1 From dda51aa2e4524914d25022864466fa9d8713a5e9 Mon Sep 17 00:00:00 2001
2 From: Eugen Hristev <eugen.hristev@microchip.com>
3 Date: Tue, 13 Apr 2021 12:57:22 +0200
4 Subject: [PATCH 180/247] media: atmel: atmel-isc: move the formats list into
7 The list of input and output formats has to be product specific.
8 Move this list into the product specific code.
9 Have pointers to these arrays inside the device struct.
11 Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
12 Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
13 Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
15 drivers/media/platform/atmel/atmel-isc-base.c | 167 ++----------------
16 drivers/media/platform/atmel/atmel-isc.h | 12 +-
17 .../media/platform/atmel/atmel-sama5d2-isc.c | 136 ++++++++++++++
18 3 files changed, 165 insertions(+), 150 deletions(-)
20 --- a/drivers/media/platform/atmel/atmel-isc-base.c
21 +++ b/drivers/media/platform/atmel/atmel-isc-base.c
22 @@ -45,137 +45,6 @@ module_param(sensor_preferred, uint, 064
23 MODULE_PARM_DESC(sensor_preferred,
24 "Sensor is preferred to output the specified format (1-on 0-off), default 1");
26 -/* This is a list of the formats that the ISC can *output* */
27 -const struct isc_format controller_formats[] = {
29 - .fourcc = V4L2_PIX_FMT_ARGB444,
32 - .fourcc = V4L2_PIX_FMT_ARGB555,
35 - .fourcc = V4L2_PIX_FMT_RGB565,
38 - .fourcc = V4L2_PIX_FMT_ABGR32,
41 - .fourcc = V4L2_PIX_FMT_XBGR32,
44 - .fourcc = V4L2_PIX_FMT_YUV420,
47 - .fourcc = V4L2_PIX_FMT_YUYV,
50 - .fourcc = V4L2_PIX_FMT_YUV422P,
53 - .fourcc = V4L2_PIX_FMT_GREY,
56 - .fourcc = V4L2_PIX_FMT_Y10,
60 -/* This is a list of formats that the ISC can receive as *input* */
61 -struct isc_format formats_list[] = {
63 - .fourcc = V4L2_PIX_FMT_SBGGR8,
64 - .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8,
65 - .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
66 - .cfa_baycfg = ISC_BAY_CFG_BGBG,
69 - .fourcc = V4L2_PIX_FMT_SGBRG8,
70 - .mbus_code = MEDIA_BUS_FMT_SGBRG8_1X8,
71 - .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
72 - .cfa_baycfg = ISC_BAY_CFG_GBGB,
75 - .fourcc = V4L2_PIX_FMT_SGRBG8,
76 - .mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8,
77 - .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
78 - .cfa_baycfg = ISC_BAY_CFG_GRGR,
81 - .fourcc = V4L2_PIX_FMT_SRGGB8,
82 - .mbus_code = MEDIA_BUS_FMT_SRGGB8_1X8,
83 - .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
84 - .cfa_baycfg = ISC_BAY_CFG_RGRG,
87 - .fourcc = V4L2_PIX_FMT_SBGGR10,
88 - .mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,
89 - .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TEN,
90 - .cfa_baycfg = ISC_BAY_CFG_RGRG,
93 - .fourcc = V4L2_PIX_FMT_SGBRG10,
94 - .mbus_code = MEDIA_BUS_FMT_SGBRG10_1X10,
95 - .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TEN,
96 - .cfa_baycfg = ISC_BAY_CFG_GBGB,
99 - .fourcc = V4L2_PIX_FMT_SGRBG10,
100 - .mbus_code = MEDIA_BUS_FMT_SGRBG10_1X10,
101 - .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TEN,
102 - .cfa_baycfg = ISC_BAY_CFG_GRGR,
105 - .fourcc = V4L2_PIX_FMT_SRGGB10,
106 - .mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10,
107 - .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TEN,
108 - .cfa_baycfg = ISC_BAY_CFG_RGRG,
111 - .fourcc = V4L2_PIX_FMT_SBGGR12,
112 - .mbus_code = MEDIA_BUS_FMT_SBGGR12_1X12,
113 - .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TWELVE,
114 - .cfa_baycfg = ISC_BAY_CFG_BGBG,
117 - .fourcc = V4L2_PIX_FMT_SGBRG12,
118 - .mbus_code = MEDIA_BUS_FMT_SGBRG12_1X12,
119 - .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TWELVE,
120 - .cfa_baycfg = ISC_BAY_CFG_GBGB,
123 - .fourcc = V4L2_PIX_FMT_SGRBG12,
124 - .mbus_code = MEDIA_BUS_FMT_SGRBG12_1X12,
125 - .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TWELVE,
126 - .cfa_baycfg = ISC_BAY_CFG_GRGR,
129 - .fourcc = V4L2_PIX_FMT_SRGGB12,
130 - .mbus_code = MEDIA_BUS_FMT_SRGGB12_1X12,
131 - .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TWELVE,
132 - .cfa_baycfg = ISC_BAY_CFG_RGRG,
135 - .fourcc = V4L2_PIX_FMT_GREY,
136 - .mbus_code = MEDIA_BUS_FMT_Y8_1X8,
137 - .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
140 - .fourcc = V4L2_PIX_FMT_YUYV,
141 - .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8,
142 - .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
145 - .fourcc = V4L2_PIX_FMT_RGB565,
146 - .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE,
147 - .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
150 - .fourcc = V4L2_PIX_FMT_Y10,
151 - .mbus_code = MEDIA_BUS_FMT_Y10_1X10,
152 - .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TEN,
157 #define ISC_IS_FORMAT_RAW(mbus_code) \
158 (((mbus_code) & 0xf000) == 0x3000)
160 @@ -919,24 +788,25 @@ static int isc_querycap(struct file *fil
161 static int isc_enum_fmt_vid_cap(struct file *file, void *priv,
162 struct v4l2_fmtdesc *f)
164 + struct isc_device *isc = video_drvdata(file);
165 u32 index = f->index;
166 u32 i, supported_index;
168 - if (index < ARRAY_SIZE(controller_formats)) {
169 - f->pixelformat = controller_formats[index].fourcc;
170 + if (index < isc->controller_formats_size) {
171 + f->pixelformat = isc->controller_formats[index].fourcc;
175 - index -= ARRAY_SIZE(controller_formats);
176 + index -= isc->controller_formats_size;
180 - for (i = 0; i < ARRAY_SIZE(formats_list); i++) {
181 - if (!ISC_IS_FORMAT_RAW(formats_list[i].mbus_code) ||
182 - !formats_list[i].sd_support)
183 + for (i = 0; i < isc->formats_list_size; i++) {
184 + if (!ISC_IS_FORMAT_RAW(isc->formats_list[i].mbus_code) ||
185 + !isc->formats_list[i].sd_support)
187 if (supported_index == index) {
188 - f->pixelformat = formats_list[i].fourcc;
189 + f->pixelformat = isc->formats_list[i].fourcc;
193 @@ -1477,8 +1347,8 @@ static int isc_enum_framesizes(struct fi
194 if (isc->user_formats[i]->fourcc == fsize->pixel_format)
197 - for (i = 0; i < ARRAY_SIZE(controller_formats); i++)
198 - if (controller_formats[i].fourcc == fsize->pixel_format)
199 + for (i = 0; i < isc->controller_formats_size; i++)
200 + if (isc->controller_formats[i].fourcc == fsize->pixel_format)
204 @@ -1514,8 +1384,8 @@ static int isc_enum_frameintervals(struc
205 if (isc->user_formats[i]->fourcc == fival->pixel_format)
208 - for (i = 0; i < ARRAY_SIZE(controller_formats); i++)
209 - if (controller_formats[i].fourcc == fival->pixel_format)
210 + for (i = 0; i < isc->controller_formats_size; i++)
211 + if (isc->controller_formats[i].fourcc == fival->pixel_format)
215 @@ -2126,12 +1996,13 @@ static void isc_async_unbind(struct v4l2
216 v4l2_ctrl_handler_free(&isc->ctrls.handler);
219 -static struct isc_format *find_format_by_code(unsigned int code, int *index)
220 +static struct isc_format *find_format_by_code(struct isc_device *isc,
221 + unsigned int code, int *index)
223 - struct isc_format *fmt = &formats_list[0];
224 + struct isc_format *fmt = &isc->formats_list[0];
227 - for (i = 0; i < ARRAY_SIZE(formats_list); i++) {
228 + for (i = 0; i < isc->formats_list_size; i++) {
229 if (fmt->mbus_code == code) {
232 @@ -2148,7 +2019,7 @@ static int isc_formats_init(struct isc_d
233 struct isc_format *fmt;
234 struct v4l2_subdev *subdev = isc->current_subdev->sd;
235 unsigned int num_fmts, i, j;
236 - u32 list_size = ARRAY_SIZE(formats_list);
237 + u32 list_size = isc->formats_list_size;
238 struct v4l2_subdev_mbus_code_enum mbus_code = {
239 .which = V4L2_SUBDEV_FORMAT_ACTIVE,
241 @@ -2158,7 +2029,7 @@ static int isc_formats_init(struct isc_d
245 - fmt = find_format_by_code(mbus_code.code, &i);
246 + fmt = find_format_by_code(isc, mbus_code.code, &i);
248 v4l2_warn(&isc->v4l2_dev, "Mbus code %x not supported\n",
250 @@ -2179,7 +2050,7 @@ static int isc_formats_init(struct isc_d
251 if (!isc->user_formats)
254 - fmt = &formats_list[0];
255 + fmt = &isc->formats_list[0];
256 for (i = 0, j = 0; i < list_size; i++) {
258 isc->user_formats[j++] = fmt;
259 --- a/drivers/media/platform/atmel/atmel-isc.h
260 +++ b/drivers/media/platform/atmel/atmel-isc.h
261 @@ -236,6 +236,12 @@ struct isc_reg_offsets {
262 * specific v4l2 controls.
264 * @offsets: struct holding the product specific register offsets
265 + * @controller_formats: pointer to the array of possible formats that the
266 + * controller can output
267 + * @formats_list: pointer to the array of possible formats that can
268 + * be used as an input to the controller
269 + * @controller_formats_size: size of controller_formats array
270 + * @formats_list_size: size of formats_list array
273 struct regmap *regmap;
274 @@ -317,10 +323,12 @@ struct isc_device {
277 struct isc_reg_offsets offsets;
278 + const struct isc_format *controller_formats;
279 + struct isc_format *formats_list;
280 + u32 controller_formats_size;
281 + u32 formats_list_size;
284 -extern struct isc_format formats_list[];
285 -extern const struct isc_format controller_formats[];
286 extern const struct regmap_config isc_regmap_config;
287 extern const struct v4l2_async_notifier_operations isc_async_ops;
289 --- a/drivers/media/platform/atmel/atmel-sama5d2-isc.c
290 +++ b/drivers/media/platform/atmel/atmel-sama5d2-isc.c
293 #define ISC_CLK_MAX_DIV 255
295 +/* This is a list of the formats that the ISC can *output* */
296 +static const struct isc_format sama5d2_controller_formats[] = {
298 + .fourcc = V4L2_PIX_FMT_ARGB444,
301 + .fourcc = V4L2_PIX_FMT_ARGB555,
304 + .fourcc = V4L2_PIX_FMT_RGB565,
307 + .fourcc = V4L2_PIX_FMT_ABGR32,
310 + .fourcc = V4L2_PIX_FMT_XBGR32,
313 + .fourcc = V4L2_PIX_FMT_YUV420,
316 + .fourcc = V4L2_PIX_FMT_YUYV,
319 + .fourcc = V4L2_PIX_FMT_YUV422P,
322 + .fourcc = V4L2_PIX_FMT_GREY,
325 + .fourcc = V4L2_PIX_FMT_Y10,
329 +/* This is a list of formats that the ISC can receive as *input* */
330 +static struct isc_format sama5d2_formats_list[] = {
332 + .fourcc = V4L2_PIX_FMT_SBGGR8,
333 + .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8,
334 + .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
335 + .cfa_baycfg = ISC_BAY_CFG_BGBG,
338 + .fourcc = V4L2_PIX_FMT_SGBRG8,
339 + .mbus_code = MEDIA_BUS_FMT_SGBRG8_1X8,
340 + .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
341 + .cfa_baycfg = ISC_BAY_CFG_GBGB,
344 + .fourcc = V4L2_PIX_FMT_SGRBG8,
345 + .mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8,
346 + .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
347 + .cfa_baycfg = ISC_BAY_CFG_GRGR,
350 + .fourcc = V4L2_PIX_FMT_SRGGB8,
351 + .mbus_code = MEDIA_BUS_FMT_SRGGB8_1X8,
352 + .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
353 + .cfa_baycfg = ISC_BAY_CFG_RGRG,
356 + .fourcc = V4L2_PIX_FMT_SBGGR10,
357 + .mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10,
358 + .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TEN,
359 + .cfa_baycfg = ISC_BAY_CFG_RGRG,
362 + .fourcc = V4L2_PIX_FMT_SGBRG10,
363 + .mbus_code = MEDIA_BUS_FMT_SGBRG10_1X10,
364 + .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TEN,
365 + .cfa_baycfg = ISC_BAY_CFG_GBGB,
368 + .fourcc = V4L2_PIX_FMT_SGRBG10,
369 + .mbus_code = MEDIA_BUS_FMT_SGRBG10_1X10,
370 + .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TEN,
371 + .cfa_baycfg = ISC_BAY_CFG_GRGR,
374 + .fourcc = V4L2_PIX_FMT_SRGGB10,
375 + .mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10,
376 + .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TEN,
377 + .cfa_baycfg = ISC_BAY_CFG_RGRG,
380 + .fourcc = V4L2_PIX_FMT_SBGGR12,
381 + .mbus_code = MEDIA_BUS_FMT_SBGGR12_1X12,
382 + .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TWELVE,
383 + .cfa_baycfg = ISC_BAY_CFG_BGBG,
386 + .fourcc = V4L2_PIX_FMT_SGBRG12,
387 + .mbus_code = MEDIA_BUS_FMT_SGBRG12_1X12,
388 + .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TWELVE,
389 + .cfa_baycfg = ISC_BAY_CFG_GBGB,
392 + .fourcc = V4L2_PIX_FMT_SGRBG12,
393 + .mbus_code = MEDIA_BUS_FMT_SGRBG12_1X12,
394 + .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TWELVE,
395 + .cfa_baycfg = ISC_BAY_CFG_GRGR,
398 + .fourcc = V4L2_PIX_FMT_SRGGB12,
399 + .mbus_code = MEDIA_BUS_FMT_SRGGB12_1X12,
400 + .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TWELVE,
401 + .cfa_baycfg = ISC_BAY_CFG_RGRG,
404 + .fourcc = V4L2_PIX_FMT_GREY,
405 + .mbus_code = MEDIA_BUS_FMT_Y8_1X8,
406 + .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
409 + .fourcc = V4L2_PIX_FMT_YUYV,
410 + .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8,
411 + .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
414 + .fourcc = V4L2_PIX_FMT_RGB565,
415 + .mbus_code = MEDIA_BUS_FMT_RGB565_2X8_LE,
416 + .pfe_cfg0_bps = ISC_PFE_CFG0_BPS_EIGHT,
419 + .fourcc = V4L2_PIX_FMT_Y10,
420 + .mbus_code = MEDIA_BUS_FMT_Y10_1X10,
421 + .pfe_cfg0_bps = ISC_PFG_CFG0_BPS_TEN,
426 static void isc_sama5d2_config_csc(struct isc_device *isc)
428 struct regmap *regmap = isc->regmap;
429 @@ -310,6 +441,11 @@ static int atmel_isc_probe(struct platfo
430 isc->offsets.version = ISC_SAMA5D2_VERSION_OFFSET;
431 isc->offsets.his_entry = ISC_SAMA5D2_HIS_ENTRY_OFFSET;
433 + isc->controller_formats = sama5d2_controller_formats;
434 + isc->controller_formats_size = ARRAY_SIZE(sama5d2_controller_formats);
435 + isc->formats_list = sama5d2_formats_list;
436 + isc->formats_list_size = ARRAY_SIZE(sama5d2_formats_list);
438 /* sama5d2-isc - 8 bits per beat */
439 isc->dcfg = ISC_DCFG_YMBSIZE_BEATS8 | ISC_DCFG_CMBSIZE_BEATS8;