Skip to content

Commit 4782928

Browse files
committed
media: i2c: Use accessors for pad config 'try_*' fields
jira LE-3428 Rebuild_History Non-Buildable kernel-5.14.0-570.23.1.el9_6 commit-author Laurent Pinchart <[email protected]> commit fd17e3a Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-5.14.0-570.23.1.el9_6/fd17e3a9.failed The 'try_*' fields of the v4l2_subdev_pad_config structure are meant to be accessed through helper functions. Replace direct access with usage of the v4l2_subdev_get_pad_format(), v4l2_subdev_get_pad_crop() and v4l2_subdev_get_pad_compose() helpers. Signed-off-by: Laurent Pinchart <[email protected]> Signed-off-by: Sakari Ailus <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]> (cherry picked from commit fd17e3a) Signed-off-by: Jonathan Maple <[email protected]> # Conflicts: # drivers/media/i2c/ov2680.c # drivers/media/i2c/ov6650.c
1 parent 882361a commit 4782928

File tree

1 file changed

+375
-0
lines changed

1 file changed

+375
-0
lines changed
Lines changed: 375 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,375 @@
1+
media: i2c: Use accessors for pad config 'try_*' fields
2+
3+
jira LE-3428
4+
Rebuild_History Non-Buildable kernel-5.14.0-570.23.1.el9_6
5+
commit-author Laurent Pinchart <[email protected]>
6+
commit fd17e3a9a7886ec949ce269a396b67875b51ff45
7+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
8+
Will be included in final tarball splat. Ref for failed cherry-pick at:
9+
ciq/ciq_backports/kernel-5.14.0-570.23.1.el9_6/fd17e3a9.failed
10+
11+
The 'try_*' fields of the v4l2_subdev_pad_config structure are meant to
12+
be accessed through helper functions. Replace direct access with usage
13+
of the v4l2_subdev_get_pad_format(), v4l2_subdev_get_pad_crop() and
14+
v4l2_subdev_get_pad_compose() helpers.
15+
16+
Signed-off-by: Laurent Pinchart <[email protected]>
17+
Signed-off-by: Sakari Ailus <[email protected]>
18+
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
19+
(cherry picked from commit fd17e3a9a7886ec949ce269a396b67875b51ff45)
20+
Signed-off-by: Jonathan Maple <[email protected]>
21+
22+
# Conflicts:
23+
# drivers/media/i2c/ov2680.c
24+
# drivers/media/i2c/ov6650.c
25+
diff --cc drivers/media/i2c/ov2680.c
26+
index dc9ac628612f,f58fa2eb86ee..000000000000
27+
--- a/drivers/media/i2c/ov2680.c
28+
+++ b/drivers/media/i2c/ov2680.c
29+
@@@ -746,16 -758,13 +746,24 @@@ unlock
30+
static int ov2680_init_cfg(struct v4l2_subdev *sd,
31+
struct v4l2_subdev_state *sd_state)
32+
{
33+
- struct ov2680_dev *sensor = to_ov2680_dev(sd);
34+
+ struct v4l2_subdev_format fmt = {
35+
+ .which = sd_state ? V4L2_SUBDEV_FORMAT_TRY
36+
+ : V4L2_SUBDEV_FORMAT_ACTIVE,
37+
+ .format = {
38+
+ .width = 800,
39+
+ .height = 600,
40+
+ }
41+
+ };
42+
43+
++<<<<<<< HEAD
44+
+ return ov2680_set_fmt(sd, sd_state, &fmt);
45+
++=======
46+
+ *v4l2_subdev_get_pad_crop(sd, sd_state, 0) = ov2680_default_crop;
47+
+
48+
+ ov2680_fill_format(sensor, v4l2_subdev_get_pad_format(sd, sd_state, 0),
49+
+ OV2680_DEFAULT_WIDTH, OV2680_DEFAULT_HEIGHT);
50+
+ return 0;
51+
++>>>>>>> fd17e3a9a788 (media: i2c: Use accessors for pad config 'try_*' fields)
52+
}
53+
54+
static int ov2680_enum_frame_size(struct v4l2_subdev *sd,
55+
diff --cc drivers/media/i2c/ov6650.c
56+
index b224b033cea1,38d21b40f5d8..000000000000
57+
--- a/drivers/media/i2c/ov6650.c
58+
+++ b/drivers/media/i2c/ov6650.c
59+
@@@ -472,9 -472,16 +472,20 @@@ static int ov6650_get_selection(struct
60+
{
61+
struct i2c_client *client = v4l2_get_subdevdata(sd);
62+
struct ov6650 *priv = to_ov6650(client);
63+
- struct v4l2_rect *rect;
64+
65+
++<<<<<<< HEAD
66+
+ if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE)
67+
+ return -EINVAL;
68+
++=======
69+
+ if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
70+
+ /* pre-select try crop rectangle */
71+
+ rect = v4l2_subdev_get_pad_crop(sd, sd_state, 0);
72+
+
73+
+ } else {
74+
+ /* pre-select active crop rectangle */
75+
+ rect = &priv->rect;
76+
+ }
77+
++>>>>>>> fd17e3a9a788 (media: i2c: Use accessors for pad config 'try_*' fields)
78+
79+
switch (sel->target) {
80+
case V4L2_SEL_TGT_CROP_BOUNDS:
81+
@@@ -499,18 -525,32 +510,42 @@@ static int ov6650_set_selection(struct
82+
struct ov6650 *priv = to_ov6650(client);
83+
int ret;
84+
85+
- if (sel->target != V4L2_SEL_TGT_CROP)
86+
+ if (sel->which != V4L2_SUBDEV_FORMAT_ACTIVE ||
87+
+ sel->target != V4L2_SEL_TGT_CROP)
88+
return -EINVAL;
89+
90+
- ov6650_bind_align_crop_rectangle(&sel->r);
91+
+ v4l_bound_align_image(&sel->r.width, 2, W_CIF, 1,
92+
+ &sel->r.height, 2, H_CIF, 1, 0);
93+
+ v4l_bound_align_image(&sel->r.left, DEF_HSTRT << 1,
94+
+ (DEF_HSTRT << 1) + W_CIF - (__s32)sel->r.width, 1,
95+
+ &sel->r.top, DEF_VSTRT << 1,
96+
+ (DEF_VSTRT << 1) + H_CIF - (__s32)sel->r.height,
97+
+ 1, 0);
98+
99+
++<<<<<<< HEAD
100+
++=======
101+
+ if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
102+
+ struct v4l2_rect *crop =
103+
+ v4l2_subdev_get_pad_crop(sd, sd_state, 0);
104+
+ struct v4l2_mbus_framefmt *mf =
105+
+ v4l2_subdev_get_pad_format(sd, sd_state, 0);
106+
+ /* detect current pad config scaling factor */
107+
+ bool half_scale = !is_unscaled_ok(mf->width, mf->height, crop);
108+
+
109+
+ /* store new crop rectangle */
110+
+ *crop = sel->r;
111+
+
112+
+ /* adjust frame size */
113+
+ mf->width = crop->width >> half_scale;
114+
+ mf->height = crop->height >> half_scale;
115+
+
116+
+ return 0;
117+
+ }
118+
+
119+
+ /* V4L2_SUBDEV_FORMAT_ACTIVE */
120+
+
121+
+ /* apply new crop rectangle */
122+
++>>>>>>> fd17e3a9a788 (media: i2c: Use accessors for pad config 'try_*' fields)
123+
ret = ov6650_reg_write(client, REG_HSTRT, sel->r.left >> 1);
124+
if (!ret) {
125+
priv->rect.width += priv->rect.left - sel->r.left;
126+
@@@ -699,22 -721,34 +737,40 @@@ static int ov6650_set_fmt(struct v4l2_s
127+
break;
128+
}
129+
130+
++<<<<<<< HEAD
131+
+ if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
132+
+ /* store media bus format code and frame size in pad config */
133+
+ sd_state->pads->try_fmt.width = mf->width;
134+
+ sd_state->pads->try_fmt.height = mf->height;
135+
+ sd_state->pads->try_fmt.code = mf->code;
136+
++=======
137+
+ if (format->which == V4L2_SUBDEV_FORMAT_TRY)
138+
+ crop = v4l2_subdev_get_pad_crop(sd, sd_state, 0);
139+
+ else
140+
+ crop = &priv->rect;
141+
+
142+
+ half_scale = !is_unscaled_ok(mf->width, mf->height, crop);
143+
+
144+
+ if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
145+
+ struct v4l2_mbus_framefmt *try_fmt =
146+
+ v4l2_subdev_get_pad_format(sd, sd_state, 0);
147+
+
148+
+ /* store new mbus frame format code and size in pad config */
149+
+ try_fmt->width = crop->width >> half_scale;
150+
+ try_fmt->height = crop->height >> half_scale;
151+
+ try_fmt->code = mf->code;
152+
++>>>>>>> fd17e3a9a788 (media: i2c: Use accessors for pad config 'try_*' fields)
153+
154+
/* return default mbus frame format updated with pad config */
155+
*mf = ov6650_def_fmt;
156+
- mf->width = sd_state->pads->try_fmt.width;
157+
- mf->height = sd_state->pads->try_fmt.height;
158+
- mf->code = sd_state->pads->try_fmt.code;
159+
+ mf->width = try_fmt->width;
160+
+ mf->height = try_fmt->height;
161+
+ mf->code = try_fmt->code;
162+
163+
} else {
164+
- int ret = 0;
165+
+ /* apply new media bus format code and frame size */
166+
+ int ret = ov6650_s_fmt(sd, mf);
167+
168+
- /* apply new media bus frame format and scaling if changed */
169+
- if (mf->code != priv->code || half_scale != priv->half_scale)
170+
- ret = ov6650_s_fmt(sd, mf->code, half_scale);
171+
if (ret)
172+
return ret;
173+
174+
diff --git a/drivers/media/i2c/adv7183.c b/drivers/media/i2c/adv7183.c
175+
index 92cafdea3f1f..3587a992907e 100644
176+
--- a/drivers/media/i2c/adv7183.c
177+
+++ b/drivers/media/i2c/adv7183.c
178+
@@ -443,7 +443,7 @@ static int adv7183_set_fmt(struct v4l2_subdev *sd,
179+
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
180+
decoder->fmt = *fmt;
181+
else
182+
- sd_state->pads->try_fmt = *fmt;
183+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *fmt;
184+
return 0;
185+
}
186+
187+
diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c
188+
index 0dce92872176..3738cfc7de1e 100644
189+
--- a/drivers/media/i2c/imx274.c
190+
+++ b/drivers/media/i2c/imx274.c
191+
@@ -1019,8 +1019,8 @@ static int __imx274_change_compose(struct stimx274 *imx274,
192+
int best_goodness = INT_MIN;
193+
194+
if (which == V4L2_SUBDEV_FORMAT_TRY) {
195+
- cur_crop = &sd_state->pads->try_crop;
196+
- tgt_fmt = &sd_state->pads->try_fmt;
197+
+ cur_crop = v4l2_subdev_get_pad_crop(&imx274->sd, sd_state, 0);
198+
+ tgt_fmt = v4l2_subdev_get_pad_format(&imx274->sd, sd_state, 0);
199+
} else {
200+
cur_crop = &imx274->crop;
201+
tgt_fmt = &imx274->format;
202+
@@ -1113,7 +1113,7 @@ static int imx274_set_fmt(struct v4l2_subdev *sd,
203+
*/
204+
fmt->field = V4L2_FIELD_NONE;
205+
if (format->which == V4L2_SUBDEV_FORMAT_TRY)
206+
- sd_state->pads->try_fmt = *fmt;
207+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *fmt;
208+
else
209+
imx274->format = *fmt;
210+
211+
@@ -1144,8 +1144,8 @@ static int imx274_get_selection(struct v4l2_subdev *sd,
212+
}
213+
214+
if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
215+
- src_crop = &sd_state->pads->try_crop;
216+
- src_fmt = &sd_state->pads->try_fmt;
217+
+ src_crop = v4l2_subdev_get_pad_crop(sd, sd_state, 0);
218+
+ src_fmt = v4l2_subdev_get_pad_format(sd, sd_state, 0);
219+
} else {
220+
src_crop = &imx274->crop;
221+
src_fmt = &imx274->format;
222+
@@ -1216,7 +1216,7 @@ static int imx274_set_selection_crop(struct stimx274 *imx274,
223+
sel->r = new_crop;
224+
225+
if (sel->which == V4L2_SUBDEV_FORMAT_TRY)
226+
- tgt_crop = &sd_state->pads->try_crop;
227+
+ tgt_crop = v4l2_subdev_get_pad_crop(&imx274->sd, sd_state, 0);
228+
else
229+
tgt_crop = &imx274->crop;
230+
231+
diff --git a/drivers/media/i2c/mt9m001.c b/drivers/media/i2c/mt9m001.c
232+
index 9dc87e42a6e6..170e00f90bdf 100644
233+
--- a/drivers/media/i2c/mt9m001.c
234+
+++ b/drivers/media/i2c/mt9m001.c
235+
@@ -411,7 +411,7 @@ static int mt9m001_set_fmt(struct v4l2_subdev *sd,
236+
237+
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
238+
return mt9m001_s_fmt(sd, fmt, mf);
239+
- sd_state->pads->try_fmt = *mf;
240+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
241+
return 0;
242+
}
243+
244+
diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
245+
index 9df005746bc4..b0f9891c36f1 100644
246+
--- a/drivers/media/i2c/mt9m111.c
247+
+++ b/drivers/media/i2c/mt9m111.c
248+
@@ -678,7 +678,7 @@ static int mt9m111_set_fmt(struct v4l2_subdev *sd,
249+
mf->xfer_func = V4L2_XFER_FUNC_DEFAULT;
250+
251+
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
252+
- sd_state->pads->try_fmt = *mf;
253+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
254+
return 0;
255+
}
256+
257+
diff --git a/drivers/media/i2c/mt9t112.c b/drivers/media/i2c/mt9t112.c
258+
index 8d2e3caa9b28..9eac716d3571 100644
259+
--- a/drivers/media/i2c/mt9t112.c
260+
+++ b/drivers/media/i2c/mt9t112.c
261+
@@ -982,7 +982,7 @@ static int mt9t112_set_fmt(struct v4l2_subdev *sd,
262+
263+
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
264+
return mt9t112_s_fmt(sd, mf);
265+
- sd_state->pads->try_fmt = *mf;
266+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
267+
268+
return 0;
269+
}
270+
diff --git a/drivers/media/i2c/mt9v011.c b/drivers/media/i2c/mt9v011.c
271+
index 7699e64e1127..4a0b0e610206 100644
272+
--- a/drivers/media/i2c/mt9v011.c
273+
+++ b/drivers/media/i2c/mt9v011.c
274+
@@ -358,7 +358,7 @@ static int mt9v011_set_fmt(struct v4l2_subdev *sd,
275+
276+
set_res(sd);
277+
} else {
278+
- sd_state->pads->try_fmt = *fmt;
279+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *fmt;
280+
}
281+
282+
return 0;
283+
diff --git a/drivers/media/i2c/mt9v111.c b/drivers/media/i2c/mt9v111.c
284+
index 44fb567f95a0..2e8dbb0e016d 100644
285+
--- a/drivers/media/i2c/mt9v111.c
286+
+++ b/drivers/media/i2c/mt9v111.c
287+
@@ -957,7 +957,7 @@ static int mt9v111_set_format(struct v4l2_subdev *subdev,
288+
static int mt9v111_init_state(struct v4l2_subdev *subdev,
289+
struct v4l2_subdev_state *sd_state)
290+
{
291+
- sd_state->pads->try_fmt = mt9v111_def_fmt;
292+
+ *v4l2_subdev_get_pad_format(subdev, sd_state, 0) = mt9v111_def_fmt;
293+
294+
return 0;
295+
}
296+
diff --git a/drivers/media/i2c/ov2640.c b/drivers/media/i2c/ov2640.c
297+
index 44ab63348c22..8b45db8e799b 100644
298+
--- a/drivers/media/i2c/ov2640.c
299+
+++ b/drivers/media/i2c/ov2640.c
300+
@@ -996,7 +996,7 @@ static int ov2640_set_fmt(struct v4l2_subdev *sd,
301+
/* select format */
302+
priv->cfmt_code = mf->code;
303+
} else {
304+
- sd_state->pads->try_fmt = *mf;
305+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
306+
}
307+
out:
308+
mutex_unlock(&priv->lock);
309+
* Unmerged path drivers/media/i2c/ov2680.c
310+
* Unmerged path drivers/media/i2c/ov6650.c
311+
diff --git a/drivers/media/i2c/ov772x.c b/drivers/media/i2c/ov772x.c
312+
index 78602a2f70b0..3035e9ac0adc 100644
313+
--- a/drivers/media/i2c/ov772x.c
314+
+++ b/drivers/media/i2c/ov772x.c
315+
@@ -1222,7 +1222,7 @@ static int ov772x_set_fmt(struct v4l2_subdev *sd,
316+
mf->xfer_func = V4L2_XFER_FUNC_DEFAULT;
317+
318+
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
319+
- sd_state->pads->try_fmt = *mf;
320+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
321+
return 0;
322+
}
323+
324+
diff --git a/drivers/media/i2c/ov9640.c b/drivers/media/i2c/ov9640.c
325+
index 9f44ed52d164..091ccc7a47ae 100644
326+
--- a/drivers/media/i2c/ov9640.c
327+
+++ b/drivers/media/i2c/ov9640.c
328+
@@ -547,7 +547,7 @@ static int ov9640_set_fmt(struct v4l2_subdev *sd,
329+
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
330+
return ov9640_s_fmt(sd, mf);
331+
332+
- sd_state->pads->try_fmt = *mf;
333+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
334+
335+
return 0;
336+
}
337+
diff --git a/drivers/media/i2c/rj54n1cb0c.c b/drivers/media/i2c/rj54n1cb0c.c
338+
index 2e4018c26912..d8e7ee7a3fca 100644
339+
--- a/drivers/media/i2c/rj54n1cb0c.c
340+
+++ b/drivers/media/i2c/rj54n1cb0c.c
341+
@@ -1009,7 +1009,7 @@ static int rj54n1_set_fmt(struct v4l2_subdev *sd,
342+
&mf->height, 84, RJ54N1_MAX_HEIGHT, align, 0);
343+
344+
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
345+
- sd_state->pads->try_fmt = *mf;
346+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
347+
return 0;
348+
}
349+
350+
diff --git a/drivers/media/i2c/saa6752hs.c b/drivers/media/i2c/saa6752hs.c
351+
index a7f043cad149..85514cd83433 100644
352+
--- a/drivers/media/i2c/saa6752hs.c
353+
+++ b/drivers/media/i2c/saa6752hs.c
354+
@@ -595,7 +595,7 @@ static int saa6752hs_set_fmt(struct v4l2_subdev *sd,
355+
f->colorspace = V4L2_COLORSPACE_SMPTE170M;
356+
357+
if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
358+
- sd_state->pads->try_fmt = *f;
359+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *f;
360+
return 0;
361+
}
362+
363+
diff --git a/drivers/media/i2c/tw9910.c b/drivers/media/i2c/tw9910.c
364+
index 09f5b3986928..230873fc78d4 100644
365+
--- a/drivers/media/i2c/tw9910.c
366+
+++ b/drivers/media/i2c/tw9910.c
367+
@@ -829,7 +829,7 @@ static int tw9910_set_fmt(struct v4l2_subdev *sd,
368+
if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
369+
return tw9910_s_fmt(sd, mf);
370+
371+
- sd_state->pads->try_fmt = *mf;
372+
+ *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
373+
374+
return 0;
375+
}

0 commit comments

Comments
 (0)