@@ -54,6 +54,7 @@ static inline int check_range(enum video_ctrl_type type, struct video_ctrl_range
54
54
}
55
55
return 0 ;
56
56
case VIDEO_CTRL_TYPE_MENU :
57
+ case VIDEO_CTRL_TYPE_MENU_INTEGER :
57
58
if (!IN_RANGE (range .min , 0 , range .max ) ||
58
59
!IN_RANGE (range .def , range .min , range .max )) {
59
60
return - ERANGE ;
@@ -170,6 +171,28 @@ int video_init_menu_ctrl(struct video_ctrl *ctrl, const struct device *dev, uint
170
171
return 0 ;
171
172
}
172
173
174
+ int video_init_integer_menu_ctrl (struct video_ctrl * ctrl , const struct device * dev , uint32_t id ,
175
+ uint8_t def , const int64_t menu [], size_t menu_len )
176
+ {
177
+ int ret ;
178
+
179
+ if (!menu ) {
180
+ return - EINVAL ;
181
+ }
182
+
183
+ ret = video_init_ctrl (
184
+ ctrl , dev , id ,
185
+ (struct video_ctrl_range ){.min = 0 , .max = menu_len - 1 , .step = 1 , .def = def });
186
+
187
+ if (ret ) {
188
+ return ret ;
189
+ }
190
+
191
+ ctrl -> int_menu = menu ;
192
+
193
+ return 0 ;
194
+ }
195
+
173
196
/* By definition, the cluster is in manual mode if the master control value is 0 */
174
197
static inline bool is_cluster_manual (const struct video_ctrl * master )
175
198
{
@@ -451,7 +474,11 @@ int video_query_ctrl(const struct device *dev, struct video_ctrl_query *cq)
451
474
cq -> type = ctrl -> type ;
452
475
cq -> flags = ctrl -> flags ;
453
476
cq -> range = ctrl -> range ;
454
- cq -> menu = ctrl -> menu ;
477
+ if (cq -> type == VIDEO_CTRL_TYPE_MENU ) {
478
+ cq -> menu = ctrl -> menu ;
479
+ } else if (cq -> type == VIDEO_CTRL_TYPE_MENU_INTEGER ) {
480
+ cq -> int_menu = ctrl -> int_menu ;
481
+ }
455
482
cq -> name = video_get_ctrl_name (cq -> id );
456
483
457
484
return 0 ;
@@ -479,6 +506,9 @@ void video_print_ctrl(const struct device *const dev, const struct video_ctrl_qu
479
506
case VIDEO_CTRL_TYPE_MENU :
480
507
type = "menu" ;
481
508
break ;
509
+ case VIDEO_CTRL_TYPE_MENU_INTEGER :
510
+ type = "menu integer" ;
511
+ break ;
482
512
case VIDEO_CTRL_TYPE_STRING :
483
513
type = "string" ;
484
514
break ;
@@ -505,10 +535,15 @@ void video_print_ctrl(const struct device *const dev, const struct video_ctrl_qu
505
535
cq -> range .step , cq -> range .def , vc .val );
506
536
}
507
537
508
- if (cq -> menu ) {
538
+ if (cq -> type == VIDEO_CTRL_TYPE_MENU && cq -> menu ) {
509
539
while (cq -> menu [i ]) {
510
540
LOG_INF ("%*s %u: %s" , 32 , "" , i , cq -> menu [i ]);
511
541
i ++ ;
512
542
}
543
+ } else if (cq -> type == VIDEO_CTRL_TYPE_MENU_INTEGER && cq -> int_menu ) {
544
+ while (cq -> int_menu [i ]) {
545
+ LOG_INF ("%*s %u: %lld" , 32 , "" , i , cq -> int_menu [i ]);
546
+ i ++ ;
547
+ }
513
548
}
514
549
}
0 commit comments