Commit e72e6cbe authored by Todor Tomov's avatar Todor Tomov Committed by Mauro Carvalho Chehab

media: ov5645: Add control to export CSI2 link frequency

Add suport for standard integer menu V4L2_CID_LINK_FREQ control.
The CSI2 link frequency value is specific for each sensor mode so the
sensor mode structure is extended to add this. The control is made
read-only and its value is updated when the sensor mode is changed -
on set_format.
Signed-off-by: default avatarTodor Tomov <todor.tomov@linaro.org>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 1c2177fd
...@@ -81,6 +81,7 @@ struct ov5645_mode_info { ...@@ -81,6 +81,7 @@ struct ov5645_mode_info {
const struct reg_value *data; const struct reg_value *data;
u32 data_size; u32 data_size;
u32 pixel_clock; u32 pixel_clock;
u32 link_freq;
}; };
struct ov5645 { struct ov5645 {
...@@ -101,6 +102,7 @@ struct ov5645 { ...@@ -101,6 +102,7 @@ struct ov5645 {
struct v4l2_ctrl_handler ctrls; struct v4l2_ctrl_handler ctrls;
struct v4l2_ctrl *pixel_clock; struct v4l2_ctrl *pixel_clock;
struct v4l2_ctrl *link_freq;
/* Cached register values */ /* Cached register values */
u8 aec_pk_manual; u8 aec_pk_manual;
...@@ -507,27 +509,35 @@ static const struct reg_value ov5645_setting_full[] = { ...@@ -507,27 +509,35 @@ static const struct reg_value ov5645_setting_full[] = {
{ 0x4202, 0x00 } { 0x4202, 0x00 }
}; };
static const s64 link_freq[] = {
222880000,
334320000
};
static const struct ov5645_mode_info ov5645_mode_info_data[] = { static const struct ov5645_mode_info ov5645_mode_info_data[] = {
{ {
.width = 1280, .width = 1280,
.height = 960, .height = 960,
.data = ov5645_setting_sxga, .data = ov5645_setting_sxga,
.data_size = ARRAY_SIZE(ov5645_setting_sxga), .data_size = ARRAY_SIZE(ov5645_setting_sxga),
.pixel_clock = 111440000 .pixel_clock = 111440000,
.link_freq = 0 /* an index in link_freq[] */
}, },
{ {
.width = 1920, .width = 1920,
.height = 1080, .height = 1080,
.data = ov5645_setting_1080p, .data = ov5645_setting_1080p,
.data_size = ARRAY_SIZE(ov5645_setting_1080p), .data_size = ARRAY_SIZE(ov5645_setting_1080p),
.pixel_clock = 167160000 .pixel_clock = 167160000,
.link_freq = 1 /* an index in link_freq[] */
}, },
{ {
.width = 2592, .width = 2592,
.height = 1944, .height = 1944,
.data = ov5645_setting_full, .data = ov5645_setting_full,
.data_size = ARRAY_SIZE(ov5645_setting_full), .data_size = ARRAY_SIZE(ov5645_setting_full),
.pixel_clock = 167160000 .pixel_clock = 167160000,
.link_freq = 1 /* an index in link_freq[] */
}, },
}; };
...@@ -990,6 +1000,11 @@ static int ov5645_set_format(struct v4l2_subdev *sd, ...@@ -990,6 +1000,11 @@ static int ov5645_set_format(struct v4l2_subdev *sd,
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = v4l2_ctrl_s_ctrl(ov5645->link_freq,
new_mode->link_freq);
if (ret < 0)
return ret;
ov5645->current_mode = new_mode; ov5645->current_mode = new_mode;
} }
...@@ -1209,7 +1224,7 @@ static int ov5645_probe(struct i2c_client *client, ...@@ -1209,7 +1224,7 @@ static int ov5645_probe(struct i2c_client *client,
mutex_init(&ov5645->power_lock); mutex_init(&ov5645->power_lock);
v4l2_ctrl_handler_init(&ov5645->ctrls, 8); v4l2_ctrl_handler_init(&ov5645->ctrls, 9);
v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops, v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
V4L2_CID_SATURATION, -4, 4, 1, 0); V4L2_CID_SATURATION, -4, 4, 1, 0);
v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops, v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops,
...@@ -1231,6 +1246,13 @@ static int ov5645_probe(struct i2c_client *client, ...@@ -1231,6 +1246,13 @@ static int ov5645_probe(struct i2c_client *client,
&ov5645_ctrl_ops, &ov5645_ctrl_ops,
V4L2_CID_PIXEL_RATE, V4L2_CID_PIXEL_RATE,
1, INT_MAX, 1, 1); 1, INT_MAX, 1, 1);
ov5645->link_freq = v4l2_ctrl_new_int_menu(&ov5645->ctrls,
&ov5645_ctrl_ops,
V4L2_CID_LINK_FREQ,
ARRAY_SIZE(link_freq) - 1,
0, link_freq);
if (ov5645->link_freq)
ov5645->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
ov5645->sd.ctrl_handler = &ov5645->ctrls; ov5645->sd.ctrl_handler = &ov5645->ctrls;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment