diff mbox series

[v2,RESEND] media: uvcvideo: uvc_ctrl_get_rel_speed: use 0 as default

Message ID 088902f67634fb0931da7b045e05afe5c8197cdc.1700505816.git.soyer@irl.hu
State New
Headers show
Series [v2,RESEND] media: uvcvideo: uvc_ctrl_get_rel_speed: use 0 as default | expand

Commit Message

Gergo Koteles Nov. 20, 2023, 6:47 p.m. UTC
Devices with pan/tilt controls but without pan/tilt speed controls
return 1 for the default value of V4L2_CID_PAN_SPEED or
V4L2_CID_TILT_SPEED. For these controls, the value of 1 means a
move and that's not a good default.

Currently, for these controls the UVC_GET_DEF query returns
bPanSpeed or bTiltSpeed of CT_PANTILT_RELATIVE_CONTROL.

According to the UVC 1.5 specification, the default value of bPanSpeed
or bTiltSpeed should be 1 if the pan/tilt control doesn't support
speed control.

"If the control does not support speed control for the Tilt control,
it will return the value 1 in this field for all these requests."

This patch modifies the uvc_ctrl_get_rel_speed to return hardcoded 0
for UVC_GET_DEF query, because that's the stop or don't move value
for these V4L2 controls.

Previous discussion
Link: https://lore.kernel.org/all/CAP_ceTy6XVmvTTAmvCp1YU2wxHwXqnarm69Yaz8K4FmpJqYxAg@mail.gmail.com/

Signed-off-by: Gergo Koteles <soyer@irl.hu>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


base-commit: be9aac187433af6abba5fcc2e73d91d0794ba360

Comments

Ricardo Ribalda March 19, 2024, 9:43 a.m. UTC | #1
Hi Gergo

I missed sending the reviewed-by sorry :)

Btw, do you still have access to the device? Could you tell me what
you get from  and UVC_GET_MAX, UVC_GET_MIN for
UVC_CT_PANTILT_RELATIVE_CONTROL and UVC_CT_ZOOM_RELATIVE_CONTROL ?

Thanks!

On Mon, 20 Nov 2023 at 19:53, Gergo Koteles <soyer@irl.hu> wrote:
>
> Devices with pan/tilt controls but without pan/tilt speed controls
> return 1 for the default value of V4L2_CID_PAN_SPEED or
> V4L2_CID_TILT_SPEED. For these controls, the value of 1 means a
> move and that's not a good default.
>
> Currently, for these controls the UVC_GET_DEF query returns
> bPanSpeed or bTiltSpeed of CT_PANTILT_RELATIVE_CONTROL.
>
> According to the UVC 1.5 specification, the default value of bPanSpeed
> or bTiltSpeed should be 1 if the pan/tilt control doesn't support
> speed control.
>
> "If the control does not support speed control for the Tilt control,
> it will return the value 1 in this field for all these requests."
>
> This patch modifies the uvc_ctrl_get_rel_speed to return hardcoded 0
> for UVC_GET_DEF query, because that's the stop or don't move value
> for these V4L2 controls.
>
> Previous discussion
> Link: https://lore.kernel.org/all/CAP_ceTy6XVmvTTAmvCp1YU2wxHwXqnarm69Yaz8K4FmpJqYxAg@mail.gmail.com/
>
> Signed-off-by: Gergo Koteles <soyer@irl.hu>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
>  drivers/media/usb/uvc/uvc_ctrl.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
> index 5e9d3da862dd..e131958c0930 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -444,9 +444,10 @@ static s32 uvc_ctrl_get_rel_speed(struct uvc_control_mapping *mapping,
>                 return -data[first+1];
>         case UVC_GET_MAX:
>         case UVC_GET_RES:
> +               return data[first+1];
>         case UVC_GET_DEF:
>         default:
> -               return data[first+1];
> +               return 0;
>         }
>  }
>
>
> base-commit: be9aac187433af6abba5fcc2e73d91d0794ba360
> --
> 2.42.0
>
>
Gergo Koteles March 20, 2024, 3:21 p.m. UTC | #2
Hi Ricardo,

On Tue, 2024-03-19 at 10:43 +0100, Ricardo Ribalda wrote:
> Hi Gergo
> 
> I missed sending the reviewed-by sorry :)
> 
> Btw, do you still have access to the device? Could you tell me what
> you get from  and UVC_GET_MAX, UVC_GET_MIN for
> UVC_CT_PANTILT_RELATIVE_CONTROL and UVC_CT_ZOOM_RELATIVE_CONTROL ?
> 

