aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2009-10-09 02:58:35 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-05 15:40:31 -0500
commit6ca3f255f790764f9cfc41d3ac02823d83dfa5ac (patch)
tree5ec7281ec5b06fc1b8458fe92d14169b410c744f /drivers
parentb3e440eef8a842736d63cc6a6594d80dfbb75fd9 (diff)
V4L/DVB (13140): gspca_jeilinj: once one frame is discarded it keeps 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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/gspca/jeilinj.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/media/video/gspca/jeilinj.c b/drivers/media/video/gspca/jeilinj.c
index a11c97ebeb0f..d679970d5b3e 100644
--- a/drivers/media/video/gspca/jeilinj.c
+++ b/drivers/media/video/gspca/jeilinj.c
@@ -185,7 +185,6 @@ static void jlj_dostream(struct work_struct *work)
185 int blocks_left; /* 0x200-sized blocks remaining in current frame. */ 185 int blocks_left; /* 0x200-sized blocks remaining in current frame. */
186 int size_in_blocks; 186 int size_in_blocks;
187 int act_len; 187 int act_len;
188 int discarding = 0; /* true if we failed to get space for frame. */
189 int packet_type; 188 int packet_type;
190 int ret; 189 int ret;
191 u8 *buffer; 190 u8 *buffer;
@@ -196,15 +195,6 @@ static void jlj_dostream(struct work_struct *work)
196 goto quit_stream; 195 goto quit_stream;
197 } 196 }
198 while (gspca_dev->present && gspca_dev->streaming) { 197 while (gspca_dev->present && gspca_dev->streaming) {
199 if (!gspca_dev->present)
200 goto quit_stream;
201 /* Start a new frame, and add the JPEG header, first thing */
202 frame = gspca_get_i_frame(gspca_dev);
203 if (frame && !discarding)
204 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
205 dev->jpeg_hdr, JPEG_HDR_SZ);
206 else
207 discarding = 1;
208 /* 198 /*
209 * Now request data block 0. Line 0 reports the size 199 * Now request data block 0. Line 0 reports the size
210 * to download, in blocks of size 0x200, and also tells the 200 * to download, in blocks of size 0x200, and also tells the
@@ -222,14 +212,17 @@ static void jlj_dostream(struct work_struct *work)
222 size_in_blocks = buffer[0x0a]; 212 size_in_blocks = buffer[0x0a];
223 blocks_left = buffer[0x0a] - 1; 213 blocks_left = buffer[0x0a] - 1;
224 PDEBUG(D_STREAM, "blocks_left = 0x%x", blocks_left); 214 PDEBUG(D_STREAM, "blocks_left = 0x%x", blocks_left);
225 packet_type = INTER_PACKET; 215
226 if (frame && !discarding) 216 /* Start a new frame, and add the JPEG header, first thing */
217 frame = gspca_get_i_frame(gspca_dev);
218 if (frame) {
219 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
220 dev->jpeg_hdr, JPEG_HDR_SZ);
227 /* Toss line 0 of data block 0, keep the rest. */ 221 /* Toss line 0 of data block 0, keep the rest. */
228 gspca_frame_add(gspca_dev, packet_type, 222 gspca_frame_add(gspca_dev, INTER_PACKET,
229 frame, buffer + FRAME_HEADER_LEN, 223 frame, buffer + FRAME_HEADER_LEN,
230 JEILINJ_MAX_TRANSFER - FRAME_HEADER_LEN); 224 JEILINJ_MAX_TRANSFER - FRAME_HEADER_LEN);
231 else 225 }
232 discarding = 1;
233 while (blocks_left > 0) { 226 while (blocks_left > 0) {
234 if (!gspca_dev->present) 227 if (!gspca_dev->present)
235 goto quit_stream; 228 goto quit_stream;
@@ -246,12 +239,10 @@ static void jlj_dostream(struct work_struct *work)
246 packet_type = LAST_PACKET; 239 packet_type = LAST_PACKET;
247 else 240 else
248 packet_type = INTER_PACKET; 241 packet_type = INTER_PACKET;
249 if (frame && !discarding) 242 if (frame)
250 gspca_frame_add(gspca_dev, packet_type, 243 gspca_frame_add(gspca_dev, packet_type,
251 frame, buffer, 244 frame, buffer,
252 JEILINJ_MAX_TRANSFER); 245 JEILINJ_MAX_TRANSFER);
253 else
254 discarding = 1;
255 } 246 }
256 } 247 }
257quit_stream: 248quit_stream: