public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <j.w.r.degoede@hhs.nl>
To: Simon Farnsworth <simon.farnsworth@onelan.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Hans Verkuil <hverkuil@xs4all.nl>
Subject: Re: libv4l2 and the Hauppauge HVR1600 (cx18 driver) not working well together
Date: Thu, 03 Sep 2009 13:20:33 +0200	[thread overview]
Message-ID: <4A9FA681.5070100@hhs.nl> (raw)
In-Reply-To: <4A9F9C5F.9000007@onelan.com>

Hans Verkuil,

I think we have found a bug in the read() implementation of the cx18
driver, see below.


Hi all,

On 09/03/2009 12:37 PM, Simon Farnsworth wrote:
> Simon Farnsworth wrote:
>> Hans de Goede wrote:
>>> Ok,
>>>
>>> That was even easier then I thought it would be. Attached is a
>>> patch (against libv4l-0.6.1), which implements 1) and 3) from
>>> above.
>>>
>> I applied it to a clone of your HG repository, and had to make a
>> minor change to get it to compile. I've attached the updated patch.
>>
>> It looks like the read() from the card isn't reading entire frames
>> ata a time - I'm using a piece of test gear that I have to return in
>> a couple of hours to send colourbars to it, and I'm seeing bad
>> colour, and the picture moving across the screen. I'll try and chase
>> this, see whether there's something obviously wrong.
>>
> There is indeed something obviously wrong; at line 315 of libv4l2.c, we
> expand the buffer we read into, then ask for that many bytes.
>

Ah, actually this is a driver bug, not a libv4l2 bug, but I'll fix things
in libv4l to work around it for now.

read() should always return an entire frame (or as much of it as will fit
and throw away the rest). Think for example of jpeg streams, where the
exact size of the image isn't known by the client (as it differs from frame
to frame). dest_fmt.fmt.pix.sizeimage purely is an upper limit, and so
is the value passed in to read(), the driver itself should clamp it so
that it returns exactly one frame (for formats which are frame based).

The page alignment (2 pages on i386 / one on x86_64) is done because some
drivers internally use page aligned buffer sizes and thus for example with
jpeg streams, can have frames queued for read() slightly bigger then
dest_fmt.fmt.pix.sizeimage, but when this happens that is really a driver bug,
because as said dest_fmt.fmt.pix.sizeimage should report an upper limit
of the the frame sizes to be expected. I'll remove the align workaround, as
that bug is much less likely to be hit (and probably easier to fix at the
driver level) then the issue we're now seeing with read().

Regards,

Hans

  parent reply	other threads:[~2009-09-03 11:17 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-02 16:32 libv4l2 and the Hauppauge HVR1600 (cx18 driver) not working well together Simon Farnsworth
2009-09-02 17:44 ` Hans de Goede
2009-09-03  9:17   ` Simon Farnsworth
2009-09-03  9:28     ` Hans de Goede
2009-09-03  9:44     ` Hans de Goede
2009-09-03 10:21       ` Simon Farnsworth
2009-09-03 10:37         ` Simon Farnsworth
2009-09-03 10:56           ` Simon Farnsworth
2009-09-03 11:16             ` Andy Walls
2009-09-03 11:20           ` Hans de Goede [this message]
2009-09-03 11:23             ` Andy Walls
2009-09-04  3:14             ` Andy Walls
2009-09-04  6:22               ` Hans de Goede
2009-09-03 11:13         ` Hans de Goede
2009-09-03 11:45     ` Hans de Goede
2009-09-03 11:06   ` Andy Walls
2009-09-03 11:23     ` Simon Farnsworth
2009-09-03 11:29       ` Andy Walls
2009-09-03 11:44         ` Simon Farnsworth
2009-09-03 23:34           ` Andy Walls

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=4A9FA681.5070100@hhs.nl \
    --to=j.w.r.degoede@hhs.nl \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=simon.farnsworth@onelan.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox