@@ -1759,18 +1759,27 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
17591759 const struct v4l2_ctrl_type_ops * type_ops ,
17601760 u32 id , const char * name , enum v4l2_ctrl_type type ,
17611761 s64 min , s64 max , u64 step , s64 def ,
1762- u32 elem_size ,
1762+ const u32 dims [ V4L2_CTRL_MAX_DIMS ], u32 elem_size ,
17631763 u32 flags , const char * const * qmenu ,
17641764 const s64 * qmenu_int , void * priv )
17651765{
17661766 struct v4l2_ctrl * ctrl ;
17671767 unsigned sz_extra ;
1768+ unsigned nr_of_dims = 0 ;
1769+ unsigned elems = 1 ;
17681770 void * data ;
17691771 int err ;
17701772
17711773 if (hdl -> error )
17721774 return NULL ;
17731775
1776+ while (dims && dims [nr_of_dims ]) {
1777+ elems *= dims [nr_of_dims ];
1778+ nr_of_dims ++ ;
1779+ if (nr_of_dims == V4L2_CTRL_MAX_DIMS )
1780+ break ;
1781+ }
1782+
17741783 if (type == V4L2_CTRL_TYPE_INTEGER64 )
17751784 elem_size = sizeof (s64 );
17761785 else if (type == V4L2_CTRL_TYPE_STRING )
@@ -1828,6 +1837,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
18281837 ctrl -> is_string = type == V4L2_CTRL_TYPE_STRING ;
18291838 ctrl -> is_ptr = type >= V4L2_CTRL_COMPOUND_TYPES || ctrl -> is_string ;
18301839 ctrl -> is_int = !ctrl -> is_ptr && type != V4L2_CTRL_TYPE_INTEGER64 ;
1840+ ctrl -> elems = elems ;
1841+ ctrl -> nr_of_dims = nr_of_dims ;
1842+ if (nr_of_dims )
1843+ memcpy (ctrl -> dims , dims , nr_of_dims * sizeof (dims [0 ]));
18311844 ctrl -> elem_size = elem_size ;
18321845 if (type == V4L2_CTRL_TYPE_MENU )
18331846 ctrl -> qmenu = qmenu ;
@@ -1892,8 +1905,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
18921905
18931906 ctrl = v4l2_ctrl_new (hdl , cfg -> ops , cfg -> type_ops , cfg -> id , name ,
18941907 type , min , max ,
1895- is_menu ? cfg -> menu_skip_mask : step ,
1896- def , cfg -> elem_size ,
1908+ is_menu ? cfg -> menu_skip_mask : step , def ,
1909+ cfg -> dims , cfg -> elem_size ,
18971910 flags , qmenu , qmenu_int , priv );
18981911 if (ctrl )
18991912 ctrl -> is_private = cfg -> is_private ;
@@ -1918,7 +1931,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std(struct v4l2_ctrl_handler *hdl,
19181931 return NULL ;
19191932 }
19201933 return v4l2_ctrl_new (hdl , ops , NULL , id , name , type ,
1921- min , max , step , def , 0 ,
1934+ min , max , step , def , NULL , 0 ,
19221935 flags , NULL , NULL , NULL );
19231936}
19241937EXPORT_SYMBOL (v4l2_ctrl_new_std );
@@ -1951,7 +1964,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl,
19511964 return NULL ;
19521965 }
19531966 return v4l2_ctrl_new (hdl , ops , NULL , id , name , type ,
1954- 0 , max , mask , def , 0 ,
1967+ 0 , max , mask , def , NULL , 0 ,
19551968 flags , qmenu , qmenu_int , NULL );
19561969}
19571970EXPORT_SYMBOL (v4l2_ctrl_new_std_menu );
@@ -1983,8 +1996,8 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu_items(struct v4l2_ctrl_handler *hdl,
19831996 return NULL ;
19841997 }
19851998 return v4l2_ctrl_new (hdl , ops , NULL , id , name , type ,
1986- 0 , max , mask , def ,
1987- 0 , flags , qmenu , NULL , NULL );
1999+ 0 , max , mask , def , NULL , 0 ,
2000+ flags , qmenu , NULL , NULL );
19882001
19892002}
19902003EXPORT_SYMBOL (v4l2_ctrl_new_std_menu_items );
@@ -2008,7 +2021,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_int_menu(struct v4l2_ctrl_handler *hdl,
20082021 return NULL ;
20092022 }
20102023 return v4l2_ctrl_new (hdl , ops , NULL , id , name , type ,
2011- 0 , max , 0 , def , 0 ,
2024+ 0 , max , 0 , def , NULL , 0 ,
20122025 flags , NULL , qmenu_int , NULL );
20132026}
20142027EXPORT_SYMBOL (v4l2_ctrl_new_int_menu );
@@ -2354,7 +2367,9 @@ int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctr
23542367 if (ctrl -> is_ptr )
23552368 qc -> flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD ;
23562369 qc -> elem_size = ctrl -> elem_size ;
2357- qc -> elems = 1 ;
2370+ qc -> elems = ctrl -> elems ;
2371+ qc -> nr_of_dims = ctrl -> nr_of_dims ;
2372+ memcpy (qc -> dims , ctrl -> dims , qc -> nr_of_dims * sizeof (qc -> dims [0 ]));
23582373 qc -> minimum = ctrl -> minimum ;
23592374 qc -> maximum = ctrl -> maximum ;
23602375 qc -> default_value = ctrl -> default_value ;
0 commit comments