diff options
Diffstat (limited to 'drivers/media/video/gspca/conex.c')
-rw-r--r-- | drivers/media/video/gspca/conex.c | 385 |
1 files changed, 176 insertions, 209 deletions
diff --git a/drivers/media/video/gspca/conex.c b/drivers/media/video/gspca/conex.c index b5481017dd4f..013d593b0c67 100644 --- a/drivers/media/video/gspca/conex.c +++ b/drivers/media/video/gspca/conex.c | |||
@@ -25,8 +25,8 @@ | |||
25 | #define CONEX_CAM 1 /* special JPEG header */ | 25 | #define CONEX_CAM 1 /* special JPEG header */ |
26 | #include "jpeg.h" | 26 | #include "jpeg.h" |
27 | 27 | ||
28 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5) | 28 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7) |
29 | static const char version[] = "2.1.5"; | 29 | static const char version[] = "2.1.7"; |
30 | 30 | ||
31 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); | 31 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); |
32 | MODULE_DESCRIPTION("GSPCA USB Conexant Camera Driver"); | 32 | MODULE_DESCRIPTION("GSPCA USB Conexant Camera Driver"); |
@@ -119,40 +119,67 @@ static struct v4l2_pix_format vga_mode[] = { | |||
119 | .priv = 0}, | 119 | .priv = 0}, |
120 | }; | 120 | }; |
121 | 121 | ||
122 | static void reg_r(struct usb_device *dev, | 122 | /* the read bytes are found in gspca_dev->usb_buf */ |
123 | __u16 index, | 123 | static void reg_r(struct gspca_dev *gspca_dev, |
124 | __u8 *buffer, __u16 length) | 124 | __u16 index, |
125 | __u16 len) | ||
125 | { | 126 | { |
127 | struct usb_device *dev = gspca_dev->dev; | ||
128 | |||
129 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
130 | if (len > sizeof gspca_dev->usb_buf) { | ||
131 | err("reg_r: buffer overflow"); | ||
132 | return; | ||
133 | } | ||
134 | #endif | ||
126 | usb_control_msg(dev, | 135 | usb_control_msg(dev, |
127 | usb_rcvctrlpipe(dev, 0), | 136 | usb_rcvctrlpipe(dev, 0), |
128 | 0, | 137 | 0, |
129 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 138 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
130 | 0, | 139 | 0, |
131 | index, buffer, length, | 140 | index, gspca_dev->usb_buf, len, |
132 | 500); | 141 | 500); |
133 | PDEBUG(D_USBI, "reg read [%02x] -> %02x ..", index, *buffer); | 142 | PDEBUG(D_USBI, "reg read [%02x] -> %02x ..", |
143 | index, gspca_dev->usb_buf[0]); | ||
144 | } | ||
145 | |||
146 | /* the bytes to write are in gspca_dev->usb_buf */ | ||
147 | static void reg_w_val(struct gspca_dev *gspca_dev, | ||
148 | __u16 index, | ||
149 | __u8 val) | ||
150 | { | ||
151 | struct usb_device *dev = gspca_dev->dev; | ||
152 | |||
153 | gspca_dev->usb_buf[0] = val; | ||
154 | usb_control_msg(dev, | ||
155 | usb_sndctrlpipe(dev, 0), | ||
156 | 0, | ||
157 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
158 | 0, | ||
159 | index, gspca_dev->usb_buf, 1, 500); | ||
134 | } | 160 | } |
135 | 161 | ||
136 | static void reg_w(struct usb_device *dev, | 162 | static void reg_w(struct gspca_dev *gspca_dev, |
137 | __u16 index, | 163 | __u16 index, |
138 | const __u8 *buffer, __u16 len) | 164 | const __u8 *buffer, |
165 | __u16 len) | ||
139 | { | 166 | { |
140 | __u8 tmpbuf[8]; | 167 | struct usb_device *dev = gspca_dev->dev; |
141 | 168 | ||
142 | #ifdef CONFIG_VIDEO_ADV_DEBUG | 169 | #ifdef CONFIG_VIDEO_ADV_DEBUG |
143 | if (len > sizeof tmpbuf) { | 170 | if (len > sizeof gspca_dev->usb_buf) { |
144 | PDEBUG(D_ERR|D_PACK, "reg_w: buffer overflow"); | 171 | err("reg_w: buffer overflow"); |
145 | return; | 172 | return; |
146 | } | 173 | } |
147 | PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer); | 174 | PDEBUG(D_USBO, "reg write [%02x] = %02x..", index, *buffer); |
148 | #endif | 175 | #endif |
149 | memcpy(tmpbuf, buffer, len); | 176 | memcpy(gspca_dev->usb_buf, buffer, len); |
150 | usb_control_msg(dev, | 177 | usb_control_msg(dev, |
151 | usb_sndctrlpipe(dev, 0), | 178 | usb_sndctrlpipe(dev, 0), |
152 | 0, | 179 | 0, |
153 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 180 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
154 | 0, | 181 | 0, |
155 | index, tmpbuf, len, 500); | 182 | index, gspca_dev->usb_buf, len, 500); |
156 | } | 183 | } |
157 | 184 | ||
158 | static const __u8 cx_sensor_init[][4] = { | 185 | static const __u8 cx_sensor_init[][4] = { |
@@ -232,17 +259,14 @@ static const __u8 cx11646_fw1[][3] = { | |||
232 | }; | 259 | }; |
233 | static void cx11646_fw(struct gspca_dev*gspca_dev) | 260 | static void cx11646_fw(struct gspca_dev*gspca_dev) |
234 | { | 261 | { |
235 | __u8 val; | ||
236 | int i = 0; | 262 | int i = 0; |
237 | 263 | ||
238 | val = 0x02; | 264 | reg_w_val(gspca_dev, 0x006a, 0x02); |
239 | reg_w(gspca_dev->dev, 0x006a, &val, 1); | ||
240 | while (cx11646_fw1[i][1]) { | 265 | while (cx11646_fw1[i][1]) { |
241 | reg_w(gspca_dev->dev, 0x006b, cx11646_fw1[i], 3); | 266 | reg_w(gspca_dev, 0x006b, cx11646_fw1[i], 3); |
242 | i++; | 267 | i++; |
243 | } | 268 | } |
244 | val = 0x00; | 269 | reg_w_val(gspca_dev, 0x006a, 0x00); |
245 | reg_w(gspca_dev->dev, 0x006a, &val, 1); | ||
246 | } | 270 | } |
247 | 271 | ||
248 | static const __u8 cxsensor[] = { | 272 | static const __u8 cxsensor[] = { |
@@ -273,52 +297,47 @@ static const __u8 reg7b[] = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff }; | |||
273 | 297 | ||
274 | static void cx_sensor(struct gspca_dev*gspca_dev) | 298 | static void cx_sensor(struct gspca_dev*gspca_dev) |
275 | { | 299 | { |
276 | __u8 val; | ||
277 | int i = 0; | 300 | int i = 0; |
278 | __u8 bufread[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; | ||
279 | int length; | 301 | int length; |
280 | const __u8 *ptsensor = cxsensor; | 302 | const __u8 *ptsensor = cxsensor; |
281 | 303 | ||
282 | reg_w(gspca_dev->dev, 0x0020, reg20, 8); | 304 | reg_w(gspca_dev, 0x0020, reg20, 8); |
283 | reg_w(gspca_dev->dev, 0x0028, reg28, 8); | 305 | reg_w(gspca_dev, 0x0028, reg28, 8); |
284 | reg_w(gspca_dev->dev, 0x0010, reg10, 8); | 306 | reg_w(gspca_dev, 0x0010, reg10, 8); |
285 | val = 0x03; | 307 | reg_w_val(gspca_dev, 0x0092, 0x03); |
286 | reg_w(gspca_dev->dev, 0x0092, &val, 1); | ||
287 | 308 | ||
288 | switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { | 309 | switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { |
289 | case 0: | 310 | case 0: |
290 | reg_w(gspca_dev->dev, 0x0071, reg71a, 4); | 311 | reg_w(gspca_dev, 0x0071, reg71a, 4); |
291 | break; | 312 | break; |
292 | case 1: | 313 | case 1: |
293 | reg_w(gspca_dev->dev, 0x0071, reg71b, 4); | 314 | reg_w(gspca_dev, 0x0071, reg71b, 4); |
294 | break; | 315 | break; |
295 | default: | 316 | default: |
296 | /* case 2: */ | 317 | /* case 2: */ |
297 | reg_w(gspca_dev->dev, 0x0071, reg71c, 4); | 318 | reg_w(gspca_dev, 0x0071, reg71c, 4); |
298 | break; | 319 | break; |
299 | case 3: | 320 | case 3: |
300 | reg_w(gspca_dev->dev, 0x0071, reg71d, 4); | 321 | reg_w(gspca_dev, 0x0071, reg71d, 4); |
301 | break; | 322 | break; |
302 | } | 323 | } |
303 | reg_w(gspca_dev->dev, 0x007b, reg7b, 6); | 324 | reg_w(gspca_dev, 0x007b, reg7b, 6); |
304 | val = 0x00; | 325 | reg_w_val(gspca_dev, 0x00f8, 0x00); |
305 | reg_w(gspca_dev->dev, 0x00f8, &val, 1); | 326 | reg_w(gspca_dev, 0x0010, reg10, 8); |
306 | reg_w(gspca_dev->dev, 0x0010, reg10, 8); | 327 | reg_w_val(gspca_dev, 0x0098, 0x41); |
307 | val = 0x41; | ||
308 | reg_w(gspca_dev->dev, 0x0098, &val, 1); | ||
309 | for (i = 0; i < 11; i++) { | 328 | for (i = 0; i < 11; i++) { |
310 | if (i == 3 || i == 5 || i == 8) | 329 | if (i == 3 || i == 5 || i == 8) |
311 | length = 8; | 330 | length = 8; |
312 | else | 331 | else |
313 | length = 4; | 332 | length = 4; |
314 | reg_w(gspca_dev->dev, 0x00e5, ptsensor, length); | 333 | reg_w(gspca_dev, 0x00e5, ptsensor, length); |
315 | if (length == 4) | 334 | if (length == 4) |
316 | reg_r(gspca_dev->dev, 0x00e8, &val, 1); | 335 | reg_r(gspca_dev, 0x00e8, 1); |
317 | else | 336 | else |
318 | reg_r(gspca_dev->dev, 0x00e8, bufread, length); | 337 | reg_r(gspca_dev, 0x00e8, length); |
319 | ptsensor += length; | 338 | ptsensor += length; |
320 | } | 339 | } |
321 | reg_r(gspca_dev->dev, 0x00e7, bufread, 8); | 340 | reg_r(gspca_dev, 0x00e7, 8); |
322 | } | 341 | } |
323 | 342 | ||
324 | static const __u8 cx_inits_176[] = { | 343 | static const __u8 cx_inits_176[] = { |
@@ -358,10 +377,9 @@ static const __u8 cx_inits_640[] = { | |||
358 | 0x77, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 377 | 0x77, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
359 | }; | 378 | }; |
360 | 379 | ||
361 | static int cx11646_initsize(struct gspca_dev *gspca_dev) | 380 | static void cx11646_initsize(struct gspca_dev *gspca_dev) |
362 | { | 381 | { |
363 | const __u8 *cxinit; | 382 | const __u8 *cxinit; |
364 | __u8 val; | ||
365 | static const __u8 reg12[] = { 0x08, 0x05, 0x07, 0x04, 0x24 }; | 383 | static const __u8 reg12[] = { 0x08, 0x05, 0x07, 0x04, 0x24 }; |
366 | static const __u8 reg17[] = | 384 | static const __u8 reg17[] = |
367 | { 0x0a, 0x00, 0xf2, 0x01, 0x0f, 0x00, 0x97, 0x02 }; | 385 | { 0x0a, 0x00, 0xf2, 0x01, 0x0f, 0x00, 0x97, 0x02 }; |
@@ -381,35 +399,29 @@ static int cx11646_initsize(struct gspca_dev *gspca_dev) | |||
381 | cxinit = cx_inits_176; | 399 | cxinit = cx_inits_176; |
382 | break; | 400 | break; |
383 | } | 401 | } |
384 | val = 0x01; | 402 | reg_w_val(gspca_dev, 0x009a, 0x01); |
385 | reg_w(gspca_dev->dev, 0x009a, &val, 1); | 403 | reg_w_val(gspca_dev, 0x0010, 0x10); |
386 | val = 0x10; | 404 | reg_w(gspca_dev, 0x0012, reg12, 5); |
387 | reg_w(gspca_dev->dev, 0x0010, &val, 1); | 405 | reg_w(gspca_dev, 0x0017, reg17, 8); |
388 | reg_w(gspca_dev->dev, 0x0012, reg12, 5); | 406 | reg_w_val(gspca_dev, 0x00c0, 0x00); |
389 | reg_w(gspca_dev->dev, 0x0017, reg17, 8); | 407 | reg_w_val(gspca_dev, 0x00c1, 0x04); |
390 | val = 0x00; | 408 | reg_w_val(gspca_dev, 0x00c2, 0x04); |
391 | reg_w(gspca_dev->dev, 0x00c0, &val, 1); | 409 | |
392 | val = 0x04; | 410 | reg_w(gspca_dev, 0x0061, cxinit, 8); |
393 | reg_w(gspca_dev->dev, 0x00c1, &val, 1); | ||
394 | val = 0x04; | ||
395 | reg_w(gspca_dev->dev, 0x00c2, &val, 1); | ||
396 | |||
397 | reg_w(gspca_dev->dev, 0x0061, cxinit, 8); | ||
398 | cxinit += 8; | 411 | cxinit += 8; |
399 | reg_w(gspca_dev->dev, 0x00ca, cxinit, 8); | 412 | reg_w(gspca_dev, 0x00ca, cxinit, 8); |
400 | cxinit += 8; | 413 | cxinit += 8; |
401 | reg_w(gspca_dev->dev, 0x00d2, cxinit, 8); | 414 | reg_w(gspca_dev, 0x00d2, cxinit, 8); |
402 | cxinit += 8; | 415 | cxinit += 8; |
403 | reg_w(gspca_dev->dev, 0x00da, cxinit, 6); | 416 | reg_w(gspca_dev, 0x00da, cxinit, 6); |
404 | cxinit += 8; | 417 | cxinit += 8; |
405 | reg_w(gspca_dev->dev, 0x0041, cxinit, 8); | 418 | reg_w(gspca_dev, 0x0041, cxinit, 8); |
406 | cxinit += 8; | 419 | cxinit += 8; |
407 | reg_w(gspca_dev->dev, 0x0049, cxinit, 8); | 420 | reg_w(gspca_dev, 0x0049, cxinit, 8); |
408 | cxinit += 8; | 421 | cxinit += 8; |
409 | reg_w(gspca_dev->dev, 0x0051, cxinit, 2); | 422 | reg_w(gspca_dev, 0x0051, cxinit, 2); |
410 | 423 | ||
411 | reg_r(gspca_dev->dev, 0x0010, &val, 1); | 424 | reg_r(gspca_dev, 0x0010, 1); |
412 | return val; | ||
413 | } | 425 | } |
414 | 426 | ||
415 | static const __u8 cx_jpeg_init[][8] = { | 427 | static const __u8 cx_jpeg_init[][8] = { |
@@ -636,26 +648,21 @@ static const __u8 cxjpeg_qtable[][8] = { | |||
636 | 648 | ||
637 | static void cx11646_jpegInit(struct gspca_dev*gspca_dev) | 649 | static void cx11646_jpegInit(struct gspca_dev*gspca_dev) |
638 | { | 650 | { |
639 | __u8 val; | ||
640 | int i; | 651 | int i; |
641 | int length; | 652 | int length; |
642 | 653 | ||
643 | val = 0x01; | 654 | reg_w_val(gspca_dev, 0x00c0, 0x01); |
644 | reg_w(gspca_dev->dev, 0x00c0, &val, 1); | 655 | reg_w_val(gspca_dev, 0x00c3, 0x00); |
645 | val = 0x00; | 656 | reg_w_val(gspca_dev, 0x00c0, 0x00); |
646 | reg_w(gspca_dev->dev, 0x00c3, &val, 1); | 657 | reg_r(gspca_dev, 0x0001, 1); |
647 | val = 0x00; | ||
648 | reg_w(gspca_dev->dev, 0x00c0, &val, 1); | ||
649 | reg_r(gspca_dev->dev, 0x0001, &val, 1); | ||
650 | length = 8; | 658 | length = 8; |
651 | for (i = 0; i < 79; i++) { | 659 | for (i = 0; i < 79; i++) { |
652 | if (i == 78) | 660 | if (i == 78) |
653 | length = 6; | 661 | length = 6; |
654 | reg_w(gspca_dev->dev, 0x0008, cx_jpeg_init[i], length); | 662 | reg_w(gspca_dev, 0x0008, cx_jpeg_init[i], length); |
655 | } | 663 | } |
656 | reg_r(gspca_dev->dev, 0x0002, &val, 1); | 664 | reg_r(gspca_dev, 0x0002, 1); |
657 | val = 0x14; | 665 | reg_w_val(gspca_dev, 0x0055, 0x14); |
658 | reg_w(gspca_dev->dev, 0x0055, &val, 1); | ||
659 | } | 666 | } |
660 | 667 | ||
661 | static const __u8 reg12[] = { 0x0a, 0x05, 0x07, 0x04, 0x19 }; | 668 | static const __u8 reg12[] = { 0x0a, 0x05, 0x07, 0x04, 0x19 }; |
@@ -665,31 +672,26 @@ static const __u8 regE5a[] = { 0x88, 0x0a, 0x0c, 0x01 }; | |||
665 | static const __u8 regE5b[] = { 0x88, 0x0b, 0x12, 0x01 }; | 672 | static const __u8 regE5b[] = { 0x88, 0x0b, 0x12, 0x01 }; |
666 | static const __u8 regE5c[] = { 0x88, 0x05, 0x01, 0x01 }; | 673 | static const __u8 regE5c[] = { 0x88, 0x05, 0x01, 0x01 }; |
667 | static const __u8 reg51[] = { 0x77, 0x03 }; | 674 | static const __u8 reg51[] = { 0x77, 0x03 }; |
668 | static const __u8 reg70 = 0x03; | 675 | #define reg70 0x03 |
669 | 676 | ||
670 | static void cx11646_jpeg(struct gspca_dev*gspca_dev) | 677 | static void cx11646_jpeg(struct gspca_dev*gspca_dev) |
671 | { | 678 | { |
672 | __u8 val; | ||
673 | int i; | 679 | int i; |
674 | int length; | 680 | int length; |
675 | __u8 Reg55; | 681 | __u8 Reg55; |
676 | __u8 bufread[8]; | ||
677 | int retry; | 682 | int retry; |
678 | 683 | ||
679 | val = 0x01; | 684 | reg_w_val(gspca_dev, 0x00c0, 0x01); |
680 | reg_w(gspca_dev->dev, 0x00c0, &val, 1); | 685 | reg_w_val(gspca_dev, 0x00c3, 0x00); |
681 | val = 0x00; | 686 | reg_w_val(gspca_dev, 0x00c0, 0x00); |
682 | reg_w(gspca_dev->dev, 0x00c3, &val, 1); | 687 | reg_r(gspca_dev, 0x0001, 1); |
683 | val = 0x00; | ||
684 | reg_w(gspca_dev->dev, 0x00c0, &val, 1); | ||
685 | reg_r(gspca_dev->dev, 0x0001, &val, 1); | ||
686 | length = 8; | 688 | length = 8; |
687 | switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { | 689 | switch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) { |
688 | case 0: | 690 | case 0: |
689 | for (i = 0; i < 27; i++) { | 691 | for (i = 0; i < 27; i++) { |
690 | if (i == 26) | 692 | if (i == 26) |
691 | length = 2; | 693 | length = 2; |
692 | reg_w(gspca_dev->dev, 0x0008, cxjpeg_640[i], length); | 694 | reg_w(gspca_dev, 0x0008, cxjpeg_640[i], length); |
693 | } | 695 | } |
694 | Reg55 = 0x28; | 696 | Reg55 = 0x28; |
695 | break; | 697 | break; |
@@ -697,7 +699,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev) | |||
697 | for (i = 0; i < 27; i++) { | 699 | for (i = 0; i < 27; i++) { |
698 | if (i == 26) | 700 | if (i == 26) |
699 | length = 2; | 701 | length = 2; |
700 | reg_w(gspca_dev->dev, 0x0008, cxjpeg_352[i], length); | 702 | reg_w(gspca_dev, 0x0008, cxjpeg_352[i], length); |
701 | } | 703 | } |
702 | Reg55 = 0x16; | 704 | Reg55 = 0x16; |
703 | break; | 705 | break; |
@@ -706,7 +708,7 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev) | |||
706 | for (i = 0; i < 27; i++) { | 708 | for (i = 0; i < 27; i++) { |
707 | if (i == 26) | 709 | if (i == 26) |
708 | length = 2; | 710 | length = 2; |
709 | reg_w(gspca_dev->dev, 0x0008, cxjpeg_320[i], length); | 711 | reg_w(gspca_dev, 0x0008, cxjpeg_320[i], length); |
710 | } | 712 | } |
711 | Reg55 = 0x14; | 713 | Reg55 = 0x14; |
712 | break; | 714 | break; |
@@ -714,124 +716,98 @@ static void cx11646_jpeg(struct gspca_dev*gspca_dev) | |||
714 | for (i = 0; i < 27; i++) { | 716 | for (i = 0; i < 27; i++) { |
715 | if (i == 26) | 717 | if (i == 26) |
716 | length = 2; | 718 | length = 2; |
717 | reg_w(gspca_dev->dev, 0x0008, cxjpeg_176[i], length); | 719 | reg_w(gspca_dev, 0x0008, cxjpeg_176[i], length); |
718 | } | 720 | } |
719 | Reg55 = 0x0B; | 721 | Reg55 = 0x0B; |
720 | break; | 722 | break; |
721 | } | 723 | } |
722 | 724 | ||
723 | reg_r(gspca_dev->dev, 0x0002, &val, 1); | 725 | reg_r(gspca_dev, 0x0002, 1); |
724 | val = Reg55; | 726 | reg_w_val(gspca_dev, 0x0055, Reg55); |
725 | reg_w(gspca_dev->dev, 0x0055, &val, 1); | 727 | reg_r(gspca_dev, 0x0002, 1); |
726 | reg_r(gspca_dev->dev, 0x0002, &val, 1); | 728 | reg_w(gspca_dev, 0x0010, reg10, 2); |
727 | reg_w(gspca_dev->dev, 0x0010, reg10, 2); | 729 | reg_w_val(gspca_dev, 0x0054, 0x02); |
728 | val = 0x02; | 730 | reg_w_val(gspca_dev, 0x0054, 0x01); |
729 | reg_w(gspca_dev->dev, 0x0054, &val, 1); | 731 | reg_w_val(gspca_dev, 0x0000, 0x94); |
730 | val = 0x01; | 732 | reg_w_val(gspca_dev, 0x0053, 0xc0); |
731 | reg_w(gspca_dev->dev, 0x0054, &val, 1); | 733 | reg_w_val(gspca_dev, 0x00fc, 0xe1); |
732 | val = 0x94; | 734 | reg_w_val(gspca_dev, 0x0000, 0x00); |
733 | reg_w(gspca_dev->dev, 0x0000, &val, 1); | ||
734 | val = 0xc0; | ||
735 | reg_w(gspca_dev->dev, 0x0053, &val, 1); | ||
736 | val = 0xe1; | ||
737 | reg_w(gspca_dev->dev, 0x00fc, &val, 1); | ||
738 | val = 0x00; | ||
739 | reg_w(gspca_dev->dev, 0x0000, &val, 1); | ||
740 | /* wait for completion */ | 735 | /* wait for completion */ |
741 | retry = 50; | 736 | retry = 50; |
742 | while (retry--) { | 737 | while (retry--) { |
743 | reg_r(gspca_dev->dev, 0x0002, &val, 1); | 738 | reg_r(gspca_dev, 0x0002, 1); |
744 | /* 0x07 until 0x00 */ | 739 | /* 0x07 until 0x00 */ |
745 | if (val == 0x00) | 740 | if (gspca_dev->usb_buf[0] == 0x00) |
746 | break; | 741 | break; |
747 | val = 0x00; | 742 | reg_w_val(gspca_dev, 0x0053, 0x00); |
748 | reg_w(gspca_dev->dev, 0x0053, &val, 1); | ||
749 | } | 743 | } |
750 | if (retry == 0) | 744 | if (retry == 0) |
751 | PDEBUG(D_ERR, "Damned Errors sending jpeg Table"); | 745 | PDEBUG(D_ERR, "Damned Errors sending jpeg Table"); |
752 | /* send the qtable now */ | 746 | /* send the qtable now */ |
753 | reg_r(gspca_dev->dev, 0x0001, &val, 1); /* -> 0x18 */ | 747 | reg_r(gspca_dev, 0x0001, 1); /* -> 0x18 */ |
754 | length = 8; | 748 | length = 8; |
755 | for (i = 0; i < 18; i++) { | 749 | for (i = 0; i < 18; i++) { |
756 | if (i == 17) | 750 | if (i == 17) |
757 | length = 2; | 751 | length = 2; |
758 | reg_w(gspca_dev->dev, 0x0008, cxjpeg_qtable[i], length); | 752 | reg_w(gspca_dev, 0x0008, cxjpeg_qtable[i], length); |
759 | 753 | ||
760 | } | 754 | } |
761 | reg_r(gspca_dev->dev, 0x0002, &val, 1); /* 0x00 */ | 755 | reg_r(gspca_dev, 0x0002, 1); /* 0x00 */ |
762 | reg_r(gspca_dev->dev, 0x0053, &val, 1); /* 0x00 */ | 756 | reg_r(gspca_dev, 0x0053, 1); /* 0x00 */ |
763 | val = 0x02; | 757 | reg_w_val(gspca_dev, 0x0054, 0x02); |
764 | reg_w(gspca_dev->dev, 0x0054, &val, 1); | 758 | reg_w_val(gspca_dev, 0x0054, 0x01); |
765 | val = 0x01; | 759 | reg_w_val(gspca_dev, 0x0000, 0x94); |
766 | reg_w(gspca_dev->dev, 0x0054, &val, 1); | 760 | reg_w_val(gspca_dev, 0x0053, 0xc0); |
767 | val = 0x94; | 761 | |
768 | reg_w(gspca_dev->dev, 0x0000, &val, 1); | 762 | reg_r(gspca_dev, 0x0038, 1); /* 0x40 */ |
769 | val = 0xc0; | 763 | reg_r(gspca_dev, 0x0038, 1); /* 0x40 */ |
770 | reg_w(gspca_dev->dev, 0x0053, &val, 1); | 764 | reg_r(gspca_dev, 0x001f, 1); /* 0x38 */ |
771 | 765 | reg_w(gspca_dev, 0x0012, reg12, 5); | |
772 | reg_r(gspca_dev->dev, 0x0038, &val, 1); /* 0x40 */ | 766 | reg_w(gspca_dev, 0x00e5, regE5_8, 8); |
773 | reg_r(gspca_dev->dev, 0x0038, &val, 1); /* 0x40 */ | 767 | reg_r(gspca_dev, 0x00e8, 8); |
774 | reg_r(gspca_dev->dev, 0x001f, &val, 1); /* 0x38 */ | 768 | reg_w(gspca_dev, 0x00e5, regE5a, 4); |
775 | reg_w(gspca_dev->dev, 0x0012, reg12, 5); | 769 | reg_r(gspca_dev, 0x00e8, 1); /* 0x00 */ |
776 | reg_w(gspca_dev->dev, 0x00e5, regE5_8, 8); | 770 | reg_w_val(gspca_dev, 0x009a, 0x01); |
777 | reg_r(gspca_dev->dev, 0x00e8, bufread, 8); | 771 | reg_w(gspca_dev, 0x00e5, regE5b, 4); |
778 | reg_w(gspca_dev->dev, 0x00e5, regE5a, 4); | 772 | reg_r(gspca_dev, 0x00e8, 1); /* 0x00 */ |
779 | reg_r(gspca_dev->dev, 0x00e8, &val, 1); /* 0x00 */ | 773 | reg_w(gspca_dev, 0x00e5, regE5c, 4); |
780 | val = 0x01; | 774 | reg_r(gspca_dev, 0x00e8, 1); /* 0x00 */ |
781 | reg_w(gspca_dev->dev, 0x009a, &val, 1); | 775 | |
782 | reg_w(gspca_dev->dev, 0x00e5, regE5b, 4); | 776 | reg_w(gspca_dev, 0x0051, reg51, 2); |
783 | reg_r(gspca_dev->dev, 0x00e8, &val, 1); /* 0x00 */ | 777 | reg_w(gspca_dev, 0x0010, reg10, 2); |
784 | reg_w(gspca_dev->dev, 0x00e5, regE5c, 4); | 778 | reg_w_val(gspca_dev, 0x0070, reg70); |
785 | reg_r(gspca_dev->dev, 0x00e8, &val, 1); /* 0x00 */ | ||
786 | |||
787 | reg_w(gspca_dev->dev, 0x0051, reg51, 2); | ||
788 | reg_w(gspca_dev->dev, 0x0010, reg10, 2); | ||
789 | reg_w(gspca_dev->dev, 0x0070, ®70, 1); | ||
790 | } | 779 | } |
791 | 780 | ||
792 | static void cx11646_init1(struct gspca_dev *gspca_dev) | 781 | static void cx11646_init1(struct gspca_dev *gspca_dev) |
793 | { | 782 | { |
794 | __u8 val; | ||
795 | int i = 0; | 783 | int i = 0; |
796 | 784 | ||
797 | val = 0; | 785 | reg_w_val(gspca_dev, 0x0010, 0x00); |
798 | reg_w(gspca_dev->dev, 0x0010, &val, 1); | 786 | reg_w_val(gspca_dev, 0x0053, 0x00); |
799 | reg_w(gspca_dev->dev, 0x0053, &val, 1); | 787 | reg_w_val(gspca_dev, 0x0052, 0x00); |
800 | reg_w(gspca_dev->dev, 0x0052, &val, 1); | 788 | reg_w_val(gspca_dev, 0x009b, 0x2f); |
801 | val = 0x2f; | 789 | reg_w_val(gspca_dev, 0x009c, 0x10); |
802 | reg_w(gspca_dev->dev, 0x009b, &val, 1); | 790 | reg_r(gspca_dev, 0x0098, 1); |
803 | val = 0x10; | 791 | reg_w_val(gspca_dev, 0x0098, 0x40); |
804 | reg_w(gspca_dev->dev, 0x009c, &val, 1); | 792 | reg_r(gspca_dev, 0x0099, 1); |
805 | reg_r(gspca_dev->dev, 0x0098, &val, 1); | 793 | reg_w_val(gspca_dev, 0x0099, 0x07); |
806 | val = 0x40; | 794 | reg_w_val(gspca_dev, 0x0039, 0x40); |
807 | reg_w(gspca_dev->dev, 0x0098, &val, 1); | 795 | reg_w_val(gspca_dev, 0x003c, 0xff); |
808 | reg_r(gspca_dev->dev, 0x0099, &val, 1); | 796 | reg_w_val(gspca_dev, 0x003f, 0x1f); |
809 | val = 0x07; | 797 | reg_w_val(gspca_dev, 0x003d, 0x40); |
810 | reg_w(gspca_dev->dev, 0x0099, &val, 1); | 798 | /* reg_w_val(gspca_dev, 0x003d, 0x60); */ |
811 | val = 0x40; | 799 | reg_r(gspca_dev, 0x0099, 1); /* ->0x07 */ |
812 | reg_w(gspca_dev->dev, 0x0039, &val, 1); | ||
813 | val = 0xff; | ||
814 | reg_w(gspca_dev->dev, 0x003c, &val, 1); | ||
815 | val = 0x1f; | ||
816 | reg_w(gspca_dev->dev, 0x003f, &val, 1); | ||
817 | val = 0x40; | ||
818 | reg_w(gspca_dev->dev, 0x003d, &val, 1); | ||
819 | /* val= 0x60; */ | ||
820 | /* reg_w(gspca_dev->dev, 0x00, 0x00, 0x003d, &val, 1); */ | ||
821 | reg_r(gspca_dev->dev, 0x0099, &val, 1); /* ->0x07 */ | ||
822 | 800 | ||
823 | while (cx_sensor_init[i][0]) { | 801 | while (cx_sensor_init[i][0]) { |
824 | reg_w(gspca_dev->dev, 0x00e5, cx_sensor_init[i], 1); | 802 | reg_w_val(gspca_dev, 0x00e5, cx_sensor_init[i][0]); |
825 | reg_r(gspca_dev->dev, 0x00e8, &val, 1); /* -> 0x00 */ | 803 | reg_r(gspca_dev, 0x00e8, 1); /* -> 0x00 */ |
826 | if (i == 1) { | 804 | if (i == 1) { |
827 | val = 1; | 805 | reg_w_val(gspca_dev, 0x00ed, 0x01); |
828 | reg_w(gspca_dev->dev, 0x00ed, &val, 1); | 806 | reg_r(gspca_dev, 0x00ed, 1); /* -> 0x01 */ |
829 | reg_r(gspca_dev->dev, 0x00ed, &val, 1); /* -> 0x01 */ | ||
830 | } | 807 | } |
831 | i++; | 808 | i++; |
832 | } | 809 | } |
833 | val = 0x00; | 810 | reg_w_val(gspca_dev, 0x00c3, 0x00); |
834 | reg_w(gspca_dev->dev, 0x00c3, &val, 1); | ||
835 | } | 811 | } |
836 | 812 | ||
837 | /* this function is called at probe time */ | 813 | /* this function is called at probe time */ |
@@ -880,29 +856,23 @@ static void sd_stopN(struct gspca_dev *gspca_dev) | |||
880 | static void sd_stop0(struct gspca_dev *gspca_dev) | 856 | static void sd_stop0(struct gspca_dev *gspca_dev) |
881 | { | 857 | { |
882 | int retry = 50; | 858 | int retry = 50; |
883 | __u8 val; | ||
884 | 859 | ||
885 | val = 0; | 860 | reg_w_val(gspca_dev, 0x0000, 0x00); |
886 | reg_w(gspca_dev->dev, 0x0000, &val, 1); | 861 | reg_r(gspca_dev, 0x0002, 1); |
887 | reg_r(gspca_dev->dev, 0x0002, &val, 1); | 862 | reg_w_val(gspca_dev, 0x0053, 0x00); |
888 | val = 0; | ||
889 | reg_w(gspca_dev->dev, 0x0053, &val, 1); | ||
890 | 863 | ||
891 | while (retry--) { | 864 | while (retry--) { |
892 | /* reg_r(gspca_dev->dev, 0x0002, &val, 1);*/ | 865 | /* reg_r(gspca_dev, 0x0002, 1);*/ |
893 | reg_r(gspca_dev->dev, 0x0053, &val, 1); | 866 | reg_r(gspca_dev, 0x0053, 1); |
894 | if (val == 0) | 867 | if (gspca_dev->usb_buf[0] == 0) |
895 | break; | 868 | break; |
896 | } | 869 | } |
897 | val = 0; | 870 | reg_w_val(gspca_dev, 0x0000, 0x00); |
898 | reg_w(gspca_dev->dev, 0x0000, &val, 1); | 871 | reg_r(gspca_dev, 0x0002, 1); |
899 | reg_r(gspca_dev->dev, 0x0002, &val, 1); | 872 | |
900 | 873 | reg_w_val(gspca_dev, 0x0010, 0x00); | |
901 | val = 0; | 874 | reg_r(gspca_dev, 0x0033, 1); |
902 | reg_w(gspca_dev->dev, 0x0010, &val, 1); | 875 | reg_w_val(gspca_dev, 0x00fc, 0xe0); |
903 | reg_r(gspca_dev->dev, 0x0033, &val, 1); | ||
904 | val = 0xe0; | ||
905 | reg_w(gspca_dev->dev, 0x00fc, &val, 1); | ||
906 | } | 876 | } |
907 | 877 | ||
908 | static void sd_close(struct gspca_dev *gspca_dev) | 878 | static void sd_close(struct gspca_dev *gspca_dev) |
@@ -937,22 +907,20 @@ static void setbrightness(struct gspca_dev*gspca_dev) | |||
937 | __u8 reg51c[2]; | 907 | __u8 reg51c[2]; |
938 | __u8 bright; | 908 | __u8 bright; |
939 | __u8 colors; | 909 | __u8 colors; |
940 | __u8 val; | ||
941 | __u8 bufread[8]; | ||
942 | 910 | ||
943 | bright = sd->brightness; | 911 | bright = sd->brightness; |
944 | regE5cbx[2] = bright; | 912 | regE5cbx[2] = bright; |
945 | reg_w(gspca_dev->dev, 0x00e5, regE5cbx, 8); | 913 | reg_w(gspca_dev, 0x00e5, regE5cbx, 8); |
946 | reg_r(gspca_dev->dev, 0x00e8, bufread, 8); | 914 | reg_r(gspca_dev, 0x00e8, 8); |
947 | reg_w(gspca_dev->dev, 0x00e5, regE5c, 4); | 915 | reg_w(gspca_dev, 0x00e5, regE5c, 4); |
948 | reg_r(gspca_dev->dev, 0x00e8, &val, 1); /* 0x00 */ | 916 | reg_r(gspca_dev, 0x00e8, 1); /* 0x00 */ |
949 | 917 | ||
950 | colors = sd->colors; | 918 | colors = sd->colors; |
951 | reg51c[0] = 0x77; | 919 | reg51c[0] = 0x77; |
952 | reg51c[1] = colors; | 920 | reg51c[1] = colors; |
953 | reg_w(gspca_dev->dev, 0x0051, reg51c, 2); | 921 | reg_w(gspca_dev, 0x0051, reg51c, 2); |
954 | reg_w(gspca_dev->dev, 0x0010, reg10, 2); | 922 | reg_w(gspca_dev, 0x0010, reg10, 2); |
955 | reg_w(gspca_dev->dev, 0x0070, ®70, 1); | 923 | reg_w_val(gspca_dev, 0x0070, reg70); |
956 | } | 924 | } |
957 | 925 | ||
958 | static void setcontrast(struct gspca_dev*gspca_dev) | 926 | static void setcontrast(struct gspca_dev*gspca_dev) |
@@ -961,16 +929,15 @@ static void setcontrast(struct gspca_dev*gspca_dev) | |||
961 | __u8 regE5acx[] = { 0x88, 0x0a, 0x0c, 0x01 }; /* seem MSB */ | 929 | __u8 regE5acx[] = { 0x88, 0x0a, 0x0c, 0x01 }; /* seem MSB */ |
962 | /* __u8 regE5bcx[] = { 0x88, 0x0b, 0x12, 0x01}; * LSB */ | 930 | /* __u8 regE5bcx[] = { 0x88, 0x0b, 0x12, 0x01}; * LSB */ |
963 | __u8 reg51c[2]; | 931 | __u8 reg51c[2]; |
964 | __u8 val; | ||
965 | 932 | ||
966 | regE5acx[2] = sd->contrast; | 933 | regE5acx[2] = sd->contrast; |
967 | reg_w(gspca_dev->dev, 0x00e5, regE5acx, 4); | 934 | reg_w(gspca_dev, 0x00e5, regE5acx, 4); |
968 | reg_r(gspca_dev->dev, 0x00e8, &val, 1); /* 0x00 */ | 935 | reg_r(gspca_dev, 0x00e8, 1); /* 0x00 */ |
969 | reg51c[0] = 0x77; | 936 | reg51c[0] = 0x77; |
970 | reg51c[1] = sd->colors; | 937 | reg51c[1] = sd->colors; |
971 | reg_w(gspca_dev->dev, 0x0051, reg51c, 2); | 938 | reg_w(gspca_dev, 0x0051, reg51c, 2); |
972 | reg_w(gspca_dev->dev, 0x0010, reg10, 2); | 939 | reg_w(gspca_dev, 0x0010, reg10, 2); |
973 | reg_w(gspca_dev->dev, 0x0070, ®70, 1); | 940 | reg_w_val(gspca_dev, 0x0070, reg70); |
974 | } | 941 | } |
975 | 942 | ||
976 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 943 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |