Skip to content

Commit

Permalink
V4L/DVB (13140): gspca_jeilinj: once one frame is discarded it keeps …
Browse files Browse the repository at this point in the history
…discarding all frames

While checking all gspca sub drivers pkt_scan functions for a bug I found in
1 of them (and after checking also in another), I noticed a bug in the
gspca_jeilinj work queue function, once it has decided to start discard a
frame because the application is not reading fast enough (and thus returning
buffers to fill fast enough), it never stops discarding.

This patch fixes this by simply completely removing the "discarding"
variable, if we need to discard the current frame because there is no buffer
to store it, the "frame" pointer will be NULL, so that is all we need to
check.

I've also moved the gspca_get_i_frame() call and the writing of the jpg
header to the buffer to after the first usb_bulk_msg() call, as we don't
need it before that, and that will give the app slightly more time to
queue a buffer for us to fill.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans de Goede authored and Mauro Carvalho Chehab committed Dec 5, 2009
1 parent b3e440e commit 6ca3f25
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions drivers/media/video/gspca/jeilinj.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ static void jlj_dostream(struct work_struct *work)
int blocks_left; /* 0x200-sized blocks remaining in current frame. */
int size_in_blocks;
int act_len;
int discarding = 0; /* true if we failed to get space for frame. */
int packet_type;
int ret;
u8 *buffer;
Expand All @@ -196,15 +195,6 @@ static void jlj_dostream(struct work_struct *work)
goto quit_stream;
}
while (gspca_dev->present && gspca_dev->streaming) {
if (!gspca_dev->present)
goto quit_stream;
/* Start a new frame, and add the JPEG header, first thing */
frame = gspca_get_i_frame(gspca_dev);
if (frame && !discarding)
gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
dev->jpeg_hdr, JPEG_HDR_SZ);
else
discarding = 1;
/*
* Now request data block 0. Line 0 reports the size
* to download, in blocks of size 0x200, and also tells the
Expand All @@ -222,14 +212,17 @@ static void jlj_dostream(struct work_struct *work)
size_in_blocks = buffer[0x0a];
blocks_left = buffer[0x0a] - 1;
PDEBUG(D_STREAM, "blocks_left = 0x%x", blocks_left);
packet_type = INTER_PACKET;
if (frame && !discarding)

/* Start a new frame, and add the JPEG header, first thing */
frame = gspca_get_i_frame(gspca_dev);
if (frame) {
gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
dev->jpeg_hdr, JPEG_HDR_SZ);
/* Toss line 0 of data block 0, keep the rest. */
gspca_frame_add(gspca_dev, packet_type,
gspca_frame_add(gspca_dev, INTER_PACKET,
frame, buffer + FRAME_HEADER_LEN,
JEILINJ_MAX_TRANSFER - FRAME_HEADER_LEN);
else
discarding = 1;
}
while (blocks_left > 0) {
if (!gspca_dev->present)
goto quit_stream;
Expand All @@ -246,12 +239,10 @@ static void jlj_dostream(struct work_struct *work)
packet_type = LAST_PACKET;
else
packet_type = INTER_PACKET;
if (frame && !discarding)
if (frame)
gspca_frame_add(gspca_dev, packet_type,
frame, buffer,
JEILINJ_MAX_TRANSFER);
else
discarding = 1;
}
}
quit_stream:
Expand Down

0 comments on commit 6ca3f25

Please sign in to comment.