afa89ed9166701c028e78f8e0acf389b15ce800f
[openwrt/staging/ldir.git] / target / linux / at91 / patches-5.10 / 160-media-atmel-atmel-isc-specialize-max-width-and-max-h.patch
1 From b51819e17260af2ecc152b7dcd61e63bcaa35edf Mon Sep 17 00:00:00 2001
2 From: Eugen Hristev <eugen.hristev@microchip.com>
3 Date: Tue, 13 Apr 2021 12:57:02 +0200
4 Subject: [PATCH 160/247] media: atmel: atmel-isc: specialize max width and max
5 height
6
7 Move the max width and max height constants to the product specific driver
8 and have them in the device struct.
9
10 Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
11 Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
12 Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
13 ---
14 drivers/media/platform/atmel/atmel-isc-base.c | 28 +++++++++----------
15 drivers/media/platform/atmel/atmel-isc.h | 9 ++++--
16 .../media/platform/atmel/atmel-sama5d2-isc.c | 7 +++--
17 3 files changed, 25 insertions(+), 19 deletions(-)
18
19 --- a/drivers/media/platform/atmel/atmel-isc-base.c
20 +++ b/drivers/media/platform/atmel/atmel-isc-base.c
21 @@ -1216,8 +1216,8 @@ static void isc_try_fse(struct isc_devic
22 * just use the maximum ISC can receive.
23 */
24 if (ret) {
25 - pad_cfg->try_crop.width = ISC_MAX_SUPPORT_WIDTH;
26 - pad_cfg->try_crop.height = ISC_MAX_SUPPORT_HEIGHT;
27 + pad_cfg->try_crop.width = isc->max_width;
28 + pad_cfg->try_crop.height = isc->max_height;
29 } else {
30 pad_cfg->try_crop.width = fse.max_width;
31 pad_cfg->try_crop.height = fse.max_height;
32 @@ -1294,10 +1294,10 @@ static int isc_try_fmt(struct isc_device
33 isc->try_config.sd_format = sd_fmt;
34
35 /* Limit to Atmel ISC hardware capabilities */
36 - if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
37 - pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
38 - if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
39 - pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
40 + if (pixfmt->width > isc->max_width)
41 + pixfmt->width = isc->max_width;
42 + if (pixfmt->height > isc->max_height)
43 + pixfmt->height = isc->max_height;
44
45 /*
46 * The mbus format is the one the subdev outputs.
47 @@ -1339,10 +1339,10 @@ static int isc_try_fmt(struct isc_device
48 v4l2_fill_pix_format(pixfmt, &format.format);
49
50 /* Limit to Atmel ISC hardware capabilities */
51 - if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
52 - pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
53 - if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
54 - pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
55 + if (pixfmt->width > isc->max_width)
56 + pixfmt->width = isc->max_width;
57 + if (pixfmt->height > isc->max_height)
58 + pixfmt->height = isc->max_height;
59
60 pixfmt->field = V4L2_FIELD_NONE;
61 pixfmt->bytesperline = (pixfmt->width * isc->try_config.bpp) >> 3;
62 @@ -1380,10 +1380,10 @@ static int isc_set_fmt(struct isc_device
63 return ret;
64
65 /* Limit to Atmel ISC hardware capabilities */
66 - if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
67 - pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
68 - if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
69 - pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
70 + if (f->fmt.pix.width > isc->max_width)
71 + f->fmt.pix.width = isc->max_width;
72 + if (f->fmt.pix.height > isc->max_height)
73 + f->fmt.pix.height = isc->max_height;
74
75 isc->fmt = *f;
76
77 --- a/drivers/media/platform/atmel/atmel-isc.h
78 +++ b/drivers/media/platform/atmel/atmel-isc.h
79 @@ -10,9 +10,6 @@
80 */
81 #ifndef _ATMEL_ISC_H_
82
83 -#define ISC_MAX_SUPPORT_WIDTH 2592
84 -#define ISC_MAX_SUPPORT_HEIGHT 1944
85 -
86 #define ISC_CLK_MAX_DIV 255
87
88 enum isc_clk_id {
89 @@ -190,6 +187,9 @@ struct isc_ctrls {
90 * @gamma_table: pointer to the table with gamma values, has
91 * gamma_max sets of GAMMA_ENTRIES entries each
92 * @gamma_max: maximum number of sets of inside the gamma_table
93 + *
94 + * @max_width: maximum frame width, dependent on the internal RAM
95 + * @max_height: maximum frame height, dependent on the internal RAM
96 */
97 struct isc_device {
98 struct regmap *regmap;
99 @@ -253,6 +253,9 @@ struct isc_device {
100 /* pointer to the defined gamma table */
101 const u32 (*gamma_table)[GAMMA_ENTRIES];
102 u32 gamma_max;
103 +
104 + u32 max_width;
105 + u32 max_height;
106 };
107
108 extern struct isc_format formats_list[];
109 --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
110 +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
111 @@ -49,8 +49,8 @@
112 #include "atmel-isc-regs.h"
113 #include "atmel-isc.h"
114
115 -#define ISC_MAX_SUPPORT_WIDTH 2592
116 -#define ISC_MAX_SUPPORT_HEIGHT 1944
117 +#define ISC_SAMA5D2_MAX_SUPPORT_WIDTH 2592
118 +#define ISC_SAMA5D2_MAX_SUPPORT_HEIGHT 1944
119
120 #define ISC_CLK_MAX_DIV 255
121
122 @@ -216,6 +216,9 @@ static int atmel_isc_probe(struct platfo
123 isc->gamma_table = isc_sama5d2_gamma_table;
124 isc->gamma_max = 2;
125
126 + isc->max_width = ISC_SAMA5D2_MAX_SUPPORT_WIDTH;
127 + isc->max_height = ISC_SAMA5D2_MAX_SUPPORT_HEIGHT;
128 +
129 ret = isc_pipeline_init(isc);
130 if (ret)
131 return ret;