diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2008-10-08 07:06:08 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:37:15 -0400 |
commit | fadc79935cdb74e744c72e25f739a4acc9efabf5 (patch) | |
tree | 8bdf4f3a47eb17f97b110c9e1105186fd7723732 /drivers/media | |
parent | a2d7807788ff3213f540ba772f6c5c39548ae09f (diff) |
V4L/DVB (9125): gspca: Big rewrite of t613 driver
- separate functions for bridge and sensor exchanges
- delays added after some exchanges
- other sensor type
Signed-off-by: Jean-Francois Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/gspca/t613.c | 592 |
1 files changed, 326 insertions, 266 deletions
diff --git a/drivers/media/video/gspca/t613.c b/drivers/media/video/gspca/t613.c index 7e435a36b056..b561f7c4f066 100644 --- a/drivers/media/video/gspca/t613.c +++ b/drivers/media/video/gspca/t613.c | |||
@@ -28,8 +28,6 @@ | |||
28 | 28 | ||
29 | #include "gspca.h" | 29 | #include "gspca.h" |
30 | 30 | ||
31 | #define MAX_GAMMA 0x10 /* 0 to 15 */ | ||
32 | |||
33 | #define V4L2_CID_EFFECTS (V4L2_CID_PRIVATE_BASE + 0) | 31 | #define V4L2_CID_EFFECTS (V4L2_CID_PRIVATE_BASE + 0) |
34 | 32 | ||
35 | MODULE_AUTHOR("Leandro Costantino <le_costantino@pixartargentina.com.ar>"); | 33 | MODULE_AUTHOR("Leandro Costantino <le_costantino@pixartargentina.com.ar>"); |
@@ -49,6 +47,10 @@ struct sd { | |||
49 | unsigned char whitebalance; | 47 | unsigned char whitebalance; |
50 | unsigned char mirror; | 48 | unsigned char mirror; |
51 | unsigned char effect; | 49 | unsigned char effect; |
50 | |||
51 | __u8 sensor; | ||
52 | #define SENSOR_TAS5130A 0 | ||
53 | #define SENSOR_OTHER 1 | ||
52 | }; | 54 | }; |
53 | 55 | ||
54 | /* V4L2 controls supported by the driver */ | 56 | /* V4L2 controls supported by the driver */ |
@@ -83,9 +85,9 @@ static struct ctrl sd_ctrls[] = { | |||
83 | .type = V4L2_CTRL_TYPE_INTEGER, | 85 | .type = V4L2_CTRL_TYPE_INTEGER, |
84 | .name = "Brightness", | 86 | .name = "Brightness", |
85 | .minimum = 0, | 87 | .minimum = 0, |
86 | .maximum = 0x0f, | 88 | .maximum = 14, |
87 | .step = 1, | 89 | .step = 1, |
88 | .default_value = 0x09, | 90 | .default_value = 8, |
89 | }, | 91 | }, |
90 | .set = sd_setbrightness, | 92 | .set = sd_setbrightness, |
91 | .get = sd_getbrightness, | 93 | .get = sd_getbrightness, |
@@ -118,16 +120,17 @@ static struct ctrl sd_ctrls[] = { | |||
118 | .set = sd_setcolors, | 120 | .set = sd_setcolors, |
119 | .get = sd_getcolors, | 121 | .get = sd_getcolors, |
120 | }, | 122 | }, |
121 | #define SD_GAMMA 3 | 123 | #define GAMMA_MAX 16 |
124 | #define GAMMA_DEF 10 | ||
122 | { | 125 | { |
123 | { | 126 | { |
124 | .id = V4L2_CID_GAMMA, /* (gamma on win) */ | 127 | .id = V4L2_CID_GAMMA, /* (gamma on win) */ |
125 | .type = V4L2_CTRL_TYPE_INTEGER, | 128 | .type = V4L2_CTRL_TYPE_INTEGER, |
126 | .name = "Gamma (Untested)", | 129 | .name = "Gamma", |
127 | .minimum = 0, | 130 | .minimum = 0, |
128 | .maximum = MAX_GAMMA, | 131 | .maximum = GAMMA_MAX - 1, |
129 | .step = 1, | 132 | .step = 1, |
130 | .default_value = 0x09, | 133 | .default_value = GAMMA_DEF, |
131 | }, | 134 | }, |
132 | .set = sd_setgamma, | 135 | .set = sd_setgamma, |
133 | .get = sd_getgamma, | 136 | .get = sd_getgamma, |
@@ -197,7 +200,7 @@ static struct ctrl sd_ctrls[] = { | |||
197 | .type = V4L2_CTRL_TYPE_INTEGER, | 200 | .type = V4L2_CTRL_TYPE_INTEGER, |
198 | .name = "Sharpness", | 201 | .name = "Sharpness", |
199 | .minimum = 0, | 202 | .minimum = 0, |
200 | .maximum = MAX_GAMMA, /* 0 to 16 */ | 203 | .maximum = 15, |
201 | .step = 1, | 204 | .step = 1, |
202 | .default_value = 0x06, | 205 | .default_value = 0x06, |
203 | }, | 206 | }, |
@@ -258,7 +261,6 @@ static struct v4l2_pix_format vga_mode_t16[] = { | |||
258 | .priv = 0}, | 261 | .priv = 0}, |
259 | }; | 262 | }; |
260 | 263 | ||
261 | #define T16_OFFSET_DATA 631 | ||
262 | #define MAX_EFFECTS 7 | 264 | #define MAX_EFFECTS 7 |
263 | /* easily done by soft, this table could be removed, | 265 | /* easily done by soft, this table could be removed, |
264 | * i keep it here just in case */ | 266 | * i keep it here just in case */ |
@@ -272,87 +274,87 @@ static const __u8 effects_table[MAX_EFFECTS][6] = { | |||
272 | {0xa8, 0xc8, 0xc6, 0xd2, 0xc0, 0x40}, /* Negative */ | 274 | {0xa8, 0xc8, 0xc6, 0xd2, 0xc0, 0x40}, /* Negative */ |
273 | }; | 275 | }; |
274 | 276 | ||
275 | static const __u8 gamma_table[MAX_GAMMA][34] = { | 277 | static const __u8 gamma_table[GAMMA_MAX][34] = { |
276 | {0x90, 0x00, 0x91, 0x3e, 0x92, 0x69, 0x93, 0x85, | 278 | {0x90, 0x00, 0x91, 0x3e, 0x92, 0x69, 0x93, 0x85, /* 0 */ |
277 | 0x94, 0x95, 0x95, 0xa1, 0x96, 0xae, 0x97, 0xb9, | 279 | 0x94, 0x95, 0x95, 0xa1, 0x96, 0xae, 0x97, 0xb9, |
278 | 0x98, 0xc2, 0x99, 0xcb, 0x9a, 0xd4, 0x9b, 0xdb, | 280 | 0x98, 0xc2, 0x99, 0xcb, 0x9a, 0xd4, 0x9b, 0xdb, |
279 | 0x9c, 0xe3, 0x9d, 0xea, 0x9e, 0xf1, 0x9f, 0xf8, | 281 | 0x9c, 0xe3, 0x9d, 0xea, 0x9e, 0xf1, 0x9f, 0xf8, |
280 | 0xa0, 0xff}, | 282 | 0xa0, 0xff}, |
281 | {0x90, 0x00, 0x91, 0x33, 0x92, 0x5A, 0x93, 0x75, | 283 | {0x90, 0x00, 0x91, 0x33, 0x92, 0x5a, 0x93, 0x75, /* 1 */ |
282 | 0x94, 0x85, 0x95, 0x93, 0x96, 0xA1, 0x97, 0xAD, | 284 | 0x94, 0x85, 0x95, 0x93, 0x96, 0xa1, 0x97, 0xad, |
283 | 0x98, 0xB7, 0x99, 0xC2, 0x9A, 0xCB, 0x9B, 0xD4, | 285 | 0x98, 0xb7, 0x99, 0xc2, 0x9a, 0xcb, 0x9b, 0xd4, |
284 | 0x9C, 0xDE, 0x9D, 0xE7, 0x9E, 0xF0, 0x9F, 0xF7, | 286 | 0x9c, 0xde, 0x9D, 0xe7, 0x9e, 0xf0, 0x9f, 0xf7, |
285 | 0xa0, 0xff}, | 287 | 0xa0, 0xff}, |
286 | {0x90, 0x00, 0x91, 0x2F, 0x92, 0x51, 0x93, 0x6B, | 288 | {0x90, 0x00, 0x91, 0x2f, 0x92, 0x51, 0x93, 0x6b, /* 2 */ |
287 | 0x94, 0x7C, 0x95, 0x8A, 0x96, 0x99, 0x97, 0xA6, | 289 | 0x94, 0x7c, 0x95, 0x8a, 0x96, 0x99, 0x97, 0xa6, |
288 | 0x98, 0xB1, 0x99, 0xBC, 0x9A, 0xC6, 0x9B, 0xD0, | 290 | 0x98, 0xb1, 0x99, 0xbc, 0x9a, 0xc6, 0x9b, 0xd0, |
289 | 0x9C, 0xDB, 0x9D, 0xE4, 0x9E, 0xED, 0x9F, 0xF6, | 291 | 0x9c, 0xdb, 0x9d, 0xe4, 0x9e, 0xed, 0x9f, 0xf6, |
290 | 0xa0, 0xff}, | 292 | 0xa0, 0xff}, |
291 | {0x90, 0x00, 0x91, 0x29, 0x92, 0x48, 0x93, 0x60, | 293 | {0x90, 0x00, 0x91, 0x29, 0x92, 0x48, 0x93, 0x60, /* 3 */ |
292 | 0x94, 0x72, 0x95, 0x81, 0x96, 0x90, 0x97, 0x9E, | 294 | 0x94, 0x72, 0x95, 0x81, 0x96, 0x90, 0x97, 0x9e, |
293 | 0x98, 0xAA, 0x99, 0xB5, 0x9A, 0xBF, 0x9B, 0xCB, | 295 | 0x98, 0xaa, 0x99, 0xb5, 0x9a, 0xbf, 0x9b, 0xcb, |
294 | 0x9C, 0xD6, 0x9D, 0xE1, 0x9E, 0xEB, 0x9F, 0xF5, | 296 | 0x9c, 0xd6, 0x9d, 0xe1, 0x9e, 0xeb, 0x9f, 0xf5, |
295 | 0xa0, 0xff}, | 297 | 0xa0, 0xff}, |
296 | {0x90, 0x00, 0x91, 0x23, 0x92, 0x3F, 0x93, 0x55, | 298 | {0x90, 0x00, 0x91, 0x23, 0x92, 0x3f, 0x93, 0x55, /* 4 */ |
297 | 0x94, 0x68, 0x95, 0x77, 0x96, 0x86, 0x97, 0x95, | 299 | 0x94, 0x68, 0x95, 0x77, 0x96, 0x86, 0x97, 0x95, |
298 | 0x98, 0xA2, 0x99, 0xAD, 0x9A, 0xB9, 0x9B, 0xC6, | 300 | 0x98, 0xa2, 0x99, 0xad, 0x9a, 0xb9, 0x9b, 0xc6, |
299 | 0x9C, 0xD2, 0x9D, 0xDE, 0x9E, 0xE9, 0x9F, 0xF4, | 301 | 0x9c, 0xd2, 0x9d, 0xde, 0x9e, 0xe9, 0x9f, 0xf4, |
300 | 0xa0, 0xff}, | 302 | 0xa0, 0xff}, |
301 | {0x90, 0x00, 0x91, 0x1B, 0x92, 0x33, 0x93, 0x48, | 303 | {0x90, 0x00, 0x91, 0x1b, 0x92, 0x33, 0x93, 0x48, /* 5 */ |
302 | 0x94, 0x59, 0x95, 0x69, 0x96, 0x79, 0x97, 0x87, | 304 | 0x94, 0x59, 0x95, 0x69, 0x96, 0x79, 0x97, 0x87, |
303 | 0x98, 0x96, 0x99, 0xA3, 0x9A, 0xB1, 0x9B, 0xBE, | 305 | 0x98, 0x96, 0x99, 0xa3, 0x9a, 0xb1, 0x9b, 0xbe, |
304 | 0x9C, 0xCC, 0x9D, 0xDA, 0x9E, 0xE7, 0x9F, 0xF3, | 306 | 0x9c, 0xcc, 0x9d, 0xda, 0x9e, 0xe7, 0x9f, 0xf3, |
305 | 0xa0, 0xff}, | 307 | 0xa0, 0xff}, |
306 | {0x90, 0x00, 0x91, 0x02, 0x92, 0x10, 0x93, 0x20, | 308 | {0x90, 0x00, 0x91, 0x02, 0x92, 0x10, 0x93, 0x20, /* 6 */ |
307 | 0x94, 0x32, 0x95, 0x40, 0x96, 0x57, 0x97, 0x67, | 309 | 0x94, 0x32, 0x95, 0x40, 0x96, 0x57, 0x97, 0x67, |
308 | 0x98, 0x77, 0x99, 0x88, 0x9a, 0x99, 0x9b, 0xaa, | 310 | 0x98, 0x77, 0x99, 0x88, 0x9a, 0x99, 0x9b, 0xaa, |
309 | 0x9c, 0xbb, 0x9d, 0xcc, 0x9e, 0xdd, 0x9f, 0xee, | 311 | 0x9c, 0xbb, 0x9d, 0xcc, 0x9e, 0xdd, 0x9f, 0xee, |
310 | 0xa0, 0xff}, | 312 | 0xa0, 0xff}, |
311 | {0x90, 0x00, 0x91, 0x02, 0x92, 0x14, 0x93, 0x26, | 313 | {0x90, 0x00, 0x91, 0x02, 0x92, 0x14, 0x93, 0x26, /* 7 */ |
312 | 0x94, 0x38, 0x95, 0x4A, 0x96, 0x60, 0x97, 0x70, | 314 | 0x94, 0x38, 0x95, 0x4a, 0x96, 0x60, 0x97, 0x70, |
313 | 0x98, 0x80, 0x99, 0x90, 0x9A, 0xA0, 0x9B, 0xB0, | 315 | 0x98, 0x80, 0x99, 0x90, 0x9a, 0xa0, 0x9b, 0xb0, |
314 | 0x9C, 0xC0, 0x9D, 0xD0, 0x9E, 0xE0, 0x9F, 0xF0, | 316 | 0x9c, 0xc0, 0x9D, 0xd0, 0x9e, 0xe0, 0x9f, 0xf0, |
315 | 0xa0, 0xff}, | 317 | 0xa0, 0xff}, |
316 | {0x90, 0x00, 0x91, 0x10, 0x92, 0x22, 0x93, 0x35, | 318 | {0x90, 0x00, 0x91, 0x10, 0x92, 0x22, 0x93, 0x35, /* 8 */ |
317 | 0x94, 0x47, 0x95, 0x5A, 0x96, 0x69, 0x97, 0x79, | 319 | 0x94, 0x47, 0x95, 0x5a, 0x96, 0x69, 0x97, 0x79, |
318 | 0x98, 0x88, 0x99, 0x97, 0x9A, 0xA7, 0x9B, 0xB6, | 320 | 0x98, 0x88, 0x99, 0x97, 0x9a, 0xa7, 0x9b, 0xb6, |
319 | 0x9C, 0xC4, 0x9D, 0xD3, 0x9E, 0xE0, 0x9F, 0xF0, | 321 | 0x9c, 0xc4, 0x9d, 0xd3, 0x9e, 0xe0, 0x9f, 0xf0, |
320 | 0xa0, 0xff}, | 322 | 0xa0, 0xff}, |
321 | {0x90, 0x00, 0x91, 0x10, 0x92, 0x26, 0x93, 0x40, | 323 | {0x90, 0x00, 0x91, 0x10, 0x92, 0x26, 0x93, 0x40, /* 9 */ |
322 | 0x94, 0x54, 0x95, 0x65, 0x96, 0x75, 0x97, 0x84, | 324 | 0x94, 0x54, 0x95, 0x65, 0x96, 0x75, 0x97, 0x84, |
323 | 0x98, 0x93, 0x99, 0xa1, 0x9a, 0xb0, 0x9b, 0xbd, | 325 | 0x98, 0x93, 0x99, 0xa1, 0x9a, 0xb0, 0x9b, 0xbd, |
324 | 0x9c, 0xca, 0x9d, 0xd6, 0x9e, 0xe0, 0x9f, 0xf0, | 326 | 0x9c, 0xca, 0x9d, 0xd6, 0x9e, 0xe0, 0x9f, 0xf0, |
325 | 0xa0, 0xff}, | 327 | 0xa0, 0xff}, |
326 | {0x90, 0x00, 0x91, 0x18, 0x92, 0x2B, 0x93, 0x44, | 328 | {0x90, 0x00, 0x91, 0x18, 0x92, 0x2b, 0x93, 0x44, /* 10 */ |
327 | 0x94, 0x60, 0x95, 0x70, 0x96, 0x80, 0x97, 0x8E, | 329 | 0x94, 0x60, 0x95, 0x70, 0x96, 0x80, 0x97, 0x8e, |
328 | 0x98, 0x9C, 0x99, 0xAA, 0x9A, 0xB7, 0x9B, 0xC4, | 330 | 0x98, 0x9c, 0x99, 0xaa, 0x9a, 0xb7, 0x9b, 0xc4, |
329 | 0x9C, 0xD0, 0x9D, 0xD8, 0x9E, 0xE2, 0x9F, 0xF0, | 331 | 0x9c, 0xd0, 0x9d, 0xd8, 0x9e, 0xe2, 0x9f, 0xf0, |
330 | 0xa0, 0xff}, | 332 | 0xa0, 0xff}, |
331 | {0x90, 0x00, 0x91, 0x1A, 0x92, 0x34, 0x93, 0x52, | 333 | {0x90, 0x00, 0x91, 0x1a, 0x92, 0x34, 0x93, 0x52, /* 11 */ |
332 | 0x94, 0x66, 0x95, 0x7E, 0x96, 0x8D, 0x97, 0x9B, | 334 | 0x94, 0x66, 0x95, 0x7e, 0x96, 0x8D, 0x97, 0x9B, |
333 | 0x98, 0xA8, 0x99, 0xB4, 0x9A, 0xC0, 0x9B, 0xCB, | 335 | 0x98, 0xa8, 0x99, 0xb4, 0x9a, 0xc0, 0x9b, 0xcb, |
334 | 0x9C, 0xD6, 0x9D, 0xE1, 0x9E, 0xEB, 0x9F, 0xF5, | 336 | 0x9c, 0xd6, 0x9d, 0xe1, 0x9e, 0xeb, 0x9f, 0xf5, |
335 | 0xa0, 0xff}, | 337 | 0xa0, 0xff}, |
336 | {0x90, 0x00, 0x91, 0x3F, 0x92, 0x5A, 0x93, 0x6E, | 338 | {0x90, 0x00, 0x91, 0x3f, 0x92, 0x5a, 0x93, 0x6e, /* 12 */ |
337 | 0x94, 0x7F, 0x95, 0x8E, 0x96, 0x9C, 0x97, 0xA8, | 339 | 0x94, 0x7f, 0x95, 0x8e, 0x96, 0x9c, 0x97, 0xa8, |
338 | 0x98, 0xB4, 0x99, 0xBF, 0x9A, 0xC9, 0x9B, 0xD3, | 340 | 0x98, 0xb4, 0x99, 0xbf, 0x9a, 0xc9, 0x9b, 0xd3, |
339 | 0x9C, 0xDC, 0x9D, 0xE5, 0x9E, 0xEE, 0x9F, 0xF6, | 341 | 0x9c, 0xdc, 0x9d, 0xe5, 0x9e, 0xee, 0x9f, 0xf6, |
340 | 0xA0, 0xFF}, | ||
341 | {0x90, 0x00, 0x91, 0x54, 0x92, 0x6F, 0x93, 0x83, | ||
342 | 0x94, 0x93, 0x95, 0xA0, 0x96, 0xAD, 0x97, 0xB7, | ||
343 | 0x98, 0xC2, 0x99, 0xCB, 0x9A, 0xD4, 0x9B, 0xDC, | ||
344 | 0x9C, 0xE4, 0x9D, 0xEB, 0x9E, 0xF2, 0x9F, 0xF9, | ||
345 | 0xa0, 0xff}, | 342 | 0xa0, 0xff}, |
346 | {0x90, 0x00, 0x91, 0x6E, 0x92, 0x88, 0x93, 0x9A, | 343 | {0x90, 0x00, 0x91, 0x54, 0x92, 0x6f, 0x93, 0x83, /* 13 */ |
347 | 0x94, 0xA8, 0x95, 0xB3, 0x96, 0xBD, 0x97, 0xC6, | 344 | 0x94, 0x93, 0x95, 0xa0, 0x96, 0xad, 0x97, 0xb7, |
348 | 0x98, 0xCF, 0x99, 0xD6, 0x9A, 0xDD, 0x9B, 0xE3, | 345 | 0x98, 0xc2, 0x99, 0xcb, 0x9a, 0xd4, 0x9b, 0xdc, |
349 | 0x9C, 0xE9, 0x9D, 0xEF, 0x9E, 0xF4, 0x9F, 0xFA, | 346 | 0x9c, 0xe4, 0x9d, 0xeb, 0x9e, 0xf2, 0x9f, 0xf9, |
350 | 0xa0, 0xff}, | 347 | 0xa0, 0xff}, |
351 | {0x90, 0x00, 0x91, 0x93, 0x92, 0xA8, 0x93, 0xB7, | 348 | {0x90, 0x00, 0x91, 0x6e, 0x92, 0x88, 0x93, 0x9a, /* 14 */ |
352 | 0x94, 0xC1, 0x95, 0xCA, 0x96, 0xD2, 0x97, 0xD8, | 349 | 0x94, 0xa8, 0x95, 0xb3, 0x96, 0xbd, 0x97, 0xc6, |
353 | 0x98, 0xDE, 0x99, 0xE3, 0x9A, 0xE8, 0x9B, 0xED, | 350 | 0x98, 0xcf, 0x99, 0xd6, 0x9a, 0xdd, 0x9b, 0xe3, |
354 | 0x9C, 0xF1, 0x9D, 0xF5, 0x9E, 0xF8, 0x9F, 0xFC, | 351 | 0x9c, 0xe9, 0x9d, 0xef, 0x9e, 0xf4, 0x9f, 0xfa, |
355 | 0xA0, 0xFF} | 352 | 0xa0, 0xff}, |
353 | {0x90, 0x00, 0x91, 0x93, 0x92, 0xa8, 0x93, 0xb7, /* 15 */ | ||
354 | 0x94, 0xc1, 0x95, 0xca, 0x96, 0xd2, 0x97, 0xd8, | ||
355 | 0x98, 0xde, 0x99, 0xe3, 0x9a, 0xe8, 0x9b, 0xed, | ||
356 | 0x9c, 0xf1, 0x9d, 0xf5, 0x9e, 0xf8, 0x9f, 0xfc, | ||
357 | 0xa0, 0xff} | ||
356 | }; | 358 | }; |
357 | 359 | ||
358 | static const __u8 tas5130a_sensor_init[][8] = { | 360 | static const __u8 tas5130a_sensor_init[][8] = { |
@@ -364,7 +366,7 @@ static const __u8 tas5130a_sensor_init[][8] = { | |||
364 | }; | 366 | }; |
365 | 367 | ||
366 | /* read 1 byte */ | 368 | /* read 1 byte */ |
367 | static int reg_r_1(struct gspca_dev *gspca_dev, | 369 | static int reg_r(struct gspca_dev *gspca_dev, |
368 | __u16 index) | 370 | __u16 index) |
369 | { | 371 | { |
370 | usb_control_msg(gspca_dev->dev, | 372 | usb_control_msg(gspca_dev->dev, |
@@ -378,26 +380,26 @@ static int reg_r_1(struct gspca_dev *gspca_dev, | |||
378 | } | 380 | } |
379 | 381 | ||
380 | static void reg_w(struct gspca_dev *gspca_dev, | 382 | static void reg_w(struct gspca_dev *gspca_dev, |
381 | __u16 value, | 383 | __u16 index) |
382 | __u16 index, | 384 | { |
383 | const __u8 *buffer, __u16 len) | 385 | usb_control_msg(gspca_dev->dev, |
386 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
387 | 0, | ||
388 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
389 | 0, index, | ||
390 | NULL, 0, 500); | ||
391 | } | ||
392 | |||
393 | static void i2c_w(struct gspca_dev *gspca_dev, | ||
394 | const __u8 *buffer, __u16 len) | ||
384 | { | 395 | { |
385 | if (buffer == NULL) { | ||
386 | usb_control_msg(gspca_dev->dev, | ||
387 | usb_sndctrlpipe(gspca_dev->dev, 0), | ||
388 | 0, | ||
389 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | ||
390 | value, index, | ||
391 | NULL, 0, 500); | ||
392 | return; | ||
393 | } | ||
394 | if (len <= USB_BUF_SZ) { | 396 | if (len <= USB_BUF_SZ) { |
395 | memcpy(gspca_dev->usb_buf, buffer, len); | 397 | memcpy(gspca_dev->usb_buf, buffer, len); |
396 | usb_control_msg(gspca_dev->dev, | 398 | usb_control_msg(gspca_dev->dev, |
397 | usb_sndctrlpipe(gspca_dev->dev, 0), | 399 | usb_sndctrlpipe(gspca_dev->dev, 0), |
398 | 0, | 400 | 0, |
399 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 401 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
400 | value, index, | 402 | 0x01, 0, |
401 | gspca_dev->usb_buf, len, 500); | 403 | gspca_dev->usb_buf, len, 500); |
402 | } else { | 404 | } else { |
403 | __u8 *tmpbuf; | 405 | __u8 *tmpbuf; |
@@ -408,12 +410,56 @@ static void reg_w(struct gspca_dev *gspca_dev, | |||
408 | usb_sndctrlpipe(gspca_dev->dev, 0), | 410 | usb_sndctrlpipe(gspca_dev->dev, 0), |
409 | 0, | 411 | 0, |
410 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, | 412 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, |
411 | value, index, | 413 | 0x01, 0, |
412 | tmpbuf, len, 500); | 414 | tmpbuf, len, 500); |
413 | kfree(tmpbuf); | 415 | kfree(tmpbuf); |
414 | } | 416 | } |
415 | } | 417 | } |
416 | 418 | ||
419 | static void other_sensor_init(struct gspca_dev *gspca_dev) | ||
420 | { | ||
421 | int i; | ||
422 | const __u8 *p; | ||
423 | __u8 byte; | ||
424 | __u8 val[6] = {0x62, 0, 0x64, 0, 0x60, 0x05}; | ||
425 | static const __u8 sensor_init[] = { | ||
426 | 0xdf, 0x6d, | ||
427 | 0xdd, 0x18, | ||
428 | 0x5a, 0xe0, | ||
429 | 0x5c, 0x07, | ||
430 | 0x5d, 0xb0, | ||
431 | 0x5e, 0x1e, | ||
432 | 0x60, 0x71, | ||
433 | 0xef, 0x00, | ||
434 | 0xe9, 0x00, | ||
435 | 0xea, 0x00, | ||
436 | 0x90, 0x24, | ||
437 | 0x91, 0xb2, | ||
438 | 0x82, 0x32, | ||
439 | 0xfd, 0x00, | ||
440 | 0xfd, 0x01, | ||
441 | 0xfd, 0x41, | ||
442 | 0x00 /* table end */ | ||
443 | }; | ||
444 | |||
445 | p = sensor_init; | ||
446 | while (*p != 0) { | ||
447 | val[1] = *p++; | ||
448 | val[3] = *p++; | ||
449 | if (*p == 0) | ||
450 | reg_w(gspca_dev, 0x3c80); | ||
451 | i2c_w(gspca_dev, val, sizeof val); | ||
452 | i = 4; | ||
453 | while (--i >= 0) { | ||
454 | msleep(15); | ||
455 | byte = reg_r(gspca_dev, 0x60); | ||
456 | if (!(byte & 0x01)) | ||
457 | break; | ||
458 | } | ||
459 | } | ||
460 | reg_w(gspca_dev, 0x3c80); | ||
461 | } | ||
462 | |||
417 | /* this function is called at probe time */ | 463 | /* this function is called at probe time */ |
418 | static int sd_config(struct gspca_dev *gspca_dev, | 464 | static int sd_config(struct gspca_dev *gspca_dev, |
419 | const struct usb_device_id *id) | 465 | const struct usb_device_id *id) |
@@ -430,7 +476,7 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
430 | sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; | 476 | sd->brightness = sd_ctrls[SD_BRIGHTNESS].qctrl.default_value; |
431 | sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; | 477 | sd->contrast = sd_ctrls[SD_CONTRAST].qctrl.default_value; |
432 | sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; | 478 | sd->colors = sd_ctrls[SD_COLOR].qctrl.default_value; |
433 | sd->gamma = sd_ctrls[SD_GAMMA].qctrl.default_value; | 479 | sd->gamma = GAMMA_DEF; |
434 | sd->mirror = sd_ctrls[SD_MIRROR].qctrl.default_value; | 480 | sd->mirror = sd_ctrls[SD_MIRROR].qctrl.default_value; |
435 | sd->freq = sd_ctrls[SD_LIGHTFREQ].qctrl.default_value; | 481 | sd->freq = sd_ctrls[SD_LIGHTFREQ].qctrl.default_value; |
436 | sd->whitebalance = sd_ctrls[SD_WHITE_BALANCE].qctrl.default_value; | 482 | sd->whitebalance = sd_ctrls[SD_WHITE_BALANCE].qctrl.default_value; |
@@ -439,27 +485,37 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
439 | return 0; | 485 | return 0; |
440 | } | 486 | } |
441 | 487 | ||
442 | static int init_default_parameters(struct gspca_dev *gspca_dev) | 488 | static void setgamma(struct gspca_dev *gspca_dev) |
489 | { | ||
490 | struct sd *sd = (struct sd *) gspca_dev; | ||
491 | |||
492 | PDEBUG(D_CONF, "Gamma: %d", sd->gamma); | ||
493 | i2c_w(gspca_dev, gamma_table[sd->gamma], sizeof gamma_table[0]); | ||
494 | } | ||
495 | |||
496 | /* this function is called at probe and resume time */ | ||
497 | static int sd_init(struct gspca_dev *gspca_dev) | ||
443 | { | 498 | { |
444 | /* some of this registers are not really neded, because | 499 | /* some of this registers are not really neded, because |
445 | * they are overriden by setbrigthness, setcontrast, etc, | 500 | * they are overriden by setbrigthness, setcontrast, etc, |
446 | * but wont hurt anyway, and can help someone with similar webcam | 501 | * but wont hurt anyway, and can help someone with similar webcam |
447 | * to see the initial parameters.*/ | 502 | * to see the initial parameters.*/ |
448 | int i = 0; | 503 | struct sd *sd = (struct sd *) gspca_dev; |
449 | __u8 test_byte; | 504 | int i; |
505 | __u8 byte, test_byte; | ||
450 | 506 | ||
451 | static const __u8 read_indexs[] = | 507 | static const __u8 read_indexs[] = |
452 | { 0x06, 0x07, 0x0a, 0x0b, 0x66, 0x80, 0x81, 0x8e, 0x8f, 0xa5, | 508 | { 0x06, 0x07, 0x0a, 0x0b, 0x66, 0x80, 0x81, 0x8e, 0x8f, 0xa5, |
453 | 0xa6, 0xa8, 0xbb, 0xbc, 0xc6, 0x00, 0x00 }; | 509 | 0xa6, 0xa8, 0xbb, 0xbc, 0xc6, 0x00, 0x00 }; |
454 | static const __u8 n1[6] = | 510 | static const __u8 n1[] = |
455 | {0x08, 0x03, 0x09, 0x03, 0x12, 0x04}; | 511 | {0x08, 0x03, 0x09, 0x03, 0x12, 0x04}; |
456 | static const __u8 n2[2] = | 512 | static const __u8 n2[] = |
457 | {0x08, 0x00}; | 513 | {0x08, 0x00}; |
458 | static const __u8 nset[6] = | 514 | static const __u8 nset[] = |
459 | { 0x61, 0x68, 0x62, 0xff, 0x60, 0x07 }; | 515 | { 0x61, 0x68, 0x62, 0xff, 0x60, 0x07 }; |
460 | static const __u8 n3[6] = | 516 | static const __u8 n3[] = |
461 | {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04}; | 517 | {0x61, 0x68, 0x65, 0x0a, 0x60, 0x04}; |
462 | static const __u8 n4[0x46] = | 518 | static const __u8 n4[] = |
463 | {0x09, 0x01, 0x12, 0x04, 0x66, 0x8a, 0x80, 0x3c, | 519 | {0x09, 0x01, 0x12, 0x04, 0x66, 0x8a, 0x80, 0x3c, |
464 | 0x81, 0x22, 0x84, 0x50, 0x8a, 0x78, 0x8b, 0x68, | 520 | 0x81, 0x22, 0x84, 0x50, 0x8a, 0x78, 0x8b, 0x68, |
465 | 0x8c, 0x88, 0x8e, 0x33, 0x8f, 0x24, 0xaa, 0xb1, | 521 | 0x8c, 0x88, 0x8e, 0x33, 0x8f, 0x24, 0xaa, 0xb1, |
@@ -469,33 +525,26 @@ static int init_default_parameters(struct gspca_dev *gspca_dev) | |||
469 | 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68, | 525 | 0x65, 0x0a, 0xbb, 0x86, 0xaf, 0x58, 0xb0, 0x68, |
470 | 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40, | 526 | 0x87, 0x40, 0x89, 0x2b, 0x8d, 0xff, 0x83, 0x40, |
471 | 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46}; | 527 | 0xac, 0x84, 0xad, 0x86, 0xaf, 0x46}; |
472 | static const __u8 nset4[18] = { | 528 | static const __u8 nset4[] = { |
473 | 0xe0, 0x60, 0xe1, 0xa8, 0xe2, 0xe0, 0xe3, 0x60, 0xe4, 0xa8, | 529 | 0xe0, 0x60, 0xe1, 0xa8, 0xe2, 0xe0, 0xe3, 0x60, 0xe4, 0xa8, |
474 | 0xe5, 0xe0, 0xe6, 0x60, 0xe7, 0xa8, | 530 | 0xe5, 0xe0, 0xe6, 0x60, 0xe7, 0xa8, |
475 | 0xe8, 0xe0 | 531 | 0xe8, 0xe0 |
476 | }; | 532 | }; |
477 | /* ojo puede ser 0xe6 en vez de 0xe9 */ | 533 | /* ojo puede ser 0xe6 en vez de 0xe9 */ |
478 | static const __u8 nset2[20] = { | 534 | static const __u8 nset2[] = { |
479 | 0xd0, 0xbb, 0xd1, 0x28, 0xd2, 0x10, 0xd3, 0x10, 0xd4, 0xbb, | 535 | 0xd0, 0xbb, 0xd1, 0x28, 0xd2, 0x10, 0xd3, 0x10, 0xd4, 0xbb, |
480 | 0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27, | 536 | 0xd5, 0x28, 0xd6, 0x1e, 0xd7, 0x27, |
481 | 0xd8, 0xc8, 0xd9, 0xfc | 537 | 0xd8, 0xc8, 0xd9, 0xfc |
482 | }; | 538 | }; |
483 | static const __u8 missing[8] = | 539 | static const __u8 missing[] = |
484 | { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 }; | 540 | { 0x87, 0x20, 0x88, 0x20, 0x89, 0x20, 0x80, 0x38 }; |
485 | static const __u8 nset3[18] = { | 541 | static const __u8 nset3[] = { |
486 | 0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, 0xcb, 0xa8, | 542 | 0xc7, 0x60, 0xc8, 0xa8, 0xc9, 0xe0, 0xca, 0x60, 0xcb, 0xa8, |
487 | 0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8, | 543 | 0xcc, 0xe0, 0xcd, 0x60, 0xce, 0xa8, |
488 | 0xcf, 0xe0 | 544 | 0xcf, 0xe0 |
489 | }; | 545 | }; |
490 | static const __u8 nset5[4] = | 546 | static const __u8 nset5[] = |
491 | { 0x8f, 0x24, 0xc3, 0x00 }; /* bright */ | 547 | { 0x8f, 0x24, 0xc3, 0x00 }; /* bright */ |
492 | static const __u8 nset6[34] = { | ||
493 | 0x90, 0x00, 0x91, 0x1c, 0x92, 0x30, 0x93, 0x43, 0x94, 0x54, | ||
494 | 0x95, 0x65, 0x96, 0x75, 0x97, 0x84, | ||
495 | 0x98, 0x93, 0x99, 0xa1, 0x9a, 0xb0, 0x9b, 0xbd, 0x9c, 0xca, | ||
496 | 0x9d, 0xd8, 0x9e, 0xe5, 0x9f, 0xf2, | ||
497 | 0xa0, 0xff | ||
498 | }; /* Gamma */ | ||
499 | static const __u8 nset7[4] = | 548 | static const __u8 nset7[4] = |
500 | { 0x66, 0xca, 0xa8, 0xf8 }; /* 50/60 Hz */ | 549 | { 0x66, 0xca, 0xa8, 0xf8 }; /* 50/60 Hz */ |
501 | static const __u8 nset9[4] = | 550 | static const __u8 nset9[4] = |
@@ -505,57 +554,74 @@ static int init_default_parameters(struct gspca_dev *gspca_dev) | |||
505 | static const __u8 nset10[6] = | 554 | static const __u8 nset10[6] = |
506 | { 0x0c, 0x03, 0xab, 0x10, 0x81, 0x20 }; | 555 | { 0x0c, 0x03, 0xab, 0x10, 0x81, 0x20 }; |
507 | 556 | ||
508 | reg_w(gspca_dev, 0x01, 0x0000, n1, 0x06); | 557 | byte = reg_r(gspca_dev, 0x06); |
509 | reg_w(gspca_dev, 0x01, 0x0000, nset, 0x06); | 558 | test_byte = reg_r(gspca_dev, 0x07); |
510 | reg_r_1(gspca_dev, 0x0063); | 559 | if (byte == 0x08 && test_byte == 0x07) { |
511 | reg_w(gspca_dev, 0x01, 0x0000, n2, 0x02); | 560 | PDEBUG(D_CONF, "other sensor"); |
561 | sd->sensor = SENSOR_OTHER; | ||
562 | } else { | ||
563 | PDEBUG(D_CONF, "sensor %02x %02x", byte, test_byte); | ||
564 | sd->sensor = SENSOR_TAS5130A; | ||
565 | } | ||
566 | |||
567 | i2c_w(gspca_dev, n1, sizeof n1); | ||
568 | test_byte = 0; | ||
569 | i = 5; | ||
570 | while (--i >= 0) { | ||
571 | i2c_w(gspca_dev, nset, sizeof nset); | ||
572 | msleep(5); | ||
573 | test_byte = reg_r(gspca_dev, 0x0063); | ||
574 | msleep(100); | ||
575 | if (test_byte == 0x17) | ||
576 | break; /* OK */ | ||
577 | } | ||
578 | if (i < 0) { | ||
579 | err("Bad sensor reset %02x", test_byte); | ||
580 | /* return -EIO; */ | ||
581 | /*fixme: test - continue */ | ||
582 | } | ||
583 | i2c_w(gspca_dev, n2, sizeof n2); | ||
512 | 584 | ||
585 | i = 0; | ||
513 | while (read_indexs[i] != 0x00) { | 586 | while (read_indexs[i] != 0x00) { |
514 | test_byte = reg_r_1(gspca_dev, read_indexs[i]); | 587 | test_byte = reg_r(gspca_dev, read_indexs[i]); |
515 | PDEBUG(D_CONF, "Reg 0x%02x => 0x%02x", read_indexs[i], | 588 | PDEBUG(D_STREAM, "Reg 0x%02x = 0x%02x", read_indexs[i], |
516 | test_byte); | 589 | test_byte); |
517 | i++; | 590 | i++; |
518 | } | 591 | } |
519 | 592 | ||
520 | reg_w(gspca_dev, 0x01, 0x0000, n3, 0x06); | 593 | i2c_w(gspca_dev, n3, sizeof n3); |
521 | reg_w(gspca_dev, 0x01, 0x0000, n4, 0x46); | 594 | i2c_w(gspca_dev, n4, sizeof n4); |
522 | reg_r_1(gspca_dev, 0x0080); | 595 | reg_r(gspca_dev, 0x0080); |
523 | reg_w(gspca_dev, 0x00, 0x2c80, NULL, 0); | 596 | reg_w(gspca_dev, 0x2c80); |
524 | reg_w(gspca_dev, 0x01, 0x0000, nset2, 0x14); | 597 | i2c_w(gspca_dev, nset2, sizeof nset2); |
525 | reg_w(gspca_dev, 0x01, 0x0000, nset3, 0x12); | 598 | i2c_w(gspca_dev, nset3, sizeof nset3); |
526 | reg_w(gspca_dev, 0x01, 0x0000, nset4, 0x12); | 599 | i2c_w(gspca_dev, nset4, sizeof nset4); |
527 | reg_w(gspca_dev, 0x00, 0x3880, NULL, 0); | 600 | reg_w(gspca_dev, 0x3880); |
528 | reg_w(gspca_dev, 0x00, 0x3880, NULL, 0); | 601 | reg_w(gspca_dev, 0x3880); |
529 | reg_w(gspca_dev, 0x00, 0x338e, NULL, 0); | 602 | reg_w(gspca_dev, 0x338e); |
530 | reg_w(gspca_dev, 0x01, 0x0000, nset5, 0x04); | 603 | i2c_w(gspca_dev, nset5, sizeof nset5); |
531 | reg_w(gspca_dev, 0x00, 0x00a9, NULL, 0); | 604 | reg_w(gspca_dev, 0x00a9); |
532 | reg_w(gspca_dev, 0x01, 0x0000, nset6, 0x22); | 605 | setgamma(gspca_dev); |
533 | reg_w(gspca_dev, 0x00, 0x86bb, NULL, 0); | 606 | reg_w(gspca_dev, 0x86bb); |
534 | reg_w(gspca_dev, 0x00, 0x4aa6, NULL, 0); | 607 | reg_w(gspca_dev, 0x4aa6); |
535 | 608 | ||
536 | reg_w(gspca_dev, 0x01, 0x0000, missing, 0x08); | 609 | i2c_w(gspca_dev, missing, sizeof missing); |
537 | 610 | ||
538 | reg_w(gspca_dev, 0x00, 0x2087, NULL, 0); | 611 | reg_w(gspca_dev, 0x2087); |
539 | reg_w(gspca_dev, 0x00, 0x2088, NULL, 0); | 612 | reg_w(gspca_dev, 0x2088); |
540 | reg_w(gspca_dev, 0x00, 0x2089, NULL, 0); | 613 | reg_w(gspca_dev, 0x2089); |
541 | 614 | ||
542 | reg_w(gspca_dev, 0x01, 0x0000, nset7, 0x04); | 615 | i2c_w(gspca_dev, nset7, sizeof nset7); |
543 | reg_w(gspca_dev, 0x01, 0x0000, nset10, 0x06); | 616 | i2c_w(gspca_dev, nset10, sizeof nset10); |
544 | reg_w(gspca_dev, 0x01, 0x0000, nset8, 0x06); | 617 | i2c_w(gspca_dev, nset8, sizeof nset8); |
545 | reg_w(gspca_dev, 0x01, 0x0000, nset9, 0x04); | 618 | i2c_w(gspca_dev, nset9, sizeof nset9); |
546 | 619 | ||
547 | reg_w(gspca_dev, 0x00, 0x2880, NULL, 0); | 620 | reg_w(gspca_dev, 0x2880); |
548 | reg_w(gspca_dev, 0x01, 0x0000, nset2, 0x14); | 621 | i2c_w(gspca_dev, nset2, sizeof nset2); |
549 | reg_w(gspca_dev, 0x01, 0x0000, nset3, 0x12); | 622 | i2c_w(gspca_dev, nset3, sizeof nset3); |
550 | reg_w(gspca_dev, 0x01, 0x0000, nset4, 0x12); | 623 | i2c_w(gspca_dev, nset4, sizeof nset4); |
551 | |||
552 | return 0; | ||
553 | } | ||
554 | 624 | ||
555 | /* this function is called at probe and resume time */ | ||
556 | static int sd_init(struct gspca_dev *gspca_dev) | ||
557 | { | ||
558 | init_default_parameters(gspca_dev); | ||
559 | return 0; | 625 | return 0; |
560 | } | 626 | } |
561 | 627 | ||
@@ -563,37 +629,36 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
563 | { | 629 | { |
564 | struct sd *sd = (struct sd *) gspca_dev; | 630 | struct sd *sd = (struct sd *) gspca_dev; |
565 | unsigned int brightness; | 631 | unsigned int brightness; |
566 | __u8 set6[4] = { 0x8f, 0x26, 0xc3, 0x80 }; | 632 | __u8 set6[4] = { 0x8f, 0x26, 0xc3, 0x00 }; |
567 | brightness = sd->brightness; | ||
568 | 633 | ||
634 | brightness = sd->brightness; | ||
569 | if (brightness < 7) { | 635 | if (brightness < 7) { |
570 | set6[3] = 0x70 - (brightness * 0xa); | 636 | set6[3] = 0x70 - brightness * 0x10; |
571 | } else { | 637 | } else { |
572 | set6[1] = 0x24; | 638 | set6[1] = 0x24; |
573 | set6[3] = 0x00 + ((brightness - 7) * 0xa); | 639 | set6[3] = 0x00 + ((brightness - 7) * 0x10); |
574 | } | 640 | } |
575 | 641 | ||
576 | reg_w(gspca_dev, 0x01, 0x0000, set6, 4); | 642 | i2c_w(gspca_dev, set6, sizeof set6); |
577 | } | 643 | } |
578 | 644 | ||
579 | static void setflip(struct gspca_dev *gspca_dev) | 645 | static void setflip(struct gspca_dev *gspca_dev) |
580 | { | 646 | { |
581 | struct sd *sd = (struct sd *) gspca_dev; | 647 | struct sd *sd = (struct sd *) gspca_dev; |
582 | |||
583 | __u8 flipcmd[8] = | 648 | __u8 flipcmd[8] = |
584 | { 0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09 }; | 649 | {0x62, 0x07, 0x63, 0x03, 0x64, 0x00, 0x60, 0x09}; |
585 | 650 | ||
586 | if (sd->mirror == 1) | 651 | if (sd->mirror) |
587 | flipcmd[3] = 0x01; | 652 | flipcmd[3] = 0x01; |
588 | 653 | ||
589 | reg_w(gspca_dev, 0x01, 0x0000, flipcmd, 8); | 654 | i2c_w(gspca_dev, flipcmd, sizeof flipcmd); |
590 | } | 655 | } |
591 | 656 | ||
592 | static void seteffect(struct gspca_dev *gspca_dev) | 657 | static void seteffect(struct gspca_dev *gspca_dev) |
593 | { | 658 | { |
594 | struct sd *sd = (struct sd *) gspca_dev; | 659 | struct sd *sd = (struct sd *) gspca_dev; |
595 | 660 | ||
596 | reg_w(gspca_dev, 0x01, 0x0000, effects_table[sd->effect], 0x06); | 661 | i2c_w(gspca_dev, effects_table[sd->effect], sizeof effects_table[0]); |
597 | if (sd->effect == 1 || sd->effect == 5) { | 662 | if (sd->effect == 1 || sd->effect == 5) { |
598 | PDEBUG(D_CONF, | 663 | PDEBUG(D_CONF, |
599 | "This effect have been disabled for webcam \"safety\""); | 664 | "This effect have been disabled for webcam \"safety\""); |
@@ -601,9 +666,9 @@ static void seteffect(struct gspca_dev *gspca_dev) | |||
601 | } | 666 | } |
602 | 667 | ||
603 | if (sd->effect == 1 || sd->effect == 4) | 668 | if (sd->effect == 1 || sd->effect == 4) |
604 | reg_w(gspca_dev, 0x00, 0x4aa6, NULL, 0); | 669 | reg_w(gspca_dev, 0x4aa6); |
605 | else | 670 | else |
606 | reg_w(gspca_dev, 0x00, 0xfaa6, NULL, 0); | 671 | reg_w(gspca_dev, 0xfaa6); |
607 | } | 672 | } |
608 | 673 | ||
609 | static void setwhitebalance(struct gspca_dev *gspca_dev) | 674 | static void setwhitebalance(struct gspca_dev *gspca_dev) |
@@ -616,7 +681,7 @@ static void setwhitebalance(struct gspca_dev *gspca_dev) | |||
616 | if (sd->whitebalance == 1) | 681 | if (sd->whitebalance == 1) |
617 | white_balance[7] = 0x3c; | 682 | white_balance[7] = 0x3c; |
618 | 683 | ||
619 | reg_w(gspca_dev, 0x01, 0x0000, white_balance, 8); | 684 | i2c_w(gspca_dev, white_balance, sizeof white_balance); |
620 | } | 685 | } |
621 | 686 | ||
622 | static void setlightfreq(struct gspca_dev *gspca_dev) | 687 | static void setlightfreq(struct gspca_dev *gspca_dev) |
@@ -627,21 +692,21 @@ static void setlightfreq(struct gspca_dev *gspca_dev) | |||
627 | if (sd->freq == 2) /* 60hz */ | 692 | if (sd->freq == 2) /* 60hz */ |
628 | freq[1] = 0x00; | 693 | freq[1] = 0x00; |
629 | 694 | ||
630 | reg_w(gspca_dev, 0x1, 0x0000, freq, 0x4); | 695 | i2c_w(gspca_dev, freq, sizeof freq); |
631 | } | 696 | } |
632 | 697 | ||
633 | static void setcontrast(struct gspca_dev *gspca_dev) | 698 | static void setcontrast(struct gspca_dev *gspca_dev) |
634 | { | 699 | { |
635 | struct sd *sd = (struct sd *) gspca_dev; | 700 | struct sd *sd = (struct sd *) gspca_dev; |
636 | unsigned int contrast = sd->contrast; | 701 | unsigned int contrast = sd->contrast; |
637 | __u16 reg_to_write = 0x00; | 702 | __u16 reg_to_write; |
638 | 703 | ||
639 | if (contrast < 7) | 704 | if (contrast < 7) |
640 | reg_to_write = 0x8ea9 - (0x200 * contrast); | 705 | reg_to_write = 0x8ea9 - (0x200 * contrast); |
641 | else | 706 | else |
642 | reg_to_write = (0x00a9 + ((contrast - 7) * 0x200)); | 707 | reg_to_write = (0x00a9 + ((contrast - 7) * 0x200)); |
643 | 708 | ||
644 | reg_w(gspca_dev, 0x00, reg_to_write, NULL, 0); | 709 | reg_w(gspca_dev, reg_to_write); |
645 | } | 710 | } |
646 | 711 | ||
647 | static void setcolors(struct gspca_dev *gspca_dev) | 712 | static void setcolors(struct gspca_dev *gspca_dev) |
@@ -650,11 +715,7 @@ static void setcolors(struct gspca_dev *gspca_dev) | |||
650 | __u16 reg_to_write; | 715 | __u16 reg_to_write; |
651 | 716 | ||
652 | reg_to_write = 0xc0bb + sd->colors * 0x100; | 717 | reg_to_write = 0xc0bb + sd->colors * 0x100; |
653 | reg_w(gspca_dev, 0x00, reg_to_write, NULL, 0); | 718 | reg_w(gspca_dev, reg_to_write); |
654 | } | ||
655 | |||
656 | static void setgamma(struct gspca_dev *gspca_dev) | ||
657 | { | ||
658 | } | 719 | } |
659 | 720 | ||
660 | static void setsharpness(struct gspca_dev *gspca_dev) | 721 | static void setsharpness(struct gspca_dev *gspca_dev) |
@@ -664,7 +725,99 @@ static void setsharpness(struct gspca_dev *gspca_dev) | |||
664 | 725 | ||
665 | reg_to_write = 0x0aa6 + 0x1000 * sd->sharpness; | 726 | reg_to_write = 0x0aa6 + 0x1000 * sd->sharpness; |
666 | 727 | ||
667 | reg_w(gspca_dev, 0x00, reg_to_write, NULL, 0); | 728 | reg_w(gspca_dev, reg_to_write); |
729 | } | ||
730 | |||
731 | static int sd_start(struct gspca_dev *gspca_dev) | ||
732 | { | ||
733 | struct sd *sd = (struct sd *) gspca_dev; | ||
734 | int i, mode; | ||
735 | static const __u8 t1[] = { 0x66, 0x00, 0xa8, 0xe8 }; | ||
736 | __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 }; | ||
737 | static const __u8 t3[] = | ||
738 | { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06, | ||
739 | 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 }; | ||
740 | static const __u8 t4[] = { 0x0b, 0x04, 0x0a, 0x40 }; | ||
741 | |||
742 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv; | ||
743 | switch (mode) { | ||
744 | case 1: /* 352x288 */ | ||
745 | t2[1] = 0x40; | ||
746 | break; | ||
747 | case 2: /* 320x240 */ | ||
748 | t2[1] = 0x10; | ||
749 | break; | ||
750 | case 3: /* 176x144 */ | ||
751 | t2[1] = 0x50; | ||
752 | break; | ||
753 | case 4: /* 160x120 */ | ||
754 | t2[1] = 0x20; | ||
755 | break; | ||
756 | default: /* 640x480 (0x00) */ | ||
757 | break; | ||
758 | } | ||
759 | |||
760 | if (sd->sensor == SENSOR_TAS5130A) { | ||
761 | i = 0; | ||
762 | while (tas5130a_sensor_init[i][0] != 0) { | ||
763 | i2c_w(gspca_dev, tas5130a_sensor_init[i], | ||
764 | sizeof tas5130a_sensor_init[0]); | ||
765 | i++; | ||
766 | } | ||
767 | reg_w(gspca_dev, 0x3c80); | ||
768 | /* just in case and to keep sync with logs (for mine) */ | ||
769 | i2c_w(gspca_dev, tas5130a_sensor_init[3], | ||
770 | sizeof tas5130a_sensor_init[0]); | ||
771 | reg_w(gspca_dev, 0x3c80); | ||
772 | } else { | ||
773 | other_sensor_init(gspca_dev); | ||
774 | } | ||
775 | /* just in case and to keep sync with logs (for mine) */ | ||
776 | i2c_w(gspca_dev, t1, sizeof t1); | ||
777 | i2c_w(gspca_dev, t2, sizeof t2); | ||
778 | reg_r(gspca_dev, 0x0012); | ||
779 | i2c_w(gspca_dev, t3, sizeof t3); | ||
780 | reg_w(gspca_dev, 0x0013); | ||
781 | i2c_w(gspca_dev, t4, sizeof t4); | ||
782 | /* restart on each start, just in case, sometimes regs goes wrong | ||
783 | * when using controls from app */ | ||
784 | setbrightness(gspca_dev); | ||
785 | setcontrast(gspca_dev); | ||
786 | setcolors(gspca_dev); | ||
787 | return 0; | ||
788 | } | ||
789 | |||
790 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | ||
791 | struct gspca_frame *frame, /* target */ | ||
792 | __u8 *data, /* isoc packet */ | ||
793 | int len) /* iso packet length */ | ||
794 | { | ||
795 | static __u8 ffd9[] = { 0xff, 0xd9 }; | ||
796 | |||
797 | if (data[0] == 0x5a) { | ||
798 | /* Control Packet, after this came the header again, | ||
799 | * but extra bytes came in the packet before this, | ||
800 | * sometimes an EOF arrives, sometimes not... */ | ||
801 | return; | ||
802 | } | ||
803 | data += 2; | ||
804 | len -= 2; | ||
805 | if (data[0] == 0xff && data[1] == 0xd8) { | ||
806 | /* extra bytes....., could be processed too but would be | ||
807 | * a waste of time, right now leave the application and | ||
808 | * libjpeg do it for ourserlves.. */ | ||
809 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, | ||
810 | ffd9, 2); | ||
811 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len); | ||
812 | return; | ||
813 | } | ||
814 | |||
815 | if (data[len - 2] == 0xff && data[len - 1] == 0xd9) { | ||
816 | /* Just in case, i have seen packets with the marker, | ||
817 | * other's do not include it... */ | ||
818 | len -= 2; | ||
819 | } | ||
820 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); | ||
668 | } | 821 | } |
669 | 822 | ||
670 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 823 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |
@@ -788,6 +941,7 @@ static int sd_setgamma(struct gspca_dev *gspca_dev, __s32 val) | |||
788 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val) | 941 | static int sd_getgamma(struct gspca_dev *gspca_dev, __s32 *val) |
789 | { | 942 | { |
790 | struct sd *sd = (struct sd *) gspca_dev; | 943 | struct sd *sd = (struct sd *) gspca_dev; |
944 | |||
791 | *val = sd->gamma; | 945 | *val = sd->gamma; |
792 | return 0; | 946 | return 0; |
793 | } | 947 | } |
@@ -835,9 +989,9 @@ static int sd_setlowlight(struct gspca_dev *gspca_dev, __s32 val) | |||
835 | 989 | ||
836 | sd->autogain = val; | 990 | sd->autogain = val; |
837 | if (val != 0) | 991 | if (val != 0) |
838 | reg_w(gspca_dev, 0x00, 0xf48e, NULL, 0); | 992 | reg_w(gspca_dev, 0xf48e); |
839 | else | 993 | else |
840 | reg_w(gspca_dev, 0x00, 0xb48e, NULL, 0); | 994 | reg_w(gspca_dev, 0xb48e); |
841 | return 0; | 995 | return 0; |
842 | } | 996 | } |
843 | 997 | ||
@@ -849,100 +1003,6 @@ static int sd_getlowlight(struct gspca_dev *gspca_dev, __s32 *val) | |||
849 | return 0; | 1003 | return 0; |
850 | } | 1004 | } |
851 | 1005 | ||
852 | static int sd_start(struct gspca_dev *gspca_dev) | ||
853 | { | ||
854 | int mode; | ||
855 | |||
856 | static const __u8 t1[] = { 0x66, 0x00, 0xa8, 0xe8 }; | ||
857 | __u8 t2[] = { 0x07, 0x00, 0x0d, 0x60, 0x0e, 0x80 }; | ||
858 | static const __u8 t3[] = | ||
859 | { 0xb3, 0x07, 0xb4, 0x00, 0xb5, 0x88, 0xb6, 0x02, 0xb7, 0x06, | ||
860 | 0xb8, 0x00, 0xb9, 0xe7, 0xba, 0x01 }; | ||
861 | static const __u8 t4[] = { 0x0b, 0x04, 0x0a, 0x40 }; | ||
862 | |||
863 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode]. priv; | ||
864 | switch (mode) { | ||
865 | case 1: /* 352x288 */ | ||
866 | t2[1] = 0x40; | ||
867 | break; | ||
868 | case 2: /* 320x240 */ | ||
869 | t2[1] = 0x10; | ||
870 | break; | ||
871 | case 3: /* 176x144 */ | ||
872 | t2[1] = 0x50; | ||
873 | break; | ||
874 | case 4: /* 160x120 */ | ||
875 | t2[1] = 0x20; | ||
876 | break; | ||
877 | default: /* 640x480 (0x00) */ | ||
878 | break; | ||
879 | } | ||
880 | |||
881 | reg_w(gspca_dev, 0x01, 0x0000, tas5130a_sensor_init[0], 0x8); | ||
882 | reg_w(gspca_dev, 0x01, 0x0000, tas5130a_sensor_init[1], 0x8); | ||
883 | reg_w(gspca_dev, 0x01, 0x0000, tas5130a_sensor_init[2], 0x8); | ||
884 | reg_w(gspca_dev, 0x01, 0x0000, tas5130a_sensor_init[3], 0x8); | ||
885 | reg_w(gspca_dev, 0x00, 0x3c80, NULL, 0); | ||
886 | /* just in case and to keep sync with logs (for mine) */ | ||
887 | reg_w(gspca_dev, 0x01, 0x0000, tas5130a_sensor_init[3], 0x8); | ||
888 | reg_w(gspca_dev, 0x00, 0x3c80, NULL, 0); | ||
889 | /* just in case and to keep sync with logs (for mine) */ | ||
890 | reg_w(gspca_dev, 0x01, 0x0000, t1, 4); | ||
891 | reg_w(gspca_dev, 0x01, 0x0000, t2, 6); | ||
892 | reg_r_1(gspca_dev, 0x0012); | ||
893 | reg_w(gspca_dev, 0x01, 0x0000, t3, 0x10); | ||
894 | reg_w(gspca_dev, 0x00, 0x0013, NULL, 0); | ||
895 | reg_w(gspca_dev, 0x01, 0x0000, t4, 0x4); | ||
896 | /* restart on each start, just in case, sometimes regs goes wrong | ||
897 | * when using controls from app */ | ||
898 | setbrightness(gspca_dev); | ||
899 | setcontrast(gspca_dev); | ||
900 | setcolors(gspca_dev); | ||
901 | return 0; | ||
902 | } | ||
903 | |||
904 | static void sd_pkt_scan(struct gspca_dev *gspca_dev, | ||
905 | struct gspca_frame *frame, /* target */ | ||
906 | __u8 *data, /* isoc packet */ | ||
907 | int len) /* iso packet length */ | ||
908 | { | ||
909 | int sof = 0; | ||
910 | static __u8 ffd9[] = { 0xff, 0xd9 }; | ||
911 | |||
912 | if (data[0] == 0x5a) { | ||
913 | /* Control Packet, after this came the header again, | ||
914 | * but extra bytes came in the packet before this, | ||
915 | * sometimes an EOF arrives, sometimes not... */ | ||
916 | return; | ||
917 | } | ||
918 | |||
919 | if (data[len - 2] == 0xff && data[len - 1] == 0xd9) { | ||
920 | /* Just in case, i have seen packets with the marker, | ||
921 | * other's do not include it... */ | ||
922 | data += 2; | ||
923 | len -= 4; | ||
924 | } else if (data[2] == 0xff && data[3] == 0xd8) { | ||
925 | sof = 1; | ||
926 | data += 2; | ||
927 | len -= 2; | ||
928 | } else { | ||
929 | data += 2; | ||
930 | len -= 2; | ||
931 | } | ||
932 | |||
933 | if (sof) { | ||
934 | /* extra bytes....., could be processed too but would be | ||
935 | * a waste of time, right now leave the application and | ||
936 | * libjpeg do it for ourserlves.. */ | ||
937 | frame = gspca_frame_add(gspca_dev, LAST_PACKET, frame, | ||
938 | ffd9, 2); | ||
939 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, data, len); | ||
940 | return; | ||
941 | } | ||
942 | |||
943 | gspca_frame_add(gspca_dev, INTER_PACKET, frame, data, len); | ||
944 | } | ||
945 | |||
946 | static int sd_querymenu(struct gspca_dev *gspca_dev, | 1006 | static int sd_querymenu(struct gspca_dev *gspca_dev, |
947 | struct v4l2_querymenu *menu) | 1007 | struct v4l2_querymenu *menu) |
948 | { | 1008 | { |