Skip to content

Commit b91b0e7

Browse files
author
Alain Volmat
committed
video: dcmipp: expose dcmipp caps for all 3 pipes.
Currently the DCMIPP driver rely on a Kconfig in order to select the right sensor resolution / format to pick. This also makes the exposure of caps easier since it can be exposed as: DUMP pipe: same caps as mentioned in Kconfig MAIN pipe: any format supported on this pipe and resolution starting at sensor selected resolution down to 64 times smaller (which is the maximum of the downscale) AUX pipe: same as MAIN except without the semi-planar and planar formats Signed-off-by: Alain Volmat <[email protected]>
1 parent d85d2ba commit b91b0e7

File tree

1 file changed

+82
-9
lines changed

1 file changed

+82
-9
lines changed

drivers/video/video_stm32_dcmipp.c

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,22 +1359,95 @@ static int stm32_dcmipp_dequeue(const struct device *dev, struct video_buffer **
13591359
}
13601360

13611361
/*
1362-
* TODO: caps aren't yet handled hence give back straight the caps given by the
1363-
* source. Normally this should be the intersection of what the source produces
1364-
* vs what the DCMIPP can input (for pipe0) and, for pipe 1 and 2, for a given
1365-
* input format, generate caps based on capabilities, color conversion, decimation
1366-
* etc
1362+
* For MAIN / AUX pipe, it is necessary that the pitch is a multiple of 16 bytes.
1363+
* Give here the multiple in number of pixels, which depends on the format chosen
13671364
*/
1365+
#define DCMIPP_CEIL_DIV_ROUND_UP_MUL(val, div, mul) \
1366+
((((val) + (div) - 1) / (div) + (mul) - 1) / (mul) * (mul))
1367+
1368+
#define DCMIPP_CEIL_DIV(val, div) \
1369+
(((val) + (div) - 1) / (div))
1370+
1371+
#define DCMIPP_VIDEO_FORMAT_CAP(format, pixmul) { \
1372+
.pixelformat = VIDEO_PIX_FMT_##format, \
1373+
.width_min = DCMIPP_CEIL_DIV_ROUND_UP_MUL(CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH, \
1374+
STM32_DCMIPP_MAX_PIPE_SCALE_FACTOR, \
1375+
pixmul), \
1376+
.width_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH / (pixmul) * (pixmul), \
1377+
.height_min = DCMIPP_CEIL_DIV(CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT, \
1378+
STM32_DCMIPP_MAX_PIPE_SCALE_FACTOR), \
1379+
.height_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT, \
1380+
.width_step = pixmul, .height_step = 1, \
1381+
}
1382+
1383+
static const struct video_format_cap stm32_dcmipp_dump_fmt[] = {
1384+
{
1385+
.pixelformat =
1386+
VIDEO_FOURCC_FROM_STR(CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT),
1387+
.width_min = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH,
1388+
.width_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH,
1389+
.height_min = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT,
1390+
.height_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT,
1391+
.width_step = 1, .height_step = 1,
1392+
},
1393+
{0},
1394+
};
1395+
1396+
static const struct video_format_cap stm32_dcmipp_main_fmts[] = {
1397+
DCMIPP_VIDEO_FORMAT_CAP(RGB565, 8),
1398+
DCMIPP_VIDEO_FORMAT_CAP(YUYV, 8),
1399+
DCMIPP_VIDEO_FORMAT_CAP(YVYU, 8),
1400+
DCMIPP_VIDEO_FORMAT_CAP(GREY, 16),
1401+
DCMIPP_VIDEO_FORMAT_CAP(RGB24, 16),
1402+
DCMIPP_VIDEO_FORMAT_CAP(BGR24, 16),
1403+
DCMIPP_VIDEO_FORMAT_CAP(ARGB32, 4),
1404+
DCMIPP_VIDEO_FORMAT_CAP(ABGR32, 4),
1405+
DCMIPP_VIDEO_FORMAT_CAP(RGBA32, 4),
1406+
DCMIPP_VIDEO_FORMAT_CAP(BGRA32, 4),
1407+
DCMIPP_VIDEO_FORMAT_CAP(NV12, 16),
1408+
DCMIPP_VIDEO_FORMAT_CAP(NV21, 16),
1409+
DCMIPP_VIDEO_FORMAT_CAP(NV16, 16),
1410+
DCMIPP_VIDEO_FORMAT_CAP(NV61, 16),
1411+
DCMIPP_VIDEO_FORMAT_CAP(YUV420, 16),
1412+
DCMIPP_VIDEO_FORMAT_CAP(YVU420, 16),
1413+
{0},
1414+
};
1415+
1416+
static const struct video_format_cap stm32_dcmipp_aux_fmts[] = {
1417+
DCMIPP_VIDEO_FORMAT_CAP(RGB565, 8),
1418+
DCMIPP_VIDEO_FORMAT_CAP(YUYV, 8),
1419+
DCMIPP_VIDEO_FORMAT_CAP(YVYU, 8),
1420+
DCMIPP_VIDEO_FORMAT_CAP(GREY, 16),
1421+
DCMIPP_VIDEO_FORMAT_CAP(RGB24, 16),
1422+
DCMIPP_VIDEO_FORMAT_CAP(BGR24, 16),
1423+
DCMIPP_VIDEO_FORMAT_CAP(ARGB32, 4),
1424+
DCMIPP_VIDEO_FORMAT_CAP(ABGR32, 4),
1425+
DCMIPP_VIDEO_FORMAT_CAP(RGBA32, 4),
1426+
DCMIPP_VIDEO_FORMAT_CAP(BGRA32, 4),
1427+
{0},
1428+
};
1429+
13681430
static int stm32_dcmipp_get_caps(const struct device *dev, struct video_caps *caps)
13691431
{
1370-
const struct stm32_dcmipp_config *config = dev->config;
1371-
int ret;
1432+
struct stm32_dcmipp_pipe_data *pipe = dev->data;
13721433

1373-
ret = video_get_caps(config->source_dev, caps);
1434+
switch (pipe->id) {
1435+
case DCMIPP_PIPE0:
1436+
caps->format_caps = stm32_dcmipp_dump_fmt;
1437+
break;
1438+
case DCMIPP_PIPE1:
1439+
caps->format_caps = stm32_dcmipp_main_fmts;
1440+
break;
1441+
case DCMIPP_PIPE2:
1442+
caps->format_caps = stm32_dcmipp_aux_fmts;
1443+
break;
1444+
default:
1445+
CODE_UNREACHABLE;
1446+
}
13741447

13751448
caps->min_vbuf_count = 1;
13761449

1377-
return ret;
1450+
return 0;
13781451
}
13791452

13801453
static int stm32_dcmipp_get_frmival(const struct device *dev, struct video_frmival *frmival)

0 commit comments

Comments
 (0)