diff options
author | Hans de Goede <hdegoede@redhat.com> | 2009-06-14 05:21:35 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-23 02:11:40 -0400 |
commit | 92918a53ee74bb326430aaa958caa0cf111b54b1 (patch) | |
tree | 405033eaf382dd1e61f06c5e892802def6535c2c /drivers/media/video | |
parent | 124cc9c0c8acc77ac2f1114ee7eea961334020ba (diff) |
V4L/DVB (12075): gspca_ov519: check ov518 packet numbers
Check ov518 packet numbers to detect dropped packets.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/gspca/ov519.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c index 55db32c95bea..c2982137dc21 100644 --- a/drivers/media/video/gspca/ov519.c +++ b/drivers/media/video/gspca/ov519.c | |||
@@ -50,6 +50,8 @@ static int i2c_detect_tries = 10; | |||
50 | struct sd { | 50 | struct sd { |
51 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 51 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
52 | 52 | ||
53 | __u8 packet_nr; | ||
54 | |||
53 | char bridge; | 55 | char bridge; |
54 | #define BRIDGE_OV511 0 | 56 | #define BRIDGE_OV511 0 |
55 | #define BRIDGE_OV511PLUS 1 | 57 | #define BRIDGE_OV511PLUS 1 |
@@ -2391,18 +2393,33 @@ static void ov518_pkt_scan(struct gspca_dev *gspca_dev, | |||
2391 | __u8 *data, /* isoc packet */ | 2393 | __u8 *data, /* isoc packet */ |
2392 | int len) /* iso packet length */ | 2394 | int len) /* iso packet length */ |
2393 | { | 2395 | { |
2394 | PDEBUG(D_STREAM, "ov518_pkt_scan: %d bytes", len); | 2396 | struct sd *sd = (struct sd *) gspca_dev; |
2395 | |||
2396 | if (len & 7) { | ||
2397 | len--; | ||
2398 | PDEBUG(D_STREAM, "packet number: %d\n", (int)data[len]); | ||
2399 | } | ||
2400 | 2397 | ||
2401 | /* A false positive here is likely, until OVT gives me | 2398 | /* A false positive here is likely, until OVT gives me |
2402 | * the definitive SOF/EOF format */ | 2399 | * the definitive SOF/EOF format */ |
2403 | if ((!(data[0] | data[1] | data[2] | data[3] | data[5])) && data[6]) { | 2400 | if ((!(data[0] | data[1] | data[2] | data[3] | data[5])) && data[6]) { |
2404 | gspca_frame_add(gspca_dev, LAST_PACKET, frame, data, 0); | 2401 | gspca_frame_add(gspca_dev, LAST_PACKET, frame, data, 0); |
2405 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, 0); | 2402 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, 0); |
2403 | sd->packet_nr = 0; | ||
2404 | } | ||
2405 | |||
2406 | if (gspca_dev->last_packet_type == DISCARD_PACKET) | ||
2407 | return; | ||
2408 | |||
2409 | /* Does this device use packet numbers ? */ | ||
2410 | if (len & 7) { | ||
2411 | len--; | ||
2412 | if (sd->packet_nr == data[len]) | ||
2413 | sd->packet_nr++; | ||
2414 | /* The last few packets of the frame (which are all 0's | ||
2415 | except that they may contain part of the footer), are | ||
2416 | numbered 0 */ | ||
2417 | else if (sd->packet_nr == 0 || data[len]) { | ||
2418 | PDEBUG(D_ERR, "Invalid packet nr: %d (expect: %d)", | ||
2419 | (int)data[len], (int)sd->packet_nr); | ||
2420 | gspca_dev->last_packet_type = DISCARD_PACKET; | ||
2421 | return; | ||
2422 | } | ||
2406 | } | 2423 | } |
2407 | 2424 | ||
2408 | /* intermediate packet */ | 2425 | /* intermediate packet */ |