Re: [RFC/PATCH 1/3] v4l: Introduce integer menu controls

2011-11-28 Thread Hans Verkuil
On Friday 25 November 2011 13:58:27 Laurent Pinchart wrote:
> Hi Sakari,
> 
> On Friday 25 November 2011 13:56:50 Sakari Ailus wrote:
> > On Fri, Nov 25, 2011 at 01:43:12PM +0100, Laurent Pinchart wrote:
> > > On Friday 25 November 2011 13:02:02 Sakari Ailus wrote:
> > > > On Fri, Nov 25, 2011 at 11:28:46AM +0100, Laurent Pinchart wrote:
> > > > > On Thursday 24 November 2011 17:12:50 Sakari Ailus wrote:
> > > > ...
> > > > 
> > > > > > @@ -1440,12 +1458,13 @@ struct v4l2_ctrl
> > > > > > *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, u32 flags;
> > > > > > 
> > > > > > v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def,
> > > > > > &flags);
> > > > > > 
> > > > > > -   if (type != V4L2_CTRL_TYPE_MENU) {
> > > > > > +   if (type != V4L2_CTRL_TYPE_MENU
> > > > > > +   && type != V4L2_CTRL_TYPE_INTEGER_MENU) {
> > > > > > 
> > > > > > handler_set_err(hdl, -EINVAL);
> > > > > > return NULL;
> > > > > > 
> > > > > > }
> > > > > > return v4l2_ctrl_new(hdl, ops, id, name, type,
> > > > > > 
> > > > > > -   0, max, mask, def, flags, qmenu, 
NULL);
> > > > > > +0, max, mask, def, flags, qmenu, NULL, 
NULL);
> > > > > 
> > > > > You pass NULL to the v4l2_ctrl_new() qmenu_int argument, which will
> > > > > make the function fail for integer menu controls. Do you expect
> > > > > standard integer menu controls to share a list of values ? If not,
> > > > > what about modifying v4l2_ctrl_new_std_menu() to take a list of
> > > > > values (or alternatively forbidding the function from being used
> > > > > for integer menu controls) ?
> > > > 
> > > > We currently have no integer menu controls, let alone one which would
> > > > have a set of standard values. We need same functionality as in
> > > > v4l2_ctrl_get_menu() for integer menus when we add the first
> > > > standardised integer menu control. I think it could be added at that
> > > > time, or I could implement a v4l2_ctrl_get_integer_menu() which would
> > > > do nothing.
> > > > 
> > > > What do you think?
> > > 
> > > I was just wondering if we will ever have a standard menu control with
> > > standard integer items. If that never happens, v4l2_ctrl_new_std_menu()
> > > needs to either take a qmenu_int array, or reject integer menu controls
> > > completely. I would thus delay adding the V4L2_CTRL_TYPE_INTEGER_MENU
> > > check to the function as it wouldn't work anyway (or, alternatively, we
> > > would add the qmenu_int argument now).
> > 
> > Either one, yes. I think I'll add a separate patch adding standard
> > integer menus and remove the check from this one.
> > 
> > There'll definitely be a need for them. For example, there are bit rate
> > menus in the standard menu type controls that ideally should be integers.
> 
> Sure, but I doubt that the bit rates themselves will be standard.

Actually, they are. MPEG audio level 1, 2, 3 and AC3 audio all have their own
standardized set of possible bitrates. If I had an integer menu at the time
I'm sure I would have used it.

Regards,

Hans

> 
> > We won't change them but there will be others. Or I'd be very surprised
> > if there were not!
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 1/3] v4l: Introduce integer menu controls

2011-11-25 Thread Laurent Pinchart
Hi Sakari,

