Re: [PATCH 4/6] media: ov772x: add media controller support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Akinobu,

On Sun, Apr 08, 2018 at 12:48:08AM +0900, Akinobu Mita wrote:
> Create a source pad and set the media controller type to the sensor.
>
> Cc: Jacopo Mondi <jacopo+renesas@xxxxxxxxxx>
> Cc: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
> Cc: Hans Verkuil <hans.verkuil@xxxxxxxxx>
> Cc: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx>
> Cc: Mauro Carvalho Chehab <mchehab@xxxxxxxxxxxxxxxx>
> Signed-off-by: Akinobu Mita <akinobu.mita@xxxxxxxxx>
> ---
>  drivers/media/i2c/ov772x.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
> index 4bb81ff..5e91fa1 100644
> --- a/drivers/media/i2c/ov772x.c
> +++ b/drivers/media/i2c/ov772x.c
> @@ -425,6 +425,9 @@ struct ov772x_priv {
>  	unsigned short                    band_filter;
>  	unsigned int			  fps;
>  	int (*reg_read)(struct i2c_client *client, u8 addr);
> +#ifdef CONFIG_MEDIA_CONTROLLER
> +	struct media_pad pad;
> +#endif
>  };
>
>  /*
> @@ -1328,9 +1331,17 @@ static int ov772x_probe(struct i2c_client *client,
>  		goto error_clk_put;
>  	}
>
> -	ret = ov772x_video_probe(priv);
> +#ifdef CONFIG_MEDIA_CONTROLLER
> +	priv->pad.flags = MEDIA_PAD_FL_SOURCE;
> +	priv->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
> +	ret = media_entity_pads_init(&priv->subdev.entity, 1, &priv->pad);
>  	if (ret < 0)
>  		goto error_gpio_put;
> +#endif
> +
> +	ret = ov772x_video_probe(priv);
> +	if (ret < 0)
> +		goto error_entity_cleanup;

If you remove the #ifdef around the media_entity_cleanup() below, I
suggest moving video_probe() before the entity intialization so you
don't have to #ifdef around the error_gpio_put: label, which otherwise
the compiler complains for being defined but not used.

>
>  	priv->cfmt = &ov772x_cfmts[0];
>  	priv->win = &ov772x_win_sizes[0];
> @@ -1338,11 +1349,15 @@ static int ov772x_probe(struct i2c_client *client,
>
>  	ret = v4l2_async_register_subdev(&priv->subdev);
>  	if (ret)
> -		goto error_gpio_put;
> +		goto error_entity_cleanup;
>
>  	return 0;
>
> +error_entity_cleanup:
> +#ifdef CONFIG_MEDIA_CONTROLLER
> +	media_entity_cleanup(&priv->subdev.entity);

media_entity_cleanup() resolves to a nop if CONFIG_MEDIA_CONTROLLER is
not defined

>  error_gpio_put:
> +#endif
>  	if (priv->pwdn_gpio)
>  		gpiod_put(priv->pwdn_gpio);
>  error_clk_put:
> @@ -1357,6 +1372,9 @@ static int ov772x_remove(struct i2c_client *client)
>  {
>  	struct ov772x_priv *priv = to_ov772x(i2c_get_clientdata(client));
>
> +#ifdef CONFIG_MEDIA_CONTROLLER
> +	media_entity_cleanup(&priv->subdev.entity);

ditto

Thanks
   j

> +#endif
>  	clk_put(priv->clk);
>  	if (priv->pwdn_gpio)
>  		gpiod_put(priv->pwdn_gpio);
> --
> 2.7.4
>

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux