From: Hans de Goede <hdegoede@redhat.com>
To: "Németh Márton" <nm127@freemail.hu>
Cc: Jean-Francois Moine <moinejf@free.fr>,
ltp-list@lists.sourceforge.net,
LKML <linux-kernel@vger.kernel.org>,
Theodore Kilgore <kilgota@auburn.edu>,
Thomas Kaiser <thomas@kaiser-linux.li>,
Kyle Guinn <elyk03@gmail.com>,
V4L Mailing List <linux-media@vger.kernel.org>
Subject: Re: [LTP] [PATCH] pac_common: redesign function for finding Start Of Frame
Date: Mon, 05 Oct 2009 09:32:24 +0200 [thread overview]
Message-ID: <4AC9A108.8040504@redhat.com> (raw)
In-Reply-To: <4AC90BBF.9040803@freemail.hu>
Hi,
Good one,
Acked-by: Hans de Goede <hdegoede@redhat.com>
Jean-Francois, can you please add this patch to your tree?
Thanks,
Hans
On 10/04/2009 10:55 PM, Németh Márton wrote:
> From: Márton Németh<nm127@freemail.hu>
>
> The original implementation of pac_find_sof() does not always find
> the Start Of Frame (SOF) marker. Replace it with a state machine
> based design.
>
> The change was tested with Labtec Webcam 2200.
>
> Signed-off-by: Márton Németh<nm127@freemail.hu>
> ---
> --- linux-2.6.32-rc1.orig/drivers/media/video/gspca/pac_common.h 2009-09-10 00:13:59.000000000 +0200
> +++ linux-2.6.32-rc1/drivers/media/video/gspca/pac_common.h 2009-10-04 21:49:19.000000000 +0200
> @@ -33,6 +33,45 @@
> static const unsigned char pac_sof_marker[5] =
> { 0xff, 0xff, 0x00, 0xff, 0x96 };
>
> +/*
> + The following state machine finds the SOF marker sequence
> + 0xff, 0xff, 0x00, 0xff, 0x96 in a byte stream.
> +
> + +----------+
> + | 0: START |<---------------\
> + +----------+<-\ |
> + | \---/otherwise |
> + v 0xff |
> + +----------+ otherwise |
> + | 1 |--------------->*
> + | | ^
> + +----------+ |
> + | |
> + v 0xff |
> + +----------+<-\0xff |
> + /->| |--/ |
> + | | 2 |--------------->*
> + | | | otherwise ^
> + | +----------+ |
> + | | |
> + | v 0x00 |
> + | +----------+ |
> + | | 3 | |
> + | | |--------------->*
> + | +----------+ otherwise ^
> + | | |
> + 0xff | v 0xff |
> + | +----------+ |
> + \--| 4 | |
> + | |----------------/
> + +----------+ otherwise
> + |
> + v 0x96
> + +----------+
> + | FOUND |
> + +----------+
> +*/
> +
> static unsigned char *pac_find_sof(struct gspca_dev *gspca_dev,
> unsigned char *m, int len)
> {
> @@ -41,17 +80,54 @@ static unsigned char *pac_find_sof(struc
>
> /* Search for the SOF marker (fixed part) in the header */
> for (i = 0; i< len; i++) {
> - if (m[i] == pac_sof_marker[sd->sof_read]) {
> - sd->sof_read++;
> - if (sd->sof_read == sizeof(pac_sof_marker)) {
> + switch (sd->sof_read) {
> + case 0:
> + if (m[i] == 0xff)
> + sd->sof_read = 1;
> + break;
> + case 1:
> + if (m[i] == 0xff)
> + sd->sof_read = 2;
> + else
> + sd->sof_read = 0;
> + break;
> + case 2:
> + switch (m[i]) {
> + case 0x00:
> + sd->sof_read = 3;
> + break;
> + case 0xff:
> + /* stay in this state */
> + break;
> + default:
> + sd->sof_read = 0;
> + }
> + break;
> + case 3:
> + if (m[i] == 0xff)
> + sd->sof_read = 4;
> + else
> + sd->sof_read = 0;
> + break;
> + case 4:
> + switch (m[i]) {
> + case 0x96:
> + /* Pattern found */
> PDEBUG(D_FRAM,
> "SOF found, bytes to analyze: %u."
> " Frame starts at byte #%u",
> len, i + 1);
> sd->sof_read = 0;
> return m + i + 1;
> + break;
> + case 0xff:
> + sd->sof_read = 2;
> + break;
> + default:
> + sd->sof_read = 0;
> }
> - } else {
> + break;
> + default:
> sd->sof_read = 0;
> }
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
prev parent reply other threads:[~2009-10-05 7:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-04 20:55 [LTP] [PATCH] pac_common: redesign function for finding Start Of Frame Németh Márton
2009-10-04 20:56 ` Németh Márton
2009-10-13 14:43 ` Subrata Modak
2009-10-05 7:32 ` Hans de Goede [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=4AC9A108.8040504@redhat.com \
--to=hdegoede@redhat.com \
--cc=elyk03@gmail.com \
--cc=kilgota@auburn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=ltp-list@lists.sourceforge.net \
--cc=moinejf@free.fr \
--cc=nm127@freemail.hu \
--cc=thomas@kaiser-linux.li \
/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