Skip to content

Commit e4c2a77

Browse files
6by9pelwell
authored andcommitted
media: i2c: ov5647: Add control of V4L2_CID_HBLANK
The driver did expose V4L2_CID_HBLANK, but as a READ_ONLY control. The sensor only uses the HTS register to control the line length, so convert this control to read/write, with the appropriate ranges. Adopt the old fixed values as the minimum values permitted in each mode to avoid issues of it not streaming. This should allow exposure times up to ~3 seconds (up from ~1sec). Signed-off-by: Dave Stevenson <[email protected]>
1 parent d6a12dd commit e4c2a77

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

drivers/media/i2c/ov5647.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
#define OV5647_REG_AEC_AGC 0x3503
5454
#define OV5647_REG_GAIN_HI 0x350a
5555
#define OV5647_REG_GAIN_LO 0x350b
56+
#define OV5647_REG_HTS_HI 0x380c
57+
#define OV5647_REG_HTS_LO 0x380d
5658
#define OV5647_REG_VTS_HI 0x380e
5759
#define OV5647_REG_VTS_LO 0x380f
5860
#define OV5647_REG_VFLIP 0x3820
@@ -79,6 +81,8 @@
7981
#define OV5647_VBLANK_MIN 24
8082
#define OV5647_VTS_MAX 32767
8183

84+
#define OV5647_HTS_MAX 0x1fff
85+
8286
#define OV5647_EXPOSURE_MIN 4
8387
#define OV5647_EXPOSURE_STEP 1
8488
#define OV5647_EXPOSURE_DEFAULT 1000
@@ -188,8 +192,6 @@ static struct regval_list ov5647_2592x1944_10bpp[] = {
188192
{0x3a19, 0xf8},
189193
{0x3c01, 0x80},
190194
{0x3b07, 0x0c},
191-
{0x380c, 0x0b},
192-
{0x380d, 0x1c},
193195
{0x3814, 0x11},
194196
{0x3815, 0x11},
195197
{0x3708, 0x64},
@@ -277,8 +279,6 @@ static struct regval_list ov5647_1080p30_10bpp[] = {
277279
{0x3a19, 0xf8},
278280
{0x3c01, 0x80},
279281
{0x3b07, 0x0c},
280-
{0x380c, 0x09},
281-
{0x380d, 0x70},
282282
{0x3814, 0x11},
283283
{0x3815, 0x11},
284284
{0x3708, 0x64},
@@ -376,8 +376,6 @@ static struct regval_list ov5647_2x2binned_10bpp[] = {
376376
{0x3809, 0x10},
377377
{0x380a, 0x03},
378378
{0x380b, 0xcc},
379-
{0x380c, 0x07},
380-
{0x380d, 0x68},
381379
{0x3811, 0x0c},
382380
{0x3813, 0x06},
383381
{0x3814, 0x31},
@@ -451,8 +449,6 @@ static struct regval_list ov5647_640x480_10bpp[] = {
451449
{0x3a19, 0xf8},
452450
{0x3c01, 0x80},
453451
{0x3b07, 0x0c},
454-
{0x380c, 0x07},
455-
{0x380d, 0x3c},
456452
{0x3814, 0x35},
457453
{0x3815, 0x35},
458454
{0x3708, 0x64},
@@ -1079,7 +1075,8 @@ static int ov5647_set_pad_fmt(struct v4l2_subdev *sd,
10791075
mode->pixel_rate, 1, mode->pixel_rate);
10801076

10811077
hblank = mode->hts - mode->format.width;
1082-
__v4l2_ctrl_modify_range(sensor->hblank, hblank, hblank, 1,
1078+
__v4l2_ctrl_modify_range(sensor->hblank, hblank,
1079+
OV5647_HTS_MAX - mode->format.width, 1,
10831080
hblank);
10841081

10851082
vblank = mode->vts - mode->format.height;
@@ -1343,14 +1340,17 @@ static int ov5647_s_ctrl(struct v4l2_ctrl *ctrl)
13431340
ret = ov5647_write16(sd, OV5647_REG_VTS_HI,
13441341
sensor->mode->format.height + ctrl->val);
13451342
break;
1343+
case V4L2_CID_HBLANK:
1344+
ret = ov5647_write16(sd, OV5647_REG_HTS_HI,
1345+
sensor->mode->format.width + ctrl->val);
1346+
break;
13461347
case V4L2_CID_TEST_PATTERN:
13471348
ret = ov5647_write(sd, OV5647_REG_ISPCTRL3D,
13481349
ov5647_test_pattern_val[ctrl->val]);
13491350
break;
13501351

13511352
/* Read-only, but we adjust it based on mode. */
13521353
case V4L2_CID_PIXEL_RATE:
1353-
case V4L2_CID_HBLANK:
13541354
/* Read-only, but we adjust it based on mode. */
13551355
break;
13561356

@@ -1427,10 +1427,11 @@ static int ov5647_init_controls(struct ov5647 *sensor, struct device *dev)
14271427
sensor->mode->pixel_rate, 1,
14281428
sensor->mode->pixel_rate);
14291429

1430-
/* By default, HBLANK is read only, but it does change per mode. */
14311430
hblank = sensor->mode->hts - sensor->mode->format.width;
14321431
sensor->hblank = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
1433-
V4L2_CID_HBLANK, hblank, hblank, 1,
1432+
V4L2_CID_HBLANK, hblank,
1433+
OV5647_HTS_MAX -
1434+
sensor->mode->format.width, 1,
14341435
hblank);
14351436

14361437
sensor->vblank = v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
@@ -1464,7 +1465,6 @@ static int ov5647_init_controls(struct ov5647 *sensor, struct device *dev)
14641465
goto handler_free;
14651466

14661467
sensor->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;
1467-
sensor->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
14681468
sensor->sd.ctrl_handler = &sensor->ctrls;
14691469

14701470
return 0;

0 commit comments

Comments
 (0)