bcm27xx: 6.1: add kernel patches
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-6.1 / 950-0625-media-i2c-imx290-Implement-HBLANK-and-VBLANK-control.patch
1 From eefa9ce2af54be4a6fa33add2c3d0ddac2739622 Mon Sep 17 00:00:00 2001
2 From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 Date: Sun, 16 Oct 2022 09:15:18 +0300
4 Subject: [PATCH] media: i2c: imx290: Implement HBLANK and VBLANK
5 controls
6
7 Upstream commit 0c3b56c905e3.
8
9 Add support for the V4L2_CID_HBLANK and V4L2_CID_VBLANK controls to the
10 imx290 driver. Make the controls read-only to start with, to report the
11 values to userspace for timing calculation.
12
13 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
14 Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
15 ---
16 drivers/media/i2c/imx290.c | 33 ++++++++++++++++++++++++++++++++-
17 1 file changed, 32 insertions(+), 1 deletion(-)
18
19 --- a/drivers/media/i2c/imx290.c
20 +++ b/drivers/media/i2c/imx290.c
21 @@ -146,6 +146,8 @@ struct imx290 {
22 struct v4l2_ctrl_handler ctrls;
23 struct v4l2_ctrl *link_freq;
24 struct v4l2_ctrl *pixel_rate;
25 + struct v4l2_ctrl *hblank;
26 + struct v4l2_ctrl *vblank;
27
28 struct mutex lock;
29 };
30 @@ -642,6 +644,20 @@ static int imx290_set_fmt(struct v4l2_su
31 if (imx290->pixel_rate)
32 __v4l2_ctrl_s_ctrl_int64(imx290->pixel_rate,
33 imx290_calc_pixel_rate(imx290));
34 +
35 + if (imx290->hblank) {
36 + unsigned int hblank = mode->hmax - mode->width;
37 +
38 + __v4l2_ctrl_modify_range(imx290->hblank, hblank, hblank,
39 + 1, hblank);
40 + }
41 +
42 + if (imx290->vblank) {
43 + unsigned int vblank = IMX290_VMAX_DEFAULT - mode->height;
44 +
45 + __v4l2_ctrl_modify_range(imx290->vblank, vblank, vblank,
46 + 1, vblank);
47 + }
48 }
49
50 *format = fmt->format;
51 @@ -880,9 +896,10 @@ static const struct media_entity_operati
52
53 static int imx290_ctrl_init(struct imx290 *imx290)
54 {
55 + unsigned int blank;
56 int ret;
57
58 - v4l2_ctrl_handler_init(&imx290->ctrls, 5);
59 + v4l2_ctrl_handler_init(&imx290->ctrls, 7);
60 imx290->ctrls.lock = &imx290->lock;
61
62 /*
63 @@ -923,6 +940,20 @@ static int imx290_ctrl_init(struct imx29
64 ARRAY_SIZE(imx290_test_pattern_menu) - 1,
65 0, 0, imx290_test_pattern_menu);
66
67 + blank = imx290->current_mode->hmax - imx290->current_mode->width;
68 + imx290->hblank = v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops,
69 + V4L2_CID_HBLANK, blank, blank, 1,
70 + blank);
71 + if (imx290->hblank)
72 + imx290->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
73 +
74 + blank = IMX290_VMAX_DEFAULT - imx290->current_mode->height;
75 + imx290->vblank = v4l2_ctrl_new_std(&imx290->ctrls, &imx290_ctrl_ops,
76 + V4L2_CID_VBLANK, blank, blank, 1,
77 + blank);
78 + if (imx290->vblank)
79 + imx290->vblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
80 +
81 imx290->sd.ctrl_handler = &imx290->ctrls;
82
83 if (imx290->ctrls.error) {