devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] media: ov7670: Implement mbus configuration
@ 2018-01-24  9:30 Jacopo Mondi
  2018-01-24  9:30 ` [PATCH v4 1/2] media: dt-bindings: Add OF properties to ov7670 Jacopo Mondi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jacopo Mondi @ 2018-01-24  9:30 UTC (permalink / raw)
  To: corbet-T1hC0tSOHrs, mchehab-DgEjT+Ai2ygdnm+yROfE0A,
	sakari.ailus-X3B1VOXEql0, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	mark.rutland-5wv7dgnIgG8
  Cc: Jacopo Mondi, linux-media-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Hello,
   4th round for this series, now based on Hans' 'parm' branch from
git://linuxtv.org/hverkuil/media_tree.git

I addressed Sakari's comments on bindings documentation and driver error path,
and I hope to get both driver and bindings acked to have this included in next
merge window.

Thanks
   j

v3->v4:
- Change bindings documentation to drop default value as vsync and hsync
  polarities are now required properties
- Do not put fwnode handle in driver dt parse error path as dev_fwnode() does
  not increase ref counting

v2->v3:
- Drop 'pll-bypass' property
- Make 'plck-hb-disable' a boolean optional property
- List 'hsync' and 'vsync' polarities as required endpoint properties
- Restructured 'ov7670_parse_dt()' function to reflect the above changes

v1->v2:
- Split bindings description and implementation
- Addressed Sakari's comments on v1
- Check for return values of register writes in set_fmt()
- TODO: decide if "pll-bypass" should be an OF property.

Jacopo Mondi (2):
  media: dt-bindings: Add OF properties to ov7670
  v4l2: i2c: ov7670: Implement OF mbus configuration

 .../devicetree/bindings/media/i2c/ov7670.txt       | 16 +++-
 drivers/media/i2c/ov7670.c                         | 98 ++++++++++++++++++----
 2 files changed, 98 insertions(+), 16 deletions(-)

--
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v4 1/2] media: dt-bindings: Add OF properties to ov7670
  2018-01-24  9:30 [PATCH v4 0/2] media: ov7670: Implement mbus configuration Jacopo Mondi
@ 2018-01-24  9:30 ` Jacopo Mondi
       [not found]   ` <1516786250-3750-2-git-send-email-jacopo+renesas-AW8dsiIh9cEdnm+yROfE0A@public.gmane.org>
  2018-01-24  9:30 ` [PATCH v4 2/2] v4l2: i2c: ov7670: Implement OF mbus configuration Jacopo Mondi
       [not found] ` <1516786250-3750-1-git-send-email-jacopo+renesas-AW8dsiIh9cEdnm+yROfE0A@public.gmane.org>
  2 siblings, 1 reply; 6+ messages in thread
From: Jacopo Mondi @ 2018-01-24  9:30 UTC (permalink / raw)
  To: corbet, mchehab, sakari.ailus, robh+dt, mark.rutland
  Cc: Jacopo Mondi, linux-media, devicetree, linux-kernel

Describe newly introduced OF properties for ov7670 image sensor.
The driver supports two standard properties to configure synchronism
signals polarities and one custom property already supported as
platform data options to suppress pixel clock during horizontal
blankings.

Re-phrase child nodes description while at there.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 Documentation/devicetree/bindings/media/i2c/ov7670.txt | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/media/i2c/ov7670.txt b/Documentation/devicetree/bindings/media/i2c/ov7670.txt
index 826b656..2c972a5 100644
--- a/Documentation/devicetree/bindings/media/i2c/ov7670.txt
+++ b/Documentation/devicetree/bindings/media/i2c/ov7670.txt
@@ -9,14 +9,21 @@ Required Properties:
 - clocks: reference to the xclk input clock.
 - clock-names: should be "xclk".
 
+Required Endpoint Properties:
+- hsync-active: active state of the HSYNC signal, 0/1 for LOW/HIGH respectively.
+- vsync-active: active state of the VSYNC signal, 0/1 for LOW/HIGH respectively.
+
 Optional Properties:
 - reset-gpios: reference to the GPIO connected to the resetb pin, if any.
   Active is low.
 - powerdown-gpios: reference to the GPIO connected to the pwdn pin, if any.
   Active is high.
+- ov7670,pclk-hb-disable: a boolean property to suppress pixel clock output
+  signal during horizontal blankings.
 
-The device node must contain one 'port' child node for its digital output
-video port, in accordance with the video interface bindings defined in
+The device node must contain one 'port' child node with one 'endpoint' child
+sub-node for its digital output video port, in accordance with the video
+interface bindings defined in:
 Documentation/devicetree/bindings/media/video-interfaces.txt.
 
 Example:
@@ -34,8 +41,13 @@ Example:
 			assigned-clocks = <&pck0>;
 			assigned-clock-rates = <25000000>;
 
+			ov7670,pclk-hb-disable;
+
 			port {
 				ov7670_0: endpoint {
+					hsync-active = <0>;
+					vsync-active = <0>;
+
 					remote-endpoint = <&isi_0>;
 				};
 			};
-- 
2.7.4

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v4 2/2] v4l2: i2c: ov7670: Implement OF mbus configuration
  2018-01-24  9:30 [PATCH v4 0/2] media: ov7670: Implement mbus configuration Jacopo Mondi
  2018-01-24  9:30 ` [PATCH v4 1/2] media: dt-bindings: Add OF properties to ov7670 Jacopo Mondi
