diff --git a/drivers/media/i2c/ov9281.c b/drivers/media/i2c/ov9281.c index 0d6759942f793954530fcaa395723e8643bfce9a..273aa904683cd184d6be6512cd934b2eb0abb25c 100644 --- 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 supported_modes[] = { { .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(struct v4l2_subdev *sd, 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_subdev *sd, struct v4l2_subdev_fh *fh) } #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_ops ov9281_video_ops = { 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, };