Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Todor Tomov <todor.tomov@linaro.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

authored by

Todor Tomov and committed by
Mauro Carvalho Chehab
e72e6cbe 1c2177fd

+26 -4
+26 -4
drivers/media/i2c/ov5645.c
··· 81 81 const struct reg_value *data; 82 82 u32 data_size; 83 83 u32 pixel_clock; 84 + u32 link_freq; 84 85 }; 85 86 86 87 struct ov5645 { ··· 102 101 103 102 struct v4l2_ctrl_handler ctrls; 104 103 struct v4l2_ctrl *pixel_clock; 104 + struct v4l2_ctrl *link_freq; 105 105 106 106 /* Cached register values */ 107 107 u8 aec_pk_manual; ··· 509 507 { 0x4202, 0x00 } 510 508 }; 511 509 510 + static const s64 link_freq[] = { 511 + 222880000, 512 + 334320000 513 + }; 514 + 512 515 static const struct ov5645_mode_info ov5645_mode_info_data[] = { 513 516 { 514 517 .width = 1280, 515 518 .height = 960, 516 519 .data = ov5645_setting_sxga, 517 520 .data_size = ARRAY_SIZE(ov5645_setting_sxga), 518 - .pixel_clock = 111440000 521 + .pixel_clock = 111440000, 522 + .link_freq = 0 /* an index in link_freq[] */ 519 523 }, 520 524 { 521 525 .width = 1920, 522 526 .height = 1080, 523 527 .data = ov5645_setting_1080p, 524 528 .data_size = ARRAY_SIZE(ov5645_setting_1080p), 525 - .pixel_clock = 167160000 529 + .pixel_clock = 167160000, 530 + .link_freq = 1 /* an index in link_freq[] */ 526 531 }, 527 532 { 528 533 .width = 2592, 529 534 .height = 1944, 530 535 .data = ov5645_setting_full, 531 536 .data_size = ARRAY_SIZE(ov5645_setting_full), 532 - .pixel_clock = 167160000 537 + .pixel_clock = 167160000, 538 + .link_freq = 1 /* an index in link_freq[] */ 533 539 }, 534 540 }; 535 541 ··· 1000 990 if (ret < 0) 1001 991 return ret; 1002 992 993 + ret = v4l2_ctrl_s_ctrl(ov5645->link_freq, 994 + new_mode->link_freq); 995 + if (ret < 0) 996 + return ret; 997 + 1003 998 ov5645->current_mode = new_mode; 1004 999 } 1005 1000 ··· 1224 1209 1225 1210 mutex_init(&ov5645->power_lock); 1226 1211 1227 - v4l2_ctrl_handler_init(&ov5645->ctrls, 8); 1212 + v4l2_ctrl_handler_init(&ov5645->ctrls, 9); 1228 1213 v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops, 1229 1214 V4L2_CID_SATURATION, -4, 4, 1, 0); 1230 1215 v4l2_ctrl_new_std(&ov5645->ctrls, &ov5645_ctrl_ops, ··· 1246 1231 &ov5645_ctrl_ops, 1247 1232 V4L2_CID_PIXEL_RATE, 1248 1233 1, INT_MAX, 1, 1); 1234 + ov5645->link_freq = v4l2_ctrl_new_int_menu(&ov5645->ctrls, 1235 + &ov5645_ctrl_ops, 1236 + V4L2_CID_LINK_FREQ, 1237 + ARRAY_SIZE(link_freq) - 1, 1238 + 0, link_freq); 1239 + if (ov5645->link_freq) 1240 + ov5645->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY; 1249 1241 1250 1242 ov5645->sd.ctrl_handler = &ov5645->ctrls; 1251 1243