diff options
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/gspca/pac7311.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/media/video/gspca/pac7311.c b/drivers/media/video/gspca/pac7311.c index 034c00d6c0ab..730b4a1aed9e 100644 --- a/drivers/media/video/gspca/pac7311.c +++ b/drivers/media/video/gspca/pac7311.c | |||
@@ -702,8 +702,16 @@ static void do_autogain(struct gspca_dev *gspca_dev) | |||
702 | static void put_jpeg_head(struct gspca_dev *gspca_dev, | 702 | static void put_jpeg_head(struct gspca_dev *gspca_dev, |
703 | struct gspca_frame *frame) | 703 | struct gspca_frame *frame) |
704 | { | 704 | { |
705 | struct sd *sd = (struct sd *) gspca_dev; | ||
705 | unsigned char tmpbuf[4]; | 706 | unsigned char tmpbuf[4]; |
706 | 707 | ||
708 | if (sd->ag_cnt >= 0) { | ||
709 | if (--sd->ag_cnt < 0) { | ||
710 | sd->ag_cnt = AG_CNT_START; | ||
711 | atomic_set(&sd->avg_lum, sd->lum_sum / AG_CNT_START); | ||
712 | atomic_set(&sd->do_gain, 1); | ||
713 | } | ||
714 | } | ||
707 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, | 715 | gspca_frame_add(gspca_dev, FIRST_PACKET, frame, |
708 | (__u8 *) pac7311_jpeg_header, | 716 | (__u8 *) pac7311_jpeg_header, |
709 | 12); | 717 | 12); |
@@ -727,7 +735,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
727 | struct sd *sd = (struct sd *) gspca_dev; | 735 | struct sd *sd = (struct sd *) gspca_dev; |
728 | int i; | 736 | int i; |
729 | 737 | ||
730 | #define INTER_FRAME 0x53 | 738 | #define INTER_FRAME 0x53 /* eof + inter frame + sof */ |
731 | #define LUM_OFFSET 0x1e /* reverse offset / start of frame */ | 739 | #define LUM_OFFSET 0x1e /* reverse offset / start of frame */ |
732 | 740 | ||
733 | /* | 741 | /* |
@@ -746,11 +754,18 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
746 | if (sd->tosof == 0) { /* if inside a frame */ | 754 | if (sd->tosof == 0) { /* if inside a frame */ |
747 | 755 | ||
748 | /* check for 'ff ff ff xx' at start and at end of packet */ | 756 | /* check for 'ff ff ff xx' at start and at end of packet */ |
749 | /* (len is always >= 3) */ | 757 | /* (len is always >= 3 and xx never ff) */ |
750 | switch (sd->ffnb) { | 758 | switch (sd->ffnb) { |
751 | case 1: | 759 | case 1: |
752 | if (data[0] != 0xff) | 760 | if (data[0] != 0xff) { /* can be '00' only */ |
761 | __u8 ff; | ||
762 | |||
763 | sd->ffnb = 0; | ||
764 | ff = 0xff; | ||
765 | gspca_frame_add(gspca_dev, INTER_PACKET, | ||
766 | frame, &ff, 1); | ||
753 | break; /* keep 'ff 00' */ | 767 | break; /* keep 'ff 00' */ |
768 | } | ||
754 | /* fall thru */ | 769 | /* fall thru */ |
755 | case 2: | 770 | case 2: |
756 | case 3: | 771 | case 3: |
@@ -775,16 +790,13 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
775 | } | 790 | } |
776 | } else { /* outside a frame */ | 791 | } else { /* outside a frame */ |
777 | 792 | ||
778 | /* | 793 | /* get the luminosity and go to the start of frame */ |
779 | * get the luminosity | ||
780 | * and go to the start of frame | ||
781 | */ | ||
782 | data += sd->tosof; | 794 | data += sd->tosof; |
783 | len -= sd->tosof; | 795 | len -= sd->tosof; |
784 | if (sd->tosof > LUM_OFFSET) | 796 | if (sd->tosof > LUM_OFFSET) |
785 | sd->lum_sum += data[-LUM_OFFSET]; | 797 | sd->lum_sum += data[-LUM_OFFSET]; |
786 | put_jpeg_head(gspca_dev, frame); | ||
787 | sd->tosof = 0; | 798 | sd->tosof = 0; |
799 | put_jpeg_head(gspca_dev, frame); | ||
788 | } | 800 | } |
789 | 801 | ||
790 | for (i = 0; i < len; i++) { | 802 | for (i = 0; i < len; i++) { |
@@ -792,10 +804,9 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
792 | continue; | 804 | continue; |
793 | switch (data[i + 1]) { | 805 | switch (data[i + 1]) { |
794 | case 0xd9: /* end of frame */ | 806 | case 0xd9: /* end of frame */ |
795 | i += 2; | ||
796 | frame = gspca_frame_add(gspca_dev, | 807 | frame = gspca_frame_add(gspca_dev, |
797 | LAST_PACKET, | 808 | LAST_PACKET, |
798 | frame, data, i); | 809 | frame, data, i + 2); |
799 | data += i + INTER_FRAME; | 810 | data += i + INTER_FRAME; |
800 | len -= i + INTER_FRAME; | 811 | len -= i + INTER_FRAME; |
801 | i = 0; | 812 | i = 0; |
@@ -816,6 +827,8 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev, | |||
816 | break; | 827 | break; |
817 | } | 828 | } |
818 | } | 829 | } |
830 | gspca_frame_add(gspca_dev, INTER_PACKET, | ||
831 | frame, data, i); | ||
819 | } | 832 | } |
820 | 833 | ||
821 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 834 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |