diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2010-01-13 13:09:14 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-02-26 13:10:47 -0500 |
commit | be927befd091481f88c5806aa0585f25ab2ee3a1 (patch) | |
tree | d0cef515ea72e265e6e30b12af35a9e8348f374d /drivers/media | |
parent | 23a5de202bc385b69eb91a5db36699e9579ec03e (diff) |
V4L/DVB: gspca - pac7302: Use usb_err to propagate USB errors
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/pac7302.c | 253 |
1 files changed, 96 insertions, 157 deletions
diff --git a/drivers/media/video/gspca/pac7302.c b/drivers/media/video/gspca/pac7302.c index 336d97ddf54e..4fa604a0457f 100644 --- a/drivers/media/video/gspca/pac7302.c +++ b/drivers/media/video/gspca/pac7302.c | |||
@@ -400,12 +400,14 @@ static const __u8 page3_7302[] = { | |||
400 | 0x00 | 400 | 0x00 |
401 | }; | 401 | }; |
402 | 402 | ||
403 | static int reg_w_buf(struct gspca_dev *gspca_dev, | 403 | static void reg_w_buf(struct gspca_dev *gspca_dev, |
404 | __u8 index, | 404 | __u8 index, |
405 | const char *buffer, int len) | 405 | const char *buffer, int len) |
406 | { | 406 | { |
407 | int ret; | 407 | int ret; |
408 | 408 | ||
409 | if (gspca_dev->usb_err < 0) | ||
410 | return; | ||
409 | memcpy(gspca_dev->usb_buf, buffer, len); | 411 | memcpy(gspca_dev->usb_buf, buffer, len); |
410 | ret = usb_control_msg(gspca_dev->dev, | 412 | ret = usb_control_msg(gspca_dev->dev, |
411 | usb_sndctrlpipe(gspca_dev->dev, 0), | 413 | usb_sndctrlpipe(gspca_dev->dev, 0), |
@@ -414,20 +416,23 @@ static int reg_w_buf(struct gspca_dev *gspca_dev, | |||
414 | 0, /* value */ | 416 | 0, /* value */ |
415 | index, gspca_dev->usb_buf, len, | 417 | index, gspca_dev->usb_buf, len, |
416 | 500); | 418 | 500); |
417 | if (ret < 0) | 419 | if (ret < 0) { |
418 | PDEBUG(D_ERR, "reg_w_buf(): " | 420 | PDEBUG(D_ERR, "reg_w_buf(): " |
419 | "Failed to write registers to index 0x%x, error %i", | 421 | "Failed to write registers to index 0x%x, error %i", |
420 | index, ret); | 422 | index, ret); |
421 | return ret; | 423 | gspca_dev->usb_err = ret; |
424 | } | ||
422 | } | 425 | } |
423 | 426 | ||
424 | 427 | ||
425 | static int reg_w(struct gspca_dev *gspca_dev, | 428 | static void reg_w(struct gspca_dev *gspca_dev, |
426 | __u8 index, | 429 | __u8 index, |
427 | __u8 value) | 430 | __u8 value) |
428 | { | 431 | { |
429 | int ret; | 432 | int ret; |
430 | 433 | ||
434 | if (gspca_dev->usb_err < 0) | ||
435 | return; | ||
431 | gspca_dev->usb_buf[0] = value; | 436 | gspca_dev->usb_buf[0] = value; |
432 | ret = usb_control_msg(gspca_dev->dev, | 437 | ret = usb_control_msg(gspca_dev->dev, |
433 | usb_sndctrlpipe(gspca_dev->dev, 0), | 438 | usb_sndctrlpipe(gspca_dev->dev, 0), |
@@ -435,32 +440,32 @@ static int reg_w(struct gspca_dev *gspca_dev, | |||
435 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 440 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
436 | 0, index, gspca_dev->usb_buf, 1, | 441 | 0, index, gspca_dev->usb_buf, 1, |
437 | 500); | 442 | 500); |
438 | if (ret < 0) | 443 | if (ret < 0) { |
439 | PDEBUG(D_ERR, "reg_w(): " | 444 | PDEBUG(D_ERR, "reg_w(): " |
440 | "Failed to write register to index 0x%x, value 0x%x, error %i", | 445 | "Failed to write register to index 0x%x, value 0x%x, error %i", |
441 | index, value, ret); | 446 | index, value, ret); |
442 | return ret; | 447 | gspca_dev->usb_err = ret; |
448 | } | ||
443 | } | 449 | } |
444 | 450 | ||
445 | static int reg_w_seq(struct gspca_dev *gspca_dev, | 451 | static void reg_w_seq(struct gspca_dev *gspca_dev, |
446 | const __u8 *seq, int len) | 452 | const __u8 *seq, int len) |
447 | { | 453 | { |
448 | int ret = 0; | ||
449 | while (--len >= 0) { | 454 | while (--len >= 0) { |
450 | if (0 <= ret) | 455 | reg_w(gspca_dev, seq[0], seq[1]); |
451 | ret = reg_w(gspca_dev, seq[0], seq[1]); | ||
452 | seq += 2; | 456 | seq += 2; |
453 | } | 457 | } |
454 | return ret; | ||
455 | } | 458 | } |
456 | 459 | ||
457 | /* load the beginning of a page */ | 460 | /* load the beginning of a page */ |
458 | static int reg_w_page(struct gspca_dev *gspca_dev, | 461 | static void reg_w_page(struct gspca_dev *gspca_dev, |
459 | const __u8 *page, int len) | 462 | const __u8 *page, int len) |
460 | { | 463 | { |
461 | int index; | 464 | int index; |
462 | int ret = 0; | 465 | int ret = 0; |
463 | 466 | ||
467 | if (gspca_dev->usb_err < 0) | ||
468 | return; | ||
464 | for (index = 0; index < len; index++) { | 469 | for (index = 0; index < len; index++) { |
465 | if (page[index] == SKIP) /* skip this index */ | 470 | if (page[index] == SKIP) /* skip this index */ |
466 | continue; | 471 | continue; |
@@ -476,52 +481,47 @@ static int reg_w_page(struct gspca_dev *gspca_dev, | |||
476 | "Failed to write register to index 0x%x, " | 481 | "Failed to write register to index 0x%x, " |
477 | "value 0x%x, error %i", | 482 | "value 0x%x, error %i", |
478 | index, page[index], ret); | 483 | index, page[index], ret); |
484 | gspca_dev->usb_err = ret; | ||
479 | break; | 485 | break; |
480 | } | 486 | } |
481 | } | 487 | } |
482 | return ret; | ||
483 | } | 488 | } |
484 | 489 | ||
485 | /* output a variable sequence */ | 490 | /* output a variable sequence */ |
486 | static int reg_w_var(struct gspca_dev *gspca_dev, | 491 | static void reg_w_var(struct gspca_dev *gspca_dev, |
487 | const __u8 *seq, | 492 | const __u8 *seq, |
488 | const __u8 *page3, unsigned int page3_len) | 493 | const __u8 *page3, unsigned int page3_len) |
489 | { | 494 | { |
490 | int index, len; | 495 | int index, len; |
491 | int ret = 0; | ||
492 | 496 | ||
493 | for (;;) { | 497 | for (;;) { |
494 | index = *seq++; | 498 | index = *seq++; |
495 | len = *seq++; | 499 | len = *seq++; |
496 | switch (len) { | 500 | switch (len) { |
497 | case END_OF_SEQUENCE: | 501 | case END_OF_SEQUENCE: |
498 | return ret; | 502 | return; |
499 | case LOAD_PAGE3: | 503 | case LOAD_PAGE3: |
500 | ret = reg_w_page(gspca_dev, page3, page3_len); | 504 | reg_w_page(gspca_dev, page3, page3_len); |
501 | break; | 505 | break; |
502 | default: | 506 | default: |
503 | if (len > USB_BUF_SZ) { | 507 | if (len > USB_BUF_SZ) { |
504 | PDEBUG(D_ERR|D_STREAM, | 508 | PDEBUG(D_ERR|D_STREAM, |
505 | "Incorrect variable sequence"); | 509 | "Incorrect variable sequence"); |
506 | return -EINVAL; | 510 | return; |
507 | } | 511 | } |
508 | while (len > 0) { | 512 | while (len > 0) { |
509 | if (len < 8) { | 513 | if (len < 8) { |
510 | ret = reg_w_buf(gspca_dev, | 514 | reg_w_buf(gspca_dev, |
511 | index, seq, len); | 515 | index, seq, len); |
512 | if (ret < 0) | ||
513 | return ret; | ||
514 | seq += len; | 516 | seq += len; |
515 | break; | 517 | break; |
516 | } | 518 | } |
517 | ret = reg_w_buf(gspca_dev, index, seq, 8); | 519 | reg_w_buf(gspca_dev, index, seq, 8); |
518 | seq += 8; | 520 | seq += 8; |
519 | index += 8; | 521 | index += 8; |
520 | len -= 8; | 522 | len -= 8; |
521 | } | 523 | } |
522 | } | 524 | } |
523 | if (ret < 0) | ||
524 | return ret; | ||
525 | } | 525 | } |
526 | /* not reached */ | 526 | /* not reached */ |
527 | } | 527 | } |
@@ -555,11 +555,10 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
555 | } | 555 | } |
556 | 556 | ||
557 | /* This function is used by pac7302 only */ | 557 | /* This function is used by pac7302 only */ |
558 | static int setbrightcont(struct gspca_dev *gspca_dev) | 558 | static void setbrightcont(struct gspca_dev *gspca_dev) |
559 | { | 559 | { |
560 | struct sd *sd = (struct sd *) gspca_dev; | 560 | struct sd *sd = (struct sd *) gspca_dev; |
561 | int i, v; | 561 | int i, v; |
562 | int ret; | ||
563 | static const __u8 max[10] = | 562 | static const __u8 max[10] = |
564 | {0x29, 0x33, 0x42, 0x5a, 0x6e, 0x80, 0x9f, 0xbb, | 563 | {0x29, 0x33, 0x42, 0x5a, 0x6e, 0x80, 0x9f, 0xbb, |
565 | 0xd4, 0xec}; | 564 | 0xd4, 0xec}; |
@@ -567,7 +566,7 @@ static int setbrightcont(struct gspca_dev *gspca_dev) | |||
567 | {0x35, 0x33, 0x33, 0x2f, 0x2a, 0x25, 0x1e, 0x17, | 566 | {0x35, 0x33, 0x33, 0x2f, 0x2a, 0x25, 0x1e, 0x17, |
568 | 0x11, 0x0b}; | 567 | 0x11, 0x0b}; |
569 | 568 | ||
570 | ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ | 569 | reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ |
571 | for (i = 0; i < 10; i++) { | 570 | for (i = 0; i < 10; i++) { |
572 | v = max[i]; | 571 | v = max[i]; |
573 | v += (sd->brightness - BRIGHTNESS_MAX) | 572 | v += (sd->brightness - BRIGHTNESS_MAX) |
@@ -577,107 +576,80 @@ static int setbrightcont(struct gspca_dev *gspca_dev) | |||
577 | v = 0; | 576 | v = 0; |
578 | else if (v > 0xff) | 577 | else if (v > 0xff) |
579 | v = 0xff; | 578 | v = 0xff; |
580 | if (0 <= ret) | 579 | reg_w(gspca_dev, 0xa2 + i, v); |
581 | ret = reg_w(gspca_dev, 0xa2 + i, v); | ||
582 | } | 580 | } |
583 | if (0 <= ret) | 581 | reg_w(gspca_dev, 0xdc, 0x01); |
584 | ret = reg_w(gspca_dev, 0xdc, 0x01); | ||
585 | return ret; | ||
586 | } | 582 | } |
587 | 583 | ||
588 | /* This function is used by pac7302 only */ | 584 | /* This function is used by pac7302 only */ |
589 | static int setcolors(struct gspca_dev *gspca_dev) | 585 | static void setcolors(struct gspca_dev *gspca_dev) |
590 | { | 586 | { |
591 | struct sd *sd = (struct sd *) gspca_dev; | 587 | struct sd *sd = (struct sd *) gspca_dev; |
592 | int i, v; | 588 | int i, v; |
593 | int ret; | ||
594 | static const int a[9] = | 589 | static const int a[9] = |
595 | {217, -212, 0, -101, 170, -67, -38, -315, 355}; | 590 | {217, -212, 0, -101, 170, -67, -38, -315, 355}; |
596 | static const int b[9] = | 591 | static const int b[9] = |
597 | {19, 106, 0, 19, 106, 1, 19, 106, 1}; | 592 | {19, 106, 0, 19, 106, 1, 19, 106, 1}; |
598 | 593 | ||
599 | ret = reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ | 594 | reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ |
600 | if (0 <= ret) | 595 | reg_w(gspca_dev, 0x11, 0x01); |
601 | ret = reg_w(gspca_dev, 0x11, 0x01); | 596 | reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ |
602 | if (0 <= ret) | ||
603 | ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ | ||
604 | for (i = 0; i < 9; i++) { | 597 | for (i = 0; i < 9; i++) { |
605 | v = a[i] * sd->colors / COLOR_MAX + b[i]; | 598 | v = a[i] * sd->colors / COLOR_MAX + b[i]; |
606 | if (0 <= ret) | 599 | reg_w(gspca_dev, 0x0f + 2 * i, (v >> 8) & 0x07); |
607 | ret = reg_w(gspca_dev, 0x0f + 2 * i, (v >> 8) & 0x07); | 600 | reg_w(gspca_dev, 0x0f + 2 * i + 1, v); |
608 | if (0 <= ret) | ||
609 | ret = reg_w(gspca_dev, 0x0f + 2 * i + 1, v); | ||
610 | } | 601 | } |
611 | if (0 <= ret) | 602 | reg_w(gspca_dev, 0xdc, 0x01); |
612 | ret = reg_w(gspca_dev, 0xdc, 0x01); | ||
613 | PDEBUG(D_CONF|D_STREAM, "color: %i", sd->colors); | 603 | PDEBUG(D_CONF|D_STREAM, "color: %i", sd->colors); |
614 | return ret; | ||
615 | } | 604 | } |
616 | 605 | ||
617 | static int setwhitebalance(struct gspca_dev *gspca_dev) | 606 | static void setwhitebalance(struct gspca_dev *gspca_dev) |
618 | { | 607 | { |
619 | struct sd *sd = (struct sd *) gspca_dev; | 608 | struct sd *sd = (struct sd *) gspca_dev; |
620 | int ret; | ||
621 | 609 | ||
622 | ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ | 610 | reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ |
623 | if (0 <= ret) | 611 | reg_w(gspca_dev, 0xc6, sd->white_balance); |
624 | ret = reg_w(gspca_dev, 0xc6, sd->white_balance); | ||
625 | 612 | ||
626 | if (0 <= ret) | 613 | reg_w(gspca_dev, 0xdc, 0x01); |
627 | ret = reg_w(gspca_dev, 0xdc, 0x01); | ||
628 | PDEBUG(D_CONF|D_STREAM, "white_balance: %i", sd->white_balance); | 614 | PDEBUG(D_CONF|D_STREAM, "white_balance: %i", sd->white_balance); |
629 | return ret; | ||
630 | } | 615 | } |
631 | 616 | ||
632 | static int setredbalance(struct gspca_dev *gspca_dev) | 617 | static void setredbalance(struct gspca_dev *gspca_dev) |
633 | { | 618 | { |
634 | struct sd *sd = (struct sd *) gspca_dev; | 619 | struct sd *sd = (struct sd *) gspca_dev; |
635 | int ret; | ||
636 | 620 | ||
637 | ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ | 621 | reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ |
638 | if (0 <= ret) | 622 | reg_w(gspca_dev, 0xc5, sd->red_balance); |
639 | ret = reg_w(gspca_dev, 0xc5, sd->red_balance); | ||
640 | 623 | ||
641 | if (0 <= ret) | 624 | reg_w(gspca_dev, 0xdc, 0x01); |
642 | ret = reg_w(gspca_dev, 0xdc, 0x01); | ||
643 | PDEBUG(D_CONF|D_STREAM, "red_balance: %i", sd->red_balance); | 625 | PDEBUG(D_CONF|D_STREAM, "red_balance: %i", sd->red_balance); |
644 | return ret; | ||
645 | } | 626 | } |
646 | 627 | ||
647 | static int setbluebalance(struct gspca_dev *gspca_dev) | 628 | static void setbluebalance(struct gspca_dev *gspca_dev) |
648 | { | 629 | { |
649 | struct sd *sd = (struct sd *) gspca_dev; | 630 | struct sd *sd = (struct sd *) gspca_dev; |
650 | int ret; | ||
651 | 631 | ||
652 | ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ | 632 | reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ |
653 | if (0 <= ret) | 633 | reg_w(gspca_dev, 0xc7, sd->blue_balance); |
654 | ret = reg_w(gspca_dev, 0xc7, sd->blue_balance); | ||
655 | 634 | ||
656 | if (0 <= ret) | 635 | reg_w(gspca_dev, 0xdc, 0x01); |
657 | ret = reg_w(gspca_dev, 0xdc, 0x01); | ||
658 | PDEBUG(D_CONF|D_STREAM, "blue_balance: %i", sd->blue_balance); | 636 | PDEBUG(D_CONF|D_STREAM, "blue_balance: %i", sd->blue_balance); |
659 | return ret; | ||
660 | } | 637 | } |
661 | 638 | ||
662 | static int setgain(struct gspca_dev *gspca_dev) | 639 | static void setgain(struct gspca_dev *gspca_dev) |
663 | { | 640 | { |
664 | struct sd *sd = (struct sd *) gspca_dev; | 641 | struct sd *sd = (struct sd *) gspca_dev; |
665 | int ret; | ||
666 | 642 | ||
667 | ret = reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ | 643 | reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ |
668 | if (0 <= ret) | 644 | reg_w(gspca_dev, 0x10, sd->gain >> 3); |
669 | ret = reg_w(gspca_dev, 0x10, sd->gain >> 3); | ||
670 | 645 | ||
671 | /* load registers to sensor (Bit 0, auto clear) */ | 646 | /* load registers to sensor (Bit 0, auto clear) */ |
672 | if (0 <= ret) | 647 | reg_w(gspca_dev, 0x11, 0x01); |
673 | ret = reg_w(gspca_dev, 0x11, 0x01); | ||
674 | return ret; | ||
675 | } | 648 | } |
676 | 649 | ||
677 | static int setexposure(struct gspca_dev *gspca_dev) | 650 | static void setexposure(struct gspca_dev *gspca_dev) |
678 | { | 651 | { |
679 | struct sd *sd = (struct sd *) gspca_dev; | 652 | struct sd *sd = (struct sd *) gspca_dev; |
680 | int ret; | ||
681 | __u8 reg; | 653 | __u8 reg; |
682 | 654 | ||
683 | /* register 2 of frame 3/4 contains the clock divider configuring the | 655 | /* register 2 of frame 3/4 contains the clock divider configuring the |
@@ -693,20 +665,16 @@ static int setexposure(struct gspca_dev *gspca_dev) | |||
693 | the nearest multiple of 3, except when between 6 and 12? */ | 665 | the nearest multiple of 3, except when between 6 and 12? */ |
694 | if (reg < 6 || reg > 12) | 666 | if (reg < 6 || reg > 12) |
695 | reg = ((reg + 1) / 3) * 3; | 667 | reg = ((reg + 1) / 3) * 3; |
696 | ret = reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ | 668 | reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ |
697 | if (0 <= ret) | 669 | reg_w(gspca_dev, 0x02, reg); |
698 | ret = reg_w(gspca_dev, 0x02, reg); | ||
699 | 670 | ||
700 | /* load registers to sensor (Bit 0, auto clear) */ | 671 | /* load registers to sensor (Bit 0, auto clear) */ |
701 | if (0 <= ret) | 672 | reg_w(gspca_dev, 0x11, 0x01); |
702 | ret = reg_w(gspca_dev, 0x11, 0x01); | ||
703 | return ret; | ||
704 | } | 673 | } |
705 | 674 | ||
706 | static int sethvflip(struct gspca_dev *gspca_dev) | 675 | static void sethvflip(struct gspca_dev *gspca_dev) |
707 | { | 676 | { |
708 | struct sd *sd = (struct sd *) gspca_dev; | 677 | struct sd *sd = (struct sd *) gspca_dev; |
709 | int ret; | ||
710 | u8 data, hflip, vflip; | 678 | u8 data, hflip, vflip; |
711 | 679 | ||
712 | hflip = sd->hflip; | 680 | hflip = sd->hflip; |
@@ -716,47 +684,37 @@ static int sethvflip(struct gspca_dev *gspca_dev) | |||
716 | if (sd->flags & FL_VFLIP) | 684 | if (sd->flags & FL_VFLIP) |
717 | vflip = !vflip; | 685 | vflip = !vflip; |
718 | 686 | ||
719 | ret = reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ | 687 | reg_w(gspca_dev, 0xff, 0x03); /* page 3 */ |
720 | data = (hflip ? 0x08 : 0x00) | (vflip ? 0x04 : 0x00); | 688 | data = (hflip ? 0x08 : 0x00) | (vflip ? 0x04 : 0x00); |
721 | if (0 <= ret) | 689 | reg_w(gspca_dev, 0x21, data); |
722 | ret = reg_w(gspca_dev, 0x21, data); | 690 | |
723 | /* load registers to sensor (Bit 0, auto clear) */ | 691 | /* load registers to sensor (Bit 0, auto clear) */ |
724 | if (0 <= ret) | 692 | reg_w(gspca_dev, 0x11, 0x01); |
725 | ret = reg_w(gspca_dev, 0x11, 0x01); | ||
726 | return ret; | ||
727 | } | 693 | } |
728 | 694 | ||
729 | /* this function is called at probe and resume time for pac7302 */ | 695 | /* this function is called at probe and resume time for pac7302 */ |
730 | static int sd_init(struct gspca_dev *gspca_dev) | 696 | static int sd_init(struct gspca_dev *gspca_dev) |
731 | { | 697 | { |
732 | return reg_w_seq(gspca_dev, init_7302, sizeof(init_7302)/2); | 698 | reg_w_seq(gspca_dev, init_7302, sizeof(init_7302)/2); |
699 | return gspca_dev->usb_err; | ||
733 | } | 700 | } |
734 | 701 | ||
735 | static int sd_start(struct gspca_dev *gspca_dev) | 702 | static int sd_start(struct gspca_dev *gspca_dev) |
736 | { | 703 | { |
737 | struct sd *sd = (struct sd *) gspca_dev; | 704 | struct sd *sd = (struct sd *) gspca_dev; |
738 | int ret = 0; | ||
739 | 705 | ||
740 | sd->sof_read = 0; | 706 | sd->sof_read = 0; |
741 | 707 | ||
742 | ret = reg_w_var(gspca_dev, start_7302, | 708 | reg_w_var(gspca_dev, start_7302, |
743 | page3_7302, sizeof(page3_7302)); | 709 | page3_7302, sizeof(page3_7302)); |
744 | if (0 <= ret) | 710 | setbrightcont(gspca_dev); |
745 | ret = setbrightcont(gspca_dev); | 711 | setcolors(gspca_dev); |
746 | if (0 <= ret) | 712 | setwhitebalance(gspca_dev); |
747 | ret = setcolors(gspca_dev); | 713 | setredbalance(gspca_dev); |
748 | if (0 <= ret) | 714 | setbluebalance(gspca_dev); |
749 | ret = setwhitebalance(gspca_dev); | 715 | setgain(gspca_dev); |
750 | if (0 <= ret) | 716 | setexposure(gspca_dev); |
751 | ret = setredbalance(gspca_dev); | 717 | sethvflip(gspca_dev); |
752 | if (0 <= ret) | ||
753 | ret = setbluebalance(gspca_dev); | ||
754 | if (0 <= ret) | ||
755 | ret = setgain(gspca_dev); | ||
756 | if (0 <= ret) | ||
757 | ret = setexposure(gspca_dev); | ||
758 | if (0 <= ret) | ||
759 | ret = sethvflip(gspca_dev); | ||
760 | 718 | ||
761 | /* only resolution 640x480 is supported for pac7302 */ | 719 | /* only resolution 640x480 is supported for pac7302 */ |
762 | 720 | ||
@@ -765,34 +723,27 @@ static int sd_start(struct gspca_dev *gspca_dev) | |||
765 | atomic_set(&sd->avg_lum, -1); | 723 | atomic_set(&sd->avg_lum, -1); |
766 | 724 | ||
767 | /* start stream */ | 725 | /* start stream */ |
768 | if (0 <= ret) | 726 | reg_w(gspca_dev, 0xff, 0x01); |
769 | ret = reg_w(gspca_dev, 0xff, 0x01); | 727 | reg_w(gspca_dev, 0x78, 0x01); |
770 | if (0 <= ret) | ||
771 | ret = reg_w(gspca_dev, 0x78, 0x01); | ||
772 | 728 | ||
773 | return ret; | 729 | return gspca_dev->usb_err; |
774 | } | 730 | } |
775 | 731 | ||
776 | static void sd_stopN(struct gspca_dev *gspca_dev) | 732 | static void sd_stopN(struct gspca_dev *gspca_dev) |
777 | { | 733 | { |
778 | int ret; | ||
779 | 734 | ||
780 | /* stop stream */ | 735 | /* stop stream */ |
781 | ret = reg_w(gspca_dev, 0xff, 0x01); | 736 | reg_w(gspca_dev, 0xff, 0x01); |
782 | if (0 <= ret) | 737 | reg_w(gspca_dev, 0x78, 0x00); |
783 | ret = reg_w(gspca_dev, 0x78, 0x00); | ||
784 | } | 738 | } |
785 | 739 | ||
786 | /* called on streamoff with alt 0 and on disconnect for pac7302 */ | 740 | /* called on streamoff with alt 0 and on disconnect for pac7302 */ |
787 | static void sd_stop0(struct gspca_dev *gspca_dev) | 741 | static void sd_stop0(struct gspca_dev *gspca_dev) |
788 | { | 742 | { |
789 | int ret; | ||
790 | |||
791 | if (!gspca_dev->present) | 743 | if (!gspca_dev->present) |
792 | return; | 744 | return; |
793 | ret = reg_w(gspca_dev, 0xff, 0x01); | 745 | reg_w(gspca_dev, 0xff, 0x01); |
794 | if (0 <= ret) | 746 | reg_w(gspca_dev, 0x78, 0x40); |
795 | ret = reg_w(gspca_dev, 0x78, 0x40); | ||
796 | } | 747 | } |
797 | 748 | ||
798 | /* Include pac common sof detection functions */ | 749 | /* Include pac common sof detection functions */ |
@@ -941,7 +892,7 @@ static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | |||
941 | sd->brightness = val; | 892 | sd->brightness = val; |
942 | if (gspca_dev->streaming) | 893 | if (gspca_dev->streaming) |
943 | setbrightcont(gspca_dev); | 894 | setbrightcont(gspca_dev); |
944 | return 0; | 895 | return gspca_dev->usb_err; |
945 | } | 896 | } |
946 | 897 | ||
947 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) | 898 | static int sd_getbrightness(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -960,7 +911,7 @@ static int sd_setcontrast(struct gspca_dev *gspca_dev, __s32 val) | |||
960 | if (gspca_dev->streaming) { | 911 | if (gspca_dev->streaming) { |
961 | setbrightcont(gspca_dev); | 912 | setbrightcont(gspca_dev); |
962 | } | 913 | } |
963 | return 0; | 914 | return gspca_dev->usb_err; |
964 | } | 915 | } |
965 | 916 | ||
966 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) | 917 | static int sd_getcontrast(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -978,7 +929,7 @@ static int sd_setcolors(struct gspca_dev *gspca_dev, __s32 val) | |||
978 | sd->colors = val; | 929 | sd->colors = val; |
979 | if (gspca_dev->streaming) | 930 | if (gspca_dev->streaming) |
980 | setcolors(gspca_dev); | 931 | setcolors(gspca_dev); |
981 | return 0; | 932 | return gspca_dev->usb_err; |
982 | } | 933 | } |
983 | 934 | ||
984 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) | 935 | static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -992,14 +943,11 @@ static int sd_getcolors(struct gspca_dev *gspca_dev, __s32 *val) | |||
992 | static int sd_setwhitebalance(struct gspca_dev *gspca_dev, __s32 val) | 943 | static int sd_setwhitebalance(struct gspca_dev *gspca_dev, __s32 val) |
993 | { | 944 | { |
994 | struct sd *sd = (struct sd *) gspca_dev; | 945 | struct sd *sd = (struct sd *) gspca_dev; |
995 | int ret = 0; | ||
996 | 946 | ||
997 | sd->white_balance = val; | 947 | sd->white_balance = val; |
998 | if (gspca_dev->streaming) | 948 | if (gspca_dev->streaming) |
999 | ret = setwhitebalance(gspca_dev); | 949 | setwhitebalance(gspca_dev); |
1000 | if (0 <= ret) | 950 | return gspca_dev->usb_err; |
1001 | ret = 0; | ||
1002 | return ret; | ||
1003 | } | 951 | } |
1004 | 952 | ||
1005 | static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val) | 953 | static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -1013,14 +961,11 @@ static int sd_getwhitebalance(struct gspca_dev *gspca_dev, __s32 *val) | |||
1013 | static int sd_setredbalance(struct gspca_dev *gspca_dev, __s32 val) | 961 | static int sd_setredbalance(struct gspca_dev *gspca_dev, __s32 val) |
1014 | { | 962 | { |
1015 | struct sd *sd = (struct sd *) gspca_dev; | 963 | struct sd *sd = (struct sd *) gspca_dev; |
1016 | int ret = 0; | ||
1017 | 964 | ||
1018 | sd->red_balance = val; | 965 | sd->red_balance = val; |
1019 | if (gspca_dev->streaming) | 966 | if (gspca_dev->streaming) |
1020 | ret = setredbalance(gspca_dev); | 967 | setredbalance(gspca_dev); |
1021 | if (0 <= ret) | 968 | return gspca_dev->usb_err; |
1022 | ret = 0; | ||
1023 | return ret; | ||
1024 | } | 969 | } |
1025 | 970 | ||
1026 | static int sd_getredbalance(struct gspca_dev *gspca_dev, __s32 *val) | 971 | static int sd_getredbalance(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -1034,14 +979,11 @@ static int sd_getredbalance(struct gspca_dev *gspca_dev, __s32 *val) | |||
1034 | static int sd_setbluebalance(struct gspca_dev *gspca_dev, __s32 val) | 979 | static int sd_setbluebalance(struct gspca_dev *gspca_dev, __s32 val) |
1035 | { | 980 | { |
1036 | struct sd *sd = (struct sd *) gspca_dev; | 981 | struct sd *sd = (struct sd *) gspca_dev; |
1037 | int ret = 0; | ||
1038 | 982 | ||
1039 | sd->blue_balance = val; | 983 | sd->blue_balance = val; |
1040 | if (gspca_dev->streaming) | 984 | if (gspca_dev->streaming) |
1041 | ret = setbluebalance(gspca_dev); | 985 | setbluebalance(gspca_dev); |
1042 | if (0 <= ret) | 986 | return gspca_dev->usb_err; |
1043 | ret = 0; | ||
1044 | return ret; | ||
1045 | } | 987 | } |
1046 | 988 | ||
1047 | static int sd_getbluebalance(struct gspca_dev *gspca_dev, __s32 *val) | 989 | static int sd_getbluebalance(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -1059,7 +1001,7 @@ static int sd_setgain(struct gspca_dev *gspca_dev, __s32 val) | |||
1059 | sd->gain = val; | 1001 | sd->gain = val; |
1060 | if (gspca_dev->streaming) | 1002 | if (gspca_dev->streaming) |
1061 | setgain(gspca_dev); | 1003 | setgain(gspca_dev); |
1062 | return 0; | 1004 | return gspca_dev->usb_err; |
1063 | } | 1005 | } |
1064 | 1006 | ||
1065 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val) | 1007 | static int sd_getgain(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -1077,7 +1019,7 @@ static int sd_setexposure(struct gspca_dev *gspca_dev, __s32 val) | |||
1077 | sd->exposure = val; | 1019 | sd->exposure = val; |
1078 | if (gspca_dev->streaming) | 1020 | if (gspca_dev->streaming) |
1079 | setexposure(gspca_dev); | 1021 | setexposure(gspca_dev); |
1080 | return 0; | 1022 | return gspca_dev->usb_err; |
1081 | } | 1023 | } |
1082 | 1024 | ||
1083 | static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val) | 1025 | static int sd_getexposure(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -1108,7 +1050,7 @@ static int sd_setautogain(struct gspca_dev *gspca_dev, __s32 val) | |||
1108 | } | 1050 | } |
1109 | } | 1051 | } |
1110 | 1052 | ||
1111 | return 0; | 1053 | return gspca_dev->usb_err; |
1112 | } | 1054 | } |
1113 | 1055 | ||
1114 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) | 1056 | static int sd_getautogain(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -1126,7 +1068,7 @@ static int sd_sethflip(struct gspca_dev *gspca_dev, __s32 val) | |||
1126 | sd->hflip = val; | 1068 | sd->hflip = val; |
1127 | if (gspca_dev->streaming) | 1069 | if (gspca_dev->streaming) |
1128 | sethvflip(gspca_dev); | 1070 | sethvflip(gspca_dev); |
1129 | return 0; | 1071 | return gspca_dev->usb_err; |
1130 | } | 1072 | } |
1131 | 1073 | ||
1132 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val) | 1074 | static int sd_gethflip(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -1144,7 +1086,7 @@ static int sd_setvflip(struct gspca_dev *gspca_dev, __s32 val) | |||
1144 | sd->vflip = val; | 1086 | sd->vflip = val; |
1145 | if (gspca_dev->streaming) | 1087 | if (gspca_dev->streaming) |
1146 | sethvflip(gspca_dev); | 1088 | sethvflip(gspca_dev); |
1147 | return 0; | 1089 | return gspca_dev->usb_err; |
1148 | } | 1090 | } |
1149 | 1091 | ||
1150 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val) | 1092 | static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val) |
@@ -1159,7 +1101,6 @@ static int sd_getvflip(struct gspca_dev *gspca_dev, __s32 *val) | |||
1159 | static int sd_dbg_s_register(struct gspca_dev *gspca_dev, | 1101 | static int sd_dbg_s_register(struct gspca_dev *gspca_dev, |
1160 | struct v4l2_dbg_register *reg) | 1102 | struct v4l2_dbg_register *reg) |
1161 | { | 1103 | { |
1162 | int ret = -EINVAL; | ||
1163 | __u8 index; | 1104 | __u8 index; |
1164 | __u8 value; | 1105 | __u8 value; |
1165 | 1106 | ||
@@ -1179,14 +1120,12 @@ static int sd_dbg_s_register(struct gspca_dev *gspca_dev, | |||
1179 | /* Note that there shall be no access to other page | 1120 | /* Note that there shall be no access to other page |
1180 | by any other function between the page swith and | 1121 | by any other function between the page swith and |
1181 | the actual register write */ | 1122 | the actual register write */ |
1182 | ret = reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ | 1123 | reg_w(gspca_dev, 0xff, 0x00); /* page 0 */ |
1183 | if (0 <= ret) | 1124 | reg_w(gspca_dev, index, value); |
1184 | ret = reg_w(gspca_dev, index, value); | ||
1185 | 1125 | ||
1186 | if (0 <= ret) | 1126 | reg_w(gspca_dev, 0xdc, 0x01); |
1187 | ret = reg_w(gspca_dev, 0xdc, 0x01); | ||
1188 | } | 1127 | } |
1189 | return ret; | 1128 | return gspca_dev->usb_err; |
1190 | } | 1129 | } |
1191 | 1130 | ||
1192 | static int sd_chip_ident(struct gspca_dev *gspca_dev, | 1131 | static int sd_chip_ident(struct gspca_dev *gspca_dev, |