@@ -70,6 +70,7 @@ static inline int check_range(enum video_ctrl_type type, struct video_ctrl_range
70
70
}
71
71
return 0 ;
72
72
case VIDEO_CTRL_TYPE_MENU :
73
+ case VIDEO_CTRL_TYPE_INTEGER_MENU :
73
74
if (!IN_RANGE (range .min , 0 , range .max ) ||
74
75
!IN_RANGE (range .def , range .min , range .max )) {
75
76
return - ERANGE ;
@@ -200,6 +201,28 @@ int video_init_menu_ctrl(struct video_ctrl *ctrl, const struct device *dev, uint
200
201
return 0 ;
201
202
}
202
203
204
+ int video_init_int_menu_ctrl (struct video_ctrl * ctrl , const struct device * dev , uint32_t id ,
205
+ uint8_t def , const int64_t menu [], size_t menu_len )
206
+ {
207
+ int ret ;
208
+
209
+ if (!menu ) {
210
+ return - EINVAL ;
211
+ }
212
+
213
+ ret = video_init_ctrl (
214
+ ctrl , dev , id ,
215
+ (struct video_ctrl_range ){.min = 0 , .max = menu_len - 1 , .step = 1 , .def = def });
216
+
217
+ if (ret ) {
218
+ return ret ;
219
+ }
220
+
221
+ ctrl -> int_menu = menu ;
222
+
223
+ return 0 ;
224
+ }
225
+
203
226
/* By definition, the cluster is in manual mode if the master control value is 0 */
204
227
static inline bool is_cluster_manual (const struct video_ctrl * master )
205
228
{
@@ -554,7 +577,11 @@ int video_query_ctrl(const struct device *dev, struct video_ctrl_query *cq)
554
577
cq -> type = ctrl -> type ;
555
578
cq -> flags = ctrl -> flags ;
556
579
cq -> range = ctrl -> range ;
557
- cq -> menu = ctrl -> menu ;
580
+ if (cq -> type == VIDEO_CTRL_TYPE_MENU ) {
581
+ cq -> menu = ctrl -> menu ;
582
+ } else if (cq -> type == VIDEO_CTRL_TYPE_INTEGER_MENU ) {
583
+ cq -> int_menu = ctrl -> int_menu ;
584
+ }
558
585
cq -> name = video_get_ctrl_name (cq -> id );
559
586
560
587
return 0 ;
@@ -583,6 +610,9 @@ void video_print_ctrl(const struct device *const dev, const struct video_ctrl_qu
583
610
case VIDEO_CTRL_TYPE_MENU :
584
611
type = "menu" ;
585
612
break ;
613
+ case VIDEO_CTRL_TYPE_INTEGER_MENU :
614
+ type = "integer menu" ;
615
+ break ;
586
616
case VIDEO_CTRL_TYPE_STRING :
587
617
type = "string" ;
588
618
break ;
@@ -609,10 +639,15 @@ void video_print_ctrl(const struct device *const dev, const struct video_ctrl_qu
609
639
cq -> range .step , cq -> range .def , vc .val );
610
640
}
611
641
612
- if (cq -> menu ) {
642
+ if (cq -> type == VIDEO_CTRL_TYPE_MENU && cq -> menu ) {
613
643
while (cq -> menu [i ]) {
614
644
LOG_INF ("%*s %u: %s" , 32 , "" , i , cq -> menu [i ]);
615
645
i ++ ;
616
646
}
647
+ } else if (cq -> type == VIDEO_CTRL_TYPE_INTEGER_MENU && cq -> int_menu ) {
648
+ while (cq -> int_menu [i ]) {
649
+ LOG_INF ("%*s %u: %lld" , 12 , "" , i , cq -> int_menu [i ]);
650
+ i ++ ;
651
+ }
617
652
}
618
653
}
0 commit comments