summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2023-08-03 12:33:37 +0300
committerMauro Carvalho Chehab <mchehab@kernel.org>2023-08-14 21:27:57 +0300
commit23321b91b39f666bec32f32ccc7d2bac93ca09d8 (patch)
tree19471a7284f3e7d2a5ab1d8b9387512cf93b9b74 /drivers/media
parent63f47529bb5c5ede928cf2dd9c69900a6c897b83 (diff)
downloadlinux-23321b91b39f666bec32f32ccc7d2bac93ca09d8.tar.xz
media: ov2680: Add an __ov2680_get_pad_format() helper function
Add an __ov2680_get_pad_format() helper function. This is a preparation patch for adding selections support. Acked-by: Rui Miguel Silva <rmfrfs@gmail.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.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.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
index 012b95f90c1d..87c4c5ea47c9 100644
--- a/drivers/media/i2c/ov2680.c
+++ b/drivers/media/i2c/ov2680.c
@@ -220,6 +220,18 @@ static void ov2680_set_bayer_order(struct ov2680_dev *sensor,
fmt->code = ov2680_hv_flip_bayer_order[hv_flip];
}
+static struct v4l2_mbus_framefmt *
+__ov2680_get_pad_format(struct ov2680_dev *sensor,
+ struct v4l2_subdev_state *state,
+ unsigned int pad,
+ enum v4l2_subdev_format_whence which)
+{
+ if (which == V4L2_SUBDEV_FORMAT_TRY)
+ return v4l2_subdev_get_try_format(&sensor->sd, state, pad);
+
+ return &sensor->mode.fmt;
+}
+
static void ov2680_fill_format(struct ov2680_dev *sensor,
struct v4l2_mbus_framefmt *fmt,
unsigned int width, unsigned int height)
@@ -508,22 +520,16 @@ static int ov2680_get_fmt(struct v4l2_subdev *sd,
struct v4l2_subdev_format *format)
{
struct ov2680_dev *sensor = to_ov2680_dev(sd);
- struct v4l2_mbus_framefmt *fmt = NULL;
+ struct v4l2_mbus_framefmt *fmt;
if (format->pad != 0)
return -EINVAL;
- mutex_lock(&sensor->lock);
-
- if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
- fmt = v4l2_subdev_get_try_format(&sensor->sd, sd_state,
- format->pad);
- } else {
- fmt = &sensor->mode.fmt;
- }
+ fmt = __ov2680_get_pad_format(sensor, sd_state, format->pad,
+ format->which);
+ mutex_lock(&sensor->lock);
format->format = *fmt;
-
mutex_unlock(&sensor->lock);
return 0;