1 From 29e3826878f43cd88414824be055cf5fcd57ab23 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Wed, 29 Apr 2020 17:25:56 +0100
4 Subject: [PATCH] media: i2c: ov5647: Set V4L2_SUBDEV_FL_HAS_EVENTS
7 The ov5647 subdev can generate control events, therefore set
8 the V4L2_SUBDEV_FL_HAS_EVENTS flag.
10 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
12 drivers/media/i2c/ov5647.c | 29 +++++++++++++++++++++++++++--
13 1 file changed, 27 insertions(+), 2 deletions(-)
15 --- a/drivers/media/i2c/ov5647.c
16 +++ b/drivers/media/i2c/ov5647.c
17 @@ -90,6 +90,8 @@ struct ov5647_mode {
18 struct v4l2_rect crop;
21 + /* HTS as defined in the register set (0x380C/0x380D) */
24 struct regval_list *reg_list;
25 unsigned int num_regs;
26 @@ -106,6 +108,7 @@ struct ov5647 {
28 struct v4l2_ctrl_handler ctrls;
29 struct v4l2_ctrl *pixel_rate;
30 + struct v4l2_ctrl *hblank;
34 @@ -605,6 +608,7 @@ static struct ov5647_mode supported_mode
37 .pixel_rate = 77291670,
40 ARRAY_SIZE(ov5647_640x480_8bit)
42 @@ -629,6 +633,7 @@ static struct ov5647_mode supported_mode
45 .pixel_rate = 87500000,
47 ov5647_2592x1944_10bit,
48 ARRAY_SIZE(ov5647_2592x1944_10bit)
50 @@ -651,6 +656,7 @@ static struct ov5647_mode supported_mode
53 .pixel_rate = 81666700,
56 ARRAY_SIZE(ov5647_1080p30_10bit)
58 @@ -672,6 +678,7 @@ static struct ov5647_mode supported_mode
61 .pixel_rate = 81666700,
63 ov5647_2x2binned_10bit,
64 ARRAY_SIZE(ov5647_2x2binned_10bit)
66 @@ -694,6 +701,7 @@ static struct ov5647_mode supported_mode
69 .pixel_rate = 55000000,
72 ARRAY_SIZE(ov5647_640x480_10bit)
74 @@ -1168,6 +1176,8 @@ static int ov5647_set_fmt(struct v4l2_su
75 * If we have changed modes, write the I2C register list on
80 if (state->mode != mode)
81 state->write_mode_regs = true;
83 @@ -1176,6 +1186,9 @@ static int ov5647_set_fmt(struct v4l2_su
87 + hblank = mode->hts - mode->format.width;
88 + __v4l2_ctrl_modify_range(state->hblank, hblank, hblank, 1,
92 mutex_unlock(&state->lock);
93 @@ -1395,6 +1408,9 @@ static int ov5647_s_ctrl(struct v4l2_ctr
94 case V4L2_CID_PIXEL_RATE:
95 /* Read-only, but we adjust it based on mode. */
97 + case V4L2_CID_HBLANK:
98 + /* Read-only, but we adjust it based on mode. */
101 dev_info(&client->dev,
102 "ctrl(id:0x%x,val:0x%x) is not handled\n",
103 @@ -1419,6 +1435,7 @@ static int ov5647_probe(struct i2c_clien
104 struct device_node *np = client->dev.of_node;
106 struct v4l2_ctrl *ctrl;
109 sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL);
111 @@ -1452,7 +1469,7 @@ static int ov5647_probe(struct i2c_clien
112 mutex_init(&sensor->lock);
114 /* Initialise controls. */
115 - v4l2_ctrl_handler_init(&sensor->ctrls, 6);
116 + v4l2_ctrl_handler_init(&sensor->ctrls, 7);
117 v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
120 @@ -1495,6 +1512,13 @@ static int ov5647_probe(struct i2c_clien
121 sensor->mode->pixel_rate, 1,
122 sensor->mode->pixel_rate);
124 + /* By default, HBLANK is read only, but it does change per mode */
125 + hblank = sensor->mode->hts - sensor->mode->format.width;
126 + sensor->hblank = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
127 + V4L2_CID_HBLANK, hblank, hblank, 1,
129 + sensor->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
131 if (sensor->ctrls.error) {
132 ret = sensor->ctrls.error;
133 dev_err(&client->dev, "%s control init failed (%d)\n",
134 @@ -1509,7 +1533,8 @@ static int ov5647_probe(struct i2c_clien
136 v4l2_i2c_subdev_init(sd, client, &ov5647_subdev_ops);
137 sensor->sd.internal_ops = &ov5647_subdev_internal_ops;
138 - sensor->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
139 + sensor->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE |
140 + V4L2_SUBDEV_FL_HAS_EVENTS;
142 sensor->pad.flags = MEDIA_PAD_FL_SOURCE;
143 sd->entity.function = MEDIA_ENT_F_CAM_SENSOR;