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