@@ -1354,25 +1354,89 @@ static int stm32_dcmipp_dequeue(const struct device *dev, struct video_buffer **
1354
1354
return 0 ;
1355
1355
}
1356
1356
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
+
1364
1417
static int stm32_dcmipp_get_caps (const struct device * dev , struct video_caps * caps )
1365
1418
{
1366
- const struct stm32_dcmipp_config * config = dev -> config ;
1367
- int ret ;
1419
+ struct stm32_dcmipp_pipe_data * pipe = dev -> data ;
1368
1420
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
+ }
1370
1434
1371
1435
caps -> min_vbuf_count = 1 ;
1372
1436
caps -> min_line_count = LINE_COUNT_HEIGHT ;
1373
1437
caps -> max_line_count = LINE_COUNT_HEIGHT ;
1374
1438
1375
- return ret ;
1439
+ return 0 ;
1376
1440
}
1377
1441
1378
1442
static int stm32_dcmipp_get_frmival (const struct device * dev , struct video_frmival * frmival )
0 commit comments