9
9
#include <zephyr/drivers/gpio.h>
10
10
#include <zephyr/drivers/i2c.h>
11
11
#include <zephyr/drivers/video.h>
12
+ #include <zephyr/drivers/video-controls.h>
12
13
#include <zephyr/logging/log.h>
13
14
14
15
LOG_MODULE_REGISTER (video_ov7670 , CONFIG_VIDEO_LOG_LEVEL );
@@ -181,6 +182,8 @@ const struct ov7670_resolution_cfg OV7670_RESOLUTION_VGA = {
181
182
182
183
/* OV7670 definitions */
183
184
#define OV7670_PROD_ID 0x76
185
+ #define OV7670_MVFP_HFLIP 0x20
186
+ #define OV7670_MVFP_VFLIP 0x10
184
187
185
188
#define OV7670_VIDEO_FORMAT_CAP (width , height , format ) \
186
189
{ \
@@ -204,7 +207,7 @@ static const struct video_format_cap fmts[] = {
204
207
* Note that this table assumes the camera is fed a 6MHz XCLK signal
205
208
*/
206
209
static const struct ov7670_reg ov7670_init_regtbl [] = {
207
- {OV7670_MVFP , 0x20 }, /* MVFP: Mirror/VFlip,Normal image */
210
+ {OV7670_MVFP , 0x00 }, /* MVFP: Mirror/VFlip,Normal image */
208
211
209
212
/* configure the output timing */
210
213
/* PCLK does not toggle during horizontal blank, one PCLK, one pixel */
@@ -547,10 +550,39 @@ static int ov7670_init(const struct device *dev)
547
550
return 0 ;
548
551
}
549
552
553
+ static int ov7670_stream_start (const struct device * dev )
554
+ {
555
+ return 0 ;
556
+ }
557
+
558
+ static int ov7670_stream_stop (const struct device * dev )
559
+ {
560
+ return 0 ;
561
+ }
562
+
563
+ static int ov7670_set_ctrl (const struct device * dev , unsigned int cid , void * value )
564
+ {
565
+ const struct ov7670_config * config = dev -> config ;
566
+
567
+ switch (cid ) {
568
+ case VIDEO_CID_HFLIP :
569
+ return i2c_reg_update_byte_dt (& config -> bus , OV7670_MVFP ,
570
+ OV7670_MVFP_HFLIP , ((int )value ) ? OV7670_MVFP_HFLIP : 0 );
571
+ case VIDEO_CID_VFLIP :
572
+ return i2c_reg_update_byte_dt (& config -> bus , OV7670_MVFP ,
573
+ OV7670_MVFP_VFLIP , ((int )value ) ? OV7670_MVFP_VFLIP : 0 );
574
+ default :
575
+ return - ENOTSUP ;
576
+ }
577
+ }
578
+
550
579
static DEVICE_API (video , ov7670_api ) = {
551
580
.set_format = ov7670_set_fmt ,
552
581
.get_format = ov7670_get_fmt ,
553
582
.get_caps = ov7670_get_caps ,
583
+ .stream_start = ov7670_stream_start ,
584
+ .stream_stop = ov7670_stream_stop ,
585
+ .set_ctrl = ov7670_set_ctrl ,
554
586
};
555
587
556
588
#if DT_ANY_INST_HAS_PROP_STATUS_OKAY (reset_gpios )
0 commit comments