From: Hans Verkuil <hans.verk...@cisco.com>

Add media controller support.

Signed-off-by: Hans Verkuil <hans.verk...@cisco.com>
---
 drivers/media/i2c/ov7670.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/media/i2c/ov7670.c b/drivers/media/i2c/ov7670.c
index 56cfb5c..b0315bb 100644
--- a/drivers/media/i2c/ov7670.c
+++ b/drivers/media/i2c/ov7670.c
@@ -210,6 +210,9 @@ struct ov7670_devtype {
 struct ov7670_format_struct;  /* coming later */
 struct ov7670_info {
        struct v4l2_subdev sd;
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       struct media_pad pad;
+#endif
        struct v4l2_ctrl_handler hdl;
        struct {
                /* gain cluster */
@@ -1641,6 +1644,16 @@ static int ov7670_probe(struct i2c_client *client,
                v4l2_ctrl_handler_free(&info->hdl);
                return err;
        }
+
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       info->pad.flags = MEDIA_PAD_FL_SOURCE;
+       info->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
+       ret = media_entity_pads_init(&info->sd.entity, 1, &info->pad);
+       if (ret < 0) {
+               v4l2_ctrl_handler_free(&info->hdl);
+               return ret;
+       }
+#endif
        /*
         * We have checked empirically that hw allows to read back the gain
         * value chosen by auto gain but that's not the case for auto exposure.
@@ -1662,6 +1675,9 @@ static int ov7670_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&info->hdl);
+#if defined(CONFIG_MEDIA_CONTROLLER)
+       media_entity_cleanup(&sd->entity);
+#endif
        return 0;
 }
 
-- 
2.10.2

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

Reply via email to