diff options
Diffstat (limited to 'drivers/media/video/gspca/sonixj.c')
-rw-r--r-- | drivers/media/video/gspca/sonixj.c | 951 |
1 files changed, 708 insertions, 243 deletions
diff --git a/drivers/media/video/gspca/sonixj.c b/drivers/media/video/gspca/sonixj.c index 3373b8d9d2a8..c72e19d3ac37 100644 --- a/drivers/media/video/gspca/sonixj.c +++ b/drivers/media/video/gspca/sonixj.c | |||
@@ -35,36 +35,47 @@ struct sd { | |||
35 | struct gspca_dev gspca_dev; /* !! must be the first item */ | 35 | struct gspca_dev gspca_dev; /* !! must be the first item */ |
36 | 36 | ||
37 | atomic_t avg_lum; | 37 | atomic_t avg_lum; |
38 | unsigned int exposure; | 38 | u32 exposure; |
39 | 39 | ||
40 | __u16 brightness; | 40 | u16 brightness; |
41 | __u8 contrast; | 41 | u8 contrast; |
42 | __u8 colors; | 42 | u8 colors; |
43 | __u8 autogain; | 43 | u8 autogain; |
44 | __u8 blue; | 44 | u8 blue; |
45 | __u8 red; | 45 | u8 red; |
46 | __u8 vflip; /* ov7630 only */ | 46 | u8 gamma; |
47 | __u8 infrared; /* mi0360 only */ | 47 | u8 vflip; /* ov7630/ov7648 only */ |
48 | 48 | u8 infrared; /* mt9v111 only */ | |
49 | __s8 ag_cnt; | 49 | u8 quality; /* image quality */ |
50 | #define QUALITY_MIN 60 | ||
51 | #define QUALITY_MAX 95 | ||
52 | #define QUALITY_DEF 80 | ||
53 | u8 jpegqual; /* webcam quality */ | ||
54 | |||
55 | u8 reg18; | ||
56 | |||
57 | s8 ag_cnt; | ||
50 | #define AG_CNT_START 13 | 58 | #define AG_CNT_START 13 |
51 | 59 | ||
52 | __u8 qindex; | 60 | u8 bridge; |
53 | __u8 bridge; | ||
54 | #define BRIDGE_SN9C102P 0 | 61 | #define BRIDGE_SN9C102P 0 |
55 | #define BRIDGE_SN9C105 1 | 62 | #define BRIDGE_SN9C105 1 |
56 | #define BRIDGE_SN9C110 2 | 63 | #define BRIDGE_SN9C110 2 |
57 | #define BRIDGE_SN9C120 3 | 64 | #define BRIDGE_SN9C120 3 |
58 | #define BRIDGE_SN9C325 4 | 65 | #define BRIDGE_SN9C325 4 |
59 | __u8 sensor; /* Type of image sensor chip */ | 66 | u8 sensor; /* Type of image sensor chip */ |
60 | #define SENSOR_HV7131R 0 | 67 | #define SENSOR_HV7131R 0 |
61 | #define SENSOR_MI0360 1 | 68 | #define SENSOR_MI0360 1 |
62 | #define SENSOR_MO4000 2 | 69 | #define SENSOR_MO4000 2 |
63 | #define SENSOR_OM6802 3 | 70 | #define SENSOR_MT9V111 3 |
64 | #define SENSOR_OV7630 4 | 71 | #define SENSOR_OM6802 4 |
65 | #define SENSOR_OV7648 5 | 72 | #define SENSOR_OV7630 5 |
66 | #define SENSOR_OV7660 6 | 73 | #define SENSOR_OV7648 6 |
67 | __u8 i2c_base; | 74 | #define SENSOR_OV7660 7 |
75 | #define SENSOR_SP80708 8 | ||
76 | u8 i2c_base; | ||
77 | |||
78 | u8 *jpeg_hdr; | ||
68 | }; | 79 | }; |
69 | 80 | ||
70 | /* V4L2 controls supported by the driver */ | 81 | /* V4L2 controls supported by the driver */ |
@@ -78,6 +89,8 @@ static int sd_setblue_balance(struct gspca_dev *gspca_dev, __s32 val); | |||
78 | static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val); | 89 | static int sd_getblue_balance(struct gspca_dev *gspca_dev, __s32 *val); |
79 | static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val); | 90 | static int sd_setred_balance(struct gspca_dev *gspca_dev, __s32 val); |
80 | static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val); | 91 | static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val); |
92 | static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val); | ||
93 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val); | ||
81 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); | 94 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val); |
82 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); | 95 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val); |
83 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); | 96 | static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val); |
@@ -158,6 +171,20 @@ static struct ctrl sd_ctrls[] = { | |||
158 | .set = sd_setred_balance, | 171 | .set = sd_setred_balance, |
159 | .get = sd_getred_balance, | 172 | .get = sd_getred_balance, |
160 | }, | 173 | }, |
174 | { | ||
175 | { | ||
176 | .id = V4L2_CID_GAMMA, | ||
177 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
178 | .name = "Gamma", | ||
179 | .minimum = 0, | ||
180 | .maximum = 40, | ||
181 | .step = 1, | ||
182 | #define GAMMA_DEF 20 | ||
183 | .default_value = GAMMA_DEF, | ||
184 | }, | ||
185 | .set = sd_setgamma, | ||
186 | .get = sd_getgamma, | ||
187 | }, | ||
161 | #define AUTOGAIN_IDX 5 | 188 | #define AUTOGAIN_IDX 5 |
162 | { | 189 | { |
163 | { | 190 | { |
@@ -173,7 +200,7 @@ static struct ctrl sd_ctrls[] = { | |||
173 | .set = sd_setautogain, | 200 | .set = sd_setautogain, |
174 | .get = sd_getautogain, | 201 | .get = sd_getautogain, |
175 | }, | 202 | }, |
176 | /* ov7630 only */ | 203 | /* ov7630/ov7648 only */ |
177 | #define VFLIP_IDX 6 | 204 | #define VFLIP_IDX 6 |
178 | { | 205 | { |
179 | { | 206 | { |
@@ -183,13 +210,13 @@ static struct ctrl sd_ctrls[] = { | |||
183 | .minimum = 0, | 210 | .minimum = 0, |
184 | .maximum = 1, | 211 | .maximum = 1, |
185 | .step = 1, | 212 | .step = 1, |
186 | #define VFLIP_DEF 1 | 213 | #define VFLIP_DEF 0 /* vflip def = 1 for ov7630 */ |
187 | .default_value = VFLIP_DEF, | 214 | .default_value = VFLIP_DEF, |
188 | }, | 215 | }, |
189 | .set = sd_setvflip, | 216 | .set = sd_setvflip, |
190 | .get = sd_getvflip, | 217 | .get = sd_getvflip, |
191 | }, | 218 | }, |
192 | /* mi0360 only */ | 219 | /* mt9v111 only */ |
193 | #define INFRARED_IDX 7 | 220 | #define INFRARED_IDX 7 |
194 | { | 221 | { |
195 | { | 222 | { |
@@ -211,18 +238,22 @@ static struct ctrl sd_ctrls[] = { | |||
211 | static __u32 ctrl_dis[] = { | 238 | static __u32 ctrl_dis[] = { |
212 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), | 239 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), |
213 | /* SENSOR_HV7131R 0 */ | 240 | /* SENSOR_HV7131R 0 */ |
214 | (1 << VFLIP_IDX), | 241 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), |
215 | /* SENSOR_MI0360 1 */ | 242 | /* SENSOR_MI0360 1 */ |
216 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), | 243 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), |
217 | /* SENSOR_MO4000 2 */ | 244 | /* SENSOR_MO4000 2 */ |
245 | (1 << VFLIP_IDX), | ||
246 | /* SENSOR_MT9V111 3 */ | ||
218 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), | 247 | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), |
219 | /* SENSOR_OM6802 3 */ | 248 | /* SENSOR_OM6802 4 */ |
220 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX), | 249 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX), |
221 | /* SENSOR_OV7630 4 */ | 250 | /* SENSOR_OV7630 5 */ |
251 | (1 << INFRARED_IDX), | ||
252 | /* SENSOR_OV7648 6 */ | ||
222 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), | 253 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), |
223 | /* SENSOR_OV7648 5 */ | 254 | /* SENSOR_OV7660 7 */ |
224 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), | 255 | (1 << AUTOGAIN_IDX) | (1 << INFRARED_IDX) | (1 << VFLIP_IDX), |
225 | /* SENSOR_OV7660 6 */ | 256 | /* SENSOR_SP80708 8 */ |
226 | }; | 257 | }; |
227 | 258 | ||
228 | static const struct v4l2_pix_format vga_mode[] = { | 259 | static const struct v4l2_pix_format vga_mode[] = { |
@@ -243,196 +274,228 @@ static const struct v4l2_pix_format vga_mode[] = { | |||
243 | .priv = 0}, | 274 | .priv = 0}, |
244 | }; | 275 | }; |
245 | 276 | ||
246 | /*Data from sn9c102p+hv71331r */ | 277 | /*Data from sn9c102p+hv7131r */ |
247 | static const __u8 sn_hv7131[] = { | 278 | static const u8 sn_hv7131[0x1c] = { |
248 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | 279 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
249 | 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20, | 280 | 0x00, 0x03, 0x64, 0x00, 0x1a, 0x20, 0x20, 0x20, |
250 | /* reg8 reg9 rega regb regc regd rege regf */ | 281 | /* reg8 reg9 rega regb regc regd rege regf */ |
251 | 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10, | 282 | 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10, |
252 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | 283 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
253 | 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41, | 284 | 0x03, 0x00, 0x00, 0x01, 0x03, 0x28, 0x1e, 0x41, |
254 | /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */ | 285 | /* reg18 reg19 reg1a reg1b */ |
255 | 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 286 | 0x0a, 0x00, 0x00, 0x00 |
256 | }; | 287 | }; |
257 | 288 | ||
258 | static const __u8 sn_mi0360[] = { | 289 | static const u8 sn_mi0360[0x1c] = { |
259 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | 290 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
260 | 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, | 291 | 0x00, 0x61, 0x44, 0x00, 0x1a, 0x20, 0x20, 0x20, |
261 | /* reg8 reg9 rega regb regc regd rege regf */ | 292 | /* reg8 reg9 rega regb regc regd rege regf */ |
262 | 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10, | 293 | 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10, |
263 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | 294 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
264 | 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61, | 295 | 0x03, 0x00, 0x00, 0x02, 0x0a, 0x28, 0x1e, 0x61, |
265 | /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */ | 296 | /* reg18 reg19 reg1a reg1b */ |
266 | 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 297 | 0x06, 0x00, 0x00, 0x00 |
267 | }; | 298 | }; |
268 | 299 | ||
269 | static const __u8 sn_mo4000[] = { | 300 | static const u8 sn_mo4000[0x1c] = { |
270 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | 301 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
271 | 0x12, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18, | 302 | 0x00, 0x23, 0x60, 0x00, 0x1a, 0x00, 0x20, 0x18, |
272 | /* reg8 reg9 rega regb regc regd rege regf */ | 303 | /* reg8 reg9 rega regb regc regd rege regf */ |
273 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 304 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
274 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | 305 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
275 | 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40, | 306 | 0x03, 0x00, 0x0b, 0x0f, 0x14, 0x28, 0x1e, 0x40, |
276 | /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */ | 307 | /* reg18 reg19 reg1a reg1b */ |
277 | 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 308 | 0x08, 0x00, 0x00, 0x00 |
278 | }; | 309 | }; |
279 | 310 | ||
280 | static const __u8 sn_om6802[] = { | 311 | static const u8 sn_mt9v111[0x1c] = { |
312 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | ||
313 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, | ||
314 | /* reg8 reg9 rega regb regc regd rege regf */ | ||
315 | 0x81, 0x5c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
316 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | ||
317 | 0x03, 0x00, 0x00, 0x02, 0x1c, 0x28, 0x1e, 0x40, | ||
318 | /* reg18 reg19 reg1a reg1b */ | ||
319 | 0x06, 0x00, 0x00, 0x00 | ||
320 | }; | ||
321 | |||
322 | static const u8 sn_om6802[0x1c] = { | ||
281 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | 323 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
282 | 0x00, 0x23, 0x72, 0x00, 0x1a, 0x34, 0x27, 0x20, | 324 | 0x00, 0x23, 0x72, 0x00, 0x1a, 0x34, 0x27, 0x20, |
283 | /* reg8 reg9 rega regb regc regd rege regf */ | 325 | /* reg8 reg9 rega regb regc regd rege regf */ |
284 | 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 326 | 0x80, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
285 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | 327 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
286 | 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40, | 328 | 0x03, 0x00, 0x51, 0x01, 0x00, 0x28, 0x1e, 0x40, |
287 | /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */ | 329 | /* reg18 reg19 reg1a reg1b */ |
288 | 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 330 | 0x05, 0x00, 0x00, 0x00 |
289 | 0x08, 0x22, 0x44, 0x63, 0x7d, 0x92, 0xa3, 0xaf, | ||
290 | 0xbc, 0xc4, 0xcd, 0xd5, 0xdc, 0xe1, 0xe8, 0xef, | ||
291 | 0xf7 | ||
292 | }; | 331 | }; |
293 | 332 | ||
294 | static const __u8 sn_ov7630[] = { | 333 | static const u8 sn_ov7630[0x1c] = { |
295 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | 334 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
296 | 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20, | 335 | 0x00, 0x21, 0x40, 0x00, 0x1a, 0x20, 0x1f, 0x20, |
297 | /* reg8 reg9 rega regb regc regd rege regf */ | 336 | /* reg8 reg9 rega regb regc regd rege regf */ |
298 | 0xa1, 0x21, 0x76, 0x21, 0x00, 0x00, 0x00, 0x10, | 337 | 0xa1, 0x21, 0x76, 0x21, 0x00, 0x00, 0x00, 0x10, |
299 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | 338 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
300 | 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2, | 339 | 0x03, 0x00, 0x04, 0x01, 0x0a, 0x28, 0x1e, 0xc2, |
301 | /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */ | 340 | /* reg18 reg19 reg1a reg1b */ |
302 | 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00 | 341 | 0x0b, 0x00, 0x00, 0x00 |
303 | }; | 342 | }; |
304 | 343 | ||
305 | static const __u8 sn_ov7648[] = { | 344 | static const u8 sn_ov7648[0x1c] = { |
306 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | 345 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
307 | 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, | 346 | 0x00, 0x63, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, |
308 | /* reg8 reg9 rega regb regc regd rege regf */ | 347 | /* reg8 reg9 rega regb regc regd rege regf */ |
309 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, | 348 | 0x81, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, |
310 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | 349 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
311 | 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00, | 350 | 0x03, 0x00, 0x00, 0x01, 0x00, 0x28, 0x1e, 0x00, |
312 | /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */ | 351 | /* reg18 reg19 reg1a reg1b */ |
313 | 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00 | 352 | 0x0b, 0x00, 0x00, 0x00 |
314 | }; | 353 | }; |
315 | 354 | ||
316 | static const __u8 sn_ov7660[] = { | 355 | static const u8 sn_ov7660[0x1c] = { |
317 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | 356 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ |
318 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, | 357 | 0x00, 0x61, 0x40, 0x00, 0x1a, 0x20, 0x20, 0x20, |
319 | /* reg8 reg9 rega regb regc regd rege regf */ | 358 | /* reg8 reg9 rega regb regc regd rege regf */ |
320 | 0x81, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10, | 359 | 0x81, 0x21, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10, |
321 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | 360 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ |
322 | 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20, | 361 | 0x03, 0x00, 0x01, 0x01, 0x08, 0x28, 0x1e, 0x20, |
323 | /* reg18 reg19 reg1a reg1b reg1c reg1d reg1e reg1f */ | 362 | /* reg18 reg19 reg1a reg1b */ |
324 | 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 363 | 0x07, 0x00, 0x00, 0x00 |
364 | }; | ||
365 | |||
366 | static const u8 sn_sp80708[0x1c] = { | ||
367 | /* reg0 reg1 reg2 reg3 reg4 reg5 reg6 reg7 */ | ||
368 | 0x00, 0x63, 0x60, 0x00, 0x1a, 0x20, 0x20, 0x20, | ||
369 | /* reg8 reg9 rega regb regc regd rege regf */ | ||
370 | 0x81, 0x18, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
371 | /* reg10 reg11 reg12 reg13 reg14 reg15 reg16 reg17 */ | ||
372 | 0x03, 0x00, 0x00, 0x03, 0x04, 0x28, 0x1e, 0x00, | ||
373 | /* reg18 reg19 reg1a reg1b */ | ||
374 | 0x07, 0x00, 0x00, 0x00 | ||
325 | }; | 375 | }; |
326 | 376 | ||
327 | /* sequence specific to the sensors - !! index = SENSOR_xxx */ | 377 | /* sequence specific to the sensors - !! index = SENSOR_xxx */ |
328 | static const __u8 *sn_tb[] = { | 378 | static const u8 *sn_tb[] = { |
329 | sn_hv7131, | 379 | sn_hv7131, |
330 | sn_mi0360, | 380 | sn_mi0360, |
331 | sn_mo4000, | 381 | sn_mo4000, |
382 | sn_mt9v111, | ||
332 | sn_om6802, | 383 | sn_om6802, |
333 | sn_ov7630, | 384 | sn_ov7630, |
334 | sn_ov7648, | 385 | sn_ov7648, |
335 | sn_ov7660 | 386 | sn_ov7660, |
387 | sn_sp80708 | ||
336 | }; | 388 | }; |
337 | 389 | ||
338 | static const __u8 gamma_def[] = { | 390 | /* default gamma table */ |
391 | static const u8 gamma_def[17] = { | ||
339 | 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, | 392 | 0x00, 0x2d, 0x46, 0x5a, 0x6c, 0x7c, 0x8b, 0x99, |
340 | 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff | 393 | 0xa6, 0xb2, 0xbf, 0xca, 0xd5, 0xe0, 0xeb, 0xf5, 0xff |
341 | }; | 394 | }; |
395 | /* gamma for sensors HV7131R and MT9V111 */ | ||
396 | static const u8 gamma_spec_1[17] = { | ||
397 | 0x08, 0x3a, 0x52, 0x65, 0x75, 0x83, 0x91, 0x9d, | ||
398 | 0xa9, 0xb4, 0xbe, 0xc8, 0xd2, 0xdb, 0xe4, 0xed, 0xf5 | ||
399 | }; | ||
400 | /* gamma for sensor SP80708 */ | ||
401 | static const u8 gamma_spec_2[17] = { | ||
402 | 0x0a, 0x2d, 0x4e, 0x68, 0x7d, 0x8f, 0x9f, 0xab, | ||
403 | 0xb7, 0xc2, 0xcc, 0xd3, 0xd8, 0xde, 0xe2, 0xe5, 0xe6 | ||
404 | }; | ||
342 | 405 | ||
343 | /* color matrix and offsets */ | 406 | /* color matrix and offsets */ |
344 | static const __u8 reg84[] = { | 407 | static const u8 reg84[] = { |
345 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */ | 408 | 0x14, 0x00, 0x27, 0x00, 0x07, 0x00, /* YR YG YB gains */ |
346 | 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */ | 409 | 0xe8, 0x0f, 0xda, 0x0f, 0x40, 0x00, /* UR UG UB */ |
347 | 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */ | 410 | 0x3e, 0x00, 0xcd, 0x0f, 0xf7, 0x0f, /* VR VG VB */ |
348 | 0x00, 0x00, 0x00 /* YUV offsets */ | 411 | 0x00, 0x00, 0x00 /* YUV offsets */ |
349 | }; | 412 | }; |
350 | static const __u8 hv7131r_sensor_init[][8] = { | 413 | static const u8 hv7131r_sensor_init[][8] = { |
351 | {0xC1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, | 414 | {0xc1, 0x11, 0x01, 0x08, 0x01, 0x00, 0x00, 0x10}, |
352 | {0xB1, 0x11, 0x34, 0x17, 0x7F, 0x00, 0x00, 0x10}, | 415 | {0xb1, 0x11, 0x34, 0x17, 0x7f, 0x00, 0x00, 0x10}, |
353 | {0xD1, 0x11, 0x40, 0xFF, 0x7F, 0x7F, 0x7F, 0x10}, | 416 | {0xd1, 0x11, 0x40, 0xff, 0x7f, 0x7f, 0x7f, 0x10}, |
354 | {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, | 417 | /* {0x91, 0x11, 0x44, 0x00, 0x00, 0x00, 0x00, 0x10}, */ |
355 | {0xD1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, | 418 | {0xd1, 0x11, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, |
356 | {0xD1, 0x11, 0x14, 0x01, 0xE2, 0x02, 0x82, 0x10}, | 419 | {0xd1, 0x11, 0x14, 0x01, 0xe2, 0x02, 0x82, 0x10}, |
357 | {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, | 420 | /* {0x91, 0x11, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, */ |
358 | 421 | ||
359 | {0xA1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, | 422 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
360 | {0xA1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, | 423 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
361 | {0xC1, 0x11, 0x25, 0x00, 0x61, 0xA8, 0x00, 0x10}, | 424 | {0xc1, 0x11, 0x25, 0x00, 0x61, 0xa8, 0x00, 0x10}, |
362 | {0xA1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10}, | 425 | {0xa1, 0x11, 0x30, 0x22, 0x00, 0x00, 0x00, 0x10}, |
363 | {0xC1, 0x11, 0x31, 0x20, 0x2E, 0x20, 0x00, 0x10}, | 426 | {0xc1, 0x11, 0x31, 0x20, 0x2e, 0x20, 0x00, 0x10}, |
364 | {0xC1, 0x11, 0x25, 0x00, 0xC3, 0x50, 0x00, 0x10}, | 427 | {0xc1, 0x11, 0x25, 0x00, 0xc3, 0x50, 0x00, 0x10}, |
365 | {0xA1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */ | 428 | {0xa1, 0x11, 0x30, 0x07, 0x00, 0x00, 0x00, 0x10}, /* gain14 */ |
366 | {0xC1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */ | 429 | {0xc1, 0x11, 0x31, 0x10, 0x10, 0x10, 0x00, 0x10}, /* r g b 101a10 */ |
367 | 430 | ||
368 | {0xA1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, | 431 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
369 | {0xA1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, | 432 | {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, |
370 | {0xA1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10}, | 433 | {0xa1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10}, |
371 | {0xA1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, | 434 | {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
372 | {0xA1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10}, | 435 | {0xa1, 0x11, 0x23, 0x09, 0x00, 0x00, 0x00, 0x10}, |
373 | 436 | ||
374 | {0xA1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, | 437 | {0xa1, 0x11, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10}, |
375 | {0xA1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, | 438 | {0xa1, 0x11, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, |
376 | {0xA1, 0x11, 0x21, 0xD0, 0x00, 0x00, 0x00, 0x10}, | 439 | {0xa1, 0x11, 0x21, 0xd0, 0x00, 0x00, 0x00, 0x10}, |
377 | {0xA1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, | 440 | {0xa1, 0x11, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
378 | {0xA1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10}, | 441 | {0xa1, 0x11, 0x23, 0x10, 0x00, 0x00, 0x00, 0x10}, |
379 | {} | 442 | {} |
380 | }; | 443 | }; |
381 | static const __u8 mi0360_sensor_init[][8] = { | 444 | static const u8 mi0360_sensor_init[][8] = { |
382 | {0xB1, 0x5D, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, | 445 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, |
383 | {0xB1, 0x5D, 0x0D, 0x00, 0x01, 0x00, 0x00, 0x10}, | 446 | {0xb1, 0x5d, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, |
384 | {0xB1, 0x5D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x10}, | 447 | {0xb1, 0x5d, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, |
385 | {0xD1, 0x5D, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10}, | 448 | {0xd1, 0x5d, 0x01, 0x00, 0x08, 0x00, 0x16, 0x10}, |
386 | {0xD1, 0x5D, 0x03, 0x01, 0xE2, 0x02, 0x82, 0x10}, | 449 | {0xd1, 0x5d, 0x03, 0x01, 0xe2, 0x02, 0x82, 0x10}, |
387 | {0xD1, 0x5D, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10}, | 450 | {0xd1, 0x5d, 0x05, 0x00, 0x09, 0x00, 0x53, 0x10}, |
388 | {0xB1, 0x5D, 0x0D, 0x00, 0x02, 0x00, 0x00, 0x10}, | 451 | {0xb1, 0x5d, 0x0d, 0x00, 0x02, 0x00, 0x00, 0x10}, |
389 | {0xD1, 0x5D, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x10}, | 452 | {0xd1, 0x5d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
390 | {0xD1, 0x5D, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x10}, | 453 | {0xd1, 0x5d, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
391 | {0xD1, 0x5D, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x10}, | 454 | {0xd1, 0x5d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x10}, |
392 | {0xD1, 0x5D, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, | 455 | {0xd1, 0x5d, 0x10, 0x00, 0x00, 0x00, 0x00, 0x10}, |
393 | {0xD1, 0x5D, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, | 456 | {0xd1, 0x5d, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
394 | {0xD1, 0x5D, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10}, | 457 | {0xd1, 0x5d, 0x14, 0x00, 0x00, 0x00, 0x00, 0x10}, |
395 | {0xD1, 0x5D, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, | 458 | {0xd1, 0x5d, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, |
396 | {0xD1, 0x5D, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, | 459 | {0xd1, 0x5d, 0x18, 0x00, 0x00, 0x00, 0x00, 0x10}, |
397 | {0xD1, 0x5D, 0x1A, 0x00, 0x00, 0x00, 0x00, 0x10}, | 460 | {0xd1, 0x5d, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
398 | {0xD1, 0x5D, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x10}, | 461 | {0xd1, 0x5d, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
399 | {0xB1, 0x5D, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10}, | 462 | {0xb1, 0x5d, 0x32, 0x00, 0x00, 0x00, 0x00, 0x10}, |
400 | {0xD1, 0x5D, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10}, | 463 | {0xd1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10}, |
401 | {0xD1, 0x5D, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, | 464 | {0xd1, 0x5d, 0x22, 0x00, 0x00, 0x00, 0x00, 0x10}, |
402 | {0xD1, 0x5D, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10}, | 465 | {0xd1, 0x5d, 0x24, 0x00, 0x00, 0x00, 0x00, 0x10}, |
403 | {0xD1, 0x5D, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10}, | 466 | {0xd1, 0x5d, 0x26, 0x00, 0x00, 0x00, 0x24, 0x10}, |
404 | {0xD1, 0x5D, 0x2F, 0xF7, 0xB0, 0x00, 0x04, 0x10}, | 467 | {0xd1, 0x5d, 0x2f, 0xf7, 0xB0, 0x00, 0x04, 0x10}, |
405 | {0xD1, 0x5D, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10}, | 468 | {0xd1, 0x5d, 0x31, 0x00, 0x00, 0x00, 0x00, 0x10}, |
406 | {0xD1, 0x5D, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10}, | 469 | {0xd1, 0x5d, 0x33, 0x00, 0x00, 0x01, 0x00, 0x10}, |
407 | {0xB1, 0x5D, 0x3D, 0x06, 0x8F, 0x00, 0x00, 0x10}, | 470 | {0xb1, 0x5d, 0x3d, 0x06, 0x8f, 0x00, 0x00, 0x10}, |
408 | {0xD1, 0x5D, 0x40, 0x01, 0xE0, 0x00, 0xD1, 0x10}, | 471 | {0xd1, 0x5d, 0x40, 0x01, 0xe0, 0x00, 0xd1, 0x10}, |
409 | {0xB1, 0x5D, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10}, | 472 | {0xb1, 0x5d, 0x44, 0x00, 0x82, 0x00, 0x00, 0x10}, |
410 | {0xD1, 0x5D, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10}, | 473 | {0xd1, 0x5d, 0x58, 0x00, 0x78, 0x00, 0x43, 0x10}, |
411 | {0xD1, 0x5D, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x10}, | 474 | {0xd1, 0x5d, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
412 | {0xD1, 0x5D, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x10}, | 475 | {0xd1, 0x5d, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x10}, |
413 | {0xD1, 0x5D, 0x5E, 0x00, 0x00, 0xA3, 0x1D, 0x10}, | 476 | {0xd1, 0x5d, 0x5e, 0x00, 0x00, 0xa3, 0x1d, 0x10}, |
414 | {0xB1, 0x5D, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10}, | 477 | {0xb1, 0x5d, 0x62, 0x04, 0x11, 0x00, 0x00, 0x10}, |
415 | 478 | ||
416 | {0xB1, 0x5D, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10}, | 479 | {0xb1, 0x5d, 0x20, 0x91, 0x01, 0x00, 0x00, 0x10}, |
417 | {0xB1, 0x5D, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10}, | 480 | {0xb1, 0x5d, 0x20, 0x11, 0x01, 0x00, 0x00, 0x10}, |
418 | {0xB1, 0x5D, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10}, | 481 | {0xb1, 0x5d, 0x09, 0x00, 0x64, 0x00, 0x00, 0x10}, |
419 | {0xD1, 0x5D, 0x2B, 0x00, 0xA0, 0x00, 0xB0, 0x10}, | 482 | {0xd1, 0x5d, 0x2b, 0x00, 0xa0, 0x00, 0xb0, 0x10}, |
420 | {0xD1, 0x5D, 0x2D, 0x00, 0xA0, 0x00, 0xA0, 0x10}, | 483 | {0xd1, 0x5d, 0x2d, 0x00, 0xa0, 0x00, 0xa0, 0x10}, |
421 | 484 | ||
422 | {0xB1, 0x5D, 0x0A, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */ | 485 | {0xb1, 0x5d, 0x0a, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor clck ?2 */ |
423 | {0xB1, 0x5D, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10}, | 486 | {0xb1, 0x5d, 0x06, 0x00, 0x30, 0x00, 0x00, 0x10}, |
424 | {0xB1, 0x5D, 0x05, 0x00, 0x0A, 0x00, 0x00, 0x10}, | 487 | {0xb1, 0x5d, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, |
425 | {0xB1, 0x5D, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */ | 488 | {0xb1, 0x5d, 0x09, 0x02, 0x35, 0x00, 0x00, 0x10}, /* exposure 2 */ |
426 | 489 | ||
427 | {0xD1, 0x5D, 0x2B, 0x00, 0xB9, 0x00, 0xE3, 0x10}, | 490 | {0xd1, 0x5d, 0x2b, 0x00, 0xb9, 0x00, 0xe3, 0x10}, |
428 | {0xD1, 0x5D, 0x2D, 0x00, 0x5f, 0x00, 0xB9, 0x10}, /* 42 */ | 491 | {0xd1, 0x5d, 0x2d, 0x00, 0x5f, 0x00, 0xb9, 0x10}, /* 42 */ |
429 | /* {0xB1, 0x5D, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */ | 492 | /* {0xb1, 0x5d, 0x35, 0x00, 0x67, 0x00, 0x00, 0x10}, * gain orig */ |
430 | /* {0xB1, 0x5D, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */ | 493 | /* {0xb1, 0x5d, 0x35, 0x00, 0x20, 0x00, 0x00, 0x10}, * gain */ |
431 | {0xB1, 0x5D, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */ | 494 | {0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10}, /* update */ |
432 | {0xB1, 0x5D, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ | 495 | {0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, /* sensor on */ |
433 | {} | 496 | {} |
434 | }; | 497 | }; |
435 | static const __u8 mo4000_sensor_init[][8] = { | 498 | static const u8 mo4000_sensor_init[][8] = { |
436 | {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, | 499 | {0xa1, 0x21, 0x01, 0x02, 0x00, 0x00, 0x00, 0x10}, |
437 | {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, | 500 | {0xa1, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x10}, |
438 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, | 501 | {0xa1, 0x21, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10}, |
@@ -455,7 +518,49 @@ static const __u8 mo4000_sensor_init[][8] = { | |||
455 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, | 518 | {0xa1, 0x21, 0x11, 0x38, 0x00, 0x00, 0x00, 0x10}, |
456 | {} | 519 | {} |
457 | }; | 520 | }; |
458 | static __u8 om6802_sensor_init[][8] = { | 521 | static const u8 mt9v111_sensor_init[][8] = { |
522 | {0xb1, 0x5c, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x10}, /* reset? */ | ||
523 | /* delay 20 ms */ | ||
524 | {0xb1, 0x5c, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
525 | {0xb1, 0x5c, 0x01, 0x00, 0x01, 0x00, 0x00, 0x10}, /* IFP select */ | ||
526 | {0xb1, 0x5c, 0x08, 0x04, 0x80, 0x00, 0x00, 0x10}, /* output fmt ctrl */ | ||
527 | {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, /* op mode ctrl */ | ||
528 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, | ||
529 | {0xb1, 0x5c, 0x03, 0x01, 0xe1, 0x00, 0x00, 0x10}, | ||
530 | {0xb1, 0x5c, 0x04, 0x02, 0x81, 0x00, 0x00, 0x10}, | ||
531 | {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10}, | ||
532 | {0xb1, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, /* sensor select */ | ||
533 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, | ||
534 | {0xb1, 0x5c, 0x03, 0x01, 0xe6, 0x00, 0x00, 0x10}, | ||
535 | {0xb1, 0x5c, 0x04, 0x02, 0x86, 0x00, 0x00, 0x10}, | ||
536 | {0xb1, 0x5c, 0x05, 0x00, 0x04, 0x00, 0x00, 0x10}, | ||
537 | {0xb1, 0x5c, 0x06, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
538 | {0xb1, 0x5c, 0x08, 0x00, 0x08, 0x00, 0x00, 0x10}, /* row start */ | ||
539 | {0xb1, 0x5c, 0x0e, 0x00, 0x08, 0x00, 0x00, 0x10}, | ||
540 | {0xb1, 0x5c, 0x02, 0x00, 0x16, 0x00, 0x00, 0x10}, /* col start */ | ||
541 | {0xb1, 0x5c, 0x03, 0x01, 0xe7, 0x00, 0x00, 0x10}, /* window height */ | ||
542 | {0xb1, 0x5c, 0x04, 0x02, 0x87, 0x00, 0x00, 0x10}, /* window width */ | ||
543 | {0xb1, 0x5c, 0x07, 0x30, 0x02, 0x00, 0x00, 0x10}, /* output ctrl */ | ||
544 | {0xb1, 0x5c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x10}, /* shutter delay */ | ||
545 | {0xb1, 0x5c, 0x12, 0x00, 0xb0, 0x00, 0x00, 0x10}, /* zoom col start */ | ||
546 | {0xb1, 0x5c, 0x13, 0x00, 0x7c, 0x00, 0x00, 0x10}, /* zoom row start */ | ||
547 | {0xb1, 0x5c, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x10}, /* digital zoom */ | ||
548 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, /* read mode */ | ||
549 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
550 | /*******/ | ||
551 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
552 | {0xb1, 0x5c, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
553 | {0xb1, 0x5c, 0x09, 0x01, 0x2c, 0x00, 0x00, 0x10}, | ||
554 | {0xd1, 0x5c, 0x2b, 0x00, 0x33, 0x00, 0xa0, 0x10}, /* green1 gain */ | ||
555 | {0xd1, 0x5c, 0x2d, 0x00, 0xa0, 0x00, 0x33, 0x10}, /* red gain */ | ||
556 | /*******/ | ||
557 | {0xb1, 0x5c, 0x06, 0x00, 0x1e, 0x00, 0x00, 0x10}, /* vert blanking */ | ||
558 | {0xb1, 0x5c, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x10}, /* horiz blanking */ | ||
559 | {0xd1, 0x5c, 0x2c, 0x00, 0xad, 0x00, 0xad, 0x10}, /* blue gain */ | ||
560 | {0xb1, 0x5c, 0x35, 0x01, 0xc0, 0x00, 0x00, 0x10}, /* global gain */ | ||
561 | {} | ||
562 | }; | ||
563 | static const u8 om6802_sensor_init[][8] = { | ||
459 | {0xa0, 0x34, 0x90, 0x05, 0x00, 0x00, 0x00, 0x10}, | 564 | {0xa0, 0x34, 0x90, 0x05, 0x00, 0x00, 0x00, 0x10}, |
460 | {0xa0, 0x34, 0x49, 0x85, 0x00, 0x00, 0x00, 0x10}, | 565 | {0xa0, 0x34, 0x49, 0x85, 0x00, 0x00, 0x00, 0x10}, |
461 | {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10}, | 566 | {0xa0, 0x34, 0x5a, 0xc0, 0x00, 0x00, 0x00, 0x10}, |
@@ -489,7 +594,7 @@ static __u8 om6802_sensor_init[][8] = { | |||
489 | /* {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, */ | 594 | /* {0xa0, 0x34, 0x69, 0x01, 0x00, 0x00, 0x00, 0x10}, */ |
490 | {} | 595 | {} |
491 | }; | 596 | }; |
492 | static const __u8 ov7630_sensor_init[][8] = { | 597 | static const u8 ov7630_sensor_init[][8] = { |
493 | {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10}, | 598 | {0xa1, 0x21, 0x76, 0x01, 0x00, 0x00, 0x00, 0x10}, |
494 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, | 599 | {0xa1, 0x21, 0x12, 0xc8, 0x00, 0x00, 0x00, 0x10}, |
495 | /* win: delay 20ms */ | 600 | /* win: delay 20ms */ |
@@ -543,7 +648,7 @@ static const __u8 ov7630_sensor_init[][8] = { | |||
543 | {} | 648 | {} |
544 | }; | 649 | }; |
545 | 650 | ||
546 | static const __u8 ov7648_sensor_init[][8] = { | 651 | static const u8 ov7648_sensor_init[][8] = { |
547 | {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10}, | 652 | {0xa1, 0x21, 0x76, 0x00, 0x00, 0x00, 0x00, 0x10}, |
548 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ | 653 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset */ |
549 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, | 654 | {0xa1, 0x21, 0x12, 0x00, 0x00, 0x00, 0x00, 0x10}, |
@@ -572,7 +677,8 @@ static const __u8 ov7648_sensor_init[][8] = { | |||
572 | {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, | 677 | {0xb1, 0x21, 0x2d, 0x85, 0x00, 0x00, 0x00, 0x10}, |
573 | /*...*/ | 678 | /*...*/ |
574 | /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */ | 679 | /* {0xa1, 0x21, 0x12, 0x08, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
575 | /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, jfm done */ | 680 | /* {0xa1, 0x21, 0x75, 0x06, 0x00, 0x00, 0x00, 0x10}, * COMN |
681 | * set by setvflip */ | ||
576 | {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10}, | 682 | {0xa1, 0x21, 0x19, 0x02, 0x00, 0x00, 0x00, 0x10}, |
577 | {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10}, | 683 | {0xa1, 0x21, 0x10, 0x32, 0x00, 0x00, 0x00, 0x10}, |
578 | /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ | 684 | /* {0xa1, 0x21, 0x16, 0x00, 0x00, 0x00, 0x00, 0x10}, jfm done */ |
@@ -589,7 +695,7 @@ static const __u8 ov7648_sensor_init[][8] = { | |||
589 | {} | 695 | {} |
590 | }; | 696 | }; |
591 | 697 | ||
592 | static const __u8 ov7660_sensor_init[][8] = { | 698 | static const u8 ov7660_sensor_init[][8] = { |
593 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ | 699 | {0xa1, 0x21, 0x12, 0x80, 0x00, 0x00, 0x00, 0x10}, /* reset SCCB */ |
594 | /* (delay 20ms) */ | 700 | /* (delay 20ms) */ |
595 | {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, | 701 | {0xa1, 0x21, 0x12, 0x05, 0x00, 0x00, 0x00, 0x10}, |
@@ -678,28 +784,92 @@ static const __u8 ov7660_sensor_init[][8] = { | |||
678 | {} | 784 | {} |
679 | }; | 785 | }; |
680 | 786 | ||
681 | static const __u8 qtable4[] = { | 787 | static const u8 sp80708_sensor_init[][8] = { |
682 | 0x06, 0x04, 0x04, 0x06, 0x04, 0x04, 0x06, 0x06, 0x06, 0x06, 0x08, 0x06, | 788 | {0xa1, 0x18, 0x06, 0xf9, 0x00, 0x00, 0x00, 0x10}, |
683 | 0x06, 0x08, 0x0A, 0x11, | 789 | {0xa1, 0x18, 0x09, 0x1f, 0x00, 0x00, 0x00, 0x10}, |
684 | 0x0A, 0x0A, 0x08, 0x08, 0x0A, 0x15, 0x0F, 0x0F, 0x0C, 0x11, 0x19, 0x15, | 790 | {0xa1, 0x18, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x10}, |
685 | 0x19, 0x19, 0x17, 0x15, | 791 | {0xa1, 0x18, 0x0d, 0xc0, 0x00, 0x00, 0x00, 0x10}, |
686 | 0x17, 0x17, 0x1B, 0x1D, 0x25, 0x21, 0x1B, 0x1D, 0x23, 0x1D, 0x17, 0x17, | 792 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, |
687 | 0x21, 0x2E, 0x21, 0x23, | 793 | {0xa1, 0x18, 0x0f, 0x0f, 0x00, 0x00, 0x00, 0x10}, |
688 | 0x27, 0x29, 0x2C, 0x2C, 0x2C, 0x19, 0x1F, 0x30, 0x32, 0x2E, 0x29, 0x32, | 794 | {0xa1, 0x18, 0x10, 0x40, 0x00, 0x00, 0x00, 0x10}, |
689 | 0x25, 0x29, 0x2C, 0x29, | 795 | {0xa1, 0x18, 0x11, 0x4e, 0x00, 0x00, 0x00, 0x10}, |
690 | 0x06, 0x08, 0x08, 0x0A, 0x08, 0x0A, 0x13, 0x0A, 0x0A, 0x13, 0x29, 0x1B, | 796 | {0xa1, 0x18, 0x12, 0x53, 0x00, 0x00, 0x00, 0x10}, |
691 | 0x17, 0x1B, 0x29, 0x29, | 797 | {0xa1, 0x18, 0x15, 0x80, 0x00, 0x00, 0x00, 0x10}, |
692 | 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, | 798 | {0xa1, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x10}, |
693 | 0x29, 0x29, 0x29, 0x29, | 799 | {0xa1, 0x18, 0x19, 0x18, 0x00, 0x00, 0x00, 0x10}, |
694 | 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, | 800 | {0xa1, 0x18, 0x1a, 0x10, 0x00, 0x00, 0x00, 0x10}, |
695 | 0x29, 0x29, 0x29, 0x29, | 801 | {0xa1, 0x18, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x10}, |
696 | 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, | 802 | {0xa1, 0x18, 0x1c, 0x28, 0x00, 0x00, 0x00, 0x10}, |
697 | 0x29, 0x29, 0x29, 0x29 | 803 | {0xa1, 0x18, 0x1d, 0x02, 0x00, 0x00, 0x00, 0x10}, |
804 | {0xa1, 0x18, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x10}, | ||
805 | {0xa1, 0x18, 0x26, 0x04, 0x00, 0x00, 0x00, 0x10}, | ||
806 | {0xa1, 0x18, 0x27, 0x1e, 0x00, 0x00, 0x00, 0x10}, | ||
807 | {0xa1, 0x18, 0x28, 0x5a, 0x00, 0x00, 0x00, 0x10}, | ||
808 | {0xa1, 0x18, 0x29, 0x28, 0x00, 0x00, 0x00, 0x10}, | ||
809 | {0xa1, 0x18, 0x2a, 0x78, 0x00, 0x00, 0x00, 0x10}, | ||
810 | {0xa1, 0x18, 0x2b, 0x01, 0x00, 0x00, 0x00, 0x10}, | ||
811 | {0xa1, 0x18, 0x2c, 0xf7, 0x00, 0x00, 0x00, 0x10}, | ||
812 | {0xa1, 0x18, 0x2d, 0x2d, 0x00, 0x00, 0x00, 0x10}, | ||
813 | {0xa1, 0x18, 0x2e, 0xd5, 0x00, 0x00, 0x00, 0x10}, | ||
814 | {0xa1, 0x18, 0x39, 0x42, 0x00, 0x00, 0x00, 0x10}, | ||
815 | {0xa1, 0x18, 0x3a, 0x67, 0x00, 0x00, 0x00, 0x10}, | ||
816 | {0xa1, 0x18, 0x3b, 0x87, 0x00, 0x00, 0x00, 0x10}, | ||
817 | {0xa1, 0x18, 0x3c, 0xa3, 0x00, 0x00, 0x00, 0x10}, | ||
818 | {0xa1, 0x18, 0x3d, 0xb0, 0x00, 0x00, 0x00, 0x10}, | ||
819 | {0xa1, 0x18, 0x3e, 0xbc, 0x00, 0x00, 0x00, 0x10}, | ||
820 | {0xa1, 0x18, 0x3f, 0xc8, 0x00, 0x00, 0x00, 0x10}, | ||
821 | {0xa1, 0x18, 0x40, 0xd4, 0x00, 0x00, 0x00, 0x10}, | ||
822 | {0xa1, 0x18, 0x41, 0xdf, 0x00, 0x00, 0x00, 0x10}, | ||
823 | {0xa1, 0x18, 0x42, 0xea, 0x00, 0x00, 0x00, 0x10}, | ||
824 | {0xa1, 0x18, 0x43, 0xf5, 0x00, 0x00, 0x00, 0x10}, | ||
825 | {0xa1, 0x18, 0x45, 0x80, 0x00, 0x00, 0x00, 0x10}, | ||
826 | {0xa1, 0x18, 0x46, 0x60, 0x00, 0x00, 0x00, 0x10}, | ||
827 | {0xa1, 0x18, 0x47, 0x50, 0x00, 0x00, 0x00, 0x10}, | ||
828 | {0xa1, 0x18, 0x48, 0x30, 0x00, 0x00, 0x00, 0x10}, | ||
829 | {0xa1, 0x18, 0x49, 0x01, 0x00, 0x00, 0x00, 0x10}, | ||
830 | {0xa1, 0x18, 0x4d, 0xae, 0x00, 0x00, 0x00, 0x10}, | ||
831 | {0xa1, 0x18, 0x4e, 0x03, 0x00, 0x00, 0x00, 0x10}, | ||
832 | {0xa1, 0x18, 0x4f, 0x66, 0x00, 0x00, 0x00, 0x10}, | ||
833 | {0xa1, 0x18, 0x50, 0x1c, 0x00, 0x00, 0x00, 0x10}, | ||
834 | {0xa1, 0x18, 0x44, 0x10, 0x00, 0x00, 0x00, 0x10}, | ||
835 | {0xa1, 0x18, 0x4a, 0x30, 0x00, 0x00, 0x00, 0x10}, | ||
836 | {0xa1, 0x18, 0x51, 0x80, 0x00, 0x00, 0x00, 0x10}, | ||
837 | {0xa1, 0x18, 0x52, 0x80, 0x00, 0x00, 0x00, 0x10}, | ||
838 | {0xa1, 0x18, 0x53, 0x80, 0x00, 0x00, 0x00, 0x10}, | ||
839 | {0xa1, 0x18, 0x54, 0x80, 0x00, 0x00, 0x00, 0x10}, | ||
840 | {0xa1, 0x18, 0x55, 0x80, 0x00, 0x00, 0x00, 0x10}, | ||
841 | {0xa1, 0x18, 0x56, 0x80, 0x00, 0x00, 0x00, 0x10}, | ||
842 | {0xa1, 0x18, 0x57, 0xe0, 0x00, 0x00, 0x00, 0x10}, | ||
843 | {0xa1, 0x18, 0x58, 0xc0, 0x00, 0x00, 0x00, 0x10}, | ||
844 | {0xa1, 0x18, 0x59, 0xab, 0x00, 0x00, 0x00, 0x10}, | ||
845 | {0xa1, 0x18, 0x5a, 0xa0, 0x00, 0x00, 0x00, 0x10}, | ||
846 | {0xa1, 0x18, 0x5b, 0x99, 0x00, 0x00, 0x00, 0x10}, | ||
847 | {0xa1, 0x18, 0x5c, 0x90, 0x00, 0x00, 0x00, 0x10}, | ||
848 | {0xa1, 0x18, 0x5e, 0x24, 0x00, 0x00, 0x00, 0x10}, | ||
849 | {0xa1, 0x18, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
850 | {0xa1, 0x18, 0x60, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
851 | {0xa1, 0x18, 0x61, 0x73, 0x00, 0x00, 0x00, 0x10}, | ||
852 | {0xa1, 0x18, 0x63, 0x42, 0x00, 0x00, 0x00, 0x10}, | ||
853 | {0xa1, 0x18, 0x64, 0x42, 0x00, 0x00, 0x00, 0x10}, | ||
854 | {0xa1, 0x18, 0x65, 0x42, 0x00, 0x00, 0x00, 0x10}, | ||
855 | {0xa1, 0x18, 0x66, 0x24, 0x00, 0x00, 0x00, 0x10}, | ||
856 | {0xa1, 0x18, 0x67, 0x24, 0x00, 0x00, 0x00, 0x10}, | ||
857 | {0xa1, 0x18, 0x68, 0x08, 0x00, 0x00, 0x00, 0x10}, | ||
858 | {0xa1, 0x18, 0x2f, 0xc9, 0x00, 0x00, 0x00, 0x10}, | ||
859 | /********/ | ||
860 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, | ||
861 | {0xa1, 0x18, 0x0c, 0x04, 0x00, 0x00, 0x00, 0x10}, | ||
862 | {0xa1, 0x18, 0x03, 0x01, 0x00, 0x00, 0x00, 0x10}, | ||
863 | {0xa1, 0x18, 0x04, 0xa4, 0x00, 0x00, 0x00, 0x10}, | ||
864 | {0xa1, 0x18, 0x14, 0x3f, 0x00, 0x00, 0x00, 0x10}, | ||
865 | {0xa1, 0x18, 0x5d, 0x80, 0x00, 0x00, 0x00, 0x10}, | ||
866 | {0xb1, 0x18, 0x11, 0x40, 0x40, 0x00, 0x00, 0x10}, | ||
867 | {} | ||
698 | }; | 868 | }; |
699 | 869 | ||
700 | /* read <len> bytes to gspca_dev->usb_buf */ | 870 | /* read <len> bytes to gspca_dev->usb_buf */ |
701 | static void reg_r(struct gspca_dev *gspca_dev, | 871 | static void reg_r(struct gspca_dev *gspca_dev, |
702 | __u16 value, int len) | 872 | u16 value, int len) |
703 | { | 873 | { |
704 | #ifdef GSPCA_DEBUG | 874 | #ifdef GSPCA_DEBUG |
705 | if (len > USB_BUF_SZ) { | 875 | if (len > USB_BUF_SZ) { |
@@ -718,10 +888,10 @@ static void reg_r(struct gspca_dev *gspca_dev, | |||
718 | } | 888 | } |
719 | 889 | ||
720 | static void reg_w1(struct gspca_dev *gspca_dev, | 890 | static void reg_w1(struct gspca_dev *gspca_dev, |
721 | __u16 value, | 891 | u16 value, |
722 | __u8 data) | 892 | u8 data) |
723 | { | 893 | { |
724 | PDEBUG(D_USBO, "reg_w1 [%02x] = %02x", value, data); | 894 | PDEBUG(D_USBO, "reg_w1 [%04x] = %02x", value, data); |
725 | gspca_dev->usb_buf[0] = data; | 895 | gspca_dev->usb_buf[0] = data; |
726 | usb_control_msg(gspca_dev->dev, | 896 | usb_control_msg(gspca_dev->dev, |
727 | usb_sndctrlpipe(gspca_dev->dev, 0), | 897 | usb_sndctrlpipe(gspca_dev->dev, 0), |
@@ -733,11 +903,11 @@ static void reg_w1(struct gspca_dev *gspca_dev, | |||
733 | 500); | 903 | 500); |
734 | } | 904 | } |
735 | static void reg_w(struct gspca_dev *gspca_dev, | 905 | static void reg_w(struct gspca_dev *gspca_dev, |
736 | __u16 value, | 906 | u16 value, |
737 | const __u8 *buffer, | 907 | const u8 *buffer, |
738 | int len) | 908 | int len) |
739 | { | 909 | { |
740 | PDEBUG(D_USBO, "reg_w [%02x] = %02x %02x ..", | 910 | PDEBUG(D_USBO, "reg_w [%04x] = %02x %02x ..", |
741 | value, buffer[0], buffer[1]); | 911 | value, buffer[0], buffer[1]); |
742 | #ifdef GSPCA_DEBUG | 912 | #ifdef GSPCA_DEBUG |
743 | if (len > USB_BUF_SZ) { | 913 | if (len > USB_BUF_SZ) { |
@@ -756,7 +926,7 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
756 | } | 926 | } |
757 | 927 | ||
758 | /* I2C write 1 byte */ | 928 | /* I2C write 1 byte */ |
759 | static void i2c_w1(struct gspca_dev *gspca_dev, __u8 reg, __u8 val) | 929 | static void i2c_w1(struct gspca_dev *gspca_dev, u8 reg, u8 val) |
760 | { | 930 | { |
761 | struct sd *sd = (struct sd *) gspca_dev; | 931 | struct sd *sd = (struct sd *) gspca_dev; |
762 | 932 | ||
@@ -781,7 +951,7 @@ static void i2c_w1(struct gspca_dev *gspca_dev, __u8 reg, __u8 val) | |||
781 | 951 | ||
782 | /* I2C write 8 bytes */ | 952 | /* I2C write 8 bytes */ |
783 | static void i2c_w8(struct gspca_dev *gspca_dev, | 953 | static void i2c_w8(struct gspca_dev *gspca_dev, |
784 | const __u8 *buffer) | 954 | const u8 *buffer) |
785 | { | 955 | { |
786 | memcpy(gspca_dev->usb_buf, buffer, 8); | 956 | memcpy(gspca_dev->usb_buf, buffer, 8); |
787 | usb_control_msg(gspca_dev->dev, | 957 | usb_control_msg(gspca_dev->dev, |
@@ -795,10 +965,10 @@ static void i2c_w8(struct gspca_dev *gspca_dev, | |||
795 | } | 965 | } |
796 | 966 | ||
797 | /* read 5 bytes in gspca_dev->usb_buf */ | 967 | /* read 5 bytes in gspca_dev->usb_buf */ |
798 | static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg) | 968 | static void i2c_r5(struct gspca_dev *gspca_dev, u8 reg) |
799 | { | 969 | { |
800 | struct sd *sd = (struct sd *) gspca_dev; | 970 | struct sd *sd = (struct sd *) gspca_dev; |
801 | __u8 mode[8]; | 971 | u8 mode[8]; |
802 | 972 | ||
803 | mode[0] = 0x81 | 0x10; | 973 | mode[0] = 0x81 | 0x10; |
804 | mode[1] = sd->i2c_base; | 974 | mode[1] = sd->i2c_base; |
@@ -817,7 +987,7 @@ static void i2c_r5(struct gspca_dev *gspca_dev, __u8 reg) | |||
817 | reg_r(gspca_dev, 0x0a, 5); | 987 | reg_r(gspca_dev, 0x0a, 5); |
818 | } | 988 | } |
819 | 989 | ||
820 | static int probesensor(struct gspca_dev *gspca_dev) | 990 | static int hv7131r_probe(struct gspca_dev *gspca_dev) |
821 | { | 991 | { |
822 | i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */ | 992 | i2c_w1(gspca_dev, 0x02, 0); /* sensor wakeup */ |
823 | msleep(10); | 993 | msleep(10); |
@@ -839,16 +1009,66 @@ static int probesensor(struct gspca_dev *gspca_dev) | |||
839 | return -ENODEV; | 1009 | return -ENODEV; |
840 | } | 1010 | } |
841 | 1011 | ||
1012 | static void mi0360_probe(struct gspca_dev *gspca_dev) | ||
1013 | { | ||
1014 | struct sd *sd = (struct sd *) gspca_dev; | ||
1015 | int i, j; | ||
1016 | u16 val = 0; | ||
1017 | static const u8 probe_tb[][4][8] = { | ||
1018 | { /* mi0360 */ | ||
1019 | {0xb0, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10}, | ||
1020 | {0x90, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
1021 | {0xa2, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
1022 | {0xb0, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10} | ||
1023 | }, | ||
1024 | { /* mt9v111 */ | ||
1025 | {0xb0, 0x5c, 0x01, 0x00, 0x04, 0x00, 0x00, 0x10}, | ||
1026 | {0x90, 0x5c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
1027 | {0xa2, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10}, | ||
1028 | {} | ||
1029 | }, | ||
1030 | }; | ||
1031 | |||
1032 | for (i = 0; i < ARRAY_SIZE(probe_tb); i++) { | ||
1033 | reg_w1(gspca_dev, 0x17, 0x62); | ||
1034 | reg_w1(gspca_dev, 0x01, 0x08); | ||
1035 | for (j = 0; j < 3; j++) | ||
1036 | i2c_w8(gspca_dev, probe_tb[i][j]); | ||
1037 | msleep(2); | ||
1038 | reg_r(gspca_dev, 0x0a, 5); | ||
1039 | val = (gspca_dev->usb_buf[3] << 8) | gspca_dev->usb_buf[4]; | ||
1040 | if (probe_tb[i][3][0] != 0) | ||
1041 | i2c_w8(gspca_dev, probe_tb[i][3]); | ||
1042 | reg_w1(gspca_dev, 0x01, 0x29); | ||
1043 | reg_w1(gspca_dev, 0x17, 0x42); | ||
1044 | if (val != 0xffff) | ||
1045 | break; | ||
1046 | } | ||
1047 | switch (val) { | ||
1048 | case 0x823a: | ||
1049 | PDEBUG(D_PROBE, "Sensor mt9v111"); | ||
1050 | sd->sensor = SENSOR_MT9V111; | ||
1051 | sd->i2c_base = 0x5c; | ||
1052 | break; | ||
1053 | case 0x8243: | ||
1054 | PDEBUG(D_PROBE, "Sensor mi0360"); | ||
1055 | break; | ||
1056 | default: | ||
1057 | PDEBUG(D_PROBE, "Unknown sensor %04x - forced to mi0360", val); | ||
1058 | break; | ||
1059 | } | ||
1060 | } | ||
1061 | |||
842 | static int configure_gpio(struct gspca_dev *gspca_dev, | 1062 | static int configure_gpio(struct gspca_dev *gspca_dev, |
843 | const __u8 *sn9c1xx) | 1063 | const u8 *sn9c1xx) |
844 | { | 1064 | { |
845 | struct sd *sd = (struct sd *) gspca_dev; | 1065 | struct sd *sd = (struct sd *) gspca_dev; |
846 | const __u8 *reg9a; | 1066 | const u8 *reg9a; |
847 | static const __u8 reg9a_def[] = | 1067 | static const u8 reg9a_def[] = |
848 | {0x08, 0x40, 0x20, 0x10, 0x00, 0x04}; | 1068 | {0x08, 0x40, 0x20, 0x10, 0x00, 0x04}; |
849 | static const __u8 reg9a_sn9c325[] = | 1069 | static const u8 reg9a_sn9c325[] = |
850 | {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20}; | 1070 | {0x0a, 0x40, 0x38, 0x30, 0x00, 0x20}; |
851 | static const __u8 regd4[] = {0x60, 0x00, 0x00}; | 1071 | static const u8 regd4[] = {0x60, 0x00, 0x00}; |
852 | 1072 | ||
853 | reg_w1(gspca_dev, 0xf1, 0x00); | 1073 | reg_w1(gspca_dev, 0xf1, 0x00); |
854 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); | 1074 | reg_w1(gspca_dev, 0x01, sn9c1xx[1]); |
@@ -872,6 +1092,12 @@ static int configure_gpio(struct gspca_dev *gspca_dev, | |||
872 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); | 1092 | reg_w(gspca_dev, 0x03, &sn9c1xx[3], 0x0f); |
873 | 1093 | ||
874 | switch (sd->sensor) { | 1094 | switch (sd->sensor) { |
1095 | case SENSOR_MT9V111: | ||
1096 | reg_w1(gspca_dev, 0x01, 0x61); | ||
1097 | reg_w1(gspca_dev, 0x17, 0x61); | ||
1098 | reg_w1(gspca_dev, 0x01, 0x60); | ||
1099 | reg_w1(gspca_dev, 0x01, 0x40); | ||
1100 | break; | ||
875 | case SENSOR_OM6802: | 1101 | case SENSOR_OM6802: |
876 | reg_w1(gspca_dev, 0x02, 0x71); | 1102 | reg_w1(gspca_dev, 0x02, 0x71); |
877 | reg_w1(gspca_dev, 0x01, 0x42); | 1103 | reg_w1(gspca_dev, 0x01, 0x42); |
@@ -900,12 +1126,20 @@ static int configure_gpio(struct gspca_dev *gspca_dev, | |||
900 | break; | 1126 | break; |
901 | } | 1127 | } |
902 | /* fall thru */ | 1128 | /* fall thru */ |
1129 | case SENSOR_SP80708: | ||
1130 | reg_w1(gspca_dev, 0x01, 0x63); | ||
1131 | reg_w1(gspca_dev, 0x17, 0x20); | ||
1132 | reg_w1(gspca_dev, 0x01, 0x62); | ||
1133 | reg_w1(gspca_dev, 0x01, 0x42); | ||
1134 | mdelay(100); | ||
1135 | reg_w1(gspca_dev, 0x02, 0x62); | ||
1136 | break; | ||
903 | default: | 1137 | default: |
904 | reg_w1(gspca_dev, 0x01, 0x43); | 1138 | reg_w1(gspca_dev, 0x01, 0x43); |
905 | reg_w1(gspca_dev, 0x17, 0x61); | 1139 | reg_w1(gspca_dev, 0x17, 0x61); |
906 | reg_w1(gspca_dev, 0x01, 0x42); | 1140 | reg_w1(gspca_dev, 0x01, 0x42); |
907 | if (sd->sensor == SENSOR_HV7131R) { | 1141 | if (sd->sensor == SENSOR_HV7131R) { |
908 | if (probesensor(gspca_dev) < 0) | 1142 | if (hv7131r_probe(gspca_dev) < 0) |
909 | return -ENODEV; | 1143 | return -ENODEV; |
910 | } | 1144 | } |
911 | break; | 1145 | break; |
@@ -916,7 +1150,7 @@ static int configure_gpio(struct gspca_dev *gspca_dev, | |||
916 | static void hv7131R_InitSensor(struct gspca_dev *gspca_dev) | 1150 | static void hv7131R_InitSensor(struct gspca_dev *gspca_dev) |
917 | { | 1151 | { |
918 | int i = 0; | 1152 | int i = 0; |
919 | static const __u8 SetSensorClk[] = /* 0x08 Mclk */ | 1153 | static const u8 SetSensorClk[] = /* 0x08 Mclk */ |
920 | { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 }; | 1154 | { 0xa1, 0x11, 0x01, 0x18, 0x00, 0x00, 0x00, 0x10 }; |
921 | 1155 | ||
922 | while (hv7131r_sensor_init[i][0]) { | 1156 | while (hv7131r_sensor_init[i][0]) { |
@@ -946,6 +1180,19 @@ static void mo4000_InitSensor(struct gspca_dev *gspca_dev) | |||
946 | } | 1180 | } |
947 | } | 1181 | } |
948 | 1182 | ||
1183 | static void mt9v111_InitSensor(struct gspca_dev *gspca_dev) | ||
1184 | { | ||
1185 | int i = 0; | ||
1186 | |||
1187 | i2c_w8(gspca_dev, mt9v111_sensor_init[i]); | ||
1188 | i++; | ||
1189 | msleep(20); | ||
1190 | while (mt9v111_sensor_init[i][0]) { | ||
1191 | i2c_w8(gspca_dev, mt9v111_sensor_init[i]); | ||
1192 | i++; | ||
1193 | } | ||
1194 | } | ||
1195 | |||
949 | static void om6802_InitSensor(struct gspca_dev *gspca_dev) | 1196 | static void om6802_InitSensor(struct gspca_dev *gspca_dev) |
950 | { | 1197 | { |
951 | int i = 0; | 1198 | int i = 0; |
@@ -1010,6 +1257,19 @@ static void ov7660_InitSensor(struct gspca_dev *gspca_dev) | |||
1010 | } | 1257 | } |
1011 | } | 1258 | } |
1012 | 1259 | ||
1260 | static void sp80708_InitSensor(struct gspca_dev *gspca_dev) | ||
1261 | { | ||
1262 | int i = 0; | ||
1263 | |||
1264 | i2c_w8(gspca_dev, sp80708_sensor_init[i]); /* reset SCCB */ | ||
1265 | i++; | ||
1266 | msleep(20); | ||
1267 | while (sp80708_sensor_init[i][0]) { | ||
1268 | i2c_w8(gspca_dev, sp80708_sensor_init[i]); | ||
1269 | i++; | ||
1270 | } | ||
1271 | } | ||
1272 | |||
1013 | /* this function is called at probe time */ | 1273 | /* this function is called at probe time */ |
1014 | static int sd_config(struct gspca_dev *gspca_dev, | 1274 | static int sd_config(struct gspca_dev *gspca_dev, |
1015 | const struct usb_device_id *id) | 1275 | const struct usb_device_id *id) |
@@ -1018,7 +1278,6 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1018 | struct cam *cam; | 1278 | struct cam *cam; |
1019 | 1279 | ||
1020 | cam = &gspca_dev->cam; | 1280 | cam = &gspca_dev->cam; |
1021 | cam->epaddr = 0x01; | ||
1022 | cam->cam_mode = vga_mode; | 1281 | cam->cam_mode = vga_mode; |
1023 | cam->nmodes = ARRAY_SIZE(vga_mode); | 1282 | cam->nmodes = ARRAY_SIZE(vga_mode); |
1024 | 1283 | ||
@@ -1026,16 +1285,21 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1026 | sd->sensor = id->driver_info >> 8; | 1285 | sd->sensor = id->driver_info >> 8; |
1027 | sd->i2c_base = id->driver_info; | 1286 | sd->i2c_base = id->driver_info; |
1028 | 1287 | ||
1029 | sd->qindex = 4; /* set the quantization table */ | ||
1030 | sd->brightness = BRIGHTNESS_DEF; | 1288 | sd->brightness = BRIGHTNESS_DEF; |
1031 | sd->contrast = CONTRAST_DEF; | 1289 | sd->contrast = CONTRAST_DEF; |
1032 | sd->colors = COLOR_DEF; | 1290 | sd->colors = COLOR_DEF; |
1033 | sd->blue = BLUE_BALANCE_DEF; | 1291 | sd->blue = BLUE_BALANCE_DEF; |
1034 | sd->red = RED_BALANCE_DEF; | 1292 | sd->red = RED_BALANCE_DEF; |
1293 | sd->gamma = GAMMA_DEF; | ||
1035 | sd->autogain = AUTOGAIN_DEF; | 1294 | sd->autogain = AUTOGAIN_DEF; |
1036 | sd->ag_cnt = -1; | 1295 | sd->ag_cnt = -1; |
1037 | sd->vflip = VFLIP_DEF; | 1296 | if (sd->sensor != SENSOR_OV7630) |
1297 | sd->vflip = 0; | ||
1298 | else | ||
1299 | sd->vflip = 1; | ||
1038 | sd->infrared = INFRARED_DEF; | 1300 | sd->infrared = INFRARED_DEF; |
1301 | sd->quality = QUALITY_DEF; | ||
1302 | sd->jpegqual = 80; | ||
1039 | 1303 | ||
1040 | gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; | 1304 | gspca_dev->ctrl_dis = ctrl_dis[sd->sensor]; |
1041 | return 0; | 1305 | return 0; |
@@ -1045,8 +1309,8 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1045 | static int sd_init(struct gspca_dev *gspca_dev) | 1309 | static int sd_init(struct gspca_dev *gspca_dev) |
1046 | { | 1310 | { |
1047 | struct sd *sd = (struct sd *) gspca_dev; | 1311 | struct sd *sd = (struct sd *) gspca_dev; |
1048 | __u8 regGpio[] = { 0x29, 0x74 }; | 1312 | u8 regGpio[] = { 0x29, 0x74 }; |
1049 | __u8 regF1; | 1313 | u8 regF1; |
1050 | 1314 | ||
1051 | /* setup a selector by bridge */ | 1315 | /* setup a selector by bridge */ |
1052 | reg_w1(gspca_dev, 0xf1, 0x01); | 1316 | reg_w1(gspca_dev, 0xf1, 0x01); |
@@ -1064,11 +1328,15 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
1064 | case BRIDGE_SN9C105: | 1328 | case BRIDGE_SN9C105: |
1065 | if (regF1 != 0x11) | 1329 | if (regF1 != 0x11) |
1066 | return -ENODEV; | 1330 | return -ENODEV; |
1331 | if (sd->sensor == SENSOR_MI0360) | ||
1332 | mi0360_probe(gspca_dev); | ||
1067 | reg_w(gspca_dev, 0x01, regGpio, 2); | 1333 | reg_w(gspca_dev, 0x01, regGpio, 2); |
1068 | break; | 1334 | break; |
1069 | case BRIDGE_SN9C120: | 1335 | case BRIDGE_SN9C120: |
1070 | if (regF1 != 0x12) | 1336 | if (regF1 != 0x12) |
1071 | return -ENODEV; | 1337 | return -ENODEV; |
1338 | if (sd->sensor == SENSOR_MI0360) | ||
1339 | mi0360_probe(gspca_dev); | ||
1072 | regGpio[1] = 0x70; | 1340 | regGpio[1] = 0x70; |
1073 | reg_w(gspca_dev, 0x01, regGpio, 2); | 1341 | reg_w(gspca_dev, 0x01, regGpio, 2); |
1074 | break; | 1342 | break; |
@@ -1086,20 +1354,14 @@ static int sd_init(struct gspca_dev *gspca_dev) | |||
1086 | return 0; | 1354 | return 0; |
1087 | } | 1355 | } |
1088 | 1356 | ||
1089 | static unsigned int setexposure(struct gspca_dev *gspca_dev, | 1357 | static u32 setexposure(struct gspca_dev *gspca_dev, |
1090 | unsigned int expo) | 1358 | u32 expo) |
1091 | { | 1359 | { |
1092 | struct sd *sd = (struct sd *) gspca_dev; | 1360 | struct sd *sd = (struct sd *) gspca_dev; |
1093 | static const __u8 doit[] = /* update sensor */ | ||
1094 | { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 }; | ||
1095 | static const __u8 sensorgo[] = /* sensor on */ | ||
1096 | { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 }; | ||
1097 | static const __u8 gainMo[] = | ||
1098 | { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d }; | ||
1099 | 1361 | ||
1100 | switch (sd->sensor) { | 1362 | switch (sd->sensor) { |
1101 | case SENSOR_HV7131R: { | 1363 | case SENSOR_HV7131R: { |
1102 | __u8 Expodoit[] = | 1364 | u8 Expodoit[] = |
1103 | { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 }; | 1365 | { 0xc1, 0x11, 0x25, 0x07, 0x27, 0xc0, 0x00, 0x16 }; |
1104 | 1366 | ||
1105 | Expodoit[3] = expo >> 16; | 1367 | Expodoit[3] = expo >> 16; |
@@ -1109,8 +1371,12 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev, | |||
1109 | break; | 1371 | break; |
1110 | } | 1372 | } |
1111 | case SENSOR_MI0360: { | 1373 | case SENSOR_MI0360: { |
1112 | __u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */ | 1374 | u8 expoMi[] = /* exposure 0x0635 -> 4 fp/s 0x10 */ |
1113 | { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 }; | 1375 | { 0xb1, 0x5d, 0x09, 0x06, 0x35, 0x00, 0x00, 0x16 }; |
1376 | static const u8 doit[] = /* update sensor */ | ||
1377 | { 0xb1, 0x5d, 0x07, 0x00, 0x03, 0x00, 0x00, 0x10 }; | ||
1378 | static const u8 sensorgo[] = /* sensor on */ | ||
1379 | { 0xb1, 0x5d, 0x07, 0x00, 0x02, 0x00, 0x00, 0x10 }; | ||
1114 | 1380 | ||
1115 | if (expo > 0x0635) | 1381 | if (expo > 0x0635) |
1116 | expo = 0x0635; | 1382 | expo = 0x0635; |
@@ -1124,10 +1390,12 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev, | |||
1124 | break; | 1390 | break; |
1125 | } | 1391 | } |
1126 | case SENSOR_MO4000: { | 1392 | case SENSOR_MO4000: { |
1127 | __u8 expoMof[] = | 1393 | u8 expoMof[] = |
1128 | { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 }; | 1394 | { 0xa1, 0x21, 0x0f, 0x20, 0x00, 0x00, 0x00, 0x10 }; |
1129 | __u8 expoMo10[] = | 1395 | u8 expoMo10[] = |
1130 | { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 }; | 1396 | { 0xa1, 0x21, 0x10, 0x20, 0x00, 0x00, 0x00, 0x10 }; |
1397 | static const u8 gainMo[] = | ||
1398 | { 0xa1, 0x21, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1d }; | ||
1131 | 1399 | ||
1132 | if (expo > 0x1fff) | 1400 | if (expo > 0x1fff) |
1133 | expo = 0x1fff; | 1401 | expo = 0x1fff; |
@@ -1139,14 +1407,27 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev, | |||
1139 | | ((expo & 0x0003) << 4); | 1407 | | ((expo & 0x0003) << 4); |
1140 | i2c_w8(gspca_dev, expoMo10); | 1408 | i2c_w8(gspca_dev, expoMo10); |
1141 | i2c_w8(gspca_dev, gainMo); | 1409 | i2c_w8(gspca_dev, gainMo); |
1142 | PDEBUG(D_CONF, "set exposure %d", | 1410 | PDEBUG(D_FRAM, "set exposure %d", |
1143 | ((expoMo10[3] & 0x07) << 10) | 1411 | ((expoMo10[3] & 0x07) << 10) |
1144 | | (expoMof[3] << 2) | 1412 | | (expoMof[3] << 2) |
1145 | | ((expoMo10[3] & 0x30) >> 4)); | 1413 | | ((expoMo10[3] & 0x30) >> 4)); |
1146 | break; | 1414 | break; |
1147 | } | 1415 | } |
1416 | case SENSOR_MT9V111: { | ||
1417 | u8 expo_c1[] = | ||
1418 | { 0xb1, 0x5c, 0x09, 0x00, 0x00, 0x00, 0x00, 0x10 }; | ||
1419 | |||
1420 | if (expo > 0x0280) | ||
1421 | expo = 0x0280; | ||
1422 | else if (expo < 0x0040) | ||
1423 | expo = 0x0040; | ||
1424 | expo_c1[3] = expo >> 8; | ||
1425 | expo_c1[4] = expo; | ||
1426 | i2c_w8(gspca_dev, expo_c1); | ||
1427 | break; | ||
1428 | } | ||
1148 | case SENSOR_OM6802: { | 1429 | case SENSOR_OM6802: { |
1149 | __u8 gainOm[] = | 1430 | u8 gainOm[] = |
1150 | { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 }; | 1431 | { 0xa0, 0x34, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
1151 | 1432 | ||
1152 | if (expo > 0x03ff) | 1433 | if (expo > 0x03ff) |
@@ -1156,7 +1437,7 @@ static unsigned int setexposure(struct gspca_dev *gspca_dev, | |||
1156 | gainOm[3] = expo >> 2; | 1437 | gainOm[3] = expo >> 2; |
1157 | i2c_w8(gspca_dev, gainOm); | 1438 | i2c_w8(gspca_dev, gainOm); |
1158 | reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f); | 1439 | reg_w1(gspca_dev, 0x96, (expo >> 5) & 0x1f); |
1159 | PDEBUG(D_CONF, "set exposure %d", gainOm[3]); | 1440 | PDEBUG(D_FRAM, "set exposure %d", gainOm[3]); |
1160 | break; | 1441 | break; |
1161 | } | 1442 | } |
1162 | } | 1443 | } |
@@ -1167,7 +1448,7 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
1167 | { | 1448 | { |
1168 | struct sd *sd = (struct sd *) gspca_dev; | 1449 | struct sd *sd = (struct sd *) gspca_dev; |
1169 | unsigned int expo; | 1450 | unsigned int expo; |
1170 | __u8 k2; | 1451 | u8 k2; |
1171 | 1452 | ||
1172 | k2 = ((int) sd->brightness - 0x8000) >> 10; | 1453 | k2 = ((int) sd->brightness - 0x8000) >> 10; |
1173 | switch (sd->sensor) { | 1454 | switch (sd->sensor) { |
@@ -1184,6 +1465,10 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
1184 | expo = sd->brightness >> 4; | 1465 | expo = sd->brightness >> 4; |
1185 | sd->exposure = setexposure(gspca_dev, expo); | 1466 | sd->exposure = setexposure(gspca_dev, expo); |
1186 | break; | 1467 | break; |
1468 | case SENSOR_MT9V111: | ||
1469 | expo = sd->brightness >> 8; | ||
1470 | sd->exposure = setexposure(gspca_dev, expo); | ||
1471 | break; | ||
1187 | case SENSOR_OM6802: | 1472 | case SENSOR_OM6802: |
1188 | expo = sd->brightness >> 6; | 1473 | expo = sd->brightness >> 6; |
1189 | sd->exposure = setexposure(gspca_dev, expo); | 1474 | sd->exposure = setexposure(gspca_dev, expo); |
@@ -1191,14 +1476,15 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
1191 | break; | 1476 | break; |
1192 | } | 1477 | } |
1193 | 1478 | ||
1194 | reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */ | 1479 | if (sd->sensor != SENSOR_MT9V111) |
1480 | reg_w1(gspca_dev, 0x96, k2); /* color matrix Y offset */ | ||
1195 | } | 1481 | } |
1196 | 1482 | ||
1197 | static void setcontrast(struct gspca_dev *gspca_dev) | 1483 | static void setcontrast(struct gspca_dev *gspca_dev) |
1198 | { | 1484 | { |
1199 | struct sd *sd = (struct sd *) gspca_dev; | 1485 | struct sd *sd = (struct sd *) gspca_dev; |
1200 | __u8 k2; | 1486 | u8 k2; |
1201 | __u8 contrast[6]; | 1487 | u8 contrast[6]; |
1202 | 1488 | ||
1203 | k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */ | 1489 | k2 = sd->contrast * 0x30 / (CONTRAST_MAX + 1) + 0x10; /* 10..40 */ |
1204 | contrast[0] = (k2 + 1) / 2; /* red */ | 1490 | contrast[0] = (k2 + 1) / 2; /* red */ |
@@ -1214,8 +1500,8 @@ static void setcolors(struct gspca_dev *gspca_dev) | |||
1214 | { | 1500 | { |
1215 | struct sd *sd = (struct sd *) gspca_dev; | 1501 | struct sd *sd = (struct sd *) gspca_dev; |
1216 | int i, v; | 1502 | int i, v; |
1217 | __u8 reg8a[12]; /* U & V gains */ | 1503 | u8 reg8a[12]; /* U & V gains */ |
1218 | static __s16 uv[6] = { /* same as reg84 in signed decimal */ | 1504 | static s16 uv[6] = { /* same as reg84 in signed decimal */ |
1219 | -24, -38, 64, /* UR UG UB */ | 1505 | -24, -38, 64, /* UR UG UB */ |
1220 | 62, -51, -9 /* VR VG VB */ | 1506 | 62, -51, -9 /* VR VG VB */ |
1221 | }; | 1507 | }; |
@@ -1236,22 +1522,75 @@ static void setredblue(struct gspca_dev *gspca_dev) | |||
1236 | reg_w1(gspca_dev, 0x06, sd->blue); | 1522 | reg_w1(gspca_dev, 0x06, sd->blue); |
1237 | } | 1523 | } |
1238 | 1524 | ||
1525 | static void setgamma(struct gspca_dev *gspca_dev) | ||
1526 | { | ||
1527 | struct sd *sd = (struct sd *) gspca_dev; | ||
1528 | int i; | ||
1529 | u8 gamma[17]; | ||
1530 | const u8 *gamma_base; | ||
1531 | static const u8 delta[17] = { | ||
1532 | 0x00, 0x14, 0x1c, 0x1c, 0x1c, 0x1c, 0x1b, 0x1a, | ||
1533 | 0x18, 0x13, 0x10, 0x0e, 0x08, 0x07, 0x04, 0x02, 0x00 | ||
1534 | }; | ||
1535 | |||
1536 | switch (sd->sensor) { | ||
1537 | case SENSOR_HV7131R: | ||
1538 | case SENSOR_MT9V111: | ||
1539 | gamma_base = gamma_spec_1; | ||
1540 | break; | ||
1541 | case SENSOR_SP80708: | ||
1542 | gamma_base = gamma_spec_2; | ||
1543 | break; | ||
1544 | default: | ||
1545 | gamma_base = gamma_def; | ||
1546 | break; | ||
1547 | } | ||
1548 | |||
1549 | for (i = 0; i < sizeof gamma; i++) | ||
1550 | gamma[i] = gamma_base[i] | ||
1551 | + delta[i] * (sd->gamma - GAMMA_DEF) / 32; | ||
1552 | reg_w(gspca_dev, 0x20, gamma, sizeof gamma); | ||
1553 | } | ||
1554 | |||
1239 | static void setautogain(struct gspca_dev *gspca_dev) | 1555 | static void setautogain(struct gspca_dev *gspca_dev) |
1240 | { | 1556 | { |
1241 | struct sd *sd = (struct sd *) gspca_dev; | 1557 | struct sd *sd = (struct sd *) gspca_dev; |
1242 | 1558 | ||
1243 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) | 1559 | if (gspca_dev->ctrl_dis & (1 << AUTOGAIN_IDX)) |
1244 | return; | 1560 | return; |
1561 | switch (sd->sensor) { | ||
1562 | case SENSOR_OV7630: | ||
1563 | case SENSOR_OV7648: { | ||
1564 | u8 comb; | ||
1565 | |||
1566 | if (sd->sensor == SENSOR_OV7630) | ||
1567 | comb = 0xc0; | ||
1568 | else | ||
1569 | comb = 0xa0; | ||
1570 | if (sd->autogain) | ||
1571 | comb |= 0x02; | ||
1572 | i2c_w1(&sd->gspca_dev, 0x13, comb); | ||
1573 | return; | ||
1574 | } | ||
1575 | } | ||
1245 | if (sd->autogain) | 1576 | if (sd->autogain) |
1246 | sd->ag_cnt = AG_CNT_START; | 1577 | sd->ag_cnt = AG_CNT_START; |
1247 | else | 1578 | else |
1248 | sd->ag_cnt = -1; | 1579 | sd->ag_cnt = -1; |
1249 | } | 1580 | } |
1250 | 1581 | ||
1582 | /* ov7630/ov7648 only */ | ||
1251 | static void setvflip(struct sd *sd) | 1583 | static void setvflip(struct sd *sd) |
1252 | { | 1584 | { |
1253 | i2c_w1(&sd->gspca_dev, 0x75, /* COMN */ | 1585 | u8 comn; |
1254 | sd->vflip ? 0x82 : 0x02); | 1586 | |
1587 | if (sd->sensor == SENSOR_OV7630) | ||
1588 | comn = 0x02; | ||
1589 | else | ||
1590 | comn = 0x06; | ||
1591 | if (sd->vflip) | ||
1592 | comn |= 0x80; | ||
1593 | i2c_w1(&sd->gspca_dev, 0x75, comn); | ||
1255 | } | 1594 | } |
1256 | 1595 | ||
1257 | static void setinfrared(struct sd *sd) | 1596 | static void setinfrared(struct sd *sd) |
@@ -1262,20 +1601,63 @@ static void setinfrared(struct sd *sd) | |||
1262 | sd->infrared ? 0x66 : 0x64); | 1601 | sd->infrared ? 0x66 : 0x64); |
1263 | } | 1602 | } |
1264 | 1603 | ||
1604 | static void setjpegqual(struct gspca_dev *gspca_dev) | ||
1605 | { | ||
1606 | struct sd *sd = (struct sd *) gspca_dev; | ||
1607 | int i, sc; | ||
1608 | |||
1609 | if (sd->jpegqual < 50) | ||
1610 | sc = 5000 / sd->jpegqual; | ||
1611 | else | ||
1612 | sc = 200 - sd->jpegqual * 2; | ||
1613 | #if USB_BUF_SZ < 64 | ||
1614 | #error "No room enough in usb_buf for quantization table" | ||
1615 | #endif | ||
1616 | for (i = 0; i < 64; i++) | ||
1617 | gspca_dev->usb_buf[i] = | ||
1618 | (jpeg_head[JPEG_QT0_OFFSET + i] * sc + 50) / 100; | ||
1619 | usb_control_msg(gspca_dev->dev, | ||
1620 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
1621 | 0x08, | ||
1622 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
1623 | 0x0100, 0, | ||
1624 | gspca_dev->usb_buf, 64, | ||
1625 | 500); | ||
1626 | for (i = 0; i < 64; i++) | ||
1627 | gspca_dev->usb_buf[i] = | ||
1628 | (jpeg_head[JPEG_QT1_OFFSET + i] * sc + 50) / 100; | ||
1629 | usb_control_msg(gspca_dev->dev, | ||
1630 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
1631 | 0x08, | ||
1632 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
1633 | 0x0140, 0, | ||
1634 | gspca_dev->usb_buf, 64, | ||
1635 | 500); | ||
1636 | |||
1637 | sd->reg18 ^= 0x40; | ||
1638 | reg_w1(gspca_dev, 0x18, sd->reg18); | ||
1639 | } | ||
1640 | |||
1265 | /* -- start the camera -- */ | 1641 | /* -- start the camera -- */ |
1266 | static int sd_start(struct gspca_dev *gspca_dev) | 1642 | static int sd_start(struct gspca_dev *gspca_dev) |
1267 | { | 1643 | { |
1268 | struct sd *sd = (struct sd *) gspca_dev; | 1644 | struct sd *sd = (struct sd *) gspca_dev; |
1269 | int i; | 1645 | int i; |
1270 | __u8 reg1, reg17, reg18; | 1646 | u8 reg1, reg17; |
1271 | const __u8 *sn9c1xx; | 1647 | const u8 *sn9c1xx; |
1272 | int mode; | 1648 | int mode; |
1273 | static const __u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; | 1649 | static const u8 C0[] = { 0x2d, 0x2d, 0x3a, 0x05, 0x04, 0x3f }; |
1274 | static const __u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; | 1650 | static const u8 CA[] = { 0x28, 0xd8, 0x14, 0xec }; |
1275 | static const __u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ | 1651 | static const u8 CE[] = { 0x32, 0xdd, 0x2d, 0xdd }; /* MI0360 */ |
1276 | static const __u8 CE_ov76xx[] = | 1652 | static const u8 CE_ov76xx[] = |
1277 | { 0x32, 0xdd, 0x32, 0xdd }; | 1653 | { 0x32, 0xdd, 0x32, 0xdd }; |
1278 | 1654 | ||
1655 | /* create the JPEG header */ | ||
1656 | sd->jpeg_hdr = kmalloc(JPEG_HDR_SZ, GFP_KERNEL); | ||
1657 | jpeg_define(sd->jpeg_hdr, gspca_dev->height, gspca_dev->width, | ||
1658 | 0x21); /* JPEG 422 */ | ||
1659 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); | ||
1660 | |||
1279 | sn9c1xx = sn_tb[(int) sd->sensor]; | 1661 | sn9c1xx = sn_tb[(int) sd->sensor]; |
1280 | configure_gpio(gspca_dev, sn9c1xx); | 1662 | configure_gpio(gspca_dev, sn9c1xx); |
1281 | 1663 | ||
@@ -1292,6 +1674,9 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1292 | reg_w1(gspca_dev, 0xc9, 0x3c); | 1674 | reg_w1(gspca_dev, 0xc9, 0x3c); |
1293 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); | 1675 | reg_w1(gspca_dev, 0x18, sn9c1xx[0x18]); |
1294 | switch (sd->sensor) { | 1676 | switch (sd->sensor) { |
1677 | case SENSOR_MT9V111: | ||
1678 | reg17 = 0xe0; | ||
1679 | break; | ||
1295 | case SENSOR_OV7630: | 1680 | case SENSOR_OV7630: |
1296 | reg17 = 0xe2; | 1681 | reg17 = 0xe2; |
1297 | break; | 1682 | break; |
@@ -1315,14 +1700,24 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1315 | reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */ | 1700 | reg_w1(gspca_dev, 0x07, sn9c1xx[7]); /* green */ |
1316 | reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */ | 1701 | reg_w1(gspca_dev, 0x06, sn9c1xx[6]); /* blue */ |
1317 | reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); | 1702 | reg_w1(gspca_dev, 0x14, sn9c1xx[0x14]); |
1318 | reg_w(gspca_dev, 0x20, gamma_def, sizeof gamma_def); | 1703 | |
1704 | setgamma(gspca_dev); | ||
1705 | |||
1319 | for (i = 0; i < 8; i++) | 1706 | for (i = 0; i < 8; i++) |
1320 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); | 1707 | reg_w(gspca_dev, 0x84, reg84, sizeof reg84); |
1321 | switch (sd->sensor) { | 1708 | switch (sd->sensor) { |
1709 | case SENSOR_MT9V111: | ||
1710 | reg_w1(gspca_dev, 0x9a, 0x07); | ||
1711 | reg_w1(gspca_dev, 0x99, 0x59); | ||
1712 | break; | ||
1322 | case SENSOR_OV7648: | 1713 | case SENSOR_OV7648: |
1323 | reg_w1(gspca_dev, 0x9a, 0x0a); | 1714 | reg_w1(gspca_dev, 0x9a, 0x0a); |
1324 | reg_w1(gspca_dev, 0x99, 0x60); | 1715 | reg_w1(gspca_dev, 0x99, 0x60); |
1325 | break; | 1716 | break; |
1717 | case SENSOR_SP80708: | ||
1718 | reg_w1(gspca_dev, 0x9a, 0x05); | ||
1719 | reg_w1(gspca_dev, 0x99, 0x59); | ||
1720 | break; | ||
1326 | case SENSOR_OV7660: | 1721 | case SENSOR_OV7660: |
1327 | if (sd->bridge == BRIDGE_SN9C120) { | 1722 | if (sd->bridge == BRIDGE_SN9C120) { |
1328 | reg_w1(gspca_dev, 0x9a, 0x05); | 1723 | reg_w1(gspca_dev, 0x9a, 0x05); |
@@ -1358,6 +1753,15 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1358 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ | 1753 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ |
1359 | } | 1754 | } |
1360 | break; | 1755 | break; |
1756 | case SENSOR_MT9V111: | ||
1757 | mt9v111_InitSensor(gspca_dev); | ||
1758 | if (mode) { | ||
1759 | reg1 = 0x04; /* 320 clk 48Mhz */ | ||
1760 | } else { | ||
1761 | /* reg1 = 0x06; * 640 clk 24Mz (done) */ | ||
1762 | reg17 = 0xc2; | ||
1763 | } | ||
1764 | break; | ||
1361 | case SENSOR_OM6802: | 1765 | case SENSOR_OM6802: |
1362 | om6802_InitSensor(gspca_dev); | 1766 | om6802_InitSensor(gspca_dev); |
1363 | reg17 = 0x64; /* 640 MCKSIZE */ | 1767 | reg17 = 0x64; /* 640 MCKSIZE */ |
@@ -1373,8 +1777,7 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1373 | reg17 = 0x21; | 1777 | reg17 = 0x21; |
1374 | /* reg1 = 0x42; * 42 - 46? */ | 1778 | /* reg1 = 0x42; * 42 - 46? */ |
1375 | break; | 1779 | break; |
1376 | default: | 1780 | case SENSOR_OV7660: |
1377 | /* case SENSOR_OV7660: */ | ||
1378 | ov7660_InitSensor(gspca_dev); | 1781 | ov7660_InitSensor(gspca_dev); |
1379 | if (sd->bridge == BRIDGE_SN9C120) { | 1782 | if (sd->bridge == BRIDGE_SN9C120) { |
1380 | if (mode) { /* 320x240 - 160x120 */ | 1783 | if (mode) { /* 320x240 - 160x120 */ |
@@ -1387,6 +1790,16 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1387 | * inverse power down */ | 1790 | * inverse power down */ |
1388 | } | 1791 | } |
1389 | break; | 1792 | break; |
1793 | default: | ||
1794 | /* case SENSOR_SP80708: */ | ||
1795 | sp80708_InitSensor(gspca_dev); | ||
1796 | if (mode) { | ||
1797 | /*?? reg1 = 0x04; * 320 clk 48Mhz */ | ||
1798 | } else { | ||
1799 | reg1 = 0x46; /* 640 clk 48Mz */ | ||
1800 | reg17 = 0xa2; | ||
1801 | } | ||
1802 | break; | ||
1390 | } | 1803 | } |
1391 | reg_w(gspca_dev, 0xc0, C0, 6); | 1804 | reg_w(gspca_dev, 0xc0, C0, 6); |
1392 | reg_w(gspca_dev, 0xca, CA, 4); | 1805 | reg_w(gspca_dev, 0xca, CA, 4); |
@@ -1403,20 +1816,13 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1403 | } | 1816 | } |
1404 | 1817 | ||
1405 | /* here change size mode 0 -> VGA; 1 -> CIF */ | 1818 | /* here change size mode 0 -> VGA; 1 -> CIF */ |
1406 | reg18 = sn9c1xx[0x18] | (mode << 4); | 1819 | sd->reg18 = sn9c1xx[0x18] | (mode << 4) | 0x40; |
1407 | reg_w1(gspca_dev, 0x18, reg18 | 0x40); | 1820 | reg_w1(gspca_dev, 0x18, sd->reg18); |
1408 | 1821 | setjpegqual(gspca_dev); | |
1409 | reg_w(gspca_dev, 0x100, qtable4, 0x40); | ||
1410 | reg_w(gspca_dev, 0x140, qtable4 + 0x40, 0x40); | ||
1411 | |||
1412 | reg_w1(gspca_dev, 0x18, reg18); | ||
1413 | 1822 | ||
1414 | reg_w1(gspca_dev, 0x17, reg17); | 1823 | reg_w1(gspca_dev, 0x17, reg17); |
1415 | reg_w1(gspca_dev, 0x01, reg1); | 1824 | reg_w1(gspca_dev, 0x01, reg1); |
1416 | switch (sd->sensor) { | 1825 | switch (sd->sensor) { |
1417 | case SENSOR_MI0360: | ||
1418 | setinfrared(sd); | ||
1419 | break; | ||
1420 | case SENSOR_OV7630: | 1826 | case SENSOR_OV7630: |
1421 | setvflip(sd); | 1827 | setvflip(sd); |
1422 | break; | 1828 | break; |
@@ -1430,14 +1836,14 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
1430 | static void sd_stopN(struct gspca_dev *gspca_dev) | 1836 | static void sd_stopN(struct gspca_dev *gspca_dev) |
1431 | { | 1837 | { |
1432 | struct sd *sd = (struct sd *) gspca_dev; | 1838 | struct sd *sd = (struct sd *) gspca_dev; |
1433 | static const __u8 stophv7131[] = | 1839 | static const u8 stophv7131[] = |
1434 | { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 }; | 1840 | { 0xa1, 0x11, 0x02, 0x09, 0x00, 0x00, 0x00, 0x10 }; |
1435 | static const __u8 stopmi0360[] = | 1841 | static const u8 stopmi0360[] = |
1436 | { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 }; | 1842 | { 0xb1, 0x5d, 0x07, 0x00, 0x00, 0x00, 0x00, 0x10 }; |
1437 | static const __u8 stopov7648[] = | 1843 | static const u8 stopov7648[] = |
1438 | { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 }; | 1844 | { 0xa1, 0x21, 0x76, 0x20, 0x00, 0x00, 0x00, 0x10 }; |
1439 | __u8 data; | 1845 | u8 data; |
1440 | const __u8 *sn9c1xx; | 1846 | const u8 *sn9c1xx; |
1441 | 1847 | ||
1442 | data = 0x0b; | 1848 | data = 0x0b; |
1443 | switch (sd->sensor) { | 1849 | switch (sd->sensor) { |
@@ -1452,6 +1858,7 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1452 | case SENSOR_OV7648: | 1858 | case SENSOR_OV7648: |
1453 | i2c_w8(gspca_dev, stopov7648); | 1859 | i2c_w8(gspca_dev, stopov7648); |
1454 | /* fall thru */ | 1860 | /* fall thru */ |
1861 | case SENSOR_MT9V111: | ||
1455 | case SENSOR_OV7630: | 1862 | case SENSOR_OV7630: |
1456 | data = 0x29; | 1863 | data = 0x29; |
1457 | break; | 1864 | break; |
@@ -1468,13 +1875,20 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
1468 | reg_w1(gspca_dev, 0xf1, 0x00); | 1875 | reg_w1(gspca_dev, 0xf1, 0x00); |
1469 | } | 1876 | } |
1470 | 1877 | ||
1878 | static void sd_stop0(struct gspca_dev *gspca_dev) | ||
1879 | { | ||
1880 | struct sd *sd = (struct sd *) gspca_dev; | ||
1881 | |||
1882 | kfree(sd->jpeg_hdr); | ||
1883 | } | ||
1884 | |||
1471 | static void do_autogain(struct gspca_dev *gspca_dev) | 1885 | static void do_autogain(struct gspca_dev *gspca_dev) |
1472 | { | 1886 | { |
1473 | struct sd *sd = (struct sd *) gspca_dev; | 1887 | struct sd *sd = (struct sd *) gspca_dev; |
1474 | int delta; | 1888 | int delta; |
1475 | int expotimes; | 1889 | int expotimes; |
1476 | __u8 luma_mean = 130; | 1890 | u8 luma_mean = 130; |
1477 | __u8 luma_delta = 20; | 1891 | u8 luma_delta = 20; |
1478 | 1892 | ||
1479 | /* Thanks S., without your advice, autobright should not work :) */ | 1893 | /* Thanks S., without your advice, autobright should not work :) */ |
1480 | if (sd->ag_cnt < 0) | 1894 | if (sd->ag_cnt < 0) |
@@ -1499,6 +1913,7 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
1499 | default: | 1913 | default: |
1500 | /* case SENSOR_MO4000: */ | 1914 | /* case SENSOR_MO4000: */ |
1501 | /* case SENSOR_MI0360: */ | 1915 | /* case SENSOR_MI0360: */ |
1916 | /* case SENSOR_MT9V111: */ | ||
1502 | /* case SENSOR_OM6802: */ | 1917 | /* case SENSOR_OM6802: */ |
1503 | expotimes = sd->exposure; | 1918 | expotimes = sd->exposure; |
1504 | expotimes += (luma_mean - delta) >> 6; | 1919 | expotimes += (luma_mean - delta) >> 6; |
@@ -1516,7 +1931,7 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
1516 | /* This function is run at interrupt level. */ | 1931 | /* This function is run at interrupt level. */ |
1517 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | 1932 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, |
1518 | struct gspca_frame *frame, /* target */ | 1933 | struct gspca_frame *frame, /* target */ |
1519 | __u8 *data, /* isoc packet */ | 1934 | u8 *data, /* isoc packet */ |
1520 | int len) /* iso packet length */ | 1935 | int len) /* iso packet length */ |
1521 | { | 1936 | { |
1522 | struct sd *sd = (struct sd *) gspca_dev; | 1937 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -1550,7 +1965,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
1550 | if (gspca_dev->last_packet_type == LAST_PACKET) { | 1965 | if (gspca_dev->last_packet_type == LAST_PACKET) { |
1551 | 1966 | ||
1552 | /* put the JPEG 422 header */ | 1967 | /* put the JPEG 422 header */ |
1553 | jpeg_put_header(gspca_dev, frame, sd->qindex, 0x21); | 1968 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, |
1969 | sd->jpeg_hdr, JPEG_HDR_SZ); | ||
1554 | } | 1970 | } |
1555 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); | 1971 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); |
1556 | } | 1972 | } |
@@ -1645,6 +2061,24 @@ static int sd_getred_balance(struct gspca_dev *gspca_dev, __s32 *val) | |||
1645 | return 0; | 2061 | return 0; |
1646 | } | 2062 | } |
1647 | 2063 | ||
2064 | static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val) | ||
2065 | { | ||
2066 | struct sd *sd = (struct sd *) gspca_dev; | ||
2067 | |||
2068 | sd->gamma = val; | ||
2069 | if (gspca_dev->streaming) | ||
2070 | setgamma(gspca_dev); | ||
2071 | return 0; | ||
2072 | } | ||
2073 | |||
2074 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val) | ||
2075 | { | ||
2076 | struct sd *sd = (struct sd *) gspca_dev; | ||
2077 | |||
2078 | *val = sd->gamma; | ||
2079 | return 0; | ||
2080 | } | ||
2081 | |||
1648 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) | 2082 | static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) |
1649 | { | 2083 | { |
1650 | struct sd *sd = (struct sd *) gspca_dev; | 2084 | struct sd *sd = (struct sd *) gspca_dev; |
@@ -1699,6 +2133,34 @@ static int sd_getinfrared(struct gspca_dev *gspca_dev, __s32 *val) | |||
1699 | return 0; | 2133 | return 0; |
1700 | } | 2134 | } |
1701 | 2135 | ||
2136 | static int sd_set_jcomp(struct gspca_dev *gspca_dev, | ||
2137 | struct v4l2_jpegcompression *jcomp) | ||
2138 | { | ||
2139 | struct sd *sd = (struct sd *) gspca_dev; | ||
2140 | |||
2141 | if (jcomp->quality < QUALITY_MIN) | ||
2142 | sd->quality = QUALITY_MIN; | ||
2143 | else if (jcomp->quality > QUALITY_MAX) | ||
2144 | sd->quality = QUALITY_MAX; | ||
2145 | else | ||
2146 | sd->quality = jcomp->quality; | ||
2147 | if (gspca_dev->streaming) | ||
2148 | jpeg_set_qual(sd->jpeg_hdr, sd->quality); | ||
2149 | return 0; | ||
2150 | } | ||
2151 | |||
2152 | static int sd_get_jcomp(struct gspca_dev *gspca_dev, | ||
2153 | struct v4l2_jpegcompression *jcomp) | ||
2154 | { | ||
2155 | struct sd *sd = (struct sd *) gspca_dev; | ||
2156 | |||
2157 | memset(jcomp, 0, sizeof *jcomp); | ||
2158 | jcomp->quality = sd->quality; | ||
2159 | jcomp->jpeg_markers = V4L2_JPEG_MARKER_DHT | ||
2160 | | V4L2_JPEG_MARKER_DQT; | ||
2161 | return 0; | ||
2162 | } | ||
2163 | |||
1702 | /* sub-driver description */ | 2164 | /* sub-driver description */ |
1703 | static const struct sd_desc sd_desc = { | 2165 | static const struct sd_desc sd_desc = { |
1704 | .name = MODULE_NAME, | 2166 | .name = MODULE_NAME, |
@@ -1708,8 +2170,11 @@ static const struct sd_desc sd_desc = { | |||
1708 | .init = sd_init, | 2170 | .init = sd_init, |
1709 | .start = sd_start, | 2171 | .start = sd_start, |
1710 | .stopN = sd_stopN, | 2172 | .stopN = sd_stopN, |
2173 | .stop0 = sd_stop0, | ||
1711 | .pkt_scan = sd_pkt_scan, | 2174 | .pkt_scan = sd_pkt_scan, |
1712 | .dq_callback = do_autogain, | 2175 | .dq_callback = do_autogain, |
2176 | .get_jcomp = sd_get_jcomp, | ||
2177 | .set_jcomp = sd_set_jcomp, | ||
1713 | }; | 2178 | }; |
1714 | 2179 | ||
1715 | /* -- module initialisation -- */ | 2180 | /* -- module initialisation -- */ |
@@ -1724,9 +2189,7 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
1724 | #endif | 2189 | #endif |
1725 | {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)}, | 2190 | {USB_DEVICE(0x045e, 0x00f5), BSI(SN9C105, OV7660, 0x21)}, |
1726 | {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)}, | 2191 | {USB_DEVICE(0x045e, 0x00f7), BSI(SN9C105, OV7660, 0x21)}, |
1727 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | ||
1728 | {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105, MI0360, 0x5d)}, | 2192 | {USB_DEVICE(0x0471, 0x0327), BSI(SN9C105, MI0360, 0x5d)}, |
1729 | #endif | ||
1730 | {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)}, | 2193 | {USB_DEVICE(0x0471, 0x0328), BSI(SN9C105, MI0360, 0x5d)}, |
1731 | {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)}, | 2194 | {USB_DEVICE(0x0471, 0x0330), BSI(SN9C105, MI0360, 0x5d)}, |
1732 | {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105, OV7660, 0x21)}, | 2195 | {USB_DEVICE(0x06f8, 0x3004), BSI(SN9C105, OV7660, 0x21)}, |
@@ -1764,10 +2227,10 @@ static const __devinitdata struct usb_device_id device_table[] = { | |||
1764 | {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x21)}, | 2227 | {USB_DEVICE(0x0c45, 0x613a), BSI(SN9C120, OV7648, 0x21)}, |
1765 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE | 2228 | #if !defined CONFIG_USB_SN9C102 && !defined CONFIG_USB_SN9C102_MODULE |
1766 | {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)}, | 2229 | {USB_DEVICE(0x0c45, 0x613b), BSI(SN9C120, OV7660, 0x21)}, |
2230 | #endif | ||
1767 | {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)}, | 2231 | {USB_DEVICE(0x0c45, 0x613c), BSI(SN9C120, HV7131R, 0x11)}, |
1768 | /* {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x??)}, */ | 2232 | /* {USB_DEVICE(0x0c45, 0x613e), BSI(SN9C120, OV7630, 0x??)}, */ |
1769 | #endif | 2233 | {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, SP80708, 0x18)}, |
1770 | {USB_DEVICE(0x0c45, 0x6143), BSI(SN9C120, MI0360, 0x5d)}, | ||
1771 | {} | 2234 | {} |
1772 | }; | 2235 | }; |
1773 | MODULE_DEVICE_TABLE(usb, device_table); | 2236 | MODULE_DEVICE_TABLE(usb, device_table); |
@@ -1794,8 +2257,10 @@ static struct usb_driver sd_driver = { | |||
1794 | /* -- module insert / remove -- */ | 2257 | /* -- module insert / remove -- */ |
1795 | static int __init sd_mod_init(void) | 2258 | static int __init sd_mod_init(void) |
1796 | { | 2259 | { |
1797 | if (usb_register(&sd_driver) < 0) | 2260 | int ret; |
1798 | return -1; | 2261 | ret = usb_register(&sd_driver); |
2262 | if (ret < 0) | ||
2263 | return ret; | ||
1799 | info("registered"); | 2264 | info("registered"); |
1800 | return 0; | 2265 | return 0; |
1801 | } | 2266 | } |