7b8e8ed697be8b495bc8d8f147e188ebdcf0d117
[openwrt/openwrt.git] / target / linux / at91 / patches-5.15 / 162-media-atmel-atmel-isc-extract-CSC-submodule-config-i.patch
1 From 6ccda3cf6a102ac4f6e21386d0dd0fedfb066525 Mon Sep 17 00:00:00 2001
2 From: Eugen Hristev <eugen.hristev@microchip.com>
3 Date: Tue, 13 Apr 2021 12:57:04 +0200
4 Subject: [PATCH 162/247] media: atmel: atmel-isc: extract CSC submodule config
5 into separate function
6
7 The CSC submodule is a part of the atmel-isc pipeline, and stands for
8 Color Space Conversion. It is used to apply a matrix transformation to
9 RGB pixels to convert them to the YUV components.
10 The CSC submodule should be initialized in the product specific driver
11 as it's product specific. Other products can implement it differently.
12
13 [hverkuil: made isc_sama5d2_config_csc static]
14
15 Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
16 Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
17 Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
18 ---
19 drivers/media/platform/atmel/atmel-isc-base.c | 8 +-------
20 drivers/media/platform/atmel/atmel-isc.h | 7 +++++++
21 drivers/media/platform/atmel/atmel-sama5d2-isc.c | 15 +++++++++++++++
22 3 files changed, 23 insertions(+), 7 deletions(-)
23
24 --- a/drivers/media/platform/atmel/atmel-isc-base.c
25 +++ b/drivers/media/platform/atmel/atmel-isc-base.c
26 @@ -654,13 +654,7 @@ static void isc_set_pipeline(struct isc_
27 regmap_bulk_write(regmap, ISC_GAM_GENTRY, gamma, GAMMA_ENTRIES);
28 regmap_bulk_write(regmap, ISC_GAM_RENTRY, gamma, GAMMA_ENTRIES);
29
30 - /* Convert RGB to YUV */
31 - regmap_write(regmap, ISC_CSC_YR_YG, 0x42 | (0x81 << 16));
32 - regmap_write(regmap, ISC_CSC_YB_OY, 0x19 | (0x10 << 16));
33 - regmap_write(regmap, ISC_CSC_CBR_CBG, 0xFDA | (0xFB6 << 16));
34 - regmap_write(regmap, ISC_CSC_CBB_OCB, 0x70 | (0x80 << 16));
35 - regmap_write(regmap, ISC_CSC_CRR_CRG, 0x70 | (0xFA2 << 16));
36 - regmap_write(regmap, ISC_CSC_CRB_OCR, 0xFEE | (0x80 << 16));
37 + isc->config_csc(isc);
38
39 regmap_write(regmap, ISC_CBC_BRIGHT, ctrls->brightness);
40 regmap_write(regmap, ISC_CBC_CONTRAST, ctrls->contrast);
41 --- a/drivers/media/platform/atmel/atmel-isc.h
42 +++ b/drivers/media/platform/atmel/atmel-isc.h
43 @@ -191,6 +191,9 @@ struct isc_ctrls {
44 *
45 * @max_width: maximum frame width, dependent on the internal RAM
46 * @max_height: maximum frame height, dependent on the internal RAM
47 + *
48 + * @config_csc: pointer to a function that initializes product
49 + * specific CSC module
50 */
51 struct isc_device {
52 struct regmap *regmap;
53 @@ -258,6 +261,10 @@ struct isc_device {
54
55 u32 max_width;
56 u32 max_height;
57 +
58 + struct {
59 + void (*config_csc)(struct isc_device *isc);
60 + };
61 };
62
63 extern struct isc_format formats_list[];
64 --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
65 +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
66 @@ -54,6 +54,19 @@
67
68 #define ISC_CLK_MAX_DIV 255
69
70 +static void isc_sama5d2_config_csc(struct isc_device *isc)
71 +{
72 + struct regmap *regmap = isc->regmap;
73 +
74 + /* Convert RGB to YUV */
75 + regmap_write(regmap, ISC_CSC_YR_YG, 0x42 | (0x81 << 16));
76 + regmap_write(regmap, ISC_CSC_YB_OY, 0x19 | (0x10 << 16));
77 + regmap_write(regmap, ISC_CSC_CBR_CBG, 0xFDA | (0xFB6 << 16));
78 + regmap_write(regmap, ISC_CSC_CBB_OCB, 0x70 | (0x80 << 16));
79 + regmap_write(regmap, ISC_CSC_CRR_CRG, 0x70 | (0xFA2 << 16));
80 + regmap_write(regmap, ISC_CSC_CRB_OCR, 0xFEE | (0x80 << 16));
81 +}
82 +
83 /* Gamma table with gamma 1/2.2 */
84 static const u32 isc_sama5d2_gamma_table[][GAMMA_ENTRIES] = {
85 /* 0 --> gamma 1/1.8 */
86 @@ -219,6 +232,8 @@ static int atmel_isc_probe(struct platfo
87 isc->max_width = ISC_SAMA5D2_MAX_SUPPORT_WIDTH;
88 isc->max_height = ISC_SAMA5D2_MAX_SUPPORT_HEIGHT;
89
90 + isc->config_csc = isc_sama5d2_config_csc;
91 +
92 /* sama5d2-isc - 8 bits per beat */
93 isc->dcfg = ISC_DCFG_YMBSIZE_BEATS8 | ISC_DCFG_CMBSIZE_BEATS8;
94