8ae528a423e6117a7edac2b0fef5a91e503dba10
[openwrt/openwrt.git] /
1 From 9ca04663315302f1556798e9da29eabf08aecd59 Mon Sep 17 00:00:00 2001
2 From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
3 Date: Fri, 12 Jun 2020 15:53:53 +0200
4 Subject: [PATCH] media: i2c: imx290: Add support to enumerate all
5 frame sizes
6
7 Commit 3b867fb641d884b714fba390ae866714ba475f29 upstream.
8
9 Add support to enumerate all frame sizes supported by IMX290. This is
10 required for using with userspace tools such as libcamera.
11
12 Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
13 Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>
14 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
15 Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
16 ---
17 drivers/media/i2c/imx290.c | 23 +++++++++++++++++++++++
18 1 file changed, 23 insertions(+)
19
20 --- a/drivers/media/i2c/imx290.c
21 +++ b/drivers/media/i2c/imx290.c
22 @@ -528,6 +528,28 @@ static int imx290_enum_mbus_code(struct
23 return 0;
24 }
25
26 +static int imx290_enum_frame_size(struct v4l2_subdev *sd,
27 + struct v4l2_subdev_pad_config *cfg,
28 + struct v4l2_subdev_frame_size_enum *fse)
29 +{
30 + const struct imx290 *imx290 = to_imx290(sd);
31 + const struct imx290_mode *imx290_modes = imx290_modes_ptr(imx290);
32 +
33 + if ((fse->code != imx290_formats[0].code) &&
34 + (fse->code != imx290_formats[1].code))
35 + return -EINVAL;
36 +
37 + if (fse->index >= imx290_modes_num(imx290))
38 + return -EINVAL;
39 +
40 + fse->min_width = imx290_modes[fse->index].width;
41 + fse->max_width = imx290_modes[fse->index].width;
42 + fse->min_height = imx290_modes[fse->index].height;
43 + fse->max_height = imx290_modes[fse->index].height;
44 +
45 + return 0;
46 +}
47 +
48 static int imx290_get_fmt(struct v4l2_subdev *sd,
49 struct v4l2_subdev_pad_config *cfg,
50 struct v4l2_subdev_format *fmt)
51 @@ -873,6 +895,7 @@ static const struct v4l2_subdev_video_op
52 static const struct v4l2_subdev_pad_ops imx290_pad_ops = {
53 .init_cfg = imx290_entity_init_cfg,
54 .enum_mbus_code = imx290_enum_mbus_code,
55 + .enum_frame_size = imx290_enum_frame_size,
56 .get_fmt = imx290_get_fmt,
57 .set_fmt = imx290_set_fmt,
58 };