On Friday 25 November 2011 13:56:50 Sakari Ailus wrote:
> On Fri, Nov 25, 2011 at 01:43:12PM +0100, Laurent Pinchart wrote:
> > On Friday 25 November 2011 13:02:02 Sakari Ailus wrote:
> > > On Fri, Nov 25, 2011 at 11:28:46AM +0100, Laurent Pinchart wrote:
> > > > On Thursday 24 November 2011 17:12:50 Sakari Ailus wrote:
> > > ...
> > > 
> > > > > @@ -1440,12 +1458,13 @@ struct v4l2_ctrl
> > > > > *v4l2_ctrl_new_std_menu(struct v4l2_ctrl_handler *hdl, u32 flags;
> > > > > 
> > > > >   v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def,
> > > > >   &flags);
> > > > > 
> > > > > - if (type != V4L2_CTRL_TYPE_MENU) {
> > > > > + if (type != V4L2_CTRL_TYPE_MENU
> > > > > + && type != V4L2_CTRL_TYPE_INTEGER_MENU) {
> > > > > 
> > > > >   handler_set_err(hdl, -EINVAL);
> > > > >   return NULL;
> > > > >   
> > > > >   }
> > > > >   return v4l2_ctrl_new(hdl, ops, id, name, type,
> > > > > 
> > > > > - 0, max, mask, def, flags, qmenu, 
> > > > > NULL);
> > > > > +  0, max, mask, def, flags, qmenu, NULL, 
> > > > > NULL);
> > > > 
> > > > You pass NULL to the v4l2_ctrl_new() qmenu_int argument, which will
> > > > make the function fail for integer menu controls. Do you expect
> > > > standard integer menu controls to share a list of values ? If not,
> > > > what about modifying v4l2_ctrl_new_std_menu() to take a list of
> > > > values (or alternatively forbidding the function from being used for
> > > > integer menu controls) ?
> > > 
> > > We currently have no integer menu controls, let alone one which would
> > > have a set of standard values. We need same functionality as in
> > > v4l2_ctrl_get_menu() for integer menus when we add the first
> > > standardised integer menu control. I think it could be added at that
> > > time, or I could implement a v4l2_ctrl_get_integer_menu() which would
> > > do nothing.
> > > 
> > > What do you think?
> > 
> > I was just wondering if we will ever have a standard menu control with
> > standard integer items. If that never happens, v4l2_ctrl_new_std_menu()
> > needs to either take a qmenu_int array, or reject integer menu controls
> > completely. I would thus delay adding the V4L2_CTRL_TYPE_INTEGER_MENU
> > check to the function as it wouldn't work anyway (or, alternatively, we
> > would add the qmenu_int argument now).
> 
> Either one, yes. I think I'll add a separate patch adding standard integer
> menus and remove the check from this one.
> 
> There'll definitely be a need for them. For example, there are bit rate
> menus in the standard menu type controls that ideally should be integers.

Sure, but I doubt that the bit rates themselves will be standard.

> We won't change them but there will be others. Or I'd be very surprised if
> there were not!

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 1/3] v4l: Introduce integer menu controls

2011-11-25 Thread Sakari Ailus
On Fri, Nov 25, 2011 at 01:43:12PM +0100, Laurent Pinchart wrote:
> Hi Sakari,
> 
> On Friday 25 November 2011 13:02:02 Sakari Ailus wrote:
> > On Fri, Nov 25, 2011 at 11:28:46AM +0100, Laurent Pinchart wrote:
> > > On Thursday 24 November 2011 17:12:50 Sakari Ailus wrote:
> > ...
> > 
> > > > @@ -1440,12 +1458,13 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct
> > > > v4l2_ctrl_handler *hdl, u32 flags;
> > > > 
> > > > v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, 
> > > > &flags);
> > > > 
> > > > -   if (type != V4L2_CTRL_TYPE_MENU) {
> > > > +   if (type != V4L2_CTRL_TYPE_MENU
> > > > +   && type != V4L2_CTRL_TYPE_INTEGER_MENU) {
> > > > 
> > > > handler_set_err(hdl, -EINVAL);
> > > > return NULL;
> > > > 
> > > > }
> > > > return v4l2_ctrl_new(hdl, ops, id, name, type,
> > > > 
> > > > -   0, max, mask, def, flags, qmenu, 
> > > > NULL);
> > > > +0, max, mask, def, flags, qmenu, NULL, 
> > > > NULL);
> > > 
> > > You pass NULL to the v4l2_ctrl_new() qmenu_int argument, which will make
> > > the function fail for integer menu controls. Do you expect standard
> > > integer menu controls to share a list of values ? If not, what about
> > > modifying v4l2_ctrl_new_std_menu() to take a list of values (or
> > > alternatively forbidding the function from being used for integer menu
> > > controls) ?
> > 
> > We currently have no integer menu controls, let alone one which would have
> > a set of standard values. We need same functionality as in
> > v4l2_ctrl_get_menu() for integer menus when we add the first standardised
> > integer menu control. I think it could be added at that time, or I could
> > implement a v4l2_ctrl_get_integer_menu() which would do nothing.
> > 
> > What do you think?
> 
> I was just wondering if we will ever have a standard menu control with 
> standard integer items. If that never happens, v4l2_ctrl_new_std_menu() needs 
> to either take a qmenu_int array, or reject integer menu controls completely. 
> I would thus delay adding the V4L2_CTRL_TYPE_INTEGER_MENU check to the 
> function as it wouldn't work anyway (or, alternatively, we would add the 
> qmenu_int argument now).

