Skip to content

Commit b326eac

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 888855d commit b326eac

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
@@ -1355,25 +1355,89 @@ static int stm32_dcmipp_dequeue(const struct device *dev, struct video_buffer **
13551355
return 0;
13561356
}
13571357

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

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

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

1376-
return ret;
1440+
return 0;
13771441
}
13781442

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

0 commit comments

Comments
 (0)