1 From 0dd7e12bb7dc81e09440f3330465c31349497dc3 Mon Sep 17 00:00:00 2001
2 From: Jacopo Mondi <jacopo+renesas@jmondi.org>
3 Date: Tue, 16 Jun 2020 16:12:38 +0200
4 Subject: [PATCH]_mbus_config
7 Upstream https://patchwork.linuxtv.org/patch/64674/
9 Use the new get_mbus_config and set_mbus_config pad operations in place
10 of the video operations currently in use.
12 Compared to other drivers where the same conversion has been performed,
13 ov6650 proved to be a bit more tricky, as the existing g_mbus_config
14 implementation did not report the currently applied configuration but
15 the set of all possible configuration options.
17 Adapt the driver to support the semantic of the two newly introduced
19 - get_mbus_config reports the current media bus configuration
20 - set_mbus_config applies only changes explicitly requested and updates
21 the provided cfg parameter to report what has actually been applied to
26 Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
28 drivers/media/i2c/ov6650.c | 56 ++++++++++++++++++++++++++------------
29 1 file changed, 39 insertions(+), 17 deletions(-)
31 --- a/drivers/media/i2c/ov6650.c
32 +++ b/drivers/media/i2c/ov6650.c
33 @@ -909,46 +909,68 @@ static const struct v4l2_subdev_core_ops
36 /* Request bus settings on camera side */
37 -static int ov6650_g_mbus_config(struct v4l2_subdev *sd,
38 - struct v4l2_mbus_config *cfg)
39 +static int ov6650_get_mbus_config(struct v4l2_subdev *sd,
41 + struct v4l2_mbus_config *cfg)
43 + struct i2c_client *client = v4l2_get_subdevdata(sd);
47 + ret = ov6650_reg_read(client, REG_COMJ, &comj);
51 + ret = ov6650_reg_read(client, REG_COMF, &comf);
55 - cfg->flags = V4L2_MBUS_MASTER |
56 - V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_PCLK_SAMPLE_FALLING |
57 - V4L2_MBUS_HSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_LOW |
58 - V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_VSYNC_ACTIVE_LOW |
59 - V4L2_MBUS_DATA_ACTIVE_HIGH;
60 + cfg->flags = V4L2_MBUS_MASTER
61 + | ((comj & COMJ_VSYNC_HIGH) ? V4L2_MBUS_VSYNC_ACTIVE_HIGH
62 + : V4L2_MBUS_VSYNC_ACTIVE_LOW)
63 + | ((comf & COMF_HREF_LOW) ? V4L2_MBUS_HSYNC_ACTIVE_LOW
64 + : V4L2_MBUS_HSYNC_ACTIVE_HIGH)
65 + | ((comj & COMJ_PCLK_RISING) ? V4L2_MBUS_PCLK_SAMPLE_RISING
66 + : V4L2_MBUS_PCLK_SAMPLE_FALLING);
67 cfg->type = V4L2_MBUS_PARALLEL;
72 /* Alter bus settings on camera side */
73 -static int ov6650_s_mbus_config(struct v4l2_subdev *sd,
74 - const struct v4l2_mbus_config *cfg)
75 +static int ov6650_set_mbus_config(struct v4l2_subdev *sd,
77 + struct v4l2_mbus_config *cfg)
79 struct i2c_client *client = v4l2_get_subdevdata(sd);
83 if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_RISING)
84 ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_PCLK_RISING, 0);
86 + else if (cfg->flags & V4L2_MBUS_PCLK_SAMPLE_FALLING)
87 ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_PCLK_RISING);
92 if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_LOW)
93 ret = ov6650_reg_rmw(client, REG_COMF, COMF_HREF_LOW, 0);
95 + else if (cfg->flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)
96 ret = ov6650_reg_rmw(client, REG_COMF, 0, COMF_HREF_LOW);
101 if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_HIGH)
102 ret = ov6650_reg_rmw(client, REG_COMJ, COMJ_VSYNC_HIGH, 0);
104 + else if (cfg->flags & V4L2_MBUS_VSYNC_ACTIVE_LOW)
105 ret = ov6650_reg_rmw(client, REG_COMJ, 0, COMJ_VSYNC_HIGH);
109 + * Update the configuration to report what is actually applied to
112 + ov6650_get_mbus_config(sd, pad, cfg);
117 @@ -956,8 +978,6 @@ static const struct v4l2_subdev_video_op
118 .s_stream = ov6650_s_stream,
119 .g_frame_interval = ov6650_g_frame_interval,
120 .s_frame_interval = ov6650_s_frame_interval,
121 - .g_mbus_config = ov6650_g_mbus_config,
122 - .s_mbus_config = ov6650_s_mbus_config,
125 static const struct v4l2_subdev_pad_ops ov6650_pad_ops = {
126 @@ -966,6 +986,8 @@ static const struct v4l2_subdev_pad_ops
127 .set_selection = ov6650_set_selection,
128 .get_fmt = ov6650_get_fmt,
129 .set_fmt = ov6650_set_fmt,
130 + .get_mbus_config = ov6650_get_mbus_config,
131 + .set_mbus_config = ov6650_set_mbus_config,
134 static const struct v4l2_subdev_ops ov6650_subdev_ops = {