Either one, yes. I think I'll add a separate patch adding standard integer
menus and remove the check from this one.

There'll definitely be a need for them. For example, there are bit rate
menus in the standard menu type controls that ideally should be integers. We
won't change them but there will be others. Or I'd be very surprised if
there were not!

Cheers,

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi jabber/XMPP/Gmail: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 1/3] v4l: Introduce integer menu controls

2011-11-25 Thread Laurent Pinchart
Hi Sakari,

On Friday 25 November 2011 13:02:02 Sakari Ailus wrote:
> On Fri, Nov 25, 2011 at 11:28:46AM +0100, Laurent Pinchart wrote:
> > On Thursday 24 November 2011 17:12:50 Sakari Ailus wrote:
> ...
> 
> > > @@ -1440,12 +1458,13 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct
> > > v4l2_ctrl_handler *hdl, u32 flags;
> > > 
> > >   v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags);
> > > 
> > > - if (type != V4L2_CTRL_TYPE_MENU) {
> > > + if (type != V4L2_CTRL_TYPE_MENU
> > > + && type != V4L2_CTRL_TYPE_INTEGER_MENU) {
> > > 
> > >   handler_set_err(hdl, -EINVAL);
> > >   return NULL;
> > >   
> > >   }
> > >   return v4l2_ctrl_new(hdl, ops, id, name, type,
> > > 
> > > - 0, max, mask, def, flags, qmenu, NULL);
> > > +  0, max, mask, def, flags, qmenu, NULL, NULL);
> > 
> > You pass NULL to the v4l2_ctrl_new() qmenu_int argument, which will make
> > the function fail for integer menu controls. Do you expect standard
> > integer menu controls to share a list of values ? If not, what about
> > modifying v4l2_ctrl_new_std_menu() to take a list of values (or
> > alternatively forbidding the function from being used for integer menu
> > controls) ?
> 
> We currently have no integer menu controls, let alone one which would have
> a set of standard values. We need same functionality as in
> v4l2_ctrl_get_menu() for integer menus when we add the first standardised
> integer menu control. I think it could be added at that time, or I could
> implement a v4l2_ctrl_get_integer_menu() which would do nothing.
> 
> What do you think?

I was just wondering if we will ever have a standard menu control with 
standard integer items. If that never happens, v4l2_ctrl_new_std_menu() needs 
to either take a qmenu_int array, or reject integer menu controls completely. 
I would thus delay adding the V4L2_CTRL_TYPE_INTEGER_MENU check to the 
function as it wouldn't work anyway (or, alternatively, we would add the 
qmenu_int argument now).

-- 
Regards,

Laurent Pinchart
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 1/3] v4l: Introduce integer menu controls

2011-11-25 Thread Sakari Ailus
On Fri, Nov 25, 2011 at 11:28:46AM +0100, Laurent Pinchart wrote:
> Hi Sakari,
> 
> Thanks for the patch.

Hi Laurent,

Thanks for the comments!

