Skip to content

Commit 126aaf6

Browse files
Alain Volmatcfriedt
authored andcommitted
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 c8092a6 commit 126aaf6

File tree

1 file changed

+81
-9
lines changed

1 file changed

+81
-9
lines changed

drivers/video/video_stm32_dcmipp.c

Lines changed: 81 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,22 +1331,94 @@ static int stm32_dcmipp_dequeue(const struct device *dev, struct video_buffer **
13311331
}
13321332

13331333
/*
1334-
* TODO: caps aren't yet handled hence give back straight the caps given by the
1335-
* source. Normally this should be the intersection of what the source produces
1336-
* vs what the DCMIPP can input (for pipe0) and, for pipe 1 and 2, for a given
1337-
* input format, generate caps based on capabilities, color conversion, decimation
1338-
* etc
1334+
* For MAIN / AUX pipe, it is necessary that the pitch is a multiple of 16 bytes.
1335+
* Give here the multiple in number of pixels, which depends on the format chosen
13391336
*/
1337+
#define DCMIPP_CEIL_DIV_ROUND_UP_MUL(val, div, mul) \
1338+
((((val) + (div) - 1) / (div) + (mul) - 1) / (mul) * (mul))
1339+
1340+
#define DCMIPP_CEIL_DIV(val, div) \
1341+
(((val) + (div) - 1) / (div))
1342+
1343+
#define DCMIPP_VIDEO_FORMAT_CAP(format, pixmul) { \
1344+
.pixelformat = VIDEO_PIX_FMT_##format, \
1345+
.width_min = DCMIPP_CEIL_DIV_ROUND_UP_MUL(CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH, \
1346+
STM32_DCMIPP_MAX_PIPE_SCALE_FACTOR, \
1347+
pixmul), \
1348+
.width_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH / (pixmul) * (pixmul), \
1349+
.height_min = DCMIPP_CEIL_DIV(CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT, \
1350+
STM32_DCMIPP_MAX_PIPE_SCALE_FACTOR), \
1351+
.height_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT, \
1352+
.width_step = pixmul, .height_step = 1, \
1353+
}
1354+
1355+
static const struct video_format_cap stm32_dcmipp_dump_fmt[] = {
1356+
{
1357+
.pixelformat = VIDEO_FOURCC_FROM_STR(CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT),
1358+
.width_min = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH,
1359+
.width_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH,
1360+
.height_min = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT,
1361+
.height_max = CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT,
1362+
.width_step = 1, .height_step = 1,
1363+
},
1364+
{0},
1365+
};
1366+
1367+
static const struct video_format_cap stm32_dcmipp_main_fmts[] = {
1368+
DCMIPP_VIDEO_FORMAT_CAP(RGB565, 8),
1369+
DCMIPP_VIDEO_FORMAT_CAP(YUYV, 8),
1370+
DCMIPP_VIDEO_FORMAT_CAP(YVYU, 8),
1371+
DCMIPP_VIDEO_FORMAT_CAP(GREY, 16),
1372+
DCMIPP_VIDEO_FORMAT_CAP(RGB24, 16),
1373+
DCMIPP_VIDEO_FORMAT_CAP(BGR24, 16),
1374+
DCMIPP_VIDEO_FORMAT_CAP(ARGB32, 4),
1375+
DCMIPP_VIDEO_FORMAT_CAP(ABGR32, 4),
1376+
DCMIPP_VIDEO_FORMAT_CAP(RGBA32, 4),
1377+
DCMIPP_VIDEO_FORMAT_CAP(BGRA32, 4),
1378+
DCMIPP_VIDEO_FORMAT_CAP(NV12, 16),
1379+
DCMIPP_VIDEO_FORMAT_CAP(NV21, 16),
1380+
DCMIPP_VIDEO_FORMAT_CAP(NV16, 16),
1381+
DCMIPP_VIDEO_FORMAT_CAP(NV61, 16),
1382+
DCMIPP_VIDEO_FORMAT_CAP(YUV420, 16),
1383+
DCMIPP_VIDEO_FORMAT_CAP(YVU420, 16),
1384+
{0},
1385+
};
1386+
1387+
static const struct video_format_cap stm32_dcmipp_aux_fmts[] = {
1388+
DCMIPP_VIDEO_FORMAT_CAP(RGB565, 8),
1389+
DCMIPP_VIDEO_FORMAT_CAP(YUYV, 8),
1390+
DCMIPP_VIDEO_FORMAT_CAP(YVYU, 8),
1391+
DCMIPP_VIDEO_FORMAT_CAP(GREY, 16),
1392+
DCMIPP_VIDEO_FORMAT_CAP(RGB24, 16),
1393+
DCMIPP_VIDEO_FORMAT_CAP(BGR24, 16),
1394+
DCMIPP_VIDEO_FORMAT_CAP(ARGB32, 4),
1395+
DCMIPP_VIDEO_FORMAT_CAP(ABGR32, 4),
1396+
DCMIPP_VIDEO_FORMAT_CAP(RGBA32, 4),
1397+
DCMIPP_VIDEO_FORMAT_CAP(BGRA32, 4),
1398+
{0},
1399+
};
1400+
13401401
static int stm32_dcmipp_get_caps(const struct device *dev, struct video_caps *caps)
13411402
{
1342-
const struct stm32_dcmipp_config *config = dev->config;
1343-
int ret;
1403+
struct stm32_dcmipp_pipe_data *pipe = dev->data;
13441404

1345-
ret = video_get_caps(config->source_dev, caps);
1405+
switch (pipe->id) {
1406+
case DCMIPP_PIPE0:
1407+
caps->format_caps = stm32_dcmipp_dump_fmt;
1408+
break;
1409+
case DCMIPP_PIPE1:
1410+
caps->format_caps = stm32_dcmipp_main_fmts;
1411+
break;
1412+
case DCMIPP_PIPE2:
1413+
caps->format_caps = stm32_dcmipp_aux_fmts;
1414+
break;
1415+
default:
1416+
CODE_UNREACHABLE;
1417+
}
13461418

13471419
caps->min_vbuf_count = 1;
13481420

1349-
return ret;
1421+
return 0;
13501422
}
13511423

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

0 commit comments

Comments
 (0)