All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Philipp Zabel <philipp.zabel@gmail.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH v2] [media] uvcvideo: Add quirk to force the Oculus DK2 IR tracker to grayscale
Date: Tue, 07 Oct 2014 02:08:41 +0300	[thread overview]
Message-ID: <32858417.QHo0V4RRE4@avalon> (raw)
In-Reply-To: <CA+gwMccBfXtus7mEbGFXidqrNmrttFm24m=x78GRrtgEBC7zjA@mail.gmail.com>

Hi Philipp,

On Monday 06 October 2014 23:45:54 Philipp Zabel wrote:
> On Mon, Oct 6, 2014 at 4:34 PM, Laurent Pinchart wrote:
> >> > @@ -311,6 +311,7 @@ static int uvc_parse_format(struct uvc_device *dev,
> >> >         struct uvc_format_desc *fmtdesc;
> >> >         struct uvc_frame *frame;
> >> >         const unsigned char *start = buffer;
> >> > +       bool force_yuy2_to_y8 = false;
> > 
> > To keep things a bit more generic, how about an unsigned int
> > width_multiplier initialized to 1 and set to 2 when the quirk applies ?
> 
> [...]
> 
> >> > @@ -333,6 +334,22 @@ static int uvc_parse_format(struct uvc_device
> >> > *dev,
> >> > 
> >> >                 /* Find the format descriptor from its GUID. */
> >> >                 fmtdesc = uvc_format_by_guid(&buffer[5]);
> >> > 
> >> > +               format->bpp = buffer[21];
> >> > +
> >> > +               if (dev->quirks & UVC_QUIRK_FORCE_Y8) {
> >> > +                       if (fmtdesc && fmtdesc->fcc ==
> >> > V4L2_PIX_FMT_YUYV
> >> > &&
> >> > +                           format->bpp == 16) {
> > 
> > I wonder if that check is really needed, all YUYV formats should have
> > 16bpp.
> >
> >> > +                               force_yuy2_to_y8 = true;
> >> > +                               fmtdesc = &uvc_fmts[9];
> > 
> > The hardcoded index here is hair-raising :-) How about something like the
> > following instead ?
> > 
> >                 }
> >                 
> >                 format->bpp = buffer[21];
> > 
> > +
> > +               /* Some devices report a format that doesn't match what
> > they
> > +                * really send.
> > +                */
> > +               if (dev->quirks & UVC_QUIRK_FORCE_Y8) {
> > +                       if (format->fcc == V4L2_PIX_FMT_YUYV) {
> > +                               strlcpy(format->name, "Greyscale 8-bit (Y8
> >  )",
> >  +                                       sizeof(format->name));
> > +                               format->fcc = V4L2_PIX_FMT_GREY;
> > +                               format->bpp = 8;
> > +                               width_multiplier = 2;
> > +                       }
> > +               }
> > +
> > 
> >                 if (buffer[2] == UVC_VS_FORMAT_UNCOMPRESSED) {
> >                         ftype = UVC_VS_FRAME_UNCOMPRESSED;
> >                 } else {
> > 
> > I know it duplicates the format string, but as we're trying to move them
> > to the V4L2 core anyway, I don't see that as being a big problem.
> 
> [...]
> 
> >> > @@ -455,6 +471,8 @@ static int uvc_parse_format(struct uvc_device *dev,
> >> > 
> >> >                 frame->bFrameIndex = buffer[3];
> >> >                 frame->bmCapabilities = buffer[4];
> >> >                 frame->wWidth = get_unaligned_le16(&buffer[5]);
> >> > 
> >> > +               if (force_yuy2_to_y8)
> >> > +                       frame->wWidth *= 2;
> > 
> > This would become
> > 
> > +               frame->wWidth = get_unaligned_le16(&buffer[5])
> > +                             * width_multiplier;
> > 
> > If you're fine with that there's no need to resubmit, I'll modify the
> > patch when applying it to my tree.
> 
> Thank you, I'm fine with your suggested changes.
> Especially the format setting part looks a lot more civilized now.

Great. I'll add the patch to my next pull request. Thank you.

-- 
Regards,

Laurent Pinchart


      reply	other threads:[~2014-10-06 23:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-06 20:50 [PATCH v2] [media] uvcvideo: Add quirk to force the Oculus DK2 IR tracker to grayscale Philipp Zabel
2014-09-29 19:38 ` Philipp Zabel
2014-10-06 14:34   ` Laurent Pinchart
2014-10-06 21:45     ` Philipp Zabel
2014-10-06 23:08       ` Laurent Pinchart [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=32858417.QHo0V4RRE4@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=philipp.zabel@gmail.com \
    /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.