4ba3e3cace4db4beaf809fee2cc3494baa40f8c9
[openwrt/staging/jow.git] / target / linux / at91 / patches-5.10 / 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 diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c
22 index ffce8de2cf4d..8ed8b8a4840c 100644
23 --- a/drivers/media/platform/atmel/atmel-isc-base.c
24 +++ b/drivers/media/platform/atmel/atmel-isc-base.c
25 @@ -2051,11 +2051,12 @@ static int isc_ctrl_init(struct isc_device *isc)
26 if (ret < 0)
27 return ret;
28
29 + /* Initialize product specific controls. For example, contrast */
30 + isc->config_ctrls(isc, ops);
31 +
32 ctrls->brightness = 0;
33 - ctrls->contrast = 256;
34
35 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_BRIGHTNESS, -1024, 1023, 1, 0);
36 - v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST, -2048, 2047, 1, 256);
37 v4l2_ctrl_new_std(hdl, ops, V4L2_CID_GAMMA, 0, isc->gamma_max, 1,
38 isc->gamma_max);
39 isc->awb_ctrl = v4l2_ctrl_new_std(hdl, &isc_awb_ops,
40 diff --git a/drivers/media/platform/atmel/atmel-isc.h b/drivers/media/platform/atmel/atmel-isc.h
41 index 293746664cef..428419d5a07d 100644
42 --- a/drivers/media/platform/atmel/atmel-isc.h
43 +++ b/drivers/media/platform/atmel/atmel-isc.h
44 @@ -226,6 +226,8 @@ struct isc_reg_offsets {
45 * specific CBC module
46 * @config_cc: pointer to a function that initializes product
47 * specific CC module
48 + * @config_ctrls: pointer to a functoin that initializes product
49 + * specific v4l2 controls.
50 *
51 * @offsets: struct holding the product specific register offsets
52 */
53 @@ -300,6 +302,9 @@ struct isc_device {
54 void (*config_csc)(struct isc_device *isc);
55 void (*config_cbc)(struct isc_device *isc);
56 void (*config_cc)(struct isc_device *isc);
57 +
58 + void (*config_ctrls)(struct isc_device *isc,
59 + const struct v4l2_ctrl_ops *ops);
60 };
61
62 struct isc_reg_offsets offsets;
63 diff --git a/drivers/media/platform/atmel/atmel-sama5d2-isc.c b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
64 index 903920b74965..7512012cd9f3 100644
65 --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
66 +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
67 @@ -96,6 +96,17 @@ static void isc_sama5d2_config_cc(struct isc_device *isc)
68 regmap_write(regmap, ISC_CC_BB_OB, (1 << 8));
69 }
70
71 +static void isc_sama5d2_config_ctrls(struct isc_device *isc,
72 + const struct v4l2_ctrl_ops *ops)
73 +{
74 + struct isc_ctrls *ctrls = &isc->ctrls;
75 + struct v4l2_ctrl_handler *hdl = &ctrls->handler;
76 +
77 + ctrls->contrast = 256;
78 +
79 + v4l2_ctrl_new_std(hdl, ops, V4L2_CID_CONTRAST, -2048, 2047, 1, 256);
80 +}
81 +
82 /* Gamma table with gamma 1/2.2 */
83 static const u32 isc_sama5d2_gamma_table[][GAMMA_ENTRIES] = {
84 /* 0 --> gamma 1/1.8 */
85 @@ -265,6 +276,7 @@ static int atmel_isc_probe(struct platform_device *pdev)
86 isc->config_csc = isc_sama5d2_config_csc;
87 isc->config_cbc = isc_sama5d2_config_cbc;
88 isc->config_cc = isc_sama5d2_config_cc;
89 + isc->config_ctrls = isc_sama5d2_config_ctrls;
90
91 isc->offsets.csc = ISC_SAMA5D2_CSC_OFFSET;
92 isc->offsets.cbc = ISC_SAMA5D2_CBC_OFFSET;
93 --
94 2.32.0
95