@ 2018-01-24  9:30 ` Jacopo Mondi
  2018-02-19 20:32   ` Sakari Ailus
       [not found] ` <1516786250-3750-1-git-send-email-jacopo+renesas-AW8dsiIh9cEdnm+yROfE0A@public.gmane.org>
  2 siblings, 1 reply; 6+ messages in thread
From: Jacopo Mondi @ 2018-01-24  9:30 UTC (permalink / raw)
  To: corbet, mchehab, sakari.ailus, robh+dt, mark.rutland
  Cc: Jacopo Mondi, linux-media, devicetree, linux-kernel

ov7670 driver supports two optional properties supplied through platform
data, but currently does not support any standard video interface
property.

Add support through OF parsing for 2 generic properties (vsync and hsync
polarities) and for one custom property already supported through
platform data to suppress pixel clock output during horizontal
blanking.

While at there, check return value of register writes in set_fmt
function and rationalize spacings.

Signal polarities and pixel clock blanking verified through scope and
image capture.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/ov7670.c | 98 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 84 insertions(+), 14 deletions(-)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 61c472e..80c822c 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -21,6 +21,7 @@
 #include <linux/gpio/consumer.h>
 #include <media/v4l2-device.h>
 #include <media/v4l2-ctrls.h>
+#include <media/v4l2-fwnode.h>
 #include <media/v4l2-mediabus.h>
 #include <media/v4l2-image-sizes.h>
 #include <media/i2c/ov7670.h>
@@ -242,6 +243,7 @@ struct ov7670_info {
 	struct clk *clk;
 	struct gpio_desc *resetb_gpio;
 	struct gpio_desc *pwdn_gpio;
+	unsigned int mbus_config;	/* Media bus configuration flags */
 	int min_width;			/* Filter out smaller sizes */
 	int min_height;			/* Filter out smaller sizes */
 	int clock_speed;		/* External clock speed (MHz) */
@@ -1018,7 +1020,7 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
 #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
 	struct v4l2_mbus_framefmt *mbus_fmt;
 #endif
-	unsigned char com7;
+	unsigned char com7, com10 = 0;
 	int ret;
 
 	if (format->pad)
@@ -1038,7 +1040,6 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
 	}
 
 	ret = ov7670_try_fmt_internal(sd, &format->format, &ovfmt, &wsize);
-
 	if (ret)
 		return ret;
 	/*
@@ -1049,16 +1050,41 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
 	 */
 	com7 = ovfmt->regs[0].value;
 	com7 |= wsize->com7_bit;
-	ov7670_write(sd, REG_COM7, com7);
+	ret = ov7670_write(sd, REG_COM7, com7);
+	if (ret)
+		return ret;
+
+	/*
+	 * Configure the media bus through COM10 register
+	 */
+	if (info->mbus_config & V4L2_MBUS_VSYNC_ACTIVE_LOW)
+		com10 |= COM10_VS_NEG;
+	if (info->mbus_config & V4L2_MBUS_HSYNC_ACTIVE_LOW)
+		com10 |= COM10_HREF_REV;
+	if (info->pclk_hb_disable)
+		com10 |= COM10_PCLK_HB;
+	ret = ov7670_write(sd, REG_COM10, com10);
+	if (ret)
+		return ret;
+
 	/*
 	 * Now write the rest of the array.  Also store start/stops
 	 */
-	ov7670_write_array(sd, ovfmt->regs + 1);
-	ov7670_set_hw(sd, wsize->hstart, wsize->hstop, wsize->vstart,
-			wsize->vstop);
-	ret = 0;
-	if (wsize->regs)
+	ret = ov7670_write_array(sd, ovfmt->regs + 1);
+	if (ret)
+		return ret;
+
+	ret = ov7670_set_hw(sd, wsize->hstart, wsize->hstop, wsize->vstart,
+			    wsize->vstop);
+	if (ret)
+		return ret;
+
+	if (wsize->regs) {
 		ret = ov7670_write_array(sd, wsize->regs);
+		if (ret)
+			return ret;
+	}
+
 	info->fmt = ovfmt;
 
 	/*
@@ -1071,8 +1097,10 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
 	 * to write it unconditionally, and that will make the frame
 	 * rate persistent too.
 	 */
-	if (ret == 0)
-		ret = ov7670_write(sd, REG_CLKRC, info->clkrc);
+	ret = ov7670_write(sd, REG_CLKRC, info->clkrc);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
@@ -1698,6 +1726,45 @@ static int ov7670_init_gpio(struct i2c_client *client, struct ov7670_info *info)
 	return 0;
 }
 
+/*
+ * ov7670_parse_dt() - Parse device tree to collect mbus configuration
+ *			properties
+ */
+static int ov7670_parse_dt(struct device *dev,
+			   struct ov7670_info *info)
+{
+	struct fwnode_handle *fwnode = dev_fwnode(dev);
+	struct v4l2_fwnode_endpoint bus_cfg;
+	struct fwnode_handle *ep;
+	int ret;
+
+	if (!fwnode)
+		return -EINVAL;
+
+	info->pclk_hb_disable = false;
+	if (fwnode_property_present(fwnode, "ov7670,pclk-hb-disable"))
+		info->pclk_hb_disable = true;
+
+	ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
+	if (!ep)
+		return -EINVAL;
+
+	ret = v4l2_fwnode_endpoint_parse(ep, &bus_cfg);
+	if (ret) {
+		fwnode_handle_put(ep);
+		return ret;
+	}
+
+	if (bus_cfg.bus_type != V4L2_MBUS_PARALLEL) {
+		dev_err(dev, "Unsupported media bus type\n");
+		fwnode_handle_put(ep);
+		return ret;
+	}
+	info->mbus_config = bus_cfg.bus.parallel.flags;
+
+	return 0;
+}
+
 static int ov7670_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
@@ -1718,7 +1785,13 @@ static int ov7670_probe(struct i2c_client *client,
 #endif
 
 	info->clock_speed = 30; /* default: a guess */
-	if (client->dev.platform_data) {
+
+	if (dev_fwnode(&client->dev)) {
+		ret = ov7670_parse_dt(&client->dev, info);
+		if (ret)
+			return ret;
+
+	} else if (client->dev.platform_data) {
 		struct ov7670_config *config = client->dev.platform_data;
 
 		/*
@@ -1785,9 +1858,6 @@ static int ov7670_probe(struct i2c_client *client,
 	tpf.denominator = 30;
 	info->devtype->set_framerate(sd, &tpf);
 
-	if (info->pclk_hb_disable)
-		ov7670_write(sd, REG_COM10, COM10_PCLK_HB);
-
 	v4l2_ctrl_handler_init(&info->hdl, 10);
 	v4l2_ctrl_new_std(&info->hdl, &ov7670_ctrl_ops,
 			V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4 0/2] media: ov7670: Implement mbus configuration
       [not found] ` <1516786250-3750-1-git-send-email-jacopo+renesas-AW8dsiIh9cEdnm+yROfE0A@public.gmane.org>
