ath25: switch default kernel to 5.15
[openwrt/staging/hauke.git] / target / linux / at91 / patches-5.10 / 164-media-atmel-atmel-isc-create-register-offsets-struct.patch
1 From 7a1b082cd81a2496e2687cee7ea1ef04a3020f48 Mon Sep 17 00:00:00 2001
2 From: Eugen Hristev <eugen.hristev@microchip.com>
3 Date: Tue, 13 Apr 2021 12:57:06 +0200
4 Subject: [PATCH 164/247] media: atmel: atmel-isc: create register offsets
5 struct
6
7 Create a struct that holds register offsets that are product specific.
8 Add initially the CSC register.
9 This allows each product that contains a variant of the ISC to add their
10 own register offset.
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 | 2 +-
17 drivers/media/platform/atmel/atmel-isc-regs.h | 3 +++
18 drivers/media/platform/atmel/atmel-isc.h | 12 +++++++++++
19 .../media/platform/atmel/atmel-sama5d2-isc.c | 20 +++++++++++++------
20 4 files changed, 30 insertions(+), 7 deletions(-)
21
22 --- a/drivers/media/platform/atmel/atmel-isc-base.c
23 +++ b/drivers/media/platform/atmel/atmel-isc-base.c
24 @@ -2326,7 +2326,7 @@ int isc_pipeline_init(struct isc_device
25 REG_FIELD(ISC_GAM_CTRL, 1, 1),
26 REG_FIELD(ISC_GAM_CTRL, 2, 2),
27 REG_FIELD(ISC_GAM_CTRL, 3, 3),
28 - REG_FIELD(ISC_CSC_CTRL, 0, 0),
29 + REG_FIELD(ISC_CSC_CTRL + isc->offsets.csc, 0, 0),
30 REG_FIELD(ISC_CBC_CTRL, 0, 0),
31 REG_FIELD(ISC_SUB422_CTRL, 0, 0),
32 REG_FIELD(ISC_SUB420_CTRL, 0, 0),
33 --- a/drivers/media/platform/atmel/atmel-isc-regs.h
34 +++ b/drivers/media/platform/atmel/atmel-isc-regs.h
35 @@ -153,6 +153,9 @@
36 /* ISC_Gamma Correction Green Entry Register */
37 #define ISC_GAM_RENTRY 0x00000298
38
39 +/* Offset for CSC register specific to sama5d2 product */
40 +#define ISC_SAMA5D2_CSC_OFFSET 0
41 +
42 /* Color Space Conversion Control Register */
43 #define ISC_CSC_CTRL 0x00000398
44
45 --- a/drivers/media/platform/atmel/atmel-isc.h
46 +++ b/drivers/media/platform/atmel/atmel-isc.h
47 @@ -144,6 +144,14 @@ struct isc_ctrls {
48 #define ISC_PIPE_LINE_NODE_NUM 11
49
50 /*
51 + * struct isc_reg_offsets - ISC device register offsets
52 + * @csc: Offset for the CSC register
53 + */
54 +struct isc_reg_offsets {
55 + u32 csc;
56 +};
57 +
58 +/*
59 * struct isc_device - ISC device driver data/config struct
60 * @regmap: Register map
61 * @hclock: Hclock clock input (refer datasheet)
62 @@ -194,6 +202,8 @@ struct isc_ctrls {
63 *
64 * @config_csc: pointer to a function that initializes product
65 * specific CSC module
66 + *
67 + * @offsets: struct holding the product specific register offsets
68 */
69 struct isc_device {
70 struct regmap *regmap;
71 @@ -265,6 +275,8 @@ struct isc_device {
72 struct {
73 void (*config_csc)(struct isc_device *isc);
74 };
75 +
76 + struct isc_reg_offsets offsets;
77 };
78
79 extern struct isc_format formats_list[];
80 --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
81 +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
82 @@ -59,12 +59,18 @@ static void isc_sama5d2_config_csc(struc
83 struct regmap *regmap = isc->regmap;
84
85 /* Convert RGB to YUV */
86 - regmap_write(regmap, ISC_CSC_YR_YG, 0x42 | (0x81 << 16));
87 - regmap_write(regmap, ISC_CSC_YB_OY, 0x19 | (0x10 << 16));
88 - regmap_write(regmap, ISC_CSC_CBR_CBG, 0xFDA | (0xFB6 << 16));
89 - regmap_write(regmap, ISC_CSC_CBB_OCB, 0x70 | (0x80 << 16));
90 - regmap_write(regmap, ISC_CSC_CRR_CRG, 0x70 | (0xFA2 << 16));
91 - regmap_write(regmap, ISC_CSC_CRB_OCR, 0xFEE | (0x80 << 16));
92 + regmap_write(regmap, ISC_CSC_YR_YG + isc->offsets.csc,
93 + 0x42 | (0x81 << 16));
94 + regmap_write(regmap, ISC_CSC_YB_OY + isc->offsets.csc,
95 + 0x19 | (0x10 << 16));
96 + regmap_write(regmap, ISC_CSC_CBR_CBG + isc->offsets.csc,
97 + 0xFDA | (0xFB6 << 16));
98 + regmap_write(regmap, ISC_CSC_CBB_OCB + isc->offsets.csc,
99 + 0x70 | (0x80 << 16));
100 + regmap_write(regmap, ISC_CSC_CRR_CRG + isc->offsets.csc,
101 + 0x70 | (0xFA2 << 16));
102 + regmap_write(regmap, ISC_CSC_CRB_OCR + isc->offsets.csc,
103 + 0xFEE | (0x80 << 16));
104 }
105
106 /* Gamma table with gamma 1/2.2 */
107 @@ -234,6 +240,8 @@ static int atmel_isc_probe(struct platfo
108
109 isc->config_csc = isc_sama5d2_config_csc;
110
111 + isc->offsets.csc = ISC_SAMA5D2_CSC_OFFSET;
112 +
113 /* sama5d2-isc - 8 bits per beat */
114 isc->dcfg = ISC_DCFG_YMBSIZE_BEATS8 | ISC_DCFG_CMBSIZE_BEATS8;
115