aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorJean-François Moine <moinejf@free.fr>2010-06-04 04:26:42 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-08-02 13:06:08 -0400
commit9a731a3265a808c806766a28e2b62e9da78f9ac6 (patch)
treec7e6465a5233a6e0579f81d46f0de80a8213ce49 /drivers/media/video
parent456c9acb63fa5c3974c72309f831bd0e1f34b6d9 (diff)
V4L/DVB: gspca - JPEG subdrivers: Don't allocate the JPEG header
The JPEG header is now included in the subdriver structure instead of being allocated and freed at capture start and stop. Signed-off-by: Jean-François 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.c8
-rw-r--r--drivers/media/video/gspca/jeilinj.c6
-rw-r--r--drivers/media/video/gspca/mars.c13
-rw-r--r--drivers/media/video/gspca/ov519.c7
-rw-r--r--drivers/media/video/gspca/sn9c20x.c17
-rw-r--r--drivers/media/video/gspca/spca500.c13
-rw-r--r--drivers/media/video/gspca/stk014.c13
-rw-r--r--drivers/media/video/gspca/sunplus.c13
-rw-r--r--drivers/media/video/gspca/w996Xcf.c16
-rw-r--r--drivers/media/video/gspca/zc3xx.c6
10 files changed, 18 insertions, 94 deletions
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index 19fe6b24c9a3..d6a75772f3f8 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -41,7 +41,7 @@ struct sd {
41#define QUALITY_MAX 60 41#define QUALITY_MAX 60
42#define QUALITY_DEF 40 42#define QUALITY_DEF 40
43 43
44 u8 *jpeg_hdr; 44 u8 jpeg_hdr[JPEG_HDR_SZ];
45}; 45};
46 46
47/* V4L2 controls supported by the driver */ 47/* V4L2 controls supported by the driver */
@@ -845,9 +845,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
845 struct sd *sd = (struct sd *) gspca_dev; 845 struct sd *sd = (struct sd *) gspca_dev;
846 846
847 /* create the JPEG header */ 847 /* create the JPEG header */
848 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
849 if (!sd->jpeg_hdr)
850 return -ENOMEM;
851 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 848 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
852 0x22); /* JPEG 411 */ 849 0x22); /* JPEG 411 */
853 jpeg_set_qual(sd->jpeg_hdr, sd->quality); 850 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
@@ -862,11 +859,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
862/* called on streamoff with alt 0 and on disconnect */ 859/* called on streamoff with alt 0 and on disconnect */
863static void sd_stop0(struct gspca_dev *gspca_dev) 860static void sd_stop0(struct gspca_dev *gspca_dev)
864{ 861{
865 struct sd *sd = (struct sd *) gspca_dev;
866 int retry = 50; 862 int retry = 50;
867 863
868 kfree(sd->jpeg_hdr);
869
870 if (!gspca_dev->present) 864 if (!gspca_dev->present)
871 return; 865 return;
872 reg_w_val(gspca_dev, 0x0000, 0x00); 866 reg_w_val(gspca_dev, 0x0000, 0x00);
diff --git a/drivers/media/video/gspca/jeilinj.c b/drivers/media/video/gspca/jeilinj.c
index 84ecd56c6470..12d9cf4caba2 100644
--- a/drivers/media/video/gspca/jeilinj.c
+++ b/drivers/media/video/gspca/jeilinj.c
@@ -50,7 +50,7 @@ struct sd {
50 struct workqueue_struct *work_thread; 50 struct workqueue_struct *work_thread;
51 u8 quality; /* image quality */ 51 u8 quality; /* image quality */
52 u8 jpegqual; /* webcam quality */ 52 u8 jpegqual; /* webcam quality */
53 u8 *jpeg_hdr; 53 u8 jpeg_hdr[JPEG_HDR_SZ];
54}; 54};
55 55
56 struct jlj_command { 56 struct jlj_command {
@@ -282,7 +282,6 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
282 destroy_workqueue(dev->work_thread); 282 destroy_workqueue(dev->work_thread);
283 dev->work_thread = NULL; 283 dev->work_thread = NULL;
284 mutex_lock(&gspca_dev->usb_lock); 284 mutex_lock(&gspca_dev->usb_lock);
285 kfree(dev->jpeg_hdr);
286} 285}
287 286
288/* this function is called at probe and resume time */ 287/* this function is called at probe and resume time */
@@ -298,9 +297,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
298 int ret; 297 int ret;
299 298
300 /* create the JPEG header */ 299 /* create the JPEG header */
301 dev->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
302 if (dev->jpeg_hdr == NULL)
303 return -ENOMEM;
304 jpeg_define(dev->jpeg_hdr, gspca_dev->height, gspca_dev->width, 300 jpeg_define(dev->jpeg_hdr, gspca_dev->height, gspca_dev->width,
305 0x21); /* JPEG 422 */ 301 0x21); /* JPEG 422 */
306 jpeg_set_qual(dev->jpeg_hdr, dev->quality); 302 jpeg_set_qual(dev->jpeg_hdr, dev->quality);
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c
index 3d9229e22b25..031f7195ce0d 100644
--- a/drivers/media/video/gspca/mars.c
+++ b/drivers/media/video/gspca/mars.c
@@ -41,7 +41,7 @@ struct sd {
41#define QUALITY_MAX 70 41#define QUALITY_MAX 70
42#define QUALITY_DEF 50 42#define QUALITY_DEF 50
43 43
44 u8 *jpeg_hdr; 44 u8 jpeg_hdr[JPEG_HDR_SZ];
45}; 45};
46 46
47/* V4L2 controls supported by the driver */ 47/* V4L2 controls supported by the driver */
@@ -200,9 +200,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
200 int i; 200 int i;
201 201
202 /* create the JPEG header */ 202 /* create the JPEG header */
203 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
204 if (!sd->jpeg_hdr)
205 return -ENOMEM;
206 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 203 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
207 0x21); /* JPEG 422 */ 204 0x21); /* JPEG 422 */
208 jpeg_set_qual(sd->jpeg_hdr, sd->quality); 205 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
@@ -317,13 +314,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
317 PDEBUG(D_ERR, "Camera Stop failed"); 314 PDEBUG(D_ERR, "Camera Stop failed");
318} 315}
319 316
320static void sd_stop0(struct gspca_dev *gspca_dev)
321{
322 struct sd *sd = (struct sd *) gspca_dev;
323
324 kfree(sd->jpeg_hdr);
325}
326
327static void sd_pkt_scan(struct gspca_dev *gspca_dev, 317static void sd_pkt_scan(struct gspca_dev *gspca_dev,
328 u8 *data, /* isoc packet */ 318 u8 *data, /* isoc packet */
329 int len) /* iso packet length */ 319 int len) /* iso packet length */
@@ -486,7 +476,6 @@ static const struct sd_desc sd_desc = {
486 .init = sd_init, 476 .init = sd_init,
487 .start = sd_start, 477 .start = sd_start,
488 .stopN = sd_stopN, 478 .stopN = sd_stopN,
489 .stop0 = sd_stop0,
490 .pkt_scan = sd_pkt_scan, 479 .pkt_scan = sd_pkt_scan,
491 .get_jcomp = sd_get_jcomp, 480 .get_jcomp = sd_get_jcomp,
492 .set_jcomp = sd_set_jcomp, 481 .set_jcomp = sd_set_jcomp,
diff --git a/drivers/media/video/gspca/ov519.c b/drivers/media/video/gspca/ov519.c
index 6eeeee25523c..2e7df66a84b9 100644
--- a/drivers/media/video/gspca/ov519.c
+++ b/drivers/media/video/gspca/ov519.c
@@ -41,6 +41,11 @@
41#include <linux/input.h> 41#include <linux/input.h>
42#include "gspca.h" 42#include "gspca.h"
43 43
44/* The jpeg_hdr is used by w996Xcf only */
45/* The CONEX_CAM define for jpeg.h needs renaming, now its used here too */
46#define CONEX_CAM
47#include "jpeg.h"
48
44MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); 49MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
45MODULE_DESCRIPTION("OV519 USB Camera Driver"); 50MODULE_DESCRIPTION("OV519 USB Camera Driver");
46MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
@@ -116,7 +121,7 @@ struct sd {
116 int sensor_height; 121 int sensor_height;
117 int sensor_reg_cache[256]; 122 int sensor_reg_cache[256];
118 123
119 u8 *jpeg_hdr; 124 u8 jpeg_hdr[JPEG_HDR_SZ];
120}; 125};
121 126
122/* Note this is a bit of a hack, but the w9968cf driver needs the code for all 127/* Note this is a bit of a hack, but the w9968cf driver needs the code for all
diff --git a/drivers/media/video/gspca/sn9c20x.c b/drivers/media/video/gspca/sn9c20x.c
index 644a7fd4701a..3f7e446d688a 100644
--- a/drivers/media/video/gspca/sn9c20x.c
+++ b/drivers/media/video/gspca/sn9c20x.c
@@ -89,7 +89,7 @@ struct sd {
89 u8 hstart; 89 u8 hstart;
90 u8 vstart; 90 u8 vstart;
91 91
92 u8 *jpeg_hdr; 92 u8 jpeg_hdr[JPEG_HDR_SZ];
93 u8 quality; 93 u8 quality;
94 94
95 u8 flags; 95 u8 flags;
@@ -2162,10 +2162,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
2162 int height = gspca_dev->height; 2162 int height = gspca_dev->height;
2163 u8 fmt, scale = 0; 2163 u8 fmt, scale = 0;
2164 2164
2165 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
2166 if (sd->jpeg_hdr == NULL)
2167 return -ENOMEM;
2168
2169 jpeg_define(sd->jpeg_hdr, height, width, 2165 jpeg_define(sd->jpeg_hdr, height, width,
2170 0x21); 2166 0x21);
2171 jpeg_set_qual(sd->jpeg_hdr, sd->quality); 2167 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
@@ -2197,8 +2193,8 @@ static int sd_start(struct gspca_dev *gspca_dev)
2197 } 2193 }
2198 2194
2199 configure_sensor_output(gspca_dev, mode); 2195 configure_sensor_output(gspca_dev, mode);
2200 reg_w(gspca_dev, 0x1100, sd->jpeg_hdr + JPEG_QT0_OFFSET, 64); 2196 reg_w(gspca_dev, 0x1100, &sd->jpeg_hdr[JPEG_QT0_OFFSET], 64);
2201 reg_w(gspca_dev, 0x1140, sd->jpeg_hdr + JPEG_QT1_OFFSET, 64); 2197 reg_w(gspca_dev, 0x1140, &sd->jpeg_hdr[JPEG_QT1_OFFSET], 64);
2202 reg_w(gspca_dev, 0x10fb, CLR_WIN(width, height), 5); 2198 reg_w(gspca_dev, 0x10fb, CLR_WIN(width, height), 5);
2203 reg_w(gspca_dev, 0x1180, HW_WIN(mode, sd->hstart, sd->vstart), 6); 2199 reg_w(gspca_dev, 0x1180, HW_WIN(mode, sd->hstart, sd->vstart), 6);
2204 reg_w1(gspca_dev, 0x1189, scale); 2200 reg_w1(gspca_dev, 0x1189, scale);
@@ -2226,12 +2222,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
2226 reg_w1(gspca_dev, 0x1061, gspca_dev->usb_buf[0] & ~0x02); 2222 reg_w1(gspca_dev, 0x1061, gspca_dev->usb_buf[0] & ~0x02);
2227} 2223}
2228 2224
2229static void sd_stop0(struct gspca_dev *gspca_dev)
2230{
2231 struct sd *sd = (struct sd *) gspca_dev;
2232 kfree(sd->jpeg_hdr);
2233}
2234
2235static void do_autoexposure(struct gspca_dev *gspca_dev, u16 avg_lum) 2225static void do_autoexposure(struct gspca_dev *gspca_dev, u16 avg_lum)
2236{ 2226{
2237 struct sd *sd = (struct sd *) gspca_dev; 2227 struct sd *sd = (struct sd *) gspca_dev;
@@ -2397,7 +2387,6 @@ static const struct sd_desc sd_desc = {
2397 .init = sd_init, 2387 .init = sd_init,
2398 .start = sd_start, 2388 .start = sd_start,
2399 .stopN = sd_stopN, 2389 .stopN = sd_stopN,
2400 .stop0 = sd_stop0,
2401 .pkt_scan = sd_pkt_scan, 2390 .pkt_scan = sd_pkt_scan,
2402#ifdef CONFIG_INPUT 2391#ifdef CONFIG_INPUT
2403 .int_pkt_scan = sd_int_pkt_scan, 2392 .int_pkt_scan = sd_int_pkt_scan,
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c
index b866c73c97db..c02beb6c1e93 100644
--- a/drivers/media/video/gspca/spca500.c
+++ b/drivers/media/video/gspca/spca500.c
@@ -57,7 +57,7 @@ struct sd {
57#define PalmPixDC85 13 57#define PalmPixDC85 13
58#define ToptroIndus 14 58#define ToptroIndus 14
59 59
60 u8 *jpeg_hdr; 60 u8 jpeg_hdr[JPEG_HDR_SZ];
61}; 61};
62 62
63/* V4L2 controls supported by the driver */ 63/* V4L2 controls supported by the driver */
@@ -669,9 +669,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
669 __u8 xmult, ymult; 669 __u8 xmult, ymult;
670 670
671 /* create the JPEG header */ 671 /* create the JPEG header */
672 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
673 if (!sd->jpeg_hdr)
674 return -ENOMEM;
675 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 672 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
676 0x22); /* JPEG 411 */ 673 0x22); /* JPEG 411 */
677 jpeg_set_qual(sd->jpeg_hdr, sd->quality); 674 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
@@ -891,13 +888,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
891 gspca_dev->usb_buf[0]); 888 gspca_dev->usb_buf[0]);
892} 889}
893 890
894static void sd_stop0(struct gspca_dev *gspca_dev)
895{
896 struct sd *sd = (struct sd *) gspca_dev;
897
898 kfree(sd->jpeg_hdr);
899}
900
901static void sd_pkt_scan(struct gspca_dev *gspca_dev, 891static void sd_pkt_scan(struct gspca_dev *gspca_dev,
902 u8 *data, /* isoc packet */ 892 u8 *data, /* isoc packet */
903 int len) /* iso packet length */ 893 int len) /* iso packet length */
@@ -1055,7 +1045,6 @@ static const struct sd_desc sd_desc = {
1055 .init = sd_init, 1045 .init = sd_init,
1056 .start = sd_start, 1046 .start = sd_start,
1057 .stopN = sd_stopN, 1047 .stopN = sd_stopN,
1058 .stop0 = sd_stop0,
1059 .pkt_scan = sd_pkt_scan, 1048 .pkt_scan = sd_pkt_scan,
1060 .get_jcomp = sd_get_jcomp, 1049 .get_jcomp = sd_get_jcomp,
1061 .set_jcomp = sd_set_jcomp, 1050 .set_jcomp = sd_set_jcomp,
diff --git a/drivers/media/video/gspca/stk014.c b/drivers/media/video/gspca/stk014.c
index 0fb534210a2c..45f4bc6ffc4a 100644
--- a/drivers/media/video/gspca/stk014.c
+++ b/drivers/media/video/gspca/stk014.c
@@ -40,7 +40,7 @@ struct sd {
40#define QUALITY_MAX 95 40#define QUALITY_MAX 95
41#define QUALITY_DEF 80 41#define QUALITY_DEF 80
42 42
43 u8 *jpeg_hdr; 43 u8 jpeg_hdr[JPEG_HDR_SZ];
44}; 44};
45 45
46/* V4L2 controls supported by the driver */ 46/* V4L2 controls supported by the driver */
@@ -337,9 +337,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
337 int ret, value; 337 int ret, value;
338 338
339 /* create the JPEG header */ 339 /* create the JPEG header */
340 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
341 if (!sd->jpeg_hdr)
342 return -ENOMEM;
343 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 340 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
344 0x22); /* JPEG 411 */ 341 0x22); /* JPEG 411 */
345 jpeg_set_qual(sd->jpeg_hdr, sd->quality); 342 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
@@ -412,13 +409,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
412 PDEBUG(D_STREAM, "camera stopped"); 409 PDEBUG(D_STREAM, "camera stopped");
413} 410}
414 411
415static void sd_stop0(struct gspca_dev *gspca_dev)
416{
417 struct sd *sd = (struct sd *) gspca_dev;
418
419 kfree(sd->jpeg_hdr);
420}
421
422static void sd_pkt_scan(struct gspca_dev *gspca_dev, 412static void sd_pkt_scan(struct gspca_dev *gspca_dev,
423 u8 *data, /* isoc packet */ 413 u8 *data, /* isoc packet */
424 int len) /* iso packet length */ 414 int len) /* iso packet length */
@@ -578,7 +568,6 @@ static const struct sd_desc sd_desc = {
578 .init = sd_init, 568 .init = sd_init,
579 .start = sd_start, 569 .start = sd_start,
580 .stopN = sd_stopN, 570 .stopN = sd_stopN,
581 .stop0 = sd_stop0,
582 .pkt_scan = sd_pkt_scan, 571 .pkt_scan = sd_pkt_scan,
583 .querymenu = sd_querymenu, 572 .querymenu = sd_querymenu,
584 .get_jcomp = sd_get_jcomp, 573 .get_jcomp = sd_get_jcomp,
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index 0c786e00ebcf..21d82bab0c2e 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -54,7 +54,7 @@ struct sd {
54#define MegapixV4 4 54#define MegapixV4 4
55#define MegaImageVI 5 55#define MegaImageVI 5
56 56
57 u8 *jpeg_hdr; 57 u8 jpeg_hdr[JPEG_HDR_SZ];
58}; 58};
59 59
60/* V4L2 controls supported by the driver */ 60/* V4L2 controls supported by the driver */
@@ -842,9 +842,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
842 int enable; 842 int enable;
843 843
844 /* create the JPEG header */ 844 /* create the JPEG header */
845 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
846 if (!sd->jpeg_hdr)
847 return -ENOMEM;
848 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 845 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
849 0x22); /* JPEG 411 */ 846 0x22); /* JPEG 411 */
850 jpeg_set_qual(sd->jpeg_hdr, sd->quality); 847 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
@@ -954,13 +951,6 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
954 } 951 }
955} 952}
956 953
957static void sd_stop0(struct gspca_dev *gspca_dev)
958{
959 struct sd *sd = (struct sd *) gspca_dev;
960
961 kfree(sd->jpeg_hdr);
962}
963
964static void sd_pkt_scan(struct gspca_dev *gspca_dev, 954static void sd_pkt_scan(struct gspca_dev *gspca_dev,
965 u8 *data, /* isoc packet */ 955 u8 *data, /* isoc packet */
966 int len) /* iso packet length */ 956 int len) /* iso packet length */
@@ -1162,7 +1152,6 @@ static const struct sd_desc sd_desc = {
1162 .init = sd_init, 1152 .init = sd_init,
1163 .start = sd_start, 1153 .start = sd_start,
1164 .stopN = sd_stopN, 1154 .stopN = sd_stopN,
1165 .stop0 = sd_stop0,
1166 .pkt_scan = sd_pkt_scan, 1155 .pkt_scan = sd_pkt_scan,
1167 .get_jcomp = sd_get_jcomp, 1156 .get_jcomp = sd_get_jcomp,
1168 .set_jcomp = sd_set_jcomp, 1157 .set_jcomp = sd_set_jcomp,
diff --git a/drivers/media/video/gspca/w996Xcf.c b/drivers/media/video/gspca/w996Xcf.c
index 2fffe203bed8..38a68591ce48 100644
--- a/drivers/media/video/gspca/w996Xcf.c
+++ b/drivers/media/video/gspca/w996Xcf.c
@@ -31,14 +31,10 @@
31 the sensor drivers to v4l2 sub drivers, and properly split of this 31 the sensor drivers to v4l2 sub drivers, and properly split of this
32 driver from ov519.c */ 32 driver from ov519.c */
33 33
34/* The CONEX_CAM define for jpeg.h needs renaming, now its used here too */
35#define CONEX_CAM
36#include "jpeg.h"
37
38#define W9968CF_I2C_BUS_DELAY 4 /* delay in us for I2C bit r/w operations */ 34#define W9968CF_I2C_BUS_DELAY 4 /* delay in us for I2C bit r/w operations */
39 35
40#define Y_QUANTABLE (sd->jpeg_hdr + JPEG_QT0_OFFSET) 36#define Y_QUANTABLE (&sd->jpeg_hdr[JPEG_QT0_OFFSET])
41#define UV_QUANTABLE (sd->jpeg_hdr + JPEG_QT1_OFFSET) 37#define UV_QUANTABLE (&sd->jpeg_hdr[JPEG_QT1_OFFSET])
42 38
43static const struct v4l2_pix_format w9968cf_vga_mode[] = { 39static const struct v4l2_pix_format w9968cf_vga_mode[] = {
44 {160, 120, V4L2_PIX_FMT_UYVY, V4L2_FIELD_NONE, 40 {160, 120, V4L2_PIX_FMT_UYVY, V4L2_FIELD_NONE,
@@ -509,11 +505,6 @@ static int w9968cf_mode_init_regs(struct sd *sd)
509 if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat == 505 if (w9968cf_vga_mode[sd->gspca_dev.curr_mode].pixelformat ==
510 V4L2_PIX_FMT_JPEG) { 506 V4L2_PIX_FMT_JPEG) {
511 /* We may get called multiple times (usb isoc bw negotiat.) */ 507 /* We may get called multiple times (usb isoc bw negotiat.) */
512 if (!sd->jpeg_hdr)
513 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
514 if (!sd->jpeg_hdr)
515 return -ENOMEM;
516
517 jpeg_define(sd->jpeg_hdr, sd->gspca_dev.height, 508 jpeg_define(sd->jpeg_hdr, sd->gspca_dev.height,
518 sd->gspca_dev.width, 0x22); /* JPEG 420 */ 509 sd->gspca_dev.width, 0x22); /* JPEG 420 */
519 jpeg_set_qual(sd->jpeg_hdr, sd->quality); 510 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
@@ -562,9 +553,6 @@ static void w9968cf_stop0(struct sd *sd)
562 reg_w(sd, 0x39, 0x0000); /* disable JPEG encoder */ 553 reg_w(sd, 0x39, 0x0000); /* disable JPEG encoder */
563 reg_w(sd, 0x16, 0x0000); /* stop video capture */ 554 reg_w(sd, 0x16, 0x0000); /* stop video capture */
564 } 555 }
565
566 kfree(sd->jpeg_hdr);
567 sd->jpeg_hdr = NULL;
568} 556}
569 557
570/* The w9968cf docs say that a 0 sized packet means EOF (and also SOF 558/* The w9968cf docs say that a 0 sized packet means EOF (and also SOF
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index d02aa5c8472a..0a043719f765 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -75,7 +75,7 @@ struct sd {
75#define SENSOR_MAX 19 75#define SENSOR_MAX 19
76 unsigned short chip_revision; 76 unsigned short chip_revision;
77 77
78 u8 *jpeg_hdr; 78 u8 jpeg_hdr[JPEG_HDR_SZ];
79}; 79};
80 80
81/* V4L2 controls supported by the driver */ 81/* V4L2 controls supported by the driver */
@@ -6798,9 +6798,6 @@ static int sd_start(struct gspca_dev *gspca_dev)
6798 }; 6798 };
6799 6799
6800 /* create the JPEG header */ 6800 /* create the JPEG header */
6801 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
6802 if (!sd->jpeg_hdr)
6803 return -ENOMEM;
6804 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, 6801 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
6805 0x21); /* JPEG 422 */ 6802 0x21); /* JPEG 422 */
6806 jpeg_set_qual(sd->jpeg_hdr, sd->quality); 6803 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
@@ -6931,7 +6928,6 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
6931{ 6928{
6932 struct sd *sd = (struct sd *) gspca_dev; 6929 struct sd *sd = (struct sd *) gspca_dev;
6933 6930
6934 kfree(sd->jpeg_hdr);
6935 if (!gspca_dev->present) 6931 if (!gspca_dev->present)
6936 return; 6932 return;
6937 send_unknown(gspca_dev->dev, sd->sensor); 6933 send_unknown(gspca_dev->dev, sd->sensor);