Skip to content

Commit 2ab24f9

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 1df3f73 commit 2ab24f9

File tree

1 file changed

+75
-11
lines changed

1 file changed

+75
-11
lines changed

drivers/video/video_stm32_dcmipp.c

Lines changed: 75 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,25 +1354,89 @@ static int stm32_dcmipp_dequeue(const struct device *dev, struct video_buffer **
13541354
return 0;
13551355
}
13561356

1357-
/*
1358-
* TODO: caps aren't yet handled hence give back straight the caps given by the
1359-
* source. Normally this should be the intersection of what the source produces
1360-
* vs what the DCMIPP can input (for pipe0) and, for pipe 1 and 2, for a given
1361-
* input format, generate caps based on capabilities, color conversion, decimation
1362-
* etc
1363-
*/
1357+
#define DCMIPP_CEIL_DIV(a, b) (((a) + (b) - 1) / (b))
1358+
#define DCMIPP_VIDEO_FORMAT_CAP(format) \
1359+
{ \
1360+
.pixelformat = VIDEO_PIX_FMT_##format, \
1361+
.width_min = DCMIPP_CEIL_DIV(CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH, \
1362+
STM32_DCMIPP_MAX_PIPE_SCALE_FACTOR), \
1363+
.width_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH, \
1364+
.height_min = DCMIPP_CEIL_DIV(CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT, \
1365+
STM32_DCMIPP_MAX_PIPE_SCALE_FACTOR), \
1366+
.height_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT, \
1367+
.width_step = 1, .height_step = 1, \
1368+
}
1369+
1370+
static const struct video_format_cap stm32_dcmipp_dump_fmt[] = {
1371+
{
1372+
.pixelformat =
1373+
VIDEO_FOURCC_FROM_STR(CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT),
1374+
.width_min = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH,
1375+
.width_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH,
1376+
.height_min = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT,
1377+
.height_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT,
1378+
.width_step = 1, .height_step = 1,
1379+
},
1380+
{0},
1381+
};
1382+
1383+
static const struct video_format_cap stm32_dcmipp_main_fmts[] = {
1384+
DCMIPP_VIDEO_FORMAT_CAP(RGB565),
1385+
DCMIPP_VIDEO_FORMAT_CAP(YUYV),
1386+
DCMIPP_VIDEO_FORMAT_CAP(YVYU),
1387+
DCMIPP_VIDEO_FORMAT_CAP(GREY),
1388+
DCMIPP_VIDEO_FORMAT_CAP(RGB24),
1389+
DCMIPP_VIDEO_FORMAT_CAP(BGR24),
1390+
DCMIPP_VIDEO_FORMAT_CAP(ARGB32),
1391+
DCMIPP_VIDEO_FORMAT_CAP(ABGR32),
1392+
DCMIPP_VIDEO_FORMAT_CAP(RGBA32),
1393+
DCMIPP_VIDEO_FORMAT_CAP(BGRA32),
1394+
DCMIPP_VIDEO_FORMAT_CAP(NV12),
1395+
DCMIPP_VIDEO_FORMAT_CAP(NV21),
1396+
DCMIPP_VIDEO_FORMAT_CAP(NV16),
1397+
DCMIPP_VIDEO_FORMAT_CAP(NV61),
1398+
DCMIPP_VIDEO_FORMAT_CAP(YUV420),
1399+
DCMIPP_VIDEO_FORMAT_CAP(YVU420),
1400+
{0},
1401+
};
1402+
1403+
static const struct video_format_cap stm32_dcmipp_aux_fmts[] = {
1404+
DCMIPP_VIDEO_FORMAT_CAP(RGB565),
1405+
DCMIPP_VIDEO_FORMAT_CAP(YUYV),
1406+
DCMIPP_VIDEO_FORMAT_CAP(YVYU),
1407+
DCMIPP_VIDEO_FORMAT_CAP(GREY),
1408+
DCMIPP_VIDEO_FORMAT_CAP(RGB24),
1409+
DCMIPP_VIDEO_FORMAT_CAP(BGR24),
1410+
DCMIPP_VIDEO_FORMAT_CAP(ARGB32),
1411+
DCMIPP_VIDEO_FORMAT_CAP(ABGR32),
1412+
DCMIPP_VIDEO_FORMAT_CAP(RGBA32),
1413+
DCMIPP_VIDEO_FORMAT_CAP(BGRA32),
1414+
{0},
1415+
};
1416+
13641417
static int stm32_dcmipp_get_caps(const struct device *dev, struct video_caps *caps)
13651418
{
1366-
const struct stm32_dcmipp_config *config = dev->config;
1367-
int ret;
1419+
struct stm32_dcmipp_pipe_data *pipe = dev->data;
13681420

1369-
ret = video_get_caps(config->source_dev, caps);
1421+
switch (pipe->id) {
1422+
case DCMIPP_PIPE0:
1423+
caps->format_caps = stm32_dcmipp_dump_fmt;
1424+
break;
1425+
case DCMIPP_PIPE1:
1426+
caps->format_caps = stm32_dcmipp_main_fmts;
1427+
break;
1428+
case DCMIPP_PIPE2:
1429+
caps->format_caps = stm32_dcmipp_aux_fmts;
1430+
break;
1431+
default:
1432+
CODE_UNREACHABLE;
1433+
}
13701434

13711435
caps->min_vbuf_count = 1;
13721436
caps->min_line_count = LINE_COUNT_HEIGHT;
13731437
caps->max_line_count = LINE_COUNT_HEIGHT;
13741438

1375-
return ret;
1439+
return 0;
13761440
}
13771441

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

0 commit comments

Comments
 (0)