Commit a6b69e40 authored by Marton Nemeth's avatar Marton Nemeth Committed by Mauro Carvalho Chehab

V4L/DVB (13298): gspca - pac207/pac7311/mr97310a: Simplify pac_find_sof.

Remove struct sd dependency from pac_find_sof() function implementation.
This step prepares separation of pac7302 and pac7311 specific parts of
struct sd.
Signed-off-by: default avatarMarton Nemeth <nm127@freemail.hu>
Signed-off-by: default avatarJean-Francois Moine <moinejf@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent c86c82b7
...@@ -1034,9 +1034,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -1034,9 +1034,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
__u8 *data, /* isoc packet */ __u8 *data, /* isoc packet */
int len) /* iso packet length */ int len) /* iso packet length */
{ {
struct sd *sd = (struct sd *) gspca_dev;
unsigned char *sof; unsigned char *sof;
sof = pac_find_sof(gspca_dev, data, len); sof = pac_find_sof(&sd->sof_read, data, len);
if (sof) { if (sof) {
int n; int n;
......
...@@ -344,7 +344,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -344,7 +344,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
unsigned char *sof; unsigned char *sof;
sof = pac_find_sof(gspca_dev, data, len); sof = pac_find_sof(&sd->sof_read, data, len);
if (sof) { if (sof) {
int n; int n;
......
...@@ -838,7 +838,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, ...@@ -838,7 +838,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
struct sd *sd = (struct sd *) gspca_dev; struct sd *sd = (struct sd *) gspca_dev;
unsigned char *sof; unsigned char *sof;
sof = pac_find_sof(gspca_dev, data, len); sof = pac_find_sof(&sd->sof_read, data, len);
if (sof) { if (sof) {
unsigned char tmpbuf[4]; unsigned char tmpbuf[4];
int n, lum_offset, footer_length; int n, lum_offset, footer_length;
......
...@@ -72,42 +72,41 @@ static const unsigned char pac_sof_marker[5] = ...@@ -72,42 +72,41 @@ static const unsigned char pac_sof_marker[5] =
+----------+ +----------+
*/ */
static unsigned char *pac_find_sof(struct gspca_dev *gspca_dev, static unsigned char *pac_find_sof(u8 *sof_read,
unsigned char *m, int len) unsigned char *m, int len)
{ {
struct sd *sd = (struct sd *) gspca_dev;
int i; int i;
/* Search for the SOF marker (fixed part) in the header */ /* Search for the SOF marker (fixed part) in the header */
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
switch (sd->sof_read) { switch (*sof_read) {
case 0: case 0:
if (m[i] == 0xff) if (m[i] == 0xff)
sd->sof_read = 1; *sof_read = 1;
break; break;
case 1: case 1:
if (m[i] == 0xff) if (m[i] == 0xff)
sd->sof_read = 2; *sof_read = 2;
else else
sd->sof_read = 0; *sof_read = 0;
break; break;
case 2: case 2:
switch (m[i]) { switch (m[i]) {
case 0x00: case 0x00:
sd->sof_read = 3; *sof_read = 3;
break; break;
case 0xff: case 0xff:
/* stay in this state */ /* stay in this state */
break; break;
default: default:
sd->sof_read = 0; *sof_read = 0;
} }
break; break;
case 3: case 3:
if (m[i] == 0xff) if (m[i] == 0xff)
sd->sof_read = 4; *sof_read = 4;
else else
sd->sof_read = 0; *sof_read = 0;
break; break;
case 4: case 4:
switch (m[i]) { switch (m[i]) {
...@@ -117,18 +116,18 @@ static unsigned char *pac_find_sof(struct gspca_dev *gspca_dev, ...@@ -117,18 +116,18 @@ static unsigned char *pac_find_sof(struct gspca_dev *gspca_dev,
"SOF found, bytes to analyze: %u." "SOF found, bytes to analyze: %u."
" Frame starts at byte #%u", " Frame starts at byte #%u",
len, i + 1); len, i + 1);
sd->sof_read = 0; *sof_read = 0;
return m + i + 1; return m + i + 1;
break; break;
case 0xff: case 0xff:
sd->sof_read = 2; *sof_read = 2;
break; break;
default: default:
sd->sof_read = 0; *sof_read = 0;
} }
break; break;
default: default:
sd->sof_read = 0; *sof_read = 0;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment