@@ -88,13 +88,13 @@ static int video_esp32_reload_dma(struct video_esp32_data *data)
88
88
89
89
ret = dma_reload (cfg -> dma_dev , cfg -> rx_dma_channel , 0 , (uint32_t )data -> active_vbuf -> buffer ,
90
90
data -> active_vbuf -> bytesused );
91
- if (ret ) {
91
+ if (ret < 0 ) {
92
92
LOG_ERR ("Unable to reload DMA (%d)" , ret );
93
93
return ret ;
94
94
}
95
95
96
96
ret = dma_start (cfg -> dma_dev , cfg -> rx_dma_channel );
97
- if (ret ) {
97
+ if (ret < 0 ) {
98
98
LOG_ERR ("Unable to start DMA (%d)" , ret );
99
99
return ret ;
100
100
}
@@ -260,7 +260,7 @@ static int video_esp32_get_fmt(const struct device *dev, struct video_format *fm
260
260
LOG_DBG ("Get format" );
261
261
262
262
ret = video_get_format (cfg -> source_dev , fmt );
263
- if (ret ) {
263
+ if (ret < 0 ) {
264
264
LOG_ERR ("Failed to get format from source" );
265
265
return ret ;
266
266
}
@@ -389,6 +389,34 @@ static int video_esp32_init(const struct device *dev)
389
389
return 0 ;
390
390
}
391
391
392
+ int video_esp32_set_selection (const struct device * dev , struct video_selection * sel )
393
+ {
394
+ struct video_esp32_data * data = dev -> data ;
395
+ const struct video_esp32_config * cfg = dev -> config ;
396
+ int ret ;
397
+
398
+ ret = video_set_selection (cfg -> source_dev , sel );
399
+ if (ret < 0 ) {
400
+ LOG_ERR ("Failed to set selection on source device" );
401
+ return ret ;
402
+ }
403
+
404
+ ret = video_get_format (cfg -> source_dev , & data -> video_format );
405
+ if (ret < 0 ) {
406
+ LOG_ERR ("Failed to get format from source device" );
407
+ return ret ;
408
+ }
409
+
410
+ return 0 ;
411
+ }
412
+
413
+ int video_esp32_get_selection (const struct device * dev , struct video_selection * sel )
414
+ {
415
+ const struct video_esp32_config * cfg = dev -> config ;
416
+
417
+ return video_get_selection (cfg -> source_dev , sel );
418
+ }
419
+
392
420
static DEVICE_API (video , esp32_driver_api ) = {
393
421
/* mandatory callbacks */
394
422
.set_format = video_esp32_set_fmt ,
@@ -399,6 +427,8 @@ static DEVICE_API(video, esp32_driver_api) = {
399
427
.enqueue = video_esp32_enqueue ,
400
428
.dequeue = video_esp32_dequeue ,
401
429
.flush = video_esp32_flush ,
430
+ .set_selection = video_esp32_set_selection ,
431
+ .get_selection = video_esp32_get_selection ,
402
432
#ifdef CONFIG_POLL
403
433
.set_signal = video_esp32_set_signal ,
404
434
#endif
0 commit comments