35c839692c615a9be704fe86171d8d1f1f719c98
[openwrt/openwrt.git] / target / linux / at91 / patches-5.15 / 176-media-atmel-atmel-isc-create-product-specific-v4l2-c.patch
1 From 0a75c502eac4f2ef71b6c3e0b3a01db1b3c37ba9 Mon Sep 17 00:00:00 2001
2 From: Eugen Hristev <eugen.hristev@microchip.com>
3 Date: Tue, 13 Apr 2021 12:57:18 +0200
4 Subject: [PATCH 176/247] media: atmel: atmel-isc: create product specific v4l2
5 controls config
6
7 Create product specific callback for initializing v4l2 controls.
8 Call this from v4l2 controls init function.
9
10 [hverkuil: made isc_sama5d2_config_ctrls static]
11
12 Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
13 Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
14 Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
15 ---
16 drivers/media/platform/atmel/atmel-isc-base.c | 5 +++--
17 drivers/media/platform/atmel/atmel-isc.h | 5 +++++
18 drivers/media/platform/atmel/atmel-sama5d2-isc.c | 12 ++++++++++++
19 3 files changed, 20 insertions(+), 2 deletions(-)
20
21 --- a/drivers/media/platform/atmel/atmel-isc-base.c
22 +++ b/drivers/media/platform/atmel/atmel-isc-base.c
23 @@ -2051,11 +2051,12 @@ static int isc_ctrl_init(struct isc_devi
24 if (ret < 0)
25 return ret;
26
27 + /* Initialize product specific controls. For example, contrast */
28 + isc->config_ctrls(isc, ops);
29 +
30 ctrls->brightness = 0;
31 - ctrls->contrast = 256;
32
33 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BRIGHTNESS, -1024, 1023, 1, 0);
34 - v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST, -2048, 2047, 1, 256);
35 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_GAMMA, 0, isc->gamma_max, 1,
36 isc->gamma_max);
37 isc->awb_ctrl = v4l2_ctrl_new_std(hdl, &isc_awb_ops,
38 --- a/drivers/media/platform/atmel/atmel-isc.h
39 +++ b/drivers/media/platform/atmel/atmel-isc.h
40 @@ -226,6 +226,8 @@ struct isc_reg_offsets {
41 * specific CBC module
42 * @config_cc: pointer to a function that initializes product
43 * specific CC module
44 + * @config_ctrls: pointer to a functoin that initializes product
45 + * specific v4l2 controls.
46 *
47 * @offsets: struct holding the product specific register offsets
48 */
49 @@ -300,6 +302,9 @@ struct isc_device {
50 void (*config_csc)(struct isc_device *isc);
51 void (*config_cbc)(struct isc_device *isc);
52 void (*config_cc)(struct isc_device *isc);
53 +
54 + void (*config_ctrls)(struct isc_device *isc,
55 + const struct v4l2_ctrl_ops *ops);
56 };
57
58 struct isc_reg_offsets offsets;
59 --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
60 +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
61 @@ -96,6 +96,17 @@ static void isc_sama5d2_config_cc(struct
62 regmap_write(regmap, ISC_CC_BB_OB, (1 << 8));
63 }
64
65 +static void isc_sama5d2_config_ctrls(struct isc_device *isc,
66 + const struct v4l2_ctrl_ops *ops)
67 +{
68 + struct isc_ctrls *ctrls = &isc->ctrls;
69 + struct v4l2_ctrl_handler *hdl = &ctrls->handler;
70 +
71 + ctrls->contrast = 256;
72 +
73 + v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST, -2048, 2047, 1, 256);
74 +}
75 +
76 /* Gamma table with gamma 1/2.2 */
77 static const u32 isc_sama5d2_gamma_table[][GAMMA_ENTRIES] = {
78 /* 0 --> gamma 1/1.8 */
79 @@ -265,6 +276,7 @@ static int atmel_isc_probe(struct platfo
80 isc->config_csc = isc_sama5d2_config_csc;
81 isc->config_cbc = isc_sama5d2_config_cbc;
82 isc->config_cc = isc_sama5d2_config_cc;
83 + isc->config_ctrls = isc_sama5d2_config_ctrls;
84
85 isc->offsets.csc = ISC_SAMA5D2_CSC_OFFSET;
86 isc->offsets.cbc = ISC_SAMA5D2_CBC_OFFSET;