2024-04-05 07:08:23

by John Bauer via B4 Relay

[permalink] [raw]
Subject: [PATCH 0/2] media: uvcvideo: UVC minimum relative pan/tilt/zoom speed fix

Thanks for the help Ricardo, still figuring out this whole workflow.

Signed-off-by: John Bauer <[email protected]>
---
Changes in v2:
- Made recommended changes, moved control check to helper function and removed dead code.
- Link to v1: https://lore.kernel.org/all/20240326-uvc-relative-ptz-speed-fix-v1-1-453fd5ccfd37@securitylive.com/

---
John Bauer (2):
media: uvcvideo: UVC minimum relative pan/tilt/zoom speed fix.
Made recommended changes

drivers/media/usb/uvc/uvc_ctrl.c | 38 +++++++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 5 deletions(-)
---
base-commit: e8f897f4afef0031fe618a8e94127a0934896aba
change-id: 20240405-uvc-fix-relative-ptz-speed-e671f9a34449

Best regards,
--
John Bauer <[email protected]>




2024-04-05 07:08:24

by John Bauer via B4 Relay

[permalink] [raw]
Subject: [PATCH 1/2] media: uvcvideo: UVC minimum relative pan/tilt/zoom speed fix.

From: John Bauer <[email protected]>

The minimum UVC control value for the relative pan/tilt/zoom speeds
cannot be probed as the implementation condenses the pan and tilt
direction and speed into two 16 bit values. The minimum cannot be
set at probe time because it is probed first and the maximum is not
yet known. With this fix if a relative speed control is queried
or set the minimum is set and checked based on the additive inverse of
the maximum at that time.

Signed-off-by: John Bauer <[email protected]>
---
drivers/media/usb/uvc/uvc_ctrl.c | 37 ++++++++++++++++++++++++++++++++++---
1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index e59a463c2761..b389ab3ee05d 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1322,9 +1322,25 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
break;
}

- if (ctrl->info.flags & UVC_CTRL_FLAG_GET_MIN)
- v4l2_ctrl->minimum = mapping->get(mapping, UVC_GET_MIN,
- uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MIN));
+ if (ctrl->info.flags & UVC_CTRL_FLAG_GET_MIN) {
+ switch (v4l2_ctrl->id) {
+ case V4L2_CID_ZOOM_CONTINUOUS:
+ case V4L2_CID_PAN_SPEED:
+ case V4L2_CID_TILT_SPEED:
+ /*
+ * For the relative speed implementation the minimum
+ * value cannot be probed so it becomes the additive
+ * inverse of maximum.
+ */
+ v4l2_ctrl->minimum = -1 * mapping->get(mapping, UVC_GET_MAX,
+ uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MAX));
+ break;
+ default:
+ v4l2_ctrl->minimum = mapping->get(mapping, UVC_GET_MIN,
+ uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MIN));
+ break;
+ }
+ }

if (ctrl->info.flags & UVC_CTRL_FLAG_GET_MAX)
v4l2_ctrl->maximum = mapping->get(mapping, UVC_GET_MAX,
@@ -1914,6 +1930,21 @@ int uvc_ctrl_set(struct uvc_fh *handle,
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MIN));
max = mapping->get(mapping, UVC_GET_MAX,
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MAX));
+
+ /*
+ * For the relative speed implementation the minimum
+ * value cannot be probed so it becomes the additive
+ * inverse of maximum.
+ */
+ switch (xctrl->id) {
+ case V4L2_CID_ZOOM_CONTINUOUS:
+ case V4L2_CID_PAN_SPEED:
+ case V4L2_CID_TILT_SPEED:
+ min = max * -1;
+ default:
+ break;
+ }
+
step = mapping->get(mapping, UVC_GET_RES,
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES));
if (step == 0)

--
2.34.1



2024-04-05 07:24:20

by Ricardo Ribalda

[permalink] [raw]
Subject: Re: [PATCH 0/2] media: uvcvideo: UVC minimum relative pan/tilt/zoom speed fix

Hi John

On Fri, 5 Apr 2024 at 09:07, John Bauer via B4 Relay
<[email protected]> wrote:
>
> Thanks for the help Ricardo, still figuring out this whole workflow.

Thanks for the changes. Can you squash 2/2 on 1/2 ?

I wonder why the patches are sent as PATCH instead of PATCHv2 ... :?
Are you using the last version of b4?

btw, if you want to avoid sending the patches to the list for testing you can do
b4 send --dry-run
and that will print the email instead of sending it.


>
> Signed-off-by: John Bauer <[email protected]>
> ---
> Changes in v2:
> - Made recommended changes, moved control check to helper function and removed dead code.
> - Link to v1: https://lore.kernel.org/all/20240326-uvc-relative-ptz-speed-fix-v1-1-453fd5ccfd37@securitylive.com/
>
> ---
> John Bauer (2):
> media: uvcvideo: UVC minimum relative pan/tilt/zoom speed fix.
> Made recommended changes
>
> drivers/media/usb/uvc/uvc_ctrl.c | 38 +++++++++++++++++++++++++++++++++-----
> 1 file changed, 33 insertions(+), 5 deletions(-)
> ---
> base-commit: e8f897f4afef0031fe618a8e94127a0934896aba
> change-id: 20240405-uvc-fix-relative-ptz-speed-e671f9a34449
>
> Best regards,
> --
> John Bauer <[email protected]>
>
>


--
Ricardo Ribalda