2024-04-03 19:59:45

by John Bauer via B4 Relay

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

Signed-off-by: John Bauer <[email protected]>
---
John Bauer (3):
media: uvcvideo: UVC minimum relative pan/tilt/zoom speed fix
media: uvcvideo: UVC minimum relative pan/tilt/zoom speed fix
media: uvcvideo: Moved control checks to helper function

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

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




2024-04-03 20:32:18

by John Bauer via B4 Relay

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

From: John Bauer <[email protected]>

Made recommended changes from Ricardo. I explored the case where
the minimum could be > 0 but less than the maximum. If this were
to occur the range of -maximum to maximum would still apply correctly
however there would be a range from -min to min that would possibly
not apply. It would be possible to capture the probed minimum and
check against that when setting the controls.

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

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

+ if (ctrl->info.flags & UVC_CTRL_FLAG_GET_MAX)
+ v4l2_ctrl->maximum = mapping->get(mapping, UVC_GET_MAX,
+ uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MAX));
+
if (ctrl->info.flags & UVC_CTRL_FLAG_GET_MIN) {
switch (v4l2_ctrl->id) {
case V4L2_CID_ZOOM_CONTINUOUS:
@@ -1332,8 +1336,7 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
* 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));
+ v4l2_ctrl->minimum = -v4l2_ctrl->maximum;
break;
default:
v4l2_ctrl->minimum = mapping->get(mapping, UVC_GET_MIN,
@@ -1342,10 +1345,6 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
}
}

- if (ctrl->info.flags & UVC_CTRL_FLAG_GET_MAX)
- v4l2_ctrl->maximum = mapping->get(mapping, UVC_GET_MAX,
- uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MAX));
-
if (ctrl->info.flags & UVC_CTRL_FLAG_GET_RES)
v4l2_ctrl->step = mapping->get(mapping, UVC_GET_RES,
uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES));
@@ -1940,7 +1939,7 @@ int uvc_ctrl_set(struct uvc_fh *handle,
case V4L2_CID_ZOOM_CONTINUOUS:
case V4L2_CID_PAN_SPEED:
case V4L2_CID_TILT_SPEED:
- min = max * -1;
+ min = -max;
default:
break;
}

--
2.34.1



2024-04-03 20:47:00

by Ricardo Ribalda

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

Hi John

Can you squash all the patches in one and resend as v3?

When you send a new version of your patch, you want to send it as PATCHvX

b4 should do this automatically for you:

- just go to the original branch
git checkout b4/uvc-relative-ptz-speed-fix

- then edit the change with something like
git rebase -i

- then edit the cover to describe the changelog with
b4 prep --edit-cover

-then submit
b4 submit

I will comment on your 2/2... but it should be squashed into your 1/2

Thanks!


On Wed, 3 Apr 2024 at 21:58, John Bauer via B4 Relay
<[email protected]> wrote:
>
> From: John Bauer <[email protected]>
>
> Made recommended changes from Ricardo. I explored the case where
> the minimum could be > 0 but less than the maximum. If this were
> to occur the range of -maximum to maximum would still apply correctly
> however there would be a range from -min to min that would possibly
> not apply. It would be possible to capture the probed minimum and
> check against that when setting the controls.
>
> Signed-off-by: John Bauer <[email protected]>
> ---
> drivers/media/usb/uvc/uvc_ctrl.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
> index b389ab3ee05d..04300a782c81 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -1322,6 +1322,10 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
> break;
> }
>
> + if (ctrl->info.flags & UVC_CTRL_FLAG_GET_MAX)
> + v4l2_ctrl->maximum = mapping->get(mapping, UVC_GET_MAX,
> + uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MAX));
> +
> if (ctrl->info.flags & UVC_CTRL_FLAG_GET_MIN) {
> switch (v4l2_ctrl->id) {
> case V4L2_CID_ZOOM_CONTINUOUS:
> @@ -1332,8 +1336,7 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
> * 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));
> + v4l2_ctrl->minimum = -v4l2_ctrl->maximum;
> break;
> default:
> v4l2_ctrl->minimum = mapping->get(mapping, UVC_GET_MIN,
> @@ -1342,10 +1345,6 @@ static int __uvc_query_v4l2_ctrl(struct uvc_video_chain *chain,
> }
> }
>
> - if (ctrl->info.flags & UVC_CTRL_FLAG_GET_MAX)
> - v4l2_ctrl->maximum = mapping->get(mapping, UVC_GET_MAX,
> - uvc_ctrl_data(ctrl, UVC_CTRL_DATA_MAX));
> -
> if (ctrl->info.flags & UVC_CTRL_FLAG_GET_RES)
> v4l2_ctrl->step = mapping->get(mapping, UVC_GET_RES,
> uvc_ctrl_data(ctrl, UVC_CTRL_DATA_RES));
> @@ -1940,7 +1939,7 @@ int uvc_ctrl_set(struct uvc_fh *handle,
> case V4L2_CID_ZOOM_CONTINUOUS:
> case V4L2_CID_PAN_SPEED:
> case V4L2_CID_TILT_SPEED:
> - min = max * -1;
> + min = -max;
> default:
> break;
> }
>
> --
> 2.34.1
>
>


--
Ricardo Ribalda