bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0728-media-i2c-ov7251-V4L2_CID_LINK_FREQUENCY-is-fixed.patch
1 From f8c8c6aed54e064f3ec36eeee0595ec4e2206d66 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Sat, 12 Feb 2022 09:53:47 +0000
4 Subject: [PATCH] media: i2c: ov7251: V4L2_CID_LINK_FREQUENCY is fixed
5
6 The link frequency does not change with the mode, so remove
7 the special handling for it.
8
9 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
10 ---
11 drivers/media/i2c/ov7251.c | 29 +++++++----------------------
12 1 file changed, 7 insertions(+), 22 deletions(-)
13
14 --- a/drivers/media/i2c/ov7251.c
15 +++ b/drivers/media/i2c/ov7251.c
16 @@ -66,7 +66,6 @@ struct ov7251_mode_info {
17 u32 height;
18 const struct reg_value *data;
19 u32 data_size;
20 - u32 link_freq;
21 u16 exposure_max;
22 u16 exposure_def;
23 struct v4l2_fract timeperframe;
24 @@ -113,7 +112,6 @@ struct ov7251 {
25 const struct ov7251_mode_info *current_mode;
26
27 struct v4l2_ctrl_handler ctrls;
28 - struct v4l2_ctrl *link_freq;
29 struct v4l2_ctrl *exposure;
30 struct v4l2_ctrl *gain;
31
32 @@ -591,7 +589,6 @@ static const struct ov7251_mode_info ov7
33 .height = 480,
34 .data = ov7251_setting_vga_30fps,
35 .data_size = ARRAY_SIZE(ov7251_setting_vga_30fps),
36 - .link_freq = 0, /* an index in link_freq[] */
37 .exposure_max = 1704,
38 .exposure_def = 504,
39 .timeperframe = {
40 @@ -604,7 +601,6 @@ static const struct ov7251_mode_info ov7
41 .height = 480,
42 .data = ov7251_setting_vga_60fps,
43 .data_size = ARRAY_SIZE(ov7251_setting_vga_60fps),
44 - .link_freq = 0, /* an index in link_freq[] */
45 .exposure_max = 840,
46 .exposure_def = 504,
47 .timeperframe = {
48 @@ -617,7 +613,6 @@ static const struct ov7251_mode_info ov7
49 .height = 480,
50 .data = ov7251_setting_vga_90fps,
51 .data_size = ARRAY_SIZE(ov7251_setting_vga_90fps),
52 - .link_freq = 0, /* an index in link_freq[] */
53 .exposure_max = 552,
54 .exposure_def = 504,
55 .timeperframe = {
56 @@ -1152,11 +1147,6 @@ static int ov7251_set_format(struct v4l2
57 __crop->height = new_mode->height;
58
59 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
60 - ret = __v4l2_ctrl_s_ctrl(ov7251->link_freq,
61 - new_mode->link_freq);
62 - if (ret < 0)
63 - goto exit;
64 -
65 ret = __v4l2_ctrl_modify_range(ov7251->exposure,
66 1, new_mode->exposure_max,
67 1, new_mode->exposure_def);
68 @@ -1311,11 +1301,6 @@ static int ov7251_set_frame_interval(str
69 new_mode = ov7251_find_mode_by_ival(ov7251, &fi->interval);
70
71 if (new_mode != ov7251->current_mode) {
72 - ret = __v4l2_ctrl_s_ctrl(ov7251->link_freq,
73 - new_mode->link_freq);
74 - if (ret < 0)
75 - goto exit;
76 -
77 ret = __v4l2_ctrl_modify_range(ov7251->exposure,
78 1, new_mode->exposure_max,
79 1, new_mode->exposure_def);
80 @@ -1464,6 +1449,7 @@ static int ov7251_probe(struct i2c_clien
81 {
82 struct v4l2_fwnode_device_properties props;
83 struct device *dev = &client->dev;
84 + struct v4l2_ctrl *ctrl;
85 struct ov7251 *ov7251;
86 unsigned int rate = 0;
87 int ret;
88 @@ -1561,13 +1547,12 @@ static int ov7251_probe(struct i2c_clien
89 v4l2_ctrl_new_std(&ov7251->ctrls, &ov7251_ctrl_ops,
90 V4L2_CID_PIXEL_RATE, OV7251_PIXEL_CLOCK,
91 OV7251_PIXEL_CLOCK, 1, OV7251_PIXEL_CLOCK);
92 - ov7251->link_freq = v4l2_ctrl_new_int_menu(&ov7251->ctrls,
93 - &ov7251_ctrl_ops,
94 - V4L2_CID_LINK_FREQ,
95 - ARRAY_SIZE(link_freq) - 1,
96 - 0, link_freq);
97 - if (ov7251->link_freq)
98 - ov7251->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
99 + ctrl = v4l2_ctrl_new_int_menu(&ov7251->ctrls, &ov7251_ctrl_ops,
100 + V4L2_CID_LINK_FREQ,
101 + ARRAY_SIZE(link_freq) - 1,
102 + 0, link_freq);
103 + if (ctrl)
104 + ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY;
105
106 ov7251->sd.ctrl_handler = &ov7251->ctrls;
107