Skip to content

Commit 84ab774

Browse files
6by9pelwell
authored andcommitted
media: i2c: ov5647: Add V4L2_CID_LINK_FREQUENCY control
The link frequency can vary between modes, so add it as a control. Signed-off-by: Dave Stevenson <[email protected]>
1 parent 35e5c3d commit 84ab774

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

drivers/media/i2c/ov5647.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ static const char * const ov5647_supply_names[] = {
9797

9898
#define OV5647_NUM_SUPPLIES ARRAY_SIZE(ov5647_supply_names)
9999

100+
#define FREQ_INDEX_FULL 0
101+
#define FREQ_INDEX_VGA 1
102+
static const s64 ov5647_link_freqs[] = {
103+
[FREQ_INDEX_FULL] = 218500000,
104+
[FREQ_INDEX_VGA] = 208333000,
105+
};
106+
100107
struct regval_list {
101108
u16 addr;
102109
u8 data;
@@ -106,6 +113,7 @@ struct ov5647_mode {
106113
struct v4l2_mbus_framefmt format;
107114
struct v4l2_rect crop;
108115
u64 pixel_rate;
116+
unsigned int link_freq_index;
109117
int hts;
110118
int vts;
111119
const struct regval_list *reg_list;
@@ -128,6 +136,7 @@ struct ov5647 {
128136
struct v4l2_ctrl *exposure;
129137
struct v4l2_ctrl *hflip;
130138
struct v4l2_ctrl *vflip;
139+
struct v4l2_ctrl *link_freq;
131140
bool streaming;
132141
};
133142

@@ -377,6 +386,7 @@ static const struct ov5647_mode ov5647_modes[] = {
377386
.height = 1944
378387
},
379388
.pixel_rate = 87500000,
389+
.link_freq_index = FREQ_INDEX_FULL,
380390
.hts = 2844,
381391
.vts = 0x7b0,
382392
.reg_list = ov5647_2592x1944_10bpp,
@@ -398,6 +408,7 @@ static const struct ov5647_mode ov5647_modes[] = {
398408
.height = 1080,
399409
},
400410
.pixel_rate = 87500000,
411+
.link_freq_index = FREQ_INDEX_FULL,
401412
.hts = 2416,
402413
.vts = 0x450,
403414
.reg_list = ov5647_1080p30_10bpp,
@@ -419,6 +430,7 @@ static const struct ov5647_mode ov5647_modes[] = {
419430
.height = 1944,
420431
},
421432
.pixel_rate = 87500000,
433+
.link_freq_index = FREQ_INDEX_FULL,
422434
.hts = 1896,
423435
.vts = 0x59b,
424436
.reg_list = ov5647_2x2binned_10bpp,
@@ -440,6 +452,7 @@ static const struct ov5647_mode ov5647_modes[] = {
440452
.height = 1920,
441453
},
442454
.pixel_rate = 55000000,
455+
.link_freq_index = FREQ_INDEX_VGA,
443456
.hts = 1852,
444457
.vts = 0x1f8,
445458
.reg_list = ov5647_640x480_10bpp,
@@ -943,6 +956,8 @@ static int ov5647_set_pad_fmt(struct v4l2_subdev *sd,
943956
sensor->exposure->minimum,
944957
exposure_max, sensor->exposure->step,
945958
exposure_def);
959+
960+
__v4l2_ctrl_s_ctrl(sensor->link_freq, mode->link_freq_index);
946961
}
947962
*fmt = mode->format;
948963
/* The code we pass back must reflect the current h/vflips. */
@@ -1248,7 +1263,7 @@ static int ov5647_init_controls(struct ov5647 *sensor, struct device *dev)
12481263
int hblank, exposure_max, exposure_def;
12491264
struct v4l2_fwnode_device_properties props;
12501265

1251-
v4l2_ctrl_handler_init(&sensor->ctrls, 9);
1266+
v4l2_ctrl_handler_init(&sensor->ctrls, 10);
12521267

12531268
v4l2_ctrl_new_std(&sensor->ctrls, &ov5647_ctrl_ops,
12541269
V4L2_CID_AUTOGAIN, 0, 1, 1, 0);
@@ -1308,6 +1323,14 @@ static int ov5647_init_controls(struct ov5647 *sensor, struct device *dev)
13081323
if (sensor->vflip)
13091324
sensor->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
13101325

1326+
sensor->link_freq =
1327+
v4l2_ctrl_new_int_menu(&sensor->ctrls, &ov5647_ctrl_ops,
1328+
V4L2_CID_LINK_FREQ,
1329+
ARRAY_SIZE(ov5647_link_freqs) - 1, 0,
1330+
ov5647_link_freqs);
1331+
if (sensor->link_freq)
1332+
sensor->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
1333+
13111334
v4l2_fwnode_device_parse(dev, &props);
13121335

13131336
v4l2_ctrl_new_fwnode_properties(&sensor->ctrls, &ov5647_ctrl_ops,

0 commit comments

Comments
 (0)