@@ -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_MENU_INTEGER :
73
74
if (!IN_RANGE (range .min , 0 , range .max ) ||
74
75
!IN_RANGE (range .def , range .min , range .max )) {
75
76
return - ERANGE ;
@@ -196,6 +197,28 @@ int video_init_menu_ctrl(struct video_ctrl *ctrl, const struct device *dev, uint
196
197
return 0 ;
197
198
}
198
199
200
+ int video_init_int_menu_ctrl (struct video_ctrl * ctrl , const struct device * dev , uint32_t id ,
201
+ uint8_t def , const int64_t menu [], size_t menu_len )
202
+ {
203
+ int ret ;
204
+
205
+ if (!menu ) {
206
+ return - EINVAL ;
207
+ }
208
+
209
+ ret = video_init_ctrl (
210
+ ctrl , dev , id ,
211
+ (struct video_ctrl_range ){.min = 0 , .max = menu_len - 1 , .step = 1 , .def = def });
212
+
213
+ if (ret ) {
214
+ return ret ;
215
+ }
216
+
217
+ ctrl -> int_menu = menu ;
218
+
219
+ return 0 ;
220
+ }
221
+
199
222
/* By definition, the cluster is in manual mode if the master control value is 0 */
200
223
static inline bool is_cluster_manual (const struct video_ctrl * master )
201
224
{
@@ -540,7 +563,11 @@ int video_query_ctrl(const struct device *dev, struct video_ctrl_query *cq)
540
563
cq -> type = ctrl -> type ;
541
564
cq -> flags = ctrl -> flags ;
542
565
cq -> range = ctrl -> range ;
543
- cq -> menu = ctrl -> menu ;
566
+ if (cq -> type == VIDEO_CTRL_TYPE_MENU ) {
567
+ cq -> menu = ctrl -> menu ;
568
+ } else if (cq -> type == VIDEO_CTRL_TYPE_MENU_INTEGER ) {
569
+ cq -> int_menu = ctrl -> int_menu ;
570
+ }
544
571
cq -> name = video_get_ctrl_name (cq -> id );
545
572
546
573
return 0 ;
@@ -568,6 +595,9 @@ void video_print_ctrl(const struct device *const dev, const struct video_ctrl_qu
568
595
case VIDEO_CTRL_TYPE_MENU :
569
596
type = "menu" ;
570
597
break ;
598
+ case VIDEO_CTRL_TYPE_MENU_INTEGER :
599
+ type = "menu integer" ;
600
+ break ;
571
601
case VIDEO_CTRL_TYPE_STRING :
572
602
type = "string" ;
573
603
break ;
@@ -594,10 +624,15 @@ void video_print_ctrl(const struct device *const dev, const struct video_ctrl_qu
594
624
cq -> range .step , cq -> range .def , vc .val );
595
625
}
596
626
597
- if (cq -> menu ) {
627
+ if (cq -> type == VIDEO_CTRL_TYPE_MENU && cq -> menu ) {
598
628
while (cq -> menu [i ]) {
599
629
LOG_INF ("%*s %u: %s" , 32 , "" , i , cq -> menu [i ]);
600
630
i ++ ;
601
631
}
632
+ } else if (cq -> type == VIDEO_CTRL_TYPE_MENU_INTEGER && cq -> int_menu ) {
633
+ while (cq -> int_menu [i ]) {
634
+ LOG_INF ("%*s %u: %lld" , 12 , "" , i , cq -> int_menu [i ]);
635
+ i ++ ;
636
+ }
602
637
}
603
638
}
0 commit comments