> On Thursday 24 November 2011 17:12:50 Sakari Ailus wrote:
...
> > @@ -1440,12 +1458,13 @@ struct v4l2_ctrl *v4l2_ctrl_new_std_menu(struct
> > v4l2_ctrl_handler *hdl, u32 flags;
> > 
> > v4l2_ctrl_fill(id, &name, &type, &min, &max, &step, &def, &flags);
> > -   if (type != V4L2_CTRL_TYPE_MENU) {
> > +   if (type != V4L2_CTRL_TYPE_MENU
> > +   && type != V4L2_CTRL_TYPE_INTEGER_MENU) {
> > handler_set_err(hdl, -EINVAL);
> > return NULL;
> > }
> > return v4l2_ctrl_new(hdl, ops, id, name, type,
> > -   0, max, mask, def, flags, qmenu, NULL);
> > +0, max, mask, def, flags, qmenu, NULL, NULL);
> 
> You pass NULL to the v4l2_ctrl_new() qmenu_int argument, which will make the 
> function fail for integer menu controls. Do you expect standard integer menu 
> controls to share a list of values ? If not, what about modifying 
> v4l2_ctrl_new_std_menu() to take a list of values (or alternatively 
> forbidding 
> the function from being used for integer menu controls) ?

We currently have no integer menu controls, let alone one which would have a
set of standard values. We need same functionality as in
v4l2_ctrl_get_menu() for integer menus when we add the first standardised
integer menu control. I think it could be added at that time, or I could
implement a v4l2_ctrl_get_integer_menu() which would do nothing.

What do you think?

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi jabber/XMPP/Gmail: sai...@retiisi.org.uk
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 1/3] v4l: Introduce integer menu controls

2011-11-25 Thread Laurent Pinchart
Hi Sakari,

Thanks for the patch.

