All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ricardo Ribalda <ribalda@chromium.org>
To: John Bauer <john@oxt.co>
Cc: Gergo Koteles <soyer@irl.hu>,
	johnebgood@securitylive.com,
	 Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	 Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linh.tp.vu@gmail.com
Subject: Re: [PATCH] uvcvideo: Remo OBSBOT quirk fix for incorrect relative min pan/tilt/zoom speeds
Date: Tue, 26 Mar 2024 15:27:25 +0100	[thread overview]
Message-ID: <CANiDSCu7qRnySQn=YJ=pkOOYe50H89CDw_AGu287LfjWebnnYQ@mail.gmail.com> (raw)
In-Reply-To: <CAMB8T1W5K68fX4jw=V8+kqc8eT2HGCv75PAidO0Nkzy-A1jFAQ@mail.gmail.com>

Hi John

On Tue, 26 Mar 2024 at 09:15, John Bauer <john@oxt.co> wrote:
>
> According to the spec bPanRelative and bTiltRelative are of "Signed
> Number" but bPanSpeed and bTiltSpeed are of "Number". I think this
> implies that a negative number is not possible for a minimum here.
>
> It is very beneficial that the direction and speed are condensed into
> one value, it greatly simplifies control as shown in a test I just did
> below.
>
> Here is a quick test I just did with the patch I'll be sending
> shortly: https://www.youtube.com/watch?v=1XqWPROw49s

That looks pretty cool :)

Thanks!

>
> Thanks,
> John
>
> On Tue, Mar 26, 2024 at 2:47 AM Ricardo Ribalda <ribalda@chromium.org> wrote:
> >
> > Hi Jon, Hi Gergo
> >
> > On Tue, 26 Mar 2024 at 07:23, John Bauer <john@oxt.co> wrote:
> > >
> > > After looking through the current implementation all of the proper checks are done in the getter and setter for the pan/tilt/zoom controls so the only change needed is the 2 locations to get/check/set the minimum when needed. Thankfully all the code that does the hard work is already implemented. I'll be submitting another patch that summarizes our findings.
> >
> >
> > My issue with the spec is that it is not clear about what GET_MIN
> > should return.  Is it the minimum absolute value for that control, or
> > the minimum value in that direction?
> >
> > In other words, can we have a device with a range (-10,20) (-A,B), or
> > only (-20,20) (-A,A) is allowed.
> >
> > If there is no device that supports (-A,B), then we do not need a quirk.
> >
> > Regards!
> >
> >
> > >
> > > Thanks,
> > > John
> > >
> > >
> > >
> > > On Mon, Mar 25, 2024 at 10:42 PM John Bauer <john@oxt.co> wrote:
> > >>
> > >> Ok, I get you now Gergo, I think I got lucky and I think you're right! Digging into the UVC 1.5 spec I can see why this works, the first byte in each 2 byte pair signifying the direction is just getting the signed bit set when a negative value is applied to both bytes so there should probably be some checks.
> > >>
> > >> Here from the UVC 1.5 spec:  CT_PANTILT_RELATIVE_CONTROL
> > >> +--------+---------------+------+---------------+------------------------------------------------+
> > >> | Offset |     Field     | Size |     Value     |                  Description                   |
> > >> +--------+---------------+------+---------------+------------------------------------------------+
> > >> |      0 | bPanRelative  |    1 | Signed Number | 0: Stop, 1: clockwise, 0xFF: counter-clockwise |
> > >> |      1 | bPanSpeed     |    1 | Number        | Speed of the Pan movement                      |
> > >> |      2 | bTiltRelative |    1 | Signed Number | 0: Stop, 1: tilt up, 0xFF: tilt down           |
> > >> |      3 | bTiltSpeed    |    1 | Number        | Speed for the Tilt movement                    |
> > >> +--------+---------------+------+---------------+------------------------------------------------+
> > >>
> > >> I think it is the direction of the original implementation which is way easier to use than having 2 controls anyway, I would say it's preferred, it's how I have all my analog stick controls mappings.
> > >>
> > >> While the OBSBOT firmware implementation may handle any signed negative value in the direction byte we should probably check and make sure it conforms to spec with 0xFF for counter clockwise and down.
> > >>
> > >> In the current implementation both pan and tilt each use 2 bytes:
> > >>
> > >> {
> > >> .id = V4L2_CID_PAN_SPEED,
> > >> .entity = UVC_GUID_UVC_CAMERA,
> > >> .selector = UVC_CT_PANTILT_RELATIVE_CONTROL,
> > >> .size = 16,
> > >> .offset = 0,
> > >> .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
> > >> .data_type = UVC_CTRL_DATA_TYPE_SIGNED,
> > >> .get = uvc_ctrl_get_rel_speed,
> > >> .set = uvc_ctrl_set_rel_speed,
> > >> },
> > >> {
> > >> .id = V4L2_CID_TILT_SPEED,
> > >> .entity = UVC_GUID_UVC_CAMERA,
> > >> .selector = UVC_CT_PANTILT_RELATIVE_CONTROL,
> > >> .size = 16,
> > >> .offset = 16,
> > >> .v4l2_type = V4L2_CTRL_TYPE_INTEGER,
> > >> .data_type = UVC_CTRL_DATA_TYPE_SIGNED,
> > >> .get = uvc_ctrl_get_rel_speed,
> > >> .set = uvc_ctrl_set_rel_speed,
> > >> },
> > >>
> > >> Going to do some testing and report back.
> > >>
> > >> Thanks,
> > >> John
> > >>
> > >>
> > >>
> > >> On Mon, Mar 25, 2024 at 9:23 PM Gergo Koteles <soyer@irl.hu> wrote:
> > >>>
> > >>> Hi John,
> > >>>
> > >>> On Mon, 2024-03-25 at 20:51 -0500, John Bauer wrote:
> > >>>
> > >>> I understand this patch might not be the ideal or proper solution; but it works. I don't think the UVC
> > >>> implementation can be trusted on these cameras, just like the Windows DirectShow implementation is off.
> > >>> I put this patch out there as I have encountered many Linux users who are struggling to get proper
> > >>> control of these awesome cameras. If the patch dies here for now, that's OK, at least there's a possible
> > >>> patch for those in need.
> > >>>
> > >>>
> > >>> Sorry, maybe I didn't phrase it well. Based on the UVC specs, I think your patch is good for all UVC PTZ cameras, so you don't need to use UVC_QUIRK_OBSBOT_MIN_SETTINGS quirk entry, just apply the quirk changes to all cameras.
> > >>>
> > >>> Thanks for doing this!
> > >>>
> > >>> Regards,
> > >>> Gergo
> > >>>
> >
> >
> > --
> > Ricardo Ribalda



