f7450cbe2c2de29a0a42317ed1845daa15451a8e
[openwrt/staging/blocktrron.git] /
1 From d66098625b057d12fcffdb07a6f2d462e0e2495d Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 4 Jan 2022 14:46:01 +0000
4 Subject: [PATCH] media: i2c: ov9281: Increase diff between VTS and max
5 exposure
6
7 The driver did allow the exposure to go up to VTS - 4 lines,
8 but this would produce a visible line on 1280x800, and a stall of
9 the sensor at 640x480.
10
11 Whilst it appears to work with a difference of 5, the datasheet states
12 there should be at least 25 lines difference between VTS and exposure,
13 so use that value.
14
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
16 ---
17 drivers/media/i2c/ov9281.c | 11 ++++++++---
18 1 file changed, 8 insertions(+), 3 deletions(-)
19
20 --- a/drivers/media/i2c/ov9281.c
21 +++ b/drivers/media/i2c/ov9281.c
22 @@ -52,7 +52,11 @@
23 #define OV9281_REG_EXPOSURE 0x3500
24 #define OV9281_EXPOSURE_MIN 4
25 #define OV9281_EXPOSURE_STEP 1
26 -#define OV9281_VTS_MAX 0x7fff
27 +/*
28 + * Number of lines less than frame length (VTS) that exposure must be.
29 + * Datasheet states 25, although empirically 5 appears to work.
30 + */
31 +#define OV9281_EXPOSURE_OFFSET 25
32
33 #define OV9281_REG_GAIN_H 0x3508
34 #define OV9281_REG_GAIN_L 0x3509
35 @@ -69,6 +73,7 @@
36 #define OV9281_TEST_PATTERN_DISABLE 0x0
37
38 #define OV9281_REG_VTS 0x380e
39 +#define OV9281_VTS_MAX 0x7fff
40
41 /*
42 * OV9281 native and active pixel array size.
43 @@ -967,7 +972,7 @@ static int ov9281_set_ctrl(struct v4l2_c
44 switch (ctrl->id) {
45 case V4L2_CID_VBLANK:
46 /* Update max exposure while meeting expected vblanking */
47 - max = ov9281->cur_mode->height + ctrl->val - 4;
48 + max = ov9281->cur_mode->height + ctrl->val - OV9281_EXPOSURE_OFFSET;
49 __v4l2_ctrl_modify_range(ov9281->exposure,
50 ov9281->exposure->minimum, max,
51 ov9281->exposure->step,
52 @@ -1062,7 +1067,7 @@ static int ov9281_initialize_controls(st
53 OV9281_VTS_MAX - mode->height, 1,
54 vblank_def);
55
56 - exposure_max = mode->vts_def - 4;
57 + exposure_max = mode->vts_def - OV9281_EXPOSURE_OFFSET;
58 ov9281->exposure = v4l2_ctrl_new_std(handler, &ov9281_ctrl_ops,
59 V4L2_CID_EXPOSURE,
60 OV9281_EXPOSURE_MIN, exposure_max,