From: Hans de Goede <hdegoede@redhat.com>
To: kilgota@banach.math.auburn.edu
Cc: Kyle Guinn <elyk03@gmail.com>,
Jean-Francois Moine <moinejf@free.fr>,
linux-media@vger.kernel.org
Subject: Re: RFC on proposed patches to mr97310a.c for gspca and v4l
Date: Thu, 05 Mar 2009 20:07:42 +0100 [thread overview]
Message-ID: <49B022FE.3050206@redhat.com> (raw)
In-Reply-To: <alpine.LNX.2.00.0903051232350.27780@banach.math.auburn.edu>
kilgota@banach.math.auburn.edu wrote:
>
>
> On Thu, 5 Mar 2009, Hans de Goede wrote:
>
>>
>>
>> Kyle Guinn wrote:
>>> On Wednesday 04 March 2009 22:34:13 kilgota@banach.math.auburn.edu
>>> wrote:
>>>> On Wed, 4 Mar 2009, Kyle Guinn wrote:
>>>>> On Tuesday 03 March 2009 18:12:33 kilgota@banach.math.auburn.edu
>>>>> wrote:
>>>>>> contents of file mr97310a.patch follow, for gspca/mr97310a.c
>>>>>> --------------------------------------------------------
>>>>>> --- mr97310a.c.old 2009-02-23 23:59:07.000000000 -0600
>>>>>> +++ mr97310a.c.new 2009-03-03 17:19:06.000000000 -0600
>>>>>> @@ -302,21 +302,9 @@ static void sd_pkt_scan(struct gspca_dev
>>>>>> data, n);
>>>>>> sd->header_read = 0;
>>>>>> gspca_frame_add(gspca_dev, FIRST_PACKET, frame, NULL, 0);
>>>>>> - len -= sof - data;
>>>>>> - data = sof;
>>>>>> - }
>>>>>> - if (sd->header_read < 7) {
>>>>>> - int needed;
>>>>>> -
>>>>>> - /* skip the rest of the header */
>>>>>> - needed = 7 - sd->header_read;
>>>>>> - if (len <= needed) {
>>>>>> - sd->header_read += len;
>>>>>> - return;
>>>>>> - }
>>>>>> - data += needed;
>>>>>> - len -= needed;
>>>>>> - sd->header_read = 7;
>>>>>> + /* keep the header, including sof marker, for coming
>>>>>> frame */
>>>>>> + len -= n;
>>>>>> + data = sof - sizeof pac_sof_marker;;
>>>>>> }
>>>>>>
>>>>>> gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
>>>>> A few notes:
>>>>>
>>>>> 1. There is an extra semicolon on that last added line.
>>>> Oops. My bifocals.
>>>>
>>>>> 2. sd->header_read no longer seems necessary.
>>>> This is very likely true.
>>>>
>>>>> 3. If the SOF marker is split over two transfers then everything
>>>>> falls
>>>>> apart.
>>>> Are you sure about that?
>>>>
>>>
>>> Simple example: One transfer ends with FF FF 00 and the next begins
>>> with FF 96 64. pac_find_sof() returns a pointer to 64, n is set to
>>> 0, len stays the same, data now points at 3 bytes _before_ the
>>> transfer buffer, and we will most likely get undefined behavior when
>>> trying to copy the data out of the transfer buffer. Not only that,
>>> but the FF FF 00 portion of the SOF won't get copied to the frame
>>> buffer.
>>>
>>
>> Good point, since we will always pass frames to userspace which start
>> with the
>> sof, maybe we should just only pass the variable part of the header to
>> userspace?
>>
>> That sure feels like the easiest solution to me.
>>
>> Regards,
>>
>> Hans
>>
>
> Hans, that would not solve the problem. In fact, it appears to me that
> this problem was already inherent in the driver code before I proposed
> any patches at all.
Erm, if I understood correctly (haven't looked yet) the driver is working
with the sof detection from pac_common, which does work with a SOF split
over multiple frames.
The problem with the new code is that it takes the return value of the sof
detection (which is a pointer into the current frame) and then
substracts the length of the sofmarker, however if only part of the sof was
in the current frame the resulting pointer (after substracting the sof length)
will point to before the current frame buffer.
Hence my proposal to fix this by simple only sending the variable part of the
header to userspace (and thus not do the substraction).
Anyways this is just what I understood from the former discussion I have *not*
looked at the actual code (-ENOTIME)
Regards,
Hans
next prev parent reply other threads:[~2009-03-05 19:01 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-17 19:09 MR97310A and other image formats Jean-Francois Moine
2009-02-17 19:35 ` Thomas Kaiser
2009-02-18 9:25 ` Jean-Francois Moine
2009-02-18 12:58 ` Thomas Kaiser
2009-02-18 19:17 ` Jean-Francois Moine
2009-02-17 19:43 ` Thomas Kaiser
2009-02-18 1:07 ` Kyle Guinn
2009-02-19 0:40 ` kilgota
2009-03-04 0:12 ` RFC on proposed patches to mr97310a.c for gspca and v4l kilgota
2009-03-04 2:50 ` Kyle Guinn
2009-03-04 5:21 ` kilgota
2009-03-04 8:41 ` Thomas Kaiser
2009-03-04 8:54 ` Thomas Kaiser
2009-03-04 19:01 ` kilgota
2009-03-05 13:02 ` Thomas Kaiser
2009-03-05 18:29 ` kilgota
2009-03-05 19:19 ` Thomas Kaiser
2009-03-05 19:45 ` kilgota
2009-03-05 20:29 ` Thomas Kaiser
2009-03-05 20:55 ` kilgota
2009-03-05 20:51 ` Thomas Kaiser
2009-04-15 23:59 ` Some questions about mr97310 controls (continuing previous thread on mr97310a.c) Theodore Kilgore
2009-04-16 16:10 ` Thomas Kaiser
2009-04-16 22:50 ` Theodore Kilgore
2009-04-17 8:36 ` Hans de Goede
2009-05-02 1:47 ` Progress with the MR97310A "CIF" cameras Theodore Kilgore
2009-04-16 5:14 ` RFC on proposed patches to mr97310a.c for gspca and v4l Kyle Guinn
2009-04-16 18:22 ` Theodore Kilgore
2009-04-17 4:33 ` Kyle Guinn
2009-04-17 17:50 ` Theodore Kilgore
2009-04-18 0:04 ` Kyle Guinn
2009-04-18 0:43 ` Theodore Kilgore
2009-04-21 1:18 ` RFC on proposed patches to mr97310a.c for gspca and v4l (headers) Theodore Kilgore
2009-04-21 2:44 ` Theodore Kilgore
2009-05-15 22:31 ` Preliminary results with an SN9C2028 camera Theodore Kilgore
2009-05-19 7:56 ` Hans de Goede
2009-05-19 18:18 ` Theodore Kilgore
2009-03-04 8:39 ` RFC on proposed patches to mr97310a.c for gspca and v4l Hans de Goede
2009-03-04 18:46 ` kilgota
2009-03-05 1:33 ` Kyle Guinn
2009-03-05 7:01 ` Hans de Goede
2009-03-04 8:35 ` Hans de Goede
2009-03-05 2:49 ` Kyle Guinn
2009-03-05 4:34 ` kilgota
2009-03-05 5:54 ` Kyle Guinn
2009-03-05 6:47 ` kilgota
2009-03-05 7:00 ` Hans de Goede
2009-03-05 19:08 ` kilgota
2009-03-05 19:07 ` Hans de Goede [this message]
2009-03-05 20:42 ` kilgota
2009-03-05 20:40 ` Hans de Goede
2009-03-05 20:58 ` kilgota
2009-03-06 1:21 ` Kyle Guinn
2009-03-06 1:57 ` kilgota
2009-03-28 22:42 ` [PATCH] to add new camera in gspca/mr97310a.c Theodore Kilgore
2009-02-19 18:17 ` MR97310A and other image formats kilgota
2009-02-19 19:17 ` Thomas Kaiser
2009-02-19 21:54 ` kilgota
2009-02-19 22:45 ` Thomas Kaiser
2009-02-19 23:50 ` kilgota
2009-02-20 0:52 ` Thomas Kaiser
2009-02-20 1:32 ` kilgota
2009-02-20 8:00 ` Thomas Kaiser
2009-02-20 18:45 ` kilgota
2009-02-20 19:05 ` Thomas Kaiser
2009-02-20 20:26 ` kilgota
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=49B022FE.3050206@redhat.com \
--to=hdegoede@redhat.com \
--cc=elyk03@gmail.com \
--cc=kilgota@banach.math.auburn.edu \
--cc=linux-media@vger.kernel.org \
--cc=moinejf@free.fr \
/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