@@ -877,7 +877,7 @@ const char *v4l2_ctrl_get_name(u32 id)
877877EXPORT_SYMBOL (v4l2_ctrl_get_name );
878878
879879void v4l2_ctrl_fill (u32 id , const char * * name , enum v4l2_ctrl_type * type ,
880- s32 * min , s32 * max , s32 * step , s32 * def , u32 * flags )
880+ s64 * min , s64 * max , u64 * step , s64 * def , u32 * flags )
881881{
882882 * name = v4l2_ctrl_get_name (id );
883883 * flags = 0 ;
@@ -1041,14 +1041,23 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
10411041 * type = V4L2_CTRL_TYPE_INTEGER ;
10421042 * flags |= V4L2_CTRL_FLAG_READ_ONLY ;
10431043 break ;
1044- case V4L2_CID_MPEG_VIDEO_DEC_FRAME :
10451044 case V4L2_CID_MPEG_VIDEO_DEC_PTS :
1046- * flags |= V4L2_CTRL_FLAG_VOLATILE ;
1047- /* Fall through */
1045+ * type = V4L2_CTRL_TYPE_INTEGER64 ;
1046+ * flags |= V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY ;
1047+ * min = * def = 0 ;
1048+ * max = 0x1ffffffffLL ;
1049+ * step = 1 ;
1050+ break ;
1051+ case V4L2_CID_MPEG_VIDEO_DEC_FRAME :
1052+ * type = V4L2_CTRL_TYPE_INTEGER64 ;
1053+ * flags |= V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY ;
1054+ * min = * def = 0 ;
1055+ * max = 0x7fffffffffffffffLL ;
1056+ * step = 1 ;
1057+ break ;
10481058 case V4L2_CID_PIXEL_RATE :
10491059 * type = V4L2_CTRL_TYPE_INTEGER64 ;
10501060 * flags |= V4L2_CTRL_FLAG_READ_ONLY ;
1051- * min = * max = * step = * def = 0 ;
10521061 break ;
10531062 default :
10541063 * type = V4L2_CTRL_TYPE_INTEGER ;
@@ -1352,15 +1361,16 @@ static int cluster_changed(struct v4l2_ctrl *master)
13521361
13531362/* Control range checking */
13541363static int check_range (enum v4l2_ctrl_type type ,
1355- s32 min , s32 max , u32 step , s32 def )
1364+ s64 min , s64 max , u64 step , s64 def )
13561365{
13571366 switch (type ) {
13581367 case V4L2_CTRL_TYPE_BOOLEAN :
13591368 if (step != 1 || max > 1 || min < 0 )
13601369 return - ERANGE ;
13611370 /* fall through */
13621371 case V4L2_CTRL_TYPE_INTEGER :
1363- if (step <= 0 || min > max || def < min || def > max )
1372+ case V4L2_CTRL_TYPE_INTEGER64 :
1373+ if (step == 0 || min > max || def < min || def > max )
13641374 return - ERANGE ;
13651375 return 0 ;
13661376 case V4L2_CTRL_TYPE_BITMASK :
@@ -1385,23 +1395,30 @@ static int check_range(enum v4l2_ctrl_type type,
13851395 }
13861396}
13871397
1398+ /* Round towards the closest legal value */
1399+ #define ROUND_TO_RANGE (val , offset_type , ctrl ) \
1400+ ({ \
1401+ offset_type offset; \
1402+ val += (ctrl)->step / 2; \
1403+ val = clamp_t(typeof(val), val, \
1404+ (ctrl)->minimum, (ctrl)->maximum); \
1405+ offset = (val) - (ctrl)->minimum; \
1406+ offset = (ctrl)->step * (offset / (ctrl)->step); \
1407+ val = (ctrl)->minimum + offset; \
1408+ 0; \
1409+ })
1410+
13881411/* Validate a new control */
13891412static int validate_new (const struct v4l2_ctrl * ctrl ,
13901413 struct v4l2_ext_control * c )
13911414{
13921415 size_t len ;
1393- u32 offset ;
1394- s32 val ;
13951416
13961417 switch (ctrl -> type ) {
13971418 case V4L2_CTRL_TYPE_INTEGER :
1398- /* Round towards the closest legal value */
1399- val = c -> value + ctrl -> step / 2 ;
1400- val = clamp (val , ctrl -> minimum , ctrl -> maximum );
1401- offset = val - ctrl -> minimum ;
1402- offset = ctrl -> step * (offset / ctrl -> step );
1403- c -> value = ctrl -> minimum + offset ;
1404- return 0 ;
1419+ return ROUND_TO_RANGE (* (s32 * )& c -> value , u32 , ctrl );
1420+ case V4L2_CTRL_TYPE_INTEGER64 :
1421+ return ROUND_TO_RANGE (* (s64 * )& c -> value64 , u64 , ctrl );
14051422
14061423 case V4L2_CTRL_TYPE_BOOLEAN :
14071424 c -> value = !!c -> value ;
@@ -1427,9 +1444,6 @@ static int validate_new(const struct v4l2_ctrl *ctrl,
14271444 c -> value = 0 ;
14281445 return 0 ;
14291446
1430- case V4L2_CTRL_TYPE_INTEGER64 :
1431- return 0 ;
1432-
14331447 case V4L2_CTRL_TYPE_STRING :
14341448 len = strlen (c -> string );
14351449 if (len < ctrl -> minimum )
@@ -1653,7 +1667,7 @@ static int handler_new_ref(struct v4l2_ctrl_handler *hdl,
16531667static struct v4l2_ctrl * v4l2_ctrl_new (struct v4l2_ctrl_handler * hdl ,
16541668 const struct v4l2_ctrl_ops * ops ,
16551669 u32 id , const char * name , enum v4l2_ctrl_type type ,
1656- s32 min , s32 max , u32 step , s32 def ,
1670+ s64 min , s64 max , u64 step , s64 def ,
16571671 u32 flags , const char * const * qmenu ,
16581672 const s64 * qmenu_int , void * priv )
16591673{
@@ -1738,10 +1752,10 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct v4l2_ctrl_handler *hdl,
17381752 const s64 * qmenu_int = cfg -> qmenu_int ;
17391753 enum v4l2_ctrl_type type = cfg -> type ;
17401754 u32 flags = cfg -> flags ;
1741- s32 min = cfg -> min ;
1742- s32 max = cfg -> max ;
1743- u32 step = cfg -> step ;
1744- s32 def = cfg -> def ;
1755+ s64 min = cfg -> min ;
1756+ s64 max = cfg -> max ;
1757+ u64 step = cfg -> step ;
1758+ s64 def = cfg -> def ;
17451759
17461760 if (name == NULL )
17471761 v4l2_ctrl_fill (cfg -> id , & name , & type , & min , & max , & step ,
@@ -1774,7 +1788,7 @@ EXPORT_SYMBOL(v4l2_ctrl_new_custom);
17741788/* Helper function for standard non-menu controls */
17751789struct v4l2_ctrl * v4l2_ctrl_new_std (struct v4l2_ctrl_handler * hdl ,
17761790 const struct v4l2_ctrl_ops * ops ,
1777- u32 id , s32 min , s32 max , u32 step , s32 def )
1791+ u32 id , s64 min , s64 max , u64 step , s64 def )
17781792{
17791793 const char * name ;
17801794 enum v4l2_ctrl_type type ;
@@ -1794,15 +1808,17 @@ EXPORT_SYMBOL(v4l2_ctrl_new_std);
17941808/* Helper function for standard menu controls */
17951809struct v4l2_ctrl * v4l2_ctrl_new_std_menu (struct v4l2_ctrl_handler * hdl ,
17961810 const struct v4l2_ctrl_ops * ops ,
1797- u32 id , s32 max , s32 mask , s32 def )
1811+ u32 id , u8 _max , u64 mask , u8 _def )
17981812{
17991813 const char * const * qmenu = NULL ;
18001814 const s64 * qmenu_int = NULL ;
18011815 unsigned int qmenu_int_len = 0 ;
18021816 const char * name ;
18031817 enum v4l2_ctrl_type type ;
1804- s32 min ;
1805- s32 step ;
1818+ s64 min ;
1819+ s64 max = _max ;
1820+ s64 def = _def ;
1821+ u64 step ;
18061822 u32 flags ;
18071823
18081824 v4l2_ctrl_fill (id , & name , & type , & min , & max , & step , & def , & flags );
@@ -1823,14 +1839,16 @@ EXPORT_SYMBOL(v4l2_ctrl_new_std_menu);
18231839
18241840/* Helper function for standard menu controls with driver defined menu */
18251841struct v4l2_ctrl * v4l2_ctrl_new_std_menu_items (struct v4l2_ctrl_handler * hdl ,
1826- const struct v4l2_ctrl_ops * ops , u32 id , s32 max ,
1827- s32 mask , s32 def , const char * const * qmenu )
1842+ const struct v4l2_ctrl_ops * ops , u32 id , u8 _max ,
1843+ u64 mask , u8 _def , const char * const * qmenu )
18281844{
18291845 enum v4l2_ctrl_type type ;
18301846 const char * name ;
18311847 u32 flags ;
1832- s32 step ;
1833- s32 min ;
1848+ u64 step ;
1849+ s64 min ;
1850+ s64 max = _max ;
1851+ s64 def = _def ;
18341852
18351853 /* v4l2_ctrl_new_std_menu_items() should only be called for
18361854 * standard controls without a standard menu.
@@ -1854,12 +1872,14 @@ EXPORT_SYMBOL(v4l2_ctrl_new_std_menu_items);
18541872/* Helper function for standard integer menu controls */
18551873struct v4l2_ctrl * v4l2_ctrl_new_int_menu (struct v4l2_ctrl_handler * hdl ,
18561874 const struct v4l2_ctrl_ops * ops ,
1857- u32 id , s32 max , s32 def , const s64 * qmenu_int )
1875+ u32 id , u8 _max , u8 _def , const s64 * qmenu_int )
18581876{
18591877 const char * name ;
18601878 enum v4l2_ctrl_type type ;
1861- s32 min ;
1862- s32 step ;
1879+ s64 min ;
1880+ u64 step ;
1881+ s64 max = _max ;
1882+ s64 def = _def ;
18631883 u32 flags ;
18641884
18651885 v4l2_ctrl_fill (id , & name , & type , & min , & max , & step , & def , & flags );
@@ -2887,13 +2907,14 @@ void v4l2_ctrl_notify(struct v4l2_ctrl *ctrl, v4l2_ctrl_notify_fnc notify, void
28872907EXPORT_SYMBOL (v4l2_ctrl_notify );
28882908
28892909int v4l2_ctrl_modify_range (struct v4l2_ctrl * ctrl ,
2890- s32 min , s32 max , u32 step , s32 def )
2910+ s64 min , s64 max , u64 step , s64 def )
28912911{
28922912 int ret = check_range (ctrl -> type , min , max , step , def );
28932913 struct v4l2_ext_control c ;
28942914
28952915 switch (ctrl -> type ) {
28962916 case V4L2_CTRL_TYPE_INTEGER :
2917+ case V4L2_CTRL_TYPE_INTEGER64 :
28972918 case V4L2_CTRL_TYPE_BOOLEAN :
28982919 case V4L2_CTRL_TYPE_MENU :
28992920 case V4L2_CTRL_TYPE_INTEGER_MENU :
0 commit comments