aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/video4linux/CARDLIST.bttv1
-rw-r--r--drivers/media/video/gspca/conex.c21
-rw-r--r--drivers/media/video/gspca/jpeg.h250
-rw-r--r--drivers/media/video/gspca/mars.c23
-rw-r--r--drivers/media/video/gspca/sonixj.c94
-rw-r--r--drivers/media/video/gspca/spca500.c22
-rw-r--r--drivers/media/video/gspca/stk014.c25
-rw-r--r--drivers/media/video/gspca/sunplus.c22
-rw-r--r--drivers/media/video/gspca/zc3xx.c18
9 files changed, 226 insertions, 250 deletions
diff --git a/Documentation/video4linux/CARDLIST.bttv b/Documentation/video4linux/CARDLIST.bttv
index e17750473e08..f11c583295e9 100644
--- a/Documentation/video4linux/CARDLIST.bttv
+++ b/Documentation/video4linux/CARDLIST.bttv
@@ -157,3 +157,4 @@
157156 -> IVCE-8784 [0000:f050,0001:f050,0002:f050,0003:f050] 157156 -> IVCE-8784 [0000:f050,0001:f050,0002:f050,0003:f050]
158157 -> Geovision GV-800(S) (master) [800a:763d] 158157 -> Geovision GV-800(S) (master) [800a:763d]
159158 -> Geovision GV-800(S) (slave) [800b:763d,800c:763d,800d:763d] 159158 -> Geovision GV-800(S) (slave) [800b:763d,800c:763d,800d:763d]
160159 -> ProVideo PV183 [1830:1540,1831:1540,1832:1540,1833:1540,1834:1540,1835:1540,1836:1540,1837:1540]
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c
index de2e608bf5ba..fd4df402bc2f 100644
--- a/drivers/media/video/gspca/conex.c
+++ b/drivers/media/video/gspca/conex.c
@@ -23,7 +23,6 @@
23 23
24#include "gspca.h" 24#include "gspca.h"
25#define CONEX_CAM 1 /* special JPEG header */ 25#define CONEX_CAM 1 /* special JPEG header */
26#define QUANT_VAL 0 /* quantization table */
27#include "jpeg.h" 26#include "jpeg.h"
28 27
29MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
@@ -37,6 +36,9 @@ struct sd {
37 unsigned char brightness; 36 unsigned char brightness;
38 unsigned char contrast; 37 unsigned char contrast;
39 unsigned char colors; 38 unsigned char colors;
39 u8 quality;
40
41 u8 *jpeg_hdr;
40}; 42};
41 43
42/* V4L2 controls supported by the driver */ 44/* V4L2 controls supported by the driver */
@@ -820,6 +822,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
820 sd->brightness = BRIGHTNESS_DEF; 822 sd->brightness = BRIGHTNESS_DEF;
821 sd->contrast = CONTRAST_DEF; 823 sd->contrast = CONTRAST_DEF;
822 sd->colors = COLOR_DEF; 824 sd->colors = COLOR_DEF;
825 sd->quality = 40;
823 return 0; 826 return 0;
824} 827}
825 828
@@ -836,6 +839,14 @@ static int sd_init(struct gspca_dev *gspca_dev)
836 839
837static int sd_start(struct gspca_dev *gspca_dev) 840static int sd_start(struct gspca_dev *gspca_dev)
838{ 841{
842 struct sd *sd = (struct sd *) gspca_dev;
843
844 /* create the JPEG header */
845 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
846 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
847 0x22); /* JPEG 411 */
848 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
849
839 cx11646_initsize(gspca_dev); 850 cx11646_initsize(gspca_dev);
840 cx11646_fw(gspca_dev); 851 cx11646_fw(gspca_dev);
841 cx_sensor(gspca_dev); 852 cx_sensor(gspca_dev);
@@ -846,8 +857,11 @@ static int sd_start(struct gspca_dev *gspca_dev)
846/* called on streamoff with alt 0 and on disconnect */ 857/* called on streamoff with alt 0 and on disconnect */
847static void sd_stop0(struct gspca_dev *gspca_dev) 858static void sd_stop0(struct gspca_dev *gspca_dev)
848{ 859{
860 struct sd *sd = (struct sd *) gspca_dev;
849 int retry = 50; 861 int retry = 50;
850 862
863 kfree(sd->jpeg_hdr);
864
851 if (!gspca_dev->present) 865 if (!gspca_dev->present)
852 return; 866 return;
853 reg_w_val(gspca_dev, 0x0000, 0x00); 867 reg_w_val(gspca_dev, 0x0000, 0x00);
@@ -873,6 +887,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
873 __u8 *data, /* isoc packet */ 887 __u8 *data, /* isoc packet */
874 int len) /* iso packet length */ 888 int len) /* iso packet length */
875{ 889{
890 struct sd *sd = (struct sd *) gspca_dev;
891
876 if (data[0] == 0xff && data[1] == 0xd8) { 892 if (data[0] == 0xff && data[1] == 0xd8) {
877 893
878 /* start of frame */ 894 /* start of frame */
@@ -880,7 +896,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
880 data, 0); 896 data, 0);
881 897
882 /* put the JPEG header in the new frame */ 898 /* put the JPEG header in the new frame */
883 jpeg_put_header(gspca_dev, frame, 0x22); 899 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
900 sd->jpeg_hdr, JPEG_HDR_SZ);
884 data += 2; 901 data += 2;
885 len -= 2; 902 len -= 2;
886 } 903 }
diff --git a/drivers/media/video/gspca/jpeg.h b/drivers/media/video/gspca/jpeg.h
index 7d2df9720025..de63c36806c0 100644
--- a/drivers/media/video/gspca/jpeg.h
+++ b/drivers/media/video/gspca/jpeg.h
@@ -27,42 +27,16 @@
27/* 27/*
28 * generation options 28 * generation options
29 * CONEX_CAM Conexant if present 29 * CONEX_CAM Conexant if present
30 * QUANT_VAL quantization table (0..8)
31 */ 30 */
32 31
33/* 32/* JPEG header */
34 * JPEG header:
35 * - start of jpeg frame
36 * - quantization table
37 * - huffman table
38 * - start of SOF0
39 */
40static const u8 jpeg_head[] = { 33static const u8 jpeg_head[] = {
41 0xff, 0xd8, /* jpeg */ 34 0xff, 0xd8, /* jpeg */
35
36/* quantization table quality 50% */
42 0xff, 0xdb, 0x00, 0x84, /* DQT */ 37 0xff, 0xdb, 0x00, 0x84, /* DQT */
43#if QUANT_VAL == 0
44/* index 0 - Q40*/
450, /* quantization table part 1 */
46 0x14, 0x0e, 0x0f, 0x12, 0x0f, 0x0d, 0x14, 0x12,
47 0x10, 0x12, 0x17, 0x15, 0x14, 0x18, 0x1e, 0x32,
48 0x21, 0x1e, 0x1c, 0x1c, 0x1e, 0x3d, 0x2c, 0x2e,
49 0x24, 0x32, 0x49, 0x40, 0x4c, 0x4b, 0x47, 0x40,
50 0x46, 0x45, 0x50, 0x5a, 0x73, 0x62, 0x50, 0x55,
51 0x6d, 0x56, 0x45, 0x46, 0x64, 0x88, 0x65, 0x6d,
52 0x77, 0x7b, 0x81, 0x82, 0x81, 0x4e, 0x60, 0x8d,
53 0x97, 0x8c, 0x7d, 0x96, 0x73, 0x7e, 0x81, 0x7c,
541, /* quantization table part 2 */
55 0x15, 0x17, 0x17, 0x1e, 0x1a, 0x1e, 0x3b, 0x21,
56 0x21, 0x3b, 0x7c, 0x53, 0x46, 0x53, 0x7c, 0x0c,
57 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c,
58 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c,
59 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c,
60 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c,
61 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c,
62 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c, 0x7c,
63#elif QUANT_VAL == 1
64/* index 1 - Q50 */
650, 380,
39#define JPEG_QT0_OFFSET 7
66 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e, 40 0x10, 0x0b, 0x0c, 0x0e, 0x0c, 0x0a, 0x10, 0x0e,
67 0x0d, 0x0e, 0x12, 0x11, 0x10, 0x13, 0x18, 0x28, 41 0x0d, 0x0e, 0x12, 0x11, 0x10, 0x13, 0x18, 0x28,
68 0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23, 0x25, 42 0x1a, 0x18, 0x16, 0x16, 0x18, 0x31, 0x23, 0x25,
@@ -72,6 +46,7 @@ static const u8 jpeg_head[] = {
72 0x5f, 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71, 46 0x5f, 0x62, 0x67, 0x68, 0x67, 0x3e, 0x4d, 0x71,
73 0x79, 0x70, 0x64, 0x78, 0x5c, 0x65, 0x67, 0x63, 47 0x79, 0x70, 0x64, 0x78, 0x5c, 0x65, 0x67, 0x63,
741, 481,
49#define JPEG_QT1_OFFSET 72
75 0x11, 0x12, 0x12, 0x18, 0x15, 0x18, 0x2f, 0x1a, 50 0x11, 0x12, 0x12, 0x18, 0x15, 0x18, 0x2f, 0x1a,
76 0x1a, 0x2f, 0x63, 0x42, 0x38, 0x42, 0x63, 0x63, 51 0x1a, 0x2f, 0x63, 0x42, 0x38, 0x42, 0x63, 0x63,
77 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 52 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
@@ -80,149 +55,6 @@ static const u8 jpeg_head[] = {
80 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 55 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
81 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 56 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
82 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 57 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63,
83#elif QUANT_VAL == 2
84/* index 2 Q60 */
850,
86 0x0d, 0x09, 0x0a, 0x0b, 0x0a, 0x08, 0x0d, 0x0b,
87 0x0a, 0x0b, 0x0e, 0x0e, 0x0d, 0x0f, 0x13, 0x20,
88 0x15, 0x13, 0x12, 0x12, 0x13, 0x27, 0x1c, 0x1e,
89 0x17, 0x20, 0x2e, 0x29, 0x31, 0x30, 0x2e, 0x29,
90 0x2d, 0x2c, 0x33, 0x3a, 0x4a, 0x3e, 0x33, 0x36,
91 0x46, 0x37, 0x2c, 0x2d, 0x40, 0x57, 0x41, 0x46,
92 0x4c, 0x4e, 0x52, 0x53, 0x52, 0x32, 0x3e, 0x5a,
93 0x61, 0x5a, 0x50, 0x60, 0x4a, 0x51, 0x52, 0x4f,
941,
95 0x0e, 0x0e, 0x0e, 0x13, 0x11, 0x13, 0x26, 0x15,
96 0x15, 0x26, 0x4f, 0x35, 0x2d, 0x35, 0x4f, 0x4f,
97 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f,
98 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f,
99 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f,
100 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f,
101 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f,
102 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f, 0x4f,
103#elif QUANT_VAL == 3
104/* index 3 - Q70 */
1050,
106 0x0a, 0x07, 0x07, 0x08, 0x07, 0x06, 0x0a, 0x08,
107 0x08, 0x08, 0x0b, 0x0a, 0x0a, 0x0b, 0x0e, 0x18,
108 0x10, 0x0e, 0x0d, 0x0d, 0x0e, 0x1d, 0x15, 0x16,
109 0x11, 0x18, 0x23, 0x1f, 0x25, 0x24, 0x22, 0x1f,
110 0x22, 0x21, 0x26, 0x2b, 0x37, 0x2f, 0x26, 0x29,
111 0x34, 0x29, 0x21, 0x22, 0x30, 0x41, 0x31, 0x34,
112 0x39, 0x3b, 0x3e, 0x3e, 0x3e, 0x25, 0x2e, 0x44,
113 0x49, 0x43, 0x3c, 0x48, 0x37, 0x3d, 0x3e, 0x3b,
1141,
115 0x0a, 0x0b, 0x0b, 0x0e, 0x0d, 0x0e, 0x1c, 0x10,
116 0x10, 0x1c, 0x3b, 0x28, 0x22, 0x28, 0x3b, 0x3b,
117 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
118 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
119 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
120 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
121 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
122 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
123#elif QUANT_VAL == 4
124/* index 4 - Q80 */
1250,
126 0x06, 0x04, 0x05, 0x06, 0x05, 0x04, 0x06, 0x06,
127 0x05, 0x06, 0x07, 0x07, 0x06, 0x08, 0x0a, 0x10,
128 0x0a, 0x0a, 0x09, 0x09, 0x0a, 0x14, 0x0e, 0x0f,
129 0x0c, 0x10, 0x17, 0x14, 0x18, 0x18, 0x17, 0x14,
130 0x16, 0x16, 0x1a, 0x1d, 0x25, 0x1f, 0x1a, 0x1b,
131 0x23, 0x1c, 0x16, 0x16, 0x20, 0x2c, 0x20, 0x23,
132 0x26, 0x27, 0x29, 0x2a, 0x29, 0x19, 0x1f, 0x2d,
133 0x30, 0x2d, 0x28, 0x30, 0x25, 0x28, 0x29, 0x28,
1341,
135 0x07, 0x07, 0x07, 0x0a, 0x08, 0x0a, 0x13, 0x0a,
136 0x0a, 0x13, 0x28, 0x1a, 0x16, 0x1a, 0x28, 0x28,
137 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
138 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
139 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
140 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
141 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
142 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28,
143#elif QUANT_VAL == 5
144/* index 5 - Q85 */
1450,
146 0x05, 0x03, 0x04, 0x04, 0x04, 0x03, 0x05, 0x04,
147 0x04, 0x04, 0x05, 0x05, 0x05, 0x06, 0x07, 0x0c,
148 0x08, 0x07, 0x07, 0x07, 0x07, 0x0f, 0x0b, 0x0b,
149 0x09, 0x0c, 0x11, 0x0f, 0x12, 0x12, 0x11, 0x0f,
150 0x11, 0x11, 0x13, 0x16, 0x1c, 0x17, 0x13, 0x14,
151 0x1a, 0x15, 0x11, 0x11, 0x18, 0x21, 0x18, 0x1a,
152 0x1d, 0x1d, 0x1f, 0x1f, 0x1f, 0x13, 0x17, 0x22,
153 0x24, 0x22, 0x1e, 0x24, 0x1c, 0x1e, 0x1f, 0x1e,
1541,
155 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x0e, 0x08,
156 0x08, 0x0e, 0x1e, 0x14, 0x11, 0x14, 0x1e, 0x1e,
157 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
158 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
159 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
160 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
161 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
162 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e, 0x1e,
163#elif QUANT_VAL == 6
164/* index 6 - 86 */
1650,
166 0x04, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x04,
167 0x04, 0x04, 0x05, 0x05, 0x04, 0x05, 0x07, 0x0B,
168 0x07, 0x07, 0x06, 0x06, 0x07, 0x0e, 0x0a, 0x0a,
169 0x08, 0x0B, 0x10, 0x0e, 0x11, 0x11, 0x10, 0x0e,
170 0x10, 0x0f, 0x12, 0x14, 0x1a, 0x16, 0x12, 0x13,
171 0x18, 0x13, 0x0f, 0x10, 0x16, 0x1f, 0x17, 0x18,
172 0x1b, 0x1b, 0x1d, 0x1d, 0x1d, 0x11, 0x16, 0x20,
173 0x22, 0x1f, 0x1c, 0x22, 0x1a, 0x1c, 0x1d, 0x1c,
1741,
175 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x0D, 0x07,
176 0x07, 0x0D, 0x1c, 0x12, 0x10, 0x12, 0x1c, 0x1c,
177 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
178 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
179 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
180 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
181 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
182 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c, 0x1c,
183#elif QUANT_VAL == 7
184/* index 7 - 88 */
1850,
186 0x04, 0x03, 0x03, 0x03, 0x03, 0x02, 0x04, 0x03,
187 0x03, 0x03, 0x04, 0x04, 0x04, 0x05, 0x06, 0x0a,
188 0x06, 0x06, 0x05, 0x05, 0x06, 0x0C, 0x08, 0x09,
189 0x07, 0x0a, 0x0e, 0x0c, 0x0f, 0x0e, 0x0e, 0x0c,
190 0x0d, 0x0d, 0x0f, 0x11, 0x16, 0x13, 0x0f, 0x10,
191 0x15, 0x11, 0x0d, 0x0d, 0x13, 0x1a, 0x13, 0x15,
192 0x17, 0x18, 0x19, 0x19, 0x19, 0x0f, 0x12, 0x1b,
193 0x1d, 0x1b, 0x18, 0x1d, 0x16, 0x18, 0x19, 0x18,
1941,
195 0x04, 0x04, 0x04, 0x06, 0x05, 0x06, 0x0B, 0x06,
196 0x06, 0x0B, 0x18, 0x10, 0x0d, 0x10, 0x18, 0x18,
197 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
198 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
199 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
200 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
201 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
202 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
203#elif QUANT_VAL == 8
204/* index 8 - ?? */
2050,
206 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
207 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x03, 0x05,
208 0x03, 0x03, 0x03, 0x03, 0x03, 0x06, 0x04, 0x05,
209 0x04, 0x05, 0x07, 0x06, 0x08, 0x08, 0x07, 0x06,
210 0x07, 0x07, 0x08, 0x09, 0x0c, 0x0a, 0x08, 0x09,
211 0x0B, 0x09, 0x07, 0x07, 0x0a, 0x0e, 0x0a, 0x0b,
212 0x0c, 0x0c, 0x0d, 0x0d, 0x0d, 0x08, 0x0a, 0x0e,
213 0x0f, 0x0e, 0x0d, 0x0f, 0x0c, 0x0d, 0x0d, 0x0c,
2141,
215 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x06, 0x03,
216 0x03, 0x06, 0x0c, 0x08, 0x07, 0x08, 0x0c, 0x0c,
217 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
218 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
219 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
220 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
221 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
222 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
223#else
224#error "Invalid quantization table"
225#endif
226 58
227/* huffman table */ 59/* huffman table */
228 0xff, 0xc4, 0x01, 0xa2, 60 0xff, 0xc4, 0x01, 0xa2,
@@ -280,55 +112,57 @@ static const u8 jpeg_head[] = {
280 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 112 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa,
281#ifdef CONEX_CAM 113#ifdef CONEX_CAM
282/* the Conexant frames start with SOF0 */ 114/* the Conexant frames start with SOF0 */
115#define JPEG_HDR_SZ 556
283#else 116#else
284 0xff, 0xc0, 0x00, 0x11, /* SOF0 (start of frame 0 */ 117 0xff, 0xc0, 0x00, 0x11, /* SOF0 (start of frame 0 */
285 0x08, /* data precision */ 118 0x08, /* data precision */
286#endif 119#define JPEG_HEIGHT_OFFSET 561
287}; 120 0x01, 0xe0, /* height */
288 121 0x02, 0x80, /* width */
289#ifndef CONEX_CAM 122 0x03, /* component number */
290/* variable part: 123 0x01,
291 * 0x01, 0xe0, height 124 0x21, /* samples Y */
292 * 0x02, 0x80, width
293 * 0x03, component number
294 * 0x01,
295 * 0x21, samples Y
296 */
297
298/* end of header */
299static u8 eoh[] = {
300 0x00, /* quant Y */ 125 0x00, /* quant Y */
301 0x02, 0x11, 0x01, /* samples CbCr - quant CbCr */ 126 0x02, 0x11, 0x01, /* samples CbCr - quant CbCr */
302 0x03, 0x11, 0x01, 127 0x03, 0x11, 0x01,
303 128
304 0xff, 0xda, 0x00, 0x0c, /* SOS (start of scan) */ 129 0xff, 0xda, 0x00, 0x0c, /* SOS (start of scan) */
305 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00 130 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00
306}; 131#define JPEG_HDR_SZ 589
307#endif 132#endif
133};
308 134
309/* -- output the JPEG header -- */ 135/* define the JPEG header */
310static void jpeg_put_header(struct gspca_dev *gspca_dev, 136static void jpeg_define(u8 *jpeg_hdr,
311 struct gspca_frame *frame, 137 int height,
312 int samplesY) 138 int width,
139 int samplesY)
313{ 140{
141 memcpy(jpeg_hdr, jpeg_head, sizeof jpeg_head);
314#ifndef CONEX_CAM 142#ifndef CONEX_CAM
315 u8 tmpbuf[8]; 143 jpeg_hdr[JPEG_HEIGHT_OFFSET + 0] = height >> 8;
144 jpeg_hdr[JPEG_HEIGHT_OFFSET + 1] = height & 0xff;
145 jpeg_hdr[JPEG_HEIGHT_OFFSET + 2] = width >> 8;
146 jpeg_hdr[JPEG_HEIGHT_OFFSET + 3] = width & 0xff;
147 jpeg_hdr[JPEG_HEIGHT_OFFSET + 6] = samplesY;
316#endif 148#endif
149}
317 150
318 gspca_frame_add(gspca_dev, FIRST_PACKET, frame, 151/* set the JPEG quality */
319 jpeg_head, sizeof jpeg_head); 152static void jpeg_set_qual(u8 *jpeg_hdr,
320#ifndef CONEX_CAM 153 int quality)
321 tmpbuf[0] = gspca_dev->height >> 8; 154{
322 tmpbuf[1] = gspca_dev->height & 0xff; 155 int i, sc;
323 tmpbuf[2] = gspca_dev->width >> 8; 156
324 tmpbuf[3] = gspca_dev->width & 0xff; 157 if (quality < 50)
325 tmpbuf[4] = 0x03; /* component number */ 158 sc = 5000 / quality;
326 tmpbuf[5] = 0x01; /* first component */ 159 else
327 tmpbuf[6] = samplesY; 160 sc = 200 - quality * 2;
328 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 161 for (i = 0; i < 64; i++) {
329 tmpbuf, 7); 162 jpeg_hdr[JPEG_QT0_OFFSET + i] =
330 gspca_frame_add(gspca_dev, INTER_PACKET, frame, 163 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
331 eoh, sizeof eoh); 164 jpeg_hdr[JPEG_QT1_OFFSET + i] =
332#endif 165 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
166 }
333} 167}
334#endif 168#endif
diff --git a/drivers/media/video/gspca/mars.c b/drivers/media/video/gspca/mars.c
index ce065d363e8a..6eb813e7b714 100644
--- a/drivers/media/video/gspca/mars.c
+++ b/drivers/media/video/gspca/mars.c
@@ -22,7 +22,6 @@
22#define MODULE_NAME "mars" 22#define MODULE_NAME "mars"
23 23
24#include "gspca.h" 24#include "gspca.h"
25#define QUANT_VAL 1 /* quantization table */
26#include "jpeg.h" 25#include "jpeg.h"
27 26
28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
@@ -37,6 +36,9 @@ struct sd {
37 u8 colors; 36 u8 colors;
38 u8 gamma; 37 u8 gamma;
39 u8 sharpness; 38 u8 sharpness;
39 u8 quality;
40
41 u8 *jpeg_hdr;
40}; 42};
41 43
42/* V4L2 controls supported by the driver */ 44/* V4L2 controls supported by the driver */
@@ -176,6 +178,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
176 sd->colors = COLOR_DEF; 178 sd->colors = COLOR_DEF;
177 sd->gamma = GAMMA_DEF; 179 sd->gamma = GAMMA_DEF;
178 sd->sharpness = SHARPNESS_DEF; 180 sd->sharpness = SHARPNESS_DEF;
181 sd->quality = 50;
179 gspca_dev->nbalt = 9; /* use the altsetting 08 */ 182 gspca_dev->nbalt = 9; /* use the altsetting 08 */
180 return 0; 183 return 0;
181} 184}
@@ -193,6 +196,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
193 u8 *data; 196 u8 *data;
194 int i; 197 int i;
195 198
199 /* create the JPEG header */
200 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
201 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
202 0x21); /* JPEG 422 */
203 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
204
196 data = gspca_dev->usb_buf; 205 data = gspca_dev->usb_buf;
197 206
198 data[0] = 0x01; /* address */ 207 data[0] = 0x01; /* address */
@@ -303,11 +312,19 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
303 PDEBUG(D_ERR, "Camera Stop failed"); 312 PDEBUG(D_ERR, "Camera Stop failed");
304} 313}
305 314
315static void sd_stop0(struct gspca_dev *gspca_dev)
316{
317 struct sd *sd = (struct sd *) gspca_dev;
318
319 kfree(sd->jpeg_hdr);
320}
321
306static void sd_pkt_scan(struct gspca_dev *gspca_dev, 322static void sd_pkt_scan(struct gspca_dev *gspca_dev,
307 struct gspca_frame *frame, /* target */ 323 struct gspca_frame *frame, /* target */
308 __u8 *data, /* isoc packet */ 324 __u8 *data, /* isoc packet */
309 int len) /* iso packet length */ 325 int len) /* iso packet length */
310{ 326{
327 struct sd *sd = (struct sd *) gspca_dev;
311 int p; 328 int p;
312 329
313 if (len < 6) { 330 if (len < 6) {
@@ -330,7 +347,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
330 frame, data, p); 347 frame, data, p);
331 348
332 /* put the JPEG header */ 349 /* put the JPEG header */
333 jpeg_put_header(gspca_dev, frame, 0x21); 350 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
351 sd->jpeg_hdr, JPEG_HDR_SZ);
334 data += p + 16; 352 data += p + 16;
335 len -= p + 16; 353 len -= p + 16;
336 break; 354 break;
@@ -436,6 +454,7 @@ static const struct sd_desc sd_desc = {
436 .init = sd_init, 454 .init = sd_init,
437 .start = sd_start, 455 .start = sd_start,
438 .stopN = sd_stopN, 456 .stopN = sd_stopN,
457 .stop0 = sd_stop0,
439 .pkt_scan = sd_pkt_scan, 458 .pkt_scan = sd_pkt_scan,
440}; 459};
441 460
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c
index edc26d8ad2ad..363c0fa39d9e 100644
--- a/drivers/media/video/gspca/sonixj.c
+++ b/drivers/media/video/gspca/sonixj.c
@@ -22,7 +22,6 @@
22#define MODULE_NAME "sonixj" 22#define MODULE_NAME "sonixj"
23 23
24#include "gspca.h" 24#include "gspca.h"
25#define QUANT_VAL 4 /* quantization table */
26#include "jpeg.h" 25#include "jpeg.h"
27 26
28#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0) 27#define V4L2_CID_INFRARED (V4L2_CID_PRIVATE_BASE + 0)
@@ -47,6 +46,10 @@ struct sd {
47 u8 gamma; 46 u8 gamma;
48 u8 vflip; /* ov7630/ov7648 only */ 47 u8 vflip; /* ov7630/ov7648 only */
49 u8 infrared; /* mt9v111 only */ 48 u8 infrared; /* mt9v111 only */
49 u8 quality; /* image quality */
50 u8 jpegqual; /* webcam quality */
51
52 u8 reg18;
50 53
51 s8 ag_cnt; 54 s8 ag_cnt;
52#define AG_CNT_START 13 55#define AG_CNT_START 13
@@ -68,6 +71,8 @@ struct sd {
68#define SENSOR_OV7660 7 71#define SENSOR_OV7660 7
69#define SENSOR_SP80708 8 72#define SENSOR_SP80708 8
70 u8 i2c_base; 73 u8 i2c_base;
74
75 u8 *jpeg_hdr;
71}; 76};
72 77
73/* V4L2 controls supported by the driver */ 78/* V4L2 controls supported by the driver */
@@ -859,25 +864,6 @@ static const u8 sp80708_sensor_init[][8] = {
859 {} 864 {}
860}; 865};
861 866
862static const u8 qtable4[] = {
863 0x06, 0x04, 0x04, 0x06, 0x04, 0x04, 0x06, 0x06,
864 0x06, 0x06, 0x08, 0x06, 0x06, 0x08, 0x0a, 0x11,
865 0x0a, 0x0a, 0x08, 0x08, 0x0a, 0x15, 0x0f, 0x0f,
866 0x0c, 0x11, 0x19, 0x15, 0x19, 0x19, 0x17, 0x15,
867 0x17, 0x17, 0x1b, 0x1d, 0x25, 0x21, 0x1b, 0x1d,
868 0x23, 0x1d, 0x17, 0x17, 0x21, 0x2e, 0x21, 0x23,
869 0x27, 0x29, 0x2c, 0x2c, 0x2c, 0x19, 0x1f, 0x30,
870 0x32, 0x2e, 0x29, 0x32, 0x25, 0x29, 0x2c, 0x29,
871 0x06, 0x08, 0x08, 0x0a, 0x08, 0x0a, 0x13, 0x0a,
872 0x0a, 0x13, 0x29, 0x1b, 0x17, 0x1b, 0x29, 0x29,
873 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
874 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
875 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
876 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
877 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29,
878 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29
879};
880
881/* read <len> bytes to gspca_dev->usb_buf */ 867/* read <len> bytes to gspca_dev->usb_buf */
882static void reg_r(struct gspca_dev *gspca_dev, 868static void reg_r(struct gspca_dev *gspca_dev,
883 u16 value, int len) 869 u16 value, int len)
@@ -1309,6 +1295,8 @@ static int sd_config(struct gspca_dev *gspca_dev,
1309 else 1295 else
1310 sd->vflip = 1; 1296 sd->vflip = 1;
1311 sd->infrared = INFRARED_DEF; 1297 sd->infrared = INFRARED_DEF;
1298 sd->quality = 80;
1299 sd->jpegqual = 80;
1312 1300
1313 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; 1301 gspca_dev->ctrl_dis = ctrl_dis[sd->sensor];
1314 return 0; 1302 return 0;
@@ -1610,12 +1598,49 @@ static void setinfrared(struct sd *sd)
1610 sd->infrared ? 0x66 : 0x64); 1598 sd->infrared ? 0x66 : 0x64);
1611} 1599}
1612 1600
1601static void setjpegqual(struct gspca_dev *gspca_dev)
1602{
1603 struct sd *sd = (struct sd *) gspca_dev;
1604 int i, sc;
1605
1606 if (sd->jpegqual < 50)
1607 sc = 5000 / sd->jpegqual;
1608 else
1609 sc = 200 - sd->jpegqual * 2;
1610#if USB_BUF_SZ < 64
1611#error "No room enough in usb_buf for quantization table"
1612#endif
1613 for (i = 0; i < 64; i++)
1614 gspca_dev->usb_buf[i] =
1615 (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100;
1616 usb_control_msg(gspca_dev->dev,
1617 usb_sndctrlpipe(gspca_dev->dev, 0),
1618 0x08,
1619 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1620 0x0100, 0,
1621 gspca_dev->usb_buf, 64,
1622 500);
1623 for (i = 0; i < 64; i++)
1624 gspca_dev->usb_buf[i] =
1625 (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100;
1626 usb_control_msg(gspca_dev->dev,
1627 usb_sndctrlpipe(gspca_dev->dev, 0),
1628 0x08,
1629 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
1630 0x0140, 0,
1631 gspca_dev->usb_buf, 64,
1632 500);
1633
1634 sd->reg18 ^= 0x40;
1635 reg_w1(gspca_dev, 0x18, sd->reg18);
1636}
1637
1613/* -- start the camera -- */ 1638/* -- start the camera -- */
1614static int sd_start(struct gspca_dev *gspca_dev) 1639static int sd_start(struct gspca_dev *gspca_dev)
1615{ 1640{
1616 struct sd *sd = (struct sd *) gspca_dev; 1641 struct sd *sd = (struct sd *) gspca_dev;
1617 int i; 1642 int i;
1618 u8 reg1, reg17, reg18; 1643 u8 reg1, reg17;
1619 const u8 *sn9c1xx; 1644 const u8 *sn9c1xx;
1620 int mode; 1645 int mode;
1621 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; 1646 static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f };
@@ -1624,6 +1649,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
1624 static const u8 CE_ov76xx[] = 1649 static const u8 CE_ov76xx[] =
1625 { 0x32, 0xdd, 0x32, 0xdd }; 1650 { 0x32, 0xdd, 0x32, 0xdd };
1626 1651
1652 /* create the JPEG header */
1653 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
1654 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
1655 0x21); /* JPEG 422 */
1656 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
1657
1627 sn9c1xx = sn_tb[(int) sd->sensor]; 1658 sn9c1xx = sn_tb[(int) sd->sensor];
1628 configure_gpio(gspca_dev, sn9c1xx); 1659 configure_gpio(gspca_dev, sn9c1xx);
1629 1660
@@ -1782,13 +1813,9 @@ static int sd_start(struct gspca_dev *gspca_dev)
1782 } 1813 }
1783 1814
1784 /* here change size mode 0 -> VGA; 1 -> CIF */ 1815 /* here change size mode 0 -> VGA; 1 -> CIF */
1785 reg18 = sn9c1xx[0x18] | (mode << 4); 1816 sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40;
1786 reg_w1(gspca_dev, 0x18, reg18 | 0x40); 1817 reg_w1(gspca_dev, 0x18, sd->reg18);
1787 1818 setjpegqual(gspca_dev);
1788 reg_w(gspca_dev, 0x0100, qtable4, 0x40);
1789 reg_w(gspca_dev, 0x0140, qtable4 + 0x40, 0x40);
1790
1791 reg_w1(gspca_dev, 0x18, reg18);
1792 1819
1793 reg_w1(gspca_dev, 0x17, reg17); 1820 reg_w1(gspca_dev, 0x17, reg17);
1794 reg_w1(gspca_dev, 0x01, reg1); 1821 reg_w1(gspca_dev, 0x01, reg1);
@@ -1845,6 +1872,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1845 reg_w1(gspca_dev, 0xf1, 0x00); 1872 reg_w1(gspca_dev, 0xf1, 0x00);
1846} 1873}
1847 1874
1875static void sd_stop0(struct gspca_dev *gspca_dev)
1876{
1877 struct sd *sd = (struct sd *) gspca_dev;
1878
1879 kfree(sd->jpeg_hdr);
1880}
1881
1848static void do_autogain(struct gspca_dev *gspca_dev) 1882static void do_autogain(struct gspca_dev *gspca_dev)
1849{ 1883{
1850 struct sd *sd = (struct sd *) gspca_dev; 1884 struct sd *sd = (struct sd *) gspca_dev;
@@ -1928,7 +1962,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1928 if (gspca_dev->last_packet_type == LAST_PACKET) { 1962 if (gspca_dev->last_packet_type == LAST_PACKET) {
1929 1963
1930 /* put the JPEG 422 header */ 1964 /* put the JPEG 422 header */
1931 jpeg_put_header(gspca_dev, frame, 0x21); 1965 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1966 sd->jpeg_hdr, JPEG_HDR_SZ);
1932 } 1967 }
1933 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); 1968 gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len);
1934} 1969}
@@ -2104,6 +2139,7 @@ static const struct sd_desc sd_desc = {
2104 .init = sd_init, 2139 .init = sd_init,
2105 .start = sd_start, 2140 .start = sd_start,
2106 .stopN = sd_stopN, 2141 .stopN = sd_stopN,
2142 .stop0 = sd_stop0,
2107 .pkt_scan = sd_pkt_scan, 2143 .pkt_scan = sd_pkt_scan,
2108 .dq_callback = do_autogain, 2144 .dq_callback = do_autogain,
2109}; 2145};
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c
index f44613095d2e..2176ac6850e3 100644
--- a/drivers/media/video/gspca/spca500.c
+++ b/drivers/media/video/gspca/spca500.c
@@ -22,7 +22,6 @@
22#define MODULE_NAME "spca500" 22#define MODULE_NAME "spca500"
23 23
24#include "gspca.h" 24#include "gspca.h"
25#define QUANT_VAL 5 /* quantization table */
26#include "jpeg.h" 25#include "jpeg.h"
27 26
28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
@@ -39,6 +38,7 @@ struct sd {
39 unsigned char brightness; 38 unsigned char brightness;
40 unsigned char contrast; 39 unsigned char contrast;
41 unsigned char colors; 40 unsigned char colors;
41 u8 quality;
42 42
43 char subtype; 43 char subtype;
44#define AgfaCl20 0 44#define AgfaCl20 0
@@ -56,6 +56,8 @@ struct sd {
56#define Optimedia 12 56#define Optimedia 12
57#define PalmPixDC85 13 57#define PalmPixDC85 13
58#define ToptroIndus 14 58#define ToptroIndus 14
59
60 u8 *jpeg_hdr;
59}; 61};
60 62
61/* V4L2 controls supported by the driver */ 63/* V4L2 controls supported by the driver */
@@ -640,6 +642,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
640 sd->brightness = BRIGHTNESS_DEF; 642 sd->brightness = BRIGHTNESS_DEF;
641 sd->contrast = CONTRAST_DEF; 643 sd->contrast = CONTRAST_DEF;
642 sd->colors = COLOR_DEF; 644 sd->colors = COLOR_DEF;
645 sd->quality = 85;
643 return 0; 646 return 0;
644} 647}
645 648
@@ -665,6 +668,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
665 __u8 Data; 668 __u8 Data;
666 __u8 xmult, ymult; 669 __u8 xmult, ymult;
667 670
671 /* create the JPEG header */
672 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
673 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
674 0x22); /* JPEG 411 */
675 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
676
668 if (sd->subtype == LogitechClickSmart310) { 677 if (sd->subtype == LogitechClickSmart310) {
669 xmult = 0x16; 678 xmult = 0x16;
670 ymult = 0x12; 679 ymult = 0x12;
@@ -880,6 +889,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
880 gspca_dev->usb_buf[0]); 889 gspca_dev->usb_buf[0]);
881} 890}
882 891
892static void sd_stop0(struct gspca_dev *gspca_dev)
893{
894 struct sd *sd = (struct sd *) gspca_dev;
895
896 kfree(sd->jpeg_hdr);
897}
898
883static void sd_pkt_scan(struct gspca_dev *gspca_dev, 899static void sd_pkt_scan(struct gspca_dev *gspca_dev,
884 struct gspca_frame *frame, /* target */ 900 struct gspca_frame *frame, /* target */
885 __u8 *data, /* isoc packet */ 901 __u8 *data, /* isoc packet */
@@ -900,7 +916,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
900 ffd9, 2); 916 ffd9, 2);
901 917
902 /* put the JPEG header in the new frame */ 918 /* put the JPEG header in the new frame */
903 jpeg_put_header(gspca_dev, frame, 0x22); 919 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
920 sd->jpeg_hdr, JPEG_HDR_SZ);
904 921
905 data += SPCA500_OFFSET_DATA; 922 data += SPCA500_OFFSET_DATA;
906 len -= SPCA500_OFFSET_DATA; 923 len -= SPCA500_OFFSET_DATA;
@@ -1013,6 +1030,7 @@ static struct sd_desc sd_desc = {
1013 .init = sd_init, 1030 .init = sd_init,
1014 .start = sd_start, 1031 .start = sd_start,
1015 .stopN = sd_stopN, 1032 .stopN = sd_stopN,
1033 .stop0 = sd_stop0,
1016 .pkt_scan = sd_pkt_scan, 1034 .pkt_scan = sd_pkt_scan,
1017}; 1035};
1018 1036
diff --git a/drivers/media/video/gspca/stk014.c b/drivers/media/video/gspca/stk014.c
index d1d54edd80bd..dd007cb52006 100644
--- a/drivers/media/video/gspca/stk014.c
+++ b/drivers/media/video/gspca/stk014.c
@@ -21,8 +21,6 @@
21#define MODULE_NAME "stk014" 21#define MODULE_NAME "stk014"
22 22
23#include "gspca.h" 23#include "gspca.h"
24#define QUANT_VAL 7 /* quantization table */
25 /* <= 4 KO - 7: good (enough!) */
26#include "jpeg.h" 24#include "jpeg.h"
27 25
28MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>"); 26MODULE_AUTHOR("Jean-Francois Moine <http://moinejf.free.fr>");
@@ -37,6 +35,9 @@ struct sd {
37 unsigned char contrast; 35 unsigned char contrast;
38 unsigned char colors; 36 unsigned char colors;
39 unsigned char lightfreq; 37 unsigned char lightfreq;
38 u8 quality;
39
40 u8 *jpeg_hdr;
40}; 41};
41 42
42/* V4L2 controls supported by the driver */ 43/* V4L2 controls supported by the driver */
@@ -300,6 +301,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
300 sd->contrast = CONTRAST_DEF; 301 sd->contrast = CONTRAST_DEF;
301 sd->colors = COLOR_DEF; 302 sd->colors = COLOR_DEF;
302 sd->lightfreq = FREQ_DEF; 303 sd->lightfreq = FREQ_DEF;
304 sd->quality = 80;
303 return 0; 305 return 0;
304} 306}
305 307
@@ -323,8 +325,15 @@ static int sd_init(struct gspca_dev *gspca_dev)
323/* -- start the camera -- */ 325/* -- start the camera -- */
324static int sd_start(struct gspca_dev *gspca_dev) 326static int sd_start(struct gspca_dev *gspca_dev)
325{ 327{
328 struct sd *sd = (struct sd *) gspca_dev;
326 int ret, value; 329 int ret, value;
327 330
331 /* create the JPEG header */
332 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
333 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
334 0x22); /* JPEG 411 */
335 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
336
328 /* work on alternate 1 */ 337 /* work on alternate 1 */
329 usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1); 338 usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1);
330 339
@@ -396,11 +405,19 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
396 PDEBUG(D_STREAM, "camera stopped"); 405 PDEBUG(D_STREAM, "camera stopped");
397} 406}
398 407
408static void sd_stop0(struct gspca_dev *gspca_dev)
409{
410 struct sd *sd = (struct sd *) gspca_dev;
411
412 kfree(sd->jpeg_hdr);
413}
414
399static void sd_pkt_scan(struct gspca_dev *gspca_dev, 415static void sd_pkt_scan(struct gspca_dev *gspca_dev,
400 struct gspca_frame *frame, /* target */ 416 struct gspca_frame *frame, /* target */
401 __u8 *data, /* isoc packet */ 417 __u8 *data, /* isoc packet */
402 int len) /* iso packet length */ 418 int len) /* iso packet length */
403{ 419{
420 struct sd *sd = (struct sd *) gspca_dev;
404 static unsigned char ffd9[] = {0xff, 0xd9}; 421 static unsigned char ffd9[] = {0xff, 0xd9};
405 422
406 /* a frame starts with: 423 /* a frame starts with:
@@ -417,7 +434,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
417 ffd9, 2); 434 ffd9, 2);
418 435
419 /* put the JPEG 411 header */ 436 /* put the JPEG 411 header */
420 jpeg_put_header(gspca_dev, frame, 0x22); 437 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
438 sd->jpeg_hdr, JPEG_HDR_SZ);
421 439
422 /* beginning of the frame */ 440 /* beginning of the frame */
423#define STKHDRSZ 12 441#define STKHDRSZ 12
@@ -526,6 +544,7 @@ static const struct sd_desc sd_desc = {
526 .init = sd_init, 544 .init = sd_init,
527 .start = sd_start, 545 .start = sd_start,
528 .stopN = sd_stopN, 546 .stopN = sd_stopN,
547 .stop0 = sd_stop0,
529 .pkt_scan = sd_pkt_scan, 548 .pkt_scan = sd_pkt_scan,
530 .querymenu = sd_querymenu, 549 .querymenu = sd_querymenu,
531}; 550};
diff --git a/drivers/media/video/gspca/sunplus.c b/drivers/media/video/gspca/sunplus.c
index 9d08a66fe23d..eadfaa9f97d2 100644
--- a/drivers/media/video/gspca/sunplus.c
+++ b/drivers/media/video/gspca/sunplus.c
@@ -22,7 +22,6 @@
22#define MODULE_NAME "sunplus" 22#define MODULE_NAME "sunplus"
23 23
24#include "gspca.h" 24#include "gspca.h"
25#define QUANT_VAL 5 /* quantization table */
26#include "jpeg.h" 25#include "jpeg.h"
27 26
28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); 27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>");
@@ -40,6 +39,7 @@ struct sd {
40 unsigned char contrast; 39 unsigned char contrast;
41 unsigned char colors; 40 unsigned char colors;
42 unsigned char autogain; 41 unsigned char autogain;
42 u8 quality;
43 43
44 char bridge; 44 char bridge;
45#define BRIDGE_SPCA504 0 45#define BRIDGE_SPCA504 0
@@ -52,6 +52,8 @@ struct sd {
52#define LogitechClickSmart420 2 52#define LogitechClickSmart420 2
53#define LogitechClickSmart820 3 53#define LogitechClickSmart820 3
54#define MegapixV4 4 54#define MegapixV4 4
55
56 u8 *jpeg_hdr;
55}; 57};
56 58
57/* V4L2 controls supported by the driver */ 59/* V4L2 controls supported by the driver */
@@ -852,6 +854,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
852 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; 854 sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value;
853 sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; 855 sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value;
854 sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; 856 sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value;
857 sd->quality = 85;
855 return 0; 858 return 0;
856} 859}
857 860
@@ -968,6 +971,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
968 __u8 i; 971 __u8 i;
969 __u8 info[6]; 972 __u8 info[6];
970 973
974 /* create the JPEG header */
975 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
976 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
977 0x22); /* JPEG 411 */
978 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
979
971 if (sd->bridge == BRIDGE_SPCA504B) 980 if (sd->bridge == BRIDGE_SPCA504B)
972 spca504B_setQtable(gspca_dev); 981 spca504B_setQtable(gspca_dev);
973 spca504B_SetSizeType(gspca_dev); 982 spca504B_SetSizeType(gspca_dev);
@@ -1077,6 +1086,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev)
1077 } 1086 }
1078} 1087}
1079 1088
1089static void sd_stop0(struct gspca_dev *gspca_dev)
1090{
1091 struct sd *sd = (struct sd *) gspca_dev;
1092
1093 kfree(sd->jpeg_hdr);
1094}
1095
1080static void sd_pkt_scan(struct gspca_dev *gspca_dev, 1096static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1081 struct gspca_frame *frame, /* target */ 1097 struct gspca_frame *frame, /* target */
1082 __u8 *data, /* isoc packet */ 1098 __u8 *data, /* isoc packet */
@@ -1153,7 +1169,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
1153 ffd9, 2); 1169 ffd9, 2);
1154 1170
1155 /* put the JPEG header in the new frame */ 1171 /* put the JPEG header in the new frame */
1156 jpeg_put_header(gspca_dev, frame, 0x22); 1172 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
1173 sd->jpeg_hdr, JPEG_HDR_SZ);
1157 } 1174 }
1158 1175
1159 /* add 0x00 after 0xff */ 1176 /* add 0x00 after 0xff */
@@ -1311,6 +1328,7 @@ static const struct sd_desc sd_desc = {
1311 .init = sd_init, 1328 .init = sd_init,
1312 .start = sd_start, 1329 .start = sd_start,
1313 .stopN = sd_stopN, 1330 .stopN = sd_stopN,
1331 .stop0 = sd_stop0,
1314 .pkt_scan = sd_pkt_scan, 1332 .pkt_scan = sd_pkt_scan,
1315}; 1333};
1316 1334
diff --git a/drivers/media/video/gspca/zc3xx.c b/drivers/media/video/gspca/zc3xx.c
index 4f459a746037..a4c673ff8f02 100644
--- a/drivers/media/video/gspca/zc3xx.c
+++ b/drivers/media/video/gspca/zc3xx.c
@@ -23,6 +23,7 @@
23#define MODULE_NAME "zc3xx" 23#define MODULE_NAME "zc3xx"
24 24
25#include "gspca.h" 25#include "gspca.h"
26#include "jpeg.h"
26 27
27MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>, " 28MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>, "
28 "Serge A. Suchkov <Serge.A.S@tochka.ru>"); 29 "Serge A. Suchkov <Serge.A.S@tochka.ru>");
@@ -32,7 +33,6 @@ MODULE_LICENSE("GPL");
32static int force_sensor = -1; 33static int force_sensor = -1;
33 34
34#define QUANT_VAL 1 /* quantization table */ 35#define QUANT_VAL 1 /* quantization table */
35#include "jpeg.h"
36#include "zc3xx-reg.h" 36#include "zc3xx-reg.h"
37 37
38/* specific webcam descriptor */ 38/* specific webcam descriptor */
@@ -45,6 +45,7 @@ struct sd {
45 __u8 autogain; 45 __u8 autogain;
46 __u8 lightfreq; 46 __u8 lightfreq;
47 __u8 sharpness; 47 __u8 sharpness;
48 u8 quality; /* image quality */
48 49
49 signed char sensor; /* Type of image sensor chip */ 50 signed char sensor; /* Type of image sensor chip */
50/* !! values used in different tables */ 51/* !! values used in different tables */
@@ -69,6 +70,8 @@ struct sd {
69#define SENSOR_TAS5130C_VF0250 17 70#define SENSOR_TAS5130C_VF0250 17
70#define SENSOR_MAX 18 71#define SENSOR_MAX 18
71 unsigned short chip_revision; 72 unsigned short chip_revision;
73
74 u8 *jpeg_hdr;
72}; 75};
73 76
74/* V4L2 controls supported by the driver */ 77/* V4L2 controls supported by the driver */
@@ -7177,6 +7180,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
7177 sd->gamma = gamma[(int) sd->sensor]; 7180 sd->gamma = gamma[(int) sd->sensor];
7178 sd->autogain = sd_ctrls[SD_AUTOGAIN].qctrl.default_value; 7181 sd->autogain = sd_ctrls[SD_AUTOGAIN].qctrl.default_value;
7179 sd->lightfreq = sd_ctrls[SD_FREQ].qctrl.default_value; 7182 sd->lightfreq = sd_ctrls[SD_FREQ].qctrl.default_value;
7183 sd->quality = 50;
7180 7184
7181 switch (sd->sensor) { 7185 switch (sd->sensor) {
7182 case SENSOR_GC0305: 7186 case SENSOR_GC0305:
@@ -7232,6 +7236,12 @@ static int sd_start(struct gspca_dev *gspca_dev)
7232 /* 17 */ 7236 /* 17 */
7233 }; 7237 };
7234 7238
7239 /* create the JPEG header */
7240 sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL);
7241 jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width,
7242 0x21); /* JPEG 422 */
7243 jpeg_set_qual(sd->jpeg_hdr, sd->quality);
7244
7235 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; 7245 mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv;
7236 zc3_init = init_tb[(int) sd->sensor][mode]; 7246 zc3_init = init_tb[(int) sd->sensor][mode];
7237 switch (sd->sensor) { 7247 switch (sd->sensor) {
@@ -7365,6 +7375,7 @@ static void sd_stop0(struct gspca_dev *gspca_dev)
7365{ 7375{
7366 struct sd *sd = (struct sd *) gspca_dev; 7376 struct sd *sd = (struct sd *) gspca_dev;
7367 7377
7378 kfree(sd->jpeg_hdr);
7368 if (!gspca_dev->present) 7379 if (!gspca_dev->present)
7369 return; 7380 return;
7370 send_unknown(gspca_dev->dev, sd->sensor); 7381 send_unknown(gspca_dev->dev, sd->sensor);
@@ -7375,12 +7386,15 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
7375 __u8 *data, 7386 __u8 *data,
7376 int len) 7387 int len)
7377{ 7388{
7389 struct sd *sd = (struct sd *) gspca_dev;
7378 7390
7379 if (data[0] == 0xff && data[1] == 0xd8) { /* start of frame */ 7391 if (data[0] == 0xff && data[1] == 0xd8) { /* start of frame */
7380 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, 7392 frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame,
7381 data, 0); 7393 data, 0);
7382 /* put the JPEG header in the new frame */ 7394 /* put the JPEG header in the new frame */
7383 jpeg_put_header(gspca_dev, frame, 0x21); 7395 gspca_frame_add(gspca_dev, FIRST_PACKET, frame,
7396 sd->jpeg_hdr, JPEG_HDR_SZ);
7397
7384 /* remove the webcam's header: 7398 /* remove the webcam's header:
7385 * ff d8 ff fe 00 0e 00 00 ss ss 00 01 ww ww hh hh pp pp 7399 * ff d8 ff fe 00 0e 00 00 ss ss 00 01 ww ww hh hh pp pp
7386 * - 'ss ss' is the frame sequence number (BE) 7400 * - 'ss ss' is the frame sequence number (BE)