[PATCH v6-1,15/17] arm64: dts: rockchip: add isp0 node for rk3399

2018-03-11 Thread Shunqian Zheng
rk3399 have two ISP, but we havn't test isp1, so just add isp0 at present.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Signed-off-by: Jacob Chen <jacob2.c...@rock-chips.com>
---
 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index 2605118..5729786 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -1614,6 +1614,24 @@
status = "disabled";
};
 
+   isp0: isp0@ff91 {
+   compatible = "rockchip,rk3399-cif-isp";
+   reg = <0x0 0xff91 0x0 0x4000>;
+   interrupts = ;
+   clocks = < SCLK_ISP0>,
+< ACLK_ISP0>, < ACLK_ISP0_WRAPPER>,
+< HCLK_ISP0>, < HCLK_ISP0_WRAPPER>;
+   clock-names = "clk_isp",
+ "aclk_isp", "aclk_isp_wrap",
+ "hclk_isp", "hclk_isp_wrap";
+   assigned-clocks = < SCLK_ISP0>, < ACLK_ISP0>;
+   assigned-clock-rates = <5>, <4>;
+
+   power-domains = < RK3399_PD_ISP0>;
+   iommus = <_mmu>;
+   status = "disabled";
+   };
+
isp0_mmu: iommu@ff914000 {
compatible = "rockchip,iommu";
reg = <0x0 0xff914000 0x0 0x100>, <0x0 0xff915000 0x0 0x100>;
-- 
1.9.1



Re: [PATCH] media: ov2685: Not delay latch for gain

2018-03-01 Thread Shunqian Zheng

Hi Tomasz,


On 2018年03月01日 16:53, Tomasz Figa wrote:

Hi Shunqian,

On Thu, Mar 1, 2018 at 5:44 PM, Shunqian Zheng <zhen...@rock-chips.com> wrote:

Update the register 0x3503 to use 'no delay latch' for gain.
This makes sensor to output the first frame as normal rather
than a very dark one.

I'm not 100% sure on how this setting works, but wouldn't it mean that
setting the gain mid-frame would result in half of the frame having
old gain and another half new? Depending how this works, perhaps we
should set this during initial register settings, but reset after
streaming starts?

Thank you.

I'm not quite sure too. Then I try to change gain during capture by:
   capture_10_frames.sh & while sleep .01; do v4l2-ctl -d /dev/video4 
--set-ctrl=analogue_gain=54; sleep .01; v4l2-ctl -d /dev/video4 
--set-ctrl=analogue_gain=1024; done


The gain setting takes effect for every single frame, not in mid-frame 
from my test.


Best wishes,
- Shunqian


Best regards,
Tomasz








[PATCH] media: ov2685: Not delay latch for gain

2018-03-01 Thread Shunqian Zheng
Update the register 0x3503 to use 'no delay latch' for gain.
This makes sensor to output the first frame as normal rather
than a very dark one.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 drivers/media/i2c/ov2685.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
index 9ac702e..83c55e8 100644
--- a/drivers/media/i2c/ov2685.c
+++ b/drivers/media/i2c/ov2685.c
@@ -119,7 +119,7 @@ struct ov2685 {
{0x3087, 0x00},
{0x3501, 0x4e},
{0x3502, 0xe0},
-   {0x3503, 0x07},
+   {0x3503, 0x27},
{0x350b, 0x36},
{0x3600, 0xb4},
{0x3603, 0x35},
-- 
1.9.1



Re: [PATCH v6 4/4] media: ov2685: add support for OV2685 sensor

2018-01-18 Thread Shunqian Zheng

Hi Sakari,


On 2018年01月19日 06:48, Sakari Ailus wrote:

Hi Shunqian,

On Tue, Jan 16, 2018 at 05:22:01PM +0800, Shunqian Zheng wrote:

+MODULE_DEVICE_TABLE(of, ov5695_of_match);

ov2685? How was this tested?

I can fix that while applying if that's the only one that needs to be taken
care of. At least it was the only one I found.


Ah.. I didn't test module building.
Thank you very much~



[PATCH v6 2/4] media: ov5695: add support for OV5695 sensor

2018-01-16 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov5695 sensor,
the driver supports following features:
 - supported resolutions
   + 2592x1944 at 30fps
   + 1920x1080 at 30fps
   + 1296x972 at 60fps
   + 1280x720 at 30fps
   + 640x480 at 120fps
 - test patterns
 - manual exposure/gain(analog and digital) control
 - vblank and hblank
 - media controller
 - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Reviewed-by: Jacopo Mondi <jacopo+rene...@jmondi.org>
---
 MAINTAINERS|7 +
 drivers/media/i2c/Kconfig  |   11 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/ov5695.c | 1399 
 4 files changed, 1418 insertions(+)
 create mode 100644 drivers/media/i2c/ov5695.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 85773bf..cca5b1c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10046,6 +10046,13 @@ T: git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/i2c/ov5647.c
 
+OMNIVISION OV5695 SENSOR DRIVER
+M:     Shunqian Zheng <zhen...@rock-chips.com>
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: drivers/media/i2c/ov5695.c
+
 OMNIVISION OV7670 SENSOR DRIVER
 M: Jonathan Corbet <cor...@lwn.net>
 L: linux-media@vger.kernel.org
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 3c6d642..55b37c8 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -645,6 +645,17 @@ config VIDEO_OV5670
  To compile this driver as a module, choose M here: the
  module will be called ov5670.
 
+config VIDEO_OV5695
+   tristate "OmniVision OV5695 sensor support"
+   depends on I2C && VIDEO_V4L2
+   depends on MEDIA_CAMERA_SUPPORT
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV5695 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov5695.
+
 config VIDEO_OV7640
tristate "OmniVision OV7640 sensor support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 548a9ef..a063030 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
 obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
+obj-$(CONFIG_VIDEO_OV5695) += ov5695.o
 obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
 obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
new file mode 100644
index 000..2db7d2e
--- /dev/null
+++ b/drivers/media/i2c/ov5695.c
@@ -0,0 +1,1399 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ov5695 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifndef V4L2_CID_DIGITAL_GAIN
+#define V4L2_CID_DIGITAL_GAIN  V4L2_CID_GAIN
+#endif
+
+/* 45Mhz * 4 Binning */
+#define OV5695_PIXEL_RATE  (45 * 1000 * 1000 * 4)
+#define OV5695_XVCLK_FREQ  2400
+
+#define CHIP_ID0x005695
+#define OV5695_REG_CHIP_ID 0x300a
+
+#define OV5695_REG_CTRL_MODE   0x0100
+#define OV5695_MODE_SW_STANDBY 0x0
+#define OV5695_MODE_STREAMING  BIT(0)
+
+#define OV5695_REG_EXPOSURE0x3500
+#defineOV5695_EXPOSURE_MIN 4
+#defineOV5695_EXPOSURE_STEP1
+#define OV5695_VTS_MAX 0x7fff
+
+#define OV5695_REG_ANALOG_GAIN 0x3509
+#defineANALOG_GAIN_MIN 0x10
+#defineANALOG_GAIN_MAX 0xf8
+#defineANALOG_GAIN_STEP1
+#defineANALOG_GAIN_DEFAULT 0xf8
+
+#define OV5695_REG_DIGI_GAIN_H 0x350a
+#define OV5695_REG_DIGI_GAIN_L 0x350b
+#define OV5695_DIGI_GAIN_L_MASK0x3f
+#define OV5695_DIGI_GAIN_H_SHIFT   6
+#define OV5695_DIGI_GAIN_MIN   0
+#define OV5695_DIGI_GAIN_MAX   (0x4000 - 1)
+#define OV5695_DIGI_GAIN_STEP  1
+#define OV5695_DIGI_GAIN_DEFAULT   1024
+
+#define OV5695_REG_TEST_PATTERN0x4503
+#defineOV5695_TEST_PATTERN_ENABLE  0x80
+#defineOV5695_TEST_PATTERN_DISABLE 0x0
+
+#define OV5695_REG_VTS 0x380e
+
+#define REG_NULL   0x
+
+#define OV5695_REG_VALUE_08BIT 1
+#define OV5695_REG_VALUE_16BIT 2
+#define OV5695_REG_VALUE_24BIT 3
+
+#define OV5695_LANES   2
+#define OV5695_BITS_PER_SAMPLE 10
+
+static const char * const ov5695_supply_names[] = {
+   "avdd",  

[PATCH v6 4/4] media: ov2685: add support for OV2685 sensor

2018-01-16 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov2685 sensor.
Though the ov2685 can output yuv data, this driver only
supports the raw bayer format, including the following features:
  - output 1600x1200 at 30fps
  - test patterns
  - manual exposure/gain control
  - vblank and hblank
  - media controller
  - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Reviewed-by: Jacopo Mondi <jacopo+rene...@jmondi.org>
---
 MAINTAINERS|   7 +
 drivers/media/i2c/Kconfig  |  12 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/ov2685.c | 845 +
 4 files changed, 865 insertions(+)
 create mode 100644 drivers/media/i2c/ov2685.c

diff --git a/MAINTAINERS b/MAINTAINERS
index cca5b1c..32afc69 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10032,6 +10032,13 @@ T: git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/i2c/ov13858.c
 
+OMNIVISION OV2685 SENSOR DRIVER
+M:     Shunqian Zheng <zhen...@rock-chips.com>
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: drivers/media/i2c/ov2685.c
+
 OMNIVISION OV5640 SENSOR DRIVER
 M: Steve Longerbeam <slongerb...@gmail.com>
 L: linux-media@vger.kernel.org
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 55b37c8..63a175d 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -586,6 +586,18 @@ config VIDEO_OV2659
  To compile this driver as a module, choose M here: the
  module will be called ov2659.
 
+config VIDEO_OV2685
+   tristate "OmniVision OV2685 sensor support"
+   depends on VIDEO_V4L2 && I2C && MEDIA_CONTROLLER
+   depends on MEDIA_CAMERA_SUPPORT
+   select V4L2_FWNODE
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV2685 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov2685.
+
 config VIDEO_OV5640
tristate "OmniVision OV5640 sensor support"
depends on OF
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index a063030..3054c69 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
 obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
 obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
+obj-$(CONFIG_VIDEO_OV2685) += ov2685.o
 obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
new file mode 100644
index 000..6940984
--- /dev/null
+++ b/drivers/media/i2c/ov2685.c
@@ -0,0 +1,845 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ov2685 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CHIP_ID0x2685
+#define OV2685_REG_CHIP_ID 0x300a
+
+#define OV2685_XVCLK_FREQ  2400
+
+#define REG_SC_CTRL_MODE   0x0100
+#define SC_CTRL_MODE_STANDBY   0x0
+#define SC_CTRL_MODE_STREAMING BIT(0)
+
+#define OV2685_REG_EXPOSURE0x3500
+#defineOV2685_EXPOSURE_MIN 4
+#defineOV2685_EXPOSURE_STEP1
+
+#define OV2685_REG_VTS 0x380e
+#define OV2685_VTS_MAX 0x7fff
+
+#define OV2685_REG_GAIN0x350a
+#define OV2685_GAIN_MIN0
+#define OV2685_GAIN_MAX0x07ff
+#define OV2685_GAIN_STEP   0x1
+#define OV2685_GAIN_DEFAULT0x0036
+
+#define OV2685_REG_TEST_PATTERN0x5080
+#define OV2685_TEST_PATTERN_DISABLED   0x00
+#define OV2685_TEST_PATTERN_COLOR_BAR  0x80
+#define OV2685_TEST_PATTERN_RANDOM 0x81
+#define OV2685_TEST_PATTERN_COLOR_BAR_FADE 0x88
+#define OV2685_TEST_PATTERN_BW_SQUARE  0x92
+#define OV2685_TEST_PATTERN_COLOR_SQUARE   0x82
+
+#define REG_NULL   0x
+
+#define OV2685_REG_VALUE_08BIT 1
+#define OV2685_REG_VALUE_16BIT 2
+#define OV2685_REG_VALUE_24BIT 3
+
+#define OV2685_LANES   1
+#define OV2685_BITS_PER_SAMPLE 10
+
+static const char * const ov2685_supply_names[] = {
+   "avdd", /* Analog power */
+   "dovdd",/* Digital I/O power */
+   "dvdd", /* Digital core power */
+};
+
+#define OV2685_NUM_SUPPLIES ARRAY_SIZE(ov2685_supply_names)
+
+struct regval {
+   u16 addr;
+   u8 val;
+};
+
+struct ov2685_mode {
+   u32 width;
+   u32 height;
+   u3

[PATCH v6 3/4] dt-bindings: media: Add bindings for OV2685

2018-01-16 Thread Shunqian Zheng
Add device tree binding documentation for the OV2685 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Reviewed-by: Jacopo Mondi <jacopo+rene...@jmondi.org>
---
 .../devicetree/bindings/media/i2c/ov2685.txt   | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2685.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov2685.txt 
b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
new file mode 100644
index 000..625c4a8
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
@@ -0,0 +1,41 @@
+* Omnivision OV2685 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: shall be "ovti,ov2685"
+- clocks: reference to the xvclk input clock
+- clock-names: shall be "xvclk"
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dovdd-supply: Digital I/O voltage supply, 1.8 volts
+- dvdd-supply: Digital core voltage supply, 1.8 volts
+- reset-gpios: Low active reset gpio
+
+The device node shall contain one 'port' child node with an
+'endpoint' subnode for its digital output video port,
+in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+The endpoint optional property 'data-lanes' shall be "<1>".
+
+Example:
+ {
+   ov2685: camera-sensor@3c {
+   compatible = "ovti,ov2685";
+   reg = <0x3c>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dovdd-supply = <>;
+   dvdd-supply = <>;
+   reset-gpios = < 3 GPIO_ACTIVE_LOW>;
+
+   port {
+   ucam_out: endpoint {
+   remote-endpoint = <_in_ucam>;
+   data-lanes = <1>;
+   };
+   };
+   };
+};
-- 
1.9.1



[PATCH v6 0/4] Add supports for OV2685 and OV5695 sensors

2018-01-16 Thread Shunqian Zheng
This adds the OV2685 and OV5695 sensor supports.

Changes of v6 are mainly addressing comments from Jacopo@
 - Fix the node/lable name inverted in Doc.
 - Guard the source code with IS_ENABLED(CONFIG_OF)
 - Move the __v4l2_ctrl_handler_setup() into ov2685_s_stream()

Changes of v5,
 - Squash the MAINTAINERS entry to driver patch

Mainly changes of v4 are addressing the comments from Sakari,
including,
 - Put dt binding before driver in series
 - Add MAINTAINERS entries
 - Use regulator_bulk_*()
 - Fix the pm_runtime_* in probe()
 - Fix the typo of 2685 0x3008/0x3010 regs

Shunqian Zheng (4):
  dt-bindings: media: Add bindings for OV5695
  media: ov5695: add support for OV5695 sensor
  dt-bindings: media: Add bindings for OV2685
  media: ov2685: add support for OV2685 sensor

 .../devicetree/bindings/media/i2c/ov2685.txt   |   41 +
 .../devicetree/bindings/media/i2c/ov5695.txt   |   41 +
 MAINTAINERS|   14 +
 drivers/media/i2c/Kconfig  |   23 +
 drivers/media/i2c/Makefile |2 +
 drivers/media/i2c/ov2685.c |  845 
 drivers/media/i2c/ov5695.c | 1399 
 7 files changed, 2365 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2685.txt
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5695.txt
 create mode 100644 drivers/media/i2c/ov2685.c
 create mode 100644 drivers/media/i2c/ov5695.c

-- 
1.9.1



[PATCH v6 1/4] dt-bindings: media: Add bindings for OV5695

2018-01-16 Thread Shunqian Zheng
Add device tree binding documentation for the OV5695 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Reviewed-by: Jacopo Mondi <jacopo+rene...@jmondi.org>
---
 .../devicetree/bindings/media/i2c/ov5695.txt   | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5695.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov5695.txt 
b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
new file mode 100644
index 000..640a637
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
@@ -0,0 +1,41 @@
+* Omnivision OV5695 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: shall be "ovti,ov5695"
+- clocks: reference to the xvclk input clock
+- clock-names: shall be "xvclk"
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dovdd-supply: Digital I/O voltage supply, 1.8 volts
+- dvdd-supply: Digital core voltage supply, 1.2 volts
+- reset-gpios: Low active reset gpio
+
+The device node shall contain one 'port' child node with an
+'endpoint' subnode for its digital output video port,
+in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+The endpoint optional property 'data-lanes' shall be "<1 2>".
+
+Example:
+ {
+   ov5695: camera-sensor@36 {
+   compatible = "ovti,ov5695";
+   reg = <0x36>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dovdd-supply = <>;
+   dvdd-supply = <_cam>;
+   reset-gpios = < 5 GPIO_ACTIVE_LOW>;
+
+   port {
+   wcam_out: endpoint {
+   remote-endpoint = <_in_wcam>;
+   data-lanes = <1 2>;
+   };
+   };
+   };
+};
-- 
1.9.1



Re: [PATCH v4 5/5] [media] MAINTAINERS: add entries for OV2685/OV5695 sensor drivers

2018-01-11 Thread Shunqian Zheng

Hi Sakari,


On 2018年01月10日 06:33, Sakari Ailus wrote:

On Tue, Jan 09, 2018 at 10:48:24PM +0800, Shunqian Zheng wrote:

Add maintainer entries for the OV2685 and OV5695 V4L2 sensor drivers.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>

Same patch with the driver, please.

Other than that seems good to me.

Does that mean I can add your Reviewed-by in the new patches?

Thank you very much~







Re: [PATCH v5 1/4] dt-bindings: media: Add bindings for OV5695

2018-01-10 Thread Shunqian Zheng

Hi Jacopo,


On 2018年01月10日 17:20, jacopo mondi wrote:

Hi Shunqian,

On Wed, Jan 10, 2018 at 10:06:04AM +0800, Shunqian Zheng wrote:

Add device tree binding documentation for the OV5695 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
  .../devicetree/bindings/media/i2c/ov5695.txt   | 41 ++
  1 file changed, 41 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5695.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov5695.txt 
b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
new file mode 100644
index 000..2f2f698
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
@@ -0,0 +1,41 @@
+* Omnivision OV5695 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: shall be "ovti,ov5695"
+- clocks: reference to the xvclk input clock
+- clock-names: shall be "xvclk"
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dovdd-supply: Digital I/O voltage supply, 1.8 volts
+- dvdd-supply: Digital core voltage supply, 1.2 volts
+- reset-gpios: Low active reset gpio
+
+The device node shall contain one 'port' child node with an
+'endpoint' subnode for its digital output video port,
+in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+The endpoint optional property 'data-lanes' shall be "<1 2>".

What happens if the property is not present? What's the default?
I think it depends on how the video receiver deal with, 'data-lanes' is 
optional as described in video-interfaces.txt,

but if somehow it used in DT, the value "<1 2>" is the right one.


I would:

Required Properties:
- compatible: ..


Option Endpoint Properties:
- data-lanes: ...


+
+Example:
+ {
+   camera-sensor: ov5695@36 {

You have inverted the label with the node name which should be generic

 ov5695: camera@36 {


 }
Thanks
j

Thank you very much~
Shunqian








Re: [PATCH v5 2/4] media: ov5695: add support for OV5695 sensor

2018-01-10 Thread Shunqian Zheng

Hi Jacopo,


On 2018年01月10日 17:08, jacopo mondi wrote:

Hello Shunqian,

On Wed, Jan 10, 2018 at 10:06:05AM +0800, Shunqian Zheng wrote:

[snip]


+static int __ov5695_start_stream(struct ov5695 *ov5695)
+{
+   int ret;
+
+   ret = ov5695_write_array(ov5695->client, ov5695_global_regs);
+   if (ret)
+   return ret;
+   ret = ov5695_write_array(ov5695->client, ov5695->cur_mode->reg_list);
+   if (ret)
+   return ret;
+
+   /* In case these controls are set before streaming */
+   ret = __v4l2_ctrl_handler_setup(>ctrl_handler);
+   if (ret)
+   return ret;
+
+   return ov5695_write_reg(ov5695->client, OV5695_REG_CTRL_MODE,
+   OV5695_REG_VALUE_08BIT, OV5695_MODE_STREAMING);
+}
+
+static int __ov5695_stop_stream(struct ov5695 *ov5695)
+{
+   return ov5695_write_reg(ov5695->client, OV5695_REG_CTRL_MODE,
+   OV5695_REG_VALUE_08BIT, OV5695_MODE_SW_STANDBY);
+}
+
+static int ov5695_s_stream(struct v4l2_subdev *sd, int on)
+{
+   struct ov5695 *ov5695 = to_ov5695(sd);
+   struct i2c_client *client = ov5695->client;
+   int ret = 0;
+
+   mutex_lock(>mutex);
+   on = !!on;
+   if (on == ov5695->streaming)
+   goto unlock_and_return;
+
+   if (on) {
+   ret = pm_runtime_get_sync(>dev);
+   if (ret < 0) {
+   pm_runtime_put_noidle(>dev);
+   goto unlock_and_return;
+   }
+
+   ret = __ov5695_start_stream(ov5695);
+   if (ret) {
+   v4l2_err(sd, "start stream failed while write regs\n");
+   pm_runtime_put(>dev);
+   goto unlock_and_return;
+   }
+   } else {
+   __ov5695_stop_stream(ov5695);
+   ret = pm_runtime_put(>dev);

I would return the result of __ov5695_stop_stream() instead of
pm_runtime_put().

I know I asked for this, but if the first s_stream(0) fails, the
sensor may not have been stopped but the interface will be put in
"streaming = 0" state, preventing a second s_stream(0) to be issued
because of your check "on == ov5695->streaming" a few lines above.

I can't tell how bad this is. Imho is acceptable but I would like to
hear someone else opinion here :)

How about not checking the return values of s_stream(0) branch?
It seems not much this driver can do if pm_runtime_put() fails.



+   }
+
+   ov5695->streaming = on;
+
+unlock_and_return:
+   mutex_unlock(>mutex);
+
+   return ret;
+}
+
+

[snip]


+static const struct of_device_id ov5695_of_match[] = {
+   { .compatible = "ovti,ov5695" },
+   {},
+};

If you don't list CONFIG_OF as a dependecy for this driver (which you
should not imho), please guard this with:

#if IS_ENABLED(CONFIG_OF)

#endif


+
+static struct i2c_driver ov5695_i2c_driver = {
+   .driver = {
+   .name = "ov5695",
+   .owner = THIS_MODULE,
+   .pm = _pm_ops,
+   .of_match_table = ov5695_of_match
+   },
+   .probe  = _probe,
+   .remove = _remove,
+};
+
+module_i2c_driver(ov5695_i2c_driver);
+
+MODULE_DESCRIPTION("OmniVision ov5695 sensor driver");
+MODULE_LICENSE("GPL v2");

As you've fixed my comments on v1, and with the above bits addressed:

Reviewed-by: Jacopo Mondi <jacopo+rene...@jmondi.org>

Thank you very much~
Shunqian


Thanks
j


--
1.9.1









[PATCH v5 4/4] media: ov2685: add support for OV2685 sensor

2018-01-09 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov2685 sensor.
Though the ov2685 can output yuv data, this driver only
supports the raw bayer format, including the following features:
  - output 1600x1200 at 30fps
  - test patterns
  - manual exposure/gain control
  - vblank and hblank
  - media controller
  - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 MAINTAINERS|   7 +
 drivers/media/i2c/Kconfig  |  12 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/ov2685.c | 842 +
 4 files changed, 862 insertions(+)
 create mode 100644 drivers/media/i2c/ov2685.c

diff --git a/MAINTAINERS b/MAINTAINERS
index cca5b1c..32afc69 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10032,6 +10032,13 @@ T: git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/i2c/ov13858.c
 
+OMNIVISION OV2685 SENSOR DRIVER
+M: Shunqian Zheng <zhen...@rock-chips.com>
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: drivers/media/i2c/ov2685.c
+
 OMNIVISION OV5640 SENSOR DRIVER
 M: Steve Longerbeam <slongerb...@gmail.com>
 L: linux-media@vger.kernel.org
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 55b37c8..63a175d 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -586,6 +586,18 @@ config VIDEO_OV2659
  To compile this driver as a module, choose M here: the
  module will be called ov2659.
 
+config VIDEO_OV2685
+   tristate "OmniVision OV2685 sensor support"
+   depends on VIDEO_V4L2 && I2C && MEDIA_CONTROLLER
+   depends on MEDIA_CAMERA_SUPPORT
+   select V4L2_FWNODE
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV2685 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov2685.
+
 config VIDEO_OV5640
tristate "OmniVision OV5640 sensor support"
depends on OF
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index a063030..3054c69 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
 obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
 obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
+obj-$(CONFIG_VIDEO_OV2685) += ov2685.o
 obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
new file mode 100644
index 000..e9339e2
--- /dev/null
+++ b/drivers/media/i2c/ov2685.c
@@ -0,0 +1,842 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ov2685 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CHIP_ID0x2685
+#define OV2685_REG_CHIP_ID 0x300a
+
+#define OV2685_XVCLK_FREQ  2400
+
+#define REG_SC_CTRL_MODE   0x0100
+#define SC_CTRL_MODE_STANDBY   0x0
+#define SC_CTRL_MODE_STREAMING BIT(0)
+
+#define OV2685_REG_EXPOSURE0x3500
+#defineOV2685_EXPOSURE_MIN 4
+#defineOV2685_EXPOSURE_STEP1
+
+#define OV2685_REG_VTS 0x380e
+#define OV2685_VTS_MAX 0x7fff
+
+#define OV2685_REG_GAIN0x350a
+#define OV2685_GAIN_MIN0
+#define OV2685_GAIN_MAX0x07ff
+#define OV2685_GAIN_STEP   0x1
+#define OV2685_GAIN_DEFAULT0x0036
+
+#define OV2685_REG_TEST_PATTERN0x5080
+#define OV2685_TEST_PATTERN_DISABLED   0x00
+#define OV2685_TEST_PATTERN_COLOR_BAR  0x80
+#define OV2685_TEST_PATTERN_RANDOM 0x81
+#define OV2685_TEST_PATTERN_COLOR_BAR_FADE 0x88
+#define OV2685_TEST_PATTERN_BW_SQUARE  0x92
+#define OV2685_TEST_PATTERN_COLOR_SQUARE   0x82
+
+#define REG_NULL   0x
+
+#define OV2685_REG_VALUE_08BIT 1
+#define OV2685_REG_VALUE_16BIT 2
+#define OV2685_REG_VALUE_24BIT 3
+
+#define OV2685_LANES   1
+#define OV2685_BITS_PER_SAMPLE 10
+
+static const char * const ov2685_supply_names[] = {
+   "avdd", /* Analog power */
+   "dovdd",/* Digital I/O power */
+   "dvdd", /* Digital core power */
+};
+
+#define OV2685_NUM_SUPPLIES ARRAY_SIZE(ov2685_supply_names)
+
+struct regval {
+   u16 addr;
+   u8 val;
+};
+
+struct ov2685_mode {
+   u32 width;
+   u32 height;
+   u32 exp_def;
+   u32 hts_def;
+   u32 vts_def;
+   const str

[PATCH v5 3/4] dt-bindings: media: Add bindings for OV2685

2018-01-09 Thread Shunqian Zheng
Add device tree binding documentation for the OV2685 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 .../devicetree/bindings/media/i2c/ov2685.txt   | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2685.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov2685.txt 
b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
new file mode 100644
index 000..f1586a2
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
@@ -0,0 +1,41 @@
+* Omnivision OV2685 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: shall be "ovti,ov2685"
+- clocks: reference to the xvclk input clock
+- clock-names: shall be "xvclk"
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dovdd-supply: Digital I/O voltage supply, 1.8 volts
+- dvdd-supply: Digital core voltage supply, 1.8 volts
+- reset-gpios: Low active reset gpio
+
+The device node shall contain one 'port' child node with an
+'endpoint' subnode for its digital output video port,
+in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+The endpoint optional property 'data-lanes' shall be "<1>".
+
+Example:
+ {
+   camera-sensor: ov2685@3c {
+   compatible = "ovti,ov2685";
+   reg = <0x3c>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dovdd-supply = <>;
+   dvdd-supply = <>;
+   reset-gpios = < 3 GPIO_ACTIVE_LOW>;
+
+   port {
+   ucam_out: endpoint {
+   remote-endpoint = <_in_ucam>;
+   data-lanes = <1>;
+   };
+   };
+   };
+};
-- 
1.9.1



[PATCH v5 0/4] Add supports for OV2685 and OV5695 sensors

2018-01-09 Thread Shunqian Zheng
This adds the OV2685 and OV5695 sensor supports.

Changes of v5,
 - Squash the MAINTAINERS entry to driver patch

Mainly changes of v4 are addressing the comments from Sakari,
including,
 - Put dt binding before driver in series
 - Add MAINTAINERS entries
 - Use regulator_bulk_*()
 - Fix the pm_runtime_* in probe()
 - Fix the typo of 2685 0x3008/0x3010 regs

Shunqian Zheng (4):
  dt-bindings: media: Add bindings for OV5695
  media: ov5695: add support for OV5695 sensor
  dt-bindings: media: Add bindings for OV2685
  media: ov2685: add support for OV2685 sensor

 .../devicetree/bindings/media/i2c/ov2685.txt   |   41 +
 .../devicetree/bindings/media/i2c/ov5695.txt   |   41 +
 MAINTAINERS|   14 +
 drivers/media/i2c/Kconfig  |   23 +
 drivers/media/i2c/Makefile |2 +
 drivers/media/i2c/ov2685.c |  842 
 drivers/media/i2c/ov5695.c | 1396 
 7 files changed, 2359 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2685.txt
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5695.txt
 create mode 100644 drivers/media/i2c/ov2685.c
 create mode 100644 drivers/media/i2c/ov5695.c

-- 
1.9.1



[PATCH v5 1/4] dt-bindings: media: Add bindings for OV5695

2018-01-09 Thread Shunqian Zheng
Add device tree binding documentation for the OV5695 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 .../devicetree/bindings/media/i2c/ov5695.txt   | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5695.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov5695.txt 
b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
new file mode 100644
index 000..2f2f698
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
@@ -0,0 +1,41 @@
+* Omnivision OV5695 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: shall be "ovti,ov5695"
+- clocks: reference to the xvclk input clock
+- clock-names: shall be "xvclk"
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dovdd-supply: Digital I/O voltage supply, 1.8 volts
+- dvdd-supply: Digital core voltage supply, 1.2 volts
+- reset-gpios: Low active reset gpio
+
+The device node shall contain one 'port' child node with an
+'endpoint' subnode for its digital output video port,
+in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+The endpoint optional property 'data-lanes' shall be "<1 2>".
+
+Example:
+ {
+   camera-sensor: ov5695@36 {
+   compatible = "ovti,ov5695";
+   reg = <0x36>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dovdd-supply = <>;
+   dvdd-supply = <_cam>;
+   reset-gpios = < 5 GPIO_ACTIVE_LOW>;
+
+   port {
+   wcam_out: endpoint {
+   remote-endpoint = <_in_wcam>;
+   data-lanes = <1 2>;
+   };
+   };
+   };
+};
-- 
1.9.1



[PATCH v5 2/4] media: ov5695: add support for OV5695 sensor

2018-01-09 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov5695 sensor,
the driver supports following features:
 - supported resolutions
   + 2592x1944 at 30fps
   + 1920x1080 at 30fps
   + 1296x972 at 60fps
   + 1280x720 at 30fps
   + 640x480 at 120fps
 - test patterns
 - manual exposure/gain(analog and digital) control
 - vblank and hblank
 - media controller
 - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 MAINTAINERS|7 +
 drivers/media/i2c/Kconfig  |   11 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/ov5695.c | 1396 
 4 files changed, 1415 insertions(+)
 create mode 100644 drivers/media/i2c/ov5695.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 85773bf..cca5b1c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10046,6 +10046,13 @@ T: git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/i2c/ov5647.c
 
+OMNIVISION OV5695 SENSOR DRIVER
+M: Shunqian Zheng <zhen...@rock-chips.com>
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: drivers/media/i2c/ov5695.c
+
 OMNIVISION OV7670 SENSOR DRIVER
 M: Jonathan Corbet <cor...@lwn.net>
 L: linux-media@vger.kernel.org
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 3c6d642..55b37c8 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -645,6 +645,17 @@ config VIDEO_OV5670
  To compile this driver as a module, choose M here: the
  module will be called ov5670.
 
+config VIDEO_OV5695
+   tristate "OmniVision OV5695 sensor support"
+   depends on I2C && VIDEO_V4L2
+   depends on MEDIA_CAMERA_SUPPORT
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV5695 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov5695.
+
 config VIDEO_OV7640
tristate "OmniVision OV7640 sensor support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 548a9ef..a063030 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
 obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
+obj-$(CONFIG_VIDEO_OV5695) += ov5695.o
 obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
 obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
new file mode 100644
index 000..c2e0462
--- /dev/null
+++ b/drivers/media/i2c/ov5695.c
@@ -0,0 +1,1396 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ov5695 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifndef V4L2_CID_DIGITAL_GAIN
+#define V4L2_CID_DIGITAL_GAIN  V4L2_CID_GAIN
+#endif
+
+/* 45Mhz * 4 Binning */
+#define OV5695_PIXEL_RATE  (45 * 1000 * 1000 * 4)
+#define OV5695_XVCLK_FREQ  2400
+
+#define CHIP_ID0x005695
+#define OV5695_REG_CHIP_ID 0x300a
+
+#define OV5695_REG_CTRL_MODE   0x0100
+#define OV5695_MODE_SW_STANDBY 0x0
+#define OV5695_MODE_STREAMING  BIT(0)
+
+#define OV5695_REG_EXPOSURE0x3500
+#defineOV5695_EXPOSURE_MIN 4
+#defineOV5695_EXPOSURE_STEP1
+#define OV5695_VTS_MAX 0x7fff
+
+#define OV5695_REG_ANALOG_GAIN 0x3509
+#defineANALOG_GAIN_MIN 0x10
+#defineANALOG_GAIN_MAX 0xf8
+#defineANALOG_GAIN_STEP1
+#defineANALOG_GAIN_DEFAULT 0xf8
+
+#define OV5695_REG_DIGI_GAIN_H 0x350a
+#define OV5695_REG_DIGI_GAIN_L 0x350b
+#define OV5695_DIGI_GAIN_L_MASK0x3f
+#define OV5695_DIGI_GAIN_H_SHIFT   6
+#define OV5695_DIGI_GAIN_MIN   0
+#define OV5695_DIGI_GAIN_MAX   (0x4000 - 1)
+#define OV5695_DIGI_GAIN_STEP  1
+#define OV5695_DIGI_GAIN_DEFAULT   1024
+
+#define OV5695_REG_TEST_PATTERN0x4503
+#defineOV5695_TEST_PATTERN_ENABLE  0x80
+#defineOV5695_TEST_PATTERN_DISABLE 0x0
+
+#define OV5695_REG_VTS 0x380e
+
+#define REG_NULL   0x
+
+#define OV5695_REG_VALUE_08BIT 1
+#define OV5695_REG_VALUE_16BIT 2
+#define OV5695_REG_VALUE_24BIT 3
+
+#define OV5695_LANES   2
+#define OV5695_BITS_PER_SAMPLE 10
+
+static const char * const ov5695_supply_names[] = {
+   "avdd", /* Analog power */
+   "dovdd",/* Digital I/

Re: [PATCH v4 2/5] media: ov5695: add support for OV5695 sensor

2018-01-09 Thread Shunqian Zheng

Hi Baruch,


On 2018年01月10日 00:54, Baruch Siach wrote:

Hi Shunqian Zheng,

On Tue, Jan 09, 2018 at 10:48:21PM +0800, Shunqian Zheng wrote:

+static int ov5695_write_array(struct i2c_client *client,
+ const struct regval *regs)
+{
+   u32 i;
+   int ret = 0;
+
+   for (i = 0; ret == 0 && regs[i].addr != REG_NULL; i++)
+   ret = ov5695_write_reg(client, regs[i].addr,
+  OV5695_REG_VALUE_08BIT, regs[i].val);

This loop should stop on first failure, and return the error value. With
current code a register write failure is masked by following writes.

This loop will stop once ret != 0 as in for loop condition

Thanks,



+
+   return ret;
+}

baruch






Re: [PATCH v3 1/4] media: ov5695: add support for OV5695 sensor

2018-01-09 Thread Shunqian Zheng

Hi Sakari,


On 2018年01月09日 06:20, Sakari Ailus wrote:

Hi Shunqian,

Could you next time add a cover page to the patchset that details the
changes from the previous version?

Please also add a MAINTAINERS entry. DT binding files should also precede
the driver.

Done.
By the way, why DT binding files should precede the driver?


On Mon, Jan 08, 2018 at 09:36:04PM +0800, Shunqian Zheng wrote:

This patch adds driver for Omnivision's ov5695 sensor,
the driver supports following features:
  - supported resolutions
+ 2592x1944 at 30fps
+ 1920x1080 at 30fps
+ 1296x972 at 60fps
+ 1280x720 at 30fps
+ 640x480 at 120fps
  - test patterns
  - manual exposure/gain(analog and digital) control
  - vblank and hblank
  - media controller
  - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
  drivers/media/i2c/Kconfig  |   11 +
  drivers/media/i2c/Makefile |1 +
  drivers/media/i2c/ov5695.c | 1392 
  3 files changed, 1404 insertions(+)
  create mode 100644 drivers/media/i2c/ov5695.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 3c6d642..55b37c8 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -645,6 +645,17 @@ config VIDEO_OV5670
  To compile this driver as a module, choose M here: the
  module will be called ov5670.
  
+config VIDEO_OV5695

+   tristate "OmniVision OV5695 sensor support"
+   depends on I2C && VIDEO_V4L2
+   depends on MEDIA_CAMERA_SUPPORT
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV5695 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov5695.
+
  config VIDEO_OV7640
tristate "OmniVision OV7640 sensor support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 548a9ef..a063030 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
  obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
  obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
  obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
+obj-$(CONFIG_VIDEO_OV5695) += ov5695.o
  obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
  obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
  obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
new file mode 100644
index 000..7e8bd82
--- /dev/null
+++ b/drivers/media/i2c/ov5695.c
@@ -0,0 +1,1392 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ov5695 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifndef V4L2_CID_DIGITAL_GAIN
+#define V4L2_CID_DIGITAL_GAIN  V4L2_CID_GAIN
+#endif
+
+/* 45Mhz * 4 Binning */
+#define OV5695_PIXEL_RATE  (45 * 1000 * 1000 * 4)
+#define CHIP_ID0x005695
+#define OV5695_REG_CHIP_ID 0x300a
+
+#define OV5695_REG_CTRL_MODE   0x0100
+#define OV5695_MODE_SW_STANDBY 0x0
+#define OV5695_MODE_STREAMING  BIT(0)
+
+#define OV5695_REG_EXPOSURE0x3500
+#defineOV5695_EXPOSURE_MIN 4
+#defineOV5695_EXPOSURE_STEP1
+#define OV5695_VTS_MAX 0x7fff
+
+#define OV5695_REG_ANALOG_GAIN 0x3509
+#defineANALOG_GAIN_MIN 0x10
+#defineANALOG_GAIN_MAX 0xf8
+#defineANALOG_GAIN_STEP1
+#defineANALOG_GAIN_DEFAULT 0xf8
+
+#define OV5695_REG_DIGI_GAIN_H 0x350a
+#define OV5695_REG_DIGI_GAIN_L 0x350b
+#define OV5695_DIGI_GAIN_L_MASK0x3f
+#define OV5695_DIGI_GAIN_H_SHIFT   6
+#define OV5695_DIGI_GAIN_MIN   0
+#define OV5695_DIGI_GAIN_MAX   (0x4000 - 1)
+#define OV5695_DIGI_GAIN_STEP  1
+#define OV5695_DIGI_GAIN_DEFAULT   1024
+
+#define OV5695_REG_TEST_PATTERN0x4503
+#defineOV5695_TEST_PATTERN_ENABLE  0x80
+#defineOV5695_TEST_PATTERN_DISABLE 0x0
+
+#define OV5695_REG_VTS 0x380e
+
+#define REG_NULL   0x
+
+#define OV5695_REG_VALUE_08BIT 1
+#define OV5695_REG_VALUE_16BIT 2
+#define OV5695_REG_VALUE_24BIT 3
+
+#define OV5695_LANES   2
+#define OV5695_BITS_PER_SAMPLE 10
+
+struct regval {
+   u16 addr;
+   u8 val;
+};
+
+struct ov5695_mode {
+   u32 width;
+   u32 height;
+   u32 max_fps;
+   u32 hts_def;
+   u32 vts_def;
+   u32 exp_def;
+   const struct regval *reg_list;
+};
+
+struct ov5695 {
+   struct i2c_client   *client;
+   struct clk  *xvclk;
+   struct regulator   

[PATCH v4 0/5] Add supports for OV2685 and OV5695 sensors

2018-01-09 Thread Shunqian Zheng
This adds the OV2685 and OV5695 sensor supports.

Mainly changes of v4 are addressing the comments from Sakari,
including,
 - Put dt binding before driver in series
 - Add MAINTAINERS entries
 - Use regulator_bulk_*()
 - Fix the pm_runtime_* in probe()
 - Fix the typo of 2685 0x3008/0x3010 regs

Shunqian Zheng (5):
  dt-bindings: media: Add bindings for OV5695
  media: ov5695: add support for OV5695 sensor
  dt-bindings: media: Add bindings for OV2685
  media: ov2685: add support for OV2685 sensor
  [media] MAINTAINERS: add entries for OV2685/OV5695 sensor drivers

 .../devicetree/bindings/media/i2c/ov2685.txt   |   41 +
 .../devicetree/bindings/media/i2c/ov5695.txt   |   41 +
 MAINTAINERS|   14 +
 drivers/media/i2c/Kconfig  |   23 +
 drivers/media/i2c/Makefile |2 +
 drivers/media/i2c/ov2685.c |  842 
 drivers/media/i2c/ov5695.c | 1396 
 7 files changed, 2359 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2685.txt
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5695.txt
 create mode 100644 drivers/media/i2c/ov2685.c
 create mode 100644 drivers/media/i2c/ov5695.c

-- 
1.9.1



[PATCH v4 1/5] dt-bindings: media: Add bindings for OV5695

2018-01-09 Thread Shunqian Zheng
Add device tree binding documentation for the OV5695 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 .../devicetree/bindings/media/i2c/ov5695.txt   | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5695.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov5695.txt 
b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
new file mode 100644
index 000..2f2f698
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
@@ -0,0 +1,41 @@
+* Omnivision OV5695 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: shall be "ovti,ov5695"
+- clocks: reference to the xvclk input clock
+- clock-names: shall be "xvclk"
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dovdd-supply: Digital I/O voltage supply, 1.8 volts
+- dvdd-supply: Digital core voltage supply, 1.2 volts
+- reset-gpios: Low active reset gpio
+
+The device node shall contain one 'port' child node with an
+'endpoint' subnode for its digital output video port,
+in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+The endpoint optional property 'data-lanes' shall be "<1 2>".
+
+Example:
+ {
+   camera-sensor: ov5695@36 {
+   compatible = "ovti,ov5695";
+   reg = <0x36>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dovdd-supply = <>;
+   dvdd-supply = <_cam>;
+   reset-gpios = < 5 GPIO_ACTIVE_LOW>;
+
+   port {
+   wcam_out: endpoint {
+   remote-endpoint = <_in_wcam>;
+   data-lanes = <1 2>;
+   };
+   };
+   };
+};
-- 
1.9.1



[PATCH v4 2/5] media: ov5695: add support for OV5695 sensor

2018-01-09 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov5695 sensor,
the driver supports following features:
 - supported resolutions
   + 2592x1944 at 30fps
   + 1920x1080 at 30fps
   + 1296x972 at 60fps
   + 1280x720 at 30fps
   + 640x480 at 120fps
 - test patterns
 - manual exposure/gain(analog and digital) control
 - vblank and hblank
 - media controller
 - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 drivers/media/i2c/Kconfig  |   11 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/ov5695.c | 1396 
 3 files changed, 1408 insertions(+)
 create mode 100644 drivers/media/i2c/ov5695.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 3c6d642..55b37c8 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -645,6 +645,17 @@ config VIDEO_OV5670
  To compile this driver as a module, choose M here: the
  module will be called ov5670.
 
+config VIDEO_OV5695
+   tristate "OmniVision OV5695 sensor support"
+   depends on I2C && VIDEO_V4L2
+   depends on MEDIA_CAMERA_SUPPORT
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV5695 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov5695.
+
 config VIDEO_OV7640
tristate "OmniVision OV7640 sensor support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 548a9ef..a063030 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
 obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
+obj-$(CONFIG_VIDEO_OV5695) += ov5695.o
 obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
 obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
new file mode 100644
index 000..c2e0462
--- /dev/null
+++ b/drivers/media/i2c/ov5695.c
@@ -0,0 +1,1396 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ov5695 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifndef V4L2_CID_DIGITAL_GAIN
+#define V4L2_CID_DIGITAL_GAIN  V4L2_CID_GAIN
+#endif
+
+/* 45Mhz * 4 Binning */
+#define OV5695_PIXEL_RATE  (45 * 1000 * 1000 * 4)
+#define OV5695_XVCLK_FREQ  2400
+
+#define CHIP_ID0x005695
+#define OV5695_REG_CHIP_ID 0x300a
+
+#define OV5695_REG_CTRL_MODE   0x0100
+#define OV5695_MODE_SW_STANDBY 0x0
+#define OV5695_MODE_STREAMING  BIT(0)
+
+#define OV5695_REG_EXPOSURE0x3500
+#defineOV5695_EXPOSURE_MIN 4
+#defineOV5695_EXPOSURE_STEP1
+#define OV5695_VTS_MAX 0x7fff
+
+#define OV5695_REG_ANALOG_GAIN 0x3509
+#defineANALOG_GAIN_MIN 0x10
+#defineANALOG_GAIN_MAX 0xf8
+#defineANALOG_GAIN_STEP1
+#defineANALOG_GAIN_DEFAULT 0xf8
+
+#define OV5695_REG_DIGI_GAIN_H 0x350a
+#define OV5695_REG_DIGI_GAIN_L 0x350b
+#define OV5695_DIGI_GAIN_L_MASK0x3f
+#define OV5695_DIGI_GAIN_H_SHIFT   6
+#define OV5695_DIGI_GAIN_MIN   0
+#define OV5695_DIGI_GAIN_MAX   (0x4000 - 1)
+#define OV5695_DIGI_GAIN_STEP  1
+#define OV5695_DIGI_GAIN_DEFAULT   1024
+
+#define OV5695_REG_TEST_PATTERN0x4503
+#defineOV5695_TEST_PATTERN_ENABLE  0x80
+#defineOV5695_TEST_PATTERN_DISABLE 0x0
+
+#define OV5695_REG_VTS 0x380e
+
+#define REG_NULL   0x
+
+#define OV5695_REG_VALUE_08BIT 1
+#define OV5695_REG_VALUE_16BIT 2
+#define OV5695_REG_VALUE_24BIT 3
+
+#define OV5695_LANES   2
+#define OV5695_BITS_PER_SAMPLE 10
+
+static const char * const ov5695_supply_names[] = {
+   "avdd", /* Analog power */
+   "dovdd",/* Digital I/O power */
+   "dvdd", /* Digital core power */
+};
+
+#define OV5695_NUM_SUPPLIES ARRAY_SIZE(ov5695_supply_names)
+
+struct regval {
+   u16 addr;
+   u8 val;
+};
+
+struct ov5695_mode {
+   u32 width;
+   u32 height;
+   u32 max_fps;
+   u32 hts_def;
+   u32 vts_def;
+   u32 exp_def;
+   const struct regval *reg_list;
+};
+
+struct ov5695 {
+   struct i2c_client   *client;
+   struct clk  *xvclk;
+   struct gpio_desc*reset_gpio;
+   struct regulator_bulk_data supplies[OV5695_NUM_SUPPLIES];
+
+  

[PATCH v4 4/5] media: ov2685: add support for OV2685 sensor

2018-01-09 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov2685 sensor.
Though the ov2685 can output yuv data, this driver only
supports the raw bayer format, including the following features:
  - output 1600x1200 at 30fps
  - test patterns
  - manual exposure/gain control
  - vblank and hblank
  - media controller
  - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 drivers/media/i2c/Kconfig  |  12 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/ov2685.c | 842 +
 3 files changed, 855 insertions(+)
 create mode 100644 drivers/media/i2c/ov2685.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 55b37c8..63a175d 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -586,6 +586,18 @@ config VIDEO_OV2659
  To compile this driver as a module, choose M here: the
  module will be called ov2659.
 
+config VIDEO_OV2685
+   tristate "OmniVision OV2685 sensor support"
+   depends on VIDEO_V4L2 && I2C && MEDIA_CONTROLLER
+   depends on MEDIA_CAMERA_SUPPORT
+   select V4L2_FWNODE
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV2685 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov2685.
+
 config VIDEO_OV5640
tristate "OmniVision OV5640 sensor support"
depends on OF
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index a063030..3054c69 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
 obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
 obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
+obj-$(CONFIG_VIDEO_OV2685) += ov2685.o
 obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
new file mode 100644
index 000..e9339e2
--- /dev/null
+++ b/drivers/media/i2c/ov2685.c
@@ -0,0 +1,842 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ov2685 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CHIP_ID0x2685
+#define OV2685_REG_CHIP_ID 0x300a
+
+#define OV2685_XVCLK_FREQ  2400
+
+#define REG_SC_CTRL_MODE   0x0100
+#define SC_CTRL_MODE_STANDBY   0x0
+#define SC_CTRL_MODE_STREAMING BIT(0)
+
+#define OV2685_REG_EXPOSURE0x3500
+#defineOV2685_EXPOSURE_MIN 4
+#defineOV2685_EXPOSURE_STEP1
+
+#define OV2685_REG_VTS 0x380e
+#define OV2685_VTS_MAX 0x7fff
+
+#define OV2685_REG_GAIN0x350a
+#define OV2685_GAIN_MIN0
+#define OV2685_GAIN_MAX0x07ff
+#define OV2685_GAIN_STEP   0x1
+#define OV2685_GAIN_DEFAULT0x0036
+
+#define OV2685_REG_TEST_PATTERN0x5080
+#define OV2685_TEST_PATTERN_DISABLED   0x00
+#define OV2685_TEST_PATTERN_COLOR_BAR  0x80
+#define OV2685_TEST_PATTERN_RANDOM 0x81
+#define OV2685_TEST_PATTERN_COLOR_BAR_FADE 0x88
+#define OV2685_TEST_PATTERN_BW_SQUARE  0x92
+#define OV2685_TEST_PATTERN_COLOR_SQUARE   0x82
+
+#define REG_NULL   0x
+
+#define OV2685_REG_VALUE_08BIT 1
+#define OV2685_REG_VALUE_16BIT 2
+#define OV2685_REG_VALUE_24BIT 3
+
+#define OV2685_LANES   1
+#define OV2685_BITS_PER_SAMPLE 10
+
+static const char * const ov2685_supply_names[] = {
+   "avdd", /* Analog power */
+   "dovdd",/* Digital I/O power */
+   "dvdd", /* Digital core power */
+};
+
+#define OV2685_NUM_SUPPLIES ARRAY_SIZE(ov2685_supply_names)
+
+struct regval {
+   u16 addr;
+   u8 val;
+};
+
+struct ov2685_mode {
+   u32 width;
+   u32 height;
+   u32 exp_def;
+   u32 hts_def;
+   u32 vts_def;
+   const struct regval *reg_list;
+};
+
+struct ov2685 {
+   struct i2c_client   *client;
+   struct clk  *xvclk;
+   struct gpio_desc*reset_gpio;
+   struct regulator_bulk_data supplies[OV2685_NUM_SUPPLIES];
+
+   boolstreaming;
+   struct mutexmutex;
+   struct v4l2_subdev  subdev;
+   struct media_padpad;
+   struct v4l2_ctrl*anal_gain;
+   struct v4l2_ctrl*exposure;
+   struct v4l2_ctrl*hblank;
+   struct v4l2_ctrl*vblank;
+   struct v4l2_ctrl*test_patter

[PATCH v4 3/5] dt-bindings: media: Add bindings for OV2685

2018-01-09 Thread Shunqian Zheng
Add device tree binding documentation for the OV2685 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 .../devicetree/bindings/media/i2c/ov2685.txt   | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2685.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov2685.txt 
b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
new file mode 100644
index 000..f1586a2
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
@@ -0,0 +1,41 @@
+* Omnivision OV2685 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: shall be "ovti,ov2685"
+- clocks: reference to the xvclk input clock
+- clock-names: shall be "xvclk"
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dovdd-supply: Digital I/O voltage supply, 1.8 volts
+- dvdd-supply: Digital core voltage supply, 1.8 volts
+- reset-gpios: Low active reset gpio
+
+The device node shall contain one 'port' child node with an
+'endpoint' subnode for its digital output video port,
+in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+The endpoint optional property 'data-lanes' shall be "<1>".
+
+Example:
+ {
+   camera-sensor: ov2685@3c {
+   compatible = "ovti,ov2685";
+   reg = <0x3c>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dovdd-supply = <>;
+   dvdd-supply = <>;
+   reset-gpios = < 3 GPIO_ACTIVE_LOW>;
+
+   port {
+   ucam_out: endpoint {
+   remote-endpoint = <_in_ucam>;
+   data-lanes = <1>;
+   };
+   };
+   };
+};
-- 
1.9.1



[PATCH v4 5/5] [media] MAINTAINERS: add entries for OV2685/OV5695 sensor drivers

2018-01-09 Thread Shunqian Zheng
Add maintainer entries for the OV2685 and OV5695 V4L2 sensor drivers.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 MAINTAINERS | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 85773bf..32afc69 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10032,6 +10032,13 @@ T: git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/i2c/ov13858.c
 
+OMNIVISION OV2685 SENSOR DRIVER
+M: Shunqian Zheng <zhen...@rock-chips.com>
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: drivers/media/i2c/ov2685.c
+
 OMNIVISION OV5640 SENSOR DRIVER
 M: Steve Longerbeam <slongerb...@gmail.com>
 L: linux-media@vger.kernel.org
@@ -10046,6 +10053,13 @@ T: git git://linuxtv.org/media_tree.git
 S: Maintained
 F: drivers/media/i2c/ov5647.c
 
+OMNIVISION OV5695 SENSOR DRIVER
+M: Shunqian Zheng <zhen...@rock-chips.com>
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+S: Maintained
+F: drivers/media/i2c/ov5695.c
+
 OMNIVISION OV7670 SENSOR DRIVER
 M: Jonathan Corbet <cor...@lwn.net>
 L: linux-media@vger.kernel.org
-- 
1.9.1



[PATCH v3 3/4] media: ov2685: add support for OV2685 sensor

2018-01-08 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov2685 sensor.
Though the ov2685 can output yuv data, this driver only
supports the raw bayer format, including the following features:
  - output 1600x1200 at 30fps
  - test patterns
  - manual exposure/gain control
  - vblank and hblank
  - media controller
  - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 drivers/media/i2c/Kconfig  |  12 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/ov2685.c | 838 +
 3 files changed, 851 insertions(+)
 create mode 100644 drivers/media/i2c/ov2685.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 55b37c8..63a175d 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -586,6 +586,18 @@ config VIDEO_OV2659
  To compile this driver as a module, choose M here: the
  module will be called ov2659.
 
+config VIDEO_OV2685
+   tristate "OmniVision OV2685 sensor support"
+   depends on VIDEO_V4L2 && I2C && MEDIA_CONTROLLER
+   depends on MEDIA_CAMERA_SUPPORT
+   select V4L2_FWNODE
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV2685 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov2685.
+
 config VIDEO_OV5640
tristate "OmniVision OV5640 sensor support"
depends on OF
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index a063030..3054c69 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
 obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
 obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
+obj-$(CONFIG_VIDEO_OV2685) += ov2685.o
 obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
new file mode 100644
index 000..e0faaab
--- /dev/null
+++ b/drivers/media/i2c/ov2685.c
@@ -0,0 +1,838 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ov2685 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CHIP_ID0x2685
+#define OV2685_REG_CHIP_ID 0x300a
+
+#define REG_SC_CTRL_MODE   0x0100
+#define SC_CTRL_MODE_STANDBY   0x0
+#define SC_CTRL_MODE_STREAMING BIT(0)
+
+#define OV2685_REG_EXPOSURE0x3500
+#defineOV2685_EXPOSURE_MIN 4
+#defineOV2685_EXPOSURE_STEP1
+
+#define OV2685_REG_VTS 0x380e
+#define OV2685_VTS_MAX 0x7fff
+
+#define OV2685_REG_GAIN0x350a
+#define OV2685_GAIN_MIN0
+#define OV2685_GAIN_MAX0x07ff
+#define OV2685_GAIN_STEP   0x1
+#define OV2685_GAIN_DEFAULT0x0036
+
+#define OV2685_REG_TEST_PATTERN0x5080
+#define OV2685_TEST_PATTERN_DISABLED   0x00
+#define OV2685_TEST_PATTERN_COLOR_BAR  0x80
+#define OV2685_TEST_PATTERN_RANDOM 0x81
+#define OV2685_TEST_PATTERN_COLOR_BAR_FADE 0x88
+#define OV2685_TEST_PATTERN_BW_SQUARE  0x92
+#define OV2685_TEST_PATTERN_COLOR_SQUARE   0x82
+
+#define REG_NULL   0x
+
+#define OV2685_REG_VALUE_08BIT 1
+#define OV2685_REG_VALUE_16BIT 2
+#define OV2685_REG_VALUE_24BIT 3
+
+#define OV2685_LANES   1
+#define OV2685_BITS_PER_SAMPLE 10
+
+struct regval {
+   u16 addr;
+   u8 val;
+};
+
+struct ov2685_mode {
+   u32 width;
+   u32 height;
+   u32 exp_def;
+   u32 hts_def;
+   u32 vts_def;
+   const struct regval *reg_list;
+};
+
+struct ov2685 {
+   struct i2c_client   *client;
+   struct clk  *xvclk;
+   struct regulator*avdd_regulator;/* Analog power */
+   struct regulator*dovdd_regulator;   /* Digital I/O power */
+   struct regulator*dvdd_regulator;/* Digital core power */
+   struct gpio_desc*reset_gpio;
+
+   boolstreaming;
+   struct mutexmutex;
+   struct v4l2_subdev  subdev;
+   struct media_padpad;
+   struct v4l2_ctrl*anal_gain;
+   struct v4l2_ctrl*exposure;
+   struct v4l2_ctrl*hblank;
+   struct v4l2_ctrl*vblank;
+   struct v4l2_ctrl*test_pattern;
+   struct v4l2_ctrl_handler ctrl_handler;
+
+   const struct ov2685_mode *cur_mode;
+};
+
+#define to_ov2685(sd) container_of(sd, struct ov2685, subdev)
+
+/* PLL set

[PATCH v3 1/4] media: ov5695: add support for OV5695 sensor

2018-01-08 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov5695 sensor,
the driver supports following features:
 - supported resolutions
   + 2592x1944 at 30fps
   + 1920x1080 at 30fps
   + 1296x972 at 60fps
   + 1280x720 at 30fps
   + 640x480 at 120fps
 - test patterns
 - manual exposure/gain(analog and digital) control
 - vblank and hblank
 - media controller
 - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 drivers/media/i2c/Kconfig  |   11 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/ov5695.c | 1392 
 3 files changed, 1404 insertions(+)
 create mode 100644 drivers/media/i2c/ov5695.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 3c6d642..55b37c8 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -645,6 +645,17 @@ config VIDEO_OV5670
  To compile this driver as a module, choose M here: the
  module will be called ov5670.
 
+config VIDEO_OV5695
+   tristate "OmniVision OV5695 sensor support"
+   depends on I2C && VIDEO_V4L2
+   depends on MEDIA_CAMERA_SUPPORT
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV5695 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov5695.
+
 config VIDEO_OV7640
tristate "OmniVision OV7640 sensor support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 548a9ef..a063030 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
 obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
+obj-$(CONFIG_VIDEO_OV5695) += ov5695.o
 obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
 obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
new file mode 100644
index 000..7e8bd82
--- /dev/null
+++ b/drivers/media/i2c/ov5695.c
@@ -0,0 +1,1392 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * ov5695 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifndef V4L2_CID_DIGITAL_GAIN
+#define V4L2_CID_DIGITAL_GAIN  V4L2_CID_GAIN
+#endif
+
+/* 45Mhz * 4 Binning */
+#define OV5695_PIXEL_RATE  (45 * 1000 * 1000 * 4)
+#define CHIP_ID0x005695
+#define OV5695_REG_CHIP_ID 0x300a
+
+#define OV5695_REG_CTRL_MODE   0x0100
+#define OV5695_MODE_SW_STANDBY 0x0
+#define OV5695_MODE_STREAMING  BIT(0)
+
+#define OV5695_REG_EXPOSURE0x3500
+#defineOV5695_EXPOSURE_MIN 4
+#defineOV5695_EXPOSURE_STEP1
+#define OV5695_VTS_MAX 0x7fff
+
+#define OV5695_REG_ANALOG_GAIN 0x3509
+#defineANALOG_GAIN_MIN 0x10
+#defineANALOG_GAIN_MAX 0xf8
+#defineANALOG_GAIN_STEP1
+#defineANALOG_GAIN_DEFAULT 0xf8
+
+#define OV5695_REG_DIGI_GAIN_H 0x350a
+#define OV5695_REG_DIGI_GAIN_L 0x350b
+#define OV5695_DIGI_GAIN_L_MASK0x3f
+#define OV5695_DIGI_GAIN_H_SHIFT   6
+#define OV5695_DIGI_GAIN_MIN   0
+#define OV5695_DIGI_GAIN_MAX   (0x4000 - 1)
+#define OV5695_DIGI_GAIN_STEP  1
+#define OV5695_DIGI_GAIN_DEFAULT   1024
+
+#define OV5695_REG_TEST_PATTERN0x4503
+#defineOV5695_TEST_PATTERN_ENABLE  0x80
+#defineOV5695_TEST_PATTERN_DISABLE 0x0
+
+#define OV5695_REG_VTS 0x380e
+
+#define REG_NULL   0x
+
+#define OV5695_REG_VALUE_08BIT 1
+#define OV5695_REG_VALUE_16BIT 2
+#define OV5695_REG_VALUE_24BIT 3
+
+#define OV5695_LANES   2
+#define OV5695_BITS_PER_SAMPLE 10
+
+struct regval {
+   u16 addr;
+   u8 val;
+};
+
+struct ov5695_mode {
+   u32 width;
+   u32 height;
+   u32 max_fps;
+   u32 hts_def;
+   u32 vts_def;
+   u32 exp_def;
+   const struct regval *reg_list;
+};
+
+struct ov5695 {
+   struct i2c_client   *client;
+   struct clk  *xvclk;
+   struct regulator*avdd_regulator;
+   struct regulator*dovdd_regulator;
+   struct regulator*dvdd_regulator;
+   struct gpio_desc*reset_gpio;
+
+   struct v4l2_subdev  subdev;
+   struct media_padpad;
+   struct v4l2_ctrl_handler ctrl_handler;
+   struct v4l2_ctrl*exposure;
+   struct v4l2_ctrl*anal_gain;
+   struct v4l2_ctrl*digi_gain;
+   struc

[PATCH v3 4/4] dt-bindings: media: Add bindings for OV2685

2018-01-08 Thread Shunqian Zheng
Add device tree binding documentation for the OV2685 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 .../devicetree/bindings/media/i2c/ov2685.txt   | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2685.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov2685.txt 
b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
new file mode 100644
index 000..f1586a2
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
@@ -0,0 +1,41 @@
+* Omnivision OV2685 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: shall be "ovti,ov2685"
+- clocks: reference to the xvclk input clock
+- clock-names: shall be "xvclk"
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dovdd-supply: Digital I/O voltage supply, 1.8 volts
+- dvdd-supply: Digital core voltage supply, 1.8 volts
+- reset-gpios: Low active reset gpio
+
+The device node shall contain one 'port' child node with an
+'endpoint' subnode for its digital output video port,
+in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+The endpoint optional property 'data-lanes' shall be "<1>".
+
+Example:
+ {
+   camera-sensor: ov2685@3c {
+   compatible = "ovti,ov2685";
+   reg = <0x3c>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dovdd-supply = <>;
+   dvdd-supply = <>;
+   reset-gpios = < 3 GPIO_ACTIVE_LOW>;
+
+   port {
+   ucam_out: endpoint {
+   remote-endpoint = <_in_ucam>;
+   data-lanes = <1>;
+   };
+   };
+   };
+};
-- 
1.9.1



[PATCH v3 2/4] dt-bindings: media: Add bindings for OV5695

2018-01-08 Thread Shunqian Zheng
Add device tree binding documentation for the OV5695 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 .../devicetree/bindings/media/i2c/ov5695.txt   | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5695.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov5695.txt 
b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
new file mode 100644
index 000..2f2f698
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
@@ -0,0 +1,41 @@
+* Omnivision OV5695 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: shall be "ovti,ov5695"
+- clocks: reference to the xvclk input clock
+- clock-names: shall be "xvclk"
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dovdd-supply: Digital I/O voltage supply, 1.8 volts
+- dvdd-supply: Digital core voltage supply, 1.2 volts
+- reset-gpios: Low active reset gpio
+
+The device node shall contain one 'port' child node with an
+'endpoint' subnode for its digital output video port,
+in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+The endpoint optional property 'data-lanes' shall be "<1 2>".
+
+Example:
+ {
+   camera-sensor: ov5695@36 {
+   compatible = "ovti,ov5695";
+   reg = <0x36>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dovdd-supply = <>;
+   dvdd-supply = <_cam>;
+   reset-gpios = < 5 GPIO_ACTIVE_LOW>;
+
+   port {
+   wcam_out: endpoint {
+   remote-endpoint = <_in_wcam>;
+   data-lanes = <1 2>;
+   };
+   };
+   };
+};
-- 
1.9.1



[PATCH v2 1/4] media: ov5695: add support for OV5695 sensor

2017-12-29 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov5695 sensor,
the driver supports following features:
 - supported resolutions
   + 2592x1944 at 30fps
   + 1920x1080 at 30fps
   + 1296x972 at 60fps
   + 1280x720 at 30fps
   + 640x480 at 120fps
 - test patterns
 - manual exposure/gain(analog and digital) control
 - vblank and hblank
 - media controller
 - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 drivers/media/i2c/Kconfig  |   11 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/ov5695.c | 1396 
 3 files changed, 1408 insertions(+)
 create mode 100644 drivers/media/i2c/ov5695.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 3c6d642..55b37c8 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -645,6 +645,17 @@ config VIDEO_OV5670
  To compile this driver as a module, choose M here: the
  module will be called ov5670.
 
+config VIDEO_OV5695
+   tristate "OmniVision OV5695 sensor support"
+   depends on I2C && VIDEO_V4L2
+   depends on MEDIA_CAMERA_SUPPORT
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV5695 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov5695.
+
 config VIDEO_OV7640
tristate "OmniVision OV7640 sensor support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 548a9ef..a063030 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
 obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
+obj-$(CONFIG_VIDEO_OV5695) += ov5695.o
 obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
 obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
new file mode 100644
index 000..4745da4
--- /dev/null
+++ b/drivers/media/i2c/ov5695.c
@@ -0,0 +1,1396 @@
+/*
+ * ov5695 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifndef V4L2_CID_DIGITAL_GAIN
+#define V4L2_CID_DIGITAL_GAIN  V4L2_CID_GAIN
+#endif
+
+/* 45Mhz * 4 Binning */
+#define OV5695_PIXEL_RATE  (45 * 1000 * 1000 * 4)
+#define CHIP_ID0x005695
+#define OV5695_REG_CHIP_ID 0x300a
+
+#define OV5695_REG_CTRL_MODE   0x0100
+#define OV5695_MODE_SW_STANDBY 0x0
+#define OV5695_MODE_STREAMING  BIT(0)
+
+#define OV5695_REG_EXPOSURE0x3500
+#defineOV5695_EXPOSURE_MIN 4
+#defineOV5695_EXPOSURE_STEP1
+#define OV5695_VTS_MAX 0x7fff
+
+#define OV5695_REG_ANALOG_GAIN 0x3509
+#defineANALOG_GAIN_MIN 0x10
+#defineANALOG_GAIN_MAX 0xf8
+#defineANALOG_GAIN_STEP1
+#defineANALOG_GAIN_DEFAULT 0xf8
+
+#define OV5695_REG_DIGI_GAIN_H 0x350a
+#define OV5695_REG_DIGI_GAIN_L 0x350b
+#define OV5695_DIGI_GAIN_L_MASK0x3f
+#define OV5695_DIGI_GAIN_H_SHIFT   6
+#define OV5695_DIGI_GAIN_MIN   0
+#define OV5695_DIGI_GAIN_MAX   (0x4000 - 1)
+#define OV5695_DIGI_GAIN_STEP  1
+#define OV5695_DIGI_GAIN_DEFAULT   1024
+
+#define OV5695_REG_TEST_PATTERN0x4503
+#defineOV5695_TEST_PATTERN_ENABLE  0x80
+#defineOV5695_TEST_PATTERN_DISABLE 0x0
+
+#define OV5695_REG_VTS 0x380e
+
+#define REG_NULL   0x
+
+#define OV5695_REG_VALUE_08BIT 1
+#define OV5695_REG_VALUE_16BIT 2
+#define OV5695_REG_VALUE_24BIT 3
+
+#define OV5695_LANES   2
+#define OV5695_BITS_PER_SAMPLE 10
+
+struct regval {
+   u16 addr;
+   u8 val;
+};
+
+struct ov5695_mode {
+   u32 width;
+   u32 height;
+   u32 max_fps;
+   u32 hts_def;
+   u32 vts_def;
+   u32 exp_def;
+   const struct regval *reg_list;
+};
+
+struct ov5695 {
+   struct i2c_client   *client;
+   struct clk  *xvclk;
+   struct regulator*avdd_regulator;
+   struct regulator*dovdd_regulator;
+   struct regulator*dvdd_regulator;
+   struct gpio_desc*reset_gpio;
+
+   struct v4l2_subdev  subdev;
+   s

[PATCH v2 4/4] [media] dt/bindings: Add bindings for OV2685

2017-12-29 Thread Shunqian Zheng
Add device tree binding documentation for the OV2685 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 .../devicetree/bindings/media/i2c/ov2685.txt   | 35 ++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2685.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov2685.txt 
b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
new file mode 100644
index 000..85aec03
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
@@ -0,0 +1,35 @@
+* Omnivision OV2685 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: should be "ovti,ov2685"
+- clocks: reference to the 24M xvclk input clock.
+- clock-names: should be "xvclk".
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dvdd-supply: Digital core voltage supply, 1.2 volts
+- reset-gpios: Low active reset gpio
+
+The device node must contain one 'port' child node for its digital output
+video port, in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+   ucam: camera-sensor@3c {
+   compatible = "ovti,ov2685";
+   reg = <0x3c>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dovdd-supply = <>;
+   reset-gpios = < 3 GPIO_ACTIVE_LOW>;
+
+   port {
+   ucam_out: endpoint {
+   remote-endpoint = <_in_ucam>;
+   data-lanes = <1>;
+   };
+   };
+   };
-- 
1.9.1



[PATCH v2 2/4] [media] dt/bindings: Add bindings for OV5695

2017-12-29 Thread Shunqian Zheng
Add device tree binding documentation for the OV5695 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 .../devicetree/bindings/media/i2c/ov5695.txt   | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5695.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov5695.txt 
b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
new file mode 100644
index 000..8d87dbc
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
@@ -0,0 +1,38 @@
+* Omnivision OV5695 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: should be "ovti,ov5695"
+- clocks: reference to the 24M xvclk input clock.
+- clock-names: should be "xvclk".
+- dovdd-supply: Digital I/O voltage supply, 1.8 volts
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dvdd-supply: Digital core voltage supply, 1.2 volts
+- reset-gpios: Low active reset gpio
+
+The device node must contain one 'port' child node for its digital output
+video port, in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+: camera-sensor@36 {
+   compatible = "ovti,ov5695";
+   reg = <0x36>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dvdd-supply = <_cam>;
+   dovdd-supply = <>;
+
+   reset-gpios = < 5 GPIO_ACTIVE_LOW>;
+
+   port {
+   wcam_out: endpoint {
+   remote-endpoint = <_in_wcam>;
+   data-lanes = <1 2>;
+   };
+   };
+};
-- 
1.9.1



[PATCH v2 3/4] media: ov2685: add support for OV2685 sensor

2017-12-29 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov2685 sensor.
Though the ov2685 can output yuv data, this driver only
supports the raw bayer format, including the following features:
  - output 1600x1200 at 30fps
  - test patterns
  - manual exposure/gain control
  - vblank and hblank
  - media controller
  - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 drivers/media/i2c/Kconfig  |  12 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/ov2685.c | 841 +
 3 files changed, 854 insertions(+)
 create mode 100644 drivers/media/i2c/ov2685.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 55b37c8..63a175d 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -586,6 +586,18 @@ config VIDEO_OV2659
  To compile this driver as a module, choose M here: the
  module will be called ov2659.
 
+config VIDEO_OV2685
+   tristate "OmniVision OV2685 sensor support"
+   depends on VIDEO_V4L2 && I2C && MEDIA_CONTROLLER
+   depends on MEDIA_CAMERA_SUPPORT
+   select V4L2_FWNODE
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV2685 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov2685.
+
 config VIDEO_OV5640
tristate "OmniVision OV5640 sensor support"
depends on OF
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index a063030..3054c69 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
 obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
 obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
+obj-$(CONFIG_VIDEO_OV2685) += ov2685.o
 obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
new file mode 100644
index 000..e037d20
--- /dev/null
+++ b/drivers/media/i2c/ov2685.c
@@ -0,0 +1,841 @@
+/*
+ * ov2685 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CHIP_ID0x2685
+#define OV2685_REG_CHIP_ID 0x300a
+
+#define REG_SC_CTRL_MODE   0x0100
+#define SC_CTRL_MODE_STANDBY   0x0
+#define SC_CTRL_MODE_STREAMING BIT(0)
+
+#define OV2685_REG_EXPOSURE0x3500
+#defineOV2685_EXPOSURE_MIN 4
+#defineOV2685_EXPOSURE_STEP1
+
+#define OV2685_REG_VTS 0x380e
+#define OV2685_VTS_MAX 0x7fff
+
+#define OV2685_REG_GAIN0x350a
+#define OV2685_GAIN_MIN0
+#define OV2685_GAIN_MAX0x07ff
+#define OV2685_GAIN_STEP   0x1
+#define OV2685_GAIN_DEFAULT0x0036
+
+#define OV2685_REG_TEST_PATTERN0x5080
+#define OV2685_TEST_PATTERN_DISABLED   0x00
+#define OV2685_TEST_PATTERN_COLOR_BAR  0x80
+#define OV2685_TEST_PATTERN_RND0x81
+#define OV2685_TEST_PATTERN_COLOR_BAR_FADE 0x88
+#define OV2685_TEST_PATTERN_BW_SQUARE  0x92
+#define OV2685_TEST_PATTERN_COLOR_SQUARE   0x82
+
+#define REG_NULL   0x
+
+#define OV2685_REG_VALUE_08BIT 1
+#define OV2685_REG_VALUE_16BIT 2
+#define OV2685_REG_VALUE_24BIT 3
+
+#define OV2685_LANES   1
+#define OV2685_BITS_PER_SAMPLE 10
+
+struct regval {
+   u16 addr;
+   u8 val;
+};
+
+struct ov2685_mode {
+   u32 width;
+   u32 height;
+   u32 exp_def;
+   u32 hts_def;
+   u32 vts_def;
+   const struct regval *reg_list;
+};
+
+struct ov2685 {
+   struct i2c_client   *client;
+   struct clk  *xvclk;
+   struct regulator*avdd_regulator;/* Analog power */
+   struct regulator*dovdd_regulator;   /* Digital I/O power */
+   /* use internal DVDD power */
+   struct gpio_desc*reset_gpio;
+
+   boolstreaming;
+   struct mutexmutex;
+   struct v4l2_subdev  subdev;
+   struct media_padpad;
+   struct v4l2_ctrl*anal_gain;
+   struct v4l2_ctrl*exposure;
+   struct v4l2_ctrl*hblank;
+   struct v4l2_ctrl*vblank;
+  

[PATCH v5 01/16] media: videodev2.h, v4l2-ioctl: add rkisp1 meta buffer format

2017-12-29 Thread Shunqian Zheng
Add the Rockchip ISP1 specific processing parameter format
V4L2_META_FMT_RK_ISP1_PARAMS and metadata format
V4L2_META_FMT_RK_ISP1_STAT_3A for 3A.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Signed-off-by: Jacob Chen <jacob2.c...@rock-chips.com>
---
 drivers/media/v4l2-core/v4l2-ioctl.c | 2 ++
 include/uapi/linux/videodev2.h   | 4 
 2 files changed, 6 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c 
b/drivers/media/v4l2-core/v4l2-ioctl.c
index 7961499..035fd22 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1246,6 +1246,8 @@ static void v4l_fill_fmtdesc(struct v4l2_fmtdesc *fmt)
case V4L2_TCH_FMT_TU08: descr = "8-bit unsigned touch data"; 
break;
case V4L2_META_FMT_VSP1_HGO:descr = "R-Car VSP1 1-D Histogram"; 
break;
case V4L2_META_FMT_VSP1_HGT:descr = "R-Car VSP1 2-D Histogram"; 
break;
+   case V4L2_META_FMT_RK_ISP1_PARAMS:  descr = "Rockchip ISP1 3A 
params"; break;
+   case V4L2_META_FMT_RK_ISP1_STAT_3A: descr = "Rockchip ISP1 3A 
statistics"; break;
 
default:
/* Compressed formats */
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h
index 1c095b5..c023c3a 100644
--- a/include/uapi/linux/videodev2.h
+++ b/include/uapi/linux/videodev2.h
@@ -689,6 +689,10 @@ struct v4l2_pix_format {
 #define V4L2_META_FMT_VSP1_HGOv4l2_fourcc('V', 'S', 'P', 'H') /* R-Car 
VSP1 1-D Histogram */
 #define V4L2_META_FMT_VSP1_HGTv4l2_fourcc('V', 'S', 'P', 'T') /* R-Car 
VSP1 2-D Histogram */
 
+/* Vendor specific - used for IPU3 camera sub-system */
+#define V4L2_META_FMT_RK_ISP1_PARAMS   v4l2_fourcc('R', 'K', '1', 'P') /* 
Rockchip ISP1 params */
+#define V4L2_META_FMT_RK_ISP1_STAT_3A  v4l2_fourcc('R', 'K', '1', 'S') /* 
Rockchip ISP1 3A statistics */
+
 /* priv field value to indicates that subsequent fields are valid. */
 #define V4L2_PIX_FMT_PRIV_MAGIC0xfeedcafe
 
-- 
1.9.1



[PATCH v5 00/16] Rockchip ISP1 Driver

2017-12-29 Thread Shunqian Zheng
changes in V5: Sync with local changes,
  - fix the SP height limit
  - speed up the second stream capture
  - the second stream can't force sync for rsz when start/stop streaming
  - add frame id to param vb2 buf
  - enable luminance maximum threshold

changes in V4:
  - fix some bugs during development
  - move quantization settings to rkisp1 subdev
  - correct some spelling problems
  - describe ports in dt-binding documents

changes in V3:
  - add some comments
  - fix wrong use of v4l2_async_subdev_notifier_register
  - optimize two paths capture at a time
  - remove compose
  - re-struct headers
  - add a tmp wiki page: http://opensource.rock-chips.com/wiki_Rockchip-isp1

changes in V2:
  mipi-phy:
- use async probing
- make it be a child device of the GRF
  isp:
- add dummy buffer
- change the way to get bus configuration, which make it possible to
add parallel sensor support in the future(without mipi-phy driver).

This patch series add a ISP(Camera) v4l2 driver for rockchip rk3288/rk3399 SoC.

Wiki Pages:
http://opensource.rock-chips.com/wiki_Rockchip-isp1

Jacob Chen (12):
  media: doc: add document for rkisp1 meta buffer format
  media: rkisp1: add Rockchip MIPI Synopsys DPHY driver
  media: rkisp1: add Rockchip ISP1 subdev driver
  media: rkisp1: add ISP1 statistics driver
  media: rkisp1: add ISP1 params driver
  media: rkisp1: add capture device driver
  media: rkisp1: add rockchip isp1 core driver
  dt-bindings: Document the Rockchip ISP1 bindings
  dt-bindings: Document the Rockchip MIPI RX D-PHY bindings
  ARM: dts: rockchip: add isp node for rk3288
  ARM: dts: rockchip: add rx0 mipi-phy for rk3288
  MAINTAINERS: add entry for Rockchip ISP1 driver

Jeffy Chen (1):
  media: rkisp1: Add user space ABI definitions

Shunqian Zheng (3):
  media: videodev2.h, v4l2-ioctl: add rkisp1 meta buffer format
  arm64: dts: rockchip: add isp0 node for rk3399
  arm64: dts: rockchip: add rx0 mipi-phy for rk3399

 .../devicetree/bindings/media/rockchip-isp1.txt|   69 +
 .../bindings/media/rockchip-mipi-dphy.txt  |   88 +
 Documentation/media/uapi/v4l/meta-formats.rst  |2 +
 .../media/uapi/v4l/pixfmt-meta-rkisp1-params.rst   |   17 +
 .../media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst |   18 +
 MAINTAINERS|   10 +
 arch/arm/boot/dts/rk3288.dtsi  |   24 +
 arch/arm64/boot/dts/rockchip/rk3399.dtsi   |   25 +
 drivers/media/platform/Kconfig |   10 +
 drivers/media/platform/Makefile|1 +
 drivers/media/platform/rockchip/isp1/Makefile  |8 +
 drivers/media/platform/rockchip/isp1/capture.c | 1728 
 drivers/media/platform/rockchip/isp1/capture.h |  194 +++
 drivers/media/platform/rockchip/isp1/common.h  |  137 ++
 drivers/media/platform/rockchip/isp1/dev.c |  653 
 drivers/media/platform/rockchip/isp1/dev.h |  120 ++
 drivers/media/platform/rockchip/isp1/isp_params.c  | 1553 ++
 drivers/media/platform/rockchip/isp1/isp_params.h  |   76 +
 drivers/media/platform/rockchip/isp1/isp_stats.c   |  522 ++
 drivers/media/platform/rockchip/isp1/isp_stats.h   |   85 +
 .../media/platform/rockchip/isp1/mipi_dphy_sy.c|  787 +
 drivers/media/platform/rockchip/isp1/regs.c|  266 +++
 drivers/media/platform/rockchip/isp1/regs.h| 1577 ++
 drivers/media/platform/rockchip/isp1/rkisp1.c  | 1205 ++
 drivers/media/platform/rockchip/isp1/rkisp1.h  |  132 ++
 drivers/media/v4l2-core/v4l2-ioctl.c   |2 +
 include/uapi/linux/rkisp1-config.h |  757 +
 include/uapi/linux/videodev2.h |4 +
 28 files changed, 10070 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/rockchip-isp1.txt
 create mode 100644 
Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-params.rst
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst
 create mode 100644 drivers/media/platform/rockchip/isp1/Makefile
 create mode 100644 drivers/media/platform/rockchip/isp1/capture.c
 create mode 100644 drivers/media/platform/rockchip/isp1/capture.h
 create mode 100644 drivers/media/platform/rockchip/isp1/common.h
 create mode 100644 drivers/media/platform/rockchip/isp1/dev.c
 create mode 100644 drivers/media/platform/rockchip/isp1/dev.h
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_params.c
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_params.h
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_stats.c
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_stats.h
 create mode 100644 drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
 create mode 100644 drivers/media/platform/rockchip/isp1/regs.c
 create mode 100644 drivers/media/platform/rockchip

[PATCH v5 02/16] media: doc: add document for rkisp1 meta buffer format

2017-12-29 Thread Shunqian Zheng
From: Jacob Chen 

This commit add docuemnt for rkisp1 meta buffer format

Signed-off-by: Jacob Chen 
---
 Documentation/media/uapi/v4l/meta-formats.rst  |  2 ++
 .../media/uapi/v4l/pixfmt-meta-rkisp1-params.rst   | 17 +
 .../media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst | 18 ++
 3 files changed, 37 insertions(+)
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-params.rst
 create mode 100644 Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst

diff --git a/Documentation/media/uapi/v4l/meta-formats.rst 
b/Documentation/media/uapi/v4l/meta-formats.rst
index 01e24e3..1b82814 100644
--- a/Documentation/media/uapi/v4l/meta-formats.rst
+++ b/Documentation/media/uapi/v4l/meta-formats.rst
@@ -14,3 +14,5 @@ These formats are used for the :ref:`metadata` interface only.
 
 pixfmt-meta-vsp1-hgo
 pixfmt-meta-vsp1-hgt
+pixfmt-meta-rkisp1-params
+pixfmt-meta-rkisp1-stat
diff --git a/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-params.rst 
b/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-params.rst
new file mode 100644
index 000..ed344d4
--- /dev/null
+++ b/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-params.rst
@@ -0,0 +1,17 @@
+.. -*- coding: utf-8; mode: rst -*-
+
+.. _v4l2-meta-fmt-rkisp1-params:
+
+***
+V4L2_META_FMT_RK_ISP1_PARAMS
+***
+
+Rockchip ISP1 Parameters Data
+
+Description
+===
+
+This format describes input parameters for the Rockchip ISP1.
+
+The data use c-struct :c:type:`rkisp1_isp_params_cfg`, which is defined in
+the ``linux/rkisp1-config.h`` header file, See it for details.
diff --git a/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst 
b/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst
new file mode 100644
index 000..5ecc403
--- /dev/null
+++ b/Documentation/media/uapi/v4l/pixfmt-meta-rkisp1-stat.rst
@@ -0,0 +1,18 @@
+.. -*- coding: utf-8; mode: rst -*-
+
+.. _v4l2-meta-fmt-rkisp1-stat:
+
+***
+V4L2_META_FMT_RK_ISP1_STAT_3A
+***
+
+Rockchip ISP1 Statistics Data
+
+Description
+===
+
+This format describes image color statistics information generated by the 
Rockchip
+ISP1.
+
+The data use c-struct :c:type:`rkisp1_stat_buffer`, which is defined in
+the ``linux/cifisp_stat.h`` header file, See it for details.
-- 
1.9.1



[PATCH v5 03/16] media: rkisp1: Add user space ABI definitions

2017-12-29 Thread Shunqian Zheng
From: Jeffy Chen 

Add the header for userspace

Signed-off-by: Jeffy Chen 
Signed-off-by: Jacob Chen 
---
 include/uapi/linux/rkisp1-config.h | 757 +
 1 file changed, 757 insertions(+)
 create mode 100644 include/uapi/linux/rkisp1-config.h

diff --git a/include/uapi/linux/rkisp1-config.h 
b/include/uapi/linux/rkisp1-config.h
new file mode 100644
index 000..0f9f4226
--- /dev/null
+++ b/include/uapi/linux/rkisp1-config.h
@@ -0,0 +1,757 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Rockchip isp1 driver
+ * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
+ */
+
+#ifndef _UAPI_RKISP1_CONFIG_H
+#define _UAPI_RKISP1_CONFIG_H
+
+#include 
+#include 
+
+#define CIFISP_MODULE_DPCC  (1 << 0)
+#define CIFISP_MODULE_BLS   (1 << 1)
+#define CIFISP_MODULE_SDG   (1 << 2)
+#define CIFISP_MODULE_HST   (1 << 3)
+#define CIFISP_MODULE_LSC   (1 << 4)
+#define CIFISP_MODULE_AWB_GAIN  (1 << 5)
+#define CIFISP_MODULE_FLT   (1 << 6)
+#define CIFISP_MODULE_BDM   (1 << 7)
+#define CIFISP_MODULE_CTK   (1 << 8)
+#define CIFISP_MODULE_GOC   (1 << 9)
+#define CIFISP_MODULE_CPROC (1 << 10)
+#define CIFISP_MODULE_AFC   (1 << 11)
+#define CIFISP_MODULE_AWB   (1 << 12)
+#define CIFISP_MODULE_IE(1 << 13)
+#define CIFISP_MODULE_AEC   (1 << 14)
+#define CIFISP_MODULE_WDR   (1 << 15)
+#define CIFISP_MODULE_DPF   (1 << 16)
+#define CIFISP_MODULE_DPF_STRENGTH  (1 << 17)
+
+#define CIFISP_CTK_COEFF_MAX0x100
+#define CIFISP_CTK_OFFSET_MAX   0x800
+
+#define CIFISP_AE_MEAN_MAX  25
+#define CIFISP_HIST_BIN_N_MAX   16
+#define CIFISP_AFM_MAX_WINDOWS  3
+#define CIFISP_DEGAMMA_CURVE_SIZE   17
+
+#define CIFISP_BDM_MAX_TH   0xFF
+
+/*
+ * Black level compensation
+ */
+/* maximum value for horizontal start address */
+#define CIFISP_BLS_START_H_MAX 0x0FFF
+/* maximum value for horizontal stop address */
+#define CIFISP_BLS_STOP_H_MAX  0x0FFF
+/* maximum value for vertical start address */
+#define CIFISP_BLS_START_V_MAX 0x0FFF
+/* maximum value for vertical stop address */
+#define CIFISP_BLS_STOP_V_MAX  0x0FFF
+/* maximum is 2^18 = 262144*/
+#define CIFISP_BLS_SAMPLES_MAX 0x0012
+/* maximum value for fixed black level */
+#define CIFISP_BLS_FIX_SUB_MAX 0x0FFF
+/* minimum value for fixed black level */
+#define CIFISP_BLS_FIX_SUB_MIN 0xF000
+/* 13 bit range (signed)*/
+#define CIFISP_BLS_FIX_MASK0x1FFF
+
+/*
+ * Automatic white balance measurments
+ */
+#define CIFISP_AWB_MAX_GRID1
+#define CIFISP_AWB_MAX_FRAMES  7
+
+/*
+ * Gamma out
+ */
+/* Maximum number of color samples supported */
+#define CIFISP_GAMMA_OUT_MAX_SAMPLES   17
+
+/*
+ * Lens shade correction
+ */
+#define CIFISP_LSC_GRAD_TBL_SIZE   8
+#define CIFISP_LSC_SIZE_TBL_SIZE   8
+/*
+ * The following matches the tuning process,
+ * not the max capabilities of the chip.
+ * Last value unused.
+ */
+#defineCIFISP_LSC_DATA_TBL_SIZE   290
+
+/*
+ * Histogram calculation
+ */
+/* Last 3 values unused. */
+#define CIFISP_HISTOGRAM_WEIGHT_GRIDS_SIZE 28
+
+/*
+ * Defect Pixel Cluster Correction
+ */
+#define CIFISP_DPCC_METHODS_MAX   3
+
+/*
+ * Denoising pre filter
+ */
+#define CIFISP_DPF_MAX_NLF_COEFFS  17
+#define CIFISP_DPF_MAX_SPATIAL_COEFFS  6
+
+/*
+ * Measurement types
+ */
+#define CIFISP_STAT_AWB   (1 << 0)
+#define CIFISP_STAT_AUTOEXP   (1 << 1)
+#define CIFISP_STAT_AFM_FIN   (1 << 2)
+#define CIFISP_STAT_HIST  (1 << 3)
+
+enum cifisp_histogram_mode {
+   CIFISP_HISTOGRAM_MODE_DISABLE,
+   CIFISP_HISTOGRAM_MODE_RGB_COMBINED,
+   CIFISP_HISTOGRAM_MODE_R_HISTOGRAM,
+   CIFISP_HISTOGRAM_MODE_G_HISTOGRAM,
+   CIFISP_HISTOGRAM_MODE_B_HISTOGRAM,
+   CIFISP_HISTOGRAM_MODE_Y_HISTOGRAM
+};
+
+enum cifisp_awb_mode_type {
+   CIFISP_AWB_MODE_MANUAL,
+   CIFISP_AWB_MODE_RGB,
+   CIFISP_AWB_MODE_YCBCR
+};
+
+enum cifisp_flt_mode {
+   CIFISP_FLT_STATIC_MODE,
+   CIFISP_FLT_DYNAMIC_MODE
+};
+
+/**
+ * enum cifisp_exp_ctrl_auotostop - stop modes
+ * @CIFISP_EXP_CTRL_AUTOSTOP_0: continous measurement
+ * @CIFISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame
+ */
+enum cifisp_exp_ctrl_auotostop {
+   CIFISP_EXP_CTRL_AUTOSTOP_0 = 0,
+   CIFISP_EXP_CTRL_AUTOSTOP_1 = 1,
+};
+
+/**
+ * enum cifisp_exp_meas_mode - Exposure measure mode
+ * @CIFISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094B
+ * @CIFISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256)
+ */
+enum cifisp_exp_meas_mode {
+   

[PATCH v5 05/16] media: rkisp1: add Rockchip ISP1 subdev driver

2017-12-29 Thread Shunqian Zheng
From: Jacob Chen <jacob2.c...@rock-chips.com>

Add the subdev driver for rockchip isp1.

Signed-off-by: Jacob Chen <jacob2.c...@rock-chips.com>
Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Signed-off-by: Yichong Zhong <z...@rock-chips.com>
Signed-off-by: Jacob Chen <c...@rock-chips.com>
Signed-off-by: Eddie Cai <eddie.cai.li...@gmail.com>
Signed-off-by: Jeffy Chen <jeffy.c...@rock-chips.com>
Signed-off-by: Allon Huang <allon.hu...@rock-chips.com>
Signed-off-by: Tomasz Figa <tf...@chromium.org>
---
 drivers/media/platform/rockchip/isp1/rkisp1.c | 1205 +
 drivers/media/platform/rockchip/isp1/rkisp1.h |  132 +++
 2 files changed, 1337 insertions(+)
 create mode 100644 drivers/media/platform/rockchip/isp1/rkisp1.c
 create mode 100644 drivers/media/platform/rockchip/isp1/rkisp1.h

diff --git a/drivers/media/platform/rockchip/isp1/rkisp1.c 
b/drivers/media/platform/rockchip/isp1/rkisp1.c
new file mode 100644
index 000..2656c5e
--- /dev/null
+++ b/drivers/media/platform/rockchip/isp1/rkisp1.c
@@ -0,0 +1,1205 @@
+/*
+ * Rockchip isp1 driver
+ *
+ * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "common.h"
+#include "regs.h"
+
+#define CIF_ISP_INPUT_W_MAX4032
+#define CIF_ISP_INPUT_H_MAX3024
+#define CIF_ISP_INPUT_W_MIN32
+#define CIF_ISP_INPUT_H_MIN32
+#define CIF_ISP_OUTPUT_W_MAX   CIF_ISP_INPUT_W_MAX
+#define CIF_ISP_OUTPUT_H_MAX   CIF_ISP_INPUT_H_MAX
+#define CIF_ISP_OUTPUT_W_MIN   CIF_ISP_INPUT_W_MIN
+#define CIF_ISP_OUTPUT_H_MIN   CIF_ISP_INPUT_H_MIN
+
+/*
+ * NOTE: MIPI controller and input MUX are also configured in this file,
+ * because ISP Subdev is not only describe ISP submodule(input size,format, 
output size, format),
+ * but also a virtual route device.
+ */
+
+/*
+ * There are many variables named with format/frame in below code,
+ * please see here for their meaning.
+ *
+ * Cropping regions of ISP
+ *
+ * +-+
+ * | Sensor image|
+ * | +---+   |
+ * | | ISP_ACQ (for black level) |   |
+ * | | in_frm|   |
+ * | | ++|   |
+ * | | |ISP_OUT ||   |
+ * | | |in_crop ||   |
+ * | | |+-+ ||   |
+ * | | ||   ISP_IS| ||   |
+ * | | ||   rkisp1_isp_subdev: out_crop   | ||   |
+ * | | |+-+ ||   |
+ * | | ++|   |
+ * | +---+   |
+ * +-+
+ */
+
+static inline struct rkisp1_device *sd_to_isp_dev(struct v4l2_subdev *sd)
+{
+   return container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev);
+}
+
+/* Get sensor by enabled media link */
+static struct v4l2_subdev *get_remote_sensor(struct v4l2_subdev *sd)
+{
+   struct media_pad *local;
+   struct media_entity *sensor_me;
+
+   local = >entity.pads[RKISP1_ISP_PAD_SINK];
+   sensor_me = media_entity_remote_pad(local)->entity;
+
+   return media_entity_to_v4l2_subd

[PATCH v5 04/16] media: rkisp1: add Rockchip MIPI Synopsys DPHY driver

2017-12-29 Thread Shunqian Zheng
From: Jacob Chen <jacob2.c...@rock-chips.com>

This commit adds a subdev driver for Rockchip MIPI Synopsys DPHY driver

Signed-off-by: Jacob Chen <jacob2.c...@rock-chips.com>
Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Signed-off-by: Tomasz Figa <tf...@chromium.org>
---
 .../media/platform/rockchip/isp1/mipi_dphy_sy.c| 787 +
 1 file changed, 787 insertions(+)
 create mode 100644 drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c

diff --git a/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c 
b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
new file mode 100644
index 000..9421183
--- /dev/null
+++ b/drivers/media/platform/rockchip/isp1/mipi_dphy_sy.c
@@ -0,0 +1,787 @@
+/*
+ * Rockchip MIPI Synopsys DPHY driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define RK3288_GRF_SOC_CON60x025c
+#define RK3288_GRF_SOC_CON80x0264
+#define RK3288_GRF_SOC_CON90x0268
+#define RK3288_GRF_SOC_CON10   0x026c
+#define RK3288_GRF_SOC_CON14   0x027c
+#define RK3288_GRF_SOC_STATUS210x02d4
+#define RK3288_GRF_IO_VSEL 0x0380
+#define RK3288_GRF_SOC_CON15   0x03a4
+
+#define RK3399_GRF_SOC_CON90x6224
+#define RK3399_GRF_SOC_CON21   0x6254
+#define RK3399_GRF_SOC_CON22   0x6258
+#define RK3399_GRF_SOC_CON23   0x625c
+#define RK3399_GRF_SOC_CON24   0x6260
+#define RK3399_GRF_SOC_CON25   0x6264
+#define RK3399_GRF_SOC_STATUS1 0xe2a4
+
+#define CLOCK_LANE_HS_RX_CONTROL   0x34
+#define LANE0_HS_RX_CONTROL0x44
+#define LANE1_HS_RX_CONTROL0x54
+#define LANE2_HS_RX_CONTROL0x84
+#define LANE3_HS_RX_CONTROL0x94
+#define HS_RX_DATA_LANES_THS_SETTLE__CONTROL   0x75
+
+#define HIWORD_UPDATE(val, mask, shift) \
+   ((val) << (shift) | (mask) << ((shift) + 16))
+
+enum mipi_dphy_sy_pads {
+   MIPI_DPHY_SY_PAD_SINK = 0,
+   MIPI_DPHY_SY_PAD_SOURCE,
+   MIPI_DPHY_SY_PADS_NUM,
+};
+
+enum dphy_reg_id {
+   GRF_DPHY_RX0_TURNDISABLE = 0,
+   GRF_DPHY_RX0_FORCERXMODE,
+   GRF_DPHY_RX0_FORCETXSTOPMODE,
+   GRF_DPHY_RX0_ENABLE,
+   GRF_DPHY_RX0_TESTCLR,
+   GRF_DPHY_RX0_TESTCLK,
+   GRF_DPHY_RX0_TESTEN,
+   GRF_DPHY_RX0_TESTDIN,
+   GRF_DPHY_RX0_TURNREQUEST,
+   GRF_DPHY_RX0_TESTDOUT,
+   GRF_DPHY_TX0_TURNDISABLE,
+   GRF_DPHY_TX0_FORCERXMODE,
+   GRF_DPHY_TX0_FORCETXSTOPMODE,
+   GRF_DPHY_TX0_TURNREQUEST,
+   GRF_DPHY_TX1RX1_TURNDISABLE,
+   GRF_DPHY_TX1RX1_FORCERXMODE,
+   GRF_DPHY_TX1RX1_FORCETXSTOPMODE,
+   GRF_DPHY_TX1RX1_ENABLE,
+   GRF_DPHY_TX1RX1_MASTERSLAVEZ,
+   GRF_DPHY_TX1RX1_BASEDIR,
+   GRF_DPHY_TX1RX1_ENABLECLK,
+   GRF_DPHY_TX1RX1_TURNREQUEST,
+   GRF_DPHY_RX1_SRC_SEL,
+   /* rk3288 only */
+   GRF_CON_DISABLE_ISP,
+   GRF_CON_ISP_DPHY_SEL,
+   GRF_DSI_CSI_TESTBUS_SEL,
+   GRF_DVP_V18SEL,
+   /* below is for rk3399 only */
+   GRF_DPHY_RX0_CLK_INV_SEL,
+   GRF_DPHY_RX1_CLK_INV_SEL,
+};
+
+struct dphy_reg {
+   u32 offset;
+   u32 mask;
+   u32 shift;
+};
+
+#define PHY_REG(_offset, _width, _shift) \
+   { .offset = _offset, .mask = BIT(_width) - 1, .shift = _shift, }
+
+static const struct dphy_reg rk3399_grf_dphy_regs[] = {
+   [GRF_DPHY_RX0_TURNREQUEST] = PHY_REG(RK3399_GRF_SOC_CON9, 4, 0),
+   [GRF_DPHY_RX0_CLK

[PATCH v5 06/16] media: rkisp1: add ISP1 statistics driver

2017-12-29 Thread Shunqian Zheng
From: Jacob Chen <jacob2.c...@rock-chips.com>

Add the capture video driver for rockchip isp1 statistics block.

Signed-off-by: Jacob Chen <jacob2.c...@rock-chips.com>
Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Signed-off-by: Yichong Zhong <z...@rock-chips.com>
Signed-off-by: Jacob Chen <c...@rock-chips.com>
Signed-off-by: Eddie Cai <eddie.cai.li...@gmail.com>
Signed-off-by: Jeffy Chen <jeffy.c...@rock-chips.com>
Signed-off-by: Allon Huang <allon.hu...@rock-chips.com>
Signed-off-by: Tomasz Figa <tf...@chromium.org>
---
 drivers/media/platform/rockchip/isp1/isp_stats.c | 522 +++
 drivers/media/platform/rockchip/isp1/isp_stats.h |  85 
 2 files changed, 607 insertions(+)
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_stats.c
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_stats.h

diff --git a/drivers/media/platform/rockchip/isp1/isp_stats.c 
b/drivers/media/platform/rockchip/isp1/isp_stats.c
new file mode 100644
index 000..dd30ebe
--- /dev/null
+++ b/drivers/media/platform/rockchip/isp1/isp_stats.c
@@ -0,0 +1,522 @@
+/*
+ * Rockchip isp1 driver
+ *
+ * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include/* for ISP statistics */
+#include "dev.h"
+#include "regs.h"
+
+#define RKISP1_ISP_STATS_REQ_BUFS_MIN 2
+#define RKISP1_ISP_STATS_REQ_BUFS_MAX 8
+
+static int rkisp1_stats_enum_fmt_meta_cap(struct file *file, void *priv,
+ struct v4l2_fmtdesc *f)
+{
+   struct video_device *video = video_devdata(file);
+   struct rkisp1_isp_stats_vdev *stats_vdev = video_get_drvdata(video);
+
+   if (f->index > 0 || f->type != video->queue->type)
+   return -EINVAL;
+
+   f->pixelformat = stats_vdev->vdev_fmt.fmt.meta.dataformat;
+   return 0;
+}
+
+static int rkisp1_stats_g_fmt_meta_cap(struct file *file, void *priv,
+  struct v4l2_format *f)
+{
+   struct video_device *video = video_devdata(file);
+   struct rkisp1_isp_stats_vdev *stats_vdev = video_get_drvdata(video);
+   struct v4l2_meta_format *meta = >fmt.meta;
+
+   if (f->type != video->queue->type)
+   return -EINVAL;
+
+   memset(meta, 0, sizeof(*meta));
+   meta->dataformat = stats_vdev->vdev_fmt.fmt.meta.dataformat;
+   meta->buffersize = stats_vdev->vdev_fmt.fmt.meta.buffersize;
+
+   return 0;
+}
+
+static int rkisp1_stats_querycap(struct file *file,
+void *priv, struct v4l2_capability *cap)
+{
+   struct video_device *vdev = video_devdata(file);
+
+   strcpy(cap->driver, DRIVER_NAME);
+   strlcpy(cap->card, vdev->name, sizeof(cap->card));
+   strlcpy(cap->bus_info, "platform: " DRIVER_NAME, sizeof(cap->bus_info));
+
+   return 0;
+}
+
+/* ISP video device IOCTLs */
+static const struct v4l2_ioctl_ops rkisp1_stats_ioctl = {
+   .vidioc_reqbufs = vb2_ioctl_reqbufs,
+   .vidioc_querybuf = vb2_ioctl_querybuf,
+   .vidioc_create_bufs = vb2_ioctl_create_bufs,
+   .vidioc_qbuf = vb2_ioctl_qbuf,
+   .vidioc_dqbuf = vb2_ioctl_dqbuf,
+   .vidioc_prepare_buf = vb2_ioctl_prepare_buf,
+   .vidioc_expbuf = vb2_ioctl_expbuf,
+   .vidioc_streamon = vb2_ioctl_streamon,
+   .vidioc_streamoff = vb2_ioctl_streamoff,
+   .vidioc_enum_fmt_meta_cap = rkisp1_stats_enum_fmt_meta_cap,
+   .vidioc_g_fmt_meta_ca

[PATCH v5 09/16] media: rkisp1: add rockchip isp1 core driver

2017-12-29 Thread Shunqian Zheng
From: Jacob Chen <jacob2.c...@rock-chips.com>

Add the core driver for rockchip isp1.

Signed-off-by: Jacob Chen <jacob2.c...@rock-chips.com>
Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Signed-off-by: Yichong Zhong <z...@rock-chips.com>
Signed-off-by: Jacob Chen <c...@rock-chips.com>
Signed-off-by: Eddie Cai <eddie.cai.li...@gmail.com>
Signed-off-by: Jeffy Chen <jeffy.c...@rock-chips.com>
Signed-off-by: Allon Huang <allon.hu...@rock-chips.com>
Signed-off-by: Tomasz Figa <tf...@chromium.org>
---
 drivers/media/platform/Kconfig|  10 +
 drivers/media/platform/Makefile   |   1 +
 drivers/media/platform/rockchip/isp1/Makefile |   8 +
 drivers/media/platform/rockchip/isp1/common.h | 137 ++
 drivers/media/platform/rockchip/isp1/dev.c| 653 ++
 drivers/media/platform/rockchip/isp1/dev.h| 120 +
 6 files changed, 929 insertions(+)
 create mode 100644 drivers/media/platform/rockchip/isp1/Makefile
 create mode 100644 drivers/media/platform/rockchip/isp1/common.h
 create mode 100644 drivers/media/platform/rockchip/isp1/dev.c
 create mode 100644 drivers/media/platform/rockchip/isp1/dev.h

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index fd0c998..062fffc 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -117,6 +117,16 @@ config VIDEO_QCOM_CAMSS
select VIDEOBUF2_DMA_SG
select V4L2_FWNODE
 
+config VIDEO_ROCKCHIP_ISP1
+   tristate "Rockchip Image Signal Processing v1 Unit driver"
+   depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API
+   depends on ARCH_ROCKCHIP || COMPILE_TEST
+   select VIDEOBUF2_DMA_CONTIG
+   select V4L2_FWNODE
+   default n
+   ---help---
+ Support for ISP1 on the rockchip SoC.
+
 config VIDEO_S3C_CAMIF
tristate "Samsung S3C24XX/S3C64XX SoC Camera Interface driver"
depends on VIDEO_V4L2 && I2C && VIDEO_V4L2_SUBDEV_API
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 003b0bb..d235908 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_VIDEO_RENESAS_FDP1)  += rcar_fdp1.o
 obj-$(CONFIG_VIDEO_RENESAS_JPU)+= rcar_jpu.o
 obj-$(CONFIG_VIDEO_RENESAS_VSP1)   += vsp1/
 
+obj-$(CONFIG_VIDEO_ROCKCHIP_ISP1)  += rockchip/isp1/
 obj-$(CONFIG_VIDEO_ROCKCHIP_RGA)   += rockchip/rga/
 
 obj-y  += omap/
diff --git a/drivers/media/platform/rockchip/isp1/Makefile 
b/drivers/media/platform/rockchip/isp1/Makefile
new file mode 100644
index 000..18af648
--- /dev/null
+++ b/drivers/media/platform/rockchip/isp1/Makefile
@@ -0,0 +1,8 @@
+obj-$(CONFIG_VIDEO_ROCKCHIP_ISP1) +=   video_rkisp1.o
+video_rkisp1-objs +=   rkisp1.o \
+   dev.o \
+   regs.o \
+   isp_stats.o \
+   isp_params.o \
+   mipi_dphy_sy.o \
+   capture.o
diff --git a/drivers/media/platform/rockchip/isp1/common.h 
b/drivers/media/platform/rockchip/isp1/common.h
new file mode 100644
index 000..1adfb90
--- /dev/null
+++ b/drivers/media/platform/rockchip/isp1/common.h
@@ -0,0 +1,137 @@
+/*
+ * Rockchip isp1 driver
+ *
+ * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _RKISP1_COMMON_H
+#define _RKISP1_COMMON_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#i

[PATCH v5 07/16] media: rkisp1: add ISP1 params driver

2017-12-29 Thread Shunqian Zheng
From: Jacob Chen <jacob2.c...@rock-chips.com>

Add the output video driver that accept params from userspace.

Signed-off-by: Jacob Chen <jacob2.c...@rock-chips.com>
Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Signed-off-by: Yichong Zhong <z...@rock-chips.com>
Signed-off-by: Jacob Chen <c...@rock-chips.com>
Signed-off-by: Eddie Cai <eddie.cai.li...@gmail.com>
Signed-off-by: Jeffy Chen <jeffy.c...@rock-chips.com>
Signed-off-by: Allon Huang <allon.hu...@rock-chips.com>
Signed-off-by: Tomasz Figa <tf...@chromium.org>
---
 drivers/media/platform/rockchip/isp1/isp_params.c | 1553 +
 drivers/media/platform/rockchip/isp1/isp_params.h |   76 +
 2 files changed, 1629 insertions(+)
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_params.c
 create mode 100644 drivers/media/platform/rockchip/isp1/isp_params.h

diff --git a/drivers/media/platform/rockchip/isp1/isp_params.c 
b/drivers/media/platform/rockchip/isp1/isp_params.c
new file mode 100644
index 000..7a90965
--- /dev/null
+++ b/drivers/media/platform/rockchip/isp1/isp_params.c
@@ -0,0 +1,1553 @@
+/*
+ * Rockchip isp1 driver
+ *
+ * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include/* for ISP params */
+#include "dev.h"
+#include "regs.h"
+
+#define RKISP1_ISP_PARAMS_REQ_BUFS_MIN 2
+#define RKISP1_ISP_PARAMS_REQ_BUFS_MAX 8
+
+#define BLS_START_H_MAX_IS_VALID(val)  ((val) < CIFISP_BLS_START_H_MAX)
+#define BLS_STOP_H_MAX_IS_VALID(val)   ((val) < CIFISP_BLS_STOP_H_MAX)
+
+#define BLS_START_V_MAX_IS_VALID(val)  ((val) < CIFISP_BLS_START_V_MAX)
+#define BLS_STOP_V_MAX_IS_VALID(val)   ((val) < CIFISP_BLS_STOP_V_MAX)
+
+#define BLS_SAMPLE_MAX_IS_VALID(val)   ((val) < CIFISP_BLS_SAMPLES_MAX)
+
+#define BLS_FIX_SUB_IS_VALID(val)  \
+   ((val) > (s16) CIFISP_BLS_FIX_SUB_MIN && (val) < CIFISP_BLS_FIX_SUB_MAX)
+
+#define RKISP1_ISP_DPCC_LINE_THRESH(n) (CIF_ISP_DPCC_LINE_THRESH_1 + 0x14 * 
(n))
+#define RKISP1_ISP_DPCC_LINE_MAD_FAC(n) (CIF_ISP_DPCC_LINE_MAD_FAC_1 + 0x14 * 
(n))
+#define RKISP1_ISP_DPCC_PG_FAC(n)  (CIF_ISP_DPCC_PG_FAC_1 + 0x14 * (n))
+#define RKISP1_ISP_DPCC_RND_THRESH(n)  (CIF_ISP_DPCC_RND_THRESH_1 + 0x14 * (n))
+#define RKISP1_ISP_DPCC_RG_FAC(n)  (CIF_ISP_DPCC_RG_FAC_1 + 0x14 * (n))
+#define RKISP1_ISP_CC_COEFF(n) (CIF_ISP_CC_COEFF_0 + (n) * 4)
+
+static inline void rkisp1_iowrite32(struct rkisp1_isp_params_vdev *params_vdev,
+   u32 value, u32 addr)
+{
+   iowrite32(value, params_vdev->dev->base_addr + addr);
+}
+
+static inline u32 rkisp1_ioread32(struct rkisp1_isp_params_vdev *params_vdev,
+ u32 addr)
+{
+   return ioread32(params_vdev->dev->base_addr + addr);
+}
+
+static inline void isp_param_set_bits(struct rkisp1_isp_params_vdev
+*params_vdev,
+ u32 reg, u32 bit_mask)
+{
+   u32 val;
+
+   val = rkisp1_ioread32(params_vdev, reg);
+   rkisp1_iowrite32(params_vdev, val | bit_mask, reg);
+}
+
+static inline void isp_param_clear_bits(struct rkisp1_isp_params_vdev
+  *params_vdev,
+   u32 reg, u32 bit_mask)
+{
+   u32 val;
+
+   val = rkisp1_ioread32(params_vdev, reg);
+   rkisp1_iowrite32(params_vdev, val & ~bit_mask, reg);
+}
+
+/* ISP BP interface function */
+static void dpcc_config(st

[PATCH v5 13/16] ARM: dts: rockchip: add rx0 mipi-phy for rk3288

2017-12-29 Thread Shunqian Zheng
From: Jacob Chen 

It's a Designware MIPI D-PHY, used by ISP in rk3288.

Signed-off-by: Jacob Chen 
---
 arch/arm/boot/dts/rk3288.dtsi | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index 5dbfafb..a4c9a6e 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -864,6 +864,13 @@
status = "disabled";
};
 
+   mipi_phy_rx0: mipi-phy-rx0 {
+   compatible = "rockchip,rk3288-mipi-dphy";
+   clocks = < SCLK_MIPIDSI_24M>, < PCLK_MIPI_CSI>;
+   clock-names = "dphy-ref", "pclk";
+   status = "disabled";
+   };
+
io_domains: io-domains {
compatible = "rockchip,rk3288-io-voltage-domain";
status = "disabled";
-- 
1.9.1



[PATCH v5 14/16] arm64: dts: rockchip: add isp0 node for rk3399

2017-12-29 Thread Shunqian Zheng
rk3399 have two ISP, but we havn't test isp1, so just add isp0 at present.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Signed-off-by: Jacob Chen <jacob2.c...@rock-chips.com>
---
 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index d340b58a..66a912f 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -1588,6 +1588,21 @@
status = "disabled";
};
 
+   isp0: isp0@ff91 {
+   compatible = "rockchip,rk3399-cif-isp";
+   reg = <0x0 0xff91 0x0 0x4000>;
+   interrupts = ;
+   clocks = < SCLK_ISP0>,
+< ACLK_ISP0>, < ACLK_ISP0_WRAPPER>,
+< HCLK_ISP0>, < HCLK_ISP0_WRAPPER>;
+   clock-names = "clk_isp",
+ "aclk_isp", "aclk_isp_wrap",
+ "hclk_isp", "hclk_isp_wrap";
+   power-domains = < RK3399_PD_ISP0>;
+   iommus = <_mmu>;
+   status = "disabled";
+   };
+
isp0_mmu: iommu@ff914000 {
compatible = "rockchip,iommu";
reg = <0x0 0xff914000 0x0 0x100>, <0x0 0xff915000 0x0 0x100>;
-- 
1.9.1



[PATCH v5 15/16] arm64: dts: rockchip: add rx0 mipi-phy for rk3399

2017-12-29 Thread Shunqian Zheng
It's a Designware MIPI D-PHY, used for ISP0 in rk3399.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Signed-off-by: Jacob Chen <jacob2.c...@rock-chips.com>
---
 arch/arm64/boot/dts/rockchip/rk3399.dtsi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
index 66a912f..8ef321f 100644
--- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi
@@ -1292,6 +1292,16 @@
status = "disabled";
};
 
+   mipi_dphy_rx0: mipi-dphy-rx0 {
+   compatible = "rockchip,rk3399-mipi-dphy";
+   clocks = < SCLK_MIPIDPHY_REF>,
+   < SCLK_DPHY_RX0_CFG>,
+   < PCLK_VIO_GRF>;
+   clock-names = "dphy-ref", "dphy-cfg", "grf";
+   power-domains = < RK3399_PD_VIO>;
+   status = "disabled";
+   };
+
u2phy0: usb2-phy@e450 {
compatible = "rockchip,rk3399-usb2phy";
reg = <0xe450 0x10>;
-- 
1.9.1



[PATCH v5 11/16] dt-bindings: Document the Rockchip MIPI RX D-PHY bindings

2017-12-29 Thread Shunqian Zheng
From: Jacob Chen 

Add DT bindings documentation for Rockchip MIPI D-PHY RX

Signed-off-by: Jacob Chen 
Reviewed-by: Rob Herring 
---
 .../bindings/media/rockchip-mipi-dphy.txt  | 88 ++
 1 file changed, 88 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt

diff --git a/Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt 
b/Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt
new file mode 100644
index 000..0571d7f
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt
@@ -0,0 +1,88 @@
+Rockchip SoC MIPI RX D-PHY
+-
+
+Required properties:
+- compatible: value should be one of the following
+   "rockchip,rk3288-mipi-dphy"
+   "rockchip,rk3399-mipi-dphy"
+- clocks : list of clock specifiers, corresponding to entries in
+   clock-names property;
+- clock-names: required clock name.
+
+MIPI RX0 D-PHY use registers in "general register files", it
+should be a child of the GRF.
+MIPI TXRX D-PHY have its own registers, it must have a reg property.
+
+Optional properties:
+- reg: offset and length of the register set for the device.
+
+port node
+---
+
+The device node should contain two 'port' child nodes, according to the 
bindings
+defined in Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+The first port show the sensors connected in this mipi-dphy.
+- endpoint:
+   - remote-endpoint: Linked to a sensor with a MIPI CSI-2 video bus.
+   - data-lanes : (required) an array specifying active physical MIPI-CSI2
+   data input lanes and their mapping to logical lanes; the
+   D-PHY can't reroute lanes, so the array's content should
+   be consecutive and only its length is meaningful.
+
+The port node must contain at least one endpoint. It could have multiple 
endpoints
+linked to different sensors, but please note that they are not supposed to be
+activated at the same time.
+
+The second port should be connected to isp node.
+- endpoint:
+   - remote-endpoint:  Linked to Rockchip ISP1, which is defined
+   in rockchip-isp1.txt.
+
+Device node example
+---
+
+grf: syscon@ff77 {
+   compatible = "rockchip,rk3288-grf", "syscon", "simple-mfd";
+
+...
+
+   mipi_dphy_rx0: mipi-dphy-rx0 {
+   compatible = "rockchip,rk3399-mipi-dphy";
+   clocks = < SCLK_MIPIDPHY_REF>,
+   < SCLK_DPHY_RX0_CFG>,
+   < PCLK_VIO_GRF>;
+   clock-names = "dphy-ref", "dphy-cfg", "grf";
+   power-domains = < RK3399_PD_VIO>;
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   mipi_in_wcam: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = <_out>;
+   data-lanes = <1 2>;
+   };
+   mipi_in_ucam: endpoint@1 {
+   reg = <1>;
+   remote-endpoint = <_out>;
+   data-lanes = <1>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   dphy_rx0_out: endpoint {
+   remote-endpoint = <_mipi_in>;
+   };
+   };
+   };
+   };
+};
-- 
1.9.1



[PATCH v5 12/16] ARM: dts: rockchip: add isp node for rk3288

2017-12-29 Thread Shunqian Zheng
From: Jacob Chen 

rk3288 have a Embedded 13M ISP

Signed-off-by: Jacob Chen 
---
 arch/arm/boot/dts/rk3288.dtsi | 17 +
 1 file changed, 17 insertions(+)

diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index cd24894..5dbfafb 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -962,6 +962,23 @@
status = "disabled";
};
 
+   isp: isp@ff91 {
+   compatible = "rockchip,rk3288-cif-isp";
+   reg = <0x0 0xff91 0x0 0x4000>;
+   interrupts = ;
+   clocks = < SCLK_ISP>, < ACLK_ISP>,
+< HCLK_ISP>, < PCLK_ISP_IN>,
+< SCLK_ISP_JPE>;
+   clock-names = "clk_isp", "aclk_isp",
+ "hclk_isp", "pclk_isp_in",
+ "sclk_isp_jpe";
+   assigned-clocks = < SCLK_ISP>, < SCLK_ISP_JPE>;
+   assigned-clock-rates = <4>, <4>;
+   power-domains = < RK3288_PD_VIO>;
+   iommus = <_mmu>;
+   status = "disabled";
+   };
+
isp_mmu: iommu@ff914000 {
compatible = "rockchip,iommu";
reg = <0x0 0xff914000 0x0 0x100>, <0x0 0xff915000 0x0 0x100>;
-- 
1.9.1



[PATCH v5 16/16] MAINTAINERS: add entry for Rockchip ISP1 driver

2017-12-28 Thread Shunqian Zheng
From: Jacob Chen <jacob2.c...@rock-chips.com>

Add MAINTAINERS entry for the rockchip isp1 driver.
This driver is maintained by rockchip officially and it
will be used for rockchip SoC on all linux-kernel based OS.

Signed-off-by: Jacob Chen <jacob2.c...@rock-chips.com>
---
 MAINTAINERS | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 85773bf..b97bc25 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -11668,6 +11668,16 @@ F: drivers/hid/hid-roccat*
 F: include/linux/hid-roccat*
 F: Documentation/ABI/*/sysfs-driver-hid-roccat*
 
+ROCKCHIP ISP V1 DRIVER
+M: Jacob chen <jacob2.c...@rock-chips.com>
+M: Shunqian Zheng <zhen...@rock-chips.com>
+M: Yichong Zhong <z...@rock-chips.com>
+L: linux-media@vger.kernel.org
+S: Maintained
+F: drivers/media/platform/rockchip/isp1/
+F: Documentation/devicetree/bindings/media/rockchip-isp1.txt
+F: Documentation/devicetree/bindings/media/rockchip-mipi-dphy.txt
+
 ROCKCHIP RASTER 2D GRAPHIC ACCELERATION UNIT DRIVER
 M: Jacob chen <jacob2.c...@rock-chips.com>
 L: linux-media@vger.kernel.org
-- 
1.9.1



[PATCH v5 08/16] media: rkisp1: add capture device driver

2017-12-28 Thread Shunqian Zheng
From: Jacob Chen <jacob2.c...@rock-chips.com>

This is the capture device interface driver that provides the v4l2
user interface. Frames can be received from ISP1.

Signed-off-by: Jacob Chen <jacob2.c...@rock-chips.com>
Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
Signed-off-by: Yichong Zhong <z...@rock-chips.com>
Signed-off-by: Jacob Chen <c...@rock-chips.com>
Signed-off-by: Eddie Cai <eddie.cai.li...@gmail.com>
Signed-off-by: Jeffy Chen <jeffy.c...@rock-chips.com>
Signed-off-by: Allon Huang <allon.hu...@rock-chips.com>
Signed-off-by: Tomasz Figa <tf...@chromium.org>
---
 drivers/media/platform/rockchip/isp1/capture.c | 1728 
 drivers/media/platform/rockchip/isp1/capture.h |  194 +++
 drivers/media/platform/rockchip/isp1/regs.c|  266 
 drivers/media/platform/rockchip/isp1/regs.h| 1577 +
 4 files changed, 3765 insertions(+)
 create mode 100644 drivers/media/platform/rockchip/isp1/capture.c
 create mode 100644 drivers/media/platform/rockchip/isp1/capture.h
 create mode 100644 drivers/media/platform/rockchip/isp1/regs.c
 create mode 100644 drivers/media/platform/rockchip/isp1/regs.h

diff --git a/drivers/media/platform/rockchip/isp1/capture.c 
b/drivers/media/platform/rockchip/isp1/capture.c
new file mode 100644
index 000..a232dce
--- /dev/null
+++ b/drivers/media/platform/rockchip/isp1/capture.c
@@ -0,0 +1,1729 @@
+/*
+ * Rockchip isp1 driver
+ *
+ * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
+ *
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ *  - Redistributions of source code must retain the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer.
+ *
+ *  - Redistributions in binary form must reproduce the above
+ *copyright notice, this list of conditions and the following
+ *disclaimer in the documentation and/or other materials
+ *provided with the distribution.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "dev.h"
+#include "regs.h"
+
+/*
+ * NOTE:
+ * 1. There are two capture video devices in rkisp1, selfpath and mainpath
+ * 2. Two capture device have separated memory-interface/crop/scale units.
+ * 3. Besides describing stream hardware, this file also contain entries
+ *for pipeline operations.
+ * 4. The register read/write operations in this file are put into regs.c.
+ */
+
+/*
+ * differences between selfpatch and mainpath
+ * available mp sink input: isp
+ * available sp sink input : isp, dma(TODO)
+ * available mp sink pad fmts: yuv422, raw
+ * available sp sink pad fmts: yuv422, yuv420..
+ * available mp source fmts: yuv, raw, jpeg(TODO)
+ * available sp source fmts: yuv, rgb
+ */
+
+#define CIF_ISP_REQ_BUFS_MIN 1
+#define CIF_ISP_REQ_BUFS_MAX 8
+
+#define STREAM_PAD_SINK0
+#define STREAM_PAD_SOURCE  1
+
+#define STREAM_MAX_MP_RSZ_OUTPUT_WIDTH 4416
+#define STREAM_MAX_MP_RSZ_OUTPUT_HEIGHT3312
+#define STREAM_MAX_SP_RSZ_OUTPUT_WIDTH 1920
+#define STREAM_MAX_SP_RSZ_OUTPUT_HEIGHT1920
+#define STREAM_MIN_RSZ_OUTPUT_WIDTH32
+#define STREAM_MIN_RSZ_OUTPUT_HEIGHT   16
+
+#define STREAM_MAX_MP_SP_INPUT_WIDTH STREAM_MAX_MP_RSZ_OUTPUT_WIDTH
+#define STREAM_MAX_MP_SP_INPUT_HEIGHT STREAM_MAX_MP_RSZ_OUTPUT_HEIGHT
+#define STREAM_MIN_MP_SP_INPUT_WIDTH   32
+#define STREAM_MIN_MP_SP_INPUT_HEIGHT  32
+
+/* Get xsubs and ysubs for fourcc formats
+ *
+ * @xsubs: horizontal color samples in a 4*4 matrix, for yuv
+ * @ysubs: vertical color samples in a 4*4 matrix, for yuv
+ */
+static int fcc_xysubs(u32 fcc, u32 *xsubs, u32 *ysubs)
+{
+   switch (fcc) {
+   case V4L2_PIX_FMT_GREY:
+   case V4L2_PIX_FMT_YUV444M:
+   *xsubs = 1;
+   *ysubs = 1;
+   break;
+   case V4L2_PIX_FMT_YUYV:
+   case V4L2_PIX_FMT_Y

[PATCH v5 10/16] dt-bindings: Document the Rockchip ISP1 bindings

2017-12-28 Thread Shunqian Zheng
From: Jacob Chen 

Add DT bindings documentation for Rockchip ISP1

Signed-off-by: Jacob Chen 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/media/rockchip-isp1.txt| 69 ++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/rockchip-isp1.txt

diff --git a/Documentation/devicetree/bindings/media/rockchip-isp1.txt 
b/Documentation/devicetree/bindings/media/rockchip-isp1.txt
new file mode 100644
index 000..4631a4b
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/rockchip-isp1.txt
@@ -0,0 +1,69 @@
+Rockchip SoC Image Signal Processing unit v1
+--
+
+Rockchip ISP1 is the Camera interface for the Rockchip series of SoCs
+which contains image processing, scaling, and compression funcitons.
+
+Required properties:
+- compatible: value should be one of the following
+   "rockchip,rk3288-cif-isp";
+   "rockchip,rk3399-cif-isp";
+- reg : offset and length of the register set for the device.
+- interrupts: should contain ISP interrupt.
+- clocks: phandle to the required clocks.
+- clock-names: required clock name.
+- iommus: required a iommu node.
+
+port node
+---
+
+The device node should contain one 'port' child node with child 'endpoint'
+nodes, according to the bindings defined in Documentation/devicetree/bindings/
+media/video-interfaces.txt.
+
+- endpoint(parallel):
+   - remote-endpoint: Connecting to a sensor with a parallel video bus.
+   - parallel_bus properties: Refer to Documentation/devicetree/bindings/
+   media/video-interfaces.txt.
+- endpoint(mipi):
+   - remote-endpoint: Connecting to Rockchip MIPI-DPHY,
+   which is defined in rockchip-mipi-dphy.txt.
+
+The port node must contain at least one endpoint, either parallel or mipi.
+It could have multiple endpoints, but please note the hardware don't support
+two sensors work at a time, they are supposed to work asynchronously.
+
+Device node example
+---
+
+   isp0: isp0@ff91 {
+   compatible = "rockchip,rk3399-cif-isp";
+   reg = <0x0 0xff91 0x0 0x4000>;
+   interrupts = ;
+   clocks = < SCLK_ISP0>,
+< ACLK_ISP0>, < ACLK_ISP0_WRAPPER>,
+< HCLK_ISP0>, < HCLK_ISP0_WRAPPER>;
+   clock-names = "clk_isp",
+ "aclk_isp", "aclk_isp_wrap",
+ "hclk_isp", "hclk_isp_wrap";
+   power-domains = < RK3399_PD_ISP0>;
+   iommus = <_mmu>;
+
+   port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   /* mipi */
+   isp0_mipi_in: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = <_rx0_out>;
+   };
+
+   /* parallel */
+   isp0_parallel_in: endpoint@1 {
+   reg = <1>;
+   remote-endpoint = <_out>;
+   bus-width = <8>;
+   };
+   };
+   };
-- 
1.9.1



Re: [PATCH 4/4] [media] dt/bindings: Add bindings for OV2685

2017-12-26 Thread Shunqian Zheng

Rob,

On 2017年12月27日 07:28, Rob Herring wrote:

On Mon, Dec 25, 2017 at 10:11:26PM +0800, Shunqian Zheng wrote:

Add device tree binding documentation for the OV2685 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
  .../devicetree/bindings/media/i2c/ov2685.txt   | 35 ++
  1 file changed, 35 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2685.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov2685.txt 
b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
new file mode 100644
index 000..c62db9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
@@ -0,0 +1,35 @@
+* Omnivision OV2685 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: should be "ovti,ov2685"
+- clocks: reference to the 24M xvclk input clock.
+- clock-names: should be "xvclk".
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dvdd-supply: Digital core voltage supply, 1.2 volts
+- reset-gpios: Low active reset gpio
+
+The device node must contain one 'port' child node for its digital output
+video port, in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+   ucam: ov2680@3c {

camera-sensor@3c


+   compatible = "ovti,ov2685";
+   reg = <0x3c>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam _rst>;

Not documented.
The _24m_cam is pin mux on my rk3399. While the _rst is board 
special pin, I should remove it in Document.


Thanks,

Shunqian




+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dovdd-supply = <>;
+   reset-gpios = < 3 GPIO_ACTIVE_LOW>;
+
+   port {
+   ucam_out: endpoint {
+   remote-endpoint = <_in_ucam>;
+   data-lanes = <1>;
+   };
+   };
+   };
--
1.9.1









[PATCH 4/4] [media] dt/bindings: Add bindings for OV2685

2017-12-25 Thread Shunqian Zheng
Add device tree binding documentation for the OV2685 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 .../devicetree/bindings/media/i2c/ov2685.txt   | 35 ++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov2685.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov2685.txt 
b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
new file mode 100644
index 000..c62db9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov2685.txt
@@ -0,0 +1,35 @@
+* Omnivision OV2685 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: should be "ovti,ov2685"
+- clocks: reference to the 24M xvclk input clock.
+- clock-names: should be "xvclk".
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dvdd-supply: Digital core voltage supply, 1.2 volts
+- reset-gpios: Low active reset gpio
+
+The device node must contain one 'port' child node for its digital output
+video port, in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+   ucam: ov2680@3c {
+   compatible = "ovti,ov2685";
+   reg = <0x3c>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam _rst>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dovdd-supply = <>;
+   reset-gpios = < 3 GPIO_ACTIVE_LOW>;
+
+   port {
+   ucam_out: endpoint {
+   remote-endpoint = <_in_ucam>;
+   data-lanes = <1>;
+   };
+   };
+   };
-- 
1.9.1



[PATCH 3/4] media: ov2685: add support for OV2685 sensor

2017-12-25 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov2685 sensor.
Though the ov2685 can output yuv data, this driver only
supports the raw bayer format, including the following features:
  - output 1600x1200 at 30fps
  - test patterns
  - manual exposure/gain control
  - vblank and hblank
  - media controller
  - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 drivers/media/i2c/Kconfig  |  12 +
 drivers/media/i2c/Makefile |   1 +
 drivers/media/i2c/ov2685.c | 834 +
 3 files changed, 847 insertions(+)
 create mode 100644 drivers/media/i2c/ov2685.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 55b37c8..63a175d 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -586,6 +586,18 @@ config VIDEO_OV2659
  To compile this driver as a module, choose M here: the
  module will be called ov2659.
 
+config VIDEO_OV2685
+   tristate "OmniVision OV2685 sensor support"
+   depends on VIDEO_V4L2 && I2C && MEDIA_CONTROLLER
+   depends on MEDIA_CAMERA_SUPPORT
+   select V4L2_FWNODE
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV2685 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov2685.
+
 config VIDEO_OV5640
tristate "OmniVision OV5640 sensor support"
depends on OF
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index a063030..3054c69 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -61,6 +61,7 @@ obj-$(CONFIG_VIDEO_SONY_BTF_MPX) += sony-btf-mpx.o
 obj-$(CONFIG_VIDEO_UPD64031A) += upd64031a.o
 obj-$(CONFIG_VIDEO_UPD64083) += upd64083.o
 obj-$(CONFIG_VIDEO_OV2640) += ov2640.o
+obj-$(CONFIG_VIDEO_OV2685) += ov2685.o
 obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
new file mode 100644
index 000..60b0794
--- /dev/null
+++ b/drivers/media/i2c/ov2685.c
@@ -0,0 +1,834 @@
+/*
+ * ov2685 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CHIP_ID0x2685
+#define OV2685_REG_CHIP_ID 0x300a
+
+#define REG_SC_CTRL_MODE   0x0100
+#define SC_CTRL_MODE_STANDBY   0x0
+#define SC_CTRL_MODE_STREAMING BIT(0)
+
+#define OV2685_REG_EXPOSURE0x3500
+#defineOV2685_EXPOSURE_MIN 4
+#defineOV2685_EXPOSURE_STEP1
+
+#define OV2685_REG_VTS 0x380e
+#define OV2685_VTS_MAX 0x7fff
+#define OV2685_VBLANK_MIN  0x0
+
+#define OV2685_REG_GAIN0x350a
+#define OV2685_GAIN_MIN0
+#define OV2685_GAIN_MAX0x07ff
+/* 4 least significant bits of expsoure are fractional part */
+#define OV2685_GAIN_STEP   0x10
+#define OV2685_GAIN_DEFAULT0x0036
+
+#define OV2685_REG_TEST_PATTERN0x5080
+#define OV2685_TEST_PATTERN_DISABLED   0x00
+#define OV2685_TEST_PATTERN_COLOR_BAR  0x80
+#define OV2685_TEST_PATTERN_RND0x81
+#define OV2685_TEST_PATTERN_COLOR_BAR_FADE 0x88
+#define OV2685_TEST_PATTERN_BW_SQUARE  0x92
+#define OV2685_TEST_PATTERN_COLOR_SQUARE   0x82
+
+#define REG_NULL   0x
+
+#define OV2685_REG_VALUE_08BIT 1
+#define OV2685_REG_VALUE_16BIT 2
+#define OV2685_REG_VALUE_24BIT 3
+
+#define OV2685_LANES   1
+#define OV2685_BITS_PER_SAMPLE 10
+
+struct regval {
+   u16 addr;
+   u8 val;
+};
+
+struct ov2685_mode {
+   u32 width;
+   u32 height;
+   u32 exp_def;
+   u32 hts_def;
+   u32 vts_def;
+   const struct regval *reg_list;
+};
+
+struct ov2685 {
+   struct i2c_client   *client;
+   struct clk  *xvclk;
+   struct regulator*avdd_regulator;/* Analog power */
+   struct regulator*dovdd_regulator;   /* Digital I/O power */
+   /* use internal DVDD power */
+   struct gpio_desc*reset_gpio;
+
+   boolstreaming;
+   struct mutexmutex;
+   struct v4l2_subdev  subdev;
+   struct media_padpad;
+   struct v4l2_ctrl*anal_gain;
+   struct v4l2_ctrl 

[PATCH 1/4] media: ov5695: add support for OV5695 sensor

2017-12-25 Thread Shunqian Zheng
This patch adds driver for Omnivision's ov5695 sensor,
the driver supports following features:
 - supported resolutions
   + 2592x1944 at 30fps
   + 1920x1080 at 30fps
   + 1296x972 at 60fps
   + 1280x720 at 30fps
   + 640x480 at 120fps
 - test patterns
 - manual exposure/gain(analog and digital) control
 - vblank and hblank
 - media controller
 - runtime pm

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 drivers/media/i2c/Kconfig  |   11 +
 drivers/media/i2c/Makefile |1 +
 drivers/media/i2c/ov5695.c | 1396 
 3 files changed, 1408 insertions(+)
 create mode 100644 drivers/media/i2c/ov5695.c

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 3c6d642..55b37c8 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -645,6 +645,17 @@ config VIDEO_OV5670
  To compile this driver as a module, choose M here: the
  module will be called ov5670.
 
+config VIDEO_OV5695
+   tristate "OmniVision OV5695 sensor support"
+   depends on I2C && VIDEO_V4L2
+   depends on MEDIA_CAMERA_SUPPORT
+   ---help---
+ This is a Video4Linux2 sensor-level driver for the OmniVision
+ OV5695 camera.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov5695.
+
 config VIDEO_OV7640
tristate "OmniVision OV7640 sensor support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 548a9ef..a063030 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -65,6 +65,7 @@ obj-$(CONFIG_VIDEO_OV5640) += ov5640.o
 obj-$(CONFIG_VIDEO_OV5645) += ov5645.o
 obj-$(CONFIG_VIDEO_OV5647) += ov5647.o
 obj-$(CONFIG_VIDEO_OV5670) += ov5670.o
+obj-$(CONFIG_VIDEO_OV5695) += ov5695.o
 obj-$(CONFIG_VIDEO_OV6650) += ov6650.o
 obj-$(CONFIG_VIDEO_OV7640) += ov7640.o
 obj-$(CONFIG_VIDEO_OV7670) += ov7670.o
diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
new file mode 100644
index 000..5d546c8
--- /dev/null
+++ b/drivers/media/i2c/ov5695.c
@@ -0,0 +1,1396 @@
+/*
+ * ov5695 driver
+ *
+ * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#ifndef V4L2_CID_DIGITAL_GAIN
+#define V4L2_CID_DIGITAL_GAIN  V4L2_CID_GAIN
+#endif
+
+/* 45Mhz * 4 Binning */
+#define OV5695_PIXEL_RATE  (45 * 1000 * 1000 * 4)
+#define CHIP_ID0x005695
+#define OV5695_REG_CHIP_ID 0x300a
+
+#define OV5695_REG_CTRL_MODE   0x0100
+#define OV5695_MODE_SW_STANDBY 0x0
+#define OV5695_MODE_STREAMING  BIT(0)
+
+#define OV5695_REG_EXPOSURE0x3500
+#defineOV5695_EXPOSURE_MIN 4
+#defineOV5695_EXPOSURE_STEP1
+#define OV5695_VTS_MAX 0x7fff
+#define OV5695_VBLANK_MIN  0x0
+
+#define OV5695_REG_ANALOG_GAIN 0x3509
+#defineANALOG_GAIN_MIN 0x10
+#defineANALOG_GAIN_MAX 0xf8
+#defineANALOG_GAIN_STEP1
+#defineANALOG_GAIN_DEFAULT 0xf8
+
+#define OV5695_REG_DIGI_GAIN_H 0x350a
+#define OV5695_REG_DIGI_GAIN_L 0x350b
+#define OV5695_DIGI_GAIN_L_MASK0x3f
+#define OV5695_DIGI_GAIN_H_SHIFT   6
+#define OV5695_DIGI_GAIN_MIN   0
+#define OV5695_DIGI_GAIN_MAX   (0x4000 - 1)
+#define OV5695_DIGI_GAIN_STEP  1
+#define OV5695_DIGI_GAIN_DEFAULT   1024
+
+#define OV5695_REG_TEST_PATTERN0x4503
+#defineOV5695_TEST_PATTERN_ENABLE  0x80
+#defineOV5695_TEST_PATTERN_DISABLE 0x0
+
+#define OV5695_REG_VTS 0x380e
+
+#define REG_NULL   0x
+
+#define OV5695_REG_VALUE_08BIT 1
+#define OV5695_REG_VALUE_16BIT 2
+#define OV5695_REG_VALUE_24BIT 3
+
+#define OV5695_LANES   2
+#define OV5695_BITS_PER_SAMPLE 10
+
+struct regval {
+   u16 addr;
+   u8 val;
+};
+
+struct ov5695_mode {
+   u32 width;
+   u32 height;
+   u32 max_fps;
+   u32 hts_def;
+   u32 vts_def;
+   u32 exp_def;
+   const struct regval *reg_list;
+};
+
+struct ov5695 {
+   struct i2c_client   *client;
+   struct clk  *xvclk;
+   struct regulator*avdd_regulator;
+   struct regulator*dovdd_regulator;
+   struct regulator*dvdd_regulator;
+   struct gpio_desc*reset_gpio

[PATCH 2/4] [media] dt/bindings: Add bindings for OV5695

2017-12-25 Thread Shunqian Zheng
Add device tree binding documentation for the OV5695 sensor.

Signed-off-by: Shunqian Zheng <zhen...@rock-chips.com>
---
 .../devicetree/bindings/media/i2c/ov5695.txt   | 38 ++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/i2c/ov5695.txt

diff --git a/Documentation/devicetree/bindings/media/i2c/ov5695.txt 
b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
new file mode 100644
index 000..ed27eb1
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/i2c/ov5695.txt
@@ -0,0 +1,38 @@
+* Omnivision OV5695 MIPI CSI-2 sensor
+
+Required Properties:
+- compatible: should be "ovti,ov5695"
+- clocks: reference to the 24M xvclk input clock.
+- clock-names: should be "xvclk".
+- dovdd-supply: Digital I/O voltage supply, 1.8 volts
+- avdd-supply: Analog voltage supply, 2.8 volts
+- dvdd-supply: Digital core voltage supply, 1.2 volts
+- reset-gpios: Low active reset gpio
+
+The device node must contain one 'port' child node for its digital output
+video port, in accordance with the video interface bindings defined in
+Documentation/devicetree/bindings/media/video-interfaces.txt.
+
+Example:
+ {
+   compatible = "ovti,ov5695";
+   reg = <0x36>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_24m_cam _rst>;
+
+   clocks = < SCLK_TESTCLKOUT1>;
+   clock-names = "xvclk";
+
+   avdd-supply = <_cam>;
+   dvdd-supply = <_cam>;
+   dovdd-supply = <>;
+
+   reset-gpios = < 5 GPIO_ACTIVE_LOW>;
+
+   port {
+   wcam_out: endpoint {
+   remote-endpoint = <_in_wcam>;
+   data-lanes = <1 2>;
+   };
+   };
+};
-- 
1.9.1