aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.15/950-0735-media-i2c-ov7251-Limit-exposure-based-on-VTS.patch
blob: 77686190e5246ec5c79ad93e02173b3f0349d4e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34pre { line-height: 125%; margin: 0; }
td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; }
td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight { background: #ffffff; }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.hi
From 1c779e83e5f78cadcd8dfc6cfca33e7aeb323f27 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Thu, 17 Feb 2022 16:44:33 +0000
Subject: [PATCH] media: i2c: ov7251: Limit exposure based on VTS

The maximum exposure is dictated by VTS, so compute it rather
than having the value in the mode table.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 drivers/media/i2c/ov7251.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

--- a/drivers/media/i2c/ov7251.c
+++ b/drivers/media/i2c/ov7251.c
@@ -37,6 +37,8 @@
 #define OV7251_AEC_EXPO_2		0x3502
 #define OV7251_AEC_AGC_ADJ_0		0x350a
 #define OV7251_AEC_AGC_ADJ_1		0x350b
+/* Exposure must be at least 20 lines shorter than VTS */
+#define OV7251_EXPOSURE_OFFSET		20
  /* HTS is registers 0x380c and 0x380d */
 #define OV7251_HTS			0x3a0
 #define OV7251_VTS_HIGH			0x380e
@@ -82,7 +84,6 @@ struct ov7251_mode_info {
 	u32 height;
 	const struct reg_value *data;
 	u32 data_size;
-	u16 exposure_max;
 	u16 exposure_def;
 	u16 vts;
 	struct v4l2_fract timeperframe;
@@ -348,7 +349,6 @@ static const struct ov7251_mode_info ov7
 		.height = 480,
 		.data = ov7251_setting_vga,
 		.data_size = ARRAY_SIZE(ov7251_setting_vga),
-		.exposure_max = 1704,
 		.exposure_def = 504,
 		.vts = 0x6bc,
 		.timeperframe = {
@@ -361,7 +361,6 @@ static const struct ov7251_mode_info ov7
 		.height = 480,
 		.data = ov7251_setting_vga,
 		.data_size = ARRAY_SIZE(ov7251_setting_vga),
-		.exposure_max = 840,
 		.exposure_def = 504,
 		.vts = 0x35c,
 		.timeperframe = {
@@ -374,7 +373,6 @@ static const struct ov7251_mode_info ov7
 		.height = 480,
 		.data = ov7251_setting_vga,
 		.data_size = ARRAY_SIZE(ov7251_setting_vga),
-		.exposure_max = 552,
 		.exposure_def = 504,
 		.vts = 0x23c,
 		.timeperframe = {
@@ -915,8 +913,8 @@ static int ov7251_set_format(struct v4l2
 					 h_blank, 1, h_blank);
 		__v4l2_ctrl_s_ctrl(ov7251->hblank, h_blank);
 
-		ret = __v4l2_ctrl_modify_range(ov7251->exposure,
-					       1, new_mode->exposure_max,
+		ret = __v4l2_ctrl_modify_range(ov7251->exposure, 1,
+					       new_mode->vts - OV7251_EXPOSURE_OFFSET,
 					       1, new_mode->exposure_def);
 		if (ret < 0)
 			goto exit;
@@ -1092,8 +1090,8 @@ static int ov7251_set_frame_interval(str
 	new_mode = ov7251_find_mode_by_ival(ov7251, &fi->interval);
 
 	if (new_mode != ov7251->current_mode) {
-		ret = __v4l2_ctrl_modify_range(ov7251->exposure,
-					       1, new_mode->exposure_max,
+		ret = __v4l2_ctrl_modify_range(ov7251->exposure, 1,
+					       new_mode->vts - OV7251_EXPOSURE_OFFSET,
 					       1, new_mode->exposure_def);
 		if (ret < 0)
 			goto exit;