PTZ Pro and BCC950 only have UVC_CT_ZOOM_ABSOLUTE_CONTROL, not
UVC_CT_ZOOM_RELATIVE_CONTROL.

v4l2-ctl -l:

zoom_absolute(int): min=100 max=1000 step=1 default=100 value=100
pan_speed(int): min=-1 max=1 step=1 default=1 value=0
tilt_speed(int): min=-1 max=1 step=1 default=1 value=0

printing data[first], data[first+1] in uvc_ctrl_get_rel_speed:

GET_DEF: 0 1
GET_MIN: 0 1
GET_MAX: 0 1
GET_RES: 0 1
GET_CUR: 0 1


I found the output of Obsbot Tiny v4l2-ctl -l at
https://www.labohyt.net/blog/gadget/post-7643:

pan_absolute(int): min=-468000 max=468000 step=3600 default=0 value=0
tilt_absolute(int): min=-324000 max=324000 step=7200 default=0 value=0
focus_absolute(int): min=0 max=100 step=1 default=0 value=0
flags=inactive
focus_automatic_continuous(bool): default=1 value=1
zoom_absolute(int): min=0 max=100 step=1 default=0 value=0
zoom_continuous(int): min=0 max=100 step=1 default=100 value=0
pan_speed(int): min=-1 max=160 step=1 default=20 value=0
tilt_speed(int): min=-1 max=120 step=1 default=20 value=0

This is where the default value of pan_speed/tilt_speed/zoom_continuous
can be useful, even if they don't work exactly like the defaults for
other controls.

So this patch isn't that good after all.

Regards,
Gergo


> Thanks!
> 
> On Mon, 20 Nov 2023 at 19:53, Gergo Koteles <soyer@irl.hu> wrote:
> > 
> > Devices with pan/tilt controls but without pan/tilt speed controls
> > return 1 for the default value of V4L2_CID_PAN_SPEED or
> > V4L2_CID_TILT_SPEED. For these controls, the value of 1 means a
> > move and that's not a good default.
> > 
> > Currently, for these controls the UVC_GET_DEF query returns
> > bPanSpeed or bTiltSpeed of CT_PANTILT_RELATIVE_CONTROL.
> > 
> > According to the UVC 1.5 specification, the default value of bPanSpeed
> > or bTiltSpeed should be 1 if the pan/tilt control doesn't support
> > speed control.
> > 
> > "If the control does not support speed control for the Tilt control,
> > it will return the value 1 in this field for all these requests."
> > 
> > This patch modifies the uvc_ctrl_get_rel_speed to return hardcoded 0
> > for UVC_GET_DEF query, because that's the stop or don't move value
> > for these V4L2 controls.
> > 
> > Previous discussion
> > Link: https://lore.kernel.org/all/CAP_ceTy6XVmvTTAmvCp1YU2wxHwXqnarm69Yaz8K4FmpJqYxAg@mail.gmail.com/
> > 
> > Signed-off-by: Gergo Koteles <soyer@irl.hu>
> Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
> > ---
> >  drivers/media/usb/uvc/uvc_ctrl.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
> > index 5e9d3da862dd..e131958c0930 100644
> > --- a/drivers/media/usb/uvc/uvc_ctrl.c
> > +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> > @@ -444,9 +444,10 @@ static s32 uvc_ctrl_get_rel_speed(struct uvc_control_mapping *mapping,
> >                 return -data[first+1];
> >         case UVC_GET_MAX:
> >         case UVC_GET_RES:
> > +               return data[first+1];
> >         case UVC_GET_DEF:
> >         default:
> > -               return data[first+1];
> > +               return 0;
> >         }
> >  }
> > 
> > 
> > base-commit: be9aac187433af6abba5fcc2e73d91d0794ba360
> > --
> > 2.42.0
> > 
> > 
> 
>
diff mbox series

Patch

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 5e9d3da862dd..e131958c0930 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -444,9 +444,10 @@  static s32 uvc_ctrl_get_rel_speed(struct uvc_control_mapping *mapping,
 		return -data[first+1];
 	case UVC_GET_MAX:
 	case UVC_GET_RES:
+		return data[first+1];
 	case UVC_GET_DEF:
 	default:
-		return data[first+1];
+		return 0;
 	}
 }