-- 
Ricardo Ribalda

      reply	other threads:[~2024-03-26 14:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26  0:38 [PATCH] uvcvideo: Remo OBSBOT quirk fix for incorrect relative min pan/tilt/zoom speeds John Bauer via B4 Relay
2024-03-26  0:38 ` John Bauer
2024-03-26  1:07 ` Gergo Koteles
     [not found]   ` <CAMB8T1ULcfBOB5VwZzUtvRnp4FvtBCFWxxTdb+OJK8FOpjKCXA@mail.gmail.com>
2024-03-26  2:25     ` Gergo Koteles
     [not found]     ` <ec0430f6e687fc5e1a19338e381804b9d6aeabba.camel@irl.hu>
     [not found]       ` <CAMB8T1Vv7CMqhH1ZY6fouxsE6r+6JbmeLnuFma_0_de814UoMA@mail.gmail.com>
     [not found]         ` <CAMB8T1VWGaWtE0k5en4-xhE69G=OyFnhqJ3mexcgNSuvO_7uUQ@mail.gmail.com>
2024-03-26  7:47           ` Ricardo Ribalda
2024-03-26  8:15             ` John Bauer
2024-03-26 14:27               ` Ricardo Ribalda [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANiDSCu7qRnySQn=YJ=pkOOYe50H89CDw_AGu287LfjWebnnYQ@mail.gmail.com' \
    --to=ribalda@chromium.org \
    --cc=john@oxt.co \
    --cc=johnebgood@securitylive.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linh.tp.vu@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=soyer@irl.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.