bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0727-media-i2c-ov7251-V4L2_CID_PIXEL_RATE-is-fixed.patch
1 From 1fbe6c846412c7c114f599fef881366f1e81ef9c Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Sat, 12 Feb 2022 09:47:38 +0000
4 Subject: [PATCH] media: i2c: ov7251: V4L2_CID_PIXEL_RATE is fixed
5
6 The pixel rate doesn't actually change based on the mode, and
7 can not be set by userspace.
8
9 Fix the control. The control is already read only as set by the core.
10
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
12 ---
13 drivers/media/i2c/ov7251.c | 24 +++++-------------------
14 1 file changed, 5 insertions(+), 19 deletions(-)
15
16 --- a/drivers/media/i2c/ov7251.c
17 +++ b/drivers/media/i2c/ov7251.c
18 @@ -54,6 +54,8 @@
19 #define OV7251_PLL2_SYS_DIV_REG 0x309a
20 #define OV7251_PLL2_ADC_DIV_REG 0x309b
21
22 +#define OV7251_PIXEL_CLOCK 48000000
23 +
24 struct reg_value {
25 u16 reg;
26 u8 val;
27 @@ -64,7 +66,6 @@ struct ov7251_mode_info {
28 u32 height;
29 const struct reg_value *data;
30 u32 data_size;
31 - u32 pixel_clock;
32 u32 link_freq;
33 u16 exposure_max;
34 u16 exposure_def;
35 @@ -112,7 +113,6 @@ struct ov7251 {
36 const struct ov7251_mode_info *current_mode;
37
38 struct v4l2_ctrl_handler ctrls;
39 - struct v4l2_ctrl *pixel_clock;
40 struct v4l2_ctrl *link_freq;
41 struct v4l2_ctrl *exposure;
42 struct v4l2_ctrl *gain;
43 @@ -591,7 +591,6 @@ static const struct ov7251_mode_info ov7
44 .height = 480,
45 .data = ov7251_setting_vga_30fps,
46 .data_size = ARRAY_SIZE(ov7251_setting_vga_30fps),
47 - .pixel_clock = 48000000,
48 .link_freq = 0, /* an index in link_freq[] */
49 .exposure_max = 1704,
50 .exposure_def = 504,
51 @@ -605,7 +604,6 @@ static const struct ov7251_mode_info ov7
52 .height = 480,
53 .data = ov7251_setting_vga_60fps,
54 .data_size = ARRAY_SIZE(ov7251_setting_vga_60fps),
55 - .pixel_clock = 48000000,
56 .link_freq = 0, /* an index in link_freq[] */
57 .exposure_max = 840,
58 .exposure_def = 504,
59 @@ -619,7 +617,6 @@ static const struct ov7251_mode_info ov7
60 .height = 480,
61 .data = ov7251_setting_vga_90fps,
62 .data_size = ARRAY_SIZE(ov7251_setting_vga_90fps),
63 - .pixel_clock = 48000000,
64 .link_freq = 0, /* an index in link_freq[] */
65 .exposure_max = 552,
66 .exposure_def = 504,
67 @@ -1155,11 +1152,6 @@ static int ov7251_set_format(struct v4l2
68 __crop->height = new_mode->height;
69
70 if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
71 - ret = __v4l2_ctrl_s_ctrl_int64(ov7251->pixel_clock,
72 - new_mode->pixel_clock);
73 - if (ret < 0)
74 - goto exit;
75 -
76 ret = __v4l2_ctrl_s_ctrl(ov7251->link_freq,
77 new_mode->link_freq);
78 if (ret < 0)
79 @@ -1319,11 +1311,6 @@ static int ov7251_set_frame_interval(str
80 new_mode = ov7251_find_mode_by_ival(ov7251, &fi->interval);
81
82 if (new_mode != ov7251->current_mode) {
83 - ret = __v4l2_ctrl_s_ctrl_int64(ov7251->pixel_clock,
84 - new_mode->pixel_clock);
85 - if (ret < 0)
86 - goto exit;
87 -
88 ret = __v4l2_ctrl_s_ctrl(ov7251->link_freq,
89 new_mode->link_freq);
90 if (ret < 0)
91 @@ -1571,10 +1558,9 @@ static int ov7251_probe(struct i2c_clien
92 V4L2_CID_TEST_PATTERN,
93 ARRAY_SIZE(ov7251_test_pattern_menu) - 1,
94 0, 0, ov7251_test_pattern_menu);
95 - ov7251->pixel_clock = v4l2_ctrl_new_std(&ov7251->ctrls,
96 - &ov7251_ctrl_ops,
97 - V4L2_CID_PIXEL_RATE,
98 - 1, INT_MAX, 1, 1);
99 + v4l2_ctrl_new_std(&ov7251->ctrls, &ov7251_ctrl_ops,
100 + V4L2_CID_PIXEL_RATE, OV7251_PIXEL_CLOCK,
101 + OV7251_PIXEL_CLOCK, 1, OV7251_PIXEL_CLOCK);
102 ov7251->link_freq = v4l2_ctrl_new_int_menu(&ov7251->ctrls,
103 &ov7251_ctrl_ops,
104 V4L2_CID_LINK_FREQ,