From c99b6817190eefc77c91567e57fc930656f205bf Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Tue, 14 Apr 2020 15:51:50 +0100 Subject: [PATCH] media: i2c: ov9281: add enum_frame_interval function for iq tool 2.2 and hal3 Adds the ov9281 parts of the Rockchip patch adding enum_frame_interval to a large number of drivers. Change-Id: I03344cd6cf278dd7c18fce8e97479089ef185a5c Signed-off-by: Zefa Chen --- drivers/media/i2c/ov9281.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) --- a/drivers/media/i2c/ov9281.c +++ b/drivers/media/i2c/ov9281.c @@ -4,6 +4,7 @@ * * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd. * V0.0X01.0X02 fix mclk issue when probe multiple camera. + * V0.0X01.0X03 add enum_frame_interval function. */ #include @@ -23,7 +24,7 @@ #include #include -#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x2) +#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x3) #ifndef V4L2_CID_DIGITAL_GAIN #define V4L2_CID_DIGITAL_GAIN V4L2_CID_GAIN @@ -92,7 +93,7 @@ struct regval { struct ov9281_mode { u32 width; u32 height; - u32 max_fps; + struct v4l2_fract max_fps; u32 hts_def; u32 vts_def; u32 exp_def; @@ -246,7 +247,10 @@ static const struct ov9281_mode supporte { .width = 1280, .height = 800, - .max_fps = 120, + .max_fps = { + .numerator = 10000, + .denominator = 1200000, + }, .exp_def = 0x0320, .hts_def = 0x0b60,//0x2d8*4 .vts_def = 0x038e, @@ -483,8 +487,7 @@ static int OV9281_g_frame_interval(struc const struct ov9281_mode *mode = ov9281->cur_mode; mutex_lock(&ov9281->mutex); - fi->interval.numerator = 10000; - fi->interval.denominator = mode->max_fps * 10000; + fi->interval = mode->max_fps; mutex_unlock(&ov9281->mutex); return 0; @@ -778,6 +781,23 @@ static int ov9281_open(struct v4l2_subde } #endif +static int +ov9281_enum_frame_interval(struct v4l2_subdev *sd, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_interval_enum *fie) +{ + if (fie->index >= ARRAY_SIZE(supported_modes)) + return -EINVAL; + + if (fie->code != MEDIA_BUS_FMT_Y10_1X10) + return -EINVAL; + + fie->width = supported_modes[fie->index].width; + fie->height = supported_modes[fie->index].height; + fie->interval = supported_modes[fie->index].max_fps; + return 0; +} + static const struct dev_pm_ops ov9281_pm_ops = { SET_RUNTIME_PM_OPS(ov9281_runtime_suspend, ov9281_runtime_resume, NULL) @@ -805,6 +825,7 @@ static const struct v4l2_subdev_video_op static const struct v4l2_subdev_pad_ops ov9281_pad_ops = { .enum_mbus_code = ov9281_enum_mbus_code, .enum_frame_size = ov9281_enum_frame_sizes, + .enum_frame_interval = ov9281_enum_frame_interval, .get_fmt = ov9281_get_fmt, .set_fmt = ov9281_set_fmt, };