aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Poulain <loic.poulain@linaro.org>2019-04-09 15:53:49 +0200
committerLoic Poulain <loic.poulain@linaro.org>2019-04-09 17:45:32 +0200
commitc3fb3b5b6ea78247a5d485cd620f8d5d1b4ab71c (patch)
treea3f78c01ca9ef8a02020ed455be7322b08919293
parent1885aeb5218cc88496bffa100e10b893b740a1e3 (diff)
media: ov5640: Add pixel clock control
Expected by camss. Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
-rw-r--r--drivers/media/i2c/ov5640.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index a4bf4b1e47b22..45d08321dbb21 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -218,6 +218,7 @@ struct ov5640_ctrls {
struct v4l2_ctrl *test_pattern;
struct v4l2_ctrl *hflip;
struct v4l2_ctrl *vflip;
+ struct v4l2_ctrl *pixel_clock;
};
struct ov5640_dev {
@@ -1840,7 +1841,7 @@ static int ov5640_set_mode(struct ov5640_dev *sensor)
enum ov5640_downsize_mode dn_mode, orig_dn_mode;
bool auto_gain = sensor->ctrls.auto_gain->val == 1;
bool auto_exp = sensor->ctrls.auto_exp->val == V4L2_EXPOSURE_AUTO;
- unsigned long rate;
+ unsigned long rate, pclock;
int ret;
dn_mode = mode->dn_mode;
@@ -1865,6 +1866,8 @@ static int ov5640_set_mode(struct ov5640_dev *sensor)
*/
rate = mode->vtot * mode->htot * 16;
rate *= ov5640_framerates[sensor->current_fr];
+ __v4l2_ctrl_s_ctrl_int64(sensor->ctrls.pixel_clock, rate / 8);
+
if (sensor->ep.bus_type == V4L2_MBUS_CSI2) {
rate = rate / sensor->ep.bus.mipi_csi2.num_data_lanes;
ret = ov5640_set_mipi_pclk(sensor, rate);
@@ -2744,6 +2747,9 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
V4L2_CID_POWER_LINE_FREQUENCY_AUTO, 0,
V4L2_CID_POWER_LINE_FREQUENCY_50HZ);
+ ctrls->pixel_clock = v4l2_ctrl_new_std(hdl, ops, V4L2_CID_PIXEL_RATE,
+ 1, INT_MAX, 1, 1);
+
if (hdl->error) {
ret = hdl->error;
goto free_ctrls;
@@ -3056,6 +3062,8 @@ static int ov5640_probe(struct i2c_client *client,
return PTR_ERR(sensor->xclk);
}
+ clk_set_rate(sensor->xclk, 23880000);
+
sensor->xclk_freq = clk_get_rate(sensor->xclk);
if (sensor->xclk_freq < OV5640_XCLK_MIN ||
sensor->xclk_freq > OV5640_XCLK_MAX) {