On Thursday 24 November 2011 17:12:50 Sakari Ailus wrote:
> Create a new control type called V4L2_CTRL_TYPE_INTEGER_MENU. Integer menu
> controls are just like menu controls but the menu items are 64-bit integers
> rather than strings.
> 
> Signed-off-by: Sakari Ailus 
> ---
>  drivers/media/video/v4l2-ctrls.c |   63
> +++-- include/linux/videodev2.h|  
>  6 +++-
>  include/media/v4l2-ctrls.h   |6 +++-
>  3 files changed, 56 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/media/video/v4l2-ctrls.c
> b/drivers/media/video/v4l2-ctrls.c index 0f415da..609eb31 100644
> --- a/drivers/media/video/v4l2-ctrls.c
> +++ b/drivers/media/video/v4l2-ctrls.c
> @@ -804,7 +804,8 @@ static void fill_event(struct v4l2_event *ev, struct
> v4l2_ctrl *ctrl, u32 change ev->u.ctrl.value64 = ctrl->cur.val64;
>   ev->u.ctrl.minimum = ctrl->minimum;
>   ev->u.ctrl.maximum = ctrl->maximum;
> - if (ctrl->type == V4L2_CTRL_TYPE_MENU)
> + if (ctrl->type == V4L2_CTRL_TYPE_MENU
> + || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU)
>   ev->u.ctrl.step = 1;
>   else
>   ev->u.ctrl.step = ctrl->step;
> @@ -1035,10 +1036,13 @@ static int validate_new_int(const struct v4l2_ctrl
> *ctrl, s32 *pval) return 0;
> 
>   case V4L2_CTRL_TYPE_MENU:
> + case V4L2_CTRL_TYPE_INTEGER_MENU:
>   if (val < ctrl->minimum || val > ctrl->maximum)
>   return -ERANGE;
> - if (ctrl->qmenu[val][0] == '\0' ||
> - (ctrl->menu_skip_mask & (1 << val)))
> + if (ctrl->menu_skip_mask & (1 << val))
> + return -EINVAL;
> + if (ctrl->type == V4L2_CTRL_TYPE_MENU &&
> + ctrl->qmenu[val][0] == '\0')
>   return -EINVAL;
>   return 0;
> 
> @@ -1295,7 +1299,8 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct
> v4l2_ctrl_handler *hdl, const struct v4l2_ctrl_ops *ops,
>   u32 id, const char *name, enum v4l2_ctrl_type type,
>   s32 min, s32 max, u32 step, s32 def,
> - u32 flags, const char * const *qmenu, void *priv)
> + u32 flags, const char * const *qmenu,
> + const s64 *qmenu_int, void *priv)
>  {
>   struct v4l2_ctrl *ctrl;
>   unsigned sz_extra = 0;
> @@ -1308,6 +1313,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct
> v4l2_ctrl_handler *hdl, (type == V4L2_CTRL_TYPE_INTEGER && step == 0) ||
>   (type == V4L2_CTRL_TYPE_BITMASK && max == 0) ||
>   (type == V4L2_CTRL_TYPE_MENU && qmenu == NULL) ||
> + (type == V4L2_CTRL_TYPE_INTEGER_MENU && qmenu_int == NULL) ||
>   (type == V4L2_CTRL_TYPE_STRING && max == 0)) {
>   handler_set_err(hdl, -ERANGE);
>   return NULL;
> @@ -1318,6 +1324,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct
> v4l2_ctrl_handler *hdl, }
>   if ((type == V4L2_CTRL_TYPE_INTEGER ||
>type == V4L2_CTRL_TYPE_MENU ||
> +  type == V4L2_CTRL_TYPE_INTEGER_MENU ||
>type == V4L2_CTRL_TYPE_BOOLEAN) &&
>   (def < min || def > max)) {
>   handler_set_err(hdl, -ERANGE);
> @@ -1352,7 +1359,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct
> v4l2_ctrl_handler *hdl, ctrl->minimum = min;
>   ctrl->maximum = max;
>   ctrl->step = step;
> - ctrl->qmenu = qmenu;
> + if (type == V4L2_CTRL_TYPE_MENU)
> + ctrl->qmenu = qmenu;
> + else if (type == V4L2_CTRL_TYPE_INTEGER_MENU)
> + ctrl->qmenu_int = qmenu_int;
>   ctrl->priv = priv;
>   ctrl->cur.val = ctrl->val = ctrl->default_value = def;
> 
> @@ -1379,6 +1389,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct
> v4l2_ctrl_handler *hdl, struct v4l2_ctrl *ctrl;
>   const char *name = cfg->name;
>   const char * const *qmenu = cfg->qmenu;
> + const s64 *qmenu_int = cfg->qmenu_int;
>   enum v4l2_ctrl_type type = cfg->type;
>   u32 flags = cfg->flags;
>   s32 min = cfg->min;
> @@ -1390,18 +1401,24 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct
> v4l2_ctrl_handler *hdl, v4l2_ctrl_fill(cfg->id, &name, &type, &min, &max,
> &step,
>   &def, &flags);
> 
> - is_menu = (cfg->type == V4L2_CTRL_TYPE_MENU);
> + is_menu = (cfg->type == V4L2_CTRL_TYPE_MENU ||
> +cfg->type == V4L2_CTRL_TYPE_INTEGER_MENU);
>   if (is_menu)
>   WARN_ON(step);
>   else
>   WARN_ON(cfg->menu_skip_mask);
> - if (is_menu && qmenu == NULL)
> + if (cfg->type == V4L2_CTRL_TYPE_MENU && qmenu == NULL)
>   qmenu = v4l2_ctrl_get_menu(cfg->id);
> + else if (cfg->type == V4L2_CTRL_TYPE_INTEGER_MENU &&
> +  qmenu_int == NULL) {
> + handler_set_err(hdl, -EINVAL);
> + return NULL;
> + }
> 
>   ctrl = v4l2_ctrl_new(hdl, c

[RFC/PATCH 1/3] v4l: Introduce integer menu controls

2011-11-24 Thread Sakari Ailus
Create a new control type called V4L2_CTRL_TYPE_INTEGER_MENU. Integer menu
controls are just like menu controls but the menu items are 64-bit integers
rather than strings.

Signed-off-by: Sakari Ailus 
---
 drivers/media/video/v4l2-ctrls.c |   63 +++--
 include/linux/videodev2.h|6 +++-
 include/media/v4l2-ctrls.h   |6 +++-
 3 files changed, 56 insertions(+), 19 deletions(-)

diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 0f415da..609eb31 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -804,7 +804,8 @@ static void fill_event(struct v4l2_event *ev, struct 
v4l2_ctrl *ctrl, u32 change
ev->u.ctrl.value64 = ctrl->cur.val64;
ev->u.ctrl.minimum = ctrl->minimum;
ev->u.ctrl.maximum = ctrl->maximum;
-   if (ctrl->type == V4L2_CTRL_TYPE_MENU)
+   if (ctrl->type == V4L2_CTRL_TYPE_MENU
+   || ctrl->type == V4L2_CTRL_TYPE_INTEGER_MENU)
ev->u.ctrl.step = 1;
else
ev->u.ctrl.step = ctrl->step;
@@ -1035,10 +1036,13 @@ static int validate_new_int(const struct v4l2_ctrl 
*ctrl, s32 *pval)
return 0;
 
case V4L2_CTRL_TYPE_MENU:
+   case V4L2_CTRL_TYPE_INTEGER_MENU:
if (val < ctrl->minimum || val > ctrl->maximum)
return -ERANGE;
-   if (ctrl->qmenu[val][0] == '\0' ||
-   (ctrl->menu_skip_mask & (1 << val)))
+   if (ctrl->menu_skip_mask & (1 << val))
+   return -EINVAL;
+   if (ctrl->type == V4L2_CTRL_TYPE_MENU &&
+   ctrl->qmenu[val][0] == '\0')
return -EINVAL;
return 0;
 
@@ -1295,7 +1299,8 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
const struct v4l2_ctrl_ops *ops,
u32 id, const char *name, enum v4l2_ctrl_type type,
s32 min, s32 max, u32 step, s32 def,
-   u32 flags, const char * const *qmenu, void *priv)
+   u32 flags, const char * const *qmenu,
+   const s64 *qmenu_int, void *priv)
 {
struct v4l2_ctrl *ctrl;
unsigned sz_extra = 0;
@@ -1308,6 +1313,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
(type == V4L2_CTRL_TYPE_INTEGER && step == 0) ||
(type == V4L2_CTRL_TYPE_BITMASK && max == 0) ||
(type == V4L2_CTRL_TYPE_MENU && qmenu == NULL) ||
+   (type == V4L2_CTRL_TYPE_INTEGER_MENU && qmenu_int == NULL) ||
(type == V4L2_CTRL_TYPE_STRING && max == 0)) {
handler_set_err(hdl, -ERANGE);
return NULL;
@@ -1318,6 +1324,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
}
if ((type == V4L2_CTRL_TYPE_INTEGER ||
 type == V4L2_CTRL_TYPE_MENU ||
+type == V4L2_CTRL_TYPE_INTEGER_MENU ||
 type == V4L2_CTRL_TYPE_BOOLEAN) &&
(def < min || def > max)) {
handler_set_err(hdl, -ERANGE);
@@ -1352,7 +1359,10 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct 
v4l2_ctrl_handler *hdl,
ctrl->minimum = min;
ctrl->maximum = max;
ctrl->step = step;
-   ctrl->qmenu = qmenu;
+   if (type == V4L2_CTRL_TYPE_MENU)
+   ctrl->qmenu = qmenu;
+   else if (type == V4L2_CTRL_TYPE_INTEGER_MENU)
+   ctrl->qmenu_int = qmenu_int;
ctrl->priv = priv;
ctrl->cur.val = ctrl->val = ctrl->default_value = def;
 
@@ -1379,6 +1389,7 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct 
v4l2_ctrl_handler *hdl,
struct v4l2_ctrl *ctrl;
const char *name = cfg->name;
const char * const *qmenu = cfg->qmenu;
+   const s64 *qmenu_int = cfg->qmenu_int;
enum v4l2_ctrl_type type = cfg->type;
u32 flags = cfg->flags;
s32 min = cfg->min;
@@ -1390,18 +1401,24 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(struct 
v4l2_ctrl_handler *hdl,
v4l2_ctrl_fill(cfg->id, &name, &type, &min, &max, &step,
&def, &flags);
 
-   is_menu = (cfg->type == V4L2_CTRL_TYPE_MENU);
+   is_menu = (cfg->type == V4L2_CTRL_TYPE_MENU ||
+  cfg->type == V4L2_CTRL_TYPE_INTEGER_MENU);
if (is_menu)
WARN_ON(step);
else
WARN_ON(cfg->menu_skip_mask);
-   if (is_menu && qmenu == NULL)
+   if (cfg->type == V4L2_CTRL_TYPE_MENU && qmenu == NULL)
qmenu = v4l2_ctrl_get_menu(cfg->id);
+   else if (cfg->type == V4L2_CTRL_TYPE_INTEGER_MENU &&
+qmenu_int == NULL) {
+   handler_set_err(hdl, -EINVAL);
+   return NULL;
+   }
 
ctrl = v4l2_ctrl_new(hdl, cfg->ops, cfg->id, name,
t