diff options
author | Mylène Josserand <mylene.josserand@bootlin.com> | 2018-04-16 08:36:51 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2018-05-17 06:22:08 -0400 |
commit | 1068fecacf4304ff5c41139c4a84a19bdb08ef90 (patch) | |
tree | 1d41bcd5ebd7194ecd77c7d3aa851b091e2c9d83 /drivers/media/i2c/ov5640.c | |
parent | deb9eec69662f14818e68c6a4e65c6c71a1789c2 (diff) | |
download | linux-1068fecacf4304ff5c41139c4a84a19bdb08ef90.tar.gz linux-1068fecacf4304ff5c41139c4a84a19bdb08ef90.tar.bz2 linux-1068fecacf4304ff5c41139c4a84a19bdb08ef90.zip |
media: ov5640: Add light frequency control
Add the light frequency control to be able to set the frequency
to manual (50Hz or 60Hz) or auto.
[Sakari Ailus: Rename "ctl" as "ctrl" as agreed.]
[mchehab+samsung@kernel.org: fixed two coding style warnings]
Signed-off-by: Mylène Josserand <mylene.josserand@bootlin.com>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/i2c/ov5640.c')
-rw-r--r-- | drivers/media/i2c/ov5640.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 7acd3b44d194..60b7da7bf8ef 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -187,6 +187,7 @@ struct ov5640_ctrls { struct v4l2_ctrl *gain; }; struct v4l2_ctrl *brightness; + struct v4l2_ctrl *light_freq; struct v4l2_ctrl *saturation; struct v4l2_ctrl *contrast; struct v4l2_ctrl *hue; @@ -2155,6 +2156,21 @@ static int ov5640_set_ctrl_test_pattern(struct ov5640_dev *sensor, int value) 0xa4, value ? 0xa4 : 0); } +static int ov5640_set_ctrl_light_freq(struct ov5640_dev *sensor, int value) +{ + int ret; + + ret = ov5640_mod_reg(sensor, OV5640_REG_HZ5060_CTRL01, BIT(7), + (value == V4L2_CID_POWER_LINE_FREQUENCY_AUTO) ? + 0 : BIT(7)); + if (ret) + return ret; + + return ov5640_mod_reg(sensor, OV5640_REG_HZ5060_CTRL00, BIT(2), + (value == V4L2_CID_POWER_LINE_FREQUENCY_50HZ) ? + BIT(2) : 0); +} + static int ov5640_g_volatile_ctrl(struct v4l2_ctrl *ctrl) { struct v4l2_subdev *sd = ctrl_to_sd(ctrl); @@ -2223,6 +2239,9 @@ static int ov5640_s_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_TEST_PATTERN: ret = ov5640_set_ctrl_test_pattern(sensor, ctrl->val); break; + case V4L2_CID_POWER_LINE_FREQUENCY: + ret = ov5640_set_ctrl_light_freq(sensor, ctrl->val); + break; default: ret = -EINVAL; break; @@ -2285,6 +2304,12 @@ static int ov5640_init_controls(struct ov5640_dev *sensor) ARRAY_SIZE(test_pattern_menu) - 1, 0, 0, test_pattern_menu); + ctrls->light_freq = + v4l2_ctrl_new_std_menu(hdl, ops, + V4L2_CID_POWER_LINE_FREQUENCY, + V4L2_CID_POWER_LINE_FREQUENCY_AUTO, 0, + V4L2_CID_POWER_LINE_FREQUENCY_50HZ); + if (hdl->error) { ret = hdl->error; goto free_ctrls; |