51659f54a409287e61dbc43c847b185852bbcca5
[openwrt/openwrt.git] / target / linux / at91 / patches-5.15 / 166-media-atmel-atmel-isc-add-CBC-to-the-reg-offsets-str.patch
1 From 52e4b779ae1af3e322d0c673375dcd51315739d4 Mon Sep 17 00:00:00 2001
2 From: Eugen Hristev <eugen.hristev@microchip.com>
3 Date: Tue, 13 Apr 2021 12:57:08 +0200
4 Subject: [PATCH 166/247] media: atmel: atmel-isc: add CBC to the reg offsets
5 struct
6
7 The CBC submodule is a part of the atmel-isc pipeline, and stands for
8 Contrast Brightness Control. It is used to apply gains and offsets to the
9 luma (Y) and chroma (U, V) components of the YUV elements.
10 Add cbc to the reg offsets struct. This will allow different products
11 to have a different reg offset for this particular module.
12
13 Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
14 Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
15 Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
16 ---
17 drivers/media/platform/atmel/atmel-isc-base.c | 2 +-
18 drivers/media/platform/atmel/atmel-isc-regs.h | 3 +++
19 drivers/media/platform/atmel/atmel-isc.h | 2 ++
20 drivers/media/platform/atmel/atmel-sama5d2-isc.c | 7 +++++--
21 4 files changed, 11 insertions(+), 3 deletions(-)
22
23 --- a/drivers/media/platform/atmel/atmel-isc-base.c
24 +++ b/drivers/media/platform/atmel/atmel-isc-base.c
25 @@ -2325,7 +2325,7 @@ int isc_pipeline_init(struct isc_device
26 REG_FIELD(ISC_GAM_CTRL, 2, 2),
27 REG_FIELD(ISC_GAM_CTRL, 3, 3),
28 REG_FIELD(ISC_CSC_CTRL + isc->offsets.csc, 0, 0),
29 - REG_FIELD(ISC_CBC_CTRL, 0, 0),
30 + REG_FIELD(ISC_CBC_CTRL + isc->offsets.cbc, 0, 0),
31 REG_FIELD(ISC_SUB422_CTRL, 0, 0),
32 REG_FIELD(ISC_SUB420_CTRL, 0, 0),
33 };
34 --- a/drivers/media/platform/atmel/atmel-isc-regs.h
35 +++ b/drivers/media/platform/atmel/atmel-isc-regs.h
36 @@ -177,6 +177,9 @@
37 /* Color Space Conversion CRB OCR Register */
38 #define ISC_CSC_CRB_OCR 0x000003b0
39
40 +/* Offset for CBC register specific to sama5d2 product */
41 +#define ISC_SAMA5D2_CBC_OFFSET 0
42 +
43 /* Contrast And Brightness Control Register */
44 #define ISC_CBC_CTRL 0x000003b4
45
46 --- a/drivers/media/platform/atmel/atmel-isc.h
47 +++ b/drivers/media/platform/atmel/atmel-isc.h
48 @@ -146,9 +146,11 @@ struct isc_ctrls {
49 /*
50 * struct isc_reg_offsets - ISC device register offsets
51 * @csc: Offset for the CSC register
52 + * @cbc: Offset for the CBC register
53 */
54 struct isc_reg_offsets {
55 u32 csc;
56 + u32 cbc;
57 };
58
59 /*
60 --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
61 +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
62 @@ -77,8 +77,10 @@ static void isc_sama5d2_config_cbc(struc
63 {
64 struct regmap *regmap = isc->regmap;
65
66 - regmap_write(regmap, ISC_CBC_BRIGHT, isc->ctrls.brightness);
67 - regmap_write(regmap, ISC_CBC_CONTRAST, isc->ctrls.contrast);
68 + regmap_write(regmap, ISC_CBC_BRIGHT + isc->offsets.cbc,
69 + isc->ctrls.brightness);
70 + regmap_write(regmap, ISC_CBC_CONTRAST + isc->offsets.cbc,
71 + isc->ctrls.contrast);
72 }
73
74 /* Gamma table with gamma 1/2.2 */
75 @@ -250,6 +252,7 @@ static int atmel_isc_probe(struct platfo
76 isc->config_cbc = isc_sama5d2_config_cbc;
77
78 isc->offsets.csc = ISC_SAMA5D2_CSC_OFFSET;
79 + isc->offsets.cbc = ISC_SAMA5D2_CBC_OFFSET;
80
81 /* sama5d2-isc - 8 bits per beat */
82 isc->dcfg = ISC_DCFG_YMBSIZE_BEATS8 | ISC_DCFG_CMBSIZE_BEATS8;