diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2008-07-04 10:16:16 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:16:53 -0400 |
commit | a5ae2062252e697d38e53dbbeb91460252208914 (patch) | |
tree | 38706e9f36e2d93cd3dee8eea639bb74a17b3efa /drivers/media/video/gspca/sonixj.c | |
parent | 54ab92ca05550550bcec2462de2605f35d079b66 (diff) |
V4L/DVB (8195): gspca: Input buffer overwritten in spca561 + cleanup code.
spca561: Input buffer may be changed on reg write.
(all sd): Cleanup code, 'const' added.
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r-- | drivers/media/video/gspca/sonixj.c | 165 |
1 files changed, 88 insertions, 77 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 4f23b16c89a8..eb5e1bfd7911 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
@@ -24,8 +24,8 @@ | |||
24 | #include "gspca.h" | 24 | #include "gspca.h" |
25 | #include "jpeg.h" | 25 | #include "jpeg.h" |
26 | 26 | ||
27 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 3) | 27 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 4) |
28 | static const char version[] = "2.1.3"; | 28 | static const char version[] = "2.1.4"; |
29 | 29 | ||
30 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); | 30 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); |
31 | MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); | 31 | MODULE_DESCRIPTION("GSPCA/SONIX JPEG USB Camera Driver"); |
@@ -74,7 +74,6 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); | |||
74 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); | 74 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); |
75 | 75 | ||
76 | static struct ctrl sd_ctrls[] = { | 76 | static struct ctrl sd_ctrls[] = { |
77 | #define SD_BRIGHTNESS 0 | ||
78 | { | 77 | { |
79 | { | 78 | { |
80 | .id = V4L2_CID_BRIGHTNESS, | 79 | .id = V4L2_CID_BRIGHTNESS, |
@@ -83,12 +82,12 @@ static struct ctrl sd_ctrls[] = { | |||
83 | .minimum = 0, | 82 | .minimum = 0, |
84 | .maximum = 0xffff, | 83 | .maximum = 0xffff, |
85 | .step = 1, | 84 | .step = 1, |
86 | .default_value = 0x7fff, | 85 | #define BRIGHTNESS_DEF 0x7fff |
86 | .default_value = BRIGHTNESS_DEF, | ||
87 | }, | 87 | }, |
88 | .set = sd_setbrightness, | 88 | .set = sd_setbrightness, |
89 | .get = sd_getbrightness, | 89 | .get = sd_getbrightness, |
90 | }, | 90 | }, |
91 | #define SD_CONTRAST 1 | ||
92 | { | 91 | { |
93 | { | 92 | { |
94 | .id = V4L2_CID_CONTRAST, | 93 | .id = V4L2_CID_CONTRAST, |
@@ -97,12 +96,12 @@ static struct ctrl sd_ctrls[] = { | |||
97 | .minimum = 0, | 96 | .minimum = 0, |
98 | .maximum = 127, | 97 | .maximum = 127, |
99 | .step = 1, | 98 | .step = 1, |
100 | .default_value = 63, | 99 | #define CONTRAST_DEF 63 |
100 | .default_value = CONTRAST_DEF, | ||
101 | }, | 101 | }, |
102 | .set = sd_setcontrast, | 102 | .set = sd_setcontrast, |
103 | .get = sd_getcontrast, | 103 | .get = sd_getcontrast, |
104 | }, | 104 | }, |
105 | #define SD_COLOR 2 | ||
106 | { | 105 | { |
107 | { | 106 | { |
108 | .id = V4L2_CID_SATURATION, | 107 | .id = V4L2_CID_SATURATION, |
@@ -111,12 +110,12 @@ static struct ctrl sd_ctrls[] = { | |||
111 | .minimum = 0, | 110 | .minimum = 0, |
112 | .maximum = 255, | 111 | .maximum = 255, |
113 | .step = 1, | 112 | .step = 1, |
114 | .default_value = 127, | 113 | #define COLOR_DEF 127 |
114 | .default_value = COLOR_DEF, | ||
115 | }, | 115 | }, |
116 | .set = sd_setcolors, | 116 | .set = sd_setcolors, |
117 | .get = sd_getcolors, | 117 | .get = sd_getcolors, |
118 | }, | 118 | }, |
119 | #define SD_AUTOGAIN 3 | ||
120 | { | 119 | { |
121 | { | 120 | { |
122 | .id = V4L2_CID_AUTOGAIN, | 121 | .id = V4L2_CID_AUTOGAIN, |
@@ -125,7 +124,8 @@ static struct ctrl sd_ctrls[] = { | |||
125 | .minimum = 0, | 124 | .minimum = 0, |
126 | .maximum = 1, | 125 | .maximum = 1, |
127 | .step = 1, | 126 | .step = 1, |
128 | .default_value = 1, | 127 | #define AUTOGAIN_DEF 1 |
128 | .default_value = AUTOGAIN_DEF, | ||
129 | }, | 129 | }, |
130 | .set = sd_setautogain, | 130 | .set = sd_setautogain, |
131 | .get = sd_getautogain, | 131 | .get = sd_getautogain, |
@@ -139,7 +139,7 @@ static struct cam_mode vga_mode[] = { | |||
139 | }; | 139 | }; |
140 | 140 | ||
141 | /*Data from sn9c102p+hv71331r */ | 141 | /*Data from sn9c102p+hv71331r */ |
142 | static __u8 sn_hv7131[] = { | 142 | static const __u8 sn_hv7131[] = { |
143 | 0x00, 0x03, 0x64, 0x00, 0x1A, 0x20, 0x20, 0x20, 0xA1, 0x11, | 143 | 0x00, 0x03, 0x64, 0x00, 0x1A, 0x20, 0x20, 0x20, 0xA1, 0x11, |
144 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 reg9 */ | 144 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 reg9 */ |
145 | 0x02, 0x09, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, /* 00 */ | 145 | 0x02, 0x09, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, /* 00 */ |
@@ -150,7 +150,7 @@ static __u8 sn_hv7131[] = { | |||
150 | /* reg1c reg1d reg1e reg1f reg20 reg21 reg22 reg23 */ | 150 | /* reg1c reg1d reg1e reg1f reg20 reg21 reg22 reg23 */ |
151 | }; | 151 | }; |
152 | 152 | ||
153 | static __u8 sn_mi0360[] = { | 153 | static const __u8 sn_mi0360[] = { |
154 | 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, 0xb1, 0x5d, | 154 | 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, 0xb1, 0x5d, |
155 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 reg9 */ | 155 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 reg9 */ |
156 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, | 156 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, |
@@ -161,7 +161,7 @@ static __u8 sn_mi0360[] = { | |||
161 | /* reg1c reg1d reg1e reg1f reg20 reg21 reg22 reg23 */ | 161 | /* reg1c reg1d reg1e reg1f reg20 reg21 reg22 reg23 */ |
162 | }; | 162 | }; |
163 | 163 | ||
164 | static __u8 sn_mo4000[] = { | 164 | static const __u8 sn_mo4000[] = { |
165 | 0x12, 0x23, 0x60, 0x00, 0x1A, 0x00, 0x20, 0x18, 0x81, | 165 | 0x12, 0x23, 0x60, 0x00, 0x1A, 0x00, 0x20, 0x18, 0x81, |
166 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 */ | 166 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 */ |
167 | 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, | 167 | 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, |
@@ -174,13 +174,13 @@ static __u8 sn_mo4000[] = { | |||
174 | 0xd3, 0xdf, 0xea, 0xf5 | 174 | 0xd3, 0xdf, 0xea, 0xf5 |
175 | }; | 175 | }; |
176 | 176 | ||
177 | static __u8 sn_ov7648[] = { | 177 | static const __u8 sn_ov7648[] = { |
178 | 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20, 0xA1, 0x6E, 0x18, 0x65, | 178 | 0x00, 0x21, 0x62, 0x00, 0x1a, 0x20, 0x20, 0x20, 0xA1, 0x6E, 0x18, 0x65, |
179 | 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1E, 0x82, | 179 | 0x00, 0x00, 0x00, 0x10, 0x03, 0x00, 0x00, 0x06, 0x06, 0x28, 0x1E, 0x82, |
180 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x00 | 180 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x00 |
181 | }; | 181 | }; |
182 | 182 | ||
183 | static __u8 sn_ov7660[] = { | 183 | static const __u8 sn_ov7660[] = { |
184 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 */ | 184 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 */ |
185 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x81, | 185 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x81, |
186 | /* reg9 rega regb regc regd rege regf reg10 reg11*/ | 186 | /* reg9 rega regb regc regd rege regf reg10 reg11*/ |
@@ -192,7 +192,7 @@ static __u8 sn_ov7660[] = { | |||
192 | }; | 192 | }; |
193 | 193 | ||
194 | /* sequence specific to the sensors - !! index = SENSOR_xxx */ | 194 | /* sequence specific to the sensors - !! index = SENSOR_xxx */ |
195 | static __u8 *sn_tb[] = { | 195 | static const __u8 *sn_tb[] = { |
196 | sn_hv7131, | 196 | sn_hv7131, |
197 | sn_mi0360, | 197 | sn_mi0360, |
198 | sn_mo4000, | 198 | sn_mo4000, |
@@ -200,28 +200,28 @@ static __u8 *sn_tb[] = { | |||
200 | sn_ov7660 | 200 | sn_ov7660 |
201 | }; | 201 | }; |
202 | 202 | ||
203 | static __u8 regsn20[] = { | 203 | static const __u8 regsn20[] = { |
204 | 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, | 204 | 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, |
205 | 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff | 205 | 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff |
206 | }; | 206 | }; |
207 | static __u8 regsn20_sn9c325[] = { | 207 | static const __u8 regsn20_sn9c325[] = { |
208 | 0x0a, 0x3a, 0x56, 0x6c, 0x7e, 0x8d, 0x9a, 0xa4, | 208 | 0x0a, 0x3a, 0x56, 0x6c, 0x7e, 0x8d, 0x9a, 0xa4, |
209 | 0xaf, 0xbb, 0xc5, 0xcd, 0xd5, 0xde, 0xe8, 0xed, 0xf5 | 209 | 0xaf, 0xbb, 0xc5, 0xcd, 0xd5, 0xde, 0xe8, 0xed, 0xf5 |
210 | }; | 210 | }; |
211 | 211 | ||
212 | static __u8 reg84[] = { | 212 | static const __u8 reg84[] = { |
213 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, 0xe5, 0x0f, | 213 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, 0xe5, 0x0f, |
214 | 0xe4, 0x0f, 0x38, 0x00, 0x3e, 0x00, 0xc3, 0x0f, | 214 | 0xe4, 0x0f, 0x38, 0x00, 0x3e, 0x00, 0xc3, 0x0f, |
215 | /* 0x00, 0x00, 0x00, 0x00, 0x00 */ | 215 | /* 0x00, 0x00, 0x00, 0x00, 0x00 */ |
216 | 0xf7, 0x0f, 0x0a, 0x00, 0x00 | 216 | 0xf7, 0x0f, 0x0a, 0x00, 0x00 |
217 | }; | 217 | }; |
218 | static __u8 reg84_sn9c325[] = { | 218 | static const __u8 reg84_sn9c325[] = { |
219 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, 0xe4, 0x0f, | 219 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, 0xe4, 0x0f, |
220 | 0xd3, 0x0f, 0x4b, 0x00, 0x48, 0x00, 0xc0, 0x0f, | 220 | 0xd3, 0x0f, 0x4b, 0x00, 0x48, 0x00, 0xc0, 0x0f, |
221 | 0xf8, 0x0f, 0x00, 0x00, 0x00 | 221 | 0xf8, 0x0f, 0x00, 0x00, 0x00 |
222 | }; | 222 | }; |
223 | 223 | ||
224 | static __u8 hv7131r_sensor_init[][8] = { | 224 | static const __u8 hv7131r_sensor_init[][8] = { |
225 | {0xC1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, | 225 | {0xC1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, |
226 | {0xB1, 0x11, 0x34, 0x17, 0x7F, 0x00, 0x00, 0x10}, | 226 | {0xB1, 0x11, 0x34, 0x17, 0x7F, 0x00, 0x00, 0x10}, |
227 | {0xD1, 0x11, 0x40, 0xFF, 0x7F, 0x7F, 0x7F, 0x10}, | 227 | {0xD1, 0x11, 0x40, 0xFF, 0x7F, 0x7F, 0x7F, 0x10}, |
@@ -250,9 +250,9 @@ static __u8 hv7131r_sensor_init[][8] = { | |||
250 | {0xA1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10}, | 250 | {0xA1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10}, |
251 | {0xA1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, | 251 | {0xA1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
252 | {0xA1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10}, | 252 | {0xA1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10}, |
253 | {0, 0, 0, 0, 0, 0, 0, 0} | 253 | {} |
254 | }; | 254 | }; |
255 | static __u8 mi0360_sensor_init[][8] = { | 255 | static const __u8 mi0360_sensor_init[][8] = { |
256 | {0xB1, 0x5D, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, | 256 | {0xB1, 0x5D, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, |
257 | {0xB1, 0x5D, 0x0D, 0x00, 0x01, 0x00, 0x00, 0x10}, | 257 | {0xB1, 0x5D, 0x0D, 0x00, 0x01, 0x00, 0x00, 0x10}, |
258 | {0xB1, 0x5D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x10}, | 258 | {0xB1, 0x5D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x10}, |
@@ -304,9 +304,9 @@ static __u8 mi0360_sensor_init[][8] = { | |||
304 | /* {0xB1, 0x5D, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */ | 304 | /* {0xB1, 0x5D, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */ |
305 | {0xB1, 0x5D, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */ | 305 | {0xB1, 0x5D, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */ |
306 | {0xB1, 0x5D, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ | 306 | {0xB1, 0x5D, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ |
307 | {0, 0, 0, 0, 0, 0, 0, 0} | 307 | {} |
308 | }; | 308 | }; |
309 | static __u8 mo4000_sensor_init[][8] = { | 309 | static const __u8 mo4000_sensor_init[][8] = { |
310 | {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, | 310 | {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, |
311 | {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, | 311 | {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, |
312 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, | 312 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, |
@@ -327,9 +327,9 @@ static __u8 mo4000_sensor_init[][8] = { | |||
327 | {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, | 327 | {0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10}, |
328 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | 328 | {0xa1, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, |
329 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, | 329 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, |
330 | {0, 0, 0, 0, 0, 0, 0, 0} | 330 | {} |
331 | }; | 331 | }; |
332 | static __u8 ov7660_sensor_init[][8] = { | 332 | static const __u8 ov7660_sensor_init[][8] = { |
333 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ | 333 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ |
334 | {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, | 334 | {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, |
335 | /* Outformat ?? rawRGB */ | 335 | /* Outformat ?? rawRGB */ |
@@ -420,12 +420,12 @@ static __u8 ov7660_sensor_init[][8] = { | |||
420 | {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, | 420 | {0xa1, 0x21, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
421 | {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10}, | 421 | {0xa1, 0x21, 0x2b, 0xc3, 0x00, 0x00, 0x00, 0x10}, |
422 | /* here may start the isoc exchanges */ | 422 | /* here may start the isoc exchanges */ |
423 | {0, 0, 0, 0, 0, 0, 0, 0} | 423 | {} |
424 | }; | 424 | }; |
425 | /* reg0x04 reg0x07 reg 0x10 */ | 425 | /* reg0x04 reg0x07 reg 0x10 */ |
426 | /* expo = (COM1 & 0x02) | (AECHH & 0x2f <<10) [ (AECh << 2) */ | 426 | /* expo = (COM1 & 0x02) | (AECHH & 0x2f <<10) [ (AECh << 2) */ |
427 | 427 | ||
428 | static __u8 ov7648_sensor_init[][8] = { | 428 | static const __u8 ov7648_sensor_init[][8] = { |
429 | {0xC1, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00}, | 429 | {0xC1, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00}, |
430 | {0xC1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00}, | 430 | {0xC1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00}, |
431 | {0xC1, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00}, | 431 | {0xC1, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00}, |
@@ -478,10 +478,10 @@ static __u8 ov7648_sensor_init[][8] = { | |||
478 | {0xA1, 0x6E, 0x07, 0x66, 0x00, 0x00, 0x00, 0x10}, /* B.. */ | 478 | {0xA1, 0x6E, 0x07, 0x66, 0x00, 0x00, 0x00, 0x10}, /* B.. */ |
479 | {0xC1, 0x6E, 0x1A, 0x03, 0x65, 0x90, 0x00, 0x10}, /* Bright/Witen....*/ | 479 | {0xC1, 0x6E, 0x1A, 0x03, 0x65, 0x90, 0x00, 0x10}, /* Bright/Witen....*/ |
480 | /* {0xC1, 0x6E, 0x16, 0x45, 0x40, 0x60, 0x00, 0x10}, * Bright/Witene */ | 480 | /* {0xC1, 0x6E, 0x16, 0x45, 0x40, 0x60, 0x00, 0x10}, * Bright/Witene */ |
481 | {0, 0, 0, 0, 0, 0, 0, 0} | 481 | {} |
482 | }; | 482 | }; |
483 | 483 | ||
484 | static __u8 qtable4[] = { | 484 | static const __u8 qtable4[] = { |
485 | 0x06, 0x04, 0x04, 0x06, 0x04, 0x04, 0x06, 0x06, 0x06, 0x06, 0x08, 0x06, | 485 | 0x06, 0x04, 0x04, 0x06, 0x04, 0x04, 0x06, 0x06, 0x06, 0x06, 0x08, 0x06, |
486 | 0x06, 0x08, 0x0A, 0x11, | 486 | 0x06, 0x08, 0x0A, 0x11, |
487 | 0x0A, 0x0A, 0x08, 0x08, 0x0A, 0x15, 0x0F, 0x0F, 0x0C, 0x11, 0x19, 0x15, | 487 | 0x0A, 0x0A, 0x08, 0x08, 0x0A, 0x15, 0x0F, 0x0F, 0x0C, 0x11, 0x19, 0x15, |
@@ -518,27 +518,36 @@ static void reg_w(struct usb_device *dev, | |||
518 | const __u8 *buffer, | 518 | const __u8 *buffer, |
519 | int len) | 519 | int len) |
520 | { | 520 | { |
521 | __u8 tmpbuf[64]; | 521 | if (len < 16) { |
522 | 522 | __u8 tmpbuf[16]; | |
523 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 523 | |
524 | if (len > sizeof tmpbuf) { | 524 | memcpy(tmpbuf, buffer, len); |
525 | PDEBUG(D_ERR|D_PACK, "reg_w: buffer overflow"); | 525 | usb_control_msg(dev, |
526 | return; | 526 | usb_sndctrlpipe(dev, 0), |
527 | 0x08, | ||
528 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
529 | value, 0, | ||
530 | tmpbuf, len, | ||
531 | 500); | ||
532 | } else { | ||
533 | __u8 *tmpbuf; | ||
534 | |||
535 | tmpbuf = kmalloc(len, GFP_KERNEL); | ||
536 | memcpy(tmpbuf, buffer, len); | ||
537 | usb_control_msg(dev, | ||
538 | usb_sndctrlpipe(dev, 0), | ||
539 | 0x08, | ||
540 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
541 | value, 0, | ||
542 | tmpbuf, len, | ||
543 | 500); | ||
544 | kfree(tmpbuf); | ||
527 | } | 545 | } |
528 | #endif | ||
529 | memcpy(tmpbuf, buffer, len); | ||
530 | usb_control_msg(dev, | ||
531 | usb_sndctrlpipe(dev, 0), | ||
532 | 0x08, | ||
533 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
534 | value, 0, | ||
535 | tmpbuf, len, | ||
536 | 500); | ||
537 | } | 546 | } |
538 | 547 | ||
539 | /* write 2 bytes */ | 548 | /* write 2 bytes */ |
540 | static void i2c_w2(struct gspca_dev *gspca_dev, | 549 | static void i2c_w2(struct gspca_dev *gspca_dev, |
541 | __u8 *buffer) | 550 | const __u8 *buffer) |
542 | { | 551 | { |
543 | struct sd *sd = (struct sd *) gspca_dev; | 552 | struct sd *sd = (struct sd *) gspca_dev; |
544 | struct usb_device *dev = gspca_dev->dev; | 553 | struct usb_device *dev = gspca_dev->dev; |
@@ -557,7 +566,7 @@ static void i2c_w2(struct gspca_dev *gspca_dev, | |||
557 | } | 566 | } |
558 | 567 | ||
559 | /* write 8 bytes */ | 568 | /* write 8 bytes */ |
560 | static void i2c_w8(struct usb_device *dev, __u8 *buffer) | 569 | static void i2c_w8(struct usb_device *dev, const __u8 *buffer) |
561 | { | 570 | { |
562 | reg_w(dev, 0x08, buffer, 8); | 571 | reg_w(dev, 0x08, buffer, 8); |
563 | msleep(1); | 572 | msleep(1); |
@@ -565,7 +574,7 @@ static void i2c_w8(struct usb_device *dev, __u8 *buffer) | |||
565 | 574 | ||
566 | /* read 5 bytes */ | 575 | /* read 5 bytes */ |
567 | static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg, | 576 | static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg, |
568 | __u8 *buffer) | 577 | __u8 *buffer) |
569 | { | 578 | { |
570 | struct sd *sd = (struct sd *) gspca_dev; | 579 | struct sd *sd = (struct sd *) gspca_dev; |
571 | struct usb_device *dev = gspca_dev->dev; | 580 | struct usb_device *dev = gspca_dev->dev; |
@@ -591,7 +600,7 @@ static int probesensor(struct gspca_dev *gspca_dev) | |||
591 | struct sd *sd = (struct sd *) gspca_dev; | 600 | struct sd *sd = (struct sd *) gspca_dev; |
592 | struct usb_device *dev = gspca_dev->dev; | 601 | struct usb_device *dev = gspca_dev->dev; |
593 | __u8 reg02; | 602 | __u8 reg02; |
594 | static __u8 datasend[] = { 2, 0 }; | 603 | static const __u8 datasend[] = { 2, 0 }; |
595 | /* reg val1 val2 val3 val4 */ | 604 | /* reg val1 val2 val3 val4 */ |
596 | __u8 datarecd[6]; | 605 | __u8 datarecd[6]; |
597 | 606 | ||
@@ -618,18 +627,18 @@ static int probesensor(struct gspca_dev *gspca_dev) | |||
618 | } | 627 | } |
619 | 628 | ||
620 | static int configure_gpio(struct gspca_dev *gspca_dev, | 629 | static int configure_gpio(struct gspca_dev *gspca_dev, |
621 | __u8 *sn9c1xx) | 630 | const __u8 *sn9c1xx) |
622 | { | 631 | { |
623 | struct sd *sd = (struct sd *) gspca_dev; | 632 | struct sd *sd = (struct sd *) gspca_dev; |
624 | struct usb_device *dev = gspca_dev->dev; | 633 | struct usb_device *dev = gspca_dev->dev; |
625 | __u8 data; | 634 | __u8 data; |
626 | __u8 regF1; | 635 | __u8 regF1; |
627 | __u8 *reg9a; | 636 | const __u8 *reg9a; |
628 | static __u8 reg9a_def[] = | 637 | static const __u8 reg9a_def[] = |
629 | {0x08, 0x40, 0x20, 0x10, 0x00, 0x04}; | 638 | {0x08, 0x40, 0x20, 0x10, 0x00, 0x04}; |
630 | static __u8 reg9a_sn9c120[] = /* from win trace */ | 639 | static const __u8 reg9a_sn9c120[] = /* from win trace */ |
631 | {0x00, 0x40, 0x38, 0x30, 0x00, 0x20}; | 640 | {0x00, 0x40, 0x38, 0x30, 0x00, 0x20}; |
632 | static __u8 reg9a_sn9c325[] = | 641 | static const __u8 reg9a_sn9c325[] = |
633 | {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20}; | 642 | {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20}; |
634 | 643 | ||
635 | 644 | ||
@@ -697,7 +706,7 @@ static void hv7131R_InitSensor(struct gspca_dev *gspca_dev) | |||
697 | { | 706 | { |
698 | int i = 0; | 707 | int i = 0; |
699 | struct usb_device *dev = gspca_dev->dev; | 708 | struct usb_device *dev = gspca_dev->dev; |
700 | static __u8 SetSensorClk[] = /* 0x08 Mclk */ | 709 | static const __u8 SetSensorClk[] = /* 0x08 Mclk */ |
701 | { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 }; | 710 | { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 }; |
702 | 711 | ||
703 | while (hv7131r_sensor_init[i][0]) { | 712 | while (hv7131r_sensor_init[i][0]) { |
@@ -971,11 +980,12 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
971 | cam->epaddr = 0x01; | 980 | cam->epaddr = 0x01; |
972 | cam->cam_mode = vga_mode; | 981 | cam->cam_mode = vga_mode; |
973 | cam->nmodes = ARRAY_SIZE(vga_mode); | 982 | cam->nmodes = ARRAY_SIZE(vga_mode); |
983 | |||
974 | sd->qindex = 4; /* set the quantization table */ | 984 | sd->qindex = 4; /* set the quantization table */ |
975 | sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; | 985 | sd->brightness = BRIGHTNESS_DEF; |
976 | sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; | 986 | sd->contrast = CONTRAST_DEF; |
977 | sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; | 987 | sd->colors = COLOR_DEF; |
978 | sd->autogain = sd_ctrls[SD_AUTOGAIN].qctrl.default_value; | 988 | sd->autogain = AUTOGAIN_DEF; |
979 | return 0; | 989 | return 0; |
980 | } | 990 | } |
981 | 991 | ||
@@ -984,7 +994,7 @@ static int sd_open(struct gspca_dev *gspca_dev) | |||
984 | { | 994 | { |
985 | struct sd *sd = (struct sd *) gspca_dev; | 995 | struct sd *sd = (struct sd *) gspca_dev; |
986 | struct usb_device *dev = gspca_dev->dev; | 996 | struct usb_device *dev = gspca_dev->dev; |
987 | /* __u8 *sn9c1xx; */ | 997 | /* const __u8 *sn9c1xx; */ |
988 | __u8 regF1; | 998 | __u8 regF1; |
989 | __u8 regGpio[] = { 0x29, 0x74 }; | 999 | __u8 regGpio[] = { 0x29, 0x74 }; |
990 | 1000 | ||
@@ -1036,11 +1046,11 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev, | |||
1036 | unsigned int expo) | 1046 | unsigned int expo) |
1037 | { | 1047 | { |
1038 | struct sd *sd = (struct sd *) gspca_dev; | 1048 | struct sd *sd = (struct sd *) gspca_dev; |
1039 | static __u8 doit[] = /* update sensor */ | 1049 | static const __u8 doit[] = /* update sensor */ |
1040 | { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 }; | 1050 | { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 }; |
1041 | static __u8 sensorgo[] = /* sensor on */ | 1051 | static const __u8 sensorgo[] = /* sensor on */ |
1042 | { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 }; | 1052 | { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 }; |
1043 | static __u8 gainMo[] = | 1053 | static const __u8 gainMo[] = |
1044 | { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d }; | 1054 | { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d }; |
1045 | 1055 | ||
1046 | switch (sd->sensor) { | 1056 | switch (sd->sensor) { |
@@ -1164,14 +1174,15 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
1164 | __u8 data; | 1174 | __u8 data; |
1165 | __u8 reg1; | 1175 | __u8 reg1; |
1166 | __u8 reg17; | 1176 | __u8 reg17; |
1167 | __u8 *sn9c1xx; | 1177 | const __u8 *sn9c1xx; |
1168 | int mode; | 1178 | int mode; |
1169 | static __u8 DC29[] = { 0x6a, 0x50, 0x00, 0x00, 0x50, 0x3c }; | 1179 | static const __u8 DC29[] = { 0x6a, 0x50, 0x00, 0x00, 0x50, 0x3c }; |
1170 | static __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; | 1180 | static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; |
1171 | static __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; | 1181 | static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; |
1172 | static __u8 CA_sn9c120[] = { 0x14, 0xec, 0x0a, 0xf6 }; /* SN9C120 */ | 1182 | static const __u8 CA_sn9c120[] = |
1173 | static __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ | 1183 | { 0x14, 0xec, 0x0a, 0xf6 }; /* SN9C120 */ |
1174 | static __u8 CE_sn9c325[] = | 1184 | static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ |
1185 | static const __u8 CE_sn9c325[] = | ||
1175 | { 0x32, 0xdd, 0x32, 0xdd }; /* OV7648 - SN9C325 */ | 1186 | { 0x32, 0xdd, 0x32, 0xdd }; /* OV7648 - SN9C325 */ |
1176 | 1187 | ||
1177 | sn9c1xx = sn_tb[(int) sd->sensor]; | 1188 | sn9c1xx = sn_tb[(int) sd->sensor]; |
@@ -1311,13 +1322,13 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1311 | { | 1322 | { |
1312 | struct sd *sd = (struct sd *) gspca_dev; | 1323 | struct sd *sd = (struct sd *) gspca_dev; |
1313 | struct usb_device *dev = gspca_dev->dev; | 1324 | struct usb_device *dev = gspca_dev->dev; |
1314 | static __u8 stophv7131[] = | 1325 | static const __u8 stophv7131[] = |
1315 | { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 }; | 1326 | { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 }; |
1316 | static __u8 stopmi0360[] = | 1327 | static const __u8 stopmi0360[] = |
1317 | { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 }; | 1328 | { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
1318 | __u8 regF1; | 1329 | __u8 regF1; |
1319 | __u8 data; | 1330 | __u8 data; |
1320 | __u8 *sn9c1xx; | 1331 | const __u8 *sn9c1xx; |
1321 | 1332 | ||
1322 | data = 0x0b; | 1333 | data = 0x0b; |
1323 | switch (sd->sensor) { | 1334 | switch (sd->sensor) { |
@@ -1392,7 +1403,7 @@ static void setautogain(struct gspca_dev *gspca_dev) | |||
1392 | 1403 | ||
1393 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 1404 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
1394 | struct gspca_frame *frame, /* target */ | 1405 | struct gspca_frame *frame, /* target */ |
1395 | unsigned char *data, /* isoc packet */ | 1406 | __u8 *data, /* isoc packet */ |
1396 | int len) /* iso packet length */ | 1407 | int len) /* iso packet length */ |
1397 | { | 1408 | { |
1398 | struct sd *sd = (struct sd *) gspca_dev; | 1409 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -1567,7 +1578,7 @@ static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) | |||
1567 | } | 1578 | } |
1568 | 1579 | ||
1569 | /* sub-driver description */ | 1580 | /* sub-driver description */ |
1570 | static struct sd_desc sd_desc = { | 1581 | static const struct sd_desc sd_desc = { |
1571 | .name = MODULE_NAME, | 1582 | .name = MODULE_NAME, |
1572 | .ctrls = sd_ctrls, | 1583 | .ctrls = sd_ctrls, |
1573 | .nctrls = ARRAY_SIZE(sd_ctrls), | 1584 | .nctrls = ARRAY_SIZE(sd_ctrls), |
@@ -1582,7 +1593,7 @@ static struct sd_desc sd_desc = { | |||
1582 | 1593 | ||
1583 | /* -- module initialisation -- */ | 1594 | /* -- module initialisation -- */ |
1584 | #define DVNM(name) .driver_info = (kernel_ulong_t) name | 1595 | #define DVNM(name) .driver_info = (kernel_ulong_t) name |
1585 | static __devinitdata struct usb_device_id device_table[] = { | 1596 | static const __devinitdata struct usb_device_id device_table[] = { |
1586 | {USB_DEVICE(0x0458, 0x7025), DVNM("Genius Eye 311Q")}, | 1597 | {USB_DEVICE(0x0458, 0x7025), DVNM("Genius Eye 311Q")}, |
1587 | {USB_DEVICE(0x045e, 0x00f5), DVNM("MicroSoft VX3000")}, | 1598 | {USB_DEVICE(0x045e, 0x00f5), DVNM("MicroSoft VX3000")}, |
1588 | {USB_DEVICE(0x045e, 0x00f7), DVNM("MicroSoft VX1000")}, | 1599 | {USB_DEVICE(0x045e, 0x00f7), DVNM("MicroSoft VX1000")}, |