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
7 Move the max width and max height constants to the product specific driver
8 and have them in the device struct.
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>
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(-)
19 diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c
20 index 02f1d1c6b06e..ed0048e79f3b 100644
21 --- a/drivers/media/platform/atmel/atmel-isc-base.c
22 +++ b/drivers/media/platform/atmel/atmel-isc-base.c
23 @@ -1216,8 +1216,8 @@ static void isc_try_fse(struct isc_device *isc,
24 * just use the maximum ISC can receive.
27 - pad_cfg->try_crop.width = ISC_MAX_SUPPORT_WIDTH;
28 - pad_cfg->try_crop.height = ISC_MAX_SUPPORT_HEIGHT;
29 + pad_cfg->try_crop.width = isc->max_width;
30 + pad_cfg->try_crop.height = isc->max_height;
32 pad_cfg->try_crop.width = fse.max_width;
33 pad_cfg->try_crop.height = fse.max_height;
34 @@ -1294,10 +1294,10 @@ static int isc_try_fmt(struct isc_device *isc, struct v4l2_format *f,
35 isc->try_config.sd_format = sd_fmt;
37 /* Limit to Atmel ISC hardware capabilities */
38 - if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
39 - pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
40 - if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
41 - pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
42 + if (pixfmt->width > isc->max_width)
43 + pixfmt->width = isc->max_width;
44 + if (pixfmt->height > isc->max_height)
45 + pixfmt->height = isc->max_height;
48 * The mbus format is the one the subdev outputs.
49 @@ -1339,10 +1339,10 @@ static int isc_try_fmt(struct isc_device *isc, struct v4l2_format *f,
50 v4l2_fill_pix_format(pixfmt, &format.format);
52 /* Limit to Atmel ISC hardware capabilities */
53 - if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
54 - pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
55 - if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
56 - pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
57 + if (pixfmt->width > isc->max_width)
58 + pixfmt->width = isc->max_width;
59 + if (pixfmt->height > isc->max_height)
60 + pixfmt->height = isc->max_height;
62 pixfmt->field = V4L2_FIELD_NONE;
63 pixfmt->bytesperline = (pixfmt->width * isc->try_config.bpp) >> 3;
64 @@ -1380,10 +1380,10 @@ static int isc_set_fmt(struct isc_device *isc, struct v4l2_format *f)
67 /* Limit to Atmel ISC hardware capabilities */
68 - if (pixfmt->width > ISC_MAX_SUPPORT_WIDTH)
69 - pixfmt->width = ISC_MAX_SUPPORT_WIDTH;
70 - if (pixfmt->height > ISC_MAX_SUPPORT_HEIGHT)
71 - pixfmt->height = ISC_MAX_SUPPORT_HEIGHT;
72 + if (f->fmt.pix.width > isc->max_width)
73 + f->fmt.pix.width = isc->max_width;
74 + if (f->fmt.pix.height > isc->max_height)
75 + f->fmt.pix.height = isc->max_height;
79 diff --git a/drivers/media/platform/atmel/atmel-isc.h b/drivers/media/platform/atmel/atmel-isc.h
80 index bb43d3a93052..f208fb691ac9 100644
81 --- a/drivers/media/platform/atmel/atmel-isc.h
82 +++ b/drivers/media/platform/atmel/atmel-isc.h
87 -#define ISC_MAX_SUPPORT_WIDTH 2592
88 -#define ISC_MAX_SUPPORT_HEIGHT 1944
90 #define ISC_CLK_MAX_DIV 255
93 @@ -190,6 +187,9 @@ struct isc_ctrls {
94 * @gamma_table: pointer to the table with gamma values, has
95 * gamma_max sets of GAMMA_ENTRIES entries each
96 * @gamma_max: maximum number of sets of inside the gamma_table
98 + * @max_width: maximum frame width, dependent on the internal RAM
99 + * @max_height: maximum frame height, dependent on the internal RAM
102 struct regmap *regmap;
103 @@ -253,6 +253,9 @@ struct isc_device {
104 /* pointer to the defined gamma table */
105 const u32 (*gamma_table)[GAMMA_ENTRIES];
112 extern struct isc_format formats_list[];
113 diff --git a/drivers/media/platform/atmel/atmel-sama5d2-isc.c b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
114 index cba6e6c8810b..39fc8d4f9bdc 100644
115 --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
116 +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
118 #include "atmel-isc-regs.h"
119 #include "atmel-isc.h"
121 -#define ISC_MAX_SUPPORT_WIDTH 2592
122 -#define ISC_MAX_SUPPORT_HEIGHT 1944
123 +#define ISC_SAMA5D2_MAX_SUPPORT_WIDTH 2592
124 +#define ISC_SAMA5D2_MAX_SUPPORT_HEIGHT 1944
126 #define ISC_CLK_MAX_DIV 255
128 @@ -216,6 +216,9 @@ static int atmel_isc_probe(struct platform_device *pdev)
129 isc->gamma_table = isc_sama5d2_gamma_table;
132 + isc->max_width = ISC_SAMA5D2_MAX_SUPPORT_WIDTH;
133 + isc->max_height = ISC_SAMA5D2_MAX_SUPPORT_HEIGHT;
135 ret = isc_pipeline_init(isc);