aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2009-11-13 07:21:03 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-05 15:41:59 -0500
commit76dd272b56cd1c7fa013ef5d7eb28c4d319e322b (patch)
tree4cd4660a847d2c1fdd9104ce4cff92b647e09b15 /drivers/media/video
parentd131c3c9e136cb5a817094c3dc4b7261b495cd6e (diff)
V4L/DVB (13453): gspca - all subdrivers: Remove the unused frame ptr from pkt_scan().
Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/gspca/conex.c12
-rw-r--r--drivers/media/video/gspca/etoms.c10
-rw-r--r--drivers/media/video/gspca/finepix.c23
-rw-r--r--drivers/media/video/gspca/gl860/gl860.c10
-rw-r--r--drivers/media/video/gspca/gspca.c20
-rw-r--r--drivers/media/video/gspca/gspca.h12
-rw-r--r--drivers/media/video/gspca/jeilinj.c21
-rw-r--r--drivers/media/video/gspca/m5602/m5602_core.c25
-rw-r--r--drivers/media/video/gspca/mars.c11
-rw-r--r--drivers/media/video/gspca/mr97310a.c11
-rw-r--r--drivers/media/video/gspca/ov519.c54
-rw-r--r--drivers/media/video/gspca/ov534.c21
-rw-r--r--drivers/media/video/gspca/pac207.c11
-rw-r--r--drivers/media/video/gspca/pac7302.c22
-rw-r--r--drivers/media/video/gspca/pac7311.c22
-rw-r--r--drivers/media/video/gspca/sn9c20x.c11
-rw-r--r--drivers/media/video/gspca/sonixb.c21
-rw-r--r--drivers/media/video/gspca/sonixj.c7
-rw-r--r--drivers/media/video/gspca/spca500.c11
-rw-r--r--drivers/media/video/gspca/spca501.c14
-rw-r--r--drivers/media/video/gspca/spca505.c10
-rw-r--r--drivers/media/video/gspca/spca506.c12
-rw-r--r--drivers/media/video/gspca/spca508.c10
-rw-r--r--drivers/media/video/gspca/spca561.c14
-rw-r--r--drivers/media/video/gspca/sq905.c21
-rw-r--r--drivers/media/video/gspca/sq905c.c12
-rw-r--r--drivers/media/video/gspca/stk014.c11
-rw-r--r--drivers/media/video/gspca/stv0680.c7
-rw-r--r--drivers/media/video/gspca/stv06xx/stv06xx.c11
-rw-r--r--drivers/media/video/gspca/sunplus.c11
-rw-r--r--drivers/media/video/gspca/t613.c7
-rw-r--r--drivers/media/video/gspca/tv8532.c7
-rw-r--r--drivers/media/video/gspca/vc032x.c21
-rw-r--r--drivers/media/video/gspca/w996Xcf.c13
-rw-r--r--drivers/media/video/gspca/zc3xx.c11
35 files changed, 240 insertions, 287 deletions
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index eca003566ae3..2f0b8d621e00 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -888,8 +888,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
888} 888}
889 889
890static void sd_pkt_scan(struct gspca_dev *gspca_dev, 890static void sd_pkt_scan(struct gspca_dev *gspca_dev,
891 struct gspca_frame *frame, /* target */ 891 u8 *data, /* isoc packet */
892 __u8 *data, /* isoc packet */
893 int len) /* iso packet length */ 892 int len) /* iso packet length */
894{ 893{
895 struct sd *sd = (struct sd *) gspca_dev; 894 struct sd *sd = (struct sd *) gspca_dev;
@@ -897,16 +896,15 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
897 if (data[0] == 0xff && data[1] == 0xd8) { 896 if (data[0] == 0xff && data[1] == 0xd8) {
898 897
899 /* start of frame */ 898 /* start of frame */
900 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 899 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
901 data, 0);
902 900
903 /* put the JPEG header in the new frame */ 901 /* put the JPEG header in the new frame */
904 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 902 gspca_frame_add(gspca_dev, FIRST_PACKET,
905 sd->jpeg_hdr, JPEG_HDR_SZ); 903 sd->jpeg_hdr, JPEG_HDR_SZ);
906 data += 2; 904 data += 2;
907 len -= 2; 905 len -= 2;
908 } 906 }
909 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 907 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
910} 908}
911 909
912static void setbrightness(struct gspca_dev*gspca_dev) 910static void setbrightness(struct gspca_dev*gspca_dev)
diff --git a/drivers/media/video/gspca/etoms.c b/drivers/media/video/gspca/etoms.c
index c1461e63647f..9de86419ae1e 100644
--- a/drivers/media/video/gspca/etoms.c
+++ b/drivers/media/video/gspca/etoms.c
@@ -752,8 +752,7 @@ static void do_autogain(struct gspca_dev *gspca_dev)
752#undef LIMIT 752#undef LIMIT
753 753
754static void sd_pkt_scan(struct gspca_dev *gspca_dev, 754static void sd_pkt_scan(struct gspca_dev *gspca_dev,
755 struct gspca_frame *frame, /* target */ 755 u8 *data, /* isoc packet */
756 __u8 *data, /* isoc packet */
757 int len) /* iso packet length */ 756 int len) /* iso packet length */
758{ 757{
759 int seqframe; 758 int seqframe;
@@ -767,14 +766,13 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
767 data[2], data[3], data[4], data[5]); 766 data[2], data[3], data[4], data[5]);
768 data += 30; 767 data += 30;
769 /* don't change datalength as the chips provided it */ 768 /* don't change datalength as the chips provided it */
770 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 769 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
771 data, 0); 770 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
772 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len);
773 return; 771 return;
774 } 772 }
775 if (len) { 773 if (len) {
776 data += 8; 774 data += 8;
777 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 775 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
778 } else { /* Drop Packet */ 776 } else { /* Drop Packet */
779 gspca_dev->last_packet_type = DISCARD_PACKET; 777 gspca_dev->last_packet_type = DISCARD_PACKET;
780 } 778 }
diff --git a/drivers/media/video/gspca/finepix.c b/drivers/media/video/gspca/finepix.c
index 480ec5c87d0e..5d90e7448579 100644
--- a/drivers/media/video/gspca/finepix.c
+++ b/drivers/media/video/gspca/finepix.c
@@ -82,7 +82,6 @@ static void dostream(struct work_struct *work)
82 struct gspca_dev *gspca_dev = &dev->gspca_dev; 82 struct gspca_dev *gspca_dev = &dev->gspca_dev;
83 struct urb *urb = gspca_dev->urb[0]; 83 struct urb *urb = gspca_dev->urb[0];
84 u8 *data = urb->transfer_buffer; 84 u8 *data = urb->transfer_buffer;
85 struct gspca_frame *frame;
86 int ret = 0; 85 int ret = 0;
87 int len; 86 int len;
88 87
@@ -118,10 +117,6 @@ again:
118 } 117 }
119 if (!gspca_dev->present || !gspca_dev->streaming) 118 if (!gspca_dev->present || !gspca_dev->streaming)
120 goto out; 119 goto out;
121 frame = gspca_get_i_frame(&dev->gspca_dev);
122 if (frame == NULL)
123 gspca_dev->last_packet_type = DISCARD_PACKET;
124
125 if (len < FPIX_MAX_TRANSFER || 120 if (len < FPIX_MAX_TRANSFER ||
126 (data[len - 2] == 0xff && 121 (data[len - 2] == 0xff &&
127 data[len - 1] == 0xd9)) { 122 data[len - 1] == 0xd9)) {
@@ -132,21 +127,17 @@ again:
132 * but there's nothing we can do. We also end 127 * but there's nothing we can do. We also end
133 * here if the the jpeg ends right at the end 128 * here if the the jpeg ends right at the end
134 * of the frame. */ 129 * of the frame. */
135 if (frame) 130 gspca_frame_add(gspca_dev, LAST_PACKET,
136 frame = gspca_frame_add(gspca_dev, 131 data, len);
137 LAST_PACKET,
138 frame,
139 data, len);
140 break; 132 break;
141 } 133 }
142 134
143 /* got a partial image */ 135 /* got a partial image */
144 if (frame) 136 gspca_frame_add(gspca_dev,
145 gspca_frame_add(gspca_dev, 137 gspca_dev->last_packet_type
146 gspca_dev->last_packet_type 138 == LAST_PACKET
147 == LAST_PACKET 139 ? FIRST_PACKET : INTER_PACKET,
148 ? FIRST_PACKET : INTER_PACKET, 140 data, len);
149 frame, data, len);
150 } 141 }
151 142
152 /* We must wait before trying reading the next 143 /* We must wait before trying reading the next
diff --git a/drivers/media/video/gspca/gl860/gl860.c b/drivers/media/video/gspca/gl860/gl860.c
index a2108dd71053..a695e0ae13c2 100644
--- a/drivers/media/video/gspca/gl860/gl860.c
+++ b/drivers/media/video/gspca/gl860/gl860.c
@@ -36,7 +36,7 @@ static int sd_isoc_init(struct gspca_dev *gspca_dev);
36static int sd_start(struct gspca_dev *gspca_dev); 36static int sd_start(struct gspca_dev *gspca_dev);
37static void sd_stop0(struct gspca_dev *gspca_dev); 37static void sd_stop0(struct gspca_dev *gspca_dev);
38static void sd_pkt_scan(struct gspca_dev *gspca_dev, 38static void sd_pkt_scan(struct gspca_dev *gspca_dev,
39 struct gspca_frame *frame, u8 *data, s32 len); 39 u8 *data, int len);
40static void sd_callback(struct gspca_dev *gspca_dev); 40static void sd_callback(struct gspca_dev *gspca_dev);
41 41
42static int gl860_guess_sensor(struct gspca_dev *gspca_dev, 42static int gl860_guess_sensor(struct gspca_dev *gspca_dev,
@@ -433,7 +433,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
433 433
434/* This function is called when an image is being received */ 434/* This function is called when an image is being received */
435static void sd_pkt_scan(struct gspca_dev *gspca_dev, 435static void sd_pkt_scan(struct gspca_dev *gspca_dev,
436 struct gspca_frame *frame, u8 *data, s32 len) 436 u8 *data, int len)
437{ 437{
438 struct sd *sd = (struct sd *) gspca_dev; 438 struct sd *sd = (struct sd *) gspca_dev;
439 static s32 nSkipped; 439 static s32 nSkipped;
@@ -445,11 +445,11 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
445 /* Test only against 0202h, so endianess does not matter */ 445 /* Test only against 0202h, so endianess does not matter */
446 switch (*(s16 *) data) { 446 switch (*(s16 *) data) {
447 case 0x0202: /* End of frame, start a new one */ 447 case 0x0202: /* End of frame, start a new one */
448 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, data, 0); 448 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
449 nSkipped = 0; 449 nSkipped = 0;
450 if (sd->nbIm >= 0 && sd->nbIm < 10) 450 if (sd->nbIm >= 0 && sd->nbIm < 10)
451 sd->nbIm++; 451 sd->nbIm++;
452 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, 0); 452 gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0);
453 break; 453 break;
454 454
455 default: 455 default:
@@ -464,7 +464,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
464 nSkipped = nToSkip + 1; 464 nSkipped = nToSkip + 1;
465 } 465 }
466 gspca_frame_add(gspca_dev, 466 gspca_frame_add(gspca_dev,
467 INTER_PACKET, frame, data, len); 467 INTER_PACKET, data, len);
468 } 468 }
469 break; 469 break;
470 } 470 }
diff --git a/drivers/media/video/gspca/gspca.c b/drivers/media/video/gspca/gspca.c
index 68ba535300f7..4076f8e5a6fc 100644
--- a/drivers/media/video/gspca/gspca.c
+++ b/drivers/media/video/gspca/gspca.c
@@ -165,7 +165,7 @@ static void fill_frame(struct gspca_dev *gspca_dev,
165 i, urb->iso_frame_desc[i].offset, len); 165 i, urb->iso_frame_desc[i].offset, len);
166 data = (u8 *) urb->transfer_buffer 166 data = (u8 *) urb->transfer_buffer
167 + urb->iso_frame_desc[i].offset; 167 + urb->iso_frame_desc[i].offset;
168 pkt_scan(gspca_dev, gspca_dev->cur_frame, data, len); 168 pkt_scan(gspca_dev, data, len);
169 } 169 }
170 170
171resubmit: 171resubmit:
@@ -218,7 +218,6 @@ static void bulk_irq(struct urb *urb)
218 218
219 PDEBUG(D_PACK, "packet l:%d", urb->actual_length); 219 PDEBUG(D_PACK, "packet l:%d", urb->actual_length);
220 gspca_dev->sd_desc->pkt_scan(gspca_dev, 220 gspca_dev->sd_desc->pkt_scan(gspca_dev,
221 gspca_dev->frame,
222 urb->transfer_buffer, 221 urb->transfer_buffer,
223 urb->actual_length); 222 urb->actual_length);
224 223
@@ -243,11 +242,10 @@ resubmit:
243 * DISCARD_PACKET invalidates the whole frame. 242 * DISCARD_PACKET invalidates the whole frame.
244 * On LAST_PACKET, a new frame is returned. 243 * On LAST_PACKET, a new frame is returned.
245 */ 244 */
246struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev, 245void gspca_frame_add(struct gspca_dev *gspca_dev,
247 enum gspca_packet_type packet_type, 246 enum gspca_packet_type packet_type,
248 struct gspca_frame *dummy, 247 const u8 *data,
249 const __u8 *data, 248 int len)
250 int len)
251{ 249{
252 struct gspca_frame *frame; 250 struct gspca_frame *frame;
253 int i, j; 251 int i, j;
@@ -259,7 +257,7 @@ struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
259 if ((frame->v4l2_buf.flags & BUF_ALL_FLAGS) 257 if ((frame->v4l2_buf.flags & BUF_ALL_FLAGS)
260 != V4L2_BUF_FLAG_QUEUED) { 258 != V4L2_BUF_FLAG_QUEUED) {
261 gspca_dev->last_packet_type = DISCARD_PACKET; 259 gspca_dev->last_packet_type = DISCARD_PACKET;
262 return frame; 260 return;
263 } 261 }
264 262
265 /* when start of a new frame, if the current frame buffer 263 /* when start of a new frame, if the current frame buffer
@@ -272,7 +270,7 @@ struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
272 } else if (gspca_dev->last_packet_type == DISCARD_PACKET) { 270 } else if (gspca_dev->last_packet_type == DISCARD_PACKET) {
273 if (packet_type == LAST_PACKET) 271 if (packet_type == LAST_PACKET)
274 gspca_dev->last_packet_type = packet_type; 272 gspca_dev->last_packet_type = packet_type;
275 return frame; 273 return;
276 } 274 }
277 275
278 /* append the packet to the frame buffer */ 276 /* append the packet to the frame buffer */
@@ -304,9 +302,9 @@ struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev,
304 i, 302 i,
305 gspca_dev->fr_o); 303 gspca_dev->fr_o);
306 j = gspca_dev->fr_queue[i]; 304 j = gspca_dev->fr_queue[i];
307 gspca_dev->cur_frame = frame = &gspca_dev->frame[j]; 305 gspca_dev->cur_frame = &gspca_dev->frame[j];
308 } 306 }
309 return frame; 307 return;
310} 308}
311EXPORT_SYMBOL(gspca_frame_add); 309EXPORT_SYMBOL(gspca_frame_add);
312 310
diff --git a/drivers/media/video/gspca/gspca.h b/drivers/media/video/gspca/gspca.h
index 59078bbf472c..181617355ec3 100644
--- a/drivers/media/video/gspca/gspca.h
+++ b/drivers/media/video/gspca/gspca.h
@@ -79,8 +79,7 @@ typedef int (*cam_streamparm_op) (struct gspca_dev *,
79typedef int (*cam_qmnu_op) (struct gspca_dev *, 79typedef int (*cam_qmnu_op) (struct gspca_dev *,
80 struct v4l2_querymenu *); 80 struct v4l2_querymenu *);
81typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev, 81typedef void (*cam_pkt_op) (struct gspca_dev *gspca_dev,
82 struct gspca_frame *frame, 82 u8 *data,
83 __u8 *data,
84 int len); 83 int len);
85 84
86struct ctrl { 85struct ctrl {
@@ -192,11 +191,10 @@ int gspca_dev_probe(struct usb_interface *intf,
192 int dev_size, 191 int dev_size,
193 struct module *module); 192 struct module *module);
194void gspca_disconnect(struct usb_interface *intf); 193void gspca_disconnect(struct usb_interface *intf);
195struct gspca_frame *gspca_frame_add(struct gspca_dev *gspca_dev, 194void gspca_frame_add(struct gspca_dev *gspca_dev,
196 enum gspca_packet_type packet_type, 195 enum gspca_packet_type packet_type,
197 struct gspca_frame *frame, 196 const u8 *data,
198 const __u8 *data, 197 int len);
199 int len);
200struct gspca_frame *gspca_get_i_frame(struct gspca_dev *gspca_dev); 198struct gspca_frame *gspca_get_i_frame(struct gspca_dev *gspca_dev);
201#ifdef CONFIG_PM 199#ifdef CONFIG_PM
202int gspca_suspend(struct usb_interface *intf, pm_message_t message); 200int gspca_suspend(struct usb_interface *intf, pm_message_t message);
diff --git a/drivers/media/video/gspca/jeilinj.c b/drivers/media/video/gspca/jeilinj.c
index d679970d5b3e..2019b04f9235 100644
--- a/drivers/media/video/gspca/jeilinj.c
+++ b/drivers/media/video/gspca/jeilinj.c
@@ -181,7 +181,6 @@ static void jlj_dostream(struct work_struct *work)
181{ 181{
182 struct sd *dev = container_of(work, struct sd, work_struct); 182 struct sd *dev = container_of(work, struct sd, work_struct);
183 struct gspca_dev *gspca_dev = &dev->gspca_dev; 183 struct gspca_dev *gspca_dev = &dev->gspca_dev;
184 struct gspca_frame *frame;
185 int blocks_left; /* 0x200-sized blocks remaining in current frame. */ 184 int blocks_left; /* 0x200-sized blocks remaining in current frame. */
186 int size_in_blocks; 185 int size_in_blocks;
187 int act_len; 186 int act_len;
@@ -214,15 +213,13 @@ static void jlj_dostream(struct work_struct *work)
214 PDEBUG(D_STREAM, "blocks_left = 0x%x", blocks_left); 213 PDEBUG(D_STREAM, "blocks_left = 0x%x", blocks_left);
215 214
216 /* Start a new frame, and add the JPEG header, first thing */ 215 /* Start a new frame, and add the JPEG header, first thing */
217 frame = gspca_get_i_frame(gspca_dev); 216 gspca_frame_add(gspca_dev, FIRST_PACKET,
218 if (frame) { 217 dev->jpeg_hdr, JPEG_HDR_SZ);
219 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 218 /* Toss line 0 of data block 0, keep the rest. */
220 dev->jpeg_hdr, JPEG_HDR_SZ); 219 gspca_frame_add(gspca_dev, INTER_PACKET,
221 /* Toss line 0 of data block 0, keep the rest. */ 220 buffer + FRAME_HEADER_LEN,
222 gspca_frame_add(gspca_dev, INTER_PACKET,
223 frame, buffer + FRAME_HEADER_LEN,
224 JEILINJ_MAX_TRANSFER - FRAME_HEADER_LEN); 221 JEILINJ_MAX_TRANSFER - FRAME_HEADER_LEN);
225 } 222
226 while (blocks_left > 0) { 223 while (blocks_left > 0) {
227 if (!gspca_dev->present) 224 if (!gspca_dev->present)
228 goto quit_stream; 225 goto quit_stream;
@@ -239,10 +236,8 @@ static void jlj_dostream(struct work_struct *work)
239 packet_type = LAST_PACKET; 236 packet_type = LAST_PACKET;
240 else 237 else
241 packet_type = INTER_PACKET; 238 packet_type = INTER_PACKET;
242 if (frame) 239 gspca_frame_add(gspca_dev, packet_type,
243 gspca_frame_add(gspca_dev, packet_type, 240 buffer, JEILINJ_MAX_TRANSFER);
244 frame, buffer,
245 JEILINJ_MAX_TRANSFER);
246 } 241 }
247 } 242 }
248quit_stream: 243quit_stream:
diff --git a/drivers/media/video/gspca/m5602/m5602_core.c b/drivers/media/video/gspca/m5602/m5602_core.c
index 7f1e5415850b..844fc1d886d1 100644
--- a/drivers/media/video/gspca/m5602/m5602_core.c
+++ b/drivers/media/video/gspca/m5602/m5602_core.c
@@ -274,8 +274,7 @@ static int m5602_start_transfer(struct gspca_dev *gspca_dev)
274} 274}
275 275
276static void m5602_urb_complete(struct gspca_dev *gspca_dev, 276static void m5602_urb_complete(struct gspca_dev *gspca_dev,
277 struct gspca_frame *frame, 277 u8 *data, int len)
278 __u8 *data, int len)
279{ 278{
280 struct sd *sd = (struct sd *) gspca_dev; 279 struct sd *sd = (struct sd *) gspca_dev;
281 280
@@ -295,19 +294,27 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev,
295 len -= 6; 294 len -= 6;
296 295
297 /* Complete the last frame (if any) */ 296 /* Complete the last frame (if any) */
298 frame = gspca_frame_add(gspca_dev, LAST_PACKET, 297 gspca_frame_add(gspca_dev, LAST_PACKET,
299 frame, data, 0); 298 NULL, 0);
300 sd->frame_count++; 299 sd->frame_count++;
301 300
302 /* Create a new frame */ 301 /* Create a new frame */
303 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len); 302 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
304 303
305 PDEBUG(D_FRAM, "Starting new frame %d", 304 PDEBUG(D_FRAM, "Starting new frame %d",
306 sd->frame_count); 305 sd->frame_count);
307 306
308 } else { 307 } else {
309 int cur_frame_len = frame->data_end - frame->data; 308 struct gspca_frame *frame;
309 int cur_frame_len;
310 310
311 frame = gspca_get_i_frame(gspca_dev);
312 if (frame == NULL) {
313 gspca_dev->last_packet_type = DISCARD_PACKET;
314 return;
315 }
316
317 cur_frame_len = frame->data_end - frame->data;
311 /* Remove urb header */ 318 /* Remove urb header */
312 data += 4; 319 data += 4;
313 len -= 4; 320 len -= 4;
@@ -316,12 +323,12 @@ static void m5602_urb_complete(struct gspca_dev *gspca_dev,
316 PDEBUG(D_FRAM, "Continuing frame %d copying %d bytes", 323 PDEBUG(D_FRAM, "Continuing frame %d copying %d bytes",
317 sd->frame_count, len); 324 sd->frame_count, len);
318 325
319 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 326 gspca_frame_add(gspca_dev, INTER_PACKET,
320 data, len); 327 data, len);
321 } else if (frame->v4l2_buf.length - cur_frame_len > 0) { 328 } else if (frame->v4l2_buf.length - cur_frame_len > 0) {
322 /* Add the remaining data up to frame size */ 329 /* Add the remaining data up to frame size */
323 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, 330 gspca_frame_add(gspca_dev, INTER_PACKET, data,
324 frame->v4l2_buf.length - cur_frame_len); 331 frame->v4l2_buf.length - cur_frame_len);
325 } 332 }
326 } 333 }
327} 334}
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c
index de769caf013d..9cf8d68c71bf 100644
--- a/drivers/media/video/gspca/mars.c
+++ b/drivers/media/video/gspca/mars.c
@@ -325,8 +325,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
325} 325}
326 326
327static void sd_pkt_scan(struct gspca_dev *gspca_dev, 327static void sd_pkt_scan(struct gspca_dev *gspca_dev,
328 struct gspca_frame *frame, /* target */ 328 u8 *data, /* isoc packet */
329 __u8 *data, /* isoc packet */
330 int len) /* iso packet length */ 329 int len) /* iso packet length */
331{ 330{
332 struct sd *sd = (struct sd *) gspca_dev; 331 struct sd *sd = (struct sd *) gspca_dev;
@@ -348,11 +347,11 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
348 || data[5 + p] == 0x67) { 347 || data[5 + p] == 0x67) {
349 PDEBUG(D_PACK, "sof offset: %d len: %d", 348 PDEBUG(D_PACK, "sof offset: %d len: %d",
350 p, len); 349 p, len);
351 frame = gspca_frame_add(gspca_dev, LAST_PACKET, 350 gspca_frame_add(gspca_dev, LAST_PACKET,
352 frame, data, p); 351 data, p);
353 352
354 /* put the JPEG header */ 353 /* put the JPEG header */
355 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 354 gspca_frame_add(gspca_dev, FIRST_PACKET,
356 sd->jpeg_hdr, JPEG_HDR_SZ); 355 sd->jpeg_hdr, JPEG_HDR_SZ);
357 data += p + 16; 356 data += p + 16;
358 len -= p + 16; 357 len -= p + 16;
@@ -360,7 +359,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
360 } 359 }
361 } 360 }
362 } 361 }
363 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 362 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
364} 363}
365 364
366static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 365static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/mr97310a.c b/drivers/media/video/gspca/mr97310a.c
index ffb5e6d62c0b..126d968dd9e0 100644
--- a/drivers/media/video/gspca/mr97310a.c
+++ b/drivers/media/video/gspca/mr97310a.c
@@ -1030,9 +1030,8 @@ static int sd_getmin_clockdiv(struct gspca_dev *gspca_dev, __s32 *val)
1030#include "pac_common.h" 1030#include "pac_common.h"
1031 1031
1032static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1032static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1033 struct gspca_frame *frame, /* target */ 1033 u8 *data, /* isoc packet */
1034 __u8 *data, /* isoc packet */ 1034 int len) /* iso packet length */
1035 int len) /* iso packet length */
1036{ 1035{
1037 struct sd *sd = (struct sd *) gspca_dev; 1036 struct sd *sd = (struct sd *) gspca_dev;
1038 unsigned char *sof; 1037 unsigned char *sof;
@@ -1047,15 +1046,15 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1047 n -= sizeof pac_sof_marker; 1046 n -= sizeof pac_sof_marker;
1048 else 1047 else
1049 n = 0; 1048 n = 0;
1050 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 1049 gspca_frame_add(gspca_dev, LAST_PACKET,
1051 data, n); 1050 data, n);
1052 /* Start next frame. */ 1051 /* Start next frame. */
1053 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 1052 gspca_frame_add(gspca_dev, FIRST_PACKET,
1054 pac_sof_marker, sizeof pac_sof_marker); 1053 pac_sof_marker, sizeof pac_sof_marker);
1055 len -= sof - data; 1054 len -= sof - data;
1056 data = sof; 1055 data = sof;
1057 } 1056 }
1058 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 1057 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
1059} 1058}
1060 1059
1061/* sub-driver description */ 1060/* sub-driver description */
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c
index f88a526e216f..ad9ec339981d 100644
--- a/drivers/media/video/gspca/ov519.c
+++ b/drivers/media/video/gspca/ov519.c
@@ -3920,9 +3920,8 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
3920} 3920}
3921 3921
3922static void ov511_pkt_scan(struct gspca_dev *gspca_dev, 3922static void ov511_pkt_scan(struct gspca_dev *gspca_dev,
3923 struct gspca_frame *frame, /* target */ 3923 u8 *in, /* isoc packet */
3924 __u8 *in, /* isoc packet */ 3924 int len) /* iso packet length */
3925 int len) /* iso packet length */
3926{ 3925{
3927 struct sd *sd = (struct sd *) gspca_dev; 3926 struct sd *sd = (struct sd *) gspca_dev;
3928 3927
@@ -3953,11 +3952,11 @@ static void ov511_pkt_scan(struct gspca_dev *gspca_dev,
3953 return; 3952 return;
3954 } 3953 }
3955 /* Add 11 byte footer to frame, might be usefull */ 3954 /* Add 11 byte footer to frame, might be usefull */
3956 gspca_frame_add(gspca_dev, LAST_PACKET, frame, in, 11); 3955 gspca_frame_add(gspca_dev, LAST_PACKET, in, 11);
3957 return; 3956 return;
3958 } else { 3957 } else {
3959 /* Frame start */ 3958 /* Frame start */
3960 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, in, 0); 3959 gspca_frame_add(gspca_dev, FIRST_PACKET, in, 0);
3961 sd->packet_nr = 0; 3960 sd->packet_nr = 0;
3962 } 3961 }
3963 } 3962 }
@@ -3966,12 +3965,11 @@ static void ov511_pkt_scan(struct gspca_dev *gspca_dev,
3966 len--; 3965 len--;
3967 3966
3968 /* intermediate packet */ 3967 /* intermediate packet */
3969 gspca_frame_add(gspca_dev, INTER_PACKET, frame, in, len); 3968 gspca_frame_add(gspca_dev, INTER_PACKET, in, len);
3970} 3969}
3971 3970
3972static void ov518_pkt_scan(struct gspca_dev *gspca_dev, 3971static void ov518_pkt_scan(struct gspca_dev *gspca_dev,
3973 struct gspca_frame *frame, /* target */ 3972 u8 *data, /* isoc packet */
3974 __u8 *data, /* isoc packet */
3975 int len) /* iso packet length */ 3973 int len) /* iso packet length */
3976{ 3974{
3977 struct sd *sd = (struct sd *) gspca_dev; 3975 struct sd *sd = (struct sd *) gspca_dev;
@@ -3979,8 +3977,8 @@ static void ov518_pkt_scan(struct gspca_dev *gspca_dev,
3979 /* A false positive here is likely, until OVT gives me 3977 /* A false positive here is likely, until OVT gives me
3980 * the definitive SOF/EOF format */ 3978 * the definitive SOF/EOF format */
3981 if ((!(data[0] | data[1] | data[2] | data[3] | data[5])) && data[6]) { 3979 if ((!(data[0] | data[1] | data[2] | data[3] | data[5])) && data[6]) {
3982 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, data, 0); 3980 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
3983 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, 0); 3981 gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0);
3984 sd->packet_nr = 0; 3982 sd->packet_nr = 0;
3985 } 3983 }
3986 3984
@@ -4004,12 +4002,11 @@ static void ov518_pkt_scan(struct gspca_dev *gspca_dev,
4004 } 4002 }
4005 4003
4006 /* intermediate packet */ 4004 /* intermediate packet */
4007 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 4005 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
4008} 4006}
4009 4007
4010static void ov519_pkt_scan(struct gspca_dev *gspca_dev, 4008static void ov519_pkt_scan(struct gspca_dev *gspca_dev,
4011 struct gspca_frame *frame, /* target */ 4009 u8 *data, /* isoc packet */
4012 __u8 *data, /* isoc packet */
4013 int len) /* iso packet length */ 4010 int len) /* iso packet length */
4014{ 4011{
4015 /* Header of ov519 is 16 bytes: 4012 /* Header of ov519 is 16 bytes:
@@ -4032,7 +4029,7 @@ static void ov519_pkt_scan(struct gspca_dev *gspca_dev,
4032 len -= HDRSZ; 4029 len -= HDRSZ;
4033#undef HDRSZ 4030#undef HDRSZ
4034 if (data[0] == 0xff || data[1] == 0xd8) 4031 if (data[0] == 0xff || data[1] == 0xd8)
4035 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 4032 gspca_frame_add(gspca_dev, FIRST_PACKET,
4036 data, len); 4033 data, len);
4037 else 4034 else
4038 gspca_dev->last_packet_type = DISCARD_PACKET; 4035 gspca_dev->last_packet_type = DISCARD_PACKET;
@@ -4040,34 +4037,31 @@ static void ov519_pkt_scan(struct gspca_dev *gspca_dev,
4040 case 0x51: /* end of frame */ 4037 case 0x51: /* end of frame */
4041 if (data[9] != 0) 4038 if (data[9] != 0)
4042 gspca_dev->last_packet_type = DISCARD_PACKET; 4039 gspca_dev->last_packet_type = DISCARD_PACKET;
4043 gspca_frame_add(gspca_dev, LAST_PACKET, frame, 4040 gspca_frame_add(gspca_dev, LAST_PACKET,
4044 data, 0); 4041 NULL, 0);
4045 return; 4042 return;
4046 } 4043 }
4047 } 4044 }
4048 4045
4049 /* intermediate packet */ 4046 /* intermediate packet */
4050 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 4047 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
4051 data, len);
4052} 4048}
4053 4049
4054static void ovfx2_pkt_scan(struct gspca_dev *gspca_dev, 4050static void ovfx2_pkt_scan(struct gspca_dev *gspca_dev,
4055 struct gspca_frame *frame, /* target */ 4051 u8 *data, /* isoc packet */
4056 __u8 *data, /* isoc packet */
4057 int len) /* iso packet length */ 4052 int len) /* iso packet length */
4058{ 4053{
4059 /* A short read signals EOF */ 4054 /* A short read signals EOF */
4060 if (len < OVFX2_BULK_SIZE) { 4055 if (len < OVFX2_BULK_SIZE) {
4061 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, data, len); 4056 gspca_frame_add(gspca_dev, LAST_PACKET, data, len);
4062 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, NULL, 0); 4057 gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0);
4063 return; 4058 return;
4064 } 4059 }
4065 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 4060 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
4066} 4061}
4067 4062
4068static void sd_pkt_scan(struct gspca_dev *gspca_dev, 4063static void sd_pkt_scan(struct gspca_dev *gspca_dev,
4069 struct gspca_frame *frame, /* target */ 4064 u8 *data, /* isoc packet */
4070 __u8 *data, /* isoc packet */
4071 int len) /* iso packet length */ 4065 int len) /* iso packet length */
4072{ 4066{
4073 struct sd *sd = (struct sd *) gspca_dev; 4067 struct sd *sd = (struct sd *) gspca_dev;
@@ -4075,20 +4069,20 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
4075 switch (sd->bridge) { 4069 switch (sd->bridge) {
4076 case BRIDGE_OV511: 4070 case BRIDGE_OV511:
4077 case BRIDGE_OV511PLUS: 4071 case BRIDGE_OV511PLUS:
4078 ov511_pkt_scan(gspca_dev, frame, data, len); 4072 ov511_pkt_scan(gspca_dev, data, len);
4079 break; 4073 break;
4080 case BRIDGE_OV518: 4074 case BRIDGE_OV518:
4081 case BRIDGE_OV518PLUS: 4075 case BRIDGE_OV518PLUS:
4082 ov518_pkt_scan(gspca_dev, frame, data, len); 4076 ov518_pkt_scan(gspca_dev, data, len);
4083 break; 4077 break;
4084 case BRIDGE_OV519: 4078 case BRIDGE_OV519:
4085 ov519_pkt_scan(gspca_dev, frame, data, len); 4079 ov519_pkt_scan(gspca_dev, data, len);
4086 break; 4080 break;
4087 case BRIDGE_OVFX2: 4081 case BRIDGE_OVFX2:
4088 ovfx2_pkt_scan(gspca_dev, frame, data, len); 4082 ovfx2_pkt_scan(gspca_dev, data, len);
4089 break; 4083 break;
4090 case BRIDGE_W9968CF: 4084 case BRIDGE_W9968CF:
4091 w9968cf_pkt_scan(gspca_dev, frame, data, len); 4085 w9968cf_pkt_scan(gspca_dev, data, len);
4092 break; 4086 break;
4093 } 4087 }
4094} 4088}
diff --git a/drivers/media/video/gspca/ov534.c b/drivers/media/video/gspca/ov534.c
index 26d98b1312e0..193129a59ab7 100644
--- a/drivers/media/video/gspca/ov534.c
+++ b/drivers/media/video/gspca/ov534.c
@@ -1403,8 +1403,8 @@ static void sd_stopN_ov965x(struct gspca_dev *gspca_dev)
1403#define UVC_STREAM_EOF (1 << 1) 1403#define UVC_STREAM_EOF (1 << 1)
1404#define UVC_STREAM_FID (1 << 0) 1404#define UVC_STREAM_FID (1 << 0)
1405 1405
1406static void sd_pkt_scan(struct gspca_dev *gspca_dev, struct gspca_frame *frame, 1406static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1407 __u8 *data, int len) 1407 u8 *data, int len)
1408{ 1408{
1409 struct sd *sd = (struct sd *) gspca_dev; 1409 struct sd *sd = (struct sd *) gspca_dev;
1410 __u32 this_pts; 1410 __u32 this_pts;
@@ -1445,23 +1445,22 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, struct gspca_frame *frame,
1445 /* If PTS or FID has changed, start a new frame. */ 1445 /* If PTS or FID has changed, start a new frame. */
1446 if (this_pts != sd->last_pts || this_fid != sd->last_fid) { 1446 if (this_pts != sd->last_pts || this_fid != sd->last_fid) {
1447 if (gspca_dev->last_packet_type == INTER_PACKET) 1447 if (gspca_dev->last_packet_type == INTER_PACKET)
1448 frame = gspca_frame_add(gspca_dev, 1448 gspca_frame_add(gspca_dev, LAST_PACKET,
1449 LAST_PACKET, frame, 1449 NULL, 0);
1450 NULL, 0);
1451 sd->last_pts = this_pts; 1450 sd->last_pts = this_pts;
1452 sd->last_fid = this_fid; 1451 sd->last_fid = this_fid;
1453 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 1452 gspca_frame_add(gspca_dev, FIRST_PACKET,
1454 data + 12, len - 12); 1453 data + 12, len - 12);
1455 /* If this packet is marked as EOF, end the frame */ 1454 /* If this packet is marked as EOF, end the frame */
1456 } else if (data[1] & UVC_STREAM_EOF) { 1455 } else if (data[1] & UVC_STREAM_EOF) {
1457 sd->last_pts = 0; 1456 sd->last_pts = 0;
1458 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 1457 gspca_frame_add(gspca_dev, LAST_PACKET,
1459 data + 12, len - 12); 1458 data + 12, len - 12);
1460 } else { 1459 } else {
1461 1460
1462 /* Add the data from this payload */ 1461 /* Add the data from this payload */
1463 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 1462 gspca_frame_add(gspca_dev, INTER_PACKET,
1464 data + 12, len - 12); 1463 data + 12, len - 12);
1465 } 1464 }
1466 1465
1467 /* Done this payload */ 1466 /* Done this payload */
@@ -1469,7 +1468,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, struct gspca_frame *frame,
1469 1468
1470discard: 1469discard:
1471 /* Discard data until a new frame starts. */ 1470 /* Discard data until a new frame starts. */
1472 gspca_frame_add(gspca_dev, DISCARD_PACKET, frame, NULL, 0); 1471 gspca_dev->last_packet_type = DISCARD_PACKET;
1473 1472
1474scan_next: 1473scan_next:
1475 remaining_len -= len; 1474 remaining_len -= len;
diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c
index 57e13e2d550c..4706a823add0 100644
--- a/drivers/media/video/gspca/pac207.c
+++ b/drivers/media/video/gspca/pac207.c
@@ -337,8 +337,7 @@ static void pac207_do_auto_gain(struct gspca_dev *gspca_dev)
337} 337}
338 338
339static void sd_pkt_scan(struct gspca_dev *gspca_dev, 339static void sd_pkt_scan(struct gspca_dev *gspca_dev,
340 struct gspca_frame *frame, 340 u8 *data,
341 __u8 *data,
342 int len) 341 int len)
343{ 342{
344 struct sd *sd = (struct sd *) gspca_dev; 343 struct sd *sd = (struct sd *) gspca_dev;
@@ -354,10 +353,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
354 n -= sizeof pac_sof_marker; 353 n -= sizeof pac_sof_marker;
355 else 354 else
356 n = 0; 355 n = 0;
357 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 356 gspca_frame_add(gspca_dev, LAST_PACKET,
358 data, n); 357 data, n);
359 sd->header_read = 0; 358 sd->header_read = 0;
360 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, NULL, 0); 359 gspca_frame_add(gspca_dev, FIRST_PACKET, NULL, 0);
361 len -= sof - data; 360 len -= sof - data;
362 data = sof; 361 data = sof;
363 } 362 }
@@ -381,7 +380,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
381 sd->header_read = 11; 380 sd->header_read = 11;
382 } 381 }
383 382
384 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 383 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
385} 384}
386 385
387static void setbrightness(struct gspca_dev *gspca_dev) 386static void setbrightness(struct gspca_dev *gspca_dev)
diff --git a/drivers/media/video/gspca/pac7302.c b/drivers/media/video/gspca/pac7302.c
index e0fd767984b3..74acceea8094 100644
--- a/drivers/media/video/gspca/pac7302.c
+++ b/drivers/media/video/gspca/pac7302.c
@@ -855,7 +855,7 @@ static void pac_start_frame(struct gspca_dev *gspca_dev,
855{ 855{
856 unsigned char tmpbuf[4]; 856 unsigned char tmpbuf[4];
857 857
858 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 858 gspca_frame_add(gspca_dev, FIRST_PACKET,
859 pac_jpeg_header1, sizeof(pac_jpeg_header1)); 859 pac_jpeg_header1, sizeof(pac_jpeg_header1));
860 860
861 tmpbuf[0] = lines >> 8; 861 tmpbuf[0] = lines >> 8;
@@ -863,25 +863,31 @@ static void pac_start_frame(struct gspca_dev *gspca_dev,
863 tmpbuf[2] = samples_per_line >> 8; 863 tmpbuf[2] = samples_per_line >> 8;
864 tmpbuf[3] = samples_per_line & 0xff; 864 tmpbuf[3] = samples_per_line & 0xff;
865 865
866 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 866 gspca_frame_add(gspca_dev, INTER_PACKET,
867 tmpbuf, sizeof(tmpbuf)); 867 tmpbuf, sizeof(tmpbuf));
868 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 868 gspca_frame_add(gspca_dev, INTER_PACKET,
869 pac_jpeg_header2, sizeof(pac_jpeg_header2)); 869 pac_jpeg_header2, sizeof(pac_jpeg_header2));
870} 870}
871 871
872/* this function is run at interrupt level */ 872/* this function is run at interrupt level */
873static void sd_pkt_scan(struct gspca_dev *gspca_dev, 873static void sd_pkt_scan(struct gspca_dev *gspca_dev,
874 struct gspca_frame *frame, /* target */ 874 u8 *data, /* isoc packet */
875 __u8 *data, /* isoc packet */
876 int len) /* iso packet length */ 875 int len) /* iso packet length */
877{ 876{
878 struct sd *sd = (struct sd *) gspca_dev; 877 struct sd *sd = (struct sd *) gspca_dev;
878 struct gspca_frame *frame;
879 unsigned char *sof; 879 unsigned char *sof;
880 880
881 sof = pac_find_sof(&sd->sof_read, data, len); 881 sof = pac_find_sof(&sd->sof_read, data, len);
882 if (sof) { 882 if (sof) {
883 int n, lum_offset, footer_length; 883 int n, lum_offset, footer_length;
884 884
885 frame = gspca_get_i_frame(gspca_dev);
886 if (frame == NULL) {
887 gspca_dev->last_packet_type = DISCARD_PACKET;
888 return;
889 }
890
885 /* 6 bytes after the FF D9 EOF marker a number of lumination 891 /* 6 bytes after the FF D9 EOF marker a number of lumination
886 bytes are send corresponding to different parts of the 892 bytes are send corresponding to different parts of the
887 image, the 14th and 15th byte after the EOF seem to 893 image, the 14th and 15th byte after the EOF seem to
@@ -895,12 +901,12 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
895 frame->data_end += n; 901 frame->data_end += n;
896 n = 0; 902 n = 0;
897 } 903 }
898 frame = gspca_frame_add(gspca_dev, INTER_PACKET, frame, 904 gspca_frame_add(gspca_dev, INTER_PACKET,
899 data, n); 905 data, n);
900 if (gspca_dev->last_packet_type != DISCARD_PACKET && 906 if (gspca_dev->last_packet_type != DISCARD_PACKET &&
901 frame->data_end[-2] == 0xff && 907 frame->data_end[-2] == 0xff &&
902 frame->data_end[-1] == 0xd9) 908 frame->data_end[-1] == 0xd9)
903 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 909 gspca_frame_add(gspca_dev, LAST_PACKET,
904 NULL, 0); 910 NULL, 0);
905 911
906 n = sof - data; 912 n = sof - data;
@@ -920,7 +926,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
920 pac_start_frame(gspca_dev, frame, 926 pac_start_frame(gspca_dev, frame,
921 gspca_dev->width, gspca_dev->height); 927 gspca_dev->width, gspca_dev->height);
922 } 928 }
923 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 929 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
924} 930}
925 931
926static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 932static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c
index 1a27da00ccc1..e5697a6345e8 100644
--- a/drivers/media/video/gspca/pac7311.c
+++ b/drivers/media/video/gspca/pac7311.c
@@ -653,7 +653,7 @@ static void pac_start_frame(struct gspca_dev *gspca_dev,
653{ 653{
654 unsigned char tmpbuf[4]; 654 unsigned char tmpbuf[4];
655 655
656 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 656 gspca_frame_add(gspca_dev, FIRST_PACKET,
657 pac_jpeg_header1, sizeof(pac_jpeg_header1)); 657 pac_jpeg_header1, sizeof(pac_jpeg_header1));
658 658
659 tmpbuf[0] = lines >> 8; 659 tmpbuf[0] = lines >> 8;
@@ -661,25 +661,31 @@ static void pac_start_frame(struct gspca_dev *gspca_dev,
661 tmpbuf[2] = samples_per_line >> 8; 661 tmpbuf[2] = samples_per_line >> 8;
662 tmpbuf[3] = samples_per_line & 0xff; 662 tmpbuf[3] = samples_per_line & 0xff;
663 663
664 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 664 gspca_frame_add(gspca_dev, INTER_PACKET,
665 tmpbuf, sizeof(tmpbuf)); 665 tmpbuf, sizeof(tmpbuf));
666 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 666 gspca_frame_add(gspca_dev, INTER_PACKET,
667 pac_jpeg_header2, sizeof(pac_jpeg_header2)); 667 pac_jpeg_header2, sizeof(pac_jpeg_header2));
668} 668}
669 669
670/* this function is run at interrupt level */ 670/* this function is run at interrupt level */
671static void sd_pkt_scan(struct gspca_dev *gspca_dev, 671static void sd_pkt_scan(struct gspca_dev *gspca_dev,
672 struct gspca_frame *frame, /* target */ 672 u8 *data, /* isoc packet */
673 __u8 *data, /* isoc packet */
674 int len) /* iso packet length */ 673 int len) /* iso packet length */
675{ 674{
676 struct sd *sd = (struct sd *) gspca_dev; 675 struct sd *sd = (struct sd *) gspca_dev;
677 unsigned char *sof; 676 unsigned char *sof;
677 struct gspca_frame *frame;
678 678
679 sof = pac_find_sof(&sd->sof_read, data, len); 679 sof = pac_find_sof(&sd->sof_read, data, len);
680 if (sof) { 680 if (sof) {
681 int n, lum_offset, footer_length; 681 int n, lum_offset, footer_length;
682 682
683 frame = gspca_get_i_frame(gspca_dev);
684 if (frame == NULL) {
685 gspca_dev->last_packet_type = DISCARD_PACKET;
686 return;
687 }
688
683 /* 6 bytes after the FF D9 EOF marker a number of lumination 689 /* 6 bytes after the FF D9 EOF marker a number of lumination
684 bytes are send corresponding to different parts of the 690 bytes are send corresponding to different parts of the
685 image, the 14th and 15th byte after the EOF seem to 691 image, the 14th and 15th byte after the EOF seem to
@@ -693,12 +699,12 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
693 frame->data_end += n; 699 frame->data_end += n;
694 n = 0; 700 n = 0;
695 } 701 }
696 frame = gspca_frame_add(gspca_dev, INTER_PACKET, frame, 702 gspca_frame_add(gspca_dev, INTER_PACKET,
697 data, n); 703 data, n);
698 if (gspca_dev->last_packet_type != DISCARD_PACKET && 704 if (gspca_dev->last_packet_type != DISCARD_PACKET &&
699 frame->data_end[-2] == 0xff && 705 frame->data_end[-2] == 0xff &&
700 frame->data_end[-1] == 0xd9) 706 frame->data_end[-1] == 0xd9)
701 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 707 gspca_frame_add(gspca_dev, LAST_PACKET,
702 NULL, 0); 708 NULL, 0);
703 709
704 n = sof - data; 710 n = sof - data;
@@ -717,7 +723,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
717 pac_start_frame(gspca_dev, frame, 723 pac_start_frame(gspca_dev, frame,
718 gspca_dev->height, gspca_dev->width); 724 gspca_dev->height, gspca_dev->width);
719 } 725 }
720 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 726 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
721} 727}
722 728
723static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) 729static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c
index cdad3db33367..b1944a7cbb0f 100644
--- a/drivers/media/video/gspca/sn9c20x.c
+++ b/drivers/media/video/gspca/sn9c20x.c
@@ -2342,7 +2342,6 @@ static void sd_dqcallback(struct gspca_dev *gspca_dev)
2342} 2342}
2343 2343
2344static void sd_pkt_scan(struct gspca_dev *gspca_dev, 2344static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2345 struct gspca_frame *frame, /* target */
2346 u8 *data, /* isoc packet */ 2345 u8 *data, /* isoc packet */
2347 int len) /* iso packet length */ 2346 int len) /* iso packet length */
2348{ 2347{
@@ -2378,22 +2377,22 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2378 avg_lum >>= 9; 2377 avg_lum >>= 9;
2379 atomic_set(&sd->avg_lum, avg_lum); 2378 atomic_set(&sd->avg_lum, avg_lum);
2380 gspca_frame_add(gspca_dev, LAST_PACKET, 2379 gspca_frame_add(gspca_dev, LAST_PACKET,
2381 frame, data, len); 2380 data, len);
2382 return; 2381 return;
2383 } 2382 }
2384 if (gspca_dev->last_packet_type == LAST_PACKET) { 2383 if (gspca_dev->last_packet_type == LAST_PACKET) {
2385 if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv 2384 if (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv
2386 & MODE_JPEG) { 2385 & MODE_JPEG) {
2387 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 2386 gspca_frame_add(gspca_dev, FIRST_PACKET,
2388 sd->jpeg_hdr, JPEG_HDR_SZ); 2387 sd->jpeg_hdr, JPEG_HDR_SZ);
2389 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 2388 gspca_frame_add(gspca_dev, INTER_PACKET,
2390 data, len); 2389 data, len);
2391 } else { 2390 } else {
2392 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 2391 gspca_frame_add(gspca_dev, FIRST_PACKET,
2393 data, len); 2392 data, len);
2394 } 2393 }
2395 } else { 2394 } else {
2396 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 2395 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2397 } 2396 }
2398} 2397}
2399 2398
diff --git a/drivers/media/video/gspca/sonixb.c b/drivers/media/video/gspca/sonixb.c
index cf3af8de6e97..a9f061063b49 100644
--- a/drivers/media/video/gspca/sonixb.c
+++ b/drivers/media/video/gspca/sonixb.c
@@ -995,8 +995,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
995} 995}
996 996
997static void sd_pkt_scan(struct gspca_dev *gspca_dev, 997static void sd_pkt_scan(struct gspca_dev *gspca_dev,
998 struct gspca_frame *frame, /* target */ 998 u8 *data, /* isoc packet */
999 unsigned char *data, /* isoc packet */
1000 int len) /* iso packet length */ 999 int len) /* iso packet length */
1001{ 1000{
1002 int i; 1001 int i;
@@ -1054,12 +1053,12 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1054 pkt_type = DISCARD_PACKET; 1053 pkt_type = DISCARD_PACKET;
1055 } 1054 }
1056 1055
1057 frame = gspca_frame_add(gspca_dev, pkt_type, 1056 gspca_frame_add(gspca_dev, pkt_type,
1058 frame, data, 0); 1057 NULL, 0);
1059 data += i + fr_h_sz; 1058 data += i + fr_h_sz;
1060 len -= i + fr_h_sz; 1059 len -= i + fr_h_sz;
1061 gspca_frame_add(gspca_dev, FIRST_PACKET, 1060 gspca_frame_add(gspca_dev, FIRST_PACKET,
1062 frame, data, len); 1061 data, len);
1063 return; 1062 return;
1064 } 1063 }
1065 } 1064 }
@@ -1068,15 +1067,21 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1068 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) { 1067 if (cam->cam_mode[gspca_dev->curr_mode].priv & MODE_RAW) {
1069 /* In raw mode we sometimes get some garbage after the frame 1068 /* In raw mode we sometimes get some garbage after the frame
1070 ignore this */ 1069 ignore this */
1071 int used = frame->data_end - frame->data; 1070 struct gspca_frame *frame;
1071 int used;
1072 int size = cam->cam_mode[gspca_dev->curr_mode].sizeimage; 1072 int size = cam->cam_mode[gspca_dev->curr_mode].sizeimage;
1073 1073
1074 frame = gspca_get_i_frame(gspca_dev);
1075 if (frame == NULL) {
1076 gspca_dev->last_packet_type = DISCARD_PACKET;
1077 return;
1078 }
1079 used = frame->data_end - frame->data;
1074 if (used + len > size) 1080 if (used + len > size)
1075 len = size - used; 1081 len = size - used;
1076 } 1082 }
1077 1083
1078 gspca_frame_add(gspca_dev, INTER_PACKET, 1084 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
1079 frame, data, len);
1080} 1085}
1081 1086
1082static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 1087static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index 5f82efb93d9b..282c707e5e81 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -1993,7 +1993,6 @@ static void do_autogain(struct gspca_dev *gspca_dev)
1993/* scan the URB packets */ 1993/* scan the URB packets */
1994/* This function is run at interrupt level. */ 1994/* This function is run at interrupt level. */
1995static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1995static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1996 struct gspca_frame *frame, /* target */
1997 u8 *data, /* isoc packet */ 1996 u8 *data, /* isoc packet */
1998 int len) /* iso packet length */ 1997 int len) /* iso packet length */
1999{ 1998{
@@ -2005,7 +2004,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2005 2004
2006 /* end of frame */ 2005 /* end of frame */
2007 gspca_frame_add(gspca_dev, LAST_PACKET, 2006 gspca_frame_add(gspca_dev, LAST_PACKET,
2008 frame, data, sof + 2); 2007 data, sof + 2);
2009 if (sd->ag_cnt < 0) 2008 if (sd->ag_cnt < 0)
2010 return; 2009 return;
2011/* w1 w2 w3 */ 2010/* w1 w2 w3 */
@@ -2028,10 +2027,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2028 if (gspca_dev->last_packet_type == LAST_PACKET) { 2027 if (gspca_dev->last_packet_type == LAST_PACKET) {
2029 2028
2030 /* put the JPEG 422 header */ 2029 /* put the JPEG 422 header */
2031 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 2030 gspca_frame_add(gspca_dev, FIRST_PACKET,
2032 sd->jpeg_hdr, JPEG_HDR_SZ); 2031 sd->jpeg_hdr, JPEG_HDR_SZ);
2033 } 2032 }
2034 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 2033 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2035} 2034}
2036 2035
2037static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 2036static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c
index fab7ef85a6c1..8bd844d319ea 100644
--- a/drivers/media/video/gspca/spca500.c
+++ b/drivers/media/video/gspca/spca500.c
@@ -899,8 +899,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
899} 899}
900 900
901static void sd_pkt_scan(struct gspca_dev *gspca_dev, 901static void sd_pkt_scan(struct gspca_dev *gspca_dev,
902 struct gspca_frame *frame, /* target */ 902 u8 *data, /* isoc packet */
903 __u8 *data, /* isoc packet */
904 int len) /* iso packet length */ 903 int len) /* iso packet length */
905{ 904{
906 struct sd *sd = (struct sd *) gspca_dev; 905 struct sd *sd = (struct sd *) gspca_dev;
@@ -913,11 +912,11 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
913/* gspca_dev->last_packet_type = DISCARD_PACKET; */ 912/* gspca_dev->last_packet_type = DISCARD_PACKET; */
914 return; 913 return;
915 } 914 }
916 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 915 gspca_frame_add(gspca_dev, LAST_PACKET,
917 ffd9, 2); 916 ffd9, 2);
918 917
919 /* put the JPEG header in the new frame */ 918 /* put the JPEG header in the new frame */
920 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 919 gspca_frame_add(gspca_dev, FIRST_PACKET,
921 sd->jpeg_hdr, JPEG_HDR_SZ); 920 sd->jpeg_hdr, JPEG_HDR_SZ);
922 921
923 data += SPCA500_OFFSET_DATA; 922 data += SPCA500_OFFSET_DATA;
@@ -931,7 +930,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
931 i = 0; 930 i = 0;
932 do { 931 do {
933 if (data[i] == 0xff) { 932 if (data[i] == 0xff) {
934 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 933 gspca_frame_add(gspca_dev, INTER_PACKET,
935 data, i + 1); 934 data, i + 1);
936 len -= i; 935 len -= i;
937 data += i; 936 data += i;
@@ -940,7 +939,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
940 } 939 }
941 i++; 940 i++;
942 } while (i < len); 941 } while (i < len);
943 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 942 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
944} 943}
945 944
946static void setbrightness(struct gspca_dev *gspca_dev) 945static void setbrightness(struct gspca_dev *gspca_dev)
diff --git a/drivers/media/video/gspca/spca501.c b/drivers/media/video/gspca/spca501.c
index b74a34218da0..d251f145a751 100644
--- a/drivers/media/video/gspca/spca501.c
+++ b/drivers/media/video/gspca/spca501.c
@@ -2032,20 +2032,15 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
2032} 2032}
2033 2033
2034static void sd_pkt_scan(struct gspca_dev *gspca_dev, 2034static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2035 struct gspca_frame *frame, /* target */ 2035 u8 *data, /* isoc packet */
2036 __u8 *data, /* isoc packet */
2037 int len) /* iso packet length */ 2036 int len) /* iso packet length */
2038{ 2037{
2039 switch (data[0]) { 2038 switch (data[0]) {
2040 case 0: /* start of frame */ 2039 case 0: /* start of frame */
2041 frame = gspca_frame_add(gspca_dev, 2040 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
2042 LAST_PACKET,
2043 frame,
2044 data, 0);
2045 data += SPCA501_OFFSET_DATA; 2041 data += SPCA501_OFFSET_DATA;
2046 len -= SPCA501_OFFSET_DATA; 2042 len -= SPCA501_OFFSET_DATA;
2047 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 2043 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
2048 data, len);
2049 return; 2044 return;
2050 case 0xff: /* drop */ 2045 case 0xff: /* drop */
2051/* gspca_dev->last_packet_type = DISCARD_PACKET; */ 2046/* gspca_dev->last_packet_type = DISCARD_PACKET; */
@@ -2053,8 +2048,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2053 } 2048 }
2054 data++; 2049 data++;
2055 len--; 2050 len--;
2056 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 2051 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
2057 data, len);
2058} 2052}
2059 2053
2060static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 2054static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/spca505.c b/drivers/media/video/gspca/spca505.c
index ea8c9fe2e961..0f9232ff1281 100644
--- a/drivers/media/video/gspca/spca505.c
+++ b/drivers/media/video/gspca/spca505.c
@@ -739,26 +739,22 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
739} 739}
740 740
741static void sd_pkt_scan(struct gspca_dev *gspca_dev, 741static void sd_pkt_scan(struct gspca_dev *gspca_dev,
742 struct gspca_frame *frame, /* target */
743 u8 *data, /* isoc packet */ 742 u8 *data, /* isoc packet */
744 int len) /* iso packet length */ 743 int len) /* iso packet length */
745{ 744{
746 switch (data[0]) { 745 switch (data[0]) {
747 case 0: /* start of frame */ 746 case 0: /* start of frame */
748 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 747 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
749 data, 0);
750 data += SPCA50X_OFFSET_DATA; 748 data += SPCA50X_OFFSET_DATA;
751 len -= SPCA50X_OFFSET_DATA; 749 len -= SPCA50X_OFFSET_DATA;
752 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 750 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
753 data, len);
754 break; 751 break;
755 case 0xff: /* drop */ 752 case 0xff: /* drop */
756 break; 753 break;
757 default: 754 default:
758 data += 1; 755 data += 1;
759 len -= 1; 756 len -= 1;
760 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 757 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
761 data, len);
762 break; 758 break;
763 } 759 }
764} 760}
diff --git a/drivers/media/video/gspca/spca506.c b/drivers/media/video/gspca/spca506.c
index a199298a6419..ab28cc23e415 100644
--- a/drivers/media/video/gspca/spca506.c
+++ b/drivers/media/video/gspca/spca506.c
@@ -543,18 +543,15 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
543} 543}
544 544
545static void sd_pkt_scan(struct gspca_dev *gspca_dev, 545static void sd_pkt_scan(struct gspca_dev *gspca_dev,
546 struct gspca_frame *frame, /* target */ 546 u8 *data, /* isoc packet */
547 __u8 *data, /* isoc packet */
548 int len) /* iso packet length */ 547 int len) /* iso packet length */
549{ 548{
550 switch (data[0]) { 549 switch (data[0]) {
551 case 0: /* start of frame */ 550 case 0: /* start of frame */
552 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 551 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
553 data, 0);
554 data += SPCA50X_OFFSET_DATA; 552 data += SPCA50X_OFFSET_DATA;
555 len -= SPCA50X_OFFSET_DATA; 553 len -= SPCA50X_OFFSET_DATA;
556 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 554 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
557 data, len);
558 break; 555 break;
559 case 0xff: /* drop */ 556 case 0xff: /* drop */
560/* gspca_dev->last_packet_type = DISCARD_PACKET; */ 557/* gspca_dev->last_packet_type = DISCARD_PACKET; */
@@ -562,8 +559,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
562 default: 559 default:
563 data += 1; 560 data += 1;
564 len -= 1; 561 len -= 1;
565 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 562 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
566 data, len);
567 break; 563 break;
568 } 564 }
569} 565}
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c
index 9696c4caf5c9..4d8e6cf75d55 100644
--- a/drivers/media/video/gspca/spca508.c
+++ b/drivers/media/video/gspca/spca508.c
@@ -1447,26 +1447,22 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1447} 1447}
1448 1448
1449static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1449static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1450 struct gspca_frame *frame, /* target */
1451 u8 *data, /* isoc packet */ 1450 u8 *data, /* isoc packet */
1452 int len) /* iso packet length */ 1451 int len) /* iso packet length */
1453{ 1452{
1454 switch (data[0]) { 1453 switch (data[0]) {
1455 case 0: /* start of frame */ 1454 case 0: /* start of frame */
1456 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 1455 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
1457 data, 0);
1458 data += SPCA508_OFFSET_DATA; 1456 data += SPCA508_OFFSET_DATA;
1459 len -= SPCA508_OFFSET_DATA; 1457 len -= SPCA508_OFFSET_DATA;
1460 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 1458 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
1461 data, len);
1462 break; 1459 break;
1463 case 0xff: /* drop */ 1460 case 0xff: /* drop */
1464 break; 1461 break;
1465 default: 1462 default:
1466 data += 1; 1463 data += 1;
1467 len -= 1; 1464 len -= 1;
1468 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 1465 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
1469 data, len);
1470 break; 1466 break;
1471 } 1467 }
1472} 1468}
diff --git a/drivers/media/video/gspca/spca561.c b/drivers/media/video/gspca/spca561.c
index 27e82b35f3e7..58c2f0039af1 100644
--- a/drivers/media/video/gspca/spca561.c
+++ b/drivers/media/video/gspca/spca561.c
@@ -779,8 +779,7 @@ static void do_autogain(struct gspca_dev *gspca_dev)
779} 779}
780 780
781static void sd_pkt_scan(struct gspca_dev *gspca_dev, 781static void sd_pkt_scan(struct gspca_dev *gspca_dev,
782 struct gspca_frame *frame, /* target */ 782 u8 *data, /* isoc packet */
783 __u8 *data, /* isoc packet */
784 int len) /* iso packet length */ 783 int len) /* iso packet length */
785{ 784{
786 struct sd *sd = (struct sd *) gspca_dev; 785 struct sd *sd = (struct sd *) gspca_dev;
@@ -788,12 +787,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
788 len--; 787 len--;
789 switch (*data++) { /* sequence number */ 788 switch (*data++) { /* sequence number */
790 case 0: /* start of frame */ 789 case 0: /* start of frame */
791 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 790 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
792 data, 0);
793 if (data[1] & 0x10) { 791 if (data[1] & 0x10) {
794 /* compressed bayer */ 792 /* compressed bayer */
795 gspca_frame_add(gspca_dev, FIRST_PACKET, 793 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
796 frame, data, len);
797 } else { 794 } else {
798 /* raw bayer (with a header, which we skip) */ 795 /* raw bayer (with a header, which we skip) */
799 if (sd->chip_revision == Rev012A) { 796 if (sd->chip_revision == Rev012A) {
@@ -803,14 +800,13 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
803 data += 16; 800 data += 16;
804 len -= 16; 801 len -= 16;
805 } 802 }
806 gspca_frame_add(gspca_dev, FIRST_PACKET, 803 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
807 frame, data, len);
808 } 804 }
809 return; 805 return;
810 case 0xff: /* drop (empty mpackets) */ 806 case 0xff: /* drop (empty mpackets) */
811 return; 807 return;
812 } 808 }
813 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 809 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
814} 810}
815 811
816/* rev 72a only */ 812/* rev 72a only */
diff --git a/drivers/media/video/gspca/sq905.c b/drivers/media/video/gspca/sq905.c
index 547d1fd5191d..1fcaca6a87f7 100644
--- a/drivers/media/video/gspca/sq905.c
+++ b/drivers/media/video/gspca/sq905.c
@@ -214,7 +214,6 @@ static void sq905_dostream(struct work_struct *work)
214{ 214{
215 struct sd *dev = container_of(work, struct sd, work_struct); 215 struct sd *dev = container_of(work, struct sd, work_struct);
216 struct gspca_dev *gspca_dev = &dev->gspca_dev; 216 struct gspca_dev *gspca_dev = &dev->gspca_dev;
217 struct gspca_frame *frame;
218 int bytes_left; /* bytes remaining in current frame. */ 217 int bytes_left; /* bytes remaining in current frame. */
219 int data_len; /* size to use for the next read. */ 218 int data_len; /* size to use for the next read. */
220 int header_read; /* true if we have already read the frame header. */ 219 int header_read; /* true if we have already read the frame header. */
@@ -266,18 +265,14 @@ static void sq905_dostream(struct work_struct *work)
266 } else { 265 } else {
267 packet_type = INTER_PACKET; 266 packet_type = INTER_PACKET;
268 } 267 }
269 frame = gspca_get_i_frame(gspca_dev); 268 gspca_frame_add(gspca_dev, packet_type,
270 if (frame) { 269 data, data_len);
271 frame = gspca_frame_add(gspca_dev, packet_type, 270 /* If entire frame fits in one packet we still
272 frame, data, data_len); 271 need to add a LAST_PACKET */
273 /* If entire frame fits in one packet we still 272 if (packet_type == FIRST_PACKET &&
274 need to add a LAST_PACKET */ 273 bytes_left == 0)
275 if (packet_type == FIRST_PACKET && 274 gspca_frame_add(gspca_dev, LAST_PACKET,
276 bytes_left == 0) 275 NULL, 0);
277 frame = gspca_frame_add(gspca_dev,
278 LAST_PACKET,
279 frame, data, 0);
280 }
281 } 276 }
282 if (gspca_dev->present) { 277 if (gspca_dev->present) {
283 /* acknowledge the frame */ 278 /* acknowledge the frame */
diff --git a/drivers/media/video/gspca/sq905c.c b/drivers/media/video/gspca/sq905c.c
index 81020f6f739e..d70b156872d6 100644
--- a/drivers/media/video/gspca/sq905c.c
+++ b/drivers/media/video/gspca/sq905c.c
@@ -115,7 +115,6 @@ static void sq905c_dostream(struct work_struct *work)
115{ 115{
116 struct sd *dev = container_of(work, struct sd, work_struct); 116 struct sd *dev = container_of(work, struct sd, work_struct);
117 struct gspca_dev *gspca_dev = &dev->gspca_dev; 117 struct gspca_dev *gspca_dev = &dev->gspca_dev;
118 struct gspca_frame *frame;
119 int bytes_left; /* bytes remaining in current frame. */ 118 int bytes_left; /* bytes remaining in current frame. */
120 int data_len; /* size to use for the next read. */ 119 int data_len; /* size to use for the next read. */
121 int act_len; 120 int act_len;
@@ -146,10 +145,8 @@ static void sq905c_dostream(struct work_struct *work)
146 PDEBUG(D_STREAM, "bytes_left = 0x%x", bytes_left); 145 PDEBUG(D_STREAM, "bytes_left = 0x%x", bytes_left);
147 /* We keep the header. It has other information, too. */ 146 /* We keep the header. It has other information, too. */
148 packet_type = FIRST_PACKET; 147 packet_type = FIRST_PACKET;
149 frame = gspca_get_i_frame(gspca_dev); 148 gspca_frame_add(gspca_dev, packet_type,
150 if (frame) 149 buffer, FRAME_HEADER_LEN);
151 gspca_frame_add(gspca_dev, packet_type,
152 frame, buffer, FRAME_HEADER_LEN);
153 while (bytes_left > 0 && gspca_dev->present) { 150 while (bytes_left > 0 && gspca_dev->present) {
154 data_len = bytes_left > SQ905C_MAX_TRANSFER ? 151 data_len = bytes_left > SQ905C_MAX_TRANSFER ?
155 SQ905C_MAX_TRANSFER : bytes_left; 152 SQ905C_MAX_TRANSFER : bytes_left;
@@ -167,9 +164,8 @@ static void sq905c_dostream(struct work_struct *work)
167 packet_type = LAST_PACKET; 164 packet_type = LAST_PACKET;
168 else 165 else
169 packet_type = INTER_PACKET; 166 packet_type = INTER_PACKET;
170 if (frame) 167 gspca_frame_add(gspca_dev, packet_type,
171 gspca_frame_add(gspca_dev, packet_type, 168 buffer, data_len);
172 frame, buffer, data_len);
173 } 169 }
174 } 170 }
175quit_stream: 171quit_stream:
diff --git a/drivers/media/video/gspca/stk014.c b/drivers/media/video/gspca/stk014.c
index 47628964801e..8e23320d7ab7 100644
--- a/drivers/media/video/gspca/stk014.c
+++ b/drivers/media/video/gspca/stk014.c
@@ -418,8 +418,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
418} 418}
419 419
420static void sd_pkt_scan(struct gspca_dev *gspca_dev, 420static void sd_pkt_scan(struct gspca_dev *gspca_dev,
421 struct gspca_frame *frame, /* target */ 421 u8 *data, /* isoc packet */
422 __u8 *data, /* isoc packet */
423 int len) /* iso packet length */ 422 int len) /* iso packet length */
424{ 423{
425 struct sd *sd = (struct sd *) gspca_dev; 424 struct sd *sd = (struct sd *) gspca_dev;
@@ -435,11 +434,11 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
435 * (without ending - ff d9) 434 * (without ending - ff d9)
436 */ 435 */
437 if (data[0] == 0xff && data[1] == 0xfe) { 436 if (data[0] == 0xff && data[1] == 0xfe) {
438 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 437 gspca_frame_add(gspca_dev, LAST_PACKET,
439 ffd9, 2); 438 ffd9, 2);
440 439
441 /* put the JPEG 411 header */ 440 /* put the JPEG 411 header */
442 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 441 gspca_frame_add(gspca_dev, FIRST_PACKET,
443 sd->jpeg_hdr, JPEG_HDR_SZ); 442 sd->jpeg_hdr, JPEG_HDR_SZ);
444 443
445 /* beginning of the frame */ 444 /* beginning of the frame */
@@ -447,7 +446,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
447 data += STKHDRSZ; 446 data += STKHDRSZ;
448 len -= STKHDRSZ; 447 len -= STKHDRSZ;
449 } 448 }
450 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 449 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
451} 450}
452 451
453static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 452static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/stv0680.c b/drivers/media/video/gspca/stv0680.c
index 0981ce14235d..2a69d7ccb50d 100644
--- a/drivers/media/video/gspca/stv0680.c
+++ b/drivers/media/video/gspca/stv0680.c
@@ -281,8 +281,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
281} 281}
282 282
283static void sd_pkt_scan(struct gspca_dev *gspca_dev, 283static void sd_pkt_scan(struct gspca_dev *gspca_dev,
284 struct gspca_frame *frame, 284 u8 *data,
285 __u8 *data,
286 int len) 285 int len)
287{ 286{
288 struct sd *sd = (struct sd *) gspca_dev; 287 struct sd *sd = (struct sd *) gspca_dev;
@@ -299,10 +298,10 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
299 /* Finish the previous frame, we do this upon reception of the next 298 /* Finish the previous frame, we do this upon reception of the next
300 packet, even though it is already complete so that the strange 16 299 packet, even though it is already complete so that the strange 16
301 byte packets send after a corrupt frame can discard it. */ 300 byte packets send after a corrupt frame can discard it. */
302 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, NULL, 0); 301 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
303 302
304 /* Store the just received frame */ 303 /* Store the just received frame */
305 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len); 304 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
306} 305}
307 306
308/* sub-driver description */ 307/* sub-driver description */
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx.c b/drivers/media/video/gspca/stv06xx/stv06xx.c
index bfae63f5584c..5d0241bb1611 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx.c
+++ b/drivers/media/video/gspca/stv06xx/stv06xx.c
@@ -312,8 +312,7 @@ out:
312 * The 0005 and 0100 chunks seem to appear only in compressed stream. 312 * The 0005 and 0100 chunks seem to appear only in compressed stream.
313 */ 313 */
314static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev, 314static void stv06xx_pkt_scan(struct gspca_dev *gspca_dev,
315 struct gspca_frame *frame, /* target */ 315 u8 *data, /* isoc packet */
316 __u8 *data, /* isoc packet */
317 int len) /* iso packet length */ 316 int len) /* iso packet length */
318{ 317{
319 struct sd *sd = (struct sd *) gspca_dev; 318 struct sd *sd = (struct sd *) gspca_dev;
@@ -366,7 +365,7 @@ frame_data:
366 sd->to_skip -= skip; 365 sd->to_skip -= skip;
367 } 366 }
368 367
369 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 368 gspca_frame_add(gspca_dev, INTER_PACKET,
370 data, chunk_len); 369 data, chunk_len);
371 break; 370 break;
372 371
@@ -378,7 +377,7 @@ frame_data:
378 377
379 /* Create a new frame, chunk length should be zero */ 378 /* Create a new frame, chunk length should be zero */
380 gspca_frame_add(gspca_dev, FIRST_PACKET, 379 gspca_frame_add(gspca_dev, FIRST_PACKET,
381 frame, data, 0); 380 NULL, 0);
382 381
383 if (sd->bridge == BRIDGE_ST6422) 382 if (sd->bridge == BRIDGE_ST6422)
384 sd->to_skip = gspca_dev->width * 4; 383 sd->to_skip = gspca_dev->width * 4;
@@ -394,8 +393,8 @@ frame_data:
394 PDEBUG(D_PACK, "End of frame detected"); 393 PDEBUG(D_PACK, "End of frame detected");
395 394
396 /* Complete the last frame (if any) */ 395 /* Complete the last frame (if any) */
397 frame = gspca_frame_add(gspca_dev, LAST_PACKET, 396 gspca_frame_add(gspca_dev, LAST_PACKET,
398 frame, data, 0); 397 NULL, 0);
399 398
400 if (chunk_len) 399 if (chunk_len)
401 PDEBUG(D_ERR, "Chunk length is " 400 PDEBUG(D_ERR, "Chunk length is "
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index aa8f995ce04e..682652cb7fe1 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -1116,7 +1116,6 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
1116} 1116}
1117 1117
1118static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1118static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1119 struct gspca_frame *frame, /* target */
1120 u8 *data, /* isoc packet */ 1119 u8 *data, /* isoc packet */
1121 int len) /* iso packet length */ 1120 int len) /* iso packet length */
1122{ 1121{
@@ -1186,11 +1185,11 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1186 break; 1185 break;
1187 } 1186 }
1188 if (sof) { /* start of frame */ 1187 if (sof) { /* start of frame */
1189 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 1188 gspca_frame_add(gspca_dev, LAST_PACKET,
1190 ffd9, 2); 1189 ffd9, 2);
1191 1190
1192 /* put the JPEG header in the new frame */ 1191 /* put the JPEG header in the new frame */
1193 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 1192 gspca_frame_add(gspca_dev, FIRST_PACKET,
1194 sd->jpeg_hdr, JPEG_HDR_SZ); 1193 sd->jpeg_hdr, JPEG_HDR_SZ);
1195 } 1194 }
1196 1195
@@ -1198,7 +1197,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1198 i = 0; 1197 i = 0;
1199 do { 1198 do {
1200 if (data[i] == 0xff) { 1199 if (data[i] == 0xff) {
1201 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 1200 gspca_frame_add(gspca_dev, INTER_PACKET,
1202 data, i + 1); 1201 data, i + 1);
1203 len -= i; 1202 len -= i;
1204 data += i; 1203 data += i;
@@ -1207,7 +1206,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1207 } 1206 }
1208 i++; 1207 i++;
1209 } while (i < len); 1208 } while (i < len);
1210 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 1209 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
1211} 1210}
1212 1211
1213static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 1212static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c
index 1d321c30d22f..55ef6a744427 100644
--- a/drivers/media/video/gspca/t613.c
+++ b/drivers/media/video/gspca/t613.c
@@ -938,7 +938,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
938} 938}
939 939
940static void sd_pkt_scan(struct gspca_dev *gspca_dev, 940static void sd_pkt_scan(struct gspca_dev *gspca_dev,
941 struct gspca_frame *frame, /* target */
942 u8 *data, /* isoc packet */ 941 u8 *data, /* isoc packet */
943 int len) /* iso packet length */ 942 int len) /* iso packet length */
944{ 943{
@@ -956,9 +955,9 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
956 /* extra bytes....., could be processed too but would be 955 /* extra bytes....., could be processed too but would be
957 * a waste of time, right now leave the application and 956 * a waste of time, right now leave the application and
958 * libjpeg do it for ourserlves.. */ 957 * libjpeg do it for ourserlves.. */
959 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 958 gspca_frame_add(gspca_dev, LAST_PACKET,
960 ffd9, 2); 959 ffd9, 2);
961 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len); 960 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
962 return; 961 return;
963 } 962 }
964 963
@@ -967,7 +966,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
967 * other's do not include it... */ 966 * other's do not include it... */
968 len -= 2; 967 len -= 2;
969 } 968 }
970 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 969 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
971} 970}
972 971
973static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 972static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/tv8532.c b/drivers/media/video/gspca/tv8532.c
index 4b44dde9f8b8..b74a3b6489c7 100644
--- a/drivers/media/video/gspca/tv8532.c
+++ b/drivers/media/video/gspca/tv8532.c
@@ -398,8 +398,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
398} 398}
399 399
400static void sd_pkt_scan(struct gspca_dev *gspca_dev, 400static void sd_pkt_scan(struct gspca_dev *gspca_dev,
401 struct gspca_frame *frame, /* target */ 401 u8 *data, /* isoc packet */
402 __u8 *data, /* isoc packet */
403 int len) /* iso packet length */ 402 int len) /* iso packet length */
404{ 403{
405 struct sd *sd = (struct sd *) gspca_dev; 404 struct sd *sd = (struct sd *) gspca_dev;
@@ -424,9 +423,9 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
424 * - 4 bytes 423 * - 4 bytes
425 */ 424 */
426 gspca_frame_add(gspca_dev, packet_type0, 425 gspca_frame_add(gspca_dev, packet_type0,
427 frame, data + 2, gspca_dev->width); 426 data + 2, gspca_dev->width);
428 gspca_frame_add(gspca_dev, packet_type1, 427 gspca_frame_add(gspca_dev, packet_type1,
429 frame, data + gspca_dev->width + 5, gspca_dev->width); 428 data + gspca_dev->width + 5, gspca_dev->width);
430} 429}
431 430
432static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 431static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/vc032x.c b/drivers/media/video/gspca/vc032x.c
index 589042f6adbe..26675236fbd2 100644
--- a/drivers/media/video/gspca/vc032x.c
+++ b/drivers/media/video/gspca/vc032x.c
@@ -2987,7 +2987,6 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
2987} 2987}
2988 2988
2989static void sd_pkt_scan(struct gspca_dev *gspca_dev, 2989static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2990 struct gspca_frame *frame, /* target */
2991 u8 *data, /* isoc packet */ 2990 u8 *data, /* isoc packet */
2992 int len) /* iso pkt length */ 2991 int len) /* iso pkt length */
2993{ 2992{
@@ -2996,21 +2995,25 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
2996 if (data[0] == 0xff && data[1] == 0xd8) { 2995 if (data[0] == 0xff && data[1] == 0xd8) {
2997 PDEBUG(D_PACK, 2996 PDEBUG(D_PACK,
2998 "vc032x header packet found len %d", len); 2997 "vc032x header packet found len %d", len);
2999 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 2998 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
3000 data, 0);
3001 data += sd->image_offset; 2999 data += sd->image_offset;
3002 len -= sd->image_offset; 3000 len -= sd->image_offset;
3003 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 3001 gspca_frame_add(gspca_dev, FIRST_PACKET, data, len);
3004 data, len);
3005 return; 3002 return;
3006 } 3003 }
3007 3004
3008 /* The vc0321 sends some additional data after sending the complete 3005 /* The vc0321 sends some additional data after sending the complete
3009 * frame, we ignore this. */ 3006 * frame, we ignore this. */
3010 if (sd->bridge == BRIDGE_VC0321 3007 if (sd->bridge == BRIDGE_VC0321) {
3011 && len > frame->v4l2_buf.length - (frame->data_end - frame->data)) 3008 struct gspca_frame *frame;
3012 len = frame->v4l2_buf.length - (frame->data_end - frame->data); 3009 int l;
3013 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 3010
3011 frame = gspca_get_i_frame(gspca_dev);
3012 l = frame->data_end - frame->data;
3013 if (len > frame->v4l2_buf.length - l)
3014 len = frame->v4l2_buf.length - l;
3015 }
3016 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
3014} 3017}
3015 3018
3016static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val) 3019static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val)
diff --git a/drivers/media/video/gspca/w996Xcf.c b/drivers/media/video/gspca/w996Xcf.c
index 4f9add79ce13..2fffe203bed8 100644
--- a/drivers/media/video/gspca/w996Xcf.c
+++ b/drivers/media/video/gspca/w996Xcf.c
@@ -576,8 +576,7 @@ static void w9968cf_stop0(struct sd *sd)
576 to be precise it sends: SOI, SOF, DRI, SOS, Y-data, SOS, U-data, SOS, 576 to be precise it sends: SOI, SOF, DRI, SOS, Y-data, SOS, U-data, SOS,
577 V-data, EOI. */ 577 V-data, EOI. */
578static void w9968cf_pkt_scan(struct gspca_dev *gspca_dev, 578static void w9968cf_pkt_scan(struct gspca_dev *gspca_dev,
579 struct gspca_frame *frame, /* target */ 579 u8 *data, /* isoc packet */
580 __u8 *data, /* isoc packet */
581 int len) /* iso packet length */ 580 int len) /* iso packet length */
582{ 581{
583 struct sd *sd = (struct sd *) gspca_dev; 582 struct sd *sd = (struct sd *) gspca_dev;
@@ -587,9 +586,9 @@ static void w9968cf_pkt_scan(struct gspca_dev *gspca_dev,
587 if (len >= 2 && 586 if (len >= 2 &&
588 data[0] == 0xff && 587 data[0] == 0xff &&
589 data[1] == 0xd8) { 588 data[1] == 0xd8) {
590 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 589 gspca_frame_add(gspca_dev, LAST_PACKET,
591 NULL, 0); 590 NULL, 0);
592 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 591 gspca_frame_add(gspca_dev, FIRST_PACKET,
593 sd->jpeg_hdr, JPEG_HDR_SZ); 592 sd->jpeg_hdr, JPEG_HDR_SZ);
594 /* Strip the ff d8, our own header (which adds 593 /* Strip the ff d8, our own header (which adds
595 huffman and quantization tables) already has this */ 594 huffman and quantization tables) already has this */
@@ -599,12 +598,12 @@ static void w9968cf_pkt_scan(struct gspca_dev *gspca_dev,
599 } else { 598 } else {
600 /* In UYVY mode an empty packet signals EOF */ 599 /* In UYVY mode an empty packet signals EOF */
601 if (gspca_dev->empty_packet) { 600 if (gspca_dev->empty_packet) {
602 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 601 gspca_frame_add(gspca_dev, LAST_PACKET,
603 NULL, 0); 602 NULL, 0);
604 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 603 gspca_frame_add(gspca_dev, FIRST_PACKET,
605 NULL, 0); 604 NULL, 0);
606 gspca_dev->empty_packet = 0; 605 gspca_dev->empty_packet = 0;
607 } 606 }
608 } 607 }
609 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 608 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
610} 609}
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 113050792246..864974b61145 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -6974,17 +6974,16 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
6974} 6974}
6975 6975
6976static void sd_pkt_scan(struct gspca_dev *gspca_dev, 6976static void sd_pkt_scan(struct gspca_dev *gspca_dev,
6977 struct gspca_frame *frame, 6977 u8 *data,
6978 __u8 *data,
6979 int len) 6978 int len)
6980{ 6979{
6981 struct sd *sd = (struct sd *) gspca_dev; 6980 struct sd *sd = (struct sd *) gspca_dev;
6982 6981
6983 if (data[0] == 0xff && data[1] == 0xd8) { /* start of frame */ 6982 if (data[0] == 0xff && data[1] == 0xd8) { /* start of frame */
6984 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 6983 gspca_frame_add(gspca_dev, LAST_PACKET,
6985 data, 0); 6984 NULL, 0);
6986 /* put the JPEG header in the new frame */ 6985 /* put the JPEG header in the new frame */
6987 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 6986 gspca_frame_add(gspca_dev, FIRST_PACKET,
6988 sd->jpeg_hdr, JPEG_HDR_SZ); 6987 sd->jpeg_hdr, JPEG_HDR_SZ);
6989 6988
6990 /* remove the webcam's header: 6989 /* remove the webcam's header:
@@ -6996,7 +6995,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
6996 data += 18; 6995 data += 18;
6997 len -= 18; 6996 len -= 18;
6998 } 6997 }
6999 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 6998 gspca_frame_add(gspca_dev, INTER_PACKET, data, len);
7000} 6999}
7001 7000
7002static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) 7001static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val)