summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2023-08-03 12:33:33 +0300
committerMauro Carvalho Chehab <mchehab@kernel.org>2023-08-14 21:27:57 +0300
commit4007015e604f680999c764be84b84aea7319fb0b (patch)
treeb42ee9c5f0d19eea6247927484ebc200640344e1 /drivers/media
parentdf3ecab8d7c5714b08544ef4ea8ac95e6a5743a3 (diff)
downloadlinux-4007015e604f680999c764be84b84aea7319fb0b.tar.xz
media: ov2680: Fix ov2680_enum_frame_interval()
Fix and simplify ov2680_enum_frame_interval(), the index is not an index into ov2680_mode_data[], so using OV2680_MODE_MAX is wrong. Instead it is an index indexing the different framerates for the resolution specified in fie->width, fie->height. Note validating fie->which is not necessary this is already done by the v4l2-core. Acked-by: Rui Miguel Silva <rmfrfs@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/i2c/ov2680.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
index 0adfacc70735..a83efd449993 100644
--- a/drivers/media/i2c/ov2680.c
+++ b/drivers/media/i2c/ov2680.c
@@ -527,21 +527,30 @@ static int ov2680_enum_frame_size(struct v4l2_subdev *sd,
return 0;
}
+static bool ov2680_valid_frame_size(struct v4l2_subdev_frame_interval_enum *fie)
+{
+ int i;
+
+ for (i = 0; i < OV2680_MODE_MAX; i++) {
+ if (fie->width == ov2680_mode_data[i].width &&
+ fie->height == ov2680_mode_data[i].height)
+ return true;
+ }
+
+ return false;
+}
+
static int ov2680_enum_frame_interval(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_frame_interval_enum *fie)
{
- struct v4l2_fract tpf;
+ struct ov2680_dev *sensor = to_ov2680_dev(sd);
- if (fie->index >= OV2680_MODE_MAX || fie->width > OV2680_WIDTH_MAX ||
- fie->height > OV2680_HEIGHT_MAX ||
- fie->which > V4L2_SUBDEV_FORMAT_ACTIVE)
+ /* Only 1 framerate */
+ if (fie->index || !ov2680_valid_frame_size(fie))
return -EINVAL;
- tpf.denominator = OV2680_FRAME_RATE;
- tpf.numerator = 1;
-
- fie->interval = tpf;
+ fie->interval = sensor->frame_interval;
return 0;
}