@ 2018-01-24 20:58   ` Sakari Ailus
  0 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2018-01-24 20:58 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: corbet-T1hC0tSOHrs, mchehab-DgEjT+Ai2ygdnm+yROfE0A,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	linux-media-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Hi Jacopo,

On Wed, Jan 24, 2018 at 10:30:48AM +0100, Jacopo Mondi wrote:
> Hello,
>    4th round for this series, now based on Hans' 'parm' branch from
> git://linuxtv.org/hverkuil/media_tree.git
> 
> I addressed Sakari's comments on bindings documentation and driver error path,
> and I hope to get both driver and bindings acked to have this included in next
> merge window.

The patches seem fine to me, but before applying them I'd like to have Rob's
ack on the DT changes.

-- 
Sakari Ailus
e-mail: sakari.ailus-X3B1VOXEql0@public.gmane.org
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4 1/2] media: dt-bindings: Add OF properties to ov7670
       [not found]   ` <1516786250-3750-2-git-send-email-jacopo+renesas-AW8dsiIh9cEdnm+yROfE0A@public.gmane.org>
@ 2018-01-30 16:59     ` Rob Herring
  0 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2018-01-30 16:59 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: corbet-T1hC0tSOHrs, mchehab-DgEjT+Ai2ygdnm+yROfE0A,
	sakari.ailus-X3B1VOXEql0, mark.rutland-5wv7dgnIgG8,
	linux-media-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On Wed, Jan 24, 2018 at 10:30:49AM +0100, Jacopo Mondi wrote:
> Describe newly introduced OF properties for ov7670 image sensor.
> The driver supports two standard properties to configure synchronism
> signals polarities and one custom property already supported as
> platform data options to suppress pixel clock during horizontal
> blankings.
> 
> Re-phrase child nodes description while at there.
> 
> Signed-off-by: Jacopo Mondi <jacopo+renesas-AW8dsiIh9cEdnm+yROfE0A@public.gmane.org>
> ---
>  Documentation/devicetree/bindings/media/i2c/ov7670.txt | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)

Reviewed-by: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v4 2/2] v4l2: i2c: ov7670: Implement OF mbus configuration
  2018-01-24  9:30 ` [PATCH v4 2/2] v4l2: i2c: ov7670: Implement OF mbus configuration Jacopo Mondi
