diff options
Diffstat (limited to 'drivers/media/video/gspca/spca500.c')
-rw-r--r-- | drivers/media/video/gspca/spca500.c | 265 |
1 files changed, 132 insertions, 133 deletions
diff --git a/drivers/media/video/gspca/spca500.c b/drivers/media/video/gspca/spca500.c index d00f0f76e0e3..156206118795 100644 --- a/drivers/media/video/gspca/spca500.c +++ b/drivers/media/video/gspca/spca500.c | |||
@@ -24,8 +24,8 @@ | |||
24 | #include "gspca.h" | 24 | #include "gspca.h" |
25 | #include "jpeg.h" | 25 | #include "jpeg.h" |
26 | 26 | ||
27 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5) | 27 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7) |
28 | static const char version[] = "2.1.5"; | 28 | static const char version[] = "2.1.7"; |
29 | 29 | ||
30 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); | 30 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); |
31 | MODULE_DESCRIPTION("GSPCA/SPCA500 USB Camera Driver"); | 31 | MODULE_DESCRIPTION("GSPCA/SPCA500 USB Camera Driver"); |
@@ -372,26 +372,27 @@ static const __u8 qtable_pocketdv[2][64] = { | |||
372 | 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28} | 372 | 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28} |
373 | }; | 373 | }; |
374 | 374 | ||
375 | static void reg_r(struct usb_device *dev, | 375 | /* read 'len' bytes to gspca_dev->usb_buf */ |
376 | __u16 index, | 376 | static void reg_r(struct gspca_dev *gspca_dev, |
377 | __u8 *buffer, __u16 length) | 377 | __u16 index, |
378 | __u16 length) | ||
378 | { | 379 | { |
379 | usb_control_msg(dev, | 380 | usb_control_msg(gspca_dev->dev, |
380 | usb_rcvctrlpipe(dev, 0), | 381 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
381 | 0, | 382 | 0, |
382 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 383 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
383 | 0, /* value */ | 384 | 0, /* value */ |
384 | index, buffer, length, 500); | 385 | index, gspca_dev->usb_buf, length, 500); |
385 | } | 386 | } |
386 | 387 | ||
387 | static int reg_w(struct usb_device *dev, | 388 | static int reg_w(struct gspca_dev *gspca_dev, |
388 | __u16 req, __u16 index, __u16 value) | 389 | __u16 req, __u16 index, __u16 value) |
389 | { | 390 | { |
390 | int ret; | 391 | int ret; |
391 | 392 | ||
392 | PDEBUG(D_USBO, "reg write: [0x%02x] = 0x%02x", index, value); | 393 | PDEBUG(D_USBO, "reg write: [0x%02x] = 0x%02x", index, value); |
393 | ret = usb_control_msg(dev, | 394 | ret = usb_control_msg(gspca_dev->dev, |
394 | usb_sndctrlpipe(dev, 0), | 395 | usb_sndctrlpipe(gspca_dev->dev, 0), |
395 | req, | 396 | req, |
396 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 397 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
397 | value, index, NULL, 0, 500); | 398 | value, index, NULL, 0, 500); |
@@ -401,28 +402,27 @@ static int reg_w(struct usb_device *dev, | |||
401 | } | 402 | } |
402 | 403 | ||
403 | /* returns: negative is error, pos or zero is data */ | 404 | /* returns: negative is error, pos or zero is data */ |
404 | static int reg_r_12(struct usb_device *dev, | 405 | static int reg_r_12(struct gspca_dev *gspca_dev, |
405 | __u16 req, /* bRequest */ | 406 | __u16 req, /* bRequest */ |
406 | __u16 index, /* wIndex */ | 407 | __u16 index, /* wIndex */ |
407 | __u16 length) /* wLength (1 or 2 only) */ | 408 | __u16 length) /* wLength (1 or 2 only) */ |
408 | { | 409 | { |
409 | int ret; | 410 | int ret; |
410 | __u8 buf[2]; | ||
411 | 411 | ||
412 | buf[1] = 0; | 412 | gspca_dev->usb_buf[1] = 0; |
413 | ret = usb_control_msg(dev, | 413 | ret = usb_control_msg(gspca_dev->dev, |
414 | usb_rcvctrlpipe(dev, 0), | 414 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
415 | req, | 415 | req, |
416 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 416 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
417 | 0, /* value */ | 417 | 0, /* value */ |
418 | index, | 418 | index, |
419 | buf, length, | 419 | gspca_dev->usb_buf, length, |
420 | 500); /* timeout */ | 420 | 500); /* timeout */ |
421 | if (ret < 0) { | 421 | if (ret < 0) { |
422 | PDEBUG(D_ERR, "reg_r_12 err %d", ret); | 422 | PDEBUG(D_ERR, "reg_r_12 err %d", ret); |
423 | return -1; | 423 | return -1; |
424 | } | 424 | } |
425 | return (buf[1] << 8) + buf[0]; | 425 | return (gspca_dev->usb_buf[1] << 8) + gspca_dev->usb_buf[0]; |
426 | } | 426 | } |
427 | 427 | ||
428 | /* | 428 | /* |
@@ -430,13 +430,13 @@ static int reg_r_12(struct usb_device *dev, | |||
430 | * a reg_read call. | 430 | * a reg_read call. |
431 | * Returns: negative is error or timeout, zero is success. | 431 | * Returns: negative is error or timeout, zero is success. |
432 | */ | 432 | */ |
433 | static int reg_r_wait(struct usb_device *dev, | 433 | static int reg_r_wait(struct gspca_dev *gspca_dev, |
434 | __u16 reg, __u16 index, __u16 value) | 434 | __u16 reg, __u16 index, __u16 value) |
435 | { | 435 | { |
436 | int ret, cnt = 20; | 436 | int ret, cnt = 20; |
437 | 437 | ||
438 | while (--cnt > 0) { | 438 | while (--cnt > 0) { |
439 | ret = reg_r_12(dev, reg, index, 1); | 439 | ret = reg_r_12(gspca_dev, reg, index, 1); |
440 | if (ret == value) | 440 | if (ret == value) |
441 | return 0; | 441 | return 0; |
442 | msleep(50); | 442 | msleep(50); |
@@ -447,11 +447,10 @@ static int reg_r_wait(struct usb_device *dev, | |||
447 | static int write_vector(struct gspca_dev *gspca_dev, | 447 | static int write_vector(struct gspca_dev *gspca_dev, |
448 | const __u16 data[][3]) | 448 | const __u16 data[][3]) |
449 | { | 449 | { |
450 | struct usb_device *dev = gspca_dev->dev; | ||
451 | int ret, i = 0; | 450 | int ret, i = 0; |
452 | 451 | ||
453 | while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) { | 452 | while (data[i][0] != 0 || data[i][1] != 0 || data[i][2] != 0) { |
454 | ret = reg_w(dev, data[i][0], data[i][2], data[i][1]); | 453 | ret = reg_w(gspca_dev, data[i][0], data[i][2], data[i][1]); |
455 | if (ret < 0) | 454 | if (ret < 0) |
456 | return ret; | 455 | return ret; |
457 | i++; | 456 | i++; |
@@ -465,19 +464,18 @@ static int spca50x_setup_qtable(struct gspca_dev *gspca_dev, | |||
465 | unsigned int cbase, | 464 | unsigned int cbase, |
466 | const __u8 qtable[2][64]) | 465 | const __u8 qtable[2][64]) |
467 | { | 466 | { |
468 | struct usb_device *dev = gspca_dev->dev; | ||
469 | int i, err; | 467 | int i, err; |
470 | 468 | ||
471 | /* loop over y components */ | 469 | /* loop over y components */ |
472 | for (i = 0; i < 64; i++) { | 470 | for (i = 0; i < 64; i++) { |
473 | err = reg_w(dev, request, ybase + i, qtable[0][i]); | 471 | err = reg_w(gspca_dev, request, ybase + i, qtable[0][i]); |
474 | if (err < 0) | 472 | if (err < 0) |
475 | return err; | 473 | return err; |
476 | } | 474 | } |
477 | 475 | ||
478 | /* loop over c components */ | 476 | /* loop over c components */ |
479 | for (i = 0; i < 64; i++) { | 477 | for (i = 0; i < 64; i++) { |
480 | err = reg_w(dev, request, cbase + i, qtable[1][i]); | 478 | err = reg_w(gspca_dev, request, cbase + i, qtable[1][i]); |
481 | if (err < 0) | 479 | if (err < 0) |
482 | return err; | 480 | return err; |
483 | } | 481 | } |
@@ -486,37 +484,33 @@ static int spca50x_setup_qtable(struct gspca_dev *gspca_dev, | |||
486 | 484 | ||
487 | static void spca500_ping310(struct gspca_dev *gspca_dev) | 485 | static void spca500_ping310(struct gspca_dev *gspca_dev) |
488 | { | 486 | { |
489 | __u8 Data[2]; | 487 | reg_r(gspca_dev, 0x0d04, 2); |
490 | |||
491 | reg_r(gspca_dev->dev, 0x0d04, Data, 2); | ||
492 | PDEBUG(D_STREAM, "ClickSmart310 ping 0x0d04 0x%02x 0x%02x", | 488 | PDEBUG(D_STREAM, "ClickSmart310 ping 0x0d04 0x%02x 0x%02x", |
493 | Data[0], Data[1]); | 489 | gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); |
494 | } | 490 | } |
495 | 491 | ||
496 | static void spca500_clksmart310_init(struct gspca_dev *gspca_dev) | 492 | static void spca500_clksmart310_init(struct gspca_dev *gspca_dev) |
497 | { | 493 | { |
498 | __u8 Data[2]; | 494 | reg_r(gspca_dev, 0x0d05, 2); |
499 | |||
500 | reg_r(gspca_dev->dev, 0x0d05, Data, 2); | ||
501 | PDEBUG(D_STREAM, "ClickSmart310 init 0x0d05 0x%02x 0x%02x", | 495 | PDEBUG(D_STREAM, "ClickSmart310 init 0x0d05 0x%02x 0x%02x", |
502 | Data[0], Data[1]); | 496 | gspca_dev->usb_buf[0], gspca_dev->usb_buf[1]); |
503 | reg_w(gspca_dev->dev, 0x00, 0x8167, 0x5a); | 497 | reg_w(gspca_dev, 0x00, 0x8167, 0x5a); |
504 | spca500_ping310(gspca_dev); | 498 | spca500_ping310(gspca_dev); |
505 | 499 | ||
506 | reg_w(gspca_dev->dev, 0x00, 0x8168, 0x22); | 500 | reg_w(gspca_dev, 0x00, 0x8168, 0x22); |
507 | reg_w(gspca_dev->dev, 0x00, 0x816a, 0xc0); | 501 | reg_w(gspca_dev, 0x00, 0x816a, 0xc0); |
508 | reg_w(gspca_dev->dev, 0x00, 0x816b, 0x0b); | 502 | reg_w(gspca_dev, 0x00, 0x816b, 0x0b); |
509 | reg_w(gspca_dev->dev, 0x00, 0x8169, 0x25); | 503 | reg_w(gspca_dev, 0x00, 0x8169, 0x25); |
510 | reg_w(gspca_dev->dev, 0x00, 0x8157, 0x5b); | 504 | reg_w(gspca_dev, 0x00, 0x8157, 0x5b); |
511 | reg_w(gspca_dev->dev, 0x00, 0x8158, 0x5b); | 505 | reg_w(gspca_dev, 0x00, 0x8158, 0x5b); |
512 | reg_w(gspca_dev->dev, 0x00, 0x813f, 0x03); | 506 | reg_w(gspca_dev, 0x00, 0x813f, 0x03); |
513 | reg_w(gspca_dev->dev, 0x00, 0x8151, 0x4a); | 507 | reg_w(gspca_dev, 0x00, 0x8151, 0x4a); |
514 | reg_w(gspca_dev->dev, 0x00, 0x8153, 0x78); | 508 | reg_w(gspca_dev, 0x00, 0x8153, 0x78); |
515 | reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x04); | 509 | reg_w(gspca_dev, 0x00, 0x0d01, 0x04); |
516 | /* 00 for adjust shutter */ | 510 | /* 00 for adjust shutter */ |
517 | reg_w(gspca_dev->dev, 0x00, 0x0d02, 0x01); | 511 | reg_w(gspca_dev, 0x00, 0x0d02, 0x01); |
518 | reg_w(gspca_dev->dev, 0x00, 0x8169, 0x25); | 512 | reg_w(gspca_dev, 0x00, 0x8169, 0x25); |
519 | reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x02); | 513 | reg_w(gspca_dev, 0x00, 0x0d01, 0x02); |
520 | } | 514 | } |
521 | 515 | ||
522 | static void spca500_setmode(struct gspca_dev *gspca_dev, | 516 | static void spca500_setmode(struct gspca_dev *gspca_dev, |
@@ -525,14 +519,14 @@ static void spca500_setmode(struct gspca_dev *gspca_dev, | |||
525 | int mode; | 519 | int mode; |
526 | 520 | ||
527 | /* set x multiplier */ | 521 | /* set x multiplier */ |
528 | reg_w(gspca_dev->dev, 0, 0x8001, xmult); | 522 | reg_w(gspca_dev, 0, 0x8001, xmult); |
529 | 523 | ||
530 | /* set y multiplier */ | 524 | /* set y multiplier */ |
531 | reg_w(gspca_dev->dev, 0, 0x8002, ymult); | 525 | reg_w(gspca_dev, 0, 0x8002, ymult); |
532 | 526 | ||
533 | /* use compressed mode, VGA, with mode specific subsample */ | 527 | /* use compressed mode, VGA, with mode specific subsample */ |
534 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; | 528 | mode = gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv; |
535 | reg_w(gspca_dev->dev, 0, 0x8003, mode << 4); | 529 | reg_w(gspca_dev, 0, 0x8003, mode << 4); |
536 | } | 530 | } |
537 | 531 | ||
538 | static int spca500_full_reset(struct gspca_dev *gspca_dev) | 532 | static int spca500_full_reset(struct gspca_dev *gspca_dev) |
@@ -540,18 +534,18 @@ static int spca500_full_reset(struct gspca_dev *gspca_dev) | |||
540 | int err; | 534 | int err; |
541 | 535 | ||
542 | /* send the reset command */ | 536 | /* send the reset command */ |
543 | err = reg_w(gspca_dev->dev, 0xe0, 0x0001, 0x0000); | 537 | err = reg_w(gspca_dev, 0xe0, 0x0001, 0x0000); |
544 | if (err < 0) | 538 | if (err < 0) |
545 | return err; | 539 | return err; |
546 | 540 | ||
547 | /* wait for the reset to complete */ | 541 | /* wait for the reset to complete */ |
548 | err = reg_r_wait(gspca_dev->dev, 0x06, 0x0000, 0x0000); | 542 | err = reg_r_wait(gspca_dev, 0x06, 0x0000, 0x0000); |
549 | if (err < 0) | 543 | if (err < 0) |
550 | return err; | 544 | return err; |
551 | err = reg_w(gspca_dev->dev, 0xe0, 0x0000, 0x0000); | 545 | err = reg_w(gspca_dev, 0xe0, 0x0000, 0x0000); |
552 | if (err < 0) | 546 | if (err < 0) |
553 | return err; | 547 | return err; |
554 | err = reg_r_wait(gspca_dev->dev, 0x06, 0, 0); | 548 | err = reg_r_wait(gspca_dev, 0x06, 0, 0); |
555 | if (err < 0) { | 549 | if (err < 0) { |
556 | PDEBUG(D_ERR, "reg_r_wait() failed"); | 550 | PDEBUG(D_ERR, "reg_r_wait() failed"); |
557 | return err; | 551 | return err; |
@@ -568,15 +562,13 @@ static int spca500_full_reset(struct gspca_dev *gspca_dev) | |||
568 | /* up-port the same feature as in 2.4.x kernel */ | 562 | /* up-port the same feature as in 2.4.x kernel */ |
569 | static int spca500_synch310(struct gspca_dev *gspca_dev) | 563 | static int spca500_synch310(struct gspca_dev *gspca_dev) |
570 | { | 564 | { |
571 | __u8 Data; | ||
572 | |||
573 | if (usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0) < 0) { | 565 | if (usb_set_interface(gspca_dev->dev, gspca_dev->iface, 0) < 0) { |
574 | PDEBUG(D_ERR, "Set packet size: set interface error"); | 566 | PDEBUG(D_ERR, "Set packet size: set interface error"); |
575 | goto error; | 567 | goto error; |
576 | } | 568 | } |
577 | spca500_ping310(gspca_dev); | 569 | spca500_ping310(gspca_dev); |
578 | 570 | ||
579 | reg_r(gspca_dev->dev, 0x0d00, &Data, 1); | 571 | reg_r(gspca_dev, 0x0d00, 1); |
580 | 572 | ||
581 | /* need alt setting here */ | 573 | /* need alt setting here */ |
582 | PDEBUG(D_PACK, "ClickSmart310 sync alt: %d", gspca_dev->alt); | 574 | PDEBUG(D_PACK, "ClickSmart310 sync alt: %d", gspca_dev->alt); |
@@ -600,12 +592,12 @@ static void spca500_reinit(struct gspca_dev *gspca_dev) | |||
600 | 592 | ||
601 | /* some unknow command from Aiptek pocket dv and family300 */ | 593 | /* some unknow command from Aiptek pocket dv and family300 */ |
602 | 594 | ||
603 | reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x01); | 595 | reg_w(gspca_dev, 0x00, 0x0d01, 0x01); |
604 | reg_w(gspca_dev->dev, 0x00, 0x0d03, 0x00); | 596 | reg_w(gspca_dev, 0x00, 0x0d03, 0x00); |
605 | reg_w(gspca_dev->dev, 0x00, 0x0d02, 0x01); | 597 | reg_w(gspca_dev, 0x00, 0x0d02, 0x01); |
606 | 598 | ||
607 | /* enable drop packet */ | 599 | /* enable drop packet */ |
608 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 600 | reg_w(gspca_dev, 0x00, 0x850a, 0x0001); |
609 | 601 | ||
610 | err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840, | 602 | err = spca50x_setup_qtable(gspca_dev, 0x00, 0x8800, 0x8840, |
611 | qtable_pocketdv); | 603 | qtable_pocketdv); |
@@ -613,22 +605,23 @@ static void spca500_reinit(struct gspca_dev *gspca_dev) | |||
613 | PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed on init"); | 605 | PDEBUG(D_ERR|D_STREAM, "spca50x_setup_qtable failed on init"); |
614 | 606 | ||
615 | /* set qtable index */ | 607 | /* set qtable index */ |
616 | reg_w(gspca_dev->dev, 0x00, 0x8880, 2); | 608 | reg_w(gspca_dev, 0x00, 0x8880, 2); |
617 | /* family cam Quicksmart stuff */ | 609 | /* family cam Quicksmart stuff */ |
618 | reg_w(gspca_dev->dev, 0x00, 0x800a, 0x00); | 610 | reg_w(gspca_dev, 0x00, 0x800a, 0x00); |
619 | /* Set agc transfer: synced inbetween frames */ | 611 | /* Set agc transfer: synced inbetween frames */ |
620 | reg_w(gspca_dev->dev, 0x00, 0x820f, 0x01); | 612 | reg_w(gspca_dev, 0x00, 0x820f, 0x01); |
621 | /* Init SDRAM - needed for SDRAM access */ | 613 | /* Init SDRAM - needed for SDRAM access */ |
622 | reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04); | 614 | reg_w(gspca_dev, 0x00, 0x870a, 0x04); |
623 | /*Start init sequence or stream */ | 615 | /*Start init sequence or stream */ |
624 | 616 | reg_w(gspca_dev, 0, 0x8003, 0x00); | |
625 | reg_w(gspca_dev->dev, 0, 0x8003, 0x00); | ||
626 | /* switch to video camera mode */ | 617 | /* switch to video camera mode */ |
627 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 618 | reg_w(gspca_dev, 0x00, 0x8000, 0x0004); |
628 | msleep(2000); | 619 | msleep(2000); |
629 | if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) | 620 | if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) { |
630 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); | 621 | reg_r(gspca_dev, 0x816b, 1); |
631 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); | 622 | Data = gspca_dev->usb_buf[0]; |
623 | reg_w(gspca_dev, 0x00, 0x816b, Data); | ||
624 | } | ||
632 | } | 625 | } |
633 | 626 | ||
634 | /* this function is called at probe time */ | 627 | /* this function is called at probe time */ |
@@ -785,9 +778,10 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
785 | } | 778 | } |
786 | 779 | ||
787 | /* is there a sensor here ? */ | 780 | /* is there a sensor here ? */ |
788 | reg_r(gspca_dev->dev, 0x8a04, &Data, 1); | 781 | reg_r(gspca_dev, 0x8a04, 1); |
789 | PDEBUG(D_STREAM, "Spca500 Sensor Address 0x%02X", Data); | 782 | PDEBUG(D_STREAM, "Spca500 Sensor Address 0x%02x", |
790 | PDEBUG(D_STREAM, "Spca500 curr_mode: %d Xmult: 0x%02X, Ymult: 0x%02X", | 783 | gspca_dev->usb_buf[0]); |
784 | PDEBUG(D_STREAM, "Spca500 curr_mode: %d Xmult: 0x%02x, Ymult: 0x%02x", | ||
791 | gspca_dev->curr_mode, xmult, ymult); | 785 | gspca_dev->curr_mode, xmult, ymult); |
792 | 786 | ||
793 | /* setup qtable */ | 787 | /* setup qtable */ |
@@ -796,33 +790,34 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
796 | spca500_setmode(gspca_dev, xmult, ymult); | 790 | spca500_setmode(gspca_dev, xmult, ymult); |
797 | 791 | ||
798 | /* enable drop packet */ | 792 | /* enable drop packet */ |
799 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 793 | reg_w(gspca_dev, 0x00, 0x850a, 0x0001); |
800 | reg_w(gspca_dev->dev, 0x00, 0x8880, 3); | 794 | reg_w(gspca_dev, 0x00, 0x8880, 3); |
801 | err = spca50x_setup_qtable(gspca_dev, | 795 | err = spca50x_setup_qtable(gspca_dev, |
802 | 0x00, 0x8800, 0x8840, | 796 | 0x00, 0x8800, 0x8840, |
803 | qtable_creative_pccam); | 797 | qtable_creative_pccam); |
804 | if (err < 0) | 798 | if (err < 0) |
805 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 799 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
806 | /* Init SDRAM - needed for SDRAM access */ | 800 | /* Init SDRAM - needed for SDRAM access */ |
807 | reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04); | 801 | reg_w(gspca_dev, 0x00, 0x870a, 0x04); |
808 | 802 | ||
809 | /* switch to video camera mode */ | 803 | /* switch to video camera mode */ |
810 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 804 | reg_w(gspca_dev, 0x00, 0x8000, 0x0004); |
811 | msleep(500); | 805 | msleep(500); |
812 | if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) | 806 | if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) |
813 | PDEBUG(D_ERR, "reg_r_wait() failed"); | 807 | PDEBUG(D_ERR, "reg_r_wait() failed"); |
814 | 808 | ||
815 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); | 809 | reg_r(gspca_dev, 0x816b, 1); |
816 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); | 810 | Data = gspca_dev->usb_buf[0]; |
811 | reg_w(gspca_dev, 0x00, 0x816b, Data); | ||
817 | 812 | ||
818 | spca500_synch310(gspca_dev); | 813 | spca500_synch310(gspca_dev); |
819 | 814 | ||
820 | write_vector(gspca_dev, spca500_visual_defaults); | 815 | write_vector(gspca_dev, spca500_visual_defaults); |
821 | spca500_setmode(gspca_dev, xmult, ymult); | 816 | spca500_setmode(gspca_dev, xmult, ymult); |
822 | /* enable drop packet */ | 817 | /* enable drop packet */ |
823 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 818 | reg_w(gspca_dev, 0x00, 0x850a, 0x0001); |
824 | PDEBUG(D_ERR, "failed to enable drop packet"); | 819 | PDEBUG(D_ERR, "failed to enable drop packet"); |
825 | reg_w(gspca_dev->dev, 0x00, 0x8880, 3); | 820 | reg_w(gspca_dev, 0x00, 0x8880, 3); |
826 | err = spca50x_setup_qtable(gspca_dev, | 821 | err = spca50x_setup_qtable(gspca_dev, |
827 | 0x00, 0x8800, 0x8840, | 822 | 0x00, 0x8800, 0x8840, |
828 | qtable_creative_pccam); | 823 | qtable_creative_pccam); |
@@ -830,16 +825,17 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
830 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 825 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
831 | 826 | ||
832 | /* Init SDRAM - needed for SDRAM access */ | 827 | /* Init SDRAM - needed for SDRAM access */ |
833 | reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04); | 828 | reg_w(gspca_dev, 0x00, 0x870a, 0x04); |
834 | 829 | ||
835 | /* switch to video camera mode */ | 830 | /* switch to video camera mode */ |
836 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 831 | reg_w(gspca_dev, 0x00, 0x8000, 0x0004); |
837 | 832 | ||
838 | if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) | 833 | if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) |
839 | PDEBUG(D_ERR, "reg_r_wait() failed"); | 834 | PDEBUG(D_ERR, "reg_r_wait() failed"); |
840 | 835 | ||
841 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); | 836 | reg_r(gspca_dev, 0x816b, 1); |
842 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); | 837 | Data = gspca_dev->usb_buf[0]; |
838 | reg_w(gspca_dev, 0x00, 0x816b, Data); | ||
843 | break; | 839 | break; |
844 | case CreativePCCam300: /* Creative PC-CAM 300 640x480 CCD */ | 840 | case CreativePCCam300: /* Creative PC-CAM 300 640x480 CCD */ |
845 | case IntelPocketPCCamera: /* FIXME: Temporary fix for | 841 | case IntelPocketPCCamera: /* FIXME: Temporary fix for |
@@ -852,10 +848,10 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
852 | PDEBUG(D_ERR, "spca500_full_reset failed"); | 848 | PDEBUG(D_ERR, "spca500_full_reset failed"); |
853 | 849 | ||
854 | /* enable drop packet */ | 850 | /* enable drop packet */ |
855 | err = reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 851 | err = reg_w(gspca_dev, 0x00, 0x850a, 0x0001); |
856 | if (err < 0) | 852 | if (err < 0) |
857 | PDEBUG(D_ERR, "failed to enable drop packet"); | 853 | PDEBUG(D_ERR, "failed to enable drop packet"); |
858 | reg_w(gspca_dev->dev, 0x00, 0x8880, 3); | 854 | reg_w(gspca_dev, 0x00, 0x8880, 3); |
859 | err = spca50x_setup_qtable(gspca_dev, | 855 | err = spca50x_setup_qtable(gspca_dev, |
860 | 0x00, 0x8800, 0x8840, | 856 | 0x00, 0x8800, 0x8840, |
861 | qtable_creative_pccam); | 857 | qtable_creative_pccam); |
@@ -863,16 +859,17 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
863 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 859 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
864 | 860 | ||
865 | spca500_setmode(gspca_dev, xmult, ymult); | 861 | spca500_setmode(gspca_dev, xmult, ymult); |
866 | reg_w(gspca_dev->dev, 0x20, 0x0001, 0x0004); | 862 | reg_w(gspca_dev, 0x20, 0x0001, 0x0004); |
867 | 863 | ||
868 | /* switch to video camera mode */ | 864 | /* switch to video camera mode */ |
869 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 865 | reg_w(gspca_dev, 0x00, 0x8000, 0x0004); |
870 | 866 | ||
871 | if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) | 867 | if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) |
872 | PDEBUG(D_ERR, "reg_r_wait() failed"); | 868 | PDEBUG(D_ERR, "reg_r_wait() failed"); |
873 | 869 | ||
874 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); | 870 | reg_r(gspca_dev, 0x816b, 1); |
875 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); | 871 | Data = gspca_dev->usb_buf[0]; |
872 | reg_w(gspca_dev, 0x00, 0x816b, Data); | ||
876 | 873 | ||
877 | /* write_vector(gspca_dev, spca500_visual_defaults); */ | 874 | /* write_vector(gspca_dev, spca500_visual_defaults); */ |
878 | break; | 875 | break; |
@@ -883,8 +880,8 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
883 | if (err < 0) | 880 | if (err < 0) |
884 | PDEBUG(D_ERR, "spca500_full_reset failed"); | 881 | PDEBUG(D_ERR, "spca500_full_reset failed"); |
885 | /* enable drop packet */ | 882 | /* enable drop packet */ |
886 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 883 | reg_w(gspca_dev, 0x00, 0x850a, 0x0001); |
887 | reg_w(gspca_dev->dev, 0x00, 0x8880, 0); | 884 | reg_w(gspca_dev, 0x00, 0x8880, 0); |
888 | err = spca50x_setup_qtable(gspca_dev, | 885 | err = spca50x_setup_qtable(gspca_dev, |
889 | 0x00, 0x8800, 0x8840, | 886 | 0x00, 0x8800, 0x8840, |
890 | qtable_kodak_ez200); | 887 | qtable_kodak_ez200); |
@@ -892,16 +889,17 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
892 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 889 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
893 | spca500_setmode(gspca_dev, xmult, ymult); | 890 | spca500_setmode(gspca_dev, xmult, ymult); |
894 | 891 | ||
895 | reg_w(gspca_dev->dev, 0x20, 0x0001, 0x0004); | 892 | reg_w(gspca_dev, 0x20, 0x0001, 0x0004); |
896 | 893 | ||
897 | /* switch to video camera mode */ | 894 | /* switch to video camera mode */ |
898 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 895 | reg_w(gspca_dev, 0x00, 0x8000, 0x0004); |
899 | 896 | ||
900 | if (reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44) != 0) | 897 | if (reg_r_wait(gspca_dev, 0, 0x8000, 0x44) != 0) |
901 | PDEBUG(D_ERR, "reg_r_wait() failed"); | 898 | PDEBUG(D_ERR, "reg_r_wait() failed"); |
902 | 899 | ||
903 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); | 900 | reg_r(gspca_dev, 0x816b, 1); |
904 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); | 901 | Data = gspca_dev->usb_buf[0]; |
902 | reg_w(gspca_dev, 0x00, 0x816b, Data); | ||
905 | 903 | ||
906 | /* write_vector(gspca_dev, spca500_visual_defaults); */ | 904 | /* write_vector(gspca_dev, spca500_visual_defaults); */ |
907 | break; | 905 | break; |
@@ -916,56 +914,58 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
916 | case ToptroIndus: | 914 | case ToptroIndus: |
917 | case AgfaCl20: | 915 | case AgfaCl20: |
918 | spca500_reinit(gspca_dev); | 916 | spca500_reinit(gspca_dev); |
919 | reg_w(gspca_dev->dev, 0x00, 0x0d01, 0x01); | 917 | reg_w(gspca_dev, 0x00, 0x0d01, 0x01); |
920 | /* enable drop packet */ | 918 | /* enable drop packet */ |
921 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 919 | reg_w(gspca_dev, 0x00, 0x850a, 0x0001); |
922 | 920 | ||
923 | err = spca50x_setup_qtable(gspca_dev, | 921 | err = spca50x_setup_qtable(gspca_dev, |
924 | 0x00, 0x8800, 0x8840, qtable_pocketdv); | 922 | 0x00, 0x8800, 0x8840, qtable_pocketdv); |
925 | if (err < 0) | 923 | if (err < 0) |
926 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 924 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
927 | reg_w(gspca_dev->dev, 0x00, 0x8880, 2); | 925 | reg_w(gspca_dev, 0x00, 0x8880, 2); |
928 | 926 | ||
929 | /* familycam Quicksmart pocketDV stuff */ | 927 | /* familycam Quicksmart pocketDV stuff */ |
930 | reg_w(gspca_dev->dev, 0x00, 0x800a, 0x00); | 928 | reg_w(gspca_dev, 0x00, 0x800a, 0x00); |
931 | /* Set agc transfer: synced inbetween frames */ | 929 | /* Set agc transfer: synced inbetween frames */ |
932 | reg_w(gspca_dev->dev, 0x00, 0x820f, 0x01); | 930 | reg_w(gspca_dev, 0x00, 0x820f, 0x01); |
933 | /* Init SDRAM - needed for SDRAM access */ | 931 | /* Init SDRAM - needed for SDRAM access */ |
934 | reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04); | 932 | reg_w(gspca_dev, 0x00, 0x870a, 0x04); |
935 | 933 | ||
936 | spca500_setmode(gspca_dev, xmult, ymult); | 934 | spca500_setmode(gspca_dev, xmult, ymult); |
937 | /* switch to video camera mode */ | 935 | /* switch to video camera mode */ |
938 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 936 | reg_w(gspca_dev, 0x00, 0x8000, 0x0004); |
939 | 937 | ||
940 | reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44); | 938 | reg_r_wait(gspca_dev, 0, 0x8000, 0x44); |
941 | 939 | ||
942 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); | 940 | reg_r(gspca_dev, 0x816b, 1); |
943 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); | 941 | Data = gspca_dev->usb_buf[0]; |
942 | reg_w(gspca_dev, 0x00, 0x816b, Data); | ||
944 | break; | 943 | break; |
945 | case LogitechTraveler: | 944 | case LogitechTraveler: |
946 | case LogitechClickSmart510: | 945 | case LogitechClickSmart510: |
947 | reg_w(gspca_dev->dev, 0x02, 0x00, 0x00); | 946 | reg_w(gspca_dev, 0x02, 0x00, 0x00); |
948 | /* enable drop packet */ | 947 | /* enable drop packet */ |
949 | reg_w(gspca_dev->dev, 0x00, 0x850a, 0x0001); | 948 | reg_w(gspca_dev, 0x00, 0x850a, 0x0001); |
950 | 949 | ||
951 | err = spca50x_setup_qtable(gspca_dev, | 950 | err = spca50x_setup_qtable(gspca_dev, |
952 | 0x00, 0x8800, | 951 | 0x00, 0x8800, |
953 | 0x8840, qtable_creative_pccam); | 952 | 0x8840, qtable_creative_pccam); |
954 | if (err < 0) | 953 | if (err < 0) |
955 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); | 954 | PDEBUG(D_ERR, "spca50x_setup_qtable failed"); |
956 | reg_w(gspca_dev->dev, 0x00, 0x8880, 3); | 955 | reg_w(gspca_dev, 0x00, 0x8880, 3); |
957 | reg_w(gspca_dev->dev, 0x00, 0x800a, 0x00); | 956 | reg_w(gspca_dev, 0x00, 0x800a, 0x00); |
958 | /* Init SDRAM - needed for SDRAM access */ | 957 | /* Init SDRAM - needed for SDRAM access */ |
959 | reg_w(gspca_dev->dev, 0x00, 0x870a, 0x04); | 958 | reg_w(gspca_dev, 0x00, 0x870a, 0x04); |
960 | 959 | ||
961 | spca500_setmode(gspca_dev, xmult, ymult); | 960 | spca500_setmode(gspca_dev, xmult, ymult); |
962 | 961 | ||
963 | /* switch to video camera mode */ | 962 | /* switch to video camera mode */ |
964 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 963 | reg_w(gspca_dev, 0x00, 0x8000, 0x0004); |
965 | reg_r_wait(gspca_dev->dev, 0, 0x8000, 0x44); | 964 | reg_r_wait(gspca_dev, 0, 0x8000, 0x44); |
966 | 965 | ||
967 | reg_r(gspca_dev->dev, 0x816b, &Data, 1); | 966 | reg_r(gspca_dev, 0x816b, 1); |
968 | reg_w(gspca_dev->dev, 0x00, 0x816b, Data); | 967 | Data = gspca_dev->usb_buf[0]; |
968 | reg_w(gspca_dev, 0x00, 0x816b, Data); | ||
969 | write_vector(gspca_dev, Clicksmart510_defaults); | 969 | write_vector(gspca_dev, Clicksmart510_defaults); |
970 | break; | 970 | break; |
971 | } | 971 | } |
@@ -973,14 +973,13 @@ static void sd_start(struct gspca_dev *gspca_dev) | |||
973 | 973 | ||
974 | static void sd_stopN(struct gspca_dev *gspca_dev) | 974 | static void sd_stopN(struct gspca_dev *gspca_dev) |
975 | { | 975 | { |
976 | __u8 data; | 976 | reg_w(gspca_dev, 0, 0x8003, 0x00); |
977 | |||
978 | reg_w(gspca_dev->dev, 0, 0x8003, 0x00); | ||
979 | 977 | ||
980 | /* switch to video camera mode */ | 978 | /* switch to video camera mode */ |
981 | reg_w(gspca_dev->dev, 0x00, 0x8000, 0x0004); | 979 | reg_w(gspca_dev, 0x00, 0x8000, 0x0004); |
982 | reg_r(gspca_dev->dev, 0x8000, &data, 1); | 980 | reg_r(gspca_dev, 0x8000, 1); |
983 | PDEBUG(D_STREAM, "stop SPCA500 done reg8000: 0x%2x", data); | 981 | PDEBUG(D_STREAM, "stop SPCA500 done reg8000: 0x%2x", |
982 | gspca_dev->usb_buf[0]); | ||
984 | } | 983 | } |
985 | 984 | ||
986 | static void sd_stop0(struct gspca_dev *gspca_dev) | 985 | static void sd_stop0(struct gspca_dev *gspca_dev) |
@@ -1043,7 +1042,7 @@ static void setbrightness(struct gspca_dev *gspca_dev) | |||
1043 | { | 1042 | { |
1044 | struct sd *sd = (struct sd *) gspca_dev; | 1043 | struct sd *sd = (struct sd *) gspca_dev; |
1045 | 1044 | ||
1046 | reg_w(gspca_dev->dev, 0x00, 0x8167, | 1045 | reg_w(gspca_dev, 0x00, 0x8167, |
1047 | (__u8) (sd->brightness - 128)); | 1046 | (__u8) (sd->brightness - 128)); |
1048 | } | 1047 | } |
1049 | 1048 | ||
@@ -1052,7 +1051,7 @@ static void getbrightness(struct gspca_dev *gspca_dev) | |||
1052 | struct sd *sd = (struct sd *) gspca_dev; | 1051 | struct sd *sd = (struct sd *) gspca_dev; |
1053 | int ret; | 1052 | int ret; |
1054 | 1053 | ||
1055 | ret = reg_r_12(gspca_dev->dev, 0x00, 0x8167, 1); | 1054 | ret = reg_r_12(gspca_dev, 0x00, 0x8167, 1); |
1056 | if (ret >= 0) | 1055 | if (ret >= 0) |
1057 | sd->brightness = ret + 128; | 1056 | sd->brightness = ret + 128; |
1058 | } | 1057 | } |
@@ -1061,7 +1060,7 @@ static void setcontrast(struct gspca_dev *gspca_dev) | |||
1061 | { | 1060 | { |
1062 | struct sd *sd = (struct sd *) gspca_dev; | 1061 | struct sd *sd = (struct sd *) gspca_dev; |
1063 | 1062 | ||
1064 | reg_w(gspca_dev->dev, 0x00, 0x8168, sd->contrast); | 1063 | reg_w(gspca_dev, 0x00, 0x8168, sd->contrast); |
1065 | } | 1064 | } |
1066 | 1065 | ||
1067 | static void getcontrast(struct gspca_dev *gspca_dev) | 1066 | static void getcontrast(struct gspca_dev *gspca_dev) |
@@ -1069,7 +1068,7 @@ static void getcontrast(struct gspca_dev *gspca_dev) | |||
1069 | struct sd *sd = (struct sd *) gspca_dev; | 1068 | struct sd *sd = (struct sd *) gspca_dev; |
1070 | int ret; | 1069 | int ret; |
1071 | 1070 | ||
1072 | ret = reg_r_12(gspca_dev->dev, 0x0, 0x8168, 1); | 1071 | ret = reg_r_12(gspca_dev, 0x0, 0x8168, 1); |
1073 | if (ret >= 0) | 1072 | if (ret >= 0) |
1074 | sd->contrast = ret; | 1073 | sd->contrast = ret; |
1075 | } | 1074 | } |
@@ -1078,7 +1077,7 @@ static void setcolors(struct gspca_dev *gspca_dev) | |||
1078 | { | 1077 | { |
1079 | struct sd *sd = (struct sd *) gspca_dev; | 1078 | struct sd *sd = (struct sd *) gspca_dev; |
1080 | 1079 | ||
1081 | reg_w(gspca_dev->dev, 0x00, 0x8169, sd->colors); | 1080 | reg_w(gspca_dev, 0x00, 0x8169, sd->colors); |
1082 | } | 1081 | } |
1083 | 1082 | ||
1084 | static void getcolors(struct gspca_dev *gspca_dev) | 1083 | static void getcolors(struct gspca_dev *gspca_dev) |
@@ -1086,7 +1085,7 @@ static void getcolors(struct gspca_dev *gspca_dev) | |||
1086 | struct sd *sd = (struct sd *) gspca_dev; | 1085 | struct sd *sd = (struct sd *) gspca_dev; |
1087 | int ret; | 1086 | int ret; |
1088 | 1087 | ||
1089 | ret = reg_r_12(gspca_dev->dev, 0x0, 0x8169, 1); | 1088 | ret = reg_r_12(gspca_dev, 0x0, 0x8169, 1); |
1090 | if (ret >= 0) | 1089 | if (ret >= 0) |
1091 | sd->colors = ret; | 1090 | sd->colors = ret; |
1092 | } | 1091 | } |