diff mbox

[v1,04/12] media: i2c: mt9m111: Add source pad

Message ID 1497891889-8038-5-git-send-email-jacopo+renesas@jmondi.org (mailing list archive)
State Changes Requested
Delegated to: Geert Uytterhoeven
Headers show

Commit Message

Jacopo Mondi June 19, 2017, 5:04 p.m. UTC
Add a single source pad to mt9m111 media entity.

Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
 drivers/media/i2c/mt9m111.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart June 20, 2017, 7:50 a.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Monday 19 Jun 2017 19:04:41 Jacopo Mondi wrote:
> Add a single source pad to mt9m111 media entity.
> 
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
>  drivers/media/i2c/mt9m111.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
> index 8e86d51..7e70969 100644
> --- a/drivers/media/i2c/mt9m111.c
> +++ b/drivers/media/i2c/mt9m111.c
> @@ -141,6 +141,8 @@
>  #define MT9M111_MAX_HEIGHT	1024
>  #define MT9M111_MAX_WIDTH	1280
> 
> +#define MT9M111_MEDIA_PAD	1
> +
>  struct mt9m111_context {
>  	u16 read_mode;
>  	u16 blanking_h;
> @@ -215,6 +217,8 @@ struct mt9m111 {
>  	int power_count;
>  	const struct mt9m111_datafmt *fmt;
>  	int lastpage;	/* PageMap cache value */
> +
> +	struct media_pad pad;
>  };
> 
>  /* Find a data format by a pixel code */
> @@ -963,13 +967,23 @@ static int mt9m111_probe(struct i2c_client *client,
>  	if (ret < 0)
>  		goto out_hdlfree;
> 
> +	mt9m111->pad.flags = MEDIA_PAD_FL_SOURCE;
> +	ret = media_entity_pads_init(&mt9m111->subdev.entity, 
MT9M111_MEDIA_PAD,

The second argument is the number of pads, not a pad number. The macro name is 
quite confusing. Given that you use it once only, you can drop it and hardcode 
the value.

> +				     &mt9m111->pad);
> +	if (ret)
> +		goto out_hdlfree;
> +
>  	mt9m111->subdev.dev = &client->dev;
> +	mt9m111->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
> +	mt9m111->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
>  	ret = v4l2_async_register_subdev(&mt9m111->subdev);
>  	if (ret < 0)
> -		goto out_hdlfree;
> +		goto out_mediafree;
> 
>  	return 0;
> 
> +out_mediafree:

Maybe out_media_cleanup ?

> +	media_entity_cleanup(&mt9m111->subdev.entity);
>  out_hdlfree:
>  	v4l2_ctrl_handler_free(&mt9m111->hdl);
>  out_clkput:
> @@ -982,6 +996,7 @@ static int mt9m111_remove(struct i2c_client *client)
>  {
>  	struct mt9m111 *mt9m111 = to_mt9m111(client);
> 
> +	media_entity_cleanup(&mt9m111->subdev.entity);
>  	v4l2_async_unregister_subdev(&mt9m111->subdev);
>  	v4l2_clk_put(mt9m111->clk);
>  	v4l2_ctrl_handler_free(&mt9m111->hdl);
diff mbox

Patch

diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index 8e86d51..7e70969 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -141,6 +141,8 @@ 
 #define MT9M111_MAX_HEIGHT	1024
 #define MT9M111_MAX_WIDTH	1280
 
+#define MT9M111_MEDIA_PAD	1
+
 struct mt9m111_context {
 	u16 read_mode;
 	u16 blanking_h;
@@ -215,6 +217,8 @@  struct mt9m111 {
 	int power_count;
 	const struct mt9m111_datafmt *fmt;
 	int lastpage;	/* PageMap cache value */
+
+	struct media_pad pad;
 };
 
 /* Find a data format by a pixel code */
@@ -963,13 +967,23 @@  static int mt9m111_probe(struct i2c_client *client,
 	if (ret < 0)
 		goto out_hdlfree;
 
+	mt9m111->pad.flags = MEDIA_PAD_FL_SOURCE;
+	ret = media_entity_pads_init(&mt9m111->subdev.entity, MT9M111_MEDIA_PAD,
+				     &mt9m111->pad);
+	if (ret)
+		goto out_hdlfree;
+
 	mt9m111->subdev.dev = &client->dev;
+	mt9m111->subdev.flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
+	mt9m111->subdev.entity.function = MEDIA_ENT_F_CAM_SENSOR;
 	ret = v4l2_async_register_subdev(&mt9m111->subdev);
 	if (ret < 0)
-		goto out_hdlfree;
+		goto out_mediafree;
 
 	return 0;
 
+out_mediafree:
+	media_entity_cleanup(&mt9m111->subdev.entity);
 out_hdlfree:
 	v4l2_ctrl_handler_free(&mt9m111->hdl);
 out_clkput:
@@ -982,6 +996,7 @@  static int mt9m111_remove(struct i2c_client *client)
 {
 	struct mt9m111 *mt9m111 = to_mt9m111(client);
 
+	media_entity_cleanup(&mt9m111->subdev.entity);
 	v4l2_async_unregister_subdev(&mt9m111->subdev);
 	v4l2_clk_put(mt9m111->clk);
 	v4l2_ctrl_handler_free(&mt9m111->hdl);