@ 2018-02-19 20:32   ` Sakari Ailus
  0 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2018-02-19 20:32 UTC (permalink / raw)
  To: Jacopo Mondi
  Cc: corbet, mchehab, robh+dt, mark.rutland, linux-media, devicetree,
	linux-kernel

On Wed, Jan 24, 2018 at 10:30:50AM +0100, Jacopo Mondi wrote:
> ov7670 driver supports two optional properties supplied through platform
> data, but currently does not support any standard video interface
> property.
> 
> Add support through OF parsing for 2 generic properties (vsync and hsync
> polarities) and for one custom property already supported through
> platform data to suppress pixel clock output during horizontal
> blanking.
> 
> While at there, check return value of register writes in set_fmt
> function and rationalize spacings.
> 
> Signal polarities and pixel clock blanking verified through scope and
> image capture.
> 
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>

Hi Jacopo,

I'll add the following diff to the patch in order to fix the build error
without V4L2_FWNODE:

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 535f85b73075..245387f7b65e 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -683,6 +683,7 @@ config VIDEO_OV7670
 	tristate "OmniVision OV7670 sensor support"
 	depends on I2C && VIDEO_V4L2
 	depends on MEDIA_CAMERA_SUPPORT
+	select V4L2_FWNODE
 	---help---
 	  This is a Video4Linux2 sensor-level driver for the OmniVision
 	  OV7670 VGA camera.  It currently only works with the M88ALP01

> ---
>  drivers/media/i2c/ov7670.c | 98 +++++++++++++++++++++++++++++++++++++++-------
>  1 file changed, 84 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
> index 61c472e..80c822c 100644
> --- a/drivers/media/i2c/ov7670.c
> +++ b/drivers/media/i2c/ov7670.c
> @@ -21,6 +21,7 @@
>  #include <linux/gpio/consumer.h>
>  #include <media/v4l2-device.h>
>  #include <media/v4l2-ctrls.h>
> +#include <media/v4l2-fwnode.h>
>  #include <media/v4l2-mediabus.h>
>  #include <media/v4l2-image-sizes.h>
>  #include <media/i2c/ov7670.h>
> @@ -242,6 +243,7 @@ struct ov7670_info {
>  	struct clk *clk;
>  	struct gpio_desc *resetb_gpio;
>  	struct gpio_desc *pwdn_gpio;
> +	unsigned int mbus_config;	/* Media bus configuration flags */
>  	int min_width;			/* Filter out smaller sizes */
>  	int min_height;			/* Filter out smaller sizes */
>  	int clock_speed;		/* External clock speed (MHz) */
> @@ -1018,7 +1020,7 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
>  #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API
>  	struct v4l2_mbus_framefmt *mbus_fmt;
>  #endif
> -	unsigned char com7;
> +	unsigned char com7, com10 = 0;
>  	int ret;
>  
>  	if (format->pad)
> @@ -1038,7 +1040,6 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
>  	}
>  
>  	ret = ov7670_try_fmt_internal(sd, &format->format, &ovfmt, &wsize);
> -
>  	if (ret)
>  		return ret;
>  	/*
> @@ -1049,16 +1050,41 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
>  	 */
>  	com7 = ovfmt->regs[0].value;
>  	com7 |= wsize->com7_bit;
> -	ov7670_write(sd, REG_COM7, com7);
> +	ret = ov7670_write(sd, REG_COM7, com7);
> +	if (ret)
> +		return ret;
> +
> +	/*
> +	 * Configure the media bus through COM10 register
> +	 */
> +	if (info->mbus_config & V4L2_MBUS_VSYNC_ACTIVE_LOW)
> +		com10 |= COM10_VS_NEG;
> +	if (info->mbus_config & V4L2_MBUS_HSYNC_ACTIVE_LOW)
> +		com10 |= COM10_HREF_REV;
> +	if (info->pclk_hb_disable)
> +		com10 |= COM10_PCLK_HB;
> +	ret = ov7670_write(sd, REG_COM10, com10);
> +	if (ret)
> +		return ret;
> +
>  	/*
>  	 * Now write the rest of the array.  Also store start/stops
>  	 */
> -	ov7670_write_array(sd, ovfmt->regs + 1);
> -	ov7670_set_hw(sd, wsize->hstart, wsize->hstop, wsize->vstart,
> -			wsize->vstop);
> -	ret = 0;
> -	if (wsize->regs)
> +	ret = ov7670_write_array(sd, ovfmt->regs + 1);
> +	if (ret)
> +		return ret;
> +
> +	ret = ov7670_set_hw(sd, wsize->hstart, wsize->hstop, wsize->vstart,
> +			    wsize->vstop);
> +	if (ret)
> +		return ret;
> +
> +	if (wsize->regs) {
>  		ret = ov7670_write_array(sd, wsize->regs);
> +		if (ret)
> +			return ret;
> +	}
> +
>  	info->fmt = ovfmt;
>  
>  	/*
> @@ -1071,8 +1097,10 @@ static int ov7670_set_fmt(struct v4l2_subdev *sd,
>  	 * to write it unconditionally, and that will make the frame
>  	 * rate persistent too.
>  	 */
> -	if (ret == 0)
> -		ret = ov7670_write(sd, REG_CLKRC, info->clkrc);
> +	ret = ov7670_write(sd, REG_CLKRC, info->clkrc);
> +	if (ret)
> +		return ret;
> +
>  	return 0;
>  }
>  
> @@ -1698,6 +1726,45 @@ static int ov7670_init_gpio(struct i2c_client *client, struct ov7670_info *info)
>  	return 0;
>  }
>  
> +/*
> + * ov7670_parse_dt() - Parse device tree to collect mbus configuration
> + *			properties
> + */
> +static int ov7670_parse_dt(struct device *dev,
> +			   struct ov7670_info *info)
> +{
> +	struct fwnode_handle *fwnode = dev_fwnode(dev);
> +	struct v4l2_fwnode_endpoint bus_cfg;
> +	struct fwnode_handle *ep;
> +	int ret;
> +
> +	if (!fwnode)
> +		return -EINVAL;
> +
> +	info->pclk_hb_disable = false;
> +	if (fwnode_property_present(fwnode, "ov7670,pclk-hb-disable"))
> +		info->pclk_hb_disable = true;
> +
> +	ep = fwnode_graph_get_next_endpoint(fwnode, NULL);
> +	if (!ep)
> +		return -EINVAL;
> +
> +	ret = v4l2_fwnode_endpoint_parse(ep, &bus_cfg);
> +	if (ret) {
> +		fwnode_handle_put(ep);
> +		return ret;
> +	}
> +
> +	if (bus_cfg.bus_type != V4L2_MBUS_PARALLEL) {
> +		dev_err(dev, "Unsupported media bus type\n");
> +		fwnode_handle_put(ep);
> +		return ret;
> +	}
> +	info->mbus_config = bus_cfg.bus.parallel.flags;
> +
> +	return 0;
> +}
> +
>  static int ov7670_probe(struct i2c_client *client,
>  			const struct i2c_device_id *id)
>  {
> @@ -1718,7 +1785,13 @@ static int ov7670_probe(struct i2c_client *client,
>  #endif
>  
>  	info->clock_speed = 30; /* default: a guess */
> -	if (client->dev.platform_data) {
> +
> +	if (dev_fwnode(&client->dev)) {
> +		ret = ov7670_parse_dt(&client->dev, info);
> +		if (ret)
> +			return ret;
> +
> +	} else if (client->dev.platform_data) {
>  		struct ov7670_config *config = client->dev.platform_data;
>  
>  		/*
> @@ -1785,9 +1858,6 @@ static int ov7670_probe(struct i2c_client *client,
>  	tpf.denominator = 30;
>  	info->devtype->set_framerate(sd, &tpf);
>  
> -	if (info->pclk_hb_disable)
> -		ov7670_write(sd, REG_COM10, COM10_PCLK_HB);
> -
>  	v4l2_ctrl_handler_init(&info->hdl, 10);
>  	v4l2_ctrl_new_std(&info->hdl, &ov7670_ctrl_ops,
>  			V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
> -- 
> 2.7.4
> 

-- 
Sakari Ailus
e-mail: sakari.ailus@iki.fi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-02-19 20:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-24  9:30 [PATCH v4 0/2] media: ov7670: Implement mbus configuration Jacopo Mondi
2018-01-24  9:30 ` [PATCH v4 1/2] media: dt-bindings: Add OF properties to ov7670 Jacopo Mondi
     [not found]   ` <1516786250-3750-2-git-send-email-jacopo+renesas-AW8dsiIh9cEdnm+yROfE0A@public.gmane.org>
2018-01-30 16:59     ` Rob Herring
2018-01-24  9:30 ` [PATCH v4 2/2] v4l2: i2c: ov7670: Implement OF mbus configuration Jacopo Mondi
2018-02-19 20:32   ` Sakari Ailus
     [not found] ` <1516786250-3750-1-git-send-email-jacopo+renesas-AW8dsiIh9cEdnm+yROfE0A@public.gmane.org>
2018-01-24 20:58   ` [PATCH v4 0/2] media: ov7670: Implement " Sakari Ailus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).