ed76e9ed07fc58716f9d7bb6609b5b07eb17dd85
[openwrt/staging/linusw.git] /
1 From a0b461a669b2e106a8b22dc3e9bd1666128d69a4 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Tue, 14 Apr 2020 15:51:50 +0100
4 Subject: [PATCH] media: i2c: ov9281: add enum_frame_interval function
5 for iq tool 2.2 and hal3
6
7 Adds the ov9281 parts of the Rockchip patch adding enum_frame_interval to
8 a large number of drivers.
9
10 Change-Id: I03344cd6cf278dd7c18fce8e97479089ef185a5c
11 Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
12 ---
13 drivers/media/i2c/ov9281.c | 31 ++++++++++++++++++++++++++-----
14 1 file changed, 26 insertions(+), 5 deletions(-)
15
16 --- a/drivers/media/i2c/ov9281.c
17 +++ b/drivers/media/i2c/ov9281.c
18 @@ -4,6 +4,7 @@
19 *
20 * Copyright (C) 2017 Fuzhou Rockchip Electronics Co., Ltd.
21 * V0.0X01.0X02 fix mclk issue when probe multiple camera.
22 + * V0.0X01.0X03 add enum_frame_interval function.
23 */
24
25 #include <linux/clk.h>
26 @@ -23,7 +24,7 @@
27 #include <media/v4l2-subdev.h>
28 #include <linux/pinctrl/consumer.h>
29
30 -#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x2)
31 +#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x3)
32
33 #ifndef V4L2_CID_DIGITAL_GAIN
34 #define V4L2_CID_DIGITAL_GAIN V4L2_CID_GAIN
35 @@ -92,7 +93,7 @@ struct regval {
36 struct ov9281_mode {
37 u32 width;
38 u32 height;
39 - u32 max_fps;
40 + struct v4l2_fract max_fps;
41 u32 hts_def;
42 u32 vts_def;
43 u32 exp_def;
44 @@ -246,7 +247,10 @@ static const struct ov9281_mode supporte
45 {
46 .width = 1280,
47 .height = 800,
48 - .max_fps = 120,
49 + .max_fps = {
50 + .numerator = 10000,
51 + .denominator = 1200000,
52 + },
53 .exp_def = 0x0320,
54 .hts_def = 0x0b60,//0x2d8*4
55 .vts_def = 0x038e,
56 @@ -483,8 +487,7 @@ static int OV9281_g_frame_interval(struc
57 const struct ov9281_mode *mode = ov9281->cur_mode;
58
59 mutex_lock(&ov9281->mutex);
60 - fi->interval.numerator = 10000;
61 - fi->interval.denominator = mode->max_fps * 10000;
62 + fi->interval = mode->max_fps;
63 mutex_unlock(&ov9281->mutex);
64
65 return 0;
66 @@ -778,6 +781,23 @@ static int ov9281_open(struct v4l2_subde
67 }
68 #endif
69
70 +static int
71 +ov9281_enum_frame_interval(struct v4l2_subdev *sd,
72 + struct v4l2_subdev_pad_config *cfg,
73 + struct v4l2_subdev_frame_interval_enum *fie)
74 +{
75 + if (fie->index >= ARRAY_SIZE(supported_modes))
76 + return -EINVAL;
77 +
78 + if (fie->code != MEDIA_BUS_FMT_Y10_1X10)
79 + return -EINVAL;
80 +
81 + fie->width = supported_modes[fie->index].width;
82 + fie->height = supported_modes[fie->index].height;
83 + fie->interval = supported_modes[fie->index].max_fps;
84 + return 0;
85 +}
86 +
87 static const struct dev_pm_ops ov9281_pm_ops = {
88 SET_RUNTIME_PM_OPS(ov9281_runtime_suspend,
89 ov9281_runtime_resume, NULL)
90 @@ -805,6 +825,7 @@ static const struct v4l2_subdev_video_op
91 static const struct v4l2_subdev_pad_ops ov9281_pad_ops = {
92 .enum_mbus_code = ov9281_enum_mbus_code,
93 .enum_frame_size = ov9281_enum_frame_sizes,
94 + .enum_frame_interval = ov9281_enum_frame_interval,
95 .get_fmt = ov9281_get_fmt,
96 .set_fmt = ov9281_set_fmt,
97 };