[1/3] media: i2c: imx290: set the format before VIDIOC_SUBDEV_G_FMT is called

Message ID 20200226215913.10631-2-andrey.konovalov@linaro.org (mailing list archive)
State Accepted, archived
Headers
Series IMX290 sensor driver fixes |

Commit Message

Andrey Konovalov Feb. 26, 2020, 9:59 p.m. UTC
  With the current driver 'media-ctl -p' issued right after the imx290 driver
is loaded prints:
pad0: Source
             [fmt:unknown/0x0]

The format value of zero is due to the current_format field of the imx290
struct not being initialized yet.

As imx290_entity_init_cfg() calls imx290_set_fmt(), the current_mode field
is also initialized, so the line which set current_mode to a default value
in driver's probe() function is no longer needed.

Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
---
 drivers/media/i2c/imx290.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Manivannan Sadhasivam March 3, 2020, 9:30 a.m. UTC | #1
On Thu, Feb 27, 2020 at 12:59:11AM +0300, Andrey Konovalov wrote:
> With the current driver 'media-ctl -p' issued right after the imx290 driver
> is loaded prints:
> pad0: Source
>              [fmt:unknown/0x0]
> 
> The format value of zero is due to the current_format field of the imx290
> struct not being initialized yet.
> 
> As imx290_entity_init_cfg() calls imx290_set_fmt(), the current_mode field
> is also initialized, so the line which set current_mode to a default value
> in driver's probe() function is no longer needed.
> 
> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

Thanks,
Mani

> ---
>  drivers/media/i2c/imx290.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
> index f7678e5a5d87..2d8c38ffe2f0 100644
> --- a/drivers/media/i2c/imx290.c
> +++ b/drivers/media/i2c/imx290.c
> @@ -722,9 +722,6 @@ static int imx290_probe(struct i2c_client *client)
>  		goto free_err;
>  	}
>  
> -	/* Set default mode to max resolution */
> -	imx290->current_mode = &imx290_modes[0];
> -
>  	/* get system clock (xclk) */
>  	imx290->xclk = devm_clk_get(dev, "xclk");
>  	if (IS_ERR(imx290->xclk)) {
> @@ -809,6 +806,9 @@ static int imx290_probe(struct i2c_client *client)
>  		goto free_ctrl;
>  	}
>  
> +	/* Initialize the frame format (this also sets imx290->current_mode) */
> +	imx290_entity_init_cfg(&imx290->sd, NULL);
> +
>  	ret = v4l2_async_register_subdev(&imx290->sd);
>  	if (ret < 0) {
>  		dev_err(dev, "Could not register v4l2 device\n");
> -- 
> 2.17.1
>
  

Patch

diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
index f7678e5a5d87..2d8c38ffe2f0 100644
--- a/drivers/media/i2c/imx290.c
+++ b/drivers/media/i2c/imx290.c
@@ -722,9 +722,6 @@  static int imx290_probe(struct i2c_client *client)
 		goto free_err;
 	}
 
-	/* Set default mode to max resolution */
-	imx290->current_mode = &imx290_modes[0];
-
 	/* get system clock (xclk) */
 	imx290->xclk = devm_clk_get(dev, "xclk");
 	if (IS_ERR(imx290->xclk)) {
@@ -809,6 +806,9 @@  static int imx290_probe(struct i2c_client *client)
 		goto free_ctrl;
 	}
 
+	/* Initialize the frame format (this also sets imx290->current_mode) */
+	imx290_entity_init_cfg(&imx290->sd, NULL);
+
 	ret = v4l2_async_register_subdev(&imx290->sd);
 	if (ret < 0) {
 		dev_err(dev, "Could not register v4l2 device\n");