@@ -54,6 +54,7 @@ static inline int check_range(enum video_ctrl_type type, struct video_ctrl_range
5454 }
5555 return 0 ;
5656 case VIDEO_CTRL_TYPE_MENU :
57+ case VIDEO_CTRL_TYPE_MENU_INTEGER :
5758 if (!IN_RANGE (range .min , 0 , range .max ) ||
5859 !IN_RANGE (range .def , range .min , range .max )) {
5960 return - ERANGE ;
@@ -170,6 +171,28 @@ int video_init_menu_ctrl(struct video_ctrl *ctrl, const struct device *dev, uint
170171 return 0 ;
171172}
172173
174+ int video_init_int_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+
173196/* By definition, the cluster is in manual mode if the master control value is 0 */
174197static inline bool is_cluster_manual (const struct video_ctrl * master )
175198{
@@ -451,7 +474,11 @@ int video_query_ctrl(const struct device *dev, struct video_ctrl_query *cq)
451474 cq -> type = ctrl -> type ;
452475 cq -> flags = ctrl -> flags ;
453476 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+ }
455482 cq -> name = video_get_ctrl_name (cq -> id );
456483
457484 return 0 ;
@@ -479,6 +506,9 @@ void video_print_ctrl(const struct device *const dev, const struct video_ctrl_qu
479506 case VIDEO_CTRL_TYPE_MENU :
480507 type = "menu" ;
481508 break ;
509+ case VIDEO_CTRL_TYPE_MENU_INTEGER :
510+ type = "menu integer" ;
511+ break ;
482512 case VIDEO_CTRL_TYPE_STRING :
483513 type = "string" ;
484514 break ;
@@ -505,10 +535,15 @@ void video_print_ctrl(const struct device *const dev, const struct video_ctrl_qu
505535 cq -> range .step , cq -> range .def , vc .val );
506536 }
507537
508- if (cq -> menu ) {
538+ if (cq -> type == VIDEO_CTRL_TYPE_MENU && cq -> menu ) {
509539 while (cq -> menu [i ]) {
510540 LOG_INF ("%*s %u: %s" , 32 , "" , i , cq -> menu [i ]);
511541 i ++ ;
512542 }
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" , 12 , "" , i , cq -> int_menu [i ]);
546+ i ++ ;
547+ }
513548 }
514549}
0 commit comments