diff options
428 files changed, 25132 insertions, 7388 deletions
diff --git a/Documentation/video4linux/CARDLIST.au0828 b/Documentation/video4linux/CARDLIST.au0828 new file mode 100644 index 000000000000..aaae360312e4 --- /dev/null +++ b/Documentation/video4linux/CARDLIST.au0828 | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | 0 -> Unknown board (au0828) | ||
| 2 | 1 -> Hauppauge HVR950Q (au0828) [2040:7200] | ||
| 3 | 2 -> Hauppauge HVR850 (au0828) [2040:7240] | ||
| 4 | 3 -> DViCO FusionHDTV USB (au0828) [0fe9:d620] | ||
diff --git a/Documentation/video4linux/CARDLIST.bttv b/Documentation/video4linux/CARDLIST.bttv index d97cf7cc6088..f32efb6fb12c 100644 --- a/Documentation/video4linux/CARDLIST.bttv +++ b/Documentation/video4linux/CARDLIST.bttv | |||
| @@ -148,3 +148,5 @@ | |||
| 148 | 147 -> VoodooTV 200 (USA) [121a:3000] | 148 | 147 -> VoodooTV 200 (USA) [121a:3000] |
| 149 | 148 -> DViCO FusionHDTV 2 [dbc0:d200] | 149 | 148 -> DViCO FusionHDTV 2 [dbc0:d200] |
| 150 | 149 -> Typhoon TV-Tuner PCI (50684) | 150 | 149 -> Typhoon TV-Tuner PCI (50684) |
| 151 | 150 -> Geovision GV-600 [008a:763c] | ||
| 152 | 151 -> Kozumi KTV-01C | ||
diff --git a/Documentation/video4linux/CARDLIST.cx23885 b/Documentation/video4linux/CARDLIST.cx23885 index 0924e6e142c4..929b90c8387f 100644 --- a/Documentation/video4linux/CARDLIST.cx23885 +++ b/Documentation/video4linux/CARDLIST.cx23885 | |||
| @@ -5,3 +5,6 @@ | |||
| 5 | 4 -> DViCO FusionHDTV5 Express [18ac:d500] | 5 | 4 -> DViCO FusionHDTV5 Express [18ac:d500] |
| 6 | 5 -> Hauppauge WinTV-HVR1500Q [0070:7790,0070:7797] | 6 | 5 -> Hauppauge WinTV-HVR1500Q [0070:7790,0070:7797] |
| 7 | 6 -> Hauppauge WinTV-HVR1500 [0070:7710,0070:7717] | 7 | 6 -> Hauppauge WinTV-HVR1500 [0070:7710,0070:7717] |
| 8 | 7 -> Hauppauge WinTV-HVR1200 [0070:71d1] | ||
| 9 | 8 -> Hauppauge WinTV-HVR1700 [0070:8101] | ||
| 10 | 9 -> Hauppauge WinTV-HVR1400 [0070:8010] | ||
diff --git a/Documentation/video4linux/CARDLIST.cx88 b/Documentation/video4linux/CARDLIST.cx88 index bc5593bd9704..543957346469 100644 --- a/Documentation/video4linux/CARDLIST.cx88 +++ b/Documentation/video4linux/CARDLIST.cx88 | |||
| @@ -57,3 +57,12 @@ | |||
| 57 | 56 -> Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder [0070:9600,0070:9601,0070:9602] | 57 | 56 -> Hauppauge WinTV-HVR1300 DVB-T/Hybrid MPEG Encoder [0070:9600,0070:9601,0070:9602] |
| 58 | 57 -> ADS Tech Instant Video PCI [1421:0390] | 58 | 57 -> ADS Tech Instant Video PCI [1421:0390] |
| 59 | 58 -> Pinnacle PCTV HD 800i [11bd:0051] | 59 | 58 -> Pinnacle PCTV HD 800i [11bd:0051] |
| 60 | 59 -> DViCO FusionHDTV 5 PCI nano [18ac:d530] | ||
| 61 | 60 -> Pinnacle Hybrid PCTV [12ab:1788] | ||
| 62 | 61 -> Winfast TV2000 XP Global [107d:6f18] | ||
| 63 | 62 -> PowerColor Real Angel 330 [14f1:ea3d] | ||
| 64 | 63 -> Geniatech X8000-MT DVBT [14f1:8852] | ||
| 65 | 64 -> DViCO FusionHDTV DVB-T PRO [18ac:db30] | ||
| 66 | 65 -> DViCO FusionHDTV 7 Gold [18ac:d610] | ||
| 67 | 66 -> Prolink Pixelview MPEG 8000GT [1554:4935] | ||
| 68 | 67 -> Kworld PlusTV HD PCI 120 (ATSC 120) [17de:08c1] | ||
diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134 index 0424901ebc78..44d84dd15ad6 100644 --- a/Documentation/video4linux/CARDLIST.saa7134 +++ b/Documentation/video4linux/CARDLIST.saa7134 | |||
| @@ -25,8 +25,8 @@ | |||
| 25 | 24 -> KNC One TV-Station DVR [1894:a006] | 25 | 24 -> KNC One TV-Station DVR [1894:a006] |
| 26 | 25 -> ASUS TV-FM 7133 [1043:4843] | 26 | 25 -> ASUS TV-FM 7133 [1043:4843] |
| 27 | 26 -> Pinnacle PCTV Stereo (saa7134) [11bd:002b] | 27 | 26 -> Pinnacle PCTV Stereo (saa7134) [11bd:002b] |
| 28 | 27 -> Manli MuchTV M-TV002/Behold TV 403 FM | 28 | 27 -> Manli MuchTV M-TV002 |
| 29 | 28 -> Manli MuchTV M-TV001/Behold TV 401 | 29 | 28 -> Manli MuchTV M-TV001 |
| 30 | 29 -> Nagase Sangyo TransGear 3000TV [1461:050c] | 30 | 29 -> Nagase Sangyo TransGear 3000TV [1461:050c] |
| 31 | 30 -> Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM) [1019:4cb4] | 31 | 30 -> Elitegroup ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM) [1019:4cb4] |
| 32 | 31 -> Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM) [1019:4cb5] | 32 | 31 -> Elitegroup ECS TVP3XP FM1236 Tuner Card (NTSC,FM) [1019:4cb5] |
| @@ -131,3 +131,12 @@ | |||
| 131 | 130 -> Beholder BeholdTV M6 / BeholdTV M6 Extra [5ace:6190,5ace:6193] | 131 | 130 -> Beholder BeholdTV M6 / BeholdTV M6 Extra [5ace:6190,5ace:6193] |
| 132 | 131 -> Twinhan Hybrid DTV-DVB 3056 PCI [1822:0022] | 132 | 131 -> Twinhan Hybrid DTV-DVB 3056 PCI [1822:0022] |
| 133 | 132 -> Genius TVGO AM11MCE | 133 | 132 -> Genius TVGO AM11MCE |
| 134 | 133 -> NXP Snake DVB-S reference design | ||
| 135 | 134 -> Medion/Creatix CTX953 Hybrid [16be:0010] | ||
| 136 | 135 -> MSI TV@nywhere A/D v1.1 [1462:8625] | ||
| 137 | 136 -> AVerMedia Cardbus TV/Radio (E506R) [1461:f436] | ||
| 138 | 137 -> AVerMedia Hybrid TV/Radio (A16D) [1461:f936] | ||
| 139 | 138 -> Avermedia M115 [1461:a836] | ||
| 140 | 139 -> Compro VideoMate T750 [185b:c900] | ||
| 141 | 140 -> Avermedia DVB-S Pro A700 [1461:a7a1] | ||
| 142 | 141 -> Avermedia DVB-S Hybrid+FM A700 [1461:a7a2] | ||
diff --git a/Documentation/video4linux/extract_xc3028.pl b/Documentation/video4linux/extract_xc3028.pl index cced8ac5c543..2cb816047fc1 100644 --- a/Documentation/video4linux/extract_xc3028.pl +++ b/Documentation/video4linux/extract_xc3028.pl | |||
| @@ -686,11 +686,11 @@ sub main_firmware($$$$) | |||
| 686 | write_hunk(812664, 192); | 686 | write_hunk(812664, 192); |
| 687 | 687 | ||
| 688 | # | 688 | # |
| 689 | # Firmware 58, type: SCODE FW HAS IF (0x60000000), IF = 4.50 MHz id: NTSC/M Jp (0000000000002000), size: 192 | 689 | # Firmware 58, type: SCODE FW MTS LCD NOGD MONO IF HAS IF (0x6002b004), IF = 4.50 MHz id: NTSC PAL/M PAL/N (000000000000b700), size: 192 |
| 690 | # | 690 | # |
| 691 | 691 | ||
| 692 | write_le32(0x60000000); # Type | 692 | write_le32(0x6002b004); # Type |
| 693 | write_le64(0x00000000, 0x00002000); # ID | 693 | write_le64(0x00000000, 0x0000b700); # ID |
| 694 | write_le16(4500); # IF | 694 | write_le16(4500); # IF |
| 695 | write_le32(192); # Size | 695 | write_le32(192); # Size |
| 696 | write_hunk(807672, 192); | 696 | write_hunk(807672, 192); |
| @@ -706,10 +706,10 @@ sub main_firmware($$$$) | |||
| 706 | write_hunk(807864, 192); | 706 | write_hunk(807864, 192); |
| 707 | 707 | ||
| 708 | # | 708 | # |
| 709 | # Firmware 60, type: SCODE FW DTV78 ZARLINK456 HAS IF (0x62000100), IF = 4.76 MHz id: (0000000000000000), size: 192 | 709 | # Firmware 60, type: SCODE FW DTV6 QAM DTV7 DTV78 DTV8 ZARLINK456 HAS IF (0x620003e0), IF = 4.76 MHz id: (0000000000000000), size: 192 |
| 710 | # | 710 | # |
| 711 | 711 | ||
| 712 | write_le32(0x62000100); # Type | 712 | write_le32(0x620003e0); # Type |
| 713 | write_le64(0x00000000, 0x00000000); # ID | 713 | write_le64(0x00000000, 0x00000000); # ID |
| 714 | write_le16(4760); # IF | 714 | write_le16(4760); # IF |
| 715 | write_le32(192); # Size | 715 | write_le32(192); # Size |
| @@ -726,30 +726,30 @@ sub main_firmware($$$$) | |||
| 726 | write_hunk(811512, 192); | 726 | write_hunk(811512, 192); |
| 727 | 727 | ||
| 728 | # | 728 | # |
| 729 | # Firmware 62, type: SCODE FW DTV7 ZARLINK456 HAS IF (0x62000080), IF = 5.26 MHz id: (0000000000000000), size: 192 | 729 | # Firmware 62, type: SCODE FW HAS IF (0x60000000), IF = 5.26 MHz id: (0000000000000000), size: 192 |
| 730 | # | 730 | # |
| 731 | 731 | ||
| 732 | write_le32(0x62000080); # Type | 732 | write_le32(0x60000000); # Type |
| 733 | write_le64(0x00000000, 0x00000000); # ID | 733 | write_le64(0x00000000, 0x00000000); # ID |
| 734 | write_le16(5260); # IF | 734 | write_le16(5260); # IF |
| 735 | write_le32(192); # Size | 735 | write_le32(192); # Size |
| 736 | write_hunk(810552, 192); | 736 | write_hunk(810552, 192); |
| 737 | 737 | ||
| 738 | # | 738 | # |
| 739 | # Firmware 63, type: SCODE FW MONO HAS IF (0x60008000), IF = 5.32 MHz id: PAL/BG NICAM/B (0000000800000007), size: 192 | 739 | # Firmware 63, type: SCODE FW MONO HAS IF (0x60008000), IF = 5.32 MHz id: PAL/BG A2 NICAM (0000000f00000007), size: 192 |
| 740 | # | 740 | # |
| 741 | 741 | ||
| 742 | write_le32(0x60008000); # Type | 742 | write_le32(0x60008000); # Type |
| 743 | write_le64(0x00000008, 0x00000007); # ID | 743 | write_le64(0x0000000f, 0x00000007); # ID |
| 744 | write_le16(5320); # IF | 744 | write_le16(5320); # IF |
| 745 | write_le32(192); # Size | 745 | write_le32(192); # Size |
| 746 | write_hunk(810744, 192); | 746 | write_hunk(810744, 192); |
| 747 | 747 | ||
| 748 | # | 748 | # |
| 749 | # Firmware 64, type: SCODE FW DTV8 CHINA HAS IF (0x64000200), IF = 5.40 MHz id: (0000000000000000), size: 192 | 749 | # Firmware 64, type: SCODE FW DTV7 DTV78 DTV8 DIBCOM52 CHINA HAS IF (0x65000380), IF = 5.40 MHz id: (0000000000000000), size: 192 |
| 750 | # | 750 | # |
| 751 | 751 | ||
| 752 | write_le32(0x64000200); # Type | 752 | write_le32(0x65000380); # Type |
| 753 | write_le64(0x00000000, 0x00000000); # ID | 753 | write_le64(0x00000000, 0x00000000); # ID |
| 754 | write_le16(5400); # IF | 754 | write_le16(5400); # IF |
| 755 | write_le32(192); # Size | 755 | write_le32(192); # Size |
| @@ -766,50 +766,50 @@ sub main_firmware($$$$) | |||
| 766 | write_hunk(809592, 192); | 766 | write_hunk(809592, 192); |
| 767 | 767 | ||
| 768 | # | 768 | # |
| 769 | # Firmware 66, type: SCODE FW HAS IF (0x60000000), IF = 5.64 MHz id: PAL/BG A2/B (0000000200000007), size: 192 | 769 | # Firmware 66, type: SCODE FW HAS IF (0x60000000), IF = 5.64 MHz id: PAL/BG A2 (0000000300000007), size: 192 |
| 770 | # | 770 | # |
| 771 | 771 | ||
| 772 | write_le32(0x60000000); # Type | 772 | write_le32(0x60000000); # Type |
| 773 | write_le64(0x00000002, 0x00000007); # ID | 773 | write_le64(0x00000003, 0x00000007); # ID |
| 774 | write_le16(5640); # IF | 774 | write_le16(5640); # IF |
| 775 | write_le32(192); # Size | 775 | write_le32(192); # Size |
| 776 | write_hunk(808440, 192); | 776 | write_hunk(808440, 192); |
| 777 | 777 | ||
| 778 | # | 778 | # |
| 779 | # Firmware 67, type: SCODE FW HAS IF (0x60000000), IF = 5.74 MHz id: PAL/BG NICAM/B (0000000800000007), size: 192 | 779 | # Firmware 67, type: SCODE FW HAS IF (0x60000000), IF = 5.74 MHz id: PAL/BG NICAM (0000000c00000007), size: 192 |
| 780 | # | 780 | # |
| 781 | 781 | ||
| 782 | write_le32(0x60000000); # Type | 782 | write_le32(0x60000000); # Type |
| 783 | write_le64(0x00000008, 0x00000007); # ID | 783 | write_le64(0x0000000c, 0x00000007); # ID |
| 784 | write_le16(5740); # IF | 784 | write_le16(5740); # IF |
| 785 | write_le32(192); # Size | 785 | write_le32(192); # Size |
| 786 | write_hunk(808632, 192); | 786 | write_hunk(808632, 192); |
| 787 | 787 | ||
| 788 | # | 788 | # |
| 789 | # Firmware 68, type: SCODE FW DTV7 DIBCOM52 HAS IF (0x61000080), IF = 5.90 MHz id: (0000000000000000), size: 192 | 789 | # Firmware 68, type: SCODE FW HAS IF (0x60000000), IF = 5.90 MHz id: (0000000000000000), size: 192 |
| 790 | # | 790 | # |
| 791 | 791 | ||
| 792 | write_le32(0x61000080); # Type | 792 | write_le32(0x60000000); # Type |
| 793 | write_le64(0x00000000, 0x00000000); # ID | 793 | write_le64(0x00000000, 0x00000000); # ID |
| 794 | write_le16(5900); # IF | 794 | write_le16(5900); # IF |
| 795 | write_le32(192); # Size | 795 | write_le32(192); # Size |
| 796 | write_hunk(810360, 192); | 796 | write_hunk(810360, 192); |
| 797 | 797 | ||
| 798 | # | 798 | # |
| 799 | # Firmware 69, type: SCODE FW MONO HAS IF (0x60008000), IF = 6.00 MHz id: PAL/I (0000000000000010), size: 192 | 799 | # Firmware 69, type: SCODE FW MONO HAS IF (0x60008000), IF = 6.00 MHz id: PAL/DK PAL/I SECAM/K3 SECAM/L SECAM/Lc NICAM (0000000c04c000f0), size: 192 |
| 800 | # | 800 | # |
| 801 | 801 | ||
| 802 | write_le32(0x60008000); # Type | 802 | write_le32(0x60008000); # Type |
| 803 | write_le64(0x00000000, 0x00000010); # ID | 803 | write_le64(0x0000000c, 0x04c000f0); # ID |
| 804 | write_le16(6000); # IF | 804 | write_le16(6000); # IF |
| 805 | write_le32(192); # Size | 805 | write_le32(192); # Size |
| 806 | write_hunk(808824, 192); | 806 | write_hunk(808824, 192); |
| 807 | 807 | ||
| 808 | # | 808 | # |
| 809 | # Firmware 70, type: SCODE FW DTV6 QAM F6MHZ HAS IF (0x68000060), IF = 6.20 MHz id: (0000000000000000), size: 192 | 809 | # Firmware 70, type: SCODE FW DTV6 QAM ATSC LG60 F6MHZ HAS IF (0x68050060), IF = 6.20 MHz id: (0000000000000000), size: 192 |
| 810 | # | 810 | # |
| 811 | 811 | ||
| 812 | write_le32(0x68000060); # Type | 812 | write_le32(0x68050060); # Type |
| 813 | write_le64(0x00000000, 0x00000000); # ID | 813 | write_le64(0x00000000, 0x00000000); # ID |
| 814 | write_le16(6200); # IF | 814 | write_le16(6200); # IF |
| 815 | write_le32(192); # Size | 815 | write_le32(192); # Size |
| @@ -846,11 +846,11 @@ sub main_firmware($$$$) | |||
| 846 | write_hunk(809208, 192); | 846 | write_hunk(809208, 192); |
| 847 | 847 | ||
| 848 | # | 848 | # |
| 849 | # Firmware 74, type: SCODE FW MONO HAS IF (0x60008000), IF = 6.50 MHz id: SECAM/K3 (0000000004000000), size: 192 | 849 | # Firmware 74, type: SCODE FW MONO HAS IF (0x60008000), IF = 6.50 MHz id: PAL/DK SECAM/K3 SECAM/L NICAM (0000000c044000e0), size: 192 |
| 850 | # | 850 | # |
| 851 | 851 | ||
| 852 | write_le32(0x60008000); # Type | 852 | write_le32(0x60008000); # Type |
| 853 | write_le64(0x00000000, 0x04000000); # ID | 853 | write_le64(0x0000000c, 0x044000e0); # ID |
| 854 | write_le16(6500); # IF | 854 | write_le16(6500); # IF |
| 855 | write_le32(192); # Size | 855 | write_le32(192); # Size |
| 856 | write_hunk(811128, 192); | 856 | write_hunk(811128, 192); |
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig index 11950698a2e7..128bb9cd5755 100644 --- a/drivers/media/Kconfig +++ b/drivers/media/Kconfig | |||
| @@ -30,7 +30,7 @@ config VIDEO_V4L2_COMMON | |||
| 30 | depends on (I2C || I2C=n) && VIDEO_DEV | 30 | depends on (I2C || I2C=n) && VIDEO_DEV |
| 31 | default (I2C || I2C=n) && VIDEO_DEV | 31 | default (I2C || I2C=n) && VIDEO_DEV |
| 32 | 32 | ||
| 33 | config VIDEO_V4L1 | 33 | config VIDEO_ALLOW_V4L1 |
| 34 | bool "Enable Video For Linux API 1 (DEPRECATED)" | 34 | bool "Enable Video For Linux API 1 (DEPRECATED)" |
| 35 | depends on VIDEO_DEV && VIDEO_V4L2_COMMON | 35 | depends on VIDEO_DEV && VIDEO_V4L2_COMMON |
| 36 | default VIDEO_DEV && VIDEO_V4L2_COMMON | 36 | default VIDEO_DEV && VIDEO_V4L2_COMMON |
| @@ -59,10 +59,15 @@ config VIDEO_V4L1_COMPAT | |||
| 59 | If you are unsure as to whether this is required, answer Y. | 59 | If you are unsure as to whether this is required, answer Y. |
| 60 | 60 | ||
| 61 | config VIDEO_V4L2 | 61 | config VIDEO_V4L2 |
| 62 | bool | 62 | tristate |
| 63 | depends on VIDEO_DEV && VIDEO_V4L2_COMMON | 63 | depends on VIDEO_DEV && VIDEO_V4L2_COMMON |
| 64 | default VIDEO_DEV && VIDEO_V4L2_COMMON | 64 | default VIDEO_DEV && VIDEO_V4L2_COMMON |
| 65 | 65 | ||
| 66 | config VIDEO_V4L1 | ||
| 67 | tristate | ||
| 68 | depends on VIDEO_DEV && VIDEO_V4L2_COMMON && VIDEO_ALLOW_V4L1 | ||
| 69 | default VIDEO_DEV && VIDEO_V4L2_COMMON && VIDEO_ALLOW_V4L1 | ||
| 70 | |||
| 66 | source "drivers/media/video/Kconfig" | 71 | source "drivers/media/video/Kconfig" |
| 67 | 72 | ||
| 68 | source "drivers/media/radio/Kconfig" | 73 | source "drivers/media/radio/Kconfig" |
| @@ -155,7 +160,7 @@ config VIDEOBUF_GEN | |||
| 155 | tristate | 160 | tristate |
| 156 | 161 | ||
| 157 | config VIDEOBUF_DMA_SG | 162 | config VIDEOBUF_DMA_SG |
| 158 | depends on PCI | 163 | depends on HAS_DMA |
| 159 | select VIDEOBUF_GEN | 164 | select VIDEOBUF_GEN |
| 160 | tristate | 165 | tristate |
| 161 | 166 | ||
diff --git a/drivers/media/common/ir-functions.c b/drivers/media/common/ir-functions.c index bb2a027b9483..266505207925 100644 --- a/drivers/media/common/ir-functions.c +++ b/drivers/media/common/ir-functions.c | |||
| @@ -34,7 +34,7 @@ static int repeat = 1; | |||
| 34 | module_param(repeat, int, 0444); | 34 | module_param(repeat, int, 0444); |
| 35 | MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)"); | 35 | MODULE_PARM_DESC(repeat,"auto-repeat for IR keys (default: on)"); |
| 36 | 36 | ||
| 37 | static int debug = 0; /* debug level (0,1,2) */ | 37 | static int debug; /* debug level (0,1,2) */ |
| 38 | module_param(debug, int, 0644); | 38 | module_param(debug, int, 0644); |
| 39 | 39 | ||
| 40 | #define dprintk(level, fmt, arg...) if (debug >= level) \ | 40 | #define dprintk(level, fmt, arg...) if (debug >= level) \ |
diff --git a/drivers/media/common/ir-keymaps.c b/drivers/media/common/ir-keymaps.c index 2ab5a120470d..a3485817e46c 100644 --- a/drivers/media/common/ir-keymaps.c +++ b/drivers/media/common/ir-keymaps.c | |||
| @@ -212,6 +212,51 @@ IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE] = { | |||
| 212 | 212 | ||
| 213 | EXPORT_SYMBOL_GPL(ir_codes_pixelview); | 213 | EXPORT_SYMBOL_GPL(ir_codes_pixelview); |
| 214 | 214 | ||
| 215 | /* | ||
| 216 | Mauro Carvalho Chehab <mchehab@infradead.org> | ||
| 217 | present on PV MPEG 8000GT | ||
| 218 | */ | ||
| 219 | IR_KEYTAB_TYPE ir_codes_pixelview_new[IR_KEYTAB_SIZE] = { | ||
| 220 | [0x3c] = KEY_PAUSE, /* Timeshift */ | ||
| 221 | [0x12] = KEY_POWER, | ||
| 222 | |||
| 223 | [0x3d] = KEY_1, | ||
| 224 | [0x38] = KEY_2, | ||
| 225 | [0x18] = KEY_3, | ||
| 226 | [0x35] = KEY_4, | ||
| 227 | [0x39] = KEY_5, | ||
| 228 | [0x15] = KEY_6, | ||
| 229 | [0x36] = KEY_7, | ||
| 230 | [0x3a] = KEY_8, | ||
| 231 | [0x1e] = KEY_9, | ||
| 232 | [0x3e] = KEY_0, | ||
| 233 | |||
| 234 | [0x1c] = KEY_AGAIN, /* LOOP */ | ||
| 235 | [0x3f] = KEY_MEDIA, /* Source */ | ||
| 236 | [0x1f] = KEY_LAST, /* +100 */ | ||
| 237 | [0x1b] = KEY_MUTE, | ||
| 238 | |||
| 239 | [0x17] = KEY_CHANNELDOWN, | ||
| 240 | [0x16] = KEY_CHANNELUP, | ||
| 241 | [0x10] = KEY_VOLUMEUP, | ||
| 242 | [0x14] = KEY_VOLUMEDOWN, | ||
| 243 | [0x13] = KEY_ZOOM, | ||
| 244 | |||
| 245 | [0x19] = KEY_SHUFFLE, /* SNAPSHOT */ | ||
| 246 | [0x1a] = KEY_SEARCH, /* scan */ | ||
| 247 | |||
| 248 | [0x37] = KEY_REWIND, /* << */ | ||
| 249 | [0x32] = KEY_RECORD, /* o (red) */ | ||
| 250 | [0x33] = KEY_FORWARD, /* >> */ | ||
| 251 | [0x11] = KEY_STOP, /* square */ | ||
| 252 | [0x3b] = KEY_PLAY, /* > */ | ||
| 253 | [0x30] = KEY_PLAYPAUSE, /* || */ | ||
| 254 | |||
| 255 | [0x31] = KEY_TV, | ||
| 256 | [0x34] = KEY_RADIO, | ||
| 257 | }; | ||
| 258 | EXPORT_SYMBOL_GPL(ir_codes_pixelview_new); | ||
| 259 | |||
| 215 | IR_KEYTAB_TYPE ir_codes_nebula[IR_KEYTAB_SIZE] = { | 260 | IR_KEYTAB_TYPE ir_codes_nebula[IR_KEYTAB_SIZE] = { |
| 216 | [ 0x00 ] = KEY_0, | 261 | [ 0x00 ] = KEY_0, |
| 217 | [ 0x01 ] = KEY_1, | 262 | [ 0x01 ] = KEY_1, |
| @@ -726,7 +771,11 @@ IR_KEYTAB_TYPE ir_codes_flyvideo[IR_KEYTAB_SIZE] = { | |||
| 726 | [ 0x12 ] = KEY_CHANNELUP, // Channel + | 771 | [ 0x12 ] = KEY_CHANNELUP, // Channel + |
| 727 | [ 0x13 ] = KEY_CHANNELDOWN, // Channel - | 772 | [ 0x13 ] = KEY_CHANNELDOWN, // Channel - |
| 728 | [ 0x06 ] = KEY_AGAIN, // Recall | 773 | [ 0x06 ] = KEY_AGAIN, // Recall |
| 729 | [ 0x10 ] = KEY_ENTER, // Enter | 774 | [ 0x10 ] = KEY_ENTER, // Enter |
| 775 | |||
| 776 | [ 0x19 ] = KEY_BACK, // Rewind ( <<< ) | ||
| 777 | [ 0x1f ] = KEY_FORWARD, // Forward ( >>> ) | ||
| 778 | [ 0x0a ] = KEY_ANGLE, // (no label, may be used as the PAUSE button) | ||
| 730 | }; | 779 | }; |
| 731 | 780 | ||
| 732 | EXPORT_SYMBOL_GPL(ir_codes_flyvideo); | 781 | EXPORT_SYMBOL_GPL(ir_codes_flyvideo); |
| @@ -1157,7 +1206,8 @@ EXPORT_SYMBOL_GPL(ir_codes_purpletv); | |||
| 1157 | 1206 | ||
| 1158 | /* Mapping for the 28 key remote control as seen at | 1207 | /* Mapping for the 28 key remote control as seen at |
| 1159 | http://www.sednacomputer.com/photo/cardbus-tv.jpg | 1208 | http://www.sednacomputer.com/photo/cardbus-tv.jpg |
| 1160 | Pavel Mihaylov <bin@bash.info> */ | 1209 | Pavel Mihaylov <bin@bash.info> |
| 1210 | Also for the remote bundled with Kozumi KTV-01C card */ | ||
| 1161 | IR_KEYTAB_TYPE ir_codes_pctv_sedna[IR_KEYTAB_SIZE] = { | 1211 | IR_KEYTAB_TYPE ir_codes_pctv_sedna[IR_KEYTAB_SIZE] = { |
| 1162 | [ 0x00 ] = KEY_0, | 1212 | [ 0x00 ] = KEY_0, |
| 1163 | [ 0x01 ] = KEY_1, | 1213 | [ 0x01 ] = KEY_1, |
| @@ -1188,6 +1238,11 @@ IR_KEYTAB_TYPE ir_codes_pctv_sedna[IR_KEYTAB_SIZE] = { | |||
| 1188 | [ 0x1c ] = KEY_RADIO, /* FM Radio */ | 1238 | [ 0x1c ] = KEY_RADIO, /* FM Radio */ |
| 1189 | [ 0x1d ] = KEY_RECORD, | 1239 | [ 0x1d ] = KEY_RECORD, |
| 1190 | [ 0x1e ] = KEY_PAUSE, | 1240 | [ 0x1e ] = KEY_PAUSE, |
| 1241 | /* additional codes for Kozumi's remote */ | ||
| 1242 | [0x14] = KEY_INFO, /* OSD */ | ||
| 1243 | [0x16] = KEY_OK, /* OK */ | ||
| 1244 | [0x17] = KEY_DIGITS, /* Plus */ | ||
| 1245 | [0x1f] = KEY_PLAY, /* Play */ | ||
| 1191 | }; | 1246 | }; |
| 1192 | 1247 | ||
| 1193 | EXPORT_SYMBOL_GPL(ir_codes_pctv_sedna); | 1248 | EXPORT_SYMBOL_GPL(ir_codes_pctv_sedna); |
| @@ -1988,6 +2043,76 @@ IR_KEYTAB_TYPE ir_codes_behold[IR_KEYTAB_SIZE] = { | |||
| 1988 | 2043 | ||
| 1989 | EXPORT_SYMBOL_GPL(ir_codes_behold); | 2044 | EXPORT_SYMBOL_GPL(ir_codes_behold); |
| 1990 | 2045 | ||
| 2046 | /* Beholder Intl. Ltd. 2008 | ||
| 2047 | * Dmitry Belimov d.belimov@google.com | ||
| 2048 | * Keytable is used by BeholdTV Columbus | ||
| 2049 | * The "ascii-art picture" below (in comments, first row | ||
| 2050 | * is the keycode in hex, and subsequent row(s) shows | ||
| 2051 | * the button labels (several variants when appropriate) | ||
| 2052 | * helps to descide which keycodes to assign to the buttons. | ||
| 2053 | */ | ||
| 2054 | IR_KEYTAB_TYPE ir_codes_behold_columbus[IR_KEYTAB_SIZE] = { | ||
| 2055 | |||
| 2056 | /* 0x13 0x11 0x1C 0x12 * | ||
| 2057 | * Mute Source TV/FM Power * | ||
| 2058 | * */ | ||
| 2059 | |||
| 2060 | [0x13] = KEY_MUTE, | ||
| 2061 | [0x11] = KEY_PROPS, | ||
| 2062 | [0x1C] = KEY_TUNER, /* KEY_TV/KEY_RADIO */ | ||
| 2063 | [0x12] = KEY_POWER, | ||
| 2064 | |||
| 2065 | /* 0x01 0x02 0x03 0x0D * | ||
| 2066 | * 1 2 3 Stereo * | ||
| 2067 | * * | ||
| 2068 | * 0x04 0x05 0x06 0x19 * | ||
| 2069 | * 4 5 6 Snapshot * | ||
| 2070 | * * | ||
| 2071 | * 0x07 0x08 0x09 0x10 * | ||
| 2072 | * 7 8 9 Zoom * | ||
| 2073 | * */ | ||
| 2074 | [0x01] = KEY_1, | ||
| 2075 | [0x02] = KEY_2, | ||
| 2076 | [0x03] = KEY_3, | ||
| 2077 | [0x0D] = KEY_SETUP, /* Setup key */ | ||
| 2078 | [0x04] = KEY_4, | ||
| 2079 | [0x05] = KEY_5, | ||
| 2080 | [0x06] = KEY_6, | ||
| 2081 | [0x19] = KEY_BOOKMARKS, /* Snapshot key */ | ||
| 2082 | [0x07] = KEY_7, | ||
| 2083 | [0x08] = KEY_8, | ||
| 2084 | [0x09] = KEY_9, | ||
| 2085 | [0x10] = KEY_ZOOM, | ||
| 2086 | |||
| 2087 | /* 0x0A 0x00 0x0B 0x0C * | ||
| 2088 | * RECALL 0 ChannelUp VolumeUp * | ||
| 2089 | * */ | ||
| 2090 | [0x0A] = KEY_AGAIN, | ||
| 2091 | [0x00] = KEY_0, | ||
| 2092 | [0x0B] = KEY_CHANNELUP, | ||
| 2093 | [0x0C] = KEY_VOLUMEUP, | ||
| 2094 | |||
| 2095 | /* 0x1B 0x1D 0x15 0x18 * | ||
| 2096 | * Timeshift Record ChannelDown VolumeDown * | ||
| 2097 | * */ | ||
| 2098 | |||
| 2099 | [0x1B] = KEY_REWIND, | ||
| 2100 | [0x1D] = KEY_RECORD, | ||
| 2101 | [0x15] = KEY_CHANNELDOWN, | ||
| 2102 | [0x18] = KEY_VOLUMEDOWN, | ||
| 2103 | |||
| 2104 | /* 0x0E 0x1E 0x0F 0x1A * | ||
| 2105 | * Stop Pause Previouse Next * | ||
| 2106 | * */ | ||
| 2107 | |||
| 2108 | [0x0E] = KEY_STOP, | ||
| 2109 | [0x1E] = KEY_PAUSE, | ||
| 2110 | [0x0F] = KEY_PREVIOUS, | ||
| 2111 | [0x1A] = KEY_NEXT, | ||
| 2112 | |||
| 2113 | }; | ||
| 2114 | EXPORT_SYMBOL_GPL(ir_codes_behold_columbus); | ||
| 2115 | |||
| 1991 | /* | 2116 | /* |
| 1992 | * Remote control for the Genius TVGO A11MCE | 2117 | * Remote control for the Genius TVGO A11MCE |
| 1993 | * Adrian Pardini <pardo.bsso@gmail.com> | 2118 | * Adrian Pardini <pardo.bsso@gmail.com> |
| @@ -2033,3 +2158,46 @@ IR_KEYTAB_TYPE ir_codes_genius_tvgo_a11mce[IR_KEYTAB_SIZE] = { | |||
| 2033 | [0x50] = KEY_BLUE, | 2158 | [0x50] = KEY_BLUE, |
| 2034 | }; | 2159 | }; |
| 2035 | EXPORT_SYMBOL_GPL(ir_codes_genius_tvgo_a11mce); | 2160 | EXPORT_SYMBOL_GPL(ir_codes_genius_tvgo_a11mce); |
| 2161 | |||
| 2162 | /* | ||
| 2163 | * Remote control for Powercolor Real Angel 330 | ||
| 2164 | * Daniel Fraga <fragabr@gmail.com> | ||
| 2165 | */ | ||
| 2166 | IR_KEYTAB_TYPE ir_codes_powercolor_real_angel[IR_KEYTAB_SIZE] = { | ||
| 2167 | [0x38] = KEY_SWITCHVIDEOMODE, /* switch inputs */ | ||
| 2168 | [0x0c] = KEY_MEDIA, /* Turn ON/OFF App */ | ||
| 2169 | [0x00] = KEY_0, | ||
| 2170 | [0x01] = KEY_1, | ||
| 2171 | [0x02] = KEY_2, | ||
| 2172 | [0x03] = KEY_3, | ||
| 2173 | [0x04] = KEY_4, | ||
| 2174 | [0x05] = KEY_5, | ||
| 2175 | [0x06] = KEY_6, | ||
| 2176 | [0x07] = KEY_7, | ||
| 2177 | [0x08] = KEY_8, | ||
| 2178 | [0x09] = KEY_9, | ||
| 2179 | [0x0a] = KEY_DIGITS, /* single, double, tripple digit */ | ||
| 2180 | [0x29] = KEY_PREVIOUS, /* previous channel */ | ||
| 2181 | [0x12] = KEY_BRIGHTNESSUP, | ||
| 2182 | [0x13] = KEY_BRIGHTNESSDOWN, | ||
| 2183 | [0x2b] = KEY_MODE, /* stereo/mono */ | ||
| 2184 | [0x2c] = KEY_TEXT, /* teletext */ | ||
| 2185 | [0x20] = KEY_UP, /* channel up */ | ||
| 2186 | [0x21] = KEY_DOWN, /* channel down */ | ||
| 2187 | [0x10] = KEY_RIGHT, /* volume up */ | ||
| 2188 | [0x11] = KEY_LEFT, /* volume down */ | ||
| 2189 | [0x0d] = KEY_MUTE, | ||
| 2190 | [0x1f] = KEY_RECORD, | ||
| 2191 | [0x17] = KEY_PLAY, | ||
| 2192 | [0x16] = KEY_PAUSE, | ||
| 2193 | [0x0b] = KEY_STOP, | ||
| 2194 | [0x27] = KEY_FASTFORWARD, | ||
| 2195 | [0x26] = KEY_REWIND, | ||
| 2196 | [0x1e] = KEY_SEARCH, /* autoscan */ | ||
| 2197 | [0x0e] = KEY_SHUFFLE, /* snapshot */ | ||
| 2198 | [0x2d] = KEY_SETUP, | ||
| 2199 | [0x0f] = KEY_SCREEN, /* full screen */ | ||
| 2200 | [0x14] = KEY_RADIO, /* FM radio */ | ||
| 2201 | [0x25] = KEY_POWER, /* power */ | ||
| 2202 | }; | ||
| 2203 | EXPORT_SYMBOL_GPL(ir_codes_powercolor_real_angel); | ||
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c index 7707b8c7394b..89c7660b85d6 100644 --- a/drivers/media/common/saa7146_core.c +++ b/drivers/media/common/saa7146_core.c | |||
| @@ -74,7 +74,7 @@ static inline int saa7146_wait_for_debi_done_sleep(struct saa7146_dev *dev, | |||
| 74 | if (err) { | 74 | if (err) { |
| 75 | printk(KERN_ERR "%s: %s timed out while waiting for " | 75 | printk(KERN_ERR "%s: %s timed out while waiting for " |
| 76 | "registers getting programmed\n", | 76 | "registers getting programmed\n", |
| 77 | dev->name, __FUNCTION__); | 77 | dev->name, __func__); |
| 78 | return -ETIMEDOUT; | 78 | return -ETIMEDOUT; |
| 79 | } | 79 | } |
| 80 | msleep(1); | 80 | msleep(1); |
| @@ -89,7 +89,7 @@ static inline int saa7146_wait_for_debi_done_sleep(struct saa7146_dev *dev, | |||
| 89 | saa7146_read(dev, MC2); | 89 | saa7146_read(dev, MC2); |
| 90 | if (err) { | 90 | if (err) { |
| 91 | DEB_S(("%s: %s timed out while waiting for transfer " | 91 | DEB_S(("%s: %s timed out while waiting for transfer " |
| 92 | "completion\n", dev->name, __FUNCTION__)); | 92 | "completion\n", dev->name, __func__)); |
| 93 | return -ETIMEDOUT; | 93 | return -ETIMEDOUT; |
| 94 | } | 94 | } |
| 95 | msleep(1); | 95 | msleep(1); |
| @@ -111,7 +111,7 @@ static inline int saa7146_wait_for_debi_done_busyloop(struct saa7146_dev *dev, | |||
| 111 | if (!loops--) { | 111 | if (!loops--) { |
| 112 | printk(KERN_ERR "%s: %s timed out while waiting for " | 112 | printk(KERN_ERR "%s: %s timed out while waiting for " |
| 113 | "registers getting programmed\n", | 113 | "registers getting programmed\n", |
| 114 | dev->name, __FUNCTION__); | 114 | dev->name, __func__); |
| 115 | return -ETIMEDOUT; | 115 | return -ETIMEDOUT; |
| 116 | } | 116 | } |
| 117 | udelay(1); | 117 | udelay(1); |
| @@ -125,7 +125,7 @@ static inline int saa7146_wait_for_debi_done_busyloop(struct saa7146_dev *dev, | |||
| 125 | saa7146_read(dev, MC2); | 125 | saa7146_read(dev, MC2); |
| 126 | if (!loops--) { | 126 | if (!loops--) { |
| 127 | DEB_S(("%s: %s timed out while waiting for transfer " | 127 | DEB_S(("%s: %s timed out while waiting for transfer " |
| 128 | "completion\n", dev->name, __FUNCTION__)); | 128 | "completion\n", dev->name, __func__)); |
| 129 | return -ETIMEDOUT; | 129 | return -ETIMEDOUT; |
| 130 | } | 130 | } |
| 131 | udelay(5); | 131 | udelay(5); |
diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c index 7e7689afae62..35b01ec40a51 100644 --- a/drivers/media/common/saa7146_i2c.c +++ b/drivers/media/common/saa7146_i2c.c | |||
| @@ -203,7 +203,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d | |||
| 203 | return -ERESTARTSYS; | 203 | return -ERESTARTSYS; |
| 204 | 204 | ||
| 205 | printk(KERN_WARNING "%s %s [irq]: timed out waiting for end of xfer\n", | 205 | printk(KERN_WARNING "%s %s [irq]: timed out waiting for end of xfer\n", |
| 206 | dev->name, __FUNCTION__); | 206 | dev->name, __func__); |
| 207 | return -EIO; | 207 | return -EIO; |
| 208 | } | 208 | } |
| 209 | status = saa7146_read(dev, I2C_STATUS); | 209 | status = saa7146_read(dev, I2C_STATUS); |
| @@ -221,7 +221,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d | |||
| 221 | } | 221 | } |
| 222 | if (time_after(jiffies,timeout)) { | 222 | if (time_after(jiffies,timeout)) { |
| 223 | printk(KERN_WARNING "%s %s: timed out waiting for MC2\n", | 223 | printk(KERN_WARNING "%s %s: timed out waiting for MC2\n", |
| 224 | dev->name, __FUNCTION__); | 224 | dev->name, __func__); |
| 225 | return -EIO; | 225 | return -EIO; |
| 226 | } | 226 | } |
| 227 | } | 227 | } |
| @@ -238,7 +238,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d | |||
| 238 | * (no answer from nonexisistant device...) | 238 | * (no answer from nonexisistant device...) |
| 239 | */ | 239 | */ |
| 240 | printk(KERN_WARNING "%s %s [poll]: timed out waiting for end of xfer\n", | 240 | printk(KERN_WARNING "%s %s [poll]: timed out waiting for end of xfer\n", |
| 241 | dev->name, __FUNCTION__); | 241 | dev->name, __func__); |
| 242 | return -EIO; | 242 | return -EIO; |
| 243 | } | 243 | } |
| 244 | if (++trial < 50 && short_delay) | 244 | if (++trial < 50 && short_delay) |
diff --git a/drivers/media/common/saa7146_vbi.c b/drivers/media/common/saa7146_vbi.c index bfbd5a841ebf..74e2b56ecb5b 100644 --- a/drivers/media/common/saa7146_vbi.c +++ b/drivers/media/common/saa7146_vbi.c | |||
| @@ -407,8 +407,8 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file) | |||
| 407 | fh->vbi_fmt.start[1] = 312; | 407 | fh->vbi_fmt.start[1] = 312; |
| 408 | fh->vbi_fmt.count[1] = 16; | 408 | fh->vbi_fmt.count[1] = 16; |
| 409 | 409 | ||
| 410 | videobuf_queue_pci_init(&fh->vbi_q, &vbi_qops, | 410 | videobuf_queue_sg_init(&fh->vbi_q, &vbi_qops, |
| 411 | dev->pci, &dev->slock, | 411 | &dev->pci->dev, &dev->slock, |
| 412 | V4L2_BUF_TYPE_VBI_CAPTURE, | 412 | V4L2_BUF_TYPE_VBI_CAPTURE, |
| 413 | V4L2_FIELD_SEQ_TB, // FIXME: does this really work? | 413 | V4L2_FIELD_SEQ_TB, // FIXME: does this really work? |
| 414 | sizeof(struct saa7146_buf), | 414 | sizeof(struct saa7146_buf), |
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c index 66fdbd0e6a6d..3cbc6ebbe649 100644 --- a/drivers/media/common/saa7146_video.c +++ b/drivers/media/common/saa7146_video.c | |||
| @@ -1410,8 +1410,8 @@ static int video_open(struct saa7146_dev *dev, struct file *file) | |||
| 1410 | sfmt = format_by_fourcc(dev,fh->video_fmt.pixelformat); | 1410 | sfmt = format_by_fourcc(dev,fh->video_fmt.pixelformat); |
| 1411 | fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8; | 1411 | fh->video_fmt.sizeimage = (fh->video_fmt.width * fh->video_fmt.height * sfmt->depth)/8; |
| 1412 | 1412 | ||
| 1413 | videobuf_queue_pci_init(&fh->video_q, &video_qops, | 1413 | videobuf_queue_sg_init(&fh->video_q, &video_qops, |
| 1414 | dev->pci, &dev->slock, | 1414 | &dev->pci->dev, &dev->slock, |
| 1415 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 1415 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 1416 | V4L2_FIELD_INTERLACED, | 1416 | V4L2_FIELD_INTERLACED, |
| 1417 | sizeof(struct saa7146_buf), | 1417 | sizeof(struct saa7146_buf), |
diff --git a/drivers/media/dvb/b2c2/Kconfig b/drivers/media/dvb/b2c2/Kconfig index 3197aeb61d1f..6ec5afba1ca7 100644 --- a/drivers/media/dvb/b2c2/Kconfig +++ b/drivers/media/dvb/b2c2/Kconfig | |||
| @@ -9,6 +9,11 @@ config DVB_B2C2_FLEXCOP | |||
| 9 | select DVB_STV0297 if !DVB_FE_CUSTOMISE | 9 | select DVB_STV0297 if !DVB_FE_CUSTOMISE |
| 10 | select DVB_BCM3510 if !DVB_FE_CUSTOMISE | 10 | select DVB_BCM3510 if !DVB_FE_CUSTOMISE |
| 11 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE | 11 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE |
| 12 | select TUNER_SIMPLE if !DVB_FE_CUSTOMISE | ||
| 13 | select DVB_S5H1420 if !DVB_FE_CUSTOMISE | ||
| 14 | select DVB_TUNER_ITD1000 if !DVB_FE_CUSTOMISE | ||
| 15 | select DVB_ISL6421 if !DVB_FE_CUSTOMISE | ||
| 16 | select DVB_CX24123 if !DVB_FE_CUSTOMISE | ||
| 12 | help | 17 | help |
| 13 | Support for the digital TV receiver chip made by B2C2 Inc. included in | 18 | Support for the digital TV receiver chip made by B2C2 Inc. included in |
| 14 | Technisats PCI cards and USB boxes. | 19 | Technisats PCI cards and USB boxes. |
diff --git a/drivers/media/dvb/b2c2/Makefile b/drivers/media/dvb/b2c2/Makefile index e97ff60a1eff..870e2848c296 100644 --- a/drivers/media/dvb/b2c2/Makefile +++ b/drivers/media/dvb/b2c2/Makefile | |||
| @@ -2,6 +2,7 @@ b2c2-flexcop-objs = flexcop.o flexcop-fe-tuner.o flexcop-i2c.o \ | |||
| 2 | flexcop-sram.o flexcop-eeprom.o flexcop-misc.o flexcop-hw-filter.o | 2 | flexcop-sram.o flexcop-eeprom.o flexcop-misc.o flexcop-hw-filter.o |
| 3 | obj-$(CONFIG_DVB_B2C2_FLEXCOP) += b2c2-flexcop.o | 3 | obj-$(CONFIG_DVB_B2C2_FLEXCOP) += b2c2-flexcop.o |
| 4 | 4 | ||
| 5 | |||
| 5 | ifneq ($(CONFIG_DVB_B2C2_FLEXCOP_PCI),) | 6 | ifneq ($(CONFIG_DVB_B2C2_FLEXCOP_PCI),) |
| 6 | b2c2-flexcop-objs += flexcop-dma.o | 7 | b2c2-flexcop-objs += flexcop-dma.o |
| 7 | endif | 8 | endif |
| @@ -13,3 +14,4 @@ b2c2-flexcop-usb-objs = flexcop-usb.o | |||
| 13 | obj-$(CONFIG_DVB_B2C2_FLEXCOP_USB) += b2c2-flexcop-usb.o | 14 | obj-$(CONFIG_DVB_B2C2_FLEXCOP_USB) += b2c2-flexcop-usb.o |
| 14 | 15 | ||
| 15 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ | 16 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ |
| 17 | EXTRA_CFLAGS += -Idrivers/media/video/ | ||
diff --git a/drivers/media/dvb/b2c2/flexcop-common.h b/drivers/media/dvb/b2c2/flexcop-common.h index 5a6c4fe249e7..8ce06336e76f 100644 --- a/drivers/media/dvb/b2c2/flexcop-common.h +++ b/drivers/media/dvb/b2c2/flexcop-common.h | |||
| @@ -44,6 +44,14 @@ struct flexcop_dma { | |||
| 44 | u32 size; /* size of each address in bytes */ | 44 | u32 size; /* size of each address in bytes */ |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | struct flexcop_i2c_adapter { | ||
| 48 | struct flexcop_device *fc; | ||
| 49 | struct i2c_adapter i2c_adap; | ||
| 50 | |||
| 51 | u8 no_base_addr; | ||
| 52 | flexcop_i2c_port_t port; | ||
| 53 | }; | ||
| 54 | |||
| 47 | /* Control structure for data definitions that are common to | 55 | /* Control structure for data definitions that are common to |
| 48 | * the B2C2-based PCI and USB devices. | 56 | * the B2C2-based PCI and USB devices. |
| 49 | */ | 57 | */ |
| @@ -72,7 +80,7 @@ struct flexcop_device { | |||
| 72 | struct dmx_frontend mem_frontend; | 80 | struct dmx_frontend mem_frontend; |
| 73 | int (*fe_sleep) (struct dvb_frontend *); | 81 | int (*fe_sleep) (struct dvb_frontend *); |
| 74 | 82 | ||
| 75 | struct i2c_adapter i2c_adap; | 83 | struct flexcop_i2c_adapter fc_i2c_adap[3]; |
| 76 | struct mutex i2c_mutex; | 84 | struct mutex i2c_mutex; |
| 77 | struct module *owner; | 85 | struct module *owner; |
| 78 | 86 | ||
| @@ -87,7 +95,8 @@ struct flexcop_device { | |||
| 87 | int (*write_ibi_reg) (struct flexcop_device *, flexcop_ibi_register, flexcop_ibi_value); | 95 | int (*write_ibi_reg) (struct flexcop_device *, flexcop_ibi_register, flexcop_ibi_value); |
| 88 | 96 | ||
| 89 | 97 | ||
| 90 | int (*i2c_request) (struct flexcop_device*, flexcop_access_op_t, flexcop_i2c_port_t, u8 chipaddr, u8 addr, u8 *buf, u16 len); | 98 | int (*i2c_request) (struct flexcop_i2c_adapter*, |
| 99 | flexcop_access_op_t, u8 chipaddr, u8 addr, u8 *buf, u16 len); | ||
| 91 | int (*stream_control) (struct flexcop_device*, int); | 100 | int (*stream_control) (struct flexcop_device*, int); |
| 92 | 101 | ||
| 93 | int (*get_mac_addr) (struct flexcop_device *fc, int extended); | 102 | int (*get_mac_addr) (struct flexcop_device *fc, int extended); |
| @@ -128,8 +137,8 @@ int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended); | |||
| 128 | * one. We have it in flexcop-i2c.c, because it is going via the actual | 137 | * one. We have it in flexcop-i2c.c, because it is going via the actual |
| 129 | * I2C-channel of the flexcop. | 138 | * I2C-channel of the flexcop. |
| 130 | */ | 139 | */ |
| 131 | int flexcop_i2c_request(struct flexcop_device*, flexcop_access_op_t, | 140 | int flexcop_i2c_request(struct flexcop_i2c_adapter*, flexcop_access_op_t, |
| 132 | flexcop_i2c_port_t, u8 chipaddr, u8 addr, u8 *buf, u16 len); | 141 | u8 chipaddr, u8 addr, u8 *buf, u16 len); |
| 133 | 142 | ||
| 134 | /* from flexcop-sram.c */ | 143 | /* from flexcop-sram.c */ |
| 135 | int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, flexcop_sram_dest_target_t target); | 144 | int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, flexcop_sram_dest_target_t target); |
diff --git a/drivers/media/dvb/b2c2/flexcop-dma.c b/drivers/media/dvb/b2c2/flexcop-dma.c index 6f592bc32d22..a91ed28f03a4 100644 --- a/drivers/media/dvb/b2c2/flexcop-dma.c +++ b/drivers/media/dvb/b2c2/flexcop-dma.c | |||
| @@ -112,7 +112,7 @@ static int flexcop_dma_remap(struct flexcop_device *fc, | |||
| 112 | { | 112 | { |
| 113 | flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_00c : dma2_01c; | 113 | flexcop_ibi_register r = (dma_idx & FC_DMA_1) ? dma1_00c : dma2_01c; |
| 114 | flexcop_ibi_value v = fc->read_ibi_reg(fc,r); | 114 | flexcop_ibi_value v = fc->read_ibi_reg(fc,r); |
| 115 | deb_info("%s\n",__FUNCTION__); | 115 | deb_info("%s\n",__func__); |
| 116 | v.dma_0xc.remap_enable = onoff; | 116 | v.dma_0xc.remap_enable = onoff; |
| 117 | fc->write_ibi_reg(fc,r,v); | 117 | fc->write_ibi_reg(fc,r,v); |
| 118 | return 0; | 118 | return 0; |
| @@ -162,7 +162,7 @@ int flexcop_dma_config_timer(struct flexcop_device *fc, | |||
| 162 | 162 | ||
| 163 | flexcop_dma_remap(fc,dma_idx,0); | 163 | flexcop_dma_remap(fc,dma_idx,0); |
| 164 | 164 | ||
| 165 | deb_info("%s\n",__FUNCTION__); | 165 | deb_info("%s\n",__func__); |
| 166 | v.dma_0x4_write.dmatimer = cycles; | 166 | v.dma_0x4_write.dmatimer = cycles; |
| 167 | fc->write_ibi_reg(fc,r,v); | 167 | fc->write_ibi_reg(fc,r,v); |
| 168 | return 0; | 168 | return 0; |
diff --git a/drivers/media/dvb/b2c2/flexcop-eeprom.c b/drivers/media/dvb/b2c2/flexcop-eeprom.c index bbcf070a178d..8a8ae8a3e6ba 100644 --- a/drivers/media/dvb/b2c2/flexcop-eeprom.c +++ b/drivers/media/dvb/b2c2/flexcop-eeprom.c | |||
| @@ -114,15 +114,18 @@ static int flexcop_eeprom_request(struct flexcop_device *fc, flexcop_access_op_t | |||
| 114 | { | 114 | { |
| 115 | int i,ret = 0; | 115 | int i,ret = 0; |
| 116 | u8 chipaddr = 0x50 | ((addr >> 8) & 3); | 116 | u8 chipaddr = 0x50 | ((addr >> 8) & 3); |
| 117 | for (i = 0; i < retries; i++) | 117 | for (i = 0; i < retries; i++) { |
| 118 | if ((ret = fc->i2c_request(fc,op,FC_I2C_PORT_EEPROM,chipaddr,addr & 0xff,buf,len)) == 0) | 118 | ret = fc->i2c_request(&fc->fc_i2c_adap[1], op, chipaddr, |
| 119 | addr & 0xff, buf, len); | ||
| 120 | if (ret == 0) | ||
| 119 | break; | 121 | break; |
| 122 | } | ||
| 120 | return ret; | 123 | return ret; |
| 121 | } | 124 | } |
| 122 | 125 | ||
| 123 | static int flexcop_eeprom_lrc_read(struct flexcop_device *fc, u16 addr, u8 *buf, u16 len, int retries) | 126 | static int flexcop_eeprom_lrc_read(struct flexcop_device *fc, u16 addr, u8 *buf, u16 len, int retries) |
| 124 | { | 127 | { |
| 125 | int ret = flexcop_eeprom_request(fc,FC_READ,addr,buf,len,retries); | 128 | int ret = flexcop_eeprom_request(fc, FC_READ, addr, buf, len, retries); |
| 126 | if (ret == 0) | 129 | if (ret == 0) |
| 127 | if (calc_lrc(buf, len - 1) != buf[len - 1]) | 130 | if (calc_lrc(buf, len - 1) != buf[len - 1]) |
| 128 | ret = -EINVAL; | 131 | ret = -EINVAL; |
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c index 0378fd646591..7b0ea3bdfafb 100644 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | * | 5 | * |
| 6 | * see flexcop.c for copyright information. | 6 | * see flexcop.c for copyright information. |
| 7 | */ | 7 | */ |
| 8 | #include <media/tuner.h> | ||
| 9 | |||
| 8 | #include "flexcop.h" | 10 | #include "flexcop.h" |
| 9 | 11 | ||
| 10 | #include "stv0299.h" | 12 | #include "stv0299.h" |
| @@ -15,6 +17,15 @@ | |||
| 15 | #include "mt312.h" | 17 | #include "mt312.h" |
| 16 | #include "lgdt330x.h" | 18 | #include "lgdt330x.h" |
| 17 | #include "dvb-pll.h" | 19 | #include "dvb-pll.h" |
| 20 | #include "tuner-simple.h" | ||
| 21 | |||
| 22 | #include "s5h1420.h" | ||
| 23 | #include "itd1000.h" | ||
| 24 | |||
| 25 | #include "cx24123.h" | ||
| 26 | #include "cx24113.h" | ||
| 27 | |||
| 28 | #include "isl6421.h" | ||
| 18 | 29 | ||
| 19 | /* lnb control */ | 30 | /* lnb control */ |
| 20 | 31 | ||
| @@ -180,13 +191,13 @@ static int samsung_tbmu24112_tuner_set_params(struct dvb_frontend* fe, struct dv | |||
| 180 | buf[2] = 0x84; /* 0xC4 */ | 191 | buf[2] = 0x84; /* 0xC4 */ |
| 181 | buf[3] = 0x08; | 192 | buf[3] = 0x08; |
| 182 | 193 | ||
| 183 | if (params->frequency < 1500000) buf[3] |= 0x10; | 194 | if (params->frequency < 1500000) |
| 195 | buf[3] |= 0x10; | ||
| 184 | 196 | ||
| 185 | if (fe->ops.i2c_gate_ctrl) | 197 | if (fe->ops.i2c_gate_ctrl) |
| 186 | fe->ops.i2c_gate_ctrl(fe, 1); | 198 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 187 | if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) { | 199 | if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1) |
| 188 | return -EIO; | 200 | return -EIO; |
| 189 | } | ||
| 190 | return 0; | 201 | return 0; |
| 191 | } | 202 | } |
| 192 | 203 | ||
| @@ -241,7 +252,7 @@ static struct stv0299_config samsung_tbmu24112_config = { | |||
| 241 | .mclk = 88000000UL, | 252 | .mclk = 88000000UL, |
| 242 | .invert = 0, | 253 | .invert = 0, |
| 243 | .skip_reinit = 0, | 254 | .skip_reinit = 0, |
| 244 | .lock_output = STV0229_LOCKOUTPUT_LK, | 255 | .lock_output = STV0299_LOCKOUTPUT_LK, |
| 245 | .volt13_op0_op1 = STV0299_VOLT13_OP1, | 256 | .volt13_op0_op1 = STV0299_VOLT13_OP1, |
| 246 | .min_delay_ms = 100, | 257 | .min_delay_ms = 100, |
| 247 | .set_symbol_rate = samsung_tbmu24112_set_symbol_rate, | 258 | .set_symbol_rate = samsung_tbmu24112_set_symbol_rate, |
| @@ -337,7 +348,7 @@ static int skystar23_samsung_tbdu18132_tuner_set_params(struct dvb_frontend* fe, | |||
| 337 | 348 | ||
| 338 | if (fe->ops.i2c_gate_ctrl) | 349 | if (fe->ops.i2c_gate_ctrl) |
| 339 | fe->ops.i2c_gate_ctrl(fe, 1); | 350 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 340 | if (i2c_transfer(&fc->i2c_adap, &msg, 1) != 1) | 351 | if (i2c_transfer(&fc->fc_i2c_adap[0].i2c_adap, &msg, 1) != 1) |
| 341 | return -EIO; | 352 | return -EIO; |
| 342 | return 0; | 353 | return 0; |
| 343 | } | 354 | } |
| @@ -386,10 +397,11 @@ static int alps_tdee4_stv0297_tuner_set_params(struct dvb_frontend* fe, | |||
| 386 | if (fe->ops.i2c_gate_ctrl) | 397 | if (fe->ops.i2c_gate_ctrl) |
| 387 | fe->ops.i2c_gate_ctrl(fe, 0); | 398 | fe->ops.i2c_gate_ctrl(fe, 0); |
| 388 | deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n",fep->frequency, buf[0],buf[1],buf[2],buf[3]); | 399 | deb_tuner("tuner buffer for %d Hz: %x %x %x %x\n",fep->frequency, buf[0],buf[1],buf[2],buf[3]); |
| 389 | ret = fc->i2c_request(fc, FC_WRITE, FC_I2C_PORT_TUNER, 0x61, buf[0], &buf[1], 3); | 400 | ret = fc->i2c_request(&fc->fc_i2c_adap[2], |
| 401 | FC_WRITE, 0x61, buf[0], &buf[1], 3); | ||
| 390 | deb_tuner("tuner write returned: %d\n",ret); | 402 | deb_tuner("tuner write returned: %d\n",ret); |
| 391 | 403 | ||
| 392 | return 0; | 404 | return ret; |
| 393 | } | 405 | } |
| 394 | 406 | ||
| 395 | static u8 alps_tdee4_stv0297_inittab[] = { | 407 | static u8 alps_tdee4_stv0297_inittab[] = { |
| @@ -472,56 +484,159 @@ static struct stv0297_config alps_tdee4_stv0297_config = { | |||
| 472 | // .pll_set = alps_tdee4_stv0297_pll_set, | 484 | // .pll_set = alps_tdee4_stv0297_pll_set, |
| 473 | }; | 485 | }; |
| 474 | 486 | ||
| 487 | |||
| 488 | /* SkyStar2 rev2.7 (a/u) */ | ||
| 489 | static struct s5h1420_config skystar2_rev2_7_s5h1420_config = { | ||
| 490 | .demod_address = 0x53, | ||
| 491 | .invert = 1, | ||
| 492 | .repeated_start_workaround = 1, | ||
| 493 | }; | ||
| 494 | |||
| 495 | static struct itd1000_config skystar2_rev2_7_itd1000_config = { | ||
| 496 | .i2c_address = 0x61, | ||
| 497 | }; | ||
| 498 | |||
| 499 | /* SkyStar2 rev2.8 */ | ||
| 500 | static struct cx24123_config skystar2_rev2_8_cx24123_config = { | ||
| 501 | .demod_address = 0x55, | ||
| 502 | .dont_use_pll = 1, | ||
| 503 | .agc_callback = cx24113_agc_callback, | ||
| 504 | }; | ||
| 505 | |||
| 506 | static const struct cx24113_config skystar2_rev2_8_cx24113_config = { | ||
| 507 | .i2c_addr = 0x54, | ||
| 508 | .xtal_khz = 10111, | ||
| 509 | }; | ||
| 510 | |||
| 475 | /* try to figure out the frontend, each card/box can have on of the following list */ | 511 | /* try to figure out the frontend, each card/box can have on of the following list */ |
| 476 | int flexcop_frontend_init(struct flexcop_device *fc) | 512 | int flexcop_frontend_init(struct flexcop_device *fc) |
| 477 | { | 513 | { |
| 478 | struct dvb_frontend_ops *ops; | 514 | struct dvb_frontend_ops *ops; |
| 515 | struct i2c_adapter *i2c = &fc->fc_i2c_adap[0].i2c_adap; | ||
| 516 | struct i2c_adapter *i2c_tuner; | ||
| 517 | |||
| 518 | /* enable no_base_addr - no repeated start when reading */ | ||
| 519 | fc->fc_i2c_adap[0].no_base_addr = 1; | ||
| 520 | fc->fe = dvb_attach(s5h1420_attach, &skystar2_rev2_7_s5h1420_config, i2c); | ||
| 521 | if (fc->fe != NULL) { | ||
| 522 | flexcop_ibi_value r108; | ||
| 523 | i2c_tuner = s5h1420_get_tuner_i2c_adapter(fc->fe); | ||
| 524 | ops = &fc->fe->ops; | ||
| 525 | |||
| 526 | fc->fe_sleep = ops->sleep; | ||
| 527 | ops->sleep = flexcop_sleep; | ||
| 528 | |||
| 529 | fc->dev_type = FC_SKY_REV27; | ||
| 530 | |||
| 531 | /* enable no_base_addr - no repeated start when reading */ | ||
| 532 | fc->fc_i2c_adap[2].no_base_addr = 1; | ||
| 533 | if (dvb_attach(isl6421_attach, fc->fe, &fc->fc_i2c_adap[2].i2c_adap, 0x08, 1, 1) == NULL) | ||
| 534 | err("ISL6421 could NOT be attached"); | ||
| 535 | else | ||
| 536 | info("ISL6421 successfully attached"); | ||
| 537 | |||
| 538 | /* the ITD1000 requires a lower i2c clock - it slows down the stuff for everyone - but is it a problem ? */ | ||
| 539 | r108.raw = 0x00000506; | ||
| 540 | fc->write_ibi_reg(fc, tw_sm_c_108, r108); | ||
| 541 | if (i2c_tuner) { | ||
| 542 | if (dvb_attach(itd1000_attach, fc->fe, i2c_tuner, &skystar2_rev2_7_itd1000_config) == NULL) | ||
| 543 | err("ITD1000 could NOT be attached"); | ||
| 544 | else | ||
| 545 | info("ITD1000 successfully attached"); | ||
| 546 | } | ||
| 547 | goto fe_found; | ||
| 548 | } | ||
| 549 | fc->fc_i2c_adap[0].no_base_addr = 0; /* for the next devices we need it again */ | ||
| 550 | |||
| 551 | /* try the sky v2.8 (cx24123, isl6421) */ | ||
| 552 | fc->fe = dvb_attach(cx24123_attach, | ||
| 553 | &skystar2_rev2_8_cx24123_config, i2c); | ||
| 554 | if (fc->fe != NULL) { | ||
| 555 | i2c_tuner = cx24123_get_tuner_i2c_adapter(fc->fe); | ||
| 556 | if (i2c_tuner != NULL) { | ||
| 557 | if (dvb_attach(cx24113_attach, fc->fe, | ||
| 558 | &skystar2_rev2_8_cx24113_config, | ||
| 559 | i2c_tuner) == NULL) | ||
| 560 | err("CX24113 could NOT be attached"); | ||
| 561 | else | ||
| 562 | info("CX24113 successfully attached"); | ||
| 563 | } | ||
| 564 | |||
| 565 | fc->dev_type = FC_SKY_REV28; | ||
| 566 | |||
| 567 | fc->fc_i2c_adap[2].no_base_addr = 1; | ||
| 568 | if (dvb_attach(isl6421_attach, fc->fe, | ||
| 569 | &fc->fc_i2c_adap[2].i2c_adap, 0x08, 0, 0) == NULL) | ||
| 570 | err("ISL6421 could NOT be attached"); | ||
| 571 | else | ||
| 572 | info("ISL6421 successfully attached"); | ||
| 573 | |||
| 574 | /* TODO on i2c_adap[1] addr 0x11 (EEPROM) there seems to be an | ||
| 575 | * IR-receiver (PIC16F818) - but the card has no input for | ||
| 576 | * that ??? */ | ||
| 577 | |||
| 578 | goto fe_found; | ||
| 579 | } | ||
| 479 | 580 | ||
| 480 | /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */ | 581 | /* try the sky v2.6 (stv0299/Samsung tbmu24112(sl1935)) */ |
| 481 | if ((fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, &fc->i2c_adap)) != NULL) { | 582 | fc->fe = dvb_attach(stv0299_attach, &samsung_tbmu24112_config, i2c); |
| 583 | if (fc->fe != NULL) { | ||
| 482 | ops = &fc->fe->ops; | 584 | ops = &fc->fe->ops; |
| 483 | 585 | ||
| 484 | ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params; | 586 | ops->tuner_ops.set_params = samsung_tbmu24112_tuner_set_params; |
| 485 | 587 | ||
| 486 | ops->set_voltage = flexcop_set_voltage; | 588 | ops->set_voltage = flexcop_set_voltage; |
| 487 | 589 | ||
| 488 | fc->fe_sleep = ops->sleep; | 590 | fc->fe_sleep = ops->sleep; |
| 489 | ops->sleep = flexcop_sleep; | 591 | ops->sleep = flexcop_sleep; |
| 592 | |||
| 593 | fc->dev_type = FC_SKY; | ||
| 594 | goto fe_found; | ||
| 595 | } | ||
| 490 | 596 | ||
| 491 | fc->dev_type = FC_SKY; | ||
| 492 | info("found the stv0299 at i2c address: 0x%02x",samsung_tbmu24112_config.demod_address); | ||
| 493 | } else | ||
| 494 | /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */ | 597 | /* try the air dvb-t (mt352/Samsung tdtc9251dh0(??)) */ |
| 495 | if ((fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, &fc->i2c_adap)) != NULL ) { | 598 | fc->fe = dvb_attach(mt352_attach, &samsung_tdtc9251dh0_config, i2c); |
| 496 | fc->dev_type = FC_AIR_DVB; | 599 | if (fc->fe != NULL) { |
| 600 | fc->dev_type = FC_AIR_DVB; | ||
| 497 | fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs; | 601 | fc->fe->ops.tuner_ops.calc_regs = samsung_tdtc9251dh0_calc_regs; |
| 498 | info("found the mt352 at i2c address: 0x%02x",samsung_tdtc9251dh0_config.demod_address); | 602 | goto fe_found; |
| 499 | } else | 603 | } |
| 604 | |||
| 500 | /* try the air atsc 2nd generation (nxt2002) */ | 605 | /* try the air atsc 2nd generation (nxt2002) */ |
| 501 | if ((fc->fe = dvb_attach(nxt200x_attach, &samsung_tbmv_config, &fc->i2c_adap)) != NULL) { | 606 | fc->fe = dvb_attach(nxt200x_attach, &samsung_tbmv_config, i2c); |
| 502 | fc->dev_type = FC_AIR_ATSC2; | 607 | if (fc->fe != NULL) { |
| 608 | fc->dev_type = FC_AIR_ATSC2; | ||
| 503 | dvb_attach(dvb_pll_attach, fc->fe, 0x61, NULL, DVB_PLL_SAMSUNG_TBMV); | 609 | dvb_attach(dvb_pll_attach, fc->fe, 0x61, NULL, DVB_PLL_SAMSUNG_TBMV); |
| 504 | info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address); | 610 | goto fe_found; |
| 505 | } else | 611 | } |
| 506 | /* try the air atsc 3nd generation (lgdt3303) */ | 612 | |
| 507 | if ((fc->fe = dvb_attach(lgdt330x_attach, &air2pc_atsc_hd5000_config, &fc->i2c_adap)) != NULL) { | 613 | fc->fe = dvb_attach(lgdt330x_attach, &air2pc_atsc_hd5000_config, i2c); |
| 508 | fc->dev_type = FC_AIR_ATSC3; | 614 | if (fc->fe != NULL) { |
| 509 | dvb_attach(dvb_pll_attach, fc->fe, 0x61, &fc->i2c_adap, DVB_PLL_LG_TDVS_H06XF); | 615 | fc->dev_type = FC_AIR_ATSC3; |
| 510 | info("found the lgdt3303 at i2c address: 0x%02x",air2pc_atsc_hd5000_config.demod_address); | 616 | dvb_attach(simple_tuner_attach, fc->fe, i2c, 0x61, |
| 511 | } else | 617 | TUNER_LG_TDVS_H06XF); |
| 618 | goto fe_found; | ||
| 619 | } | ||
| 620 | |||
| 512 | /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */ | 621 | /* try the air atsc 1nd generation (bcm3510)/panasonic ct10s */ |
| 513 | if ((fc->fe = dvb_attach(bcm3510_attach, &air2pc_atsc_first_gen_config, &fc->i2c_adap)) != NULL) { | 622 | fc->fe = dvb_attach(bcm3510_attach, &air2pc_atsc_first_gen_config, i2c); |
| 514 | fc->dev_type = FC_AIR_ATSC1; | 623 | if (fc->fe != NULL) { |
| 515 | info("found the bcm3510 at i2c address: 0x%02x",air2pc_atsc_first_gen_config.demod_address); | 624 | fc->dev_type = FC_AIR_ATSC1; |
| 516 | } else | 625 | goto fe_found; |
| 626 | } | ||
| 627 | |||
| 517 | /* try the cable dvb (stv0297) */ | 628 | /* try the cable dvb (stv0297) */ |
| 518 | if ((fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, &fc->i2c_adap)) != NULL) { | 629 | fc->fe = dvb_attach(stv0297_attach, &alps_tdee4_stv0297_config, i2c); |
| 519 | fc->dev_type = FC_CABLE; | 630 | if (fc->fe != NULL) { |
| 631 | fc->dev_type = FC_CABLE; | ||
| 520 | fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params; | 632 | fc->fe->ops.tuner_ops.set_params = alps_tdee4_stv0297_tuner_set_params; |
| 521 | info("found the stv0297 at i2c address: 0x%02x",alps_tdee4_stv0297_config.demod_address); | 633 | goto fe_found; |
| 522 | } else | 634 | } |
| 635 | |||
| 523 | /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ | 636 | /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ |
| 524 | if ((fc->fe = dvb_attach(vp310_mt312_attach, &skystar23_samsung_tbdu18132_config, &fc->i2c_adap)) != NULL) { | 637 | fc->fe = dvb_attach(vp310_mt312_attach, |
| 638 | &skystar23_samsung_tbdu18132_config, i2c); | ||
| 639 | if (fc->fe != NULL) { | ||
| 525 | ops = &fc->fe->ops; | 640 | ops = &fc->fe->ops; |
| 526 | 641 | ||
| 527 | ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params; | 642 | ops->tuner_ops.set_params = skystar23_samsung_tbdu18132_tuner_set_params; |
| @@ -535,19 +650,21 @@ int flexcop_frontend_init(struct flexcop_device *fc) | |||
| 535 | ops->sleep = flexcop_sleep; | 650 | ops->sleep = flexcop_sleep; |
| 536 | 651 | ||
| 537 | fc->dev_type = FC_SKY_OLD; | 652 | fc->dev_type = FC_SKY_OLD; |
| 538 | info("found the vp310 (aka mt312) at i2c address: 0x%02x",skystar23_samsung_tbdu18132_config.demod_address); | 653 | goto fe_found; |
| 539 | } | 654 | } |
| 540 | 655 | ||
| 541 | if (fc->fe == NULL) { | 656 | err("no frontend driver found for this B2C2/FlexCop adapter"); |
| 542 | err("no frontend driver found for this B2C2/FlexCop adapter"); | 657 | return -ENODEV; |
| 543 | return -ENODEV; | 658 | |
| 544 | } else { | 659 | fe_found: |
| 545 | if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) { | 660 | info("found '%s' .", fc->fe->ops.info.name); |
| 546 | err("frontend registration failed!"); | 661 | if (dvb_register_frontend(&fc->dvb_adapter, fc->fe)) { |
| 547 | dvb_frontend_detach(fc->fe); | 662 | err("frontend registration failed!"); |
| 548 | fc->fe = NULL; | 663 | ops = &fc->fe->ops; |
| 549 | return -EINVAL; | 664 | if (ops->release != NULL) |
| 550 | } | 665 | ops->release(fc->fe); |
| 666 | fc->fe = NULL; | ||
| 667 | return -EINVAL; | ||
| 551 | } | 668 | } |
| 552 | fc->init_state |= FC_STATE_FE_INIT; | 669 | fc->init_state |= FC_STATE_FE_INIT; |
| 553 | return 0; | 670 | return 0; |
diff --git a/drivers/media/dvb/b2c2/flexcop-i2c.c b/drivers/media/dvb/b2c2/flexcop-i2c.c index 6bf858a436c9..55973eaf3711 100644 --- a/drivers/media/dvb/b2c2/flexcop-i2c.c +++ b/drivers/media/dvb/b2c2/flexcop-i2c.c | |||
| @@ -9,6 +9,8 @@ | |||
| 9 | 9 | ||
| 10 | #define FC_MAX_I2C_RETRIES 100000 | 10 | #define FC_MAX_I2C_RETRIES 100000 |
| 11 | 11 | ||
| 12 | /* #define DUMP_I2C_MESSAGES */ | ||
| 13 | |||
| 12 | static int flexcop_i2c_operation(struct flexcop_device *fc, flexcop_ibi_value *r100) | 14 | static int flexcop_i2c_operation(struct flexcop_device *fc, flexcop_ibi_value *r100) |
| 13 | { | 15 | { |
| 14 | int i; | 16 | int i; |
| @@ -38,30 +40,25 @@ static int flexcop_i2c_operation(struct flexcop_device *fc, flexcop_ibi_value *r | |||
| 38 | return -EREMOTEIO; | 40 | return -EREMOTEIO; |
| 39 | } | 41 | } |
| 40 | 42 | ||
| 41 | static int flexcop_i2c_read4(struct flexcop_device *fc, flexcop_ibi_value r100, u8 *buf) | 43 | static int flexcop_i2c_read4(struct flexcop_i2c_adapter *i2c, |
| 44 | flexcop_ibi_value r100, u8 *buf) | ||
| 42 | { | 45 | { |
| 43 | flexcop_ibi_value r104; | 46 | flexcop_ibi_value r104; |
| 44 | int len = r100.tw_sm_c_100.total_bytes, /* remember total_bytes is buflen-1 */ | 47 | int len = r100.tw_sm_c_100.total_bytes, /* remember total_bytes is buflen-1 */ |
| 45 | ret; | 48 | ret; |
| 46 | 49 | ||
| 47 | if ((ret = flexcop_i2c_operation(fc,&r100)) != 0) { | 50 | r100.tw_sm_c_100.no_base_addr_ack_error = i2c->no_base_addr; |
| 48 | /* The Cablestar needs a different kind of i2c-transfer (does not | 51 | ret = flexcop_i2c_operation(i2c->fc, &r100); |
| 49 | * support "Repeat Start"): | 52 | if (ret != 0) { |
| 50 | * wait for the ACK failure, | 53 | deb_i2c("read failed. %d\n", ret); |
| 51 | * and do a subsequent read with the Bit 30 enabled | 54 | return ret; |
| 52 | */ | ||
| 53 | r100.tw_sm_c_100.no_base_addr_ack_error = 1; | ||
| 54 | if ((ret = flexcop_i2c_operation(fc,&r100)) != 0) { | ||
| 55 | deb_i2c("no_base_addr read failed. %d\n",ret); | ||
| 56 | return ret; | ||
| 57 | } | ||
| 58 | } | 55 | } |
| 59 | 56 | ||
| 60 | buf[0] = r100.tw_sm_c_100.data1_reg; | 57 | buf[0] = r100.tw_sm_c_100.data1_reg; |
| 61 | 58 | ||
| 62 | if (len > 0) { | 59 | if (len > 0) { |
| 63 | r104 = fc->read_ibi_reg(fc,tw_sm_c_104); | 60 | r104 = i2c->fc->read_ibi_reg(i2c->fc, tw_sm_c_104); |
| 64 | deb_i2c("read: r100: %08x, r104: %08x\n",r100.raw,r104.raw); | 61 | deb_i2c("read: r100: %08x, r104: %08x\n", r100.raw, r104.raw); |
| 65 | 62 | ||
| 66 | /* there is at least one more byte, otherwise we wouldn't be here */ | 63 | /* there is at least one more byte, otherwise we wouldn't be here */ |
| 67 | buf[1] = r104.tw_sm_c_104.data2_reg; | 64 | buf[1] = r104.tw_sm_c_104.data2_reg; |
| @@ -85,17 +82,22 @@ static int flexcop_i2c_write4(struct flexcop_device *fc, flexcop_ibi_value r100, | |||
| 85 | r104.tw_sm_c_104.data3_reg = len > 1 ? buf[2] : 0; | 82 | r104.tw_sm_c_104.data3_reg = len > 1 ? buf[2] : 0; |
| 86 | r104.tw_sm_c_104.data4_reg = len > 2 ? buf[3] : 0; | 83 | r104.tw_sm_c_104.data4_reg = len > 2 ? buf[3] : 0; |
| 87 | 84 | ||
| 88 | deb_i2c("write: r100: %08x, r104: %08x\n",r100.raw,r104.raw); | 85 | deb_i2c("write: r100: %08x, r104: %08x\n", r100.raw, r104.raw); |
| 89 | 86 | ||
| 90 | /* write the additional i2c data before doing the actual i2c operation */ | 87 | /* write the additional i2c data before doing the actual i2c operation */ |
| 91 | fc->write_ibi_reg(fc,tw_sm_c_104,r104); | 88 | fc->write_ibi_reg(fc, tw_sm_c_104, r104); |
| 92 | return flexcop_i2c_operation(fc,&r100); | 89 | return flexcop_i2c_operation(fc, &r100); |
| 93 | } | 90 | } |
| 94 | 91 | ||
| 95 | int flexcop_i2c_request(struct flexcop_device *fc, flexcop_access_op_t op, | 92 | int flexcop_i2c_request(struct flexcop_i2c_adapter *i2c, |
| 96 | flexcop_i2c_port_t port, u8 chipaddr, u8 addr, u8 *buf, u16 len) | 93 | flexcop_access_op_t op, u8 chipaddr, u8 addr, u8 *buf, u16 len) |
| 97 | { | 94 | { |
| 98 | int ret; | 95 | int ret; |
| 96 | |||
| 97 | #ifdef DUMP_I2C_MESSAGES | ||
| 98 | int i; | ||
| 99 | #endif | ||
| 100 | |||
| 99 | u16 bytes_to_transfer; | 101 | u16 bytes_to_transfer; |
| 100 | flexcop_ibi_value r100; | 102 | flexcop_ibi_value r100; |
| 101 | 103 | ||
| @@ -103,7 +105,25 @@ int flexcop_i2c_request(struct flexcop_device *fc, flexcop_access_op_t op, | |||
| 103 | r100.raw = 0; | 105 | r100.raw = 0; |
| 104 | r100.tw_sm_c_100.chipaddr = chipaddr; | 106 | r100.tw_sm_c_100.chipaddr = chipaddr; |
| 105 | r100.tw_sm_c_100.twoWS_rw = op; | 107 | r100.tw_sm_c_100.twoWS_rw = op; |
| 106 | r100.tw_sm_c_100.twoWS_port_reg = port; | 108 | r100.tw_sm_c_100.twoWS_port_reg = i2c->port; |
| 109 | |||
| 110 | #ifdef DUMP_I2C_MESSAGES | ||
| 111 | printk(KERN_DEBUG "%d ", i2c->port); | ||
| 112 | if (op == FC_READ) | ||
| 113 | printk("rd("); | ||
| 114 | else | ||
| 115 | printk("wr("); | ||
| 116 | |||
| 117 | printk("%02x): %02x ", chipaddr, addr); | ||
| 118 | #endif | ||
| 119 | |||
| 120 | /* in that case addr is the only value -> | ||
| 121 | * we write it twice as baseaddr and val0 | ||
| 122 | * BBTI is doing it like that for ISL6421 at least */ | ||
| 123 | if (i2c->no_base_addr && len == 0 && op == FC_WRITE) { | ||
| 124 | buf = &addr; | ||
| 125 | len = 1; | ||
| 126 | } | ||
| 107 | 127 | ||
| 108 | while (len != 0) { | 128 | while (len != 0) { |
| 109 | bytes_to_transfer = len > 4 ? 4 : len; | 129 | bytes_to_transfer = len > 4 ? 4 : len; |
| @@ -112,9 +132,14 @@ int flexcop_i2c_request(struct flexcop_device *fc, flexcop_access_op_t op, | |||
| 112 | r100.tw_sm_c_100.baseaddr = addr; | 132 | r100.tw_sm_c_100.baseaddr = addr; |
| 113 | 133 | ||
| 114 | if (op == FC_READ) | 134 | if (op == FC_READ) |
| 115 | ret = flexcop_i2c_read4(fc, r100, buf); | 135 | ret = flexcop_i2c_read4(i2c, r100, buf); |
| 116 | else | 136 | else |
| 117 | ret = flexcop_i2c_write4(fc,r100, buf); | 137 | ret = flexcop_i2c_write4(i2c->fc, r100, buf); |
| 138 | |||
| 139 | #ifdef DUMP_I2C_MESSAGES | ||
| 140 | for (i = 0; i < bytes_to_transfer; i++) | ||
| 141 | printk("%02x ", buf[i]); | ||
| 142 | #endif | ||
| 118 | 143 | ||
| 119 | if (ret < 0) | 144 | if (ret < 0) |
| 120 | return ret; | 145 | return ret; |
| @@ -122,7 +147,11 @@ int flexcop_i2c_request(struct flexcop_device *fc, flexcop_access_op_t op, | |||
| 122 | buf += bytes_to_transfer; | 147 | buf += bytes_to_transfer; |
| 123 | addr += bytes_to_transfer; | 148 | addr += bytes_to_transfer; |
| 124 | len -= bytes_to_transfer; | 149 | len -= bytes_to_transfer; |
| 125 | }; | 150 | } |
| 151 | |||
| 152 | #ifdef DUMP_I2C_MESSAGES | ||
| 153 | printk("\n"); | ||
| 154 | #endif | ||
| 126 | 155 | ||
| 127 | return 0; | 156 | return 0; |
| 128 | } | 157 | } |
| @@ -132,7 +161,7 @@ EXPORT_SYMBOL(flexcop_i2c_request); | |||
| 132 | /* master xfer callback for demodulator */ | 161 | /* master xfer callback for demodulator */ |
| 133 | static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num) | 162 | static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs[], int num) |
| 134 | { | 163 | { |
| 135 | struct flexcop_device *fc = i2c_get_adapdata(i2c_adap); | 164 | struct flexcop_i2c_adapter *i2c = i2c_get_adapdata(i2c_adap); |
| 136 | int i, ret = 0; | 165 | int i, ret = 0; |
| 137 | 166 | ||
| 138 | /* Some drivers use 1 byte or 0 byte reads as probes, which this | 167 | /* Some drivers use 1 byte or 0 byte reads as probes, which this |
| @@ -142,34 +171,29 @@ static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs | |||
| 142 | if (num == 1 && msgs[0].flags == I2C_M_RD && msgs[0].len <= 1) | 171 | if (num == 1 && msgs[0].flags == I2C_M_RD && msgs[0].len <= 1) |
| 143 | return 1; | 172 | return 1; |
| 144 | 173 | ||
| 145 | if (mutex_lock_interruptible(&fc->i2c_mutex)) | 174 | if (mutex_lock_interruptible(&i2c->fc->i2c_mutex)) |
| 146 | return -ERESTARTSYS; | 175 | return -ERESTARTSYS; |
| 147 | 176 | ||
| 148 | /* reading */ | 177 | for (i = 0; i < num; i++) { |
| 149 | if (num == 2 && | 178 | /* reading */ |
| 150 | msgs[0].flags == 0 && | 179 | if (i+1 < num && (msgs[i+1].flags == I2C_M_RD)) { |
| 151 | msgs[1].flags == I2C_M_RD && | 180 | ret = i2c->fc->i2c_request(i2c, FC_READ, msgs[i].addr, |
| 152 | msgs[0].buf != NULL && | 181 | msgs[i].buf[0], msgs[i+1].buf, msgs[i+1].len); |
| 153 | msgs[1].buf != NULL) { | 182 | i++; /* skip the following message */ |
| 154 | 183 | } else /* writing */ | |
| 155 | ret = fc->i2c_request(fc, FC_READ, FC_I2C_PORT_DEMOD, msgs[0].addr, msgs[0].buf[0], msgs[1].buf, msgs[1].len); | 184 | ret = i2c->fc->i2c_request(i2c, FC_WRITE, msgs[i].addr, |
| 156 | 185 | msgs[i].buf[0], &msgs[i].buf[1], | |
| 157 | } else for (i = 0; i < num; i++) { /* writing command */ | 186 | msgs[i].len - 1); |
| 158 | if (msgs[i].flags != 0 || msgs[i].buf == NULL || msgs[i].len < 2) { | 187 | if (ret < 0) { |
| 159 | ret = -EINVAL; | 188 | err("i2c master_xfer failed"); |
| 160 | break; | 189 | break; |
| 161 | } | 190 | } |
| 162 | |||
| 163 | ret = fc->i2c_request(fc, FC_WRITE, FC_I2C_PORT_DEMOD, msgs[i].addr, msgs[i].buf[0], &msgs[i].buf[1], msgs[i].len - 1); | ||
| 164 | } | 191 | } |
| 165 | 192 | ||
| 166 | if (ret < 0) | 193 | mutex_unlock(&i2c->fc->i2c_mutex); |
| 167 | err("i2c master_xfer failed"); | ||
| 168 | else | ||
| 169 | ret = num; | ||
| 170 | |||
| 171 | mutex_unlock(&fc->i2c_mutex); | ||
| 172 | 194 | ||
| 195 | if (ret == 0) | ||
| 196 | ret = num; | ||
| 173 | return ret; | 197 | return ret; |
| 174 | } | 198 | } |
| 175 | 199 | ||
| @@ -189,28 +213,68 @@ int flexcop_i2c_init(struct flexcop_device *fc) | |||
| 189 | 213 | ||
| 190 | mutex_init(&fc->i2c_mutex); | 214 | mutex_init(&fc->i2c_mutex); |
| 191 | 215 | ||
| 192 | memset(&fc->i2c_adap, 0, sizeof(struct i2c_adapter)); | 216 | fc->fc_i2c_adap[0].fc = fc; |
| 193 | strncpy(fc->i2c_adap.name, "B2C2 FlexCop device", | 217 | fc->fc_i2c_adap[1].fc = fc; |
| 194 | sizeof(fc->i2c_adap.name)); | 218 | fc->fc_i2c_adap[2].fc = fc; |
| 195 | 219 | ||
| 196 | i2c_set_adapdata(&fc->i2c_adap,fc); | 220 | fc->fc_i2c_adap[0].port = FC_I2C_PORT_DEMOD; |
| 221 | fc->fc_i2c_adap[1].port = FC_I2C_PORT_EEPROM; | ||
| 222 | fc->fc_i2c_adap[2].port = FC_I2C_PORT_TUNER; | ||
| 223 | |||
| 224 | strncpy(fc->fc_i2c_adap[0].i2c_adap.name, | ||
| 225 | "B2C2 FlexCop I2C to demod", I2C_NAME_SIZE); | ||
| 226 | strncpy(fc->fc_i2c_adap[1].i2c_adap.name, | ||
| 227 | "B2C2 FlexCop I2C to eeprom", I2C_NAME_SIZE); | ||
| 228 | strncpy(fc->fc_i2c_adap[2].i2c_adap.name, | ||
| 229 | "B2C2 FlexCop I2C to tuner", I2C_NAME_SIZE); | ||
| 230 | |||
| 231 | i2c_set_adapdata(&fc->fc_i2c_adap[0].i2c_adap, &fc->fc_i2c_adap[0]); | ||
| 232 | i2c_set_adapdata(&fc->fc_i2c_adap[1].i2c_adap, &fc->fc_i2c_adap[1]); | ||
| 233 | i2c_set_adapdata(&fc->fc_i2c_adap[2].i2c_adap, &fc->fc_i2c_adap[2]); | ||
| 234 | |||
| 235 | fc->fc_i2c_adap[0].i2c_adap.class = | ||
| 236 | fc->fc_i2c_adap[1].i2c_adap.class = | ||
| 237 | fc->fc_i2c_adap[2].i2c_adap.class = I2C_CLASS_TV_DIGITAL; | ||
| 238 | fc->fc_i2c_adap[0].i2c_adap.algo = | ||
| 239 | fc->fc_i2c_adap[1].i2c_adap.algo = | ||
| 240 | fc->fc_i2c_adap[2].i2c_adap.algo = &flexcop_algo; | ||
| 241 | fc->fc_i2c_adap[0].i2c_adap.algo_data = | ||
| 242 | fc->fc_i2c_adap[1].i2c_adap.algo_data = | ||
| 243 | fc->fc_i2c_adap[2].i2c_adap.algo_data = NULL; | ||
| 244 | fc->fc_i2c_adap[0].i2c_adap.dev.parent = | ||
| 245 | fc->fc_i2c_adap[1].i2c_adap.dev.parent = | ||
| 246 | fc->fc_i2c_adap[2].i2c_adap.dev.parent = fc->dev; | ||
| 247 | |||
| 248 | ret = i2c_add_adapter(&fc->fc_i2c_adap[0].i2c_adap); | ||
| 249 | if (ret < 0) | ||
| 250 | return ret; | ||
| 197 | 251 | ||
| 198 | fc->i2c_adap.class = I2C_CLASS_TV_DIGITAL; | 252 | ret = i2c_add_adapter(&fc->fc_i2c_adap[1].i2c_adap); |
| 199 | fc->i2c_adap.algo = &flexcop_algo; | 253 | if (ret < 0) |
| 200 | fc->i2c_adap.algo_data = NULL; | 254 | goto adap_1_failed; |
| 201 | fc->i2c_adap.dev.parent = fc->dev; | ||
| 202 | 255 | ||
| 203 | if ((ret = i2c_add_adapter(&fc->i2c_adap)) < 0) | 256 | ret = i2c_add_adapter(&fc->fc_i2c_adap[2].i2c_adap); |
| 204 | return ret; | 257 | if (ret < 0) |
| 258 | goto adap_2_failed; | ||
| 205 | 259 | ||
| 206 | fc->init_state |= FC_STATE_I2C_INIT; | 260 | fc->init_state |= FC_STATE_I2C_INIT; |
| 207 | return 0; | 261 | return 0; |
| 262 | |||
| 263 | adap_2_failed: | ||
| 264 | i2c_del_adapter(&fc->fc_i2c_adap[1].i2c_adap); | ||
| 265 | adap_1_failed: | ||
| 266 | i2c_del_adapter(&fc->fc_i2c_adap[0].i2c_adap); | ||
| 267 | |||
| 268 | return ret; | ||
| 208 | } | 269 | } |
| 209 | 270 | ||
| 210 | void flexcop_i2c_exit(struct flexcop_device *fc) | 271 | void flexcop_i2c_exit(struct flexcop_device *fc) |
| 211 | { | 272 | { |
| 212 | if (fc->init_state & FC_STATE_I2C_INIT) | 273 | if (fc->init_state & FC_STATE_I2C_INIT) { |
| 213 | i2c_del_adapter(&fc->i2c_adap); | 274 | i2c_del_adapter(&fc->fc_i2c_adap[2].i2c_adap); |
| 275 | i2c_del_adapter(&fc->fc_i2c_adap[1].i2c_adap); | ||
| 276 | i2c_del_adapter(&fc->fc_i2c_adap[0].i2c_adap); | ||
| 277 | } | ||
| 214 | 278 | ||
| 215 | fc->init_state &= ~FC_STATE_I2C_INIT; | 279 | fc->init_state &= ~FC_STATE_I2C_INIT; |
| 216 | } | 280 | } |
diff --git a/drivers/media/dvb/b2c2/flexcop-misc.c b/drivers/media/dvb/b2c2/flexcop-misc.c index 167583bf0621..93d20e56f909 100644 --- a/drivers/media/dvb/b2c2/flexcop-misc.c +++ b/drivers/media/dvb/b2c2/flexcop-misc.c | |||
| @@ -52,6 +52,8 @@ static const char *flexcop_device_names[] = { | |||
| 52 | "Sky2PC/SkyStar 2 DVB-S (old version)", | 52 | "Sky2PC/SkyStar 2 DVB-S (old version)", |
| 53 | "Cable2PC/CableStar 2 DVB-C", | 53 | "Cable2PC/CableStar 2 DVB-C", |
| 54 | "Air2PC/AirStar 2 ATSC 3rd generation (HD5000)", | 54 | "Air2PC/AirStar 2 ATSC 3rd generation (HD5000)", |
| 55 | "Sky2PC/SkyStar 2 DVB-S rev 2.7a/u", | ||
| 56 | "Sky2PC/SkyStar 2 DVB-S rev 2.8", | ||
| 55 | }; | 57 | }; |
| 56 | 58 | ||
| 57 | static const char *flexcop_bus_names[] = { | 59 | static const char *flexcop_bus_names[] = { |
diff --git a/drivers/media/dvb/b2c2/flexcop-pci.c b/drivers/media/dvb/b2c2/flexcop-pci.c index 01af4d237eb1..5b30dfc7846b 100644 --- a/drivers/media/dvb/b2c2/flexcop-pci.c +++ b/drivers/media/dvb/b2c2/flexcop-pci.c | |||
| @@ -32,7 +32,7 @@ MODULE_PARM_DESC(irq_chk_intv, "set the interval for IRQ watchdog (currently jus | |||
| 32 | #define deb_irq(args...) dprintk(0x08,args) | 32 | #define deb_irq(args...) dprintk(0x08,args) |
| 33 | #define deb_chk(args...) dprintk(0x10,args) | 33 | #define deb_chk(args...) dprintk(0x10,args) |
| 34 | 34 | ||
| 35 | static int debug = 0; | 35 | static int debug; |
| 36 | module_param(debug, int, 0644); | 36 | module_param(debug, int, 0644); |
| 37 | MODULE_PARM_DESC(debug, "set debug level (1=info,2=regs,4=TS,8=irqdma (|-able))." DEBSTATUS); | 37 | MODULE_PARM_DESC(debug, "set debug level (1=info,2=regs,4=TS,8=irqdma (|-able))." DEBSTATUS); |
| 38 | 38 | ||
diff --git a/drivers/media/dvb/b2c2/flexcop-reg.h b/drivers/media/dvb/b2c2/flexcop-reg.h index 491f9bd6e195..7599fccc1a5b 100644 --- a/drivers/media/dvb/b2c2/flexcop-reg.h +++ b/drivers/media/dvb/b2c2/flexcop-reg.h | |||
| @@ -25,6 +25,8 @@ typedef enum { | |||
| 25 | FC_SKY_OLD, | 25 | FC_SKY_OLD, |
| 26 | FC_CABLE, | 26 | FC_CABLE, |
| 27 | FC_AIR_ATSC3, | 27 | FC_AIR_ATSC3, |
| 28 | FC_SKY_REV27, | ||
| 29 | FC_SKY_REV28, | ||
| 28 | } flexcop_device_type_t; | 30 | } flexcop_device_type_t; |
| 29 | 31 | ||
| 30 | typedef enum { | 32 | typedef enum { |
diff --git a/drivers/media/dvb/b2c2/flexcop-sram.c b/drivers/media/dvb/b2c2/flexcop-sram.c index 01570ec80962..cda69528548a 100644 --- a/drivers/media/dvb/b2c2/flexcop-sram.c +++ b/drivers/media/dvb/b2c2/flexcop-sram.c | |||
| @@ -90,7 +90,7 @@ static void flexcop_sram_write(struct adapter *adapter, u32 bank, u32 addr, u8 * | |||
| 90 | }; | 90 | }; |
| 91 | 91 | ||
| 92 | if (retries == 0) | 92 | if (retries == 0) |
| 93 | printk("%s: SRAM timeout\n", __FUNCTION__); | 93 | printk("%s: SRAM timeout\n", __func__); |
| 94 | 94 | ||
| 95 | write_reg_dw(adapter, 0x700, command); | 95 | write_reg_dw(adapter, 0x700, command); |
| 96 | 96 | ||
| @@ -115,7 +115,7 @@ static void flex_sram_read(struct adapter *adapter, u32 bank, u32 addr, u8 *buf, | |||
| 115 | }; | 115 | }; |
| 116 | 116 | ||
| 117 | if (retries == 0) | 117 | if (retries == 0) |
| 118 | printk("%s: SRAM timeout\n", __FUNCTION__); | 118 | printk("%s: SRAM timeout\n", __func__); |
| 119 | 119 | ||
| 120 | write_reg_dw(adapter, 0x700, command); | 120 | write_reg_dw(adapter, 0x700, command); |
| 121 | 121 | ||
| @@ -127,7 +127,7 @@ static void flex_sram_read(struct adapter *adapter, u32 bank, u32 addr, u8 *buf, | |||
| 127 | }; | 127 | }; |
| 128 | 128 | ||
| 129 | if (retries == 0) | 129 | if (retries == 0) |
| 130 | printk("%s: SRAM timeout\n", __FUNCTION__); | 130 | printk("%s: SRAM timeout\n", __func__); |
| 131 | 131 | ||
| 132 | value = read_reg_dw(adapter, 0x700) >> 0x10; | 132 | value = read_reg_dw(adapter, 0x700) >> 0x10; |
| 133 | 133 | ||
| @@ -240,13 +240,13 @@ static void sram_init(struct adapter *adapter) | |||
| 240 | 240 | ||
| 241 | adapter->dw_sram_type = tmp & 0x30000; | 241 | adapter->dw_sram_type = tmp & 0x30000; |
| 242 | 242 | ||
| 243 | ddprintk("%s: dw_sram_type = %x\n", __FUNCTION__, adapter->dw_sram_type); | 243 | ddprintk("%s: dw_sram_type = %x\n", __func__, adapter->dw_sram_type); |
| 244 | 244 | ||
| 245 | } else { | 245 | } else { |
| 246 | 246 | ||
| 247 | adapter->dw_sram_type = 0x10000; | 247 | adapter->dw_sram_type = 0x10000; |
| 248 | 248 | ||
| 249 | ddprintk("%s: dw_sram_type = %x\n", __FUNCTION__, adapter->dw_sram_type); | 249 | ddprintk("%s: dw_sram_type = %x\n", __func__, adapter->dw_sram_type); |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | /* return value is never used? */ | 252 | /* return value is never used? */ |
| @@ -257,7 +257,7 @@ static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr) | |||
| 257 | { | 257 | { |
| 258 | u8 tmp1, tmp2; | 258 | u8 tmp1, tmp2; |
| 259 | 259 | ||
| 260 | dprintk("%s: mask = %x, addr = %x\n", __FUNCTION__, mask, addr); | 260 | dprintk("%s: mask = %x, addr = %x\n", __func__, mask, addr); |
| 261 | 261 | ||
| 262 | sram_set_size(adapter, mask); | 262 | sram_set_size(adapter, mask); |
| 263 | sram_init(adapter); | 263 | sram_init(adapter); |
| @@ -275,7 +275,7 @@ static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr) | |||
| 275 | sram_read(adapter, addr, &tmp2, 1); | 275 | sram_read(adapter, addr, &tmp2, 1); |
| 276 | sram_read(adapter, addr, &tmp2, 1); | 276 | sram_read(adapter, addr, &tmp2, 1); |
| 277 | 277 | ||
| 278 | dprintk("%s: wrote 0xa5, read 0x%2x\n", __FUNCTION__, tmp2); | 278 | dprintk("%s: wrote 0xa5, read 0x%2x\n", __func__, tmp2); |
| 279 | 279 | ||
| 280 | if (tmp2 != 0xa5) | 280 | if (tmp2 != 0xa5) |
| 281 | return 0; | 281 | return 0; |
| @@ -293,7 +293,7 @@ static int sram_test_location(struct adapter *adapter, u32 mask, u32 addr) | |||
| 293 | sram_read(adapter, addr, &tmp2, 1); | 293 | sram_read(adapter, addr, &tmp2, 1); |
| 294 | sram_read(adapter, addr, &tmp2, 1); | 294 | sram_read(adapter, addr, &tmp2, 1); |
| 295 | 295 | ||
| 296 | dprintk("%s: wrote 0x5a, read 0x%2x\n", __FUNCTION__, tmp2); | 296 | dprintk("%s: wrote 0x5a, read 0x%2x\n", __func__, tmp2); |
| 297 | 297 | ||
| 298 | if (tmp2 != 0x5a) | 298 | if (tmp2 != 0x5a) |
| 299 | return 0; | 299 | return 0; |
| @@ -340,7 +340,7 @@ static int flexcop_sram_detect(struct flexcop_device *fc) | |||
| 340 | 340 | ||
| 341 | tmp3 = read_reg_dw(adapter, 0x71c); | 341 | tmp3 = read_reg_dw(adapter, 0x71c); |
| 342 | 342 | ||
| 343 | dprintk("%s: tmp3 = %x\n", __FUNCTION__, tmp3); | 343 | dprintk("%s: tmp3 = %x\n", __func__, tmp3); |
| 344 | 344 | ||
| 345 | write_reg_dw(adapter, 0x71c, tmp2); | 345 | write_reg_dw(adapter, 0x71c, tmp2); |
| 346 | 346 | ||
| @@ -351,7 +351,7 @@ static int flexcop_sram_detect(struct flexcop_device *fc) | |||
| 351 | sram_init(adapter); | 351 | sram_init(adapter); |
| 352 | write_reg_dw(adapter, 0x208, tmp); | 352 | write_reg_dw(adapter, 0x208, tmp); |
| 353 | 353 | ||
| 354 | dprintk("%s: sram size = 32K\n", __FUNCTION__); | 354 | dprintk("%s: sram size = 32K\n", __func__); |
| 355 | 355 | ||
| 356 | return 32; | 356 | return 32; |
| 357 | } | 357 | } |
| @@ -361,7 +361,7 @@ static int flexcop_sram_detect(struct flexcop_device *fc) | |||
| 361 | sram_init(adapter); | 361 | sram_init(adapter); |
| 362 | write_reg_dw(adapter, 0x208, tmp); | 362 | write_reg_dw(adapter, 0x208, tmp); |
| 363 | 363 | ||
| 364 | dprintk("%s: sram size = 128K\n", __FUNCTION__); | 364 | dprintk("%s: sram size = 128K\n", __func__); |
| 365 | 365 | ||
| 366 | return 128; | 366 | return 128; |
| 367 | } | 367 | } |
| @@ -371,7 +371,7 @@ static int flexcop_sram_detect(struct flexcop_device *fc) | |||
| 371 | sram_init(adapter); | 371 | sram_init(adapter); |
| 372 | write_reg_dw(adapter, 0x208, tmp); | 372 | write_reg_dw(adapter, 0x208, tmp); |
| 373 | 373 | ||
| 374 | dprintk("%s: sram size = 64K\n", __FUNCTION__); | 374 | dprintk("%s: sram size = 64K\n", __func__); |
| 375 | 375 | ||
| 376 | return 64; | 376 | return 64; |
| 377 | } | 377 | } |
| @@ -381,7 +381,7 @@ static int flexcop_sram_detect(struct flexcop_device *fc) | |||
| 381 | sram_init(adapter); | 381 | sram_init(adapter); |
| 382 | write_reg_dw(adapter, 0x208, tmp); | 382 | write_reg_dw(adapter, 0x208, tmp); |
| 383 | 383 | ||
| 384 | dprintk("%s: sram size = 32K\n", __FUNCTION__); | 384 | dprintk("%s: sram size = 32K\n", __func__); |
| 385 | 385 | ||
| 386 | return 32; | 386 | return 32; |
| 387 | } | 387 | } |
| @@ -390,7 +390,7 @@ static int flexcop_sram_detect(struct flexcop_device *fc) | |||
| 390 | sram_init(adapter); | 390 | sram_init(adapter); |
| 391 | write_reg_dw(adapter, 0x208, tmp); | 391 | write_reg_dw(adapter, 0x208, tmp); |
| 392 | 392 | ||
| 393 | dprintk("%s: SRAM detection failed. Set to 32K \n", __FUNCTION__); | 393 | dprintk("%s: SRAM detection failed. Set to 32K \n", __func__); |
| 394 | 394 | ||
| 395 | return 0; | 395 | return 0; |
| 396 | } | 396 | } |
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c index 87fb75f0d1cf..449fb5c3d0b1 100644 --- a/drivers/media/dvb/b2c2/flexcop-usb.c +++ b/drivers/media/dvb/b2c2/flexcop-usb.c | |||
| @@ -211,10 +211,11 @@ static int flexcop_usb_utility_req(struct flexcop_usb *fc_usb, int set, | |||
| 211 | #endif | 211 | #endif |
| 212 | 212 | ||
| 213 | /* usb i2c stuff */ | 213 | /* usb i2c stuff */ |
| 214 | static int flexcop_usb_i2c_req(struct flexcop_usb *fc_usb, | 214 | static int flexcop_usb_i2c_req(struct flexcop_i2c_adapter *i2c, |
| 215 | flexcop_usb_request_t req, flexcop_usb_i2c_function_t func, | 215 | flexcop_usb_request_t req, flexcop_usb_i2c_function_t func, |
| 216 | flexcop_i2c_port_t port, u8 chipaddr, u8 addr, u8 *buf, u8 buflen) | 216 | u8 chipaddr, u8 addr, u8 *buf, u8 buflen) |
| 217 | { | 217 | { |
| 218 | struct flexcop_usb *fc_usb = i2c->fc->bus_specific; | ||
| 218 | u16 wValue, wIndex; | 219 | u16 wValue, wIndex; |
| 219 | int nWaitTime,pipe,len; | 220 | int nWaitTime,pipe,len; |
| 220 | // u8 dwRequestType; | 221 | // u8 dwRequestType; |
| @@ -242,7 +243,7 @@ static int flexcop_usb_i2c_req(struct flexcop_usb *fc_usb, | |||
| 242 | deb_info("unsupported function for i2c_req %x\n",func); | 243 | deb_info("unsupported function for i2c_req %x\n",func); |
| 243 | return -EINVAL; | 244 | return -EINVAL; |
| 244 | } | 245 | } |
| 245 | wValue = (func << 8 ) | (port << 4); | 246 | wValue = (func << 8) | (i2c->port << 4); |
| 246 | wIndex = (chipaddr << 8 ) | addr; | 247 | wIndex = (chipaddr << 8 ) | addr; |
| 247 | 248 | ||
| 248 | deb_i2c("i2c %2d: %02x %02x %02x %02x %02x %02x\n",func,request_type,req, | 249 | deb_i2c("i2c %2d: %02x %02x %02x %02x %02x %02x\n",func,request_type,req, |
| @@ -274,13 +275,15 @@ static int flexcop_usb_write_ibi_reg(struct flexcop_device *fc, flexcop_ibi_regi | |||
| 274 | return flexcop_usb_readwrite_dw(fc,reg, &val.raw, 0); | 275 | return flexcop_usb_readwrite_dw(fc,reg, &val.raw, 0); |
| 275 | } | 276 | } |
| 276 | 277 | ||
| 277 | static int flexcop_usb_i2c_request(struct flexcop_device *fc, flexcop_access_op_t op, | 278 | static int flexcop_usb_i2c_request(struct flexcop_i2c_adapter *i2c, |
| 278 | flexcop_i2c_port_t port, u8 chipaddr, u8 addr, u8 *buf, u16 len) | 279 | flexcop_access_op_t op, u8 chipaddr, u8 addr, u8 *buf, u16 len) |
| 279 | { | 280 | { |
| 280 | if (op == FC_READ) | 281 | if (op == FC_READ) |
| 281 | return flexcop_usb_i2c_req(fc->bus_specific,B2C2_USB_I2C_REQUEST,USB_FUNC_I2C_READ,port,chipaddr,addr,buf,len); | 282 | return flexcop_usb_i2c_req(i2c, B2C2_USB_I2C_REQUEST, |
| 283 | USB_FUNC_I2C_READ, chipaddr, addr, buf, len); | ||
| 282 | else | 284 | else |
| 283 | return flexcop_usb_i2c_req(fc->bus_specific,B2C2_USB_I2C_REQUEST,USB_FUNC_I2C_WRITE,port,chipaddr,addr,buf,len); | 285 | return flexcop_usb_i2c_req(i2c, B2C2_USB_I2C_REQUEST, |
| 286 | USB_FUNC_I2C_WRITE, chipaddr, addr, buf, len); | ||
| 284 | } | 287 | } |
| 285 | 288 | ||
| 286 | static void flexcop_usb_process_frame(struct flexcop_usb *fc_usb, u8 *buffer, int buffer_length) | 289 | static void flexcop_usb_process_frame(struct flexcop_usb *fc_usb, u8 *buffer, int buffer_length) |
diff --git a/drivers/media/dvb/b2c2/flexcop.c b/drivers/media/dvb/b2c2/flexcop.c index 2ddafd071c97..5f79c8dc3836 100644 --- a/drivers/media/dvb/b2c2/flexcop.c +++ b/drivers/media/dvb/b2c2/flexcop.c | |||
| @@ -49,6 +49,8 @@ module_param_named(debug, b2c2_flexcop_debug, int, 0644); | |||
| 49 | MODULE_PARM_DESC(debug, "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram,32=reg (|-able))." DEBSTATUS); | 49 | MODULE_PARM_DESC(debug, "set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram,32=reg (|-able))." DEBSTATUS); |
| 50 | #undef DEBSTATUS | 50 | #undef DEBSTATUS |
| 51 | 51 | ||
| 52 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 53 | |||
| 52 | /* global zero for ibi values */ | 54 | /* global zero for ibi values */ |
| 53 | flexcop_ibi_value ibi_zero; | 55 | flexcop_ibi_value ibi_zero; |
| 54 | 56 | ||
| @@ -66,8 +68,10 @@ static int flexcop_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) | |||
| 66 | 68 | ||
| 67 | static int flexcop_dvb_init(struct flexcop_device *fc) | 69 | static int flexcop_dvb_init(struct flexcop_device *fc) |
| 68 | { | 70 | { |
| 69 | int ret; | 71 | int ret = dvb_register_adapter(&fc->dvb_adapter, |
| 70 | if ((ret = dvb_register_adapter(&fc->dvb_adapter,"FlexCop Digital TV device",fc->owner,fc->dev)) < 0) { | 72 | "FlexCop Digital TV device", fc->owner, |
| 73 | fc->dev, adapter_nr); | ||
| 74 | if (ret < 0) { | ||
| 71 | err("error registering DVB adapter"); | 75 | err("error registering DVB adapter"); |
| 72 | return ret; | 76 | return ret; |
| 73 | } | 77 | } |
| @@ -257,6 +261,12 @@ int flexcop_device_initialize(struct flexcop_device *fc) | |||
| 257 | if ((ret = flexcop_dvb_init(fc))) | 261 | if ((ret = flexcop_dvb_init(fc))) |
| 258 | goto error; | 262 | goto error; |
| 259 | 263 | ||
| 264 | /* i2c has to be done before doing EEProm stuff - | ||
| 265 | * because the EEProm is accessed via i2c */ | ||
| 266 | ret = flexcop_i2c_init(fc); | ||
| 267 | if (ret) | ||
| 268 | goto error; | ||
| 269 | |||
| 260 | /* do the MAC address reading after initializing the dvb_adapter */ | 270 | /* do the MAC address reading after initializing the dvb_adapter */ |
| 261 | if (fc->get_mac_addr(fc, 0) == 0) { | 271 | if (fc->get_mac_addr(fc, 0) == 0) { |
| 262 | u8 *b = fc->dvb_adapter.proposed_mac; | 272 | u8 *b = fc->dvb_adapter.proposed_mac; |
| @@ -266,10 +276,6 @@ int flexcop_device_initialize(struct flexcop_device *fc) | |||
| 266 | } else | 276 | } else |
| 267 | warn("reading of MAC address failed.\n"); | 277 | warn("reading of MAC address failed.\n"); |
| 268 | 278 | ||
| 269 | |||
| 270 | if ((ret = flexcop_i2c_init(fc))) | ||
| 271 | goto error; | ||
| 272 | |||
| 273 | if ((ret = flexcop_frontend_init(fc))) | 279 | if ((ret = flexcop_frontend_init(fc))) |
| 274 | goto error; | 280 | goto error; |
| 275 | 281 | ||
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig index ea666174e988..902c762e0b7f 100644 --- a/drivers/media/dvb/bt8xx/Kconfig +++ b/drivers/media/dvb/bt8xx/Kconfig | |||
| @@ -7,8 +7,8 @@ config DVB_BT8XX | |||
| 7 | select DVB_CX24110 if !DVB_FE_CUSTOMISE | 7 | select DVB_CX24110 if !DVB_FE_CUSTOMISE |
| 8 | select DVB_OR51211 if !DVB_FE_CUSTOMISE | 8 | select DVB_OR51211 if !DVB_FE_CUSTOMISE |
| 9 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE | 9 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE |
| 10 | select DVB_PLL if !DVB_FE_CUSTOMISE | ||
| 11 | select DVB_ZL10353 if !DVB_FE_CUSTOMISE | 10 | select DVB_ZL10353 if !DVB_FE_CUSTOMISE |
| 11 | select TUNER_SIMPLE if !DVB_FE_CUSTOMISE | ||
| 12 | select FW_LOADER | 12 | select FW_LOADER |
| 13 | help | 13 | help |
| 14 | Support for PCI cards based on the Bt8xx PCI bridge. Examples are | 14 | Support for PCI cards based on the Bt8xx PCI bridge. Examples are |
diff --git a/drivers/media/dvb/bt8xx/Makefile b/drivers/media/dvb/bt8xx/Makefile index 84cf70504d17..9d3e68b5d6eb 100644 --- a/drivers/media/dvb/bt8xx/Makefile +++ b/drivers/media/dvb/bt8xx/Makefile | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | obj-$(CONFIG_DVB_BT8XX) += bt878.o dvb-bt8xx.o dst.o dst_ca.o | 1 | obj-$(CONFIG_DVB_BT8XX) += bt878.o dvb-bt8xx.o dst.o dst_ca.o |
| 2 | 2 | ||
| 3 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core/ -Idrivers/media/video/bt8xx -Idrivers/media/dvb/frontends | 3 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core |
| 4 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends | ||
| 5 | EXTRA_CFLAGS += -Idrivers/media/video/bt8xx | ||
| 6 | EXTRA_CFLAGS += -Idrivers/media/video | ||
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c index 307ff35bdf13..75711bde23ad 100644 --- a/drivers/media/dvb/bt8xx/dst.c +++ b/drivers/media/dvb/bt8xx/dst.c | |||
| @@ -1290,7 +1290,7 @@ static int dst_get_signal(struct dst_state *state) | |||
| 1290 | { | 1290 | { |
| 1291 | int retval; | 1291 | int retval; |
| 1292 | u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; | 1292 | u8 get_signal[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb }; |
| 1293 | //dprintk("%s: Getting Signal strength and other parameters\n", __FUNCTION__); | 1293 | //dprintk("%s: Getting Signal strength and other parameters\n", __func__); |
| 1294 | if ((state->diseq_flags & ATTEMPT_TUNE) == 0) { | 1294 | if ((state->diseq_flags & ATTEMPT_TUNE) == 0) { |
| 1295 | state->decode_lock = state->decode_strength = state->decode_snr = 0; | 1295 | state->decode_lock = state->decode_strength = state->decode_snr = 0; |
| 1296 | return 0; | 1296 | return 0; |
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c index 50bc32a8bd55..0258451423ad 100644 --- a/drivers/media/dvb/bt8xx/dst_ca.c +++ b/drivers/media/dvb/bt8xx/dst_ca.c | |||
| @@ -36,13 +36,13 @@ | |||
| 36 | #define dprintk(x, y, z, format, arg...) do { \ | 36 | #define dprintk(x, y, z, format, arg...) do { \ |
| 37 | if (z) { \ | 37 | if (z) { \ |
| 38 | if ((x > DST_CA_ERROR) && (x > y)) \ | 38 | if ((x > DST_CA_ERROR) && (x > y)) \ |
| 39 | printk(KERN_ERR "%s: " format "\n", __FUNCTION__ , ##arg); \ | 39 | printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \ |
| 40 | else if ((x > DST_CA_NOTICE) && (x > y)) \ | 40 | else if ((x > DST_CA_NOTICE) && (x > y)) \ |
| 41 | printk(KERN_NOTICE "%s: " format "\n", __FUNCTION__ , ##arg); \ | 41 | printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \ |
| 42 | else if ((x > DST_CA_INFO) && (x > y)) \ | 42 | else if ((x > DST_CA_INFO) && (x > y)) \ |
| 43 | printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##arg); \ | 43 | printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \ |
| 44 | else if ((x > DST_CA_DEBUG) && (x > y)) \ | 44 | else if ((x > DST_CA_DEBUG) && (x > y)) \ |
| 45 | printk(KERN_DEBUG "%s: " format "\n", __FUNCTION__ , ##arg); \ | 45 | printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \ |
| 46 | } else { \ | 46 | } else { \ |
| 47 | if (x > y) \ | 47 | if (x > y) \ |
| 48 | printk(format, ## arg); \ | 48 | printk(format, ## arg); \ |
| @@ -162,7 +162,7 @@ static int ca_get_app_info(struct dst_state *state) | |||
| 162 | dprintk(verbose, DST_CA_INFO, 1, " ================================ CI Module Application Info ======================================"); | 162 | dprintk(verbose, DST_CA_INFO, 1, " ================================ CI Module Application Info ======================================"); |
| 163 | dprintk(verbose, DST_CA_INFO, 1, " Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]", | 163 | dprintk(verbose, DST_CA_INFO, 1, " Application Type=[%d], Application Vendor=[%d], Vendor Code=[%d]\n%s: Application info=[%s]", |
| 164 | state->messages[7], (state->messages[8] << 8) | state->messages[9], | 164 | state->messages[7], (state->messages[8] << 8) | state->messages[9], |
| 165 | (state->messages[10] << 8) | state->messages[11], __FUNCTION__, (char *)(&state->messages[12])); | 165 | (state->messages[10] << 8) | state->messages[11], __func__, (char *)(&state->messages[12])); |
| 166 | dprintk(verbose, DST_CA_INFO, 1, " =================================================================================================="); | 166 | dprintk(verbose, DST_CA_INFO, 1, " =================================================================================================="); |
| 167 | 167 | ||
| 168 | // Transform dst message to correct application_info message | 168 | // Transform dst message to correct application_info message |
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c index dedd30a8356b..6afbfbbef0ce 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c | |||
| @@ -40,10 +40,12 @@ static int debug; | |||
| 40 | module_param(debug, int, 0644); | 40 | module_param(debug, int, 0644); |
| 41 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); | 41 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); |
| 42 | 42 | ||
| 43 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 44 | |||
| 43 | #define dprintk( args... ) \ | 45 | #define dprintk( args... ) \ |
| 44 | do \ | 46 | do { \ |
| 45 | if (debug) printk(KERN_DEBUG args); \ | 47 | if (debug) printk(KERN_DEBUG args); \ |
| 46 | while (0) | 48 | } while (0) |
| 47 | 49 | ||
| 48 | #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ | 50 | #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */ |
| 49 | 51 | ||
| @@ -609,8 +611,9 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) | |||
| 609 | lgdt330x_reset(card); | 611 | lgdt330x_reset(card); |
| 610 | card->fe = dvb_attach(lgdt330x_attach, &tdvs_tua6034_config, card->i2c_adapter); | 612 | card->fe = dvb_attach(lgdt330x_attach, &tdvs_tua6034_config, card->i2c_adapter); |
| 611 | if (card->fe != NULL) { | 613 | if (card->fe != NULL) { |
| 612 | dvb_attach(dvb_pll_attach, card->fe, 0x61, | 614 | dvb_attach(simple_tuner_attach, card->fe, |
| 613 | card->i2c_adapter, DVB_PLL_LG_TDVS_H06XF); | 615 | card->i2c_adapter, 0x61, |
| 616 | TUNER_LG_TDVS_H06XF); | ||
| 614 | dprintk ("dvb_bt8xx: lgdt330x detected\n"); | 617 | dprintk ("dvb_bt8xx: lgdt330x detected\n"); |
| 615 | } | 618 | } |
| 616 | break; | 619 | break; |
| @@ -670,7 +673,7 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) | |||
| 670 | state->dst_ca = NULL; | 673 | state->dst_ca = NULL; |
| 671 | /* DST is not a frontend, attaching the ASIC */ | 674 | /* DST is not a frontend, attaching the ASIC */ |
| 672 | if (dvb_attach(dst_attach, state, &card->dvb_adapter) == NULL) { | 675 | if (dvb_attach(dst_attach, state, &card->dvb_adapter) == NULL) { |
| 673 | printk("%s: Could not find a Twinhan DST.\n", __FUNCTION__); | 676 | printk("%s: Could not find a Twinhan DST.\n", __func__); |
| 674 | break; | 677 | break; |
| 675 | } | 678 | } |
| 676 | /* Attach other DST peripherals if any */ | 679 | /* Attach other DST peripherals if any */ |
| @@ -692,8 +695,9 @@ static void frontend_init(struct dvb_bt8xx_card *card, u32 type) | |||
| 692 | case BTTV_BOARD_PC_HDTV: | 695 | case BTTV_BOARD_PC_HDTV: |
| 693 | card->fe = dvb_attach(or51211_attach, &or51211_config, card->i2c_adapter); | 696 | card->fe = dvb_attach(or51211_attach, &or51211_config, card->i2c_adapter); |
| 694 | if (card->fe != NULL) | 697 | if (card->fe != NULL) |
| 695 | dvb_attach(dvb_pll_attach, card->fe, 0x61, | 698 | dvb_attach(simple_tuner_attach, card->fe, |
| 696 | card->i2c_adapter, DVB_PLL_FCV1236D); | 699 | card->i2c_adapter, 0x61, |
| 700 | TUNER_PHILIPS_FCV1236D); | ||
| 697 | break; | 701 | break; |
| 698 | } | 702 | } |
| 699 | 703 | ||
| @@ -715,7 +719,10 @@ static int __devinit dvb_bt8xx_load_card(struct dvb_bt8xx_card *card, u32 type) | |||
| 715 | { | 719 | { |
| 716 | int result; | 720 | int result; |
| 717 | 721 | ||
| 718 | if ((result = dvb_register_adapter(&card->dvb_adapter, card->card_name, THIS_MODULE, &card->bt->dev->dev)) < 0) { | 722 | result = dvb_register_adapter(&card->dvb_adapter, card->card_name, |
| 723 | THIS_MODULE, &card->bt->dev->dev, | ||
| 724 | adapter_nr); | ||
| 725 | if (result < 0) { | ||
| 719 | printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result); | 726 | printk("dvb_bt8xx: dvb_register_adapter failed (errno = %d)\n", result); |
| 720 | return result; | 727 | return result; |
| 721 | } | 728 | } |
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.h b/drivers/media/dvb/bt8xx/dvb-bt8xx.h index 436880e68672..4499ed2ac0ed 100644 --- a/drivers/media/dvb/bt8xx/dvb-bt8xx.h +++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.h | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | #include "or51211.h" | 38 | #include "or51211.h" |
| 39 | #include "lgdt330x.h" | 39 | #include "lgdt330x.h" |
| 40 | #include "zl10353.h" | 40 | #include "zl10353.h" |
| 41 | #include "dvb-pll.h" | 41 | #include "tuner-simple.h" |
| 42 | 42 | ||
| 43 | struct dvb_bt8xx_card { | 43 | struct dvb_bt8xx_card { |
| 44 | struct mutex lock; | 44 | struct mutex lock; |
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c index db08b0a8888a..f5010e8671b8 100644 --- a/drivers/media/dvb/cinergyT2/cinergyT2.c +++ b/drivers/media/dvb/cinergyT2/cinergyT2.c | |||
| @@ -58,11 +58,13 @@ static int debug; | |||
| 58 | module_param_named(debug, debug, int, 0644); | 58 | module_param_named(debug, debug, int, 0644); |
| 59 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); | 59 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); |
| 60 | 60 | ||
| 61 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 62 | |||
| 61 | #define dprintk(level, args...) \ | 63 | #define dprintk(level, args...) \ |
| 62 | do { \ | 64 | do { \ |
| 63 | if ((debug & level)) { \ | 65 | if ((debug & level)) { \ |
| 64 | printk("%s: %s(): ", KBUILD_MODNAME, \ | 66 | printk("%s: %s(): ", KBUILD_MODNAME, \ |
| 65 | __FUNCTION__); \ | 67 | __func__); \ |
| 66 | printk(args); } \ | 68 | printk(args); } \ |
| 67 | } while (0) | 69 | } while (0) |
| 68 | 70 | ||
| @@ -938,7 +940,10 @@ static int cinergyt2_probe (struct usb_interface *intf, | |||
| 938 | return -ENOMEM; | 940 | return -ENOMEM; |
| 939 | } | 941 | } |
| 940 | 942 | ||
| 941 | if ((err = dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, THIS_MODULE, &cinergyt2->udev->dev)) < 0) { | 943 | err = dvb_register_adapter(&cinergyt2->adapter, DRIVER_NAME, |
| 944 | THIS_MODULE, &cinergyt2->udev->dev, | ||
| 945 | adapter_nr); | ||
| 946 | if (err < 0) { | ||
| 942 | kfree(cinergyt2); | 947 | kfree(cinergyt2); |
| 943 | return err; | 948 | return err; |
| 944 | } | 949 | } |
diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h index 0c1d87c5227a..b0d347daae47 100644 --- a/drivers/media/dvb/dvb-core/demux.h +++ b/drivers/media/dvb/dvb-core/demux.h | |||
| @@ -80,6 +80,8 @@ enum dmx_success { | |||
| 80 | #define TS_PAYLOAD_ONLY 2 /* in case TS_PACKET is set, only send the TS | 80 | #define TS_PAYLOAD_ONLY 2 /* in case TS_PACKET is set, only send the TS |
| 81 | payload (<=184 bytes per packet) to callback */ | 81 | payload (<=184 bytes per packet) to callback */ |
| 82 | #define TS_DECODER 4 /* send stream to built-in decoder (if present) */ | 82 | #define TS_DECODER 4 /* send stream to built-in decoder (if present) */ |
| 83 | #define TS_DEMUX 8 /* in case TS_PACKET is set, send the TS to | ||
| 84 | the demux device, not to the dvr device */ | ||
| 83 | 85 | ||
| 84 | /* PES type for filters which write to built-in decoder */ | 86 | /* PES type for filters which write to built-in decoder */ |
| 85 | /* these should be kept identical to the types in dmx.h */ | 87 | /* these should be kept identical to the types in dmx.h */ |
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index f94bc31e3b33..df5bef6a2517 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c | |||
| @@ -126,7 +126,7 @@ static int dvb_dvr_open(struct inode *inode, struct file *file) | |||
| 126 | struct dmxdev *dmxdev = dvbdev->priv; | 126 | struct dmxdev *dmxdev = dvbdev->priv; |
| 127 | struct dmx_frontend *front; | 127 | struct dmx_frontend *front; |
| 128 | 128 | ||
| 129 | dprintk("function : %s\n", __FUNCTION__); | 129 | dprintk("function : %s\n", __func__); |
| 130 | 130 | ||
| 131 | if (mutex_lock_interruptible(&dmxdev->mutex)) | 131 | if (mutex_lock_interruptible(&dmxdev->mutex)) |
| 132 | return -ERESTARTSYS; | 132 | return -ERESTARTSYS; |
| @@ -259,6 +259,39 @@ static ssize_t dvb_dvr_read(struct file *file, char __user *buf, size_t count, | |||
| 259 | return ret; | 259 | return ret; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | static int dvb_dvr_set_buffer_size(struct dmxdev *dmxdev, | ||
| 263 | unsigned long size) | ||
| 264 | { | ||
| 265 | struct dvb_ringbuffer *buf = &dmxdev->dvr_buffer; | ||
| 266 | void *newmem; | ||
| 267 | void *oldmem; | ||
| 268 | |||
| 269 | dprintk("function : %s\n", __func__); | ||
| 270 | |||
| 271 | if (buf->size == size) | ||
| 272 | return 0; | ||
| 273 | if (!size) | ||
| 274 | return -EINVAL; | ||
| 275 | |||
| 276 | newmem = vmalloc(size); | ||
| 277 | if (!newmem) | ||
| 278 | return -ENOMEM; | ||
| 279 | |||
| 280 | oldmem = buf->data; | ||
| 281 | |||
| 282 | spin_lock_irq(&dmxdev->lock); | ||
| 283 | buf->data = newmem; | ||
| 284 | buf->size = size; | ||
| 285 | |||
| 286 | /* reset and not flush in case the buffer shrinks */ | ||
| 287 | dvb_ringbuffer_reset(buf); | ||
| 288 | spin_unlock_irq(&dmxdev->lock); | ||
| 289 | |||
| 290 | vfree(oldmem); | ||
| 291 | |||
| 292 | return 0; | ||
| 293 | } | ||
| 294 | |||
| 262 | static inline void dvb_dmxdev_filter_state_set(struct dmxdev_filter | 295 | static inline void dvb_dmxdev_filter_state_set(struct dmxdev_filter |
| 263 | *dmxdevfilter, int state) | 296 | *dmxdevfilter, int state) |
| 264 | { | 297 | { |
| @@ -271,28 +304,32 @@ static int dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter, | |||
| 271 | unsigned long size) | 304 | unsigned long size) |
| 272 | { | 305 | { |
| 273 | struct dvb_ringbuffer *buf = &dmxdevfilter->buffer; | 306 | struct dvb_ringbuffer *buf = &dmxdevfilter->buffer; |
| 274 | void *mem; | 307 | void *newmem; |
| 308 | void *oldmem; | ||
| 275 | 309 | ||
| 276 | if (buf->size == size) | 310 | if (buf->size == size) |
| 277 | return 0; | 311 | return 0; |
| 312 | if (!size) | ||
| 313 | return -EINVAL; | ||
| 278 | if (dmxdevfilter->state >= DMXDEV_STATE_GO) | 314 | if (dmxdevfilter->state >= DMXDEV_STATE_GO) |
| 279 | return -EBUSY; | 315 | return -EBUSY; |
| 316 | |||
| 317 | newmem = vmalloc(size); | ||
| 318 | if (!newmem) | ||
| 319 | return -ENOMEM; | ||
| 320 | |||
| 321 | oldmem = buf->data; | ||
| 322 | |||
| 280 | spin_lock_irq(&dmxdevfilter->dev->lock); | 323 | spin_lock_irq(&dmxdevfilter->dev->lock); |
| 281 | mem = buf->data; | 324 | buf->data = newmem; |
| 282 | buf->data = NULL; | ||
| 283 | buf->size = size; | 325 | buf->size = size; |
| 284 | dvb_ringbuffer_flush(buf); | 326 | |
| 327 | /* reset and not flush in case the buffer shrinks */ | ||
| 328 | dvb_ringbuffer_reset(buf); | ||
| 285 | spin_unlock_irq(&dmxdevfilter->dev->lock); | 329 | spin_unlock_irq(&dmxdevfilter->dev->lock); |
| 286 | vfree(mem); | ||
| 287 | 330 | ||
| 288 | if (buf->size) { | 331 | vfree(oldmem); |
| 289 | mem = vmalloc(dmxdevfilter->buffer.size); | 332 | |
| 290 | if (!mem) | ||
| 291 | return -ENOMEM; | ||
| 292 | spin_lock_irq(&dmxdevfilter->dev->lock); | ||
| 293 | buf->data = mem; | ||
| 294 | spin_unlock_irq(&dmxdevfilter->dev->lock); | ||
| 295 | } | ||
| 296 | return 0; | 333 | return 0; |
| 297 | } | 334 | } |
| 298 | 335 | ||
| @@ -374,7 +411,8 @@ static int dvb_dmxdev_ts_callback(const u8 *buffer1, size_t buffer1_len, | |||
| 374 | return 0; | 411 | return 0; |
| 375 | } | 412 | } |
| 376 | 413 | ||
| 377 | if (dmxdevfilter->params.pes.output == DMX_OUT_TAP) | 414 | if (dmxdevfilter->params.pes.output == DMX_OUT_TAP |
| 415 | || dmxdevfilter->params.pes.output == DMX_OUT_TSDEMUX_TAP) | ||
| 378 | buffer = &dmxdevfilter->buffer; | 416 | buffer = &dmxdevfilter->buffer; |
| 379 | else | 417 | else |
| 380 | buffer = &dmxdevfilter->dev->dvr_buffer; | 418 | buffer = &dmxdevfilter->dev->dvr_buffer; |
| @@ -550,7 +588,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) | |||
| 550 | dvb_dmxdev_section_callback); | 588 | dvb_dmxdev_section_callback); |
| 551 | if (ret < 0) { | 589 | if (ret < 0) { |
| 552 | printk("DVB (%s): could not alloc feed\n", | 590 | printk("DVB (%s): could not alloc feed\n", |
| 553 | __FUNCTION__); | 591 | __func__); |
| 554 | return ret; | 592 | return ret; |
| 555 | } | 593 | } |
| 556 | 594 | ||
| @@ -558,7 +596,7 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) | |||
| 558 | (para->flags & DMX_CHECK_CRC) ? 1 : 0); | 596 | (para->flags & DMX_CHECK_CRC) ? 1 : 0); |
| 559 | if (ret < 0) { | 597 | if (ret < 0) { |
| 560 | printk("DVB (%s): could not set feed\n", | 598 | printk("DVB (%s): could not set feed\n", |
| 561 | __FUNCTION__); | 599 | __func__); |
| 562 | dvb_dmxdev_feed_restart(filter); | 600 | dvb_dmxdev_feed_restart(filter); |
| 563 | return ret; | 601 | return ret; |
| 564 | } | 602 | } |
| @@ -620,9 +658,10 @@ static int dvb_dmxdev_filter_start(struct dmxdev_filter *filter) | |||
| 620 | 658 | ||
| 621 | if (otype == DMX_OUT_TS_TAP) | 659 | if (otype == DMX_OUT_TS_TAP) |
| 622 | ts_type |= TS_PACKET; | 660 | ts_type |= TS_PACKET; |
| 623 | 661 | else if (otype == DMX_OUT_TSDEMUX_TAP) | |
| 624 | if (otype == DMX_OUT_TAP) | 662 | ts_type |= TS_PACKET | TS_DEMUX; |
| 625 | ts_type |= TS_PAYLOAD_ONLY | TS_PACKET; | 663 | else if (otype == DMX_OUT_TAP) |
| 664 | ts_type |= TS_PACKET | TS_DEMUX | TS_PAYLOAD_ONLY; | ||
| 626 | 665 | ||
| 627 | ret = dmxdev->demux->allocate_ts_feed(dmxdev->demux, | 666 | ret = dmxdev->demux->allocate_ts_feed(dmxdev->demux, |
| 628 | tsfeed, | 667 | tsfeed, |
| @@ -732,7 +771,7 @@ static int dvb_dmxdev_filter_set(struct dmxdev *dmxdev, | |||
| 732 | struct dmxdev_filter *dmxdevfilter, | 771 | struct dmxdev_filter *dmxdevfilter, |
| 733 | struct dmx_sct_filter_params *params) | 772 | struct dmx_sct_filter_params *params) |
| 734 | { | 773 | { |
| 735 | dprintk("function : %s\n", __FUNCTION__); | 774 | dprintk("function : %s\n", __func__); |
| 736 | 775 | ||
| 737 | dvb_dmxdev_filter_stop(dmxdevfilter); | 776 | dvb_dmxdev_filter_stop(dmxdevfilter); |
| 738 | 777 | ||
| @@ -1007,6 +1046,7 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file, | |||
| 1007 | { | 1046 | { |
| 1008 | struct dvb_device *dvbdev = file->private_data; | 1047 | struct dvb_device *dvbdev = file->private_data; |
| 1009 | struct dmxdev *dmxdev = dvbdev->priv; | 1048 | struct dmxdev *dmxdev = dvbdev->priv; |
| 1049 | unsigned long arg = (unsigned long)parg; | ||
| 1010 | int ret; | 1050 | int ret; |
| 1011 | 1051 | ||
| 1012 | if (mutex_lock_interruptible(&dmxdev->mutex)) | 1052 | if (mutex_lock_interruptible(&dmxdev->mutex)) |
| @@ -1014,8 +1054,7 @@ static int dvb_dvr_do_ioctl(struct inode *inode, struct file *file, | |||
| 1014 | 1054 | ||
| 1015 | switch (cmd) { | 1055 | switch (cmd) { |
| 1016 | case DMX_SET_BUFFER_SIZE: | 1056 | case DMX_SET_BUFFER_SIZE: |
| 1017 | // FIXME: implement | 1057 | ret = dvb_dvr_set_buffer_size(dmxdev, arg); |
| 1018 | ret = 0; | ||
| 1019 | break; | 1058 | break; |
| 1020 | 1059 | ||
| 1021 | default: | 1060 | default: |
| @@ -1038,7 +1077,7 @@ static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait) | |||
| 1038 | struct dmxdev *dmxdev = dvbdev->priv; | 1077 | struct dmxdev *dmxdev = dvbdev->priv; |
| 1039 | unsigned int mask = 0; | 1078 | unsigned int mask = 0; |
| 1040 | 1079 | ||
| 1041 | dprintk("function : %s\n", __FUNCTION__); | 1080 | dprintk("function : %s\n", __func__); |
| 1042 | 1081 | ||
| 1043 | poll_wait(file, &dmxdev->dvr_buffer.queue, wait); | 1082 | poll_wait(file, &dmxdev->dvr_buffer.queue, wait); |
| 1044 | 1083 | ||
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 89437fdab8be..8cbdb0ec67e2 100644 --- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c | |||
| @@ -250,7 +250,7 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot, | |||
| 250 | unsigned long timeout; | 250 | unsigned long timeout; |
| 251 | unsigned long start; | 251 | unsigned long start; |
| 252 | 252 | ||
| 253 | dprintk("%s\n", __FUNCTION__); | 253 | dprintk("%s\n", __func__); |
| 254 | 254 | ||
| 255 | /* loop until timeout elapsed */ | 255 | /* loop until timeout elapsed */ |
| 256 | start = jiffies; | 256 | start = jiffies; |
| @@ -263,7 +263,7 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot, | |||
| 263 | 263 | ||
| 264 | /* if we got the flags, it was successful! */ | 264 | /* if we got the flags, it was successful! */ |
| 265 | if (res & waitfor) { | 265 | if (res & waitfor) { |
| 266 | dprintk("%s succeeded timeout:%lu\n", __FUNCTION__, jiffies - start); | 266 | dprintk("%s succeeded timeout:%lu\n", __func__, jiffies - start); |
| 267 | return 0; | 267 | return 0; |
| 268 | } | 268 | } |
| 269 | 269 | ||
| @@ -276,7 +276,7 @@ static int dvb_ca_en50221_wait_if_status(struct dvb_ca_private *ca, int slot, | |||
| 276 | msleep(1); | 276 | msleep(1); |
| 277 | } | 277 | } |
| 278 | 278 | ||
| 279 | dprintk("%s failed timeout:%lu\n", __FUNCTION__, jiffies - start); | 279 | dprintk("%s failed timeout:%lu\n", __func__, jiffies - start); |
| 280 | 280 | ||
| 281 | /* if we get here, we've timed out */ | 281 | /* if we get here, we've timed out */ |
| 282 | return -ETIMEDOUT; | 282 | return -ETIMEDOUT; |
| @@ -297,7 +297,7 @@ static int dvb_ca_en50221_link_init(struct dvb_ca_private *ca, int slot) | |||
| 297 | int buf_size; | 297 | int buf_size; |
| 298 | u8 buf[2]; | 298 | u8 buf[2]; |
| 299 | 299 | ||
| 300 | dprintk("%s\n", __FUNCTION__); | 300 | dprintk("%s\n", __func__); |
| 301 | 301 | ||
| 302 | /* we'll be determining these during this function */ | 302 | /* we'll be determining these during this function */ |
| 303 | ca->slot_info[slot].da_irq_supported = 0; | 303 | ca->slot_info[slot].da_irq_supported = 0; |
| @@ -549,7 +549,7 @@ static int dvb_ca_en50221_set_configoption(struct dvb_ca_private *ca, int slot) | |||
| 549 | { | 549 | { |
| 550 | int configoption; | 550 | int configoption; |
| 551 | 551 | ||
| 552 | dprintk("%s\n", __FUNCTION__); | 552 | dprintk("%s\n", __func__); |
| 553 | 553 | ||
| 554 | /* set the config option */ | 554 | /* set the config option */ |
| 555 | ca->pub->write_attribute_mem(ca->pub, slot, | 555 | ca->pub->write_attribute_mem(ca->pub, slot, |
| @@ -587,7 +587,7 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb | |||
| 587 | u8 buf[HOST_LINK_BUF_SIZE]; | 587 | u8 buf[HOST_LINK_BUF_SIZE]; |
| 588 | int i; | 588 | int i; |
| 589 | 589 | ||
| 590 | dprintk("%s\n", __FUNCTION__); | 590 | dprintk("%s\n", __func__); |
| 591 | 591 | ||
| 592 | /* check if we have space for a link buf in the rx_buffer */ | 592 | /* check if we have space for a link buf in the rx_buffer */ |
| 593 | if (ebuf == NULL) { | 593 | if (ebuf == NULL) { |
| @@ -708,7 +708,7 @@ static int dvb_ca_en50221_write_data(struct dvb_ca_private *ca, int slot, u8 * b | |||
| 708 | int status; | 708 | int status; |
| 709 | int i; | 709 | int i; |
| 710 | 710 | ||
| 711 | dprintk("%s\n", __FUNCTION__); | 711 | dprintk("%s\n", __func__); |
| 712 | 712 | ||
| 713 | 713 | ||
| 714 | // sanity check | 714 | // sanity check |
| @@ -785,7 +785,7 @@ EXPORT_SYMBOL(dvb_ca_en50221_camchange_irq); | |||
| 785 | */ | 785 | */ |
| 786 | static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot) | 786 | static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot) |
| 787 | { | 787 | { |
| 788 | dprintk("%s\n", __FUNCTION__); | 788 | dprintk("%s\n", __func__); |
| 789 | 789 | ||
| 790 | ca->pub->slot_shutdown(ca->pub, slot); | 790 | ca->pub->slot_shutdown(ca->pub, slot); |
| 791 | ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; | 791 | ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; |
| @@ -892,7 +892,7 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot) | |||
| 892 | static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca) | 892 | static void dvb_ca_en50221_thread_wakeup(struct dvb_ca_private *ca) |
| 893 | { | 893 | { |
| 894 | 894 | ||
| 895 | dprintk("%s\n", __FUNCTION__); | 895 | dprintk("%s\n", __func__); |
| 896 | 896 | ||
| 897 | ca->wakeup = 1; | 897 | ca->wakeup = 1; |
| 898 | mb(); | 898 | mb(); |
| @@ -964,7 +964,7 @@ static int dvb_ca_en50221_thread(void *data) | |||
| 964 | int pktcount; | 964 | int pktcount; |
| 965 | void *rxbuf; | 965 | void *rxbuf; |
| 966 | 966 | ||
| 967 | dprintk("%s\n", __FUNCTION__); | 967 | dprintk("%s\n", __func__); |
| 968 | 968 | ||
| 969 | /* choose the correct initial delay */ | 969 | /* choose the correct initial delay */ |
| 970 | dvb_ca_en50221_thread_update_delay(ca); | 970 | dvb_ca_en50221_thread_update_delay(ca); |
| @@ -1172,7 +1172,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct inode *inode, struct file *file, | |||
| 1172 | int err = 0; | 1172 | int err = 0; |
| 1173 | int slot; | 1173 | int slot; |
| 1174 | 1174 | ||
| 1175 | dprintk("%s\n", __FUNCTION__); | 1175 | dprintk("%s\n", __func__); |
| 1176 | 1176 | ||
| 1177 | switch (cmd) { | 1177 | switch (cmd) { |
| 1178 | case CA_RESET: | 1178 | case CA_RESET: |
| @@ -1266,7 +1266,7 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file, | |||
| 1266 | unsigned long timeout; | 1266 | unsigned long timeout; |
| 1267 | int written; | 1267 | int written; |
| 1268 | 1268 | ||
| 1269 | dprintk("%s\n", __FUNCTION__); | 1269 | dprintk("%s\n", __func__); |
| 1270 | 1270 | ||
| 1271 | /* Incoming packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */ | 1271 | /* Incoming packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */ |
| 1272 | if (count < 2) | 1272 | if (count < 2) |
| @@ -1401,7 +1401,7 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf, | |||
| 1401 | int pktlen; | 1401 | int pktlen; |
| 1402 | int dispose = 0; | 1402 | int dispose = 0; |
| 1403 | 1403 | ||
| 1404 | dprintk("%s\n", __FUNCTION__); | 1404 | dprintk("%s\n", __func__); |
| 1405 | 1405 | ||
| 1406 | /* Outgoing packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */ | 1406 | /* Outgoing packet has a 2 byte header. hdr[0] = slot_id, hdr[1] = connection_id */ |
| 1407 | if (count < 2) | 1407 | if (count < 2) |
| @@ -1490,7 +1490,7 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file) | |||
| 1490 | int err; | 1490 | int err; |
| 1491 | int i; | 1491 | int i; |
| 1492 | 1492 | ||
| 1493 | dprintk("%s\n", __FUNCTION__); | 1493 | dprintk("%s\n", __func__); |
| 1494 | 1494 | ||
| 1495 | if (!try_module_get(ca->pub->owner)) | 1495 | if (!try_module_get(ca->pub->owner)) |
| 1496 | return -EIO; | 1496 | return -EIO; |
| @@ -1534,7 +1534,7 @@ static int dvb_ca_en50221_io_release(struct inode *inode, struct file *file) | |||
| 1534 | struct dvb_ca_private *ca = dvbdev->priv; | 1534 | struct dvb_ca_private *ca = dvbdev->priv; |
| 1535 | int err; | 1535 | int err; |
| 1536 | 1536 | ||
| 1537 | dprintk("%s\n", __FUNCTION__); | 1537 | dprintk("%s\n", __func__); |
| 1538 | 1538 | ||
| 1539 | /* mark the CA device as closed */ | 1539 | /* mark the CA device as closed */ |
| 1540 | ca->open = 0; | 1540 | ca->open = 0; |
| @@ -1564,7 +1564,7 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait) | |||
| 1564 | int slot; | 1564 | int slot; |
| 1565 | int result = 0; | 1565 | int result = 0; |
| 1566 | 1566 | ||
| 1567 | dprintk("%s\n", __FUNCTION__); | 1567 | dprintk("%s\n", __func__); |
| 1568 | 1568 | ||
| 1569 | if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) { | 1569 | if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) { |
| 1570 | mask |= POLLIN; | 1570 | mask |= POLLIN; |
| @@ -1626,7 +1626,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter, | |||
| 1626 | struct dvb_ca_private *ca = NULL; | 1626 | struct dvb_ca_private *ca = NULL; |
| 1627 | int i; | 1627 | int i; |
| 1628 | 1628 | ||
| 1629 | dprintk("%s\n", __FUNCTION__); | 1629 | dprintk("%s\n", __func__); |
| 1630 | 1630 | ||
| 1631 | if (slot_count < 1) | 1631 | if (slot_count < 1) |
| 1632 | return -EINVAL; | 1632 | return -EINVAL; |
| @@ -1704,7 +1704,7 @@ void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca) | |||
| 1704 | struct dvb_ca_private *ca = pubca->private; | 1704 | struct dvb_ca_private *ca = pubca->private; |
| 1705 | int i; | 1705 | int i; |
| 1706 | 1706 | ||
| 1707 | dprintk("%s\n", __FUNCTION__); | 1707 | dprintk("%s\n", __func__); |
| 1708 | 1708 | ||
| 1709 | /* shutdown the thread if there was one */ | 1709 | /* shutdown the thread if there was one */ |
| 1710 | kthread_stop(ca->thread); | 1710 | kthread_stop(ca->thread); |
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c index 7959020f9317..934e15fffc56 100644 --- a/drivers/media/dvb/dvb-core/dvb_demux.c +++ b/drivers/media/dvb/dvb-core/dvb_demux.c | |||
| @@ -368,7 +368,7 @@ static inline void dvb_dmx_swfilter_packet_type(struct dvb_demux_feed *feed, | |||
| 368 | #define DVR_FEED(f) \ | 368 | #define DVR_FEED(f) \ |
| 369 | (((f)->type == DMX_TYPE_TS) && \ | 369 | (((f)->type == DMX_TYPE_TS) && \ |
| 370 | ((f)->feed.ts.is_filtering) && \ | 370 | ((f)->feed.ts.is_filtering) && \ |
| 371 | (((f)->ts_type & (TS_PACKET|TS_PAYLOAD_ONLY)) == TS_PACKET)) | 371 | (((f)->ts_type & (TS_PACKET | TS_DEMUX)) == TS_PACKET)) |
| 372 | 372 | ||
| 373 | static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) | 373 | static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf) |
| 374 | { | 374 | { |
| @@ -553,7 +553,7 @@ static void dvb_demux_feed_add(struct dvb_demux_feed *feed) | |||
| 553 | spin_lock_irq(&feed->demux->lock); | 553 | spin_lock_irq(&feed->demux->lock); |
| 554 | if (dvb_demux_feed_find(feed)) { | 554 | if (dvb_demux_feed_find(feed)) { |
| 555 | printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n", | 555 | printk(KERN_ERR "%s: feed already in list (type=%x state=%x pid=%x)\n", |
| 556 | __FUNCTION__, feed->type, feed->state, feed->pid); | 556 | __func__, feed->type, feed->state, feed->pid); |
| 557 | goto out; | 557 | goto out; |
| 558 | } | 558 | } |
| 559 | 559 | ||
| @@ -567,7 +567,7 @@ static void dvb_demux_feed_del(struct dvb_demux_feed *feed) | |||
| 567 | spin_lock_irq(&feed->demux->lock); | 567 | spin_lock_irq(&feed->demux->lock); |
| 568 | if (!(dvb_demux_feed_find(feed))) { | 568 | if (!(dvb_demux_feed_find(feed))) { |
| 569 | printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n", | 569 | printk(KERN_ERR "%s: feed not in list (type=%x state=%x pid=%x)\n", |
| 570 | __FUNCTION__, feed->type, feed->state, feed->pid); | 570 | __func__, feed->type, feed->state, feed->pid); |
| 571 | goto out; | 571 | goto out; |
| 572 | } | 572 | } |
| 573 | 573 | ||
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index 925cfa6221ad..2dddd08c5445 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c | |||
| @@ -135,7 +135,7 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) | |||
| 135 | struct dvb_frontend_event *e; | 135 | struct dvb_frontend_event *e; |
| 136 | int wp; | 136 | int wp; |
| 137 | 137 | ||
| 138 | dprintk ("%s\n", __FUNCTION__); | 138 | dprintk ("%s\n", __func__); |
| 139 | 139 | ||
| 140 | if (mutex_lock_interruptible (&events->mtx)) | 140 | if (mutex_lock_interruptible (&events->mtx)) |
| 141 | return; | 141 | return; |
| @@ -171,7 +171,7 @@ static int dvb_frontend_get_event(struct dvb_frontend *fe, | |||
| 171 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | 171 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
| 172 | struct dvb_fe_events *events = &fepriv->events; | 172 | struct dvb_fe_events *events = &fepriv->events; |
| 173 | 173 | ||
| 174 | dprintk ("%s\n", __FUNCTION__); | 174 | dprintk ("%s\n", __func__); |
| 175 | 175 | ||
| 176 | if (events->overflow) { | 176 | if (events->overflow) { |
| 177 | events->overflow = 0; | 177 | events->overflow = 0; |
| @@ -237,7 +237,7 @@ static void dvb_frontend_swzigzag_update_delay(struct dvb_frontend_private *fepr | |||
| 237 | { | 237 | { |
| 238 | int q2; | 238 | int q2; |
| 239 | 239 | ||
| 240 | dprintk ("%s\n", __FUNCTION__); | 240 | dprintk ("%s\n", __func__); |
| 241 | 241 | ||
| 242 | if (locked) | 242 | if (locked) |
| 243 | (fepriv->quality) = (fepriv->quality * 220 + 36*256) / 256; | 243 | (fepriv->quality) = (fepriv->quality * 220 + 36*256) / 256; |
| @@ -329,7 +329,7 @@ static int dvb_frontend_swzigzag_autotune(struct dvb_frontend *fe, int check_wra | |||
| 329 | 329 | ||
| 330 | dprintk("%s: drift:%i inversion:%i auto_step:%i " | 330 | dprintk("%s: drift:%i inversion:%i auto_step:%i " |
| 331 | "auto_sub_step:%i started_auto_step:%i\n", | 331 | "auto_sub_step:%i started_auto_step:%i\n", |
| 332 | __FUNCTION__, fepriv->lnb_drift, fepriv->inversion, | 332 | __func__, fepriv->lnb_drift, fepriv->inversion, |
| 333 | fepriv->auto_step, fepriv->auto_sub_step, fepriv->started_auto_step); | 333 | fepriv->auto_step, fepriv->auto_sub_step, fepriv->started_auto_step); |
| 334 | 334 | ||
| 335 | /* set the frontend itself */ | 335 | /* set the frontend itself */ |
| @@ -511,7 +511,7 @@ static int dvb_frontend_thread(void *data) | |||
| 511 | fe_status_t s; | 511 | fe_status_t s; |
| 512 | struct dvb_frontend_parameters *params; | 512 | struct dvb_frontend_parameters *params; |
| 513 | 513 | ||
| 514 | dprintk("%s\n", __FUNCTION__); | 514 | dprintk("%s\n", __func__); |
| 515 | 515 | ||
| 516 | fepriv->check_wrapped = 0; | 516 | fepriv->check_wrapped = 0; |
| 517 | fepriv->quality = 0; | 517 | fepriv->quality = 0; |
| @@ -597,7 +597,7 @@ static void dvb_frontend_stop(struct dvb_frontend *fe) | |||
| 597 | { | 597 | { |
| 598 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | 598 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
| 599 | 599 | ||
| 600 | dprintk ("%s\n", __FUNCTION__); | 600 | dprintk ("%s\n", __func__); |
| 601 | 601 | ||
| 602 | fepriv->exit = 1; | 602 | fepriv->exit = 1; |
| 603 | mb(); | 603 | mb(); |
| @@ -665,7 +665,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe) | |||
| 665 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | 665 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
| 666 | struct task_struct *fe_thread; | 666 | struct task_struct *fe_thread; |
| 667 | 667 | ||
| 668 | dprintk ("%s\n", __FUNCTION__); | 668 | dprintk ("%s\n", __func__); |
| 669 | 669 | ||
| 670 | if (fepriv->thread) { | 670 | if (fepriv->thread) { |
| 671 | if (!fepriv->exit) | 671 | if (!fepriv->exit) |
| @@ -763,7 +763,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, | |||
| 763 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | 763 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
| 764 | int err = -EOPNOTSUPP; | 764 | int err = -EOPNOTSUPP; |
| 765 | 765 | ||
| 766 | dprintk ("%s\n", __FUNCTION__); | 766 | dprintk ("%s\n", __func__); |
| 767 | 767 | ||
| 768 | if (fepriv->exit) | 768 | if (fepriv->exit) |
| 769 | return -ENODEV; | 769 | return -ENODEV; |
| @@ -895,7 +895,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, | |||
| 895 | int i; | 895 | int i; |
| 896 | u8 last = 1; | 896 | u8 last = 1; |
| 897 | if (dvb_frontend_debug) | 897 | if (dvb_frontend_debug) |
| 898 | printk("%s switch command: 0x%04lx\n", __FUNCTION__, cmd); | 898 | printk("%s switch command: 0x%04lx\n", __func__, cmd); |
| 899 | do_gettimeofday(&nexttime); | 899 | do_gettimeofday(&nexttime); |
| 900 | if (dvb_frontend_debug) | 900 | if (dvb_frontend_debug) |
| 901 | memcpy(&tv[0], &nexttime, sizeof(struct timeval)); | 901 | memcpy(&tv[0], &nexttime, sizeof(struct timeval)); |
| @@ -919,7 +919,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file, | |||
| 919 | } | 919 | } |
| 920 | if (dvb_frontend_debug) { | 920 | if (dvb_frontend_debug) { |
| 921 | printk("%s(%d): switch delay (should be 32k followed by all 8k\n", | 921 | printk("%s(%d): switch delay (should be 32k followed by all 8k\n", |
| 922 | __FUNCTION__, fe->dvb->num); | 922 | __func__, fe->dvb->num); |
| 923 | for (i = 1; i < 10; i++) | 923 | for (i = 1; i < 10; i++) |
| 924 | printk("%d: %d\n", i, timeval_usec_diff(tv[i-1] , tv[i])); | 924 | printk("%d: %d\n", i, timeval_usec_diff(tv[i-1] , tv[i])); |
| 925 | } | 925 | } |
| @@ -1037,7 +1037,7 @@ static unsigned int dvb_frontend_poll(struct file *file, struct poll_table_struc | |||
| 1037 | struct dvb_frontend *fe = dvbdev->priv; | 1037 | struct dvb_frontend *fe = dvbdev->priv; |
| 1038 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | 1038 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
| 1039 | 1039 | ||
| 1040 | dprintk ("%s\n", __FUNCTION__); | 1040 | dprintk ("%s\n", __func__); |
| 1041 | 1041 | ||
| 1042 | poll_wait (file, &fepriv->events.wait_queue, wait); | 1042 | poll_wait (file, &fepriv->events.wait_queue, wait); |
| 1043 | 1043 | ||
| @@ -1054,7 +1054,7 @@ static int dvb_frontend_open(struct inode *inode, struct file *file) | |||
| 1054 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | 1054 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
| 1055 | int ret; | 1055 | int ret; |
| 1056 | 1056 | ||
| 1057 | dprintk ("%s\n", __FUNCTION__); | 1057 | dprintk ("%s\n", __func__); |
| 1058 | 1058 | ||
| 1059 | if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) { | 1059 | if (dvbdev->users == -1 && fe->ops.ts_bus_ctrl) { |
| 1060 | if ((ret = fe->ops.ts_bus_ctrl(fe, 1)) < 0) | 1060 | if ((ret = fe->ops.ts_bus_ctrl(fe, 1)) < 0) |
| @@ -1095,7 +1095,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file) | |||
| 1095 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | 1095 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
| 1096 | int ret; | 1096 | int ret; |
| 1097 | 1097 | ||
| 1098 | dprintk ("%s\n", __FUNCTION__); | 1098 | dprintk ("%s\n", __func__); |
| 1099 | 1099 | ||
| 1100 | if ((file->f_flags & O_ACCMODE) != O_RDONLY) | 1100 | if ((file->f_flags & O_ACCMODE) != O_RDONLY) |
| 1101 | fepriv->release_jiffies = jiffies; | 1101 | fepriv->release_jiffies = jiffies; |
| @@ -1135,7 +1135,7 @@ int dvb_register_frontend(struct dvb_adapter* dvb, | |||
| 1135 | .kernel_ioctl = dvb_frontend_ioctl | 1135 | .kernel_ioctl = dvb_frontend_ioctl |
| 1136 | }; | 1136 | }; |
| 1137 | 1137 | ||
| 1138 | dprintk ("%s\n", __FUNCTION__); | 1138 | dprintk ("%s\n", __func__); |
| 1139 | 1139 | ||
| 1140 | if (mutex_lock_interruptible(&frontend_mutex)) | 1140 | if (mutex_lock_interruptible(&frontend_mutex)) |
| 1141 | return -ERESTARTSYS; | 1141 | return -ERESTARTSYS; |
| @@ -1169,7 +1169,7 @@ EXPORT_SYMBOL(dvb_register_frontend); | |||
| 1169 | int dvb_unregister_frontend(struct dvb_frontend* fe) | 1169 | int dvb_unregister_frontend(struct dvb_frontend* fe) |
| 1170 | { | 1170 | { |
| 1171 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | 1171 | struct dvb_frontend_private *fepriv = fe->frontend_priv; |
| 1172 | dprintk ("%s\n", __FUNCTION__); | 1172 | dprintk ("%s\n", __func__); |
| 1173 | 1173 | ||
| 1174 | mutex_lock(&frontend_mutex); | 1174 | mutex_lock(&frontend_mutex); |
| 1175 | dvb_frontend_stop (fe); | 1175 | dvb_frontend_stop (fe); |
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c index 4c8b62e2c035..56d871cfd7fc 100644 --- a/drivers/media/dvb/dvb-core/dvb_net.c +++ b/drivers/media/dvb/dvb-core/dvb_net.c | |||
| @@ -354,7 +354,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len ) | |||
| 354 | #ifdef ULE_DEBUG | 354 | #ifdef ULE_DEBUG |
| 355 | /* The code inside ULE_DEBUG keeps a history of the last 100 TS cells processed. */ | 355 | /* The code inside ULE_DEBUG keeps a history of the last 100 TS cells processed. */ |
| 356 | static unsigned char ule_hist[100*TS_SZ]; | 356 | static unsigned char ule_hist[100*TS_SZ]; |
| 357 | static unsigned char *ule_where = ule_hist, ule_dump = 0; | 357 | static unsigned char *ule_where = ule_hist, ule_dump; |
| 358 | #endif | 358 | #endif |
| 359 | 359 | ||
| 360 | /* For all TS cells in current buffer. | 360 | /* For all TS cells in current buffer. |
| @@ -965,17 +965,17 @@ static int dvb_net_feed_start(struct net_device *dev) | |||
| 965 | struct dmx_demux *demux = priv->demux; | 965 | struct dmx_demux *demux = priv->demux; |
| 966 | unsigned char *mac = (unsigned char *) dev->dev_addr; | 966 | unsigned char *mac = (unsigned char *) dev->dev_addr; |
| 967 | 967 | ||
| 968 | dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode); | 968 | dprintk("%s: rx_mode %i\n", __func__, priv->rx_mode); |
| 969 | mutex_lock(&priv->mutex); | 969 | mutex_lock(&priv->mutex); |
| 970 | if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0]) | 970 | if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0]) |
| 971 | printk("%s: BUG %d\n", __FUNCTION__, __LINE__); | 971 | printk("%s: BUG %d\n", __func__, __LINE__); |
| 972 | 972 | ||
| 973 | priv->secfeed=NULL; | 973 | priv->secfeed=NULL; |
| 974 | priv->secfilter=NULL; | 974 | priv->secfilter=NULL; |
| 975 | priv->tsfeed = NULL; | 975 | priv->tsfeed = NULL; |
| 976 | 976 | ||
| 977 | if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) { | 977 | if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) { |
| 978 | dprintk("%s: alloc secfeed\n", __FUNCTION__); | 978 | dprintk("%s: alloc secfeed\n", __func__); |
| 979 | ret=demux->allocate_section_feed(demux, &priv->secfeed, | 979 | ret=demux->allocate_section_feed(demux, &priv->secfeed, |
| 980 | dvb_net_sec_callback); | 980 | dvb_net_sec_callback); |
| 981 | if (ret<0) { | 981 | if (ret<0) { |
| @@ -993,38 +993,38 @@ static int dvb_net_feed_start(struct net_device *dev) | |||
| 993 | } | 993 | } |
| 994 | 994 | ||
| 995 | if (priv->rx_mode != RX_MODE_PROMISC) { | 995 | if (priv->rx_mode != RX_MODE_PROMISC) { |
| 996 | dprintk("%s: set secfilter\n", __FUNCTION__); | 996 | dprintk("%s: set secfilter\n", __func__); |
| 997 | dvb_net_filter_sec_set(dev, &priv->secfilter, mac, mask_normal); | 997 | dvb_net_filter_sec_set(dev, &priv->secfilter, mac, mask_normal); |
| 998 | } | 998 | } |
| 999 | 999 | ||
| 1000 | switch (priv->rx_mode) { | 1000 | switch (priv->rx_mode) { |
| 1001 | case RX_MODE_MULTI: | 1001 | case RX_MODE_MULTI: |
| 1002 | for (i = 0; i < priv->multi_num; i++) { | 1002 | for (i = 0; i < priv->multi_num; i++) { |
| 1003 | dprintk("%s: set multi_secfilter[%d]\n", __FUNCTION__, i); | 1003 | dprintk("%s: set multi_secfilter[%d]\n", __func__, i); |
| 1004 | dvb_net_filter_sec_set(dev, &priv->multi_secfilter[i], | 1004 | dvb_net_filter_sec_set(dev, &priv->multi_secfilter[i], |
| 1005 | priv->multi_macs[i], mask_normal); | 1005 | priv->multi_macs[i], mask_normal); |
| 1006 | } | 1006 | } |
| 1007 | break; | 1007 | break; |
| 1008 | case RX_MODE_ALL_MULTI: | 1008 | case RX_MODE_ALL_MULTI: |
| 1009 | priv->multi_num=1; | 1009 | priv->multi_num=1; |
| 1010 | dprintk("%s: set multi_secfilter[0]\n", __FUNCTION__); | 1010 | dprintk("%s: set multi_secfilter[0]\n", __func__); |
| 1011 | dvb_net_filter_sec_set(dev, &priv->multi_secfilter[0], | 1011 | dvb_net_filter_sec_set(dev, &priv->multi_secfilter[0], |
| 1012 | mac_allmulti, mask_allmulti); | 1012 | mac_allmulti, mask_allmulti); |
| 1013 | break; | 1013 | break; |
| 1014 | case RX_MODE_PROMISC: | 1014 | case RX_MODE_PROMISC: |
| 1015 | priv->multi_num=0; | 1015 | priv->multi_num=0; |
| 1016 | dprintk("%s: set secfilter\n", __FUNCTION__); | 1016 | dprintk("%s: set secfilter\n", __func__); |
| 1017 | dvb_net_filter_sec_set(dev, &priv->secfilter, mac, mask_promisc); | 1017 | dvb_net_filter_sec_set(dev, &priv->secfilter, mac, mask_promisc); |
| 1018 | break; | 1018 | break; |
| 1019 | } | 1019 | } |
| 1020 | 1020 | ||
| 1021 | dprintk("%s: start filtering\n", __FUNCTION__); | 1021 | dprintk("%s: start filtering\n", __func__); |
| 1022 | priv->secfeed->start_filtering(priv->secfeed); | 1022 | priv->secfeed->start_filtering(priv->secfeed); |
| 1023 | } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) { | 1023 | } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) { |
| 1024 | struct timespec timeout = { 0, 10000000 }; // 10 msec | 1024 | struct timespec timeout = { 0, 10000000 }; // 10 msec |
| 1025 | 1025 | ||
| 1026 | /* we have payloads encapsulated in TS */ | 1026 | /* we have payloads encapsulated in TS */ |
| 1027 | dprintk("%s: alloc tsfeed\n", __FUNCTION__); | 1027 | dprintk("%s: alloc tsfeed\n", __func__); |
| 1028 | ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback); | 1028 | ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback); |
| 1029 | if (ret < 0) { | 1029 | if (ret < 0) { |
| 1030 | printk("%s: could not allocate ts feed\n", dev->name); | 1030 | printk("%s: could not allocate ts feed\n", dev->name); |
| @@ -1048,7 +1048,7 @@ static int dvb_net_feed_start(struct net_device *dev) | |||
| 1048 | goto error; | 1048 | goto error; |
| 1049 | } | 1049 | } |
| 1050 | 1050 | ||
| 1051 | dprintk("%s: start filtering\n", __FUNCTION__); | 1051 | dprintk("%s: start filtering\n", __func__); |
| 1052 | priv->tsfeed->start_filtering(priv->tsfeed); | 1052 | priv->tsfeed->start_filtering(priv->tsfeed); |
| 1053 | } else | 1053 | } else |
| 1054 | ret = -EINVAL; | 1054 | ret = -EINVAL; |
| @@ -1063,17 +1063,17 @@ static int dvb_net_feed_stop(struct net_device *dev) | |||
| 1063 | struct dvb_net_priv *priv = dev->priv; | 1063 | struct dvb_net_priv *priv = dev->priv; |
| 1064 | int i, ret = 0; | 1064 | int i, ret = 0; |
| 1065 | 1065 | ||
| 1066 | dprintk("%s\n", __FUNCTION__); | 1066 | dprintk("%s\n", __func__); |
| 1067 | mutex_lock(&priv->mutex); | 1067 | mutex_lock(&priv->mutex); |
| 1068 | if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) { | 1068 | if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) { |
| 1069 | if (priv->secfeed) { | 1069 | if (priv->secfeed) { |
| 1070 | if (priv->secfeed->is_filtering) { | 1070 | if (priv->secfeed->is_filtering) { |
| 1071 | dprintk("%s: stop secfeed\n", __FUNCTION__); | 1071 | dprintk("%s: stop secfeed\n", __func__); |
| 1072 | priv->secfeed->stop_filtering(priv->secfeed); | 1072 | priv->secfeed->stop_filtering(priv->secfeed); |
| 1073 | } | 1073 | } |
| 1074 | 1074 | ||
| 1075 | if (priv->secfilter) { | 1075 | if (priv->secfilter) { |
| 1076 | dprintk("%s: release secfilter\n", __FUNCTION__); | 1076 | dprintk("%s: release secfilter\n", __func__); |
| 1077 | priv->secfeed->release_filter(priv->secfeed, | 1077 | priv->secfeed->release_filter(priv->secfeed, |
| 1078 | priv->secfilter); | 1078 | priv->secfilter); |
| 1079 | priv->secfilter=NULL; | 1079 | priv->secfilter=NULL; |
| @@ -1082,7 +1082,7 @@ static int dvb_net_feed_stop(struct net_device *dev) | |||
| 1082 | for (i=0; i<priv->multi_num; i++) { | 1082 | for (i=0; i<priv->multi_num; i++) { |
| 1083 | if (priv->multi_secfilter[i]) { | 1083 | if (priv->multi_secfilter[i]) { |
| 1084 | dprintk("%s: release multi_filter[%d]\n", | 1084 | dprintk("%s: release multi_filter[%d]\n", |
| 1085 | __FUNCTION__, i); | 1085 | __func__, i); |
| 1086 | priv->secfeed->release_filter(priv->secfeed, | 1086 | priv->secfeed->release_filter(priv->secfeed, |
| 1087 | priv->multi_secfilter[i]); | 1087 | priv->multi_secfilter[i]); |
| 1088 | priv->multi_secfilter[i] = NULL; | 1088 | priv->multi_secfilter[i] = NULL; |
| @@ -1096,7 +1096,7 @@ static int dvb_net_feed_stop(struct net_device *dev) | |||
| 1096 | } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) { | 1096 | } else if (priv->feedtype == DVB_NET_FEEDTYPE_ULE) { |
| 1097 | if (priv->tsfeed) { | 1097 | if (priv->tsfeed) { |
| 1098 | if (priv->tsfeed->is_filtering) { | 1098 | if (priv->tsfeed->is_filtering) { |
| 1099 | dprintk("%s: stop tsfeed\n", __FUNCTION__); | 1099 | dprintk("%s: stop tsfeed\n", __func__); |
| 1100 | priv->tsfeed->stop_filtering(priv->tsfeed); | 1100 | priv->tsfeed->stop_filtering(priv->tsfeed); |
| 1101 | } | 1101 | } |
| 1102 | priv->demux->release_ts_feed(priv->demux, priv->tsfeed); | 1102 | priv->demux->release_ts_feed(priv->demux, priv->tsfeed); |
diff --git a/drivers/media/dvb/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb/dvb-core/dvb_ringbuffer.c index ac9d93cf83c6..872985b7912d 100644 --- a/drivers/media/dvb/dvb-core/dvb_ringbuffer.c +++ b/drivers/media/dvb/dvb-core/dvb_ringbuffer.c | |||
| @@ -90,7 +90,11 @@ void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf) | |||
| 90 | rbuf->error = 0; | 90 | rbuf->error = 0; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | 93 | void dvb_ringbuffer_reset(struct dvb_ringbuffer *rbuf) | |
| 94 | { | ||
| 95 | rbuf->pread = rbuf->pwrite = 0; | ||
| 96 | rbuf->error = 0; | ||
| 97 | } | ||
| 94 | 98 | ||
| 95 | void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf) | 99 | void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf) |
| 96 | { | 100 | { |
diff --git a/drivers/media/dvb/dvb-core/dvb_ringbuffer.h b/drivers/media/dvb/dvb-core/dvb_ringbuffer.h index d97714e75736..890826262966 100644 --- a/drivers/media/dvb/dvb-core/dvb_ringbuffer.h +++ b/drivers/media/dvb/dvb-core/dvb_ringbuffer.h | |||
| @@ -69,6 +69,7 @@ struct dvb_ringbuffer { | |||
| 69 | ** to lock read or write operations. | 69 | ** to lock read or write operations. |
| 70 | ** Two or more readers must be locked against each other. | 70 | ** Two or more readers must be locked against each other. |
| 71 | ** Flushing the buffer counts as a read operation. | 71 | ** Flushing the buffer counts as a read operation. |
| 72 | ** Resetting the buffer counts as a read and write operation. | ||
| 72 | ** Two or more writers must be locked against each other. | 73 | ** Two or more writers must be locked against each other. |
| 73 | */ | 74 | */ |
| 74 | 75 | ||
| @@ -85,6 +86,13 @@ extern ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf); | |||
| 85 | extern ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf); | 86 | extern ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf); |
| 86 | 87 | ||
| 87 | 88 | ||
| 89 | /* | ||
| 90 | ** Reset the read and write pointers to zero and flush the buffer | ||
| 91 | ** This counts as a read and write operation | ||
| 92 | */ | ||
| 93 | extern void dvb_ringbuffer_reset(struct dvb_ringbuffer *rbuf); | ||
| 94 | |||
| 95 | |||
| 88 | /* read routines & macros */ | 96 | /* read routines & macros */ |
| 89 | /* ---------------------- */ | 97 | /* ---------------------- */ |
| 90 | /* flush buffer */ | 98 | /* flush buffer */ |
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c index 18738faecbbc..8b56d929f7fd 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.c +++ b/drivers/media/dvb/dvb-core/dvbdev.c | |||
| @@ -49,7 +49,6 @@ static const char * const dnames[] = { | |||
| 49 | "net", "osd" | 49 | "net", "osd" |
| 50 | }; | 50 | }; |
| 51 | 51 | ||
| 52 | #define DVB_MAX_ADAPTERS 8 | ||
| 53 | #define DVB_MAX_IDS 4 | 52 | #define DVB_MAX_IDS 4 |
| 54 | #define nums2minor(num,type,id) ((num << 6) | (id << 4) | type) | 53 | #define nums2minor(num,type,id) ((num << 6) | (id << 4) | type) |
| 55 | #define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64) | 54 | #define MAX_DVB_MINORS (DVB_MAX_ADAPTERS*64) |
| @@ -97,7 +96,7 @@ static int dvb_device_open(struct inode *inode, struct file *file) | |||
| 97 | } | 96 | } |
| 98 | 97 | ||
| 99 | 98 | ||
| 100 | static struct file_operations dvb_device_fops = | 99 | static const struct file_operations dvb_device_fops = |
| 101 | { | 100 | { |
| 102 | .owner = THIS_MODULE, | 101 | .owner = THIS_MODULE, |
| 103 | .open = dvb_device_open, | 102 | .open = dvb_device_open, |
| @@ -196,7 +195,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, | |||
| 196 | if ((id = dvbdev_get_free_id (adap, type)) < 0){ | 195 | if ((id = dvbdev_get_free_id (adap, type)) < 0){ |
| 197 | mutex_unlock(&dvbdev_register_lock); | 196 | mutex_unlock(&dvbdev_register_lock); |
| 198 | *pdvbdev = NULL; | 197 | *pdvbdev = NULL; |
| 199 | printk(KERN_ERR "%s: couldn't find free device id\n", __FUNCTION__); | 198 | printk(KERN_ERR "%s: couldn't find free device id\n", __func__); |
| 200 | return -ENFILE; | 199 | return -ENFILE; |
| 201 | } | 200 | } |
| 202 | 201 | ||
| @@ -235,7 +234,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, | |||
| 235 | "dvb%d.%s%d", adap->num, dnames[type], id); | 234 | "dvb%d.%s%d", adap->num, dnames[type], id); |
| 236 | if (IS_ERR(clsdev)) { | 235 | if (IS_ERR(clsdev)) { |
| 237 | printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n", | 236 | printk(KERN_ERR "%s: failed to create device dvb%d.%s%d (%ld)\n", |
| 238 | __FUNCTION__, adap->num, dnames[type], id, PTR_ERR(clsdev)); | 237 | __func__, adap->num, dnames[type], id, PTR_ERR(clsdev)); |
| 239 | return PTR_ERR(clsdev); | 238 | return PTR_ERR(clsdev); |
| 240 | } | 239 | } |
| 241 | 240 | ||
| @@ -262,18 +261,25 @@ void dvb_unregister_device(struct dvb_device *dvbdev) | |||
| 262 | } | 261 | } |
| 263 | EXPORT_SYMBOL(dvb_unregister_device); | 262 | EXPORT_SYMBOL(dvb_unregister_device); |
| 264 | 263 | ||
| 264 | static int dvbdev_check_free_adapter_num(int num) | ||
| 265 | { | ||
| 266 | struct list_head *entry; | ||
| 267 | list_for_each(entry, &dvb_adapter_list) { | ||
| 268 | struct dvb_adapter *adap; | ||
| 269 | adap = list_entry(entry, struct dvb_adapter, list_head); | ||
| 270 | if (adap->num == num) | ||
| 271 | return 0; | ||
| 272 | } | ||
| 273 | return 1; | ||
| 274 | } | ||
| 265 | 275 | ||
| 266 | static int dvbdev_get_free_adapter_num (void) | 276 | static int dvbdev_get_free_adapter_num (void) |
| 267 | { | 277 | { |
| 268 | int num = 0; | 278 | int num = 0; |
| 269 | 279 | ||
| 270 | while (num < DVB_MAX_ADAPTERS) { | 280 | while (num < DVB_MAX_ADAPTERS) { |
| 271 | struct dvb_adapter *adap; | 281 | if (dvbdev_check_free_adapter_num(num)) |
| 272 | list_for_each_entry(adap, &dvb_adapter_list, list_head) | 282 | return num; |
| 273 | if (adap->num == num) | ||
| 274 | goto skip; | ||
| 275 | return num; | ||
| 276 | skip: | ||
| 277 | num++; | 283 | num++; |
| 278 | } | 284 | } |
| 279 | 285 | ||
| @@ -281,13 +287,28 @@ skip: | |||
| 281 | } | 287 | } |
| 282 | 288 | ||
| 283 | 289 | ||
| 284 | int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct module *module, struct device *device) | 290 | int dvb_register_adapter(struct dvb_adapter *adap, const char *name, |
| 291 | struct module *module, struct device *device, | ||
| 292 | short *adapter_nums) | ||
| 285 | { | 293 | { |
| 286 | int num; | 294 | int i, num; |
| 287 | 295 | ||
| 288 | mutex_lock(&dvbdev_register_lock); | 296 | mutex_lock(&dvbdev_register_lock); |
| 289 | 297 | ||
| 290 | if ((num = dvbdev_get_free_adapter_num ()) < 0) { | 298 | for (i = 0; i < DVB_MAX_ADAPTERS; ++i) { |
| 299 | num = adapter_nums[i]; | ||
| 300 | if (num >= 0 && num < DVB_MAX_ADAPTERS) { | ||
| 301 | /* use the one the driver asked for */ | ||
| 302 | if (dvbdev_check_free_adapter_num(num)) | ||
| 303 | break; | ||
| 304 | } else { | ||
| 305 | num = dvbdev_get_free_adapter_num(); | ||
| 306 | break; | ||
| 307 | } | ||
| 308 | num = -1; | ||
| 309 | } | ||
| 310 | |||
| 311 | if (num < 0) { | ||
| 291 | mutex_unlock(&dvbdev_register_lock); | 312 | mutex_unlock(&dvbdev_register_lock); |
| 292 | return -ENFILE; | 313 | return -ENFILE; |
| 293 | } | 314 | } |
diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h index 6dff10ebf470..5f9a737c6de1 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.h +++ b/drivers/media/dvb/dvb-core/dvbdev.h | |||
| @@ -31,6 +31,10 @@ | |||
| 31 | 31 | ||
| 32 | #define DVB_MAJOR 212 | 32 | #define DVB_MAJOR 212 |
| 33 | 33 | ||
| 34 | #define DVB_MAX_ADAPTERS 8 | ||
| 35 | |||
| 36 | #define DVB_UNSET (-1) | ||
| 37 | |||
| 34 | #define DVB_DEVICE_VIDEO 0 | 38 | #define DVB_DEVICE_VIDEO 0 |
| 35 | #define DVB_DEVICE_AUDIO 1 | 39 | #define DVB_DEVICE_AUDIO 1 |
| 36 | #define DVB_DEVICE_SEC 2 | 40 | #define DVB_DEVICE_SEC 2 |
| @@ -41,6 +45,11 @@ | |||
| 41 | #define DVB_DEVICE_NET 7 | 45 | #define DVB_DEVICE_NET 7 |
| 42 | #define DVB_DEVICE_OSD 8 | 46 | #define DVB_DEVICE_OSD 8 |
| 43 | 47 | ||
| 48 | #define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \ | ||
| 49 | static short adapter_nr[] = \ | ||
| 50 | {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \ | ||
| 51 | module_param_array(adapter_nr, short, NULL, 0444); \ | ||
| 52 | MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers") | ||
| 44 | 53 | ||
| 45 | struct dvb_adapter { | 54 | struct dvb_adapter { |
| 46 | int num; | 55 | int num; |
| @@ -78,7 +87,9 @@ struct dvb_device { | |||
| 78 | }; | 87 | }; |
| 79 | 88 | ||
| 80 | 89 | ||
| 81 | extern int dvb_register_adapter (struct dvb_adapter *adap, const char *name, struct module *module, struct device *device); | 90 | extern int dvb_register_adapter(struct dvb_adapter *adap, const char *name, |
| 91 | struct module *module, struct device *device, | ||
| 92 | short *adapter_nums); | ||
| 82 | extern int dvb_unregister_adapter (struct dvb_adapter *adap); | 93 | extern int dvb_unregister_adapter (struct dvb_adapter *adap); |
| 83 | 94 | ||
| 84 | extern int dvb_register_device (struct dvb_adapter *adap, | 95 | extern int dvb_register_device (struct dvb_adapter *adap, |
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig index d73934dd4c57..3c8493d2026d 100644 --- a/drivers/media/dvb/dvb-usb/Kconfig +++ b/drivers/media/dvb/dvb-usb/Kconfig | |||
| @@ -105,6 +105,7 @@ config DVB_USB_CXUSB | |||
| 105 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE | 105 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE |
| 106 | select DVB_MT352 if !DVB_FE_CUSTOMISE | 106 | select DVB_MT352 if !DVB_FE_CUSTOMISE |
| 107 | select DVB_ZL10353 if !DVB_FE_CUSTOMISE | 107 | select DVB_ZL10353 if !DVB_FE_CUSTOMISE |
| 108 | select TUNER_SIMPLE if !DVB_FE_CUSTOMISE | ||
| 108 | help | 109 | help |
| 109 | Say Y here to support the Conexant USB2.0 hybrid reference design. | 110 | Say Y here to support the Conexant USB2.0 hybrid reference design. |
| 110 | Currently, only DVB and ATSC modes are supported, analog mode | 111 | Currently, only DVB and ATSC modes are supported, analog mode |
diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c index a6c5f19f680d..dc8c8784caa8 100644 --- a/drivers/media/dvb/dvb-usb/a800.c +++ b/drivers/media/dvb/dvb-usb/a800.c | |||
| @@ -18,6 +18,9 @@ | |||
| 18 | static int debug; | 18 | static int debug; |
| 19 | module_param(debug, int, 0644); | 19 | module_param(debug, int, 0644); |
| 20 | MODULE_PARM_DESC(debug, "set debugging level (rc=1 (or-able))." DVB_USB_DEBUG_STATUS); | 20 | MODULE_PARM_DESC(debug, "set debugging level (rc=1 (or-able))." DVB_USB_DEBUG_STATUS); |
| 21 | |||
| 22 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 23 | |||
| 21 | #define deb_rc(args...) dprintk(debug,0x01,args) | 24 | #define deb_rc(args...) dprintk(debug,0x01,args) |
| 22 | 25 | ||
| 23 | static int a800_power_ctrl(struct dvb_usb_device *d, int onoff) | 26 | static int a800_power_ctrl(struct dvb_usb_device *d, int onoff) |
| @@ -94,7 +97,8 @@ static struct dvb_usb_device_properties a800_properties; | |||
| 94 | static int a800_probe(struct usb_interface *intf, | 97 | static int a800_probe(struct usb_interface *intf, |
| 95 | const struct usb_device_id *id) | 98 | const struct usb_device_id *id) |
| 96 | { | 99 | { |
| 97 | return dvb_usb_device_init(intf,&a800_properties,THIS_MODULE,NULL); | 100 | return dvb_usb_device_init(intf, &a800_properties, |
| 101 | THIS_MODULE, NULL, adapter_nr); | ||
| 98 | } | 102 | } |
| 99 | 103 | ||
| 100 | /* do not change the order of the ID table */ | 104 | /* do not change the order of the ID table */ |
diff --git a/drivers/media/dvb/dvb-usb/af9005.c b/drivers/media/dvb/dvb-usb/af9005.c index e7f76f515b4f..cfe71feefcad 100644 --- a/drivers/media/dvb/dvb-usb/af9005.c +++ b/drivers/media/dvb/dvb-usb/af9005.c | |||
| @@ -39,6 +39,8 @@ int dvb_usb_af9005_dump_eeprom = 0; | |||
| 39 | module_param_named(dump_eeprom, dvb_usb_af9005_dump_eeprom, int, 0); | 39 | module_param_named(dump_eeprom, dvb_usb_af9005_dump_eeprom, int, 0); |
| 40 | MODULE_PARM_DESC(dump_eeprom, "dump contents of the eeprom."); | 40 | MODULE_PARM_DESC(dump_eeprom, "dump contents of the eeprom."); |
| 41 | 41 | ||
| 42 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 43 | |||
| 42 | /* remote control decoder */ | 44 | /* remote control decoder */ |
| 43 | int (*rc_decode) (struct dvb_usb_device * d, u8 * data, int len, u32 * event, | 45 | int (*rc_decode) (struct dvb_usb_device * d, u8 * data, int len, u32 * event, |
| 44 | int *state); | 46 | int *state); |
| @@ -1020,7 +1022,8 @@ static struct dvb_usb_device_properties af9005_properties; | |||
| 1020 | static int af9005_usb_probe(struct usb_interface *intf, | 1022 | static int af9005_usb_probe(struct usb_interface *intf, |
| 1021 | const struct usb_device_id *id) | 1023 | const struct usb_device_id *id) |
| 1022 | { | 1024 | { |
| 1023 | return dvb_usb_device_init(intf, &af9005_properties, THIS_MODULE, NULL); | 1025 | return dvb_usb_device_init(intf, &af9005_properties, |
| 1026 | THIS_MODULE, NULL, adapter_nr); | ||
| 1024 | } | 1027 | } |
| 1025 | 1028 | ||
| 1026 | static struct usb_device_id af9005_usb_table[] = { | 1029 | static struct usb_device_id af9005_usb_table[] = { |
diff --git a/drivers/media/dvb/dvb-usb/au6610.c b/drivers/media/dvb/dvb-usb/au6610.c index f3ff81314696..2ccb90fa60c8 100644 --- a/drivers/media/dvb/dvb-usb/au6610.c +++ b/drivers/media/dvb/dvb-usb/au6610.c | |||
| @@ -19,6 +19,8 @@ static int dvb_usb_au6610_debug; | |||
| 19 | module_param_named(debug, dvb_usb_au6610_debug, int, 0644); | 19 | module_param_named(debug, dvb_usb_au6610_debug, int, 0644); |
| 20 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); | 20 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); |
| 21 | 21 | ||
| 22 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 23 | |||
| 22 | static int au6610_usb_msg(struct dvb_usb_device *d, u8 operation, u8 addr, | 24 | static int au6610_usb_msg(struct dvb_usb_device *d, u8 operation, u8 addr, |
| 23 | u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen) | 25 | u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen) |
| 24 | { | 26 | { |
| @@ -163,7 +165,9 @@ static int au6610_probe(struct usb_interface *intf, | |||
| 163 | if (intf->num_altsetting < AU6610_ALTSETTING_COUNT) | 165 | if (intf->num_altsetting < AU6610_ALTSETTING_COUNT) |
| 164 | return -ENODEV; | 166 | return -ENODEV; |
| 165 | 167 | ||
| 166 | if ((ret = dvb_usb_device_init(intf, &au6610_properties, THIS_MODULE, &d)) == 0) { | 168 | ret = dvb_usb_device_init(intf, &au6610_properties, THIS_MODULE, &d, |
| 169 | adapter_nr); | ||
| 170 | if (ret == 0) { | ||
| 167 | alt = usb_altnum_to_altsetting(intf, AU6610_ALTSETTING); | 171 | alt = usb_altnum_to_altsetting(intf, AU6610_ALTSETTING); |
| 168 | 172 | ||
| 169 | if (alt == NULL) { | 173 | if (alt == NULL) { |
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c index c58365005ac1..720fcd1c3c1d 100644 --- a/drivers/media/dvb/dvb-usb/cxusb.c +++ b/drivers/media/dvb/dvb-usb/cxusb.c | |||
| @@ -23,6 +23,8 @@ | |||
| 23 | * | 23 | * |
| 24 | * see Documentation/dvb/README.dvb-usb for more information | 24 | * see Documentation/dvb/README.dvb-usb for more information |
| 25 | */ | 25 | */ |
| 26 | #include <media/tuner.h> | ||
| 27 | |||
| 26 | #include "cxusb.h" | 28 | #include "cxusb.h" |
| 27 | 29 | ||
| 28 | #include "cx22702.h" | 30 | #include "cx22702.h" |
| @@ -31,12 +33,15 @@ | |||
| 31 | #include "mt352_priv.h" | 33 | #include "mt352_priv.h" |
| 32 | #include "zl10353.h" | 34 | #include "zl10353.h" |
| 33 | #include "tuner-xc2028.h" | 35 | #include "tuner-xc2028.h" |
| 34 | #include "tuner-xc2028-types.h" | 36 | #include "tuner-simple.h" |
| 35 | 37 | ||
| 36 | /* debug */ | 38 | /* debug */ |
| 37 | static int dvb_usb_cxusb_debug; | 39 | static int dvb_usb_cxusb_debug; |
| 38 | module_param_named(debug, dvb_usb_cxusb_debug, int, 0644); | 40 | module_param_named(debug, dvb_usb_cxusb_debug, int, 0644); |
| 39 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); | 41 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); |
| 42 | |||
| 43 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 44 | |||
| 40 | #define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args) | 45 | #define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args) |
| 41 | #define deb_i2c(args...) if (d->udev->descriptor.idVendor == USB_VID_MEDION) \ | 46 | #define deb_i2c(args...) if (d->udev->descriptor.idVendor == USB_VID_MEDION) \ |
| 42 | dprintk(dvb_usb_cxusb_debug,0x01,args) | 47 | dprintk(dvb_usb_cxusb_debug,0x01,args) |
| @@ -450,8 +455,9 @@ static struct mt352_config cxusb_mt352_xc3028_config = { | |||
| 450 | /* Callbacks for DVB USB */ | 455 | /* Callbacks for DVB USB */ |
| 451 | static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap) | 456 | static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap) |
| 452 | { | 457 | { |
| 453 | dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap, | 458 | dvb_attach(simple_tuner_attach, adap->fe, |
| 454 | DVB_PLL_FMD1216ME); | 459 | &adap->dev->i2c_adap, 0x61, |
| 460 | TUNER_PHILIPS_FMD1216ME_MK3); | ||
| 455 | return 0; | 461 | return 0; |
| 456 | } | 462 | } |
| 457 | 463 | ||
| @@ -477,8 +483,8 @@ static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap) | |||
| 477 | 483 | ||
| 478 | static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap) | 484 | static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap) |
| 479 | { | 485 | { |
| 480 | dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap, | 486 | dvb_attach(simple_tuner_attach, adap->fe, |
| 481 | DVB_PLL_LG_TDVS_H06XF); | 487 | &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF); |
| 482 | return 0; | 488 | return 0; |
| 483 | } | 489 | } |
| 484 | 490 | ||
| @@ -488,14 +494,14 @@ static int dvico_bluebird_xc2028_callback(void *ptr, int command, int arg) | |||
| 488 | 494 | ||
| 489 | switch (command) { | 495 | switch (command) { |
| 490 | case XC2028_TUNER_RESET: | 496 | case XC2028_TUNER_RESET: |
| 491 | deb_info("%s: XC2028_TUNER_RESET %d\n", __FUNCTION__, arg); | 497 | deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg); |
| 492 | cxusb_bluebird_gpio_pulse(d, 0x01, 1); | 498 | cxusb_bluebird_gpio_pulse(d, 0x01, 1); |
| 493 | break; | 499 | break; |
| 494 | case XC2028_RESET_CLK: | 500 | case XC2028_RESET_CLK: |
| 495 | deb_info("%s: XC2028_RESET_CLK %d\n", __FUNCTION__, arg); | 501 | deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg); |
| 496 | break; | 502 | break; |
| 497 | default: | 503 | default: |
| 498 | deb_info("%s: unknown command %d, arg %d\n", __FUNCTION__, | 504 | deb_info("%s: unknown command %d, arg %d\n", __func__, |
| 499 | command, arg); | 505 | command, arg); |
| 500 | return -EINVAL; | 506 | return -EINVAL; |
| 501 | } | 507 | } |
| @@ -509,13 +515,12 @@ static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap) | |||
| 509 | struct xc2028_config cfg = { | 515 | struct xc2028_config cfg = { |
| 510 | .i2c_adap = &adap->dev->i2c_adap, | 516 | .i2c_adap = &adap->dev->i2c_adap, |
| 511 | .i2c_addr = 0x61, | 517 | .i2c_addr = 0x61, |
| 512 | .video_dev = adap->dev, | ||
| 513 | .callback = dvico_bluebird_xc2028_callback, | 518 | .callback = dvico_bluebird_xc2028_callback, |
| 514 | }; | 519 | }; |
| 515 | static struct xc2028_ctrl ctl = { | 520 | static struct xc2028_ctrl ctl = { |
| 516 | .fname = "xc3028-dvico-au-01.fw", | 521 | .fname = "xc3028-dvico-au-01.fw", |
| 517 | .max_len = 64, | 522 | .max_len = 64, |
| 518 | .scode_table = ZARLINK456, | 523 | .scode_table = XC3028_FE_ZARLINK456, |
| 519 | }; | 524 | }; |
| 520 | 525 | ||
| 521 | fe = dvb_attach(xc2028_attach, adap->fe, &cfg); | 526 | fe = dvb_attach(xc2028_attach, adap->fe, &cfg); |
| @@ -720,16 +725,24 @@ static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_prope | |||
| 720 | static int cxusb_probe(struct usb_interface *intf, | 725 | static int cxusb_probe(struct usb_interface *intf, |
| 721 | const struct usb_device_id *id) | 726 | const struct usb_device_id *id) |
| 722 | { | 727 | { |
| 723 | if (dvb_usb_device_init(intf,&cxusb_medion_properties,THIS_MODULE,NULL) == 0 || | 728 | if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties, |
| 724 | dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0 || | 729 | THIS_MODULE, NULL, adapter_nr) || |
| 725 | dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0 || | 730 | 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties, |
| 726 | dvb_usb_device_init(intf,&cxusb_bluebird_lgz201_properties,THIS_MODULE,NULL) == 0 || | 731 | THIS_MODULE, NULL, adapter_nr) || |
| 727 | dvb_usb_device_init(intf,&cxusb_bluebird_dtt7579_properties,THIS_MODULE,NULL) == 0 || | 732 | 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties, |
| 728 | dvb_usb_device_init(intf,&cxusb_bluebird_dualdig4_properties,THIS_MODULE,NULL) == 0 || | 733 | THIS_MODULE, NULL, adapter_nr) || |
| 729 | dvb_usb_device_init(intf,&cxusb_bluebird_nano2_properties,THIS_MODULE,NULL) == 0 || | 734 | 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties, |
| 730 | dvb_usb_device_init(intf,&cxusb_bluebird_nano2_needsfirmware_properties,THIS_MODULE,NULL) == 0) { | 735 | THIS_MODULE, NULL, adapter_nr) || |
| 736 | 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties, | ||
| 737 | THIS_MODULE, NULL, adapter_nr) || | ||
| 738 | 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties, | ||
| 739 | THIS_MODULE, NULL, adapter_nr) || | ||
| 740 | 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties, | ||
| 741 | THIS_MODULE, NULL, adapter_nr) || | ||
| 742 | 0 == dvb_usb_device_init(intf, | ||
| 743 | &cxusb_bluebird_nano2_needsfirmware_properties, | ||
| 744 | THIS_MODULE, NULL, adapter_nr)) | ||
| 731 | return 0; | 745 | return 0; |
| 732 | } | ||
| 733 | 746 | ||
| 734 | return -EINVAL; | 747 | return -EINVAL; |
| 735 | } | 748 | } |
diff --git a/drivers/media/dvb/dvb-usb/dib0700.h b/drivers/media/dvb/dvb-usb/dib0700.h index 4a903ea95896..66d4dc6ba46f 100644 --- a/drivers/media/dvb/dvb-usb/dib0700.h +++ b/drivers/media/dvb/dvb-usb/dib0700.h | |||
| @@ -37,6 +37,7 @@ struct dib0700_state { | |||
| 37 | u8 channel_state; | 37 | u8 channel_state; |
| 38 | u16 mt2060_if1[2]; | 38 | u16 mt2060_if1[2]; |
| 39 | u8 rc_toggle; | 39 | u8 rc_toggle; |
| 40 | u8 rc_counter; | ||
| 40 | u8 is_dib7000pc; | 41 | u8 is_dib7000pc; |
| 41 | }; | 42 | }; |
| 42 | 43 | ||
| @@ -44,12 +45,15 @@ extern int dib0700_set_gpio(struct dvb_usb_device *, enum dib07x0_gpios gpio, u8 | |||
| 44 | extern int dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3); | 45 | extern int dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3); |
| 45 | extern int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen); | 46 | extern int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen); |
| 46 | extern int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw); | 47 | extern int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw); |
| 48 | extern int dib0700_rc_setup(struct dvb_usb_device *d); | ||
| 47 | extern int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff); | 49 | extern int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff); |
| 48 | extern struct i2c_algorithm dib0700_i2c_algo; | 50 | extern struct i2c_algorithm dib0700_i2c_algo; |
| 49 | extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props, | 51 | extern int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props, |
| 50 | struct dvb_usb_device_description **desc, int *cold); | 52 | struct dvb_usb_device_description **desc, int *cold); |
| 51 | 53 | ||
| 52 | extern int dib0700_device_count; | 54 | extern int dib0700_device_count; |
| 55 | extern int dvb_usb_dib0700_ir_proto; | ||
| 53 | extern struct dvb_usb_device_properties dib0700_devices[]; | 56 | extern struct dvb_usb_device_properties dib0700_devices[]; |
| 54 | extern struct usb_device_id dib0700_usb_id_table[]; | 57 | extern struct usb_device_id dib0700_usb_id_table[]; |
| 58 | |||
| 55 | #endif | 59 | #endif |
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c index c9857d5c6982..595a04696c87 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_core.c +++ b/drivers/media/dvb/dvb-usb/dib0700_core.c | |||
| @@ -13,10 +13,12 @@ int dvb_usb_dib0700_debug; | |||
| 13 | module_param_named(debug,dvb_usb_dib0700_debug, int, 0644); | 13 | module_param_named(debug,dvb_usb_dib0700_debug, int, 0644); |
| 14 | MODULE_PARM_DESC(debug, "set debugging level (1=info,2=fw,4=fwdata,8=data (or-able))." DVB_USB_DEBUG_STATUS); | 14 | MODULE_PARM_DESC(debug, "set debugging level (1=info,2=fw,4=fwdata,8=data (or-able))." DVB_USB_DEBUG_STATUS); |
| 15 | 15 | ||
| 16 | static int dvb_usb_dib0700_ir_proto = 1; | 16 | int dvb_usb_dib0700_ir_proto = 1; |
| 17 | module_param(dvb_usb_dib0700_ir_proto, int, 0644); | 17 | module_param(dvb_usb_dib0700_ir_proto, int, 0644); |
| 18 | MODULE_PARM_DESC(dvb_usb_dib0700_ir_proto, "set ir protocol (0=NEC, 1=RC5 (default), 2=RC6)."); | 18 | MODULE_PARM_DESC(dvb_usb_dib0700_ir_proto, "set ir protocol (0=NEC, 1=RC5 (default), 2=RC6)."); |
| 19 | 19 | ||
| 20 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 21 | |||
| 20 | /* expecting rx buffer: request data[0] data[1] ... data[2] */ | 22 | /* expecting rx buffer: request data[0] data[1] ... data[2] */ |
| 21 | static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen) | 23 | static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen) |
| 22 | { | 24 | { |
| @@ -261,7 +263,7 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff) | |||
| 261 | return dib0700_ctrl_wr(adap->dev, b, 4); | 263 | return dib0700_ctrl_wr(adap->dev, b, 4); |
| 262 | } | 264 | } |
| 263 | 265 | ||
| 264 | static int dib0700_rc_setup(struct dvb_usb_device *d) | 266 | int dib0700_rc_setup(struct dvb_usb_device *d) |
| 265 | { | 267 | { |
| 266 | u8 rc_setup[3] = {REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0}; | 268 | u8 rc_setup[3] = {REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0}; |
| 267 | int i = dib0700_ctrl_wr(d, rc_setup, 3); | 269 | int i = dib0700_ctrl_wr(d, rc_setup, 3); |
| @@ -279,7 +281,8 @@ static int dib0700_probe(struct usb_interface *intf, | |||
| 279 | struct dvb_usb_device *dev; | 281 | struct dvb_usb_device *dev; |
| 280 | 282 | ||
| 281 | for (i = 0; i < dib0700_device_count; i++) | 283 | for (i = 0; i < dib0700_device_count; i++) |
| 282 | if (dvb_usb_device_init(intf, &dib0700_devices[i], THIS_MODULE, &dev) == 0) | 284 | if (dvb_usb_device_init(intf, &dib0700_devices[i], THIS_MODULE, |
| 285 | &dev, adapter_nr) == 0) | ||
| 283 | { | 286 | { |
| 284 | dib0700_rc_setup(dev); | 287 | dib0700_rc_setup(dev); |
| 285 | return 0; | 288 | return 0; |
diff --git a/drivers/media/dvb/dvb-usb/dib0700_devices.c b/drivers/media/dvb/dvb-usb/dib0700_devices.c index e7093826e975..6477fc66cc23 100644 --- a/drivers/media/dvb/dvb-usb/dib0700_devices.c +++ b/drivers/media/dvb/dvb-usb/dib0700_devices.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "dib7000p.h" | 13 | #include "dib7000p.h" |
| 14 | #include "mt2060.h" | 14 | #include "mt2060.h" |
| 15 | #include "mt2266.h" | 15 | #include "mt2266.h" |
| 16 | #include "tuner-xc2028.h" | ||
| 16 | #include "dib0070.h" | 17 | #include "dib0070.h" |
| 17 | 18 | ||
| 18 | static int force_lna_activation; | 19 | static int force_lna_activation; |
| @@ -297,10 +298,156 @@ static int stk7700d_tuner_attach(struct dvb_usb_adapter *adap) | |||
| 297 | &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;; | 298 | &stk7700d_mt2266_config[adap->id]) == NULL ? -ENODEV : 0;; |
| 298 | } | 299 | } |
| 299 | 300 | ||
| 301 | /* STK7700-PH: Digital/Analog Hybrid Tuner, e.h. Cinergy HT USB HE */ | ||
| 302 | struct dibx000_agc_config xc3028_agc_config = { | ||
| 303 | BAND_VHF | BAND_UHF, /* band_caps */ | ||
| 304 | |||
| 305 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0, | ||
| 306 | * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0, | ||
| 307 | * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=2, P_agc_write=0 */ | ||
| 308 | (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | | ||
| 309 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */ | ||
| 310 | |||
| 311 | 712, /* inv_gain */ | ||
| 312 | 21, /* time_stabiliz */ | ||
| 313 | |||
| 314 | 0, /* alpha_level */ | ||
| 315 | 118, /* thlock */ | ||
| 316 | |||
| 317 | 0, /* wbd_inv */ | ||
| 318 | 2867, /* wbd_ref */ | ||
| 319 | 0, /* wbd_sel */ | ||
| 320 | 2, /* wbd_alpha */ | ||
| 321 | |||
| 322 | 0, /* agc1_max */ | ||
| 323 | 0, /* agc1_min */ | ||
| 324 | 39718, /* agc2_max */ | ||
| 325 | 9930, /* agc2_min */ | ||
| 326 | 0, /* agc1_pt1 */ | ||
| 327 | 0, /* agc1_pt2 */ | ||
| 328 | 0, /* agc1_pt3 */ | ||
| 329 | 0, /* agc1_slope1 */ | ||
| 330 | 0, /* agc1_slope2 */ | ||
| 331 | 0, /* agc2_pt1 */ | ||
| 332 | 128, /* agc2_pt2 */ | ||
| 333 | 29, /* agc2_slope1 */ | ||
| 334 | 29, /* agc2_slope2 */ | ||
| 335 | |||
| 336 | 17, /* alpha_mant */ | ||
| 337 | 27, /* alpha_exp */ | ||
| 338 | 23, /* beta_mant */ | ||
| 339 | 51, /* beta_exp */ | ||
| 340 | |||
| 341 | 1, /* perform_agc_softsplit */ | ||
| 342 | }; | ||
| 343 | |||
| 344 | /* PLL Configuration for COFDM BW_MHz = 8.00 with external clock = 30.00 */ | ||
| 345 | struct dibx000_bandwidth_config xc3028_bw_config = { | ||
| 346 | 60000, 30000, /* internal, sampling */ | ||
| 347 | 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */ | ||
| 348 | 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, | ||
| 349 | modulo */ | ||
| 350 | (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */ | ||
| 351 | (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */ | ||
| 352 | 20452225, /* timf */ | ||
| 353 | 30000000, /* xtal_hz */ | ||
| 354 | }; | ||
| 355 | |||
| 356 | static struct dib7000p_config stk7700ph_dib7700_xc3028_config = { | ||
| 357 | .output_mpeg2_in_188_bytes = 1, | ||
| 358 | .tuner_is_baseband = 1, | ||
| 359 | |||
| 360 | .agc_config_count = 1, | ||
| 361 | .agc = &xc3028_agc_config, | ||
| 362 | .bw = &xc3028_bw_config, | ||
| 363 | |||
| 364 | .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, | ||
| 365 | .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, | ||
| 366 | .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, | ||
| 367 | }; | ||
| 368 | |||
| 369 | static int stk7700ph_xc3028_callback(void *ptr, int command, int arg) | ||
| 370 | { | ||
| 371 | struct dvb_usb_adapter *adap = ptr; | ||
| 372 | |||
| 373 | switch (command) { | ||
| 374 | case XC2028_TUNER_RESET: | ||
| 375 | /* Send the tuner in then out of reset */ | ||
| 376 | dib7000p_set_gpio(adap->fe, 8, 0, 0); msleep(10); | ||
| 377 | dib7000p_set_gpio(adap->fe, 8, 0, 1); | ||
| 378 | break; | ||
| 379 | case XC2028_RESET_CLK: | ||
| 380 | break; | ||
| 381 | default: | ||
| 382 | err("%s: unknown command %d, arg %d\n", __func__, | ||
| 383 | command, arg); | ||
| 384 | return -EINVAL; | ||
| 385 | } | ||
| 386 | return 0; | ||
| 387 | } | ||
| 388 | |||
| 389 | static struct xc2028_ctrl stk7700ph_xc3028_ctrl = { | ||
| 390 | .fname = XC2028_DEFAULT_FIRMWARE, | ||
| 391 | .max_len = 64, | ||
| 392 | .demod = XC3028_FE_DIBCOM52, | ||
| 393 | }; | ||
| 394 | |||
| 395 | static struct xc2028_config stk7700ph_xc3028_config = { | ||
| 396 | .i2c_addr = 0x61, | ||
| 397 | .callback = stk7700ph_xc3028_callback, | ||
| 398 | .ctrl = &stk7700ph_xc3028_ctrl, | ||
| 399 | }; | ||
| 400 | |||
| 401 | static int stk7700ph_frontend_attach(struct dvb_usb_adapter *adap) | ||
| 402 | { | ||
| 403 | struct usb_device_descriptor *desc = &adap->dev->udev->descriptor; | ||
| 404 | |||
| 405 | if (desc->idVendor == USB_VID_PINNACLE && | ||
| 406 | desc->idProduct == USB_PID_PINNACLE_EXPRESSCARD_320CX) | ||
| 407 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); | ||
| 408 | else | ||
| 409 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); | ||
| 410 | msleep(20); | ||
| 411 | dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); | ||
| 412 | dib0700_set_gpio(adap->dev, GPIO4, GPIO_OUT, 1); | ||
| 413 | dib0700_set_gpio(adap->dev, GPIO7, GPIO_OUT, 1); | ||
| 414 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 0); | ||
| 415 | msleep(10); | ||
| 416 | dib0700_set_gpio(adap->dev, GPIO10, GPIO_OUT, 1); | ||
| 417 | msleep(20); | ||
| 418 | dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); | ||
| 419 | msleep(10); | ||
| 420 | |||
| 421 | dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, | ||
| 422 | &stk7700ph_dib7700_xc3028_config); | ||
| 423 | |||
| 424 | adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, | ||
| 425 | &stk7700ph_dib7700_xc3028_config); | ||
| 426 | |||
| 427 | return adap->fe == NULL ? -ENODEV : 0; | ||
| 428 | } | ||
| 429 | |||
| 430 | static int stk7700ph_tuner_attach(struct dvb_usb_adapter *adap) | ||
| 431 | { | ||
| 432 | struct i2c_adapter *tun_i2c; | ||
| 433 | |||
| 434 | tun_i2c = dib7000p_get_i2c_master(adap->fe, | ||
| 435 | DIBX000_I2C_INTERFACE_TUNER, 1); | ||
| 436 | |||
| 437 | stk7700ph_xc3028_config.i2c_adap = tun_i2c; | ||
| 438 | stk7700ph_xc3028_config.video_dev = adap; | ||
| 439 | |||
| 440 | return dvb_attach(xc2028_attach, adap->fe, &stk7700ph_xc3028_config) | ||
| 441 | == NULL ? -ENODEV : 0; | ||
| 442 | } | ||
| 443 | |||
| 300 | #define DEFAULT_RC_INTERVAL 150 | 444 | #define DEFAULT_RC_INTERVAL 150 |
| 301 | 445 | ||
| 302 | static u8 rc_request[] = { REQUEST_POLL_RC, 0 }; | 446 | static u8 rc_request[] = { REQUEST_POLL_RC, 0 }; |
| 303 | 447 | ||
| 448 | /* Number of keypresses to ignore before start repeating */ | ||
| 449 | #define RC_REPEAT_DELAY 2 | ||
| 450 | |||
| 304 | static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | 451 | static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state) |
| 305 | { | 452 | { |
| 306 | u8 key[4]; | 453 | u8 key[4]; |
| @@ -314,18 +461,67 @@ static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
| 314 | err("RC Query Failed"); | 461 | err("RC Query Failed"); |
| 315 | return -1; | 462 | return -1; |
| 316 | } | 463 | } |
| 464 | |||
| 465 | /* losing half of KEY_0 events from Philipps rc5 remotes.. */ | ||
| 317 | if (key[0]==0 && key[1]==0 && key[2]==0 && key[3]==0) return 0; | 466 | if (key[0]==0 && key[1]==0 && key[2]==0 && key[3]==0) return 0; |
| 318 | if (key[3-1]!=st->rc_toggle) { | 467 | |
| 468 | /* info("%d: %2X %2X %2X %2X",dvb_usb_dib0700_ir_proto,(int)key[3-2],(int)key[3-3],(int)key[3-1],(int)key[3]); */ | ||
| 469 | |||
| 470 | dib0700_rc_setup(d); /* reset ir sensor data to prevent false events */ | ||
| 471 | |||
| 472 | switch (dvb_usb_dib0700_ir_proto) { | ||
| 473 | case 0: { | ||
| 474 | /* NEC protocol sends repeat code as 0 0 0 FF */ | ||
| 475 | if ((key[3-2] == 0x00) && (key[3-3] == 0x00) && | ||
| 476 | (key[3] == 0xFF)) { | ||
| 477 | st->rc_counter++; | ||
| 478 | if (st->rc_counter > RC_REPEAT_DELAY) { | ||
| 479 | *event = d->last_event; | ||
| 480 | *state = REMOTE_KEY_PRESSED; | ||
| 481 | st->rc_counter = RC_REPEAT_DELAY; | ||
| 482 | } | ||
| 483 | return 0; | ||
| 484 | } | ||
| 319 | for (i=0;i<d->props.rc_key_map_size; i++) { | 485 | for (i=0;i<d->props.rc_key_map_size; i++) { |
| 320 | if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) { | 486 | if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) { |
| 487 | st->rc_counter = 0; | ||
| 488 | *event = keymap[i].event; | ||
| 489 | *state = REMOTE_KEY_PRESSED; | ||
| 490 | d->last_event = keymap[i].event; | ||
| 491 | return 0; | ||
| 492 | } | ||
| 493 | } | ||
| 494 | break; | ||
| 495 | } | ||
| 496 | default: { | ||
| 497 | /* RC-5 protocol changes toggle bit on new keypress */ | ||
| 498 | for (i = 0; i < d->props.rc_key_map_size; i++) { | ||
| 499 | if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) { | ||
| 500 | if (d->last_event == keymap[i].event && | ||
| 501 | key[3-1] == st->rc_toggle) { | ||
| 502 | st->rc_counter++; | ||
| 503 | /* prevents unwanted double hits */ | ||
| 504 | if (st->rc_counter > RC_REPEAT_DELAY) { | ||
| 505 | *event = d->last_event; | ||
| 506 | *state = REMOTE_KEY_PRESSED; | ||
| 507 | st->rc_counter = RC_REPEAT_DELAY; | ||
| 508 | } | ||
| 509 | |||
| 510 | return 0; | ||
| 511 | } | ||
| 512 | st->rc_counter = 0; | ||
| 321 | *event = keymap[i].event; | 513 | *event = keymap[i].event; |
| 322 | *state = REMOTE_KEY_PRESSED; | 514 | *state = REMOTE_KEY_PRESSED; |
| 323 | st->rc_toggle=key[3-1]; | 515 | st->rc_toggle = key[3-1]; |
| 516 | d->last_event = keymap[i].event; | ||
| 324 | return 0; | 517 | return 0; |
| 325 | } | 518 | } |
| 326 | } | 519 | } |
| 327 | err("Unknown remote controller key : %2X %2X",(int)key[3-2],(int)key[3-3]); | 520 | break; |
| 328 | } | 521 | } |
| 522 | } | ||
| 523 | err("Unknown remote controller key: %2X %2X %2X %2X", (int) key[3-2], (int) key[3-3], (int) key[3-1], (int) key[3]); | ||
| 524 | d->last_event = 0; | ||
| 329 | return 0; | 525 | return 0; |
| 330 | } | 526 | } |
| 331 | 527 | ||
| @@ -794,6 +990,10 @@ static struct dib7000p_config dib7070p_dib7000p_config = { | |||
| 794 | /* STK7070P */ | 990 | /* STK7070P */ |
| 795 | static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap) | 991 | static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap) |
| 796 | { | 992 | { |
| 993 | if (adap->dev->udev->descriptor.idVendor == USB_VID_PINNACLE && | ||
| 994 | adap->dev->udev->descriptor.idProduct == USB_PID_PINNACLE_PCTV72E) | ||
| 995 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 0); | ||
| 996 | else | ||
| 797 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); | 997 | dib0700_set_gpio(adap->dev, GPIO6, GPIO_OUT, 1); |
| 798 | msleep(10); | 998 | msleep(10); |
| 799 | dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); | 999 | dib0700_set_gpio(adap->dev, GPIO9, GPIO_OUT, 1); |
| @@ -808,9 +1008,11 @@ static int stk7070p_frontend_attach(struct dvb_usb_adapter *adap) | |||
| 808 | msleep(10); | 1008 | msleep(10); |
| 809 | dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); | 1009 | dib0700_set_gpio(adap->dev, GPIO0, GPIO_OUT, 1); |
| 810 | 1010 | ||
| 811 | dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, &dib7070p_dib7000p_config); | 1011 | dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18, |
| 1012 | &dib7070p_dib7000p_config); | ||
| 812 | 1013 | ||
| 813 | adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, &dib7070p_dib7000p_config); | 1014 | adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80, |
| 1015 | &dib7070p_dib7000p_config); | ||
| 814 | return adap->fe == NULL ? -ENODEV : 0; | 1016 | return adap->fe == NULL ? -ENODEV : 0; |
| 815 | } | 1017 | } |
| 816 | 1018 | ||
| @@ -878,34 +1080,43 @@ static int stk7070pd_frontend_attach1(struct dvb_usb_adapter *adap) | |||
| 878 | /* DVB-USB and USB stuff follows */ | 1080 | /* DVB-USB and USB stuff follows */ |
| 879 | struct usb_device_id dib0700_usb_id_table[] = { | 1081 | struct usb_device_id dib0700_usb_id_table[] = { |
| 880 | /* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) }, | 1082 | /* 0 */ { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P) }, |
| 881 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) }, | 1083 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700P_PC) }, |
| 882 | 1084 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) }, | |
| 883 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500) }, | 1085 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) }, |
| 884 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_500_2) }, | 1086 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) }, |
| 885 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK) }, | ||
| 886 | /* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) }, | 1087 | /* 5 */ { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR) }, |
| 887 | { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) }, | 1088 | { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500) }, |
| 888 | { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) }, | 1089 | { USB_DEVICE(USB_VID_UNIWILL, USB_PID_UNIWILL_STK7700P) }, |
| 889 | { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) }, | 1090 | { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P) }, |
| 890 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) }, | 1091 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_2) }, |
| 891 | /* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) }, | 1092 | /* 10 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_2) }, |
| 892 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) }, | 1093 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV2000E) }, |
| 893 | { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) }, | 1094 | { USB_DEVICE(USB_VID_TERRATEC, |
| 894 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) }, | 1095 | USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY) }, |
| 895 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) }, | 1096 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_TD_STICK) }, |
| 1097 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7700D) }, | ||
| 896 | /* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) }, | 1098 | /* 15 */{ USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070P) }, |
| 897 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) }, | 1099 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DVB_T_FLASH) }, |
| 898 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) }, | 1100 | { USB_DEVICE(USB_VID_DIBCOM, USB_PID_DIBCOM_STK7070PD) }, |
| 899 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) }, | 1101 | { USB_DEVICE(USB_VID_PINNACLE, |
| 900 | { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) }, | 1102 | USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T) }, |
| 1103 | { USB_DEVICE(USB_VID_COMPRO, USB_PID_COMPRO_VIDEOMATE_U500_PC) }, | ||
| 901 | /* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) }, | 1104 | /* 20 */{ USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_EXPRESS) }, |
| 902 | { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) }, | 1105 | { USB_DEVICE(USB_VID_GIGABYTE, USB_PID_GIGABYTE_U7000) }, |
| 903 | { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) }, | 1106 | { USB_DEVICE(USB_VID_ULTIMA_ELECTRONIC, USB_PID_ARTEC_T14BR) }, |
| 904 | { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) }, | 1107 | { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3000) }, |
| 905 | { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) }, | 1108 | { USB_DEVICE(USB_VID_ASUS, USB_PID_ASUS_U3100) }, |
| 906 | /* 25 */ { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) }, | 1109 | /* 25 */{ USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_NOVA_T_STICK_3) }, |
| 907 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) }, | 1110 | { USB_DEVICE(USB_VID_HAUPPAUGE, USB_PID_HAUPPAUGE_MYTV_T) }, |
| 908 | { 0 } /* Terminating entry */ | 1111 | { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_USB_XE) }, |
| 1112 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_EXPRESSCARD_320CX) }, | ||
| 1113 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV72E) }, | ||
| 1114 | /* 30 */{ USB_DEVICE(USB_VID_PINNACLE, USB_PID_PINNACLE_PCTV73E) }, | ||
| 1115 | { USB_DEVICE(USB_VID_YUAN, USB_PID_YUAN_EC372S) }, | ||
| 1116 | { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_HT_EXPRESS) }, | ||
| 1117 | { USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_XXS) }, | ||
| 1118 | { USB_DEVICE(USB_VID_LEADTEK, USB_PID_WINFAST_DTV_DONGLE_STK7700P_2) }, | ||
| 1119 | { 0 } /* Terminating entry */ | ||
| 909 | }; | 1120 | }; |
| 910 | MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); | 1121 | MODULE_DEVICE_TABLE(usb, dib0700_usb_id_table); |
| 911 | 1122 | ||
| @@ -969,7 +1180,7 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
| 969 | { NULL }, | 1180 | { NULL }, |
| 970 | }, | 1181 | }, |
| 971 | { "Leadtek Winfast DTV Dongle (STK7700P based)", | 1182 | { "Leadtek Winfast DTV Dongle (STK7700P based)", |
| 972 | { &dib0700_usb_id_table[8], NULL }, | 1183 | { &dib0700_usb_id_table[8], &dib0700_usb_id_table[34] }, |
| 973 | { NULL }, | 1184 | { NULL }, |
| 974 | }, | 1185 | }, |
| 975 | { "AVerMedia AVerTV DVB-T Express", | 1186 | { "AVerMedia AVerTV DVB-T Express", |
| @@ -1069,12 +1280,16 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
| 1069 | }, | 1280 | }, |
| 1070 | }, | 1281 | }, |
| 1071 | 1282 | ||
| 1072 | .num_device_descs = 1, | 1283 | .num_device_descs = 2, |
| 1073 | .devices = { | 1284 | .devices = { |
| 1074 | { "ASUS My Cinema U3000 Mini DVBT Tuner", | 1285 | { "ASUS My Cinema U3000 Mini DVBT Tuner", |
| 1075 | { &dib0700_usb_id_table[23], NULL }, | 1286 | { &dib0700_usb_id_table[23], NULL }, |
| 1076 | { NULL }, | 1287 | { NULL }, |
| 1077 | }, | 1288 | }, |
| 1289 | { "Yuan EC372S", | ||
| 1290 | { &dib0700_usb_id_table[31], NULL }, | ||
| 1291 | { NULL }, | ||
| 1292 | } | ||
| 1078 | } | 1293 | } |
| 1079 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, | 1294 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, |
| 1080 | 1295 | ||
| @@ -1090,7 +1305,7 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
| 1090 | }, | 1305 | }, |
| 1091 | }, | 1306 | }, |
| 1092 | 1307 | ||
| 1093 | .num_device_descs = 6, | 1308 | .num_device_descs = 9, |
| 1094 | .devices = { | 1309 | .devices = { |
| 1095 | { "DiBcom STK7070P reference design", | 1310 | { "DiBcom STK7070P reference design", |
| 1096 | { &dib0700_usb_id_table[15], NULL }, | 1311 | { &dib0700_usb_id_table[15], NULL }, |
| @@ -1116,6 +1331,18 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
| 1116 | { &dib0700_usb_id_table[26], NULL }, | 1331 | { &dib0700_usb_id_table[26], NULL }, |
| 1117 | { NULL }, | 1332 | { NULL }, |
| 1118 | }, | 1333 | }, |
| 1334 | { "Pinnacle PCTV 72e", | ||
| 1335 | { &dib0700_usb_id_table[29], NULL }, | ||
| 1336 | { NULL }, | ||
| 1337 | }, | ||
| 1338 | { "Pinnacle PCTV 73e", | ||
| 1339 | { &dib0700_usb_id_table[30], NULL }, | ||
| 1340 | { NULL }, | ||
| 1341 | }, | ||
| 1342 | { "Terratec Cinergy T USB XXS", | ||
| 1343 | { &dib0700_usb_id_table[33], NULL }, | ||
| 1344 | { NULL }, | ||
| 1345 | }, | ||
| 1119 | }, | 1346 | }, |
| 1120 | 1347 | ||
| 1121 | .rc_interval = DEFAULT_RC_INTERVAL, | 1348 | .rc_interval = DEFAULT_RC_INTERVAL, |
| @@ -1155,6 +1382,40 @@ struct dvb_usb_device_properties dib0700_devices[] = { | |||
| 1155 | { NULL }, | 1382 | { NULL }, |
| 1156 | } | 1383 | } |
| 1157 | } | 1384 | } |
| 1385 | }, { DIB0700_DEFAULT_DEVICE_PROPERTIES, | ||
| 1386 | |||
| 1387 | .num_adapters = 1, | ||
| 1388 | .adapter = { | ||
| 1389 | { | ||
| 1390 | .frontend_attach = stk7700ph_frontend_attach, | ||
| 1391 | .tuner_attach = stk7700ph_tuner_attach, | ||
| 1392 | |||
| 1393 | DIB0700_DEFAULT_STREAMING_CONFIG(0x02), | ||
| 1394 | |||
| 1395 | .size_of_priv = sizeof(struct | ||
| 1396 | dib0700_adapter_state), | ||
| 1397 | }, | ||
| 1398 | }, | ||
| 1399 | |||
| 1400 | .num_device_descs = 3, | ||
| 1401 | .devices = { | ||
| 1402 | { "Terratec Cinergy HT USB XE", | ||
| 1403 | { &dib0700_usb_id_table[27], NULL }, | ||
| 1404 | { NULL }, | ||
| 1405 | }, | ||
| 1406 | { "Pinnacle Expresscard 320cx", | ||
| 1407 | { &dib0700_usb_id_table[28], NULL }, | ||
| 1408 | { NULL }, | ||
| 1409 | }, | ||
| 1410 | { "Terratec Cinergy HT Express", | ||
| 1411 | { &dib0700_usb_id_table[32], NULL }, | ||
| 1412 | { NULL }, | ||
| 1413 | }, | ||
| 1414 | }, | ||
| 1415 | .rc_interval = DEFAULT_RC_INTERVAL, | ||
| 1416 | .rc_key_map = dib0700_rc_keys, | ||
| 1417 | .rc_key_map_size = ARRAY_SIZE(dib0700_rc_keys), | ||
| 1418 | .rc_query = dib0700_rc_query | ||
| 1158 | }, | 1419 | }, |
| 1159 | }; | 1420 | }; |
| 1160 | 1421 | ||
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c index 043cadae0859..eeef50bff4f9 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mb.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | */ | 14 | */ |
| 15 | #include "dibusb.h" | 15 | #include "dibusb.h" |
| 16 | 16 | ||
| 17 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 18 | |||
| 17 | static int dib3000mb_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) | 19 | static int dib3000mb_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) |
| 18 | { | 20 | { |
| 19 | struct dvb_usb_adapter *adap = fe->dvb->priv; | 21 | struct dvb_usb_adapter *adap = fe->dvb->priv; |
| @@ -107,10 +109,14 @@ static struct dvb_usb_device_properties artec_t1_usb2_properties; | |||
| 107 | static int dibusb_probe(struct usb_interface *intf, | 109 | static int dibusb_probe(struct usb_interface *intf, |
| 108 | const struct usb_device_id *id) | 110 | const struct usb_device_id *id) |
| 109 | { | 111 | { |
| 110 | if (dvb_usb_device_init(intf,&dibusb1_1_properties,THIS_MODULE,NULL) == 0 || | 112 | if (0 == dvb_usb_device_init(intf, &dibusb1_1_properties, |
| 111 | dvb_usb_device_init(intf,&dibusb1_1_an2235_properties,THIS_MODULE,NULL) == 0 || | 113 | THIS_MODULE, NULL, adapter_nr) || |
| 112 | dvb_usb_device_init(intf,&dibusb2_0b_properties,THIS_MODULE,NULL) == 0 || | 114 | 0 == dvb_usb_device_init(intf, &dibusb1_1_an2235_properties, |
| 113 | dvb_usb_device_init(intf,&artec_t1_usb2_properties,THIS_MODULE,NULL) == 0) | 115 | THIS_MODULE, NULL, adapter_nr) || |
| 116 | 0 == dvb_usb_device_init(intf, &dibusb2_0b_properties, | ||
| 117 | THIS_MODULE, NULL, adapter_nr) || | ||
| 118 | 0 == dvb_usb_device_init(intf, &artec_t1_usb2_properties, | ||
| 119 | THIS_MODULE, NULL, adapter_nr)) | ||
| 114 | return 0; | 120 | return 0; |
| 115 | 121 | ||
| 116 | return -EINVAL; | 122 | return -EINVAL; |
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c index e7ea3e753d6d..059cec955318 100644 --- a/drivers/media/dvb/dvb-usb/dibusb-mc.c +++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c | |||
| @@ -14,13 +14,16 @@ | |||
| 14 | */ | 14 | */ |
| 15 | #include "dibusb.h" | 15 | #include "dibusb.h" |
| 16 | 16 | ||
| 17 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 18 | |||
| 17 | /* USB Driver stuff */ | 19 | /* USB Driver stuff */ |
| 18 | static struct dvb_usb_device_properties dibusb_mc_properties; | 20 | static struct dvb_usb_device_properties dibusb_mc_properties; |
| 19 | 21 | ||
| 20 | static int dibusb_mc_probe(struct usb_interface *intf, | 22 | static int dibusb_mc_probe(struct usb_interface *intf, |
| 21 | const struct usb_device_id *id) | 23 | const struct usb_device_id *id) |
| 22 | { | 24 | { |
| 23 | return dvb_usb_device_init(intf,&dibusb_mc_properties,THIS_MODULE,NULL); | 25 | return dvb_usb_device_init(intf, &dibusb_mc_properties, THIS_MODULE, |
| 26 | NULL, adapter_nr); | ||
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | /* do not change the order of the ID table */ | 29 | /* do not change the order of the ID table */ |
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c index 3acbda4aa27e..b545cf3eab2e 100644 --- a/drivers/media/dvb/dvb-usb/digitv.c +++ b/drivers/media/dvb/dvb-usb/digitv.c | |||
| @@ -20,6 +20,9 @@ | |||
| 20 | static int dvb_usb_digitv_debug; | 20 | static int dvb_usb_digitv_debug; |
| 21 | module_param_named(debug,dvb_usb_digitv_debug, int, 0644); | 21 | module_param_named(debug,dvb_usb_digitv_debug, int, 0644); |
| 22 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); | 22 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); |
| 23 | |||
| 24 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 25 | |||
| 23 | #define deb_rc(args...) dprintk(dvb_usb_digitv_debug,0x01,args) | 26 | #define deb_rc(args...) dprintk(dvb_usb_digitv_debug,0x01,args) |
| 24 | 27 | ||
| 25 | static int digitv_ctrl_msg(struct dvb_usb_device *d, | 28 | static int digitv_ctrl_msg(struct dvb_usb_device *d, |
| @@ -256,8 +259,9 @@ static int digitv_probe(struct usb_interface *intf, | |||
| 256 | const struct usb_device_id *id) | 259 | const struct usb_device_id *id) |
| 257 | { | 260 | { |
| 258 | struct dvb_usb_device *d; | 261 | struct dvb_usb_device *d; |
| 259 | int ret; | 262 | int ret = dvb_usb_device_init(intf, &digitv_properties, THIS_MODULE, &d, |
| 260 | if ((ret = dvb_usb_device_init(intf,&digitv_properties,THIS_MODULE,&d)) == 0) { | 263 | adapter_nr); |
| 264 | if (ret == 0) { | ||
| 261 | u8 b[4] = { 0 }; | 265 | u8 b[4] = { 0 }; |
| 262 | 266 | ||
| 263 | if (d != NULL) { /* do that only when the firmware is loaded */ | 267 | if (d != NULL) { /* do that only when the firmware is loaded */ |
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c index d86cf9bee91c..81a6cbf60160 100644 --- a/drivers/media/dvb/dvb-usb/dtt200u.c +++ b/drivers/media/dvb/dvb-usb/dtt200u.c | |||
| @@ -18,6 +18,8 @@ int dvb_usb_dtt200u_debug; | |||
| 18 | module_param_named(debug,dvb_usb_dtt200u_debug, int, 0644); | 18 | module_param_named(debug,dvb_usb_dtt200u_debug, int, 0644); |
| 19 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2 (or-able))." DVB_USB_DEBUG_STATUS); | 19 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2 (or-able))." DVB_USB_DEBUG_STATUS); |
| 20 | 20 | ||
| 21 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 22 | |||
| 21 | static int dtt200u_power_ctrl(struct dvb_usb_device *d, int onoff) | 23 | static int dtt200u_power_ctrl(struct dvb_usb_device *d, int onoff) |
| 22 | { | 24 | { |
| 23 | u8 b = SET_INIT; | 25 | u8 b = SET_INIT; |
| @@ -101,11 +103,16 @@ static struct dvb_usb_device_properties wt220u_miglia_properties; | |||
| 101 | static int dtt200u_usb_probe(struct usb_interface *intf, | 103 | static int dtt200u_usb_probe(struct usb_interface *intf, |
| 102 | const struct usb_device_id *id) | 104 | const struct usb_device_id *id) |
| 103 | { | 105 | { |
| 104 | if (dvb_usb_device_init(intf,&dtt200u_properties,THIS_MODULE,NULL) == 0 || | 106 | if (0 == dvb_usb_device_init(intf, &dtt200u_properties, |
| 105 | dvb_usb_device_init(intf,&wt220u_properties,THIS_MODULE,NULL) == 0 || | 107 | THIS_MODULE, NULL, adapter_nr) || |
| 106 | dvb_usb_device_init(intf,&wt220u_fc_properties,THIS_MODULE,NULL) == 0 || | 108 | 0 == dvb_usb_device_init(intf, &wt220u_properties, |
| 107 | dvb_usb_device_init(intf,&wt220u_zl0353_properties,THIS_MODULE,NULL) == 0 || | 109 | THIS_MODULE, NULL, adapter_nr) || |
| 108 | dvb_usb_device_init(intf,&wt220u_miglia_properties,THIS_MODULE,NULL) == 0) | 110 | 0 == dvb_usb_device_init(intf, &wt220u_fc_properties, |
| 111 | THIS_MODULE, NULL, adapter_nr) || | ||
| 112 | 0 == dvb_usb_device_init(intf, &wt220u_zl0353_properties, | ||
| 113 | THIS_MODULE, NULL, adapter_nr) || | ||
| 114 | 0 == dvb_usb_device_init(intf, &wt220u_miglia_properties, | ||
| 115 | THIS_MODULE, NULL, adapter_nr)) | ||
| 109 | return 0; | 116 | return 0; |
| 110 | 117 | ||
| 111 | return -ENODEV; | 118 | return -ENODEV; |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-common.h b/drivers/media/dvb/dvb-usb/dvb-usb-common.h index 35ab68f6dcf6..6b7b2a89242e 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-common.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-common.h | |||
| @@ -40,7 +40,8 @@ extern int dvb_usb_adapter_stream_exit(struct dvb_usb_adapter *adap); | |||
| 40 | extern int dvb_usb_i2c_init(struct dvb_usb_device *); | 40 | extern int dvb_usb_i2c_init(struct dvb_usb_device *); |
| 41 | extern int dvb_usb_i2c_exit(struct dvb_usb_device *); | 41 | extern int dvb_usb_i2c_exit(struct dvb_usb_device *); |
| 42 | 42 | ||
| 43 | extern int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap); | 43 | extern int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap, |
| 44 | short *adapter_nums); | ||
| 44 | extern int dvb_usb_adapter_dvb_exit(struct dvb_usb_adapter *adap); | 45 | extern int dvb_usb_adapter_dvb_exit(struct dvb_usb_adapter *adap); |
| 45 | extern int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap); | 46 | extern int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap); |
| 46 | extern int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap); | 47 | extern int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap); |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c index 4561a672da92..ce8cd0c5d831 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c | |||
| @@ -77,12 +77,13 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) | |||
| 77 | return dvb_usb_ctrl_feed(dvbdmxfeed,0); | 77 | return dvb_usb_ctrl_feed(dvbdmxfeed,0); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) | 80 | int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap, short *adapter_nums) |
| 81 | { | 81 | { |
| 82 | int ret; | 82 | int ret = dvb_register_adapter(&adap->dvb_adap, adap->dev->desc->name, |
| 83 | adap->dev->owner, &adap->dev->udev->dev, | ||
| 84 | adapter_nums); | ||
| 83 | 85 | ||
| 84 | if ((ret = dvb_register_adapter(&adap->dvb_adap, adap->dev->desc->name, | 86 | if (ret < 0) { |
| 85 | adap->dev->owner, &adap->dev->udev->dev)) < 0) { | ||
| 86 | deb_info("dvb_register_adapter failed: error %d", ret); | 87 | deb_info("dvb_register_adapter failed: error %d", ret); |
| 87 | goto err; | 88 | goto err; |
| 88 | } | 89 | } |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h index aa4844ef875e..34245d1b7dd9 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h | |||
| @@ -40,14 +40,15 @@ | |||
| 40 | #define USB_VID_MSI 0x0db0 | 40 | #define USB_VID_MSI 0x0db0 |
| 41 | #define USB_VID_OPERA1 0x695c | 41 | #define USB_VID_OPERA1 0x695c |
| 42 | #define USB_VID_PINNACLE 0x2304 | 42 | #define USB_VID_PINNACLE 0x2304 |
| 43 | #define USB_VID_TECHNOTREND 0x0b48 | ||
| 43 | #define USB_VID_TERRATEC 0x0ccd | 44 | #define USB_VID_TERRATEC 0x0ccd |
| 44 | #define USB_VID_VISIONPLUS 0x13d3 | 45 | #define USB_VID_VISIONPLUS 0x13d3 |
| 45 | #define USB_VID_TWINHAN 0x1822 | 46 | #define USB_VID_TWINHAN 0x1822 |
| 46 | #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 | 47 | #define USB_VID_ULTIMA_ELECTRONIC 0x05d8 |
| 47 | #define USB_VID_UNIWILL 0x1584 | 48 | #define USB_VID_UNIWILL 0x1584 |
| 48 | #define USB_VID_WIDEVIEW 0x14aa | 49 | #define USB_VID_WIDEVIEW 0x14aa |
| 49 | /* dom : pour gigabyte u7000 */ | ||
| 50 | #define USB_VID_GIGABYTE 0x1044 | 50 | #define USB_VID_GIGABYTE 0x1044 |
| 51 | #define USB_VID_YUAN 0x1164 | ||
| 51 | 52 | ||
| 52 | 53 | ||
| 53 | /* Product IDs */ | 54 | /* Product IDs */ |
| @@ -134,10 +135,17 @@ | |||
| 134 | #define USB_PID_AVERMEDIA_EXPRESS 0xb568 | 135 | #define USB_PID_AVERMEDIA_EXPRESS 0xb568 |
| 135 | #define USB_PID_AVERMEDIA_VOLAR 0xa807 | 136 | #define USB_PID_AVERMEDIA_VOLAR 0xa807 |
| 136 | #define USB_PID_AVERMEDIA_VOLAR_2 0xb808 | 137 | #define USB_PID_AVERMEDIA_VOLAR_2 0xb808 |
| 138 | #define USB_PID_TECHNOTREND_CONNECT_S2400 0x3006 | ||
| 137 | #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a | 139 | #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY 0x005a |
| 140 | #define USB_PID_TERRATEC_CINERGY_HT_USB_XE 0x0058 | ||
| 141 | #define USB_PID_TERRATEC_CINERGY_HT_EXPRESS 0x0060 | ||
| 142 | #define USB_PID_TERRATEC_CINERGY_T_XXS 0x0078 | ||
| 143 | #define USB_PID_PINNACLE_EXPRESSCARD_320CX 0x022e | ||
| 138 | #define USB_PID_PINNACLE_PCTV2000E 0x022c | 144 | #define USB_PID_PINNACLE_PCTV2000E 0x022c |
| 139 | #define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 | 145 | #define USB_PID_PINNACLE_PCTV_DVB_T_FLASH 0x0228 |
| 140 | #define USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T 0x0229 | 146 | #define USB_PID_PINNACLE_PCTV_DUAL_DIVERSITY_DVB_T 0x0229 |
| 147 | #define USB_PID_PINNACLE_PCTV72E 0x0236 | ||
| 148 | #define USB_PID_PINNACLE_PCTV73E 0x0237 | ||
| 141 | #define USB_PID_PCTV_200E 0x020e | 149 | #define USB_PID_PCTV_200E 0x020e |
| 142 | #define USB_PID_PCTV_400E 0x020f | 150 | #define USB_PID_PCTV_400E 0x020f |
| 143 | #define USB_PID_PCTV_450E 0x0222 | 151 | #define USB_PID_PCTV_450E 0x0222 |
| @@ -172,6 +180,7 @@ | |||
| 172 | #define USB_PID_WINFAST_DTV_DONGLE_COLD 0x6025 | 180 | #define USB_PID_WINFAST_DTV_DONGLE_COLD 0x6025 |
| 173 | #define USB_PID_WINFAST_DTV_DONGLE_WARM 0x6026 | 181 | #define USB_PID_WINFAST_DTV_DONGLE_WARM 0x6026 |
| 174 | #define USB_PID_WINFAST_DTV_DONGLE_STK7700P 0x6f00 | 182 | #define USB_PID_WINFAST_DTV_DONGLE_STK7700P 0x6f00 |
| 183 | #define USB_PID_WINFAST_DTV_DONGLE_STK7700P_2 0x6f01 | ||
| 175 | #define USB_PID_GENPIX_8PSK_REV_1_COLD 0x0200 | 184 | #define USB_PID_GENPIX_8PSK_REV_1_COLD 0x0200 |
| 176 | #define USB_PID_GENPIX_8PSK_REV_1_WARM 0x0201 | 185 | #define USB_PID_GENPIX_8PSK_REV_1_WARM 0x0201 |
| 177 | #define USB_PID_GENPIX_8PSK_REV_2 0x0202 | 186 | #define USB_PID_GENPIX_8PSK_REV_2 0x0202 |
| @@ -183,9 +192,9 @@ | |||
| 183 | #define USB_PID_OPERA1_WARM 0x3829 | 192 | #define USB_PID_OPERA1_WARM 0x3829 |
| 184 | #define USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD 0x0514 | 193 | #define USB_PID_LIFEVIEW_TV_WALKER_TWIN_COLD 0x0514 |
| 185 | #define USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM 0x0513 | 194 | #define USB_PID_LIFEVIEW_TV_WALKER_TWIN_WARM 0x0513 |
| 186 | /* dom pour gigabyte u7000 */ | ||
| 187 | #define USB_PID_GIGABYTE_U7000 0x7001 | 195 | #define USB_PID_GIGABYTE_U7000 0x7001 |
| 188 | #define USB_PID_ASUS_U3000 0x171f | 196 | #define USB_PID_ASUS_U3000 0x171f |
| 189 | #define USB_PID_ASUS_U3100 0x173f | 197 | #define USB_PID_ASUS_U3100 0x173f |
| 198 | #define USB_PID_YUAN_EC372S 0x1edc | ||
| 190 | 199 | ||
| 191 | #endif | 200 | #endif |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c index cdd717c3fe45..e331db8c77b2 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c +++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c | |||
| @@ -26,7 +26,7 @@ static int dvb_usb_force_pid_filter_usage; | |||
| 26 | module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage, int, 0444); | 26 | module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage, int, 0444); |
| 27 | MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a PID filter, if any (default: 0)."); | 27 | MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a PID filter, if any (default: 0)."); |
| 28 | 28 | ||
| 29 | static int dvb_usb_adapter_init(struct dvb_usb_device *d) | 29 | static int dvb_usb_adapter_init(struct dvb_usb_device *d, short *adapter_nrs) |
| 30 | { | 30 | { |
| 31 | struct dvb_usb_adapter *adap; | 31 | struct dvb_usb_adapter *adap; |
| 32 | int ret,n; | 32 | int ret,n; |
| @@ -72,7 +72,7 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d) | |||
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | if ((ret = dvb_usb_adapter_stream_init(adap)) || | 74 | if ((ret = dvb_usb_adapter_stream_init(adap)) || |
| 75 | (ret = dvb_usb_adapter_dvb_init(adap)) || | 75 | (ret = dvb_usb_adapter_dvb_init(adap, adapter_nrs)) || |
| 76 | (ret = dvb_usb_adapter_frontend_init(adap))) { | 76 | (ret = dvb_usb_adapter_frontend_init(adap))) { |
| 77 | return ret; | 77 | return ret; |
| 78 | } | 78 | } |
| @@ -122,7 +122,7 @@ static int dvb_usb_exit(struct dvb_usb_device *d) | |||
| 122 | return 0; | 122 | return 0; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | static int dvb_usb_init(struct dvb_usb_device *d) | 125 | static int dvb_usb_init(struct dvb_usb_device *d, short *adapter_nums) |
| 126 | { | 126 | { |
| 127 | int ret = 0; | 127 | int ret = 0; |
| 128 | 128 | ||
| @@ -143,7 +143,7 @@ static int dvb_usb_init(struct dvb_usb_device *d) | |||
| 143 | dvb_usb_device_power_ctrl(d, 1); | 143 | dvb_usb_device_power_ctrl(d, 1); |
| 144 | 144 | ||
| 145 | if ((ret = dvb_usb_i2c_init(d)) || | 145 | if ((ret = dvb_usb_i2c_init(d)) || |
| 146 | (ret = dvb_usb_adapter_init(d))) { | 146 | (ret = dvb_usb_adapter_init(d, adapter_nums))) { |
| 147 | dvb_usb_exit(d); | 147 | dvb_usb_exit(d); |
| 148 | return ret; | 148 | return ret; |
| 149 | } | 149 | } |
| @@ -213,8 +213,10 @@ int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
| 213 | /* | 213 | /* |
| 214 | * USB | 214 | * USB |
| 215 | */ | 215 | */ |
| 216 | int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_device_properties | 216 | int dvb_usb_device_init(struct usb_interface *intf, |
| 217 | *props, struct module *owner,struct dvb_usb_device **du) | 217 | struct dvb_usb_device_properties *props, |
| 218 | struct module *owner, struct dvb_usb_device **du, | ||
| 219 | short *adapter_nums) | ||
| 218 | { | 220 | { |
| 219 | struct usb_device *udev = interface_to_usbdev(intf); | 221 | struct usb_device *udev = interface_to_usbdev(intf); |
| 220 | struct dvb_usb_device *d = NULL; | 222 | struct dvb_usb_device *d = NULL; |
| @@ -254,7 +256,7 @@ int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_device_proper | |||
| 254 | if (du != NULL) | 256 | if (du != NULL) |
| 255 | *du = d; | 257 | *du = d; |
| 256 | 258 | ||
| 257 | ret = dvb_usb_init(d); | 259 | ret = dvb_usb_init(d, adapter_nums); |
| 258 | 260 | ||
| 259 | if (ret == 0) | 261 | if (ret == 0) |
| 260 | info("%s successfully initialized and connected.",desc->name); | 262 | info("%s successfully initialized and connected.",desc->name); |
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h index d1b3c7b81fff..b1de0f7e26e8 100644 --- a/drivers/media/dvb/dvb-usb/dvb-usb.h +++ b/drivers/media/dvb/dvb-usb/dvb-usb.h | |||
| @@ -372,7 +372,10 @@ struct dvb_usb_device { | |||
| 372 | void *priv; | 372 | void *priv; |
| 373 | }; | 373 | }; |
| 374 | 374 | ||
| 375 | extern int dvb_usb_device_init(struct usb_interface *, struct dvb_usb_device_properties *, struct module *, struct dvb_usb_device **); | 375 | extern int dvb_usb_device_init(struct usb_interface *, |
| 376 | struct dvb_usb_device_properties *, | ||
| 377 | struct module *, struct dvb_usb_device **, | ||
| 378 | short *adapter_nums); | ||
| 376 | extern void dvb_usb_device_exit(struct usb_interface *); | 379 | extern void dvb_usb_device_exit(struct usb_interface *); |
| 377 | 380 | ||
| 378 | /* the generic read/write method for device control */ | 381 | /* the generic read/write method for device control */ |
diff --git a/drivers/media/dvb/dvb-usb/gl861.c b/drivers/media/dvb/dvb-usb/gl861.c index 6b99d9f4d5b3..0a8ac64a4e33 100644 --- a/drivers/media/dvb/dvb-usb/gl861.c +++ b/drivers/media/dvb/dvb-usb/gl861.c | |||
| @@ -16,6 +16,8 @@ static int dvb_usb_gl861_debug; | |||
| 16 | module_param_named(debug,dvb_usb_gl861_debug, int, 0644); | 16 | module_param_named(debug,dvb_usb_gl861_debug, int, 0644); |
| 17 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); | 17 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); |
| 18 | 18 | ||
| 19 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 20 | |||
| 19 | static int gl861_i2c_msg(struct dvb_usb_device *d, u8 addr, | 21 | static int gl861_i2c_msg(struct dvb_usb_device *d, u8 addr, |
| 20 | u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen) | 22 | u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen) |
| 21 | { | 23 | { |
| @@ -140,7 +142,9 @@ static int gl861_probe(struct usb_interface *intf, | |||
| 140 | if (intf->num_altsetting < 2) | 142 | if (intf->num_altsetting < 2) |
| 141 | return -ENODEV; | 143 | return -ENODEV; |
| 142 | 144 | ||
| 143 | if ((ret = dvb_usb_device_init(intf, &gl861_properties, THIS_MODULE, &d)) == 0) { | 145 | ret = dvb_usb_device_init(intf, &gl861_properties, THIS_MODULE, &d, |
| 146 | adapter_nr); | ||
| 147 | if (ret == 0) { | ||
| 144 | alt = usb_altnum_to_altsetting(intf, 0); | 148 | alt = usb_altnum_to_altsetting(intf, 0); |
| 145 | 149 | ||
| 146 | if (alt == NULL) { | 150 | if (alt == NULL) { |
diff --git a/drivers/media/dvb/dvb-usb/gp8psk-fe.c b/drivers/media/dvb/dvb-usb/gp8psk-fe.c index e37142d9271a..262a858c3068 100644 --- a/drivers/media/dvb/dvb-usb/gp8psk-fe.c +++ b/drivers/media/dvb/dvb-usb/gp8psk-fe.c | |||
| @@ -152,7 +152,7 @@ static int gp8psk_fe_send_diseqc_msg (struct dvb_frontend* fe, | |||
| 152 | { | 152 | { |
| 153 | struct gp8psk_fe_state *st = fe->demodulator_priv; | 153 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
| 154 | 154 | ||
| 155 | deb_fe("%s\n",__FUNCTION__); | 155 | deb_fe("%s\n",__func__); |
| 156 | 156 | ||
| 157 | if (gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, m->msg[0], 0, | 157 | if (gp8psk_usb_out_op(st->d,SEND_DISEQC_COMMAND, m->msg[0], 0, |
| 158 | m->msg, m->msg_len)) { | 158 | m->msg, m->msg_len)) { |
| @@ -167,7 +167,7 @@ static int gp8psk_fe_send_diseqc_burst (struct dvb_frontend* fe, | |||
| 167 | struct gp8psk_fe_state *st = fe->demodulator_priv; | 167 | struct gp8psk_fe_state *st = fe->demodulator_priv; |
| 168 | u8 cmd; | 168 | u8 cmd; |
| 169 | 169 | ||
| 170 | deb_fe("%s\n",__FUNCTION__); | 170 | deb_fe("%s\n",__func__); |
| 171 | 171 | ||
| 172 | /* These commands are certainly wrong */ | 172 | /* These commands are certainly wrong */ |
| 173 | cmd = (burst == SEC_MINI_A) ? 0x00 : 0x01; | 173 | cmd = (burst == SEC_MINI_A) ? 0x00 : 0x01; |
diff --git a/drivers/media/dvb/dvb-usb/gp8psk.c b/drivers/media/dvb/dvb-usb/gp8psk.c index 83e8535014c6..9a942afaf0af 100644 --- a/drivers/media/dvb/dvb-usb/gp8psk.c +++ b/drivers/media/dvb/dvb-usb/gp8psk.c | |||
| @@ -22,6 +22,8 @@ int dvb_usb_gp8psk_debug; | |||
| 22 | module_param_named(debug,dvb_usb_gp8psk_debug, int, 0644); | 22 | module_param_named(debug,dvb_usb_gp8psk_debug, int, 0644); |
| 23 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); | 23 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); |
| 24 | 24 | ||
| 25 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 26 | |||
| 25 | int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) | 27 | int gp8psk_usb_in_op(struct dvb_usb_device *d, u8 req, u16 value, u16 index, u8 *b, int blen) |
| 26 | { | 28 | { |
| 27 | int ret = 0,try = 0; | 29 | int ret = 0,try = 0; |
| @@ -190,7 +192,8 @@ static int gp8psk_usb_probe(struct usb_interface *intf, | |||
| 190 | { | 192 | { |
| 191 | int ret; | 193 | int ret; |
| 192 | struct usb_device *udev = interface_to_usbdev(intf); | 194 | struct usb_device *udev = interface_to_usbdev(intf); |
| 193 | ret = dvb_usb_device_init(intf,&gp8psk_properties,THIS_MODULE,NULL); | 195 | ret = dvb_usb_device_init(intf, &gp8psk_properties, |
| 196 | THIS_MODULE, NULL, adapter_nr); | ||
| 194 | if (ret == 0) { | 197 | if (ret == 0) { |
| 195 | info("found Genpix USB device pID = %x (hex)", | 198 | info("found Genpix USB device pID = %x (hex)", |
| 196 | le16_to_cpu(udev->descriptor.idProduct)); | 199 | le16_to_cpu(udev->descriptor.idProduct)); |
diff --git a/drivers/media/dvb/dvb-usb/m920x.c b/drivers/media/dvb/dvb-usb/m920x.c index a956bc503a4c..a12e6f784fda 100644 --- a/drivers/media/dvb/dvb-usb/m920x.c +++ b/drivers/media/dvb/dvb-usb/m920x.c | |||
| @@ -22,6 +22,8 @@ static int dvb_usb_m920x_debug; | |||
| 22 | module_param_named(debug,dvb_usb_m920x_debug, int, 0644); | 22 | module_param_named(debug,dvb_usb_m920x_debug, int, 0644); |
| 23 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); | 23 | MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS); |
| 24 | 24 | ||
| 25 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 26 | |||
| 25 | static int m920x_set_filter(struct dvb_usb_device *d, int type, int idx, int pid); | 27 | static int m920x_set_filter(struct dvb_usb_device *d, int type, int idx, int pid); |
| 26 | 28 | ||
| 27 | static inline int m920x_read(struct usb_device *udev, u8 request, u16 value, | 29 | static inline int m920x_read(struct usb_device *udev, u8 request, u16 value, |
| @@ -477,7 +479,7 @@ static struct qt1010_config m920x_qt1010_config = { | |||
| 477 | /* Callbacks for DVB USB */ | 479 | /* Callbacks for DVB USB */ |
| 478 | static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap) | 480 | static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap) |
| 479 | { | 481 | { |
| 480 | deb("%s\n",__FUNCTION__); | 482 | deb("%s\n",__func__); |
| 481 | 483 | ||
| 482 | if ((adap->fe = dvb_attach(mt352_attach, | 484 | if ((adap->fe = dvb_attach(mt352_attach, |
| 483 | &m920x_mt352_config, | 485 | &m920x_mt352_config, |
| @@ -489,7 +491,7 @@ static int m920x_mt352_frontend_attach(struct dvb_usb_adapter *adap) | |||
| 489 | 491 | ||
| 490 | static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap) | 492 | static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap) |
| 491 | { | 493 | { |
| 492 | deb("%s\n",__FUNCTION__); | 494 | deb("%s\n",__func__); |
| 493 | 495 | ||
| 494 | if ((adap->fe = dvb_attach(tda10046_attach, | 496 | if ((adap->fe = dvb_attach(tda10046_attach, |
| 495 | &m920x_tda10046_08_config, | 497 | &m920x_tda10046_08_config, |
| @@ -501,7 +503,7 @@ static int m920x_tda10046_08_frontend_attach(struct dvb_usb_adapter *adap) | |||
| 501 | 503 | ||
| 502 | static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap) | 504 | static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap) |
| 503 | { | 505 | { |
| 504 | deb("%s\n",__FUNCTION__); | 506 | deb("%s\n",__func__); |
| 505 | 507 | ||
| 506 | if ((adap->fe = dvb_attach(tda10046_attach, | 508 | if ((adap->fe = dvb_attach(tda10046_attach, |
| 507 | &m920x_tda10046_0b_config, | 509 | &m920x_tda10046_0b_config, |
| @@ -513,7 +515,7 @@ static int m920x_tda10046_0b_frontend_attach(struct dvb_usb_adapter *adap) | |||
| 513 | 515 | ||
| 514 | static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap) | 516 | static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap) |
| 515 | { | 517 | { |
| 516 | deb("%s\n",__FUNCTION__); | 518 | deb("%s\n",__func__); |
| 517 | 519 | ||
| 518 | if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, &m920x_qt1010_config) == NULL) | 520 | if (dvb_attach(qt1010_attach, adap->fe, &adap->dev->i2c_adap, &m920x_qt1010_config) == NULL) |
| 519 | return -ENODEV; | 521 | return -ENODEV; |
| @@ -523,7 +525,7 @@ static int m920x_qt1010_tuner_attach(struct dvb_usb_adapter *adap) | |||
| 523 | 525 | ||
| 524 | static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap) | 526 | static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap) |
| 525 | { | 527 | { |
| 526 | deb("%s\n",__FUNCTION__); | 528 | deb("%s\n",__func__); |
| 527 | 529 | ||
| 528 | if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, NULL) == NULL) | 530 | if (dvb_attach(tda827x_attach, adap->fe, 0x60, &adap->dev->i2c_adap, NULL) == NULL) |
| 529 | return -ENODEV; | 531 | return -ENODEV; |
| @@ -533,7 +535,7 @@ static int m920x_tda8275_60_tuner_attach(struct dvb_usb_adapter *adap) | |||
| 533 | 535 | ||
| 534 | static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap) | 536 | static int m920x_tda8275_61_tuner_attach(struct dvb_usb_adapter *adap) |
| 535 | { | 537 | { |
| 536 | deb("%s\n",__FUNCTION__); | 538 | deb("%s\n",__func__); |
| 537 | 539 | ||
| 538 | if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap, NULL) == NULL) | 540 | if (dvb_attach(tda827x_attach, adap->fe, 0x61, &adap->dev->i2c_adap, NULL) == NULL) |
| 539 | return -ENODEV; | 541 | return -ENODEV; |
| @@ -618,27 +620,31 @@ static int m920x_probe(struct usb_interface *intf, | |||
| 618 | * multi-tuner device | 620 | * multi-tuner device |
| 619 | */ | 621 | */ |
| 620 | 622 | ||
| 621 | if ((ret = dvb_usb_device_init(intf, &megasky_properties, | 623 | ret = dvb_usb_device_init(intf, &megasky_properties, |
| 622 | THIS_MODULE, &d)) == 0) { | 624 | THIS_MODULE, &d, adapter_nr); |
| 625 | if (ret == 0) { | ||
| 623 | rc_init_seq = megasky_rc_init; | 626 | rc_init_seq = megasky_rc_init; |
| 624 | goto found; | 627 | goto found; |
| 625 | } | 628 | } |
| 626 | 629 | ||
| 627 | if ((ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties, | 630 | ret = dvb_usb_device_init(intf, &digivox_mini_ii_properties, |
| 628 | THIS_MODULE, &d)) == 0) { | 631 | THIS_MODULE, &d, adapter_nr); |
| 632 | if (ret == 0) { | ||
| 629 | /* No remote control, so no rc_init_seq */ | 633 | /* No remote control, so no rc_init_seq */ |
| 630 | goto found; | 634 | goto found; |
| 631 | } | 635 | } |
| 632 | 636 | ||
| 633 | /* This configures both tuners on the TV Walker Twin */ | 637 | /* This configures both tuners on the TV Walker Twin */ |
| 634 | if ((ret = dvb_usb_device_init(intf, &tvwalkertwin_properties, | 638 | ret = dvb_usb_device_init(intf, &tvwalkertwin_properties, |
| 635 | THIS_MODULE, &d)) == 0) { | 639 | THIS_MODULE, &d, adapter_nr); |
| 640 | if (ret == 0) { | ||
| 636 | rc_init_seq = tvwalkertwin_rc_init; | 641 | rc_init_seq = tvwalkertwin_rc_init; |
| 637 | goto found; | 642 | goto found; |
| 638 | } | 643 | } |
| 639 | 644 | ||
| 640 | if ((ret = dvb_usb_device_init(intf, &dposh_properties, | 645 | ret = dvb_usb_device_init(intf, &dposh_properties, |
| 641 | THIS_MODULE, &d)) == 0) { | 646 | THIS_MODULE, &d, adapter_nr); |
| 647 | if (ret == 0) { | ||
| 642 | /* Remote controller not supported yet. */ | 648 | /* Remote controller not supported yet. */ |
| 643 | goto found; | 649 | goto found; |
| 644 | } | 650 | } |
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c index badc468170ea..07fb843c7c2b 100644 --- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c +++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c | |||
| @@ -15,6 +15,8 @@ static int debug; | |||
| 15 | module_param(debug, int, 0644); | 15 | module_param(debug, int, 0644); |
| 16 | MODULE_PARM_DESC(debug, "set debugging level (1=rc,2=eeprom (|-able))." DVB_USB_DEBUG_STATUS); | 16 | MODULE_PARM_DESC(debug, "set debugging level (1=rc,2=eeprom (|-able))." DVB_USB_DEBUG_STATUS); |
| 17 | 17 | ||
| 18 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 19 | |||
| 18 | #define deb_rc(args...) dprintk(debug,0x01,args) | 20 | #define deb_rc(args...) dprintk(debug,0x01,args) |
| 19 | #define deb_ee(args...) dprintk(debug,0x02,args) | 21 | #define deb_ee(args...) dprintk(debug,0x02,args) |
| 20 | 22 | ||
| @@ -142,7 +144,8 @@ static struct dvb_usb_device_properties nova_t_properties; | |||
| 142 | static int nova_t_probe(struct usb_interface *intf, | 144 | static int nova_t_probe(struct usb_interface *intf, |
| 143 | const struct usb_device_id *id) | 145 | const struct usb_device_id *id) |
| 144 | { | 146 | { |
| 145 | return dvb_usb_device_init(intf,&nova_t_properties,THIS_MODULE,NULL); | 147 | return dvb_usb_device_init(intf, &nova_t_properties, |
| 148 | THIS_MODULE, NULL, adapter_nr); | ||
| 146 | } | 149 | } |
| 147 | 150 | ||
| 148 | /* do not change the order of the ID table */ | 151 | /* do not change the order of the ID table */ |
diff --git a/drivers/media/dvb/dvb-usb/opera1.c b/drivers/media/dvb/dvb-usb/opera1.c index 302cc67407c3..7e32d11f32b0 100644 --- a/drivers/media/dvb/dvb-usb/opera1.c +++ b/drivers/media/dvb/dvb-usb/opera1.c | |||
| @@ -46,6 +46,9 @@ MODULE_PARM_DESC(debug, | |||
| 46 | "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64 (or-able))." | 46 | "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64 (or-able))." |
| 47 | DVB_USB_DEBUG_STATUS); | 47 | DVB_USB_DEBUG_STATUS); |
| 48 | 48 | ||
| 49 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 50 | |||
| 51 | |||
| 49 | static int opera1_xilinx_rw(struct usb_device *dev, u8 request, u16 value, | 52 | static int opera1_xilinx_rw(struct usb_device *dev, u8 request, u16 value, |
| 50 | u8 * data, u16 len, int flags) | 53 | u8 * data, u16 len, int flags) |
| 51 | { | 54 | { |
| @@ -243,7 +246,7 @@ static struct stv0299_config opera1_stv0299_config = { | |||
| 243 | .mclk = 88000000UL, | 246 | .mclk = 88000000UL, |
| 244 | .invert = 1, | 247 | .invert = 1, |
| 245 | .skip_reinit = 0, | 248 | .skip_reinit = 0, |
| 246 | .lock_output = STV0229_LOCKOUTPUT_0, | 249 | .lock_output = STV0299_LOCKOUTPUT_0, |
| 247 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | 250 | .volt13_op0_op1 = STV0299_VOLT13_OP0, |
| 248 | .inittab = opera1_inittab, | 251 | .inittab = opera1_inittab, |
| 249 | .set_symbol_rate = opera1_stv0299_set_symbol_rate, | 252 | .set_symbol_rate = opera1_stv0299_set_symbol_rate, |
| @@ -548,7 +551,8 @@ static int opera1_probe(struct usb_interface *intf, | |||
| 548 | return -EINVAL; | 551 | return -EINVAL; |
| 549 | } | 552 | } |
| 550 | 553 | ||
| 551 | if (dvb_usb_device_init(intf, &opera1_properties, THIS_MODULE, NULL) != 0) | 554 | if (0 != dvb_usb_device_init(intf, &opera1_properties, |
| 555 | THIS_MODULE, NULL, adapter_nr)) | ||
| 552 | return -EINVAL; | 556 | return -EINVAL; |
| 553 | return 0; | 557 | return 0; |
| 554 | } | 558 | } |
diff --git a/drivers/media/dvb/dvb-usb/ttusb2.c b/drivers/media/dvb/dvb-usb/ttusb2.c index 3b9da9c25c6e..20ca9d9ee99b 100644 --- a/drivers/media/dvb/dvb-usb/ttusb2.c +++ b/drivers/media/dvb/dvb-usb/ttusb2.c | |||
| @@ -37,6 +37,8 @@ static int dvb_usb_ttusb2_debug; | |||
| 37 | module_param_named(debug,dvb_usb_ttusb2_debug, int, 0644); | 37 | module_param_named(debug,dvb_usb_ttusb2_debug, int, 0644); |
| 38 | MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able))." DVB_USB_DEBUG_STATUS); | 38 | MODULE_PARM_DESC(debug, "set debugging level (1=info (or-able))." DVB_USB_DEBUG_STATUS); |
| 39 | 39 | ||
| 40 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 41 | |||
| 40 | struct ttusb2_state { | 42 | struct ttusb2_state { |
| 41 | u8 id; | 43 | u8 id; |
| 42 | }; | 44 | }; |
| @@ -145,6 +147,7 @@ static struct tda10086_config tda10086_config = { | |||
| 145 | .demod_address = 0x0e, | 147 | .demod_address = 0x0e, |
| 146 | .invert = 0, | 148 | .invert = 0, |
| 147 | .diseqc_tone = 1, | 149 | .diseqc_tone = 1, |
| 150 | .xtal_freq = TDA10086_XTAL_16M, | ||
| 148 | }; | 151 | }; |
| 149 | 152 | ||
| 150 | static int ttusb2_frontend_attach(struct dvb_usb_adapter *adap) | 153 | static int ttusb2_frontend_attach(struct dvb_usb_adapter *adap) |
| @@ -176,17 +179,25 @@ static int ttusb2_tuner_attach(struct dvb_usb_adapter *adap) | |||
| 176 | 179 | ||
| 177 | /* DVB USB Driver stuff */ | 180 | /* DVB USB Driver stuff */ |
| 178 | static struct dvb_usb_device_properties ttusb2_properties; | 181 | static struct dvb_usb_device_properties ttusb2_properties; |
| 182 | static struct dvb_usb_device_properties ttusb2_properties_s2400; | ||
| 179 | 183 | ||
| 180 | static int ttusb2_probe(struct usb_interface *intf, | 184 | static int ttusb2_probe(struct usb_interface *intf, |
| 181 | const struct usb_device_id *id) | 185 | const struct usb_device_id *id) |
| 182 | { | 186 | { |
| 183 | return dvb_usb_device_init(intf,&ttusb2_properties,THIS_MODULE,NULL); | 187 | if (0 == dvb_usb_device_init(intf, &ttusb2_properties, |
| 188 | THIS_MODULE, NULL, adapter_nr) || | ||
| 189 | 0 == dvb_usb_device_init(intf, &ttusb2_properties_s2400, | ||
| 190 | THIS_MODULE, NULL, adapter_nr)) | ||
| 191 | return 0; | ||
| 192 | return -ENODEV; | ||
| 184 | } | 193 | } |
| 185 | 194 | ||
| 186 | static struct usb_device_id ttusb2_table [] = { | 195 | static struct usb_device_id ttusb2_table [] = { |
| 187 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_400E) }, | 196 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_400E) }, |
| 188 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_450E) }, | 197 | { USB_DEVICE(USB_VID_PINNACLE, USB_PID_PCTV_450E) }, |
| 189 | {} /* Terminating entry */ | 198 | { USB_DEVICE(USB_VID_TECHNOTREND, |
| 199 | USB_PID_TECHNOTREND_CONNECT_S2400) }, | ||
| 200 | {} /* Terminating entry */ | ||
| 190 | }; | 201 | }; |
| 191 | MODULE_DEVICE_TABLE (usb, ttusb2_table); | 202 | MODULE_DEVICE_TABLE (usb, ttusb2_table); |
| 192 | 203 | ||
| @@ -242,6 +253,54 @@ static struct dvb_usb_device_properties ttusb2_properties = { | |||
| 242 | } | 253 | } |
| 243 | }; | 254 | }; |
| 244 | 255 | ||
| 256 | static struct dvb_usb_device_properties ttusb2_properties_s2400 = { | ||
| 257 | .caps = DVB_USB_IS_AN_I2C_ADAPTER, | ||
| 258 | |||
| 259 | .usb_ctrl = CYPRESS_FX2, | ||
| 260 | .firmware = "dvb-usb-tt-s2400-01.fw", | ||
| 261 | |||
| 262 | .size_of_priv = sizeof(struct ttusb2_state), | ||
| 263 | |||
| 264 | .num_adapters = 1, | ||
| 265 | .adapter = { | ||
| 266 | { | ||
| 267 | .streaming_ctrl = NULL, | ||
| 268 | |||
| 269 | .frontend_attach = ttusb2_frontend_attach, | ||
| 270 | .tuner_attach = ttusb2_tuner_attach, | ||
| 271 | |||
| 272 | /* parameter for the MPEG2-data transfer */ | ||
| 273 | .stream = { | ||
| 274 | .type = USB_ISOC, | ||
| 275 | .count = 5, | ||
| 276 | .endpoint = 0x02, | ||
| 277 | .u = { | ||
| 278 | .isoc = { | ||
| 279 | .framesperurb = 4, | ||
| 280 | .framesize = 940, | ||
| 281 | .interval = 1, | ||
| 282 | } | ||
| 283 | } | ||
| 284 | } | ||
| 285 | } | ||
| 286 | }, | ||
| 287 | |||
| 288 | .power_ctrl = ttusb2_power_ctrl, | ||
| 289 | .identify_state = ttusb2_identify_state, | ||
| 290 | |||
| 291 | .i2c_algo = &ttusb2_i2c_algo, | ||
| 292 | |||
| 293 | .generic_bulk_ctrl_endpoint = 0x01, | ||
| 294 | |||
| 295 | .num_device_descs = 1, | ||
| 296 | .devices = { | ||
| 297 | { "Technotrend TT-connect S-2400", | ||
| 298 | { &ttusb2_table[2], NULL }, | ||
| 299 | { NULL }, | ||
| 300 | }, | ||
| 301 | } | ||
| 302 | }; | ||
| 303 | |||
| 245 | static struct usb_driver ttusb2_driver = { | 304 | static struct usb_driver ttusb2_driver = { |
| 246 | .name = "dvb_usb_ttusb2", | 305 | .name = "dvb_usb_ttusb2", |
| 247 | .probe = ttusb2_probe, | 306 | .probe = ttusb2_probe, |
diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c index 0dcab3d4e236..9e7653bb3b66 100644 --- a/drivers/media/dvb/dvb-usb/umt-010.c +++ b/drivers/media/dvb/dvb-usb/umt-010.c | |||
| @@ -13,6 +13,8 @@ | |||
| 13 | 13 | ||
| 14 | #include "mt352.h" | 14 | #include "mt352.h" |
| 15 | 15 | ||
| 16 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 17 | |||
| 16 | static int umt_mt352_demod_init(struct dvb_frontend *fe) | 18 | static int umt_mt352_demod_init(struct dvb_frontend *fe) |
| 17 | { | 19 | { |
| 18 | static u8 mt352_clock_config[] = { 0x89, 0xb8, 0x2d }; | 20 | static u8 mt352_clock_config[] = { 0x89, 0xb8, 0x2d }; |
| @@ -75,7 +77,8 @@ static struct dvb_usb_device_properties umt_properties; | |||
| 75 | static int umt_probe(struct usb_interface *intf, | 77 | static int umt_probe(struct usb_interface *intf, |
| 76 | const struct usb_device_id *id) | 78 | const struct usb_device_id *id) |
| 77 | { | 79 | { |
| 78 | if (dvb_usb_device_init(intf,&umt_properties,THIS_MODULE,NULL) == 0) | 80 | if (0 == dvb_usb_device_init(intf, &umt_properties, |
| 81 | THIS_MODULE, NULL, adapter_nr)) | ||
| 79 | return 0; | 82 | return 0; |
| 80 | return -EINVAL; | 83 | return -EINVAL; |
| 81 | } | 84 | } |
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c index c3fdc7cd094e..ccc7e4452664 100644 --- a/drivers/media/dvb/dvb-usb/vp702x-fe.c +++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c | |||
| @@ -67,7 +67,7 @@ static int vp702x_fe_read_status(struct dvb_frontend* fe, fe_status_t *status) | |||
| 67 | { | 67 | { |
| 68 | struct vp702x_fe_state *st = fe->demodulator_priv; | 68 | struct vp702x_fe_state *st = fe->demodulator_priv; |
| 69 | vp702x_fe_refresh_state(st); | 69 | vp702x_fe_refresh_state(st); |
| 70 | deb_fe("%s\n",__FUNCTION__); | 70 | deb_fe("%s\n",__func__); |
| 71 | 71 | ||
| 72 | if (st->lock == 0) | 72 | if (st->lock == 0) |
| 73 | *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER; | 73 | *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI | FE_HAS_SIGNAL | FE_HAS_CARRIER; |
| @@ -121,7 +121,7 @@ static int vp702x_fe_read_snr(struct dvb_frontend* fe, u16 *snr) | |||
| 121 | 121 | ||
| 122 | static int vp702x_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) | 122 | static int vp702x_fe_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *tune) |
| 123 | { | 123 | { |
| 124 | deb_fe("%s\n",__FUNCTION__); | 124 | deb_fe("%s\n",__func__); |
| 125 | tune->min_delay_ms = 2000; | 125 | tune->min_delay_ms = 2000; |
| 126 | return 0; | 126 | return 0; |
| 127 | } | 127 | } |
| @@ -183,21 +183,21 @@ static int vp702x_fe_set_frontend(struct dvb_frontend* fe, | |||
| 183 | static int vp702x_fe_init(struct dvb_frontend *fe) | 183 | static int vp702x_fe_init(struct dvb_frontend *fe) |
| 184 | { | 184 | { |
| 185 | struct vp702x_fe_state *st = fe->demodulator_priv; | 185 | struct vp702x_fe_state *st = fe->demodulator_priv; |
| 186 | deb_fe("%s\n",__FUNCTION__); | 186 | deb_fe("%s\n",__func__); |
| 187 | vp702x_usb_in_op(st->d, RESET_TUNER, 0, 0, NULL, 0); | 187 | vp702x_usb_in_op(st->d, RESET_TUNER, 0, 0, NULL, 0); |
| 188 | return 0; | 188 | return 0; |
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | static int vp702x_fe_sleep(struct dvb_frontend *fe) | 191 | static int vp702x_fe_sleep(struct dvb_frontend *fe) |
| 192 | { | 192 | { |
| 193 | deb_fe("%s\n",__FUNCTION__); | 193 | deb_fe("%s\n",__func__); |
| 194 | return 0; | 194 | return 0; |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | static int vp702x_fe_get_frontend(struct dvb_frontend* fe, | 197 | static int vp702x_fe_get_frontend(struct dvb_frontend* fe, |
| 198 | struct dvb_frontend_parameters *fep) | 198 | struct dvb_frontend_parameters *fep) |
| 199 | { | 199 | { |
| 200 | deb_fe("%s\n",__FUNCTION__); | 200 | deb_fe("%s\n",__func__); |
| 201 | return 0; | 201 | return 0; |
| 202 | } | 202 | } |
| 203 | 203 | ||
| @@ -208,7 +208,7 @@ static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, | |||
| 208 | u8 cmd[8],ibuf[10]; | 208 | u8 cmd[8],ibuf[10]; |
| 209 | memset(cmd,0,8); | 209 | memset(cmd,0,8); |
| 210 | 210 | ||
| 211 | deb_fe("%s\n",__FUNCTION__); | 211 | deb_fe("%s\n",__func__); |
| 212 | 212 | ||
| 213 | if (m->msg_len > 4) | 213 | if (m->msg_len > 4) |
| 214 | return -EINVAL; | 214 | return -EINVAL; |
| @@ -230,7 +230,7 @@ static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, | |||
| 230 | 230 | ||
| 231 | static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) | 231 | static int vp702x_fe_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) |
| 232 | { | 232 | { |
| 233 | deb_fe("%s\n",__FUNCTION__); | 233 | deb_fe("%s\n",__func__); |
| 234 | return 0; | 234 | return 0; |
| 235 | } | 235 | } |
| 236 | 236 | ||
| @@ -238,7 +238,7 @@ static int vp702x_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
| 238 | { | 238 | { |
| 239 | struct vp702x_fe_state *st = fe->demodulator_priv; | 239 | struct vp702x_fe_state *st = fe->demodulator_priv; |
| 240 | u8 ibuf[10]; | 240 | u8 ibuf[10]; |
| 241 | deb_fe("%s\n",__FUNCTION__); | 241 | deb_fe("%s\n",__func__); |
| 242 | 242 | ||
| 243 | st->tone_mode = tone; | 243 | st->tone_mode = tone; |
| 244 | 244 | ||
| @@ -263,7 +263,7 @@ static int vp702x_fe_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t | |||
| 263 | { | 263 | { |
| 264 | struct vp702x_fe_state *st = fe->demodulator_priv; | 264 | struct vp702x_fe_state *st = fe->demodulator_priv; |
| 265 | u8 ibuf[10]; | 265 | u8 ibuf[10]; |
| 266 | deb_fe("%s\n",__FUNCTION__); | 266 | deb_fe("%s\n",__func__); |
| 267 | 267 | ||
| 268 | st->voltage = voltage; | 268 | st->voltage = voltage; |
| 269 | 269 | ||
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c index e553c139ac44..986fff9a5ba8 100644 --- a/drivers/media/dvb/dvb-usb/vp702x.c +++ b/drivers/media/dvb/dvb-usb/vp702x.c | |||
| @@ -21,6 +21,8 @@ int dvb_usb_vp702x_debug; | |||
| 21 | module_param_named(debug,dvb_usb_vp702x_debug, int, 0644); | 21 | module_param_named(debug,dvb_usb_vp702x_debug, int, 0644); |
| 22 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); | 22 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); |
| 23 | 23 | ||
| 24 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 25 | |||
| 24 | struct vp702x_state { | 26 | struct vp702x_state { |
| 25 | int pid_filter_count; | 27 | int pid_filter_count; |
| 26 | int pid_filter_can_bypass; | 28 | int pid_filter_can_bypass; |
| @@ -238,7 +240,8 @@ static struct dvb_usb_device_properties vp702x_properties; | |||
| 238 | static int vp702x_usb_probe(struct usb_interface *intf, | 240 | static int vp702x_usb_probe(struct usb_interface *intf, |
| 239 | const struct usb_device_id *id) | 241 | const struct usb_device_id *id) |
| 240 | { | 242 | { |
| 241 | return dvb_usb_device_init(intf,&vp702x_properties,THIS_MODULE,NULL); | 243 | return dvb_usb_device_init(intf, &vp702x_properties, |
| 244 | THIS_MODULE, NULL, adapter_nr); | ||
| 242 | } | 245 | } |
| 243 | 246 | ||
| 244 | static struct usb_device_id vp702x_usb_table [] = { | 247 | static struct usb_device_id vp702x_usb_table [] = { |
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index c172babf59bb..acb345504e0d 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c | |||
| @@ -18,6 +18,9 @@ | |||
| 18 | static int dvb_usb_vp7045_debug; | 18 | static int dvb_usb_vp7045_debug; |
| 19 | module_param_named(debug,dvb_usb_vp7045_debug, int, 0644); | 19 | module_param_named(debug,dvb_usb_vp7045_debug, int, 0644); |
| 20 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); | 20 | MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,rc=4 (or-able))." DVB_USB_DEBUG_STATUS); |
| 21 | |||
| 22 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 23 | |||
| 21 | #define deb_info(args...) dprintk(dvb_usb_vp7045_debug,0x01,args) | 24 | #define deb_info(args...) dprintk(dvb_usb_vp7045_debug,0x01,args) |
| 22 | #define deb_xfer(args...) dprintk(dvb_usb_vp7045_debug,0x02,args) | 25 | #define deb_xfer(args...) dprintk(dvb_usb_vp7045_debug,0x02,args) |
| 23 | #define deb_rc(args...) dprintk(dvb_usb_vp7045_debug,0x04,args) | 26 | #define deb_rc(args...) dprintk(dvb_usb_vp7045_debug,0x04,args) |
| @@ -219,7 +222,8 @@ static struct dvb_usb_device_properties vp7045_properties; | |||
| 219 | static int vp7045_usb_probe(struct usb_interface *intf, | 222 | static int vp7045_usb_probe(struct usb_interface *intf, |
| 220 | const struct usb_device_id *id) | 223 | const struct usb_device_id *id) |
| 221 | { | 224 | { |
| 222 | return dvb_usb_device_init(intf,&vp7045_properties,THIS_MODULE,NULL); | 225 | return dvb_usb_device_init(intf, &vp7045_properties, |
| 226 | THIS_MODULE, NULL, adapter_nr); | ||
| 223 | } | 227 | } |
| 224 | 228 | ||
| 225 | static struct usb_device_id vp7045_usb_table [] = { | 229 | static struct usb_device_id vp7045_usb_table [] = { |
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index 9ad86ce4a4e5..68fab616f55d 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig | |||
| @@ -188,6 +188,14 @@ config DVB_DIB7000P | |||
| 188 | A DVB-T tuner module. Designed for mobile usage. Say Y when you want | 188 | A DVB-T tuner module. Designed for mobile usage. Say Y when you want |
| 189 | to support this frontend. | 189 | to support this frontend. |
| 190 | 190 | ||
| 191 | config DVB_TDA10048 | ||
| 192 | tristate "Philips TDA10048HN based" | ||
| 193 | depends on DVB_CORE && I2C | ||
| 194 | default m if DVB_FE_CUSTOMISE | ||
| 195 | select FW_LOADER | ||
| 196 | help | ||
| 197 | A DVB-T tuner module. Say Y when you want to support this frontend. | ||
| 198 | |||
| 191 | comment "DVB-C (cable) frontends" | 199 | comment "DVB-C (cable) frontends" |
| 192 | depends on DVB_CORE | 200 | depends on DVB_CORE |
| 193 | 201 | ||
| @@ -291,6 +299,14 @@ config DVB_S5H1409 | |||
| 291 | An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want | 299 | An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want |
| 292 | to support this frontend. | 300 | to support this frontend. |
| 293 | 301 | ||
| 302 | config DVB_AU8522 | ||
| 303 | tristate "Auvitek AU8522 based" | ||
| 304 | depends on DVB_CORE && I2C | ||
| 305 | default m if DVB_FE_CUSTOMISE | ||
| 306 | help | ||
| 307 | An ATSC 8VSB and QAM64/256 tuner module. Say Y when you want | ||
| 308 | to support this frontend. | ||
| 309 | |||
| 294 | comment "Tuners/PLL support" | 310 | comment "Tuners/PLL support" |
| 295 | depends on DVB_CORE | 311 | depends on DVB_CORE |
| 296 | 312 | ||
| @@ -369,6 +385,11 @@ config DVB_TUNER_XC5000 | |||
| 369 | This device is only used inside a SiP called togther with a | 385 | This device is only used inside a SiP called togther with a |
| 370 | demodulator for now. | 386 | demodulator for now. |
| 371 | 387 | ||
| 388 | config DVB_TUNER_ITD1000 | ||
| 389 | tristate "Integrant ITD1000 Zero IF tuner for DVB-S/DSS" | ||
| 390 | depends on DVB_CORE && I2C | ||
| 391 | default m if DVB_FE_CUSTOMISE | ||
| 392 | |||
| 372 | comment "Miscellaneous devices" | 393 | comment "Miscellaneous devices" |
| 373 | depends on DVB_CORE | 394 | depends on DVB_CORE |
| 374 | 395 | ||
| @@ -379,6 +400,13 @@ config DVB_LNBP21 | |||
| 379 | help | 400 | help |
| 380 | An SEC control chip. | 401 | An SEC control chip. |
| 381 | 402 | ||
| 403 | config DVB_ISL6405 | ||
| 404 | tristate "ISL6405 SEC controller" | ||
| 405 | depends on DVB_CORE && I2C | ||
| 406 | default m if DVB_FE_CUSTOMISE | ||
| 407 | help | ||
| 408 | An SEC control chip. | ||
| 409 | |||
| 382 | config DVB_ISL6421 | 410 | config DVB_ISL6421 |
| 383 | tristate "ISL6421 SEC controller" | 411 | tristate "ISL6421 SEC controller" |
| 384 | depends on DVB_CORE && I2C | 412 | depends on DVB_CORE && I2C |
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index 16bd107ebd32..2f873fc0f649 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile | |||
| @@ -38,6 +38,7 @@ obj-$(CONFIG_DVB_S5H1420) += s5h1420.o | |||
| 38 | obj-$(CONFIG_DVB_LGDT330X) += lgdt330x.o | 38 | obj-$(CONFIG_DVB_LGDT330X) += lgdt330x.o |
| 39 | obj-$(CONFIG_DVB_CX24123) += cx24123.o | 39 | obj-$(CONFIG_DVB_CX24123) += cx24123.o |
| 40 | obj-$(CONFIG_DVB_LNBP21) += lnbp21.o | 40 | obj-$(CONFIG_DVB_LNBP21) += lnbp21.o |
| 41 | obj-$(CONFIG_DVB_ISL6405) += isl6405.o | ||
| 41 | obj-$(CONFIG_DVB_ISL6421) += isl6421.o | 42 | obj-$(CONFIG_DVB_ISL6421) += isl6421.o |
| 42 | obj-$(CONFIG_DVB_TDA10086) += tda10086.o | 43 | obj-$(CONFIG_DVB_TDA10086) += tda10086.o |
| 43 | obj-$(CONFIG_DVB_TDA826X) += tda826x.o | 44 | obj-$(CONFIG_DVB_TDA826X) += tda826x.o |
| @@ -51,3 +52,6 @@ obj-$(CONFIG_DVB_TUA6100) += tua6100.o | |||
| 51 | obj-$(CONFIG_DVB_TUNER_MT2131) += mt2131.o | 52 | obj-$(CONFIG_DVB_TUNER_MT2131) += mt2131.o |
| 52 | obj-$(CONFIG_DVB_S5H1409) += s5h1409.o | 53 | obj-$(CONFIG_DVB_S5H1409) += s5h1409.o |
| 53 | obj-$(CONFIG_DVB_TUNER_XC5000) += xc5000.o | 54 | obj-$(CONFIG_DVB_TUNER_XC5000) += xc5000.o |
| 55 | obj-$(CONFIG_DVB_TUNER_ITD1000) += itd1000.o | ||
| 56 | obj-$(CONFIG_DVB_AU8522) += au8522.o | ||
| 57 | obj-$(CONFIG_DVB_TDA10048) += tda10048.o | ||
diff --git a/drivers/media/dvb/frontends/au8522.c b/drivers/media/dvb/frontends/au8522.c new file mode 100644 index 000000000000..084a280c2d7f --- /dev/null +++ b/drivers/media/dvb/frontends/au8522.c | |||
| @@ -0,0 +1,692 @@ | |||
| 1 | /* | ||
| 2 | Auvitek AU8522 QAM/8VSB demodulator driver | ||
| 3 | |||
| 4 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/kernel.h> | ||
| 23 | #include <linux/init.h> | ||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/string.h> | ||
| 26 | #include <linux/slab.h> | ||
| 27 | #include <linux/delay.h> | ||
| 28 | #include "dvb_frontend.h" | ||
| 29 | #include "dvb-pll.h" | ||
| 30 | #include "au8522.h" | ||
| 31 | |||
| 32 | struct au8522_state { | ||
| 33 | |||
| 34 | struct i2c_adapter *i2c; | ||
| 35 | |||
| 36 | /* configuration settings */ | ||
| 37 | const struct au8522_config *config; | ||
| 38 | |||
| 39 | struct dvb_frontend frontend; | ||
| 40 | |||
| 41 | u32 current_frequency; | ||
| 42 | fe_modulation_t current_modulation; | ||
| 43 | |||
| 44 | }; | ||
| 45 | |||
| 46 | static int debug; | ||
| 47 | |||
| 48 | #define dprintk(arg...) do { \ | ||
| 49 | if (debug) \ | ||
| 50 | printk(arg); \ | ||
| 51 | } while (0) | ||
| 52 | |||
| 53 | /* 16 bit registers, 8 bit values */ | ||
| 54 | static int au8522_writereg(struct au8522_state *state, u16 reg, u8 data) | ||
| 55 | { | ||
| 56 | int ret; | ||
| 57 | u8 buf [] = { reg >> 8, reg & 0xff, data }; | ||
| 58 | |||
| 59 | struct i2c_msg msg = { .addr = state->config->demod_address, | ||
| 60 | .flags = 0, .buf = buf, .len = 3 }; | ||
| 61 | |||
| 62 | ret = i2c_transfer(state->i2c, &msg, 1); | ||
| 63 | |||
| 64 | if (ret != 1) | ||
| 65 | printk("%s: writereg error (reg == 0x%02x, val == 0x%04x, " | ||
| 66 | "ret == %i)\n", __func__, reg, data, ret); | ||
| 67 | |||
| 68 | return (ret != 1) ? -1 : 0; | ||
| 69 | } | ||
| 70 | |||
| 71 | static u8 au8522_readreg(struct au8522_state *state, u16 reg) | ||
| 72 | { | ||
| 73 | int ret; | ||
| 74 | u8 b0 [] = { reg >> 8, reg & 0xff }; | ||
| 75 | u8 b1 [] = { 0 }; | ||
| 76 | |||
| 77 | struct i2c_msg msg [] = { | ||
| 78 | { .addr = state->config->demod_address, .flags = 0, | ||
| 79 | .buf = b0, .len = 2 }, | ||
| 80 | { .addr = state->config->demod_address, .flags = I2C_M_RD, | ||
| 81 | .buf = b1, .len = 1 } }; | ||
| 82 | |||
| 83 | ret = i2c_transfer(state->i2c, msg, 2); | ||
| 84 | |||
| 85 | if (ret != 2) | ||
| 86 | printk(KERN_ERR "%s: readreg error (ret == %i)\n", | ||
| 87 | __func__, ret); | ||
| 88 | return b1[0]; | ||
| 89 | } | ||
| 90 | |||
| 91 | static int au8522_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) | ||
| 92 | { | ||
| 93 | struct au8522_state *state = fe->demodulator_priv; | ||
| 94 | |||
| 95 | dprintk("%s(%d)\n", __func__, enable); | ||
| 96 | |||
| 97 | if (enable) | ||
| 98 | return au8522_writereg(state, 0x106, 1); | ||
| 99 | else | ||
| 100 | return au8522_writereg(state, 0x106, 0); | ||
| 101 | } | ||
| 102 | |||
| 103 | struct mse2snr_tab { | ||
| 104 | u16 val; | ||
| 105 | u16 data; | ||
| 106 | }; | ||
| 107 | |||
| 108 | /* VSB SNR lookup table */ | ||
| 109 | static struct mse2snr_tab vsb_mse2snr_tab[] = { | ||
| 110 | { 0, 270 }, | ||
| 111 | { 2, 250 }, | ||
| 112 | { 3, 240 }, | ||
| 113 | { 5, 230 }, | ||
| 114 | { 7, 220 }, | ||
| 115 | { 9, 210 }, | ||
| 116 | { 12, 200 }, | ||
| 117 | { 13, 195 }, | ||
| 118 | { 15, 190 }, | ||
| 119 | { 17, 185 }, | ||
| 120 | { 19, 180 }, | ||
| 121 | { 21, 175 }, | ||
| 122 | { 24, 170 }, | ||
| 123 | { 27, 165 }, | ||
| 124 | { 31, 160 }, | ||
| 125 | { 32, 158 }, | ||
| 126 | { 33, 156 }, | ||
| 127 | { 36, 152 }, | ||
| 128 | { 37, 150 }, | ||
| 129 | { 39, 148 }, | ||
| 130 | { 40, 146 }, | ||
| 131 | { 41, 144 }, | ||
| 132 | { 43, 142 }, | ||
| 133 | { 44, 140 }, | ||
| 134 | { 48, 135 }, | ||
| 135 | { 50, 130 }, | ||
| 136 | { 43, 142 }, | ||
| 137 | { 53, 125 }, | ||
| 138 | { 56, 120 }, | ||
| 139 | { 256, 115 }, | ||
| 140 | }; | ||
| 141 | |||
| 142 | /* QAM64 SNR lookup table */ | ||
| 143 | static struct mse2snr_tab qam64_mse2snr_tab[] = { | ||
| 144 | { 15, 0 }, | ||
| 145 | { 16, 290 }, | ||
| 146 | { 17, 288 }, | ||
| 147 | { 18, 286 }, | ||
| 148 | { 19, 284 }, | ||
| 149 | { 20, 282 }, | ||
| 150 | { 21, 281 }, | ||
| 151 | { 22, 279 }, | ||
| 152 | { 23, 277 }, | ||
| 153 | { 24, 275 }, | ||
| 154 | { 25, 273 }, | ||
| 155 | { 26, 271 }, | ||
| 156 | { 27, 269 }, | ||
| 157 | { 28, 268 }, | ||
| 158 | { 29, 266 }, | ||
| 159 | { 30, 264 }, | ||
| 160 | { 31, 262 }, | ||
| 161 | { 32, 260 }, | ||
| 162 | { 33, 259 }, | ||
| 163 | { 34, 258 }, | ||
| 164 | { 35, 256 }, | ||
| 165 | { 36, 255 }, | ||
| 166 | { 37, 254 }, | ||
| 167 | { 38, 252 }, | ||
| 168 | { 39, 251 }, | ||
| 169 | { 40, 250 }, | ||
| 170 | { 41, 249 }, | ||
| 171 | { 42, 248 }, | ||
| 172 | { 43, 246 }, | ||
| 173 | { 44, 245 }, | ||
| 174 | { 45, 244 }, | ||
| 175 | { 46, 242 }, | ||
| 176 | { 47, 241 }, | ||
| 177 | { 48, 240 }, | ||
| 178 | { 50, 239 }, | ||
| 179 | { 51, 238 }, | ||
| 180 | { 53, 237 }, | ||
| 181 | { 54, 236 }, | ||
| 182 | { 56, 235 }, | ||
| 183 | { 57, 234 }, | ||
| 184 | { 59, 233 }, | ||
| 185 | { 60, 232 }, | ||
| 186 | { 62, 231 }, | ||
| 187 | { 63, 230 }, | ||
| 188 | { 65, 229 }, | ||
| 189 | { 67, 228 }, | ||
| 190 | { 68, 227 }, | ||
| 191 | { 70, 226 }, | ||
| 192 | { 71, 225 }, | ||
| 193 | { 73, 224 }, | ||
| 194 | { 74, 223 }, | ||
| 195 | { 76, 222 }, | ||
| 196 | { 78, 221 }, | ||
| 197 | { 80, 220 }, | ||
| 198 | { 82, 219 }, | ||
| 199 | { 85, 218 }, | ||
| 200 | { 88, 217 }, | ||
| 201 | { 90, 216 }, | ||
| 202 | { 92, 215 }, | ||
| 203 | { 93, 214 }, | ||
| 204 | { 94, 212 }, | ||
| 205 | { 95, 211 }, | ||
| 206 | { 97, 210 }, | ||
| 207 | { 99, 209 }, | ||
| 208 | { 101, 208 }, | ||
| 209 | { 102, 207 }, | ||
| 210 | { 104, 206 }, | ||
| 211 | { 107, 205 }, | ||
| 212 | { 111, 204 }, | ||
| 213 | { 114, 203 }, | ||
| 214 | { 118, 202 }, | ||
| 215 | { 122, 201 }, | ||
| 216 | { 125, 200 }, | ||
| 217 | { 128, 199 }, | ||
| 218 | { 130, 198 }, | ||
| 219 | { 132, 197 }, | ||
| 220 | { 256, 190 }, | ||
| 221 | }; | ||
| 222 | |||
| 223 | /* QAM256 SNR lookup table */ | ||
| 224 | static struct mse2snr_tab qam256_mse2snr_tab[] = { | ||
| 225 | { 16, 0 }, | ||
| 226 | { 17, 400 }, | ||
| 227 | { 18, 398 }, | ||
| 228 | { 19, 396 }, | ||
| 229 | { 20, 394 }, | ||
| 230 | { 21, 392 }, | ||
| 231 | { 22, 390 }, | ||
| 232 | { 23, 388 }, | ||
| 233 | { 24, 386 }, | ||
| 234 | { 25, 384 }, | ||
| 235 | { 26, 382 }, | ||
| 236 | { 27, 380 }, | ||
| 237 | { 28, 379 }, | ||
| 238 | { 29, 378 }, | ||
| 239 | { 30, 377 }, | ||
| 240 | { 31, 376 }, | ||
| 241 | { 32, 375 }, | ||
| 242 | { 33, 374 }, | ||
| 243 | { 34, 373 }, | ||
| 244 | { 35, 372 }, | ||
| 245 | { 36, 371 }, | ||
| 246 | { 37, 370 }, | ||
| 247 | { 38, 362 }, | ||
| 248 | { 39, 354 }, | ||
| 249 | { 40, 346 }, | ||
| 250 | { 41, 338 }, | ||
| 251 | { 42, 330 }, | ||
| 252 | { 43, 328 }, | ||
| 253 | { 44, 326 }, | ||
| 254 | { 45, 324 }, | ||
| 255 | { 46, 322 }, | ||
| 256 | { 47, 320 }, | ||
| 257 | { 48, 319 }, | ||
| 258 | { 49, 318 }, | ||
| 259 | { 50, 317 }, | ||
| 260 | { 51, 316 }, | ||
| 261 | { 52, 315 }, | ||
| 262 | { 53, 314 }, | ||
| 263 | { 54, 313 }, | ||
| 264 | { 55, 312 }, | ||
| 265 | { 56, 311 }, | ||
| 266 | { 57, 310 }, | ||
| 267 | { 58, 308 }, | ||
| 268 | { 59, 306 }, | ||
| 269 | { 60, 304 }, | ||
| 270 | { 61, 302 }, | ||
| 271 | { 62, 300 }, | ||
| 272 | { 63, 298 }, | ||
| 273 | { 65, 295 }, | ||
| 274 | { 68, 294 }, | ||
| 275 | { 70, 293 }, | ||
| 276 | { 73, 292 }, | ||
| 277 | { 76, 291 }, | ||
| 278 | { 78, 290 }, | ||
| 279 | { 79, 289 }, | ||
| 280 | { 81, 288 }, | ||
| 281 | { 82, 287 }, | ||
| 282 | { 83, 286 }, | ||
| 283 | { 84, 285 }, | ||
| 284 | { 85, 284 }, | ||
| 285 | { 86, 283 }, | ||
| 286 | { 88, 282 }, | ||
| 287 | { 89, 281 }, | ||
| 288 | { 256, 280 }, | ||
| 289 | }; | ||
| 290 | |||
| 291 | static int au8522_mse2snr_lookup(struct mse2snr_tab *tab, int sz, int mse, | ||
| 292 | u16 *snr) | ||
| 293 | { | ||
| 294 | int i, ret = -EINVAL; | ||
| 295 | dprintk("%s()\n", __func__); | ||
| 296 | |||
| 297 | for (i = 0; i < sz; i++) { | ||
| 298 | if (mse < tab[i].val) { | ||
| 299 | *snr = tab[i].data; | ||
| 300 | ret = 0; | ||
| 301 | break; | ||
| 302 | } | ||
| 303 | } | ||
| 304 | dprintk("%s() snr=%d\n", __func__, *snr); | ||
| 305 | return ret; | ||
| 306 | } | ||
| 307 | |||
| 308 | /* VSB Modulation table */ | ||
| 309 | static struct { | ||
| 310 | u16 reg; | ||
| 311 | u16 data; | ||
| 312 | } VSB_mod_tab[] = { | ||
| 313 | { 0x8090, 0x84 }, | ||
| 314 | { 0x4092, 0x11 }, | ||
| 315 | { 0x2005, 0x00 }, | ||
| 316 | { 0x8091, 0x80 }, | ||
| 317 | { 0x80a3, 0x0c }, | ||
| 318 | { 0x80a4, 0xe8 }, | ||
| 319 | { 0x8081, 0xc4 }, | ||
| 320 | { 0x80a5, 0x40 }, | ||
| 321 | { 0x80a7, 0x40 }, | ||
| 322 | { 0x80a6, 0x67 }, | ||
| 323 | { 0x8262, 0x20 }, | ||
| 324 | { 0x821c, 0x30 }, | ||
| 325 | { 0x80d8, 0x1a }, | ||
| 326 | { 0x8227, 0xa0 }, | ||
| 327 | { 0x8121, 0xff }, | ||
| 328 | { 0x80a8, 0xf0 }, | ||
| 329 | { 0x80a9, 0x05 }, | ||
| 330 | { 0x80aa, 0x77 }, | ||
| 331 | { 0x80ab, 0xf0 }, | ||
| 332 | { 0x80ac, 0x05 }, | ||
| 333 | { 0x80ad, 0x77 }, | ||
| 334 | { 0x80ae, 0x41 }, | ||
| 335 | { 0x80af, 0x66 }, | ||
| 336 | { 0x821b, 0xcc }, | ||
| 337 | { 0x821d, 0x80 }, | ||
| 338 | { 0x80b5, 0xfb }, | ||
| 339 | { 0x80b6, 0x8e }, | ||
| 340 | { 0x80b7, 0x39 }, | ||
| 341 | { 0x80a4, 0xe8 }, | ||
| 342 | { 0x8231, 0x13 }, | ||
| 343 | }; | ||
| 344 | |||
| 345 | /* QAM Modulation table */ | ||
| 346 | static struct { | ||
| 347 | u16 reg; | ||
| 348 | u16 data; | ||
| 349 | } QAM_mod_tab[] = { | ||
| 350 | { 0x80a3, 0x09 }, | ||
| 351 | { 0x80a4, 0x00 }, | ||
| 352 | { 0x8081, 0xc4 }, | ||
| 353 | { 0x80a5, 0x40 }, | ||
| 354 | { 0x80b5, 0xfb }, | ||
| 355 | { 0x80b6, 0x8e }, | ||
| 356 | { 0x80b7, 0x39 }, | ||
| 357 | { 0x80aa, 0x77 }, | ||
| 358 | { 0x80ad, 0x77 }, | ||
| 359 | { 0x80a6, 0x67 }, | ||
| 360 | { 0x8262, 0x20 }, | ||
| 361 | { 0x821c, 0x30 }, | ||
| 362 | { 0x80b8, 0x3e }, | ||
| 363 | { 0x80b9, 0xf0 }, | ||
| 364 | { 0x80ba, 0x01 }, | ||
| 365 | { 0x80bb, 0x18 }, | ||
| 366 | { 0x80bc, 0x50 }, | ||
| 367 | { 0x80bd, 0x00 }, | ||
| 368 | { 0x80be, 0xea }, | ||
| 369 | { 0x80bf, 0xef }, | ||
| 370 | { 0x80c0, 0xfc }, | ||
| 371 | { 0x80c1, 0xbd }, | ||
| 372 | { 0x80c2, 0x1f }, | ||
| 373 | { 0x80c3, 0xfc }, | ||
| 374 | { 0x80c4, 0xdd }, | ||
| 375 | { 0x80c5, 0xaf }, | ||
| 376 | { 0x80c6, 0x00 }, | ||
| 377 | { 0x80c7, 0x38 }, | ||
| 378 | { 0x80c8, 0x30 }, | ||
| 379 | { 0x80c9, 0x05 }, | ||
| 380 | { 0x80ca, 0x4a }, | ||
| 381 | { 0x80cb, 0xd0 }, | ||
| 382 | { 0x80cc, 0x01 }, | ||
| 383 | { 0x80cd, 0xd9 }, | ||
| 384 | { 0x80ce, 0x6f }, | ||
| 385 | { 0x80cf, 0xf9 }, | ||
| 386 | { 0x80d0, 0x70 }, | ||
| 387 | { 0x80d1, 0xdf }, | ||
| 388 | { 0x80d2, 0xf7 }, | ||
| 389 | { 0x80d3, 0xc2 }, | ||
| 390 | { 0x80d4, 0xdf }, | ||
| 391 | { 0x80d5, 0x02 }, | ||
| 392 | { 0x80d6, 0x9a }, | ||
| 393 | { 0x80d7, 0xd0 }, | ||
| 394 | { 0x8250, 0x0d }, | ||
| 395 | { 0x8251, 0xcd }, | ||
| 396 | { 0x8252, 0xe0 }, | ||
| 397 | { 0x8253, 0x05 }, | ||
| 398 | { 0x8254, 0xa7 }, | ||
| 399 | { 0x8255, 0xff }, | ||
| 400 | { 0x8256, 0xed }, | ||
| 401 | { 0x8257, 0x5b }, | ||
| 402 | { 0x8258, 0xae }, | ||
| 403 | { 0x8259, 0xe6 }, | ||
| 404 | { 0x825a, 0x3d }, | ||
| 405 | { 0x825b, 0x0f }, | ||
| 406 | { 0x825c, 0x0d }, | ||
| 407 | { 0x825d, 0xea }, | ||
| 408 | { 0x825e, 0xf2 }, | ||
| 409 | { 0x825f, 0x51 }, | ||
| 410 | { 0x8260, 0xf5 }, | ||
| 411 | { 0x8261, 0x06 }, | ||
| 412 | { 0x821a, 0x00 }, | ||
| 413 | { 0x8546, 0x40 }, | ||
| 414 | { 0x8210, 0x26 }, | ||
| 415 | { 0x8211, 0xf6 }, | ||
| 416 | { 0x8212, 0x84 }, | ||
| 417 | { 0x8213, 0x02 }, | ||
| 418 | { 0x8502, 0x01 }, | ||
| 419 | { 0x8121, 0x04 }, | ||
| 420 | { 0x8122, 0x04 }, | ||
| 421 | { 0x852e, 0x10 }, | ||
| 422 | { 0x80a4, 0xca }, | ||
| 423 | { 0x80a7, 0x40 }, | ||
| 424 | { 0x8526, 0x01 }, | ||
| 425 | }; | ||
| 426 | |||
| 427 | static int au8522_enable_modulation(struct dvb_frontend *fe, | ||
| 428 | fe_modulation_t m) | ||
| 429 | { | ||
| 430 | struct au8522_state *state = fe->demodulator_priv; | ||
| 431 | int i; | ||
| 432 | |||
| 433 | dprintk("%s(0x%08x)\n", __func__, m); | ||
| 434 | |||
| 435 | switch (m) { | ||
| 436 | case VSB_8: | ||
| 437 | dprintk("%s() VSB_8\n", __func__); | ||
| 438 | for (i = 0; i < ARRAY_SIZE(VSB_mod_tab); i++) | ||
| 439 | au8522_writereg(state, | ||
| 440 | VSB_mod_tab[i].reg, | ||
| 441 | VSB_mod_tab[i].data); | ||
| 442 | break; | ||
| 443 | case QAM_64: | ||
| 444 | case QAM_256: | ||
| 445 | dprintk("%s() QAM 64/256\n", __func__); | ||
| 446 | for (i = 0; i < ARRAY_SIZE(QAM_mod_tab); i++) | ||
| 447 | au8522_writereg(state, | ||
| 448 | QAM_mod_tab[i].reg, | ||
| 449 | QAM_mod_tab[i].data); | ||
| 450 | break; | ||
| 451 | default: | ||
| 452 | dprintk("%s() Invalid modulation\n", __func__); | ||
| 453 | return -EINVAL; | ||
| 454 | } | ||
| 455 | |||
| 456 | state->current_modulation = m; | ||
| 457 | |||
| 458 | return 0; | ||
| 459 | } | ||
| 460 | |||
| 461 | /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ | ||
| 462 | static int au8522_set_frontend(struct dvb_frontend *fe, | ||
| 463 | struct dvb_frontend_parameters *p) | ||
| 464 | { | ||
| 465 | struct au8522_state *state = fe->demodulator_priv; | ||
| 466 | |||
| 467 | dprintk("%s(frequency=%d)\n", __func__, p->frequency); | ||
| 468 | |||
| 469 | state->current_frequency = p->frequency; | ||
| 470 | |||
| 471 | au8522_enable_modulation(fe, p->u.vsb.modulation); | ||
| 472 | |||
| 473 | /* Allow the demod to settle */ | ||
| 474 | msleep(100); | ||
| 475 | |||
| 476 | if (fe->ops.tuner_ops.set_params) { | ||
| 477 | if (fe->ops.i2c_gate_ctrl) | ||
| 478 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 479 | fe->ops.tuner_ops.set_params(fe, p); | ||
| 480 | if (fe->ops.i2c_gate_ctrl) | ||
| 481 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 482 | } | ||
| 483 | |||
| 484 | return 0; | ||
| 485 | } | ||
| 486 | |||
| 487 | /* Reset the demod hardware and reset all of the configuration registers | ||
| 488 | to a default state. */ | ||
| 489 | static int au8522_init(struct dvb_frontend *fe) | ||
| 490 | { | ||
| 491 | struct au8522_state *state = fe->demodulator_priv; | ||
| 492 | dprintk("%s()\n", __func__); | ||
| 493 | |||
| 494 | au8522_writereg(state, 0xa4, 1 << 5); | ||
| 495 | |||
| 496 | au8522_i2c_gate_ctrl(fe, 1); | ||
| 497 | |||
| 498 | return 0; | ||
| 499 | } | ||
| 500 | |||
| 501 | static int au8522_read_status(struct dvb_frontend *fe, fe_status_t *status) | ||
| 502 | { | ||
| 503 | struct au8522_state *state = fe->demodulator_priv; | ||
| 504 | u8 reg; | ||
| 505 | u32 tuner_status = 0; | ||
| 506 | |||
| 507 | *status = 0; | ||
| 508 | |||
| 509 | if (state->current_modulation == VSB_8) { | ||
| 510 | dprintk("%s() Checking VSB_8\n", __func__); | ||
| 511 | reg = au8522_readreg(state, 0x4088); | ||
| 512 | if (reg & 0x01) | ||
| 513 | *status |= FE_HAS_VITERBI; | ||
| 514 | if (reg & 0x02) | ||
| 515 | *status |= FE_HAS_LOCK | FE_HAS_SYNC; | ||
| 516 | } else { | ||
| 517 | dprintk("%s() Checking QAM\n", __func__); | ||
| 518 | reg = au8522_readreg(state, 0x4541); | ||
| 519 | if (reg & 0x80) | ||
| 520 | *status |= FE_HAS_VITERBI; | ||
| 521 | if (reg & 0x20) | ||
| 522 | *status |= FE_HAS_LOCK | FE_HAS_SYNC; | ||
| 523 | } | ||
| 524 | |||
| 525 | switch (state->config->status_mode) { | ||
| 526 | case AU8522_DEMODLOCKING: | ||
| 527 | dprintk("%s() DEMODLOCKING\n", __func__); | ||
| 528 | if (*status & FE_HAS_VITERBI) | ||
| 529 | *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; | ||
| 530 | break; | ||
| 531 | case AU8522_TUNERLOCKING: | ||
| 532 | /* Get the tuner status */ | ||
| 533 | dprintk("%s() TUNERLOCKING\n", __func__); | ||
| 534 | if (fe->ops.tuner_ops.get_status) { | ||
| 535 | if (fe->ops.i2c_gate_ctrl) | ||
| 536 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 537 | |||
| 538 | fe->ops.tuner_ops.get_status(fe, &tuner_status); | ||
| 539 | |||
| 540 | if (fe->ops.i2c_gate_ctrl) | ||
| 541 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 542 | } | ||
| 543 | if (tuner_status) | ||
| 544 | *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; | ||
| 545 | break; | ||
| 546 | } | ||
| 547 | |||
| 548 | dprintk("%s() status 0x%08x\n", __func__, *status); | ||
| 549 | |||
| 550 | return 0; | ||
| 551 | } | ||
| 552 | |||
| 553 | static int au8522_read_snr(struct dvb_frontend *fe, u16 *snr) | ||
| 554 | { | ||
| 555 | struct au8522_state *state = fe->demodulator_priv; | ||
| 556 | int ret = -EINVAL; | ||
| 557 | |||
| 558 | dprintk("%s()\n", __func__); | ||
| 559 | |||
| 560 | if (state->current_modulation == QAM_256) | ||
| 561 | ret = au8522_mse2snr_lookup(qam256_mse2snr_tab, | ||
| 562 | ARRAY_SIZE(qam256_mse2snr_tab), | ||
| 563 | au8522_readreg(state, 0x4522), | ||
| 564 | snr); | ||
| 565 | else if (state->current_modulation == QAM_64) | ||
| 566 | ret = au8522_mse2snr_lookup(qam64_mse2snr_tab, | ||
| 567 | ARRAY_SIZE(qam64_mse2snr_tab), | ||
| 568 | au8522_readreg(state, 0x4522), | ||
| 569 | snr); | ||
| 570 | else /* VSB_8 */ | ||
| 571 | ret = au8522_mse2snr_lookup(vsb_mse2snr_tab, | ||
| 572 | ARRAY_SIZE(vsb_mse2snr_tab), | ||
| 573 | au8522_readreg(state, 0x4311), | ||
| 574 | snr); | ||
| 575 | |||
| 576 | return ret; | ||
| 577 | } | ||
| 578 | |||
| 579 | static int au8522_read_signal_strength(struct dvb_frontend *fe, | ||
| 580 | u16 *signal_strength) | ||
| 581 | { | ||
| 582 | return au8522_read_snr(fe, signal_strength); | ||
| 583 | } | ||
| 584 | |||
| 585 | static int au8522_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | ||
| 586 | { | ||
| 587 | struct au8522_state *state = fe->demodulator_priv; | ||
| 588 | |||
| 589 | if (state->current_modulation == VSB_8) | ||
| 590 | *ucblocks = au8522_readreg(state, 0x4087); | ||
| 591 | else | ||
| 592 | *ucblocks = au8522_readreg(state, 0x4543); | ||
| 593 | |||
| 594 | return 0; | ||
| 595 | } | ||
| 596 | |||
| 597 | static int au8522_read_ber(struct dvb_frontend *fe, u32 *ber) | ||
| 598 | { | ||
| 599 | return au8522_read_ucblocks(fe, ber); | ||
| 600 | } | ||
| 601 | |||
| 602 | static int au8522_get_frontend(struct dvb_frontend *fe, | ||
| 603 | struct dvb_frontend_parameters *p) | ||
| 604 | { | ||
| 605 | struct au8522_state *state = fe->demodulator_priv; | ||
| 606 | |||
| 607 | p->frequency = state->current_frequency; | ||
| 608 | p->u.vsb.modulation = state->current_modulation; | ||
| 609 | |||
| 610 | return 0; | ||
| 611 | } | ||
| 612 | |||
| 613 | static int au8522_get_tune_settings(struct dvb_frontend *fe, | ||
| 614 | struct dvb_frontend_tune_settings *tune) | ||
| 615 | { | ||
| 616 | tune->min_delay_ms = 1000; | ||
| 617 | return 0; | ||
| 618 | } | ||
| 619 | |||
| 620 | static void au8522_release(struct dvb_frontend *fe) | ||
| 621 | { | ||
| 622 | struct au8522_state *state = fe->demodulator_priv; | ||
| 623 | kfree(state); | ||
| 624 | } | ||
| 625 | |||
| 626 | static struct dvb_frontend_ops au8522_ops; | ||
| 627 | |||
| 628 | struct dvb_frontend *au8522_attach(const struct au8522_config *config, | ||
| 629 | struct i2c_adapter *i2c) | ||
| 630 | { | ||
| 631 | struct au8522_state *state = NULL; | ||
| 632 | |||
| 633 | /* allocate memory for the internal state */ | ||
| 634 | state = kmalloc(sizeof(struct au8522_state), GFP_KERNEL); | ||
| 635 | if (state == NULL) | ||
| 636 | goto error; | ||
| 637 | |||
| 638 | /* setup the state */ | ||
| 639 | state->config = config; | ||
| 640 | state->i2c = i2c; | ||
| 641 | /* create dvb_frontend */ | ||
| 642 | memcpy(&state->frontend.ops, &au8522_ops, | ||
| 643 | sizeof(struct dvb_frontend_ops)); | ||
| 644 | state->frontend.demodulator_priv = state; | ||
| 645 | |||
| 646 | if (au8522_init(&state->frontend) != 0) { | ||
| 647 | printk(KERN_ERR "%s: Failed to initialize correctly\n", | ||
| 648 | __func__); | ||
| 649 | goto error; | ||
| 650 | } | ||
| 651 | |||
| 652 | /* Note: Leaving the I2C gate open here. */ | ||
| 653 | au8522_i2c_gate_ctrl(&state->frontend, 1); | ||
| 654 | |||
| 655 | return &state->frontend; | ||
| 656 | |||
| 657 | error: | ||
| 658 | kfree(state); | ||
| 659 | return NULL; | ||
| 660 | } | ||
| 661 | EXPORT_SYMBOL(au8522_attach); | ||
| 662 | |||
| 663 | static struct dvb_frontend_ops au8522_ops = { | ||
| 664 | |||
| 665 | .info = { | ||
| 666 | .name = "Auvitek AU8522 QAM/8VSB Frontend", | ||
| 667 | .type = FE_ATSC, | ||
| 668 | .frequency_min = 54000000, | ||
| 669 | .frequency_max = 858000000, | ||
| 670 | .frequency_stepsize = 62500, | ||
| 671 | .caps = FE_CAN_QAM_64 | FE_CAN_QAM_256 | FE_CAN_8VSB | ||
| 672 | }, | ||
| 673 | |||
| 674 | .init = au8522_init, | ||
| 675 | .i2c_gate_ctrl = au8522_i2c_gate_ctrl, | ||
| 676 | .set_frontend = au8522_set_frontend, | ||
| 677 | .get_frontend = au8522_get_frontend, | ||
| 678 | .get_tune_settings = au8522_get_tune_settings, | ||
| 679 | .read_status = au8522_read_status, | ||
| 680 | .read_ber = au8522_read_ber, | ||
| 681 | .read_signal_strength = au8522_read_signal_strength, | ||
| 682 | .read_snr = au8522_read_snr, | ||
| 683 | .read_ucblocks = au8522_read_ucblocks, | ||
| 684 | .release = au8522_release, | ||
| 685 | }; | ||
| 686 | |||
| 687 | module_param(debug, int, 0644); | ||
| 688 | MODULE_PARM_DESC(debug, "Enable verbose debug messages"); | ||
| 689 | |||
| 690 | MODULE_DESCRIPTION("Auvitek AU8522 QAM-B/ATSC Demodulator driver"); | ||
| 691 | MODULE_AUTHOR("Steven Toth"); | ||
| 692 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/frontends/au8522.h b/drivers/media/dvb/frontends/au8522.h new file mode 100644 index 000000000000..d7affa3cdb27 --- /dev/null +++ b/drivers/media/dvb/frontends/au8522.h | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | /* | ||
| 2 | Auvitek AU8522 QAM/8VSB demodulator driver | ||
| 3 | |||
| 4 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | #ifndef __AU8522_H__ | ||
| 23 | #define __AU8522_H__ | ||
| 24 | |||
| 25 | #include <linux/dvb/frontend.h> | ||
| 26 | |||
| 27 | struct au8522_config { | ||
| 28 | /* the demodulator's i2c address */ | ||
| 29 | u8 demod_address; | ||
| 30 | |||
| 31 | /* Return lock status based on tuner lock, or demod lock */ | ||
| 32 | #define AU8522_TUNERLOCKING 0 | ||
| 33 | #define AU8522_DEMODLOCKING 1 | ||
| 34 | u8 status_mode; | ||
| 35 | }; | ||
| 36 | |||
| 37 | #if defined(CONFIG_DVB_AU8522) || \ | ||
| 38 | (defined(CONFIG_DVB_AU8522_MODULE) && defined(MODULE)) | ||
| 39 | extern struct dvb_frontend *au8522_attach(const struct au8522_config *config, | ||
| 40 | struct i2c_adapter *i2c); | ||
| 41 | #else | ||
| 42 | static inline | ||
| 43 | struct dvb_frontend *au8522_attach(const struct au8522_config *config, | ||
| 44 | struct i2c_adapter *i2c) | ||
| 45 | { | ||
| 46 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
| 47 | return NULL; | ||
| 48 | } | ||
| 49 | #endif /* CONFIG_DVB_AU8522 */ | ||
| 50 | |||
| 51 | #endif /* __AU8522_H__ */ | ||
| 52 | |||
| 53 | /* | ||
| 54 | * Local variables: | ||
| 55 | * c-basic-offset: 8 | ||
| 56 | */ | ||
diff --git a/drivers/media/dvb/frontends/bcm3510.c b/drivers/media/dvb/frontends/bcm3510.c index a913f49c062b..d268e65e777d 100644 --- a/drivers/media/dvb/frontends/bcm3510.c +++ b/drivers/media/dvb/frontends/bcm3510.c | |||
| @@ -91,7 +91,7 @@ static int bcm3510_writebytes (struct bcm3510_state *state, u8 reg, u8 *buf, u8 | |||
| 91 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { | 91 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { |
| 92 | 92 | ||
| 93 | deb_info("%s: i2c write error (addr %02x, reg %02x, err == %i)\n", | 93 | deb_info("%s: i2c write error (addr %02x, reg %02x, err == %i)\n", |
| 94 | __FUNCTION__, state->config->demod_address, reg, err); | 94 | __func__, state->config->demod_address, reg, err); |
| 95 | return -EREMOTEIO; | 95 | return -EREMOTEIO; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| @@ -110,7 +110,7 @@ static int bcm3510_readbytes (struct bcm3510_state *state, u8 reg, u8 *buf, u8 l | |||
| 110 | 110 | ||
| 111 | if ((err = i2c_transfer (state->i2c, msg, 2)) != 2) { | 111 | if ((err = i2c_transfer (state->i2c, msg, 2)) != 2) { |
| 112 | deb_info("%s: i2c read error (addr %02x, reg %02x, err == %i)\n", | 112 | deb_info("%s: i2c read error (addr %02x, reg %02x, err == %i)\n", |
| 113 | __FUNCTION__, state->config->demod_address, reg, err); | 113 | __func__, state->config->demod_address, reg, err); |
| 114 | return -EREMOTEIO; | 114 | return -EREMOTEIO; |
| 115 | } | 115 | } |
| 116 | deb_i2c("i2c rd %02x: ",reg); | 116 | deb_i2c("i2c rd %02x: ",reg); |
diff --git a/drivers/media/dvb/frontends/bcm3510.h b/drivers/media/dvb/frontends/bcm3510.h index 7e4f95e1734b..f4575c0cc446 100644 --- a/drivers/media/dvb/frontends/bcm3510.h +++ b/drivers/media/dvb/frontends/bcm3510.h | |||
| @@ -41,7 +41,7 @@ extern struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config, | |||
| 41 | static inline struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config, | 41 | static inline struct dvb_frontend* bcm3510_attach(const struct bcm3510_config* config, |
| 42 | struct i2c_adapter* i2c) | 42 | struct i2c_adapter* i2c) |
| 43 | { | 43 | { |
| 44 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 44 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 45 | return NULL; | 45 | return NULL; |
| 46 | } | 46 | } |
| 47 | #endif // CONFIG_DVB_BCM3510 | 47 | #endif // CONFIG_DVB_BCM3510 |
diff --git a/drivers/media/dvb/frontends/bsbe1.h b/drivers/media/dvb/frontends/bsbe1.h index d8f65738e5d2..5e431ebd089b 100644 --- a/drivers/media/dvb/frontends/bsbe1.h +++ b/drivers/media/dvb/frontends/bsbe1.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * bsbe1.h - ALPS BSBE1 tuner support (moved from av7110.c) | 2 | * bsbe1.h - ALPS BSBE1 tuner support |
| 3 | * | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or | 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License | 5 | * modify it under the terms of the GNU General Public License |
| @@ -26,44 +26,24 @@ | |||
| 26 | #define BSBE1_H | 26 | #define BSBE1_H |
| 27 | 27 | ||
| 28 | static u8 alps_bsbe1_inittab[] = { | 28 | static u8 alps_bsbe1_inittab[] = { |
| 29 | 0x01, 0x15, | 29 | 0x01, 0x15, /* XTAL = 4MHz, VCO = 352 MHz */ |
| 30 | 0x02, 0x30, | 30 | 0x02, 0x30, /* MCLK = 88 MHz */ |
| 31 | 0x03, 0x00, | 31 | 0x03, 0x00, /* ACR output 0 */ |
| 32 | 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ | 32 | 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ |
| 33 | 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ | 33 | 0x05, 0x05, /* I2CT = 0, SCLT = 1, SDAT = 1 */ |
| 34 | 0x06, 0x40, /* DAC not used, set to high impendance mode */ | 34 | 0x06, 0x00, /* DAC output 0 */ |
| 35 | 0x07, 0x00, /* DAC LSB */ | ||
| 36 | 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ | 35 | 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ |
| 37 | 0x09, 0x00, /* FIFO */ | 36 | 0x09, 0x00, /* FIFO */ |
| 38 | 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ | 37 | 0x0c, 0x51, /* OP1/OP0 normal, val = 1 (LNB power on) */ |
| 39 | 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ | 38 | 0x0d, 0x82, /* DC offset compensation = on, beta_agc1 = 2 */ |
| 40 | 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ | 39 | 0x0f, 0x92, /* AGC1R */ |
| 41 | 0x10, 0x3f, // AGC2 0x3d | 40 | 0x10, 0x34, /* AGC2O */ |
| 42 | 0x11, 0x84, | 41 | 0x11, 0x84, /* TLSR */ |
| 43 | 0x12, 0xb9, | 42 | 0x12, 0xb9, /* CFD */ |
| 44 | 0x15, 0xc9, // lock detector threshold | 43 | 0x15, 0xc9, /* lock detector threshold */ |
| 45 | 0x16, 0x00, | 44 | 0x28, 0x00, /* out imp: normal, type: parallel, FEC mode: QPSK */ |
| 46 | 0x17, 0x00, | 45 | 0x33, 0xfc, /* RS control */ |
| 47 | 0x18, 0x00, | 46 | 0x34, 0x93, /* count viterbi bit errors per 2E18 bytes */ |
| 48 | 0x19, 0x00, | ||
| 49 | 0x1a, 0x00, | ||
| 50 | 0x1f, 0x50, | ||
| 51 | 0x20, 0x00, | ||
| 52 | 0x21, 0x00, | ||
| 53 | 0x22, 0x00, | ||
| 54 | 0x23, 0x00, | ||
| 55 | 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0 | ||
| 56 | 0x29, 0x1e, // 1/2 threshold | ||
| 57 | 0x2a, 0x14, // 2/3 threshold | ||
| 58 | 0x2b, 0x0f, // 3/4 threshold | ||
| 59 | 0x2c, 0x09, // 5/6 threshold | ||
| 60 | 0x2d, 0x05, // 7/8 threshold | ||
| 61 | 0x2e, 0x01, | ||
| 62 | 0x31, 0x1f, // test all FECs | ||
| 63 | 0x32, 0x19, // viterbi and synchro search | ||
| 64 | 0x33, 0xfc, // rs control | ||
| 65 | 0x34, 0x93, // error control | ||
| 66 | 0x0f, 0x92, | ||
| 67 | 0xff, 0xff | 47 | 0xff, 0xff |
| 68 | }; | 48 | }; |
| 69 | 49 | ||
| @@ -100,11 +80,11 @@ static int alps_bsbe1_tuner_set_params(struct dvb_frontend* fe, struct dvb_front | |||
| 100 | if ((params->frequency < 950000) || (params->frequency > 2150000)) | 80 | if ((params->frequency < 950000) || (params->frequency > 2150000)) |
| 101 | return -EINVAL; | 81 | return -EINVAL; |
| 102 | 82 | ||
| 103 | div = (params->frequency + (125 - 1)) / 125; // round correctly | 83 | div = params->frequency / 1000; |
| 104 | data[0] = (div >> 8) & 0x7f; | 84 | data[0] = (div >> 8) & 0x7f; |
| 105 | data[1] = div & 0xff; | 85 | data[1] = div & 0xff; |
| 106 | data[2] = 0x80 | ((div & 0x18000) >> 10) | 4; | 86 | data[2] = 0x80 | ((div & 0x18000) >> 10) | 0x1; |
| 107 | data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4; | 87 | data[3] = 0xe0; |
| 108 | 88 | ||
| 109 | if (fe->ops.i2c_gate_ctrl) | 89 | if (fe->ops.i2c_gate_ctrl) |
| 110 | fe->ops.i2c_gate_ctrl(fe, 1); | 90 | fe->ops.i2c_gate_ctrl(fe, 1); |
diff --git a/drivers/media/dvb/frontends/bsru6.h b/drivers/media/dvb/frontends/bsru6.h index e231cd84b3a1..45a6dfd8ebb5 100644 --- a/drivers/media/dvb/frontends/bsru6.h +++ b/drivers/media/dvb/frontends/bsru6.h | |||
| @@ -133,7 +133,7 @@ static struct stv0299_config alps_bsru6_config = { | |||
| 133 | .mclk = 88000000UL, | 133 | .mclk = 88000000UL, |
| 134 | .invert = 1, | 134 | .invert = 1, |
| 135 | .skip_reinit = 0, | 135 | .skip_reinit = 0, |
| 136 | .lock_output = STV0229_LOCKOUTPUT_1, | 136 | .lock_output = STV0299_LOCKOUTPUT_1, |
| 137 | .volt13_op0_op1 = STV0299_VOLT13_OP1, | 137 | .volt13_op0_op1 = STV0299_VOLT13_OP1, |
| 138 | .min_delay_ms = 100, | 138 | .min_delay_ms = 100, |
| 139 | .set_symbol_rate = alps_bsru6_set_symbol_rate, | 139 | .set_symbol_rate = alps_bsru6_set_symbol_rate, |
diff --git a/drivers/media/dvb/frontends/cx22700.c b/drivers/media/dvb/frontends/cx22700.c index 11a4968f18cb..ace5cb17165d 100644 --- a/drivers/media/dvb/frontends/cx22700.c +++ b/drivers/media/dvb/frontends/cx22700.c | |||
| @@ -73,13 +73,13 @@ static int cx22700_writereg (struct cx22700_state* state, u8 reg, u8 data) | |||
| 73 | u8 buf [] = { reg, data }; | 73 | u8 buf [] = { reg, data }; |
| 74 | struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; | 74 | struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; |
| 75 | 75 | ||
| 76 | dprintk ("%s\n", __FUNCTION__); | 76 | dprintk ("%s\n", __func__); |
| 77 | 77 | ||
| 78 | ret = i2c_transfer (state->i2c, &msg, 1); | 78 | ret = i2c_transfer (state->i2c, &msg, 1); |
| 79 | 79 | ||
| 80 | if (ret != 1) | 80 | if (ret != 1) |
| 81 | printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", | 81 | printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", |
| 82 | __FUNCTION__, reg, data, ret); | 82 | __func__, reg, data, ret); |
| 83 | 83 | ||
| 84 | return (ret != 1) ? -1 : 0; | 84 | return (ret != 1) ? -1 : 0; |
| 85 | } | 85 | } |
| @@ -92,7 +92,7 @@ static int cx22700_readreg (struct cx22700_state* state, u8 reg) | |||
| 92 | struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, | 92 | struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, |
| 93 | { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; | 93 | { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; |
| 94 | 94 | ||
| 95 | dprintk ("%s\n", __FUNCTION__); | 95 | dprintk ("%s\n", __func__); |
| 96 | 96 | ||
| 97 | ret = i2c_transfer (state->i2c, msg, 2); | 97 | ret = i2c_transfer (state->i2c, msg, 2); |
| 98 | 98 | ||
| @@ -105,7 +105,7 @@ static int cx22700_set_inversion (struct cx22700_state* state, int inversion) | |||
| 105 | { | 105 | { |
| 106 | u8 val; | 106 | u8 val; |
| 107 | 107 | ||
| 108 | dprintk ("%s\n", __FUNCTION__); | 108 | dprintk ("%s\n", __func__); |
| 109 | 109 | ||
| 110 | switch (inversion) { | 110 | switch (inversion) { |
| 111 | case INVERSION_AUTO: | 111 | case INVERSION_AUTO: |
| @@ -127,7 +127,7 @@ static int cx22700_set_tps (struct cx22700_state *state, struct dvb_ofdm_paramet | |||
| 127 | static const u8 fec_tab [6] = { 0, 1, 2, 0, 3, 4 }; | 127 | static const u8 fec_tab [6] = { 0, 1, 2, 0, 3, 4 }; |
| 128 | u8 val; | 128 | u8 val; |
| 129 | 129 | ||
| 130 | dprintk ("%s\n", __FUNCTION__); | 130 | dprintk ("%s\n", __func__); |
| 131 | 131 | ||
| 132 | if (p->code_rate_HP < FEC_1_2 || p->code_rate_HP > FEC_7_8) | 132 | if (p->code_rate_HP < FEC_1_2 || p->code_rate_HP > FEC_7_8) |
| 133 | return -EINVAL; | 133 | return -EINVAL; |
| @@ -191,7 +191,7 @@ static int cx22700_get_tps (struct cx22700_state* state, struct dvb_ofdm_paramet | |||
| 191 | FEC_5_6, FEC_7_8 }; | 191 | FEC_5_6, FEC_7_8 }; |
| 192 | u8 val; | 192 | u8 val; |
| 193 | 193 | ||
| 194 | dprintk ("%s\n", __FUNCTION__); | 194 | dprintk ("%s\n", __func__); |
| 195 | 195 | ||
| 196 | if (!(cx22700_readreg(state, 0x07) & 0x20)) /* tps valid? */ | 196 | if (!(cx22700_readreg(state, 0x07) & 0x20)) /* tps valid? */ |
| 197 | return -EAGAIN; | 197 | return -EAGAIN; |
diff --git a/drivers/media/dvb/frontends/cx22700.h b/drivers/media/dvb/frontends/cx22700.h index 7ac33690cdcc..4757a930ca05 100644 --- a/drivers/media/dvb/frontends/cx22700.h +++ b/drivers/media/dvb/frontends/cx22700.h | |||
| @@ -38,7 +38,7 @@ extern struct dvb_frontend* cx22700_attach(const struct cx22700_config* config, | |||
| 38 | static inline struct dvb_frontend* cx22700_attach(const struct cx22700_config* config, | 38 | static inline struct dvb_frontend* cx22700_attach(const struct cx22700_config* config, |
| 39 | struct i2c_adapter* i2c) | 39 | struct i2c_adapter* i2c) |
| 40 | { | 40 | { |
| 41 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 41 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 42 | return NULL; | 42 | return NULL; |
| 43 | } | 43 | } |
| 44 | #endif // CONFIG_DVB_CX22700 | 44 | #endif // CONFIG_DVB_CX22700 |
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c index 1dc164d5488c..cc1db4e371c3 100644 --- a/drivers/media/dvb/frontends/cx22702.c +++ b/drivers/media/dvb/frontends/cx22702.c | |||
| @@ -48,7 +48,7 @@ struct cx22702_state { | |||
| 48 | u8 prevUCBlocks; | 48 | u8 prevUCBlocks; |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | static int debug = 0; | 51 | static int debug; |
| 52 | #define dprintk if (debug) printk | 52 | #define dprintk if (debug) printk |
| 53 | 53 | ||
| 54 | /* Register values to initialise the demod */ | 54 | /* Register values to initialise the demod */ |
| @@ -90,7 +90,7 @@ static int cx22702_writereg (struct cx22702_state* state, u8 reg, u8 data) | |||
| 90 | 90 | ||
| 91 | if (ret != 1) | 91 | if (ret != 1) |
| 92 | printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", | 92 | printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n", |
| 93 | __FUNCTION__, reg, data, ret); | 93 | __func__, reg, data, ret); |
| 94 | 94 | ||
| 95 | return (ret != 1) ? -1 : 0; | 95 | return (ret != 1) ? -1 : 0; |
| 96 | } | 96 | } |
| @@ -108,7 +108,7 @@ static u8 cx22702_readreg (struct cx22702_state* state, u8 reg) | |||
| 108 | ret = i2c_transfer(state->i2c, msg, 2); | 108 | ret = i2c_transfer(state->i2c, msg, 2); |
| 109 | 109 | ||
| 110 | if (ret != 2) | 110 | if (ret != 2) |
| 111 | printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret); | 111 | printk("%s: readreg error (ret == %i)\n", __func__, ret); |
| 112 | 112 | ||
| 113 | return b1[0]; | 113 | return b1[0]; |
| 114 | } | 114 | } |
| @@ -195,7 +195,7 @@ static int cx22702_get_tps (struct cx22702_state *state, struct dvb_ofdm_paramet | |||
| 195 | static int cx22702_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) | 195 | static int cx22702_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) |
| 196 | { | 196 | { |
| 197 | struct cx22702_state* state = fe->demodulator_priv; | 197 | struct cx22702_state* state = fe->demodulator_priv; |
| 198 | dprintk ("%s(%d)\n", __FUNCTION__, enable); | 198 | dprintk ("%s(%d)\n", __func__, enable); |
| 199 | if (enable) | 199 | if (enable) |
| 200 | return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) & 0xfe); | 200 | return cx22702_writereg (state, 0x0D, cx22702_readreg(state, 0x0D) & 0xfe); |
| 201 | else | 201 | else |
| @@ -228,7 +228,7 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
| 228 | cx22702_writereg(state, 0x0C, cx22702_readreg(state, 0x0C) &0xcf ); | 228 | cx22702_writereg(state, 0x0C, cx22702_readreg(state, 0x0C) &0xcf ); |
| 229 | break; | 229 | break; |
| 230 | default: | 230 | default: |
| 231 | dprintk ("%s: invalid bandwidth\n",__FUNCTION__); | 231 | dprintk ("%s: invalid bandwidth\n",__func__); |
| 232 | return -EINVAL; | 232 | return -EINVAL; |
| 233 | } | 233 | } |
| 234 | 234 | ||
| @@ -250,7 +250,7 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
| 250 | cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) & 0xfc ); | 250 | cx22702_writereg(state, 0x0B, cx22702_readreg(state, 0x0B) & 0xfc ); |
| 251 | cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 ); | 251 | cx22702_writereg(state, 0x0C, (cx22702_readreg(state, 0x0C) & 0xBF) | 0x40 ); |
| 252 | cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */ | 252 | cx22702_writereg(state, 0x00, 0x01); /* Begin aquisition */ |
| 253 | dprintk("%s: Autodetecting\n",__FUNCTION__); | 253 | dprintk("%s: Autodetecting\n",__func__); |
| 254 | return 0; | 254 | return 0; |
| 255 | } | 255 | } |
| 256 | 256 | ||
| @@ -261,7 +261,7 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
| 261 | case QAM_16: val = (val&0xe7)|0x08; break; | 261 | case QAM_16: val = (val&0xe7)|0x08; break; |
| 262 | case QAM_64: val = (val&0xe7)|0x10; break; | 262 | case QAM_64: val = (val&0xe7)|0x10; break; |
| 263 | default: | 263 | default: |
| 264 | dprintk ("%s: invalid constellation\n",__FUNCTION__); | 264 | dprintk ("%s: invalid constellation\n",__func__); |
| 265 | return -EINVAL; | 265 | return -EINVAL; |
| 266 | } | 266 | } |
| 267 | switch(p->u.ofdm.hierarchy_information) { | 267 | switch(p->u.ofdm.hierarchy_information) { |
| @@ -270,7 +270,7 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
| 270 | case HIERARCHY_2: val = (val&0xf8)|2; break; | 270 | case HIERARCHY_2: val = (val&0xf8)|2; break; |
| 271 | case HIERARCHY_4: val = (val&0xf8)|3; break; | 271 | case HIERARCHY_4: val = (val&0xf8)|3; break; |
| 272 | default: | 272 | default: |
| 273 | dprintk ("%s: invalid hierarchy\n",__FUNCTION__); | 273 | dprintk ("%s: invalid hierarchy\n",__func__); |
| 274 | return -EINVAL; | 274 | return -EINVAL; |
| 275 | } | 275 | } |
| 276 | cx22702_writereg (state, 0x06, val); | 276 | cx22702_writereg (state, 0x06, val); |
| @@ -284,7 +284,7 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
| 284 | case FEC_5_6: val = (val&0xc7)|0x18; break; | 284 | case FEC_5_6: val = (val&0xc7)|0x18; break; |
| 285 | case FEC_7_8: val = (val&0xc7)|0x20; break; | 285 | case FEC_7_8: val = (val&0xc7)|0x20; break; |
| 286 | default: | 286 | default: |
| 287 | dprintk ("%s: invalid code_rate_HP\n",__FUNCTION__); | 287 | dprintk ("%s: invalid code_rate_HP\n",__func__); |
| 288 | return -EINVAL; | 288 | return -EINVAL; |
| 289 | } | 289 | } |
| 290 | switch(p->u.ofdm.code_rate_LP) { | 290 | switch(p->u.ofdm.code_rate_LP) { |
| @@ -295,7 +295,7 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
| 295 | case FEC_5_6: val = (val&0xf8)|3; break; | 295 | case FEC_5_6: val = (val&0xf8)|3; break; |
| 296 | case FEC_7_8: val = (val&0xf8)|4; break; | 296 | case FEC_7_8: val = (val&0xf8)|4; break; |
| 297 | default: | 297 | default: |
| 298 | dprintk ("%s: invalid code_rate_LP\n",__FUNCTION__); | 298 | dprintk ("%s: invalid code_rate_LP\n",__func__); |
| 299 | return -EINVAL; | 299 | return -EINVAL; |
| 300 | } | 300 | } |
| 301 | cx22702_writereg (state, 0x07, val); | 301 | cx22702_writereg (state, 0x07, val); |
| @@ -307,14 +307,14 @@ static int cx22702_set_tps (struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
| 307 | case GUARD_INTERVAL_1_8: val = (val&0xf3)|0x08; break; | 307 | case GUARD_INTERVAL_1_8: val = (val&0xf3)|0x08; break; |
| 308 | case GUARD_INTERVAL_1_4: val = (val&0xf3)|0x0c; break; | 308 | case GUARD_INTERVAL_1_4: val = (val&0xf3)|0x0c; break; |
| 309 | default: | 309 | default: |
| 310 | dprintk ("%s: invalid guard_interval\n",__FUNCTION__); | 310 | dprintk ("%s: invalid guard_interval\n",__func__); |
| 311 | return -EINVAL; | 311 | return -EINVAL; |
| 312 | } | 312 | } |
| 313 | switch(p->u.ofdm.transmission_mode) { | 313 | switch(p->u.ofdm.transmission_mode) { |
| 314 | case TRANSMISSION_MODE_2K: val = (val&0xfc); break; | 314 | case TRANSMISSION_MODE_2K: val = (val&0xfc); break; |
| 315 | case TRANSMISSION_MODE_8K: val = (val&0xfc)|1; break; | 315 | case TRANSMISSION_MODE_8K: val = (val&0xfc)|1; break; |
| 316 | default: | 316 | default: |
| 317 | dprintk ("%s: invalid transmission_mode\n",__FUNCTION__); | 317 | dprintk ("%s: invalid transmission_mode\n",__func__); |
| 318 | return -EINVAL; | 318 | return -EINVAL; |
| 319 | } | 319 | } |
| 320 | cx22702_writereg(state, 0x08, val); | 320 | cx22702_writereg(state, 0x08, val); |
| @@ -360,7 +360,7 @@ static int cx22702_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 360 | reg23 = cx22702_readreg (state, 0x23); | 360 | reg23 = cx22702_readreg (state, 0x23); |
| 361 | 361 | ||
| 362 | dprintk ("%s: status demod=0x%02x agc=0x%02x\n" | 362 | dprintk ("%s: status demod=0x%02x agc=0x%02x\n" |
| 363 | ,__FUNCTION__,reg0A,reg23); | 363 | ,__func__,reg0A,reg23); |
| 364 | 364 | ||
| 365 | if(reg0A & 0x10) { | 365 | if(reg0A & 0x10) { |
| 366 | *status |= FE_HAS_LOCK; | 366 | *status |= FE_HAS_LOCK; |
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h index 9cd64da6ee40..8af766a31552 100644 --- a/drivers/media/dvb/frontends/cx22702.h +++ b/drivers/media/dvb/frontends/cx22702.h | |||
| @@ -48,7 +48,7 @@ extern struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, | |||
| 48 | static inline struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, | 48 | static inline struct dvb_frontend* cx22702_attach(const struct cx22702_config* config, |
| 49 | struct i2c_adapter* i2c) | 49 | struct i2c_adapter* i2c) |
| 50 | { | 50 | { |
| 51 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 51 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 52 | return NULL; | 52 | return NULL; |
| 53 | } | 53 | } |
| 54 | #endif // CONFIG_DVB_CX22702 | 54 | #endif // CONFIG_DVB_CX22702 |
diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c index b03d8283c37d..87ae29db024f 100644 --- a/drivers/media/dvb/frontends/cx24110.c +++ b/drivers/media/dvb/frontends/cx24110.c | |||
| @@ -121,7 +121,7 @@ static int cx24110_writereg (struct cx24110_state* state, int reg, int data) | |||
| 121 | 121 | ||
| 122 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { | 122 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { |
| 123 | dprintk ("%s: writereg error (err == %i, reg == 0x%02x," | 123 | dprintk ("%s: writereg error (err == %i, reg == 0x%02x," |
| 124 | " data == 0x%02x)\n", __FUNCTION__, err, reg, data); | 124 | " data == 0x%02x)\n", __func__, err, reg, data); |
| 125 | return -EREMOTEIO; | 125 | return -EREMOTEIO; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| @@ -247,7 +247,7 @@ static int cx24110_set_symbolrate (struct cx24110_state* state, u32 srate) | |||
| 247 | static const u32 bands[]={5000000UL,15000000UL,90999000UL/2}; | 247 | static const u32 bands[]={5000000UL,15000000UL,90999000UL/2}; |
| 248 | int i; | 248 | int i; |
| 249 | 249 | ||
| 250 | dprintk("cx24110 debug: entering %s(%d)\n",__FUNCTION__,srate); | 250 | dprintk("cx24110 debug: entering %s(%d)\n",__func__,srate); |
| 251 | if (srate>90999000UL/2) | 251 | if (srate>90999000UL/2) |
| 252 | srate=90999000UL/2; | 252 | srate=90999000UL/2; |
| 253 | if (srate<500000) | 253 | if (srate<500000) |
| @@ -358,7 +358,7 @@ static int cx24110_initfe(struct dvb_frontend* fe) | |||
| 358 | /* fixme (low): error handling */ | 358 | /* fixme (low): error handling */ |
| 359 | int i; | 359 | int i; |
| 360 | 360 | ||
| 361 | dprintk("%s: init chip\n", __FUNCTION__); | 361 | dprintk("%s: init chip\n", __func__); |
| 362 | 362 | ||
| 363 | for(i = 0; i < ARRAY_SIZE(cx24110_regdata); i++) { | 363 | for(i = 0; i < ARRAY_SIZE(cx24110_regdata); i++) { |
| 364 | cx24110_writereg(state, cx24110_regdata[i].reg, cx24110_regdata[i].data); | 364 | cx24110_writereg(state, cx24110_regdata[i].reg, cx24110_regdata[i].data); |
diff --git a/drivers/media/dvb/frontends/cx24110.h b/drivers/media/dvb/frontends/cx24110.h index 0ca3af4db513..1792adb23c4d 100644 --- a/drivers/media/dvb/frontends/cx24110.h +++ b/drivers/media/dvb/frontends/cx24110.h | |||
| @@ -48,7 +48,7 @@ extern struct dvb_frontend* cx24110_attach(const struct cx24110_config* config, | |||
| 48 | static inline struct dvb_frontend* cx24110_attach(const struct cx24110_config* config, | 48 | static inline struct dvb_frontend* cx24110_attach(const struct cx24110_config* config, |
| 49 | struct i2c_adapter* i2c) | 49 | struct i2c_adapter* i2c) |
| 50 | { | 50 | { |
| 51 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 51 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 52 | return NULL; | 52 | return NULL; |
| 53 | } | 53 | } |
| 54 | #endif // CONFIG_DVB_CX24110 | 54 | #endif // CONFIG_DVB_CX24110 |
diff --git a/drivers/media/dvb/frontends/cx24113.h b/drivers/media/dvb/frontends/cx24113.h new file mode 100644 index 000000000000..5ab3dd11076b --- /dev/null +++ b/drivers/media/dvb/frontends/cx24113.h | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | /* | ||
| 2 | * Driver for Conexant CX24113/CX24128 Tuner (Satelite) | ||
| 3 | * | ||
| 4 | * Copyright (C) 2007-8 Patrick Boettcher <pb@linuxtv.org> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= | ||
| 20 | */ | ||
| 21 | |||
| 22 | #ifndef CX24113_H | ||
| 23 | #define CX24113_H | ||
| 24 | |||
| 25 | struct dvb_frontend; | ||
| 26 | |||
| 27 | struct cx24113_config { | ||
| 28 | u8 i2c_addr; /* 0x14 or 0x54 */ | ||
| 29 | |||
| 30 | u32 xtal_khz; | ||
| 31 | }; | ||
| 32 | |||
| 33 | /* TODO: #if defined(CONFIG_DVB_TUNER_CX24113) || \ | ||
| 34 | * (defined(CONFIG_DVB_TUNER_CX24113_MODULE) && defined(MODULE)) */ | ||
| 35 | |||
| 36 | static inline struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe, | ||
| 37 | const struct cx24113_config *config, struct i2c_adapter *i2c) | ||
| 38 | { | ||
| 39 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
| 40 | return NULL; | ||
| 41 | } | ||
| 42 | |||
| 43 | static inline void cx24113_agc_callback(struct dvb_frontend *fe) | ||
| 44 | { | ||
| 45 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
| 46 | } | ||
| 47 | |||
| 48 | #endif /* CX24113_H */ | ||
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c index d74fdbd63361..7f68d78c6558 100644 --- a/drivers/media/dvb/frontends/cx24123.c +++ b/drivers/media/dvb/frontends/cx24123.c | |||
| @@ -1,24 +1,26 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver | 2 | * Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver |
| 3 | 3 | * | |
| 4 | Copyright (C) 2005 Steven Toth <stoth@hauppauge.com> | 4 | * Copyright (C) 2005 Steven Toth <stoth@hauppauge.com> |
| 5 | 5 | * | |
| 6 | Support for KWorld DVB-S 100 by Vadim Catana <skystar@moldova.cc> | 6 | * Support for KWorld DVB-S 100 by Vadim Catana <skystar@moldova.cc> |
| 7 | 7 | * | |
| 8 | This program is free software; you can redistribute it and/or modify | 8 | * Support for CX24123/CX24113-NIM by Patrick Boettcher <pb@linuxtv.org> |
| 9 | it under the terms of the GNU General Public License as published by | 9 | * |
| 10 | the Free Software Foundation; either version 2 of the License, or | 10 | * This program is free software; you can redistribute it and/or |
| 11 | (at your option) any later version. | 11 | * modify it under the terms of the GNU General Public License as |
| 12 | 12 | * published by the Free Software Foundation; either version 2 of | |
| 13 | This program is distributed in the hope that it will be useful, | 13 | * the License, or (at your option) any later version. |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * This program is distributed in the hope that it will be useful, |
| 16 | GNU General Public License for more details. | 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 18 | You should have received a copy of the GNU General Public License | 18 | * General Public License for more details. |
| 19 | along with this program; if not, write to the Free Software | 19 | * |
| 20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 20 | * You should have received a copy of the GNU General Public License |
| 21 | */ | 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 23 | */ | ||
| 22 | 24 | ||
| 23 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
| 24 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
| @@ -32,9 +34,16 @@ | |||
| 32 | 34 | ||
| 33 | static int force_band; | 35 | static int force_band; |
| 34 | static int debug; | 36 | static int debug; |
| 37 | |||
| 38 | #define info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0) | ||
| 39 | #define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0) | ||
| 40 | |||
| 35 | #define dprintk(args...) \ | 41 | #define dprintk(args...) \ |
| 36 | do { \ | 42 | do { \ |
| 37 | if (debug) printk (KERN_DEBUG "cx24123: " args); \ | 43 | if (debug) { \ |
| 44 | printk(KERN_DEBUG "CX24123: %s: ", __func__); \ | ||
| 45 | printk(args); \ | ||
| 46 | } \ | ||
| 38 | } while (0) | 47 | } while (0) |
| 39 | 48 | ||
| 40 | struct cx24123_state | 49 | struct cx24123_state |
| @@ -51,6 +60,10 @@ struct cx24123_state | |||
| 51 | u32 pllarg; | 60 | u32 pllarg; |
| 52 | u32 FILTune; | 61 | u32 FILTune; |
| 53 | 62 | ||
| 63 | struct i2c_adapter tuner_i2c_adapter; | ||
| 64 | |||
| 65 | u8 demod_rev; | ||
| 66 | |||
| 54 | /* The Demod/Tuner can't easily provide these, we cache them */ | 67 | /* The Demod/Tuner can't easily provide these, we cache them */ |
| 55 | u32 currentfreq; | 68 | u32 currentfreq; |
| 56 | u32 currentsymbolrate; | 69 | u32 currentsymbolrate; |
| @@ -225,48 +238,52 @@ static struct { | |||
| 225 | {0x67, 0x83}, /* Non-DCII symbol clock */ | 238 | {0x67, 0x83}, /* Non-DCII symbol clock */ |
| 226 | }; | 239 | }; |
| 227 | 240 | ||
| 228 | static int cx24123_writereg(struct cx24123_state* state, int reg, int data) | 241 | static int cx24123_i2c_writereg(struct cx24123_state *state, |
| 242 | u8 i2c_addr, int reg, int data) | ||
| 229 | { | 243 | { |
| 230 | u8 buf[] = { reg, data }; | 244 | u8 buf[] = { reg, data }; |
| 231 | struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; | 245 | struct i2c_msg msg = { |
| 246 | .addr = i2c_addr, .flags = 0, .buf = buf, .len = 2 | ||
| 247 | }; | ||
| 232 | int err; | 248 | int err; |
| 233 | 249 | ||
| 234 | if (debug>1) | 250 | /* printk(KERN_DEBUG "wr(%02x): %02x %02x\n", i2c_addr, reg, data); */ |
| 235 | printk("cx24123: %s: write reg 0x%02x, value 0x%02x\n", | ||
| 236 | __FUNCTION__,reg, data); | ||
| 237 | 251 | ||
| 238 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { | 252 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { |
| 239 | printk("%s: writereg error(err == %i, reg == 0x%02x," | 253 | printk("%s: writereg error(err == %i, reg == 0x%02x," |
| 240 | " data == 0x%02x)\n", __FUNCTION__, err, reg, data); | 254 | " data == 0x%02x)\n", __func__, err, reg, data); |
| 241 | return -EREMOTEIO; | 255 | return err; |
| 242 | } | 256 | } |
| 243 | 257 | ||
| 244 | return 0; | 258 | return 0; |
| 245 | } | 259 | } |
| 246 | 260 | ||
| 247 | static int cx24123_readreg(struct cx24123_state* state, u8 reg) | 261 | static int cx24123_i2c_readreg(struct cx24123_state *state, u8 i2c_addr, u8 reg) |
| 248 | { | 262 | { |
| 249 | int ret; | 263 | int ret; |
| 250 | u8 b0[] = { reg }; | 264 | u8 b = 0; |
| 251 | u8 b1[] = { 0 }; | ||
| 252 | struct i2c_msg msg[] = { | 265 | struct i2c_msg msg[] = { |
| 253 | { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, | 266 | { .addr = i2c_addr, .flags = 0, .buf = ®, .len = 1 }, |
| 254 | { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } | 267 | { .addr = i2c_addr, .flags = I2C_M_RD, .buf = &b, .len = 1 } |
| 255 | }; | 268 | }; |
| 256 | 269 | ||
| 257 | ret = i2c_transfer(state->i2c, msg, 2); | 270 | ret = i2c_transfer(state->i2c, msg, 2); |
| 258 | 271 | ||
| 259 | if (ret != 2) { | 272 | if (ret != 2) { |
| 260 | printk("%s: reg=0x%x (error=%d)\n", __FUNCTION__, reg, ret); | 273 | err("%s: reg=0x%x (error=%d)\n", __func__, reg, ret); |
| 261 | return ret; | 274 | return ret; |
| 262 | } | 275 | } |
| 263 | 276 | ||
| 264 | if (debug>1) | 277 | /* printk(KERN_DEBUG "rd(%02x): %02x %02x\n", i2c_addr, reg, b); */ |
| 265 | printk("cx24123: read reg 0x%02x, value 0x%02x\n",reg, ret); | ||
| 266 | 278 | ||
| 267 | return b1[0]; | 279 | return b; |
| 268 | } | 280 | } |
| 269 | 281 | ||
| 282 | #define cx24123_readreg(state, reg) \ | ||
| 283 | cx24123_i2c_readreg(state, state->config->demod_address, reg) | ||
| 284 | #define cx24123_writereg(state, reg, val) \ | ||
| 285 | cx24123_i2c_writereg(state, state->config->demod_address, reg, val) | ||
| 286 | |||
| 270 | static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) | 287 | static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) |
| 271 | { | 288 | { |
| 272 | u8 nom_reg = cx24123_readreg(state, 0x0e); | 289 | u8 nom_reg = cx24123_readreg(state, 0x0e); |
| @@ -274,17 +291,17 @@ static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_invers | |||
| 274 | 291 | ||
| 275 | switch (inversion) { | 292 | switch (inversion) { |
| 276 | case INVERSION_OFF: | 293 | case INVERSION_OFF: |
| 277 | dprintk("%s: inversion off\n",__FUNCTION__); | 294 | dprintk("inversion off\n"); |
| 278 | cx24123_writereg(state, 0x0e, nom_reg & ~0x80); | 295 | cx24123_writereg(state, 0x0e, nom_reg & ~0x80); |
| 279 | cx24123_writereg(state, 0x10, auto_reg | 0x80); | 296 | cx24123_writereg(state, 0x10, auto_reg | 0x80); |
| 280 | break; | 297 | break; |
| 281 | case INVERSION_ON: | 298 | case INVERSION_ON: |
| 282 | dprintk("%s: inversion on\n",__FUNCTION__); | 299 | dprintk("inversion on\n"); |
| 283 | cx24123_writereg(state, 0x0e, nom_reg | 0x80); | 300 | cx24123_writereg(state, 0x0e, nom_reg | 0x80); |
| 284 | cx24123_writereg(state, 0x10, auto_reg | 0x80); | 301 | cx24123_writereg(state, 0x10, auto_reg | 0x80); |
| 285 | break; | 302 | break; |
| 286 | case INVERSION_AUTO: | 303 | case INVERSION_AUTO: |
| 287 | dprintk("%s: inversion auto\n",__FUNCTION__); | 304 | dprintk("inversion auto\n"); |
| 288 | cx24123_writereg(state, 0x10, auto_reg & ~0x80); | 305 | cx24123_writereg(state, 0x10, auto_reg & ~0x80); |
| 289 | break; | 306 | break; |
| 290 | default: | 307 | default: |
| @@ -301,10 +318,10 @@ static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_invers | |||
| 301 | val = cx24123_readreg(state, 0x1b) >> 7; | 318 | val = cx24123_readreg(state, 0x1b) >> 7; |
| 302 | 319 | ||
| 303 | if (val == 0) { | 320 | if (val == 0) { |
| 304 | dprintk("%s: read inversion off\n",__FUNCTION__); | 321 | dprintk("read inversion off\n"); |
| 305 | *inversion = INVERSION_OFF; | 322 | *inversion = INVERSION_OFF; |
| 306 | } else { | 323 | } else { |
| 307 | dprintk("%s: read inversion on\n",__FUNCTION__); | 324 | dprintk("read inversion on\n"); |
| 308 | *inversion = INVERSION_ON; | 325 | *inversion = INVERSION_ON; |
| 309 | } | 326 | } |
| 310 | 327 | ||
| @@ -326,42 +343,42 @@ static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) | |||
| 326 | 343 | ||
| 327 | switch (fec) { | 344 | switch (fec) { |
| 328 | case FEC_1_2: | 345 | case FEC_1_2: |
| 329 | dprintk("%s: set FEC to 1/2\n",__FUNCTION__); | 346 | dprintk("set FEC to 1/2\n"); |
| 330 | cx24123_writereg(state, 0x0e, nom_reg | 0x01); | 347 | cx24123_writereg(state, 0x0e, nom_reg | 0x01); |
| 331 | cx24123_writereg(state, 0x0f, 0x02); | 348 | cx24123_writereg(state, 0x0f, 0x02); |
| 332 | break; | 349 | break; |
| 333 | case FEC_2_3: | 350 | case FEC_2_3: |
| 334 | dprintk("%s: set FEC to 2/3\n",__FUNCTION__); | 351 | dprintk("set FEC to 2/3\n"); |
| 335 | cx24123_writereg(state, 0x0e, nom_reg | 0x02); | 352 | cx24123_writereg(state, 0x0e, nom_reg | 0x02); |
| 336 | cx24123_writereg(state, 0x0f, 0x04); | 353 | cx24123_writereg(state, 0x0f, 0x04); |
| 337 | break; | 354 | break; |
| 338 | case FEC_3_4: | 355 | case FEC_3_4: |
| 339 | dprintk("%s: set FEC to 3/4\n",__FUNCTION__); | 356 | dprintk("set FEC to 3/4\n"); |
| 340 | cx24123_writereg(state, 0x0e, nom_reg | 0x03); | 357 | cx24123_writereg(state, 0x0e, nom_reg | 0x03); |
| 341 | cx24123_writereg(state, 0x0f, 0x08); | 358 | cx24123_writereg(state, 0x0f, 0x08); |
| 342 | break; | 359 | break; |
| 343 | case FEC_4_5: | 360 | case FEC_4_5: |
| 344 | dprintk("%s: set FEC to 4/5\n",__FUNCTION__); | 361 | dprintk("set FEC to 4/5\n"); |
| 345 | cx24123_writereg(state, 0x0e, nom_reg | 0x04); | 362 | cx24123_writereg(state, 0x0e, nom_reg | 0x04); |
| 346 | cx24123_writereg(state, 0x0f, 0x10); | 363 | cx24123_writereg(state, 0x0f, 0x10); |
| 347 | break; | 364 | break; |
| 348 | case FEC_5_6: | 365 | case FEC_5_6: |
| 349 | dprintk("%s: set FEC to 5/6\n",__FUNCTION__); | 366 | dprintk("set FEC to 5/6\n"); |
| 350 | cx24123_writereg(state, 0x0e, nom_reg | 0x05); | 367 | cx24123_writereg(state, 0x0e, nom_reg | 0x05); |
| 351 | cx24123_writereg(state, 0x0f, 0x20); | 368 | cx24123_writereg(state, 0x0f, 0x20); |
| 352 | break; | 369 | break; |
| 353 | case FEC_6_7: | 370 | case FEC_6_7: |
| 354 | dprintk("%s: set FEC to 6/7\n",__FUNCTION__); | 371 | dprintk("set FEC to 6/7\n"); |
| 355 | cx24123_writereg(state, 0x0e, nom_reg | 0x06); | 372 | cx24123_writereg(state, 0x0e, nom_reg | 0x06); |
| 356 | cx24123_writereg(state, 0x0f, 0x40); | 373 | cx24123_writereg(state, 0x0f, 0x40); |
| 357 | break; | 374 | break; |
| 358 | case FEC_7_8: | 375 | case FEC_7_8: |
| 359 | dprintk("%s: set FEC to 7/8\n",__FUNCTION__); | 376 | dprintk("set FEC to 7/8\n"); |
| 360 | cx24123_writereg(state, 0x0e, nom_reg | 0x07); | 377 | cx24123_writereg(state, 0x0e, nom_reg | 0x07); |
| 361 | cx24123_writereg(state, 0x0f, 0x80); | 378 | cx24123_writereg(state, 0x0f, 0x80); |
| 362 | break; | 379 | break; |
| 363 | case FEC_AUTO: | 380 | case FEC_AUTO: |
| 364 | dprintk("%s: set FEC to auto\n",__FUNCTION__); | 381 | dprintk("set FEC to auto\n"); |
| 365 | cx24123_writereg(state, 0x0f, 0xfe); | 382 | cx24123_writereg(state, 0x0f, 0xfe); |
| 366 | break; | 383 | break; |
| 367 | default: | 384 | default: |
| @@ -490,7 +507,8 @@ static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) | |||
| 490 | tmp = cx24123_readreg(state, 0x0c) & ~0xe0; | 507 | tmp = cx24123_readreg(state, 0x0c) & ~0xe0; |
| 491 | cx24123_writereg(state, 0x0c, tmp | sample_gain << 5); | 508 | cx24123_writereg(state, 0x0c, tmp | sample_gain << 5); |
| 492 | 509 | ||
| 493 | dprintk("%s: srate=%d, ratio=0x%08x, sample_rate=%i sample_gain=%d\n", __FUNCTION__, srate, ratio, sample_rate, sample_gain); | 510 | dprintk("srate=%d, ratio=0x%08x, sample_rate=%i sample_gain=%d\n", |
| 511 | srate, ratio, sample_rate, sample_gain); | ||
| 494 | 512 | ||
| 495 | return 0; | 513 | return 0; |
| 496 | } | 514 | } |
| @@ -570,7 +588,7 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 570 | struct cx24123_state *state = fe->demodulator_priv; | 588 | struct cx24123_state *state = fe->demodulator_priv; |
| 571 | unsigned long timeout; | 589 | unsigned long timeout; |
| 572 | 590 | ||
| 573 | dprintk("%s: pll writereg called, data=0x%08x\n",__FUNCTION__,data); | 591 | dprintk("pll writereg called, data=0x%08x\n", data); |
| 574 | 592 | ||
| 575 | /* align the 21 bytes into to bit23 boundary */ | 593 | /* align the 21 bytes into to bit23 boundary */ |
| 576 | data = data << 3; | 594 | data = data << 3; |
| @@ -583,7 +601,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 583 | cx24123_writereg(state, 0x22, (data >> 16) & 0xff); | 601 | cx24123_writereg(state, 0x22, (data >> 16) & 0xff); |
| 584 | while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { | 602 | while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { |
| 585 | if (time_after(jiffies, timeout)) { | 603 | if (time_after(jiffies, timeout)) { |
| 586 | printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__); | 604 | err("%s: demodulator is not responding, "\ |
| 605 | "possibly hung, aborting.\n", __func__); | ||
| 587 | return -EREMOTEIO; | 606 | return -EREMOTEIO; |
| 588 | } | 607 | } |
| 589 | msleep(10); | 608 | msleep(10); |
| @@ -594,7 +613,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 594 | cx24123_writereg(state, 0x22, (data>>8) & 0xff ); | 613 | cx24123_writereg(state, 0x22, (data>>8) & 0xff ); |
| 595 | while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { | 614 | while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { |
| 596 | if (time_after(jiffies, timeout)) { | 615 | if (time_after(jiffies, timeout)) { |
| 597 | printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__); | 616 | err("%s: demodulator is not responding, "\ |
| 617 | "possibly hung, aborting.\n", __func__); | ||
| 598 | return -EREMOTEIO; | 618 | return -EREMOTEIO; |
| 599 | } | 619 | } |
| 600 | msleep(10); | 620 | msleep(10); |
| @@ -605,7 +625,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 605 | cx24123_writereg(state, 0x22, (data) & 0xff ); | 625 | cx24123_writereg(state, 0x22, (data) & 0xff ); |
| 606 | while ((cx24123_readreg(state, 0x20) & 0x80)) { | 626 | while ((cx24123_readreg(state, 0x20) & 0x80)) { |
| 607 | if (time_after(jiffies, timeout)) { | 627 | if (time_after(jiffies, timeout)) { |
| 608 | printk("%s: demodulator is not responding, possibly hung, aborting.\n", __FUNCTION__); | 628 | err("%s: demodulator is not responding," \ |
| 629 | "possibly hung, aborting.\n", __func__); | ||
| 609 | return -EREMOTEIO; | 630 | return -EREMOTEIO; |
| 610 | } | 631 | } |
| 611 | msleep(10); | 632 | msleep(10); |
| @@ -626,7 +647,7 @@ static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
| 626 | dprintk("frequency=%i\n", p->frequency); | 647 | dprintk("frequency=%i\n", p->frequency); |
| 627 | 648 | ||
| 628 | if (cx24123_pll_calculate(fe, p) != 0) { | 649 | if (cx24123_pll_calculate(fe, p) != 0) { |
| 629 | printk("%s: cx24123_pll_calcutate failed\n",__FUNCTION__); | 650 | err("%s: cx24123_pll_calcutate failed\n", __func__); |
| 630 | return -EINVAL; | 651 | return -EINVAL; |
| 631 | } | 652 | } |
| 632 | 653 | ||
| @@ -643,18 +664,38 @@ static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_paramet | |||
| 643 | cx24123_writereg(state, 0x27, state->FILTune >> 2); | 664 | cx24123_writereg(state, 0x27, state->FILTune >> 2); |
| 644 | cx24123_writereg(state, 0x28, val | (state->FILTune & 0x3)); | 665 | cx24123_writereg(state, 0x28, val | (state->FILTune & 0x3)); |
| 645 | 666 | ||
| 646 | dprintk("%s: pll tune VCA=%d, band=%d, pll=%d\n",__FUNCTION__,state->VCAarg, | 667 | dprintk("pll tune VCA=%d, band=%d, pll=%d\n", state->VCAarg, |
| 647 | state->bandselectarg,state->pllarg); | 668 | state->bandselectarg, state->pllarg); |
| 648 | 669 | ||
| 649 | return 0; | 670 | return 0; |
| 650 | } | 671 | } |
| 651 | 672 | ||
| 673 | |||
| 674 | /* | ||
| 675 | * 0x23: | ||
| 676 | * [7:7] = BTI enabled | ||
| 677 | * [6:6] = I2C repeater enabled | ||
| 678 | * [5:5] = I2C repeater start | ||
| 679 | * [0:0] = BTI start | ||
| 680 | */ | ||
| 681 | |||
| 682 | /* mode == 1 -> i2c-repeater, 0 -> bti */ | ||
| 683 | static int cx24123_repeater_mode(struct cx24123_state *state, u8 mode, u8 start) | ||
| 684 | { | ||
| 685 | u8 r = cx24123_readreg(state, 0x23) & 0x1e; | ||
| 686 | if (mode) | ||
| 687 | r |= (1 << 6) | (start << 5); | ||
| 688 | else | ||
| 689 | r |= (1 << 7) | (start); | ||
| 690 | return cx24123_writereg(state, 0x23, r); | ||
| 691 | } | ||
| 692 | |||
| 652 | static int cx24123_initfe(struct dvb_frontend* fe) | 693 | static int cx24123_initfe(struct dvb_frontend* fe) |
| 653 | { | 694 | { |
| 654 | struct cx24123_state *state = fe->demodulator_priv; | 695 | struct cx24123_state *state = fe->demodulator_priv; |
| 655 | int i; | 696 | int i; |
| 656 | 697 | ||
| 657 | dprintk("%s: init frontend\n",__FUNCTION__); | 698 | dprintk("init frontend\n"); |
| 658 | 699 | ||
| 659 | /* Configure the demod to a good set of defaults */ | 700 | /* Configure the demod to a good set of defaults */ |
| 660 | for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++) | 701 | for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++) |
| @@ -664,6 +705,9 @@ static int cx24123_initfe(struct dvb_frontend* fe) | |||
| 664 | if(state->config->lnb_polarity) | 705 | if(state->config->lnb_polarity) |
| 665 | cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02); | 706 | cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02); |
| 666 | 707 | ||
| 708 | if (state->config->dont_use_pll) | ||
| 709 | cx24123_repeater_mode(state, 1, 0); | ||
| 710 | |||
| 667 | return 0; | 711 | return 0; |
| 668 | } | 712 | } |
| 669 | 713 | ||
| @@ -676,10 +720,10 @@ static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage | |||
| 676 | 720 | ||
| 677 | switch (voltage) { | 721 | switch (voltage) { |
| 678 | case SEC_VOLTAGE_13: | 722 | case SEC_VOLTAGE_13: |
| 679 | dprintk("%s: setting voltage 13V\n", __FUNCTION__); | 723 | dprintk("setting voltage 13V\n"); |
| 680 | return cx24123_writereg(state, 0x29, val & 0x7f); | 724 | return cx24123_writereg(state, 0x29, val & 0x7f); |
| 681 | case SEC_VOLTAGE_18: | 725 | case SEC_VOLTAGE_18: |
| 682 | dprintk("%s: setting voltage 18V\n", __FUNCTION__); | 726 | dprintk("setting voltage 18V\n"); |
| 683 | return cx24123_writereg(state, 0x29, val | 0x80); | 727 | return cx24123_writereg(state, 0x29, val | 0x80); |
| 684 | case SEC_VOLTAGE_OFF: | 728 | case SEC_VOLTAGE_OFF: |
| 685 | /* already handled in cx88-dvb */ | 729 | /* already handled in cx88-dvb */ |
| @@ -697,7 +741,8 @@ static void cx24123_wait_for_diseqc(struct cx24123_state *state) | |||
| 697 | unsigned long timeout = jiffies + msecs_to_jiffies(200); | 741 | unsigned long timeout = jiffies + msecs_to_jiffies(200); |
| 698 | while (!(cx24123_readreg(state, 0x29) & 0x40)) { | 742 | while (!(cx24123_readreg(state, 0x29) & 0x40)) { |
| 699 | if(time_after(jiffies, timeout)) { | 743 | if(time_after(jiffies, timeout)) { |
| 700 | printk("%s: diseqc queue not ready, command may be lost.\n", __FUNCTION__); | 744 | err("%s: diseqc queue not ready, " \ |
| 745 | "command may be lost.\n", __func__); | ||
| 701 | break; | 746 | break; |
| 702 | } | 747 | } |
| 703 | msleep(10); | 748 | msleep(10); |
| @@ -709,7 +754,7 @@ static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma | |||
| 709 | struct cx24123_state *state = fe->demodulator_priv; | 754 | struct cx24123_state *state = fe->demodulator_priv; |
| 710 | int i, val, tone; | 755 | int i, val, tone; |
| 711 | 756 | ||
| 712 | dprintk("%s:\n",__FUNCTION__); | 757 | dprintk("\n"); |
| 713 | 758 | ||
| 714 | /* stop continuous tone if enabled */ | 759 | /* stop continuous tone if enabled */ |
| 715 | tone = cx24123_readreg(state, 0x29); | 760 | tone = cx24123_readreg(state, 0x29); |
| @@ -744,7 +789,7 @@ static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t | |||
| 744 | struct cx24123_state *state = fe->demodulator_priv; | 789 | struct cx24123_state *state = fe->demodulator_priv; |
| 745 | int val, tone; | 790 | int val, tone; |
| 746 | 791 | ||
| 747 | dprintk("%s:\n", __FUNCTION__); | 792 | dprintk("\n"); |
| 748 | 793 | ||
| 749 | /* stop continuous tone if enabled */ | 794 | /* stop continuous tone if enabled */ |
| 750 | tone = cx24123_readreg(state, 0x29); | 795 | tone = cx24123_readreg(state, 0x29); |
| @@ -778,13 +823,21 @@ static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t | |||
| 778 | static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) | 823 | static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) |
| 779 | { | 824 | { |
| 780 | struct cx24123_state *state = fe->demodulator_priv; | 825 | struct cx24123_state *state = fe->demodulator_priv; |
| 781 | |||
| 782 | int sync = cx24123_readreg(state, 0x14); | 826 | int sync = cx24123_readreg(state, 0x14); |
| 783 | int lock = cx24123_readreg(state, 0x20); | ||
| 784 | 827 | ||
| 785 | *status = 0; | 828 | *status = 0; |
| 786 | if (lock & 0x01) | 829 | if (state->config->dont_use_pll) { |
| 787 | *status |= FE_HAS_SIGNAL; | 830 | u32 tun_status = 0; |
| 831 | if (fe->ops.tuner_ops.get_status) | ||
| 832 | fe->ops.tuner_ops.get_status(fe, &tun_status); | ||
| 833 | if (tun_status & TUNER_STATUS_LOCKED) | ||
| 834 | *status |= FE_HAS_SIGNAL; | ||
| 835 | } else { | ||
| 836 | int lock = cx24123_readreg(state, 0x20); | ||
| 837 | if (lock & 0x01) | ||
| 838 | *status |= FE_HAS_SIGNAL; | ||
| 839 | } | ||
| 840 | |||
| 788 | if (sync & 0x02) | 841 | if (sync & 0x02) |
| 789 | *status |= FE_HAS_CARRIER; /* Phase locked */ | 842 | *status |= FE_HAS_CARRIER; /* Phase locked */ |
| 790 | if (sync & 0x04) | 843 | if (sync & 0x04) |
| @@ -803,7 +856,7 @@ static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 803 | * Configured to return the measurement of errors in blocks, because no UCBLOCKS value | 856 | * Configured to return the measurement of errors in blocks, because no UCBLOCKS value |
| 804 | * is available, so this value doubles up to satisfy both measurements | 857 | * is available, so this value doubles up to satisfy both measurements |
| 805 | */ | 858 | */ |
| 806 | static int cx24123_read_ber(struct dvb_frontend* fe, u32* ber) | 859 | static int cx24123_read_ber(struct dvb_frontend *fe, u32 *ber) |
| 807 | { | 860 | { |
| 808 | struct cx24123_state *state = fe->demodulator_priv; | 861 | struct cx24123_state *state = fe->demodulator_priv; |
| 809 | 862 | ||
| @@ -813,23 +866,24 @@ static int cx24123_read_ber(struct dvb_frontend* fe, u32* ber) | |||
| 813 | (cx24123_readreg(state, 0x1d) << 8 | | 866 | (cx24123_readreg(state, 0x1d) << 8 | |
| 814 | cx24123_readreg(state, 0x1e)); | 867 | cx24123_readreg(state, 0x1e)); |
| 815 | 868 | ||
| 816 | dprintk("%s: BER = %d\n",__FUNCTION__,*ber); | 869 | dprintk("BER = %d\n", *ber); |
| 817 | 870 | ||
| 818 | return 0; | 871 | return 0; |
| 819 | } | 872 | } |
| 820 | 873 | ||
| 821 | static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) | 874 | static int cx24123_read_signal_strength(struct dvb_frontend *fe, |
| 875 | u16 *signal_strength) | ||
| 822 | { | 876 | { |
| 823 | struct cx24123_state *state = fe->demodulator_priv; | 877 | struct cx24123_state *state = fe->demodulator_priv; |
| 824 | 878 | ||
| 825 | *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ | 879 | *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ |
| 826 | 880 | ||
| 827 | dprintk("%s: Signal strength = %d\n",__FUNCTION__,*signal_strength); | 881 | dprintk("Signal strength = %d\n", *signal_strength); |
| 828 | 882 | ||
| 829 | return 0; | 883 | return 0; |
| 830 | } | 884 | } |
| 831 | 885 | ||
| 832 | static int cx24123_read_snr(struct dvb_frontend* fe, u16* snr) | 886 | static int cx24123_read_snr(struct dvb_frontend *fe, u16 *snr) |
| 833 | { | 887 | { |
| 834 | struct cx24123_state *state = fe->demodulator_priv; | 888 | struct cx24123_state *state = fe->demodulator_priv; |
| 835 | 889 | ||
| @@ -838,16 +892,17 @@ static int cx24123_read_snr(struct dvb_frontend* fe, u16* snr) | |||
| 838 | *snr = 65535 - (((u16)cx24123_readreg(state, 0x18) << 8) | | 892 | *snr = 65535 - (((u16)cx24123_readreg(state, 0x18) << 8) | |
| 839 | (u16)cx24123_readreg(state, 0x19)); | 893 | (u16)cx24123_readreg(state, 0x19)); |
| 840 | 894 | ||
| 841 | dprintk("%s: read S/N index = %d\n",__FUNCTION__,*snr); | 895 | dprintk("read S/N index = %d\n", *snr); |
| 842 | 896 | ||
| 843 | return 0; | 897 | return 0; |
| 844 | } | 898 | } |
| 845 | 899 | ||
| 846 | static int cx24123_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 900 | static int cx24123_set_frontend(struct dvb_frontend *fe, |
| 901 | struct dvb_frontend_parameters *p) | ||
| 847 | { | 902 | { |
| 848 | struct cx24123_state *state = fe->demodulator_priv; | 903 | struct cx24123_state *state = fe->demodulator_priv; |
| 849 | 904 | ||
| 850 | dprintk("%s: set_frontend\n",__FUNCTION__); | 905 | dprintk("\n"); |
| 851 | 906 | ||
| 852 | if (state->config->set_ts_params) | 907 | if (state->config->set_ts_params) |
| 853 | state->config->set_ts_params(fe, 0); | 908 | state->config->set_ts_params(fe, 0); |
| @@ -858,13 +913,22 @@ static int cx24123_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 858 | cx24123_set_inversion(state, p->inversion); | 913 | cx24123_set_inversion(state, p->inversion); |
| 859 | cx24123_set_fec(state, p->u.qpsk.fec_inner); | 914 | cx24123_set_fec(state, p->u.qpsk.fec_inner); |
| 860 | cx24123_set_symbolrate(state, p->u.qpsk.symbol_rate); | 915 | cx24123_set_symbolrate(state, p->u.qpsk.symbol_rate); |
| 861 | cx24123_pll_tune(fe, p); | 916 | |
| 917 | if (!state->config->dont_use_pll) | ||
| 918 | cx24123_pll_tune(fe, p); | ||
| 919 | else if (fe->ops.tuner_ops.set_params) | ||
| 920 | fe->ops.tuner_ops.set_params(fe, p); | ||
| 921 | else | ||
| 922 | err("it seems I don't have a tuner..."); | ||
| 862 | 923 | ||
| 863 | /* Enable automatic aquisition and reset cycle */ | 924 | /* Enable automatic aquisition and reset cycle */ |
| 864 | cx24123_writereg(state, 0x03, (cx24123_readreg(state, 0x03) | 0x07)); | 925 | cx24123_writereg(state, 0x03, (cx24123_readreg(state, 0x03) | 0x07)); |
| 865 | cx24123_writereg(state, 0x00, 0x10); | 926 | cx24123_writereg(state, 0x00, 0x10); |
| 866 | cx24123_writereg(state, 0x00, 0); | 927 | cx24123_writereg(state, 0x00, 0); |
| 867 | 928 | ||
| 929 | if (state->config->agc_callback) | ||
| 930 | state->config->agc_callback(fe); | ||
| 931 | |||
| 868 | return 0; | 932 | return 0; |
| 869 | } | 933 | } |
| 870 | 934 | ||
| @@ -872,14 +936,14 @@ static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 872 | { | 936 | { |
| 873 | struct cx24123_state *state = fe->demodulator_priv; | 937 | struct cx24123_state *state = fe->demodulator_priv; |
| 874 | 938 | ||
| 875 | dprintk("%s: get_frontend\n",__FUNCTION__); | 939 | dprintk("\n"); |
| 876 | 940 | ||
| 877 | if (cx24123_get_inversion(state, &p->inversion) != 0) { | 941 | if (cx24123_get_inversion(state, &p->inversion) != 0) { |
| 878 | printk("%s: Failed to get inversion status\n",__FUNCTION__); | 942 | err("%s: Failed to get inversion status\n", __func__); |
| 879 | return -EREMOTEIO; | 943 | return -EREMOTEIO; |
| 880 | } | 944 | } |
| 881 | if (cx24123_get_fec(state, &p->u.qpsk.fec_inner) != 0) { | 945 | if (cx24123_get_fec(state, &p->u.qpsk.fec_inner) != 0) { |
| 882 | printk("%s: Failed to get fec status\n",__FUNCTION__); | 946 | err("%s: Failed to get fec status\n", __func__); |
| 883 | return -EREMOTEIO; | 947 | return -EREMOTEIO; |
| 884 | } | 948 | } |
| 885 | p->frequency = state->currentfreq; | 949 | p->frequency = state->currentfreq; |
| @@ -900,13 +964,13 @@ static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
| 900 | 964 | ||
| 901 | switch (tone) { | 965 | switch (tone) { |
| 902 | case SEC_TONE_ON: | 966 | case SEC_TONE_ON: |
| 903 | dprintk("%s: setting tone on\n", __FUNCTION__); | 967 | dprintk("setting tone on\n"); |
| 904 | return cx24123_writereg(state, 0x29, val | 0x10); | 968 | return cx24123_writereg(state, 0x29, val | 0x10); |
| 905 | case SEC_TONE_OFF: | 969 | case SEC_TONE_OFF: |
| 906 | dprintk("%s: setting tone off\n",__FUNCTION__); | 970 | dprintk("setting tone off\n"); |
| 907 | return cx24123_writereg(state, 0x29, val & 0xef); | 971 | return cx24123_writereg(state, 0x29, val & 0xef); |
| 908 | default: | 972 | default: |
| 909 | printk("%s: CASE reached default with tone=%d\n", __FUNCTION__, tone); | 973 | err("CASE reached default with tone=%d\n", tone); |
| 910 | return -EINVAL; | 974 | return -EINVAL; |
| 911 | } | 975 | } |
| 912 | 976 | ||
| @@ -939,47 +1003,86 @@ static int cx24123_get_algo(struct dvb_frontend *fe) | |||
| 939 | static void cx24123_release(struct dvb_frontend* fe) | 1003 | static void cx24123_release(struct dvb_frontend* fe) |
| 940 | { | 1004 | { |
| 941 | struct cx24123_state* state = fe->demodulator_priv; | 1005 | struct cx24123_state* state = fe->demodulator_priv; |
| 942 | dprintk("%s\n",__FUNCTION__); | 1006 | dprintk("\n"); |
| 1007 | i2c_del_adapter(&state->tuner_i2c_adapter); | ||
| 943 | kfree(state); | 1008 | kfree(state); |
| 944 | } | 1009 | } |
| 945 | 1010 | ||
| 1011 | static int cx24123_tuner_i2c_tuner_xfer(struct i2c_adapter *i2c_adap, | ||
| 1012 | struct i2c_msg msg[], int num) | ||
| 1013 | { | ||
| 1014 | struct cx24123_state *state = i2c_get_adapdata(i2c_adap); | ||
| 1015 | /* this repeater closes after the first stop */ | ||
| 1016 | cx24123_repeater_mode(state, 1, 1); | ||
| 1017 | return i2c_transfer(state->i2c, msg, num); | ||
| 1018 | } | ||
| 1019 | |||
| 1020 | static u32 cx24123_tuner_i2c_func(struct i2c_adapter *adapter) | ||
| 1021 | { | ||
| 1022 | return I2C_FUNC_I2C; | ||
| 1023 | } | ||
| 1024 | |||
| 1025 | static struct i2c_algorithm cx24123_tuner_i2c_algo = { | ||
| 1026 | .master_xfer = cx24123_tuner_i2c_tuner_xfer, | ||
| 1027 | .functionality = cx24123_tuner_i2c_func, | ||
| 1028 | }; | ||
| 1029 | |||
| 1030 | struct i2c_adapter * | ||
| 1031 | cx24123_get_tuner_i2c_adapter(struct dvb_frontend *fe) | ||
| 1032 | { | ||
| 1033 | struct cx24123_state *state = fe->demodulator_priv; | ||
| 1034 | return &state->tuner_i2c_adapter; | ||
| 1035 | } | ||
| 1036 | EXPORT_SYMBOL(cx24123_get_tuner_i2c_adapter); | ||
| 1037 | |||
| 946 | static struct dvb_frontend_ops cx24123_ops; | 1038 | static struct dvb_frontend_ops cx24123_ops; |
| 947 | 1039 | ||
| 948 | struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, | 1040 | struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, |
| 949 | struct i2c_adapter* i2c) | 1041 | struct i2c_adapter* i2c) |
| 950 | { | 1042 | { |
| 951 | struct cx24123_state* state = NULL; | 1043 | struct cx24123_state *state = |
| 952 | int ret; | 1044 | kzalloc(sizeof(struct cx24123_state), GFP_KERNEL); |
| 953 | |||
| 954 | dprintk("%s\n",__FUNCTION__); | ||
| 955 | 1045 | ||
| 1046 | dprintk("\n"); | ||
| 956 | /* allocate memory for the internal state */ | 1047 | /* allocate memory for the internal state */ |
| 957 | state = kmalloc(sizeof(struct cx24123_state), GFP_KERNEL); | ||
| 958 | if (state == NULL) { | 1048 | if (state == NULL) { |
| 959 | printk("Unable to kmalloc\n"); | 1049 | err("Unable to kmalloc\n"); |
| 960 | goto error; | 1050 | goto error; |
| 961 | } | 1051 | } |
| 962 | 1052 | ||
| 963 | /* setup the state */ | 1053 | /* setup the state */ |
| 964 | state->config = config; | 1054 | state->config = config; |
| 965 | state->i2c = i2c; | 1055 | state->i2c = i2c; |
| 966 | state->VCAarg = 0; | ||
| 967 | state->VGAarg = 0; | ||
| 968 | state->bandselectarg = 0; | ||
| 969 | state->pllarg = 0; | ||
| 970 | state->currentfreq = 0; | ||
| 971 | state->currentsymbolrate = 0; | ||
| 972 | 1056 | ||
| 973 | /* check if the demod is there */ | 1057 | /* check if the demod is there */ |
| 974 | ret = cx24123_readreg(state, 0x00); | 1058 | state->demod_rev = cx24123_readreg(state, 0x00); |
| 975 | if ((ret != 0xd1) && (ret != 0xe1)) { | 1059 | switch (state->demod_rev) { |
| 976 | printk("Version != d1 or e1\n"); | 1060 | case 0xe1: info("detected CX24123C\n"); break; |
| 1061 | case 0xd1: info("detected CX24123\n"); break; | ||
| 1062 | default: | ||
| 1063 | err("wrong demod revision: %x\n", state->demod_rev); | ||
| 977 | goto error; | 1064 | goto error; |
| 978 | } | 1065 | } |
| 979 | 1066 | ||
| 980 | /* create dvb_frontend */ | 1067 | /* create dvb_frontend */ |
| 981 | memcpy(&state->frontend.ops, &cx24123_ops, sizeof(struct dvb_frontend_ops)); | 1068 | memcpy(&state->frontend.ops, &cx24123_ops, sizeof(struct dvb_frontend_ops)); |
| 982 | state->frontend.demodulator_priv = state; | 1069 | state->frontend.demodulator_priv = state; |
| 1070 | |||
| 1071 | /* create tuner i2c adapter */ | ||
| 1072 | if (config->dont_use_pll) | ||
| 1073 | cx24123_repeater_mode(state, 1, 0); | ||
| 1074 | |||
| 1075 | strncpy(state->tuner_i2c_adapter.name, | ||
| 1076 | "CX24123 tuner I2C bus", I2C_NAME_SIZE); | ||
| 1077 | state->tuner_i2c_adapter.class = I2C_CLASS_TV_DIGITAL, | ||
| 1078 | state->tuner_i2c_adapter.algo = &cx24123_tuner_i2c_algo; | ||
| 1079 | state->tuner_i2c_adapter.algo_data = NULL; | ||
| 1080 | i2c_set_adapdata(&state->tuner_i2c_adapter, state); | ||
| 1081 | if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) { | ||
| 1082 | err("tuner i2c bus could not be initialized\n"); | ||
| 1083 | goto error; | ||
| 1084 | } | ||
| 1085 | |||
| 983 | return &state->frontend; | 1086 | return &state->frontend; |
| 984 | 1087 | ||
| 985 | error: | 1088 | error: |
| @@ -1029,7 +1132,8 @@ MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)"); | |||
| 1029 | module_param(force_band, int, 0644); | 1132 | module_param(force_band, int, 0644); |
| 1030 | MODULE_PARM_DESC(force_band, "Force a specific band select (1-9, default:off)."); | 1133 | MODULE_PARM_DESC(force_band, "Force a specific band select (1-9, default:off)."); |
| 1031 | 1134 | ||
| 1032 | MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24123/cx24109 hardware"); | 1135 | MODULE_DESCRIPTION("DVB Frontend module for Conexant " \ |
| 1136 | "CX24123/CX24109/CX24113 hardware"); | ||
| 1033 | MODULE_AUTHOR("Steven Toth"); | 1137 | MODULE_AUTHOR("Steven Toth"); |
| 1034 | MODULE_LICENSE("GPL"); | 1138 | MODULE_LICENSE("GPL"); |
| 1035 | 1139 | ||
diff --git a/drivers/media/dvb/frontends/cx24123.h b/drivers/media/dvb/frontends/cx24123.h index 84f9e4f5c15e..81ebc3d2f19f 100644 --- a/drivers/media/dvb/frontends/cx24123.h +++ b/drivers/media/dvb/frontends/cx24123.h | |||
| @@ -33,16 +33,27 @@ struct cx24123_config | |||
| 33 | 33 | ||
| 34 | /* 0 = LNB voltage normal, 1 = LNB voltage inverted */ | 34 | /* 0 = LNB voltage normal, 1 = LNB voltage inverted */ |
| 35 | int lnb_polarity; | 35 | int lnb_polarity; |
| 36 | |||
| 37 | /* this device has another tuner */ | ||
| 38 | u8 dont_use_pll; | ||
| 39 | void (*agc_callback) (struct dvb_frontend *); | ||
| 36 | }; | 40 | }; |
| 37 | 41 | ||
| 38 | #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) && defined(MODULE)) | 42 | #if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) && defined(MODULE)) |
| 39 | extern struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, | 43 | extern struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, |
| 40 | struct i2c_adapter* i2c); | 44 | struct i2c_adapter *i2c); |
| 45 | extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *); | ||
| 41 | #else | 46 | #else |
| 42 | static inline struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, | 47 | static inline struct dvb_frontend *cx24123_attach( |
| 43 | struct i2c_adapter* i2c) | 48 | const struct cx24123_config *config, struct i2c_adapter *i2c) |
| 49 | { | ||
| 50 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
| 51 | return NULL; | ||
| 52 | } | ||
| 53 | static struct i2c_adapter * | ||
| 54 | cx24123_get_tuner_i2c_adapter(struct dvb_frontend *fe) | ||
| 44 | { | 55 | { |
| 45 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 56 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 46 | return NULL; | 57 | return NULL; |
| 47 | } | 58 | } |
| 48 | #endif // CONFIG_DVB_CX24123 | 59 | #endif // CONFIG_DVB_CX24123 |
diff --git a/drivers/media/dvb/frontends/dib3000.h b/drivers/media/dvb/frontends/dib3000.h index a6d3854a67bc..ba917359fa65 100644 --- a/drivers/media/dvb/frontends/dib3000.h +++ b/drivers/media/dvb/frontends/dib3000.h | |||
| @@ -48,7 +48,7 @@ extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config | |||
| 48 | static inline struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config, | 48 | static inline struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config, |
| 49 | struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops) | 49 | struct i2c_adapter* i2c, struct dib_fe_xfer_ops *xfer_ops) |
| 50 | { | 50 | { |
| 51 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 51 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 52 | return NULL; | 52 | return NULL; |
| 53 | } | 53 | } |
| 54 | #endif // CONFIG_DVB_DIB3000MB | 54 | #endif // CONFIG_DVB_DIB3000MB |
diff --git a/drivers/media/dvb/frontends/dib3000mc.h b/drivers/media/dvb/frontends/dib3000mc.h index 72d4757601d8..4142ed7a47d0 100644 --- a/drivers/media/dvb/frontends/dib3000mc.h +++ b/drivers/media/dvb/frontends/dib3000mc.h | |||
| @@ -44,7 +44,7 @@ extern struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i | |||
| 44 | #else | 44 | #else |
| 45 | static inline struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg) | 45 | static inline struct dvb_frontend * dib3000mc_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib3000mc_config *cfg) |
| 46 | { | 46 | { |
| 47 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 47 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 48 | return NULL; | 48 | return NULL; |
| 49 | } | 49 | } |
| 50 | #endif // CONFIG_DVB_DIB3000MC | 50 | #endif // CONFIG_DVB_DIB3000MC |
diff --git a/drivers/media/dvb/frontends/dib7000p.c b/drivers/media/dvb/frontends/dib7000p.c index 47c23e29753e..1a0142e0d741 100644 --- a/drivers/media/dvb/frontends/dib7000p.c +++ b/drivers/media/dvb/frontends/dib7000p.c | |||
| @@ -1168,7 +1168,7 @@ static int dib7000p_set_frontend(struct dvb_frontend* fe, | |||
| 1168 | ret = dib7000p_tune(fe, fep); | 1168 | ret = dib7000p_tune(fe, fep); |
| 1169 | 1169 | ||
| 1170 | /* make this a config parameter */ | 1170 | /* make this a config parameter */ |
| 1171 | dib7000p_set_output_mode(state, OUTMODE_MPEG2_FIFO); | 1171 | dib7000p_set_output_mode(state, state->cfg.output_mode); |
| 1172 | return ret; | 1172 | return ret; |
| 1173 | } | 1173 | } |
| 1174 | 1174 | ||
| @@ -1330,6 +1330,12 @@ struct dvb_frontend * dib7000p_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, | |||
| 1330 | st->gpio_val = cfg->gpio_val; | 1330 | st->gpio_val = cfg->gpio_val; |
| 1331 | st->gpio_dir = cfg->gpio_dir; | 1331 | st->gpio_dir = cfg->gpio_dir; |
| 1332 | 1332 | ||
| 1333 | /* Ensure the output mode remains at the previous default if it's | ||
| 1334 | * not specifically set by the caller. | ||
| 1335 | */ | ||
| 1336 | if (st->cfg.output_mode != OUTMODE_MPEG2_SERIAL) | ||
| 1337 | st->cfg.output_mode = OUTMODE_MPEG2_FIFO; | ||
| 1338 | |||
| 1333 | demod = &st->demod; | 1339 | demod = &st->demod; |
| 1334 | demod->demodulator_priv = st; | 1340 | demod->demodulator_priv = st; |
| 1335 | memcpy(&st->demod.ops, &dib7000p_ops, sizeof(struct dvb_frontend_ops)); | 1341 | memcpy(&st->demod.ops, &dib7000p_ops, sizeof(struct dvb_frontend_ops)); |
diff --git a/drivers/media/dvb/frontends/dib7000p.h b/drivers/media/dvb/frontends/dib7000p.h index eefcac8b5244..081bd81f3da2 100644 --- a/drivers/media/dvb/frontends/dib7000p.h +++ b/drivers/media/dvb/frontends/dib7000p.h | |||
| @@ -31,6 +31,8 @@ struct dib7000p_config { | |||
| 31 | u8 spur_protect; | 31 | u8 spur_protect; |
| 32 | 32 | ||
| 33 | int (*agc_control) (struct dvb_frontend *, u8 before); | 33 | int (*agc_control) (struct dvb_frontend *, u8 before); |
| 34 | |||
| 35 | u8 output_mode; | ||
| 34 | }; | 36 | }; |
| 35 | 37 | ||
| 36 | #define DEFAULT_DIB7000P_I2C_ADDRESS 18 | 38 | #define DEFAULT_DIB7000P_I2C_ADDRESS 18 |
diff --git a/drivers/media/dvb/frontends/dvb-pll.c b/drivers/media/dvb/frontends/dvb-pll.c index 8c8d7342d0b3..a054894ff481 100644 --- a/drivers/media/dvb/frontends/dvb-pll.c +++ b/drivers/media/dvb/frontends/dvb-pll.c | |||
| @@ -44,14 +44,10 @@ struct dvb_pll_priv { | |||
| 44 | 44 | ||
| 45 | static unsigned int dvb_pll_devcount; | 45 | static unsigned int dvb_pll_devcount; |
| 46 | 46 | ||
| 47 | static int debug = 0; | 47 | static int debug; |
| 48 | module_param(debug, int, 0644); | 48 | module_param(debug, int, 0644); |
| 49 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 49 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 50 | 50 | ||
| 51 | static unsigned int input[DVB_PLL_MAX] = { [ 0 ... (DVB_PLL_MAX-1) ] = 0 }; | ||
| 52 | module_param_array(input, int, NULL, 0644); | ||
| 53 | MODULE_PARM_DESC(input,"specify rf input choice, 0 for autoselect (default)"); | ||
| 54 | |||
| 55 | static unsigned int id[DVB_PLL_MAX] = | 51 | static unsigned int id[DVB_PLL_MAX] = |
| 56 | { [ 0 ... (DVB_PLL_MAX-1) ] = DVB_PLL_UNDEFINED }; | 52 | { [ 0 ... (DVB_PLL_MAX-1) ] = DVB_PLL_UNDEFINED }; |
| 57 | module_param_array(id, int, NULL, 0644); | 53 | module_param_array(id, int, NULL, 0644); |
| @@ -80,23 +76,6 @@ struct dvb_pll_desc { | |||
| 80 | /* ----------------------------------------------------------- */ | 76 | /* ----------------------------------------------------------- */ |
| 81 | /* descriptions */ | 77 | /* descriptions */ |
| 82 | 78 | ||
| 83 | /* Set AGC TOP value to 103 dBuV: | ||
| 84 | 0x80 = Control Byte | ||
| 85 | 0x40 = 250 uA charge pump (irrelevant) | ||
| 86 | 0x18 = Aux Byte to follow | ||
| 87 | 0x06 = 64.5 kHz divider (irrelevant) | ||
| 88 | 0x01 = Disable Vt (aka sleep) | ||
| 89 | |||
| 90 | 0x00 = AGC Time constant 2s Iagc = 300 nA (vs 0x80 = 9 nA) | ||
| 91 | 0x50 = AGC Take over point = 103 dBuV */ | ||
| 92 | static u8 tua603x_agc103[] = { 2, 0x80|0x40|0x18|0x06|0x01, 0x00|0x50 }; | ||
| 93 | |||
| 94 | /* 0x04 = 166.67 kHz divider | ||
| 95 | |||
| 96 | 0x80 = AGC Time constant 50ms Iagc = 9 uA | ||
| 97 | 0x20 = AGC Take over point = 112 dBuV */ | ||
| 98 | static u8 tua603x_agc112[] = { 2, 0x80|0x40|0x18|0x04|0x01, 0x80|0x20 }; | ||
| 99 | |||
| 100 | static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = { | 79 | static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = { |
| 101 | .name = "Thomson dtt7579", | 80 | .name = "Thomson dtt7579", |
| 102 | .min = 177000000, | 81 | .min = 177000000, |
| @@ -112,19 +91,6 @@ static struct dvb_pll_desc dvb_pll_thomson_dtt7579 = { | |||
| 112 | }, | 91 | }, |
| 113 | }; | 92 | }; |
| 114 | 93 | ||
| 115 | static struct dvb_pll_desc dvb_pll_thomson_dtt7610 = { | ||
| 116 | .name = "Thomson dtt7610", | ||
| 117 | .min = 44000000, | ||
| 118 | .max = 958000000, | ||
| 119 | .iffreq= 44000000, | ||
| 120 | .count = 3, | ||
| 121 | .entries = { | ||
| 122 | { 157250000, 62500, 0x8e, 0x39 }, | ||
| 123 | { 454000000, 62500, 0x8e, 0x3a }, | ||
| 124 | { 999999999, 62500, 0x8e, 0x3c }, | ||
| 125 | }, | ||
| 126 | }; | ||
| 127 | |||
| 128 | static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf, | 94 | static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf, |
| 129 | const struct dvb_frontend_parameters *params) | 95 | const struct dvb_frontend_parameters *params) |
| 130 | { | 96 | { |
| @@ -165,34 +131,6 @@ static struct dvb_pll_desc dvb_pll_lg_z201 = { | |||
| 165 | }, | 131 | }, |
| 166 | }; | 132 | }; |
| 167 | 133 | ||
| 168 | static struct dvb_pll_desc dvb_pll_microtune_4042 = { | ||
| 169 | .name = "Microtune 4042 FI5", | ||
| 170 | .min = 57000000, | ||
| 171 | .max = 858000000, | ||
| 172 | .iffreq= 44000000, | ||
| 173 | .count = 3, | ||
| 174 | .entries = { | ||
| 175 | { 162000000, 62500, 0x8e, 0xa1 }, | ||
| 176 | { 457000000, 62500, 0x8e, 0x91 }, | ||
| 177 | { 999999999, 62500, 0x8e, 0x31 }, | ||
| 178 | }, | ||
| 179 | }; | ||
| 180 | |||
| 181 | static struct dvb_pll_desc dvb_pll_thomson_dtt761x = { | ||
| 182 | /* DTT 7611 7611A 7612 7613 7613A 7614 7615 7615A */ | ||
| 183 | .name = "Thomson dtt761x", | ||
| 184 | .min = 57000000, | ||
| 185 | .max = 863000000, | ||
| 186 | .iffreq= 44000000, | ||
| 187 | .count = 3, | ||
| 188 | .initdata = tua603x_agc103, | ||
| 189 | .entries = { | ||
| 190 | { 147000000, 62500, 0x8e, 0x39 }, | ||
| 191 | { 417000000, 62500, 0x8e, 0x3a }, | ||
| 192 | { 999999999, 62500, 0x8e, 0x3c }, | ||
| 193 | }, | ||
| 194 | }; | ||
| 195 | |||
| 196 | static struct dvb_pll_desc dvb_pll_unknown_1 = { | 134 | static struct dvb_pll_desc dvb_pll_unknown_1 = { |
| 197 | .name = "unknown 1", /* used by dntv live dvb-t */ | 135 | .name = "unknown 1", /* used by dntv live dvb-t */ |
| 198 | .min = 174000000, | 136 | .min = 174000000, |
| @@ -301,54 +239,6 @@ static struct dvb_pll_desc dvb_pll_tua6034 = { | |||
| 301 | }, | 239 | }, |
| 302 | }; | 240 | }; |
| 303 | 241 | ||
| 304 | /* Infineon TUA6034 | ||
| 305 | * used in LG TDVS-H061F, LG TDVS-H062F and LG TDVS-H064F | ||
| 306 | */ | ||
| 307 | static struct dvb_pll_desc dvb_pll_lg_tdvs_h06xf = { | ||
| 308 | .name = "LG TDVS-H06xF", | ||
| 309 | .min = 54000000, | ||
| 310 | .max = 863000000, | ||
| 311 | .iffreq= 44000000, | ||
| 312 | .initdata = tua603x_agc103, | ||
| 313 | .count = 3, | ||
| 314 | .entries = { | ||
| 315 | { 165000000, 62500, 0xce, 0x01 }, | ||
| 316 | { 450000000, 62500, 0xce, 0x02 }, | ||
| 317 | { 999999999, 62500, 0xce, 0x04 }, | ||
| 318 | }, | ||
| 319 | }; | ||
| 320 | |||
| 321 | /* Philips FMD1216ME | ||
| 322 | * used in Medion Hybrid PCMCIA card and USB Box | ||
| 323 | */ | ||
| 324 | static void fmd1216me_bw(struct dvb_frontend *fe, u8 *buf, | ||
| 325 | const struct dvb_frontend_parameters *params) | ||
| 326 | { | ||
| 327 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ && | ||
| 328 | params->frequency >= 158870000) | ||
| 329 | buf[3] |= 0x08; | ||
| 330 | } | ||
| 331 | |||
| 332 | static struct dvb_pll_desc dvb_pll_fmd1216me = { | ||
| 333 | .name = "Philips FMD1216ME", | ||
| 334 | .min = 50870000, | ||
| 335 | .max = 858000000, | ||
| 336 | .iffreq= 36125000, | ||
| 337 | .set = fmd1216me_bw, | ||
| 338 | .initdata = tua603x_agc112, | ||
| 339 | .sleepdata = (u8[]){ 4, 0x9c, 0x60, 0x85, 0x54 }, | ||
| 340 | .count = 7, | ||
| 341 | .entries = { | ||
| 342 | { 143870000, 166667, 0xbc, 0x41 }, | ||
| 343 | { 158870000, 166667, 0xf4, 0x41 }, | ||
| 344 | { 329870000, 166667, 0xbc, 0x42 }, | ||
| 345 | { 441870000, 166667, 0xf4, 0x42 }, | ||
| 346 | { 625870000, 166667, 0xbc, 0x44 }, | ||
| 347 | { 803870000, 166667, 0xf4, 0x44 }, | ||
| 348 | { 999999999, 166667, 0xfc, 0x44 }, | ||
| 349 | } | ||
| 350 | }; | ||
| 351 | |||
| 352 | /* ALPS TDED4 | 242 | /* ALPS TDED4 |
| 353 | * used in Nebula-Cards and USB boxes | 243 | * used in Nebula-Cards and USB boxes |
| 354 | */ | 244 | */ |
| @@ -391,55 +281,6 @@ static struct dvb_pll_desc dvb_pll_tdhu2 = { | |||
| 391 | } | 281 | } |
| 392 | }; | 282 | }; |
| 393 | 283 | ||
| 394 | /* Philips TUV1236D | ||
| 395 | * used in ATI HDTV Wonder | ||
| 396 | */ | ||
| 397 | static void tuv1236d_rf(struct dvb_frontend *fe, u8 *buf, | ||
| 398 | const struct dvb_frontend_parameters *params) | ||
| 399 | { | ||
| 400 | struct dvb_pll_priv *priv = fe->tuner_priv; | ||
| 401 | unsigned int new_rf = input[priv->nr]; | ||
| 402 | |||
| 403 | if ((new_rf == 0) || (new_rf > 2)) { | ||
| 404 | switch (params->u.vsb.modulation) { | ||
| 405 | case QAM_64: | ||
| 406 | case QAM_256: | ||
| 407 | new_rf = 1; | ||
| 408 | break; | ||
| 409 | case VSB_8: | ||
| 410 | default: | ||
| 411 | new_rf = 2; | ||
| 412 | } | ||
| 413 | } | ||
| 414 | |||
| 415 | switch (new_rf) { | ||
| 416 | case 1: | ||
| 417 | buf[3] |= 0x08; | ||
| 418 | break; | ||
| 419 | case 2: | ||
| 420 | buf[3] &= ~0x08; | ||
| 421 | break; | ||
| 422 | default: | ||
| 423 | printk(KERN_WARNING | ||
| 424 | "%s: unhandled rf input selection: %d", | ||
| 425 | __FUNCTION__, new_rf); | ||
| 426 | } | ||
| 427 | } | ||
| 428 | |||
| 429 | static struct dvb_pll_desc dvb_pll_tuv1236d = { | ||
| 430 | .name = "Philips TUV1236D", | ||
| 431 | .min = 54000000, | ||
| 432 | .max = 864000000, | ||
| 433 | .iffreq= 44000000, | ||
| 434 | .set = tuv1236d_rf, | ||
| 435 | .count = 3, | ||
| 436 | .entries = { | ||
| 437 | { 157250000, 62500, 0xc6, 0x41 }, | ||
| 438 | { 454000000, 62500, 0xc6, 0x42 }, | ||
| 439 | { 999999999, 62500, 0xc6, 0x44 }, | ||
| 440 | }, | ||
| 441 | }; | ||
| 442 | |||
| 443 | /* Samsung TBMV30111IN / TBMV30712IN1 | 284 | /* Samsung TBMV30111IN / TBMV30712IN1 |
| 444 | * used in Air2PC ATSC - 2nd generation (nxt2002) | 285 | * used in Air2PC ATSC - 2nd generation (nxt2002) |
| 445 | */ | 286 | */ |
| @@ -476,64 +317,6 @@ static struct dvb_pll_desc dvb_pll_philips_sd1878_tda8261 = { | |||
| 476 | }, | 317 | }, |
| 477 | }; | 318 | }; |
| 478 | 319 | ||
| 479 | /* | ||
| 480 | * Philips TD1316 Tuner. | ||
| 481 | */ | ||
| 482 | static void td1316_bw(struct dvb_frontend *fe, u8 *buf, | ||
| 483 | const struct dvb_frontend_parameters *params) | ||
| 484 | { | ||
| 485 | u8 band; | ||
| 486 | |||
| 487 | /* determine band */ | ||
| 488 | if (params->frequency < 161000000) | ||
| 489 | band = 1; | ||
| 490 | else if (params->frequency < 444000000) | ||
| 491 | band = 2; | ||
| 492 | else | ||
| 493 | band = 4; | ||
| 494 | |||
| 495 | buf[3] |= band; | ||
| 496 | |||
| 497 | /* setup PLL filter */ | ||
| 498 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) | ||
| 499 | buf[3] |= 1 << 3; | ||
| 500 | } | ||
| 501 | |||
| 502 | static struct dvb_pll_desc dvb_pll_philips_td1316 = { | ||
| 503 | .name = "Philips TD1316", | ||
| 504 | .min = 87000000, | ||
| 505 | .max = 895000000, | ||
| 506 | .iffreq= 36166667, | ||
| 507 | .set = td1316_bw, | ||
| 508 | .count = 9, | ||
| 509 | .entries = { | ||
| 510 | { 93834000, 166667, 0xca, 0x60}, | ||
| 511 | { 123834000, 166667, 0xca, 0xa0}, | ||
| 512 | { 163834000, 166667, 0xca, 0xc0}, | ||
| 513 | { 253834000, 166667, 0xca, 0x60}, | ||
| 514 | { 383834000, 166667, 0xca, 0xa0}, | ||
| 515 | { 443834000, 166667, 0xca, 0xc0}, | ||
| 516 | { 583834000, 166667, 0xca, 0x60}, | ||
| 517 | { 793834000, 166667, 0xca, 0xa0}, | ||
| 518 | { 858834000, 166667, 0xca, 0xe0}, | ||
| 519 | }, | ||
| 520 | }; | ||
| 521 | |||
| 522 | /* FE6600 used on DViCO Hybrid */ | ||
| 523 | static struct dvb_pll_desc dvb_pll_thomson_fe6600 = { | ||
| 524 | .name = "Thomson FE6600", | ||
| 525 | .min = 44250000, | ||
| 526 | .max = 858000000, | ||
| 527 | .iffreq= 36125000, | ||
| 528 | .count = 4, | ||
| 529 | .entries = { | ||
| 530 | { 250000000, 166667, 0xb4, 0x12 }, | ||
| 531 | { 455000000, 166667, 0xfe, 0x11 }, | ||
| 532 | { 775500000, 166667, 0xbc, 0x18 }, | ||
| 533 | { 999999999, 166667, 0xf4, 0x18 }, | ||
| 534 | } | ||
| 535 | }; | ||
| 536 | |||
| 537 | static void opera1_bw(struct dvb_frontend *fe, u8 *buf, | 320 | static void opera1_bw(struct dvb_frontend *fe, u8 *buf, |
| 538 | const struct dvb_frontend_parameters *params) | 321 | const struct dvb_frontend_parameters *params) |
| 539 | { | 322 | { |
| @@ -560,50 +343,23 @@ static struct dvb_pll_desc dvb_pll_opera1 = { | |||
| 560 | } | 343 | } |
| 561 | }; | 344 | }; |
| 562 | 345 | ||
| 563 | /* Philips FCV1236D | ||
| 564 | */ | ||
| 565 | static struct dvb_pll_desc dvb_pll_fcv1236d = { | ||
| 566 | /* Bit_0: RF Input select | ||
| 567 | * Bit_1: 0=digital, 1=analog | ||
| 568 | */ | ||
| 569 | .name = "Philips FCV1236D", | ||
| 570 | .min = 53000000, | ||
| 571 | .max = 803000000, | ||
| 572 | .iffreq= 44000000, | ||
| 573 | .count = 3, | ||
| 574 | .entries = { | ||
| 575 | { 159000000, 62500, 0x8e, 0xa0 }, | ||
| 576 | { 453000000, 62500, 0x8e, 0x90 }, | ||
| 577 | { 999999999, 62500, 0x8e, 0x30 }, | ||
| 578 | }, | ||
| 579 | }; | ||
| 580 | |||
| 581 | /* ----------------------------------------------------------- */ | 346 | /* ----------------------------------------------------------- */ |
| 582 | 347 | ||
| 583 | static struct dvb_pll_desc *pll_list[] = { | 348 | static struct dvb_pll_desc *pll_list[] = { |
| 584 | [DVB_PLL_UNDEFINED] = NULL, | 349 | [DVB_PLL_UNDEFINED] = NULL, |
| 585 | [DVB_PLL_THOMSON_DTT7579] = &dvb_pll_thomson_dtt7579, | 350 | [DVB_PLL_THOMSON_DTT7579] = &dvb_pll_thomson_dtt7579, |
| 586 | [DVB_PLL_THOMSON_DTT759X] = &dvb_pll_thomson_dtt759x, | 351 | [DVB_PLL_THOMSON_DTT759X] = &dvb_pll_thomson_dtt759x, |
| 587 | [DVB_PLL_THOMSON_DTT7610] = &dvb_pll_thomson_dtt7610, | ||
| 588 | [DVB_PLL_LG_Z201] = &dvb_pll_lg_z201, | 352 | [DVB_PLL_LG_Z201] = &dvb_pll_lg_z201, |
| 589 | [DVB_PLL_MICROTUNE_4042] = &dvb_pll_microtune_4042, | ||
| 590 | [DVB_PLL_THOMSON_DTT761X] = &dvb_pll_thomson_dtt761x, | ||
| 591 | [DVB_PLL_UNKNOWN_1] = &dvb_pll_unknown_1, | 353 | [DVB_PLL_UNKNOWN_1] = &dvb_pll_unknown_1, |
| 592 | [DVB_PLL_TUA6010XS] = &dvb_pll_tua6010xs, | 354 | [DVB_PLL_TUA6010XS] = &dvb_pll_tua6010xs, |
| 593 | [DVB_PLL_ENV57H1XD5] = &dvb_pll_env57h1xd5, | 355 | [DVB_PLL_ENV57H1XD5] = &dvb_pll_env57h1xd5, |
| 594 | [DVB_PLL_TUA6034] = &dvb_pll_tua6034, | 356 | [DVB_PLL_TUA6034] = &dvb_pll_tua6034, |
| 595 | [DVB_PLL_LG_TDVS_H06XF] = &dvb_pll_lg_tdvs_h06xf, | ||
| 596 | [DVB_PLL_TDA665X] = &dvb_pll_tda665x, | 357 | [DVB_PLL_TDA665X] = &dvb_pll_tda665x, |
| 597 | [DVB_PLL_FMD1216ME] = &dvb_pll_fmd1216me, | ||
| 598 | [DVB_PLL_TDED4] = &dvb_pll_tded4, | 358 | [DVB_PLL_TDED4] = &dvb_pll_tded4, |
| 599 | [DVB_PLL_TUV1236D] = &dvb_pll_tuv1236d, | ||
| 600 | [DVB_PLL_TDHU2] = &dvb_pll_tdhu2, | 359 | [DVB_PLL_TDHU2] = &dvb_pll_tdhu2, |
| 601 | [DVB_PLL_SAMSUNG_TBMV] = &dvb_pll_samsung_tbmv, | 360 | [DVB_PLL_SAMSUNG_TBMV] = &dvb_pll_samsung_tbmv, |
| 602 | [DVB_PLL_PHILIPS_SD1878_TDA8261] = &dvb_pll_philips_sd1878_tda8261, | 361 | [DVB_PLL_PHILIPS_SD1878_TDA8261] = &dvb_pll_philips_sd1878_tda8261, |
| 603 | [DVB_PLL_PHILIPS_TD1316] = &dvb_pll_philips_td1316, | ||
| 604 | [DVB_PLL_THOMSON_FE6600] = &dvb_pll_thomson_fe6600, | ||
| 605 | [DVB_PLL_OPERA1] = &dvb_pll_opera1, | 362 | [DVB_PLL_OPERA1] = &dvb_pll_opera1, |
| 606 | [DVB_PLL_FCV1236D] = &dvb_pll_fcv1236d, | ||
| 607 | }; | 363 | }; |
| 608 | 364 | ||
| 609 | /* ----------------------------------------------------------- */ | 365 | /* ----------------------------------------------------------- */ |
| @@ -849,20 +605,6 @@ struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, int pll_addr, | |||
| 849 | id[priv->nr] == pll_desc_id ? | 605 | id[priv->nr] == pll_desc_id ? |
| 850 | "insmod option" : "autodetected"); | 606 | "insmod option" : "autodetected"); |
| 851 | } | 607 | } |
| 852 | if ((debug) || (input[priv->nr] > 0)) { | ||
| 853 | printk("dvb-pll[%d]", priv->nr); | ||
| 854 | if (i2c != NULL) | ||
| 855 | printk(" %d-%04x", i2c_adapter_id(i2c), pll_addr); | ||
| 856 | printk(": tuner rf input will be "); | ||
| 857 | switch (input[priv->nr]) { | ||
| 858 | case 0: | ||
| 859 | printk("autoselected\n"); | ||
| 860 | break; | ||
| 861 | default: | ||
| 862 | printk("set to input %d (insmod option)\n", | ||
| 863 | input[priv->nr]); | ||
| 864 | } | ||
| 865 | } | ||
| 866 | 608 | ||
| 867 | return fe; | 609 | return fe; |
| 868 | } | 610 | } |
diff --git a/drivers/media/dvb/frontends/dvb-pll.h b/drivers/media/dvb/frontends/dvb-pll.h index e93a8104052b..872ca29e7cf3 100644 --- a/drivers/media/dvb/frontends/dvb-pll.h +++ b/drivers/media/dvb/frontends/dvb-pll.h | |||
| @@ -11,26 +11,17 @@ | |||
| 11 | #define DVB_PLL_UNDEFINED 0 | 11 | #define DVB_PLL_UNDEFINED 0 |
| 12 | #define DVB_PLL_THOMSON_DTT7579 1 | 12 | #define DVB_PLL_THOMSON_DTT7579 1 |
| 13 | #define DVB_PLL_THOMSON_DTT759X 2 | 13 | #define DVB_PLL_THOMSON_DTT759X 2 |
| 14 | #define DVB_PLL_THOMSON_DTT7610 3 | 14 | #define DVB_PLL_LG_Z201 3 |
| 15 | #define DVB_PLL_LG_Z201 4 | 15 | #define DVB_PLL_UNKNOWN_1 4 |
| 16 | #define DVB_PLL_MICROTUNE_4042 5 | 16 | #define DVB_PLL_TUA6010XS 5 |
| 17 | #define DVB_PLL_THOMSON_DTT761X 6 | 17 | #define DVB_PLL_ENV57H1XD5 6 |
| 18 | #define DVB_PLL_UNKNOWN_1 7 | 18 | #define DVB_PLL_TUA6034 7 |
| 19 | #define DVB_PLL_TUA6010XS 8 | 19 | #define DVB_PLL_TDA665X 8 |
| 20 | #define DVB_PLL_ENV57H1XD5 9 | 20 | #define DVB_PLL_TDED4 9 |
| 21 | #define DVB_PLL_TUA6034 10 | 21 | #define DVB_PLL_TDHU2 10 |
| 22 | #define DVB_PLL_LG_TDVS_H06XF 11 | 22 | #define DVB_PLL_SAMSUNG_TBMV 11 |
| 23 | #define DVB_PLL_TDA665X 12 | 23 | #define DVB_PLL_PHILIPS_SD1878_TDA8261 12 |
| 24 | #define DVB_PLL_FMD1216ME 13 | 24 | #define DVB_PLL_OPERA1 13 |
| 25 | #define DVB_PLL_TDED4 14 | ||
| 26 | #define DVB_PLL_TUV1236D 15 | ||
| 27 | #define DVB_PLL_TDHU2 16 | ||
| 28 | #define DVB_PLL_SAMSUNG_TBMV 17 | ||
| 29 | #define DVB_PLL_PHILIPS_SD1878_TDA8261 18 | ||
| 30 | #define DVB_PLL_PHILIPS_TD1316 19 | ||
| 31 | #define DVB_PLL_THOMSON_FE6600 20 | ||
| 32 | #define DVB_PLL_OPERA1 21 | ||
| 33 | #define DVB_PLL_FCV1236D 22 | ||
| 34 | 25 | ||
| 35 | /** | 26 | /** |
| 36 | * Attach a dvb-pll to the supplied frontend structure. | 27 | * Attach a dvb-pll to the supplied frontend structure. |
| @@ -52,7 +43,7 @@ static inline struct dvb_frontend *dvb_pll_attach(struct dvb_frontend *fe, | |||
| 52 | struct i2c_adapter *i2c, | 43 | struct i2c_adapter *i2c, |
| 53 | unsigned int pll_desc_id) | 44 | unsigned int pll_desc_id) |
| 54 | { | 45 | { |
| 55 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 46 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 56 | return NULL; | 47 | return NULL; |
| 57 | } | 48 | } |
| 58 | #endif | 49 | #endif |
diff --git a/drivers/media/dvb/frontends/isl6405.c b/drivers/media/dvb/frontends/isl6405.c new file mode 100644 index 000000000000..33d33f4d8867 --- /dev/null +++ b/drivers/media/dvb/frontends/isl6405.c | |||
| @@ -0,0 +1,164 @@ | |||
| 1 | /* | ||
| 2 | * isl6405.c - driver for dual lnb supply and control ic ISL6405 | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008 Hartmut Hackmann | ||
| 5 | * Copyright (C) 2006 Oliver Endriss | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU General Public License | ||
| 9 | * as published by the Free Software Foundation; either version 2 | ||
| 10 | * of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License | ||
| 20 | * along with this program; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
| 22 | * Or, point your browser to http://www.gnu.org/copyleft/gpl.html | ||
| 23 | * | ||
| 24 | * | ||
| 25 | * the project's page is at http://www.linuxtv.org | ||
| 26 | */ | ||
| 27 | #include <linux/delay.h> | ||
| 28 | #include <linux/errno.h> | ||
| 29 | #include <linux/init.h> | ||
| 30 | #include <linux/kernel.h> | ||
| 31 | #include <linux/module.h> | ||
| 32 | #include <linux/string.h> | ||
| 33 | #include <linux/slab.h> | ||
| 34 | |||
| 35 | #include "dvb_frontend.h" | ||
| 36 | #include "isl6405.h" | ||
| 37 | |||
| 38 | struct isl6405 { | ||
| 39 | u8 config; | ||
| 40 | u8 override_or; | ||
| 41 | u8 override_and; | ||
| 42 | struct i2c_adapter *i2c; | ||
| 43 | u8 i2c_addr; | ||
| 44 | }; | ||
| 45 | |||
| 46 | static int isl6405_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) | ||
| 47 | { | ||
| 48 | struct isl6405 *isl6405 = (struct isl6405 *) fe->sec_priv; | ||
| 49 | struct i2c_msg msg = { .addr = isl6405->i2c_addr, .flags = 0, | ||
| 50 | .buf = &isl6405->config, | ||
| 51 | .len = sizeof(isl6405->config) }; | ||
| 52 | |||
| 53 | if (isl6405->override_or & 0x80) { | ||
| 54 | isl6405->config &= ~(ISL6405_VSEL2 | ISL6405_EN2); | ||
| 55 | switch (voltage) { | ||
| 56 | case SEC_VOLTAGE_OFF: | ||
| 57 | break; | ||
| 58 | case SEC_VOLTAGE_13: | ||
| 59 | isl6405->config |= ISL6405_EN2; | ||
| 60 | break; | ||
| 61 | case SEC_VOLTAGE_18: | ||
| 62 | isl6405->config |= (ISL6405_EN2 | ISL6405_VSEL2); | ||
| 63 | break; | ||
| 64 | default: | ||
| 65 | return -EINVAL; | ||
| 66 | } | ||
| 67 | } else { | ||
| 68 | isl6405->config &= ~(ISL6405_VSEL1 | ISL6405_EN1); | ||
| 69 | switch (voltage) { | ||
| 70 | case SEC_VOLTAGE_OFF: | ||
| 71 | break; | ||
| 72 | case SEC_VOLTAGE_13: | ||
| 73 | isl6405->config |= ISL6405_EN1; | ||
| 74 | break; | ||
| 75 | case SEC_VOLTAGE_18: | ||
| 76 | isl6405->config |= (ISL6405_EN1 | ISL6405_VSEL1); | ||
| 77 | break; | ||
| 78 | default: | ||
| 79 | return -EINVAL; | ||
| 80 | }; | ||
| 81 | } | ||
| 82 | isl6405->config |= isl6405->override_or; | ||
| 83 | isl6405->config &= isl6405->override_and; | ||
| 84 | |||
| 85 | return (i2c_transfer(isl6405->i2c, &msg, 1) == 1) ? 0 : -EIO; | ||
| 86 | } | ||
| 87 | |||
| 88 | static int isl6405_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg) | ||
| 89 | { | ||
| 90 | struct isl6405 *isl6405 = (struct isl6405 *) fe->sec_priv; | ||
| 91 | struct i2c_msg msg = { .addr = isl6405->i2c_addr, .flags = 0, | ||
| 92 | .buf = &isl6405->config, | ||
| 93 | .len = sizeof(isl6405->config) }; | ||
| 94 | |||
| 95 | if (isl6405->override_or & 0x80) { | ||
| 96 | if (arg) | ||
| 97 | isl6405->config |= ISL6405_LLC2; | ||
| 98 | else | ||
| 99 | isl6405->config &= ~ISL6405_LLC2; | ||
| 100 | } else { | ||
| 101 | if (arg) | ||
| 102 | isl6405->config |= ISL6405_LLC1; | ||
| 103 | else | ||
| 104 | isl6405->config &= ~ISL6405_LLC1; | ||
| 105 | } | ||
| 106 | isl6405->config |= isl6405->override_or; | ||
| 107 | isl6405->config &= isl6405->override_and; | ||
| 108 | |||
| 109 | return (i2c_transfer(isl6405->i2c, &msg, 1) == 1) ? 0 : -EIO; | ||
| 110 | } | ||
| 111 | |||
| 112 | static void isl6405_release(struct dvb_frontend *fe) | ||
| 113 | { | ||
| 114 | /* power off */ | ||
| 115 | isl6405_set_voltage(fe, SEC_VOLTAGE_OFF); | ||
| 116 | |||
| 117 | /* free */ | ||
| 118 | kfree(fe->sec_priv); | ||
| 119 | fe->sec_priv = NULL; | ||
| 120 | } | ||
| 121 | |||
| 122 | struct dvb_frontend *isl6405_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, | ||
| 123 | u8 i2c_addr, u8 override_set, u8 override_clear) | ||
| 124 | { | ||
| 125 | struct isl6405 *isl6405 = kmalloc(sizeof(struct isl6405), GFP_KERNEL); | ||
| 126 | if (!isl6405) | ||
| 127 | return NULL; | ||
| 128 | |||
| 129 | /* default configuration */ | ||
| 130 | if (override_set & 0x80) | ||
| 131 | isl6405->config = ISL6405_ISEL2; | ||
| 132 | else | ||
| 133 | isl6405->config = ISL6405_ISEL1; | ||
| 134 | isl6405->i2c = i2c; | ||
| 135 | isl6405->i2c_addr = i2c_addr; | ||
| 136 | fe->sec_priv = isl6405; | ||
| 137 | |||
| 138 | /* bits which should be forced to '1' */ | ||
| 139 | isl6405->override_or = override_set; | ||
| 140 | |||
| 141 | /* bits which should be forced to '0' */ | ||
| 142 | isl6405->override_and = ~override_clear; | ||
| 143 | |||
| 144 | /* detect if it is present or not */ | ||
| 145 | if (isl6405_set_voltage(fe, SEC_VOLTAGE_OFF)) { | ||
| 146 | kfree(isl6405); | ||
| 147 | fe->sec_priv = NULL; | ||
| 148 | return NULL; | ||
| 149 | } | ||
| 150 | |||
| 151 | /* install release callback */ | ||
| 152 | fe->ops.release_sec = isl6405_release; | ||
| 153 | |||
| 154 | /* override frontend ops */ | ||
| 155 | fe->ops.set_voltage = isl6405_set_voltage; | ||
| 156 | fe->ops.enable_high_lnb_voltage = isl6405_enable_high_lnb_voltage; | ||
| 157 | |||
| 158 | return fe; | ||
| 159 | } | ||
| 160 | EXPORT_SYMBOL(isl6405_attach); | ||
| 161 | |||
| 162 | MODULE_DESCRIPTION("Driver for lnb supply and control ic isl6405"); | ||
| 163 | MODULE_AUTHOR("Hartmut Hackmann & Oliver Endriss"); | ||
| 164 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/frontends/isl6405.h b/drivers/media/dvb/frontends/isl6405.h new file mode 100644 index 000000000000..1c793d37576b --- /dev/null +++ b/drivers/media/dvb/frontends/isl6405.h | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | /* | ||
| 2 | * isl6405.h - driver for dual lnb supply and control ic ISL6405 | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008 Hartmut Hackmann | ||
| 5 | * Copyright (C) 2006 Oliver Endriss | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU General Public License | ||
| 9 | * as published by the Free Software Foundation; either version 2 | ||
| 10 | * of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | * | ||
| 19 | * You should have received a copy of the GNU General Public License | ||
| 20 | * along with this program; if not, write to the Free Software | ||
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
| 22 | * Or, point your browser to http://www.gnu.org/copyleft/gpl.html | ||
| 23 | * | ||
| 24 | * | ||
| 25 | * the project's page is at http://www.linuxtv.org | ||
| 26 | */ | ||
| 27 | |||
| 28 | #ifndef _ISL6405_H | ||
| 29 | #define _ISL6405_H | ||
| 30 | |||
| 31 | #include <linux/dvb/frontend.h> | ||
| 32 | |||
| 33 | /* system register bits */ | ||
| 34 | |||
| 35 | /* this bit selects register (control) 1 or 2 | ||
| 36 | note that the bit maps are different */ | ||
| 37 | |||
| 38 | #define ISL6405_SR 0x80 | ||
| 39 | |||
| 40 | /* SR = 0 */ | ||
| 41 | #define ISL6405_OLF1 0x01 | ||
| 42 | #define ISL6405_EN1 0x02 | ||
| 43 | #define ISL6405_VSEL1 0x04 | ||
| 44 | #define ISL6405_LLC1 0x08 | ||
| 45 | #define ISL6405_ENT1 0x10 | ||
| 46 | #define ISL6405_ISEL1 0x20 | ||
| 47 | #define ISL6405_DCL 0x40 | ||
| 48 | |||
| 49 | /* SR = 1 */ | ||
| 50 | #define ISL6405_OLF2 0x01 | ||
| 51 | #define ISL6405_OTF 0x02 | ||
| 52 | #define ISL6405_EN2 0x04 | ||
| 53 | #define ISL6405_VSEL2 0x08 | ||
| 54 | #define ISL6405_LLC2 0x10 | ||
| 55 | #define ISL6405_ENT2 0x20 | ||
| 56 | #define ISL6405_ISEL2 0x40 | ||
| 57 | |||
| 58 | #if defined(CONFIG_DVB_ISL6405) || (defined(CONFIG_DVB_ISL6405_MODULE) && defined(MODULE)) | ||
| 59 | /* override_set and override_clear control which system register bits (above) | ||
| 60 | * to always set & clear | ||
| 61 | */ | ||
| 62 | extern struct dvb_frontend *isl6405_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, | ||
| 63 | u8 i2c_addr, u8 override_set, u8 override_clear); | ||
| 64 | #else | ||
| 65 | static inline struct dvb_frontend *isl6405_attach(struct dvb_frontend *fe, | ||
| 66 | struct i2c_adapter *i2c, u8 i2c_addr, | ||
| 67 | u8 override_set, u8 override_clear) | ||
| 68 | { | ||
| 69 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
| 70 | return NULL; | ||
| 71 | } | ||
| 72 | #endif /* CONFIG_DVB_ISL6405 */ | ||
| 73 | |||
| 74 | #endif | ||
diff --git a/drivers/media/dvb/frontends/isl6421.h b/drivers/media/dvb/frontends/isl6421.h index ea7f78a7d3cd..47e4518a042d 100644 --- a/drivers/media/dvb/frontends/isl6421.h +++ b/drivers/media/dvb/frontends/isl6421.h | |||
| @@ -47,7 +47,7 @@ extern struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_a | |||
| 47 | static inline struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, | 47 | static inline struct dvb_frontend *isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, |
| 48 | u8 override_set, u8 override_clear) | 48 | u8 override_set, u8 override_clear) |
| 49 | { | 49 | { |
| 50 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 50 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 51 | return NULL; | 51 | return NULL; |
| 52 | } | 52 | } |
| 53 | #endif // CONFIG_DVB_ISL6421 | 53 | #endif // CONFIG_DVB_ISL6421 |
diff --git a/drivers/media/dvb/frontends/itd1000.c b/drivers/media/dvb/frontends/itd1000.c new file mode 100644 index 000000000000..04c562ccf990 --- /dev/null +++ b/drivers/media/dvb/frontends/itd1000.c | |||
| @@ -0,0 +1,400 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Integrant ITD1000 "Zero-IF Tuner IC for Direct Broadcast Satellite" | ||
| 3 | * | ||
| 4 | * Copyright (c) 2007-8 Patrick Boettcher <pb@linuxtv.org> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/module.h> | ||
| 23 | #include <linux/moduleparam.h> | ||
| 24 | #include <linux/delay.h> | ||
| 25 | #include <linux/dvb/frontend.h> | ||
| 26 | #include <linux/i2c.h> | ||
| 27 | |||
| 28 | #include "dvb_frontend.h" | ||
| 29 | |||
| 30 | #include "itd1000.h" | ||
| 31 | #include "itd1000_priv.h" | ||
| 32 | |||
| 33 | static int debug; | ||
| 34 | module_param(debug, int, 0644); | ||
| 35 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); | ||
| 36 | |||
| 37 | #define deb(args...) do { \ | ||
| 38 | if (debug) { \ | ||
| 39 | printk(KERN_DEBUG "ITD1000: " args);\ | ||
| 40 | printk("\n"); \ | ||
| 41 | } \ | ||
| 42 | } while (0) | ||
| 43 | |||
| 44 | #define warn(args...) do { \ | ||
| 45 | printk(KERN_WARNING "ITD1000: " args); \ | ||
| 46 | printk("\n"); \ | ||
| 47 | } while (0) | ||
| 48 | |||
| 49 | #define info(args...) do { \ | ||
| 50 | printk(KERN_INFO "ITD1000: " args); \ | ||
| 51 | printk("\n"); \ | ||
| 52 | } while (0) | ||
| 53 | |||
| 54 | /* don't write more than one byte with flexcop behind */ | ||
| 55 | static int itd1000_write_regs(struct itd1000_state *state, u8 reg, u8 v[], u8 len) | ||
| 56 | { | ||
| 57 | u8 buf[1+len]; | ||
| 58 | struct i2c_msg msg = { | ||
| 59 | .addr = state->cfg->i2c_address, .flags = 0, .buf = buf, .len = len+1 | ||
| 60 | }; | ||
| 61 | buf[0] = reg; | ||
| 62 | memcpy(&buf[1], v, len); | ||
| 63 | |||
| 64 | /* deb("wr %02x: %02x", reg, v[0]); */ | ||
| 65 | |||
| 66 | if (i2c_transfer(state->i2c, &msg, 1) != 1) { | ||
| 67 | printk(KERN_WARNING "itd1000 I2C write failed\n"); | ||
| 68 | return -EREMOTEIO; | ||
| 69 | } | ||
| 70 | return 0; | ||
| 71 | } | ||
| 72 | |||
| 73 | static int itd1000_read_reg(struct itd1000_state *state, u8 reg) | ||
| 74 | { | ||
| 75 | u8 val; | ||
| 76 | struct i2c_msg msg[2] = { | ||
| 77 | { .addr = state->cfg->i2c_address, .flags = 0, .buf = ®, .len = 1 }, | ||
| 78 | { .addr = state->cfg->i2c_address, .flags = I2C_M_RD, .buf = &val, .len = 1 }, | ||
| 79 | }; | ||
| 80 | |||
| 81 | /* ugly flexcop workaround */ | ||
| 82 | itd1000_write_regs(state, (reg - 1) & 0xff, &state->shadow[(reg - 1) & 0xff], 1); | ||
| 83 | |||
| 84 | if (i2c_transfer(state->i2c, msg, 2) != 2) { | ||
| 85 | warn("itd1000 I2C read failed"); | ||
| 86 | return -EREMOTEIO; | ||
| 87 | } | ||
| 88 | return val; | ||
| 89 | } | ||
| 90 | |||
| 91 | static inline int itd1000_write_reg(struct itd1000_state *state, u8 r, u8 v) | ||
| 92 | { | ||
| 93 | int ret = itd1000_write_regs(state, r, &v, 1); | ||
| 94 | state->shadow[r] = v; | ||
| 95 | return ret; | ||
| 96 | } | ||
| 97 | |||
| 98 | |||
| 99 | static struct { | ||
| 100 | u32 symbol_rate; | ||
| 101 | u8 pgaext : 4; /* PLLFH */ | ||
| 102 | u8 bbgvmin : 4; /* BBGVMIN */ | ||
| 103 | } itd1000_lpf_pga[] = { | ||
| 104 | { 0, 0x8, 0x3 }, | ||
| 105 | { 5200000, 0x8, 0x3 }, | ||
| 106 | { 12200000, 0x4, 0x3 }, | ||
| 107 | { 15400000, 0x2, 0x3 }, | ||
| 108 | { 19800000, 0x2, 0x3 }, | ||
| 109 | { 21500000, 0x2, 0x3 }, | ||
| 110 | { 24500000, 0x2, 0x3 }, | ||
| 111 | { 28400000, 0x2, 0x3 }, | ||
| 112 | { 33400000, 0x2, 0x3 }, | ||
| 113 | { 34400000, 0x1, 0x4 }, | ||
| 114 | { 34400000, 0x1, 0x4 }, | ||
| 115 | { 38400000, 0x1, 0x4 }, | ||
| 116 | { 38400000, 0x1, 0x4 }, | ||
| 117 | { 40400000, 0x1, 0x4 }, | ||
| 118 | { 45400000, 0x1, 0x4 }, | ||
| 119 | }; | ||
| 120 | |||
| 121 | static void itd1000_set_lpf_bw(struct itd1000_state *state, u32 symbol_rate) | ||
| 122 | { | ||
| 123 | u8 i; | ||
| 124 | u8 con1 = itd1000_read_reg(state, CON1) & 0xfd; | ||
| 125 | u8 pllfh = itd1000_read_reg(state, PLLFH) & 0x0f; | ||
| 126 | u8 bbgvmin = itd1000_read_reg(state, BBGVMIN) & 0xf0; | ||
| 127 | u8 bw = itd1000_read_reg(state, BW) & 0xf0; | ||
| 128 | |||
| 129 | deb("symbol_rate = %d", symbol_rate); | ||
| 130 | |||
| 131 | /* not sure what is that ? - starting to download the table */ | ||
| 132 | itd1000_write_reg(state, CON1, con1 | (1 << 1)); | ||
| 133 | |||
| 134 | for (i = 0; i < ARRAY_SIZE(itd1000_lpf_pga); i++) | ||
| 135 | if (symbol_rate < itd1000_lpf_pga[i].symbol_rate) { | ||
| 136 | deb("symrate: index: %d pgaext: %x, bbgvmin: %x", i, itd1000_lpf_pga[i].pgaext, itd1000_lpf_pga[i].bbgvmin); | ||
| 137 | itd1000_write_reg(state, PLLFH, pllfh | (itd1000_lpf_pga[i].pgaext << 4)); | ||
| 138 | itd1000_write_reg(state, BBGVMIN, bbgvmin | (itd1000_lpf_pga[i].bbgvmin)); | ||
| 139 | itd1000_write_reg(state, BW, bw | (i & 0x0f)); | ||
| 140 | break; | ||
| 141 | } | ||
| 142 | |||
| 143 | itd1000_write_reg(state, CON1, con1 | (0 << 1)); | ||
| 144 | } | ||
| 145 | |||
| 146 | static struct { | ||
| 147 | u8 vcorg; | ||
| 148 | u32 fmax_rg; | ||
| 149 | } itd1000_vcorg[] = { | ||
| 150 | { 1, 920000 }, | ||
| 151 | { 2, 971000 }, | ||
| 152 | { 3, 1031000 }, | ||
| 153 | { 4, 1091000 }, | ||
| 154 | { 5, 1171000 }, | ||
| 155 | { 6, 1281000 }, | ||
| 156 | { 7, 1381000 }, | ||
| 157 | { 8, 500000 }, /* this is intentional. */ | ||
| 158 | { 9, 1451000 }, | ||
| 159 | { 10, 1531000 }, | ||
| 160 | { 11, 1631000 }, | ||
| 161 | { 12, 1741000 }, | ||
| 162 | { 13, 1891000 }, | ||
| 163 | { 14, 2071000 }, | ||
| 164 | { 15, 2250000 }, | ||
| 165 | }; | ||
| 166 | |||
| 167 | static void itd1000_set_vco(struct itd1000_state *state, u32 freq_khz) | ||
| 168 | { | ||
| 169 | u8 i; | ||
| 170 | u8 gvbb_i2c = itd1000_read_reg(state, GVBB_I2C) & 0xbf; | ||
| 171 | u8 vco_chp1_i2c = itd1000_read_reg(state, VCO_CHP1_I2C) & 0x0f; | ||
| 172 | u8 adcout; | ||
| 173 | |||
| 174 | /* reserved bit again (reset ?) */ | ||
| 175 | itd1000_write_reg(state, GVBB_I2C, gvbb_i2c | (1 << 6)); | ||
| 176 | |||
| 177 | for (i = 0; i < ARRAY_SIZE(itd1000_vcorg); i++) { | ||
| 178 | if (freq_khz < itd1000_vcorg[i].fmax_rg) { | ||
| 179 | itd1000_write_reg(state, VCO_CHP1_I2C, vco_chp1_i2c | (itd1000_vcorg[i].vcorg << 4)); | ||
| 180 | msleep(1); | ||
| 181 | |||
| 182 | adcout = itd1000_read_reg(state, PLLLOCK) & 0x0f; | ||
| 183 | |||
| 184 | deb("VCO: %dkHz: %d -> ADCOUT: %d %02x", freq_khz, itd1000_vcorg[i].vcorg, adcout, vco_chp1_i2c); | ||
| 185 | |||
| 186 | if (adcout > 13) { | ||
| 187 | if (!(itd1000_vcorg[i].vcorg == 7 || itd1000_vcorg[i].vcorg == 15)) | ||
| 188 | itd1000_write_reg(state, VCO_CHP1_I2C, vco_chp1_i2c | ((itd1000_vcorg[i].vcorg + 1) << 4)); | ||
| 189 | } else if (adcout < 2) { | ||
| 190 | if (!(itd1000_vcorg[i].vcorg == 1 || itd1000_vcorg[i].vcorg == 9)) | ||
| 191 | itd1000_write_reg(state, VCO_CHP1_I2C, vco_chp1_i2c | ((itd1000_vcorg[i].vcorg - 1) << 4)); | ||
| 192 | } | ||
| 193 | break; | ||
| 194 | } | ||
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 198 | struct { | ||
| 199 | u32 freq; | ||
| 200 | u8 values[10]; /* RFTR, RFST1 - RFST9 */ | ||
| 201 | } itd1000_fre_values[] = { | ||
| 202 | { 1075000, { 0x59, 0x1d, 0x1c, 0x17, 0x16, 0x0f, 0x0e, 0x0c, 0x0b, 0x0a } }, | ||
| 203 | { 1250000, { 0x89, 0x1e, 0x1d, 0x17, 0x15, 0x0f, 0x0e, 0x0c, 0x0b, 0x0a } }, | ||
| 204 | { 1450000, { 0x89, 0x1e, 0x1d, 0x17, 0x15, 0x0f, 0x0e, 0x0c, 0x0b, 0x0a } }, | ||
| 205 | { 1650000, { 0x69, 0x1e, 0x1d, 0x17, 0x15, 0x0f, 0x0e, 0x0c, 0x0b, 0x0a } }, | ||
| 206 | { 1750000, { 0x69, 0x1e, 0x17, 0x15, 0x14, 0x0f, 0x0e, 0x0c, 0x0b, 0x0a } }, | ||
| 207 | { 1850000, { 0x69, 0x1d, 0x17, 0x16, 0x14, 0x0f, 0x0e, 0x0d, 0x0b, 0x0a } }, | ||
| 208 | { 1900000, { 0x69, 0x1d, 0x17, 0x15, 0x14, 0x0f, 0x0e, 0x0d, 0x0b, 0x0a } }, | ||
| 209 | { 1950000, { 0x69, 0x1d, 0x17, 0x16, 0x14, 0x13, 0x0e, 0x0d, 0x0b, 0x0a } }, | ||
| 210 | { 2050000, { 0x69, 0x1e, 0x1d, 0x17, 0x16, 0x14, 0x13, 0x0e, 0x0b, 0x0a } }, | ||
| 211 | { 2150000, { 0x69, 0x1d, 0x1c, 0x17, 0x15, 0x14, 0x13, 0x0f, 0x0e, 0x0b } } | ||
| 212 | }; | ||
| 213 | |||
| 214 | |||
| 215 | #define FREF 16 | ||
| 216 | |||
| 217 | static void itd1000_set_lo(struct itd1000_state *state, u32 freq_khz) | ||
| 218 | { | ||
| 219 | int i, j; | ||
| 220 | u32 plln, pllf; | ||
| 221 | u64 tmp; | ||
| 222 | |||
| 223 | plln = (freq_khz * 1000) / 2 / FREF; | ||
| 224 | |||
| 225 | /* Compute the factional part times 1000 */ | ||
| 226 | tmp = plln % 1000000; | ||
| 227 | plln /= 1000000; | ||
| 228 | |||
| 229 | tmp *= 1048576; | ||
| 230 | do_div(tmp, 1000000); | ||
| 231 | pllf = (u32) tmp; | ||
| 232 | |||
| 233 | state->frequency = ((plln * 1000) + (pllf * 1000)/1048576) * 2*FREF; | ||
| 234 | deb("frequency: %dkHz (wanted) %dkHz (set), PLLF = %d, PLLN = %d", freq_khz, state->frequency, pllf, plln); | ||
| 235 | |||
| 236 | itd1000_write_reg(state, PLLNH, 0x80); /* PLLNH */; | ||
| 237 | itd1000_write_reg(state, PLLNL, plln & 0xff); | ||
| 238 | itd1000_write_reg(state, PLLFH, (itd1000_read_reg(state, PLLFH) & 0xf0) | ((pllf >> 16) & 0x0f)); | ||
| 239 | itd1000_write_reg(state, PLLFM, (pllf >> 8) & 0xff); | ||
| 240 | itd1000_write_reg(state, PLLFL, (pllf >> 0) & 0xff); | ||
| 241 | |||
| 242 | for (i = 0; i < ARRAY_SIZE(itd1000_fre_values); i++) { | ||
| 243 | if (freq_khz <= itd1000_fre_values[i].freq) { | ||
| 244 | deb("fre_values: %d", i); | ||
| 245 | itd1000_write_reg(state, RFTR, itd1000_fre_values[i].values[0]); | ||
| 246 | for (j = 0; j < 9; j++) | ||
| 247 | itd1000_write_reg(state, RFST1+j, itd1000_fre_values[i].values[j+1]); | ||
| 248 | break; | ||
| 249 | } | ||
| 250 | } | ||
| 251 | |||
| 252 | itd1000_set_vco(state, freq_khz); | ||
| 253 | } | ||
| 254 | |||
| 255 | static int itd1000_set_parameters(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) | ||
| 256 | { | ||
| 257 | struct itd1000_state *state = fe->tuner_priv; | ||
| 258 | u8 pllcon1; | ||
| 259 | |||
| 260 | itd1000_set_lo(state, p->frequency); | ||
| 261 | itd1000_set_lpf_bw(state, p->u.qpsk.symbol_rate); | ||
| 262 | |||
| 263 | pllcon1 = itd1000_read_reg(state, PLLCON1) & 0x7f; | ||
| 264 | itd1000_write_reg(state, PLLCON1, pllcon1 | (1 << 7)); | ||
| 265 | itd1000_write_reg(state, PLLCON1, pllcon1); | ||
| 266 | |||
| 267 | return 0; | ||
| 268 | } | ||
| 269 | |||
| 270 | static int itd1000_get_frequency(struct dvb_frontend *fe, u32 *frequency) | ||
| 271 | { | ||
| 272 | struct itd1000_state *state = fe->tuner_priv; | ||
| 273 | *frequency = state->frequency; | ||
| 274 | return 0; | ||
| 275 | } | ||
| 276 | |||
| 277 | static int itd1000_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) | ||
| 278 | { | ||
| 279 | return 0; | ||
| 280 | } | ||
| 281 | |||
| 282 | static u8 itd1000_init_tab[][2] = { | ||
| 283 | { PLLCON1, 0x65 }, /* Register does not change */ | ||
| 284 | { PLLNH, 0x80 }, /* Bits [7:6] do not change */ | ||
| 285 | { RESERVED_0X6D, 0x3b }, | ||
| 286 | { VCO_CHP2_I2C, 0x12 }, | ||
| 287 | { 0x72, 0xf9 }, /* No such regsister defined */ | ||
| 288 | { RESERVED_0X73, 0xff }, | ||
| 289 | { RESERVED_0X74, 0xb2 }, | ||
| 290 | { RESERVED_0X75, 0xc7 }, | ||
| 291 | { EXTGVBBRF, 0xf0 }, | ||
| 292 | { DIVAGCCK, 0x80 }, | ||
| 293 | { BBTR, 0xa0 }, | ||
| 294 | { RESERVED_0X7E, 0x4f }, | ||
| 295 | { 0x82, 0x88 }, /* No such regsister defined */ | ||
| 296 | { 0x83, 0x80 }, /* No such regsister defined */ | ||
| 297 | { 0x84, 0x80 }, /* No such regsister defined */ | ||
| 298 | { RESERVED_0X85, 0x74 }, | ||
| 299 | { RESERVED_0X86, 0xff }, | ||
| 300 | { RESERVED_0X88, 0x02 }, | ||
| 301 | { RESERVED_0X89, 0x16 }, | ||
| 302 | { RFST0, 0x1f }, | ||
| 303 | { RESERVED_0X94, 0x66 }, | ||
| 304 | { RESERVED_0X95, 0x66 }, | ||
| 305 | { RESERVED_0X96, 0x77 }, | ||
| 306 | { RESERVED_0X97, 0x99 }, | ||
| 307 | { RESERVED_0X98, 0xff }, | ||
| 308 | { RESERVED_0X99, 0xfc }, | ||
| 309 | { RESERVED_0X9A, 0xba }, | ||
| 310 | { RESERVED_0X9B, 0xaa }, | ||
| 311 | }; | ||
| 312 | |||
| 313 | static u8 itd1000_reinit_tab[][2] = { | ||
| 314 | { VCO_CHP1_I2C, 0x8a }, | ||
| 315 | { BW, 0x87 }, | ||
| 316 | { GVBB_I2C, 0x03 }, | ||
| 317 | { BBGVMIN, 0x03 }, | ||
| 318 | { CON1, 0x2e }, | ||
| 319 | }; | ||
| 320 | |||
| 321 | |||
| 322 | static int itd1000_init(struct dvb_frontend *fe) | ||
| 323 | { | ||
| 324 | struct itd1000_state *state = fe->tuner_priv; | ||
| 325 | int i; | ||
| 326 | |||
| 327 | for (i = 0; i < ARRAY_SIZE(itd1000_init_tab); i++) | ||
| 328 | itd1000_write_reg(state, itd1000_init_tab[i][0], itd1000_init_tab[i][1]); | ||
| 329 | |||
| 330 | for (i = 0; i < ARRAY_SIZE(itd1000_reinit_tab); i++) | ||
| 331 | itd1000_write_reg(state, itd1000_reinit_tab[i][0], itd1000_reinit_tab[i][1]); | ||
| 332 | |||
| 333 | return 0; | ||
| 334 | } | ||
| 335 | |||
| 336 | static int itd1000_sleep(struct dvb_frontend *fe) | ||
| 337 | { | ||
| 338 | return 0; | ||
| 339 | } | ||
| 340 | |||
| 341 | static int itd1000_release(struct dvb_frontend *fe) | ||
| 342 | { | ||
| 343 | kfree(fe->tuner_priv); | ||
| 344 | fe->tuner_priv = NULL; | ||
| 345 | return 0; | ||
| 346 | } | ||
| 347 | |||
| 348 | static const struct dvb_tuner_ops itd1000_tuner_ops = { | ||
| 349 | .info = { | ||
| 350 | .name = "Integrant ITD1000", | ||
| 351 | .frequency_min = 950000, | ||
| 352 | .frequency_max = 2150000, | ||
| 353 | .frequency_step = 125, /* kHz for QPSK frontends */ | ||
| 354 | }, | ||
| 355 | |||
| 356 | .release = itd1000_release, | ||
| 357 | |||
| 358 | .init = itd1000_init, | ||
| 359 | .sleep = itd1000_sleep, | ||
| 360 | |||
| 361 | .set_params = itd1000_set_parameters, | ||
| 362 | .get_frequency = itd1000_get_frequency, | ||
| 363 | .get_bandwidth = itd1000_get_bandwidth | ||
| 364 | }; | ||
| 365 | |||
| 366 | |||
| 367 | struct dvb_frontend *itd1000_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct itd1000_config *cfg) | ||
| 368 | { | ||
| 369 | struct itd1000_state *state = NULL; | ||
| 370 | u8 i = 0; | ||
| 371 | |||
| 372 | state = kzalloc(sizeof(struct itd1000_state), GFP_KERNEL); | ||
| 373 | if (state == NULL) | ||
| 374 | return NULL; | ||
| 375 | |||
| 376 | state->cfg = cfg; | ||
| 377 | state->i2c = i2c; | ||
| 378 | |||
| 379 | i = itd1000_read_reg(state, 0); | ||
| 380 | if (i != 0) { | ||
| 381 | kfree(state); | ||
| 382 | return NULL; | ||
| 383 | } | ||
| 384 | info("successfully identified (ID: %d)", i); | ||
| 385 | |||
| 386 | memset(state->shadow, 0xff, sizeof(state->shadow)); | ||
| 387 | for (i = 0x65; i < 0x9c; i++) | ||
| 388 | state->shadow[i] = itd1000_read_reg(state, i); | ||
| 389 | |||
| 390 | memcpy(&fe->ops.tuner_ops, &itd1000_tuner_ops, sizeof(struct dvb_tuner_ops)); | ||
| 391 | |||
| 392 | fe->tuner_priv = state; | ||
| 393 | |||
| 394 | return fe; | ||
| 395 | } | ||
| 396 | EXPORT_SYMBOL(itd1000_attach); | ||
| 397 | |||
| 398 | MODULE_AUTHOR("Patrick Boettcher <pb@linuxtv.org>"); | ||
| 399 | MODULE_DESCRIPTION("Integrant ITD1000 driver"); | ||
| 400 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/frontends/itd1000.h b/drivers/media/dvb/frontends/itd1000.h new file mode 100644 index 000000000000..5e18df071b88 --- /dev/null +++ b/drivers/media/dvb/frontends/itd1000.h | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Integrant ITD1000 "Zero-IF Tuner IC for Direct Broadcast Satellite" | ||
| 3 | * | ||
| 4 | * Copyright (c) 2007 Patrick Boettcher <pb@linuxtv.org> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= | ||
| 20 | */ | ||
| 21 | |||
| 22 | #ifndef ITD1000_H | ||
| 23 | #define ITD1000_H | ||
| 24 | |||
| 25 | struct dvb_frontend; | ||
| 26 | struct i2c_adapter; | ||
| 27 | |||
| 28 | struct itd1000_config { | ||
| 29 | u8 i2c_address; | ||
| 30 | }; | ||
| 31 | |||
| 32 | #if defined(CONFIG_DVB_TUNER_ITD1000) || (defined(CONFIG_DVB_TUNER_ITD1000_MODULE) && defined(MODULE)) | ||
| 33 | extern struct dvb_frontend *itd1000_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct itd1000_config *cfg); | ||
| 34 | #else | ||
| 35 | static inline struct dvb_frontend *itd1000_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct itd1000_config *cfg) | ||
| 36 | { | ||
| 37 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
| 38 | return NULL; | ||
| 39 | } | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #endif | ||
diff --git a/drivers/media/dvb/frontends/itd1000_priv.h b/drivers/media/dvb/frontends/itd1000_priv.h new file mode 100644 index 000000000000..8cdc54e57903 --- /dev/null +++ b/drivers/media/dvb/frontends/itd1000_priv.h | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Integrant ITD1000 "Zero-IF Tuner IC for Direct Broadcast Satellite" | ||
| 3 | * | ||
| 4 | * Copyright (c) 2007 Patrick Boettcher <pb@linuxtv.org> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.= | ||
| 20 | */ | ||
| 21 | |||
| 22 | #ifndef ITD1000_PRIV_H | ||
| 23 | #define ITD1000_PRIV_H | ||
| 24 | |||
| 25 | struct itd1000_state { | ||
| 26 | struct itd1000_config *cfg; | ||
| 27 | struct i2c_adapter *i2c; | ||
| 28 | |||
| 29 | u32 frequency; /* contains the value resulting from the LO-setting */ | ||
| 30 | |||
| 31 | /* ugly workaround for flexcop's incapable i2c-controller | ||
| 32 | * FIXME, if possible | ||
| 33 | */ | ||
| 34 | u8 shadow[255]; | ||
| 35 | }; | ||
| 36 | |||
| 37 | enum itd1000_register { | ||
| 38 | VCO_CHP1 = 0x65, | ||
| 39 | VCO_CHP2, | ||
| 40 | PLLCON1, | ||
| 41 | PLLNH, | ||
| 42 | PLLNL, | ||
| 43 | PLLFH, | ||
| 44 | PLLFM, | ||
| 45 | PLLFL, | ||
| 46 | RESERVED_0X6D, | ||
| 47 | PLLLOCK, | ||
| 48 | VCO_CHP2_I2C, | ||
| 49 | VCO_CHP1_I2C, | ||
| 50 | BW, | ||
| 51 | RESERVED_0X73 = 0x73, | ||
| 52 | RESERVED_0X74, | ||
| 53 | RESERVED_0X75, | ||
| 54 | GVBB, | ||
| 55 | GVRF, | ||
| 56 | GVBB_I2C, | ||
| 57 | EXTGVBBRF, | ||
| 58 | DIVAGCCK, | ||
| 59 | BBTR, | ||
| 60 | RFTR, | ||
| 61 | BBGVMIN, | ||
| 62 | RESERVED_0X7E, | ||
| 63 | RESERVED_0X85 = 0x85, | ||
| 64 | RESERVED_0X86, | ||
| 65 | CON1, | ||
| 66 | RESERVED_0X88, | ||
| 67 | RESERVED_0X89, | ||
| 68 | RFST0, | ||
| 69 | RFST1, | ||
| 70 | RFST2, | ||
| 71 | RFST3, | ||
| 72 | RFST4, | ||
| 73 | RFST5, | ||
| 74 | RFST6, | ||
| 75 | RFST7, | ||
| 76 | RFST8, | ||
| 77 | RFST9, | ||
| 78 | RESERVED_0X94, | ||
| 79 | RESERVED_0X95, | ||
| 80 | RESERVED_0X96, | ||
| 81 | RESERVED_0X97, | ||
| 82 | RESERVED_0X98, | ||
| 83 | RESERVED_0X99, | ||
| 84 | RESERVED_0X9A, | ||
| 85 | RESERVED_0X9B, | ||
| 86 | }; | ||
| 87 | |||
| 88 | #endif | ||
diff --git a/drivers/media/dvb/frontends/l64781.c b/drivers/media/dvb/frontends/l64781.c index 443d9045d4c9..e1e70e9e0cb9 100644 --- a/drivers/media/dvb/frontends/l64781.c +++ b/drivers/media/dvb/frontends/l64781.c | |||
| @@ -57,7 +57,7 @@ static int l64781_writereg (struct l64781_state* state, u8 reg, u8 data) | |||
| 57 | 57 | ||
| 58 | if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1) | 58 | if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1) |
| 59 | dprintk ("%s: write_reg error (reg == %02x) = %02x!\n", | 59 | dprintk ("%s: write_reg error (reg == %02x) = %02x!\n", |
| 60 | __FUNCTION__, reg, ret); | 60 | __func__, reg, ret); |
| 61 | 61 | ||
| 62 | return (ret != 1) ? -1 : 0; | 62 | return (ret != 1) ? -1 : 0; |
| 63 | } | 63 | } |
diff --git a/drivers/media/dvb/frontends/l64781.h b/drivers/media/dvb/frontends/l64781.h index cd15f76ff28d..1305a9e7fb0b 100644 --- a/drivers/media/dvb/frontends/l64781.h +++ b/drivers/media/dvb/frontends/l64781.h | |||
| @@ -38,7 +38,7 @@ extern struct dvb_frontend* l64781_attach(const struct l64781_config* config, | |||
| 38 | static inline struct dvb_frontend* l64781_attach(const struct l64781_config* config, | 38 | static inline struct dvb_frontend* l64781_attach(const struct l64781_config* config, |
| 39 | struct i2c_adapter* i2c) | 39 | struct i2c_adapter* i2c) |
| 40 | { | 40 | { |
| 41 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 41 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 42 | return NULL; | 42 | return NULL; |
| 43 | } | 43 | } |
| 44 | #endif // CONFIG_DVB_L64781 | 44 | #endif // CONFIG_DVB_L64781 |
diff --git a/drivers/media/dvb/frontends/lgdt330x.c b/drivers/media/dvb/frontends/lgdt330x.c index bdc9fa88b86a..f0195c8272f4 100644 --- a/drivers/media/dvb/frontends/lgdt330x.c +++ b/drivers/media/dvb/frontends/lgdt330x.c | |||
| @@ -49,7 +49,7 @@ | |||
| 49 | /* Use Equalizer Mean Squared Error instead of Phaser Tracker MSE */ | 49 | /* Use Equalizer Mean Squared Error instead of Phaser Tracker MSE */ |
| 50 | /* #define USE_EQMSE */ | 50 | /* #define USE_EQMSE */ |
| 51 | 51 | ||
| 52 | static int debug = 0; | 52 | static int debug; |
| 53 | module_param(debug, int, 0644); | 53 | module_param(debug, int, 0644); |
| 54 | MODULE_PARM_DESC(debug,"Turn on/off lgdt330x frontend debugging (default:off)."); | 54 | MODULE_PARM_DESC(debug,"Turn on/off lgdt330x frontend debugging (default:off)."); |
| 55 | #define dprintk(args...) \ | 55 | #define dprintk(args...) \ |
| @@ -88,7 +88,7 @@ static int i2c_write_demod_bytes (struct lgdt330x_state* state, | |||
| 88 | 88 | ||
| 89 | for (i=0; i<len-1; i+=2){ | 89 | for (i=0; i<len-1; i+=2){ |
| 90 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { | 90 | if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { |
| 91 | printk(KERN_WARNING "lgdt330x: %s error (addr %02x <- %02x, err = %i)\n", __FUNCTION__, msg.buf[0], msg.buf[1], err); | 91 | printk(KERN_WARNING "lgdt330x: %s error (addr %02x <- %02x, err = %i)\n", __func__, msg.buf[0], msg.buf[1], err); |
| 92 | if (err < 0) | 92 | if (err < 0) |
| 93 | return err; | 93 | return err; |
| 94 | else | 94 | else |
| @@ -117,7 +117,7 @@ static u8 i2c_read_demod_bytes (struct lgdt330x_state* state, | |||
| 117 | int ret; | 117 | int ret; |
| 118 | ret = i2c_transfer(state->i2c, msg, 2); | 118 | ret = i2c_transfer(state->i2c, msg, 2); |
| 119 | if (ret != 2) { | 119 | if (ret != 2) { |
| 120 | printk(KERN_WARNING "lgdt330x: %s: addr 0x%02x select 0x%02x error (ret == %i)\n", __FUNCTION__, state->config->demod_address, reg, ret); | 120 | printk(KERN_WARNING "lgdt330x: %s: addr 0x%02x select 0x%02x error (ret == %i)\n", __func__, state->config->demod_address, reg, ret); |
| 121 | } else { | 121 | } else { |
| 122 | ret = 0; | 122 | ret = 0; |
| 123 | } | 123 | } |
| @@ -256,7 +256,7 @@ static int lgdt330x_init(struct dvb_frontend* fe) | |||
| 256 | printk (KERN_WARNING "Only LGDT3302 and LGDT3303 are supported chips.\n"); | 256 | printk (KERN_WARNING "Only LGDT3302 and LGDT3303 are supported chips.\n"); |
| 257 | err = -ENODEV; | 257 | err = -ENODEV; |
| 258 | } | 258 | } |
| 259 | dprintk("%s entered as %s\n", __FUNCTION__, chip_name); | 259 | dprintk("%s entered as %s\n", __func__, chip_name); |
| 260 | if (err < 0) | 260 | if (err < 0) |
| 261 | return err; | 261 | return err; |
| 262 | return lgdt330x_SwReset(state); | 262 | return lgdt330x_SwReset(state); |
| @@ -334,7 +334,7 @@ static int lgdt330x_set_parameters(struct dvb_frontend* fe, | |||
| 334 | if (state->current_modulation != param->u.vsb.modulation) { | 334 | if (state->current_modulation != param->u.vsb.modulation) { |
| 335 | switch(param->u.vsb.modulation) { | 335 | switch(param->u.vsb.modulation) { |
| 336 | case VSB_8: | 336 | case VSB_8: |
| 337 | dprintk("%s: VSB_8 MODE\n", __FUNCTION__); | 337 | dprintk("%s: VSB_8 MODE\n", __func__); |
| 338 | 338 | ||
| 339 | /* Select VSB mode */ | 339 | /* Select VSB mode */ |
| 340 | top_ctrl_cfg[1] = 0x03; | 340 | top_ctrl_cfg[1] = 0x03; |
| @@ -350,7 +350,7 @@ static int lgdt330x_set_parameters(struct dvb_frontend* fe, | |||
| 350 | break; | 350 | break; |
| 351 | 351 | ||
| 352 | case QAM_64: | 352 | case QAM_64: |
| 353 | dprintk("%s: QAM_64 MODE\n", __FUNCTION__); | 353 | dprintk("%s: QAM_64 MODE\n", __func__); |
| 354 | 354 | ||
| 355 | /* Select QAM_64 mode */ | 355 | /* Select QAM_64 mode */ |
| 356 | top_ctrl_cfg[1] = 0x00; | 356 | top_ctrl_cfg[1] = 0x00; |
| @@ -366,7 +366,7 @@ static int lgdt330x_set_parameters(struct dvb_frontend* fe, | |||
| 366 | break; | 366 | break; |
| 367 | 367 | ||
| 368 | case QAM_256: | 368 | case QAM_256: |
| 369 | dprintk("%s: QAM_256 MODE\n", __FUNCTION__); | 369 | dprintk("%s: QAM_256 MODE\n", __func__); |
| 370 | 370 | ||
| 371 | /* Select QAM_256 mode */ | 371 | /* Select QAM_256 mode */ |
| 372 | top_ctrl_cfg[1] = 0x01; | 372 | top_ctrl_cfg[1] = 0x01; |
| @@ -381,7 +381,7 @@ static int lgdt330x_set_parameters(struct dvb_frontend* fe, | |||
| 381 | } | 381 | } |
| 382 | break; | 382 | break; |
| 383 | default: | 383 | default: |
| 384 | printk(KERN_WARNING "lgdt330x: %s: Modulation type(%d) UNSUPPORTED\n", __FUNCTION__, param->u.vsb.modulation); | 384 | printk(KERN_WARNING "lgdt330x: %s: Modulation type(%d) UNSUPPORTED\n", __func__, param->u.vsb.modulation); |
| 385 | return -1; | 385 | return -1; |
| 386 | } | 386 | } |
| 387 | /* | 387 | /* |
| @@ -431,7 +431,7 @@ static int lgdt3302_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 431 | 431 | ||
| 432 | /* AGC status register */ | 432 | /* AGC status register */ |
| 433 | i2c_read_demod_bytes(state, AGC_STATUS, buf, 1); | 433 | i2c_read_demod_bytes(state, AGC_STATUS, buf, 1); |
| 434 | dprintk("%s: AGC_STATUS = 0x%02x\n", __FUNCTION__, buf[0]); | 434 | dprintk("%s: AGC_STATUS = 0x%02x\n", __func__, buf[0]); |
| 435 | if ((buf[0] & 0x0c) == 0x8){ | 435 | if ((buf[0] & 0x0c) == 0x8){ |
| 436 | /* Test signal does not exist flag */ | 436 | /* Test signal does not exist flag */ |
| 437 | /* as well as the AGC lock flag. */ | 437 | /* as well as the AGC lock flag. */ |
| @@ -445,7 +445,7 @@ static int lgdt3302_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 445 | */ | 445 | */ |
| 446 | /* signal status */ | 446 | /* signal status */ |
| 447 | i2c_read_demod_bytes(state, TOP_CONTROL, buf, sizeof(buf)); | 447 | i2c_read_demod_bytes(state, TOP_CONTROL, buf, sizeof(buf)); |
| 448 | dprintk("%s: TOP_CONTROL = 0x%02x, IRO_MASK = 0x%02x, IRQ_STATUS = 0x%02x\n", __FUNCTION__, buf[0], buf[1], buf[2]); | 448 | dprintk("%s: TOP_CONTROL = 0x%02x, IRO_MASK = 0x%02x, IRQ_STATUS = 0x%02x\n", __func__, buf[0], buf[1], buf[2]); |
| 449 | 449 | ||
| 450 | 450 | ||
| 451 | /* sync status */ | 451 | /* sync status */ |
| @@ -461,7 +461,7 @@ static int lgdt3302_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 461 | 461 | ||
| 462 | /* Carrier Recovery Lock Status Register */ | 462 | /* Carrier Recovery Lock Status Register */ |
| 463 | i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1); | 463 | i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1); |
| 464 | dprintk("%s: CARRIER_LOCK = 0x%02x\n", __FUNCTION__, buf[0]); | 464 | dprintk("%s: CARRIER_LOCK = 0x%02x\n", __func__, buf[0]); |
| 465 | switch (state->current_modulation) { | 465 | switch (state->current_modulation) { |
| 466 | case QAM_256: | 466 | case QAM_256: |
| 467 | case QAM_64: | 467 | case QAM_64: |
| @@ -474,7 +474,7 @@ static int lgdt3302_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 474 | *status |= FE_HAS_CARRIER; | 474 | *status |= FE_HAS_CARRIER; |
| 475 | break; | 475 | break; |
| 476 | default: | 476 | default: |
| 477 | printk(KERN_WARNING "lgdt330x: %s: Modulation set to unsupported value\n", __FUNCTION__); | 477 | printk(KERN_WARNING "lgdt330x: %s: Modulation set to unsupported value\n", __func__); |
| 478 | } | 478 | } |
| 479 | 479 | ||
| 480 | return 0; | 480 | return 0; |
| @@ -493,7 +493,7 @@ static int lgdt3303_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 493 | if (err < 0) | 493 | if (err < 0) |
| 494 | return err; | 494 | return err; |
| 495 | 495 | ||
| 496 | dprintk("%s: AGC_STATUS = 0x%02x\n", __FUNCTION__, buf[0]); | 496 | dprintk("%s: AGC_STATUS = 0x%02x\n", __func__, buf[0]); |
| 497 | if ((buf[0] & 0x21) == 0x01){ | 497 | if ((buf[0] & 0x21) == 0x01){ |
| 498 | /* Test input signal does not exist flag */ | 498 | /* Test input signal does not exist flag */ |
| 499 | /* as well as the AGC lock flag. */ | 499 | /* as well as the AGC lock flag. */ |
| @@ -502,7 +502,7 @@ static int lgdt3303_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 502 | 502 | ||
| 503 | /* Carrier Recovery Lock Status Register */ | 503 | /* Carrier Recovery Lock Status Register */ |
| 504 | i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1); | 504 | i2c_read_demod_bytes(state, CARRIER_LOCK, buf, 1); |
| 505 | dprintk("%s: CARRIER_LOCK = 0x%02x\n", __FUNCTION__, buf[0]); | 505 | dprintk("%s: CARRIER_LOCK = 0x%02x\n", __func__, buf[0]); |
| 506 | switch (state->current_modulation) { | 506 | switch (state->current_modulation) { |
| 507 | case QAM_256: | 507 | case QAM_256: |
| 508 | case QAM_64: | 508 | case QAM_64: |
| @@ -533,7 +533,7 @@ static int lgdt3303_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 533 | } | 533 | } |
| 534 | break; | 534 | break; |
| 535 | default: | 535 | default: |
| 536 | printk(KERN_WARNING "lgdt330x: %s: Modulation set to unsupported value\n", __FUNCTION__); | 536 | printk(KERN_WARNING "lgdt330x: %s: Modulation set to unsupported value\n", __func__); |
| 537 | } | 537 | } |
| 538 | return 0; | 538 | return 0; |
| 539 | } | 539 | } |
| @@ -607,14 +607,14 @@ static int lgdt3302_read_snr(struct dvb_frontend* fe, u16* snr) | |||
| 607 | break; | 607 | break; |
| 608 | default: | 608 | default: |
| 609 | printk(KERN_ERR "lgdt330x: %s: Modulation set to unsupported value\n", | 609 | printk(KERN_ERR "lgdt330x: %s: Modulation set to unsupported value\n", |
| 610 | __FUNCTION__); | 610 | __func__); |
| 611 | return -EREMOTEIO; /* return -EDRIVER_IS_GIBBERED; */ | 611 | return -EREMOTEIO; /* return -EDRIVER_IS_GIBBERED; */ |
| 612 | } | 612 | } |
| 613 | 613 | ||
| 614 | state->snr = calculate_snr(noise, c); | 614 | state->snr = calculate_snr(noise, c); |
| 615 | *snr = (state->snr) >> 16; /* Convert from 8.24 fixed-point to 8.8 */ | 615 | *snr = (state->snr) >> 16; /* Convert from 8.24 fixed-point to 8.8 */ |
| 616 | 616 | ||
| 617 | dprintk("%s: noise = 0x%08x, snr = %d.%02d dB\n", __FUNCTION__, noise, | 617 | dprintk("%s: noise = 0x%08x, snr = %d.%02d dB\n", __func__, noise, |
| 618 | state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16); | 618 | state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16); |
| 619 | 619 | ||
| 620 | return 0; | 620 | return 0; |
| @@ -651,14 +651,14 @@ static int lgdt3303_read_snr(struct dvb_frontend* fe, u16* snr) | |||
| 651 | break; | 651 | break; |
| 652 | default: | 652 | default: |
| 653 | printk(KERN_ERR "lgdt330x: %s: Modulation set to unsupported value\n", | 653 | printk(KERN_ERR "lgdt330x: %s: Modulation set to unsupported value\n", |
| 654 | __FUNCTION__); | 654 | __func__); |
| 655 | return -EREMOTEIO; /* return -EDRIVER_IS_GIBBERED; */ | 655 | return -EREMOTEIO; /* return -EDRIVER_IS_GIBBERED; */ |
| 656 | } | 656 | } |
| 657 | 657 | ||
| 658 | state->snr = calculate_snr(noise, c); | 658 | state->snr = calculate_snr(noise, c); |
| 659 | *snr = (state->snr) >> 16; /* Convert from 8.24 fixed-point to 8.8 */ | 659 | *snr = (state->snr) >> 16; /* Convert from 8.24 fixed-point to 8.8 */ |
| 660 | 660 | ||
| 661 | dprintk("%s: noise = 0x%08x, snr = %d.%02d dB\n", __FUNCTION__, noise, | 661 | dprintk("%s: noise = 0x%08x, snr = %d.%02d dB\n", __func__, noise, |
| 662 | state->snr >> 24, (((state->snr >> 8) & 0xffff) * 100) >> 16); | 662 | state->snr >> 24, (((state->snr >> 8) & 0xffff) * 100) >> 16); |
| 663 | 663 | ||
| 664 | return 0; | 664 | return 0; |
| @@ -743,7 +743,7 @@ struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config, | |||
| 743 | 743 | ||
| 744 | error: | 744 | error: |
| 745 | kfree(state); | 745 | kfree(state); |
| 746 | dprintk("%s: ERROR\n",__FUNCTION__); | 746 | dprintk("%s: ERROR\n",__func__); |
| 747 | return NULL; | 747 | return NULL; |
| 748 | } | 748 | } |
| 749 | 749 | ||
diff --git a/drivers/media/dvb/frontends/lgdt330x.h b/drivers/media/dvb/frontends/lgdt330x.h index 995059004b10..9012504f0f2d 100644 --- a/drivers/media/dvb/frontends/lgdt330x.h +++ b/drivers/media/dvb/frontends/lgdt330x.h | |||
| @@ -59,7 +59,7 @@ extern struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config | |||
| 59 | static inline struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config, | 59 | static inline struct dvb_frontend* lgdt330x_attach(const struct lgdt330x_config* config, |
| 60 | struct i2c_adapter* i2c) | 60 | struct i2c_adapter* i2c) |
| 61 | { | 61 | { |
| 62 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 62 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 63 | return NULL; | 63 | return NULL; |
| 64 | } | 64 | } |
| 65 | #endif // CONFIG_DVB_LGDT330X | 65 | #endif // CONFIG_DVB_LGDT330X |
diff --git a/drivers/media/dvb/frontends/lnbp21.h b/drivers/media/dvb/frontends/lnbp21.h index 68906acf7d63..8fe094bd9689 100644 --- a/drivers/media/dvb/frontends/lnbp21.h +++ b/drivers/media/dvb/frontends/lnbp21.h | |||
| @@ -45,7 +45,7 @@ extern struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_ad | |||
| 45 | #else | 45 | #else |
| 46 | static inline struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear) | 46 | static inline struct dvb_frontend *lnbp21_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 override_set, u8 override_clear) |
| 47 | { | 47 | { |
| 48 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 48 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 49 | return NULL; | 49 | return NULL; |
| 50 | } | 50 | } |
| 51 | #endif // CONFIG_DVB_LNBP21 | 51 | #endif // CONFIG_DVB_LNBP21 |
diff --git a/drivers/media/dvb/frontends/mt2060.h b/drivers/media/dvb/frontends/mt2060.h index 0a86eab3a954..acba0058f519 100644 --- a/drivers/media/dvb/frontends/mt2060.h +++ b/drivers/media/dvb/frontends/mt2060.h | |||
| @@ -35,7 +35,7 @@ extern struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_a | |||
| 35 | #else | 35 | #else |
| 36 | static inline struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1) | 36 | static inline struct dvb_frontend * mt2060_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2060_config *cfg, u16 if1) |
| 37 | { | 37 | { |
| 38 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 38 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 39 | return NULL; | 39 | return NULL; |
| 40 | } | 40 | } |
| 41 | #endif // CONFIG_DVB_TUNER_MT2060 | 41 | #endif // CONFIG_DVB_TUNER_MT2060 |
diff --git a/drivers/media/dvb/frontends/mt2131.c b/drivers/media/dvb/frontends/mt2131.c index 13cf16668171..e254bcfc2efb 100644 --- a/drivers/media/dvb/frontends/mt2131.c +++ b/drivers/media/dvb/frontends/mt2131.c | |||
| @@ -110,7 +110,7 @@ static int mt2131_set_params(struct dvb_frontend *fe, | |||
| 110 | priv->bandwidth = 0; | 110 | priv->bandwidth = 0; |
| 111 | 111 | ||
| 112 | freq = params->frequency / 1000; // Hz -> kHz | 112 | freq = params->frequency / 1000; // Hz -> kHz |
| 113 | dprintk(1, "%s() freq=%d\n", __FUNCTION__, freq); | 113 | dprintk(1, "%s() freq=%d\n", __func__, freq); |
| 114 | 114 | ||
| 115 | f_lo1 = freq + MT2131_IF1 * 1000; | 115 | f_lo1 = freq + MT2131_IF1 * 1000; |
| 116 | f_lo1 = (f_lo1 / 250) * 250; | 116 | f_lo1 = (f_lo1 / 250) * 250; |
| @@ -187,7 +187,7 @@ static int mt2131_set_params(struct dvb_frontend *fe, | |||
| 187 | static int mt2131_get_frequency(struct dvb_frontend *fe, u32 *frequency) | 187 | static int mt2131_get_frequency(struct dvb_frontend *fe, u32 *frequency) |
| 188 | { | 188 | { |
| 189 | struct mt2131_priv *priv = fe->tuner_priv; | 189 | struct mt2131_priv *priv = fe->tuner_priv; |
| 190 | dprintk(1, "%s()\n", __FUNCTION__); | 190 | dprintk(1, "%s()\n", __func__); |
| 191 | *frequency = priv->frequency; | 191 | *frequency = priv->frequency; |
| 192 | return 0; | 192 | return 0; |
| 193 | } | 193 | } |
| @@ -195,7 +195,7 @@ static int mt2131_get_frequency(struct dvb_frontend *fe, u32 *frequency) | |||
| 195 | static int mt2131_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) | 195 | static int mt2131_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) |
| 196 | { | 196 | { |
| 197 | struct mt2131_priv *priv = fe->tuner_priv; | 197 | struct mt2131_priv *priv = fe->tuner_priv; |
| 198 | dprintk(1, "%s()\n", __FUNCTION__); | 198 | dprintk(1, "%s()\n", __func__); |
| 199 | *bandwidth = priv->bandwidth; | 199 | *bandwidth = priv->bandwidth; |
| 200 | return 0; | 200 | return 0; |
| 201 | } | 201 | } |
| @@ -214,7 +214,7 @@ static int mt2131_get_status(struct dvb_frontend *fe, u32 *status) | |||
| 214 | 214 | ||
| 215 | mt2131_readreg(priv, 0x09, &afc_status); | 215 | mt2131_readreg(priv, 0x09, &afc_status); |
| 216 | dprintk(1, "%s() - LO Status = 0x%x, AFC Status = 0x%x\n", | 216 | dprintk(1, "%s() - LO Status = 0x%x, AFC Status = 0x%x\n", |
| 217 | __FUNCTION__, lock_status, afc_status); | 217 | __func__, lock_status, afc_status); |
| 218 | 218 | ||
| 219 | return 0; | 219 | return 0; |
| 220 | } | 220 | } |
| @@ -223,7 +223,7 @@ static int mt2131_init(struct dvb_frontend *fe) | |||
| 223 | { | 223 | { |
| 224 | struct mt2131_priv *priv = fe->tuner_priv; | 224 | struct mt2131_priv *priv = fe->tuner_priv; |
| 225 | int ret; | 225 | int ret; |
| 226 | dprintk(1, "%s()\n", __FUNCTION__); | 226 | dprintk(1, "%s()\n", __func__); |
| 227 | 227 | ||
| 228 | if ((ret = mt2131_writeregs(priv, mt2131_config1, | 228 | if ((ret = mt2131_writeregs(priv, mt2131_config1, |
| 229 | sizeof(mt2131_config1))) < 0) | 229 | sizeof(mt2131_config1))) < 0) |
| @@ -243,7 +243,7 @@ static int mt2131_init(struct dvb_frontend *fe) | |||
| 243 | 243 | ||
| 244 | static int mt2131_release(struct dvb_frontend *fe) | 244 | static int mt2131_release(struct dvb_frontend *fe) |
| 245 | { | 245 | { |
| 246 | dprintk(1, "%s()\n", __FUNCTION__); | 246 | dprintk(1, "%s()\n", __func__); |
| 247 | kfree(fe->tuner_priv); | 247 | kfree(fe->tuner_priv); |
| 248 | fe->tuner_priv = NULL; | 248 | fe->tuner_priv = NULL; |
| 249 | return 0; | 249 | return 0; |
| @@ -273,7 +273,7 @@ struct dvb_frontend * mt2131_attach(struct dvb_frontend *fe, | |||
| 273 | struct mt2131_priv *priv = NULL; | 273 | struct mt2131_priv *priv = NULL; |
| 274 | u8 id = 0; | 274 | u8 id = 0; |
| 275 | 275 | ||
| 276 | dprintk(1, "%s()\n", __FUNCTION__); | 276 | dprintk(1, "%s()\n", __func__); |
| 277 | 277 | ||
| 278 | priv = kzalloc(sizeof(struct mt2131_priv), GFP_KERNEL); | 278 | priv = kzalloc(sizeof(struct mt2131_priv), GFP_KERNEL); |
| 279 | if (priv == NULL) | 279 | if (priv == NULL) |
diff --git a/drivers/media/dvb/frontends/mt2131.h b/drivers/media/dvb/frontends/mt2131.h index 1e4ffe7dc8c8..606d8576bc98 100644 --- a/drivers/media/dvb/frontends/mt2131.h +++ b/drivers/media/dvb/frontends/mt2131.h | |||
| @@ -41,7 +41,7 @@ static inline struct dvb_frontend* mt2131_attach(struct dvb_frontend *fe, | |||
| 41 | struct mt2131_config *cfg, | 41 | struct mt2131_config *cfg, |
| 42 | u16 if1) | 42 | u16 if1) |
| 43 | { | 43 | { |
| 44 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 44 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 45 | return NULL; | 45 | return NULL; |
| 46 | } | 46 | } |
| 47 | #endif /* CONFIG_DVB_TUNER_MT2131 */ | 47 | #endif /* CONFIG_DVB_TUNER_MT2131 */ |
diff --git a/drivers/media/dvb/frontends/mt2266.h b/drivers/media/dvb/frontends/mt2266.h index f31dd613ad37..c5113efe333c 100644 --- a/drivers/media/dvb/frontends/mt2266.h +++ b/drivers/media/dvb/frontends/mt2266.h | |||
| @@ -29,7 +29,7 @@ extern struct dvb_frontend * mt2266_attach(struct dvb_frontend *fe, struct i2c_a | |||
| 29 | #else | 29 | #else |
| 30 | static inline struct dvb_frontend * mt2266_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2266_config *cfg) | 30 | static inline struct dvb_frontend * mt2266_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, struct mt2266_config *cfg) |
| 31 | { | 31 | { |
| 32 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 32 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 33 | return NULL; | 33 | return NULL; |
| 34 | } | 34 | } |
| 35 | #endif // CONFIG_DVB_TUNER_MT2266 | 35 | #endif // CONFIG_DVB_TUNER_MT2266 |
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c index 1638301fbd6e..081ca3398c76 100644 --- a/drivers/media/dvb/frontends/mt312.c +++ b/drivers/media/dvb/frontends/mt312.c | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Driver for Zarlink VP310/MT312 Satellite Channel Decoder | 2 | Driver for Zarlink VP310/MT312/ZL10313 Satellite Channel Decoder |
| 3 | 3 | ||
| 4 | Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org> | 4 | Copyright (C) 2003 Andreas Oberritter <obi@linuxtv.org> |
| 5 | Copyright (C) 2008 Matthias Schwarzott <zzam@gentoo.org> | ||
| 5 | 6 | ||
| 6 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
| @@ -43,7 +44,8 @@ struct mt312_state { | |||
| 43 | struct dvb_frontend frontend; | 44 | struct dvb_frontend frontend; |
| 44 | 45 | ||
| 45 | u8 id; | 46 | u8 id; |
| 46 | u8 frequency; | 47 | unsigned long xtal; |
| 48 | u8 freq_mult; | ||
| 47 | }; | 49 | }; |
| 48 | 50 | ||
| 49 | static int debug; | 51 | static int debug; |
| @@ -53,12 +55,11 @@ static int debug; | |||
| 53 | printk(KERN_DEBUG "mt312: " args); \ | 55 | printk(KERN_DEBUG "mt312: " args); \ |
| 54 | } while (0) | 56 | } while (0) |
| 55 | 57 | ||
| 56 | #define MT312_SYS_CLK 90000000UL /* 90 MHz */ | ||
| 57 | #define MT312_LPOWER_SYS_CLK 60000000UL /* 60 MHz */ | ||
| 58 | #define MT312_PLL_CLK 10000000UL /* 10 MHz */ | 58 | #define MT312_PLL_CLK 10000000UL /* 10 MHz */ |
| 59 | #define MT312_PLL_CLK_10_111 10111000UL /* 10.111 MHz */ | ||
| 59 | 60 | ||
| 60 | static int mt312_read(struct mt312_state *state, const enum mt312_reg_addr reg, | 61 | static int mt312_read(struct mt312_state *state, const enum mt312_reg_addr reg, |
| 61 | void *buf, const size_t count) | 62 | u8 *buf, const size_t count) |
| 62 | { | 63 | { |
| 63 | int ret; | 64 | int ret; |
| 64 | struct i2c_msg msg[2]; | 65 | struct i2c_msg msg[2]; |
| @@ -76,7 +77,7 @@ static int mt312_read(struct mt312_state *state, const enum mt312_reg_addr reg, | |||
| 76 | ret = i2c_transfer(state->i2c, msg, 2); | 77 | ret = i2c_transfer(state->i2c, msg, 2); |
| 77 | 78 | ||
| 78 | if (ret != 2) { | 79 | if (ret != 2) { |
| 79 | printk(KERN_ERR "%s: ret == %d\n", __FUNCTION__, ret); | 80 | printk(KERN_ERR "%s: ret == %d\n", __func__, ret); |
| 80 | return -EREMOTEIO; | 81 | return -EREMOTEIO; |
| 81 | } | 82 | } |
| 82 | 83 | ||
| @@ -84,7 +85,7 @@ static int mt312_read(struct mt312_state *state, const enum mt312_reg_addr reg, | |||
| 84 | int i; | 85 | int i; |
| 85 | dprintk("R(%d):", reg & 0x7f); | 86 | dprintk("R(%d):", reg & 0x7f); |
| 86 | for (i = 0; i < count; i++) | 87 | for (i = 0; i < count; i++) |
| 87 | printk(" %02x", ((const u8 *) buf)[i]); | 88 | printk(" %02x", buf[i]); |
| 88 | printk("\n"); | 89 | printk("\n"); |
| 89 | } | 90 | } |
| 90 | 91 | ||
| @@ -92,7 +93,7 @@ static int mt312_read(struct mt312_state *state, const enum mt312_reg_addr reg, | |||
| 92 | } | 93 | } |
| 93 | 94 | ||
| 94 | static int mt312_write(struct mt312_state *state, const enum mt312_reg_addr reg, | 95 | static int mt312_write(struct mt312_state *state, const enum mt312_reg_addr reg, |
| 95 | const void *src, const size_t count) | 96 | const u8 *src, const size_t count) |
| 96 | { | 97 | { |
| 97 | int ret; | 98 | int ret; |
| 98 | u8 buf[count + 1]; | 99 | u8 buf[count + 1]; |
| @@ -102,7 +103,7 @@ static int mt312_write(struct mt312_state *state, const enum mt312_reg_addr reg, | |||
| 102 | int i; | 103 | int i; |
| 103 | dprintk("W(%d):", reg & 0x7f); | 104 | dprintk("W(%d):", reg & 0x7f); |
| 104 | for (i = 0; i < count; i++) | 105 | for (i = 0; i < count; i++) |
| 105 | printk(" %02x", ((const u8 *) src)[i]); | 106 | printk(" %02x", src[i]); |
| 106 | printk("\n"); | 107 | printk("\n"); |
| 107 | } | 108 | } |
| 108 | 109 | ||
| @@ -117,7 +118,7 @@ static int mt312_write(struct mt312_state *state, const enum mt312_reg_addr reg, | |||
| 117 | ret = i2c_transfer(state->i2c, &msg, 1); | 118 | ret = i2c_transfer(state->i2c, &msg, 1); |
| 118 | 119 | ||
| 119 | if (ret != 1) { | 120 | if (ret != 1) { |
| 120 | dprintk("%s: ret == %d\n", __FUNCTION__, ret); | 121 | dprintk("%s: ret == %d\n", __func__, ret); |
| 121 | return -EREMOTEIO; | 122 | return -EREMOTEIO; |
| 122 | } | 123 | } |
| 123 | 124 | ||
| @@ -209,7 +210,7 @@ static int mt312_get_symbol_rate(struct mt312_state *state, u32 *sr) | |||
| 209 | dprintk("sym_rat_op=%d dec_ratio=%d\n", | 210 | dprintk("sym_rat_op=%d dec_ratio=%d\n", |
| 210 | sym_rat_op, dec_ratio); | 211 | sym_rat_op, dec_ratio); |
| 211 | dprintk("*sr(manual) = %lu\n", | 212 | dprintk("*sr(manual) = %lu\n", |
| 212 | (((MT312_PLL_CLK * 8192) / (sym_rat_op + 8192)) * | 213 | (((state->xtal * 8192) / (sym_rat_op + 8192)) * |
| 213 | 2) - dec_ratio); | 214 | 2) - dec_ratio); |
| 214 | } | 215 | } |
| 215 | 216 | ||
| @@ -242,7 +243,7 @@ static int mt312_initfe(struct dvb_frontend *fe) | |||
| 242 | 243 | ||
| 243 | /* wake up */ | 244 | /* wake up */ |
| 244 | ret = mt312_writereg(state, CONFIG, | 245 | ret = mt312_writereg(state, CONFIG, |
| 245 | (state->frequency == 60 ? 0x88 : 0x8c)); | 246 | (state->freq_mult == 6 ? 0x88 : 0x8c)); |
| 246 | if (ret < 0) | 247 | if (ret < 0) |
| 247 | return ret; | 248 | return ret; |
| 248 | 249 | ||
| @@ -265,12 +266,37 @@ static int mt312_initfe(struct dvb_frontend *fe) | |||
| 265 | return ret; | 266 | return ret; |
| 266 | } | 267 | } |
| 267 | 268 | ||
| 269 | switch (state->id) { | ||
| 270 | case ID_ZL10313: | ||
| 271 | /* enable ADC */ | ||
| 272 | ret = mt312_writereg(state, GPP_CTRL, 0x80); | ||
| 273 | if (ret < 0) | ||
| 274 | return ret; | ||
| 275 | |||
| 276 | /* configure ZL10313 for optimal ADC performance */ | ||
| 277 | buf[0] = 0x80; | ||
| 278 | buf[1] = 0xB0; | ||
| 279 | ret = mt312_write(state, HW_CTRL, buf, 2); | ||
| 280 | if (ret < 0) | ||
| 281 | return ret; | ||
| 282 | |||
| 283 | /* enable MPEG output and ADCs */ | ||
| 284 | ret = mt312_writereg(state, HW_CTRL, 0x00); | ||
| 285 | if (ret < 0) | ||
| 286 | return ret; | ||
| 287 | |||
| 288 | ret = mt312_writereg(state, MPEG_CTRL, 0x00); | ||
| 289 | if (ret < 0) | ||
| 290 | return ret; | ||
| 291 | |||
| 292 | break; | ||
| 293 | } | ||
| 294 | |||
| 268 | /* SYS_CLK */ | 295 | /* SYS_CLK */ |
| 269 | buf[0] = mt312_div((state->frequency == 60 ? MT312_LPOWER_SYS_CLK : | 296 | buf[0] = mt312_div(state->xtal * state->freq_mult * 2, 1000000); |
| 270 | MT312_SYS_CLK) * 2, 1000000); | ||
| 271 | 297 | ||
| 272 | /* DISEQC_RATIO */ | 298 | /* DISEQC_RATIO */ |
| 273 | buf[1] = mt312_div(MT312_PLL_CLK, 15000 * 4); | 299 | buf[1] = mt312_div(state->xtal, 22000 * 4); |
| 274 | 300 | ||
| 275 | ret = mt312_write(state, SYS_CLK, buf, sizeof(buf)); | 301 | ret = mt312_write(state, SYS_CLK, buf, sizeof(buf)); |
| 276 | if (ret < 0) | 302 | if (ret < 0) |
| @@ -280,7 +306,17 @@ static int mt312_initfe(struct dvb_frontend *fe) | |||
| 280 | if (ret < 0) | 306 | if (ret < 0) |
| 281 | return ret; | 307 | return ret; |
| 282 | 308 | ||
| 283 | ret = mt312_writereg(state, OP_CTRL, 0x53); | 309 | /* different MOCLK polarity */ |
| 310 | switch (state->id) { | ||
| 311 | case ID_ZL10313: | ||
| 312 | buf[0] = 0x33; | ||
| 313 | break; | ||
| 314 | default: | ||
| 315 | buf[0] = 0x53; | ||
| 316 | break; | ||
| 317 | } | ||
| 318 | |||
| 319 | ret = mt312_writereg(state, OP_CTRL, buf[0]); | ||
| 284 | if (ret < 0) | 320 | if (ret < 0) |
| 285 | return ret; | 321 | return ret; |
| 286 | 322 | ||
| @@ -323,6 +359,9 @@ static int mt312_send_master_cmd(struct dvb_frontend *fe, | |||
| 323 | if (ret < 0) | 359 | if (ret < 0) |
| 324 | return ret; | 360 | return ret; |
| 325 | 361 | ||
| 362 | /* is there a better way to wait for message to be transmitted */ | ||
| 363 | msleep(100); | ||
| 364 | |||
| 326 | /* set DISEQC_MODE[2:0] to zero if a return message is expected */ | 365 | /* set DISEQC_MODE[2:0] to zero if a return message is expected */ |
| 327 | if (c->msg[0] & 0x02) { | 366 | if (c->msg[0] & 0x02) { |
| 328 | ret = mt312_writereg(state, DISEQC_MODE, (diseqc_mode & 0x40)); | 367 | ret = mt312_writereg(state, DISEQC_MODE, (diseqc_mode & 0x40)); |
| @@ -383,11 +422,16 @@ static int mt312_set_voltage(struct dvb_frontend *fe, const fe_sec_voltage_t v) | |||
| 383 | { | 422 | { |
| 384 | struct mt312_state *state = fe->demodulator_priv; | 423 | struct mt312_state *state = fe->demodulator_priv; |
| 385 | const u8 volt_tab[3] = { 0x00, 0x40, 0x00 }; | 424 | const u8 volt_tab[3] = { 0x00, 0x40, 0x00 }; |
| 425 | u8 val; | ||
| 386 | 426 | ||
| 387 | if (v > SEC_VOLTAGE_OFF) | 427 | if (v > SEC_VOLTAGE_OFF) |
| 388 | return -EINVAL; | 428 | return -EINVAL; |
| 389 | 429 | ||
| 390 | return mt312_writereg(state, DISEQC_MODE, volt_tab[v]); | 430 | val = volt_tab[v]; |
| 431 | if (state->config->voltage_inverted) | ||
| 432 | val ^= 0x40; | ||
| 433 | |||
| 434 | return mt312_writereg(state, DISEQC_MODE, val); | ||
| 391 | } | 435 | } |
| 392 | 436 | ||
| 393 | static int mt312_read_status(struct dvb_frontend *fe, fe_status_t *s) | 437 | static int mt312_read_status(struct dvb_frontend *fe, fe_status_t *s) |
| @@ -463,7 +507,7 @@ static int mt312_read_snr(struct dvb_frontend *fe, u16 *snr) | |||
| 463 | int ret; | 507 | int ret; |
| 464 | u8 buf[2]; | 508 | u8 buf[2]; |
| 465 | 509 | ||
| 466 | ret = mt312_read(state, M_SNR_H, &buf, sizeof(buf)); | 510 | ret = mt312_read(state, M_SNR_H, buf, sizeof(buf)); |
| 467 | if (ret < 0) | 511 | if (ret < 0) |
| 468 | return ret; | 512 | return ret; |
| 469 | 513 | ||
| @@ -478,7 +522,7 @@ static int mt312_read_ucblocks(struct dvb_frontend *fe, u32 *ubc) | |||
| 478 | int ret; | 522 | int ret; |
| 479 | u8 buf[2]; | 523 | u8 buf[2]; |
| 480 | 524 | ||
| 481 | ret = mt312_read(state, RS_UBC_H, &buf, sizeof(buf)); | 525 | ret = mt312_read(state, RS_UBC_H, buf, sizeof(buf)); |
| 482 | if (ret < 0) | 526 | if (ret < 0) |
| 483 | return ret; | 527 | return ret; |
| 484 | 528 | ||
| @@ -499,7 +543,7 @@ static int mt312_set_frontend(struct dvb_frontend *fe, | |||
| 499 | { 0x00, 0x01, 0x02, 0x04, 0x3f, 0x08, 0x10, 0x20, 0x3f, 0x3f }; | 543 | { 0x00, 0x01, 0x02, 0x04, 0x3f, 0x08, 0x10, 0x20, 0x3f, 0x3f }; |
| 500 | const u8 inv_tab[3] = { 0x00, 0x40, 0x80 }; | 544 | const u8 inv_tab[3] = { 0x00, 0x40, 0x80 }; |
| 501 | 545 | ||
| 502 | dprintk("%s: Freq %d\n", __FUNCTION__, p->frequency); | 546 | dprintk("%s: Freq %d\n", __func__, p->frequency); |
| 503 | 547 | ||
| 504 | if ((p->frequency < fe->ops.info.frequency_min) | 548 | if ((p->frequency < fe->ops.info.frequency_min) |
| 505 | || (p->frequency > fe->ops.info.frequency_max)) | 549 | || (p->frequency > fe->ops.info.frequency_max)) |
| @@ -532,17 +576,17 @@ static int mt312_set_frontend(struct dvb_frontend *fe, | |||
| 532 | return ret; | 576 | return ret; |
| 533 | if (p->u.qpsk.symbol_rate >= 30000000) { | 577 | if (p->u.qpsk.symbol_rate >= 30000000) { |
| 534 | /* Note that 30MS/s should use 90MHz */ | 578 | /* Note that 30MS/s should use 90MHz */ |
| 535 | if ((config_val & 0x0c) == 0x08) { | 579 | if (state->freq_mult == 6) { |
| 536 | /* We are running 60MHz */ | 580 | /* We are running 60MHz */ |
| 537 | state->frequency = 90; | 581 | state->freq_mult = 9; |
| 538 | ret = mt312_initfe(fe); | 582 | ret = mt312_initfe(fe); |
| 539 | if (ret < 0) | 583 | if (ret < 0) |
| 540 | return ret; | 584 | return ret; |
| 541 | } | 585 | } |
| 542 | } else { | 586 | } else { |
| 543 | if ((config_val & 0x0c) == 0x0C) { | 587 | if (state->freq_mult == 9) { |
| 544 | /* We are running 90MHz */ | 588 | /* We are running 90MHz */ |
| 545 | state->frequency = 60; | 589 | state->freq_mult = 6; |
| 546 | ret = mt312_initfe(fe); | 590 | ret = mt312_initfe(fe); |
| 547 | if (ret < 0) | 591 | if (ret < 0) |
| 548 | return ret; | 592 | return ret; |
| @@ -551,6 +595,7 @@ static int mt312_set_frontend(struct dvb_frontend *fe, | |||
| 551 | break; | 595 | break; |
| 552 | 596 | ||
| 553 | case ID_MT312: | 597 | case ID_MT312: |
| 598 | case ID_ZL10313: | ||
| 554 | break; | 599 | break; |
| 555 | 600 | ||
| 556 | default: | 601 | default: |
| @@ -616,11 +661,29 @@ static int mt312_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) | |||
| 616 | { | 661 | { |
| 617 | struct mt312_state *state = fe->demodulator_priv; | 662 | struct mt312_state *state = fe->demodulator_priv; |
| 618 | 663 | ||
| 619 | if (enable) { | 664 | u8 val = 0x00; |
| 620 | return mt312_writereg(state, GPP_CTRL, 0x40); | 665 | int ret; |
| 621 | } else { | 666 | |
| 622 | return mt312_writereg(state, GPP_CTRL, 0x00); | 667 | switch (state->id) { |
| 668 | case ID_ZL10313: | ||
| 669 | ret = mt312_readreg(state, GPP_CTRL, &val); | ||
| 670 | if (ret < 0) | ||
| 671 | goto error; | ||
| 672 | |||
| 673 | /* preserve this bit to not accidently shutdown ADC */ | ||
| 674 | val &= 0x80; | ||
| 675 | break; | ||
| 623 | } | 676 | } |
| 677 | |||
| 678 | if (enable) | ||
| 679 | val |= 0x40; | ||
| 680 | else | ||
| 681 | val &= ~0x40; | ||
| 682 | |||
| 683 | ret = mt312_writereg(state, GPP_CTRL, val); | ||
| 684 | |||
| 685 | error: | ||
| 686 | return ret; | ||
| 624 | } | 687 | } |
| 625 | 688 | ||
| 626 | static int mt312_sleep(struct dvb_frontend *fe) | 689 | static int mt312_sleep(struct dvb_frontend *fe) |
| @@ -634,6 +697,18 @@ static int mt312_sleep(struct dvb_frontend *fe) | |||
| 634 | if (ret < 0) | 697 | if (ret < 0) |
| 635 | return ret; | 698 | return ret; |
| 636 | 699 | ||
| 700 | if (state->id == ID_ZL10313) { | ||
| 701 | /* reset ADC */ | ||
| 702 | ret = mt312_writereg(state, GPP_CTRL, 0x00); | ||
| 703 | if (ret < 0) | ||
| 704 | return ret; | ||
| 705 | |||
| 706 | /* full shutdown of ADCs, mpeg bus tristated */ | ||
| 707 | ret = mt312_writereg(state, HW_CTRL, 0x0d); | ||
| 708 | if (ret < 0) | ||
| 709 | return ret; | ||
| 710 | } | ||
| 711 | |||
| 637 | ret = mt312_readreg(state, CONFIG, &config); | 712 | ret = mt312_readreg(state, CONFIG, &config); |
| 638 | if (ret < 0) | 713 | if (ret < 0) |
| 639 | return ret; | 714 | return ret; |
| @@ -661,6 +736,7 @@ static void mt312_release(struct dvb_frontend *fe) | |||
| 661 | kfree(state); | 736 | kfree(state); |
| 662 | } | 737 | } |
| 663 | 738 | ||
| 739 | #define MT312_SYS_CLK 90000000UL /* 90 MHz */ | ||
| 664 | static struct dvb_frontend_ops vp310_mt312_ops = { | 740 | static struct dvb_frontend_ops vp310_mt312_ops = { |
| 665 | 741 | ||
| 666 | .info = { | 742 | .info = { |
| @@ -668,8 +744,8 @@ static struct dvb_frontend_ops vp310_mt312_ops = { | |||
| 668 | .type = FE_QPSK, | 744 | .type = FE_QPSK, |
| 669 | .frequency_min = 950000, | 745 | .frequency_min = 950000, |
| 670 | .frequency_max = 2150000, | 746 | .frequency_max = 2150000, |
| 671 | .frequency_stepsize = (MT312_PLL_CLK / 1000) / 128, | 747 | .frequency_stepsize = (MT312_PLL_CLK / 1000) / 128, /* FIXME: adjust freq to real used xtal */ |
| 672 | .symbol_rate_min = MT312_SYS_CLK / 128, | 748 | .symbol_rate_min = MT312_SYS_CLK / 128, /* FIXME as above */ |
| 673 | .symbol_rate_max = MT312_SYS_CLK / 2, | 749 | .symbol_rate_max = MT312_SYS_CLK / 2, |
| 674 | .caps = | 750 | .caps = |
| 675 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | | 751 | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | |
| @@ -726,14 +802,21 @@ struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config, | |||
| 726 | switch (state->id) { | 802 | switch (state->id) { |
| 727 | case ID_VP310: | 803 | case ID_VP310: |
| 728 | strcpy(state->frontend.ops.info.name, "Zarlink VP310 DVB-S"); | 804 | strcpy(state->frontend.ops.info.name, "Zarlink VP310 DVB-S"); |
| 729 | state->frequency = 90; | 805 | state->xtal = MT312_PLL_CLK; |
| 806 | state->freq_mult = 9; | ||
| 730 | break; | 807 | break; |
| 731 | case ID_MT312: | 808 | case ID_MT312: |
| 732 | strcpy(state->frontend.ops.info.name, "Zarlink MT312 DVB-S"); | 809 | strcpy(state->frontend.ops.info.name, "Zarlink MT312 DVB-S"); |
| 733 | state->frequency = 60; | 810 | state->xtal = MT312_PLL_CLK; |
| 811 | state->freq_mult = 6; | ||
| 812 | break; | ||
| 813 | case ID_ZL10313: | ||
| 814 | strcpy(state->frontend.ops.info.name, "Zarlink ZL10313 DVB-S"); | ||
| 815 | state->xtal = MT312_PLL_CLK_10_111; | ||
| 816 | state->freq_mult = 9; | ||
| 734 | break; | 817 | break; |
| 735 | default: | 818 | default: |
| 736 | printk(KERN_WARNING "Only Zarlink VP310/MT312" | 819 | printk(KERN_WARNING "Only Zarlink VP310/MT312/ZL10313" |
| 737 | " are supported chips.\n"); | 820 | " are supported chips.\n"); |
| 738 | goto error; | 821 | goto error; |
| 739 | } | 822 | } |
| @@ -749,7 +832,7 @@ EXPORT_SYMBOL(vp310_mt312_attach); | |||
| 749 | module_param(debug, int, 0644); | 832 | module_param(debug, int, 0644); |
| 750 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | 833 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); |
| 751 | 834 | ||
| 752 | MODULE_DESCRIPTION("Zarlink VP310/MT312 DVB-S Demodulator driver"); | 835 | MODULE_DESCRIPTION("Zarlink VP310/MT312/ZL10313 DVB-S Demodulator driver"); |
| 753 | MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>"); | 836 | MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>"); |
| 754 | MODULE_LICENSE("GPL"); | 837 | MODULE_LICENSE("GPL"); |
| 755 | 838 | ||
diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h index f17cb93ba9ba..96338f0c4dd4 100644 --- a/drivers/media/dvb/frontends/mt312.h +++ b/drivers/media/dvb/frontends/mt312.h | |||
| @@ -31,6 +31,9 @@ | |||
| 31 | struct mt312_config { | 31 | struct mt312_config { |
| 32 | /* the demodulator's i2c address */ | 32 | /* the demodulator's i2c address */ |
| 33 | u8 demod_address; | 33 | u8 demod_address; |
| 34 | |||
| 35 | /* inverted voltage setting */ | ||
| 36 | int voltage_inverted:1; | ||
| 34 | }; | 37 | }; |
| 35 | 38 | ||
| 36 | #if defined(CONFIG_DVB_MT312) || (defined(CONFIG_DVB_MT312_MODULE) && defined(MODULE)) | 39 | #if defined(CONFIG_DVB_MT312) || (defined(CONFIG_DVB_MT312_MODULE) && defined(MODULE)) |
| @@ -40,7 +43,7 @@ struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config, | |||
| 40 | static inline struct dvb_frontend *vp310_mt312_attach( | 43 | static inline struct dvb_frontend *vp310_mt312_attach( |
| 41 | const struct mt312_config *config, struct i2c_adapter *i2c) | 44 | const struct mt312_config *config, struct i2c_adapter *i2c) |
| 42 | { | 45 | { |
| 43 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 46 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 44 | return NULL; | 47 | return NULL; |
| 45 | } | 48 | } |
| 46 | #endif /* CONFIG_DVB_MT312 */ | 49 | #endif /* CONFIG_DVB_MT312 */ |
diff --git a/drivers/media/dvb/frontends/mt312_priv.h b/drivers/media/dvb/frontends/mt312_priv.h index 5e0b95b5337b..a3959f94d639 100644 --- a/drivers/media/dvb/frontends/mt312_priv.h +++ b/drivers/media/dvb/frontends/mt312_priv.h | |||
| @@ -110,6 +110,8 @@ enum mt312_reg_addr { | |||
| 110 | VIT_ERRPER_H = 83, | 110 | VIT_ERRPER_H = 83, |
| 111 | VIT_ERRPER_M = 84, | 111 | VIT_ERRPER_M = 84, |
| 112 | VIT_ERRPER_L = 85, | 112 | VIT_ERRPER_L = 85, |
| 113 | HW_CTRL = 84, /* ZL10313 only */ | ||
| 114 | MPEG_CTRL = 85, /* ZL10313 only */ | ||
| 113 | VIT_SETUP = 86, | 115 | VIT_SETUP = 86, |
| 114 | VIT_REF0 = 87, | 116 | VIT_REF0 = 87, |
| 115 | VIT_REF1 = 88, | 117 | VIT_REF1 = 88, |
| @@ -156,7 +158,8 @@ enum mt312_reg_addr { | |||
| 156 | 158 | ||
| 157 | enum mt312_model_id { | 159 | enum mt312_model_id { |
| 158 | ID_VP310 = 1, | 160 | ID_VP310 = 1, |
| 159 | ID_MT312 = 3 | 161 | ID_MT312 = 3, |
| 162 | ID_ZL10313 = 5, | ||
| 160 | }; | 163 | }; |
| 161 | 164 | ||
| 162 | #endif /* DVB_FRONTENDS_MT312_PRIV */ | 165 | #endif /* DVB_FRONTENDS_MT312_PRIV */ |
diff --git a/drivers/media/dvb/frontends/mt352.c b/drivers/media/dvb/frontends/mt352.c index 7cd190b6f015..beba5aa0db50 100644 --- a/drivers/media/dvb/frontends/mt352.c +++ b/drivers/media/dvb/frontends/mt352.c | |||
| @@ -95,7 +95,7 @@ static int mt352_read_register(struct mt352_state* state, u8 reg) | |||
| 95 | 95 | ||
| 96 | if (ret != 2) { | 96 | if (ret != 2) { |
| 97 | printk("%s: readreg error (reg=%d, ret==%i)\n", | 97 | printk("%s: readreg error (reg=%d, ret==%i)\n", |
| 98 | __FUNCTION__, reg, ret); | 98 | __func__, reg, ret); |
| 99 | return ret; | 99 | return ret; |
| 100 | } | 100 | } |
| 101 | 101 | ||
| @@ -135,7 +135,7 @@ static void mt352_calc_nominal_rate(struct mt352_state* state, | |||
| 135 | value = 64 * bw * (1<<16) / (7 * 8); | 135 | value = 64 * bw * (1<<16) / (7 * 8); |
| 136 | value = value * 1000 / adc_clock; | 136 | value = value * 1000 / adc_clock; |
| 137 | dprintk("%s: bw %d, adc_clock %d => 0x%x\n", | 137 | dprintk("%s: bw %d, adc_clock %d => 0x%x\n", |
| 138 | __FUNCTION__, bw, adc_clock, value); | 138 | __func__, bw, adc_clock, value); |
| 139 | buf[0] = msb(value); | 139 | buf[0] = msb(value); |
| 140 | buf[1] = lsb(value); | 140 | buf[1] = lsb(value); |
| 141 | } | 141 | } |
| @@ -161,7 +161,7 @@ static void mt352_calc_input_freq(struct mt352_state* state, | |||
| 161 | } | 161 | } |
| 162 | value = -16374 * ife / adc_clock; | 162 | value = -16374 * ife / adc_clock; |
| 163 | dprintk("%s: if2 %d, ife %d, adc_clock %d => %d / 0x%x\n", | 163 | dprintk("%s: if2 %d, ife %d, adc_clock %d => %d / 0x%x\n", |
| 164 | __FUNCTION__, if2, ife, adc_clock, value, value & 0x3fff); | 164 | __func__, if2, ife, adc_clock, value, value & 0x3fff); |
| 165 | buf[0] = msb(value); | 165 | buf[0] = msb(value); |
| 166 | buf[1] = lsb(value); | 166 | buf[1] = lsb(value); |
| 167 | } | 167 | } |
| @@ -521,7 +521,7 @@ static int mt352_init(struct dvb_frontend* fe) | |||
| 521 | 521 | ||
| 522 | static u8 mt352_reset_attach [] = { RESET, 0xC0 }; | 522 | static u8 mt352_reset_attach [] = { RESET, 0xC0 }; |
| 523 | 523 | ||
| 524 | dprintk("%s: hello\n",__FUNCTION__); | 524 | dprintk("%s: hello\n",__func__); |
| 525 | 525 | ||
| 526 | if ((mt352_read_register(state, CLOCK_CTL) & 0x10) == 0 || | 526 | if ((mt352_read_register(state, CLOCK_CTL) & 0x10) == 0 || |
| 527 | (mt352_read_register(state, CONFIG) & 0x20) == 0) { | 527 | (mt352_read_register(state, CONFIG) & 0x20) == 0) { |
diff --git a/drivers/media/dvb/frontends/mt352.h b/drivers/media/dvb/frontends/mt352.h index e9964081fd84..595092f9f0c4 100644 --- a/drivers/media/dvb/frontends/mt352.h +++ b/drivers/media/dvb/frontends/mt352.h | |||
| @@ -58,7 +58,7 @@ extern struct dvb_frontend* mt352_attach(const struct mt352_config* config, | |||
| 58 | static inline struct dvb_frontend* mt352_attach(const struct mt352_config* config, | 58 | static inline struct dvb_frontend* mt352_attach(const struct mt352_config* config, |
| 59 | struct i2c_adapter* i2c) | 59 | struct i2c_adapter* i2c) |
| 60 | { | 60 | { |
| 61 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 61 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 62 | return NULL; | 62 | return NULL; |
| 63 | } | 63 | } |
| 64 | #endif // CONFIG_DVB_MT352 | 64 | #endif // CONFIG_DVB_MT352 |
diff --git a/drivers/media/dvb/frontends/nxt200x.c b/drivers/media/dvb/frontends/nxt200x.c index fcf964fe1d6b..23d022852543 100644 --- a/drivers/media/dvb/frontends/nxt200x.c +++ b/drivers/media/dvb/frontends/nxt200x.c | |||
| @@ -74,7 +74,7 @@ static int i2c_writebytes (struct nxt200x_state* state, u8 addr, u8 *buf, u8 len | |||
| 74 | 74 | ||
| 75 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { | 75 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { |
| 76 | printk (KERN_WARNING "nxt200x: %s: i2c write error (addr 0x%02x, err == %i)\n", | 76 | printk (KERN_WARNING "nxt200x: %s: i2c write error (addr 0x%02x, err == %i)\n", |
| 77 | __FUNCTION__, addr, err); | 77 | __func__, addr, err); |
| 78 | return -EREMOTEIO; | 78 | return -EREMOTEIO; |
| 79 | } | 79 | } |
| 80 | return 0; | 80 | return 0; |
| @@ -87,7 +87,7 @@ static u8 i2c_readbytes (struct nxt200x_state* state, u8 addr, u8* buf, u8 len) | |||
| 87 | 87 | ||
| 88 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { | 88 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { |
| 89 | printk (KERN_WARNING "nxt200x: %s: i2c read error (addr 0x%02x, err == %i)\n", | 89 | printk (KERN_WARNING "nxt200x: %s: i2c read error (addr 0x%02x, err == %i)\n", |
| 90 | __FUNCTION__, addr, err); | 90 | __func__, addr, err); |
| 91 | return -EREMOTEIO; | 91 | return -EREMOTEIO; |
| 92 | } | 92 | } |
| 93 | return 0; | 93 | return 0; |
| @@ -104,7 +104,7 @@ static int nxt200x_writebytes (struct nxt200x_state* state, u8 reg, u8 *buf, u8 | |||
| 104 | 104 | ||
| 105 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { | 105 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { |
| 106 | printk (KERN_WARNING "nxt200x: %s: i2c write error (addr 0x%02x, err == %i)\n", | 106 | printk (KERN_WARNING "nxt200x: %s: i2c write error (addr 0x%02x, err == %i)\n", |
| 107 | __FUNCTION__, state->config->demod_address, err); | 107 | __func__, state->config->demod_address, err); |
| 108 | return -EREMOTEIO; | 108 | return -EREMOTEIO; |
| 109 | } | 109 | } |
| 110 | return 0; | 110 | return 0; |
| @@ -121,7 +121,7 @@ static u8 nxt200x_readbytes (struct nxt200x_state* state, u8 reg, u8* buf, u8 le | |||
| 121 | 121 | ||
| 122 | if ((err = i2c_transfer (state->i2c, msg, 2)) != 2) { | 122 | if ((err = i2c_transfer (state->i2c, msg, 2)) != 2) { |
| 123 | printk (KERN_WARNING "nxt200x: %s: i2c read error (addr 0x%02x, err == %i)\n", | 123 | printk (KERN_WARNING "nxt200x: %s: i2c read error (addr 0x%02x, err == %i)\n", |
| 124 | __FUNCTION__, state->config->demod_address, err); | 124 | __func__, state->config->demod_address, err); |
| 125 | return -EREMOTEIO; | 125 | return -EREMOTEIO; |
| 126 | } | 126 | } |
| 127 | return 0; | 127 | return 0; |
| @@ -146,7 +146,7 @@ static u16 nxt200x_crc(u16 crc, u8 c) | |||
| 146 | static int nxt200x_writereg_multibyte (struct nxt200x_state* state, u8 reg, u8* data, u8 len) | 146 | static int nxt200x_writereg_multibyte (struct nxt200x_state* state, u8 reg, u8* data, u8 len) |
| 147 | { | 147 | { |
| 148 | u8 attr, len2, buf; | 148 | u8 attr, len2, buf; |
| 149 | dprintk("%s\n", __FUNCTION__); | 149 | dprintk("%s\n", __func__); |
| 150 | 150 | ||
| 151 | /* set mutli register register */ | 151 | /* set mutli register register */ |
| 152 | nxt200x_writebytes(state, 0x35, ®, 1); | 152 | nxt200x_writebytes(state, 0x35, ®, 1); |
| @@ -207,7 +207,7 @@ static int nxt200x_readreg_multibyte (struct nxt200x_state* state, u8 reg, u8* d | |||
| 207 | { | 207 | { |
| 208 | int i; | 208 | int i; |
| 209 | u8 buf, len2, attr; | 209 | u8 buf, len2, attr; |
| 210 | dprintk("%s\n", __FUNCTION__); | 210 | dprintk("%s\n", __func__); |
| 211 | 211 | ||
| 212 | /* set mutli register register */ | 212 | /* set mutli register register */ |
| 213 | nxt200x_writebytes(state, 0x35, ®, 1); | 213 | nxt200x_writebytes(state, 0x35, ®, 1); |
| @@ -254,7 +254,7 @@ static int nxt200x_readreg_multibyte (struct nxt200x_state* state, u8 reg, u8* d | |||
| 254 | static void nxt200x_microcontroller_stop (struct nxt200x_state* state) | 254 | static void nxt200x_microcontroller_stop (struct nxt200x_state* state) |
| 255 | { | 255 | { |
| 256 | u8 buf, stopval, counter = 0; | 256 | u8 buf, stopval, counter = 0; |
| 257 | dprintk("%s\n", __FUNCTION__); | 257 | dprintk("%s\n", __func__); |
| 258 | 258 | ||
| 259 | /* set correct stop value */ | 259 | /* set correct stop value */ |
| 260 | switch (state->demod_chip) { | 260 | switch (state->demod_chip) { |
| @@ -287,7 +287,7 @@ static void nxt200x_microcontroller_stop (struct nxt200x_state* state) | |||
| 287 | static void nxt200x_microcontroller_start (struct nxt200x_state* state) | 287 | static void nxt200x_microcontroller_start (struct nxt200x_state* state) |
| 288 | { | 288 | { |
| 289 | u8 buf; | 289 | u8 buf; |
| 290 | dprintk("%s\n", __FUNCTION__); | 290 | dprintk("%s\n", __func__); |
| 291 | 291 | ||
| 292 | buf = 0x00; | 292 | buf = 0x00; |
| 293 | nxt200x_writebytes(state, 0x22, &buf, 1); | 293 | nxt200x_writebytes(state, 0x22, &buf, 1); |
| @@ -297,7 +297,7 @@ static void nxt2004_microcontroller_init (struct nxt200x_state* state) | |||
| 297 | { | 297 | { |
| 298 | u8 buf[9]; | 298 | u8 buf[9]; |
| 299 | u8 counter = 0; | 299 | u8 counter = 0; |
| 300 | dprintk("%s\n", __FUNCTION__); | 300 | dprintk("%s\n", __func__); |
| 301 | 301 | ||
| 302 | buf[0] = 0x00; | 302 | buf[0] = 0x00; |
| 303 | nxt200x_writebytes(state, 0x2b, buf, 1); | 303 | nxt200x_writebytes(state, 0x2b, buf, 1); |
| @@ -328,7 +328,7 @@ static int nxt200x_writetuner (struct nxt200x_state* state, u8* data) | |||
| 328 | { | 328 | { |
| 329 | u8 buf, count = 0; | 329 | u8 buf, count = 0; |
| 330 | 330 | ||
| 331 | dprintk("%s\n", __FUNCTION__); | 331 | dprintk("%s\n", __func__); |
| 332 | 332 | ||
| 333 | dprintk("Tuner Bytes: %02X %02X %02X %02X\n", data[1], data[2], data[3], data[4]); | 333 | dprintk("Tuner Bytes: %02X %02X %02X %02X\n", data[1], data[2], data[3], data[4]); |
| 334 | 334 | ||
| @@ -387,7 +387,7 @@ static int nxt200x_writetuner (struct nxt200x_state* state, u8* data) | |||
| 387 | static void nxt200x_agc_reset(struct nxt200x_state* state) | 387 | static void nxt200x_agc_reset(struct nxt200x_state* state) |
| 388 | { | 388 | { |
| 389 | u8 buf; | 389 | u8 buf; |
| 390 | dprintk("%s\n", __FUNCTION__); | 390 | dprintk("%s\n", __func__); |
| 391 | 391 | ||
| 392 | switch (state->demod_chip) { | 392 | switch (state->demod_chip) { |
| 393 | case NXT2002: | 393 | case NXT2002: |
| @@ -416,7 +416,7 @@ static int nxt2002_load_firmware (struct dvb_frontend* fe, const struct firmware | |||
| 416 | u8 buf[3], written = 0, chunkpos = 0; | 416 | u8 buf[3], written = 0, chunkpos = 0; |
| 417 | u16 rambase, position, crc = 0; | 417 | u16 rambase, position, crc = 0; |
| 418 | 418 | ||
| 419 | dprintk("%s\n", __FUNCTION__); | 419 | dprintk("%s\n", __func__); |
| 420 | dprintk("Firmware is %zu bytes\n", fw->size); | 420 | dprintk("Firmware is %zu bytes\n", fw->size); |
| 421 | 421 | ||
| 422 | /* Get the RAM base for this nxt2002 */ | 422 | /* Get the RAM base for this nxt2002 */ |
| @@ -483,7 +483,7 @@ static int nxt2004_load_firmware (struct dvb_frontend* fe, const struct firmware | |||
| 483 | u8 buf[3]; | 483 | u8 buf[3]; |
| 484 | u16 rambase, position, crc=0; | 484 | u16 rambase, position, crc=0; |
| 485 | 485 | ||
| 486 | dprintk("%s\n", __FUNCTION__); | 486 | dprintk("%s\n", __func__); |
| 487 | dprintk("Firmware is %zu bytes\n", fw->size); | 487 | dprintk("Firmware is %zu bytes\n", fw->size); |
| 488 | 488 | ||
| 489 | /* set rambase */ | 489 | /* set rambase */ |
diff --git a/drivers/media/dvb/frontends/nxt200x.h b/drivers/media/dvb/frontends/nxt200x.h index bb0ef58d7972..f3c84583770f 100644 --- a/drivers/media/dvb/frontends/nxt200x.h +++ b/drivers/media/dvb/frontends/nxt200x.h | |||
| @@ -49,7 +49,7 @@ extern struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config, | |||
| 49 | static inline struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config, | 49 | static inline struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config, |
| 50 | struct i2c_adapter* i2c) | 50 | struct i2c_adapter* i2c) |
| 51 | { | 51 | { |
| 52 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 52 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 53 | return NULL; | 53 | return NULL; |
| 54 | } | 54 | } |
| 55 | #endif // CONFIG_DVB_NXT200X | 55 | #endif // CONFIG_DVB_NXT200X |
diff --git a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c index d313d7dcf386..0eef22dbf8a0 100644 --- a/drivers/media/dvb/frontends/nxt6000.c +++ b/drivers/media/dvb/frontends/nxt6000.c | |||
| @@ -38,7 +38,7 @@ struct nxt6000_state { | |||
| 38 | struct dvb_frontend frontend; | 38 | struct dvb_frontend frontend; |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | static int debug = 0; | 41 | static int debug; |
| 42 | #define dprintk if (debug) printk | 42 | #define dprintk if (debug) printk |
| 43 | 43 | ||
| 44 | static int nxt6000_writereg(struct nxt6000_state* state, u8 reg, u8 data) | 44 | static int nxt6000_writereg(struct nxt6000_state* state, u8 reg, u8 data) |
diff --git a/drivers/media/dvb/frontends/nxt6000.h b/drivers/media/dvb/frontends/nxt6000.h index 13d22518356e..878eb38a075e 100644 --- a/drivers/media/dvb/frontends/nxt6000.h +++ b/drivers/media/dvb/frontends/nxt6000.h | |||
| @@ -40,7 +40,7 @@ extern struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, | |||
| 40 | static inline struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, | 40 | static inline struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config, |
| 41 | struct i2c_adapter* i2c) | 41 | struct i2c_adapter* i2c) |
| 42 | { | 42 | { |
| 43 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 43 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 44 | return NULL; | 44 | return NULL; |
| 45 | } | 45 | } |
| 46 | #endif // CONFIG_DVB_NXT6000 | 46 | #endif // CONFIG_DVB_NXT6000 |
diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c index 8ffb8daca031..c7b5785f81f2 100644 --- a/drivers/media/dvb/frontends/or51132.c +++ b/drivers/media/dvb/frontends/or51132.c | |||
| @@ -419,7 +419,7 @@ static int or51132_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 419 | *status = 0; | 419 | *status = 0; |
| 420 | return -EREMOTEIO; | 420 | return -EREMOTEIO; |
| 421 | } | 421 | } |
| 422 | dprintk("%s: read_status %04x\n", __FUNCTION__, reg); | 422 | dprintk("%s: read_status %04x\n", __func__, reg); |
| 423 | 423 | ||
| 424 | if (reg & 0x0100) /* Receiver Lock */ | 424 | if (reg & 0x0100) /* Receiver Lock */ |
| 425 | *status = FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI| | 425 | *status = FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI| |
| @@ -504,14 +504,14 @@ start: | |||
| 504 | if (retry--) goto start; | 504 | if (retry--) goto start; |
| 505 | return -EREMOTEIO; | 505 | return -EREMOTEIO; |
| 506 | } | 506 | } |
| 507 | dprintk("%s: modulation %02x, NTSC rej O%s\n", __FUNCTION__, | 507 | dprintk("%s: modulation %02x, NTSC rej O%s\n", __func__, |
| 508 | reg&0xff, reg&0x1000?"n":"ff"); | 508 | reg&0xff, reg&0x1000?"n":"ff"); |
| 509 | 509 | ||
| 510 | /* Calculate SNR using noise, c, and NTSC rejection correction */ | 510 | /* Calculate SNR using noise, c, and NTSC rejection correction */ |
| 511 | state->snr = calculate_snr(noise, c) - usK; | 511 | state->snr = calculate_snr(noise, c) - usK; |
| 512 | *snr = (state->snr) >> 16; | 512 | *snr = (state->snr) >> 16; |
| 513 | 513 | ||
| 514 | dprintk("%s: noise = 0x%08x, snr = %d.%02d dB\n", __FUNCTION__, noise, | 514 | dprintk("%s: noise = 0x%08x, snr = %d.%02d dB\n", __func__, noise, |
| 515 | state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16); | 515 | state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16); |
| 516 | 516 | ||
| 517 | return 0; | 517 | return 0; |
diff --git a/drivers/media/dvb/frontends/or51132.h b/drivers/media/dvb/frontends/or51132.h index add24f0a743b..1b8e04d973c8 100644 --- a/drivers/media/dvb/frontends/or51132.h +++ b/drivers/media/dvb/frontends/or51132.h | |||
| @@ -41,7 +41,7 @@ extern struct dvb_frontend* or51132_attach(const struct or51132_config* config, | |||
| 41 | static inline struct dvb_frontend* or51132_attach(const struct or51132_config* config, | 41 | static inline struct dvb_frontend* or51132_attach(const struct or51132_config* config, |
| 42 | struct i2c_adapter* i2c) | 42 | struct i2c_adapter* i2c) |
| 43 | { | 43 | { |
| 44 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 44 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 45 | return NULL; | 45 | return NULL; |
| 46 | } | 46 | } |
| 47 | #endif // CONFIG_DVB_OR51132 | 47 | #endif // CONFIG_DVB_OR51132 |
diff --git a/drivers/media/dvb/frontends/or51211.c b/drivers/media/dvb/frontends/or51211.c index 6a6b0d727c6f..7eaa4765593f 100644 --- a/drivers/media/dvb/frontends/or51211.c +++ b/drivers/media/dvb/frontends/or51211.c | |||
| @@ -307,19 +307,19 @@ static int or51211_read_snr(struct dvb_frontend* fe, u16* snr) | |||
| 307 | 307 | ||
| 308 | if (i2c_writebytes(state,state->config->demod_address,snd_buf,3)) { | 308 | if (i2c_writebytes(state,state->config->demod_address,snd_buf,3)) { |
| 309 | printk(KERN_WARNING "%s: error writing snr reg\n", | 309 | printk(KERN_WARNING "%s: error writing snr reg\n", |
| 310 | __FUNCTION__); | 310 | __func__); |
| 311 | return -1; | 311 | return -1; |
| 312 | } | 312 | } |
| 313 | if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) { | 313 | if (i2c_readbytes(state,state->config->demod_address,rec_buf,2)) { |
| 314 | printk(KERN_WARNING "%s: read_status read error\n", | 314 | printk(KERN_WARNING "%s: read_status read error\n", |
| 315 | __FUNCTION__); | 315 | __func__); |
| 316 | return -1; | 316 | return -1; |
| 317 | } | 317 | } |
| 318 | 318 | ||
| 319 | state->snr = calculate_snr(rec_buf[0], 89599047); | 319 | state->snr = calculate_snr(rec_buf[0], 89599047); |
| 320 | *snr = (state->snr) >> 16; | 320 | *snr = (state->snr) >> 16; |
| 321 | 321 | ||
| 322 | dprintk("%s: noise = 0x%02x, snr = %d.%02d dB\n", __FUNCTION__, rec_buf[0], | 322 | dprintk("%s: noise = 0x%02x, snr = %d.%02d dB\n", __func__, rec_buf[0], |
| 323 | state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16); | 323 | state->snr >> 24, (((state->snr>>8) & 0xffff) * 100) >> 16); |
| 324 | 324 | ||
| 325 | return 0; | 325 | return 0; |
diff --git a/drivers/media/dvb/frontends/or51211.h b/drivers/media/dvb/frontends/or51211.h index 8aad8402d615..3ce0508b898e 100644 --- a/drivers/media/dvb/frontends/or51211.h +++ b/drivers/media/dvb/frontends/or51211.h | |||
| @@ -44,7 +44,7 @@ extern struct dvb_frontend* or51211_attach(const struct or51211_config* config, | |||
| 44 | static inline struct dvb_frontend* or51211_attach(const struct or51211_config* config, | 44 | static inline struct dvb_frontend* or51211_attach(const struct or51211_config* config, |
| 45 | struct i2c_adapter* i2c) | 45 | struct i2c_adapter* i2c) |
| 46 | { | 46 | { |
| 47 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 47 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 48 | return NULL; | 48 | return NULL; |
| 49 | } | 49 | } |
| 50 | #endif // CONFIG_DVB_OR51211 | 50 | #endif // CONFIG_DVB_OR51211 |
diff --git a/drivers/media/dvb/frontends/qt1010.h b/drivers/media/dvb/frontends/qt1010.h index 3ab4aa045c36..cff6a7ca5380 100644 --- a/drivers/media/dvb/frontends/qt1010.h +++ b/drivers/media/dvb/frontends/qt1010.h | |||
| @@ -45,7 +45,7 @@ static inline struct dvb_frontend *qt1010_attach(struct dvb_frontend *fe, | |||
| 45 | struct i2c_adapter *i2c, | 45 | struct i2c_adapter *i2c, |
| 46 | struct qt1010_config *cfg) | 46 | struct qt1010_config *cfg) |
| 47 | { | 47 | { |
| 48 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 48 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 49 | return NULL; | 49 | return NULL; |
| 50 | } | 50 | } |
| 51 | #endif // CONFIG_DVB_TUNER_QT1010 | 51 | #endif // CONFIG_DVB_TUNER_QT1010 |
diff --git a/drivers/media/dvb/frontends/s5h1409.c b/drivers/media/dvb/frontends/s5h1409.c index 1a4d8319773c..b999ec424ff7 100644 --- a/drivers/media/dvb/frontends/s5h1409.c +++ b/drivers/media/dvb/frontends/s5h1409.c | |||
| @@ -48,7 +48,7 @@ struct s5h1409_state { | |||
| 48 | u32 qam_state; | 48 | u32 qam_state; |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | static int debug = 0; | 51 | static int debug; |
| 52 | #define dprintk if (debug) printk | 52 | #define dprintk if (debug) printk |
| 53 | 53 | ||
| 54 | /* Register values to initialise the demod, this will set VSB by default */ | 54 | /* Register values to initialise the demod, this will set VSB by default */ |
| @@ -312,7 +312,7 @@ static int s5h1409_writereg(struct s5h1409_state* state, u8 reg, u16 data) | |||
| 312 | 312 | ||
| 313 | if (ret != 1) | 313 | if (ret != 1) |
| 314 | printk("%s: writereg error (reg == 0x%02x, val == 0x%04x, " | 314 | printk("%s: writereg error (reg == 0x%02x, val == 0x%04x, " |
| 315 | "ret == %i)\n", __FUNCTION__, reg, data, ret); | 315 | "ret == %i)\n", __func__, reg, data, ret); |
| 316 | 316 | ||
| 317 | return (ret != 1) ? -1 : 0; | 317 | return (ret != 1) ? -1 : 0; |
| 318 | } | 318 | } |
| @@ -332,7 +332,7 @@ static u16 s5h1409_readreg(struct s5h1409_state* state, u8 reg) | |||
| 332 | ret = i2c_transfer(state->i2c, msg, 2); | 332 | ret = i2c_transfer(state->i2c, msg, 2); |
| 333 | 333 | ||
| 334 | if (ret != 2) | 334 | if (ret != 2) |
| 335 | printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret); | 335 | printk("%s: readreg error (ret == %i)\n", __func__, ret); |
| 336 | return (b1[0] << 8) | b1[1]; | 336 | return (b1[0] << 8) | b1[1]; |
| 337 | } | 337 | } |
| 338 | 338 | ||
| @@ -340,7 +340,7 @@ static int s5h1409_softreset(struct dvb_frontend* fe) | |||
| 340 | { | 340 | { |
| 341 | struct s5h1409_state* state = fe->demodulator_priv; | 341 | struct s5h1409_state* state = fe->demodulator_priv; |
| 342 | 342 | ||
| 343 | dprintk("%s()\n", __FUNCTION__); | 343 | dprintk("%s()\n", __func__); |
| 344 | 344 | ||
| 345 | s5h1409_writereg(state, 0xf5, 0); | 345 | s5h1409_writereg(state, 0xf5, 0); |
| 346 | s5h1409_writereg(state, 0xf5, 1); | 346 | s5h1409_writereg(state, 0xf5, 1); |
| @@ -356,7 +356,7 @@ static int s5h1409_set_if_freq(struct dvb_frontend* fe, int KHz) | |||
| 356 | { | 356 | { |
| 357 | struct s5h1409_state* state = fe->demodulator_priv; | 357 | struct s5h1409_state* state = fe->demodulator_priv; |
| 358 | 358 | ||
| 359 | dprintk("%s(%d KHz)\n", __FUNCTION__, KHz); | 359 | dprintk("%s(%d KHz)\n", __func__, KHz); |
| 360 | 360 | ||
| 361 | switch (KHz) { | 361 | switch (KHz) { |
| 362 | case 4000: | 362 | case 4000: |
| @@ -381,7 +381,7 @@ static int s5h1409_set_spectralinversion(struct dvb_frontend* fe, int inverted) | |||
| 381 | { | 381 | { |
| 382 | struct s5h1409_state* state = fe->demodulator_priv; | 382 | struct s5h1409_state* state = fe->demodulator_priv; |
| 383 | 383 | ||
| 384 | dprintk("%s(%d)\n", __FUNCTION__, inverted); | 384 | dprintk("%s(%d)\n", __func__, inverted); |
| 385 | 385 | ||
| 386 | if(inverted == 1) | 386 | if(inverted == 1) |
| 387 | return s5h1409_writereg(state, 0x1b, 0x1101); /* Inverted */ | 387 | return s5h1409_writereg(state, 0x1b, 0x1101); /* Inverted */ |
| @@ -394,25 +394,25 @@ static int s5h1409_enable_modulation(struct dvb_frontend* fe, | |||
| 394 | { | 394 | { |
| 395 | struct s5h1409_state* state = fe->demodulator_priv; | 395 | struct s5h1409_state* state = fe->demodulator_priv; |
| 396 | 396 | ||
| 397 | dprintk("%s(0x%08x)\n", __FUNCTION__, m); | 397 | dprintk("%s(0x%08x)\n", __func__, m); |
| 398 | 398 | ||
| 399 | switch(m) { | 399 | switch(m) { |
| 400 | case VSB_8: | 400 | case VSB_8: |
| 401 | dprintk("%s() VSB_8\n", __FUNCTION__); | 401 | dprintk("%s() VSB_8\n", __func__); |
| 402 | if (state->if_freq != S5H1409_VSB_IF_FREQ) | 402 | if (state->if_freq != S5H1409_VSB_IF_FREQ) |
| 403 | s5h1409_set_if_freq(fe, S5H1409_VSB_IF_FREQ); | 403 | s5h1409_set_if_freq(fe, S5H1409_VSB_IF_FREQ); |
| 404 | s5h1409_writereg(state, 0xf4, 0); | 404 | s5h1409_writereg(state, 0xf4, 0); |
| 405 | break; | 405 | break; |
| 406 | case QAM_64: | 406 | case QAM_64: |
| 407 | case QAM_256: | 407 | case QAM_256: |
| 408 | dprintk("%s() QAM_AUTO (64/256)\n", __FUNCTION__); | 408 | dprintk("%s() QAM_AUTO (64/256)\n", __func__); |
| 409 | if (state->if_freq != S5H1409_QAM_IF_FREQ) | 409 | if (state->if_freq != S5H1409_QAM_IF_FREQ) |
| 410 | s5h1409_set_if_freq(fe, S5H1409_QAM_IF_FREQ); | 410 | s5h1409_set_if_freq(fe, S5H1409_QAM_IF_FREQ); |
| 411 | s5h1409_writereg(state, 0xf4, 1); | 411 | s5h1409_writereg(state, 0xf4, 1); |
| 412 | s5h1409_writereg(state, 0x85, 0x110); | 412 | s5h1409_writereg(state, 0x85, 0x110); |
| 413 | break; | 413 | break; |
| 414 | default: | 414 | default: |
| 415 | dprintk("%s() Invalid modulation\n", __FUNCTION__); | 415 | dprintk("%s() Invalid modulation\n", __func__); |
| 416 | return -EINVAL; | 416 | return -EINVAL; |
| 417 | } | 417 | } |
| 418 | 418 | ||
| @@ -426,7 +426,7 @@ static int s5h1409_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) | |||
| 426 | { | 426 | { |
| 427 | struct s5h1409_state* state = fe->demodulator_priv; | 427 | struct s5h1409_state* state = fe->demodulator_priv; |
| 428 | 428 | ||
| 429 | dprintk("%s(%d)\n", __FUNCTION__, enable); | 429 | dprintk("%s(%d)\n", __func__, enable); |
| 430 | 430 | ||
| 431 | if (enable) | 431 | if (enable) |
| 432 | return s5h1409_writereg(state, 0xf3, 1); | 432 | return s5h1409_writereg(state, 0xf3, 1); |
| @@ -438,7 +438,7 @@ static int s5h1409_set_gpio(struct dvb_frontend* fe, int enable) | |||
| 438 | { | 438 | { |
| 439 | struct s5h1409_state* state = fe->demodulator_priv; | 439 | struct s5h1409_state* state = fe->demodulator_priv; |
| 440 | 440 | ||
| 441 | dprintk("%s(%d)\n", __FUNCTION__, enable); | 441 | dprintk("%s(%d)\n", __func__, enable); |
| 442 | 442 | ||
| 443 | if (enable) | 443 | if (enable) |
| 444 | return s5h1409_writereg(state, 0xe3, | 444 | return s5h1409_writereg(state, 0xe3, |
| @@ -452,7 +452,7 @@ static int s5h1409_sleep(struct dvb_frontend* fe, int enable) | |||
| 452 | { | 452 | { |
| 453 | struct s5h1409_state* state = fe->demodulator_priv; | 453 | struct s5h1409_state* state = fe->demodulator_priv; |
| 454 | 454 | ||
| 455 | dprintk("%s(%d)\n", __FUNCTION__, enable); | 455 | dprintk("%s(%d)\n", __func__, enable); |
| 456 | 456 | ||
| 457 | return s5h1409_writereg(state, 0xf2, enable); | 457 | return s5h1409_writereg(state, 0xf2, enable); |
| 458 | } | 458 | } |
| @@ -461,7 +461,7 @@ static int s5h1409_register_reset(struct dvb_frontend* fe) | |||
| 461 | { | 461 | { |
| 462 | struct s5h1409_state* state = fe->demodulator_priv; | 462 | struct s5h1409_state* state = fe->demodulator_priv; |
| 463 | 463 | ||
| 464 | dprintk("%s()\n", __FUNCTION__); | 464 | dprintk("%s()\n", __func__); |
| 465 | 465 | ||
| 466 | return s5h1409_writereg(state, 0xfa, 0); | 466 | return s5h1409_writereg(state, 0xfa, 0); |
| 467 | } | 467 | } |
| @@ -534,7 +534,7 @@ static int s5h1409_set_frontend (struct dvb_frontend* fe, | |||
| 534 | { | 534 | { |
| 535 | struct s5h1409_state* state = fe->demodulator_priv; | 535 | struct s5h1409_state* state = fe->demodulator_priv; |
| 536 | 536 | ||
| 537 | dprintk("%s(frequency=%d)\n", __FUNCTION__, p->frequency); | 537 | dprintk("%s(frequency=%d)\n", __func__, p->frequency); |
| 538 | 538 | ||
| 539 | s5h1409_softreset(fe); | 539 | s5h1409_softreset(fe); |
| 540 | 540 | ||
| @@ -565,7 +565,7 @@ static int s5h1409_set_mpeg_timing(struct dvb_frontend *fe, int mode) | |||
| 565 | struct s5h1409_state *state = fe->demodulator_priv; | 565 | struct s5h1409_state *state = fe->demodulator_priv; |
| 566 | u16 val; | 566 | u16 val; |
| 567 | 567 | ||
| 568 | dprintk("%s(%d)\n", __FUNCTION__, mode); | 568 | dprintk("%s(%d)\n", __func__, mode); |
| 569 | 569 | ||
| 570 | val = s5h1409_readreg(state, 0xac) & 0xcfff; | 570 | val = s5h1409_readreg(state, 0xac) & 0xcfff; |
| 571 | switch (mode) { | 571 | switch (mode) { |
| @@ -573,7 +573,7 @@ static int s5h1409_set_mpeg_timing(struct dvb_frontend *fe, int mode) | |||
| 573 | val |= 0x0000; | 573 | val |= 0x0000; |
| 574 | break; | 574 | break; |
| 575 | case S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK: | 575 | case S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK: |
| 576 | dprintk("%s(%d) Mode1 or Defaulting\n", __FUNCTION__, mode); | 576 | dprintk("%s(%d) Mode1 or Defaulting\n", __func__, mode); |
| 577 | val |= 0x1000; | 577 | val |= 0x1000; |
| 578 | break; | 578 | break; |
| 579 | case S5H1409_MPEGTIMING_NONCONTINOUS_INVERTING_CLOCK: | 579 | case S5H1409_MPEGTIMING_NONCONTINOUS_INVERTING_CLOCK: |
| @@ -597,7 +597,7 @@ static int s5h1409_init (struct dvb_frontend* fe) | |||
| 597 | int i; | 597 | int i; |
| 598 | 598 | ||
| 599 | struct s5h1409_state* state = fe->demodulator_priv; | 599 | struct s5h1409_state* state = fe->demodulator_priv; |
| 600 | dprintk("%s()\n", __FUNCTION__); | 600 | dprintk("%s()\n", __func__); |
| 601 | 601 | ||
| 602 | s5h1409_sleep(fe, 0); | 602 | s5h1409_sleep(fe, 0); |
| 603 | s5h1409_register_reset(fe); | 603 | s5h1409_register_reset(fe); |
| @@ -663,7 +663,7 @@ static int s5h1409_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 663 | break; | 663 | break; |
| 664 | } | 664 | } |
| 665 | 665 | ||
| 666 | dprintk("%s() status 0x%08x\n", __FUNCTION__, *status); | 666 | dprintk("%s() status 0x%08x\n", __func__, *status); |
| 667 | 667 | ||
| 668 | return 0; | 668 | return 0; |
| 669 | } | 669 | } |
| @@ -671,7 +671,7 @@ static int s5h1409_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 671 | static int s5h1409_qam256_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | 671 | static int s5h1409_qam256_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) |
| 672 | { | 672 | { |
| 673 | int i, ret = -EINVAL; | 673 | int i, ret = -EINVAL; |
| 674 | dprintk("%s()\n", __FUNCTION__); | 674 | dprintk("%s()\n", __func__); |
| 675 | 675 | ||
| 676 | for (i=0; i < ARRAY_SIZE(qam256_snr_tab); i++) { | 676 | for (i=0; i < ARRAY_SIZE(qam256_snr_tab); i++) { |
| 677 | if (v < qam256_snr_tab[i].val) { | 677 | if (v < qam256_snr_tab[i].val) { |
| @@ -686,7 +686,7 @@ static int s5h1409_qam256_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | |||
| 686 | static int s5h1409_qam64_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | 686 | static int s5h1409_qam64_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) |
| 687 | { | 687 | { |
| 688 | int i, ret = -EINVAL; | 688 | int i, ret = -EINVAL; |
| 689 | dprintk("%s()\n", __FUNCTION__); | 689 | dprintk("%s()\n", __func__); |
| 690 | 690 | ||
| 691 | for (i=0; i < ARRAY_SIZE(qam64_snr_tab); i++) { | 691 | for (i=0; i < ARRAY_SIZE(qam64_snr_tab); i++) { |
| 692 | if (v < qam64_snr_tab[i].val) { | 692 | if (v < qam64_snr_tab[i].val) { |
| @@ -701,7 +701,7 @@ static int s5h1409_qam64_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | |||
| 701 | static int s5h1409_vsb_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | 701 | static int s5h1409_vsb_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) |
| 702 | { | 702 | { |
| 703 | int i, ret = -EINVAL; | 703 | int i, ret = -EINVAL; |
| 704 | dprintk("%s()\n", __FUNCTION__); | 704 | dprintk("%s()\n", __func__); |
| 705 | 705 | ||
| 706 | for (i=0; i < ARRAY_SIZE(vsb_snr_tab); i++) { | 706 | for (i=0; i < ARRAY_SIZE(vsb_snr_tab); i++) { |
| 707 | if (v > vsb_snr_tab[i].val) { | 707 | if (v > vsb_snr_tab[i].val) { |
| @@ -710,7 +710,7 @@ static int s5h1409_vsb_lookup_snr(struct dvb_frontend* fe, u16* snr, u16 v) | |||
| 710 | break; | 710 | break; |
| 711 | } | 711 | } |
| 712 | } | 712 | } |
| 713 | dprintk("%s() snr=%d\n", __FUNCTION__, *snr); | 713 | dprintk("%s() snr=%d\n", __func__, *snr); |
| 714 | return ret; | 714 | return ret; |
| 715 | } | 715 | } |
| 716 | 716 | ||
| @@ -718,7 +718,7 @@ static int s5h1409_read_snr(struct dvb_frontend* fe, u16* snr) | |||
| 718 | { | 718 | { |
| 719 | struct s5h1409_state* state = fe->demodulator_priv; | 719 | struct s5h1409_state* state = fe->demodulator_priv; |
| 720 | u16 reg; | 720 | u16 reg; |
| 721 | dprintk("%s()\n", __FUNCTION__); | 721 | dprintk("%s()\n", __func__); |
| 722 | 722 | ||
| 723 | switch(state->current_modulation) { | 723 | switch(state->current_modulation) { |
| 724 | case QAM_64: | 724 | case QAM_64: |
| @@ -812,7 +812,7 @@ struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, | |||
| 812 | 812 | ||
| 813 | if (s5h1409_init(&state->frontend) != 0) { | 813 | if (s5h1409_init(&state->frontend) != 0) { |
| 814 | printk(KERN_ERR "%s: Failed to initialize correctly\n", | 814 | printk(KERN_ERR "%s: Failed to initialize correctly\n", |
| 815 | __FUNCTION__); | 815 | __func__); |
| 816 | goto error; | 816 | goto error; |
| 817 | } | 817 | } |
| 818 | 818 | ||
diff --git a/drivers/media/dvb/frontends/s5h1409.h b/drivers/media/dvb/frontends/s5h1409.h index f0bb13fe808b..59f4335964c6 100644 --- a/drivers/media/dvb/frontends/s5h1409.h +++ b/drivers/media/dvb/frontends/s5h1409.h | |||
| @@ -67,7 +67,7 @@ extern struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, | |||
| 67 | static inline struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, | 67 | static inline struct dvb_frontend* s5h1409_attach(const struct s5h1409_config* config, |
| 68 | struct i2c_adapter* i2c) | 68 | struct i2c_adapter* i2c) |
| 69 | { | 69 | { |
| 70 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 70 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 71 | return NULL; | 71 | return NULL; |
| 72 | } | 72 | } |
| 73 | #endif /* CONFIG_DVB_S5H1409 */ | 73 | #endif /* CONFIG_DVB_S5H1409 */ |
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c index 2c2c344c4c64..281e1cb2edc6 100644 --- a/drivers/media/dvb/frontends/s5h1420.c +++ b/drivers/media/dvb/frontends/s5h1420.c | |||
| @@ -1,24 +1,26 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Driver for Samsung S5H1420 QPSK Demodulator | 2 | * Driver for |
| 3 | 3 | * Samsung S5H1420 and | |
| 4 | Copyright (C) 2005 Andrew de Quincey <adq_dvb@lidskialf.net> | 4 | * PnpNetwork PN1010 QPSK Demodulator |
| 5 | 5 | * | |
| 6 | This program is free software; you can redistribute it and/or modify | 6 | * Copyright (C) 2005 Andrew de Quincey <adq_dvb@lidskialf.net> |
| 7 | it under the terms of the GNU General Public License as published by | 7 | * Copyright (C) 2005-8 Patrick Boettcher <pb@linuxtv.org> |
| 8 | the Free Software Foundation; either version 2 of the License, or | 8 | * |
| 9 | (at your option) any later version. | 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | 10 | * it under the terms of the GNU General Public License as published by | |
| 11 | This program is distributed in the hope that it will be useful, | 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * (at your option) any later version. |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * |
| 14 | 14 | * This program is distributed in the hope that it will be useful, | |
| 15 | GNU General Public License for more details. | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | You should have received a copy of the GNU General Public License | 17 | * |
| 18 | along with this program; if not, write to the Free Software | 18 | * GNU General Public License for more details. |
| 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | * |
| 20 | 20 | * You should have received a copy of the GNU General Public License | |
| 21 | */ | 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 23 | */ | ||
| 22 | 24 | ||
| 23 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
| 24 | #include <linux/module.h> | 26 | #include <linux/module.h> |
| @@ -29,23 +31,35 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||
| 29 | #include <linux/jiffies.h> | 31 | #include <linux/jiffies.h> |
| 30 | #include <asm/div64.h> | 32 | #include <asm/div64.h> |
| 31 | 33 | ||
| 32 | #include "dvb_frontend.h" | 34 | #include <linux/i2c.h> |
| 33 | #include "s5h1420.h" | ||
| 34 | 35 | ||
| 35 | 36 | ||
| 37 | #include "dvb_frontend.h" | ||
| 38 | #include "s5h1420.h" | ||
| 39 | #include "s5h1420_priv.h" | ||
| 36 | 40 | ||
| 37 | #define TONE_FREQ 22000 | 41 | #define TONE_FREQ 22000 |
| 38 | 42 | ||
| 39 | struct s5h1420_state { | 43 | struct s5h1420_state { |
| 40 | struct i2c_adapter* i2c; | 44 | struct i2c_adapter* i2c; |
| 41 | const struct s5h1420_config* config; | 45 | const struct s5h1420_config* config; |
| 46 | |||
| 42 | struct dvb_frontend frontend; | 47 | struct dvb_frontend frontend; |
| 48 | struct i2c_adapter tuner_i2c_adapter; | ||
| 49 | |||
| 50 | u8 CON_1_val; | ||
| 43 | 51 | ||
| 44 | u8 postlocked:1; | 52 | u8 postlocked:1; |
| 45 | u32 fclk; | 53 | u32 fclk; |
| 46 | u32 tunedfreq; | 54 | u32 tunedfreq; |
| 47 | fe_code_rate_t fec_inner; | 55 | fe_code_rate_t fec_inner; |
| 48 | u32 symbol_rate; | 56 | u32 symbol_rate; |
| 57 | |||
| 58 | /* FIXME: ugly workaround for flexcop's incapable i2c-controller | ||
| 59 | * it does not support repeated-start, workaround: write addr-1 | ||
| 60 | * and then read | ||
| 61 | */ | ||
| 62 | u8 shadow[255]; | ||
| 49 | }; | 63 | }; |
| 50 | 64 | ||
| 51 | static u32 s5h1420_getsymbolrate(struct s5h1420_state* state); | 65 | static u32 s5h1420_getsymbolrate(struct s5h1420_state* state); |
| @@ -53,44 +67,66 @@ static int s5h1420_get_tune_settings(struct dvb_frontend* fe, | |||
| 53 | struct dvb_frontend_tune_settings* fesettings); | 67 | struct dvb_frontend_tune_settings* fesettings); |
| 54 | 68 | ||
| 55 | 69 | ||
| 56 | static int debug = 0; | 70 | static int debug; |
| 57 | #define dprintk if (debug) printk | 71 | module_param(debug, int, 0644); |
| 72 | MODULE_PARM_DESC(debug, "enable debugging"); | ||
| 73 | |||
| 74 | #define dprintk(x...) do { \ | ||
| 75 | if (debug) \ | ||
| 76 | printk(KERN_DEBUG "S5H1420: " x); \ | ||
| 77 | } while (0) | ||
| 78 | |||
| 79 | static u8 s5h1420_readreg(struct s5h1420_state *state, u8 reg) | ||
| 80 | { | ||
| 81 | int ret; | ||
| 82 | u8 b[2]; | ||
| 83 | struct i2c_msg msg[] = { | ||
| 84 | { .addr = state->config->demod_address, .flags = 0, .buf = b, .len = 2 }, | ||
| 85 | { .addr = state->config->demod_address, .flags = 0, .buf = ®, .len = 1 }, | ||
| 86 | { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b, .len = 1 }, | ||
| 87 | }; | ||
| 88 | |||
| 89 | b[0] = (reg - 1) & 0xff; | ||
| 90 | b[1] = state->shadow[(reg - 1) & 0xff]; | ||
| 91 | |||
| 92 | if (state->config->repeated_start_workaround) { | ||
| 93 | ret = i2c_transfer(state->i2c, msg, 3); | ||
| 94 | if (ret != 3) | ||
| 95 | return ret; | ||
| 96 | } else { | ||
| 97 | ret = i2c_transfer(state->i2c, &msg[1], 2); | ||
| 98 | if (ret != 2) | ||
| 99 | return ret; | ||
| 100 | } | ||
| 101 | |||
| 102 | /* dprintk("rd(%02x): %02x %02x\n", state->config->demod_address, reg, b[0]); */ | ||
| 103 | |||
| 104 | return b[0]; | ||
| 105 | } | ||
| 58 | 106 | ||
| 59 | static int s5h1420_writereg (struct s5h1420_state* state, u8 reg, u8 data) | 107 | static int s5h1420_writereg (struct s5h1420_state* state, u8 reg, u8 data) |
| 60 | { | 108 | { |
| 61 | u8 buf [] = { reg, data }; | 109 | u8 buf[] = { reg, data }; |
| 62 | struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; | 110 | struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; |
| 63 | int err; | 111 | int err; |
| 64 | 112 | ||
| 65 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { | 113 | /* dprintk("wr(%02x): %02x %02x\n", state->config->demod_address, reg, data); */ |
| 66 | dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data); | 114 | err = i2c_transfer(state->i2c, &msg, 1); |
| 115 | if (err != 1) { | ||
| 116 | dprintk("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __func__, err, reg, data); | ||
| 67 | return -EREMOTEIO; | 117 | return -EREMOTEIO; |
| 68 | } | 118 | } |
| 119 | state->shadow[reg] = data; | ||
| 69 | 120 | ||
| 70 | return 0; | 121 | return 0; |
| 71 | } | 122 | } |
| 72 | 123 | ||
| 73 | static u8 s5h1420_readreg (struct s5h1420_state* state, u8 reg) | ||
| 74 | { | ||
| 75 | int ret; | ||
| 76 | u8 b0 [] = { reg }; | ||
| 77 | u8 b1 [] = { 0 }; | ||
| 78 | struct i2c_msg msg1 = { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }; | ||
| 79 | struct i2c_msg msg2 = { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 }; | ||
| 80 | |||
| 81 | if ((ret = i2c_transfer (state->i2c, &msg1, 1)) != 1) | ||
| 82 | return ret; | ||
| 83 | |||
| 84 | if ((ret = i2c_transfer (state->i2c, &msg2, 1)) != 1) | ||
| 85 | return ret; | ||
| 86 | |||
| 87 | return b1[0]; | ||
| 88 | } | ||
| 89 | |||
| 90 | static int s5h1420_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage) | 124 | static int s5h1420_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage) |
| 91 | { | 125 | { |
| 92 | struct s5h1420_state* state = fe->demodulator_priv; | 126 | struct s5h1420_state* state = fe->demodulator_priv; |
| 93 | 127 | ||
| 128 | dprintk("enter %s\n", __func__); | ||
| 129 | |||
| 94 | switch(voltage) { | 130 | switch(voltage) { |
| 95 | case SEC_VOLTAGE_13: | 131 | case SEC_VOLTAGE_13: |
| 96 | s5h1420_writereg(state, 0x3c, | 132 | s5h1420_writereg(state, 0x3c, |
| @@ -106,6 +142,7 @@ static int s5h1420_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag | |||
| 106 | break; | 142 | break; |
| 107 | } | 143 | } |
| 108 | 144 | ||
| 145 | dprintk("leave %s\n", __func__); | ||
| 109 | return 0; | 146 | return 0; |
| 110 | } | 147 | } |
| 111 | 148 | ||
| @@ -113,6 +150,7 @@ static int s5h1420_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
| 113 | { | 150 | { |
| 114 | struct s5h1420_state* state = fe->demodulator_priv; | 151 | struct s5h1420_state* state = fe->demodulator_priv; |
| 115 | 152 | ||
| 153 | dprintk("enter %s\n", __func__); | ||
| 116 | switch(tone) { | 154 | switch(tone) { |
| 117 | case SEC_TONE_ON: | 155 | case SEC_TONE_ON: |
| 118 | s5h1420_writereg(state, 0x3b, | 156 | s5h1420_writereg(state, 0x3b, |
| @@ -124,6 +162,7 @@ static int s5h1420_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
| 124 | (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01); | 162 | (s5h1420_readreg(state, 0x3b) & 0x74) | 0x01); |
| 125 | break; | 163 | break; |
| 126 | } | 164 | } |
| 165 | dprintk("leave %s\n", __func__); | ||
| 127 | 166 | ||
| 128 | return 0; | 167 | return 0; |
| 129 | } | 168 | } |
| @@ -137,6 +176,7 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, | |||
| 137 | unsigned long timeout; | 176 | unsigned long timeout; |
| 138 | int result = 0; | 177 | int result = 0; |
| 139 | 178 | ||
| 179 | dprintk("enter %s\n", __func__); | ||
| 140 | if (cmd->msg_len > 8) | 180 | if (cmd->msg_len > 8) |
| 141 | return -EINVAL; | 181 | return -EINVAL; |
| 142 | 182 | ||
| @@ -168,6 +208,7 @@ static int s5h1420_send_master_cmd (struct dvb_frontend* fe, | |||
| 168 | /* restore original settings */ | 208 | /* restore original settings */ |
| 169 | s5h1420_writereg(state, 0x3b, val); | 209 | s5h1420_writereg(state, 0x3b, val); |
| 170 | msleep(15); | 210 | msleep(15); |
| 211 | dprintk("leave %s\n", __func__); | ||
| 171 | return result; | 212 | return result; |
| 172 | } | 213 | } |
| 173 | 214 | ||
| @@ -289,6 +330,8 @@ static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 289 | struct s5h1420_state* state = fe->demodulator_priv; | 330 | struct s5h1420_state* state = fe->demodulator_priv; |
| 290 | u8 val; | 331 | u8 val; |
| 291 | 332 | ||
| 333 | dprintk("enter %s\n", __func__); | ||
| 334 | |||
| 292 | if (status == NULL) | 335 | if (status == NULL) |
| 293 | return -EINVAL; | 336 | return -EINVAL; |
| 294 | 337 | ||
| @@ -297,13 +340,13 @@ static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 297 | 340 | ||
| 298 | /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert | 341 | /* fix for FEC 5/6 inversion issue - if it doesn't quite lock, invert |
| 299 | the inversion, wait a bit and check again */ | 342 | the inversion, wait a bit and check again */ |
| 300 | if (*status == (FE_HAS_SIGNAL|FE_HAS_CARRIER|FE_HAS_VITERBI)) { | 343 | if (*status == (FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI)) { |
| 301 | val = s5h1420_readreg(state, 0x32); | 344 | val = s5h1420_readreg(state, Vit10); |
| 302 | if ((val & 0x07) == 0x03) { | 345 | if ((val & 0x07) == 0x03) { |
| 303 | if (val & 0x08) | 346 | if (val & 0x08) |
| 304 | s5h1420_writereg(state, 0x31, 0x13); | 347 | s5h1420_writereg(state, Vit09, 0x13); |
| 305 | else | 348 | else |
| 306 | s5h1420_writereg(state, 0x31, 0x1b); | 349 | s5h1420_writereg(state, Vit09, 0x1b); |
| 307 | 350 | ||
| 308 | /* wait a bit then update lock status */ | 351 | /* wait a bit then update lock status */ |
| 309 | mdelay(200); | 352 | mdelay(200); |
| @@ -312,68 +355,73 @@ static int s5h1420_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 312 | } | 355 | } |
| 313 | 356 | ||
| 314 | /* perform post lock setup */ | 357 | /* perform post lock setup */ |
| 315 | if ((*status & FE_HAS_LOCK) && (!state->postlocked)) { | 358 | if ((*status & FE_HAS_LOCK) && !state->postlocked) { |
| 316 | 359 | ||
| 317 | /* calculate the data rate */ | 360 | /* calculate the data rate */ |
| 318 | u32 tmp = s5h1420_getsymbolrate(state); | 361 | u32 tmp = s5h1420_getsymbolrate(state); |
| 319 | switch(s5h1420_readreg(state, 0x32) & 0x07) { | 362 | switch (s5h1420_readreg(state, Vit10) & 0x07) { |
| 320 | case 0: | 363 | case 0: tmp = (tmp * 2 * 1) / 2; break; |
| 321 | tmp = (tmp * 2 * 1) / 2; | 364 | case 1: tmp = (tmp * 2 * 2) / 3; break; |
| 322 | break; | 365 | case 2: tmp = (tmp * 2 * 3) / 4; break; |
| 323 | 366 | case 3: tmp = (tmp * 2 * 5) / 6; break; | |
| 324 | case 1: | 367 | case 4: tmp = (tmp * 2 * 6) / 7; break; |
| 325 | tmp = (tmp * 2 * 2) / 3; | 368 | case 5: tmp = (tmp * 2 * 7) / 8; break; |
| 326 | break; | ||
| 327 | |||
| 328 | case 2: | ||
| 329 | tmp = (tmp * 2 * 3) / 4; | ||
| 330 | break; | ||
| 331 | |||
| 332 | case 3: | ||
| 333 | tmp = (tmp * 2 * 5) / 6; | ||
| 334 | break; | ||
| 335 | |||
| 336 | case 4: | ||
| 337 | tmp = (tmp * 2 * 6) / 7; | ||
| 338 | break; | ||
| 339 | |||
| 340 | case 5: | ||
| 341 | tmp = (tmp * 2 * 7) / 8; | ||
| 342 | break; | ||
| 343 | } | 369 | } |
| 370 | |||
| 344 | if (tmp == 0) { | 371 | if (tmp == 0) { |
| 345 | printk("s5h1420: avoided division by 0\n"); | 372 | printk(KERN_ERR "s5h1420: avoided division by 0\n"); |
| 346 | tmp = 1; | 373 | tmp = 1; |
| 347 | } | 374 | } |
| 348 | tmp = state->fclk / tmp; | 375 | tmp = state->fclk / tmp; |
| 349 | 376 | ||
| 377 | |||
| 350 | /* set the MPEG_CLK_INTL for the calculated data rate */ | 378 | /* set the MPEG_CLK_INTL for the calculated data rate */ |
| 351 | if (tmp < 4) | 379 | if (tmp < 2) |
| 352 | val = 0x00; | 380 | val = 0x00; |
| 353 | else if (tmp < 8) | 381 | else if (tmp < 5) |
| 354 | val = 0x01; | 382 | val = 0x01; |
| 355 | else if (tmp < 12) | 383 | else if (tmp < 9) |
| 356 | val = 0x02; | 384 | val = 0x02; |
| 357 | else if (tmp < 16) | 385 | else if (tmp < 13) |
| 358 | val = 0x03; | 386 | val = 0x03; |
| 359 | else if (tmp < 24) | 387 | else if (tmp < 17) |
| 360 | val = 0x04; | 388 | val = 0x04; |
| 361 | else if (tmp < 32) | 389 | else if (tmp < 25) |
| 362 | val = 0x05; | 390 | val = 0x05; |
| 363 | else | 391 | else if (tmp < 33) |
| 364 | val = 0x06; | 392 | val = 0x06; |
| 365 | s5h1420_writereg(state, 0x22, val); | 393 | else |
| 394 | val = 0x07; | ||
| 395 | dprintk("for MPEG_CLK_INTL %d %x\n", tmp, val); | ||
| 396 | |||
| 397 | s5h1420_writereg(state, FEC01, 0x18); | ||
| 398 | s5h1420_writereg(state, FEC01, 0x10); | ||
| 399 | s5h1420_writereg(state, FEC01, val); | ||
| 400 | |||
| 401 | /* Enable "MPEG_Out" */ | ||
| 402 | val = s5h1420_readreg(state, Mpeg02); | ||
| 403 | s5h1420_writereg(state, Mpeg02, val | (1 << 6)); | ||
| 366 | 404 | ||
| 367 | /* DC freeze */ | 405 | /* kicker disable */ |
| 368 | s5h1420_writereg(state, 0x1f, s5h1420_readreg(state, 0x1f) | 0x01); | 406 | val = s5h1420_readreg(state, QPSK01) & 0x7f; |
| 407 | s5h1420_writereg(state, QPSK01, val); | ||
| 369 | 408 | ||
| 370 | /* kicker disable + remove DC offset */ | 409 | /* DC freeze TODO it was never activated by default or it can stay activated */ |
| 371 | s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) & 0x6f); | 410 | |
| 411 | if (s5h1420_getsymbolrate(state) >= 20000000) { | ||
| 412 | s5h1420_writereg(state, Loop04, 0x8a); | ||
| 413 | s5h1420_writereg(state, Loop05, 0x6a); | ||
| 414 | } else { | ||
| 415 | s5h1420_writereg(state, Loop04, 0x58); | ||
| 416 | s5h1420_writereg(state, Loop05, 0x27); | ||
| 417 | } | ||
| 372 | 418 | ||
| 373 | /* post-lock processing has been done! */ | 419 | /* post-lock processing has been done! */ |
| 374 | state->postlocked = 1; | 420 | state->postlocked = 1; |
| 375 | } | 421 | } |
| 376 | 422 | ||
| 423 | dprintk("leave %s\n", __func__); | ||
| 424 | |||
| 377 | return 0; | 425 | return 0; |
| 378 | } | 426 | } |
| 379 | 427 | ||
| @@ -414,6 +462,7 @@ static int s5h1420_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | |||
| 414 | 462 | ||
| 415 | static void s5h1420_reset(struct s5h1420_state* state) | 463 | static void s5h1420_reset(struct s5h1420_state* state) |
| 416 | { | 464 | { |
| 465 | dprintk("%s\n", __func__); | ||
| 417 | s5h1420_writereg (state, 0x01, 0x08); | 466 | s5h1420_writereg (state, 0x01, 0x08); |
| 418 | s5h1420_writereg (state, 0x01, 0x00); | 467 | s5h1420_writereg (state, 0x01, 0x00); |
| 419 | udelay(10); | 468 | udelay(10); |
| @@ -422,54 +471,52 @@ static void s5h1420_reset(struct s5h1420_state* state) | |||
| 422 | static void s5h1420_setsymbolrate(struct s5h1420_state* state, | 471 | static void s5h1420_setsymbolrate(struct s5h1420_state* state, |
| 423 | struct dvb_frontend_parameters *p) | 472 | struct dvb_frontend_parameters *p) |
| 424 | { | 473 | { |
| 474 | u8 v; | ||
| 425 | u64 val; | 475 | u64 val; |
| 426 | 476 | ||
| 477 | dprintk("enter %s\n", __func__); | ||
| 478 | |||
| 427 | val = ((u64) p->u.qpsk.symbol_rate / 1000ULL) * (1ULL<<24); | 479 | val = ((u64) p->u.qpsk.symbol_rate / 1000ULL) * (1ULL<<24); |
| 428 | if (p->u.qpsk.symbol_rate <= 21000000) { | 480 | if (p->u.qpsk.symbol_rate < 29000000) |
| 429 | val *= 2; | 481 | val *= 2; |
| 430 | } | ||
| 431 | do_div(val, (state->fclk / 1000)); | 482 | do_div(val, (state->fclk / 1000)); |
| 432 | 483 | ||
| 433 | s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) & 0x7f); | 484 | dprintk("symbol rate register: %06llx\n", val); |
| 434 | s5h1420_writereg(state, 0x11, val >> 16); | 485 | |
| 435 | s5h1420_writereg(state, 0x12, val >> 8); | 486 | v = s5h1420_readreg(state, Loop01); |
| 436 | s5h1420_writereg(state, 0x13, val & 0xff); | 487 | s5h1420_writereg(state, Loop01, v & 0x7f); |
| 437 | s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) | 0x80); | 488 | s5h1420_writereg(state, Tnco01, val >> 16); |
| 489 | s5h1420_writereg(state, Tnco02, val >> 8); | ||
| 490 | s5h1420_writereg(state, Tnco03, val & 0xff); | ||
| 491 | s5h1420_writereg(state, Loop01, v | 0x80); | ||
| 492 | dprintk("leave %s\n", __func__); | ||
| 438 | } | 493 | } |
| 439 | 494 | ||
| 440 | static u32 s5h1420_getsymbolrate(struct s5h1420_state* state) | 495 | static u32 s5h1420_getsymbolrate(struct s5h1420_state* state) |
| 441 | { | 496 | { |
| 442 | u64 val = 0; | 497 | return state->symbol_rate; |
| 443 | int sampling = 2; | ||
| 444 | |||
| 445 | if (s5h1420_readreg(state, 0x05) & 0x2) | ||
| 446 | sampling = 1; | ||
| 447 | |||
| 448 | s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) | 0x08); | ||
| 449 | val = s5h1420_readreg(state, 0x11) << 16; | ||
| 450 | val |= s5h1420_readreg(state, 0x12) << 8; | ||
| 451 | val |= s5h1420_readreg(state, 0x13); | ||
| 452 | s5h1420_writereg(state, 0x06, s5h1420_readreg(state, 0x06) & 0xf7); | ||
| 453 | |||
| 454 | val *= (state->fclk / 1000ULL); | ||
| 455 | do_div(val, ((1<<24) * sampling)); | ||
| 456 | |||
| 457 | return (u32) (val * 1000ULL); | ||
| 458 | } | 498 | } |
| 459 | 499 | ||
| 460 | static void s5h1420_setfreqoffset(struct s5h1420_state* state, int freqoffset) | 500 | static void s5h1420_setfreqoffset(struct s5h1420_state* state, int freqoffset) |
| 461 | { | 501 | { |
| 462 | int val; | 502 | int val; |
| 503 | u8 v; | ||
| 504 | |||
| 505 | dprintk("enter %s\n", __func__); | ||
| 463 | 506 | ||
| 464 | /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so | 507 | /* remember freqoffset is in kHz, but the chip wants the offset in Hz, so |
| 465 | * divide fclk by 1000000 to get the correct value. */ | 508 | * divide fclk by 1000000 to get the correct value. */ |
| 466 | val = -(int) ((freqoffset * (1<<24)) / (state->fclk / 1000000)); | 509 | val = -(int) ((freqoffset * (1<<24)) / (state->fclk / 1000000)); |
| 467 | 510 | ||
| 468 | s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) & 0xbf); | 511 | dprintk("phase rotator/freqoffset: %d %06x\n", freqoffset, val); |
| 469 | s5h1420_writereg(state, 0x0e, val >> 16); | 512 | |
| 470 | s5h1420_writereg(state, 0x0f, val >> 8); | 513 | v = s5h1420_readreg(state, Loop01); |
| 471 | s5h1420_writereg(state, 0x10, val & 0xff); | 514 | s5h1420_writereg(state, Loop01, v & 0xbf); |
| 472 | s5h1420_writereg(state, 0x09, s5h1420_readreg(state, 0x09) | 0x40); | 515 | s5h1420_writereg(state, Pnco01, val >> 16); |
| 516 | s5h1420_writereg(state, Pnco02, val >> 8); | ||
| 517 | s5h1420_writereg(state, Pnco03, val & 0xff); | ||
| 518 | s5h1420_writereg(state, Loop01, v | 0x40); | ||
| 519 | dprintk("leave %s\n", __func__); | ||
| 473 | } | 520 | } |
| 474 | 521 | ||
| 475 | static int s5h1420_getfreqoffset(struct s5h1420_state* state) | 522 | static int s5h1420_getfreqoffset(struct s5h1420_state* state) |
| @@ -496,52 +543,53 @@ static void s5h1420_setfec_inversion(struct s5h1420_state* state, | |||
| 496 | struct dvb_frontend_parameters *p) | 543 | struct dvb_frontend_parameters *p) |
| 497 | { | 544 | { |
| 498 | u8 inversion = 0; | 545 | u8 inversion = 0; |
| 546 | u8 vit08, vit09; | ||
| 547 | |||
| 548 | dprintk("enter %s\n", __func__); | ||
| 499 | 549 | ||
| 500 | if (p->inversion == INVERSION_OFF) { | 550 | if (p->inversion == INVERSION_OFF) |
| 501 | inversion = state->config->invert ? 0x08 : 0; | 551 | inversion = state->config->invert ? 0x08 : 0; |
| 502 | } else if (p->inversion == INVERSION_ON) { | 552 | else if (p->inversion == INVERSION_ON) |
| 503 | inversion = state->config->invert ? 0 : 0x08; | 553 | inversion = state->config->invert ? 0 : 0x08; |
| 504 | } | ||
| 505 | 554 | ||
| 506 | if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) { | 555 | if ((p->u.qpsk.fec_inner == FEC_AUTO) || (p->inversion == INVERSION_AUTO)) { |
| 507 | s5h1420_writereg(state, 0x30, 0x3f); | 556 | vit08 = 0x3f; |
| 508 | s5h1420_writereg(state, 0x31, 0x00 | inversion); | 557 | vit09 = 0; |
| 509 | } else { | 558 | } else { |
| 510 | switch(p->u.qpsk.fec_inner) { | 559 | switch(p->u.qpsk.fec_inner) { |
| 511 | case FEC_1_2: | 560 | case FEC_1_2: |
| 512 | s5h1420_writereg(state, 0x30, 0x01); | 561 | vit08 = 0x01; vit09 = 0x10; |
| 513 | s5h1420_writereg(state, 0x31, 0x10 | inversion); | ||
| 514 | break; | 562 | break; |
| 515 | 563 | ||
| 516 | case FEC_2_3: | 564 | case FEC_2_3: |
| 517 | s5h1420_writereg(state, 0x30, 0x02); | 565 | vit08 = 0x02; vit09 = 0x11; |
| 518 | s5h1420_writereg(state, 0x31, 0x11 | inversion); | ||
| 519 | break; | 566 | break; |
| 520 | 567 | ||
| 521 | case FEC_3_4: | 568 | case FEC_3_4: |
| 522 | s5h1420_writereg(state, 0x30, 0x04); | 569 | vit08 = 0x04; vit09 = 0x12; |
| 523 | s5h1420_writereg(state, 0x31, 0x12 | inversion); | ||
| 524 | break; | 570 | break; |
| 525 | 571 | ||
| 526 | case FEC_5_6: | 572 | case FEC_5_6: |
| 527 | s5h1420_writereg(state, 0x30, 0x08); | 573 | vit08 = 0x08; vit09 = 0x13; |
| 528 | s5h1420_writereg(state, 0x31, 0x13 | inversion); | ||
| 529 | break; | 574 | break; |
| 530 | 575 | ||
| 531 | case FEC_6_7: | 576 | case FEC_6_7: |
| 532 | s5h1420_writereg(state, 0x30, 0x10); | 577 | vit08 = 0x10; vit09 = 0x14; |
| 533 | s5h1420_writereg(state, 0x31, 0x14 | inversion); | ||
| 534 | break; | 578 | break; |
| 535 | 579 | ||
| 536 | case FEC_7_8: | 580 | case FEC_7_8: |
| 537 | s5h1420_writereg(state, 0x30, 0x20); | 581 | vit08 = 0x20; vit09 = 0x15; |
| 538 | s5h1420_writereg(state, 0x31, 0x15 | inversion); | ||
| 539 | break; | 582 | break; |
| 540 | 583 | ||
| 541 | default: | 584 | default: |
| 542 | return; | 585 | return; |
| 543 | } | 586 | } |
| 544 | } | 587 | } |
| 588 | vit09 |= inversion; | ||
| 589 | dprintk("fec: %02x %02x\n", vit08, vit09); | ||
| 590 | s5h1420_writereg(state, Vit08, vit08); | ||
| 591 | s5h1420_writereg(state, Vit09, vit09); | ||
| 592 | dprintk("leave %s\n", __func__); | ||
| 545 | } | 593 | } |
| 546 | 594 | ||
| 547 | static fe_code_rate_t s5h1420_getfec(struct s5h1420_state* state) | 595 | static fe_code_rate_t s5h1420_getfec(struct s5h1420_state* state) |
| @@ -583,16 +631,19 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, | |||
| 583 | struct s5h1420_state* state = fe->demodulator_priv; | 631 | struct s5h1420_state* state = fe->demodulator_priv; |
| 584 | int frequency_delta; | 632 | int frequency_delta; |
| 585 | struct dvb_frontend_tune_settings fesettings; | 633 | struct dvb_frontend_tune_settings fesettings; |
| 634 | uint8_t clock_settting; | ||
| 635 | |||
| 636 | dprintk("enter %s\n", __func__); | ||
| 586 | 637 | ||
| 587 | /* check if we should do a fast-tune */ | 638 | /* check if we should do a fast-tune */ |
| 588 | memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters)); | 639 | memcpy(&fesettings.parameters, p, sizeof(struct dvb_frontend_parameters)); |
| 589 | s5h1420_get_tune_settings(fe, &fesettings); | 640 | s5h1420_get_tune_settings(fe, &fesettings); |
| 590 | frequency_delta = p->frequency - state->tunedfreq; | 641 | frequency_delta = p->frequency - state->tunedfreq; |
| 591 | if ((frequency_delta > -fesettings.max_drift) && | 642 | if ((frequency_delta > -fesettings.max_drift) && |
| 592 | (frequency_delta < fesettings.max_drift) && | 643 | (frequency_delta < fesettings.max_drift) && |
| 593 | (frequency_delta != 0) && | 644 | (frequency_delta != 0) && |
| 594 | (state->fec_inner == p->u.qpsk.fec_inner) && | 645 | (state->fec_inner == p->u.qpsk.fec_inner) && |
| 595 | (state->symbol_rate == p->u.qpsk.symbol_rate)) { | 646 | (state->symbol_rate == p->u.qpsk.symbol_rate)) { |
| 596 | 647 | ||
| 597 | if (fe->ops.tuner_ops.set_params) { | 648 | if (fe->ops.tuner_ops.set_params) { |
| 598 | fe->ops.tuner_ops.set_params(fe, p); | 649 | fe->ops.tuner_ops.set_params(fe, p); |
| @@ -606,54 +657,93 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, | |||
| 606 | } else { | 657 | } else { |
| 607 | s5h1420_setfreqoffset(state, 0); | 658 | s5h1420_setfreqoffset(state, 0); |
| 608 | } | 659 | } |
| 660 | dprintk("simple tune\n"); | ||
| 609 | return 0; | 661 | return 0; |
| 610 | } | 662 | } |
| 663 | dprintk("tuning demod\n"); | ||
| 611 | 664 | ||
| 612 | /* first of all, software reset */ | 665 | /* first of all, software reset */ |
| 613 | s5h1420_reset(state); | 666 | s5h1420_reset(state); |
| 614 | 667 | ||
| 615 | /* set s5h1420 fclk PLL according to desired symbol rate */ | 668 | /* set s5h1420 fclk PLL according to desired symbol rate */ |
| 616 | if (p->u.qpsk.symbol_rate > 28000000) { | 669 | if (p->u.qpsk.symbol_rate > 33000000) |
| 617 | state->fclk = 88000000; | 670 | state->fclk = 80000000; |
| 618 | s5h1420_writereg(state, 0x03, 0x50); | 671 | else if (p->u.qpsk.symbol_rate > 28500000) |
| 619 | s5h1420_writereg(state, 0x04, 0x40); | ||
| 620 | s5h1420_writereg(state, 0x05, 0xae); | ||
| 621 | } else if (p->u.qpsk.symbol_rate > 21000000) { | ||
| 622 | state->fclk = 59000000; | 672 | state->fclk = 59000000; |
| 623 | s5h1420_writereg(state, 0x03, 0x33); | 673 | else if (p->u.qpsk.symbol_rate > 25000000) |
| 624 | s5h1420_writereg(state, 0x04, 0x40); | 674 | state->fclk = 86000000; |
| 625 | s5h1420_writereg(state, 0x05, 0xae); | 675 | else if (p->u.qpsk.symbol_rate > 1900000) |
| 626 | } else { | ||
| 627 | state->fclk = 88000000; | 676 | state->fclk = 88000000; |
| 628 | s5h1420_writereg(state, 0x03, 0x50); | 677 | else |
| 629 | s5h1420_writereg(state, 0x04, 0x40); | 678 | state->fclk = 44000000; |
| 630 | s5h1420_writereg(state, 0x05, 0xac); | 679 | |
| 680 | /* Clock */ | ||
| 681 | switch (state->fclk) { | ||
| 682 | default: | ||
| 683 | case 88000000: | ||
| 684 | clock_settting = 80; | ||
| 685 | break; | ||
| 686 | case 86000000: | ||
| 687 | clock_settting = 78; | ||
| 688 | break; | ||
| 689 | case 80000000: | ||
| 690 | clock_settting = 72; | ||
| 691 | break; | ||
| 692 | case 59000000: | ||
| 693 | clock_settting = 51; | ||
| 694 | break; | ||
| 695 | case 44000000: | ||
| 696 | clock_settting = 36; | ||
| 697 | break; | ||
| 631 | } | 698 | } |
| 699 | dprintk("pll01: %d, ToneFreq: %d\n", state->fclk/1000000 - 8, (state->fclk + (TONE_FREQ * 32) - 1) / (TONE_FREQ * 32)); | ||
| 700 | s5h1420_writereg(state, PLL01, state->fclk/1000000 - 8); | ||
| 701 | s5h1420_writereg(state, PLL02, 0x40); | ||
| 702 | s5h1420_writereg(state, DiS01, (state->fclk + (TONE_FREQ * 32) - 1) / (TONE_FREQ * 32)); | ||
| 632 | 703 | ||
| 633 | /* set misc registers */ | 704 | /* TODO DC offset removal, config parameter ? */ |
| 634 | s5h1420_writereg(state, 0x02, 0x00); | 705 | if (p->u.qpsk.symbol_rate > 29000000) |
| 635 | s5h1420_writereg(state, 0x06, 0x00); | 706 | s5h1420_writereg(state, QPSK01, 0xae | 0x10); |
| 636 | s5h1420_writereg(state, 0x07, 0xb0); | 707 | else |
| 637 | s5h1420_writereg(state, 0x0a, 0xe7); | 708 | s5h1420_writereg(state, QPSK01, 0xac | 0x10); |
| 638 | s5h1420_writereg(state, 0x0b, 0x78); | ||
| 639 | s5h1420_writereg(state, 0x0c, 0x48); | ||
| 640 | s5h1420_writereg(state, 0x0d, 0x6b); | ||
| 641 | s5h1420_writereg(state, 0x2e, 0x8e); | ||
| 642 | s5h1420_writereg(state, 0x35, 0x33); | ||
| 643 | s5h1420_writereg(state, 0x38, 0x01); | ||
| 644 | s5h1420_writereg(state, 0x39, 0x7d); | ||
| 645 | s5h1420_writereg(state, 0x3a, (state->fclk + (TONE_FREQ * 32) - 1) / (TONE_FREQ * 32)); | ||
| 646 | s5h1420_writereg(state, 0x3c, 0x00); | ||
| 647 | s5h1420_writereg(state, 0x45, 0x61); | ||
| 648 | s5h1420_writereg(state, 0x46, 0x1d); | ||
| 649 | 709 | ||
| 650 | /* start QPSK */ | 710 | /* set misc registers */ |
| 651 | s5h1420_writereg(state, 0x05, s5h1420_readreg(state, 0x05) | 1); | 711 | s5h1420_writereg(state, CON_1, 0x00); |
| 712 | s5h1420_writereg(state, QPSK02, 0x00); | ||
| 713 | s5h1420_writereg(state, Pre01, 0xb0); | ||
| 714 | |||
| 715 | s5h1420_writereg(state, Loop01, 0xF0); | ||
| 716 | s5h1420_writereg(state, Loop02, 0x2a); /* e7 for s5h1420 */ | ||
| 717 | s5h1420_writereg(state, Loop03, 0x79); /* 78 for s5h1420 */ | ||
| 718 | if (p->u.qpsk.symbol_rate > 20000000) | ||
| 719 | s5h1420_writereg(state, Loop04, 0x79); | ||
| 720 | else | ||
| 721 | s5h1420_writereg(state, Loop04, 0x58); | ||
| 722 | s5h1420_writereg(state, Loop05, 0x6b); | ||
| 723 | |||
| 724 | if (p->u.qpsk.symbol_rate >= 8000000) | ||
| 725 | s5h1420_writereg(state, Post01, (0 << 6) | 0x10); | ||
| 726 | else if (p->u.qpsk.symbol_rate >= 4000000) | ||
| 727 | s5h1420_writereg(state, Post01, (1 << 6) | 0x10); | ||
| 728 | else | ||
| 729 | s5h1420_writereg(state, Post01, (3 << 6) | 0x10); | ||
| 730 | |||
| 731 | s5h1420_writereg(state, Monitor12, 0x00); /* unfreeze DC compensation */ | ||
| 732 | |||
| 733 | s5h1420_writereg(state, Sync01, 0x33); | ||
| 734 | s5h1420_writereg(state, Mpeg01, state->config->cdclk_polarity); | ||
| 735 | s5h1420_writereg(state, Mpeg02, 0x3d); /* Parallel output more, disabled -> enabled later */ | ||
| 736 | s5h1420_writereg(state, Err01, 0x03); /* 0x1d for s5h1420 */ | ||
| 737 | |||
| 738 | s5h1420_writereg(state, Vit06, 0x6e); /* 0x8e for s5h1420 */ | ||
| 739 | s5h1420_writereg(state, DiS03, 0x00); | ||
| 740 | s5h1420_writereg(state, Rf01, 0x61); /* Tuner i2c address - for the gate controller */ | ||
| 652 | 741 | ||
| 653 | /* set tuner PLL */ | 742 | /* set tuner PLL */ |
| 654 | if (fe->ops.tuner_ops.set_params) { | 743 | if (fe->ops.tuner_ops.set_params) { |
| 655 | fe->ops.tuner_ops.set_params(fe, p); | 744 | fe->ops.tuner_ops.set_params(fe, p); |
| 656 | if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0); | 745 | if (fe->ops.i2c_gate_ctrl) |
| 746 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 657 | s5h1420_setfreqoffset(state, 0); | 747 | s5h1420_setfreqoffset(state, 0); |
| 658 | } | 748 | } |
| 659 | 749 | ||
| @@ -661,10 +751,15 @@ static int s5h1420_set_frontend(struct dvb_frontend* fe, | |||
| 661 | s5h1420_setsymbolrate(state, p); | 751 | s5h1420_setsymbolrate(state, p); |
| 662 | s5h1420_setfec_inversion(state, p); | 752 | s5h1420_setfec_inversion(state, p); |
| 663 | 753 | ||
| 754 | /* start QPSK */ | ||
| 755 | s5h1420_writereg(state, QPSK01, s5h1420_readreg(state, QPSK01) | 1); | ||
| 756 | |||
| 664 | state->fec_inner = p->u.qpsk.fec_inner; | 757 | state->fec_inner = p->u.qpsk.fec_inner; |
| 665 | state->symbol_rate = p->u.qpsk.symbol_rate; | 758 | state->symbol_rate = p->u.qpsk.symbol_rate; |
| 666 | state->postlocked = 0; | 759 | state->postlocked = 0; |
| 667 | state->tunedfreq = p->frequency; | 760 | state->tunedfreq = p->frequency; |
| 761 | |||
| 762 | dprintk("leave %s\n", __func__); | ||
| 668 | return 0; | 763 | return 0; |
| 669 | } | 764 | } |
| 670 | 765 | ||
| @@ -717,11 +812,10 @@ static int s5h1420_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) | |||
| 717 | { | 812 | { |
| 718 | struct s5h1420_state* state = fe->demodulator_priv; | 813 | struct s5h1420_state* state = fe->demodulator_priv; |
| 719 | 814 | ||
| 720 | if (enable) { | 815 | if (enable) |
| 721 | return s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) | 1); | 816 | return s5h1420_writereg(state, 0x02, state->CON_1_val | 1); |
| 722 | } else { | 817 | else |
| 723 | return s5h1420_writereg (state, 0x02, s5h1420_readreg(state,0x02) & 0xfe); | 818 | return s5h1420_writereg(state, 0x02, state->CON_1_val & 0xfe); |
| 724 | } | ||
| 725 | } | 819 | } |
| 726 | 820 | ||
| 727 | static int s5h1420_init (struct dvb_frontend* fe) | 821 | static int s5h1420_init (struct dvb_frontend* fe) |
| @@ -729,7 +823,8 @@ static int s5h1420_init (struct dvb_frontend* fe) | |||
| 729 | struct s5h1420_state* state = fe->demodulator_priv; | 823 | struct s5h1420_state* state = fe->demodulator_priv; |
| 730 | 824 | ||
| 731 | /* disable power down and do reset */ | 825 | /* disable power down and do reset */ |
| 732 | s5h1420_writereg(state, 0x02, 0x10); | 826 | state->CON_1_val = 0x10; |
| 827 | s5h1420_writereg(state, 0x02, state->CON_1_val); | ||
| 733 | msleep(10); | 828 | msleep(10); |
| 734 | s5h1420_reset(state); | 829 | s5h1420_reset(state); |
| 735 | 830 | ||
| @@ -739,26 +834,60 @@ static int s5h1420_init (struct dvb_frontend* fe) | |||
| 739 | static int s5h1420_sleep(struct dvb_frontend* fe) | 834 | static int s5h1420_sleep(struct dvb_frontend* fe) |
| 740 | { | 835 | { |
| 741 | struct s5h1420_state* state = fe->demodulator_priv; | 836 | struct s5h1420_state* state = fe->demodulator_priv; |
| 742 | 837 | state->CON_1_val = 0x12; | |
| 743 | return s5h1420_writereg(state, 0x02, 0x12); | 838 | return s5h1420_writereg(state, 0x02, state->CON_1_val); |
| 744 | } | 839 | } |
| 745 | 840 | ||
| 746 | static void s5h1420_release(struct dvb_frontend* fe) | 841 | static void s5h1420_release(struct dvb_frontend* fe) |
| 747 | { | 842 | { |
| 748 | struct s5h1420_state* state = fe->demodulator_priv; | 843 | struct s5h1420_state* state = fe->demodulator_priv; |
| 844 | i2c_del_adapter(&state->tuner_i2c_adapter); | ||
| 749 | kfree(state); | 845 | kfree(state); |
| 750 | } | 846 | } |
| 751 | 847 | ||
| 752 | static struct dvb_frontend_ops s5h1420_ops; | 848 | static u32 s5h1420_tuner_i2c_func(struct i2c_adapter *adapter) |
| 849 | { | ||
| 850 | return I2C_FUNC_I2C; | ||
| 851 | } | ||
| 852 | |||
| 853 | static int s5h1420_tuner_i2c_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[], int num) | ||
| 854 | { | ||
| 855 | struct s5h1420_state *state = i2c_get_adapdata(i2c_adap); | ||
| 856 | struct i2c_msg m[1 + num]; | ||
| 857 | u8 tx_open[2] = { CON_1, state->CON_1_val | 1 }; /* repeater stops once there was a stop condition */ | ||
| 858 | |||
| 859 | memset(m, 0, sizeof(struct i2c_msg) * (1 + num)); | ||
| 860 | |||
| 861 | m[0].addr = state->config->demod_address; | ||
| 862 | m[0].buf = tx_open; | ||
| 863 | m[0].len = 2; | ||
| 753 | 864 | ||
| 754 | struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, | 865 | memcpy(&m[1], msg, sizeof(struct i2c_msg) * num); |
| 755 | struct i2c_adapter* i2c) | 866 | |
| 867 | return i2c_transfer(state->i2c, m, 1+num) == 1 + num ? num : -EIO; | ||
| 868 | } | ||
| 869 | |||
| 870 | static struct i2c_algorithm s5h1420_tuner_i2c_algo = { | ||
| 871 | .master_xfer = s5h1420_tuner_i2c_tuner_xfer, | ||
| 872 | .functionality = s5h1420_tuner_i2c_func, | ||
| 873 | }; | ||
| 874 | |||
| 875 | struct i2c_adapter *s5h1420_get_tuner_i2c_adapter(struct dvb_frontend *fe) | ||
| 756 | { | 876 | { |
| 757 | struct s5h1420_state* state = NULL; | 877 | struct s5h1420_state *state = fe->demodulator_priv; |
| 758 | u8 identity; | 878 | return &state->tuner_i2c_adapter; |
| 879 | } | ||
| 880 | EXPORT_SYMBOL(s5h1420_get_tuner_i2c_adapter); | ||
| 881 | |||
| 882 | static struct dvb_frontend_ops s5h1420_ops; | ||
| 759 | 883 | ||
| 884 | struct dvb_frontend *s5h1420_attach(const struct s5h1420_config *config, | ||
| 885 | struct i2c_adapter *i2c) | ||
| 886 | { | ||
| 760 | /* allocate memory for the internal state */ | 887 | /* allocate memory for the internal state */ |
| 761 | state = kmalloc(sizeof(struct s5h1420_state), GFP_KERNEL); | 888 | struct s5h1420_state *state = kzalloc(sizeof(struct s5h1420_state), GFP_KERNEL); |
| 889 | u8 i; | ||
| 890 | |||
| 762 | if (state == NULL) | 891 | if (state == NULL) |
| 763 | goto error; | 892 | goto error; |
| 764 | 893 | ||
| @@ -772,24 +901,42 @@ struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, | |||
| 772 | state->symbol_rate = 0; | 901 | state->symbol_rate = 0; |
| 773 | 902 | ||
| 774 | /* check if the demod is there + identify it */ | 903 | /* check if the demod is there + identify it */ |
| 775 | identity = s5h1420_readreg(state, 0x00); | 904 | i = s5h1420_readreg(state, ID01); |
| 776 | if (identity != 0x03) | 905 | if (i != 0x03) |
| 777 | goto error; | 906 | goto error; |
| 778 | 907 | ||
| 908 | memset(state->shadow, 0xff, sizeof(state->shadow)); | ||
| 909 | |||
| 910 | for (i = 0; i < 0x50; i++) | ||
| 911 | state->shadow[i] = s5h1420_readreg(state, i); | ||
| 912 | |||
| 779 | /* create dvb_frontend */ | 913 | /* create dvb_frontend */ |
| 780 | memcpy(&state->frontend.ops, &s5h1420_ops, sizeof(struct dvb_frontend_ops)); | 914 | memcpy(&state->frontend.ops, &s5h1420_ops, sizeof(struct dvb_frontend_ops)); |
| 781 | state->frontend.demodulator_priv = state; | 915 | state->frontend.demodulator_priv = state; |
| 916 | |||
| 917 | /* create tuner i2c adapter */ | ||
| 918 | strncpy(state->tuner_i2c_adapter.name, "S5H1420-PN1010 tuner I2C bus", I2C_NAME_SIZE); | ||
| 919 | state->tuner_i2c_adapter.class = I2C_CLASS_TV_DIGITAL, | ||
| 920 | state->tuner_i2c_adapter.algo = &s5h1420_tuner_i2c_algo; | ||
| 921 | state->tuner_i2c_adapter.algo_data = NULL; | ||
| 922 | i2c_set_adapdata(&state->tuner_i2c_adapter, state); | ||
| 923 | if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) { | ||
| 924 | printk(KERN_ERR "S5H1420/PN1010: tuner i2c bus could not be initialized\n"); | ||
| 925 | goto error; | ||
| 926 | } | ||
| 927 | |||
| 782 | return &state->frontend; | 928 | return &state->frontend; |
| 783 | 929 | ||
| 784 | error: | 930 | error: |
| 785 | kfree(state); | 931 | kfree(state); |
| 786 | return NULL; | 932 | return NULL; |
| 787 | } | 933 | } |
| 934 | EXPORT_SYMBOL(s5h1420_attach); | ||
| 788 | 935 | ||
| 789 | static struct dvb_frontend_ops s5h1420_ops = { | 936 | static struct dvb_frontend_ops s5h1420_ops = { |
| 790 | 937 | ||
| 791 | .info = { | 938 | .info = { |
| 792 | .name = "Samsung S5H1420 DVB-S", | 939 | .name = "Samsung S5H1420/PnpNetwork PN1010 DVB-S", |
| 793 | .type = FE_QPSK, | 940 | .type = FE_QPSK, |
| 794 | .frequency_min = 950000, | 941 | .frequency_min = 950000, |
| 795 | .frequency_max = 2150000, | 942 | .frequency_max = 2150000, |
| @@ -826,10 +973,6 @@ static struct dvb_frontend_ops s5h1420_ops = { | |||
| 826 | .set_voltage = s5h1420_set_voltage, | 973 | .set_voltage = s5h1420_set_voltage, |
| 827 | }; | 974 | }; |
| 828 | 975 | ||
| 829 | module_param(debug, int, 0644); | 976 | MODULE_DESCRIPTION("Samsung S5H1420/PnpNetwork PN1010 DVB-S Demodulator driver"); |
| 830 | 977 | MODULE_AUTHOR("Andrew de Quincey, Patrick Boettcher"); | |
| 831 | MODULE_DESCRIPTION("Samsung S5H1420 DVB-S Demodulator driver"); | ||
| 832 | MODULE_AUTHOR("Andrew de Quincey"); | ||
| 833 | MODULE_LICENSE("GPL"); | 978 | MODULE_LICENSE("GPL"); |
| 834 | |||
| 835 | EXPORT_SYMBOL(s5h1420_attach); | ||
diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h index 1555870f7226..4c913f142bc4 100644 --- a/drivers/media/dvb/frontends/s5h1420.h +++ b/drivers/media/dvb/frontends/s5h1420.h | |||
| @@ -1,25 +1,26 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Driver for S5H1420 QPSK Demodulators | 2 | * Driver for |
| 3 | 3 | * Samsung S5H1420 and | |
| 4 | Copyright (C) 2005 Andrew de Quincey <adq_dvb@lidskialf.net> | 4 | * PnpNetwork PN1010 QPSK Demodulator |
| 5 | 5 | * | |
| 6 | This program is free software; you can redistribute it and/or modify | 6 | * Copyright (C) 2005 Andrew de Quincey <adq_dvb@lidskialf.net> |
| 7 | it under the terms of the GNU General Public License as published by | 7 | * Copyright (C) 2005-8 Patrick Boettcher <pb@linuxtv.org> |
| 8 | the Free Software Foundation; either version 2 of the License, or | 8 | * |
| 9 | (at your option) any later version. | 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | 10 | * it under the terms of the GNU General Public License as published by | |
| 11 | This program is distributed in the hope that it will be useful, | 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * (at your option) any later version. |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * |
| 14 | 14 | * This program is distributed in the hope that it will be useful, | |
| 15 | GNU General Public License for more details. | 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | You should have received a copy of the GNU General Public License | 17 | * |
| 18 | along with this program; if not, write to the Free Software | 18 | * GNU General Public License for more details. |
| 19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | * |
| 20 | 20 | * You should have received a copy of the GNU General Public License | |
| 21 | */ | 21 | * along with this program; if not, write to the Free Software |
| 22 | 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 23 | */ | ||
| 23 | #ifndef S5H1420_H | 24 | #ifndef S5H1420_H |
| 24 | #define S5H1420_H | 25 | #define S5H1420_H |
| 25 | 26 | ||
| @@ -31,17 +32,26 @@ struct s5h1420_config | |||
| 31 | u8 demod_address; | 32 | u8 demod_address; |
| 32 | 33 | ||
| 33 | /* does the inversion require inversion? */ | 34 | /* does the inversion require inversion? */ |
| 34 | u8 invert:1; | 35 | u8 invert : 1; |
| 36 | |||
| 37 | u8 repeated_start_workaround : 1; | ||
| 38 | u8 cdclk_polarity : 1; /* 1 == falling edge, 0 == raising edge */ | ||
| 35 | }; | 39 | }; |
| 36 | 40 | ||
| 37 | #if defined(CONFIG_DVB_S5H1420) || (defined(CONFIG_DVB_S5H1420_MODULE) && defined(MODULE)) | 41 | #if defined(CONFIG_DVB_S5H1420) || (defined(CONFIG_DVB_S5H1420_MODULE) && defined(MODULE)) |
| 38 | extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, | 42 | extern struct dvb_frontend *s5h1420_attach(const struct s5h1420_config *config, |
| 39 | struct i2c_adapter* i2c); | 43 | struct i2c_adapter *i2c); |
| 44 | extern struct i2c_adapter *s5h1420_get_tuner_i2c_adapter(struct dvb_frontend *fe); | ||
| 40 | #else | 45 | #else |
| 41 | static inline struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, | 46 | static inline struct dvb_frontend *s5h1420_attach(const struct s5h1420_config *config, |
| 42 | struct i2c_adapter* i2c) | 47 | struct i2c_adapter *i2c) |
| 48 | { | ||
| 49 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
| 50 | return NULL; | ||
| 51 | } | ||
| 52 | |||
| 53 | static inline struct i2c_adapter *s5h1420_get_tuner_i2c_adapter(struct dvb_frontend *fe) | ||
| 43 | { | 54 | { |
| 44 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | ||
| 45 | return NULL; | 55 | return NULL; |
| 46 | } | 56 | } |
| 47 | #endif // CONFIG_DVB_S5H1420 | 57 | #endif // CONFIG_DVB_S5H1420 |
diff --git a/drivers/media/dvb/frontends/s5h1420_priv.h b/drivers/media/dvb/frontends/s5h1420_priv.h new file mode 100644 index 000000000000..d9c58d281816 --- /dev/null +++ b/drivers/media/dvb/frontends/s5h1420_priv.h | |||
| @@ -0,0 +1,102 @@ | |||
| 1 | /* | ||
| 2 | * Driver for | ||
| 3 | * Samsung S5H1420 and | ||
| 4 | * PnpNetwork PN1010 QPSK Demodulator | ||
| 5 | * | ||
| 6 | * Copyright (C) 2005 Andrew de Quincey <adq_dvb@lidskialf.net> | ||
| 7 | * Copyright (C) 2005 Patrick Boettcher <pb@linuxtv.org> | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify it | ||
| 10 | * under the terms of the GNU General Public License as published by the Free | ||
| 11 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 12 | * any later version. | ||
| 13 | * | ||
| 14 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 16 | * FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | * | ||
| 18 | * GNU General Public License for more details. | ||
| 19 | * | ||
| 20 | * You should have received a copy of the GNU General Public License along with | ||
| 21 | * this program; if not, write to the Free Software Foundation, Inc., 675 Mass | ||
| 22 | * Ave, Cambridge, MA 02139, USA. | ||
| 23 | */ | ||
| 24 | #ifndef S5H1420_PRIV | ||
| 25 | #define S5H1420_PRIV | ||
| 26 | |||
| 27 | #include <asm/types.h> | ||
| 28 | |||
| 29 | enum s5h1420_register { | ||
| 30 | ID01 = 0x00, | ||
| 31 | CON_0 = 0x01, | ||
| 32 | CON_1 = 0x02, | ||
| 33 | PLL01 = 0x03, | ||
| 34 | PLL02 = 0x04, | ||
| 35 | QPSK01 = 0x05, | ||
| 36 | QPSK02 = 0x06, | ||
| 37 | Pre01 = 0x07, | ||
| 38 | Post01 = 0x08, | ||
| 39 | Loop01 = 0x09, | ||
| 40 | Loop02 = 0x0a, | ||
| 41 | Loop03 = 0x0b, | ||
| 42 | Loop04 = 0x0c, | ||
| 43 | Loop05 = 0x0d, | ||
| 44 | Pnco01 = 0x0e, | ||
| 45 | Pnco02 = 0x0f, | ||
| 46 | Pnco03 = 0x10, | ||
| 47 | Tnco01 = 0x11, | ||
| 48 | Tnco02 = 0x12, | ||
| 49 | Tnco03 = 0x13, | ||
| 50 | Monitor01 = 0x14, | ||
| 51 | Monitor02 = 0x15, | ||
| 52 | Monitor03 = 0x16, | ||
| 53 | Monitor04 = 0x17, | ||
| 54 | Monitor05 = 0x18, | ||
| 55 | Monitor06 = 0x19, | ||
| 56 | Monitor07 = 0x1a, | ||
| 57 | Monitor12 = 0x1f, | ||
| 58 | |||
| 59 | FEC01 = 0x22, | ||
| 60 | Soft01 = 0x23, | ||
| 61 | Soft02 = 0x24, | ||
| 62 | Soft03 = 0x25, | ||
| 63 | Soft04 = 0x26, | ||
| 64 | Soft05 = 0x27, | ||
| 65 | Soft06 = 0x28, | ||
| 66 | Vit01 = 0x29, | ||
| 67 | Vit02 = 0x2a, | ||
| 68 | Vit03 = 0x2b, | ||
| 69 | Vit04 = 0x2c, | ||
| 70 | Vit05 = 0x2d, | ||
| 71 | Vit06 = 0x2e, | ||
| 72 | Vit07 = 0x2f, | ||
| 73 | Vit08 = 0x30, | ||
| 74 | Vit09 = 0x31, | ||
| 75 | Vit10 = 0x32, | ||
| 76 | Vit11 = 0x33, | ||
| 77 | Vit12 = 0x34, | ||
| 78 | Sync01 = 0x35, | ||
| 79 | Sync02 = 0x36, | ||
| 80 | Rs01 = 0x37, | ||
| 81 | Mpeg01 = 0x38, | ||
| 82 | Mpeg02 = 0x39, | ||
| 83 | DiS01 = 0x3a, | ||
| 84 | DiS02 = 0x3b, | ||
| 85 | DiS03 = 0x3c, | ||
| 86 | DiS04 = 0x3d, | ||
| 87 | DiS05 = 0x3e, | ||
| 88 | DiS06 = 0x3f, | ||
| 89 | DiS07 = 0x40, | ||
| 90 | DiS08 = 0x41, | ||
| 91 | DiS09 = 0x42, | ||
| 92 | DiS10 = 0x43, | ||
| 93 | DiS11 = 0x44, | ||
| 94 | Rf01 = 0x45, | ||
| 95 | Err01 = 0x46, | ||
| 96 | Err02 = 0x47, | ||
| 97 | Err03 = 0x48, | ||
| 98 | Err04 = 0x49, | ||
| 99 | }; | ||
| 100 | |||
| 101 | |||
| 102 | #endif | ||
diff --git a/drivers/media/dvb/frontends/sp8870.c b/drivers/media/dvb/frontends/sp8870.c index da876f7bfe32..aa78aa14aad9 100644 --- a/drivers/media/dvb/frontends/sp8870.c +++ b/drivers/media/dvb/frontends/sp8870.c | |||
| @@ -70,7 +70,7 @@ static int sp8870_writereg (struct sp8870_state* state, u16 reg, u16 data) | |||
| 70 | int err; | 70 | int err; |
| 71 | 71 | ||
| 72 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { | 72 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { |
| 73 | dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data); | 73 | dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __func__, err, reg, data); |
| 74 | return -EREMOTEIO; | 74 | return -EREMOTEIO; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| @@ -88,7 +88,7 @@ static int sp8870_readreg (struct sp8870_state* state, u16 reg) | |||
| 88 | ret = i2c_transfer (state->i2c, msg, 2); | 88 | ret = i2c_transfer (state->i2c, msg, 2); |
| 89 | 89 | ||
| 90 | if (ret != 2) { | 90 | if (ret != 2) { |
| 91 | dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret); | 91 | dprintk("%s: readreg error (ret == %i)\n", __func__, ret); |
| 92 | return -1; | 92 | return -1; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| @@ -104,7 +104,7 @@ static int sp8870_firmware_upload (struct sp8870_state* state, const struct firm | |||
| 104 | int tx_len; | 104 | int tx_len; |
| 105 | int err = 0; | 105 | int err = 0; |
| 106 | 106 | ||
| 107 | dprintk ("%s: ...\n", __FUNCTION__); | 107 | dprintk ("%s: ...\n", __func__); |
| 108 | 108 | ||
| 109 | if (fw->size < SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET) | 109 | if (fw->size < SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET) |
| 110 | return -EINVAL; | 110 | return -EINVAL; |
| @@ -131,14 +131,14 @@ static int sp8870_firmware_upload (struct sp8870_state* state, const struct firm | |||
| 131 | msg.buf = tx_buf; | 131 | msg.buf = tx_buf; |
| 132 | msg.len = tx_len + 2; | 132 | msg.len = tx_len + 2; |
| 133 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { | 133 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { |
| 134 | printk("%s: firmware upload failed!\n", __FUNCTION__); | 134 | printk("%s: firmware upload failed!\n", __func__); |
| 135 | printk ("%s: i2c error (err == %i)\n", __FUNCTION__, err); | 135 | printk ("%s: i2c error (err == %i)\n", __func__, err); |
| 136 | return err; | 136 | return err; |
| 137 | } | 137 | } |
| 138 | fw_pos += tx_len; | 138 | fw_pos += tx_len; |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | dprintk ("%s: done!\n", __FUNCTION__); | 141 | dprintk ("%s: done!\n", __func__); |
| 142 | return 0; | 142 | return 0; |
| 143 | }; | 143 | }; |
| 144 | 144 | ||
| @@ -310,7 +310,7 @@ static int sp8870_init (struct dvb_frontend* fe) | |||
| 310 | if (state->initialised) return 0; | 310 | if (state->initialised) return 0; |
| 311 | state->initialised = 1; | 311 | state->initialised = 1; |
| 312 | 312 | ||
| 313 | dprintk ("%s\n", __FUNCTION__); | 313 | dprintk ("%s\n", __func__); |
| 314 | 314 | ||
| 315 | 315 | ||
| 316 | /* request the firmware, this will block until someone uploads it */ | 316 | /* request the firmware, this will block until someone uploads it */ |
| @@ -449,15 +449,15 @@ static int sp8870_read_uncorrected_blocks (struct dvb_frontend* fe, u32* ublocks | |||
| 449 | return 0; | 449 | return 0; |
| 450 | } | 450 | } |
| 451 | 451 | ||
| 452 | // number of trials to recover from lockup | 452 | /* number of trials to recover from lockup */ |
| 453 | #define MAXTRIALS 5 | 453 | #define MAXTRIALS 5 |
| 454 | // maximum checks for data valid signal | 454 | /* maximum checks for data valid signal */ |
| 455 | #define MAXCHECKS 100 | 455 | #define MAXCHECKS 100 |
| 456 | 456 | ||
| 457 | // only for debugging: counter for detected lockups | 457 | /* only for debugging: counter for detected lockups */ |
| 458 | static int lockups = 0; | 458 | static int lockups; |
| 459 | // only for debugging: counter for channel switches | 459 | /* only for debugging: counter for channel switches */ |
| 460 | static int switches = 0; | 460 | static int switches; |
| 461 | 461 | ||
| 462 | static int sp8870_set_frontend (struct dvb_frontend* fe, struct dvb_frontend_parameters *p) | 462 | static int sp8870_set_frontend (struct dvb_frontend* fe, struct dvb_frontend_parameters *p) |
| 463 | { | 463 | { |
| @@ -475,7 +475,7 @@ static int sp8870_set_frontend (struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 475 | int trials = 0; | 475 | int trials = 0; |
| 476 | int check_count = 0; | 476 | int check_count = 0; |
| 477 | 477 | ||
| 478 | dprintk("%s: frequency = %i\n", __FUNCTION__, p->frequency); | 478 | dprintk("%s: frequency = %i\n", __func__, p->frequency); |
| 479 | 479 | ||
| 480 | for (trials = 1; trials <= MAXTRIALS; trials++) { | 480 | for (trials = 1; trials <= MAXTRIALS; trials++) { |
| 481 | 481 | ||
| @@ -487,7 +487,7 @@ static int sp8870_set_frontend (struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 487 | valid = sp8870_read_data_valid_signal(state); | 487 | valid = sp8870_read_data_valid_signal(state); |
| 488 | if (valid) { | 488 | if (valid) { |
| 489 | dprintk("%s: delay = %i usec\n", | 489 | dprintk("%s: delay = %i usec\n", |
| 490 | __FUNCTION__, check_count * 10); | 490 | __func__, check_count * 10); |
| 491 | break; | 491 | break; |
| 492 | } | 492 | } |
| 493 | udelay(10); | 493 | udelay(10); |
| @@ -497,20 +497,20 @@ static int sp8870_set_frontend (struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 497 | } | 497 | } |
| 498 | 498 | ||
| 499 | if (!valid) { | 499 | if (!valid) { |
| 500 | printk("%s: firmware crash!!!!!!\n", __FUNCTION__); | 500 | printk("%s: firmware crash!!!!!!\n", __func__); |
| 501 | return -EIO; | 501 | return -EIO; |
| 502 | } | 502 | } |
| 503 | 503 | ||
| 504 | if (debug) { | 504 | if (debug) { |
| 505 | if (valid) { | 505 | if (valid) { |
| 506 | if (trials > 1) { | 506 | if (trials > 1) { |
| 507 | printk("%s: firmware lockup!!!\n", __FUNCTION__); | 507 | printk("%s: firmware lockup!!!\n", __func__); |
| 508 | printk("%s: recovered after %i trial(s))\n", __FUNCTION__, trials - 1); | 508 | printk("%s: recovered after %i trial(s))\n", __func__, trials - 1); |
| 509 | lockups++; | 509 | lockups++; |
| 510 | } | 510 | } |
| 511 | } | 511 | } |
| 512 | switches++; | 512 | switches++; |
| 513 | printk("%s: switches = %i lockups = %i\n", __FUNCTION__, switches, lockups); | 513 | printk("%s: switches = %i lockups = %i\n", __func__, switches, lockups); |
| 514 | } | 514 | } |
| 515 | 515 | ||
| 516 | return 0; | 516 | return 0; |
diff --git a/drivers/media/dvb/frontends/sp8870.h b/drivers/media/dvb/frontends/sp8870.h index 909cefe7139e..a764a793c7d8 100644 --- a/drivers/media/dvb/frontends/sp8870.h +++ b/drivers/media/dvb/frontends/sp8870.h | |||
| @@ -42,7 +42,7 @@ extern struct dvb_frontend* sp8870_attach(const struct sp8870_config* config, | |||
| 42 | static inline struct dvb_frontend* sp8870_attach(const struct sp8870_config* config, | 42 | static inline struct dvb_frontend* sp8870_attach(const struct sp8870_config* config, |
| 43 | struct i2c_adapter* i2c) | 43 | struct i2c_adapter* i2c) |
| 44 | { | 44 | { |
| 45 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 45 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 46 | return NULL; | 46 | return NULL; |
| 47 | } | 47 | } |
| 48 | #endif // CONFIG_DVB_SP8870 | 48 | #endif // CONFIG_DVB_SP8870 |
diff --git a/drivers/media/dvb/frontends/sp887x.c b/drivers/media/dvb/frontends/sp887x.c index 1aa2539f5099..49f55877f513 100644 --- a/drivers/media/dvb/frontends/sp887x.c +++ b/drivers/media/dvb/frontends/sp887x.c | |||
| @@ -43,7 +43,7 @@ static int i2c_writebytes (struct sp887x_state* state, u8 *buf, u8 len) | |||
| 43 | 43 | ||
| 44 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { | 44 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { |
| 45 | printk ("%s: i2c write error (addr %02x, err == %i)\n", | 45 | printk ("%s: i2c write error (addr %02x, err == %i)\n", |
| 46 | __FUNCTION__, state->config->demod_address, err); | 46 | __func__, state->config->demod_address, err); |
| 47 | return -EREMOTEIO; | 47 | return -EREMOTEIO; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| @@ -65,7 +65,7 @@ static int sp887x_writereg (struct sp887x_state* state, u16 reg, u16 data) | |||
| 65 | { | 65 | { |
| 66 | printk("%s: writereg error " | 66 | printk("%s: writereg error " |
| 67 | "(reg %03x, data %03x, ret == %i)\n", | 67 | "(reg %03x, data %03x, ret == %i)\n", |
| 68 | __FUNCTION__, reg & 0xffff, data & 0xffff, ret); | 68 | __func__, reg & 0xffff, data & 0xffff, ret); |
| 69 | return ret; | 69 | return ret; |
| 70 | } | 70 | } |
| 71 | } | 71 | } |
| @@ -82,7 +82,7 @@ static int sp887x_readreg (struct sp887x_state* state, u16 reg) | |||
| 82 | { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 }}; | 82 | { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 }}; |
| 83 | 83 | ||
| 84 | if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) { | 84 | if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) { |
| 85 | printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret); | 85 | printk("%s: readreg error (ret == %i)\n", __func__, ret); |
| 86 | return -1; | 86 | return -1; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| @@ -91,7 +91,7 @@ static int sp887x_readreg (struct sp887x_state* state, u16 reg) | |||
| 91 | 91 | ||
| 92 | static void sp887x_microcontroller_stop (struct sp887x_state* state) | 92 | static void sp887x_microcontroller_stop (struct sp887x_state* state) |
| 93 | { | 93 | { |
| 94 | dprintk("%s\n", __FUNCTION__); | 94 | dprintk("%s\n", __func__); |
| 95 | sp887x_writereg(state, 0xf08, 0x000); | 95 | sp887x_writereg(state, 0xf08, 0x000); |
| 96 | sp887x_writereg(state, 0xf09, 0x000); | 96 | sp887x_writereg(state, 0xf09, 0x000); |
| 97 | 97 | ||
| @@ -101,7 +101,7 @@ static void sp887x_microcontroller_stop (struct sp887x_state* state) | |||
| 101 | 101 | ||
| 102 | static void sp887x_microcontroller_start (struct sp887x_state* state) | 102 | static void sp887x_microcontroller_start (struct sp887x_state* state) |
| 103 | { | 103 | { |
| 104 | dprintk("%s\n", __FUNCTION__); | 104 | dprintk("%s\n", __func__); |
| 105 | sp887x_writereg(state, 0xf08, 0x000); | 105 | sp887x_writereg(state, 0xf08, 0x000); |
| 106 | sp887x_writereg(state, 0xf09, 0x000); | 106 | sp887x_writereg(state, 0xf09, 0x000); |
| 107 | 107 | ||
| @@ -112,7 +112,7 @@ static void sp887x_microcontroller_start (struct sp887x_state* state) | |||
| 112 | static void sp887x_setup_agc (struct sp887x_state* state) | 112 | static void sp887x_setup_agc (struct sp887x_state* state) |
| 113 | { | 113 | { |
| 114 | /* setup AGC parameters */ | 114 | /* setup AGC parameters */ |
| 115 | dprintk("%s\n", __FUNCTION__); | 115 | dprintk("%s\n", __func__); |
| 116 | sp887x_writereg(state, 0x33c, 0x054); | 116 | sp887x_writereg(state, 0x33c, 0x054); |
| 117 | sp887x_writereg(state, 0x33b, 0x04c); | 117 | sp887x_writereg(state, 0x33b, 0x04c); |
| 118 | sp887x_writereg(state, 0x328, 0x000); | 118 | sp887x_writereg(state, 0x328, 0x000); |
| @@ -142,7 +142,7 @@ static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware | |||
| 142 | int fw_size = fw->size; | 142 | int fw_size = fw->size; |
| 143 | unsigned char *mem = fw->data; | 143 | unsigned char *mem = fw->data; |
| 144 | 144 | ||
| 145 | dprintk("%s\n", __FUNCTION__); | 145 | dprintk("%s\n", __func__); |
| 146 | 146 | ||
| 147 | /* ignore the first 10 bytes, then we expect 0x4000 bytes of firmware */ | 147 | /* ignore the first 10 bytes, then we expect 0x4000 bytes of firmware */ |
| 148 | if (fw_size < FW_SIZE+10) | 148 | if (fw_size < FW_SIZE+10) |
| @@ -155,7 +155,7 @@ static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware | |||
| 155 | 155 | ||
| 156 | sp887x_microcontroller_stop (state); | 156 | sp887x_microcontroller_stop (state); |
| 157 | 157 | ||
| 158 | printk ("%s: firmware upload... ", __FUNCTION__); | 158 | printk ("%s: firmware upload... ", __func__); |
| 159 | 159 | ||
| 160 | /* setup write pointer to -1 (end of memory) */ | 160 | /* setup write pointer to -1 (end of memory) */ |
| 161 | /* bit 0x8000 in address is set to enable 13bit mode */ | 161 | /* bit 0x8000 in address is set to enable 13bit mode */ |
| @@ -181,7 +181,7 @@ static int sp887x_initial_setup (struct dvb_frontend* fe, const struct firmware | |||
| 181 | 181 | ||
| 182 | if ((err = i2c_writebytes (state, buf, c+2)) < 0) { | 182 | if ((err = i2c_writebytes (state, buf, c+2)) < 0) { |
| 183 | printk ("failed.\n"); | 183 | printk ("failed.\n"); |
| 184 | printk ("%s: i2c error (err == %i)\n", __FUNCTION__, err); | 184 | printk ("%s: i2c error (err == %i)\n", __func__, err); |
| 185 | return err; | 185 | return err; |
| 186 | } | 186 | } |
| 187 | } | 187 | } |
diff --git a/drivers/media/dvb/frontends/sp887x.h b/drivers/media/dvb/frontends/sp887x.h index 7ee78d7d916d..04eff6e0eef3 100644 --- a/drivers/media/dvb/frontends/sp887x.h +++ b/drivers/media/dvb/frontends/sp887x.h | |||
| @@ -24,7 +24,7 @@ extern struct dvb_frontend* sp887x_attach(const struct sp887x_config* config, | |||
| 24 | static inline struct dvb_frontend* sp887x_attach(const struct sp887x_config* config, | 24 | static inline struct dvb_frontend* sp887x_attach(const struct sp887x_config* config, |
| 25 | struct i2c_adapter* i2c) | 25 | struct i2c_adapter* i2c) |
| 26 | { | 26 | { |
| 27 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 27 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 28 | return NULL; | 28 | return NULL; |
| 29 | } | 29 | } |
| 30 | #endif // CONFIG_DVB_SP887X | 30 | #endif // CONFIG_DVB_SP887X |
diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c index 7c23775f77db..62caf802ed99 100644 --- a/drivers/media/dvb/frontends/stv0297.c +++ b/drivers/media/dvb/frontends/stv0297.c | |||
| @@ -58,7 +58,7 @@ static int stv0297_writereg(struct stv0297_state *state, u8 reg, u8 data) | |||
| 58 | 58 | ||
| 59 | if (ret != 1) | 59 | if (ret != 1) |
| 60 | dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, " | 60 | dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, " |
| 61 | "ret == %i)\n", __FUNCTION__, reg, data, ret); | 61 | "ret == %i)\n", __func__, reg, data, ret); |
| 62 | 62 | ||
| 63 | return (ret != 1) ? -1 : 0; | 63 | return (ret != 1) ? -1 : 0; |
| 64 | } | 64 | } |
| @@ -75,16 +75,16 @@ static int stv0297_readreg(struct stv0297_state *state, u8 reg) | |||
| 75 | // this device needs a STOP between the register and data | 75 | // this device needs a STOP between the register and data |
| 76 | if (state->config->stop_during_read) { | 76 | if (state->config->stop_during_read) { |
| 77 | if ((ret = i2c_transfer(state->i2c, &msg[0], 1)) != 1) { | 77 | if ((ret = i2c_transfer(state->i2c, &msg[0], 1)) != 1) { |
| 78 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg, ret); | 78 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __func__, reg, ret); |
| 79 | return -1; | 79 | return -1; |
| 80 | } | 80 | } |
| 81 | if ((ret = i2c_transfer(state->i2c, &msg[1], 1)) != 1) { | 81 | if ((ret = i2c_transfer(state->i2c, &msg[1], 1)) != 1) { |
| 82 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg, ret); | 82 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __func__, reg, ret); |
| 83 | return -1; | 83 | return -1; |
| 84 | } | 84 | } |
| 85 | } else { | 85 | } else { |
| 86 | if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) { | 86 | if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) { |
| 87 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg, ret); | 87 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __func__, reg, ret); |
| 88 | return -1; | 88 | return -1; |
| 89 | } | 89 | } |
| 90 | } | 90 | } |
| @@ -115,16 +115,16 @@ static int stv0297_readregs(struct stv0297_state *state, u8 reg1, u8 * b, u8 len | |||
| 115 | // this device needs a STOP between the register and data | 115 | // this device needs a STOP between the register and data |
| 116 | if (state->config->stop_during_read) { | 116 | if (state->config->stop_during_read) { |
| 117 | if ((ret = i2c_transfer(state->i2c, &msg[0], 1)) != 1) { | 117 | if ((ret = i2c_transfer(state->i2c, &msg[0], 1)) != 1) { |
| 118 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg1, ret); | 118 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __func__, reg1, ret); |
| 119 | return -1; | 119 | return -1; |
| 120 | } | 120 | } |
| 121 | if ((ret = i2c_transfer(state->i2c, &msg[1], 1)) != 1) { | 121 | if ((ret = i2c_transfer(state->i2c, &msg[1], 1)) != 1) { |
| 122 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg1, ret); | 122 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __func__, reg1, ret); |
| 123 | return -1; | 123 | return -1; |
| 124 | } | 124 | } |
| 125 | } else { | 125 | } else { |
| 126 | if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) { | 126 | if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) { |
| 127 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __FUNCTION__, reg1, ret); | 127 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", __func__, reg1, ret); |
| 128 | return -1; | 128 | return -1; |
| 129 | } | 129 | } |
| 130 | } | 130 | } |
diff --git a/drivers/media/dvb/frontends/stv0297.h b/drivers/media/dvb/frontends/stv0297.h index 69f4515df2b9..3f8f9468f387 100644 --- a/drivers/media/dvb/frontends/stv0297.h +++ b/drivers/media/dvb/frontends/stv0297.h | |||
| @@ -49,7 +49,7 @@ extern struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, | |||
| 49 | static inline struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, | 49 | static inline struct dvb_frontend* stv0297_attach(const struct stv0297_config* config, |
| 50 | struct i2c_adapter* i2c) | 50 | struct i2c_adapter* i2c) |
| 51 | { | 51 | { |
| 52 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 52 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 53 | return NULL; | 53 | return NULL; |
| 54 | } | 54 | } |
| 55 | #endif // CONFIG_DVB_STV0297 | 55 | #endif // CONFIG_DVB_STV0297 |
diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c index 035dd7ba6519..17556183e871 100644 --- a/drivers/media/dvb/frontends/stv0299.c +++ b/drivers/media/dvb/frontends/stv0299.c | |||
| @@ -86,7 +86,7 @@ static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data) | |||
| 86 | 86 | ||
| 87 | if (ret != 1) | 87 | if (ret != 1) |
| 88 | dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, " | 88 | dprintk("%s: writereg error (reg == 0x%02x, val == 0x%02x, " |
| 89 | "ret == %i)\n", __FUNCTION__, reg, data, ret); | 89 | "ret == %i)\n", __func__, reg, data, ret); |
| 90 | 90 | ||
| 91 | return (ret != 1) ? -EREMOTEIO : 0; | 91 | return (ret != 1) ? -EREMOTEIO : 0; |
| 92 | } | 92 | } |
| @@ -113,7 +113,7 @@ static u8 stv0299_readreg (struct stv0299_state* state, u8 reg) | |||
| 113 | 113 | ||
| 114 | if (ret != 2) | 114 | if (ret != 2) |
| 115 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", | 115 | dprintk("%s: readreg error (reg == 0x%02x, ret == %i)\n", |
| 116 | __FUNCTION__, reg, ret); | 116 | __func__, reg, ret); |
| 117 | 117 | ||
| 118 | return b1[0]; | 118 | return b1[0]; |
| 119 | } | 119 | } |
| @@ -127,14 +127,14 @@ static int stv0299_readregs (struct stv0299_state* state, u8 reg1, u8 *b, u8 len | |||
| 127 | ret = i2c_transfer (state->i2c, msg, 2); | 127 | ret = i2c_transfer (state->i2c, msg, 2); |
| 128 | 128 | ||
| 129 | if (ret != 2) | 129 | if (ret != 2) |
| 130 | dprintk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret); | 130 | dprintk("%s: readreg error (ret == %i)\n", __func__, ret); |
| 131 | 131 | ||
| 132 | return ret == 2 ? 0 : ret; | 132 | return ret == 2 ? 0 : ret; |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | static int stv0299_set_FEC (struct stv0299_state* state, fe_code_rate_t fec) | 135 | static int stv0299_set_FEC (struct stv0299_state* state, fe_code_rate_t fec) |
| 136 | { | 136 | { |
| 137 | dprintk ("%s\n", __FUNCTION__); | 137 | dprintk ("%s\n", __func__); |
| 138 | 138 | ||
| 139 | switch (fec) { | 139 | switch (fec) { |
| 140 | case FEC_AUTO: | 140 | case FEC_AUTO: |
| @@ -174,7 +174,7 @@ static fe_code_rate_t stv0299_get_fec (struct stv0299_state* state) | |||
| 174 | FEC_7_8, FEC_1_2 }; | 174 | FEC_7_8, FEC_1_2 }; |
| 175 | u8 index; | 175 | u8 index; |
| 176 | 176 | ||
| 177 | dprintk ("%s\n", __FUNCTION__); | 177 | dprintk ("%s\n", __func__); |
| 178 | 178 | ||
| 179 | index = stv0299_readreg (state, 0x1b); | 179 | index = stv0299_readreg (state, 0x1b); |
| 180 | index &= 0x7; | 180 | index &= 0x7; |
| @@ -189,11 +189,11 @@ static int stv0299_wait_diseqc_fifo (struct stv0299_state* state, int timeout) | |||
| 189 | { | 189 | { |
| 190 | unsigned long start = jiffies; | 190 | unsigned long start = jiffies; |
| 191 | 191 | ||
| 192 | dprintk ("%s\n", __FUNCTION__); | 192 | dprintk ("%s\n", __func__); |
| 193 | 193 | ||
| 194 | while (stv0299_readreg(state, 0x0a) & 1) { | 194 | while (stv0299_readreg(state, 0x0a) & 1) { |
| 195 | if (jiffies - start > timeout) { | 195 | if (jiffies - start > timeout) { |
| 196 | dprintk ("%s: timeout!!\n", __FUNCTION__); | 196 | dprintk ("%s: timeout!!\n", __func__); |
| 197 | return -ETIMEDOUT; | 197 | return -ETIMEDOUT; |
| 198 | } | 198 | } |
| 199 | msleep(10); | 199 | msleep(10); |
| @@ -206,11 +206,11 @@ static int stv0299_wait_diseqc_idle (struct stv0299_state* state, int timeout) | |||
| 206 | { | 206 | { |
| 207 | unsigned long start = jiffies; | 207 | unsigned long start = jiffies; |
| 208 | 208 | ||
| 209 | dprintk ("%s\n", __FUNCTION__); | 209 | dprintk ("%s\n", __func__); |
| 210 | 210 | ||
| 211 | while ((stv0299_readreg(state, 0x0a) & 3) != 2 ) { | 211 | while ((stv0299_readreg(state, 0x0a) & 3) != 2 ) { |
| 212 | if (jiffies - start > timeout) { | 212 | if (jiffies - start > timeout) { |
| 213 | dprintk ("%s: timeout!!\n", __FUNCTION__); | 213 | dprintk ("%s: timeout!!\n", __func__); |
| 214 | return -ETIMEDOUT; | 214 | return -ETIMEDOUT; |
| 215 | } | 215 | } |
| 216 | msleep(10); | 216 | msleep(10); |
| @@ -245,7 +245,7 @@ static int stv0299_get_symbolrate (struct stv0299_state* state) | |||
| 245 | u8 sfr[3]; | 245 | u8 sfr[3]; |
| 246 | s8 rtf; | 246 | s8 rtf; |
| 247 | 247 | ||
| 248 | dprintk ("%s\n", __FUNCTION__); | 248 | dprintk ("%s\n", __func__); |
| 249 | 249 | ||
| 250 | stv0299_readregs (state, 0x1f, sfr, 3); | 250 | stv0299_readregs (state, 0x1f, sfr, 3); |
| 251 | stv0299_readregs (state, 0x1a, (u8 *)&rtf, 1); | 251 | stv0299_readregs (state, 0x1a, (u8 *)&rtf, 1); |
| @@ -257,8 +257,8 @@ static int stv0299_get_symbolrate (struct stv0299_state* state) | |||
| 257 | offset = (s32) rtf * (srate / 4096L); | 257 | offset = (s32) rtf * (srate / 4096L); |
| 258 | offset /= 128; | 258 | offset /= 128; |
| 259 | 259 | ||
| 260 | dprintk ("%s : srate = %i\n", __FUNCTION__, srate); | 260 | dprintk ("%s : srate = %i\n", __func__, srate); |
| 261 | dprintk ("%s : ofset = %i\n", __FUNCTION__, offset); | 261 | dprintk ("%s : ofset = %i\n", __func__, offset); |
| 262 | 262 | ||
| 263 | srate += offset; | 263 | srate += offset; |
| 264 | 264 | ||
| @@ -276,7 +276,7 @@ static int stv0299_send_diseqc_msg (struct dvb_frontend* fe, | |||
| 276 | u8 val; | 276 | u8 val; |
| 277 | int i; | 277 | int i; |
| 278 | 278 | ||
| 279 | dprintk ("%s\n", __FUNCTION__); | 279 | dprintk ("%s\n", __func__); |
| 280 | 280 | ||
| 281 | if (stv0299_wait_diseqc_idle (state, 100) < 0) | 281 | if (stv0299_wait_diseqc_idle (state, 100) < 0) |
| 282 | return -ETIMEDOUT; | 282 | return -ETIMEDOUT; |
| @@ -305,7 +305,7 @@ static int stv0299_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t | |||
| 305 | struct stv0299_state* state = fe->demodulator_priv; | 305 | struct stv0299_state* state = fe->demodulator_priv; |
| 306 | u8 val; | 306 | u8 val; |
| 307 | 307 | ||
| 308 | dprintk ("%s\n", __FUNCTION__); | 308 | dprintk ("%s\n", __func__); |
| 309 | 309 | ||
| 310 | if (stv0299_wait_diseqc_idle (state, 100) < 0) | 310 | if (stv0299_wait_diseqc_idle (state, 100) < 0) |
| 311 | return -ETIMEDOUT; | 311 | return -ETIMEDOUT; |
| @@ -355,7 +355,7 @@ static int stv0299_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag | |||
| 355 | u8 reg0x08; | 355 | u8 reg0x08; |
| 356 | u8 reg0x0c; | 356 | u8 reg0x0c; |
| 357 | 357 | ||
| 358 | dprintk("%s: %s\n", __FUNCTION__, | 358 | dprintk("%s: %s\n", __func__, |
| 359 | voltage == SEC_VOLTAGE_13 ? "SEC_VOLTAGE_13" : | 359 | voltage == SEC_VOLTAGE_13 ? "SEC_VOLTAGE_13" : |
| 360 | voltage == SEC_VOLTAGE_18 ? "SEC_VOLTAGE_18" : "??"); | 360 | voltage == SEC_VOLTAGE_18 ? "SEC_VOLTAGE_18" : "??"); |
| 361 | 361 | ||
| @@ -366,26 +366,32 @@ static int stv0299_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltag | |||
| 366 | * H/V switching over OP0, OP1 and OP2 are LNB power enable bits | 366 | * H/V switching over OP0, OP1 and OP2 are LNB power enable bits |
| 367 | */ | 367 | */ |
| 368 | reg0x0c &= 0x0f; | 368 | reg0x0c &= 0x0f; |
| 369 | 369 | reg0x08 = (reg0x08 & 0x3f) | (state->config->lock_output << 6); | |
| 370 | if (voltage == SEC_VOLTAGE_OFF) { | ||
| 371 | stv0299_writeregI (state, 0x0c, 0x00); /* LNB power off! */ | ||
| 372 | return stv0299_writeregI (state, 0x08, 0x00); /* LNB power off! */ | ||
| 373 | } | ||
| 374 | |||
| 375 | stv0299_writeregI (state, 0x08, (reg0x08 & 0x3f) | (state->config->lock_output << 6)); | ||
| 376 | 370 | ||
| 377 | switch (voltage) { | 371 | switch (voltage) { |
| 378 | case SEC_VOLTAGE_13: | 372 | case SEC_VOLTAGE_13: |
| 379 | if (state->config->volt13_op0_op1 == STV0299_VOLT13_OP0) reg0x0c |= 0x10; | 373 | if (state->config->volt13_op0_op1 == STV0299_VOLT13_OP0) |
| 380 | else reg0x0c |= 0x40; | 374 | reg0x0c |= 0x10; /* OP1 off, OP0 on */ |
| 381 | 375 | else | |
| 382 | return stv0299_writeregI(state, 0x0c, reg0x0c); | 376 | reg0x0c |= 0x40; /* OP1 on, OP0 off */ |
| 383 | 377 | break; | |
| 384 | case SEC_VOLTAGE_18: | 378 | case SEC_VOLTAGE_18: |
| 385 | return stv0299_writeregI(state, 0x0c, reg0x0c | 0x50); | 379 | reg0x0c |= 0x50; /* OP1 on, OP0 on */ |
| 380 | break; | ||
| 381 | case SEC_VOLTAGE_OFF: | ||
| 382 | /* LNB power off! */ | ||
| 383 | reg0x08 = 0x00; | ||
| 384 | reg0x0c = 0x00; | ||
| 385 | break; | ||
| 386 | default: | 386 | default: |
| 387 | return -EINVAL; | 387 | return -EINVAL; |
| 388 | }; | 388 | }; |
| 389 | |||
| 390 | if (state->config->op0_off) | ||
| 391 | reg0x0c &= ~0x10; | ||
| 392 | |||
| 393 | stv0299_writeregI(state, 0x08, reg0x08); | ||
| 394 | return stv0299_writeregI(state, 0x0c, reg0x0c); | ||
| 389 | } | 395 | } |
| 390 | 396 | ||
| 391 | static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long cmd) | 397 | static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long cmd) |
| @@ -408,7 +414,7 @@ static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long | |||
| 408 | 414 | ||
| 409 | cmd = cmd << 1; | 415 | cmd = cmd << 1; |
| 410 | if (debug_legacy_dish_switch) | 416 | if (debug_legacy_dish_switch) |
| 411 | printk ("%s switch command: 0x%04lx\n",__FUNCTION__, cmd); | 417 | printk ("%s switch command: 0x%04lx\n",__func__, cmd); |
| 412 | 418 | ||
| 413 | do_gettimeofday (&nexttime); | 419 | do_gettimeofday (&nexttime); |
| 414 | if (debug_legacy_dish_switch) | 420 | if (debug_legacy_dish_switch) |
| @@ -433,7 +439,7 @@ static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, unsigned long | |||
| 433 | } | 439 | } |
| 434 | if (debug_legacy_dish_switch) { | 440 | if (debug_legacy_dish_switch) { |
| 435 | printk ("%s(%d): switch delay (should be 32k followed by all 8k\n", | 441 | printk ("%s(%d): switch delay (should be 32k followed by all 8k\n", |
| 436 | __FUNCTION__, fe->dvb->num); | 442 | __func__, fe->dvb->num); |
| 437 | for (i = 1; i < 10; i++) | 443 | for (i = 1; i < 10; i++) |
| 438 | printk ("%d: %d\n", i, timeval_usec_diff(tv[i-1] , tv[i])); | 444 | printk ("%d: %d\n", i, timeval_usec_diff(tv[i-1] , tv[i])); |
| 439 | } | 445 | } |
| @@ -445,11 +451,20 @@ static int stv0299_init (struct dvb_frontend* fe) | |||
| 445 | { | 451 | { |
| 446 | struct stv0299_state* state = fe->demodulator_priv; | 452 | struct stv0299_state* state = fe->demodulator_priv; |
| 447 | int i; | 453 | int i; |
| 454 | u8 reg; | ||
| 455 | u8 val; | ||
| 448 | 456 | ||
| 449 | dprintk("stv0299: init chip\n"); | 457 | dprintk("stv0299: init chip\n"); |
| 450 | 458 | ||
| 451 | for (i=0; !(state->config->inittab[i] == 0xff && state->config->inittab[i+1] == 0xff); i+=2) | 459 | for (i = 0; ; i += 2) { |
| 452 | stv0299_writeregI(state, state->config->inittab[i], state->config->inittab[i+1]); | 460 | reg = state->config->inittab[i]; |
| 461 | val = state->config->inittab[i+1]; | ||
| 462 | if (reg == 0xff && val == 0xff) | ||
| 463 | break; | ||
| 464 | if (reg == 0x0c && state->config->op0_off) | ||
| 465 | val &= ~0x10; | ||
| 466 | stv0299_writeregI(state, reg, val); | ||
| 467 | } | ||
| 453 | 468 | ||
| 454 | return 0; | 469 | return 0; |
| 455 | } | 470 | } |
| @@ -461,7 +476,7 @@ static int stv0299_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 461 | u8 signal = 0xff - stv0299_readreg (state, 0x18); | 476 | u8 signal = 0xff - stv0299_readreg (state, 0x18); |
| 462 | u8 sync = stv0299_readreg (state, 0x1b); | 477 | u8 sync = stv0299_readreg (state, 0x1b); |
| 463 | 478 | ||
| 464 | dprintk ("%s : FE_READ_STATUS : VSTATUS: 0x%02x\n", __FUNCTION__, sync); | 479 | dprintk ("%s : FE_READ_STATUS : VSTATUS: 0x%02x\n", __func__, sync); |
| 465 | *status = 0; | 480 | *status = 0; |
| 466 | 481 | ||
| 467 | if (signal > 10) | 482 | if (signal > 10) |
| @@ -499,7 +514,7 @@ static int stv0299_read_signal_strength(struct dvb_frontend* fe, u16* strength) | |||
| 499 | s32 signal = 0xffff - ((stv0299_readreg (state, 0x18) << 8) | 514 | s32 signal = 0xffff - ((stv0299_readreg (state, 0x18) << 8) |
| 500 | | stv0299_readreg (state, 0x19)); | 515 | | stv0299_readreg (state, 0x19)); |
| 501 | 516 | ||
| 502 | dprintk ("%s : FE_READ_SIGNAL_STRENGTH : AGC2I: 0x%02x%02x, signal=0x%04x\n", __FUNCTION__, | 517 | dprintk ("%s : FE_READ_SIGNAL_STRENGTH : AGC2I: 0x%02x%02x, signal=0x%04x\n", __func__, |
| 503 | stv0299_readreg (state, 0x18), | 518 | stv0299_readreg (state, 0x18), |
| 504 | stv0299_readreg (state, 0x19), (int) signal); | 519 | stv0299_readreg (state, 0x19), (int) signal); |
| 505 | 520 | ||
| @@ -536,7 +551,7 @@ static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par | |||
| 536 | struct stv0299_state* state = fe->demodulator_priv; | 551 | struct stv0299_state* state = fe->demodulator_priv; |
| 537 | int invval = 0; | 552 | int invval = 0; |
| 538 | 553 | ||
| 539 | dprintk ("%s : FE_SET_FRONTEND\n", __FUNCTION__); | 554 | dprintk ("%s : FE_SET_FRONTEND\n", __func__); |
| 540 | 555 | ||
| 541 | // set the inversion | 556 | // set the inversion |
| 542 | if (p->inversion == INVERSION_OFF) invval = 0; | 557 | if (p->inversion == INVERSION_OFF) invval = 0; |
diff --git a/drivers/media/dvb/frontends/stv0299.h b/drivers/media/dvb/frontends/stv0299.h index 33df9495908f..3282f43022f5 100644 --- a/drivers/media/dvb/frontends/stv0299.h +++ b/drivers/media/dvb/frontends/stv0299.h | |||
| @@ -48,10 +48,10 @@ | |||
| 48 | #include <linux/dvb/frontend.h> | 48 | #include <linux/dvb/frontend.h> |
| 49 | #include "dvb_frontend.h" | 49 | #include "dvb_frontend.h" |
| 50 | 50 | ||
| 51 | #define STV0229_LOCKOUTPUT_0 0 | 51 | #define STV0299_LOCKOUTPUT_0 0 |
| 52 | #define STV0229_LOCKOUTPUT_1 1 | 52 | #define STV0299_LOCKOUTPUT_1 1 |
| 53 | #define STV0229_LOCKOUTPUT_CF 2 | 53 | #define STV0299_LOCKOUTPUT_CF 2 |
| 54 | #define STV0229_LOCKOUTPUT_LK 3 | 54 | #define STV0299_LOCKOUTPUT_LK 3 |
| 55 | 55 | ||
| 56 | #define STV0299_VOLT13_OP0 0 | 56 | #define STV0299_VOLT13_OP0 0 |
| 57 | #define STV0299_VOLT13_OP1 1 | 57 | #define STV0299_VOLT13_OP1 1 |
| @@ -82,6 +82,9 @@ struct stv0299_config | |||
| 82 | /* Is 13v controlled by OP0 or OP1? */ | 82 | /* Is 13v controlled by OP0 or OP1? */ |
| 83 | u8 volt13_op0_op1:1; | 83 | u8 volt13_op0_op1:1; |
| 84 | 84 | ||
| 85 | /* Turn-off OP0? */ | ||
| 86 | u8 op0_off:1; | ||
| 87 | |||
| 85 | /* minimum delay before retuning */ | 88 | /* minimum delay before retuning */ |
| 86 | int min_delay_ms; | 89 | int min_delay_ms; |
| 87 | 90 | ||
| @@ -96,7 +99,7 @@ extern struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, | |||
| 96 | static inline struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, | 99 | static inline struct dvb_frontend* stv0299_attach(const struct stv0299_config* config, |
| 97 | struct i2c_adapter* i2c) | 100 | struct i2c_adapter* i2c) |
| 98 | { | 101 | { |
| 99 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 102 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 100 | return NULL; | 103 | return NULL; |
| 101 | } | 104 | } |
| 102 | #endif // CONFIG_DVB_STV0299 | 105 | #endif // CONFIG_DVB_STV0299 |
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c index 45137d2ebfb9..f648fdb64bb7 100644 --- a/drivers/media/dvb/frontends/tda10021.c +++ b/drivers/media/dvb/frontends/tda10021.c | |||
| @@ -79,7 +79,7 @@ static int _tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data) | |||
| 79 | if (ret != 1) | 79 | if (ret != 1) |
| 80 | printk("DVB: TDA10021(%d): %s, writereg error " | 80 | printk("DVB: TDA10021(%d): %s, writereg error " |
| 81 | "(reg == 0x%02x, val == 0x%02x, ret == %i)\n", | 81 | "(reg == 0x%02x, val == 0x%02x, ret == %i)\n", |
| 82 | state->frontend.dvb->num, __FUNCTION__, reg, data, ret); | 82 | state->frontend.dvb->num, __func__, reg, data, ret); |
| 83 | 83 | ||
| 84 | msleep(10); | 84 | msleep(10); |
| 85 | return (ret != 1) ? -EREMOTEIO : 0; | 85 | return (ret != 1) ? -EREMOTEIO : 0; |
| @@ -97,7 +97,7 @@ static u8 tda10021_readreg (struct tda10021_state* state, u8 reg) | |||
| 97 | // Don't print an error message if the id is read. | 97 | // Don't print an error message if the id is read. |
| 98 | if (ret != 2 && reg != 0x1a) | 98 | if (ret != 2 && reg != 0x1a) |
| 99 | printk("DVB: TDA10021: %s: readreg error (ret == %i)\n", | 99 | printk("DVB: TDA10021: %s: readreg error (ret == %i)\n", |
| 100 | __FUNCTION__, ret); | 100 | __func__, ret); |
| 101 | return b1[0]; | 101 | return b1[0]; |
| 102 | } | 102 | } |
| 103 | 103 | ||
diff --git a/drivers/media/dvb/frontends/tda10023.c b/drivers/media/dvb/frontends/tda10023.c index 364bc01971a0..0727b80bc4d2 100644 --- a/drivers/media/dvb/frontends/tda10023.c +++ b/drivers/media/dvb/frontends/tda10023.c | |||
| @@ -118,7 +118,7 @@ static u8 tda10023_readreg (struct tda10023_state* state, u8 reg) | |||
| 118 | ret = i2c_transfer (state->i2c, msg, 2); | 118 | ret = i2c_transfer (state->i2c, msg, 2); |
| 119 | if (ret != 2) | 119 | if (ret != 2) |
| 120 | printk("DVB: TDA10023: %s: readreg error (ret == %i)\n", | 120 | printk("DVB: TDA10023: %s: readreg error (ret == %i)\n", |
| 121 | __FUNCTION__, ret); | 121 | __func__, ret); |
| 122 | return b1[0]; | 122 | return b1[0]; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| @@ -132,7 +132,7 @@ static int tda10023_writereg (struct tda10023_state* state, u8 reg, u8 data) | |||
| 132 | if (ret != 1) | 132 | if (ret != 1) |
| 133 | printk("DVB: TDA10023(%d): %s, writereg error " | 133 | printk("DVB: TDA10023(%d): %s, writereg error " |
| 134 | "(reg == 0x%02x, val == 0x%02x, ret == %i)\n", | 134 | "(reg == 0x%02x, val == 0x%02x, ret == %i)\n", |
| 135 | state->frontend.dvb->num, __FUNCTION__, reg, data, ret); | 135 | state->frontend.dvb->num, __func__, reg, data, ret); |
| 136 | 136 | ||
| 137 | return (ret != 1) ? -EREMOTEIO : 0; | 137 | return (ret != 1) ? -EREMOTEIO : 0; |
| 138 | } | 138 | } |
diff --git a/drivers/media/dvb/frontends/tda1002x.h b/drivers/media/dvb/frontends/tda1002x.h index e9094d8123f6..1bcc0d44b90b 100644 --- a/drivers/media/dvb/frontends/tda1002x.h +++ b/drivers/media/dvb/frontends/tda1002x.h | |||
| @@ -40,7 +40,7 @@ extern struct dvb_frontend* tda10021_attach(const struct tda1002x_config* config | |||
| 40 | static inline struct dvb_frontend* tda10021_attach(const struct tda1002x_config* config, | 40 | static inline struct dvb_frontend* tda10021_attach(const struct tda1002x_config* config, |
| 41 | struct i2c_adapter* i2c, u8 pwm) | 41 | struct i2c_adapter* i2c, u8 pwm) |
| 42 | { | 42 | { |
| 43 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 43 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 44 | return NULL; | 44 | return NULL; |
| 45 | } | 45 | } |
| 46 | #endif // CONFIG_DVB_TDA10021 | 46 | #endif // CONFIG_DVB_TDA10021 |
| @@ -52,7 +52,7 @@ extern struct dvb_frontend* tda10023_attach(const struct tda1002x_config* config | |||
| 52 | static inline struct dvb_frontend* tda10023_attach(const struct tda1002x_config* config, | 52 | static inline struct dvb_frontend* tda10023_attach(const struct tda1002x_config* config, |
| 53 | struct i2c_adapter* i2c, u8 pwm) | 53 | struct i2c_adapter* i2c, u8 pwm) |
| 54 | { | 54 | { |
| 55 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 55 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 56 | return NULL; | 56 | return NULL; |
| 57 | } | 57 | } |
| 58 | #endif // CONFIG_DVB_TDA10023 | 58 | #endif // CONFIG_DVB_TDA10023 |
diff --git a/drivers/media/dvb/frontends/tda10048.c b/drivers/media/dvb/frontends/tda10048.c new file mode 100644 index 000000000000..090fb7dd93c6 --- /dev/null +++ b/drivers/media/dvb/frontends/tda10048.c | |||
| @@ -0,0 +1,841 @@ | |||
| 1 | /* | ||
| 2 | NXP TDA10048HN DVB OFDM demodulator driver | ||
| 3 | |||
| 4 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/kernel.h> | ||
| 23 | #include <linux/init.h> | ||
| 24 | #include <linux/module.h> | ||
| 25 | #include <linux/string.h> | ||
| 26 | #include <linux/slab.h> | ||
| 27 | #include <linux/delay.h> | ||
| 28 | #include "dvb_frontend.h" | ||
| 29 | #include "dvb_math.h" | ||
| 30 | #include "tda10048.h" | ||
| 31 | |||
| 32 | #define TDA10048_DEFAULT_FIRMWARE "dvb-fe-tda10048-1.0.fw" | ||
| 33 | #define TDA10048_DEFAULT_FIRMWARE_SIZE 24878 | ||
| 34 | |||
| 35 | /* Register name definitions */ | ||
| 36 | #define TDA10048_IDENTITY 0x00 | ||
| 37 | #define TDA10048_VERSION 0x01 | ||
| 38 | #define TDA10048_DSP_CODE_CPT 0x0C | ||
| 39 | #define TDA10048_DSP_CODE_IN 0x0E | ||
| 40 | #define TDA10048_IN_CONF1 0x10 | ||
| 41 | #define TDA10048_IN_CONF2 0x11 | ||
| 42 | #define TDA10048_IN_CONF3 0x12 | ||
| 43 | #define TDA10048_OUT_CONF1 0x14 | ||
| 44 | #define TDA10048_OUT_CONF2 0x15 | ||
| 45 | #define TDA10048_OUT_CONF3 0x16 | ||
| 46 | #define TDA10048_AUTO 0x18 | ||
| 47 | #define TDA10048_SYNC_STATUS 0x1A | ||
| 48 | #define TDA10048_CONF_C4_1 0x1E | ||
| 49 | #define TDA10048_CONF_C4_2 0x1F | ||
| 50 | #define TDA10048_CODE_IN_RAM 0x20 | ||
| 51 | #define TDA10048_CHANNEL_INFO_1_R 0x22 | ||
| 52 | #define TDA10048_CHANNEL_INFO_2_R 0x23 | ||
| 53 | #define TDA10048_CHANNEL_INFO1 0x24 | ||
| 54 | #define TDA10048_CHANNEL_INFO2 0x25 | ||
| 55 | #define TDA10048_TIME_ERROR_R 0x26 | ||
| 56 | #define TDA10048_TIME_ERROR 0x27 | ||
| 57 | #define TDA10048_FREQ_ERROR_LSB_R 0x28 | ||
| 58 | #define TDA10048_FREQ_ERROR_MSB_R 0x29 | ||
| 59 | #define TDA10048_FREQ_ERROR_LSB 0x2A | ||
| 60 | #define TDA10048_FREQ_ERROR_MSB 0x2B | ||
| 61 | #define TDA10048_IT_SEL 0x30 | ||
| 62 | #define TDA10048_IT_STAT 0x32 | ||
| 63 | #define TDA10048_DSP_AD_LSB 0x3C | ||
| 64 | #define TDA10048_DSP_AD_MSB 0x3D | ||
| 65 | #define TDA10048_DSP_REF_LSB 0x3E | ||
| 66 | #define TDA10048_DSP_REF_MSB 0x3F | ||
| 67 | #define TDA10048_CONF_TRISTATE1 0x44 | ||
| 68 | #define TDA10048_CONF_TRISTATE2 0x45 | ||
| 69 | #define TDA10048_CONF_POLARITY 0x46 | ||
| 70 | #define TDA10048_GPIO_SP_DS0 0x48 | ||
| 71 | #define TDA10048_GPIO_SP_DS1 0x49 | ||
| 72 | #define TDA10048_GPIO_SP_DS2 0x4A | ||
| 73 | #define TDA10048_GPIO_SP_DS3 0x4B | ||
| 74 | #define TDA10048_GPIO_OUT_SEL 0x4C | ||
| 75 | #define TDA10048_GPIO_SELECT 0x4D | ||
| 76 | #define TDA10048_IC_MODE 0x4E | ||
| 77 | #define TDA10048_CONF_XO 0x50 | ||
| 78 | #define TDA10048_CONF_PLL1 0x51 | ||
| 79 | #define TDA10048_CONF_PLL2 0x52 | ||
| 80 | #define TDA10048_CONF_PLL3 0x53 | ||
| 81 | #define TDA10048_CONF_ADC 0x54 | ||
| 82 | #define TDA10048_CONF_ADC_2 0x55 | ||
| 83 | #define TDA10048_CONF_C1_1 0x60 | ||
| 84 | #define TDA10048_CONF_C1_3 0x62 | ||
| 85 | #define TDA10048_AGC_CONF 0x70 | ||
| 86 | #define TDA10048_AGC_THRESHOLD_LSB 0x72 | ||
| 87 | #define TDA10048_AGC_THRESHOLD_MSB 0x73 | ||
| 88 | #define TDA10048_AGC_RENORM 0x74 | ||
| 89 | #define TDA10048_AGC_GAINS 0x76 | ||
| 90 | #define TDA10048_AGC_TUN_MIN 0x78 | ||
| 91 | #define TDA10048_AGC_TUN_MAX 0x79 | ||
| 92 | #define TDA10048_AGC_IF_MIN 0x7A | ||
| 93 | #define TDA10048_AGC_IF_MAX 0x7B | ||
| 94 | #define TDA10048_AGC_TUN_LEVEL 0x7E | ||
| 95 | #define TDA10048_AGC_IF_LEVEL 0x7F | ||
| 96 | #define TDA10048_DIG_AGC_LEVEL 0x81 | ||
| 97 | #define TDA10048_FREQ_PHY2_LSB 0x86 | ||
| 98 | #define TDA10048_FREQ_PHY2_MSB 0x87 | ||
| 99 | #define TDA10048_TIME_INVWREF_LSB 0x88 | ||
| 100 | #define TDA10048_TIME_INVWREF_MSB 0x89 | ||
| 101 | #define TDA10048_TIME_WREF_LSB 0x8A | ||
| 102 | #define TDA10048_TIME_WREF_MID1 0x8B | ||
| 103 | #define TDA10048_TIME_WREF_MID2 0x8C | ||
| 104 | #define TDA10048_TIME_WREF_MSB 0x8D | ||
| 105 | #define TDA10048_NP_OUT 0xA2 | ||
| 106 | #define TDA10048_CELL_ID_LSB 0xA4 | ||
| 107 | #define TDA10048_CELL_ID_MSB 0xA5 | ||
| 108 | #define TDA10048_EXTTPS_ODD 0xAA | ||
| 109 | #define TDA10048_EXTTPS_EVEN 0xAB | ||
| 110 | #define TDA10048_TPS_LENGTH 0xAC | ||
| 111 | #define TDA10048_FREE_REG_1 0xB2 | ||
| 112 | #define TDA10048_FREE_REG_2 0xB3 | ||
| 113 | #define TDA10048_CONF_C3_1 0xC0 | ||
| 114 | #define TDA10048_CYBER_CTRL 0xC2 | ||
| 115 | #define TDA10048_CBER_NMAX_LSB 0xC4 | ||
| 116 | #define TDA10048_CBER_NMAX_MSB 0xC5 | ||
| 117 | #define TDA10048_CBER_LSB 0xC6 | ||
| 118 | #define TDA10048_CBER_MSB 0xC7 | ||
| 119 | #define TDA10048_VBER_LSB 0xC8 | ||
| 120 | #define TDA10048_VBER_MID 0xC9 | ||
| 121 | #define TDA10048_VBER_MSB 0xCA | ||
| 122 | #define TDA10048_CYBER_LUT 0xCC | ||
| 123 | #define TDA10048_UNCOR_CTRL 0xCD | ||
| 124 | #define TDA10048_UNCOR_CPT_LSB 0xCE | ||
| 125 | #define TDA10048_UNCOR_CPT_MSB 0xCF | ||
| 126 | #define TDA10048_SOFT_IT_C3 0xD6 | ||
| 127 | #define TDA10048_CONF_TS2 0xE0 | ||
| 128 | #define TDA10048_CONF_TS1 0xE1 | ||
| 129 | |||
| 130 | static unsigned int debug; | ||
| 131 | |||
| 132 | #define dprintk(level, fmt, arg...)\ | ||
| 133 | do { if (debug >= level)\ | ||
| 134 | printk(KERN_DEBUG "tda10048: " fmt, ## arg);\ | ||
| 135 | } while (0) | ||
| 136 | |||
| 137 | struct tda10048_state { | ||
| 138 | |||
| 139 | struct i2c_adapter *i2c; | ||
| 140 | |||
| 141 | /* configuration settings */ | ||
| 142 | const struct tda10048_config *config; | ||
| 143 | struct dvb_frontend frontend; | ||
| 144 | |||
| 145 | int fwloaded; | ||
| 146 | }; | ||
| 147 | |||
| 148 | static struct init_tab { | ||
| 149 | u8 reg; | ||
| 150 | u16 data; | ||
| 151 | } init_tab[] = { | ||
| 152 | { TDA10048_CONF_PLL1, 0x08 }, | ||
| 153 | { TDA10048_CONF_ADC_2, 0x00 }, | ||
| 154 | { TDA10048_CONF_C4_1, 0x00 }, | ||
| 155 | { TDA10048_CONF_PLL1, 0x0f }, | ||
| 156 | { TDA10048_CONF_PLL2, 0x0a }, | ||
| 157 | { TDA10048_CONF_PLL3, 0x43 }, | ||
| 158 | { TDA10048_FREQ_PHY2_LSB, 0x02 }, | ||
| 159 | { TDA10048_FREQ_PHY2_MSB, 0x0a }, | ||
| 160 | { TDA10048_TIME_WREF_LSB, 0xbd }, | ||
| 161 | { TDA10048_TIME_WREF_MID1, 0xe4 }, | ||
| 162 | { TDA10048_TIME_WREF_MID2, 0xa8 }, | ||
| 163 | { TDA10048_TIME_WREF_MSB, 0x02 }, | ||
| 164 | { TDA10048_TIME_INVWREF_LSB, 0x04 }, | ||
| 165 | { TDA10048_TIME_INVWREF_MSB, 0x06 }, | ||
| 166 | { TDA10048_CONF_C4_1, 0x00 }, | ||
| 167 | { TDA10048_CONF_C1_1, 0xa8 }, | ||
| 168 | { TDA10048_AGC_CONF, 0x16 }, | ||
| 169 | { TDA10048_CONF_C1_3, 0x0b }, | ||
| 170 | { TDA10048_AGC_TUN_MIN, 0x00 }, | ||
| 171 | { TDA10048_AGC_TUN_MAX, 0xff }, | ||
| 172 | { TDA10048_AGC_IF_MIN, 0x00 }, | ||
| 173 | { TDA10048_AGC_IF_MAX, 0xff }, | ||
| 174 | { TDA10048_AGC_THRESHOLD_MSB, 0x00 }, | ||
| 175 | { TDA10048_AGC_THRESHOLD_LSB, 0x70 }, | ||
| 176 | { TDA10048_CYBER_CTRL, 0x38 }, | ||
| 177 | { TDA10048_AGC_GAINS, 0x12 }, | ||
| 178 | { TDA10048_CONF_XO, 0x00 }, | ||
| 179 | { TDA10048_CONF_TS1, 0x07 }, | ||
| 180 | { TDA10048_IC_MODE, 0x00 }, | ||
| 181 | { TDA10048_CONF_TS2, 0xc0 }, | ||
| 182 | { TDA10048_CONF_TRISTATE1, 0x21 }, | ||
| 183 | { TDA10048_CONF_TRISTATE2, 0x00 }, | ||
| 184 | { TDA10048_CONF_POLARITY, 0x00 }, | ||
| 185 | { TDA10048_CONF_C4_2, 0x04 }, | ||
| 186 | { TDA10048_CONF_ADC, 0x60 }, | ||
| 187 | { TDA10048_CONF_ADC_2, 0x10 }, | ||
| 188 | { TDA10048_CONF_ADC, 0x60 }, | ||
| 189 | { TDA10048_CONF_ADC_2, 0x00 }, | ||
| 190 | { TDA10048_CONF_C1_1, 0xa8 }, | ||
| 191 | { TDA10048_UNCOR_CTRL, 0x00 }, | ||
| 192 | { TDA10048_CONF_C4_2, 0x04 }, | ||
| 193 | }; | ||
| 194 | |||
| 195 | static int tda10048_writereg(struct tda10048_state *state, u8 reg, u8 data) | ||
| 196 | { | ||
| 197 | int ret; | ||
| 198 | u8 buf [] = { reg, data }; | ||
| 199 | struct i2c_msg msg = { | ||
| 200 | .addr = state->config->demod_address, | ||
| 201 | .flags = 0, .buf = buf, .len = 2 }; | ||
| 202 | |||
| 203 | dprintk(2, "%s(reg = 0x%02x, data = 0x%02x)\n", __func__, reg, data); | ||
| 204 | |||
| 205 | ret = i2c_transfer(state->i2c, &msg, 1); | ||
| 206 | |||
| 207 | if (ret != 1) | ||
| 208 | printk("%s: writereg error (ret == %i)\n", __func__, ret); | ||
| 209 | |||
| 210 | return (ret != 1) ? -1 : 0; | ||
| 211 | } | ||
| 212 | |||
| 213 | static u8 tda10048_readreg(struct tda10048_state *state, u8 reg) | ||
| 214 | { | ||
| 215 | int ret; | ||
| 216 | u8 b0 [] = { reg }; | ||
| 217 | u8 b1 [] = { 0 }; | ||
| 218 | struct i2c_msg msg [] = { | ||
| 219 | { .addr = state->config->demod_address, | ||
| 220 | .flags = 0, .buf = b0, .len = 1 }, | ||
| 221 | { .addr = state->config->demod_address, | ||
| 222 | .flags = I2C_M_RD, .buf = b1, .len = 1 } }; | ||
| 223 | |||
| 224 | dprintk(2, "%s(reg = 0x%02x)\n", __func__, reg); | ||
| 225 | |||
| 226 | ret = i2c_transfer(state->i2c, msg, 2); | ||
| 227 | |||
| 228 | if (ret != 2) | ||
| 229 | printk(KERN_ERR "%s: readreg error (ret == %i)\n", | ||
| 230 | __func__, ret); | ||
| 231 | |||
| 232 | return b1[0]; | ||
| 233 | } | ||
| 234 | |||
| 235 | static int tda10048_writeregbulk(struct tda10048_state *state, u8 reg, | ||
| 236 | u8 *data, u16 len) | ||
| 237 | { | ||
| 238 | int ret = -EREMOTEIO; | ||
| 239 | struct i2c_msg msg; | ||
| 240 | u8 *buf; | ||
| 241 | |||
| 242 | dprintk(2, "%s(%d, ?, len = %d)\n", __func__, reg, len); | ||
| 243 | |||
| 244 | buf = kmalloc(len + 1, GFP_KERNEL); | ||
| 245 | if (buf == NULL) { | ||
| 246 | ret = -ENOMEM; | ||
| 247 | goto error; | ||
| 248 | } | ||
| 249 | |||
| 250 | *buf = reg; | ||
| 251 | memcpy(buf + 1, data, len); | ||
| 252 | |||
| 253 | msg.addr = state->config->demod_address; | ||
| 254 | msg.flags = 0; | ||
| 255 | msg.buf = buf; | ||
| 256 | msg.len = len + 1; | ||
| 257 | |||
| 258 | dprintk(2, "%s(): write len = %d\n", | ||
| 259 | __func__, msg.len); | ||
| 260 | |||
| 261 | ret = i2c_transfer(state->i2c, &msg, 1); | ||
| 262 | if (ret != 1) { | ||
| 263 | printk(KERN_ERR "%s(): writereg error err %i\n", | ||
| 264 | __func__, ret); | ||
| 265 | ret = -EREMOTEIO; | ||
| 266 | } | ||
| 267 | |||
| 268 | error: | ||
| 269 | kfree(buf); | ||
| 270 | |||
| 271 | return ret; | ||
| 272 | } | ||
| 273 | |||
| 274 | static int tda10048_firmware_upload(struct dvb_frontend *fe) | ||
| 275 | { | ||
| 276 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 277 | const struct firmware *fw; | ||
| 278 | int ret; | ||
| 279 | int pos = 0; | ||
| 280 | int cnt; | ||
| 281 | u8 wlen = state->config->fwbulkwritelen; | ||
| 282 | |||
| 283 | if ((wlen != TDA10048_BULKWRITE_200) && (wlen != TDA10048_BULKWRITE_50)) | ||
| 284 | wlen = TDA10048_BULKWRITE_200; | ||
| 285 | |||
| 286 | /* request the firmware, this will block and timeout */ | ||
| 287 | printk(KERN_INFO "%s: waiting for firmware upload (%s)...\n", | ||
| 288 | __func__, | ||
| 289 | TDA10048_DEFAULT_FIRMWARE); | ||
| 290 | |||
| 291 | ret = request_firmware(&fw, TDA10048_DEFAULT_FIRMWARE, | ||
| 292 | &state->i2c->dev); | ||
| 293 | if (ret) { | ||
| 294 | printk(KERN_ERR "%s: Upload failed. (file not found?)\n", | ||
| 295 | __func__); | ||
| 296 | return -EIO; | ||
| 297 | } else { | ||
| 298 | printk(KERN_INFO "%s: firmware read %Zu bytes.\n", | ||
| 299 | __func__, | ||
| 300 | fw->size); | ||
| 301 | ret = 0; | ||
| 302 | } | ||
| 303 | |||
| 304 | if (fw->size != TDA10048_DEFAULT_FIRMWARE_SIZE) { | ||
| 305 | printk(KERN_ERR "%s: firmware incorrect size\n", __func__); | ||
| 306 | return -EIO; | ||
| 307 | } else { | ||
| 308 | printk(KERN_INFO "%s: firmware uploading\n", __func__); | ||
| 309 | |||
| 310 | /* Soft reset */ | ||
| 311 | tda10048_writereg(state, TDA10048_CONF_TRISTATE1, | ||
| 312 | tda10048_readreg(state, TDA10048_CONF_TRISTATE1) | ||
| 313 | & 0xfe); | ||
| 314 | tda10048_writereg(state, TDA10048_CONF_TRISTATE1, | ||
| 315 | tda10048_readreg(state, TDA10048_CONF_TRISTATE1) | ||
| 316 | | 0x01); | ||
| 317 | |||
| 318 | /* Put the demod into host download mode */ | ||
| 319 | tda10048_writereg(state, TDA10048_CONF_C4_1, | ||
| 320 | tda10048_readreg(state, TDA10048_CONF_C4_1) & 0xf9); | ||
| 321 | |||
| 322 | /* Boot the DSP */ | ||
| 323 | tda10048_writereg(state, TDA10048_CONF_C4_1, | ||
| 324 | tda10048_readreg(state, TDA10048_CONF_C4_1) | 0x08); | ||
| 325 | |||
| 326 | /* Prepare for download */ | ||
| 327 | tda10048_writereg(state, TDA10048_DSP_CODE_CPT, 0); | ||
| 328 | |||
| 329 | /* Download the firmware payload */ | ||
| 330 | while (pos < fw->size) { | ||
| 331 | |||
| 332 | if ((fw->size - pos) > wlen) | ||
| 333 | cnt = wlen; | ||
| 334 | else | ||
| 335 | cnt = fw->size - pos; | ||
| 336 | |||
| 337 | tda10048_writeregbulk(state, TDA10048_DSP_CODE_IN, | ||
| 338 | &fw->data[pos], cnt); | ||
| 339 | |||
| 340 | pos += cnt; | ||
| 341 | } | ||
| 342 | |||
| 343 | ret = -EIO; | ||
| 344 | /* Wait up to 250ms for the DSP to boot */ | ||
| 345 | for (cnt = 0; cnt < 250 ; cnt += 10) { | ||
| 346 | |||
| 347 | msleep(10); | ||
| 348 | |||
| 349 | if (tda10048_readreg(state, TDA10048_SYNC_STATUS) | ||
| 350 | & 0x40) { | ||
| 351 | ret = 0; | ||
| 352 | break; | ||
| 353 | } | ||
| 354 | } | ||
| 355 | } | ||
| 356 | |||
| 357 | release_firmware(fw); | ||
| 358 | |||
| 359 | if (ret == 0) { | ||
| 360 | printk(KERN_INFO "%s: firmware uploaded\n", __func__); | ||
| 361 | state->fwloaded = 1; | ||
| 362 | } else | ||
| 363 | printk(KERN_ERR "%s: firmware upload failed\n", __func__); | ||
| 364 | |||
| 365 | return ret; | ||
| 366 | } | ||
| 367 | |||
| 368 | static int tda10048_set_inversion(struct dvb_frontend *fe, int inversion) | ||
| 369 | { | ||
| 370 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 371 | |||
| 372 | dprintk(1, "%s(%d)\n", __func__, inversion); | ||
| 373 | |||
| 374 | if (inversion == TDA10048_INVERSION_ON) | ||
| 375 | tda10048_writereg(state, TDA10048_CONF_C1_1, | ||
| 376 | tda10048_readreg(state, TDA10048_CONF_C1_1) | 0x20); | ||
| 377 | else | ||
| 378 | tda10048_writereg(state, TDA10048_CONF_C1_1, | ||
| 379 | tda10048_readreg(state, TDA10048_CONF_C1_1) & 0xdf); | ||
| 380 | |||
| 381 | return 0; | ||
| 382 | } | ||
| 383 | |||
| 384 | /* Retrieve the demod settings */ | ||
| 385 | static int tda10048_get_tps(struct tda10048_state *state, | ||
| 386 | struct dvb_ofdm_parameters *p) | ||
| 387 | { | ||
| 388 | u8 val; | ||
| 389 | |||
| 390 | /* Make sure the TPS regs are valid */ | ||
| 391 | if (!(tda10048_readreg(state, TDA10048_AUTO) & 0x01)) | ||
| 392 | return -EAGAIN; | ||
| 393 | |||
| 394 | val = tda10048_readreg(state, TDA10048_OUT_CONF2); | ||
| 395 | switch ((val & 0x60) >> 5) { | ||
| 396 | case 0: p->constellation = QPSK; break; | ||
| 397 | case 1: p->constellation = QAM_16; break; | ||
| 398 | case 2: p->constellation = QAM_64; break; | ||
| 399 | } | ||
| 400 | switch ((val & 0x18) >> 3) { | ||
| 401 | case 0: p->hierarchy_information = HIERARCHY_NONE; break; | ||
| 402 | case 1: p->hierarchy_information = HIERARCHY_1; break; | ||
| 403 | case 2: p->hierarchy_information = HIERARCHY_2; break; | ||
| 404 | case 3: p->hierarchy_information = HIERARCHY_4; break; | ||
| 405 | } | ||
| 406 | switch (val & 0x07) { | ||
| 407 | case 0: p->code_rate_HP = FEC_1_2; break; | ||
| 408 | case 1: p->code_rate_HP = FEC_2_3; break; | ||
| 409 | case 2: p->code_rate_HP = FEC_3_4; break; | ||
| 410 | case 3: p->code_rate_HP = FEC_5_6; break; | ||
| 411 | case 4: p->code_rate_HP = FEC_7_8; break; | ||
| 412 | } | ||
| 413 | |||
| 414 | val = tda10048_readreg(state, TDA10048_OUT_CONF3); | ||
| 415 | switch (val & 0x07) { | ||
| 416 | case 0: p->code_rate_LP = FEC_1_2; break; | ||
| 417 | case 1: p->code_rate_LP = FEC_2_3; break; | ||
| 418 | case 2: p->code_rate_LP = FEC_3_4; break; | ||
| 419 | case 3: p->code_rate_LP = FEC_5_6; break; | ||
| 420 | case 4: p->code_rate_LP = FEC_7_8; break; | ||
| 421 | } | ||
| 422 | |||
| 423 | val = tda10048_readreg(state, TDA10048_OUT_CONF1); | ||
| 424 | switch ((val & 0x0c) >> 2) { | ||
| 425 | case 0: p->guard_interval = GUARD_INTERVAL_1_32; break; | ||
| 426 | case 1: p->guard_interval = GUARD_INTERVAL_1_16; break; | ||
| 427 | case 2: p->guard_interval = GUARD_INTERVAL_1_8; break; | ||
| 428 | case 3: p->guard_interval = GUARD_INTERVAL_1_4; break; | ||
| 429 | } | ||
| 430 | switch (val & 0x02) { | ||
| 431 | case 0: p->transmission_mode = TRANSMISSION_MODE_2K; break; | ||
| 432 | case 1: p->transmission_mode = TRANSMISSION_MODE_8K; break; | ||
| 433 | } | ||
| 434 | |||
| 435 | return 0; | ||
| 436 | } | ||
| 437 | |||
| 438 | static int tda10048_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) | ||
| 439 | { | ||
| 440 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 441 | dprintk(1, "%s(%d)\n", __func__, enable); | ||
| 442 | |||
| 443 | if (enable) | ||
| 444 | return tda10048_writereg(state, TDA10048_CONF_C4_1, | ||
| 445 | tda10048_readreg(state, TDA10048_CONF_C4_1) | 0x02); | ||
| 446 | else | ||
| 447 | return tda10048_writereg(state, TDA10048_CONF_C4_1, | ||
| 448 | tda10048_readreg(state, TDA10048_CONF_C4_1) & 0xfd); | ||
| 449 | } | ||
| 450 | |||
| 451 | static int tda10048_output_mode(struct dvb_frontend *fe, int serial) | ||
| 452 | { | ||
| 453 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 454 | dprintk(1, "%s(%d)\n", __func__, serial); | ||
| 455 | |||
| 456 | /* Ensure pins are out of tri-state */ | ||
| 457 | tda10048_writereg(state, TDA10048_CONF_TRISTATE1, 0x21); | ||
| 458 | tda10048_writereg(state, TDA10048_CONF_TRISTATE2, 0x00); | ||
| 459 | |||
| 460 | if (serial) { | ||
| 461 | tda10048_writereg(state, TDA10048_IC_MODE, 0x80 | 0x20); | ||
| 462 | tda10048_writereg(state, TDA10048_CONF_TS2, 0xc0); | ||
| 463 | } else { | ||
| 464 | tda10048_writereg(state, TDA10048_IC_MODE, 0x00); | ||
| 465 | tda10048_writereg(state, TDA10048_CONF_TS2, 0x01); | ||
| 466 | } | ||
| 467 | |||
| 468 | return 0; | ||
| 469 | } | ||
| 470 | |||
| 471 | /* Talk to the demod, set the FEC, GUARD, QAM settings etc */ | ||
| 472 | /* TODO: Support manual tuning with specific params */ | ||
| 473 | static int tda10048_set_frontend(struct dvb_frontend *fe, | ||
| 474 | struct dvb_frontend_parameters *p) | ||
| 475 | { | ||
| 476 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 477 | |||
| 478 | dprintk(1, "%s(frequency=%d)\n", __func__, p->frequency); | ||
| 479 | |||
| 480 | if (fe->ops.tuner_ops.set_params) { | ||
| 481 | |||
| 482 | if (fe->ops.i2c_gate_ctrl) | ||
| 483 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 484 | |||
| 485 | fe->ops.tuner_ops.set_params(fe, p); | ||
| 486 | |||
| 487 | if (fe->ops.i2c_gate_ctrl) | ||
| 488 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 489 | } | ||
| 490 | |||
| 491 | /* Enable demod TPS auto detection and begin acquisition */ | ||
| 492 | tda10048_writereg(state, TDA10048_AUTO, 0x57); | ||
| 493 | |||
| 494 | return 0; | ||
| 495 | } | ||
| 496 | |||
| 497 | /* Establish sane defaults and load firmware. */ | ||
| 498 | static int tda10048_init(struct dvb_frontend *fe) | ||
| 499 | { | ||
| 500 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 501 | int ret = 0, i; | ||
| 502 | |||
| 503 | dprintk(1, "%s()\n", __func__); | ||
| 504 | |||
| 505 | /* Apply register defaults */ | ||
| 506 | for (i = 0; i < ARRAY_SIZE(init_tab); i++) | ||
| 507 | tda10048_writereg(state, init_tab[i].reg, init_tab[i].data); | ||
| 508 | |||
| 509 | if (state->fwloaded == 0) | ||
| 510 | ret = tda10048_firmware_upload(fe); | ||
| 511 | |||
| 512 | /* Set either serial or parallel */ | ||
| 513 | tda10048_output_mode(fe, state->config->output_mode); | ||
| 514 | |||
| 515 | /* set inversion */ | ||
| 516 | tda10048_set_inversion(fe, state->config->inversion); | ||
| 517 | |||
| 518 | /* Ensure we leave the gate closed */ | ||
| 519 | tda10048_i2c_gate_ctrl(fe, 0); | ||
| 520 | |||
| 521 | return ret; | ||
| 522 | } | ||
| 523 | |||
| 524 | static int tda10048_read_status(struct dvb_frontend *fe, fe_status_t *status) | ||
| 525 | { | ||
| 526 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 527 | u8 reg; | ||
| 528 | |||
| 529 | *status = 0; | ||
| 530 | |||
| 531 | reg = tda10048_readreg(state, TDA10048_SYNC_STATUS); | ||
| 532 | |||
| 533 | dprintk(1, "%s() status =0x%02x\n", __func__, reg); | ||
| 534 | |||
| 535 | if (reg & 0x02) | ||
| 536 | *status |= FE_HAS_CARRIER; | ||
| 537 | |||
| 538 | if (reg & 0x04) | ||
| 539 | *status |= FE_HAS_SIGNAL; | ||
| 540 | |||
| 541 | if (reg & 0x08) { | ||
| 542 | *status |= FE_HAS_LOCK; | ||
| 543 | *status |= FE_HAS_VITERBI; | ||
| 544 | *status |= FE_HAS_SYNC; | ||
| 545 | } | ||
| 546 | |||
| 547 | return 0; | ||
| 548 | } | ||
| 549 | |||
| 550 | static int tda10048_read_ber(struct dvb_frontend *fe, u32 *ber) | ||
| 551 | { | ||
| 552 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 553 | |||
| 554 | dprintk(1, "%s()\n", __func__); | ||
| 555 | |||
| 556 | /* TODO: A reset may be required here */ | ||
| 557 | *ber = tda10048_readreg(state, TDA10048_CBER_MSB) << 8 | | ||
| 558 | tda10048_readreg(state, TDA10048_CBER_LSB); | ||
| 559 | |||
| 560 | return 0; | ||
| 561 | } | ||
| 562 | |||
| 563 | static int tda10048_read_signal_strength(struct dvb_frontend *fe, | ||
| 564 | u16 *signal_strength) | ||
| 565 | { | ||
| 566 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 567 | u8 v; | ||
| 568 | |||
| 569 | dprintk(1, "%s()\n", __func__); | ||
| 570 | |||
| 571 | *signal_strength = 65535; | ||
| 572 | |||
| 573 | v = tda10048_readreg(state, TDA10048_NP_OUT); | ||
| 574 | if (v > 0) | ||
| 575 | *signal_strength -= (v << 8) | v; | ||
| 576 | |||
| 577 | return 0; | ||
| 578 | } | ||
| 579 | |||
| 580 | /* SNR lookup table */ | ||
| 581 | static struct snr_tab { | ||
| 582 | u8 val; | ||
| 583 | u8 data; | ||
| 584 | } snr_tab[] = { | ||
| 585 | { 0, 0 }, | ||
| 586 | { 1, 246 }, | ||
| 587 | { 2, 215 }, | ||
| 588 | { 3, 198 }, | ||
| 589 | { 4, 185 }, | ||
| 590 | { 5, 176 }, | ||
| 591 | { 6, 168 }, | ||
| 592 | { 7, 161 }, | ||
| 593 | { 8, 155 }, | ||
| 594 | { 9, 150 }, | ||
| 595 | { 10, 146 }, | ||
| 596 | { 11, 141 }, | ||
| 597 | { 12, 138 }, | ||
| 598 | { 13, 134 }, | ||
| 599 | { 14, 131 }, | ||
| 600 | { 15, 128 }, | ||
| 601 | { 16, 125 }, | ||
| 602 | { 17, 122 }, | ||
| 603 | { 18, 120 }, | ||
| 604 | { 19, 118 }, | ||
| 605 | { 20, 115 }, | ||
| 606 | { 21, 113 }, | ||
| 607 | { 22, 111 }, | ||
| 608 | { 23, 109 }, | ||
| 609 | { 24, 107 }, | ||
| 610 | { 25, 106 }, | ||
| 611 | { 26, 104 }, | ||
| 612 | { 27, 102 }, | ||
| 613 | { 28, 101 }, | ||
| 614 | { 29, 99 }, | ||
| 615 | { 30, 98 }, | ||
| 616 | { 31, 96 }, | ||
| 617 | { 32, 95 }, | ||
| 618 | { 33, 94 }, | ||
| 619 | { 34, 92 }, | ||
| 620 | { 35, 91 }, | ||
| 621 | { 36, 90 }, | ||
| 622 | { 37, 89 }, | ||
| 623 | { 38, 88 }, | ||
| 624 | { 39, 86 }, | ||
| 625 | { 40, 85 }, | ||
| 626 | { 41, 84 }, | ||
| 627 | { 42, 83 }, | ||
| 628 | { 43, 82 }, | ||
| 629 | { 44, 81 }, | ||
| 630 | { 45, 80 }, | ||
| 631 | { 46, 79 }, | ||
| 632 | { 47, 78 }, | ||
| 633 | { 48, 77 }, | ||
| 634 | { 49, 76 }, | ||
| 635 | { 50, 76 }, | ||
| 636 | { 51, 75 }, | ||
| 637 | { 52, 74 }, | ||
| 638 | { 53, 73 }, | ||
| 639 | { 54, 72 }, | ||
| 640 | { 56, 71 }, | ||
| 641 | { 57, 70 }, | ||
| 642 | { 58, 69 }, | ||
| 643 | { 60, 68 }, | ||
| 644 | { 61, 67 }, | ||
| 645 | { 63, 66 }, | ||
| 646 | { 64, 65 }, | ||
| 647 | { 66, 64 }, | ||
| 648 | { 67, 63 }, | ||
| 649 | { 68, 62 }, | ||
| 650 | { 69, 62 }, | ||
| 651 | { 70, 61 }, | ||
| 652 | { 72, 60 }, | ||
| 653 | { 74, 59 }, | ||
| 654 | { 75, 58 }, | ||
| 655 | { 77, 57 }, | ||
| 656 | { 79, 56 }, | ||
| 657 | { 81, 55 }, | ||
| 658 | { 83, 54 }, | ||
| 659 | { 85, 53 }, | ||
| 660 | { 87, 52 }, | ||
| 661 | { 89, 51 }, | ||
| 662 | { 91, 50 }, | ||
| 663 | { 93, 49 }, | ||
| 664 | { 95, 48 }, | ||
| 665 | { 97, 47 }, | ||
| 666 | { 100, 46 }, | ||
| 667 | { 102, 45 }, | ||
| 668 | { 104, 44 }, | ||
| 669 | { 107, 43 }, | ||
| 670 | { 109, 42 }, | ||
| 671 | { 112, 41 }, | ||
| 672 | { 114, 40 }, | ||
| 673 | { 117, 39 }, | ||
| 674 | { 120, 38 }, | ||
| 675 | { 123, 37 }, | ||
| 676 | { 125, 36 }, | ||
| 677 | { 128, 35 }, | ||
| 678 | { 131, 34 }, | ||
| 679 | { 134, 33 }, | ||
| 680 | { 138, 32 }, | ||
| 681 | { 141, 31 }, | ||
| 682 | { 144, 30 }, | ||
| 683 | { 147, 29 }, | ||
| 684 | { 151, 28 }, | ||
| 685 | { 154, 27 }, | ||
| 686 | { 158, 26 }, | ||
| 687 | { 162, 25 }, | ||
| 688 | { 165, 24 }, | ||
| 689 | { 169, 23 }, | ||
| 690 | { 173, 22 }, | ||
| 691 | { 177, 21 }, | ||
| 692 | { 181, 20 }, | ||
| 693 | { 186, 19 }, | ||
| 694 | { 190, 18 }, | ||
| 695 | { 194, 17 }, | ||
| 696 | { 199, 16 }, | ||
| 697 | { 204, 15 }, | ||
| 698 | { 208, 14 }, | ||
| 699 | { 213, 13 }, | ||
| 700 | { 218, 12 }, | ||
| 701 | { 223, 11 }, | ||
| 702 | { 229, 10 }, | ||
| 703 | { 234, 9 }, | ||
| 704 | { 239, 8 }, | ||
| 705 | { 245, 7 }, | ||
| 706 | { 251, 6 }, | ||
| 707 | { 255, 5 }, | ||
| 708 | }; | ||
| 709 | |||
| 710 | static int tda10048_read_snr(struct dvb_frontend *fe, u16 *snr) | ||
| 711 | { | ||
| 712 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 713 | u8 v; | ||
| 714 | int i, ret = -EINVAL; | ||
| 715 | |||
| 716 | dprintk(1, "%s()\n", __func__); | ||
| 717 | |||
| 718 | v = tda10048_readreg(state, TDA10048_NP_OUT); | ||
| 719 | for (i = 0; i < ARRAY_SIZE(snr_tab); i++) { | ||
| 720 | if (v <= snr_tab[i].val) { | ||
| 721 | *snr = snr_tab[i].data; | ||
| 722 | ret = 0; | ||
| 723 | break; | ||
| 724 | } | ||
| 725 | } | ||
| 726 | |||
| 727 | return ret; | ||
| 728 | } | ||
| 729 | |||
| 730 | static int tda10048_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) | ||
| 731 | { | ||
| 732 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 733 | |||
| 734 | dprintk(1, "%s()\n", __func__); | ||
| 735 | |||
| 736 | *ucblocks = tda10048_readreg(state, TDA10048_UNCOR_CPT_MSB) << 8 | | ||
| 737 | tda10048_readreg(state, TDA10048_UNCOR_CPT_LSB); | ||
| 738 | |||
| 739 | return 0; | ||
| 740 | } | ||
| 741 | |||
| 742 | static int tda10048_get_frontend(struct dvb_frontend *fe, | ||
| 743 | struct dvb_frontend_parameters *p) | ||
| 744 | { | ||
| 745 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 746 | |||
| 747 | dprintk(1, "%s()\n", __func__); | ||
| 748 | |||
| 749 | p->inversion = tda10048_readreg(state, TDA10048_CONF_C1_1) | ||
| 750 | & 0x20 ? INVERSION_ON : INVERSION_OFF; | ||
| 751 | |||
| 752 | return tda10048_get_tps(state, &p->u.ofdm); | ||
| 753 | } | ||
| 754 | |||
| 755 | static int tda10048_get_tune_settings(struct dvb_frontend *fe, | ||
| 756 | struct dvb_frontend_tune_settings *tune) | ||
| 757 | { | ||
| 758 | tune->min_delay_ms = 1000; | ||
| 759 | return 0; | ||
| 760 | } | ||
| 761 | |||
| 762 | static void tda10048_release(struct dvb_frontend *fe) | ||
| 763 | { | ||
| 764 | struct tda10048_state *state = fe->demodulator_priv; | ||
| 765 | dprintk(1, "%s()\n", __func__); | ||
| 766 | kfree(state); | ||
| 767 | } | ||
| 768 | |||
| 769 | static struct dvb_frontend_ops tda10048_ops; | ||
| 770 | |||
| 771 | struct dvb_frontend *tda10048_attach(const struct tda10048_config *config, | ||
| 772 | struct i2c_adapter *i2c) | ||
| 773 | { | ||
| 774 | struct tda10048_state *state = NULL; | ||
| 775 | |||
| 776 | dprintk(1, "%s()\n", __func__); | ||
| 777 | |||
| 778 | /* allocate memory for the internal state */ | ||
| 779 | state = kmalloc(sizeof(struct tda10048_state), GFP_KERNEL); | ||
| 780 | if (state == NULL) | ||
| 781 | goto error; | ||
| 782 | |||
| 783 | /* setup the state */ | ||
| 784 | state->config = config; | ||
| 785 | state->i2c = i2c; | ||
| 786 | state->fwloaded = 0; | ||
| 787 | |||
| 788 | /* check if the demod is present */ | ||
| 789 | if (tda10048_readreg(state, TDA10048_IDENTITY) != 0x048) | ||
| 790 | goto error; | ||
| 791 | |||
| 792 | /* create dvb_frontend */ | ||
| 793 | memcpy(&state->frontend.ops, &tda10048_ops, | ||
| 794 | sizeof(struct dvb_frontend_ops)); | ||
| 795 | state->frontend.demodulator_priv = state; | ||
| 796 | |||
| 797 | /* Leave the gate closed */ | ||
| 798 | tda10048_i2c_gate_ctrl(&state->frontend, 0); | ||
| 799 | |||
| 800 | return &state->frontend; | ||
| 801 | |||
| 802 | error: | ||
| 803 | kfree(state); | ||
| 804 | return NULL; | ||
| 805 | } | ||
| 806 | EXPORT_SYMBOL(tda10048_attach); | ||
| 807 | |||
| 808 | static struct dvb_frontend_ops tda10048_ops = { | ||
| 809 | |||
| 810 | .info = { | ||
| 811 | .name = "NXP TDA10048HN DVB-T", | ||
| 812 | .type = FE_OFDM, | ||
| 813 | .frequency_min = 177000000, | ||
| 814 | .frequency_max = 858000000, | ||
| 815 | .frequency_stepsize = 166666, | ||
| 816 | .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | | ||
| 817 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | | ||
| 818 | FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | | ||
| 819 | FE_CAN_HIERARCHY_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | | ||
| 820 | FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_RECOVER | ||
| 821 | }, | ||
| 822 | |||
| 823 | .release = tda10048_release, | ||
| 824 | .init = tda10048_init, | ||
| 825 | .i2c_gate_ctrl = tda10048_i2c_gate_ctrl, | ||
| 826 | .set_frontend = tda10048_set_frontend, | ||
| 827 | .get_frontend = tda10048_get_frontend, | ||
| 828 | .get_tune_settings = tda10048_get_tune_settings, | ||
| 829 | .read_status = tda10048_read_status, | ||
| 830 | .read_ber = tda10048_read_ber, | ||
| 831 | .read_signal_strength = tda10048_read_signal_strength, | ||
| 832 | .read_snr = tda10048_read_snr, | ||
| 833 | .read_ucblocks = tda10048_read_ucblocks, | ||
| 834 | }; | ||
| 835 | |||
| 836 | module_param(debug, int, 0644); | ||
| 837 | MODULE_PARM_DESC(debug, "Enable verbose debug messages"); | ||
| 838 | |||
| 839 | MODULE_DESCRIPTION("NXP TDA10048HN DVB-T Demodulator driver"); | ||
| 840 | MODULE_AUTHOR("Steven Toth"); | ||
| 841 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/frontends/tda10048.h b/drivers/media/dvb/frontends/tda10048.h new file mode 100644 index 000000000000..2b5c78e62c86 --- /dev/null +++ b/drivers/media/dvb/frontends/tda10048.h | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | /* | ||
| 2 | NXP TDA10048HN DVB OFDM demodulator driver | ||
| 3 | |||
| 4 | Copyright (C) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | #ifndef TDA10048_H | ||
| 23 | #define TDA10048_H | ||
| 24 | |||
| 25 | #include <linux/dvb/frontend.h> | ||
| 26 | #include <linux/firmware.h> | ||
| 27 | |||
| 28 | struct tda10048_config { | ||
| 29 | |||
| 30 | /* the demodulator's i2c address */ | ||
| 31 | u8 demod_address; | ||
| 32 | |||
| 33 | /* serial/parallel output */ | ||
| 34 | #define TDA10048_PARALLEL_OUTPUT 0 | ||
| 35 | #define TDA10048_SERIAL_OUTPUT 1 | ||
| 36 | u8 output_mode; | ||
| 37 | |||
| 38 | #define TDA10048_BULKWRITE_200 200 | ||
| 39 | #define TDA10048_BULKWRITE_50 50 | ||
| 40 | u8 fwbulkwritelen; | ||
| 41 | |||
| 42 | /* Spectral Inversion */ | ||
| 43 | #define TDA10048_INVERSION_OFF 0 | ||
| 44 | #define TDA10048_INVERSION_ON 1 | ||
| 45 | u8 inversion; | ||
| 46 | }; | ||
| 47 | |||
| 48 | #if defined(CONFIG_DVB_TDA10048) || \ | ||
| 49 | (defined(CONFIG_DVB_TDA10048_MODULE) && defined(MODULE)) | ||
| 50 | extern struct dvb_frontend *tda10048_attach( | ||
| 51 | const struct tda10048_config *config, | ||
| 52 | struct i2c_adapter *i2c); | ||
| 53 | #else | ||
| 54 | static inline struct dvb_frontend *tda10048_attach( | ||
| 55 | const struct tda10048_config *config, | ||
| 56 | struct i2c_adapter *i2c) | ||
| 57 | { | ||
| 58 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); | ||
| 59 | return NULL; | ||
| 60 | } | ||
| 61 | #endif /* CONFIG_DVB_TDA10048 */ | ||
| 62 | |||
| 63 | #endif /* TDA10048_H */ | ||
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c index 8415a8a5247a..49973846373e 100644 --- a/drivers/media/dvb/frontends/tda1004x.c +++ b/drivers/media/dvb/frontends/tda1004x.c | |||
| @@ -131,16 +131,16 @@ static int tda1004x_write_byteI(struct tda1004x_state *state, int reg, int data) | |||
| 131 | u8 buf[] = { reg, data }; | 131 | u8 buf[] = { reg, data }; |
| 132 | struct i2c_msg msg = { .flags = 0, .buf = buf, .len = 2 }; | 132 | struct i2c_msg msg = { .flags = 0, .buf = buf, .len = 2 }; |
| 133 | 133 | ||
| 134 | dprintk("%s: reg=0x%x, data=0x%x\n", __FUNCTION__, reg, data); | 134 | dprintk("%s: reg=0x%x, data=0x%x\n", __func__, reg, data); |
| 135 | 135 | ||
| 136 | msg.addr = state->config->demod_address; | 136 | msg.addr = state->config->demod_address; |
| 137 | ret = i2c_transfer(state->i2c, &msg, 1); | 137 | ret = i2c_transfer(state->i2c, &msg, 1); |
| 138 | 138 | ||
| 139 | if (ret != 1) | 139 | if (ret != 1) |
| 140 | dprintk("%s: error reg=0x%x, data=0x%x, ret=%i\n", | 140 | dprintk("%s: error reg=0x%x, data=0x%x, ret=%i\n", |
| 141 | __FUNCTION__, reg, data, ret); | 141 | __func__, reg, data, ret); |
| 142 | 142 | ||
| 143 | dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __FUNCTION__, | 143 | dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __func__, |
| 144 | reg, data, ret); | 144 | reg, data, ret); |
| 145 | return (ret != 1) ? -1 : 0; | 145 | return (ret != 1) ? -1 : 0; |
| 146 | } | 146 | } |
| @@ -153,19 +153,19 @@ static int tda1004x_read_byte(struct tda1004x_state *state, int reg) | |||
| 153 | struct i2c_msg msg[] = {{ .flags = 0, .buf = b0, .len = 1 }, | 153 | struct i2c_msg msg[] = {{ .flags = 0, .buf = b0, .len = 1 }, |
| 154 | { .flags = I2C_M_RD, .buf = b1, .len = 1 }}; | 154 | { .flags = I2C_M_RD, .buf = b1, .len = 1 }}; |
| 155 | 155 | ||
| 156 | dprintk("%s: reg=0x%x\n", __FUNCTION__, reg); | 156 | dprintk("%s: reg=0x%x\n", __func__, reg); |
| 157 | 157 | ||
| 158 | msg[0].addr = state->config->demod_address; | 158 | msg[0].addr = state->config->demod_address; |
| 159 | msg[1].addr = state->config->demod_address; | 159 | msg[1].addr = state->config->demod_address; |
| 160 | ret = i2c_transfer(state->i2c, msg, 2); | 160 | ret = i2c_transfer(state->i2c, msg, 2); |
| 161 | 161 | ||
| 162 | if (ret != 2) { | 162 | if (ret != 2) { |
| 163 | dprintk("%s: error reg=0x%x, ret=%i\n", __FUNCTION__, reg, | 163 | dprintk("%s: error reg=0x%x, ret=%i\n", __func__, reg, |
| 164 | ret); | 164 | ret); |
| 165 | return -1; | 165 | return -1; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __FUNCTION__, | 168 | dprintk("%s: success reg=0x%x, data=0x%x, ret=%i\n", __func__, |
| 169 | reg, b1[0], ret); | 169 | reg, b1[0], ret); |
| 170 | return b1[0]; | 170 | return b1[0]; |
| 171 | } | 171 | } |
| @@ -173,7 +173,7 @@ static int tda1004x_read_byte(struct tda1004x_state *state, int reg) | |||
| 173 | static int tda1004x_write_mask(struct tda1004x_state *state, int reg, int mask, int data) | 173 | static int tda1004x_write_mask(struct tda1004x_state *state, int reg, int mask, int data) |
| 174 | { | 174 | { |
| 175 | int val; | 175 | int val; |
| 176 | dprintk("%s: reg=0x%x, mask=0x%x, data=0x%x\n", __FUNCTION__, reg, | 176 | dprintk("%s: reg=0x%x, mask=0x%x, data=0x%x\n", __func__, reg, |
| 177 | mask, data); | 177 | mask, data); |
| 178 | 178 | ||
| 179 | // read a byte and check | 179 | // read a byte and check |
| @@ -194,7 +194,7 @@ static int tda1004x_write_buf(struct tda1004x_state *state, int reg, unsigned ch | |||
| 194 | int i; | 194 | int i; |
| 195 | int result; | 195 | int result; |
| 196 | 196 | ||
| 197 | dprintk("%s: reg=0x%x, len=0x%x\n", __FUNCTION__, reg, len); | 197 | dprintk("%s: reg=0x%x, len=0x%x\n", __func__, reg, len); |
| 198 | 198 | ||
| 199 | result = 0; | 199 | result = 0; |
| 200 | for (i = 0; i < len; i++) { | 200 | for (i = 0; i < len; i++) { |
| @@ -209,7 +209,7 @@ static int tda1004x_write_buf(struct tda1004x_state *state, int reg, unsigned ch | |||
| 209 | static int tda1004x_enable_tuner_i2c(struct tda1004x_state *state) | 209 | static int tda1004x_enable_tuner_i2c(struct tda1004x_state *state) |
| 210 | { | 210 | { |
| 211 | int result; | 211 | int result; |
| 212 | dprintk("%s\n", __FUNCTION__); | 212 | dprintk("%s\n", __func__); |
| 213 | 213 | ||
| 214 | result = tda1004x_write_mask(state, TDA1004X_CONFC4, 2, 2); | 214 | result = tda1004x_write_mask(state, TDA1004X_CONFC4, 2, 2); |
| 215 | msleep(20); | 215 | msleep(20); |
| @@ -218,7 +218,7 @@ static int tda1004x_enable_tuner_i2c(struct tda1004x_state *state) | |||
| 218 | 218 | ||
| 219 | static int tda1004x_disable_tuner_i2c(struct tda1004x_state *state) | 219 | static int tda1004x_disable_tuner_i2c(struct tda1004x_state *state) |
| 220 | { | 220 | { |
| 221 | dprintk("%s\n", __FUNCTION__); | 221 | dprintk("%s\n", __func__); |
| 222 | 222 | ||
| 223 | return tda1004x_write_mask(state, TDA1004X_CONFC4, 2, 0); | 223 | return tda1004x_write_mask(state, TDA1004X_CONFC4, 2, 0); |
| 224 | } | 224 | } |
| @@ -345,7 +345,7 @@ static int tda1004x_do_upload(struct tda1004x_state *state, | |||
| 345 | } | 345 | } |
| 346 | pos += tx_size; | 346 | pos += tx_size; |
| 347 | 347 | ||
| 348 | dprintk("%s: fw_pos=0x%x\n", __FUNCTION__, pos); | 348 | dprintk("%s: fw_pos=0x%x\n", __func__, pos); |
| 349 | } | 349 | } |
| 350 | // give the DSP a chance to settle 03/10/05 Hac | 350 | // give the DSP a chance to settle 03/10/05 Hac |
| 351 | msleep(100); | 351 | msleep(100); |
| @@ -444,10 +444,10 @@ static void tda10046_init_plls(struct dvb_frontend* fe) | |||
| 444 | tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x03); // PLL M = 3 | 444 | tda1004x_write_byteI(state, TDA10046H_CONFPLL2, 0x03); // PLL M = 3 |
| 445 | } | 445 | } |
| 446 | if (state->config->xtal_freq == TDA10046_XTAL_4M ) { | 446 | if (state->config->xtal_freq == TDA10046_XTAL_4M ) { |
| 447 | dprintk("%s: setting up PLLs for a 4 MHz Xtal\n", __FUNCTION__); | 447 | dprintk("%s: setting up PLLs for a 4 MHz Xtal\n", __func__); |
| 448 | tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0); // PLL P = N = 0 | 448 | tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 0); // PLL P = N = 0 |
| 449 | } else { | 449 | } else { |
| 450 | dprintk("%s: setting up PLLs for a 16 MHz Xtal\n", __FUNCTION__); | 450 | dprintk("%s: setting up PLLs for a 16 MHz Xtal\n", __func__); |
| 451 | tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 3); // PLL P = 0, N = 3 | 451 | tda1004x_write_byteI(state, TDA10046H_CONFPLL3, 3); // PLL P = 0, N = 3 |
| 452 | } | 452 | } |
| 453 | if(tda10046_clk53m) | 453 | if(tda10046_clk53m) |
| @@ -488,7 +488,7 @@ static int tda10046_fwupload(struct dvb_frontend* fe) | |||
| 488 | if (state->config->xtal_freq == TDA10046_XTAL_4M) { | 488 | if (state->config->xtal_freq == TDA10046_XTAL_4M) { |
| 489 | tda1004x_write_byteI(state, TDA1004X_CONFC4, 0); | 489 | tda1004x_write_byteI(state, TDA1004X_CONFC4, 0); |
| 490 | } else { | 490 | } else { |
| 491 | dprintk("%s: 16MHz Xtal, reducing I2C speed\n", __FUNCTION__); | 491 | dprintk("%s: 16MHz Xtal, reducing I2C speed\n", __func__); |
| 492 | tda1004x_write_byteI(state, TDA1004X_CONFC4, 0x80); | 492 | tda1004x_write_byteI(state, TDA1004X_CONFC4, 0x80); |
| 493 | } | 493 | } |
| 494 | tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0); | 494 | tda1004x_write_mask(state, TDA10046H_CONF_TRISTATE1, 1, 0); |
| @@ -594,7 +594,7 @@ static int tda10045_init(struct dvb_frontend* fe) | |||
| 594 | { | 594 | { |
| 595 | struct tda1004x_state* state = fe->demodulator_priv; | 595 | struct tda1004x_state* state = fe->demodulator_priv; |
| 596 | 596 | ||
| 597 | dprintk("%s\n", __FUNCTION__); | 597 | dprintk("%s\n", __func__); |
| 598 | 598 | ||
| 599 | if (tda10045_fwupload(fe)) { | 599 | if (tda10045_fwupload(fe)) { |
| 600 | printk("tda1004x: firmware upload failed\n"); | 600 | printk("tda1004x: firmware upload failed\n"); |
| @@ -624,7 +624,7 @@ static int tda10045_init(struct dvb_frontend* fe) | |||
| 624 | static int tda10046_init(struct dvb_frontend* fe) | 624 | static int tda10046_init(struct dvb_frontend* fe) |
| 625 | { | 625 | { |
| 626 | struct tda1004x_state* state = fe->demodulator_priv; | 626 | struct tda1004x_state* state = fe->demodulator_priv; |
| 627 | dprintk("%s\n", __FUNCTION__); | 627 | dprintk("%s\n", __func__); |
| 628 | 628 | ||
| 629 | if (tda10046_fwupload(fe)) { | 629 | if (tda10046_fwupload(fe)) { |
| 630 | printk("tda1004x: firmware upload failed\n"); | 630 | printk("tda1004x: firmware upload failed\n"); |
| @@ -686,7 +686,7 @@ static int tda1004x_set_fe(struct dvb_frontend* fe, | |||
| 686 | int tmp; | 686 | int tmp; |
| 687 | int inversion; | 687 | int inversion; |
| 688 | 688 | ||
| 689 | dprintk("%s\n", __FUNCTION__); | 689 | dprintk("%s\n", __func__); |
| 690 | 690 | ||
| 691 | if (state->demod_type == TDA1004X_DEMOD_TDA10046) { | 691 | if (state->demod_type == TDA1004X_DEMOD_TDA10046) { |
| 692 | // setup auto offset | 692 | // setup auto offset |
| @@ -881,7 +881,7 @@ static int tda1004x_get_fe(struct dvb_frontend* fe, struct dvb_frontend_paramete | |||
| 881 | { | 881 | { |
| 882 | struct tda1004x_state* state = fe->demodulator_priv; | 882 | struct tda1004x_state* state = fe->demodulator_priv; |
| 883 | 883 | ||
| 884 | dprintk("%s\n", __FUNCTION__); | 884 | dprintk("%s\n", __func__); |
| 885 | 885 | ||
| 886 | // inversion status | 886 | // inversion status |
| 887 | fe_params->inversion = INVERSION_OFF; | 887 | fe_params->inversion = INVERSION_OFF; |
| @@ -989,7 +989,7 @@ static int tda1004x_read_status(struct dvb_frontend* fe, fe_status_t * fe_status | |||
| 989 | int cber; | 989 | int cber; |
| 990 | int vber; | 990 | int vber; |
| 991 | 991 | ||
| 992 | dprintk("%s\n", __FUNCTION__); | 992 | dprintk("%s\n", __func__); |
| 993 | 993 | ||
| 994 | // read status | 994 | // read status |
| 995 | status = tda1004x_read_byte(state, TDA1004X_STATUS_CD); | 995 | status = tda1004x_read_byte(state, TDA1004X_STATUS_CD); |
| @@ -1048,7 +1048,7 @@ static int tda1004x_read_status(struct dvb_frontend* fe, fe_status_t * fe_status | |||
| 1048 | } | 1048 | } |
| 1049 | 1049 | ||
| 1050 | // success | 1050 | // success |
| 1051 | dprintk("%s: fe_status=0x%x\n", __FUNCTION__, *fe_status); | 1051 | dprintk("%s: fe_status=0x%x\n", __func__, *fe_status); |
| 1052 | return 0; | 1052 | return 0; |
| 1053 | } | 1053 | } |
| 1054 | 1054 | ||
| @@ -1058,7 +1058,7 @@ static int tda1004x_read_signal_strength(struct dvb_frontend* fe, u16 * signal) | |||
| 1058 | int tmp; | 1058 | int tmp; |
| 1059 | int reg = 0; | 1059 | int reg = 0; |
| 1060 | 1060 | ||
| 1061 | dprintk("%s\n", __FUNCTION__); | 1061 | dprintk("%s\n", __func__); |
| 1062 | 1062 | ||
| 1063 | // determine the register to use | 1063 | // determine the register to use |
| 1064 | switch (state->demod_type) { | 1064 | switch (state->demod_type) { |
| @@ -1077,7 +1077,7 @@ static int tda1004x_read_signal_strength(struct dvb_frontend* fe, u16 * signal) | |||
| 1077 | return -EIO; | 1077 | return -EIO; |
| 1078 | 1078 | ||
| 1079 | *signal = (tmp << 8) | tmp; | 1079 | *signal = (tmp << 8) | tmp; |
| 1080 | dprintk("%s: signal=0x%x\n", __FUNCTION__, *signal); | 1080 | dprintk("%s: signal=0x%x\n", __func__, *signal); |
| 1081 | return 0; | 1081 | return 0; |
| 1082 | } | 1082 | } |
| 1083 | 1083 | ||
| @@ -1086,7 +1086,7 @@ static int tda1004x_read_snr(struct dvb_frontend* fe, u16 * snr) | |||
| 1086 | struct tda1004x_state* state = fe->demodulator_priv; | 1086 | struct tda1004x_state* state = fe->demodulator_priv; |
| 1087 | int tmp; | 1087 | int tmp; |
| 1088 | 1088 | ||
| 1089 | dprintk("%s\n", __FUNCTION__); | 1089 | dprintk("%s\n", __func__); |
| 1090 | 1090 | ||
| 1091 | // read it | 1091 | // read it |
| 1092 | tmp = tda1004x_read_byte(state, TDA1004X_SNR); | 1092 | tmp = tda1004x_read_byte(state, TDA1004X_SNR); |
| @@ -1095,7 +1095,7 @@ static int tda1004x_read_snr(struct dvb_frontend* fe, u16 * snr) | |||
| 1095 | tmp = 255 - tmp; | 1095 | tmp = 255 - tmp; |
| 1096 | 1096 | ||
| 1097 | *snr = ((tmp << 8) | tmp); | 1097 | *snr = ((tmp << 8) | tmp); |
| 1098 | dprintk("%s: snr=0x%x\n", __FUNCTION__, *snr); | 1098 | dprintk("%s: snr=0x%x\n", __func__, *snr); |
| 1099 | return 0; | 1099 | return 0; |
| 1100 | } | 1100 | } |
| 1101 | 1101 | ||
| @@ -1106,7 +1106,7 @@ static int tda1004x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | |||
| 1106 | int tmp2; | 1106 | int tmp2; |
| 1107 | int counter; | 1107 | int counter; |
| 1108 | 1108 | ||
| 1109 | dprintk("%s\n", __FUNCTION__); | 1109 | dprintk("%s\n", __func__); |
| 1110 | 1110 | ||
| 1111 | // read the UCBLOCKS and reset | 1111 | // read the UCBLOCKS and reset |
| 1112 | counter = 0; | 1112 | counter = 0; |
| @@ -1132,7 +1132,7 @@ static int tda1004x_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | |||
| 1132 | else | 1132 | else |
| 1133 | *ucblocks = 0xffffffff; | 1133 | *ucblocks = 0xffffffff; |
| 1134 | 1134 | ||
| 1135 | dprintk("%s: ucblocks=0x%x\n", __FUNCTION__, *ucblocks); | 1135 | dprintk("%s: ucblocks=0x%x\n", __func__, *ucblocks); |
| 1136 | return 0; | 1136 | return 0; |
| 1137 | } | 1137 | } |
| 1138 | 1138 | ||
| @@ -1141,7 +1141,7 @@ static int tda1004x_read_ber(struct dvb_frontend* fe, u32* ber) | |||
| 1141 | struct tda1004x_state* state = fe->demodulator_priv; | 1141 | struct tda1004x_state* state = fe->demodulator_priv; |
| 1142 | int tmp; | 1142 | int tmp; |
| 1143 | 1143 | ||
| 1144 | dprintk("%s\n", __FUNCTION__); | 1144 | dprintk("%s\n", __func__); |
| 1145 | 1145 | ||
| 1146 | // read it in | 1146 | // read it in |
| 1147 | tmp = tda1004x_read_byte(state, TDA1004X_CBER_LSB); | 1147 | tmp = tda1004x_read_byte(state, TDA1004X_CBER_LSB); |
| @@ -1155,7 +1155,7 @@ static int tda1004x_read_ber(struct dvb_frontend* fe, u32* ber) | |||
| 1155 | // The address 0x20 should be read to cope with a TDA10046 bug | 1155 | // The address 0x20 should be read to cope with a TDA10046 bug |
| 1156 | tda1004x_read_byte(state, TDA1004X_CBER_RESET); | 1156 | tda1004x_read_byte(state, TDA1004X_CBER_RESET); |
| 1157 | 1157 | ||
| 1158 | dprintk("%s: ber=0x%x\n", __FUNCTION__, *ber); | 1158 | dprintk("%s: ber=0x%x\n", __func__, *ber); |
| 1159 | return 0; | 1159 | return 0; |
| 1160 | } | 1160 | } |
| 1161 | 1161 | ||
diff --git a/drivers/media/dvb/frontends/tda1004x.h b/drivers/media/dvb/frontends/tda1004x.h index abae84350142..4e27ffb0f14e 100644 --- a/drivers/media/dvb/frontends/tda1004x.h +++ b/drivers/media/dvb/frontends/tda1004x.h | |||
| @@ -94,7 +94,6 @@ struct tda1004x_config | |||
| 94 | 94 | ||
| 95 | /* slave address and configuration of the tuner */ | 95 | /* slave address and configuration of the tuner */ |
| 96 | u8 tuner_address; | 96 | u8 tuner_address; |
| 97 | u8 tuner_config; | ||
| 98 | u8 antenna_switch; | 97 | u8 antenna_switch; |
| 99 | 98 | ||
| 100 | /* if the board uses another I2c Bridge (tda8290), its address */ | 99 | /* if the board uses another I2c Bridge (tda8290), its address */ |
| @@ -128,13 +127,13 @@ extern struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config | |||
| 128 | static inline struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config, | 127 | static inline struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config, |
| 129 | struct i2c_adapter* i2c) | 128 | struct i2c_adapter* i2c) |
| 130 | { | 129 | { |
| 131 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 130 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 132 | return NULL; | 131 | return NULL; |
| 133 | } | 132 | } |
| 134 | static inline struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config, | 133 | static inline struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config, |
| 135 | struct i2c_adapter* i2c) | 134 | struct i2c_adapter* i2c) |
| 136 | { | 135 | { |
| 137 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 136 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 138 | return NULL; | 137 | return NULL; |
| 139 | } | 138 | } |
| 140 | #endif // CONFIG_DVB_TDA1004X | 139 | #endif // CONFIG_DVB_TDA1004X |
diff --git a/drivers/media/dvb/frontends/tda10086.c b/drivers/media/dvb/frontends/tda10086.c index 0d2b69a99ad4..a17ce3c4ad86 100644 --- a/drivers/media/dvb/frontends/tda10086.c +++ b/drivers/media/dvb/frontends/tda10086.c | |||
| @@ -43,7 +43,7 @@ struct tda10086_state { | |||
| 43 | bool has_lock; | 43 | bool has_lock; |
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | static int debug = 0; | 46 | static int debug; |
| 47 | #define dprintk(args...) \ | 47 | #define dprintk(args...) \ |
| 48 | do { \ | 48 | do { \ |
| 49 | if (debug) printk(KERN_DEBUG "tda10086: " args); \ | 49 | if (debug) printk(KERN_DEBUG "tda10086: " args); \ |
| @@ -60,7 +60,7 @@ static int tda10086_write_byte(struct tda10086_state *state, int reg, int data) | |||
| 60 | 60 | ||
| 61 | if (ret != 1) | 61 | if (ret != 1) |
| 62 | dprintk("%s: error reg=0x%x, data=0x%x, ret=%i\n", | 62 | dprintk("%s: error reg=0x%x, data=0x%x, ret=%i\n", |
| 63 | __FUNCTION__, reg, data, ret); | 63 | __func__, reg, data, ret); |
| 64 | 64 | ||
| 65 | return (ret != 1) ? ret : 0; | 65 | return (ret != 1) ? ret : 0; |
| 66 | } | 66 | } |
| @@ -78,7 +78,7 @@ static int tda10086_read_byte(struct tda10086_state *state, int reg) | |||
| 78 | ret = i2c_transfer(state->i2c, msg, 2); | 78 | ret = i2c_transfer(state->i2c, msg, 2); |
| 79 | 79 | ||
| 80 | if (ret != 2) { | 80 | if (ret != 2) { |
| 81 | dprintk("%s: error reg=0x%x, ret=%i\n", __FUNCTION__, reg, | 81 | dprintk("%s: error reg=0x%x, ret=%i\n", __func__, reg, |
| 82 | ret); | 82 | ret); |
| 83 | return ret; | 83 | return ret; |
| 84 | } | 84 | } |
| @@ -90,16 +90,16 @@ static int tda10086_write_mask(struct tda10086_state *state, int reg, int mask, | |||
| 90 | { | 90 | { |
| 91 | int val; | 91 | int val; |
| 92 | 92 | ||
| 93 | // read a byte and check | 93 | /* read a byte and check */ |
| 94 | val = tda10086_read_byte(state, reg); | 94 | val = tda10086_read_byte(state, reg); |
| 95 | if (val < 0) | 95 | if (val < 0) |
| 96 | return val; | 96 | return val; |
| 97 | 97 | ||
| 98 | // mask if off | 98 | /* mask if off */ |
| 99 | val = val & ~mask; | 99 | val = val & ~mask; |
| 100 | val |= data & 0xff; | 100 | val |= data & 0xff; |
| 101 | 101 | ||
| 102 | // write it out again | 102 | /* write it out again */ |
| 103 | return tda10086_write_byte(state, reg, val); | 103 | return tda10086_write_byte(state, reg, val); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| @@ -108,62 +108,67 @@ static int tda10086_init(struct dvb_frontend* fe) | |||
| 108 | struct tda10086_state* state = fe->demodulator_priv; | 108 | struct tda10086_state* state = fe->demodulator_priv; |
| 109 | u8 t22k_off = 0x80; | 109 | u8 t22k_off = 0x80; |
| 110 | 110 | ||
| 111 | dprintk ("%s\n", __FUNCTION__); | 111 | dprintk ("%s\n", __func__); |
| 112 | 112 | ||
| 113 | if (state->config->diseqc_tone) | 113 | if (state->config->diseqc_tone) |
| 114 | t22k_off = 0; | 114 | t22k_off = 0; |
| 115 | // reset | 115 | /* reset */ |
| 116 | tda10086_write_byte(state, 0x00, 0x00); | 116 | tda10086_write_byte(state, 0x00, 0x00); |
| 117 | msleep(10); | 117 | msleep(10); |
| 118 | 118 | ||
| 119 | // misc setup | 119 | /* misc setup */ |
| 120 | tda10086_write_byte(state, 0x01, 0x94); | 120 | tda10086_write_byte(state, 0x01, 0x94); |
| 121 | tda10086_write_byte(state, 0x02, 0x35); // NOTE: TT drivers appear to disable CSWP | 121 | tda10086_write_byte(state, 0x02, 0x35); /* NOTE: TT drivers appear to disable CSWP */ |
| 122 | tda10086_write_byte(state, 0x03, 0xe4); | 122 | tda10086_write_byte(state, 0x03, 0xe4); |
| 123 | tda10086_write_byte(state, 0x04, 0x43); | 123 | tda10086_write_byte(state, 0x04, 0x43); |
| 124 | tda10086_write_byte(state, 0x0c, 0x0c); | 124 | tda10086_write_byte(state, 0x0c, 0x0c); |
| 125 | tda10086_write_byte(state, 0x1b, 0xb0); // noise threshold | 125 | tda10086_write_byte(state, 0x1b, 0xb0); /* noise threshold */ |
| 126 | tda10086_write_byte(state, 0x20, 0x89); // misc | 126 | tda10086_write_byte(state, 0x20, 0x89); /* misc */ |
| 127 | tda10086_write_byte(state, 0x30, 0x04); // acquisition period length | 127 | tda10086_write_byte(state, 0x30, 0x04); /* acquisition period length */ |
| 128 | tda10086_write_byte(state, 0x32, 0x00); // irq off | 128 | tda10086_write_byte(state, 0x32, 0x00); /* irq off */ |
| 129 | tda10086_write_byte(state, 0x31, 0x56); // setup AFC | 129 | tda10086_write_byte(state, 0x31, 0x56); /* setup AFC */ |
| 130 | 130 | ||
| 131 | // setup PLL (assumes 16Mhz XIN) | 131 | /* setup PLL (this assumes SACLK = 96MHz) */ |
| 132 | tda10086_write_byte(state, 0x55, 0x2c); // misc PLL setup | 132 | tda10086_write_byte(state, 0x55, 0x2c); /* misc PLL setup */ |
| 133 | tda10086_write_byte(state, 0x3a, 0x0b); // M=12 | 133 | if (state->config->xtal_freq == TDA10086_XTAL_16M) { |
| 134 | tda10086_write_byte(state, 0x3b, 0x01); // P=2 | 134 | tda10086_write_byte(state, 0x3a, 0x0b); /* M=12 */ |
| 135 | tda10086_write_mask(state, 0x55, 0x20, 0x00); // powerup PLL | 135 | tda10086_write_byte(state, 0x3b, 0x01); /* P=2 */ |
| 136 | 136 | } else { | |
| 137 | // setup TS interface | 137 | tda10086_write_byte(state, 0x3a, 0x17); /* M=24 */ |
| 138 | tda10086_write_byte(state, 0x3b, 0x00); /* P=1 */ | ||
| 139 | } | ||
| 140 | tda10086_write_mask(state, 0x55, 0x20, 0x00); /* powerup PLL */ | ||
| 141 | |||
| 142 | /* setup TS interface */ | ||
| 138 | tda10086_write_byte(state, 0x11, 0x81); | 143 | tda10086_write_byte(state, 0x11, 0x81); |
| 139 | tda10086_write_byte(state, 0x12, 0x81); | 144 | tda10086_write_byte(state, 0x12, 0x81); |
| 140 | tda10086_write_byte(state, 0x19, 0x40); // parallel mode A + MSBFIRST | 145 | tda10086_write_byte(state, 0x19, 0x40); /* parallel mode A + MSBFIRST */ |
| 141 | tda10086_write_byte(state, 0x56, 0x80); // powerdown WPLL - unused in the mode we use | 146 | tda10086_write_byte(state, 0x56, 0x80); /* powerdown WPLL - unused in the mode we use */ |
| 142 | tda10086_write_byte(state, 0x57, 0x08); // bypass WPLL - unused in the mode we use | 147 | tda10086_write_byte(state, 0x57, 0x08); /* bypass WPLL - unused in the mode we use */ |
| 143 | tda10086_write_byte(state, 0x10, 0x2a); | 148 | tda10086_write_byte(state, 0x10, 0x2a); |
| 144 | 149 | ||
| 145 | // setup ADC | 150 | /* setup ADC */ |
| 146 | tda10086_write_byte(state, 0x58, 0x61); // ADC setup | 151 | tda10086_write_byte(state, 0x58, 0x61); /* ADC setup */ |
| 147 | tda10086_write_mask(state, 0x58, 0x01, 0x00); // powerup ADC | 152 | tda10086_write_mask(state, 0x58, 0x01, 0x00); /* powerup ADC */ |
| 148 | 153 | ||
| 149 | // setup AGC | 154 | /* setup AGC */ |
| 150 | tda10086_write_byte(state, 0x05, 0x0B); | 155 | tda10086_write_byte(state, 0x05, 0x0B); |
| 151 | tda10086_write_byte(state, 0x37, 0x63); | 156 | tda10086_write_byte(state, 0x37, 0x63); |
| 152 | tda10086_write_byte(state, 0x3f, 0x0a); // NOTE: flydvb varies it | 157 | tda10086_write_byte(state, 0x3f, 0x0a); /* NOTE: flydvb varies it */ |
| 153 | tda10086_write_byte(state, 0x40, 0x64); | 158 | tda10086_write_byte(state, 0x40, 0x64); |
| 154 | tda10086_write_byte(state, 0x41, 0x4f); | 159 | tda10086_write_byte(state, 0x41, 0x4f); |
| 155 | tda10086_write_byte(state, 0x42, 0x43); | 160 | tda10086_write_byte(state, 0x42, 0x43); |
| 156 | 161 | ||
| 157 | // setup viterbi | 162 | /* setup viterbi */ |
| 158 | tda10086_write_byte(state, 0x1a, 0x11); // VBER 10^6, DVB, QPSK | 163 | tda10086_write_byte(state, 0x1a, 0x11); /* VBER 10^6, DVB, QPSK */ |
| 159 | 164 | ||
| 160 | // setup carrier recovery | 165 | /* setup carrier recovery */ |
| 161 | tda10086_write_byte(state, 0x3d, 0x80); | 166 | tda10086_write_byte(state, 0x3d, 0x80); |
| 162 | 167 | ||
| 163 | // setup SEC | 168 | /* setup SEC */ |
| 164 | tda10086_write_byte(state, 0x36, t22k_off); // all SEC off, 22k tone | 169 | tda10086_write_byte(state, 0x36, t22k_off); /* all SEC off, 22k tone */ |
| 165 | tda10086_write_byte(state, 0x34, (((1<<19) * (22000/1000)) / (SACLK/1000))); // } tone frequency | 170 | tda10086_write_byte(state, 0x34, (((1<<19) * (22000/1000)) / (SACLK/1000))); |
| 166 | tda10086_write_byte(state, 0x35, (((1<<19) * (22000/1000)) / (SACLK/1000)) >> 8); // } | 171 | tda10086_write_byte(state, 0x35, (((1<<19) * (22000/1000)) / (SACLK/1000)) >> 8); |
| 167 | 172 | ||
| 168 | return 0; | 173 | return 0; |
| 169 | } | 174 | } |
| @@ -173,7 +178,7 @@ static void tda10086_diseqc_wait(struct tda10086_state *state) | |||
| 173 | unsigned long timeout = jiffies + msecs_to_jiffies(200); | 178 | unsigned long timeout = jiffies + msecs_to_jiffies(200); |
| 174 | while (!(tda10086_read_byte(state, 0x50) & 0x01)) { | 179 | while (!(tda10086_read_byte(state, 0x50) & 0x01)) { |
| 175 | if(time_after(jiffies, timeout)) { | 180 | if(time_after(jiffies, timeout)) { |
| 176 | printk("%s: diseqc queue not ready, command may be lost.\n", __FUNCTION__); | 181 | printk("%s: diseqc queue not ready, command may be lost.\n", __func__); |
| 177 | break; | 182 | break; |
| 178 | } | 183 | } |
| 179 | msleep(10); | 184 | msleep(10); |
| @@ -185,7 +190,7 @@ static int tda10086_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) | |||
| 185 | struct tda10086_state* state = fe->demodulator_priv; | 190 | struct tda10086_state* state = fe->demodulator_priv; |
| 186 | u8 t22k_off = 0x80; | 191 | u8 t22k_off = 0x80; |
| 187 | 192 | ||
| 188 | dprintk ("%s\n", __FUNCTION__); | 193 | dprintk ("%s\n", __func__); |
| 189 | 194 | ||
| 190 | if (state->config->diseqc_tone) | 195 | if (state->config->diseqc_tone) |
| 191 | t22k_off = 0; | 196 | t22k_off = 0; |
| @@ -211,7 +216,7 @@ static int tda10086_send_master_cmd (struct dvb_frontend* fe, | |||
| 211 | u8 oldval; | 216 | u8 oldval; |
| 212 | u8 t22k_off = 0x80; | 217 | u8 t22k_off = 0x80; |
| 213 | 218 | ||
| 214 | dprintk ("%s\n", __FUNCTION__); | 219 | dprintk ("%s\n", __func__); |
| 215 | 220 | ||
| 216 | if (state->config->diseqc_tone) | 221 | if (state->config->diseqc_tone) |
| 217 | t22k_off = 0; | 222 | t22k_off = 0; |
| @@ -239,7 +244,7 @@ static int tda10086_send_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t minic | |||
| 239 | u8 oldval = tda10086_read_byte(state, 0x36); | 244 | u8 oldval = tda10086_read_byte(state, 0x36); |
| 240 | u8 t22k_off = 0x80; | 245 | u8 t22k_off = 0x80; |
| 241 | 246 | ||
| 242 | dprintk ("%s\n", __FUNCTION__); | 247 | dprintk ("%s\n", __func__); |
| 243 | 248 | ||
| 244 | if (state->config->diseqc_tone) | 249 | if (state->config->diseqc_tone) |
| 245 | t22k_off = 0; | 250 | t22k_off = 0; |
| @@ -266,7 +271,7 @@ static int tda10086_set_inversion(struct tda10086_state *state, | |||
| 266 | { | 271 | { |
| 267 | u8 invval = 0x80; | 272 | u8 invval = 0x80; |
| 268 | 273 | ||
| 269 | dprintk ("%s %i %i\n", __FUNCTION__, fe_params->inversion, state->config->invert); | 274 | dprintk ("%s %i %i\n", __func__, fe_params->inversion, state->config->invert); |
| 270 | 275 | ||
| 271 | switch(fe_params->inversion) { | 276 | switch(fe_params->inversion) { |
| 272 | case INVERSION_OFF: | 277 | case INVERSION_OFF: |
| @@ -300,9 +305,9 @@ static int tda10086_set_symbol_rate(struct tda10086_state *state, | |||
| 300 | u32 bdri; | 305 | u32 bdri; |
| 301 | u32 symbol_rate = fe_params->u.qpsk.symbol_rate; | 306 | u32 symbol_rate = fe_params->u.qpsk.symbol_rate; |
| 302 | 307 | ||
| 303 | dprintk ("%s %i\n", __FUNCTION__, symbol_rate); | 308 | dprintk ("%s %i\n", __func__, symbol_rate); |
| 304 | 309 | ||
| 305 | // setup the decimation and anti-aliasing filters.. | 310 | /* setup the decimation and anti-aliasing filters.. */ |
| 306 | if (symbol_rate < (u32) (SACLK * 0.0137)) { | 311 | if (symbol_rate < (u32) (SACLK * 0.0137)) { |
| 307 | dfn=4; | 312 | dfn=4; |
| 308 | afs=1; | 313 | afs=1; |
| @@ -339,13 +344,13 @@ static int tda10086_set_symbol_rate(struct tda10086_state *state, | |||
| 339 | byp=1; | 344 | byp=1; |
| 340 | } | 345 | } |
| 341 | 346 | ||
| 342 | // calculate BDR | 347 | /* calculate BDR */ |
| 343 | big = (1ULL<<21) * ((u64) symbol_rate/1000ULL) * (1ULL<<dfn); | 348 | big = (1ULL<<21) * ((u64) symbol_rate/1000ULL) * (1ULL<<dfn); |
| 344 | big += ((SACLK/1000ULL)-1ULL); | 349 | big += ((SACLK/1000ULL)-1ULL); |
| 345 | do_div(big, (SACLK/1000ULL)); | 350 | do_div(big, (SACLK/1000ULL)); |
| 346 | bdr = big & 0xfffff; | 351 | bdr = big & 0xfffff; |
| 347 | 352 | ||
| 348 | // calculate BDRI | 353 | /* calculate BDRI */ |
| 349 | tmp = (1<<dfn)*(symbol_rate/1000); | 354 | tmp = (1<<dfn)*(symbol_rate/1000); |
| 350 | bdri = ((32 * (SACLK/1000)) + (tmp-1)) / tmp; | 355 | bdri = ((32 * (SACLK/1000)) + (tmp-1)) / tmp; |
| 351 | 356 | ||
| @@ -366,7 +371,7 @@ static int tda10086_set_fec(struct tda10086_state *state, | |||
| 366 | { | 371 | { |
| 367 | u8 fecval; | 372 | u8 fecval; |
| 368 | 373 | ||
| 369 | dprintk ("%s %i\n", __FUNCTION__, fe_params->u.qpsk.fec_inner); | 374 | dprintk ("%s %i\n", __func__, fe_params->u.qpsk.fec_inner); |
| 370 | 375 | ||
| 371 | switch(fe_params->u.qpsk.fec_inner) { | 376 | switch(fe_params->u.qpsk.fec_inner) { |
| 372 | case FEC_1_2: | 377 | case FEC_1_2: |
| @@ -412,13 +417,13 @@ static int tda10086_set_frontend(struct dvb_frontend* fe, | |||
| 412 | u32 freq = 0; | 417 | u32 freq = 0; |
| 413 | int freqoff; | 418 | int freqoff; |
| 414 | 419 | ||
| 415 | dprintk ("%s\n", __FUNCTION__); | 420 | dprintk ("%s\n", __func__); |
| 416 | 421 | ||
| 417 | // modify parameters for tuning | 422 | /* modify parameters for tuning */ |
| 418 | tda10086_write_byte(state, 0x02, 0x35); | 423 | tda10086_write_byte(state, 0x02, 0x35); |
| 419 | state->has_lock = false; | 424 | state->has_lock = false; |
| 420 | 425 | ||
| 421 | // set params | 426 | /* set params */ |
| 422 | if (fe->ops.tuner_ops.set_params) { | 427 | if (fe->ops.tuner_ops.set_params) { |
| 423 | fe->ops.tuner_ops.set_params(fe, fe_params); | 428 | fe->ops.tuner_ops.set_params(fe, fe_params); |
| 424 | if (fe->ops.i2c_gate_ctrl) | 429 | if (fe->ops.i2c_gate_ctrl) |
| @@ -430,7 +435,7 @@ static int tda10086_set_frontend(struct dvb_frontend* fe, | |||
| 430 | fe->ops.i2c_gate_ctrl(fe, 0); | 435 | fe->ops.i2c_gate_ctrl(fe, 0); |
| 431 | } | 436 | } |
| 432 | 437 | ||
| 433 | // calcluate the frequency offset (in *Hz* not kHz) | 438 | /* calcluate the frequency offset (in *Hz* not kHz) */ |
| 434 | freqoff = fe_params->frequency - freq; | 439 | freqoff = fe_params->frequency - freq; |
| 435 | freqoff = ((1<<16) * freqoff) / (SACLK/1000); | 440 | freqoff = ((1<<16) * freqoff) / (SACLK/1000); |
| 436 | tda10086_write_byte(state, 0x3d, 0x80 | ((freqoff >> 8) & 0x7f)); | 441 | tda10086_write_byte(state, 0x3d, 0x80 | ((freqoff >> 8) & 0x7f)); |
| @@ -443,7 +448,7 @@ static int tda10086_set_frontend(struct dvb_frontend* fe, | |||
| 443 | if ((ret = tda10086_set_fec(state, fe_params)) < 0) | 448 | if ((ret = tda10086_set_fec(state, fe_params)) < 0) |
| 444 | return ret; | 449 | return ret; |
| 445 | 450 | ||
| 446 | // soft reset + disable TS output until lock | 451 | /* soft reset + disable TS output until lock */ |
| 447 | tda10086_write_mask(state, 0x10, 0x40, 0x40); | 452 | tda10086_write_mask(state, 0x10, 0x40, 0x40); |
| 448 | tda10086_write_mask(state, 0x00, 0x01, 0x00); | 453 | tda10086_write_mask(state, 0x00, 0x01, 0x00); |
| 449 | 454 | ||
| @@ -459,13 +464,13 @@ static int tda10086_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_pa | |||
| 459 | int tmp; | 464 | int tmp; |
| 460 | u64 tmp64; | 465 | u64 tmp64; |
| 461 | 466 | ||
| 462 | dprintk ("%s\n", __FUNCTION__); | 467 | dprintk ("%s\n", __func__); |
| 463 | 468 | ||
| 464 | // check for invalid symbol rate | 469 | /* check for invalid symbol rate */ |
| 465 | if (fe_params->u.qpsk.symbol_rate < 500000) | 470 | if (fe_params->u.qpsk.symbol_rate < 500000) |
| 466 | return -EINVAL; | 471 | return -EINVAL; |
| 467 | 472 | ||
| 468 | // calculate the updated frequency (note: we convert from Hz->kHz) | 473 | /* calculate the updated frequency (note: we convert from Hz->kHz) */ |
| 469 | tmp64 = tda10086_read_byte(state, 0x52); | 474 | tmp64 = tda10086_read_byte(state, 0x52); |
| 470 | tmp64 |= (tda10086_read_byte(state, 0x51) << 8); | 475 | tmp64 |= (tda10086_read_byte(state, 0x51) << 8); |
| 471 | if (tmp64 & 0x8000) | 476 | if (tmp64 & 0x8000) |
| @@ -474,7 +479,7 @@ static int tda10086_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_pa | |||
| 474 | do_div(tmp64, (1ULL<<15) * (1ULL<<1)); | 479 | do_div(tmp64, (1ULL<<15) * (1ULL<<1)); |
| 475 | fe_params->frequency = (int) state->frequency + (int) tmp64; | 480 | fe_params->frequency = (int) state->frequency + (int) tmp64; |
| 476 | 481 | ||
| 477 | // the inversion | 482 | /* the inversion */ |
| 478 | val = tda10086_read_byte(state, 0x0c); | 483 | val = tda10086_read_byte(state, 0x0c); |
| 479 | if (val & 0x80) { | 484 | if (val & 0x80) { |
| 480 | switch(val & 0x40) { | 485 | switch(val & 0x40) { |
| @@ -505,7 +510,7 @@ static int tda10086_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_pa | |||
| 505 | } | 510 | } |
| 506 | } | 511 | } |
| 507 | 512 | ||
| 508 | // calculate the updated symbol rate | 513 | /* calculate the updated symbol rate */ |
| 509 | tmp = tda10086_read_byte(state, 0x1d); | 514 | tmp = tda10086_read_byte(state, 0x1d); |
| 510 | if (tmp & 0x80) | 515 | if (tmp & 0x80) |
| 511 | tmp |= 0xffffff00; | 516 | tmp |= 0xffffff00; |
| @@ -513,7 +518,7 @@ static int tda10086_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_pa | |||
| 513 | tmp = ((state->symbol_rate/1000) * tmp) / (1000000/1000); | 518 | tmp = ((state->symbol_rate/1000) * tmp) / (1000000/1000); |
| 514 | fe_params->u.qpsk.symbol_rate = state->symbol_rate + tmp; | 519 | fe_params->u.qpsk.symbol_rate = state->symbol_rate + tmp; |
| 515 | 520 | ||
| 516 | // the FEC | 521 | /* the FEC */ |
| 517 | val = (tda10086_read_byte(state, 0x0d) & 0x70) >> 4; | 522 | val = (tda10086_read_byte(state, 0x0d) & 0x70) >> 4; |
| 518 | switch(val) { | 523 | switch(val) { |
| 519 | case 0x00: | 524 | case 0x00: |
| @@ -550,7 +555,7 @@ static int tda10086_read_status(struct dvb_frontend* fe, fe_status_t *fe_status) | |||
| 550 | struct tda10086_state* state = fe->demodulator_priv; | 555 | struct tda10086_state* state = fe->demodulator_priv; |
| 551 | u8 val; | 556 | u8 val; |
| 552 | 557 | ||
| 553 | dprintk ("%s\n", __FUNCTION__); | 558 | dprintk ("%s\n", __func__); |
| 554 | 559 | ||
| 555 | val = tda10086_read_byte(state, 0x0e); | 560 | val = tda10086_read_byte(state, 0x0e); |
| 556 | *fe_status = 0; | 561 | *fe_status = 0; |
| @@ -566,7 +571,7 @@ static int tda10086_read_status(struct dvb_frontend* fe, fe_status_t *fe_status) | |||
| 566 | *fe_status |= FE_HAS_LOCK; | 571 | *fe_status |= FE_HAS_LOCK; |
| 567 | if (!state->has_lock) { | 572 | if (!state->has_lock) { |
| 568 | state->has_lock = true; | 573 | state->has_lock = true; |
| 569 | // modify parameters for stable reception | 574 | /* modify parameters for stable reception */ |
| 570 | tda10086_write_byte(state, 0x02, 0x00); | 575 | tda10086_write_byte(state, 0x02, 0x00); |
| 571 | } | 576 | } |
| 572 | } | 577 | } |
| @@ -579,7 +584,7 @@ static int tda10086_read_signal_strength(struct dvb_frontend* fe, u16 * signal) | |||
| 579 | struct tda10086_state* state = fe->demodulator_priv; | 584 | struct tda10086_state* state = fe->demodulator_priv; |
| 580 | u8 _str; | 585 | u8 _str; |
| 581 | 586 | ||
| 582 | dprintk ("%s\n", __FUNCTION__); | 587 | dprintk ("%s\n", __func__); |
| 583 | 588 | ||
| 584 | _str = 0xff - tda10086_read_byte(state, 0x43); | 589 | _str = 0xff - tda10086_read_byte(state, 0x43); |
| 585 | *signal = (_str << 8) | _str; | 590 | *signal = (_str << 8) | _str; |
| @@ -592,7 +597,7 @@ static int tda10086_read_snr(struct dvb_frontend* fe, u16 * snr) | |||
| 592 | struct tda10086_state* state = fe->demodulator_priv; | 597 | struct tda10086_state* state = fe->demodulator_priv; |
| 593 | u8 _snr; | 598 | u8 _snr; |
| 594 | 599 | ||
| 595 | dprintk ("%s\n", __FUNCTION__); | 600 | dprintk ("%s\n", __func__); |
| 596 | 601 | ||
| 597 | _snr = 0xff - tda10086_read_byte(state, 0x1c); | 602 | _snr = 0xff - tda10086_read_byte(state, 0x1c); |
| 598 | *snr = (_snr << 8) | _snr; | 603 | *snr = (_snr << 8) | _snr; |
| @@ -604,12 +609,12 @@ static int tda10086_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) | |||
| 604 | { | 609 | { |
| 605 | struct tda10086_state* state = fe->demodulator_priv; | 610 | struct tda10086_state* state = fe->demodulator_priv; |
| 606 | 611 | ||
| 607 | dprintk ("%s\n", __FUNCTION__); | 612 | dprintk ("%s\n", __func__); |
| 608 | 613 | ||
| 609 | // read it | 614 | /* read it */ |
| 610 | *ucblocks = tda10086_read_byte(state, 0x18) & 0x7f; | 615 | *ucblocks = tda10086_read_byte(state, 0x18) & 0x7f; |
| 611 | 616 | ||
| 612 | // reset counter | 617 | /* reset counter */ |
| 613 | tda10086_write_byte(state, 0x18, 0x00); | 618 | tda10086_write_byte(state, 0x18, 0x00); |
| 614 | tda10086_write_byte(state, 0x18, 0x80); | 619 | tda10086_write_byte(state, 0x18, 0x80); |
| 615 | 620 | ||
| @@ -620,9 +625,9 @@ static int tda10086_read_ber(struct dvb_frontend* fe, u32* ber) | |||
| 620 | { | 625 | { |
| 621 | struct tda10086_state* state = fe->demodulator_priv; | 626 | struct tda10086_state* state = fe->demodulator_priv; |
| 622 | 627 | ||
| 623 | dprintk ("%s\n", __FUNCTION__); | 628 | dprintk ("%s\n", __func__); |
| 624 | 629 | ||
| 625 | // read it | 630 | /* read it */ |
| 626 | *ber = 0; | 631 | *ber = 0; |
| 627 | *ber |= tda10086_read_byte(state, 0x15); | 632 | *ber |= tda10086_read_byte(state, 0x15); |
| 628 | *ber |= tda10086_read_byte(state, 0x16) << 8; | 633 | *ber |= tda10086_read_byte(state, 0x16) << 8; |
| @@ -635,7 +640,7 @@ static int tda10086_sleep(struct dvb_frontend* fe) | |||
| 635 | { | 640 | { |
| 636 | struct tda10086_state* state = fe->demodulator_priv; | 641 | struct tda10086_state* state = fe->demodulator_priv; |
| 637 | 642 | ||
| 638 | dprintk ("%s\n", __FUNCTION__); | 643 | dprintk ("%s\n", __func__); |
| 639 | 644 | ||
| 640 | tda10086_write_mask(state, 0x00, 0x08, 0x08); | 645 | tda10086_write_mask(state, 0x00, 0x08, 0x08); |
| 641 | 646 | ||
| @@ -646,7 +651,7 @@ static int tda10086_i2c_gate_ctrl(struct dvb_frontend* fe, int enable) | |||
| 646 | { | 651 | { |
| 647 | struct tda10086_state* state = fe->demodulator_priv; | 652 | struct tda10086_state* state = fe->demodulator_priv; |
| 648 | 653 | ||
| 649 | dprintk ("%s\n", __FUNCTION__); | 654 | dprintk ("%s\n", __func__); |
| 650 | 655 | ||
| 651 | if (enable) { | 656 | if (enable) { |
| 652 | tda10086_write_mask(state, 0x00, 0x10, 0x10); | 657 | tda10086_write_mask(state, 0x00, 0x10, 0x10); |
| @@ -737,7 +742,7 @@ struct dvb_frontend* tda10086_attach(const struct tda10086_config* config, | |||
| 737 | { | 742 | { |
| 738 | struct tda10086_state *state; | 743 | struct tda10086_state *state; |
| 739 | 744 | ||
| 740 | dprintk ("%s\n", __FUNCTION__); | 745 | dprintk ("%s\n", __func__); |
| 741 | 746 | ||
| 742 | /* allocate memory for the internal state */ | 747 | /* allocate memory for the internal state */ |
| 743 | state = kmalloc(sizeof(struct tda10086_state), GFP_KERNEL); | 748 | state = kmalloc(sizeof(struct tda10086_state), GFP_KERNEL); |
diff --git a/drivers/media/dvb/frontends/tda10086.h b/drivers/media/dvb/frontends/tda10086.h index eeceaeee78ff..61148c558d8d 100644 --- a/drivers/media/dvb/frontends/tda10086.h +++ b/drivers/media/dvb/frontends/tda10086.h | |||
| @@ -26,6 +26,11 @@ | |||
| 26 | #include <linux/dvb/frontend.h> | 26 | #include <linux/dvb/frontend.h> |
| 27 | #include <linux/firmware.h> | 27 | #include <linux/firmware.h> |
| 28 | 28 | ||
| 29 | enum tda10086_xtal { | ||
| 30 | TDA10086_XTAL_16M, | ||
| 31 | TDA10086_XTAL_4M | ||
| 32 | }; | ||
| 33 | |||
| 29 | struct tda10086_config | 34 | struct tda10086_config |
| 30 | { | 35 | { |
| 31 | /* the demodulator's i2c address */ | 36 | /* the demodulator's i2c address */ |
| @@ -36,6 +41,9 @@ struct tda10086_config | |||
| 36 | 41 | ||
| 37 | /* do we need the diseqc signal with carrier? */ | 42 | /* do we need the diseqc signal with carrier? */ |
| 38 | u8 diseqc_tone; | 43 | u8 diseqc_tone; |
| 44 | |||
| 45 | /* frequency of the reference xtal */ | ||
| 46 | enum tda10086_xtal xtal_freq; | ||
| 39 | }; | 47 | }; |
| 40 | 48 | ||
| 41 | #if defined(CONFIG_DVB_TDA10086) || (defined(CONFIG_DVB_TDA10086_MODULE) && defined(MODULE)) | 49 | #if defined(CONFIG_DVB_TDA10086) || (defined(CONFIG_DVB_TDA10086_MODULE) && defined(MODULE)) |
| @@ -45,9 +53,9 @@ extern struct dvb_frontend* tda10086_attach(const struct tda10086_config* config | |||
| 45 | static inline struct dvb_frontend* tda10086_attach(const struct tda10086_config* config, | 53 | static inline struct dvb_frontend* tda10086_attach(const struct tda10086_config* config, |
| 46 | struct i2c_adapter* i2c) | 54 | struct i2c_adapter* i2c) |
| 47 | { | 55 | { |
| 48 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 56 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 49 | return NULL; | 57 | return NULL; |
| 50 | } | 58 | } |
| 51 | #endif // CONFIG_DVB_TDA10086 | 59 | #endif /* CONFIG_DVB_TDA10086 */ |
| 52 | 60 | ||
| 53 | #endif // TDA10086_H | 61 | #endif /* TDA10086_H */ |
diff --git a/drivers/media/dvb/frontends/tda18271-common.c b/drivers/media/dvb/frontends/tda18271-common.c index bca570990613..e27a7620a32f 100644 --- a/drivers/media/dvb/frontends/tda18271-common.c +++ b/drivers/media/dvb/frontends/tda18271-common.c | |||
| @@ -125,16 +125,16 @@ int tda18271_read_regs(struct dvb_frontend *fe) | |||
| 125 | unsigned char buf = 0x00; | 125 | unsigned char buf = 0x00; |
| 126 | int ret; | 126 | int ret; |
| 127 | struct i2c_msg msg[] = { | 127 | struct i2c_msg msg[] = { |
| 128 | { .addr = priv->i2c_addr, .flags = 0, | 128 | { .addr = priv->i2c_props.addr, .flags = 0, |
| 129 | .buf = &buf, .len = 1 }, | 129 | .buf = &buf, .len = 1 }, |
| 130 | { .addr = priv->i2c_addr, .flags = I2C_M_RD, | 130 | { .addr = priv->i2c_props.addr, .flags = I2C_M_RD, |
| 131 | .buf = regs, .len = 16 } | 131 | .buf = regs, .len = 16 } |
| 132 | }; | 132 | }; |
| 133 | 133 | ||
| 134 | tda18271_i2c_gate_ctrl(fe, 1); | 134 | tda18271_i2c_gate_ctrl(fe, 1); |
| 135 | 135 | ||
| 136 | /* read all registers */ | 136 | /* read all registers */ |
| 137 | ret = i2c_transfer(priv->i2c_adap, msg, 2); | 137 | ret = i2c_transfer(priv->i2c_props.adap, msg, 2); |
| 138 | 138 | ||
| 139 | tda18271_i2c_gate_ctrl(fe, 0); | 139 | tda18271_i2c_gate_ctrl(fe, 0); |
| 140 | 140 | ||
| @@ -155,16 +155,16 @@ int tda18271_read_extended(struct dvb_frontend *fe) | |||
| 155 | unsigned char buf = 0x00; | 155 | unsigned char buf = 0x00; |
| 156 | int ret, i; | 156 | int ret, i; |
| 157 | struct i2c_msg msg[] = { | 157 | struct i2c_msg msg[] = { |
| 158 | { .addr = priv->i2c_addr, .flags = 0, | 158 | { .addr = priv->i2c_props.addr, .flags = 0, |
| 159 | .buf = &buf, .len = 1 }, | 159 | .buf = &buf, .len = 1 }, |
| 160 | { .addr = priv->i2c_addr, .flags = I2C_M_RD, | 160 | { .addr = priv->i2c_props.addr, .flags = I2C_M_RD, |
| 161 | .buf = regdump, .len = TDA18271_NUM_REGS } | 161 | .buf = regdump, .len = TDA18271_NUM_REGS } |
| 162 | }; | 162 | }; |
| 163 | 163 | ||
| 164 | tda18271_i2c_gate_ctrl(fe, 1); | 164 | tda18271_i2c_gate_ctrl(fe, 1); |
| 165 | 165 | ||
| 166 | /* read all registers */ | 166 | /* read all registers */ |
| 167 | ret = i2c_transfer(priv->i2c_adap, msg, 2); | 167 | ret = i2c_transfer(priv->i2c_props.adap, msg, 2); |
| 168 | 168 | ||
| 169 | tda18271_i2c_gate_ctrl(fe, 0); | 169 | tda18271_i2c_gate_ctrl(fe, 0); |
| 170 | 170 | ||
| @@ -192,7 +192,7 @@ int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len) | |||
| 192 | struct tda18271_priv *priv = fe->tuner_priv; | 192 | struct tda18271_priv *priv = fe->tuner_priv; |
| 193 | unsigned char *regs = priv->tda18271_regs; | 193 | unsigned char *regs = priv->tda18271_regs; |
| 194 | unsigned char buf[TDA18271_NUM_REGS + 1]; | 194 | unsigned char buf[TDA18271_NUM_REGS + 1]; |
| 195 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, | 195 | struct i2c_msg msg = { .addr = priv->i2c_props.addr, .flags = 0, |
| 196 | .buf = buf, .len = len + 1 }; | 196 | .buf = buf, .len = len + 1 }; |
| 197 | int i, ret; | 197 | int i, ret; |
| 198 | 198 | ||
| @@ -205,7 +205,7 @@ int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len) | |||
| 205 | tda18271_i2c_gate_ctrl(fe, 1); | 205 | tda18271_i2c_gate_ctrl(fe, 1); |
| 206 | 206 | ||
| 207 | /* write registers */ | 207 | /* write registers */ |
| 208 | ret = i2c_transfer(priv->i2c_adap, &msg, 1); | 208 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); |
| 209 | 209 | ||
| 210 | tda18271_i2c_gate_ctrl(fe, 0); | 210 | tda18271_i2c_gate_ctrl(fe, 0); |
| 211 | 211 | ||
| @@ -217,13 +217,29 @@ int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len) | |||
| 217 | 217 | ||
| 218 | /*---------------------------------------------------------------------*/ | 218 | /*---------------------------------------------------------------------*/ |
| 219 | 219 | ||
| 220 | int tda18271_charge_pump_source(struct dvb_frontend *fe, | ||
| 221 | enum tda18271_pll pll, int force) | ||
| 222 | { | ||
| 223 | struct tda18271_priv *priv = fe->tuner_priv; | ||
| 224 | unsigned char *regs = priv->tda18271_regs; | ||
| 225 | |||
| 226 | int r_cp = (pll == TDA18271_CAL_PLL) ? R_EB7 : R_EB4; | ||
| 227 | |||
| 228 | regs[r_cp] &= ~0x20; | ||
| 229 | regs[r_cp] |= ((force & 1) << 5); | ||
| 230 | tda18271_write_regs(fe, r_cp, 1); | ||
| 231 | |||
| 232 | return 0; | ||
| 233 | } | ||
| 234 | |||
| 220 | int tda18271_init_regs(struct dvb_frontend *fe) | 235 | int tda18271_init_regs(struct dvb_frontend *fe) |
| 221 | { | 236 | { |
| 222 | struct tda18271_priv *priv = fe->tuner_priv; | 237 | struct tda18271_priv *priv = fe->tuner_priv; |
| 223 | unsigned char *regs = priv->tda18271_regs; | 238 | unsigned char *regs = priv->tda18271_regs; |
| 224 | 239 | ||
| 225 | tda_dbg("initializing registers for device @ %d-%04x\n", | 240 | tda_dbg("initializing registers for device @ %d-%04x\n", |
| 226 | i2c_adapter_id(priv->i2c_adap), priv->i2c_addr); | 241 | i2c_adapter_id(priv->i2c_props.adap), |
| 242 | priv->i2c_props.addr); | ||
| 227 | 243 | ||
| 228 | /* initialize registers */ | 244 | /* initialize registers */ |
| 229 | switch (priv->id) { | 245 | switch (priv->id) { |
| @@ -310,7 +326,12 @@ int tda18271_init_regs(struct dvb_frontend *fe) | |||
| 310 | regs[R_EB22] = 0x48; | 326 | regs[R_EB22] = 0x48; |
| 311 | regs[R_EB23] = 0xb0; | 327 | regs[R_EB23] = 0xb0; |
| 312 | 328 | ||
| 313 | tda18271_write_regs(fe, 0x00, TDA18271_NUM_REGS); | 329 | if (priv->small_i2c) { |
| 330 | tda18271_write_regs(fe, 0x00, 0x10); | ||
| 331 | tda18271_write_regs(fe, 0x10, 0x10); | ||
| 332 | tda18271_write_regs(fe, 0x20, 0x07); | ||
| 333 | } else | ||
| 334 | tda18271_write_regs(fe, 0x00, TDA18271_NUM_REGS); | ||
| 314 | 335 | ||
| 315 | /* setup agc1 gain */ | 336 | /* setup agc1 gain */ |
| 316 | regs[R_EB17] = 0x00; | 337 | regs[R_EB17] = 0x00; |
| @@ -349,24 +370,15 @@ int tda18271_init_regs(struct dvb_frontend *fe) | |||
| 349 | regs[R_MD2] = 0x08; | 370 | regs[R_MD2] = 0x08; |
| 350 | regs[R_MD3] = 0x00; | 371 | regs[R_MD3] = 0x00; |
| 351 | 372 | ||
| 352 | switch (priv->id) { | 373 | tda18271_write_regs(fe, R_EP3, 11); |
| 353 | case TDA18271HDC1: | ||
| 354 | tda18271_write_regs(fe, R_EP3, 11); | ||
| 355 | break; | ||
| 356 | case TDA18271HDC2: | ||
| 357 | tda18271_write_regs(fe, R_EP3, 12); | ||
| 358 | break; | ||
| 359 | }; | ||
| 360 | 374 | ||
| 361 | if ((priv->id) == TDA18271HDC2) { | 375 | if ((priv->id) == TDA18271HDC2) { |
| 362 | /* main pll cp source on */ | 376 | /* main pll cp source on */ |
| 363 | regs[R_EB4] = 0x61; | 377 | tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 1); |
| 364 | tda18271_write_regs(fe, R_EB4, 1); | ||
| 365 | msleep(1); | 378 | msleep(1); |
| 366 | 379 | ||
| 367 | /* main pll cp source off */ | 380 | /* main pll cp source off */ |
| 368 | regs[R_EB4] = 0x41; | 381 | tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 0); |
| 369 | tda18271_write_regs(fe, R_EB4, 1); | ||
| 370 | } | 382 | } |
| 371 | 383 | ||
| 372 | msleep(5); /* pll locking */ | 384 | msleep(5); /* pll locking */ |
| @@ -398,6 +410,7 @@ int tda18271_init_regs(struct dvb_frontend *fe) | |||
| 398 | tda18271_write_regs(fe, R_EP3, 11); | 410 | tda18271_write_regs(fe, R_EP3, 11); |
| 399 | msleep(5); /* pll locking */ | 411 | msleep(5); /* pll locking */ |
| 400 | 412 | ||
| 413 | /* launch detector */ | ||
| 401 | tda18271_write_regs(fe, R_EP1, 1); | 414 | tda18271_write_regs(fe, R_EP1, 1); |
| 402 | msleep(5); /* wanted mid measurement */ | 415 | msleep(5); /* wanted mid measurement */ |
| 403 | 416 | ||
diff --git a/drivers/media/dvb/frontends/tda18271-fe.c b/drivers/media/dvb/frontends/tda18271-fe.c index dfe72aaec380..b262100ae897 100644 --- a/drivers/media/dvb/frontends/tda18271-fe.c +++ b/drivers/media/dvb/frontends/tda18271-fe.c | |||
| @@ -31,30 +31,23 @@ static int tda18271_cal_on_startup; | |||
| 31 | module_param_named(cal, tda18271_cal_on_startup, int, 0644); | 31 | module_param_named(cal, tda18271_cal_on_startup, int, 0644); |
| 32 | MODULE_PARM_DESC(cal, "perform RF tracking filter calibration on startup"); | 32 | MODULE_PARM_DESC(cal, "perform RF tracking filter calibration on startup"); |
| 33 | 33 | ||
| 34 | static LIST_HEAD(tda18271_list); | ||
| 35 | static DEFINE_MUTEX(tda18271_list_mutex); | 34 | static DEFINE_MUTEX(tda18271_list_mutex); |
| 35 | static LIST_HEAD(hybrid_tuner_instance_list); | ||
| 36 | 36 | ||
| 37 | /*---------------------------------------------------------------------*/ | 37 | /*---------------------------------------------------------------------*/ |
| 38 | 38 | ||
| 39 | static int tda18271_ir_cal_init(struct dvb_frontend *fe) | 39 | static inline int charge_pump_source(struct dvb_frontend *fe, int force) |
| 40 | { | 40 | { |
| 41 | struct tda18271_priv *priv = fe->tuner_priv; | 41 | struct tda18271_priv *priv = fe->tuner_priv; |
| 42 | unsigned char *regs = priv->tda18271_regs; | 42 | return tda18271_charge_pump_source(fe, |
| 43 | 43 | (priv->role == TDA18271_SLAVE) ? | |
| 44 | tda18271_read_regs(fe); | 44 | TDA18271_CAL_PLL : |
| 45 | 45 | TDA18271_MAIN_PLL, force); | |
| 46 | /* test IR_CAL_OK to see if we need init */ | ||
| 47 | if ((regs[R_EP1] & 0x08) == 0) | ||
| 48 | tda18271_init_regs(fe); | ||
| 49 | |||
| 50 | return 0; | ||
| 51 | } | 46 | } |
| 52 | 47 | ||
| 53 | /* ------------------------------------------------------------------ */ | ||
| 54 | |||
| 55 | static int tda18271_channel_configuration(struct dvb_frontend *fe, | 48 | static int tda18271_channel_configuration(struct dvb_frontend *fe, |
| 56 | u32 ifc, u32 freq, u32 bw, u8 std, | 49 | struct tda18271_std_map_item *map, |
| 57 | int radio) | 50 | u32 freq, u32 bw) |
| 58 | { | 51 | { |
| 59 | struct tda18271_priv *priv = fe->tuner_priv; | 52 | struct tda18271_priv *priv = fe->tuner_priv; |
| 60 | unsigned char *regs = priv->tda18271_regs; | 53 | unsigned char *regs = priv->tda18271_regs; |
| @@ -64,38 +57,34 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
| 64 | 57 | ||
| 65 | /* set standard */ | 58 | /* set standard */ |
| 66 | regs[R_EP3] &= ~0x1f; /* clear std bits */ | 59 | regs[R_EP3] &= ~0x1f; /* clear std bits */ |
| 67 | regs[R_EP3] |= std; | 60 | regs[R_EP3] |= (map->agc_mode << 3) | map->std; |
| 61 | |||
| 62 | /* set rfagc to high speed mode */ | ||
| 63 | regs[R_EP3] &= ~0x04; | ||
| 68 | 64 | ||
| 69 | /* set cal mode to normal */ | 65 | /* set cal mode to normal */ |
| 70 | regs[R_EP4] &= ~0x03; | 66 | regs[R_EP4] &= ~0x03; |
| 71 | 67 | ||
| 72 | /* update IF output level & IF notch frequency */ | 68 | /* update IF output level & IF notch frequency */ |
| 73 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ | 69 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ |
| 70 | regs[R_EP4] |= (map->if_lvl << 2); | ||
| 74 | 71 | ||
| 75 | switch (priv->mode) { | 72 | switch (priv->mode) { |
| 76 | case TDA18271_ANALOG: | 73 | case TDA18271_ANALOG: |
| 77 | regs[R_MPD] &= ~0x80; /* IF notch = 0 */ | 74 | regs[R_MPD] &= ~0x80; /* IF notch = 0 */ |
| 78 | break; | 75 | break; |
| 79 | case TDA18271_DIGITAL: | 76 | case TDA18271_DIGITAL: |
| 80 | regs[R_EP4] |= 0x04; /* IF level = 1 */ | ||
| 81 | regs[R_MPD] |= 0x80; /* IF notch = 1 */ | 77 | regs[R_MPD] |= 0x80; /* IF notch = 1 */ |
| 82 | break; | 78 | break; |
| 83 | } | 79 | } |
| 84 | 80 | ||
| 85 | if (radio) | 81 | /* update FM_RFn */ |
| 86 | regs[R_EP4] |= 0x80; | 82 | regs[R_EP4] &= ~0x80; |
| 87 | else | 83 | regs[R_EP4] |= map->fm_rfn << 7; |
| 88 | regs[R_EP4] &= ~0x80; | ||
| 89 | 84 | ||
| 90 | /* update RF_TOP / IF_TOP */ | 85 | /* update rf top / if top */ |
| 91 | switch (priv->mode) { | 86 | regs[R_EB22] = 0x00; |
| 92 | case TDA18271_ANALOG: | 87 | regs[R_EB22] |= map->rfagc_top; |
| 93 | regs[R_EB22] = 0x2c; | ||
| 94 | break; | ||
| 95 | case TDA18271_DIGITAL: | ||
| 96 | regs[R_EB22] = 0x37; | ||
| 97 | break; | ||
| 98 | } | ||
| 99 | tda18271_write_regs(fe, R_EB22, 1); | 88 | tda18271_write_regs(fe, R_EB22, 1); |
| 100 | 89 | ||
| 101 | /* --------------------------------------------------------------- */ | 90 | /* --------------------------------------------------------------- */ |
| @@ -117,8 +106,14 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
| 117 | 106 | ||
| 118 | /* dual tuner and agc1 extra configuration */ | 107 | /* dual tuner and agc1 extra configuration */ |
| 119 | 108 | ||
| 120 | /* main vco when Master, cal vco when slave */ | 109 | switch (priv->role) { |
| 121 | regs[R_EB1] |= 0x04; /* FIXME: assumes master */ | 110 | case TDA18271_MASTER: |
| 111 | regs[R_EB1] |= 0x04; /* main vco */ | ||
| 112 | break; | ||
| 113 | case TDA18271_SLAVE: | ||
| 114 | regs[R_EB1] &= ~0x04; /* cal vco */ | ||
| 115 | break; | ||
| 116 | } | ||
| 122 | 117 | ||
| 123 | /* agc1 always active */ | 118 | /* agc1 always active */ |
| 124 | regs[R_EB1] &= ~0x02; | 119 | regs[R_EB1] &= ~0x02; |
| @@ -130,25 +125,40 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe, | |||
| 130 | 125 | ||
| 131 | /* --------------------------------------------------------------- */ | 126 | /* --------------------------------------------------------------- */ |
| 132 | 127 | ||
| 133 | N = freq + ifc; | 128 | N = map->if_freq * 1000 + freq; |
| 134 | 129 | ||
| 135 | /* FIXME: assumes master */ | 130 | switch (priv->role) { |
| 136 | tda18271_calc_main_pll(fe, N); | 131 | case TDA18271_MASTER: |
| 137 | tda18271_write_regs(fe, R_MPD, 4); | 132 | tda18271_calc_main_pll(fe, N); |
| 133 | tda18271_write_regs(fe, R_MPD, 4); | ||
| 134 | break; | ||
| 135 | case TDA18271_SLAVE: | ||
| 136 | tda18271_calc_cal_pll(fe, N); | ||
| 137 | tda18271_write_regs(fe, R_CPD, 4); | ||
| 138 | |||
| 139 | regs[R_MPD] = regs[R_CPD] & 0x7f; | ||
| 140 | tda18271_write_regs(fe, R_MPD, 1); | ||
| 141 | break; | ||
| 142 | } | ||
| 138 | 143 | ||
| 139 | tda18271_write_regs(fe, R_TM, 7); | 144 | tda18271_write_regs(fe, R_TM, 7); |
| 140 | 145 | ||
| 141 | /* main pll charge pump source */ | 146 | /* force charge pump source */ |
| 142 | regs[R_EB4] |= 0x20; | 147 | charge_pump_source(fe, 1); |
| 143 | tda18271_write_regs(fe, R_EB4, 1); | ||
| 144 | 148 | ||
| 145 | msleep(1); | 149 | msleep(1); |
| 146 | 150 | ||
| 147 | /* normal operation for the main pll */ | 151 | /* return pll to normal operation */ |
| 148 | regs[R_EB4] &= ~0x20; | 152 | charge_pump_source(fe, 0); |
| 149 | tda18271_write_regs(fe, R_EB4, 1); | ||
| 150 | 153 | ||
| 151 | msleep(5); | 154 | msleep(20); |
| 155 | |||
| 156 | /* set rfagc to normal speed mode */ | ||
| 157 | if (map->fm_rfn) | ||
| 158 | regs[R_EP3] &= ~0x04; | ||
| 159 | else | ||
| 160 | regs[R_EP3] |= 0x04; | ||
| 161 | tda18271_write_regs(fe, R_EP3, 1); | ||
| 152 | 162 | ||
| 153 | return 0; | 163 | return 0; |
| 154 | } | 164 | } |
| @@ -195,8 +205,10 @@ static int tda18271_read_thermometer(struct dvb_frontend *fe) | |||
| 195 | return tm; | 205 | return tm; |
| 196 | } | 206 | } |
| 197 | 207 | ||
| 198 | static int tda18271_rf_tracking_filters_correction(struct dvb_frontend *fe, | 208 | /* ------------------------------------------------------------------ */ |
| 199 | u32 freq) | 209 | |
| 210 | static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe, | ||
| 211 | u32 freq) | ||
| 200 | { | 212 | { |
| 201 | struct tda18271_priv *priv = fe->tuner_priv; | 213 | struct tda18271_priv *priv = fe->tuner_priv; |
| 202 | struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; | 214 | struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; |
| @@ -296,12 +308,10 @@ static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) | |||
| 296 | tda18271_write_regs(fe, R_EB13, 1); | 308 | tda18271_write_regs(fe, R_EB13, 1); |
| 297 | 309 | ||
| 298 | /* main pll charge pump source */ | 310 | /* main pll charge pump source */ |
| 299 | regs[R_EB4] |= 0x20; | 311 | tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 1); |
| 300 | tda18271_write_regs(fe, R_EB4, 1); | ||
| 301 | 312 | ||
| 302 | /* cal pll charge pump source */ | 313 | /* cal pll charge pump source */ |
| 303 | regs[R_EB7] |= 0x20; | 314 | tda18271_charge_pump_source(fe, TDA18271_CAL_PLL, 1); |
| 304 | tda18271_write_regs(fe, R_EB7, 1); | ||
| 305 | 315 | ||
| 306 | /* force dcdc converter to 0 V */ | 316 | /* force dcdc converter to 0 V */ |
| 307 | regs[R_EB14] = 0x00; | 317 | regs[R_EB14] = 0x00; |
| @@ -320,8 +330,8 @@ static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) | |||
| 320 | /* set the internal calibration signal */ | 330 | /* set the internal calibration signal */ |
| 321 | N = freq; | 331 | N = freq; |
| 322 | 332 | ||
| 323 | tda18271_calc_main_pll(fe, N); | 333 | tda18271_calc_cal_pll(fe, N); |
| 324 | tda18271_write_regs(fe, R_MPD, 4); | 334 | tda18271_write_regs(fe, R_CPD, 4); |
| 325 | 335 | ||
| 326 | /* downconvert internal calibration */ | 336 | /* downconvert internal calibration */ |
| 327 | N += 1000000; | 337 | N += 1000000; |
| @@ -339,14 +349,12 @@ static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) | |||
| 339 | /* --------------------------------------------------------------- */ | 349 | /* --------------------------------------------------------------- */ |
| 340 | 350 | ||
| 341 | /* normal operation for the main pll */ | 351 | /* normal operation for the main pll */ |
| 342 | regs[R_EB4] &= ~0x20; | 352 | tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 0); |
| 343 | tda18271_write_regs(fe, R_EB4, 1); | ||
| 344 | 353 | ||
| 345 | /* normal operation for the cal pll */ | 354 | /* normal operation for the cal pll */ |
| 346 | regs[R_EB7] &= ~0x20; | 355 | tda18271_charge_pump_source(fe, TDA18271_CAL_PLL, 0); |
| 347 | tda18271_write_regs(fe, R_EB7, 1); | ||
| 348 | 356 | ||
| 349 | msleep(5); /* plls locking */ | 357 | msleep(10); /* plls locking */ |
| 350 | 358 | ||
| 351 | /* launch the rf tracking filters calibration */ | 359 | /* launch the rf tracking filters calibration */ |
| 352 | regs[R_EB20] |= 0x20; | 360 | regs[R_EB20] |= 0x20; |
| @@ -443,7 +451,7 @@ static int tda18271_powerscan(struct dvb_frontend *fe, | |||
| 443 | 451 | ||
| 444 | count += 200; | 452 | count += 200; |
| 445 | 453 | ||
| 446 | if (count < count_limit) | 454 | if (count <= count_limit) |
| 447 | continue; | 455 | continue; |
| 448 | 456 | ||
| 449 | if (sgn <= 0) | 457 | if (sgn <= 0) |
| @@ -587,7 +595,7 @@ static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe) | |||
| 587 | 595 | ||
| 588 | /* ------------------------------------------------------------------ */ | 596 | /* ------------------------------------------------------------------ */ |
| 589 | 597 | ||
| 590 | static int tda18271_rf_cal_init(struct dvb_frontend *fe) | 598 | static int tda18271c2_rf_cal_init(struct dvb_frontend *fe) |
| 591 | { | 599 | { |
| 592 | struct tda18271_priv *priv = fe->tuner_priv; | 600 | struct tda18271_priv *priv = fe->tuner_priv; |
| 593 | unsigned char *regs = priv->tda18271_regs; | 601 | unsigned char *regs = priv->tda18271_regs; |
| @@ -610,63 +618,13 @@ static int tda18271_rf_cal_init(struct dvb_frontend *fe) | |||
| 610 | return 0; | 618 | return 0; |
| 611 | } | 619 | } |
| 612 | 620 | ||
| 613 | static int tda18271_init(struct dvb_frontend *fe) | 621 | static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, |
| 614 | { | 622 | u32 freq, u32 bw) |
| 615 | struct tda18271_priv *priv = fe->tuner_priv; | ||
| 616 | |||
| 617 | mutex_lock(&priv->lock); | ||
| 618 | |||
| 619 | /* power up */ | ||
| 620 | tda18271_set_standby_mode(fe, 0, 0, 0); | ||
| 621 | |||
| 622 | /* initialization */ | ||
| 623 | tda18271_ir_cal_init(fe); | ||
| 624 | |||
| 625 | if (priv->id == TDA18271HDC2) | ||
| 626 | tda18271_rf_cal_init(fe); | ||
| 627 | |||
| 628 | mutex_unlock(&priv->lock); | ||
| 629 | |||
| 630 | return 0; | ||
| 631 | } | ||
| 632 | |||
| 633 | static int tda18271c2_tune(struct dvb_frontend *fe, | ||
| 634 | u32 ifc, u32 freq, u32 bw, u8 std, int radio) | ||
| 635 | { | ||
| 636 | struct tda18271_priv *priv = fe->tuner_priv; | ||
| 637 | |||
| 638 | tda_dbg("freq = %d, ifc = %d\n", freq, ifc); | ||
| 639 | |||
| 640 | tda18271_init(fe); | ||
| 641 | |||
| 642 | mutex_lock(&priv->lock); | ||
| 643 | |||
| 644 | tda18271_rf_tracking_filters_correction(fe, freq); | ||
| 645 | |||
| 646 | tda18271_channel_configuration(fe, ifc, freq, bw, std, radio); | ||
| 647 | |||
| 648 | mutex_unlock(&priv->lock); | ||
| 649 | |||
| 650 | return 0; | ||
| 651 | } | ||
| 652 | |||
| 653 | /* ------------------------------------------------------------------ */ | ||
| 654 | |||
| 655 | static int tda18271c1_tune(struct dvb_frontend *fe, | ||
| 656 | u32 ifc, u32 freq, u32 bw, u8 std, int radio) | ||
| 657 | { | 623 | { |
| 658 | struct tda18271_priv *priv = fe->tuner_priv; | 624 | struct tda18271_priv *priv = fe->tuner_priv; |
| 659 | unsigned char *regs = priv->tda18271_regs; | 625 | unsigned char *regs = priv->tda18271_regs; |
| 660 | u32 N = 0; | 626 | u32 N = 0; |
| 661 | 627 | ||
| 662 | tda18271_init(fe); | ||
| 663 | |||
| 664 | mutex_lock(&priv->lock); | ||
| 665 | |||
| 666 | tda_dbg("freq = %d, ifc = %d\n", freq, ifc); | ||
| 667 | |||
| 668 | /* RF tracking filter calibration */ | ||
| 669 | |||
| 670 | /* calculate bp filter */ | 628 | /* calculate bp filter */ |
| 671 | tda18271_calc_bp_filter(fe, &freq); | 629 | tda18271_calc_bp_filter(fe, &freq); |
| 672 | tda18271_write_regs(fe, R_EP1, 1); | 630 | tda18271_write_regs(fe, R_EP1, 1); |
| @@ -737,7 +695,7 @@ static int tda18271c1_tune(struct dvb_frontend *fe, | |||
| 737 | 695 | ||
| 738 | regs[R_EB7] = 0x40; | 696 | regs[R_EB7] = 0x40; |
| 739 | tda18271_write_regs(fe, R_EB7, 1); | 697 | tda18271_write_regs(fe, R_EB7, 1); |
| 740 | msleep(10); | 698 | msleep(10); /* pll locking */ |
| 741 | 699 | ||
| 742 | regs[R_EB20] = 0xec; | 700 | regs[R_EB20] = 0xec; |
| 743 | tda18271_write_regs(fe, R_EB20, 1); | 701 | tda18271_write_regs(fe, R_EB20, 1); |
| @@ -752,74 +710,70 @@ static int tda18271c1_tune(struct dvb_frontend *fe, | |||
| 752 | if (0 == tda18271_calc_rf_cal(fe, &freq)) | 710 | if (0 == tda18271_calc_rf_cal(fe, &freq)) |
| 753 | tda18271_write_regs(fe, R_EB14, 1); | 711 | tda18271_write_regs(fe, R_EB14, 1); |
| 754 | 712 | ||
| 755 | /* Channel Configuration */ | 713 | return 0; |
| 714 | } | ||
| 756 | 715 | ||
| 757 | switch (priv->mode) { | 716 | /* ------------------------------------------------------------------ */ |
| 758 | case TDA18271_ANALOG: | ||
| 759 | regs[R_EB22] = 0x2c; | ||
| 760 | break; | ||
| 761 | case TDA18271_DIGITAL: | ||
| 762 | regs[R_EB22] = 0x37; | ||
| 763 | break; | ||
| 764 | } | ||
| 765 | tda18271_write_regs(fe, R_EB22, 1); | ||
| 766 | 717 | ||
| 767 | regs[R_EP1] |= 0x40; /* set dis power level on */ | 718 | static int tda18271_ir_cal_init(struct dvb_frontend *fe) |
| 719 | { | ||
| 720 | struct tda18271_priv *priv = fe->tuner_priv; | ||
| 721 | unsigned char *regs = priv->tda18271_regs; | ||
| 768 | 722 | ||
| 769 | /* set standard */ | 723 | tda18271_read_regs(fe); |
| 770 | regs[R_EP3] &= ~0x1f; /* clear std bits */ | ||
| 771 | 724 | ||
| 772 | /* see table 22 */ | 725 | /* test IR_CAL_OK to see if we need init */ |
| 773 | regs[R_EP3] |= std; | 726 | if ((regs[R_EP1] & 0x08) == 0) |
| 727 | tda18271_init_regs(fe); | ||
| 774 | 728 | ||
| 775 | regs[R_EP4] &= ~0x03; /* set cal mode to normal */ | 729 | return 0; |
| 730 | } | ||
| 776 | 731 | ||
| 777 | regs[R_EP4] &= ~0x1c; /* clear if level bits */ | 732 | static int tda18271_init(struct dvb_frontend *fe) |
| 778 | switch (priv->mode) { | 733 | { |
| 779 | case TDA18271_ANALOG: | 734 | struct tda18271_priv *priv = fe->tuner_priv; |
| 780 | regs[R_MPD] &= ~0x80; /* IF notch = 0 */ | ||
| 781 | break; | ||
| 782 | case TDA18271_DIGITAL: | ||
| 783 | regs[R_EP4] |= 0x04; | ||
| 784 | regs[R_MPD] |= 0x80; | ||
| 785 | break; | ||
| 786 | } | ||
| 787 | 735 | ||
| 788 | if (radio) | 736 | mutex_lock(&priv->lock); |
| 789 | regs[R_EP4] |= 0x80; | ||
| 790 | else | ||
| 791 | regs[R_EP4] &= ~0x80; | ||
| 792 | 737 | ||
| 793 | /* image rejection validity */ | 738 | /* power up */ |
| 794 | tda18271_calc_ir_measure(fe, &freq); | 739 | tda18271_set_standby_mode(fe, 0, 0, 0); |
| 795 | 740 | ||
| 796 | /* calculate MAIN PLL */ | 741 | /* initialization */ |
| 797 | N = freq + ifc; | 742 | tda18271_ir_cal_init(fe); |
| 798 | 743 | ||
| 799 | tda18271_calc_main_pll(fe, N); | 744 | if (priv->id == TDA18271HDC2) |
| 745 | tda18271c2_rf_cal_init(fe); | ||
| 800 | 746 | ||
| 801 | tda18271_write_regs(fe, R_TM, 15); | ||
| 802 | msleep(5); | ||
| 803 | mutex_unlock(&priv->lock); | 747 | mutex_unlock(&priv->lock); |
| 804 | 748 | ||
| 805 | return 0; | 749 | return 0; |
| 806 | } | 750 | } |
| 807 | 751 | ||
| 808 | static inline int tda18271_tune(struct dvb_frontend *fe, | 752 | static int tda18271_tune(struct dvb_frontend *fe, |
| 809 | u32 ifc, u32 freq, u32 bw, u8 std, int radio) | 753 | struct tda18271_std_map_item *map, u32 freq, u32 bw) |
| 810 | { | 754 | { |
| 811 | struct tda18271_priv *priv = fe->tuner_priv; | 755 | struct tda18271_priv *priv = fe->tuner_priv; |
| 812 | int ret = -EINVAL; | 756 | |
| 757 | tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n", | ||
| 758 | freq, map->if_freq, bw, map->agc_mode, map->std); | ||
| 759 | |||
| 760 | tda18271_init(fe); | ||
| 761 | |||
| 762 | mutex_lock(&priv->lock); | ||
| 813 | 763 | ||
| 814 | switch (priv->id) { | 764 | switch (priv->id) { |
| 815 | case TDA18271HDC1: | 765 | case TDA18271HDC1: |
| 816 | ret = tda18271c1_tune(fe, ifc, freq, bw, std, radio); | 766 | tda18271c1_rf_tracking_filter_calibration(fe, freq, bw); |
| 817 | break; | 767 | break; |
| 818 | case TDA18271HDC2: | 768 | case TDA18271HDC2: |
| 819 | ret = tda18271c2_tune(fe, ifc, freq, bw, std, radio); | 769 | tda18271c2_rf_tracking_filters_correction(fe, freq); |
| 820 | break; | 770 | break; |
| 821 | } | 771 | } |
| 822 | return ret; | 772 | tda18271_channel_configuration(fe, map, freq, bw); |
| 773 | |||
| 774 | mutex_unlock(&priv->lock); | ||
| 775 | |||
| 776 | return 0; | ||
| 823 | } | 777 | } |
| 824 | 778 | ||
| 825 | /* ------------------------------------------------------------------ */ | 779 | /* ------------------------------------------------------------------ */ |
| @@ -829,9 +783,8 @@ static int tda18271_set_params(struct dvb_frontend *fe, | |||
| 829 | { | 783 | { |
| 830 | struct tda18271_priv *priv = fe->tuner_priv; | 784 | struct tda18271_priv *priv = fe->tuner_priv; |
| 831 | struct tda18271_std_map *std_map = &priv->std; | 785 | struct tda18271_std_map *std_map = &priv->std; |
| 786 | struct tda18271_std_map_item *map; | ||
| 832 | int ret; | 787 | int ret; |
| 833 | u8 std; | ||
| 834 | u16 sgIF; | ||
| 835 | u32 bw, freq = params->frequency; | 788 | u32 bw, freq = params->frequency; |
| 836 | 789 | ||
| 837 | priv->mode = TDA18271_DIGITAL; | 790 | priv->mode = TDA18271_DIGITAL; |
| @@ -840,13 +793,11 @@ static int tda18271_set_params(struct dvb_frontend *fe, | |||
| 840 | switch (params->u.vsb.modulation) { | 793 | switch (params->u.vsb.modulation) { |
| 841 | case VSB_8: | 794 | case VSB_8: |
| 842 | case VSB_16: | 795 | case VSB_16: |
| 843 | std = std_map->atsc_6.std_bits; | 796 | map = &std_map->atsc_6; |
| 844 | sgIF = std_map->atsc_6.if_freq; | ||
| 845 | break; | 797 | break; |
| 846 | case QAM_64: | 798 | case QAM_64: |
| 847 | case QAM_256: | 799 | case QAM_256: |
| 848 | std = std_map->qam_6.std_bits; | 800 | map = &std_map->qam_6; |
| 849 | sgIF = std_map->qam_6.if_freq; | ||
| 850 | break; | 801 | break; |
| 851 | default: | 802 | default: |
| 852 | tda_warn("modulation not set!\n"); | 803 | tda_warn("modulation not set!\n"); |
| @@ -861,18 +812,15 @@ static int tda18271_set_params(struct dvb_frontend *fe, | |||
| 861 | switch (params->u.ofdm.bandwidth) { | 812 | switch (params->u.ofdm.bandwidth) { |
| 862 | case BANDWIDTH_6_MHZ: | 813 | case BANDWIDTH_6_MHZ: |
| 863 | bw = 6000000; | 814 | bw = 6000000; |
| 864 | std = std_map->dvbt_6.std_bits; | 815 | map = &std_map->dvbt_6; |
| 865 | sgIF = std_map->dvbt_6.if_freq; | ||
| 866 | break; | 816 | break; |
| 867 | case BANDWIDTH_7_MHZ: | 817 | case BANDWIDTH_7_MHZ: |
| 868 | bw = 7000000; | 818 | bw = 7000000; |
| 869 | std = std_map->dvbt_7.std_bits; | 819 | map = &std_map->dvbt_7; |
| 870 | sgIF = std_map->dvbt_7.if_freq; | ||
| 871 | break; | 820 | break; |
| 872 | case BANDWIDTH_8_MHZ: | 821 | case BANDWIDTH_8_MHZ: |
| 873 | bw = 8000000; | 822 | bw = 8000000; |
| 874 | std = std_map->dvbt_8.std_bits; | 823 | map = &std_map->dvbt_8; |
| 875 | sgIF = std_map->dvbt_8.if_freq; | ||
| 876 | break; | 824 | break; |
| 877 | default: | 825 | default: |
| 878 | tda_warn("bandwidth not set!\n"); | 826 | tda_warn("bandwidth not set!\n"); |
| @@ -887,7 +835,7 @@ static int tda18271_set_params(struct dvb_frontend *fe, | |||
| 887 | if (fe->ops.analog_ops.standby) | 835 | if (fe->ops.analog_ops.standby) |
| 888 | fe->ops.analog_ops.standby(fe); | 836 | fe->ops.analog_ops.standby(fe); |
| 889 | 837 | ||
| 890 | ret = tda18271_tune(fe, sgIF * 1000, freq, bw, std, 0); | 838 | ret = tda18271_tune(fe, map, freq, bw); |
| 891 | 839 | ||
| 892 | if (ret < 0) | 840 | if (ret < 0) |
| 893 | goto fail; | 841 | goto fail; |
| @@ -904,57 +852,46 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe, | |||
| 904 | { | 852 | { |
| 905 | struct tda18271_priv *priv = fe->tuner_priv; | 853 | struct tda18271_priv *priv = fe->tuner_priv; |
| 906 | struct tda18271_std_map *std_map = &priv->std; | 854 | struct tda18271_std_map *std_map = &priv->std; |
| 855 | struct tda18271_std_map_item *map; | ||
| 907 | char *mode; | 856 | char *mode; |
| 908 | int ret, radio = 0; | 857 | int ret; |
| 909 | u8 std; | ||
| 910 | u16 sgIF; | ||
| 911 | u32 freq = params->frequency * 62500; | 858 | u32 freq = params->frequency * 62500; |
| 912 | 859 | ||
| 913 | priv->mode = TDA18271_ANALOG; | 860 | priv->mode = TDA18271_ANALOG; |
| 914 | 861 | ||
| 915 | if (params->mode == V4L2_TUNER_RADIO) { | 862 | if (params->mode == V4L2_TUNER_RADIO) { |
| 916 | radio = 1; | ||
| 917 | freq = freq / 1000; | 863 | freq = freq / 1000; |
| 918 | std = std_map->fm_radio.std_bits; | 864 | map = &std_map->fm_radio; |
| 919 | sgIF = std_map->fm_radio.if_freq; | ||
| 920 | mode = "fm"; | 865 | mode = "fm"; |
| 921 | } else if (params->std & V4L2_STD_MN) { | 866 | } else if (params->std & V4L2_STD_MN) { |
| 922 | std = std_map->atv_mn.std_bits; | 867 | map = &std_map->atv_mn; |
| 923 | sgIF = std_map->atv_mn.if_freq; | ||
| 924 | mode = "MN"; | 868 | mode = "MN"; |
| 925 | } else if (params->std & V4L2_STD_B) { | 869 | } else if (params->std & V4L2_STD_B) { |
| 926 | std = std_map->atv_b.std_bits; | 870 | map = &std_map->atv_b; |
| 927 | sgIF = std_map->atv_b.if_freq; | ||
| 928 | mode = "B"; | 871 | mode = "B"; |
| 929 | } else if (params->std & V4L2_STD_GH) { | 872 | } else if (params->std & V4L2_STD_GH) { |
| 930 | std = std_map->atv_gh.std_bits; | 873 | map = &std_map->atv_gh; |
| 931 | sgIF = std_map->atv_gh.if_freq; | ||
| 932 | mode = "GH"; | 874 | mode = "GH"; |
| 933 | } else if (params->std & V4L2_STD_PAL_I) { | 875 | } else if (params->std & V4L2_STD_PAL_I) { |
| 934 | std = std_map->atv_i.std_bits; | 876 | map = &std_map->atv_i; |
| 935 | sgIF = std_map->atv_i.if_freq; | ||
| 936 | mode = "I"; | 877 | mode = "I"; |
| 937 | } else if (params->std & V4L2_STD_DK) { | 878 | } else if (params->std & V4L2_STD_DK) { |
| 938 | std = std_map->atv_dk.std_bits; | 879 | map = &std_map->atv_dk; |
| 939 | sgIF = std_map->atv_dk.if_freq; | ||
| 940 | mode = "DK"; | 880 | mode = "DK"; |
| 941 | } else if (params->std & V4L2_STD_SECAM_L) { | 881 | } else if (params->std & V4L2_STD_SECAM_L) { |
| 942 | std = std_map->atv_l.std_bits; | 882 | map = &std_map->atv_l; |
| 943 | sgIF = std_map->atv_l.if_freq; | ||
| 944 | mode = "L"; | 883 | mode = "L"; |
| 945 | } else if (params->std & V4L2_STD_SECAM_LC) { | 884 | } else if (params->std & V4L2_STD_SECAM_LC) { |
| 946 | std = std_map->atv_lc.std_bits; | 885 | map = &std_map->atv_lc; |
| 947 | sgIF = std_map->atv_lc.if_freq; | ||
| 948 | mode = "L'"; | 886 | mode = "L'"; |
| 949 | } else { | 887 | } else { |
| 950 | std = std_map->atv_i.std_bits; | 888 | map = &std_map->atv_i; |
| 951 | sgIF = std_map->atv_i.if_freq; | ||
| 952 | mode = "xx"; | 889 | mode = "xx"; |
| 953 | } | 890 | } |
| 954 | 891 | ||
| 955 | tda_dbg("setting tda18271 to system %s\n", mode); | 892 | tda_dbg("setting tda18271 to system %s\n", mode); |
| 956 | 893 | ||
| 957 | ret = tda18271_tune(fe, sgIF * 1000, freq, 0, std, radio); | 894 | ret = tda18271_tune(fe, map, freq, 0); |
| 958 | 895 | ||
| 959 | if (ret < 0) | 896 | if (ret < 0) |
| 960 | goto fail; | 897 | goto fail; |
| @@ -986,16 +923,9 @@ static int tda18271_release(struct dvb_frontend *fe) | |||
| 986 | 923 | ||
| 987 | mutex_lock(&tda18271_list_mutex); | 924 | mutex_lock(&tda18271_list_mutex); |
| 988 | 925 | ||
| 989 | priv->count--; | 926 | if (priv) |
| 927 | hybrid_tuner_release_state(priv); | ||
| 990 | 928 | ||
| 991 | if (!priv->count) { | ||
| 992 | tda_dbg("destroying instance @ %d-%04x\n", | ||
| 993 | i2c_adapter_id(priv->i2c_adap), | ||
| 994 | priv->i2c_addr); | ||
| 995 | list_del(&priv->tda18271_list); | ||
| 996 | |||
| 997 | kfree(priv); | ||
| 998 | } | ||
| 999 | mutex_unlock(&tda18271_list_mutex); | 929 | mutex_unlock(&tda18271_list_mutex); |
| 1000 | 930 | ||
| 1001 | fe->tuner_priv = NULL; | 931 | fe->tuner_priv = NULL; |
| @@ -1020,15 +950,20 @@ static int tda18271_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) | |||
| 1020 | /* ------------------------------------------------------------------ */ | 950 | /* ------------------------------------------------------------------ */ |
| 1021 | 951 | ||
| 1022 | #define tda18271_update_std(std_cfg, name) do { \ | 952 | #define tda18271_update_std(std_cfg, name) do { \ |
| 1023 | if (map->std_cfg.if_freq + map->std_cfg.std_bits > 0) { \ | 953 | if (map->std_cfg.if_freq + \ |
| 954 | map->std_cfg.agc_mode + map->std_cfg.std + \ | ||
| 955 | map->std_cfg.if_lvl + map->std_cfg.rfagc_top > 0) { \ | ||
| 1024 | tda_dbg("Using custom std config for %s\n", name); \ | 956 | tda_dbg("Using custom std config for %s\n", name); \ |
| 1025 | memcpy(&std->std_cfg, &map->std_cfg, \ | 957 | memcpy(&std->std_cfg, &map->std_cfg, \ |
| 1026 | sizeof(struct tda18271_std_map_item)); \ | 958 | sizeof(struct tda18271_std_map_item)); \ |
| 1027 | } } while (0) | 959 | } } while (0) |
| 1028 | 960 | ||
| 1029 | #define tda18271_dump_std_item(std_cfg, name) do { \ | 961 | #define tda18271_dump_std_item(std_cfg, name) do { \ |
| 1030 | tda_dbg("(%s) if freq = %d, std bits = 0x%02x\n", \ | 962 | tda_dbg("(%s) if_freq = %d, agc_mode = %d, std = %d, " \ |
| 1031 | name, std->std_cfg.if_freq, std->std_cfg.std_bits); \ | 963 | "if_lvl = %d, rfagc_top = 0x%02x\n", \ |
| 964 | name, std->std_cfg.if_freq, \ | ||
| 965 | std->std_cfg.agc_mode, std->std_cfg.std, \ | ||
| 966 | std->std_cfg.if_lvl, std->std_cfg.rfagc_top); \ | ||
| 1032 | } while (0) | 967 | } while (0) |
| 1033 | 968 | ||
| 1034 | static int tda18271_dump_std_map(struct dvb_frontend *fe) | 969 | static int tda18271_dump_std_map(struct dvb_frontend *fe) |
| @@ -1037,20 +972,20 @@ static int tda18271_dump_std_map(struct dvb_frontend *fe) | |||
| 1037 | struct tda18271_std_map *std = &priv->std; | 972 | struct tda18271_std_map *std = &priv->std; |
| 1038 | 973 | ||
| 1039 | tda_dbg("========== STANDARD MAP SETTINGS ==========\n"); | 974 | tda_dbg("========== STANDARD MAP SETTINGS ==========\n"); |
| 1040 | tda18271_dump_std_item(fm_radio, "fm"); | 975 | tda18271_dump_std_item(fm_radio, " fm "); |
| 1041 | tda18271_dump_std_item(atv_b, "pal b"); | 976 | tda18271_dump_std_item(atv_b, "atv b "); |
| 1042 | tda18271_dump_std_item(atv_dk, "pal dk"); | 977 | tda18271_dump_std_item(atv_dk, "atv dk"); |
| 1043 | tda18271_dump_std_item(atv_gh, "pal gh"); | 978 | tda18271_dump_std_item(atv_gh, "atv gh"); |
| 1044 | tda18271_dump_std_item(atv_i, "pal i"); | 979 | tda18271_dump_std_item(atv_i, "atv i "); |
| 1045 | tda18271_dump_std_item(atv_l, "pal l"); | 980 | tda18271_dump_std_item(atv_l, "atv l "); |
| 1046 | tda18271_dump_std_item(atv_lc, "pal l'"); | 981 | tda18271_dump_std_item(atv_lc, "atv l'"); |
| 1047 | tda18271_dump_std_item(atv_mn, "atv mn"); | 982 | tda18271_dump_std_item(atv_mn, "atv mn"); |
| 1048 | tda18271_dump_std_item(atsc_6, "atsc 6"); | 983 | tda18271_dump_std_item(atsc_6, "atsc 6"); |
| 1049 | tda18271_dump_std_item(dvbt_6, "dvbt 6"); | 984 | tda18271_dump_std_item(dvbt_6, "dvbt 6"); |
| 1050 | tda18271_dump_std_item(dvbt_7, "dvbt 7"); | 985 | tda18271_dump_std_item(dvbt_7, "dvbt 7"); |
| 1051 | tda18271_dump_std_item(dvbt_8, "dvbt 8"); | 986 | tda18271_dump_std_item(dvbt_8, "dvbt 8"); |
| 1052 | tda18271_dump_std_item(qam_6, "qam 6"); | 987 | tda18271_dump_std_item(qam_6, "qam 6 "); |
| 1053 | tda18271_dump_std_item(qam_8, "qam 8"); | 988 | tda18271_dump_std_item(qam_8, "qam 8 "); |
| 1054 | 989 | ||
| 1055 | return 0; | 990 | return 0; |
| 1056 | } | 991 | } |
| @@ -1109,7 +1044,8 @@ static int tda18271_get_id(struct dvb_frontend *fe) | |||
| 1109 | } | 1044 | } |
| 1110 | 1045 | ||
| 1111 | tda_info("%s detected @ %d-%04x%s\n", name, | 1046 | tda_info("%s detected @ %d-%04x%s\n", name, |
| 1112 | i2c_adapter_id(priv->i2c_adap), priv->i2c_addr, | 1047 | i2c_adapter_id(priv->i2c_props.adap), |
| 1048 | priv->i2c_props.addr, | ||
| 1113 | (0 == ret) ? "" : ", device not supported."); | 1049 | (0 == ret) ? "" : ", device not supported."); |
| 1114 | 1050 | ||
| 1115 | return ret; | 1051 | return ret; |
| @@ -1136,45 +1072,28 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, | |||
| 1136 | struct tda18271_config *cfg) | 1072 | struct tda18271_config *cfg) |
| 1137 | { | 1073 | { |
| 1138 | struct tda18271_priv *priv = NULL; | 1074 | struct tda18271_priv *priv = NULL; |
| 1139 | int state_found = 0; | 1075 | int instance; |
| 1140 | 1076 | ||
| 1141 | mutex_lock(&tda18271_list_mutex); | 1077 | mutex_lock(&tda18271_list_mutex); |
| 1142 | 1078 | ||
| 1143 | list_for_each_entry(priv, &tda18271_list, tda18271_list) { | 1079 | instance = hybrid_tuner_request_state(struct tda18271_priv, priv, |
| 1144 | if ((i2c_adapter_id(priv->i2c_adap) == i2c_adapter_id(i2c)) && | 1080 | hybrid_tuner_instance_list, |
| 1145 | (priv->i2c_addr == addr)) { | 1081 | i2c, addr, "tda18271"); |
| 1146 | tda_dbg("attaching existing tuner @ %d-%04x\n", | 1082 | switch (instance) { |
| 1147 | i2c_adapter_id(priv->i2c_adap), | 1083 | case 0: |
| 1148 | priv->i2c_addr); | 1084 | goto fail; |
| 1149 | priv->count++; | 1085 | break; |
| 1150 | fe->tuner_priv = priv; | 1086 | case 1: |
| 1151 | state_found = 1; | 1087 | /* new tuner instance */ |
| 1152 | /* allow dvb driver to override i2c gate setting */ | ||
| 1153 | if ((cfg) && (cfg->gate != TDA18271_GATE_ANALOG)) | ||
| 1154 | priv->gate = cfg->gate; | ||
| 1155 | break; | ||
| 1156 | } | ||
| 1157 | } | ||
| 1158 | if (state_found == 0) { | ||
| 1159 | tda_dbg("creating new tuner instance @ %d-%04x\n", | ||
| 1160 | i2c_adapter_id(i2c), addr); | ||
| 1161 | |||
| 1162 | priv = kzalloc(sizeof(struct tda18271_priv), GFP_KERNEL); | ||
| 1163 | if (priv == NULL) { | ||
| 1164 | mutex_unlock(&tda18271_list_mutex); | ||
| 1165 | return NULL; | ||
| 1166 | } | ||
| 1167 | |||
| 1168 | priv->i2c_addr = addr; | ||
| 1169 | priv->i2c_adap = i2c; | ||
| 1170 | priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO; | 1088 | priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO; |
| 1089 | priv->role = (cfg) ? cfg->role : TDA18271_MASTER; | ||
| 1171 | priv->cal_initialized = false; | 1090 | priv->cal_initialized = false; |
| 1172 | mutex_init(&priv->lock); | 1091 | mutex_init(&priv->lock); |
| 1173 | priv->count++; | ||
| 1174 | 1092 | ||
| 1175 | fe->tuner_priv = priv; | 1093 | fe->tuner_priv = priv; |
| 1176 | 1094 | ||
| 1177 | list_add_tail(&priv->tda18271_list, &tda18271_list); | 1095 | if (cfg) |
| 1096 | priv->small_i2c = cfg->small_i2c; | ||
| 1178 | 1097 | ||
| 1179 | if (tda18271_get_id(fe) < 0) | 1098 | if (tda18271_get_id(fe) < 0) |
| 1180 | goto fail; | 1099 | goto fail; |
| @@ -1186,9 +1105,18 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, | |||
| 1186 | tda18271_init_regs(fe); | 1105 | tda18271_init_regs(fe); |
| 1187 | 1106 | ||
| 1188 | if ((tda18271_cal_on_startup) && (priv->id == TDA18271HDC2)) | 1107 | if ((tda18271_cal_on_startup) && (priv->id == TDA18271HDC2)) |
| 1189 | tda18271_rf_cal_init(fe); | 1108 | tda18271c2_rf_cal_init(fe); |
| 1190 | 1109 | ||
| 1191 | mutex_unlock(&priv->lock); | 1110 | mutex_unlock(&priv->lock); |
| 1111 | break; | ||
| 1112 | default: | ||
| 1113 | /* existing tuner instance */ | ||
| 1114 | fe->tuner_priv = priv; | ||
| 1115 | |||
| 1116 | /* allow dvb driver to override i2c gate setting */ | ||
| 1117 | if ((cfg) && (cfg->gate != TDA18271_GATE_ANALOG)) | ||
| 1118 | priv->gate = cfg->gate; | ||
| 1119 | break; | ||
| 1192 | } | 1120 | } |
| 1193 | 1121 | ||
| 1194 | /* override default std map with values in config struct */ | 1122 | /* override default std map with values in config struct */ |
| @@ -1200,7 +1128,7 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr, | |||
| 1200 | memcpy(&fe->ops.tuner_ops, &tda18271_tuner_ops, | 1128 | memcpy(&fe->ops.tuner_ops, &tda18271_tuner_ops, |
| 1201 | sizeof(struct dvb_tuner_ops)); | 1129 | sizeof(struct dvb_tuner_ops)); |
| 1202 | 1130 | ||
| 1203 | if (tda18271_debug & DBG_MAP) | 1131 | if (tda18271_debug & (DBG_MAP | DBG_ADV)) |
| 1204 | tda18271_dump_std_map(fe); | 1132 | tda18271_dump_std_map(fe); |
| 1205 | 1133 | ||
| 1206 | return fe; | 1134 | return fe; |
| @@ -1214,7 +1142,7 @@ EXPORT_SYMBOL_GPL(tda18271_attach); | |||
| 1214 | MODULE_DESCRIPTION("NXP TDA18271HD analog / digital tuner driver"); | 1142 | MODULE_DESCRIPTION("NXP TDA18271HD analog / digital tuner driver"); |
| 1215 | MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>"); | 1143 | MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>"); |
| 1216 | MODULE_LICENSE("GPL"); | 1144 | MODULE_LICENSE("GPL"); |
| 1217 | MODULE_VERSION("0.2"); | 1145 | MODULE_VERSION("0.3"); |
| 1218 | 1146 | ||
| 1219 | /* | 1147 | /* |
| 1220 | * Overrides for Emacs so that we follow Linus's tabbing style. | 1148 | * Overrides for Emacs so that we follow Linus's tabbing style. |
diff --git a/drivers/media/dvb/frontends/tda18271-priv.h b/drivers/media/dvb/frontends/tda18271-priv.h index 7b939a5325fb..2bc5eb368ea2 100644 --- a/drivers/media/dvb/frontends/tda18271-priv.h +++ b/drivers/media/dvb/frontends/tda18271-priv.h | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
| 25 | #include <linux/types.h> | 25 | #include <linux/types.h> |
| 26 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
| 27 | #include "tuner-i2c.h" | ||
| 27 | #include "tda18271.h" | 28 | #include "tda18271.h" |
| 28 | 29 | ||
| 29 | #define R_ID 0x00 /* ID byte */ | 30 | #define R_ID 0x00 /* ID byte */ |
| @@ -85,6 +86,11 @@ struct tda18271_rf_tracking_filter_cal { | |||
| 85 | int rf_b2; | 86 | int rf_b2; |
| 86 | }; | 87 | }; |
| 87 | 88 | ||
| 89 | enum tda18271_pll { | ||
| 90 | TDA18271_MAIN_PLL, | ||
| 91 | TDA18271_CAL_PLL, | ||
| 92 | }; | ||
| 93 | |||
| 88 | enum tda18271_mode { | 94 | enum tda18271_mode { |
| 89 | TDA18271_ANALOG, | 95 | TDA18271_ANALOG, |
| 90 | TDA18271_DIGITAL, | 96 | TDA18271_DIGITAL, |
| @@ -98,19 +104,19 @@ enum tda18271_ver { | |||
| 98 | }; | 104 | }; |
| 99 | 105 | ||
| 100 | struct tda18271_priv { | 106 | struct tda18271_priv { |
| 101 | u8 i2c_addr; | ||
| 102 | struct i2c_adapter *i2c_adap; | ||
| 103 | unsigned char tda18271_regs[TDA18271_NUM_REGS]; | 107 | unsigned char tda18271_regs[TDA18271_NUM_REGS]; |
| 104 | 108 | ||
| 105 | struct list_head tda18271_list; | 109 | struct list_head hybrid_tuner_instance_list; |
| 110 | struct tuner_i2c_props i2c_props; | ||
| 106 | 111 | ||
| 107 | enum tda18271_mode mode; | 112 | enum tda18271_mode mode; |
| 113 | enum tda18271_role role; | ||
| 108 | enum tda18271_i2c_gate gate; | 114 | enum tda18271_i2c_gate gate; |
| 109 | enum tda18271_ver id; | 115 | enum tda18271_ver id; |
| 110 | 116 | ||
| 111 | unsigned int count; | ||
| 112 | unsigned int tm_rfcal; | 117 | unsigned int tm_rfcal; |
| 113 | unsigned int cal_initialized:1; | 118 | unsigned int cal_initialized:1; |
| 119 | unsigned int small_i2c:1; | ||
| 114 | 120 | ||
| 115 | struct tda18271_map_layout *maps; | 121 | struct tda18271_map_layout *maps; |
| 116 | struct tda18271_std_map std; | 122 | struct tda18271_std_map std; |
| @@ -133,7 +139,7 @@ extern int tda18271_debug; | |||
| 133 | #define DBG_CAL 16 | 139 | #define DBG_CAL 16 |
| 134 | 140 | ||
| 135 | #define tda_printk(kern, fmt, arg...) \ | 141 | #define tda_printk(kern, fmt, arg...) \ |
| 136 | printk(kern "%s: " fmt, __FUNCTION__, ##arg) | 142 | printk(kern "%s: " fmt, __func__, ##arg) |
| 137 | 143 | ||
| 138 | #define dprintk(kern, lvl, fmt, arg...) do {\ | 144 | #define dprintk(kern, lvl, fmt, arg...) do {\ |
| 139 | if (tda18271_debug & lvl) \ | 145 | if (tda18271_debug & lvl) \ |
| @@ -188,6 +194,8 @@ extern int tda18271_read_extended(struct dvb_frontend *fe); | |||
| 188 | extern int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len); | 194 | extern int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len); |
| 189 | extern int tda18271_init_regs(struct dvb_frontend *fe); | 195 | extern int tda18271_init_regs(struct dvb_frontend *fe); |
| 190 | 196 | ||
| 197 | extern int tda18271_charge_pump_source(struct dvb_frontend *fe, | ||
| 198 | enum tda18271_pll pll, int force); | ||
| 191 | extern int tda18271_set_standby_mode(struct dvb_frontend *fe, | 199 | extern int tda18271_set_standby_mode(struct dvb_frontend *fe, |
| 192 | int sm, int sm_lt, int sm_xt); | 200 | int sm, int sm_lt, int sm_xt); |
| 193 | 201 | ||
diff --git a/drivers/media/dvb/frontends/tda18271-tables.c b/drivers/media/dvb/frontends/tda18271-tables.c index e94afcfdc5bc..83e7561960c1 100644 --- a/drivers/media/dvb/frontends/tda18271-tables.c +++ b/drivers/media/dvb/frontends/tda18271-tables.c | |||
| @@ -1187,37 +1187,65 @@ fail: | |||
| 1187 | /*---------------------------------------------------------------------*/ | 1187 | /*---------------------------------------------------------------------*/ |
| 1188 | 1188 | ||
| 1189 | static struct tda18271_std_map tda18271c1_std_map = { | 1189 | static struct tda18271_std_map tda18271c1_std_map = { |
| 1190 | .fm_radio = { .if_freq = 1250, .std_bits = 0x18 }, | 1190 | .fm_radio = { .if_freq = 1250, .fm_rfn = 1, .agc_mode = 3, .std = 0, |
| 1191 | .atv_b = { .if_freq = 6750, .std_bits = 0x0e }, | 1191 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x18 */ |
| 1192 | .atv_dk = { .if_freq = 7750, .std_bits = 0x0f }, | 1192 | .atv_b = { .if_freq = 6750, .fm_rfn = 0, .agc_mode = 1, .std = 6, |
| 1193 | .atv_gh = { .if_freq = 7750, .std_bits = 0x0f }, | 1193 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */ |
| 1194 | .atv_i = { .if_freq = 7750, .std_bits = 0x0f }, | 1194 | .atv_dk = { .if_freq = 7750, .fm_rfn = 0, .agc_mode = 1, .std = 7, |
| 1195 | .atv_l = { .if_freq = 7750, .std_bits = 0x0f }, | 1195 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0f */ |
| 1196 | .atv_lc = { .if_freq = 1250, .std_bits = 0x0f }, | 1196 | .atv_gh = { .if_freq = 7750, .fm_rfn = 0, .agc_mode = 1, .std = 7, |
| 1197 | .atv_mn = { .if_freq = 5750, .std_bits = 0x0d }, | 1197 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0f */ |
| 1198 | .atsc_6 = { .if_freq = 3250, .std_bits = 0x1c }, | 1198 | .atv_i = { .if_freq = 7750, .fm_rfn = 0, .agc_mode = 1, .std = 7, |
| 1199 | .dvbt_6 = { .if_freq = 3300, .std_bits = 0x1c }, | 1199 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0f */ |
| 1200 | .dvbt_7 = { .if_freq = 3800, .std_bits = 0x1d }, | 1200 | .atv_l = { .if_freq = 7750, .fm_rfn = 0, .agc_mode = 1, .std = 7, |
| 1201 | .dvbt_8 = { .if_freq = 4300, .std_bits = 0x1e }, | 1201 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0f */ |
| 1202 | .qam_6 = { .if_freq = 4000, .std_bits = 0x1d }, | 1202 | .atv_lc = { .if_freq = 1250, .fm_rfn = 0, .agc_mode = 1, .std = 7, |
| 1203 | .qam_8 = { .if_freq = 5000, .std_bits = 0x1f }, | 1203 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0f */ |
| 1204 | .atv_mn = { .if_freq = 5750, .fm_rfn = 0, .agc_mode = 1, .std = 5, | ||
| 1205 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0d */ | ||
| 1206 | .atsc_6 = { .if_freq = 3250, .fm_rfn = 0, .agc_mode = 3, .std = 4, | ||
| 1207 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1c */ | ||
| 1208 | .dvbt_6 = { .if_freq = 3300, .fm_rfn = 0, .agc_mode = 3, .std = 4, | ||
| 1209 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1c */ | ||
| 1210 | .dvbt_7 = { .if_freq = 3800, .fm_rfn = 0, .agc_mode = 3, .std = 5, | ||
| 1211 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1d */ | ||
| 1212 | .dvbt_8 = { .if_freq = 4300, .fm_rfn = 0, .agc_mode = 3, .std = 6, | ||
| 1213 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1e */ | ||
| 1214 | .qam_6 = { .if_freq = 4000, .fm_rfn = 0, .agc_mode = 3, .std = 5, | ||
| 1215 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1d */ | ||
| 1216 | .qam_8 = { .if_freq = 5000, .fm_rfn = 0, .agc_mode = 3, .std = 7, | ||
| 1217 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1f */ | ||
| 1204 | }; | 1218 | }; |
| 1205 | 1219 | ||
| 1206 | static struct tda18271_std_map tda18271c2_std_map = { | 1220 | static struct tda18271_std_map tda18271c2_std_map = { |
| 1207 | .fm_radio = { .if_freq = 1250, .std_bits = 0x18 }, | 1221 | .fm_radio = { .if_freq = 1250, .fm_rfn = 1, .agc_mode = 3, .std = 0, |
| 1208 | .atv_b = { .if_freq = 6000, .std_bits = 0x0d }, | 1222 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x18 */ |
| 1209 | .atv_dk = { .if_freq = 6900, .std_bits = 0x0e }, | 1223 | .atv_b = { .if_freq = 6000, .fm_rfn = 0, .agc_mode = 1, .std = 5, |
| 1210 | .atv_gh = { .if_freq = 7100, .std_bits = 0x0e }, | 1224 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0d */ |
| 1211 | .atv_i = { .if_freq = 7250, .std_bits = 0x0e }, | 1225 | .atv_dk = { .if_freq = 6900, .fm_rfn = 0, .agc_mode = 1, .std = 6, |
| 1212 | .atv_l = { .if_freq = 6900, .std_bits = 0x0e }, | 1226 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */ |
| 1213 | .atv_lc = { .if_freq = 1250, .std_bits = 0x0e }, | 1227 | .atv_gh = { .if_freq = 7100, .fm_rfn = 0, .agc_mode = 1, .std = 6, |
| 1214 | .atv_mn = { .if_freq = 5400, .std_bits = 0x0c }, | 1228 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */ |
| 1215 | .atsc_6 = { .if_freq = 3250, .std_bits = 0x1c }, | 1229 | .atv_i = { .if_freq = 7250, .fm_rfn = 0, .agc_mode = 1, .std = 6, |
| 1216 | .dvbt_6 = { .if_freq = 3300, .std_bits = 0x1c }, | 1230 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */ |
| 1217 | .dvbt_7 = { .if_freq = 3500, .std_bits = 0x1c }, | 1231 | .atv_l = { .if_freq = 6900, .fm_rfn = 0, .agc_mode = 1, .std = 6, |
| 1218 | .dvbt_8 = { .if_freq = 4000, .std_bits = 0x1d }, | 1232 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */ |
| 1219 | .qam_6 = { .if_freq = 4000, .std_bits = 0x1d }, | 1233 | .atv_lc = { .if_freq = 1250, .fm_rfn = 0, .agc_mode = 1, .std = 6, |
| 1220 | .qam_8 = { .if_freq = 5000, .std_bits = 0x1f }, | 1234 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0e */ |
| 1235 | .atv_mn = { .if_freq = 5400, .fm_rfn = 0, .agc_mode = 1, .std = 4, | ||
| 1236 | .if_lvl = 0, .rfagc_top = 0x2c, }, /* EP3[4:0] 0x0c */ | ||
| 1237 | .atsc_6 = { .if_freq = 3250, .fm_rfn = 0, .agc_mode = 3, .std = 4, | ||
| 1238 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1c */ | ||
| 1239 | .dvbt_6 = { .if_freq = 3300, .fm_rfn = 0, .agc_mode = 3, .std = 4, | ||
| 1240 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1c */ | ||
| 1241 | .dvbt_7 = { .if_freq = 3500, .fm_rfn = 0, .agc_mode = 3, .std = 4, | ||
| 1242 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1c */ | ||
| 1243 | .dvbt_8 = { .if_freq = 4000, .fm_rfn = 0, .agc_mode = 3, .std = 5, | ||
| 1244 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1d */ | ||
| 1245 | .qam_6 = { .if_freq = 4000, .fm_rfn = 0, .agc_mode = 3, .std = 5, | ||
| 1246 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1d */ | ||
| 1247 | .qam_8 = { .if_freq = 5000, .fm_rfn = 0, .agc_mode = 3, .std = 7, | ||
| 1248 | .if_lvl = 1, .rfagc_top = 0x37, }, /* EP3[4:0] 0x1f */ | ||
| 1221 | }; | 1249 | }; |
| 1222 | 1250 | ||
| 1223 | /*---------------------------------------------------------------------*/ | 1251 | /*---------------------------------------------------------------------*/ |
diff --git a/drivers/media/dvb/frontends/tda18271.h b/drivers/media/dvb/frontends/tda18271.h index 24b0e35a2ab3..0e7af8d05a38 100644 --- a/drivers/media/dvb/frontends/tda18271.h +++ b/drivers/media/dvb/frontends/tda18271.h | |||
| @@ -26,7 +26,17 @@ | |||
| 26 | 26 | ||
| 27 | struct tda18271_std_map_item { | 27 | struct tda18271_std_map_item { |
| 28 | u16 if_freq; | 28 | u16 if_freq; |
| 29 | u8 std_bits; | 29 | |
| 30 | /* EP3[4:3] */ | ||
| 31 | unsigned int agc_mode:2; | ||
| 32 | /* EP3[2:0] */ | ||
| 33 | unsigned int std:3; | ||
| 34 | /* EP4[7] */ | ||
| 35 | unsigned int fm_rfn:1; | ||
| 36 | /* EP4[4:2] */ | ||
| 37 | unsigned int if_lvl:3; | ||
| 38 | /* EB22[6:0] */ | ||
| 39 | unsigned int rfagc_top:7; | ||
| 30 | }; | 40 | }; |
| 31 | 41 | ||
| 32 | struct tda18271_std_map { | 42 | struct tda18271_std_map { |
| @@ -46,6 +56,11 @@ struct tda18271_std_map { | |||
| 46 | struct tda18271_std_map_item qam_8; | 56 | struct tda18271_std_map_item qam_8; |
| 47 | }; | 57 | }; |
| 48 | 58 | ||
| 59 | enum tda18271_role { | ||
| 60 | TDA18271_MASTER = 0, | ||
| 61 | TDA18271_SLAVE, | ||
| 62 | }; | ||
| 63 | |||
| 49 | enum tda18271_i2c_gate { | 64 | enum tda18271_i2c_gate { |
| 50 | TDA18271_GATE_AUTO = 0, | 65 | TDA18271_GATE_AUTO = 0, |
| 51 | TDA18271_GATE_ANALOG, | 66 | TDA18271_GATE_ANALOG, |
| @@ -56,8 +71,14 @@ struct tda18271_config { | |||
| 56 | /* override default if freq / std settings (optional) */ | 71 | /* override default if freq / std settings (optional) */ |
| 57 | struct tda18271_std_map *std_map; | 72 | struct tda18271_std_map *std_map; |
| 58 | 73 | ||
| 74 | /* master / slave tuner: master uses main pll, slave uses cal pll */ | ||
| 75 | enum tda18271_role role; | ||
| 76 | |||
| 59 | /* use i2c gate provided by analog or digital demod */ | 77 | /* use i2c gate provided by analog or digital demod */ |
| 60 | enum tda18271_i2c_gate gate; | 78 | enum tda18271_i2c_gate gate; |
| 79 | |||
| 80 | /* some i2c providers cant write all 39 registers at once */ | ||
| 81 | unsigned int small_i2c:1; | ||
| 61 | }; | 82 | }; |
| 62 | 83 | ||
| 63 | #if defined(CONFIG_DVB_TDA18271) || (defined(CONFIG_DVB_TDA18271_MODULE) && defined(MODULE)) | 84 | #if defined(CONFIG_DVB_TDA18271) || (defined(CONFIG_DVB_TDA18271_MODULE) && defined(MODULE)) |
| @@ -70,7 +91,7 @@ static inline struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, | |||
| 70 | struct i2c_adapter *i2c, | 91 | struct i2c_adapter *i2c, |
| 71 | struct tda18271_config *cfg) | 92 | struct tda18271_config *cfg) |
| 72 | { | 93 | { |
| 73 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 94 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 74 | return NULL; | 95 | return NULL; |
| 75 | } | 96 | } |
| 76 | #endif | 97 | #endif |
diff --git a/drivers/media/dvb/frontends/tda8083.c b/drivers/media/dvb/frontends/tda8083.c index 011b74f798a0..5b843b2e67e8 100644 --- a/drivers/media/dvb/frontends/tda8083.c +++ b/drivers/media/dvb/frontends/tda8083.c | |||
| @@ -68,7 +68,7 @@ static int tda8083_writereg (struct tda8083_state* state, u8 reg, u8 data) | |||
| 68 | 68 | ||
| 69 | if (ret != 1) | 69 | if (ret != 1) |
| 70 | dprintk ("%s: writereg error (reg %02x, ret == %i)\n", | 70 | dprintk ("%s: writereg error (reg %02x, ret == %i)\n", |
| 71 | __FUNCTION__, reg, ret); | 71 | __func__, reg, ret); |
| 72 | 72 | ||
| 73 | return (ret != 1) ? -1 : 0; | 73 | return (ret != 1) ? -1 : 0; |
| 74 | } | 74 | } |
| @@ -83,7 +83,7 @@ static int tda8083_readregs (struct tda8083_state* state, u8 reg1, u8 *b, u8 len | |||
| 83 | 83 | ||
| 84 | if (ret != 2) | 84 | if (ret != 2) |
| 85 | dprintk ("%s: readreg error (reg %02x, ret == %i)\n", | 85 | dprintk ("%s: readreg error (reg %02x, ret == %i)\n", |
| 86 | __FUNCTION__, reg1, ret); | 86 | __func__, reg1, ret); |
| 87 | 87 | ||
| 88 | return ret == 2 ? 0 : -1; | 88 | return ret == 2 ? 0 : -1; |
| 89 | } | 89 | } |
diff --git a/drivers/media/dvb/frontends/tda8083.h b/drivers/media/dvb/frontends/tda8083.h index 2d3307999f21..5a03c14a10e8 100644 --- a/drivers/media/dvb/frontends/tda8083.h +++ b/drivers/media/dvb/frontends/tda8083.h | |||
| @@ -42,7 +42,7 @@ extern struct dvb_frontend* tda8083_attach(const struct tda8083_config* config, | |||
| 42 | static inline struct dvb_frontend* tda8083_attach(const struct tda8083_config* config, | 42 | static inline struct dvb_frontend* tda8083_attach(const struct tda8083_config* config, |
| 43 | struct i2c_adapter* i2c) | 43 | struct i2c_adapter* i2c) |
| 44 | { | 44 | { |
| 45 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 45 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 46 | return NULL; | 46 | return NULL; |
| 47 | } | 47 | } |
| 48 | #endif // CONFIG_DVB_TDA8083 | 48 | #endif // CONFIG_DVB_TDA8083 |
diff --git a/drivers/media/dvb/frontends/tda826x.c b/drivers/media/dvb/frontends/tda826x.c index bd3ebc284835..a051554b5e25 100644 --- a/drivers/media/dvb/frontends/tda826x.c +++ b/drivers/media/dvb/frontends/tda826x.c | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | 26 | ||
| 27 | #include "tda826x.h" | 27 | #include "tda826x.h" |
| 28 | 28 | ||
| 29 | static int debug = 0; | 29 | static int debug; |
| 30 | #define dprintk(args...) \ | 30 | #define dprintk(args...) \ |
| 31 | do { \ | 31 | do { \ |
| 32 | if (debug) printk(KERN_DEBUG "tda826x: " args); \ | 32 | if (debug) printk(KERN_DEBUG "tda826x: " args); \ |
| @@ -54,7 +54,7 @@ static int tda826x_sleep(struct dvb_frontend *fe) | |||
| 54 | u8 buf [] = { 0x00, 0x8d }; | 54 | u8 buf [] = { 0x00, 0x8d }; |
| 55 | struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = buf, .len = 2 }; | 55 | struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = buf, .len = 2 }; |
| 56 | 56 | ||
| 57 | dprintk("%s:\n", __FUNCTION__); | 57 | dprintk("%s:\n", __func__); |
| 58 | 58 | ||
| 59 | if (!priv->has_loopthrough) | 59 | if (!priv->has_loopthrough) |
| 60 | buf[1] = 0xad; | 60 | buf[1] = 0xad; |
| @@ -62,7 +62,7 @@ static int tda826x_sleep(struct dvb_frontend *fe) | |||
| 62 | if (fe->ops.i2c_gate_ctrl) | 62 | if (fe->ops.i2c_gate_ctrl) |
| 63 | fe->ops.i2c_gate_ctrl(fe, 1); | 63 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 64 | if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) { | 64 | if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) { |
| 65 | dprintk("%s: i2c error\n", __FUNCTION__); | 65 | dprintk("%s: i2c error\n", __func__); |
| 66 | } | 66 | } |
| 67 | if (fe->ops.i2c_gate_ctrl) | 67 | if (fe->ops.i2c_gate_ctrl) |
| 68 | fe->ops.i2c_gate_ctrl(fe, 0); | 68 | fe->ops.i2c_gate_ctrl(fe, 0); |
| @@ -75,13 +75,24 @@ static int tda826x_set_params(struct dvb_frontend *fe, struct dvb_frontend_param | |||
| 75 | struct tda826x_priv *priv = fe->tuner_priv; | 75 | struct tda826x_priv *priv = fe->tuner_priv; |
| 76 | int ret; | 76 | int ret; |
| 77 | u32 div; | 77 | u32 div; |
| 78 | u32 ksyms; | ||
| 79 | u32 bandwidth; | ||
| 78 | u8 buf [11]; | 80 | u8 buf [11]; |
| 79 | struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = buf, .len = 11 }; | 81 | struct i2c_msg msg = { .addr = priv->i2c_address, .flags = 0, .buf = buf, .len = 11 }; |
| 80 | 82 | ||
| 81 | dprintk("%s:\n", __FUNCTION__); | 83 | dprintk("%s:\n", __func__); |
| 82 | 84 | ||
| 83 | div = (params->frequency + (1000-1)) / 1000; | 85 | div = (params->frequency + (1000-1)) / 1000; |
| 84 | 86 | ||
| 87 | /* BW = ((1 + RO) * SR/2 + 5) * 1.3 [SR in MSPS, BW in MHz] */ | ||
| 88 | /* with R0 = 0.35 and some transformations: */ | ||
| 89 | ksyms = params->u.qpsk.symbol_rate / 1000; | ||
| 90 | bandwidth = (878 * ksyms + 6500000) / 1000000 + 1; | ||
| 91 | if (bandwidth < 5) | ||
| 92 | bandwidth = 5; | ||
| 93 | else if (bandwidth > 36) | ||
| 94 | bandwidth = 36; | ||
| 95 | |||
| 85 | buf[0] = 0x00; // subaddress | 96 | buf[0] = 0x00; // subaddress |
| 86 | buf[1] = 0x09; // powerdown RSSI + the magic value 1 | 97 | buf[1] = 0x09; // powerdown RSSI + the magic value 1 |
| 87 | if (!priv->has_loopthrough) | 98 | if (!priv->has_loopthrough) |
| @@ -89,7 +100,7 @@ static int tda826x_set_params(struct dvb_frontend *fe, struct dvb_frontend_param | |||
| 89 | buf[2] = (1<<5) | 0x0b; // 1Mhz + 0.45 VCO | 100 | buf[2] = (1<<5) | 0x0b; // 1Mhz + 0.45 VCO |
| 90 | buf[3] = div >> 7; | 101 | buf[3] = div >> 7; |
| 91 | buf[4] = div << 1; | 102 | buf[4] = div << 1; |
| 92 | buf[5] = 0x77; // baseband cut-off 19 MHz | 103 | buf[5] = ((bandwidth - 5) << 3) | 7; /* baseband cut-off */ |
| 93 | buf[6] = 0xfe; // baseband gain 9 db + no RF attenuation | 104 | buf[6] = 0xfe; // baseband gain 9 db + no RF attenuation |
| 94 | buf[7] = 0x83; // charge pumps at high, tests off | 105 | buf[7] = 0x83; // charge pumps at high, tests off |
| 95 | buf[8] = 0x80; // recommended value 4 for AMPVCO + disable ports. | 106 | buf[8] = 0x80; // recommended value 4 for AMPVCO + disable ports. |
| @@ -99,7 +110,7 @@ static int tda826x_set_params(struct dvb_frontend *fe, struct dvb_frontend_param | |||
| 99 | if (fe->ops.i2c_gate_ctrl) | 110 | if (fe->ops.i2c_gate_ctrl) |
| 100 | fe->ops.i2c_gate_ctrl(fe, 1); | 111 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 101 | if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) { | 112 | if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) { |
| 102 | dprintk("%s: i2c error\n", __FUNCTION__); | 113 | dprintk("%s: i2c error\n", __func__); |
| 103 | } | 114 | } |
| 104 | if (fe->ops.i2c_gate_ctrl) | 115 | if (fe->ops.i2c_gate_ctrl) |
| 105 | fe->ops.i2c_gate_ctrl(fe, 0); | 116 | fe->ops.i2c_gate_ctrl(fe, 0); |
| @@ -138,7 +149,7 @@ struct dvb_frontend *tda826x_attach(struct dvb_frontend *fe, int addr, struct i2 | |||
| 138 | }; | 149 | }; |
| 139 | int ret; | 150 | int ret; |
| 140 | 151 | ||
| 141 | dprintk("%s:\n", __FUNCTION__); | 152 | dprintk("%s:\n", __func__); |
| 142 | 153 | ||
| 143 | if (fe->ops.i2c_gate_ctrl) | 154 | if (fe->ops.i2c_gate_ctrl) |
| 144 | fe->ops.i2c_gate_ctrl(fe, 1); | 155 | fe->ops.i2c_gate_ctrl(fe, 1); |
diff --git a/drivers/media/dvb/frontends/tda826x.h b/drivers/media/dvb/frontends/tda826x.h index ad9981195961..89e97926ab23 100644 --- a/drivers/media/dvb/frontends/tda826x.h +++ b/drivers/media/dvb/frontends/tda826x.h | |||
| @@ -45,7 +45,7 @@ static inline struct dvb_frontend* tda826x_attach(struct dvb_frontend *fe, | |||
| 45 | struct i2c_adapter *i2c, | 45 | struct i2c_adapter *i2c, |
| 46 | int has_loopthrough) | 46 | int has_loopthrough) |
| 47 | { | 47 | { |
| 48 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 48 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 49 | return NULL; | 49 | return NULL; |
| 50 | } | 50 | } |
| 51 | #endif // CONFIG_DVB_TDA826X | 51 | #endif // CONFIG_DVB_TDA826X |
diff --git a/drivers/media/dvb/frontends/tda827x.c b/drivers/media/dvb/frontends/tda827x.c index 229b11987a58..d30d2c9094d9 100644 --- a/drivers/media/dvb/frontends/tda827x.c +++ b/drivers/media/dvb/frontends/tda827x.c | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | #include "tda827x.h" | 26 | #include "tda827x.h" |
| 27 | 27 | ||
| 28 | static int debug = 0; | 28 | static int debug; |
| 29 | module_param(debug, int, 0644); | 29 | module_param(debug, int, 0644); |
| 30 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); | 30 | MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); |
| 31 | 31 | ||
| @@ -142,7 +142,7 @@ static int tda827xo_set_params(struct dvb_frontend *fe, | |||
| 142 | int i, tuner_freq, if_freq; | 142 | int i, tuner_freq, if_freq; |
| 143 | u32 N; | 143 | u32 N; |
| 144 | 144 | ||
| 145 | dprintk("%s:\n", __FUNCTION__); | 145 | dprintk("%s:\n", __func__); |
| 146 | switch (params->u.ofdm.bandwidth) { | 146 | switch (params->u.ofdm.bandwidth) { |
| 147 | case BANDWIDTH_6_MHZ: | 147 | case BANDWIDTH_6_MHZ: |
| 148 | if_freq = 4000000; | 148 | if_freq = 4000000; |
| @@ -186,7 +186,7 @@ static int tda827xo_set_params(struct dvb_frontend *fe, | |||
| 186 | fe->ops.i2c_gate_ctrl(fe, 1); | 186 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 187 | if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) { | 187 | if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) { |
| 188 | printk("%s: could not write to tuner at addr: 0x%02x\n", | 188 | printk("%s: could not write to tuner at addr: 0x%02x\n", |
| 189 | __FUNCTION__, priv->i2c_addr << 1); | 189 | __func__, priv->i2c_addr << 1); |
| 190 | return -EIO; | 190 | return -EIO; |
| 191 | } | 191 | } |
| 192 | msleep(500); | 192 | msleep(500); |
| @@ -212,7 +212,7 @@ static int tda827xo_sleep(struct dvb_frontend *fe) | |||
| 212 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, | 212 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, |
| 213 | .buf = buf, .len = sizeof(buf) }; | 213 | .buf = buf, .len = sizeof(buf) }; |
| 214 | 214 | ||
| 215 | dprintk("%s:\n", __FUNCTION__); | 215 | dprintk("%s:\n", __func__); |
| 216 | if (fe->ops.i2c_gate_ctrl) | 216 | if (fe->ops.i2c_gate_ctrl) |
| 217 | fe->ops.i2c_gate_ctrl(fe, 1); | 217 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 218 | i2c_transfer(priv->i2c_adap, &msg, 1); | 218 | i2c_transfer(priv->i2c_adap, &msg, 1); |
| @@ -389,6 +389,79 @@ static struct tda827xa_data tda827xa_analog[] = { | |||
| 389 | { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0} | 389 | { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0} |
| 390 | }; | 390 | }; |
| 391 | 391 | ||
| 392 | static int tda827xa_sleep(struct dvb_frontend *fe) | ||
| 393 | { | ||
| 394 | struct tda827x_priv *priv = fe->tuner_priv; | ||
| 395 | static u8 buf[] = { 0x30, 0x90 }; | ||
| 396 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, | ||
| 397 | .buf = buf, .len = sizeof(buf) }; | ||
| 398 | |||
| 399 | dprintk("%s:\n", __func__); | ||
| 400 | if (fe->ops.i2c_gate_ctrl) | ||
| 401 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 402 | |||
| 403 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
| 404 | |||
| 405 | if (fe->ops.i2c_gate_ctrl) | ||
| 406 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 407 | |||
| 408 | if (priv->cfg && priv->cfg->sleep) | ||
| 409 | priv->cfg->sleep(fe); | ||
| 410 | |||
| 411 | return 0; | ||
| 412 | } | ||
| 413 | |||
| 414 | static void tda827xa_lna_gain(struct dvb_frontend *fe, int high, | ||
| 415 | struct analog_parameters *params) | ||
| 416 | { | ||
| 417 | struct tda827x_priv *priv = fe->tuner_priv; | ||
| 418 | unsigned char buf[] = {0x22, 0x01}; | ||
| 419 | int arg; | ||
| 420 | int gp_func; | ||
| 421 | struct i2c_msg msg = { .addr = priv->cfg->switch_addr, .flags = 0, | ||
| 422 | .buf = buf, .len = sizeof(buf) }; | ||
| 423 | |||
| 424 | if (NULL == priv->cfg) { | ||
| 425 | dprintk("tda827x_config not defined, cannot set LNA gain!\n"); | ||
| 426 | return; | ||
| 427 | } | ||
| 428 | if (priv->cfg->config) { | ||
| 429 | if (high) | ||
| 430 | dprintk("setting LNA to high gain\n"); | ||
| 431 | else | ||
| 432 | dprintk("setting LNA to low gain\n"); | ||
| 433 | } | ||
| 434 | switch (priv->cfg->config) { | ||
| 435 | case 0: /* no LNA */ | ||
| 436 | break; | ||
| 437 | case 1: /* switch is GPIO 0 of tda8290 */ | ||
| 438 | case 2: | ||
| 439 | if (params == NULL) { | ||
| 440 | gp_func = 0; | ||
| 441 | arg = 0; | ||
| 442 | } else { | ||
| 443 | /* turn Vsync on */ | ||
| 444 | gp_func = 1; | ||
| 445 | if (params->std & V4L2_STD_MN) | ||
| 446 | arg = 1; | ||
| 447 | else | ||
| 448 | arg = 0; | ||
| 449 | } | ||
| 450 | if (priv->cfg->tuner_callback) | ||
| 451 | priv->cfg->tuner_callback(priv->i2c_adap->algo_data, | ||
| 452 | gp_func, arg); | ||
| 453 | buf[1] = high ? 0 : 1; | ||
| 454 | if (priv->cfg->config == 2) | ||
| 455 | buf[1] = high ? 1 : 0; | ||
| 456 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
| 457 | break; | ||
| 458 | case 3: /* switch with GPIO of saa713x */ | ||
| 459 | if (priv->cfg->tuner_callback) | ||
| 460 | priv->cfg->tuner_callback(priv->i2c_adap->algo_data, 0, high); | ||
| 461 | break; | ||
| 462 | } | ||
| 463 | } | ||
| 464 | |||
| 392 | static int tda827xa_set_params(struct dvb_frontend *fe, | 465 | static int tda827xa_set_params(struct dvb_frontend *fe, |
| 393 | struct dvb_frontend_parameters *params) | 466 | struct dvb_frontend_parameters *params) |
| 394 | { | 467 | { |
| @@ -401,9 +474,9 @@ static int tda827xa_set_params(struct dvb_frontend *fe, | |||
| 401 | int i, tuner_freq, if_freq; | 474 | int i, tuner_freq, if_freq; |
| 402 | u32 N; | 475 | u32 N; |
| 403 | 476 | ||
| 404 | dprintk("%s:\n", __FUNCTION__); | 477 | dprintk("%s:\n", __func__); |
| 405 | if (priv->cfg && priv->cfg->lna_gain) | 478 | |
| 406 | priv->cfg->lna_gain(fe, 1); | 479 | tda827xa_lna_gain(fe, 1, NULL); |
| 407 | msleep(20); | 480 | msleep(20); |
| 408 | 481 | ||
| 409 | switch (params->u.ofdm.bandwidth) { | 482 | switch (params->u.ofdm.bandwidth) { |
| @@ -444,7 +517,7 @@ static int tda827xa_set_params(struct dvb_frontend *fe, | |||
| 444 | fe->ops.i2c_gate_ctrl(fe, 1); | 517 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 445 | if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) { | 518 | if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) { |
| 446 | printk("%s: could not write to tuner at addr: 0x%02x\n", | 519 | printk("%s: could not write to tuner at addr: 0x%02x\n", |
| 447 | __FUNCTION__, priv->i2c_addr << 1); | 520 | __func__, priv->i2c_addr << 1); |
| 448 | return -EIO; | 521 | return -EIO; |
| 449 | } | 522 | } |
| 450 | buf[0] = 0x90; | 523 | buf[0] = 0x90; |
| @@ -474,8 +547,7 @@ static int tda827xa_set_params(struct dvb_frontend *fe, | |||
| 474 | buf[1] >>= 4; | 547 | buf[1] >>= 4; |
| 475 | dprintk("tda8275a AGC2 gain is: %d\n", buf[1]); | 548 | dprintk("tda8275a AGC2 gain is: %d\n", buf[1]); |
| 476 | if ((buf[1]) < 2) { | 549 | if ((buf[1]) < 2) { |
| 477 | if (priv->cfg && priv->cfg->lna_gain) | 550 | tda827xa_lna_gain(fe, 0, NULL); |
| 478 | priv->cfg->lna_gain(fe, 0); | ||
| 479 | buf[0] = 0x60; | 551 | buf[0] = 0x60; |
| 480 | buf[1] = 0x0c; | 552 | buf[1] = 0x0c; |
| 481 | if (fe->ops.i2c_gate_ctrl) | 553 | if (fe->ops.i2c_gate_ctrl) |
| @@ -523,75 +595,6 @@ static int tda827xa_set_params(struct dvb_frontend *fe, | |||
| 523 | return 0; | 595 | return 0; |
| 524 | } | 596 | } |
| 525 | 597 | ||
| 526 | static int tda827xa_sleep(struct dvb_frontend *fe) | ||
| 527 | { | ||
| 528 | struct tda827x_priv *priv = fe->tuner_priv; | ||
| 529 | static u8 buf[] = { 0x30, 0x90 }; | ||
| 530 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, | ||
| 531 | .buf = buf, .len = sizeof(buf) }; | ||
| 532 | |||
| 533 | dprintk("%s:\n", __FUNCTION__); | ||
| 534 | if (fe->ops.i2c_gate_ctrl) | ||
| 535 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 536 | |||
| 537 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
| 538 | |||
| 539 | if (fe->ops.i2c_gate_ctrl) | ||
| 540 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 541 | |||
| 542 | if (priv->cfg && priv->cfg->sleep) | ||
| 543 | priv->cfg->sleep(fe); | ||
| 544 | |||
| 545 | return 0; | ||
| 546 | } | ||
| 547 | |||
| 548 | /* ------------------------------------------------------------------ */ | ||
| 549 | |||
| 550 | static void tda827xa_lna_gain(struct dvb_frontend *fe, int high, | ||
| 551 | struct analog_parameters *params) | ||
| 552 | { | ||
| 553 | struct tda827x_priv *priv = fe->tuner_priv; | ||
| 554 | unsigned char buf[] = {0x22, 0x01}; | ||
| 555 | int arg; | ||
| 556 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, | ||
| 557 | .buf = buf, .len = sizeof(buf) }; | ||
| 558 | |||
| 559 | if (NULL == priv->cfg) { | ||
| 560 | dprintk("tda827x_config not defined, cannot set LNA gain!\n"); | ||
| 561 | return; | ||
| 562 | } | ||
| 563 | |||
| 564 | if (priv->cfg->config) { | ||
| 565 | if (high) | ||
| 566 | dprintk("setting LNA to high gain\n"); | ||
| 567 | else | ||
| 568 | dprintk("setting LNA to low gain\n"); | ||
| 569 | } | ||
| 570 | switch (*priv->cfg->config) { | ||
| 571 | case 0: /* no LNA */ | ||
| 572 | break; | ||
| 573 | case 1: /* switch is GPIO 0 of tda8290 */ | ||
| 574 | case 2: | ||
| 575 | /* turn Vsync on */ | ||
| 576 | if (params->std & V4L2_STD_MN) | ||
| 577 | arg = 1; | ||
| 578 | else | ||
| 579 | arg = 0; | ||
| 580 | if (priv->cfg->tuner_callback) | ||
| 581 | priv->cfg->tuner_callback(priv->i2c_adap->algo_data, | ||
| 582 | 1, arg); | ||
| 583 | buf[1] = high ? 0 : 1; | ||
| 584 | if (*priv->cfg->config == 2) | ||
| 585 | buf[1] = high ? 1 : 0; | ||
| 586 | i2c_transfer(priv->i2c_adap, &msg, 1); | ||
| 587 | break; | ||
| 588 | case 3: /* switch with GPIO of saa713x */ | ||
| 589 | if (priv->cfg->tuner_callback) | ||
| 590 | priv->cfg->tuner_callback(priv->i2c_adap->algo_data, | ||
| 591 | 0, high); | ||
| 592 | break; | ||
| 593 | } | ||
| 594 | } | ||
| 595 | 598 | ||
| 596 | static int tda827xa_set_analog_params(struct dvb_frontend *fe, | 599 | static int tda827xa_set_analog_params(struct dvb_frontend *fe, |
| 597 | struct analog_parameters *params) | 600 | struct analog_parameters *params) |
| @@ -726,7 +729,7 @@ static int tda827x_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) | |||
| 726 | static int tda827x_init(struct dvb_frontend *fe) | 729 | static int tda827x_init(struct dvb_frontend *fe) |
| 727 | { | 730 | { |
| 728 | struct tda827x_priv *priv = fe->tuner_priv; | 731 | struct tda827x_priv *priv = fe->tuner_priv; |
| 729 | dprintk("%s:\n", __FUNCTION__); | 732 | dprintk("%s:\n", __func__); |
| 730 | if (priv->cfg && priv->cfg->init) | 733 | if (priv->cfg && priv->cfg->init) |
| 731 | priv->cfg->init(fe); | 734 | priv->cfg->init(fe); |
| 732 | 735 | ||
| @@ -794,7 +797,7 @@ static int tda827x_probe_version(struct dvb_frontend *fe) | |||
| 794 | fe->ops.i2c_gate_ctrl(fe, 1); | 797 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 795 | if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) { | 798 | if (i2c_transfer(priv->i2c_adap, &msg, 1) != 1) { |
| 796 | printk("%s: could not read from tuner at addr: 0x%02x\n", | 799 | printk("%s: could not read from tuner at addr: 0x%02x\n", |
| 797 | __FUNCTION__, msg.addr << 1); | 800 | __func__, msg.addr << 1); |
| 798 | return -EIO; | 801 | return -EIO; |
| 799 | } | 802 | } |
| 800 | if ((data & 0x3c) == 0) { | 803 | if ((data & 0x3c) == 0) { |
| @@ -818,7 +821,7 @@ struct dvb_frontend *tda827x_attach(struct dvb_frontend *fe, int addr, | |||
| 818 | { | 821 | { |
| 819 | struct tda827x_priv *priv = NULL; | 822 | struct tda827x_priv *priv = NULL; |
| 820 | 823 | ||
| 821 | dprintk("%s:\n", __FUNCTION__); | 824 | dprintk("%s:\n", __func__); |
| 822 | priv = kzalloc(sizeof(struct tda827x_priv), GFP_KERNEL); | 825 | priv = kzalloc(sizeof(struct tda827x_priv), GFP_KERNEL); |
| 823 | if (priv == NULL) | 826 | if (priv == NULL) |
| 824 | return NULL; | 827 | return NULL; |
diff --git a/drivers/media/dvb/frontends/tda827x.h b/drivers/media/dvb/frontends/tda827x.h index 92eb65b4012b..b73c23570dab 100644 --- a/drivers/media/dvb/frontends/tda827x.h +++ b/drivers/media/dvb/frontends/tda827x.h | |||
| @@ -30,12 +30,12 @@ | |||
| 30 | struct tda827x_config | 30 | struct tda827x_config |
| 31 | { | 31 | { |
| 32 | /* saa7134 - provided callbacks */ | 32 | /* saa7134 - provided callbacks */ |
| 33 | void (*lna_gain) (struct dvb_frontend *fe, int high); | ||
| 34 | int (*init) (struct dvb_frontend *fe); | 33 | int (*init) (struct dvb_frontend *fe); |
| 35 | int (*sleep) (struct dvb_frontend *fe); | 34 | int (*sleep) (struct dvb_frontend *fe); |
| 36 | 35 | ||
| 37 | /* interface to tda829x driver */ | 36 | /* interface to tda829x driver */ |
| 38 | unsigned int *config; | 37 | unsigned int config; |
| 38 | int switch_addr; | ||
| 39 | int (*tuner_callback) (void *dev, int command, int arg); | 39 | int (*tuner_callback) (void *dev, int command, int arg); |
| 40 | 40 | ||
| 41 | void (*agcf)(struct dvb_frontend *fe); | 41 | void (*agcf)(struct dvb_frontend *fe); |
| @@ -61,7 +61,7 @@ static inline struct dvb_frontend* tda827x_attach(struct dvb_frontend *fe, | |||
| 61 | struct i2c_adapter *i2c, | 61 | struct i2c_adapter *i2c, |
| 62 | struct tda827x_config *cfg) | 62 | struct tda827x_config *cfg) |
| 63 | { | 63 | { |
| 64 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 64 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 65 | return NULL; | 65 | return NULL; |
| 66 | } | 66 | } |
| 67 | #endif // CONFIG_DVB_TDA827X | 67 | #endif // CONFIG_DVB_TDA827X |
diff --git a/drivers/media/dvb/frontends/tua6100.c b/drivers/media/dvb/frontends/tua6100.c index 6ba0029dcf2e..1790baee014c 100644 --- a/drivers/media/dvb/frontends/tua6100.c +++ b/drivers/media/dvb/frontends/tua6100.c | |||
| @@ -58,7 +58,7 @@ static int tua6100_sleep(struct dvb_frontend *fe) | |||
| 58 | if (fe->ops.i2c_gate_ctrl) | 58 | if (fe->ops.i2c_gate_ctrl) |
| 59 | fe->ops.i2c_gate_ctrl(fe, 1); | 59 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 60 | if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) { | 60 | if ((ret = i2c_transfer (priv->i2c, &msg, 1)) != 1) { |
| 61 | printk("%s: i2c error\n", __FUNCTION__); | 61 | printk("%s: i2c error\n", __func__); |
| 62 | } | 62 | } |
| 63 | if (fe->ops.i2c_gate_ctrl) | 63 | if (fe->ops.i2c_gate_ctrl) |
| 64 | fe->ops.i2c_gate_ctrl(fe, 0); | 64 | fe->ops.i2c_gate_ctrl(fe, 0); |
diff --git a/drivers/media/dvb/frontends/tua6100.h b/drivers/media/dvb/frontends/tua6100.h index 03a665e7df6d..f83dbd5e42ae 100644 --- a/drivers/media/dvb/frontends/tua6100.h +++ b/drivers/media/dvb/frontends/tua6100.h | |||
| @@ -39,7 +39,7 @@ extern struct dvb_frontend *tua6100_attach(struct dvb_frontend *fe, int addr, st | |||
| 39 | #else | 39 | #else |
| 40 | static inline struct dvb_frontend* tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c) | 40 | static inline struct dvb_frontend* tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c) |
| 41 | { | 41 | { |
| 42 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 42 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 43 | return NULL; | 43 | return NULL; |
| 44 | } | 44 | } |
| 45 | #endif // CONFIG_DVB_TUA6100 | 45 | #endif // CONFIG_DVB_TUA6100 |
diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c index 8791701c8f25..a184597f1d9b 100644 --- a/drivers/media/dvb/frontends/ves1820.c +++ b/drivers/media/dvb/frontends/ves1820.c | |||
| @@ -66,7 +66,7 @@ static int ves1820_writereg(struct ves1820_state *state, u8 reg, u8 data) | |||
| 66 | 66 | ||
| 67 | if (ret != 1) | 67 | if (ret != 1) |
| 68 | printk("ves1820: %s(): writereg error (reg == 0x%02x, " | 68 | printk("ves1820: %s(): writereg error (reg == 0x%02x, " |
| 69 | "val == 0x%02x, ret == %i)\n", __FUNCTION__, reg, data, ret); | 69 | "val == 0x%02x, ret == %i)\n", __func__, reg, data, ret); |
| 70 | 70 | ||
| 71 | return (ret != 1) ? -EREMOTEIO : 0; | 71 | return (ret != 1) ? -EREMOTEIO : 0; |
| 72 | } | 72 | } |
| @@ -85,7 +85,7 @@ static u8 ves1820_readreg(struct ves1820_state *state, u8 reg) | |||
| 85 | 85 | ||
| 86 | if (ret != 2) | 86 | if (ret != 2) |
| 87 | printk("ves1820: %s(): readreg error (reg == 0x%02x, " | 87 | printk("ves1820: %s(): readreg error (reg == 0x%02x, " |
| 88 | "ret == %i)\n", __FUNCTION__, reg, ret); | 88 | "ret == %i)\n", __func__, reg, ret); |
| 89 | 89 | ||
| 90 | return b1[0]; | 90 | return b1[0]; |
| 91 | } | 91 | } |
diff --git a/drivers/media/dvb/frontends/ves1820.h b/drivers/media/dvb/frontends/ves1820.h index e4a2a324046a..e902ed634ec3 100644 --- a/drivers/media/dvb/frontends/ves1820.h +++ b/drivers/media/dvb/frontends/ves1820.h | |||
| @@ -48,7 +48,7 @@ extern struct dvb_frontend* ves1820_attach(const struct ves1820_config* config, | |||
| 48 | static inline struct dvb_frontend* ves1820_attach(const struct ves1820_config* config, | 48 | static inline struct dvb_frontend* ves1820_attach(const struct ves1820_config* config, |
| 49 | struct i2c_adapter* i2c, u8 pwm) | 49 | struct i2c_adapter* i2c, u8 pwm) |
| 50 | { | 50 | { |
| 51 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 51 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 52 | return NULL; | 52 | return NULL; |
| 53 | } | 53 | } |
| 54 | #endif // CONFIG_DVB_VES1820 | 54 | #endif // CONFIG_DVB_VES1820 |
diff --git a/drivers/media/dvb/frontends/ves1x93.c b/drivers/media/dvb/frontends/ves1x93.c index 23fd0303c91b..bd558960bd87 100644 --- a/drivers/media/dvb/frontends/ves1x93.c +++ b/drivers/media/dvb/frontends/ves1x93.c | |||
| @@ -48,7 +48,7 @@ struct ves1x93_state { | |||
| 48 | u8 demod_type; | 48 | u8 demod_type; |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | static int debug = 0; | 51 | static int debug; |
| 52 | #define dprintk if (debug) printk | 52 | #define dprintk if (debug) printk |
| 53 | 53 | ||
| 54 | #define DEMOD_VES1893 0 | 54 | #define DEMOD_VES1893 0 |
| @@ -98,7 +98,7 @@ static int ves1x93_writereg (struct ves1x93_state* state, u8 reg, u8 data) | |||
| 98 | int err; | 98 | int err; |
| 99 | 99 | ||
| 100 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { | 100 | if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { |
| 101 | dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data); | 101 | dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __func__, err, reg, data); |
| 102 | return -EREMOTEIO; | 102 | return -EREMOTEIO; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| @@ -179,7 +179,7 @@ static int ves1x93_set_symbolrate (struct ves1x93_state* state, u32 srate) | |||
| 179 | u32 tmp; | 179 | u32 tmp; |
| 180 | u32 FIN; | 180 | u32 FIN; |
| 181 | 181 | ||
| 182 | dprintk("%s: srate == %d\n", __FUNCTION__, (unsigned int) srate); | 182 | dprintk("%s: srate == %d\n", __func__, (unsigned int) srate); |
| 183 | 183 | ||
| 184 | if (srate > state->config->xin/2) | 184 | if (srate > state->config->xin/2) |
| 185 | srate = state->config->xin/2; | 185 | srate = state->config->xin/2; |
| @@ -266,7 +266,7 @@ static int ves1x93_init (struct dvb_frontend* fe) | |||
| 266 | int i; | 266 | int i; |
| 267 | int val; | 267 | int val; |
| 268 | 268 | ||
| 269 | dprintk("%s: init chip\n", __FUNCTION__); | 269 | dprintk("%s: init chip\n", __func__); |
| 270 | 270 | ||
| 271 | for (i = 0; i < state->tab_size; i++) { | 271 | for (i = 0; i < state->tab_size; i++) { |
| 272 | if (state->init_1x93_wtab[i]) { | 272 | if (state->init_1x93_wtab[i]) { |
diff --git a/drivers/media/dvb/frontends/ves1x93.h b/drivers/media/dvb/frontends/ves1x93.h index d507f8966f81..8a5a49e808f6 100644 --- a/drivers/media/dvb/frontends/ves1x93.h +++ b/drivers/media/dvb/frontends/ves1x93.h | |||
| @@ -47,7 +47,7 @@ extern struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config, | |||
| 47 | static inline struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config, | 47 | static inline struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config, |
| 48 | struct i2c_adapter* i2c) | 48 | struct i2c_adapter* i2c) |
| 49 | { | 49 | { |
| 50 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 50 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 51 | return NULL; | 51 | return NULL; |
| 52 | } | 52 | } |
| 53 | #endif // CONFIG_DVB_VES1X93 | 53 | #endif // CONFIG_DVB_VES1X93 |
diff --git a/drivers/media/dvb/frontends/xc5000.c b/drivers/media/dvb/frontends/xc5000.c index f642ca200b59..43d35bdb221f 100644 --- a/drivers/media/dvb/frontends/xc5000.c +++ b/drivers/media/dvb/frontends/xc5000.c | |||
| @@ -151,7 +151,7 @@ typedef struct { | |||
| 151 | #define FM_Radio_INPUT2 21 | 151 | #define FM_Radio_INPUT2 21 |
| 152 | #define FM_Radio_INPUT1 22 | 152 | #define FM_Radio_INPUT1 22 |
| 153 | 153 | ||
| 154 | XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = { | 154 | static XC_TV_STANDARD XC5000_Standard[MAX_TV_STANDARD] = { |
| 155 | {"M/N-NTSC/PAL-BTSC", 0x0400, 0x8020}, | 155 | {"M/N-NTSC/PAL-BTSC", 0x0400, 0x8020}, |
| 156 | {"M/N-NTSC/PAL-A2", 0x0600, 0x8020}, | 156 | {"M/N-NTSC/PAL-A2", 0x0600, 0x8020}, |
| 157 | {"M/N-NTSC/PAL-EIAJ", 0x0440, 0x8020}, | 157 | {"M/N-NTSC/PAL-EIAJ", 0x0440, 0x8020}, |
| @@ -209,7 +209,7 @@ static void xc5000_TunerReset(struct dvb_frontend *fe) | |||
| 209 | struct xc5000_priv *priv = fe->tuner_priv; | 209 | struct xc5000_priv *priv = fe->tuner_priv; |
| 210 | int ret; | 210 | int ret; |
| 211 | 211 | ||
| 212 | dprintk(1, "%s()\n", __FUNCTION__); | 212 | dprintk(1, "%s()\n", __func__); |
| 213 | 213 | ||
| 214 | if (priv->cfg->tuner_callback) { | 214 | if (priv->cfg->tuner_callback) { |
| 215 | ret = priv->cfg->tuner_callback(priv->cfg->priv, | 215 | ret = priv->cfg->tuner_callback(priv->cfg->priv, |
| @@ -330,7 +330,7 @@ static int xc_load_i2c_sequence(struct dvb_frontend *fe, u8 i2c_sequence[]) | |||
| 330 | 330 | ||
| 331 | static int xc_initialize(struct xc5000_priv *priv) | 331 | static int xc_initialize(struct xc5000_priv *priv) |
| 332 | { | 332 | { |
| 333 | dprintk(1, "%s()\n", __FUNCTION__); | 333 | dprintk(1, "%s()\n", __func__); |
| 334 | return xc_write_reg(priv, XREG_INIT, 0); | 334 | return xc_write_reg(priv, XREG_INIT, 0); |
| 335 | } | 335 | } |
| 336 | 336 | ||
| @@ -338,9 +338,9 @@ static int xc_SetTVStandard(struct xc5000_priv *priv, | |||
| 338 | u16 VideoMode, u16 AudioMode) | 338 | u16 VideoMode, u16 AudioMode) |
| 339 | { | 339 | { |
| 340 | int ret; | 340 | int ret; |
| 341 | dprintk(1, "%s(0x%04x,0x%04x)\n", __FUNCTION__, VideoMode, AudioMode); | 341 | dprintk(1, "%s(0x%04x,0x%04x)\n", __func__, VideoMode, AudioMode); |
| 342 | dprintk(1, "%s() Standard = %s\n", | 342 | dprintk(1, "%s() Standard = %s\n", |
| 343 | __FUNCTION__, | 343 | __func__, |
| 344 | XC5000_Standard[priv->video_standard].Name); | 344 | XC5000_Standard[priv->video_standard].Name); |
| 345 | 345 | ||
| 346 | ret = xc_write_reg(priv, XREG_VIDEO_MODE, VideoMode); | 346 | ret = xc_write_reg(priv, XREG_VIDEO_MODE, VideoMode); |
| @@ -361,7 +361,7 @@ static int xc_shutdown(struct xc5000_priv *priv) | |||
| 361 | 361 | ||
| 362 | static int xc_SetSignalSource(struct xc5000_priv *priv, u16 rf_mode) | 362 | static int xc_SetSignalSource(struct xc5000_priv *priv, u16 rf_mode) |
| 363 | { | 363 | { |
| 364 | dprintk(1, "%s(%d) Source = %s\n", __FUNCTION__, rf_mode, | 364 | dprintk(1, "%s(%d) Source = %s\n", __func__, rf_mode, |
| 365 | rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE"); | 365 | rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE"); |
| 366 | 366 | ||
| 367 | if ((rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE)) | 367 | if ((rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE)) |
| @@ -369,7 +369,7 @@ static int xc_SetSignalSource(struct xc5000_priv *priv, u16 rf_mode) | |||
| 369 | rf_mode = XC_RF_MODE_CABLE; | 369 | rf_mode = XC_RF_MODE_CABLE; |
| 370 | printk(KERN_ERR | 370 | printk(KERN_ERR |
| 371 | "%s(), Invalid mode, defaulting to CABLE", | 371 | "%s(), Invalid mode, defaulting to CABLE", |
| 372 | __FUNCTION__); | 372 | __func__); |
| 373 | } | 373 | } |
| 374 | return xc_write_reg(priv, XREG_SIGNALSOURCE, rf_mode); | 374 | return xc_write_reg(priv, XREG_SIGNALSOURCE, rf_mode); |
| 375 | } | 375 | } |
| @@ -380,7 +380,7 @@ static int xc_set_RF_frequency(struct xc5000_priv *priv, u32 freq_hz) | |||
| 380 | { | 380 | { |
| 381 | u16 freq_code; | 381 | u16 freq_code; |
| 382 | 382 | ||
| 383 | dprintk(1, "%s(%u)\n", __FUNCTION__, freq_hz); | 383 | dprintk(1, "%s(%u)\n", __func__, freq_hz); |
| 384 | 384 | ||
| 385 | if ((freq_hz > xc5000_tuner_ops.info.frequency_max) || | 385 | if ((freq_hz > xc5000_tuner_ops.info.frequency_max) || |
| 386 | (freq_hz < xc5000_tuner_ops.info.frequency_min)) | 386 | (freq_hz < xc5000_tuner_ops.info.frequency_min)) |
| @@ -396,7 +396,7 @@ static int xc_set_IF_frequency(struct xc5000_priv *priv, u32 freq_khz) | |||
| 396 | { | 396 | { |
| 397 | u32 freq_code = (freq_khz * 1024)/1000; | 397 | u32 freq_code = (freq_khz * 1024)/1000; |
| 398 | dprintk(1, "%s(freq_khz = %d) freq_code = 0x%x\n", | 398 | dprintk(1, "%s(freq_khz = %d) freq_code = 0x%x\n", |
| 399 | __FUNCTION__, freq_khz, freq_code); | 399 | __func__, freq_khz, freq_code); |
| 400 | 400 | ||
| 401 | return xc_write_reg(priv, XREG_IF_OUT, freq_code); | 401 | return xc_write_reg(priv, XREG_IF_OUT, freq_code); |
| 402 | } | 402 | } |
| @@ -488,7 +488,7 @@ static int xc_tune_channel(struct xc5000_priv *priv, u32 freq_hz) | |||
| 488 | { | 488 | { |
| 489 | int found = 0; | 489 | int found = 0; |
| 490 | 490 | ||
| 491 | dprintk(1, "%s(%u)\n", __FUNCTION__, freq_hz); | 491 | dprintk(1, "%s(%u)\n", __func__, freq_hz); |
| 492 | 492 | ||
| 493 | if (xc_set_RF_frequency(priv, freq_hz) != XC_RESULT_SUCCESS) | 493 | if (xc_set_RF_frequency(priv, freq_hz) != XC_RESULT_SUCCESS) |
| 494 | return 0; | 494 | return 0; |
| @@ -627,12 +627,12 @@ static int xc5000_set_params(struct dvb_frontend *fe, | |||
| 627 | struct xc5000_priv *priv = fe->tuner_priv; | 627 | struct xc5000_priv *priv = fe->tuner_priv; |
| 628 | int ret; | 628 | int ret; |
| 629 | 629 | ||
| 630 | dprintk(1, "%s() frequency=%d (Hz)\n", __FUNCTION__, params->frequency); | 630 | dprintk(1, "%s() frequency=%d (Hz)\n", __func__, params->frequency); |
| 631 | 631 | ||
| 632 | switch(params->u.vsb.modulation) { | 632 | switch(params->u.vsb.modulation) { |
| 633 | case VSB_8: | 633 | case VSB_8: |
| 634 | case VSB_16: | 634 | case VSB_16: |
| 635 | dprintk(1, "%s() VSB modulation\n", __FUNCTION__); | 635 | dprintk(1, "%s() VSB modulation\n", __func__); |
| 636 | priv->rf_mode = XC_RF_MODE_AIR; | 636 | priv->rf_mode = XC_RF_MODE_AIR; |
| 637 | priv->freq_hz = params->frequency - 1750000; | 637 | priv->freq_hz = params->frequency - 1750000; |
| 638 | priv->bandwidth = BANDWIDTH_6_MHZ; | 638 | priv->bandwidth = BANDWIDTH_6_MHZ; |
| @@ -641,7 +641,7 @@ static int xc5000_set_params(struct dvb_frontend *fe, | |||
| 641 | case QAM_64: | 641 | case QAM_64: |
| 642 | case QAM_256: | 642 | case QAM_256: |
| 643 | case QAM_AUTO: | 643 | case QAM_AUTO: |
| 644 | dprintk(1, "%s() QAM modulation\n", __FUNCTION__); | 644 | dprintk(1, "%s() QAM modulation\n", __func__); |
| 645 | priv->rf_mode = XC_RF_MODE_CABLE; | 645 | priv->rf_mode = XC_RF_MODE_CABLE; |
| 646 | priv->freq_hz = params->frequency - 1750000; | 646 | priv->freq_hz = params->frequency - 1750000; |
| 647 | priv->bandwidth = BANDWIDTH_6_MHZ; | 647 | priv->bandwidth = BANDWIDTH_6_MHZ; |
| @@ -652,7 +652,7 @@ static int xc5000_set_params(struct dvb_frontend *fe, | |||
| 652 | } | 652 | } |
| 653 | 653 | ||
| 654 | dprintk(1, "%s() frequency=%d (compensated)\n", | 654 | dprintk(1, "%s() frequency=%d (compensated)\n", |
| 655 | __FUNCTION__, priv->freq_hz); | 655 | __func__, priv->freq_hz); |
| 656 | 656 | ||
| 657 | ret = xc_SetSignalSource(priv, priv->rf_mode); | 657 | ret = xc_SetSignalSource(priv, priv->rf_mode); |
| 658 | if (ret != XC_RESULT_SUCCESS) { | 658 | if (ret != XC_RESULT_SUCCESS) { |
| @@ -697,7 +697,7 @@ static int xc5000_set_analog_params(struct dvb_frontend *fe, | |||
| 697 | xc_load_fw_and_init_tuner(fe); | 697 | xc_load_fw_and_init_tuner(fe); |
| 698 | 698 | ||
| 699 | dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n", | 699 | dprintk(1, "%s() frequency=%d (in units of 62.5khz)\n", |
| 700 | __FUNCTION__, params->frequency); | 700 | __func__, params->frequency); |
| 701 | 701 | ||
| 702 | priv->rf_mode = XC_RF_MODE_CABLE; /* Fix me: it could be air. */ | 702 | priv->rf_mode = XC_RF_MODE_CABLE; /* Fix me: it could be air. */ |
| 703 | 703 | ||
| @@ -775,7 +775,7 @@ tune_channel: | |||
| 775 | static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq) | 775 | static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq) |
| 776 | { | 776 | { |
| 777 | struct xc5000_priv *priv = fe->tuner_priv; | 777 | struct xc5000_priv *priv = fe->tuner_priv; |
| 778 | dprintk(1, "%s()\n", __FUNCTION__); | 778 | dprintk(1, "%s()\n", __func__); |
| 779 | *freq = priv->freq_hz; | 779 | *freq = priv->freq_hz; |
| 780 | return 0; | 780 | return 0; |
| 781 | } | 781 | } |
| @@ -783,7 +783,7 @@ static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq) | |||
| 783 | static int xc5000_get_bandwidth(struct dvb_frontend *fe, u32 *bw) | 783 | static int xc5000_get_bandwidth(struct dvb_frontend *fe, u32 *bw) |
| 784 | { | 784 | { |
| 785 | struct xc5000_priv *priv = fe->tuner_priv; | 785 | struct xc5000_priv *priv = fe->tuner_priv; |
| 786 | dprintk(1, "%s()\n", __FUNCTION__); | 786 | dprintk(1, "%s()\n", __func__); |
| 787 | 787 | ||
| 788 | *bw = priv->bandwidth; | 788 | *bw = priv->bandwidth; |
| 789 | return 0; | 789 | return 0; |
| @@ -796,7 +796,7 @@ static int xc5000_get_status(struct dvb_frontend *fe, u32 *status) | |||
| 796 | 796 | ||
| 797 | xc_get_lock_status(priv, &lock_status); | 797 | xc_get_lock_status(priv, &lock_status); |
| 798 | 798 | ||
| 799 | dprintk(1, "%s() lock_status = 0x%08x\n", __FUNCTION__, lock_status); | 799 | dprintk(1, "%s() lock_status = 0x%08x\n", __func__, lock_status); |
| 800 | 800 | ||
| 801 | *status = lock_status; | 801 | *status = lock_status; |
| 802 | 802 | ||
| @@ -836,7 +836,7 @@ static int xc5000_sleep(struct dvb_frontend *fe) | |||
| 836 | struct xc5000_priv *priv = fe->tuner_priv; | 836 | struct xc5000_priv *priv = fe->tuner_priv; |
| 837 | int ret; | 837 | int ret; |
| 838 | 838 | ||
| 839 | dprintk(1, "%s()\n", __FUNCTION__); | 839 | dprintk(1, "%s()\n", __func__); |
| 840 | 840 | ||
| 841 | /* On Pinnacle PCTV HD 800i, the tuner cannot be reinitialized | 841 | /* On Pinnacle PCTV HD 800i, the tuner cannot be reinitialized |
| 842 | * once shutdown without reloading the driver. Maybe I am not | 842 | * once shutdown without reloading the driver. Maybe I am not |
| @@ -848,7 +848,7 @@ static int xc5000_sleep(struct dvb_frontend *fe) | |||
| 848 | if(ret != XC_RESULT_SUCCESS) { | 848 | if(ret != XC_RESULT_SUCCESS) { |
| 849 | printk(KERN_ERR | 849 | printk(KERN_ERR |
| 850 | "xc5000: %s() unable to shutdown tuner\n", | 850 | "xc5000: %s() unable to shutdown tuner\n", |
| 851 | __FUNCTION__); | 851 | __func__); |
| 852 | return -EREMOTEIO; | 852 | return -EREMOTEIO; |
| 853 | } | 853 | } |
| 854 | else { | 854 | else { |
| @@ -860,7 +860,7 @@ static int xc5000_sleep(struct dvb_frontend *fe) | |||
| 860 | static int xc5000_init(struct dvb_frontend *fe) | 860 | static int xc5000_init(struct dvb_frontend *fe) |
| 861 | { | 861 | { |
| 862 | struct xc5000_priv *priv = fe->tuner_priv; | 862 | struct xc5000_priv *priv = fe->tuner_priv; |
| 863 | dprintk(1, "%s()\n", __FUNCTION__); | 863 | dprintk(1, "%s()\n", __func__); |
| 864 | 864 | ||
| 865 | if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) { | 865 | if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) { |
| 866 | printk(KERN_ERR "xc5000: Unable to initialise tuner\n"); | 866 | printk(KERN_ERR "xc5000: Unable to initialise tuner\n"); |
| @@ -875,7 +875,7 @@ static int xc5000_init(struct dvb_frontend *fe) | |||
| 875 | 875 | ||
| 876 | static int xc5000_release(struct dvb_frontend *fe) | 876 | static int xc5000_release(struct dvb_frontend *fe) |
| 877 | { | 877 | { |
| 878 | dprintk(1, "%s()\n", __FUNCTION__); | 878 | dprintk(1, "%s()\n", __func__); |
| 879 | kfree(fe->tuner_priv); | 879 | kfree(fe->tuner_priv); |
| 880 | fe->tuner_priv = NULL; | 880 | fe->tuner_priv = NULL; |
| 881 | return 0; | 881 | return 0; |
| @@ -907,7 +907,7 @@ struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe, | |||
| 907 | struct xc5000_priv *priv = NULL; | 907 | struct xc5000_priv *priv = NULL; |
| 908 | u16 id = 0; | 908 | u16 id = 0; |
| 909 | 909 | ||
| 910 | dprintk(1, "%s()\n", __FUNCTION__); | 910 | dprintk(1, "%s()\n", __func__); |
| 911 | 911 | ||
| 912 | priv = kzalloc(sizeof(struct xc5000_priv), GFP_KERNEL); | 912 | priv = kzalloc(sizeof(struct xc5000_priv), GFP_KERNEL); |
| 913 | if (priv == NULL) | 913 | if (priv == NULL) |
diff --git a/drivers/media/dvb/frontends/xc5000.h b/drivers/media/dvb/frontends/xc5000.h index 32a5f1c86a16..b890883a0cdc 100644 --- a/drivers/media/dvb/frontends/xc5000.h +++ b/drivers/media/dvb/frontends/xc5000.h | |||
| @@ -55,7 +55,7 @@ static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, | |||
| 55 | struct i2c_adapter *i2c, | 55 | struct i2c_adapter *i2c, |
| 56 | struct xc5000_config *cfg) | 56 | struct xc5000_config *cfg) |
| 57 | { | 57 | { |
| 58 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 58 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 59 | return NULL; | 59 | return NULL; |
| 60 | } | 60 | } |
| 61 | #endif // CONFIG_DVB_TUNER_XC5000 | 61 | #endif // CONFIG_DVB_TUNER_XC5000 |
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c index 276e3b631dc2..36a5a1c101d5 100644 --- a/drivers/media/dvb/frontends/zl10353.c +++ b/drivers/media/dvb/frontends/zl10353.c | |||
| @@ -46,7 +46,7 @@ static int debug; | |||
| 46 | if (debug) printk(KERN_DEBUG "zl10353: " args); \ | 46 | if (debug) printk(KERN_DEBUG "zl10353: " args); \ |
| 47 | } while (0) | 47 | } while (0) |
| 48 | 48 | ||
| 49 | static int debug_regs = 0; | 49 | static int debug_regs; |
| 50 | 50 | ||
| 51 | static int zl10353_single_write(struct dvb_frontend *fe, u8 reg, u8 val) | 51 | static int zl10353_single_write(struct dvb_frontend *fe, u8 reg, u8 val) |
| 52 | { | 52 | { |
| @@ -88,7 +88,7 @@ static int zl10353_read_register(struct zl10353_state *state, u8 reg) | |||
| 88 | 88 | ||
| 89 | if (ret != 2) { | 89 | if (ret != 2) { |
| 90 | printk("%s: readreg error (reg=%d, ret==%i)\n", | 90 | printk("%s: readreg error (reg=%d, ret==%i)\n", |
| 91 | __FUNCTION__, reg, ret); | 91 | __func__, reg, ret); |
| 92 | return ret; | 92 | return ret; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| @@ -152,7 +152,7 @@ static void zl10353_calc_nominal_rate(struct dvb_frontend *fe, | |||
| 152 | *nominal_rate = value; | 152 | *nominal_rate = value; |
| 153 | 153 | ||
| 154 | dprintk("%s: bw %d, adc_clock %d => 0x%x\n", | 154 | dprintk("%s: bw %d, adc_clock %d => 0x%x\n", |
| 155 | __FUNCTION__, bw, adc_clock, *nominal_rate); | 155 | __func__, bw, adc_clock, *nominal_rate); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | static void zl10353_calc_input_freq(struct dvb_frontend *fe, | 158 | static void zl10353_calc_input_freq(struct dvb_frontend *fe, |
| @@ -181,7 +181,7 @@ static void zl10353_calc_input_freq(struct dvb_frontend *fe, | |||
| 181 | *input_freq = -value; | 181 | *input_freq = -value; |
| 182 | 182 | ||
| 183 | dprintk("%s: if2 %d, ife %d, adc_clock %d => %d / 0x%x\n", | 183 | dprintk("%s: if2 %d, ife %d, adc_clock %d => %d / 0x%x\n", |
| 184 | __FUNCTION__, if2, ife, adc_clock, -(int)value, *input_freq); | 184 | __func__, if2, ife, adc_clock, -(int)value, *input_freq); |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | static int zl10353_sleep(struct dvb_frontend *fe) | 187 | static int zl10353_sleep(struct dvb_frontend *fe) |
diff --git a/drivers/media/dvb/frontends/zl10353.h b/drivers/media/dvb/frontends/zl10353.h index fc734c22b5fa..fdbb88ff75fe 100644 --- a/drivers/media/dvb/frontends/zl10353.h +++ b/drivers/media/dvb/frontends/zl10353.h | |||
| @@ -47,7 +47,7 @@ extern struct dvb_frontend* zl10353_attach(const struct zl10353_config *config, | |||
| 47 | static inline struct dvb_frontend* zl10353_attach(const struct zl10353_config *config, | 47 | static inline struct dvb_frontend* zl10353_attach(const struct zl10353_config *config, |
| 48 | struct i2c_adapter *i2c) | 48 | struct i2c_adapter *i2c) |
| 49 | { | 49 | { |
| 50 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 50 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 51 | return NULL; | 51 | return NULL; |
| 52 | } | 52 | } |
| 53 | #endif /* CONFIG_DVB_ZL10353 */ | 53 | #endif /* CONFIG_DVB_ZL10353 */ |
diff --git a/drivers/media/dvb/pluto2/pluto2.c b/drivers/media/dvb/pluto2/pluto2.c index 08a2599ed74a..960ed5763ae1 100644 --- a/drivers/media/dvb/pluto2/pluto2.c +++ b/drivers/media/dvb/pluto2/pluto2.c | |||
| @@ -39,6 +39,8 @@ | |||
| 39 | #include "dvbdev.h" | 39 | #include "dvbdev.h" |
| 40 | #include "tda1004x.h" | 40 | #include "tda1004x.h" |
| 41 | 41 | ||
| 42 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 43 | |||
| 42 | #define DRIVER_NAME "pluto2" | 44 | #define DRIVER_NAME "pluto2" |
| 43 | 45 | ||
| 44 | #define REG_PIDn(n) ((n) << 2) /* PID n pattern registers */ | 46 | #define REG_PIDn(n) ((n) << 2) /* PID n pattern registers */ |
| @@ -662,7 +664,8 @@ static int __devinit pluto2_probe(struct pci_dev *pdev, | |||
| 662 | goto err_pluto_hw_exit; | 664 | goto err_pluto_hw_exit; |
| 663 | 665 | ||
| 664 | /* dvb */ | 666 | /* dvb */ |
| 665 | ret = dvb_register_adapter(&pluto->dvb_adapter, DRIVER_NAME, THIS_MODULE, &pdev->dev); | 667 | ret = dvb_register_adapter(&pluto->dvb_adapter, DRIVER_NAME, |
| 668 | THIS_MODULE, &pdev->dev, adapter_nr); | ||
| 666 | if (ret < 0) | 669 | if (ret < 0) |
| 667 | goto err_i2c_del_adapter; | 670 | goto err_i2c_del_adapter; |
| 668 | 671 | ||
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c index 0e5701bdff19..747e7f1a6267 100644 --- a/drivers/media/dvb/ttpci/av7110.c +++ b/drivers/media/dvb/ttpci/av7110.c | |||
| @@ -112,6 +112,8 @@ MODULE_PARM_DESC(wss_cfg_16_9, "WSS 16:9 - default 0x0007 - bit 15: disable, 14: | |||
| 112 | module_param(tv_standard, int, 0444); | 112 | module_param(tv_standard, int, 0444); |
| 113 | MODULE_PARM_DESC(tv_standard, "TV standard: 0 PAL (default), 1 NTSC"); | 113 | MODULE_PARM_DESC(tv_standard, "TV standard: 0 PAL (default), 1 NTSC"); |
| 114 | 114 | ||
| 115 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 116 | |||
| 115 | static void restart_feeds(struct av7110 *av7110); | 117 | static void restart_feeds(struct av7110 *av7110); |
| 116 | 118 | ||
| 117 | static int av7110_num; | 119 | static int av7110_num; |
| @@ -359,7 +361,7 @@ static inline void start_debi_dma(struct av7110 *av7110, int dir, | |||
| 359 | { | 361 | { |
| 360 | dprintk(8, "%c %08lx %u\n", dir == DEBI_READ ? 'R' : 'W', addr, len); | 362 | dprintk(8, "%c %08lx %u\n", dir == DEBI_READ ? 'R' : 'W', addr, len); |
| 361 | if (saa7146_wait_for_debi_done(av7110->dev, 0)) { | 363 | if (saa7146_wait_for_debi_done(av7110->dev, 0)) { |
| 362 | printk(KERN_ERR "%s: saa7146_wait_for_debi_done timed out\n", __FUNCTION__); | 364 | printk(KERN_ERR "%s: saa7146_wait_for_debi_done timed out\n", __func__); |
| 363 | return; | 365 | return; |
| 364 | } | 366 | } |
| 365 | 367 | ||
| @@ -497,7 +499,7 @@ static void gpioirq(unsigned long data) | |||
| 497 | saa7146_read(av7110->dev, SSR)); | 499 | saa7146_read(av7110->dev, SSR)); |
| 498 | 500 | ||
| 499 | if (saa7146_wait_for_debi_done(av7110->dev, 0)) { | 501 | if (saa7146_wait_for_debi_done(av7110->dev, 0)) { |
| 500 | printk(KERN_ERR "%s: saa7146_wait_for_debi_done timed out\n", __FUNCTION__); | 502 | printk(KERN_ERR "%s: saa7146_wait_for_debi_done timed out\n", __func__); |
| 501 | BUG(); /* maybe we should try resetting the debi? */ | 503 | BUG(); /* maybe we should try resetting the debi? */ |
| 502 | } | 504 | } |
| 503 | 505 | ||
| @@ -827,7 +829,7 @@ static int StartHWFilter(struct dvb_demux_filter *dvbdmxfilter) | |||
| 827 | if (ret != 0 || handle >= 32) { | 829 | if (ret != 0 || handle >= 32) { |
| 828 | printk("dvb-ttpci: %s error buf %04x %04x %04x %04x " | 830 | printk("dvb-ttpci: %s error buf %04x %04x %04x %04x " |
| 829 | "ret %d handle %04x\n", | 831 | "ret %d handle %04x\n", |
| 830 | __FUNCTION__, buf[0], buf[1], buf[2], buf[3], | 832 | __func__, buf[0], buf[1], buf[2], buf[3], |
| 831 | ret, handle); | 833 | ret, handle); |
| 832 | dvbdmxfilter->hw_handle = 0xffff; | 834 | dvbdmxfilter->hw_handle = 0xffff; |
| 833 | if (!ret) | 835 | if (!ret) |
| @@ -854,7 +856,7 @@ static int StopHWFilter(struct dvb_demux_filter *dvbdmxfilter) | |||
| 854 | handle = dvbdmxfilter->hw_handle; | 856 | handle = dvbdmxfilter->hw_handle; |
| 855 | if (handle >= 32) { | 857 | if (handle >= 32) { |
| 856 | printk("%s tried to stop invalid filter %04x, filter type = %x\n", | 858 | printk("%s tried to stop invalid filter %04x, filter type = %x\n", |
| 857 | __FUNCTION__, handle, dvbdmxfilter->type); | 859 | __func__, handle, dvbdmxfilter->type); |
| 858 | return -EINVAL; | 860 | return -EINVAL; |
| 859 | } | 861 | } |
| 860 | 862 | ||
| @@ -867,7 +869,7 @@ static int StopHWFilter(struct dvb_demux_filter *dvbdmxfilter) | |||
| 867 | if (ret != 0 || answ[1] != handle) { | 869 | if (ret != 0 || answ[1] != handle) { |
| 868 | printk("dvb-ttpci: %s error cmd %04x %04x %04x ret %x " | 870 | printk("dvb-ttpci: %s error cmd %04x %04x %04x ret %x " |
| 869 | "resp %04x %04x pid %d\n", | 871 | "resp %04x %04x pid %d\n", |
| 870 | __FUNCTION__, buf[0], buf[1], buf[2], ret, | 872 | __func__, buf[0], buf[1], buf[2], ret, |
| 871 | answ[0], answ[1], dvbdmxfilter->feed->pid); | 873 | answ[0], answ[1], dvbdmxfilter->feed->pid); |
| 872 | if (!ret) | 874 | if (!ret) |
| 873 | ret = -1; | 875 | ret = -1; |
| @@ -1122,7 +1124,7 @@ static int dvb_get_stc(struct dmx_demux *demux, unsigned int num, | |||
| 1122 | 1124 | ||
| 1123 | ret = av7110_fw_request(av7110, &tag, 0, fwstc, 4); | 1125 | ret = av7110_fw_request(av7110, &tag, 0, fwstc, 4); |
| 1124 | if (ret) { | 1126 | if (ret) { |
| 1125 | printk(KERN_ERR "%s: av7110_fw_request error\n", __FUNCTION__); | 1127 | printk(KERN_ERR "%s: av7110_fw_request error\n", __func__); |
| 1126 | return ret; | 1128 | return ret; |
| 1127 | } | 1129 | } |
| 1128 | dprintk(2, "fwstc = %04hx %04hx %04hx %04hx\n", | 1130 | dprintk(2, "fwstc = %04hx %04hx %04hx %04hx\n", |
| @@ -2461,7 +2463,7 @@ static int __devinit av7110_attach(struct saa7146_dev* dev, | |||
| 2461 | goto err_kfree_0; | 2463 | goto err_kfree_0; |
| 2462 | 2464 | ||
| 2463 | ret = dvb_register_adapter(&av7110->dvb_adapter, av7110->card_name, | 2465 | ret = dvb_register_adapter(&av7110->dvb_adapter, av7110->card_name, |
| 2464 | THIS_MODULE, &dev->pci->dev); | 2466 | THIS_MODULE, &dev->pci->dev, adapter_nr); |
| 2465 | if (ret < 0) | 2467 | if (ret < 0) |
| 2466 | goto err_put_firmware_1; | 2468 | goto err_put_firmware_1; |
| 2467 | 2469 | ||
diff --git a/drivers/media/dvb/ttpci/av7110.h b/drivers/media/dvb/ttpci/av7110.h index 39fbf7d5cffb..e494e04eeee8 100644 --- a/drivers/media/dvb/ttpci/av7110.h +++ b/drivers/media/dvb/ttpci/av7110.h | |||
| @@ -40,7 +40,7 @@ | |||
| 40 | extern int av7110_debug; | 40 | extern int av7110_debug; |
| 41 | 41 | ||
| 42 | #define dprintk(level,args...) \ | 42 | #define dprintk(level,args...) \ |
| 43 | do { if ((av7110_debug & level)) { printk("dvb-ttpci: %s(): ", __FUNCTION__); printk(args); } } while (0) | 43 | do { if ((av7110_debug & level)) { printk("dvb-ttpci: %s(): ", __func__); printk(args); } } while (0) |
| 44 | 44 | ||
| 45 | #define MAXFILT 32 | 45 | #define MAXFILT 32 |
| 46 | 46 | ||
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c index a468aa2e4854..9d81074b31df 100644 --- a/drivers/media/dvb/ttpci/av7110_hw.c +++ b/drivers/media/dvb/ttpci/av7110_hw.c | |||
| @@ -53,11 +53,11 @@ int av7110_debiwrite(struct av7110 *av7110, u32 config, | |||
| 53 | struct saa7146_dev *dev = av7110->dev; | 53 | struct saa7146_dev *dev = av7110->dev; |
| 54 | 54 | ||
| 55 | if (count <= 0 || count > 32764) { | 55 | if (count <= 0 || count > 32764) { |
| 56 | printk("%s: invalid count %d\n", __FUNCTION__, count); | 56 | printk("%s: invalid count %d\n", __func__, count); |
| 57 | return -1; | 57 | return -1; |
| 58 | } | 58 | } |
| 59 | if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) { | 59 | if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) { |
| 60 | printk("%s: wait_for_debi_done failed\n", __FUNCTION__); | 60 | printk("%s: wait_for_debi_done failed\n", __func__); |
| 61 | return -1; | 61 | return -1; |
| 62 | } | 62 | } |
| 63 | saa7146_write(dev, DEBI_CONFIG, config); | 63 | saa7146_write(dev, DEBI_CONFIG, config); |
| @@ -76,11 +76,11 @@ u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count) | |||
| 76 | u32 result = 0; | 76 | u32 result = 0; |
| 77 | 77 | ||
| 78 | if (count > 32764 || count <= 0) { | 78 | if (count > 32764 || count <= 0) { |
| 79 | printk("%s: invalid count %d\n", __FUNCTION__, count); | 79 | printk("%s: invalid count %d\n", __func__, count); |
| 80 | return 0; | 80 | return 0; |
| 81 | } | 81 | } |
| 82 | if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) { | 82 | if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) { |
| 83 | printk("%s: wait_for_debi_done #1 failed\n", __FUNCTION__); | 83 | printk("%s: wait_for_debi_done #1 failed\n", __func__); |
| 84 | return 0; | 84 | return 0; |
| 85 | } | 85 | } |
| 86 | saa7146_write(dev, DEBI_AD, av7110->debi_bus); | 86 | saa7146_write(dev, DEBI_AD, av7110->debi_bus); |
| @@ -91,7 +91,7 @@ u32 av7110_debiread(struct av7110 *av7110, u32 config, int addr, int count) | |||
| 91 | if (count > 4) | 91 | if (count > 4) |
| 92 | return count; | 92 | return count; |
| 93 | if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) { | 93 | if (saa7146_wait_for_debi_done(av7110->dev, 0) < 0) { |
| 94 | printk("%s: wait_for_debi_done #2 failed\n", __FUNCTION__); | 94 | printk("%s: wait_for_debi_done #2 failed\n", __func__); |
| 95 | return 0; | 95 | return 0; |
| 96 | } | 96 | } |
| 97 | 97 | ||
| @@ -332,7 +332,7 @@ int av7110_wait_msgstate(struct av7110 *av7110, u16 flags) | |||
| 332 | break; | 332 | break; |
| 333 | if (err) { | 333 | if (err) { |
| 334 | printk(KERN_ERR "%s: timeout waiting for MSGSTATE %04x\n", | 334 | printk(KERN_ERR "%s: timeout waiting for MSGSTATE %04x\n", |
| 335 | __FUNCTION__, stat & flags); | 335 | __func__, stat & flags); |
| 336 | return -ETIMEDOUT; | 336 | return -ETIMEDOUT; |
| 337 | } | 337 | } |
| 338 | msleep(1); | 338 | msleep(1); |
| @@ -362,7 +362,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) | |||
| 362 | if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0) | 362 | if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0) |
| 363 | break; | 363 | break; |
| 364 | if (err) { | 364 | if (err) { |
| 365 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND idle\n", __FUNCTION__); | 365 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND idle\n", __func__); |
| 366 | av7110->arm_errors++; | 366 | av7110->arm_errors++; |
| 367 | return -ETIMEDOUT; | 367 | return -ETIMEDOUT; |
| 368 | } | 368 | } |
| @@ -379,7 +379,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) | |||
| 379 | if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0) | 379 | if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0) |
| 380 | break; | 380 | break; |
| 381 | if (err) { | 381 | if (err) { |
| 382 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); | 382 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for HANDSHAKE_REG\n", __func__); |
| 383 | return -ETIMEDOUT; | 383 | return -ETIMEDOUT; |
| 384 | } | 384 | } |
| 385 | msleep(1); | 385 | msleep(1); |
| @@ -419,14 +419,14 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) | |||
| 419 | stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); | 419 | stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); |
| 420 | if (stat & flags[0]) { | 420 | if (stat & flags[0]) { |
| 421 | printk(KERN_ERR "%s: %s QUEUE overflow\n", | 421 | printk(KERN_ERR "%s: %s QUEUE overflow\n", |
| 422 | __FUNCTION__, type); | 422 | __func__, type); |
| 423 | return -1; | 423 | return -1; |
| 424 | } | 424 | } |
| 425 | if ((stat & flags[1]) == 0) | 425 | if ((stat & flags[1]) == 0) |
| 426 | break; | 426 | break; |
| 427 | if (err) { | 427 | if (err) { |
| 428 | printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n", | 428 | printk(KERN_ERR "%s: timeout waiting on busy %s QUEUE\n", |
| 429 | __FUNCTION__, type); | 429 | __func__, type); |
| 430 | return -ETIMEDOUT; | 430 | return -ETIMEDOUT; |
| 431 | } | 431 | } |
| 432 | msleep(1); | 432 | msleep(1); |
| @@ -454,7 +454,7 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) | |||
| 454 | break; | 454 | break; |
| 455 | if (err) { | 455 | if (err) { |
| 456 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND %d to complete\n", | 456 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for COMMAND %d to complete\n", |
| 457 | __FUNCTION__, (buf[0] >> 8) & 0xff); | 457 | __func__, (buf[0] >> 8) & 0xff); |
| 458 | return -ETIMEDOUT; | 458 | return -ETIMEDOUT; |
| 459 | } | 459 | } |
| 460 | msleep(1); | 460 | msleep(1); |
| @@ -462,11 +462,11 @@ static int __av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) | |||
| 462 | 462 | ||
| 463 | stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); | 463 | stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); |
| 464 | if (stat & GPMQOver) { | 464 | if (stat & GPMQOver) { |
| 465 | printk(KERN_ERR "dvb-ttpci: %s(): GPMQOver\n", __FUNCTION__); | 465 | printk(KERN_ERR "dvb-ttpci: %s(): GPMQOver\n", __func__); |
| 466 | return -ENOSPC; | 466 | return -ENOSPC; |
| 467 | } | 467 | } |
| 468 | else if (stat & OSDQOver) { | 468 | else if (stat & OSDQOver) { |
| 469 | printk(KERN_ERR "dvb-ttpci: %s(): OSDQOver\n", __FUNCTION__); | 469 | printk(KERN_ERR "dvb-ttpci: %s(): OSDQOver\n", __func__); |
| 470 | return -ENOSPC; | 470 | return -ENOSPC; |
| 471 | } | 471 | } |
| 472 | #endif | 472 | #endif |
| @@ -491,7 +491,7 @@ static int av7110_send_fw_cmd(struct av7110 *av7110, u16* buf, int length) | |||
| 491 | mutex_unlock(&av7110->dcomlock); | 491 | mutex_unlock(&av7110->dcomlock); |
| 492 | if (ret && ret!=-ERESTARTSYS) | 492 | if (ret && ret!=-ERESTARTSYS) |
| 493 | printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n", | 493 | printk(KERN_ERR "dvb-ttpci: %s(): av7110_send_fw_cmd error %d\n", |
| 494 | __FUNCTION__, ret); | 494 | __func__, ret); |
| 495 | return ret; | 495 | return ret; |
| 496 | } | 496 | } |
| 497 | 497 | ||
| @@ -575,7 +575,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, | |||
| 575 | if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0) | 575 | if (rdebi(av7110, DEBINOSWAP, COMMAND, 0, 2) == 0) |
| 576 | break; | 576 | break; |
| 577 | if (err) { | 577 | if (err) { |
| 578 | printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __FUNCTION__); | 578 | printk(KERN_ERR "%s: timeout waiting for COMMAND to complete\n", __func__); |
| 579 | mutex_unlock(&av7110->dcomlock); | 579 | mutex_unlock(&av7110->dcomlock); |
| 580 | return -ETIMEDOUT; | 580 | return -ETIMEDOUT; |
| 581 | } | 581 | } |
| @@ -591,7 +591,7 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, | |||
| 591 | if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0) | 591 | if (rdebi(av7110, DEBINOSWAP, HANDSHAKE_REG, 0, 2) == 0) |
| 592 | break; | 592 | break; |
| 593 | if (err) { | 593 | if (err) { |
| 594 | printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __FUNCTION__); | 594 | printk(KERN_ERR "%s: timeout waiting for HANDSHAKE_REG\n", __func__); |
| 595 | mutex_unlock(&av7110->dcomlock); | 595 | mutex_unlock(&av7110->dcomlock); |
| 596 | return -ETIMEDOUT; | 596 | return -ETIMEDOUT; |
| 597 | } | 597 | } |
| @@ -602,12 +602,12 @@ int av7110_fw_request(struct av7110 *av7110, u16 *request_buf, | |||
| 602 | #ifdef COM_DEBUG | 602 | #ifdef COM_DEBUG |
| 603 | stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); | 603 | stat = rdebi(av7110, DEBINOSWAP, MSGSTATE, 0, 2); |
| 604 | if (stat & GPMQOver) { | 604 | if (stat & GPMQOver) { |
| 605 | printk(KERN_ERR "%s: GPMQOver\n", __FUNCTION__); | 605 | printk(KERN_ERR "%s: GPMQOver\n", __func__); |
| 606 | mutex_unlock(&av7110->dcomlock); | 606 | mutex_unlock(&av7110->dcomlock); |
| 607 | return -1; | 607 | return -1; |
| 608 | } | 608 | } |
| 609 | else if (stat & OSDQOver) { | 609 | else if (stat & OSDQOver) { |
| 610 | printk(KERN_ERR "%s: OSDQOver\n", __FUNCTION__); | 610 | printk(KERN_ERR "%s: OSDQOver\n", __func__); |
| 611 | mutex_unlock(&av7110->dcomlock); | 611 | mutex_unlock(&av7110->dcomlock); |
| 612 | return -1; | 612 | return -1; |
| 613 | } | 613 | } |
| @@ -741,7 +741,7 @@ static int FlushText(struct av7110 *av7110) | |||
| 741 | break; | 741 | break; |
| 742 | if (err) { | 742 | if (err) { |
| 743 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n", | 743 | printk(KERN_ERR "dvb-ttpci: %s(): timeout waiting for BUFF1_BASE == 0\n", |
| 744 | __FUNCTION__); | 744 | __func__); |
| 745 | mutex_unlock(&av7110->dcomlock); | 745 | mutex_unlock(&av7110->dcomlock); |
| 746 | return -ETIMEDOUT; | 746 | return -ETIMEDOUT; |
| 747 | } | 747 | } |
| @@ -768,7 +768,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, char *buf) | |||
| 768 | break; | 768 | break; |
| 769 | if (ret) { | 769 | if (ret) { |
| 770 | printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n", | 770 | printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for BUFF1_BASE == 0\n", |
| 771 | __FUNCTION__); | 771 | __func__); |
| 772 | mutex_unlock(&av7110->dcomlock); | 772 | mutex_unlock(&av7110->dcomlock); |
| 773 | return -ETIMEDOUT; | 773 | return -ETIMEDOUT; |
| 774 | } | 774 | } |
| @@ -782,7 +782,7 @@ static int WriteText(struct av7110 *av7110, u8 win, u16 x, u16 y, char *buf) | |||
| 782 | break; | 782 | break; |
| 783 | if (ret) { | 783 | if (ret) { |
| 784 | printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n", | 784 | printk(KERN_ERR "dvb-ttpci: %s: timeout waiting for HANDSHAKE_REG\n", |
| 785 | __FUNCTION__); | 785 | __func__); |
| 786 | mutex_unlock(&av7110->dcomlock); | 786 | mutex_unlock(&av7110->dcomlock); |
| 787 | return -ETIMEDOUT; | 787 | return -ETIMEDOUT; |
| 788 | } | 788 | } |
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c index a283e1de83fa..23a1c6380d3f 100644 --- a/drivers/media/dvb/ttpci/av7110_ir.c +++ b/drivers/media/dvb/ttpci/av7110_ir.c | |||
| @@ -133,7 +133,7 @@ static void av7110_emit_key(unsigned long parm) | |||
| 133 | break; | 133 | break; |
| 134 | 134 | ||
| 135 | default: | 135 | default: |
| 136 | printk("%s invalid protocol %x\n", __FUNCTION__, ir->protocol); | 136 | printk("%s invalid protocol %x\n", __func__, ir->protocol); |
| 137 | return; | 137 | return; |
| 138 | } | 138 | } |
| 139 | 139 | ||
| @@ -143,7 +143,7 @@ static void av7110_emit_key(unsigned long parm) | |||
| 143 | keycode = ir->key_map[data]; | 143 | keycode = ir->key_map[data]; |
| 144 | 144 | ||
| 145 | dprintk(16, "%s: code %08x -> addr %i data 0x%02x -> keycode %i\n", | 145 | dprintk(16, "%s: code %08x -> addr %i data 0x%02x -> keycode %i\n", |
| 146 | __FUNCTION__, ircom, addr, data, keycode); | 146 | __func__, ircom, addr, data, keycode); |
| 147 | 147 | ||
| 148 | /* check device address */ | 148 | /* check device address */ |
| 149 | if (!(ir->device_mask & (1 << addr))) | 149 | if (!(ir->device_mask & (1 << addr))) |
| @@ -151,7 +151,7 @@ static void av7110_emit_key(unsigned long parm) | |||
| 151 | 151 | ||
| 152 | if (!keycode) { | 152 | if (!keycode) { |
| 153 | printk ("%s: code %08x -> addr %i data 0x%02x -> unknown key!\n", | 153 | printk ("%s: code %08x -> addr %i data 0x%02x -> unknown key!\n", |
| 154 | __FUNCTION__, ircom, addr, data); | 154 | __func__, ircom, addr, data); |
| 155 | return; | 155 | return; |
| 156 | } | 156 | } |
| 157 | 157 | ||
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c index e2f066fb7967..b4a0cc5dc935 100644 --- a/drivers/media/dvb/ttpci/av7110_v4l.c +++ b/drivers/media/dvb/ttpci/av7110_v4l.c | |||
| @@ -573,7 +573,7 @@ static int av7110_vbi_reset(struct inode *inode, struct file *file) | |||
| 573 | struct saa7146_dev *dev = fh->dev; | 573 | struct saa7146_dev *dev = fh->dev; |
| 574 | struct av7110 *av7110 = (struct av7110*) dev->ext_priv; | 574 | struct av7110 *av7110 = (struct av7110*) dev->ext_priv; |
| 575 | 575 | ||
| 576 | dprintk(2, "%s\n", __FUNCTION__); | 576 | dprintk(2, "%s\n", __func__); |
| 577 | av7110->wssMode = 0; | 577 | av7110->wssMode = 0; |
| 578 | av7110->wssData = 0; | 578 | av7110->wssData = 0; |
| 579 | if (FW_VERSION(av7110->arm_app) < 0x2623) | 579 | if (FW_VERSION(av7110->arm_app) < 0x2623) |
| @@ -590,7 +590,7 @@ static ssize_t av7110_vbi_write(struct file *file, const char __user *data, size | |||
| 590 | struct v4l2_sliced_vbi_data d; | 590 | struct v4l2_sliced_vbi_data d; |
| 591 | int rc; | 591 | int rc; |
| 592 | 592 | ||
| 593 | dprintk(2, "%s\n", __FUNCTION__); | 593 | dprintk(2, "%s\n", __func__); |
| 594 | if (FW_VERSION(av7110->arm_app) < 0x2623 || !av7110->wssMode || count != sizeof d) | 594 | if (FW_VERSION(av7110->arm_app) < 0x2623 || !av7110->wssMode || count != sizeof d) |
| 595 | return -EINVAL; | 595 | return -EINVAL; |
| 596 | if (copy_from_user(&d, data, count)) | 596 | if (copy_from_user(&d, data, count)) |
diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 2d64d557b977..b30a5288e484 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c | |||
| @@ -178,7 +178,7 @@ static int ciintf_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 addre | |||
| 178 | udelay(1); | 178 | udelay(1); |
| 179 | 179 | ||
| 180 | result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0); | 180 | result = ttpci_budget_debiread(&budget_av->budget, DEBICICAM, address & 3, 1, 0, 0); |
| 181 | if ((result == -ETIMEDOUT) || ((result == 0xff) && ((address & 3) < 2))) { | 181 | if (result == -ETIMEDOUT) { |
| 182 | ciintf_slot_shutdown(ca, slot); | 182 | ciintf_slot_shutdown(ca, slot); |
| 183 | printk(KERN_INFO "budget-av: cam ejected 3\n"); | 183 | printk(KERN_INFO "budget-av: cam ejected 3\n"); |
| 184 | return -ETIMEDOUT; | 184 | return -ETIMEDOUT; |
| @@ -577,7 +577,7 @@ static struct stv0299_config typhoon_config = { | |||
| 577 | .mclk = 88000000UL, | 577 | .mclk = 88000000UL, |
| 578 | .invert = 0, | 578 | .invert = 0, |
| 579 | .skip_reinit = 0, | 579 | .skip_reinit = 0, |
| 580 | .lock_output = STV0229_LOCKOUTPUT_1, | 580 | .lock_output = STV0299_LOCKOUTPUT_1, |
| 581 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | 581 | .volt13_op0_op1 = STV0299_VOLT13_OP0, |
| 582 | .min_delay_ms = 100, | 582 | .min_delay_ms = 100, |
| 583 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, | 583 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, |
| @@ -590,7 +590,7 @@ static struct stv0299_config cinergy_1200s_config = { | |||
| 590 | .mclk = 88000000UL, | 590 | .mclk = 88000000UL, |
| 591 | .invert = 0, | 591 | .invert = 0, |
| 592 | .skip_reinit = 0, | 592 | .skip_reinit = 0, |
| 593 | .lock_output = STV0229_LOCKOUTPUT_0, | 593 | .lock_output = STV0299_LOCKOUTPUT_0, |
| 594 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | 594 | .volt13_op0_op1 = STV0299_VOLT13_OP0, |
| 595 | .min_delay_ms = 100, | 595 | .min_delay_ms = 100, |
| 596 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, | 596 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, |
| @@ -602,7 +602,7 @@ static struct stv0299_config cinergy_1200s_1894_0010_config = { | |||
| 602 | .mclk = 88000000UL, | 602 | .mclk = 88000000UL, |
| 603 | .invert = 1, | 603 | .invert = 1, |
| 604 | .skip_reinit = 0, | 604 | .skip_reinit = 0, |
| 605 | .lock_output = STV0229_LOCKOUTPUT_1, | 605 | .lock_output = STV0299_LOCKOUTPUT_1, |
| 606 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | 606 | .volt13_op0_op1 = STV0299_VOLT13_OP0, |
| 607 | .min_delay_ms = 100, | 607 | .min_delay_ms = 100, |
| 608 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, | 608 | .set_symbol_rate = philips_su1278_ty_ci_set_symbol_rate, |
| @@ -869,7 +869,7 @@ static struct stv0299_config philips_sd1878_config = { | |||
| 869 | .mclk = 88000000UL, | 869 | .mclk = 88000000UL, |
| 870 | .invert = 0, | 870 | .invert = 0, |
| 871 | .skip_reinit = 0, | 871 | .skip_reinit = 0, |
| 872 | .lock_output = STV0229_LOCKOUTPUT_1, | 872 | .lock_output = STV0299_LOCKOUTPUT_1, |
| 873 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | 873 | .volt13_op0_op1 = STV0299_VOLT13_OP0, |
| 874 | .min_delay_ms = 100, | 874 | .min_delay_ms = 100, |
| 875 | .set_symbol_rate = philips_sd1878_ci_set_symbol_rate, | 875 | .set_symbol_rate = philips_sd1878_ci_set_symbol_rate, |
| @@ -941,6 +941,12 @@ static void frontend_init(struct budget_av *budget_av) | |||
| 941 | switch (saa->pci->subsystem_device) { | 941 | switch (saa->pci->subsystem_device) { |
| 942 | 942 | ||
| 943 | case SUBID_DVBS_KNC1: | 943 | case SUBID_DVBS_KNC1: |
| 944 | /* | ||
| 945 | * maybe that setting is needed for other dvb-s cards as well, | ||
| 946 | * but so far it has been only confirmed for this type | ||
| 947 | */ | ||
| 948 | budget_av->reinitialise_demod = 1; | ||
| 949 | /* fall through */ | ||
| 944 | case SUBID_DVBS_KNC1_PLUS: | 950 | case SUBID_DVBS_KNC1_PLUS: |
| 945 | case SUBID_DVBS_EASYWATCH_1: | 951 | case SUBID_DVBS_EASYWATCH_1: |
| 946 | if (saa->pci->subsystem_vendor == 0x1894) { | 952 | if (saa->pci->subsystem_vendor == 0x1894) { |
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 509349211d4f..6530323d5406 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c | |||
| @@ -86,7 +86,7 @@ static int rc5_device = -1; | |||
| 86 | module_param(rc5_device, int, 0644); | 86 | module_param(rc5_device, int, 0644); |
| 87 | MODULE_PARM_DESC(rc5_device, "only IR commands to given RC5 device (device = 0 - 31, any device = 255, default: autodetect)"); | 87 | MODULE_PARM_DESC(rc5_device, "only IR commands to given RC5 device (device = 0 - 31, any device = 255, default: autodetect)"); |
| 88 | 88 | ||
| 89 | static int ir_debug = 0; | 89 | static int ir_debug; |
| 90 | module_param(ir_debug, int, 0644); | 90 | module_param(ir_debug, int, 0644); |
| 91 | MODULE_PARM_DESC(ir_debug, "enable debugging information for IR decoding"); | 91 | MODULE_PARM_DESC(ir_debug, "enable debugging information for IR decoding"); |
| 92 | 92 | ||
| @@ -728,7 +728,7 @@ static struct stv0299_config philips_su1278_tt_config = { | |||
| 728 | .mclk = 64000000UL, | 728 | .mclk = 64000000UL, |
| 729 | .invert = 0, | 729 | .invert = 0, |
| 730 | .skip_reinit = 1, | 730 | .skip_reinit = 1, |
| 731 | .lock_output = STV0229_LOCKOUTPUT_1, | 731 | .lock_output = STV0299_LOCKOUTPUT_1, |
| 732 | .volt13_op0_op1 = STV0299_VOLT13_OP1, | 732 | .volt13_op0_op1 = STV0299_VOLT13_OP1, |
| 733 | .min_delay_ms = 50, | 733 | .min_delay_ms = 50, |
| 734 | .set_symbol_rate = philips_su1278_tt_set_symbol_rate, | 734 | .set_symbol_rate = philips_su1278_tt_set_symbol_rate, |
| @@ -1121,7 +1121,7 @@ static void frontend_init(struct budget_ci *budget_ci) | |||
| 1121 | 1121 | ||
| 1122 | budget_ci->budget.dvb_frontend->ops.dishnetwork_send_legacy_command = NULL; | 1122 | budget_ci->budget.dvb_frontend->ops.dishnetwork_send_legacy_command = NULL; |
| 1123 | if (dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, LNBP21_LLC, 0) == NULL) { | 1123 | if (dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, LNBP21_LLC, 0) == NULL) { |
| 1124 | printk("%s: No LNBP21 found!\n", __FUNCTION__); | 1124 | printk("%s: No LNBP21 found!\n", __func__); |
| 1125 | dvb_frontend_detach(budget_ci->budget.dvb_frontend); | 1125 | dvb_frontend_detach(budget_ci->budget.dvb_frontend); |
| 1126 | budget_ci->budget.dvb_frontend = NULL; | 1126 | budget_ci->budget.dvb_frontend = NULL; |
| 1127 | } | 1127 | } |
diff --git a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c index 0252081f013c..18cac4b12ab2 100644 --- a/drivers/media/dvb/ttpci/budget-core.c +++ b/drivers/media/dvb/ttpci/budget-core.c | |||
| @@ -57,6 +57,8 @@ module_param_named(bufsize, dma_buffer_size, int, 0444); | |||
| 57 | MODULE_PARM_DESC(debug, "Turn on/off budget debugging (default:off)."); | 57 | MODULE_PARM_DESC(debug, "Turn on/off budget debugging (default:off)."); |
| 58 | MODULE_PARM_DESC(bufsize, "DMA buffer size in KB, default: 188, min: 188, max: 1410 (Activy: 564)"); | 58 | MODULE_PARM_DESC(bufsize, "DMA buffer size in KB, default: 188, min: 188, max: 1410 (Activy: 564)"); |
| 59 | 59 | ||
| 60 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 61 | |||
| 60 | /**************************************************************************** | 62 | /**************************************************************************** |
| 61 | * TT budget / WinTV Nova | 63 | * TT budget / WinTV Nova |
| 62 | ****************************************************************************/ | 64 | ****************************************************************************/ |
| @@ -223,7 +225,7 @@ static void vpeirq(unsigned long data) | |||
| 223 | 225 | ||
| 224 | if (budget->buffer_warnings && time_after(jiffies, budget->buffer_warning_time)) { | 226 | if (budget->buffer_warnings && time_after(jiffies, budget->buffer_warning_time)) { |
| 225 | printk("%s %s: used %d times >80%% of buffer (%u bytes now)\n", | 227 | printk("%s %s: used %d times >80%% of buffer (%u bytes now)\n", |
| 226 | budget->dev->name, __FUNCTION__, budget->buffer_warnings, count); | 228 | budget->dev->name, __func__, budget->buffer_warnings, count); |
| 227 | budget->buffer_warning_time = jiffies + BUFFER_WARNING_WAIT; | 229 | budget->buffer_warning_time = jiffies + BUFFER_WARNING_WAIT; |
| 228 | budget->buffer_warnings = 0; | 230 | budget->buffer_warnings = 0; |
| 229 | } | 231 | } |
| @@ -471,9 +473,10 @@ int ttpci_budget_init(struct budget *budget, struct saa7146_dev *dev, | |||
| 471 | budget->buffer_width, budget->buffer_height); | 473 | budget->buffer_width, budget->buffer_height); |
| 472 | printk("%s: dma buffer size %u\n", budget->dev->name, budget->buffer_size); | 474 | printk("%s: dma buffer size %u\n", budget->dev->name, budget->buffer_size); |
| 473 | 475 | ||
| 474 | if ((ret = dvb_register_adapter(&budget->dvb_adapter, budget->card->name, owner, &budget->dev->pci->dev)) < 0) { | 476 | ret = dvb_register_adapter(&budget->dvb_adapter, budget->card->name, |
| 477 | owner, &budget->dev->pci->dev, adapter_nr); | ||
| 478 | if (ret < 0) | ||
| 475 | return ret; | 479 | return ret; |
| 476 | } | ||
| 477 | 480 | ||
| 478 | /* set dd1 stream a & b */ | 481 | /* set dd1 stream a & b */ |
| 479 | saa7146_write(dev, DD1_STREAM_B, 0x00000000); | 482 | saa7146_write(dev, DD1_STREAM_B, 0x00000000); |
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c index 14b00f57b5de..2293d80c6e51 100644 --- a/drivers/media/dvb/ttpci/budget.c +++ b/drivers/media/dvb/ttpci/budget.c | |||
| @@ -45,6 +45,7 @@ | |||
| 45 | #include "tda826x.h" | 45 | #include "tda826x.h" |
| 46 | #include "lnbp21.h" | 46 | #include "lnbp21.h" |
| 47 | #include "bsru6.h" | 47 | #include "bsru6.h" |
| 48 | #include "bsbe1.h" | ||
| 48 | 49 | ||
| 49 | static int diseqc_method; | 50 | static int diseqc_method; |
| 50 | module_param(diseqc_method, int, 0444); | 51 | module_param(diseqc_method, int, 0444); |
| @@ -257,11 +258,17 @@ static struct ves1820_config alps_tdbe2_config = { | |||
| 257 | 258 | ||
| 258 | static int grundig_29504_401_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) | 259 | static int grundig_29504_401_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
| 259 | { | 260 | { |
| 260 | struct budget* budget = (struct budget*) fe->dvb->priv; | 261 | struct budget *budget = fe->dvb->priv; |
| 262 | u8 *tuner_addr = fe->tuner_priv; | ||
| 261 | u32 div; | 263 | u32 div; |
| 262 | u8 cfg, cpump, band_select; | 264 | u8 cfg, cpump, band_select; |
| 263 | u8 data[4]; | 265 | u8 data[4]; |
| 264 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; | 266 | struct i2c_msg msg = { .flags = 0, .buf = data, .len = sizeof(data) }; |
| 267 | |||
| 268 | if (tuner_addr) | ||
| 269 | msg.addr = *tuner_addr; | ||
| 270 | else | ||
| 271 | msg.addr = 0x61; | ||
| 265 | 272 | ||
| 266 | div = (36125000 + params->frequency) / 166666; | 273 | div = (36125000 + params->frequency) / 166666; |
| 267 | 274 | ||
| @@ -292,6 +299,12 @@ static struct l64781_config grundig_29504_401_config = { | |||
| 292 | .demod_address = 0x55, | 299 | .demod_address = 0x55, |
| 293 | }; | 300 | }; |
| 294 | 301 | ||
| 302 | static struct l64781_config grundig_29504_401_config_activy = { | ||
| 303 | .demod_address = 0x54, | ||
| 304 | }; | ||
| 305 | |||
| 306 | static u8 tuner_address_grundig_29504_401_activy = 0x60; | ||
| 307 | |||
| 295 | static int grundig_29504_451_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) | 308 | static int grundig_29504_451_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) |
| 296 | { | 309 | { |
| 297 | struct budget* budget = (struct budget*) fe->dvb->priv; | 310 | struct budget* budget = (struct budget*) fe->dvb->priv; |
| @@ -346,14 +359,48 @@ static int s5h1420_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend | |||
| 346 | static struct s5h1420_config s5h1420_config = { | 359 | static struct s5h1420_config s5h1420_config = { |
| 347 | .demod_address = 0x53, | 360 | .demod_address = 0x53, |
| 348 | .invert = 1, | 361 | .invert = 1, |
| 362 | .cdclk_polarity = 1, | ||
| 349 | }; | 363 | }; |
| 350 | 364 | ||
| 351 | static struct tda10086_config tda10086_config = { | 365 | static struct tda10086_config tda10086_config = { |
| 352 | .demod_address = 0x0e, | 366 | .demod_address = 0x0e, |
| 353 | .invert = 0, | 367 | .invert = 0, |
| 354 | .diseqc_tone = 1, | 368 | .diseqc_tone = 1, |
| 369 | .xtal_freq = TDA10086_XTAL_16M, | ||
| 355 | }; | 370 | }; |
| 356 | 371 | ||
| 372 | static struct stv0299_config alps_bsru6_config_activy = { | ||
| 373 | .demod_address = 0x68, | ||
| 374 | .inittab = alps_bsru6_inittab, | ||
| 375 | .mclk = 88000000UL, | ||
| 376 | .invert = 1, | ||
| 377 | .op0_off = 1, | ||
| 378 | .min_delay_ms = 100, | ||
| 379 | .set_symbol_rate = alps_bsru6_set_symbol_rate, | ||
| 380 | }; | ||
| 381 | |||
| 382 | static struct stv0299_config alps_bsbe1_config_activy = { | ||
| 383 | .demod_address = 0x68, | ||
| 384 | .inittab = alps_bsbe1_inittab, | ||
| 385 | .mclk = 88000000UL, | ||
| 386 | .invert = 1, | ||
| 387 | .op0_off = 1, | ||
| 388 | .min_delay_ms = 100, | ||
| 389 | .set_symbol_rate = alps_bsbe1_set_symbol_rate, | ||
| 390 | }; | ||
| 391 | |||
| 392 | |||
| 393 | static int i2c_readreg(struct i2c_adapter *i2c, u8 adr, u8 reg) | ||
| 394 | { | ||
| 395 | u8 val; | ||
| 396 | struct i2c_msg msg[] = { | ||
| 397 | { .addr = adr, .flags = 0, .buf = ®, .len = 1 }, | ||
| 398 | { .addr = adr, .flags = I2C_M_RD, .buf = &val, .len = 1 } | ||
| 399 | }; | ||
| 400 | |||
| 401 | return (i2c_transfer(i2c, msg, 2) != 2) ? -EIO : val; | ||
| 402 | } | ||
| 403 | |||
| 357 | static u8 read_pwm(struct budget* budget) | 404 | static u8 read_pwm(struct budget* budget) |
| 358 | { | 405 | { |
| 359 | u8 b = 0xff; | 406 | u8 b = 0xff; |
| @@ -369,6 +416,8 @@ static u8 read_pwm(struct budget* budget) | |||
| 369 | 416 | ||
| 370 | static void frontend_init(struct budget *budget) | 417 | static void frontend_init(struct budget *budget) |
| 371 | { | 418 | { |
| 419 | (void)alps_bsbe1_config; /* avoid warning */ | ||
| 420 | |||
| 372 | switch(budget->dev->pci->subsystem_device) { | 421 | switch(budget->dev->pci->subsystem_device) { |
| 373 | case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659)) | 422 | case 0x1003: // Hauppauge/TT Nova budget (stv0299/ALPS BSRU6(tsa5059) OR ves1893/ALPS BSRV2(sp5659)) |
| 374 | case 0x1013: | 423 | case 0x1013: |
| @@ -414,15 +463,43 @@ static void frontend_init(struct budget *budget) | |||
| 414 | } | 463 | } |
| 415 | break; | 464 | break; |
| 416 | 465 | ||
| 417 | case 0x4f60: // Fujitsu Siemens Activy Budget-S PCI rev AL (stv0299/ALPS BSRU6(tsa5059)) | 466 | case 0x4f60: /* Fujitsu Siemens Activy Budget-S PCI rev AL (stv0299/tsa5059) */ |
| 418 | budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config, &budget->i2c_adap); | 467 | { |
| 419 | if (budget->dvb_frontend) { | 468 | int subtype = i2c_readreg(&budget->i2c_adap, 0x50, 0x67); |
| 420 | budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; | 469 | |
| 421 | budget->dvb_frontend->tuner_priv = &budget->i2c_adap; | 470 | if (subtype < 0) |
| 422 | budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage; | 471 | break; |
| 423 | budget->dvb_frontend->ops.dishnetwork_send_legacy_command = NULL; | 472 | /* fixme: find a better way to identify the card */ |
| 473 | if (subtype < 0x36) { | ||
| 474 | /* assume ALPS BSRU6 */ | ||
| 475 | budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config_activy, &budget->i2c_adap); | ||
| 476 | if (budget->dvb_frontend) { | ||
| 477 | printk(KERN_INFO "budget: tuner ALPS BSRU6 detected\n"); | ||
| 478 | budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params; | ||
| 479 | budget->dvb_frontend->tuner_priv = &budget->i2c_adap; | ||
| 480 | budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage; | ||
| 481 | budget->dvb_frontend->ops.dishnetwork_send_legacy_command = NULL; | ||
| 482 | break; | ||
| 483 | } | ||
| 484 | } else { | ||
| 485 | /* assume ALPS BSBE1 */ | ||
| 486 | /* reset tuner */ | ||
| 487 | saa7146_setgpio(budget->dev, 3, SAA7146_GPIO_OUTLO); | ||
| 488 | msleep(50); | ||
| 489 | saa7146_setgpio(budget->dev, 3, SAA7146_GPIO_OUTHI); | ||
| 490 | msleep(250); | ||
| 491 | budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsbe1_config_activy, &budget->i2c_adap); | ||
| 492 | if (budget->dvb_frontend) { | ||
| 493 | printk(KERN_INFO "budget: tuner ALPS BSBE1 detected\n"); | ||
| 494 | budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsbe1_tuner_set_params; | ||
| 495 | budget->dvb_frontend->tuner_priv = &budget->i2c_adap; | ||
| 496 | budget->dvb_frontend->ops.set_voltage = siemens_budget_set_voltage; | ||
| 497 | budget->dvb_frontend->ops.dishnetwork_send_legacy_command = NULL; | ||
| 498 | break; | ||
| 499 | } | ||
| 424 | } | 500 | } |
| 425 | break; | 501 | break; |
| 502 | } | ||
| 426 | 503 | ||
| 427 | case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI rev GR (tda8083/Grundig 29504-451(tsa5522)) | 504 | case 0x4f61: // Fujitsu Siemens Activy Budget-S PCI rev GR (tda8083/Grundig 29504-451(tsa5522)) |
| 428 | budget->dvb_frontend = dvb_attach(tda8083_attach, &grundig_29504_451_config, &budget->i2c_adap); | 505 | budget->dvb_frontend = dvb_attach(tda8083_attach, &grundig_29504_451_config, &budget->i2c_adap); |
| @@ -433,12 +510,20 @@ static void frontend_init(struct budget *budget) | |||
| 433 | } | 510 | } |
| 434 | break; | 511 | break; |
| 435 | 512 | ||
| 513 | case 0x5f61: /* Fujitsu Siemens Activy Budget-T PCI rev GR (L64781/Grundig 29504-401(tsa5060)) */ | ||
| 514 | budget->dvb_frontend = dvb_attach(l64781_attach, &grundig_29504_401_config_activy, &budget->i2c_adap); | ||
| 515 | if (budget->dvb_frontend) { | ||
| 516 | budget->dvb_frontend->tuner_priv = &tuner_address_grundig_29504_401_activy; | ||
| 517 | budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_401_tuner_set_params; | ||
| 518 | } | ||
| 519 | break; | ||
| 520 | |||
| 436 | case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260)) | 521 | case 0x1016: // Hauppauge/TT Nova-S SE (samsung s5h1420/????(tda8260)) |
| 437 | budget->dvb_frontend = dvb_attach(s5h1420_attach, &s5h1420_config, &budget->i2c_adap); | 522 | budget->dvb_frontend = dvb_attach(s5h1420_attach, &s5h1420_config, &budget->i2c_adap); |
| 438 | if (budget->dvb_frontend) { | 523 | if (budget->dvb_frontend) { |
| 439 | budget->dvb_frontend->ops.tuner_ops.set_params = s5h1420_tuner_set_params; | 524 | budget->dvb_frontend->ops.tuner_ops.set_params = s5h1420_tuner_set_params; |
| 440 | if (dvb_attach(lnbp21_attach, budget->dvb_frontend, &budget->i2c_adap, 0, 0) == NULL) { | 525 | if (dvb_attach(lnbp21_attach, budget->dvb_frontend, &budget->i2c_adap, 0, 0) == NULL) { |
| 441 | printk("%s: No LNBP21 found!\n", __FUNCTION__); | 526 | printk("%s: No LNBP21 found!\n", __func__); |
| 442 | goto error_out; | 527 | goto error_out; |
| 443 | } | 528 | } |
| 444 | break; | 529 | break; |
| @@ -454,9 +539,9 @@ static void frontend_init(struct budget *budget) | |||
| 454 | budget->dvb_frontend = dvb_attach(tda10086_attach, &tda10086_config, &budget->i2c_adap); | 539 | budget->dvb_frontend = dvb_attach(tda10086_attach, &tda10086_config, &budget->i2c_adap); |
| 455 | if (budget->dvb_frontend) { | 540 | if (budget->dvb_frontend) { |
| 456 | if (dvb_attach(tda826x_attach, budget->dvb_frontend, 0x60, &budget->i2c_adap, 0) == NULL) | 541 | if (dvb_attach(tda826x_attach, budget->dvb_frontend, 0x60, &budget->i2c_adap, 0) == NULL) |
| 457 | printk("%s: No tda826x found!\n", __FUNCTION__); | 542 | printk("%s: No tda826x found!\n", __func__); |
| 458 | if (dvb_attach(lnbp21_attach, budget->dvb_frontend, &budget->i2c_adap, 0, 0) == NULL) { | 543 | if (dvb_attach(lnbp21_attach, budget->dvb_frontend, &budget->i2c_adap, 0, 0) == NULL) { |
| 459 | printk("%s: No LNBP21 found!\n", __FUNCTION__); | 544 | printk("%s: No LNBP21 found!\n", __func__); |
| 460 | goto error_out; | 545 | goto error_out; |
| 461 | } | 546 | } |
| 462 | break; | 547 | break; |
| @@ -537,6 +622,7 @@ MAKE_BUDGET_INFO(satel, "SATELCO Multimedia PCI", BUDGET_TT_HW_DISEQC); | |||
| 537 | MAKE_BUDGET_INFO(ttbs1401, "TT-Budget-S-1401 PCI", BUDGET_TT); | 622 | MAKE_BUDGET_INFO(ttbs1401, "TT-Budget-S-1401 PCI", BUDGET_TT); |
| 538 | MAKE_BUDGET_INFO(fsacs0, "Fujitsu Siemens Activy Budget-S PCI (rev GR/grundig frontend)", BUDGET_FS_ACTIVY); | 623 | MAKE_BUDGET_INFO(fsacs0, "Fujitsu Siemens Activy Budget-S PCI (rev GR/grundig frontend)", BUDGET_FS_ACTIVY); |
| 539 | MAKE_BUDGET_INFO(fsacs1, "Fujitsu Siemens Activy Budget-S PCI (rev AL/alps frontend)", BUDGET_FS_ACTIVY); | 624 | MAKE_BUDGET_INFO(fsacs1, "Fujitsu Siemens Activy Budget-S PCI (rev AL/alps frontend)", BUDGET_FS_ACTIVY); |
| 625 | MAKE_BUDGET_INFO(fsact, "Fujitsu Siemens Activy Budget-T PCI (rev GR/Grundig frontend)", BUDGET_FS_ACTIVY); | ||
| 540 | 626 | ||
| 541 | static struct pci_device_id pci_tbl[] = { | 627 | static struct pci_device_id pci_tbl[] = { |
| 542 | MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1003), | 628 | MAKE_EXTENSION_PCI(ttbs, 0x13c2, 0x1003), |
| @@ -547,6 +633,7 @@ static struct pci_device_id pci_tbl[] = { | |||
| 547 | MAKE_EXTENSION_PCI(ttbs1401, 0x13c2, 0x1018), | 633 | MAKE_EXTENSION_PCI(ttbs1401, 0x13c2, 0x1018), |
| 548 | MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60), | 634 | MAKE_EXTENSION_PCI(fsacs1,0x1131, 0x4f60), |
| 549 | MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61), | 635 | MAKE_EXTENSION_PCI(fsacs0,0x1131, 0x4f61), |
| 636 | MAKE_EXTENSION_PCI(fsact, 0x1131, 0x5f61), | ||
| 550 | { | 637 | { |
| 551 | .vendor = 0, | 638 | .vendor = 0, |
| 552 | } | 639 | } |
diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h index d764ffa728b0..dd450b739bff 100644 --- a/drivers/media/dvb/ttpci/budget.h +++ b/drivers/media/dvb/ttpci/budget.h | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | |||
| 1 | #ifndef __BUDGET_DVB__ | 2 | #ifndef __BUDGET_DVB__ |
| 2 | #define __BUDGET_DVB__ | 3 | #define __BUDGET_DVB__ |
| 3 | 4 | ||
| @@ -21,7 +22,7 @@ extern int budget_debug; | |||
| 21 | #endif | 22 | #endif |
| 22 | 23 | ||
| 23 | #define dprintk(level,args...) \ | 24 | #define dprintk(level,args...) \ |
| 24 | do { if ((budget_debug & level)) { printk("%s: %s(): ", KBUILD_MODNAME, __FUNCTION__); printk(args); } } while (0) | 25 | do { if ((budget_debug & level)) { printk("%s: %s(): ", KBUILD_MODNAME, __func__); printk(args); } } while (0) |
| 25 | 26 | ||
| 26 | struct budget_info { | 27 | struct budget_info { |
| 27 | char *name; | 28 | char *name; |
diff --git a/drivers/media/dvb/ttpci/ttpci-eeprom.c b/drivers/media/dvb/ttpci/ttpci-eeprom.c index 1f31e91195b0..7dd54b3026a2 100644 --- a/drivers/media/dvb/ttpci/ttpci-eeprom.c +++ b/drivers/media/dvb/ttpci/ttpci-eeprom.c | |||
| @@ -95,7 +95,7 @@ static int ttpci_eeprom_read_encodedMAC(struct i2c_adapter *adapter, u8 * encode | |||
| 95 | { .addr = 0x50, .flags = I2C_M_RD, .buf = encodedMAC, .len = 20 } | 95 | { .addr = 0x50, .flags = I2C_M_RD, .buf = encodedMAC, .len = 20 } |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | /* dprintk("%s\n", __FUNCTION__); */ | 98 | /* dprintk("%s\n", __func__); */ |
| 99 | 99 | ||
| 100 | ret = i2c_transfer(adapter, msg, 2); | 100 | ret = i2c_transfer(adapter, msg, 2); |
| 101 | 101 | ||
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c index 7902ae1d9a18..732ce4de512e 100644 --- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c | |||
| @@ -56,10 +56,11 @@ | |||
| 56 | */ | 56 | */ |
| 57 | 57 | ||
| 58 | static int debug; | 58 | static int debug; |
| 59 | |||
| 60 | module_param(debug, int, 0644); | 59 | module_param(debug, int, 0644); |
| 61 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); | 60 | MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); |
| 62 | 61 | ||
| 62 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 63 | |||
| 63 | #define dprintk(x...) do { if (debug) printk(KERN_DEBUG x); } while (0) | 64 | #define dprintk(x...) do { if (debug) printk(KERN_DEBUG x); } while (0) |
| 64 | 65 | ||
| 65 | #define ISO_BUF_COUNT 4 | 66 | #define ISO_BUF_COUNT 4 |
| @@ -153,12 +154,12 @@ static int ttusb_cmd(struct ttusb *ttusb, | |||
| 153 | (u8 *) data, len, &actual_len, 1000); | 154 | (u8 *) data, len, &actual_len, 1000); |
| 154 | if (err != 0) { | 155 | if (err != 0) { |
| 155 | dprintk("%s: usb_bulk_msg(send) failed, err == %i!\n", | 156 | dprintk("%s: usb_bulk_msg(send) failed, err == %i!\n", |
| 156 | __FUNCTION__, err); | 157 | __func__, err); |
| 157 | mutex_unlock(&ttusb->semusb); | 158 | mutex_unlock(&ttusb->semusb); |
| 158 | return err; | 159 | return err; |
| 159 | } | 160 | } |
| 160 | if (actual_len != len) { | 161 | if (actual_len != len) { |
| 161 | dprintk("%s: only wrote %d of %d bytes\n", __FUNCTION__, | 162 | dprintk("%s: only wrote %d of %d bytes\n", __func__, |
| 162 | actual_len, len); | 163 | actual_len, len); |
| 163 | mutex_unlock(&ttusb->semusb); | 164 | mutex_unlock(&ttusb->semusb); |
| 164 | return -1; | 165 | return -1; |
| @@ -168,7 +169,7 @@ static int ttusb_cmd(struct ttusb *ttusb, | |||
| 168 | ttusb->last_result, 32, &actual_len, 1000); | 169 | ttusb->last_result, 32, &actual_len, 1000); |
| 169 | 170 | ||
| 170 | if (err != 0) { | 171 | if (err != 0) { |
| 171 | printk("%s: failed, receive error %d\n", __FUNCTION__, | 172 | printk("%s: failed, receive error %d\n", __func__, |
| 172 | err); | 173 | err); |
| 173 | mutex_unlock(&ttusb->semusb); | 174 | mutex_unlock(&ttusb->semusb); |
| 174 | return err; | 175 | return err; |
| @@ -229,7 +230,7 @@ static int ttusb_i2c_msg(struct ttusb *ttusb, | |||
| 229 | if (err || b[0] != 0x55 || b[1] != id) { | 230 | if (err || b[0] != 0x55 || b[1] != id) { |
| 230 | dprintk | 231 | dprintk |
| 231 | ("%s: usb_bulk_msg(recv) failed, err == %i, id == %02x, b == ", | 232 | ("%s: usb_bulk_msg(recv) failed, err == %i, id == %02x, b == ", |
| 232 | __FUNCTION__, err, id); | 233 | __func__, err, id); |
| 233 | return -EREMOTEIO; | 234 | return -EREMOTEIO; |
| 234 | } | 235 | } |
| 235 | 236 | ||
| @@ -273,7 +274,7 @@ static int master_xfer(struct i2c_adapter* adapter, struct i2c_msg *msg, int num | |||
| 273 | snd_buf, snd_len, rcv_buf, rcv_len); | 274 | snd_buf, snd_len, rcv_buf, rcv_len); |
| 274 | 275 | ||
| 275 | if (err < rcv_len) { | 276 | if (err < rcv_len) { |
| 276 | dprintk("%s: i == %i\n", __FUNCTION__, i); | 277 | dprintk("%s: i == %i\n", __func__, i); |
| 277 | break; | 278 | break; |
| 278 | } | 279 | } |
| 279 | 280 | ||
| @@ -327,7 +328,7 @@ static int ttusb_boot_dsp(struct ttusb *ttusb) | |||
| 327 | done: | 328 | done: |
| 328 | if (err) { | 329 | if (err) { |
| 329 | dprintk("%s: usb_bulk_msg() failed, return value %i!\n", | 330 | dprintk("%s: usb_bulk_msg() failed, return value %i!\n", |
| 330 | __FUNCTION__, err); | 331 | __func__, err); |
| 331 | } | 332 | } |
| 332 | 333 | ||
| 333 | return err; | 334 | return err; |
| @@ -427,7 +428,7 @@ static int ttusb_init_controller(struct ttusb *ttusb) | |||
| 427 | if ((err = ttusb_result(ttusb, get_version, sizeof(get_version)))) | 428 | if ((err = ttusb_result(ttusb, get_version, sizeof(get_version)))) |
| 428 | return err; | 429 | return err; |
| 429 | 430 | ||
| 430 | dprintk("%s: stc-version: %c%c%c%c%c\n", __FUNCTION__, | 431 | dprintk("%s: stc-version: %c%c%c%c%c\n", __func__, |
| 431 | get_version[4], get_version[5], get_version[6], | 432 | get_version[4], get_version[5], get_version[6], |
| 432 | get_version[7], get_version[8]); | 433 | get_version[7], get_version[8]); |
| 433 | 434 | ||
| @@ -437,7 +438,7 @@ static int ttusb_init_controller(struct ttusb *ttusb) | |||
| 437 | memcmp(get_version + 4, "V 2.2", 5)) { | 438 | memcmp(get_version + 4, "V 2.2", 5)) { |
| 438 | printk | 439 | printk |
| 439 | ("%s: unknown STC version %c%c%c%c%c, please report!\n", | 440 | ("%s: unknown STC version %c%c%c%c%c, please report!\n", |
| 440 | __FUNCTION__, get_version[4], get_version[5], | 441 | __func__, get_version[4], get_version[5], |
| 441 | get_version[6], get_version[7], get_version[8]); | 442 | get_version[6], get_version[7], get_version[8]); |
| 442 | } | 443 | } |
| 443 | 444 | ||
| @@ -453,7 +454,7 @@ static int ttusb_init_controller(struct ttusb *ttusb) | |||
| 453 | ttusb_result(ttusb, get_dsp_version, sizeof(get_dsp_version)); | 454 | ttusb_result(ttusb, get_dsp_version, sizeof(get_dsp_version)); |
| 454 | if (err) | 455 | if (err) |
| 455 | return err; | 456 | return err; |
| 456 | printk("%s: dsp-version: %c%c%c\n", __FUNCTION__, | 457 | printk("%s: dsp-version: %c%c%c\n", __func__, |
| 457 | get_dsp_version[4], get_dsp_version[5], get_dsp_version[6]); | 458 | get_dsp_version[4], get_dsp_version[5], get_dsp_version[6]); |
| 458 | return 0; | 459 | return 0; |
| 459 | } | 460 | } |
| @@ -476,7 +477,7 @@ static int ttusb_send_diseqc(struct dvb_frontend* fe, | |||
| 476 | /* Diseqc */ | 477 | /* Diseqc */ |
| 477 | if ((err = ttusb_cmd(ttusb, b, 4 + b[3], 0))) { | 478 | if ((err = ttusb_cmd(ttusb, b, 4 + b[3], 0))) { |
| 478 | dprintk("%s: usb_bulk_msg() failed, return value %i!\n", | 479 | dprintk("%s: usb_bulk_msg() failed, return value %i!\n", |
| 479 | __FUNCTION__, err); | 480 | __func__, err); |
| 480 | } | 481 | } |
| 481 | 482 | ||
| 482 | return err; | 483 | return err; |
| @@ -494,7 +495,7 @@ static int ttusb_update_lnb(struct ttusb *ttusb) | |||
| 494 | /* SetLNB */ | 495 | /* SetLNB */ |
| 495 | if ((err = ttusb_cmd(ttusb, b, sizeof(b), 0))) { | 496 | if ((err = ttusb_cmd(ttusb, b, sizeof(b), 0))) { |
| 496 | dprintk("%s: usb_bulk_msg() failed, return value %i!\n", | 497 | dprintk("%s: usb_bulk_msg() failed, return value %i!\n", |
| 497 | __FUNCTION__, err); | 498 | __func__, err); |
| 498 | } | 499 | } |
| 499 | 500 | ||
| 500 | return err; | 501 | return err; |
| @@ -528,7 +529,7 @@ static void ttusb_set_led_freq(struct ttusb *ttusb, u8 freq) | |||
| 528 | err = ttusb_cmd(ttusb, b, sizeof(b), 0); | 529 | err = ttusb_cmd(ttusb, b, sizeof(b), 0); |
| 529 | if (err) { | 530 | if (err) { |
| 530 | dprintk("%s: usb_bulk_msg() failed, return value %i!\n", | 531 | dprintk("%s: usb_bulk_msg() failed, return value %i!\n", |
| 531 | __FUNCTION__, err); | 532 | __func__, err); |
| 532 | } | 533 | } |
| 533 | } | 534 | } |
| 534 | #endif | 535 | #endif |
| @@ -542,7 +543,7 @@ static void ttusb_handle_sec_data(struct ttusb_channel *channel, | |||
| 542 | const u8 * data, int len); | 543 | const u8 * data, int len); |
| 543 | #endif | 544 | #endif |
| 544 | 545 | ||
| 545 | static int numpkt = 0, numts, numstuff, numsec, numinvalid; | 546 | static int numpkt, numts, numstuff, numsec, numinvalid; |
| 546 | static unsigned long lastj; | 547 | static unsigned long lastj; |
| 547 | 548 | ||
| 548 | static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack, | 549 | static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack, |
| @@ -554,7 +555,7 @@ static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack, | |||
| 554 | csum ^= le16_to_cpup((u16 *) (muxpack + i)); | 555 | csum ^= le16_to_cpup((u16 *) (muxpack + i)); |
| 555 | if (csum) { | 556 | if (csum) { |
| 556 | printk("%s: muxpack with incorrect checksum, ignoring\n", | 557 | printk("%s: muxpack with incorrect checksum, ignoring\n", |
| 557 | __FUNCTION__); | 558 | __func__); |
| 558 | numinvalid++; | 559 | numinvalid++; |
| 559 | return; | 560 | return; |
| 560 | } | 561 | } |
| @@ -563,7 +564,7 @@ static void ttusb_process_muxpack(struct ttusb *ttusb, const u8 * muxpack, | |||
| 563 | cc &= 0x7FFF; | 564 | cc &= 0x7FFF; |
| 564 | if ((cc != ttusb->cc) && (ttusb->cc != -1)) | 565 | if ((cc != ttusb->cc) && (ttusb->cc != -1)) |
| 565 | printk("%s: cc discontinuity (%d frames missing)\n", | 566 | printk("%s: cc discontinuity (%d frames missing)\n", |
| 566 | __FUNCTION__, (cc - ttusb->cc) & 0x7FFF); | 567 | __func__, (cc - ttusb->cc) & 0x7FFF); |
| 567 | ttusb->cc = (cc + 1) & 0x7FFF; | 568 | ttusb->cc = (cc + 1) & 0x7FFF; |
| 568 | if (muxpack[0] & 0x80) { | 569 | if (muxpack[0] & 0x80) { |
| 569 | #ifdef TTUSB_HWSECTIONS | 570 | #ifdef TTUSB_HWSECTIONS |
| @@ -613,7 +614,7 @@ static void ttusb_process_frame(struct ttusb *ttusb, u8 * data, int len) | |||
| 613 | int maxwork = 1024; | 614 | int maxwork = 1024; |
| 614 | while (len) { | 615 | while (len) { |
| 615 | if (!(maxwork--)) { | 616 | if (!(maxwork--)) { |
| 616 | printk("%s: too much work\n", __FUNCTION__); | 617 | printk("%s: too much work\n", __func__); |
| 617 | break; | 618 | break; |
| 618 | } | 619 | } |
| 619 | 620 | ||
| @@ -632,7 +633,7 @@ static void ttusb_process_frame(struct ttusb *ttusb, u8 * data, int len) | |||
| 632 | #else | 633 | #else |
| 633 | if (ttusb->insync) { | 634 | if (ttusb->insync) { |
| 634 | printk("%s: lost sync.\n", | 635 | printk("%s: lost sync.\n", |
| 635 | __FUNCTION__); | 636 | __func__); |
| 636 | ttusb->insync = 0; | 637 | ttusb->insync = 0; |
| 637 | } | 638 | } |
| 638 | #endif | 639 | #endif |
| @@ -691,7 +692,7 @@ static void ttusb_process_frame(struct ttusb *ttusb, u8 * data, int len) | |||
| 691 | else { | 692 | else { |
| 692 | dprintk | 693 | dprintk |
| 693 | ("%s: invalid state: first byte is %x\n", | 694 | ("%s: invalid state: first byte is %x\n", |
| 694 | __FUNCTION__, | 695 | __func__, |
| 695 | ttusb->muxpack[0]); | 696 | ttusb->muxpack[0]); |
| 696 | ttusb->mux_state = 0; | 697 | ttusb->mux_state = 0; |
| 697 | } | 698 | } |
| @@ -740,7 +741,7 @@ static void ttusb_iso_irq(struct urb *urb) | |||
| 740 | 741 | ||
| 741 | #if 0 | 742 | #if 0 |
| 742 | printk("%s: status %d, errcount == %d, length == %i\n", | 743 | printk("%s: status %d, errcount == %d, length == %i\n", |
| 743 | __FUNCTION__, | 744 | __func__, |
| 744 | urb->status, urb->error_count, urb->actual_length); | 745 | urb->status, urb->error_count, urb->actual_length); |
| 745 | #endif | 746 | #endif |
| 746 | 747 | ||
| @@ -833,7 +834,7 @@ static int ttusb_start_iso_xfer(struct ttusb *ttusb) | |||
| 833 | int i, j, err, buffer_offset = 0; | 834 | int i, j, err, buffer_offset = 0; |
| 834 | 835 | ||
| 835 | if (ttusb->iso_streaming) { | 836 | if (ttusb->iso_streaming) { |
| 836 | printk("%s: iso xfer already running!\n", __FUNCTION__); | 837 | printk("%s: iso xfer already running!\n", __func__); |
| 837 | return 0; | 838 | return 0; |
| 838 | } | 839 | } |
| 839 | 840 | ||
| @@ -869,7 +870,7 @@ static int ttusb_start_iso_xfer(struct ttusb *ttusb) | |||
| 869 | ttusb_stop_iso_xfer(ttusb); | 870 | ttusb_stop_iso_xfer(ttusb); |
| 870 | printk | 871 | printk |
| 871 | ("%s: failed urb submission (%i: err = %i)!\n", | 872 | ("%s: failed urb submission (%i: err = %i)!\n", |
| 872 | __FUNCTION__, i, err); | 873 | __func__, i, err); |
| 873 | return err; | 874 | return err; |
| 874 | } | 875 | } |
| 875 | } | 876 | } |
| @@ -1005,7 +1006,7 @@ static int stc_release(struct inode *inode, struct file *file) | |||
| 1005 | return 0; | 1006 | return 0; |
| 1006 | } | 1007 | } |
| 1007 | 1008 | ||
| 1008 | static struct file_operations stc_fops = { | 1009 | static const struct file_operations stc_fops = { |
| 1009 | .owner = THIS_MODULE, | 1010 | .owner = THIS_MODULE, |
| 1010 | .read = stc_read, | 1011 | .read = stc_read, |
| 1011 | .open = stc_open, | 1012 | .open = stc_open, |
| @@ -1313,7 +1314,7 @@ static struct stv0299_config alps_stv0299_config = { | |||
| 1313 | .mclk = 88000000UL, | 1314 | .mclk = 88000000UL, |
| 1314 | .invert = 1, | 1315 | .invert = 1, |
| 1315 | .skip_reinit = 0, | 1316 | .skip_reinit = 0, |
| 1316 | .lock_output = STV0229_LOCKOUTPUT_1, | 1317 | .lock_output = STV0299_LOCKOUTPUT_1, |
| 1317 | .volt13_op0_op1 = STV0299_VOLT13_OP1, | 1318 | .volt13_op0_op1 = STV0299_VOLT13_OP1, |
| 1318 | .min_delay_ms = 100, | 1319 | .min_delay_ms = 100, |
| 1319 | .set_symbol_rate = alps_stv0299_set_symbol_rate, | 1320 | .set_symbol_rate = alps_stv0299_set_symbol_rate, |
| @@ -1643,7 +1644,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
| 1643 | struct ttusb *ttusb; | 1644 | struct ttusb *ttusb; |
| 1644 | int result; | 1645 | int result; |
| 1645 | 1646 | ||
| 1646 | dprintk("%s: TTUSB DVB connected\n", __FUNCTION__); | 1647 | dprintk("%s: TTUSB DVB connected\n", __func__); |
| 1647 | 1648 | ||
| 1648 | udev = interface_to_usbdev(intf); | 1649 | udev = interface_to_usbdev(intf); |
| 1649 | 1650 | ||
| @@ -1669,7 +1670,10 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
| 1669 | 1670 | ||
| 1670 | mutex_unlock(&ttusb->semi2c); | 1671 | mutex_unlock(&ttusb->semi2c); |
| 1671 | 1672 | ||
| 1672 | if ((result = dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE, &udev->dev)) < 0) { | 1673 | result = dvb_register_adapter(&ttusb->adapter, |
| 1674 | "Technotrend/Hauppauge Nova-USB", | ||
| 1675 | THIS_MODULE, &udev->dev, adapter_nr); | ||
| 1676 | if (result < 0) { | ||
| 1673 | ttusb_free_iso_urbs(ttusb); | 1677 | ttusb_free_iso_urbs(ttusb); |
| 1674 | kfree(ttusb); | 1678 | kfree(ttusb); |
| 1675 | return result; | 1679 | return result; |
| @@ -1773,7 +1777,7 @@ static void ttusb_disconnect(struct usb_interface *intf) | |||
| 1773 | 1777 | ||
| 1774 | kfree(ttusb); | 1778 | kfree(ttusb); |
| 1775 | 1779 | ||
| 1776 | dprintk("%s: TTUSB DVB disconnected\n", __FUNCTION__); | 1780 | dprintk("%s: TTUSB DVB disconnected\n", __func__); |
| 1777 | } | 1781 | } |
| 1778 | 1782 | ||
| 1779 | static struct usb_device_id ttusb_table[] = { | 1783 | static struct usb_device_id ttusb_table[] = { |
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 1ec981d98b91..42eee04daa5d 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c | |||
| @@ -52,6 +52,8 @@ MODULE_PARM_DESC(output_pva, "Output PVA from dvr device (default:off)"); | |||
| 52 | module_param(enable_rc, int, 0644); | 52 | module_param(enable_rc, int, 0644); |
| 53 | MODULE_PARM_DESC(enable_rc, "Turn on/off IR remote control(default: off)"); | 53 | MODULE_PARM_DESC(enable_rc, "Turn on/off IR remote control(default: off)"); |
| 54 | 54 | ||
| 55 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 56 | |||
| 55 | #define dprintk if (debug) printk | 57 | #define dprintk if (debug) printk |
| 56 | 58 | ||
| 57 | #define DRIVER_NAME "TechnoTrend/Hauppauge DEC USB" | 59 | #define DRIVER_NAME "TechnoTrend/Hauppauge DEC USB" |
| @@ -217,11 +219,11 @@ static void ttusb_dec_handle_irq( struct urb *urb) | |||
| 217 | case -ETIME: | 219 | case -ETIME: |
| 218 | /* this urb is dead, cleanup */ | 220 | /* this urb is dead, cleanup */ |
| 219 | dprintk("%s:urb shutting down with status: %d\n", | 221 | dprintk("%s:urb shutting down with status: %d\n", |
| 220 | __FUNCTION__, urb->status); | 222 | __func__, urb->status); |
| 221 | return; | 223 | return; |
| 222 | default: | 224 | default: |
| 223 | dprintk("%s:nonzero status received: %d\n", | 225 | dprintk("%s:nonzero status received: %d\n", |
| 224 | __FUNCTION__,urb->status); | 226 | __func__,urb->status); |
| 225 | goto exit; | 227 | goto exit; |
| 226 | } | 228 | } |
| 227 | 229 | ||
| @@ -235,7 +237,7 @@ static void ttusb_dec_handle_irq( struct urb *urb) | |||
| 235 | * keyrepeat signal is recieved for lets say 200ms. | 237 | * keyrepeat signal is recieved for lets say 200ms. |
| 236 | * this should/could be added later ... | 238 | * this should/could be added later ... |
| 237 | * for now lets report each signal as a key down and up*/ | 239 | * for now lets report each signal as a key down and up*/ |
| 238 | dprintk("%s:rc signal:%d\n", __FUNCTION__, buffer[4]); | 240 | dprintk("%s:rc signal:%d\n", __func__, buffer[4]); |
| 239 | input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 1); | 241 | input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 1); |
| 240 | input_sync(dec->rc_input_dev); | 242 | input_sync(dec->rc_input_dev); |
| 241 | input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 0); | 243 | input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 0); |
| @@ -245,7 +247,7 @@ static void ttusb_dec_handle_irq( struct urb *urb) | |||
| 245 | exit: retval = usb_submit_urb(urb, GFP_ATOMIC); | 247 | exit: retval = usb_submit_urb(urb, GFP_ATOMIC); |
| 246 | if(retval) | 248 | if(retval) |
| 247 | printk("%s - usb_commit_urb failed with result: %d\n", | 249 | printk("%s - usb_commit_urb failed with result: %d\n", |
| 248 | __FUNCTION__, retval); | 250 | __func__, retval); |
| 249 | } | 251 | } |
| 250 | 252 | ||
| 251 | static u16 crc16(u16 crc, const u8 *buf, size_t len) | 253 | static u16 crc16(u16 crc, const u8 *buf, size_t len) |
| @@ -268,7 +270,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, | |||
| 268 | int result, actual_len, i; | 270 | int result, actual_len, i; |
| 269 | u8 *b; | 271 | u8 *b; |
| 270 | 272 | ||
| 271 | dprintk("%s\n", __FUNCTION__); | 273 | dprintk("%s\n", __func__); |
| 272 | 274 | ||
| 273 | b = kmalloc(COMMAND_PACKET_SIZE + 4, GFP_KERNEL); | 275 | b = kmalloc(COMMAND_PACKET_SIZE + 4, GFP_KERNEL); |
| 274 | if (!b) | 276 | if (!b) |
| @@ -276,7 +278,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, | |||
| 276 | 278 | ||
| 277 | if ((result = mutex_lock_interruptible(&dec->usb_mutex))) { | 279 | if ((result = mutex_lock_interruptible(&dec->usb_mutex))) { |
| 278 | kfree(b); | 280 | kfree(b); |
| 279 | printk("%s: Failed to lock usb mutex.\n", __FUNCTION__); | 281 | printk("%s: Failed to lock usb mutex.\n", __func__); |
| 280 | return result; | 282 | return result; |
| 281 | } | 283 | } |
| 282 | 284 | ||
| @@ -289,7 +291,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, | |||
| 289 | memcpy(&b[4], params, param_length); | 291 | memcpy(&b[4], params, param_length); |
| 290 | 292 | ||
| 291 | if (debug) { | 293 | if (debug) { |
| 292 | printk("%s: command: ", __FUNCTION__); | 294 | printk("%s: command: ", __func__); |
| 293 | for (i = 0; i < param_length + 4; i++) | 295 | for (i = 0; i < param_length + 4; i++) |
| 294 | printk("0x%02X ", b[i]); | 296 | printk("0x%02X ", b[i]); |
| 295 | printk("\n"); | 297 | printk("\n"); |
| @@ -300,7 +302,7 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, | |||
| 300 | 302 | ||
| 301 | if (result) { | 303 | if (result) { |
| 302 | printk("%s: command bulk message failed: error %d\n", | 304 | printk("%s: command bulk message failed: error %d\n", |
| 303 | __FUNCTION__, result); | 305 | __func__, result); |
| 304 | mutex_unlock(&dec->usb_mutex); | 306 | mutex_unlock(&dec->usb_mutex); |
| 305 | kfree(b); | 307 | kfree(b); |
| 306 | return result; | 308 | return result; |
| @@ -311,13 +313,13 @@ static int ttusb_dec_send_command(struct ttusb_dec *dec, const u8 command, | |||
| 311 | 313 | ||
| 312 | if (result) { | 314 | if (result) { |
| 313 | printk("%s: result bulk message failed: error %d\n", | 315 | printk("%s: result bulk message failed: error %d\n", |
| 314 | __FUNCTION__, result); | 316 | __func__, result); |
| 315 | mutex_unlock(&dec->usb_mutex); | 317 | mutex_unlock(&dec->usb_mutex); |
| 316 | kfree(b); | 318 | kfree(b); |
| 317 | return result; | 319 | return result; |
| 318 | } else { | 320 | } else { |
| 319 | if (debug) { | 321 | if (debug) { |
| 320 | printk("%s: result: ", __FUNCTION__); | 322 | printk("%s: result: ", __func__); |
| 321 | for (i = 0; i < actual_len; i++) | 323 | for (i = 0; i < actual_len; i++) |
| 322 | printk("0x%02X ", b[i]); | 324 | printk("0x%02X ", b[i]); |
| 323 | printk("\n"); | 325 | printk("\n"); |
| @@ -343,7 +345,7 @@ static int ttusb_dec_get_stb_state (struct ttusb_dec *dec, unsigned int *mode, | |||
| 343 | int result; | 345 | int result; |
| 344 | unsigned int tmp; | 346 | unsigned int tmp; |
| 345 | 347 | ||
| 346 | dprintk("%s\n", __FUNCTION__); | 348 | dprintk("%s\n", __func__); |
| 347 | 349 | ||
| 348 | result = ttusb_dec_send_command(dec, 0x08, 0, NULL, &c_length, c); | 350 | result = ttusb_dec_send_command(dec, 0x08, 0, NULL, &c_length, c); |
| 349 | if (result) | 351 | if (result) |
| @@ -400,7 +402,7 @@ static void ttusb_dec_set_pids(struct ttusb_dec *dec) | |||
| 400 | u16 audio = htons(dec->pid[DMX_PES_AUDIO]); | 402 | u16 audio = htons(dec->pid[DMX_PES_AUDIO]); |
| 401 | u16 video = htons(dec->pid[DMX_PES_VIDEO]); | 403 | u16 video = htons(dec->pid[DMX_PES_VIDEO]); |
| 402 | 404 | ||
| 403 | dprintk("%s\n", __FUNCTION__); | 405 | dprintk("%s\n", __func__); |
| 404 | 406 | ||
| 405 | memcpy(&b[0], &pcr, 2); | 407 | memcpy(&b[0], &pcr, 2); |
| 406 | memcpy(&b[2], &audio, 2); | 408 | memcpy(&b[2], &audio, 2); |
| @@ -419,12 +421,12 @@ static void ttusb_dec_set_pids(struct ttusb_dec *dec) | |||
| 419 | static void ttusb_dec_process_pva(struct ttusb_dec *dec, u8 *pva, int length) | 421 | static void ttusb_dec_process_pva(struct ttusb_dec *dec, u8 *pva, int length) |
| 420 | { | 422 | { |
| 421 | if (length < 8) { | 423 | if (length < 8) { |
| 422 | printk("%s: packet too short - discarding\n", __FUNCTION__); | 424 | printk("%s: packet too short - discarding\n", __func__); |
| 423 | return; | 425 | return; |
| 424 | } | 426 | } |
| 425 | 427 | ||
| 426 | if (length > 8 + MAX_PVA_LENGTH) { | 428 | if (length > 8 + MAX_PVA_LENGTH) { |
| 427 | printk("%s: packet too long - discarding\n", __FUNCTION__); | 429 | printk("%s: packet too long - discarding\n", __func__); |
| 428 | return; | 430 | return; |
| 429 | } | 431 | } |
| 430 | 432 | ||
| @@ -507,7 +509,7 @@ static void ttusb_dec_process_pva(struct ttusb_dec *dec, u8 *pva, int length) | |||
| 507 | break; | 509 | break; |
| 508 | 510 | ||
| 509 | default: | 511 | default: |
| 510 | printk("%s: unknown PVA type: %02x.\n", __FUNCTION__, | 512 | printk("%s: unknown PVA type: %02x.\n", __func__, |
| 511 | pva[2]); | 513 | pva[2]); |
| 512 | break; | 514 | break; |
| 513 | } | 515 | } |
| @@ -546,7 +548,7 @@ static void ttusb_dec_process_packet(struct ttusb_dec *dec) | |||
| 546 | u16 packet_id; | 548 | u16 packet_id; |
| 547 | 549 | ||
| 548 | if (dec->packet_length % 2) { | 550 | if (dec->packet_length % 2) { |
| 549 | printk("%s: odd sized packet - discarding\n", __FUNCTION__); | 551 | printk("%s: odd sized packet - discarding\n", __func__); |
| 550 | return; | 552 | return; |
| 551 | } | 553 | } |
| 552 | 554 | ||
| @@ -554,7 +556,7 @@ static void ttusb_dec_process_packet(struct ttusb_dec *dec) | |||
| 554 | csum ^= ((dec->packet[i] << 8) + dec->packet[i + 1]); | 556 | csum ^= ((dec->packet[i] << 8) + dec->packet[i + 1]); |
| 555 | 557 | ||
| 556 | if (csum) { | 558 | if (csum) { |
| 557 | printk("%s: checksum failed - discarding\n", __FUNCTION__); | 559 | printk("%s: checksum failed - discarding\n", __func__); |
| 558 | return; | 560 | return; |
| 559 | } | 561 | } |
| 560 | 562 | ||
| @@ -563,7 +565,7 @@ static void ttusb_dec_process_packet(struct ttusb_dec *dec) | |||
| 563 | 565 | ||
| 564 | if ((packet_id != dec->next_packet_id) && dec->next_packet_id) { | 566 | if ((packet_id != dec->next_packet_id) && dec->next_packet_id) { |
| 565 | printk("%s: warning: lost packets between %u and %u\n", | 567 | printk("%s: warning: lost packets between %u and %u\n", |
| 566 | __FUNCTION__, dec->next_packet_id - 1, packet_id); | 568 | __func__, dec->next_packet_id - 1, packet_id); |
| 567 | } | 569 | } |
| 568 | 570 | ||
| 569 | if (packet_id == 0xffff) | 571 | if (packet_id == 0xffff) |
| @@ -652,7 +654,7 @@ static void ttusb_dec_process_urb_frame(struct ttusb_dec *dec, u8 *b, | |||
| 652 | dec->packet_state = 7; | 654 | dec->packet_state = 7; |
| 653 | } else { | 655 | } else { |
| 654 | printk("%s: unknown packet type: " | 656 | printk("%s: unknown packet type: " |
| 655 | "%02x%02x\n", __FUNCTION__, | 657 | "%02x%02x\n", __func__, |
| 656 | dec->packet[0], dec->packet[1]); | 658 | dec->packet[0], dec->packet[1]); |
| 657 | dec->packet_state = 0; | 659 | dec->packet_state = 0; |
| 658 | } | 660 | } |
| @@ -724,7 +726,7 @@ static void ttusb_dec_process_urb_frame(struct ttusb_dec *dec, u8 *b, | |||
| 724 | 726 | ||
| 725 | default: | 727 | default: |
| 726 | printk("%s: illegal packet state encountered.\n", | 728 | printk("%s: illegal packet state encountered.\n", |
| 727 | __FUNCTION__); | 729 | __func__); |
| 728 | dec->packet_state = 0; | 730 | dec->packet_state = 0; |
| 729 | } | 731 | } |
| 730 | } | 732 | } |
| @@ -792,7 +794,7 @@ static void ttusb_dec_process_urb(struct urb *urb) | |||
| 792 | } else { | 794 | } else { |
| 793 | /* -ENOENT is expected when unlinking urbs */ | 795 | /* -ENOENT is expected when unlinking urbs */ |
| 794 | if (urb->status != -ENOENT) | 796 | if (urb->status != -ENOENT) |
| 795 | dprintk("%s: urb error: %d\n", __FUNCTION__, | 797 | dprintk("%s: urb error: %d\n", __func__, |
| 796 | urb->status); | 798 | urb->status); |
| 797 | } | 799 | } |
| 798 | 800 | ||
| @@ -804,7 +806,7 @@ static void ttusb_dec_setup_urbs(struct ttusb_dec *dec) | |||
| 804 | { | 806 | { |
| 805 | int i, j, buffer_offset = 0; | 807 | int i, j, buffer_offset = 0; |
| 806 | 808 | ||
| 807 | dprintk("%s\n", __FUNCTION__); | 809 | dprintk("%s\n", __func__); |
| 808 | 810 | ||
| 809 | for (i = 0; i < ISO_BUF_COUNT; i++) { | 811 | for (i = 0; i < ISO_BUF_COUNT; i++) { |
| 810 | int frame_offset = 0; | 812 | int frame_offset = 0; |
| @@ -834,7 +836,7 @@ static void ttusb_dec_stop_iso_xfer(struct ttusb_dec *dec) | |||
| 834 | { | 836 | { |
| 835 | int i; | 837 | int i; |
| 836 | 838 | ||
| 837 | dprintk("%s\n", __FUNCTION__); | 839 | dprintk("%s\n", __func__); |
| 838 | 840 | ||
| 839 | if (mutex_lock_interruptible(&dec->iso_mutex)) | 841 | if (mutex_lock_interruptible(&dec->iso_mutex)) |
| 840 | return; | 842 | return; |
| @@ -889,7 +891,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) | |||
| 889 | { | 891 | { |
| 890 | int i, result; | 892 | int i, result; |
| 891 | 893 | ||
| 892 | dprintk("%s\n", __FUNCTION__); | 894 | dprintk("%s\n", __func__); |
| 893 | 895 | ||
| 894 | if (mutex_lock_interruptible(&dec->iso_mutex)) | 896 | if (mutex_lock_interruptible(&dec->iso_mutex)) |
| 895 | return -EAGAIN; | 897 | return -EAGAIN; |
| @@ -905,7 +907,7 @@ static int ttusb_dec_start_iso_xfer(struct ttusb_dec *dec) | |||
| 905 | if ((result = usb_submit_urb(dec->iso_urb[i], | 907 | if ((result = usb_submit_urb(dec->iso_urb[i], |
| 906 | GFP_ATOMIC))) { | 908 | GFP_ATOMIC))) { |
| 907 | printk("%s: failed urb submission %d: " | 909 | printk("%s: failed urb submission %d: " |
| 908 | "error %d\n", __FUNCTION__, i, result); | 910 | "error %d\n", __func__, i, result); |
| 909 | 911 | ||
| 910 | while (i) { | 912 | while (i) { |
| 911 | usb_kill_urb(dec->iso_urb[i - 1]); | 913 | usb_kill_urb(dec->iso_urb[i - 1]); |
| @@ -932,7 +934,7 @@ static int ttusb_dec_start_ts_feed(struct dvb_demux_feed *dvbdmxfeed) | |||
| 932 | u8 b0[] = { 0x05 }; | 934 | u8 b0[] = { 0x05 }; |
| 933 | int result = 0; | 935 | int result = 0; |
| 934 | 936 | ||
| 935 | dprintk("%s\n", __FUNCTION__); | 937 | dprintk("%s\n", __func__); |
| 936 | 938 | ||
| 937 | dprintk(" ts_type:"); | 939 | dprintk(" ts_type:"); |
| 938 | 940 | ||
| @@ -1012,7 +1014,7 @@ static int ttusb_dec_start_sec_feed(struct dvb_demux_feed *dvbdmxfeed) | |||
| 1012 | unsigned long flags; | 1014 | unsigned long flags; |
| 1013 | u8 x = 1; | 1015 | u8 x = 1; |
| 1014 | 1016 | ||
| 1015 | dprintk("%s\n", __FUNCTION__); | 1017 | dprintk("%s\n", __func__); |
| 1016 | 1018 | ||
| 1017 | pid = htons(dvbdmxfeed->pid); | 1019 | pid = htons(dvbdmxfeed->pid); |
| 1018 | memcpy(&b0[0], &pid, 2); | 1020 | memcpy(&b0[0], &pid, 2); |
| @@ -1052,7 +1054,7 @@ static int ttusb_dec_start_feed(struct dvb_demux_feed *dvbdmxfeed) | |||
| 1052 | { | 1054 | { |
| 1053 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; | 1055 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; |
| 1054 | 1056 | ||
| 1055 | dprintk("%s\n", __FUNCTION__); | 1057 | dprintk("%s\n", __func__); |
| 1056 | 1058 | ||
| 1057 | if (!dvbdmx->dmx.frontend) | 1059 | if (!dvbdmx->dmx.frontend) |
| 1058 | return -EINVAL; | 1060 | return -EINVAL; |
| @@ -1113,7 +1115,7 @@ static int ttusb_dec_stop_sec_feed(struct dvb_demux_feed *dvbdmxfeed) | |||
| 1113 | 1115 | ||
| 1114 | static int ttusb_dec_stop_feed(struct dvb_demux_feed *dvbdmxfeed) | 1116 | static int ttusb_dec_stop_feed(struct dvb_demux_feed *dvbdmxfeed) |
| 1115 | { | 1117 | { |
| 1116 | dprintk("%s\n", __FUNCTION__); | 1118 | dprintk("%s\n", __func__); |
| 1117 | 1119 | ||
| 1118 | switch (dvbdmxfeed->type) { | 1120 | switch (dvbdmxfeed->type) { |
| 1119 | case DMX_TYPE_TS: | 1121 | case DMX_TYPE_TS: |
| @@ -1132,7 +1134,7 @@ static void ttusb_dec_free_iso_urbs(struct ttusb_dec *dec) | |||
| 1132 | { | 1134 | { |
| 1133 | int i; | 1135 | int i; |
| 1134 | 1136 | ||
| 1135 | dprintk("%s\n", __FUNCTION__); | 1137 | dprintk("%s\n", __func__); |
| 1136 | 1138 | ||
| 1137 | for (i = 0; i < ISO_BUF_COUNT; i++) | 1139 | for (i = 0; i < ISO_BUF_COUNT; i++) |
| 1138 | usb_free_urb(dec->iso_urb[i]); | 1140 | usb_free_urb(dec->iso_urb[i]); |
| @@ -1147,7 +1149,7 @@ static int ttusb_dec_alloc_iso_urbs(struct ttusb_dec *dec) | |||
| 1147 | { | 1149 | { |
| 1148 | int i; | 1150 | int i; |
| 1149 | 1151 | ||
| 1150 | dprintk("%s\n", __FUNCTION__); | 1152 | dprintk("%s\n", __func__); |
| 1151 | 1153 | ||
| 1152 | dec->iso_buffer = pci_alloc_consistent(NULL, | 1154 | dec->iso_buffer = pci_alloc_consistent(NULL, |
| 1153 | ISO_FRAME_SIZE * | 1155 | ISO_FRAME_SIZE * |
| @@ -1214,7 +1216,7 @@ static int ttusb_init_rc( struct ttusb_dec *dec) | |||
| 1214 | 1216 | ||
| 1215 | dec->rc_input_dev = input_dev; | 1217 | dec->rc_input_dev = input_dev; |
| 1216 | if (usb_submit_urb(dec->irq_urb, GFP_KERNEL)) | 1218 | if (usb_submit_urb(dec->irq_urb, GFP_KERNEL)) |
| 1217 | printk("%s: usb_submit_urb failed\n",__FUNCTION__); | 1219 | printk("%s: usb_submit_urb failed\n",__func__); |
| 1218 | /* enable irq pipe */ | 1220 | /* enable irq pipe */ |
| 1219 | ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL); | 1221 | ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL); |
| 1220 | 1222 | ||
| @@ -1223,7 +1225,7 @@ static int ttusb_init_rc( struct ttusb_dec *dec) | |||
| 1223 | 1225 | ||
| 1224 | static void ttusb_dec_init_v_pes(struct ttusb_dec *dec) | 1226 | static void ttusb_dec_init_v_pes(struct ttusb_dec *dec) |
| 1225 | { | 1227 | { |
| 1226 | dprintk("%s\n", __FUNCTION__); | 1228 | dprintk("%s\n", __func__); |
| 1227 | 1229 | ||
| 1228 | dec->v_pes[0] = 0x00; | 1230 | dec->v_pes[0] = 0x00; |
| 1229 | dec->v_pes[1] = 0x00; | 1231 | dec->v_pes[1] = 0x00; |
| @@ -1233,7 +1235,7 @@ static void ttusb_dec_init_v_pes(struct ttusb_dec *dec) | |||
| 1233 | 1235 | ||
| 1234 | static int ttusb_dec_init_usb(struct ttusb_dec *dec) | 1236 | static int ttusb_dec_init_usb(struct ttusb_dec *dec) |
| 1235 | { | 1237 | { |
| 1236 | dprintk("%s\n", __FUNCTION__); | 1238 | dprintk("%s\n", __func__); |
| 1237 | 1239 | ||
| 1238 | mutex_init(&dec->usb_mutex); | 1240 | mutex_init(&dec->usb_mutex); |
| 1239 | mutex_init(&dec->iso_mutex); | 1241 | mutex_init(&dec->iso_mutex); |
| @@ -1281,11 +1283,11 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec) | |||
| 1281 | u32 crc32_csum, crc32_check, tmp; | 1283 | u32 crc32_csum, crc32_check, tmp; |
| 1282 | const struct firmware *fw_entry = NULL; | 1284 | const struct firmware *fw_entry = NULL; |
| 1283 | 1285 | ||
| 1284 | dprintk("%s\n", __FUNCTION__); | 1286 | dprintk("%s\n", __func__); |
| 1285 | 1287 | ||
| 1286 | if (request_firmware(&fw_entry, dec->firmware_name, &dec->udev->dev)) { | 1288 | if (request_firmware(&fw_entry, dec->firmware_name, &dec->udev->dev)) { |
| 1287 | printk(KERN_ERR "%s: Firmware (%s) unavailable.\n", | 1289 | printk(KERN_ERR "%s: Firmware (%s) unavailable.\n", |
| 1288 | __FUNCTION__, dec->firmware_name); | 1290 | __func__, dec->firmware_name); |
| 1289 | return 1; | 1291 | return 1; |
| 1290 | } | 1292 | } |
| 1291 | 1293 | ||
| @@ -1294,7 +1296,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec) | |||
| 1294 | 1296 | ||
| 1295 | if (firmware_size < 60) { | 1297 | if (firmware_size < 60) { |
| 1296 | printk("%s: firmware size too small for DSP code (%zu < 60).\n", | 1298 | printk("%s: firmware size too small for DSP code (%zu < 60).\n", |
| 1297 | __FUNCTION__, firmware_size); | 1299 | __func__, firmware_size); |
| 1298 | release_firmware(fw_entry); | 1300 | release_firmware(fw_entry); |
| 1299 | return -1; | 1301 | return -1; |
| 1300 | } | 1302 | } |
| @@ -1308,7 +1310,7 @@ static int ttusb_dec_boot_dsp(struct ttusb_dec *dec) | |||
| 1308 | if (crc32_csum != crc32_check) { | 1310 | if (crc32_csum != crc32_check) { |
| 1309 | printk("%s: crc32 check of DSP code failed (calculated " | 1311 | printk("%s: crc32 check of DSP code failed (calculated " |
| 1310 | "0x%08x != 0x%08x in file), file invalid.\n", | 1312 | "0x%08x != 0x%08x in file), file invalid.\n", |
| 1311 | __FUNCTION__, crc32_csum, crc32_check); | 1313 | __func__, crc32_csum, crc32_check); |
| 1312 | release_firmware(fw_entry); | 1314 | release_firmware(fw_entry); |
| 1313 | return -1; | 1315 | return -1; |
| 1314 | } | 1316 | } |
| @@ -1376,7 +1378,7 @@ static int ttusb_dec_init_stb(struct ttusb_dec *dec) | |||
| 1376 | int result; | 1378 | int result; |
| 1377 | unsigned int mode, model, version; | 1379 | unsigned int mode, model, version; |
| 1378 | 1380 | ||
| 1379 | dprintk("%s\n", __FUNCTION__); | 1381 | dprintk("%s\n", __func__); |
| 1380 | 1382 | ||
| 1381 | result = ttusb_dec_get_stb_state(dec, &mode, &model, &version); | 1383 | result = ttusb_dec_get_stb_state(dec, &mode, &model, &version); |
| 1382 | 1384 | ||
| @@ -1415,7 +1417,7 @@ static int ttusb_dec_init_stb(struct ttusb_dec *dec) | |||
| 1415 | default: | 1417 | default: |
| 1416 | printk(KERN_ERR "%s: unknown model returned " | 1418 | printk(KERN_ERR "%s: unknown model returned " |
| 1417 | "by firmware (%08x) - please report\n", | 1419 | "by firmware (%08x) - please report\n", |
| 1418 | __FUNCTION__, model); | 1420 | __func__, model); |
| 1419 | return -1; | 1421 | return -1; |
| 1420 | break; | 1422 | break; |
| 1421 | } | 1423 | } |
| @@ -1434,12 +1436,14 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec) | |||
| 1434 | { | 1436 | { |
| 1435 | int result; | 1437 | int result; |
| 1436 | 1438 | ||
| 1437 | dprintk("%s\n", __FUNCTION__); | 1439 | dprintk("%s\n", __func__); |
| 1438 | 1440 | ||
| 1439 | if ((result = dvb_register_adapter(&dec->adapter, | 1441 | if ((result = dvb_register_adapter(&dec->adapter, |
| 1440 | dec->model_name, THIS_MODULE, &dec->udev->dev)) < 0) { | 1442 | dec->model_name, THIS_MODULE, |
| 1443 | &dec->udev->dev, | ||
| 1444 | adapter_nr)) < 0) { | ||
| 1441 | printk("%s: dvb_register_adapter failed: error %d\n", | 1445 | printk("%s: dvb_register_adapter failed: error %d\n", |
| 1442 | __FUNCTION__, result); | 1446 | __func__, result); |
| 1443 | 1447 | ||
| 1444 | return result; | 1448 | return result; |
| 1445 | } | 1449 | } |
| @@ -1454,7 +1458,7 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec) | |||
| 1454 | dec->demux.write_to_decoder = NULL; | 1458 | dec->demux.write_to_decoder = NULL; |
| 1455 | 1459 | ||
| 1456 | if ((result = dvb_dmx_init(&dec->demux)) < 0) { | 1460 | if ((result = dvb_dmx_init(&dec->demux)) < 0) { |
| 1457 | printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__, | 1461 | printk("%s: dvb_dmx_init failed: error %d\n", __func__, |
| 1458 | result); | 1462 | result); |
| 1459 | 1463 | ||
| 1460 | dvb_unregister_adapter(&dec->adapter); | 1464 | dvb_unregister_adapter(&dec->adapter); |
| @@ -1468,7 +1472,7 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec) | |||
| 1468 | 1472 | ||
| 1469 | if ((result = dvb_dmxdev_init(&dec->dmxdev, &dec->adapter)) < 0) { | 1473 | if ((result = dvb_dmxdev_init(&dec->dmxdev, &dec->adapter)) < 0) { |
| 1470 | printk("%s: dvb_dmxdev_init failed: error %d\n", | 1474 | printk("%s: dvb_dmxdev_init failed: error %d\n", |
| 1471 | __FUNCTION__, result); | 1475 | __func__, result); |
| 1472 | 1476 | ||
| 1473 | dvb_dmx_release(&dec->demux); | 1477 | dvb_dmx_release(&dec->demux); |
| 1474 | dvb_unregister_adapter(&dec->adapter); | 1478 | dvb_unregister_adapter(&dec->adapter); |
| @@ -1480,7 +1484,7 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec) | |||
| 1480 | 1484 | ||
| 1481 | if ((result = dec->demux.dmx.add_frontend(&dec->demux.dmx, | 1485 | if ((result = dec->demux.dmx.add_frontend(&dec->demux.dmx, |
| 1482 | &dec->frontend)) < 0) { | 1486 | &dec->frontend)) < 0) { |
| 1483 | printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__, | 1487 | printk("%s: dvb_dmx_init failed: error %d\n", __func__, |
| 1484 | result); | 1488 | result); |
| 1485 | 1489 | ||
| 1486 | dvb_dmxdev_release(&dec->dmxdev); | 1490 | dvb_dmxdev_release(&dec->dmxdev); |
| @@ -1492,7 +1496,7 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec) | |||
| 1492 | 1496 | ||
| 1493 | if ((result = dec->demux.dmx.connect_frontend(&dec->demux.dmx, | 1497 | if ((result = dec->demux.dmx.connect_frontend(&dec->demux.dmx, |
| 1494 | &dec->frontend)) < 0) { | 1498 | &dec->frontend)) < 0) { |
| 1495 | printk("%s: dvb_dmx_init failed: error %d\n", __FUNCTION__, | 1499 | printk("%s: dvb_dmx_init failed: error %d\n", __func__, |
| 1496 | result); | 1500 | result); |
| 1497 | 1501 | ||
| 1498 | dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend); | 1502 | dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend); |
| @@ -1510,7 +1514,7 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec) | |||
| 1510 | 1514 | ||
| 1511 | static void ttusb_dec_exit_dvb(struct ttusb_dec *dec) | 1515 | static void ttusb_dec_exit_dvb(struct ttusb_dec *dec) |
| 1512 | { | 1516 | { |
| 1513 | dprintk("%s\n", __FUNCTION__); | 1517 | dprintk("%s\n", __func__); |
| 1514 | 1518 | ||
| 1515 | dvb_net_release(&dec->dvb_net); | 1519 | dvb_net_release(&dec->dvb_net); |
| 1516 | dec->demux.dmx.close(&dec->demux.dmx); | 1520 | dec->demux.dmx.close(&dec->demux.dmx); |
| @@ -1528,7 +1532,7 @@ static void ttusb_dec_exit_dvb(struct ttusb_dec *dec) | |||
| 1528 | static void ttusb_dec_exit_rc(struct ttusb_dec *dec) | 1532 | static void ttusb_dec_exit_rc(struct ttusb_dec *dec) |
| 1529 | { | 1533 | { |
| 1530 | 1534 | ||
| 1531 | dprintk("%s\n", __FUNCTION__); | 1535 | dprintk("%s\n", __func__); |
| 1532 | /* we have to check whether the irq URB is already submitted. | 1536 | /* we have to check whether the irq URB is already submitted. |
| 1533 | * As the irq is submitted after the interface is changed, | 1537 | * As the irq is submitted after the interface is changed, |
| 1534 | * this is the best method i figured out. | 1538 | * this is the best method i figured out. |
| @@ -1552,7 +1556,7 @@ static void ttusb_dec_exit_usb(struct ttusb_dec *dec) | |||
| 1552 | { | 1556 | { |
| 1553 | int i; | 1557 | int i; |
| 1554 | 1558 | ||
| 1555 | dprintk("%s\n", __FUNCTION__); | 1559 | dprintk("%s\n", __func__); |
| 1556 | 1560 | ||
| 1557 | dec->iso_stream_count = 0; | 1561 | dec->iso_stream_count = 0; |
| 1558 | 1562 | ||
| @@ -1612,12 +1616,12 @@ static int ttusb_dec_probe(struct usb_interface *intf, | |||
| 1612 | struct usb_device *udev; | 1616 | struct usb_device *udev; |
| 1613 | struct ttusb_dec *dec; | 1617 | struct ttusb_dec *dec; |
| 1614 | 1618 | ||
| 1615 | dprintk("%s\n", __FUNCTION__); | 1619 | dprintk("%s\n", __func__); |
| 1616 | 1620 | ||
| 1617 | udev = interface_to_usbdev(intf); | 1621 | udev = interface_to_usbdev(intf); |
| 1618 | 1622 | ||
| 1619 | if (!(dec = kzalloc(sizeof(struct ttusb_dec), GFP_KERNEL))) { | 1623 | if (!(dec = kzalloc(sizeof(struct ttusb_dec), GFP_KERNEL))) { |
| 1620 | printk("%s: couldn't allocate memory.\n", __FUNCTION__); | 1624 | printk("%s: couldn't allocate memory.\n", __func__); |
| 1621 | return -ENOMEM; | 1625 | return -ENOMEM; |
| 1622 | } | 1626 | } |
| 1623 | 1627 | ||
| @@ -1692,7 +1696,7 @@ static void ttusb_dec_disconnect(struct usb_interface *intf) | |||
| 1692 | 1696 | ||
| 1693 | usb_set_intfdata(intf, NULL); | 1697 | usb_set_intfdata(intf, NULL); |
| 1694 | 1698 | ||
| 1695 | dprintk("%s\n", __FUNCTION__); | 1699 | dprintk("%s\n", __func__); |
| 1696 | 1700 | ||
| 1697 | if (dec->active) { | 1701 | if (dec->active) { |
| 1698 | ttusb_dec_exit_tasklet(dec); | 1702 | ttusb_dec_exit_tasklet(dec); |
| @@ -1749,7 +1753,7 @@ static int __init ttusb_dec_init(void) | |||
| 1749 | int result; | 1753 | int result; |
| 1750 | 1754 | ||
| 1751 | if ((result = usb_register(&ttusb_dec_driver)) < 0) { | 1755 | if ((result = usb_register(&ttusb_dec_driver)) < 0) { |
| 1752 | printk("%s: initialisation failed: error %d.\n", __FUNCTION__, | 1756 | printk("%s: initialisation failed: error %d.\n", __func__, |
| 1753 | result); | 1757 | result); |
| 1754 | return result; | 1758 | return result; |
| 1755 | } | 1759 | } |
diff --git a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c index a6fb1d6a7b5d..eb5eaeccd7c4 100644 --- a/drivers/media/dvb/ttusb-dec/ttusbdecfe.c +++ b/drivers/media/dvb/ttusb-dec/ttusbdecfe.c | |||
| @@ -53,7 +53,7 @@ static int ttusbdecfe_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 53 | return ret; | 53 | return ret; |
| 54 | 54 | ||
| 55 | if(len != 4) { | 55 | if(len != 4) { |
| 56 | printk(KERN_ERR "%s: unexpected reply\n", __FUNCTION__); | 56 | printk(KERN_ERR "%s: unexpected reply\n", __func__); |
| 57 | return -EIO; | 57 | return -EIO; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| @@ -70,7 +70,7 @@ static int ttusbdecfe_read_status(struct dvb_frontend* fe, fe_status_t* status) | |||
| 70 | break; | 70 | break; |
| 71 | default: | 71 | default: |
| 72 | pr_info("%s: returned unknown value: %d\n", | 72 | pr_info("%s: returned unknown value: %d\n", |
| 73 | __FUNCTION__, result[3]); | 73 | __func__, result[3]); |
| 74 | return -EIO; | 74 | return -EIO; |
| 75 | } | 75 | } |
| 76 | 76 | ||
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index 36c0e3651502..4e3f83e4e48f 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c | |||
| @@ -438,7 +438,9 @@ static const struct file_operations usb_dsbr100_fops = { | |||
| 438 | .open = usb_dsbr100_open, | 438 | .open = usb_dsbr100_open, |
| 439 | .release = usb_dsbr100_close, | 439 | .release = usb_dsbr100_close, |
| 440 | .ioctl = video_ioctl2, | 440 | .ioctl = video_ioctl2, |
| 441 | #ifdef CONFIG_COMPAT | ||
| 441 | .compat_ioctl = v4l_compat_ioctl32, | 442 | .compat_ioctl = v4l_compat_ioctl32, |
| 443 | #endif | ||
| 442 | .llseek = no_llseek, | 444 | .llseek = no_llseek, |
| 443 | }; | 445 | }; |
| 444 | 446 | ||
diff --git a/drivers/media/radio/miropcm20-radio.c b/drivers/media/radio/miropcm20-radio.c index 3ae56fef8c92..09fe6f1cdf14 100644 --- a/drivers/media/radio/miropcm20-radio.c +++ b/drivers/media/radio/miropcm20-radio.c | |||
| @@ -221,7 +221,9 @@ static const struct file_operations pcm20_fops = { | |||
| 221 | .open = video_exclusive_open, | 221 | .open = video_exclusive_open, |
| 222 | .release = video_exclusive_release, | 222 | .release = video_exclusive_release, |
| 223 | .ioctl = pcm20_ioctl, | 223 | .ioctl = pcm20_ioctl, |
| 224 | #ifdef CONFIG_COMPAT | ||
| 224 | .compat_ioctl = v4l_compat_ioctl32, | 225 | .compat_ioctl = v4l_compat_ioctl32, |
| 226 | #endif | ||
| 225 | .llseek = no_llseek, | 227 | .llseek = no_llseek, |
| 226 | }; | 228 | }; |
| 227 | 229 | ||
diff --git a/drivers/media/radio/miropcm20-rds.c b/drivers/media/radio/miropcm20-rds.c index aed11477378b..06dfed9ef4c7 100644 --- a/drivers/media/radio/miropcm20-rds.c +++ b/drivers/media/radio/miropcm20-rds.c | |||
| @@ -19,7 +19,7 @@ | |||
| 19 | #include "miropcm20-rds-core.h" | 19 | #include "miropcm20-rds-core.h" |
| 20 | 20 | ||
| 21 | static char * text_buffer; | 21 | static char * text_buffer; |
| 22 | static int rds_users = 0; | 22 | static int rds_users; |
| 23 | 23 | ||
| 24 | 24 | ||
| 25 | static int rds_f_open(struct inode *in, struct file *fi) | 25 | static int rds_f_open(struct inode *in, struct file *fi) |
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c index c69bde39a233..1ec18ed1a733 100644 --- a/drivers/media/radio/radio-aimslab.c +++ b/drivers/media/radio/radio-aimslab.c | |||
| @@ -382,7 +382,9 @@ static const struct file_operations rtrack_fops = { | |||
| 382 | .open = video_exclusive_open, | 382 | .open = video_exclusive_open, |
| 383 | .release = video_exclusive_release, | 383 | .release = video_exclusive_release, |
| 384 | .ioctl = video_ioctl2, | 384 | .ioctl = video_ioctl2, |
| 385 | #ifdef CONFIG_COMPAT | ||
| 385 | .compat_ioctl = v4l_compat_ioctl32, | 386 | .compat_ioctl = v4l_compat_ioctl32, |
| 387 | #endif | ||
| 386 | .llseek = no_llseek, | 388 | .llseek = no_llseek, |
| 387 | }; | 389 | }; |
| 388 | 390 | ||
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c index 9b1f7a99dac0..46cdb549eac7 100644 --- a/drivers/media/radio/radio-aztech.c +++ b/drivers/media/radio/radio-aztech.c | |||
| @@ -346,7 +346,9 @@ static const struct file_operations aztech_fops = { | |||
| 346 | .open = video_exclusive_open, | 346 | .open = video_exclusive_open, |
| 347 | .release = video_exclusive_release, | 347 | .release = video_exclusive_release, |
| 348 | .ioctl = video_ioctl2, | 348 | .ioctl = video_ioctl2, |
| 349 | #ifdef CONFIG_COMPAT | ||
| 349 | .compat_ioctl = v4l_compat_ioctl32, | 350 | .compat_ioctl = v4l_compat_ioctl32, |
| 351 | #endif | ||
| 350 | .llseek = no_llseek, | 352 | .llseek = no_llseek, |
| 351 | }; | 353 | }; |
| 352 | 354 | ||
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c index 57b9e3adc8f0..b14db53ea456 100644 --- a/drivers/media/radio/radio-cadet.c +++ b/drivers/media/radio/radio-cadet.c | |||
| @@ -69,13 +69,13 @@ static struct v4l2_queryctrl radio_qctrl[] = { | |||
| 69 | 69 | ||
| 70 | static int io=-1; /* default to isapnp activation */ | 70 | static int io=-1; /* default to isapnp activation */ |
| 71 | static int radio_nr = -1; | 71 | static int radio_nr = -1; |
| 72 | static int users=0; | 72 | static int users; |
| 73 | static int curtuner=0; | 73 | static int curtuner; |
| 74 | static int tunestat=0; | 74 | static int tunestat; |
| 75 | static int sigstrength=0; | 75 | static int sigstrength; |
| 76 | static wait_queue_head_t read_queue; | 76 | static wait_queue_head_t read_queue; |
| 77 | static struct timer_list readtimer; | 77 | static struct timer_list readtimer; |
| 78 | static __u8 rdsin=0,rdsout=0,rdsstat=0; | 78 | static __u8 rdsin, rdsout, rdsstat; |
| 79 | static unsigned char rdsbuf[RDS_BUFFER]; | 79 | static unsigned char rdsbuf[RDS_BUFFER]; |
| 80 | static spinlock_t cadet_io_lock; | 80 | static spinlock_t cadet_io_lock; |
| 81 | 81 | ||
| @@ -563,7 +563,9 @@ static const struct file_operations cadet_fops = { | |||
| 563 | .read = cadet_read, | 563 | .read = cadet_read, |
| 564 | .ioctl = video_ioctl2, | 564 | .ioctl = video_ioctl2, |
| 565 | .poll = cadet_poll, | 565 | .poll = cadet_poll, |
| 566 | #ifdef CONFIG_COMPAT | ||
| 566 | .compat_ioctl = v4l_compat_ioctl32, | 567 | .compat_ioctl = v4l_compat_ioctl32, |
| 568 | #endif | ||
| 567 | .llseek = no_llseek, | 569 | .llseek = no_llseek, |
| 568 | }; | 570 | }; |
| 569 | 571 | ||
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c index 99a323131333..de49be971480 100644 --- a/drivers/media/radio/radio-gemtek-pci.c +++ b/drivers/media/radio/radio-gemtek-pci.c | |||
| @@ -368,7 +368,9 @@ static const struct file_operations gemtek_pci_fops = { | |||
| 368 | .open = video_exclusive_open, | 368 | .open = video_exclusive_open, |
| 369 | .release = video_exclusive_release, | 369 | .release = video_exclusive_release, |
| 370 | .ioctl = video_ioctl2, | 370 | .ioctl = video_ioctl2, |
| 371 | #ifdef CONFIG_COMPAT | ||
| 371 | .compat_ioctl = v4l_compat_ioctl32, | 372 | .compat_ioctl = v4l_compat_ioctl32, |
| 373 | #endif | ||
| 372 | .llseek = no_llseek, | 374 | .llseek = no_llseek, |
| 373 | }; | 375 | }; |
| 374 | 376 | ||
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c index 246422b49267..81f6aeb1cd11 100644 --- a/drivers/media/radio/radio-gemtek.c +++ b/drivers/media/radio/radio-gemtek.c | |||
| @@ -397,7 +397,9 @@ static const struct file_operations gemtek_fops = { | |||
| 397 | .open = video_exclusive_open, | 397 | .open = video_exclusive_open, |
| 398 | .release = video_exclusive_release, | 398 | .release = video_exclusive_release, |
| 399 | .ioctl = video_ioctl2, | 399 | .ioctl = video_ioctl2, |
| 400 | #ifdef CONFIG_COMPAT | ||
| 400 | .compat_ioctl = v4l_compat_ioctl32, | 401 | .compat_ioctl = v4l_compat_ioctl32, |
| 402 | #endif | ||
| 401 | .llseek = no_llseek | 403 | .llseek = no_llseek |
| 402 | }; | 404 | }; |
| 403 | 405 | ||
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c index bc51f4d23a5a..bddd3c409aa9 100644 --- a/drivers/media/radio/radio-maestro.c +++ b/drivers/media/radio/radio-maestro.c | |||
| @@ -100,7 +100,9 @@ static const struct file_operations maestro_fops = { | |||
| 100 | .open = video_exclusive_open, | 100 | .open = video_exclusive_open, |
| 101 | .release = video_exclusive_release, | 101 | .release = video_exclusive_release, |
| 102 | .ioctl = video_ioctl2, | 102 | .ioctl = video_ioctl2, |
| 103 | #ifdef CONFIG_COMPAT | ||
| 103 | .compat_ioctl = v4l_compat_ioctl32, | 104 | .compat_ioctl = v4l_compat_ioctl32, |
| 105 | #endif | ||
| 104 | .llseek = no_llseek, | 106 | .llseek = no_llseek, |
| 105 | }; | 107 | }; |
| 106 | 108 | ||
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c index 8e184cfc1c94..0133ecf3e040 100644 --- a/drivers/media/radio/radio-maxiradio.c +++ b/drivers/media/radio/radio-maxiradio.c | |||
| @@ -103,7 +103,9 @@ static const struct file_operations maxiradio_fops = { | |||
| 103 | .open = video_exclusive_open, | 103 | .open = video_exclusive_open, |
| 104 | .release = video_exclusive_release, | 104 | .release = video_exclusive_release, |
| 105 | .ioctl = video_ioctl2, | 105 | .ioctl = video_ioctl2, |
| 106 | #ifdef CONFIG_COMPAT | ||
| 106 | .compat_ioctl = v4l_compat_ioctl32, | 107 | .compat_ioctl = v4l_compat_ioctl32, |
| 108 | #endif | ||
| 107 | .llseek = no_llseek, | 109 | .llseek = no_llseek, |
| 108 | }; | 110 | }; |
| 109 | 111 | ||
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c index 82aedfc95d4f..070802103dc3 100644 --- a/drivers/media/radio/radio-rtrack2.c +++ b/drivers/media/radio/radio-rtrack2.c | |||
| @@ -288,7 +288,9 @@ static const struct file_operations rtrack2_fops = { | |||
| 288 | .open = video_exclusive_open, | 288 | .open = video_exclusive_open, |
| 289 | .release = video_exclusive_release, | 289 | .release = video_exclusive_release, |
| 290 | .ioctl = video_ioctl2, | 290 | .ioctl = video_ioctl2, |
| 291 | #ifdef CONFIG_COMPAT | ||
| 291 | .compat_ioctl = v4l_compat_ioctl32, | 292 | .compat_ioctl = v4l_compat_ioctl32, |
| 293 | #endif | ||
| 292 | .llseek = no_llseek, | 294 | .llseek = no_llseek, |
| 293 | }; | 295 | }; |
| 294 | 296 | ||
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c index 53e114857377..66e052fd3909 100644 --- a/drivers/media/radio/radio-sf16fmi.c +++ b/drivers/media/radio/radio-sf16fmi.c | |||
| @@ -288,7 +288,9 @@ static const struct file_operations fmi_fops = { | |||
| 288 | .open = video_exclusive_open, | 288 | .open = video_exclusive_open, |
| 289 | .release = video_exclusive_release, | 289 | .release = video_exclusive_release, |
| 290 | .ioctl = video_ioctl2, | 290 | .ioctl = video_ioctl2, |
| 291 | #ifdef CONFIG_COMPAT | ||
| 291 | .compat_ioctl = v4l_compat_ioctl32, | 292 | .compat_ioctl = v4l_compat_ioctl32, |
| 293 | #endif | ||
| 292 | .llseek = no_llseek, | 294 | .llseek = no_llseek, |
| 293 | }; | 295 | }; |
| 294 | 296 | ||
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c index ebc5fbbc38bb..b0ccf7cb5952 100644 --- a/drivers/media/radio/radio-sf16fmr2.c +++ b/drivers/media/radio/radio-sf16fmr2.c | |||
| @@ -29,6 +29,8 @@ static struct mutex lock; | |||
| 29 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | 29 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ |
| 30 | #define RADIO_VERSION KERNEL_VERSION(0,0,2) | 30 | #define RADIO_VERSION KERNEL_VERSION(0,0,2) |
| 31 | 31 | ||
| 32 | #define AUD_VOL_INDEX 1 | ||
| 33 | |||
| 32 | static struct v4l2_queryctrl radio_qctrl[] = { | 34 | static struct v4l2_queryctrl radio_qctrl[] = { |
| 33 | { | 35 | { |
| 34 | .id = V4L2_CID_AUDIO_MUTE, | 36 | .id = V4L2_CID_AUDIO_MUTE, |
| @@ -37,13 +39,14 @@ static struct v4l2_queryctrl radio_qctrl[] = { | |||
| 37 | .maximum = 1, | 39 | .maximum = 1, |
| 38 | .default_value = 1, | 40 | .default_value = 1, |
| 39 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 41 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 40 | },{ | 42 | }, |
| 43 | [AUD_VOL_INDEX] = { | ||
| 41 | .id = V4L2_CID_AUDIO_VOLUME, | 44 | .id = V4L2_CID_AUDIO_VOLUME, |
| 42 | .name = "Volume", | 45 | .name = "Volume", |
| 43 | .minimum = 0, | 46 | .minimum = 0, |
| 44 | .maximum = 65535, | 47 | .maximum = 15, |
| 45 | .step = 1<<12, | 48 | .step = 1, |
| 46 | .default_value = 0xff, | 49 | .default_value = 0, |
| 47 | .type = V4L2_CTRL_TYPE_INTEGER, | 50 | .type = V4L2_CTRL_TYPE_INTEGER, |
| 48 | } | 51 | } |
| 49 | }; | 52 | }; |
| @@ -61,7 +64,7 @@ static struct v4l2_queryctrl radio_qctrl[] = { | |||
| 61 | struct fmr2_device | 64 | struct fmr2_device |
| 62 | { | 65 | { |
| 63 | int port; | 66 | int port; |
| 64 | int curvol; /* 0-65535, if not volume 0 or 65535 */ | 67 | int curvol; /* 0-15 */ |
| 65 | int mute; | 68 | int mute; |
| 66 | int stereo; /* card is producing stereo audio */ | 69 | int stereo; /* card is producing stereo audio */ |
| 67 | unsigned long curfreq; /* freq in kHz */ | 70 | unsigned long curfreq; /* freq in kHz */ |
| @@ -176,51 +179,35 @@ static int fmr2_setfreq(struct fmr2_device *dev) | |||
| 176 | /* !!! not tested, in my card this does't work !!! */ | 179 | /* !!! not tested, in my card this does't work !!! */ |
| 177 | static int fmr2_setvolume(struct fmr2_device *dev) | 180 | static int fmr2_setvolume(struct fmr2_device *dev) |
| 178 | { | 181 | { |
| 179 | int i,a,n, port = dev->port; | 182 | int vol[16] = { 0x021, 0x084, 0x090, 0x104, |
| 183 | 0x110, 0x204, 0x210, 0x402, | ||
| 184 | 0x404, 0x408, 0x410, 0x801, | ||
| 185 | 0x802, 0x804, 0x808, 0x810 }; | ||
| 186 | int i, a, port = dev->port; | ||
| 187 | int n = vol[dev->curvol & 0x0f]; | ||
| 180 | 188 | ||
| 181 | if (dev->card_type != 11) return 1; | 189 | if (dev->card_type != 11) |
| 190 | return 1; | ||
| 182 | 191 | ||
| 183 | switch( (dev->curvol+(1<<11)) >> 12 ) | 192 | for (i = 12; --i >= 0; ) { |
| 184 | { | ||
| 185 | case 0: case 1: n = 0x21; break; | ||
| 186 | case 2: n = 0x84; break; | ||
| 187 | case 3: n = 0x90; break; | ||
| 188 | case 4: n = 0x104; break; | ||
| 189 | case 5: n = 0x110; break; | ||
| 190 | case 6: n = 0x204; break; | ||
| 191 | case 7: n = 0x210; break; | ||
| 192 | case 8: n = 0x402; break; | ||
| 193 | case 9: n = 0x404; break; | ||
| 194 | default: | ||
| 195 | case 10: n = 0x408; break; | ||
| 196 | case 11: n = 0x410; break; | ||
| 197 | case 12: n = 0x801; break; | ||
| 198 | case 13: n = 0x802; break; | ||
| 199 | case 14: n = 0x804; break; | ||
| 200 | case 15: n = 0x808; break; | ||
| 201 | case 16: n = 0x810; break; | ||
| 202 | } | ||
| 203 | for(i=12;--i>=0;) | ||
| 204 | { | ||
| 205 | a = ((n >> i) & 1) << 6; /* if (a=0) a= 0; else a= 0x40; */ | 193 | a = ((n >> i) & 1) << 6; /* if (a=0) a= 0; else a= 0x40; */ |
| 206 | outb(a|4, port); | 194 | outb(a | 4, port); |
| 207 | wait(4,port); | 195 | wait(4, port); |
| 208 | outb(a|0x24, port); | 196 | outb(a | 0x24, port); |
| 209 | wait(4,port); | 197 | wait(4, port); |
| 210 | outb(a|4, port); | 198 | outb(a | 4, port); |
| 211 | wait(4,port); | 199 | wait(4, port); |
| 212 | } | 200 | } |
| 213 | for(i=6;--i>=0;) | 201 | for (i = 6; --i >= 0; ) { |
| 214 | { | ||
| 215 | a = ((0x18 >> i) & 1) << 6; | 202 | a = ((0x18 >> i) & 1) << 6; |
| 216 | outb(a|4, port); | 203 | outb(a | 4, port); |
| 217 | wait(4,port); | 204 | wait(4,port); |
| 218 | outb(a|0x24, port); | 205 | outb(a | 0x24, port); |
| 219 | wait(4,port); | 206 | wait(4,port); |
| 220 | outb(a|4, port); | 207 | outb(a|4, port); |
| 221 | wait(4,port); | 208 | wait(4,port); |
| 222 | } | 209 | } |
| 223 | wait(4,port); | 210 | wait(4, port); |
| 224 | outb(0x14, port); | 211 | outb(0x14, port); |
| 225 | 212 | ||
| 226 | return 0; | 213 | return 0; |
| @@ -312,16 +299,10 @@ static int vidioc_queryctrl(struct file *file, void *priv, | |||
| 312 | struct v4l2_queryctrl *qc) | 299 | struct v4l2_queryctrl *qc) |
| 313 | { | 300 | { |
| 314 | int i; | 301 | int i; |
| 315 | struct video_device *dev = video_devdata(file); | ||
| 316 | struct fmr2_device *fmr2 = dev->priv; | ||
| 317 | 302 | ||
| 318 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | 303 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { |
| 319 | if ((fmr2->card_type != 11) | ||
| 320 | && V4L2_CID_AUDIO_VOLUME) | ||
| 321 | radio_qctrl[i].step = 65535; | ||
| 322 | if (qc->id && qc->id == radio_qctrl[i].id) { | 304 | if (qc->id && qc->id == radio_qctrl[i].id) { |
| 323 | memcpy(qc, &(radio_qctrl[i]), | 305 | memcpy(qc, &radio_qctrl[i], sizeof(*qc)); |
| 324 | sizeof(*qc)); | ||
| 325 | return 0; | 306 | return 0; |
| 326 | } | 307 | } |
| 327 | } | 308 | } |
| @@ -354,24 +335,13 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
| 354 | switch (ctrl->id) { | 335 | switch (ctrl->id) { |
| 355 | case V4L2_CID_AUDIO_MUTE: | 336 | case V4L2_CID_AUDIO_MUTE: |
| 356 | fmr2->mute = ctrl->value; | 337 | fmr2->mute = ctrl->value; |
| 357 | if (fmr2->card_type != 11) { | ||
| 358 | if (!fmr2->mute) | ||
| 359 | fmr2->curvol = 65535; | ||
| 360 | else | ||
| 361 | fmr2->curvol = 0; | ||
| 362 | } | ||
| 363 | break; | 338 | break; |
| 364 | case V4L2_CID_AUDIO_VOLUME: | 339 | case V4L2_CID_AUDIO_VOLUME: |
| 365 | fmr2->curvol = ctrl->value; | 340 | if (ctrl->value > radio_qctrl[AUD_VOL_INDEX].maximum) |
| 366 | if (fmr2->card_type != 11) { | 341 | fmr2->curvol = radio_qctrl[AUD_VOL_INDEX].maximum; |
| 367 | if (fmr2->curvol) { | 342 | else |
| 368 | fmr2->curvol = 65535; | 343 | fmr2->curvol = ctrl->value; |
| 369 | fmr2->mute = 0; | 344 | |
| 370 | } else { | ||
| 371 | fmr2->curvol = 0; | ||
| 372 | fmr2->mute = 1; | ||
| 373 | } | ||
| 374 | } | ||
| 375 | break; | 345 | break; |
| 376 | default: | 346 | default: |
| 377 | return -EINVAL; | 347 | return -EINVAL; |
| @@ -387,6 +357,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv, | |||
| 387 | mutex_lock(&lock); | 357 | mutex_lock(&lock); |
| 388 | if (fmr2->curvol && !fmr2->mute) { | 358 | if (fmr2->curvol && !fmr2->mute) { |
| 389 | fmr2_setvolume(fmr2); | 359 | fmr2_setvolume(fmr2); |
| 360 | /* Set frequency and unmute card */ | ||
| 390 | fmr2_setfreq(fmr2); | 361 | fmr2_setfreq(fmr2); |
| 391 | } else | 362 | } else |
| 392 | fmr2_mute(fmr2->port); | 363 | fmr2_mute(fmr2->port); |
| @@ -433,7 +404,9 @@ static const struct file_operations fmr2_fops = { | |||
| 433 | .open = video_exclusive_open, | 404 | .open = video_exclusive_open, |
| 434 | .release = video_exclusive_release, | 405 | .release = video_exclusive_release, |
| 435 | .ioctl = video_ioctl2, | 406 | .ioctl = video_ioctl2, |
| 407 | #ifdef CONFIG_COMPAT | ||
| 436 | .compat_ioctl = v4l_compat_ioctl32, | 408 | .compat_ioctl = v4l_compat_ioctl32, |
| 409 | #endif | ||
| 437 | .llseek = no_llseek, | 410 | .llseek = no_llseek, |
| 438 | }; | 411 | }; |
| 439 | 412 | ||
| @@ -487,6 +460,11 @@ static int __init fmr2_init(void) | |||
| 487 | fmr2_product_info(&fmr2_unit); | 460 | fmr2_product_info(&fmr2_unit); |
| 488 | mutex_unlock(&lock); | 461 | mutex_unlock(&lock); |
| 489 | debug_print((KERN_DEBUG "card_type %d\n", fmr2_unit.card_type)); | 462 | debug_print((KERN_DEBUG "card_type %d\n", fmr2_unit.card_type)); |
| 463 | |||
| 464 | /* Only card_type == 11 implements volume */ | ||
| 465 | if (fmr2_unit.card_type != 11) | ||
| 466 | radio_qctrl[AUD_VOL_INDEX].maximum = 1; | ||
| 467 | |||
| 490 | return 0; | 468 | return 0; |
| 491 | } | 469 | } |
| 492 | 470 | ||
diff --git a/drivers/media/radio/radio-si470x.c b/drivers/media/radio/radio-si470x.c index 649f14d2c013..77354ca6e8e9 100644 --- a/drivers/media/radio/radio-si470x.c +++ b/drivers/media/radio/radio-si470x.c | |||
| @@ -85,6 +85,7 @@ | |||
| 85 | * Oliver Neukum <oliver@neukum.org> | 85 | * Oliver Neukum <oliver@neukum.org> |
| 86 | * Version 1.0.7 | 86 | * Version 1.0.7 |
| 87 | * - usb autosuspend support | 87 | * - usb autosuspend support |
| 88 | * - unplugging fixed | ||
| 88 | * | 89 | * |
| 89 | * ToDo: | 90 | * ToDo: |
| 90 | * - add seeking support | 91 | * - add seeking support |
| @@ -97,10 +98,10 @@ | |||
| 97 | /* driver definitions */ | 98 | /* driver definitions */ |
| 98 | #define DRIVER_AUTHOR "Tobias Lorenz <tobias.lorenz@gmx.net>" | 99 | #define DRIVER_AUTHOR "Tobias Lorenz <tobias.lorenz@gmx.net>" |
| 99 | #define DRIVER_NAME "radio-si470x" | 100 | #define DRIVER_NAME "radio-si470x" |
| 100 | #define DRIVER_KERNEL_VERSION KERNEL_VERSION(1, 0, 6) | 101 | #define DRIVER_KERNEL_VERSION KERNEL_VERSION(1, 0, 7) |
| 101 | #define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver" | 102 | #define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver" |
| 102 | #define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers" | 103 | #define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers" |
| 103 | #define DRIVER_VERSION "1.0.6" | 104 | #define DRIVER_VERSION "1.0.7" |
| 104 | 105 | ||
| 105 | 106 | ||
| 106 | /* kernel includes */ | 107 | /* kernel includes */ |
| @@ -424,6 +425,7 @@ struct si470x_device { | |||
| 424 | 425 | ||
| 425 | /* driver management */ | 426 | /* driver management */ |
| 426 | unsigned int users; | 427 | unsigned int users; |
| 428 | unsigned char disconnected; | ||
| 427 | 429 | ||
| 428 | /* Silabs internal registers (0..15) */ | 430 | /* Silabs internal registers (0..15) */ |
| 429 | unsigned short registers[RADIO_REGISTER_NUM]; | 431 | unsigned short registers[RADIO_REGISTER_NUM]; |
| @@ -440,6 +442,12 @@ struct si470x_device { | |||
| 440 | 442 | ||
| 441 | 443 | ||
| 442 | /* | 444 | /* |
| 445 | * Lock to prevent kfree of data before all users have releases the device. | ||
| 446 | */ | ||
| 447 | static DEFINE_MUTEX(open_close_lock); | ||
| 448 | |||
| 449 | |||
| 450 | /* | ||
| 443 | * The frequency is set in units of 62.5 Hz when using V4L2_TUNER_CAP_LOW, | 451 | * The frequency is set in units of 62.5 Hz when using V4L2_TUNER_CAP_LOW, |
| 444 | * 62.5 kHz otherwise. | 452 | * 62.5 kHz otherwise. |
| 445 | * The tuner is able to have a channel spacing of 50, 100 or 200 kHz. | 453 | * The tuner is able to have a channel spacing of 50, 100 or 200 kHz. |
| @@ -577,7 +585,7 @@ static int si470x_get_rds_registers(struct si470x_device *radio) | |||
| 577 | usb_rcvintpipe(radio->usbdev, 1), | 585 | usb_rcvintpipe(radio->usbdev, 1), |
| 578 | (void *) &buf, sizeof(buf), &size, usb_timeout); | 586 | (void *) &buf, sizeof(buf), &size, usb_timeout); |
| 579 | if (size != sizeof(buf)) | 587 | if (size != sizeof(buf)) |
| 580 | printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_register: " | 588 | printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: " |
| 581 | "return size differs: %d != %zu\n", size, sizeof(buf)); | 589 | "return size differs: %d != %zu\n", size, sizeof(buf)); |
| 582 | if (retval < 0) | 590 | if (retval < 0) |
| 583 | printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: " | 591 | printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: " |
| @@ -875,6 +883,8 @@ static void si470x_work(struct work_struct *work) | |||
| 875 | struct si470x_device *radio = container_of(work, struct si470x_device, | 883 | struct si470x_device *radio = container_of(work, struct si470x_device, |
| 876 | work.work); | 884 | work.work); |
| 877 | 885 | ||
| 886 | if (radio->disconnected) | ||
| 887 | return; | ||
| 878 | if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) | 888 | if ((radio->registers[SYSCONFIG1] & SYSCONFIG1_RDS) == 0) |
| 879 | return; | 889 | return; |
| 880 | 890 | ||
| @@ -1001,13 +1011,21 @@ static int si470x_fops_open(struct inode *inode, struct file *file) | |||
| 1001 | static int si470x_fops_release(struct inode *inode, struct file *file) | 1011 | static int si470x_fops_release(struct inode *inode, struct file *file) |
| 1002 | { | 1012 | { |
| 1003 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1013 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
| 1004 | int retval; | 1014 | int retval = 0; |
| 1005 | 1015 | ||
| 1006 | if (!radio) | 1016 | if (!radio) |
| 1007 | return -ENODEV; | 1017 | return -ENODEV; |
| 1008 | 1018 | ||
| 1019 | mutex_lock(&open_close_lock); | ||
| 1009 | radio->users--; | 1020 | radio->users--; |
| 1010 | if (radio->users == 0) { | 1021 | if (radio->users == 0) { |
| 1022 | if (radio->disconnected) { | ||
| 1023 | video_unregister_device(radio->videodev); | ||
| 1024 | kfree(radio->buffer); | ||
| 1025 | kfree(radio); | ||
| 1026 | goto done; | ||
| 1027 | } | ||
| 1028 | |||
| 1011 | /* stop rds reception */ | 1029 | /* stop rds reception */ |
| 1012 | cancel_delayed_work_sync(&radio->work); | 1030 | cancel_delayed_work_sync(&radio->work); |
| 1013 | 1031 | ||
| @@ -1016,10 +1034,11 @@ static int si470x_fops_release(struct inode *inode, struct file *file) | |||
| 1016 | 1034 | ||
| 1017 | retval = si470x_stop(radio); | 1035 | retval = si470x_stop(radio); |
| 1018 | usb_autopm_put_interface(radio->intf); | 1036 | usb_autopm_put_interface(radio->intf); |
| 1019 | return retval; | ||
| 1020 | } | 1037 | } |
| 1021 | 1038 | ||
| 1022 | return 0; | 1039 | done: |
| 1040 | mutex_unlock(&open_close_lock); | ||
| 1041 | return retval; | ||
| 1023 | } | 1042 | } |
| 1024 | 1043 | ||
| 1025 | 1044 | ||
| @@ -1032,7 +1051,9 @@ static const struct file_operations si470x_fops = { | |||
| 1032 | .read = si470x_fops_read, | 1051 | .read = si470x_fops_read, |
| 1033 | .poll = si470x_fops_poll, | 1052 | .poll = si470x_fops_poll, |
| 1034 | .ioctl = video_ioctl2, | 1053 | .ioctl = video_ioctl2, |
| 1054 | #ifdef CONFIG_COMPAT | ||
| 1035 | .compat_ioctl = v4l_compat_ioctl32, | 1055 | .compat_ioctl = v4l_compat_ioctl32, |
| 1056 | #endif | ||
| 1036 | .open = si470x_fops_open, | 1057 | .open = si470x_fops_open, |
| 1037 | .release = si470x_fops_release, | 1058 | .release = si470x_fops_release, |
| 1038 | }; | 1059 | }; |
| @@ -1157,6 +1178,9 @@ static int si470x_vidioc_g_ctrl(struct file *file, void *priv, | |||
| 1157 | { | 1178 | { |
| 1158 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1179 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
| 1159 | 1180 | ||
| 1181 | if (radio->disconnected) | ||
| 1182 | return -EIO; | ||
| 1183 | |||
| 1160 | switch (ctrl->id) { | 1184 | switch (ctrl->id) { |
| 1161 | case V4L2_CID_AUDIO_VOLUME: | 1185 | case V4L2_CID_AUDIO_VOLUME: |
| 1162 | ctrl->value = radio->registers[SYSCONFIG2] & | 1186 | ctrl->value = radio->registers[SYSCONFIG2] & |
| @@ -1181,6 +1205,9 @@ static int si470x_vidioc_s_ctrl(struct file *file, void *priv, | |||
| 1181 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1205 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
| 1182 | int retval; | 1206 | int retval; |
| 1183 | 1207 | ||
| 1208 | if (radio->disconnected) | ||
| 1209 | return -EIO; | ||
| 1210 | |||
| 1184 | switch (ctrl->id) { | 1211 | switch (ctrl->id) { |
| 1185 | case V4L2_CID_AUDIO_VOLUME: | 1212 | case V4L2_CID_AUDIO_VOLUME: |
| 1186 | radio->registers[SYSCONFIG2] &= ~SYSCONFIG2_VOLUME; | 1213 | radio->registers[SYSCONFIG2] &= ~SYSCONFIG2_VOLUME; |
| @@ -1243,6 +1270,8 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv, | |||
| 1243 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1270 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
| 1244 | int retval; | 1271 | int retval; |
| 1245 | 1272 | ||
| 1273 | if (radio->disconnected) | ||
| 1274 | return -EIO; | ||
| 1246 | if (tuner->index > 0) | 1275 | if (tuner->index > 0) |
| 1247 | return -EINVAL; | 1276 | return -EINVAL; |
| 1248 | 1277 | ||
| @@ -1299,6 +1328,8 @@ static int si470x_vidioc_s_tuner(struct file *file, void *priv, | |||
| 1299 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1328 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
| 1300 | int retval; | 1329 | int retval; |
| 1301 | 1330 | ||
| 1331 | if (radio->disconnected) | ||
| 1332 | return -EIO; | ||
| 1302 | if (tuner->index > 0) | 1333 | if (tuner->index > 0) |
| 1303 | return -EINVAL; | 1334 | return -EINVAL; |
| 1304 | 1335 | ||
| @@ -1324,6 +1355,9 @@ static int si470x_vidioc_g_frequency(struct file *file, void *priv, | |||
| 1324 | { | 1355 | { |
| 1325 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1356 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
| 1326 | 1357 | ||
| 1358 | if (radio->disconnected) | ||
| 1359 | return -EIO; | ||
| 1360 | |||
| 1327 | freq->type = V4L2_TUNER_RADIO; | 1361 | freq->type = V4L2_TUNER_RADIO; |
| 1328 | freq->frequency = si470x_get_freq(radio); | 1362 | freq->frequency = si470x_get_freq(radio); |
| 1329 | 1363 | ||
| @@ -1340,6 +1374,8 @@ static int si470x_vidioc_s_frequency(struct file *file, void *priv, | |||
| 1340 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); | 1374 | struct si470x_device *radio = video_get_drvdata(video_devdata(file)); |
| 1341 | int retval; | 1375 | int retval; |
| 1342 | 1376 | ||
| 1377 | if (radio->disconnected) | ||
| 1378 | return -EIO; | ||
| 1343 | if (freq->type != V4L2_TUNER_RADIO) | 1379 | if (freq->type != V4L2_TUNER_RADIO) |
| 1344 | return -EINVAL; | 1380 | return -EINVAL; |
| 1345 | 1381 | ||
| @@ -1510,11 +1546,16 @@ static void si470x_usb_driver_disconnect(struct usb_interface *intf) | |||
| 1510 | { | 1546 | { |
| 1511 | struct si470x_device *radio = usb_get_intfdata(intf); | 1547 | struct si470x_device *radio = usb_get_intfdata(intf); |
| 1512 | 1548 | ||
| 1549 | mutex_lock(&open_close_lock); | ||
| 1550 | radio->disconnected = 1; | ||
| 1513 | cancel_delayed_work_sync(&radio->work); | 1551 | cancel_delayed_work_sync(&radio->work); |
| 1514 | usb_set_intfdata(intf, NULL); | 1552 | usb_set_intfdata(intf, NULL); |
| 1515 | video_unregister_device(radio->videodev); | 1553 | if (radio->users == 0) { |
| 1516 | kfree(radio->buffer); | 1554 | video_unregister_device(radio->videodev); |
| 1517 | kfree(radio); | 1555 | kfree(radio->buffer); |
| 1556 | kfree(radio); | ||
| 1557 | } | ||
| 1558 | mutex_unlock(&open_close_lock); | ||
| 1518 | } | 1559 | } |
| 1519 | 1560 | ||
| 1520 | 1561 | ||
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c index 535ffe8c8102..acc32080e9bd 100644 --- a/drivers/media/radio/radio-terratec.c +++ b/drivers/media/radio/radio-terratec.c | |||
| @@ -360,7 +360,9 @@ static const struct file_operations terratec_fops = { | |||
| 360 | .open = video_exclusive_open, | 360 | .open = video_exclusive_open, |
| 361 | .release = video_exclusive_release, | 361 | .release = video_exclusive_release, |
| 362 | .ioctl = video_ioctl2, | 362 | .ioctl = video_ioctl2, |
| 363 | #ifdef CONFIG_COMPAT | ||
| 363 | .compat_ioctl = v4l_compat_ioctl32, | 364 | .compat_ioctl = v4l_compat_ioctl32, |
| 365 | #endif | ||
| 364 | .llseek = no_llseek, | 366 | .llseek = no_llseek, |
| 365 | }; | 367 | }; |
| 366 | 368 | ||
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c index c11981fed827..4ebdfbadeb9c 100644 --- a/drivers/media/radio/radio-trust.c +++ b/drivers/media/radio/radio-trust.c | |||
| @@ -340,7 +340,9 @@ static const struct file_operations trust_fops = { | |||
| 340 | .open = video_exclusive_open, | 340 | .open = video_exclusive_open, |
| 341 | .release = video_exclusive_release, | 341 | .release = video_exclusive_release, |
| 342 | .ioctl = video_ioctl2, | 342 | .ioctl = video_ioctl2, |
| 343 | #ifdef CONFIG_COMPAT | ||
| 343 | .compat_ioctl = v4l_compat_ioctl32, | 344 | .compat_ioctl = v4l_compat_ioctl32, |
| 345 | #endif | ||
| 344 | .llseek = no_llseek, | 346 | .llseek = no_llseek, |
| 345 | }; | 347 | }; |
| 346 | 348 | ||
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c index 1366326474e5..18f2abd7e255 100644 --- a/drivers/media/radio/radio-typhoon.c +++ b/drivers/media/radio/radio-typhoon.c | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | #include <linux/init.h> /* Initdata */ | 35 | #include <linux/init.h> /* Initdata */ |
| 36 | #include <linux/ioport.h> /* request_region */ | 36 | #include <linux/ioport.h> /* request_region */ |
| 37 | #include <linux/proc_fs.h> /* radio card status report */ | 37 | #include <linux/proc_fs.h> /* radio card status report */ |
| 38 | #include <linux/seq_file.h> | ||
| 38 | #include <asm/io.h> /* outb, outb_p */ | 39 | #include <asm/io.h> /* outb, outb_p */ |
| 39 | #include <asm/uaccess.h> /* copy to/from user */ | 40 | #include <asm/uaccess.h> /* copy to/from user */ |
| 40 | #include <linux/videodev2.h> /* kernel radio structs */ | 41 | #include <linux/videodev2.h> /* kernel radio structs */ |
| @@ -93,9 +94,6 @@ static int typhoon_setfreq(struct typhoon_device *dev, unsigned long frequency); | |||
| 93 | static void typhoon_mute(struct typhoon_device *dev); | 94 | static void typhoon_mute(struct typhoon_device *dev); |
| 94 | static void typhoon_unmute(struct typhoon_device *dev); | 95 | static void typhoon_unmute(struct typhoon_device *dev); |
| 95 | static int typhoon_setvol(struct typhoon_device *dev, int vol); | 96 | static int typhoon_setvol(struct typhoon_device *dev, int vol); |
| 96 | #ifdef CONFIG_RADIO_TYPHOON_PROC_FS | ||
| 97 | static int typhoon_get_info(char *buf, char **start, off_t offset, int len); | ||
| 98 | #endif | ||
| 99 | 97 | ||
| 100 | static void typhoon_setvol_generic(struct typhoon_device *dev, int vol) | 98 | static void typhoon_setvol_generic(struct typhoon_device *dev, int vol) |
| 101 | { | 99 | { |
| @@ -340,7 +338,9 @@ static const struct file_operations typhoon_fops = { | |||
| 340 | .open = video_exclusive_open, | 338 | .open = video_exclusive_open, |
| 341 | .release = video_exclusive_release, | 339 | .release = video_exclusive_release, |
| 342 | .ioctl = video_ioctl2, | 340 | .ioctl = video_ioctl2, |
| 341 | #ifdef CONFIG_COMPAT | ||
| 343 | .compat_ioctl = v4l_compat_ioctl32, | 342 | .compat_ioctl = v4l_compat_ioctl32, |
| 343 | #endif | ||
| 344 | .llseek = no_llseek, | 344 | .llseek = no_llseek, |
| 345 | }; | 345 | }; |
| 346 | 346 | ||
| @@ -366,30 +366,39 @@ static struct video_device typhoon_radio = | |||
| 366 | 366 | ||
| 367 | #ifdef CONFIG_RADIO_TYPHOON_PROC_FS | 367 | #ifdef CONFIG_RADIO_TYPHOON_PROC_FS |
| 368 | 368 | ||
| 369 | static int typhoon_get_info(char *buf, char **start, off_t offset, int len) | 369 | static int typhoon_proc_show(struct seq_file *m, void *v) |
| 370 | { | 370 | { |
| 371 | char *out = buf; | ||
| 372 | |||
| 373 | #ifdef MODULE | 371 | #ifdef MODULE |
| 374 | #define MODULEPROCSTRING "Driver loaded as a module" | 372 | #define MODULEPROCSTRING "Driver loaded as a module" |
| 375 | #else | 373 | #else |
| 376 | #define MODULEPROCSTRING "Driver compiled into kernel" | 374 | #define MODULEPROCSTRING "Driver compiled into kernel" |
| 377 | #endif | 375 | #endif |
| 378 | 376 | ||
| 379 | /* output must be kept under PAGE_SIZE */ | 377 | seq_puts(m, BANNER); |
| 380 | out += sprintf(out, BANNER); | 378 | seq_puts(m, "Load type: " MODULEPROCSTRING "\n\n"); |
| 381 | out += sprintf(out, "Load type: " MODULEPROCSTRING "\n\n"); | 379 | seq_printf(m, "frequency = %lu kHz\n", |
| 382 | out += sprintf(out, "frequency = %lu kHz\n", | ||
| 383 | typhoon_unit.curfreq >> 4); | 380 | typhoon_unit.curfreq >> 4); |
| 384 | out += sprintf(out, "volume = %d\n", typhoon_unit.curvol); | 381 | seq_printf(m, "volume = %d\n", typhoon_unit.curvol); |
| 385 | out += sprintf(out, "mute = %s\n", typhoon_unit.muted ? | 382 | seq_printf(m, "mute = %s\n", typhoon_unit.muted ? |
| 386 | "on" : "off"); | 383 | "on" : "off"); |
| 387 | out += sprintf(out, "iobase = 0x%x\n", typhoon_unit.iobase); | 384 | seq_printf(m, "iobase = 0x%x\n", typhoon_unit.iobase); |
| 388 | out += sprintf(out, "mute frequency = %lu kHz\n", | 385 | seq_printf(m, "mute frequency = %lu kHz\n", |
| 389 | typhoon_unit.mutefreq >> 4); | 386 | typhoon_unit.mutefreq >> 4); |
| 390 | return out - buf; | 387 | return 0; |
| 391 | } | 388 | } |
| 392 | 389 | ||
| 390 | static int typhoon_proc_open(struct inode *inode, struct file *file) | ||
| 391 | { | ||
| 392 | return single_open(file, typhoon_proc_show, NULL); | ||
| 393 | } | ||
| 394 | |||
| 395 | static const struct file_operations typhoon_proc_fops = { | ||
| 396 | .owner = THIS_MODULE, | ||
| 397 | .open = typhoon_proc_open, | ||
| 398 | .read = seq_read, | ||
| 399 | .llseek = seq_lseek, | ||
| 400 | .release = single_release, | ||
| 401 | }; | ||
| 393 | #endif /* CONFIG_RADIO_TYPHOON_PROC_FS */ | 402 | #endif /* CONFIG_RADIO_TYPHOON_PROC_FS */ |
| 394 | 403 | ||
| 395 | MODULE_AUTHOR("Dr. Henrik Seidel"); | 404 | MODULE_AUTHOR("Dr. Henrik Seidel"); |
| @@ -404,7 +413,7 @@ MODULE_PARM_DESC(io, "I/O address of the Typhoon card (0x316 or 0x336)"); | |||
| 404 | module_param(radio_nr, int, 0); | 413 | module_param(radio_nr, int, 0); |
| 405 | 414 | ||
| 406 | #ifdef MODULE | 415 | #ifdef MODULE |
| 407 | static unsigned long mutefreq = 0; | 416 | static unsigned long mutefreq; |
| 408 | module_param(mutefreq, ulong, 0); | 417 | module_param(mutefreq, ulong, 0); |
| 409 | MODULE_PARM_DESC(mutefreq, "Frequency used when muting the card (in kHz)"); | 418 | MODULE_PARM_DESC(mutefreq, "Frequency used when muting the card (in kHz)"); |
| 410 | #endif | 419 | #endif |
| @@ -450,8 +459,7 @@ static int __init typhoon_init(void) | |||
| 450 | typhoon_mute(&typhoon_unit); | 459 | typhoon_mute(&typhoon_unit); |
| 451 | 460 | ||
| 452 | #ifdef CONFIG_RADIO_TYPHOON_PROC_FS | 461 | #ifdef CONFIG_RADIO_TYPHOON_PROC_FS |
| 453 | if (!create_proc_info_entry("driver/radio-typhoon", 0, NULL, | 462 | if (!proc_create("driver/radio-typhoon", 0, NULL, &typhoon_proc_fops)) |
| 454 | typhoon_get_info)) | ||
| 455 | printk(KERN_ERR "radio-typhoon: registering /proc/driver/radio-typhoon failed\n"); | 463 | printk(KERN_ERR "radio-typhoon: registering /proc/driver/radio-typhoon failed\n"); |
| 456 | #endif | 464 | #endif |
| 457 | 465 | ||
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c index 203f4373eeb8..43773c56c62f 100644 --- a/drivers/media/radio/radio-zoltrix.c +++ b/drivers/media/radio/radio-zoltrix.c | |||
| @@ -401,7 +401,9 @@ static const struct file_operations zoltrix_fops = | |||
| 401 | .open = video_exclusive_open, | 401 | .open = video_exclusive_open, |
| 402 | .release = video_exclusive_release, | 402 | .release = video_exclusive_release, |
| 403 | .ioctl = video_ioctl2, | 403 | .ioctl = video_ioctl2, |
| 404 | #ifdef CONFIG_COMPAT | ||
| 404 | .compat_ioctl = v4l_compat_ioctl32, | 405 | .compat_ioctl = v4l_compat_ioctl32, |
| 406 | #endif | ||
| 405 | .llseek = no_llseek, | 407 | .llseek = no_llseek, |
| 406 | }; | 408 | }; |
| 407 | 409 | ||
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 1832966f53f3..fe9a4cc14141 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
| @@ -270,6 +270,15 @@ config VIDEO_SAA711X | |||
| 270 | To compile this driver as a module, choose M here: the | 270 | To compile this driver as a module, choose M here: the |
| 271 | module will be called saa7115. | 271 | module will be called saa7115. |
| 272 | 272 | ||
| 273 | config VIDEO_SAA717X | ||
| 274 | tristate "Philips SAA7171/3/4 audio/video decoders" | ||
| 275 | depends on VIDEO_V4L2 && I2C | ||
| 276 | ---help--- | ||
| 277 | Support for the Philips SAA7171/3/4 audio/video decoders. | ||
| 278 | |||
| 279 | To compile this driver as a module, choose M here: the | ||
| 280 | module will be called saa717x. | ||
| 281 | |||
| 273 | config VIDEO_SAA7191 | 282 | config VIDEO_SAA7191 |
| 274 | tristate "Philips SAA7191 video decoder" | 283 | tristate "Philips SAA7191 video decoder" |
| 275 | depends on VIDEO_V4L1 && I2C | 284 | depends on VIDEO_V4L1 && I2C |
| @@ -689,6 +698,8 @@ source "drivers/media/video/cx88/Kconfig" | |||
| 689 | 698 | ||
| 690 | source "drivers/media/video/cx23885/Kconfig" | 699 | source "drivers/media/video/cx23885/Kconfig" |
| 691 | 700 | ||
| 701 | source "drivers/media/video/au0828/Kconfig" | ||
| 702 | |||
| 692 | source "drivers/media/video/ivtv/Kconfig" | 703 | source "drivers/media/video/ivtv/Kconfig" |
| 693 | 704 | ||
| 694 | config VIDEO_M32R_AR | 705 | config VIDEO_M32R_AR |
| @@ -836,4 +847,49 @@ config USB_STKWEBCAM | |||
| 836 | 847 | ||
| 837 | endif # V4L_USB_DRIVERS | 848 | endif # V4L_USB_DRIVERS |
| 838 | 849 | ||
| 850 | config SOC_CAMERA | ||
| 851 | tristate "SoC camera support" | ||
| 852 | depends on VIDEO_V4L2 | ||
| 853 | select VIDEOBUF_DMA_SG | ||
| 854 | help | ||
| 855 | SoC Camera is a common API to several cameras, not connecting | ||
| 856 | over a bus like PCI or USB. For example some i2c camera connected | ||
| 857 | directly to the data bus of an SoC. | ||
| 858 | |||
| 859 | config SOC_CAMERA_MT9M001 | ||
| 860 | tristate "mt9m001 support" | ||
| 861 | depends on SOC_CAMERA | ||
| 862 | select GPIO_PCA953X if MT9M001_PCA9536_SWITCH | ||
| 863 | help | ||
| 864 | This driver supports MT9M001 cameras from Micron, monochrome | ||
| 865 | and colour models. | ||
| 866 | |||
| 867 | config MT9M001_PCA9536_SWITCH | ||
| 868 | bool "pca9536 datawidth switch for mt9m001" | ||
| 869 | depends on SOC_CAMERA_MT9M001 && GENERIC_GPIO | ||
| 870 | help | ||
| 871 | Select this if your MT9M001 camera uses a PCA9536 I2C GPIO | ||
| 872 | extender to switch between 8 and 10 bit datawidth modes | ||
| 873 | |||
| 874 | config SOC_CAMERA_MT9V022 | ||
| 875 | tristate "mt9v022 support" | ||
| 876 | depends on SOC_CAMERA | ||
| 877 | select GPIO_PCA953X if MT9V022_PCA9536_SWITCH | ||
| 878 | help | ||
| 879 | This driver supports MT9V022 cameras from Micron | ||
| 880 | |||
| 881 | config MT9V022_PCA9536_SWITCH | ||
| 882 | bool "pca9536 datawidth switch for mt9v022" | ||
| 883 | depends on SOC_CAMERA_MT9V022 && GENERIC_GPIO | ||
| 884 | help | ||
| 885 | Select this if your MT9V022 camera uses a PCA9536 I2C GPIO | ||
| 886 | extender to switch between 8 and 10 bit datawidth modes | ||
| 887 | |||
| 888 | config VIDEO_PXA27x | ||
| 889 | tristate "PXA27x Quick Capture Interface driver" | ||
| 890 | depends on VIDEO_DEV && PXA27x | ||
| 891 | select SOC_CAMERA | ||
| 892 | ---help--- | ||
| 893 | This is a v4l2 driver for the PXA27x Quick Capture Interface | ||
| 894 | |||
| 839 | endif # VIDEO_CAPTURE_DRIVERS | 895 | endif # VIDEO_CAPTURE_DRIVERS |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 3f209b32eeac..be14227f3726 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | zr36067-objs := zoran_procfs.o zoran_device.o \ | 5 | zr36067-objs := zoran_procfs.o zoran_device.o \ |
| 6 | zoran_driver.o zoran_card.o | 6 | zoran_driver.o zoran_card.o |
| 7 | tuner-objs := tuner-core.o tuner-types.o | 7 | tuner-objs := tuner-core.o |
| 8 | 8 | ||
| 9 | msp3400-objs := msp3400-driver.o msp3400-kthreads.o | 9 | msp3400-objs := msp3400-driver.o msp3400-kthreads.o |
| 10 | 10 | ||
| @@ -38,6 +38,7 @@ obj-$(CONFIG_VIDEO_SAA7110) += saa7110.o | |||
| 38 | obj-$(CONFIG_VIDEO_SAA7111) += saa7111.o | 38 | obj-$(CONFIG_VIDEO_SAA7111) += saa7111.o |
| 39 | obj-$(CONFIG_VIDEO_SAA7114) += saa7114.o | 39 | obj-$(CONFIG_VIDEO_SAA7114) += saa7114.o |
| 40 | obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o | 40 | obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o |
| 41 | obj-$(CONFIG_VIDEO_SAA717X) += saa717x.o | ||
| 41 | obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o | 42 | obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o |
| 42 | obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o | 43 | obj-$(CONFIG_VIDEO_SAA7185) += saa7185.o |
| 43 | obj-$(CONFIG_VIDEO_SAA7191) += saa7191.o | 44 | obj-$(CONFIG_VIDEO_SAA7191) += saa7191.o |
| @@ -87,6 +88,8 @@ obj-$(CONFIG_VIDEO_TUNER) += tuner.o | |||
| 87 | 88 | ||
| 88 | obj-$(CONFIG_TUNER_XC2028) += tuner-xc2028.o | 89 | obj-$(CONFIG_TUNER_XC2028) += tuner-xc2028.o |
| 89 | obj-$(CONFIG_TUNER_SIMPLE) += tuner-simple.o | 90 | obj-$(CONFIG_TUNER_SIMPLE) += tuner-simple.o |
| 91 | # tuner-types will be merged into tuner-simple, in the future | ||
| 92 | obj-$(CONFIG_TUNER_SIMPLE) += tuner-types.o | ||
| 90 | obj-$(CONFIG_TUNER_MT20XX) += mt20xx.o | 93 | obj-$(CONFIG_TUNER_MT20XX) += mt20xx.o |
| 91 | obj-$(CONFIG_TUNER_TDA8290) += tda8290.o | 94 | obj-$(CONFIG_TUNER_TDA8290) += tda8290.o |
| 92 | obj-$(CONFIG_TUNER_TEA5767) += tea5767.o | 95 | obj-$(CONFIG_TUNER_TEA5767) += tea5767.o |
| @@ -135,5 +138,12 @@ obj-$(CONFIG_VIDEO_IVTV) += ivtv/ | |||
| 135 | obj-$(CONFIG_VIDEO_VIVI) += vivi.o | 138 | obj-$(CONFIG_VIDEO_VIVI) += vivi.o |
| 136 | obj-$(CONFIG_VIDEO_CX23885) += cx23885/ | 139 | obj-$(CONFIG_VIDEO_CX23885) += cx23885/ |
| 137 | 140 | ||
| 141 | obj-$(CONFIG_VIDEO_PXA27x) += pxa_camera.o | ||
| 142 | obj-$(CONFIG_SOC_CAMERA) += soc_camera.o | ||
| 143 | obj-$(CONFIG_SOC_CAMERA_MT9M001) += mt9m001.o | ||
| 144 | obj-$(CONFIG_SOC_CAMERA_MT9V022) += mt9v022.o | ||
| 145 | |||
| 146 | obj-$(CONFIG_VIDEO_AU0828) += au0828/ | ||
| 147 | |||
| 138 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core | 148 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core |
| 139 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends | 149 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends |
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c index fea2e723e34b..f794f2dbfb32 100644 --- a/drivers/media/video/adv7170.c +++ b/drivers/media/video/adv7170.c | |||
| @@ -56,7 +56,7 @@ MODULE_LICENSE("GPL"); | |||
| 56 | #define I2C_NAME(x) (x)->name | 56 | #define I2C_NAME(x) (x)->name |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | static int debug = 0; | 59 | static int debug; |
| 60 | module_param(debug, int, 0); | 60 | module_param(debug, int, 0); |
| 61 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 61 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 62 | 62 | ||
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c index 10d4d89623f1..8ee07a68f702 100644 --- a/drivers/media/video/adv7175.c +++ b/drivers/media/video/adv7175.c | |||
| @@ -52,7 +52,7 @@ MODULE_LICENSE("GPL"); | |||
| 52 | #define I2C_NAME(s) (s)->name | 52 | #define I2C_NAME(s) (s)->name |
| 53 | 53 | ||
| 54 | 54 | ||
| 55 | static int debug = 0; | 55 | static int debug; |
| 56 | module_param(debug, int, 0); | 56 | module_param(debug, int, 0); |
| 57 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 57 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 58 | 58 | ||
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c index c94a4d0f2804..8c7d1958856b 100644 --- a/drivers/media/video/arv.c +++ b/drivers/media/video/arv.c | |||
| @@ -125,8 +125,8 @@ static unsigned char yuv[MAX_AR_FRAME_BYTES]; | |||
| 125 | /* default frequency */ | 125 | /* default frequency */ |
| 126 | #define DEFAULT_FREQ 50 /* 50 or 75 (MHz) is available as BCLK */ | 126 | #define DEFAULT_FREQ 50 /* 50 or 75 (MHz) is available as BCLK */ |
| 127 | static int freq = DEFAULT_FREQ; /* BCLK: available 50 or 70 (MHz) */ | 127 | static int freq = DEFAULT_FREQ; /* BCLK: available 50 or 70 (MHz) */ |
| 128 | static int vga = 0; /* default mode(0:QVGA mode, other:VGA mode) */ | 128 | static int vga; /* default mode(0:QVGA mode, other:VGA mode) */ |
| 129 | static int vga_interlace = 0; /* 0 is normal mode for, else interlace mode */ | 129 | static int vga_interlace; /* 0 is normal mode for, else interlace mode */ |
| 130 | module_param(freq, int, 0); | 130 | module_param(freq, int, 0); |
| 131 | module_param(vga, int, 0); | 131 | module_param(vga, int, 0); |
| 132 | module_param(vga_interlace, int, 0); | 132 | module_param(vga_interlace, int, 0); |
| @@ -747,7 +747,9 @@ static const struct file_operations ar_fops = { | |||
| 747 | .release = video_exclusive_release, | 747 | .release = video_exclusive_release, |
| 748 | .read = ar_read, | 748 | .read = ar_read, |
| 749 | .ioctl = ar_ioctl, | 749 | .ioctl = ar_ioctl, |
| 750 | #ifdef CONFIG_COMPAT | ||
| 750 | .compat_ioctl = v4l_compat_ioctl32, | 751 | .compat_ioctl = v4l_compat_ioctl32, |
| 752 | #endif | ||
| 751 | .llseek = no_llseek, | 753 | .llseek = no_llseek, |
| 752 | }; | 754 | }; |
| 753 | 755 | ||
diff --git a/drivers/media/video/au0828/Kconfig b/drivers/media/video/au0828/Kconfig new file mode 100644 index 000000000000..c97c4bd24841 --- /dev/null +++ b/drivers/media/video/au0828/Kconfig | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | |||
| 2 | config VIDEO_AU0828 | ||
| 3 | tristate "Auvitek AU0828 support" | ||
| 4 | depends on VIDEO_DEV && I2C && INPUT | ||
| 5 | select I2C_ALGOBIT | ||
| 6 | select DVB_AU8522 if !DVB_FE_CUSTOMIZE | ||
| 7 | select DVB_TUNER_XC5000 if !DVB_FE_CUSTOMIZE | ||
| 8 | ---help--- | ||
| 9 | This is a video4linux driver for Auvitek's USB device. | ||
| 10 | |||
| 11 | To compile this driver as a module, choose M here: the | ||
| 12 | module will be called au0828 | ||
diff --git a/drivers/media/video/au0828/Makefile b/drivers/media/video/au0828/Makefile new file mode 100644 index 000000000000..9f4f572c89c5 --- /dev/null +++ b/drivers/media/video/au0828/Makefile | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | au0828-objs := au0828-core.o au0828-i2c.o au0828-cards.o au0828-dvb.o | ||
| 2 | |||
| 3 | obj-$(CONFIG_VIDEO_AU0828) += au0828.o | ||
| 4 | |||
| 5 | EXTRA_CFLAGS += -Idrivers/media/video | ||
| 6 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core | ||
| 7 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends | ||
| 8 | |||
| 9 | EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m) | ||
diff --git a/drivers/media/video/au0828/au0828-cards.c b/drivers/media/video/au0828/au0828-cards.c new file mode 100644 index 000000000000..8ca91f814277 --- /dev/null +++ b/drivers/media/video/au0828/au0828-cards.c | |||
| @@ -0,0 +1,182 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Auvitek USB bridge | ||
| 3 | * | ||
| 4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include "au0828.h" | ||
| 23 | #include "au0828-cards.h" | ||
| 24 | |||
| 25 | struct au0828_board au0828_boards[] = { | ||
| 26 | [AU0828_BOARD_UNKNOWN] = { | ||
| 27 | .name = "Unknown board", | ||
| 28 | }, | ||
| 29 | [AU0828_BOARD_HAUPPAUGE_HVR850] = { | ||
| 30 | .name = "Hauppauge HVR850", | ||
| 31 | }, | ||
| 32 | [AU0828_BOARD_HAUPPAUGE_HVR950Q] = { | ||
| 33 | .name = "Hauppauge HVR950Q", | ||
| 34 | }, | ||
| 35 | [AU0828_BOARD_DVICO_FUSIONHDTV7] = { | ||
| 36 | .name = "DViCO FusionHDTV USB", | ||
| 37 | }, | ||
| 38 | }; | ||
| 39 | const unsigned int au0828_bcount = ARRAY_SIZE(au0828_boards); | ||
| 40 | |||
| 41 | /* Tuner callback function for au0828 boards. Currently only needed | ||
| 42 | * for HVR1500Q, which has an xc5000 tuner. | ||
| 43 | */ | ||
| 44 | int au0828_tuner_callback(void *priv, int command, int arg) | ||
| 45 | { | ||
| 46 | struct au0828_dev *dev = priv; | ||
| 47 | |||
| 48 | dprintk(1, "%s()\n", __func__); | ||
| 49 | |||
| 50 | switch (dev->board) { | ||
| 51 | case AU0828_BOARD_HAUPPAUGE_HVR850: | ||
| 52 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | ||
| 53 | case AU0828_BOARD_DVICO_FUSIONHDTV7: | ||
| 54 | if (command == 0) { | ||
| 55 | /* Tuner Reset Command from xc5000 */ | ||
| 56 | /* Drive the tuner into reset and out */ | ||
| 57 | au0828_clear(dev, REG_001, 2); | ||
| 58 | mdelay(200); | ||
| 59 | au0828_set(dev, REG_001, 2); | ||
| 60 | mdelay(50); | ||
| 61 | return 0; | ||
| 62 | } else { | ||
| 63 | printk(KERN_ERR | ||
| 64 | "%s(): Unknown command.\n", __func__); | ||
| 65 | return -EINVAL; | ||
| 66 | } | ||
| 67 | break; | ||
| 68 | } | ||
| 69 | |||
| 70 | return 0; /* Should never be here */ | ||
| 71 | } | ||
| 72 | |||
| 73 | static void hauppauge_eeprom(struct au0828_dev *dev, u8 *eeprom_data) | ||
| 74 | { | ||
| 75 | struct tveeprom tv; | ||
| 76 | |||
| 77 | tveeprom_hauppauge_analog(&dev->i2c_client, &tv, eeprom_data); | ||
| 78 | |||
| 79 | /* Make sure we support the board model */ | ||
| 80 | switch (tv.model) { | ||
| 81 | case 72001: /* WinTV-HVR950q (Retail, IR, ATSC/QAM and basic analog video */ | ||
| 82 | case 72301: /* WinTV-HVR850 (Retail, IR, ATSC and basic analog video */ | ||
| 83 | break; | ||
| 84 | default: | ||
| 85 | printk(KERN_WARNING "%s: warning: " | ||
| 86 | "unknown hauppauge model #%d\n", __func__, tv.model); | ||
| 87 | break; | ||
| 88 | } | ||
| 89 | |||
| 90 | printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n", | ||
| 91 | __func__, tv.model); | ||
| 92 | } | ||
| 93 | |||
| 94 | void au0828_card_setup(struct au0828_dev *dev) | ||
| 95 | { | ||
| 96 | static u8 eeprom[256]; | ||
| 97 | |||
| 98 | dprintk(1, "%s()\n", __func__); | ||
| 99 | |||
| 100 | if (dev->i2c_rc == 0) { | ||
| 101 | dev->i2c_client.addr = 0xa0 >> 1; | ||
| 102 | tveeprom_read(&dev->i2c_client, eeprom, sizeof(eeprom)); | ||
| 103 | } | ||
| 104 | |||
| 105 | switch (dev->board) { | ||
| 106 | case AU0828_BOARD_HAUPPAUGE_HVR850: | ||
| 107 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | ||
| 108 | if (dev->i2c_rc == 0) | ||
| 109 | hauppauge_eeprom(dev, eeprom+0xa0); | ||
| 110 | break; | ||
| 111 | } | ||
| 112 | } | ||
| 113 | |||
| 114 | /* | ||
| 115 | * The bridge has between 8 and 12 gpios. | ||
| 116 | * Regs 1 and 0 deal with output enables. | ||
| 117 | * Regs 3 and 2 deal with direction. | ||
| 118 | */ | ||
| 119 | void au0828_gpio_setup(struct au0828_dev *dev) | ||
| 120 | { | ||
| 121 | dprintk(1, "%s()\n", __func__); | ||
| 122 | |||
| 123 | switch (dev->board) { | ||
| 124 | case AU0828_BOARD_HAUPPAUGE_HVR850: | ||
| 125 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | ||
| 126 | /* GPIO's | ||
| 127 | * 4 - CS5340 | ||
| 128 | * 5 - AU8522 Demodulator | ||
| 129 | * 6 - eeprom W/P | ||
| 130 | * 9 - XC5000 Tuner | ||
| 131 | */ | ||
| 132 | |||
| 133 | /* Into reset */ | ||
| 134 | au0828_write(dev, REG_003, 0x02); | ||
| 135 | au0828_write(dev, REG_002, 0x88 | 0x20); | ||
| 136 | au0828_write(dev, REG_001, 0x0); | ||
| 137 | au0828_write(dev, REG_000, 0x0); | ||
| 138 | msleep(100); | ||
| 139 | |||
| 140 | /* Out of reset */ | ||
| 141 | au0828_write(dev, REG_003, 0x02); | ||
| 142 | au0828_write(dev, REG_001, 0x02); | ||
| 143 | au0828_write(dev, REG_002, 0x88 | 0x20); | ||
| 144 | au0828_write(dev, REG_000, 0x88 | 0x20 | 0x40); | ||
| 145 | msleep(250); | ||
| 146 | break; | ||
| 147 | case AU0828_BOARD_DVICO_FUSIONHDTV7: | ||
| 148 | /* GPIO's | ||
| 149 | * 6 - ? | ||
| 150 | * 8 - AU8522 Demodulator | ||
| 151 | * 9 - XC5000 Tuner | ||
| 152 | */ | ||
| 153 | |||
| 154 | /* Into reset */ | ||
| 155 | au0828_write(dev, REG_003, 0x02); | ||
| 156 | au0828_write(dev, REG_002, 0xa0); | ||
| 157 | au0828_write(dev, REG_001, 0x0); | ||
| 158 | au0828_write(dev, REG_000, 0x0); | ||
| 159 | msleep(100); | ||
| 160 | |||
| 161 | /* Out of reset */ | ||
| 162 | au0828_write(dev, REG_003, 0x02); | ||
| 163 | au0828_write(dev, REG_002, 0xa0); | ||
| 164 | au0828_write(dev, REG_001, 0x02); | ||
| 165 | au0828_write(dev, REG_000, 0xa0); | ||
| 166 | msleep(250); | ||
| 167 | break; | ||
| 168 | } | ||
| 169 | } | ||
| 170 | |||
| 171 | /* table of devices that work with this driver */ | ||
| 172 | struct usb_device_id au0828_usb_id_table [] = { | ||
| 173 | { USB_DEVICE(0x2040, 0x7200), | ||
| 174 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR950Q }, | ||
| 175 | { USB_DEVICE(0x2040, 0x7240), | ||
| 176 | .driver_info = AU0828_BOARD_HAUPPAUGE_HVR850 }, | ||
| 177 | { USB_DEVICE(0x0fe9, 0xd620), | ||
| 178 | .driver_info = AU0828_BOARD_DVICO_FUSIONHDTV7 }, | ||
| 179 | { }, | ||
| 180 | }; | ||
| 181 | |||
| 182 | MODULE_DEVICE_TABLE(usb, au0828_usb_id_table); | ||
diff --git a/drivers/media/video/au0828/au0828-cards.h b/drivers/media/video/au0828/au0828-cards.h new file mode 100644 index 000000000000..e26f54a961d0 --- /dev/null +++ b/drivers/media/video/au0828/au0828-cards.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Auvitek USB bridge | ||
| 3 | * | ||
| 4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #define AU0828_BOARD_UNKNOWN 0 | ||
| 23 | #define AU0828_BOARD_HAUPPAUGE_HVR950Q 1 | ||
| 24 | #define AU0828_BOARD_HAUPPAUGE_HVR850 2 | ||
| 25 | #define AU0828_BOARD_DVICO_FUSIONHDTV7 3 | ||
diff --git a/drivers/media/video/au0828/au0828-core.c b/drivers/media/video/au0828/au0828-core.c new file mode 100644 index 000000000000..e65d5642cb1d --- /dev/null +++ b/drivers/media/video/au0828/au0828-core.c | |||
| @@ -0,0 +1,270 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Auvitek USB bridge | ||
| 3 | * | ||
| 4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/module.h> | ||
| 23 | #include <linux/videodev2.h> | ||
| 24 | #include <media/v4l2-common.h> | ||
| 25 | #include <linux/mutex.h> | ||
| 26 | |||
| 27 | #include "au0828.h" | ||
| 28 | |||
| 29 | /* | ||
| 30 | * 1 = General debug messages | ||
| 31 | * 2 = USB handling | ||
| 32 | * 4 = I2C related | ||
| 33 | * 8 = Bridge related | ||
| 34 | */ | ||
| 35 | unsigned int debug; | ||
| 36 | module_param(debug, int, 0644); | ||
| 37 | MODULE_PARM_DESC(debug, "enable debug messages"); | ||
| 38 | |||
| 39 | unsigned int usb_debug; | ||
| 40 | module_param(usb_debug, int, 0644); | ||
| 41 | MODULE_PARM_DESC(usb_debug, "enable usb debug messages"); | ||
| 42 | |||
| 43 | unsigned int bridge_debug; | ||
| 44 | module_param(bridge_debug, int, 0644); | ||
| 45 | MODULE_PARM_DESC(bridge_debug, "enable bridge debug messages"); | ||
| 46 | |||
| 47 | #define _AU0828_BULKPIPE 0x03 | ||
| 48 | #define _BULKPIPESIZE 0xffff | ||
| 49 | |||
| 50 | static int send_control_msg(struct au0828_dev *dev, u16 request, u32 value, | ||
| 51 | u16 index, unsigned char *cp, u16 size); | ||
| 52 | static int recv_control_msg(struct au0828_dev *dev, u16 request, u32 value, | ||
| 53 | u16 index, unsigned char *cp, u16 size); | ||
| 54 | |||
| 55 | /* USB Direction */ | ||
| 56 | #define CMD_REQUEST_IN 0x00 | ||
| 57 | #define CMD_REQUEST_OUT 0x01 | ||
| 58 | |||
| 59 | u32 au0828_readreg(struct au0828_dev *dev, u16 reg) | ||
| 60 | { | ||
| 61 | recv_control_msg(dev, CMD_REQUEST_IN, 0, reg, dev->ctrlmsg, 1); | ||
| 62 | dprintk(8, "%s(0x%x) = 0x%x\n", __func__, reg, dev->ctrlmsg[0]); | ||
| 63 | return dev->ctrlmsg[0]; | ||
| 64 | } | ||
| 65 | |||
| 66 | u32 au0828_writereg(struct au0828_dev *dev, u16 reg, u32 val) | ||
| 67 | { | ||
| 68 | dprintk(8, "%s(0x%x, 0x%x)\n", __func__, reg, val); | ||
| 69 | return send_control_msg(dev, CMD_REQUEST_OUT, val, reg, | ||
| 70 | dev->ctrlmsg, 0); | ||
| 71 | } | ||
| 72 | |||
| 73 | static void cmd_msg_dump(struct au0828_dev *dev) | ||
| 74 | { | ||
| 75 | int i; | ||
| 76 | |||
| 77 | for (i = 0; i < sizeof(dev->ctrlmsg); i += 16) | ||
| 78 | dprintk(2, "%s() %02x %02x %02x %02x %02x %02x %02x %02x " | ||
| 79 | "%02x %02x %02x %02x %02x %02x %02x %02x\n", | ||
| 80 | __func__, | ||
| 81 | dev->ctrlmsg[i+0], dev->ctrlmsg[i+1], | ||
| 82 | dev->ctrlmsg[i+2], dev->ctrlmsg[i+3], | ||
| 83 | dev->ctrlmsg[i+4], dev->ctrlmsg[i+5], | ||
| 84 | dev->ctrlmsg[i+6], dev->ctrlmsg[i+7], | ||
| 85 | dev->ctrlmsg[i+8], dev->ctrlmsg[i+9], | ||
| 86 | dev->ctrlmsg[i+10], dev->ctrlmsg[i+11], | ||
| 87 | dev->ctrlmsg[i+12], dev->ctrlmsg[i+13], | ||
| 88 | dev->ctrlmsg[i+14], dev->ctrlmsg[i+15]); | ||
| 89 | } | ||
| 90 | |||
| 91 | static int send_control_msg(struct au0828_dev *dev, u16 request, u32 value, | ||
| 92 | u16 index, unsigned char *cp, u16 size) | ||
| 93 | { | ||
| 94 | int status = -ENODEV; | ||
| 95 | mutex_lock(&dev->mutex); | ||
| 96 | if (dev->usbdev) { | ||
| 97 | |||
| 98 | /* cp must be memory that has been allocated by kmalloc */ | ||
| 99 | status = usb_control_msg(dev->usbdev, | ||
| 100 | usb_sndctrlpipe(dev->usbdev, 0), | ||
| 101 | request, | ||
| 102 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
| 103 | value, index, | ||
| 104 | cp, size, 1000); | ||
| 105 | |||
| 106 | status = min(status, 0); | ||
| 107 | |||
| 108 | if (status < 0) { | ||
| 109 | printk(KERN_ERR "%s() Failed sending control message, error %d.\n", | ||
| 110 | __func__, status); | ||
| 111 | } | ||
| 112 | |||
| 113 | } | ||
| 114 | mutex_unlock(&dev->mutex); | ||
| 115 | return status; | ||
| 116 | } | ||
| 117 | |||
| 118 | static int recv_control_msg(struct au0828_dev *dev, u16 request, u32 value, | ||
| 119 | u16 index, unsigned char *cp, u16 size) | ||
| 120 | { | ||
| 121 | int status = -ENODEV; | ||
| 122 | mutex_lock(&dev->mutex); | ||
| 123 | if (dev->usbdev) { | ||
| 124 | |||
| 125 | memset(dev->ctrlmsg, 0, sizeof(dev->ctrlmsg)); | ||
| 126 | |||
| 127 | /* cp must be memory that has been allocated by kmalloc */ | ||
| 128 | status = usb_control_msg(dev->usbdev, | ||
| 129 | usb_rcvctrlpipe(dev->usbdev, 0), | ||
| 130 | request, | ||
| 131 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | ||
| 132 | value, index, | ||
| 133 | cp, size, 1000); | ||
| 134 | |||
| 135 | status = min(status, 0); | ||
| 136 | |||
| 137 | if (status < 0) { | ||
| 138 | printk(KERN_ERR "%s() Failed receiving control message, error %d.\n", | ||
| 139 | __func__, status); | ||
| 140 | } else | ||
| 141 | cmd_msg_dump(dev); | ||
| 142 | } | ||
| 143 | mutex_unlock(&dev->mutex); | ||
| 144 | return status; | ||
| 145 | } | ||
| 146 | |||
| 147 | static void au0828_usb_disconnect(struct usb_interface *interface) | ||
| 148 | { | ||
| 149 | struct au0828_dev *dev = usb_get_intfdata(interface); | ||
| 150 | |||
| 151 | dprintk(1, "%s()\n", __func__); | ||
| 152 | |||
| 153 | /* Digital TV */ | ||
| 154 | au0828_dvb_unregister(dev); | ||
| 155 | |||
| 156 | /* I2C */ | ||
| 157 | au0828_i2c_unregister(dev); | ||
| 158 | |||
| 159 | usb_set_intfdata(interface, NULL); | ||
| 160 | |||
| 161 | mutex_lock(&dev->mutex); | ||
| 162 | dev->usbdev = NULL; | ||
| 163 | mutex_unlock(&dev->mutex); | ||
| 164 | |||
| 165 | kfree(dev); | ||
| 166 | |||
| 167 | } | ||
| 168 | |||
| 169 | static int au0828_usb_probe(struct usb_interface *interface, | ||
| 170 | const struct usb_device_id *id) | ||
| 171 | { | ||
| 172 | int ifnum; | ||
| 173 | struct au0828_dev *dev; | ||
| 174 | struct usb_device *usbdev = interface_to_usbdev(interface); | ||
| 175 | |||
| 176 | ifnum = interface->altsetting->desc.bInterfaceNumber; | ||
| 177 | |||
| 178 | if (ifnum != 0) | ||
| 179 | return -ENODEV; | ||
| 180 | |||
| 181 | dprintk(1, "%s() vendor id 0x%x device id 0x%x ifnum:%d\n", __func__, | ||
| 182 | le16_to_cpu(usbdev->descriptor.idVendor), | ||
| 183 | le16_to_cpu(usbdev->descriptor.idProduct), | ||
| 184 | ifnum); | ||
| 185 | |||
| 186 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | ||
| 187 | if (dev == NULL) { | ||
| 188 | printk(KERN_ERR "%s() Unable to allocate memory\n", __func__); | ||
| 189 | return -ENOMEM; | ||
| 190 | } | ||
| 191 | |||
| 192 | mutex_init(&dev->mutex); | ||
| 193 | mutex_init(&dev->dvb.lock); | ||
| 194 | dev->usbdev = usbdev; | ||
| 195 | dev->board = id->driver_info; | ||
| 196 | |||
| 197 | usb_set_intfdata(interface, dev); | ||
| 198 | |||
| 199 | /* Power Up the bridge */ | ||
| 200 | au0828_write(dev, REG_600, 1 << 4); | ||
| 201 | |||
| 202 | /* Bring up the GPIO's and supporting devices */ | ||
| 203 | au0828_gpio_setup(dev); | ||
| 204 | |||
| 205 | /* I2C */ | ||
| 206 | au0828_i2c_register(dev); | ||
| 207 | |||
| 208 | /* Setup */ | ||
| 209 | au0828_card_setup(dev); | ||
| 210 | |||
| 211 | /* Digital TV */ | ||
| 212 | au0828_dvb_register(dev); | ||
| 213 | |||
| 214 | printk(KERN_INFO "Registered device AU0828 [%s]\n", | ||
| 215 | au0828_boards[dev->board].name == NULL ? "Unset" : | ||
| 216 | au0828_boards[dev->board].name); | ||
| 217 | |||
| 218 | return 0; | ||
| 219 | } | ||
| 220 | |||
| 221 | static struct usb_driver au0828_usb_driver = { | ||
| 222 | .name = DRIVER_NAME, | ||
| 223 | .probe = au0828_usb_probe, | ||
| 224 | .disconnect = au0828_usb_disconnect, | ||
| 225 | .id_table = au0828_usb_id_table, | ||
| 226 | }; | ||
| 227 | |||
| 228 | static int __init au0828_init(void) | ||
| 229 | { | ||
| 230 | int ret; | ||
| 231 | |||
| 232 | if (debug) | ||
| 233 | printk(KERN_INFO "%s() Debugging is enabled\n", __func__); | ||
| 234 | |||
| 235 | if (usb_debug) { | ||
| 236 | printk(KERN_INFO "%s() USB Debugging is enabled\n", __func__); | ||
| 237 | debug |= 2; | ||
| 238 | } | ||
| 239 | |||
| 240 | if (i2c_debug) { | ||
| 241 | printk(KERN_INFO "%s() I2C Debugging is enabled\n", __func__); | ||
| 242 | debug |= 4; | ||
| 243 | } | ||
| 244 | |||
| 245 | if (bridge_debug) { | ||
| 246 | printk(KERN_INFO "%s() Bridge Debugging is enabled\n", | ||
| 247 | __func__); | ||
| 248 | debug |= 8; | ||
| 249 | } | ||
| 250 | |||
| 251 | printk(KERN_INFO "au0828 driver loaded\n"); | ||
| 252 | |||
| 253 | ret = usb_register(&au0828_usb_driver); | ||
| 254 | if (ret) | ||
| 255 | printk(KERN_ERR "usb_register failed, error = %d\n", ret); | ||
| 256 | |||
| 257 | return ret; | ||
| 258 | } | ||
| 259 | |||
| 260 | static void __exit au0828_exit(void) | ||
| 261 | { | ||
| 262 | usb_deregister(&au0828_usb_driver); | ||
| 263 | } | ||
| 264 | |||
| 265 | module_init(au0828_init); | ||
| 266 | module_exit(au0828_exit); | ||
| 267 | |||
| 268 | MODULE_DESCRIPTION("Driver for Auvitek AU0828 based products"); | ||
| 269 | MODULE_AUTHOR("Steven Toth <stoth@hauppauge.com>"); | ||
| 270 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c new file mode 100644 index 000000000000..85d0ae9a322f --- /dev/null +++ b/drivers/media/video/au0828/au0828-dvb.c | |||
| @@ -0,0 +1,373 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Auvitek USB bridge | ||
| 3 | * | ||
| 4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/module.h> | ||
| 23 | #include <linux/init.h> | ||
| 24 | #include <linux/device.h> | ||
| 25 | #include <linux/suspend.h> | ||
| 26 | #include <media/v4l2-common.h> | ||
| 27 | |||
| 28 | #include "au0828.h" | ||
| 29 | #include "au8522.h" | ||
| 30 | #include "xc5000.h" | ||
| 31 | |||
| 32 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 33 | |||
| 34 | #define _AU0828_BULKPIPE 0x83 | ||
| 35 | #define _BULKPIPESIZE 0xe522 | ||
| 36 | |||
| 37 | static struct au8522_config hauppauge_hvr950q_config = { | ||
| 38 | .demod_address = 0x8e >> 1, | ||
| 39 | .status_mode = AU8522_DEMODLOCKING, | ||
| 40 | }; | ||
| 41 | |||
| 42 | static struct xc5000_config hauppauge_hvr950q_tunerconfig = { | ||
| 43 | .i2c_address = 0x61, | ||
| 44 | .if_khz = 6000, | ||
| 45 | .tuner_callback = au0828_tuner_callback | ||
| 46 | }; | ||
| 47 | |||
| 48 | /*-------------------------------------------------------------------*/ | ||
| 49 | static void urb_completion(struct urb *purb) | ||
| 50 | { | ||
| 51 | u8 *ptr; | ||
| 52 | struct au0828_dev *dev = purb->context; | ||
| 53 | int ptype = usb_pipetype(purb->pipe); | ||
| 54 | |||
| 55 | dprintk(2, "%s()\n", __func__); | ||
| 56 | |||
| 57 | if (!dev) | ||
| 58 | return; | ||
| 59 | |||
| 60 | if (dev->urb_streaming == 0) | ||
| 61 | return; | ||
| 62 | |||
| 63 | if (ptype != PIPE_BULK) { | ||
| 64 | printk(KERN_ERR "%s() Unsupported URB type %d\n", | ||
| 65 | __func__, ptype); | ||
| 66 | return; | ||
| 67 | } | ||
| 68 | |||
| 69 | ptr = (u8 *)purb->transfer_buffer; | ||
| 70 | |||
| 71 | /* Feed the transport payload into the kernel demux */ | ||
| 72 | dvb_dmx_swfilter_packets(&dev->dvb.demux, | ||
| 73 | purb->transfer_buffer, purb->actual_length / 188); | ||
| 74 | |||
| 75 | /* Clean the buffer before we requeue */ | ||
| 76 | memset(purb->transfer_buffer, 0, URB_BUFSIZE); | ||
| 77 | |||
| 78 | /* Requeue URB */ | ||
| 79 | usb_submit_urb(purb, GFP_ATOMIC); | ||
| 80 | } | ||
| 81 | |||
| 82 | static int stop_urb_transfer(struct au0828_dev *dev) | ||
| 83 | { | ||
| 84 | int i; | ||
| 85 | |||
| 86 | dprintk(2, "%s()\n", __func__); | ||
| 87 | |||
| 88 | for (i = 0; i < URB_COUNT; i++) { | ||
| 89 | usb_kill_urb(dev->urbs[i]); | ||
| 90 | kfree(dev->urbs[i]->transfer_buffer); | ||
| 91 | usb_free_urb(dev->urbs[i]); | ||
| 92 | } | ||
| 93 | |||
| 94 | dev->urb_streaming = 0; | ||
| 95 | |||
| 96 | return 0; | ||
| 97 | } | ||
| 98 | |||
| 99 | static int start_urb_transfer(struct au0828_dev *dev) | ||
| 100 | { | ||
| 101 | struct urb *purb; | ||
| 102 | int i, ret = -ENOMEM; | ||
| 103 | |||
| 104 | dprintk(2, "%s()\n", __func__); | ||
| 105 | |||
| 106 | if (dev->urb_streaming) { | ||
| 107 | dprintk(2, "%s: iso xfer already running!\n", __func__); | ||
| 108 | return 0; | ||
| 109 | } | ||
| 110 | |||
| 111 | for (i = 0; i < URB_COUNT; i++) { | ||
| 112 | |||
| 113 | dev->urbs[i] = usb_alloc_urb(0, GFP_KERNEL); | ||
| 114 | if (!dev->urbs[i]) | ||
| 115 | goto err; | ||
| 116 | |||
| 117 | purb = dev->urbs[i]; | ||
| 118 | |||
| 119 | purb->transfer_buffer = kzalloc(URB_BUFSIZE, GFP_KERNEL); | ||
| 120 | if (!purb->transfer_buffer) { | ||
| 121 | usb_free_urb(purb); | ||
| 122 | dev->urbs[i] = 0; | ||
| 123 | goto err; | ||
| 124 | } | ||
| 125 | |||
| 126 | purb->status = -EINPROGRESS; | ||
| 127 | usb_fill_bulk_urb(purb, | ||
| 128 | dev->usbdev, | ||
| 129 | usb_rcvbulkpipe(dev->usbdev, _AU0828_BULKPIPE), | ||
| 130 | purb->transfer_buffer, | ||
| 131 | URB_BUFSIZE, | ||
| 132 | urb_completion, | ||
| 133 | dev); | ||
| 134 | |||
| 135 | } | ||
| 136 | |||
| 137 | for (i = 0; i < URB_COUNT; i++) { | ||
| 138 | ret = usb_submit_urb(dev->urbs[i], GFP_ATOMIC); | ||
| 139 | if (ret != 0) { | ||
| 140 | stop_urb_transfer(dev); | ||
| 141 | printk(KERN_ERR "%s: failed urb submission, " | ||
| 142 | "err = %d\n", __func__, ret); | ||
| 143 | return ret; | ||
| 144 | } | ||
| 145 | } | ||
| 146 | |||
| 147 | dev->urb_streaming = 1; | ||
| 148 | ret = 0; | ||
| 149 | |||
| 150 | err: | ||
| 151 | return ret; | ||
| 152 | } | ||
| 153 | |||
| 154 | static int au0828_dvb_start_feed(struct dvb_demux_feed *feed) | ||
| 155 | { | ||
| 156 | struct dvb_demux *demux = feed->demux; | ||
| 157 | struct au0828_dev *dev = (struct au0828_dev *) demux->priv; | ||
| 158 | struct au0828_dvb *dvb = &dev->dvb; | ||
| 159 | int ret = 0; | ||
| 160 | |||
| 161 | dprintk(1, "%s()\n", __func__); | ||
| 162 | |||
| 163 | if (!demux->dmx.frontend) | ||
| 164 | return -EINVAL; | ||
| 165 | |||
| 166 | if (dvb) { | ||
| 167 | mutex_lock(&dvb->lock); | ||
| 168 | if (dvb->feeding++ == 0) { | ||
| 169 | /* Start transport */ | ||
| 170 | au0828_write(dev, 0x608, 0x90); | ||
| 171 | au0828_write(dev, 0x609, 0x72); | ||
| 172 | au0828_write(dev, 0x60a, 0x71); | ||
| 173 | au0828_write(dev, 0x60b, 0x01); | ||
| 174 | ret = start_urb_transfer(dev); | ||
| 175 | } | ||
| 176 | mutex_unlock(&dvb->lock); | ||
| 177 | } | ||
| 178 | |||
| 179 | return ret; | ||
| 180 | } | ||
| 181 | |||
| 182 | static int au0828_dvb_stop_feed(struct dvb_demux_feed *feed) | ||
| 183 | { | ||
| 184 | struct dvb_demux *demux = feed->demux; | ||
| 185 | struct au0828_dev *dev = (struct au0828_dev *) demux->priv; | ||
| 186 | struct au0828_dvb *dvb = &dev->dvb; | ||
| 187 | int ret = 0; | ||
| 188 | |||
| 189 | dprintk(1, "%s()\n", __func__); | ||
| 190 | |||
| 191 | if (dvb) { | ||
| 192 | mutex_lock(&dvb->lock); | ||
| 193 | if (--dvb->feeding == 0) { | ||
| 194 | /* Stop transport */ | ||
| 195 | au0828_write(dev, 0x608, 0x00); | ||
| 196 | au0828_write(dev, 0x609, 0x00); | ||
| 197 | au0828_write(dev, 0x60a, 0x00); | ||
| 198 | au0828_write(dev, 0x60b, 0x00); | ||
| 199 | ret = stop_urb_transfer(dev); | ||
| 200 | } | ||
| 201 | mutex_unlock(&dvb->lock); | ||
| 202 | } | ||
| 203 | |||
| 204 | return ret; | ||
| 205 | } | ||
| 206 | |||
| 207 | int dvb_register(struct au0828_dev *dev) | ||
| 208 | { | ||
| 209 | struct au0828_dvb *dvb = &dev->dvb; | ||
| 210 | int result; | ||
| 211 | |||
| 212 | dprintk(1, "%s()\n", __func__); | ||
| 213 | |||
| 214 | /* register adapter */ | ||
| 215 | result = dvb_register_adapter(&dvb->adapter, DRIVER_NAME, THIS_MODULE, | ||
| 216 | &dev->usbdev->dev, adapter_nr); | ||
| 217 | if (result < 0) { | ||
| 218 | printk(KERN_ERR "%s: dvb_register_adapter failed " | ||
| 219 | "(errno = %d)\n", DRIVER_NAME, result); | ||
| 220 | goto fail_adapter; | ||
| 221 | } | ||
| 222 | dvb->adapter.priv = dev; | ||
| 223 | |||
| 224 | /* register frontend */ | ||
| 225 | result = dvb_register_frontend(&dvb->adapter, dvb->frontend); | ||
| 226 | if (result < 0) { | ||
| 227 | printk(KERN_ERR "%s: dvb_register_frontend failed " | ||
| 228 | "(errno = %d)\n", DRIVER_NAME, result); | ||
| 229 | goto fail_frontend; | ||
| 230 | } | ||
| 231 | |||
| 232 | /* register demux stuff */ | ||
| 233 | dvb->demux.dmx.capabilities = | ||
| 234 | DMX_TS_FILTERING | DMX_SECTION_FILTERING | | ||
| 235 | DMX_MEMORY_BASED_FILTERING; | ||
| 236 | dvb->demux.priv = dev; | ||
| 237 | dvb->demux.filternum = 256; | ||
| 238 | dvb->demux.feednum = 256; | ||
| 239 | dvb->demux.start_feed = au0828_dvb_start_feed; | ||
| 240 | dvb->demux.stop_feed = au0828_dvb_stop_feed; | ||
| 241 | result = dvb_dmx_init(&dvb->demux); | ||
| 242 | if (result < 0) { | ||
| 243 | printk(KERN_ERR "%s: dvb_dmx_init failed (errno = %d)\n", | ||
| 244 | DRIVER_NAME, result); | ||
| 245 | goto fail_dmx; | ||
| 246 | } | ||
| 247 | |||
| 248 | dvb->dmxdev.filternum = 256; | ||
| 249 | dvb->dmxdev.demux = &dvb->demux.dmx; | ||
| 250 | dvb->dmxdev.capabilities = 0; | ||
| 251 | result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); | ||
| 252 | if (result < 0) { | ||
| 253 | printk(KERN_ERR "%s: dvb_dmxdev_init failed (errno = %d)\n", | ||
| 254 | DRIVER_NAME, result); | ||
| 255 | goto fail_dmxdev; | ||
| 256 | } | ||
| 257 | |||
| 258 | dvb->fe_hw.source = DMX_FRONTEND_0; | ||
| 259 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
| 260 | if (result < 0) { | ||
| 261 | printk(KERN_ERR "%s: add_frontend failed " | ||
| 262 | "(DMX_FRONTEND_0, errno = %d)\n", DRIVER_NAME, result); | ||
| 263 | goto fail_fe_hw; | ||
| 264 | } | ||
| 265 | |||
| 266 | dvb->fe_mem.source = DMX_MEMORY_FE; | ||
| 267 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
| 268 | if (result < 0) { | ||
| 269 | printk(KERN_ERR "%s: add_frontend failed " | ||
| 270 | "(DMX_MEMORY_FE, errno = %d)\n", DRIVER_NAME, result); | ||
| 271 | goto fail_fe_mem; | ||
| 272 | } | ||
| 273 | |||
| 274 | result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
| 275 | if (result < 0) { | ||
| 276 | printk(KERN_ERR "%s: connect_frontend failed (errno = %d)\n", | ||
| 277 | DRIVER_NAME, result); | ||
| 278 | goto fail_fe_conn; | ||
| 279 | } | ||
| 280 | |||
| 281 | /* register network adapter */ | ||
| 282 | dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); | ||
| 283 | return 0; | ||
| 284 | |||
| 285 | fail_fe_conn: | ||
| 286 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
| 287 | fail_fe_mem: | ||
| 288 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
| 289 | fail_fe_hw: | ||
| 290 | dvb_dmxdev_release(&dvb->dmxdev); | ||
| 291 | fail_dmxdev: | ||
| 292 | dvb_dmx_release(&dvb->demux); | ||
| 293 | fail_dmx: | ||
| 294 | dvb_unregister_frontend(dvb->frontend); | ||
| 295 | fail_frontend: | ||
| 296 | dvb_frontend_detach(dvb->frontend); | ||
| 297 | dvb_unregister_adapter(&dvb->adapter); | ||
| 298 | fail_adapter: | ||
| 299 | return result; | ||
| 300 | } | ||
| 301 | |||
| 302 | void au0828_dvb_unregister(struct au0828_dev *dev) | ||
| 303 | { | ||
| 304 | struct au0828_dvb *dvb = &dev->dvb; | ||
| 305 | |||
| 306 | dprintk(1, "%s()\n", __func__); | ||
| 307 | |||
| 308 | if (dvb->frontend == NULL) | ||
| 309 | return; | ||
| 310 | |||
| 311 | dvb_net_release(&dvb->net); | ||
| 312 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
| 313 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
| 314 | dvb_dmxdev_release(&dvb->dmxdev); | ||
| 315 | dvb_dmx_release(&dvb->demux); | ||
| 316 | dvb_unregister_frontend(dvb->frontend); | ||
| 317 | dvb_frontend_detach(dvb->frontend); | ||
| 318 | dvb_unregister_adapter(&dvb->adapter); | ||
| 319 | } | ||
| 320 | |||
| 321 | /* All the DVB attach calls go here, this function get's modified | ||
| 322 | * for each new card. No other function in this file needs | ||
| 323 | * to change. | ||
| 324 | */ | ||
| 325 | int au0828_dvb_register(struct au0828_dev *dev) | ||
| 326 | { | ||
| 327 | struct au0828_dvb *dvb = &dev->dvb; | ||
| 328 | int ret; | ||
| 329 | |||
| 330 | dprintk(1, "%s()\n", __func__); | ||
| 331 | |||
| 332 | /* init frontend */ | ||
| 333 | switch (dev->board) { | ||
| 334 | case AU0828_BOARD_HAUPPAUGE_HVR850: | ||
| 335 | case AU0828_BOARD_HAUPPAUGE_HVR950Q: | ||
| 336 | case AU0828_BOARD_DVICO_FUSIONHDTV7: | ||
| 337 | dvb->frontend = dvb_attach(au8522_attach, | ||
| 338 | &hauppauge_hvr950q_config, | ||
| 339 | &dev->i2c_adap); | ||
| 340 | if (dvb->frontend != NULL) { | ||
| 341 | hauppauge_hvr950q_tunerconfig.priv = dev; | ||
| 342 | dvb_attach(xc5000_attach, dvb->frontend, | ||
| 343 | &dev->i2c_adap, | ||
| 344 | &hauppauge_hvr950q_tunerconfig); | ||
| 345 | } | ||
| 346 | break; | ||
| 347 | default: | ||
| 348 | printk(KERN_WARNING "The frontend of your DVB/ATSC card " | ||
| 349 | "isn't supported yet\n"); | ||
| 350 | break; | ||
| 351 | } | ||
| 352 | if (NULL == dvb->frontend) { | ||
| 353 | printk(KERN_ERR "%s() Frontend initialization failed\n", | ||
| 354 | __func__); | ||
| 355 | return -1; | ||
| 356 | } | ||
| 357 | |||
| 358 | /* Put the analog decoder in standby to keep it quiet */ | ||
| 359 | au0828_call_i2c_clients(dev, TUNER_SET_STANDBY, NULL); | ||
| 360 | |||
| 361 | if (dvb->frontend->ops.analog_ops.standby) | ||
| 362 | dvb->frontend->ops.analog_ops.standby(dvb->frontend); | ||
| 363 | |||
| 364 | /* register everything */ | ||
| 365 | ret = dvb_register(dev); | ||
| 366 | if (ret < 0) { | ||
| 367 | if (dvb->frontend->ops.release) | ||
| 368 | dvb->frontend->ops.release(dvb->frontend); | ||
| 369 | return ret; | ||
| 370 | } | ||
| 371 | |||
| 372 | return 0; | ||
| 373 | } | ||
diff --git a/drivers/media/video/au0828/au0828-i2c.c b/drivers/media/video/au0828/au0828-i2c.c new file mode 100644 index 000000000000..94c8b74a6651 --- /dev/null +++ b/drivers/media/video/au0828/au0828-i2c.c | |||
| @@ -0,0 +1,385 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Auvitek AU0828 USB bridge | ||
| 3 | * | ||
| 4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/module.h> | ||
| 23 | #include <linux/moduleparam.h> | ||
| 24 | #include <linux/init.h> | ||
| 25 | #include <linux/delay.h> | ||
| 26 | #include <linux/io.h> | ||
| 27 | |||
| 28 | #include "au0828.h" | ||
| 29 | |||
| 30 | #include <media/v4l2-common.h> | ||
| 31 | |||
| 32 | unsigned int i2c_debug; | ||
| 33 | module_param(i2c_debug, int, 0444); | ||
| 34 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); | ||
| 35 | |||
| 36 | unsigned int i2c_scan; | ||
| 37 | module_param(i2c_scan, int, 0444); | ||
| 38 | MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); | ||
| 39 | |||
| 40 | #define I2C_WAIT_DELAY 512 | ||
| 41 | #define I2C_WAIT_RETRY 64 | ||
| 42 | |||
| 43 | static inline int i2c_slave_did_write_ack(struct i2c_adapter *i2c_adap) | ||
| 44 | { | ||
| 45 | struct au0828_dev *dev = i2c_adap->algo_data; | ||
| 46 | return au0828_read(dev, REG_201) & 0x08 ? 0 : 1; | ||
| 47 | } | ||
| 48 | |||
| 49 | static inline int i2c_slave_did_read_ack(struct i2c_adapter *i2c_adap) | ||
| 50 | { | ||
| 51 | struct au0828_dev *dev = i2c_adap->algo_data; | ||
| 52 | return au0828_read(dev, REG_201) & 0x02 ? 0 : 1; | ||
| 53 | } | ||
| 54 | |||
| 55 | static int i2c_wait_read_ack(struct i2c_adapter *i2c_adap) | ||
| 56 | { | ||
| 57 | int count; | ||
| 58 | |||
| 59 | for (count = 0; count < I2C_WAIT_RETRY; count++) { | ||
| 60 | if (!i2c_slave_did_read_ack(i2c_adap)) | ||
| 61 | break; | ||
| 62 | udelay(I2C_WAIT_DELAY); | ||
| 63 | } | ||
| 64 | |||
| 65 | if (I2C_WAIT_RETRY == count) | ||
| 66 | return 0; | ||
| 67 | |||
| 68 | return 1; | ||
| 69 | } | ||
| 70 | |||
| 71 | static inline int i2c_is_read_busy(struct i2c_adapter *i2c_adap) | ||
| 72 | { | ||
| 73 | struct au0828_dev *dev = i2c_adap->algo_data; | ||
| 74 | return au0828_read(dev, REG_201) & 0x01 ? 0 : 1; | ||
| 75 | } | ||
| 76 | |||
| 77 | static int i2c_wait_read_done(struct i2c_adapter *i2c_adap) | ||
| 78 | { | ||
| 79 | int count; | ||
| 80 | |||
| 81 | for (count = 0; count < I2C_WAIT_RETRY; count++) { | ||
| 82 | if (!i2c_is_read_busy(i2c_adap)) | ||
| 83 | break; | ||
| 84 | udelay(I2C_WAIT_DELAY); | ||
| 85 | } | ||
| 86 | |||
| 87 | if (I2C_WAIT_RETRY == count) | ||
| 88 | return 0; | ||
| 89 | |||
| 90 | return 1; | ||
| 91 | } | ||
| 92 | |||
| 93 | static inline int i2c_is_write_done(struct i2c_adapter *i2c_adap) | ||
| 94 | { | ||
| 95 | struct au0828_dev *dev = i2c_adap->algo_data; | ||
| 96 | return au0828_read(dev, REG_201) & 0x04 ? 1 : 0; | ||
| 97 | } | ||
| 98 | |||
| 99 | static int i2c_wait_write_done(struct i2c_adapter *i2c_adap) | ||
| 100 | { | ||
| 101 | int count; | ||
| 102 | |||
| 103 | for (count = 0; count < I2C_WAIT_RETRY; count++) { | ||
| 104 | if (i2c_is_write_done(i2c_adap)) | ||
| 105 | break; | ||
| 106 | udelay(I2C_WAIT_DELAY); | ||
| 107 | } | ||
| 108 | |||
| 109 | if (I2C_WAIT_RETRY == count) | ||
| 110 | return 0; | ||
| 111 | |||
| 112 | return 1; | ||
| 113 | } | ||
| 114 | |||
| 115 | static inline int i2c_is_busy(struct i2c_adapter *i2c_adap) | ||
| 116 | { | ||
| 117 | struct au0828_dev *dev = i2c_adap->algo_data; | ||
| 118 | return au0828_read(dev, REG_201) & 0x10 ? 1 : 0; | ||
| 119 | } | ||
| 120 | |||
| 121 | static int i2c_wait_done(struct i2c_adapter *i2c_adap) | ||
| 122 | { | ||
| 123 | int count; | ||
| 124 | |||
| 125 | for (count = 0; count < I2C_WAIT_RETRY; count++) { | ||
| 126 | if (!i2c_is_busy(i2c_adap)) | ||
| 127 | break; | ||
| 128 | udelay(I2C_WAIT_DELAY); | ||
| 129 | } | ||
| 130 | |||
| 131 | if (I2C_WAIT_RETRY == count) | ||
| 132 | return 0; | ||
| 133 | |||
| 134 | return 1; | ||
| 135 | } | ||
| 136 | |||
| 137 | /* FIXME: Implement join handling correctly */ | ||
| 138 | static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | ||
| 139 | const struct i2c_msg *msg, int joined_rlen) | ||
| 140 | { | ||
| 141 | int i, strobe = 0; | ||
| 142 | struct au0828_dev *dev = i2c_adap->algo_data; | ||
| 143 | |||
| 144 | dprintk(4, "%s()\n", __func__); | ||
| 145 | |||
| 146 | au0828_write(dev, REG_2FF, 0x01); | ||
| 147 | au0828_write(dev, REG_202, 0x07); | ||
| 148 | |||
| 149 | /* Hardware needs 8 bit addresses */ | ||
| 150 | au0828_write(dev, REG_203, msg->addr << 1); | ||
| 151 | |||
| 152 | dprintk(4, "SEND: %02x\n", msg->addr); | ||
| 153 | |||
| 154 | for (i = 0; i < msg->len;) { | ||
| 155 | |||
| 156 | dprintk(4, " %02x\n", msg->buf[i]); | ||
| 157 | |||
| 158 | au0828_write(dev, REG_205, msg->buf[i]); | ||
| 159 | |||
| 160 | strobe++; | ||
| 161 | i++; | ||
| 162 | |||
| 163 | if ((strobe >= 4) || (i >= msg->len)) { | ||
| 164 | |||
| 165 | /* Strobe the byte into the bus */ | ||
| 166 | if (i < msg->len) | ||
| 167 | au0828_write(dev, REG_200, 0x41); | ||
| 168 | else | ||
| 169 | au0828_write(dev, REG_200, 0x01); | ||
| 170 | |||
| 171 | /* Reset strobe trigger */ | ||
| 172 | strobe = 0; | ||
| 173 | |||
| 174 | if (!i2c_wait_write_done(i2c_adap)) | ||
| 175 | return -EIO; | ||
| 176 | |||
| 177 | } | ||
| 178 | |||
| 179 | } | ||
| 180 | if (!i2c_wait_done(i2c_adap)) | ||
| 181 | return -EIO; | ||
| 182 | |||
| 183 | dprintk(4, "\n"); | ||
| 184 | |||
| 185 | return msg->len; | ||
| 186 | } | ||
| 187 | |||
| 188 | /* FIXME: Implement join handling correctly */ | ||
| 189 | static int i2c_readbytes(struct i2c_adapter *i2c_adap, | ||
| 190 | const struct i2c_msg *msg, int joined) | ||
| 191 | { | ||
| 192 | struct au0828_dev *dev = i2c_adap->algo_data; | ||
| 193 | int i; | ||
| 194 | |||
| 195 | dprintk(4, "%s()\n", __func__); | ||
| 196 | |||
| 197 | au0828_write(dev, REG_2FF, 0x01); | ||
| 198 | au0828_write(dev, REG_202, 0x07); | ||
| 199 | |||
| 200 | /* Hardware needs 8 bit addresses */ | ||
| 201 | au0828_write(dev, REG_203, msg->addr << 1); | ||
| 202 | |||
| 203 | dprintk(4, " RECV:\n"); | ||
| 204 | |||
| 205 | /* Deal with i2c_scan */ | ||
| 206 | if (msg->len == 0) { | ||
| 207 | au0828_write(dev, REG_200, 0x20); | ||
| 208 | if (i2c_wait_read_ack(i2c_adap)) | ||
| 209 | return -EIO; | ||
| 210 | return 0; | ||
| 211 | } | ||
| 212 | |||
| 213 | for (i = 0; i < msg->len;) { | ||
| 214 | |||
| 215 | i++; | ||
| 216 | |||
| 217 | if (i < msg->len) | ||
| 218 | au0828_write(dev, REG_200, 0x60); | ||
| 219 | else | ||
| 220 | au0828_write(dev, REG_200, 0x20); | ||
| 221 | |||
| 222 | if (!i2c_wait_read_done(i2c_adap)) | ||
| 223 | return -EIO; | ||
| 224 | |||
| 225 | msg->buf[i-1] = au0828_read(dev, REG_209) & 0xff; | ||
| 226 | |||
| 227 | dprintk(4, " %02x\n", msg->buf[i-1]); | ||
| 228 | } | ||
| 229 | if (!i2c_wait_done(i2c_adap)) | ||
| 230 | return -EIO; | ||
| 231 | |||
| 232 | dprintk(4, "\n"); | ||
| 233 | |||
| 234 | return msg->len; | ||
| 235 | } | ||
| 236 | |||
| 237 | static int i2c_xfer(struct i2c_adapter *i2c_adap, | ||
| 238 | struct i2c_msg *msgs, int num) | ||
| 239 | { | ||
| 240 | int i, retval = 0; | ||
| 241 | |||
| 242 | dprintk(4, "%s(num = %d)\n", __func__, num); | ||
| 243 | |||
| 244 | for (i = 0; i < num; i++) { | ||
| 245 | dprintk(4, "%s(num = %d) addr = 0x%02x len = 0x%x\n", | ||
| 246 | __func__, num, msgs[i].addr, msgs[i].len); | ||
| 247 | if (msgs[i].flags & I2C_M_RD) { | ||
| 248 | /* read */ | ||
| 249 | retval = i2c_readbytes(i2c_adap, &msgs[i], 0); | ||
| 250 | } else if (i + 1 < num && (msgs[i + 1].flags & I2C_M_RD) && | ||
| 251 | msgs[i].addr == msgs[i + 1].addr) { | ||
| 252 | /* write then read from same address */ | ||
| 253 | retval = i2c_sendbytes(i2c_adap, &msgs[i], | ||
| 254 | msgs[i + 1].len); | ||
| 255 | if (retval < 0) | ||
| 256 | goto err; | ||
| 257 | i++; | ||
| 258 | retval = i2c_readbytes(i2c_adap, &msgs[i], 1); | ||
| 259 | } else { | ||
| 260 | /* write */ | ||
| 261 | retval = i2c_sendbytes(i2c_adap, &msgs[i], 0); | ||
| 262 | } | ||
| 263 | if (retval < 0) | ||
| 264 | goto err; | ||
| 265 | } | ||
| 266 | return num; | ||
| 267 | |||
| 268 | err: | ||
| 269 | return retval; | ||
| 270 | } | ||
| 271 | |||
| 272 | static int attach_inform(struct i2c_client *client) | ||
| 273 | { | ||
| 274 | dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n", | ||
| 275 | client->driver->driver.name, client->addr, client->name); | ||
| 276 | |||
| 277 | if (!client->driver->command) | ||
| 278 | return 0; | ||
| 279 | |||
| 280 | return 0; | ||
| 281 | } | ||
| 282 | |||
| 283 | static int detach_inform(struct i2c_client *client) | ||
| 284 | { | ||
| 285 | dprintk(1, "i2c detach [client=%s]\n", client->name); | ||
| 286 | |||
| 287 | return 0; | ||
| 288 | } | ||
| 289 | |||
| 290 | void au0828_call_i2c_clients(struct au0828_dev *dev, | ||
| 291 | unsigned int cmd, void *arg) | ||
| 292 | { | ||
| 293 | if (dev->i2c_rc != 0) | ||
| 294 | return; | ||
| 295 | |||
| 296 | i2c_clients_command(&dev->i2c_adap, cmd, arg); | ||
| 297 | } | ||
| 298 | |||
| 299 | static u32 au0828_functionality(struct i2c_adapter *adap) | ||
| 300 | { | ||
| 301 | return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C; | ||
| 302 | } | ||
| 303 | |||
| 304 | static struct i2c_algorithm au0828_i2c_algo_template = { | ||
| 305 | .master_xfer = i2c_xfer, | ||
| 306 | .functionality = au0828_functionality, | ||
| 307 | }; | ||
| 308 | |||
| 309 | /* ----------------------------------------------------------------------- */ | ||
| 310 | |||
| 311 | static struct i2c_adapter au0828_i2c_adap_template = { | ||
| 312 | .name = DRIVER_NAME, | ||
| 313 | .owner = THIS_MODULE, | ||
| 314 | .id = I2C_HW_B_AU0828, | ||
| 315 | .algo = &au0828_i2c_algo_template, | ||
| 316 | .class = I2C_CLASS_TV_ANALOG, | ||
| 317 | .client_register = attach_inform, | ||
| 318 | .client_unregister = detach_inform, | ||
| 319 | }; | ||
| 320 | |||
| 321 | static struct i2c_client au0828_i2c_client_template = { | ||
| 322 | .name = "au0828 internal", | ||
| 323 | }; | ||
| 324 | |||
| 325 | static char *i2c_devs[128] = { | ||
| 326 | [0x8e >> 1] = "au8522", | ||
| 327 | [0xa0 >> 1] = "eeprom", | ||
| 328 | [0xc2 >> 1] = "tuner/xc5000", | ||
| 329 | }; | ||
| 330 | |||
| 331 | static void do_i2c_scan(char *name, struct i2c_client *c) | ||
| 332 | { | ||
| 333 | unsigned char buf; | ||
| 334 | int i, rc; | ||
| 335 | |||
| 336 | for (i = 0; i < 128; i++) { | ||
| 337 | c->addr = i; | ||
| 338 | rc = i2c_master_recv(c, &buf, 0); | ||
| 339 | if (rc < 0) | ||
| 340 | continue; | ||
| 341 | printk(KERN_INFO "%s: i2c scan: found device @ 0x%x [%s]\n", | ||
| 342 | name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???"); | ||
| 343 | } | ||
| 344 | } | ||
| 345 | |||
| 346 | /* init + register i2c algo-bit adapter */ | ||
| 347 | int au0828_i2c_register(struct au0828_dev *dev) | ||
| 348 | { | ||
| 349 | dprintk(1, "%s()\n", __func__); | ||
| 350 | |||
| 351 | memcpy(&dev->i2c_adap, &au0828_i2c_adap_template, | ||
| 352 | sizeof(dev->i2c_adap)); | ||
| 353 | memcpy(&dev->i2c_algo, &au0828_i2c_algo_template, | ||
| 354 | sizeof(dev->i2c_algo)); | ||
| 355 | memcpy(&dev->i2c_client, &au0828_i2c_client_template, | ||
| 356 | sizeof(dev->i2c_client)); | ||
| 357 | |||
| 358 | dev->i2c_adap.dev.parent = &dev->usbdev->dev; | ||
| 359 | |||
| 360 | strlcpy(dev->i2c_adap.name, DRIVER_NAME, | ||
| 361 | sizeof(dev->i2c_adap.name)); | ||
| 362 | |||
| 363 | dev->i2c_algo.data = dev; | ||
| 364 | dev->i2c_adap.algo_data = dev; | ||
| 365 | i2c_set_adapdata(&dev->i2c_adap, dev); | ||
| 366 | i2c_add_adapter(&dev->i2c_adap); | ||
| 367 | |||
| 368 | dev->i2c_client.adapter = &dev->i2c_adap; | ||
| 369 | |||
| 370 | if (0 == dev->i2c_rc) { | ||
| 371 | printk(KERN_INFO "%s: i2c bus registered\n", DRIVER_NAME); | ||
| 372 | if (i2c_scan) | ||
| 373 | do_i2c_scan(DRIVER_NAME, &dev->i2c_client); | ||
| 374 | } else | ||
| 375 | printk(KERN_INFO "%s: i2c bus register FAILED\n", DRIVER_NAME); | ||
| 376 | |||
| 377 | return dev->i2c_rc; | ||
| 378 | } | ||
| 379 | |||
| 380 | int au0828_i2c_unregister(struct au0828_dev *dev) | ||
| 381 | { | ||
| 382 | i2c_del_adapter(&dev->i2c_adap); | ||
| 383 | return 0; | ||
| 384 | } | ||
| 385 | |||
diff --git a/drivers/media/video/au0828/au0828-reg.h b/drivers/media/video/au0828/au0828-reg.h new file mode 100644 index 000000000000..39827550891c --- /dev/null +++ b/drivers/media/video/au0828/au0828-reg.h | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Auvitek USB bridge | ||
| 3 | * | ||
| 4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* We'll start to rename these registers once we have a better | ||
| 23 | * understanding of their meaning. | ||
| 24 | */ | ||
| 25 | #define REG_000 0x000 | ||
| 26 | #define REG_001 0x001 | ||
| 27 | #define REG_002 0x002 | ||
| 28 | #define REG_003 0x003 | ||
| 29 | |||
| 30 | #define REG_200 0x200 | ||
| 31 | #define REG_201 0x201 | ||
| 32 | #define REG_202 0x202 | ||
| 33 | #define REG_203 0x203 | ||
| 34 | #define REG_205 0x205 | ||
| 35 | #define REG_209 0x209 | ||
| 36 | #define REG_2FF 0x2ff | ||
| 37 | |||
| 38 | #define REG_600 0x600 | ||
diff --git a/drivers/media/video/au0828/au0828.h b/drivers/media/video/au0828/au0828.h new file mode 100644 index 000000000000..0200b9fc5dc4 --- /dev/null +++ b/drivers/media/video/au0828/au0828.h | |||
| @@ -0,0 +1,128 @@ | |||
| 1 | /* | ||
| 2 | * Driver for the Auvitek AU0828 USB bridge | ||
| 3 | * | ||
| 4 | * Copyright (c) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * | ||
| 15 | * GNU General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License | ||
| 18 | * along with this program; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 20 | */ | ||
| 21 | |||
| 22 | #include <linux/usb.h> | ||
| 23 | #include <linux/i2c.h> | ||
| 24 | #include <linux/i2c-algo-bit.h> | ||
| 25 | #include <media/tveeprom.h> | ||
| 26 | |||
| 27 | /* DVB */ | ||
| 28 | #include "demux.h" | ||
| 29 | #include "dmxdev.h" | ||
| 30 | #include "dvb_demux.h" | ||
| 31 | #include "dvb_frontend.h" | ||
| 32 | #include "dvb_net.h" | ||
| 33 | #include "dvbdev.h" | ||
| 34 | |||
| 35 | #include "au0828-reg.h" | ||
| 36 | #include "au0828-cards.h" | ||
| 37 | |||
| 38 | #define DRIVER_NAME "au0828" | ||
| 39 | #define URB_COUNT 16 | ||
| 40 | #define URB_BUFSIZE (0xe522) | ||
| 41 | |||
| 42 | struct au0828_board { | ||
| 43 | char *name; | ||
| 44 | }; | ||
| 45 | |||
| 46 | struct au0828_dvb { | ||
| 47 | struct mutex lock; | ||
| 48 | struct dvb_adapter adapter; | ||
| 49 | struct dvb_frontend *frontend; | ||
| 50 | struct dvb_demux demux; | ||
| 51 | struct dmxdev dmxdev; | ||
| 52 | struct dmx_frontend fe_hw; | ||
| 53 | struct dmx_frontend fe_mem; | ||
| 54 | struct dvb_net net; | ||
| 55 | int feeding; | ||
| 56 | }; | ||
| 57 | |||
| 58 | struct au0828_dev { | ||
| 59 | struct mutex mutex; | ||
| 60 | struct usb_device *usbdev; | ||
| 61 | int board; | ||
| 62 | u8 ctrlmsg[64]; | ||
| 63 | |||
| 64 | /* I2C */ | ||
| 65 | struct i2c_adapter i2c_adap; | ||
| 66 | struct i2c_algo_bit_data i2c_algo; | ||
| 67 | struct i2c_client i2c_client; | ||
| 68 | u32 i2c_rc; | ||
| 69 | |||
| 70 | /* Digital */ | ||
| 71 | struct au0828_dvb dvb; | ||
| 72 | |||
| 73 | /* USB / URB Related */ | ||
| 74 | int urb_streaming; | ||
| 75 | struct urb *urbs[URB_COUNT]; | ||
| 76 | |||
| 77 | }; | ||
| 78 | |||
| 79 | struct au0828_buff { | ||
| 80 | struct au0828_dev *dev; | ||
| 81 | struct urb *purb; | ||
| 82 | struct list_head buff_list; | ||
| 83 | }; | ||
| 84 | |||
| 85 | /* ----------------------------------------------------------- */ | ||
| 86 | #define au0828_read(dev, reg) au0828_readreg(dev, reg) | ||
| 87 | #define au0828_write(dev, reg, value) au0828_writereg(dev, reg, value) | ||
| 88 | #define au0828_andor(dev, reg, mask, value) \ | ||
| 89 | au0828_writereg(dev, reg, \ | ||
| 90 | (au0828_readreg(dev, reg) & ~(mask)) | ((value) & (mask))) | ||
| 91 | |||
| 92 | #define au0828_set(dev, reg, bit) au0828_andor(dev, (reg), (bit), (bit)) | ||
| 93 | #define au0828_clear(dev, reg, bit) au0828_andor(dev, (reg), (bit), 0) | ||
| 94 | |||
| 95 | /* ----------------------------------------------------------- */ | ||
| 96 | /* au0828-core.c */ | ||
| 97 | extern u32 au0828_read(struct au0828_dev *dev, u16 reg); | ||
| 98 | extern u32 au0828_write(struct au0828_dev *dev, u16 reg, u32 val); | ||
| 99 | extern unsigned int debug; | ||
| 100 | extern unsigned int usb_debug; | ||
| 101 | extern unsigned int bridge_debug; | ||
| 102 | |||
| 103 | /* ----------------------------------------------------------- */ | ||
| 104 | /* au0828-cards.c */ | ||
| 105 | extern struct au0828_board au0828_boards[]; | ||
| 106 | extern struct usb_device_id au0828_usb_id_table[]; | ||
| 107 | extern const unsigned int au0828_bcount; | ||
| 108 | extern void au0828_gpio_setup(struct au0828_dev *dev); | ||
| 109 | extern int au0828_tuner_callback(void *priv, int command, int arg); | ||
| 110 | extern void au0828_card_setup(struct au0828_dev *dev); | ||
| 111 | |||
| 112 | /* ----------------------------------------------------------- */ | ||
| 113 | /* au0828-i2c.c */ | ||
| 114 | extern int au0828_i2c_register(struct au0828_dev *dev); | ||
| 115 | extern int au0828_i2c_unregister(struct au0828_dev *dev); | ||
| 116 | extern void au0828_call_i2c_clients(struct au0828_dev *dev, | ||
| 117 | unsigned int cmd, void *arg); | ||
| 118 | extern unsigned int i2c_debug; | ||
| 119 | |||
| 120 | /* ----------------------------------------------------------- */ | ||
| 121 | /* au0828-dvb.c */ | ||
| 122 | extern int au0828_dvb_register(struct au0828_dev *dev); | ||
| 123 | extern void au0828_dvb_unregister(struct au0828_dev *dev); | ||
| 124 | |||
| 125 | #define dprintk(level, fmt, arg...)\ | ||
| 126 | do { if (debug & level)\ | ||
| 127 | printk(KERN_DEBUG DRIVER_NAME "/0: " fmt, ## arg);\ | ||
| 128 | } while (0) | ||
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c index e663cc045c41..8bfd5c75cb3a 100644 --- a/drivers/media/video/bt819.c +++ b/drivers/media/video/bt819.c | |||
| @@ -57,7 +57,7 @@ MODULE_LICENSE("GPL"); | |||
| 57 | #define I2C_NAME(s) (s)->name | 57 | #define I2C_NAME(s) (s)->name |
| 58 | 58 | ||
| 59 | 59 | ||
| 60 | static int debug = 0; | 60 | static int debug; |
| 61 | module_param(debug, int, 0); | 61 | module_param(debug, int, 0); |
| 62 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 62 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 63 | 63 | ||
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c index 7dee2e3235ad..98ee2d8feb34 100644 --- a/drivers/media/video/bt856.c +++ b/drivers/media/video/bt856.c | |||
| @@ -56,7 +56,7 @@ MODULE_LICENSE("GPL"); | |||
| 56 | #define I2C_NAME(s) (s)->name | 56 | #define I2C_NAME(s) (s)->name |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | static int debug = 0; | 59 | static int debug; |
| 60 | module_param(debug, int, 0); | 60 | module_param(debug, int, 0); |
| 61 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 61 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 62 | 62 | ||
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c index 7374c02dd183..f20a01cfc73e 100644 --- a/drivers/media/video/bt8xx/bttv-cards.c +++ b/drivers/media/video/bt8xx/bttv-cards.c | |||
| @@ -71,6 +71,8 @@ static void kodicom4400r_init(struct bttv *btv); | |||
| 71 | static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input); | 71 | static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input); |
| 72 | static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input); | 72 | static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input); |
| 73 | 73 | ||
| 74 | static void geovision_muxsel(struct bttv *btv, unsigned int input); | ||
| 75 | |||
| 74 | static int terratec_active_radio_upgrade(struct bttv *btv); | 76 | static int terratec_active_radio_upgrade(struct bttv *btv); |
| 75 | static int tea5757_read(struct bttv *btv); | 77 | static int tea5757_read(struct bttv *btv); |
| 76 | static int tea5757_write(struct bttv *btv, int value); | 78 | static int tea5757_write(struct bttv *btv, int value); |
| @@ -301,6 +303,7 @@ static struct CARD { | |||
| 301 | { 0xd50018ac, BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE, "DViCO FusionHDTV 5 Lite" }, | 303 | { 0xd50018ac, BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE, "DViCO FusionHDTV 5 Lite" }, |
| 302 | { 0x00261822, BTTV_BOARD_TWINHAN_DST, "DNTV Live! Mini "}, | 304 | { 0x00261822, BTTV_BOARD_TWINHAN_DST, "DNTV Live! Mini "}, |
| 303 | { 0xd200dbc0, BTTV_BOARD_DVICO_FUSIONHDTV_2, "DViCO FusionHDTV 2" }, | 305 | { 0xd200dbc0, BTTV_BOARD_DVICO_FUSIONHDTV_2, "DViCO FusionHDTV 2" }, |
| 306 | { 0x763c008a, BTTV_BOARD_GEOVISION_GV600, "GeoVision GV-600" }, | ||
| 304 | 307 | ||
| 305 | { 0, -1, NULL } | 308 | { 0, -1, NULL } |
| 306 | }; | 309 | }; |
| @@ -576,6 +579,8 @@ struct tvcard bttv_tvcards[] = { | |||
| 576 | .needs_tvaudio = 1, | 579 | .needs_tvaudio = 1, |
| 577 | .pll = PLL_28, | 580 | .pll = PLL_28, |
| 578 | .tuner_type = UNSET, | 581 | .tuner_type = UNSET, |
| 582 | .tuner_addr = ADDR_UNSET, | ||
| 583 | .radio_addr = ADDR_UNSET, | ||
| 579 | }, | 584 | }, |
| 580 | [BTTV_BOARD_WINVIEW_601] = { | 585 | [BTTV_BOARD_WINVIEW_601] = { |
| 581 | .name = "Leadtek WinView 601", | 586 | .name = "Leadtek WinView 601", |
| @@ -2322,7 +2327,7 @@ struct tvcard bttv_tvcards[] = { | |||
| 2322 | .tuner = 0, | 2327 | .tuner = 0, |
| 2323 | .svhs = 2, | 2328 | .svhs = 2, |
| 2324 | .muxsel = { 2, 3, 1, 0 }, | 2329 | .muxsel = { 2, 3, 1, 0 }, |
| 2325 | .tuner_type = TUNER_PHILIPS_ATSC, | 2330 | .tuner_type = TUNER_PHILIPS_FCV1236D, |
| 2326 | .tuner_addr = ADDR_UNSET, | 2331 | .tuner_addr = ADDR_UNSET, |
| 2327 | .radio_addr = ADDR_UNSET, | 2332 | .radio_addr = ADDR_UNSET, |
| 2328 | .has_dvb = 1, | 2333 | .has_dvb = 1, |
| @@ -2961,7 +2966,7 @@ struct tvcard bttv_tvcards[] = { | |||
| 2961 | [BTTV_BOARD_DVICO_FUSIONHDTV_2] = { | 2966 | [BTTV_BOARD_DVICO_FUSIONHDTV_2] = { |
| 2962 | .name = "DViCO FusionHDTV 2", | 2967 | .name = "DViCO FusionHDTV 2", |
| 2963 | .tuner = 0, | 2968 | .tuner = 0, |
| 2964 | .tuner_type = TUNER_PHILIPS_ATSC, /* FCV1236D */ | 2969 | .tuner_type = TUNER_PHILIPS_FCV1236D, |
| 2965 | .tuner_addr = ADDR_UNSET, | 2970 | .tuner_addr = ADDR_UNSET, |
| 2966 | .radio_addr = ADDR_UNSET, | 2971 | .radio_addr = ADDR_UNSET, |
| 2967 | .video_inputs = 3, | 2972 | .video_inputs = 3, |
| @@ -2992,6 +2997,45 @@ struct tvcard bttv_tvcards[] = { | |||
| 2992 | .tuner_addr = ADDR_UNSET, | 2997 | .tuner_addr = ADDR_UNSET, |
| 2993 | .radio_addr = ADDR_UNSET, | 2998 | .radio_addr = ADDR_UNSET, |
| 2994 | }, | 2999 | }, |
| 3000 | [BTTV_BOARD_GEOVISION_GV600] = { | ||
| 3001 | /* emhn@usb.ve */ | ||
| 3002 | .name = "Geovision GV-600", | ||
| 3003 | .video_inputs = 16, | ||
| 3004 | .audio_inputs = 0, | ||
| 3005 | .tuner = UNSET, | ||
| 3006 | .svhs = UNSET, | ||
| 3007 | .gpiomask = 0x0, | ||
| 3008 | .muxsel = { 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 3009 | 2, 2, 2, 2, 2, 2, 2, 2 }, | ||
| 3010 | .muxsel_hook = geovision_muxsel, | ||
| 3011 | .gpiomux = { 0 }, | ||
| 3012 | .no_msp34xx = 1, | ||
| 3013 | .pll = PLL_28, | ||
| 3014 | .tuner_type = UNSET, | ||
| 3015 | .tuner_addr = ADDR_UNSET, | ||
| 3016 | .radio_addr = ADDR_UNSET, | ||
| 3017 | }, | ||
| 3018 | [BTTV_BOARD_KOZUMI_KTV_01C] = { | ||
| 3019 | /* Mauro Lacy <mauro@lacy.com.ar> | ||
| 3020 | * Based on MagicTV and Conceptronic CONTVFMi */ | ||
| 3021 | |||
| 3022 | .name = "Kozumi KTV-01C", | ||
| 3023 | .video_inputs = 3, | ||
| 3024 | .audio_inputs = 1, | ||
| 3025 | .tuner = 0, | ||
| 3026 | .svhs = 2, | ||
| 3027 | .gpiomask = 0x008007, | ||
| 3028 | .muxsel = { 2, 3, 1, 1 }, | ||
| 3029 | .gpiomux = { 0, 1, 2, 2 }, /* CONTVFMi */ | ||
| 3030 | .gpiomute = 3, /* CONTVFMi */ | ||
| 3031 | .needs_tvaudio = 0, | ||
| 3032 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, /* TCL MK3 */ | ||
| 3033 | .tuner_addr = ADDR_UNSET, | ||
| 3034 | .radio_addr = ADDR_UNSET, | ||
| 3035 | .pll = PLL_28, | ||
| 3036 | .has_radio = 1, | ||
| 3037 | .has_remote = 1, | ||
| 3038 | }, | ||
| 2995 | }; | 3039 | }; |
| 2996 | 3040 | ||
| 2997 | static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards); | 3041 | static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards); |
| @@ -3331,6 +3375,13 @@ static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input) | |||
| 3331 | gpio_bits( 3<<9, inmux<<9 ); | 3375 | gpio_bits( 3<<9, inmux<<9 ); |
| 3332 | } | 3376 | } |
| 3333 | 3377 | ||
| 3378 | static void geovision_muxsel(struct bttv *btv, unsigned int input) | ||
| 3379 | { | ||
| 3380 | unsigned int inmux = input % 16; | ||
| 3381 | gpio_inout(0xf, 0xf); | ||
| 3382 | gpio_bits(0xf, inmux); | ||
| 3383 | } | ||
| 3384 | |||
| 3334 | /* ----------------------------------------------------------------------- */ | 3385 | /* ----------------------------------------------------------------------- */ |
| 3335 | 3386 | ||
| 3336 | static void bttv_reset_audio(struct bttv *btv) | 3387 | static void bttv_reset_audio(struct bttv *btv) |
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c index fcf8f2d208a8..2ca3e9cfb2bb 100644 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ b/drivers/media/video/bt8xx/bttv-driver.c | |||
| @@ -2372,7 +2372,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv, | |||
| 2372 | if (check_btres(fh, RESOURCE_OVERLAY)) { | 2372 | if (check_btres(fh, RESOURCE_OVERLAY)) { |
| 2373 | struct bttv_buffer *new; | 2373 | struct bttv_buffer *new; |
| 2374 | 2374 | ||
| 2375 | new = videobuf_pci_alloc(sizeof(*new)); | 2375 | new = videobuf_sg_alloc(sizeof(*new)); |
| 2376 | new->crop = btv->crop[!!fh->do_crop].rect; | 2376 | new->crop = btv->crop[!!fh->do_crop].rect; |
| 2377 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); | 2377 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); |
| 2378 | retval = bttv_switch_overlay(btv,fh,new); | 2378 | retval = bttv_switch_overlay(btv,fh,new); |
| @@ -2760,7 +2760,7 @@ static int bttv_overlay(struct file *file, void *f, unsigned int on) | |||
| 2760 | mutex_lock(&fh->cap.vb_lock); | 2760 | mutex_lock(&fh->cap.vb_lock); |
| 2761 | if (on) { | 2761 | if (on) { |
| 2762 | fh->ov.tvnorm = btv->tvnorm; | 2762 | fh->ov.tvnorm = btv->tvnorm; |
| 2763 | new = videobuf_pci_alloc(sizeof(*new)); | 2763 | new = videobuf_sg_alloc(sizeof(*new)); |
| 2764 | new->crop = btv->crop[!!fh->do_crop].rect; | 2764 | new->crop = btv->crop[!!fh->do_crop].rect; |
| 2765 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); | 2765 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); |
| 2766 | } else { | 2766 | } else { |
| @@ -2834,7 +2834,7 @@ static int bttv_s_fbuf(struct file *file, void *f, | |||
| 2834 | if (check_btres(fh, RESOURCE_OVERLAY)) { | 2834 | if (check_btres(fh, RESOURCE_OVERLAY)) { |
| 2835 | struct bttv_buffer *new; | 2835 | struct bttv_buffer *new; |
| 2836 | 2836 | ||
| 2837 | new = videobuf_pci_alloc(sizeof(*new)); | 2837 | new = videobuf_sg_alloc(sizeof(*new)); |
| 2838 | new->crop = btv->crop[!!fh->do_crop].rect; | 2838 | new->crop = btv->crop[!!fh->do_crop].rect; |
| 2839 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); | 2839 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); |
| 2840 | retval = bttv_switch_overlay(btv, fh, new); | 2840 | retval = bttv_switch_overlay(btv, fh, new); |
| @@ -3117,12 +3117,18 @@ static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop) | |||
| 3117 | 3117 | ||
| 3118 | static int bttv_g_audio(struct file *file, void *priv, struct v4l2_audio *a) | 3118 | static int bttv_g_audio(struct file *file, void *priv, struct v4l2_audio *a) |
| 3119 | { | 3119 | { |
| 3120 | if (unlikely(a->index)) | ||
| 3121 | return -EINVAL; | ||
| 3122 | |||
| 3120 | strcpy(a->name, "audio"); | 3123 | strcpy(a->name, "audio"); |
| 3121 | return 0; | 3124 | return 0; |
| 3122 | } | 3125 | } |
| 3123 | 3126 | ||
| 3124 | static int bttv_s_audio(struct file *file, void *priv, struct v4l2_audio *a) | 3127 | static int bttv_s_audio(struct file *file, void *priv, struct v4l2_audio *a) |
| 3125 | { | 3128 | { |
| 3129 | if (unlikely(a->index)) | ||
| 3130 | return -EINVAL; | ||
| 3131 | |||
| 3126 | return 0; | 3132 | return 0; |
| 3127 | } | 3133 | } |
| 3128 | 3134 | ||
| @@ -3184,7 +3190,7 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait) | |||
| 3184 | /* need to capture a new frame */ | 3190 | /* need to capture a new frame */ |
| 3185 | if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) | 3191 | if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) |
| 3186 | goto err; | 3192 | goto err; |
| 3187 | fh->cap.read_buf = videobuf_pci_alloc(fh->cap.msize); | 3193 | fh->cap.read_buf = videobuf_sg_alloc(fh->cap.msize); |
| 3188 | if (NULL == fh->cap.read_buf) | 3194 | if (NULL == fh->cap.read_buf) |
| 3189 | goto err; | 3195 | goto err; |
| 3190 | fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; | 3196 | fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; |
| @@ -3251,14 +3257,14 @@ static int bttv_open(struct inode *inode, struct file *file) | |||
| 3251 | fh->ov.setup_ok = 0; | 3257 | fh->ov.setup_ok = 0; |
| 3252 | v4l2_prio_open(&btv->prio,&fh->prio); | 3258 | v4l2_prio_open(&btv->prio,&fh->prio); |
| 3253 | 3259 | ||
| 3254 | videobuf_queue_pci_init(&fh->cap, &bttv_video_qops, | 3260 | videobuf_queue_sg_init(&fh->cap, &bttv_video_qops, |
| 3255 | btv->c.pci, &btv->s_lock, | 3261 | &btv->c.pci->dev, &btv->s_lock, |
| 3256 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 3262 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 3257 | V4L2_FIELD_INTERLACED, | 3263 | V4L2_FIELD_INTERLACED, |
| 3258 | sizeof(struct bttv_buffer), | 3264 | sizeof(struct bttv_buffer), |
| 3259 | fh); | 3265 | fh); |
| 3260 | videobuf_queue_pci_init(&fh->vbi, &bttv_vbi_qops, | 3266 | videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops, |
| 3261 | btv->c.pci, &btv->s_lock, | 3267 | &btv->c.pci->dev, &btv->s_lock, |
| 3262 | V4L2_BUF_TYPE_VBI_CAPTURE, | 3268 | V4L2_BUF_TYPE_VBI_CAPTURE, |
| 3263 | V4L2_FIELD_SEQ_TB, | 3269 | V4L2_FIELD_SEQ_TB, |
| 3264 | sizeof(struct bttv_buffer), | 3270 | sizeof(struct bttv_buffer), |
| @@ -3457,6 +3463,9 @@ static int radio_release(struct inode *inode, struct file *file) | |||
| 3457 | struct bttv *btv = fh->btv; | 3463 | struct bttv *btv = fh->btv; |
| 3458 | struct rds_command cmd; | 3464 | struct rds_command cmd; |
| 3459 | 3465 | ||
| 3466 | file->private_data = NULL; | ||
| 3467 | kfree(fh); | ||
| 3468 | |||
| 3460 | btv->radio_user--; | 3469 | btv->radio_user--; |
| 3461 | 3470 | ||
| 3462 | bttv_call_i2c_clients(btv, RDS_CMD_CLOSE, &cmd); | 3471 | bttv_call_i2c_clients(btv, RDS_CMD_CLOSE, &cmd); |
| @@ -3510,7 +3519,7 @@ static int radio_enum_input(struct file *file, void *priv, | |||
| 3510 | return -EINVAL; | 3519 | return -EINVAL; |
| 3511 | 3520 | ||
| 3512 | strcpy(i->name, "Radio"); | 3521 | strcpy(i->name, "Radio"); |
| 3513 | i->type = V4L2_INPUT_TYPE_TUNER; | 3522 | i->type = V4L2_INPUT_TYPE_TUNER; |
| 3514 | 3523 | ||
| 3515 | return 0; | 3524 | return 0; |
| 3516 | } | 3525 | } |
| @@ -3518,10 +3527,9 @@ static int radio_enum_input(struct file *file, void *priv, | |||
| 3518 | static int radio_g_audio(struct file *file, void *priv, | 3527 | static int radio_g_audio(struct file *file, void *priv, |
| 3519 | struct v4l2_audio *a) | 3528 | struct v4l2_audio *a) |
| 3520 | { | 3529 | { |
| 3521 | if (a->index != 0) | 3530 | if (unlikely(a->index)) |
| 3522 | return -EINVAL; | 3531 | return -EINVAL; |
| 3523 | 3532 | ||
| 3524 | memset(a, 0, sizeof(*a)); | ||
| 3525 | strcpy(a->name, "Radio"); | 3533 | strcpy(a->name, "Radio"); |
| 3526 | 3534 | ||
| 3527 | return 0; | 3535 | return 0; |
| @@ -3543,11 +3551,17 @@ static int radio_s_tuner(struct file *file, void *priv, | |||
| 3543 | static int radio_s_audio(struct file *file, void *priv, | 3551 | static int radio_s_audio(struct file *file, void *priv, |
| 3544 | struct v4l2_audio *a) | 3552 | struct v4l2_audio *a) |
| 3545 | { | 3553 | { |
| 3554 | if (unlikely(a->index)) | ||
| 3555 | return -EINVAL; | ||
| 3556 | |||
| 3546 | return 0; | 3557 | return 0; |
| 3547 | } | 3558 | } |
| 3548 | 3559 | ||
| 3549 | static int radio_s_input(struct file *filp, void *priv, unsigned int i) | 3560 | static int radio_s_input(struct file *filp, void *priv, unsigned int i) |
| 3550 | { | 3561 | { |
| 3562 | if (unlikely(i)) | ||
| 3563 | return -EINVAL; | ||
| 3564 | |||
| 3551 | return 0; | 3565 | return 0; |
| 3552 | } | 3566 | } |
| 3553 | 3567 | ||
diff --git a/drivers/media/video/bt8xx/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c index fc9ecb21eec6..a38af98f4cae 100644 --- a/drivers/media/video/bt8xx/bttv-input.c +++ b/drivers/media/video/bt8xx/bttv-input.c | |||
| @@ -278,6 +278,12 @@ int bttv_input_init(struct bttv *btv) | |||
| 278 | ir->mask_keyup = 0x004000; | 278 | ir->mask_keyup = 0x004000; |
| 279 | ir->polling = 50; /* ms */ | 279 | ir->polling = 50; /* ms */ |
| 280 | break; | 280 | break; |
| 281 | case BTTV_BOARD_KOZUMI_KTV_01C: | ||
| 282 | ir_codes = ir_codes_pctv_sedna; | ||
| 283 | ir->mask_keycode = 0x001f00; | ||
| 284 | ir->mask_keyup = 0x006000; | ||
| 285 | ir->polling = 50; /* ms */ | ||
| 286 | break; | ||
| 281 | } | 287 | } |
| 282 | if (NULL == ir_codes) { | 288 | if (NULL == ir_codes) { |
| 283 | dprintk(KERN_INFO "Ooops: IR config error [card=%d]\n", btv->c.type); | 289 | dprintk(KERN_INFO "Ooops: IR config error [card=%d]\n", btv->c.type); |
diff --git a/drivers/media/video/bt8xx/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c index 75fa82c7c735..bfdbc469e30f 100644 --- a/drivers/media/video/bt8xx/bttv-vbi.c +++ b/drivers/media/video/bt8xx/bttv-vbi.c | |||
| @@ -54,7 +54,7 @@ | |||
| 54 | #define VBI_DEFLINES 16 | 54 | #define VBI_DEFLINES 16 |
| 55 | 55 | ||
| 56 | static unsigned int vbibufs = 4; | 56 | static unsigned int vbibufs = 4; |
| 57 | static unsigned int vbi_debug = 0; | 57 | static unsigned int vbi_debug; |
| 58 | 58 | ||
| 59 | module_param(vbibufs, int, 0444); | 59 | module_param(vbibufs, int, 0444); |
| 60 | module_param(vbi_debug, int, 0644); | 60 | module_param(vbi_debug, int, 0644); |
diff --git a/drivers/media/video/bt8xx/bttv.h b/drivers/media/video/bt8xx/bttv.h index bf4c339a520c..f2393202904b 100644 --- a/drivers/media/video/bt8xx/bttv.h +++ b/drivers/media/video/bt8xx/bttv.h | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <media/ir-common.h> | 19 | #include <media/ir-common.h> |
| 20 | #include <media/ir-kbd-i2c.h> | 20 | #include <media/ir-kbd-i2c.h> |
| 21 | #include <media/i2c-addr.h> | 21 | #include <media/i2c-addr.h> |
| 22 | #include <media/tuner.h> | ||
| 22 | 23 | ||
| 23 | /* ---------------------------------------------------------- */ | 24 | /* ---------------------------------------------------------- */ |
| 24 | /* exported by bttv-cards.c */ | 25 | /* exported by bttv-cards.c */ |
| @@ -173,6 +174,8 @@ | |||
| 173 | #define BTTV_BOARD_VOODOOTV_200 0x93 | 174 | #define BTTV_BOARD_VOODOOTV_200 0x93 |
| 174 | #define BTTV_BOARD_DVICO_FUSIONHDTV_2 0x94 | 175 | #define BTTV_BOARD_DVICO_FUSIONHDTV_2 0x94 |
| 175 | #define BTTV_BOARD_TYPHOON_TVTUNERPCI 0x95 | 176 | #define BTTV_BOARD_TYPHOON_TVTUNERPCI 0x95 |
| 177 | #define BTTV_BOARD_GEOVISION_GV600 0x96 | ||
| 178 | #define BTTV_BOARD_KOZUMI_KTV_01C 0x97 | ||
| 176 | 179 | ||
| 177 | 180 | ||
| 178 | /* more card-specific defines */ | 181 | /* more card-specific defines */ |
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h index 1305d315cfc5..03816b73f847 100644 --- a/drivers/media/video/bt8xx/bttvp.h +++ b/drivers/media/video/bt8xx/bttvp.h | |||
| @@ -42,7 +42,6 @@ | |||
| 42 | 42 | ||
| 43 | #include <linux/device.h> | 43 | #include <linux/device.h> |
| 44 | #include <media/videobuf-dma-sg.h> | 44 | #include <media/videobuf-dma-sg.h> |
| 45 | #include <media/tuner.h> | ||
| 46 | #include <media/tveeprom.h> | 45 | #include <media/tveeprom.h> |
| 47 | #include <media/ir-common.h> | 46 | #include <media/ir-common.h> |
| 48 | 47 | ||
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c index 032265383df2..b364adaae78d 100644 --- a/drivers/media/video/bw-qcam.c +++ b/drivers/media/video/bw-qcam.c | |||
| @@ -523,7 +523,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[]) | |||
| 523 | int ret=1; | 523 | int ret=1; |
| 524 | unsigned int hi, lo; | 524 | unsigned int hi, lo; |
| 525 | unsigned int hi2, lo2; | 525 | unsigned int hi2, lo2; |
| 526 | static int state = 0; | 526 | static int state; |
| 527 | 527 | ||
| 528 | if (buffer == NULL) | 528 | if (buffer == NULL) |
| 529 | { | 529 | { |
| @@ -898,7 +898,9 @@ static const struct file_operations qcam_fops = { | |||
| 898 | .open = video_exclusive_open, | 898 | .open = video_exclusive_open, |
| 899 | .release = video_exclusive_release, | 899 | .release = video_exclusive_release, |
| 900 | .ioctl = qcam_ioctl, | 900 | .ioctl = qcam_ioctl, |
| 901 | #ifdef CONFIG_COMPAT | ||
| 901 | .compat_ioctl = v4l_compat_ioctl32, | 902 | .compat_ioctl = v4l_compat_ioctl32, |
| 903 | #endif | ||
| 902 | .read = qcam_read, | 904 | .read = qcam_read, |
| 903 | .llseek = no_llseek, | 905 | .llseek = no_llseek, |
| 904 | }; | 906 | }; |
| @@ -912,7 +914,7 @@ static struct video_device qcam_template= | |||
| 912 | 914 | ||
| 913 | #define MAX_CAMS 4 | 915 | #define MAX_CAMS 4 |
| 914 | static struct qcam_device *qcams[MAX_CAMS]; | 916 | static struct qcam_device *qcams[MAX_CAMS]; |
| 915 | static unsigned int num_cams = 0; | 917 | static unsigned int num_cams; |
| 916 | 918 | ||
| 917 | static int init_bwqcam(struct parport *port) | 919 | static int init_bwqcam(struct parport *port) |
| 918 | { | 920 | { |
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c index cf1546b5a7f1..fe1e67bb1ca8 100644 --- a/drivers/media/video/c-qcam.c +++ b/drivers/media/video/c-qcam.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #include <linux/videodev.h> | 36 | #include <linux/videodev.h> |
| 37 | #include <media/v4l2-common.h> | 37 | #include <media/v4l2-common.h> |
| 38 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
| 39 | #include <linux/jiffies.h> | ||
| 39 | 40 | ||
| 40 | #include <asm/uaccess.h> | 41 | #include <asm/uaccess.h> |
| 41 | 42 | ||
| @@ -69,7 +70,7 @@ struct qcam_device { | |||
| 69 | 70 | ||
| 70 | static int parport[MAX_CAMS] = { [1 ... MAX_CAMS-1] = -1 }; | 71 | static int parport[MAX_CAMS] = { [1 ... MAX_CAMS-1] = -1 }; |
| 71 | static int probe = 2; | 72 | static int probe = 2; |
| 72 | static int force_rgb = 0; | 73 | static int force_rgb; |
| 73 | static int video_nr = -1; | 74 | static int video_nr = -1; |
| 74 | 75 | ||
| 75 | static inline void qcam_set_ack(struct qcam_device *qcam, unsigned int i) | 76 | static inline void qcam_set_ack(struct qcam_device *qcam, unsigned int i) |
| @@ -95,7 +96,8 @@ static unsigned int qcam_await_ready1(struct qcam_device *qcam, | |||
| 95 | unsigned long oldjiffies = jiffies; | 96 | unsigned long oldjiffies = jiffies; |
| 96 | unsigned int i; | 97 | unsigned int i; |
| 97 | 98 | ||
| 98 | for (oldjiffies = jiffies; (jiffies - oldjiffies) < msecs_to_jiffies(40); ) | 99 | for (oldjiffies = jiffies; |
| 100 | time_before(jiffies, oldjiffies + msecs_to_jiffies(40)); ) | ||
| 99 | if (qcam_ready1(qcam) == value) | 101 | if (qcam_ready1(qcam) == value) |
| 100 | return 0; | 102 | return 0; |
| 101 | 103 | ||
| @@ -120,7 +122,8 @@ static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value) | |||
| 120 | unsigned long oldjiffies = jiffies; | 122 | unsigned long oldjiffies = jiffies; |
| 121 | unsigned int i; | 123 | unsigned int i; |
| 122 | 124 | ||
| 123 | for (oldjiffies = jiffies; (jiffies - oldjiffies) < msecs_to_jiffies(40); ) | 125 | for (oldjiffies = jiffies; |
| 126 | time_before(jiffies, oldjiffies + msecs_to_jiffies(40)); ) | ||
| 124 | if (qcam_ready2(qcam) == value) | 127 | if (qcam_ready2(qcam) == value) |
| 125 | return 0; | 128 | return 0; |
| 126 | 129 | ||
| @@ -689,7 +692,9 @@ static const struct file_operations qcam_fops = { | |||
| 689 | .open = video_exclusive_open, | 692 | .open = video_exclusive_open, |
| 690 | .release = video_exclusive_release, | 693 | .release = video_exclusive_release, |
| 691 | .ioctl = qcam_ioctl, | 694 | .ioctl = qcam_ioctl, |
| 695 | #ifdef CONFIG_COMPAT | ||
| 692 | .compat_ioctl = v4l_compat_ioctl32, | 696 | .compat_ioctl = v4l_compat_ioctl32, |
| 697 | #endif | ||
| 693 | .read = qcam_read, | 698 | .read = qcam_read, |
| 694 | .llseek = no_llseek, | 699 | .llseek = no_llseek, |
| 695 | }; | 700 | }; |
| @@ -741,7 +746,7 @@ static struct qcam_device *qcam_init(struct parport *port) | |||
| 741 | } | 746 | } |
| 742 | 747 | ||
| 743 | static struct qcam_device *qcams[MAX_CAMS]; | 748 | static struct qcam_device *qcams[MAX_CAMS]; |
| 744 | static unsigned int num_cams = 0; | 749 | static unsigned int num_cams; |
| 745 | 750 | ||
| 746 | static int init_cqcam(struct parport *port) | 751 | static int init_cqcam(struct parport *port) |
| 747 | { | 752 | { |
diff --git a/drivers/media/video/cafe_ccic.c b/drivers/media/video/cafe_ccic.c index 7ae499c9c54c..5195b1f3378a 100644 --- a/drivers/media/video/cafe_ccic.c +++ b/drivers/media/video/cafe_ccic.c | |||
| @@ -65,7 +65,7 @@ MODULE_SUPPORTED_DEVICE("Video"); | |||
| 65 | */ | 65 | */ |
| 66 | 66 | ||
| 67 | #define MAX_DMA_BUFS 3 | 67 | #define MAX_DMA_BUFS 3 |
| 68 | static int alloc_bufs_at_read = 0; | 68 | static int alloc_bufs_at_read; |
| 69 | module_param(alloc_bufs_at_read, bool, 0444); | 69 | module_param(alloc_bufs_at_read, bool, 0444); |
| 70 | MODULE_PARM_DESC(alloc_bufs_at_read, | 70 | MODULE_PARM_DESC(alloc_bufs_at_read, |
| 71 | "Non-zero value causes DMA buffers to be allocated when the " | 71 | "Non-zero value causes DMA buffers to be allocated when the " |
| @@ -99,7 +99,7 @@ MODULE_PARM_DESC(max_buffers, | |||
| 99 | "will be allowed to allocate. These buffers are big and live " | 99 | "will be allowed to allocate. These buffers are big and live " |
| 100 | "in vmalloc space."); | 100 | "in vmalloc space."); |
| 101 | 101 | ||
| 102 | static int flip = 0; | 102 | static int flip; |
| 103 | module_param(flip, bool, 0444); | 103 | module_param(flip, bool, 0444); |
| 104 | MODULE_PARM_DESC(flip, | 104 | MODULE_PARM_DESC(flip, |
| 105 | "If set, the sensor will be instructed to flip the image " | 105 | "If set, the sensor will be instructed to flip the image " |
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index 7c630f5ee725..2a81376ef503 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c | |||
| @@ -3792,7 +3792,9 @@ static const struct file_operations cpia_fops = { | |||
| 3792 | .read = cpia_read, | 3792 | .read = cpia_read, |
| 3793 | .mmap = cpia_mmap, | 3793 | .mmap = cpia_mmap, |
| 3794 | .ioctl = cpia_ioctl, | 3794 | .ioctl = cpia_ioctl, |
| 3795 | #ifdef CONFIG_COMPAT | ||
| 3795 | .compat_ioctl = v4l_compat_ioctl32, | 3796 | .compat_ioctl = v4l_compat_ioctl32, |
| 3797 | #endif | ||
| 3796 | .llseek = no_llseek, | 3798 | .llseek = no_llseek, |
| 3797 | }; | 3799 | }; |
| 3798 | 3800 | ||
diff --git a/drivers/media/video/cpia.h b/drivers/media/video/cpia.h index 78392fb6f94e..5096058bf579 100644 --- a/drivers/media/video/cpia.h +++ b/drivers/media/video/cpia.h | |||
| @@ -412,11 +412,11 @@ void cpia_unregister_camera(struct cam_data *cam); | |||
| 412 | /* ErrorCode */ | 412 | /* ErrorCode */ |
| 413 | #define ERROR_FLICKER_BELOW_MIN_EXP 0x01 /*flicker exposure got below minimum exposure */ | 413 | #define ERROR_FLICKER_BELOW_MIN_EXP 0x01 /*flicker exposure got below minimum exposure */ |
| 414 | #define ALOG(fmt,args...) printk(fmt, ##args) | 414 | #define ALOG(fmt,args...) printk(fmt, ##args) |
| 415 | #define LOG(fmt,args...) ALOG(KERN_INFO __FILE__ ":%s(%d):" fmt, __FUNCTION__ , __LINE__ , ##args) | 415 | #define LOG(fmt,args...) ALOG(KERN_INFO __FILE__ ":%s(%d):" fmt, __func__ , __LINE__ , ##args) |
| 416 | 416 | ||
| 417 | #ifdef _CPIA_DEBUG_ | 417 | #ifdef _CPIA_DEBUG_ |
| 418 | #define ADBG(fmt,args...) printk(fmt, jiffies, ##args) | 418 | #define ADBG(fmt,args...) printk(fmt, jiffies, ##args) |
| 419 | #define DBG(fmt,args...) ADBG(KERN_DEBUG __FILE__" (%ld):%s(%d):" fmt, __FUNCTION__, __LINE__ , ##args) | 419 | #define DBG(fmt,args...) ADBG(KERN_DEBUG __FILE__" (%ld):%s(%d):" fmt, __func__, __LINE__ , ##args) |
| 420 | #else | 420 | #else |
| 421 | #define DBG(fmn,args...) do {} while(0) | 421 | #define DBG(fmn,args...) do {} while(0) |
| 422 | #endif | 422 | #endif |
diff --git a/drivers/media/video/cpia2/cpia2_core.c b/drivers/media/video/cpia2/cpia2_core.c index a76bd786cf13..c8b9fdb700ff 100644 --- a/drivers/media/video/cpia2/cpia2_core.c +++ b/drivers/media/video/cpia2/cpia2_core.c | |||
| @@ -34,7 +34,7 @@ | |||
| 34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
| 35 | #include <linux/vmalloc.h> | 35 | #include <linux/vmalloc.h> |
| 36 | 36 | ||
| 37 | //#define _CPIA2_DEBUG_ | 37 | /* #define _CPIA2_DEBUG_ */ |
| 38 | 38 | ||
| 39 | #include "cpia2patch.h" | 39 | #include "cpia2patch.h" |
| 40 | 40 | ||
| @@ -48,7 +48,7 @@ static const char *block_name[] = { | |||
| 48 | }; | 48 | }; |
| 49 | #endif | 49 | #endif |
| 50 | 50 | ||
| 51 | static unsigned int debugs_on = 0;//DEBUG_REG; | 51 | static unsigned int debugs_on; /* default 0 - DEBUG_REG */ |
| 52 | 52 | ||
| 53 | 53 | ||
| 54 | /****************************************************************************** | 54 | /****************************************************************************** |
| @@ -570,7 +570,7 @@ int cpia2_send_command(struct camera_data *cam, struct cpia2_command *cmd) | |||
| 570 | block_name[block_index]); | 570 | block_name[block_index]); |
| 571 | break; | 571 | break; |
| 572 | default: | 572 | default: |
| 573 | LOG("%s: invalid request mode\n",__FUNCTION__); | 573 | LOG("%s: invalid request mode\n",__func__); |
| 574 | return -EINVAL; | 574 | return -EINVAL; |
| 575 | } | 575 | } |
| 576 | 576 | ||
| @@ -952,7 +952,7 @@ static int set_default_user_mode(struct camera_data *cam) | |||
| 952 | frame_rate = CPIA2_VP_FRAMERATE_30; | 952 | frame_rate = CPIA2_VP_FRAMERATE_30; |
| 953 | break; | 953 | break; |
| 954 | default: | 954 | default: |
| 955 | LOG("%s: Invalid sensor flag value 0x%0X\n",__FUNCTION__, | 955 | LOG("%s: Invalid sensor flag value 0x%0X\n",__func__, |
| 956 | cam->params.version.sensor_flags); | 956 | cam->params.version.sensor_flags); |
| 957 | return -EINVAL; | 957 | return -EINVAL; |
| 958 | } | 958 | } |
| @@ -2356,12 +2356,12 @@ long cpia2_read(struct camera_data *cam, | |||
| 2356 | } | 2356 | } |
| 2357 | 2357 | ||
| 2358 | if (!buf) { | 2358 | if (!buf) { |
| 2359 | ERR("%s: buffer NULL\n",__FUNCTION__); | 2359 | ERR("%s: buffer NULL\n",__func__); |
| 2360 | return -EINVAL; | 2360 | return -EINVAL; |
| 2361 | } | 2361 | } |
| 2362 | 2362 | ||
| 2363 | if (!cam) { | 2363 | if (!cam) { |
| 2364 | ERR("%s: Internal error, camera_data NULL!\n",__FUNCTION__); | 2364 | ERR("%s: Internal error, camera_data NULL!\n",__func__); |
| 2365 | return -EINVAL; | 2365 | return -EINVAL; |
| 2366 | } | 2366 | } |
| 2367 | 2367 | ||
| @@ -2370,7 +2370,7 @@ long cpia2_read(struct camera_data *cam, | |||
| 2370 | return -ERESTARTSYS; | 2370 | return -ERESTARTSYS; |
| 2371 | 2371 | ||
| 2372 | if (!cam->present) { | 2372 | if (!cam->present) { |
| 2373 | LOG("%s: camera removed\n",__FUNCTION__); | 2373 | LOG("%s: camera removed\n",__func__); |
| 2374 | mutex_unlock(&cam->busy_lock); | 2374 | mutex_unlock(&cam->busy_lock); |
| 2375 | return 0; /* EOF */ | 2375 | return 0; /* EOF */ |
| 2376 | } | 2376 | } |
| @@ -2434,7 +2434,7 @@ unsigned int cpia2_poll(struct camera_data *cam, struct file *filp, | |||
| 2434 | unsigned int status=0; | 2434 | unsigned int status=0; |
| 2435 | 2435 | ||
| 2436 | if(!cam) { | 2436 | if(!cam) { |
| 2437 | ERR("%s: Internal error, camera_data not found!\n",__FUNCTION__); | 2437 | ERR("%s: Internal error, camera_data not found!\n",__func__); |
| 2438 | return POLLERR; | 2438 | return POLLERR; |
| 2439 | } | 2439 | } |
| 2440 | 2440 | ||
diff --git a/drivers/media/video/cpia2/cpia2_usb.c b/drivers/media/video/cpia2/cpia2_usb.c index d8e929863a88..a4574740350d 100644 --- a/drivers/media/video/cpia2/cpia2_usb.c +++ b/drivers/media/video/cpia2/cpia2_usb.c | |||
| @@ -84,7 +84,7 @@ static struct usb_driver cpia2_driver = { | |||
| 84 | *****************************************************************************/ | 84 | *****************************************************************************/ |
| 85 | static void process_frame(struct camera_data *cam) | 85 | static void process_frame(struct camera_data *cam) |
| 86 | { | 86 | { |
| 87 | static int frame_count = 0; | 87 | static int frame_count; |
| 88 | 88 | ||
| 89 | unsigned char *inbuff = cam->workbuff->data; | 89 | unsigned char *inbuff = cam->workbuff->data; |
| 90 | 90 | ||
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c index e378abec806d..7ce2789fa976 100644 --- a/drivers/media/video/cpia2/cpia2_v4l.c +++ b/drivers/media/video/cpia2/cpia2_v4l.c | |||
| @@ -1927,7 +1927,9 @@ static const struct file_operations fops_template = { | |||
| 1927 | .poll = cpia2_v4l_poll, | 1927 | .poll = cpia2_v4l_poll, |
| 1928 | .ioctl = cpia2_ioctl, | 1928 | .ioctl = cpia2_ioctl, |
| 1929 | .llseek = no_llseek, | 1929 | .llseek = no_llseek, |
| 1930 | #ifdef CONFIG_COMPAT | ||
| 1930 | .compat_ioctl = v4l_compat_ioctl32, | 1931 | .compat_ioctl = v4l_compat_ioctl32, |
| 1932 | #endif | ||
| 1931 | .mmap = cpia2_mmap, | 1933 | .mmap = cpia2_mmap, |
| 1932 | }; | 1934 | }; |
| 1933 | 1935 | ||
diff --git a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c index 9da4726eb9b9..ef1f89399983 100644 --- a/drivers/media/video/cpia_usb.c +++ b/drivers/media/video/cpia_usb.c | |||
| @@ -170,7 +170,7 @@ static void cpia_usb_complete(struct urb *urb) | |||
| 170 | /* resubmit */ | 170 | /* resubmit */ |
| 171 | urb->dev = ucpia->dev; | 171 | urb->dev = ucpia->dev; |
| 172 | if ((i = usb_submit_urb(urb, GFP_ATOMIC)) != 0) | 172 | if ((i = usb_submit_urb(urb, GFP_ATOMIC)) != 0) |
| 173 | printk(KERN_ERR "%s: usb_submit_urb ret %d\n", __FUNCTION__, i); | 173 | printk(KERN_ERR "%s: usb_submit_urb ret %d\n", __func__, i); |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | static int cpia_usb_open(void *privdata) | 176 | static int cpia_usb_open(void *privdata) |
diff --git a/drivers/media/video/cx23885/Kconfig b/drivers/media/video/cx23885/Kconfig index 1fd326fe4113..ca5fbce3a909 100644 --- a/drivers/media/video/cx23885/Kconfig +++ b/drivers/media/video/cx23885/Kconfig | |||
| @@ -8,6 +8,7 @@ config VIDEO_CX23885 | |||
| 8 | select VIDEO_TVEEPROM | 8 | select VIDEO_TVEEPROM |
| 9 | select VIDEO_IR | 9 | select VIDEO_IR |
| 10 | select VIDEOBUF_DVB | 10 | select VIDEOBUF_DVB |
| 11 | select VIDEO_CX25840 | ||
| 11 | select DVB_TUNER_MT2131 if !DVB_FE_CUSTOMISE | 12 | select DVB_TUNER_MT2131 if !DVB_FE_CUSTOMISE |
| 12 | select DVB_S5H1409 if !DVB_FE_CUSTOMISE | 13 | select DVB_S5H1409 if !DVB_FE_CUSTOMISE |
| 13 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE | 14 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE |
| @@ -16,6 +17,7 @@ config VIDEO_CX23885 | |||
| 16 | select TUNER_TDA8290 if !DVB_FE_CUSTOMIZE | 17 | select TUNER_TDA8290 if !DVB_FE_CUSTOMIZE |
| 17 | select DVB_TDA18271 if !DVB_FE_CUSTOMIZE | 18 | select DVB_TDA18271 if !DVB_FE_CUSTOMIZE |
| 18 | select DVB_TUNER_XC5000 if !DVB_FE_CUSTOMIZE | 19 | select DVB_TUNER_XC5000 if !DVB_FE_CUSTOMIZE |
| 20 | select DVB_TDA10048 if !DVB_FE_CUSTOMIZE | ||
| 19 | ---help--- | 21 | ---help--- |
| 20 | This is a video4linux driver for Conexant 23885 based | 22 | This is a video4linux driver for Conexant 23885 based |
| 21 | TV cards. | 23 | TV cards. |
diff --git a/drivers/media/video/cx23885/Makefile b/drivers/media/video/cx23885/Makefile index 32c90be50602..d7b0721af062 100644 --- a/drivers/media/video/cx23885/Makefile +++ b/drivers/media/video/cx23885/Makefile | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | cx23885-objs := cx23885-cards.o cx23885-video.o cx23885-vbi.o cx23885-core.o cx23885-i2c.o cx23885-dvb.o | 1 | cx23885-objs := cx23885-cards.o cx23885-video.o cx23885-vbi.o cx23885-core.o cx23885-i2c.o cx23885-dvb.o cx23885-417.o |
| 2 | 2 | ||
| 3 | obj-$(CONFIG_VIDEO_CX23885) += cx23885.o | 3 | obj-$(CONFIG_VIDEO_CX23885) += cx23885.o |
| 4 | 4 | ||
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c new file mode 100644 index 000000000000..acdd3b6b3e7c --- /dev/null +++ b/drivers/media/video/cx23885/cx23885-417.c | |||
| @@ -0,0 +1,1764 @@ | |||
| 1 | /* | ||
| 2 | * | ||
| 3 | * Support for a cx23417 mpeg encoder via cx23885 host port. | ||
| 4 | * | ||
| 5 | * (c) 2004 Jelle Foks <jelle@foks.8m.com> | ||
| 6 | * (c) 2004 Gerd Knorr <kraxel@bytesex.org> | ||
| 7 | * (c) 2008 Steven Toth <stoth@hauppauge.com> | ||
| 8 | * - CX23885/7/8 support | ||
| 9 | * | ||
| 10 | * Includes parts from the ivtv driver( http://ivtv.sourceforge.net/), | ||
| 11 | * | ||
| 12 | * This program is free software; you can redistribute it and/or modify | ||
| 13 | * it under the terms of the GNU General Public License as published by | ||
| 14 | * the Free Software Foundation; either version 2 of the License, or | ||
| 15 | * (at your option) any later version. | ||
| 16 | * | ||
| 17 | * This program is distributed in the hope that it will be useful, | ||
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 20 | * GNU General Public License for more details. | ||
| 21 | * | ||
| 22 | * You should have received a copy of the GNU General Public License | ||
| 23 | * along with this program; if not, write to the Free Software | ||
| 24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 25 | */ | ||
| 26 | |||
| 27 | #include <linux/module.h> | ||
| 28 | #include <linux/moduleparam.h> | ||
| 29 | #include <linux/init.h> | ||
| 30 | #include <linux/fs.h> | ||
| 31 | #include <linux/delay.h> | ||
| 32 | #include <linux/device.h> | ||
| 33 | #include <linux/firmware.h> | ||
| 34 | #include <media/v4l2-common.h> | ||
| 35 | #include <media/cx2341x.h> | ||
| 36 | |||
| 37 | #include "cx23885.h" | ||
| 38 | #include "media/cx2341x.h" | ||
| 39 | |||
| 40 | #define CX23885_FIRM_IMAGE_SIZE 376836 | ||
| 41 | #define CX23885_FIRM_IMAGE_NAME "v4l-cx23885-enc.fw" | ||
| 42 | |||
| 43 | static unsigned int mpegbufs = 32; | ||
| 44 | module_param(mpegbufs, int, 0644); | ||
| 45 | MODULE_PARM_DESC(mpegbufs, "number of mpeg buffers, range 2-32"); | ||
| 46 | static unsigned int mpeglines = 32; | ||
| 47 | module_param(mpeglines, int, 0644); | ||
| 48 | MODULE_PARM_DESC(mpeglines, "number of lines in an MPEG buffer, range 2-32"); | ||
| 49 | static unsigned int mpeglinesize = 512; | ||
| 50 | module_param(mpeglinesize, int, 0644); | ||
| 51 | MODULE_PARM_DESC(mpeglinesize, | ||
| 52 | "number of bytes in each line of an MPEG buffer, range 512-1024"); | ||
| 53 | |||
| 54 | static unsigned int v4l_debug; | ||
| 55 | module_param(v4l_debug, int, 0644); | ||
| 56 | MODULE_PARM_DESC(v4l_debug, "enable V4L debug messages"); | ||
| 57 | |||
| 58 | #define dprintk(level, fmt, arg...)\ | ||
| 59 | do { if (v4l_debug >= level) \ | ||
| 60 | printk(KERN_DEBUG "%s: " fmt, dev->name , ## arg);\ | ||
| 61 | } while (0) | ||
| 62 | |||
| 63 | static struct cx23885_tvnorm cx23885_tvnorms[] = { | ||
| 64 | { | ||
| 65 | .name = "NTSC-M", | ||
| 66 | .id = V4L2_STD_NTSC_M, | ||
| 67 | }, { | ||
| 68 | .name = "NTSC-JP", | ||
| 69 | .id = V4L2_STD_NTSC_M_JP, | ||
| 70 | }, { | ||
| 71 | .name = "PAL-BG", | ||
| 72 | .id = V4L2_STD_PAL_BG, | ||
| 73 | }, { | ||
| 74 | .name = "PAL-DK", | ||
| 75 | .id = V4L2_STD_PAL_DK, | ||
| 76 | }, { | ||
| 77 | .name = "PAL-I", | ||
| 78 | .id = V4L2_STD_PAL_I, | ||
| 79 | }, { | ||
| 80 | .name = "PAL-M", | ||
| 81 | .id = V4L2_STD_PAL_M, | ||
| 82 | }, { | ||
| 83 | .name = "PAL-N", | ||
| 84 | .id = V4L2_STD_PAL_N, | ||
| 85 | }, { | ||
| 86 | .name = "PAL-Nc", | ||
| 87 | .id = V4L2_STD_PAL_Nc, | ||
| 88 | }, { | ||
| 89 | .name = "PAL-60", | ||
| 90 | .id = V4L2_STD_PAL_60, | ||
| 91 | }, { | ||
| 92 | .name = "SECAM-L", | ||
| 93 | .id = V4L2_STD_SECAM_L, | ||
| 94 | }, { | ||
| 95 | .name = "SECAM-DK", | ||
| 96 | .id = V4L2_STD_SECAM_DK, | ||
| 97 | } | ||
| 98 | }; | ||
| 99 | |||
| 100 | /* ------------------------------------------------------------------ */ | ||
| 101 | enum cx23885_capture_type { | ||
| 102 | CX23885_MPEG_CAPTURE, | ||
| 103 | CX23885_RAW_CAPTURE, | ||
| 104 | CX23885_RAW_PASSTHRU_CAPTURE | ||
| 105 | }; | ||
| 106 | enum cx23885_capture_bits { | ||
| 107 | CX23885_RAW_BITS_NONE = 0x00, | ||
| 108 | CX23885_RAW_BITS_YUV_CAPTURE = 0x01, | ||
| 109 | CX23885_RAW_BITS_PCM_CAPTURE = 0x02, | ||
| 110 | CX23885_RAW_BITS_VBI_CAPTURE = 0x04, | ||
| 111 | CX23885_RAW_BITS_PASSTHRU_CAPTURE = 0x08, | ||
| 112 | CX23885_RAW_BITS_TO_HOST_CAPTURE = 0x10 | ||
| 113 | }; | ||
| 114 | enum cx23885_capture_end { | ||
| 115 | CX23885_END_AT_GOP, /* stop at the end of gop, generate irq */ | ||
| 116 | CX23885_END_NOW, /* stop immediately, no irq */ | ||
| 117 | }; | ||
| 118 | enum cx23885_framerate { | ||
| 119 | CX23885_FRAMERATE_NTSC_30, /* NTSC: 30fps */ | ||
| 120 | CX23885_FRAMERATE_PAL_25 /* PAL: 25fps */ | ||
| 121 | }; | ||
| 122 | enum cx23885_stream_port { | ||
| 123 | CX23885_OUTPUT_PORT_MEMORY, | ||
| 124 | CX23885_OUTPUT_PORT_STREAMING, | ||
| 125 | CX23885_OUTPUT_PORT_SERIAL | ||
| 126 | }; | ||
| 127 | enum cx23885_data_xfer_status { | ||
| 128 | CX23885_MORE_BUFFERS_FOLLOW, | ||
| 129 | CX23885_LAST_BUFFER, | ||
| 130 | }; | ||
| 131 | enum cx23885_picture_mask { | ||
| 132 | CX23885_PICTURE_MASK_NONE, | ||
| 133 | CX23885_PICTURE_MASK_I_FRAMES, | ||
| 134 | CX23885_PICTURE_MASK_I_P_FRAMES = 0x3, | ||
| 135 | CX23885_PICTURE_MASK_ALL_FRAMES = 0x7, | ||
| 136 | }; | ||
| 137 | enum cx23885_vbi_mode_bits { | ||
| 138 | CX23885_VBI_BITS_SLICED, | ||
| 139 | CX23885_VBI_BITS_RAW, | ||
| 140 | }; | ||
| 141 | enum cx23885_vbi_insertion_bits { | ||
| 142 | CX23885_VBI_BITS_INSERT_IN_XTENSION_USR_DATA, | ||
| 143 | CX23885_VBI_BITS_INSERT_IN_PRIVATE_PACKETS = 0x1 << 1, | ||
| 144 | CX23885_VBI_BITS_SEPARATE_STREAM = 0x2 << 1, | ||
| 145 | CX23885_VBI_BITS_SEPARATE_STREAM_USR_DATA = 0x4 << 1, | ||
| 146 | CX23885_VBI_BITS_SEPARATE_STREAM_PRV_DATA = 0x5 << 1, | ||
| 147 | }; | ||
| 148 | enum cx23885_dma_unit { | ||
| 149 | CX23885_DMA_BYTES, | ||
| 150 | CX23885_DMA_FRAMES, | ||
| 151 | }; | ||
| 152 | enum cx23885_dma_transfer_status_bits { | ||
| 153 | CX23885_DMA_TRANSFER_BITS_DONE = 0x01, | ||
| 154 | CX23885_DMA_TRANSFER_BITS_ERROR = 0x04, | ||
| 155 | CX23885_DMA_TRANSFER_BITS_LL_ERROR = 0x10, | ||
| 156 | }; | ||
| 157 | enum cx23885_pause { | ||
| 158 | CX23885_PAUSE_ENCODING, | ||
| 159 | CX23885_RESUME_ENCODING, | ||
| 160 | }; | ||
| 161 | enum cx23885_copyright { | ||
| 162 | CX23885_COPYRIGHT_OFF, | ||
| 163 | CX23885_COPYRIGHT_ON, | ||
| 164 | }; | ||
| 165 | enum cx23885_notification_type { | ||
| 166 | CX23885_NOTIFICATION_REFRESH, | ||
| 167 | }; | ||
| 168 | enum cx23885_notification_status { | ||
| 169 | CX23885_NOTIFICATION_OFF, | ||
| 170 | CX23885_NOTIFICATION_ON, | ||
| 171 | }; | ||
| 172 | enum cx23885_notification_mailbox { | ||
| 173 | CX23885_NOTIFICATION_NO_MAILBOX = -1, | ||
| 174 | }; | ||
| 175 | enum cx23885_field1_lines { | ||
| 176 | CX23885_FIELD1_SAA7114 = 0x00EF, /* 239 */ | ||
| 177 | CX23885_FIELD1_SAA7115 = 0x00F0, /* 240 */ | ||
| 178 | CX23885_FIELD1_MICRONAS = 0x0105, /* 261 */ | ||
| 179 | }; | ||
| 180 | enum cx23885_field2_lines { | ||
| 181 | CX23885_FIELD2_SAA7114 = 0x00EF, /* 239 */ | ||
| 182 | CX23885_FIELD2_SAA7115 = 0x00F0, /* 240 */ | ||
| 183 | CX23885_FIELD2_MICRONAS = 0x0106, /* 262 */ | ||
| 184 | }; | ||
| 185 | enum cx23885_custom_data_type { | ||
| 186 | CX23885_CUSTOM_EXTENSION_USR_DATA, | ||
| 187 | CX23885_CUSTOM_PRIVATE_PACKET, | ||
| 188 | }; | ||
| 189 | enum cx23885_mute { | ||
| 190 | CX23885_UNMUTE, | ||
| 191 | CX23885_MUTE, | ||
| 192 | }; | ||
| 193 | enum cx23885_mute_video_mask { | ||
| 194 | CX23885_MUTE_VIDEO_V_MASK = 0x0000FF00, | ||
| 195 | CX23885_MUTE_VIDEO_U_MASK = 0x00FF0000, | ||
| 196 | CX23885_MUTE_VIDEO_Y_MASK = 0xFF000000, | ||
| 197 | }; | ||
| 198 | enum cx23885_mute_video_shift { | ||
| 199 | CX23885_MUTE_VIDEO_V_SHIFT = 8, | ||
| 200 | CX23885_MUTE_VIDEO_U_SHIFT = 16, | ||
| 201 | CX23885_MUTE_VIDEO_Y_SHIFT = 24, | ||
| 202 | }; | ||
| 203 | |||
| 204 | /* defines below are from ivtv-driver.h */ | ||
| 205 | #define IVTV_CMD_HW_BLOCKS_RST 0xFFFFFFFF | ||
| 206 | |||
| 207 | /* Firmware API commands */ | ||
| 208 | #define IVTV_API_STD_TIMEOUT 500 | ||
| 209 | |||
| 210 | /* Registers */ | ||
| 211 | /* IVTV_REG_OFFSET */ | ||
| 212 | #define IVTV_REG_ENC_SDRAM_REFRESH (0x07F8) | ||
| 213 | #define IVTV_REG_ENC_SDRAM_PRECHARGE (0x07FC) | ||
| 214 | #define IVTV_REG_SPU (0x9050) | ||
| 215 | #define IVTV_REG_HW_BLOCKS (0x9054) | ||
| 216 | #define IVTV_REG_VPU (0x9058) | ||
| 217 | #define IVTV_REG_APU (0xA064) | ||
| 218 | |||
| 219 | /**** Bit definitions for MC417_RWD and MC417_OEN registers *** | ||
| 220 | bits 31-16 | ||
| 221 | +-----------+ | ||
| 222 | | Reserved | | ||
| 223 | +-----------+ | ||
| 224 | bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 | ||
| 225 | +-------+-------+-------+-------+-------+-------+-------+-------+ | ||
| 226 | | MIWR# | MIRD# | MICS# |MIRDY# |MIADDR3|MIADDR2|MIADDR1|MIADDR0| | ||
| 227 | +-------+-------+-------+-------+-------+-------+-------+-------+ | ||
| 228 | bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 | ||
| 229 | +-------+-------+-------+-------+-------+-------+-------+-------+ | ||
| 230 | |MIDATA7|MIDATA6|MIDATA5|MIDATA4|MIDATA3|MIDATA2|MIDATA1|MIDATA0| | ||
| 231 | +-------+-------+-------+-------+-------+-------+-------+-------+ | ||
| 232 | ***/ | ||
| 233 | #define MC417_MIWR 0x8000 | ||
| 234 | #define MC417_MIRD 0x4000 | ||
| 235 | #define MC417_MICS 0x2000 | ||
| 236 | #define MC417_MIRDY 0x1000 | ||
| 237 | #define MC417_MIADDR 0x0F00 | ||
| 238 | #define MC417_MIDATA 0x00FF | ||
| 239 | |||
| 240 | /* MIADDR* nibble definitions */ | ||
| 241 | #define MCI_MEMORY_DATA_BYTE0 0x000 | ||
| 242 | #define MCI_MEMORY_DATA_BYTE1 0x100 | ||
| 243 | #define MCI_MEMORY_DATA_BYTE2 0x200 | ||
| 244 | #define MCI_MEMORY_DATA_BYTE3 0x300 | ||
| 245 | #define MCI_MEMORY_ADDRESS_BYTE2 0x400 | ||
| 246 | #define MCI_MEMORY_ADDRESS_BYTE1 0x500 | ||
| 247 | #define MCI_MEMORY_ADDRESS_BYTE0 0x600 | ||
| 248 | #define MCI_REGISTER_DATA_BYTE0 0x800 | ||
| 249 | #define MCI_REGISTER_DATA_BYTE1 0x900 | ||
| 250 | #define MCI_REGISTER_DATA_BYTE2 0xA00 | ||
| 251 | #define MCI_REGISTER_DATA_BYTE3 0xB00 | ||
| 252 | #define MCI_REGISTER_ADDRESS_BYTE0 0xC00 | ||
| 253 | #define MCI_REGISTER_ADDRESS_BYTE1 0xD00 | ||
| 254 | #define MCI_REGISTER_MODE 0xE00 | ||
| 255 | |||
| 256 | /* Read and write modes */ | ||
| 257 | #define MCI_MODE_REGISTER_READ 0 | ||
| 258 | #define MCI_MODE_REGISTER_WRITE 1 | ||
| 259 | #define MCI_MODE_MEMORY_READ 0 | ||
| 260 | #define MCI_MODE_MEMORY_WRITE 0x40 | ||
| 261 | |||
| 262 | /*** Bit definitions for MC417_CTL register **** | ||
| 263 | bits 31-6 bits 5-4 bit 3 bits 2-1 Bit 0 | ||
| 264 | +--------+-------------+--------+--------------+------------+ | ||
| 265 | |Reserved|MC417_SPD_CTL|Reserved|MC417_GPIO_SEL|UART_GPIO_EN| | ||
| 266 | +--------+-------------+--------+--------------+------------+ | ||
| 267 | ***/ | ||
| 268 | #define MC417_SPD_CTL(x) (((x) << 4) & 0x00000030) | ||
| 269 | #define MC417_GPIO_SEL(x) (((x) << 1) & 0x00000006) | ||
| 270 | #define MC417_UART_GPIO_EN 0x00000001 | ||
| 271 | |||
| 272 | /* Values for speed control */ | ||
| 273 | #define MC417_SPD_CTL_SLOW 0x1 | ||
| 274 | #define MC417_SPD_CTL_MEDIUM 0x0 | ||
| 275 | #define MC417_SPD_CTL_FAST 0x3 /* b'1x, but we use b'11 */ | ||
| 276 | |||
| 277 | /* Values for GPIO select */ | ||
| 278 | #define MC417_GPIO_SEL_GPIO3 0x3 | ||
| 279 | #define MC417_GPIO_SEL_GPIO2 0x2 | ||
| 280 | #define MC417_GPIO_SEL_GPIO1 0x1 | ||
| 281 | #define MC417_GPIO_SEL_GPIO0 0x0 | ||
| 282 | |||
| 283 | void cx23885_mc417_init(struct cx23885_dev *dev) | ||
| 284 | { | ||
| 285 | u32 regval; | ||
| 286 | |||
| 287 | dprintk(2, "%s()\n", __func__); | ||
| 288 | |||
| 289 | /* Configure MC417_CTL register to defaults. */ | ||
| 290 | regval = MC417_SPD_CTL(MC417_SPD_CTL_FAST) | | ||
| 291 | MC417_GPIO_SEL(MC417_GPIO_SEL_GPIO3) | | ||
| 292 | MC417_UART_GPIO_EN; | ||
| 293 | cx_write(MC417_CTL, regval); | ||
| 294 | |||
| 295 | /* Configure MC417_OEN to defaults. */ | ||
| 296 | regval = MC417_MIRDY; | ||
| 297 | cx_write(MC417_OEN, regval); | ||
| 298 | |||
| 299 | /* Configure MC417_RWD to defaults. */ | ||
| 300 | regval = MC417_MIWR | MC417_MIRD | MC417_MICS; | ||
| 301 | cx_write(MC417_RWD, regval); | ||
| 302 | } | ||
| 303 | |||
| 304 | static int mc417_wait_ready(struct cx23885_dev *dev) | ||
| 305 | { | ||
| 306 | u32 mi_ready; | ||
| 307 | unsigned long timeout = jiffies + msecs_to_jiffies(1); | ||
| 308 | |||
| 309 | for (;;) { | ||
| 310 | mi_ready = cx_read(MC417_RWD) & MC417_MIRDY; | ||
| 311 | if (mi_ready != 0) | ||
| 312 | return 0; | ||
| 313 | if (time_after(jiffies, timeout)) | ||
| 314 | return -1; | ||
| 315 | udelay(1); | ||
| 316 | } | ||
| 317 | } | ||
| 318 | |||
| 319 | static int mc417_register_write(struct cx23885_dev *dev, u16 address, u32 value) | ||
| 320 | { | ||
| 321 | u32 regval; | ||
| 322 | |||
| 323 | /* Enable MC417 GPIO outputs except for MC417_MIRDY, | ||
| 324 | * which is an input. | ||
| 325 | */ | ||
| 326 | cx_write(MC417_OEN, MC417_MIRDY); | ||
| 327 | |||
| 328 | /* Write data byte 0 */ | ||
| 329 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_DATA_BYTE0 | | ||
| 330 | (value & 0x000000FF); | ||
| 331 | cx_write(MC417_RWD, regval); | ||
| 332 | |||
| 333 | /* Transition CS/WR to effect write transaction across bus. */ | ||
| 334 | regval |= MC417_MICS | MC417_MIWR; | ||
| 335 | cx_write(MC417_RWD, regval); | ||
| 336 | |||
| 337 | /* Write data byte 1 */ | ||
| 338 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_DATA_BYTE1 | | ||
| 339 | ((value >> 8) & 0x000000FF); | ||
| 340 | cx_write(MC417_RWD, regval); | ||
| 341 | regval |= MC417_MICS | MC417_MIWR; | ||
| 342 | cx_write(MC417_RWD, regval); | ||
| 343 | |||
| 344 | /* Write data byte 2 */ | ||
| 345 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_DATA_BYTE2 | | ||
| 346 | ((value >> 16) & 0x000000FF); | ||
| 347 | cx_write(MC417_RWD, regval); | ||
| 348 | regval |= MC417_MICS | MC417_MIWR; | ||
| 349 | cx_write(MC417_RWD, regval); | ||
| 350 | |||
| 351 | /* Write data byte 3 */ | ||
| 352 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_DATA_BYTE3 | | ||
| 353 | ((value >> 24) & 0x000000FF); | ||
| 354 | cx_write(MC417_RWD, regval); | ||
| 355 | regval |= MC417_MICS | MC417_MIWR; | ||
| 356 | cx_write(MC417_RWD, regval); | ||
| 357 | |||
| 358 | /* Write address byte 0 */ | ||
| 359 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_ADDRESS_BYTE0 | | ||
| 360 | (address & 0xFF); | ||
| 361 | cx_write(MC417_RWD, regval); | ||
| 362 | regval |= MC417_MICS | MC417_MIWR; | ||
| 363 | cx_write(MC417_RWD, regval); | ||
| 364 | |||
| 365 | /* Write address byte 1 */ | ||
| 366 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_ADDRESS_BYTE1 | | ||
| 367 | ((address >> 8) & 0xFF); | ||
| 368 | cx_write(MC417_RWD, regval); | ||
| 369 | regval |= MC417_MICS | MC417_MIWR; | ||
| 370 | cx_write(MC417_RWD, regval); | ||
| 371 | |||
| 372 | /* Indicate that this is a write. */ | ||
| 373 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_MODE | | ||
| 374 | MCI_MODE_REGISTER_WRITE; | ||
| 375 | cx_write(MC417_RWD, regval); | ||
| 376 | regval |= MC417_MICS | MC417_MIWR; | ||
| 377 | cx_write(MC417_RWD, regval); | ||
| 378 | |||
| 379 | /* Wait for the trans to complete (MC417_MIRDY asserted). */ | ||
| 380 | return mc417_wait_ready(dev); | ||
| 381 | } | ||
| 382 | |||
| 383 | static int mc417_register_read(struct cx23885_dev *dev, u16 address, u32 *value) | ||
| 384 | { | ||
| 385 | int retval; | ||
| 386 | u32 regval; | ||
| 387 | u32 tempval; | ||
| 388 | u32 dataval; | ||
| 389 | |||
| 390 | /* Enable MC417 GPIO outputs except for MC417_MIRDY, | ||
| 391 | * which is an input. | ||
| 392 | */ | ||
| 393 | cx_write(MC417_OEN, MC417_MIRDY); | ||
| 394 | |||
| 395 | /* Write address byte 0 */ | ||
| 396 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_ADDRESS_BYTE0 | | ||
| 397 | ((address & 0x00FF)); | ||
| 398 | cx_write(MC417_RWD, regval); | ||
| 399 | regval |= MC417_MICS | MC417_MIWR; | ||
| 400 | cx_write(MC417_RWD, regval); | ||
| 401 | |||
| 402 | /* Write address byte 1 */ | ||
| 403 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_ADDRESS_BYTE1 | | ||
| 404 | ((address >> 8) & 0xFF); | ||
| 405 | cx_write(MC417_RWD, regval); | ||
| 406 | regval |= MC417_MICS | MC417_MIWR; | ||
| 407 | cx_write(MC417_RWD, regval); | ||
| 408 | |||
| 409 | /* Indicate that this is a register read. */ | ||
| 410 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_MODE | | ||
| 411 | MCI_MODE_REGISTER_READ; | ||
| 412 | cx_write(MC417_RWD, regval); | ||
| 413 | regval |= MC417_MICS | MC417_MIWR; | ||
| 414 | cx_write(MC417_RWD, regval); | ||
| 415 | |||
| 416 | /* Wait for the trans to complete (MC417_MIRDY asserted). */ | ||
| 417 | retval = mc417_wait_ready(dev); | ||
| 418 | |||
| 419 | /* switch the DAT0-7 GPIO[10:3] to input mode */ | ||
| 420 | cx_write(MC417_OEN, MC417_MIRDY | MC417_MIDATA); | ||
| 421 | |||
| 422 | /* Read data byte 0 */ | ||
| 423 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_DATA_BYTE0; | ||
| 424 | cx_write(MC417_RWD, regval); | ||
| 425 | |||
| 426 | /* Transition RD to effect read transaction across bus. | ||
| 427 | * Transtion 0x5000 -> 0x9000 correct (RD/RDY -> WR/RDY)? | ||
| 428 | * Should it be 0x9000 -> 0xF000 (also why is RDY being set, its | ||
| 429 | * input only...) | ||
| 430 | */ | ||
| 431 | regval = MC417_MIWR | MC417_MIRDY | MCI_REGISTER_DATA_BYTE0; | ||
| 432 | cx_write(MC417_RWD, regval); | ||
| 433 | |||
| 434 | /* Collect byte */ | ||
| 435 | tempval = cx_read(MC417_RWD); | ||
| 436 | dataval = tempval & 0x000000FF; | ||
| 437 | |||
| 438 | /* Bring CS and RD high. */ | ||
| 439 | regval = MC417_MIWR | MC417_MIRD | MC417_MICS | MC417_MIRDY; | ||
| 440 | cx_write(MC417_RWD, regval); | ||
| 441 | |||
| 442 | /* Read data byte 1 */ | ||
| 443 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_DATA_BYTE1; | ||
| 444 | cx_write(MC417_RWD, regval); | ||
| 445 | regval = MC417_MIWR | MC417_MIRDY | MCI_REGISTER_DATA_BYTE1; | ||
| 446 | cx_write(MC417_RWD, regval); | ||
| 447 | tempval = cx_read(MC417_RWD); | ||
| 448 | dataval |= ((tempval & 0x000000FF) << 8); | ||
| 449 | regval = MC417_MIWR | MC417_MIRD | MC417_MICS | MC417_MIRDY; | ||
| 450 | cx_write(MC417_RWD, regval); | ||
| 451 | |||
| 452 | /* Read data byte 2 */ | ||
| 453 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_DATA_BYTE2; | ||
| 454 | cx_write(MC417_RWD, regval); | ||
| 455 | regval = MC417_MIWR | MC417_MIRDY | MCI_REGISTER_DATA_BYTE2; | ||
| 456 | cx_write(MC417_RWD, regval); | ||
| 457 | tempval = cx_read(MC417_RWD); | ||
| 458 | dataval |= ((tempval & 0x000000FF) << 16); | ||
| 459 | regval = MC417_MIWR | MC417_MIRD | MC417_MICS | MC417_MIRDY; | ||
| 460 | cx_write(MC417_RWD, regval); | ||
| 461 | |||
| 462 | /* Read data byte 3 */ | ||
| 463 | regval = MC417_MIRD | MC417_MIRDY | MCI_REGISTER_DATA_BYTE3; | ||
| 464 | cx_write(MC417_RWD, regval); | ||
| 465 | regval = MC417_MIWR | MC417_MIRDY | MCI_REGISTER_DATA_BYTE3; | ||
| 466 | cx_write(MC417_RWD, regval); | ||
| 467 | tempval = cx_read(MC417_RWD); | ||
| 468 | dataval |= ((tempval & 0x000000FF) << 24); | ||
| 469 | regval = MC417_MIWR | MC417_MIRD | MC417_MICS | MC417_MIRDY; | ||
| 470 | cx_write(MC417_RWD, regval); | ||
| 471 | |||
| 472 | *value = dataval; | ||
| 473 | |||
| 474 | return retval; | ||
| 475 | } | ||
| 476 | |||
| 477 | int mc417_memory_write(struct cx23885_dev *dev, u32 address, u32 value) | ||
| 478 | { | ||
| 479 | u32 regval; | ||
| 480 | |||
| 481 | /* Enable MC417 GPIO outputs except for MC417_MIRDY, | ||
| 482 | * which is an input. | ||
| 483 | */ | ||
| 484 | cx_write(MC417_OEN, MC417_MIRDY); | ||
| 485 | |||
| 486 | /* Write data byte 0 */ | ||
| 487 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_DATA_BYTE0 | | ||
| 488 | (value & 0x000000FF); | ||
| 489 | cx_write(MC417_RWD, regval); | ||
| 490 | |||
| 491 | /* Transition CS/WR to effect write transaction across bus. */ | ||
| 492 | regval |= MC417_MICS | MC417_MIWR; | ||
| 493 | cx_write(MC417_RWD, regval); | ||
| 494 | |||
| 495 | /* Write data byte 1 */ | ||
| 496 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_DATA_BYTE1 | | ||
| 497 | ((value >> 8) & 0x000000FF); | ||
| 498 | cx_write(MC417_RWD, regval); | ||
| 499 | regval |= MC417_MICS | MC417_MIWR; | ||
| 500 | cx_write(MC417_RWD, regval); | ||
| 501 | |||
| 502 | /* Write data byte 2 */ | ||
| 503 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_DATA_BYTE2 | | ||
| 504 | ((value >> 16) & 0x000000FF); | ||
| 505 | cx_write(MC417_RWD, regval); | ||
| 506 | regval |= MC417_MICS | MC417_MIWR; | ||
| 507 | cx_write(MC417_RWD, regval); | ||
| 508 | |||
| 509 | /* Write data byte 3 */ | ||
| 510 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_DATA_BYTE3 | | ||
| 511 | ((value >> 24) & 0x000000FF); | ||
| 512 | cx_write(MC417_RWD, regval); | ||
| 513 | regval |= MC417_MICS | MC417_MIWR; | ||
| 514 | cx_write(MC417_RWD, regval); | ||
| 515 | |||
| 516 | /* Write address byte 2 */ | ||
| 517 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_ADDRESS_BYTE2 | | ||
| 518 | MCI_MODE_MEMORY_WRITE | ((address >> 16) & 0x3F); | ||
| 519 | cx_write(MC417_RWD, regval); | ||
| 520 | regval |= MC417_MICS | MC417_MIWR; | ||
| 521 | cx_write(MC417_RWD, regval); | ||
| 522 | |||
| 523 | /* Write address byte 1 */ | ||
| 524 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_ADDRESS_BYTE1 | | ||
| 525 | ((address >> 8) & 0xFF); | ||
| 526 | cx_write(MC417_RWD, regval); | ||
| 527 | regval |= MC417_MICS | MC417_MIWR; | ||
| 528 | cx_write(MC417_RWD, regval); | ||
| 529 | |||
| 530 | /* Write address byte 0 */ | ||
| 531 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_ADDRESS_BYTE0 | | ||
| 532 | (address & 0xFF); | ||
| 533 | cx_write(MC417_RWD, regval); | ||
| 534 | regval |= MC417_MICS | MC417_MIWR; | ||
| 535 | cx_write(MC417_RWD, regval); | ||
| 536 | |||
| 537 | /* Wait for the trans to complete (MC417_MIRDY asserted). */ | ||
| 538 | return mc417_wait_ready(dev); | ||
| 539 | } | ||
| 540 | |||
| 541 | int mc417_memory_read(struct cx23885_dev *dev, u32 address, u32 *value) | ||
| 542 | { | ||
| 543 | int retval; | ||
| 544 | u32 regval; | ||
| 545 | u32 tempval; | ||
| 546 | u32 dataval; | ||
| 547 | |||
| 548 | /* Enable MC417 GPIO outputs except for MC417_MIRDY, | ||
| 549 | * which is an input. | ||
| 550 | */ | ||
| 551 | cx_write(MC417_OEN, MC417_MIRDY); | ||
| 552 | |||
| 553 | /* Write address byte 2 */ | ||
| 554 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_ADDRESS_BYTE2 | | ||
| 555 | MCI_MODE_MEMORY_READ | ((address >> 16) & 0x3F); | ||
| 556 | cx_write(MC417_RWD, regval); | ||
| 557 | regval |= MC417_MICS | MC417_MIWR; | ||
| 558 | cx_write(MC417_RWD, regval); | ||
| 559 | |||
| 560 | /* Write address byte 1 */ | ||
| 561 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_ADDRESS_BYTE1 | | ||
| 562 | ((address >> 8) & 0xFF); | ||
| 563 | cx_write(MC417_RWD, regval); | ||
| 564 | regval |= MC417_MICS | MC417_MIWR; | ||
| 565 | cx_write(MC417_RWD, regval); | ||
| 566 | |||
| 567 | /* Write address byte 0 */ | ||
| 568 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_ADDRESS_BYTE0 | | ||
| 569 | (address & 0xFF); | ||
| 570 | cx_write(MC417_RWD, regval); | ||
| 571 | regval |= MC417_MICS | MC417_MIWR; | ||
| 572 | cx_write(MC417_RWD, regval); | ||
| 573 | |||
| 574 | /* Wait for the trans to complete (MC417_MIRDY asserted). */ | ||
| 575 | retval = mc417_wait_ready(dev); | ||
| 576 | |||
| 577 | /* switch the DAT0-7 GPIO[10:3] to input mode */ | ||
| 578 | cx_write(MC417_OEN, MC417_MIRDY | MC417_MIDATA); | ||
| 579 | |||
| 580 | /* Read data byte 3 */ | ||
| 581 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_DATA_BYTE3; | ||
| 582 | cx_write(MC417_RWD, regval); | ||
| 583 | |||
| 584 | /* Transition RD to effect read transaction across bus. */ | ||
| 585 | regval = MC417_MIWR | MC417_MIRDY | MCI_MEMORY_DATA_BYTE3; | ||
| 586 | cx_write(MC417_RWD, regval); | ||
| 587 | |||
| 588 | /* Collect byte */ | ||
| 589 | tempval = cx_read(MC417_RWD); | ||
| 590 | dataval = ((tempval & 0x000000FF) << 24); | ||
| 591 | |||
| 592 | /* Bring CS and RD high. */ | ||
| 593 | regval = MC417_MIWR | MC417_MIRD | MC417_MICS | MC417_MIRDY; | ||
| 594 | cx_write(MC417_RWD, regval); | ||
| 595 | |||
| 596 | /* Read data byte 2 */ | ||
| 597 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_DATA_BYTE2; | ||
| 598 | cx_write(MC417_RWD, regval); | ||
| 599 | regval = MC417_MIWR | MC417_MIRDY | MCI_MEMORY_DATA_BYTE2; | ||
| 600 | cx_write(MC417_RWD, regval); | ||
| 601 | tempval = cx_read(MC417_RWD); | ||
| 602 | dataval |= ((tempval & 0x000000FF) << 16); | ||
| 603 | regval = MC417_MIWR | MC417_MIRD | MC417_MICS | MC417_MIRDY; | ||
| 604 | cx_write(MC417_RWD, regval); | ||
| 605 | |||
| 606 | /* Read data byte 1 */ | ||
| 607 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_DATA_BYTE1; | ||
| 608 | cx_write(MC417_RWD, regval); | ||
| 609 | regval = MC417_MIWR | MC417_MIRDY | MCI_MEMORY_DATA_BYTE1; | ||
| 610 | cx_write(MC417_RWD, regval); | ||
| 611 | tempval = cx_read(MC417_RWD); | ||
| 612 | dataval |= ((tempval & 0x000000FF) << 8); | ||
| 613 | regval = MC417_MIWR | MC417_MIRD | MC417_MICS | MC417_MIRDY; | ||
| 614 | cx_write(MC417_RWD, regval); | ||
| 615 | |||
| 616 | /* Read data byte 0 */ | ||
| 617 | regval = MC417_MIRD | MC417_MIRDY | MCI_MEMORY_DATA_BYTE0; | ||
| 618 | cx_write(MC417_RWD, regval); | ||
| 619 | regval = MC417_MIWR | MC417_MIRDY | MCI_MEMORY_DATA_BYTE0; | ||
| 620 | cx_write(MC417_RWD, regval); | ||
| 621 | tempval = cx_read(MC417_RWD); | ||
| 622 | dataval |= (tempval & 0x000000FF); | ||
| 623 | regval = MC417_MIWR | MC417_MIRD | MC417_MICS | MC417_MIRDY; | ||
| 624 | cx_write(MC417_RWD, regval); | ||
| 625 | |||
| 626 | *value = dataval; | ||
| 627 | |||
| 628 | return retval; | ||
| 629 | } | ||
| 630 | |||
| 631 | /* ------------------------------------------------------------------ */ | ||
| 632 | |||
| 633 | /* MPEG encoder API */ | ||
| 634 | char *cmd_to_str(int cmd) | ||
| 635 | { | ||
| 636 | switch (cmd) { | ||
| 637 | case CX2341X_ENC_PING_FW: | ||
| 638 | return "PING_FW"; | ||
| 639 | case CX2341X_ENC_START_CAPTURE: | ||
| 640 | return "START_CAPTURE"; | ||
| 641 | case CX2341X_ENC_STOP_CAPTURE: | ||
| 642 | return "STOP_CAPTURE"; | ||
| 643 | case CX2341X_ENC_SET_AUDIO_ID: | ||
| 644 | return "SET_AUDIO_ID"; | ||
| 645 | case CX2341X_ENC_SET_VIDEO_ID: | ||
| 646 | return "SET_VIDEO_ID"; | ||
| 647 | case CX2341X_ENC_SET_PCR_ID: | ||
| 648 | return "SET_PCR_PID"; | ||
| 649 | case CX2341X_ENC_SET_FRAME_RATE: | ||
| 650 | return "SET_FRAME_RATE"; | ||
| 651 | case CX2341X_ENC_SET_FRAME_SIZE: | ||
| 652 | return "SET_FRAME_SIZE"; | ||
| 653 | case CX2341X_ENC_SET_BIT_RATE: | ||
| 654 | return "SET_BIT_RATE"; | ||
| 655 | case CX2341X_ENC_SET_GOP_PROPERTIES: | ||
| 656 | return "SET_GOP_PROPERTIES"; | ||
| 657 | case CX2341X_ENC_SET_ASPECT_RATIO: | ||
| 658 | return "SET_ASPECT_RATIO"; | ||
| 659 | case CX2341X_ENC_SET_DNR_FILTER_MODE: | ||
| 660 | return "SET_DNR_FILTER_PROPS"; | ||
| 661 | case CX2341X_ENC_SET_DNR_FILTER_PROPS: | ||
| 662 | return "SET_DNR_FILTER_PROPS"; | ||
| 663 | case CX2341X_ENC_SET_CORING_LEVELS: | ||
| 664 | return "SET_CORING_LEVELS"; | ||
| 665 | case CX2341X_ENC_SET_SPATIAL_FILTER_TYPE: | ||
| 666 | return "SET_SPATIAL_FILTER_TYPE"; | ||
| 667 | case CX2341X_ENC_SET_VBI_LINE: | ||
| 668 | return "SET_VBI_LINE"; | ||
| 669 | case CX2341X_ENC_SET_STREAM_TYPE: | ||
| 670 | return "SET_STREAM_TYPE"; | ||
| 671 | case CX2341X_ENC_SET_OUTPUT_PORT: | ||
| 672 | return "SET_OUTPUT_PORT"; | ||
| 673 | case CX2341X_ENC_SET_AUDIO_PROPERTIES: | ||
| 674 | return "SET_AUDIO_PROPERTIES"; | ||
| 675 | case CX2341X_ENC_HALT_FW: | ||
| 676 | return "HALT_FW"; | ||
| 677 | case CX2341X_ENC_GET_VERSION: | ||
| 678 | return "GET_VERSION"; | ||
| 679 | case CX2341X_ENC_SET_GOP_CLOSURE: | ||
| 680 | return "SET_GOP_CLOSURE"; | ||
| 681 | case CX2341X_ENC_GET_SEQ_END: | ||
| 682 | return "GET_SEQ_END"; | ||
| 683 | case CX2341X_ENC_SET_PGM_INDEX_INFO: | ||
| 684 | return "SET_PGM_INDEX_INFO"; | ||
| 685 | case CX2341X_ENC_SET_VBI_CONFIG: | ||
| 686 | return "SET_VBI_CONFIG"; | ||
| 687 | case CX2341X_ENC_SET_DMA_BLOCK_SIZE: | ||
| 688 | return "SET_DMA_BLOCK_SIZE"; | ||
| 689 | case CX2341X_ENC_GET_PREV_DMA_INFO_MB_10: | ||
| 690 | return "GET_PREV_DMA_INFO_MB_10"; | ||
| 691 | case CX2341X_ENC_GET_PREV_DMA_INFO_MB_9: | ||
| 692 | return "GET_PREV_DMA_INFO_MB_9"; | ||
| 693 | case CX2341X_ENC_SCHED_DMA_TO_HOST: | ||
| 694 | return "SCHED_DMA_TO_HOST"; | ||
| 695 | case CX2341X_ENC_INITIALIZE_INPUT: | ||
| 696 | return "INITIALIZE_INPUT"; | ||
| 697 | case CX2341X_ENC_SET_FRAME_DROP_RATE: | ||
| 698 | return "SET_FRAME_DROP_RATE"; | ||
| 699 | case CX2341X_ENC_PAUSE_ENCODER: | ||
| 700 | return "PAUSE_ENCODER"; | ||
| 701 | case CX2341X_ENC_REFRESH_INPUT: | ||
| 702 | return "REFRESH_INPUT"; | ||
| 703 | case CX2341X_ENC_SET_COPYRIGHT: | ||
| 704 | return "SET_COPYRIGHT"; | ||
| 705 | case CX2341X_ENC_SET_EVENT_NOTIFICATION: | ||
| 706 | return "SET_EVENT_NOTIFICATION"; | ||
| 707 | case CX2341X_ENC_SET_NUM_VSYNC_LINES: | ||
| 708 | return "SET_NUM_VSYNC_LINES"; | ||
| 709 | case CX2341X_ENC_SET_PLACEHOLDER: | ||
| 710 | return "SET_PLACEHOLDER"; | ||
| 711 | case CX2341X_ENC_MUTE_VIDEO: | ||
| 712 | return "MUTE_VIDEO"; | ||
| 713 | case CX2341X_ENC_MUTE_AUDIO: | ||
| 714 | return "MUTE_AUDIO"; | ||
| 715 | case CX2341X_ENC_MISC: | ||
| 716 | return "MISC"; | ||
| 717 | default: | ||
| 718 | return "UNKNOWN"; | ||
| 719 | } | ||
| 720 | } | ||
| 721 | |||
| 722 | static int cx23885_mbox_func(void *priv, | ||
| 723 | u32 command, | ||
| 724 | int in, | ||
| 725 | int out, | ||
| 726 | u32 data[CX2341X_MBOX_MAX_DATA]) | ||
| 727 | { | ||
| 728 | struct cx23885_dev *dev = priv; | ||
| 729 | unsigned long timeout; | ||
| 730 | u32 value, flag, retval = 0; | ||
| 731 | int i; | ||
| 732 | |||
| 733 | dprintk(3, "%s: command(0x%X) = %s\n", __func__, command, | ||
| 734 | cmd_to_str(command)); | ||
| 735 | |||
| 736 | /* this may not be 100% safe if we can't read any memory location | ||
| 737 | without side effects */ | ||
| 738 | mc417_memory_read(dev, dev->cx23417_mailbox - 4, &value); | ||
| 739 | if (value != 0x12345678) { | ||
| 740 | printk(KERN_ERR | ||
| 741 | "Firmware and/or mailbox pointer not initialized " | ||
| 742 | "or corrupted, signature = 0x%x, cmd = %s\n", value, | ||
| 743 | cmd_to_str(command)); | ||
| 744 | return -1; | ||
| 745 | } | ||
| 746 | |||
| 747 | /* This read looks at 32 bits, but flag is only 8 bits. | ||
| 748 | * Seems we also bail if CMD or TIMEOUT bytes are set??? | ||
| 749 | */ | ||
| 750 | mc417_memory_read(dev, dev->cx23417_mailbox, &flag); | ||
| 751 | if (flag) { | ||
| 752 | printk(KERN_ERR "ERROR: Mailbox appears to be in use " | ||
| 753 | "(%x), cmd = %s\n", flag, cmd_to_str(command)); | ||
| 754 | return -1; | ||
| 755 | } | ||
| 756 | |||
| 757 | flag |= 1; /* tell 'em we're working on it */ | ||
| 758 | mc417_memory_write(dev, dev->cx23417_mailbox, flag); | ||
| 759 | |||
| 760 | /* write command + args + fill remaining with zeros */ | ||
| 761 | /* command code */ | ||
| 762 | mc417_memory_write(dev, dev->cx23417_mailbox + 1, command); | ||
| 763 | mc417_memory_write(dev, dev->cx23417_mailbox + 3, | ||
| 764 | IVTV_API_STD_TIMEOUT); /* timeout */ | ||
| 765 | for (i = 0; i < in; i++) { | ||
| 766 | mc417_memory_write(dev, dev->cx23417_mailbox + 4 + i, data[i]); | ||
| 767 | dprintk(3, "API Input %d = %d\n", i, data[i]); | ||
| 768 | } | ||
| 769 | for (; i < CX2341X_MBOX_MAX_DATA; i++) | ||
| 770 | mc417_memory_write(dev, dev->cx23417_mailbox + 4 + i, 0); | ||
| 771 | |||
| 772 | flag |= 3; /* tell 'em we're done writing */ | ||
| 773 | mc417_memory_write(dev, dev->cx23417_mailbox, flag); | ||
| 774 | |||
| 775 | /* wait for firmware to handle the API command */ | ||
| 776 | timeout = jiffies + msecs_to_jiffies(10); | ||
| 777 | for (;;) { | ||
| 778 | mc417_memory_read(dev, dev->cx23417_mailbox, &flag); | ||
| 779 | if (0 != (flag & 4)) | ||
| 780 | break; | ||
| 781 | if (time_after(jiffies, timeout)) { | ||
| 782 | printk(KERN_ERR "ERROR: API Mailbox timeout\n"); | ||
| 783 | return -1; | ||
| 784 | } | ||
| 785 | udelay(10); | ||
| 786 | } | ||
| 787 | |||
| 788 | /* read output values */ | ||
| 789 | for (i = 0; i < out; i++) { | ||
| 790 | mc417_memory_read(dev, dev->cx23417_mailbox + 4 + i, data + i); | ||
| 791 | dprintk(3, "API Output %d = %d\n", i, data[i]); | ||
| 792 | } | ||
| 793 | |||
| 794 | mc417_memory_read(dev, dev->cx23417_mailbox + 2, &retval); | ||
| 795 | dprintk(3, "API result = %d\n", retval); | ||
| 796 | |||
| 797 | flag = 0; | ||
| 798 | mc417_memory_write(dev, dev->cx23417_mailbox, flag); | ||
| 799 | |||
| 800 | return retval; | ||
| 801 | } | ||
| 802 | |||
| 803 | /* We don't need to call the API often, so using just one | ||
| 804 | * mailbox will probably suffice | ||
| 805 | */ | ||
| 806 | static int cx23885_api_cmd(struct cx23885_dev *dev, | ||
| 807 | u32 command, | ||
| 808 | u32 inputcnt, | ||
| 809 | u32 outputcnt, | ||
| 810 | ...) | ||
| 811 | { | ||
| 812 | u32 data[CX2341X_MBOX_MAX_DATA]; | ||
| 813 | va_list vargs; | ||
| 814 | int i, err; | ||
| 815 | |||
| 816 | dprintk(3, "%s() cmds = 0x%08x\n", __func__, command); | ||
| 817 | |||
| 818 | va_start(vargs, outputcnt); | ||
| 819 | for (i = 0; i < inputcnt; i++) | ||
| 820 | data[i] = va_arg(vargs, int); | ||
| 821 | |||
| 822 | err = cx23885_mbox_func(dev, command, inputcnt, outputcnt, data); | ||
| 823 | for (i = 0; i < outputcnt; i++) { | ||
| 824 | int *vptr = va_arg(vargs, int *); | ||
| 825 | *vptr = data[i]; | ||
| 826 | } | ||
| 827 | va_end(vargs); | ||
| 828 | |||
| 829 | return err; | ||
| 830 | } | ||
| 831 | |||
| 832 | static int cx23885_find_mailbox(struct cx23885_dev *dev) | ||
| 833 | { | ||
| 834 | u32 signature[4] = { | ||
| 835 | 0x12345678, 0x34567812, 0x56781234, 0x78123456 | ||
| 836 | }; | ||
| 837 | int signaturecnt = 0; | ||
| 838 | u32 value; | ||
| 839 | int i; | ||
| 840 | |||
| 841 | dprintk(2, "%s()\n", __func__); | ||
| 842 | |||
| 843 | for (i = 0; i < CX23885_FIRM_IMAGE_SIZE; i++) { | ||
| 844 | mc417_memory_read(dev, i, &value); | ||
| 845 | if (value == signature[signaturecnt]) | ||
| 846 | signaturecnt++; | ||
| 847 | else | ||
| 848 | signaturecnt = 0; | ||
| 849 | if (4 == signaturecnt) { | ||
| 850 | dprintk(1, "Mailbox signature found at 0x%x\n", i+1); | ||
| 851 | return i+1; | ||
| 852 | } | ||
| 853 | } | ||
| 854 | printk(KERN_ERR "Mailbox signature values not found!\n"); | ||
| 855 | return -1; | ||
| 856 | } | ||
| 857 | |||
| 858 | static int cx23885_load_firmware(struct cx23885_dev *dev) | ||
| 859 | { | ||
| 860 | static const unsigned char magic[8] = { | ||
| 861 | 0xa7, 0x0d, 0x00, 0x00, 0x66, 0xbb, 0x55, 0xaa | ||
| 862 | }; | ||
| 863 | const struct firmware *firmware; | ||
| 864 | int i, retval = 0; | ||
| 865 | u32 value = 0; | ||
| 866 | u32 gpio_output = 0; | ||
| 867 | u32 checksum = 0; | ||
| 868 | u32 *dataptr; | ||
| 869 | |||
| 870 | dprintk(2, "%s()\n", __func__); | ||
| 871 | |||
| 872 | /* Save GPIO settings before reset of APU */ | ||
| 873 | retval |= mc417_memory_read(dev, 0x9020, &gpio_output); | ||
| 874 | retval |= mc417_memory_read(dev, 0x900C, &value); | ||
| 875 | |||
| 876 | retval = mc417_register_write(dev, | ||
| 877 | IVTV_REG_VPU, 0xFFFFFFED); | ||
| 878 | retval |= mc417_register_write(dev, | ||
| 879 | IVTV_REG_HW_BLOCKS, IVTV_CMD_HW_BLOCKS_RST); | ||
| 880 | retval |= mc417_register_write(dev, | ||
| 881 | IVTV_REG_ENC_SDRAM_REFRESH, 0x80000800); | ||
| 882 | retval |= mc417_register_write(dev, | ||
| 883 | IVTV_REG_ENC_SDRAM_PRECHARGE, 0x1A); | ||
| 884 | retval |= mc417_register_write(dev, | ||
| 885 | IVTV_REG_APU, 0); | ||
| 886 | |||
| 887 | if (retval != 0) { | ||
| 888 | printk(KERN_ERR "%s: Error with mc417_register_write\n", | ||
| 889 | __func__); | ||
| 890 | return -1; | ||
| 891 | } | ||
| 892 | |||
| 893 | retval = request_firmware(&firmware, CX23885_FIRM_IMAGE_NAME, | ||
| 894 | &dev->pci->dev); | ||
| 895 | |||
| 896 | if (retval != 0) { | ||
| 897 | printk(KERN_ERR | ||
| 898 | "ERROR: Hotplug firmware request failed (%s).\n", | ||
| 899 | CX2341X_FIRM_ENC_FILENAME); | ||
| 900 | printk(KERN_ERR "Please fix your hotplug setup, the board will " | ||
| 901 | "not work without firmware loaded!\n"); | ||
| 902 | return -1; | ||
| 903 | } | ||
| 904 | |||
| 905 | if (firmware->size != CX23885_FIRM_IMAGE_SIZE) { | ||
| 906 | printk(KERN_ERR "ERROR: Firmware size mismatch " | ||
| 907 | "(have %zd, expected %d)\n", | ||
| 908 | firmware->size, CX23885_FIRM_IMAGE_SIZE); | ||
| 909 | release_firmware(firmware); | ||
| 910 | return -1; | ||
| 911 | } | ||
| 912 | |||
| 913 | if (0 != memcmp(firmware->data, magic, 8)) { | ||
| 914 | printk(KERN_ERR | ||
| 915 | "ERROR: Firmware magic mismatch, wrong file?\n"); | ||
| 916 | release_firmware(firmware); | ||
| 917 | return -1; | ||
| 918 | } | ||
| 919 | |||
| 920 | /* transfer to the chip */ | ||
| 921 | dprintk(2, "Loading firmware ...\n"); | ||
| 922 | dataptr = (u32 *)firmware->data; | ||
| 923 | for (i = 0; i < (firmware->size >> 2); i++) { | ||
| 924 | value = *dataptr; | ||
| 925 | checksum += ~value; | ||
| 926 | if (mc417_memory_write(dev, i, value) != 0) { | ||
| 927 | printk(KERN_ERR "ERROR: Loading firmware failed!\n"); | ||
| 928 | release_firmware(firmware); | ||
| 929 | return -1; | ||
| 930 | } | ||
| 931 | dataptr++; | ||
| 932 | } | ||
| 933 | |||
| 934 | /* read back to verify with the checksum */ | ||
| 935 | dprintk(1, "Verifying firmware ...\n"); | ||
| 936 | for (i--; i >= 0; i--) { | ||
| 937 | if (mc417_memory_read(dev, i, &value) != 0) { | ||
| 938 | printk(KERN_ERR "ERROR: Reading firmware failed!\n"); | ||
| 939 | release_firmware(firmware); | ||
| 940 | return -1; | ||
| 941 | } | ||
| 942 | checksum -= ~value; | ||
| 943 | } | ||
| 944 | if (checksum) { | ||
| 945 | printk(KERN_ERR | ||
| 946 | "ERROR: Firmware load failed (checksum mismatch).\n"); | ||
| 947 | release_firmware(firmware); | ||
| 948 | return -1; | ||
| 949 | } | ||
| 950 | release_firmware(firmware); | ||
| 951 | dprintk(1, "Firmware upload successful.\n"); | ||
| 952 | |||
| 953 | retval |= mc417_register_write(dev, IVTV_REG_HW_BLOCKS, | ||
| 954 | IVTV_CMD_HW_BLOCKS_RST); | ||
| 955 | |||
| 956 | /* Restore GPIO settings, make sure EIO14 is enabled as an output. */ | ||
| 957 | dprintk(2, "%s: GPIO output EIO 0-15 was = 0x%x\n", | ||
| 958 | __func__, gpio_output); | ||
| 959 | /* Power-up seems to have GPIOs AFU. This was causing digital side | ||
| 960 | * to fail at power-up. Seems GPIOs should be set to 0x10ff0411 at | ||
| 961 | * power-up. | ||
| 962 | * gpio_output |= (1<<14); | ||
| 963 | */ | ||
| 964 | /* Note: GPIO14 is specific to the HVR1800 here */ | ||
| 965 | gpio_output = 0x10ff0411 | (1<<14); | ||
| 966 | retval |= mc417_register_write(dev, 0x9020, gpio_output | (1<<14)); | ||
| 967 | dprintk(2, "%s: GPIO output EIO 0-15 now = 0x%x\n", | ||
| 968 | __func__, gpio_output); | ||
| 969 | |||
| 970 | dprintk(1, "%s: GPIO value EIO 0-15 was = 0x%x\n", | ||
| 971 | __func__, value); | ||
| 972 | value |= (1<<14); | ||
| 973 | dprintk(1, "%s: GPIO value EIO 0-15 now = 0x%x\n", | ||
| 974 | __func__, value); | ||
| 975 | retval |= mc417_register_write(dev, 0x900C, value); | ||
| 976 | |||
| 977 | retval |= mc417_register_read(dev, IVTV_REG_VPU, &value); | ||
| 978 | retval |= mc417_register_write(dev, IVTV_REG_VPU, value & 0xFFFFFFE8); | ||
| 979 | |||
| 980 | if (retval < 0) | ||
| 981 | printk(KERN_ERR "%s: Error with mc417_register_write\n", | ||
| 982 | __func__); | ||
| 983 | return 0; | ||
| 984 | } | ||
| 985 | |||
| 986 | void cx23885_417_check_encoder(struct cx23885_dev *dev) | ||
| 987 | { | ||
| 988 | u32 status, seq; | ||
| 989 | |||
| 990 | status = seq = 0; | ||
| 991 | cx23885_api_cmd(dev, CX2341X_ENC_GET_SEQ_END, 0, 2, &status, &seq); | ||
| 992 | dprintk(1, "%s() status = %d, seq = %d\n", __func__, status, seq); | ||
| 993 | } | ||
| 994 | |||
| 995 | static void cx23885_codec_settings(struct cx23885_dev *dev) | ||
| 996 | { | ||
| 997 | dprintk(1, "%s()\n", __func__); | ||
| 998 | |||
| 999 | /* assign frame size */ | ||
| 1000 | cx23885_api_cmd(dev, CX2341X_ENC_SET_FRAME_SIZE, 2, 0, | ||
| 1001 | dev->ts1.height, dev->ts1.width); | ||
| 1002 | |||
| 1003 | dev->mpeg_params.width = dev->ts1.width; | ||
| 1004 | dev->mpeg_params.height = dev->ts1.height; | ||
| 1005 | dev->mpeg_params.is_50hz = | ||
| 1006 | (dev->encodernorm.id & V4L2_STD_625_50) != 0; | ||
| 1007 | |||
| 1008 | cx2341x_update(dev, cx23885_mbox_func, NULL, &dev->mpeg_params); | ||
| 1009 | |||
| 1010 | cx23885_api_cmd(dev, CX2341X_ENC_MISC, 2, 0, 3, 1); | ||
| 1011 | cx23885_api_cmd(dev, CX2341X_ENC_MISC, 2, 0, 4, 1); | ||
| 1012 | } | ||
| 1013 | |||
| 1014 | static int cx23885_initialize_codec(struct cx23885_dev *dev) | ||
| 1015 | { | ||
| 1016 | int version; | ||
| 1017 | int retval; | ||
| 1018 | u32 i, data[7]; | ||
| 1019 | |||
| 1020 | dprintk(1, "%s()\n", __func__); | ||
| 1021 | |||
| 1022 | retval = cx23885_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); /* ping */ | ||
| 1023 | if (retval < 0) { | ||
| 1024 | dprintk(2, "%s() PING OK\n", __func__); | ||
| 1025 | retval = cx23885_load_firmware(dev); | ||
| 1026 | if (retval < 0) { | ||
| 1027 | printk(KERN_ERR "%s() f/w load failed\n", __func__); | ||
| 1028 | return retval; | ||
| 1029 | } | ||
| 1030 | dev->cx23417_mailbox = cx23885_find_mailbox(dev); | ||
| 1031 | if (dev->cx23417_mailbox < 0) { | ||
| 1032 | printk(KERN_ERR "%s() mailbox < 0, error\n", | ||
| 1033 | __func__); | ||
| 1034 | return -1; | ||
| 1035 | } | ||
| 1036 | retval = cx23885_api_cmd(dev, CX2341X_ENC_PING_FW, 0, 0); | ||
| 1037 | if (retval < 0) { | ||
| 1038 | printk(KERN_ERR | ||
| 1039 | "ERROR: cx23417 firmware ping failed!\n"); | ||
| 1040 | return -1; | ||
| 1041 | } | ||
| 1042 | retval = cx23885_api_cmd(dev, CX2341X_ENC_GET_VERSION, 0, 1, | ||
| 1043 | &version); | ||
| 1044 | if (retval < 0) { | ||
| 1045 | printk(KERN_ERR "ERROR: cx23417 firmware get encoder :" | ||
| 1046 | "version failed!\n"); | ||
| 1047 | return -1; | ||
| 1048 | } | ||
| 1049 | dprintk(1, "cx23417 firmware version is 0x%08x\n", version); | ||
| 1050 | msleep(200); | ||
| 1051 | } | ||
| 1052 | |||
| 1053 | cx23885_codec_settings(dev); | ||
| 1054 | msleep(60); | ||
| 1055 | |||
| 1056 | cx23885_api_cmd(dev, CX2341X_ENC_SET_NUM_VSYNC_LINES, 2, 0, | ||
| 1057 | CX23885_FIELD1_SAA7115, CX23885_FIELD2_SAA7115); | ||
| 1058 | cx23885_api_cmd(dev, CX2341X_ENC_SET_PLACEHOLDER, 12, 0, | ||
| 1059 | CX23885_CUSTOM_EXTENSION_USR_DATA, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1060 | 0, 0); | ||
| 1061 | |||
| 1062 | /* Setup to capture VBI */ | ||
| 1063 | data[0] = 0x0001BD00; | ||
| 1064 | data[1] = 1; /* frames per interrupt */ | ||
| 1065 | data[2] = 4; /* total bufs */ | ||
| 1066 | data[3] = 0x91559155; /* start codes */ | ||
| 1067 | data[4] = 0x206080C0; /* stop codes */ | ||
| 1068 | data[5] = 6; /* lines */ | ||
| 1069 | data[6] = 64; /* BPL */ | ||
| 1070 | |||
| 1071 | cx23885_api_cmd(dev, CX2341X_ENC_SET_VBI_CONFIG, 7, 0, data[0], data[1], | ||
| 1072 | data[2], data[3], data[4], data[5], data[6]); | ||
| 1073 | |||
| 1074 | for (i = 2; i <= 24; i++) { | ||
| 1075 | int valid; | ||
| 1076 | |||
| 1077 | valid = ((i >= 19) && (i <= 21)); | ||
| 1078 | cx23885_api_cmd(dev, CX2341X_ENC_SET_VBI_LINE, 5, 0, i, | ||
| 1079 | valid, 0 , 0, 0); | ||
| 1080 | cx23885_api_cmd(dev, CX2341X_ENC_SET_VBI_LINE, 5, 0, | ||
| 1081 | i | 0x80000000, valid, 0, 0, 0); | ||
| 1082 | } | ||
| 1083 | |||
| 1084 | cx23885_api_cmd(dev, CX2341X_ENC_MUTE_AUDIO, 1, 0, CX23885_UNMUTE); | ||
| 1085 | msleep(60); | ||
| 1086 | |||
| 1087 | /* initialize the video input */ | ||
| 1088 | cx23885_api_cmd(dev, CX2341X_ENC_INITIALIZE_INPUT, 0, 0); | ||
| 1089 | msleep(60); | ||
| 1090 | |||
| 1091 | /* Enable VIP style pixel invalidation so we work with scaled mode */ | ||
| 1092 | mc417_memory_write(dev, 2120, 0x00000080); | ||
| 1093 | |||
| 1094 | /* start capturing to the host interface */ | ||
| 1095 | cx23885_api_cmd(dev, CX2341X_ENC_START_CAPTURE, 2, 0, | ||
| 1096 | CX23885_MPEG_CAPTURE, CX23885_RAW_BITS_NONE); | ||
| 1097 | msleep(10); | ||
| 1098 | |||
| 1099 | return 0; | ||
| 1100 | } | ||
| 1101 | |||
| 1102 | /* ------------------------------------------------------------------ */ | ||
| 1103 | |||
| 1104 | static int bb_buf_setup(struct videobuf_queue *q, | ||
| 1105 | unsigned int *count, unsigned int *size) | ||
| 1106 | { | ||
| 1107 | struct cx23885_fh *fh = q->priv_data; | ||
| 1108 | |||
| 1109 | fh->dev->ts1.ts_packet_size = mpeglinesize; | ||
| 1110 | fh->dev->ts1.ts_packet_count = mpeglines; | ||
| 1111 | |||
| 1112 | *size = fh->dev->ts1.ts_packet_size * fh->dev->ts1.ts_packet_count; | ||
| 1113 | *count = mpegbufs; | ||
| 1114 | |||
| 1115 | return 0; | ||
| 1116 | } | ||
| 1117 | |||
| 1118 | static int bb_buf_prepare(struct videobuf_queue *q, | ||
| 1119 | struct videobuf_buffer *vb, enum v4l2_field field) | ||
| 1120 | { | ||
| 1121 | struct cx23885_fh *fh = q->priv_data; | ||
| 1122 | return cx23885_buf_prepare(q, &fh->dev->ts1, | ||
| 1123 | (struct cx23885_buffer *)vb, | ||
| 1124 | field); | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | static void bb_buf_queue(struct videobuf_queue *q, | ||
| 1128 | struct videobuf_buffer *vb) | ||
| 1129 | { | ||
| 1130 | struct cx23885_fh *fh = q->priv_data; | ||
| 1131 | cx23885_buf_queue(&fh->dev->ts1, (struct cx23885_buffer *)vb); | ||
| 1132 | } | ||
| 1133 | |||
| 1134 | static void bb_buf_release(struct videobuf_queue *q, | ||
| 1135 | struct videobuf_buffer *vb) | ||
| 1136 | { | ||
| 1137 | cx23885_free_buffer(q, (struct cx23885_buffer *)vb); | ||
| 1138 | } | ||
| 1139 | |||
| 1140 | static struct videobuf_queue_ops cx23885_qops = { | ||
| 1141 | .buf_setup = bb_buf_setup, | ||
| 1142 | .buf_prepare = bb_buf_prepare, | ||
| 1143 | .buf_queue = bb_buf_queue, | ||
| 1144 | .buf_release = bb_buf_release, | ||
| 1145 | }; | ||
| 1146 | |||
| 1147 | /* ------------------------------------------------------------------ */ | ||
| 1148 | |||
| 1149 | static const u32 *ctrl_classes[] = { | ||
| 1150 | cx2341x_mpeg_ctrls, | ||
| 1151 | NULL | ||
| 1152 | }; | ||
| 1153 | |||
| 1154 | static int cx23885_queryctrl(struct cx23885_dev *dev, | ||
| 1155 | struct v4l2_queryctrl *qctrl) | ||
| 1156 | { | ||
| 1157 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); | ||
| 1158 | if (qctrl->id == 0) | ||
| 1159 | return -EINVAL; | ||
| 1160 | |||
| 1161 | /* MPEG V4L2 controls */ | ||
| 1162 | if (cx2341x_ctrl_query(&dev->mpeg_params, qctrl)) | ||
| 1163 | qctrl->flags |= V4L2_CTRL_FLAG_DISABLED; | ||
| 1164 | |||
| 1165 | return 0; | ||
| 1166 | } | ||
| 1167 | |||
| 1168 | static int cx23885_querymenu(struct cx23885_dev *dev, | ||
| 1169 | struct v4l2_querymenu *qmenu) | ||
| 1170 | { | ||
| 1171 | struct v4l2_queryctrl qctrl; | ||
| 1172 | |||
| 1173 | qctrl.id = qmenu->id; | ||
| 1174 | cx23885_queryctrl(dev, &qctrl); | ||
| 1175 | return v4l2_ctrl_query_menu(qmenu, &qctrl, | ||
| 1176 | cx2341x_ctrl_get_menu(qmenu->id)); | ||
| 1177 | } | ||
| 1178 | |||
| 1179 | int cx23885_do_ioctl(struct inode *inode, struct file *file, int radio, | ||
| 1180 | struct cx23885_dev *dev, unsigned int cmd, void *arg, | ||
| 1181 | v4l2_kioctl driver_ioctl) | ||
| 1182 | { | ||
| 1183 | int err; | ||
| 1184 | |||
| 1185 | switch (cmd) { | ||
| 1186 | /* ---------- tv norms ---------- */ | ||
| 1187 | case VIDIOC_ENUMSTD: | ||
| 1188 | { | ||
| 1189 | struct v4l2_standard *e = arg; | ||
| 1190 | unsigned int i; | ||
| 1191 | |||
| 1192 | i = e->index; | ||
| 1193 | if (i >= ARRAY_SIZE(cx23885_tvnorms)) | ||
| 1194 | return -EINVAL; | ||
| 1195 | err = v4l2_video_std_construct(e, | ||
| 1196 | cx23885_tvnorms[e->index].id, | ||
| 1197 | cx23885_tvnorms[e->index].name); | ||
| 1198 | e->index = i; | ||
| 1199 | if (err < 0) | ||
| 1200 | return err; | ||
| 1201 | return 0; | ||
| 1202 | } | ||
| 1203 | case VIDIOC_G_STD: | ||
| 1204 | { | ||
| 1205 | v4l2_std_id *id = arg; | ||
| 1206 | |||
| 1207 | *id = dev->encodernorm.id; | ||
| 1208 | return 0; | ||
| 1209 | } | ||
| 1210 | case VIDIOC_S_STD: | ||
| 1211 | { | ||
| 1212 | v4l2_std_id *id = arg; | ||
| 1213 | unsigned int i; | ||
| 1214 | |||
| 1215 | for (i = 0; i < ARRAY_SIZE(cx23885_tvnorms); i++) | ||
| 1216 | if (*id & cx23885_tvnorms[i].id) | ||
| 1217 | break; | ||
| 1218 | if (i == ARRAY_SIZE(cx23885_tvnorms)) | ||
| 1219 | return -EINVAL; | ||
| 1220 | dev->encodernorm = cx23885_tvnorms[i]; | ||
| 1221 | |||
| 1222 | return 0; | ||
| 1223 | } | ||
| 1224 | |||
| 1225 | /* ------ input switching ---------- */ | ||
| 1226 | case VIDIOC_ENUMINPUT: | ||
| 1227 | { | ||
| 1228 | struct cx23885_input *input; | ||
| 1229 | struct v4l2_input *i = arg; | ||
| 1230 | unsigned int n; | ||
| 1231 | |||
| 1232 | n = i->index; | ||
| 1233 | if (n >= 4) | ||
| 1234 | return -EINVAL; | ||
| 1235 | input = &cx23885_boards[dev->board].input[n]; | ||
| 1236 | if (input->type == 0) | ||
| 1237 | return -EINVAL; | ||
| 1238 | memset(i, 0, sizeof(*i)); | ||
| 1239 | i->index = n; | ||
| 1240 | /* FIXME | ||
| 1241 | * strcpy(i->name, input->name); */ | ||
| 1242 | strcpy(i->name, "unset"); | ||
| 1243 | if (input->type == CX23885_VMUX_TELEVISION || | ||
| 1244 | input->type == CX23885_VMUX_CABLE) | ||
| 1245 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
| 1246 | else | ||
| 1247 | i->type = V4L2_INPUT_TYPE_CAMERA; | ||
| 1248 | |||
| 1249 | for (n = 0; n < ARRAY_SIZE(cx23885_tvnorms); n++) | ||
| 1250 | i->std |= cx23885_tvnorms[n].id; | ||
| 1251 | return 0; | ||
| 1252 | } | ||
| 1253 | case VIDIOC_G_INPUT: | ||
| 1254 | { | ||
| 1255 | unsigned int *i = arg; | ||
| 1256 | |||
| 1257 | *i = dev->input; | ||
| 1258 | return 0; | ||
| 1259 | } | ||
| 1260 | case VIDIOC_S_INPUT: | ||
| 1261 | { | ||
| 1262 | unsigned int *i = arg; | ||
| 1263 | |||
| 1264 | if (*i >= 4) | ||
| 1265 | return -EINVAL; | ||
| 1266 | |||
| 1267 | return 0; | ||
| 1268 | } | ||
| 1269 | |||
| 1270 | /* --- tuner ioctls ------------------------------------------ */ | ||
| 1271 | case VIDIOC_G_TUNER: | ||
| 1272 | { | ||
| 1273 | struct v4l2_tuner *t = arg; | ||
| 1274 | |||
| 1275 | if (UNSET == dev->tuner_type) | ||
| 1276 | return -EINVAL; | ||
| 1277 | if (0 != t->index) | ||
| 1278 | return -EINVAL; | ||
| 1279 | memset(t, 0, sizeof(*t)); | ||
| 1280 | strcpy(t->name, "Television"); | ||
| 1281 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_TUNER, t); | ||
| 1282 | cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t); | ||
| 1283 | |||
| 1284 | dprintk(1, "VIDIOC_G_TUNER: tuner type %d\n", t->type); | ||
| 1285 | |||
| 1286 | return 0; | ||
| 1287 | } | ||
| 1288 | case VIDIOC_S_TUNER: | ||
| 1289 | { | ||
| 1290 | struct v4l2_tuner *t = arg; | ||
| 1291 | |||
| 1292 | if (UNSET == dev->tuner_type) | ||
| 1293 | return -EINVAL; | ||
| 1294 | |||
| 1295 | /* Update the A/V core */ | ||
| 1296 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_TUNER, t); | ||
| 1297 | |||
| 1298 | return 0; | ||
| 1299 | } | ||
| 1300 | case VIDIOC_G_FREQUENCY: | ||
| 1301 | { | ||
| 1302 | struct v4l2_frequency *f = arg; | ||
| 1303 | |||
| 1304 | memset(f, 0, sizeof(*f)); | ||
| 1305 | if (UNSET == dev->tuner_type) | ||
| 1306 | return -EINVAL; | ||
| 1307 | f->type = V4L2_TUNER_ANALOG_TV; | ||
| 1308 | f->frequency = dev->freq; | ||
| 1309 | |||
| 1310 | /* Assumption that tuner is always on bus 1 */ | ||
| 1311 | cx23885_call_i2c_clients(&dev->i2c_bus[1], | ||
| 1312 | VIDIOC_G_FREQUENCY, f); | ||
| 1313 | |||
| 1314 | return 0; | ||
| 1315 | } | ||
| 1316 | case VIDIOC_S_FREQUENCY: | ||
| 1317 | { | ||
| 1318 | struct v4l2_frequency *f = arg; | ||
| 1319 | |||
| 1320 | dprintk(1, "VIDIOC_S_FREQUENCY: dev type %d, f\n", | ||
| 1321 | dev->tuner_type); | ||
| 1322 | dprintk(1, "VIDIOC_S_FREQUENCY: f tuner %d, f type %d\n", | ||
| 1323 | f->tuner, f->type); | ||
| 1324 | if (UNSET == dev->tuner_type) | ||
| 1325 | return -EINVAL; | ||
| 1326 | if (f->tuner != 0) | ||
| 1327 | return -EINVAL; | ||
| 1328 | if (f->type != V4L2_TUNER_ANALOG_TV) | ||
| 1329 | return -EINVAL; | ||
| 1330 | dev->freq = f->frequency; | ||
| 1331 | |||
| 1332 | /* Assumption that tuner is always on bus 1 */ | ||
| 1333 | cx23885_call_i2c_clients(&dev->i2c_bus[1], | ||
| 1334 | VIDIOC_S_FREQUENCY, f); | ||
| 1335 | return 0; | ||
| 1336 | } | ||
| 1337 | case VIDIOC_S_CTRL: | ||
| 1338 | { | ||
| 1339 | /* Update the A/V core */ | ||
| 1340 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_CTRL, arg); | ||
| 1341 | return 0; | ||
| 1342 | } | ||
| 1343 | default: | ||
| 1344 | /* Convert V4L ioctl to V4L2 and call mpeg_do_ioctl | ||
| 1345 | * (driver_ioctl) */ | ||
| 1346 | return v4l_compat_translate_ioctl(inode, file, cmd, arg, | ||
| 1347 | driver_ioctl); | ||
| 1348 | } | ||
| 1349 | |||
| 1350 | return 0; | ||
| 1351 | } | ||
| 1352 | |||
| 1353 | static int mpeg_do_ioctl(struct inode *inode, struct file *file, | ||
| 1354 | unsigned int cmd, void *arg) | ||
| 1355 | { | ||
| 1356 | struct cx23885_fh *fh = file->private_data; | ||
| 1357 | struct cx23885_dev *dev = fh->dev; | ||
| 1358 | struct cx23885_tsport *tsport = &dev->ts1; | ||
| 1359 | |||
| 1360 | if (v4l_debug > 1) | ||
| 1361 | v4l_print_ioctl(dev->name, cmd); | ||
| 1362 | |||
| 1363 | switch (cmd) { | ||
| 1364 | |||
| 1365 | /* --- capabilities ------------------------------------------ */ | ||
| 1366 | case VIDIOC_QUERYCAP: | ||
| 1367 | { | ||
| 1368 | struct v4l2_capability *cap = arg; | ||
| 1369 | |||
| 1370 | memset(cap, 0, sizeof(*cap)); | ||
| 1371 | strcpy(cap->driver, dev->name); | ||
| 1372 | strlcpy(cap->card, cx23885_boards[tsport->dev->board].name, | ||
| 1373 | sizeof(cap->card)); | ||
| 1374 | sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci)); | ||
| 1375 | cap->version = CX23885_VERSION_CODE; | ||
| 1376 | cap->capabilities = | ||
| 1377 | V4L2_CAP_VIDEO_CAPTURE | | ||
| 1378 | V4L2_CAP_READWRITE | | ||
| 1379 | V4L2_CAP_STREAMING | | ||
| 1380 | 0; | ||
| 1381 | if (UNSET != dev->tuner_type) | ||
| 1382 | cap->capabilities |= V4L2_CAP_TUNER; | ||
| 1383 | |||
| 1384 | return 0; | ||
| 1385 | } | ||
| 1386 | |||
| 1387 | /* --- capture ioctls ---------------------------------------- */ | ||
| 1388 | case VIDIOC_ENUM_FMT: | ||
| 1389 | { | ||
| 1390 | struct v4l2_fmtdesc *f = arg; | ||
| 1391 | int index; | ||
| 1392 | |||
| 1393 | index = f->index; | ||
| 1394 | if (index != 0) | ||
| 1395 | return -EINVAL; | ||
| 1396 | |||
| 1397 | memset(f, 0, sizeof(*f)); | ||
| 1398 | f->index = index; | ||
| 1399 | strlcpy(f->description, "MPEG", sizeof(f->description)); | ||
| 1400 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 1401 | f->pixelformat = V4L2_PIX_FMT_MPEG; | ||
| 1402 | return 0; | ||
| 1403 | } | ||
| 1404 | case VIDIOC_G_FMT: | ||
| 1405 | { | ||
| 1406 | struct v4l2_format *f = arg; | ||
| 1407 | |||
| 1408 | memset(f, 0, sizeof(*f)); | ||
| 1409 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 1410 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | ||
| 1411 | f->fmt.pix.bytesperline = 0; | ||
| 1412 | f->fmt.pix.sizeimage = | ||
| 1413 | dev->ts1.ts_packet_size * dev->ts1.ts_packet_count; | ||
| 1414 | f->fmt.pix.colorspace = 0; | ||
| 1415 | f->fmt.pix.width = dev->ts1.width; | ||
| 1416 | f->fmt.pix.height = dev->ts1.height; | ||
| 1417 | f->fmt.pix.field = fh->mpegq.field; | ||
| 1418 | dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d, f: %d\n", | ||
| 1419 | dev->ts1.width, dev->ts1.height, fh->mpegq.field); | ||
| 1420 | return 0; | ||
| 1421 | } | ||
| 1422 | case VIDIOC_TRY_FMT: | ||
| 1423 | { | ||
| 1424 | struct v4l2_format *f = arg; | ||
| 1425 | |||
| 1426 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 1427 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | ||
| 1428 | f->fmt.pix.bytesperline = 0; | ||
| 1429 | f->fmt.pix.sizeimage = | ||
| 1430 | dev->ts1.ts_packet_size * dev->ts1.ts_packet_count; | ||
| 1431 | f->fmt.pix.sizeimage = | ||
| 1432 | f->fmt.pix.colorspace = 0; | ||
| 1433 | dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n", | ||
| 1434 | dev->ts1.width, dev->ts1.height, fh->mpegq.field); | ||
| 1435 | return 0; | ||
| 1436 | } | ||
| 1437 | case VIDIOC_S_FMT: | ||
| 1438 | { | ||
| 1439 | struct v4l2_format *f = arg; | ||
| 1440 | |||
| 1441 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 1442 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; | ||
| 1443 | f->fmt.pix.bytesperline = 0; | ||
| 1444 | f->fmt.pix.sizeimage = | ||
| 1445 | dev->ts1.ts_packet_size * dev->ts1.ts_packet_count; | ||
| 1446 | f->fmt.pix.colorspace = 0; | ||
| 1447 | dprintk(1, "VIDIOC_S_FMT: w: %d, h: %d, f: %d\n", | ||
| 1448 | f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field); | ||
| 1449 | return 0; | ||
| 1450 | } | ||
| 1451 | |||
| 1452 | /* --- streaming capture ------------------------------------- */ | ||
| 1453 | case VIDIOC_REQBUFS: | ||
| 1454 | return videobuf_reqbufs(&fh->mpegq, arg); | ||
| 1455 | |||
| 1456 | case VIDIOC_QUERYBUF: | ||
| 1457 | return videobuf_querybuf(&fh->mpegq, arg); | ||
| 1458 | |||
| 1459 | case VIDIOC_QBUF: | ||
| 1460 | return videobuf_qbuf(&fh->mpegq, arg); | ||
| 1461 | |||
| 1462 | case VIDIOC_DQBUF: | ||
| 1463 | return videobuf_dqbuf(&fh->mpegq, arg, | ||
| 1464 | file->f_flags & O_NONBLOCK); | ||
| 1465 | |||
| 1466 | case VIDIOC_STREAMON: | ||
| 1467 | return videobuf_streamon(&fh->mpegq); | ||
| 1468 | |||
| 1469 | case VIDIOC_STREAMOFF: | ||
| 1470 | return videobuf_streamoff(&fh->mpegq); | ||
| 1471 | |||
| 1472 | case VIDIOC_G_EXT_CTRLS: | ||
| 1473 | { | ||
| 1474 | struct v4l2_ext_controls *f = arg; | ||
| 1475 | |||
| 1476 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
| 1477 | return -EINVAL; | ||
| 1478 | return cx2341x_ext_ctrls(&dev->mpeg_params, 0, f, cmd); | ||
| 1479 | } | ||
| 1480 | case VIDIOC_S_EXT_CTRLS: | ||
| 1481 | case VIDIOC_TRY_EXT_CTRLS: | ||
| 1482 | { | ||
| 1483 | struct v4l2_ext_controls *f = arg; | ||
| 1484 | struct cx2341x_mpeg_params p; | ||
| 1485 | int err; | ||
| 1486 | |||
| 1487 | if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) | ||
| 1488 | return -EINVAL; | ||
| 1489 | p = dev->mpeg_params; | ||
| 1490 | err = cx2341x_ext_ctrls(&p, 0, f, cmd); | ||
| 1491 | if (err == 0 && cmd == VIDIOC_S_EXT_CTRLS) { | ||
| 1492 | err = cx2341x_update(dev, cx23885_mbox_func, | ||
| 1493 | &dev->mpeg_params, &p); | ||
| 1494 | dev->mpeg_params = p; | ||
| 1495 | } | ||
| 1496 | return err; | ||
| 1497 | } | ||
| 1498 | case VIDIOC_S_FREQUENCY: | ||
| 1499 | { | ||
| 1500 | cx23885_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, | ||
| 1501 | CX23885_END_NOW, CX23885_MPEG_CAPTURE, | ||
| 1502 | CX23885_RAW_BITS_NONE); | ||
| 1503 | cx23885_do_ioctl(inode, file, 0, dev, cmd, arg, | ||
| 1504 | mpeg_do_ioctl); | ||
| 1505 | cx23885_initialize_codec(dev); | ||
| 1506 | |||
| 1507 | return 0; | ||
| 1508 | } | ||
| 1509 | case VIDIOC_LOG_STATUS: | ||
| 1510 | { | ||
| 1511 | char name[32 + 2]; | ||
| 1512 | |||
| 1513 | snprintf(name, sizeof(name), "%s/2", dev->name); | ||
| 1514 | printk(KERN_INFO | ||
| 1515 | "%s/2: ============ START LOG STATUS ============\n", | ||
| 1516 | dev->name); | ||
| 1517 | cx23885_call_i2c_clients(&dev->i2c_bus[0], VIDIOC_LOG_STATUS, | ||
| 1518 | NULL); | ||
| 1519 | cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_LOG_STATUS, | ||
| 1520 | NULL); | ||
| 1521 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_LOG_STATUS, | ||
| 1522 | NULL); | ||
| 1523 | cx2341x_log_status(&dev->mpeg_params, name); | ||
| 1524 | printk(KERN_INFO | ||
| 1525 | "%s/2: ============= END LOG STATUS =============\n", | ||
| 1526 | dev->name); | ||
| 1527 | return 0; | ||
| 1528 | } | ||
| 1529 | case VIDIOC_QUERYMENU: | ||
| 1530 | return cx23885_querymenu(dev, arg); | ||
| 1531 | case VIDIOC_QUERYCTRL: | ||
| 1532 | { | ||
| 1533 | struct v4l2_queryctrl *c = arg; | ||
| 1534 | |||
| 1535 | return cx23885_queryctrl(dev, c); | ||
| 1536 | } | ||
| 1537 | |||
| 1538 | default: | ||
| 1539 | return cx23885_do_ioctl(inode, file, 0, dev, cmd, arg, | ||
| 1540 | mpeg_do_ioctl); | ||
| 1541 | } | ||
| 1542 | return 0; | ||
| 1543 | } | ||
| 1544 | |||
| 1545 | static int mpeg_ioctl(struct inode *inode, struct file *file, | ||
| 1546 | unsigned int cmd, unsigned long arg) | ||
| 1547 | { | ||
| 1548 | return video_usercopy(inode, file, cmd, arg, mpeg_do_ioctl); | ||
| 1549 | } | ||
| 1550 | |||
| 1551 | static int mpeg_open(struct inode *inode, struct file *file) | ||
| 1552 | { | ||
| 1553 | int minor = iminor(inode); | ||
| 1554 | struct cx23885_dev *h, *dev = NULL; | ||
| 1555 | struct list_head *list; | ||
| 1556 | struct cx23885_fh *fh; | ||
| 1557 | |||
| 1558 | dprintk(2, "%s()\n", __func__); | ||
| 1559 | |||
| 1560 | list_for_each(list, &cx23885_devlist) { | ||
| 1561 | h = list_entry(list, struct cx23885_dev, devlist); | ||
| 1562 | if (h->v4l_device->minor == minor) { | ||
| 1563 | dev = h; | ||
| 1564 | break; | ||
| 1565 | } | ||
| 1566 | } | ||
| 1567 | |||
| 1568 | if (dev == NULL) | ||
| 1569 | return -ENODEV; | ||
| 1570 | |||
| 1571 | /* allocate + initialize per filehandle data */ | ||
| 1572 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | ||
| 1573 | if (NULL == fh) | ||
| 1574 | return -ENOMEM; | ||
| 1575 | |||
| 1576 | file->private_data = fh; | ||
| 1577 | fh->dev = dev; | ||
| 1578 | |||
| 1579 | videobuf_queue_sg_init(&fh->mpegq, &cx23885_qops, | ||
| 1580 | &dev->pci->dev, &dev->ts1.slock, | ||
| 1581 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | ||
| 1582 | V4L2_FIELD_INTERLACED, | ||
| 1583 | sizeof(struct cx23885_buffer), | ||
| 1584 | fh); | ||
| 1585 | |||
| 1586 | return 0; | ||
| 1587 | } | ||
| 1588 | |||
| 1589 | static int mpeg_release(struct inode *inode, struct file *file) | ||
| 1590 | { | ||
| 1591 | struct cx23885_fh *fh = file->private_data; | ||
| 1592 | struct cx23885_dev *dev = fh->dev; | ||
| 1593 | |||
| 1594 | dprintk(2, "%s()\n", __func__); | ||
| 1595 | |||
| 1596 | /* FIXME: Review this crap */ | ||
| 1597 | /* Shut device down on last close */ | ||
| 1598 | if (atomic_cmpxchg(&fh->v4l_reading, 1, 0) == 1) { | ||
| 1599 | if (atomic_dec_return(&dev->v4l_reader_count) == 0) { | ||
| 1600 | /* stop mpeg capture */ | ||
| 1601 | cx23885_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0, | ||
| 1602 | CX23885_END_NOW, CX23885_MPEG_CAPTURE, | ||
| 1603 | CX23885_RAW_BITS_NONE); | ||
| 1604 | |||
| 1605 | msleep(500); | ||
| 1606 | cx23885_417_check_encoder(dev); | ||
| 1607 | |||
| 1608 | cx23885_cancel_buffers(&fh->dev->ts1); | ||
| 1609 | } | ||
| 1610 | } | ||
| 1611 | |||
| 1612 | if (fh->mpegq.streaming) | ||
| 1613 | videobuf_streamoff(&fh->mpegq); | ||
| 1614 | if (fh->mpegq.reading) | ||
| 1615 | videobuf_read_stop(&fh->mpegq); | ||
| 1616 | |||
| 1617 | videobuf_mmap_free(&fh->mpegq); | ||
| 1618 | file->private_data = NULL; | ||
| 1619 | kfree(fh); | ||
| 1620 | |||
| 1621 | return 0; | ||
| 1622 | } | ||
| 1623 | |||
| 1624 | static ssize_t mpeg_read(struct file *file, char __user *data, | ||
| 1625 | size_t count, loff_t *ppos) | ||
| 1626 | { | ||
| 1627 | struct cx23885_fh *fh = file->private_data; | ||
| 1628 | struct cx23885_dev *dev = fh->dev; | ||
| 1629 | |||
| 1630 | dprintk(2, "%s()\n", __func__); | ||
| 1631 | |||
| 1632 | /* Deal w/ A/V decoder * and mpeg encoder sync issues. */ | ||
| 1633 | /* Start mpeg encoder on first read. */ | ||
| 1634 | if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) { | ||
| 1635 | if (atomic_inc_return(&dev->v4l_reader_count) == 1) { | ||
| 1636 | if (cx23885_initialize_codec(dev) < 0) | ||
| 1637 | return -EINVAL; | ||
| 1638 | } | ||
| 1639 | } | ||
| 1640 | |||
| 1641 | return videobuf_read_stream(&fh->mpegq, data, count, ppos, 0, | ||
| 1642 | file->f_flags & O_NONBLOCK); | ||
| 1643 | } | ||
| 1644 | |||
| 1645 | static unsigned int mpeg_poll(struct file *file, | ||
| 1646 | struct poll_table_struct *wait) | ||
| 1647 | { | ||
| 1648 | struct cx23885_fh *fh = file->private_data; | ||
| 1649 | struct cx23885_dev *dev = fh->dev; | ||
| 1650 | |||
| 1651 | dprintk(2, "%s\n", __func__); | ||
| 1652 | |||
| 1653 | return videobuf_poll_stream(file, &fh->mpegq, wait); | ||
| 1654 | } | ||
| 1655 | |||
| 1656 | static int mpeg_mmap(struct file *file, struct vm_area_struct *vma) | ||
| 1657 | { | ||
| 1658 | struct cx23885_fh *fh = file->private_data; | ||
| 1659 | struct cx23885_dev *dev = fh->dev; | ||
| 1660 | |||
| 1661 | dprintk(2, "%s()\n", __func__); | ||
| 1662 | |||
| 1663 | return videobuf_mmap_mapper(&fh->mpegq, vma); | ||
| 1664 | } | ||
| 1665 | |||
| 1666 | static struct file_operations mpeg_fops = { | ||
| 1667 | .owner = THIS_MODULE, | ||
| 1668 | .open = mpeg_open, | ||
| 1669 | .release = mpeg_release, | ||
| 1670 | .read = mpeg_read, | ||
| 1671 | .poll = mpeg_poll, | ||
| 1672 | .mmap = mpeg_mmap, | ||
| 1673 | .ioctl = mpeg_ioctl, | ||
| 1674 | .llseek = no_llseek, | ||
| 1675 | }; | ||
| 1676 | |||
| 1677 | static struct video_device cx23885_mpeg_template = { | ||
| 1678 | .name = "cx23885", | ||
| 1679 | .type = VID_TYPE_CAPTURE | | ||
| 1680 | VID_TYPE_TUNER | | ||
| 1681 | VID_TYPE_SCALES | | ||
| 1682 | VID_TYPE_MPEG_ENCODER, | ||
| 1683 | .fops = &mpeg_fops, | ||
| 1684 | .minor = -1, | ||
| 1685 | }; | ||
| 1686 | |||
| 1687 | void cx23885_417_unregister(struct cx23885_dev *dev) | ||
| 1688 | { | ||
| 1689 | dprintk(1, "%s()\n", __func__); | ||
| 1690 | |||
| 1691 | if (dev->v4l_device) { | ||
| 1692 | if (-1 != dev->v4l_device->minor) | ||
| 1693 | video_unregister_device(dev->v4l_device); | ||
| 1694 | else | ||
| 1695 | video_device_release(dev->v4l_device); | ||
| 1696 | dev->v4l_device = NULL; | ||
| 1697 | } | ||
| 1698 | } | ||
| 1699 | |||
| 1700 | static struct video_device *cx23885_video_dev_alloc( | ||
| 1701 | struct cx23885_tsport *tsport, | ||
| 1702 | struct pci_dev *pci, | ||
| 1703 | struct video_device *template, | ||
| 1704 | char *type) | ||
| 1705 | { | ||
| 1706 | struct video_device *vfd; | ||
| 1707 | struct cx23885_dev *dev = tsport->dev; | ||
| 1708 | |||
| 1709 | dprintk(1, "%s()\n", __func__); | ||
| 1710 | |||
| 1711 | vfd = video_device_alloc(); | ||
| 1712 | if (NULL == vfd) | ||
| 1713 | return NULL; | ||
| 1714 | *vfd = *template; | ||
| 1715 | vfd->minor = -1; | ||
| 1716 | snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, | ||
| 1717 | type, cx23885_boards[tsport->dev->board].name); | ||
| 1718 | vfd->dev = &pci->dev; | ||
| 1719 | vfd->release = video_device_release; | ||
| 1720 | return vfd; | ||
| 1721 | } | ||
| 1722 | |||
| 1723 | int cx23885_417_register(struct cx23885_dev *dev) | ||
| 1724 | { | ||
| 1725 | /* FIXME: Port1 hardcoded here */ | ||
| 1726 | int err = -ENODEV; | ||
| 1727 | struct cx23885_tsport *tsport = &dev->ts1; | ||
| 1728 | |||
| 1729 | dprintk(1, "%s()\n", __func__); | ||
| 1730 | |||
| 1731 | if (cx23885_boards[dev->board].portb != CX23885_MPEG_ENCODER) | ||
| 1732 | return err; | ||
| 1733 | |||
| 1734 | /* Set default TV standard */ | ||
| 1735 | dev->encodernorm = cx23885_tvnorms[0]; | ||
| 1736 | |||
| 1737 | if (dev->encodernorm.id & V4L2_STD_525_60) | ||
| 1738 | tsport->height = 480; | ||
| 1739 | else | ||
| 1740 | tsport->height = 576; | ||
| 1741 | |||
| 1742 | tsport->width = 720; | ||
| 1743 | cx2341x_fill_defaults(&dev->mpeg_params); | ||
| 1744 | |||
| 1745 | dev->mpeg_params.port = CX2341X_PORT_SERIAL; | ||
| 1746 | |||
| 1747 | /* Allocate and initialize V4L video device */ | ||
| 1748 | dev->v4l_device = cx23885_video_dev_alloc(tsport, | ||
| 1749 | dev->pci, &cx23885_mpeg_template, "mpeg"); | ||
| 1750 | err = video_register_device(dev->v4l_device, | ||
| 1751 | VFL_TYPE_GRABBER, -1); | ||
| 1752 | if (err < 0) { | ||
| 1753 | printk(KERN_INFO "%s: can't register mpeg device\n", dev->name); | ||
| 1754 | return err; | ||
| 1755 | } | ||
| 1756 | |||
| 1757 | /* Initialize MC417 registers */ | ||
| 1758 | cx23885_mc417_init(dev); | ||
| 1759 | |||
| 1760 | printk(KERN_INFO "%s: registered device video%d [mpeg]\n", | ||
| 1761 | dev->name, dev->v4l_device->minor & 0x1f); | ||
| 1762 | |||
| 1763 | return 0; | ||
| 1764 | } | ||
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c index dfa269838e01..6ebf58724a01 100644 --- a/drivers/media/video/cx23885/cx23885-cards.c +++ b/drivers/media/video/cx23885/cx23885-cards.c | |||
| @@ -73,6 +73,7 @@ struct cx23885_board cx23885_boards[] = { | |||
| 73 | [CX23885_BOARD_HAUPPAUGE_HVR1800] = { | 73 | [CX23885_BOARD_HAUPPAUGE_HVR1800] = { |
| 74 | .name = "Hauppauge WinTV-HVR1800", | 74 | .name = "Hauppauge WinTV-HVR1800", |
| 75 | .porta = CX23885_ANALOG_VIDEO, | 75 | .porta = CX23885_ANALOG_VIDEO, |
| 76 | .portb = CX23885_MPEG_ENCODER, | ||
| 76 | .portc = CX23885_MPEG_DVB, | 77 | .portc = CX23885_MPEG_DVB, |
| 77 | .tuner_type = TUNER_PHILIPS_TDA8290, | 78 | .tuner_type = TUNER_PHILIPS_TDA8290, |
| 78 | .tuner_addr = 0x42, /* 0x84 >> 1 */ | 79 | .tuner_addr = 0x42, /* 0x84 >> 1 */ |
| @@ -130,6 +131,18 @@ struct cx23885_board cx23885_boards[] = { | |||
| 130 | .name = "Hauppauge WinTV-HVR1500", | 131 | .name = "Hauppauge WinTV-HVR1500", |
| 131 | .portc = CX23885_MPEG_DVB, | 132 | .portc = CX23885_MPEG_DVB, |
| 132 | }, | 133 | }, |
| 134 | [CX23885_BOARD_HAUPPAUGE_HVR1200] = { | ||
| 135 | .name = "Hauppauge WinTV-HVR1200", | ||
| 136 | .portc = CX23885_MPEG_DVB, | ||
| 137 | }, | ||
| 138 | [CX23885_BOARD_HAUPPAUGE_HVR1700] = { | ||
| 139 | .name = "Hauppauge WinTV-HVR1700", | ||
| 140 | .portc = CX23885_MPEG_DVB, | ||
| 141 | }, | ||
| 142 | [CX23885_BOARD_HAUPPAUGE_HVR1400] = { | ||
| 143 | .name = "Hauppauge WinTV-HVR1400", | ||
| 144 | .portc = CX23885_MPEG_DVB, | ||
| 145 | }, | ||
| 133 | }; | 146 | }; |
| 134 | const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards); | 147 | const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards); |
| 135 | 148 | ||
| @@ -181,6 +194,18 @@ struct cx23885_subid cx23885_subids[] = { | |||
| 181 | .subvendor = 0x0070, | 194 | .subvendor = 0x0070, |
| 182 | .subdevice = 0x7717, | 195 | .subdevice = 0x7717, |
| 183 | .card = CX23885_BOARD_HAUPPAUGE_HVR1500, | 196 | .card = CX23885_BOARD_HAUPPAUGE_HVR1500, |
| 197 | }, { | ||
| 198 | .subvendor = 0x0070, | ||
| 199 | .subdevice = 0x71d1, | ||
| 200 | .card = CX23885_BOARD_HAUPPAUGE_HVR1200, | ||
| 201 | }, { | ||
| 202 | .subvendor = 0x0070, | ||
| 203 | .subdevice = 0x8101, | ||
| 204 | .card = CX23885_BOARD_HAUPPAUGE_HVR1700, | ||
| 205 | }, { | ||
| 206 | .subvendor = 0x0070, | ||
| 207 | .subdevice = 0x8010, | ||
| 208 | .card = CX23885_BOARD_HAUPPAUGE_HVR1400, | ||
| 184 | }, | 209 | }, |
| 185 | }; | 210 | }; |
| 186 | const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids); | 211 | const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids); |
| @@ -235,6 +260,12 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data) | |||
| 235 | case 79561: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */ | 260 | case 79561: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */ |
| 236 | case 79571: /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, ATSC and Basic analog */ | 261 | case 79571: /* WinTV-HVR1250 (PCIe, OEM, No IR, full height, ATSC and Basic analog */ |
| 237 | case 79671: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */ | 262 | case 79671: /* WinTV-HVR1250 (PCIe, OEM, No IR, half height, ATSC and Basic analog */ |
| 263 | case 80019: | ||
| 264 | /* WinTV-HVR1400 (Express Card, Retail, IR, | ||
| 265 | * DVB-T and Basic analog */ | ||
| 266 | case 81519: | ||
| 267 | /* WinTV-HVR1700 (PCIe, Retail, No IR, half height, | ||
| 268 | * DVB-T and MPEG2 HW Encoder */ | ||
| 238 | break; | 269 | break; |
| 239 | default: | 270 | default: |
| 240 | printk("%s: warning: unknown hauppauge model #%d\n", dev->name, tv.model); | 271 | printk("%s: warning: unknown hauppauge model #%d\n", dev->name, tv.model); |
| @@ -264,7 +295,7 @@ int cx23885_tuner_callback(void *priv, int command, int arg) | |||
| 264 | } | 295 | } |
| 265 | else { | 296 | else { |
| 266 | printk(KERN_ERR | 297 | printk(KERN_ERR |
| 267 | "%s(): Unknow command.\n", __FUNCTION__); | 298 | "%s(): Unknow command.\n", __func__); |
| 268 | return -EINVAL; | 299 | return -EINVAL; |
| 269 | } | 300 | } |
| 270 | break; | 301 | break; |
| @@ -306,6 +337,10 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) | |||
| 306 | /* GPIO-15-18 cx23417 READY, CS, RD, WR */ | 337 | /* GPIO-15-18 cx23417 READY, CS, RD, WR */ |
| 307 | /* GPIO-19 IR_RX */ | 338 | /* GPIO-19 IR_RX */ |
| 308 | 339 | ||
| 340 | /* CX23417 GPIO's */ | ||
| 341 | /* EIO15 Zilog Reset */ | ||
| 342 | /* EIO14 S5H1409/CX24227 Reset */ | ||
| 343 | |||
| 309 | /* Force the TDA8295A into reset and back */ | 344 | /* Force the TDA8295A into reset and back */ |
| 310 | cx_set(GP0_IO, 0x00040004); | 345 | cx_set(GP0_IO, 0x00040004); |
| 311 | mdelay(20); | 346 | mdelay(20); |
| @@ -314,6 +349,50 @@ void cx23885_gpio_setup(struct cx23885_dev *dev) | |||
| 314 | cx_set(GP0_IO, 0x00040004); | 349 | cx_set(GP0_IO, 0x00040004); |
| 315 | mdelay(20); | 350 | mdelay(20); |
| 316 | break; | 351 | break; |
| 352 | case CX23885_BOARD_HAUPPAUGE_HVR1200: | ||
| 353 | /* GPIO-0 tda10048 demodulator reset */ | ||
| 354 | /* GPIO-2 tda18271 tuner reset */ | ||
| 355 | |||
| 356 | /* Put the parts into reset and back */ | ||
| 357 | cx_set(GP0_IO, 0x00050000); | ||
| 358 | mdelay(20); | ||
| 359 | cx_clear(GP0_IO, 0x00000005); | ||
| 360 | mdelay(20); | ||
| 361 | cx_set(GP0_IO, 0x00050005); | ||
| 362 | break; | ||
| 363 | case CX23885_BOARD_HAUPPAUGE_HVR1700: | ||
| 364 | /* GPIO-0 TDA10048 demodulator reset */ | ||
| 365 | /* GPIO-2 TDA8295A Reset */ | ||
| 366 | /* GPIO-3-10 cx23417 data0-7 */ | ||
| 367 | /* GPIO-11-14 cx23417 addr0-3 */ | ||
| 368 | /* GPIO-15-18 cx23417 READY, CS, RD, WR */ | ||
| 369 | |||
| 370 | /* The following GPIO's are on the interna AVCore (cx25840) */ | ||
| 371 | /* GPIO-19 IR_RX */ | ||
| 372 | /* GPIO-20 IR_TX 416/DVBT Select */ | ||
| 373 | /* GPIO-21 IIS DAT */ | ||
| 374 | /* GPIO-22 IIS WCLK */ | ||
| 375 | /* GPIO-23 IIS BCLK */ | ||
| 376 | |||
| 377 | /* Put the parts into reset and back */ | ||
| 378 | cx_set(GP0_IO, 0x00050000); | ||
| 379 | mdelay(20); | ||
| 380 | cx_clear(GP0_IO, 0x00000005); | ||
| 381 | mdelay(20); | ||
| 382 | cx_set(GP0_IO, 0x00050005); | ||
| 383 | break; | ||
| 384 | case CX23885_BOARD_HAUPPAUGE_HVR1400: | ||
| 385 | /* GPIO-0 Dibcom7000p demodulator reset */ | ||
| 386 | /* GPIO-2 xc3028L tuner reset */ | ||
| 387 | /* GPIO-13 LED */ | ||
| 388 | |||
| 389 | /* Put the parts into reset and back */ | ||
| 390 | cx_set(GP0_IO, 0x00050000); | ||
| 391 | mdelay(20); | ||
| 392 | cx_clear(GP0_IO, 0x00000005); | ||
| 393 | mdelay(20); | ||
| 394 | cx_set(GP0_IO, 0x00050005); | ||
| 395 | break; | ||
| 317 | } | 396 | } |
| 318 | } | 397 | } |
| 319 | 398 | ||
| @@ -324,6 +403,8 @@ int cx23885_ir_init(struct cx23885_dev *dev) | |||
| 324 | case CX23885_BOARD_HAUPPAUGE_HVR1500: | 403 | case CX23885_BOARD_HAUPPAUGE_HVR1500: |
| 325 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: | 404 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: |
| 326 | case CX23885_BOARD_HAUPPAUGE_HVR1800: | 405 | case CX23885_BOARD_HAUPPAUGE_HVR1800: |
| 406 | case CX23885_BOARD_HAUPPAUGE_HVR1200: | ||
| 407 | case CX23885_BOARD_HAUPPAUGE_HVR1400: | ||
| 327 | /* FIXME: Implement me */ | 408 | /* FIXME: Implement me */ |
| 328 | break; | 409 | break; |
| 329 | } | 410 | } |
| @@ -348,11 +429,14 @@ void cx23885_card_setup(struct cx23885_dev *dev) | |||
| 348 | case CX23885_BOARD_HAUPPAUGE_HVR1250: | 429 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
| 349 | case CX23885_BOARD_HAUPPAUGE_HVR1500: | 430 | case CX23885_BOARD_HAUPPAUGE_HVR1500: |
| 350 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: | 431 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: |
| 432 | case CX23885_BOARD_HAUPPAUGE_HVR1400: | ||
| 351 | if (dev->i2c_bus[0].i2c_rc == 0) | 433 | if (dev->i2c_bus[0].i2c_rc == 0) |
| 352 | hauppauge_eeprom(dev, eeprom+0x80); | 434 | hauppauge_eeprom(dev, eeprom+0x80); |
| 353 | break; | 435 | break; |
| 354 | case CX23885_BOARD_HAUPPAUGE_HVR1800: | 436 | case CX23885_BOARD_HAUPPAUGE_HVR1800: |
| 355 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: | 437 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: |
| 438 | case CX23885_BOARD_HAUPPAUGE_HVR1200: | ||
| 439 | case CX23885_BOARD_HAUPPAUGE_HVR1700: | ||
| 356 | if (dev->i2c_bus[0].i2c_rc == 0) | 440 | if (dev->i2c_bus[0].i2c_rc == 0) |
| 357 | hauppauge_eeprom(dev, eeprom+0xc0); | 441 | hauppauge_eeprom(dev, eeprom+0xc0); |
| 358 | break; | 442 | break; |
| @@ -364,17 +448,45 @@ void cx23885_card_setup(struct cx23885_dev *dev) | |||
| 364 | ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ | 448 | ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ |
| 365 | ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; | 449 | ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; |
| 366 | break; | 450 | break; |
| 451 | case CX23885_BOARD_HAUPPAUGE_HVR1800: | ||
| 452 | /* Defaults for VID B - Analog encoder */ | ||
| 453 | /* DREQ_POL, SMODE, PUNC_CLK, MCLK_POL Serial bus + punc clk */ | ||
| 454 | ts1->gen_ctrl_val = 0x10e; | ||
| 455 | ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ | ||
| 456 | ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; | ||
| 457 | |||
| 458 | /* APB_TSVALERR_POL (active low)*/ | ||
| 459 | ts1->vld_misc_val = 0x2000; | ||
| 460 | ts1->hw_sop_ctrl_val = (0x47 << 16 | 188 << 4 | 0xc); | ||
| 461 | |||
| 462 | /* Defaults for VID C */ | ||
| 463 | ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */ | ||
| 464 | ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */ | ||
| 465 | ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; | ||
| 466 | break; | ||
| 367 | case CX23885_BOARD_HAUPPAUGE_HVR1250: | 467 | case CX23885_BOARD_HAUPPAUGE_HVR1250: |
| 368 | case CX23885_BOARD_HAUPPAUGE_HVR1500: | 468 | case CX23885_BOARD_HAUPPAUGE_HVR1500: |
| 369 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: | 469 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: |
| 370 | case CX23885_BOARD_HAUPPAUGE_HVR1800: | ||
| 371 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: | 470 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: |
| 471 | case CX23885_BOARD_HAUPPAUGE_HVR1200: | ||
| 472 | case CX23885_BOARD_HAUPPAUGE_HVR1700: | ||
| 473 | case CX23885_BOARD_HAUPPAUGE_HVR1400: | ||
| 372 | default: | 474 | default: |
| 373 | ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */ | 475 | ts2->gen_ctrl_val = 0xc; /* Serial bus + punctured clock */ |
| 374 | ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */ | 476 | ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */ |
| 375 | ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; | 477 | ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; |
| 376 | } | 478 | } |
| 377 | 479 | ||
| 480 | /* Certain boards support analog, or require the avcore to be | ||
| 481 | * loaded, ensure this happens. | ||
| 482 | */ | ||
| 483 | switch (dev->board) { | ||
| 484 | case CX23885_BOARD_HAUPPAUGE_HVR1800: | ||
| 485 | case CX23885_BOARD_HAUPPAUGE_HVR1800lp: | ||
| 486 | case CX23885_BOARD_HAUPPAUGE_HVR1700: | ||
| 487 | request_module("cx25840"); | ||
| 488 | break; | ||
| 489 | } | ||
| 378 | } | 490 | } |
| 379 | 491 | ||
| 380 | /* ------------------------------------------------------------------ */ | 492 | /* ------------------------------------------------------------------ */ |
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c index 7f10b273598f..f24abcd06dea 100644 --- a/drivers/media/video/cx23885/cx23885-core.c +++ b/drivers/media/video/cx23885/cx23885-core.c | |||
| @@ -190,25 +190,25 @@ static struct sram_channel cx23887_sram_channels[] = { | |||
| 190 | static int cx23885_risc_decode(u32 risc) | 190 | static int cx23885_risc_decode(u32 risc) |
| 191 | { | 191 | { |
| 192 | static char *instr[16] = { | 192 | static char *instr[16] = { |
| 193 | [ RISC_SYNC >> 28 ] = "sync", | 193 | [RISC_SYNC >> 28] = "sync", |
| 194 | [ RISC_WRITE >> 28 ] = "write", | 194 | [RISC_WRITE >> 28] = "write", |
| 195 | [ RISC_WRITEC >> 28 ] = "writec", | 195 | [RISC_WRITEC >> 28] = "writec", |
| 196 | [ RISC_READ >> 28 ] = "read", | 196 | [RISC_READ >> 28] = "read", |
| 197 | [ RISC_READC >> 28 ] = "readc", | 197 | [RISC_READC >> 28] = "readc", |
| 198 | [ RISC_JUMP >> 28 ] = "jump", | 198 | [RISC_JUMP >> 28] = "jump", |
| 199 | [ RISC_SKIP >> 28 ] = "skip", | 199 | [RISC_SKIP >> 28] = "skip", |
| 200 | [ RISC_WRITERM >> 28 ] = "writerm", | 200 | [RISC_WRITERM >> 28] = "writerm", |
| 201 | [ RISC_WRITECM >> 28 ] = "writecm", | 201 | [RISC_WRITECM >> 28] = "writecm", |
| 202 | [ RISC_WRITECR >> 28 ] = "writecr", | 202 | [RISC_WRITECR >> 28] = "writecr", |
| 203 | }; | 203 | }; |
| 204 | static int incr[16] = { | 204 | static int incr[16] = { |
| 205 | [ RISC_WRITE >> 28 ] = 3, | 205 | [RISC_WRITE >> 28] = 3, |
| 206 | [ RISC_JUMP >> 28 ] = 3, | 206 | [RISC_JUMP >> 28] = 3, |
| 207 | [ RISC_SKIP >> 28 ] = 1, | 207 | [RISC_SKIP >> 28] = 1, |
| 208 | [ RISC_SYNC >> 28 ] = 1, | 208 | [RISC_SYNC >> 28] = 1, |
| 209 | [ RISC_WRITERM >> 28 ] = 3, | 209 | [RISC_WRITERM >> 28] = 3, |
| 210 | [ RISC_WRITECM >> 28 ] = 3, | 210 | [RISC_WRITECM >> 28] = 3, |
| 211 | [ RISC_WRITECR >> 28 ] = 4, | 211 | [RISC_WRITECR >> 28] = 4, |
| 212 | }; | 212 | }; |
| 213 | static char *bits[] = { | 213 | static char *bits[] = { |
| 214 | "12", "13", "14", "resync", | 214 | "12", "13", "14", "resync", |
| @@ -260,7 +260,7 @@ void cx23885_wakeup(struct cx23885_tsport *port, | |||
| 260 | } | 260 | } |
| 261 | if (bc != 1) | 261 | if (bc != 1) |
| 262 | printk("%s: %d buffers handled (should be 1)\n", | 262 | printk("%s: %d buffers handled (should be 1)\n", |
| 263 | __FUNCTION__, bc); | 263 | __func__, bc); |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | int cx23885_sram_channel_setup(struct cx23885_dev *dev, | 266 | int cx23885_sram_channel_setup(struct cx23885_dev *dev, |
| @@ -272,7 +272,7 @@ int cx23885_sram_channel_setup(struct cx23885_dev *dev, | |||
| 272 | 272 | ||
| 273 | if (ch->cmds_start == 0) | 273 | if (ch->cmds_start == 0) |
| 274 | { | 274 | { |
| 275 | dprintk(1, "%s() Erasing channel [%s]\n", __FUNCTION__, | 275 | dprintk(1, "%s() Erasing channel [%s]\n", __func__, |
| 276 | ch->name); | 276 | ch->name); |
| 277 | cx_write(ch->ptr1_reg, 0); | 277 | cx_write(ch->ptr1_reg, 0); |
| 278 | cx_write(ch->ptr2_reg, 0); | 278 | cx_write(ch->ptr2_reg, 0); |
| @@ -280,7 +280,7 @@ int cx23885_sram_channel_setup(struct cx23885_dev *dev, | |||
| 280 | cx_write(ch->cnt1_reg, 0); | 280 | cx_write(ch->cnt1_reg, 0); |
| 281 | return 0; | 281 | return 0; |
| 282 | } else { | 282 | } else { |
| 283 | dprintk(1, "%s() Configuring channel [%s]\n", __FUNCTION__, | 283 | dprintk(1, "%s() Configuring channel [%s]\n", __func__, |
| 284 | ch->name); | 284 | ch->name); |
| 285 | } | 285 | } |
| 286 | 286 | ||
| @@ -297,7 +297,7 @@ int cx23885_sram_channel_setup(struct cx23885_dev *dev, | |||
| 297 | 297 | ||
| 298 | /* write CDT */ | 298 | /* write CDT */ |
| 299 | for (i = 0; i < lines; i++) { | 299 | for (i = 0; i < lines; i++) { |
| 300 | dprintk(2, "%s() 0x%08x <- 0x%08x\n", __FUNCTION__, cdt + 16*i, | 300 | dprintk(2, "%s() 0x%08x <- 0x%08x\n", __func__, cdt + 16*i, |
| 301 | ch->fifo_start + bpl*i); | 301 | ch->fifo_start + bpl*i); |
| 302 | cx_write(cdt + 16*i, ch->fifo_start + bpl*i); | 302 | cx_write(cdt + 16*i, ch->fifo_start + bpl*i); |
| 303 | cx_write(cdt + 16*i + 4, 0); | 303 | cx_write(cdt + 16*i + 4, 0); |
| @@ -449,7 +449,7 @@ static void cx23885_shutdown(struct cx23885_dev *dev) | |||
| 449 | 449 | ||
| 450 | static void cx23885_reset(struct cx23885_dev *dev) | 450 | static void cx23885_reset(struct cx23885_dev *dev) |
| 451 | { | 451 | { |
| 452 | dprintk(1, "%s()\n", __FUNCTION__); | 452 | dprintk(1, "%s()\n", __func__); |
| 453 | 453 | ||
| 454 | cx23885_shutdown(dev); | 454 | cx23885_shutdown(dev); |
| 455 | 455 | ||
| @@ -482,7 +482,7 @@ static void cx23885_reset(struct cx23885_dev *dev) | |||
| 482 | 482 | ||
| 483 | static int cx23885_pci_quirks(struct cx23885_dev *dev) | 483 | static int cx23885_pci_quirks(struct cx23885_dev *dev) |
| 484 | { | 484 | { |
| 485 | dprintk(1, "%s()\n", __FUNCTION__); | 485 | dprintk(1, "%s()\n", __func__); |
| 486 | 486 | ||
| 487 | /* The cx23885 bridge has a weird bug which causes NMI to be asserted | 487 | /* The cx23885 bridge has a weird bug which causes NMI to be asserted |
| 488 | * when DMA begins if RDR_TLCTL0 bit4 is not cleared. It does not | 488 | * when DMA begins if RDR_TLCTL0 bit4 is not cleared. It does not |
| @@ -513,11 +513,13 @@ int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc, | |||
| 513 | 513 | ||
| 514 | static int cx23885_init_tsport(struct cx23885_dev *dev, struct cx23885_tsport *port, int portno) | 514 | static int cx23885_init_tsport(struct cx23885_dev *dev, struct cx23885_tsport *port, int portno) |
| 515 | { | 515 | { |
| 516 | dprintk(1, "%s(portno=%d)\n", __FUNCTION__, portno); | 516 | dprintk(1, "%s(portno=%d)\n", __func__, portno); |
| 517 | 517 | ||
| 518 | /* Transport bus init dma queue - Common settings */ | 518 | /* Transport bus init dma queue - Common settings */ |
| 519 | port->dma_ctl_val = 0x11; /* Enable RISC controller and Fifo */ | 519 | port->dma_ctl_val = 0x11; /* Enable RISC controller and Fifo */ |
| 520 | port->ts_int_msk_val = 0x1111; /* TS port bits for RISC */ | 520 | port->ts_int_msk_val = 0x1111; /* TS port bits for RISC */ |
| 521 | port->vld_misc_val = 0x0; | ||
| 522 | port->hw_sop_ctrl_val = (0x47 << 16 | 188 << 4); | ||
| 521 | 523 | ||
| 522 | spin_lock_init(&port->slock); | 524 | spin_lock_init(&port->slock); |
| 523 | port->dev = dev; | 525 | port->dev = dev; |
| @@ -544,7 +546,7 @@ static int cx23885_init_tsport(struct cx23885_dev *dev, struct cx23885_tsport *p | |||
| 544 | port->reg_ts_clk_en = VID_B_TS_CLK_EN; | 546 | port->reg_ts_clk_en = VID_B_TS_CLK_EN; |
| 545 | port->reg_src_sel = VID_B_SRC_SEL; | 547 | port->reg_src_sel = VID_B_SRC_SEL; |
| 546 | port->reg_ts_int_msk = VID_B_INT_MSK; | 548 | port->reg_ts_int_msk = VID_B_INT_MSK; |
| 547 | port->reg_ts_int_stat = VID_B_INT_STAT; | 549 | port->reg_ts_int_stat = VID_B_INT_STAT; |
| 548 | port->sram_chno = SRAM_CH03; /* VID_B */ | 550 | port->sram_chno = SRAM_CH03; /* VID_B */ |
| 549 | port->pci_irqmask = 0x02; /* VID_B bit1 */ | 551 | port->pci_irqmask = 0x02; /* VID_B bit1 */ |
| 550 | break; | 552 | break; |
| @@ -604,14 +606,14 @@ static void cx23885_dev_checkrevision(struct cx23885_dev *dev) | |||
| 604 | break; | 606 | break; |
| 605 | default: | 607 | default: |
| 606 | printk(KERN_ERR "%s() New hardware revision found 0x%x\n", | 608 | printk(KERN_ERR "%s() New hardware revision found 0x%x\n", |
| 607 | __FUNCTION__, dev->hwrevision); | 609 | __func__, dev->hwrevision); |
| 608 | } | 610 | } |
| 609 | if (dev->hwrevision) | 611 | if (dev->hwrevision) |
| 610 | printk(KERN_INFO "%s() Hardware revision = 0x%02x\n", | 612 | printk(KERN_INFO "%s() Hardware revision = 0x%02x\n", |
| 611 | __FUNCTION__, dev->hwrevision); | 613 | __func__, dev->hwrevision); |
| 612 | else | 614 | else |
| 613 | printk(KERN_ERR "%s() Hardware revision unknown 0x%x\n", | 615 | printk(KERN_ERR "%s() Hardware revision unknown 0x%x\n", |
| 614 | __FUNCTION__, dev->hwrevision); | 616 | __func__, dev->hwrevision); |
| 615 | } | 617 | } |
| 616 | 618 | ||
| 617 | static int cx23885_dev_setup(struct cx23885_dev *dev) | 619 | static int cx23885_dev_setup(struct cx23885_dev *dev) |
| @@ -644,7 +646,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
| 644 | BUG(); | 646 | BUG(); |
| 645 | 647 | ||
| 646 | dprintk(1, "%s() Memory configured for PCIe bridge type %d\n", | 648 | dprintk(1, "%s() Memory configured for PCIe bridge type %d\n", |
| 647 | __FUNCTION__, dev->bridge); | 649 | __func__, dev->bridge); |
| 648 | 650 | ||
| 649 | /* board config */ | 651 | /* board config */ |
| 650 | dev->board = UNSET; | 652 | dev->board = UNSET; |
| @@ -697,10 +699,12 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
| 697 | dev->i2c_bus[2].reg_wdata = I2C3_WDATA; | 699 | dev->i2c_bus[2].reg_wdata = I2C3_WDATA; |
| 698 | dev->i2c_bus[2].i2c_period = (0x07 << 24); /* 1.95MHz */ | 700 | dev->i2c_bus[2].i2c_period = (0x07 << 24); /* 1.95MHz */ |
| 699 | 701 | ||
| 700 | if(cx23885_boards[dev->board].portb == CX23885_MPEG_DVB) | 702 | if ((cx23885_boards[dev->board].portb == CX23885_MPEG_DVB) || |
| 703 | (cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER)) | ||
| 701 | cx23885_init_tsport(dev, &dev->ts1, 1); | 704 | cx23885_init_tsport(dev, &dev->ts1, 1); |
| 702 | 705 | ||
| 703 | if(cx23885_boards[dev->board].portc == CX23885_MPEG_DVB) | 706 | if ((cx23885_boards[dev->board].portc == CX23885_MPEG_DVB) || |
| 707 | (cx23885_boards[dev->board].portc == CX23885_MPEG_ENCODER)) | ||
| 704 | cx23885_init_tsport(dev, &dev->ts2, 2); | 708 | cx23885_init_tsport(dev, &dev->ts2, 2); |
| 705 | 709 | ||
| 706 | if (get_resources(dev) < 0) { | 710 | if (get_resources(dev) < 0) { |
| @@ -734,9 +738,9 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
| 734 | dev->radio_addr = cx23885_boards[dev->board].radio_addr; | 738 | dev->radio_addr = cx23885_boards[dev->board].radio_addr; |
| 735 | 739 | ||
| 736 | dprintk(1, "%s() tuner_type = 0x%x tuner_addr = 0x%x\n", | 740 | dprintk(1, "%s() tuner_type = 0x%x tuner_addr = 0x%x\n", |
| 737 | __FUNCTION__, dev->tuner_type, dev->tuner_addr); | 741 | __func__, dev->tuner_type, dev->tuner_addr); |
| 738 | dprintk(1, "%s() radio_type = 0x%x radio_addr = 0x%x\n", | 742 | dprintk(1, "%s() radio_type = 0x%x radio_addr = 0x%x\n", |
| 739 | __FUNCTION__, dev->radio_type, dev->radio_addr); | 743 | __func__, dev->radio_type, dev->radio_addr); |
| 740 | 744 | ||
| 741 | /* init hardware */ | 745 | /* init hardware */ |
| 742 | cx23885_reset(dev); | 746 | cx23885_reset(dev); |
| @@ -744,28 +748,43 @@ static int cx23885_dev_setup(struct cx23885_dev *dev) | |||
| 744 | cx23885_i2c_register(&dev->i2c_bus[0]); | 748 | cx23885_i2c_register(&dev->i2c_bus[0]); |
| 745 | cx23885_i2c_register(&dev->i2c_bus[1]); | 749 | cx23885_i2c_register(&dev->i2c_bus[1]); |
| 746 | cx23885_i2c_register(&dev->i2c_bus[2]); | 750 | cx23885_i2c_register(&dev->i2c_bus[2]); |
| 747 | cx23885_call_i2c_clients (&dev->i2c_bus[0], TUNER_SET_STANDBY, NULL); | ||
| 748 | cx23885_card_setup(dev); | 751 | cx23885_card_setup(dev); |
| 752 | cx23885_call_i2c_clients (&dev->i2c_bus[0], TUNER_SET_STANDBY, NULL); | ||
| 749 | cx23885_ir_init(dev); | 753 | cx23885_ir_init(dev); |
| 750 | 754 | ||
| 751 | if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { | 755 | if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { |
| 752 | if (cx23885_video_register(dev) < 0) { | 756 | if (cx23885_video_register(dev) < 0) { |
| 753 | printk(KERN_ERR "%s() Failed to register analog " | 757 | printk(KERN_ERR "%s() Failed to register analog " |
| 754 | "video adapters on VID_A\n", __FUNCTION__); | 758 | "video adapters on VID_A\n", __func__); |
| 755 | } | 759 | } |
| 756 | } | 760 | } |
| 757 | 761 | ||
| 758 | if (cx23885_boards[dev->board].portb == CX23885_MPEG_DVB) { | 762 | if (cx23885_boards[dev->board].portb == CX23885_MPEG_DVB) { |
| 759 | if (cx23885_dvb_register(&dev->ts1) < 0) { | 763 | if (cx23885_dvb_register(&dev->ts1) < 0) { |
| 760 | printk(KERN_ERR "%s() Failed to register dvb adapters on VID_B\n", | 764 | printk(KERN_ERR "%s() Failed to register dvb adapters on VID_B\n", |
| 761 | __FUNCTION__); | 765 | __func__); |
| 766 | } | ||
| 767 | } else | ||
| 768 | if (cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER) { | ||
| 769 | if (cx23885_417_register(dev) < 0) { | ||
| 770 | printk(KERN_ERR | ||
| 771 | "%s() Failed to register 417 on VID_B\n", | ||
| 772 | __func__); | ||
| 762 | } | 773 | } |
| 763 | } | 774 | } |
| 764 | 775 | ||
| 765 | if (cx23885_boards[dev->board].portc == CX23885_MPEG_DVB) { | 776 | if (cx23885_boards[dev->board].portc == CX23885_MPEG_DVB) { |
| 766 | if (cx23885_dvb_register(&dev->ts2) < 0) { | 777 | if (cx23885_dvb_register(&dev->ts2) < 0) { |
| 767 | printk(KERN_ERR "%s() Failed to register dvb adapters on VID_C\n", | 778 | printk(KERN_ERR |
| 768 | __FUNCTION__); | 779 | "%s() Failed to register dvb on VID_C\n", |
| 780 | __func__); | ||
| 781 | } | ||
| 782 | } else | ||
| 783 | if (cx23885_boards[dev->board].portc == CX23885_MPEG_ENCODER) { | ||
| 784 | if (cx23885_417_register(dev) < 0) { | ||
| 785 | printk(KERN_ERR | ||
| 786 | "%s() Failed to register 417 on VID_C\n", | ||
| 787 | __func__); | ||
| 769 | } | 788 | } |
| 770 | } | 789 | } |
| 771 | 790 | ||
| @@ -785,12 +804,18 @@ static void cx23885_dev_unregister(struct cx23885_dev *dev) | |||
| 785 | if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) | 804 | if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) |
| 786 | cx23885_video_unregister(dev); | 805 | cx23885_video_unregister(dev); |
| 787 | 806 | ||
| 788 | if(cx23885_boards[dev->board].portb == CX23885_MPEG_DVB) | 807 | if (cx23885_boards[dev->board].portb == CX23885_MPEG_DVB) |
| 789 | cx23885_dvb_unregister(&dev->ts1); | 808 | cx23885_dvb_unregister(&dev->ts1); |
| 790 | 809 | ||
| 791 | if(cx23885_boards[dev->board].portc == CX23885_MPEG_DVB) | 810 | if (cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER) |
| 811 | cx23885_417_unregister(dev); | ||
| 812 | |||
| 813 | if (cx23885_boards[dev->board].portc == CX23885_MPEG_DVB) | ||
| 792 | cx23885_dvb_unregister(&dev->ts2); | 814 | cx23885_dvb_unregister(&dev->ts2); |
| 793 | 815 | ||
| 816 | if (cx23885_boards[dev->board].portc == CX23885_MPEG_ENCODER) | ||
| 817 | cx23885_417_unregister(dev); | ||
| 818 | |||
| 794 | cx23885_i2c_unregister(&dev->i2c_bus[2]); | 819 | cx23885_i2c_unregister(&dev->i2c_bus[2]); |
| 795 | cx23885_i2c_unregister(&dev->i2c_bus[1]); | 820 | cx23885_i2c_unregister(&dev->i2c_bus[1]); |
| 796 | cx23885_i2c_unregister(&dev->i2c_bus[0]); | 821 | cx23885_i2c_unregister(&dev->i2c_bus[0]); |
| @@ -952,7 +977,7 @@ void cx23885_free_buffer(struct videobuf_queue *q, struct cx23885_buffer *buf) | |||
| 952 | videobuf_waiton(&buf->vb, 0, 0); | 977 | videobuf_waiton(&buf->vb, 0, 0); |
| 953 | videobuf_dma_unmap(q, dma); | 978 | videobuf_dma_unmap(q, dma); |
| 954 | videobuf_dma_free(dma); | 979 | videobuf_dma_free(dma); |
| 955 | btcx_riscmem_free((struct pci_dev *)q->dev, &buf->risc); | 980 | btcx_riscmem_free(to_pci_dev(q->dev), &buf->risc); |
| 956 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | 981 | buf->vb.state = VIDEOBUF_NEEDS_INIT; |
| 957 | } | 982 | } |
| 958 | 983 | ||
| @@ -960,50 +985,50 @@ static void cx23885_tsport_reg_dump(struct cx23885_tsport *port) | |||
| 960 | { | 985 | { |
| 961 | struct cx23885_dev *dev = port->dev; | 986 | struct cx23885_dev *dev = port->dev; |
| 962 | 987 | ||
| 963 | dprintk(1, "%s() Register Dump\n", __FUNCTION__); | 988 | dprintk(1, "%s() Register Dump\n", __func__); |
| 964 | dprintk(1, "%s() DEV_CNTRL2 0x%08X\n", __FUNCTION__, | 989 | dprintk(1, "%s() DEV_CNTRL2 0x%08X\n", __func__, |
| 965 | cx_read(DEV_CNTRL2)); | 990 | cx_read(DEV_CNTRL2)); |
| 966 | dprintk(1, "%s() PCI_INT_MSK 0x%08X\n", __FUNCTION__, | 991 | dprintk(1, "%s() PCI_INT_MSK 0x%08X\n", __func__, |
| 967 | cx_read(PCI_INT_MSK)); | 992 | cx_read(PCI_INT_MSK)); |
| 968 | dprintk(1, "%s() AUD_INT_INT_MSK 0x%08X\n", __FUNCTION__, | 993 | dprintk(1, "%s() AUD_INT_INT_MSK 0x%08X\n", __func__, |
| 969 | cx_read(AUDIO_INT_INT_MSK)); | 994 | cx_read(AUDIO_INT_INT_MSK)); |
| 970 | dprintk(1, "%s() AUD_INT_DMA_CTL 0x%08X\n", __FUNCTION__, | 995 | dprintk(1, "%s() AUD_INT_DMA_CTL 0x%08X\n", __func__, |
| 971 | cx_read(AUD_INT_DMA_CTL)); | 996 | cx_read(AUD_INT_DMA_CTL)); |
| 972 | dprintk(1, "%s() AUD_EXT_INT_MSK 0x%08X\n", __FUNCTION__, | 997 | dprintk(1, "%s() AUD_EXT_INT_MSK 0x%08X\n", __func__, |
| 973 | cx_read(AUDIO_EXT_INT_MSK)); | 998 | cx_read(AUDIO_EXT_INT_MSK)); |
| 974 | dprintk(1, "%s() AUD_EXT_DMA_CTL 0x%08X\n", __FUNCTION__, | 999 | dprintk(1, "%s() AUD_EXT_DMA_CTL 0x%08X\n", __func__, |
| 975 | cx_read(AUD_EXT_DMA_CTL)); | 1000 | cx_read(AUD_EXT_DMA_CTL)); |
| 976 | dprintk(1, "%s() PAD_CTRL 0x%08X\n", __FUNCTION__, | 1001 | dprintk(1, "%s() PAD_CTRL 0x%08X\n", __func__, |
| 977 | cx_read(PAD_CTRL)); | 1002 | cx_read(PAD_CTRL)); |
| 978 | dprintk(1, "%s() ALT_PIN_OUT_SEL 0x%08X\n", __FUNCTION__, | 1003 | dprintk(1, "%s() ALT_PIN_OUT_SEL 0x%08X\n", __func__, |
| 979 | cx_read(ALT_PIN_OUT_SEL)); | 1004 | cx_read(ALT_PIN_OUT_SEL)); |
| 980 | dprintk(1, "%s() GPIO2 0x%08X\n", __FUNCTION__, | 1005 | dprintk(1, "%s() GPIO2 0x%08X\n", __func__, |
| 981 | cx_read(GPIO2)); | 1006 | cx_read(GPIO2)); |
| 982 | dprintk(1, "%s() gpcnt(0x%08X) 0x%08X\n", __FUNCTION__, | 1007 | dprintk(1, "%s() gpcnt(0x%08X) 0x%08X\n", __func__, |
| 983 | port->reg_gpcnt, cx_read(port->reg_gpcnt)); | 1008 | port->reg_gpcnt, cx_read(port->reg_gpcnt)); |
| 984 | dprintk(1, "%s() gpcnt_ctl(0x%08X) 0x%08x\n", __FUNCTION__, | 1009 | dprintk(1, "%s() gpcnt_ctl(0x%08X) 0x%08x\n", __func__, |
| 985 | port->reg_gpcnt_ctl, cx_read(port->reg_gpcnt_ctl)); | 1010 | port->reg_gpcnt_ctl, cx_read(port->reg_gpcnt_ctl)); |
| 986 | dprintk(1, "%s() dma_ctl(0x%08X) 0x%08x\n", __FUNCTION__, | 1011 | dprintk(1, "%s() dma_ctl(0x%08X) 0x%08x\n", __func__, |
| 987 | port->reg_dma_ctl, cx_read(port->reg_dma_ctl)); | 1012 | port->reg_dma_ctl, cx_read(port->reg_dma_ctl)); |
| 988 | dprintk(1, "%s() src_sel(0x%08X) 0x%08x\n", __FUNCTION__, | 1013 | dprintk(1, "%s() src_sel(0x%08X) 0x%08x\n", __func__, |
| 989 | port->reg_src_sel, cx_read(port->reg_src_sel)); | 1014 | port->reg_src_sel, cx_read(port->reg_src_sel)); |
| 990 | dprintk(1, "%s() lngth(0x%08X) 0x%08x\n", __FUNCTION__, | 1015 | dprintk(1, "%s() lngth(0x%08X) 0x%08x\n", __func__, |
| 991 | port->reg_lngth, cx_read(port->reg_lngth)); | 1016 | port->reg_lngth, cx_read(port->reg_lngth)); |
| 992 | dprintk(1, "%s() hw_sop_ctrl(0x%08X) 0x%08x\n", __FUNCTION__, | 1017 | dprintk(1, "%s() hw_sop_ctrl(0x%08X) 0x%08x\n", __func__, |
| 993 | port->reg_hw_sop_ctrl, cx_read(port->reg_hw_sop_ctrl)); | 1018 | port->reg_hw_sop_ctrl, cx_read(port->reg_hw_sop_ctrl)); |
| 994 | dprintk(1, "%s() gen_ctrl(0x%08X) 0x%08x\n", __FUNCTION__, | 1019 | dprintk(1, "%s() gen_ctrl(0x%08X) 0x%08x\n", __func__, |
| 995 | port->reg_gen_ctrl, cx_read(port->reg_gen_ctrl)); | 1020 | port->reg_gen_ctrl, cx_read(port->reg_gen_ctrl)); |
| 996 | dprintk(1, "%s() bd_pkt_status(0x%08X) 0x%08x\n", __FUNCTION__, | 1021 | dprintk(1, "%s() bd_pkt_status(0x%08X) 0x%08x\n", __func__, |
| 997 | port->reg_bd_pkt_status, cx_read(port->reg_bd_pkt_status)); | 1022 | port->reg_bd_pkt_status, cx_read(port->reg_bd_pkt_status)); |
| 998 | dprintk(1, "%s() sop_status(0x%08X) 0x%08x\n", __FUNCTION__, | 1023 | dprintk(1, "%s() sop_status(0x%08X) 0x%08x\n", __func__, |
| 999 | port->reg_sop_status, cx_read(port->reg_sop_status)); | 1024 | port->reg_sop_status, cx_read(port->reg_sop_status)); |
| 1000 | dprintk(1, "%s() fifo_ovfl_stat(0x%08X) 0x%08x\n", __FUNCTION__, | 1025 | dprintk(1, "%s() fifo_ovfl_stat(0x%08X) 0x%08x\n", __func__, |
| 1001 | port->reg_fifo_ovfl_stat, cx_read(port->reg_fifo_ovfl_stat)); | 1026 | port->reg_fifo_ovfl_stat, cx_read(port->reg_fifo_ovfl_stat)); |
| 1002 | dprintk(1, "%s() vld_misc(0x%08X) 0x%08x\n", __FUNCTION__, | 1027 | dprintk(1, "%s() vld_misc(0x%08X) 0x%08x\n", __func__, |
| 1003 | port->reg_vld_misc, cx_read(port->reg_vld_misc)); | 1028 | port->reg_vld_misc, cx_read(port->reg_vld_misc)); |
| 1004 | dprintk(1, "%s() ts_clk_en(0x%08X) 0x%08x\n", __FUNCTION__, | 1029 | dprintk(1, "%s() ts_clk_en(0x%08X) 0x%08x\n", __func__, |
| 1005 | port->reg_ts_clk_en, cx_read(port->reg_ts_clk_en)); | 1030 | port->reg_ts_clk_en, cx_read(port->reg_ts_clk_en)); |
| 1006 | dprintk(1, "%s() ts_int_msk(0x%08X) 0x%08x\n", __FUNCTION__, | 1031 | dprintk(1, "%s() ts_int_msk(0x%08X) 0x%08x\n", __func__, |
| 1007 | port->reg_ts_int_msk, cx_read(port->reg_ts_int_msk)); | 1032 | port->reg_ts_int_msk, cx_read(port->reg_ts_int_msk)); |
| 1008 | } | 1033 | } |
| 1009 | 1034 | ||
| @@ -1012,8 +1037,9 @@ static int cx23885_start_dma(struct cx23885_tsport *port, | |||
| 1012 | struct cx23885_buffer *buf) | 1037 | struct cx23885_buffer *buf) |
| 1013 | { | 1038 | { |
| 1014 | struct cx23885_dev *dev = port->dev; | 1039 | struct cx23885_dev *dev = port->dev; |
| 1040 | u32 reg; | ||
| 1015 | 1041 | ||
| 1016 | dprintk(1, "%s() w: %d, h: %d, f: %d\n", __FUNCTION__, | 1042 | dprintk(1, "%s() w: %d, h: %d, f: %d\n", __func__, |
| 1017 | buf->vb.width, buf->vb.height, buf->vb.field); | 1043 | buf->vb.width, buf->vb.height, buf->vb.field); |
| 1018 | 1044 | ||
| 1019 | /* setup fifo + format */ | 1045 | /* setup fifo + format */ |
| @@ -1031,21 +1057,24 @@ static int cx23885_start_dma(struct cx23885_tsport *port, | |||
| 1031 | if ( (!(cx23885_boards[dev->board].portb & CX23885_MPEG_DVB)) && | 1057 | if ( (!(cx23885_boards[dev->board].portb & CX23885_MPEG_DVB)) && |
| 1032 | (!(cx23885_boards[dev->board].portc & CX23885_MPEG_DVB)) ) { | 1058 | (!(cx23885_boards[dev->board].portc & CX23885_MPEG_DVB)) ) { |
| 1033 | printk( "%s() Failed. Unsupported value in .portb/c (0x%08x)/(0x%08x)\n", | 1059 | printk( "%s() Failed. Unsupported value in .portb/c (0x%08x)/(0x%08x)\n", |
| 1034 | __FUNCTION__, | 1060 | __func__, |
| 1035 | cx23885_boards[dev->board].portb, | 1061 | cx23885_boards[dev->board].portb, |
| 1036 | cx23885_boards[dev->board].portc ); | 1062 | cx23885_boards[dev->board].portc ); |
| 1037 | return -EINVAL; | 1063 | return -EINVAL; |
| 1038 | } | 1064 | } |
| 1039 | 1065 | ||
| 1066 | if (cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER) | ||
| 1067 | cx23885_av_clk(dev, 0); | ||
| 1068 | |||
| 1040 | udelay(100); | 1069 | udelay(100); |
| 1041 | 1070 | ||
| 1042 | /* If the port supports SRC SELECT, configure it */ | 1071 | /* If the port supports SRC SELECT, configure it */ |
| 1043 | if(port->reg_src_sel) | 1072 | if(port->reg_src_sel) |
| 1044 | cx_write(port->reg_src_sel, port->src_sel_val); | 1073 | cx_write(port->reg_src_sel, port->src_sel_val); |
| 1045 | 1074 | ||
| 1046 | cx_write(port->reg_hw_sop_ctrl, 0x47 << 16 | 188 << 4); | 1075 | cx_write(port->reg_hw_sop_ctrl, port->hw_sop_ctrl_val); |
| 1047 | cx_write(port->reg_ts_clk_en, port->ts_clk_en_val); | 1076 | cx_write(port->reg_ts_clk_en, port->ts_clk_en_val); |
| 1048 | cx_write(port->reg_vld_misc, 0x00); | 1077 | cx_write(port->reg_vld_misc, port->vld_misc_val); |
| 1049 | cx_write(port->reg_gen_ctrl, port->gen_ctrl_val); | 1078 | cx_write(port->reg_gen_ctrl, port->gen_ctrl_val); |
| 1050 | udelay(100); | 1079 | udelay(100); |
| 1051 | 1080 | ||
| @@ -1054,11 +1083,26 @@ static int cx23885_start_dma(struct cx23885_tsport *port, | |||
| 1054 | cx_write(port->reg_gpcnt_ctl, 3); | 1083 | cx_write(port->reg_gpcnt_ctl, 3); |
| 1055 | q->count = 1; | 1084 | q->count = 1; |
| 1056 | 1085 | ||
| 1086 | if (cx23885_boards[dev->board].portb & CX23885_MPEG_ENCODER) { | ||
| 1087 | |||
| 1088 | reg = cx_read(PAD_CTRL); | ||
| 1089 | reg = reg & ~0x1; /* Clear TS1_OE */ | ||
| 1090 | |||
| 1091 | /* FIXME, bit 2 writing here is questionable */ | ||
| 1092 | /* set TS1_SOP_OE and TS1_OE_HI */ | ||
| 1093 | reg = reg | 0xa; | ||
| 1094 | cx_write(PAD_CTRL, reg); | ||
| 1095 | |||
| 1096 | /* FIXME and these two registers should be documented. */ | ||
| 1097 | cx_write(CLK_DELAY, cx_read(CLK_DELAY) | 0x80000011); | ||
| 1098 | cx_write(ALT_PIN_OUT_SEL, 0x10100045); | ||
| 1099 | } | ||
| 1100 | |||
| 1057 | switch(dev->bridge) { | 1101 | switch(dev->bridge) { |
| 1058 | case CX23885_BRIDGE_885: | 1102 | case CX23885_BRIDGE_885: |
| 1059 | case CX23885_BRIDGE_887: | 1103 | case CX23885_BRIDGE_887: |
| 1060 | /* enable irqs */ | 1104 | /* enable irqs */ |
| 1061 | dprintk(1, "%s() enabling TS int's and DMA\n", __FUNCTION__ ); | 1105 | dprintk(1, "%s() enabling TS int's and DMA\n", __func__ ); |
| 1062 | cx_set(port->reg_ts_int_msk, port->ts_int_msk_val); | 1106 | cx_set(port->reg_ts_int_msk, port->ts_int_msk_val); |
| 1063 | cx_set(port->reg_dma_ctl, port->dma_ctl_val); | 1107 | cx_set(port->reg_dma_ctl, port->dma_ctl_val); |
| 1064 | cx_set(PCI_INT_MSK, dev->pci_irqmask | port->pci_irqmask); | 1108 | cx_set(PCI_INT_MSK, dev->pci_irqmask | port->pci_irqmask); |
| @@ -1069,6 +1113,9 @@ static int cx23885_start_dma(struct cx23885_tsport *port, | |||
| 1069 | 1113 | ||
| 1070 | cx_set(DEV_CNTRL2, (1<<5)); /* Enable RISC controller */ | 1114 | cx_set(DEV_CNTRL2, (1<<5)); /* Enable RISC controller */ |
| 1071 | 1115 | ||
| 1116 | if (cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER) | ||
| 1117 | cx23885_av_clk(dev, 1); | ||
| 1118 | |||
| 1072 | if (debug > 4) | 1119 | if (debug > 4) |
| 1073 | cx23885_tsport_reg_dump(port); | 1120 | cx23885_tsport_reg_dump(port); |
| 1074 | 1121 | ||
| @@ -1078,12 +1125,32 @@ static int cx23885_start_dma(struct cx23885_tsport *port, | |||
| 1078 | static int cx23885_stop_dma(struct cx23885_tsport *port) | 1125 | static int cx23885_stop_dma(struct cx23885_tsport *port) |
| 1079 | { | 1126 | { |
| 1080 | struct cx23885_dev *dev = port->dev; | 1127 | struct cx23885_dev *dev = port->dev; |
| 1081 | dprintk(1, "%s()\n", __FUNCTION__); | 1128 | u32 reg; |
| 1129 | |||
| 1130 | dprintk(1, "%s()\n", __func__); | ||
| 1082 | 1131 | ||
| 1083 | /* Stop interrupts and DMA */ | 1132 | /* Stop interrupts and DMA */ |
| 1084 | cx_clear(port->reg_ts_int_msk, port->ts_int_msk_val); | 1133 | cx_clear(port->reg_ts_int_msk, port->ts_int_msk_val); |
| 1085 | cx_clear(port->reg_dma_ctl, port->dma_ctl_val); | 1134 | cx_clear(port->reg_dma_ctl, port->dma_ctl_val); |
| 1086 | 1135 | ||
| 1136 | if (cx23885_boards[dev->board].portb & CX23885_MPEG_ENCODER) { | ||
| 1137 | |||
| 1138 | reg = cx_read(PAD_CTRL); | ||
| 1139 | |||
| 1140 | /* Set TS1_OE */ | ||
| 1141 | reg = reg | 0x1; | ||
| 1142 | |||
| 1143 | /* clear TS1_SOP_OE and TS1_OE_HI */ | ||
| 1144 | reg = reg & ~0xa; | ||
| 1145 | cx_write(PAD_CTRL, reg); | ||
| 1146 | cx_write(port->reg_src_sel, 0); | ||
| 1147 | cx_write(port->reg_gen_ctrl, 8); | ||
| 1148 | |||
| 1149 | } | ||
| 1150 | |||
| 1151 | if (cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER) | ||
| 1152 | cx23885_av_clk(dev, 0); | ||
| 1153 | |||
| 1087 | return 0; | 1154 | return 0; |
| 1088 | } | 1155 | } |
| 1089 | 1156 | ||
| @@ -1093,13 +1160,13 @@ int cx23885_restart_queue(struct cx23885_tsport *port, | |||
| 1093 | struct cx23885_dev *dev = port->dev; | 1160 | struct cx23885_dev *dev = port->dev; |
| 1094 | struct cx23885_buffer *buf; | 1161 | struct cx23885_buffer *buf; |
| 1095 | 1162 | ||
| 1096 | dprintk(5, "%s()\n", __FUNCTION__); | 1163 | dprintk(5, "%s()\n", __func__); |
| 1097 | if (list_empty(&q->active)) | 1164 | if (list_empty(&q->active)) |
| 1098 | { | 1165 | { |
| 1099 | struct cx23885_buffer *prev; | 1166 | struct cx23885_buffer *prev; |
| 1100 | prev = NULL; | 1167 | prev = NULL; |
| 1101 | 1168 | ||
| 1102 | dprintk(5, "%s() queue is empty\n", __FUNCTION__); | 1169 | dprintk(5, "%s() queue is empty\n", __func__); |
| 1103 | 1170 | ||
| 1104 | for (;;) { | 1171 | for (;;) { |
| 1105 | if (list_empty(&q->queued)) | 1172 | if (list_empty(&q->queued)) |
| @@ -1154,7 +1221,7 @@ int cx23885_buf_prepare(struct videobuf_queue *q, struct cx23885_tsport *port, | |||
| 1154 | int size = port->ts_packet_size * port->ts_packet_count; | 1221 | int size = port->ts_packet_size * port->ts_packet_count; |
| 1155 | int rc; | 1222 | int rc; |
| 1156 | 1223 | ||
| 1157 | dprintk(1, "%s: %p\n", __FUNCTION__, buf); | 1224 | dprintk(1, "%s: %p\n", __func__, buf); |
| 1158 | if (0 != buf->vb.baddr && buf->vb.bsize < size) | 1225 | if (0 != buf->vb.baddr && buf->vb.bsize < size) |
| 1159 | return -EINVAL; | 1226 | return -EINVAL; |
| 1160 | 1227 | ||
| @@ -1197,7 +1264,7 @@ void cx23885_buf_queue(struct cx23885_tsport *port, struct cx23885_buffer *buf) | |||
| 1197 | buf->count = cx88q->count++; | 1264 | buf->count = cx88q->count++; |
| 1198 | mod_timer(&cx88q->timeout, jiffies + BUFFER_TIMEOUT); | 1265 | mod_timer(&cx88q->timeout, jiffies + BUFFER_TIMEOUT); |
| 1199 | dprintk(1, "[%p/%d] %s - first active\n", | 1266 | dprintk(1, "[%p/%d] %s - first active\n", |
| 1200 | buf, buf->vb.i, __FUNCTION__); | 1267 | buf, buf->vb.i, __func__); |
| 1201 | } else { | 1268 | } else { |
| 1202 | dprintk( 1, "queue is not empty - append to active\n" ); | 1269 | dprintk( 1, "queue is not empty - append to active\n" ); |
| 1203 | prev = list_entry(cx88q->active.prev, struct cx23885_buffer, | 1270 | prev = list_entry(cx88q->active.prev, struct cx23885_buffer, |
| @@ -1208,7 +1275,7 @@ void cx23885_buf_queue(struct cx23885_tsport *port, struct cx23885_buffer *buf) | |||
| 1208 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 1275 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
| 1209 | prev->risc.jmp[2] = cpu_to_le32(0); /* 64 bit bits 63-32 */ | 1276 | prev->risc.jmp[2] = cpu_to_le32(0); /* 64 bit bits 63-32 */ |
| 1210 | dprintk( 1, "[%p/%d] %s - append to active\n", | 1277 | dprintk( 1, "[%p/%d] %s - append to active\n", |
| 1211 | buf, buf->vb.i, __FUNCTION__); | 1278 | buf, buf->vb.i, __func__); |
| 1212 | } | 1279 | } |
| 1213 | } | 1280 | } |
| 1214 | 1281 | ||
| @@ -1239,13 +1306,23 @@ static void do_cancel_buffers(struct cx23885_tsport *port, char *reason, | |||
| 1239 | spin_unlock_irqrestore(&port->slock, flags); | 1306 | spin_unlock_irqrestore(&port->slock, flags); |
| 1240 | } | 1307 | } |
| 1241 | 1308 | ||
| 1309 | void cx23885_cancel_buffers(struct cx23885_tsport *port) | ||
| 1310 | { | ||
| 1311 | struct cx23885_dev *dev = port->dev; | ||
| 1312 | struct cx23885_dmaqueue *q = &port->mpegq; | ||
| 1313 | |||
| 1314 | dprintk(1, "%s()\n", __FUNCTION__); | ||
| 1315 | del_timer_sync(&q->timeout); | ||
| 1316 | cx23885_stop_dma(port); | ||
| 1317 | do_cancel_buffers(port, "cancel", 0); | ||
| 1318 | } | ||
| 1242 | 1319 | ||
| 1243 | static void cx23885_timeout(unsigned long data) | 1320 | static void cx23885_timeout(unsigned long data) |
| 1244 | { | 1321 | { |
| 1245 | struct cx23885_tsport *port = (struct cx23885_tsport *)data; | 1322 | struct cx23885_tsport *port = (struct cx23885_tsport *)data; |
| 1246 | struct cx23885_dev *dev = port->dev; | 1323 | struct cx23885_dev *dev = port->dev; |
| 1247 | 1324 | ||
| 1248 | dprintk(1, "%s()\n",__FUNCTION__); | 1325 | dprintk(1, "%s()\n",__func__); |
| 1249 | 1326 | ||
| 1250 | if (debug > 5) | 1327 | if (debug > 5) |
| 1251 | cx23885_sram_channel_dump(dev, &dev->sram_channels[ port->sram_chno ]); | 1328 | cx23885_sram_channel_dump(dev, &dev->sram_channels[ port->sram_chno ]); |
| @@ -1254,16 +1331,77 @@ static void cx23885_timeout(unsigned long data) | |||
| 1254 | do_cancel_buffers(port, "timeout", 1); | 1331 | do_cancel_buffers(port, "timeout", 1); |
| 1255 | } | 1332 | } |
| 1256 | 1333 | ||
| 1334 | int cx23885_irq_417(struct cx23885_dev *dev, u32 status) | ||
| 1335 | { | ||
| 1336 | /* FIXME: port1 assumption here. */ | ||
| 1337 | struct cx23885_tsport *port = &dev->ts1; | ||
| 1338 | int count = 0; | ||
| 1339 | int handled = 0; | ||
| 1340 | |||
| 1341 | if (status == 0) | ||
| 1342 | return handled; | ||
| 1343 | |||
| 1344 | count = cx_read(port->reg_gpcnt); | ||
| 1345 | dprintk(7, "status: 0x%08x mask: 0x%08x count: 0x%x\n", | ||
| 1346 | status, cx_read(port->reg_ts_int_msk), count); | ||
| 1347 | |||
| 1348 | if ((status & VID_B_MSK_BAD_PKT) || | ||
| 1349 | (status & VID_B_MSK_OPC_ERR) || | ||
| 1350 | (status & VID_B_MSK_VBI_OPC_ERR) || | ||
| 1351 | (status & VID_B_MSK_SYNC) || | ||
| 1352 | (status & VID_B_MSK_VBI_SYNC) || | ||
| 1353 | (status & VID_B_MSK_OF) || | ||
| 1354 | (status & VID_B_MSK_VBI_OF)) { | ||
| 1355 | printk(KERN_ERR "%s: V4L mpeg risc op code error, status " | ||
| 1356 | "= 0x%x\n", dev->name, status); | ||
| 1357 | if (status & VID_B_MSK_BAD_PKT) | ||
| 1358 | dprintk(1, " VID_B_MSK_BAD_PKT\n"); | ||
| 1359 | if (status & VID_B_MSK_OPC_ERR) | ||
| 1360 | dprintk(1, " VID_B_MSK_OPC_ERR\n"); | ||
| 1361 | if (status & VID_B_MSK_VBI_OPC_ERR) | ||
| 1362 | dprintk(1, " VID_B_MSK_VBI_OPC_ERR\n"); | ||
| 1363 | if (status & VID_B_MSK_SYNC) | ||
| 1364 | dprintk(1, " VID_B_MSK_SYNC\n"); | ||
| 1365 | if (status & VID_B_MSK_VBI_SYNC) | ||
| 1366 | dprintk(1, " VID_B_MSK_VBI_SYNC\n"); | ||
| 1367 | if (status & VID_B_MSK_OF) | ||
| 1368 | dprintk(1, " VID_B_MSK_OF\n"); | ||
| 1369 | if (status & VID_B_MSK_VBI_OF) | ||
| 1370 | dprintk(1, " VID_B_MSK_VBI_OF\n"); | ||
| 1371 | |||
| 1372 | cx_clear(port->reg_dma_ctl, port->dma_ctl_val); | ||
| 1373 | cx23885_sram_channel_dump(dev, | ||
| 1374 | &dev->sram_channels[port->sram_chno]); | ||
| 1375 | cx23885_417_check_encoder(dev); | ||
| 1376 | } else if (status & VID_B_MSK_RISCI1) { | ||
| 1377 | dprintk(7, " VID_B_MSK_RISCI1\n"); | ||
| 1378 | spin_lock(&port->slock); | ||
| 1379 | cx23885_wakeup(port, &port->mpegq, count); | ||
| 1380 | spin_unlock(&port->slock); | ||
| 1381 | } else if (status & VID_B_MSK_RISCI2) { | ||
| 1382 | dprintk(7, " VID_B_MSK_RISCI2\n"); | ||
| 1383 | spin_lock(&port->slock); | ||
| 1384 | cx23885_restart_queue(port, &port->mpegq); | ||
| 1385 | spin_unlock(&port->slock); | ||
| 1386 | } | ||
| 1387 | if (status) { | ||
| 1388 | cx_write(port->reg_ts_int_stat, status); | ||
| 1389 | handled = 1; | ||
| 1390 | } | ||
| 1391 | |||
| 1392 | return handled; | ||
| 1393 | } | ||
| 1394 | |||
| 1257 | static int cx23885_irq_ts(struct cx23885_tsport *port, u32 status) | 1395 | static int cx23885_irq_ts(struct cx23885_tsport *port, u32 status) |
| 1258 | { | 1396 | { |
| 1259 | struct cx23885_dev *dev = port->dev; | 1397 | struct cx23885_dev *dev = port->dev; |
| 1260 | int handled = 0; | 1398 | int handled = 0; |
| 1261 | u32 count; | 1399 | u32 count; |
| 1262 | 1400 | ||
| 1263 | if ( (status & VID_BC_MSK_OPC_ERR) || | 1401 | if ((status & VID_BC_MSK_OPC_ERR) || |
| 1264 | (status & VID_BC_MSK_BAD_PKT) || | 1402 | (status & VID_BC_MSK_BAD_PKT) || |
| 1265 | (status & VID_BC_MSK_SYNC) || | 1403 | (status & VID_BC_MSK_SYNC) || |
| 1266 | (status & VID_BC_MSK_OF)) | 1404 | (status & VID_BC_MSK_OF)) |
| 1267 | { | 1405 | { |
| 1268 | if (status & VID_BC_MSK_OPC_ERR) | 1406 | if (status & VID_BC_MSK_OPC_ERR) |
| 1269 | dprintk(7, " (VID_BC_MSK_OPC_ERR 0x%08x)\n", VID_BC_MSK_OPC_ERR); | 1407 | dprintk(7, " (VID_BC_MSK_OPC_ERR 0x%08x)\n", VID_BC_MSK_OPC_ERR); |
| @@ -1277,7 +1415,8 @@ static int cx23885_irq_ts(struct cx23885_tsport *port, u32 status) | |||
| 1277 | printk(KERN_ERR "%s: mpeg risc op code error\n", dev->name); | 1415 | printk(KERN_ERR "%s: mpeg risc op code error\n", dev->name); |
| 1278 | 1416 | ||
| 1279 | cx_clear(port->reg_dma_ctl, port->dma_ctl_val); | 1417 | cx_clear(port->reg_dma_ctl, port->dma_ctl_val); |
| 1280 | cx23885_sram_channel_dump(dev, &dev->sram_channels[ port->sram_chno ]); | 1418 | cx23885_sram_channel_dump(dev, |
| 1419 | &dev->sram_channels[port->sram_chno]); | ||
| 1281 | 1420 | ||
| 1282 | } else if (status & VID_BC_MSK_RISCI1) { | 1421 | } else if (status & VID_BC_MSK_RISCI1) { |
| 1283 | 1422 | ||
| @@ -1378,11 +1517,17 @@ static irqreturn_t cx23885_irq(int irq, void *dev_id) | |||
| 1378 | if (ts1_status) { | 1517 | if (ts1_status) { |
| 1379 | if (cx23885_boards[dev->board].portb == CX23885_MPEG_DVB) | 1518 | if (cx23885_boards[dev->board].portb == CX23885_MPEG_DVB) |
| 1380 | handled += cx23885_irq_ts(ts1, ts1_status); | 1519 | handled += cx23885_irq_ts(ts1, ts1_status); |
| 1520 | else | ||
| 1521 | if (cx23885_boards[dev->board].portb == CX23885_MPEG_ENCODER) | ||
| 1522 | handled += cx23885_irq_417(dev, ts1_status); | ||
| 1381 | } | 1523 | } |
| 1382 | 1524 | ||
| 1383 | if (ts2_status) { | 1525 | if (ts2_status) { |
| 1384 | if (cx23885_boards[dev->board].portc == CX23885_MPEG_DVB) | 1526 | if (cx23885_boards[dev->board].portc == CX23885_MPEG_DVB) |
| 1385 | handled += cx23885_irq_ts(ts2, ts2_status); | 1527 | handled += cx23885_irq_ts(ts2, ts2_status); |
| 1528 | else | ||
| 1529 | if (cx23885_boards[dev->board].portc == CX23885_MPEG_ENCODER) | ||
| 1530 | handled += cx23885_irq_417(dev, ts2_status); | ||
| 1386 | } | 1531 | } |
| 1387 | 1532 | ||
| 1388 | if (vida_status) | 1533 | if (vida_status) |
| @@ -1422,7 +1567,8 @@ static int __devinit cx23885_initdev(struct pci_dev *pci_dev, | |||
| 1422 | printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, " | 1567 | printk(KERN_INFO "%s/0: found at %s, rev: %d, irq: %d, " |
| 1423 | "latency: %d, mmio: 0x%llx\n", dev->name, | 1568 | "latency: %d, mmio: 0x%llx\n", dev->name, |
| 1424 | pci_name(pci_dev), dev->pci_rev, pci_dev->irq, | 1569 | pci_name(pci_dev), dev->pci_rev, pci_dev->irq, |
| 1425 | dev->pci_lat, (unsigned long long)pci_resource_start(pci_dev,0)); | 1570 | dev->pci_lat, |
| 1571 | (unsigned long long)pci_resource_start(pci_dev, 0)); | ||
| 1426 | 1572 | ||
| 1427 | pci_set_master(pci_dev); | 1573 | pci_set_master(pci_dev); |
| 1428 | if (!pci_dma_supported(pci_dev, 0xffffffff)) { | 1574 | if (!pci_dma_supported(pci_dev, 0xffffffff)) { |
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c index ed465c007cea..870d6e197d65 100644 --- a/drivers/media/video/cx23885/cx23885-dvb.c +++ b/drivers/media/video/cx23885/cx23885-dvb.c | |||
| @@ -36,9 +36,12 @@ | |||
| 36 | #include "tda18271.h" | 36 | #include "tda18271.h" |
| 37 | #include "lgdt330x.h" | 37 | #include "lgdt330x.h" |
| 38 | #include "xc5000.h" | 38 | #include "xc5000.h" |
| 39 | #include "tda10048.h" | ||
| 39 | #include "dvb-pll.h" | 40 | #include "dvb-pll.h" |
| 40 | #include "tuner-xc2028.h" | 41 | #include "tuner-xc2028.h" |
| 41 | #include "tuner-xc2028-types.h" | 42 | #include "tuner-simple.h" |
| 43 | #include "dib7000p.h" | ||
| 44 | #include "dibx000_common.h" | ||
| 42 | 45 | ||
| 43 | static unsigned int debug; | 46 | static unsigned int debug; |
| 44 | 47 | ||
| @@ -53,6 +56,8 @@ static unsigned int alt_tuner; | |||
| 53 | module_param(alt_tuner, int, 0644); | 56 | module_param(alt_tuner, int, 0644); |
| 54 | MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration"); | 57 | MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration"); |
| 55 | 58 | ||
| 59 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 60 | |||
| 56 | /* ------------------------------------------------------------------ */ | 61 | /* ------------------------------------------------------------------ */ |
| 57 | 62 | ||
| 58 | static int dvb_buf_setup(struct videobuf_queue *q, | 63 | static int dvb_buf_setup(struct videobuf_queue *q, |
| @@ -104,6 +109,13 @@ static struct s5h1409_config hauppauge_generic_config = { | |||
| 104 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | 109 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, |
| 105 | }; | 110 | }; |
| 106 | 111 | ||
| 112 | static struct tda10048_config hauppauge_hvr1200_config = { | ||
| 113 | .demod_address = 0x10 >> 1, | ||
| 114 | .output_mode = TDA10048_SERIAL_OUTPUT, | ||
| 115 | .fwbulkwritelen = TDA10048_BULKWRITE_200, | ||
| 116 | .inversion = TDA10048_INVERSION_ON | ||
| 117 | }; | ||
| 118 | |||
| 107 | static struct s5h1409_config hauppauge_ezqam_config = { | 119 | static struct s5h1409_config hauppauge_ezqam_config = { |
| 108 | .demod_address = 0x32 >> 1, | 120 | .demod_address = 0x32 >> 1, |
| 109 | .output_mode = S5H1409_SERIAL_OUTPUT, | 121 | .output_mode = S5H1409_SERIAL_OUTPUT, |
| @@ -164,8 +176,10 @@ static struct tda829x_config tda829x_no_probe = { | |||
| 164 | }; | 176 | }; |
| 165 | 177 | ||
| 166 | static struct tda18271_std_map hauppauge_tda18271_std_map = { | 178 | static struct tda18271_std_map hauppauge_tda18271_std_map = { |
| 167 | .atsc_6 = { .if_freq = 5380, .std_bits = 0x1b }, | 179 | .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3, |
| 168 | .qam_6 = { .if_freq = 4000, .std_bits = 0x18 }, | 180 | .if_lvl = 6, .rfagc_top = 0x37 }, |
| 181 | .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0, | ||
| 182 | .if_lvl = 6, .rfagc_top = 0x37 }, | ||
| 169 | }; | 183 | }; |
| 170 | 184 | ||
| 171 | static struct tda18271_config hauppauge_tda18271_config = { | 185 | static struct tda18271_config hauppauge_tda18271_config = { |
| @@ -173,6 +187,96 @@ static struct tda18271_config hauppauge_tda18271_config = { | |||
| 173 | .gate = TDA18271_GATE_ANALOG, | 187 | .gate = TDA18271_GATE_ANALOG, |
| 174 | }; | 188 | }; |
| 175 | 189 | ||
| 190 | static struct tda18271_config hauppauge_hvr1200_tuner_config = { | ||
| 191 | .gate = TDA18271_GATE_ANALOG, | ||
| 192 | }; | ||
| 193 | |||
| 194 | struct dibx000_agc_config xc3028_agc_config = { | ||
| 195 | BAND_VHF | BAND_UHF, /* band_caps */ | ||
| 196 | |||
| 197 | /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0, | ||
| 198 | * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, | ||
| 199 | * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0, | ||
| 200 | * P_agc_nb_est=2, P_agc_write=0 | ||
| 201 | */ | ||
| 202 | (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) | | ||
| 203 | (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */ | ||
| 204 | |||
| 205 | 712, /* inv_gain */ | ||
| 206 | 21, /* time_stabiliz */ | ||
| 207 | |||
| 208 | 0, /* alpha_level */ | ||
| 209 | 118, /* thlock */ | ||
| 210 | |||
| 211 | 0, /* wbd_inv */ | ||
| 212 | 2867, /* wbd_ref */ | ||
| 213 | 0, /* wbd_sel */ | ||
| 214 | 2, /* wbd_alpha */ | ||
| 215 | |||
| 216 | 0, /* agc1_max */ | ||
| 217 | 0, /* agc1_min */ | ||
| 218 | 39718, /* agc2_max */ | ||
| 219 | 9930, /* agc2_min */ | ||
| 220 | 0, /* agc1_pt1 */ | ||
| 221 | 0, /* agc1_pt2 */ | ||
| 222 | 0, /* agc1_pt3 */ | ||
| 223 | 0, /* agc1_slope1 */ | ||
| 224 | 0, /* agc1_slope2 */ | ||
| 225 | 0, /* agc2_pt1 */ | ||
| 226 | 128, /* agc2_pt2 */ | ||
| 227 | 29, /* agc2_slope1 */ | ||
| 228 | 29, /* agc2_slope2 */ | ||
| 229 | |||
| 230 | 17, /* alpha_mant */ | ||
| 231 | 27, /* alpha_exp */ | ||
| 232 | 23, /* beta_mant */ | ||
| 233 | 51, /* beta_exp */ | ||
| 234 | |||
| 235 | 1, /* perform_agc_softsplit */ | ||
| 236 | }; | ||
| 237 | |||
| 238 | /* PLL Configuration for COFDM BW_MHz = 8.000000 | ||
| 239 | * With external clock = 30.000000 */ | ||
| 240 | struct dibx000_bandwidth_config xc3028_bw_config = { | ||
| 241 | 60000, /* internal */ | ||
| 242 | 30000, /* sampling */ | ||
| 243 | 1, /* pll_cfg: prediv */ | ||
| 244 | 8, /* pll_cfg: ratio */ | ||
| 245 | 3, /* pll_cfg: range */ | ||
| 246 | 1, /* pll_cfg: reset */ | ||
| 247 | 0, /* pll_cfg: bypass */ | ||
| 248 | 0, /* misc: refdiv */ | ||
| 249 | 0, /* misc: bypclk_div */ | ||
| 250 | 1, /* misc: IO_CLK_en_core */ | ||
| 251 | 1, /* misc: ADClkSrc */ | ||
| 252 | 0, /* misc: modulo */ | ||
| 253 | (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */ | ||
| 254 | (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */ | ||
| 255 | 20452225, /* timf */ | ||
| 256 | 30000000 /* xtal_hz */ | ||
| 257 | }; | ||
| 258 | |||
| 259 | static struct dib7000p_config hauppauge_hvr1400_dib7000_config = { | ||
| 260 | .output_mpeg2_in_188_bytes = 1, | ||
| 261 | .hostbus_diversity = 1, | ||
| 262 | .tuner_is_baseband = 0, | ||
| 263 | .update_lna = NULL, | ||
| 264 | |||
| 265 | .agc_config_count = 1, | ||
| 266 | .agc = &xc3028_agc_config, | ||
| 267 | .bw = &xc3028_bw_config, | ||
| 268 | |||
| 269 | .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS, | ||
| 270 | .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES, | ||
| 271 | .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS, | ||
| 272 | |||
| 273 | .pwm_freq_div = 0, | ||
| 274 | .agc_control = NULL, | ||
| 275 | .spur_protect = 0, | ||
| 276 | |||
| 277 | .output_mode = OUTMODE_MPEG2_SERIAL, | ||
| 278 | }; | ||
| 279 | |||
| 176 | static int cx23885_hvr1500_xc3028_callback(void *ptr, int command, int arg) | 280 | static int cx23885_hvr1500_xc3028_callback(void *ptr, int command, int arg) |
| 177 | { | 281 | { |
| 178 | struct cx23885_tsport *port = ptr; | 282 | struct cx23885_tsport *port = ptr; |
| @@ -182,7 +286,7 @@ static int cx23885_hvr1500_xc3028_callback(void *ptr, int command, int arg) | |||
| 182 | case XC2028_TUNER_RESET: | 286 | case XC2028_TUNER_RESET: |
| 183 | /* Send the tuner in then out of reset */ | 287 | /* Send the tuner in then out of reset */ |
| 184 | /* GPIO-2 xc3028 tuner */ | 288 | /* GPIO-2 xc3028 tuner */ |
| 185 | dprintk(1, "%s: XC2028_TUNER_RESET %d\n", __FUNCTION__, arg); | 289 | dprintk(1, "%s: XC2028_TUNER_RESET %d\n", __func__, arg); |
| 186 | 290 | ||
| 187 | cx_set(GP0_IO, 0x00040000); | 291 | cx_set(GP0_IO, 0x00040000); |
| 188 | cx_clear(GP0_IO, 0x00000004); | 292 | cx_clear(GP0_IO, 0x00000004); |
| @@ -192,10 +296,10 @@ static int cx23885_hvr1500_xc3028_callback(void *ptr, int command, int arg) | |||
| 192 | msleep(5); | 296 | msleep(5); |
| 193 | break; | 297 | break; |
| 194 | case XC2028_RESET_CLK: | 298 | case XC2028_RESET_CLK: |
| 195 | dprintk(1, "%s: XC2028_RESET_CLK %d\n", __FUNCTION__, arg); | 299 | dprintk(1, "%s: XC2028_RESET_CLK %d\n", __func__, arg); |
| 196 | break; | 300 | break; |
| 197 | default: | 301 | default: |
| 198 | dprintk(1, "%s: unknown command %d, arg %d\n", __FUNCTION__, | 302 | dprintk(1, "%s: unknown command %d, arg %d\n", __func__, |
| 199 | command, arg); | 303 | command, arg); |
| 200 | return -EINVAL; | 304 | return -EINVAL; |
| 201 | } | 305 | } |
| @@ -271,8 +375,9 @@ static int dvb_register(struct cx23885_tsport *port) | |||
| 271 | &fusionhdtv_5_express, | 375 | &fusionhdtv_5_express, |
| 272 | &i2c_bus->i2c_adap); | 376 | &i2c_bus->i2c_adap); |
| 273 | if (port->dvb.frontend != NULL) { | 377 | if (port->dvb.frontend != NULL) { |
| 274 | dvb_attach(dvb_pll_attach, port->dvb.frontend, 0x61, | 378 | dvb_attach(simple_tuner_attach, port->dvb.frontend, |
| 275 | &i2c_bus->i2c_adap, DVB_PLL_LG_TDVS_H06XF); | 379 | &i2c_bus->i2c_adap, 0x61, |
| 380 | TUNER_LG_TDVS_H06XF); | ||
| 276 | } | 381 | } |
| 277 | break; | 382 | break; |
| 278 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: | 383 | case CX23885_BOARD_HAUPPAUGE_HVR1500Q: |
| @@ -297,13 +402,52 @@ static int dvb_register(struct cx23885_tsport *port) | |||
| 297 | struct xc2028_config cfg = { | 402 | struct xc2028_config cfg = { |
| 298 | .i2c_adap = &i2c_bus->i2c_adap, | 403 | .i2c_adap = &i2c_bus->i2c_adap, |
| 299 | .i2c_addr = 0x61, | 404 | .i2c_addr = 0x61, |
| 300 | .video_dev = port, | ||
| 301 | .callback = cx23885_hvr1500_xc3028_callback, | 405 | .callback = cx23885_hvr1500_xc3028_callback, |
| 302 | }; | 406 | }; |
| 303 | static struct xc2028_ctrl ctl = { | 407 | static struct xc2028_ctrl ctl = { |
| 304 | .fname = "xc3028-v27.fw", | 408 | .fname = "xc3028-v27.fw", |
| 305 | .max_len = 64, | 409 | .max_len = 64, |
| 306 | .scode_table = OREN538, | 410 | .scode_table = XC3028_FE_OREN538, |
| 411 | }; | ||
| 412 | |||
| 413 | fe = dvb_attach(xc2028_attach, | ||
| 414 | port->dvb.frontend, &cfg); | ||
| 415 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) | ||
| 416 | fe->ops.tuner_ops.set_config(fe, &ctl); | ||
| 417 | } | ||
| 418 | break; | ||
| 419 | case CX23885_BOARD_HAUPPAUGE_HVR1200: | ||
| 420 | case CX23885_BOARD_HAUPPAUGE_HVR1700: | ||
| 421 | i2c_bus = &dev->i2c_bus[0]; | ||
| 422 | port->dvb.frontend = dvb_attach(tda10048_attach, | ||
| 423 | &hauppauge_hvr1200_config, | ||
| 424 | &i2c_bus->i2c_adap); | ||
| 425 | if (port->dvb.frontend != NULL) { | ||
| 426 | dvb_attach(tda829x_attach, port->dvb.frontend, | ||
| 427 | &dev->i2c_bus[1].i2c_adap, 0x42, | ||
| 428 | &tda829x_no_probe); | ||
| 429 | dvb_attach(tda18271_attach, port->dvb.frontend, | ||
| 430 | 0x60, &dev->i2c_bus[1].i2c_adap, | ||
| 431 | &hauppauge_hvr1200_tuner_config); | ||
| 432 | } | ||
| 433 | break; | ||
| 434 | case CX23885_BOARD_HAUPPAUGE_HVR1400: | ||
| 435 | i2c_bus = &dev->i2c_bus[0]; | ||
| 436 | port->dvb.frontend = dvb_attach(dib7000p_attach, | ||
| 437 | &i2c_bus->i2c_adap, | ||
| 438 | 0x12, &hauppauge_hvr1400_dib7000_config); | ||
| 439 | if (port->dvb.frontend != NULL) { | ||
| 440 | struct dvb_frontend *fe; | ||
| 441 | struct xc2028_config cfg = { | ||
| 442 | .i2c_adap = &dev->i2c_bus[1].i2c_adap, | ||
| 443 | .i2c_addr = 0x64, | ||
| 444 | .callback = cx23885_hvr1500_xc3028_callback, | ||
| 445 | }; | ||
| 446 | static struct xc2028_ctrl ctl = { | ||
| 447 | .fname = "xc3028L-v36.fw", | ||
| 448 | .max_len = 64, | ||
| 449 | .demod = 5000, | ||
| 450 | .d2633 = 1 | ||
| 307 | }; | 451 | }; |
| 308 | 452 | ||
| 309 | fe = dvb_attach(xc2028_attach, | 453 | fe = dvb_attach(xc2028_attach, |
| @@ -330,7 +474,7 @@ static int dvb_register(struct cx23885_tsport *port) | |||
| 330 | 474 | ||
| 331 | /* register everything */ | 475 | /* register everything */ |
| 332 | return videobuf_dvb_register(&port->dvb, THIS_MODULE, port, | 476 | return videobuf_dvb_register(&port->dvb, THIS_MODULE, port, |
| 333 | &dev->pci->dev); | 477 | &dev->pci->dev, adapter_nr); |
| 334 | } | 478 | } |
| 335 | 479 | ||
| 336 | int cx23885_dvb_register(struct cx23885_tsport *port) | 480 | int cx23885_dvb_register(struct cx23885_tsport *port) |
| @@ -338,7 +482,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port) | |||
| 338 | struct cx23885_dev *dev = port->dev; | 482 | struct cx23885_dev *dev = port->dev; |
| 339 | int err; | 483 | int err; |
| 340 | 484 | ||
| 341 | dprintk(1, "%s\n", __FUNCTION__); | 485 | dprintk(1, "%s\n", __func__); |
| 342 | dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", | 486 | dprintk(1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", |
| 343 | dev->board, | 487 | dev->board, |
| 344 | dev->name, | 488 | dev->name, |
| @@ -349,12 +493,12 @@ int cx23885_dvb_register(struct cx23885_tsport *port) | |||
| 349 | 493 | ||
| 350 | /* dvb stuff */ | 494 | /* dvb stuff */ |
| 351 | printk("%s: cx23885 based dvb card\n", dev->name); | 495 | printk("%s: cx23885 based dvb card\n", dev->name); |
| 352 | videobuf_queue_pci_init(&port->dvb.dvbq, &dvb_qops, dev->pci, &port->slock, | 496 | videobuf_queue_sg_init(&port->dvb.dvbq, &dvb_qops, &dev->pci->dev, &port->slock, |
| 353 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, | 497 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP, |
| 354 | sizeof(struct cx23885_buffer), port); | 498 | sizeof(struct cx23885_buffer), port); |
| 355 | err = dvb_register(port); | 499 | err = dvb_register(port); |
| 356 | if (err != 0) | 500 | if (err != 0) |
| 357 | printk("%s() dvb_register failed err = %d\n", __FUNCTION__, err); | 501 | printk("%s() dvb_register failed err = %d\n", __func__, err); |
| 358 | 502 | ||
| 359 | return err; | 503 | return err; |
| 360 | } | 504 | } |
diff --git a/drivers/media/video/cx23885/cx23885-i2c.c b/drivers/media/video/cx23885/cx23885-i2c.c index 92fe0bd37c84..c6bb0a05bc1c 100644 --- a/drivers/media/video/cx23885/cx23885-i2c.c +++ b/drivers/media/video/cx23885/cx23885-i2c.c | |||
| @@ -33,7 +33,7 @@ static unsigned int i2c_debug; | |||
| 33 | module_param(i2c_debug, int, 0644); | 33 | module_param(i2c_debug, int, 0644); |
| 34 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); | 34 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); |
| 35 | 35 | ||
| 36 | static unsigned int i2c_scan = 0; | 36 | static unsigned int i2c_scan; |
| 37 | module_param(i2c_scan, int, 0444); | 37 | module_param(i2c_scan, int, 0444); |
| 38 | MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); | 38 | MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); |
| 39 | 39 | ||
| @@ -87,10 +87,10 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
| 87 | int retval, cnt; | 87 | int retval, cnt; |
| 88 | 88 | ||
| 89 | if (joined_rlen) | 89 | if (joined_rlen) |
| 90 | dprintk(1, "%s(msg->wlen=%d, nextmsg->rlen=%d)\n", __FUNCTION__, | 90 | dprintk(1, "%s(msg->wlen=%d, nextmsg->rlen=%d)\n", __func__, |
| 91 | msg->len, joined_rlen); | 91 | msg->len, joined_rlen); |
| 92 | else | 92 | else |
| 93 | dprintk(1, "%s(msg->len=%d)\n", __FUNCTION__, msg->len); | 93 | dprintk(1, "%s(msg->len=%d)\n", __func__, msg->len); |
| 94 | 94 | ||
| 95 | /* Deal with i2c probe functions with zero payload */ | 95 | /* Deal with i2c probe functions with zero payload */ |
| 96 | if (msg->len == 0) { | 96 | if (msg->len == 0) { |
| @@ -101,7 +101,7 @@ static int i2c_sendbytes(struct i2c_adapter *i2c_adap, | |||
| 101 | if (!i2c_slave_did_ack(i2c_adap)) | 101 | if (!i2c_slave_did_ack(i2c_adap)) |
| 102 | return -EIO; | 102 | return -EIO; |
| 103 | 103 | ||
| 104 | dprintk(1, "%s() returns 0\n", __FUNCTION__); | 104 | dprintk(1, "%s() returns 0\n", __func__); |
| 105 | return 0; | 105 | return 0; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| @@ -176,7 +176,7 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
| 176 | 176 | ||
| 177 | 177 | ||
| 178 | if (i2c_debug && !joined) | 178 | if (i2c_debug && !joined) |
| 179 | dprintk(1, "%s(msg->len=%d)\n", __FUNCTION__, msg->len); | 179 | dprintk(1, "%s(msg->len=%d)\n", __func__, msg->len); |
| 180 | 180 | ||
| 181 | /* Deal with i2c probe functions with zero payload */ | 181 | /* Deal with i2c probe functions with zero payload */ |
| 182 | if (msg->len == 0) { | 182 | if (msg->len == 0) { |
| @@ -188,7 +188,7 @@ static int i2c_readbytes(struct i2c_adapter *i2c_adap, | |||
| 188 | return -EIO; | 188 | return -EIO; |
| 189 | 189 | ||
| 190 | 190 | ||
| 191 | dprintk(1, "%s() returns 0\n", __FUNCTION__); | 191 | dprintk(1, "%s() returns 0\n", __func__); |
| 192 | return 0; | 192 | return 0; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| @@ -238,11 +238,11 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, | |||
| 238 | struct cx23885_dev *dev = bus->dev; | 238 | struct cx23885_dev *dev = bus->dev; |
| 239 | int i, retval = 0; | 239 | int i, retval = 0; |
| 240 | 240 | ||
| 241 | dprintk(1, "%s(num = %d)\n", __FUNCTION__, num); | 241 | dprintk(1, "%s(num = %d)\n", __func__, num); |
| 242 | 242 | ||
| 243 | for (i = 0 ; i < num; i++) { | 243 | for (i = 0 ; i < num; i++) { |
| 244 | dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n", | 244 | dprintk(1, "%s(num = %d) addr = 0x%02x len = 0x%x\n", |
| 245 | __FUNCTION__, num, msgs[i].addr, msgs[i].len); | 245 | __func__, num, msgs[i].addr, msgs[i].len); |
| 246 | if (msgs[i].flags & I2C_M_RD) { | 246 | if (msgs[i].flags & I2C_M_RD) { |
| 247 | /* read */ | 247 | /* read */ |
| 248 | retval = i2c_readbytes(i2c_adap, &msgs[i], 0); | 248 | retval = i2c_readbytes(i2c_adap, &msgs[i], 0); |
| @@ -353,6 +353,8 @@ static struct i2c_client cx23885_i2c_client_template = { | |||
| 353 | }; | 353 | }; |
| 354 | 354 | ||
| 355 | static char *i2c_devs[128] = { | 355 | static char *i2c_devs[128] = { |
| 356 | [0x10 >> 1] = "tda10048", | ||
| 357 | [0x12 >> 1] = "dib7000pc", | ||
| 356 | [ 0x1c >> 1 ] = "lgdt3303", | 358 | [ 0x1c >> 1 ] = "lgdt3303", |
| 357 | [ 0x86 >> 1 ] = "tda9887", | 359 | [ 0x86 >> 1 ] = "tda9887", |
| 358 | [ 0x32 >> 1 ] = "cx24227", | 360 | [ 0x32 >> 1 ] = "cx24227", |
| @@ -360,7 +362,8 @@ static char *i2c_devs[128] = { | |||
| 360 | [ 0x84 >> 1 ] = "tda8295", | 362 | [ 0x84 >> 1 ] = "tda8295", |
| 361 | [ 0xa0 >> 1 ] = "eeprom", | 363 | [ 0xa0 >> 1 ] = "eeprom", |
| 362 | [ 0xc0 >> 1 ] = "tuner/mt2131/tda8275", | 364 | [ 0xc0 >> 1 ] = "tuner/mt2131/tda8275", |
| 363 | [ 0xc2 >> 1 ] = "tuner/mt2131/tda8275/xc5000", | 365 | [0xc2 >> 1] = "tuner/mt2131/tda8275/xc5000/xc3028", |
| 366 | [0xc8 >> 1] = "tuner/xc3028L", | ||
| 364 | }; | 367 | }; |
| 365 | 368 | ||
| 366 | static void do_i2c_scan(char *name, struct i2c_client *c) | 369 | static void do_i2c_scan(char *name, struct i2c_client *c) |
| @@ -383,7 +386,7 @@ int cx23885_i2c_register(struct cx23885_i2c *bus) | |||
| 383 | { | 386 | { |
| 384 | struct cx23885_dev *dev = bus->dev; | 387 | struct cx23885_dev *dev = bus->dev; |
| 385 | 388 | ||
| 386 | dprintk(1, "%s(bus = %d)\n", __FUNCTION__, bus->nr); | 389 | dprintk(1, "%s(bus = %d)\n", __func__, bus->nr); |
| 387 | 390 | ||
| 388 | memcpy(&bus->i2c_adap, &cx23885_i2c_adap_template, | 391 | memcpy(&bus->i2c_adap, &cx23885_i2c_adap_template, |
| 389 | sizeof(bus->i2c_adap)); | 392 | sizeof(bus->i2c_adap)); |
| @@ -420,6 +423,29 @@ int cx23885_i2c_unregister(struct cx23885_i2c *bus) | |||
| 420 | return 0; | 423 | return 0; |
| 421 | } | 424 | } |
| 422 | 425 | ||
| 426 | void cx23885_av_clk(struct cx23885_dev *dev, int enable) | ||
| 427 | { | ||
| 428 | /* write 0 to bus 2 addr 0x144 via i2x_xfer() */ | ||
| 429 | char buffer[3]; | ||
| 430 | struct i2c_msg msg; | ||
| 431 | dprintk(1, "%s(enabled = %d)\n", __func__, enable); | ||
| 432 | |||
| 433 | /* Register 0x144 */ | ||
| 434 | buffer[0] = 0x01; | ||
| 435 | buffer[1] = 0x44; | ||
| 436 | if (enable == 1) | ||
| 437 | buffer[2] = 0x05; | ||
| 438 | else | ||
| 439 | buffer[2] = 0x00; | ||
| 440 | |||
| 441 | msg.addr = 0x44; | ||
| 442 | msg.flags = I2C_M_TEN; | ||
| 443 | msg.len = 3; | ||
| 444 | msg.buf = buffer; | ||
| 445 | |||
| 446 | i2c_xfer(&dev->i2c_bus[2].i2c_adap, &msg, 1); | ||
| 447 | } | ||
| 448 | |||
| 423 | /* ----------------------------------------------------------------------- */ | 449 | /* ----------------------------------------------------------------------- */ |
| 424 | 450 | ||
| 425 | /* | 451 | /* |
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c index d3c4d2c5cbe0..84652210a28c 100644 --- a/drivers/media/video/cx23885/cx23885-video.c +++ b/drivers/media/video/cx23885/cx23885-video.c | |||
| @@ -141,7 +141,7 @@ static struct cx23885_fmt *format_by_fourcc(unsigned int fourcc) | |||
| 141 | if (formats[i].fourcc == fourcc) | 141 | if (formats[i].fourcc == fourcc) |
| 142 | return formats+i; | 142 | return formats+i; |
| 143 | 143 | ||
| 144 | printk(KERN_ERR "%s(0x%08x) NOT FOUND\n", __FUNCTION__, fourcc); | 144 | printk(KERN_ERR "%s(0x%08x) NOT FOUND\n", __func__, fourcc); |
| 145 | return NULL; | 145 | return NULL; |
| 146 | } | 146 | } |
| 147 | 147 | ||
| @@ -292,13 +292,13 @@ void cx23885_video_wakeup(struct cx23885_dev *dev, | |||
| 292 | } | 292 | } |
| 293 | if (bc != 1) | 293 | if (bc != 1) |
| 294 | printk(KERN_ERR "%s: %d buffers handled (should be 1)\n", | 294 | printk(KERN_ERR "%s: %d buffers handled (should be 1)\n", |
| 295 | __FUNCTION__, bc); | 295 | __func__, bc); |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm) | 298 | int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm) |
| 299 | { | 299 | { |
| 300 | dprintk(1, "%s(norm = 0x%08x) name: [%s]\n", | 300 | dprintk(1, "%s(norm = 0x%08x) name: [%s]\n", |
| 301 | __FUNCTION__, | 301 | __func__, |
| 302 | (unsigned int)norm, | 302 | (unsigned int)norm, |
| 303 | v4l2_norm_to_name(norm)); | 303 | v4l2_norm_to_name(norm)); |
| 304 | 304 | ||
| @@ -319,7 +319,7 @@ struct video_device *cx23885_vdev_init(struct cx23885_dev *dev, | |||
| 319 | char *type) | 319 | char *type) |
| 320 | { | 320 | { |
| 321 | struct video_device *vfd; | 321 | struct video_device *vfd; |
| 322 | dprintk(1, "%s()\n", __FUNCTION__); | 322 | dprintk(1, "%s()\n", __func__); |
| 323 | 323 | ||
| 324 | vfd = video_device_alloc(); | 324 | vfd = video_device_alloc(); |
| 325 | if (NULL == vfd) | 325 | if (NULL == vfd) |
| @@ -358,7 +358,7 @@ EXPORT_SYMBOL(cx23885_ctrl_query); | |||
| 358 | static int res_get(struct cx23885_dev *dev, struct cx23885_fh *fh, | 358 | static int res_get(struct cx23885_dev *dev, struct cx23885_fh *fh, |
| 359 | unsigned int bit) | 359 | unsigned int bit) |
| 360 | { | 360 | { |
| 361 | dprintk(1, "%s()\n", __FUNCTION__); | 361 | dprintk(1, "%s()\n", __func__); |
| 362 | if (fh->resources & bit) | 362 | if (fh->resources & bit) |
| 363 | /* have it already allocated */ | 363 | /* have it already allocated */ |
| 364 | return 1; | 364 | return 1; |
| @@ -392,7 +392,7 @@ static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh, | |||
| 392 | unsigned int bits) | 392 | unsigned int bits) |
| 393 | { | 393 | { |
| 394 | BUG_ON((fh->resources & bits) != bits); | 394 | BUG_ON((fh->resources & bits) != bits); |
| 395 | dprintk(1, "%s()\n", __FUNCTION__); | 395 | dprintk(1, "%s()\n", __func__); |
| 396 | 396 | ||
| 397 | mutex_lock(&dev->lock); | 397 | mutex_lock(&dev->lock); |
| 398 | fh->resources &= ~bits; | 398 | fh->resources &= ~bits; |
| @@ -407,7 +407,7 @@ int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input) | |||
| 407 | memset(&route, 0, sizeof(route)); | 407 | memset(&route, 0, sizeof(route)); |
| 408 | 408 | ||
| 409 | dprintk(1, "%s() video_mux: %d [vmux=%d, gpio=0x%x,0x%x,0x%x,0x%x]\n", | 409 | dprintk(1, "%s() video_mux: %d [vmux=%d, gpio=0x%x,0x%x,0x%x,0x%x]\n", |
| 410 | __FUNCTION__, | 410 | __func__, |
| 411 | input, INPUT(input)->vmux, | 411 | input, INPUT(input)->vmux, |
| 412 | INPUT(input)->gpio0, INPUT(input)->gpio1, | 412 | INPUT(input)->gpio0, INPUT(input)->gpio1, |
| 413 | INPUT(input)->gpio2, INPUT(input)->gpio3); | 413 | INPUT(input)->gpio2, INPUT(input)->gpio3); |
| @@ -427,7 +427,7 @@ EXPORT_SYMBOL(cx23885_video_mux); | |||
| 427 | int cx23885_set_scale(struct cx23885_dev *dev, unsigned int width, | 427 | int cx23885_set_scale(struct cx23885_dev *dev, unsigned int width, |
| 428 | unsigned int height, enum v4l2_field field) | 428 | unsigned int height, enum v4l2_field field) |
| 429 | { | 429 | { |
| 430 | dprintk(1, "%s()\n", __FUNCTION__); | 430 | dprintk(1, "%s()\n", __func__); |
| 431 | return 0; | 431 | return 0; |
| 432 | } | 432 | } |
| 433 | 433 | ||
| @@ -435,7 +435,7 @@ static int cx23885_start_video_dma(struct cx23885_dev *dev, | |||
| 435 | struct cx23885_dmaqueue *q, | 435 | struct cx23885_dmaqueue *q, |
| 436 | struct cx23885_buffer *buf) | 436 | struct cx23885_buffer *buf) |
| 437 | { | 437 | { |
| 438 | dprintk(1, "%s()\n", __FUNCTION__); | 438 | dprintk(1, "%s()\n", __func__); |
| 439 | 439 | ||
| 440 | /* setup fifo + format */ | 440 | /* setup fifo + format */ |
| 441 | cx23885_sram_channel_setup(dev, &dev->sram_channels[SRAM_CH01], | 441 | cx23885_sram_channel_setup(dev, &dev->sram_channels[SRAM_CH01], |
| @@ -463,7 +463,7 @@ static int cx23885_restart_video_queue(struct cx23885_dev *dev, | |||
| 463 | { | 463 | { |
| 464 | struct cx23885_buffer *buf, *prev; | 464 | struct cx23885_buffer *buf, *prev; |
| 465 | struct list_head *item; | 465 | struct list_head *item; |
| 466 | dprintk(1, "%s()\n", __FUNCTION__); | 466 | dprintk(1, "%s()\n", __func__); |
| 467 | 467 | ||
| 468 | if (!list_empty(&q->active)) { | 468 | if (!list_empty(&q->active)) { |
| 469 | buf = list_entry(q->active.next, struct cx23885_buffer, | 469 | buf = list_entry(q->active.next, struct cx23885_buffer, |
| @@ -579,13 +579,13 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, | |||
| 579 | if (dev->tvnorm & V4L2_STD_NTSC) { | 579 | if (dev->tvnorm & V4L2_STD_NTSC) { |
| 580 | /* cx25840 transmits NTSC bottom field first */ | 580 | /* cx25840 transmits NTSC bottom field first */ |
| 581 | dprintk(1, "%s() Creating NTSC risc\n", | 581 | dprintk(1, "%s() Creating NTSC risc\n", |
| 582 | __FUNCTION__); | 582 | __func__); |
| 583 | line0_offset = buf->bpl; | 583 | line0_offset = buf->bpl; |
| 584 | line1_offset = 0; | 584 | line1_offset = 0; |
| 585 | } else { | 585 | } else { |
| 586 | /* All other formats are top field first */ | 586 | /* All other formats are top field first */ |
| 587 | dprintk(1, "%s() Creating PAL/SECAM risc\n", | 587 | dprintk(1, "%s() Creating PAL/SECAM risc\n", |
| 588 | __FUNCTION__); | 588 | __func__); |
| 589 | line0_offset = 0; | 589 | line0_offset = 0; |
| 590 | line1_offset = buf->bpl; | 590 | line1_offset = buf->bpl; |
| 591 | } | 591 | } |
| @@ -765,8 +765,8 @@ static int video_open(struct inode *inode, struct file *file) | |||
| 765 | fh->height = 240; | 765 | fh->height = 240; |
| 766 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); | 766 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); |
| 767 | 767 | ||
| 768 | videobuf_queue_pci_init(&fh->vidq, &cx23885_video_qops, | 768 | videobuf_queue_sg_init(&fh->vidq, &cx23885_video_qops, |
| 769 | dev->pci, &dev->slock, | 769 | &dev->pci->dev, &dev->slock, |
| 770 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 770 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 771 | V4L2_FIELD_INTERLACED, | 771 | V4L2_FIELD_INTERLACED, |
| 772 | sizeof(struct cx23885_buffer), | 772 | sizeof(struct cx23885_buffer), |
| @@ -885,7 +885,7 @@ static int video_mmap(struct file *file, struct vm_area_struct *vma) | |||
| 885 | 885 | ||
| 886 | int cx23885_get_control(struct cx23885_dev *dev, struct v4l2_control *ctl) | 886 | int cx23885_get_control(struct cx23885_dev *dev, struct v4l2_control *ctl) |
| 887 | { | 887 | { |
| 888 | dprintk(1, "%s() calling cx25840(VIDIOC_G_CTRL)\n", __FUNCTION__); | 888 | dprintk(1, "%s() calling cx25840(VIDIOC_G_CTRL)\n", __func__); |
| 889 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_CTRL, ctl); | 889 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_CTRL, ctl); |
| 890 | return 0; | 890 | return 0; |
| 891 | } | 891 | } |
| @@ -894,7 +894,7 @@ EXPORT_SYMBOL(cx23885_get_control); | |||
| 894 | int cx23885_set_control(struct cx23885_dev *dev, struct v4l2_control *ctl) | 894 | int cx23885_set_control(struct cx23885_dev *dev, struct v4l2_control *ctl) |
| 895 | { | 895 | { |
| 896 | dprintk(1, "%s() calling cx25840(VIDIOC_S_CTRL)" | 896 | dprintk(1, "%s() calling cx25840(VIDIOC_S_CTRL)" |
| 897 | " (disabled - no action)\n", __FUNCTION__); | 897 | " (disabled - no action)\n", __func__); |
| 898 | return 0; | 898 | return 0; |
| 899 | } | 899 | } |
| 900 | EXPORT_SYMBOL(cx23885_set_control); | 900 | EXPORT_SYMBOL(cx23885_set_control); |
| @@ -990,7 +990,7 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv, | |||
| 990 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; | 990 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; |
| 991 | int err; | 991 | int err; |
| 992 | 992 | ||
| 993 | dprintk(2, "%s()\n", __FUNCTION__); | 993 | dprintk(2, "%s()\n", __func__); |
| 994 | err = vidioc_try_fmt_cap(file, priv, f); | 994 | err = vidioc_try_fmt_cap(file, priv, f); |
| 995 | 995 | ||
| 996 | if (0 != err) | 996 | if (0 != err) |
| @@ -999,7 +999,7 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv, | |||
| 999 | fh->width = f->fmt.pix.width; | 999 | fh->width = f->fmt.pix.width; |
| 1000 | fh->height = f->fmt.pix.height; | 1000 | fh->height = f->fmt.pix.height; |
| 1001 | fh->vidq.field = f->fmt.pix.field; | 1001 | fh->vidq.field = f->fmt.pix.field; |
| 1002 | dprintk(2, "%s() width=%d height=%d field=%d\n", __FUNCTION__, | 1002 | dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, |
| 1003 | fh->width, fh->height, fh->vidq.field); | 1003 | fh->width, fh->height, fh->vidq.field); |
| 1004 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_FMT, f); | 1004 | cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_FMT, f); |
| 1005 | return 0; | 1005 | return 0; |
| @@ -1101,7 +1101,7 @@ static int vidioc_streamon(struct file *file, void *priv, | |||
| 1101 | { | 1101 | { |
| 1102 | struct cx23885_fh *fh = priv; | 1102 | struct cx23885_fh *fh = priv; |
| 1103 | struct cx23885_dev *dev = fh->dev; | 1103 | struct cx23885_dev *dev = fh->dev; |
| 1104 | dprintk(1, "%s()\n", __FUNCTION__); | 1104 | dprintk(1, "%s()\n", __func__); |
| 1105 | 1105 | ||
| 1106 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) | 1106 | if (unlikely(fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) |
| 1107 | return -EINVAL; | 1107 | return -EINVAL; |
| @@ -1118,7 +1118,7 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
| 1118 | struct cx23885_fh *fh = priv; | 1118 | struct cx23885_fh *fh = priv; |
| 1119 | struct cx23885_dev *dev = fh->dev; | 1119 | struct cx23885_dev *dev = fh->dev; |
| 1120 | int err, res; | 1120 | int err, res; |
| 1121 | dprintk(1, "%s()\n", __FUNCTION__); | 1121 | dprintk(1, "%s()\n", __func__); |
| 1122 | 1122 | ||
| 1123 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1123 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
| 1124 | return -EINVAL; | 1124 | return -EINVAL; |
| @@ -1136,7 +1136,7 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | |||
| 1136 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *tvnorms) | 1136 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *tvnorms) |
| 1137 | { | 1137 | { |
| 1138 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; | 1138 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; |
| 1139 | dprintk(1, "%s()\n", __FUNCTION__); | 1139 | dprintk(1, "%s()\n", __func__); |
| 1140 | 1140 | ||
| 1141 | mutex_lock(&dev->lock); | 1141 | mutex_lock(&dev->lock); |
| 1142 | cx23885_set_tvnorm(dev, *tvnorms); | 1142 | cx23885_set_tvnorm(dev, *tvnorms); |
| @@ -1159,7 +1159,7 @@ int cx23885_enum_input(struct cx23885_dev *dev, struct v4l2_input *i) | |||
| 1159 | [CX23885_VMUX_DEBUG] = "for debug only", | 1159 | [CX23885_VMUX_DEBUG] = "for debug only", |
| 1160 | }; | 1160 | }; |
| 1161 | unsigned int n; | 1161 | unsigned int n; |
| 1162 | dprintk(1, "%s()\n", __FUNCTION__); | 1162 | dprintk(1, "%s()\n", __func__); |
| 1163 | 1163 | ||
| 1164 | n = i->index; | 1164 | n = i->index; |
| 1165 | if (n >= 4) | 1165 | if (n >= 4) |
| @@ -1184,7 +1184,7 @@ static int vidioc_enum_input(struct file *file, void *priv, | |||
| 1184 | struct v4l2_input *i) | 1184 | struct v4l2_input *i) |
| 1185 | { | 1185 | { |
| 1186 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; | 1186 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; |
| 1187 | dprintk(1, "%s()\n", __FUNCTION__); | 1187 | dprintk(1, "%s()\n", __func__); |
| 1188 | return cx23885_enum_input(dev, i); | 1188 | return cx23885_enum_input(dev, i); |
| 1189 | } | 1189 | } |
| 1190 | 1190 | ||
| @@ -1193,7 +1193,7 @@ static int vidioc_g_input(struct file *file, void *priv, unsigned int *i) | |||
| 1193 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; | 1193 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; |
| 1194 | 1194 | ||
| 1195 | *i = dev->input; | 1195 | *i = dev->input; |
| 1196 | dprintk(1, "%s() returns %d\n", __FUNCTION__, *i); | 1196 | dprintk(1, "%s() returns %d\n", __func__, *i); |
| 1197 | return 0; | 1197 | return 0; |
| 1198 | } | 1198 | } |
| 1199 | 1199 | ||
| @@ -1201,10 +1201,10 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) | |||
| 1201 | { | 1201 | { |
| 1202 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; | 1202 | struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; |
| 1203 | 1203 | ||
| 1204 | dprintk(1, "%s(%d)\n", __FUNCTION__, i); | 1204 | dprintk(1, "%s(%d)\n", __func__, i); |
| 1205 | 1205 | ||
| 1206 | if (i >= 4) { | 1206 | if (i >= 4) { |
| 1207 | dprintk(1, "%s() -EINVAL\n", __FUNCTION__); | 1207 | dprintk(1, "%s() -EINVAL\n", __func__); |
| 1208 | return -EINVAL; | 1208 | return -EINVAL; |
| 1209 | } | 1209 | } |
| 1210 | 1210 | ||
| @@ -1389,7 +1389,7 @@ int cx23885_video_irq(struct cx23885_dev *dev, u32 status) | |||
| 1389 | return handled; | 1389 | return handled; |
| 1390 | cx_write(VID_A_INT_STAT, status); | 1390 | cx_write(VID_A_INT_STAT, status); |
| 1391 | 1391 | ||
| 1392 | dprintk(2, "%s() status = 0x%08x\n", __FUNCTION__, status); | 1392 | dprintk(2, "%s() status = 0x%08x\n", __func__, status); |
| 1393 | /* risc op code error */ | 1393 | /* risc op code error */ |
| 1394 | if (status & (1 << 16)) { | 1394 | if (status & (1 << 16)) { |
| 1395 | printk(KERN_WARNING "%s/0: video risc op code error\n", | 1395 | printk(KERN_WARNING "%s/0: video risc op code error\n", |
| @@ -1487,7 +1487,7 @@ static const struct file_operations radio_fops = { | |||
| 1487 | 1487 | ||
| 1488 | void cx23885_video_unregister(struct cx23885_dev *dev) | 1488 | void cx23885_video_unregister(struct cx23885_dev *dev) |
| 1489 | { | 1489 | { |
| 1490 | dprintk(1, "%s()\n", __FUNCTION__); | 1490 | dprintk(1, "%s()\n", __func__); |
| 1491 | cx_clear(PCI_INT_MSK, 1); | 1491 | cx_clear(PCI_INT_MSK, 1); |
| 1492 | 1492 | ||
| 1493 | if (dev->video_dev) { | 1493 | if (dev->video_dev) { |
| @@ -1505,7 +1505,7 @@ int cx23885_video_register(struct cx23885_dev *dev) | |||
| 1505 | { | 1505 | { |
| 1506 | int err; | 1506 | int err; |
| 1507 | 1507 | ||
| 1508 | dprintk(1, "%s()\n", __FUNCTION__); | 1508 | dprintk(1, "%s()\n", __func__); |
| 1509 | spin_lock_init(&dev->slock); | 1509 | spin_lock_init(&dev->slock); |
| 1510 | 1510 | ||
| 1511 | /* Initialize VBI template */ | 1511 | /* Initialize VBI template */ |
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h index 7cb2179f2622..32af87f25e7b 100644 --- a/drivers/media/video/cx23885/cx23885.h +++ b/drivers/media/video/cx23885/cx23885.h | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | #include "btcx-risc.h" | 33 | #include "btcx-risc.h" |
| 34 | #include "cx23885-reg.h" | 34 | #include "cx23885-reg.h" |
| 35 | #include "media/cx2341x.h" | ||
| 35 | 36 | ||
| 36 | #include <linux/version.h> | 37 | #include <linux/version.h> |
| 37 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
| @@ -59,6 +60,9 @@ | |||
| 59 | #define CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP 4 | 60 | #define CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP 4 |
| 60 | #define CX23885_BOARD_HAUPPAUGE_HVR1500Q 5 | 61 | #define CX23885_BOARD_HAUPPAUGE_HVR1500Q 5 |
| 61 | #define CX23885_BOARD_HAUPPAUGE_HVR1500 6 | 62 | #define CX23885_BOARD_HAUPPAUGE_HVR1500 6 |
| 63 | #define CX23885_BOARD_HAUPPAUGE_HVR1200 7 | ||
| 64 | #define CX23885_BOARD_HAUPPAUGE_HVR1700 8 | ||
| 65 | #define CX23885_BOARD_HAUPPAUGE_HVR1400 9 | ||
| 62 | 66 | ||
| 63 | /* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM B/G/H/LC */ | 67 | /* Currently unsupported by the driver: PAL/H, NTSC/Kr, SECAM B/G/H/LC */ |
| 64 | #define CX23885_NORMS (\ | 68 | #define CX23885_NORMS (\ |
| @@ -154,6 +158,7 @@ typedef enum { | |||
| 154 | CX23885_MPEG_UNDEFINED = 0, | 158 | CX23885_MPEG_UNDEFINED = 0, |
| 155 | CX23885_MPEG_DVB, | 159 | CX23885_MPEG_DVB, |
| 156 | CX23885_ANALOG_VIDEO, | 160 | CX23885_ANALOG_VIDEO, |
| 161 | CX23885_MPEG_ENCODER, | ||
| 157 | } port_t; | 162 | } port_t; |
| 158 | 163 | ||
| 159 | struct cx23885_board { | 164 | struct cx23885_board { |
| @@ -252,6 +257,8 @@ struct cx23885_tsport { | |||
| 252 | u32 gen_ctrl_val; | 257 | u32 gen_ctrl_val; |
| 253 | u32 ts_clk_en_val; | 258 | u32 ts_clk_en_val; |
| 254 | u32 src_sel_val; | 259 | u32 src_sel_val; |
| 260 | u32 vld_misc_val; | ||
| 261 | u32 hw_sop_ctrl_val; | ||
| 255 | }; | 262 | }; |
| 256 | 263 | ||
| 257 | struct cx23885_dev { | 264 | struct cx23885_dev { |
| @@ -312,6 +319,14 @@ struct cx23885_dev { | |||
| 312 | struct cx23885_dmaqueue vidq; | 319 | struct cx23885_dmaqueue vidq; |
| 313 | struct cx23885_dmaqueue vbiq; | 320 | struct cx23885_dmaqueue vbiq; |
| 314 | spinlock_t slock; | 321 | spinlock_t slock; |
| 322 | |||
| 323 | /* MPEG Encoder ONLY settings */ | ||
| 324 | u32 cx23417_mailbox; | ||
| 325 | struct cx2341x_mpeg_params mpeg_params; | ||
| 326 | struct video_device *v4l_device; | ||
| 327 | atomic_t v4l_reader_count; | ||
| 328 | struct cx23885_tvnorm encodernorm; | ||
| 329 | |||
| 315 | }; | 330 | }; |
| 316 | 331 | ||
| 317 | extern struct list_head cx23885_devlist; | 332 | extern struct list_head cx23885_devlist; |
| @@ -431,6 +446,18 @@ extern int cx23885_i2c_register(struct cx23885_i2c *bus); | |||
| 431 | extern int cx23885_i2c_unregister(struct cx23885_i2c *bus); | 446 | extern int cx23885_i2c_unregister(struct cx23885_i2c *bus); |
| 432 | extern void cx23885_call_i2c_clients(struct cx23885_i2c *bus, unsigned int cmd, | 447 | extern void cx23885_call_i2c_clients(struct cx23885_i2c *bus, unsigned int cmd, |
| 433 | void *arg); | 448 | void *arg); |
| 449 | extern void cx23885_av_clk(struct cx23885_dev *dev, int enable); | ||
| 450 | |||
| 451 | /* ----------------------------------------------------------- */ | ||
| 452 | /* cx23885-417.c */ | ||
| 453 | extern int cx23885_417_register(struct cx23885_dev *dev); | ||
| 454 | extern void cx23885_417_unregister(struct cx23885_dev *dev); | ||
| 455 | extern int cx23885_irq_417(struct cx23885_dev *dev, u32 status); | ||
| 456 | extern void cx23885_417_check_encoder(struct cx23885_dev *dev); | ||
| 457 | extern void cx23885_mc417_init(struct cx23885_dev *dev); | ||
| 458 | extern int mc417_memory_read(struct cx23885_dev *dev, u32 address, u32 *value); | ||
| 459 | extern int mc417_memory_write(struct cx23885_dev *dev, u32 address, u32 value); | ||
| 460 | |||
| 434 | 461 | ||
| 435 | /* ----------------------------------------------------------- */ | 462 | /* ----------------------------------------------------------- */ |
| 436 | /* tv norms */ | 463 | /* tv norms */ |
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c index 756a1eeb274e..7fde678b2c4a 100644 --- a/drivers/media/video/cx25840/cx25840-core.c +++ b/drivers/media/video/cx25840/cx25840-core.c | |||
| @@ -352,7 +352,7 @@ static void cx23885_initialize(struct i2c_client *client) | |||
| 352 | static void input_change(struct i2c_client *client) | 352 | static void input_change(struct i2c_client *client) |
| 353 | { | 353 | { |
| 354 | struct cx25840_state *state = i2c_get_clientdata(client); | 354 | struct cx25840_state *state = i2c_get_clientdata(client); |
| 355 | v4l2_std_id std = cx25840_get_v4lstd(client); | 355 | v4l2_std_id std = state->std; |
| 356 | 356 | ||
| 357 | /* Follow step 8c and 8d of section 3.16 in the cx25840 datasheet */ | 357 | /* Follow step 8c and 8d of section 3.16 in the cx25840 datasheet */ |
| 358 | if (std & V4L2_STD_SECAM) { | 358 | if (std & V4L2_STD_SECAM) { |
| @@ -523,32 +523,34 @@ static int set_input(struct i2c_client *client, enum cx25840_video_input vid_inp | |||
| 523 | 523 | ||
| 524 | /* ----------------------------------------------------------------------- */ | 524 | /* ----------------------------------------------------------------------- */ |
| 525 | 525 | ||
| 526 | static int set_v4lstd(struct i2c_client *client, v4l2_std_id std) | 526 | static int set_v4lstd(struct i2c_client *client) |
| 527 | { | 527 | { |
| 528 | u8 fmt=0; /* zero is autodetect */ | 528 | struct cx25840_state *state = i2c_get_clientdata(client); |
| 529 | u8 fmt = 0; /* zero is autodetect */ | ||
| 530 | u8 pal_m = 0; | ||
| 529 | 531 | ||
| 530 | /* First tests should be against specific std */ | 532 | /* First tests should be against specific std */ |
| 531 | if (std == V4L2_STD_NTSC_M_JP) { | 533 | if (state->std == V4L2_STD_NTSC_M_JP) { |
| 532 | fmt=0x2; | 534 | fmt = 0x2; |
| 533 | } else if (std == V4L2_STD_NTSC_443) { | 535 | } else if (state->std == V4L2_STD_NTSC_443) { |
| 534 | fmt=0x3; | 536 | fmt = 0x3; |
| 535 | } else if (std == V4L2_STD_PAL_M) { | 537 | } else if (state->std == V4L2_STD_PAL_M) { |
| 536 | fmt=0x5; | 538 | pal_m = 1; |
| 537 | } else if (std == V4L2_STD_PAL_N) { | 539 | fmt = 0x5; |
| 538 | fmt=0x6; | 540 | } else if (state->std == V4L2_STD_PAL_N) { |
| 539 | } else if (std == V4L2_STD_PAL_Nc) { | 541 | fmt = 0x6; |
| 540 | fmt=0x7; | 542 | } else if (state->std == V4L2_STD_PAL_Nc) { |
| 541 | } else if (std == V4L2_STD_PAL_60) { | 543 | fmt = 0x7; |
| 542 | fmt=0x8; | 544 | } else if (state->std == V4L2_STD_PAL_60) { |
| 545 | fmt = 0x8; | ||
| 543 | } else { | 546 | } else { |
| 544 | /* Then, test against generic ones */ | 547 | /* Then, test against generic ones */ |
| 545 | if (std & V4L2_STD_NTSC) { | 548 | if (state->std & V4L2_STD_NTSC) |
| 546 | fmt=0x1; | 549 | fmt = 0x1; |
| 547 | } else if (std & V4L2_STD_PAL) { | 550 | else if (state->std & V4L2_STD_PAL) |
| 548 | fmt=0x4; | 551 | fmt = 0x4; |
| 549 | } else if (std & V4L2_STD_SECAM) { | 552 | else if (state->std & V4L2_STD_SECAM) |
| 550 | fmt=0xc; | 553 | fmt = 0xc; |
| 551 | } | ||
| 552 | } | 554 | } |
| 553 | 555 | ||
| 554 | v4l_dbg(1, cx25840_debug, client, "changing video std to fmt %i\n",fmt); | 556 | v4l_dbg(1, cx25840_debug, client, "changing video std to fmt %i\n",fmt); |
| @@ -563,42 +565,13 @@ static int set_v4lstd(struct i2c_client *client, v4l2_std_id std) | |||
| 563 | cx25840_and_or(client, 0x47b, ~6, 0); | 565 | cx25840_and_or(client, 0x47b, ~6, 0); |
| 564 | } | 566 | } |
| 565 | cx25840_and_or(client, 0x400, ~0xf, fmt); | 567 | cx25840_and_or(client, 0x400, ~0xf, fmt); |
| 568 | cx25840_and_or(client, 0x403, ~0x3, pal_m); | ||
| 566 | cx25840_vbi_setup(client); | 569 | cx25840_vbi_setup(client); |
| 570 | if (!state->is_cx25836) | ||
| 571 | input_change(client); | ||
| 567 | return 0; | 572 | return 0; |
| 568 | } | 573 | } |
| 569 | 574 | ||
| 570 | v4l2_std_id cx25840_get_v4lstd(struct i2c_client * client) | ||
| 571 | { | ||
| 572 | struct cx25840_state *state = i2c_get_clientdata(client); | ||
| 573 | /* check VID_FMT_SEL first */ | ||
| 574 | u8 fmt = cx25840_read(client, 0x400) & 0xf; | ||
| 575 | |||
| 576 | if (!fmt) { | ||
| 577 | /* check AFD_FMT_STAT if set to autodetect */ | ||
| 578 | fmt = cx25840_read(client, 0x40d) & 0xf; | ||
| 579 | } | ||
| 580 | |||
| 581 | switch (fmt) { | ||
| 582 | case 0x1: | ||
| 583 | { | ||
| 584 | /* if the audio std is A2-M, then this is the South Korean | ||
| 585 | NTSC standard */ | ||
| 586 | if (!state->is_cx25836 && cx25840_read(client, 0x805) == 2) | ||
| 587 | return V4L2_STD_NTSC_M_KR; | ||
| 588 | return V4L2_STD_NTSC_M; | ||
| 589 | } | ||
| 590 | case 0x2: return V4L2_STD_NTSC_M_JP; | ||
| 591 | case 0x3: return V4L2_STD_NTSC_443; | ||
| 592 | case 0x4: return V4L2_STD_PAL; | ||
| 593 | case 0x5: return V4L2_STD_PAL_M; | ||
| 594 | case 0x6: return V4L2_STD_PAL_N; | ||
| 595 | case 0x7: return V4L2_STD_PAL_Nc; | ||
| 596 | case 0x8: return V4L2_STD_PAL_60; | ||
| 597 | case 0xc: return V4L2_STD_SECAM; | ||
| 598 | default: return V4L2_STD_UNKNOWN; | ||
| 599 | } | ||
| 600 | } | ||
| 601 | |||
| 602 | /* ----------------------------------------------------------------------- */ | 575 | /* ----------------------------------------------------------------------- */ |
| 603 | 576 | ||
| 604 | static int set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl) | 577 | static int set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl) |
| @@ -718,9 +691,10 @@ static int get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) | |||
| 718 | 691 | ||
| 719 | static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) | 692 | static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt) |
| 720 | { | 693 | { |
| 694 | struct cx25840_state *state = i2c_get_clientdata(client); | ||
| 721 | struct v4l2_pix_format *pix; | 695 | struct v4l2_pix_format *pix; |
| 722 | int HSC, VSC, Vsrc, Hsrc, filter, Vlines; | 696 | int HSC, VSC, Vsrc, Hsrc, filter, Vlines; |
| 723 | int is_50Hz = !(cx25840_get_v4lstd(client) & V4L2_STD_525_60); | 697 | int is_50Hz = !(state->std & V4L2_STD_525_60); |
| 724 | 698 | ||
| 725 | switch (fmt->type) { | 699 | switch (fmt->type) { |
| 726 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | 700 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
| @@ -1096,12 +1070,15 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd, | |||
| 1096 | } | 1070 | } |
| 1097 | 1071 | ||
| 1098 | case VIDIOC_G_STD: | 1072 | case VIDIOC_G_STD: |
| 1099 | *(v4l2_std_id *)arg = cx25840_get_v4lstd(client); | 1073 | *(v4l2_std_id *)arg = state->std; |
| 1100 | break; | 1074 | break; |
| 1101 | 1075 | ||
| 1102 | case VIDIOC_S_STD: | 1076 | case VIDIOC_S_STD: |
| 1077 | if (state->radio == 0 && state->std == *(v4l2_std_id *)arg) | ||
| 1078 | return 0; | ||
| 1103 | state->radio = 0; | 1079 | state->radio = 0; |
| 1104 | return set_v4lstd(client, *(v4l2_std_id *)arg); | 1080 | state->std = *(v4l2_std_id *)arg; |
| 1081 | return set_v4lstd(client); | ||
| 1105 | 1082 | ||
| 1106 | case AUDC_SET_RADIO: | 1083 | case AUDC_SET_RADIO: |
| 1107 | state->radio = 1; | 1084 | state->radio = 1; |
| @@ -1291,6 +1268,12 @@ static int cx25840_probe(struct i2c_client *client) | |||
| 1291 | state->id = id; | 1268 | state->id = id; |
| 1292 | state->rev = device_id; | 1269 | state->rev = device_id; |
| 1293 | 1270 | ||
| 1271 | if (state->is_cx23885) { | ||
| 1272 | /* Drive GPIO2 direction and values */ | ||
| 1273 | cx25840_write(client, 0x160, 0x1d); | ||
| 1274 | cx25840_write(client, 0x164, 0x00); | ||
| 1275 | } | ||
| 1276 | |||
| 1294 | return 0; | 1277 | return 0; |
| 1295 | } | 1278 | } |
| 1296 | 1279 | ||
diff --git a/drivers/media/video/cx25840/cx25840-core.h b/drivers/media/video/cx25840/cx25840-core.h index 95093edc9186..8bf797f48b09 100644 --- a/drivers/media/video/cx25840/cx25840-core.h +++ b/drivers/media/video/cx25840/cx25840-core.h | |||
| @@ -38,6 +38,7 @@ struct cx25840_state { | |||
| 38 | struct i2c_client *c; | 38 | struct i2c_client *c; |
| 39 | int pvr150_workaround; | 39 | int pvr150_workaround; |
| 40 | int radio; | 40 | int radio; |
| 41 | v4l2_std_id std; | ||
| 41 | enum cx25840_video_input vid_input; | 42 | enum cx25840_video_input vid_input; |
| 42 | enum cx25840_audio_input aud_input; | 43 | enum cx25840_audio_input aud_input; |
| 43 | u32 audclk_freq; | 44 | u32 audclk_freq; |
| @@ -60,7 +61,6 @@ int cx25840_write4(struct i2c_client *client, u16 addr, u32 value); | |||
| 60 | u8 cx25840_read(struct i2c_client *client, u16 addr); | 61 | u8 cx25840_read(struct i2c_client *client, u16 addr); |
| 61 | u32 cx25840_read4(struct i2c_client *client, u16 addr); | 62 | u32 cx25840_read4(struct i2c_client *client, u16 addr); |
| 62 | int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned mask, u8 value); | 63 | int cx25840_and_or(struct i2c_client *client, u16 addr, unsigned mask, u8 value); |
| 63 | v4l2_std_id cx25840_get_v4lstd(struct i2c_client *client); | ||
| 64 | 64 | ||
| 65 | /* ----------------------------------------------------------------------- */ | 65 | /* ----------------------------------------------------------------------- */ |
| 66 | /* cx25850-firmware.c */ | 66 | /* cx25850-firmware.c */ |
diff --git a/drivers/media/video/cx25840/cx25840-firmware.c b/drivers/media/video/cx25840/cx25840-firmware.c index 1ddf724a2c74..620d295947ab 100644 --- a/drivers/media/video/cx25840/cx25840-firmware.c +++ b/drivers/media/video/cx25840/cx25840-firmware.c | |||
| @@ -79,11 +79,9 @@ static int check_fw_load(struct i2c_client *client, int size) | |||
| 79 | return 0; | 79 | return 0; |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | static int fw_write(struct i2c_client *client, u8 * data, int size) | 82 | static int fw_write(struct i2c_client *client, u8 *data, int size) |
| 83 | { | 83 | { |
| 84 | int sent; | 84 | if (i2c_master_send(client, data, size) < size) { |
| 85 | |||
| 86 | if ((sent = i2c_master_send(client, data, size)) < size) { | ||
| 87 | v4l_err(client, "firmware load i2c failure\n"); | 85 | v4l_err(client, "firmware load i2c failure\n"); |
| 88 | return -ENOSYS; | 86 | return -ENOSYS; |
| 89 | } | 87 | } |
| @@ -96,7 +94,7 @@ int cx25840_loadfw(struct i2c_client *client) | |||
| 96 | struct cx25840_state *state = i2c_get_clientdata(client); | 94 | struct cx25840_state *state = i2c_get_clientdata(client); |
| 97 | const struct firmware *fw = NULL; | 95 | const struct firmware *fw = NULL; |
| 98 | u8 buffer[4], *ptr; | 96 | u8 buffer[4], *ptr; |
| 99 | int size, send, retval; | 97 | int size, retval; |
| 100 | 98 | ||
| 101 | if (state->is_cx23885) | 99 | if (state->is_cx23885) |
| 102 | firmware = FWFILE_CX23885; | 100 | firmware = FWFILE_CX23885; |
| @@ -124,8 +122,7 @@ int cx25840_loadfw(struct i2c_client *client) | |||
| 124 | while (size > 0) { | 122 | while (size > 0) { |
| 125 | ptr[0] = 0x08; | 123 | ptr[0] = 0x08; |
| 126 | ptr[1] = 0x02; | 124 | ptr[1] = 0x02; |
| 127 | send = size > (FWSEND - 2) ? FWSEND : size + 2; | 125 | retval = fw_write(client, ptr, min(FWSEND, size + 2)); |
| 128 | retval = fw_write(client, ptr, send); | ||
| 129 | 126 | ||
| 130 | if (retval < 0) { | 127 | if (retval < 0) { |
| 131 | release_firmware(fw); | 128 | release_firmware(fw); |
diff --git a/drivers/media/video/cx25840/cx25840-vbi.c b/drivers/media/video/cx25840/cx25840-vbi.c index 6828f59b9d83..c754b9d13369 100644 --- a/drivers/media/video/cx25840/cx25840-vbi.c +++ b/drivers/media/video/cx25840/cx25840-vbi.c | |||
| @@ -85,7 +85,7 @@ static int decode_vps(u8 * dst, u8 * p) | |||
| 85 | void cx25840_vbi_setup(struct i2c_client *client) | 85 | void cx25840_vbi_setup(struct i2c_client *client) |
| 86 | { | 86 | { |
| 87 | struct cx25840_state *state = i2c_get_clientdata(client); | 87 | struct cx25840_state *state = i2c_get_clientdata(client); |
| 88 | v4l2_std_id std = cx25840_get_v4lstd(client); | 88 | v4l2_std_id std = state->std; |
| 89 | int hblank,hactive,burst,vblank,vactive,sc,vblank656,src_decimation; | 89 | int hblank,hactive,burst,vblank,vactive,sc,vblank656,src_decimation; |
| 90 | int luma_lpf,uv_lpf, comb; | 90 | int luma_lpf,uv_lpf, comb; |
| 91 | u32 pll_int,pll_frac,pll_post; | 91 | u32 pll_int,pll_frac,pll_post; |
| @@ -242,7 +242,7 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg) | |||
| 242 | 0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */ | 242 | 0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */ |
| 243 | 0, 0, 0, 0 | 243 | 0, 0, 0, 0 |
| 244 | }; | 244 | }; |
| 245 | int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_525_60); | 245 | int is_pal = !(state->std & V4L2_STD_525_60); |
| 246 | int i; | 246 | int i; |
| 247 | 247 | ||
| 248 | fmt = arg; | 248 | fmt = arg; |
| @@ -279,7 +279,7 @@ int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg) | |||
| 279 | 279 | ||
| 280 | case VIDIOC_S_FMT: | 280 | case VIDIOC_S_FMT: |
| 281 | { | 281 | { |
| 282 | int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_525_60); | 282 | int is_pal = !(state->std & V4L2_STD_525_60); |
| 283 | int vbi_offset = is_pal ? 1 : 0; | 283 | int vbi_offset = is_pal ? 1 : 0; |
| 284 | int i, x; | 284 | int i, x; |
| 285 | u8 lcr[24]; | 285 | u8 lcr[24]; |
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig index 49d3813a9b48..bcf6d9ba063d 100644 --- a/drivers/media/video/cx88/Kconfig +++ b/drivers/media/video/cx88/Kconfig | |||
| @@ -57,6 +57,7 @@ config VIDEO_CX88_DVB | |||
| 57 | select DVB_NXT200X if !DVB_FE_CUSTOMISE | 57 | select DVB_NXT200X if !DVB_FE_CUSTOMISE |
| 58 | select DVB_CX24123 if !DVB_FE_CUSTOMISE | 58 | select DVB_CX24123 if !DVB_FE_CUSTOMISE |
| 59 | select DVB_ISL6421 if !DVB_FE_CUSTOMISE | 59 | select DVB_ISL6421 if !DVB_FE_CUSTOMISE |
| 60 | select TUNER_SIMPLE if !DVB_FE_CUSTOMISE | ||
| 60 | ---help--- | 61 | ---help--- |
| 61 | This adds support for DVB/ATSC cards based on the | 62 | This adds support for DVB/ATSC cards based on the |
| 62 | Conexant 2388x chip. | 63 | Conexant 2388x chip. |
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c index 03feb5b49e1b..e976fc6bef7c 100644 --- a/drivers/media/video/cx88/cx88-alsa.c +++ b/drivers/media/video/cx88/cx88-alsa.c | |||
| @@ -283,7 +283,7 @@ static int dsp_buffer_free(snd_cx88_card_t *chip) | |||
| 283 | BUG_ON(!chip->dma_size); | 283 | BUG_ON(!chip->dma_size); |
| 284 | 284 | ||
| 285 | dprintk(2,"Freeing buffer\n"); | 285 | dprintk(2,"Freeing buffer\n"); |
| 286 | videobuf_pci_dma_unmap(chip->pci, chip->dma_risc); | 286 | videobuf_sg_dma_unmap(&chip->pci->dev, chip->dma_risc); |
| 287 | videobuf_dma_free(chip->dma_risc); | 287 | videobuf_dma_free(chip->dma_risc); |
| 288 | btcx_riscmem_free(chip->pci,&chip->buf->risc); | 288 | btcx_riscmem_free(chip->pci,&chip->buf->risc); |
| 289 | kfree(chip->buf); | 289 | kfree(chip->buf); |
| @@ -385,7 +385,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream, | |||
| 385 | BUG_ON(!chip->dma_size); | 385 | BUG_ON(!chip->dma_size); |
| 386 | BUG_ON(chip->num_periods & (chip->num_periods-1)); | 386 | BUG_ON(chip->num_periods & (chip->num_periods-1)); |
| 387 | 387 | ||
| 388 | buf = videobuf_pci_alloc(sizeof(*buf)); | 388 | buf = videobuf_sg_alloc(sizeof(*buf)); |
| 389 | if (NULL == buf) | 389 | if (NULL == buf) |
| 390 | return -ENOMEM; | 390 | return -ENOMEM; |
| 391 | 391 | ||
| @@ -396,14 +396,14 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream, | |||
| 396 | buf->vb.height = chip->num_periods; | 396 | buf->vb.height = chip->num_periods; |
| 397 | buf->vb.size = chip->dma_size; | 397 | buf->vb.size = chip->dma_size; |
| 398 | 398 | ||
| 399 | dma=videobuf_to_dma(&buf->vb); | 399 | dma = videobuf_to_dma(&buf->vb); |
| 400 | videobuf_dma_init(dma); | 400 | videobuf_dma_init(dma); |
| 401 | ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE, | 401 | ret = videobuf_dma_init_kernel(dma, PCI_DMA_FROMDEVICE, |
| 402 | (PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT)); | 402 | (PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT)); |
| 403 | if (ret < 0) | 403 | if (ret < 0) |
| 404 | goto error; | 404 | goto error; |
| 405 | 405 | ||
| 406 | ret = videobuf_pci_dma_map(chip->pci,dma); | 406 | ret = videobuf_sg_dma_map(&chip->pci->dev, dma); |
| 407 | if (ret < 0) | 407 | if (ret < 0) |
| 408 | goto error; | 408 | goto error; |
| 409 | 409 | ||
| @@ -494,7 +494,7 @@ static snd_pcm_uframes_t snd_cx88_pointer(struct snd_pcm_substream *substream) | |||
| 494 | 494 | ||
| 495 | count = atomic_read(&chip->count); | 495 | count = atomic_read(&chip->count); |
| 496 | 496 | ||
| 497 | // dprintk(2, "%s - count %d (+%u), period %d, frame %lu\n", __FUNCTION__, | 497 | // dprintk(2, "%s - count %d (+%u), period %d, frame %lu\n", __func__, |
| 498 | // count, new, count & (runtime->periods-1), | 498 | // count, new, count & (runtime->periods-1), |
| 499 | // runtime->period_size * (count & (runtime->periods-1))); | 499 | // runtime->period_size * (count & (runtime->periods-1))); |
| 500 | return runtime->period_size * (count & (runtime->periods-1)); | 500 | return runtime->period_size * (count & (runtime->periods-1)); |
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c index a99e9d5950aa..61c4f72644b8 100644 --- a/drivers/media/video/cx88/cx88-blackbird.c +++ b/drivers/media/video/cx88/cx88-blackbird.c | |||
| @@ -45,7 +45,7 @@ static unsigned int mpegbufs = 32; | |||
| 45 | module_param(mpegbufs,int,0644); | 45 | module_param(mpegbufs,int,0644); |
| 46 | MODULE_PARM_DESC(mpegbufs,"number of mpeg buffers, range 2-32"); | 46 | MODULE_PARM_DESC(mpegbufs,"number of mpeg buffers, range 2-32"); |
| 47 | 47 | ||
| 48 | static unsigned int debug = 0; | 48 | static unsigned int debug; |
| 49 | module_param(debug,int,0644); | 49 | module_param(debug,int,0644); |
| 50 | MODULE_PARM_DESC(debug,"enable debug messages [blackbird]"); | 50 | MODULE_PARM_DESC(debug,"enable debug messages [blackbird]"); |
| 51 | 51 | ||
| @@ -314,7 +314,7 @@ static int blackbird_mbox_func(void *priv, u32 command, int in, int out, u32 dat | |||
| 314 | u32 value, flag, retval; | 314 | u32 value, flag, retval; |
| 315 | int i; | 315 | int i; |
| 316 | 316 | ||
| 317 | dprintk(1,"%s: 0x%X\n", __FUNCTION__, command); | 317 | dprintk(1,"%s: 0x%X\n", __func__, command); |
| 318 | 318 | ||
| 319 | /* this may not be 100% safe if we can't read any memory location | 319 | /* this may not be 100% safe if we can't read any memory location |
| 320 | without side effects */ | 320 | without side effects */ |
| @@ -693,7 +693,7 @@ static int blackbird_queryctrl(struct cx8802_dev *dev, struct v4l2_queryctrl *qc | |||
| 693 | return -EINVAL; | 693 | return -EINVAL; |
| 694 | 694 | ||
| 695 | /* Standard V4L2 controls */ | 695 | /* Standard V4L2 controls */ |
| 696 | if (cx8800_ctrl_query(qctrl) == 0) | 696 | if (cx8800_ctrl_query(dev->core, qctrl) == 0) |
| 697 | return 0; | 697 | return 0; |
| 698 | 698 | ||
| 699 | /* MPEG V4L2 controls */ | 699 | /* MPEG V4L2 controls */ |
| @@ -933,7 +933,7 @@ static int vidioc_queryctrl (struct file *file, void *priv, | |||
| 933 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); | 933 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); |
| 934 | if (unlikely(qctrl->id == 0)) | 934 | if (unlikely(qctrl->id == 0)) |
| 935 | return -EINVAL; | 935 | return -EINVAL; |
| 936 | return cx8800_ctrl_query(qctrl); | 936 | return cx8800_ctrl_query(dev->core, qctrl); |
| 937 | } | 937 | } |
| 938 | 938 | ||
| 939 | static int vidioc_enum_input (struct file *file, void *priv, | 939 | static int vidioc_enum_input (struct file *file, void *priv, |
| @@ -1055,7 +1055,7 @@ static int mpeg_open(struct inode *inode, struct file *file) | |||
| 1055 | 1055 | ||
| 1056 | dev = cx8802_get_device(inode); | 1056 | dev = cx8802_get_device(inode); |
| 1057 | 1057 | ||
| 1058 | dprintk( 1, "%s\n", __FUNCTION__); | 1058 | dprintk( 1, "%s\n", __func__); |
| 1059 | 1059 | ||
| 1060 | if (dev == NULL) | 1060 | if (dev == NULL) |
| 1061 | return -ENODEV; | 1061 | return -ENODEV; |
| @@ -1065,7 +1065,7 @@ static int mpeg_open(struct inode *inode, struct file *file) | |||
| 1065 | if (drv) { | 1065 | if (drv) { |
| 1066 | err = drv->request_acquire(drv); | 1066 | err = drv->request_acquire(drv); |
| 1067 | if(err != 0) { | 1067 | if(err != 0) { |
| 1068 | dprintk(1,"%s: Unable to acquire hardware, %d\n", __FUNCTION__, err); | 1068 | dprintk(1,"%s: Unable to acquire hardware, %d\n", __func__, err); |
| 1069 | return err; | 1069 | return err; |
| 1070 | } | 1070 | } |
| 1071 | } | 1071 | } |
| @@ -1087,8 +1087,8 @@ static int mpeg_open(struct inode *inode, struct file *file) | |||
| 1087 | file->private_data = fh; | 1087 | file->private_data = fh; |
| 1088 | fh->dev = dev; | 1088 | fh->dev = dev; |
| 1089 | 1089 | ||
| 1090 | videobuf_queue_pci_init(&fh->mpegq, &blackbird_qops, | 1090 | videobuf_queue_sg_init(&fh->mpegq, &blackbird_qops, |
| 1091 | dev->pci, &dev->slock, | 1091 | &dev->pci->dev, &dev->slock, |
| 1092 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 1092 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 1093 | V4L2_FIELD_INTERLACED, | 1093 | V4L2_FIELD_INTERLACED, |
| 1094 | sizeof(struct cx88_buffer), | 1094 | sizeof(struct cx88_buffer), |
| @@ -1284,7 +1284,7 @@ static int cx8802_blackbird_probe(struct cx8802_driver *drv) | |||
| 1284 | struct cx8802_dev *dev = core->dvbdev; | 1284 | struct cx8802_dev *dev = core->dvbdev; |
| 1285 | int err; | 1285 | int err; |
| 1286 | 1286 | ||
| 1287 | dprintk( 1, "%s\n", __FUNCTION__); | 1287 | dprintk( 1, "%s\n", __func__); |
| 1288 | dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", | 1288 | dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", |
| 1289 | core->boardnr, | 1289 | core->boardnr, |
| 1290 | core->name, | 1290 | core->name, |
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index 8c9a8adf52de..620159d05506 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c | |||
| @@ -44,6 +44,16 @@ static unsigned int latency = UNSET; | |||
| 44 | module_param(latency,int,0444); | 44 | module_param(latency,int,0444); |
| 45 | MODULE_PARM_DESC(latency,"pci latency timer"); | 45 | MODULE_PARM_DESC(latency,"pci latency timer"); |
| 46 | 46 | ||
| 47 | #define info_printk(core, fmt, arg...) \ | ||
| 48 | printk(KERN_INFO "%s: " fmt, core->name , ## arg) | ||
| 49 | |||
| 50 | #define warn_printk(core, fmt, arg...) \ | ||
| 51 | printk(KERN_WARNING "%s: " fmt, core->name , ## arg) | ||
| 52 | |||
| 53 | #define err_printk(core, fmt, arg...) \ | ||
| 54 | printk(KERN_ERR "%s: " fmt, core->name , ## arg) | ||
| 55 | |||
| 56 | |||
| 47 | /* ------------------------------------------------------------------ */ | 57 | /* ------------------------------------------------------------------ */ |
| 48 | /* board config info */ | 58 | /* board config info */ |
| 49 | 59 | ||
| @@ -1354,6 +1364,10 @@ static const struct cx88_board cx88_boards[] = { | |||
| 1354 | }}, | 1364 | }}, |
| 1355 | /* fixme: Add radio support */ | 1365 | /* fixme: Add radio support */ |
| 1356 | .mpeg = CX88_MPEG_DVB | CX88_MPEG_BLACKBIRD, | 1366 | .mpeg = CX88_MPEG_DVB | CX88_MPEG_BLACKBIRD, |
| 1367 | .radio = { | ||
| 1368 | .type = CX88_RADIO, | ||
| 1369 | .gpio0 = 0xe780, | ||
| 1370 | }, | ||
| 1357 | }, | 1371 | }, |
| 1358 | [CX88_BOARD_ADSTECH_PTV_390] = { | 1372 | [CX88_BOARD_ADSTECH_PTV_390] = { |
| 1359 | .name = "ADS Tech Instant Video PCI", | 1373 | .name = "ADS Tech Instant Video PCI", |
| @@ -1401,6 +1415,245 @@ static const struct cx88_board cx88_boards[] = { | |||
| 1401 | }}, | 1415 | }}, |
| 1402 | .mpeg = CX88_MPEG_DVB, | 1416 | .mpeg = CX88_MPEG_DVB, |
| 1403 | }, | 1417 | }, |
| 1418 | [CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO] = { | ||
| 1419 | .name = "DViCO FusionHDTV 5 PCI nano", | ||
| 1420 | /* xc3008 tuner, digital only for now */ | ||
| 1421 | .tuner_type = TUNER_ABSENT, | ||
| 1422 | .radio_type = UNSET, | ||
| 1423 | .tuner_addr = ADDR_UNSET, | ||
| 1424 | .radio_addr = ADDR_UNSET, | ||
| 1425 | .input = {{ | ||
| 1426 | .type = CX88_VMUX_TELEVISION, | ||
| 1427 | .vmux = 0, | ||
| 1428 | .gpio0 = 0x000027df, /* Unconfirmed */ | ||
| 1429 | }, { | ||
| 1430 | .type = CX88_VMUX_COMPOSITE1, | ||
| 1431 | .vmux = 1, | ||
| 1432 | .gpio0 = 0x000027df, /* Unconfirmed */ | ||
| 1433 | .audioroute = 1, | ||
| 1434 | }, { | ||
| 1435 | .type = CX88_VMUX_SVIDEO, | ||
| 1436 | .vmux = 2, | ||
| 1437 | .gpio0 = 0x000027df, /* Unconfirmed */ | ||
| 1438 | .audioroute = 1, | ||
| 1439 | } }, | ||
| 1440 | .mpeg = CX88_MPEG_DVB, | ||
| 1441 | }, | ||
| 1442 | [CX88_BOARD_PINNACLE_HYBRID_PCTV] = { | ||
| 1443 | .name = "Pinnacle Hybrid PCTV", | ||
| 1444 | .tuner_type = TUNER_XC2028, | ||
| 1445 | .tuner_addr = 0x61, | ||
| 1446 | .input = { { | ||
| 1447 | .type = CX88_VMUX_TELEVISION, | ||
| 1448 | .vmux = 0, | ||
| 1449 | }, { | ||
| 1450 | .type = CX88_VMUX_COMPOSITE1, | ||
| 1451 | .vmux = 1, | ||
| 1452 | }, { | ||
| 1453 | .type = CX88_VMUX_SVIDEO, | ||
| 1454 | .vmux = 2, | ||
| 1455 | } }, | ||
| 1456 | .radio = { | ||
| 1457 | .type = CX88_RADIO, | ||
| 1458 | .gpio0 = 0x004ff, | ||
| 1459 | .gpio1 = 0x010ff, | ||
| 1460 | .gpio2 = 0x0ff, | ||
| 1461 | }, | ||
| 1462 | }, | ||
| 1463 | [CX88_BOARD_WINFAST_TV2000_XP_GLOBAL] = { | ||
| 1464 | .name = "Winfast TV2000 XP Global", | ||
| 1465 | .tuner_type = TUNER_XC2028, | ||
| 1466 | .tuner_addr = 0x61, | ||
| 1467 | .input = { { | ||
| 1468 | .type = CX88_VMUX_TELEVISION, | ||
| 1469 | .vmux = 0, | ||
| 1470 | .gpio0 = 0x0400, /* pin 2:mute = 0 (off?) */ | ||
| 1471 | .gpio1 = 0x0000, | ||
| 1472 | .gpio2 = 0x0800, /* pin 19:audio = 0 (tv) */ | ||
| 1473 | |||
| 1474 | }, { | ||
| 1475 | .type = CX88_VMUX_COMPOSITE1, | ||
| 1476 | .vmux = 1, | ||
| 1477 | .gpio0 = 0x0400, /* probably? or 0x0404 to turn mute on */ | ||
| 1478 | .gpio1 = 0x0000, | ||
| 1479 | .gpio2 = 0x0808, /* pin 19:audio = 1 (line) */ | ||
| 1480 | |||
| 1481 | }, { | ||
| 1482 | .type = CX88_VMUX_SVIDEO, | ||
| 1483 | .vmux = 2, | ||
| 1484 | } }, | ||
| 1485 | .radio = { | ||
| 1486 | .type = CX88_RADIO, | ||
| 1487 | .gpio0 = 0x004ff, | ||
| 1488 | .gpio1 = 0x010ff, | ||
| 1489 | .gpio2 = 0x0ff, | ||
| 1490 | }, | ||
| 1491 | }, | ||
| 1492 | [CX88_BOARD_POWERCOLOR_REAL_ANGEL] = { | ||
| 1493 | .name = "PowerColor Real Angel 330", | ||
| 1494 | .tuner_type = TUNER_XC2028, | ||
| 1495 | .tuner_addr = 0x61, | ||
| 1496 | .input = { { | ||
| 1497 | .type = CX88_VMUX_TELEVISION, | ||
| 1498 | .vmux = 0, | ||
| 1499 | .gpio0 = 0x00ff, | ||
| 1500 | .gpio1 = 0xf35d, | ||
| 1501 | .gpio3 = 0x0000, | ||
| 1502 | }, { | ||
| 1503 | .type = CX88_VMUX_COMPOSITE1, | ||
| 1504 | .vmux = 1, | ||
| 1505 | .gpio0 = 0x00ff, | ||
| 1506 | .gpio1 = 0xf37d, | ||
| 1507 | .gpio3 = 0x0000, | ||
| 1508 | }, { | ||
| 1509 | .type = CX88_VMUX_SVIDEO, | ||
| 1510 | .vmux = 2, | ||
| 1511 | .gpio0 = 0x000ff, | ||
| 1512 | .gpio1 = 0x0f37d, | ||
| 1513 | .gpio3 = 0x00000, | ||
| 1514 | } }, | ||
| 1515 | .radio = { | ||
| 1516 | .type = CX88_RADIO, | ||
| 1517 | .gpio0 = 0x000ff, | ||
| 1518 | .gpio1 = 0x0f35d, | ||
| 1519 | .gpio3 = 0x00000, | ||
| 1520 | }, | ||
| 1521 | }, | ||
| 1522 | [CX88_BOARD_GENIATECH_X8000_MT] = { | ||
| 1523 | /* Also PowerColor Real Angel 330 and Geniatech X800 OEM */ | ||
| 1524 | .name = "Geniatech X8000-MT DVBT", | ||
| 1525 | .tuner_type = TUNER_XC2028, | ||
| 1526 | .tuner_addr = 0x61, | ||
| 1527 | .input = { { | ||
| 1528 | .type = CX88_VMUX_TELEVISION, | ||
| 1529 | .vmux = 0, | ||
| 1530 | .gpio0 = 0x00000000, | ||
| 1531 | .gpio1 = 0x00e3e341, | ||
| 1532 | .gpio2 = 0x00000000, | ||
| 1533 | .gpio3 = 0x00000000, | ||
| 1534 | }, { | ||
| 1535 | .type = CX88_VMUX_COMPOSITE1, | ||
| 1536 | .vmux = 1, | ||
| 1537 | .gpio0 = 0x00000000, | ||
| 1538 | .gpio1 = 0x00e3e361, | ||
| 1539 | .gpio2 = 0x00000000, | ||
| 1540 | .gpio3 = 0x00000000, | ||
| 1541 | }, { | ||
| 1542 | .type = CX88_VMUX_SVIDEO, | ||
| 1543 | .vmux = 2, | ||
| 1544 | .gpio0 = 0x00000000, | ||
| 1545 | .gpio1 = 0x00e3e361, | ||
| 1546 | .gpio2 = 0x00000000, | ||
| 1547 | .gpio3 = 0x00000000, | ||
| 1548 | } }, | ||
| 1549 | .radio = { | ||
| 1550 | .type = CX88_RADIO, | ||
| 1551 | .gpio0 = 0x00000000, | ||
| 1552 | .gpio1 = 0x00e3e341, | ||
| 1553 | .gpio2 = 0x00000000, | ||
| 1554 | .gpio3 = 0x00000000, | ||
| 1555 | }, | ||
| 1556 | .mpeg = CX88_MPEG_DVB, | ||
| 1557 | }, | ||
| 1558 | [CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO] = { | ||
| 1559 | .name = "DViCO FusionHDTV DVB-T PRO", | ||
| 1560 | .tuner_type = TUNER_ABSENT, /* XXX: Has XC3028 */ | ||
| 1561 | .radio_type = UNSET, | ||
| 1562 | .tuner_addr = ADDR_UNSET, | ||
| 1563 | .radio_addr = ADDR_UNSET, | ||
| 1564 | .input = { { | ||
| 1565 | .type = CX88_VMUX_COMPOSITE1, | ||
| 1566 | .vmux = 1, | ||
| 1567 | .gpio0 = 0x000067df, | ||
| 1568 | }, { | ||
| 1569 | .type = CX88_VMUX_SVIDEO, | ||
| 1570 | .vmux = 2, | ||
| 1571 | .gpio0 = 0x000067df, | ||
| 1572 | } }, | ||
| 1573 | .mpeg = CX88_MPEG_DVB, | ||
| 1574 | }, | ||
| 1575 | [CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD] = { | ||
| 1576 | .name = "DViCO FusionHDTV 7 Gold", | ||
| 1577 | .tuner_type = TUNER_XC5000, | ||
| 1578 | .radio_type = UNSET, | ||
| 1579 | .tuner_addr = ADDR_UNSET, | ||
| 1580 | .radio_addr = ADDR_UNSET, | ||
| 1581 | .input = {{ | ||
| 1582 | .type = CX88_VMUX_TELEVISION, | ||
| 1583 | .vmux = 0, | ||
| 1584 | .gpio0 = 0x10df, | ||
| 1585 | },{ | ||
| 1586 | .type = CX88_VMUX_COMPOSITE1, | ||
| 1587 | .vmux = 1, | ||
| 1588 | .gpio0 = 0x16d9, | ||
| 1589 | },{ | ||
| 1590 | .type = CX88_VMUX_SVIDEO, | ||
| 1591 | .vmux = 2, | ||
| 1592 | .gpio0 = 0x16d9, | ||
| 1593 | }}, | ||
| 1594 | }, | ||
| 1595 | [CX88_BOARD_PROLINK_PV_8000GT] = { | ||
| 1596 | .name = "Prolink Pixelview MPEG 8000GT", | ||
| 1597 | .tuner_type = TUNER_XC2028, | ||
| 1598 | .tuner_addr = 0x61, | ||
| 1599 | .input = { { | ||
| 1600 | .type = CX88_VMUX_TELEVISION, | ||
| 1601 | .vmux = 0, | ||
| 1602 | .gpio0 = 0x0ff, | ||
| 1603 | .gpio2 = 0x0cfb, | ||
| 1604 | }, { | ||
| 1605 | .type = CX88_VMUX_COMPOSITE1, | ||
| 1606 | .vmux = 1, | ||
| 1607 | .gpio2 = 0x0cfb, | ||
| 1608 | }, { | ||
| 1609 | .type = CX88_VMUX_SVIDEO, | ||
| 1610 | .vmux = 2, | ||
| 1611 | .gpio2 = 0x0cfb, | ||
| 1612 | } }, | ||
| 1613 | .radio = { | ||
| 1614 | .type = CX88_RADIO, | ||
| 1615 | .gpio2 = 0x0cfb, | ||
| 1616 | }, | ||
| 1617 | }, | ||
| 1618 | /* Both radio, analog and ATSC work with this board. | ||
| 1619 | However, for analog to work, s5h1409 gate should be open, | ||
| 1620 | otherwise, tuner-xc3028 won't be detected. | ||
| 1621 | A proper fix require using the newer i2c methods to add | ||
| 1622 | tuner-xc3028 without doing an i2c probe. | ||
| 1623 | */ | ||
| 1624 | [CX88_BOARD_KWORLD_ATSC_120] = { | ||
| 1625 | .name = "Kworld PlusTV HD PCI 120 (ATSC 120)", | ||
| 1626 | .tuner_type = TUNER_XC2028, | ||
| 1627 | .radio_type = UNSET, | ||
| 1628 | .tuner_addr = ADDR_UNSET, | ||
| 1629 | .radio_addr = ADDR_UNSET, | ||
| 1630 | .input = { { | ||
| 1631 | .type = CX88_VMUX_TELEVISION, | ||
| 1632 | .vmux = 0, | ||
| 1633 | .gpio0 = 0x000000ff, | ||
| 1634 | .gpio1 = 0x0000f35d, | ||
| 1635 | .gpio2 = 0x00000000, | ||
| 1636 | }, { | ||
| 1637 | .type = CX88_VMUX_COMPOSITE1, | ||
| 1638 | .vmux = 1, | ||
| 1639 | .gpio0 = 0x000000ff, | ||
| 1640 | .gpio1 = 0x0000f37e, | ||
| 1641 | .gpio2 = 0x00000000, | ||
| 1642 | }, { | ||
| 1643 | .type = CX88_VMUX_SVIDEO, | ||
| 1644 | .vmux = 2, | ||
| 1645 | .gpio0 = 0x000000ff, | ||
| 1646 | .gpio1 = 0x0000f37e, | ||
| 1647 | .gpio2 = 0x00000000, | ||
| 1648 | } }, | ||
| 1649 | .radio = { | ||
| 1650 | .type = CX88_RADIO, | ||
| 1651 | .gpio0 = 0x000000ff, | ||
| 1652 | .gpio1 = 0x0000f35d, | ||
| 1653 | .gpio2 = 0x00000000, | ||
| 1654 | }, | ||
| 1655 | .mpeg = CX88_MPEG_DVB, | ||
| 1656 | }, | ||
| 1404 | }; | 1657 | }; |
| 1405 | 1658 | ||
| 1406 | /* ------------------------------------------------------------------ */ | 1659 | /* ------------------------------------------------------------------ */ |
| @@ -1605,7 +1858,11 @@ static const struct cx88_subid cx88_subids[] = { | |||
| 1605 | .subdevice = 0xdb11, | 1858 | .subdevice = 0xdb11, |
| 1606 | .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS, | 1859 | .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS, |
| 1607 | /* Re-branded DViCO: UltraView DVB-T Plus */ | 1860 | /* Re-branded DViCO: UltraView DVB-T Plus */ |
| 1608 | },{ | 1861 | }, { |
| 1862 | .subvendor = 0x18ac, | ||
| 1863 | .subdevice = 0xdb30, | ||
| 1864 | .card = CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO, | ||
| 1865 | }, { | ||
| 1609 | .subvendor = 0x17de, | 1866 | .subvendor = 0x17de, |
| 1610 | .subdevice = 0x0840, | 1867 | .subdevice = 0x0840, |
| 1611 | .card = CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT, | 1868 | .card = CX88_BOARD_KWORLD_HARDWARE_MPEG_TV_XPERT, |
| @@ -1714,6 +1971,38 @@ static const struct cx88_subid cx88_subids[] = { | |||
| 1714 | .subvendor = 0x11bd, | 1971 | .subvendor = 0x11bd, |
| 1715 | .subdevice = 0x0051, | 1972 | .subdevice = 0x0051, |
| 1716 | .card = CX88_BOARD_PINNACLE_PCTV_HD_800i, | 1973 | .card = CX88_BOARD_PINNACLE_PCTV_HD_800i, |
| 1974 | }, { | ||
| 1975 | .subvendor = 0x18ac, | ||
| 1976 | .subdevice = 0xd530, | ||
| 1977 | .card = CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO, | ||
| 1978 | }, { | ||
| 1979 | .subvendor = 0x12ab, | ||
| 1980 | .subdevice = 0x1788, | ||
| 1981 | .card = CX88_BOARD_PINNACLE_HYBRID_PCTV, | ||
| 1982 | }, { | ||
| 1983 | .subvendor = 0x14f1, | ||
| 1984 | .subdevice = 0xea3d, | ||
| 1985 | .card = CX88_BOARD_POWERCOLOR_REAL_ANGEL, | ||
| 1986 | }, { | ||
| 1987 | .subvendor = 0x107d, | ||
| 1988 | .subdevice = 0x6f18, | ||
| 1989 | .card = CX88_BOARD_WINFAST_TV2000_XP_GLOBAL, | ||
| 1990 | }, { | ||
| 1991 | .subvendor = 0x14f1, | ||
| 1992 | .subdevice = 0x8852, | ||
| 1993 | .card = CX88_BOARD_GENIATECH_X8000_MT, | ||
| 1994 | }, { | ||
| 1995 | .subvendor = 0x18ac, | ||
| 1996 | .subdevice = 0xd610, | ||
| 1997 | .card = CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD, | ||
| 1998 | }, { | ||
| 1999 | .subvendor = 0x1554, | ||
| 2000 | .subdevice = 0x4935, | ||
| 2001 | .card = CX88_BOARD_PROLINK_PV_8000GT, | ||
| 2002 | }, { | ||
| 2003 | .subvendor = 0x17de, | ||
| 2004 | .subdevice = 0x08c1, | ||
| 2005 | .card = CX88_BOARD_KWORLD_ATSC_120, | ||
| 1717 | }, | 2006 | }, |
| 1718 | }; | 2007 | }; |
| 1719 | 2008 | ||
| @@ -1731,17 +2020,16 @@ static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data) | |||
| 1731 | if (eeprom_data[4] != 0x7d || | 2020 | if (eeprom_data[4] != 0x7d || |
| 1732 | eeprom_data[5] != 0x10 || | 2021 | eeprom_data[5] != 0x10 || |
| 1733 | eeprom_data[7] != 0x66) { | 2022 | eeprom_data[7] != 0x66) { |
| 1734 | printk(KERN_WARNING "%s: Leadtek eeprom invalid.\n", | 2023 | warn_printk(core, "Leadtek eeprom invalid.\n"); |
| 1735 | core->name); | ||
| 1736 | return; | 2024 | return; |
| 1737 | } | 2025 | } |
| 1738 | 2026 | ||
| 1739 | core->board.tuner_type = (eeprom_data[6] == 0x13) ? | 2027 | core->board.tuner_type = (eeprom_data[6] == 0x13) ? |
| 1740 | TUNER_PHILIPS_FM1236_MK3 : TUNER_PHILIPS_FM1216ME_MK3; | 2028 | TUNER_PHILIPS_FM1236_MK3 : TUNER_PHILIPS_FM1216ME_MK3; |
| 1741 | 2029 | ||
| 1742 | printk(KERN_INFO "%s: Leadtek Winfast 2000XP Expert config: " | 2030 | info_printk(core, "Leadtek Winfast 2000XP Expert config: " |
| 1743 | "tuner=%d, eeprom[0]=0x%02x\n", | 2031 | "tuner=%d, eeprom[0]=0x%02x\n", |
| 1744 | core->name, core->board.tuner_type, eeprom_data[0]); | 2032 | core->board.tuner_type, eeprom_data[0]); |
| 1745 | } | 2033 | } |
| 1746 | 2034 | ||
| 1747 | static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) | 2035 | static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) |
| @@ -1785,13 +2073,12 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data) | |||
| 1785 | /* known */ | 2073 | /* known */ |
| 1786 | break; | 2074 | break; |
| 1787 | default: | 2075 | default: |
| 1788 | printk("%s: warning: unknown hauppauge model #%d\n", | 2076 | warn_printk(core, "warning: unknown hauppauge model #%d\n", |
| 1789 | core->name, tv.model); | 2077 | tv.model); |
| 1790 | break; | 2078 | break; |
| 1791 | } | 2079 | } |
| 1792 | 2080 | ||
| 1793 | printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n", | 2081 | info_printk(core, "hauppauge eeprom: model=%d\n", tv.model); |
| 1794 | core->name, tv.model); | ||
| 1795 | } | 2082 | } |
| 1796 | 2083 | ||
| 1797 | /* ----------------------------------------------------------------------- */ | 2084 | /* ----------------------------------------------------------------------- */ |
| @@ -1837,8 +2124,7 @@ static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data) | |||
| 1837 | char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner)) | 2124 | char *name = (eeprom_data[0x0d] < ARRAY_SIZE(gdi_tuner)) |
| 1838 | ? gdi_tuner[eeprom_data[0x0d]].name : NULL; | 2125 | ? gdi_tuner[eeprom_data[0x0d]].name : NULL; |
| 1839 | 2126 | ||
| 1840 | printk(KERN_INFO "%s: GDI: tuner=%s\n", core->name, | 2127 | info_printk(core, "GDI: tuner=%s\n", name ? name : "unknown"); |
| 1841 | name ? name : "unknown"); | ||
| 1842 | if (NULL == name) | 2128 | if (NULL == name) |
| 1843 | return; | 2129 | return; |
| 1844 | core->board.tuner_type = gdi_tuner[eeprom_data[0x0d]].id; | 2130 | core->board.tuner_type = gdi_tuner[eeprom_data[0x0d]].id; |
| @@ -1846,6 +2132,75 @@ static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data) | |||
| 1846 | CX88_RADIO : 0; | 2132 | CX88_RADIO : 0; |
| 1847 | } | 2133 | } |
| 1848 | 2134 | ||
| 2135 | /* ------------------------------------------------------------------- */ | ||
| 2136 | /* some Divco specific stuff */ | ||
| 2137 | static int cx88_dvico_xc2028_callback(struct cx88_core *core, | ||
| 2138 | int command, int arg) | ||
| 2139 | { | ||
| 2140 | switch (command) { | ||
| 2141 | case XC2028_TUNER_RESET: | ||
| 2142 | cx_write(MO_GP0_IO, 0x101000); | ||
| 2143 | mdelay(5); | ||
| 2144 | cx_set(MO_GP0_IO, 0x101010); | ||
| 2145 | break; | ||
| 2146 | default: | ||
| 2147 | return -EINVAL; | ||
| 2148 | } | ||
| 2149 | |||
| 2150 | return 0; | ||
| 2151 | } | ||
| 2152 | |||
| 2153 | |||
| 2154 | /* ----------------------------------------------------------------------- */ | ||
| 2155 | /* some Geniatech specific stuff */ | ||
| 2156 | |||
| 2157 | static int cx88_xc3028_geniatech_tuner_callback(struct cx88_core *core, | ||
| 2158 | int command, int mode) | ||
| 2159 | { | ||
| 2160 | switch (command) { | ||
| 2161 | case XC2028_TUNER_RESET: | ||
| 2162 | switch (INPUT(core->input).type) { | ||
| 2163 | case CX88_RADIO: | ||
| 2164 | break; | ||
| 2165 | case CX88_VMUX_DVB: | ||
| 2166 | cx_write(MO_GP1_IO, 0x030302); | ||
| 2167 | mdelay(50); | ||
| 2168 | break; | ||
| 2169 | default: | ||
| 2170 | cx_write(MO_GP1_IO, 0x030301); | ||
| 2171 | mdelay(50); | ||
| 2172 | } | ||
| 2173 | cx_write(MO_GP1_IO, 0x101010); | ||
| 2174 | mdelay(50); | ||
| 2175 | cx_write(MO_GP1_IO, 0x101000); | ||
| 2176 | mdelay(50); | ||
| 2177 | cx_write(MO_GP1_IO, 0x101010); | ||
| 2178 | mdelay(50); | ||
| 2179 | return 0; | ||
| 2180 | } | ||
| 2181 | return -EINVAL; | ||
| 2182 | } | ||
| 2183 | |||
| 2184 | /* ------------------------------------------------------------------- */ | ||
| 2185 | /* some Divco specific stuff */ | ||
| 2186 | static int cx88_pv_8000gt_callback(struct cx88_core *core, | ||
| 2187 | int command, int arg) | ||
| 2188 | { | ||
| 2189 | switch (command) { | ||
| 2190 | case XC2028_TUNER_RESET: | ||
| 2191 | cx_write(MO_GP2_IO, 0xcf7); | ||
| 2192 | mdelay(50); | ||
| 2193 | cx_write(MO_GP2_IO, 0xef5); | ||
| 2194 | mdelay(50); | ||
| 2195 | cx_write(MO_GP2_IO, 0xcf7); | ||
| 2196 | break; | ||
| 2197 | default: | ||
| 2198 | return -EINVAL; | ||
| 2199 | } | ||
| 2200 | |||
| 2201 | return 0; | ||
| 2202 | } | ||
| 2203 | |||
| 1849 | /* ----------------------------------------------------------------------- */ | 2204 | /* ----------------------------------------------------------------------- */ |
| 1850 | /* some DViCO specific stuff */ | 2205 | /* some DViCO specific stuff */ |
| 1851 | 2206 | ||
| @@ -1874,32 +2229,85 @@ static void dvico_fusionhdtv_hybrid_init(struct cx88_core *core) | |||
| 1874 | msg.len = (i != 12 ? 5 : 2); | 2229 | msg.len = (i != 12 ? 5 : 2); |
| 1875 | err = i2c_transfer(&core->i2c_adap, &msg, 1); | 2230 | err = i2c_transfer(&core->i2c_adap, &msg, 1); |
| 1876 | if (err != 1) { | 2231 | if (err != 1) { |
| 1877 | printk("dvico_fusionhdtv_hybrid_init buf %d failed (err = %d)!\n", i, err); | 2232 | warn_printk(core, "dvico_fusionhdtv_hybrid_init buf %d " |
| 2233 | "failed (err = %d)!\n", i, err); | ||
| 1878 | return; | 2234 | return; |
| 1879 | } | 2235 | } |
| 1880 | } | 2236 | } |
| 1881 | } | 2237 | } |
| 1882 | 2238 | ||
| 2239 | static int cx88_xc2028_tuner_callback(struct cx88_core *core, | ||
| 2240 | int command, int arg) | ||
| 2241 | { | ||
| 2242 | /* Board-specific callbacks */ | ||
| 2243 | switch (core->boardnr) { | ||
| 2244 | case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: | ||
| 2245 | case CX88_BOARD_POWERCOLOR_REAL_ANGEL: | ||
| 2246 | case CX88_BOARD_GENIATECH_X8000_MT: | ||
| 2247 | case CX88_BOARD_KWORLD_ATSC_120: | ||
| 2248 | return cx88_xc3028_geniatech_tuner_callback(core, | ||
| 2249 | command, arg); | ||
| 2250 | case CX88_BOARD_PROLINK_PV_8000GT: | ||
| 2251 | return cx88_pv_8000gt_callback(core, command, arg); | ||
| 2252 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: | ||
| 2253 | return cx88_dvico_xc2028_callback(core, command, arg); | ||
| 2254 | } | ||
| 2255 | |||
| 2256 | switch (command) { | ||
| 2257 | case XC2028_TUNER_RESET: | ||
| 2258 | switch (INPUT(core->input).type) { | ||
| 2259 | case CX88_RADIO: | ||
| 2260 | info_printk(core, "setting GPIO to radio!\n"); | ||
| 2261 | cx_write(MO_GP0_IO, 0x4ff); | ||
| 2262 | mdelay(250); | ||
| 2263 | cx_write(MO_GP2_IO, 0xff); | ||
| 2264 | mdelay(250); | ||
| 2265 | break; | ||
| 2266 | case CX88_VMUX_DVB: /* Digital TV*/ | ||
| 2267 | default: /* Analog TV */ | ||
| 2268 | info_printk(core, "setting GPIO to TV!\n"); | ||
| 2269 | break; | ||
| 2270 | } | ||
| 2271 | cx_write(MO_GP1_IO, 0x101010); | ||
| 2272 | mdelay(250); | ||
| 2273 | cx_write(MO_GP1_IO, 0x101000); | ||
| 2274 | mdelay(250); | ||
| 2275 | cx_write(MO_GP1_IO, 0x101010); | ||
| 2276 | mdelay(250); | ||
| 2277 | return 0; | ||
| 2278 | } | ||
| 2279 | return -EINVAL; | ||
| 2280 | } | ||
| 2281 | |||
| 1883 | /* ----------------------------------------------------------------------- */ | 2282 | /* ----------------------------------------------------------------------- */ |
| 1884 | /* Tuner callback function. Currently only needed for the Pinnacle * | 2283 | /* Tuner callback function. Currently only needed for the Pinnacle * |
| 1885 | * PCTV HD 800i with an xc5000 sillicon tuner. This is used for both * | 2284 | * PCTV HD 800i with an xc5000 sillicon tuner. This is used for both * |
| 1886 | * analog tuner attach (tuner-core.c) and dvb tuner attach (cx88-dvb.c) */ | 2285 | * analog tuner attach (tuner-core.c) and dvb tuner attach (cx88-dvb.c) */ |
| 1887 | 2286 | ||
| 1888 | int cx88_tuner_callback(void *priv, int command, int arg) | 2287 | static int cx88_xc5000_tuner_callback(struct cx88_core *core, |
| 2288 | int command, int arg) | ||
| 1889 | { | 2289 | { |
| 1890 | struct i2c_algo_bit_data *i2c_algo = priv; | 2290 | switch (core->boardnr) { |
| 1891 | struct cx88_core *core = i2c_algo->data; | ||
| 1892 | |||
| 1893 | switch(core->boardnr) { | ||
| 1894 | case CX88_BOARD_PINNACLE_PCTV_HD_800i: | 2291 | case CX88_BOARD_PINNACLE_PCTV_HD_800i: |
| 1895 | if(command == 0) { /* This is the reset command from xc5000 */ | 2292 | if (command == 0) { /* This is the reset command from xc5000 */ |
| 1896 | /* Reset XC5000 tuner via SYS_RSTO_pin */ | 2293 | /* Reset XC5000 tuner via SYS_RSTO_pin */ |
| 1897 | cx_write(MO_SRST_IO, 0); | 2294 | cx_write(MO_SRST_IO, 0); |
| 1898 | msleep(10); | 2295 | msleep(10); |
| 1899 | cx_write(MO_SRST_IO, 1); | 2296 | cx_write(MO_SRST_IO, 1); |
| 1900 | return 0; | 2297 | return 0; |
| 2298 | } else { | ||
| 2299 | err_printk(core, "xc5000: unknown tuner " | ||
| 2300 | "callback command.\n"); | ||
| 2301 | return -EINVAL; | ||
| 1901 | } | 2302 | } |
| 1902 | else { | 2303 | break; |
| 2304 | case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: | ||
| 2305 | if (command == 0) { /* This is the reset command from xc5000 */ | ||
| 2306 | cx_clear(MO_GP0_IO, 0x00000010); | ||
| 2307 | msleep(10); | ||
| 2308 | cx_set(MO_GP0_IO, 0x00000010); | ||
| 2309 | return 0; | ||
| 2310 | } else { | ||
| 1903 | printk(KERN_ERR | 2311 | printk(KERN_ERR |
| 1904 | "xc5000: unknown tuner callback command.\n"); | 2312 | "xc5000: unknown tuner callback command.\n"); |
| 1905 | return -EINVAL; | 2313 | return -EINVAL; |
| @@ -1908,6 +2316,36 @@ int cx88_tuner_callback(void *priv, int command, int arg) | |||
| 1908 | } | 2316 | } |
| 1909 | return 0; /* Should never be here */ | 2317 | return 0; /* Should never be here */ |
| 1910 | } | 2318 | } |
| 2319 | |||
| 2320 | int cx88_tuner_callback(void *priv, int command, int arg) | ||
| 2321 | { | ||
| 2322 | struct i2c_algo_bit_data *i2c_algo = priv; | ||
| 2323 | struct cx88_core *core; | ||
| 2324 | |||
| 2325 | if (!i2c_algo) { | ||
| 2326 | printk(KERN_ERR "cx88: Error - i2c private data undefined.\n"); | ||
| 2327 | return -EINVAL; | ||
| 2328 | } | ||
| 2329 | |||
| 2330 | core = i2c_algo->data; | ||
| 2331 | |||
| 2332 | if (!core) { | ||
| 2333 | printk(KERN_ERR "cx88: Error - device struct undefined.\n"); | ||
| 2334 | return -EINVAL; | ||
| 2335 | } | ||
| 2336 | |||
| 2337 | switch (core->board.tuner_type) { | ||
| 2338 | case TUNER_XC2028: | ||
| 2339 | info_printk(core, "Calling XC2028/3028 callback\n"); | ||
| 2340 | return cx88_xc2028_tuner_callback(core, command, arg); | ||
| 2341 | case TUNER_XC5000: | ||
| 2342 | info_printk(core, "Calling XC5000 callback\n"); | ||
| 2343 | return cx88_xc5000_tuner_callback(core, command, arg); | ||
| 2344 | } | ||
| 2345 | err_printk(core, "Error: Calling callback for tuner %d\n", | ||
| 2346 | core->board.tuner_type); | ||
| 2347 | return -EINVAL; | ||
| 2348 | } | ||
| 1911 | EXPORT_SYMBOL(cx88_tuner_callback); | 2349 | EXPORT_SYMBOL(cx88_tuner_callback); |
| 1912 | 2350 | ||
| 1913 | /* ----------------------------------------------------------------------- */ | 2351 | /* ----------------------------------------------------------------------- */ |
| @@ -1918,23 +2356,25 @@ static void cx88_card_list(struct cx88_core *core, struct pci_dev *pci) | |||
| 1918 | 2356 | ||
| 1919 | if (0 == pci->subsystem_vendor && | 2357 | if (0 == pci->subsystem_vendor && |
| 1920 | 0 == pci->subsystem_device) { | 2358 | 0 == pci->subsystem_device) { |
| 1921 | printk("%s: Your board has no valid PCI Subsystem ID and thus can't\n" | 2359 | printk(KERN_ERR |
| 2360 | "%s: Your board has no valid PCI Subsystem ID and thus can't\n" | ||
| 1922 | "%s: be autodetected. Please pass card=<n> insmod option to\n" | 2361 | "%s: be autodetected. Please pass card=<n> insmod option to\n" |
| 1923 | "%s: workaround that. Redirect complaints to the vendor of\n" | 2362 | "%s: workaround that. Redirect complaints to the vendor of\n" |
| 1924 | "%s: the TV card. Best regards,\n" | 2363 | "%s: the TV card. Best regards,\n" |
| 1925 | "%s: -- tux\n", | 2364 | "%s: -- tux\n", |
| 1926 | core->name,core->name,core->name,core->name,core->name); | 2365 | core->name,core->name,core->name,core->name,core->name); |
| 1927 | } else { | 2366 | } else { |
| 1928 | printk("%s: Your board isn't known (yet) to the driver. You can\n" | 2367 | printk(KERN_ERR |
| 2368 | "%s: Your board isn't known (yet) to the driver. You can\n" | ||
| 1929 | "%s: try to pick one of the existing card configs via\n" | 2369 | "%s: try to pick one of the existing card configs via\n" |
| 1930 | "%s: card=<n> insmod option. Updating to the latest\n" | 2370 | "%s: card=<n> insmod option. Updating to the latest\n" |
| 1931 | "%s: version might help as well.\n", | 2371 | "%s: version might help as well.\n", |
| 1932 | core->name,core->name,core->name,core->name); | 2372 | core->name,core->name,core->name,core->name); |
| 1933 | } | 2373 | } |
| 1934 | printk("%s: Here is a list of valid choices for the card=<n> insmod option:\n", | 2374 | err_printk(core, "Here is a list of valid choices for the card=<n> " |
| 1935 | core->name); | 2375 | "insmod option:\n"); |
| 1936 | for (i = 0; i < ARRAY_SIZE(cx88_boards); i++) | 2376 | for (i = 0; i < ARRAY_SIZE(cx88_boards); i++) |
| 1937 | printk("%s: card=%d -> %s\n", | 2377 | printk(KERN_ERR "%s: card=%d -> %s\n", |
| 1938 | core->name, i, cx88_boards[i].name); | 2378 | core->name, i, cx88_boards[i].name); |
| 1939 | } | 2379 | } |
| 1940 | 2380 | ||
| @@ -1951,9 +2391,57 @@ static void cx88_card_setup_pre_i2c(struct cx88_core *core) | |||
| 1951 | cx_set(MO_GP0_IO, 0x00000080); /* 702 out of reset */ | 2391 | cx_set(MO_GP0_IO, 0x00000080); /* 702 out of reset */ |
| 1952 | udelay(1000); | 2392 | udelay(1000); |
| 1953 | break; | 2393 | break; |
| 2394 | |||
| 2395 | case CX88_BOARD_PROLINK_PV_8000GT: | ||
| 2396 | cx_write(MO_GP2_IO, 0xcf7); | ||
| 2397 | mdelay(50); | ||
| 2398 | cx_write(MO_GP2_IO, 0xef5); | ||
| 2399 | mdelay(50); | ||
| 2400 | cx_write(MO_GP2_IO, 0xcf7); | ||
| 2401 | msleep(10); | ||
| 2402 | break; | ||
| 2403 | |||
| 2404 | case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: | ||
| 2405 | /* Enable the xc5000 tuner */ | ||
| 2406 | cx_set(MO_GP0_IO, 0x00001010); | ||
| 2407 | break; | ||
| 1954 | } | 2408 | } |
| 1955 | } | 2409 | } |
| 1956 | 2410 | ||
| 2411 | /* | ||
| 2412 | * Sets board-dependent xc3028 configuration | ||
| 2413 | */ | ||
| 2414 | void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl) | ||
| 2415 | { | ||
| 2416 | memset(ctl, 0, sizeof(*ctl)); | ||
| 2417 | |||
| 2418 | ctl->fname = XC2028_DEFAULT_FIRMWARE; | ||
| 2419 | ctl->max_len = 64; | ||
| 2420 | |||
| 2421 | switch (core->boardnr) { | ||
| 2422 | case CX88_BOARD_POWERCOLOR_REAL_ANGEL: | ||
| 2423 | /* Doesn't work with firmware version 2.7 */ | ||
| 2424 | ctl->fname = "xc3028-v25.fw"; | ||
| 2425 | break; | ||
| 2426 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: | ||
| 2427 | ctl->scode_table = XC3028_FE_ZARLINK456; | ||
| 2428 | break; | ||
| 2429 | case CX88_BOARD_KWORLD_ATSC_120: | ||
| 2430 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: | ||
| 2431 | ctl->demod = XC3028_FE_OREN538; | ||
| 2432 | break; | ||
| 2433 | case CX88_BOARD_PROLINK_PV_8000GT: | ||
| 2434 | /* | ||
| 2435 | * This board uses non-MTS firmware | ||
| 2436 | */ | ||
| 2437 | break; | ||
| 2438 | default: | ||
| 2439 | ctl->demod = XC3028_FE_OREN538; | ||
| 2440 | ctl->mts = 1; | ||
| 2441 | } | ||
| 2442 | } | ||
| 2443 | EXPORT_SYMBOL_GPL(cx88_setup_xc3028); | ||
| 2444 | |||
| 1957 | static void cx88_card_setup(struct cx88_core *core) | 2445 | static void cx88_card_setup(struct cx88_core *core) |
| 1958 | { | 2446 | { |
| 1959 | static u8 eeprom[256]; | 2447 | static u8 eeprom[256]; |
| @@ -1991,6 +2479,13 @@ static void cx88_card_setup(struct cx88_core *core) | |||
| 1991 | cx_write(MO_GP0_IO, 0x000007f8); | 2479 | cx_write(MO_GP0_IO, 0x000007f8); |
| 1992 | cx_write(MO_GP1_IO, 0x00000001); | 2480 | cx_write(MO_GP1_IO, 0x00000001); |
| 1993 | break; | 2481 | break; |
| 2482 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: | ||
| 2483 | /* GPIO0:0 is hooked to demod reset */ | ||
| 2484 | /* GPIO0:4 is hooked to xc3028 reset */ | ||
| 2485 | cx_write(MO_GP0_IO, 0x00111100); | ||
| 2486 | msleep(1); | ||
| 2487 | cx_write(MO_GP0_IO, 0x00111111); | ||
| 2488 | break; | ||
| 1994 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: | 2489 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: |
| 1995 | /* GPIO0:6 is hooked to FX2 reset pin */ | 2490 | /* GPIO0:6 is hooked to FX2 reset pin */ |
| 1996 | cx_set(MO_GP0_IO, 0x00004040); | 2491 | cx_set(MO_GP0_IO, 0x00004040); |
| @@ -2038,10 +2533,8 @@ static void cx88_card_setup(struct cx88_core *core) | |||
| 2038 | for (i = 0; i < ARRAY_SIZE(buffer); i++) | 2533 | for (i = 0; i < ARRAY_SIZE(buffer); i++) |
| 2039 | if (2 != i2c_master_send(&core->i2c_client, | 2534 | if (2 != i2c_master_send(&core->i2c_client, |
| 2040 | buffer[i],2)) | 2535 | buffer[i],2)) |
| 2041 | printk(KERN_WARNING | 2536 | warn_printk(core, "Unable to enable " |
| 2042 | "%s: Unable to enable " | 2537 | "tuner(%i).\n", i); |
| 2043 | "tuner(%i).\n", | ||
| 2044 | core->name, i); | ||
| 2045 | } | 2538 | } |
| 2046 | break; | 2539 | break; |
| 2047 | case CX88_BOARD_MSI_TVANYWHERE_MASTER: | 2540 | case CX88_BOARD_MSI_TVANYWHERE_MASTER: |
| @@ -2062,6 +2555,22 @@ static void cx88_card_setup(struct cx88_core *core) | |||
| 2062 | cx88_call_i2c_clients(core, TUNER_SET_CONFIG, &tea5767_cfg); | 2555 | cx88_call_i2c_clients(core, TUNER_SET_CONFIG, &tea5767_cfg); |
| 2063 | } | 2556 | } |
| 2064 | } | 2557 | } |
| 2558 | |||
| 2559 | if (core->board.tuner_type == TUNER_XC2028) { | ||
| 2560 | struct v4l2_priv_tun_config xc2028_cfg; | ||
| 2561 | struct xc2028_ctrl ctl; | ||
| 2562 | |||
| 2563 | /* Fills device-dependent initialization parameters */ | ||
| 2564 | cx88_setup_xc3028(core, &ctl); | ||
| 2565 | |||
| 2566 | /* Sends parameters to xc2028/3028 tuner */ | ||
| 2567 | memset(&xc2028_cfg, 0, sizeof(xc2028_cfg)); | ||
| 2568 | xc2028_cfg.tuner = TUNER_XC2028; | ||
| 2569 | xc2028_cfg.priv = &ctl; | ||
| 2570 | info_printk(core, "Asking xc2028/3028 to load firmware %s\n", | ||
| 2571 | ctl.fname); | ||
| 2572 | cx88_call_i2c_clients(core, TUNER_SET_CONFIG, &xc2028_cfg); | ||
| 2573 | } | ||
| 2065 | } | 2574 | } |
| 2066 | 2575 | ||
| 2067 | /* ------------------------------------------------------------------ */ | 2576 | /* ------------------------------------------------------------------ */ |
| @@ -2178,9 +2687,8 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) | |||
| 2178 | 2687 | ||
| 2179 | memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board)); | 2688 | memcpy(&core->board, &cx88_boards[core->boardnr], sizeof(core->board)); |
| 2180 | 2689 | ||
| 2181 | printk(KERN_INFO "%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n", | 2690 | info_printk(core, "subsystem: %04x:%04x, board: %s [card=%d,%s]\n", |
| 2182 | core->name,pci->subsystem_vendor, | 2691 | pci->subsystem_vendor, pci->subsystem_device, core->board.name, |
| 2183 | pci->subsystem_device, core->board.name, | ||
| 2184 | core->boardnr, card[core->nr] == core->boardnr ? | 2692 | core->boardnr, card[core->nr] == core->boardnr ? |
| 2185 | "insmod option" : "autodetected"); | 2693 | "insmod option" : "autodetected"); |
| 2186 | 2694 | ||
| @@ -2189,8 +2697,8 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) | |||
| 2189 | if (radio[core->nr] != UNSET) | 2697 | if (radio[core->nr] != UNSET) |
| 2190 | core->board.radio_type = radio[core->nr]; | 2698 | core->board.radio_type = radio[core->nr]; |
| 2191 | 2699 | ||
| 2192 | printk(KERN_INFO "%s: TV tuner type %d, Radio tuner type %d\n", | 2700 | info_printk(core, "TV tuner type %d, Radio tuner type %d\n", |
| 2193 | core->name, core->board.tuner_type, core->board.radio_type); | 2701 | core->board.tuner_type, core->board.radio_type); |
| 2194 | 2702 | ||
| 2195 | /* init hardware */ | 2703 | /* init hardware */ |
| 2196 | cx88_reset(core); | 2704 | cx88_reset(core); |
| @@ -2207,12 +2715,3 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) | |||
| 2207 | 2715 | ||
| 2208 | return core; | 2716 | return core; |
| 2209 | } | 2717 | } |
| 2210 | |||
| 2211 | /* ------------------------------------------------------------------ */ | ||
| 2212 | |||
| 2213 | /* | ||
| 2214 | * Local variables: | ||
| 2215 | * c-basic-offset: 8 | ||
| 2216 | * End: | ||
| 2217 | * kate: eol "unix"; indent-width 3; remove-trailing-space on; replace-trailing-space-save on; tab-width 8; replace-tabs off; space-indent off; mixed-indent off | ||
| 2218 | */ | ||
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c index 01e2ac98970b..c4d1aff1fdb4 100644 --- a/drivers/media/video/cx88/cx88-core.c +++ b/drivers/media/video/cx88/cx88-core.c | |||
| @@ -47,15 +47,15 @@ MODULE_LICENSE("GPL"); | |||
| 47 | 47 | ||
| 48 | /* ------------------------------------------------------------------ */ | 48 | /* ------------------------------------------------------------------ */ |
| 49 | 49 | ||
| 50 | static unsigned int core_debug = 0; | 50 | static unsigned int core_debug; |
| 51 | module_param(core_debug,int,0644); | 51 | module_param(core_debug,int,0644); |
| 52 | MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); | 52 | MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); |
| 53 | 53 | ||
| 54 | static unsigned int nicam = 0; | 54 | static unsigned int nicam; |
| 55 | module_param(nicam,int,0644); | 55 | module_param(nicam,int,0644); |
| 56 | MODULE_PARM_DESC(nicam,"tv audio is nicam"); | 56 | MODULE_PARM_DESC(nicam,"tv audio is nicam"); |
| 57 | 57 | ||
| 58 | static unsigned int nocomb = 0; | 58 | static unsigned int nocomb; |
| 59 | module_param(nocomb,int,0644); | 59 | module_param(nocomb,int,0644); |
| 60 | MODULE_PARM_DESC(nocomb,"disable comb filter"); | 60 | MODULE_PARM_DESC(nocomb,"disable comb filter"); |
| 61 | 61 | ||
| @@ -219,7 +219,7 @@ cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf) | |||
| 219 | videobuf_waiton(&buf->vb,0,0); | 219 | videobuf_waiton(&buf->vb,0,0); |
| 220 | videobuf_dma_unmap(q, dma); | 220 | videobuf_dma_unmap(q, dma); |
| 221 | videobuf_dma_free(dma); | 221 | videobuf_dma_free(dma); |
| 222 | btcx_riscmem_free((struct pci_dev *)q->dev, &buf->risc); | 222 | btcx_riscmem_free(to_pci_dev(q->dev), &buf->risc); |
| 223 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | 223 | buf->vb.state = VIDEOBUF_NEEDS_INIT; |
| 224 | } | 224 | } |
| 225 | 225 | ||
| @@ -548,7 +548,7 @@ void cx88_wakeup(struct cx88_core *core, | |||
| 548 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); | 548 | mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT); |
| 549 | } | 549 | } |
| 550 | if (bc != 1) | 550 | if (bc != 1) |
| 551 | printk("%s: %d buffers handled (should be 1)\n",__FUNCTION__,bc); | 551 | printk("%s: %d buffers handled (should be 1)\n",__func__,bc); |
| 552 | } | 552 | } |
| 553 | 553 | ||
| 554 | void cx88_shutdown(struct cx88_core *core) | 554 | void cx88_shutdown(struct cx88_core *core) |
| @@ -577,7 +577,7 @@ void cx88_shutdown(struct cx88_core *core) | |||
| 577 | 577 | ||
| 578 | int cx88_reset(struct cx88_core *core) | 578 | int cx88_reset(struct cx88_core *core) |
| 579 | { | 579 | { |
| 580 | dprintk(1,"%s\n",__FUNCTION__); | 580 | dprintk(1,"%s\n",__func__); |
| 581 | cx88_shutdown(core); | 581 | cx88_shutdown(core); |
| 582 | 582 | ||
| 583 | /* clear irq status */ | 583 | /* clear irq status */ |
| @@ -929,7 +929,10 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm) | |||
| 929 | 929 | ||
| 930 | dprintk(1,"set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n", | 930 | dprintk(1,"set_tvnorm: MO_INPUT_FORMAT 0x%08x [old=0x%08x]\n", |
| 931 | cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f); | 931 | cxiformat, cx_read(MO_INPUT_FORMAT) & 0x0f); |
| 932 | cx_andor(MO_INPUT_FORMAT, 0xf, cxiformat); | 932 | /* Chroma AGC must be disabled if SECAM is used, we enable it |
| 933 | by default on PAL and NTSC */ | ||
| 934 | cx_andor(MO_INPUT_FORMAT, 0x40f, | ||
| 935 | norm & V4L2_STD_SECAM ? cxiformat : cxiformat | 0x400); | ||
| 933 | 936 | ||
| 934 | // FIXME: as-is from DScaler | 937 | // FIXME: as-is from DScaler |
| 935 | dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n", | 938 | dprintk(1,"set_tvnorm: MO_OUTPUT_FORMAT 0x%08x [old=0x%08x]\n", |
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c index f7b41eb1bb5a..f1251b844e08 100644 --- a/drivers/media/video/cx88/cx88-dvb.c +++ b/drivers/media/video/cx88/cx88-dvb.c | |||
| @@ -45,16 +45,20 @@ | |||
| 45 | #include "nxt200x.h" | 45 | #include "nxt200x.h" |
| 46 | #include "cx24123.h" | 46 | #include "cx24123.h" |
| 47 | #include "isl6421.h" | 47 | #include "isl6421.h" |
| 48 | #include "tuner-simple.h" | ||
| 49 | #include "tda9887.h" | ||
| 48 | 50 | ||
| 49 | MODULE_DESCRIPTION("driver for cx2388x based DVB cards"); | 51 | MODULE_DESCRIPTION("driver for cx2388x based DVB cards"); |
| 50 | MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); | 52 | MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); |
| 51 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); | 53 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
| 52 | MODULE_LICENSE("GPL"); | 54 | MODULE_LICENSE("GPL"); |
| 53 | 55 | ||
| 54 | static unsigned int debug = 0; | 56 | static unsigned int debug; |
| 55 | module_param(debug, int, 0644); | 57 | module_param(debug, int, 0644); |
| 56 | MODULE_PARM_DESC(debug,"enable debug messages [dvb]"); | 58 | MODULE_PARM_DESC(debug,"enable debug messages [dvb]"); |
| 57 | 59 | ||
| 60 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 61 | |||
| 58 | #define dprintk(level,fmt, arg...) if (debug >= level) \ | 62 | #define dprintk(level,fmt, arg...) if (debug >= level) \ |
| 59 | printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg) | 63 | printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg) |
| 60 | 64 | ||
| @@ -235,6 +239,19 @@ static struct zl10353_config dvico_fusionhdtv_hybrid = { | |||
| 235 | .no_tuner = 1, | 239 | .no_tuner = 1, |
| 236 | }; | 240 | }; |
| 237 | 241 | ||
| 242 | static struct zl10353_config dvico_fusionhdtv_xc3028 = { | ||
| 243 | .demod_address = 0x0f, | ||
| 244 | .if2 = 45600, | ||
| 245 | .no_tuner = 1, | ||
| 246 | }; | ||
| 247 | |||
| 248 | static struct mt352_config dvico_fusionhdtv_mt352_xc3028 = { | ||
| 249 | .demod_address = 0x0f, | ||
| 250 | .if2 = 4560, | ||
| 251 | .no_tuner = 1, | ||
| 252 | .demod_init = dvico_fusionhdtv_demod_init, | ||
| 253 | }; | ||
| 254 | |||
| 238 | static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = { | 255 | static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = { |
| 239 | .demod_address = 0x0f, | 256 | .demod_address = 0x0f, |
| 240 | }; | 257 | }; |
| @@ -266,7 +283,7 @@ static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index) | |||
| 266 | struct cx8802_dev *dev= fe->dvb->priv; | 283 | struct cx8802_dev *dev= fe->dvb->priv; |
| 267 | struct cx88_core *core = dev->core; | 284 | struct cx88_core *core = dev->core; |
| 268 | 285 | ||
| 269 | dprintk(1, "%s: index = %d\n", __FUNCTION__, index); | 286 | dprintk(1, "%s: index = %d\n", __func__, index); |
| 270 | if (index == 0) | 287 | if (index == 0) |
| 271 | cx_clear(MO_GP0_IO, 8); | 288 | cx_clear(MO_GP0_IO, 8); |
| 272 | else | 289 | else |
| @@ -357,6 +374,40 @@ static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe, | |||
| 357 | return 0; | 374 | return 0; |
| 358 | } | 375 | } |
| 359 | 376 | ||
| 377 | static int cx88_pci_nano_callback(void *ptr, int command, int arg) | ||
| 378 | { | ||
| 379 | struct cx88_core *core = ptr; | ||
| 380 | |||
| 381 | switch (command) { | ||
| 382 | case XC2028_TUNER_RESET: | ||
| 383 | /* Send the tuner in then out of reset */ | ||
| 384 | dprintk(1, "%s: XC2028_TUNER_RESET %d\n", __func__, arg); | ||
| 385 | |||
| 386 | switch (core->boardnr) { | ||
| 387 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: | ||
| 388 | /* GPIO-4 xc3028 tuner */ | ||
| 389 | |||
| 390 | cx_set(MO_GP0_IO, 0x00001000); | ||
| 391 | cx_clear(MO_GP0_IO, 0x00000010); | ||
| 392 | msleep(100); | ||
| 393 | cx_set(MO_GP0_IO, 0x00000010); | ||
| 394 | msleep(100); | ||
| 395 | break; | ||
| 396 | } | ||
| 397 | |||
| 398 | break; | ||
| 399 | case XC2028_RESET_CLK: | ||
| 400 | dprintk(1, "%s: XC2028_RESET_CLK %d\n", __func__, arg); | ||
| 401 | break; | ||
| 402 | default: | ||
| 403 | dprintk(1, "%s: unknown command %d, arg %d\n", __func__, | ||
| 404 | command, arg); | ||
| 405 | return -EINVAL; | ||
| 406 | } | ||
| 407 | |||
| 408 | return 0; | ||
| 409 | } | ||
| 410 | |||
| 360 | static struct cx24123_config geniatech_dvbs_config = { | 411 | static struct cx24123_config geniatech_dvbs_config = { |
| 361 | .demod_address = 0x55, | 412 | .demod_address = 0x55, |
| 362 | .set_ts_params = cx24123_set_ts_param, | 413 | .set_ts_params = cx24123_set_ts_param, |
| @@ -383,12 +434,76 @@ static struct s5h1409_config pinnacle_pctv_hd_800i_config = { | |||
| 383 | .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK, | 434 | .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK, |
| 384 | }; | 435 | }; |
| 385 | 436 | ||
| 437 | static struct s5h1409_config dvico_hdtv5_pci_nano_config = { | ||
| 438 | .demod_address = 0x32 >> 1, | ||
| 439 | .output_mode = S5H1409_SERIAL_OUTPUT, | ||
| 440 | .gpio = S5H1409_GPIO_OFF, | ||
| 441 | .inversion = S5H1409_INVERSION_OFF, | ||
| 442 | .status_mode = S5H1409_DEMODLOCKING, | ||
| 443 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | ||
| 444 | }; | ||
| 445 | |||
| 446 | static struct s5h1409_config kworld_atsc_120_config = { | ||
| 447 | .demod_address = 0x32 >> 1, | ||
| 448 | .output_mode = S5H1409_SERIAL_OUTPUT, | ||
| 449 | .gpio = S5H1409_GPIO_OFF, | ||
| 450 | .inversion = S5H1409_INVERSION_OFF, | ||
| 451 | .status_mode = S5H1409_DEMODLOCKING, | ||
| 452 | .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK, | ||
| 453 | }; | ||
| 454 | |||
| 386 | static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = { | 455 | static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = { |
| 387 | .i2c_address = 0x64, | 456 | .i2c_address = 0x64, |
| 388 | .if_khz = 5380, | 457 | .if_khz = 5380, |
| 389 | .tuner_callback = cx88_tuner_callback, | 458 | .tuner_callback = cx88_tuner_callback, |
| 390 | }; | 459 | }; |
| 391 | 460 | ||
| 461 | static struct zl10353_config cx88_geniatech_x8000_mt = { | ||
| 462 | .demod_address = (0x1e >> 1), | ||
| 463 | .no_tuner = 1, | ||
| 464 | }; | ||
| 465 | |||
| 466 | static int attach_xc3028(u8 addr, struct cx8802_dev *dev) | ||
| 467 | { | ||
| 468 | struct dvb_frontend *fe; | ||
| 469 | struct xc2028_ctrl ctl; | ||
| 470 | struct xc2028_config cfg = { | ||
| 471 | .i2c_adap = &dev->core->i2c_adap, | ||
| 472 | .i2c_addr = addr, | ||
| 473 | .ctrl = &ctl, | ||
| 474 | .callback = cx88_tuner_callback, | ||
| 475 | }; | ||
| 476 | |||
| 477 | if (!dev->dvb.frontend) { | ||
| 478 | printk(KERN_ERR "%s/2: dvb frontend not attached. " | ||
| 479 | "Can't attach xc3028\n", | ||
| 480 | dev->core->name); | ||
| 481 | return -EINVAL; | ||
| 482 | } | ||
| 483 | |||
| 484 | /* | ||
| 485 | * Some xc3028 devices may be hidden by an I2C gate. This is known | ||
| 486 | * to happen with some s5h1409-based devices. | ||
| 487 | * Now that I2C gate is open, sets up xc3028 configuration | ||
| 488 | */ | ||
| 489 | cx88_setup_xc3028(dev->core, &ctl); | ||
| 490 | |||
| 491 | fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg); | ||
| 492 | if (!fe) { | ||
| 493 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", | ||
| 494 | dev->core->name); | ||
| 495 | dvb_frontend_detach(dev->dvb.frontend); | ||
| 496 | dvb_unregister_frontend(dev->dvb.frontend); | ||
| 497 | dev->dvb.frontend = NULL; | ||
| 498 | return -EINVAL; | ||
| 499 | } | ||
| 500 | |||
| 501 | printk(KERN_INFO "%s/2: xc3028 attached\n", | ||
| 502 | dev->core->name); | ||
| 503 | |||
| 504 | return 0; | ||
| 505 | } | ||
| 506 | |||
| 392 | static int dvb_register(struct cx8802_dev *dev) | 507 | static int dvb_register(struct cx8802_dev *dev) |
| 393 | { | 508 | { |
| 394 | /* init struct videobuf_dvb */ | 509 | /* init struct videobuf_dvb */ |
| @@ -429,8 +544,9 @@ static int dvb_register(struct cx8802_dev *dev) | |||
| 429 | &hauppauge_hvr_config, | 544 | &hauppauge_hvr_config, |
| 430 | &dev->core->i2c_adap); | 545 | &dev->core->i2c_adap); |
| 431 | if (dev->dvb.frontend != NULL) { | 546 | if (dev->dvb.frontend != NULL) { |
| 432 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 547 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 433 | &dev->core->i2c_adap, DVB_PLL_FMD1216ME); | 548 | &dev->core->i2c_adap, 0x61, |
| 549 | TUNER_PHILIPS_FMD1216ME_MK3); | ||
| 434 | } | 550 | } |
| 435 | break; | 551 | break; |
| 436 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: | 552 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: |
| @@ -497,8 +613,9 @@ static int dvb_register(struct cx8802_dev *dev) | |||
| 497 | dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, | 613 | dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, |
| 498 | &dev->vp3054->adap); | 614 | &dev->vp3054->adap); |
| 499 | if (dev->dvb.frontend != NULL) { | 615 | if (dev->dvb.frontend != NULL) { |
| 500 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 616 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 501 | &dev->core->i2c_adap, DVB_PLL_FMD1216ME); | 617 | &dev->core->i2c_adap, 0x61, |
| 618 | TUNER_PHILIPS_FMD1216ME_MK3); | ||
| 502 | } | 619 | } |
| 503 | #else | 620 | #else |
| 504 | printk(KERN_ERR "%s/2: built without vp3054 support\n", dev->core->name); | 621 | printk(KERN_ERR "%s/2: built without vp3054 support\n", dev->core->name); |
| @@ -509,18 +626,36 @@ static int dvb_register(struct cx8802_dev *dev) | |||
| 509 | &dvico_fusionhdtv_hybrid, | 626 | &dvico_fusionhdtv_hybrid, |
| 510 | &dev->core->i2c_adap); | 627 | &dev->core->i2c_adap); |
| 511 | if (dev->dvb.frontend != NULL) { | 628 | if (dev->dvb.frontend != NULL) { |
| 512 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 629 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 513 | &dev->core->i2c_adap, | 630 | &dev->core->i2c_adap, 0x61, |
| 514 | DVB_PLL_THOMSON_FE6600); | 631 | TUNER_THOMSON_FE6600); |
| 515 | } | 632 | } |
| 516 | break; | 633 | break; |
| 634 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: | ||
| 635 | dev->dvb.frontend = dvb_attach(zl10353_attach, | ||
| 636 | &dvico_fusionhdtv_xc3028, | ||
| 637 | &dev->core->i2c_adap); | ||
| 638 | if (dev->dvb.frontend == NULL) | ||
| 639 | dev->dvb.frontend = dvb_attach(mt352_attach, | ||
| 640 | &dvico_fusionhdtv_mt352_xc3028, | ||
| 641 | &dev->core->i2c_adap); | ||
| 642 | /* | ||
| 643 | * On this board, the demod provides the I2C bus pullup. | ||
| 644 | * We must not permit gate_ctrl to be performed, or | ||
| 645 | * the xc3028 cannot communicate on the bus. | ||
| 646 | */ | ||
| 647 | if (dev->dvb.frontend) | ||
| 648 | dev->dvb.frontend->ops.i2c_gate_ctrl = NULL; | ||
| 649 | if (attach_xc3028(0x61, dev) < 0) | ||
| 650 | return -EINVAL; | ||
| 651 | break; | ||
| 517 | case CX88_BOARD_PCHDTV_HD3000: | 652 | case CX88_BOARD_PCHDTV_HD3000: |
| 518 | dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, | 653 | dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, |
| 519 | &dev->core->i2c_adap); | 654 | &dev->core->i2c_adap); |
| 520 | if (dev->dvb.frontend != NULL) { | 655 | if (dev->dvb.frontend != NULL) { |
| 521 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 656 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 522 | &dev->core->i2c_adap, | 657 | &dev->core->i2c_adap, 0x61, |
| 523 | DVB_PLL_THOMSON_DTT761X); | 658 | TUNER_THOMSON_DTT761X); |
| 524 | } | 659 | } |
| 525 | break; | 660 | break; |
| 526 | case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: | 661 | case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: |
| @@ -540,9 +675,9 @@ static int dvb_register(struct cx8802_dev *dev) | |||
| 540 | &fusionhdtv_3_gold, | 675 | &fusionhdtv_3_gold, |
| 541 | &dev->core->i2c_adap); | 676 | &dev->core->i2c_adap); |
| 542 | if (dev->dvb.frontend != NULL) { | 677 | if (dev->dvb.frontend != NULL) { |
| 543 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 678 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 544 | &dev->core->i2c_adap, | 679 | &dev->core->i2c_adap, 0x61, |
| 545 | DVB_PLL_MICROTUNE_4042); | 680 | TUNER_MICROTUNE_4042FI5); |
| 546 | } | 681 | } |
| 547 | } | 682 | } |
| 548 | break; | 683 | break; |
| @@ -560,9 +695,9 @@ static int dvb_register(struct cx8802_dev *dev) | |||
| 560 | &fusionhdtv_3_gold, | 695 | &fusionhdtv_3_gold, |
| 561 | &dev->core->i2c_adap); | 696 | &dev->core->i2c_adap); |
| 562 | if (dev->dvb.frontend != NULL) { | 697 | if (dev->dvb.frontend != NULL) { |
| 563 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 698 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 564 | &dev->core->i2c_adap, | 699 | &dev->core->i2c_adap, 0x61, |
| 565 | DVB_PLL_THOMSON_DTT761X); | 700 | TUNER_THOMSON_DTT761X); |
| 566 | } | 701 | } |
| 567 | } | 702 | } |
| 568 | break; | 703 | break; |
| @@ -580,9 +715,11 @@ static int dvb_register(struct cx8802_dev *dev) | |||
| 580 | &fusionhdtv_5_gold, | 715 | &fusionhdtv_5_gold, |
| 581 | &dev->core->i2c_adap); | 716 | &dev->core->i2c_adap); |
| 582 | if (dev->dvb.frontend != NULL) { | 717 | if (dev->dvb.frontend != NULL) { |
| 583 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 718 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 584 | &dev->core->i2c_adap, | 719 | &dev->core->i2c_adap, 0x61, |
| 585 | DVB_PLL_LG_TDVS_H06XF); | 720 | TUNER_LG_TDVS_H06XF); |
| 721 | dvb_attach(tda9887_attach, dev->dvb.frontend, | ||
| 722 | &dev->core->i2c_adap, 0x43); | ||
| 586 | } | 723 | } |
| 587 | } | 724 | } |
| 588 | break; | 725 | break; |
| @@ -600,9 +737,11 @@ static int dvb_register(struct cx8802_dev *dev) | |||
| 600 | &pchdtv_hd5500, | 737 | &pchdtv_hd5500, |
| 601 | &dev->core->i2c_adap); | 738 | &dev->core->i2c_adap); |
| 602 | if (dev->dvb.frontend != NULL) { | 739 | if (dev->dvb.frontend != NULL) { |
| 603 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 740 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 604 | &dev->core->i2c_adap, | 741 | &dev->core->i2c_adap, 0x61, |
| 605 | DVB_PLL_LG_TDVS_H06XF); | 742 | TUNER_LG_TDVS_H06XF); |
| 743 | dvb_attach(tda9887_attach, dev->dvb.frontend, | ||
| 744 | &dev->core->i2c_adap, 0x43); | ||
| 606 | } | 745 | } |
| 607 | } | 746 | } |
| 608 | break; | 747 | break; |
| @@ -611,8 +750,9 @@ static int dvb_register(struct cx8802_dev *dev) | |||
| 611 | &ati_hdtvwonder, | 750 | &ati_hdtvwonder, |
| 612 | &dev->core->i2c_adap); | 751 | &dev->core->i2c_adap); |
| 613 | if (dev->dvb.frontend != NULL) { | 752 | if (dev->dvb.frontend != NULL) { |
| 614 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 753 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 615 | NULL, DVB_PLL_TUV1236D); | 754 | &dev->core->i2c_adap, 0x61, |
| 755 | TUNER_PHILIPS_TUV1236D); | ||
| 616 | } | 756 | } |
| 617 | break; | 757 | break; |
| 618 | case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: | 758 | case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: |
| @@ -658,14 +798,62 @@ static int dvb_register(struct cx8802_dev *dev) | |||
| 658 | &pinnacle_pctv_hd_800i_tuner_config); | 798 | &pinnacle_pctv_hd_800i_tuner_config); |
| 659 | } | 799 | } |
| 660 | break; | 800 | break; |
| 801 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: | ||
| 802 | dev->dvb.frontend = dvb_attach(s5h1409_attach, | ||
| 803 | &dvico_hdtv5_pci_nano_config, | ||
| 804 | &dev->core->i2c_adap); | ||
| 805 | if (dev->dvb.frontend != NULL) { | ||
| 806 | struct dvb_frontend *fe; | ||
| 807 | struct xc2028_config cfg = { | ||
| 808 | .i2c_adap = &dev->core->i2c_adap, | ||
| 809 | .i2c_addr = 0x61, | ||
| 810 | .callback = cx88_pci_nano_callback, | ||
| 811 | }; | ||
| 812 | static struct xc2028_ctrl ctl = { | ||
| 813 | .fname = "xc3028-v27.fw", | ||
| 814 | .max_len = 64, | ||
| 815 | .scode_table = XC3028_FE_OREN538, | ||
| 816 | }; | ||
| 817 | |||
| 818 | fe = dvb_attach(xc2028_attach, | ||
| 819 | dev->dvb.frontend, &cfg); | ||
| 820 | if (fe != NULL && fe->ops.tuner_ops.set_config != NULL) | ||
| 821 | fe->ops.tuner_ops.set_config(fe, &ctl); | ||
| 822 | } | ||
| 823 | break; | ||
| 824 | case CX88_BOARD_PINNACLE_HYBRID_PCTV: | ||
| 825 | dev->dvb.frontend = dvb_attach(zl10353_attach, | ||
| 826 | &cx88_geniatech_x8000_mt, | ||
| 827 | &dev->core->i2c_adap); | ||
| 828 | if (attach_xc3028(0x61, dev) < 0) | ||
| 829 | return -EINVAL; | ||
| 830 | break; | ||
| 831 | case CX88_BOARD_GENIATECH_X8000_MT: | ||
| 832 | dev->ts_gen_cntrl = 0x00; | ||
| 833 | |||
| 834 | dev->dvb.frontend = dvb_attach(zl10353_attach, | ||
| 835 | &cx88_geniatech_x8000_mt, | ||
| 836 | &dev->core->i2c_adap); | ||
| 837 | if (attach_xc3028(0x61, dev) < 0) | ||
| 838 | return -EINVAL; | ||
| 839 | break; | ||
| 840 | case CX88_BOARD_KWORLD_ATSC_120: | ||
| 841 | dev->dvb.frontend = dvb_attach(s5h1409_attach, | ||
| 842 | &kworld_atsc_120_config, | ||
| 843 | &dev->core->i2c_adap); | ||
| 844 | if (attach_xc3028(0x61, dev) < 0) | ||
| 845 | return -EINVAL; | ||
| 846 | break; | ||
| 661 | default: | 847 | default: |
| 662 | printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", | 848 | printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", |
| 663 | dev->core->name); | 849 | dev->core->name); |
| 664 | break; | 850 | break; |
| 665 | } | 851 | } |
| 666 | if (NULL == dev->dvb.frontend) { | 852 | if (NULL == dev->dvb.frontend) { |
| 667 | printk(KERN_ERR "%s/2: frontend initialization failed\n", dev->core->name); | 853 | printk(KERN_ERR |
| 668 | return -1; | 854 | "%s/2: frontend initialization failed\n", |
| 855 | dev->core->name); | ||
| 856 | return -EINVAL; | ||
| 669 | } | 857 | } |
| 670 | 858 | ||
| 671 | /* Ensure all frontends negotiate bus access */ | 859 | /* Ensure all frontends negotiate bus access */ |
| @@ -675,7 +863,8 @@ static int dvb_register(struct cx8802_dev *dev) | |||
| 675 | cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); | 863 | cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); |
| 676 | 864 | ||
| 677 | /* register everything */ | 865 | /* register everything */ |
| 678 | return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev); | 866 | return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, |
| 867 | &dev->pci->dev, adapter_nr); | ||
| 679 | } | 868 | } |
| 680 | 869 | ||
| 681 | /* ----------------------------------------------------------- */ | 870 | /* ----------------------------------------------------------- */ |
| @@ -685,7 +874,7 @@ static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv) | |||
| 685 | { | 874 | { |
| 686 | struct cx88_core *core = drv->core; | 875 | struct cx88_core *core = drv->core; |
| 687 | int err = 0; | 876 | int err = 0; |
| 688 | dprintk( 1, "%s\n", __FUNCTION__); | 877 | dprintk( 1, "%s\n", __func__); |
| 689 | 878 | ||
| 690 | switch (core->boardnr) { | 879 | switch (core->boardnr) { |
| 691 | case CX88_BOARD_HAUPPAUGE_HVR1300: | 880 | case CX88_BOARD_HAUPPAUGE_HVR1300: |
| @@ -708,7 +897,7 @@ static int cx8802_dvb_advise_release(struct cx8802_driver *drv) | |||
| 708 | { | 897 | { |
| 709 | struct cx88_core *core = drv->core; | 898 | struct cx88_core *core = drv->core; |
| 710 | int err = 0; | 899 | int err = 0; |
| 711 | dprintk( 1, "%s\n", __FUNCTION__); | 900 | dprintk( 1, "%s\n", __func__); |
| 712 | 901 | ||
| 713 | switch (core->boardnr) { | 902 | switch (core->boardnr) { |
| 714 | case CX88_BOARD_HAUPPAUGE_HVR1300: | 903 | case CX88_BOARD_HAUPPAUGE_HVR1300: |
| @@ -726,7 +915,7 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) | |||
| 726 | struct cx8802_dev *dev = drv->core->dvbdev; | 915 | struct cx8802_dev *dev = drv->core->dvbdev; |
| 727 | int err; | 916 | int err; |
| 728 | 917 | ||
| 729 | dprintk( 1, "%s\n", __FUNCTION__); | 918 | dprintk( 1, "%s\n", __func__); |
| 730 | dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", | 919 | dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n", |
| 731 | core->boardnr, | 920 | core->boardnr, |
| 732 | core->name, | 921 | core->name, |
| @@ -744,8 +933,8 @@ static int cx8802_dvb_probe(struct cx8802_driver *drv) | |||
| 744 | 933 | ||
| 745 | /* dvb stuff */ | 934 | /* dvb stuff */ |
| 746 | printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); | 935 | printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name); |
| 747 | videobuf_queue_pci_init(&dev->dvb.dvbq, &dvb_qops, | 936 | videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops, |
| 748 | dev->pci, &dev->slock, | 937 | &dev->pci->dev, &dev->slock, |
| 749 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 938 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 750 | V4L2_FIELD_TOP, | 939 | V4L2_FIELD_TOP, |
| 751 | sizeof(struct cx88_buffer), | 940 | sizeof(struct cx88_buffer), |
| @@ -764,7 +953,8 @@ static int cx8802_dvb_remove(struct cx8802_driver *drv) | |||
| 764 | struct cx8802_dev *dev = drv->core->dvbdev; | 953 | struct cx8802_dev *dev = drv->core->dvbdev; |
| 765 | 954 | ||
| 766 | /* dvb */ | 955 | /* dvb */ |
| 767 | videobuf_dvb_unregister(&dev->dvb); | 956 | if (dev->dvb.frontend) |
| 957 | videobuf_dvb_unregister(&dev->dvb); | ||
| 768 | 958 | ||
| 769 | vp3054_i2c_remove(dev); | 959 | vp3054_i2c_remove(dev); |
| 770 | 960 | ||
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c index 566b26af523e..c6b44732a082 100644 --- a/drivers/media/video/cx88/cx88-i2c.c +++ b/drivers/media/video/cx88/cx88-i2c.c | |||
| @@ -35,11 +35,11 @@ | |||
| 35 | #include "cx88.h" | 35 | #include "cx88.h" |
| 36 | #include <media/v4l2-common.h> | 36 | #include <media/v4l2-common.h> |
| 37 | 37 | ||
| 38 | static unsigned int i2c_debug = 0; | 38 | static unsigned int i2c_debug; |
| 39 | module_param(i2c_debug, int, 0644); | 39 | module_param(i2c_debug, int, 0644); |
| 40 | MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]"); | 40 | MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]"); |
| 41 | 41 | ||
| 42 | static unsigned int i2c_scan = 0; | 42 | static unsigned int i2c_scan; |
| 43 | module_param(i2c_scan, int, 0444); | 43 | module_param(i2c_scan, int, 0444); |
| 44 | MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); | 44 | MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); |
| 45 | 45 | ||
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c index bb0911b4d2f6..53526d997a4e 100644 --- a/drivers/media/video/cx88/cx88-input.c +++ b/drivers/media/video/cx88/cx88-input.c | |||
| @@ -57,7 +57,7 @@ struct cx88_IR { | |||
| 57 | u32 mask_keyup; | 57 | u32 mask_keyup; |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | static int ir_debug = 0; | 60 | static int ir_debug; |
| 61 | module_param(ir_debug, int, 0644); /* debug level [IR] */ | 61 | module_param(ir_debug, int, 0644); /* debug level [IR] */ |
| 62 | MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); | 62 | MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); |
| 63 | 63 | ||
| @@ -258,6 +258,13 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | |||
| 258 | ir->mask_keyup = 0x80; | 258 | ir->mask_keyup = 0x80; |
| 259 | ir->polling = 1; /* ms */ | 259 | ir->polling = 1; /* ms */ |
| 260 | break; | 260 | break; |
| 261 | case CX88_BOARD_PROLINK_PV_8000GT: | ||
| 262 | ir_codes = ir_codes_pixelview_new; | ||
| 263 | ir->gpio_addr = MO_GP1_IO; | ||
| 264 | ir->mask_keycode = 0x3f; | ||
| 265 | ir->mask_keyup = 0x80; | ||
| 266 | ir->polling = 1; /* ms */ | ||
| 267 | break; | ||
| 261 | case CX88_BOARD_KWORLD_LTV883: | 268 | case CX88_BOARD_KWORLD_LTV883: |
| 262 | ir_codes = ir_codes_pixelview; | 269 | ir_codes = ir_codes_pixelview; |
| 263 | ir->gpio_addr = MO_GP1_IO; | 270 | ir->gpio_addr = MO_GP1_IO; |
| @@ -310,6 +317,12 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci) | |||
| 310 | ir_type = IR_TYPE_RC5; | 317 | ir_type = IR_TYPE_RC5; |
| 311 | ir->sampling = 1; | 318 | ir->sampling = 1; |
| 312 | break; | 319 | break; |
| 320 | case CX88_BOARD_POWERCOLOR_REAL_ANGEL: | ||
| 321 | ir_codes = ir_codes_powercolor_real_angel; | ||
| 322 | ir->gpio_addr = MO_GP2_IO; | ||
| 323 | ir->mask_keycode = 0x7e; | ||
| 324 | ir->polling = 100; /* ms */ | ||
| 325 | break; | ||
| 313 | } | 326 | } |
| 314 | 327 | ||
| 315 | if (NULL == ir_codes) { | 328 | if (NULL == ir_codes) { |
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c index e357f415db06..a6b061c2644a 100644 --- a/drivers/media/video/cx88/cx88-mpeg.c +++ b/drivers/media/video/cx88/cx88-mpeg.c | |||
| @@ -39,7 +39,7 @@ MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>"); | |||
| 39 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); | 39 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
| 40 | MODULE_LICENSE("GPL"); | 40 | MODULE_LICENSE("GPL"); |
| 41 | 41 | ||
| 42 | static unsigned int debug = 0; | 42 | static unsigned int debug; |
| 43 | module_param(debug,int,0644); | 43 | module_param(debug,int,0644); |
| 44 | MODULE_PARM_DESC(debug,"enable debug messages [mpeg]"); | 44 | MODULE_PARM_DESC(debug,"enable debug messages [mpeg]"); |
| 45 | 45 | ||
| @@ -146,7 +146,7 @@ static int cx8802_start_dma(struct cx8802_dev *dev, | |||
| 146 | cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */ | 146 | cx_write(TS_GEN_CNTRL, 0x06); /* punctured clock TS & posedge driven */ |
| 147 | udelay(100); | 147 | udelay(100); |
| 148 | } else { | 148 | } else { |
| 149 | printk( "%s() Failed. Unsupported value in .mpeg (0x%08x)\n", __FUNCTION__, | 149 | printk( "%s() Failed. Unsupported value in .mpeg (0x%08x)\n", __func__, |
| 150 | core->board.mpeg ); | 150 | core->board.mpeg ); |
| 151 | return -EINVAL; | 151 | return -EINVAL; |
| 152 | } | 152 | } |
| @@ -247,7 +247,7 @@ int cx8802_buf_prepare(struct videobuf_queue *q, struct cx8802_dev *dev, | |||
| 247 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); | 247 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); |
| 248 | int rc; | 248 | int rc; |
| 249 | 249 | ||
| 250 | dprintk(1, "%s: %p\n", __FUNCTION__, buf); | 250 | dprintk(1, "%s: %p\n", __func__, buf); |
| 251 | if (0 != buf->vb.baddr && buf->vb.bsize < size) | 251 | if (0 != buf->vb.baddr && buf->vb.bsize < size) |
| 252 | return -EINVAL; | 252 | return -EINVAL; |
| 253 | 253 | ||
| @@ -289,7 +289,7 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) | |||
| 289 | buf->count = cx88q->count++; | 289 | buf->count = cx88q->count++; |
| 290 | mod_timer(&cx88q->timeout, jiffies+BUFFER_TIMEOUT); | 290 | mod_timer(&cx88q->timeout, jiffies+BUFFER_TIMEOUT); |
| 291 | dprintk(1,"[%p/%d] %s - first active\n", | 291 | dprintk(1,"[%p/%d] %s - first active\n", |
| 292 | buf, buf->vb.i, __FUNCTION__); | 292 | buf, buf->vb.i, __func__); |
| 293 | 293 | ||
| 294 | } else { | 294 | } else { |
| 295 | dprintk( 1, "queue is not empty - append to active\n" ); | 295 | dprintk( 1, "queue is not empty - append to active\n" ); |
| @@ -299,7 +299,7 @@ void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf) | |||
| 299 | buf->count = cx88q->count++; | 299 | buf->count = cx88q->count++; |
| 300 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); | 300 | prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma); |
| 301 | dprintk( 1, "[%p/%d] %s - append to active\n", | 301 | dprintk( 1, "[%p/%d] %s - append to active\n", |
| 302 | buf, buf->vb.i, __FUNCTION__); | 302 | buf, buf->vb.i, __func__); |
| 303 | } | 303 | } |
| 304 | } | 304 | } |
| 305 | 305 | ||
| @@ -342,7 +342,7 @@ static void cx8802_timeout(unsigned long data) | |||
| 342 | { | 342 | { |
| 343 | struct cx8802_dev *dev = (struct cx8802_dev*)data; | 343 | struct cx8802_dev *dev = (struct cx8802_dev*)data; |
| 344 | 344 | ||
| 345 | dprintk(1, "%s\n",__FUNCTION__); | 345 | dprintk(1, "%s\n",__func__); |
| 346 | 346 | ||
| 347 | if (debug) | 347 | if (debug) |
| 348 | cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH28]); | 348 | cx88_sram_channel_dump(dev->core, &cx88_sram_channels[SRAM_CH28]); |
| @@ -613,6 +613,8 @@ static int cx8802_request_acquire(struct cx8802_driver *drv) | |||
| 613 | core->active_type_id != drv->type_id) | 613 | core->active_type_id != drv->type_id) |
| 614 | return -EBUSY; | 614 | return -EBUSY; |
| 615 | 615 | ||
| 616 | core->input = CX88_VMUX_DVB; | ||
| 617 | |||
| 616 | if (drv->advise_acquire) | 618 | if (drv->advise_acquire) |
| 617 | { | 619 | { |
| 618 | mutex_lock(&drv->core->lock); | 620 | mutex_lock(&drv->core->lock); |
| @@ -623,7 +625,7 @@ static int cx8802_request_acquire(struct cx8802_driver *drv) | |||
| 623 | } | 625 | } |
| 624 | mutex_unlock(&drv->core->lock); | 626 | mutex_unlock(&drv->core->lock); |
| 625 | 627 | ||
| 626 | mpeg_dbg(1,"%s() Post acquire GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO)); | 628 | mpeg_dbg(1,"%s() Post acquire GPIO=%x\n", __func__, cx_read(MO_GP0_IO)); |
| 627 | } | 629 | } |
| 628 | 630 | ||
| 629 | return 0; | 631 | return 0; |
| @@ -639,7 +641,7 @@ static int cx8802_request_release(struct cx8802_driver *drv) | |||
| 639 | { | 641 | { |
| 640 | drv->advise_release(drv); | 642 | drv->advise_release(drv); |
| 641 | core->active_type_id = CX88_BOARD_NONE; | 643 | core->active_type_id = CX88_BOARD_NONE; |
| 642 | mpeg_dbg(1,"%s() Post release GPIO=%x\n", __FUNCTION__, cx_read(MO_GP0_IO)); | 644 | mpeg_dbg(1,"%s() Post release GPIO=%x\n", __func__, cx_read(MO_GP0_IO)); |
| 643 | } | 645 | } |
| 644 | mutex_unlock(&drv->core->lock); | 646 | mutex_unlock(&drv->core->lock); |
| 645 | 647 | ||
| @@ -813,7 +815,7 @@ static void __devexit cx8802_remove(struct pci_dev *pci_dev) | |||
| 813 | 815 | ||
| 814 | dev = pci_get_drvdata(pci_dev); | 816 | dev = pci_get_drvdata(pci_dev); |
| 815 | 817 | ||
| 816 | dprintk( 1, "%s\n", __FUNCTION__); | 818 | dprintk( 1, "%s\n", __func__); |
| 817 | 819 | ||
| 818 | if (!list_empty(&dev->drvlist)) { | 820 | if (!list_empty(&dev->drvlist)) { |
| 819 | struct cx8802_driver *drv, *tmp; | 821 | struct cx8802_driver *drv, *tmp; |
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c index 76e5c78d8ae4..3a1977f41e27 100644 --- a/drivers/media/video/cx88/cx88-tvaudio.c +++ b/drivers/media/video/cx88/cx88-tvaudio.c | |||
| @@ -53,15 +53,15 @@ | |||
| 53 | 53 | ||
| 54 | #include "cx88.h" | 54 | #include "cx88.h" |
| 55 | 55 | ||
| 56 | static unsigned int audio_debug = 0; | 56 | static unsigned int audio_debug; |
| 57 | module_param(audio_debug, int, 0644); | 57 | module_param(audio_debug, int, 0644); |
| 58 | MODULE_PARM_DESC(audio_debug, "enable debug messages [audio]"); | 58 | MODULE_PARM_DESC(audio_debug, "enable debug messages [audio]"); |
| 59 | 59 | ||
| 60 | static unsigned int always_analog = 0; | 60 | static unsigned int always_analog; |
| 61 | module_param(always_analog,int,0644); | 61 | module_param(always_analog,int,0644); |
| 62 | MODULE_PARM_DESC(always_analog,"force analog audio out"); | 62 | MODULE_PARM_DESC(always_analog,"force analog audio out"); |
| 63 | 63 | ||
| 64 | static unsigned int radio_deemphasis = 0; | 64 | static unsigned int radio_deemphasis; |
| 65 | module_param(radio_deemphasis,int,0644); | 65 | module_param(radio_deemphasis,int,0644); |
| 66 | MODULE_PARM_DESC(radio_deemphasis, "Radio deemphasis time constant, " | 66 | MODULE_PARM_DESC(radio_deemphasis, "Radio deemphasis time constant, " |
| 67 | "0=None, 1=50us (elsewhere), 2=75us (USA)"); | 67 | "0=None, 1=50us (elsewhere), 2=75us (USA)"); |
| @@ -265,12 +265,12 @@ static void set_audio_standard_BTSC(struct cx88_core *core, unsigned int sap, | |||
| 265 | mode |= EN_FMRADIO_EN_RDS; | 265 | mode |= EN_FMRADIO_EN_RDS; |
| 266 | 266 | ||
| 267 | if (sap) { | 267 | if (sap) { |
| 268 | dprintk("%s SAP (status: unknown)\n", __FUNCTION__); | 268 | dprintk("%s SAP (status: unknown)\n", __func__); |
| 269 | set_audio_start(core, SEL_SAP); | 269 | set_audio_start(core, SEL_SAP); |
| 270 | set_audio_registers(core, btsc_sap); | 270 | set_audio_registers(core, btsc_sap); |
| 271 | set_audio_finish(core, mode); | 271 | set_audio_finish(core, mode); |
| 272 | } else { | 272 | } else { |
| 273 | dprintk("%s (status: known-good)\n", __FUNCTION__); | 273 | dprintk("%s (status: known-good)\n", __func__); |
| 274 | set_audio_start(core, SEL_BTSC); | 274 | set_audio_start(core, SEL_BTSC); |
| 275 | set_audio_registers(core, btsc); | 275 | set_audio_registers(core, btsc); |
| 276 | set_audio_finish(core, mode); | 276 | set_audio_finish(core, mode); |
| @@ -351,16 +351,16 @@ static void set_audio_standard_NICAM(struct cx88_core *core, u32 mode) | |||
| 351 | set_audio_start(core,SEL_NICAM); | 351 | set_audio_start(core,SEL_NICAM); |
| 352 | switch (core->tvaudio) { | 352 | switch (core->tvaudio) { |
| 353 | case WW_L: | 353 | case WW_L: |
| 354 | dprintk("%s SECAM-L NICAM (status: devel)\n", __FUNCTION__); | 354 | dprintk("%s SECAM-L NICAM (status: devel)\n", __func__); |
| 355 | set_audio_registers(core, nicam_l); | 355 | set_audio_registers(core, nicam_l); |
| 356 | break; | 356 | break; |
| 357 | case WW_I: | 357 | case WW_I: |
| 358 | dprintk("%s PAL-I NICAM (status: known-good)\n", __FUNCTION__); | 358 | dprintk("%s PAL-I NICAM (status: known-good)\n", __func__); |
| 359 | set_audio_registers(core, nicam_bgdki_common); | 359 | set_audio_registers(core, nicam_bgdki_common); |
| 360 | set_audio_registers(core, nicam_i); | 360 | set_audio_registers(core, nicam_i); |
| 361 | break; | 361 | break; |
| 362 | default: | 362 | default: |
| 363 | dprintk("%s PAL-BGDK NICAM (status: known-good)\n", __FUNCTION__); | 363 | dprintk("%s PAL-BGDK NICAM (status: known-good)\n", __func__); |
| 364 | set_audio_registers(core, nicam_bgdki_common); | 364 | set_audio_registers(core, nicam_bgdki_common); |
| 365 | set_audio_registers(core, nicam_default); | 365 | set_audio_registers(core, nicam_default); |
| 366 | break; | 366 | break; |
| @@ -600,28 +600,28 @@ static void set_audio_standard_A2(struct cx88_core *core, u32 mode) | |||
| 600 | set_audio_start(core, SEL_A2); | 600 | set_audio_start(core, SEL_A2); |
| 601 | switch (core->tvaudio) { | 601 | switch (core->tvaudio) { |
| 602 | case WW_BG: | 602 | case WW_BG: |
| 603 | dprintk("%s PAL-BG A1/2 (status: known-good)\n", __FUNCTION__); | 603 | dprintk("%s PAL-BG A1/2 (status: known-good)\n", __func__); |
| 604 | set_audio_registers(core, a2_bgdk_common); | 604 | set_audio_registers(core, a2_bgdk_common); |
| 605 | set_audio_registers(core, a2_bg); | 605 | set_audio_registers(core, a2_bg); |
| 606 | set_audio_registers(core, a2_deemph50); | 606 | set_audio_registers(core, a2_deemph50); |
| 607 | break; | 607 | break; |
| 608 | case WW_DK: | 608 | case WW_DK: |
| 609 | dprintk("%s PAL-DK A1/2 (status: known-good)\n", __FUNCTION__); | 609 | dprintk("%s PAL-DK A1/2 (status: known-good)\n", __func__); |
| 610 | set_audio_registers(core, a2_bgdk_common); | 610 | set_audio_registers(core, a2_bgdk_common); |
| 611 | set_audio_registers(core, a2_dk); | 611 | set_audio_registers(core, a2_dk); |
| 612 | set_audio_registers(core, a2_deemph50); | 612 | set_audio_registers(core, a2_deemph50); |
| 613 | break; | 613 | break; |
| 614 | case WW_I: | 614 | case WW_I: |
| 615 | dprintk("%s PAL-I A1 (status: known-good)\n", __FUNCTION__); | 615 | dprintk("%s PAL-I A1 (status: known-good)\n", __func__); |
| 616 | set_audio_registers(core, a1_i); | 616 | set_audio_registers(core, a1_i); |
| 617 | set_audio_registers(core, a2_deemph50); | 617 | set_audio_registers(core, a2_deemph50); |
| 618 | break; | 618 | break; |
| 619 | case WW_L: | 619 | case WW_L: |
| 620 | dprintk("%s AM-L (status: devel)\n", __FUNCTION__); | 620 | dprintk("%s AM-L (status: devel)\n", __func__); |
| 621 | set_audio_registers(core, am_l); | 621 | set_audio_registers(core, am_l); |
| 622 | break; | 622 | break; |
| 623 | default: | 623 | default: |
| 624 | dprintk("%s Warning: wrong value\n", __FUNCTION__); | 624 | dprintk("%s Warning: wrong value\n", __func__); |
| 625 | return; | 625 | return; |
| 626 | break; | 626 | break; |
| 627 | }; | 627 | }; |
| @@ -637,7 +637,7 @@ static void set_audio_standard_EIAJ(struct cx88_core *core) | |||
| 637 | 637 | ||
| 638 | { /* end of list */ }, | 638 | { /* end of list */ }, |
| 639 | }; | 639 | }; |
| 640 | dprintk("%s (status: unknown)\n", __FUNCTION__); | 640 | dprintk("%s (status: unknown)\n", __func__); |
| 641 | 641 | ||
| 642 | set_audio_start(core, SEL_EIAJ); | 642 | set_audio_start(core, SEL_EIAJ); |
| 643 | set_audio_registers(core, eiaj); | 643 | set_audio_registers(core, eiaj); |
| @@ -691,7 +691,7 @@ static void set_audio_standard_FM(struct cx88_core *core, | |||
| 691 | { /* end of list */ }, | 691 | { /* end of list */ }, |
| 692 | }; | 692 | }; |
| 693 | 693 | ||
| 694 | dprintk("%s (status: unknown)\n", __FUNCTION__); | 694 | dprintk("%s (status: unknown)\n", __func__); |
| 695 | set_audio_start(core, SEL_FMRADIO); | 695 | set_audio_start(core, SEL_FMRADIO); |
| 696 | 696 | ||
| 697 | switch (deemph) { | 697 | switch (deemph) { |
diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c index d96ecfcf393a..0943060682bc 100644 --- a/drivers/media/video/cx88/cx88-vbi.c +++ b/drivers/media/video/cx88/cx88-vbi.c | |||
| @@ -11,7 +11,7 @@ static unsigned int vbibufs = 4; | |||
| 11 | module_param(vbibufs,int,0644); | 11 | module_param(vbibufs,int,0644); |
| 12 | MODULE_PARM_DESC(vbibufs,"number of vbi buffers, range 2-32"); | 12 | MODULE_PARM_DESC(vbibufs,"number of vbi buffers, range 2-32"); |
| 13 | 13 | ||
| 14 | static unsigned int vbi_debug = 0; | 14 | static unsigned int vbi_debug; |
| 15 | module_param(vbi_debug,int,0644); | 15 | module_param(vbi_debug,int,0644); |
| 16 | MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]"); | 16 | MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]"); |
| 17 | 17 | ||
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index 227179620d13..eea23f95edb7 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
| @@ -63,11 +63,11 @@ MODULE_PARM_DESC(video_nr,"video device numbers"); | |||
| 63 | MODULE_PARM_DESC(vbi_nr,"vbi device numbers"); | 63 | MODULE_PARM_DESC(vbi_nr,"vbi device numbers"); |
| 64 | MODULE_PARM_DESC(radio_nr,"radio device numbers"); | 64 | MODULE_PARM_DESC(radio_nr,"radio device numbers"); |
| 65 | 65 | ||
| 66 | static unsigned int video_debug = 0; | 66 | static unsigned int video_debug; |
| 67 | module_param(video_debug,int,0644); | 67 | module_param(video_debug,int,0644); |
| 68 | MODULE_PARM_DESC(video_debug,"enable debug messages [video]"); | 68 | MODULE_PARM_DESC(video_debug,"enable debug messages [video]"); |
| 69 | 69 | ||
| 70 | static unsigned int irq_debug = 0; | 70 | static unsigned int irq_debug; |
| 71 | module_param(irq_debug,int,0644); | 71 | module_param(irq_debug,int,0644); |
| 72 | MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]"); | 72 | MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]"); |
| 73 | 73 | ||
| @@ -228,6 +228,30 @@ static struct cx88_ctrl cx8800_ctls[] = { | |||
| 228 | .mask = 0x00ff, | 228 | .mask = 0x00ff, |
| 229 | .shift = 0, | 229 | .shift = 0, |
| 230 | },{ | 230 | },{ |
| 231 | .v = { | ||
| 232 | .id = V4L2_CID_CHROMA_AGC, | ||
| 233 | .name = "Chroma AGC", | ||
| 234 | .minimum = 0, | ||
| 235 | .maximum = 1, | ||
| 236 | .default_value = 0x1, | ||
| 237 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
| 238 | }, | ||
| 239 | .reg = MO_INPUT_FORMAT, | ||
| 240 | .mask = 1 << 10, | ||
| 241 | .shift = 10, | ||
| 242 | }, { | ||
| 243 | .v = { | ||
| 244 | .id = V4L2_CID_COLOR_KILLER, | ||
| 245 | .name = "Color killer", | ||
| 246 | .minimum = 0, | ||
| 247 | .maximum = 1, | ||
| 248 | .default_value = 0x1, | ||
| 249 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
| 250 | }, | ||
| 251 | .reg = MO_INPUT_FORMAT, | ||
| 252 | .mask = 1 << 9, | ||
| 253 | .shift = 9, | ||
| 254 | }, { | ||
| 231 | /* --- audio --- */ | 255 | /* --- audio --- */ |
| 232 | .v = { | 256 | .v = { |
| 233 | .id = V4L2_CID_AUDIO_MUTE, | 257 | .id = V4L2_CID_AUDIO_MUTE, |
| @@ -282,6 +306,8 @@ const u32 cx88_user_ctrls[] = { | |||
| 282 | V4L2_CID_AUDIO_VOLUME, | 306 | V4L2_CID_AUDIO_VOLUME, |
| 283 | V4L2_CID_AUDIO_BALANCE, | 307 | V4L2_CID_AUDIO_BALANCE, |
| 284 | V4L2_CID_AUDIO_MUTE, | 308 | V4L2_CID_AUDIO_MUTE, |
| 309 | V4L2_CID_CHROMA_AGC, | ||
| 310 | V4L2_CID_COLOR_KILLER, | ||
| 285 | 0 | 311 | 0 |
| 286 | }; | 312 | }; |
| 287 | EXPORT_SYMBOL(cx88_user_ctrls); | 313 | EXPORT_SYMBOL(cx88_user_ctrls); |
| @@ -291,7 +317,7 @@ static const u32 *ctrl_classes[] = { | |||
| 291 | NULL | 317 | NULL |
| 292 | }; | 318 | }; |
| 293 | 319 | ||
| 294 | int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl) | 320 | int cx8800_ctrl_query(struct cx88_core *core, struct v4l2_queryctrl *qctrl) |
| 295 | { | 321 | { |
| 296 | int i; | 322 | int i; |
| 297 | 323 | ||
| @@ -306,6 +332,11 @@ int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl) | |||
| 306 | return 0; | 332 | return 0; |
| 307 | } | 333 | } |
| 308 | *qctrl = cx8800_ctls[i].v; | 334 | *qctrl = cx8800_ctls[i].v; |
| 335 | /* Report chroma AGC as inactive when SECAM is selected */ | ||
| 336 | if (cx8800_ctls[i].v.id == V4L2_CID_CHROMA_AGC && | ||
| 337 | core->tvnorm & V4L2_STD_SECAM) | ||
| 338 | qctrl->flags |= V4L2_CTRL_FLAG_INACTIVE; | ||
| 339 | |||
| 309 | return 0; | 340 | return 0; |
| 310 | } | 341 | } |
| 311 | EXPORT_SYMBOL(cx8800_ctrl_query); | 342 | EXPORT_SYMBOL(cx8800_ctrl_query); |
| @@ -776,14 +807,14 @@ static int video_open(struct inode *inode, struct file *file) | |||
| 776 | fh->height = 240; | 807 | fh->height = 240; |
| 777 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); | 808 | fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); |
| 778 | 809 | ||
| 779 | videobuf_queue_pci_init(&fh->vidq, &cx8800_video_qops, | 810 | videobuf_queue_sg_init(&fh->vidq, &cx8800_video_qops, |
| 780 | dev->pci, &dev->slock, | 811 | &dev->pci->dev, &dev->slock, |
| 781 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 812 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 782 | V4L2_FIELD_INTERLACED, | 813 | V4L2_FIELD_INTERLACED, |
| 783 | sizeof(struct cx88_buffer), | 814 | sizeof(struct cx88_buffer), |
| 784 | fh); | 815 | fh); |
| 785 | videobuf_queue_pci_init(&fh->vbiq, &cx8800_vbi_qops, | 816 | videobuf_queue_sg_init(&fh->vbiq, &cx8800_vbi_qops, |
| 786 | dev->pci, &dev->slock, | 817 | &dev->pci->dev, &dev->slock, |
| 787 | V4L2_BUF_TYPE_VBI_CAPTURE, | 818 | V4L2_BUF_TYPE_VBI_CAPTURE, |
| 788 | V4L2_FIELD_SEQ_TB, | 819 | V4L2_FIELD_SEQ_TB, |
| 789 | sizeof(struct cx88_buffer), | 820 | sizeof(struct cx88_buffer), |
| @@ -976,6 +1007,12 @@ int cx88_set_control(struct cx88_core *core, struct v4l2_control *ctl) | |||
| 976 | } | 1007 | } |
| 977 | mask=0xffff; | 1008 | mask=0xffff; |
| 978 | break; | 1009 | break; |
| 1010 | case V4L2_CID_CHROMA_AGC: | ||
| 1011 | /* Do not allow chroma AGC to be enabled for SECAM */ | ||
| 1012 | value = ((ctl->value - c->off) << c->shift) & c->mask; | ||
| 1013 | if (core->tvnorm & V4L2_STD_SECAM && value) | ||
| 1014 | return -EINVAL; | ||
| 1015 | break; | ||
| 979 | default: | 1016 | default: |
| 980 | value = ((ctl->value - c->off) << c->shift) & c->mask; | 1017 | value = ((ctl->value - c->off) << c->shift) & c->mask; |
| 981 | break; | 1018 | break; |
| @@ -1268,10 +1305,12 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int i) | |||
| 1268 | static int vidioc_queryctrl (struct file *file, void *priv, | 1305 | static int vidioc_queryctrl (struct file *file, void *priv, |
| 1269 | struct v4l2_queryctrl *qctrl) | 1306 | struct v4l2_queryctrl *qctrl) |
| 1270 | { | 1307 | { |
| 1308 | struct cx88_core *core = ((struct cx8800_fh *)priv)->dev->core; | ||
| 1309 | |||
| 1271 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); | 1310 | qctrl->id = v4l2_ctrl_next(ctrl_classes, qctrl->id); |
| 1272 | if (unlikely(qctrl->id == 0)) | 1311 | if (unlikely(qctrl->id == 0)) |
| 1273 | return -EINVAL; | 1312 | return -EINVAL; |
| 1274 | return cx8800_ctrl_query(qctrl); | 1313 | return cx8800_ctrl_query(core, qctrl); |
| 1275 | } | 1314 | } |
| 1276 | 1315 | ||
| 1277 | static int vidioc_g_ctrl (struct file *file, void *priv, | 1316 | static int vidioc_g_ctrl (struct file *file, void *priv, |
| @@ -1832,8 +1871,11 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, | |||
| 1832 | 1871 | ||
| 1833 | switch (core->boardnr) { | 1872 | switch (core->boardnr) { |
| 1834 | case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: | 1873 | case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: |
| 1835 | request_module("ir-kbd-i2c"); | 1874 | case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: |
| 1836 | request_module("rtc-isl1208"); | 1875 | request_module("rtc-isl1208"); |
| 1876 | /* break intentionally omitted */ | ||
| 1877 | case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: | ||
| 1878 | request_module("ir-kbd-i2c"); | ||
| 1837 | } | 1879 | } |
| 1838 | 1880 | ||
| 1839 | /* register v4l devices */ | 1881 | /* register v4l devices */ |
| @@ -1917,6 +1959,9 @@ static void __devexit cx8800_finidev(struct pci_dev *pci_dev) | |||
| 1917 | core->kthread = NULL; | 1959 | core->kthread = NULL; |
| 1918 | } | 1960 | } |
| 1919 | 1961 | ||
| 1962 | if (core->ir) | ||
| 1963 | cx88_ir_stop(core, core->ir); | ||
| 1964 | |||
| 1920 | cx88_shutdown(core); /* FIXME */ | 1965 | cx88_shutdown(core); /* FIXME */ |
| 1921 | pci_disable_device(pci_dev); | 1966 | pci_disable_device(pci_dev); |
| 1922 | 1967 | ||
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h index 37e6d2e4002f..14ac173f4071 100644 --- a/drivers/media/video/cx88/cx88.h +++ b/drivers/media/video/cx88/cx88.h | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | 37 | ||
| 38 | #include "btcx-risc.h" | 38 | #include "btcx-risc.h" |
| 39 | #include "cx88-reg.h" | 39 | #include "cx88-reg.h" |
| 40 | #include "tuner-xc2028.h" | ||
| 40 | 41 | ||
| 41 | #include <linux/version.h> | 42 | #include <linux/version.h> |
| 42 | #include <linux/mutex.h> | 43 | #include <linux/mutex.h> |
| @@ -211,6 +212,15 @@ extern struct sram_channel cx88_sram_channels[]; | |||
| 211 | #define CX88_BOARD_HAUPPAUGE_HVR1300 56 | 212 | #define CX88_BOARD_HAUPPAUGE_HVR1300 56 |
| 212 | #define CX88_BOARD_ADSTECH_PTV_390 57 | 213 | #define CX88_BOARD_ADSTECH_PTV_390 57 |
| 213 | #define CX88_BOARD_PINNACLE_PCTV_HD_800i 58 | 214 | #define CX88_BOARD_PINNACLE_PCTV_HD_800i 58 |
| 215 | #define CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO 59 | ||
| 216 | #define CX88_BOARD_PINNACLE_HYBRID_PCTV 60 | ||
| 217 | #define CX88_BOARD_WINFAST_TV2000_XP_GLOBAL 61 | ||
| 218 | #define CX88_BOARD_POWERCOLOR_REAL_ANGEL 62 | ||
| 219 | #define CX88_BOARD_GENIATECH_X8000_MT 63 | ||
| 220 | #define CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO 64 | ||
| 221 | #define CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD 65 | ||
| 222 | #define CX88_BOARD_PROLINK_PV_8000GT 66 | ||
| 223 | #define CX88_BOARD_KWORLD_ATSC_120 67 | ||
| 214 | 224 | ||
| 215 | enum cx88_itype { | 225 | enum cx88_itype { |
| 216 | CX88_VMUX_COMPOSITE1 = 1, | 226 | CX88_VMUX_COMPOSITE1 = 1, |
| @@ -595,6 +605,7 @@ extern int cx88_tuner_callback(void *dev, int command, int arg); | |||
| 595 | extern int cx88_get_resources(const struct cx88_core *core, | 605 | extern int cx88_get_resources(const struct cx88_core *core, |
| 596 | struct pci_dev *pci); | 606 | struct pci_dev *pci); |
| 597 | extern struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr); | 607 | extern struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr); |
| 608 | extern void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl); | ||
| 598 | 609 | ||
| 599 | /* ----------------------------------------------------------- */ | 610 | /* ----------------------------------------------------------- */ |
| 600 | /* cx88-tvaudio.c */ | 611 | /* cx88-tvaudio.c */ |
| @@ -640,7 +651,8 @@ void cx8802_cancel_buffers(struct cx8802_dev *dev); | |||
| 640 | /* ----------------------------------------------------------- */ | 651 | /* ----------------------------------------------------------- */ |
| 641 | /* cx88-video.c*/ | 652 | /* cx88-video.c*/ |
| 642 | extern const u32 cx88_user_ctrls[]; | 653 | extern const u32 cx88_user_ctrls[]; |
| 643 | extern int cx8800_ctrl_query(struct v4l2_queryctrl *qctrl); | 654 | extern int cx8800_ctrl_query(struct cx88_core *core, |
| 655 | struct v4l2_queryctrl *qctrl); | ||
| 644 | int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i); | 656 | int cx88_enum_input (struct cx88_core *core,struct v4l2_input *i); |
| 645 | int cx88_set_freq (struct cx88_core *core,struct v4l2_frequency *f); | 657 | int cx88_set_freq (struct cx88_core *core,struct v4l2_frequency *f); |
| 646 | int cx88_get_control(struct cx88_core *core, struct v4l2_control *ctl); | 658 | int cx88_get_control(struct cx88_core *core, struct v4l2_control *ctl); |
diff --git a/drivers/media/video/dabfirmware.h b/drivers/media/video/dabfirmware.h index d14d803566a3..cbd92635993d 100644 --- a/drivers/media/video/dabfirmware.h +++ b/drivers/media/video/dabfirmware.h | |||
| @@ -1,5 +1,12 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * dabdata.h - dab usb firmware and bitstream data | 2 | * dabdata.h - dab usb firmware and bitstream data |
| 3 | * | ||
| 4 | * Copyright (C) 1999 BayCom GmbH | ||
| 5 | * | ||
| 6 | * Redistribution and use in source and binary forms, with or without | ||
| 7 | * modification, are permitted provided that redistributions of source | ||
| 8 | * code retain the above copyright notice and this comment without | ||
| 9 | * modification. | ||
| 3 | */ | 10 | */ |
| 4 | 11 | ||
| 5 | static INTEL_HEX_RECORD firmware[] = { | 12 | static INTEL_HEX_RECORD firmware[] = { |
diff --git a/drivers/media/video/dabusb.c b/drivers/media/video/dabusb.c index a5731f90be0f..8d1f8ee2a533 100644 --- a/drivers/media/video/dabusb.c +++ b/drivers/media/video/dabusb.c | |||
| @@ -205,7 +205,7 @@ static void dabusb_iso_complete (struct urb *purb) | |||
| 205 | /*-------------------------------------------------------------------*/ | 205 | /*-------------------------------------------------------------------*/ |
| 206 | static int dabusb_alloc_buffers (pdabusb_t s) | 206 | static int dabusb_alloc_buffers (pdabusb_t s) |
| 207 | { | 207 | { |
| 208 | int buffers = 0; | 208 | int transfer_len = 0; |
| 209 | pbuff_t b; | 209 | pbuff_t b; |
| 210 | unsigned int pipe = usb_rcvisocpipe (s->usbdev, _DABUSB_ISOPIPE); | 210 | unsigned int pipe = usb_rcvisocpipe (s->usbdev, _DABUSB_ISOPIPE); |
| 211 | int pipesize = usb_maxpacket (s->usbdev, pipe, usb_pipeout (pipe)); | 211 | int pipesize = usb_maxpacket (s->usbdev, pipe, usb_pipeout (pipe)); |
| @@ -216,7 +216,7 @@ static int dabusb_alloc_buffers (pdabusb_t s) | |||
| 216 | dbg("dabusb_alloc_buffers pipesize:%d packets:%d transfer_buffer_len:%d", | 216 | dbg("dabusb_alloc_buffers pipesize:%d packets:%d transfer_buffer_len:%d", |
| 217 | pipesize, packets, transfer_buffer_length); | 217 | pipesize, packets, transfer_buffer_length); |
| 218 | 218 | ||
| 219 | while (buffers < (s->total_buffer_size << 10)) { | 219 | while (transfer_len < (s->total_buffer_size << 10)) { |
| 220 | b = kzalloc(sizeof (buff_t), GFP_KERNEL); | 220 | b = kzalloc(sizeof (buff_t), GFP_KERNEL); |
| 221 | if (!b) { | 221 | if (!b) { |
| 222 | err("kzalloc(sizeof(buff_t))==NULL"); | 222 | err("kzalloc(sizeof(buff_t))==NULL"); |
| @@ -251,10 +251,10 @@ static int dabusb_alloc_buffers (pdabusb_t s) | |||
| 251 | b->purb->iso_frame_desc[i].length = pipesize; | 251 | b->purb->iso_frame_desc[i].length = pipesize; |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | buffers += transfer_buffer_length; | 254 | transfer_len += transfer_buffer_length; |
| 255 | list_add_tail (&b->buff_list, &s->free_buff_list); | 255 | list_add_tail (&b->buff_list, &s->free_buff_list); |
| 256 | } | 256 | } |
| 257 | s->got_mem = buffers; | 257 | s->got_mem = transfer_len; |
| 258 | 258 | ||
| 259 | return 0; | 259 | return 0; |
| 260 | 260 | ||
diff --git a/drivers/media/video/dpc7146.c b/drivers/media/video/dpc7146.c index 9ceb6b2f3949..88d6df71d051 100644 --- a/drivers/media/video/dpc7146.c +++ b/drivers/media/video/dpc7146.c | |||
| @@ -54,11 +54,11 @@ | |||
| 54 | 54 | ||
| 55 | #define DPC_BOARD_CAN_DO_VBI(dev) (dev->revision != 0) | 55 | #define DPC_BOARD_CAN_DO_VBI(dev) (dev->revision != 0) |
| 56 | 56 | ||
| 57 | static int debug = 0; | 57 | static int debug; |
| 58 | module_param(debug, int, 0); | 58 | module_param(debug, int, 0); |
| 59 | MODULE_PARM_DESC(debug, "debug verbosity"); | 59 | MODULE_PARM_DESC(debug, "debug verbosity"); |
| 60 | 60 | ||
| 61 | static int dpc_num = 0; | 61 | static int dpc_num; |
| 62 | 62 | ||
| 63 | #define DPC_INPUTS 2 | 63 | #define DPC_INPUTS 2 |
| 64 | static struct v4l2_input dpc_inputs[DPC_INPUTS] = { | 64 | static struct v4l2_input dpc_inputs[DPC_INPUTS] = { |
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig index 0f7a0bd86ff4..9caffed2b6b8 100644 --- a/drivers/media/video/em28xx/Kconfig +++ b/drivers/media/video/em28xx/Kconfig | |||
| @@ -1,11 +1,13 @@ | |||
| 1 | config VIDEO_EM28XX | 1 | config VIDEO_EM28XX |
| 2 | tristate "Empia EM2800/2820/2840 USB video capture support" | 2 | tristate "Empia EM28xx USB video capture support" |
| 3 | depends on VIDEO_DEV && I2C && INPUT | 3 | depends on VIDEO_DEV && I2C && INPUT |
| 4 | select VIDEO_TUNER | 4 | select VIDEO_TUNER |
| 5 | select VIDEO_TVEEPROM | 5 | select VIDEO_TVEEPROM |
| 6 | select VIDEO_IR | 6 | select VIDEO_IR |
| 7 | select VIDEOBUF_VMALLOC | ||
| 7 | select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO | 8 | select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO |
| 8 | select VIDEO_TVP5150 if VIDEO_HELPER_CHIPS_AUTO | 9 | select VIDEO_TVP5150 if VIDEO_HELPER_CHIPS_AUTO |
| 10 | select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO | ||
| 9 | ---help--- | 11 | ---help--- |
| 10 | This is a video4linux driver for Empia 28xx based TV cards. | 12 | This is a video4linux driver for Empia 28xx based TV cards. |
| 11 | 13 | ||
| @@ -27,3 +29,13 @@ config VIDEO_EM28XX_ALSA | |||
| 27 | To compile this driver as a module, choose M here: the | 29 | To compile this driver as a module, choose M here: the |
| 28 | module will be called em28xx-alsa | 30 | module will be called em28xx-alsa |
| 29 | 31 | ||
| 32 | config VIDEO_EM28XX_DVB | ||
| 33 | tristate "DVB/ATSC Support for em28xx based TV cards" | ||
| 34 | depends on VIDEO_EM28XX && DVB_CORE | ||
| 35 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE | ||
| 36 | select DVB_ZL10353 if !DVB_FE_CUSTOMISE | ||
| 37 | select VIDEOBUF_DVB | ||
| 38 | select FW_LOADER | ||
| 39 | ---help--- | ||
| 40 | This adds support for DVB cards based on the | ||
| 41 | Empiatech em28xx chips. | ||
diff --git a/drivers/media/video/em28xx/Makefile b/drivers/media/video/em28xx/Makefile index 0924550992d0..3d1c3cc337fe 100644 --- a/drivers/media/video/em28xx/Makefile +++ b/drivers/media/video/em28xx/Makefile | |||
| @@ -5,6 +5,7 @@ em28xx-alsa-objs := em28xx-audio.o | |||
| 5 | 5 | ||
| 6 | obj-$(CONFIG_VIDEO_EM28XX) += em28xx.o | 6 | obj-$(CONFIG_VIDEO_EM28XX) += em28xx.o |
| 7 | obj-$(CONFIG_VIDEO_EM28XX_ALSA) += em28xx-alsa.o | 7 | obj-$(CONFIG_VIDEO_EM28XX_ALSA) += em28xx-alsa.o |
| 8 | obj-$(CONFIG_VIDEO_EM28XX_DVB) += em28xx-dvb.o | ||
| 8 | 9 | ||
| 9 | EXTRA_CFLAGS += -Idrivers/media/video | 10 | EXTRA_CFLAGS += -Idrivers/media/video |
| 10 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core | 11 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core |
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c index 8c67f678266a..92b2a6db4fdc 100644 --- a/drivers/media/video/em28xx/em28xx-audio.c +++ b/drivers/media/video/em28xx/em28xx-audio.c | |||
| @@ -51,7 +51,7 @@ MODULE_PARM_DESC(debug, "activates debug info"); | |||
| 51 | #define dprintk(fmt, arg...) do { \ | 51 | #define dprintk(fmt, arg...) do { \ |
| 52 | if (debug) \ | 52 | if (debug) \ |
| 53 | printk(KERN_INFO "em28xx-audio %s: " fmt, \ | 53 | printk(KERN_INFO "em28xx-audio %s: " fmt, \ |
| 54 | __FUNCTION__, ##arg); \ | 54 | __func__, ##arg); \ |
| 55 | } while (0) | 55 | } while (0) |
| 56 | 56 | ||
| 57 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | 57 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c index aae7753fef11..50ccf3771204 100644 --- a/drivers/media/video/em28xx/em28xx-cards.c +++ b/drivers/media/video/em28xx/em28xx-cards.c | |||
| @@ -36,7 +36,6 @@ | |||
| 36 | #include <media/v4l2-common.h> | 36 | #include <media/v4l2-common.h> |
| 37 | 37 | ||
| 38 | #include "em28xx.h" | 38 | #include "em28xx.h" |
| 39 | #include "tuner-xc2028.h" | ||
| 40 | 39 | ||
| 41 | static int tuner = -1; | 40 | static int tuner = -1; |
| 42 | module_param(tuner, int, 0444); | 41 | module_param(tuner, int, 0444); |
| @@ -52,26 +51,6 @@ struct em28xx_hash_table { | |||
| 52 | unsigned int tuner; | 51 | unsigned int tuner; |
| 53 | }; | 52 | }; |
| 54 | 53 | ||
| 55 | /* Boards supported by driver */ | ||
| 56 | |||
| 57 | #define EM2800_BOARD_UNKNOWN 0 | ||
| 58 | #define EM2820_BOARD_UNKNOWN 1 | ||
| 59 | #define EM2820_BOARD_TERRATEC_CINERGY_250 2 | ||
| 60 | #define EM2820_BOARD_PINNACLE_USB_2 3 | ||
| 61 | #define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 4 | ||
| 62 | #define EM2820_BOARD_MSI_VOX_USB_2 5 | ||
| 63 | #define EM2800_BOARD_TERRATEC_CINERGY_200 6 | ||
| 64 | #define EM2800_BOARD_LEADTEK_WINFAST_USBII 7 | ||
| 65 | #define EM2800_BOARD_KWORLD_USB2800 8 | ||
| 66 | #define EM2820_BOARD_PINNACLE_DVC_90 9 | ||
| 67 | #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 10 | ||
| 68 | #define EM2880_BOARD_TERRATEC_HYBRID_XS 11 | ||
| 69 | #define EM2820_BOARD_KWORLD_PVRTV2800RF 12 | ||
| 70 | #define EM2880_BOARD_TERRATEC_PRODIGY_XS 13 | ||
| 71 | #define EM2820_BOARD_PROLINK_PLAYTV_USB2 14 | ||
| 72 | #define EM2800_BOARD_VGEAR_POCKETTV 15 | ||
| 73 | #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 16 | ||
| 74 | |||
| 75 | struct em28xx_board em28xx_boards[] = { | 54 | struct em28xx_board em28xx_boards[] = { |
| 76 | [EM2800_BOARD_UNKNOWN] = { | 55 | [EM2800_BOARD_UNKNOWN] = { |
| 77 | .name = "Unknown EM2800 video grabber", | 56 | .name = "Unknown EM2800 video grabber", |
| @@ -200,6 +179,7 @@ struct em28xx_board em28xx_boards[] = { | |||
| 200 | .tuner_type = TUNER_XC2028, | 179 | .tuner_type = TUNER_XC2028, |
| 201 | .mts_firmware = 1, | 180 | .mts_firmware = 1, |
| 202 | .has_12mhz_i2s = 1, | 181 | .has_12mhz_i2s = 1, |
| 182 | .has_dvb = 1, | ||
| 203 | .decoder = EM28XX_TVP5150, | 183 | .decoder = EM28XX_TVP5150, |
| 204 | .input = { { | 184 | .input = { { |
| 205 | .type = EM28XX_VMUX_TELEVISION, | 185 | .type = EM28XX_VMUX_TELEVISION, |
| @@ -214,9 +194,6 @@ struct em28xx_board em28xx_boards[] = { | |||
| 214 | .vmux = TVP5150_SVIDEO, | 194 | .vmux = TVP5150_SVIDEO, |
| 215 | .amux = 1, | 195 | .amux = 1, |
| 216 | } }, | 196 | } }, |
| 217 | |||
| 218 | /* gpio's 4, 1, 0 */ | ||
| 219 | .analog_gpio = 0x003d2d, | ||
| 220 | }, | 197 | }, |
| 221 | [EM2880_BOARD_TERRATEC_HYBRID_XS] = { | 198 | [EM2880_BOARD_TERRATEC_HYBRID_XS] = { |
| 222 | .name = "Terratec Hybrid XS", | 199 | .name = "Terratec Hybrid XS", |
| @@ -331,7 +308,7 @@ struct em28xx_board em28xx_boards[] = { | |||
| 331 | .name = "Kworld USB2800", | 308 | .name = "Kworld USB2800", |
| 332 | .is_em2800 = 1, | 309 | .is_em2800 = 1, |
| 333 | .vchannels = 3, | 310 | .vchannels = 3, |
| 334 | .tuner_type = TUNER_PHILIPS_ATSC, | 311 | .tuner_type = TUNER_PHILIPS_FCV1236D, |
| 335 | .tda9887_conf = TDA9887_PRESENT, | 312 | .tda9887_conf = TDA9887_PRESENT, |
| 336 | .decoder = EM28XX_SAA7113, | 313 | .decoder = EM28XX_SAA7113, |
| 337 | .input = { { | 314 | .input = { { |
| @@ -453,7 +430,36 @@ struct usb_device_id em28xx_id_table [] = { | |||
| 453 | }; | 430 | }; |
| 454 | MODULE_DEVICE_TABLE(usb, em28xx_id_table); | 431 | MODULE_DEVICE_TABLE(usb, em28xx_id_table); |
| 455 | 432 | ||
| 456 | /* EEPROM hash table for devices with generic USB IDs */ | 433 | /* |
| 434 | * Reset sequences for analog/digital modes | ||
| 435 | */ | ||
| 436 | |||
| 437 | /* Board Hauppauge WinTV HVR 900 analog */ | ||
| 438 | static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = { | ||
| 439 | {EM28XX_R08_GPIO, 0x2d, ~EM_GPIO_4, 10}, | ||
| 440 | {0x05, 0xff, 0x10, 10}, | ||
| 441 | { -1, -1, -1, -1}, | ||
| 442 | }; | ||
| 443 | |||
| 444 | /* Board Hauppauge WinTV HVR 900 digital */ | ||
| 445 | static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = { | ||
| 446 | {EM28XX_R08_GPIO, 0x2e, ~EM_GPIO_4, 10}, | ||
| 447 | {EM2880_R04_GPO, 0x04, 0x0f, 10}, | ||
| 448 | {EM2880_R04_GPO, 0x0c, 0x0f, 10}, | ||
| 449 | { -1, -1, -1, -1}, | ||
| 450 | }; | ||
| 451 | |||
| 452 | /* Board Hauppauge WinTV HVR 900 tuner_callback */ | ||
| 453 | static struct em28xx_reg_seq hauppauge_wintv_hvr_900_tuner_callback[] = { | ||
| 454 | {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10}, | ||
| 455 | {EM28XX_R08_GPIO, 0, EM_GPIO_4, 10}, | ||
| 456 | {EM28XX_R08_GPIO, EM_GPIO_4, EM_GPIO_4, 10}, | ||
| 457 | { -1, -1, -1, -1}, | ||
| 458 | }; | ||
| 459 | |||
| 460 | /* | ||
| 461 | * EEPROM hash table for devices with generic USB IDs | ||
| 462 | */ | ||
| 457 | static struct em28xx_hash_table em28xx_eeprom_hash [] = { | 463 | static struct em28xx_hash_table em28xx_eeprom_hash [] = { |
| 458 | /* P/N: SA 60002070465 Tuner: TVF7533-MF */ | 464 | /* P/N: SA 60002070465 Tuner: TVF7533-MF */ |
| 459 | {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF}, | 465 | {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF}, |
| @@ -465,79 +471,113 @@ static struct em28xx_hash_table em28xx_i2c_hash[] = { | |||
| 465 | {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC}, | 471 | {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC}, |
| 466 | }; | 472 | }; |
| 467 | 473 | ||
| 474 | int em28xx_tuner_callback(void *ptr, int command, int arg) | ||
| 475 | { | ||
| 476 | int rc = 0; | ||
| 477 | struct em28xx *dev = ptr; | ||
| 478 | |||
| 479 | if (dev->tuner_type != TUNER_XC2028) | ||
| 480 | return 0; | ||
| 481 | |||
| 482 | if (command != XC2028_TUNER_RESET) | ||
| 483 | return 0; | ||
| 484 | |||
| 485 | if (dev->mode == EM28XX_ANALOG_MODE) | ||
| 486 | rc = em28xx_gpio_set(dev, dev->tun_analog_gpio); | ||
| 487 | else | ||
| 488 | rc = em28xx_gpio_set(dev, dev->tun_digital_gpio); | ||
| 489 | |||
| 490 | return rc; | ||
| 491 | } | ||
| 492 | EXPORT_SYMBOL_GPL(em28xx_tuner_callback); | ||
| 493 | |||
| 494 | static void em28xx_set_model(struct em28xx *dev) | ||
| 495 | { | ||
| 496 | dev->is_em2800 = em28xx_boards[dev->model].is_em2800; | ||
| 497 | dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx; | ||
| 498 | dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf; | ||
| 499 | dev->decoder = em28xx_boards[dev->model].decoder; | ||
| 500 | dev->video_inputs = em28xx_boards[dev->model].vchannels; | ||
| 501 | dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s; | ||
| 502 | dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480; | ||
| 503 | dev->has_dvb = em28xx_boards[dev->model].has_dvb; | ||
| 504 | } | ||
| 505 | |||
| 468 | /* Since em28xx_pre_card_setup() requires a proper dev->model, | 506 | /* Since em28xx_pre_card_setup() requires a proper dev->model, |
| 469 | * this won't work for boards with generic PCI IDs | 507 | * this won't work for boards with generic PCI IDs |
| 470 | */ | 508 | */ |
| 471 | void em28xx_pre_card_setup(struct em28xx *dev) | 509 | void em28xx_pre_card_setup(struct em28xx *dev) |
| 472 | { | 510 | { |
| 511 | int rc; | ||
| 512 | |||
| 513 | rc = em28xx_read_reg(dev, EM2880_R04_GPO); | ||
| 514 | if (rc >= 0) | ||
| 515 | dev->reg_gpo = rc; | ||
| 516 | |||
| 517 | dev->wait_after_write = 5; | ||
| 518 | rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID); | ||
| 519 | if (rc > 0) { | ||
| 520 | switch (rc) { | ||
| 521 | case CHIP_ID_EM2883: | ||
| 522 | em28xx_info("chip ID is em2882/em2883\n"); | ||
| 523 | dev->wait_after_write = 0; | ||
| 524 | break; | ||
| 525 | default: | ||
| 526 | em28xx_info("em28xx chip ID = %d\n", rc); | ||
| 527 | } | ||
| 528 | } | ||
| 529 | em28xx_set_model(dev); | ||
| 530 | |||
| 473 | /* request some modules */ | 531 | /* request some modules */ |
| 474 | switch (dev->model) { | 532 | switch (dev->model) { |
| 475 | case EM2880_BOARD_TERRATEC_PRODIGY_XS: | 533 | case EM2880_BOARD_TERRATEC_PRODIGY_XS: |
| 476 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: | 534 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: |
| 477 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950: | ||
| 478 | case EM2880_BOARD_TERRATEC_HYBRID_XS: | 535 | case EM2880_BOARD_TERRATEC_HYBRID_XS: |
| 479 | em28xx_write_regs(dev, XCLK_REG, "\x27", 1); | 536 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950: |
| 480 | em28xx_write_regs(dev, I2C_CLK_REG, "\x40", 1); | 537 | em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x27", 1); |
| 481 | em28xx_write_regs(dev, 0x08, "\xff", 1); | 538 | em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1); |
| 482 | em28xx_write_regs(dev, 0x04, "\x00", 1); | ||
| 483 | msleep(100); | ||
| 484 | em28xx_write_regs(dev, 0x04, "\x08", 1); | ||
| 485 | msleep(100); | ||
| 486 | em28xx_write_regs(dev, 0x08, "\xff", 1); | ||
| 487 | msleep(50); | ||
| 488 | em28xx_write_regs(dev, 0x08, "\x2d", 1); | ||
| 489 | msleep(50); | 539 | msleep(50); |
| 490 | em28xx_write_regs(dev, 0x08, "\x3d", 1); | 540 | |
| 541 | /* Sets GPO/GPIO sequences for this device */ | ||
| 542 | dev->analog_gpio = hauppauge_wintv_hvr_900_analog; | ||
| 543 | dev->digital_gpio = hauppauge_wintv_hvr_900_digital; | ||
| 544 | dev->tun_analog_gpio = hauppauge_wintv_hvr_900_tuner_callback; | ||
| 545 | dev->tun_digital_gpio = hauppauge_wintv_hvr_900_tuner_callback; | ||
| 546 | |||
| 491 | break; | 547 | break; |
| 492 | } | 548 | } |
| 549 | |||
| 550 | em28xx_gpio_set(dev, dev->tun_analog_gpio); | ||
| 551 | em28xx_set_mode(dev, EM28XX_ANALOG_MODE); | ||
| 552 | |||
| 553 | /* Unlock device */ | ||
| 554 | em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED); | ||
| 493 | } | 555 | } |
| 494 | 556 | ||
| 495 | static int em28xx_tuner_callback(void *ptr, int command, int arg) | 557 | static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl) |
| 496 | { | 558 | { |
| 497 | int rc = 0; | 559 | memset(ctl, 0, sizeof(*ctl)); |
| 498 | struct em28xx *dev = ptr; | ||
| 499 | 560 | ||
| 500 | if (dev->tuner_type != TUNER_XC2028) | 561 | ctl->fname = XC2028_DEFAULT_FIRMWARE; |
| 501 | return 0; | 562 | ctl->max_len = 64; |
| 502 | 563 | ctl->mts = em28xx_boards[dev->model].mts_firmware; | |
| 503 | switch (command) { | ||
| 504 | case XC2028_TUNER_RESET: | ||
| 505 | { | ||
| 506 | /* GPIO and initialization codes for analog TV and radio | ||
| 507 | This code should be complemented for DTV, since reset | ||
| 508 | codes are different. | ||
| 509 | */ | ||
| 510 | |||
| 511 | dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1); | ||
| 512 | dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1); | ||
| 513 | |||
| 514 | if (dev->analog_gpio) { | ||
| 515 | char gpio0 = dev->analog_gpio & 0xff; | ||
| 516 | char gpio1 = (dev->analog_gpio >> 8) & 0xff; | ||
| 517 | char gpio4 = dev->analog_gpio >> 24; | ||
| 518 | |||
| 519 | if (gpio4) { | ||
| 520 | dev->em28xx_write_regs(dev, 0x04, &gpio4, 1); | ||
| 521 | msleep(140); | ||
| 522 | } | ||
| 523 | |||
| 524 | msleep(6); | ||
| 525 | dev->em28xx_write_regs(dev, 0x08, &gpio0, 1); | ||
| 526 | msleep(10); | ||
| 527 | dev->em28xx_write_regs(dev, 0x08, &gpio1, 1); | ||
| 528 | msleep(5); | ||
| 529 | } | ||
| 530 | 564 | ||
| 565 | switch (dev->model) { | ||
| 566 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: | ||
| 567 | ctl->demod = XC3028_FE_ZARLINK456; | ||
| 531 | break; | 568 | break; |
| 569 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950: | ||
| 570 | /* FIXME: Better to specify the needed IF */ | ||
| 571 | ctl->demod = XC3028_FE_DEFAULT; | ||
| 572 | break; | ||
| 573 | default: | ||
| 574 | ctl->demod = XC3028_FE_OREN538; | ||
| 532 | } | 575 | } |
| 533 | } | ||
| 534 | return rc; | ||
| 535 | } | 576 | } |
| 536 | 577 | ||
| 537 | static void em28xx_config_tuner(struct em28xx *dev) | 578 | static void em28xx_config_tuner(struct em28xx *dev) |
| 538 | { | 579 | { |
| 539 | struct v4l2_priv_tun_config xc2028_cfg; | 580 | struct v4l2_priv_tun_config xc2028_cfg; |
| 540 | struct xc2028_ctrl ctl; | ||
| 541 | struct tuner_setup tun_setup; | 581 | struct tuner_setup tun_setup; |
| 542 | struct v4l2_frequency f; | 582 | struct v4l2_frequency f; |
| 543 | 583 | ||
| @@ -552,11 +592,9 @@ static void em28xx_config_tuner(struct em28xx *dev) | |||
| 552 | em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); | 592 | em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); |
| 553 | 593 | ||
| 554 | if (dev->tuner_type == TUNER_XC2028) { | 594 | if (dev->tuner_type == TUNER_XC2028) { |
| 555 | memset(&ctl, 0, sizeof(ctl)); | 595 | struct xc2028_ctrl ctl; |
| 556 | 596 | ||
| 557 | ctl.fname = XC2028_DEFAULT_FIRMWARE; | 597 | em28xx_setup_xc3028(dev, &ctl); |
| 558 | ctl.max_len = 64; | ||
| 559 | ctl.mts = em28xx_boards[dev->model].mts_firmware; | ||
| 560 | 598 | ||
| 561 | xc2028_cfg.tuner = TUNER_XC2028; | 599 | xc2028_cfg.tuner = TUNER_XC2028; |
| 562 | xc2028_cfg.priv = &ctl; | 600 | xc2028_cfg.priv = &ctl; |
| @@ -654,19 +692,6 @@ static int em28xx_hint_board(struct em28xx *dev) | |||
| 654 | return -1; | 692 | return -1; |
| 655 | } | 693 | } |
| 656 | 694 | ||
| 657 | |||
| 658 | static void em28xx_set_model(struct em28xx *dev) | ||
| 659 | { | ||
| 660 | dev->is_em2800 = em28xx_boards[dev->model].is_em2800; | ||
| 661 | dev->has_msp34xx = em28xx_boards[dev->model].has_msp34xx; | ||
| 662 | dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf; | ||
| 663 | dev->decoder = em28xx_boards[dev->model].decoder; | ||
| 664 | dev->video_inputs = em28xx_boards[dev->model].vchannels; | ||
| 665 | dev->analog_gpio = em28xx_boards[dev->model].analog_gpio; | ||
| 666 | dev->has_12mhz_i2s = em28xx_boards[dev->model].has_12mhz_i2s; | ||
| 667 | dev->max_range_640_480 = em28xx_boards[dev->model].max_range_640_480; | ||
| 668 | } | ||
| 669 | |||
| 670 | /* ----------------------------------------------------------------------- */ | 695 | /* ----------------------------------------------------------------------- */ |
| 671 | void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir) | 696 | void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir) |
| 672 | { | 697 | { |
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index c1caaa855b99..f8c41d8c74c4 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c | |||
| @@ -31,104 +31,33 @@ | |||
| 31 | 31 | ||
| 32 | /* #define ENABLE_DEBUG_ISOC_FRAMES */ | 32 | /* #define ENABLE_DEBUG_ISOC_FRAMES */ |
| 33 | 33 | ||
| 34 | static unsigned int core_debug = 0; | 34 | static unsigned int core_debug; |
| 35 | module_param(core_debug,int,0644); | 35 | module_param(core_debug,int,0644); |
| 36 | MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); | 36 | MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); |
| 37 | 37 | ||
| 38 | #define em28xx_coredbg(fmt, arg...) do {\ | 38 | #define em28xx_coredbg(fmt, arg...) do {\ |
| 39 | if (core_debug) \ | 39 | if (core_debug) \ |
| 40 | printk(KERN_INFO "%s %s :"fmt, \ | 40 | printk(KERN_INFO "%s %s :"fmt, \ |
| 41 | dev->name, __FUNCTION__ , ##arg); } while (0) | 41 | dev->name, __func__ , ##arg); } while (0) |
| 42 | 42 | ||
| 43 | static unsigned int reg_debug = 0; | 43 | static unsigned int reg_debug; |
| 44 | module_param(reg_debug,int,0644); | 44 | module_param(reg_debug,int,0644); |
| 45 | MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]"); | 45 | MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]"); |
| 46 | 46 | ||
| 47 | #define em28xx_regdbg(fmt, arg...) do {\ | 47 | #define em28xx_regdbg(fmt, arg...) do {\ |
| 48 | if (reg_debug) \ | 48 | if (reg_debug) \ |
| 49 | printk(KERN_INFO "%s %s :"fmt, \ | 49 | printk(KERN_INFO "%s %s :"fmt, \ |
| 50 | dev->name, __FUNCTION__ , ##arg); } while (0) | 50 | dev->name, __func__ , ##arg); } while (0) |
| 51 | |||
| 52 | static unsigned int isoc_debug = 0; | ||
| 53 | module_param(isoc_debug,int,0644); | ||
| 54 | MODULE_PARM_DESC(isoc_debug,"enable debug messages [isoc transfers]"); | ||
| 55 | |||
| 56 | #define em28xx_isocdbg(fmt, arg...) do {\ | ||
| 57 | if (isoc_debug) \ | ||
| 58 | printk(KERN_INFO "%s %s :"fmt, \ | ||
| 59 | dev->name, __FUNCTION__ , ##arg); } while (0) | ||
| 60 | 51 | ||
| 61 | static int alt = EM28XX_PINOUT; | 52 | static int alt = EM28XX_PINOUT; |
| 62 | module_param(alt, int, 0644); | 53 | module_param(alt, int, 0644); |
| 63 | MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); | 54 | MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint"); |
| 64 | 55 | ||
| 65 | 56 | /* FIXME */ | |
| 66 | /* | 57 | #define em28xx_isocdbg(fmt, arg...) do {\ |
| 67 | * em28xx_request_buffers() | 58 | if (core_debug) \ |
| 68 | * allocate a number of buffers | 59 | printk(KERN_INFO "%s %s :"fmt, \ |
| 69 | */ | 60 | dev->name, __func__ , ##arg); } while (0) |
| 70 | u32 em28xx_request_buffers(struct em28xx *dev, u32 count) | ||
| 71 | { | ||
| 72 | const size_t imagesize = PAGE_ALIGN(dev->frame_size); /*needs to be page aligned cause the buffers can be mapped individually! */ | ||
| 73 | void *buff = NULL; | ||
| 74 | u32 i; | ||
| 75 | em28xx_coredbg("requested %i buffers with size %zi\n", | ||
| 76 | count, imagesize); | ||
| 77 | if (count > EM28XX_NUM_FRAMES) | ||
| 78 | count = EM28XX_NUM_FRAMES; | ||
| 79 | |||
| 80 | dev->num_frames = count; | ||
| 81 | while (dev->num_frames > 0) { | ||
| 82 | if ((buff = vmalloc_32(dev->num_frames * imagesize))) { | ||
| 83 | memset(buff, 0, dev->num_frames * imagesize); | ||
| 84 | break; | ||
| 85 | } | ||
| 86 | dev->num_frames--; | ||
| 87 | } | ||
| 88 | |||
| 89 | for (i = 0; i < dev->num_frames; i++) { | ||
| 90 | dev->frame[i].bufmem = buff + i * imagesize; | ||
| 91 | dev->frame[i].buf.index = i; | ||
| 92 | dev->frame[i].buf.m.offset = i * imagesize; | ||
| 93 | dev->frame[i].buf.length = dev->frame_size; | ||
| 94 | dev->frame[i].buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 95 | dev->frame[i].buf.sequence = 0; | ||
| 96 | dev->frame[i].buf.field = V4L2_FIELD_NONE; | ||
| 97 | dev->frame[i].buf.memory = V4L2_MEMORY_MMAP; | ||
| 98 | dev->frame[i].buf.flags = 0; | ||
| 99 | } | ||
| 100 | return dev->num_frames; | ||
| 101 | } | ||
| 102 | |||
| 103 | /* | ||
| 104 | * em28xx_queue_unusedframes() | ||
| 105 | * add all frames that are not currently in use to the inbuffer queue | ||
| 106 | */ | ||
| 107 | void em28xx_queue_unusedframes(struct em28xx *dev) | ||
| 108 | { | ||
| 109 | unsigned long lock_flags; | ||
| 110 | u32 i; | ||
| 111 | |||
| 112 | for (i = 0; i < dev->num_frames; i++) | ||
| 113 | if (dev->frame[i].state == F_UNUSED) { | ||
| 114 | dev->frame[i].state = F_QUEUED; | ||
| 115 | spin_lock_irqsave(&dev->queue_lock, lock_flags); | ||
| 116 | list_add_tail(&dev->frame[i].frame, &dev->inqueue); | ||
| 117 | spin_unlock_irqrestore(&dev->queue_lock, lock_flags); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 121 | /* | ||
| 122 | * em28xx_release_buffers() | ||
| 123 | * free frame buffers | ||
| 124 | */ | ||
| 125 | void em28xx_release_buffers(struct em28xx *dev) | ||
| 126 | { | ||
| 127 | if (dev->num_frames) { | ||
| 128 | vfree(dev->frame[0].bufmem); | ||
| 129 | dev->num_frames = 0; | ||
| 130 | } | ||
| 131 | } | ||
| 132 | 61 | ||
| 133 | /* | 62 | /* |
| 134 | * em28xx_read_reg_req() | 63 | * em28xx_read_reg_req() |
| @@ -148,11 +77,11 @@ int em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg, | |||
| 148 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 77 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 149 | 0x0000, reg, buf, len, HZ); | 78 | 0x0000, reg, buf, len, HZ); |
| 150 | 79 | ||
| 151 | if (reg_debug){ | 80 | if (reg_debug) { |
| 152 | printk(ret < 0 ? " failed!\n" : "%02x values: ", ret); | 81 | printk(ret < 0 ? " failed!\n" : "%02x values: ", ret); |
| 153 | for (byte = 0; byte < len; byte++) { | 82 | for (byte = 0; byte < len; byte++) |
| 154 | printk(" %02x", (unsigned char)buf[byte]); | 83 | printk(" %02x", (unsigned char)buf[byte]); |
| 155 | } | 84 | |
| 156 | printk("\n"); | 85 | printk("\n"); |
| 157 | } | 86 | } |
| 158 | 87 | ||
| @@ -205,7 +134,10 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | |||
| 205 | unsigned char *bufs; | 134 | unsigned char *bufs; |
| 206 | 135 | ||
| 207 | if (dev->state & DEV_DISCONNECTED) | 136 | if (dev->state & DEV_DISCONNECTED) |
| 208 | return(-ENODEV); | 137 | return -ENODEV; |
| 138 | |||
| 139 | if (len < 1) | ||
| 140 | return -EINVAL; | ||
| 209 | 141 | ||
| 210 | bufs = kmalloc(len, GFP_KERNEL); | 142 | bufs = kmalloc(len, GFP_KERNEL); |
| 211 | 143 | ||
| @@ -214,8 +146,8 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | |||
| 214 | if (reg_debug) { | 146 | if (reg_debug) { |
| 215 | int i; | 147 | int i; |
| 216 | for (i = 0; i < len; ++i) | 148 | for (i = 0; i < len; ++i) |
| 217 | printk (" %02x", (unsigned char)buf[i]); | 149 | printk(" %02x", (unsigned char)buf[i]); |
| 218 | printk ("\n"); | 150 | printk("\n"); |
| 219 | } | 151 | } |
| 220 | 152 | ||
| 221 | if (!bufs) | 153 | if (!bufs) |
| @@ -224,14 +156,32 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, | |||
| 224 | ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req, | 156 | ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), req, |
| 225 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 157 | USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
| 226 | 0x0000, reg, bufs, len, HZ); | 158 | 0x0000, reg, bufs, len, HZ); |
| 227 | msleep(5); /* FIXME: magic number */ | 159 | if (dev->wait_after_write) |
| 160 | msleep(dev->wait_after_write); | ||
| 161 | |||
| 228 | kfree(bufs); | 162 | kfree(bufs); |
| 229 | return ret; | 163 | return ret; |
| 230 | } | 164 | } |
| 231 | 165 | ||
| 232 | int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len) | 166 | int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len) |
| 233 | { | 167 | { |
| 234 | return em28xx_write_regs_req(dev, USB_REQ_GET_STATUS, reg, buf, len); | 168 | int rc; |
| 169 | |||
| 170 | rc = em28xx_write_regs_req(dev, USB_REQ_GET_STATUS, reg, buf, len); | ||
| 171 | |||
| 172 | /* Stores GPO/GPIO values at the cache, if changed | ||
| 173 | Only write values should be stored, since input on a GPIO | ||
| 174 | register will return the input bits. | ||
| 175 | Not sure what happens on reading GPO register. | ||
| 176 | */ | ||
| 177 | if (rc >= 0) { | ||
| 178 | if (reg == EM2880_R04_GPO) | ||
| 179 | dev->reg_gpo = buf[0]; | ||
| 180 | else if (reg == EM28XX_R08_GPIO) | ||
| 181 | dev->reg_gpio = buf[0]; | ||
| 182 | } | ||
| 183 | |||
| 184 | return rc; | ||
| 235 | } | 185 | } |
| 236 | 186 | ||
| 237 | /* | 187 | /* |
| @@ -244,9 +194,20 @@ static int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, | |||
| 244 | { | 194 | { |
| 245 | int oldval; | 195 | int oldval; |
| 246 | u8 newval; | 196 | u8 newval; |
| 247 | if ((oldval = em28xx_read_reg(dev, reg)) < 0) | 197 | |
| 198 | /* Uses cache for gpo/gpio registers */ | ||
| 199 | if (reg == EM2880_R04_GPO) | ||
| 200 | oldval = dev->reg_gpo; | ||
| 201 | else if (reg == EM28XX_R08_GPIO) | ||
| 202 | oldval = dev->reg_gpio; | ||
| 203 | else | ||
| 204 | oldval = em28xx_read_reg(dev, reg); | ||
| 205 | |||
| 206 | if (oldval < 0) | ||
| 248 | return oldval; | 207 | return oldval; |
| 208 | |||
| 249 | newval = (((u8) oldval) & ~bitmask) | (val & bitmask); | 209 | newval = (((u8) oldval) & ~bitmask) | (val & bitmask); |
| 210 | |||
| 250 | return em28xx_write_regs(dev, reg, &newval, 1); | 211 | return em28xx_write_regs(dev, reg, &newval, 1); |
| 251 | } | 212 | } |
| 252 | 213 | ||
| @@ -258,20 +219,26 @@ static int em28xx_write_ac97(struct em28xx *dev, u8 reg, u8 *val) | |||
| 258 | { | 219 | { |
| 259 | int ret, i; | 220 | int ret, i; |
| 260 | u8 addr = reg & 0x7f; | 221 | u8 addr = reg & 0x7f; |
| 261 | if ((ret = em28xx_write_regs(dev, AC97LSB_REG, val, 2)) < 0) | 222 | |
| 223 | ret = em28xx_write_regs(dev, EM28XX_R40_AC97LSB, val, 2); | ||
| 224 | if (ret < 0) | ||
| 262 | return ret; | 225 | return ret; |
| 263 | if ((ret = em28xx_write_regs(dev, AC97ADDR_REG, &addr, 1)) < 0) | 226 | |
| 227 | ret = em28xx_write_regs(dev, EM28XX_R42_AC97ADDR, &addr, 1); | ||
| 228 | if (ret < 0) | ||
| 264 | return ret; | 229 | return ret; |
| 265 | 230 | ||
| 266 | /* Wait up to 50 ms for AC97 command to complete */ | 231 | /* Wait up to 50 ms for AC97 command to complete */ |
| 267 | for (i = 0; i < 10; i++) { | 232 | for (i = 0; i < 10; i++) { |
| 268 | if ((ret = em28xx_read_reg(dev, AC97BUSY_REG)) < 0) | 233 | ret = em28xx_read_reg(dev, EM28XX_R43_AC97BUSY); |
| 234 | if (ret < 0) | ||
| 269 | return ret; | 235 | return ret; |
| 236 | |||
| 270 | if (!(ret & 0x01)) | 237 | if (!(ret & 0x01)) |
| 271 | return 0; | 238 | return 0; |
| 272 | msleep(5); | 239 | msleep(5); |
| 273 | } | 240 | } |
| 274 | em28xx_warn ("AC97 command still being executed: not handled properly!\n"); | 241 | em28xx_warn("AC97 command still being executed: not handled properly!\n"); |
| 275 | return 0; | 242 | return 0; |
| 276 | } | 243 | } |
| 277 | 244 | ||
| @@ -289,7 +256,7 @@ static int em28xx_set_audio_source(struct em28xx *dev) | |||
| 289 | else | 256 | else |
| 290 | input = EM2800_AUDIO_SRC_TUNER; | 257 | input = EM2800_AUDIO_SRC_TUNER; |
| 291 | 258 | ||
| 292 | ret = em28xx_write_regs(dev, EM2800_AUDIOSRC_REG, &input, 1); | 259 | ret = em28xx_write_regs(dev, EM2800_R08_AUDIOSRC, &input, 1); |
| 293 | if (ret < 0) | 260 | if (ret < 0) |
| 294 | return ret; | 261 | return ret; |
| 295 | } | 262 | } |
| @@ -315,7 +282,7 @@ static int em28xx_set_audio_source(struct em28xx *dev) | |||
| 315 | } | 282 | } |
| 316 | } | 283 | } |
| 317 | 284 | ||
| 318 | ret = em28xx_write_reg_bits(dev, AUDIOSRC_REG, input, 0xc0); | 285 | ret = em28xx_write_reg_bits(dev, EM28XX_R0E_AUDIOSRC, input, 0xc0); |
| 319 | if (ret < 0) | 286 | if (ret < 0) |
| 320 | return ret; | 287 | return ret; |
| 321 | msleep(5); | 288 | msleep(5); |
| @@ -323,11 +290,11 @@ static int em28xx_set_audio_source(struct em28xx *dev) | |||
| 323 | /* Sets AC97 mixer registers | 290 | /* Sets AC97 mixer registers |
| 324 | This is seems to be needed, even for non-ac97 configs | 291 | This is seems to be needed, even for non-ac97 configs |
| 325 | */ | 292 | */ |
| 326 | ret = em28xx_write_ac97(dev, VIDEO_AC97, video); | 293 | ret = em28xx_write_ac97(dev, EM28XX_R14_VIDEO_AC97, video); |
| 327 | if (ret < 0) | 294 | if (ret < 0) |
| 328 | return ret; | 295 | return ret; |
| 329 | 296 | ||
| 330 | ret = em28xx_write_ac97(dev, LINE_IN_AC97, line); | 297 | ret = em28xx_write_ac97(dev, EM28XX_R10_LINE_IN_AC97, line); |
| 331 | 298 | ||
| 332 | return ret; | 299 | return ret; |
| 333 | } | 300 | } |
| @@ -343,7 +310,7 @@ int em28xx_audio_analog_set(struct em28xx *dev) | |||
| 343 | 310 | ||
| 344 | /* Mute */ | 311 | /* Mute */ |
| 345 | s[1] |= 0x80; | 312 | s[1] |= 0x80; |
| 346 | ret = em28xx_write_ac97(dev, MASTER_AC97, s); | 313 | ret = em28xx_write_ac97(dev, EM28XX_R02_MASTER_AC97, s); |
| 347 | 314 | ||
| 348 | if (ret < 0) | 315 | if (ret < 0) |
| 349 | return ret; | 316 | return ret; |
| @@ -354,7 +321,7 @@ int em28xx_audio_analog_set(struct em28xx *dev) | |||
| 354 | if (!dev->mute) | 321 | if (!dev->mute) |
| 355 | xclk |= 0x80; | 322 | xclk |= 0x80; |
| 356 | 323 | ||
| 357 | ret = em28xx_write_reg_bits(dev, XCLK_REG, xclk, 0xa7); | 324 | ret = em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, xclk, 0xa7); |
| 358 | if (ret < 0) | 325 | if (ret < 0) |
| 359 | return ret; | 326 | return ret; |
| 360 | msleep(10); | 327 | msleep(10); |
| @@ -365,7 +332,7 @@ int em28xx_audio_analog_set(struct em28xx *dev) | |||
| 365 | /* Unmute device */ | 332 | /* Unmute device */ |
| 366 | if (!dev->mute) | 333 | if (!dev->mute) |
| 367 | s[1] &= ~0x80; | 334 | s[1] &= ~0x80; |
| 368 | ret = em28xx_write_ac97(dev, MASTER_AC97, s); | 335 | ret = em28xx_write_ac97(dev, EM28XX_R02_MASTER_AC97, s); |
| 369 | 336 | ||
| 370 | return ret; | 337 | return ret; |
| 371 | } | 338 | } |
| @@ -373,50 +340,68 @@ EXPORT_SYMBOL_GPL(em28xx_audio_analog_set); | |||
| 373 | 340 | ||
| 374 | int em28xx_colorlevels_set_default(struct em28xx *dev) | 341 | int em28xx_colorlevels_set_default(struct em28xx *dev) |
| 375 | { | 342 | { |
| 376 | em28xx_write_regs(dev, YGAIN_REG, "\x10", 1); /* contrast */ | 343 | em28xx_write_regs(dev, EM28XX_R20_YGAIN, "\x10", 1); /* contrast */ |
| 377 | em28xx_write_regs(dev, YOFFSET_REG, "\x00", 1); /* brightness */ | 344 | em28xx_write_regs(dev, EM28XX_R21_YOFFSET, "\x00", 1); /* brightness */ |
| 378 | em28xx_write_regs(dev, UVGAIN_REG, "\x10", 1); /* saturation */ | 345 | em28xx_write_regs(dev, EM28XX_R22_UVGAIN, "\x10", 1); /* saturation */ |
| 379 | em28xx_write_regs(dev, UOFFSET_REG, "\x00", 1); | 346 | em28xx_write_regs(dev, EM28XX_R23_UOFFSET, "\x00", 1); |
| 380 | em28xx_write_regs(dev, VOFFSET_REG, "\x00", 1); | 347 | em28xx_write_regs(dev, EM28XX_R24_VOFFSET, "\x00", 1); |
| 381 | em28xx_write_regs(dev, SHARPNESS_REG, "\x00", 1); | 348 | em28xx_write_regs(dev, EM28XX_R25_SHARPNESS, "\x00", 1); |
| 382 | 349 | ||
| 383 | em28xx_write_regs(dev, GAMMA_REG, "\x20", 1); | 350 | em28xx_write_regs(dev, EM28XX_R14_GAMMA, "\x20", 1); |
| 384 | em28xx_write_regs(dev, RGAIN_REG, "\x20", 1); | 351 | em28xx_write_regs(dev, EM28XX_R15_RGAIN, "\x20", 1); |
| 385 | em28xx_write_regs(dev, GGAIN_REG, "\x20", 1); | 352 | em28xx_write_regs(dev, EM28XX_R16_GGAIN, "\x20", 1); |
| 386 | em28xx_write_regs(dev, BGAIN_REG, "\x20", 1); | 353 | em28xx_write_regs(dev, EM28XX_R17_BGAIN, "\x20", 1); |
| 387 | em28xx_write_regs(dev, ROFFSET_REG, "\x00", 1); | 354 | em28xx_write_regs(dev, EM28XX_R18_ROFFSET, "\x00", 1); |
| 388 | em28xx_write_regs(dev, GOFFSET_REG, "\x00", 1); | 355 | em28xx_write_regs(dev, EM28XX_R19_GOFFSET, "\x00", 1); |
| 389 | return em28xx_write_regs(dev, BOFFSET_REG, "\x00", 1); | 356 | return em28xx_write_regs(dev, EM28XX_R1A_BOFFSET, "\x00", 1); |
| 390 | } | 357 | } |
| 391 | 358 | ||
| 392 | int em28xx_capture_start(struct em28xx *dev, int start) | 359 | int em28xx_capture_start(struct em28xx *dev, int start) |
| 393 | { | 360 | { |
| 394 | int ret; | 361 | int rc; |
| 395 | /* FIXME: which is the best order? */ | 362 | /* FIXME: which is the best order? */ |
| 396 | /* video registers are sampled by VREF */ | 363 | /* video registers are sampled by VREF */ |
| 397 | if ((ret = em28xx_write_reg_bits(dev, USBSUSP_REG, start ? 0x10 : 0x00, | 364 | rc = em28xx_write_reg_bits(dev, EM28XX_R0C_USBSUSP, |
| 398 | 0x10)) < 0) | 365 | start ? 0x10 : 0x00, 0x10); |
| 399 | return ret; | 366 | if (rc < 0) |
| 367 | return rc; | ||
| 368 | |||
| 369 | if (!start) { | ||
| 370 | /* disable video capture */ | ||
| 371 | rc = em28xx_write_regs(dev, EM28XX_R12_VINENABLE, "\x27", 1); | ||
| 372 | return rc; | ||
| 373 | } | ||
| 374 | |||
| 400 | /* enable video capture */ | 375 | /* enable video capture */ |
| 401 | return em28xx_write_regs(dev, VINENABLE_REG, start ? "\x67" : "\x27", 1); | 376 | rc = em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1); |
| 377 | |||
| 378 | if (dev->mode == EM28XX_ANALOG_MODE) | ||
| 379 | rc = em28xx_write_regs(dev, EM28XX_R12_VINENABLE, "\x67", 1); | ||
| 380 | else | ||
| 381 | rc = em28xx_write_regs(dev, EM28XX_R12_VINENABLE, "\x37", 1); | ||
| 382 | |||
| 383 | msleep(6); | ||
| 384 | |||
| 385 | return rc; | ||
| 402 | } | 386 | } |
| 403 | 387 | ||
| 404 | int em28xx_outfmt_set_yuv422(struct em28xx *dev) | 388 | int em28xx_outfmt_set_yuv422(struct em28xx *dev) |
| 405 | { | 389 | { |
| 406 | em28xx_write_regs(dev, OUTFMT_REG, "\x34", 1); | 390 | em28xx_write_regs(dev, EM28XX_R27_OUTFMT, "\x34", 1); |
| 407 | em28xx_write_regs(dev, VINMODE_REG, "\x10", 1); | 391 | em28xx_write_regs(dev, EM28XX_R10_VINMODE, "\x10", 1); |
| 408 | return em28xx_write_regs(dev, VINCTRL_REG, "\x11", 1); | 392 | return em28xx_write_regs(dev, EM28XX_R11_VINCTRL, "\x11", 1); |
| 409 | } | 393 | } |
| 410 | 394 | ||
| 411 | static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax, | 395 | static int em28xx_accumulator_set(struct em28xx *dev, u8 xmin, u8 xmax, |
| 412 | u8 ymin, u8 ymax) | 396 | u8 ymin, u8 ymax) |
| 413 | { | 397 | { |
| 414 | em28xx_coredbg("em28xx Scale: (%d,%d)-(%d,%d)\n", xmin, ymin, xmax, ymax); | 398 | em28xx_coredbg("em28xx Scale: (%d,%d)-(%d,%d)\n", |
| 399 | xmin, ymin, xmax, ymax); | ||
| 415 | 400 | ||
| 416 | em28xx_write_regs(dev, XMIN_REG, &xmin, 1); | 401 | em28xx_write_regs(dev, EM28XX_R28_XMIN, &xmin, 1); |
| 417 | em28xx_write_regs(dev, XMAX_REG, &xmax, 1); | 402 | em28xx_write_regs(dev, EM28XX_R29_XMAX, &xmax, 1); |
| 418 | em28xx_write_regs(dev, YMIN_REG, &ymin, 1); | 403 | em28xx_write_regs(dev, EM28XX_R2A_YMIN, &ymin, 1); |
| 419 | return em28xx_write_regs(dev, YMAX_REG, &ymax, 1); | 404 | return em28xx_write_regs(dev, EM28XX_R2B_YMAX, &ymax, 1); |
| 420 | } | 405 | } |
| 421 | 406 | ||
| 422 | static int em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart, | 407 | static int em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart, |
| @@ -426,34 +411,36 @@ static int em28xx_capture_area_set(struct em28xx *dev, u8 hstart, u8 vstart, | |||
| 426 | u8 cheight = height; | 411 | u8 cheight = height; |
| 427 | u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01); | 412 | u8 overflow = (height >> 7 & 0x02) | (width >> 8 & 0x01); |
| 428 | 413 | ||
| 429 | em28xx_coredbg("em28xx Area Set: (%d,%d)\n", (width | (overflow & 2) << 7), | 414 | em28xx_coredbg("em28xx Area Set: (%d,%d)\n", |
| 415 | (width | (overflow & 2) << 7), | ||
| 430 | (height | (overflow & 1) << 8)); | 416 | (height | (overflow & 1) << 8)); |
| 431 | 417 | ||
| 432 | em28xx_write_regs(dev, HSTART_REG, &hstart, 1); | 418 | em28xx_write_regs(dev, EM28XX_R1C_HSTART, &hstart, 1); |
| 433 | em28xx_write_regs(dev, VSTART_REG, &vstart, 1); | 419 | em28xx_write_regs(dev, EM28XX_R1D_VSTART, &vstart, 1); |
| 434 | em28xx_write_regs(dev, CWIDTH_REG, &cwidth, 1); | 420 | em28xx_write_regs(dev, EM28XX_R1E_CWIDTH, &cwidth, 1); |
| 435 | em28xx_write_regs(dev, CHEIGHT_REG, &cheight, 1); | 421 | em28xx_write_regs(dev, EM28XX_R1F_CHEIGHT, &cheight, 1); |
| 436 | return em28xx_write_regs(dev, OFLOW_REG, &overflow, 1); | 422 | return em28xx_write_regs(dev, EM28XX_R1B_OFLOW, &overflow, 1); |
| 437 | } | 423 | } |
| 438 | 424 | ||
| 439 | static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v) | 425 | static int em28xx_scaler_set(struct em28xx *dev, u16 h, u16 v) |
| 440 | { | 426 | { |
| 441 | u8 mode; | 427 | u8 mode; |
| 442 | /* the em2800 scaler only supports scaling down to 50% */ | 428 | /* the em2800 scaler only supports scaling down to 50% */ |
| 443 | if(dev->is_em2800) | 429 | if (dev->is_em2800) |
| 444 | mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00); | 430 | mode = (v ? 0x20 : 0x00) | (h ? 0x10 : 0x00); |
| 445 | else { | 431 | else { |
| 446 | u8 buf[2]; | 432 | u8 buf[2]; |
| 447 | buf[0] = h; | 433 | buf[0] = h; |
| 448 | buf[1] = h >> 8; | 434 | buf[1] = h >> 8; |
| 449 | em28xx_write_regs(dev, HSCALELOW_REG, (char *)buf, 2); | 435 | em28xx_write_regs(dev, EM28XX_R30_HSCALELOW, (char *)buf, 2); |
| 450 | buf[0] = v; | 436 | buf[0] = v; |
| 451 | buf[1] = v >> 8; | 437 | buf[1] = v >> 8; |
| 452 | em28xx_write_regs(dev, VSCALELOW_REG, (char *)buf, 2); | 438 | em28xx_write_regs(dev, EM28XX_R32_VSCALELOW, (char *)buf, 2); |
| 453 | /* it seems that both H and V scalers must be active to work correctly */ | 439 | /* it seems that both H and V scalers must be active |
| 440 | to work correctly */ | ||
| 454 | mode = (h || v)? 0x30: 0x00; | 441 | mode = (h || v)? 0x30: 0x00; |
| 455 | } | 442 | } |
| 456 | return em28xx_write_reg_bits(dev, COMPR_REG, mode, 0x30); | 443 | return em28xx_write_reg_bits(dev, EM28XX_R26_COMPR, mode, 0x30); |
| 457 | } | 444 | } |
| 458 | 445 | ||
| 459 | /* FIXME: this only function read values from dev */ | 446 | /* FIXME: this only function read values from dev */ |
| @@ -469,376 +456,271 @@ int em28xx_resolution_set(struct em28xx *dev) | |||
| 469 | return em28xx_scaler_set(dev, dev->hscale, dev->vscale); | 456 | return em28xx_scaler_set(dev, dev->hscale, dev->vscale); |
| 470 | } | 457 | } |
| 471 | 458 | ||
| 472 | 459 | int em28xx_set_alternate(struct em28xx *dev) | |
| 473 | /******************* isoc transfer handling ****************************/ | ||
| 474 | |||
| 475 | #ifdef ENABLE_DEBUG_ISOC_FRAMES | ||
| 476 | static void em28xx_isoc_dump(struct urb *urb) | ||
| 477 | { | 460 | { |
| 478 | int len = 0; | 461 | int errCode, prev_alt = dev->alt; |
| 479 | int ntrans = 0; | ||
| 480 | int i; | 462 | int i; |
| 463 | unsigned int min_pkt_size = dev->width * 2 + 4; | ||
| 481 | 464 | ||
| 482 | printk(KERN_DEBUG "isocIrq: sf=%d np=%d ec=%x\n", | 465 | /* When image size is bigger than a certain value, |
| 483 | urb->start_frame, urb->number_of_packets, | 466 | the frame size should be increased, otherwise, only |
| 484 | urb->error_count); | 467 | green screen will be received. |
| 485 | for (i = 0; i < urb->number_of_packets; i++) { | 468 | */ |
| 486 | unsigned char *buf = | 469 | if (dev->width * 2 * dev->height > 720 * 240 * 2) |
| 487 | urb->transfer_buffer + | 470 | min_pkt_size *= 2; |
| 488 | urb->iso_frame_desc[i].offset; | 471 | |
| 489 | int alen = urb->iso_frame_desc[i].actual_length; | 472 | for (i = 0; i < dev->num_alt; i++) { |
| 490 | if (alen > 0) { | 473 | /* stop when the selected alt setting offers enough bandwidth */ |
| 491 | if (buf[0] == 0x88) { | 474 | if (dev->alt_max_pkt_size[i] >= min_pkt_size) { |
| 492 | ntrans++; | 475 | dev->alt = i; |
| 493 | len += alen; | 476 | break; |
| 494 | } else if (buf[0] == 0x22) { | 477 | /* otherwise make sure that we end up with the maximum bandwidth |
| 495 | printk(KERN_DEBUG | 478 | because the min_pkt_size equation might be wrong... |
| 496 | "= l=%d nt=%d bpp=%d\n", | 479 | */ |
| 497 | len - 4 * ntrans, ntrans, | 480 | } else if (dev->alt_max_pkt_size[i] > |
| 498 | ntrans == 0 ? 0 : len / ntrans); | 481 | dev->alt_max_pkt_size[dev->alt]) |
| 499 | ntrans = 1; | 482 | dev->alt = i; |
| 500 | len = alen; | 483 | } |
| 501 | } else | 484 | |
| 502 | printk(KERN_DEBUG "!\n"); | 485 | if (dev->alt != prev_alt) { |
| 486 | em28xx_coredbg("minimum isoc packet size: %u (alt=%d)\n", | ||
| 487 | min_pkt_size, dev->alt); | ||
| 488 | dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt]; | ||
| 489 | em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", | ||
| 490 | dev->alt, dev->max_pkt_size); | ||
| 491 | errCode = usb_set_interface(dev->udev, 0, dev->alt); | ||
| 492 | if (errCode < 0) { | ||
| 493 | em28xx_errdev("cannot change alternate number to %d (error=%i)\n", | ||
| 494 | dev->alt, errCode); | ||
| 495 | return errCode; | ||
| 503 | } | 496 | } |
| 504 | printk(KERN_DEBUG " n=%d s=%d al=%d %x\n", i, | ||
| 505 | urb->iso_frame_desc[i].status, | ||
| 506 | urb->iso_frame_desc[i].actual_length, | ||
| 507 | (unsigned int) | ||
| 508 | *((unsigned char *)(urb->transfer_buffer + | ||
| 509 | urb->iso_frame_desc[i]. | ||
| 510 | offset))); | ||
| 511 | } | 497 | } |
| 498 | return 0; | ||
| 512 | } | 499 | } |
| 513 | #endif | ||
| 514 | 500 | ||
| 515 | static inline int em28xx_isoc_video(struct em28xx *dev,struct em28xx_frame_t **f, | 501 | int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio) |
| 516 | unsigned long *lock_flags, unsigned char buf) | ||
| 517 | { | 502 | { |
| 518 | if (!(buf & 0x01)) { | 503 | int rc = 0; |
| 519 | if ((*f)->state == F_GRABBING) { | 504 | |
| 520 | /*previous frame is incomplete */ | 505 | if (!gpio) |
| 521 | if ((*f)->fieldbytesused < dev->field_size) { | 506 | return rc; |
| 522 | (*f)->state = F_ERROR; | 507 | |
| 523 | em28xx_isocdbg ("dropping incomplete bottom field (%i missing bytes)", | 508 | dev->em28xx_write_regs_req(dev, 0x00, 0x48, "\x00", 1); |
| 524 | dev->field_size-(*f)->fieldbytesused); | 509 | if (dev->mode == EM28XX_ANALOG_MODE) |
| 525 | } else { | 510 | dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x67", 1); |
| 526 | (*f)->state = F_DONE; | 511 | else |
| 527 | (*f)->buf.bytesused = dev->frame_size; | 512 | dev->em28xx_write_regs_req(dev, 0x00, 0x12, "\x37", 1); |
| 528 | } | 513 | msleep(6); |
| 529 | } | 514 | |
| 530 | if ((*f)->state == F_DONE || (*f)->state == F_ERROR) { | 515 | /* Send GPIO reset sequences specified at board entry */ |
| 531 | /* move current frame to outqueue and get next free buffer from inqueue */ | 516 | while (gpio->sleep >= 0) { |
| 532 | spin_lock_irqsave(&dev-> queue_lock, *lock_flags); | 517 | if (gpio->reg >= 0) { |
| 533 | list_move_tail(&(*f)->frame, &dev->outqueue); | 518 | rc = em28xx_write_reg_bits(dev, |
| 534 | if (!list_empty(&dev->inqueue)) | 519 | gpio->reg, |
| 535 | (*f) = list_entry(dev-> inqueue.next, | 520 | gpio->val, |
| 536 | struct em28xx_frame_t,frame); | 521 | gpio->mask); |
| 537 | else | 522 | if (rc < 0) |
| 538 | (*f) = NULL; | 523 | return rc; |
| 539 | spin_unlock_irqrestore(&dev->queue_lock,*lock_flags); | ||
| 540 | } | ||
| 541 | if (!(*f)) { | ||
| 542 | em28xx_isocdbg ("new frame but no buffer is free"); | ||
| 543 | return -1; | ||
| 544 | } | ||
| 545 | do_gettimeofday(&(*f)->buf.timestamp); | ||
| 546 | (*f)->buf.sequence = ++dev->frame_count; | ||
| 547 | (*f)->buf.field = V4L2_FIELD_INTERLACED; | ||
| 548 | (*f)->state = F_GRABBING; | ||
| 549 | (*f)->buf.bytesused = 0; | ||
| 550 | (*f)->top_field = 1; | ||
| 551 | (*f)->fieldbytesused = 0; | ||
| 552 | } else { | ||
| 553 | /* acquiring bottom field */ | ||
| 554 | if ((*f)->state == F_GRABBING) { | ||
| 555 | if (!(*f)->top_field) { | ||
| 556 | (*f)->state = F_ERROR; | ||
| 557 | em28xx_isocdbg ("unexpected begin of bottom field; discarding it"); | ||
| 558 | } else if ((*f)-> fieldbytesused < dev->field_size - 172) { | ||
| 559 | (*f)->state = F_ERROR; | ||
| 560 | em28xx_isocdbg ("dropping incomplete top field (%i missing bytes)", | ||
| 561 | dev->field_size-(*f)->fieldbytesused); | ||
| 562 | } else { | ||
| 563 | (*f)->top_field = 0; | ||
| 564 | (*f)->fieldbytesused = 0; | ||
| 565 | } | ||
| 566 | } | 524 | } |
| 525 | if (gpio->sleep > 0) | ||
| 526 | msleep(gpio->sleep); | ||
| 527 | |||
| 528 | gpio++; | ||
| 567 | } | 529 | } |
| 568 | return (0); | 530 | return rc; |
| 569 | } | 531 | } |
| 570 | 532 | ||
| 571 | static inline void em28xx_isoc_video_copy(struct em28xx *dev, | 533 | int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode) |
| 572 | struct em28xx_frame_t **f, unsigned char *buf, int len) | ||
| 573 | { | 534 | { |
| 574 | void *fieldstart, *startwrite, *startread; | 535 | if (dev->mode == set_mode) |
| 575 | int linesdone, currlinedone, offset, lencopy,remain; | 536 | return 0; |
| 576 | 537 | ||
| 577 | if(dev->frame_size != (*f)->buf.length){ | 538 | if (set_mode == EM28XX_MODE_UNDEFINED) { |
| 578 | em28xx_err("frame_size %i and buf.length %i are different!!!\n",dev->frame_size,(*f)->buf.length); | 539 | dev->mode = set_mode; |
| 579 | return; | 540 | return 0; |
| 580 | } | 541 | } |
| 581 | 542 | ||
| 582 | if ((*f)->fieldbytesused + len > dev->field_size) | 543 | dev->mode = set_mode; |
| 583 | len =dev->field_size - (*f)->fieldbytesused; | ||
| 584 | |||
| 585 | if (buf[0] != 0x88 && buf[0] != 0x22) { | ||
| 586 | em28xx_isocdbg("frame is not complete\n"); | ||
| 587 | startread = buf; | ||
| 588 | len+=4; | ||
| 589 | } else | ||
| 590 | startread = buf + 4; | ||
| 591 | |||
| 592 | remain = len; | ||
| 593 | 544 | ||
| 594 | if ((*f)->top_field) | 545 | if (dev->mode == EM28XX_DIGITAL_MODE) |
| 595 | fieldstart = (*f)->bufmem; | 546 | return em28xx_gpio_set(dev, dev->digital_gpio); |
| 596 | else | 547 | else |
| 597 | fieldstart = (*f)->bufmem + dev->bytesperline; | 548 | return em28xx_gpio_set(dev, dev->analog_gpio); |
| 598 | |||
| 599 | linesdone = (*f)->fieldbytesused / dev->bytesperline; | ||
| 600 | currlinedone = (*f)->fieldbytesused % dev->bytesperline; | ||
| 601 | offset = linesdone * dev->bytesperline * 2 + currlinedone; | ||
| 602 | startwrite = fieldstart + offset; | ||
| 603 | lencopy = dev->bytesperline - currlinedone; | ||
| 604 | lencopy = lencopy > remain ? remain : lencopy; | ||
| 605 | |||
| 606 | memcpy(startwrite, startread, lencopy); | ||
| 607 | remain -= lencopy; | ||
| 608 | |||
| 609 | while (remain > 0) { | ||
| 610 | startwrite += lencopy + dev->bytesperline; | ||
| 611 | startread += lencopy; | ||
| 612 | if (dev->bytesperline > remain) | ||
| 613 | lencopy = remain; | ||
| 614 | else | ||
| 615 | lencopy = dev->bytesperline; | ||
| 616 | |||
| 617 | memcpy(startwrite, startread, lencopy); | ||
| 618 | remain -= lencopy; | ||
| 619 | } | ||
| 620 | |||
| 621 | (*f)->fieldbytesused += len; | ||
| 622 | } | 549 | } |
| 550 | EXPORT_SYMBOL_GPL(em28xx_set_mode); | ||
| 551 | |||
| 552 | /* ------------------------------------------------------------------ | ||
| 553 | URB control | ||
| 554 | ------------------------------------------------------------------*/ | ||
| 623 | 555 | ||
| 624 | /* | 556 | /* |
| 625 | * em28xx_isoIrq() | 557 | * IRQ callback, called by URB callback |
| 626 | * handles the incoming isoc urbs and fills the frames from our inqueue | ||
| 627 | */ | 558 | */ |
| 628 | static void em28xx_isocIrq(struct urb *urb) | 559 | static void em28xx_irq_callback(struct urb *urb) |
| 629 | { | 560 | { |
| 630 | struct em28xx *dev = urb->context; | 561 | struct em28xx_dmaqueue *dma_q = urb->context; |
| 631 | int i, status; | 562 | struct em28xx *dev = container_of(dma_q, struct em28xx, vidq); |
| 632 | struct em28xx_frame_t **f; | 563 | int rc, i; |
| 633 | unsigned long lock_flags; | ||
| 634 | |||
| 635 | if (!dev) | ||
| 636 | return; | ||
| 637 | #ifdef ENABLE_DEBUG_ISOC_FRAMES | ||
| 638 | if (isoc_debug>1) | ||
| 639 | em28xx_isoc_dump(urb); | ||
| 640 | #endif | ||
| 641 | |||
| 642 | if (urb->status == -ENOENT) | ||
| 643 | return; | ||
| 644 | |||
| 645 | f = &dev->frame_current; | ||
| 646 | |||
| 647 | if (dev->stream == STREAM_INTERRUPT) { | ||
| 648 | dev->stream = STREAM_OFF; | ||
| 649 | if ((*f)) | ||
| 650 | (*f)->state = F_QUEUED; | ||
| 651 | em28xx_isocdbg("stream interrupted"); | ||
| 652 | wake_up_interruptible(&dev->wait_stream); | ||
| 653 | } | ||
| 654 | |||
| 655 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | ||
| 656 | return; | ||
| 657 | |||
| 658 | if (dev->stream == STREAM_ON && !list_empty(&dev->inqueue)) { | ||
| 659 | if (!(*f)) | ||
| 660 | (*f) = list_entry(dev->inqueue.next, | ||
| 661 | struct em28xx_frame_t, frame); | ||
| 662 | |||
| 663 | for (i = 0; i < urb->number_of_packets; i++) { | ||
| 664 | unsigned char *buf = urb->transfer_buffer + | ||
| 665 | urb->iso_frame_desc[i].offset; | ||
| 666 | int len = urb->iso_frame_desc[i].actual_length - 4; | ||
| 667 | |||
| 668 | if (urb->iso_frame_desc[i].status) { | ||
| 669 | em28xx_isocdbg("data error: [%d] len=%d, status=%d", i, | ||
| 670 | urb->iso_frame_desc[i].actual_length, | ||
| 671 | urb->iso_frame_desc[i].status); | ||
| 672 | if (urb->iso_frame_desc[i].status != -EPROTO) | ||
| 673 | continue; | ||
| 674 | } | ||
| 675 | if (urb->iso_frame_desc[i].actual_length <= 0) { | ||
| 676 | em28xx_isocdbg("packet %d is empty",i); | ||
| 677 | continue; | ||
| 678 | } | ||
| 679 | if (urb->iso_frame_desc[i].actual_length > | ||
| 680 | urb->iso_frame_desc[i].length) { | ||
| 681 | em28xx_isocdbg("packet bigger than packet size"); | ||
| 682 | continue; | ||
| 683 | } | ||
| 684 | /*new frame */ | ||
| 685 | if (buf[0] == 0x22 && buf[1] == 0x5a) { | ||
| 686 | em28xx_isocdbg("Video frame, length=%i!",len); | ||
| 687 | |||
| 688 | if (em28xx_isoc_video(dev,f,&lock_flags,buf[2])) | ||
| 689 | break; | ||
| 690 | } else if (buf[0]==0x33 && buf[1]==0x95 && buf[2]==0x00) { | ||
| 691 | em28xx_isocdbg("VBI HEADER!!!"); | ||
| 692 | } | ||
| 693 | 564 | ||
| 694 | /* actual copying */ | 565 | /* Copy data from URB */ |
| 695 | if ((*f)->state == F_GRABBING) { | 566 | spin_lock(&dev->slock); |
| 696 | em28xx_isoc_video_copy(dev,f,buf, len); | 567 | rc = dev->isoc_ctl.isoc_copy(dev, urb); |
| 697 | } | 568 | spin_unlock(&dev->slock); |
| 698 | } | ||
| 699 | } | ||
| 700 | 569 | ||
| 570 | /* Reset urb buffers */ | ||
| 701 | for (i = 0; i < urb->number_of_packets; i++) { | 571 | for (i = 0; i < urb->number_of_packets; i++) { |
| 702 | urb->iso_frame_desc[i].status = 0; | 572 | urb->iso_frame_desc[i].status = 0; |
| 703 | urb->iso_frame_desc[i].actual_length = 0; | 573 | urb->iso_frame_desc[i].actual_length = 0; |
| 704 | } | 574 | } |
| 705 | |||
| 706 | urb->status = 0; | 575 | urb->status = 0; |
| 707 | if ((status = usb_submit_urb(urb, GFP_ATOMIC))) { | 576 | |
| 708 | em28xx_errdev("resubmit of urb failed (error=%i)\n", status); | 577 | urb->status = usb_submit_urb(urb, GFP_ATOMIC); |
| 709 | dev->state |= DEV_MISCONFIGURED; | 578 | if (urb->status) { |
| 579 | em28xx_isocdbg("urb resubmit failed (error=%i)\n", | ||
| 580 | urb->status); | ||
| 710 | } | 581 | } |
| 711 | wake_up_interruptible(&dev->wait_frame); | ||
| 712 | return; | ||
| 713 | } | 582 | } |
| 714 | 583 | ||
| 715 | /* | 584 | /* |
| 716 | * em28xx_uninit_isoc() | 585 | * Stop and Deallocate URBs |
| 717 | * deallocates the buffers and urbs allocated during em28xx_init_iosc() | ||
| 718 | */ | 586 | */ |
| 719 | void em28xx_uninit_isoc(struct em28xx *dev) | 587 | void em28xx_uninit_isoc(struct em28xx *dev) |
| 720 | { | 588 | { |
| 589 | struct urb *urb; | ||
| 721 | int i; | 590 | int i; |
| 722 | 591 | ||
| 723 | for (i = 0; i < EM28XX_NUM_BUFS; i++) { | 592 | em28xx_isocdbg("em28xx: called em28xx_uninit_isoc\n"); |
| 724 | if (dev->urb[i]) { | 593 | |
| 725 | usb_kill_urb(dev->urb[i]); | 594 | dev->isoc_ctl.nfields = -1; |
| 726 | if (dev->transfer_buffer[i]) { | 595 | for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { |
| 596 | urb = dev->isoc_ctl.urb[i]; | ||
| 597 | if (urb) { | ||
| 598 | usb_kill_urb(urb); | ||
| 599 | usb_unlink_urb(urb); | ||
| 600 | if (dev->isoc_ctl.transfer_buffer[i]) { | ||
| 727 | usb_buffer_free(dev->udev, | 601 | usb_buffer_free(dev->udev, |
| 728 | dev->urb[i]->transfer_buffer_length, | 602 | urb->transfer_buffer_length, |
| 729 | dev->transfer_buffer[i], | 603 | dev->isoc_ctl.transfer_buffer[i], |
| 730 | dev->urb[i]->transfer_dma); | 604 | urb->transfer_dma); |
| 731 | } | 605 | } |
| 732 | usb_free_urb(dev->urb[i]); | 606 | usb_free_urb(urb); |
| 607 | dev->isoc_ctl.urb[i] = NULL; | ||
| 733 | } | 608 | } |
| 734 | dev->urb[i] = NULL; | 609 | dev->isoc_ctl.transfer_buffer[i] = NULL; |
| 735 | dev->transfer_buffer[i] = NULL; | ||
| 736 | } | 610 | } |
| 611 | |||
| 612 | kfree(dev->isoc_ctl.urb); | ||
| 613 | kfree(dev->isoc_ctl.transfer_buffer); | ||
| 614 | |||
| 615 | dev->isoc_ctl.urb = NULL; | ||
| 616 | dev->isoc_ctl.transfer_buffer = NULL; | ||
| 617 | dev->isoc_ctl.num_bufs = 0; | ||
| 618 | |||
| 737 | em28xx_capture_start(dev, 0); | 619 | em28xx_capture_start(dev, 0); |
| 738 | } | 620 | } |
| 621 | EXPORT_SYMBOL_GPL(em28xx_uninit_isoc); | ||
| 739 | 622 | ||
| 740 | /* | 623 | /* |
| 741 | * em28xx_init_isoc() | 624 | * Allocate URBs and start IRQ |
| 742 | * allocates transfer buffers and submits the urbs for isoc transfer | ||
| 743 | */ | 625 | */ |
| 744 | int em28xx_init_isoc(struct em28xx *dev) | 626 | int em28xx_init_isoc(struct em28xx *dev, int max_packets, |
| 627 | int num_bufs, int max_pkt_size, | ||
| 628 | int (*isoc_copy) (struct em28xx *dev, struct urb *urb)) | ||
| 745 | { | 629 | { |
| 746 | /* change interface to 3 which allows the biggest packet sizes */ | 630 | struct em28xx_dmaqueue *dma_q = &dev->vidq; |
| 747 | int i, errCode; | 631 | int i; |
| 748 | int sb_size; | 632 | int sb_size, pipe; |
| 749 | 633 | struct urb *urb; | |
| 750 | em28xx_set_alternate(dev); | 634 | int j, k; |
| 751 | sb_size = EM28XX_NUM_PACKETS * dev->max_pkt_size; | 635 | int rc; |
| 752 | 636 | ||
| 753 | /* reset streaming vars */ | 637 | em28xx_isocdbg("em28xx: called em28xx_prepare_isoc\n"); |
| 754 | dev->frame_current = NULL; | 638 | |
| 755 | dev->frame_count = 0; | 639 | /* De-allocates all pending stuff */ |
| 756 | 640 | em28xx_uninit_isoc(dev); | |
| 757 | /* allocate urbs */ | 641 | |
| 758 | for (i = 0; i < EM28XX_NUM_BUFS; i++) { | 642 | dev->isoc_ctl.isoc_copy = isoc_copy; |
| 759 | struct urb *urb; | 643 | dev->isoc_ctl.num_bufs = num_bufs; |
| 760 | int j; | 644 | |
| 761 | /* allocate transfer buffer */ | 645 | dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL); |
| 762 | urb = usb_alloc_urb(EM28XX_NUM_PACKETS, GFP_KERNEL); | 646 | if (!dev->isoc_ctl.urb) { |
| 763 | if (!urb){ | 647 | em28xx_errdev("cannot alloc memory for usb buffers\n"); |
| 764 | em28xx_errdev("cannot alloc urb %i\n", i); | 648 | return -ENOMEM; |
| 649 | } | ||
| 650 | |||
| 651 | dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs, | ||
| 652 | GFP_KERNEL); | ||
| 653 | if (!dev->isoc_ctl.urb) { | ||
| 654 | em28xx_errdev("cannot allocate memory for usbtransfer\n"); | ||
| 655 | kfree(dev->isoc_ctl.urb); | ||
| 656 | return -ENOMEM; | ||
| 657 | } | ||
| 658 | |||
| 659 | dev->isoc_ctl.max_pkt_size = max_pkt_size; | ||
| 660 | dev->isoc_ctl.buf = NULL; | ||
| 661 | |||
| 662 | sb_size = max_packets * dev->isoc_ctl.max_pkt_size; | ||
| 663 | |||
| 664 | /* allocate urbs and transfer buffers */ | ||
| 665 | for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { | ||
| 666 | urb = usb_alloc_urb(max_packets, GFP_KERNEL); | ||
| 667 | if (!urb) { | ||
| 668 | em28xx_err("cannot alloc isoc_ctl.urb %i\n", i); | ||
| 765 | em28xx_uninit_isoc(dev); | 669 | em28xx_uninit_isoc(dev); |
| 766 | return -ENOMEM; | 670 | return -ENOMEM; |
| 767 | } | 671 | } |
| 768 | dev->transfer_buffer[i] = usb_buffer_alloc(dev->udev, sb_size, | 672 | dev->isoc_ctl.urb[i] = urb; |
| 769 | GFP_KERNEL, | 673 | |
| 770 | &urb->transfer_dma); | 674 | dev->isoc_ctl.transfer_buffer[i] = usb_buffer_alloc(dev->udev, |
| 771 | if (!dev->transfer_buffer[i]) { | 675 | sb_size, GFP_KERNEL, &urb->transfer_dma); |
| 772 | em28xx_errdev | 676 | if (!dev->isoc_ctl.transfer_buffer[i]) { |
| 773 | ("unable to allocate %i bytes for transfer buffer %i\n", | 677 | em28xx_err("unable to allocate %i bytes for transfer" |
| 774 | sb_size, i); | 678 | " buffer %i%s\n", |
| 679 | sb_size, i, | ||
| 680 | in_interrupt()?" while in int":""); | ||
| 775 | em28xx_uninit_isoc(dev); | 681 | em28xx_uninit_isoc(dev); |
| 776 | usb_free_urb(urb); | ||
| 777 | return -ENOMEM; | 682 | return -ENOMEM; |
| 778 | } | 683 | } |
| 779 | memset(dev->transfer_buffer[i], 0, sb_size); | 684 | memset(dev->isoc_ctl.transfer_buffer[i], 0, sb_size); |
| 780 | urb->dev = dev->udev; | 685 | |
| 781 | urb->context = dev; | 686 | /* FIXME: this is a hack - should be |
| 782 | urb->pipe = usb_rcvisocpipe(dev->udev, 0x82); | 687 | 'desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK' |
| 783 | urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; | 688 | should also be using 'desc.bInterval' |
| 784 | urb->interval = 1; | 689 | */ |
| 785 | urb->transfer_buffer = dev->transfer_buffer[i]; | 690 | pipe = usb_rcvisocpipe(dev->udev, |
| 786 | urb->complete = em28xx_isocIrq; | 691 | dev->mode == EM28XX_ANALOG_MODE ? 0x82 : 0x84); |
| 787 | urb->number_of_packets = EM28XX_NUM_PACKETS; | 692 | |
| 788 | urb->transfer_buffer_length = sb_size; | 693 | usb_fill_int_urb(urb, dev->udev, pipe, |
| 789 | for (j = 0; j < EM28XX_NUM_PACKETS; j++) { | 694 | dev->isoc_ctl.transfer_buffer[i], sb_size, |
| 790 | urb->iso_frame_desc[j].offset = j * dev->max_pkt_size; | 695 | em28xx_irq_callback, dma_q, 1); |
| 791 | urb->iso_frame_desc[j].length = dev->max_pkt_size; | 696 | |
| 697 | urb->number_of_packets = max_packets; | ||
| 698 | urb->transfer_flags = URB_ISO_ASAP; | ||
| 699 | |||
| 700 | k = 0; | ||
| 701 | for (j = 0; j < max_packets; j++) { | ||
| 702 | urb->iso_frame_desc[j].offset = k; | ||
| 703 | urb->iso_frame_desc[j].length = | ||
| 704 | dev->isoc_ctl.max_pkt_size; | ||
| 705 | k += dev->isoc_ctl.max_pkt_size; | ||
| 792 | } | 706 | } |
| 793 | dev->urb[i] = urb; | ||
| 794 | } | 707 | } |
| 795 | 708 | ||
| 796 | /* submit urbs */ | 709 | init_waitqueue_head(&dma_q->wq); |
| 797 | em28xx_coredbg("Submitting %d urbs of %d packets (%d each)\n", | ||
| 798 | EM28XX_NUM_BUFS, EM28XX_NUM_PACKETS, dev->max_pkt_size); | ||
| 799 | for (i = 0; i < EM28XX_NUM_BUFS; i++) { | ||
| 800 | errCode = usb_submit_urb(dev->urb[i], GFP_KERNEL); | ||
| 801 | if (errCode) { | ||
| 802 | em28xx_errdev("submit of urb %i failed (error=%i)\n", i, | ||
| 803 | errCode); | ||
| 804 | em28xx_uninit_isoc(dev); | ||
| 805 | return errCode; | ||
| 806 | } | ||
| 807 | } | ||
| 808 | |||
| 809 | return 0; | ||
| 810 | } | ||
| 811 | |||
| 812 | int em28xx_set_alternate(struct em28xx *dev) | ||
| 813 | { | ||
| 814 | int errCode, prev_alt = dev->alt; | ||
| 815 | int i; | ||
| 816 | unsigned int min_pkt_size = dev->bytesperline+4; | ||
| 817 | |||
| 818 | /* When image size is bigger than a ceirtain value, | ||
| 819 | the frame size should be increased, otherwise, only | ||
| 820 | green screen will be received. | ||
| 821 | */ | ||
| 822 | if (dev->frame_size > 720*240*2) | ||
| 823 | min_pkt_size *= 2; | ||
| 824 | 710 | ||
| 825 | for (i = 0; i < dev->num_alt; i++) | 711 | em28xx_capture_start(dev, 1); |
| 826 | if (dev->alt_max_pkt_size[i] >= min_pkt_size) | ||
| 827 | break; | ||
| 828 | dev->alt = i; | ||
| 829 | 712 | ||
| 830 | if (dev->alt != prev_alt) { | 713 | /* submit urbs and enables IRQ */ |
| 831 | em28xx_coredbg("minimum isoc packet size: %u (alt=%d)\n", | 714 | for (i = 0; i < dev->isoc_ctl.num_bufs; i++) { |
| 832 | min_pkt_size, dev->alt); | 715 | rc = usb_submit_urb(dev->isoc_ctl.urb[i], GFP_ATOMIC); |
| 833 | dev->max_pkt_size = dev->alt_max_pkt_size[dev->alt]; | 716 | if (rc) { |
| 834 | em28xx_coredbg("setting alternate %d with wMaxPacketSize=%u\n", | 717 | em28xx_err("submit of urb %i failed (error=%i)\n", i, |
| 835 | dev->alt, dev->max_pkt_size); | 718 | rc); |
| 836 | errCode = usb_set_interface(dev->udev, 0, dev->alt); | 719 | em28xx_uninit_isoc(dev); |
| 837 | if (errCode < 0) { | 720 | return rc; |
| 838 | em28xx_errdev ("cannot change alternate number to %d (error=%i)\n", | ||
| 839 | dev->alt, errCode); | ||
| 840 | return errCode; | ||
| 841 | } | 721 | } |
| 842 | } | 722 | } |
| 723 | |||
| 843 | return 0; | 724 | return 0; |
| 844 | } | 725 | } |
| 726 | EXPORT_SYMBOL_GPL(em28xx_init_isoc); | ||
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c new file mode 100644 index 000000000000..7df81575b7f2 --- /dev/null +++ b/drivers/media/video/em28xx/em28xx-dvb.c | |||
| @@ -0,0 +1,474 @@ | |||
| 1 | /* | ||
| 2 | DVB device driver for em28xx | ||
| 3 | |||
| 4 | (c) 2008 Mauro Carvalho Chehab <mchehab@infradead.org> | ||
| 5 | |||
| 6 | (c) 2008 Devin Heitmueller <devin.heitmueller@gmail.com> | ||
| 7 | - Fixes for the driver to properly work with HVR-950 | ||
| 8 | |||
| 9 | (c) 2008 Aidan Thornton <makosoft@googlemail.com> | ||
| 10 | |||
| 11 | Based on cx88-dvb, saa7134-dvb and videobuf-dvb originally written by: | ||
| 12 | (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au> | ||
| 13 | (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] | ||
| 14 | |||
| 15 | This program is free software; you can redistribute it and/or modify | ||
| 16 | it under the terms of the GNU General Public License as published by | ||
| 17 | the Free Software Foundation; either version 2 of the License. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include <linux/kernel.h> | ||
| 21 | #include <linux/usb.h> | ||
| 22 | |||
| 23 | #include "em28xx.h" | ||
| 24 | #include <media/v4l2-common.h> | ||
| 25 | #include <media/videobuf-vmalloc.h> | ||
| 26 | |||
| 27 | #include "lgdt330x.h" | ||
| 28 | #include "zl10353.h" | ||
| 29 | |||
| 30 | MODULE_DESCRIPTION("driver for em28xx based DVB cards"); | ||
| 31 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); | ||
| 32 | MODULE_LICENSE("GPL"); | ||
| 33 | |||
| 34 | static unsigned int debug; | ||
| 35 | module_param(debug, int, 0644); | ||
| 36 | MODULE_PARM_DESC(debug, "enable debug messages [dvb]"); | ||
| 37 | |||
| 38 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 39 | |||
| 40 | #define dprintk(level, fmt, arg...) do { \ | ||
| 41 | if (debug >= level) \ | ||
| 42 | printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->name, ## arg); \ | ||
| 43 | } while (0) | ||
| 44 | |||
| 45 | #define EM28XX_DVB_NUM_BUFS 5 | ||
| 46 | #define EM28XX_DVB_MAX_PACKETSIZE 564 | ||
| 47 | #define EM28XX_DVB_MAX_PACKETS 64 | ||
| 48 | |||
| 49 | struct em28xx_dvb { | ||
| 50 | struct dvb_frontend *frontend; | ||
| 51 | |||
| 52 | /* feed count management */ | ||
| 53 | struct mutex lock; | ||
| 54 | int nfeeds; | ||
| 55 | |||
| 56 | /* general boilerplate stuff */ | ||
| 57 | struct dvb_adapter adapter; | ||
| 58 | struct dvb_demux demux; | ||
| 59 | struct dmxdev dmxdev; | ||
| 60 | struct dmx_frontend fe_hw; | ||
| 61 | struct dmx_frontend fe_mem; | ||
| 62 | struct dvb_net net; | ||
| 63 | }; | ||
| 64 | |||
| 65 | |||
| 66 | static inline void print_err_status(struct em28xx *dev, | ||
| 67 | int packet, int status) | ||
| 68 | { | ||
| 69 | char *errmsg = "Unknown"; | ||
| 70 | |||
| 71 | switch (status) { | ||
| 72 | case -ENOENT: | ||
| 73 | errmsg = "unlinked synchronuously"; | ||
| 74 | break; | ||
| 75 | case -ECONNRESET: | ||
| 76 | errmsg = "unlinked asynchronuously"; | ||
| 77 | break; | ||
| 78 | case -ENOSR: | ||
| 79 | errmsg = "Buffer error (overrun)"; | ||
| 80 | break; | ||
| 81 | case -EPIPE: | ||
| 82 | errmsg = "Stalled (device not responding)"; | ||
| 83 | break; | ||
| 84 | case -EOVERFLOW: | ||
| 85 | errmsg = "Babble (bad cable?)"; | ||
| 86 | break; | ||
| 87 | case -EPROTO: | ||
| 88 | errmsg = "Bit-stuff error (bad cable?)"; | ||
| 89 | break; | ||
| 90 | case -EILSEQ: | ||
| 91 | errmsg = "CRC/Timeout (could be anything)"; | ||
| 92 | break; | ||
| 93 | case -ETIME: | ||
| 94 | errmsg = "Device does not respond"; | ||
| 95 | break; | ||
| 96 | } | ||
| 97 | if (packet < 0) { | ||
| 98 | dprintk(1, "URB status %d [%s].\n", status, errmsg); | ||
| 99 | } else { | ||
| 100 | dprintk(1, "URB packet %d, status %d [%s].\n", | ||
| 101 | packet, status, errmsg); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | static inline int dvb_isoc_copy(struct em28xx *dev, struct urb *urb) | ||
| 106 | { | ||
| 107 | int i; | ||
| 108 | |||
| 109 | if (!dev) | ||
| 110 | return 0; | ||
| 111 | |||
| 112 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | ||
| 113 | return 0; | ||
| 114 | |||
| 115 | if (urb->status < 0) { | ||
| 116 | print_err_status(dev, -1, urb->status); | ||
| 117 | if (urb->status == -ENOENT) | ||
| 118 | return 0; | ||
| 119 | } | ||
| 120 | |||
| 121 | for (i = 0; i < urb->number_of_packets; i++) { | ||
| 122 | int status = urb->iso_frame_desc[i].status; | ||
| 123 | |||
| 124 | if (status < 0) { | ||
| 125 | print_err_status(dev, i, status); | ||
| 126 | if (urb->iso_frame_desc[i].status != -EPROTO) | ||
| 127 | continue; | ||
| 128 | } | ||
| 129 | |||
| 130 | dvb_dmx_swfilter(&dev->dvb->demux, urb->transfer_buffer + | ||
| 131 | urb->iso_frame_desc[i].offset, | ||
| 132 | urb->iso_frame_desc[i].actual_length); | ||
| 133 | } | ||
| 134 | |||
| 135 | return 0; | ||
| 136 | } | ||
| 137 | |||
| 138 | static int start_streaming(struct em28xx_dvb *dvb) | ||
| 139 | { | ||
| 140 | int rc; | ||
| 141 | struct em28xx *dev = dvb->adapter.priv; | ||
| 142 | |||
| 143 | usb_set_interface(dev->udev, 0, 1); | ||
| 144 | rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); | ||
| 145 | if (rc < 0) | ||
| 146 | return rc; | ||
| 147 | |||
| 148 | return em28xx_init_isoc(dev, EM28XX_DVB_MAX_PACKETS, | ||
| 149 | EM28XX_DVB_NUM_BUFS, EM28XX_DVB_MAX_PACKETSIZE, | ||
| 150 | dvb_isoc_copy); | ||
| 151 | } | ||
| 152 | |||
| 153 | static int stop_streaming(struct em28xx_dvb *dvb) | ||
| 154 | { | ||
| 155 | struct em28xx *dev = dvb->adapter.priv; | ||
| 156 | |||
| 157 | em28xx_uninit_isoc(dev); | ||
| 158 | |||
| 159 | em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED); | ||
| 160 | |||
| 161 | return 0; | ||
| 162 | } | ||
| 163 | |||
| 164 | static int start_feed(struct dvb_demux_feed *feed) | ||
| 165 | { | ||
| 166 | struct dvb_demux *demux = feed->demux; | ||
| 167 | struct em28xx_dvb *dvb = demux->priv; | ||
| 168 | int rc, ret; | ||
| 169 | |||
| 170 | if (!demux->dmx.frontend) | ||
| 171 | return -EINVAL; | ||
| 172 | |||
| 173 | mutex_lock(&dvb->lock); | ||
| 174 | dvb->nfeeds++; | ||
| 175 | rc = dvb->nfeeds; | ||
| 176 | |||
| 177 | if (dvb->nfeeds == 1) { | ||
| 178 | ret = start_streaming(dvb); | ||
| 179 | if (ret < 0) | ||
| 180 | rc = ret; | ||
| 181 | } | ||
| 182 | |||
| 183 | mutex_unlock(&dvb->lock); | ||
| 184 | return rc; | ||
| 185 | } | ||
| 186 | |||
| 187 | static int stop_feed(struct dvb_demux_feed *feed) | ||
| 188 | { | ||
| 189 | struct dvb_demux *demux = feed->demux; | ||
| 190 | struct em28xx_dvb *dvb = demux->priv; | ||
| 191 | int err = 0; | ||
| 192 | |||
| 193 | mutex_lock(&dvb->lock); | ||
| 194 | dvb->nfeeds--; | ||
| 195 | |||
| 196 | if (0 == dvb->nfeeds) | ||
| 197 | err = stop_streaming(dvb); | ||
| 198 | |||
| 199 | mutex_unlock(&dvb->lock); | ||
| 200 | return err; | ||
| 201 | } | ||
| 202 | |||
| 203 | |||
| 204 | |||
| 205 | /* ------------------------------------------------------------------ */ | ||
| 206 | static int em28xx_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) | ||
| 207 | { | ||
| 208 | struct em28xx *dev = fe->dvb->priv; | ||
| 209 | |||
| 210 | if (acquire) | ||
| 211 | return em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); | ||
| 212 | else | ||
| 213 | return em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED); | ||
| 214 | } | ||
| 215 | |||
| 216 | /* ------------------------------------------------------------------ */ | ||
| 217 | |||
| 218 | static struct lgdt330x_config em2880_lgdt3303_dev = { | ||
| 219 | .demod_address = 0x0e, | ||
| 220 | .demod_chip = LGDT3303, | ||
| 221 | }; | ||
| 222 | |||
| 223 | static struct zl10353_config em28xx_zl10353_with_xc3028 = { | ||
| 224 | .demod_address = (0x1e >> 1), | ||
| 225 | .no_tuner = 1, | ||
| 226 | .parallel_ts = 1, | ||
| 227 | .if2 = 45600, | ||
| 228 | }; | ||
| 229 | |||
| 230 | /* ------------------------------------------------------------------ */ | ||
| 231 | |||
| 232 | static int attach_xc3028(u8 addr, struct em28xx *dev) | ||
| 233 | { | ||
| 234 | struct dvb_frontend *fe; | ||
| 235 | struct xc2028_config cfg; | ||
| 236 | |||
| 237 | memset(&cfg, 0, sizeof(cfg)); | ||
| 238 | cfg.i2c_adap = &dev->i2c_adap; | ||
| 239 | cfg.i2c_addr = addr; | ||
| 240 | cfg.callback = em28xx_tuner_callback; | ||
| 241 | |||
| 242 | if (!dev->dvb->frontend) { | ||
| 243 | printk(KERN_ERR "%s/2: dvb frontend not attached. " | ||
| 244 | "Can't attach xc3028\n", | ||
| 245 | dev->name); | ||
| 246 | return -EINVAL; | ||
| 247 | } | ||
| 248 | |||
| 249 | fe = dvb_attach(xc2028_attach, dev->dvb->frontend, &cfg); | ||
| 250 | if (!fe) { | ||
| 251 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", | ||
| 252 | dev->name); | ||
| 253 | dvb_frontend_detach(dev->dvb->frontend); | ||
| 254 | dvb_unregister_frontend(dev->dvb->frontend); | ||
| 255 | dev->dvb->frontend = NULL; | ||
| 256 | return -EINVAL; | ||
| 257 | } | ||
| 258 | |||
| 259 | printk(KERN_INFO "%s/2: xc3028 attached\n", dev->name); | ||
| 260 | |||
| 261 | return 0; | ||
| 262 | } | ||
| 263 | |||
| 264 | /* ------------------------------------------------------------------ */ | ||
| 265 | |||
| 266 | int register_dvb(struct em28xx_dvb *dvb, | ||
| 267 | struct module *module, | ||
| 268 | struct em28xx *dev, | ||
| 269 | struct device *device) | ||
| 270 | { | ||
| 271 | int result; | ||
| 272 | |||
| 273 | mutex_init(&dvb->lock); | ||
| 274 | |||
| 275 | /* register adapter */ | ||
| 276 | result = dvb_register_adapter(&dvb->adapter, dev->name, module, device, | ||
| 277 | adapter_nr); | ||
| 278 | if (result < 0) { | ||
| 279 | printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", | ||
| 280 | dev->name, result); | ||
| 281 | goto fail_adapter; | ||
| 282 | } | ||
| 283 | |||
| 284 | /* Ensure all frontends negotiate bus access */ | ||
| 285 | dvb->frontend->ops.ts_bus_ctrl = em28xx_dvb_bus_ctrl; | ||
| 286 | |||
| 287 | dvb->adapter.priv = dev; | ||
| 288 | |||
| 289 | /* register frontend */ | ||
| 290 | result = dvb_register_frontend(&dvb->adapter, dvb->frontend); | ||
| 291 | if (result < 0) { | ||
| 292 | printk(KERN_WARNING "%s: dvb_register_frontend failed (errno = %d)\n", | ||
| 293 | dev->name, result); | ||
| 294 | goto fail_frontend; | ||
| 295 | } | ||
| 296 | |||
| 297 | /* register demux stuff */ | ||
| 298 | dvb->demux.dmx.capabilities = | ||
| 299 | DMX_TS_FILTERING | DMX_SECTION_FILTERING | | ||
| 300 | DMX_MEMORY_BASED_FILTERING; | ||
| 301 | dvb->demux.priv = dvb; | ||
| 302 | dvb->demux.filternum = 256; | ||
| 303 | dvb->demux.feednum = 256; | ||
| 304 | dvb->demux.start_feed = start_feed; | ||
| 305 | dvb->demux.stop_feed = stop_feed; | ||
| 306 | |||
| 307 | result = dvb_dmx_init(&dvb->demux); | ||
| 308 | if (result < 0) { | ||
| 309 | printk(KERN_WARNING "%s: dvb_dmx_init failed (errno = %d)\n", | ||
| 310 | dev->name, result); | ||
| 311 | goto fail_dmx; | ||
| 312 | } | ||
| 313 | |||
| 314 | dvb->dmxdev.filternum = 256; | ||
| 315 | dvb->dmxdev.demux = &dvb->demux.dmx; | ||
| 316 | dvb->dmxdev.capabilities = 0; | ||
| 317 | result = dvb_dmxdev_init(&dvb->dmxdev, &dvb->adapter); | ||
| 318 | if (result < 0) { | ||
| 319 | printk(KERN_WARNING "%s: dvb_dmxdev_init failed (errno = %d)\n", | ||
| 320 | dev->name, result); | ||
| 321 | goto fail_dmxdev; | ||
| 322 | } | ||
| 323 | |||
| 324 | dvb->fe_hw.source = DMX_FRONTEND_0; | ||
| 325 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
| 326 | if (result < 0) { | ||
| 327 | printk(KERN_WARNING "%s: add_frontend failed (DMX_FRONTEND_0, errno = %d)\n", | ||
| 328 | dev->name, result); | ||
| 329 | goto fail_fe_hw; | ||
| 330 | } | ||
| 331 | |||
| 332 | dvb->fe_mem.source = DMX_MEMORY_FE; | ||
| 333 | result = dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
| 334 | if (result < 0) { | ||
| 335 | printk(KERN_WARNING "%s: add_frontend failed (DMX_MEMORY_FE, errno = %d)\n", | ||
| 336 | dev->name, result); | ||
| 337 | goto fail_fe_mem; | ||
| 338 | } | ||
| 339 | |||
| 340 | result = dvb->demux.dmx.connect_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
| 341 | if (result < 0) { | ||
| 342 | printk(KERN_WARNING "%s: connect_frontend failed (errno = %d)\n", | ||
| 343 | dev->name, result); | ||
| 344 | goto fail_fe_conn; | ||
| 345 | } | ||
| 346 | |||
| 347 | /* register network adapter */ | ||
| 348 | dvb_net_init(&dvb->adapter, &dvb->net, &dvb->demux.dmx); | ||
| 349 | return 0; | ||
| 350 | |||
| 351 | fail_fe_conn: | ||
| 352 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
| 353 | fail_fe_mem: | ||
| 354 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
| 355 | fail_fe_hw: | ||
| 356 | dvb_dmxdev_release(&dvb->dmxdev); | ||
| 357 | fail_dmxdev: | ||
| 358 | dvb_dmx_release(&dvb->demux); | ||
| 359 | fail_dmx: | ||
| 360 | dvb_unregister_frontend(dvb->frontend); | ||
| 361 | fail_frontend: | ||
| 362 | dvb_frontend_detach(dvb->frontend); | ||
| 363 | dvb_unregister_adapter(&dvb->adapter); | ||
| 364 | fail_adapter: | ||
| 365 | return result; | ||
| 366 | } | ||
| 367 | |||
| 368 | static void unregister_dvb(struct em28xx_dvb *dvb) | ||
| 369 | { | ||
| 370 | dvb_net_release(&dvb->net); | ||
| 371 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_mem); | ||
| 372 | dvb->demux.dmx.remove_frontend(&dvb->demux.dmx, &dvb->fe_hw); | ||
| 373 | dvb_dmxdev_release(&dvb->dmxdev); | ||
| 374 | dvb_dmx_release(&dvb->demux); | ||
| 375 | dvb_unregister_frontend(dvb->frontend); | ||
| 376 | dvb_frontend_detach(dvb->frontend); | ||
| 377 | dvb_unregister_adapter(&dvb->adapter); | ||
| 378 | } | ||
| 379 | |||
| 380 | |||
| 381 | static int dvb_init(struct em28xx *dev) | ||
| 382 | { | ||
| 383 | int result = 0; | ||
| 384 | struct em28xx_dvb *dvb; | ||
| 385 | |||
| 386 | dvb = kzalloc(sizeof(struct em28xx_dvb), GFP_KERNEL); | ||
| 387 | |||
| 388 | if (dvb == NULL) { | ||
| 389 | printk(KERN_INFO "em28xx_dvb: memory allocation failed\n"); | ||
| 390 | return -ENOMEM; | ||
| 391 | } | ||
| 392 | dev->dvb = dvb; | ||
| 393 | |||
| 394 | em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); | ||
| 395 | /* init frontend */ | ||
| 396 | switch (dev->model) { | ||
| 397 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950: | ||
| 398 | dvb->frontend = dvb_attach(lgdt330x_attach, | ||
| 399 | &em2880_lgdt3303_dev, | ||
| 400 | &dev->i2c_adap); | ||
| 401 | if (attach_xc3028(0x61, dev) < 0) { | ||
| 402 | result = -EINVAL; | ||
| 403 | goto out_free; | ||
| 404 | } | ||
| 405 | break; | ||
| 406 | case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: | ||
| 407 | dvb->frontend = dvb_attach(zl10353_attach, | ||
| 408 | &em28xx_zl10353_with_xc3028, | ||
| 409 | &dev->i2c_adap); | ||
| 410 | if (attach_xc3028(0x61, dev) < 0) { | ||
| 411 | result = -EINVAL; | ||
| 412 | goto out_free; | ||
| 413 | } | ||
| 414 | break; | ||
| 415 | default: | ||
| 416 | printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card" | ||
| 417 | " isn't supported yet\n", | ||
| 418 | dev->name); | ||
| 419 | break; | ||
| 420 | } | ||
| 421 | if (NULL == dvb->frontend) { | ||
| 422 | printk(KERN_ERR | ||
| 423 | "%s/2: frontend initialization failed\n", | ||
| 424 | dev->name); | ||
| 425 | result = -EINVAL; | ||
| 426 | goto out_free; | ||
| 427 | } | ||
| 428 | |||
| 429 | /* register everything */ | ||
| 430 | result = register_dvb(dvb, THIS_MODULE, dev, &dev->udev->dev); | ||
| 431 | |||
| 432 | if (result < 0) | ||
| 433 | goto out_free; | ||
| 434 | |||
| 435 | em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED); | ||
| 436 | printk(KERN_INFO "Successfully loaded em28xx-dvb\n"); | ||
| 437 | return 0; | ||
| 438 | |||
| 439 | out_free: | ||
| 440 | em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED); | ||
| 441 | kfree(dvb); | ||
| 442 | dev->dvb = NULL; | ||
| 443 | return result; | ||
| 444 | } | ||
| 445 | |||
| 446 | static int dvb_fini(struct em28xx *dev) | ||
| 447 | { | ||
| 448 | if (dev->dvb) { | ||
| 449 | unregister_dvb(dev->dvb); | ||
| 450 | dev->dvb = NULL; | ||
| 451 | } | ||
| 452 | |||
| 453 | return 0; | ||
| 454 | } | ||
| 455 | |||
| 456 | static struct em28xx_ops dvb_ops = { | ||
| 457 | .id = EM28XX_DVB, | ||
| 458 | .name = "Em28xx dvb Extension", | ||
| 459 | .init = dvb_init, | ||
| 460 | .fini = dvb_fini, | ||
| 461 | }; | ||
| 462 | |||
| 463 | static int __init em28xx_dvb_register(void) | ||
| 464 | { | ||
| 465 | return em28xx_register_extension(&dvb_ops); | ||
| 466 | } | ||
| 467 | |||
| 468 | static void __exit em28xx_dvb_unregister(void) | ||
| 469 | { | ||
| 470 | em28xx_unregister_extension(&dvb_ops); | ||
| 471 | } | ||
| 472 | |||
| 473 | module_init(em28xx_dvb_register); | ||
| 474 | module_exit(em28xx_dvb_unregister); | ||
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c index cacd04d46e99..6a78fd294cab 100644 --- a/drivers/media/video/em28xx/em28xx-i2c.c +++ b/drivers/media/video/em28xx/em28xx-i2c.c | |||
| @@ -33,19 +33,29 @@ | |||
| 33 | 33 | ||
| 34 | /* ----------------------------------------------------------- */ | 34 | /* ----------------------------------------------------------- */ |
| 35 | 35 | ||
| 36 | static unsigned int i2c_scan = 0; | 36 | static unsigned int i2c_scan; |
| 37 | module_param(i2c_scan, int, 0444); | 37 | module_param(i2c_scan, int, 0444); |
| 38 | MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); | 38 | MODULE_PARM_DESC(i2c_scan, "scan i2c bus at insmod time"); |
| 39 | 39 | ||
| 40 | static unsigned int i2c_debug = 0; | 40 | static unsigned int i2c_debug; |
| 41 | module_param(i2c_debug, int, 0644); | 41 | module_param(i2c_debug, int, 0644); |
| 42 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); | 42 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); |
| 43 | 43 | ||
| 44 | #define dprintk1(lvl,fmt, args...) if (i2c_debug>=lvl) do {\ | 44 | |
| 45 | printk(fmt, ##args); } while (0) | 45 | #define dprintk1(lvl, fmt, args...) \ |
| 46 | #define dprintk2(lvl,fmt, args...) if (i2c_debug>=lvl) do{ \ | 46 | do { \ |
| 47 | printk(KERN_DEBUG "%s at %s: " fmt, \ | 47 | if (i2c_debug >= lvl) { \ |
| 48 | dev->name, __FUNCTION__ , ##args); } while (0) | 48 | printk(fmt, ##args); \ |
| 49 | } \ | ||
| 50 | } while (0) | ||
| 51 | |||
| 52 | #define dprintk2(lvl, fmt, args...) \ | ||
| 53 | do { \ | ||
| 54 | if (i2c_debug >= lvl) { \ | ||
| 55 | printk(KERN_DEBUG "%s at %s: " fmt, \ | ||
| 56 | dev->name, __func__ , ##args); \ | ||
| 57 | } \ | ||
| 58 | } while (0) | ||
| 49 | 59 | ||
| 50 | /* | 60 | /* |
| 51 | * em2800_i2c_send_max4() | 61 | * em2800_i2c_send_max4() |
| @@ -235,16 +245,16 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
| 235 | return 0; | 245 | return 0; |
| 236 | for (i = 0; i < num; i++) { | 246 | for (i = 0; i < num; i++) { |
| 237 | addr = msgs[i].addr << 1; | 247 | addr = msgs[i].addr << 1; |
| 238 | dprintk2(2,"%s %s addr=%x len=%d:", | 248 | dprintk2(2, "%s %s addr=%x len=%d:", |
| 239 | (msgs[i].flags & I2C_M_RD) ? "read" : "write", | 249 | (msgs[i].flags & I2C_M_RD) ? "read" : "write", |
| 240 | i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len); | 250 | i == num - 1 ? "stop" : "nonstop", addr, msgs[i].len); |
| 241 | if (!msgs[i].len) { /* no len: check only for device presence */ | 251 | if (!msgs[i].len) { /* no len: check only for device presence */ |
| 242 | if (dev->is_em2800) | 252 | if (dev->is_em2800) |
| 243 | rc = em2800_i2c_check_for_device(dev, addr); | 253 | rc = em2800_i2c_check_for_device(dev, addr); |
| 244 | else | 254 | else |
| 245 | rc = em28xx_i2c_check_for_device(dev, addr); | 255 | rc = em28xx_i2c_check_for_device(dev, addr); |
| 246 | if (rc < 0) { | 256 | if (rc < 0) { |
| 247 | dprintk2(2," no device\n"); | 257 | dprintk2(2, " no device\n"); |
| 248 | return rc; | 258 | return rc; |
| 249 | } | 259 | } |
| 250 | 260 | ||
| @@ -258,14 +268,13 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
| 258 | rc = em28xx_i2c_recv_bytes(dev, addr, | 268 | rc = em28xx_i2c_recv_bytes(dev, addr, |
| 259 | msgs[i].buf, | 269 | msgs[i].buf, |
| 260 | msgs[i].len); | 270 | msgs[i].len); |
| 261 | if (i2c_debug>=2) { | 271 | if (i2c_debug >= 2) { |
| 262 | for (byte = 0; byte < msgs[i].len; byte++) { | 272 | for (byte = 0; byte < msgs[i].len; byte++) |
| 263 | printk(" %02x", msgs[i].buf[byte]); | 273 | printk(" %02x", msgs[i].buf[byte]); |
| 264 | } | ||
| 265 | } | 274 | } |
| 266 | } else { | 275 | } else { |
| 267 | /* write bytes */ | 276 | /* write bytes */ |
| 268 | if (i2c_debug>=2) { | 277 | if (i2c_debug >= 2) { |
| 269 | for (byte = 0; byte < msgs[i].len; byte++) | 278 | for (byte = 0; byte < msgs[i].len; byte++) |
| 270 | printk(" %02x", msgs[i].buf[byte]); | 279 | printk(" %02x", msgs[i].buf[byte]); |
| 271 | } | 280 | } |
| @@ -281,13 +290,13 @@ static int em28xx_i2c_xfer(struct i2c_adapter *i2c_adap, | |||
| 281 | } | 290 | } |
| 282 | if (rc < 0) | 291 | if (rc < 0) |
| 283 | goto err; | 292 | goto err; |
| 284 | if (i2c_debug>=2) | 293 | if (i2c_debug >= 2) |
| 285 | printk("\n"); | 294 | printk("\n"); |
| 286 | } | 295 | } |
| 287 | 296 | ||
| 288 | return num; | 297 | return num; |
| 289 | err: | 298 | err: |
| 290 | dprintk2(2," ERROR: %i\n", rc); | 299 | dprintk2(2, " ERROR: %i\n", rc); |
| 291 | return rc; | 300 | return rc; |
| 292 | } | 301 | } |
| 293 | 302 | ||
| @@ -330,7 +339,9 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) | |||
| 330 | return -1; | 339 | return -1; |
| 331 | 340 | ||
| 332 | buf = 0; | 341 | buf = 0; |
| 333 | if (1 != (err = i2c_master_send(&dev->i2c_client, &buf, 1))) { | 342 | |
| 343 | err = i2c_master_send(&dev->i2c_client, &buf, 1); | ||
| 344 | if (err != 1) { | ||
| 334 | printk(KERN_INFO "%s: Huh, no eeprom present (err=%d)?\n", | 345 | printk(KERN_INFO "%s: Huh, no eeprom present (err=%d)?\n", |
| 335 | dev->name, err); | 346 | dev->name, err); |
| 336 | return -1; | 347 | return -1; |
| @@ -403,8 +414,10 @@ static int em28xx_i2c_eeprom(struct em28xx *dev, unsigned char *eedata, int len) | |||
| 403 | break; | 414 | break; |
| 404 | } | 415 | } |
| 405 | printk(KERN_INFO "Table at 0x%02x, strings=0x%04x, 0x%04x, 0x%04x\n", | 416 | printk(KERN_INFO "Table at 0x%02x, strings=0x%04x, 0x%04x, 0x%04x\n", |
| 406 | em_eeprom->string_idx_table,em_eeprom->string1, | 417 | em_eeprom->string_idx_table, |
| 407 | em_eeprom->string2,em_eeprom->string3); | 418 | em_eeprom->string1, |
| 419 | em_eeprom->string2, | ||
| 420 | em_eeprom->string3); | ||
| 408 | 421 | ||
| 409 | return 0; | 422 | return 0; |
| 410 | } | 423 | } |
| @@ -430,58 +443,61 @@ static int attach_inform(struct i2c_client *client) | |||
| 430 | struct em28xx *dev = client->adapter->algo_data; | 443 | struct em28xx *dev = client->adapter->algo_data; |
| 431 | 444 | ||
| 432 | switch (client->addr << 1) { | 445 | switch (client->addr << 1) { |
| 433 | case 0x86: | 446 | case 0x86: |
| 434 | case 0x84: | 447 | case 0x84: |
| 435 | case 0x96: | 448 | case 0x96: |
| 436 | case 0x94: | 449 | case 0x94: |
| 437 | { | 450 | { |
| 438 | struct v4l2_priv_tun_config tda9887_cfg; | 451 | struct v4l2_priv_tun_config tda9887_cfg; |
| 439 | 452 | ||
| 440 | struct tuner_setup tun_setup; | 453 | struct tuner_setup tun_setup; |
| 441 | 454 | ||
| 442 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; | 455 | tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; |
| 443 | tun_setup.type = TUNER_TDA9887; | 456 | tun_setup.type = TUNER_TDA9887; |
| 444 | tun_setup.addr = client->addr; | 457 | tun_setup.addr = client->addr; |
| 445 | 458 | ||
| 446 | em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); | 459 | em28xx_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, |
| 447 | 460 | &tun_setup); | |
| 448 | tda9887_cfg.tuner = TUNER_TDA9887; | 461 | |
| 449 | tda9887_cfg.priv = &dev->tda9887_conf; | 462 | tda9887_cfg.tuner = TUNER_TDA9887; |
| 450 | em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, | 463 | tda9887_cfg.priv = &dev->tda9887_conf; |
| 451 | &tda9887_cfg); | 464 | em28xx_i2c_call_clients(dev, TUNER_SET_CONFIG, |
| 452 | break; | 465 | &tda9887_cfg); |
| 453 | } | 466 | break; |
| 454 | case 0x42: | 467 | } |
| 455 | dprintk1(1,"attach_inform: saa7114 detected.\n"); | 468 | case 0x42: |
| 456 | break; | 469 | dprintk1(1, "attach_inform: saa7114 detected.\n"); |
| 457 | case 0x4a: | 470 | break; |
| 458 | dprintk1(1,"attach_inform: saa7113 detected.\n"); | 471 | case 0x4a: |
| 459 | break; | 472 | dprintk1(1, "attach_inform: saa7113 detected.\n"); |
| 460 | case 0xa0: | 473 | break; |
| 461 | dprintk1(1,"attach_inform: eeprom detected.\n"); | 474 | case 0xa0: |
| 462 | break; | 475 | dprintk1(1, "attach_inform: eeprom detected.\n"); |
| 463 | case 0x60: | 476 | break; |
| 464 | case 0x8e: | 477 | case 0x60: |
| 465 | { | 478 | case 0x8e: |
| 466 | struct IR_i2c *ir = i2c_get_clientdata(client); | 479 | { |
| 467 | dprintk1(1,"attach_inform: IR detected (%s).\n",ir->phys); | 480 | struct IR_i2c *ir = i2c_get_clientdata(client); |
| 468 | em28xx_set_ir(dev,ir); | 481 | dprintk1(1, "attach_inform: IR detected (%s).\n", |
| 469 | break; | 482 | ir->phys); |
| 470 | } | 483 | em28xx_set_ir(dev, ir); |
| 471 | case 0x80: | 484 | break; |
| 472 | case 0x88: | 485 | } |
| 473 | dprintk1(1,"attach_inform: msp34xx detected.\n"); | 486 | case 0x80: |
| 474 | break; | 487 | case 0x88: |
| 475 | case 0xb8: | 488 | dprintk1(1, "attach_inform: msp34xx detected.\n"); |
| 476 | case 0xba: | 489 | break; |
| 477 | dprintk1(1,"attach_inform: tvp5150 detected.\n"); | 490 | case 0xb8: |
| 478 | break; | 491 | case 0xba: |
| 479 | 492 | dprintk1(1, "attach_inform: tvp5150 detected.\n"); | |
| 480 | default: | 493 | break; |
| 481 | if (!dev->tuner_addr) | 494 | |
| 482 | dev->tuner_addr = client->addr; | 495 | default: |
| 483 | 496 | if (!dev->tuner_addr) | |
| 484 | dprintk1(1,"attach inform: detected I2C address %x\n", client->addr << 1); | 497 | dev->tuner_addr = client->addr; |
| 498 | |||
| 499 | dprintk1(1, "attach inform: detected I2C address %x\n", | ||
| 500 | client->addr << 1); | ||
| 485 | 501 | ||
| 486 | } | 502 | } |
| 487 | 503 | ||
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c index 10da2fd8d987..bb5807159b8d 100644 --- a/drivers/media/video/em28xx/em28xx-input.c +++ b/drivers/media/video/em28xx/em28xx-input.c | |||
| @@ -32,10 +32,12 @@ | |||
| 32 | 32 | ||
| 33 | static unsigned int ir_debug; | 33 | static unsigned int ir_debug; |
| 34 | module_param(ir_debug, int, 0644); | 34 | module_param(ir_debug, int, 0644); |
| 35 | MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]"); | 35 | MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]"); |
| 36 | 36 | ||
| 37 | #define dprintk(fmt, arg...) if (ir_debug) \ | 37 | #define dprintk(fmt, arg...) \ |
| 38 | printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg) | 38 | if (ir_debug) { \ |
| 39 | printk(KERN_DEBUG "%s/ir: " fmt, ir->c.name , ## arg); \ | ||
| 40 | } | ||
| 39 | 41 | ||
| 40 | /* ----------------------------------------------------------------------- */ | 42 | /* ----------------------------------------------------------------------- */ |
| 41 | 43 | ||
| @@ -44,7 +46,7 @@ int em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
| 44 | unsigned char b; | 46 | unsigned char b; |
| 45 | 47 | ||
| 46 | /* poll IR chip */ | 48 | /* poll IR chip */ |
| 47 | if (1 != i2c_master_recv(&ir->c,&b,1)) { | 49 | if (1 != i2c_master_recv(&ir->c, &b, 1)) { |
| 48 | dprintk("read error\n"); | 50 | dprintk("read error\n"); |
| 49 | return -EIO; | 51 | return -EIO; |
| 50 | } | 52 | } |
| @@ -74,24 +76,25 @@ int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
| 74 | unsigned char code; | 76 | unsigned char code; |
| 75 | 77 | ||
| 76 | /* poll IR chip */ | 78 | /* poll IR chip */ |
| 77 | if (2 != i2c_master_recv(&ir->c,buf,2)) | 79 | if (2 != i2c_master_recv(&ir->c, buf, 2)) |
| 78 | return -EIO; | 80 | return -EIO; |
| 79 | 81 | ||
| 80 | /* Does eliminate repeated parity code */ | 82 | /* Does eliminate repeated parity code */ |
| 81 | if (buf[1]==0xff) | 83 | if (buf[1] == 0xff) |
| 82 | return 0; | 84 | return 0; |
| 83 | 85 | ||
| 84 | ir->old=buf[1]; | 86 | ir->old = buf[1]; |
| 85 | 87 | ||
| 86 | /* Rearranges bits to the right order */ | 88 | /* Rearranges bits to the right order */ |
| 87 | code= ((buf[0]&0x01)<<5) | /* 0010 0000 */ | 89 | code = ((buf[0]&0x01)<<5) | /* 0010 0000 */ |
| 88 | ((buf[0]&0x02)<<3) | /* 0001 0000 */ | 90 | ((buf[0]&0x02)<<3) | /* 0001 0000 */ |
| 89 | ((buf[0]&0x04)<<1) | /* 0000 1000 */ | 91 | ((buf[0]&0x04)<<1) | /* 0000 1000 */ |
| 90 | ((buf[0]&0x08)>>1) | /* 0000 0100 */ | 92 | ((buf[0]&0x08)>>1) | /* 0000 0100 */ |
| 91 | ((buf[0]&0x10)>>3) | /* 0000 0010 */ | 93 | ((buf[0]&0x10)>>3) | /* 0000 0010 */ |
| 92 | ((buf[0]&0x20)>>5); /* 0000 0001 */ | 94 | ((buf[0]&0x20)>>5); /* 0000 0001 */ |
| 93 | 95 | ||
| 94 | dprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x)\n",code,buf[0]); | 96 | dprintk("ir hauppauge (em2840): code=0x%02x (rcv=0x%02x)\n", |
| 97 | code, buf[0]); | ||
| 95 | 98 | ||
| 96 | /* return key */ | 99 | /* return key */ |
| 97 | *ir_key = code; | 100 | *ir_key = code; |
| @@ -106,15 +109,14 @@ int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key, | |||
| 106 | 109 | ||
| 107 | /* poll IR chip */ | 110 | /* poll IR chip */ |
| 108 | 111 | ||
| 109 | if (3 != i2c_master_recv(&ir->c,buf,3)) { | 112 | if (3 != i2c_master_recv(&ir->c, buf, 3)) { |
| 110 | dprintk("read error\n"); | 113 | dprintk("read error\n"); |
| 111 | return -EIO; | 114 | return -EIO; |
| 112 | } | 115 | } |
| 113 | 116 | ||
| 114 | dprintk("key %02x\n", buf[2]&0x3f); | 117 | dprintk("key %02x\n", buf[2]&0x3f); |
| 115 | if (buf[0]!=0x00){ | 118 | if (buf[0] != 0x00) |
| 116 | return 0; | 119 | return 0; |
| 117 | } | ||
| 118 | 120 | ||
| 119 | *ir_key = buf[2]&0x3f; | 121 | *ir_key = buf[2]&0x3f; |
| 120 | *ir_raw = buf[2]&0x3f; | 122 | *ir_raw = buf[2]&0x3f; |
diff --git a/drivers/media/video/em28xx/em28xx-reg.h b/drivers/media/video/em28xx/em28xx-reg.h new file mode 100644 index 000000000000..9058bed07953 --- /dev/null +++ b/drivers/media/video/em28xx/em28xx-reg.h | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | #define EM_GPIO_0 (1 << 0) | ||
| 2 | #define EM_GPIO_1 (1 << 1) | ||
| 3 | #define EM_GPIO_2 (1 << 2) | ||
| 4 | #define EM_GPIO_3 (1 << 3) | ||
| 5 | #define EM_GPIO_4 (1 << 4) | ||
| 6 | #define EM_GPIO_5 (1 << 5) | ||
| 7 | #define EM_GPIO_6 (1 << 6) | ||
| 8 | #define EM_GPIO_7 (1 << 7) | ||
| 9 | |||
| 10 | #define EM_GPO_0 (1 << 0) | ||
| 11 | #define EM_GPO_1 (1 << 1) | ||
| 12 | #define EM_GPO_2 (1 << 2) | ||
| 13 | #define EM_GPO_3 (1 << 3) | ||
| 14 | |||
| 15 | /* em2800 registers */ | ||
| 16 | #define EM2800_R08_AUDIOSRC 0x08 | ||
| 17 | |||
| 18 | /* em28xx registers */ | ||
| 19 | |||
| 20 | /* GPIO/GPO registers */ | ||
| 21 | #define EM2880_R04_GPO 0x04 /* em2880-em2883 only */ | ||
| 22 | #define EM28XX_R08_GPIO 0x08 /* em2820 or upper */ | ||
| 23 | |||
| 24 | #define EM28XX_R06_I2C_CLK 0x06 | ||
| 25 | #define EM28XX_R0A_CHIPID 0x0a | ||
| 26 | #define EM28XX_R0C_USBSUSP 0x0c /* */ | ||
| 27 | |||
| 28 | #define EM28XX_R0E_AUDIOSRC 0x0e | ||
| 29 | #define EM28XX_R0F_XCLK 0x0f | ||
| 30 | |||
| 31 | #define EM28XX_R10_VINMODE 0x10 | ||
| 32 | #define EM28XX_R11_VINCTRL 0x11 | ||
| 33 | #define EM28XX_R12_VINENABLE 0x12 /* */ | ||
| 34 | |||
| 35 | #define EM28XX_R14_GAMMA 0x14 | ||
| 36 | #define EM28XX_R15_RGAIN 0x15 | ||
| 37 | #define EM28XX_R16_GGAIN 0x16 | ||
| 38 | #define EM28XX_R17_BGAIN 0x17 | ||
| 39 | #define EM28XX_R18_ROFFSET 0x18 | ||
| 40 | #define EM28XX_R19_GOFFSET 0x19 | ||
| 41 | #define EM28XX_R1A_BOFFSET 0x1a | ||
| 42 | |||
| 43 | #define EM28XX_R1B_OFLOW 0x1b | ||
| 44 | #define EM28XX_R1C_HSTART 0x1c | ||
| 45 | #define EM28XX_R1D_VSTART 0x1d | ||
| 46 | #define EM28XX_R1E_CWIDTH 0x1e | ||
| 47 | #define EM28XX_R1F_CHEIGHT 0x1f | ||
| 48 | |||
| 49 | #define EM28XX_R20_YGAIN 0x20 | ||
| 50 | #define EM28XX_R21_YOFFSET 0x21 | ||
| 51 | #define EM28XX_R22_UVGAIN 0x22 | ||
| 52 | #define EM28XX_R23_UOFFSET 0x23 | ||
| 53 | #define EM28XX_R24_VOFFSET 0x24 | ||
| 54 | #define EM28XX_R25_SHARPNESS 0x25 | ||
| 55 | |||
| 56 | #define EM28XX_R26_COMPR 0x26 | ||
| 57 | #define EM28XX_R27_OUTFMT 0x27 | ||
| 58 | |||
| 59 | #define EM28XX_R28_XMIN 0x28 | ||
| 60 | #define EM28XX_R29_XMAX 0x29 | ||
| 61 | #define EM28XX_R2A_YMIN 0x2a | ||
| 62 | #define EM28XX_R2B_YMAX 0x2b | ||
| 63 | |||
| 64 | #define EM28XX_R30_HSCALELOW 0x30 | ||
| 65 | #define EM28XX_R31_HSCALEHIGH 0x31 | ||
| 66 | #define EM28XX_R32_VSCALELOW 0x32 | ||
| 67 | #define EM28XX_R33_VSCALEHIGH 0x33 | ||
| 68 | |||
| 69 | #define EM28XX_R40_AC97LSB 0x40 | ||
| 70 | #define EM28XX_R41_AC97MSB 0x41 | ||
| 71 | #define EM28XX_R42_AC97ADDR 0x42 | ||
| 72 | #define EM28XX_R43_AC97BUSY 0x43 | ||
| 73 | |||
| 74 | /* em202 registers */ | ||
| 75 | #define EM28XX_R02_MASTER_AC97 0x02 | ||
| 76 | #define EM28XX_R10_LINE_IN_AC97 0x10 | ||
| 77 | #define EM28XX_R14_VIDEO_AC97 0x14 | ||
| 78 | |||
| 79 | /* register settings */ | ||
| 80 | #define EM2800_AUDIO_SRC_TUNER 0x0d | ||
| 81 | #define EM2800_AUDIO_SRC_LINE 0x0c | ||
| 82 | #define EM28XX_AUDIO_SRC_TUNER 0xc0 | ||
| 83 | #define EM28XX_AUDIO_SRC_LINE 0x80 | ||
| 84 | |||
| 85 | /* FIXME: Need to be populated with the other chip ID's */ | ||
| 86 | enum em28xx_chip_id { | ||
| 87 | CHIP_ID_EM2883 = 36, | ||
| 88 | }; | ||
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index 4abe6701a770..8996175cc950 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | em28xx-video.c - driver for Empia EM2800/EM2820/2840 USB video capture devices | 2 | em28xx-video.c - driver for Empia EM2800/EM2820/2840 USB |
| 3 | video capture devices | ||
| 3 | 4 | ||
| 4 | Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it> | 5 | Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it> |
| 5 | Markus Rechberger <mrechberger@gmail.com> | 6 | Markus Rechberger <mrechberger@gmail.com> |
| @@ -52,7 +53,19 @@ | |||
| 52 | #define em28xx_videodbg(fmt, arg...) do {\ | 53 | #define em28xx_videodbg(fmt, arg...) do {\ |
| 53 | if (video_debug) \ | 54 | if (video_debug) \ |
| 54 | printk(KERN_INFO "%s %s :"fmt, \ | 55 | printk(KERN_INFO "%s %s :"fmt, \ |
| 55 | dev->name, __FUNCTION__ , ##arg); } while (0) | 56 | dev->name, __func__ , ##arg); } while (0) |
| 57 | |||
| 58 | static unsigned int isoc_debug; | ||
| 59 | module_param(isoc_debug, int, 0644); | ||
| 60 | MODULE_PARM_DESC(isoc_debug, "enable debug messages [isoc transfers]"); | ||
| 61 | |||
| 62 | #define em28xx_isocdbg(fmt, arg...) \ | ||
| 63 | do {\ | ||
| 64 | if (isoc_debug) { \ | ||
| 65 | printk(KERN_INFO "%s %s :"fmt, \ | ||
| 66 | dev->name, __func__ , ##arg); \ | ||
| 67 | } \ | ||
| 68 | } while (0) | ||
| 56 | 69 | ||
| 57 | MODULE_AUTHOR(DRIVER_AUTHOR); | 70 | MODULE_AUTHOR(DRIVER_AUTHOR); |
| 58 | MODULE_DESCRIPTION(DRIVER_DESC); | 71 | MODULE_DESCRIPTION(DRIVER_DESC); |
| @@ -74,9 +87,9 @@ MODULE_PARM_DESC(video_nr, "video device numbers"); | |||
| 74 | MODULE_PARM_DESC(vbi_nr, "vbi device numbers"); | 87 | MODULE_PARM_DESC(vbi_nr, "vbi device numbers"); |
| 75 | MODULE_PARM_DESC(radio_nr, "radio device numbers"); | 88 | MODULE_PARM_DESC(radio_nr, "radio device numbers"); |
| 76 | 89 | ||
| 77 | static unsigned int video_debug = 0; | 90 | static unsigned int video_debug; |
| 78 | module_param(video_debug,int,0644); | 91 | module_param(video_debug, int, 0644); |
| 79 | MODULE_PARM_DESC(video_debug,"enable debug messages [video]"); | 92 | MODULE_PARM_DESC(video_debug, "enable debug messages [video]"); |
| 80 | 93 | ||
| 81 | /* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS */ | 94 | /* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS */ |
| 82 | static unsigned long em28xx_devused; | 95 | static unsigned long em28xx_devused; |
| @@ -93,7 +106,7 @@ static struct v4l2_queryctrl em28xx_qctrl[] = { | |||
| 93 | .step = 0x1, | 106 | .step = 0x1, |
| 94 | .default_value = 0x1f, | 107 | .default_value = 0x1f, |
| 95 | .flags = 0, | 108 | .flags = 0, |
| 96 | },{ | 109 | }, { |
| 97 | .id = V4L2_CID_AUDIO_MUTE, | 110 | .id = V4L2_CID_AUDIO_MUTE, |
| 98 | .type = V4L2_CTRL_TYPE_BOOLEAN, | 111 | .type = V4L2_CTRL_TYPE_BOOLEAN, |
| 99 | .name = "Mute", | 112 | .name = "Mute", |
| @@ -107,8 +120,391 @@ static struct v4l2_queryctrl em28xx_qctrl[] = { | |||
| 107 | 120 | ||
| 108 | static struct usb_driver em28xx_usb_driver; | 121 | static struct usb_driver em28xx_usb_driver; |
| 109 | 122 | ||
| 123 | /* ------------------------------------------------------------------ | ||
| 124 | DMA and thread functions | ||
| 125 | ------------------------------------------------------------------*/ | ||
| 126 | |||
| 127 | /* | ||
| 128 | * Announces that a buffer were filled and request the next | ||
| 129 | */ | ||
| 130 | static inline void buffer_filled(struct em28xx *dev, | ||
| 131 | struct em28xx_dmaqueue *dma_q, | ||
| 132 | struct em28xx_buffer *buf) | ||
| 133 | { | ||
| 134 | /* Advice that buffer was filled */ | ||
| 135 | em28xx_isocdbg("[%p/%d] wakeup\n", buf, buf->vb.i); | ||
| 136 | buf->vb.state = VIDEOBUF_DONE; | ||
| 137 | buf->vb.field_count++; | ||
| 138 | do_gettimeofday(&buf->vb.ts); | ||
| 110 | 139 | ||
| 111 | /********************* v4l2 interface ******************************************/ | 140 | dev->isoc_ctl.buf = NULL; |
| 141 | |||
| 142 | list_del(&buf->vb.queue); | ||
| 143 | wake_up(&buf->vb.done); | ||
| 144 | } | ||
| 145 | |||
| 146 | /* | ||
| 147 | * Identify the buffer header type and properly handles | ||
| 148 | */ | ||
| 149 | static void em28xx_copy_video(struct em28xx *dev, | ||
| 150 | struct em28xx_dmaqueue *dma_q, | ||
| 151 | struct em28xx_buffer *buf, | ||
| 152 | unsigned char *p, | ||
| 153 | unsigned char *outp, unsigned long len) | ||
| 154 | { | ||
| 155 | void *fieldstart, *startwrite, *startread; | ||
| 156 | int linesdone, currlinedone, offset, lencopy, remain; | ||
| 157 | int bytesperline = dev->width << 1; | ||
| 158 | |||
| 159 | if (dma_q->pos + len > buf->vb.size) | ||
| 160 | len = buf->vb.size - dma_q->pos; | ||
| 161 | |||
| 162 | if (p[0] != 0x88 && p[0] != 0x22) { | ||
| 163 | em28xx_isocdbg("frame is not complete\n"); | ||
| 164 | len += 4; | ||
| 165 | } else | ||
| 166 | p += 4; | ||
| 167 | |||
| 168 | startread = p; | ||
| 169 | remain = len; | ||
| 170 | |||
| 171 | /* Interlaces frame */ | ||
| 172 | if (buf->top_field) | ||
| 173 | fieldstart = outp; | ||
| 174 | else | ||
| 175 | fieldstart = outp + bytesperline; | ||
| 176 | |||
| 177 | linesdone = dma_q->pos / bytesperline; | ||
| 178 | currlinedone = dma_q->pos % bytesperline; | ||
| 179 | offset = linesdone * bytesperline * 2 + currlinedone; | ||
| 180 | startwrite = fieldstart + offset; | ||
| 181 | lencopy = bytesperline - currlinedone; | ||
| 182 | lencopy = lencopy > remain ? remain : lencopy; | ||
| 183 | |||
| 184 | if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) { | ||
| 185 | em28xx_isocdbg("Overflow of %zi bytes past buffer end (1)\n", | ||
| 186 | ((char *)startwrite + lencopy) - | ||
| 187 | ((char *)outp + buf->vb.size)); | ||
| 188 | lencopy = remain = (char *)outp + buf->vb.size - (char *)startwrite; | ||
| 189 | } | ||
| 190 | if (lencopy <= 0) | ||
| 191 | return; | ||
| 192 | memcpy(startwrite, startread, lencopy); | ||
| 193 | |||
| 194 | remain -= lencopy; | ||
| 195 | |||
| 196 | while (remain > 0) { | ||
| 197 | startwrite += lencopy + bytesperline; | ||
| 198 | startread += lencopy; | ||
| 199 | if (bytesperline > remain) | ||
| 200 | lencopy = remain; | ||
| 201 | else | ||
| 202 | lencopy = bytesperline; | ||
| 203 | |||
| 204 | if ((char *)startwrite + lencopy > (char *)outp + buf->vb.size) { | ||
| 205 | em28xx_isocdbg("Overflow of %zi bytes past buffer end (2)\n", | ||
| 206 | ((char *)startwrite + lencopy) - | ||
| 207 | ((char *)outp + buf->vb.size)); | ||
| 208 | lencopy = remain = (char *)outp + buf->vb.size - | ||
| 209 | (char *)startwrite; | ||
| 210 | } | ||
| 211 | if (lencopy <= 0) | ||
| 212 | break; | ||
| 213 | |||
| 214 | memcpy(startwrite, startread, lencopy); | ||
| 215 | |||
| 216 | remain -= lencopy; | ||
| 217 | } | ||
| 218 | |||
| 219 | dma_q->pos += len; | ||
| 220 | } | ||
| 221 | |||
| 222 | static inline void print_err_status(struct em28xx *dev, | ||
| 223 | int packet, int status) | ||
| 224 | { | ||
| 225 | char *errmsg = "Unknown"; | ||
| 226 | |||
| 227 | switch (status) { | ||
| 228 | case -ENOENT: | ||
| 229 | errmsg = "unlinked synchronuously"; | ||
| 230 | break; | ||
| 231 | case -ECONNRESET: | ||
| 232 | errmsg = "unlinked asynchronuously"; | ||
| 233 | break; | ||
| 234 | case -ENOSR: | ||
| 235 | errmsg = "Buffer error (overrun)"; | ||
| 236 | break; | ||
| 237 | case -EPIPE: | ||
| 238 | errmsg = "Stalled (device not responding)"; | ||
| 239 | break; | ||
| 240 | case -EOVERFLOW: | ||
| 241 | errmsg = "Babble (bad cable?)"; | ||
| 242 | break; | ||
| 243 | case -EPROTO: | ||
| 244 | errmsg = "Bit-stuff error (bad cable?)"; | ||
| 245 | break; | ||
| 246 | case -EILSEQ: | ||
| 247 | errmsg = "CRC/Timeout (could be anything)"; | ||
| 248 | break; | ||
| 249 | case -ETIME: | ||
| 250 | errmsg = "Device does not respond"; | ||
| 251 | break; | ||
| 252 | } | ||
| 253 | if (packet < 0) { | ||
| 254 | em28xx_isocdbg("URB status %d [%s].\n", status, errmsg); | ||
| 255 | } else { | ||
| 256 | em28xx_isocdbg("URB packet %d, status %d [%s].\n", | ||
| 257 | packet, status, errmsg); | ||
| 258 | } | ||
| 259 | } | ||
| 260 | |||
| 261 | /* | ||
| 262 | * video-buf generic routine to get the next available buffer | ||
| 263 | */ | ||
| 264 | static inline void get_next_buf(struct em28xx_dmaqueue *dma_q, | ||
| 265 | struct em28xx_buffer **buf) | ||
| 266 | { | ||
| 267 | struct em28xx *dev = container_of(dma_q, struct em28xx, vidq); | ||
| 268 | char *outp; | ||
| 269 | |||
| 270 | if (list_empty(&dma_q->active)) { | ||
| 271 | em28xx_isocdbg("No active queue to serve\n"); | ||
| 272 | dev->isoc_ctl.buf = NULL; | ||
| 273 | *buf = NULL; | ||
| 274 | return; | ||
| 275 | } | ||
| 276 | |||
| 277 | /* Get the next buffer */ | ||
| 278 | *buf = list_entry(dma_q->active.next, struct em28xx_buffer, vb.queue); | ||
| 279 | |||
| 280 | /* Cleans up buffer - Usefull for testing for frame/URB loss */ | ||
| 281 | outp = videobuf_to_vmalloc(&(*buf)->vb); | ||
| 282 | memset(outp, 0, (*buf)->vb.size); | ||
| 283 | |||
| 284 | dev->isoc_ctl.buf = *buf; | ||
| 285 | |||
| 286 | return; | ||
| 287 | } | ||
| 288 | |||
| 289 | /* | ||
| 290 | * Controls the isoc copy of each urb packet | ||
| 291 | */ | ||
| 292 | static inline int em28xx_isoc_copy(struct em28xx *dev, struct urb *urb) | ||
| 293 | { | ||
| 294 | struct em28xx_buffer *buf; | ||
| 295 | struct em28xx_dmaqueue *dma_q = urb->context; | ||
| 296 | unsigned char *outp = NULL; | ||
| 297 | int i, len = 0, rc = 1; | ||
| 298 | unsigned char *p; | ||
| 299 | |||
| 300 | if (!dev) | ||
| 301 | return 0; | ||
| 302 | |||
| 303 | if ((dev->state & DEV_DISCONNECTED) || (dev->state & DEV_MISCONFIGURED)) | ||
| 304 | return 0; | ||
| 305 | |||
| 306 | if (urb->status < 0) { | ||
| 307 | print_err_status(dev, -1, urb->status); | ||
| 308 | if (urb->status == -ENOENT) | ||
| 309 | return 0; | ||
| 310 | } | ||
| 311 | |||
| 312 | buf = dev->isoc_ctl.buf; | ||
| 313 | if (buf != NULL) | ||
| 314 | outp = videobuf_to_vmalloc(&buf->vb); | ||
| 315 | |||
| 316 | for (i = 0; i < urb->number_of_packets; i++) { | ||
| 317 | int status = urb->iso_frame_desc[i].status; | ||
| 318 | |||
| 319 | if (status < 0) { | ||
| 320 | print_err_status(dev, i, status); | ||
| 321 | if (urb->iso_frame_desc[i].status != -EPROTO) | ||
| 322 | continue; | ||
| 323 | } | ||
| 324 | |||
| 325 | len = urb->iso_frame_desc[i].actual_length - 4; | ||
| 326 | |||
| 327 | if (urb->iso_frame_desc[i].actual_length <= 0) { | ||
| 328 | /* em28xx_isocdbg("packet %d is empty",i); - spammy */ | ||
| 329 | continue; | ||
| 330 | } | ||
| 331 | if (urb->iso_frame_desc[i].actual_length > | ||
| 332 | dev->max_pkt_size) { | ||
| 333 | em28xx_isocdbg("packet bigger than packet size"); | ||
| 334 | continue; | ||
| 335 | } | ||
| 336 | |||
| 337 | p = urb->transfer_buffer + urb->iso_frame_desc[i].offset; | ||
| 338 | |||
| 339 | /* FIXME: incomplete buffer checks where removed to make | ||
| 340 | logic simpler. Impacts of those changes should be evaluated | ||
| 341 | */ | ||
| 342 | if (p[0] == 0x33 && p[1] == 0x95 && p[2] == 0x00) { | ||
| 343 | em28xx_isocdbg("VBI HEADER!!!\n"); | ||
| 344 | /* FIXME: Should add vbi copy */ | ||
| 345 | continue; | ||
| 346 | } | ||
| 347 | if (p[0] == 0x22 && p[1] == 0x5a) { | ||
| 348 | em28xx_isocdbg("Video frame %d, length=%i, %s\n", p[2], | ||
| 349 | len, (p[2] & 1)? "odd" : "even"); | ||
| 350 | |||
| 351 | if (!(p[2] & 1)) { | ||
| 352 | if (buf != NULL) | ||
| 353 | buffer_filled(dev, dma_q, buf); | ||
| 354 | get_next_buf(dma_q, &buf); | ||
| 355 | if (buf == NULL) | ||
| 356 | outp = NULL; | ||
| 357 | else | ||
| 358 | outp = videobuf_to_vmalloc(&buf->vb); | ||
| 359 | } | ||
| 360 | |||
| 361 | if (buf != NULL) { | ||
| 362 | if (p[2] & 1) | ||
| 363 | buf->top_field = 0; | ||
| 364 | else | ||
| 365 | buf->top_field = 1; | ||
| 366 | } | ||
| 367 | |||
| 368 | dma_q->pos = 0; | ||
| 369 | } | ||
| 370 | if (buf != NULL) | ||
| 371 | em28xx_copy_video(dev, dma_q, buf, p, outp, len); | ||
| 372 | } | ||
| 373 | return rc; | ||
| 374 | } | ||
| 375 | |||
| 376 | /* ------------------------------------------------------------------ | ||
| 377 | Videobuf operations | ||
| 378 | ------------------------------------------------------------------*/ | ||
| 379 | |||
| 380 | static int | ||
| 381 | buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) | ||
| 382 | { | ||
| 383 | struct em28xx_fh *fh = vq->priv_data; | ||
| 384 | struct em28xx *dev = fh->dev; | ||
| 385 | struct v4l2_frequency f; | ||
| 386 | |||
| 387 | *size = 16 * fh->dev->width * fh->dev->height >> 3; | ||
| 388 | if (0 == *count) | ||
| 389 | *count = EM28XX_DEF_BUF; | ||
| 390 | |||
| 391 | if (*count < EM28XX_MIN_BUF) | ||
| 392 | *count = EM28XX_MIN_BUF; | ||
| 393 | |||
| 394 | /* Ask tuner to go to analog mode */ | ||
| 395 | memset(&f, 0, sizeof(f)); | ||
| 396 | f.frequency = dev->ctl_freq; | ||
| 397 | |||
| 398 | em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, &f); | ||
| 399 | |||
| 400 | return 0; | ||
| 401 | } | ||
| 402 | |||
| 403 | /* This is called *without* dev->slock held; please keep it that way */ | ||
| 404 | static void free_buffer(struct videobuf_queue *vq, struct em28xx_buffer *buf) | ||
| 405 | { | ||
| 406 | struct em28xx_fh *fh = vq->priv_data; | ||
| 407 | struct em28xx *dev = fh->dev; | ||
| 408 | unsigned long flags = 0; | ||
| 409 | if (in_interrupt()) | ||
| 410 | BUG(); | ||
| 411 | |||
| 412 | /* We used to wait for the buffer to finish here, but this didn't work | ||
| 413 | because, as we were keeping the state as VIDEOBUF_QUEUED, | ||
| 414 | videobuf_queue_cancel marked it as finished for us. | ||
| 415 | (Also, it could wedge forever if the hardware was misconfigured.) | ||
| 416 | |||
| 417 | This should be safe; by the time we get here, the buffer isn't | ||
| 418 | queued anymore. If we ever start marking the buffers as | ||
| 419 | VIDEOBUF_ACTIVE, it won't be, though. | ||
| 420 | */ | ||
| 421 | spin_lock_irqsave(&dev->slock, flags); | ||
| 422 | if (dev->isoc_ctl.buf == buf) | ||
| 423 | dev->isoc_ctl.buf = NULL; | ||
| 424 | spin_unlock_irqrestore(&dev->slock, flags); | ||
| 425 | |||
| 426 | videobuf_vmalloc_free(&buf->vb); | ||
| 427 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | ||
| 428 | } | ||
| 429 | |||
| 430 | static int | ||
| 431 | buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, | ||
| 432 | enum v4l2_field field) | ||
| 433 | { | ||
| 434 | struct em28xx_fh *fh = vq->priv_data; | ||
| 435 | struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); | ||
| 436 | struct em28xx *dev = fh->dev; | ||
| 437 | int rc = 0, urb_init = 0; | ||
| 438 | |||
| 439 | /* FIXME: It assumes depth = 16 */ | ||
| 440 | /* The only currently supported format is 16 bits/pixel */ | ||
| 441 | buf->vb.size = 16 * dev->width * dev->height >> 3; | ||
| 442 | |||
| 443 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | ||
| 444 | return -EINVAL; | ||
| 445 | |||
| 446 | buf->vb.width = dev->width; | ||
| 447 | buf->vb.height = dev->height; | ||
| 448 | buf->vb.field = field; | ||
| 449 | |||
| 450 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | ||
| 451 | rc = videobuf_iolock(vq, &buf->vb, NULL); | ||
| 452 | if (rc < 0) | ||
| 453 | goto fail; | ||
| 454 | } | ||
| 455 | |||
| 456 | if (!dev->isoc_ctl.num_bufs) | ||
| 457 | urb_init = 1; | ||
| 458 | |||
| 459 | if (urb_init) { | ||
| 460 | rc = em28xx_init_isoc(dev, EM28XX_NUM_PACKETS, | ||
| 461 | EM28XX_NUM_BUFS, dev->max_pkt_size, | ||
| 462 | em28xx_isoc_copy); | ||
| 463 | if (rc < 0) | ||
| 464 | goto fail; | ||
| 465 | } | ||
| 466 | |||
| 467 | buf->vb.state = VIDEOBUF_PREPARED; | ||
| 468 | return 0; | ||
| 469 | |||
| 470 | fail: | ||
| 471 | free_buffer(vq, buf); | ||
| 472 | return rc; | ||
| 473 | } | ||
| 474 | |||
| 475 | static void | ||
| 476 | buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | ||
| 477 | { | ||
| 478 | struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); | ||
| 479 | struct em28xx_fh *fh = vq->priv_data; | ||
| 480 | struct em28xx *dev = fh->dev; | ||
| 481 | struct em28xx_dmaqueue *vidq = &dev->vidq; | ||
| 482 | |||
| 483 | buf->vb.state = VIDEOBUF_QUEUED; | ||
| 484 | list_add_tail(&buf->vb.queue, &vidq->active); | ||
| 485 | |||
| 486 | } | ||
| 487 | |||
| 488 | static void buffer_release(struct videobuf_queue *vq, | ||
| 489 | struct videobuf_buffer *vb) | ||
| 490 | { | ||
| 491 | struct em28xx_buffer *buf = container_of(vb, struct em28xx_buffer, vb); | ||
| 492 | struct em28xx_fh *fh = vq->priv_data; | ||
| 493 | struct em28xx *dev = (struct em28xx *)fh->dev; | ||
| 494 | |||
| 495 | em28xx_isocdbg("em28xx: called buffer_release\n"); | ||
| 496 | |||
| 497 | free_buffer(vq, buf); | ||
| 498 | } | ||
| 499 | |||
| 500 | static struct videobuf_queue_ops em28xx_video_qops = { | ||
| 501 | .buf_setup = buffer_setup, | ||
| 502 | .buf_prepare = buffer_prepare, | ||
| 503 | .buf_queue = buffer_queue, | ||
| 504 | .buf_release = buffer_release, | ||
| 505 | }; | ||
| 506 | |||
| 507 | /********************* v4l2 interface **************************************/ | ||
| 112 | 508 | ||
| 113 | /* | 509 | /* |
| 114 | * em28xx_config() | 510 | * em28xx_config() |
| @@ -123,9 +519,9 @@ static int em28xx_config(struct em28xx *dev) | |||
| 123 | 519 | ||
| 124 | /* enable vbi capturing */ | 520 | /* enable vbi capturing */ |
| 125 | 521 | ||
| 126 | /* em28xx_write_regs_req(dev,0x00,0x0e,"\xC0",1); audio register */ | 522 | /* em28xx_write_regs_req(dev, 0x00, 0x0e, "\xC0", 1); audio register */ |
| 127 | /* em28xx_write_regs_req(dev,0x00,0x0f,"\x80",1); clk register */ | 523 | /* em28xx_write_regs_req(dev, 0x00, 0x0f, "\x80", 1); clk register */ |
| 128 | em28xx_write_regs_req(dev,0x00,0x11,"\x51",1); | 524 | em28xx_write_regs_req(dev, 0x00, 0x11, "\x51", 1); |
| 129 | 525 | ||
| 130 | dev->mute = 1; /* maybe not the right place... */ | 526 | dev->mute = 1; /* maybe not the right place... */ |
| 131 | dev->volume = 0x1f; | 527 | dev->volume = 0x1f; |
| @@ -152,23 +548,6 @@ static void em28xx_config_i2c(struct em28xx *dev) | |||
| 152 | em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL); | 548 | em28xx_i2c_call_clients(dev, VIDIOC_STREAMON, NULL); |
| 153 | } | 549 | } |
| 154 | 550 | ||
| 155 | /* | ||
| 156 | * em28xx_empty_framequeues() | ||
| 157 | * prepare queues for incoming and outgoing frames | ||
| 158 | */ | ||
| 159 | static void em28xx_empty_framequeues(struct em28xx *dev) | ||
| 160 | { | ||
| 161 | u32 i; | ||
| 162 | |||
| 163 | INIT_LIST_HEAD(&dev->inqueue); | ||
| 164 | INIT_LIST_HEAD(&dev->outqueue); | ||
| 165 | |||
| 166 | for (i = 0; i < EM28XX_NUM_FRAMES; i++) { | ||
| 167 | dev->frame[i].state = F_UNUSED; | ||
| 168 | dev->frame[i].buf.bytesused = 0; | ||
| 169 | } | ||
| 170 | } | ||
| 171 | |||
| 172 | static void video_mux(struct em28xx *dev, int index) | 551 | static void video_mux(struct em28xx *dev, int index) |
| 173 | { | 552 | { |
| 174 | struct v4l2_routing route; | 553 | struct v4l2_routing route; |
| @@ -181,12 +560,15 @@ static void video_mux(struct em28xx *dev, int index) | |||
| 181 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route); | 560 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_VIDEO_ROUTING, &route); |
| 182 | 561 | ||
| 183 | if (dev->has_msp34xx) { | 562 | if (dev->has_msp34xx) { |
| 184 | if (dev->i2s_speed) | 563 | if (dev->i2s_speed) { |
| 185 | em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed); | 564 | em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, |
| 565 | &dev->i2s_speed); | ||
| 566 | } | ||
| 186 | route.input = dev->ctl_ainput; | 567 | route.input = dev->ctl_ainput; |
| 187 | route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); | 568 | route.output = MSP_OUTPUT(MSP_SC_IN_DSP_SCART1); |
| 188 | /* Note: this is msp3400 specific */ | 569 | /* Note: this is msp3400 specific */ |
| 189 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route); | 570 | em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, |
| 571 | &route); | ||
| 190 | } | 572 | } |
| 191 | 573 | ||
| 192 | em28xx_audio_analog_set(dev); | 574 | em28xx_audio_analog_set(dev); |
| @@ -202,15 +584,12 @@ static int res_get(struct em28xx_fh *fh) | |||
| 202 | if (fh->stream_on) | 584 | if (fh->stream_on) |
| 203 | return rc; | 585 | return rc; |
| 204 | 586 | ||
| 205 | mutex_lock(&dev->lock); | ||
| 206 | |||
| 207 | if (dev->stream_on) | 587 | if (dev->stream_on) |
| 208 | rc = -EINVAL; | 588 | return -EINVAL; |
| 209 | else { | ||
| 210 | dev->stream_on = 1; | ||
| 211 | fh->stream_on = 1; | ||
| 212 | } | ||
| 213 | 589 | ||
| 590 | mutex_lock(&dev->lock); | ||
| 591 | dev->stream_on = 1; | ||
| 592 | fh->stream_on = 1; | ||
| 214 | mutex_unlock(&dev->lock); | 593 | mutex_unlock(&dev->lock); |
| 215 | return rc; | 594 | return rc; |
| 216 | } | 595 | } |
| @@ -231,33 +610,6 @@ static void res_free(struct em28xx_fh *fh) | |||
| 231 | } | 610 | } |
| 232 | 611 | ||
| 233 | /* | 612 | /* |
| 234 | * em28xx_vm_open() | ||
| 235 | */ | ||
| 236 | static void em28xx_vm_open(struct vm_area_struct *vma) | ||
| 237 | { | ||
| 238 | struct em28xx_frame_t *f = vma->vm_private_data; | ||
| 239 | f->vma_use_count++; | ||
| 240 | } | ||
| 241 | |||
| 242 | /* | ||
| 243 | * em28xx_vm_close() | ||
| 244 | */ | ||
| 245 | static void em28xx_vm_close(struct vm_area_struct *vma) | ||
| 246 | { | ||
| 247 | /* NOTE: buffers are not freed here */ | ||
| 248 | struct em28xx_frame_t *f = vma->vm_private_data; | ||
| 249 | |||
| 250 | if (f->vma_use_count) | ||
| 251 | f->vma_use_count--; | ||
| 252 | } | ||
| 253 | |||
| 254 | static struct vm_operations_struct em28xx_vm_ops = { | ||
| 255 | .open = em28xx_vm_open, | ||
| 256 | .close = em28xx_vm_close, | ||
| 257 | }; | ||
| 258 | |||
| 259 | |||
| 260 | /* | ||
| 261 | * em28xx_get_ctrl() | 613 | * em28xx_get_ctrl() |
| 262 | * return the current saturation, brightness or contrast, mute state | 614 | * return the current saturation, brightness or contrast, mute state |
| 263 | */ | 615 | */ |
| @@ -296,34 +648,6 @@ static int em28xx_set_ctrl(struct em28xx *dev, const struct v4l2_control *ctrl) | |||
| 296 | } | 648 | } |
| 297 | } | 649 | } |
| 298 | 650 | ||
| 299 | /* | ||
| 300 | * em28xx_stream_interrupt() | ||
| 301 | * stops streaming | ||
| 302 | */ | ||
| 303 | static int em28xx_stream_interrupt(struct em28xx *dev) | ||
| 304 | { | ||
| 305 | int rc = 0; | ||
| 306 | |||
| 307 | /* stop reading from the device */ | ||
| 308 | |||
| 309 | dev->stream = STREAM_INTERRUPT; | ||
| 310 | rc = wait_event_timeout(dev->wait_stream, | ||
| 311 | (dev->stream == STREAM_OFF) || | ||
| 312 | (dev->state & DEV_DISCONNECTED), | ||
| 313 | EM28XX_URB_TIMEOUT); | ||
| 314 | |||
| 315 | if (rc) { | ||
| 316 | dev->state |= DEV_MISCONFIGURED; | ||
| 317 | em28xx_videodbg("device is misconfigured; close and " | ||
| 318 | "open /dev/video%d again\n", | ||
| 319 | dev->vdev->minor-MINOR_VFL_TYPE_GRABBER_MIN); | ||
| 320 | return rc; | ||
| 321 | } | ||
| 322 | |||
| 323 | return 0; | ||
| 324 | } | ||
| 325 | |||
| 326 | |||
| 327 | static int check_dev(struct em28xx *dev) | 651 | static int check_dev(struct em28xx *dev) |
| 328 | { | 652 | { |
| 329 | if (dev->state & DEV_DISCONNECTED) { | 653 | if (dev->state & DEV_DISCONNECTED) { |
| @@ -370,8 +694,8 @@ static int vidioc_g_fmt_cap(struct file *file, void *priv, | |||
| 370 | f->fmt.pix.width = dev->width; | 694 | f->fmt.pix.width = dev->width; |
| 371 | f->fmt.pix.height = dev->height; | 695 | f->fmt.pix.height = dev->height; |
| 372 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; | 696 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; |
| 373 | f->fmt.pix.bytesperline = dev->bytesperline; | 697 | f->fmt.pix.bytesperline = dev->width * 2; |
| 374 | f->fmt.pix.sizeimage = dev->frame_size; | 698 | f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * dev->height; |
| 375 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; | 699 | f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; |
| 376 | 700 | ||
| 377 | /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ | 701 | /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ |
| @@ -447,7 +771,7 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv, | |||
| 447 | { | 771 | { |
| 448 | struct em28xx_fh *fh = priv; | 772 | struct em28xx_fh *fh = priv; |
| 449 | struct em28xx *dev = fh->dev; | 773 | struct em28xx *dev = fh->dev; |
| 450 | int rc, i; | 774 | int rc; |
| 451 | 775 | ||
| 452 | rc = check_dev(dev); | 776 | rc = check_dev(dev); |
| 453 | if (rc < 0) | 777 | if (rc < 0) |
| @@ -457,49 +781,34 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv, | |||
| 457 | 781 | ||
| 458 | mutex_lock(&dev->lock); | 782 | mutex_lock(&dev->lock); |
| 459 | 783 | ||
| 460 | for (i = 0; i < dev->num_frames; i++) | 784 | if (videobuf_queue_is_busy(&fh->vb_vidq)) { |
| 461 | if (dev->frame[i].vma_use_count) { | 785 | em28xx_errdev("%s queue busy\n", __func__); |
| 462 | em28xx_videodbg("VIDIOC_S_FMT failed. " | 786 | rc = -EBUSY; |
| 463 | "Unmap the buffers first.\n"); | 787 | goto out; |
| 464 | rc = -EINVAL; | ||
| 465 | goto err; | ||
| 466 | } | ||
| 467 | |||
| 468 | /* stop io in case it is already in progress */ | ||
| 469 | if (dev->stream == STREAM_ON) { | ||
| 470 | em28xx_videodbg("VIDIOC_SET_FMT: interrupting stream\n"); | ||
| 471 | rc = em28xx_stream_interrupt(dev); | ||
| 472 | if (rc < 0) | ||
| 473 | goto err; | ||
| 474 | } | 788 | } |
| 475 | 789 | ||
| 476 | em28xx_release_buffers(dev); | 790 | if (dev->stream_on && !fh->stream_on) { |
| 477 | dev->io = IO_NONE; | 791 | em28xx_errdev("%s device in use by another fh\n", __func__); |
| 792 | rc = -EBUSY; | ||
| 793 | goto out; | ||
| 794 | } | ||
| 478 | 795 | ||
| 479 | /* set new image size */ | 796 | /* set new image size */ |
| 480 | dev->width = f->fmt.pix.width; | 797 | dev->width = f->fmt.pix.width; |
| 481 | dev->height = f->fmt.pix.height; | 798 | dev->height = f->fmt.pix.height; |
| 482 | dev->frame_size = dev->width * dev->height * 2; | ||
| 483 | dev->field_size = dev->frame_size >> 1; | ||
| 484 | dev->bytesperline = dev->width * 2; | ||
| 485 | get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); | 799 | get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); |
| 486 | 800 | ||
| 487 | /* FIXME: This is really weird! Why capture is starting with | ||
| 488 | this ioctl ??? | ||
| 489 | */ | ||
| 490 | em28xx_uninit_isoc(dev); | ||
| 491 | em28xx_set_alternate(dev); | 801 | em28xx_set_alternate(dev); |
| 492 | em28xx_capture_start(dev, 1); | ||
| 493 | em28xx_resolution_set(dev); | 802 | em28xx_resolution_set(dev); |
| 494 | em28xx_init_isoc(dev); | 803 | |
| 495 | rc = 0; | 804 | rc = 0; |
| 496 | 805 | ||
| 497 | err: | 806 | out: |
| 498 | mutex_unlock(&dev->lock); | 807 | mutex_unlock(&dev->lock); |
| 499 | return rc; | 808 | return rc; |
| 500 | } | 809 | } |
| 501 | 810 | ||
| 502 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) | 811 | static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id * norm) |
| 503 | { | 812 | { |
| 504 | struct em28xx_fh *fh = priv; | 813 | struct em28xx_fh *fh = priv; |
| 505 | struct em28xx *dev = fh->dev; | 814 | struct em28xx *dev = fh->dev; |
| @@ -524,9 +833,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) | |||
| 524 | /* set new image size */ | 833 | /* set new image size */ |
| 525 | dev->width = f.fmt.pix.width; | 834 | dev->width = f.fmt.pix.width; |
| 526 | dev->height = f.fmt.pix.height; | 835 | dev->height = f.fmt.pix.height; |
| 527 | dev->frame_size = dev->width * dev->height * 2; | ||
| 528 | dev->field_size = dev->frame_size >> 1; | ||
| 529 | dev->bytesperline = dev->width * 2; | ||
| 530 | get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); | 836 | get_scale(dev, dev->width, dev->height, &dev->hscale, &dev->vscale); |
| 531 | 837 | ||
| 532 | em28xx_resolution_set(dev); | 838 | em28xx_resolution_set(dev); |
| @@ -619,11 +925,11 @@ static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a) | |||
| 619 | 925 | ||
| 620 | index = dev->ctl_ainput; | 926 | index = dev->ctl_ainput; |
| 621 | 927 | ||
| 622 | if (index == 0) { | 928 | if (index == 0) |
| 623 | strcpy(a->name, "Television"); | 929 | strcpy(a->name, "Television"); |
| 624 | } else { | 930 | else |
| 625 | strcpy(a->name, "Line In"); | 931 | strcpy(a->name, "Line In"); |
| 626 | } | 932 | |
| 627 | a->capability = V4L2_AUDCAP_STEREO; | 933 | a->capability = V4L2_AUDCAP_STEREO; |
| 628 | a->index = index; | 934 | a->index = index; |
| 629 | 935 | ||
| @@ -834,9 +1140,9 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
| 834 | static int em28xx_reg_len(int reg) | 1140 | static int em28xx_reg_len(int reg) |
| 835 | { | 1141 | { |
| 836 | switch (reg) { | 1142 | switch (reg) { |
| 837 | case AC97LSB_REG: | 1143 | case EM28XX_R40_AC97LSB: |
| 838 | case HSCALELOW_REG: | 1144 | case EM28XX_R30_HSCALELOW: |
| 839 | case VSCALELOW_REG: | 1145 | case EM28XX_R32_VSCALELOW: |
| 840 | return 2; | 1146 | return 2; |
| 841 | default: | 1147 | default: |
| 842 | return 1; | 1148 | return 1; |
| @@ -918,23 +1224,11 @@ static int vidioc_streamon(struct file *file, void *priv, | |||
| 918 | if (rc < 0) | 1224 | if (rc < 0) |
| 919 | return rc; | 1225 | return rc; |
| 920 | 1226 | ||
| 921 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || dev->io != IO_MMAP) | ||
| 922 | return -EINVAL; | ||
| 923 | |||
| 924 | if (list_empty(&dev->inqueue)) | ||
| 925 | return -EINVAL; | ||
| 926 | |||
| 927 | mutex_lock(&dev->lock); | ||
| 928 | 1227 | ||
| 929 | if (unlikely(res_get(fh) < 0)) { | 1228 | if (unlikely(res_get(fh) < 0)) |
| 930 | mutex_unlock(&dev->lock); | ||
| 931 | return -EBUSY; | 1229 | return -EBUSY; |
| 932 | } | ||
| 933 | 1230 | ||
| 934 | dev->stream = STREAM_ON; /* FIXME: Start video capture here? */ | 1231 | return (videobuf_streamon(&fh->vb_vidq)); |
| 935 | |||
| 936 | mutex_unlock(&dev->lock); | ||
| 937 | return 0; | ||
| 938 | } | 1232 | } |
| 939 | 1233 | ||
| 940 | static int vidioc_streamoff(struct file *file, void *priv, | 1234 | static int vidioc_streamoff(struct file *file, void *priv, |
| @@ -948,23 +1242,14 @@ static int vidioc_streamoff(struct file *file, void *priv, | |||
| 948 | if (rc < 0) | 1242 | if (rc < 0) |
| 949 | return rc; | 1243 | return rc; |
| 950 | 1244 | ||
| 951 | if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || dev->io != IO_MMAP) | 1245 | if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
| 1246 | return -EINVAL; | ||
| 1247 | if (type != fh->type) | ||
| 952 | return -EINVAL; | 1248 | return -EINVAL; |
| 953 | 1249 | ||
| 954 | mutex_lock(&dev->lock); | 1250 | videobuf_streamoff(&fh->vb_vidq); |
| 955 | 1251 | res_free(fh); | |
| 956 | if (dev->stream == STREAM_ON) { | ||
| 957 | em28xx_videodbg("VIDIOC_STREAMOFF: interrupting stream\n"); | ||
| 958 | rc = em28xx_stream_interrupt(dev); | ||
| 959 | if (rc < 0) { | ||
| 960 | mutex_unlock(&dev->lock); | ||
| 961 | return rc; | ||
| 962 | } | ||
| 963 | } | ||
| 964 | |||
| 965 | em28xx_empty_framequeues(dev); | ||
| 966 | 1252 | ||
| 967 | mutex_unlock(&dev->lock); | ||
| 968 | return 0; | 1253 | return 0; |
| 969 | } | 1254 | } |
| 970 | 1255 | ||
| @@ -1058,53 +1343,13 @@ static int vidioc_reqbufs(struct file *file, void *priv, | |||
| 1058 | { | 1343 | { |
| 1059 | struct em28xx_fh *fh = priv; | 1344 | struct em28xx_fh *fh = priv; |
| 1060 | struct em28xx *dev = fh->dev; | 1345 | struct em28xx *dev = fh->dev; |
| 1061 | u32 i; | ||
| 1062 | int rc; | 1346 | int rc; |
| 1063 | 1347 | ||
| 1064 | rc = check_dev(dev); | 1348 | rc = check_dev(dev); |
| 1065 | if (rc < 0) | 1349 | if (rc < 0) |
| 1066 | return rc; | 1350 | return rc; |
| 1067 | 1351 | ||
| 1068 | if (rb->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 1352 | return (videobuf_reqbufs(&fh->vb_vidq, rb)); |
| 1069 | rb->memory != V4L2_MEMORY_MMAP) | ||
| 1070 | return -EINVAL; | ||
| 1071 | |||
| 1072 | if (dev->io == IO_READ) { | ||
| 1073 | em28xx_videodbg("method is set to read;" | ||
| 1074 | " close and open the device again to" | ||
| 1075 | " choose the mmap I/O method\n"); | ||
| 1076 | return -EINVAL; | ||
| 1077 | } | ||
| 1078 | |||
| 1079 | for (i = 0; i < dev->num_frames; i++) | ||
| 1080 | if (dev->frame[i].vma_use_count) { | ||
| 1081 | em28xx_videodbg("VIDIOC_REQBUFS failed; " | ||
| 1082 | "previous buffers are still mapped\n"); | ||
| 1083 | return -EINVAL; | ||
| 1084 | } | ||
| 1085 | |||
| 1086 | mutex_lock(&dev->lock); | ||
| 1087 | |||
| 1088 | if (dev->stream == STREAM_ON) { | ||
| 1089 | em28xx_videodbg("VIDIOC_REQBUFS: interrupting stream\n"); | ||
| 1090 | rc = em28xx_stream_interrupt(dev); | ||
| 1091 | if (rc < 0) { | ||
| 1092 | mutex_unlock(&dev->lock); | ||
| 1093 | return rc; | ||
| 1094 | } | ||
| 1095 | } | ||
| 1096 | |||
| 1097 | em28xx_empty_framequeues(dev); | ||
| 1098 | |||
| 1099 | em28xx_release_buffers(dev); | ||
| 1100 | if (rb->count) | ||
| 1101 | rb->count = em28xx_request_buffers(dev, rb->count); | ||
| 1102 | |||
| 1103 | dev->frame_current = NULL; | ||
| 1104 | dev->io = rb->count ? IO_MMAP : IO_NONE; | ||
| 1105 | |||
| 1106 | mutex_unlock(&dev->lock); | ||
| 1107 | return 0; | ||
| 1108 | } | 1353 | } |
| 1109 | 1354 | ||
| 1110 | static int vidioc_querybuf(struct file *file, void *priv, | 1355 | static int vidioc_querybuf(struct file *file, void *priv, |
| @@ -1118,52 +1363,20 @@ static int vidioc_querybuf(struct file *file, void *priv, | |||
| 1118 | if (rc < 0) | 1363 | if (rc < 0) |
| 1119 | return rc; | 1364 | return rc; |
| 1120 | 1365 | ||
| 1121 | if (b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 1366 | return (videobuf_querybuf(&fh->vb_vidq, b)); |
| 1122 | b->index >= dev->num_frames || dev->io != IO_MMAP) | ||
| 1123 | return -EINVAL; | ||
| 1124 | |||
| 1125 | mutex_lock(&dev->lock); | ||
| 1126 | |||
| 1127 | memcpy(b, &dev->frame[b->index].buf, sizeof(*b)); | ||
| 1128 | |||
| 1129 | if (dev->frame[b->index].vma_use_count) | ||
| 1130 | b->flags |= V4L2_BUF_FLAG_MAPPED; | ||
| 1131 | |||
| 1132 | if (dev->frame[b->index].state == F_DONE) | ||
| 1133 | b->flags |= V4L2_BUF_FLAG_DONE; | ||
| 1134 | else if (dev->frame[b->index].state != F_UNUSED) | ||
| 1135 | b->flags |= V4L2_BUF_FLAG_QUEUED; | ||
| 1136 | |||
| 1137 | mutex_unlock(&dev->lock); | ||
| 1138 | return 0; | ||
| 1139 | } | 1367 | } |
| 1140 | 1368 | ||
| 1141 | static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) | 1369 | static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) |
| 1142 | { | 1370 | { |
| 1143 | struct em28xx_fh *fh = priv; | 1371 | struct em28xx_fh *fh = priv; |
| 1144 | struct em28xx *dev = fh->dev; | 1372 | struct em28xx *dev = fh->dev; |
| 1145 | unsigned long lock_flags; | ||
| 1146 | int rc; | 1373 | int rc; |
| 1147 | 1374 | ||
| 1148 | rc = check_dev(dev); | 1375 | rc = check_dev(dev); |
| 1149 | if (rc < 0) | 1376 | if (rc < 0) |
| 1150 | return rc; | 1377 | return rc; |
| 1151 | 1378 | ||
| 1152 | if (b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || dev->io != IO_MMAP || | 1379 | return (videobuf_qbuf(&fh->vb_vidq, b)); |
| 1153 | b->index >= dev->num_frames) | ||
| 1154 | return -EINVAL; | ||
| 1155 | |||
| 1156 | if (dev->frame[b->index].state != F_UNUSED) | ||
| 1157 | return -EAGAIN; | ||
| 1158 | |||
| 1159 | dev->frame[b->index].state = F_QUEUED; | ||
| 1160 | |||
| 1161 | /* add frame to fifo */ | ||
| 1162 | spin_lock_irqsave(&dev->queue_lock, lock_flags); | ||
| 1163 | list_add_tail(&dev->frame[b->index].frame, &dev->inqueue); | ||
| 1164 | spin_unlock_irqrestore(&dev->queue_lock, lock_flags); | ||
| 1165 | |||
| 1166 | return 0; | ||
| 1167 | } | 1380 | } |
| 1168 | 1381 | ||
| 1169 | static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) | 1382 | static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) |
| @@ -1171,46 +1384,24 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) | |||
| 1171 | struct em28xx_fh *fh = priv; | 1384 | struct em28xx_fh *fh = priv; |
| 1172 | struct em28xx *dev = fh->dev; | 1385 | struct em28xx *dev = fh->dev; |
| 1173 | int rc; | 1386 | int rc; |
| 1174 | struct em28xx_frame_t *f; | ||
| 1175 | unsigned long lock_flags; | ||
| 1176 | 1387 | ||
| 1177 | rc = check_dev(dev); | 1388 | rc = check_dev(dev); |
| 1178 | if (rc < 0) | 1389 | if (rc < 0) |
| 1179 | return rc; | 1390 | return rc; |
| 1180 | 1391 | ||
| 1181 | if (b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || dev->io != IO_MMAP) | 1392 | return (videobuf_dqbuf(&fh->vb_vidq, b, |
| 1182 | return -EINVAL; | 1393 | file->f_flags & O_NONBLOCK)); |
| 1183 | 1394 | } | |
| 1184 | if (list_empty(&dev->outqueue)) { | ||
| 1185 | if (dev->stream == STREAM_OFF) | ||
| 1186 | return -EINVAL; | ||
| 1187 | |||
| 1188 | if (file->f_flags & O_NONBLOCK) | ||
| 1189 | return -EAGAIN; | ||
| 1190 | |||
| 1191 | rc = wait_event_interruptible(dev->wait_frame, | ||
| 1192 | (!list_empty(&dev->outqueue)) || | ||
| 1193 | (dev->state & DEV_DISCONNECTED)); | ||
| 1194 | if (rc) | ||
| 1195 | return rc; | ||
| 1196 | |||
| 1197 | if (dev->state & DEV_DISCONNECTED) | ||
| 1198 | return -ENODEV; | ||
| 1199 | } | ||
| 1200 | |||
| 1201 | spin_lock_irqsave(&dev->queue_lock, lock_flags); | ||
| 1202 | f = list_entry(dev->outqueue.next, struct em28xx_frame_t, frame); | ||
| 1203 | list_del(dev->outqueue.next); | ||
| 1204 | spin_unlock_irqrestore(&dev->queue_lock, lock_flags); | ||
| 1205 | |||
| 1206 | f->state = F_UNUSED; | ||
| 1207 | memcpy(b, &f->buf, sizeof(*b)); | ||
| 1208 | 1395 | ||
| 1209 | if (f->vma_use_count) | 1396 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
| 1210 | b->flags |= V4L2_BUF_FLAG_MAPPED; | 1397 | static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) |
| 1398 | { | ||
| 1399 | struct em28xx_fh *fh = priv; | ||
| 1211 | 1400 | ||
| 1212 | return 0; | 1401 | return videobuf_cgmbuf(&fh->vb_vidq, mbuf, 8); |
| 1213 | } | 1402 | } |
| 1403 | #endif | ||
| 1404 | |||
| 1214 | 1405 | ||
| 1215 | /* ----------------------------------------------------------- */ | 1406 | /* ----------------------------------------------------------- */ |
| 1216 | /* RADIO ESPECIFIC IOCTLS */ | 1407 | /* RADIO ESPECIFIC IOCTLS */ |
| @@ -1316,17 +1507,18 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
| 1316 | { | 1507 | { |
| 1317 | int minor = iminor(inode); | 1508 | int minor = iminor(inode); |
| 1318 | int errCode = 0, radio = 0; | 1509 | int errCode = 0, radio = 0; |
| 1319 | struct em28xx *h,*dev = NULL; | 1510 | struct em28xx *h, *dev = NULL; |
| 1320 | struct em28xx_fh *fh; | 1511 | struct em28xx_fh *fh; |
| 1512 | enum v4l2_buf_type fh_type = 0; | ||
| 1321 | 1513 | ||
| 1322 | list_for_each_entry(h, &em28xx_devlist, devlist) { | 1514 | list_for_each_entry(h, &em28xx_devlist, devlist) { |
| 1323 | if (h->vdev->minor == minor) { | 1515 | if (h->vdev->minor == minor) { |
| 1324 | dev = h; | 1516 | dev = h; |
| 1325 | dev->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1517 | fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 1326 | } | 1518 | } |
| 1327 | if (h->vbi_dev->minor == minor) { | 1519 | if (h->vbi_dev->minor == minor) { |
| 1328 | dev = h; | 1520 | dev = h; |
| 1329 | dev->type = V4L2_BUF_TYPE_VBI_CAPTURE; | 1521 | fh_type = V4L2_BUF_TYPE_VBI_CAPTURE; |
| 1330 | } | 1522 | } |
| 1331 | if (h->radio_dev && | 1523 | if (h->radio_dev && |
| 1332 | h->radio_dev->minor == minor) { | 1524 | h->radio_dev->minor == minor) { |
| @@ -1338,10 +1530,10 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
| 1338 | return -ENODEV; | 1530 | return -ENODEV; |
| 1339 | 1531 | ||
| 1340 | em28xx_videodbg("open minor=%d type=%s users=%d\n", | 1532 | em28xx_videodbg("open minor=%d type=%s users=%d\n", |
| 1341 | minor,v4l2_type_names[dev->type],dev->users); | 1533 | minor, v4l2_type_names[fh_type], dev->users); |
| 1342 | 1534 | ||
| 1343 | fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL); | ||
| 1344 | 1535 | ||
| 1536 | fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL); | ||
| 1345 | if (!fh) { | 1537 | if (!fh) { |
| 1346 | em28xx_errdev("em28xx-video.c: Out of memory?!\n"); | 1538 | em28xx_errdev("em28xx-video.c: Out of memory?!\n"); |
| 1347 | return -ENOMEM; | 1539 | return -ENOMEM; |
| @@ -1349,28 +1541,24 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
| 1349 | mutex_lock(&dev->lock); | 1541 | mutex_lock(&dev->lock); |
| 1350 | fh->dev = dev; | 1542 | fh->dev = dev; |
| 1351 | fh->radio = radio; | 1543 | fh->radio = radio; |
| 1544 | fh->type = fh_type; | ||
| 1352 | filp->private_data = fh; | 1545 | filp->private_data = fh; |
| 1353 | 1546 | ||
| 1354 | if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { | 1547 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE && dev->users == 0) { |
| 1355 | dev->width = norm_maxw(dev); | 1548 | dev->width = norm_maxw(dev); |
| 1356 | dev->height = norm_maxh(dev); | 1549 | dev->height = norm_maxh(dev); |
| 1357 | dev->frame_size = dev->width * dev->height * 2; | ||
| 1358 | dev->field_size = dev->frame_size >> 1; /*both_fileds ? dev->frame_size>>1 : dev->frame_size; */ | ||
| 1359 | dev->bytesperline = dev->width * 2; | ||
| 1360 | dev->hscale = 0; | 1550 | dev->hscale = 0; |
| 1361 | dev->vscale = 0; | 1551 | dev->vscale = 0; |
| 1362 | 1552 | ||
| 1553 | em28xx_set_mode(dev, EM28XX_ANALOG_MODE); | ||
| 1363 | em28xx_set_alternate(dev); | 1554 | em28xx_set_alternate(dev); |
| 1364 | em28xx_capture_start(dev, 1); | ||
| 1365 | em28xx_resolution_set(dev); | 1555 | em28xx_resolution_set(dev); |
| 1366 | 1556 | ||
| 1557 | /* Needed, since GPIO might have disabled power of | ||
| 1558 | some i2c device | ||
| 1559 | */ | ||
| 1560 | em28xx_config_i2c(dev); | ||
| 1367 | 1561 | ||
| 1368 | /* start the transfer */ | ||
| 1369 | errCode = em28xx_init_isoc(dev); | ||
| 1370 | if (errCode) | ||
| 1371 | goto err; | ||
| 1372 | |||
| 1373 | em28xx_empty_framequeues(dev); | ||
| 1374 | } | 1562 | } |
| 1375 | if (fh->radio) { | 1563 | if (fh->radio) { |
| 1376 | em28xx_videodbg("video_open: setting radio device\n"); | 1564 | em28xx_videodbg("video_open: setting radio device\n"); |
| @@ -1379,8 +1567,12 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) | |||
| 1379 | 1567 | ||
| 1380 | dev->users++; | 1568 | dev->users++; |
| 1381 | 1569 | ||
| 1382 | err: | 1570 | videobuf_queue_vmalloc_init(&fh->vb_vidq, &em28xx_video_qops, |
| 1571 | NULL, &dev->slock, fh->type, V4L2_FIELD_INTERLACED, | ||
| 1572 | sizeof(struct em28xx_buffer), fh); | ||
| 1573 | |||
| 1383 | mutex_unlock(&dev->lock); | 1574 | mutex_unlock(&dev->lock); |
| 1575 | |||
| 1384 | return errCode; | 1576 | return errCode; |
| 1385 | } | 1577 | } |
| 1386 | 1578 | ||
| @@ -1423,12 +1615,13 @@ static void em28xx_release_resources(struct em28xx *dev) | |||
| 1423 | usb_put_dev(dev->udev); | 1615 | usb_put_dev(dev->udev); |
| 1424 | 1616 | ||
| 1425 | /* Mark device as unused */ | 1617 | /* Mark device as unused */ |
| 1426 | em28xx_devused&=~(1<<dev->devno); | 1618 | em28xx_devused &= ~(1<<dev->devno); |
| 1427 | } | 1619 | } |
| 1428 | 1620 | ||
| 1429 | /* | 1621 | /* |
| 1430 | * em28xx_v4l2_close() | 1622 | * em28xx_v4l2_close() |
| 1431 | * stops streaming and deallocates all resources allocated by the v4l2 calls and ioctls | 1623 | * stops streaming and deallocates all resources allocated by the v4l2 |
| 1624 | * calls and ioctls | ||
| 1432 | */ | 1625 | */ |
| 1433 | static int em28xx_v4l2_close(struct inode *inode, struct file *filp) | 1626 | static int em28xx_v4l2_close(struct inode *inode, struct file *filp) |
| 1434 | { | 1627 | { |
| @@ -1445,9 +1638,8 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp) | |||
| 1445 | mutex_lock(&dev->lock); | 1638 | mutex_lock(&dev->lock); |
| 1446 | 1639 | ||
| 1447 | if (dev->users == 1) { | 1640 | if (dev->users == 1) { |
| 1448 | em28xx_uninit_isoc(dev); | 1641 | videobuf_stop(&fh->vb_vidq); |
| 1449 | em28xx_release_buffers(dev); | 1642 | videobuf_mmap_free(&fh->vb_vidq); |
| 1450 | dev->io = IO_NONE; | ||
| 1451 | 1643 | ||
| 1452 | /* the device is already disconnect, | 1644 | /* the device is already disconnect, |
| 1453 | free the remaining resources */ | 1645 | free the remaining resources */ |
| @@ -1458,6 +1650,10 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp) | |||
| 1458 | return 0; | 1650 | return 0; |
| 1459 | } | 1651 | } |
| 1460 | 1652 | ||
| 1653 | /* do this before setting alternate! */ | ||
| 1654 | em28xx_uninit_isoc(dev); | ||
| 1655 | em28xx_set_mode(dev, EM28XX_MODE_UNDEFINED); | ||
| 1656 | |||
| 1461 | /* set alternate 0 */ | 1657 | /* set alternate 0 */ |
| 1462 | dev->alt = 0; | 1658 | dev->alt = 0; |
| 1463 | em28xx_videodbg("setting alternate 0\n"); | 1659 | em28xx_videodbg("setting alternate 0\n"); |
| @@ -1479,135 +1675,29 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp) | |||
| 1479 | * will allocate buffers when called for the first time | 1675 | * will allocate buffers when called for the first time |
| 1480 | */ | 1676 | */ |
| 1481 | static ssize_t | 1677 | static ssize_t |
| 1482 | em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count, | 1678 | em28xx_v4l2_read(struct file *filp, char __user *buf, size_t count, |
| 1483 | loff_t * f_pos) | 1679 | loff_t *pos) |
| 1484 | { | 1680 | { |
| 1485 | struct em28xx_frame_t *f, *i; | ||
| 1486 | unsigned long lock_flags; | ||
| 1487 | int ret = 0; | ||
| 1488 | struct em28xx_fh *fh = filp->private_data; | 1681 | struct em28xx_fh *fh = filp->private_data; |
| 1489 | struct em28xx *dev = fh->dev; | 1682 | struct em28xx *dev = fh->dev; |
| 1683 | int rc; | ||
| 1684 | |||
| 1685 | rc = check_dev(dev); | ||
| 1686 | if (rc < 0) | ||
| 1687 | return rc; | ||
| 1490 | 1688 | ||
| 1491 | /* FIXME: read() is not prepared to allow changing the video | 1689 | /* FIXME: read() is not prepared to allow changing the video |
| 1492 | resolution while streaming. Seems a bug at em28xx_set_fmt | 1690 | resolution while streaming. Seems a bug at em28xx_set_fmt |
| 1493 | */ | 1691 | */ |
| 1494 | 1692 | ||
| 1495 | if (unlikely(res_get(fh) < 0)) | 1693 | if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { |
| 1496 | return -EBUSY; | 1694 | if (unlikely(res_get(fh))) |
| 1497 | 1695 | return -EBUSY; | |
| 1498 | mutex_lock(&dev->lock); | ||
| 1499 | |||
| 1500 | if (dev->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 1501 | em28xx_videodbg("V4l2_Buf_type_videocapture is set\n"); | ||
| 1502 | 1696 | ||
| 1503 | if (dev->type == V4L2_BUF_TYPE_VBI_CAPTURE) { | 1697 | return videobuf_read_stream(&fh->vb_vidq, buf, count, pos, 0, |
| 1504 | em28xx_videodbg("V4L2_BUF_TYPE_VBI_CAPTURE is set\n"); | 1698 | filp->f_flags & O_NONBLOCK); |
| 1505 | em28xx_videodbg("not supported yet! ...\n"); | ||
| 1506 | if (copy_to_user(buf, "", 1)) { | ||
| 1507 | mutex_unlock(&dev->lock); | ||
| 1508 | return -EFAULT; | ||
| 1509 | } | ||
| 1510 | mutex_unlock(&dev->lock); | ||
| 1511 | return (1); | ||
| 1512 | } | ||
| 1513 | if (dev->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) { | ||
| 1514 | em28xx_videodbg("V4L2_BUF_TYPE_SLICED_VBI_CAPTURE is set\n"); | ||
| 1515 | em28xx_videodbg("not supported yet! ...\n"); | ||
| 1516 | if (copy_to_user(buf, "", 1)) { | ||
| 1517 | mutex_unlock(&dev->lock); | ||
| 1518 | return -EFAULT; | ||
| 1519 | } | ||
| 1520 | mutex_unlock(&dev->lock); | ||
| 1521 | return (1); | ||
| 1522 | } | 1699 | } |
| 1523 | 1700 | return 0; | |
| 1524 | if (dev->state & DEV_DISCONNECTED) { | ||
| 1525 | em28xx_videodbg("device not present\n"); | ||
| 1526 | mutex_unlock(&dev->lock); | ||
| 1527 | return -ENODEV; | ||
| 1528 | } | ||
| 1529 | |||
| 1530 | if (dev->state & DEV_MISCONFIGURED) { | ||
| 1531 | em28xx_videodbg("device misconfigured; close and open it again\n"); | ||
| 1532 | mutex_unlock(&dev->lock); | ||
| 1533 | return -EIO; | ||
| 1534 | } | ||
| 1535 | |||
| 1536 | if (dev->io == IO_MMAP) { | ||
| 1537 | em28xx_videodbg ("IO method is set to mmap; close and open" | ||
| 1538 | " the device again to choose the read method\n"); | ||
| 1539 | mutex_unlock(&dev->lock); | ||
| 1540 | return -EINVAL; | ||
| 1541 | } | ||
| 1542 | |||
| 1543 | if (dev->io == IO_NONE) { | ||
| 1544 | if (!em28xx_request_buffers(dev, EM28XX_NUM_READ_FRAMES)) { | ||
| 1545 | em28xx_errdev("read failed, not enough memory\n"); | ||
| 1546 | mutex_unlock(&dev->lock); | ||
| 1547 | return -ENOMEM; | ||
| 1548 | } | ||
| 1549 | dev->io = IO_READ; | ||
| 1550 | dev->stream = STREAM_ON; | ||
| 1551 | em28xx_queue_unusedframes(dev); | ||
| 1552 | } | ||
| 1553 | |||
| 1554 | if (!count) { | ||
| 1555 | mutex_unlock(&dev->lock); | ||
| 1556 | return 0; | ||
| 1557 | } | ||
| 1558 | |||
| 1559 | if (list_empty(&dev->outqueue)) { | ||
| 1560 | if (filp->f_flags & O_NONBLOCK) { | ||
| 1561 | mutex_unlock(&dev->lock); | ||
| 1562 | return -EAGAIN; | ||
| 1563 | } | ||
| 1564 | ret = wait_event_interruptible | ||
| 1565 | (dev->wait_frame, | ||
| 1566 | (!list_empty(&dev->outqueue)) || | ||
| 1567 | (dev->state & DEV_DISCONNECTED)); | ||
| 1568 | if (ret) { | ||
| 1569 | mutex_unlock(&dev->lock); | ||
| 1570 | return ret; | ||
| 1571 | } | ||
| 1572 | if (dev->state & DEV_DISCONNECTED) { | ||
| 1573 | mutex_unlock(&dev->lock); | ||
| 1574 | return -ENODEV; | ||
| 1575 | } | ||
| 1576 | dev->video_bytesread = 0; | ||
| 1577 | } | ||
| 1578 | |||
| 1579 | f = list_entry(dev->outqueue.prev, struct em28xx_frame_t, frame); | ||
| 1580 | |||
| 1581 | em28xx_queue_unusedframes(dev); | ||
| 1582 | |||
| 1583 | if (count > f->buf.length) | ||
| 1584 | count = f->buf.length; | ||
| 1585 | |||
| 1586 | if ((dev->video_bytesread + count) > dev->frame_size) | ||
| 1587 | count = dev->frame_size - dev->video_bytesread; | ||
| 1588 | |||
| 1589 | if (copy_to_user(buf, f->bufmem+dev->video_bytesread, count)) { | ||
| 1590 | em28xx_err("Error while copying to user\n"); | ||
| 1591 | return -EFAULT; | ||
| 1592 | } | ||
| 1593 | dev->video_bytesread += count; | ||
| 1594 | |||
| 1595 | if (dev->video_bytesread == dev->frame_size) { | ||
| 1596 | spin_lock_irqsave(&dev->queue_lock, lock_flags); | ||
| 1597 | list_for_each_entry(i, &dev->outqueue, frame) | ||
| 1598 | i->state = F_UNUSED; | ||
| 1599 | INIT_LIST_HEAD(&dev->outqueue); | ||
| 1600 | spin_unlock_irqrestore(&dev->queue_lock, lock_flags); | ||
| 1601 | |||
| 1602 | em28xx_queue_unusedframes(dev); | ||
| 1603 | dev->video_bytesread = 0; | ||
| 1604 | } | ||
| 1605 | |||
| 1606 | *f_pos += count; | ||
| 1607 | |||
| 1608 | mutex_unlock(&dev->lock); | ||
| 1609 | |||
| 1610 | return count; | ||
| 1611 | } | 1701 | } |
| 1612 | 1702 | ||
| 1613 | /* | 1703 | /* |
| @@ -1616,46 +1706,21 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count, | |||
| 1616 | */ | 1706 | */ |
| 1617 | static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait) | 1707 | static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait) |
| 1618 | { | 1708 | { |
| 1619 | unsigned int mask = 0; | ||
| 1620 | struct em28xx_fh *fh = filp->private_data; | 1709 | struct em28xx_fh *fh = filp->private_data; |
| 1621 | struct em28xx *dev = fh->dev; | 1710 | struct em28xx *dev = fh->dev; |
| 1711 | int rc; | ||
| 1712 | |||
| 1713 | rc = check_dev(dev); | ||
| 1714 | if (rc < 0) | ||
| 1715 | return rc; | ||
| 1622 | 1716 | ||
| 1623 | if (unlikely(res_get(fh) < 0)) | 1717 | if (unlikely(res_get(fh) < 0)) |
| 1624 | return POLLERR; | 1718 | return POLLERR; |
| 1625 | 1719 | ||
| 1626 | mutex_lock(&dev->lock); | 1720 | if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) |
| 1627 | 1721 | return POLLERR; | |
| 1628 | if (dev->state & DEV_DISCONNECTED) { | ||
| 1629 | em28xx_videodbg("device not present\n"); | ||
| 1630 | } else if (dev->state & DEV_MISCONFIGURED) { | ||
| 1631 | em28xx_videodbg("device is misconfigured; close and open it again\n"); | ||
| 1632 | } else { | ||
| 1633 | if (dev->io == IO_NONE) { | ||
| 1634 | if (!em28xx_request_buffers | ||
| 1635 | (dev, EM28XX_NUM_READ_FRAMES)) { | ||
| 1636 | em28xx_warn | ||
| 1637 | ("poll() failed, not enough memory\n"); | ||
| 1638 | } else { | ||
| 1639 | dev->io = IO_READ; | ||
| 1640 | dev->stream = STREAM_ON; | ||
| 1641 | } | ||
| 1642 | } | ||
| 1643 | |||
| 1644 | if (dev->io == IO_READ) { | ||
| 1645 | em28xx_queue_unusedframes(dev); | ||
| 1646 | poll_wait(filp, &dev->wait_frame, wait); | ||
| 1647 | |||
| 1648 | if (!list_empty(&dev->outqueue)) | ||
| 1649 | mask |= POLLIN | POLLRDNORM; | ||
| 1650 | |||
| 1651 | mutex_unlock(&dev->lock); | ||
| 1652 | |||
| 1653 | return mask; | ||
| 1654 | } | ||
| 1655 | } | ||
| 1656 | 1722 | ||
| 1657 | mutex_unlock(&dev->lock); | 1723 | return videobuf_poll_stream(filp, &fh->vb_vidq, wait); |
| 1658 | return POLLERR; | ||
| 1659 | } | 1724 | } |
| 1660 | 1725 | ||
| 1661 | /* | 1726 | /* |
| @@ -1665,69 +1730,23 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) | |||
| 1665 | { | 1730 | { |
| 1666 | struct em28xx_fh *fh = filp->private_data; | 1731 | struct em28xx_fh *fh = filp->private_data; |
| 1667 | struct em28xx *dev = fh->dev; | 1732 | struct em28xx *dev = fh->dev; |
| 1668 | unsigned long size = vma->vm_end - vma->vm_start; | 1733 | int rc; |
| 1669 | unsigned long start = vma->vm_start; | ||
| 1670 | void *pos; | ||
| 1671 | u32 i; | ||
| 1672 | 1734 | ||
| 1673 | if (unlikely(res_get(fh) < 0)) | 1735 | if (unlikely(res_get(fh) < 0)) |
| 1674 | return -EBUSY; | 1736 | return -EBUSY; |
| 1675 | 1737 | ||
| 1676 | mutex_lock(&dev->lock); | 1738 | rc = check_dev(dev); |
| 1677 | 1739 | if (rc < 0) | |
| 1678 | if (dev->state & DEV_DISCONNECTED) { | 1740 | return rc; |
| 1679 | em28xx_videodbg("mmap: device not present\n"); | ||
| 1680 | mutex_unlock(&dev->lock); | ||
| 1681 | return -ENODEV; | ||
| 1682 | } | ||
| 1683 | |||
| 1684 | if (dev->state & DEV_MISCONFIGURED) { | ||
| 1685 | em28xx_videodbg ("mmap: Device is misconfigured; close and " | ||
| 1686 | "open it again\n"); | ||
| 1687 | mutex_unlock(&dev->lock); | ||
| 1688 | return -EIO; | ||
| 1689 | } | ||
| 1690 | |||
| 1691 | if (dev->io != IO_MMAP || !(vma->vm_flags & VM_WRITE)) { | ||
| 1692 | mutex_unlock(&dev->lock); | ||
| 1693 | return -EINVAL; | ||
| 1694 | } | ||
| 1695 | |||
| 1696 | if (size > PAGE_ALIGN(dev->frame[0].buf.length)) | ||
| 1697 | size = PAGE_ALIGN(dev->frame[0].buf.length); | ||
| 1698 | |||
| 1699 | for (i = 0; i < dev->num_frames; i++) { | ||
| 1700 | if ((dev->frame[i].buf.m.offset >> PAGE_SHIFT) == vma->vm_pgoff) | ||
| 1701 | break; | ||
| 1702 | } | ||
| 1703 | if (i == dev->num_frames) { | ||
| 1704 | em28xx_videodbg("mmap: user supplied mapping address is out of range\n"); | ||
| 1705 | mutex_unlock(&dev->lock); | ||
| 1706 | return -EINVAL; | ||
| 1707 | } | ||
| 1708 | |||
| 1709 | /* VM_IO is eventually going to replace PageReserved altogether */ | ||
| 1710 | vma->vm_flags |= VM_IO; | ||
| 1711 | vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */ | ||
| 1712 | 1741 | ||
| 1713 | pos = dev->frame[i].bufmem; | 1742 | rc = videobuf_mmap_mapper(&fh->vb_vidq, vma); |
| 1714 | while (size > 0) { /* size is page-aligned */ | ||
| 1715 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { | ||
| 1716 | em28xx_videodbg("mmap: vm_insert_page failed\n"); | ||
| 1717 | mutex_unlock(&dev->lock); | ||
| 1718 | return -EAGAIN; | ||
| 1719 | } | ||
| 1720 | start += PAGE_SIZE; | ||
| 1721 | pos += PAGE_SIZE; | ||
| 1722 | size -= PAGE_SIZE; | ||
| 1723 | } | ||
| 1724 | 1743 | ||
| 1725 | vma->vm_ops = &em28xx_vm_ops; | 1744 | em28xx_videodbg("vma start=0x%08lx, size=%ld, ret=%d\n", |
| 1726 | vma->vm_private_data = &dev->frame[i]; | 1745 | (unsigned long)vma->vm_start, |
| 1746 | (unsigned long)vma->vm_end-(unsigned long)vma->vm_start, | ||
| 1747 | rc); | ||
| 1727 | 1748 | ||
| 1728 | em28xx_vm_open(vma); | 1749 | return rc; |
| 1729 | mutex_unlock(&dev->lock); | ||
| 1730 | return 0; | ||
| 1731 | } | 1750 | } |
| 1732 | 1751 | ||
| 1733 | static const struct file_operations em28xx_v4l_fops = { | 1752 | static const struct file_operations em28xx_v4l_fops = { |
| @@ -1790,6 +1809,9 @@ static const struct video_device em28xx_video_template = { | |||
| 1790 | .vidioc_g_register = vidioc_g_register, | 1809 | .vidioc_g_register = vidioc_g_register, |
| 1791 | .vidioc_s_register = vidioc_s_register, | 1810 | .vidioc_s_register = vidioc_s_register, |
| 1792 | #endif | 1811 | #endif |
| 1812 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | ||
| 1813 | .vidiocgmbuf = vidiocgmbuf, | ||
| 1814 | #endif | ||
| 1793 | 1815 | ||
| 1794 | .tvnorms = V4L2_STD_ALL, | 1816 | .tvnorms = V4L2_STD_ALL, |
| 1795 | .current_norm = V4L2_STD_PAL, | 1817 | .current_norm = V4L2_STD_PAL, |
| @@ -1818,7 +1840,7 @@ static struct video_device em28xx_radio_template = { | |||
| 1818 | #endif | 1840 | #endif |
| 1819 | }; | 1841 | }; |
| 1820 | 1842 | ||
| 1821 | /******************************** usb interface *****************************************/ | 1843 | /******************************** usb interface ******************************/ |
| 1822 | 1844 | ||
| 1823 | 1845 | ||
| 1824 | static LIST_HEAD(em28xx_extension_devlist); | 1846 | static LIST_HEAD(em28xx_extension_devlist); |
| @@ -1875,6 +1897,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev, | |||
| 1875 | vfd->dev = &dev->udev->dev; | 1897 | vfd->dev = &dev->udev->dev; |
| 1876 | vfd->release = video_device_release; | 1898 | vfd->release = video_device_release; |
| 1877 | vfd->type = type; | 1899 | vfd->type = type; |
| 1900 | vfd->debug = video_debug; | ||
| 1878 | 1901 | ||
| 1879 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", | 1902 | snprintf(vfd->name, sizeof(vfd->name), "%s %s", |
| 1880 | dev->name, type_name); | 1903 | dev->name, type_name); |
| @@ -1898,7 +1921,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
| 1898 | 1921 | ||
| 1899 | dev->udev = udev; | 1922 | dev->udev = udev; |
| 1900 | mutex_init(&dev->lock); | 1923 | mutex_init(&dev->lock); |
| 1901 | spin_lock_init(&dev->queue_lock); | 1924 | spin_lock_init(&dev->slock); |
| 1902 | init_waitqueue_head(&dev->open); | 1925 | init_waitqueue_head(&dev->open); |
| 1903 | init_waitqueue_head(&dev->wait_frame); | 1926 | init_waitqueue_head(&dev->wait_frame); |
| 1904 | init_waitqueue_head(&dev->wait_stream); | 1927 | init_waitqueue_head(&dev->wait_stream); |
| @@ -1910,10 +1933,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
| 1910 | dev->em28xx_read_reg_req = em28xx_read_reg_req; | 1933 | dev->em28xx_read_reg_req = em28xx_read_reg_req; |
| 1911 | dev->is_em2800 = em28xx_boards[dev->model].is_em2800; | 1934 | dev->is_em2800 = em28xx_boards[dev->model].is_em2800; |
| 1912 | 1935 | ||
| 1913 | errCode = em28xx_read_reg(dev, CHIPID_REG); | ||
| 1914 | if (errCode >= 0) | ||
| 1915 | em28xx_info("em28xx chip ID = %d\n", errCode); | ||
| 1916 | |||
| 1917 | em28xx_pre_card_setup(dev); | 1936 | em28xx_pre_card_setup(dev); |
| 1918 | 1937 | ||
| 1919 | errCode = em28xx_config(dev); | 1938 | errCode = em28xx_config(dev); |
| @@ -1946,10 +1965,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
| 1946 | dev->width = maxw; | 1965 | dev->width = maxw; |
| 1947 | dev->height = maxh; | 1966 | dev->height = maxh; |
| 1948 | dev->interlaced = EM28XX_INTERLACED_DEFAULT; | 1967 | dev->interlaced = EM28XX_INTERLACED_DEFAULT; |
| 1949 | dev->field_size = dev->width * dev->height; | ||
| 1950 | dev->frame_size = | ||
| 1951 | dev->interlaced ? dev->field_size << 1 : dev->field_size; | ||
| 1952 | dev->bytesperline = dev->width * 2; | ||
| 1953 | dev->hscale = 0; | 1968 | dev->hscale = 0; |
| 1954 | dev->vscale = 0; | 1969 | dev->vscale = 0; |
| 1955 | dev->ctl_input = 2; | 1970 | dev->ctl_input = 2; |
| @@ -2005,6 +2020,10 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev, | |||
| 2005 | dev->radio_dev->minor & 0x1f); | 2020 | dev->radio_dev->minor & 0x1f); |
| 2006 | } | 2021 | } |
| 2007 | 2022 | ||
| 2023 | /* init video dma queues */ | ||
| 2024 | INIT_LIST_HEAD(&dev->vidq.active); | ||
| 2025 | INIT_LIST_HEAD(&dev->vidq.queued); | ||
| 2026 | |||
| 2008 | 2027 | ||
| 2009 | if (dev->has_msp34xx) { | 2028 | if (dev->has_msp34xx) { |
| 2010 | /* Send a reset to other chips via gpio */ | 2029 | /* Send a reset to other chips via gpio */ |
| @@ -2048,6 +2067,9 @@ static void request_module_async(struct work_struct *work) | |||
| 2048 | request_module("snd-usb-audio"); | 2067 | request_module("snd-usb-audio"); |
| 2049 | else | 2068 | else |
| 2050 | request_module("em28xx-alsa"); | 2069 | request_module("em28xx-alsa"); |
| 2070 | |||
| 2071 | if (dev->has_dvb) | ||
| 2072 | request_module("em28xx-dvb"); | ||
| 2051 | } | 2073 | } |
| 2052 | 2074 | ||
| 2053 | static void request_modules(struct em28xx *dev) | 2075 | static void request_modules(struct em28xx *dev) |
| @@ -2077,22 +2099,24 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
| 2077 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; | 2099 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; |
| 2078 | 2100 | ||
| 2079 | /* Check to see next free device and mark as used */ | 2101 | /* Check to see next free device and mark as used */ |
| 2080 | nr=find_first_zero_bit(&em28xx_devused,EM28XX_MAXBOARDS); | 2102 | nr = find_first_zero_bit(&em28xx_devused, EM28XX_MAXBOARDS); |
| 2081 | em28xx_devused|=1<<nr; | 2103 | em28xx_devused |= 1<<nr; |
| 2082 | 2104 | ||
| 2083 | /* Don't register audio interfaces */ | 2105 | /* Don't register audio interfaces */ |
| 2084 | if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { | 2106 | if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) { |
| 2085 | em28xx_err(DRIVER_NAME " audio device (%04x:%04x): interface %i, class %i\n", | 2107 | em28xx_err(DRIVER_NAME " audio device (%04x:%04x): interface %i, class %i\n", |
| 2086 | udev->descriptor.idVendor,udev->descriptor.idProduct, | 2108 | udev->descriptor.idVendor, |
| 2109 | udev->descriptor.idProduct, | ||
| 2087 | ifnum, | 2110 | ifnum, |
| 2088 | interface->altsetting[0].desc.bInterfaceClass); | 2111 | interface->altsetting[0].desc.bInterfaceClass); |
| 2089 | 2112 | ||
| 2090 | em28xx_devused&=~(1<<nr); | 2113 | em28xx_devused &= ~(1<<nr); |
| 2091 | return -ENODEV; | 2114 | return -ENODEV; |
| 2092 | } | 2115 | } |
| 2093 | 2116 | ||
| 2094 | em28xx_err(DRIVER_NAME " new video device (%04x:%04x): interface %i, class %i\n", | 2117 | em28xx_err(DRIVER_NAME " new video device (%04x:%04x): interface %i, class %i\n", |
| 2095 | udev->descriptor.idVendor,udev->descriptor.idProduct, | 2118 | udev->descriptor.idVendor, |
| 2119 | udev->descriptor.idProduct, | ||
| 2096 | ifnum, | 2120 | ifnum, |
| 2097 | interface->altsetting[0].desc.bInterfaceClass); | 2121 | interface->altsetting[0].desc.bInterfaceClass); |
| 2098 | 2122 | ||
| @@ -2102,18 +2126,19 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
| 2102 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != | 2126 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != |
| 2103 | USB_ENDPOINT_XFER_ISOC) { | 2127 | USB_ENDPOINT_XFER_ISOC) { |
| 2104 | em28xx_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n"); | 2128 | em28xx_err(DRIVER_NAME " probing error: endpoint is non-ISO endpoint!\n"); |
| 2105 | em28xx_devused&=~(1<<nr); | 2129 | em28xx_devused &= ~(1<<nr); |
| 2106 | return -ENODEV; | 2130 | return -ENODEV; |
| 2107 | } | 2131 | } |
| 2108 | if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) { | 2132 | if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) { |
| 2109 | em28xx_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n"); | 2133 | em28xx_err(DRIVER_NAME " probing error: endpoint is ISO OUT endpoint!\n"); |
| 2110 | em28xx_devused&=~(1<<nr); | 2134 | em28xx_devused &= ~(1<<nr); |
| 2111 | return -ENODEV; | 2135 | return -ENODEV; |
| 2112 | } | 2136 | } |
| 2113 | 2137 | ||
| 2114 | if (nr >= EM28XX_MAXBOARDS) { | 2138 | if (nr >= EM28XX_MAXBOARDS) { |
| 2115 | printk (DRIVER_NAME ": Supports only %i em28xx boards.\n",EM28XX_MAXBOARDS); | 2139 | printk(DRIVER_NAME ": Supports only %i em28xx boards.\n", |
| 2116 | em28xx_devused&=~(1<<nr); | 2140 | EM28XX_MAXBOARDS); |
| 2141 | em28xx_devused &= ~(1<<nr); | ||
| 2117 | return -ENOMEM; | 2142 | return -ENOMEM; |
| 2118 | } | 2143 | } |
| 2119 | 2144 | ||
| @@ -2121,7 +2146,7 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
| 2121 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 2146 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
| 2122 | if (dev == NULL) { | 2147 | if (dev == NULL) { |
| 2123 | em28xx_err(DRIVER_NAME ": out of memory!\n"); | 2148 | em28xx_err(DRIVER_NAME ": out of memory!\n"); |
| 2124 | em28xx_devused&=~(1<<nr); | 2149 | em28xx_devused &= ~(1<<nr); |
| 2125 | return -ENOMEM; | 2150 | return -ENOMEM; |
| 2126 | } | 2151 | } |
| 2127 | 2152 | ||
| @@ -2145,14 +2170,14 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
| 2145 | /* compute alternate max packet sizes */ | 2170 | /* compute alternate max packet sizes */ |
| 2146 | uif = udev->actconfig->interface[0]; | 2171 | uif = udev->actconfig->interface[0]; |
| 2147 | 2172 | ||
| 2148 | dev->num_alt=uif->num_altsetting; | 2173 | dev->num_alt = uif->num_altsetting; |
| 2149 | em28xx_info("Alternate settings: %i\n",dev->num_alt); | 2174 | em28xx_info("Alternate settings: %i\n", dev->num_alt); |
| 2150 | // dev->alt_max_pkt_size = kmalloc(sizeof(*dev->alt_max_pkt_size)* | 2175 | /* dev->alt_max_pkt_size = kmalloc(sizeof(*dev->alt_max_pkt_size)* */ |
| 2151 | dev->alt_max_pkt_size = kmalloc(32* | 2176 | dev->alt_max_pkt_size = kmalloc(32 * dev->num_alt, GFP_KERNEL); |
| 2152 | dev->num_alt,GFP_KERNEL); | 2177 | |
| 2153 | if (dev->alt_max_pkt_size == NULL) { | 2178 | if (dev->alt_max_pkt_size == NULL) { |
| 2154 | em28xx_errdev("out of memory!\n"); | 2179 | em28xx_errdev("out of memory!\n"); |
| 2155 | em28xx_devused&=~(1<<nr); | 2180 | em28xx_devused &= ~(1<<nr); |
| 2156 | kfree(dev); | 2181 | kfree(dev); |
| 2157 | return -ENOMEM; | 2182 | return -ENOMEM; |
| 2158 | } | 2183 | } |
| @@ -2162,11 +2187,11 @@ static int em28xx_usb_probe(struct usb_interface *interface, | |||
| 2162 | wMaxPacketSize); | 2187 | wMaxPacketSize); |
| 2163 | dev->alt_max_pkt_size[i] = | 2188 | dev->alt_max_pkt_size[i] = |
| 2164 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 2189 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
| 2165 | em28xx_info("Alternate setting %i, max size= %i\n",i, | 2190 | em28xx_info("Alternate setting %i, max size= %i\n", i, |
| 2166 | dev->alt_max_pkt_size[i]); | 2191 | dev->alt_max_pkt_size[i]); |
| 2167 | } | 2192 | } |
| 2168 | 2193 | ||
| 2169 | if ((card[nr]>=0)&&(card[nr]<em28xx_bcount)) | 2194 | if ((card[nr] >= 0) && (card[nr] < em28xx_bcount)) |
| 2170 | dev->model = card[nr]; | 2195 | dev->model = card[nr]; |
| 2171 | 2196 | ||
| 2172 | /* allocate device struct */ | 2197 | /* allocate device struct */ |
| @@ -2202,7 +2227,8 @@ static void em28xx_usb_disconnect(struct usb_interface *interface) | |||
| 2202 | 2227 | ||
| 2203 | em28xx_info("disconnecting %s\n", dev->vdev->name); | 2228 | em28xx_info("disconnecting %s\n", dev->vdev->name); |
| 2204 | 2229 | ||
| 2205 | /* wait until all current v4l2 io is finished then deallocate resources */ | 2230 | /* wait until all current v4l2 io is finished then deallocate |
| 2231 | resources */ | ||
| 2206 | mutex_lock(&dev->lock); | 2232 | mutex_lock(&dev->lock); |
| 2207 | 2233 | ||
| 2208 | wake_up_interruptible_all(&dev->open); | 2234 | wake_up_interruptible_all(&dev->open); |
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 04e0e48ecabe..002f170b211a 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h | |||
| @@ -26,11 +26,39 @@ | |||
| 26 | #define _EM28XX_H | 26 | #define _EM28XX_H |
| 27 | 27 | ||
| 28 | #include <linux/videodev2.h> | 28 | #include <linux/videodev2.h> |
| 29 | #include <media/videobuf-vmalloc.h> | ||
| 30 | |||
| 29 | #include <linux/i2c.h> | 31 | #include <linux/i2c.h> |
| 30 | #include <linux/mutex.h> | 32 | #include <linux/mutex.h> |
| 31 | #include <media/ir-kbd-i2c.h> | 33 | #include <media/ir-kbd-i2c.h> |
| 32 | 34 | #if defined(CONFIG_VIDEO_EM28XX_DVB) || defined(CONFIG_VIDEO_EM28XX_DVB_MODULE) | |
| 33 | #define UNSET -1 | 35 | #include <media/videobuf-dvb.h> |
| 36 | #endif | ||
| 37 | #include "tuner-xc2028.h" | ||
| 38 | #include "em28xx-reg.h" | ||
| 39 | |||
| 40 | /* Boards supported by driver */ | ||
| 41 | #define EM2800_BOARD_UNKNOWN 0 | ||
| 42 | #define EM2820_BOARD_UNKNOWN 1 | ||
| 43 | #define EM2820_BOARD_TERRATEC_CINERGY_250 2 | ||
| 44 | #define EM2820_BOARD_PINNACLE_USB_2 3 | ||
| 45 | #define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 4 | ||
| 46 | #define EM2820_BOARD_MSI_VOX_USB_2 5 | ||
| 47 | #define EM2800_BOARD_TERRATEC_CINERGY_200 6 | ||
| 48 | #define EM2800_BOARD_LEADTEK_WINFAST_USBII 7 | ||
| 49 | #define EM2800_BOARD_KWORLD_USB2800 8 | ||
| 50 | #define EM2820_BOARD_PINNACLE_DVC_90 9 | ||
| 51 | #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 10 | ||
| 52 | #define EM2880_BOARD_TERRATEC_HYBRID_XS 11 | ||
| 53 | #define EM2820_BOARD_KWORLD_PVRTV2800RF 12 | ||
| 54 | #define EM2880_BOARD_TERRATEC_PRODIGY_XS 13 | ||
| 55 | #define EM2820_BOARD_PROLINK_PLAYTV_USB2 14 | ||
| 56 | #define EM2800_BOARD_VGEAR_POCKETTV 15 | ||
| 57 | #define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 16 | ||
| 58 | |||
| 59 | /* Limits minimum and default number of buffers */ | ||
| 60 | #define EM28XX_MIN_BUF 4 | ||
| 61 | #define EM28XX_DEF_BUF 8 | ||
| 34 | 62 | ||
| 35 | /* maximum number of em28xx boards */ | 63 | /* maximum number of em28xx boards */ |
| 36 | #define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */ | 64 | #define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */ |
| @@ -81,31 +109,78 @@ | |||
| 81 | /* time in msecs to wait for i2c writes to finish */ | 109 | /* time in msecs to wait for i2c writes to finish */ |
| 82 | #define EM2800_I2C_WRITE_TIMEOUT 20 | 110 | #define EM2800_I2C_WRITE_TIMEOUT 20 |
| 83 | 111 | ||
| 84 | /* the various frame states */ | 112 | enum em28xx_mode { |
| 85 | enum em28xx_frame_state { | 113 | EM28XX_MODE_UNDEFINED, |
| 86 | F_UNUSED = 0, | 114 | EM28XX_ANALOG_MODE, |
| 87 | F_QUEUED, | 115 | EM28XX_DIGITAL_MODE, |
| 88 | F_GRABBING, | ||
| 89 | F_DONE, | ||
| 90 | F_ERROR, | ||
| 91 | }; | 116 | }; |
| 92 | 117 | ||
| 93 | /* stream states */ | ||
| 94 | enum em28xx_stream_state { | 118 | enum em28xx_stream_state { |
| 95 | STREAM_OFF, | 119 | STREAM_OFF, |
| 96 | STREAM_INTERRUPT, | 120 | STREAM_INTERRUPT, |
| 97 | STREAM_ON, | 121 | STREAM_ON, |
| 98 | }; | 122 | }; |
| 99 | 123 | ||
| 100 | /* frames */ | 124 | struct em28xx; |
| 101 | struct em28xx_frame_t { | 125 | |
| 102 | void *bufmem; | 126 | struct em28xx_usb_isoc_ctl { |
| 103 | struct v4l2_buffer buf; | 127 | /* max packet size of isoc transaction */ |
| 104 | enum em28xx_frame_state state; | 128 | int max_pkt_size; |
| 129 | |||
| 130 | /* number of allocated urbs */ | ||
| 131 | int num_bufs; | ||
| 132 | |||
| 133 | /* urb for isoc transfers */ | ||
| 134 | struct urb **urb; | ||
| 135 | |||
| 136 | /* transfer buffers for isoc transfer */ | ||
| 137 | char **transfer_buffer; | ||
| 138 | |||
| 139 | /* Last buffer command and region */ | ||
| 140 | u8 cmd; | ||
| 141 | int pos, size, pktsize; | ||
| 142 | |||
| 143 | /* Last field: ODD or EVEN? */ | ||
| 144 | int field; | ||
| 145 | |||
| 146 | /* Stores incomplete commands */ | ||
| 147 | u32 tmp_buf; | ||
| 148 | int tmp_buf_len; | ||
| 149 | |||
| 150 | /* Stores already requested buffers */ | ||
| 151 | struct em28xx_buffer *buf; | ||
| 152 | |||
| 153 | /* Stores the number of received fields */ | ||
| 154 | int nfields; | ||
| 155 | |||
| 156 | /* isoc urb callback */ | ||
| 157 | int (*isoc_copy) (struct em28xx *dev, struct urb *urb); | ||
| 158 | |||
| 159 | }; | ||
| 160 | |||
| 161 | struct em28xx_fmt { | ||
| 162 | char *name; | ||
| 163 | u32 fourcc; /* v4l2 format id */ | ||
| 164 | }; | ||
| 165 | |||
| 166 | /* buffer for one video frame */ | ||
| 167 | struct em28xx_buffer { | ||
| 168 | /* common v4l buffer stuff -- must be first */ | ||
| 169 | struct videobuf_buffer vb; | ||
| 170 | |||
| 105 | struct list_head frame; | 171 | struct list_head frame; |
| 106 | unsigned long vma_use_count; | ||
| 107 | int top_field; | 172 | int top_field; |
| 108 | int fieldbytesused; | 173 | int receiving; |
| 174 | }; | ||
| 175 | |||
| 176 | struct em28xx_dmaqueue { | ||
| 177 | struct list_head active; | ||
| 178 | struct list_head queued; | ||
| 179 | |||
| 180 | wait_queue_head_t wq; | ||
| 181 | |||
| 182 | /* Counters to control buffer fill */ | ||
| 183 | int pos; | ||
| 109 | }; | 184 | }; |
| 110 | 185 | ||
| 111 | /* io methods */ | 186 | /* io methods */ |
| @@ -152,6 +227,12 @@ enum em28xx_decoder { | |||
| 152 | EM28XX_SAA7114 | 227 | EM28XX_SAA7114 |
| 153 | }; | 228 | }; |
| 154 | 229 | ||
| 230 | struct em28xx_reg_seq { | ||
| 231 | int reg; | ||
| 232 | unsigned char val, mask; | ||
| 233 | int sleep; | ||
| 234 | }; | ||
| 235 | |||
| 155 | struct em28xx_board { | 236 | struct em28xx_board { |
| 156 | char *name; | 237 | char *name; |
| 157 | int vchannels; | 238 | int vchannels; |
| @@ -165,8 +246,7 @@ struct em28xx_board { | |||
| 165 | unsigned int mts_firmware:1; | 246 | unsigned int mts_firmware:1; |
| 166 | unsigned int has_12mhz_i2s:1; | 247 | unsigned int has_12mhz_i2s:1; |
| 167 | unsigned int max_range_640_480:1; | 248 | unsigned int max_range_640_480:1; |
| 168 | 249 | unsigned int has_dvb:1; | |
| 169 | unsigned int analog_gpio; | ||
| 170 | 250 | ||
| 171 | enum em28xx_decoder decoder; | 251 | enum em28xx_decoder decoder; |
| 172 | 252 | ||
| @@ -199,7 +279,10 @@ enum em28xx_dev_state { | |||
| 199 | #define EM28XX_NUM_AUDIO_PACKETS 64 | 279 | #define EM28XX_NUM_AUDIO_PACKETS 64 |
| 200 | #define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */ | 280 | #define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */ |
| 201 | #define EM28XX_CAPTURE_STREAM_EN 1 | 281 | #define EM28XX_CAPTURE_STREAM_EN 1 |
| 282 | |||
| 283 | /* em28xx extensions */ | ||
| 202 | #define EM28XX_AUDIO 0x10 | 284 | #define EM28XX_AUDIO 0x10 |
| 285 | #define EM28XX_DVB 0x20 | ||
| 203 | 286 | ||
| 204 | struct em28xx_audio { | 287 | struct em28xx_audio { |
| 205 | char name[50]; | 288 | char name[50]; |
| @@ -217,13 +300,24 @@ struct em28xx_audio { | |||
| 217 | spinlock_t slock; | 300 | spinlock_t slock; |
| 218 | }; | 301 | }; |
| 219 | 302 | ||
| 303 | struct em28xx; | ||
| 304 | |||
| 305 | struct em28xx_fh { | ||
| 306 | struct em28xx *dev; | ||
| 307 | unsigned int stream_on:1; /* Locks streams */ | ||
| 308 | int radio; | ||
| 309 | |||
| 310 | struct videobuf_queue vb_vidq; | ||
| 311 | |||
| 312 | enum v4l2_buf_type type; | ||
| 313 | }; | ||
| 314 | |||
| 220 | /* main device struct */ | 315 | /* main device struct */ |
| 221 | struct em28xx { | 316 | struct em28xx { |
| 222 | /* generic device properties */ | 317 | /* generic device properties */ |
| 223 | char name[30]; /* name (including minor) of the device */ | 318 | char name[30]; /* name (including minor) of the device */ |
| 224 | int model; /* index in the device_data struct */ | 319 | int model; /* index in the device_data struct */ |
| 225 | int devno; /* marks the number of this device */ | 320 | int devno; /* marks the number of this device */ |
| 226 | unsigned int analog_gpio; | ||
| 227 | unsigned int is_em2800:1; | 321 | unsigned int is_em2800:1; |
| 228 | unsigned int has_msp34xx:1; | 322 | unsigned int has_msp34xx:1; |
| 229 | unsigned int has_tda9887:1; | 323 | unsigned int has_tda9887:1; |
| @@ -231,6 +325,16 @@ struct em28xx { | |||
| 231 | unsigned int has_audio_class:1; | 325 | unsigned int has_audio_class:1; |
| 232 | unsigned int has_12mhz_i2s:1; | 326 | unsigned int has_12mhz_i2s:1; |
| 233 | unsigned int max_range_640_480:1; | 327 | unsigned int max_range_640_480:1; |
| 328 | unsigned int has_dvb:1; | ||
| 329 | |||
| 330 | /* Some older em28xx chips needs a waiting time after writing */ | ||
| 331 | unsigned int wait_after_write; | ||
| 332 | |||
| 333 | /* GPIO sequences for analog and digital mode */ | ||
| 334 | struct em28xx_reg_seq *analog_gpio, *digital_gpio; | ||
| 335 | |||
| 336 | /* GPIO sequences for tuner callbacks */ | ||
| 337 | struct em28xx_reg_seq *tun_analog_gpio, *tun_digital_gpio; | ||
| 234 | 338 | ||
| 235 | int video_inputs; /* number of video inputs */ | 339 | int video_inputs; /* number of video inputs */ |
| 236 | struct list_head devlist; | 340 | struct list_head devlist; |
| @@ -255,36 +359,28 @@ struct em28xx { | |||
| 255 | int mute; | 359 | int mute; |
| 256 | int volume; | 360 | int volume; |
| 257 | /* frame properties */ | 361 | /* frame properties */ |
| 258 | struct em28xx_frame_t frame[EM28XX_NUM_FRAMES]; /* list of frames */ | ||
| 259 | int num_frames; /* number of frames currently in use */ | ||
| 260 | unsigned int frame_count; /* total number of transfered frames */ | ||
| 261 | struct em28xx_frame_t *frame_current; /* the frame that is being filled */ | ||
| 262 | int width; /* current frame width */ | 362 | int width; /* current frame width */ |
| 263 | int height; /* current frame height */ | 363 | int height; /* current frame height */ |
| 264 | int frame_size; /* current frame size */ | ||
| 265 | int field_size; /* current field size */ | ||
| 266 | int bytesperline; | ||
| 267 | int hscale; /* horizontal scale factor (see datasheet) */ | 364 | int hscale; /* horizontal scale factor (see datasheet) */ |
| 268 | int vscale; /* vertical scale factor (see datasheet) */ | 365 | int vscale; /* vertical scale factor (see datasheet) */ |
| 269 | int interlaced; /* 1=interlace fileds, 0=just top fileds */ | 366 | int interlaced; /* 1=interlace fileds, 0=just top fileds */ |
| 270 | int type; | ||
| 271 | unsigned int video_bytesread; /* Number of bytes read */ | 367 | unsigned int video_bytesread; /* Number of bytes read */ |
| 272 | 368 | ||
| 273 | unsigned long hash; /* eeprom hash - for boards with generic ID */ | 369 | unsigned long hash; /* eeprom hash - for boards with generic ID */ |
| 274 | unsigned long i2c_hash; /* i2c devicelist hash - for boards with generic ID */ | 370 | unsigned long i2c_hash; /* i2c devicelist hash - |
| 371 | for boards with generic ID */ | ||
| 275 | 372 | ||
| 276 | struct em28xx_audio *adev; | 373 | struct em28xx_audio *adev; |
| 277 | 374 | ||
| 278 | /* states */ | 375 | /* states */ |
| 279 | enum em28xx_dev_state state; | 376 | enum em28xx_dev_state state; |
| 280 | enum em28xx_stream_state stream; | ||
| 281 | enum em28xx_io_method io; | 377 | enum em28xx_io_method io; |
| 282 | 378 | ||
| 283 | struct work_struct request_module_wk; | 379 | struct work_struct request_module_wk; |
| 284 | 380 | ||
| 285 | /* locks */ | 381 | /* locks */ |
| 286 | struct mutex lock; | 382 | struct mutex lock; |
| 287 | spinlock_t queue_lock; | 383 | /* spinlock_t queue_lock; */ |
| 288 | struct list_head inqueue, outqueue; | 384 | struct list_head inqueue, outqueue; |
| 289 | wait_queue_head_t open, wait_frame, wait_stream; | 385 | wait_queue_head_t open, wait_frame, wait_stream; |
| 290 | struct video_device *vbi_dev; | 386 | struct video_device *vbi_dev; |
| @@ -292,6 +388,11 @@ struct em28xx { | |||
| 292 | 388 | ||
| 293 | unsigned char eedata[256]; | 389 | unsigned char eedata[256]; |
| 294 | 390 | ||
| 391 | /* Isoc control struct */ | ||
| 392 | struct em28xx_dmaqueue vidq; | ||
| 393 | struct em28xx_usb_isoc_ctl isoc_ctl; | ||
| 394 | spinlock_t slock; | ||
| 395 | |||
| 295 | /* usb transfer */ | 396 | /* usb transfer */ |
| 296 | struct usb_device *udev; /* the usb device */ | 397 | struct usb_device *udev; /* the usb device */ |
| 297 | int alt; /* alternate */ | 398 | int alt; /* alternate */ |
| @@ -301,20 +402,21 @@ struct em28xx { | |||
| 301 | struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */ | 402 | struct urb *urb[EM28XX_NUM_BUFS]; /* urb for isoc transfers */ |
| 302 | char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */ | 403 | char *transfer_buffer[EM28XX_NUM_BUFS]; /* transfer buffers for isoc transfer */ |
| 303 | /* helper funcs that call usb_control_msg */ | 404 | /* helper funcs that call usb_control_msg */ |
| 304 | int (*em28xx_write_regs) (struct em28xx * dev, u16 reg, char *buf, | 405 | int (*em28xx_write_regs) (struct em28xx *dev, u16 reg, |
| 305 | int len); | ||
| 306 | int (*em28xx_read_reg) (struct em28xx * dev, u16 reg); | ||
| 307 | int (*em28xx_read_reg_req_len) (struct em28xx * dev, u8 req, u16 reg, | ||
| 308 | char *buf, int len); | 406 | char *buf, int len); |
| 309 | int (*em28xx_write_regs_req) (struct em28xx * dev, u8 req, u16 reg, | 407 | int (*em28xx_read_reg) (struct em28xx *dev, u16 reg); |
| 408 | int (*em28xx_read_reg_req_len) (struct em28xx *dev, u8 req, u16 reg, | ||
| 409 | char *buf, int len); | ||
| 410 | int (*em28xx_write_regs_req) (struct em28xx *dev, u8 req, u16 reg, | ||
| 310 | char *buf, int len); | 411 | char *buf, int len); |
| 311 | int (*em28xx_read_reg_req) (struct em28xx * dev, u8 req, u16 reg); | 412 | int (*em28xx_read_reg_req) (struct em28xx *dev, u8 req, u16 reg); |
| 312 | }; | ||
| 313 | 413 | ||
| 314 | struct em28xx_fh { | 414 | enum em28xx_mode mode; |
| 315 | struct em28xx *dev; | 415 | |
| 316 | unsigned int stream_on:1; /* Locks streams */ | 416 | /* Caches GPO and GPIO registers */ |
| 317 | int radio; | 417 | unsigned char reg_gpo, reg_gpio; |
| 418 | |||
| 419 | struct em28xx_dvb *dvb; | ||
| 318 | }; | 420 | }; |
| 319 | 421 | ||
| 320 | struct em28xx_ops { | 422 | struct em28xx_ops { |
| @@ -351,22 +453,27 @@ int em28xx_colorlevels_set_default(struct em28xx *dev); | |||
| 351 | int em28xx_capture_start(struct em28xx *dev, int start); | 453 | int em28xx_capture_start(struct em28xx *dev, int start); |
| 352 | int em28xx_outfmt_set_yuv422(struct em28xx *dev); | 454 | int em28xx_outfmt_set_yuv422(struct em28xx *dev); |
| 353 | int em28xx_resolution_set(struct em28xx *dev); | 455 | int em28xx_resolution_set(struct em28xx *dev); |
| 354 | int em28xx_init_isoc(struct em28xx *dev); | ||
| 355 | void em28xx_uninit_isoc(struct em28xx *dev); | ||
| 356 | int em28xx_set_alternate(struct em28xx *dev); | 456 | int em28xx_set_alternate(struct em28xx *dev); |
| 457 | int em28xx_init_isoc(struct em28xx *dev, int max_packets, | ||
| 458 | int num_bufs, int max_pkt_size, | ||
| 459 | int (*isoc_copy) (struct em28xx *dev, struct urb *urb)); | ||
| 460 | void em28xx_uninit_isoc(struct em28xx *dev); | ||
| 461 | int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode); | ||
| 462 | int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio); | ||
| 357 | 463 | ||
| 358 | /* Provided by em28xx-video.c */ | 464 | /* Provided by em28xx-video.c */ |
| 359 | int em28xx_register_extension(struct em28xx_ops *dev); | 465 | int em28xx_register_extension(struct em28xx_ops *dev); |
| 360 | void em28xx_unregister_extension(struct em28xx_ops *dev); | 466 | void em28xx_unregister_extension(struct em28xx_ops *dev); |
| 361 | 467 | ||
| 362 | /* Provided by em28xx-cards.c */ | 468 | /* Provided by em28xx-cards.c */ |
| 363 | extern int em2800_variant_detect(struct usb_device* udev,int model); | 469 | extern int em2800_variant_detect(struct usb_device *udev, int model); |
| 364 | extern void em28xx_pre_card_setup(struct em28xx *dev); | 470 | extern void em28xx_pre_card_setup(struct em28xx *dev); |
| 365 | extern void em28xx_card_setup(struct em28xx *dev); | 471 | extern void em28xx_card_setup(struct em28xx *dev); |
| 366 | extern struct em28xx_board em28xx_boards[]; | 472 | extern struct em28xx_board em28xx_boards[]; |
| 367 | extern struct usb_device_id em28xx_id_table[]; | 473 | extern struct usb_device_id em28xx_id_table[]; |
| 368 | extern const unsigned int em28xx_bcount; | 474 | extern const unsigned int em28xx_bcount; |
| 369 | void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir); | 475 | void em28xx_set_ir(struct em28xx *dev, struct IR_i2c *ir); |
| 476 | int em28xx_tuner_callback(void *ptr, int command, int arg); | ||
| 370 | 477 | ||
| 371 | /* Provided by em28xx-input.c */ | 478 | /* Provided by em28xx-input.c */ |
| 372 | /* TODO: Check if the standard get_key handlers on ir-common can be used */ | 479 | /* TODO: Check if the standard get_key handlers on ir-common can be used */ |
| @@ -375,71 +482,6 @@ int em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw); | |||
| 375 | int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key, | 482 | int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key, |
| 376 | u32 *ir_raw); | 483 | u32 *ir_raw); |
| 377 | 484 | ||
| 378 | /* em2800 registers */ | ||
| 379 | #define EM2800_AUDIOSRC_REG 0x08 | ||
| 380 | |||
| 381 | /* em28xx registers */ | ||
| 382 | #define I2C_CLK_REG 0x06 | ||
| 383 | #define CHIPID_REG 0x0a | ||
| 384 | #define USBSUSP_REG 0x0c /* */ | ||
| 385 | |||
| 386 | #define AUDIOSRC_REG 0x0e | ||
| 387 | #define XCLK_REG 0x0f | ||
| 388 | |||
| 389 | #define VINMODE_REG 0x10 | ||
| 390 | #define VINCTRL_REG 0x11 | ||
| 391 | #define VINENABLE_REG 0x12 /* */ | ||
| 392 | |||
| 393 | #define GAMMA_REG 0x14 | ||
| 394 | #define RGAIN_REG 0x15 | ||
| 395 | #define GGAIN_REG 0x16 | ||
| 396 | #define BGAIN_REG 0x17 | ||
| 397 | #define ROFFSET_REG 0x18 | ||
| 398 | #define GOFFSET_REG 0x19 | ||
| 399 | #define BOFFSET_REG 0x1a | ||
| 400 | |||
| 401 | #define OFLOW_REG 0x1b | ||
| 402 | #define HSTART_REG 0x1c | ||
| 403 | #define VSTART_REG 0x1d | ||
| 404 | #define CWIDTH_REG 0x1e | ||
| 405 | #define CHEIGHT_REG 0x1f | ||
| 406 | |||
| 407 | #define YGAIN_REG 0x20 | ||
| 408 | #define YOFFSET_REG 0x21 | ||
| 409 | #define UVGAIN_REG 0x22 | ||
| 410 | #define UOFFSET_REG 0x23 | ||
| 411 | #define VOFFSET_REG 0x24 | ||
| 412 | #define SHARPNESS_REG 0x25 | ||
| 413 | |||
| 414 | #define COMPR_REG 0x26 | ||
| 415 | #define OUTFMT_REG 0x27 | ||
| 416 | |||
| 417 | #define XMIN_REG 0x28 | ||
| 418 | #define XMAX_REG 0x29 | ||
| 419 | #define YMIN_REG 0x2a | ||
| 420 | #define YMAX_REG 0x2b | ||
| 421 | |||
| 422 | #define HSCALELOW_REG 0x30 | ||
| 423 | #define HSCALEHIGH_REG 0x31 | ||
| 424 | #define VSCALELOW_REG 0x32 | ||
| 425 | #define VSCALEHIGH_REG 0x33 | ||
| 426 | |||
| 427 | #define AC97LSB_REG 0x40 | ||
| 428 | #define AC97MSB_REG 0x41 | ||
| 429 | #define AC97ADDR_REG 0x42 | ||
| 430 | #define AC97BUSY_REG 0x43 | ||
| 431 | |||
| 432 | /* em202 registers */ | ||
| 433 | #define MASTER_AC97 0x02 | ||
| 434 | #define LINE_IN_AC97 0x10 | ||
| 435 | #define VIDEO_AC97 0x14 | ||
| 436 | |||
| 437 | /* register settings */ | ||
| 438 | #define EM2800_AUDIO_SRC_TUNER 0x0d | ||
| 439 | #define EM2800_AUDIO_SRC_LINE 0x0c | ||
| 440 | #define EM28XX_AUDIO_SRC_TUNER 0xc0 | ||
| 441 | #define EM28XX_AUDIO_SRC_LINE 0x80 | ||
| 442 | |||
| 443 | /* printk macros */ | 485 | /* printk macros */ |
| 444 | 486 | ||
| 445 | #define em28xx_err(fmt, arg...) do {\ | 487 | #define em28xx_err(fmt, arg...) do {\ |
| @@ -456,80 +498,80 @@ int em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key, | |||
| 456 | printk(KERN_WARNING "%s: "fmt,\ | 498 | printk(KERN_WARNING "%s: "fmt,\ |
| 457 | dev->name , ##arg); } while (0) | 499 | dev->name , ##arg); } while (0) |
| 458 | 500 | ||
| 459 | inline static int em28xx_compression_disable(struct em28xx *dev) | 501 | static inline int em28xx_compression_disable(struct em28xx *dev) |
| 460 | { | 502 | { |
| 461 | /* side effect of disabling scaler and mixer */ | 503 | /* side effect of disabling scaler and mixer */ |
| 462 | return em28xx_write_regs(dev, COMPR_REG, "\x00", 1); | 504 | return em28xx_write_regs(dev, EM28XX_R26_COMPR, "\x00", 1); |
| 463 | } | 505 | } |
| 464 | 506 | ||
| 465 | inline static int em28xx_contrast_get(struct em28xx *dev) | 507 | static inline int em28xx_contrast_get(struct em28xx *dev) |
| 466 | { | 508 | { |
| 467 | return em28xx_read_reg(dev, YGAIN_REG) & 0x1f; | 509 | return em28xx_read_reg(dev, EM28XX_R20_YGAIN) & 0x1f; |
| 468 | } | 510 | } |
| 469 | 511 | ||
| 470 | inline static int em28xx_brightness_get(struct em28xx *dev) | 512 | static inline int em28xx_brightness_get(struct em28xx *dev) |
| 471 | { | 513 | { |
| 472 | return em28xx_read_reg(dev, YOFFSET_REG); | 514 | return em28xx_read_reg(dev, EM28XX_R21_YOFFSET); |
| 473 | } | 515 | } |
| 474 | 516 | ||
| 475 | inline static int em28xx_saturation_get(struct em28xx *dev) | 517 | static inline int em28xx_saturation_get(struct em28xx *dev) |
| 476 | { | 518 | { |
| 477 | return em28xx_read_reg(dev, UVGAIN_REG) & 0x1f; | 519 | return em28xx_read_reg(dev, EM28XX_R22_UVGAIN) & 0x1f; |
| 478 | } | 520 | } |
| 479 | 521 | ||
| 480 | inline static int em28xx_u_balance_get(struct em28xx *dev) | 522 | static inline int em28xx_u_balance_get(struct em28xx *dev) |
| 481 | { | 523 | { |
| 482 | return em28xx_read_reg(dev, UOFFSET_REG); | 524 | return em28xx_read_reg(dev, EM28XX_R23_UOFFSET); |
| 483 | } | 525 | } |
| 484 | 526 | ||
| 485 | inline static int em28xx_v_balance_get(struct em28xx *dev) | 527 | static inline int em28xx_v_balance_get(struct em28xx *dev) |
| 486 | { | 528 | { |
| 487 | return em28xx_read_reg(dev, VOFFSET_REG); | 529 | return em28xx_read_reg(dev, EM28XX_R24_VOFFSET); |
| 488 | } | 530 | } |
| 489 | 531 | ||
| 490 | inline static int em28xx_gamma_get(struct em28xx *dev) | 532 | static inline int em28xx_gamma_get(struct em28xx *dev) |
| 491 | { | 533 | { |
| 492 | return em28xx_read_reg(dev, GAMMA_REG) & 0x3f; | 534 | return em28xx_read_reg(dev, EM28XX_R14_GAMMA) & 0x3f; |
| 493 | } | 535 | } |
| 494 | 536 | ||
| 495 | inline static int em28xx_contrast_set(struct em28xx *dev, s32 val) | 537 | static inline int em28xx_contrast_set(struct em28xx *dev, s32 val) |
| 496 | { | 538 | { |
| 497 | u8 tmp = (u8) val; | 539 | u8 tmp = (u8) val; |
| 498 | return em28xx_write_regs(dev, YGAIN_REG, &tmp, 1); | 540 | return em28xx_write_regs(dev, EM28XX_R20_YGAIN, &tmp, 1); |
| 499 | } | 541 | } |
| 500 | 542 | ||
| 501 | inline static int em28xx_brightness_set(struct em28xx *dev, s32 val) | 543 | static inline int em28xx_brightness_set(struct em28xx *dev, s32 val) |
| 502 | { | 544 | { |
| 503 | u8 tmp = (u8) val; | 545 | u8 tmp = (u8) val; |
| 504 | return em28xx_write_regs(dev, YOFFSET_REG, &tmp, 1); | 546 | return em28xx_write_regs(dev, EM28XX_R21_YOFFSET, &tmp, 1); |
| 505 | } | 547 | } |
| 506 | 548 | ||
| 507 | inline static int em28xx_saturation_set(struct em28xx *dev, s32 val) | 549 | static inline int em28xx_saturation_set(struct em28xx *dev, s32 val) |
| 508 | { | 550 | { |
| 509 | u8 tmp = (u8) val; | 551 | u8 tmp = (u8) val; |
| 510 | return em28xx_write_regs(dev, UVGAIN_REG, &tmp, 1); | 552 | return em28xx_write_regs(dev, EM28XX_R22_UVGAIN, &tmp, 1); |
| 511 | } | 553 | } |
| 512 | 554 | ||
| 513 | inline static int em28xx_u_balance_set(struct em28xx *dev, s32 val) | 555 | static inline int em28xx_u_balance_set(struct em28xx *dev, s32 val) |
| 514 | { | 556 | { |
| 515 | u8 tmp = (u8) val; | 557 | u8 tmp = (u8) val; |
| 516 | return em28xx_write_regs(dev, UOFFSET_REG, &tmp, 1); | 558 | return em28xx_write_regs(dev, EM28XX_R23_UOFFSET, &tmp, 1); |
| 517 | } | 559 | } |
| 518 | 560 | ||
| 519 | inline static int em28xx_v_balance_set(struct em28xx *dev, s32 val) | 561 | static inline int em28xx_v_balance_set(struct em28xx *dev, s32 val) |
| 520 | { | 562 | { |
| 521 | u8 tmp = (u8) val; | 563 | u8 tmp = (u8) val; |
| 522 | return em28xx_write_regs(dev, VOFFSET_REG, &tmp, 1); | 564 | return em28xx_write_regs(dev, EM28XX_R24_VOFFSET, &tmp, 1); |
| 523 | } | 565 | } |
| 524 | 566 | ||
| 525 | inline static int em28xx_gamma_set(struct em28xx *dev, s32 val) | 567 | static inline int em28xx_gamma_set(struct em28xx *dev, s32 val) |
| 526 | { | 568 | { |
| 527 | u8 tmp = (u8) val; | 569 | u8 tmp = (u8) val; |
| 528 | return em28xx_write_regs(dev, GAMMA_REG, &tmp, 1); | 570 | return em28xx_write_regs(dev, EM28XX_R14_GAMMA, &tmp, 1); |
| 529 | } | 571 | } |
| 530 | 572 | ||
| 531 | /*FIXME: maxw should be dependent of alt mode */ | 573 | /*FIXME: maxw should be dependent of alt mode */ |
| 532 | inline static unsigned int norm_maxw(struct em28xx *dev) | 574 | static inline unsigned int norm_maxw(struct em28xx *dev) |
| 533 | { | 575 | { |
| 534 | if (dev->max_range_640_480) | 576 | if (dev->max_range_640_480) |
| 535 | return 640; | 577 | return 640; |
| @@ -537,7 +579,7 @@ inline static unsigned int norm_maxw(struct em28xx *dev) | |||
| 537 | return 720; | 579 | return 720; |
| 538 | } | 580 | } |
| 539 | 581 | ||
| 540 | inline static unsigned int norm_maxh(struct em28xx *dev) | 582 | static inline unsigned int norm_maxh(struct em28xx *dev) |
| 541 | { | 583 | { |
| 542 | if (dev->max_range_640_480) | 584 | if (dev->max_range_640_480) |
| 543 | return 480; | 585 | return 480; |
diff --git a/drivers/media/video/et61x251/et61x251.h b/drivers/media/video/et61x251/et61x251.h index 02c741d8f85a..cc77d144df3c 100644 --- a/drivers/media/video/et61x251/et61x251.h +++ b/drivers/media/video/et61x251/et61x251.h | |||
| @@ -199,7 +199,7 @@ do { \ | |||
| 199 | dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ | 199 | dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ |
| 200 | else if ((level) >= 3) \ | 200 | else if ((level) >= 3) \ |
| 201 | dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", \ | 201 | dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", \ |
| 202 | __FILE__, __FUNCTION__, __LINE__ , ## args); \ | 202 | __FILE__, __func__, __LINE__ , ## args); \ |
| 203 | } \ | 203 | } \ |
| 204 | } while (0) | 204 | } while (0) |
| 205 | # define KDBG(level, fmt, args...) \ | 205 | # define KDBG(level, fmt, args...) \ |
| @@ -209,7 +209,7 @@ do { \ | |||
| 209 | pr_info("et61x251: " fmt "\n", ## args); \ | 209 | pr_info("et61x251: " fmt "\n", ## args); \ |
| 210 | else if ((level) == 3) \ | 210 | else if ((level) == 3) \ |
| 211 | pr_debug("sn9c102: [%s:%s:%d] " fmt "\n", __FILE__, \ | 211 | pr_debug("sn9c102: [%s:%s:%d] " fmt "\n", __FILE__, \ |
| 212 | __FUNCTION__, __LINE__ , ## args); \ | 212 | __func__, __LINE__ , ## args); \ |
| 213 | } \ | 213 | } \ |
| 214 | } while (0) | 214 | } while (0) |
| 215 | # define V4LDBG(level, name, cmd) \ | 215 | # define V4LDBG(level, name, cmd) \ |
| @@ -225,7 +225,7 @@ do { \ | |||
| 225 | 225 | ||
| 226 | #undef PDBG | 226 | #undef PDBG |
| 227 | #define PDBG(fmt, args...) \ | 227 | #define PDBG(fmt, args...) \ |
| 228 | dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", __FILE__, __FUNCTION__, \ | 228 | dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", __FILE__, __func__, \ |
| 229 | __LINE__ , ## args) | 229 | __LINE__ , ## args) |
| 230 | 230 | ||
| 231 | #undef PDBGG | 231 | #undef PDBGG |
diff --git a/drivers/media/video/et61x251/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c index 06b6a3ae06c4..5e749c528a62 100644 --- a/drivers/media/video/et61x251/et61x251_core.c +++ b/drivers/media/video/et61x251/et61x251_core.c | |||
| @@ -2523,7 +2523,9 @@ static const struct file_operations et61x251_fops = { | |||
| 2523 | .open = et61x251_open, | 2523 | .open = et61x251_open, |
| 2524 | .release = et61x251_release, | 2524 | .release = et61x251_release, |
| 2525 | .ioctl = et61x251_ioctl, | 2525 | .ioctl = et61x251_ioctl, |
| 2526 | #ifdef CONFIG_COMPAT | ||
| 2526 | .compat_ioctl = v4l_compat_ioctl32, | 2527 | .compat_ioctl = v4l_compat_ioctl32, |
| 2528 | #endif | ||
| 2527 | .read = et61x251_read, | 2529 | .read = et61x251_read, |
| 2528 | .poll = et61x251_poll, | 2530 | .poll = et61x251_poll, |
| 2529 | .mmap = et61x251_mmap, | 2531 | .mmap = et61x251_mmap, |
| @@ -2538,7 +2540,7 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
| 2538 | { | 2540 | { |
| 2539 | struct usb_device *udev = interface_to_usbdev(intf); | 2541 | struct usb_device *udev = interface_to_usbdev(intf); |
| 2540 | struct et61x251_device* cam; | 2542 | struct et61x251_device* cam; |
| 2541 | static unsigned int dev_nr = 0; | 2543 | static unsigned int dev_nr; |
| 2542 | unsigned int i; | 2544 | unsigned int i; |
| 2543 | int err = 0; | 2545 | int err = 0; |
| 2544 | 2546 | ||
diff --git a/drivers/media/video/hexium_gemini.c b/drivers/media/video/hexium_gemini.c index c7fed3405655..352f84d440fb 100644 --- a/drivers/media/video/hexium_gemini.c +++ b/drivers/media/video/hexium_gemini.c | |||
| @@ -25,12 +25,12 @@ | |||
| 25 | 25 | ||
| 26 | #include <media/saa7146_vv.h> | 26 | #include <media/saa7146_vv.h> |
| 27 | 27 | ||
| 28 | static int debug = 0; | 28 | static int debug; |
| 29 | module_param(debug, int, 0); | 29 | module_param(debug, int, 0); |
| 30 | MODULE_PARM_DESC(debug, "debug verbosity"); | 30 | MODULE_PARM_DESC(debug, "debug verbosity"); |
| 31 | 31 | ||
| 32 | /* global variables */ | 32 | /* global variables */ |
| 33 | static int hexium_num = 0; | 33 | static int hexium_num; |
| 34 | 34 | ||
| 35 | #define HEXIUM_GEMINI 4 | 35 | #define HEXIUM_GEMINI 4 |
| 36 | #define HEXIUM_GEMINI_DUAL 5 | 36 | #define HEXIUM_GEMINI_DUAL 5 |
diff --git a/drivers/media/video/hexium_orion.c b/drivers/media/video/hexium_orion.c index 137c4736da04..8d3c1482e7ea 100644 --- a/drivers/media/video/hexium_orion.c +++ b/drivers/media/video/hexium_orion.c | |||
| @@ -25,12 +25,12 @@ | |||
| 25 | 25 | ||
| 26 | #include <media/saa7146_vv.h> | 26 | #include <media/saa7146_vv.h> |
| 27 | 27 | ||
| 28 | static int debug = 0; | 28 | static int debug; |
| 29 | module_param(debug, int, 0); | 29 | module_param(debug, int, 0); |
| 30 | MODULE_PARM_DESC(debug, "debug verbosity"); | 30 | MODULE_PARM_DESC(debug, "debug verbosity"); |
| 31 | 31 | ||
| 32 | /* global variables */ | 32 | /* global variables */ |
| 33 | static int hexium_num = 0; | 33 | static int hexium_num; |
| 34 | 34 | ||
| 35 | #define HEXIUM_HV_PCI6_ORION 1 | 35 | #define HEXIUM_HV_PCI6_ORION 1 |
| 36 | #define HEXIUM_ORION_1SVHS_3BNC 2 | 36 | #define HEXIUM_ORION_1SVHS_3BNC 2 |
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c index dabafdf71e60..11c5fdedc23b 100644 --- a/drivers/media/video/ir-kbd-i2c.c +++ b/drivers/media/video/ir-kbd-i2c.c | |||
| @@ -50,7 +50,7 @@ | |||
| 50 | static int debug; | 50 | static int debug; |
| 51 | module_param(debug, int, 0644); /* debug level (0,1,2) */ | 51 | module_param(debug, int, 0644); /* debug level (0,1,2) */ |
| 52 | 52 | ||
| 53 | static int hauppauge = 0; | 53 | static int hauppauge; |
| 54 | module_param(hauppauge, int, 0644); /* Choose Hauppauge remote */ | 54 | module_param(hauppauge, int, 0644); /* Choose Hauppauge remote */ |
| 55 | MODULE_PARM_DESC(hauppauge, "Specify Hauppauge remote: 0=black, 1=grey (defaults to 0)"); | 55 | MODULE_PARM_DESC(hauppauge, "Specify Hauppauge remote: 0=black, 1=grey (defaults to 0)"); |
| 56 | 56 | ||
| @@ -153,7 +153,7 @@ static int get_key_fusionhdtv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | |||
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | if(buf[0] !=0 || buf[1] !=0 || buf[2] !=0 || buf[3] != 0) | 155 | if(buf[0] !=0 || buf[1] !=0 || buf[2] !=0 || buf[3] != 0) |
| 156 | dprintk(2, "%s: 0x%2x 0x%2x 0x%2x 0x%2x\n", __FUNCTION__, | 156 | dprintk(2, "%s: 0x%2x 0x%2x 0x%2x 0x%2x\n", __func__, |
| 157 | buf[0], buf[1], buf[2], buf[3]); | 157 | buf[0], buf[1], buf[2], buf[3]); |
| 158 | 158 | ||
| 159 | /* no key pressed or signal from other ir remote */ | 159 | /* no key pressed or signal from other ir remote */ |
| @@ -508,10 +508,10 @@ static int ir_probe(struct i2c_adapter *adap) | |||
| 508 | static const int probe_em28XX[] = { 0x30, 0x47, -1 }; | 508 | static const int probe_em28XX[] = { 0x30, 0x47, -1 }; |
| 509 | static const int probe_cx88[] = { 0x18, 0x6b, 0x71, -1 }; | 509 | static const int probe_cx88[] = { 0x18, 0x6b, 0x71, -1 }; |
| 510 | static const int probe_cx23885[] = { 0x6b, -1 }; | 510 | static const int probe_cx23885[] = { 0x6b, -1 }; |
| 511 | const int *probe = NULL; | 511 | const int *probe; |
| 512 | struct i2c_client c; | 512 | struct i2c_client *c; |
| 513 | unsigned char buf; | 513 | unsigned char buf; |
| 514 | int i,rc; | 514 | int i, rc; |
| 515 | 515 | ||
| 516 | switch (adap->id) { | 516 | switch (adap->id) { |
| 517 | case I2C_HW_B_BT848: | 517 | case I2C_HW_B_BT848: |
| @@ -532,23 +532,27 @@ static int ir_probe(struct i2c_adapter *adap) | |||
| 532 | case I2C_HW_B_CX23885: | 532 | case I2C_HW_B_CX23885: |
| 533 | probe = probe_cx23885; | 533 | probe = probe_cx23885; |
| 534 | break; | 534 | break; |
| 535 | } | 535 | default: |
| 536 | if (NULL == probe) | ||
| 537 | return 0; | 536 | return 0; |
| 537 | } | ||
| 538 | |||
| 539 | c = kzalloc(sizeof(*c), GFP_KERNEL); | ||
| 540 | if (!c) | ||
| 541 | return -ENOMEM; | ||
| 538 | 542 | ||
| 539 | memset(&c,0,sizeof(c)); | 543 | c->adapter = adap; |
| 540 | c.adapter = adap; | ||
| 541 | for (i = 0; -1 != probe[i]; i++) { | 544 | for (i = 0; -1 != probe[i]; i++) { |
| 542 | c.addr = probe[i]; | 545 | c->addr = probe[i]; |
| 543 | rc = i2c_master_recv(&c,&buf,0); | 546 | rc = i2c_master_recv(c, &buf, 0); |
| 544 | dprintk(1,"probe 0x%02x @ %s: %s\n", | 547 | dprintk(1,"probe 0x%02x @ %s: %s\n", |
| 545 | probe[i], adap->name, | 548 | probe[i], adap->name, |
| 546 | (0 == rc) ? "yes" : "no"); | 549 | (0 == rc) ? "yes" : "no"); |
| 547 | if (0 == rc) { | 550 | if (0 == rc) { |
| 548 | ir_attach(adap,probe[i],0,0); | 551 | ir_attach(adap, probe[i], 0, 0); |
| 549 | break; | 552 | break; |
| 550 | } | 553 | } |
| 551 | } | 554 | } |
| 555 | kfree(c); | ||
| 552 | return 0; | 556 | return 0; |
| 553 | } | 557 | } |
| 554 | 558 | ||
diff --git a/drivers/media/video/ivtv/Kconfig b/drivers/media/video/ivtv/Kconfig index 270906fc3146..b6171702c4d0 100644 --- a/drivers/media/video/ivtv/Kconfig +++ b/drivers/media/video/ivtv/Kconfig | |||
| @@ -10,6 +10,7 @@ config VIDEO_IVTV | |||
| 10 | select VIDEO_CX25840 | 10 | select VIDEO_CX25840 |
| 11 | select VIDEO_MSP3400 | 11 | select VIDEO_MSP3400 |
| 12 | select VIDEO_SAA711X | 12 | select VIDEO_SAA711X |
| 13 | select VIDEO_SAA717X | ||
| 13 | select VIDEO_SAA7127 | 14 | select VIDEO_SAA7127 |
| 14 | select VIDEO_TVAUDIO | 15 | select VIDEO_TVAUDIO |
| 15 | select VIDEO_CS53L32A | 16 | select VIDEO_CS53L32A |
diff --git a/drivers/media/video/ivtv/ivtv-cards.c b/drivers/media/video/ivtv/ivtv-cards.c index f23c6b8d6911..e908649ea37c 100644 --- a/drivers/media/video/ivtv/ivtv-cards.c +++ b/drivers/media/video/ivtv/ivtv-cards.c | |||
| @@ -416,11 +416,10 @@ static const struct ivtv_card ivtv_card_avc2410 = { | |||
| 416 | on the country/region setting of the user to decide which tuner | 416 | on the country/region setting of the user to decide which tuner |
| 417 | is available. */ | 417 | is available. */ |
| 418 | .tuners = { | 418 | .tuners = { |
| 419 | /* This tuner has been verified for the AVC2410 */ | ||
| 420 | { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, | 419 | { .std = V4L2_STD_625_50, .tuner = TUNER_PHILIPS_FM1216ME_MK3 }, |
| 421 | /* This is a good guess, but I'm not totally sure this is | 420 | { .std = V4L2_STD_ALL - V4L2_STD_NTSC_M_JP, |
| 422 | the correct tuner for NTSC. */ | 421 | .tuner = TUNER_PHILIPS_FM1236_MK3 }, |
| 423 | { .std = V4L2_STD_ALL, .tuner = TUNER_PHILIPS_FM1236_MK3 }, | 422 | { .std = V4L2_STD_NTSC_M_JP, .tuner = TUNER_PHILIPS_FQ1286 }, |
| 424 | }, | 423 | }, |
| 425 | .pci_list = ivtv_pci_avc2410, | 424 | .pci_list = ivtv_pci_avc2410, |
| 426 | .i2c = &ivtv_i2c_std, | 425 | .i2c = &ivtv_i2c_std, |
diff --git a/drivers/media/video/ivtv/ivtv-cards.h b/drivers/media/video/ivtv/ivtv-cards.h index 191aafdd9968..9186fa2ee5fc 100644 --- a/drivers/media/video/ivtv/ivtv-cards.h +++ b/drivers/media/video/ivtv/ivtv-cards.h | |||
| @@ -119,7 +119,7 @@ | |||
| 119 | 119 | ||
| 120 | #define IVTV_CARD_MAX_VIDEO_INPUTS 6 | 120 | #define IVTV_CARD_MAX_VIDEO_INPUTS 6 |
| 121 | #define IVTV_CARD_MAX_AUDIO_INPUTS 3 | 121 | #define IVTV_CARD_MAX_AUDIO_INPUTS 3 |
| 122 | #define IVTV_CARD_MAX_TUNERS 2 | 122 | #define IVTV_CARD_MAX_TUNERS 3 |
| 123 | 123 | ||
| 124 | /* SAA71XX HW inputs */ | 124 | /* SAA71XX HW inputs */ |
| 125 | #define IVTV_SAA71XX_COMPOSITE0 0 | 125 | #define IVTV_SAA71XX_COMPOSITE0 0 |
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c index 948ca35e7ee8..065df53f80fd 100644 --- a/drivers/media/video/ivtv/ivtv-driver.c +++ b/drivers/media/video/ivtv/ivtv-driver.c | |||
| @@ -101,7 +101,7 @@ static int radio[IVTV_MAX_CARDS] = { -1, -1, -1, -1, -1, -1, -1, -1, | |||
| 101 | static unsigned int cardtype_c = 1; | 101 | static unsigned int cardtype_c = 1; |
| 102 | static unsigned int tuner_c = 1; | 102 | static unsigned int tuner_c = 1; |
| 103 | static unsigned int radio_c = 1; | 103 | static unsigned int radio_c = 1; |
| 104 | static char pal[] = "--"; | 104 | static char pal[] = "---"; |
| 105 | static char secam[] = "--"; | 105 | static char secam[] = "--"; |
| 106 | static char ntsc[] = "-"; | 106 | static char ntsc[] = "-"; |
| 107 | 107 | ||
| @@ -126,12 +126,13 @@ static int dec_mpg_buffers = IVTV_DEFAULT_DEC_MPG_BUFFERS; | |||
| 126 | static int dec_yuv_buffers = IVTV_DEFAULT_DEC_YUV_BUFFERS; | 126 | static int dec_yuv_buffers = IVTV_DEFAULT_DEC_YUV_BUFFERS; |
| 127 | static int dec_vbi_buffers = IVTV_DEFAULT_DEC_VBI_BUFFERS; | 127 | static int dec_vbi_buffers = IVTV_DEFAULT_DEC_VBI_BUFFERS; |
| 128 | 128 | ||
| 129 | static int ivtv_yuv_mode = 0; | 129 | static int ivtv_yuv_mode; |
| 130 | static int ivtv_yuv_threshold=-1; | 130 | static int ivtv_yuv_threshold = -1; |
| 131 | static int ivtv_pci_latency = 1; | 131 | static int ivtv_pci_latency = 1; |
| 132 | 132 | ||
| 133 | int ivtv_debug = 0; | 133 | int ivtv_debug; |
| 134 | 134 | ||
| 135 | static int tunertype = -1; | ||
| 135 | static int newi2c = -1; | 136 | static int newi2c = -1; |
| 136 | 137 | ||
| 137 | module_param_array(tuner, int, &tuner_c, 0644); | 138 | module_param_array(tuner, int, &tuner_c, 0644); |
| @@ -154,6 +155,7 @@ module_param(dec_mpg_buffers, int, 0644); | |||
| 154 | module_param(dec_yuv_buffers, int, 0644); | 155 | module_param(dec_yuv_buffers, int, 0644); |
| 155 | module_param(dec_vbi_buffers, int, 0644); | 156 | module_param(dec_vbi_buffers, int, 0644); |
| 156 | 157 | ||
| 158 | module_param(tunertype, int, 0644); | ||
| 157 | module_param(newi2c, int, 0644); | 159 | module_param(newi2c, int, 0644); |
| 158 | 160 | ||
| 159 | MODULE_PARM_DESC(tuner, "Tuner type selection,\n" | 161 | MODULE_PARM_DESC(tuner, "Tuner type selection,\n" |
| @@ -190,9 +192,14 @@ MODULE_PARM_DESC(cardtype, | |||
| 190 | "\t\t\t24 = AverMedia EZMaker PCI Deluxe\n" | 192 | "\t\t\t24 = AverMedia EZMaker PCI Deluxe\n" |
| 191 | "\t\t\t 0 = Autodetect (default)\n" | 193 | "\t\t\t 0 = Autodetect (default)\n" |
| 192 | "\t\t\t-1 = Ignore this card\n\t\t"); | 194 | "\t\t\t-1 = Ignore this card\n\t\t"); |
| 193 | MODULE_PARM_DESC(pal, "Set PAL standard: B, G, H, D, K, I, M, N, Nc, 60"); | 195 | MODULE_PARM_DESC(pal, "Set PAL standard: BGH, DK, I, M, N, Nc, 60"); |
| 194 | MODULE_PARM_DESC(secam, "Set SECAM standard: B, G, H, D, K, L, LC"); | 196 | MODULE_PARM_DESC(secam, "Set SECAM standard: BGH, DK, L, LC"); |
| 195 | MODULE_PARM_DESC(ntsc, "Set NTSC standard: M, J, K"); | 197 | MODULE_PARM_DESC(ntsc, "Set NTSC standard: M, J (Japan), K (South Korea)"); |
| 198 | MODULE_PARM_DESC(tunertype, | ||
| 199 | "Specify tuner type:\n" | ||
| 200 | "\t\t\t 0 = tuner for PAL-B/G/H/D/K/I, SECAM-B/G/H/D/K/L/Lc\n" | ||
| 201 | "\t\t\t 1 = tuner for NTSC-M/J/K, PAL-M/N/Nc\n" | ||
| 202 | "\t\t\t-1 = Autodetect (default)\n"); | ||
| 196 | MODULE_PARM_DESC(debug, | 203 | MODULE_PARM_DESC(debug, |
| 197 | "Debug level (bitmask). Default: 0\n" | 204 | "Debug level (bitmask). Default: 0\n" |
| 198 | "\t\t\t 1/0x0001: warning\n" | 205 | "\t\t\t 1/0x0001: warning\n" |
| @@ -490,30 +497,35 @@ static v4l2_std_id ivtv_parse_std(struct ivtv *itv) | |||
| 490 | { | 497 | { |
| 491 | switch (pal[0]) { | 498 | switch (pal[0]) { |
| 492 | case '6': | 499 | case '6': |
| 500 | tunertype = 0; | ||
| 493 | return V4L2_STD_PAL_60; | 501 | return V4L2_STD_PAL_60; |
| 494 | case 'b': | 502 | case 'b': |
| 495 | case 'B': | 503 | case 'B': |
| 496 | case 'g': | 504 | case 'g': |
| 497 | case 'G': | 505 | case 'G': |
| 498 | return V4L2_STD_PAL_BG; | ||
| 499 | case 'h': | 506 | case 'h': |
| 500 | case 'H': | 507 | case 'H': |
| 501 | return V4L2_STD_PAL_H; | 508 | tunertype = 0; |
| 509 | return V4L2_STD_PAL_BG | V4L2_STD_PAL_H; | ||
| 502 | case 'n': | 510 | case 'n': |
| 503 | case 'N': | 511 | case 'N': |
| 512 | tunertype = 1; | ||
| 504 | if (pal[1] == 'c' || pal[1] == 'C') | 513 | if (pal[1] == 'c' || pal[1] == 'C') |
| 505 | return V4L2_STD_PAL_Nc; | 514 | return V4L2_STD_PAL_Nc; |
| 506 | return V4L2_STD_PAL_N; | 515 | return V4L2_STD_PAL_N; |
| 507 | case 'i': | 516 | case 'i': |
| 508 | case 'I': | 517 | case 'I': |
| 518 | tunertype = 0; | ||
| 509 | return V4L2_STD_PAL_I; | 519 | return V4L2_STD_PAL_I; |
| 510 | case 'd': | 520 | case 'd': |
| 511 | case 'D': | 521 | case 'D': |
| 512 | case 'k': | 522 | case 'k': |
| 513 | case 'K': | 523 | case 'K': |
| 524 | tunertype = 0; | ||
| 514 | return V4L2_STD_PAL_DK; | 525 | return V4L2_STD_PAL_DK; |
| 515 | case 'M': | 526 | case 'M': |
| 516 | case 'm': | 527 | case 'm': |
| 528 | tunertype = 1; | ||
| 517 | return V4L2_STD_PAL_M; | 529 | return V4L2_STD_PAL_M; |
| 518 | case '-': | 530 | case '-': |
| 519 | break; | 531 | break; |
| @@ -529,14 +541,17 @@ static v4l2_std_id ivtv_parse_std(struct ivtv *itv) | |||
| 529 | case 'G': | 541 | case 'G': |
| 530 | case 'h': | 542 | case 'h': |
| 531 | case 'H': | 543 | case 'H': |
| 544 | tunertype = 0; | ||
| 532 | return V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H; | 545 | return V4L2_STD_SECAM_B | V4L2_STD_SECAM_G | V4L2_STD_SECAM_H; |
| 533 | case 'd': | 546 | case 'd': |
| 534 | case 'D': | 547 | case 'D': |
| 535 | case 'k': | 548 | case 'k': |
| 536 | case 'K': | 549 | case 'K': |
| 550 | tunertype = 0; | ||
| 537 | return V4L2_STD_SECAM_DK; | 551 | return V4L2_STD_SECAM_DK; |
| 538 | case 'l': | 552 | case 'l': |
| 539 | case 'L': | 553 | case 'L': |
| 554 | tunertype = 0; | ||
| 540 | if (secam[1] == 'C' || secam[1] == 'c') | 555 | if (secam[1] == 'C' || secam[1] == 'c') |
| 541 | return V4L2_STD_SECAM_LC; | 556 | return V4L2_STD_SECAM_LC; |
| 542 | return V4L2_STD_SECAM_L; | 557 | return V4L2_STD_SECAM_L; |
| @@ -550,12 +565,15 @@ static v4l2_std_id ivtv_parse_std(struct ivtv *itv) | |||
| 550 | switch (ntsc[0]) { | 565 | switch (ntsc[0]) { |
| 551 | case 'm': | 566 | case 'm': |
| 552 | case 'M': | 567 | case 'M': |
| 568 | tunertype = 1; | ||
| 553 | return V4L2_STD_NTSC_M; | 569 | return V4L2_STD_NTSC_M; |
| 554 | case 'j': | 570 | case 'j': |
| 555 | case 'J': | 571 | case 'J': |
| 572 | tunertype = 1; | ||
| 556 | return V4L2_STD_NTSC_M_JP; | 573 | return V4L2_STD_NTSC_M_JP; |
| 557 | case 'k': | 574 | case 'k': |
| 558 | case 'K': | 575 | case 'K': |
| 576 | tunertype = 1; | ||
| 559 | return V4L2_STD_NTSC_M_KR; | 577 | return V4L2_STD_NTSC_M_KR; |
| 560 | case '-': | 578 | case '-': |
| 561 | break; | 579 | break; |
| @@ -584,8 +602,13 @@ static void ivtv_process_options(struct ivtv *itv) | |||
| 584 | itv->options.tuner = tuner[itv->num]; | 602 | itv->options.tuner = tuner[itv->num]; |
| 585 | itv->options.radio = radio[itv->num]; | 603 | itv->options.radio = radio[itv->num]; |
| 586 | itv->options.newi2c = newi2c; | 604 | itv->options.newi2c = newi2c; |
| 587 | 605 | if (tunertype < -1 || tunertype > 1) { | |
| 606 | IVTV_WARN("Invalid tunertype argument, will autodetect instead\n"); | ||
| 607 | tunertype = -1; | ||
| 608 | } | ||
| 588 | itv->std = ivtv_parse_std(itv); | 609 | itv->std = ivtv_parse_std(itv); |
| 610 | if (itv->std == 0 && tunertype >= 0) | ||
| 611 | itv->std = tunertype ? V4L2_STD_MN : (V4L2_STD_ALL & ~V4L2_STD_MN); | ||
| 589 | itv->has_cx23415 = (itv->dev->device == PCI_DEVICE_ID_IVTV15); | 612 | itv->has_cx23415 = (itv->dev->device == PCI_DEVICE_ID_IVTV15); |
| 590 | chipname = itv->has_cx23415 ? "cx23415" : "cx23416"; | 613 | chipname = itv->has_cx23415 ? "cx23415" : "cx23416"; |
| 591 | if (itv->options.cardtype == -1) { | 614 | if (itv->options.cardtype == -1) { |
| @@ -711,6 +734,7 @@ static int __devinit ivtv_init_struct1(struct ivtv *itv) | |||
| 711 | itv->yuv_info.lace_mode = ivtv_yuv_mode; | 734 | itv->yuv_info.lace_mode = ivtv_yuv_mode; |
| 712 | itv->yuv_info.lace_threshold = ivtv_yuv_threshold; | 735 | itv->yuv_info.lace_threshold = ivtv_yuv_threshold; |
| 713 | itv->yuv_info.max_frames_buffered = 3; | 736 | itv->yuv_info.max_frames_buffered = 3; |
| 737 | itv->yuv_info.track_osd = 1; | ||
| 714 | return 0; | 738 | return 0; |
| 715 | } | 739 | } |
| 716 | 740 | ||
| @@ -859,7 +883,9 @@ static void ivtv_load_and_init_modules(struct ivtv *itv) | |||
| 859 | #ifndef CONFIG_VIDEO_SAA7127 | 883 | #ifndef CONFIG_VIDEO_SAA7127 |
| 860 | hw = ivtv_request_module(itv, hw, "saa7127", IVTV_HW_SAA7127); | 884 | hw = ivtv_request_module(itv, hw, "saa7127", IVTV_HW_SAA7127); |
| 861 | #endif | 885 | #endif |
| 886 | #ifndef CONFIG_VIDEO_SAA717X | ||
| 862 | hw = ivtv_request_module(itv, hw, "saa717x", IVTV_HW_SAA717X); | 887 | hw = ivtv_request_module(itv, hw, "saa717x", IVTV_HW_SAA717X); |
| 888 | #endif | ||
| 863 | #ifndef CONFIG_VIDEO_UPD64031A | 889 | #ifndef CONFIG_VIDEO_UPD64031A |
| 864 | hw = ivtv_request_module(itv, hw, "upd64031a", IVTV_HW_UPD64031A); | 890 | hw = ivtv_request_module(itv, hw, "upd64031a", IVTV_HW_UPD64031A); |
| 865 | #endif | 891 | #endif |
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h index 536140f0c19e..ba06e813c58c 100644 --- a/drivers/media/video/ivtv/ivtv-driver.h +++ b/drivers/media/video/ivtv/ivtv-driver.h | |||
| @@ -456,6 +456,8 @@ struct yuv_playback_info | |||
| 456 | int v_filter_2; | 456 | int v_filter_2; |
| 457 | int h_filter; | 457 | int h_filter; |
| 458 | 458 | ||
| 459 | u8 track_osd; /* Should yuv output track the OSD size & position */ | ||
| 460 | |||
| 459 | u32 osd_x_offset; | 461 | u32 osd_x_offset; |
| 460 | u32 osd_y_offset; | 462 | u32 osd_y_offset; |
| 461 | 463 | ||
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c index 6fb96f19a866..a7640c49f1d8 100644 --- a/drivers/media/video/ivtv/ivtv-fileops.c +++ b/drivers/media/video/ivtv/ivtv-fileops.c | |||
| @@ -219,7 +219,9 @@ static struct ivtv_buffer *ivtv_get_buffer(struct ivtv_stream *s, int non_block, | |||
| 219 | /* Process pending program info updates and pending VBI data */ | 219 | /* Process pending program info updates and pending VBI data */ |
| 220 | ivtv_update_pgm_info(itv); | 220 | ivtv_update_pgm_info(itv); |
| 221 | 221 | ||
| 222 | if (jiffies - itv->dualwatch_jiffies > msecs_to_jiffies(1000)) { | 222 | if (time_after(jiffies, |
| 223 | itv->dualwatch_jiffies + | ||
| 224 | msecs_to_jiffies(1000))) { | ||
| 223 | itv->dualwatch_jiffies = jiffies; | 225 | itv->dualwatch_jiffies = jiffies; |
| 224 | ivtv_dualwatch(itv); | 226 | ivtv_dualwatch(itv); |
| 225 | } | 227 | } |
| @@ -753,7 +755,7 @@ unsigned int ivtv_v4l2_enc_poll(struct file *filp, poll_table * wait) | |||
| 753 | IVTV_DEBUG_HI_FILE("Encoder poll\n"); | 755 | IVTV_DEBUG_HI_FILE("Encoder poll\n"); |
| 754 | poll_wait(filp, &s->waitq, wait); | 756 | poll_wait(filp, &s->waitq, wait); |
| 755 | 757 | ||
| 756 | if (eof || s->q_full.length) | 758 | if (eof || s->q_full.length || s->q_io.length) |
| 757 | return POLLIN | POLLRDNORM; | 759 | return POLLIN | POLLRDNORM; |
| 758 | return 0; | 760 | return 0; |
| 759 | } | 761 | } |
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c index fa5ab1eb1800..9824eafee021 100644 --- a/drivers/media/video/ivtv/ivtv-i2c.c +++ b/drivers/media/video/ivtv/ivtv-i2c.c | |||
| @@ -177,10 +177,16 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx) | |||
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | if (id != I2C_DRIVERID_TUNER) { | 179 | if (id != I2C_DRIVERID_TUNER) { |
| 180 | c = i2c_new_device(&itv->i2c_adap, &info); | 180 | if (id == I2C_DRIVERID_UPD64031A || |
| 181 | if (c->driver == NULL) | 181 | id == I2C_DRIVERID_UPD64083) { |
| 182 | unsigned short addrs[2] = { info.addr, I2C_CLIENT_END }; | ||
| 183 | |||
| 184 | c = i2c_new_probed_device(&itv->i2c_adap, &info, addrs); | ||
| 185 | } else | ||
| 186 | c = i2c_new_device(&itv->i2c_adap, &info); | ||
| 187 | if (c && c->driver == NULL) | ||
| 182 | i2c_unregister_device(c); | 188 | i2c_unregister_device(c); |
| 183 | else | 189 | else if (c) |
| 184 | itv->i2c_clients[i] = c; | 190 | itv->i2c_clients[i] = c; |
| 185 | return itv->i2c_clients[i] ? 0 : -ENODEV; | 191 | return itv->i2c_clients[i] ? 0 : -ENODEV; |
| 186 | } | 192 | } |
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c index edef2a579617..15cac1812122 100644 --- a/drivers/media/video/ivtv/ivtv-ioctl.c +++ b/drivers/media/video/ivtv/ivtv-ioctl.c | |||
| @@ -712,6 +712,7 @@ static int ivtv_debug_ioctls(struct file *filp, unsigned int cmd, void *arg) | |||
| 712 | int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg) | 712 | int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg) |
| 713 | { | 713 | { |
| 714 | struct ivtv_open_id *id = NULL; | 714 | struct ivtv_open_id *id = NULL; |
| 715 | struct yuv_playback_info *yi = &itv->yuv_info; | ||
| 715 | u32 data[CX2341X_MBOX_MAX_DATA]; | 716 | u32 data[CX2341X_MBOX_MAX_DATA]; |
| 716 | int streamtype = 0; | 717 | int streamtype = 0; |
| 717 | 718 | ||
| @@ -741,7 +742,8 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
| 741 | 742 | ||
| 742 | memset(vcap, 0, sizeof(*vcap)); | 743 | memset(vcap, 0, sizeof(*vcap)); |
| 743 | strcpy(vcap->driver, IVTV_DRIVER_NAME); /* driver name */ | 744 | strcpy(vcap->driver, IVTV_DRIVER_NAME); /* driver name */ |
| 744 | strcpy(vcap->card, itv->card_name); /* card type */ | 745 | strncpy(vcap->card, itv->card_name, |
| 746 | sizeof(vcap->card)-1); /* card type */ | ||
| 745 | strcpy(vcap->bus_info, pci_name(itv->dev)); /* bus info... */ | 747 | strcpy(vcap->bus_info, pci_name(itv->dev)); /* bus info... */ |
| 746 | vcap->version = IVTV_DRIVER_VERSION; /* version */ | 748 | vcap->version = IVTV_DRIVER_VERSION; /* version */ |
| 747 | vcap->capabilities = itv->v4l2_cap; /* capabilities */ | 749 | vcap->capabilities = itv->v4l2_cap; /* capabilities */ |
| @@ -827,8 +829,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
| 827 | case VIDIOC_CROPCAP: { | 829 | case VIDIOC_CROPCAP: { |
| 828 | struct v4l2_cropcap *cropcap = arg; | 830 | struct v4l2_cropcap *cropcap = arg; |
| 829 | 831 | ||
| 830 | if (cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && | 832 | if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) |
| 831 | cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT) | ||
| 832 | return -EINVAL; | 833 | return -EINVAL; |
| 833 | cropcap->bounds.top = cropcap->bounds.left = 0; | 834 | cropcap->bounds.top = cropcap->bounds.left = 0; |
| 834 | cropcap->bounds.width = 720; | 835 | cropcap->bounds.width = 720; |
| @@ -837,8 +838,14 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
| 837 | cropcap->pixelaspect.numerator = itv->is_50hz ? 59 : 10; | 838 | cropcap->pixelaspect.numerator = itv->is_50hz ? 59 : 10; |
| 838 | cropcap->pixelaspect.denominator = itv->is_50hz ? 54 : 11; | 839 | cropcap->pixelaspect.denominator = itv->is_50hz ? 54 : 11; |
| 839 | } else if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) { | 840 | } else if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) { |
| 840 | cropcap->bounds.width = itv->yuv_info.osd_full_w; | 841 | if (yi->track_osd) { |
| 841 | cropcap->bounds.height = itv->yuv_info.osd_full_h; | 842 | cropcap->bounds.width = yi->osd_full_w; |
| 843 | cropcap->bounds.height = yi->osd_full_h; | ||
| 844 | } else { | ||
| 845 | cropcap->bounds.width = 720; | ||
| 846 | cropcap->bounds.height = | ||
| 847 | itv->is_out_50hz ? 576 : 480; | ||
| 848 | } | ||
| 842 | cropcap->pixelaspect.numerator = itv->is_out_50hz ? 59 : 10; | 849 | cropcap->pixelaspect.numerator = itv->is_out_50hz ? 59 : 10; |
| 843 | cropcap->pixelaspect.denominator = itv->is_out_50hz ? 54 : 11; | 850 | cropcap->pixelaspect.denominator = itv->is_out_50hz ? 54 : 11; |
| 844 | } else { | 851 | } else { |
| @@ -856,7 +863,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
| 856 | if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && | 863 | if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && |
| 857 | (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) { | 864 | (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) { |
| 858 | if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) { | 865 | if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) { |
| 859 | itv->yuv_info.main_rect = crop->c; | 866 | yi->main_rect = crop->c; |
| 860 | return 0; | 867 | return 0; |
| 861 | } else { | 868 | } else { |
| 862 | if (!ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4, | 869 | if (!ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4, |
| @@ -867,9 +874,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
| 867 | } | 874 | } |
| 868 | return -EINVAL; | 875 | return -EINVAL; |
| 869 | } | 876 | } |
| 870 | if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 877 | return -EINVAL; |
| 871 | return -EINVAL; | ||
| 872 | return itv->video_dec_func(itv, VIDIOC_S_CROP, arg); | ||
| 873 | } | 878 | } |
| 874 | 879 | ||
| 875 | case VIDIOC_G_CROP: { | 880 | case VIDIOC_G_CROP: { |
| @@ -878,14 +883,12 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
| 878 | if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && | 883 | if (crop->type == V4L2_BUF_TYPE_VIDEO_OUTPUT && |
| 879 | (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) { | 884 | (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) { |
| 880 | if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) | 885 | if (streamtype == IVTV_DEC_STREAM_TYPE_YUV) |
| 881 | crop->c = itv->yuv_info.main_rect; | 886 | crop->c = yi->main_rect; |
| 882 | else | 887 | else |
| 883 | crop->c = itv->main_rect; | 888 | crop->c = itv->main_rect; |
| 884 | return 0; | 889 | return 0; |
| 885 | } | 890 | } |
| 886 | if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 891 | return -EINVAL; |
| 887 | return -EINVAL; | ||
| 888 | return itv->video_dec_func(itv, VIDIOC_G_CROP, arg); | ||
| 889 | } | 892 | } |
| 890 | 893 | ||
| 891 | case VIDIOC_ENUM_FMT: { | 894 | case VIDIOC_ENUM_FMT: { |
| @@ -1070,11 +1073,10 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
| 1070 | itv->main_rect.height = itv->params.height; | 1073 | itv->main_rect.height = itv->params.height; |
| 1071 | ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4, | 1074 | ivtv_vapi(itv, CX2341X_OSD_SET_FRAMEBUFFER_WINDOW, 4, |
| 1072 | 720, itv->main_rect.height, 0, 0); | 1075 | 720, itv->main_rect.height, 0, 0); |
| 1073 | itv->yuv_info.main_rect = itv->main_rect; | 1076 | yi->main_rect = itv->main_rect; |
| 1074 | if (!itv->osd_info) { | 1077 | if (!itv->osd_info) { |
| 1075 | itv->yuv_info.osd_full_w = 720; | 1078 | yi->osd_full_w = 720; |
| 1076 | itv->yuv_info.osd_full_h = | 1079 | yi->osd_full_h = itv->is_out_50hz ? 576 : 480; |
| 1077 | itv->is_out_50hz ? 576 : 480; | ||
| 1078 | } | 1080 | } |
| 1079 | } | 1081 | } |
| 1080 | break; | 1082 | break; |
| @@ -1272,6 +1274,8 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
| 1272 | else | 1274 | else |
| 1273 | fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA; | 1275 | fb->flags |= V4L2_FBUF_FLAG_LOCAL_ALPHA; |
| 1274 | } | 1276 | } |
| 1277 | if (yi->track_osd) | ||
| 1278 | fb->flags |= V4L2_FBUF_FLAG_OVERLAY; | ||
| 1275 | break; | 1279 | break; |
| 1276 | } | 1280 | } |
| 1277 | 1281 | ||
| @@ -1285,6 +1289,7 @@ int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void | |||
| 1285 | (fb->flags & (V4L2_FBUF_FLAG_LOCAL_ALPHA|V4L2_FBUF_FLAG_LOCAL_INV_ALPHA)) != 0; | 1289 | (fb->flags & (V4L2_FBUF_FLAG_LOCAL_ALPHA|V4L2_FBUF_FLAG_LOCAL_INV_ALPHA)) != 0; |
| 1286 | itv->osd_chroma_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; | 1290 | itv->osd_chroma_key_state = (fb->flags & V4L2_FBUF_FLAG_CHROMAKEY) != 0; |
| 1287 | ivtv_set_osd_alpha(itv); | 1291 | ivtv_set_osd_alpha(itv); |
| 1292 | yi->track_osd = (fb->flags & V4L2_FBUF_FLAG_OVERLAY) != 0; | ||
| 1288 | break; | 1293 | break; |
| 1289 | } | 1294 | } |
| 1290 | 1295 | ||
| @@ -1628,6 +1633,7 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp, | |||
| 1628 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) { | 1633 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) { |
| 1629 | printk(KERN_INFO "ivtv%d ioctl: ", itv->num); | 1634 | printk(KERN_INFO "ivtv%d ioctl: ", itv->num); |
| 1630 | v4l_printk_ioctl(cmd); | 1635 | v4l_printk_ioctl(cmd); |
| 1636 | printk("\n"); | ||
| 1631 | } | 1637 | } |
| 1632 | return ivtv_debug_ioctls(filp, cmd, arg); | 1638 | return ivtv_debug_ioctls(filp, cmd, arg); |
| 1633 | 1639 | ||
| @@ -1671,6 +1677,7 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp, | |||
| 1671 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) { | 1677 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) { |
| 1672 | printk(KERN_INFO "ivtv%d ioctl: ", itv->num); | 1678 | printk(KERN_INFO "ivtv%d ioctl: ", itv->num); |
| 1673 | v4l_printk_ioctl(cmd); | 1679 | v4l_printk_ioctl(cmd); |
| 1680 | printk("\n"); | ||
| 1674 | } | 1681 | } |
| 1675 | return ivtv_v4l2_ioctls(itv, filp, cmd, arg); | 1682 | return ivtv_v4l2_ioctls(itv, filp, cmd, arg); |
| 1676 | 1683 | ||
| @@ -1684,6 +1691,7 @@ static int ivtv_v4l2_do_ioctl(struct inode *inode, struct file *filp, | |||
| 1684 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) { | 1691 | if (ivtv_debug & IVTV_DBGFLG_IOCTL) { |
| 1685 | printk(KERN_INFO "ivtv%d ioctl: ", itv->num); | 1692 | printk(KERN_INFO "ivtv%d ioctl: ", itv->num); |
| 1686 | v4l_printk_ioctl(cmd); | 1693 | v4l_printk_ioctl(cmd); |
| 1694 | printk("\n"); | ||
| 1687 | } | 1695 | } |
| 1688 | return ivtv_control_ioctls(itv, cmd, arg); | 1696 | return ivtv_control_ioctls(itv, cmd, arg); |
| 1689 | 1697 | ||
diff --git a/drivers/media/video/ivtv/ivtv-irq.c b/drivers/media/video/ivtv/ivtv-irq.c index 65604dde9726..a329c4689dbf 100644 --- a/drivers/media/video/ivtv/ivtv-irq.c +++ b/drivers/media/video/ivtv/ivtv-irq.c | |||
| @@ -384,6 +384,8 @@ static void ivtv_dma_enc_start_xfer(struct ivtv_stream *s) | |||
| 384 | ivtv_stream_sync_for_device(s); | 384 | ivtv_stream_sync_for_device(s); |
| 385 | write_reg(s->sg_handle, IVTV_REG_ENCDMAADDR); | 385 | write_reg(s->sg_handle, IVTV_REG_ENCDMAADDR); |
| 386 | write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER); | 386 | write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x02, IVTV_REG_DMAXFER); |
| 387 | itv->dma_timer.expires = jiffies + msecs_to_jiffies(100); | ||
| 388 | add_timer(&itv->dma_timer); | ||
| 387 | } | 389 | } |
| 388 | 390 | ||
| 389 | static void ivtv_dma_dec_start_xfer(struct ivtv_stream *s) | 391 | static void ivtv_dma_dec_start_xfer(struct ivtv_stream *s) |
| @@ -398,6 +400,8 @@ static void ivtv_dma_dec_start_xfer(struct ivtv_stream *s) | |||
| 398 | ivtv_stream_sync_for_device(s); | 400 | ivtv_stream_sync_for_device(s); |
| 399 | write_reg(s->sg_handle, IVTV_REG_DECDMAADDR); | 401 | write_reg(s->sg_handle, IVTV_REG_DECDMAADDR); |
| 400 | write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x01, IVTV_REG_DMAXFER); | 402 | write_reg_sync(read_reg(IVTV_REG_DMAXFER) | 0x01, IVTV_REG_DMAXFER); |
| 403 | itv->dma_timer.expires = jiffies + msecs_to_jiffies(100); | ||
| 404 | add_timer(&itv->dma_timer); | ||
| 401 | } | 405 | } |
| 402 | 406 | ||
| 403 | /* start the encoder DMA */ | 407 | /* start the encoder DMA */ |
| @@ -459,8 +463,6 @@ static void ivtv_dma_enc_start(struct ivtv_stream *s) | |||
| 459 | ivtv_dma_enc_start_xfer(s); | 463 | ivtv_dma_enc_start_xfer(s); |
| 460 | set_bit(IVTV_F_I_DMA, &itv->i_flags); | 464 | set_bit(IVTV_F_I_DMA, &itv->i_flags); |
| 461 | itv->cur_dma_stream = s->type; | 465 | itv->cur_dma_stream = s->type; |
| 462 | itv->dma_timer.expires = jiffies + msecs_to_jiffies(100); | ||
| 463 | add_timer(&itv->dma_timer); | ||
| 464 | } | 466 | } |
| 465 | } | 467 | } |
| 466 | 468 | ||
| @@ -481,8 +483,6 @@ static void ivtv_dma_dec_start(struct ivtv_stream *s) | |||
| 481 | ivtv_dma_dec_start_xfer(s); | 483 | ivtv_dma_dec_start_xfer(s); |
| 482 | set_bit(IVTV_F_I_DMA, &itv->i_flags); | 484 | set_bit(IVTV_F_I_DMA, &itv->i_flags); |
| 483 | itv->cur_dma_stream = s->type; | 485 | itv->cur_dma_stream = s->type; |
| 484 | itv->dma_timer.expires = jiffies + msecs_to_jiffies(100); | ||
| 485 | add_timer(&itv->dma_timer); | ||
| 486 | } | 486 | } |
| 487 | 487 | ||
| 488 | static void ivtv_irq_dma_read(struct ivtv *itv) | 488 | static void ivtv_irq_dma_read(struct ivtv *itv) |
| @@ -492,10 +492,11 @@ static void ivtv_irq_dma_read(struct ivtv *itv) | |||
| 492 | int hw_stream_type = 0; | 492 | int hw_stream_type = 0; |
| 493 | 493 | ||
| 494 | IVTV_DEBUG_HI_IRQ("DEC DMA READ\n"); | 494 | IVTV_DEBUG_HI_IRQ("DEC DMA READ\n"); |
| 495 | if (!test_bit(IVTV_F_I_UDMA, &itv->i_flags) && itv->cur_dma_stream < 0) { | 495 | |
| 496 | del_timer(&itv->dma_timer); | 496 | del_timer(&itv->dma_timer); |
| 497 | |||
| 498 | if (!test_bit(IVTV_F_I_UDMA, &itv->i_flags) && itv->cur_dma_stream < 0) | ||
| 497 | return; | 499 | return; |
| 498 | } | ||
| 499 | 500 | ||
| 500 | if (!test_bit(IVTV_F_I_UDMA, &itv->i_flags)) { | 501 | if (!test_bit(IVTV_F_I_UDMA, &itv->i_flags)) { |
| 501 | s = &itv->streams[itv->cur_dma_stream]; | 502 | s = &itv->streams[itv->cur_dma_stream]; |
| @@ -543,7 +544,6 @@ static void ivtv_irq_dma_read(struct ivtv *itv) | |||
| 543 | } | 544 | } |
| 544 | wake_up(&s->waitq); | 545 | wake_up(&s->waitq); |
| 545 | } | 546 | } |
| 546 | del_timer(&itv->dma_timer); | ||
| 547 | clear_bit(IVTV_F_I_UDMA, &itv->i_flags); | 547 | clear_bit(IVTV_F_I_UDMA, &itv->i_flags); |
| 548 | clear_bit(IVTV_F_I_DMA, &itv->i_flags); | 548 | clear_bit(IVTV_F_I_DMA, &itv->i_flags); |
| 549 | itv->cur_dma_stream = -1; | 549 | itv->cur_dma_stream = -1; |
| @@ -557,10 +557,12 @@ static void ivtv_irq_enc_dma_complete(struct ivtv *itv) | |||
| 557 | 557 | ||
| 558 | ivtv_api_get_data(&itv->enc_mbox, IVTV_MBOX_DMA_END, data); | 558 | ivtv_api_get_data(&itv->enc_mbox, IVTV_MBOX_DMA_END, data); |
| 559 | IVTV_DEBUG_HI_IRQ("ENC DMA COMPLETE %x %d (%d)\n", data[0], data[1], itv->cur_dma_stream); | 559 | IVTV_DEBUG_HI_IRQ("ENC DMA COMPLETE %x %d (%d)\n", data[0], data[1], itv->cur_dma_stream); |
| 560 | if (itv->cur_dma_stream < 0) { | 560 | |
| 561 | del_timer(&itv->dma_timer); | 561 | del_timer(&itv->dma_timer); |
| 562 | |||
| 563 | if (itv->cur_dma_stream < 0) | ||
| 562 | return; | 564 | return; |
| 563 | } | 565 | |
| 564 | s = &itv->streams[itv->cur_dma_stream]; | 566 | s = &itv->streams[itv->cur_dma_stream]; |
| 565 | ivtv_stream_sync_for_cpu(s); | 567 | ivtv_stream_sync_for_cpu(s); |
| 566 | 568 | ||
| @@ -585,7 +587,6 @@ static void ivtv_irq_enc_dma_complete(struct ivtv *itv) | |||
| 585 | ivtv_dma_enc_start_xfer(s); | 587 | ivtv_dma_enc_start_xfer(s); |
| 586 | return; | 588 | return; |
| 587 | } | 589 | } |
| 588 | del_timer(&itv->dma_timer); | ||
| 589 | clear_bit(IVTV_F_I_DMA, &itv->i_flags); | 590 | clear_bit(IVTV_F_I_DMA, &itv->i_flags); |
| 590 | itv->cur_dma_stream = -1; | 591 | itv->cur_dma_stream = -1; |
| 591 | dma_post(s); | 592 | dma_post(s); |
diff --git a/drivers/media/video/ivtv/ivtv-mailbox.c b/drivers/media/video/ivtv/ivtv-mailbox.c index 13a6c374d2db..1b5c0ac09a85 100644 --- a/drivers/media/video/ivtv/ivtv-mailbox.c +++ b/drivers/media/video/ivtv/ivtv-mailbox.c | |||
| @@ -177,7 +177,8 @@ static int get_mailbox(struct ivtv *itv, struct ivtv_mailbox_data *mbdata, int f | |||
| 177 | 177 | ||
| 178 | /* Sleep before a retry, if not atomic */ | 178 | /* Sleep before a retry, if not atomic */ |
| 179 | if (!(flags & API_NO_WAIT_MB)) { | 179 | if (!(flags & API_NO_WAIT_MB)) { |
| 180 | if (jiffies - then > msecs_to_jiffies(10*retries)) | 180 | if (time_after(jiffies, |
| 181 | then + msecs_to_jiffies(10*retries))) | ||
| 181 | break; | 182 | break; |
| 182 | ivtv_msleep_timeout(10, 0); | 183 | ivtv_msleep_timeout(10, 0); |
| 183 | } | 184 | } |
| @@ -244,7 +245,9 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
| 244 | data, then just return 0 as there is no need to issue this command again. | 245 | data, then just return 0 as there is no need to issue this command again. |
| 245 | Just an optimization to prevent unnecessary use of mailboxes. */ | 246 | Just an optimization to prevent unnecessary use of mailboxes. */ |
| 246 | if (itv->api_cache[cmd].last_jiffies && | 247 | if (itv->api_cache[cmd].last_jiffies && |
| 247 | jiffies - itv->api_cache[cmd].last_jiffies < msecs_to_jiffies(1800000) && | 248 | time_before(jiffies, |
| 249 | itv->api_cache[cmd].last_jiffies + | ||
| 250 | msecs_to_jiffies(1800000)) && | ||
| 248 | !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) { | 251 | !memcmp(data, itv->api_cache[cmd].data, sizeof(itv->api_cache[cmd].data))) { |
| 249 | itv->api_cache[cmd].last_jiffies = jiffies; | 252 | itv->api_cache[cmd].last_jiffies = jiffies; |
| 250 | return 0; | 253 | return 0; |
| @@ -299,7 +302,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
| 299 | } | 302 | } |
| 300 | } | 303 | } |
| 301 | while (!(readl(&mbox->flags) & IVTV_MBOX_FIRMWARE_DONE)) { | 304 | while (!(readl(&mbox->flags) & IVTV_MBOX_FIRMWARE_DONE)) { |
| 302 | if (jiffies - then > api_timeout) { | 305 | if (time_after(jiffies, then + api_timeout)) { |
| 303 | IVTV_DEBUG_WARN("Could not get result (%s)\n", api_info[cmd].name); | 306 | IVTV_DEBUG_WARN("Could not get result (%s)\n", api_info[cmd].name); |
| 304 | /* reset the mailbox, but it is likely too late already */ | 307 | /* reset the mailbox, but it is likely too late already */ |
| 305 | write_sync(0, &mbox->flags); | 308 | write_sync(0, &mbox->flags); |
| @@ -311,7 +314,7 @@ static int ivtv_api_call(struct ivtv *itv, int cmd, int args, u32 data[]) | |||
| 311 | else | 314 | else |
| 312 | ivtv_msleep_timeout(1, 0); | 315 | ivtv_msleep_timeout(1, 0); |
| 313 | } | 316 | } |
| 314 | if (jiffies - then > msecs_to_jiffies(100)) | 317 | if (time_after(jiffies, then + msecs_to_jiffies(100))) |
| 315 | IVTV_DEBUG_WARN("%s took %u jiffies\n", | 318 | IVTV_DEBUG_WARN("%s took %u jiffies\n", |
| 316 | api_info[cmd].name, | 319 | api_info[cmd].name, |
| 317 | jiffies_to_msecs(jiffies - then)); | 320 | jiffies_to_msecs(jiffies - then)); |
diff --git a/drivers/media/video/ivtv/ivtv-queue.c b/drivers/media/video/ivtv/ivtv-queue.c index 39a216713244..3e1deec67a5e 100644 --- a/drivers/media/video/ivtv/ivtv-queue.c +++ b/drivers/media/video/ivtv/ivtv-queue.c | |||
| @@ -51,7 +51,7 @@ void ivtv_queue_init(struct ivtv_queue *q) | |||
| 51 | 51 | ||
| 52 | void ivtv_enqueue(struct ivtv_stream *s, struct ivtv_buffer *buf, struct ivtv_queue *q) | 52 | void ivtv_enqueue(struct ivtv_stream *s, struct ivtv_buffer *buf, struct ivtv_queue *q) |
| 53 | { | 53 | { |
| 54 | unsigned long flags = 0; | 54 | unsigned long flags; |
| 55 | 55 | ||
| 56 | /* clear the buffer if it is going to be enqueued to the free queue */ | 56 | /* clear the buffer if it is going to be enqueued to the free queue */ |
| 57 | if (q == &s->q_free) { | 57 | if (q == &s->q_free) { |
| @@ -71,7 +71,7 @@ void ivtv_enqueue(struct ivtv_stream *s, struct ivtv_buffer *buf, struct ivtv_qu | |||
| 71 | struct ivtv_buffer *ivtv_dequeue(struct ivtv_stream *s, struct ivtv_queue *q) | 71 | struct ivtv_buffer *ivtv_dequeue(struct ivtv_stream *s, struct ivtv_queue *q) |
| 72 | { | 72 | { |
| 73 | struct ivtv_buffer *buf = NULL; | 73 | struct ivtv_buffer *buf = NULL; |
| 74 | unsigned long flags = 0; | 74 | unsigned long flags; |
| 75 | 75 | ||
| 76 | spin_lock_irqsave(&s->qlock, flags); | 76 | spin_lock_irqsave(&s->qlock, flags); |
| 77 | if (!list_empty(&q->list)) { | 77 | if (!list_empty(&q->list)) { |
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index 24d98ecf35ad..4ab8d36831ba 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c | |||
| @@ -768,7 +768,8 @@ int ivtv_stop_v4l2_encode_stream(struct ivtv_stream *s, int gop_end) | |||
| 768 | 768 | ||
| 769 | /* wait 2s for EOS interrupt */ | 769 | /* wait 2s for EOS interrupt */ |
| 770 | while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) && | 770 | while (!test_bit(IVTV_F_I_EOS, &itv->i_flags) && |
| 771 | jiffies < then + msecs_to_jiffies (2000)) { | 771 | time_before(jiffies, |
| 772 | then + msecs_to_jiffies(2000))) { | ||
| 772 | schedule_timeout(msecs_to_jiffies(10)); | 773 | schedule_timeout(msecs_to_jiffies(10)); |
| 773 | } | 774 | } |
| 774 | 775 | ||
diff --git a/drivers/media/video/ivtv/ivtv-yuv.c b/drivers/media/video/ivtv/ivtv-yuv.c index 85183480a225..393d917cd672 100644 --- a/drivers/media/video/ivtv/ivtv-yuv.c +++ b/drivers/media/video/ivtv/ivtv-yuv.c | |||
| @@ -718,9 +718,11 @@ static u32 ivtv_yuv_window_setup(struct ivtv *itv, struct yuv_frame_info *f) | |||
| 718 | f->src_w -= (osd_scale * osd_crop) >> 16; | 718 | f->src_w -= (osd_scale * osd_crop) >> 16; |
| 719 | } | 719 | } |
| 720 | 720 | ||
| 721 | /* The OSD can be moved. Track to it */ | 721 | if (itv->yuv_info.track_osd) { |
| 722 | f->dst_x += itv->yuv_info.osd_x_offset; | 722 | /* The OSD can be moved. Track to it */ |
| 723 | f->dst_y += itv->yuv_info.osd_y_offset; | 723 | f->dst_x += itv->yuv_info.osd_x_offset; |
| 724 | f->dst_y += itv->yuv_info.osd_y_offset; | ||
| 725 | } | ||
| 724 | 726 | ||
| 725 | /* Width & height for both src & dst must be even. | 727 | /* Width & height for both src & dst must be even. |
| 726 | Same for coordinates. */ | 728 | Same for coordinates. */ |
| @@ -792,11 +794,19 @@ void ivtv_yuv_work_handler(struct ivtv *itv) | |||
| 792 | IVTV_DEBUG_YUV("Update yuv registers for frame %d\n", frame); | 794 | IVTV_DEBUG_YUV("Update yuv registers for frame %d\n", frame); |
| 793 | f = yi->new_frame_info[frame]; | 795 | f = yi->new_frame_info[frame]; |
| 794 | 796 | ||
| 795 | /* Update the osd pan info */ | 797 | if (yi->track_osd) { |
| 796 | f.pan_x = yi->osd_x_pan; | 798 | /* Snapshot the osd pan info */ |
| 797 | f.pan_y = yi->osd_y_pan; | 799 | f.pan_x = yi->osd_x_pan; |
| 798 | f.vis_w = yi->osd_vis_w; | 800 | f.pan_y = yi->osd_y_pan; |
| 799 | f.vis_h = yi->osd_vis_h; | 801 | f.vis_w = yi->osd_vis_w; |
| 802 | f.vis_h = yi->osd_vis_h; | ||
| 803 | } else { | ||
| 804 | /* Not tracking the osd, so assume full screen */ | ||
| 805 | f.pan_x = 0; | ||
| 806 | f.pan_y = 0; | ||
| 807 | f.vis_w = 720; | ||
| 808 | f.vis_h = yi->decode_height; | ||
| 809 | } | ||
| 800 | 810 | ||
| 801 | /* Calculate the display window coordinates. Exit if nothing left */ | 811 | /* Calculate the display window coordinates. Exit if nothing left */ |
| 802 | if (!(yuv_update = ivtv_yuv_window_setup(itv, &f))) | 812 | if (!(yuv_update = ivtv_yuv_window_setup(itv, &f))) |
| @@ -914,7 +924,7 @@ static void ivtv_yuv_init(struct ivtv *itv) | |||
| 914 | } | 924 | } |
| 915 | 925 | ||
| 916 | /* Get next available yuv buffer on PVR350 */ | 926 | /* Get next available yuv buffer on PVR350 */ |
| 917 | void ivtv_yuv_next_free(struct ivtv *itv) | 927 | static void ivtv_yuv_next_free(struct ivtv *itv) |
| 918 | { | 928 | { |
| 919 | int draw, display; | 929 | int draw, display; |
| 920 | struct yuv_playback_info *yi = &itv->yuv_info; | 930 | struct yuv_playback_info *yi = &itv->yuv_info; |
| @@ -937,7 +947,7 @@ void ivtv_yuv_next_free(struct ivtv *itv) | |||
| 937 | } | 947 | } |
| 938 | 948 | ||
| 939 | /* Set up frame according to ivtv_dma_frame parameters */ | 949 | /* Set up frame according to ivtv_dma_frame parameters */ |
| 940 | void ivtv_yuv_setup_frame(struct ivtv *itv, struct ivtv_dma_frame *args) | 950 | static void ivtv_yuv_setup_frame(struct ivtv *itv, struct ivtv_dma_frame *args) |
| 941 | { | 951 | { |
| 942 | struct yuv_playback_info *yi = &itv->yuv_info; | 952 | struct yuv_playback_info *yi = &itv->yuv_info; |
| 943 | u8 frame = yi->draw_frame; | 953 | u8 frame = yi->draw_frame; |
| @@ -965,12 +975,6 @@ void ivtv_yuv_setup_frame(struct ivtv *itv, struct ivtv_dma_frame *args) | |||
| 965 | /* Are we going to offset the Y plane */ | 975 | /* Are we going to offset the Y plane */ |
| 966 | nf->offset_y = (nf->tru_h + nf->src_x < 512 - 16) ? 1 : 0; | 976 | nf->offset_y = (nf->tru_h + nf->src_x < 512 - 16) ? 1 : 0; |
| 967 | 977 | ||
| 968 | /* Snapshot the osd pan info */ | ||
| 969 | nf->pan_x = yi->osd_x_pan; | ||
| 970 | nf->pan_y = yi->osd_y_pan; | ||
| 971 | nf->vis_w = yi->osd_vis_w; | ||
| 972 | nf->vis_h = yi->osd_vis_h; | ||
| 973 | |||
| 974 | nf->update = 0; | 978 | nf->update = 0; |
| 975 | nf->interlaced_y = 0; | 979 | nf->interlaced_y = 0; |
| 976 | nf->interlaced_uv = 0; | 980 | nf->interlaced_uv = 0; |
| @@ -1042,7 +1046,7 @@ void ivtv_yuv_frame_complete(struct ivtv *itv) | |||
| 1042 | (itv->yuv_info.draw_frame + 1) % IVTV_YUV_BUFFERS); | 1046 | (itv->yuv_info.draw_frame + 1) % IVTV_YUV_BUFFERS); |
| 1043 | } | 1047 | } |
| 1044 | 1048 | ||
| 1045 | int ivtv_yuv_udma_frame(struct ivtv *itv, struct ivtv_dma_frame *args) | 1049 | static int ivtv_yuv_udma_frame(struct ivtv *itv, struct ivtv_dma_frame *args) |
| 1046 | { | 1050 | { |
| 1047 | DEFINE_WAIT(wait); | 1051 | DEFINE_WAIT(wait); |
| 1048 | int rc = 0; | 1052 | int rc = 0; |
diff --git a/drivers/media/video/meye.c b/drivers/media/video/meye.c index 3d51fa0a52b6..e7ccbc895d7a 100644 --- a/drivers/media/video/meye.c +++ b/drivers/media/video/meye.c | |||
| @@ -42,15 +42,10 @@ | |||
| 42 | #include <linux/meye.h> | 42 | #include <linux/meye.h> |
| 43 | 43 | ||
| 44 | MODULE_AUTHOR("Stelian Pop <stelian@popies.net>"); | 44 | MODULE_AUTHOR("Stelian Pop <stelian@popies.net>"); |
| 45 | MODULE_DESCRIPTION("v4l/v4l2 driver for the MotionEye camera"); | 45 | MODULE_DESCRIPTION("v4l2 driver for the MotionEye camera"); |
| 46 | MODULE_LICENSE("GPL"); | 46 | MODULE_LICENSE("GPL"); |
| 47 | MODULE_VERSION(MEYE_DRIVER_VERSION); | 47 | MODULE_VERSION(MEYE_DRIVER_VERSION); |
| 48 | 48 | ||
| 49 | /* force usage of V4L1 API */ | ||
| 50 | static int forcev4l1; /* = 0 */ | ||
| 51 | module_param(forcev4l1, int, 0644); | ||
| 52 | MODULE_PARM_DESC(forcev4l1, "force use of V4L1 instead of V4L2"); | ||
| 53 | |||
| 54 | /* number of grab buffers */ | 49 | /* number of grab buffers */ |
| 55 | static unsigned int gbuffers = 2; | 50 | static unsigned int gbuffers = 2; |
| 56 | module_param(gbuffers, int, 0444); | 51 | module_param(gbuffers, int, 0444); |
| @@ -789,7 +784,7 @@ static irqreturn_t meye_irq(int irq, void *dev_id) | |||
| 789 | { | 784 | { |
| 790 | u32 v; | 785 | u32 v; |
| 791 | int reqnr; | 786 | int reqnr; |
| 792 | static int sequence = 0; | 787 | static int sequence; |
| 793 | 788 | ||
| 794 | v = mchip_read(MCHIP_MM_INTA); | 789 | v = mchip_read(MCHIP_MM_INTA); |
| 795 | 790 | ||
| @@ -876,795 +871,735 @@ static int meye_release(struct inode *inode, struct file *file) | |||
| 876 | return 0; | 871 | return 0; |
| 877 | } | 872 | } |
| 878 | 873 | ||
| 879 | static int meye_do_ioctl(struct inode *inode, struct file *file, | 874 | static int meyeioc_g_params(struct meye_params *p) |
| 880 | unsigned int cmd, void *arg) | ||
| 881 | { | 875 | { |
| 882 | switch (cmd) { | 876 | *p = meye.params; |
| 877 | return 0; | ||
| 878 | } | ||
| 883 | 879 | ||
| 884 | case VIDIOCGCAP: { | 880 | static int meyeioc_s_params(struct meye_params *jp) |
| 885 | struct video_capability *b = arg; | 881 | { |
| 886 | strcpy(b->name,meye.video_dev->name); | 882 | if (jp->subsample > 1) |
| 887 | b->type = VID_TYPE_CAPTURE; | 883 | return -EINVAL; |
| 888 | b->channels = 1; | ||
| 889 | b->audios = 0; | ||
| 890 | b->maxwidth = 640; | ||
| 891 | b->maxheight = 480; | ||
| 892 | b->minwidth = 320; | ||
| 893 | b->minheight = 240; | ||
| 894 | break; | ||
| 895 | } | ||
| 896 | 884 | ||
| 897 | case VIDIOCGCHAN: { | 885 | if (jp->quality > 10) |
| 898 | struct video_channel *v = arg; | 886 | return -EINVAL; |
| 899 | v->flags = 0; | ||
| 900 | v->tuners = 0; | ||
| 901 | v->type = VIDEO_TYPE_CAMERA; | ||
| 902 | if (v->channel != 0) | ||
| 903 | return -EINVAL; | ||
| 904 | strcpy(v->name,"Camera"); | ||
| 905 | break; | ||
| 906 | } | ||
| 907 | 887 | ||
| 908 | case VIDIOCSCHAN: { | 888 | if (jp->sharpness > 63 || jp->agc > 63 || jp->picture > 63) |
| 909 | struct video_channel *v = arg; | 889 | return -EINVAL; |
| 910 | if (v->channel != 0) | ||
| 911 | return -EINVAL; | ||
| 912 | break; | ||
| 913 | } | ||
| 914 | 890 | ||
| 915 | case VIDIOCGPICT: { | 891 | if (jp->framerate > 31) |
| 916 | struct video_picture *p = arg; | 892 | return -EINVAL; |
| 917 | *p = meye.picture; | ||
| 918 | break; | ||
| 919 | } | ||
| 920 | 893 | ||
| 921 | case VIDIOCSPICT: { | 894 | mutex_lock(&meye.lock); |
| 922 | struct video_picture *p = arg; | ||
| 923 | if (p->depth != 16) | ||
| 924 | return -EINVAL; | ||
| 925 | if (p->palette != VIDEO_PALETTE_YUV422 && p->palette != VIDEO_PALETTE_YUYV) | ||
| 926 | return -EINVAL; | ||
| 927 | mutex_lock(&meye.lock); | ||
| 928 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERABRIGHTNESS, | ||
| 929 | p->brightness >> 10); | ||
| 930 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAHUE, | ||
| 931 | p->hue >> 10); | ||
| 932 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERACOLOR, | ||
| 933 | p->colour >> 10); | ||
| 934 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERACONTRAST, | ||
| 935 | p->contrast >> 10); | ||
| 936 | meye.picture = *p; | ||
| 937 | mutex_unlock(&meye.lock); | ||
| 938 | break; | ||
| 939 | } | ||
| 940 | 895 | ||
| 941 | case VIDIOCSYNC: { | 896 | if (meye.params.subsample != jp->subsample || |
| 942 | int *i = arg; | 897 | meye.params.quality != jp->quality) |
| 943 | int unused; | 898 | mchip_hic_stop(); /* need restart */ |
| 899 | |||
| 900 | meye.params = *jp; | ||
| 901 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERASHARPNESS, | ||
| 902 | meye.params.sharpness); | ||
| 903 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAAGC, | ||
| 904 | meye.params.agc); | ||
| 905 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE, | ||
| 906 | meye.params.picture); | ||
| 907 | mutex_unlock(&meye.lock); | ||
| 944 | 908 | ||
| 945 | if (*i < 0 || *i >= gbuffers) | 909 | return 0; |
| 946 | return -EINVAL; | 910 | } |
| 947 | 911 | ||
| 948 | mutex_lock(&meye.lock); | 912 | static int meyeioc_qbuf_capt(int *nb) |
| 913 | { | ||
| 914 | if (!meye.grab_fbuffer) | ||
| 915 | return -EINVAL; | ||
| 949 | 916 | ||
| 950 | switch (meye.grab_buffer[*i].state) { | 917 | if (*nb >= gbuffers) |
| 918 | return -EINVAL; | ||
| 951 | 919 | ||
| 952 | case MEYE_BUF_UNUSED: | 920 | if (*nb < 0) { |
| 953 | mutex_unlock(&meye.lock); | 921 | /* stop capture */ |
| 954 | return -EINVAL; | 922 | mchip_hic_stop(); |
| 955 | case MEYE_BUF_USING: | 923 | return 0; |
| 956 | if (file->f_flags & O_NONBLOCK) { | ||
| 957 | mutex_unlock(&meye.lock); | ||
| 958 | return -EAGAIN; | ||
| 959 | } | ||
| 960 | if (wait_event_interruptible(meye.proc_list, | ||
| 961 | (meye.grab_buffer[*i].state != MEYE_BUF_USING))) { | ||
| 962 | mutex_unlock(&meye.lock); | ||
| 963 | return -EINTR; | ||
| 964 | } | ||
| 965 | /* fall through */ | ||
| 966 | case MEYE_BUF_DONE: | ||
| 967 | meye.grab_buffer[*i].state = MEYE_BUF_UNUSED; | ||
| 968 | kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int)); | ||
| 969 | } | ||
| 970 | mutex_unlock(&meye.lock); | ||
| 971 | break; | ||
| 972 | } | 924 | } |
| 973 | 925 | ||
| 974 | case VIDIOCMCAPTURE: { | 926 | if (meye.grab_buffer[*nb].state != MEYE_BUF_UNUSED) |
| 975 | struct video_mmap *vm = arg; | 927 | return -EBUSY; |
| 976 | int restart = 0; | ||
| 977 | |||
| 978 | if (vm->frame >= gbuffers || vm->frame < 0) | ||
| 979 | return -EINVAL; | ||
| 980 | if (vm->format != VIDEO_PALETTE_YUV422 && vm->format != VIDEO_PALETTE_YUYV) | ||
| 981 | return -EINVAL; | ||
| 982 | if (vm->height * vm->width * 2 > gbufsize) | ||
| 983 | return -EINVAL; | ||
| 984 | if (!meye.grab_fbuffer) | ||
| 985 | return -EINVAL; | ||
| 986 | if (meye.grab_buffer[vm->frame].state != MEYE_BUF_UNUSED) | ||
| 987 | return -EBUSY; | ||
| 988 | |||
| 989 | mutex_lock(&meye.lock); | ||
| 990 | if (vm->width == 640 && vm->height == 480) { | ||
| 991 | if (meye.params.subsample) { | ||
| 992 | meye.params.subsample = 0; | ||
| 993 | restart = 1; | ||
| 994 | } | ||
| 995 | } else if (vm->width == 320 && vm->height == 240) { | ||
| 996 | if (!meye.params.subsample) { | ||
| 997 | meye.params.subsample = 1; | ||
| 998 | restart = 1; | ||
| 999 | } | ||
| 1000 | } else { | ||
| 1001 | mutex_unlock(&meye.lock); | ||
| 1002 | return -EINVAL; | ||
| 1003 | } | ||
| 1004 | 928 | ||
| 1005 | if (restart || meye.mchip_mode != MCHIP_HIC_MODE_CONT_OUT) | 929 | mutex_lock(&meye.lock); |
| 1006 | mchip_continuous_start(); | ||
| 1007 | meye.grab_buffer[vm->frame].state = MEYE_BUF_USING; | ||
| 1008 | kfifo_put(meye.grabq, (unsigned char *)&vm->frame, sizeof(int)); | ||
| 1009 | mutex_unlock(&meye.lock); | ||
| 1010 | break; | ||
| 1011 | } | ||
| 1012 | 930 | ||
| 1013 | case VIDIOCGMBUF: { | 931 | if (meye.mchip_mode != MCHIP_HIC_MODE_CONT_COMP) |
| 1014 | struct video_mbuf *vm = arg; | 932 | mchip_cont_compression_start(); |
| 1015 | int i; | ||
| 1016 | 933 | ||
| 1017 | memset(vm, 0 , sizeof(*vm)); | 934 | meye.grab_buffer[*nb].state = MEYE_BUF_USING; |
| 1018 | vm->size = gbufsize * gbuffers; | 935 | kfifo_put(meye.grabq, (unsigned char *)nb, sizeof(int)); |
| 1019 | vm->frames = gbuffers; | 936 | mutex_unlock(&meye.lock); |
| 1020 | for (i = 0; i < gbuffers; i++) | ||
| 1021 | vm->offsets[i] = i * gbufsize; | ||
| 1022 | break; | ||
| 1023 | } | ||
| 1024 | 937 | ||
| 1025 | case MEYEIOC_G_PARAMS: { | 938 | return 0; |
| 1026 | struct meye_params *p = arg; | 939 | } |
| 1027 | *p = meye.params; | ||
| 1028 | break; | ||
| 1029 | } | ||
| 1030 | 940 | ||
| 1031 | case MEYEIOC_S_PARAMS: { | 941 | static int meyeioc_sync(struct file *file, void *fh, int *i) |
| 1032 | struct meye_params *jp = arg; | 942 | { |
| 1033 | if (jp->subsample > 1) | 943 | int unused; |
| 1034 | return -EINVAL; | ||
| 1035 | if (jp->quality > 10) | ||
| 1036 | return -EINVAL; | ||
| 1037 | if (jp->sharpness > 63 || jp->agc > 63 || jp->picture > 63) | ||
| 1038 | return -EINVAL; | ||
| 1039 | if (jp->framerate > 31) | ||
| 1040 | return -EINVAL; | ||
| 1041 | mutex_lock(&meye.lock); | ||
| 1042 | if (meye.params.subsample != jp->subsample || | ||
| 1043 | meye.params.quality != jp->quality) | ||
| 1044 | mchip_hic_stop(); /* need restart */ | ||
| 1045 | meye.params = *jp; | ||
| 1046 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERASHARPNESS, | ||
| 1047 | meye.params.sharpness); | ||
| 1048 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAAGC, | ||
| 1049 | meye.params.agc); | ||
| 1050 | sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERAPICTURE, | ||
| 1051 | meye.params.picture); | ||
| 1052 | mutex_unlock(&meye.lock); | ||
| 1053 | break; | ||
| 1054 | } | ||
| 1055 | 944 | ||
| 1056 | case MEYEIOC_QBUF_CAPT: { | 945 | if (*i < 0 || *i >= gbuffers) |
| 1057 | int *nb = arg; | 946 | return -EINVAL; |
| 1058 | 947 | ||
| 1059 | if (!meye.grab_fbuffer) | 948 | mutex_lock(&meye.lock); |
| 1060 | return -EINVAL; | 949 | switch (meye.grab_buffer[*i].state) { |
| 1061 | if (*nb >= gbuffers) | 950 | |
| 1062 | return -EINVAL; | 951 | case MEYE_BUF_UNUSED: |
| 1063 | if (*nb < 0) { | ||
| 1064 | /* stop capture */ | ||
| 1065 | mchip_hic_stop(); | ||
| 1066 | return 0; | ||
| 1067 | } | ||
| 1068 | if (meye.grab_buffer[*nb].state != MEYE_BUF_UNUSED) | ||
| 1069 | return -EBUSY; | ||
| 1070 | mutex_lock(&meye.lock); | ||
| 1071 | if (meye.mchip_mode != MCHIP_HIC_MODE_CONT_COMP) | ||
| 1072 | mchip_cont_compression_start(); | ||
| 1073 | meye.grab_buffer[*nb].state = MEYE_BUF_USING; | ||
| 1074 | kfifo_put(meye.grabq, (unsigned char *)nb, sizeof(int)); | ||
| 1075 | mutex_unlock(&meye.lock); | 952 | mutex_unlock(&meye.lock); |
| 1076 | break; | 953 | return -EINVAL; |
| 954 | case MEYE_BUF_USING: | ||
| 955 | if (file->f_flags & O_NONBLOCK) { | ||
| 956 | mutex_unlock(&meye.lock); | ||
| 957 | return -EAGAIN; | ||
| 958 | } | ||
| 959 | if (wait_event_interruptible(meye.proc_list, | ||
| 960 | (meye.grab_buffer[*i].state != MEYE_BUF_USING))) { | ||
| 961 | mutex_unlock(&meye.lock); | ||
| 962 | return -EINTR; | ||
| 963 | } | ||
| 964 | /* fall through */ | ||
| 965 | case MEYE_BUF_DONE: | ||
| 966 | meye.grab_buffer[*i].state = MEYE_BUF_UNUSED; | ||
| 967 | kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int)); | ||
| 1077 | } | 968 | } |
| 969 | *i = meye.grab_buffer[*i].size; | ||
| 970 | mutex_unlock(&meye.lock); | ||
| 971 | return 0; | ||
| 972 | } | ||
| 1078 | 973 | ||
| 1079 | case MEYEIOC_SYNC: { | 974 | static int meyeioc_stillcapt(void) |
| 1080 | int *i = arg; | 975 | { |
| 1081 | int unused; | 976 | if (!meye.grab_fbuffer) |
| 977 | return -EINVAL; | ||
| 1082 | 978 | ||
| 1083 | if (*i < 0 || *i >= gbuffers) | 979 | if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED) |
| 1084 | return -EINVAL; | 980 | return -EBUSY; |
| 1085 | 981 | ||
| 1086 | mutex_lock(&meye.lock); | 982 | mutex_lock(&meye.lock); |
| 1087 | switch (meye.grab_buffer[*i].state) { | 983 | meye.grab_buffer[0].state = MEYE_BUF_USING; |
| 984 | mchip_take_picture(); | ||
| 1088 | 985 | ||
| 1089 | case MEYE_BUF_UNUSED: | 986 | mchip_get_picture(meye.grab_fbuffer, |
| 1090 | mutex_unlock(&meye.lock); | 987 | mchip_hsize() * mchip_vsize() * 2); |
| 1091 | return -EINVAL; | ||
| 1092 | case MEYE_BUF_USING: | ||
| 1093 | if (file->f_flags & O_NONBLOCK) { | ||
| 1094 | mutex_unlock(&meye.lock); | ||
| 1095 | return -EAGAIN; | ||
| 1096 | } | ||
| 1097 | if (wait_event_interruptible(meye.proc_list, | ||
| 1098 | (meye.grab_buffer[*i].state != MEYE_BUF_USING))) { | ||
| 1099 | mutex_unlock(&meye.lock); | ||
| 1100 | return -EINTR; | ||
| 1101 | } | ||
| 1102 | /* fall through */ | ||
| 1103 | case MEYE_BUF_DONE: | ||
| 1104 | meye.grab_buffer[*i].state = MEYE_BUF_UNUSED; | ||
| 1105 | kfifo_get(meye.doneq, (unsigned char *)&unused, sizeof(int)); | ||
| 1106 | } | ||
| 1107 | *i = meye.grab_buffer[*i].size; | ||
| 1108 | mutex_unlock(&meye.lock); | ||
| 1109 | break; | ||
| 1110 | } | ||
| 1111 | 988 | ||
| 1112 | case MEYEIOC_STILLCAPT: { | 989 | meye.grab_buffer[0].state = MEYE_BUF_DONE; |
| 990 | mutex_unlock(&meye.lock); | ||
| 1113 | 991 | ||
| 1114 | if (!meye.grab_fbuffer) | 992 | return 0; |
| 1115 | return -EINVAL; | 993 | } |
| 1116 | if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED) | 994 | |
| 1117 | return -EBUSY; | 995 | static int meyeioc_stilljcapt(int *len) |
| 1118 | mutex_lock(&meye.lock); | 996 | { |
| 1119 | meye.grab_buffer[0].state = MEYE_BUF_USING; | 997 | if (!meye.grab_fbuffer) |
| 998 | return -EINVAL; | ||
| 999 | |||
| 1000 | if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED) | ||
| 1001 | return -EBUSY; | ||
| 1002 | |||
| 1003 | mutex_lock(&meye.lock); | ||
| 1004 | meye.grab_buffer[0].state = MEYE_BUF_USING; | ||
| 1005 | *len = -1; | ||
| 1006 | |||
| 1007 | while (*len == -1) { | ||
| 1120 | mchip_take_picture(); | 1008 | mchip_take_picture(); |
| 1121 | mchip_get_picture( | 1009 | *len = mchip_compress_frame(meye.grab_fbuffer, gbufsize); |
| 1122 | meye.grab_fbuffer, | ||
| 1123 | mchip_hsize() * mchip_vsize() * 2); | ||
| 1124 | meye.grab_buffer[0].state = MEYE_BUF_DONE; | ||
| 1125 | mutex_unlock(&meye.lock); | ||
| 1126 | break; | ||
| 1127 | } | 1010 | } |
| 1128 | 1011 | ||
| 1129 | case MEYEIOC_STILLJCAPT: { | 1012 | meye.grab_buffer[0].state = MEYE_BUF_DONE; |
| 1130 | int *len = arg; | 1013 | mutex_unlock(&meye.lock); |
| 1131 | 1014 | return 0; | |
| 1132 | if (!meye.grab_fbuffer) | 1015 | } |
| 1133 | return -EINVAL; | ||
| 1134 | if (meye.grab_buffer[0].state != MEYE_BUF_UNUSED) | ||
| 1135 | return -EBUSY; | ||
| 1136 | mutex_lock(&meye.lock); | ||
| 1137 | meye.grab_buffer[0].state = MEYE_BUF_USING; | ||
| 1138 | *len = -1; | ||
| 1139 | while (*len == -1) { | ||
| 1140 | mchip_take_picture(); | ||
| 1141 | *len = mchip_compress_frame(meye.grab_fbuffer, gbufsize); | ||
| 1142 | } | ||
| 1143 | meye.grab_buffer[0].state = MEYE_BUF_DONE; | ||
| 1144 | mutex_unlock(&meye.lock); | ||
| 1145 | break; | ||
| 1146 | } | ||
| 1147 | 1016 | ||
| 1148 | case VIDIOC_QUERYCAP: { | 1017 | static int vidioc_querycap(struct file *file, void *fh, |
| 1149 | struct v4l2_capability *cap = arg; | 1018 | struct v4l2_capability *cap) |
| 1019 | { | ||
| 1020 | memset(cap, 0, sizeof(*cap)); | ||
| 1021 | strcpy(cap->driver, "meye"); | ||
| 1022 | strcpy(cap->card, "meye"); | ||
| 1023 | sprintf(cap->bus_info, "PCI:%s", pci_name(meye.mchip_dev)); | ||
| 1150 | 1024 | ||
| 1151 | if (forcev4l1) | 1025 | cap->version = (MEYE_DRIVER_MAJORVERSION << 8) + |
| 1152 | return -EINVAL; | 1026 | MEYE_DRIVER_MINORVERSION; |
| 1153 | 1027 | ||
| 1154 | memset(cap, 0, sizeof(*cap)); | 1028 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | |
| 1155 | strcpy(cap->driver, "meye"); | 1029 | V4L2_CAP_STREAMING; |
| 1156 | strcpy(cap->card, "meye"); | 1030 | |
| 1157 | sprintf(cap->bus_info, "PCI:%s", pci_name(meye.mchip_dev)); | 1031 | return 0; |
| 1158 | cap->version = (MEYE_DRIVER_MAJORVERSION << 8) + | 1032 | } |
| 1159 | MEYE_DRIVER_MINORVERSION; | 1033 | |
| 1160 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | | 1034 | static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *i) |
| 1161 | V4L2_CAP_STREAMING; | 1035 | { |
| 1162 | break; | 1036 | if (i->index != 0) |
| 1163 | } | 1037 | return -EINVAL; |
| 1164 | 1038 | ||
| 1165 | case VIDIOC_ENUMINPUT: { | 1039 | memset(i, 0, sizeof(*i)); |
| 1166 | struct v4l2_input *i = arg; | 1040 | i->index = 0; |
| 1041 | strcpy(i->name, "Camera"); | ||
| 1042 | i->type = V4L2_INPUT_TYPE_CAMERA; | ||
| 1167 | 1043 | ||
| 1168 | if (i->index != 0) | 1044 | return 0; |
| 1169 | return -EINVAL; | 1045 | } |
| 1170 | memset(i, 0, sizeof(*i)); | 1046 | |
| 1171 | i->index = 0; | 1047 | static int vidioc_g_input(struct file *file, void *fh, unsigned int *i) |
| 1172 | strcpy(i->name, "Camera"); | 1048 | { |
| 1173 | i->type = V4L2_INPUT_TYPE_CAMERA; | 1049 | *i = 0; |
| 1050 | return 0; | ||
| 1051 | } | ||
| 1052 | |||
| 1053 | static int vidioc_s_input(struct file *file, void *fh, unsigned int i) | ||
| 1054 | { | ||
| 1055 | if (i != 0) | ||
| 1056 | return -EINVAL; | ||
| 1057 | |||
| 1058 | return 0; | ||
| 1059 | } | ||
| 1060 | |||
| 1061 | static int vidioc_queryctrl(struct file *file, void *fh, | ||
| 1062 | struct v4l2_queryctrl *c) | ||
| 1063 | { | ||
| 1064 | switch (c->id) { | ||
| 1065 | |||
| 1066 | case V4L2_CID_BRIGHTNESS: | ||
| 1067 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1068 | strcpy(c->name, "Brightness"); | ||
| 1069 | c->minimum = 0; | ||
| 1070 | c->maximum = 63; | ||
| 1071 | c->step = 1; | ||
| 1072 | c->default_value = 32; | ||
| 1073 | c->flags = 0; | ||
| 1074 | break; | ||
| 1075 | case V4L2_CID_HUE: | ||
| 1076 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1077 | strcpy(c->name, "Hue"); | ||
| 1078 | c->minimum = 0; | ||
| 1079 | c->maximum = 63; | ||
| 1080 | c->step = 1; | ||
| 1081 | c->default_value = 32; | ||
| 1082 | c->flags = 0; | ||
| 1083 | break; | ||
| 1084 | case V4L2_CID_CONTRAST: | ||
| 1085 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1086 | strcpy(c->name, "Contrast"); | ||
| 1087 | c->minimum = 0; | ||
| 1088 | c->maximum = 63; | ||
| 1089 | c->step = 1; | ||
| 1090 | c->default_value = 32; | ||
| 1091 | c->flags = 0; | ||
| 1092 | break; | ||
| 1093 | case V4L2_CID_SATURATION: | ||
| 1094 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1095 | strcpy(c->name, "Saturation"); | ||
| 1096 | c->minimum = 0; | ||
| 1097 | c->maximum = 63; | ||
| 1098 | c->step = 1; | ||
| 1099 | c->default_value = 32; | ||
| 1100 | c->flags = 0; | ||
| 1101 | break; | ||
| 1102 | case V4L2_CID_AGC: | ||
| 1103 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1104 | strcpy(c->name, "Agc"); | ||
| 1105 | c->minimum = 0; | ||
| 1106 | c->maximum = 63; | ||
| 1107 | c->step = 1; | ||
| 1108 | c->default_value = 48; | ||
| 1109 | c->flags = 0; | ||
| 1174 | break; | 1110 | break; |
| 1111 | case V4L2_CID_MEYE_SHARPNESS: | ||
| 1112 | case V4L2_CID_SHARPNESS: | ||
| 1113 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1114 | strcpy(c->name, "Sharpness"); | ||
| 1115 | c->minimum = 0; | ||
| 1116 | c->maximum = 63; | ||
| 1117 | c->step = 1; | ||
| 1118 | c->default_value = 32; | ||
| 1119 | |||
| 1120 | /* Continue to report legacy private SHARPNESS ctrl but | ||
| 1121 | * say it is disabled in preference to ctrl in the spec | ||
| 1122 | */ | ||
| 1123 | c->flags = (c->id == V4L2_CID_SHARPNESS) ? 0 : | ||
| 1124 | V4L2_CTRL_FLAG_DISABLED; | ||
| 1125 | break; | ||
| 1126 | case V4L2_CID_PICTURE: | ||
| 1127 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1128 | strcpy(c->name, "Picture"); | ||
| 1129 | c->minimum = 0; | ||
| 1130 | c->maximum = 63; | ||
| 1131 | c->step = 1; | ||
| 1132 | c->default_value = 0; | ||
| 1133 | c->flags = 0; | ||
| 1134 | break; | ||
| 1135 | case V4L2_CID_JPEGQUAL: | ||
| 1136 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1137 | strcpy(c->name, "JPEG quality"); | ||
| 1138 | c->minimum = 0; | ||
| 1139 | c->maximum = 10; | ||
| 1140 | c->step = 1; | ||
| 1141 | c->default_value = 8; | ||
| 1142 | c->flags = 0; | ||
| 1143 | break; | ||
| 1144 | case V4L2_CID_FRAMERATE: | ||
| 1145 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1146 | strcpy(c->name, "Framerate"); | ||
| 1147 | c->minimum = 0; | ||
| 1148 | c->maximum = 31; | ||
| 1149 | c->step = 1; | ||
| 1150 | c->default_value = 0; | ||
| 1151 | c->flags = 0; | ||
| 1152 | break; | ||
| 1153 | default: | ||
| 1154 | return -EINVAL; | ||
| 1175 | } | 1155 | } |
| 1176 | 1156 | ||
| 1177 | case VIDIOC_G_INPUT: { | 1157 | return 0; |
| 1178 | int *i = arg; | 1158 | } |
| 1179 | 1159 | ||
| 1180 | *i = 0; | 1160 | static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *c) |
| 1161 | { | ||
| 1162 | mutex_lock(&meye.lock); | ||
| 1163 | switch (c->id) { | ||
| 1164 | case V4L2_CID_BRIGHTNESS: | ||
| 1165 | sony_pic_camera_command( | ||
| 1166 | SONY_PIC_COMMAND_SETCAMERABRIGHTNESS, c->value); | ||
| 1167 | meye.picture.brightness = c->value << 10; | ||
| 1168 | break; | ||
| 1169 | case V4L2_CID_HUE: | ||
| 1170 | sony_pic_camera_command( | ||
| 1171 | SONY_PIC_COMMAND_SETCAMERAHUE, c->value); | ||
| 1172 | meye.picture.hue = c->value << 10; | ||
| 1173 | break; | ||
| 1174 | case V4L2_CID_CONTRAST: | ||
| 1175 | sony_pic_camera_command( | ||
| 1176 | SONY_PIC_COMMAND_SETCAMERACONTRAST, c->value); | ||
| 1177 | meye.picture.contrast = c->value << 10; | ||
| 1178 | break; | ||
| 1179 | case V4L2_CID_SATURATION: | ||
| 1180 | sony_pic_camera_command( | ||
| 1181 | SONY_PIC_COMMAND_SETCAMERACOLOR, c->value); | ||
| 1182 | meye.picture.colour = c->value << 10; | ||
| 1183 | break; | ||
| 1184 | case V4L2_CID_AGC: | ||
| 1185 | sony_pic_camera_command( | ||
| 1186 | SONY_PIC_COMMAND_SETCAMERAAGC, c->value); | ||
| 1187 | meye.params.agc = c->value; | ||
| 1188 | break; | ||
| 1189 | case V4L2_CID_SHARPNESS: | ||
| 1190 | case V4L2_CID_MEYE_SHARPNESS: | ||
| 1191 | sony_pic_camera_command( | ||
| 1192 | SONY_PIC_COMMAND_SETCAMERASHARPNESS, c->value); | ||
| 1193 | meye.params.sharpness = c->value; | ||
| 1194 | break; | ||
| 1195 | case V4L2_CID_PICTURE: | ||
| 1196 | sony_pic_camera_command( | ||
| 1197 | SONY_PIC_COMMAND_SETCAMERAPICTURE, c->value); | ||
| 1198 | meye.params.picture = c->value; | ||
| 1199 | break; | ||
| 1200 | case V4L2_CID_JPEGQUAL: | ||
| 1201 | meye.params.quality = c->value; | ||
| 1202 | break; | ||
| 1203 | case V4L2_CID_FRAMERATE: | ||
| 1204 | meye.params.framerate = c->value; | ||
| 1181 | break; | 1205 | break; |
| 1206 | default: | ||
| 1207 | mutex_unlock(&meye.lock); | ||
| 1208 | return -EINVAL; | ||
| 1182 | } | 1209 | } |
| 1210 | mutex_unlock(&meye.lock); | ||
| 1183 | 1211 | ||
| 1184 | case VIDIOC_S_INPUT: { | 1212 | return 0; |
| 1185 | int *i = arg; | 1213 | } |
| 1186 | 1214 | ||
| 1187 | if (*i != 0) | 1215 | static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *c) |
| 1188 | return -EINVAL; | 1216 | { |
| 1217 | mutex_lock(&meye.lock); | ||
| 1218 | switch (c->id) { | ||
| 1219 | case V4L2_CID_BRIGHTNESS: | ||
| 1220 | c->value = meye.picture.brightness >> 10; | ||
| 1221 | break; | ||
| 1222 | case V4L2_CID_HUE: | ||
| 1223 | c->value = meye.picture.hue >> 10; | ||
| 1224 | break; | ||
| 1225 | case V4L2_CID_CONTRAST: | ||
| 1226 | c->value = meye.picture.contrast >> 10; | ||
| 1227 | break; | ||
| 1228 | case V4L2_CID_SATURATION: | ||
| 1229 | c->value = meye.picture.colour >> 10; | ||
| 1230 | break; | ||
| 1231 | case V4L2_CID_AGC: | ||
| 1232 | c->value = meye.params.agc; | ||
| 1233 | break; | ||
| 1234 | case V4L2_CID_SHARPNESS: | ||
| 1235 | case V4L2_CID_MEYE_SHARPNESS: | ||
| 1236 | c->value = meye.params.sharpness; | ||
| 1189 | break; | 1237 | break; |
| 1238 | case V4L2_CID_PICTURE: | ||
| 1239 | c->value = meye.params.picture; | ||
| 1240 | break; | ||
| 1241 | case V4L2_CID_JPEGQUAL: | ||
| 1242 | c->value = meye.params.quality; | ||
| 1243 | break; | ||
| 1244 | case V4L2_CID_FRAMERATE: | ||
| 1245 | c->value = meye.params.framerate; | ||
| 1246 | break; | ||
| 1247 | default: | ||
| 1248 | mutex_unlock(&meye.lock); | ||
| 1249 | return -EINVAL; | ||
| 1190 | } | 1250 | } |
| 1251 | mutex_unlock(&meye.lock); | ||
| 1191 | 1252 | ||
| 1192 | case VIDIOC_QUERYCTRL: { | 1253 | return 0; |
| 1193 | struct v4l2_queryctrl *c = arg; | 1254 | } |
| 1194 | 1255 | ||
| 1195 | switch (c->id) { | 1256 | static int vidioc_enum_fmt_cap(struct file *file, void *fh, |
| 1257 | struct v4l2_fmtdesc *f) | ||
| 1258 | { | ||
| 1259 | if (f->index > 1) | ||
| 1260 | return -EINVAL; | ||
| 1196 | 1261 | ||
| 1197 | case V4L2_CID_BRIGHTNESS: | 1262 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
| 1198 | c->type = V4L2_CTRL_TYPE_INTEGER; | 1263 | return -EINVAL; |
| 1199 | strcpy(c->name, "Brightness"); | 1264 | |
| 1200 | c->minimum = 0; | 1265 | if (f->index == 0) { |
| 1201 | c->maximum = 63; | 1266 | /* standard YUV 422 capture */ |
| 1202 | c->step = 1; | 1267 | memset(f, 0, sizeof(*f)); |
| 1203 | c->default_value = 32; | 1268 | f->index = 0; |
| 1204 | c->flags = 0; | 1269 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 1205 | break; | 1270 | f->flags = 0; |
| 1206 | case V4L2_CID_HUE: | 1271 | strcpy(f->description, "YUV422"); |
| 1207 | c->type = V4L2_CTRL_TYPE_INTEGER; | 1272 | f->pixelformat = V4L2_PIX_FMT_YUYV; |
| 1208 | strcpy(c->name, "Hue"); | 1273 | } else { |
| 1209 | c->minimum = 0; | 1274 | /* compressed MJPEG capture */ |
| 1210 | c->maximum = 63; | 1275 | memset(f, 0, sizeof(*f)); |
| 1211 | c->step = 1; | 1276 | f->index = 1; |
| 1212 | c->default_value = 32; | 1277 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 1213 | c->flags = 0; | 1278 | f->flags = V4L2_FMT_FLAG_COMPRESSED; |
| 1214 | break; | 1279 | strcpy(f->description, "MJPEG"); |
| 1215 | case V4L2_CID_CONTRAST: | 1280 | f->pixelformat = V4L2_PIX_FMT_MJPEG; |
| 1216 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1217 | strcpy(c->name, "Contrast"); | ||
| 1218 | c->minimum = 0; | ||
| 1219 | c->maximum = 63; | ||
| 1220 | c->step = 1; | ||
| 1221 | c->default_value = 32; | ||
| 1222 | c->flags = 0; | ||
| 1223 | break; | ||
| 1224 | case V4L2_CID_SATURATION: | ||
| 1225 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1226 | strcpy(c->name, "Saturation"); | ||
| 1227 | c->minimum = 0; | ||
| 1228 | c->maximum = 63; | ||
| 1229 | c->step = 1; | ||
| 1230 | c->default_value = 32; | ||
| 1231 | c->flags = 0; | ||
| 1232 | break; | ||
| 1233 | case V4L2_CID_AGC: | ||
| 1234 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1235 | strcpy(c->name, "Agc"); | ||
| 1236 | c->minimum = 0; | ||
| 1237 | c->maximum = 63; | ||
| 1238 | c->step = 1; | ||
| 1239 | c->default_value = 48; | ||
| 1240 | c->flags = 0; | ||
| 1241 | break; | ||
| 1242 | case V4L2_CID_SHARPNESS: | ||
| 1243 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1244 | strcpy(c->name, "Sharpness"); | ||
| 1245 | c->minimum = 0; | ||
| 1246 | c->maximum = 63; | ||
| 1247 | c->step = 1; | ||
| 1248 | c->default_value = 32; | ||
| 1249 | c->flags = 0; | ||
| 1250 | break; | ||
| 1251 | case V4L2_CID_PICTURE: | ||
| 1252 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1253 | strcpy(c->name, "Picture"); | ||
| 1254 | c->minimum = 0; | ||
| 1255 | c->maximum = 63; | ||
| 1256 | c->step = 1; | ||
| 1257 | c->default_value = 0; | ||
| 1258 | c->flags = 0; | ||
| 1259 | break; | ||
| 1260 | case V4L2_CID_JPEGQUAL: | ||
| 1261 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1262 | strcpy(c->name, "JPEG quality"); | ||
| 1263 | c->minimum = 0; | ||
| 1264 | c->maximum = 10; | ||
| 1265 | c->step = 1; | ||
| 1266 | c->default_value = 8; | ||
| 1267 | c->flags = 0; | ||
| 1268 | break; | ||
| 1269 | case V4L2_CID_FRAMERATE: | ||
| 1270 | c->type = V4L2_CTRL_TYPE_INTEGER; | ||
| 1271 | strcpy(c->name, "Framerate"); | ||
| 1272 | c->minimum = 0; | ||
| 1273 | c->maximum = 31; | ||
| 1274 | c->step = 1; | ||
| 1275 | c->default_value = 0; | ||
| 1276 | c->flags = 0; | ||
| 1277 | break; | ||
| 1278 | default: | ||
| 1279 | return -EINVAL; | ||
| 1280 | } | ||
| 1281 | break; | ||
| 1282 | } | 1281 | } |
| 1283 | 1282 | ||
| 1284 | case VIDIOC_S_CTRL: { | 1283 | return 0; |
| 1285 | struct v4l2_control *c = arg; | 1284 | } |
| 1286 | 1285 | ||
| 1287 | mutex_lock(&meye.lock); | 1286 | static int vidioc_try_fmt_cap(struct file *file, void *fh, |
| 1288 | switch (c->id) { | 1287 | struct v4l2_format *f) |
| 1289 | case V4L2_CID_BRIGHTNESS: | 1288 | { |
| 1290 | sony_pic_camera_command( | 1289 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
| 1291 | SONY_PIC_COMMAND_SETCAMERABRIGHTNESS, c->value); | 1290 | return -EINVAL; |
| 1292 | meye.picture.brightness = c->value << 10; | 1291 | |
| 1293 | break; | 1292 | if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV && |
| 1294 | case V4L2_CID_HUE: | 1293 | f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG) |
| 1295 | sony_pic_camera_command( | 1294 | return -EINVAL; |
| 1296 | SONY_PIC_COMMAND_SETCAMERAHUE, c->value); | 1295 | |
| 1297 | meye.picture.hue = c->value << 10; | 1296 | if (f->fmt.pix.field != V4L2_FIELD_ANY && |
| 1298 | break; | 1297 | f->fmt.pix.field != V4L2_FIELD_NONE) |
| 1299 | case V4L2_CID_CONTRAST: | 1298 | return -EINVAL; |
| 1300 | sony_pic_camera_command( | 1299 | |
| 1301 | SONY_PIC_COMMAND_SETCAMERACONTRAST, c->value); | 1300 | f->fmt.pix.field = V4L2_FIELD_NONE; |
| 1302 | meye.picture.contrast = c->value << 10; | 1301 | |
| 1303 | break; | 1302 | if (f->fmt.pix.width <= 320) { |
| 1304 | case V4L2_CID_SATURATION: | 1303 | f->fmt.pix.width = 320; |
| 1305 | sony_pic_camera_command( | 1304 | f->fmt.pix.height = 240; |
| 1306 | SONY_PIC_COMMAND_SETCAMERACOLOR, c->value); | 1305 | } else { |
| 1307 | meye.picture.colour = c->value << 10; | 1306 | f->fmt.pix.width = 640; |
| 1308 | break; | 1307 | f->fmt.pix.height = 480; |
| 1309 | case V4L2_CID_AGC: | ||
| 1310 | sony_pic_camera_command( | ||
| 1311 | SONY_PIC_COMMAND_SETCAMERAAGC, c->value); | ||
| 1312 | meye.params.agc = c->value; | ||
| 1313 | break; | ||
| 1314 | case V4L2_CID_SHARPNESS: | ||
| 1315 | sony_pic_camera_command( | ||
| 1316 | SONY_PIC_COMMAND_SETCAMERASHARPNESS, c->value); | ||
| 1317 | meye.params.sharpness = c->value; | ||
| 1318 | break; | ||
| 1319 | case V4L2_CID_PICTURE: | ||
| 1320 | sony_pic_camera_command( | ||
| 1321 | SONY_PIC_COMMAND_SETCAMERAPICTURE, c->value); | ||
| 1322 | meye.params.picture = c->value; | ||
| 1323 | break; | ||
| 1324 | case V4L2_CID_JPEGQUAL: | ||
| 1325 | meye.params.quality = c->value; | ||
| 1326 | break; | ||
| 1327 | case V4L2_CID_FRAMERATE: | ||
| 1328 | meye.params.framerate = c->value; | ||
| 1329 | break; | ||
| 1330 | default: | ||
| 1331 | mutex_unlock(&meye.lock); | ||
| 1332 | return -EINVAL; | ||
| 1333 | } | ||
| 1334 | mutex_unlock(&meye.lock); | ||
| 1335 | break; | ||
| 1336 | } | 1308 | } |
| 1337 | 1309 | ||
| 1338 | case VIDIOC_G_CTRL: { | 1310 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; |
| 1339 | struct v4l2_control *c = arg; | 1311 | f->fmt.pix.sizeimage = f->fmt.pix.height * |
| 1312 | f->fmt.pix.bytesperline; | ||
| 1313 | f->fmt.pix.colorspace = 0; | ||
| 1314 | f->fmt.pix.priv = 0; | ||
| 1340 | 1315 | ||
| 1341 | mutex_lock(&meye.lock); | 1316 | return 0; |
| 1342 | switch (c->id) { | 1317 | } |
| 1343 | case V4L2_CID_BRIGHTNESS: | 1318 | |
| 1344 | c->value = meye.picture.brightness >> 10; | 1319 | static int vidioc_g_fmt_cap(struct file *file, void *fh, struct v4l2_format *f) |
| 1345 | break; | 1320 | { |
| 1346 | case V4L2_CID_HUE: | 1321 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
| 1347 | c->value = meye.picture.hue >> 10; | 1322 | return -EINVAL; |
| 1348 | break; | 1323 | |
| 1349 | case V4L2_CID_CONTRAST: | 1324 | memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format)); |
| 1350 | c->value = meye.picture.contrast >> 10; | 1325 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 1351 | break; | 1326 | |
| 1352 | case V4L2_CID_SATURATION: | 1327 | switch (meye.mchip_mode) { |
| 1353 | c->value = meye.picture.colour >> 10; | 1328 | case MCHIP_HIC_MODE_CONT_OUT: |
| 1354 | break; | 1329 | default: |
| 1355 | case V4L2_CID_AGC: | 1330 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; |
| 1356 | c->value = meye.params.agc; | 1331 | break; |
| 1357 | break; | 1332 | case MCHIP_HIC_MODE_CONT_COMP: |
| 1358 | case V4L2_CID_SHARPNESS: | 1333 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG; |
| 1359 | c->value = meye.params.sharpness; | ||
| 1360 | break; | ||
| 1361 | case V4L2_CID_PICTURE: | ||
| 1362 | c->value = meye.params.picture; | ||
| 1363 | break; | ||
| 1364 | case V4L2_CID_JPEGQUAL: | ||
| 1365 | c->value = meye.params.quality; | ||
| 1366 | break; | ||
| 1367 | case V4L2_CID_FRAMERATE: | ||
| 1368 | c->value = meye.params.framerate; | ||
| 1369 | break; | ||
| 1370 | default: | ||
| 1371 | mutex_unlock(&meye.lock); | ||
| 1372 | return -EINVAL; | ||
| 1373 | } | ||
| 1374 | mutex_unlock(&meye.lock); | ||
| 1375 | break; | 1334 | break; |
| 1376 | } | 1335 | } |
| 1377 | 1336 | ||
| 1378 | case VIDIOC_ENUM_FMT: { | 1337 | f->fmt.pix.field = V4L2_FIELD_NONE; |
| 1379 | struct v4l2_fmtdesc *f = arg; | 1338 | f->fmt.pix.width = mchip_hsize(); |
| 1380 | 1339 | f->fmt.pix.height = mchip_vsize(); | |
| 1381 | if (f->index > 1) | 1340 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; |
| 1382 | return -EINVAL; | 1341 | f->fmt.pix.sizeimage = f->fmt.pix.height * |
| 1383 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1342 | f->fmt.pix.bytesperline; |
| 1384 | return -EINVAL; | 1343 | f->fmt.pix.colorspace = 0; |
| 1385 | if (f->index == 0) { | 1344 | f->fmt.pix.priv = 0; |
| 1386 | /* standard YUV 422 capture */ | 1345 | |
| 1387 | memset(f, 0, sizeof(*f)); | 1346 | return 0; |
| 1388 | f->index = 0; | 1347 | } |
| 1389 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1348 | |
| 1390 | f->flags = 0; | 1349 | static int vidioc_s_fmt_cap(struct file *file, void *fh, struct v4l2_format *f) |
| 1391 | strcpy(f->description, "YUV422"); | 1350 | { |
| 1392 | f->pixelformat = V4L2_PIX_FMT_YUYV; | 1351 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
| 1393 | } else { | 1352 | return -EINVAL; |
| 1394 | /* compressed MJPEG capture */ | 1353 | |
| 1395 | memset(f, 0, sizeof(*f)); | 1354 | if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV && |
| 1396 | f->index = 1; | 1355 | f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG) |
| 1397 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1356 | return -EINVAL; |
| 1398 | f->flags = V4L2_FMT_FLAG_COMPRESSED; | 1357 | |
| 1399 | strcpy(f->description, "MJPEG"); | 1358 | if (f->fmt.pix.field != V4L2_FIELD_ANY && |
| 1400 | f->pixelformat = V4L2_PIX_FMT_MJPEG; | 1359 | f->fmt.pix.field != V4L2_FIELD_NONE) |
| 1401 | } | 1360 | return -EINVAL; |
| 1402 | break; | 1361 | |
| 1362 | f->fmt.pix.field = V4L2_FIELD_NONE; | ||
| 1363 | mutex_lock(&meye.lock); | ||
| 1364 | |||
| 1365 | if (f->fmt.pix.width <= 320) { | ||
| 1366 | f->fmt.pix.width = 320; | ||
| 1367 | f->fmt.pix.height = 240; | ||
| 1368 | meye.params.subsample = 1; | ||
| 1369 | } else { | ||
| 1370 | f->fmt.pix.width = 640; | ||
| 1371 | f->fmt.pix.height = 480; | ||
| 1372 | meye.params.subsample = 0; | ||
| 1403 | } | 1373 | } |
| 1404 | 1374 | ||
| 1405 | case VIDIOC_TRY_FMT: { | 1375 | switch (f->fmt.pix.pixelformat) { |
| 1406 | struct v4l2_format *f = arg; | 1376 | case V4L2_PIX_FMT_YUYV: |
| 1407 | 1377 | meye.mchip_mode = MCHIP_HIC_MODE_CONT_OUT; | |
| 1408 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1378 | break; |
| 1409 | return -EINVAL; | 1379 | case V4L2_PIX_FMT_MJPEG: |
| 1410 | if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV && | 1380 | meye.mchip_mode = MCHIP_HIC_MODE_CONT_COMP; |
| 1411 | f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG) | ||
| 1412 | return -EINVAL; | ||
| 1413 | if (f->fmt.pix.field != V4L2_FIELD_ANY && | ||
| 1414 | f->fmt.pix.field != V4L2_FIELD_NONE) | ||
| 1415 | return -EINVAL; | ||
| 1416 | f->fmt.pix.field = V4L2_FIELD_NONE; | ||
| 1417 | if (f->fmt.pix.width <= 320) { | ||
| 1418 | f->fmt.pix.width = 320; | ||
| 1419 | f->fmt.pix.height = 240; | ||
| 1420 | } else { | ||
| 1421 | f->fmt.pix.width = 640; | ||
| 1422 | f->fmt.pix.height = 480; | ||
| 1423 | } | ||
| 1424 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; | ||
| 1425 | f->fmt.pix.sizeimage = f->fmt.pix.height * | ||
| 1426 | f->fmt.pix.bytesperline; | ||
| 1427 | f->fmt.pix.colorspace = 0; | ||
| 1428 | f->fmt.pix.priv = 0; | ||
| 1429 | break; | 1381 | break; |
| 1430 | } | 1382 | } |
| 1431 | 1383 | ||
| 1432 | case VIDIOC_G_FMT: { | 1384 | mutex_unlock(&meye.lock); |
| 1433 | struct v4l2_format *f = arg; | 1385 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; |
| 1386 | f->fmt.pix.sizeimage = f->fmt.pix.height * | ||
| 1387 | f->fmt.pix.bytesperline; | ||
| 1388 | f->fmt.pix.colorspace = 0; | ||
| 1389 | f->fmt.pix.priv = 0; | ||
| 1434 | 1390 | ||
| 1435 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1391 | return 0; |
| 1436 | return -EINVAL; | 1392 | } |
| 1437 | memset(&f->fmt.pix, 0, sizeof(struct v4l2_pix_format)); | ||
| 1438 | f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 1439 | switch (meye.mchip_mode) { | ||
| 1440 | case MCHIP_HIC_MODE_CONT_OUT: | ||
| 1441 | default: | ||
| 1442 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; | ||
| 1443 | break; | ||
| 1444 | case MCHIP_HIC_MODE_CONT_COMP: | ||
| 1445 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG; | ||
| 1446 | break; | ||
| 1447 | } | ||
| 1448 | f->fmt.pix.field = V4L2_FIELD_NONE; | ||
| 1449 | f->fmt.pix.width = mchip_hsize(); | ||
| 1450 | f->fmt.pix.height = mchip_vsize(); | ||
| 1451 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; | ||
| 1452 | f->fmt.pix.sizeimage = f->fmt.pix.height * | ||
| 1453 | f->fmt.pix.bytesperline; | ||
| 1454 | f->fmt.pix.colorspace = 0; | ||
| 1455 | f->fmt.pix.priv = 0; | ||
| 1456 | break; | ||
| 1457 | } | ||
| 1458 | 1393 | ||
| 1459 | case VIDIOC_S_FMT: { | 1394 | static int vidioc_reqbufs(struct file *file, void *fh, |
| 1460 | struct v4l2_format *f = arg; | 1395 | struct v4l2_requestbuffers *req) |
| 1461 | 1396 | { | |
| 1462 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1397 | int i; |
| 1463 | return -EINVAL; | ||
| 1464 | if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_YUYV && | ||
| 1465 | f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG) | ||
| 1466 | return -EINVAL; | ||
| 1467 | if (f->fmt.pix.field != V4L2_FIELD_ANY && | ||
| 1468 | f->fmt.pix.field != V4L2_FIELD_NONE) | ||
| 1469 | return -EINVAL; | ||
| 1470 | f->fmt.pix.field = V4L2_FIELD_NONE; | ||
| 1471 | mutex_lock(&meye.lock); | ||
| 1472 | if (f->fmt.pix.width <= 320) { | ||
| 1473 | f->fmt.pix.width = 320; | ||
| 1474 | f->fmt.pix.height = 240; | ||
| 1475 | meye.params.subsample = 1; | ||
| 1476 | } else { | ||
| 1477 | f->fmt.pix.width = 640; | ||
| 1478 | f->fmt.pix.height = 480; | ||
| 1479 | meye.params.subsample = 0; | ||
| 1480 | } | ||
| 1481 | switch (f->fmt.pix.pixelformat) { | ||
| 1482 | case V4L2_PIX_FMT_YUYV: | ||
| 1483 | meye.mchip_mode = MCHIP_HIC_MODE_CONT_OUT; | ||
| 1484 | break; | ||
| 1485 | case V4L2_PIX_FMT_MJPEG: | ||
| 1486 | meye.mchip_mode = MCHIP_HIC_MODE_CONT_COMP; | ||
| 1487 | break; | ||
| 1488 | } | ||
| 1489 | mutex_unlock(&meye.lock); | ||
| 1490 | f->fmt.pix.bytesperline = f->fmt.pix.width * 2; | ||
| 1491 | f->fmt.pix.sizeimage = f->fmt.pix.height * | ||
| 1492 | f->fmt.pix.bytesperline; | ||
| 1493 | f->fmt.pix.colorspace = 0; | ||
| 1494 | f->fmt.pix.priv = 0; | ||
| 1495 | 1398 | ||
| 1496 | break; | 1399 | if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
| 1497 | } | 1400 | return -EINVAL; |
| 1498 | 1401 | ||
| 1499 | case VIDIOC_REQBUFS: { | 1402 | if (req->memory != V4L2_MEMORY_MMAP) |
| 1500 | struct v4l2_requestbuffers *req = arg; | 1403 | return -EINVAL; |
| 1501 | int i; | ||
| 1502 | 1404 | ||
| 1503 | if (req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1405 | if (meye.grab_fbuffer && req->count == gbuffers) { |
| 1504 | return -EINVAL; | 1406 | /* already allocated, no modifications */ |
| 1505 | if (req->memory != V4L2_MEMORY_MMAP) | 1407 | return 0; |
| 1506 | return -EINVAL; | ||
| 1507 | if (meye.grab_fbuffer && req->count == gbuffers) { | ||
| 1508 | /* already allocated, no modifications */ | ||
| 1509 | break; | ||
| 1510 | } | ||
| 1511 | mutex_lock(&meye.lock); | ||
| 1512 | if (meye.grab_fbuffer) { | ||
| 1513 | for (i = 0; i < gbuffers; i++) | ||
| 1514 | if (meye.vma_use_count[i]) { | ||
| 1515 | mutex_unlock(&meye.lock); | ||
| 1516 | return -EINVAL; | ||
| 1517 | } | ||
| 1518 | rvfree(meye.grab_fbuffer, gbuffers * gbufsize); | ||
| 1519 | meye.grab_fbuffer = NULL; | ||
| 1520 | } | ||
| 1521 | gbuffers = max(2, min((int)req->count, MEYE_MAX_BUFNBRS)); | ||
| 1522 | req->count = gbuffers; | ||
| 1523 | meye.grab_fbuffer = rvmalloc(gbuffers * gbufsize); | ||
| 1524 | if (!meye.grab_fbuffer) { | ||
| 1525 | printk(KERN_ERR "meye: v4l framebuffer allocation" | ||
| 1526 | " failed\n"); | ||
| 1527 | mutex_unlock(&meye.lock); | ||
| 1528 | return -ENOMEM; | ||
| 1529 | } | ||
| 1530 | for (i = 0; i < gbuffers; i++) | ||
| 1531 | meye.vma_use_count[i] = 0; | ||
| 1532 | mutex_unlock(&meye.lock); | ||
| 1533 | break; | ||
| 1534 | } | 1408 | } |
| 1535 | 1409 | ||
| 1536 | case VIDIOC_QUERYBUF: { | 1410 | mutex_lock(&meye.lock); |
| 1537 | struct v4l2_buffer *buf = arg; | 1411 | if (meye.grab_fbuffer) { |
| 1538 | int index = buf->index; | 1412 | for (i = 0; i < gbuffers; i++) |
| 1539 | 1413 | if (meye.vma_use_count[i]) { | |
| 1540 | if (index < 0 || index >= gbuffers) | 1414 | mutex_unlock(&meye.lock); |
| 1541 | return -EINVAL; | 1415 | return -EINVAL; |
| 1542 | memset(buf, 0, sizeof(*buf)); | 1416 | } |
| 1543 | buf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1417 | rvfree(meye.grab_fbuffer, gbuffers * gbufsize); |
| 1544 | buf->index = index; | 1418 | meye.grab_fbuffer = NULL; |
| 1545 | buf->bytesused = meye.grab_buffer[index].size; | ||
| 1546 | buf->flags = V4L2_BUF_FLAG_MAPPED; | ||
| 1547 | if (meye.grab_buffer[index].state == MEYE_BUF_USING) | ||
| 1548 | buf->flags |= V4L2_BUF_FLAG_QUEUED; | ||
| 1549 | if (meye.grab_buffer[index].state == MEYE_BUF_DONE) | ||
| 1550 | buf->flags |= V4L2_BUF_FLAG_DONE; | ||
| 1551 | buf->field = V4L2_FIELD_NONE; | ||
| 1552 | buf->timestamp = meye.grab_buffer[index].timestamp; | ||
| 1553 | buf->sequence = meye.grab_buffer[index].sequence; | ||
| 1554 | buf->memory = V4L2_MEMORY_MMAP; | ||
| 1555 | buf->m.offset = index * gbufsize; | ||
| 1556 | buf->length = gbufsize; | ||
| 1557 | break; | ||
| 1558 | } | 1419 | } |
| 1559 | 1420 | ||
| 1560 | case VIDIOC_QBUF: { | 1421 | gbuffers = max(2, min((int)req->count, MEYE_MAX_BUFNBRS)); |
| 1561 | struct v4l2_buffer *buf = arg; | 1422 | req->count = gbuffers; |
| 1562 | 1423 | meye.grab_fbuffer = rvmalloc(gbuffers * gbufsize); | |
| 1563 | if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1424 | |
| 1564 | return -EINVAL; | 1425 | if (!meye.grab_fbuffer) { |
| 1565 | if (buf->memory != V4L2_MEMORY_MMAP) | 1426 | printk(KERN_ERR "meye: v4l framebuffer allocation" |
| 1566 | return -EINVAL; | 1427 | " failed\n"); |
| 1567 | if (buf->index < 0 || buf->index >= gbuffers) | ||
| 1568 | return -EINVAL; | ||
| 1569 | if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED) | ||
| 1570 | return -EINVAL; | ||
| 1571 | mutex_lock(&meye.lock); | ||
| 1572 | buf->flags |= V4L2_BUF_FLAG_QUEUED; | ||
| 1573 | buf->flags &= ~V4L2_BUF_FLAG_DONE; | ||
| 1574 | meye.grab_buffer[buf->index].state = MEYE_BUF_USING; | ||
| 1575 | kfifo_put(meye.grabq, (unsigned char *)&buf->index, sizeof(int)); | ||
| 1576 | mutex_unlock(&meye.lock); | 1428 | mutex_unlock(&meye.lock); |
| 1577 | break; | 1429 | return -ENOMEM; |
| 1578 | } | 1430 | } |
| 1579 | 1431 | ||
| 1580 | case VIDIOC_DQBUF: { | 1432 | for (i = 0; i < gbuffers; i++) |
| 1581 | struct v4l2_buffer *buf = arg; | 1433 | meye.vma_use_count[i] = 0; |
| 1582 | int reqnr; | ||
| 1583 | 1434 | ||
| 1584 | if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1435 | mutex_unlock(&meye.lock); |
| 1585 | return -EINVAL; | ||
| 1586 | if (buf->memory != V4L2_MEMORY_MMAP) | ||
| 1587 | return -EINVAL; | ||
| 1588 | 1436 | ||
| 1589 | mutex_lock(&meye.lock); | 1437 | return 0; |
| 1590 | if (kfifo_len(meye.doneq) == 0 && file->f_flags & O_NONBLOCK) { | 1438 | } |
| 1591 | mutex_unlock(&meye.lock); | 1439 | |
| 1592 | return -EAGAIN; | 1440 | static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf) |
| 1593 | } | 1441 | { |
| 1594 | if (wait_event_interruptible(meye.proc_list, | 1442 | int index = buf->index; |
| 1595 | kfifo_len(meye.doneq) != 0) < 0) { | 1443 | |
| 1596 | mutex_unlock(&meye.lock); | 1444 | if (index < 0 || index >= gbuffers) |
| 1597 | return -EINTR; | 1445 | return -EINVAL; |
| 1598 | } | 1446 | |
| 1599 | if (!kfifo_get(meye.doneq, (unsigned char *)&reqnr, | 1447 | memset(buf, 0, sizeof(*buf)); |
| 1600 | sizeof(int))) { | 1448 | |
| 1601 | mutex_unlock(&meye.lock); | 1449 | buf->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 1602 | return -EBUSY; | 1450 | buf->index = index; |
| 1603 | } | 1451 | buf->bytesused = meye.grab_buffer[index].size; |
| 1604 | if (meye.grab_buffer[reqnr].state != MEYE_BUF_DONE) { | 1452 | buf->flags = V4L2_BUF_FLAG_MAPPED; |
| 1605 | mutex_unlock(&meye.lock); | 1453 | |
| 1606 | return -EINVAL; | 1454 | if (meye.grab_buffer[index].state == MEYE_BUF_USING) |
| 1607 | } | 1455 | buf->flags |= V4L2_BUF_FLAG_QUEUED; |
| 1608 | buf->index = reqnr; | 1456 | |
| 1609 | buf->bytesused = meye.grab_buffer[reqnr].size; | 1457 | if (meye.grab_buffer[index].state == MEYE_BUF_DONE) |
| 1610 | buf->flags = V4L2_BUF_FLAG_MAPPED; | 1458 | buf->flags |= V4L2_BUF_FLAG_DONE; |
| 1611 | buf->field = V4L2_FIELD_NONE; | 1459 | |
| 1612 | buf->timestamp = meye.grab_buffer[reqnr].timestamp; | 1460 | buf->field = V4L2_FIELD_NONE; |
| 1613 | buf->sequence = meye.grab_buffer[reqnr].sequence; | 1461 | buf->timestamp = meye.grab_buffer[index].timestamp; |
| 1614 | buf->memory = V4L2_MEMORY_MMAP; | 1462 | buf->sequence = meye.grab_buffer[index].sequence; |
| 1615 | buf->m.offset = reqnr * gbufsize; | 1463 | buf->memory = V4L2_MEMORY_MMAP; |
| 1616 | buf->length = gbufsize; | 1464 | buf->m.offset = index * gbufsize; |
| 1617 | meye.grab_buffer[reqnr].state = MEYE_BUF_UNUSED; | 1465 | buf->length = gbufsize; |
| 1466 | |||
| 1467 | return 0; | ||
| 1468 | } | ||
| 1469 | |||
| 1470 | static int vidioc_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) | ||
| 1471 | { | ||
| 1472 | if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 1473 | return -EINVAL; | ||
| 1474 | |||
| 1475 | if (buf->memory != V4L2_MEMORY_MMAP) | ||
| 1476 | return -EINVAL; | ||
| 1477 | |||
| 1478 | if (buf->index < 0 || buf->index >= gbuffers) | ||
| 1479 | return -EINVAL; | ||
| 1480 | |||
| 1481 | if (meye.grab_buffer[buf->index].state != MEYE_BUF_UNUSED) | ||
| 1482 | return -EINVAL; | ||
| 1483 | |||
| 1484 | mutex_lock(&meye.lock); | ||
| 1485 | buf->flags |= V4L2_BUF_FLAG_QUEUED; | ||
| 1486 | buf->flags &= ~V4L2_BUF_FLAG_DONE; | ||
| 1487 | meye.grab_buffer[buf->index].state = MEYE_BUF_USING; | ||
| 1488 | kfifo_put(meye.grabq, (unsigned char *)&buf->index, sizeof(int)); | ||
| 1489 | mutex_unlock(&meye.lock); | ||
| 1490 | |||
| 1491 | return 0; | ||
| 1492 | } | ||
| 1493 | |||
| 1494 | static int vidioc_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) | ||
| 1495 | { | ||
| 1496 | int reqnr; | ||
| 1497 | |||
| 1498 | if (buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 1499 | return -EINVAL; | ||
| 1500 | |||
| 1501 | if (buf->memory != V4L2_MEMORY_MMAP) | ||
| 1502 | return -EINVAL; | ||
| 1503 | |||
| 1504 | mutex_lock(&meye.lock); | ||
| 1505 | |||
| 1506 | if (kfifo_len(meye.doneq) == 0 && file->f_flags & O_NONBLOCK) { | ||
| 1618 | mutex_unlock(&meye.lock); | 1507 | mutex_unlock(&meye.lock); |
| 1619 | break; | 1508 | return -EAGAIN; |
| 1620 | } | 1509 | } |
| 1621 | 1510 | ||
| 1622 | case VIDIOC_STREAMON: { | 1511 | if (wait_event_interruptible(meye.proc_list, |
| 1623 | mutex_lock(&meye.lock); | 1512 | kfifo_len(meye.doneq) != 0) < 0) { |
| 1624 | switch (meye.mchip_mode) { | ||
| 1625 | case MCHIP_HIC_MODE_CONT_OUT: | ||
| 1626 | mchip_continuous_start(); | ||
| 1627 | break; | ||
| 1628 | case MCHIP_HIC_MODE_CONT_COMP: | ||
| 1629 | mchip_cont_compression_start(); | ||
| 1630 | break; | ||
| 1631 | default: | ||
| 1632 | mutex_unlock(&meye.lock); | ||
| 1633 | return -EINVAL; | ||
| 1634 | } | ||
| 1635 | mutex_unlock(&meye.lock); | 1513 | mutex_unlock(&meye.lock); |
| 1636 | break; | 1514 | return -EINTR; |
| 1637 | } | 1515 | } |
| 1638 | 1516 | ||
| 1639 | case VIDIOC_STREAMOFF: { | 1517 | if (!kfifo_get(meye.doneq, (unsigned char *)&reqnr, |
| 1640 | int i; | 1518 | sizeof(int))) { |
| 1519 | mutex_unlock(&meye.lock); | ||
| 1520 | return -EBUSY; | ||
| 1521 | } | ||
| 1641 | 1522 | ||
| 1642 | mutex_lock(&meye.lock); | 1523 | if (meye.grab_buffer[reqnr].state != MEYE_BUF_DONE) { |
| 1643 | mchip_hic_stop(); | ||
| 1644 | kfifo_reset(meye.grabq); | ||
| 1645 | kfifo_reset(meye.doneq); | ||
| 1646 | for (i = 0; i < MEYE_MAX_BUFNBRS; i++) | ||
| 1647 | meye.grab_buffer[i].state = MEYE_BUF_UNUSED; | ||
| 1648 | mutex_unlock(&meye.lock); | 1524 | mutex_unlock(&meye.lock); |
| 1649 | break; | 1525 | return -EINVAL; |
| 1650 | } | 1526 | } |
| 1651 | 1527 | ||
| 1652 | /* | 1528 | buf->index = reqnr; |
| 1653 | * XXX what about private snapshot ioctls ? | 1529 | buf->bytesused = meye.grab_buffer[reqnr].size; |
| 1654 | * Do they need to be converted to V4L2 ? | 1530 | buf->flags = V4L2_BUF_FLAG_MAPPED; |
| 1655 | */ | 1531 | buf->field = V4L2_FIELD_NONE; |
| 1532 | buf->timestamp = meye.grab_buffer[reqnr].timestamp; | ||
| 1533 | buf->sequence = meye.grab_buffer[reqnr].sequence; | ||
| 1534 | buf->memory = V4L2_MEMORY_MMAP; | ||
| 1535 | buf->m.offset = reqnr * gbufsize; | ||
| 1536 | buf->length = gbufsize; | ||
| 1537 | meye.grab_buffer[reqnr].state = MEYE_BUF_UNUSED; | ||
| 1538 | mutex_unlock(&meye.lock); | ||
| 1539 | |||
| 1540 | return 0; | ||
| 1541 | } | ||
| 1656 | 1542 | ||
| 1543 | static int vidioc_streamon(struct file *file, void *fh, enum v4l2_buf_type i) | ||
| 1544 | { | ||
| 1545 | mutex_lock(&meye.lock); | ||
| 1546 | |||
| 1547 | switch (meye.mchip_mode) { | ||
| 1548 | case MCHIP_HIC_MODE_CONT_OUT: | ||
| 1549 | mchip_continuous_start(); | ||
| 1550 | break; | ||
| 1551 | case MCHIP_HIC_MODE_CONT_COMP: | ||
| 1552 | mchip_cont_compression_start(); | ||
| 1553 | break; | ||
| 1657 | default: | 1554 | default: |
| 1658 | return -ENOIOCTLCMD; | 1555 | mutex_unlock(&meye.lock); |
| 1556 | return -EINVAL; | ||
| 1659 | } | 1557 | } |
| 1660 | 1558 | ||
| 1559 | mutex_unlock(&meye.lock); | ||
| 1560 | |||
| 1661 | return 0; | 1561 | return 0; |
| 1662 | } | 1562 | } |
| 1663 | 1563 | ||
| 1664 | static int meye_ioctl(struct inode *inode, struct file *file, | 1564 | static int vidioc_streamoff(struct file *file, void *fh, enum v4l2_buf_type i) |
| 1665 | unsigned int cmd, unsigned long arg) | ||
| 1666 | { | 1565 | { |
| 1667 | return video_usercopy(inode, file, cmd, arg, meye_do_ioctl); | 1566 | mutex_lock(&meye.lock); |
| 1567 | mchip_hic_stop(); | ||
| 1568 | kfifo_reset(meye.grabq); | ||
| 1569 | kfifo_reset(meye.doneq); | ||
| 1570 | |||
| 1571 | for (i = 0; i < MEYE_MAX_BUFNBRS; i++) | ||
| 1572 | meye.grab_buffer[i].state = MEYE_BUF_UNUSED; | ||
| 1573 | |||
| 1574 | mutex_unlock(&meye.lock); | ||
| 1575 | return 0; | ||
| 1576 | } | ||
| 1577 | |||
| 1578 | static int vidioc_default(struct file *file, void *fh, int cmd, void *arg) | ||
| 1579 | { | ||
| 1580 | switch (cmd) { | ||
| 1581 | case MEYEIOC_G_PARAMS: | ||
| 1582 | return meyeioc_g_params((struct meye_params *) arg); | ||
| 1583 | |||
| 1584 | case MEYEIOC_S_PARAMS: | ||
| 1585 | return meyeioc_s_params((struct meye_params *) arg); | ||
| 1586 | |||
| 1587 | case MEYEIOC_QBUF_CAPT: | ||
| 1588 | return meyeioc_qbuf_capt((int *) arg); | ||
| 1589 | |||
| 1590 | case MEYEIOC_SYNC: | ||
| 1591 | return meyeioc_sync(file, fh, (int *) arg); | ||
| 1592 | |||
| 1593 | case MEYEIOC_STILLCAPT: | ||
| 1594 | return meyeioc_stillcapt(); | ||
| 1595 | |||
| 1596 | case MEYEIOC_STILLJCAPT: | ||
| 1597 | return meyeioc_stilljcapt((int *) arg); | ||
| 1598 | |||
| 1599 | default: | ||
| 1600 | return -EINVAL; | ||
| 1601 | } | ||
| 1602 | |||
| 1668 | } | 1603 | } |
| 1669 | 1604 | ||
| 1670 | static unsigned int meye_poll(struct file *file, poll_table *wait) | 1605 | static unsigned int meye_poll(struct file *file, poll_table *wait) |
| @@ -1752,8 +1687,10 @@ static const struct file_operations meye_fops = { | |||
| 1752 | .open = meye_open, | 1687 | .open = meye_open, |
| 1753 | .release = meye_release, | 1688 | .release = meye_release, |
| 1754 | .mmap = meye_mmap, | 1689 | .mmap = meye_mmap, |
| 1755 | .ioctl = meye_ioctl, | 1690 | .ioctl = video_ioctl2, |
| 1691 | #ifdef CONFIG_COMPAT | ||
| 1756 | .compat_ioctl = v4l_compat_ioctl32, | 1692 | .compat_ioctl = v4l_compat_ioctl32, |
| 1693 | #endif | ||
| 1757 | .poll = meye_poll, | 1694 | .poll = meye_poll, |
| 1758 | .llseek = no_llseek, | 1695 | .llseek = no_llseek, |
| 1759 | }; | 1696 | }; |
| @@ -1765,6 +1702,24 @@ static struct video_device meye_template = { | |||
| 1765 | .fops = &meye_fops, | 1702 | .fops = &meye_fops, |
| 1766 | .release = video_device_release, | 1703 | .release = video_device_release, |
| 1767 | .minor = -1, | 1704 | .minor = -1, |
| 1705 | .vidioc_querycap = vidioc_querycap, | ||
| 1706 | .vidioc_enum_input = vidioc_enum_input, | ||
| 1707 | .vidioc_g_input = vidioc_g_input, | ||
| 1708 | .vidioc_s_input = vidioc_s_input, | ||
| 1709 | .vidioc_queryctrl = vidioc_queryctrl, | ||
| 1710 | .vidioc_s_ctrl = vidioc_s_ctrl, | ||
| 1711 | .vidioc_g_ctrl = vidioc_g_ctrl, | ||
| 1712 | .vidioc_enum_fmt_cap = vidioc_enum_fmt_cap, | ||
| 1713 | .vidioc_try_fmt_cap = vidioc_try_fmt_cap, | ||
| 1714 | .vidioc_g_fmt_cap = vidioc_g_fmt_cap, | ||
| 1715 | .vidioc_s_fmt_cap = vidioc_s_fmt_cap, | ||
| 1716 | .vidioc_reqbufs = vidioc_reqbufs, | ||
| 1717 | .vidioc_querybuf = vidioc_querybuf, | ||
| 1718 | .vidioc_qbuf = vidioc_qbuf, | ||
| 1719 | .vidioc_dqbuf = vidioc_dqbuf, | ||
| 1720 | .vidioc_streamon = vidioc_streamon, | ||
| 1721 | .vidioc_streamoff = vidioc_streamoff, | ||
| 1722 | .vidioc_default = vidioc_default, | ||
| 1768 | }; | 1723 | }; |
| 1769 | 1724 | ||
| 1770 | #ifdef CONFIG_PM | 1725 | #ifdef CONFIG_PM |
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c index 7a11f3159e32..b73c740f7fb2 100644 --- a/drivers/media/video/msp3400-driver.c +++ b/drivers/media/video/msp3400-driver.c | |||
| @@ -366,7 +366,7 @@ int msp_sleep(struct msp_state *state, int timeout) | |||
| 366 | } | 366 | } |
| 367 | 367 | ||
| 368 | /* ------------------------------------------------------------------------ */ | 368 | /* ------------------------------------------------------------------------ */ |
| 369 | #ifdef CONFIG_VIDEO_V4L1 | 369 | #ifdef CONFIG_VIDEO_ALLOW_V4L1 |
| 370 | static int msp_mode_v4l2_to_v4l1(int rxsubchans, int audmode) | 370 | static int msp_mode_v4l2_to_v4l1(int rxsubchans, int audmode) |
| 371 | { | 371 | { |
| 372 | if (rxsubchans == V4L2_TUNER_SUB_MONO) | 372 | if (rxsubchans == V4L2_TUNER_SUB_MONO) |
| @@ -514,7 +514,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
| 514 | /* --- v4l ioctls --- */ | 514 | /* --- v4l ioctls --- */ |
| 515 | /* take care: bttv does userspace copying, we'll get a | 515 | /* take care: bttv does userspace copying, we'll get a |
| 516 | kernel pointer here... */ | 516 | kernel pointer here... */ |
| 517 | #ifdef CONFIG_VIDEO_V4L1 | 517 | #ifdef CONFIG_VIDEO_ALLOW_V4L1 |
| 518 | case VIDIOCGAUDIO: | 518 | case VIDIOCGAUDIO: |
| 519 | { | 519 | { |
| 520 | struct video_audio *va = arg; | 520 | struct video_audio *va = arg; |
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c index 61ec794a737e..7f5568592793 100644 --- a/drivers/media/video/msp3400-kthreads.c +++ b/drivers/media/video/msp3400-kthreads.c | |||
| @@ -833,11 +833,6 @@ static int msp34xxg_modus(struct i2c_client *client) | |||
| 833 | v4l_dbg(1, msp_debug, client, "selected radio modus\n"); | 833 | v4l_dbg(1, msp_debug, client, "selected radio modus\n"); |
| 834 | return 0x0001; | 834 | return 0x0001; |
| 835 | } | 835 | } |
| 836 | |||
| 837 | if (state->v4l2_std & V4L2_STD_PAL) { | ||
| 838 | v4l_dbg(1, msp_debug, client, "selected PAL modus\n"); | ||
| 839 | return 0x7001; | ||
| 840 | } | ||
| 841 | if (state->v4l2_std == V4L2_STD_NTSC_M_JP) { | 836 | if (state->v4l2_std == V4L2_STD_NTSC_M_JP) { |
| 842 | v4l_dbg(1, msp_debug, client, "selected M (EIA-J) modus\n"); | 837 | v4l_dbg(1, msp_debug, client, "selected M (EIA-J) modus\n"); |
| 843 | return 0x4001; | 838 | return 0x4001; |
| @@ -846,15 +841,15 @@ static int msp34xxg_modus(struct i2c_client *client) | |||
| 846 | v4l_dbg(1, msp_debug, client, "selected M (A2) modus\n"); | 841 | v4l_dbg(1, msp_debug, client, "selected M (A2) modus\n"); |
| 847 | return 0x0001; | 842 | return 0x0001; |
| 848 | } | 843 | } |
| 844 | if (state->v4l2_std == V4L2_STD_SECAM_L) { | ||
| 845 | v4l_dbg(1, msp_debug, client, "selected SECAM-L modus\n"); | ||
| 846 | return 0x6001; | ||
| 847 | } | ||
| 849 | if (state->v4l2_std & V4L2_STD_MN) { | 848 | if (state->v4l2_std & V4L2_STD_MN) { |
| 850 | v4l_dbg(1, msp_debug, client, "selected M (BTSC) modus\n"); | 849 | v4l_dbg(1, msp_debug, client, "selected M (BTSC) modus\n"); |
| 851 | return 0x2001; | 850 | return 0x2001; |
| 852 | } | 851 | } |
| 853 | if (state->v4l2_std & V4L2_STD_SECAM) { | 852 | return 0x7001; |
| 854 | v4l_dbg(1, msp_debug, client, "selected SECAM modus\n"); | ||
| 855 | return 0x6001; | ||
| 856 | } | ||
| 857 | return 0x0001; | ||
| 858 | } | 853 | } |
| 859 | 854 | ||
| 860 | static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in) | 855 | static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in) |
diff --git a/drivers/media/video/mt20xx.c b/drivers/media/video/mt20xx.c index 74fd6a01d4c4..fbcb28233737 100644 --- a/drivers/media/video/mt20xx.c +++ b/drivers/media/video/mt20xx.c | |||
| @@ -10,12 +10,10 @@ | |||
| 10 | #include "tuner-i2c.h" | 10 | #include "tuner-i2c.h" |
| 11 | #include "mt20xx.h" | 11 | #include "mt20xx.h" |
| 12 | 12 | ||
| 13 | static int debug = 0; | 13 | static int debug; |
| 14 | module_param(debug, int, 0644); | 14 | module_param(debug, int, 0644); |
| 15 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 15 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 16 | 16 | ||
| 17 | #define PREFIX "mt20xx" | ||
| 18 | |||
| 19 | /* ---------------------------------------------------------------------- */ | 17 | /* ---------------------------------------------------------------------- */ |
| 20 | 18 | ||
| 21 | static unsigned int optimize_vco = 1; | 19 | static unsigned int optimize_vco = 1; |
| @@ -24,7 +22,7 @@ module_param(optimize_vco, int, 0644); | |||
| 24 | static unsigned int tv_antenna = 1; | 22 | static unsigned int tv_antenna = 1; |
| 25 | module_param(tv_antenna, int, 0644); | 23 | module_param(tv_antenna, int, 0644); |
| 26 | 24 | ||
| 27 | static unsigned int radio_antenna = 0; | 25 | static unsigned int radio_antenna; |
| 28 | module_param(radio_antenna, int, 0644); | 26 | module_param(radio_antenna, int, 0644); |
| 29 | 27 | ||
| 30 | /* ---------------------------------------------------------------------- */ | 28 | /* ---------------------------------------------------------------------- */ |
| @@ -611,6 +609,7 @@ struct dvb_frontend *microtune_attach(struct dvb_frontend *fe, | |||
| 611 | 609 | ||
| 612 | priv->i2c_props.addr = i2c_addr; | 610 | priv->i2c_props.addr = i2c_addr; |
| 613 | priv->i2c_props.adap = i2c_adap; | 611 | priv->i2c_props.adap = i2c_adap; |
| 612 | priv->i2c_props.name = "mt20xx"; | ||
| 614 | 613 | ||
| 615 | //priv->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */ | 614 | //priv->radio_if2 = 10700 * 1000; /* 10.7MHz - FM radio */ |
| 616 | 615 | ||
diff --git a/drivers/media/video/mt20xx.h b/drivers/media/video/mt20xx.h index 5e9c825d2e91..aa848e14ce5e 100644 --- a/drivers/media/video/mt20xx.h +++ b/drivers/media/video/mt20xx.h | |||
| @@ -29,7 +29,7 @@ static inline struct dvb_frontend *microtune_attach(struct dvb_frontend *fe, | |||
| 29 | struct i2c_adapter* i2c_adap, | 29 | struct i2c_adapter* i2c_adap, |
| 30 | u8 i2c_addr) | 30 | u8 i2c_addr) |
| 31 | { | 31 | { |
| 32 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 32 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 33 | return NULL; | 33 | return NULL; |
| 34 | } | 34 | } |
| 35 | #endif | 35 | #endif |
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c new file mode 100644 index 000000000000..3fb5f63df1e6 --- /dev/null +++ b/drivers/media/video/mt9m001.c | |||
| @@ -0,0 +1,722 @@ | |||
| 1 | /* | ||
| 2 | * Driver for MT9M001 CMOS Image Sensor from Micron | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 as | ||
| 8 | * published by the Free Software Foundation. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #include <linux/videodev2.h> | ||
| 12 | #include <linux/slab.h> | ||
| 13 | #include <linux/i2c.h> | ||
| 14 | #include <linux/log2.h> | ||
| 15 | |||
| 16 | #include <media/v4l2-common.h> | ||
| 17 | #include <media/v4l2-chip-ident.h> | ||
| 18 | #include <media/soc_camera.h> | ||
| 19 | |||
| 20 | #ifdef CONFIG_MT9M001_PCA9536_SWITCH | ||
| 21 | #include <asm/gpio.h> | ||
| 22 | #endif | ||
| 23 | |||
| 24 | /* mt9m001 i2c address 0x5d | ||
| 25 | * The platform has to define i2c_board_info | ||
| 26 | * and call i2c_register_board_info() */ | ||
| 27 | |||
| 28 | /* mt9m001 selected register addresses */ | ||
| 29 | #define MT9M001_CHIP_VERSION 0x00 | ||
| 30 | #define MT9M001_ROW_START 0x01 | ||
| 31 | #define MT9M001_COLUMN_START 0x02 | ||
| 32 | #define MT9M001_WINDOW_HEIGHT 0x03 | ||
| 33 | #define MT9M001_WINDOW_WIDTH 0x04 | ||
| 34 | #define MT9M001_HORIZONTAL_BLANKING 0x05 | ||
| 35 | #define MT9M001_VERTICAL_BLANKING 0x06 | ||
| 36 | #define MT9M001_OUTPUT_CONTROL 0x07 | ||
| 37 | #define MT9M001_SHUTTER_WIDTH 0x09 | ||
| 38 | #define MT9M001_FRAME_RESTART 0x0b | ||
| 39 | #define MT9M001_SHUTTER_DELAY 0x0c | ||
| 40 | #define MT9M001_RESET 0x0d | ||
| 41 | #define MT9M001_READ_OPTIONS1 0x1e | ||
| 42 | #define MT9M001_READ_OPTIONS2 0x20 | ||
| 43 | #define MT9M001_GLOBAL_GAIN 0x35 | ||
| 44 | #define MT9M001_CHIP_ENABLE 0xF1 | ||
| 45 | |||
| 46 | static const struct soc_camera_data_format mt9m001_colour_formats[] = { | ||
| 47 | /* Order important: first natively supported, | ||
| 48 | * second supported with a GPIO extender */ | ||
| 49 | { | ||
| 50 | .name = "Bayer (sRGB) 10 bit", | ||
| 51 | .depth = 10, | ||
| 52 | .fourcc = V4L2_PIX_FMT_SBGGR16, | ||
| 53 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
| 54 | }, { | ||
| 55 | .name = "Bayer (sRGB) 8 bit", | ||
| 56 | .depth = 8, | ||
| 57 | .fourcc = V4L2_PIX_FMT_SBGGR8, | ||
| 58 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
| 59 | } | ||
| 60 | }; | ||
| 61 | |||
| 62 | static const struct soc_camera_data_format mt9m001_monochrome_formats[] = { | ||
| 63 | /* Order important - see above */ | ||
| 64 | { | ||
| 65 | .name = "Monochrome 10 bit", | ||
| 66 | .depth = 10, | ||
| 67 | .fourcc = V4L2_PIX_FMT_Y16, | ||
| 68 | }, { | ||
| 69 | .name = "Monochrome 8 bit", | ||
| 70 | .depth = 8, | ||
| 71 | .fourcc = V4L2_PIX_FMT_GREY, | ||
| 72 | }, | ||
| 73 | }; | ||
| 74 | |||
| 75 | struct mt9m001 { | ||
| 76 | struct i2c_client *client; | ||
| 77 | struct soc_camera_device icd; | ||
| 78 | int model; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */ | ||
| 79 | int switch_gpio; | ||
| 80 | unsigned char autoexposure; | ||
| 81 | unsigned char datawidth; | ||
| 82 | }; | ||
| 83 | |||
| 84 | static int reg_read(struct soc_camera_device *icd, const u8 reg) | ||
| 85 | { | ||
| 86 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 87 | struct i2c_client *client = mt9m001->client; | ||
| 88 | s32 data = i2c_smbus_read_word_data(client, reg); | ||
| 89 | return data < 0 ? data : swab16(data); | ||
| 90 | } | ||
| 91 | |||
| 92 | static int reg_write(struct soc_camera_device *icd, const u8 reg, | ||
| 93 | const u16 data) | ||
| 94 | { | ||
| 95 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 96 | return i2c_smbus_write_word_data(mt9m001->client, reg, swab16(data)); | ||
| 97 | } | ||
| 98 | |||
| 99 | static int reg_set(struct soc_camera_device *icd, const u8 reg, | ||
| 100 | const u16 data) | ||
| 101 | { | ||
| 102 | int ret; | ||
| 103 | |||
| 104 | ret = reg_read(icd, reg); | ||
| 105 | if (ret < 0) | ||
| 106 | return ret; | ||
| 107 | return reg_write(icd, reg, ret | data); | ||
| 108 | } | ||
| 109 | |||
| 110 | static int reg_clear(struct soc_camera_device *icd, const u8 reg, | ||
| 111 | const u16 data) | ||
| 112 | { | ||
| 113 | int ret; | ||
| 114 | |||
| 115 | ret = reg_read(icd, reg); | ||
| 116 | if (ret < 0) | ||
| 117 | return ret; | ||
| 118 | return reg_write(icd, reg, ret & ~data); | ||
| 119 | } | ||
| 120 | |||
| 121 | static int mt9m001_init(struct soc_camera_device *icd) | ||
| 122 | { | ||
| 123 | int ret; | ||
| 124 | |||
| 125 | /* Disable chip, synchronous option update */ | ||
| 126 | dev_dbg(icd->vdev->dev, "%s\n", __func__); | ||
| 127 | |||
| 128 | ret = reg_write(icd, MT9M001_RESET, 1); | ||
| 129 | if (ret >= 0) | ||
| 130 | ret = reg_write(icd, MT9M001_RESET, 0); | ||
| 131 | if (ret >= 0) | ||
| 132 | ret = reg_write(icd, MT9M001_OUTPUT_CONTROL, 0); | ||
| 133 | |||
| 134 | return ret >= 0 ? 0 : -EIO; | ||
| 135 | } | ||
| 136 | |||
| 137 | static int mt9m001_release(struct soc_camera_device *icd) | ||
| 138 | { | ||
| 139 | /* Disable the chip */ | ||
| 140 | reg_write(icd, MT9M001_OUTPUT_CONTROL, 0); | ||
| 141 | return 0; | ||
| 142 | } | ||
| 143 | |||
| 144 | static int mt9m001_start_capture(struct soc_camera_device *icd) | ||
| 145 | { | ||
| 146 | /* Switch to master "normal" mode */ | ||
| 147 | if (reg_write(icd, MT9M001_OUTPUT_CONTROL, 2) < 0) | ||
| 148 | return -EIO; | ||
| 149 | return 0; | ||
| 150 | } | ||
| 151 | |||
| 152 | static int mt9m001_stop_capture(struct soc_camera_device *icd) | ||
| 153 | { | ||
| 154 | /* Stop sensor readout */ | ||
| 155 | if (reg_write(icd, MT9M001_OUTPUT_CONTROL, 0) < 0) | ||
| 156 | return -EIO; | ||
| 157 | return 0; | ||
| 158 | } | ||
| 159 | |||
| 160 | static int bus_switch_request(struct mt9m001 *mt9m001, | ||
| 161 | struct soc_camera_link *icl) | ||
| 162 | { | ||
| 163 | #ifdef CONFIG_MT9M001_PCA9536_SWITCH | ||
| 164 | int ret; | ||
| 165 | unsigned int gpio = icl->gpio; | ||
| 166 | |||
| 167 | if (gpio_is_valid(gpio)) { | ||
| 168 | /* We have a data bus switch. */ | ||
| 169 | ret = gpio_request(gpio, "mt9m001"); | ||
| 170 | if (ret < 0) { | ||
| 171 | dev_err(&mt9m001->client->dev, "Cannot get GPIO %u\n", | ||
| 172 | gpio); | ||
| 173 | return ret; | ||
| 174 | } | ||
| 175 | |||
| 176 | ret = gpio_direction_output(gpio, 0); | ||
| 177 | if (ret < 0) { | ||
| 178 | dev_err(&mt9m001->client->dev, | ||
| 179 | "Cannot set GPIO %u to output\n", gpio); | ||
| 180 | gpio_free(gpio); | ||
| 181 | return ret; | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 185 | mt9m001->switch_gpio = gpio; | ||
| 186 | #else | ||
| 187 | mt9m001->switch_gpio = -EINVAL; | ||
| 188 | #endif | ||
| 189 | return 0; | ||
| 190 | } | ||
| 191 | |||
| 192 | static void bus_switch_release(struct mt9m001 *mt9m001) | ||
| 193 | { | ||
| 194 | #ifdef CONFIG_MT9M001_PCA9536_SWITCH | ||
| 195 | if (gpio_is_valid(mt9m001->switch_gpio)) | ||
| 196 | gpio_free(mt9m001->switch_gpio); | ||
| 197 | #endif | ||
| 198 | } | ||
| 199 | |||
| 200 | static int bus_switch_act(struct mt9m001 *mt9m001, int go8bit) | ||
| 201 | { | ||
| 202 | #ifdef CONFIG_MT9M001_PCA9536_SWITCH | ||
| 203 | if (!gpio_is_valid(mt9m001->switch_gpio)) | ||
| 204 | return -ENODEV; | ||
| 205 | |||
| 206 | gpio_set_value_cansleep(mt9m001->switch_gpio, go8bit); | ||
| 207 | return 0; | ||
| 208 | #else | ||
| 209 | return -ENODEV; | ||
| 210 | #endif | ||
| 211 | } | ||
| 212 | |||
| 213 | static int bus_switch_possible(struct mt9m001 *mt9m001) | ||
| 214 | { | ||
| 215 | #ifdef CONFIG_MT9M001_PCA9536_SWITCH | ||
| 216 | return gpio_is_valid(mt9m001->switch_gpio); | ||
| 217 | #else | ||
| 218 | return 0; | ||
| 219 | #endif | ||
| 220 | } | ||
| 221 | |||
| 222 | static int mt9m001_set_bus_param(struct soc_camera_device *icd, | ||
| 223 | unsigned long flags) | ||
| 224 | { | ||
| 225 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 226 | unsigned int width_flag = flags & SOCAM_DATAWIDTH_MASK; | ||
| 227 | int ret; | ||
| 228 | |||
| 229 | /* Flags validity verified in test_bus_param */ | ||
| 230 | |||
| 231 | if ((mt9m001->datawidth != 10 && (width_flag == SOCAM_DATAWIDTH_10)) || | ||
| 232 | (mt9m001->datawidth != 9 && (width_flag == SOCAM_DATAWIDTH_9)) || | ||
| 233 | (mt9m001->datawidth != 8 && (width_flag == SOCAM_DATAWIDTH_8))) { | ||
| 234 | /* Well, we actually only can do 10 or 8 bits... */ | ||
| 235 | if (width_flag == SOCAM_DATAWIDTH_9) | ||
| 236 | return -EINVAL; | ||
| 237 | ret = bus_switch_act(mt9m001, | ||
| 238 | width_flag == SOCAM_DATAWIDTH_8); | ||
| 239 | if (ret < 0) | ||
| 240 | return ret; | ||
| 241 | |||
| 242 | mt9m001->datawidth = width_flag == SOCAM_DATAWIDTH_8 ? 8 : 10; | ||
| 243 | } | ||
| 244 | |||
| 245 | return 0; | ||
| 246 | } | ||
| 247 | |||
| 248 | static unsigned long mt9m001_query_bus_param(struct soc_camera_device *icd) | ||
| 249 | { | ||
| 250 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 251 | unsigned int width_flag = SOCAM_DATAWIDTH_10; | ||
| 252 | |||
| 253 | if (bus_switch_possible(mt9m001)) | ||
| 254 | width_flag |= SOCAM_DATAWIDTH_8; | ||
| 255 | |||
| 256 | /* MT9M001 has all capture_format parameters fixed */ | ||
| 257 | return SOCAM_PCLK_SAMPLE_RISING | | ||
| 258 | SOCAM_HSYNC_ACTIVE_HIGH | | ||
| 259 | SOCAM_VSYNC_ACTIVE_HIGH | | ||
| 260 | SOCAM_MASTER | | ||
| 261 | width_flag; | ||
| 262 | } | ||
| 263 | |||
| 264 | static int mt9m001_set_fmt_cap(struct soc_camera_device *icd, | ||
| 265 | __u32 pixfmt, struct v4l2_rect *rect) | ||
| 266 | { | ||
| 267 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 268 | int ret; | ||
| 269 | const u16 hblank = 9, vblank = 25; | ||
| 270 | |||
| 271 | /* Blanking and start values - default... */ | ||
| 272 | ret = reg_write(icd, MT9M001_HORIZONTAL_BLANKING, hblank); | ||
| 273 | if (ret >= 0) | ||
| 274 | ret = reg_write(icd, MT9M001_VERTICAL_BLANKING, vblank); | ||
| 275 | |||
| 276 | /* The caller provides a supported format, as verified per | ||
| 277 | * call to icd->try_fmt_cap() */ | ||
| 278 | if (ret >= 0) | ||
| 279 | ret = reg_write(icd, MT9M001_COLUMN_START, rect->left); | ||
| 280 | if (ret >= 0) | ||
| 281 | ret = reg_write(icd, MT9M001_ROW_START, rect->top); | ||
| 282 | if (ret >= 0) | ||
| 283 | ret = reg_write(icd, MT9M001_WINDOW_WIDTH, rect->width - 1); | ||
| 284 | if (ret >= 0) | ||
| 285 | ret = reg_write(icd, MT9M001_WINDOW_HEIGHT, | ||
| 286 | rect->height + icd->y_skip_top - 1); | ||
| 287 | if (ret >= 0 && mt9m001->autoexposure) { | ||
| 288 | ret = reg_write(icd, MT9M001_SHUTTER_WIDTH, | ||
| 289 | rect->height + icd->y_skip_top + vblank); | ||
| 290 | if (ret >= 0) { | ||
| 291 | const struct v4l2_queryctrl *qctrl = | ||
| 292 | soc_camera_find_qctrl(icd->ops, | ||
| 293 | V4L2_CID_EXPOSURE); | ||
| 294 | icd->exposure = (524 + (rect->height + icd->y_skip_top + | ||
| 295 | vblank - 1) * | ||
| 296 | (qctrl->maximum - qctrl->minimum)) / | ||
| 297 | 1048 + qctrl->minimum; | ||
| 298 | } | ||
| 299 | } | ||
| 300 | |||
| 301 | return ret < 0 ? ret : 0; | ||
| 302 | } | ||
| 303 | |||
| 304 | static int mt9m001_try_fmt_cap(struct soc_camera_device *icd, | ||
| 305 | struct v4l2_format *f) | ||
| 306 | { | ||
| 307 | if (f->fmt.pix.height < 32 + icd->y_skip_top) | ||
| 308 | f->fmt.pix.height = 32 + icd->y_skip_top; | ||
| 309 | if (f->fmt.pix.height > 1024 + icd->y_skip_top) | ||
| 310 | f->fmt.pix.height = 1024 + icd->y_skip_top; | ||
| 311 | if (f->fmt.pix.width < 48) | ||
| 312 | f->fmt.pix.width = 48; | ||
| 313 | if (f->fmt.pix.width > 1280) | ||
| 314 | f->fmt.pix.width = 1280; | ||
| 315 | f->fmt.pix.width &= ~0x01; /* has to be even, unsure why was ~3 */ | ||
| 316 | |||
| 317 | return 0; | ||
| 318 | } | ||
| 319 | |||
| 320 | static int mt9m001_get_chip_id(struct soc_camera_device *icd, | ||
| 321 | struct v4l2_chip_ident *id) | ||
| 322 | { | ||
| 323 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 324 | |||
| 325 | if (id->match_type != V4L2_CHIP_MATCH_I2C_ADDR) | ||
| 326 | return -EINVAL; | ||
| 327 | |||
| 328 | if (id->match_chip != mt9m001->client->addr) | ||
| 329 | return -ENODEV; | ||
| 330 | |||
| 331 | id->ident = mt9m001->model; | ||
| 332 | id->revision = 0; | ||
| 333 | |||
| 334 | return 0; | ||
| 335 | } | ||
| 336 | |||
| 337 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
| 338 | static int mt9m001_get_register(struct soc_camera_device *icd, | ||
| 339 | struct v4l2_register *reg) | ||
| 340 | { | ||
| 341 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 342 | |||
| 343 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) | ||
| 344 | return -EINVAL; | ||
| 345 | |||
| 346 | if (reg->match_chip != mt9m001->client->addr) | ||
| 347 | return -ENODEV; | ||
| 348 | |||
| 349 | reg->val = reg_read(icd, reg->reg); | ||
| 350 | |||
| 351 | if (reg->val > 0xffff) | ||
| 352 | return -EIO; | ||
| 353 | |||
| 354 | return 0; | ||
| 355 | } | ||
| 356 | |||
| 357 | static int mt9m001_set_register(struct soc_camera_device *icd, | ||
| 358 | struct v4l2_register *reg) | ||
| 359 | { | ||
| 360 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 361 | |||
| 362 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) | ||
| 363 | return -EINVAL; | ||
| 364 | |||
| 365 | if (reg->match_chip != mt9m001->client->addr) | ||
| 366 | return -ENODEV; | ||
| 367 | |||
| 368 | if (reg_write(icd, reg->reg, reg->val) < 0) | ||
| 369 | return -EIO; | ||
| 370 | |||
| 371 | return 0; | ||
| 372 | } | ||
| 373 | #endif | ||
| 374 | |||
| 375 | const struct v4l2_queryctrl mt9m001_controls[] = { | ||
| 376 | { | ||
| 377 | .id = V4L2_CID_VFLIP, | ||
| 378 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
| 379 | .name = "Flip Vertically", | ||
| 380 | .minimum = 0, | ||
| 381 | .maximum = 1, | ||
| 382 | .step = 1, | ||
| 383 | .default_value = 0, | ||
| 384 | }, { | ||
| 385 | .id = V4L2_CID_GAIN, | ||
| 386 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 387 | .name = "Gain", | ||
| 388 | .minimum = 0, | ||
| 389 | .maximum = 127, | ||
| 390 | .step = 1, | ||
| 391 | .default_value = 64, | ||
| 392 | .flags = V4L2_CTRL_FLAG_SLIDER, | ||
| 393 | }, { | ||
| 394 | .id = V4L2_CID_EXPOSURE, | ||
| 395 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 396 | .name = "Exposure", | ||
| 397 | .minimum = 1, | ||
| 398 | .maximum = 255, | ||
| 399 | .step = 1, | ||
| 400 | .default_value = 255, | ||
| 401 | .flags = V4L2_CTRL_FLAG_SLIDER, | ||
| 402 | }, { | ||
| 403 | .id = V4L2_CID_EXPOSURE_AUTO, | ||
| 404 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
| 405 | .name = "Automatic Exposure", | ||
| 406 | .minimum = 0, | ||
| 407 | .maximum = 1, | ||
| 408 | .step = 1, | ||
| 409 | .default_value = 1, | ||
| 410 | } | ||
| 411 | }; | ||
| 412 | |||
| 413 | static int mt9m001_video_probe(struct soc_camera_device *); | ||
| 414 | static void mt9m001_video_remove(struct soc_camera_device *); | ||
| 415 | static int mt9m001_get_control(struct soc_camera_device *, struct v4l2_control *); | ||
| 416 | static int mt9m001_set_control(struct soc_camera_device *, struct v4l2_control *); | ||
| 417 | |||
| 418 | static struct soc_camera_ops mt9m001_ops = { | ||
| 419 | .owner = THIS_MODULE, | ||
| 420 | .probe = mt9m001_video_probe, | ||
| 421 | .remove = mt9m001_video_remove, | ||
| 422 | .init = mt9m001_init, | ||
| 423 | .release = mt9m001_release, | ||
| 424 | .start_capture = mt9m001_start_capture, | ||
| 425 | .stop_capture = mt9m001_stop_capture, | ||
| 426 | .set_fmt_cap = mt9m001_set_fmt_cap, | ||
| 427 | .try_fmt_cap = mt9m001_try_fmt_cap, | ||
| 428 | .set_bus_param = mt9m001_set_bus_param, | ||
| 429 | .query_bus_param = mt9m001_query_bus_param, | ||
| 430 | .controls = mt9m001_controls, | ||
| 431 | .num_controls = ARRAY_SIZE(mt9m001_controls), | ||
| 432 | .get_control = mt9m001_get_control, | ||
| 433 | .set_control = mt9m001_set_control, | ||
| 434 | .get_chip_id = mt9m001_get_chip_id, | ||
| 435 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
| 436 | .get_register = mt9m001_get_register, | ||
| 437 | .set_register = mt9m001_set_register, | ||
| 438 | #endif | ||
| 439 | }; | ||
| 440 | |||
| 441 | static int mt9m001_get_control(struct soc_camera_device *icd, struct v4l2_control *ctrl) | ||
| 442 | { | ||
| 443 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 444 | int data; | ||
| 445 | |||
| 446 | switch (ctrl->id) { | ||
| 447 | case V4L2_CID_VFLIP: | ||
| 448 | data = reg_read(icd, MT9M001_READ_OPTIONS2); | ||
| 449 | if (data < 0) | ||
| 450 | return -EIO; | ||
| 451 | ctrl->value = !!(data & 0x8000); | ||
| 452 | break; | ||
| 453 | case V4L2_CID_EXPOSURE_AUTO: | ||
| 454 | ctrl->value = mt9m001->autoexposure; | ||
| 455 | break; | ||
| 456 | } | ||
| 457 | return 0; | ||
| 458 | } | ||
| 459 | |||
| 460 | static int mt9m001_set_control(struct soc_camera_device *icd, struct v4l2_control *ctrl) | ||
| 461 | { | ||
| 462 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 463 | const struct v4l2_queryctrl *qctrl; | ||
| 464 | int data; | ||
| 465 | |||
| 466 | qctrl = soc_camera_find_qctrl(&mt9m001_ops, ctrl->id); | ||
| 467 | |||
| 468 | if (!qctrl) | ||
| 469 | return -EINVAL; | ||
| 470 | |||
| 471 | switch (ctrl->id) { | ||
| 472 | case V4L2_CID_VFLIP: | ||
| 473 | if (ctrl->value) | ||
| 474 | data = reg_set(icd, MT9M001_READ_OPTIONS2, 0x8000); | ||
| 475 | else | ||
| 476 | data = reg_clear(icd, MT9M001_READ_OPTIONS2, 0x8000); | ||
| 477 | if (data < 0) | ||
| 478 | return -EIO; | ||
| 479 | break; | ||
| 480 | case V4L2_CID_GAIN: | ||
| 481 | if (ctrl->value > qctrl->maximum || ctrl->value < qctrl->minimum) | ||
| 482 | return -EINVAL; | ||
| 483 | /* See Datasheet Table 7, Gain settings. */ | ||
| 484 | if (ctrl->value <= qctrl->default_value) { | ||
| 485 | /* Pack it into 0..1 step 0.125, register values 0..8 */ | ||
| 486 | unsigned long range = qctrl->default_value - qctrl->minimum; | ||
| 487 | data = ((ctrl->value - qctrl->minimum) * 8 + range / 2) / range; | ||
| 488 | |||
| 489 | dev_dbg(&icd->dev, "Setting gain %d\n", data); | ||
| 490 | data = reg_write(icd, MT9M001_GLOBAL_GAIN, data); | ||
| 491 | if (data < 0) | ||
| 492 | return -EIO; | ||
| 493 | } else { | ||
| 494 | /* Pack it into 1.125..15 variable step, register values 9..67 */ | ||
| 495 | /* We assume qctrl->maximum - qctrl->default_value - 1 > 0 */ | ||
| 496 | unsigned long range = qctrl->maximum - qctrl->default_value - 1; | ||
| 497 | unsigned long gain = ((ctrl->value - qctrl->default_value - 1) * | ||
| 498 | 111 + range / 2) / range + 9; | ||
| 499 | |||
| 500 | if (gain <= 32) | ||
| 501 | data = gain; | ||
| 502 | else if (gain <= 64) | ||
| 503 | data = ((gain - 32) * 16 + 16) / 32 + 80; | ||
| 504 | else | ||
| 505 | data = ((gain - 64) * 7 + 28) / 56 + 96; | ||
| 506 | |||
| 507 | dev_dbg(&icd->dev, "Setting gain from %d to %d\n", | ||
| 508 | reg_read(icd, MT9M001_GLOBAL_GAIN), data); | ||
| 509 | data = reg_write(icd, MT9M001_GLOBAL_GAIN, data); | ||
| 510 | if (data < 0) | ||
| 511 | return -EIO; | ||
| 512 | } | ||
| 513 | |||
| 514 | /* Success */ | ||
| 515 | icd->gain = ctrl->value; | ||
| 516 | break; | ||
| 517 | case V4L2_CID_EXPOSURE: | ||
| 518 | /* mt9m001 has maximum == default */ | ||
| 519 | if (ctrl->value > qctrl->maximum || ctrl->value < qctrl->minimum) | ||
| 520 | return -EINVAL; | ||
| 521 | else { | ||
| 522 | unsigned long range = qctrl->maximum - qctrl->minimum; | ||
| 523 | unsigned long shutter = ((ctrl->value - qctrl->minimum) * 1048 + | ||
| 524 | range / 2) / range + 1; | ||
| 525 | |||
| 526 | dev_dbg(&icd->dev, "Setting shutter width from %d to %lu\n", | ||
| 527 | reg_read(icd, MT9M001_SHUTTER_WIDTH), shutter); | ||
| 528 | if (reg_write(icd, MT9M001_SHUTTER_WIDTH, shutter) < 0) | ||
| 529 | return -EIO; | ||
| 530 | icd->exposure = ctrl->value; | ||
| 531 | mt9m001->autoexposure = 0; | ||
| 532 | } | ||
| 533 | break; | ||
| 534 | case V4L2_CID_EXPOSURE_AUTO: | ||
| 535 | if (ctrl->value) { | ||
| 536 | const u16 vblank = 25; | ||
| 537 | if (reg_write(icd, MT9M001_SHUTTER_WIDTH, icd->height + | ||
| 538 | icd->y_skip_top + vblank) < 0) | ||
| 539 | return -EIO; | ||
| 540 | qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE); | ||
| 541 | icd->exposure = (524 + (icd->height + icd->y_skip_top + vblank - 1) * | ||
| 542 | (qctrl->maximum - qctrl->minimum)) / | ||
| 543 | 1048 + qctrl->minimum; | ||
| 544 | mt9m001->autoexposure = 1; | ||
| 545 | } else | ||
| 546 | mt9m001->autoexposure = 0; | ||
| 547 | break; | ||
| 548 | } | ||
| 549 | return 0; | ||
| 550 | } | ||
| 551 | |||
| 552 | /* Interface active, can use i2c. If it fails, it can indeed mean, that | ||
| 553 | * this wasn't our capture interface, so, we wait for the right one */ | ||
| 554 | static int mt9m001_video_probe(struct soc_camera_device *icd) | ||
| 555 | { | ||
| 556 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 557 | s32 data; | ||
| 558 | int ret; | ||
| 559 | |||
| 560 | /* We must have a parent by now. And it cannot be a wrong one. | ||
| 561 | * So this entire test is completely redundant. */ | ||
| 562 | if (!icd->dev.parent || | ||
| 563 | to_soc_camera_host(icd->dev.parent)->nr != icd->iface) | ||
| 564 | return -ENODEV; | ||
| 565 | |||
| 566 | /* Enable the chip */ | ||
| 567 | data = reg_write(&mt9m001->icd, MT9M001_CHIP_ENABLE, 1); | ||
| 568 | dev_dbg(&icd->dev, "write: %d\n", data); | ||
| 569 | |||
| 570 | /* Read out the chip version register */ | ||
| 571 | data = reg_read(icd, MT9M001_CHIP_VERSION); | ||
| 572 | |||
| 573 | /* must be 0x8411 or 0x8421 for colour sensor and 8431 for bw */ | ||
| 574 | switch (data) { | ||
| 575 | case 0x8411: | ||
| 576 | case 0x8421: | ||
| 577 | mt9m001->model = V4L2_IDENT_MT9M001C12ST; | ||
| 578 | icd->formats = mt9m001_colour_formats; | ||
| 579 | if (mt9m001->client->dev.platform_data) | ||
| 580 | icd->num_formats = ARRAY_SIZE(mt9m001_colour_formats); | ||
| 581 | else | ||
| 582 | icd->num_formats = 1; | ||
| 583 | break; | ||
| 584 | case 0x8431: | ||
| 585 | mt9m001->model = V4L2_IDENT_MT9M001C12STM; | ||
| 586 | icd->formats = mt9m001_monochrome_formats; | ||
| 587 | if (mt9m001->client->dev.platform_data) | ||
| 588 | icd->num_formats = ARRAY_SIZE(mt9m001_monochrome_formats); | ||
| 589 | else | ||
| 590 | icd->num_formats = 1; | ||
| 591 | break; | ||
| 592 | default: | ||
| 593 | ret = -ENODEV; | ||
| 594 | dev_err(&icd->dev, | ||
| 595 | "No MT9M001 chip detected, register read %x\n", data); | ||
| 596 | goto ei2c; | ||
| 597 | } | ||
| 598 | |||
| 599 | dev_info(&icd->dev, "Detected a MT9M001 chip ID %x (%s)\n", data, | ||
| 600 | data == 0x8431 ? "C12STM" : "C12ST"); | ||
| 601 | |||
| 602 | /* Now that we know the model, we can start video */ | ||
| 603 | ret = soc_camera_video_start(icd); | ||
| 604 | if (ret) | ||
| 605 | goto eisis; | ||
| 606 | |||
| 607 | return 0; | ||
| 608 | |||
| 609 | eisis: | ||
| 610 | ei2c: | ||
| 611 | return ret; | ||
| 612 | } | ||
| 613 | |||
| 614 | static void mt9m001_video_remove(struct soc_camera_device *icd) | ||
| 615 | { | ||
| 616 | struct mt9m001 *mt9m001 = container_of(icd, struct mt9m001, icd); | ||
| 617 | |||
| 618 | dev_dbg(&icd->dev, "Video %x removed: %p, %p\n", mt9m001->client->addr, | ||
| 619 | mt9m001->icd.dev.parent, mt9m001->icd.vdev); | ||
| 620 | soc_camera_video_stop(&mt9m001->icd); | ||
| 621 | } | ||
| 622 | |||
| 623 | static int mt9m001_probe(struct i2c_client *client) | ||
| 624 | { | ||
| 625 | struct mt9m001 *mt9m001; | ||
| 626 | struct soc_camera_device *icd; | ||
| 627 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | ||
| 628 | struct soc_camera_link *icl = client->dev.platform_data; | ||
| 629 | int ret; | ||
| 630 | |||
| 631 | if (!icl) { | ||
| 632 | dev_err(&client->dev, "MT9M001 driver needs platform data\n"); | ||
| 633 | return -EINVAL; | ||
| 634 | } | ||
| 635 | |||
| 636 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) { | ||
| 637 | dev_warn(&adapter->dev, | ||
| 638 | "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n"); | ||
| 639 | return -EIO; | ||
| 640 | } | ||
| 641 | |||
| 642 | mt9m001 = kzalloc(sizeof(struct mt9m001), GFP_KERNEL); | ||
| 643 | if (!mt9m001) | ||
| 644 | return -ENOMEM; | ||
| 645 | |||
| 646 | mt9m001->client = client; | ||
| 647 | i2c_set_clientdata(client, mt9m001); | ||
| 648 | |||
| 649 | /* Second stage probe - when a capture adapter is there */ | ||
| 650 | icd = &mt9m001->icd; | ||
| 651 | icd->ops = &mt9m001_ops; | ||
| 652 | icd->control = &client->dev; | ||
| 653 | icd->x_min = 20; | ||
| 654 | icd->y_min = 12; | ||
| 655 | icd->x_current = 20; | ||
| 656 | icd->y_current = 12; | ||
| 657 | icd->width_min = 48; | ||
| 658 | icd->width_max = 1280; | ||
| 659 | icd->height_min = 32; | ||
| 660 | icd->height_max = 1024; | ||
| 661 | icd->y_skip_top = 1; | ||
| 662 | icd->iface = icl->bus_id; | ||
| 663 | /* Default datawidth - this is the only width this camera (normally) | ||
| 664 | * supports. It is only with extra logic that it can support | ||
| 665 | * other widths. Therefore it seems to be a sensible default. */ | ||
| 666 | mt9m001->datawidth = 10; | ||
| 667 | /* Simulated autoexposure. If enabled, we calculate shutter width | ||
| 668 | * ourselves in the driver based on vertical blanking and frame width */ | ||
| 669 | mt9m001->autoexposure = 1; | ||
| 670 | |||
| 671 | ret = bus_switch_request(mt9m001, icl); | ||
| 672 | if (ret) | ||
| 673 | goto eswinit; | ||
| 674 | |||
| 675 | ret = soc_camera_device_register(icd); | ||
| 676 | if (ret) | ||
| 677 | goto eisdr; | ||
| 678 | |||
| 679 | return 0; | ||
| 680 | |||
| 681 | eisdr: | ||
| 682 | bus_switch_release(mt9m001); | ||
| 683 | eswinit: | ||
| 684 | kfree(mt9m001); | ||
| 685 | return ret; | ||
| 686 | } | ||
| 687 | |||
| 688 | static int mt9m001_remove(struct i2c_client *client) | ||
| 689 | { | ||
| 690 | struct mt9m001 *mt9m001 = i2c_get_clientdata(client); | ||
| 691 | |||
| 692 | soc_camera_device_unregister(&mt9m001->icd); | ||
| 693 | bus_switch_release(mt9m001); | ||
| 694 | kfree(mt9m001); | ||
| 695 | |||
| 696 | return 0; | ||
| 697 | } | ||
| 698 | |||
| 699 | static struct i2c_driver mt9m001_i2c_driver = { | ||
| 700 | .driver = { | ||
| 701 | .name = "mt9m001", | ||
| 702 | }, | ||
| 703 | .probe = mt9m001_probe, | ||
| 704 | .remove = mt9m001_remove, | ||
| 705 | }; | ||
| 706 | |||
| 707 | static int __init mt9m001_mod_init(void) | ||
| 708 | { | ||
| 709 | return i2c_add_driver(&mt9m001_i2c_driver); | ||
| 710 | } | ||
| 711 | |||
| 712 | static void __exit mt9m001_mod_exit(void) | ||
| 713 | { | ||
| 714 | i2c_del_driver(&mt9m001_i2c_driver); | ||
| 715 | } | ||
| 716 | |||
| 717 | module_init(mt9m001_mod_init); | ||
| 718 | module_exit(mt9m001_mod_exit); | ||
| 719 | |||
| 720 | MODULE_DESCRIPTION("Micron MT9M001 Camera driver"); | ||
| 721 | MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>"); | ||
| 722 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c new file mode 100644 index 000000000000..d4b9e2744343 --- /dev/null +++ b/drivers/media/video/mt9v022.c | |||
| @@ -0,0 +1,844 @@ | |||
| 1 | /* | ||
| 2 | * Driver for MT9V022 CMOS Image Sensor from Micron | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 as | ||
| 8 | * published by the Free Software Foundation. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #include <linux/videodev2.h> | ||
| 12 | #include <linux/slab.h> | ||
| 13 | #include <linux/i2c.h> | ||
| 14 | #include <linux/delay.h> | ||
| 15 | #include <linux/log2.h> | ||
| 16 | |||
| 17 | #include <media/v4l2-common.h> | ||
| 18 | #include <media/v4l2-chip-ident.h> | ||
| 19 | #include <media/soc_camera.h> | ||
| 20 | |||
| 21 | #ifdef CONFIG_MT9M001_PCA9536_SWITCH | ||
| 22 | #include <asm/gpio.h> | ||
| 23 | #endif | ||
| 24 | |||
| 25 | /* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c | ||
| 26 | * The platform has to define i2c_board_info | ||
| 27 | * and call i2c_register_board_info() */ | ||
| 28 | |||
| 29 | static char *sensor_type; | ||
| 30 | module_param(sensor_type, charp, S_IRUGO); | ||
| 31 | MODULE_PARM_DESC(sensor_type, "Sensor type: \"colour\" or \"monochrome\"\n"); | ||
| 32 | |||
| 33 | /* mt9v022 selected register addresses */ | ||
| 34 | #define MT9V022_CHIP_VERSION 0x00 | ||
| 35 | #define MT9V022_COLUMN_START 0x01 | ||
| 36 | #define MT9V022_ROW_START 0x02 | ||
| 37 | #define MT9V022_WINDOW_HEIGHT 0x03 | ||
| 38 | #define MT9V022_WINDOW_WIDTH 0x04 | ||
| 39 | #define MT9V022_HORIZONTAL_BLANKING 0x05 | ||
| 40 | #define MT9V022_VERTICAL_BLANKING 0x06 | ||
| 41 | #define MT9V022_CHIP_CONTROL 0x07 | ||
| 42 | #define MT9V022_SHUTTER_WIDTH1 0x08 | ||
| 43 | #define MT9V022_SHUTTER_WIDTH2 0x09 | ||
| 44 | #define MT9V022_SHUTTER_WIDTH_CTRL 0x0a | ||
| 45 | #define MT9V022_TOTAL_SHUTTER_WIDTH 0x0b | ||
| 46 | #define MT9V022_RESET 0x0c | ||
| 47 | #define MT9V022_READ_MODE 0x0d | ||
| 48 | #define MT9V022_MONITOR_MODE 0x0e | ||
| 49 | #define MT9V022_PIXEL_OPERATION_MODE 0x0f | ||
| 50 | #define MT9V022_LED_OUT_CONTROL 0x1b | ||
| 51 | #define MT9V022_ADC_MODE_CONTROL 0x1c | ||
| 52 | #define MT9V022_ANALOG_GAIN 0x34 | ||
| 53 | #define MT9V022_BLACK_LEVEL_CALIB_CTRL 0x47 | ||
| 54 | #define MT9V022_PIXCLK_FV_LV 0x74 | ||
| 55 | #define MT9V022_DIGITAL_TEST_PATTERN 0x7f | ||
| 56 | #define MT9V022_AEC_AGC_ENABLE 0xAF | ||
| 57 | #define MT9V022_MAX_TOTAL_SHUTTER_WIDTH 0xBD | ||
| 58 | |||
| 59 | /* Progressive scan, master, defaults */ | ||
| 60 | #define MT9V022_CHIP_CONTROL_DEFAULT 0x188 | ||
| 61 | |||
| 62 | static const struct soc_camera_data_format mt9v022_colour_formats[] = { | ||
| 63 | /* Order important: first natively supported, | ||
| 64 | * second supported with a GPIO extender */ | ||
| 65 | { | ||
| 66 | .name = "Bayer (sRGB) 10 bit", | ||
| 67 | .depth = 10, | ||
| 68 | .fourcc = V4L2_PIX_FMT_SBGGR16, | ||
| 69 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
| 70 | }, { | ||
| 71 | .name = "Bayer (sRGB) 8 bit", | ||
| 72 | .depth = 8, | ||
| 73 | .fourcc = V4L2_PIX_FMT_SBGGR8, | ||
| 74 | .colorspace = V4L2_COLORSPACE_SRGB, | ||
| 75 | } | ||
| 76 | }; | ||
| 77 | |||
| 78 | static const struct soc_camera_data_format mt9v022_monochrome_formats[] = { | ||
| 79 | /* Order important - see above */ | ||
| 80 | { | ||
| 81 | .name = "Monochrome 10 bit", | ||
| 82 | .depth = 10, | ||
| 83 | .fourcc = V4L2_PIX_FMT_Y16, | ||
| 84 | }, { | ||
| 85 | .name = "Monochrome 8 bit", | ||
| 86 | .depth = 8, | ||
| 87 | .fourcc = V4L2_PIX_FMT_GREY, | ||
| 88 | }, | ||
| 89 | }; | ||
| 90 | |||
| 91 | struct mt9v022 { | ||
| 92 | struct i2c_client *client; | ||
| 93 | struct soc_camera_device icd; | ||
| 94 | int model; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */ | ||
| 95 | int switch_gpio; | ||
| 96 | u16 chip_control; | ||
| 97 | unsigned char datawidth; | ||
| 98 | }; | ||
| 99 | |||
| 100 | static int reg_read(struct soc_camera_device *icd, const u8 reg) | ||
| 101 | { | ||
| 102 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 103 | struct i2c_client *client = mt9v022->client; | ||
| 104 | s32 data = i2c_smbus_read_word_data(client, reg); | ||
| 105 | return data < 0 ? data : swab16(data); | ||
| 106 | } | ||
| 107 | |||
| 108 | static int reg_write(struct soc_camera_device *icd, const u8 reg, | ||
| 109 | const u16 data) | ||
| 110 | { | ||
| 111 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 112 | return i2c_smbus_write_word_data(mt9v022->client, reg, swab16(data)); | ||
| 113 | } | ||
| 114 | |||
| 115 | static int reg_set(struct soc_camera_device *icd, const u8 reg, | ||
| 116 | const u16 data) | ||
| 117 | { | ||
| 118 | int ret; | ||
| 119 | |||
| 120 | ret = reg_read(icd, reg); | ||
| 121 | if (ret < 0) | ||
| 122 | return ret; | ||
| 123 | return reg_write(icd, reg, ret | data); | ||
| 124 | } | ||
| 125 | |||
| 126 | static int reg_clear(struct soc_camera_device *icd, const u8 reg, | ||
| 127 | const u16 data) | ||
| 128 | { | ||
| 129 | int ret; | ||
| 130 | |||
| 131 | ret = reg_read(icd, reg); | ||
| 132 | if (ret < 0) | ||
| 133 | return ret; | ||
| 134 | return reg_write(icd, reg, ret & ~data); | ||
| 135 | } | ||
| 136 | |||
| 137 | static int mt9v022_init(struct soc_camera_device *icd) | ||
| 138 | { | ||
| 139 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 140 | int ret; | ||
| 141 | |||
| 142 | /* Almost the default mode: master, parallel, simultaneous, and an | ||
| 143 | * undocumented bit 0x200, which is present in table 7, but not in 8, | ||
| 144 | * plus snapshot mode to disable scan for now */ | ||
| 145 | mt9v022->chip_control |= 0x10; | ||
| 146 | ret = reg_write(icd, MT9V022_CHIP_CONTROL, mt9v022->chip_control); | ||
| 147 | if (ret >= 0) | ||
| 148 | reg_write(icd, MT9V022_READ_MODE, 0x300); | ||
| 149 | |||
| 150 | /* All defaults */ | ||
| 151 | if (ret >= 0) | ||
| 152 | /* AEC, AGC on */ | ||
| 153 | ret = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x3); | ||
| 154 | if (ret >= 0) | ||
| 155 | ret = reg_write(icd, MT9V022_MAX_TOTAL_SHUTTER_WIDTH, 480); | ||
| 156 | if (ret >= 0) | ||
| 157 | /* default - auto */ | ||
| 158 | ret = reg_clear(icd, MT9V022_BLACK_LEVEL_CALIB_CTRL, 1); | ||
| 159 | if (ret >= 0) | ||
| 160 | ret = reg_write(icd, MT9V022_DIGITAL_TEST_PATTERN, 0); | ||
| 161 | |||
| 162 | return ret >= 0 ? 0 : -EIO; | ||
| 163 | } | ||
| 164 | |||
| 165 | static int mt9v022_release(struct soc_camera_device *icd) | ||
| 166 | { | ||
| 167 | /* Nothing? */ | ||
| 168 | return 0; | ||
| 169 | } | ||
| 170 | |||
| 171 | static int mt9v022_start_capture(struct soc_camera_device *icd) | ||
| 172 | { | ||
| 173 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 174 | /* Switch to master "normal" mode */ | ||
| 175 | mt9v022->chip_control &= ~0x10; | ||
| 176 | if (reg_write(icd, MT9V022_CHIP_CONTROL, | ||
| 177 | mt9v022->chip_control) < 0) | ||
| 178 | return -EIO; | ||
| 179 | return 0; | ||
| 180 | } | ||
| 181 | |||
| 182 | static int mt9v022_stop_capture(struct soc_camera_device *icd) | ||
| 183 | { | ||
| 184 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 185 | /* Switch to snapshot mode */ | ||
| 186 | mt9v022->chip_control |= 0x10; | ||
| 187 | if (reg_write(icd, MT9V022_CHIP_CONTROL, | ||
| 188 | mt9v022->chip_control) < 0) | ||
| 189 | return -EIO; | ||
| 190 | return 0; | ||
| 191 | } | ||
| 192 | |||
| 193 | static int bus_switch_request(struct mt9v022 *mt9v022, struct soc_camera_link *icl) | ||
| 194 | { | ||
| 195 | #ifdef CONFIG_MT9V022_PCA9536_SWITCH | ||
| 196 | int ret; | ||
| 197 | unsigned int gpio = icl->gpio; | ||
| 198 | |||
| 199 | if (gpio_is_valid(gpio)) { | ||
| 200 | /* We have a data bus switch. */ | ||
| 201 | ret = gpio_request(gpio, "mt9v022"); | ||
| 202 | if (ret < 0) { | ||
| 203 | dev_err(&mt9v022->client->dev, "Cannot get GPIO %u\n", gpio); | ||
| 204 | return ret; | ||
| 205 | } | ||
| 206 | |||
| 207 | ret = gpio_direction_output(gpio, 0); | ||
| 208 | if (ret < 0) { | ||
| 209 | dev_err(&mt9v022->client->dev, | ||
| 210 | "Cannot set GPIO %u to output\n", gpio); | ||
| 211 | gpio_free(gpio); | ||
| 212 | return ret; | ||
| 213 | } | ||
| 214 | } | ||
| 215 | |||
| 216 | mt9v022->switch_gpio = gpio; | ||
| 217 | #else | ||
| 218 | mt9v022->switch_gpio = -EINVAL; | ||
| 219 | #endif | ||
| 220 | return 0; | ||
| 221 | } | ||
| 222 | |||
| 223 | static void bus_switch_release(struct mt9v022 *mt9v022) | ||
| 224 | { | ||
| 225 | #ifdef CONFIG_MT9V022_PCA9536_SWITCH | ||
| 226 | if (gpio_is_valid(mt9v022->switch_gpio)) | ||
| 227 | gpio_free(mt9v022->switch_gpio); | ||
| 228 | #endif | ||
| 229 | } | ||
| 230 | |||
| 231 | static int bus_switch_act(struct mt9v022 *mt9v022, int go8bit) | ||
| 232 | { | ||
| 233 | #ifdef CONFIG_MT9V022_PCA9536_SWITCH | ||
| 234 | if (!gpio_is_valid(mt9v022->switch_gpio)) | ||
| 235 | return -ENODEV; | ||
| 236 | |||
| 237 | gpio_set_value_cansleep(mt9v022->switch_gpio, go8bit); | ||
| 238 | return 0; | ||
| 239 | #else | ||
| 240 | return -ENODEV; | ||
| 241 | #endif | ||
| 242 | } | ||
| 243 | |||
| 244 | static int bus_switch_possible(struct mt9v022 *mt9v022) | ||
| 245 | { | ||
| 246 | #ifdef CONFIG_MT9V022_PCA9536_SWITCH | ||
| 247 | return gpio_is_valid(mt9v022->switch_gpio); | ||
| 248 | #else | ||
| 249 | return 0; | ||
| 250 | #endif | ||
| 251 | } | ||
| 252 | |||
| 253 | static int mt9v022_set_bus_param(struct soc_camera_device *icd, | ||
| 254 | unsigned long flags) | ||
| 255 | { | ||
| 256 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 257 | unsigned int width_flag = flags & SOCAM_DATAWIDTH_MASK; | ||
| 258 | int ret; | ||
| 259 | u16 pixclk = 0; | ||
| 260 | |||
| 261 | /* Only one width bit may be set */ | ||
| 262 | if (!is_power_of_2(width_flag)) | ||
| 263 | return -EINVAL; | ||
| 264 | |||
| 265 | if ((mt9v022->datawidth != 10 && (width_flag == SOCAM_DATAWIDTH_10)) || | ||
| 266 | (mt9v022->datawidth != 9 && (width_flag == SOCAM_DATAWIDTH_9)) || | ||
| 267 | (mt9v022->datawidth != 8 && (width_flag == SOCAM_DATAWIDTH_8))) { | ||
| 268 | /* Well, we actually only can do 10 or 8 bits... */ | ||
| 269 | if (width_flag == SOCAM_DATAWIDTH_9) | ||
| 270 | return -EINVAL; | ||
| 271 | |||
| 272 | ret = bus_switch_act(mt9v022, | ||
| 273 | width_flag == SOCAM_DATAWIDTH_8); | ||
| 274 | if (ret < 0) | ||
| 275 | return ret; | ||
| 276 | |||
| 277 | mt9v022->datawidth = width_flag == SOCAM_DATAWIDTH_8 ? 8 : 10; | ||
| 278 | } | ||
| 279 | |||
| 280 | if (flags & SOCAM_PCLK_SAMPLE_RISING) | ||
| 281 | pixclk |= 0x10; | ||
| 282 | |||
| 283 | if (!(flags & SOCAM_HSYNC_ACTIVE_HIGH)) | ||
| 284 | pixclk |= 0x1; | ||
| 285 | |||
| 286 | if (!(flags & SOCAM_VSYNC_ACTIVE_HIGH)) | ||
| 287 | pixclk |= 0x2; | ||
| 288 | |||
| 289 | ret = reg_write(icd, MT9V022_PIXCLK_FV_LV, pixclk); | ||
| 290 | if (ret < 0) | ||
| 291 | return ret; | ||
| 292 | |||
| 293 | if (!(flags & SOCAM_MASTER)) | ||
| 294 | mt9v022->chip_control &= ~0x8; | ||
| 295 | |||
| 296 | ret = reg_write(icd, MT9V022_CHIP_CONTROL, mt9v022->chip_control); | ||
| 297 | if (ret < 0) | ||
| 298 | return ret; | ||
| 299 | |||
| 300 | dev_dbg(&icd->dev, "Calculated pixclk 0x%x, chip control 0x%x\n", | ||
| 301 | pixclk, mt9v022->chip_control); | ||
| 302 | |||
| 303 | return 0; | ||
| 304 | } | ||
| 305 | |||
| 306 | static unsigned long mt9v022_query_bus_param(struct soc_camera_device *icd) | ||
| 307 | { | ||
| 308 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 309 | unsigned int width_flag = SOCAM_DATAWIDTH_10; | ||
| 310 | |||
| 311 | if (bus_switch_possible(mt9v022)) | ||
| 312 | width_flag |= SOCAM_DATAWIDTH_8; | ||
| 313 | |||
| 314 | return SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING | | ||
| 315 | SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW | | ||
| 316 | SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW | | ||
| 317 | SOCAM_MASTER | SOCAM_SLAVE | | ||
| 318 | width_flag; | ||
| 319 | } | ||
| 320 | |||
| 321 | static int mt9v022_set_fmt_cap(struct soc_camera_device *icd, | ||
| 322 | __u32 pixfmt, struct v4l2_rect *rect) | ||
| 323 | { | ||
| 324 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 325 | int ret; | ||
| 326 | |||
| 327 | /* The caller provides a supported format, as verified per call to | ||
| 328 | * icd->try_fmt_cap(), datawidth is from our supported format list */ | ||
| 329 | switch (pixfmt) { | ||
| 330 | case V4L2_PIX_FMT_GREY: | ||
| 331 | case V4L2_PIX_FMT_Y16: | ||
| 332 | if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATM) | ||
| 333 | return -EINVAL; | ||
| 334 | break; | ||
| 335 | case V4L2_PIX_FMT_SBGGR8: | ||
| 336 | case V4L2_PIX_FMT_SBGGR16: | ||
| 337 | if (mt9v022->model != V4L2_IDENT_MT9V022IX7ATC) | ||
| 338 | return -EINVAL; | ||
| 339 | break; | ||
| 340 | case 0: | ||
| 341 | /* No format change, only geometry */ | ||
| 342 | break; | ||
| 343 | default: | ||
| 344 | return -EINVAL; | ||
| 345 | } | ||
| 346 | |||
| 347 | /* Like in example app. Contradicts the datasheet though */ | ||
| 348 | ret = reg_read(icd, MT9V022_AEC_AGC_ENABLE); | ||
| 349 | if (ret >= 0) { | ||
| 350 | if (ret & 1) /* Autoexposure */ | ||
| 351 | ret = reg_write(icd, MT9V022_MAX_TOTAL_SHUTTER_WIDTH, | ||
| 352 | rect->height + icd->y_skip_top + 43); | ||
| 353 | else | ||
| 354 | ret = reg_write(icd, MT9V022_TOTAL_SHUTTER_WIDTH, | ||
| 355 | rect->height + icd->y_skip_top + 43); | ||
| 356 | } | ||
| 357 | /* Setup frame format: defaults apart from width and height */ | ||
| 358 | if (ret >= 0) | ||
| 359 | ret = reg_write(icd, MT9V022_COLUMN_START, rect->left); | ||
| 360 | if (ret >= 0) | ||
| 361 | ret = reg_write(icd, MT9V022_ROW_START, rect->top); | ||
| 362 | if (ret >= 0) | ||
| 363 | /* Default 94, Phytec driver says: | ||
| 364 | * "width + horizontal blank >= 660" */ | ||
| 365 | ret = reg_write(icd, MT9V022_HORIZONTAL_BLANKING, | ||
| 366 | rect->width > 660 - 43 ? 43 : | ||
| 367 | 660 - rect->width); | ||
| 368 | if (ret >= 0) | ||
| 369 | ret = reg_write(icd, MT9V022_VERTICAL_BLANKING, 45); | ||
| 370 | if (ret >= 0) | ||
| 371 | ret = reg_write(icd, MT9V022_WINDOW_WIDTH, rect->width); | ||
| 372 | if (ret >= 0) | ||
| 373 | ret = reg_write(icd, MT9V022_WINDOW_HEIGHT, | ||
| 374 | rect->height + icd->y_skip_top); | ||
| 375 | |||
| 376 | if (ret < 0) | ||
| 377 | return ret; | ||
| 378 | |||
| 379 | dev_dbg(&icd->dev, "Frame %ux%u pixel\n", rect->width, rect->height); | ||
| 380 | |||
| 381 | return 0; | ||
| 382 | } | ||
| 383 | |||
| 384 | static int mt9v022_try_fmt_cap(struct soc_camera_device *icd, | ||
| 385 | struct v4l2_format *f) | ||
| 386 | { | ||
| 387 | if (f->fmt.pix.height < 32 + icd->y_skip_top) | ||
| 388 | f->fmt.pix.height = 32 + icd->y_skip_top; | ||
| 389 | if (f->fmt.pix.height > 480 + icd->y_skip_top) | ||
| 390 | f->fmt.pix.height = 480 + icd->y_skip_top; | ||
| 391 | if (f->fmt.pix.width < 48) | ||
| 392 | f->fmt.pix.width = 48; | ||
| 393 | if (f->fmt.pix.width > 752) | ||
| 394 | f->fmt.pix.width = 752; | ||
| 395 | f->fmt.pix.width &= ~0x03; /* ? */ | ||
| 396 | |||
| 397 | return 0; | ||
| 398 | } | ||
| 399 | |||
| 400 | static int mt9v022_get_chip_id(struct soc_camera_device *icd, | ||
| 401 | struct v4l2_chip_ident *id) | ||
| 402 | { | ||
| 403 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 404 | |||
| 405 | if (id->match_type != V4L2_CHIP_MATCH_I2C_ADDR) | ||
| 406 | return -EINVAL; | ||
| 407 | |||
| 408 | if (id->match_chip != mt9v022->client->addr) | ||
| 409 | return -ENODEV; | ||
| 410 | |||
| 411 | id->ident = mt9v022->model; | ||
| 412 | id->revision = 0; | ||
| 413 | |||
| 414 | return 0; | ||
| 415 | } | ||
| 416 | |||
| 417 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
| 418 | static int mt9v022_get_register(struct soc_camera_device *icd, | ||
| 419 | struct v4l2_register *reg) | ||
| 420 | { | ||
| 421 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 422 | |||
| 423 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) | ||
| 424 | return -EINVAL; | ||
| 425 | |||
| 426 | if (reg->match_chip != mt9v022->client->addr) | ||
| 427 | return -ENODEV; | ||
| 428 | |||
| 429 | reg->val = reg_read(icd, reg->reg); | ||
| 430 | |||
| 431 | if (reg->val > 0xffff) | ||
| 432 | return -EIO; | ||
| 433 | |||
| 434 | return 0; | ||
| 435 | } | ||
| 436 | |||
| 437 | static int mt9v022_set_register(struct soc_camera_device *icd, | ||
| 438 | struct v4l2_register *reg) | ||
| 439 | { | ||
| 440 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 441 | |||
| 442 | if (reg->match_type != V4L2_CHIP_MATCH_I2C_ADDR || reg->reg > 0xff) | ||
| 443 | return -EINVAL; | ||
| 444 | |||
| 445 | if (reg->match_chip != mt9v022->client->addr) | ||
| 446 | return -ENODEV; | ||
| 447 | |||
| 448 | if (reg_write(icd, reg->reg, reg->val) < 0) | ||
| 449 | return -EIO; | ||
| 450 | |||
| 451 | return 0; | ||
| 452 | } | ||
| 453 | #endif | ||
| 454 | |||
| 455 | const struct v4l2_queryctrl mt9v022_controls[] = { | ||
| 456 | { | ||
| 457 | .id = V4L2_CID_VFLIP, | ||
| 458 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
| 459 | .name = "Flip Vertically", | ||
| 460 | .minimum = 0, | ||
| 461 | .maximum = 1, | ||
| 462 | .step = 1, | ||
| 463 | .default_value = 0, | ||
| 464 | }, { | ||
| 465 | .id = V4L2_CID_HFLIP, | ||
| 466 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
| 467 | .name = "Flip Horizontally", | ||
| 468 | .minimum = 0, | ||
| 469 | .maximum = 1, | ||
| 470 | .step = 1, | ||
| 471 | .default_value = 0, | ||
| 472 | }, { | ||
| 473 | .id = V4L2_CID_GAIN, | ||
| 474 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 475 | .name = "Analog Gain", | ||
| 476 | .minimum = 64, | ||
| 477 | .maximum = 127, | ||
| 478 | .step = 1, | ||
| 479 | .default_value = 64, | ||
| 480 | .flags = V4L2_CTRL_FLAG_SLIDER, | ||
| 481 | }, { | ||
| 482 | .id = V4L2_CID_EXPOSURE, | ||
| 483 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 484 | .name = "Exposure", | ||
| 485 | .minimum = 1, | ||
| 486 | .maximum = 255, | ||
| 487 | .step = 1, | ||
| 488 | .default_value = 255, | ||
| 489 | .flags = V4L2_CTRL_FLAG_SLIDER, | ||
| 490 | }, { | ||
| 491 | .id = V4L2_CID_AUTOGAIN, | ||
| 492 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
| 493 | .name = "Automatic Gain", | ||
| 494 | .minimum = 0, | ||
| 495 | .maximum = 1, | ||
| 496 | .step = 1, | ||
| 497 | .default_value = 1, | ||
| 498 | }, { | ||
| 499 | .id = V4L2_CID_EXPOSURE_AUTO, | ||
| 500 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
| 501 | .name = "Automatic Exposure", | ||
| 502 | .minimum = 0, | ||
| 503 | .maximum = 1, | ||
| 504 | .step = 1, | ||
| 505 | .default_value = 1, | ||
| 506 | } | ||
| 507 | }; | ||
| 508 | |||
| 509 | static int mt9v022_video_probe(struct soc_camera_device *); | ||
| 510 | static void mt9v022_video_remove(struct soc_camera_device *); | ||
| 511 | static int mt9v022_get_control(struct soc_camera_device *, struct v4l2_control *); | ||
| 512 | static int mt9v022_set_control(struct soc_camera_device *, struct v4l2_control *); | ||
| 513 | |||
| 514 | static struct soc_camera_ops mt9v022_ops = { | ||
| 515 | .owner = THIS_MODULE, | ||
| 516 | .probe = mt9v022_video_probe, | ||
| 517 | .remove = mt9v022_video_remove, | ||
| 518 | .init = mt9v022_init, | ||
| 519 | .release = mt9v022_release, | ||
| 520 | .start_capture = mt9v022_start_capture, | ||
| 521 | .stop_capture = mt9v022_stop_capture, | ||
| 522 | .set_fmt_cap = mt9v022_set_fmt_cap, | ||
| 523 | .try_fmt_cap = mt9v022_try_fmt_cap, | ||
| 524 | .set_bus_param = mt9v022_set_bus_param, | ||
| 525 | .query_bus_param = mt9v022_query_bus_param, | ||
| 526 | .controls = mt9v022_controls, | ||
| 527 | .num_controls = ARRAY_SIZE(mt9v022_controls), | ||
| 528 | .get_control = mt9v022_get_control, | ||
| 529 | .set_control = mt9v022_set_control, | ||
| 530 | .get_chip_id = mt9v022_get_chip_id, | ||
| 531 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
| 532 | .get_register = mt9v022_get_register, | ||
| 533 | .set_register = mt9v022_set_register, | ||
| 534 | #endif | ||
| 535 | }; | ||
| 536 | |||
| 537 | static int mt9v022_get_control(struct soc_camera_device *icd, | ||
| 538 | struct v4l2_control *ctrl) | ||
| 539 | { | ||
| 540 | int data; | ||
| 541 | |||
| 542 | switch (ctrl->id) { | ||
| 543 | case V4L2_CID_VFLIP: | ||
| 544 | data = reg_read(icd, MT9V022_READ_MODE); | ||
| 545 | if (data < 0) | ||
| 546 | return -EIO; | ||
| 547 | ctrl->value = !!(data & 0x10); | ||
| 548 | break; | ||
| 549 | case V4L2_CID_HFLIP: | ||
| 550 | data = reg_read(icd, MT9V022_READ_MODE); | ||
| 551 | if (data < 0) | ||
| 552 | return -EIO; | ||
| 553 | ctrl->value = !!(data & 0x20); | ||
| 554 | break; | ||
| 555 | case V4L2_CID_EXPOSURE_AUTO: | ||
| 556 | data = reg_read(icd, MT9V022_AEC_AGC_ENABLE); | ||
| 557 | if (data < 0) | ||
| 558 | return -EIO; | ||
| 559 | ctrl->value = !!(data & 0x1); | ||
| 560 | break; | ||
| 561 | case V4L2_CID_AUTOGAIN: | ||
| 562 | data = reg_read(icd, MT9V022_AEC_AGC_ENABLE); | ||
| 563 | if (data < 0) | ||
| 564 | return -EIO; | ||
| 565 | ctrl->value = !!(data & 0x2); | ||
| 566 | break; | ||
| 567 | } | ||
| 568 | return 0; | ||
| 569 | } | ||
| 570 | |||
| 571 | static int mt9v022_set_control(struct soc_camera_device *icd, | ||
| 572 | struct v4l2_control *ctrl) | ||
| 573 | { | ||
| 574 | int data; | ||
| 575 | const struct v4l2_queryctrl *qctrl; | ||
| 576 | |||
| 577 | qctrl = soc_camera_find_qctrl(&mt9v022_ops, ctrl->id); | ||
| 578 | |||
| 579 | if (!qctrl) | ||
| 580 | return -EINVAL; | ||
| 581 | |||
| 582 | switch (ctrl->id) { | ||
| 583 | case V4L2_CID_VFLIP: | ||
| 584 | if (ctrl->value) | ||
| 585 | data = reg_set(icd, MT9V022_READ_MODE, 0x10); | ||
| 586 | else | ||
| 587 | data = reg_clear(icd, MT9V022_READ_MODE, 0x10); | ||
| 588 | if (data < 0) | ||
| 589 | return -EIO; | ||
| 590 | break; | ||
| 591 | case V4L2_CID_HFLIP: | ||
| 592 | if (ctrl->value) | ||
| 593 | data = reg_set(icd, MT9V022_READ_MODE, 0x20); | ||
| 594 | else | ||
| 595 | data = reg_clear(icd, MT9V022_READ_MODE, 0x20); | ||
| 596 | if (data < 0) | ||
| 597 | return -EIO; | ||
| 598 | break; | ||
| 599 | case V4L2_CID_GAIN: | ||
| 600 | /* mt9v022 has minimum == default */ | ||
| 601 | if (ctrl->value > qctrl->maximum || ctrl->value < qctrl->minimum) | ||
| 602 | return -EINVAL; | ||
| 603 | else { | ||
| 604 | unsigned long range = qctrl->maximum - qctrl->minimum; | ||
| 605 | /* Datasheet says 16 to 64. autogain only works properly | ||
| 606 | * after setting gain to maximum 14. Larger values | ||
| 607 | * produce "white fly" noise effect. On the whole, | ||
| 608 | * manually setting analog gain does no good. */ | ||
| 609 | unsigned long gain = ((ctrl->value - qctrl->minimum) * | ||
| 610 | 10 + range / 2) / range + 4; | ||
| 611 | if (gain >= 32) | ||
| 612 | gain &= ~1; | ||
| 613 | /* The user wants to set gain manually, hope, she | ||
| 614 | * knows, what she's doing... Switch AGC off. */ | ||
| 615 | |||
| 616 | if (reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x2) < 0) | ||
| 617 | return -EIO; | ||
| 618 | |||
| 619 | dev_info(&icd->dev, "Setting gain from %d to %lu\n", | ||
| 620 | reg_read(icd, MT9V022_ANALOG_GAIN), gain); | ||
| 621 | if (reg_write(icd, MT9V022_ANALOG_GAIN, gain) < 0) | ||
| 622 | return -EIO; | ||
| 623 | icd->gain = ctrl->value; | ||
| 624 | } | ||
| 625 | break; | ||
| 626 | case V4L2_CID_EXPOSURE: | ||
| 627 | /* mt9v022 has maximum == default */ | ||
| 628 | if (ctrl->value > qctrl->maximum || ctrl->value < qctrl->minimum) | ||
| 629 | return -EINVAL; | ||
| 630 | else { | ||
| 631 | unsigned long range = qctrl->maximum - qctrl->minimum; | ||
| 632 | unsigned long shutter = ((ctrl->value - qctrl->minimum) * | ||
| 633 | 479 + range / 2) / range + 1; | ||
| 634 | /* The user wants to set shutter width manually, hope, | ||
| 635 | * she knows, what she's doing... Switch AEC off. */ | ||
| 636 | |||
| 637 | if (reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x1) < 0) | ||
| 638 | return -EIO; | ||
| 639 | |||
| 640 | dev_dbg(&icd->dev, "Shutter width from %d to %lu\n", | ||
| 641 | reg_read(icd, MT9V022_TOTAL_SHUTTER_WIDTH), | ||
| 642 | shutter); | ||
| 643 | if (reg_write(icd, MT9V022_TOTAL_SHUTTER_WIDTH, | ||
| 644 | shutter) < 0) | ||
| 645 | return -EIO; | ||
| 646 | icd->exposure = ctrl->value; | ||
| 647 | } | ||
| 648 | break; | ||
| 649 | case V4L2_CID_AUTOGAIN: | ||
| 650 | if (ctrl->value) | ||
| 651 | data = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x2); | ||
| 652 | else | ||
| 653 | data = reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x2); | ||
| 654 | if (data < 0) | ||
| 655 | return -EIO; | ||
| 656 | break; | ||
| 657 | case V4L2_CID_EXPOSURE_AUTO: | ||
| 658 | if (ctrl->value) | ||
| 659 | data = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x1); | ||
| 660 | else | ||
| 661 | data = reg_clear(icd, MT9V022_AEC_AGC_ENABLE, 0x1); | ||
| 662 | if (data < 0) | ||
| 663 | return -EIO; | ||
| 664 | break; | ||
| 665 | } | ||
| 666 | return 0; | ||
| 667 | } | ||
| 668 | |||
| 669 | /* Interface active, can use i2c. If it fails, it can indeed mean, that | ||
| 670 | * this wasn't our capture interface, so, we wait for the right one */ | ||
| 671 | static int mt9v022_video_probe(struct soc_camera_device *icd) | ||
| 672 | { | ||
| 673 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 674 | s32 data; | ||
| 675 | int ret; | ||
| 676 | |||
| 677 | if (!icd->dev.parent || | ||
| 678 | to_soc_camera_host(icd->dev.parent)->nr != icd->iface) | ||
| 679 | return -ENODEV; | ||
| 680 | |||
| 681 | /* Read out the chip version register */ | ||
| 682 | data = reg_read(icd, MT9V022_CHIP_VERSION); | ||
| 683 | |||
| 684 | /* must be 0x1311 or 0x1313 */ | ||
| 685 | if (data != 0x1311 && data != 0x1313) { | ||
| 686 | ret = -ENODEV; | ||
| 687 | dev_info(&icd->dev, "No MT9V022 detected, ID register 0x%x\n", | ||
| 688 | data); | ||
| 689 | goto ei2c; | ||
| 690 | } | ||
| 691 | |||
| 692 | /* Soft reset */ | ||
| 693 | ret = reg_write(icd, MT9V022_RESET, 1); | ||
| 694 | if (ret < 0) | ||
| 695 | goto ei2c; | ||
| 696 | /* 15 clock cycles */ | ||
| 697 | udelay(200); | ||
| 698 | if (reg_read(icd, MT9V022_RESET)) { | ||
| 699 | dev_err(&icd->dev, "Resetting MT9V022 failed!\n"); | ||
| 700 | goto ei2c; | ||
| 701 | } | ||
| 702 | |||
| 703 | /* Set monochrome or colour sensor type */ | ||
| 704 | if (sensor_type && (!strcmp("colour", sensor_type) || | ||
| 705 | !strcmp("color", sensor_type))) { | ||
| 706 | ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 4 | 0x11); | ||
| 707 | mt9v022->model = V4L2_IDENT_MT9V022IX7ATC; | ||
| 708 | icd->formats = mt9v022_colour_formats; | ||
| 709 | if (mt9v022->client->dev.platform_data) | ||
| 710 | icd->num_formats = ARRAY_SIZE(mt9v022_colour_formats); | ||
| 711 | else | ||
| 712 | icd->num_formats = 1; | ||
| 713 | } else { | ||
| 714 | ret = reg_write(icd, MT9V022_PIXEL_OPERATION_MODE, 0x11); | ||
| 715 | mt9v022->model = V4L2_IDENT_MT9V022IX7ATM; | ||
| 716 | icd->formats = mt9v022_monochrome_formats; | ||
| 717 | if (mt9v022->client->dev.platform_data) | ||
| 718 | icd->num_formats = ARRAY_SIZE(mt9v022_monochrome_formats); | ||
| 719 | else | ||
| 720 | icd->num_formats = 1; | ||
| 721 | } | ||
| 722 | |||
| 723 | if (ret >= 0) | ||
| 724 | ret = soc_camera_video_start(icd); | ||
| 725 | if (ret < 0) | ||
| 726 | goto eisis; | ||
| 727 | |||
| 728 | dev_info(&icd->dev, "Detected a MT9V022 chip ID %x, %s sensor\n", | ||
| 729 | data, mt9v022->model == V4L2_IDENT_MT9V022IX7ATM ? | ||
| 730 | "monochrome" : "colour"); | ||
| 731 | |||
| 732 | return 0; | ||
| 733 | |||
| 734 | eisis: | ||
| 735 | ei2c: | ||
| 736 | return ret; | ||
| 737 | } | ||
| 738 | |||
| 739 | static void mt9v022_video_remove(struct soc_camera_device *icd) | ||
| 740 | { | ||
| 741 | struct mt9v022 *mt9v022 = container_of(icd, struct mt9v022, icd); | ||
| 742 | |||
| 743 | dev_dbg(&icd->dev, "Video %x removed: %p, %p\n", mt9v022->client->addr, | ||
| 744 | mt9v022->icd.dev.parent, mt9v022->icd.vdev); | ||
| 745 | soc_camera_video_stop(&mt9v022->icd); | ||
| 746 | } | ||
| 747 | |||
| 748 | static int mt9v022_probe(struct i2c_client *client) | ||
| 749 | { | ||
| 750 | struct mt9v022 *mt9v022; | ||
| 751 | struct soc_camera_device *icd; | ||
| 752 | struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); | ||
| 753 | struct soc_camera_link *icl = client->dev.platform_data; | ||
| 754 | int ret; | ||
| 755 | |||
| 756 | if (!icl) { | ||
| 757 | dev_err(&client->dev, "MT9V022 driver needs platform data\n"); | ||
| 758 | return -EINVAL; | ||
| 759 | } | ||
| 760 | |||
| 761 | if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA)) { | ||
| 762 | dev_warn(&adapter->dev, | ||
| 763 | "I2C-Adapter doesn't support I2C_FUNC_SMBUS_WORD\n"); | ||
| 764 | return -EIO; | ||
| 765 | } | ||
| 766 | |||
| 767 | mt9v022 = kzalloc(sizeof(struct mt9v022), GFP_KERNEL); | ||
| 768 | if (!mt9v022) | ||
| 769 | return -ENOMEM; | ||
| 770 | |||
| 771 | mt9v022->chip_control = MT9V022_CHIP_CONTROL_DEFAULT; | ||
| 772 | mt9v022->client = client; | ||
| 773 | i2c_set_clientdata(client, mt9v022); | ||
| 774 | |||
| 775 | icd = &mt9v022->icd; | ||
| 776 | icd->ops = &mt9v022_ops; | ||
| 777 | icd->control = &client->dev; | ||
| 778 | icd->x_min = 1; | ||
| 779 | icd->y_min = 4; | ||
| 780 | icd->x_current = 1; | ||
| 781 | icd->y_current = 4; | ||
| 782 | icd->width_min = 48; | ||
| 783 | icd->width_max = 752; | ||
| 784 | icd->height_min = 32; | ||
| 785 | icd->height_max = 480; | ||
| 786 | icd->y_skip_top = 1; | ||
| 787 | icd->iface = icl->bus_id; | ||
| 788 | /* Default datawidth - this is the only width this camera (normally) | ||
| 789 | * supports. It is only with extra logic that it can support | ||
| 790 | * other widths. Therefore it seems to be a sensible default. */ | ||
| 791 | mt9v022->datawidth = 10; | ||
| 792 | |||
| 793 | ret = bus_switch_request(mt9v022, icl); | ||
| 794 | if (ret) | ||
| 795 | goto eswinit; | ||
| 796 | |||
| 797 | ret = soc_camera_device_register(icd); | ||
| 798 | if (ret) | ||
| 799 | goto eisdr; | ||
| 800 | |||
| 801 | return 0; | ||
| 802 | |||
| 803 | eisdr: | ||
| 804 | bus_switch_release(mt9v022); | ||
| 805 | eswinit: | ||
| 806 | kfree(mt9v022); | ||
| 807 | return ret; | ||
| 808 | } | ||
| 809 | |||
| 810 | static int mt9v022_remove(struct i2c_client *client) | ||
| 811 | { | ||
| 812 | struct mt9v022 *mt9v022 = i2c_get_clientdata(client); | ||
| 813 | |||
| 814 | soc_camera_device_unregister(&mt9v022->icd); | ||
| 815 | bus_switch_release(mt9v022); | ||
| 816 | kfree(mt9v022); | ||
| 817 | |||
| 818 | return 0; | ||
| 819 | } | ||
| 820 | |||
| 821 | static struct i2c_driver mt9v022_i2c_driver = { | ||
| 822 | .driver = { | ||
| 823 | .name = "mt9v022", | ||
| 824 | }, | ||
| 825 | .probe = mt9v022_probe, | ||
| 826 | .remove = mt9v022_remove, | ||
| 827 | }; | ||
| 828 | |||
| 829 | static int __init mt9v022_mod_init(void) | ||
| 830 | { | ||
| 831 | return i2c_add_driver(&mt9v022_i2c_driver); | ||
| 832 | } | ||
| 833 | |||
| 834 | static void __exit mt9v022_mod_exit(void) | ||
| 835 | { | ||
| 836 | i2c_del_driver(&mt9v022_i2c_driver); | ||
| 837 | } | ||
| 838 | |||
| 839 | module_init(mt9v022_mod_init); | ||
| 840 | module_exit(mt9v022_mod_exit); | ||
| 841 | |||
| 842 | MODULE_DESCRIPTION("Micron MT9V022 Camera driver"); | ||
| 843 | MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>"); | ||
| 844 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c index cb5a510f9251..f68e91fbe7fb 100644 --- a/drivers/media/video/mxb.c +++ b/drivers/media/video/mxb.c | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | #define MXB_BOARD_CAN_DO_VBI(dev) (dev->revision != 0) | 38 | #define MXB_BOARD_CAN_DO_VBI(dev) (dev->revision != 0) |
| 39 | 39 | ||
| 40 | /* global variable */ | 40 | /* global variable */ |
| 41 | static int mxb_num = 0; | 41 | static int mxb_num; |
| 42 | 42 | ||
| 43 | /* initial frequence the tuner will be tuned to. | 43 | /* initial frequence the tuner will be tuned to. |
| 44 | in verden (lower saxony, germany) 4148 is a | 44 | in verden (lower saxony, germany) 4148 is a |
| @@ -47,7 +47,7 @@ static int freq = 4148; | |||
| 47 | module_param(freq, int, 0644); | 47 | module_param(freq, int, 0644); |
| 48 | MODULE_PARM_DESC(freq, "initial frequency the tuner will be tuned to while setup"); | 48 | MODULE_PARM_DESC(freq, "initial frequency the tuner will be tuned to while setup"); |
| 49 | 49 | ||
| 50 | static int debug = 0; | 50 | static int debug; |
| 51 | module_param(debug, int, 0644); | 51 | module_param(debug, int, 0644); |
| 52 | MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); | 52 | MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); |
| 53 | 53 | ||
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c index 6590058e8ff0..eafb0c7736e6 100644 --- a/drivers/media/video/ov511.c +++ b/drivers/media/video/ov511.c | |||
| @@ -4659,7 +4659,9 @@ static const struct file_operations ov511_fops = { | |||
| 4659 | .read = ov51x_v4l1_read, | 4659 | .read = ov51x_v4l1_read, |
| 4660 | .mmap = ov51x_v4l1_mmap, | 4660 | .mmap = ov51x_v4l1_mmap, |
| 4661 | .ioctl = ov51x_v4l1_ioctl, | 4661 | .ioctl = ov51x_v4l1_ioctl, |
| 4662 | #ifdef CONFIG_COMPAT | ||
| 4662 | .compat_ioctl = v4l_compat_ioctl32, | 4663 | .compat_ioctl = v4l_compat_ioctl32, |
| 4664 | #endif | ||
| 4663 | .llseek = no_llseek, | 4665 | .llseek = no_llseek, |
| 4664 | }; | 4666 | }; |
| 4665 | 4667 | ||
| @@ -5831,7 +5833,7 @@ ov51x_probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
| 5831 | goto error; | 5833 | goto error; |
| 5832 | 5834 | ||
| 5833 | memcpy(ov->vdev, &vdev_template, sizeof(*ov->vdev)); | 5835 | memcpy(ov->vdev, &vdev_template, sizeof(*ov->vdev)); |
| 5834 | ov->vdev->dev = &dev->dev; | 5836 | ov->vdev->dev = &intf->dev; |
| 5835 | video_set_drvdata(ov->vdev, ov); | 5837 | video_set_drvdata(ov->vdev, ov); |
| 5836 | 5838 | ||
| 5837 | for (i = 0; i < OV511_MAX_UNIT_VIDEO; i++) { | 5839 | for (i = 0; i < OV511_MAX_UNIT_VIDEO; i++) { |
diff --git a/drivers/media/video/ov511.h b/drivers/media/video/ov511.h index 18c64222dd11..1010e51189b7 100644 --- a/drivers/media/video/ov511.h +++ b/drivers/media/video/ov511.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #ifdef OV511_DEBUG | 12 | #ifdef OV511_DEBUG |
| 13 | #define PDEBUG(level, fmt, args...) \ | 13 | #define PDEBUG(level, fmt, args...) \ |
| 14 | if (debug >= (level)) info("[%s:%d] " fmt, \ | 14 | if (debug >= (level)) info("[%s:%d] " fmt, \ |
| 15 | __FUNCTION__, __LINE__ , ## args) | 15 | __func__, __LINE__ , ## args) |
| 16 | #else | 16 | #else |
| 17 | #define PDEBUG(level, fmt, args...) do {} while(0) | 17 | #define PDEBUG(level, fmt, args...) do {} while(0) |
| 18 | #endif | 18 | #endif |
diff --git a/drivers/media/video/ovcamchip/ovcamchip_priv.h b/drivers/media/video/ovcamchip/ovcamchip_priv.h index 50c7763d44b3..9afa4fe47726 100644 --- a/drivers/media/video/ovcamchip/ovcamchip_priv.h +++ b/drivers/media/video/ovcamchip/ovcamchip_priv.h | |||
| @@ -24,11 +24,11 @@ extern int ovcamchip_debug; | |||
| 24 | 24 | ||
| 25 | #define PDEBUG(level, fmt, args...) \ | 25 | #define PDEBUG(level, fmt, args...) \ |
| 26 | if (ovcamchip_debug >= (level)) pr_debug("[%s:%d] " fmt "\n", \ | 26 | if (ovcamchip_debug >= (level)) pr_debug("[%s:%d] " fmt "\n", \ |
| 27 | __FUNCTION__, __LINE__ , ## args) | 27 | __func__, __LINE__ , ## args) |
| 28 | 28 | ||
| 29 | #define DDEBUG(level, dev, fmt, args...) \ | 29 | #define DDEBUG(level, dev, fmt, args...) \ |
| 30 | if (ovcamchip_debug >= (level)) dev_dbg(dev, "[%s:%d] " fmt "\n", \ | 30 | if (ovcamchip_debug >= (level)) dev_dbg(dev, "[%s:%d] " fmt "\n", \ |
| 31 | __FUNCTION__, __LINE__ , ## args) | 31 | __func__, __LINE__ , ## args) |
| 32 | 32 | ||
| 33 | /* Number of times to retry chip detection. Increase this if you are getting | 33 | /* Number of times to retry chip detection. Increase this if you are getting |
| 34 | * "Failed to init camera chip" */ | 34 | * "Failed to init camera chip" */ |
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c index 6820c2aabd30..51b1461d8fb6 100644 --- a/drivers/media/video/pms.c +++ b/drivers/media/video/pms.c | |||
| @@ -57,11 +57,11 @@ struct i2c_info | |||
| 57 | u8 hits; | 57 | u8 hits; |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | static int i2c_count = 0; | 60 | static int i2c_count; |
| 61 | static struct i2c_info i2cinfo[64]; | 61 | static struct i2c_info i2cinfo[64]; |
| 62 | 62 | ||
| 63 | static int decoder = PHILIPS2; | 63 | static int decoder = PHILIPS2; |
| 64 | static int standard = 0; /* 0 - auto 1 - ntsc 2 - pal 3 - secam */ | 64 | static int standard; /* 0 - auto 1 - ntsc 2 - pal 3 - secam */ |
| 65 | 65 | ||
| 66 | /* | 66 | /* |
| 67 | * I/O ports and Shared Memory | 67 | * I/O ports and Shared Memory |
| @@ -885,7 +885,9 @@ static const struct file_operations pms_fops = { | |||
| 885 | .open = video_exclusive_open, | 885 | .open = video_exclusive_open, |
| 886 | .release = video_exclusive_release, | 886 | .release = video_exclusive_release, |
| 887 | .ioctl = pms_ioctl, | 887 | .ioctl = pms_ioctl, |
| 888 | #ifdef CONFIG_COMPAT | ||
| 888 | .compat_ioctl = v4l_compat_ioctl32, | 889 | .compat_ioctl = v4l_compat_ioctl32, |
| 890 | #endif | ||
| 889 | .read = pms_read, | 891 | .read = pms_read, |
| 890 | .llseek = no_llseek, | 892 | .llseek = no_llseek, |
| 891 | }; | 893 | }; |
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig index 6fc1b8be1a1f..a8da90f69dd9 100644 --- a/drivers/media/video/pvrusb2/Kconfig +++ b/drivers/media/video/pvrusb2/Kconfig | |||
| @@ -58,6 +58,30 @@ config VIDEO_PVRUSB2_SYSFS | |||
| 58 | 58 | ||
| 59 | Note: This feature is experimental and subject to change. | 59 | Note: This feature is experimental and subject to change. |
| 60 | 60 | ||
| 61 | config VIDEO_PVRUSB2_DVB | ||
| 62 | bool "pvrusb2 DVB support (EXPERIMENTAL)" | ||
| 63 | default n | ||
| 64 | depends on VIDEO_PVRUSB2 && DVB_CORE && EXPERIMENTAL | ||
| 65 | select DVB_LGDT330X if !DVB_FE_CUSTOMISE | ||
| 66 | select DVB_S5H1409 if !DVB_FE_CUSTOMISE | ||
| 67 | select DVB_TDA10048 if !DVB_FE_CUSTOMIZE | ||
| 68 | select DVB_TDA18271 if !DVB_FE_CUSTOMIZE | ||
| 69 | select TUNER_SIMPLE if !DVB_FE_CUSTOMISE | ||
| 70 | select TUNER_TDA8290 if !DVB_FE_CUSTOMIZE | ||
| 71 | ---help--- | ||
| 72 | |||
| 73 | This option enables compilation of a DVB interface for the | ||
| 74 | pvrusb2 driver. Currently this is very very experimental. | ||
| 75 | It is also limiting - the DVB interface can only access the | ||
| 76 | digital side of hybrid devices, and there are going to be | ||
| 77 | issues if you attempt to mess with the V4L side at the same | ||
| 78 | time. Don't turn this on unless you know what you are | ||
| 79 | doing. | ||
| 80 | |||
| 81 | If you are in doubt, say N. | ||
| 82 | |||
| 83 | Note: This feature is very experimental and might break | ||
| 84 | |||
| 61 | config VIDEO_PVRUSB2_DEBUGIFC | 85 | config VIDEO_PVRUSB2_DEBUGIFC |
| 62 | bool "pvrusb2 debug interface" | 86 | bool "pvrusb2 debug interface" |
| 63 | depends on VIDEO_PVRUSB2_SYSFS | 87 | depends on VIDEO_PVRUSB2_SYSFS |
diff --git a/drivers/media/video/pvrusb2/Makefile b/drivers/media/video/pvrusb2/Makefile index 47284e558648..5b3083c89aa9 100644 --- a/drivers/media/video/pvrusb2/Makefile +++ b/drivers/media/video/pvrusb2/Makefile | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | obj-pvrusb2-sysfs-$(CONFIG_VIDEO_PVRUSB2_SYSFS) := pvrusb2-sysfs.o | 1 | obj-pvrusb2-sysfs-$(CONFIG_VIDEO_PVRUSB2_SYSFS) := pvrusb2-sysfs.o |
| 2 | obj-pvrusb2-debugifc-$(CONFIG_VIDEO_PVRUSB2_DEBUGIFC) := pvrusb2-debugifc.o | 2 | obj-pvrusb2-debugifc-$(CONFIG_VIDEO_PVRUSB2_DEBUGIFC) := pvrusb2-debugifc.o |
| 3 | obj-pvrusb2-dvb-$(CONFIG_VIDEO_PVRUSB2_DVB) := pvrusb2-dvb.o | ||
| 3 | 4 | ||
| 4 | pvrusb2-objs := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \ | 5 | pvrusb2-objs := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \ |
| 5 | pvrusb2-audio.o pvrusb2-i2c-chips-v4l2.o \ | 6 | pvrusb2-audio.o pvrusb2-i2c-chips-v4l2.o \ |
| @@ -9,6 +10,11 @@ pvrusb2-objs := pvrusb2-i2c-core.o pvrusb2-i2c-cmd-v4l2.o \ | |||
| 9 | pvrusb2-ctrl.o pvrusb2-std.o pvrusb2-devattr.o \ | 10 | pvrusb2-ctrl.o pvrusb2-std.o pvrusb2-devattr.o \ |
| 10 | pvrusb2-context.o pvrusb2-io.o pvrusb2-ioread.o \ | 11 | pvrusb2-context.o pvrusb2-io.o pvrusb2-ioread.o \ |
| 11 | pvrusb2-cx2584x-v4l.o pvrusb2-wm8775.o \ | 12 | pvrusb2-cx2584x-v4l.o pvrusb2-wm8775.o \ |
| 13 | $(obj-pvrusb2-dvb-y) \ | ||
| 12 | $(obj-pvrusb2-sysfs-y) $(obj-pvrusb2-debugifc-y) | 14 | $(obj-pvrusb2-sysfs-y) $(obj-pvrusb2-debugifc-y) |
| 13 | 15 | ||
| 14 | obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2.o | 16 | obj-$(CONFIG_VIDEO_PVRUSB2) += pvrusb2.o |
| 17 | |||
| 18 | EXTRA_CFLAGS += -Idrivers/media/video | ||
| 19 | EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core | ||
| 20 | EXTRA_CFLAGS += -Idrivers/media/dvb/frontends | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.c b/drivers/media/video/pvrusb2/pvrusb2-context.c index 160437b21e6d..b5db6a5bab31 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-context.c +++ b/drivers/media/video/pvrusb2/pvrusb2-context.c | |||
| @@ -23,39 +23,193 @@ | |||
| 23 | #include "pvrusb2-ioread.h" | 23 | #include "pvrusb2-ioread.h" |
| 24 | #include "pvrusb2-hdw.h" | 24 | #include "pvrusb2-hdw.h" |
| 25 | #include "pvrusb2-debug.h" | 25 | #include "pvrusb2-debug.h" |
| 26 | #include <linux/wait.h> | ||
| 27 | #include <linux/kthread.h> | ||
| 26 | #include <linux/errno.h> | 28 | #include <linux/errno.h> |
| 27 | #include <linux/string.h> | 29 | #include <linux/string.h> |
| 28 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
| 29 | 31 | ||
| 32 | static struct pvr2_context *pvr2_context_exist_first; | ||
| 33 | static struct pvr2_context *pvr2_context_exist_last; | ||
| 34 | static struct pvr2_context *pvr2_context_notify_first; | ||
| 35 | static struct pvr2_context *pvr2_context_notify_last; | ||
| 36 | static DEFINE_MUTEX(pvr2_context_mutex); | ||
| 37 | static DECLARE_WAIT_QUEUE_HEAD(pvr2_context_sync_data); | ||
| 38 | static DECLARE_WAIT_QUEUE_HEAD(pvr2_context_cleanup_data); | ||
| 39 | static int pvr2_context_cleanup_flag; | ||
| 40 | static int pvr2_context_cleaned_flag; | ||
| 41 | static struct task_struct *pvr2_context_thread_ptr; | ||
| 42 | |||
| 43 | |||
| 44 | static void pvr2_context_set_notify(struct pvr2_context *mp, int fl) | ||
| 45 | { | ||
| 46 | int signal_flag = 0; | ||
| 47 | mutex_lock(&pvr2_context_mutex); | ||
| 48 | if (fl) { | ||
| 49 | if (!mp->notify_flag) { | ||
| 50 | signal_flag = (pvr2_context_notify_first == NULL); | ||
| 51 | mp->notify_prev = pvr2_context_notify_last; | ||
| 52 | mp->notify_next = NULL; | ||
| 53 | pvr2_context_notify_last = mp; | ||
| 54 | if (mp->notify_prev) { | ||
| 55 | mp->notify_prev->notify_next = mp; | ||
| 56 | } else { | ||
| 57 | pvr2_context_notify_first = mp; | ||
| 58 | } | ||
| 59 | mp->notify_flag = !0; | ||
| 60 | } | ||
| 61 | } else { | ||
| 62 | if (mp->notify_flag) { | ||
| 63 | mp->notify_flag = 0; | ||
| 64 | if (mp->notify_next) { | ||
| 65 | mp->notify_next->notify_prev = mp->notify_prev; | ||
| 66 | } else { | ||
| 67 | pvr2_context_notify_last = mp->notify_prev; | ||
| 68 | } | ||
| 69 | if (mp->notify_prev) { | ||
| 70 | mp->notify_prev->notify_next = mp->notify_next; | ||
| 71 | } else { | ||
| 72 | pvr2_context_notify_first = mp->notify_next; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
| 76 | mutex_unlock(&pvr2_context_mutex); | ||
| 77 | if (signal_flag) wake_up(&pvr2_context_sync_data); | ||
| 78 | } | ||
| 79 | |||
| 30 | 80 | ||
| 31 | static void pvr2_context_destroy(struct pvr2_context *mp) | 81 | static void pvr2_context_destroy(struct pvr2_context *mp) |
| 32 | { | 82 | { |
| 33 | pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr_main id=%p",mp); | 83 | pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context %p (destroy)",mp); |
| 34 | if (mp->hdw) pvr2_hdw_destroy(mp->hdw); | 84 | if (mp->hdw) pvr2_hdw_destroy(mp->hdw); |
| 85 | pvr2_context_set_notify(mp, 0); | ||
| 86 | mutex_lock(&pvr2_context_mutex); | ||
| 87 | if (mp->exist_next) { | ||
| 88 | mp->exist_next->exist_prev = mp->exist_prev; | ||
| 89 | } else { | ||
| 90 | pvr2_context_exist_last = mp->exist_prev; | ||
| 91 | } | ||
| 92 | if (mp->exist_prev) { | ||
| 93 | mp->exist_prev->exist_next = mp->exist_next; | ||
| 94 | } else { | ||
| 95 | pvr2_context_exist_first = mp->exist_next; | ||
| 96 | } | ||
| 97 | if (!pvr2_context_exist_first) { | ||
| 98 | /* Trigger wakeup on control thread in case it is waiting | ||
| 99 | for an exit condition. */ | ||
| 100 | wake_up(&pvr2_context_sync_data); | ||
| 101 | } | ||
| 102 | mutex_unlock(&pvr2_context_mutex); | ||
| 35 | kfree(mp); | 103 | kfree(mp); |
| 36 | } | 104 | } |
| 37 | 105 | ||
| 38 | 106 | ||
| 39 | static void pvr2_context_state_check(struct pvr2_context *mp) | 107 | static void pvr2_context_notify(struct pvr2_context *mp) |
| 40 | { | 108 | { |
| 41 | if (mp->init_flag) return; | 109 | pvr2_context_set_notify(mp,!0); |
| 110 | } | ||
| 111 | |||
| 42 | 112 | ||
| 43 | switch (pvr2_hdw_get_state(mp->hdw)) { | 113 | static void pvr2_context_check(struct pvr2_context *mp) |
| 44 | case PVR2_STATE_WARM: break; | 114 | { |
| 45 | case PVR2_STATE_ERROR: break; | 115 | struct pvr2_channel *ch1, *ch2; |
| 46 | case PVR2_STATE_READY: break; | 116 | pvr2_trace(PVR2_TRACE_CTXT, |
| 47 | case PVR2_STATE_RUN: break; | 117 | "pvr2_context %p (notify)", mp); |
| 48 | default: return; | 118 | if (!mp->initialized_flag && !mp->disconnect_flag) { |
| 119 | mp->initialized_flag = !0; | ||
| 120 | pvr2_trace(PVR2_TRACE_CTXT, | ||
| 121 | "pvr2_context %p (initialize)", mp); | ||
| 122 | /* Finish hardware initialization */ | ||
| 123 | if (pvr2_hdw_initialize(mp->hdw, | ||
| 124 | (void (*)(void *))pvr2_context_notify, | ||
| 125 | mp)) { | ||
| 126 | mp->video_stream.stream = | ||
| 127 | pvr2_hdw_get_video_stream(mp->hdw); | ||
| 128 | /* Trigger interface initialization. By doing this | ||
| 129 | here initialization runs in our own safe and | ||
| 130 | cozy thread context. */ | ||
| 131 | if (mp->setup_func) mp->setup_func(mp); | ||
| 132 | } else { | ||
| 133 | pvr2_trace(PVR2_TRACE_CTXT, | ||
| 134 | "pvr2_context %p (thread skipping setup)", | ||
| 135 | mp); | ||
| 136 | /* Even though initialization did not succeed, | ||
| 137 | we're still going to continue anyway. We need | ||
| 138 | to do this in order to await the expected | ||
| 139 | disconnect (which we will detect in the normal | ||
| 140 | course of operation). */ | ||
| 141 | } | ||
| 49 | } | 142 | } |
| 50 | 143 | ||
| 51 | pvr2_context_enter(mp); do { | 144 | for (ch1 = mp->mc_first; ch1; ch1 = ch2) { |
| 52 | mp->init_flag = !0; | 145 | ch2 = ch1->mc_next; |
| 53 | mp->video_stream.stream = pvr2_hdw_get_video_stream(mp->hdw); | 146 | if (ch1->check_func) ch1->check_func(ch1); |
| 54 | if (mp->setup_func) { | 147 | } |
| 55 | mp->setup_func(mp); | 148 | |
| 149 | if (mp->disconnect_flag && !mp->mc_first) { | ||
| 150 | /* Go away... */ | ||
| 151 | pvr2_context_destroy(mp); | ||
| 152 | return; | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | |||
| 157 | static int pvr2_context_shutok(void) | ||
| 158 | { | ||
| 159 | return pvr2_context_cleanup_flag && (pvr2_context_exist_first == NULL); | ||
| 160 | } | ||
| 161 | |||
| 162 | |||
| 163 | static int pvr2_context_thread_func(void *foo) | ||
| 164 | { | ||
| 165 | struct pvr2_context *mp; | ||
| 166 | |||
| 167 | pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context thread start"); | ||
| 168 | |||
| 169 | do { | ||
| 170 | while ((mp = pvr2_context_notify_first) != NULL) { | ||
| 171 | pvr2_context_set_notify(mp, 0); | ||
| 172 | pvr2_context_check(mp); | ||
| 56 | } | 173 | } |
| 57 | } while (0); pvr2_context_exit(mp); | 174 | wait_event_interruptible( |
| 58 | } | 175 | pvr2_context_sync_data, |
| 176 | ((pvr2_context_notify_first != NULL) || | ||
| 177 | pvr2_context_shutok())); | ||
| 178 | } while (!pvr2_context_shutok()); | ||
| 179 | |||
| 180 | pvr2_context_cleaned_flag = !0; | ||
| 181 | wake_up(&pvr2_context_cleanup_data); | ||
| 182 | |||
| 183 | pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context thread cleaned up"); | ||
| 184 | |||
| 185 | wait_event_interruptible( | ||
| 186 | pvr2_context_sync_data, | ||
| 187 | kthread_should_stop()); | ||
| 188 | |||
| 189 | pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context thread end"); | ||
| 190 | |||
| 191 | return 0; | ||
| 192 | } | ||
| 193 | |||
| 194 | |||
| 195 | int pvr2_context_global_init(void) | ||
| 196 | { | ||
| 197 | pvr2_context_thread_ptr = kthread_run(pvr2_context_thread_func, | ||
| 198 | 0, | ||
| 199 | "pvrusb2-context"); | ||
| 200 | return (pvr2_context_thread_ptr ? 0 : -ENOMEM); | ||
| 201 | } | ||
| 202 | |||
| 203 | |||
| 204 | void pvr2_context_global_done(void) | ||
| 205 | { | ||
| 206 | pvr2_context_cleanup_flag = !0; | ||
| 207 | wake_up(&pvr2_context_sync_data); | ||
| 208 | wait_event_interruptible( | ||
| 209 | pvr2_context_cleanup_data, | ||
| 210 | pvr2_context_cleaned_flag); | ||
| 211 | kthread_stop(pvr2_context_thread_ptr); | ||
| 212 | } | ||
| 59 | 213 | ||
| 60 | 214 | ||
| 61 | struct pvr2_context *pvr2_context_create( | 215 | struct pvr2_context *pvr2_context_create( |
| @@ -66,67 +220,75 @@ struct pvr2_context *pvr2_context_create( | |||
| 66 | struct pvr2_context *mp = NULL; | 220 | struct pvr2_context *mp = NULL; |
| 67 | mp = kzalloc(sizeof(*mp),GFP_KERNEL); | 221 | mp = kzalloc(sizeof(*mp),GFP_KERNEL); |
| 68 | if (!mp) goto done; | 222 | if (!mp) goto done; |
| 69 | pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_main id=%p",mp); | 223 | pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context %p (create)",mp); |
| 70 | mp->setup_func = setup_func; | 224 | mp->setup_func = setup_func; |
| 71 | mutex_init(&mp->mutex); | 225 | mutex_init(&mp->mutex); |
| 226 | mutex_lock(&pvr2_context_mutex); | ||
| 227 | mp->exist_prev = pvr2_context_exist_last; | ||
| 228 | mp->exist_next = NULL; | ||
| 229 | pvr2_context_exist_last = mp; | ||
| 230 | if (mp->exist_prev) { | ||
| 231 | mp->exist_prev->exist_next = mp; | ||
| 232 | } else { | ||
| 233 | pvr2_context_exist_first = mp; | ||
| 234 | } | ||
| 235 | mutex_unlock(&pvr2_context_mutex); | ||
| 72 | mp->hdw = pvr2_hdw_create(intf,devid); | 236 | mp->hdw = pvr2_hdw_create(intf,devid); |
| 73 | if (!mp->hdw) { | 237 | if (!mp->hdw) { |
| 74 | pvr2_context_destroy(mp); | 238 | pvr2_context_destroy(mp); |
| 75 | mp = NULL; | 239 | mp = NULL; |
| 76 | goto done; | 240 | goto done; |
| 77 | } | 241 | } |
| 78 | pvr2_hdw_set_state_callback(mp->hdw, | 242 | pvr2_context_set_notify(mp, !0); |
| 79 | (void (*)(void *))pvr2_context_state_check, | ||
| 80 | mp); | ||
| 81 | pvr2_context_state_check(mp); | ||
| 82 | done: | 243 | done: |
| 83 | return mp; | 244 | return mp; |
| 84 | } | 245 | } |
| 85 | 246 | ||
| 86 | 247 | ||
| 87 | void pvr2_context_enter(struct pvr2_context *mp) | 248 | static void pvr2_context_reset_input_limits(struct pvr2_context *mp) |
| 249 | { | ||
| 250 | unsigned int tmsk,mmsk; | ||
| 251 | struct pvr2_channel *cp; | ||
| 252 | struct pvr2_hdw *hdw = mp->hdw; | ||
| 253 | mmsk = pvr2_hdw_get_input_available(hdw); | ||
| 254 | tmsk = mmsk; | ||
| 255 | for (cp = mp->mc_first; cp; cp = cp->mc_next) { | ||
| 256 | if (!cp->input_mask) continue; | ||
| 257 | tmsk &= cp->input_mask; | ||
| 258 | } | ||
| 259 | pvr2_hdw_set_input_allowed(hdw,mmsk,tmsk); | ||
| 260 | pvr2_hdw_commit_ctl(hdw); | ||
| 261 | } | ||
| 262 | |||
| 263 | |||
| 264 | static void pvr2_context_enter(struct pvr2_context *mp) | ||
| 88 | { | 265 | { |
| 89 | mutex_lock(&mp->mutex); | 266 | mutex_lock(&mp->mutex); |
| 90 | pvr2_trace(PVR2_TRACE_CREG,"pvr2_context_enter(id=%p)",mp); | ||
| 91 | } | 267 | } |
| 92 | 268 | ||
| 93 | 269 | ||
| 94 | void pvr2_context_exit(struct pvr2_context *mp) | 270 | static void pvr2_context_exit(struct pvr2_context *mp) |
| 95 | { | 271 | { |
| 96 | int destroy_flag = 0; | 272 | int destroy_flag = 0; |
| 97 | if (!(mp->mc_first || !mp->disconnect_flag)) { | 273 | if (!(mp->mc_first || !mp->disconnect_flag)) { |
| 98 | destroy_flag = !0; | 274 | destroy_flag = !0; |
| 99 | } | 275 | } |
| 100 | pvr2_trace(PVR2_TRACE_CREG,"pvr2_context_exit(id=%p) outside",mp); | ||
| 101 | mutex_unlock(&mp->mutex); | 276 | mutex_unlock(&mp->mutex); |
| 102 | if (destroy_flag) pvr2_context_destroy(mp); | 277 | if (destroy_flag) pvr2_context_notify(mp); |
| 103 | } | ||
| 104 | |||
| 105 | |||
| 106 | static void pvr2_context_run_checks(struct pvr2_context *mp) | ||
| 107 | { | ||
| 108 | struct pvr2_channel *ch1,*ch2; | ||
| 109 | for (ch1 = mp->mc_first; ch1; ch1 = ch2) { | ||
| 110 | ch2 = ch1->mc_next; | ||
| 111 | if (ch1->check_func) { | ||
| 112 | ch1->check_func(ch1); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | } | 278 | } |
| 116 | 279 | ||
| 117 | 280 | ||
| 118 | void pvr2_context_disconnect(struct pvr2_context *mp) | 281 | void pvr2_context_disconnect(struct pvr2_context *mp) |
| 119 | { | 282 | { |
| 120 | pvr2_context_enter(mp); do { | 283 | pvr2_hdw_disconnect(mp->hdw); |
| 121 | pvr2_hdw_disconnect(mp->hdw); | 284 | mp->disconnect_flag = !0; |
| 122 | mp->disconnect_flag = !0; | 285 | pvr2_context_notify(mp); |
| 123 | pvr2_context_run_checks(mp); | ||
| 124 | } while (0); pvr2_context_exit(mp); | ||
| 125 | } | 286 | } |
| 126 | 287 | ||
| 127 | 288 | ||
| 128 | void pvr2_channel_init(struct pvr2_channel *cp,struct pvr2_context *mp) | 289 | void pvr2_channel_init(struct pvr2_channel *cp,struct pvr2_context *mp) |
| 129 | { | 290 | { |
| 291 | pvr2_context_enter(mp); | ||
| 130 | cp->hdw = mp->hdw; | 292 | cp->hdw = mp->hdw; |
| 131 | cp->mc_head = mp; | 293 | cp->mc_head = mp; |
| 132 | cp->mc_next = NULL; | 294 | cp->mc_next = NULL; |
| @@ -137,6 +299,7 @@ void pvr2_channel_init(struct pvr2_channel *cp,struct pvr2_context *mp) | |||
| 137 | mp->mc_first = cp; | 299 | mp->mc_first = cp; |
| 138 | } | 300 | } |
| 139 | mp->mc_last = cp; | 301 | mp->mc_last = cp; |
| 302 | pvr2_context_exit(mp); | ||
| 140 | } | 303 | } |
| 141 | 304 | ||
| 142 | 305 | ||
| @@ -152,7 +315,10 @@ static void pvr2_channel_disclaim_stream(struct pvr2_channel *cp) | |||
| 152 | void pvr2_channel_done(struct pvr2_channel *cp) | 315 | void pvr2_channel_done(struct pvr2_channel *cp) |
| 153 | { | 316 | { |
| 154 | struct pvr2_context *mp = cp->mc_head; | 317 | struct pvr2_context *mp = cp->mc_head; |
| 318 | pvr2_context_enter(mp); | ||
| 319 | cp->input_mask = 0; | ||
| 155 | pvr2_channel_disclaim_stream(cp); | 320 | pvr2_channel_disclaim_stream(cp); |
| 321 | pvr2_context_reset_input_limits(mp); | ||
| 156 | if (cp->mc_next) { | 322 | if (cp->mc_next) { |
| 157 | cp->mc_next->mc_prev = cp->mc_prev; | 323 | cp->mc_next->mc_prev = cp->mc_prev; |
| 158 | } else { | 324 | } else { |
| @@ -164,6 +330,58 @@ void pvr2_channel_done(struct pvr2_channel *cp) | |||
| 164 | mp->mc_first = cp->mc_next; | 330 | mp->mc_first = cp->mc_next; |
| 165 | } | 331 | } |
| 166 | cp->hdw = NULL; | 332 | cp->hdw = NULL; |
| 333 | pvr2_context_exit(mp); | ||
| 334 | } | ||
| 335 | |||
| 336 | |||
| 337 | int pvr2_channel_limit_inputs(struct pvr2_channel *cp,unsigned int cmsk) | ||
| 338 | { | ||
| 339 | unsigned int tmsk,mmsk; | ||
| 340 | int ret = 0; | ||
| 341 | struct pvr2_channel *p2; | ||
| 342 | struct pvr2_hdw *hdw = cp->hdw; | ||
| 343 | |||
| 344 | mmsk = pvr2_hdw_get_input_available(hdw); | ||
| 345 | cmsk &= mmsk; | ||
| 346 | if (cmsk == cp->input_mask) { | ||
| 347 | /* No change; nothing to do */ | ||
| 348 | return 0; | ||
| 349 | } | ||
| 350 | |||
| 351 | pvr2_context_enter(cp->mc_head); | ||
| 352 | do { | ||
| 353 | if (!cmsk) { | ||
| 354 | cp->input_mask = 0; | ||
| 355 | pvr2_context_reset_input_limits(cp->mc_head); | ||
| 356 | break; | ||
| 357 | } | ||
| 358 | tmsk = mmsk; | ||
| 359 | for (p2 = cp->mc_head->mc_first; p2; p2 = p2->mc_next) { | ||
| 360 | if (p2 == cp) continue; | ||
| 361 | if (!p2->input_mask) continue; | ||
| 362 | tmsk &= p2->input_mask; | ||
| 363 | } | ||
| 364 | if (!(tmsk & cmsk)) { | ||
| 365 | ret = -EPERM; | ||
| 366 | break; | ||
| 367 | } | ||
| 368 | tmsk &= cmsk; | ||
| 369 | if ((ret = pvr2_hdw_set_input_allowed(hdw,mmsk,tmsk)) != 0) { | ||
| 370 | /* Internal failure changing allowed list; probably | ||
| 371 | should not happen, but react if it does. */ | ||
| 372 | break; | ||
| 373 | } | ||
| 374 | cp->input_mask = cmsk; | ||
| 375 | pvr2_hdw_commit_ctl(hdw); | ||
| 376 | } while (0); | ||
| 377 | pvr2_context_exit(cp->mc_head); | ||
| 378 | return ret; | ||
| 379 | } | ||
| 380 | |||
| 381 | |||
| 382 | unsigned int pvr2_channel_get_limited_inputs(struct pvr2_channel *cp) | ||
| 383 | { | ||
| 384 | return cp->input_mask; | ||
| 167 | } | 385 | } |
| 168 | 386 | ||
| 169 | 387 | ||
| @@ -173,7 +391,7 @@ int pvr2_channel_claim_stream(struct pvr2_channel *cp, | |||
| 173 | int code = 0; | 391 | int code = 0; |
| 174 | pvr2_context_enter(cp->mc_head); do { | 392 | pvr2_context_enter(cp->mc_head); do { |
| 175 | if (sp == cp->stream) break; | 393 | if (sp == cp->stream) break; |
| 176 | if (sp->user) { | 394 | if (sp && sp->user) { |
| 177 | code = -EBUSY; | 395 | code = -EBUSY; |
| 178 | break; | 396 | break; |
| 179 | } | 397 | } |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.h b/drivers/media/video/pvrusb2/pvrusb2-context.h index a04187a93225..745e270233c2 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-context.h +++ b/drivers/media/video/pvrusb2/pvrusb2-context.h | |||
| @@ -30,7 +30,6 @@ struct pvr2_stream; /* stream interface - defined elsewhere */ | |||
| 30 | struct pvr2_context; /* All central state */ | 30 | struct pvr2_context; /* All central state */ |
| 31 | struct pvr2_channel; /* One I/O pathway to a user */ | 31 | struct pvr2_channel; /* One I/O pathway to a user */ |
| 32 | struct pvr2_context_stream; /* Wrapper for a stream */ | 32 | struct pvr2_context_stream; /* Wrapper for a stream */ |
| 33 | struct pvr2_crit_reg; /* Critical region pointer */ | ||
| 34 | struct pvr2_ioread; /* Low level stream structure */ | 33 | struct pvr2_ioread; /* Low level stream structure */ |
| 35 | 34 | ||
| 36 | struct pvr2_context_stream { | 35 | struct pvr2_context_stream { |
| @@ -41,11 +40,16 @@ struct pvr2_context_stream { | |||
| 41 | struct pvr2_context { | 40 | struct pvr2_context { |
| 42 | struct pvr2_channel *mc_first; | 41 | struct pvr2_channel *mc_first; |
| 43 | struct pvr2_channel *mc_last; | 42 | struct pvr2_channel *mc_last; |
| 43 | struct pvr2_context *exist_next; | ||
| 44 | struct pvr2_context *exist_prev; | ||
| 45 | struct pvr2_context *notify_next; | ||
| 46 | struct pvr2_context *notify_prev; | ||
| 44 | struct pvr2_hdw *hdw; | 47 | struct pvr2_hdw *hdw; |
| 45 | struct pvr2_context_stream video_stream; | 48 | struct pvr2_context_stream video_stream; |
| 46 | struct mutex mutex; | 49 | struct mutex mutex; |
| 50 | int notify_flag; | ||
| 51 | int initialized_flag; | ||
| 47 | int disconnect_flag; | 52 | int disconnect_flag; |
| 48 | int init_flag; | ||
| 49 | 53 | ||
| 50 | /* Called after pvr2_context initialization is complete */ | 54 | /* Called after pvr2_context initialization is complete */ |
| 51 | void (*setup_func)(struct pvr2_context *); | 55 | void (*setup_func)(struct pvr2_context *); |
| @@ -58,12 +62,10 @@ struct pvr2_channel { | |||
| 58 | struct pvr2_channel *mc_prev; | 62 | struct pvr2_channel *mc_prev; |
| 59 | struct pvr2_context_stream *stream; | 63 | struct pvr2_context_stream *stream; |
| 60 | struct pvr2_hdw *hdw; | 64 | struct pvr2_hdw *hdw; |
| 65 | unsigned int input_mask; | ||
| 61 | void (*check_func)(struct pvr2_channel *); | 66 | void (*check_func)(struct pvr2_channel *); |
| 62 | }; | 67 | }; |
| 63 | 68 | ||
| 64 | void pvr2_context_enter(struct pvr2_context *); | ||
| 65 | void pvr2_context_exit(struct pvr2_context *); | ||
| 66 | |||
| 67 | struct pvr2_context *pvr2_context_create(struct usb_interface *intf, | 69 | struct pvr2_context *pvr2_context_create(struct usb_interface *intf, |
| 68 | const struct usb_device_id *devid, | 70 | const struct usb_device_id *devid, |
| 69 | void (*setup_func)(struct pvr2_context *)); | 71 | void (*setup_func)(struct pvr2_context *)); |
| @@ -71,11 +73,15 @@ void pvr2_context_disconnect(struct pvr2_context *); | |||
| 71 | 73 | ||
| 72 | void pvr2_channel_init(struct pvr2_channel *,struct pvr2_context *); | 74 | void pvr2_channel_init(struct pvr2_channel *,struct pvr2_context *); |
| 73 | void pvr2_channel_done(struct pvr2_channel *); | 75 | void pvr2_channel_done(struct pvr2_channel *); |
| 76 | int pvr2_channel_limit_inputs(struct pvr2_channel *,unsigned int); | ||
| 77 | unsigned int pvr2_channel_get_limited_inputs(struct pvr2_channel *); | ||
| 74 | int pvr2_channel_claim_stream(struct pvr2_channel *, | 78 | int pvr2_channel_claim_stream(struct pvr2_channel *, |
| 75 | struct pvr2_context_stream *); | 79 | struct pvr2_context_stream *); |
| 76 | struct pvr2_ioread *pvr2_channel_create_mpeg_stream( | 80 | struct pvr2_ioread *pvr2_channel_create_mpeg_stream( |
| 77 | struct pvr2_context_stream *); | 81 | struct pvr2_context_stream *); |
| 78 | 82 | ||
| 83 | int pvr2_context_global_init(void); | ||
| 84 | void pvr2_context_global_done(void); | ||
| 79 | 85 | ||
| 80 | #endif /* __PVRUSB2_CONTEXT_H */ | 86 | #endif /* __PVRUSB2_CONTEXT_H */ |
| 81 | /* | 87 | /* |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c index 5a3e8d21a38a..91a42f2473a7 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c +++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c | |||
| @@ -30,6 +30,9 @@ static int pvr2_ctrl_range_check(struct pvr2_ctrl *cptr,int val) | |||
| 30 | { | 30 | { |
| 31 | if (cptr->info->check_value) { | 31 | if (cptr->info->check_value) { |
| 32 | if (!cptr->info->check_value(cptr,val)) return -ERANGE; | 32 | if (!cptr->info->check_value(cptr,val)) return -ERANGE; |
| 33 | } else if (cptr->info->type == pvr2_ctl_enum) { | ||
| 34 | if (val < 0) return -ERANGE; | ||
| 35 | if (val >= cptr->info->def.type_enum.count) return -ERANGE; | ||
| 33 | } else { | 36 | } else { |
| 34 | int lim; | 37 | int lim; |
| 35 | lim = cptr->info->def.type_int.min_value; | 38 | lim = cptr->info->def.type_int.min_value; |
| @@ -63,13 +66,10 @@ int pvr2_ctrl_set_mask_value(struct pvr2_ctrl *cptr,int mask,int val) | |||
| 63 | if (cptr->info->set_value) { | 66 | if (cptr->info->set_value) { |
| 64 | if (cptr->info->type == pvr2_ctl_bitmask) { | 67 | if (cptr->info->type == pvr2_ctl_bitmask) { |
| 65 | mask &= cptr->info->def.type_bitmask.valid_bits; | 68 | mask &= cptr->info->def.type_bitmask.valid_bits; |
| 66 | } else if (cptr->info->type == pvr2_ctl_int) { | 69 | } else if ((cptr->info->type == pvr2_ctl_int)|| |
| 70 | (cptr->info->type == pvr2_ctl_enum)) { | ||
| 67 | ret = pvr2_ctrl_range_check(cptr,val); | 71 | ret = pvr2_ctrl_range_check(cptr,val); |
| 68 | if (ret < 0) break; | 72 | if (ret < 0) break; |
| 69 | } else if (cptr->info->type == pvr2_ctl_enum) { | ||
| 70 | if (val >= cptr->info->def.type_enum.count) { | ||
| 71 | break; | ||
| 72 | } | ||
| 73 | } else if (cptr->info->type != pvr2_ctl_bool) { | 73 | } else if (cptr->info->type != pvr2_ctl_bool) { |
| 74 | break; | 74 | break; |
| 75 | } | 75 | } |
| @@ -204,8 +204,7 @@ int pvr2_ctrl_get_valname(struct pvr2_ctrl *cptr,int val, | |||
| 204 | if (cptr->info->type == pvr2_ctl_enum) { | 204 | if (cptr->info->type == pvr2_ctl_enum) { |
| 205 | const char **names; | 205 | const char **names; |
| 206 | names = cptr->info->def.type_enum.value_names; | 206 | names = cptr->info->def.type_enum.value_names; |
| 207 | if ((val >= 0) && | 207 | if (pvr2_ctrl_range_check(cptr,val) == 0) { |
| 208 | (val < cptr->info->def.type_enum.count)) { | ||
| 209 | if (names[val]) { | 208 | if (names[val]) { |
| 210 | *blen = scnprintf( | 209 | *blen = scnprintf( |
| 211 | bptr,bmax,"%s", | 210 | bptr,bmax,"%s", |
| @@ -528,10 +527,8 @@ int pvr2_ctrl_sym_to_value(struct pvr2_ctrl *cptr, | |||
| 528 | ptr,len,valptr, | 527 | ptr,len,valptr, |
| 529 | cptr->info->def.type_enum.value_names, | 528 | cptr->info->def.type_enum.value_names, |
| 530 | cptr->info->def.type_enum.count); | 529 | cptr->info->def.type_enum.count); |
| 531 | if ((ret >= 0) && | 530 | if (ret >= 0) { |
| 532 | ((*valptr < 0) || | 531 | ret = pvr2_ctrl_range_check(cptr,*valptr); |
| 533 | (*valptr >= cptr->info->def.type_enum.count))) { | ||
| 534 | ret = -ERANGE; | ||
| 535 | } | 532 | } |
| 536 | if (maskptr) *maskptr = ~0; | 533 | if (maskptr) *maskptr = ~0; |
| 537 | } else if (cptr->info->type == pvr2_ctl_bitmask) { | 534 | } else if (cptr->info->type == pvr2_ctl_bitmask) { |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c index ffdc45c324e5..97350b048b8d 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c +++ b/drivers/media/video/pvrusb2/pvrusb2-cx2584x-v4l.c | |||
| @@ -84,7 +84,9 @@ static const struct routing_scheme_item routing_schemegv[] = { | |||
| 84 | .vid = CX25840_COMPOSITE2, | 84 | .vid = CX25840_COMPOSITE2, |
| 85 | .aud = CX25840_AUDIO5, | 85 | .aud = CX25840_AUDIO5, |
| 86 | }, | 86 | }, |
| 87 | [PVR2_CVAL_INPUT_RADIO] = { /* Treat the same as composite */ | 87 | [PVR2_CVAL_INPUT_RADIO] = { |
| 88 | /* line-in is used for radio and composite. A GPIO is | ||
| 89 | used to switch between the two choices. */ | ||
| 88 | .vid = CX25840_COMPOSITE1, | 90 | .vid = CX25840_COMPOSITE1, |
| 89 | .aud = CX25840_AUDIO_SERIAL, | 91 | .aud = CX25840_AUDIO_SERIAL, |
| 90 | }, | 92 | }, |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-debug.h b/drivers/media/video/pvrusb2/pvrusb2-debug.h index fca49d8a9311..11537ddf8aa3 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-debug.h +++ b/drivers/media/video/pvrusb2/pvrusb2-debug.h | |||
| @@ -39,7 +39,7 @@ extern int pvrusb2_debug; | |||
| 39 | #define PVR2_TRACE_EEPROM (1 << 10) /* eeprom parsing / report */ | 39 | #define PVR2_TRACE_EEPROM (1 << 10) /* eeprom parsing / report */ |
| 40 | #define PVR2_TRACE_STRUCT (1 << 11) /* internal struct creation */ | 40 | #define PVR2_TRACE_STRUCT (1 << 11) /* internal struct creation */ |
| 41 | #define PVR2_TRACE_OPEN_CLOSE (1 << 12) /* application open / close */ | 41 | #define PVR2_TRACE_OPEN_CLOSE (1 << 12) /* application open / close */ |
| 42 | #define PVR2_TRACE_CREG (1 << 13) /* Main critical region entry / exit */ | 42 | #define PVR2_TRACE_CTXT (1 << 13) /* Main context tracking */ |
| 43 | #define PVR2_TRACE_SYSFS (1 << 14) /* Sysfs driven I/O */ | 43 | #define PVR2_TRACE_SYSFS (1 << 14) /* Sysfs driven I/O */ |
| 44 | #define PVR2_TRACE_FIRMWARE (1 << 15) /* firmware upload actions */ | 44 | #define PVR2_TRACE_FIRMWARE (1 << 15) /* firmware upload actions */ |
| 45 | #define PVR2_TRACE_CHIPS (1 << 16) /* chip broadcast operation */ | 45 | #define PVR2_TRACE_CHIPS (1 << 16) /* chip broadcast operation */ |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-debugifc.c b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c index b0687430fdd4..b53121c78ff9 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-debugifc.c +++ b/drivers/media/video/pvrusb2/pvrusb2-debugifc.c | |||
| @@ -164,6 +164,8 @@ int pvr2_debugifc_print_status(struct pvr2_hdw *hdw, | |||
| 164 | int ccnt; | 164 | int ccnt; |
| 165 | int ret; | 165 | int ret; |
| 166 | u32 gpio_dir,gpio_in,gpio_out; | 166 | u32 gpio_dir,gpio_in,gpio_out; |
| 167 | struct pvr2_stream_stats stats; | ||
| 168 | struct pvr2_stream *sp; | ||
| 167 | 169 | ||
| 168 | ret = pvr2_hdw_is_hsm(hdw); | 170 | ret = pvr2_hdw_is_hsm(hdw); |
| 169 | ccnt = scnprintf(buf,acnt,"USB link speed: %s\n", | 171 | ccnt = scnprintf(buf,acnt,"USB link speed: %s\n", |
| @@ -182,6 +184,24 @@ int pvr2_debugifc_print_status(struct pvr2_hdw *hdw, | |||
| 182 | pvr2_hdw_get_streaming(hdw) ? "on" : "off"); | 184 | pvr2_hdw_get_streaming(hdw) ? "on" : "off"); |
| 183 | bcnt += ccnt; acnt -= ccnt; buf += ccnt; | 185 | bcnt += ccnt; acnt -= ccnt; buf += ccnt; |
| 184 | 186 | ||
| 187 | |||
| 188 | sp = pvr2_hdw_get_video_stream(hdw); | ||
| 189 | if (sp) { | ||
| 190 | pvr2_stream_get_stats(sp, &stats, 0); | ||
| 191 | ccnt = scnprintf( | ||
| 192 | buf,acnt, | ||
| 193 | "Bytes streamed=%u" | ||
| 194 | " URBs: queued=%u idle=%u ready=%u" | ||
| 195 | " processed=%u failed=%u\n", | ||
| 196 | stats.bytes_processed, | ||
| 197 | stats.buffers_in_queue, | ||
| 198 | stats.buffers_in_idle, | ||
| 199 | stats.buffers_in_ready, | ||
| 200 | stats.buffers_processed, | ||
| 201 | stats.buffers_failed); | ||
| 202 | bcnt += ccnt; acnt -= ccnt; buf += ccnt; | ||
| 203 | } | ||
| 204 | |||
| 185 | return bcnt; | 205 | return bcnt; |
| 186 | } | 206 | } |
| 187 | 207 | ||
| @@ -220,6 +240,10 @@ static int pvr2_debugifc_do1cmd(struct pvr2_hdw *hdw,const char *buf, | |||
| 220 | return pvr2_hdw_cmd_decoder_reset(hdw); | 240 | return pvr2_hdw_cmd_decoder_reset(hdw); |
| 221 | } else if (debugifc_match_keyword(wptr,wlen,"worker")) { | 241 | } else if (debugifc_match_keyword(wptr,wlen,"worker")) { |
| 222 | return pvr2_hdw_untrip(hdw); | 242 | return pvr2_hdw_untrip(hdw); |
| 243 | } else if (debugifc_match_keyword(wptr,wlen,"usbstats")) { | ||
| 244 | pvr2_stream_get_stats(pvr2_hdw_get_video_stream(hdw), | ||
| 245 | NULL, !0); | ||
| 246 | return 0; | ||
| 223 | } | 247 | } |
| 224 | return -EINVAL; | 248 | return -EINVAL; |
| 225 | } else if (debugifc_match_keyword(wptr,wlen,"cpufw")) { | 249 | } else if (debugifc_match_keyword(wptr,wlen,"cpufw")) { |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.c b/drivers/media/video/pvrusb2/pvrusb2-devattr.c index fe9991c10cf4..2dd06a90adce 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-devattr.c +++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.c | |||
| @@ -32,7 +32,15 @@ pvr2_device_desc structures. | |||
| 32 | /* This is needed in order to pull in tuner type ids... */ | 32 | /* This is needed in order to pull in tuner type ids... */ |
| 33 | #include <linux/i2c.h> | 33 | #include <linux/i2c.h> |
| 34 | #include <media/tuner.h> | 34 | #include <media/tuner.h> |
| 35 | 35 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB | |
| 36 | #include "pvrusb2-hdw-internal.h" | ||
| 37 | #include "lgdt330x.h" | ||
| 38 | #include "s5h1409.h" | ||
| 39 | #include "tda10048.h" | ||
| 40 | #include "tda18271.h" | ||
| 41 | #include "tda8290.h" | ||
| 42 | #include "tuner-simple.h" | ||
| 43 | #endif | ||
| 36 | 44 | ||
| 37 | 45 | ||
| 38 | /*------------------------------------------------------------------------*/ | 46 | /*------------------------------------------------------------------------*/ |
| @@ -49,14 +57,19 @@ static const char *pvr2_fw1_names_29xxx[] = { | |||
| 49 | }; | 57 | }; |
| 50 | 58 | ||
| 51 | static const struct pvr2_device_desc pvr2_device_29xxx = { | 59 | static const struct pvr2_device_desc pvr2_device_29xxx = { |
| 52 | .description = "WinTV PVR USB2 Model Category 29xxxx", | 60 | .description = "WinTV PVR USB2 Model Category 29xxx", |
| 53 | .shortname = "29xxx", | 61 | .shortname = "29xxx", |
| 54 | .client_modules.lst = pvr2_client_29xxx, | 62 | .client_modules.lst = pvr2_client_29xxx, |
| 55 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_29xxx), | 63 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_29xxx), |
| 56 | .fx2_firmware.lst = pvr2_fw1_names_29xxx, | 64 | .fx2_firmware.lst = pvr2_fw1_names_29xxx, |
| 57 | .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_29xxx), | 65 | .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_29xxx), |
| 58 | .flag_has_hauppauge_rom = !0, | 66 | .flag_has_hauppauge_rom = !0, |
| 67 | .flag_has_analogtuner = !0, | ||
| 68 | .flag_has_fmradio = !0, | ||
| 69 | .flag_has_composite = !0, | ||
| 70 | .flag_has_svideo = !0, | ||
| 59 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, | 71 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, |
| 72 | .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, | ||
| 60 | }; | 73 | }; |
| 61 | 74 | ||
| 62 | 75 | ||
| @@ -75,7 +88,7 @@ static const char *pvr2_fw1_names_24xxx[] = { | |||
| 75 | }; | 88 | }; |
| 76 | 89 | ||
| 77 | static const struct pvr2_device_desc pvr2_device_24xxx = { | 90 | static const struct pvr2_device_desc pvr2_device_24xxx = { |
| 78 | .description = "WinTV PVR USB2 Model Category 24xxxx", | 91 | .description = "WinTV PVR USB2 Model Category 24xxx", |
| 79 | .shortname = "24xxx", | 92 | .shortname = "24xxx", |
| 80 | .client_modules.lst = pvr2_client_24xxx, | 93 | .client_modules.lst = pvr2_client_24xxx, |
| 81 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_24xxx), | 94 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_24xxx), |
| @@ -85,7 +98,12 @@ static const struct pvr2_device_desc pvr2_device_24xxx = { | |||
| 85 | .flag_has_wm8775 = !0, | 98 | .flag_has_wm8775 = !0, |
| 86 | .flag_has_hauppauge_rom = !0, | 99 | .flag_has_hauppauge_rom = !0, |
| 87 | .flag_has_hauppauge_custom_ir = !0, | 100 | .flag_has_hauppauge_custom_ir = !0, |
| 101 | .flag_has_analogtuner = !0, | ||
| 102 | .flag_has_fmradio = !0, | ||
| 103 | .flag_has_composite = !0, | ||
| 104 | .flag_has_svideo = !0, | ||
| 88 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, | 105 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, |
| 106 | .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, | ||
| 89 | }; | 107 | }; |
| 90 | 108 | ||
| 91 | 109 | ||
| @@ -105,6 +123,30 @@ static const struct pvr2_device_desc pvr2_device_gotview_2 = { | |||
| 105 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_gotview_2), | 123 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_gotview_2), |
| 106 | .flag_has_cx25840 = !0, | 124 | .flag_has_cx25840 = !0, |
| 107 | .default_tuner_type = TUNER_PHILIPS_FM1216ME_MK3, | 125 | .default_tuner_type = TUNER_PHILIPS_FM1216ME_MK3, |
| 126 | .flag_has_analogtuner = !0, | ||
| 127 | .flag_has_fmradio = !0, | ||
| 128 | .flag_has_composite = !0, | ||
| 129 | .flag_has_svideo = !0, | ||
| 130 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_GOTVIEW, | ||
| 131 | }; | ||
| 132 | |||
| 133 | |||
| 134 | |||
| 135 | /*------------------------------------------------------------------------*/ | ||
| 136 | /* GOTVIEW USB2.0 DVD Deluxe */ | ||
| 137 | |||
| 138 | /* (same module list as gotview_2) */ | ||
| 139 | |||
| 140 | static const struct pvr2_device_desc pvr2_device_gotview_2d = { | ||
| 141 | .description = "Gotview USB 2.0 DVD Deluxe", | ||
| 142 | .shortname = "gv2d", | ||
| 143 | .client_modules.lst = pvr2_client_gotview_2, | ||
| 144 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_gotview_2), | ||
| 145 | .flag_has_cx25840 = !0, | ||
| 146 | .default_tuner_type = TUNER_PHILIPS_FM1216ME_MK3, | ||
| 147 | .flag_has_analogtuner = !0, | ||
| 148 | .flag_has_composite = !0, | ||
| 149 | .flag_has_svideo = !0, | ||
| 108 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_GOTVIEW, | 150 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_GOTVIEW, |
| 109 | }; | 151 | }; |
| 110 | 152 | ||
| @@ -114,6 +156,38 @@ static const struct pvr2_device_desc pvr2_device_gotview_2 = { | |||
| 114 | /*------------------------------------------------------------------------*/ | 156 | /*------------------------------------------------------------------------*/ |
| 115 | /* OnAir Creator */ | 157 | /* OnAir Creator */ |
| 116 | 158 | ||
| 159 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB | ||
| 160 | static struct lgdt330x_config pvr2_lgdt3303_config = { | ||
| 161 | .demod_address = 0x0e, | ||
| 162 | .demod_chip = LGDT3303, | ||
| 163 | .clock_polarity_flip = 1, | ||
| 164 | }; | ||
| 165 | |||
| 166 | static int pvr2_lgdt3303_attach(struct pvr2_dvb_adapter *adap) | ||
| 167 | { | ||
| 168 | adap->fe = dvb_attach(lgdt330x_attach, &pvr2_lgdt3303_config, | ||
| 169 | &adap->channel.hdw->i2c_adap); | ||
| 170 | if (adap->fe) | ||
| 171 | return 0; | ||
| 172 | |||
| 173 | return -EIO; | ||
| 174 | } | ||
| 175 | |||
| 176 | static int pvr2_lgh06xf_attach(struct pvr2_dvb_adapter *adap) | ||
| 177 | { | ||
| 178 | dvb_attach(simple_tuner_attach, adap->fe, | ||
| 179 | &adap->channel.hdw->i2c_adap, 0x61, | ||
| 180 | TUNER_LG_TDVS_H06XF); | ||
| 181 | |||
| 182 | return 0; | ||
| 183 | } | ||
| 184 | |||
| 185 | struct pvr2_dvb_props pvr2_onair_creator_fe_props = { | ||
| 186 | .frontend_attach = pvr2_lgdt3303_attach, | ||
| 187 | .tuner_attach = pvr2_lgh06xf_attach, | ||
| 188 | }; | ||
| 189 | #endif | ||
| 190 | |||
| 117 | static const char *pvr2_client_onair_creator[] = { | 191 | static const char *pvr2_client_onair_creator[] = { |
| 118 | "saa7115", | 192 | "saa7115", |
| 119 | "tuner", | 193 | "tuner", |
| @@ -126,7 +200,16 @@ static const struct pvr2_device_desc pvr2_device_onair_creator = { | |||
| 126 | .client_modules.lst = pvr2_client_onair_creator, | 200 | .client_modules.lst = pvr2_client_onair_creator, |
| 127 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_onair_creator), | 201 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_onair_creator), |
| 128 | .default_tuner_type = TUNER_LG_TDVS_H06XF, | 202 | .default_tuner_type = TUNER_LG_TDVS_H06XF, |
| 203 | .flag_has_analogtuner = !0, | ||
| 204 | .flag_has_composite = !0, | ||
| 205 | .flag_has_svideo = !0, | ||
| 206 | .flag_digital_requires_cx23416 = !0, | ||
| 129 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, | 207 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, |
| 208 | .digital_control_scheme = PVR2_DIGITAL_SCHEME_ONAIR, | ||
| 209 | .default_std_mask = V4L2_STD_NTSC_M, | ||
| 210 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB | ||
| 211 | .dvb_props = &pvr2_onair_creator_fe_props, | ||
| 212 | #endif | ||
| 130 | }; | 213 | }; |
| 131 | #endif | 214 | #endif |
| 132 | 215 | ||
| @@ -136,6 +219,37 @@ static const struct pvr2_device_desc pvr2_device_onair_creator = { | |||
| 136 | /*------------------------------------------------------------------------*/ | 219 | /*------------------------------------------------------------------------*/ |
| 137 | /* OnAir USB 2.0 */ | 220 | /* OnAir USB 2.0 */ |
| 138 | 221 | ||
| 222 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB | ||
| 223 | static struct lgdt330x_config pvr2_lgdt3302_config = { | ||
| 224 | .demod_address = 0x0e, | ||
| 225 | .demod_chip = LGDT3302, | ||
| 226 | }; | ||
| 227 | |||
| 228 | static int pvr2_lgdt3302_attach(struct pvr2_dvb_adapter *adap) | ||
| 229 | { | ||
| 230 | adap->fe = dvb_attach(lgdt330x_attach, &pvr2_lgdt3302_config, | ||
| 231 | &adap->channel.hdw->i2c_adap); | ||
| 232 | if (adap->fe) | ||
| 233 | return 0; | ||
| 234 | |||
| 235 | return -EIO; | ||
| 236 | } | ||
| 237 | |||
| 238 | static int pvr2_fcv1236d_attach(struct pvr2_dvb_adapter *adap) | ||
| 239 | { | ||
| 240 | dvb_attach(simple_tuner_attach, adap->fe, | ||
| 241 | &adap->channel.hdw->i2c_adap, 0x61, | ||
| 242 | TUNER_PHILIPS_FCV1236D); | ||
| 243 | |||
| 244 | return 0; | ||
| 245 | } | ||
| 246 | |||
| 247 | struct pvr2_dvb_props pvr2_onair_usb2_fe_props = { | ||
| 248 | .frontend_attach = pvr2_lgdt3302_attach, | ||
| 249 | .tuner_attach = pvr2_fcv1236d_attach, | ||
| 250 | }; | ||
| 251 | #endif | ||
| 252 | |||
| 139 | static const char *pvr2_client_onair_usb2[] = { | 253 | static const char *pvr2_client_onair_usb2[] = { |
| 140 | "saa7115", | 254 | "saa7115", |
| 141 | "tuner", | 255 | "tuner", |
| @@ -147,8 +261,17 @@ static const struct pvr2_device_desc pvr2_device_onair_usb2 = { | |||
| 147 | .shortname = "oa2", | 261 | .shortname = "oa2", |
| 148 | .client_modules.lst = pvr2_client_onair_usb2, | 262 | .client_modules.lst = pvr2_client_onair_usb2, |
| 149 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_onair_usb2), | 263 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_onair_usb2), |
| 150 | .default_tuner_type = TUNER_PHILIPS_ATSC, | 264 | .default_tuner_type = TUNER_PHILIPS_FCV1236D, |
| 265 | .flag_has_analogtuner = !0, | ||
| 266 | .flag_has_composite = !0, | ||
| 267 | .flag_has_svideo = !0, | ||
| 268 | .flag_digital_requires_cx23416 = !0, | ||
| 151 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, | 269 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, |
| 270 | .digital_control_scheme = PVR2_DIGITAL_SCHEME_ONAIR, | ||
| 271 | .default_std_mask = V4L2_STD_NTSC_M, | ||
| 272 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB | ||
| 273 | .dvb_props = &pvr2_onair_usb2_fe_props, | ||
| 274 | #endif | ||
| 152 | }; | 275 | }; |
| 153 | #endif | 276 | #endif |
| 154 | 277 | ||
| @@ -157,6 +280,50 @@ static const struct pvr2_device_desc pvr2_device_onair_usb2 = { | |||
| 157 | /*------------------------------------------------------------------------*/ | 280 | /*------------------------------------------------------------------------*/ |
| 158 | /* Hauppauge PVR-USB2 Model 73xxx */ | 281 | /* Hauppauge PVR-USB2 Model 73xxx */ |
| 159 | 282 | ||
| 283 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB | ||
| 284 | static struct tda10048_config hauppauge_tda10048_config = { | ||
| 285 | .demod_address = 0x10 >> 1, | ||
| 286 | .output_mode = TDA10048_PARALLEL_OUTPUT, | ||
| 287 | .fwbulkwritelen = TDA10048_BULKWRITE_50, | ||
| 288 | .inversion = TDA10048_INVERSION_ON, | ||
| 289 | }; | ||
| 290 | |||
| 291 | static struct tda829x_config tda829x_no_probe = { | ||
| 292 | .probe_tuner = TDA829X_DONT_PROBE, | ||
| 293 | }; | ||
| 294 | |||
| 295 | static struct tda18271_config hauppauge_tda18271_dvb_config = { | ||
| 296 | .gate = TDA18271_GATE_ANALOG, | ||
| 297 | }; | ||
| 298 | |||
| 299 | static int pvr2_tda10048_attach(struct pvr2_dvb_adapter *adap) | ||
| 300 | { | ||
| 301 | adap->fe = dvb_attach(tda10048_attach, &hauppauge_tda10048_config, | ||
| 302 | &adap->channel.hdw->i2c_adap); | ||
| 303 | if (adap->fe) | ||
| 304 | return 0; | ||
| 305 | |||
| 306 | return -EIO; | ||
| 307 | } | ||
| 308 | |||
| 309 | static int pvr2_73xxx_tda18271_8295_attach(struct pvr2_dvb_adapter *adap) | ||
| 310 | { | ||
| 311 | dvb_attach(tda829x_attach, adap->fe, | ||
| 312 | &adap->channel.hdw->i2c_adap, 0x42, | ||
| 313 | &tda829x_no_probe); | ||
| 314 | dvb_attach(tda18271_attach, adap->fe, 0x60, | ||
| 315 | &adap->channel.hdw->i2c_adap, | ||
| 316 | &hauppauge_tda18271_dvb_config); | ||
| 317 | |||
| 318 | return 0; | ||
| 319 | } | ||
| 320 | |||
| 321 | struct pvr2_dvb_props pvr2_73xxx_dvb_props = { | ||
| 322 | .frontend_attach = pvr2_tda10048_attach, | ||
| 323 | .tuner_attach = pvr2_73xxx_tda18271_8295_attach, | ||
| 324 | }; | ||
| 325 | #endif | ||
| 326 | |||
| 160 | static const char *pvr2_client_73xxx[] = { | 327 | static const char *pvr2_client_73xxx[] = { |
| 161 | "cx25840", | 328 | "cx25840", |
| 162 | "tuner", | 329 | "tuner", |
| @@ -167,7 +334,7 @@ static const char *pvr2_fw1_names_73xxx[] = { | |||
| 167 | }; | 334 | }; |
| 168 | 335 | ||
| 169 | static const struct pvr2_device_desc pvr2_device_73xxx = { | 336 | static const struct pvr2_device_desc pvr2_device_73xxx = { |
| 170 | .description = "WinTV PVR USB2 Model Category 73xxxx", | 337 | .description = "WinTV PVR USB2 Model Category 73xxx", |
| 171 | .shortname = "73xxx", | 338 | .shortname = "73xxx", |
| 172 | .client_modules.lst = pvr2_client_73xxx, | 339 | .client_modules.lst = pvr2_client_73xxx, |
| 173 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_73xxx), | 340 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_73xxx), |
| @@ -175,15 +342,14 @@ static const struct pvr2_device_desc pvr2_device_73xxx = { | |||
| 175 | .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_73xxx), | 342 | .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_73xxx), |
| 176 | .flag_has_cx25840 = !0, | 343 | .flag_has_cx25840 = !0, |
| 177 | .flag_has_hauppauge_rom = !0, | 344 | .flag_has_hauppauge_rom = !0, |
| 178 | #if 0 | ||
| 179 | .flag_has_analogtuner = !0, | 345 | .flag_has_analogtuner = !0, |
| 180 | .flag_has_composite = !0, | 346 | .flag_has_composite = !0, |
| 181 | .flag_has_svideo = !0, | 347 | .flag_has_svideo = !0, |
| 182 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, | 348 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, |
| 183 | .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE, | 349 | .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE, |
| 184 | .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, | 350 | .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, |
| 185 | #else | 351 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB |
| 186 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, | 352 | .dvb_props = &pvr2_73xxx_dvb_props, |
| 187 | #endif | 353 | #endif |
| 188 | }; | 354 | }; |
| 189 | 355 | ||
| @@ -192,6 +358,56 @@ static const struct pvr2_device_desc pvr2_device_73xxx = { | |||
| 192 | /*------------------------------------------------------------------------*/ | 358 | /*------------------------------------------------------------------------*/ |
| 193 | /* Hauppauge PVR-USB2 Model 75xxx */ | 359 | /* Hauppauge PVR-USB2 Model 75xxx */ |
| 194 | 360 | ||
| 361 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB | ||
| 362 | static struct s5h1409_config pvr2_s5h1409_config = { | ||
| 363 | .demod_address = 0x32 >> 1, | ||
| 364 | .output_mode = S5H1409_PARALLEL_OUTPUT, | ||
| 365 | .gpio = S5H1409_GPIO_OFF, | ||
| 366 | .qam_if = 4000, | ||
| 367 | .inversion = S5H1409_INVERSION_ON, | ||
| 368 | .status_mode = S5H1409_DEMODLOCKING, | ||
| 369 | }; | ||
| 370 | |||
| 371 | static struct tda18271_std_map hauppauge_tda18271_std_map = { | ||
| 372 | .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3, | ||
| 373 | .if_lvl = 6, .rfagc_top = 0x37, }, | ||
| 374 | .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0, | ||
| 375 | .if_lvl = 6, .rfagc_top = 0x37, }, | ||
| 376 | }; | ||
| 377 | |||
| 378 | static struct tda18271_config hauppauge_tda18271_config = { | ||
| 379 | .std_map = &hauppauge_tda18271_std_map, | ||
| 380 | .gate = TDA18271_GATE_ANALOG, | ||
| 381 | }; | ||
| 382 | |||
| 383 | static int pvr2_s5h1409_attach(struct pvr2_dvb_adapter *adap) | ||
| 384 | { | ||
| 385 | adap->fe = dvb_attach(s5h1409_attach, &pvr2_s5h1409_config, | ||
| 386 | &adap->channel.hdw->i2c_adap); | ||
| 387 | if (adap->fe) | ||
| 388 | return 0; | ||
| 389 | |||
| 390 | return -EIO; | ||
| 391 | } | ||
| 392 | |||
| 393 | static int pvr2_tda18271_8295_attach(struct pvr2_dvb_adapter *adap) | ||
| 394 | { | ||
| 395 | dvb_attach(tda829x_attach, adap->fe, | ||
| 396 | &adap->channel.hdw->i2c_adap, 0x42, | ||
| 397 | &tda829x_no_probe); | ||
| 398 | dvb_attach(tda18271_attach, adap->fe, 0x60, | ||
| 399 | &adap->channel.hdw->i2c_adap, | ||
| 400 | &hauppauge_tda18271_config); | ||
| 401 | |||
| 402 | return 0; | ||
| 403 | } | ||
| 404 | |||
| 405 | struct pvr2_dvb_props pvr2_750xx_dvb_props = { | ||
| 406 | .frontend_attach = pvr2_s5h1409_attach, | ||
| 407 | .tuner_attach = pvr2_tda18271_8295_attach, | ||
| 408 | }; | ||
| 409 | #endif | ||
| 410 | |||
| 195 | static const char *pvr2_client_75xxx[] = { | 411 | static const char *pvr2_client_75xxx[] = { |
| 196 | "cx25840", | 412 | "cx25840", |
| 197 | "tuner", | 413 | "tuner", |
| @@ -201,17 +417,43 @@ static const char *pvr2_fw1_names_75xxx[] = { | |||
| 201 | "v4l-pvrusb2-73xxx-01.fw", | 417 | "v4l-pvrusb2-73xxx-01.fw", |
| 202 | }; | 418 | }; |
| 203 | 419 | ||
| 204 | static const struct pvr2_device_desc pvr2_device_75xxx = { | 420 | static const struct pvr2_device_desc pvr2_device_750xx = { |
| 205 | .description = "WinTV PVR USB2 Model Category 75xxxx", | 421 | .description = "WinTV PVR USB2 Model Category 750xx", |
| 206 | .shortname = "75xxx", | 422 | .shortname = "750xx", |
| 423 | .client_modules.lst = pvr2_client_75xxx, | ||
| 424 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_75xxx), | ||
| 425 | .fx2_firmware.lst = pvr2_fw1_names_75xxx, | ||
| 426 | .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_75xxx), | ||
| 427 | .flag_has_cx25840 = !0, | ||
| 428 | .flag_has_hauppauge_rom = !0, | ||
| 429 | .flag_has_analogtuner = !0, | ||
| 430 | .flag_has_composite = !0, | ||
| 431 | .flag_has_svideo = !0, | ||
| 432 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, | ||
| 433 | .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE, | ||
| 434 | .default_std_mask = V4L2_STD_NTSC_M, | ||
| 435 | .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, | ||
| 436 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB | ||
| 437 | .dvb_props = &pvr2_750xx_dvb_props, | ||
| 438 | #endif | ||
| 439 | }; | ||
| 440 | |||
| 441 | static const struct pvr2_device_desc pvr2_device_751xx = { | ||
| 442 | .description = "WinTV PVR USB2 Model Category 751xx", | ||
| 443 | .shortname = "751xx", | ||
| 207 | .client_modules.lst = pvr2_client_75xxx, | 444 | .client_modules.lst = pvr2_client_75xxx, |
| 208 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_75xxx), | 445 | .client_modules.cnt = ARRAY_SIZE(pvr2_client_75xxx), |
| 209 | .fx2_firmware.lst = pvr2_fw1_names_75xxx, | 446 | .fx2_firmware.lst = pvr2_fw1_names_75xxx, |
| 210 | .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_75xxx), | 447 | .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_75xxx), |
| 211 | .flag_has_cx25840 = !0, | 448 | .flag_has_cx25840 = !0, |
| 212 | .flag_has_hauppauge_rom = !0, | 449 | .flag_has_hauppauge_rom = !0, |
| 450 | .flag_has_analogtuner = !0, | ||
| 451 | .flag_has_composite = !0, | ||
| 452 | .flag_has_svideo = !0, | ||
| 213 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, | 453 | .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE, |
| 454 | .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE, | ||
| 214 | .default_std_mask = V4L2_STD_NTSC_M, | 455 | .default_std_mask = V4L2_STD_NTSC_M, |
| 456 | .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE, | ||
| 215 | }; | 457 | }; |
| 216 | 458 | ||
| 217 | 459 | ||
| @@ -225,6 +467,8 @@ struct usb_device_id pvr2_device_table[] = { | |||
| 225 | .driver_info = (kernel_ulong_t)&pvr2_device_24xxx}, | 467 | .driver_info = (kernel_ulong_t)&pvr2_device_24xxx}, |
| 226 | { USB_DEVICE(0x1164, 0x0622), | 468 | { USB_DEVICE(0x1164, 0x0622), |
| 227 | .driver_info = (kernel_ulong_t)&pvr2_device_gotview_2}, | 469 | .driver_info = (kernel_ulong_t)&pvr2_device_gotview_2}, |
| 470 | { USB_DEVICE(0x1164, 0x0602), | ||
| 471 | .driver_info = (kernel_ulong_t)&pvr2_device_gotview_2d}, | ||
| 228 | #ifdef CONFIG_VIDEO_PVRUSB2_ONAIR_CREATOR | 472 | #ifdef CONFIG_VIDEO_PVRUSB2_ONAIR_CREATOR |
| 229 | { USB_DEVICE(0x11ba, 0x1003), | 473 | { USB_DEVICE(0x11ba, 0x1003), |
| 230 | .driver_info = (kernel_ulong_t)&pvr2_device_onair_creator}, | 474 | .driver_info = (kernel_ulong_t)&pvr2_device_onair_creator}, |
| @@ -236,9 +480,9 @@ struct usb_device_id pvr2_device_table[] = { | |||
| 236 | { USB_DEVICE(0x2040, 0x7300), | 480 | { USB_DEVICE(0x2040, 0x7300), |
| 237 | .driver_info = (kernel_ulong_t)&pvr2_device_73xxx}, | 481 | .driver_info = (kernel_ulong_t)&pvr2_device_73xxx}, |
| 238 | { USB_DEVICE(0x2040, 0x7500), | 482 | { USB_DEVICE(0x2040, 0x7500), |
| 239 | .driver_info = (kernel_ulong_t)&pvr2_device_75xxx}, | 483 | .driver_info = (kernel_ulong_t)&pvr2_device_750xx}, |
| 240 | { USB_DEVICE(0x2040, 0x7501), | 484 | { USB_DEVICE(0x2040, 0x7501), |
| 241 | .driver_info = (kernel_ulong_t)&pvr2_device_75xxx}, | 485 | .driver_info = (kernel_ulong_t)&pvr2_device_751xx}, |
| 242 | { } | 486 | { } |
| 243 | }; | 487 | }; |
| 244 | 488 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-devattr.h b/drivers/media/video/pvrusb2/pvrusb2-devattr.h index 64b467f0637f..c2e2b06fe2e0 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-devattr.h +++ b/drivers/media/video/pvrusb2/pvrusb2-devattr.h | |||
| @@ -23,6 +23,9 @@ | |||
| 23 | 23 | ||
| 24 | #include <linux/mod_devicetable.h> | 24 | #include <linux/mod_devicetable.h> |
| 25 | #include <linux/videodev2.h> | 25 | #include <linux/videodev2.h> |
| 26 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB | ||
| 27 | #include "pvrusb2-dvb.h" | ||
| 28 | #endif | ||
| 26 | 29 | ||
| 27 | /* | 30 | /* |
| 28 | 31 | ||
| @@ -39,6 +42,13 @@ struct pvr2_string_table { | |||
| 39 | #define PVR2_ROUTING_SCHEME_HAUPPAUGE 0 | 42 | #define PVR2_ROUTING_SCHEME_HAUPPAUGE 0 |
| 40 | #define PVR2_ROUTING_SCHEME_GOTVIEW 1 | 43 | #define PVR2_ROUTING_SCHEME_GOTVIEW 1 |
| 41 | 44 | ||
| 45 | #define PVR2_DIGITAL_SCHEME_NONE 0 | ||
| 46 | #define PVR2_DIGITAL_SCHEME_HAUPPAUGE 1 | ||
| 47 | #define PVR2_DIGITAL_SCHEME_ONAIR 2 | ||
| 48 | |||
| 49 | #define PVR2_LED_SCHEME_NONE 0 | ||
| 50 | #define PVR2_LED_SCHEME_HAUPPAUGE 1 | ||
| 51 | |||
| 42 | /* This describes a particular hardware type (except for the USB device ID | 52 | /* This describes a particular hardware type (except for the USB device ID |
| 43 | which must live in a separate structure due to environmental | 53 | which must live in a separate structure due to environmental |
| 44 | constraints). See the top of pvrusb2-hdw.c for where this is | 54 | constraints). See the top of pvrusb2-hdw.c for where this is |
| @@ -58,40 +68,64 @@ struct pvr2_device_desc { | |||
| 58 | was initialized from internal ROM. */ | 68 | was initialized from internal ROM. */ |
| 59 | struct pvr2_string_table fx2_firmware; | 69 | struct pvr2_string_table fx2_firmware; |
| 60 | 70 | ||
| 71 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB | ||
| 72 | /* callback functions to handle attachment of digital tuner & demod */ | ||
| 73 | struct pvr2_dvb_props *dvb_props; | ||
| 74 | |||
| 75 | #endif | ||
| 76 | /* Initial standard bits to use for this device, if not zero. | ||
| 77 | Anything set here is also implied as an available standard. | ||
| 78 | Note: This is ignored if overridden on the module load line via | ||
| 79 | the video_std module option. */ | ||
| 80 | v4l2_std_id default_std_mask; | ||
| 81 | |||
| 82 | /* V4L tuner type ID to use with this device (only used if the | ||
| 83 | driver could not discover the type any other way). */ | ||
| 84 | int default_tuner_type; | ||
| 85 | |||
| 61 | /* Signal routing scheme used by device, contains one of | 86 | /* Signal routing scheme used by device, contains one of |
| 62 | PVR2_ROUTING_SCHEME_XXX. Schemes have to be defined as we | 87 | PVR2_ROUTING_SCHEME_XXX. Schemes have to be defined as we |
| 63 | encounter them. This is an arbitrary integer scheme id; its | 88 | encounter them. This is an arbitrary integer scheme id; its |
| 64 | meaning is contained entirely within the driver and is | 89 | meaning is contained entirely within the driver and is |
| 65 | interpreted by logic which must send commands to the chip-level | 90 | interpreted by logic which must send commands to the chip-level |
| 66 | drivers (search for things which touch this field). */ | 91 | drivers (search for things which touch this field). */ |
| 67 | unsigned int signal_routing_scheme; | 92 | unsigned char signal_routing_scheme; |
| 68 | 93 | ||
| 69 | /* V4L tuner type ID to use with this device (only used if the | 94 | /* Indicates scheme for controlling device's LED (if any). The |
| 70 | driver could not discover the type any other way). */ | 95 | driver will turn on the LED when streaming is underway. This |
| 71 | int default_tuner_type; | 96 | contains one of PVR2_LED_SCHEME_XXX. */ |
| 97 | unsigned char led_scheme; | ||
| 72 | 98 | ||
| 73 | /* Initial standard bits to use for this device, if not zero. | 99 | /* Control scheme to use if there is a digital tuner. This |
| 74 | Anything set here is also implied as an available standard. | 100 | contains one of PVR2_DIGITAL_SCHEME_XXX. This is an arbitrary |
| 75 | Note: This is ignored if overridden on the module load line via | 101 | integer scheme id; its meaning is contained entirely within the |
| 76 | the video_std module option. */ | 102 | driver and is interpreted by logic which must control the |
| 77 | v4l2_std_id default_std_mask; | 103 | streaming pathway (search for things which touch this field). */ |
| 104 | unsigned char digital_control_scheme; | ||
| 78 | 105 | ||
| 79 | /* If set, we don't bother trying to load cx23416 firmware. */ | 106 | /* If set, we don't bother trying to load cx23416 firmware. */ |
| 80 | char flag_skip_cx23416_firmware; | 107 | int flag_skip_cx23416_firmware:1; |
| 108 | |||
| 109 | /* If set, the encoder must be healthy in order for digital mode to | ||
| 110 | work (otherwise we assume that digital streaming will work even | ||
| 111 | if we fail to locate firmware for the encoder). If the device | ||
| 112 | doesn't support digital streaming then this flag has no | ||
| 113 | effect. */ | ||
| 114 | int flag_digital_requires_cx23416:1; | ||
| 81 | 115 | ||
| 82 | /* Device has a hauppauge eeprom which we can interrogate. */ | 116 | /* Device has a hauppauge eeprom which we can interrogate. */ |
| 83 | char flag_has_hauppauge_rom; | 117 | int flag_has_hauppauge_rom:1; |
| 84 | 118 | ||
| 85 | /* Device does not require a powerup command to be issued. */ | 119 | /* Device does not require a powerup command to be issued. */ |
| 86 | char flag_no_powerup; | 120 | int flag_no_powerup:1; |
| 87 | 121 | ||
| 88 | /* Device has a cx25840 - this enables special additional logic to | 122 | /* Device has a cx25840 - this enables special additional logic to |
| 89 | handle it. */ | 123 | handle it. */ |
| 90 | char flag_has_cx25840; | 124 | int flag_has_cx25840:1; |
| 91 | 125 | ||
| 92 | /* Device has a wm8775 - this enables special additional logic to | 126 | /* Device has a wm8775 - this enables special additional logic to |
| 93 | ensure that it is found. */ | 127 | ensure that it is found. */ |
| 94 | char flag_has_wm8775; | 128 | int flag_has_wm8775:1; |
| 95 | 129 | ||
| 96 | /* Device has IR hardware that can be faked into looking like a | 130 | /* Device has IR hardware that can be faked into looking like a |
| 97 | normal Hauppauge i2c IR receiver. This is currently very | 131 | normal Hauppauge i2c IR receiver. This is currently very |
| @@ -101,7 +135,15 @@ struct pvr2_device_desc { | |||
| 101 | to virtualize the presence of the non-existant IR receiver chip and | 135 | to virtualize the presence of the non-existant IR receiver chip and |
| 102 | implement the virtual receiver in terms of appropriate FX2 | 136 | implement the virtual receiver in terms of appropriate FX2 |
| 103 | commands. */ | 137 | commands. */ |
| 104 | char flag_has_hauppauge_custom_ir; | 138 | int flag_has_hauppauge_custom_ir:1; |
| 139 | |||
| 140 | /* These bits define which kinds of sources the device can handle. | ||
| 141 | Note: Digital tuner presence is inferred by the | ||
| 142 | digital_control_scheme enumeration. */ | ||
| 143 | int flag_has_fmradio:1; /* Has FM radio receiver */ | ||
| 144 | int flag_has_analogtuner:1; /* Has analog tuner */ | ||
| 145 | int flag_has_composite:1; /* Has composite input */ | ||
| 146 | int flag_has_svideo:1; /* Has s-video input */ | ||
| 105 | }; | 147 | }; |
| 106 | 148 | ||
| 107 | extern struct usb_device_id pvr2_device_table[]; | 149 | extern struct usb_device_id pvr2_device_table[]; |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-dvb.c b/drivers/media/video/pvrusb2/pvrusb2-dvb.c new file mode 100644 index 000000000000..2e64f98d1241 --- /dev/null +++ b/drivers/media/video/pvrusb2/pvrusb2-dvb.c | |||
| @@ -0,0 +1,425 @@ | |||
| 1 | /* | ||
| 2 | * pvrusb2-dvb.c - linux-dvb api interface to the pvrusb2 driver. | ||
| 3 | * | ||
| 4 | * Copyright (C) 2007, 2008 Michael Krufky <mkrufky@linuxtv.org> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2 of the License | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program; if not, write to the Free Software | ||
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <linux/kthread.h> | ||
| 22 | #include <linux/freezer.h> | ||
| 23 | #include "dvbdev.h" | ||
| 24 | #include "pvrusb2-hdw-internal.h" | ||
| 25 | #include "pvrusb2-hdw.h" | ||
| 26 | #include "pvrusb2-io.h" | ||
| 27 | #include "pvrusb2-dvb.h" | ||
| 28 | |||
| 29 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 30 | |||
| 31 | static int pvr2_dvb_feed_func(struct pvr2_dvb_adapter *adap) | ||
| 32 | { | ||
| 33 | int ret; | ||
| 34 | unsigned int count; | ||
| 35 | struct pvr2_buffer *bp; | ||
| 36 | struct pvr2_stream *stream; | ||
| 37 | |||
| 38 | printk(KERN_DEBUG "dvb thread started\n"); | ||
| 39 | set_freezable(); | ||
| 40 | |||
| 41 | stream = adap->channel.stream->stream; | ||
| 42 | |||
| 43 | for (;;) { | ||
| 44 | if (kthread_should_stop()) break; | ||
| 45 | |||
| 46 | /* Not sure about this... */ | ||
| 47 | try_to_freeze(); | ||
| 48 | |||
| 49 | bp = pvr2_stream_get_ready_buffer(stream); | ||
| 50 | if (bp != NULL) { | ||
| 51 | count = pvr2_buffer_get_count(bp); | ||
| 52 | if (count) { | ||
| 53 | dvb_dmx_swfilter( | ||
| 54 | &adap->demux, | ||
| 55 | adap->buffer_storage[ | ||
| 56 | pvr2_buffer_get_id(bp)], | ||
| 57 | count); | ||
| 58 | } else { | ||
| 59 | ret = pvr2_buffer_get_status(bp); | ||
| 60 | if (ret < 0) break; | ||
| 61 | } | ||
| 62 | ret = pvr2_buffer_queue(bp); | ||
| 63 | if (ret < 0) break; | ||
| 64 | |||
| 65 | /* Since we know we did something to a buffer, | ||
| 66 | just go back and try again. No point in | ||
| 67 | blocking unless we really ran out of | ||
| 68 | buffers to process. */ | ||
| 69 | continue; | ||
| 70 | } | ||
| 71 | |||
| 72 | |||
| 73 | /* Wait until more buffers become available or we're | ||
| 74 | told not to wait any longer. */ | ||
| 75 | ret = wait_event_interruptible( | ||
| 76 | adap->buffer_wait_data, | ||
| 77 | (pvr2_stream_get_ready_count(stream) > 0) || | ||
| 78 | kthread_should_stop()); | ||
| 79 | if (ret < 0) break; | ||
| 80 | } | ||
| 81 | |||
| 82 | /* If we get here and ret is < 0, then an error has occurred. | ||
| 83 | Probably would be a good idea to communicate that to DVB core... */ | ||
| 84 | |||
| 85 | printk(KERN_DEBUG "dvb thread stopped\n"); | ||
| 86 | |||
| 87 | return 0; | ||
| 88 | } | ||
| 89 | |||
| 90 | static int pvr2_dvb_feed_thread(void *data) | ||
| 91 | { | ||
| 92 | int stat = pvr2_dvb_feed_func(data); | ||
| 93 | /* from videobuf-dvb.c: */ | ||
| 94 | while (!kthread_should_stop()) { | ||
| 95 | set_current_state(TASK_INTERRUPTIBLE); | ||
| 96 | schedule(); | ||
| 97 | } | ||
| 98 | return stat; | ||
| 99 | } | ||
| 100 | |||
| 101 | static void pvr2_dvb_notify(struct pvr2_dvb_adapter *adap) | ||
| 102 | { | ||
| 103 | wake_up(&adap->buffer_wait_data); | ||
| 104 | } | ||
| 105 | |||
| 106 | static void pvr2_dvb_stream_end(struct pvr2_dvb_adapter *adap) | ||
| 107 | { | ||
| 108 | unsigned int idx; | ||
| 109 | struct pvr2_stream *stream; | ||
| 110 | |||
| 111 | if (adap->thread) { | ||
| 112 | kthread_stop(adap->thread); | ||
| 113 | adap->thread = NULL; | ||
| 114 | } | ||
| 115 | |||
| 116 | if (adap->channel.stream) { | ||
| 117 | stream = adap->channel.stream->stream; | ||
| 118 | } else { | ||
| 119 | stream = NULL; | ||
| 120 | } | ||
| 121 | if (stream) { | ||
| 122 | pvr2_hdw_set_streaming(adap->channel.hdw, 0); | ||
| 123 | pvr2_stream_set_callback(stream, NULL, NULL); | ||
| 124 | pvr2_stream_kill(stream); | ||
| 125 | pvr2_stream_set_buffer_count(stream, 0); | ||
| 126 | pvr2_channel_claim_stream(&adap->channel, NULL); | ||
| 127 | } | ||
| 128 | |||
| 129 | if (adap->stream_run) { | ||
| 130 | for (idx = 0; idx < PVR2_DVB_BUFFER_COUNT; idx++) { | ||
| 131 | if (!(adap->buffer_storage[idx])) continue; | ||
| 132 | kfree(adap->buffer_storage[idx]); | ||
| 133 | adap->buffer_storage[idx] = 0; | ||
| 134 | } | ||
| 135 | adap->stream_run = 0; | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | static int pvr2_dvb_stream_do_start(struct pvr2_dvb_adapter *adap) | ||
| 140 | { | ||
| 141 | struct pvr2_context *pvr = adap->channel.mc_head; | ||
| 142 | unsigned int idx; | ||
| 143 | int ret; | ||
| 144 | struct pvr2_buffer *bp; | ||
| 145 | struct pvr2_stream *stream = 0; | ||
| 146 | |||
| 147 | if (adap->stream_run) return -EIO; | ||
| 148 | |||
| 149 | ret = pvr2_channel_claim_stream(&adap->channel, &pvr->video_stream); | ||
| 150 | /* somebody else already has the stream */ | ||
| 151 | if (ret < 0) return ret; | ||
| 152 | |||
| 153 | stream = adap->channel.stream->stream; | ||
| 154 | |||
| 155 | for (idx = 0; idx < PVR2_DVB_BUFFER_COUNT; idx++) { | ||
| 156 | adap->buffer_storage[idx] = kmalloc(PVR2_DVB_BUFFER_SIZE, | ||
| 157 | GFP_KERNEL); | ||
| 158 | if (!(adap->buffer_storage[idx])) return -ENOMEM; | ||
| 159 | } | ||
| 160 | |||
| 161 | pvr2_stream_set_callback(pvr->video_stream.stream, | ||
| 162 | (pvr2_stream_callback) pvr2_dvb_notify, adap); | ||
| 163 | |||
| 164 | ret = pvr2_stream_set_buffer_count(stream, PVR2_DVB_BUFFER_COUNT); | ||
| 165 | if (ret < 0) return ret; | ||
| 166 | |||
| 167 | for (idx = 0; idx < PVR2_DVB_BUFFER_COUNT; idx++) { | ||
| 168 | bp = pvr2_stream_get_buffer(stream, idx); | ||
| 169 | pvr2_buffer_set_buffer(bp, | ||
| 170 | adap->buffer_storage[idx], | ||
| 171 | PVR2_DVB_BUFFER_SIZE); | ||
| 172 | } | ||
| 173 | |||
| 174 | ret = pvr2_hdw_set_streaming(adap->channel.hdw, 1); | ||
| 175 | if (ret < 0) return ret; | ||
| 176 | |||
| 177 | while ((bp = pvr2_stream_get_idle_buffer(stream)) != 0) { | ||
| 178 | ret = pvr2_buffer_queue(bp); | ||
| 179 | if (ret < 0) return ret; | ||
| 180 | } | ||
| 181 | |||
| 182 | adap->thread = kthread_run(pvr2_dvb_feed_thread, adap, "pvrusb2-dvb"); | ||
| 183 | |||
| 184 | if (IS_ERR(adap->thread)) { | ||
| 185 | ret = PTR_ERR(adap->thread); | ||
| 186 | adap->thread = NULL; | ||
| 187 | return ret; | ||
| 188 | } | ||
| 189 | |||
| 190 | adap->stream_run = !0; | ||
| 191 | |||
| 192 | return 0; | ||
| 193 | } | ||
| 194 | |||
| 195 | static int pvr2_dvb_stream_start(struct pvr2_dvb_adapter *adap) | ||
| 196 | { | ||
| 197 | int ret = pvr2_dvb_stream_do_start(adap); | ||
| 198 | if (ret < 0) pvr2_dvb_stream_end(adap); | ||
| 199 | return ret; | ||
| 200 | } | ||
| 201 | |||
| 202 | static int pvr2_dvb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) | ||
| 203 | { | ||
| 204 | struct pvr2_dvb_adapter *adap = dvbdmxfeed->demux->priv; | ||
| 205 | int ret = 0; | ||
| 206 | |||
| 207 | if (adap == NULL) return -ENODEV; | ||
| 208 | |||
| 209 | mutex_lock(&adap->lock); | ||
| 210 | do { | ||
| 211 | if (onoff) { | ||
| 212 | if (!adap->feedcount) { | ||
| 213 | printk(KERN_DEBUG "start feeding\n"); | ||
| 214 | ret = pvr2_dvb_stream_start(adap); | ||
| 215 | if (ret < 0) break; | ||
| 216 | } | ||
| 217 | (adap->feedcount)++; | ||
| 218 | } else if (adap->feedcount > 0) { | ||
| 219 | (adap->feedcount)--; | ||
| 220 | if (!adap->feedcount) { | ||
| 221 | printk(KERN_DEBUG "stop feeding\n"); | ||
| 222 | pvr2_dvb_stream_end(adap); | ||
| 223 | } | ||
| 224 | } | ||
| 225 | } while (0); | ||
| 226 | mutex_unlock(&adap->lock); | ||
| 227 | |||
| 228 | return ret; | ||
| 229 | } | ||
| 230 | |||
| 231 | static int pvr2_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed) | ||
| 232 | { | ||
| 233 | printk(KERN_DEBUG "start pid: 0x%04x, feedtype: %d\n", | ||
| 234 | dvbdmxfeed->pid, dvbdmxfeed->type); | ||
| 235 | return pvr2_dvb_ctrl_feed(dvbdmxfeed, 1); | ||
| 236 | } | ||
| 237 | |||
| 238 | static int pvr2_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) | ||
| 239 | { | ||
| 240 | printk(KERN_DEBUG "stop pid: 0x%04x, feedtype: %d\n", | ||
| 241 | dvbdmxfeed->pid, dvbdmxfeed->type); | ||
| 242 | return pvr2_dvb_ctrl_feed(dvbdmxfeed, 0); | ||
| 243 | } | ||
| 244 | |||
| 245 | static int pvr2_dvb_bus_ctrl(struct dvb_frontend *fe, int acquire) | ||
| 246 | { | ||
| 247 | struct pvr2_dvb_adapter *adap = fe->dvb->priv; | ||
| 248 | return pvr2_channel_limit_inputs( | ||
| 249 | &adap->channel, | ||
| 250 | (acquire ? (1 << PVR2_CVAL_INPUT_DTV) : 0)); | ||
| 251 | } | ||
| 252 | |||
| 253 | static int pvr2_dvb_adapter_init(struct pvr2_dvb_adapter *adap) | ||
| 254 | { | ||
| 255 | int ret; | ||
| 256 | |||
| 257 | ret = dvb_register_adapter(&adap->dvb_adap, "pvrusb2-dvb", | ||
| 258 | THIS_MODULE/*&hdw->usb_dev->owner*/, | ||
| 259 | &adap->channel.hdw->usb_dev->dev, | ||
| 260 | adapter_nr); | ||
| 261 | if (ret < 0) { | ||
| 262 | err("dvb_register_adapter failed: error %d", ret); | ||
| 263 | goto err; | ||
| 264 | } | ||
| 265 | adap->dvb_adap.priv = adap; | ||
| 266 | |||
| 267 | adap->demux.dmx.capabilities = DMX_TS_FILTERING | | ||
| 268 | DMX_SECTION_FILTERING | | ||
| 269 | DMX_MEMORY_BASED_FILTERING; | ||
| 270 | adap->demux.priv = adap; | ||
| 271 | adap->demux.filternum = 256; | ||
| 272 | adap->demux.feednum = 256; | ||
| 273 | adap->demux.start_feed = pvr2_dvb_start_feed; | ||
| 274 | adap->demux.stop_feed = pvr2_dvb_stop_feed; | ||
| 275 | adap->demux.write_to_decoder = NULL; | ||
| 276 | |||
| 277 | ret = dvb_dmx_init(&adap->demux); | ||
| 278 | if (ret < 0) { | ||
| 279 | err("dvb_dmx_init failed: error %d", ret); | ||
| 280 | goto err_dmx; | ||
| 281 | } | ||
| 282 | |||
| 283 | adap->dmxdev.filternum = adap->demux.filternum; | ||
| 284 | adap->dmxdev.demux = &adap->demux.dmx; | ||
| 285 | adap->dmxdev.capabilities = 0; | ||
| 286 | |||
| 287 | ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap); | ||
| 288 | if (ret < 0) { | ||
| 289 | err("dvb_dmxdev_init failed: error %d", ret); | ||
| 290 | goto err_dmx_dev; | ||
| 291 | } | ||
| 292 | |||
| 293 | dvb_net_init(&adap->dvb_adap, &adap->dvb_net, &adap->demux.dmx); | ||
| 294 | |||
| 295 | return 0; | ||
| 296 | |||
| 297 | err_dmx_dev: | ||
| 298 | dvb_dmx_release(&adap->demux); | ||
| 299 | err_dmx: | ||
| 300 | dvb_unregister_adapter(&adap->dvb_adap); | ||
| 301 | err: | ||
| 302 | return ret; | ||
| 303 | } | ||
| 304 | |||
| 305 | static int pvr2_dvb_adapter_exit(struct pvr2_dvb_adapter *adap) | ||
| 306 | { | ||
| 307 | printk(KERN_DEBUG "unregistering DVB devices\n"); | ||
| 308 | dvb_net_release(&adap->dvb_net); | ||
| 309 | adap->demux.dmx.close(&adap->demux.dmx); | ||
| 310 | dvb_dmxdev_release(&adap->dmxdev); | ||
| 311 | dvb_dmx_release(&adap->demux); | ||
| 312 | dvb_unregister_adapter(&adap->dvb_adap); | ||
| 313 | return 0; | ||
| 314 | } | ||
| 315 | |||
| 316 | static int pvr2_dvb_frontend_init(struct pvr2_dvb_adapter *adap) | ||
| 317 | { | ||
| 318 | struct pvr2_hdw *hdw = adap->channel.hdw; | ||
| 319 | struct pvr2_dvb_props *dvb_props = hdw->hdw_desc->dvb_props; | ||
| 320 | int ret = 0; | ||
| 321 | |||
| 322 | if (dvb_props == NULL) { | ||
| 323 | err("fe_props not defined!"); | ||
| 324 | return -EINVAL; | ||
| 325 | } | ||
| 326 | |||
| 327 | ret = pvr2_channel_limit_inputs( | ||
| 328 | &adap->channel, | ||
| 329 | (1 << PVR2_CVAL_INPUT_DTV)); | ||
| 330 | if (ret) { | ||
| 331 | err("failed to grab control of dtv input (code=%d)", | ||
| 332 | ret); | ||
| 333 | return ret; | ||
| 334 | } | ||
| 335 | |||
| 336 | if (dvb_props->frontend_attach == NULL) { | ||
| 337 | err("frontend_attach not defined!"); | ||
| 338 | ret = -EINVAL; | ||
| 339 | goto done; | ||
| 340 | } | ||
| 341 | |||
| 342 | if ((dvb_props->frontend_attach(adap) == 0) && (adap->fe)) { | ||
| 343 | |||
| 344 | if (dvb_register_frontend(&adap->dvb_adap, adap->fe)) { | ||
| 345 | err("frontend registration failed!"); | ||
| 346 | dvb_frontend_detach(adap->fe); | ||
| 347 | adap->fe = NULL; | ||
| 348 | ret = -ENODEV; | ||
| 349 | goto done; | ||
| 350 | } | ||
| 351 | |||
| 352 | if (dvb_props->tuner_attach) | ||
| 353 | dvb_props->tuner_attach(adap); | ||
| 354 | |||
| 355 | if (adap->fe->ops.analog_ops.standby) | ||
| 356 | adap->fe->ops.analog_ops.standby(adap->fe); | ||
| 357 | |||
| 358 | /* Ensure all frontends negotiate bus access */ | ||
| 359 | adap->fe->ops.ts_bus_ctrl = pvr2_dvb_bus_ctrl; | ||
| 360 | |||
| 361 | } else { | ||
| 362 | err("no frontend was attached!"); | ||
| 363 | ret = -ENODEV; | ||
| 364 | return ret; | ||
| 365 | } | ||
| 366 | |||
| 367 | done: | ||
| 368 | pvr2_channel_limit_inputs(&adap->channel, 0); | ||
| 369 | return ret; | ||
| 370 | } | ||
| 371 | |||
| 372 | static int pvr2_dvb_frontend_exit(struct pvr2_dvb_adapter *adap) | ||
| 373 | { | ||
| 374 | if (adap->fe != NULL) { | ||
| 375 | dvb_unregister_frontend(adap->fe); | ||
| 376 | dvb_frontend_detach(adap->fe); | ||
| 377 | } | ||
| 378 | return 0; | ||
| 379 | } | ||
| 380 | |||
| 381 | static void pvr2_dvb_destroy(struct pvr2_dvb_adapter *adap) | ||
| 382 | { | ||
| 383 | pvr2_dvb_stream_end(adap); | ||
| 384 | pvr2_dvb_frontend_exit(adap); | ||
| 385 | pvr2_dvb_adapter_exit(adap); | ||
| 386 | pvr2_channel_done(&adap->channel); | ||
| 387 | kfree(adap); | ||
| 388 | } | ||
| 389 | |||
| 390 | static void pvr2_dvb_internal_check(struct pvr2_channel *chp) | ||
| 391 | { | ||
| 392 | struct pvr2_dvb_adapter *adap; | ||
| 393 | adap = container_of(chp, struct pvr2_dvb_adapter, channel); | ||
| 394 | if (!adap->channel.mc_head->disconnect_flag) return; | ||
| 395 | pvr2_dvb_destroy(adap); | ||
| 396 | } | ||
| 397 | |||
| 398 | struct pvr2_dvb_adapter *pvr2_dvb_create(struct pvr2_context *pvr) | ||
| 399 | { | ||
| 400 | int ret = 0; | ||
| 401 | struct pvr2_dvb_adapter *adap; | ||
| 402 | if (!pvr->hdw->hdw_desc->dvb_props) { | ||
| 403 | /* Device lacks a digital interface so don't set up | ||
| 404 | the DVB side of the driver either. For now. */ | ||
| 405 | return NULL; | ||
| 406 | } | ||
| 407 | adap = kzalloc(sizeof(*adap), GFP_KERNEL); | ||
| 408 | if (!adap) return adap; | ||
| 409 | pvr2_channel_init(&adap->channel, pvr); | ||
| 410 | adap->channel.check_func = pvr2_dvb_internal_check; | ||
| 411 | init_waitqueue_head(&adap->buffer_wait_data); | ||
| 412 | mutex_init(&adap->lock); | ||
| 413 | ret = pvr2_dvb_adapter_init(adap); | ||
| 414 | if (ret < 0) goto fail1; | ||
| 415 | ret = pvr2_dvb_frontend_init(adap); | ||
| 416 | if (ret < 0) goto fail2; | ||
| 417 | return adap; | ||
| 418 | |||
| 419 | fail2: | ||
| 420 | pvr2_dvb_adapter_exit(adap); | ||
| 421 | fail1: | ||
| 422 | pvr2_channel_done(&adap->channel); | ||
| 423 | return NULL; | ||
| 424 | } | ||
| 425 | |||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-dvb.h b/drivers/media/video/pvrusb2/pvrusb2-dvb.h new file mode 100644 index 000000000000..884ff916a352 --- /dev/null +++ b/drivers/media/video/pvrusb2/pvrusb2-dvb.h | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | #ifndef __PVRUSB2_DVB_H__ | ||
| 2 | #define __PVRUSB2_DVB_H__ | ||
| 3 | |||
| 4 | #include "dvb_frontend.h" | ||
| 5 | #include "dvb_demux.h" | ||
| 6 | #include "dvb_net.h" | ||
| 7 | #include "dmxdev.h" | ||
| 8 | #include "pvrusb2-context.h" | ||
| 9 | |||
| 10 | #define PVR2_DVB_BUFFER_COUNT 32 | ||
| 11 | #define PVR2_DVB_BUFFER_SIZE PAGE_ALIGN(0x4000) | ||
| 12 | |||
| 13 | struct pvr2_dvb_adapter { | ||
| 14 | struct pvr2_channel channel; | ||
| 15 | |||
| 16 | struct dvb_adapter dvb_adap; | ||
| 17 | struct dmxdev dmxdev; | ||
| 18 | struct dvb_demux demux; | ||
| 19 | struct dvb_net dvb_net; | ||
| 20 | struct dvb_frontend *fe; | ||
| 21 | |||
| 22 | int feedcount; | ||
| 23 | int max_feed_count; | ||
| 24 | |||
| 25 | struct task_struct *thread; | ||
| 26 | struct mutex lock; | ||
| 27 | |||
| 28 | unsigned int stream_run:1; | ||
| 29 | |||
| 30 | wait_queue_head_t buffer_wait_data; | ||
| 31 | char *buffer_storage[PVR2_DVB_BUFFER_COUNT]; | ||
| 32 | }; | ||
| 33 | |||
| 34 | struct pvr2_dvb_props { | ||
| 35 | int (*frontend_attach) (struct pvr2_dvb_adapter *); | ||
| 36 | int (*tuner_attach) (struct pvr2_dvb_adapter *); | ||
| 37 | }; | ||
| 38 | |||
| 39 | struct pvr2_dvb_adapter *pvr2_dvb_create(struct pvr2_context *pvr); | ||
| 40 | |||
| 41 | #endif /* __PVRUSB2_DVB_H__ */ | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-encoder.c b/drivers/media/video/pvrusb2/pvrusb2-encoder.c index 64062879981e..c46d367f7472 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-encoder.c +++ b/drivers/media/video/pvrusb2/pvrusb2-encoder.c | |||
| @@ -278,11 +278,20 @@ static int pvr2_encoder_cmd(void *ctxt, | |||
| 278 | ret = -EBUSY; | 278 | ret = -EBUSY; |
| 279 | } | 279 | } |
| 280 | if (ret) { | 280 | if (ret) { |
| 281 | del_timer_sync(&hdw->encoder_run_timer); | ||
| 281 | hdw->state_encoder_ok = 0; | 282 | hdw->state_encoder_ok = 0; |
| 282 | pvr2_trace(PVR2_TRACE_STBITS, | 283 | pvr2_trace(PVR2_TRACE_STBITS, |
| 283 | "State bit %s <-- %s", | 284 | "State bit %s <-- %s", |
| 284 | "state_encoder_ok", | 285 | "state_encoder_ok", |
| 285 | (hdw->state_encoder_ok ? "true" : "false")); | 286 | (hdw->state_encoder_ok ? "true" : "false")); |
| 287 | if (hdw->state_encoder_runok) { | ||
| 288 | hdw->state_encoder_runok = 0; | ||
| 289 | pvr2_trace(PVR2_TRACE_STBITS, | ||
| 290 | "State bit %s <-- %s", | ||
| 291 | "state_encoder_runok", | ||
| 292 | (hdw->state_encoder_runok ? | ||
| 293 | "true" : "false")); | ||
| 294 | } | ||
| 286 | pvr2_trace( | 295 | pvr2_trace( |
| 287 | PVR2_TRACE_ERROR_LEGS, | 296 | PVR2_TRACE_ERROR_LEGS, |
| 288 | "Giving up on command." | 297 | "Giving up on command." |
| @@ -480,10 +489,6 @@ int pvr2_encoder_start(struct pvr2_hdw *hdw) | |||
| 480 | /* unmask some interrupts */ | 489 | /* unmask some interrupts */ |
| 481 | pvr2_write_register(hdw, 0x0048, 0xbfffffff); | 490 | pvr2_write_register(hdw, 0x0048, 0xbfffffff); |
| 482 | 491 | ||
| 483 | /* change some GPIO data */ | ||
| 484 | pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000481); | ||
| 485 | pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000000); | ||
| 486 | |||
| 487 | pvr2_encoder_vcmd(hdw,CX2341X_ENC_MUTE_VIDEO,1, | 492 | pvr2_encoder_vcmd(hdw,CX2341X_ENC_MUTE_VIDEO,1, |
| 488 | hdw->input_val == PVR2_CVAL_INPUT_RADIO ? 1 : 0); | 493 | hdw->input_val == PVR2_CVAL_INPUT_RADIO ? 1 : 0); |
| 489 | 494 | ||
| @@ -526,12 +531,6 @@ int pvr2_encoder_stop(struct pvr2_hdw *hdw) | |||
| 526 | break; | 531 | break; |
| 527 | } | 532 | } |
| 528 | 533 | ||
| 529 | /* change some GPIO data */ | ||
| 530 | /* Note: Bit d7 of dir appears to control the LED. So we shut it | ||
| 531 | off here. */ | ||
| 532 | pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000401); | ||
| 533 | pvr2_hdw_gpio_chg_out(hdw,0xffffffff,0x00000000); | ||
| 534 | |||
| 535 | return status; | 534 | return status; |
| 536 | } | 535 | } |
| 537 | 536 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h b/drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h index ffbc6d096108..abaada31e66e 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h +++ b/drivers/media/video/pvrusb2/pvrusb2-fx2-cmd.h | |||
| @@ -22,32 +22,41 @@ | |||
| 22 | #ifndef _PVRUSB2_FX2_CMD_H_ | 22 | #ifndef _PVRUSB2_FX2_CMD_H_ |
| 23 | #define _PVRUSB2_FX2_CMD_H_ | 23 | #define _PVRUSB2_FX2_CMD_H_ |
| 24 | 24 | ||
| 25 | #define FX2CMD_MEM_WRITE_DWORD 0x01 | 25 | #define FX2CMD_MEM_WRITE_DWORD 0x01u |
| 26 | #define FX2CMD_MEM_READ_DWORD 0x02 | 26 | #define FX2CMD_MEM_READ_DWORD 0x02u |
| 27 | 27 | ||
| 28 | #define FX2CMD_MEM_READ_64BYTES 0x28 | 28 | #define FX2CMD_MEM_READ_64BYTES 0x28u |
| 29 | 29 | ||
| 30 | #define FX2CMD_REG_WRITE 0x04 | 30 | #define FX2CMD_REG_WRITE 0x04u |
| 31 | #define FX2CMD_REG_READ 0x05 | 31 | #define FX2CMD_REG_READ 0x05u |
| 32 | #define FX2CMD_MEMSEL 0x06 | 32 | #define FX2CMD_MEMSEL 0x06u |
| 33 | 33 | ||
| 34 | #define FX2CMD_I2C_WRITE 0x08 | 34 | #define FX2CMD_I2C_WRITE 0x08u |
| 35 | #define FX2CMD_I2C_READ 0x09 | 35 | #define FX2CMD_I2C_READ 0x09u |
| 36 | 36 | ||
| 37 | #define FX2CMD_GET_USB_SPEED 0x0b | 37 | #define FX2CMD_GET_USB_SPEED 0x0bu |
| 38 | 38 | ||
| 39 | #define FX2CMD_STREAMING_ON 0x36 | 39 | #define FX2CMD_STREAMING_ON 0x36u |
| 40 | #define FX2CMD_STREAMING_OFF 0x37 | 40 | #define FX2CMD_STREAMING_OFF 0x37u |
| 41 | 41 | ||
| 42 | #define FX2CMD_FWPOST1 0x52 | 42 | #define FX2CMD_FWPOST1 0x52u |
| 43 | 43 | ||
| 44 | #define FX2CMD_POWER_OFF 0xdc | 44 | #define FX2CMD_POWER_OFF 0xdcu |
| 45 | #define FX2CMD_POWER_ON 0xde | 45 | #define FX2CMD_POWER_ON 0xdeu |
| 46 | 46 | ||
| 47 | #define FX2CMD_DEEP_RESET 0xdd | 47 | #define FX2CMD_DEEP_RESET 0xddu |
| 48 | 48 | ||
| 49 | #define FX2CMD_GET_EEPROM_ADDR 0xeb | 49 | #define FX2CMD_GET_EEPROM_ADDR 0xebu |
| 50 | #define FX2CMD_GET_IR_CODE 0xec | 50 | #define FX2CMD_GET_IR_CODE 0xecu |
| 51 | |||
| 52 | #define FX2CMD_HCW_DEMOD_RESETIN 0xf0u | ||
| 53 | #define FX2CMD_HCW_DTV_STREAMING_ON 0xf1u | ||
| 54 | #define FX2CMD_HCW_DTV_STREAMING_OFF 0xf2u | ||
| 55 | |||
| 56 | #define FX2CMD_ONAIR_DTV_STREAMING_ON 0xa0u | ||
| 57 | #define FX2CMD_ONAIR_DTV_STREAMING_OFF 0xa1u | ||
| 58 | #define FX2CMD_ONAIR_DTV_POWER_ON 0xa2u | ||
| 59 | #define FX2CMD_ONAIR_DTV_POWER_OFF 0xa3u | ||
| 51 | 60 | ||
| 52 | #endif /* _PVRUSB2_FX2_CMD_H_ */ | 61 | #endif /* _PVRUSB2_FX2_CMD_H_ */ |
| 53 | 62 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h index d7a216b41b72..a3fe251d6fd9 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h | |||
| @@ -163,6 +163,11 @@ struct pvr2_decoder_ctrl { | |||
| 163 | #define FW1_STATE_RELOAD 3 | 163 | #define FW1_STATE_RELOAD 3 |
| 164 | #define FW1_STATE_OK 4 | 164 | #define FW1_STATE_OK 4 |
| 165 | 165 | ||
| 166 | /* What state the device is in if it is a hybrid */ | ||
| 167 | #define PVR2_PATHWAY_UNKNOWN 0 | ||
| 168 | #define PVR2_PATHWAY_ANALOG 1 | ||
| 169 | #define PVR2_PATHWAY_DIGITAL 2 | ||
| 170 | |||
| 166 | typedef int (*pvr2_i2c_func)(struct pvr2_hdw *,u8,u8 *,u16,u8 *, u16); | 171 | typedef int (*pvr2_i2c_func)(struct pvr2_hdw *,u8,u8 *,u16,u8 *, u16); |
| 167 | #define PVR2_I2C_FUNC_CNT 128 | 172 | #define PVR2_I2C_FUNC_CNT 128 |
| 168 | 173 | ||
| @@ -182,7 +187,6 @@ struct pvr2_hdw { | |||
| 182 | struct workqueue_struct *workqueue; | 187 | struct workqueue_struct *workqueue; |
| 183 | struct work_struct workpoll; /* Update driver state */ | 188 | struct work_struct workpoll; /* Update driver state */ |
| 184 | struct work_struct worki2csync; /* Update i2c clients */ | 189 | struct work_struct worki2csync; /* Update i2c clients */ |
| 185 | struct work_struct workinit; /* Driver initialization sequence */ | ||
| 186 | 190 | ||
| 187 | /* Video spigot */ | 191 | /* Video spigot */ |
| 188 | struct pvr2_stream *vid_stream; | 192 | struct pvr2_stream *vid_stream; |
| @@ -229,17 +233,19 @@ struct pvr2_hdw { | |||
| 229 | 233 | ||
| 230 | /* Bits of state that describe what is going on with various parts | 234 | /* Bits of state that describe what is going on with various parts |
| 231 | of the driver. */ | 235 | of the driver. */ |
| 236 | int state_pathway_ok; /* Pathway config is ok */ | ||
| 232 | int state_encoder_ok; /* Encoder is operational */ | 237 | int state_encoder_ok; /* Encoder is operational */ |
| 233 | int state_encoder_run; /* Encoder is running */ | 238 | int state_encoder_run; /* Encoder is running */ |
| 234 | int state_encoder_config; /* Encoder is configured */ | 239 | int state_encoder_config; /* Encoder is configured */ |
| 235 | int state_encoder_waitok; /* Encoder pre-wait done */ | 240 | int state_encoder_waitok; /* Encoder pre-wait done */ |
| 241 | int state_encoder_runok; /* Encoder has run for >= .25 sec */ | ||
| 236 | int state_decoder_run; /* Decoder is running */ | 242 | int state_decoder_run; /* Decoder is running */ |
| 237 | int state_usbstream_run; /* FX2 is streaming */ | 243 | int state_usbstream_run; /* FX2 is streaming */ |
| 238 | int state_decoder_quiescent; /* Decoder idle for > 50msec */ | 244 | int state_decoder_quiescent; /* Decoder idle for > 50msec */ |
| 239 | int state_pipeline_config; /* Pipeline is configured */ | 245 | int state_pipeline_config; /* Pipeline is configured */ |
| 240 | int state_pipeline_req; /* Somebody wants to stream */ | 246 | int state_pipeline_req; /* Somebody wants to stream */ |
| 241 | int state_pipeline_pause; /* Pipeline must be paused */ | 247 | int state_pipeline_pause; /* Pipeline must be paused */ |
| 242 | int state_pipeline_idle; /* Pipeline not running */ | 248 | int state_pipeline_idle; /* Pipeline not running */ |
| 243 | 249 | ||
| 244 | /* This is the master state of the driver. It is the combined | 250 | /* This is the master state of the driver. It is the combined |
| 245 | result of other bits of state. Examining this will indicate the | 251 | result of other bits of state. Examining this will indicate the |
| @@ -247,6 +253,9 @@ struct pvr2_hdw { | |||
| 247 | PVR2_STATE_xxxx */ | 253 | PVR2_STATE_xxxx */ |
| 248 | unsigned int master_state; | 254 | unsigned int master_state; |
| 249 | 255 | ||
| 256 | /* True if device led is currently on */ | ||
| 257 | int led_on; | ||
| 258 | |||
| 250 | /* True if states must be re-evaluated */ | 259 | /* True if states must be re-evaluated */ |
| 251 | int state_stale; | 260 | int state_stale; |
| 252 | 261 | ||
| @@ -259,6 +268,9 @@ struct pvr2_hdw { | |||
| 259 | /* Timer for measuring encoder pre-wait time */ | 268 | /* Timer for measuring encoder pre-wait time */ |
| 260 | struct timer_list encoder_wait_timer; | 269 | struct timer_list encoder_wait_timer; |
| 261 | 270 | ||
| 271 | /* Timer for measuring encoder minimum run time */ | ||
| 272 | struct timer_list encoder_run_timer; | ||
| 273 | |||
| 262 | /* Place to block while waiting for state changes */ | 274 | /* Place to block while waiting for state changes */ |
| 263 | wait_queue_head_t state_wait_data; | 275 | wait_queue_head_t state_wait_data; |
| 264 | 276 | ||
| @@ -267,6 +279,7 @@ struct pvr2_hdw { | |||
| 267 | int flag_disconnected; /* flag_ok == 0 due to disconnect */ | 279 | int flag_disconnected; /* flag_ok == 0 due to disconnect */ |
| 268 | int flag_init_ok; /* true if structure is fully initialized */ | 280 | int flag_init_ok; /* true if structure is fully initialized */ |
| 269 | int fw1_state; /* current situation with fw1 */ | 281 | int fw1_state; /* current situation with fw1 */ |
| 282 | int pathway_state; /* one of PVR2_PATHWAY_xxx */ | ||
| 270 | int flag_decoder_missed;/* We've noticed missing decoder */ | 283 | int flag_decoder_missed;/* We've noticed missing decoder */ |
| 271 | int flag_tripped; /* Indicates overall failure to start */ | 284 | int flag_tripped; /* Indicates overall failure to start */ |
| 272 | 285 | ||
| @@ -323,6 +336,11 @@ struct pvr2_hdw { | |||
| 323 | int v4l_minor_number_vbi; | 336 | int v4l_minor_number_vbi; |
| 324 | int v4l_minor_number_radio; | 337 | int v4l_minor_number_radio; |
| 325 | 338 | ||
| 339 | /* Bit mask of PVR2_CVAL_INPUT choices which are valid for the hardware */ | ||
| 340 | unsigned int input_avail_mask; | ||
| 341 | /* Bit mask of PVR2_CVAL_INPUT choices which are currenly allowed */ | ||
| 342 | unsigned int input_allowed_mask; | ||
| 343 | |||
| 326 | /* Location of eeprom or a negative number if none */ | 344 | /* Location of eeprom or a negative number if none */ |
| 327 | int eeprom_addr; | 345 | int eeprom_addr; |
| 328 | 346 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c index 2404053a4d85..0a868888f389 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c | |||
| @@ -43,13 +43,13 @@ | |||
| 43 | static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL}; | 43 | static struct pvr2_hdw *unit_pointers[PVR_NUM] = {[ 0 ... PVR_NUM-1 ] = NULL}; |
| 44 | static DEFINE_MUTEX(pvr2_unit_mtx); | 44 | static DEFINE_MUTEX(pvr2_unit_mtx); |
| 45 | 45 | ||
| 46 | static int ctlchg = 0; | 46 | static int ctlchg; |
| 47 | static int initusbreset = 1; | 47 | static int initusbreset = 1; |
| 48 | static int procreload = 0; | 48 | static int procreload; |
| 49 | static int tuner[PVR_NUM] = { [0 ... PVR_NUM-1] = -1 }; | 49 | static int tuner[PVR_NUM] = { [0 ... PVR_NUM-1] = -1 }; |
| 50 | static int tolerance[PVR_NUM] = { [0 ... PVR_NUM-1] = 0 }; | 50 | static int tolerance[PVR_NUM] = { [0 ... PVR_NUM-1] = 0 }; |
| 51 | static int video_std[PVR_NUM] = { [0 ... PVR_NUM-1] = 0 }; | 51 | static int video_std[PVR_NUM] = { [0 ... PVR_NUM-1] = 0 }; |
| 52 | static int init_pause_msec = 0; | 52 | static int init_pause_msec; |
| 53 | 53 | ||
| 54 | module_param(ctlchg, int, S_IRUGO|S_IWUSR); | 54 | module_param(ctlchg, int, S_IRUGO|S_IWUSR); |
| 55 | MODULE_PARM_DESC(ctlchg, "0=optimize ctl change 1=always accept new ctl value"); | 55 | MODULE_PARM_DESC(ctlchg, "0=optimize ctl change 1=always accept new ctl value"); |
| @@ -182,6 +182,7 @@ static const char *control_values_srate[] = { | |||
| 182 | 182 | ||
| 183 | static const char *control_values_input[] = { | 183 | static const char *control_values_input[] = { |
| 184 | [PVR2_CVAL_INPUT_TV] = "television", /*xawtv needs this name*/ | 184 | [PVR2_CVAL_INPUT_TV] = "television", /*xawtv needs this name*/ |
| 185 | [PVR2_CVAL_INPUT_DTV] = "dtv", | ||
| 185 | [PVR2_CVAL_INPUT_RADIO] = "radio", | 186 | [PVR2_CVAL_INPUT_RADIO] = "radio", |
| 186 | [PVR2_CVAL_INPUT_SVIDEO] = "s-video", | 187 | [PVR2_CVAL_INPUT_SVIDEO] = "s-video", |
| 187 | [PVR2_CVAL_INPUT_COMPOSITE] = "composite", | 188 | [PVR2_CVAL_INPUT_COMPOSITE] = "composite", |
| @@ -215,12 +216,45 @@ static const char *pvr2_state_names[] = { | |||
| 215 | }; | 216 | }; |
| 216 | 217 | ||
| 217 | 218 | ||
| 219 | struct pvr2_fx2cmd_descdef { | ||
| 220 | unsigned char id; | ||
| 221 | unsigned char *desc; | ||
| 222 | }; | ||
| 223 | |||
| 224 | static const struct pvr2_fx2cmd_descdef pvr2_fx2cmd_desc[] = { | ||
| 225 | {FX2CMD_MEM_WRITE_DWORD, "write encoder dword"}, | ||
| 226 | {FX2CMD_MEM_READ_DWORD, "read encoder dword"}, | ||
| 227 | {FX2CMD_MEM_READ_64BYTES, "read encoder 64bytes"}, | ||
| 228 | {FX2CMD_REG_WRITE, "write encoder register"}, | ||
| 229 | {FX2CMD_REG_READ, "read encoder register"}, | ||
| 230 | {FX2CMD_MEMSEL, "encoder memsel"}, | ||
| 231 | {FX2CMD_I2C_WRITE, "i2c write"}, | ||
| 232 | {FX2CMD_I2C_READ, "i2c read"}, | ||
| 233 | {FX2CMD_GET_USB_SPEED, "get USB speed"}, | ||
| 234 | {FX2CMD_STREAMING_ON, "stream on"}, | ||
| 235 | {FX2CMD_STREAMING_OFF, "stream off"}, | ||
| 236 | {FX2CMD_FWPOST1, "fwpost1"}, | ||
| 237 | {FX2CMD_POWER_OFF, "power off"}, | ||
| 238 | {FX2CMD_POWER_ON, "power on"}, | ||
| 239 | {FX2CMD_DEEP_RESET, "deep reset"}, | ||
| 240 | {FX2CMD_GET_EEPROM_ADDR, "get rom addr"}, | ||
| 241 | {FX2CMD_GET_IR_CODE, "get IR code"}, | ||
| 242 | {FX2CMD_HCW_DEMOD_RESETIN, "hcw demod resetin"}, | ||
| 243 | {FX2CMD_HCW_DTV_STREAMING_ON, "hcw dtv stream on"}, | ||
| 244 | {FX2CMD_HCW_DTV_STREAMING_OFF, "hcw dtv stream off"}, | ||
| 245 | {FX2CMD_ONAIR_DTV_STREAMING_ON, "onair dtv stream on"}, | ||
| 246 | {FX2CMD_ONAIR_DTV_STREAMING_OFF, "onair dtv stream off"}, | ||
| 247 | {FX2CMD_ONAIR_DTV_POWER_ON, "onair dtv power on"}, | ||
| 248 | {FX2CMD_ONAIR_DTV_POWER_OFF, "onair dtv power off"}, | ||
| 249 | }; | ||
| 250 | |||
| 251 | |||
| 252 | static int pvr2_hdw_set_input(struct pvr2_hdw *hdw,int v); | ||
| 218 | static void pvr2_hdw_state_sched(struct pvr2_hdw *); | 253 | static void pvr2_hdw_state_sched(struct pvr2_hdw *); |
| 219 | static int pvr2_hdw_state_eval(struct pvr2_hdw *); | 254 | static int pvr2_hdw_state_eval(struct pvr2_hdw *); |
| 220 | static void pvr2_hdw_set_cur_freq(struct pvr2_hdw *,unsigned long); | 255 | static void pvr2_hdw_set_cur_freq(struct pvr2_hdw *,unsigned long); |
| 221 | static void pvr2_hdw_worker_i2c(struct work_struct *work); | 256 | static void pvr2_hdw_worker_i2c(struct work_struct *work); |
| 222 | static void pvr2_hdw_worker_poll(struct work_struct *work); | 257 | static void pvr2_hdw_worker_poll(struct work_struct *work); |
| 223 | static void pvr2_hdw_worker_init(struct work_struct *work); | ||
| 224 | static int pvr2_hdw_wait(struct pvr2_hdw *,int state); | 258 | static int pvr2_hdw_wait(struct pvr2_hdw *,int state); |
| 225 | static int pvr2_hdw_untrip_unlocked(struct pvr2_hdw *); | 259 | static int pvr2_hdw_untrip_unlocked(struct pvr2_hdw *); |
| 226 | static void pvr2_hdw_state_log_state(struct pvr2_hdw *); | 260 | static void pvr2_hdw_state_log_state(struct pvr2_hdw *); |
| @@ -231,6 +265,8 @@ static void pvr2_hdw_internal_find_stdenum(struct pvr2_hdw *hdw); | |||
| 231 | static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw); | 265 | static void pvr2_hdw_internal_set_std_avail(struct pvr2_hdw *hdw); |
| 232 | static void pvr2_hdw_quiescent_timeout(unsigned long); | 266 | static void pvr2_hdw_quiescent_timeout(unsigned long); |
| 233 | static void pvr2_hdw_encoder_wait_timeout(unsigned long); | 267 | static void pvr2_hdw_encoder_wait_timeout(unsigned long); |
| 268 | static void pvr2_hdw_encoder_run_timeout(unsigned long); | ||
| 269 | static int pvr2_issue_simple_cmd(struct pvr2_hdw *,u32); | ||
| 234 | static int pvr2_send_request_ex(struct pvr2_hdw *hdw, | 270 | static int pvr2_send_request_ex(struct pvr2_hdw *hdw, |
| 235 | unsigned int timeout,int probe_fl, | 271 | unsigned int timeout,int probe_fl, |
| 236 | void *write_data,unsigned int write_len, | 272 | void *write_data,unsigned int write_len, |
| @@ -367,26 +403,14 @@ static int ctrl_get_input(struct pvr2_ctrl *cptr,int *vp) | |||
| 367 | return 0; | 403 | return 0; |
| 368 | } | 404 | } |
| 369 | 405 | ||
| 370 | static int ctrl_set_input(struct pvr2_ctrl *cptr,int m,int v) | 406 | static int ctrl_check_input(struct pvr2_ctrl *cptr,int v) |
| 371 | { | 407 | { |
| 372 | struct pvr2_hdw *hdw = cptr->hdw; | 408 | return ((1 << v) & cptr->hdw->input_allowed_mask) != 0; |
| 373 | 409 | } | |
| 374 | if (hdw->input_val != v) { | ||
| 375 | hdw->input_val = v; | ||
| 376 | hdw->input_dirty = !0; | ||
| 377 | } | ||
| 378 | 410 | ||
| 379 | /* Handle side effects - if we switch to a mode that needs the RF | 411 | static int ctrl_set_input(struct pvr2_ctrl *cptr,int m,int v) |
| 380 | tuner, then select the right frequency choice as well and mark | 412 | { |
| 381 | it dirty. */ | 413 | return pvr2_hdw_set_input(cptr->hdw,v); |
| 382 | if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { | ||
| 383 | hdw->freqSelector = 0; | ||
| 384 | hdw->freqDirty = !0; | ||
| 385 | } else if (hdw->input_val == PVR2_CVAL_INPUT_TV) { | ||
| 386 | hdw->freqSelector = 1; | ||
| 387 | hdw->freqDirty = !0; | ||
| 388 | } | ||
| 389 | return 0; | ||
| 390 | } | 414 | } |
| 391 | 415 | ||
| 392 | static int ctrl_isdirty_input(struct pvr2_ctrl *cptr) | 416 | static int ctrl_isdirty_input(struct pvr2_ctrl *cptr) |
| @@ -803,6 +827,7 @@ static const struct pvr2_ctl_info control_defs[] = { | |||
| 803 | .name = "input", | 827 | .name = "input", |
| 804 | .internal_id = PVR2_CID_INPUT, | 828 | .internal_id = PVR2_CID_INPUT, |
| 805 | .default_value = PVR2_CVAL_INPUT_TV, | 829 | .default_value = PVR2_CVAL_INPUT_TV, |
| 830 | .check_value = ctrl_check_input, | ||
| 806 | DEFREF(input), | 831 | DEFREF(input), |
| 807 | DEFENUM(control_values_input), | 832 | DEFENUM(control_values_input), |
| 808 | },{ | 833 | },{ |
| @@ -982,7 +1007,7 @@ unsigned long pvr2_hdw_get_cur_freq(struct pvr2_hdw *hdw) | |||
| 982 | 1007 | ||
| 983 | /* Set the currently tuned frequency and account for all possible | 1008 | /* Set the currently tuned frequency and account for all possible |
| 984 | driver-core side effects of this action. */ | 1009 | driver-core side effects of this action. */ |
| 985 | void pvr2_hdw_set_cur_freq(struct pvr2_hdw *hdw,unsigned long val) | 1010 | static void pvr2_hdw_set_cur_freq(struct pvr2_hdw *hdw,unsigned long val) |
| 986 | { | 1011 | { |
| 987 | if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { | 1012 | if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { |
| 988 | if (hdw->freqSelector) { | 1013 | if (hdw->freqSelector) { |
| @@ -1195,6 +1220,14 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw) | |||
| 1195 | time we configure the encoder, then we'll fully configure it. */ | 1220 | time we configure the encoder, then we'll fully configure it. */ |
| 1196 | hdw->enc_cur_valid = 0; | 1221 | hdw->enc_cur_valid = 0; |
| 1197 | 1222 | ||
| 1223 | /* Encoder is about to be reset so note that as far as we're | ||
| 1224 | concerned now, the encoder has never been run. */ | ||
| 1225 | del_timer_sync(&hdw->encoder_run_timer); | ||
| 1226 | if (hdw->state_encoder_runok) { | ||
| 1227 | hdw->state_encoder_runok = 0; | ||
| 1228 | trace_stbit("state_encoder_runok",hdw->state_encoder_runok); | ||
| 1229 | } | ||
| 1230 | |||
| 1198 | /* First prepare firmware loading */ | 1231 | /* First prepare firmware loading */ |
| 1199 | ret |= pvr2_write_register(hdw, 0x0048, 0xffffffff); /*interrupt mask*/ | 1232 | ret |= pvr2_write_register(hdw, 0x0048, 0xffffffff); /*interrupt mask*/ |
| 1200 | ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000088); /*gpio dir*/ | 1233 | ret |= pvr2_hdw_gpio_chg_dir(hdw,0xffffffff,0x00000088); /*gpio dir*/ |
| @@ -1212,19 +1245,14 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw) | |||
| 1212 | ret |= pvr2_write_register(hdw, 0xaa04, 0x00057810); /*unknown*/ | 1245 | ret |= pvr2_write_register(hdw, 0xaa04, 0x00057810); /*unknown*/ |
| 1213 | ret |= pvr2_write_register(hdw, 0xaa10, 0x00148500); /*unknown*/ | 1246 | ret |= pvr2_write_register(hdw, 0xaa10, 0x00148500); /*unknown*/ |
| 1214 | ret |= pvr2_write_register(hdw, 0xaa18, 0x00840000); /*unknown*/ | 1247 | ret |= pvr2_write_register(hdw, 0xaa18, 0x00840000); /*unknown*/ |
| 1215 | LOCK_TAKE(hdw->ctl_lock); do { | 1248 | ret |= pvr2_issue_simple_cmd(hdw,FX2CMD_FWPOST1); |
| 1216 | hdw->cmd_buffer[0] = FX2CMD_FWPOST1; | 1249 | ret |= pvr2_issue_simple_cmd(hdw,FX2CMD_MEMSEL | (1 << 8) | (0 << 16)); |
| 1217 | ret |= pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0); | ||
| 1218 | hdw->cmd_buffer[0] = FX2CMD_MEMSEL; | ||
| 1219 | hdw->cmd_buffer[1] = 0; | ||
| 1220 | ret |= pvr2_send_request(hdw,hdw->cmd_buffer,2,NULL,0); | ||
| 1221 | } while (0); LOCK_GIVE(hdw->ctl_lock); | ||
| 1222 | 1250 | ||
| 1223 | if (ret) { | 1251 | if (ret) { |
| 1224 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 1252 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 1225 | "firmware2 upload prep failed, ret=%d",ret); | 1253 | "firmware2 upload prep failed, ret=%d",ret); |
| 1226 | release_firmware(fw_entry); | 1254 | release_firmware(fw_entry); |
| 1227 | return ret; | 1255 | goto done; |
| 1228 | } | 1256 | } |
| 1229 | 1257 | ||
| 1230 | /* Now send firmware */ | 1258 | /* Now send firmware */ |
| @@ -1237,7 +1265,8 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw) | |||
| 1237 | " must be a multiple of %zu bytes", | 1265 | " must be a multiple of %zu bytes", |
| 1238 | fw_files[fwidx],sizeof(u32)); | 1266 | fw_files[fwidx],sizeof(u32)); |
| 1239 | release_firmware(fw_entry); | 1267 | release_firmware(fw_entry); |
| 1240 | return -1; | 1268 | ret = -EINVAL; |
| 1269 | goto done; | ||
| 1241 | } | 1270 | } |
| 1242 | 1271 | ||
| 1243 | fw_ptr = kmalloc(FIRMWARE_CHUNK_SIZE, GFP_KERNEL); | 1272 | fw_ptr = kmalloc(FIRMWARE_CHUNK_SIZE, GFP_KERNEL); |
| @@ -1245,7 +1274,8 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw) | |||
| 1245 | release_firmware(fw_entry); | 1274 | release_firmware(fw_entry); |
| 1246 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 1275 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 1247 | "failed to allocate memory for firmware2 upload"); | 1276 | "failed to allocate memory for firmware2 upload"); |
| 1248 | return -ENOMEM; | 1277 | ret = -ENOMEM; |
| 1278 | goto done; | ||
| 1249 | } | 1279 | } |
| 1250 | 1280 | ||
| 1251 | pipe = usb_sndbulkpipe(hdw->usb_dev, PVR2_FIRMWARE_ENDPOINT); | 1281 | pipe = usb_sndbulkpipe(hdw->usb_dev, PVR2_FIRMWARE_ENDPOINT); |
| @@ -1276,23 +1306,27 @@ int pvr2_upload_firmware2(struct pvr2_hdw *hdw) | |||
| 1276 | if (ret) { | 1306 | if (ret) { |
| 1277 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 1307 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 1278 | "firmware2 upload transfer failure"); | 1308 | "firmware2 upload transfer failure"); |
| 1279 | return ret; | 1309 | goto done; |
| 1280 | } | 1310 | } |
| 1281 | 1311 | ||
| 1282 | /* Finish upload */ | 1312 | /* Finish upload */ |
| 1283 | 1313 | ||
| 1284 | ret |= pvr2_write_register(hdw, 0x9054, 0xffffffff); /*reset hw blocks*/ | 1314 | ret |= pvr2_write_register(hdw, 0x9054, 0xffffffff); /*reset hw blocks*/ |
| 1285 | ret |= pvr2_write_register(hdw, 0x9058, 0xffffffe8); /*VPU ctrl*/ | 1315 | ret |= pvr2_write_register(hdw, 0x9058, 0xffffffe8); /*VPU ctrl*/ |
| 1286 | LOCK_TAKE(hdw->ctl_lock); do { | 1316 | ret |= pvr2_issue_simple_cmd(hdw,FX2CMD_MEMSEL | (1 << 8) | (0 << 16)); |
| 1287 | hdw->cmd_buffer[0] = FX2CMD_MEMSEL; | ||
| 1288 | hdw->cmd_buffer[1] = 0; | ||
| 1289 | ret |= pvr2_send_request(hdw,hdw->cmd_buffer,2,NULL,0); | ||
| 1290 | } while (0); LOCK_GIVE(hdw->ctl_lock); | ||
| 1291 | 1317 | ||
| 1292 | if (ret) { | 1318 | if (ret) { |
| 1293 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, | 1319 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 1294 | "firmware2 upload post-proc failure"); | 1320 | "firmware2 upload post-proc failure"); |
| 1295 | } | 1321 | } |
| 1322 | |||
| 1323 | done: | ||
| 1324 | if (hdw->hdw_desc->signal_routing_scheme == | ||
| 1325 | PVR2_ROUTING_SCHEME_GOTVIEW) { | ||
| 1326 | /* Ensure that GPIO 11 is set to output for GOTVIEW | ||
| 1327 | hardware. */ | ||
| 1328 | pvr2_hdw_gpio_chg_dir(hdw,(1 << 11),~0); | ||
| 1329 | } | ||
| 1296 | return ret; | 1330 | return ret; |
| 1297 | } | 1331 | } |
| 1298 | 1332 | ||
| @@ -1364,11 +1398,6 @@ int pvr2_hdw_untrip(struct pvr2_hdw *hdw) | |||
| 1364 | } | 1398 | } |
| 1365 | 1399 | ||
| 1366 | 1400 | ||
| 1367 | const char *pvr2_hdw_get_state_name(unsigned int id) | ||
| 1368 | { | ||
| 1369 | if (id >= ARRAY_SIZE(pvr2_state_names)) return NULL; | ||
| 1370 | return pvr2_state_names[id]; | ||
| 1371 | } | ||
| 1372 | 1401 | ||
| 1373 | 1402 | ||
| 1374 | int pvr2_hdw_get_streaming(struct pvr2_hdw *hdw) | 1403 | int pvr2_hdw_get_streaming(struct pvr2_hdw *hdw) |
| @@ -1495,7 +1524,7 @@ struct pvr2_std_hack { | |||
| 1495 | default - which can always be overridden explicitly - and if the user | 1524 | default - which can always be overridden explicitly - and if the user |
| 1496 | has otherwise named a default then that default will always be used in | 1525 | has otherwise named a default then that default will always be used in |
| 1497 | place of this table. */ | 1526 | place of this table. */ |
| 1498 | const static struct pvr2_std_hack std_eeprom_maps[] = { | 1527 | static const struct pvr2_std_hack std_eeprom_maps[] = { |
| 1499 | { /* PAL(B/G) */ | 1528 | { /* PAL(B/G) */ |
| 1500 | .pat = V4L2_STD_B|V4L2_STD_GH, | 1529 | .pat = V4L2_STD_B|V4L2_STD_GH, |
| 1501 | .std = V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_PAL_G, | 1530 | .std = V4L2_STD_PAL_B|V4L2_STD_PAL_B1|V4L2_STD_PAL_G, |
| @@ -1712,6 +1741,13 @@ static void pvr2_hdw_setup_low(struct pvr2_hdw *hdw) | |||
| 1712 | 1741 | ||
| 1713 | if (!pvr2_hdw_dev_ok(hdw)) return; | 1742 | if (!pvr2_hdw_dev_ok(hdw)) return; |
| 1714 | 1743 | ||
| 1744 | if (hdw->hdw_desc->signal_routing_scheme == | ||
| 1745 | PVR2_ROUTING_SCHEME_GOTVIEW) { | ||
| 1746 | /* Ensure that GPIO 11 is set to output for GOTVIEW | ||
| 1747 | hardware. */ | ||
| 1748 | pvr2_hdw_gpio_chg_dir(hdw,(1 << 11),~0); | ||
| 1749 | } | ||
| 1750 | |||
| 1715 | pvr2_hdw_commit_setup(hdw); | 1751 | pvr2_hdw_commit_setup(hdw); |
| 1716 | 1752 | ||
| 1717 | hdw->vid_stream = pvr2_stream_create(); | 1753 | hdw->vid_stream = pvr2_stream_create(); |
| @@ -1805,12 +1841,37 @@ static void pvr2_hdw_setup(struct pvr2_hdw *hdw) | |||
| 1805 | } | 1841 | } |
| 1806 | 1842 | ||
| 1807 | 1843 | ||
| 1808 | /* Create and return a structure for interacting with the underlying | 1844 | /* Perform second stage initialization. Set callback pointer first so that |
| 1809 | hardware */ | 1845 | we can avoid a possible initialization race (if the kernel thread runs |
| 1846 | before the callback has been set). */ | ||
| 1847 | int pvr2_hdw_initialize(struct pvr2_hdw *hdw, | ||
| 1848 | void (*callback_func)(void *), | ||
| 1849 | void *callback_data) | ||
| 1850 | { | ||
| 1851 | LOCK_TAKE(hdw->big_lock); do { | ||
| 1852 | if (hdw->flag_disconnected) { | ||
| 1853 | /* Handle a race here: If we're already | ||
| 1854 | disconnected by this point, then give up. If we | ||
| 1855 | get past this then we'll remain connected for | ||
| 1856 | the duration of initialization since the entire | ||
| 1857 | initialization sequence is now protected by the | ||
| 1858 | big_lock. */ | ||
| 1859 | break; | ||
| 1860 | } | ||
| 1861 | hdw->state_data = callback_data; | ||
| 1862 | hdw->state_func = callback_func; | ||
| 1863 | pvr2_hdw_setup(hdw); | ||
| 1864 | } while (0); LOCK_GIVE(hdw->big_lock); | ||
| 1865 | return hdw->flag_init_ok; | ||
| 1866 | } | ||
| 1867 | |||
| 1868 | |||
| 1869 | /* Create, set up, and return a structure for interacting with the | ||
| 1870 | underlying hardware. */ | ||
| 1810 | struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | 1871 | struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, |
| 1811 | const struct usb_device_id *devid) | 1872 | const struct usb_device_id *devid) |
| 1812 | { | 1873 | { |
| 1813 | unsigned int idx,cnt1,cnt2; | 1874 | unsigned int idx,cnt1,cnt2,m; |
| 1814 | struct pvr2_hdw *hdw; | 1875 | struct pvr2_hdw *hdw; |
| 1815 | int valid_std_mask; | 1876 | int valid_std_mask; |
| 1816 | struct pvr2_ctrl *cptr; | 1877 | struct pvr2_ctrl *cptr; |
| @@ -1834,6 +1895,10 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
| 1834 | hdw->encoder_wait_timer.data = (unsigned long)hdw; | 1895 | hdw->encoder_wait_timer.data = (unsigned long)hdw; |
| 1835 | hdw->encoder_wait_timer.function = pvr2_hdw_encoder_wait_timeout; | 1896 | hdw->encoder_wait_timer.function = pvr2_hdw_encoder_wait_timeout; |
| 1836 | 1897 | ||
| 1898 | init_timer(&hdw->encoder_run_timer); | ||
| 1899 | hdw->encoder_run_timer.data = (unsigned long)hdw; | ||
| 1900 | hdw->encoder_run_timer.function = pvr2_hdw_encoder_run_timeout; | ||
| 1901 | |||
| 1837 | hdw->master_state = PVR2_STATE_DEAD; | 1902 | hdw->master_state = PVR2_STATE_DEAD; |
| 1838 | 1903 | ||
| 1839 | init_waitqueue_head(&hdw->state_wait_data); | 1904 | init_waitqueue_head(&hdw->state_wait_data); |
| @@ -1841,6 +1906,26 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
| 1841 | hdw->tuner_signal_stale = !0; | 1906 | hdw->tuner_signal_stale = !0; |
| 1842 | cx2341x_fill_defaults(&hdw->enc_ctl_state); | 1907 | cx2341x_fill_defaults(&hdw->enc_ctl_state); |
| 1843 | 1908 | ||
| 1909 | /* Calculate which inputs are OK */ | ||
| 1910 | m = 0; | ||
| 1911 | if (hdw_desc->flag_has_analogtuner) m |= 1 << PVR2_CVAL_INPUT_TV; | ||
| 1912 | if (hdw_desc->digital_control_scheme != PVR2_DIGITAL_SCHEME_NONE) { | ||
| 1913 | m |= 1 << PVR2_CVAL_INPUT_DTV; | ||
| 1914 | } | ||
| 1915 | if (hdw_desc->flag_has_svideo) m |= 1 << PVR2_CVAL_INPUT_SVIDEO; | ||
| 1916 | if (hdw_desc->flag_has_composite) m |= 1 << PVR2_CVAL_INPUT_COMPOSITE; | ||
| 1917 | if (hdw_desc->flag_has_fmradio) m |= 1 << PVR2_CVAL_INPUT_RADIO; | ||
| 1918 | hdw->input_avail_mask = m; | ||
| 1919 | hdw->input_allowed_mask = hdw->input_avail_mask; | ||
| 1920 | |||
| 1921 | /* If not a hybrid device, pathway_state never changes. So | ||
| 1922 | initialize it here to what it should forever be. */ | ||
| 1923 | if (!(hdw->input_avail_mask & (1 << PVR2_CVAL_INPUT_DTV))) { | ||
| 1924 | hdw->pathway_state = PVR2_PATHWAY_ANALOG; | ||
| 1925 | } else if (!(hdw->input_avail_mask & (1 << PVR2_CVAL_INPUT_TV))) { | ||
| 1926 | hdw->pathway_state = PVR2_PATHWAY_DIGITAL; | ||
| 1927 | } | ||
| 1928 | |||
| 1844 | hdw->control_cnt = CTRLDEF_COUNT; | 1929 | hdw->control_cnt = CTRLDEF_COUNT; |
| 1845 | hdw->control_cnt += MPEGDEF_COUNT; | 1930 | hdw->control_cnt += MPEGDEF_COUNT; |
| 1846 | hdw->controls = kzalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt, | 1931 | hdw->controls = kzalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt, |
| @@ -1858,6 +1943,15 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
| 1858 | cptr = hdw->controls + idx; | 1943 | cptr = hdw->controls + idx; |
| 1859 | cptr->info = control_defs+idx; | 1944 | cptr->info = control_defs+idx; |
| 1860 | } | 1945 | } |
| 1946 | |||
| 1947 | /* Ensure that default input choice is a valid one. */ | ||
| 1948 | m = hdw->input_avail_mask; | ||
| 1949 | if (m) for (idx = 0; idx < (sizeof(m) << 3); idx++) { | ||
| 1950 | if (!((1 << idx) & m)) continue; | ||
| 1951 | hdw->input_val = idx; | ||
| 1952 | break; | ||
| 1953 | } | ||
| 1954 | |||
| 1861 | /* Define and configure additional controls from cx2341x module. */ | 1955 | /* Define and configure additional controls from cx2341x module. */ |
| 1862 | hdw->mpeg_ctrl_info = kzalloc( | 1956 | hdw->mpeg_ctrl_info = kzalloc( |
| 1863 | sizeof(*(hdw->mpeg_ctrl_info)) * MPEGDEF_COUNT, GFP_KERNEL); | 1957 | sizeof(*(hdw->mpeg_ctrl_info)) * MPEGDEF_COUNT, GFP_KERNEL); |
| @@ -1981,7 +2075,6 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
| 1981 | hdw->workqueue = create_singlethread_workqueue(hdw->name); | 2075 | hdw->workqueue = create_singlethread_workqueue(hdw->name); |
| 1982 | INIT_WORK(&hdw->workpoll,pvr2_hdw_worker_poll); | 2076 | INIT_WORK(&hdw->workpoll,pvr2_hdw_worker_poll); |
| 1983 | INIT_WORK(&hdw->worki2csync,pvr2_hdw_worker_i2c); | 2077 | INIT_WORK(&hdw->worki2csync,pvr2_hdw_worker_i2c); |
| 1984 | INIT_WORK(&hdw->workinit,pvr2_hdw_worker_init); | ||
| 1985 | 2078 | ||
| 1986 | pvr2_trace(PVR2_TRACE_INIT,"Driver unit number is %d, name is %s", | 2079 | pvr2_trace(PVR2_TRACE_INIT,"Driver unit number is %d, name is %s", |
| 1987 | hdw->unit_number,hdw->name); | 2080 | hdw->unit_number,hdw->name); |
| @@ -2003,11 +2096,11 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
| 2003 | mutex_init(&hdw->ctl_lock_mutex); | 2096 | mutex_init(&hdw->ctl_lock_mutex); |
| 2004 | mutex_init(&hdw->big_lock_mutex); | 2097 | mutex_init(&hdw->big_lock_mutex); |
| 2005 | 2098 | ||
| 2006 | queue_work(hdw->workqueue,&hdw->workinit); | ||
| 2007 | return hdw; | 2099 | return hdw; |
| 2008 | fail: | 2100 | fail: |
| 2009 | if (hdw) { | 2101 | if (hdw) { |
| 2010 | del_timer_sync(&hdw->quiescent_timer); | 2102 | del_timer_sync(&hdw->quiescent_timer); |
| 2103 | del_timer_sync(&hdw->encoder_run_timer); | ||
| 2011 | del_timer_sync(&hdw->encoder_wait_timer); | 2104 | del_timer_sync(&hdw->encoder_wait_timer); |
| 2012 | if (hdw->workqueue) { | 2105 | if (hdw->workqueue) { |
| 2013 | flush_workqueue(hdw->workqueue); | 2106 | flush_workqueue(hdw->workqueue); |
| @@ -2064,13 +2157,14 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw) | |||
| 2064 | { | 2157 | { |
| 2065 | if (!hdw) return; | 2158 | if (!hdw) return; |
| 2066 | pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw); | 2159 | pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_destroy: hdw=%p",hdw); |
| 2067 | del_timer_sync(&hdw->quiescent_timer); | ||
| 2068 | del_timer_sync(&hdw->encoder_wait_timer); | ||
| 2069 | if (hdw->workqueue) { | 2160 | if (hdw->workqueue) { |
| 2070 | flush_workqueue(hdw->workqueue); | 2161 | flush_workqueue(hdw->workqueue); |
| 2071 | destroy_workqueue(hdw->workqueue); | 2162 | destroy_workqueue(hdw->workqueue); |
| 2072 | hdw->workqueue = NULL; | 2163 | hdw->workqueue = NULL; |
| 2073 | } | 2164 | } |
| 2165 | del_timer_sync(&hdw->quiescent_timer); | ||
| 2166 | del_timer_sync(&hdw->encoder_run_timer); | ||
| 2167 | del_timer_sync(&hdw->encoder_wait_timer); | ||
| 2074 | if (hdw->fw_buffer) { | 2168 | if (hdw->fw_buffer) { |
| 2075 | kfree(hdw->fw_buffer); | 2169 | kfree(hdw->fw_buffer); |
| 2076 | hdw->fw_buffer = NULL; | 2170 | hdw->fw_buffer = NULL; |
| @@ -2352,6 +2446,18 @@ static int pvr2_hdw_commit_execute(struct pvr2_hdw *hdw) | |||
| 2352 | } | 2446 | } |
| 2353 | } | 2447 | } |
| 2354 | 2448 | ||
| 2449 | if (hdw->input_dirty && hdw->state_pathway_ok && | ||
| 2450 | (((hdw->input_val == PVR2_CVAL_INPUT_DTV) ? | ||
| 2451 | PVR2_PATHWAY_DIGITAL : PVR2_PATHWAY_ANALOG) != | ||
| 2452 | hdw->pathway_state)) { | ||
| 2453 | /* Change of mode being asked for... */ | ||
| 2454 | hdw->state_pathway_ok = 0; | ||
| 2455 | trace_stbit("state_pathway_ok",hdw->state_pathway_ok); | ||
| 2456 | } | ||
| 2457 | if (!hdw->state_pathway_ok) { | ||
| 2458 | /* Can't commit anything until pathway is ok. */ | ||
| 2459 | return 0; | ||
| 2460 | } | ||
| 2355 | /* If any of the below has changed, then we can't do the update | 2461 | /* If any of the below has changed, then we can't do the update |
| 2356 | while the pipeline is running. Pipeline must be paused first | 2462 | while the pipeline is running. Pipeline must be paused first |
| 2357 | and decoder -> encoder connection be made quiescent before we | 2463 | and decoder -> encoder connection be made quiescent before we |
| @@ -2405,12 +2511,28 @@ static int pvr2_hdw_commit_execute(struct pvr2_hdw *hdw) | |||
| 2405 | hdw->active_stream_type = hdw->desired_stream_type; | 2511 | hdw->active_stream_type = hdw->desired_stream_type; |
| 2406 | } | 2512 | } |
| 2407 | 2513 | ||
| 2514 | if (hdw->hdw_desc->signal_routing_scheme == | ||
| 2515 | PVR2_ROUTING_SCHEME_GOTVIEW) { | ||
| 2516 | u32 b; | ||
| 2517 | /* Handle GOTVIEW audio switching */ | ||
| 2518 | pvr2_hdw_gpio_get_out(hdw,&b); | ||
| 2519 | if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { | ||
| 2520 | /* Set GPIO 11 */ | ||
| 2521 | pvr2_hdw_gpio_chg_out(hdw,(1 << 11),~0); | ||
| 2522 | } else { | ||
| 2523 | /* Clear GPIO 11 */ | ||
| 2524 | pvr2_hdw_gpio_chg_out(hdw,(1 << 11),0); | ||
| 2525 | } | ||
| 2526 | } | ||
| 2527 | |||
| 2408 | /* Now execute i2c core update */ | 2528 | /* Now execute i2c core update */ |
| 2409 | pvr2_i2c_core_sync(hdw); | 2529 | pvr2_i2c_core_sync(hdw); |
| 2410 | 2530 | ||
| 2411 | if (hdw->state_encoder_run) { | 2531 | if ((hdw->pathway_state == PVR2_PATHWAY_ANALOG) && |
| 2412 | /* If encoder isn't running, then this will get worked out | 2532 | hdw->state_encoder_run) { |
| 2413 | later when we start the encoder. */ | 2533 | /* If encoder isn't running or it can't be touched, then |
| 2534 | this will get worked out later when we start the | ||
| 2535 | encoder. */ | ||
| 2414 | if (pvr2_encoder_adjust(hdw) < 0) return !0; | 2536 | if (pvr2_encoder_adjust(hdw) < 0) return !0; |
| 2415 | } | 2537 | } |
| 2416 | 2538 | ||
| @@ -2453,15 +2575,6 @@ static void pvr2_hdw_worker_poll(struct work_struct *work) | |||
| 2453 | } | 2575 | } |
| 2454 | 2576 | ||
| 2455 | 2577 | ||
| 2456 | static void pvr2_hdw_worker_init(struct work_struct *work) | ||
| 2457 | { | ||
| 2458 | struct pvr2_hdw *hdw = container_of(work,struct pvr2_hdw,workinit); | ||
| 2459 | LOCK_TAKE(hdw->big_lock); do { | ||
| 2460 | pvr2_hdw_setup(hdw); | ||
| 2461 | } while (0); LOCK_GIVE(hdw->big_lock); | ||
| 2462 | } | ||
| 2463 | |||
| 2464 | |||
| 2465 | static int pvr2_hdw_wait(struct pvr2_hdw *hdw,int state) | 2578 | static int pvr2_hdw_wait(struct pvr2_hdw *hdw,int state) |
| 2466 | { | 2579 | { |
| 2467 | return wait_event_interruptible( | 2580 | return wait_event_interruptible( |
| @@ -2471,17 +2584,6 @@ static int pvr2_hdw_wait(struct pvr2_hdw *hdw,int state) | |||
| 2471 | } | 2584 | } |
| 2472 | 2585 | ||
| 2473 | 2586 | ||
| 2474 | void pvr2_hdw_set_state_callback(struct pvr2_hdw *hdw, | ||
| 2475 | void (*callback_func)(void *), | ||
| 2476 | void *callback_data) | ||
| 2477 | { | ||
| 2478 | LOCK_TAKE(hdw->big_lock); do { | ||
| 2479 | hdw->state_data = callback_data; | ||
| 2480 | hdw->state_func = callback_func; | ||
| 2481 | } while (0); LOCK_GIVE(hdw->big_lock); | ||
| 2482 | } | ||
| 2483 | |||
| 2484 | |||
| 2485 | /* Return name for this driver instance */ | 2587 | /* Return name for this driver instance */ |
| 2486 | const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw) | 2588 | const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *hdw) |
| 2487 | { | 2589 | { |
| @@ -3050,6 +3152,67 @@ int pvr2_send_request(struct pvr2_hdw *hdw, | |||
| 3050 | read_data,read_len); | 3152 | read_data,read_len); |
| 3051 | } | 3153 | } |
| 3052 | 3154 | ||
| 3155 | |||
| 3156 | static int pvr2_issue_simple_cmd(struct pvr2_hdw *hdw,u32 cmdcode) | ||
| 3157 | { | ||
| 3158 | int ret; | ||
| 3159 | unsigned int cnt = 1; | ||
| 3160 | unsigned int args = 0; | ||
| 3161 | LOCK_TAKE(hdw->ctl_lock); | ||
| 3162 | hdw->cmd_buffer[0] = cmdcode & 0xffu; | ||
| 3163 | args = (cmdcode >> 8) & 0xffu; | ||
| 3164 | args = (args > 2) ? 2 : args; | ||
| 3165 | if (args) { | ||
| 3166 | cnt += args; | ||
| 3167 | hdw->cmd_buffer[1] = (cmdcode >> 16) & 0xffu; | ||
| 3168 | if (args > 1) { | ||
| 3169 | hdw->cmd_buffer[2] = (cmdcode >> 24) & 0xffu; | ||
| 3170 | } | ||
| 3171 | } | ||
| 3172 | if (pvrusb2_debug & PVR2_TRACE_INIT) { | ||
| 3173 | unsigned int idx; | ||
| 3174 | unsigned int ccnt,bcnt; | ||
| 3175 | char tbuf[50]; | ||
| 3176 | cmdcode &= 0xffu; | ||
| 3177 | bcnt = 0; | ||
| 3178 | ccnt = scnprintf(tbuf+bcnt, | ||
| 3179 | sizeof(tbuf)-bcnt, | ||
| 3180 | "Sending FX2 command 0x%x",cmdcode); | ||
| 3181 | bcnt += ccnt; | ||
| 3182 | for (idx = 0; idx < ARRAY_SIZE(pvr2_fx2cmd_desc); idx++) { | ||
| 3183 | if (pvr2_fx2cmd_desc[idx].id == cmdcode) { | ||
| 3184 | ccnt = scnprintf(tbuf+bcnt, | ||
| 3185 | sizeof(tbuf)-bcnt, | ||
| 3186 | " \"%s\"", | ||
| 3187 | pvr2_fx2cmd_desc[idx].desc); | ||
| 3188 | bcnt += ccnt; | ||
| 3189 | break; | ||
| 3190 | } | ||
| 3191 | } | ||
| 3192 | if (args) { | ||
| 3193 | ccnt = scnprintf(tbuf+bcnt, | ||
| 3194 | sizeof(tbuf)-bcnt, | ||
| 3195 | " (%u",hdw->cmd_buffer[1]); | ||
| 3196 | bcnt += ccnt; | ||
| 3197 | if (args > 1) { | ||
| 3198 | ccnt = scnprintf(tbuf+bcnt, | ||
| 3199 | sizeof(tbuf)-bcnt, | ||
| 3200 | ",%u",hdw->cmd_buffer[2]); | ||
| 3201 | bcnt += ccnt; | ||
| 3202 | } | ||
| 3203 | ccnt = scnprintf(tbuf+bcnt, | ||
| 3204 | sizeof(tbuf)-bcnt, | ||
| 3205 | ")"); | ||
| 3206 | bcnt += ccnt; | ||
| 3207 | } | ||
| 3208 | pvr2_trace(PVR2_TRACE_INIT,"%.*s",bcnt,tbuf); | ||
| 3209 | } | ||
| 3210 | ret = pvr2_send_request(hdw,hdw->cmd_buffer,cnt,NULL,0); | ||
| 3211 | LOCK_GIVE(hdw->ctl_lock); | ||
| 3212 | return ret; | ||
| 3213 | } | ||
| 3214 | |||
| 3215 | |||
| 3053 | int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data) | 3216 | int pvr2_write_register(struct pvr2_hdw *hdw, u16 reg, u32 data) |
| 3054 | { | 3217 | { |
| 3055 | int ret; | 3218 | int ret; |
| @@ -3157,25 +3320,19 @@ void pvr2_hdw_cpureset_assert(struct pvr2_hdw *hdw,int val) | |||
| 3157 | 3320 | ||
| 3158 | int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *hdw) | 3321 | int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *hdw) |
| 3159 | { | 3322 | { |
| 3160 | int status; | 3323 | return pvr2_issue_simple_cmd(hdw,FX2CMD_DEEP_RESET); |
| 3161 | LOCK_TAKE(hdw->ctl_lock); do { | ||
| 3162 | pvr2_trace(PVR2_TRACE_INIT,"Requesting uproc hard reset"); | ||
| 3163 | hdw->cmd_buffer[0] = FX2CMD_DEEP_RESET; | ||
| 3164 | status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0); | ||
| 3165 | } while (0); LOCK_GIVE(hdw->ctl_lock); | ||
| 3166 | return status; | ||
| 3167 | } | 3324 | } |
| 3168 | 3325 | ||
| 3169 | 3326 | ||
| 3170 | int pvr2_hdw_cmd_powerup(struct pvr2_hdw *hdw) | 3327 | int pvr2_hdw_cmd_powerup(struct pvr2_hdw *hdw) |
| 3171 | { | 3328 | { |
| 3172 | int status; | 3329 | return pvr2_issue_simple_cmd(hdw,FX2CMD_POWER_ON); |
| 3173 | LOCK_TAKE(hdw->ctl_lock); do { | 3330 | } |
| 3174 | pvr2_trace(PVR2_TRACE_INIT,"Requesting powerup"); | 3331 | |
| 3175 | hdw->cmd_buffer[0] = FX2CMD_POWER_ON; | 3332 | |
| 3176 | status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0); | 3333 | int pvr2_hdw_cmd_powerdown(struct pvr2_hdw *hdw) |
| 3177 | } while (0); LOCK_GIVE(hdw->ctl_lock); | 3334 | { |
| 3178 | return status; | 3335 | return pvr2_issue_simple_cmd(hdw,FX2CMD_POWER_OFF); |
| 3179 | } | 3336 | } |
| 3180 | 3337 | ||
| 3181 | 3338 | ||
| @@ -3200,16 +3357,173 @@ int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *hdw) | |||
| 3200 | } | 3357 | } |
| 3201 | 3358 | ||
| 3202 | 3359 | ||
| 3360 | static int pvr2_hdw_cmd_hcw_demod_reset(struct pvr2_hdw *hdw, int onoff) | ||
| 3361 | { | ||
| 3362 | hdw->flag_ok = !0; | ||
| 3363 | return pvr2_issue_simple_cmd(hdw, | ||
| 3364 | FX2CMD_HCW_DEMOD_RESETIN | | ||
| 3365 | (1 << 8) | | ||
| 3366 | ((onoff ? 1 : 0) << 16)); | ||
| 3367 | } | ||
| 3368 | |||
| 3369 | |||
| 3370 | static int pvr2_hdw_cmd_onair_fe_power_ctrl(struct pvr2_hdw *hdw, int onoff) | ||
| 3371 | { | ||
| 3372 | hdw->flag_ok = !0; | ||
| 3373 | return pvr2_issue_simple_cmd(hdw,(onoff ? | ||
| 3374 | FX2CMD_ONAIR_DTV_POWER_ON : | ||
| 3375 | FX2CMD_ONAIR_DTV_POWER_OFF)); | ||
| 3376 | } | ||
| 3377 | |||
| 3378 | |||
| 3379 | static int pvr2_hdw_cmd_onair_digital_path_ctrl(struct pvr2_hdw *hdw, | ||
| 3380 | int onoff) | ||
| 3381 | { | ||
| 3382 | return pvr2_issue_simple_cmd(hdw,(onoff ? | ||
| 3383 | FX2CMD_ONAIR_DTV_STREAMING_ON : | ||
| 3384 | FX2CMD_ONAIR_DTV_STREAMING_OFF)); | ||
| 3385 | } | ||
| 3386 | |||
| 3387 | |||
| 3388 | static void pvr2_hdw_cmd_modeswitch(struct pvr2_hdw *hdw,int digitalFl) | ||
| 3389 | { | ||
| 3390 | int cmode; | ||
| 3391 | /* Compare digital/analog desired setting with current setting. If | ||
| 3392 | they don't match, fix it... */ | ||
| 3393 | cmode = (digitalFl ? PVR2_PATHWAY_DIGITAL : PVR2_PATHWAY_ANALOG); | ||
| 3394 | if (cmode == hdw->pathway_state) { | ||
| 3395 | /* They match; nothing to do */ | ||
| 3396 | return; | ||
| 3397 | } | ||
| 3398 | |||
| 3399 | switch (hdw->hdw_desc->digital_control_scheme) { | ||
| 3400 | case PVR2_DIGITAL_SCHEME_HAUPPAUGE: | ||
| 3401 | pvr2_hdw_cmd_hcw_demod_reset(hdw,digitalFl); | ||
| 3402 | if (cmode == PVR2_PATHWAY_ANALOG) { | ||
| 3403 | /* If moving to analog mode, also force the decoder | ||
| 3404 | to reset. If no decoder is attached, then it's | ||
| 3405 | ok to ignore this because if/when the decoder | ||
| 3406 | attaches, it will reset itself at that time. */ | ||
| 3407 | pvr2_hdw_cmd_decoder_reset(hdw); | ||
| 3408 | } | ||
| 3409 | break; | ||
| 3410 | case PVR2_DIGITAL_SCHEME_ONAIR: | ||
| 3411 | /* Supposedly we should always have the power on whether in | ||
| 3412 | digital or analog mode. But for now do what appears to | ||
| 3413 | work... */ | ||
| 3414 | pvr2_hdw_cmd_onair_fe_power_ctrl(hdw,digitalFl); | ||
| 3415 | break; | ||
| 3416 | default: break; | ||
| 3417 | } | ||
| 3418 | |||
| 3419 | pvr2_hdw_untrip_unlocked(hdw); | ||
| 3420 | hdw->pathway_state = cmode; | ||
| 3421 | } | ||
| 3422 | |||
| 3423 | |||
| 3424 | void pvr2_led_ctrl_hauppauge(struct pvr2_hdw *hdw, int onoff) | ||
| 3425 | { | ||
| 3426 | /* change some GPIO data | ||
| 3427 | * | ||
| 3428 | * note: bit d7 of dir appears to control the LED, | ||
| 3429 | * so we shut it off here. | ||
| 3430 | * | ||
| 3431 | */ | ||
| 3432 | if (onoff) { | ||
| 3433 | pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000481); | ||
| 3434 | } else { | ||
| 3435 | pvr2_hdw_gpio_chg_dir(hdw, 0xffffffff, 0x00000401); | ||
| 3436 | } | ||
| 3437 | pvr2_hdw_gpio_chg_out(hdw, 0xffffffff, 0x00000000); | ||
| 3438 | } | ||
| 3439 | |||
| 3440 | |||
| 3441 | typedef void (*led_method_func)(struct pvr2_hdw *,int); | ||
| 3442 | |||
| 3443 | static led_method_func led_methods[] = { | ||
| 3444 | [PVR2_LED_SCHEME_HAUPPAUGE] = pvr2_led_ctrl_hauppauge, | ||
| 3445 | }; | ||
| 3446 | |||
| 3447 | |||
| 3448 | /* Toggle LED */ | ||
| 3449 | static void pvr2_led_ctrl(struct pvr2_hdw *hdw,int onoff) | ||
| 3450 | { | ||
| 3451 | unsigned int scheme_id; | ||
| 3452 | led_method_func fp; | ||
| 3453 | |||
| 3454 | if ((!onoff) == (!hdw->led_on)) return; | ||
| 3455 | |||
| 3456 | hdw->led_on = onoff != 0; | ||
| 3457 | |||
| 3458 | scheme_id = hdw->hdw_desc->led_scheme; | ||
| 3459 | if (scheme_id < ARRAY_SIZE(led_methods)) { | ||
| 3460 | fp = led_methods[scheme_id]; | ||
| 3461 | } else { | ||
| 3462 | fp = NULL; | ||
| 3463 | } | ||
| 3464 | |||
| 3465 | if (fp) (*fp)(hdw,onoff); | ||
| 3466 | } | ||
| 3467 | |||
| 3468 | |||
| 3203 | /* Stop / start video stream transport */ | 3469 | /* Stop / start video stream transport */ |
| 3204 | static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl) | 3470 | static int pvr2_hdw_cmd_usbstream(struct pvr2_hdw *hdw,int runFl) |
| 3205 | { | 3471 | { |
| 3206 | int status; | 3472 | int ret; |
| 3207 | LOCK_TAKE(hdw->ctl_lock); do { | 3473 | |
| 3208 | hdw->cmd_buffer[0] = | 3474 | /* If we're in analog mode, then just issue the usual analog |
| 3209 | (runFl ? FX2CMD_STREAMING_ON : FX2CMD_STREAMING_OFF); | 3475 | command. */ |
| 3210 | status = pvr2_send_request(hdw,hdw->cmd_buffer,1,NULL,0); | 3476 | if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { |
| 3211 | } while (0); LOCK_GIVE(hdw->ctl_lock); | 3477 | return pvr2_issue_simple_cmd(hdw, |
| 3212 | return status; | 3478 | (runFl ? |
| 3479 | FX2CMD_STREAMING_ON : | ||
| 3480 | FX2CMD_STREAMING_OFF)); | ||
| 3481 | /*Note: Not reached */ | ||
| 3482 | } | ||
| 3483 | |||
| 3484 | if (hdw->pathway_state != PVR2_PATHWAY_DIGITAL) { | ||
| 3485 | /* Whoops, we don't know what mode we're in... */ | ||
| 3486 | return -EINVAL; | ||
| 3487 | } | ||
| 3488 | |||
| 3489 | /* To get here we have to be in digital mode. The mechanism here | ||
| 3490 | is unfortunately different for different vendors. So we switch | ||
| 3491 | on the device's digital scheme attribute in order to figure out | ||
| 3492 | what to do. */ | ||
| 3493 | switch (hdw->hdw_desc->digital_control_scheme) { | ||
| 3494 | case PVR2_DIGITAL_SCHEME_HAUPPAUGE: | ||
| 3495 | return pvr2_issue_simple_cmd(hdw, | ||
| 3496 | (runFl ? | ||
| 3497 | FX2CMD_HCW_DTV_STREAMING_ON : | ||
| 3498 | FX2CMD_HCW_DTV_STREAMING_OFF)); | ||
| 3499 | case PVR2_DIGITAL_SCHEME_ONAIR: | ||
| 3500 | ret = pvr2_issue_simple_cmd(hdw, | ||
| 3501 | (runFl ? | ||
| 3502 | FX2CMD_STREAMING_ON : | ||
| 3503 | FX2CMD_STREAMING_OFF)); | ||
| 3504 | if (ret) return ret; | ||
| 3505 | return pvr2_hdw_cmd_onair_digital_path_ctrl(hdw,runFl); | ||
| 3506 | default: | ||
| 3507 | return -EINVAL; | ||
| 3508 | } | ||
| 3509 | } | ||
| 3510 | |||
| 3511 | |||
| 3512 | /* Evaluate whether or not state_pathway_ok can change */ | ||
| 3513 | static int state_eval_pathway_ok(struct pvr2_hdw *hdw) | ||
| 3514 | { | ||
| 3515 | if (hdw->state_pathway_ok) { | ||
| 3516 | /* Nothing to do if pathway is already ok */ | ||
| 3517 | return 0; | ||
| 3518 | } | ||
| 3519 | if (!hdw->state_pipeline_idle) { | ||
| 3520 | /* Not allowed to change anything if pipeline is not idle */ | ||
| 3521 | return 0; | ||
| 3522 | } | ||
| 3523 | pvr2_hdw_cmd_modeswitch(hdw,hdw->input_val == PVR2_CVAL_INPUT_DTV); | ||
| 3524 | hdw->state_pathway_ok = !0; | ||
| 3525 | trace_stbit("state_pathway_ok",hdw->state_pathway_ok); | ||
| 3526 | return !0; | ||
| 3213 | } | 3527 | } |
| 3214 | 3528 | ||
| 3215 | 3529 | ||
| @@ -3222,6 +3536,12 @@ static int state_eval_encoder_ok(struct pvr2_hdw *hdw) | |||
| 3222 | if (hdw->state_encoder_config) return 0; | 3536 | if (hdw->state_encoder_config) return 0; |
| 3223 | if (hdw->state_decoder_run) return 0; | 3537 | if (hdw->state_decoder_run) return 0; |
| 3224 | if (hdw->state_usbstream_run) return 0; | 3538 | if (hdw->state_usbstream_run) return 0; |
| 3539 | if (hdw->pathway_state == PVR2_PATHWAY_DIGITAL) { | ||
| 3540 | if (!hdw->hdw_desc->flag_digital_requires_cx23416) return 0; | ||
| 3541 | } else if (hdw->pathway_state != PVR2_PATHWAY_ANALOG) { | ||
| 3542 | return 0; | ||
| 3543 | } | ||
| 3544 | |||
| 3225 | if (pvr2_upload_firmware2(hdw) < 0) { | 3545 | if (pvr2_upload_firmware2(hdw) < 0) { |
| 3226 | hdw->flag_tripped = !0; | 3546 | hdw->flag_tripped = !0; |
| 3227 | trace_stbit("flag_tripped",hdw->flag_tripped); | 3547 | trace_stbit("flag_tripped",hdw->flag_tripped); |
| @@ -3247,7 +3567,9 @@ static int state_eval_encoder_config(struct pvr2_hdw *hdw) | |||
| 3247 | /* paranoia - solve race if timer just completed */ | 3567 | /* paranoia - solve race if timer just completed */ |
| 3248 | del_timer_sync(&hdw->encoder_wait_timer); | 3568 | del_timer_sync(&hdw->encoder_wait_timer); |
| 3249 | } else { | 3569 | } else { |
| 3250 | if (!hdw->state_encoder_ok || | 3570 | if (!hdw->state_pathway_ok || |
| 3571 | (hdw->pathway_state != PVR2_PATHWAY_ANALOG) || | ||
| 3572 | !hdw->state_encoder_ok || | ||
| 3251 | !hdw->state_pipeline_idle || | 3573 | !hdw->state_pipeline_idle || |
| 3252 | hdw->state_pipeline_pause || | 3574 | hdw->state_pipeline_pause || |
| 3253 | !hdw->state_pipeline_req || | 3575 | !hdw->state_pipeline_req || |
| @@ -3296,20 +3618,116 @@ static int state_eval_encoder_config(struct pvr2_hdw *hdw) | |||
| 3296 | } | 3618 | } |
| 3297 | 3619 | ||
| 3298 | 3620 | ||
| 3621 | /* Return true if the encoder should not be running. */ | ||
| 3622 | static int state_check_disable_encoder_run(struct pvr2_hdw *hdw) | ||
| 3623 | { | ||
| 3624 | if (!hdw->state_encoder_ok) { | ||
| 3625 | /* Encoder isn't healthy at the moment, so stop it. */ | ||
| 3626 | return !0; | ||
| 3627 | } | ||
| 3628 | if (!hdw->state_pathway_ok) { | ||
| 3629 | /* Mode is not understood at the moment (i.e. it wants to | ||
| 3630 | change), so encoder must be stopped. */ | ||
| 3631 | return !0; | ||
| 3632 | } | ||
| 3633 | |||
| 3634 | switch (hdw->pathway_state) { | ||
| 3635 | case PVR2_PATHWAY_ANALOG: | ||
| 3636 | if (!hdw->state_decoder_run) { | ||
| 3637 | /* We're in analog mode and the decoder is not | ||
| 3638 | running; thus the encoder should be stopped as | ||
| 3639 | well. */ | ||
| 3640 | return !0; | ||
| 3641 | } | ||
| 3642 | break; | ||
| 3643 | case PVR2_PATHWAY_DIGITAL: | ||
| 3644 | if (hdw->state_encoder_runok) { | ||
| 3645 | /* This is a funny case. We're in digital mode so | ||
| 3646 | really the encoder should be stopped. However | ||
| 3647 | if it really is running, only kill it after | ||
| 3648 | runok has been set. This gives a chance for the | ||
| 3649 | onair quirk to function (encoder must run | ||
| 3650 | briefly first, at least once, before onair | ||
| 3651 | digital streaming can work). */ | ||
| 3652 | return !0; | ||
| 3653 | } | ||
| 3654 | break; | ||
| 3655 | default: | ||
| 3656 | /* Unknown mode; so encoder should be stopped. */ | ||
| 3657 | return !0; | ||
| 3658 | } | ||
| 3659 | |||
| 3660 | /* If we get here, we haven't found a reason to stop the | ||
| 3661 | encoder. */ | ||
| 3662 | return 0; | ||
| 3663 | } | ||
| 3664 | |||
| 3665 | |||
| 3666 | /* Return true if the encoder should be running. */ | ||
| 3667 | static int state_check_enable_encoder_run(struct pvr2_hdw *hdw) | ||
| 3668 | { | ||
| 3669 | if (!hdw->state_encoder_ok) { | ||
| 3670 | /* Don't run the encoder if it isn't healthy... */ | ||
| 3671 | return 0; | ||
| 3672 | } | ||
| 3673 | if (!hdw->state_pathway_ok) { | ||
| 3674 | /* Don't run the encoder if we don't (yet) know what mode | ||
| 3675 | we need to be in... */ | ||
| 3676 | return 0; | ||
| 3677 | } | ||
| 3678 | |||
| 3679 | switch (hdw->pathway_state) { | ||
| 3680 | case PVR2_PATHWAY_ANALOG: | ||
| 3681 | if (hdw->state_decoder_run) { | ||
| 3682 | /* In analog mode, if the decoder is running, then | ||
| 3683 | run the encoder. */ | ||
| 3684 | return !0; | ||
| 3685 | } | ||
| 3686 | break; | ||
| 3687 | case PVR2_PATHWAY_DIGITAL: | ||
| 3688 | if ((hdw->hdw_desc->digital_control_scheme == | ||
| 3689 | PVR2_DIGITAL_SCHEME_ONAIR) && | ||
| 3690 | !hdw->state_encoder_runok) { | ||
| 3691 | /* This is a quirk. OnAir hardware won't stream | ||
| 3692 | digital until the encoder has been run at least | ||
| 3693 | once, for a minimal period of time (empiricially | ||
| 3694 | measured to be 1/4 second). So if we're on | ||
| 3695 | OnAir hardware and the encoder has never been | ||
| 3696 | run at all, then start the encoder. Normal | ||
| 3697 | state machine logic in the driver will | ||
| 3698 | automatically handle the remaining bits. */ | ||
| 3699 | return !0; | ||
| 3700 | } | ||
| 3701 | break; | ||
| 3702 | default: | ||
| 3703 | /* For completeness (unknown mode; encoder won't run ever) */ | ||
| 3704 | break; | ||
| 3705 | } | ||
| 3706 | /* If we get here, then we haven't found any reason to run the | ||
| 3707 | encoder, so don't run it. */ | ||
| 3708 | return 0; | ||
| 3709 | } | ||
| 3710 | |||
| 3711 | |||
| 3299 | /* Evaluate whether or not state_encoder_run can change */ | 3712 | /* Evaluate whether or not state_encoder_run can change */ |
| 3300 | static int state_eval_encoder_run(struct pvr2_hdw *hdw) | 3713 | static int state_eval_encoder_run(struct pvr2_hdw *hdw) |
| 3301 | { | 3714 | { |
| 3302 | if (hdw->state_encoder_run) { | 3715 | if (hdw->state_encoder_run) { |
| 3716 | if (!state_check_disable_encoder_run(hdw)) return 0; | ||
| 3303 | if (hdw->state_encoder_ok) { | 3717 | if (hdw->state_encoder_ok) { |
| 3304 | if (hdw->state_decoder_run) return 0; | 3718 | del_timer_sync(&hdw->encoder_run_timer); |
| 3305 | if (pvr2_encoder_stop(hdw) < 0) return !0; | 3719 | if (pvr2_encoder_stop(hdw) < 0) return !0; |
| 3306 | } | 3720 | } |
| 3307 | hdw->state_encoder_run = 0; | 3721 | hdw->state_encoder_run = 0; |
| 3308 | } else { | 3722 | } else { |
| 3309 | if (!hdw->state_encoder_ok) return 0; | 3723 | if (!state_check_enable_encoder_run(hdw)) return 0; |
| 3310 | if (!hdw->state_decoder_run) return 0; | ||
| 3311 | if (pvr2_encoder_start(hdw) < 0) return !0; | 3724 | if (pvr2_encoder_start(hdw) < 0) return !0; |
| 3312 | hdw->state_encoder_run = !0; | 3725 | hdw->state_encoder_run = !0; |
| 3726 | if (!hdw->state_encoder_runok) { | ||
| 3727 | hdw->encoder_run_timer.expires = | ||
| 3728 | jiffies + (HZ*250/1000); | ||
| 3729 | add_timer(&hdw->encoder_run_timer); | ||
| 3730 | } | ||
| 3313 | } | 3731 | } |
| 3314 | trace_stbit("state_encoder_run",hdw->state_encoder_run); | 3732 | trace_stbit("state_encoder_run",hdw->state_encoder_run); |
| 3315 | return !0; | 3733 | return !0; |
| @@ -3338,13 +3756,27 @@ static void pvr2_hdw_encoder_wait_timeout(unsigned long data) | |||
| 3338 | } | 3756 | } |
| 3339 | 3757 | ||
| 3340 | 3758 | ||
| 3759 | /* Timeout function for encoder run timer. */ | ||
| 3760 | static void pvr2_hdw_encoder_run_timeout(unsigned long data) | ||
| 3761 | { | ||
| 3762 | struct pvr2_hdw *hdw = (struct pvr2_hdw *)data; | ||
| 3763 | if (!hdw->state_encoder_runok) { | ||
| 3764 | hdw->state_encoder_runok = !0; | ||
| 3765 | trace_stbit("state_encoder_runok",hdw->state_encoder_runok); | ||
| 3766 | hdw->state_stale = !0; | ||
| 3767 | queue_work(hdw->workqueue,&hdw->workpoll); | ||
| 3768 | } | ||
| 3769 | } | ||
| 3770 | |||
| 3771 | |||
| 3341 | /* Evaluate whether or not state_decoder_run can change */ | 3772 | /* Evaluate whether or not state_decoder_run can change */ |
| 3342 | static int state_eval_decoder_run(struct pvr2_hdw *hdw) | 3773 | static int state_eval_decoder_run(struct pvr2_hdw *hdw) |
| 3343 | { | 3774 | { |
| 3344 | if (hdw->state_decoder_run) { | 3775 | if (hdw->state_decoder_run) { |
| 3345 | if (hdw->state_encoder_ok) { | 3776 | if (hdw->state_encoder_ok) { |
| 3346 | if (hdw->state_pipeline_req && | 3777 | if (hdw->state_pipeline_req && |
| 3347 | !hdw->state_pipeline_pause) return 0; | 3778 | !hdw->state_pipeline_pause && |
| 3779 | hdw->state_pathway_ok) return 0; | ||
| 3348 | } | 3780 | } |
| 3349 | if (!hdw->flag_decoder_missed) { | 3781 | if (!hdw->flag_decoder_missed) { |
| 3350 | pvr2_decoder_enable(hdw,0); | 3782 | pvr2_decoder_enable(hdw,0); |
| @@ -3377,7 +3809,9 @@ static int state_eval_decoder_run(struct pvr2_hdw *hdw) | |||
| 3377 | hopefully further stabilize the encoder. */ | 3809 | hopefully further stabilize the encoder. */ |
| 3378 | return 0; | 3810 | return 0; |
| 3379 | } | 3811 | } |
| 3380 | if (!hdw->state_pipeline_req || | 3812 | if (!hdw->state_pathway_ok || |
| 3813 | (hdw->pathway_state != PVR2_PATHWAY_ANALOG) || | ||
| 3814 | !hdw->state_pipeline_req || | ||
| 3381 | hdw->state_pipeline_pause || | 3815 | hdw->state_pipeline_pause || |
| 3382 | !hdw->state_pipeline_config || | 3816 | !hdw->state_pipeline_config || |
| 3383 | !hdw->state_encoder_config || | 3817 | !hdw->state_encoder_config || |
| @@ -3398,16 +3832,43 @@ static int state_eval_decoder_run(struct pvr2_hdw *hdw) | |||
| 3398 | static int state_eval_usbstream_run(struct pvr2_hdw *hdw) | 3832 | static int state_eval_usbstream_run(struct pvr2_hdw *hdw) |
| 3399 | { | 3833 | { |
| 3400 | if (hdw->state_usbstream_run) { | 3834 | if (hdw->state_usbstream_run) { |
| 3401 | if (hdw->state_encoder_ok) { | 3835 | int fl = !0; |
| 3402 | if (hdw->state_encoder_run) return 0; | 3836 | if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { |
| 3837 | fl = (hdw->state_encoder_ok && | ||
| 3838 | hdw->state_encoder_run); | ||
| 3839 | } else if ((hdw->pathway_state == PVR2_PATHWAY_DIGITAL) && | ||
| 3840 | (hdw->hdw_desc->flag_digital_requires_cx23416)) { | ||
| 3841 | fl = hdw->state_encoder_ok; | ||
| 3842 | } | ||
| 3843 | if (fl && | ||
| 3844 | hdw->state_pipeline_req && | ||
| 3845 | !hdw->state_pipeline_pause && | ||
| 3846 | hdw->state_pathway_ok) { | ||
| 3847 | return 0; | ||
| 3403 | } | 3848 | } |
| 3404 | pvr2_hdw_cmd_usbstream(hdw,0); | 3849 | pvr2_hdw_cmd_usbstream(hdw,0); |
| 3405 | hdw->state_usbstream_run = 0; | 3850 | hdw->state_usbstream_run = 0; |
| 3406 | } else { | 3851 | } else { |
| 3407 | if (!hdw->state_encoder_ok || | 3852 | if (!hdw->state_pipeline_req || |
| 3408 | !hdw->state_encoder_run || | 3853 | hdw->state_pipeline_pause || |
| 3409 | !hdw->state_pipeline_req || | 3854 | !hdw->state_pathway_ok) return 0; |
| 3410 | hdw->state_pipeline_pause) return 0; | 3855 | if (hdw->pathway_state == PVR2_PATHWAY_ANALOG) { |
| 3856 | if (!hdw->state_encoder_ok || | ||
| 3857 | !hdw->state_encoder_run) return 0; | ||
| 3858 | } else if ((hdw->pathway_state == PVR2_PATHWAY_DIGITAL) && | ||
| 3859 | (hdw->hdw_desc->flag_digital_requires_cx23416)) { | ||
| 3860 | if (!hdw->state_encoder_ok) return 0; | ||
| 3861 | if (hdw->state_encoder_run) return 0; | ||
| 3862 | if (hdw->hdw_desc->digital_control_scheme == | ||
| 3863 | PVR2_DIGITAL_SCHEME_ONAIR) { | ||
| 3864 | /* OnAir digital receivers won't stream | ||
| 3865 | unless the analog encoder has run first. | ||
| 3866 | Why? I have no idea. But don't even | ||
| 3867 | try until we know the analog side is | ||
| 3868 | known to have run. */ | ||
| 3869 | if (!hdw->state_encoder_runok) return 0; | ||
| 3870 | } | ||
| 3871 | } | ||
| 3411 | if (pvr2_hdw_cmd_usbstream(hdw,!0) < 0) return 0; | 3872 | if (pvr2_hdw_cmd_usbstream(hdw,!0) < 0) return 0; |
| 3412 | hdw->state_usbstream_run = !0; | 3873 | hdw->state_usbstream_run = !0; |
| 3413 | } | 3874 | } |
| @@ -3453,7 +3914,8 @@ static int state_update_pipeline_state(struct pvr2_hdw *hdw) | |||
| 3453 | typedef int (*state_eval_func)(struct pvr2_hdw *); | 3914 | typedef int (*state_eval_func)(struct pvr2_hdw *); |
| 3454 | 3915 | ||
| 3455 | /* Set of functions to be run to evaluate various states in the driver. */ | 3916 | /* Set of functions to be run to evaluate various states in the driver. */ |
| 3456 | const static state_eval_func eval_funcs[] = { | 3917 | static const state_eval_func eval_funcs[] = { |
| 3918 | state_eval_pathway_ok, | ||
| 3457 | state_eval_pipeline_config, | 3919 | state_eval_pipeline_config, |
| 3458 | state_eval_encoder_ok, | 3920 | state_eval_encoder_ok, |
| 3459 | state_eval_encoder_config, | 3921 | state_eval_encoder_config, |
| @@ -3501,6 +3963,34 @@ static int pvr2_hdw_state_update(struct pvr2_hdw *hdw) | |||
| 3501 | } | 3963 | } |
| 3502 | 3964 | ||
| 3503 | 3965 | ||
| 3966 | static unsigned int print_input_mask(unsigned int msk, | ||
| 3967 | char *buf,unsigned int acnt) | ||
| 3968 | { | ||
| 3969 | unsigned int idx,ccnt; | ||
| 3970 | unsigned int tcnt = 0; | ||
| 3971 | for (idx = 0; idx < ARRAY_SIZE(control_values_input); idx++) { | ||
| 3972 | if (!((1 << idx) & msk)) continue; | ||
| 3973 | ccnt = scnprintf(buf+tcnt, | ||
| 3974 | acnt-tcnt, | ||
| 3975 | "%s%s", | ||
| 3976 | (tcnt ? ", " : ""), | ||
| 3977 | control_values_input[idx]); | ||
| 3978 | tcnt += ccnt; | ||
| 3979 | } | ||
| 3980 | return tcnt; | ||
| 3981 | } | ||
| 3982 | |||
| 3983 | |||
| 3984 | static const char *pvr2_pathway_state_name(int id) | ||
| 3985 | { | ||
| 3986 | switch (id) { | ||
| 3987 | case PVR2_PATHWAY_ANALOG: return "analog"; | ||
| 3988 | case PVR2_PATHWAY_DIGITAL: return "digital"; | ||
| 3989 | default: return "unknown"; | ||
| 3990 | } | ||
| 3991 | } | ||
| 3992 | |||
| 3993 | |||
| 3504 | static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which, | 3994 | static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which, |
| 3505 | char *buf,unsigned int acnt) | 3995 | char *buf,unsigned int acnt) |
| 3506 | { | 3996 | { |
| @@ -3508,13 +3998,15 @@ static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which, | |||
| 3508 | case 0: | 3998 | case 0: |
| 3509 | return scnprintf( | 3999 | return scnprintf( |
| 3510 | buf,acnt, | 4000 | buf,acnt, |
| 3511 | "driver:%s%s%s%s%s", | 4001 | "driver:%s%s%s%s%s <mode=%s>", |
| 3512 | (hdw->flag_ok ? " <ok>" : " <fail>"), | 4002 | (hdw->flag_ok ? " <ok>" : " <fail>"), |
| 3513 | (hdw->flag_init_ok ? " <init>" : " <uninitialized>"), | 4003 | (hdw->flag_init_ok ? " <init>" : " <uninitialized>"), |
| 3514 | (hdw->flag_disconnected ? " <disconnected>" : | 4004 | (hdw->flag_disconnected ? " <disconnected>" : |
| 3515 | " <connected>"), | 4005 | " <connected>"), |
| 3516 | (hdw->flag_tripped ? " <tripped>" : ""), | 4006 | (hdw->flag_tripped ? " <tripped>" : ""), |
| 3517 | (hdw->flag_decoder_missed ? " <no decoder>" : "")); | 4007 | (hdw->flag_decoder_missed ? " <no decoder>" : ""), |
| 4008 | pvr2_pathway_state_name(hdw->pathway_state)); | ||
| 4009 | |||
| 3518 | case 1: | 4010 | case 1: |
| 3519 | return scnprintf( | 4011 | return scnprintf( |
| 3520 | buf,acnt, | 4012 | buf,acnt, |
| @@ -3527,7 +4019,7 @@ static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which, | |||
| 3527 | case 2: | 4019 | case 2: |
| 3528 | return scnprintf( | 4020 | return scnprintf( |
| 3529 | buf,acnt, | 4021 | buf,acnt, |
| 3530 | "worker:%s%s%s%s%s%s", | 4022 | "worker:%s%s%s%s%s%s%s", |
| 3531 | (hdw->state_decoder_run ? | 4023 | (hdw->state_decoder_run ? |
| 3532 | " <decode:run>" : | 4024 | " <decode:run>" : |
| 3533 | (hdw->state_decoder_quiescent ? | 4025 | (hdw->state_decoder_quiescent ? |
| @@ -3537,20 +4029,65 @@ static unsigned int pvr2_hdw_report_unlocked(struct pvr2_hdw *hdw,int which, | |||
| 3537 | (hdw->state_encoder_ok ? | 4029 | (hdw->state_encoder_ok ? |
| 3538 | "" : " <encode:init>"), | 4030 | "" : " <encode:init>"), |
| 3539 | (hdw->state_encoder_run ? | 4031 | (hdw->state_encoder_run ? |
| 3540 | " <encode:run>" : " <encode:stop>"), | 4032 | (hdw->state_encoder_runok ? |
| 4033 | " <encode:run>" : | ||
| 4034 | " <encode:firstrun>") : | ||
| 4035 | (hdw->state_encoder_runok ? | ||
| 4036 | " <encode:stop>" : | ||
| 4037 | " <encode:virgin>")), | ||
| 3541 | (hdw->state_encoder_config ? | 4038 | (hdw->state_encoder_config ? |
| 3542 | " <encode:configok>" : | 4039 | " <encode:configok>" : |
| 3543 | (hdw->state_encoder_waitok ? | 4040 | (hdw->state_encoder_waitok ? |
| 3544 | "" : " <encode:wait>")), | 4041 | "" : " <encode:waitok>")), |
| 3545 | (hdw->state_usbstream_run ? | 4042 | (hdw->state_usbstream_run ? |
| 3546 | " <usb:run>" : " <usb:stop>")); | 4043 | " <usb:run>" : " <usb:stop>"), |
| 3547 | break; | 4044 | (hdw->state_pathway_ok ? |
| 4045 | " <pathway:ok>" : "")); | ||
| 3548 | case 3: | 4046 | case 3: |
| 3549 | return scnprintf( | 4047 | return scnprintf( |
| 3550 | buf,acnt, | 4048 | buf,acnt, |
| 3551 | "state: %s", | 4049 | "state: %s", |
| 3552 | pvr2_get_state_name(hdw->master_state)); | 4050 | pvr2_get_state_name(hdw->master_state)); |
| 3553 | break; | 4051 | case 4: { |
| 4052 | unsigned int tcnt = 0; | ||
| 4053 | unsigned int ccnt; | ||
| 4054 | |||
| 4055 | ccnt = scnprintf(buf, | ||
| 4056 | acnt, | ||
| 4057 | "Hardware supported inputs: "); | ||
| 4058 | tcnt += ccnt; | ||
| 4059 | tcnt += print_input_mask(hdw->input_avail_mask, | ||
| 4060 | buf+tcnt, | ||
| 4061 | acnt-tcnt); | ||
| 4062 | if (hdw->input_avail_mask != hdw->input_allowed_mask) { | ||
| 4063 | ccnt = scnprintf(buf+tcnt, | ||
| 4064 | acnt-tcnt, | ||
| 4065 | "; allowed inputs: "); | ||
| 4066 | tcnt += ccnt; | ||
| 4067 | tcnt += print_input_mask(hdw->input_allowed_mask, | ||
| 4068 | buf+tcnt, | ||
| 4069 | acnt-tcnt); | ||
| 4070 | } | ||
| 4071 | return tcnt; | ||
| 4072 | } | ||
| 4073 | case 5: { | ||
| 4074 | struct pvr2_stream_stats stats; | ||
| 4075 | if (!hdw->vid_stream) break; | ||
| 4076 | pvr2_stream_get_stats(hdw->vid_stream, | ||
| 4077 | &stats, | ||
| 4078 | 0); | ||
| 4079 | return scnprintf( | ||
| 4080 | buf,acnt, | ||
| 4081 | "Bytes streamed=%u" | ||
| 4082 | " URBs: queued=%u idle=%u ready=%u" | ||
| 4083 | " processed=%u failed=%u", | ||
| 4084 | stats.bytes_processed, | ||
| 4085 | stats.buffers_in_queue, | ||
| 4086 | stats.buffers_in_idle, | ||
| 4087 | stats.buffers_in_ready, | ||
| 4088 | stats.buffers_processed, | ||
| 4089 | stats.buffers_failed); | ||
| 4090 | } | ||
| 3554 | default: break; | 4091 | default: break; |
| 3555 | } | 4092 | } |
| 3556 | return 0; | 4093 | return 0; |
| @@ -3596,6 +4133,7 @@ static int pvr2_hdw_state_eval(struct pvr2_hdw *hdw) | |||
| 3596 | unsigned int st; | 4133 | unsigned int st; |
| 3597 | int state_updated = 0; | 4134 | int state_updated = 0; |
| 3598 | int callback_flag = 0; | 4135 | int callback_flag = 0; |
| 4136 | int analog_mode; | ||
| 3599 | 4137 | ||
| 3600 | pvr2_trace(PVR2_TRACE_STBITS, | 4138 | pvr2_trace(PVR2_TRACE_STBITS, |
| 3601 | "Drive state check START"); | 4139 | "Drive state check START"); |
| @@ -3606,18 +4144,23 @@ static int pvr2_hdw_state_eval(struct pvr2_hdw *hdw) | |||
| 3606 | /* Process all state and get back over disposition */ | 4144 | /* Process all state and get back over disposition */ |
| 3607 | state_updated = pvr2_hdw_state_update(hdw); | 4145 | state_updated = pvr2_hdw_state_update(hdw); |
| 3608 | 4146 | ||
| 4147 | analog_mode = (hdw->pathway_state != PVR2_PATHWAY_DIGITAL); | ||
| 4148 | |||
| 3609 | /* Update master state based upon all other states. */ | 4149 | /* Update master state based upon all other states. */ |
| 3610 | if (!hdw->flag_ok) { | 4150 | if (!hdw->flag_ok) { |
| 3611 | st = PVR2_STATE_DEAD; | 4151 | st = PVR2_STATE_DEAD; |
| 3612 | } else if (hdw->fw1_state != FW1_STATE_OK) { | 4152 | } else if (hdw->fw1_state != FW1_STATE_OK) { |
| 3613 | st = PVR2_STATE_COLD; | 4153 | st = PVR2_STATE_COLD; |
| 3614 | } else if (!hdw->state_encoder_ok) { | 4154 | } else if ((analog_mode || |
| 4155 | hdw->hdw_desc->flag_digital_requires_cx23416) && | ||
| 4156 | !hdw->state_encoder_ok) { | ||
| 3615 | st = PVR2_STATE_WARM; | 4157 | st = PVR2_STATE_WARM; |
| 3616 | } else if (hdw->flag_tripped || hdw->flag_decoder_missed) { | 4158 | } else if (hdw->flag_tripped || |
| 4159 | (analog_mode && hdw->flag_decoder_missed)) { | ||
| 3617 | st = PVR2_STATE_ERROR; | 4160 | st = PVR2_STATE_ERROR; |
| 3618 | } else if (hdw->state_encoder_run && | 4161 | } else if (hdw->state_usbstream_run && |
| 3619 | hdw->state_decoder_run && | 4162 | (!analog_mode || |
| 3620 | hdw->state_usbstream_run) { | 4163 | (hdw->state_encoder_run && hdw->state_decoder_run))) { |
| 3621 | st = PVR2_STATE_RUN; | 4164 | st = PVR2_STATE_RUN; |
| 3622 | } else { | 4165 | } else { |
| 3623 | st = PVR2_STATE_READY; | 4166 | st = PVR2_STATE_READY; |
| @@ -3627,6 +4170,7 @@ static int pvr2_hdw_state_eval(struct pvr2_hdw *hdw) | |||
| 3627 | "Device state change from %s to %s", | 4170 | "Device state change from %s to %s", |
| 3628 | pvr2_get_state_name(hdw->master_state), | 4171 | pvr2_get_state_name(hdw->master_state), |
| 3629 | pvr2_get_state_name(st)); | 4172 | pvr2_get_state_name(st)); |
| 4173 | pvr2_led_ctrl(hdw,st == PVR2_STATE_RUN); | ||
| 3630 | hdw->master_state = st; | 4174 | hdw->master_state = st; |
| 3631 | state_updated = !0; | 4175 | state_updated = !0; |
| 3632 | callback_flag = !0; | 4176 | callback_flag = !0; |
| @@ -3656,47 +4200,6 @@ static void pvr2_hdw_state_sched(struct pvr2_hdw *hdw) | |||
| 3656 | } | 4200 | } |
| 3657 | 4201 | ||
| 3658 | 4202 | ||
| 3659 | void pvr2_hdw_get_debug_info_unlocked(const struct pvr2_hdw *hdw, | ||
| 3660 | struct pvr2_hdw_debug_info *ptr) | ||
| 3661 | { | ||
| 3662 | ptr->big_lock_held = hdw->big_lock_held; | ||
| 3663 | ptr->ctl_lock_held = hdw->ctl_lock_held; | ||
| 3664 | ptr->flag_disconnected = hdw->flag_disconnected; | ||
| 3665 | ptr->flag_init_ok = hdw->flag_init_ok; | ||
| 3666 | ptr->flag_ok = hdw->flag_ok; | ||
| 3667 | ptr->fw1_state = hdw->fw1_state; | ||
| 3668 | ptr->flag_decoder_missed = hdw->flag_decoder_missed; | ||
| 3669 | ptr->flag_tripped = hdw->flag_tripped; | ||
| 3670 | ptr->state_encoder_ok = hdw->state_encoder_ok; | ||
| 3671 | ptr->state_encoder_run = hdw->state_encoder_run; | ||
| 3672 | ptr->state_decoder_run = hdw->state_decoder_run; | ||
| 3673 | ptr->state_usbstream_run = hdw->state_usbstream_run; | ||
| 3674 | ptr->state_decoder_quiescent = hdw->state_decoder_quiescent; | ||
| 3675 | ptr->state_pipeline_config = hdw->state_pipeline_config; | ||
| 3676 | ptr->state_pipeline_req = hdw->state_pipeline_req; | ||
| 3677 | ptr->state_pipeline_pause = hdw->state_pipeline_pause; | ||
| 3678 | ptr->state_pipeline_idle = hdw->state_pipeline_idle; | ||
| 3679 | ptr->cmd_debug_state = hdw->cmd_debug_state; | ||
| 3680 | ptr->cmd_code = hdw->cmd_debug_code; | ||
| 3681 | ptr->cmd_debug_write_len = hdw->cmd_debug_write_len; | ||
| 3682 | ptr->cmd_debug_read_len = hdw->cmd_debug_read_len; | ||
| 3683 | ptr->cmd_debug_timeout = hdw->ctl_timeout_flag; | ||
| 3684 | ptr->cmd_debug_write_pend = hdw->ctl_write_pend_flag; | ||
| 3685 | ptr->cmd_debug_read_pend = hdw->ctl_read_pend_flag; | ||
| 3686 | ptr->cmd_debug_rstatus = hdw->ctl_read_urb->status; | ||
| 3687 | ptr->cmd_debug_wstatus = hdw->ctl_read_urb->status; | ||
| 3688 | } | ||
| 3689 | |||
| 3690 | |||
| 3691 | void pvr2_hdw_get_debug_info_locked(struct pvr2_hdw *hdw, | ||
| 3692 | struct pvr2_hdw_debug_info *ptr) | ||
| 3693 | { | ||
| 3694 | LOCK_TAKE(hdw->ctl_lock); do { | ||
| 3695 | pvr2_hdw_get_debug_info_unlocked(hdw,ptr); | ||
| 3696 | } while(0); LOCK_GIVE(hdw->ctl_lock); | ||
| 3697 | } | ||
| 3698 | |||
| 3699 | |||
| 3700 | int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *dp) | 4203 | int pvr2_hdw_gpio_get_dir(struct pvr2_hdw *hdw,u32 *dp) |
| 3701 | { | 4204 | { |
| 3702 | return pvr2_read_register(hdw,PVR2_GPIO_DIR,dp); | 4205 | return pvr2_read_register(hdw,PVR2_GPIO_DIR,dp); |
| @@ -3756,6 +4259,80 @@ int pvr2_hdw_gpio_chg_out(struct pvr2_hdw *hdw,u32 msk,u32 val) | |||
| 3756 | } | 4259 | } |
| 3757 | 4260 | ||
| 3758 | 4261 | ||
| 4262 | unsigned int pvr2_hdw_get_input_available(struct pvr2_hdw *hdw) | ||
| 4263 | { | ||
| 4264 | return hdw->input_avail_mask; | ||
| 4265 | } | ||
| 4266 | |||
| 4267 | |||
| 4268 | unsigned int pvr2_hdw_get_input_allowed(struct pvr2_hdw *hdw) | ||
| 4269 | { | ||
| 4270 | return hdw->input_allowed_mask; | ||
| 4271 | } | ||
| 4272 | |||
| 4273 | |||
| 4274 | static int pvr2_hdw_set_input(struct pvr2_hdw *hdw,int v) | ||
| 4275 | { | ||
| 4276 | if (hdw->input_val != v) { | ||
| 4277 | hdw->input_val = v; | ||
| 4278 | hdw->input_dirty = !0; | ||
| 4279 | } | ||
| 4280 | |||
| 4281 | /* Handle side effects - if we switch to a mode that needs the RF | ||
| 4282 | tuner, then select the right frequency choice as well and mark | ||
| 4283 | it dirty. */ | ||
| 4284 | if (hdw->input_val == PVR2_CVAL_INPUT_RADIO) { | ||
| 4285 | hdw->freqSelector = 0; | ||
| 4286 | hdw->freqDirty = !0; | ||
| 4287 | } else if ((hdw->input_val == PVR2_CVAL_INPUT_TV) || | ||
| 4288 | (hdw->input_val == PVR2_CVAL_INPUT_DTV)) { | ||
| 4289 | hdw->freqSelector = 1; | ||
| 4290 | hdw->freqDirty = !0; | ||
| 4291 | } | ||
| 4292 | return 0; | ||
| 4293 | } | ||
| 4294 | |||
| 4295 | |||
| 4296 | int pvr2_hdw_set_input_allowed(struct pvr2_hdw *hdw, | ||
| 4297 | unsigned int change_mask, | ||
| 4298 | unsigned int change_val) | ||
| 4299 | { | ||
| 4300 | int ret = 0; | ||
| 4301 | unsigned int nv,m,idx; | ||
| 4302 | LOCK_TAKE(hdw->big_lock); | ||
| 4303 | do { | ||
| 4304 | nv = hdw->input_allowed_mask & ~change_mask; | ||
| 4305 | nv |= (change_val & change_mask); | ||
| 4306 | nv &= hdw->input_avail_mask; | ||
| 4307 | if (!nv) { | ||
| 4308 | /* No legal modes left; return error instead. */ | ||
| 4309 | ret = -EPERM; | ||
| 4310 | break; | ||
| 4311 | } | ||
| 4312 | hdw->input_allowed_mask = nv; | ||
| 4313 | if ((1 << hdw->input_val) & hdw->input_allowed_mask) { | ||
| 4314 | /* Current mode is still in the allowed mask, so | ||
| 4315 | we're done. */ | ||
| 4316 | break; | ||
| 4317 | } | ||
| 4318 | /* Select and switch to a mode that is still in the allowed | ||
| 4319 | mask */ | ||
| 4320 | if (!hdw->input_allowed_mask) { | ||
| 4321 | /* Nothing legal; give up */ | ||
| 4322 | break; | ||
| 4323 | } | ||
| 4324 | m = hdw->input_allowed_mask; | ||
| 4325 | for (idx = 0; idx < (sizeof(m) << 3); idx++) { | ||
| 4326 | if (!((1 << idx) & m)) continue; | ||
| 4327 | pvr2_hdw_set_input(hdw,idx); | ||
| 4328 | break; | ||
| 4329 | } | ||
| 4330 | } while (0); | ||
| 4331 | LOCK_GIVE(hdw->big_lock); | ||
| 4332 | return ret; | ||
| 4333 | } | ||
| 4334 | |||
| 4335 | |||
| 3759 | /* Find I2C address of eeprom */ | 4336 | /* Find I2C address of eeprom */ |
| 3760 | static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw) | 4337 | static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw) |
| 3761 | { | 4338 | { |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h index 3ad7a13d6c39..20295e0c1995 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h | |||
| @@ -40,9 +40,10 @@ | |||
| 40 | 40 | ||
| 41 | /* Legal values for the INPUT state variable */ | 41 | /* Legal values for the INPUT state variable */ |
| 42 | #define PVR2_CVAL_INPUT_TV 0 | 42 | #define PVR2_CVAL_INPUT_TV 0 |
| 43 | #define PVR2_CVAL_INPUT_SVIDEO 1 | 43 | #define PVR2_CVAL_INPUT_DTV 1 |
| 44 | #define PVR2_CVAL_INPUT_COMPOSITE 2 | 44 | #define PVR2_CVAL_INPUT_COMPOSITE 2 |
| 45 | #define PVR2_CVAL_INPUT_RADIO 3 | 45 | #define PVR2_CVAL_INPUT_SVIDEO 3 |
| 46 | #define PVR2_CVAL_INPUT_RADIO 4 | ||
| 46 | 47 | ||
| 47 | enum pvr2_config { | 48 | enum pvr2_config { |
| 48 | pvr2_config_empty, /* No configuration */ | 49 | pvr2_config_empty, /* No configuration */ |
| @@ -90,9 +91,6 @@ enum pvr2_v4l_type { | |||
| 90 | /* Translate configuration enum to a string label */ | 91 | /* Translate configuration enum to a string label */ |
| 91 | const char *pvr2_config_get_name(enum pvr2_config); | 92 | const char *pvr2_config_get_name(enum pvr2_config); |
| 92 | 93 | ||
| 93 | /* Translate a master state enum to a string label */ | ||
| 94 | const char *pvr2_hdw_get_state_name(unsigned int); | ||
| 95 | |||
| 96 | struct pvr2_hdw; | 94 | struct pvr2_hdw; |
| 97 | 95 | ||
| 98 | /* Create and return a structure for interacting with the underlying | 96 | /* Create and return a structure for interacting with the underlying |
| @@ -100,14 +98,15 @@ struct pvr2_hdw; | |||
| 100 | struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | 98 | struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, |
| 101 | const struct usb_device_id *devid); | 99 | const struct usb_device_id *devid); |
| 102 | 100 | ||
| 101 | /* Perform second stage initialization, passing in a notification callback | ||
| 102 | for when the master state changes. */ | ||
| 103 | int pvr2_hdw_initialize(struct pvr2_hdw *, | ||
| 104 | void (*callback_func)(void *), | ||
| 105 | void *callback_data); | ||
| 106 | |||
| 103 | /* Destroy hardware interaction structure */ | 107 | /* Destroy hardware interaction structure */ |
| 104 | void pvr2_hdw_destroy(struct pvr2_hdw *); | 108 | void pvr2_hdw_destroy(struct pvr2_hdw *); |
| 105 | 109 | ||
| 106 | /* Register a function to be called whenever the master state changes. */ | ||
| 107 | void pvr2_hdw_set_state_callback(struct pvr2_hdw *, | ||
| 108 | void (*callback_func)(void *), | ||
| 109 | void *callback_data); | ||
| 110 | |||
| 111 | /* Return true if in the ready (normal) state */ | 110 | /* Return true if in the ready (normal) state */ |
| 112 | int pvr2_hdw_dev_ok(struct pvr2_hdw *); | 111 | int pvr2_hdw_dev_ok(struct pvr2_hdw *); |
| 113 | 112 | ||
| @@ -146,6 +145,23 @@ struct pvr2_ctrl *pvr2_hdw_get_ctrl_nextv4l(struct pvr2_hdw *, | |||
| 146 | /* Commit all control changes made up to this point */ | 145 | /* Commit all control changes made up to this point */ |
| 147 | int pvr2_hdw_commit_ctl(struct pvr2_hdw *); | 146 | int pvr2_hdw_commit_ctl(struct pvr2_hdw *); |
| 148 | 147 | ||
| 148 | /* Return a bit mask of valid input selections for this device. Mask bits | ||
| 149 | * will be according to PVR_CVAL_INPUT_xxxx definitions. */ | ||
| 150 | unsigned int pvr2_hdw_get_input_available(struct pvr2_hdw *); | ||
| 151 | |||
| 152 | /* Return a bit mask of allowed input selections for this device. Mask bits | ||
| 153 | * will be according to PVR_CVAL_INPUT_xxxx definitions. */ | ||
| 154 | unsigned int pvr2_hdw_get_input_allowed(struct pvr2_hdw *); | ||
| 155 | |||
| 156 | /* Change the set of allowed input selections for this device. Both | ||
| 157 | change_mask and change_valu are mask bits according to | ||
| 158 | PVR_CVAL_INPUT_xxxx definitions. The change_mask parameter indicate | ||
| 159 | which settings are being changed and the change_val parameter indicates | ||
| 160 | whether corresponding settings are being set or cleared. */ | ||
| 161 | int pvr2_hdw_set_input_allowed(struct pvr2_hdw *, | ||
| 162 | unsigned int change_mask, | ||
| 163 | unsigned int change_val); | ||
| 164 | |||
| 149 | /* Return name for this driver instance */ | 165 | /* Return name for this driver instance */ |
| 150 | const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *); | 166 | const char *pvr2_hdw_get_driver_name(struct pvr2_hdw *); |
| 151 | 167 | ||
| @@ -250,6 +266,9 @@ int pvr2_hdw_cmd_deep_reset(struct pvr2_hdw *); | |||
| 250 | /* Execute simple reset command */ | 266 | /* Execute simple reset command */ |
| 251 | int pvr2_hdw_cmd_powerup(struct pvr2_hdw *); | 267 | int pvr2_hdw_cmd_powerup(struct pvr2_hdw *); |
| 252 | 268 | ||
| 269 | /* suspend */ | ||
| 270 | int pvr2_hdw_cmd_powerdown(struct pvr2_hdw *); | ||
| 271 | |||
| 253 | /* Order decoder to reset */ | 272 | /* Order decoder to reset */ |
| 254 | int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *); | 273 | int pvr2_hdw_cmd_decoder_reset(struct pvr2_hdw *); |
| 255 | 274 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c index 62867fa3517a..793c89a8d672 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c +++ b/drivers/media/video/pvrusb2/pvrusb2-i2c-core.c | |||
| @@ -35,7 +35,7 @@ | |||
| 35 | 35 | ||
| 36 | */ | 36 | */ |
| 37 | 37 | ||
| 38 | static unsigned int i2c_scan = 0; | 38 | static unsigned int i2c_scan; |
| 39 | module_param(i2c_scan, int, S_IRUGO|S_IWUSR); | 39 | module_param(i2c_scan, int, S_IRUGO|S_IWUSR); |
| 40 | MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); | 40 | MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); |
| 41 | 41 | ||
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.c b/drivers/media/video/pvrusb2/pvrusb2-io.c index a9889ff96ecc..7aff8b720064 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-io.c +++ b/drivers/media/video/pvrusb2/pvrusb2-io.c | |||
| @@ -80,6 +80,10 @@ struct pvr2_stream { | |||
| 80 | /* Tracking state for tolerating errors */ | 80 | /* Tracking state for tolerating errors */ |
| 81 | unsigned int fail_count; | 81 | unsigned int fail_count; |
| 82 | unsigned int fail_tolerance; | 82 | unsigned int fail_tolerance; |
| 83 | |||
| 84 | unsigned int buffers_processed; | ||
| 85 | unsigned int buffers_failed; | ||
| 86 | unsigned int bytes_processed; | ||
| 83 | }; | 87 | }; |
| 84 | 88 | ||
| 85 | struct pvr2_buffer { | 89 | struct pvr2_buffer { |
| @@ -446,6 +450,8 @@ static void buffer_complete(struct urb *urb) | |||
| 446 | (urb->status == -ENOENT) || | 450 | (urb->status == -ENOENT) || |
| 447 | (urb->status == -ECONNRESET) || | 451 | (urb->status == -ECONNRESET) || |
| 448 | (urb->status == -ESHUTDOWN)) { | 452 | (urb->status == -ESHUTDOWN)) { |
| 453 | (sp->buffers_processed)++; | ||
| 454 | sp->bytes_processed += urb->actual_length; | ||
| 449 | bp->used_count = urb->actual_length; | 455 | bp->used_count = urb->actual_length; |
| 450 | if (sp->fail_count) { | 456 | if (sp->fail_count) { |
| 451 | pvr2_trace(PVR2_TRACE_TOLERANCE, | 457 | pvr2_trace(PVR2_TRACE_TOLERANCE, |
| @@ -457,11 +463,13 @@ static void buffer_complete(struct urb *urb) | |||
| 457 | // We can tolerate this error, because we're below the | 463 | // We can tolerate this error, because we're below the |
| 458 | // threshold... | 464 | // threshold... |
| 459 | (sp->fail_count)++; | 465 | (sp->fail_count)++; |
| 466 | (sp->buffers_failed)++; | ||
| 460 | pvr2_trace(PVR2_TRACE_TOLERANCE, | 467 | pvr2_trace(PVR2_TRACE_TOLERANCE, |
| 461 | "stream %p ignoring error %d" | 468 | "stream %p ignoring error %d" |
| 462 | " - fail count increased to %u", | 469 | " - fail count increased to %u", |
| 463 | sp,urb->status,sp->fail_count); | 470 | sp,urb->status,sp->fail_count); |
| 464 | } else { | 471 | } else { |
| 472 | (sp->buffers_failed)++; | ||
| 465 | bp->status = urb->status; | 473 | bp->status = urb->status; |
| 466 | } | 474 | } |
| 467 | spin_unlock_irqrestore(&sp->list_lock,irq_flags); | 475 | spin_unlock_irqrestore(&sp->list_lock,irq_flags); |
| @@ -515,6 +523,28 @@ void pvr2_stream_set_callback(struct pvr2_stream *sp, | |||
| 515 | } while(0); mutex_unlock(&sp->mutex); | 523 | } while(0); mutex_unlock(&sp->mutex); |
| 516 | } | 524 | } |
| 517 | 525 | ||
| 526 | void pvr2_stream_get_stats(struct pvr2_stream *sp, | ||
| 527 | struct pvr2_stream_stats *stats, | ||
| 528 | int zero_counts) | ||
| 529 | { | ||
| 530 | unsigned long irq_flags; | ||
| 531 | spin_lock_irqsave(&sp->list_lock,irq_flags); | ||
| 532 | if (stats) { | ||
| 533 | stats->buffers_in_queue = sp->q_count; | ||
| 534 | stats->buffers_in_idle = sp->i_count; | ||
| 535 | stats->buffers_in_ready = sp->r_count; | ||
| 536 | stats->buffers_processed = sp->buffers_processed; | ||
| 537 | stats->buffers_failed = sp->buffers_failed; | ||
| 538 | stats->bytes_processed = sp->bytes_processed; | ||
| 539 | } | ||
| 540 | if (zero_counts) { | ||
| 541 | sp->buffers_processed = 0; | ||
| 542 | sp->buffers_failed = 0; | ||
| 543 | sp->bytes_processed = 0; | ||
| 544 | } | ||
| 545 | spin_unlock_irqrestore(&sp->list_lock,irq_flags); | ||
| 546 | } | ||
| 547 | |||
| 518 | /* Query / set the nominal buffer count */ | 548 | /* Query / set the nominal buffer count */ |
| 519 | int pvr2_stream_get_buffer_count(struct pvr2_stream *sp) | 549 | int pvr2_stream_get_buffer_count(struct pvr2_stream *sp) |
| 520 | { | 550 | { |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-io.h b/drivers/media/video/pvrusb2/pvrusb2-io.h index 93279cc2a35e..42fcf8281a87 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-io.h +++ b/drivers/media/video/pvrusb2/pvrusb2-io.h | |||
| @@ -36,6 +36,15 @@ enum pvr2_buffer_state { | |||
| 36 | struct pvr2_stream; | 36 | struct pvr2_stream; |
| 37 | struct pvr2_buffer; | 37 | struct pvr2_buffer; |
| 38 | 38 | ||
| 39 | struct pvr2_stream_stats { | ||
| 40 | unsigned int buffers_in_queue; | ||
| 41 | unsigned int buffers_in_idle; | ||
| 42 | unsigned int buffers_in_ready; | ||
| 43 | unsigned int buffers_processed; | ||
| 44 | unsigned int buffers_failed; | ||
| 45 | unsigned int bytes_processed; | ||
| 46 | }; | ||
| 47 | |||
| 39 | /* Initialize / tear down stream structure */ | 48 | /* Initialize / tear down stream structure */ |
| 40 | struct pvr2_stream *pvr2_stream_create(void); | 49 | struct pvr2_stream *pvr2_stream_create(void); |
| 41 | void pvr2_stream_destroy(struct pvr2_stream *); | 50 | void pvr2_stream_destroy(struct pvr2_stream *); |
| @@ -45,6 +54,9 @@ void pvr2_stream_setup(struct pvr2_stream *, | |||
| 45 | void pvr2_stream_set_callback(struct pvr2_stream *, | 54 | void pvr2_stream_set_callback(struct pvr2_stream *, |
| 46 | pvr2_stream_callback func, | 55 | pvr2_stream_callback func, |
| 47 | void *data); | 56 | void *data); |
| 57 | void pvr2_stream_get_stats(struct pvr2_stream *, | ||
| 58 | struct pvr2_stream_stats *, | ||
| 59 | int zero_counts); | ||
| 48 | 60 | ||
| 49 | /* Query / set the nominal buffer count */ | 61 | /* Query / set the nominal buffer count */ |
| 50 | int pvr2_stream_get_buffer_count(struct pvr2_stream *); | 62 | int pvr2_stream_get_buffer_count(struct pvr2_stream *); |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-main.c b/drivers/media/video/pvrusb2/pvrusb2-main.c index b63b2265503a..332aced8a5a1 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-main.c +++ b/drivers/media/video/pvrusb2/pvrusb2-main.c | |||
| @@ -60,6 +60,10 @@ static void pvr_setup_attach(struct pvr2_context *pvr) | |||
| 60 | { | 60 | { |
| 61 | /* Create association with v4l layer */ | 61 | /* Create association with v4l layer */ |
| 62 | pvr2_v4l2_create(pvr); | 62 | pvr2_v4l2_create(pvr); |
| 63 | #ifdef CONFIG_VIDEO_PVRUSB2_DVB | ||
| 64 | /* Create association with dvb layer */ | ||
| 65 | pvr2_dvb_create(pvr); | ||
| 66 | #endif | ||
| 63 | #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS | 67 | #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS |
| 64 | pvr2_sysfs_create(pvr,class_ptr); | 68 | pvr2_sysfs_create(pvr,class_ptr); |
| 65 | #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */ | 69 | #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */ |
| @@ -121,6 +125,12 @@ static int __init pvr_init(void) | |||
| 121 | 125 | ||
| 122 | pvr2_trace(PVR2_TRACE_INIT,"pvr_init"); | 126 | pvr2_trace(PVR2_TRACE_INIT,"pvr_init"); |
| 123 | 127 | ||
| 128 | ret = pvr2_context_global_init(); | ||
| 129 | if (ret != 0) { | ||
| 130 | pvr2_trace(PVR2_TRACE_INIT,"pvr_init failure code=%d",ret); | ||
| 131 | return ret; | ||
| 132 | } | ||
| 133 | |||
| 124 | #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS | 134 | #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS |
| 125 | class_ptr = pvr2_sysfs_class_create(); | 135 | class_ptr = pvr2_sysfs_class_create(); |
| 126 | #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */ | 136 | #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */ |
| @@ -132,6 +142,8 @@ static int __init pvr_init(void) | |||
| 132 | if (pvrusb2_debug) info("Debug mask is %d (0x%x)", | 142 | if (pvrusb2_debug) info("Debug mask is %d (0x%x)", |
| 133 | pvrusb2_debug,pvrusb2_debug); | 143 | pvrusb2_debug,pvrusb2_debug); |
| 134 | 144 | ||
| 145 | pvr2_trace(PVR2_TRACE_INIT,"pvr_init complete"); | ||
| 146 | |||
| 135 | return ret; | 147 | return ret; |
| 136 | } | 148 | } |
| 137 | 149 | ||
| @@ -144,6 +156,10 @@ static void __exit pvr_exit(void) | |||
| 144 | #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS | 156 | #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS |
| 145 | pvr2_sysfs_class_destroy(class_ptr); | 157 | pvr2_sysfs_class_destroy(class_ptr); |
| 146 | #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */ | 158 | #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */ |
| 159 | |||
| 160 | pvr2_context_global_done(); | ||
| 161 | |||
| 162 | pvr2_trace(PVR2_TRACE_INIT,"pvr_exit complete"); | ||
| 147 | } | 163 | } |
| 148 | 164 | ||
| 149 | module_init(pvr_init); | 165 | module_init(pvr_init); |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-std.c b/drivers/media/video/pvrusb2/pvrusb2-std.c index da309288daa4..fdc5a2b49ca8 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-std.c +++ b/drivers/media/video/pvrusb2/pvrusb2-std.c | |||
| @@ -79,7 +79,7 @@ struct std_name { | |||
| 79 | #define TSTD_Nc (V4L2_STD_PAL_Nc) | 79 | #define TSTD_Nc (V4L2_STD_PAL_Nc) |
| 80 | #define TSTD_60 (V4L2_STD_PAL_60) | 80 | #define TSTD_60 (V4L2_STD_PAL_60) |
| 81 | 81 | ||
| 82 | #define CSTD_ALL (CSTD_PAL|CSTD_NTSC|CSTD_SECAM) | 82 | #define CSTD_ALL (CSTD_PAL|CSTD_NTSC|CSTD_ATSC|CSTD_SECAM) |
| 83 | 83 | ||
| 84 | /* Mapping of standard bits to color system */ | 84 | /* Mapping of standard bits to color system */ |
| 85 | static const struct std_name std_groups[] = { | 85 | static const struct std_name std_groups[] = { |
| @@ -328,7 +328,7 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr, | |||
| 328 | struct v4l2_standard *stddefs; | 328 | struct v4l2_standard *stddefs; |
| 329 | 329 | ||
| 330 | if (pvrusb2_debug & PVR2_TRACE_STD) { | 330 | if (pvrusb2_debug & PVR2_TRACE_STD) { |
| 331 | char buf[50]; | 331 | char buf[100]; |
| 332 | bcnt = pvr2_std_id_to_str(buf,sizeof(buf),id); | 332 | bcnt = pvr2_std_id_to_str(buf,sizeof(buf),id); |
| 333 | pvr2_trace( | 333 | pvr2_trace( |
| 334 | PVR2_TRACE_STD,"Mapping standards mask=0x%x (%.*s)", | 334 | PVR2_TRACE_STD,"Mapping standards mask=0x%x (%.*s)", |
| @@ -352,8 +352,11 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr, | |||
| 352 | if ((id & std_mixes[idx2]) == std_mixes[idx2]) std_cnt++; | 352 | if ((id & std_mixes[idx2]) == std_mixes[idx2]) std_cnt++; |
| 353 | } | 353 | } |
| 354 | 354 | ||
| 355 | /* Don't complain about ATSC standard values */ | ||
| 356 | fmsk &= ~CSTD_ATSC; | ||
| 357 | |||
| 355 | if (fmsk) { | 358 | if (fmsk) { |
| 356 | char buf[50]; | 359 | char buf[100]; |
| 357 | bcnt = pvr2_std_id_to_str(buf,sizeof(buf),fmsk); | 360 | bcnt = pvr2_std_id_to_str(buf,sizeof(buf),fmsk); |
| 358 | pvr2_trace( | 361 | pvr2_trace( |
| 359 | PVR2_TRACE_ERROR_LEGS, | 362 | PVR2_TRACE_ERROR_LEGS, |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c index 07f4eae18433..0ff7a836a8a2 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c +++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c | |||
| @@ -287,6 +287,8 @@ static ssize_t store_val_norm(int id,struct device *class_dev, | |||
| 287 | struct pvr2_sysfs *sfp; | 287 | struct pvr2_sysfs *sfp; |
| 288 | int ret; | 288 | int ret; |
| 289 | sfp = (struct pvr2_sysfs *)class_dev->driver_data; | 289 | sfp = (struct pvr2_sysfs *)class_dev->driver_data; |
| 290 | pvr2_sysfs_trace("pvr2_sysfs(%p) store_val_norm(cid=%d) \"%.*s\"", | ||
| 291 | sfp,id,(int)count,buf); | ||
| 290 | ret = store_val_any(id,0,sfp,buf,count); | 292 | ret = store_val_any(id,0,sfp,buf,count); |
| 291 | if (!ret) ret = count; | 293 | if (!ret) ret = count; |
| 292 | return ret; | 294 | return ret; |
| @@ -298,6 +300,8 @@ static ssize_t store_val_custom(int id,struct device *class_dev, | |||
| 298 | struct pvr2_sysfs *sfp; | 300 | struct pvr2_sysfs *sfp; |
| 299 | int ret; | 301 | int ret; |
| 300 | sfp = (struct pvr2_sysfs *)class_dev->driver_data; | 302 | sfp = (struct pvr2_sysfs *)class_dev->driver_data; |
| 303 | pvr2_sysfs_trace("pvr2_sysfs(%p) store_val_custom(cid=%d) \"%.*s\"", | ||
| 304 | sfp,id,(int)count,buf); | ||
| 301 | ret = store_val_any(id,1,sfp,buf,count); | 305 | ret = store_val_any(id,1,sfp,buf,count); |
| 302 | if (!ret) ret = count; | 306 | if (!ret) ret = count; |
| 303 | return ret; | 307 | return ret; |
| @@ -604,8 +608,9 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id) | |||
| 604 | 608 | ||
| 605 | ret = sysfs_create_group(&sfp->class_dev->kobj,&cip->grp); | 609 | ret = sysfs_create_group(&sfp->class_dev->kobj,&cip->grp); |
| 606 | if (ret) { | 610 | if (ret) { |
| 607 | printk(KERN_WARNING "%s: sysfs_create_group error: %d\n", | 611 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 608 | __FUNCTION__, ret); | 612 | "sysfs_create_group error: %d", |
| 613 | ret); | ||
| 609 | return; | 614 | return; |
| 610 | } | 615 | } |
| 611 | cip->created_ok = !0; | 616 | cip->created_ok = !0; |
| @@ -636,15 +641,17 @@ static void pvr2_sysfs_add_debugifc(struct pvr2_sysfs *sfp) | |||
| 636 | sfp->debugifc = dip; | 641 | sfp->debugifc = dip; |
| 637 | ret = device_create_file(sfp->class_dev,&dip->attr_debugcmd); | 642 | ret = device_create_file(sfp->class_dev,&dip->attr_debugcmd); |
| 638 | if (ret < 0) { | 643 | if (ret < 0) { |
| 639 | printk(KERN_WARNING "%s: device_create_file error: %d\n", | 644 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 640 | __FUNCTION__, ret); | 645 | "device_create_file error: %d", |
| 646 | ret); | ||
| 641 | } else { | 647 | } else { |
| 642 | dip->debugcmd_created_ok = !0; | 648 | dip->debugcmd_created_ok = !0; |
| 643 | } | 649 | } |
| 644 | ret = device_create_file(sfp->class_dev,&dip->attr_debuginfo); | 650 | ret = device_create_file(sfp->class_dev,&dip->attr_debuginfo); |
| 645 | if (ret < 0) { | 651 | if (ret < 0) { |
| 646 | printk(KERN_WARNING "%s: device_create_file error: %d\n", | 652 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 647 | __FUNCTION__, ret); | 653 | "device_create_file error: %d", |
| 654 | ret); | ||
| 648 | } else { | 655 | } else { |
| 649 | dip->debuginfo_created_ok = !0; | 656 | dip->debuginfo_created_ok = !0; |
| 650 | } | 657 | } |
| @@ -847,8 +854,8 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
| 847 | class_dev->driver_data = sfp; | 854 | class_dev->driver_data = sfp; |
| 848 | ret = device_register(class_dev); | 855 | ret = device_register(class_dev); |
| 849 | if (ret) { | 856 | if (ret) { |
| 850 | printk(KERN_ERR "%s: device_register failed\n", | 857 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 851 | __FUNCTION__); | 858 | "device_register failed"); |
| 852 | kfree(class_dev); | 859 | kfree(class_dev); |
| 853 | return; | 860 | return; |
| 854 | } | 861 | } |
| @@ -860,8 +867,9 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
| 860 | ret = device_create_file(sfp->class_dev, | 867 | ret = device_create_file(sfp->class_dev, |
| 861 | &sfp->attr_v4l_minor_number); | 868 | &sfp->attr_v4l_minor_number); |
| 862 | if (ret < 0) { | 869 | if (ret < 0) { |
| 863 | printk(KERN_WARNING "%s: device_create_file error: %d\n", | 870 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 864 | __FUNCTION__, ret); | 871 | "device_create_file error: %d", |
| 872 | ret); | ||
| 865 | } else { | 873 | } else { |
| 866 | sfp->v4l_minor_number_created_ok = !0; | 874 | sfp->v4l_minor_number_created_ok = !0; |
| 867 | } | 875 | } |
| @@ -873,8 +881,9 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
| 873 | ret = device_create_file(sfp->class_dev, | 881 | ret = device_create_file(sfp->class_dev, |
| 874 | &sfp->attr_v4l_radio_minor_number); | 882 | &sfp->attr_v4l_radio_minor_number); |
| 875 | if (ret < 0) { | 883 | if (ret < 0) { |
| 876 | printk(KERN_WARNING "%s: device_create_file error: %d\n", | 884 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 877 | __FUNCTION__, ret); | 885 | "device_create_file error: %d", |
| 886 | ret); | ||
| 878 | } else { | 887 | } else { |
| 879 | sfp->v4l_radio_minor_number_created_ok = !0; | 888 | sfp->v4l_radio_minor_number_created_ok = !0; |
| 880 | } | 889 | } |
| @@ -885,8 +894,9 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
| 885 | sfp->attr_unit_number.store = NULL; | 894 | sfp->attr_unit_number.store = NULL; |
| 886 | ret = device_create_file(sfp->class_dev,&sfp->attr_unit_number); | 895 | ret = device_create_file(sfp->class_dev,&sfp->attr_unit_number); |
| 887 | if (ret < 0) { | 896 | if (ret < 0) { |
| 888 | printk(KERN_WARNING "%s: device_create_file error: %d\n", | 897 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 889 | __FUNCTION__, ret); | 898 | "device_create_file error: %d", |
| 899 | ret); | ||
| 890 | } else { | 900 | } else { |
| 891 | sfp->unit_number_created_ok = !0; | 901 | sfp->unit_number_created_ok = !0; |
| 892 | } | 902 | } |
| @@ -898,8 +908,9 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
| 898 | ret = device_create_file(sfp->class_dev, | 908 | ret = device_create_file(sfp->class_dev, |
| 899 | &sfp->attr_bus_info); | 909 | &sfp->attr_bus_info); |
| 900 | if (ret < 0) { | 910 | if (ret < 0) { |
| 901 | printk(KERN_WARNING "%s: device_create_file error: %d\n", | 911 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 902 | __FUNCTION__, ret); | 912 | "device_create_file error: %d", |
| 913 | ret); | ||
| 903 | } else { | 914 | } else { |
| 904 | sfp->bus_info_created_ok = !0; | 915 | sfp->bus_info_created_ok = !0; |
| 905 | } | 916 | } |
| @@ -911,8 +922,9 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
| 911 | ret = device_create_file(sfp->class_dev, | 922 | ret = device_create_file(sfp->class_dev, |
| 912 | &sfp->attr_hdw_name); | 923 | &sfp->attr_hdw_name); |
| 913 | if (ret < 0) { | 924 | if (ret < 0) { |
| 914 | printk(KERN_WARNING "%s: device_create_file error: %d\n", | 925 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 915 | __FUNCTION__, ret); | 926 | "device_create_file error: %d", |
| 927 | ret); | ||
| 916 | } else { | 928 | } else { |
| 917 | sfp->hdw_name_created_ok = !0; | 929 | sfp->hdw_name_created_ok = !0; |
| 918 | } | 930 | } |
| @@ -924,8 +936,9 @@ static void class_dev_create(struct pvr2_sysfs *sfp, | |||
| 924 | ret = device_create_file(sfp->class_dev, | 936 | ret = device_create_file(sfp->class_dev, |
| 925 | &sfp->attr_hdw_desc); | 937 | &sfp->attr_hdw_desc); |
| 926 | if (ret < 0) { | 938 | if (ret < 0) { |
| 927 | printk(KERN_WARNING "%s: device_create_file error: %d\n", | 939 | pvr2_trace(PVR2_TRACE_ERROR_LEGS, |
| 928 | __FUNCTION__, ret); | 940 | "device_create_file error: %d", |
| 941 | ret); | ||
| 929 | } else { | 942 | } else { |
| 930 | sfp->hdw_desc_created_ok = !0; | 943 | sfp->hdw_desc_created_ok = !0; |
| 931 | } | 944 | } |
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c index 8f0587ebd4bd..087a18245560 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c +++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c | |||
| @@ -57,7 +57,9 @@ struct pvr2_v4l2_fh { | |||
| 57 | struct pvr2_v4l2_fh *vprev; | 57 | struct pvr2_v4l2_fh *vprev; |
| 58 | wait_queue_head_t wait_data; | 58 | wait_queue_head_t wait_data; |
| 59 | int fw_mode_flag; | 59 | int fw_mode_flag; |
| 60 | int prev_input_val; | 60 | /* Map contiguous ordinal value to input id */ |
| 61 | unsigned char *input_map; | ||
| 62 | unsigned int input_cnt; | ||
| 61 | }; | 63 | }; |
| 62 | 64 | ||
| 63 | struct pvr2_v4l2 { | 65 | struct pvr2_v4l2 { |
| @@ -259,14 +261,21 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
| 259 | struct v4l2_input *vi = (struct v4l2_input *)arg; | 261 | struct v4l2_input *vi = (struct v4l2_input *)arg; |
| 260 | struct v4l2_input tmp; | 262 | struct v4l2_input tmp; |
| 261 | unsigned int cnt; | 263 | unsigned int cnt; |
| 264 | int val; | ||
| 262 | 265 | ||
| 263 | cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT); | 266 | cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT); |
| 264 | 267 | ||
| 265 | memset(&tmp,0,sizeof(tmp)); | 268 | memset(&tmp,0,sizeof(tmp)); |
| 266 | tmp.index = vi->index; | 269 | tmp.index = vi->index; |
| 267 | ret = 0; | 270 | ret = 0; |
| 268 | switch (vi->index) { | 271 | if ((vi->index < 0) || (vi->index >= fh->input_cnt)) { |
| 272 | ret = -EINVAL; | ||
| 273 | break; | ||
| 274 | } | ||
| 275 | val = fh->input_map[vi->index]; | ||
| 276 | switch (val) { | ||
| 269 | case PVR2_CVAL_INPUT_TV: | 277 | case PVR2_CVAL_INPUT_TV: |
| 278 | case PVR2_CVAL_INPUT_DTV: | ||
| 270 | case PVR2_CVAL_INPUT_RADIO: | 279 | case PVR2_CVAL_INPUT_RADIO: |
| 271 | tmp.type = V4L2_INPUT_TYPE_TUNER; | 280 | tmp.type = V4L2_INPUT_TYPE_TUNER; |
| 272 | break; | 281 | break; |
| @@ -281,7 +290,7 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
| 281 | if (ret < 0) break; | 290 | if (ret < 0) break; |
| 282 | 291 | ||
| 283 | cnt = 0; | 292 | cnt = 0; |
| 284 | pvr2_ctrl_get_valname(cptr,vi->index, | 293 | pvr2_ctrl_get_valname(cptr,val, |
| 285 | tmp.name,sizeof(tmp.name)-1,&cnt); | 294 | tmp.name,sizeof(tmp.name)-1,&cnt); |
| 286 | tmp.name[cnt] = 0; | 295 | tmp.name[cnt] = 0; |
| 287 | 296 | ||
| @@ -303,22 +312,33 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
| 303 | 312 | ||
| 304 | case VIDIOC_G_INPUT: | 313 | case VIDIOC_G_INPUT: |
| 305 | { | 314 | { |
| 315 | unsigned int idx; | ||
| 306 | struct pvr2_ctrl *cptr; | 316 | struct pvr2_ctrl *cptr; |
| 307 | struct v4l2_input *vi = (struct v4l2_input *)arg; | 317 | struct v4l2_input *vi = (struct v4l2_input *)arg; |
| 308 | int val; | 318 | int val; |
| 309 | cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT); | 319 | cptr = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT); |
| 310 | val = 0; | 320 | val = 0; |
| 311 | ret = pvr2_ctrl_get_value(cptr,&val); | 321 | ret = pvr2_ctrl_get_value(cptr,&val); |
| 312 | vi->index = val; | 322 | vi->index = 0; |
| 323 | for (idx = 0; idx < fh->input_cnt; idx++) { | ||
| 324 | if (fh->input_map[idx] == val) { | ||
| 325 | vi->index = idx; | ||
| 326 | break; | ||
| 327 | } | ||
| 328 | } | ||
| 313 | break; | 329 | break; |
| 314 | } | 330 | } |
| 315 | 331 | ||
| 316 | case VIDIOC_S_INPUT: | 332 | case VIDIOC_S_INPUT: |
| 317 | { | 333 | { |
| 318 | struct v4l2_input *vi = (struct v4l2_input *)arg; | 334 | struct v4l2_input *vi = (struct v4l2_input *)arg; |
| 335 | if ((vi->index < 0) || (vi->index >= fh->input_cnt)) { | ||
| 336 | ret = -ERANGE; | ||
| 337 | break; | ||
| 338 | } | ||
| 319 | ret = pvr2_ctrl_set_value( | 339 | ret = pvr2_ctrl_set_value( |
| 320 | pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT), | 340 | pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT), |
| 321 | vi->index); | 341 | fh->input_map[vi->index]); |
| 322 | break; | 342 | break; |
| 323 | } | 343 | } |
| 324 | 344 | ||
| @@ -858,7 +878,6 @@ static int pvr2_v4l2_release(struct inode *inode, struct file *file) | |||
| 858 | { | 878 | { |
| 859 | struct pvr2_v4l2_fh *fhp = file->private_data; | 879 | struct pvr2_v4l2_fh *fhp = file->private_data; |
| 860 | struct pvr2_v4l2 *vp = fhp->vhead; | 880 | struct pvr2_v4l2 *vp = fhp->vhead; |
| 861 | struct pvr2_context *mp = fhp->vhead->channel.mc_head; | ||
| 862 | struct pvr2_hdw *hdw = fhp->channel.mc_head->hdw; | 881 | struct pvr2_hdw *hdw = fhp->channel.mc_head->hdw; |
| 863 | 882 | ||
| 864 | pvr2_trace(PVR2_TRACE_OPEN_CLOSE,"pvr2_v4l2_release"); | 883 | pvr2_trace(PVR2_TRACE_OPEN_CLOSE,"pvr2_v4l2_release"); |
| @@ -875,42 +894,30 @@ static int pvr2_v4l2_release(struct inode *inode, struct file *file) | |||
| 875 | v4l2_prio_close(&vp->prio, &fhp->prio); | 894 | v4l2_prio_close(&vp->prio, &fhp->prio); |
| 876 | file->private_data = NULL; | 895 | file->private_data = NULL; |
| 877 | 896 | ||
| 878 | pvr2_context_enter(mp); do { | 897 | if (fhp->vnext) { |
| 879 | /* Restore the previous input selection, if it makes sense | 898 | fhp->vnext->vprev = fhp->vprev; |
| 880 | to do so. */ | 899 | } else { |
| 881 | if (fhp->dev_info->v4l_type == VFL_TYPE_RADIO) { | 900 | vp->vlast = fhp->vprev; |
| 882 | struct pvr2_ctrl *cp; | 901 | } |
| 883 | int pval; | 902 | if (fhp->vprev) { |
| 884 | cp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT); | 903 | fhp->vprev->vnext = fhp->vnext; |
| 885 | pvr2_ctrl_get_value(cp,&pval); | 904 | } else { |
| 886 | /* Only restore if we're still selecting the radio */ | 905 | vp->vfirst = fhp->vnext; |
| 887 | if (pval == PVR2_CVAL_INPUT_RADIO) { | 906 | } |
| 888 | pvr2_ctrl_set_value(cp,fhp->prev_input_val); | 907 | fhp->vnext = NULL; |
| 889 | pvr2_hdw_commit_ctl(hdw); | 908 | fhp->vprev = NULL; |
| 890 | } | 909 | fhp->vhead = NULL; |
| 891 | } | 910 | pvr2_channel_done(&fhp->channel); |
| 892 | 911 | pvr2_trace(PVR2_TRACE_STRUCT, | |
| 893 | if (fhp->vnext) { | 912 | "Destroying pvr_v4l2_fh id=%p",fhp); |
| 894 | fhp->vnext->vprev = fhp->vprev; | 913 | if (fhp->input_map) { |
| 895 | } else { | 914 | kfree(fhp->input_map); |
| 896 | vp->vlast = fhp->vprev; | 915 | fhp->input_map = NULL; |
| 897 | } | 916 | } |
| 898 | if (fhp->vprev) { | 917 | kfree(fhp); |
| 899 | fhp->vprev->vnext = fhp->vnext; | 918 | if (vp->channel.mc_head->disconnect_flag && !vp->vfirst) { |
| 900 | } else { | 919 | pvr2_v4l2_destroy_no_lock(vp); |
| 901 | vp->vfirst = fhp->vnext; | 920 | } |
| 902 | } | ||
| 903 | fhp->vnext = NULL; | ||
| 904 | fhp->vprev = NULL; | ||
| 905 | fhp->vhead = NULL; | ||
| 906 | pvr2_channel_done(&fhp->channel); | ||
| 907 | pvr2_trace(PVR2_TRACE_STRUCT, | ||
| 908 | "Destroying pvr_v4l2_fh id=%p",fhp); | ||
| 909 | kfree(fhp); | ||
| 910 | if (vp->channel.mc_head->disconnect_flag && !vp->vfirst) { | ||
| 911 | pvr2_v4l2_destroy_no_lock(vp); | ||
| 912 | } | ||
| 913 | } while (0); pvr2_context_exit(mp); | ||
| 914 | return 0; | 921 | return 0; |
| 915 | } | 922 | } |
| 916 | 923 | ||
| @@ -921,6 +928,9 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file) | |||
| 921 | struct pvr2_v4l2_fh *fhp; | 928 | struct pvr2_v4l2_fh *fhp; |
| 922 | struct pvr2_v4l2 *vp; | 929 | struct pvr2_v4l2 *vp; |
| 923 | struct pvr2_hdw *hdw; | 930 | struct pvr2_hdw *hdw; |
| 931 | unsigned int input_mask = 0; | ||
| 932 | unsigned int input_cnt,idx; | ||
| 933 | int ret = 0; | ||
| 924 | 934 | ||
| 925 | dip = container_of(video_devdata(file),struct pvr2_v4l2_dev,devbase); | 935 | dip = container_of(video_devdata(file),struct pvr2_v4l2_dev,devbase); |
| 926 | 936 | ||
| @@ -943,32 +953,62 @@ static int pvr2_v4l2_open(struct inode *inode, struct file *file) | |||
| 943 | init_waitqueue_head(&fhp->wait_data); | 953 | init_waitqueue_head(&fhp->wait_data); |
| 944 | fhp->dev_info = dip; | 954 | fhp->dev_info = dip; |
| 945 | 955 | ||
| 946 | pvr2_context_enter(vp->channel.mc_head); do { | 956 | pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_v4l2_fh id=%p",fhp); |
| 947 | pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr_v4l2_fh id=%p",fhp); | 957 | pvr2_channel_init(&fhp->channel,vp->channel.mc_head); |
| 948 | pvr2_channel_init(&fhp->channel,vp->channel.mc_head); | ||
| 949 | 958 | ||
| 950 | fhp->vnext = NULL; | 959 | if (dip->v4l_type == VFL_TYPE_RADIO) { |
| 951 | fhp->vprev = vp->vlast; | 960 | /* Opening device as a radio, legal input selection subset |
| 952 | if (vp->vlast) { | 961 | is just the radio. */ |
| 953 | vp->vlast->vnext = fhp; | 962 | input_mask = (1 << PVR2_CVAL_INPUT_RADIO); |
| 954 | } else { | 963 | } else { |
| 955 | vp->vfirst = fhp; | 964 | /* Opening the main V4L device, legal input selection |
| 956 | } | 965 | subset includes all analog inputs. */ |
| 957 | vp->vlast = fhp; | 966 | input_mask = ((1 << PVR2_CVAL_INPUT_RADIO) | |
| 958 | fhp->vhead = vp; | 967 | (1 << PVR2_CVAL_INPUT_TV) | |
| 959 | 968 | (1 << PVR2_CVAL_INPUT_COMPOSITE) | | |
| 960 | /* Opening the /dev/radioX device implies a mode switch. | 969 | (1 << PVR2_CVAL_INPUT_SVIDEO)); |
| 961 | So execute that here. Note that you can get the | 970 | } |
| 962 | IDENTICAL effect merely by opening the normal video | 971 | ret = pvr2_channel_limit_inputs(&fhp->channel,input_mask); |
| 963 | device and setting the input appropriately. */ | 972 | if (ret) { |
| 964 | if (dip->v4l_type == VFL_TYPE_RADIO) { | 973 | pvr2_channel_done(&fhp->channel); |
| 965 | struct pvr2_ctrl *cp; | 974 | pvr2_trace(PVR2_TRACE_STRUCT, |
| 966 | cp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_INPUT); | 975 | "Destroying pvr_v4l2_fh id=%p (input mask error)", |
| 967 | pvr2_ctrl_get_value(cp,&fhp->prev_input_val); | 976 | fhp); |
| 968 | pvr2_ctrl_set_value(cp,PVR2_CVAL_INPUT_RADIO); | 977 | |
| 969 | pvr2_hdw_commit_ctl(hdw); | 978 | kfree(fhp); |
| 970 | } | 979 | return ret; |
| 971 | } while (0); pvr2_context_exit(vp->channel.mc_head); | 980 | } |
| 981 | |||
| 982 | input_mask &= pvr2_hdw_get_input_available(hdw); | ||
| 983 | input_cnt = 0; | ||
| 984 | for (idx = 0; idx < (sizeof(input_mask) << 3); idx++) { | ||
| 985 | if (input_mask & (1 << idx)) input_cnt++; | ||
| 986 | } | ||
| 987 | fhp->input_cnt = input_cnt; | ||
| 988 | fhp->input_map = kzalloc(input_cnt,GFP_KERNEL); | ||
| 989 | if (!fhp->input_map) { | ||
| 990 | pvr2_channel_done(&fhp->channel); | ||
| 991 | pvr2_trace(PVR2_TRACE_STRUCT, | ||
| 992 | "Destroying pvr_v4l2_fh id=%p (input map failure)", | ||
| 993 | fhp); | ||
| 994 | kfree(fhp); | ||
| 995 | return -ENOMEM; | ||
| 996 | } | ||
| 997 | input_cnt = 0; | ||
| 998 | for (idx = 0; idx < (sizeof(input_mask) << 3); idx++) { | ||
| 999 | if (!(input_mask & (1 << idx))) continue; | ||
| 1000 | fhp->input_map[input_cnt++] = idx; | ||
| 1001 | } | ||
| 1002 | |||
| 1003 | fhp->vnext = NULL; | ||
| 1004 | fhp->vprev = vp->vlast; | ||
| 1005 | if (vp->vlast) { | ||
| 1006 | vp->vlast->vnext = fhp; | ||
| 1007 | } else { | ||
| 1008 | vp->vfirst = fhp; | ||
| 1009 | } | ||
| 1010 | vp->vlast = fhp; | ||
| 1011 | fhp->vhead = vp; | ||
| 972 | 1012 | ||
| 973 | fhp->file = file; | 1013 | fhp->file = file; |
| 974 | file->private_data = fhp; | 1014 | file->private_data = fhp; |
| @@ -1201,24 +1241,27 @@ struct pvr2_v4l2 *pvr2_v4l2_create(struct pvr2_context *mnp) | |||
| 1201 | 1241 | ||
| 1202 | vp = kzalloc(sizeof(*vp),GFP_KERNEL); | 1242 | vp = kzalloc(sizeof(*vp),GFP_KERNEL); |
| 1203 | if (!vp) return vp; | 1243 | if (!vp) return vp; |
| 1204 | vp->dev_video = kzalloc(sizeof(*vp->dev_video),GFP_KERNEL); | ||
| 1205 | vp->dev_radio = kzalloc(sizeof(*vp->dev_radio),GFP_KERNEL); | ||
| 1206 | if (!(vp->dev_video && vp->dev_radio)) { | ||
| 1207 | kfree(vp->dev_video); | ||
| 1208 | kfree(vp->dev_radio); | ||
| 1209 | kfree(vp); | ||
| 1210 | return NULL; | ||
| 1211 | } | ||
| 1212 | pvr2_channel_init(&vp->channel,mnp); | 1244 | pvr2_channel_init(&vp->channel,mnp); |
| 1213 | pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr2_v4l2 id=%p",vp); | 1245 | pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr2_v4l2 id=%p",vp); |
| 1214 | 1246 | ||
| 1215 | vp->channel.check_func = pvr2_v4l2_internal_check; | 1247 | vp->channel.check_func = pvr2_v4l2_internal_check; |
| 1216 | 1248 | ||
| 1217 | /* register streams */ | 1249 | /* register streams */ |
| 1250 | vp->dev_video = kzalloc(sizeof(*vp->dev_video),GFP_KERNEL); | ||
| 1251 | if (!vp->dev_video) goto fail; | ||
| 1218 | pvr2_v4l2_dev_init(vp->dev_video,vp,VFL_TYPE_GRABBER); | 1252 | pvr2_v4l2_dev_init(vp->dev_video,vp,VFL_TYPE_GRABBER); |
| 1219 | pvr2_v4l2_dev_init(vp->dev_radio,vp,VFL_TYPE_RADIO); | 1253 | if (pvr2_hdw_get_input_available(vp->channel.mc_head->hdw) & |
| 1254 | (1 << PVR2_CVAL_INPUT_RADIO)) { | ||
| 1255 | vp->dev_radio = kzalloc(sizeof(*vp->dev_radio),GFP_KERNEL); | ||
| 1256 | if (!vp->dev_radio) goto fail; | ||
| 1257 | pvr2_v4l2_dev_init(vp->dev_radio,vp,VFL_TYPE_RADIO); | ||
| 1258 | } | ||
| 1220 | 1259 | ||
| 1221 | return vp; | 1260 | return vp; |
| 1261 | fail: | ||
| 1262 | pvr2_trace(PVR2_TRACE_STRUCT,"Failure creating pvr2_v4l2 id=%p",vp); | ||
| 1263 | pvr2_v4l2_destroy_no_lock(vp); | ||
| 1264 | return 0; | ||
| 1222 | } | 1265 | } |
| 1223 | 1266 | ||
| 1224 | /* | 1267 | /* |
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c index e0a453a6543d..423fa7c2d0c9 100644 --- a/drivers/media/video/pwc/pwc-if.c +++ b/drivers/media/video/pwc/pwc-if.c | |||
| @@ -130,8 +130,8 @@ static int default_fbufs = 3; /* Default number of frame buffers */ | |||
| 130 | #ifdef CONFIG_USB_PWC_DEBUG | 130 | #ifdef CONFIG_USB_PWC_DEBUG |
| 131 | int pwc_trace = PWC_DEBUG_LEVEL; | 131 | int pwc_trace = PWC_DEBUG_LEVEL; |
| 132 | #endif | 132 | #endif |
| 133 | static int power_save = 0; | 133 | static int power_save; |
| 134 | static int led_on = 100, led_off = 0; /* defaults to LED that is on while in use */ | 134 | static int led_on = 100, led_off; /* defaults to LED that is on while in use */ |
| 135 | static int pwc_preferred_compression = 1; /* 0..3 = uncompressed..high */ | 135 | static int pwc_preferred_compression = 1; /* 0..3 = uncompressed..high */ |
| 136 | static struct { | 136 | static struct { |
| 137 | int type; | 137 | int type; |
| @@ -159,7 +159,9 @@ static const struct file_operations pwc_fops = { | |||
| 159 | .poll = pwc_video_poll, | 159 | .poll = pwc_video_poll, |
| 160 | .mmap = pwc_video_mmap, | 160 | .mmap = pwc_video_mmap, |
| 161 | .ioctl = pwc_video_ioctl, | 161 | .ioctl = pwc_video_ioctl, |
| 162 | #ifdef CONFIG_COMPAT | ||
| 162 | .compat_ioctl = v4l_compat_ioctl32, | 163 | .compat_ioctl = v4l_compat_ioctl32, |
| 164 | #endif | ||
| 163 | .llseek = no_llseek, | 165 | .llseek = no_llseek, |
| 164 | }; | 166 | }; |
| 165 | static struct video_device pwc_template = { | 167 | static struct video_device pwc_template = { |
| @@ -487,7 +489,7 @@ static void pwc_reset_buffers(struct pwc_device *pdev) | |||
| 487 | int i; | 489 | int i; |
| 488 | unsigned long flags; | 490 | unsigned long flags; |
| 489 | 491 | ||
| 490 | PWC_DEBUG_MEMORY(">> %s __enter__\n", __FUNCTION__); | 492 | PWC_DEBUG_MEMORY(">> %s __enter__\n", __func__); |
| 491 | 493 | ||
| 492 | spin_lock_irqsave(&pdev->ptrlock, flags); | 494 | spin_lock_irqsave(&pdev->ptrlock, flags); |
| 493 | pdev->full_frames = NULL; | 495 | pdev->full_frames = NULL; |
| @@ -509,7 +511,7 @@ static void pwc_reset_buffers(struct pwc_device *pdev) | |||
| 509 | pdev->fill_image = 0; | 511 | pdev->fill_image = 0; |
| 510 | spin_unlock_irqrestore(&pdev->ptrlock, flags); | 512 | spin_unlock_irqrestore(&pdev->ptrlock, flags); |
| 511 | 513 | ||
| 512 | PWC_DEBUG_MEMORY("<< %s __leaving__\n", __FUNCTION__); | 514 | PWC_DEBUG_MEMORY("<< %s __leaving__\n", __func__); |
| 513 | } | 515 | } |
| 514 | 516 | ||
| 515 | 517 | ||
| @@ -786,8 +788,8 @@ static void pwc_isoc_handler(struct urb *urb) | |||
| 786 | } /* ..status == 0 */ | 788 | } /* ..status == 0 */ |
| 787 | else { | 789 | else { |
| 788 | /* This is normally not interesting to the user, unless | 790 | /* This is normally not interesting to the user, unless |
| 789 | * you are really debugging something */ | 791 | * you are really debugging something, default = 0 */ |
| 790 | static int iso_error = 0; | 792 | static int iso_error; |
| 791 | iso_error++; | 793 | iso_error++; |
| 792 | if (iso_error < 20) | 794 | if (iso_error < 20) |
| 793 | PWC_DEBUG_FLOW("Iso frame %d of USB has error %d\n", i, fst); | 795 | PWC_DEBUG_FLOW("Iso frame %d of USB has error %d\n", i, fst); |
| @@ -1426,7 +1428,7 @@ static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma) | |||
| 1426 | unsigned long page, pos = 0; | 1428 | unsigned long page, pos = 0; |
| 1427 | int index; | 1429 | int index; |
| 1428 | 1430 | ||
| 1429 | PWC_DEBUG_MEMORY(">> %s\n", __FUNCTION__); | 1431 | PWC_DEBUG_MEMORY(">> %s\n", __func__); |
| 1430 | pdev = vdev->priv; | 1432 | pdev = vdev->priv; |
| 1431 | size = vma->vm_end - vma->vm_start; | 1433 | size = vma->vm_end - vma->vm_start; |
| 1432 | start = vma->vm_start; | 1434 | start = vma->vm_start; |
diff --git a/drivers/media/video/pwc/pwc-v4l.c b/drivers/media/video/pwc/pwc-v4l.c index 32fbe1ae6251..1742889874df 100644 --- a/drivers/media/video/pwc/pwc-v4l.c +++ b/drivers/media/video/pwc/pwc-v4l.c | |||
| @@ -351,8 +351,10 @@ int pwc_video_do_ioctl(struct inode *inode, struct file *file, | |||
| 351 | return -EFAULT; | 351 | return -EFAULT; |
| 352 | 352 | ||
| 353 | #ifdef CONFIG_USB_PWC_DEBUG | 353 | #ifdef CONFIG_USB_PWC_DEBUG |
| 354 | if (PWC_DEBUG_LEVEL_IOCTL & pwc_trace) | 354 | if (PWC_DEBUG_LEVEL_IOCTL & pwc_trace) { |
| 355 | v4l_printk_ioctl(cmd); | 355 | v4l_printk_ioctl(cmd); |
| 356 | printk("\n"); | ||
| 357 | } | ||
| 356 | #endif | 358 | #endif |
| 357 | 359 | ||
| 358 | 360 | ||
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c new file mode 100644 index 000000000000..7cc8e9b19fb7 --- /dev/null +++ b/drivers/media/video/pxa_camera.c | |||
| @@ -0,0 +1,1206 @@ | |||
| 1 | /* | ||
| 2 | * V4L2 Driver for PXA camera host | ||
| 3 | * | ||
| 4 | * Copyright (C) 2006, Sascha Hauer, Pengutronix | ||
| 5 | * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License as published by | ||
| 9 | * the Free Software Foundation; either version 2 of the License, or | ||
| 10 | * (at your option) any later version. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/init.h> | ||
| 14 | #include <linux/module.h> | ||
| 15 | #include <linux/io.h> | ||
| 16 | #include <linux/delay.h> | ||
| 17 | #include <linux/dma-mapping.h> | ||
| 18 | #include <linux/errno.h> | ||
| 19 | #include <linux/fs.h> | ||
| 20 | #include <linux/interrupt.h> | ||
| 21 | #include <linux/kernel.h> | ||
| 22 | #include <linux/mm.h> | ||
| 23 | #include <linux/moduleparam.h> | ||
| 24 | #include <linux/time.h> | ||
| 25 | #include <linux/version.h> | ||
| 26 | #include <linux/device.h> | ||
| 27 | #include <linux/platform_device.h> | ||
| 28 | #include <linux/mutex.h> | ||
| 29 | #include <linux/clk.h> | ||
| 30 | |||
| 31 | #include <media/v4l2-common.h> | ||
| 32 | #include <media/v4l2-dev.h> | ||
| 33 | #include <media/soc_camera.h> | ||
| 34 | |||
| 35 | #include <linux/videodev2.h> | ||
| 36 | |||
| 37 | #include <asm/dma.h> | ||
| 38 | #include <asm/arch/pxa-regs.h> | ||
| 39 | #include <asm/arch/camera.h> | ||
| 40 | |||
| 41 | #define PXA_CAM_VERSION_CODE KERNEL_VERSION(0, 0, 5) | ||
| 42 | #define PXA_CAM_DRV_NAME "pxa27x-camera" | ||
| 43 | |||
| 44 | #define CICR0_SIM_MP (0 << 24) | ||
| 45 | #define CICR0_SIM_SP (1 << 24) | ||
| 46 | #define CICR0_SIM_MS (2 << 24) | ||
| 47 | #define CICR0_SIM_EP (3 << 24) | ||
| 48 | #define CICR0_SIM_ES (4 << 24) | ||
| 49 | |||
| 50 | #define CICR1_DW_VAL(x) ((x) & CICR1_DW) /* Data bus width */ | ||
| 51 | #define CICR1_PPL_VAL(x) (((x) << 15) & CICR1_PPL) /* Pixels per line */ | ||
| 52 | #define CICR1_COLOR_SP_VAL(x) (((x) << 3) & CICR1_COLOR_SP) /* color space */ | ||
| 53 | #define CICR1_RGB_BPP_VAL(x) (((x) << 7) & CICR1_RGB_BPP) /* bpp for rgb */ | ||
| 54 | #define CICR1_RGBT_CONV_VAL(x) (((x) << 29) & CICR1_RGBT_CONV) /* rgbt conv */ | ||
| 55 | |||
| 56 | #define CICR2_BLW_VAL(x) (((x) << 24) & CICR2_BLW) /* Beginning-of-line pixel clock wait count */ | ||
| 57 | #define CICR2_ELW_VAL(x) (((x) << 16) & CICR2_ELW) /* End-of-line pixel clock wait count */ | ||
| 58 | #define CICR2_HSW_VAL(x) (((x) << 10) & CICR2_HSW) /* Horizontal sync pulse width */ | ||
| 59 | #define CICR2_BFPW_VAL(x) (((x) << 3) & CICR2_BFPW) /* Beginning-of-frame pixel clock wait count */ | ||
| 60 | #define CICR2_FSW_VAL(x) (((x) << 0) & CICR2_FSW) /* Frame stabilization wait count */ | ||
| 61 | |||
| 62 | #define CICR3_BFW_VAL(x) (((x) << 24) & CICR3_BFW) /* Beginning-of-frame line clock wait count */ | ||
| 63 | #define CICR3_EFW_VAL(x) (((x) << 16) & CICR3_EFW) /* End-of-frame line clock wait count */ | ||
| 64 | #define CICR3_VSW_VAL(x) (((x) << 11) & CICR3_VSW) /* Vertical sync pulse width */ | ||
| 65 | #define CICR3_LPF_VAL(x) (((x) << 0) & CICR3_LPF) /* Lines per frame */ | ||
| 66 | |||
| 67 | #define CICR0_IRQ_MASK (CICR0_TOM | CICR0_RDAVM | CICR0_FEM | CICR0_EOLM | \ | ||
| 68 | CICR0_PERRM | CICR0_QDM | CICR0_CDM | CICR0_SOFM | \ | ||
| 69 | CICR0_EOFM | CICR0_FOM) | ||
| 70 | |||
| 71 | static DEFINE_MUTEX(camera_lock); | ||
| 72 | |||
| 73 | /* | ||
| 74 | * Structures | ||
| 75 | */ | ||
| 76 | enum pxa_camera_active_dma { | ||
| 77 | DMA_Y = 0x1, | ||
| 78 | DMA_U = 0x2, | ||
| 79 | DMA_V = 0x4, | ||
| 80 | }; | ||
| 81 | |||
| 82 | /* descriptor needed for the PXA DMA engine */ | ||
| 83 | struct pxa_cam_dma { | ||
| 84 | dma_addr_t sg_dma; | ||
| 85 | struct pxa_dma_desc *sg_cpu; | ||
| 86 | size_t sg_size; | ||
| 87 | int sglen; | ||
| 88 | }; | ||
| 89 | |||
| 90 | /* buffer for one video frame */ | ||
| 91 | struct pxa_buffer { | ||
| 92 | /* common v4l buffer stuff -- must be first */ | ||
| 93 | struct videobuf_buffer vb; | ||
| 94 | |||
| 95 | const struct soc_camera_data_format *fmt; | ||
| 96 | |||
| 97 | /* our descriptor lists for Y, U and V channels */ | ||
| 98 | struct pxa_cam_dma dmas[3]; | ||
| 99 | |||
| 100 | int inwork; | ||
| 101 | |||
| 102 | enum pxa_camera_active_dma active_dma; | ||
| 103 | }; | ||
| 104 | |||
| 105 | struct pxa_camera_dev { | ||
| 106 | struct device *dev; | ||
| 107 | /* PXA27x is only supposed to handle one camera on its Quick Capture | ||
| 108 | * interface. If anyone ever builds hardware to enable more than | ||
| 109 | * one camera, they will have to modify this driver too */ | ||
| 110 | struct soc_camera_device *icd; | ||
| 111 | struct clk *clk; | ||
| 112 | |||
| 113 | unsigned int irq; | ||
| 114 | void __iomem *base; | ||
| 115 | |||
| 116 | int channels; | ||
| 117 | unsigned int dma_chans[3]; | ||
| 118 | |||
| 119 | struct pxacamera_platform_data *pdata; | ||
| 120 | struct resource *res; | ||
| 121 | unsigned long platform_flags; | ||
| 122 | unsigned long platform_mclk_10khz; | ||
| 123 | |||
| 124 | struct list_head capture; | ||
| 125 | |||
| 126 | spinlock_t lock; | ||
| 127 | |||
| 128 | struct pxa_buffer *active; | ||
| 129 | struct pxa_dma_desc *sg_tail[3]; | ||
| 130 | }; | ||
| 131 | |||
| 132 | static const char *pxa_cam_driver_description = "PXA_Camera"; | ||
| 133 | |||
| 134 | static unsigned int vid_limit = 16; /* Video memory limit, in Mb */ | ||
| 135 | |||
| 136 | /* | ||
| 137 | * Videobuf operations | ||
| 138 | */ | ||
| 139 | static int pxa_videobuf_setup(struct videobuf_queue *vq, unsigned int *count, | ||
| 140 | unsigned int *size) | ||
| 141 | { | ||
| 142 | struct soc_camera_device *icd = vq->priv_data; | ||
| 143 | struct soc_camera_host *ici = | ||
| 144 | to_soc_camera_host(icd->dev.parent); | ||
| 145 | struct pxa_camera_dev *pcdev = ici->priv; | ||
| 146 | |||
| 147 | dev_dbg(&icd->dev, "count=%d, size=%d\n", *count, *size); | ||
| 148 | |||
| 149 | /* planar capture requires Y, U and V buffers to be page aligned */ | ||
| 150 | if (pcdev->channels == 3) { | ||
| 151 | *size = PAGE_ALIGN(icd->width * icd->height); /* Y pages */ | ||
| 152 | *size += PAGE_ALIGN(icd->width * icd->height / 2); /* U pages */ | ||
| 153 | *size += PAGE_ALIGN(icd->width * icd->height / 2); /* V pages */ | ||
| 154 | } else { | ||
| 155 | *size = icd->width * icd->height * | ||
| 156 | ((icd->current_fmt->depth + 7) >> 3); | ||
| 157 | } | ||
| 158 | |||
| 159 | if (0 == *count) | ||
| 160 | *count = 32; | ||
| 161 | while (*size * *count > vid_limit * 1024 * 1024) | ||
| 162 | (*count)--; | ||
| 163 | |||
| 164 | return 0; | ||
| 165 | } | ||
| 166 | |||
| 167 | static void free_buffer(struct videobuf_queue *vq, struct pxa_buffer *buf) | ||
| 168 | { | ||
| 169 | struct soc_camera_device *icd = vq->priv_data; | ||
| 170 | struct soc_camera_host *ici = | ||
| 171 | to_soc_camera_host(icd->dev.parent); | ||
| 172 | struct pxa_camera_dev *pcdev = ici->priv; | ||
| 173 | struct videobuf_dmabuf *dma = videobuf_to_dma(&buf->vb); | ||
| 174 | int i; | ||
| 175 | |||
| 176 | BUG_ON(in_interrupt()); | ||
| 177 | |||
| 178 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | ||
| 179 | &buf->vb, buf->vb.baddr, buf->vb.bsize); | ||
| 180 | |||
| 181 | /* This waits until this buffer is out of danger, i.e., until it is no | ||
| 182 | * longer in STATE_QUEUED or STATE_ACTIVE */ | ||
| 183 | videobuf_waiton(&buf->vb, 0, 0); | ||
| 184 | videobuf_dma_unmap(vq, dma); | ||
| 185 | videobuf_dma_free(dma); | ||
| 186 | |||
| 187 | for (i = 0; i < ARRAY_SIZE(buf->dmas); i++) { | ||
| 188 | if (buf->dmas[i].sg_cpu) | ||
| 189 | dma_free_coherent(pcdev->dev, buf->dmas[i].sg_size, | ||
| 190 | buf->dmas[i].sg_cpu, | ||
| 191 | buf->dmas[i].sg_dma); | ||
| 192 | buf->dmas[i].sg_cpu = NULL; | ||
| 193 | } | ||
| 194 | |||
| 195 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | ||
| 196 | } | ||
| 197 | |||
| 198 | static int pxa_init_dma_channel(struct pxa_camera_dev *pcdev, | ||
| 199 | struct pxa_buffer *buf, | ||
| 200 | struct videobuf_dmabuf *dma, int channel, | ||
| 201 | int sglen, int sg_start, int cibr, | ||
| 202 | unsigned int size) | ||
| 203 | { | ||
| 204 | struct pxa_cam_dma *pxa_dma = &buf->dmas[channel]; | ||
| 205 | int i; | ||
| 206 | |||
| 207 | if (pxa_dma->sg_cpu) | ||
| 208 | dma_free_coherent(pcdev->dev, pxa_dma->sg_size, | ||
| 209 | pxa_dma->sg_cpu, pxa_dma->sg_dma); | ||
| 210 | |||
| 211 | pxa_dma->sg_size = (sglen + 1) * sizeof(struct pxa_dma_desc); | ||
| 212 | pxa_dma->sg_cpu = dma_alloc_coherent(pcdev->dev, pxa_dma->sg_size, | ||
| 213 | &pxa_dma->sg_dma, GFP_KERNEL); | ||
| 214 | if (!pxa_dma->sg_cpu) | ||
| 215 | return -ENOMEM; | ||
| 216 | |||
| 217 | pxa_dma->sglen = sglen; | ||
| 218 | |||
| 219 | for (i = 0; i < sglen; i++) { | ||
| 220 | int sg_i = sg_start + i; | ||
| 221 | struct scatterlist *sg = dma->sglist; | ||
| 222 | unsigned int dma_len = sg_dma_len(&sg[sg_i]), xfer_len; | ||
| 223 | |||
| 224 | pxa_dma->sg_cpu[i].dsadr = pcdev->res->start + cibr; | ||
| 225 | pxa_dma->sg_cpu[i].dtadr = sg_dma_address(&sg[sg_i]); | ||
| 226 | |||
| 227 | /* PXA27x Developer's Manual 27.4.4.1: round up to 8 bytes */ | ||
| 228 | xfer_len = (min(dma_len, size) + 7) & ~7; | ||
| 229 | |||
| 230 | pxa_dma->sg_cpu[i].dcmd = | ||
| 231 | DCMD_FLOWSRC | DCMD_BURST8 | DCMD_INCTRGADDR | xfer_len; | ||
| 232 | size -= dma_len; | ||
| 233 | pxa_dma->sg_cpu[i].ddadr = | ||
| 234 | pxa_dma->sg_dma + (i + 1) * sizeof(struct pxa_dma_desc); | ||
| 235 | } | ||
| 236 | |||
| 237 | pxa_dma->sg_cpu[sglen - 1].ddadr = DDADR_STOP; | ||
| 238 | pxa_dma->sg_cpu[sglen - 1].dcmd |= DCMD_ENDIRQEN; | ||
| 239 | |||
| 240 | return 0; | ||
| 241 | } | ||
| 242 | |||
| 243 | static int pxa_videobuf_prepare(struct videobuf_queue *vq, | ||
| 244 | struct videobuf_buffer *vb, enum v4l2_field field) | ||
| 245 | { | ||
| 246 | struct soc_camera_device *icd = vq->priv_data; | ||
| 247 | struct soc_camera_host *ici = | ||
| 248 | to_soc_camera_host(icd->dev.parent); | ||
| 249 | struct pxa_camera_dev *pcdev = ici->priv; | ||
| 250 | struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); | ||
| 251 | int ret; | ||
| 252 | int sglen_y, sglen_yu = 0, sglen_u = 0, sglen_v = 0; | ||
| 253 | int size_y, size_u = 0, size_v = 0; | ||
| 254 | |||
| 255 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | ||
| 256 | vb, vb->baddr, vb->bsize); | ||
| 257 | |||
| 258 | /* Added list head initialization on alloc */ | ||
| 259 | WARN_ON(!list_empty(&vb->queue)); | ||
| 260 | |||
| 261 | #ifdef DEBUG | ||
| 262 | /* This can be useful if you want to see if we actually fill | ||
| 263 | * the buffer with something */ | ||
| 264 | memset((void *)vb->baddr, 0xaa, vb->bsize); | ||
| 265 | #endif | ||
| 266 | |||
| 267 | BUG_ON(NULL == icd->current_fmt); | ||
| 268 | |||
| 269 | /* I think, in buf_prepare you only have to protect global data, | ||
| 270 | * the actual buffer is yours */ | ||
| 271 | buf->inwork = 1; | ||
| 272 | |||
| 273 | if (buf->fmt != icd->current_fmt || | ||
| 274 | vb->width != icd->width || | ||
| 275 | vb->height != icd->height || | ||
| 276 | vb->field != field) { | ||
| 277 | buf->fmt = icd->current_fmt; | ||
| 278 | vb->width = icd->width; | ||
| 279 | vb->height = icd->height; | ||
| 280 | vb->field = field; | ||
| 281 | vb->state = VIDEOBUF_NEEDS_INIT; | ||
| 282 | } | ||
| 283 | |||
| 284 | vb->size = vb->width * vb->height * ((buf->fmt->depth + 7) >> 3); | ||
| 285 | if (0 != vb->baddr && vb->bsize < vb->size) { | ||
| 286 | ret = -EINVAL; | ||
| 287 | goto out; | ||
| 288 | } | ||
| 289 | |||
| 290 | if (vb->state == VIDEOBUF_NEEDS_INIT) { | ||
| 291 | unsigned int size = vb->size; | ||
| 292 | struct videobuf_dmabuf *dma = videobuf_to_dma(vb); | ||
| 293 | |||
| 294 | ret = videobuf_iolock(vq, vb, NULL); | ||
| 295 | if (ret) | ||
| 296 | goto fail; | ||
| 297 | |||
| 298 | if (pcdev->channels == 3) { | ||
| 299 | /* FIXME the calculations should be more precise */ | ||
| 300 | sglen_y = dma->sglen / 2; | ||
| 301 | sglen_u = sglen_v = dma->sglen / 4 + 1; | ||
| 302 | sglen_yu = sglen_y + sglen_u; | ||
| 303 | size_y = size / 2; | ||
| 304 | size_u = size_v = size / 4; | ||
| 305 | } else { | ||
| 306 | sglen_y = dma->sglen; | ||
| 307 | size_y = size; | ||
| 308 | } | ||
| 309 | |||
| 310 | /* init DMA for Y channel */ | ||
| 311 | ret = pxa_init_dma_channel(pcdev, buf, dma, 0, sglen_y, | ||
| 312 | 0, 0x28, size_y); | ||
| 313 | |||
| 314 | if (ret) { | ||
| 315 | dev_err(pcdev->dev, | ||
| 316 | "DMA initialization for Y/RGB failed\n"); | ||
| 317 | goto fail; | ||
| 318 | } | ||
| 319 | |||
| 320 | if (pcdev->channels == 3) { | ||
| 321 | /* init DMA for U channel */ | ||
| 322 | ret = pxa_init_dma_channel(pcdev, buf, dma, 1, sglen_u, | ||
| 323 | sglen_y, 0x30, size_u); | ||
| 324 | if (ret) { | ||
| 325 | dev_err(pcdev->dev, | ||
| 326 | "DMA initialization for U failed\n"); | ||
| 327 | goto fail_u; | ||
| 328 | } | ||
| 329 | |||
| 330 | /* init DMA for V channel */ | ||
| 331 | ret = pxa_init_dma_channel(pcdev, buf, dma, 2, sglen_v, | ||
| 332 | sglen_yu, 0x38, size_v); | ||
| 333 | if (ret) { | ||
| 334 | dev_err(pcdev->dev, | ||
| 335 | "DMA initialization for V failed\n"); | ||
| 336 | goto fail_v; | ||
| 337 | } | ||
| 338 | } | ||
| 339 | |||
| 340 | vb->state = VIDEOBUF_PREPARED; | ||
| 341 | } | ||
| 342 | |||
| 343 | buf->inwork = 0; | ||
| 344 | buf->active_dma = DMA_Y; | ||
| 345 | if (pcdev->channels == 3) | ||
| 346 | buf->active_dma |= DMA_U | DMA_V; | ||
| 347 | |||
| 348 | return 0; | ||
| 349 | |||
| 350 | fail_v: | ||
| 351 | dma_free_coherent(pcdev->dev, buf->dmas[1].sg_size, | ||
| 352 | buf->dmas[1].sg_cpu, buf->dmas[1].sg_dma); | ||
| 353 | fail_u: | ||
| 354 | dma_free_coherent(pcdev->dev, buf->dmas[0].sg_size, | ||
| 355 | buf->dmas[0].sg_cpu, buf->dmas[0].sg_dma); | ||
| 356 | fail: | ||
| 357 | free_buffer(vq, buf); | ||
| 358 | out: | ||
| 359 | buf->inwork = 0; | ||
| 360 | return ret; | ||
| 361 | } | ||
| 362 | |||
| 363 | static void pxa_videobuf_queue(struct videobuf_queue *vq, | ||
| 364 | struct videobuf_buffer *vb) | ||
| 365 | { | ||
| 366 | struct soc_camera_device *icd = vq->priv_data; | ||
| 367 | struct soc_camera_host *ici = | ||
| 368 | to_soc_camera_host(icd->dev.parent); | ||
| 369 | struct pxa_camera_dev *pcdev = ici->priv; | ||
| 370 | struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); | ||
| 371 | struct pxa_buffer *active; | ||
| 372 | unsigned long flags; | ||
| 373 | int i; | ||
| 374 | |||
| 375 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | ||
| 376 | vb, vb->baddr, vb->bsize); | ||
| 377 | spin_lock_irqsave(&pcdev->lock, flags); | ||
| 378 | |||
| 379 | list_add_tail(&vb->queue, &pcdev->capture); | ||
| 380 | |||
| 381 | vb->state = VIDEOBUF_ACTIVE; | ||
| 382 | active = pcdev->active; | ||
| 383 | |||
| 384 | if (!active) { | ||
| 385 | CIFR |= CIFR_RESET_F; | ||
| 386 | |||
| 387 | for (i = 0; i < pcdev->channels; i++) { | ||
| 388 | DDADR(pcdev->dma_chans[i]) = buf->dmas[i].sg_dma; | ||
| 389 | DCSR(pcdev->dma_chans[i]) = DCSR_RUN; | ||
| 390 | pcdev->sg_tail[i] = buf->dmas[i].sg_cpu + buf->dmas[i].sglen - 1; | ||
| 391 | } | ||
| 392 | |||
| 393 | pcdev->active = buf; | ||
| 394 | CICR0 |= CICR0_ENB; | ||
| 395 | } else { | ||
| 396 | struct pxa_cam_dma *buf_dma; | ||
| 397 | struct pxa_cam_dma *act_dma; | ||
| 398 | int nents; | ||
| 399 | |||
| 400 | for (i = 0; i < pcdev->channels; i++) { | ||
| 401 | buf_dma = &buf->dmas[i]; | ||
| 402 | act_dma = &active->dmas[i]; | ||
| 403 | nents = buf_dma->sglen; | ||
| 404 | |||
| 405 | /* Stop DMA engine */ | ||
| 406 | DCSR(pcdev->dma_chans[i]) = 0; | ||
| 407 | |||
| 408 | /* Add the descriptors we just initialized to | ||
| 409 | the currently running chain */ | ||
| 410 | pcdev->sg_tail[i]->ddadr = buf_dma->sg_dma; | ||
| 411 | pcdev->sg_tail[i] = buf_dma->sg_cpu + buf_dma->sglen - 1; | ||
| 412 | |||
| 413 | /* Setup a dummy descriptor with the DMA engines current | ||
| 414 | * state | ||
| 415 | */ | ||
| 416 | buf_dma->sg_cpu[nents].dsadr = | ||
| 417 | pcdev->res->start + 0x28 + i*8; /* CIBRx */ | ||
| 418 | buf_dma->sg_cpu[nents].dtadr = | ||
| 419 | DTADR(pcdev->dma_chans[i]); | ||
| 420 | buf_dma->sg_cpu[nents].dcmd = | ||
| 421 | DCMD(pcdev->dma_chans[i]); | ||
| 422 | |||
| 423 | if (DDADR(pcdev->dma_chans[i]) == DDADR_STOP) { | ||
| 424 | /* The DMA engine is on the last | ||
| 425 | descriptor, set the next descriptors | ||
| 426 | address to the descriptors we just | ||
| 427 | initialized */ | ||
| 428 | buf_dma->sg_cpu[nents].ddadr = buf_dma->sg_dma; | ||
| 429 | } else { | ||
| 430 | buf_dma->sg_cpu[nents].ddadr = | ||
| 431 | DDADR(pcdev->dma_chans[i]); | ||
| 432 | } | ||
| 433 | |||
| 434 | /* The next descriptor is the dummy descriptor */ | ||
| 435 | DDADR(pcdev->dma_chans[i]) = buf_dma->sg_dma + nents * | ||
| 436 | sizeof(struct pxa_dma_desc); | ||
| 437 | |||
| 438 | DCSR(pcdev->dma_chans[i]) = DCSR_RUN; | ||
| 439 | } | ||
| 440 | } | ||
| 441 | |||
| 442 | spin_unlock_irqrestore(&pcdev->lock, flags); | ||
| 443 | } | ||
| 444 | |||
| 445 | static void pxa_videobuf_release(struct videobuf_queue *vq, | ||
| 446 | struct videobuf_buffer *vb) | ||
| 447 | { | ||
| 448 | struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); | ||
| 449 | #ifdef DEBUG | ||
| 450 | struct soc_camera_device *icd = vq->priv_data; | ||
| 451 | |||
| 452 | dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | ||
| 453 | vb, vb->baddr, vb->bsize); | ||
| 454 | |||
| 455 | switch (vb->state) { | ||
| 456 | case VIDEOBUF_ACTIVE: | ||
| 457 | dev_dbg(&icd->dev, "%s (active)\n", __func__); | ||
| 458 | break; | ||
| 459 | case VIDEOBUF_QUEUED: | ||
| 460 | dev_dbg(&icd->dev, "%s (queued)\n", __func__); | ||
| 461 | break; | ||
| 462 | case VIDEOBUF_PREPARED: | ||
| 463 | dev_dbg(&icd->dev, "%s (prepared)\n", __func__); | ||
| 464 | break; | ||
| 465 | default: | ||
| 466 | dev_dbg(&icd->dev, "%s (unknown)\n", __func__); | ||
| 467 | break; | ||
| 468 | } | ||
| 469 | #endif | ||
| 470 | |||
| 471 | free_buffer(vq, buf); | ||
| 472 | } | ||
| 473 | |||
| 474 | static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev, | ||
| 475 | struct videobuf_buffer *vb, | ||
| 476 | struct pxa_buffer *buf) | ||
| 477 | { | ||
| 478 | /* _init is used to debug races, see comment in pxa_camera_reqbufs() */ | ||
| 479 | list_del_init(&vb->queue); | ||
| 480 | vb->state = VIDEOBUF_DONE; | ||
| 481 | do_gettimeofday(&vb->ts); | ||
| 482 | vb->field_count++; | ||
| 483 | wake_up(&vb->done); | ||
| 484 | |||
| 485 | if (list_empty(&pcdev->capture)) { | ||
| 486 | pcdev->active = NULL; | ||
| 487 | DCSR(pcdev->dma_chans[0]) = 0; | ||
| 488 | DCSR(pcdev->dma_chans[1]) = 0; | ||
| 489 | DCSR(pcdev->dma_chans[2]) = 0; | ||
| 490 | CICR0 &= ~CICR0_ENB; | ||
| 491 | return; | ||
| 492 | } | ||
| 493 | |||
| 494 | pcdev->active = list_entry(pcdev->capture.next, | ||
| 495 | struct pxa_buffer, vb.queue); | ||
| 496 | } | ||
| 497 | |||
| 498 | static void pxa_camera_dma_irq(int channel, struct pxa_camera_dev *pcdev, | ||
| 499 | enum pxa_camera_active_dma act_dma) | ||
| 500 | { | ||
| 501 | struct pxa_buffer *buf; | ||
| 502 | unsigned long flags; | ||
| 503 | u32 status, camera_status, overrun; | ||
| 504 | struct videobuf_buffer *vb; | ||
| 505 | |||
| 506 | spin_lock_irqsave(&pcdev->lock, flags); | ||
| 507 | |||
| 508 | status = DCSR(channel); | ||
| 509 | DCSR(channel) = status | DCSR_ENDINTR; | ||
| 510 | |||
| 511 | if (status & DCSR_BUSERR) { | ||
| 512 | dev_err(pcdev->dev, "DMA Bus Error IRQ!\n"); | ||
| 513 | goto out; | ||
| 514 | } | ||
| 515 | |||
| 516 | if (!(status & DCSR_ENDINTR)) { | ||
| 517 | dev_err(pcdev->dev, "Unknown DMA IRQ source, " | ||
| 518 | "status: 0x%08x\n", status); | ||
| 519 | goto out; | ||
| 520 | } | ||
| 521 | |||
| 522 | if (!pcdev->active) { | ||
| 523 | dev_err(pcdev->dev, "DMA End IRQ with no active buffer!\n"); | ||
| 524 | goto out; | ||
| 525 | } | ||
| 526 | |||
| 527 | camera_status = CISR; | ||
| 528 | overrun = CISR_IFO_0; | ||
| 529 | if (pcdev->channels == 3) | ||
| 530 | overrun |= CISR_IFO_1 | CISR_IFO_2; | ||
| 531 | if (camera_status & overrun) { | ||
| 532 | dev_dbg(pcdev->dev, "FIFO overrun! CISR: %x\n", camera_status); | ||
| 533 | /* Stop the Capture Interface */ | ||
| 534 | CICR0 &= ~CICR0_ENB; | ||
| 535 | /* Stop DMA */ | ||
| 536 | DCSR(channel) = 0; | ||
| 537 | /* Reset the FIFOs */ | ||
| 538 | CIFR |= CIFR_RESET_F; | ||
| 539 | /* Enable End-Of-Frame Interrupt */ | ||
| 540 | CICR0 &= ~CICR0_EOFM; | ||
| 541 | /* Restart the Capture Interface */ | ||
| 542 | CICR0 |= CICR0_ENB; | ||
| 543 | goto out; | ||
| 544 | } | ||
| 545 | |||
| 546 | vb = &pcdev->active->vb; | ||
| 547 | buf = container_of(vb, struct pxa_buffer, vb); | ||
| 548 | WARN_ON(buf->inwork || list_empty(&vb->queue)); | ||
| 549 | dev_dbg(pcdev->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, | ||
| 550 | vb, vb->baddr, vb->bsize); | ||
| 551 | |||
| 552 | buf->active_dma &= ~act_dma; | ||
| 553 | if (!buf->active_dma) | ||
| 554 | pxa_camera_wakeup(pcdev, vb, buf); | ||
| 555 | |||
| 556 | out: | ||
| 557 | spin_unlock_irqrestore(&pcdev->lock, flags); | ||
| 558 | } | ||
| 559 | |||
| 560 | static void pxa_camera_dma_irq_y(int channel, void *data) | ||
| 561 | { | ||
| 562 | struct pxa_camera_dev *pcdev = data; | ||
| 563 | pxa_camera_dma_irq(channel, pcdev, DMA_Y); | ||
| 564 | } | ||
| 565 | |||
| 566 | static void pxa_camera_dma_irq_u(int channel, void *data) | ||
| 567 | { | ||
| 568 | struct pxa_camera_dev *pcdev = data; | ||
| 569 | pxa_camera_dma_irq(channel, pcdev, DMA_U); | ||
| 570 | } | ||
| 571 | |||
| 572 | static void pxa_camera_dma_irq_v(int channel, void *data) | ||
| 573 | { | ||
| 574 | struct pxa_camera_dev *pcdev = data; | ||
| 575 | pxa_camera_dma_irq(channel, pcdev, DMA_V); | ||
| 576 | } | ||
| 577 | |||
| 578 | static struct videobuf_queue_ops pxa_videobuf_ops = { | ||
| 579 | .buf_setup = pxa_videobuf_setup, | ||
| 580 | .buf_prepare = pxa_videobuf_prepare, | ||
| 581 | .buf_queue = pxa_videobuf_queue, | ||
| 582 | .buf_release = pxa_videobuf_release, | ||
| 583 | }; | ||
| 584 | |||
| 585 | static int mclk_get_divisor(struct pxa_camera_dev *pcdev) | ||
| 586 | { | ||
| 587 | unsigned int mclk_10khz = pcdev->platform_mclk_10khz; | ||
| 588 | unsigned long div; | ||
| 589 | unsigned long lcdclk; | ||
| 590 | |||
| 591 | lcdclk = clk_get_rate(pcdev->clk) / 10000; | ||
| 592 | |||
| 593 | /* We verify platform_mclk_10khz != 0, so if anyone breaks it, here | ||
| 594 | * they get a nice Oops */ | ||
| 595 | div = (lcdclk + 2 * mclk_10khz - 1) / (2 * mclk_10khz) - 1; | ||
| 596 | |||
| 597 | dev_dbg(pcdev->dev, "LCD clock %lukHz, target freq %dkHz, " | ||
| 598 | "divisor %lu\n", lcdclk * 10, mclk_10khz * 10, div); | ||
| 599 | |||
| 600 | return div; | ||
| 601 | } | ||
| 602 | |||
| 603 | static void pxa_camera_activate(struct pxa_camera_dev *pcdev) | ||
| 604 | { | ||
| 605 | struct pxacamera_platform_data *pdata = pcdev->pdata; | ||
| 606 | u32 cicr4 = 0; | ||
| 607 | |||
| 608 | dev_dbg(pcdev->dev, "Registered platform device at %p data %p\n", | ||
| 609 | pcdev, pdata); | ||
| 610 | |||
| 611 | if (pdata && pdata->init) { | ||
| 612 | dev_dbg(pcdev->dev, "%s: Init gpios\n", __func__); | ||
| 613 | pdata->init(pcdev->dev); | ||
| 614 | } | ||
| 615 | |||
| 616 | if (pdata && pdata->power) { | ||
| 617 | dev_dbg(pcdev->dev, "%s: Power on camera\n", __func__); | ||
| 618 | pdata->power(pcdev->dev, 1); | ||
| 619 | } | ||
| 620 | |||
| 621 | if (pdata && pdata->reset) { | ||
| 622 | dev_dbg(pcdev->dev, "%s: Releasing camera reset\n", | ||
| 623 | __func__); | ||
| 624 | pdata->reset(pcdev->dev, 1); | ||
| 625 | } | ||
| 626 | |||
| 627 | CICR0 = 0x3FF; /* disable all interrupts */ | ||
| 628 | |||
| 629 | if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN) | ||
| 630 | cicr4 |= CICR4_PCLK_EN; | ||
| 631 | if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN) | ||
| 632 | cicr4 |= CICR4_MCLK_EN; | ||
| 633 | if (pcdev->platform_flags & PXA_CAMERA_PCP) | ||
| 634 | cicr4 |= CICR4_PCP; | ||
| 635 | if (pcdev->platform_flags & PXA_CAMERA_HSP) | ||
| 636 | cicr4 |= CICR4_HSP; | ||
| 637 | if (pcdev->platform_flags & PXA_CAMERA_VSP) | ||
| 638 | cicr4 |= CICR4_VSP; | ||
| 639 | |||
| 640 | CICR4 = mclk_get_divisor(pcdev) | cicr4; | ||
| 641 | |||
| 642 | clk_enable(pcdev->clk); | ||
| 643 | } | ||
| 644 | |||
| 645 | static void pxa_camera_deactivate(struct pxa_camera_dev *pcdev) | ||
| 646 | { | ||
| 647 | struct pxacamera_platform_data *board = pcdev->pdata; | ||
| 648 | |||
| 649 | clk_disable(pcdev->clk); | ||
| 650 | |||
| 651 | if (board && board->reset) { | ||
| 652 | dev_dbg(pcdev->dev, "%s: Asserting camera reset\n", | ||
| 653 | __func__); | ||
| 654 | board->reset(pcdev->dev, 0); | ||
| 655 | } | ||
| 656 | |||
| 657 | if (board && board->power) { | ||
| 658 | dev_dbg(pcdev->dev, "%s: Power off camera\n", __func__); | ||
| 659 | board->power(pcdev->dev, 0); | ||
| 660 | } | ||
| 661 | } | ||
| 662 | |||
| 663 | static irqreturn_t pxa_camera_irq(int irq, void *data) | ||
| 664 | { | ||
| 665 | struct pxa_camera_dev *pcdev = data; | ||
| 666 | unsigned int status = CISR; | ||
| 667 | |||
| 668 | dev_dbg(pcdev->dev, "Camera interrupt status 0x%x\n", status); | ||
| 669 | |||
| 670 | if (!status) | ||
| 671 | return IRQ_NONE; | ||
| 672 | |||
| 673 | CISR = status; | ||
| 674 | |||
| 675 | if (status & CISR_EOF) { | ||
| 676 | int i; | ||
| 677 | for (i = 0; i < pcdev->channels; i++) { | ||
| 678 | DDADR(pcdev->dma_chans[i]) = | ||
| 679 | pcdev->active->dmas[i].sg_dma; | ||
| 680 | DCSR(pcdev->dma_chans[i]) = DCSR_RUN; | ||
| 681 | } | ||
| 682 | CICR0 |= CICR0_EOFM; | ||
| 683 | } | ||
| 684 | |||
| 685 | return IRQ_HANDLED; | ||
| 686 | } | ||
| 687 | |||
| 688 | /* The following two functions absolutely depend on the fact, that | ||
| 689 | * there can be only one camera on PXA quick capture interface */ | ||
| 690 | static int pxa_camera_add_device(struct soc_camera_device *icd) | ||
| 691 | { | ||
| 692 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
| 693 | struct pxa_camera_dev *pcdev = ici->priv; | ||
| 694 | int ret; | ||
| 695 | |||
| 696 | mutex_lock(&camera_lock); | ||
| 697 | |||
| 698 | if (pcdev->icd) { | ||
| 699 | ret = -EBUSY; | ||
| 700 | goto ebusy; | ||
| 701 | } | ||
| 702 | |||
| 703 | dev_info(&icd->dev, "PXA Camera driver attached to camera %d\n", | ||
| 704 | icd->devnum); | ||
| 705 | |||
| 706 | pxa_camera_activate(pcdev); | ||
| 707 | ret = icd->ops->init(icd); | ||
| 708 | |||
| 709 | if (!ret) | ||
| 710 | pcdev->icd = icd; | ||
| 711 | |||
| 712 | ebusy: | ||
| 713 | mutex_unlock(&camera_lock); | ||
| 714 | |||
| 715 | return ret; | ||
| 716 | } | ||
| 717 | |||
| 718 | static void pxa_camera_remove_device(struct soc_camera_device *icd) | ||
| 719 | { | ||
| 720 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
| 721 | struct pxa_camera_dev *pcdev = ici->priv; | ||
| 722 | |||
| 723 | BUG_ON(icd != pcdev->icd); | ||
| 724 | |||
| 725 | dev_info(&icd->dev, "PXA Camera driver detached from camera %d\n", | ||
| 726 | icd->devnum); | ||
| 727 | |||
| 728 | /* disable capture, disable interrupts */ | ||
| 729 | CICR0 = 0x3ff; | ||
| 730 | |||
| 731 | /* Stop DMA engine */ | ||
| 732 | DCSR(pcdev->dma_chans[0]) = 0; | ||
| 733 | DCSR(pcdev->dma_chans[1]) = 0; | ||
| 734 | DCSR(pcdev->dma_chans[2]) = 0; | ||
| 735 | |||
| 736 | icd->ops->release(icd); | ||
| 737 | |||
| 738 | pxa_camera_deactivate(pcdev); | ||
| 739 | |||
| 740 | pcdev->icd = NULL; | ||
| 741 | } | ||
| 742 | |||
| 743 | static int test_platform_param(struct pxa_camera_dev *pcdev, | ||
| 744 | unsigned char buswidth, unsigned long *flags) | ||
| 745 | { | ||
| 746 | /* | ||
| 747 | * Platform specified synchronization and pixel clock polarities are | ||
| 748 | * only a recommendation and are only used during probing. The PXA270 | ||
| 749 | * quick capture interface supports both. | ||
| 750 | */ | ||
| 751 | *flags = (pcdev->platform_flags & PXA_CAMERA_MASTER ? | ||
| 752 | SOCAM_MASTER : SOCAM_SLAVE) | | ||
| 753 | SOCAM_HSYNC_ACTIVE_HIGH | | ||
| 754 | SOCAM_HSYNC_ACTIVE_LOW | | ||
| 755 | SOCAM_VSYNC_ACTIVE_HIGH | | ||
| 756 | SOCAM_VSYNC_ACTIVE_LOW | | ||
| 757 | SOCAM_PCLK_SAMPLE_RISING | | ||
| 758 | SOCAM_PCLK_SAMPLE_FALLING; | ||
| 759 | |||
| 760 | /* If requested data width is supported by the platform, use it */ | ||
| 761 | switch (buswidth) { | ||
| 762 | case 10: | ||
| 763 | if (!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_10)) | ||
| 764 | return -EINVAL; | ||
| 765 | *flags |= SOCAM_DATAWIDTH_10; | ||
| 766 | break; | ||
| 767 | case 9: | ||
| 768 | if (!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_9)) | ||
| 769 | return -EINVAL; | ||
| 770 | *flags |= SOCAM_DATAWIDTH_9; | ||
| 771 | break; | ||
| 772 | case 8: | ||
| 773 | if (!(pcdev->platform_flags & PXA_CAMERA_DATAWIDTH_8)) | ||
| 774 | return -EINVAL; | ||
| 775 | *flags |= SOCAM_DATAWIDTH_8; | ||
| 776 | } | ||
| 777 | |||
| 778 | return 0; | ||
| 779 | } | ||
| 780 | |||
| 781 | static int pxa_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt) | ||
| 782 | { | ||
| 783 | struct soc_camera_host *ici = | ||
| 784 | to_soc_camera_host(icd->dev.parent); | ||
| 785 | struct pxa_camera_dev *pcdev = ici->priv; | ||
| 786 | unsigned long dw, bpp, bus_flags, camera_flags, common_flags; | ||
| 787 | u32 cicr0, cicr1, cicr4 = 0; | ||
| 788 | int ret = test_platform_param(pcdev, icd->buswidth, &bus_flags); | ||
| 789 | |||
| 790 | if (ret < 0) | ||
| 791 | return ret; | ||
| 792 | |||
| 793 | camera_flags = icd->ops->query_bus_param(icd); | ||
| 794 | |||
| 795 | common_flags = soc_camera_bus_param_compatible(camera_flags, bus_flags); | ||
| 796 | if (!common_flags) | ||
| 797 | return -EINVAL; | ||
| 798 | |||
| 799 | pcdev->channels = 1; | ||
| 800 | |||
| 801 | /* Make choises, based on platform preferences */ | ||
| 802 | if ((common_flags & SOCAM_HSYNC_ACTIVE_HIGH) && | ||
| 803 | (common_flags & SOCAM_HSYNC_ACTIVE_LOW)) { | ||
| 804 | if (pcdev->platform_flags & PXA_CAMERA_HSP) | ||
| 805 | common_flags &= ~SOCAM_HSYNC_ACTIVE_HIGH; | ||
| 806 | else | ||
| 807 | common_flags &= ~SOCAM_HSYNC_ACTIVE_LOW; | ||
| 808 | } | ||
| 809 | |||
| 810 | if ((common_flags & SOCAM_VSYNC_ACTIVE_HIGH) && | ||
| 811 | (common_flags & SOCAM_VSYNC_ACTIVE_LOW)) { | ||
| 812 | if (pcdev->platform_flags & PXA_CAMERA_VSP) | ||
| 813 | common_flags &= ~SOCAM_VSYNC_ACTIVE_HIGH; | ||
| 814 | else | ||
| 815 | common_flags &= ~SOCAM_VSYNC_ACTIVE_LOW; | ||
| 816 | } | ||
| 817 | |||
| 818 | if ((common_flags & SOCAM_PCLK_SAMPLE_RISING) && | ||
| 819 | (common_flags & SOCAM_PCLK_SAMPLE_FALLING)) { | ||
| 820 | if (pcdev->platform_flags & PXA_CAMERA_PCP) | ||
| 821 | common_flags &= ~SOCAM_PCLK_SAMPLE_RISING; | ||
| 822 | else | ||
| 823 | common_flags &= ~SOCAM_PCLK_SAMPLE_FALLING; | ||
| 824 | } | ||
| 825 | |||
| 826 | ret = icd->ops->set_bus_param(icd, common_flags); | ||
| 827 | if (ret < 0) | ||
| 828 | return ret; | ||
| 829 | |||
| 830 | /* Datawidth is now guaranteed to be equal to one of the three values. | ||
| 831 | * We fix bit-per-pixel equal to data-width... */ | ||
| 832 | switch (common_flags & SOCAM_DATAWIDTH_MASK) { | ||
| 833 | case SOCAM_DATAWIDTH_10: | ||
| 834 | icd->buswidth = 10; | ||
| 835 | dw = 4; | ||
| 836 | bpp = 0x40; | ||
| 837 | break; | ||
| 838 | case SOCAM_DATAWIDTH_9: | ||
| 839 | icd->buswidth = 9; | ||
| 840 | dw = 3; | ||
| 841 | bpp = 0x20; | ||
| 842 | break; | ||
| 843 | default: | ||
| 844 | /* Actually it can only be 8 now, | ||
| 845 | * default is just to silence compiler warnings */ | ||
| 846 | case SOCAM_DATAWIDTH_8: | ||
| 847 | icd->buswidth = 8; | ||
| 848 | dw = 2; | ||
| 849 | bpp = 0; | ||
| 850 | } | ||
| 851 | |||
| 852 | if (pcdev->platform_flags & PXA_CAMERA_PCLK_EN) | ||
| 853 | cicr4 |= CICR4_PCLK_EN; | ||
| 854 | if (pcdev->platform_flags & PXA_CAMERA_MCLK_EN) | ||
| 855 | cicr4 |= CICR4_MCLK_EN; | ||
| 856 | if (common_flags & SOCAM_PCLK_SAMPLE_FALLING) | ||
| 857 | cicr4 |= CICR4_PCP; | ||
| 858 | if (common_flags & SOCAM_HSYNC_ACTIVE_LOW) | ||
| 859 | cicr4 |= CICR4_HSP; | ||
| 860 | if (common_flags & SOCAM_VSYNC_ACTIVE_LOW) | ||
| 861 | cicr4 |= CICR4_VSP; | ||
| 862 | |||
| 863 | cicr0 = CICR0; | ||
| 864 | if (cicr0 & CICR0_ENB) | ||
| 865 | CICR0 = cicr0 & ~CICR0_ENB; | ||
| 866 | |||
| 867 | cicr1 = CICR1_PPL_VAL(icd->width - 1) | bpp | dw; | ||
| 868 | |||
| 869 | switch (pixfmt) { | ||
| 870 | case V4L2_PIX_FMT_YUV422P: | ||
| 871 | pcdev->channels = 3; | ||
| 872 | cicr1 |= CICR1_YCBCR_F; | ||
| 873 | case V4L2_PIX_FMT_YUYV: | ||
| 874 | cicr1 |= CICR1_COLOR_SP_VAL(2); | ||
| 875 | break; | ||
| 876 | case V4L2_PIX_FMT_RGB555: | ||
| 877 | cicr1 |= CICR1_RGB_BPP_VAL(1) | CICR1_RGBT_CONV_VAL(2) | | ||
| 878 | CICR1_TBIT | CICR1_COLOR_SP_VAL(1); | ||
| 879 | break; | ||
| 880 | case V4L2_PIX_FMT_RGB565: | ||
| 881 | cicr1 |= CICR1_COLOR_SP_VAL(1) | CICR1_RGB_BPP_VAL(2); | ||
| 882 | break; | ||
| 883 | } | ||
| 884 | |||
| 885 | CICR1 = cicr1; | ||
| 886 | CICR2 = 0; | ||
| 887 | CICR3 = CICR3_LPF_VAL(icd->height - 1) | | ||
| 888 | CICR3_BFW_VAL(min((unsigned short)255, icd->y_skip_top)); | ||
| 889 | CICR4 = mclk_get_divisor(pcdev) | cicr4; | ||
| 890 | |||
| 891 | /* CIF interrupts are not used, only DMA */ | ||
| 892 | CICR0 = (pcdev->platform_flags & PXA_CAMERA_MASTER ? | ||
| 893 | CICR0_SIM_MP : (CICR0_SL_CAP_EN | CICR0_SIM_SP)) | | ||
| 894 | CICR0_DMAEN | CICR0_IRQ_MASK | (cicr0 & CICR0_ENB); | ||
| 895 | |||
| 896 | return 0; | ||
| 897 | } | ||
| 898 | |||
| 899 | static int pxa_camera_try_bus_param(struct soc_camera_device *icd, __u32 pixfmt) | ||
| 900 | { | ||
| 901 | struct soc_camera_host *ici = | ||
| 902 | to_soc_camera_host(icd->dev.parent); | ||
| 903 | struct pxa_camera_dev *pcdev = ici->priv; | ||
| 904 | unsigned long bus_flags, camera_flags; | ||
| 905 | int ret = test_platform_param(pcdev, icd->buswidth, &bus_flags); | ||
| 906 | |||
| 907 | if (ret < 0) | ||
| 908 | return ret; | ||
| 909 | |||
| 910 | camera_flags = icd->ops->query_bus_param(icd); | ||
| 911 | |||
| 912 | return soc_camera_bus_param_compatible(camera_flags, bus_flags) ? 0 : -EINVAL; | ||
| 913 | } | ||
| 914 | |||
| 915 | static int pxa_camera_set_fmt_cap(struct soc_camera_device *icd, | ||
| 916 | __u32 pixfmt, struct v4l2_rect *rect) | ||
| 917 | { | ||
| 918 | return icd->ops->set_fmt_cap(icd, pixfmt, rect); | ||
| 919 | } | ||
| 920 | |||
| 921 | static int pxa_camera_try_fmt_cap(struct soc_camera_device *icd, | ||
| 922 | struct v4l2_format *f) | ||
| 923 | { | ||
| 924 | /* limit to pxa hardware capabilities */ | ||
| 925 | if (f->fmt.pix.height < 32) | ||
| 926 | f->fmt.pix.height = 32; | ||
| 927 | if (f->fmt.pix.height > 2048) | ||
| 928 | f->fmt.pix.height = 2048; | ||
| 929 | if (f->fmt.pix.width < 48) | ||
| 930 | f->fmt.pix.width = 48; | ||
| 931 | if (f->fmt.pix.width > 2048) | ||
| 932 | f->fmt.pix.width = 2048; | ||
| 933 | f->fmt.pix.width &= ~0x01; | ||
| 934 | |||
| 935 | /* limit to sensor capabilities */ | ||
| 936 | return icd->ops->try_fmt_cap(icd, f); | ||
| 937 | } | ||
| 938 | |||
| 939 | static int pxa_camera_reqbufs(struct soc_camera_file *icf, | ||
| 940 | struct v4l2_requestbuffers *p) | ||
| 941 | { | ||
| 942 | int i; | ||
| 943 | |||
| 944 | /* This is for locking debugging only. I removed spinlocks and now I | ||
| 945 | * check whether .prepare is ever called on a linked buffer, or whether | ||
| 946 | * a dma IRQ can occur for an in-work or unlinked buffer. Until now | ||
| 947 | * it hadn't triggered */ | ||
| 948 | for (i = 0; i < p->count; i++) { | ||
| 949 | struct pxa_buffer *buf = container_of(icf->vb_vidq.bufs[i], | ||
| 950 | struct pxa_buffer, vb); | ||
| 951 | buf->inwork = 0; | ||
| 952 | INIT_LIST_HEAD(&buf->vb.queue); | ||
| 953 | } | ||
| 954 | |||
| 955 | return 0; | ||
| 956 | } | ||
| 957 | |||
| 958 | static unsigned int pxa_camera_poll(struct file *file, poll_table *pt) | ||
| 959 | { | ||
| 960 | struct soc_camera_file *icf = file->private_data; | ||
| 961 | struct pxa_buffer *buf; | ||
| 962 | |||
| 963 | buf = list_entry(icf->vb_vidq.stream.next, struct pxa_buffer, | ||
| 964 | vb.stream); | ||
| 965 | |||
| 966 | poll_wait(file, &buf->vb.done, pt); | ||
| 967 | |||
| 968 | if (buf->vb.state == VIDEOBUF_DONE || | ||
| 969 | buf->vb.state == VIDEOBUF_ERROR) | ||
| 970 | return POLLIN|POLLRDNORM; | ||
| 971 | |||
| 972 | return 0; | ||
| 973 | } | ||
| 974 | |||
| 975 | static int pxa_camera_querycap(struct soc_camera_host *ici, | ||
| 976 | struct v4l2_capability *cap) | ||
| 977 | { | ||
| 978 | /* cap->name is set by the firendly caller:-> */ | ||
| 979 | strlcpy(cap->card, pxa_cam_driver_description, sizeof(cap->card)); | ||
| 980 | cap->version = PXA_CAM_VERSION_CODE; | ||
| 981 | cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; | ||
| 982 | |||
| 983 | return 0; | ||
| 984 | } | ||
| 985 | |||
| 986 | static spinlock_t *pxa_camera_spinlock_alloc(struct soc_camera_file *icf) | ||
| 987 | { | ||
| 988 | struct soc_camera_host *ici = | ||
| 989 | to_soc_camera_host(icf->icd->dev.parent); | ||
| 990 | struct pxa_camera_dev *pcdev = ici->priv; | ||
| 991 | |||
| 992 | return &pcdev->lock; | ||
| 993 | } | ||
| 994 | |||
| 995 | static struct soc_camera_host_ops pxa_soc_camera_host_ops = { | ||
| 996 | .owner = THIS_MODULE, | ||
| 997 | .add = pxa_camera_add_device, | ||
| 998 | .remove = pxa_camera_remove_device, | ||
| 999 | .set_fmt_cap = pxa_camera_set_fmt_cap, | ||
| 1000 | .try_fmt_cap = pxa_camera_try_fmt_cap, | ||
| 1001 | .reqbufs = pxa_camera_reqbufs, | ||
| 1002 | .poll = pxa_camera_poll, | ||
| 1003 | .querycap = pxa_camera_querycap, | ||
| 1004 | .try_bus_param = pxa_camera_try_bus_param, | ||
| 1005 | .set_bus_param = pxa_camera_set_bus_param, | ||
| 1006 | .spinlock_alloc = pxa_camera_spinlock_alloc, | ||
| 1007 | }; | ||
| 1008 | |||
| 1009 | /* Should be allocated dynamically too, but we have only one. */ | ||
| 1010 | static struct soc_camera_host pxa_soc_camera_host = { | ||
| 1011 | .drv_name = PXA_CAM_DRV_NAME, | ||
| 1012 | .vbq_ops = &pxa_videobuf_ops, | ||
| 1013 | .msize = sizeof(struct pxa_buffer), | ||
| 1014 | .ops = &pxa_soc_camera_host_ops, | ||
| 1015 | }; | ||
| 1016 | |||
| 1017 | static int pxa_camera_probe(struct platform_device *pdev) | ||
| 1018 | { | ||
| 1019 | struct pxa_camera_dev *pcdev; | ||
| 1020 | struct resource *res; | ||
| 1021 | void __iomem *base; | ||
| 1022 | unsigned int irq; | ||
| 1023 | int err = 0; | ||
| 1024 | |||
| 1025 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 1026 | irq = platform_get_irq(pdev, 0); | ||
| 1027 | if (!res || !irq) { | ||
| 1028 | err = -ENODEV; | ||
| 1029 | goto exit; | ||
| 1030 | } | ||
| 1031 | |||
| 1032 | pcdev = kzalloc(sizeof(*pcdev), GFP_KERNEL); | ||
| 1033 | if (!pcdev) { | ||
| 1034 | dev_err(&pdev->dev, "Could not allocate pcdev\n"); | ||
| 1035 | err = -ENOMEM; | ||
| 1036 | goto exit; | ||
| 1037 | } | ||
| 1038 | |||
| 1039 | pcdev->clk = clk_get(&pdev->dev, "CAMCLK"); | ||
| 1040 | if (IS_ERR(pcdev->clk)) { | ||
| 1041 | err = PTR_ERR(pcdev->clk); | ||
| 1042 | goto exit_kfree; | ||
| 1043 | } | ||
| 1044 | |||
| 1045 | dev_set_drvdata(&pdev->dev, pcdev); | ||
| 1046 | pcdev->res = res; | ||
| 1047 | |||
| 1048 | pcdev->pdata = pdev->dev.platform_data; | ||
| 1049 | pcdev->platform_flags = pcdev->pdata->flags; | ||
| 1050 | if (!(pcdev->platform_flags & (PXA_CAMERA_DATAWIDTH_8 | | ||
| 1051 | PXA_CAMERA_DATAWIDTH_9 | PXA_CAMERA_DATAWIDTH_10))) { | ||
| 1052 | /* Platform hasn't set available data widths. This is bad. | ||
| 1053 | * Warn and use a default. */ | ||
| 1054 | dev_warn(&pdev->dev, "WARNING! Platform hasn't set available " | ||
| 1055 | "data widths, using default 10 bit\n"); | ||
| 1056 | pcdev->platform_flags |= PXA_CAMERA_DATAWIDTH_10; | ||
| 1057 | } | ||
| 1058 | pcdev->platform_mclk_10khz = pcdev->pdata->mclk_10khz; | ||
| 1059 | if (!pcdev->platform_mclk_10khz) { | ||
| 1060 | dev_warn(&pdev->dev, | ||
| 1061 | "mclk_10khz == 0! Please, fix your platform data. " | ||
| 1062 | "Using default 20MHz\n"); | ||
| 1063 | pcdev->platform_mclk_10khz = 2000; | ||
| 1064 | } | ||
| 1065 | |||
| 1066 | INIT_LIST_HEAD(&pcdev->capture); | ||
| 1067 | spin_lock_init(&pcdev->lock); | ||
| 1068 | |||
| 1069 | /* | ||
| 1070 | * Request the regions. | ||
| 1071 | */ | ||
| 1072 | if (!request_mem_region(res->start, res->end - res->start + 1, | ||
| 1073 | PXA_CAM_DRV_NAME)) { | ||
| 1074 | err = -EBUSY; | ||
| 1075 | goto exit_clk; | ||
| 1076 | } | ||
| 1077 | |||
| 1078 | base = ioremap(res->start, res->end - res->start + 1); | ||
| 1079 | if (!base) { | ||
| 1080 | err = -ENOMEM; | ||
| 1081 | goto exit_release; | ||
| 1082 | } | ||
| 1083 | pcdev->irq = irq; | ||
| 1084 | pcdev->base = base; | ||
| 1085 | pcdev->dev = &pdev->dev; | ||
| 1086 | |||
| 1087 | /* request dma */ | ||
| 1088 | pcdev->dma_chans[0] = pxa_request_dma("CI_Y", DMA_PRIO_HIGH, | ||
| 1089 | pxa_camera_dma_irq_y, pcdev); | ||
| 1090 | if (pcdev->dma_chans[0] < 0) { | ||
| 1091 | dev_err(pcdev->dev, "Can't request DMA for Y\n"); | ||
| 1092 | err = -ENOMEM; | ||
| 1093 | goto exit_iounmap; | ||
| 1094 | } | ||
| 1095 | dev_dbg(pcdev->dev, "got DMA channel %d\n", pcdev->dma_chans[0]); | ||
| 1096 | |||
| 1097 | pcdev->dma_chans[1] = pxa_request_dma("CI_U", DMA_PRIO_HIGH, | ||
| 1098 | pxa_camera_dma_irq_u, pcdev); | ||
| 1099 | if (pcdev->dma_chans[1] < 0) { | ||
| 1100 | dev_err(pcdev->dev, "Can't request DMA for U\n"); | ||
| 1101 | err = -ENOMEM; | ||
| 1102 | goto exit_free_dma_y; | ||
| 1103 | } | ||
| 1104 | dev_dbg(pcdev->dev, "got DMA channel (U) %d\n", pcdev->dma_chans[1]); | ||
| 1105 | |||
| 1106 | pcdev->dma_chans[2] = pxa_request_dma("CI_V", DMA_PRIO_HIGH, | ||
| 1107 | pxa_camera_dma_irq_v, pcdev); | ||
| 1108 | if (pcdev->dma_chans[0] < 0) { | ||
| 1109 | dev_err(pcdev->dev, "Can't request DMA for V\n"); | ||
| 1110 | err = -ENOMEM; | ||
| 1111 | goto exit_free_dma_u; | ||
| 1112 | } | ||
| 1113 | dev_dbg(pcdev->dev, "got DMA channel (V) %d\n", pcdev->dma_chans[2]); | ||
| 1114 | |||
| 1115 | DRCMR68 = pcdev->dma_chans[0] | DRCMR_MAPVLD; | ||
| 1116 | DRCMR69 = pcdev->dma_chans[1] | DRCMR_MAPVLD; | ||
| 1117 | DRCMR70 = pcdev->dma_chans[2] | DRCMR_MAPVLD; | ||
| 1118 | |||
| 1119 | /* request irq */ | ||
| 1120 | err = request_irq(pcdev->irq, pxa_camera_irq, 0, PXA_CAM_DRV_NAME, | ||
| 1121 | pcdev); | ||
| 1122 | if (err) { | ||
| 1123 | dev_err(pcdev->dev, "Camera interrupt register failed \n"); | ||
| 1124 | goto exit_free_dma; | ||
| 1125 | } | ||
| 1126 | |||
| 1127 | pxa_soc_camera_host.priv = pcdev; | ||
| 1128 | pxa_soc_camera_host.dev.parent = &pdev->dev; | ||
| 1129 | pxa_soc_camera_host.nr = pdev->id; | ||
| 1130 | err = soc_camera_host_register(&pxa_soc_camera_host); | ||
| 1131 | if (err) | ||
| 1132 | goto exit_free_irq; | ||
| 1133 | |||
| 1134 | return 0; | ||
| 1135 | |||
| 1136 | exit_free_irq: | ||
| 1137 | free_irq(pcdev->irq, pcdev); | ||
| 1138 | exit_free_dma: | ||
| 1139 | pxa_free_dma(pcdev->dma_chans[2]); | ||
| 1140 | exit_free_dma_u: | ||
| 1141 | pxa_free_dma(pcdev->dma_chans[1]); | ||
| 1142 | exit_free_dma_y: | ||
| 1143 | pxa_free_dma(pcdev->dma_chans[0]); | ||
| 1144 | exit_iounmap: | ||
| 1145 | iounmap(base); | ||
| 1146 | exit_release: | ||
| 1147 | release_mem_region(res->start, res->end - res->start + 1); | ||
| 1148 | exit_clk: | ||
| 1149 | clk_put(pcdev->clk); | ||
| 1150 | exit_kfree: | ||
| 1151 | kfree(pcdev); | ||
| 1152 | exit: | ||
| 1153 | return err; | ||
| 1154 | } | ||
| 1155 | |||
| 1156 | static int __devexit pxa_camera_remove(struct platform_device *pdev) | ||
| 1157 | { | ||
| 1158 | struct pxa_camera_dev *pcdev = platform_get_drvdata(pdev); | ||
| 1159 | struct resource *res; | ||
| 1160 | |||
| 1161 | clk_put(pcdev->clk); | ||
| 1162 | |||
| 1163 | pxa_free_dma(pcdev->dma_chans[0]); | ||
| 1164 | pxa_free_dma(pcdev->dma_chans[1]); | ||
| 1165 | pxa_free_dma(pcdev->dma_chans[2]); | ||
| 1166 | free_irq(pcdev->irq, pcdev); | ||
| 1167 | |||
| 1168 | soc_camera_host_unregister(&pxa_soc_camera_host); | ||
| 1169 | |||
| 1170 | iounmap(pcdev->base); | ||
| 1171 | |||
| 1172 | res = pcdev->res; | ||
| 1173 | release_mem_region(res->start, res->end - res->start + 1); | ||
| 1174 | |||
| 1175 | kfree(pcdev); | ||
| 1176 | |||
| 1177 | dev_info(&pdev->dev, "PXA Camera driver unloaded\n"); | ||
| 1178 | |||
| 1179 | return 0; | ||
| 1180 | } | ||
| 1181 | |||
| 1182 | static struct platform_driver pxa_camera_driver = { | ||
| 1183 | .driver = { | ||
| 1184 | .name = PXA_CAM_DRV_NAME, | ||
| 1185 | }, | ||
| 1186 | .probe = pxa_camera_probe, | ||
| 1187 | .remove = __exit_p(pxa_camera_remove), | ||
| 1188 | }; | ||
| 1189 | |||
| 1190 | |||
| 1191 | static int __devinit pxa_camera_init(void) | ||
| 1192 | { | ||
| 1193 | return platform_driver_register(&pxa_camera_driver); | ||
| 1194 | } | ||
| 1195 | |||
| 1196 | static void __exit pxa_camera_exit(void) | ||
| 1197 | { | ||
| 1198 | return platform_driver_unregister(&pxa_camera_driver); | ||
| 1199 | } | ||
| 1200 | |||
| 1201 | module_init(pxa_camera_init); | ||
| 1202 | module_exit(pxa_camera_exit); | ||
| 1203 | |||
| 1204 | MODULE_DESCRIPTION("PXA27x SoC Camera Host driver"); | ||
| 1205 | MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>"); | ||
| 1206 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c index f55d6e85f20f..ec8c65dc8408 100644 --- a/drivers/media/video/saa5249.c +++ b/drivers/media/video/saa5249.c | |||
| @@ -701,7 +701,9 @@ static const struct file_operations saa_fops = { | |||
| 701 | .open = saa5249_open, | 701 | .open = saa5249_open, |
| 702 | .release = saa5249_release, | 702 | .release = saa5249_release, |
| 703 | .ioctl = saa5249_ioctl, | 703 | .ioctl = saa5249_ioctl, |
| 704 | #ifdef CONFIG_COMPAT | ||
| 704 | .compat_ioctl = v4l_compat_ioctl32, | 705 | .compat_ioctl = v4l_compat_ioctl32, |
| 706 | #endif | ||
| 705 | .llseek = no_llseek, | 707 | .llseek = no_llseek, |
| 706 | }; | 708 | }; |
| 707 | 709 | ||
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c index 72e344a12c79..716ee7f64df3 100644 --- a/drivers/media/video/saa6588.c +++ b/drivers/media/video/saa6588.c | |||
| @@ -44,10 +44,10 @@ static unsigned short normal_i2c[] = { | |||
| 44 | I2C_CLIENT_INSMOD; | 44 | I2C_CLIENT_INSMOD; |
| 45 | 45 | ||
| 46 | /* insmod options */ | 46 | /* insmod options */ |
| 47 | static unsigned int debug = 0; | 47 | static unsigned int debug; |
| 48 | static unsigned int xtal = 0; | 48 | static unsigned int xtal; |
| 49 | static unsigned int rbds = 0; | 49 | static unsigned int rbds; |
| 50 | static unsigned int plvl = 0; | 50 | static unsigned int plvl; |
| 51 | static unsigned int bufblocks = 100; | 51 | static unsigned int bufblocks = 100; |
| 52 | 52 | ||
| 53 | module_param(debug, int, 0644); | 53 | module_param(debug, int, 0644); |
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c index 1df2602cd184..4aa82b310708 100644 --- a/drivers/media/video/saa7110.c +++ b/drivers/media/video/saa7110.c | |||
| @@ -46,7 +46,7 @@ MODULE_LICENSE("GPL"); | |||
| 46 | #include <media/v4l2-common.h> | 46 | #include <media/v4l2-common.h> |
| 47 | #include <linux/video_decoder.h> | 47 | #include <linux/video_decoder.h> |
| 48 | 48 | ||
| 49 | static int debug = 0; | 49 | static int debug; |
| 50 | module_param(debug, int, 0); | 50 | module_param(debug, int, 0); |
| 51 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 51 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 52 | 52 | ||
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c index a0772c53bb1f..96c3d4357722 100644 --- a/drivers/media/video/saa7111.c +++ b/drivers/media/video/saa7111.c | |||
| @@ -55,7 +55,7 @@ MODULE_LICENSE("GPL"); | |||
| 55 | #define I2C_NAME(s) (s)->name | 55 | #define I2C_NAME(s) (s)->name |
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | static int debug = 0; | 58 | static int debug; |
| 59 | module_param(debug, int, 0644); | 59 | module_param(debug, int, 0644); |
| 60 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 60 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 61 | 61 | ||
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c index bf91a4faa706..e79075533beb 100644 --- a/drivers/media/video/saa7114.c +++ b/drivers/media/video/saa7114.c | |||
| @@ -56,7 +56,7 @@ MODULE_LICENSE("GPL"); | |||
| 56 | #define I2C_NAME(x) (x)->name | 56 | #define I2C_NAME(x) (x)->name |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | static int debug = 0; | 59 | static int debug; |
| 60 | module_param(debug, int, 0); | 60 | module_param(debug, int, 0); |
| 61 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 61 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 62 | 62 | ||
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c index 41e5e518a47e..416d05d4a969 100644 --- a/drivers/media/video/saa7115.c +++ b/drivers/media/video/saa7115.c | |||
| @@ -57,7 +57,7 @@ MODULE_AUTHOR( "Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, " | |||
| 57 | "Hans Verkuil, Mauro Carvalho Chehab"); | 57 | "Hans Verkuil, Mauro Carvalho Chehab"); |
| 58 | MODULE_LICENSE("GPL"); | 58 | MODULE_LICENSE("GPL"); |
| 59 | 59 | ||
| 60 | static int debug = 0; | 60 | static int debug; |
| 61 | module_param(debug, bool, 0644); | 61 | module_param(debug, bool, 0644); |
| 62 | 62 | ||
| 63 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 63 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| @@ -957,7 +957,7 @@ static void saa711x_set_v4lstd(struct i2c_client *client, v4l2_std_id std) | |||
| 957 | 957 | ||
| 958 | if (std == V4L2_STD_PAL_M) { | 958 | if (std == V4L2_STD_PAL_M) { |
| 959 | reg |= 0x30; | 959 | reg |= 0x30; |
| 960 | } else if (std == V4L2_STD_PAL_N) { | 960 | } else if (std == V4L2_STD_PAL_Nc) { |
| 961 | reg |= 0x20; | 961 | reg |= 0x20; |
| 962 | } else if (std == V4L2_STD_PAL_60) { | 962 | } else if (std == V4L2_STD_PAL_60) { |
| 963 | reg |= 0x10; | 963 | reg |= 0x10; |
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c index 80bf91187856..cedb988574bd 100644 --- a/drivers/media/video/saa711x.c +++ b/drivers/media/video/saa711x.c | |||
| @@ -48,7 +48,7 @@ MODULE_LICENSE("GPL"); | |||
| 48 | 48 | ||
| 49 | #include <linux/video_decoder.h> | 49 | #include <linux/video_decoder.h> |
| 50 | 50 | ||
| 51 | static int debug = 0; | 51 | static int debug; |
| 52 | module_param(debug, int, 0644); | 52 | module_param(debug, int, 0644); |
| 53 | MODULE_PARM_DESC(debug, " Set the default Debug level. Default: 0 (Off) - (0-1)"); | 53 | MODULE_PARM_DESC(debug, " Set the default Debug level. Default: 0 (Off) - (0-1)"); |
| 54 | 54 | ||
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig index 96bc3b1298a2..e086f14d5663 100644 --- a/drivers/media/video/saa7134/Kconfig +++ b/drivers/media/video/saa7134/Kconfig | |||
| @@ -37,6 +37,7 @@ config VIDEO_SAA7134_DVB | |||
| 37 | select DVB_TDA826X if !DVB_FE_CUSTOMISE | 37 | select DVB_TDA826X if !DVB_FE_CUSTOMISE |
| 38 | select DVB_TDA827X if !DVB_FE_CUSTOMISE | 38 | select DVB_TDA827X if !DVB_FE_CUSTOMISE |
| 39 | select DVB_ISL6421 if !DVB_FE_CUSTOMISE | 39 | select DVB_ISL6421 if !DVB_FE_CUSTOMISE |
| 40 | select TUNER_SIMPLE if !DVB_FE_CUSTOMISE | ||
| 40 | ---help--- | 41 | ---help--- |
| 41 | This adds support for DVB cards based on the | 42 | This adds support for DVB cards based on the |
| 42 | Philips saa7134 chip. | 43 | Philips saa7134 chip. |
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c index ec6bdb9680a3..ba3082422a01 100644 --- a/drivers/media/video/saa7134/saa7134-alsa.c +++ b/drivers/media/video/saa7134/saa7134-alsa.c | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | #include "saa7134.h" | 31 | #include "saa7134.h" |
| 32 | #include "saa7134-reg.h" | 32 | #include "saa7134-reg.h" |
| 33 | 33 | ||
| 34 | static unsigned int debug = 0; | 34 | static unsigned int debug; |
| 35 | module_param(debug, int, 0644); | 35 | module_param(debug, int, 0644); |
| 36 | MODULE_PARM_DESC(debug,"enable debug messages [alsa]"); | 36 | MODULE_PARM_DESC(debug,"enable debug messages [alsa]"); |
| 37 | 37 | ||
| @@ -503,7 +503,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream, | |||
| 503 | /* release the old buffer */ | 503 | /* release the old buffer */ |
| 504 | if (substream->runtime->dma_area) { | 504 | if (substream->runtime->dma_area) { |
| 505 | saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); | 505 | saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); |
| 506 | videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma); | 506 | videobuf_sg_dma_unmap(&dev->pci->dev, &dev->dmasound.dma); |
| 507 | dsp_buffer_free(dev); | 507 | dsp_buffer_free(dev); |
| 508 | substream->runtime->dma_area = NULL; | 508 | substream->runtime->dma_area = NULL; |
| 509 | } | 509 | } |
| @@ -519,12 +519,12 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream, | |||
| 519 | return err; | 519 | return err; |
| 520 | } | 520 | } |
| 521 | 521 | ||
| 522 | if (0 != (err = videobuf_pci_dma_map(dev->pci, &dev->dmasound.dma))) { | 522 | if (0 != (err = videobuf_sg_dma_map(&dev->pci->dev, &dev->dmasound.dma))) { |
| 523 | dsp_buffer_free(dev); | 523 | dsp_buffer_free(dev); |
| 524 | return err; | 524 | return err; |
| 525 | } | 525 | } |
| 526 | if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) { | 526 | if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) { |
| 527 | videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma); | 527 | videobuf_sg_dma_unmap(&dev->pci->dev, &dev->dmasound.dma); |
| 528 | dsp_buffer_free(dev); | 528 | dsp_buffer_free(dev); |
| 529 | return err; | 529 | return err; |
| 530 | } | 530 | } |
| @@ -533,7 +533,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream, | |||
| 533 | dev->dmasound.dma.sglen, | 533 | dev->dmasound.dma.sglen, |
| 534 | 0))) { | 534 | 0))) { |
| 535 | saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); | 535 | saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); |
| 536 | videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma); | 536 | videobuf_sg_dma_unmap(&dev->pci->dev, &dev->dmasound.dma); |
| 537 | dsp_buffer_free(dev); | 537 | dsp_buffer_free(dev); |
| 538 | return err; | 538 | return err; |
| 539 | } | 539 | } |
| @@ -569,7 +569,7 @@ static int snd_card_saa7134_hw_free(struct snd_pcm_substream * substream) | |||
| 569 | 569 | ||
| 570 | if (substream->runtime->dma_area) { | 570 | if (substream->runtime->dma_area) { |
| 571 | saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); | 571 | saa7134_pgtable_free(dev->pci, &dev->dmasound.pt); |
| 572 | videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma); | 572 | videobuf_sg_dma_unmap(&dev->pci->dev, &dev->dmasound.dma); |
| 573 | dsp_buffer_free(dev); | 573 | dsp_buffer_free(dev); |
| 574 | substream->runtime->dma_area = NULL; | 574 | substream->runtime->dma_area = NULL; |
| 575 | } | 575 | } |
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index 6f5744286e8c..98375955a84b 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c | |||
| @@ -22,11 +22,15 @@ | |||
| 22 | 22 | ||
| 23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
| 24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
| 25 | #include <linux/i2c.h> | ||
| 26 | #include <linux/i2c-algo-bit.h> | ||
| 25 | 27 | ||
| 26 | #include "saa7134-reg.h" | 28 | #include "saa7134-reg.h" |
| 27 | #include "saa7134.h" | 29 | #include "saa7134.h" |
| 30 | #include "tuner-xc2028.h" | ||
| 28 | #include <media/v4l2-common.h> | 31 | #include <media/v4l2-common.h> |
| 29 | #include <media/tveeprom.h> | 32 | #include <media/tveeprom.h> |
| 33 | #include "tea5767.h" | ||
| 30 | 34 | ||
| 31 | /* commly used strings */ | 35 | /* commly used strings */ |
| 32 | static char name_mute[] = "mute"; | 36 | static char name_mute[] = "mute"; |
| @@ -1046,7 +1050,7 @@ struct saa7134_board saa7134_boards[] = { | |||
| 1046 | }, | 1050 | }, |
| 1047 | [SAA7134_BOARD_MANLI_MTV002] = { | 1051 | [SAA7134_BOARD_MANLI_MTV002] = { |
| 1048 | /* Ognjen Nastic <ognjen@logosoft.ba> */ | 1052 | /* Ognjen Nastic <ognjen@logosoft.ba> */ |
| 1049 | .name = "Manli MuchTV M-TV002/Behold TV 403 FM", | 1053 | .name = "Manli MuchTV M-TV002", |
| 1050 | .audio_clock = 0x00200000, | 1054 | .audio_clock = 0x00200000, |
| 1051 | .tuner_type = TUNER_PHILIPS_PAL, | 1055 | .tuner_type = TUNER_PHILIPS_PAL, |
| 1052 | .radio_type = UNSET, | 1056 | .radio_type = UNSET, |
| @@ -1073,7 +1077,7 @@ struct saa7134_board saa7134_boards[] = { | |||
| 1073 | }, | 1077 | }, |
| 1074 | [SAA7134_BOARD_MANLI_MTV001] = { | 1078 | [SAA7134_BOARD_MANLI_MTV001] = { |
| 1075 | /* Ognjen Nastic <ognjen@logosoft.ba> UNTESTED */ | 1079 | /* Ognjen Nastic <ognjen@logosoft.ba> UNTESTED */ |
| 1076 | .name = "Manli MuchTV M-TV001/Behold TV 401", | 1080 | .name = "Manli MuchTV M-TV001", |
| 1077 | .audio_clock = 0x00200000, | 1081 | .audio_clock = 0x00200000, |
| 1078 | .tuner_type = TUNER_PHILIPS_PAL, | 1082 | .tuner_type = TUNER_PHILIPS_PAL, |
| 1079 | .radio_type = UNSET, | 1083 | .radio_type = UNSET, |
| @@ -2195,6 +2199,8 @@ struct saa7134_board saa7134_boards[] = { | |||
| 2195 | }, | 2199 | }, |
| 2196 | [SAA7134_BOARD_BEHOLD_409FM] = { | 2200 | [SAA7134_BOARD_BEHOLD_409FM] = { |
| 2197 | /* <http://tuner.beholder.ru>, Sergey <skiv@orel.ru> */ | 2201 | /* <http://tuner.beholder.ru>, Sergey <skiv@orel.ru> */ |
| 2202 | /* Beholder Intl. Ltd. 2008 */ | ||
| 2203 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 2198 | .name = "Beholder BeholdTV 409 FM", | 2204 | .name = "Beholder BeholdTV 409 FM", |
| 2199 | .audio_clock = 0x00187de7, | 2205 | .audio_clock = 0x00187de7, |
| 2200 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, | 2206 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, |
| @@ -2202,6 +2208,7 @@ struct saa7134_board saa7134_boards[] = { | |||
| 2202 | .tuner_addr = ADDR_UNSET, | 2208 | .tuner_addr = ADDR_UNSET, |
| 2203 | .radio_addr = ADDR_UNSET, | 2209 | .radio_addr = ADDR_UNSET, |
| 2204 | .tda9887_conf = TDA9887_PRESENT, | 2210 | .tda9887_conf = TDA9887_PRESENT, |
| 2211 | .gpiomask = 0x00008000, | ||
| 2205 | .inputs = {{ | 2212 | .inputs = {{ |
| 2206 | .name = name_tv, | 2213 | .name = name_tv, |
| 2207 | .vmux = 3, | 2214 | .vmux = 3, |
| @@ -2908,15 +2915,13 @@ struct saa7134_board saa7134_boards[] = { | |||
| 2908 | }}, | 2915 | }}, |
| 2909 | }, | 2916 | }, |
| 2910 | [SAA7134_BOARD_MD7134_BRIDGE_2] = { | 2917 | [SAA7134_BOARD_MD7134_BRIDGE_2] = { |
| 2911 | /* This card has two saa7134 chips on it, | 2918 | /* The second saa7134 on this card only serves as DVB-S host bridge */ |
| 2912 | but only one of them is currently working. | ||
| 2913 | The programming for the primary decoder is | ||
| 2914 | in SAA7134_BOARD_MD7134 */ | ||
| 2915 | .name = "Medion 7134 Bridge #2", | 2919 | .name = "Medion 7134 Bridge #2", |
| 2916 | .audio_clock = 0x00187de7, | 2920 | .audio_clock = 0x00187de7, |
| 2917 | .radio_type = UNSET, | 2921 | .radio_type = UNSET, |
| 2918 | .tuner_addr = ADDR_UNSET, | 2922 | .tuner_addr = ADDR_UNSET, |
| 2919 | .radio_addr = ADDR_UNSET, | 2923 | .radio_addr = ADDR_UNSET, |
| 2924 | .mpeg = SAA7134_MPEG_DVB, | ||
| 2920 | }, | 2925 | }, |
| 2921 | [SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS] = { | 2926 | [SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS] = { |
| 2922 | .name = "LifeView FlyDVB-T Hybrid Cardbus/MSI TV @nywhere A/D NB", | 2927 | .name = "LifeView FlyDVB-T Hybrid Cardbus/MSI TV @nywhere A/D NB", |
| @@ -3330,7 +3335,7 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3330 | /* Juan Pablo Sormani <sorman@gmail.com> */ | 3335 | /* Juan Pablo Sormani <sorman@gmail.com> */ |
| 3331 | .name = "Encore ENLTV-FM", | 3336 | .name = "Encore ENLTV-FM", |
| 3332 | .audio_clock = 0x00200000, | 3337 | .audio_clock = 0x00200000, |
| 3333 | .tuner_type = TUNER_PHILIPS_ATSC, | 3338 | .tuner_type = TUNER_PHILIPS_FCV1236D, |
| 3334 | .radio_type = UNSET, | 3339 | .radio_type = UNSET, |
| 3335 | .tuner_addr = ADDR_UNSET, | 3340 | .tuner_addr = ADDR_UNSET, |
| 3336 | .radio_addr = ADDR_UNSET, | 3341 | .radio_addr = ADDR_UNSET, |
| @@ -3575,12 +3580,15 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3575 | }}, | 3580 | }}, |
| 3576 | }, | 3581 | }, |
| 3577 | [SAA7134_BOARD_BEHOLD_401] = { | 3582 | [SAA7134_BOARD_BEHOLD_401] = { |
| 3583 | /* Beholder Intl. Ltd. 2008 */ | ||
| 3584 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 3578 | .name = "Beholder BeholdTV 401", | 3585 | .name = "Beholder BeholdTV 401", |
| 3579 | .audio_clock = 0x00187de7, | 3586 | .audio_clock = 0x00187de7, |
| 3580 | .tuner_type = TUNER_PHILIPS_FQ1216ME, | 3587 | .tuner_type = TUNER_PHILIPS_FQ1216ME, |
| 3581 | .radio_type = UNSET, | 3588 | .radio_type = UNSET, |
| 3582 | .tuner_addr = ADDR_UNSET, | 3589 | .tuner_addr = ADDR_UNSET, |
| 3583 | .radio_addr = ADDR_UNSET, | 3590 | .radio_addr = ADDR_UNSET, |
| 3591 | .gpiomask = 0x00008000, | ||
| 3584 | .inputs = {{ | 3592 | .inputs = {{ |
| 3585 | .name = name_svideo, | 3593 | .name = name_svideo, |
| 3586 | .vmux = 8, | 3594 | .vmux = 8, |
| @@ -3601,12 +3609,15 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3601 | }, | 3609 | }, |
| 3602 | }, | 3610 | }, |
| 3603 | [SAA7134_BOARD_BEHOLD_403] = { | 3611 | [SAA7134_BOARD_BEHOLD_403] = { |
| 3612 | /* Beholder Intl. Ltd. 2008 */ | ||
| 3613 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 3604 | .name = "Beholder BeholdTV 403", | 3614 | .name = "Beholder BeholdTV 403", |
| 3605 | .audio_clock = 0x00187de7, | 3615 | .audio_clock = 0x00187de7, |
| 3606 | .tuner_type = TUNER_PHILIPS_FQ1216ME, | 3616 | .tuner_type = TUNER_PHILIPS_FQ1216ME, |
| 3607 | .radio_type = UNSET, | 3617 | .radio_type = UNSET, |
| 3608 | .tuner_addr = ADDR_UNSET, | 3618 | .tuner_addr = ADDR_UNSET, |
| 3609 | .radio_addr = ADDR_UNSET, | 3619 | .radio_addr = ADDR_UNSET, |
| 3620 | .gpiomask = 0x00008000, | ||
| 3610 | .inputs = {{ | 3621 | .inputs = {{ |
| 3611 | .name = name_svideo, | 3622 | .name = name_svideo, |
| 3612 | .vmux = 8, | 3623 | .vmux = 8, |
| @@ -3623,12 +3634,15 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3623 | }}, | 3634 | }}, |
| 3624 | }, | 3635 | }, |
| 3625 | [SAA7134_BOARD_BEHOLD_403FM] = { | 3636 | [SAA7134_BOARD_BEHOLD_403FM] = { |
| 3637 | /* Beholder Intl. Ltd. 2008 */ | ||
| 3638 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 3626 | .name = "Beholder BeholdTV 403 FM", | 3639 | .name = "Beholder BeholdTV 403 FM", |
| 3627 | .audio_clock = 0x00187de7, | 3640 | .audio_clock = 0x00187de7, |
| 3628 | .tuner_type = TUNER_PHILIPS_FQ1216ME, | 3641 | .tuner_type = TUNER_PHILIPS_FQ1216ME, |
| 3629 | .radio_type = UNSET, | 3642 | .radio_type = UNSET, |
| 3630 | .tuner_addr = ADDR_UNSET, | 3643 | .tuner_addr = ADDR_UNSET, |
| 3631 | .radio_addr = ADDR_UNSET, | 3644 | .radio_addr = ADDR_UNSET, |
| 3645 | .gpiomask = 0x00008000, | ||
| 3632 | .inputs = {{ | 3646 | .inputs = {{ |
| 3633 | .name = name_svideo, | 3647 | .name = name_svideo, |
| 3634 | .vmux = 8, | 3648 | .vmux = 8, |
| @@ -3649,6 +3663,8 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3649 | }, | 3663 | }, |
| 3650 | }, | 3664 | }, |
| 3651 | [SAA7134_BOARD_BEHOLD_405] = { | 3665 | [SAA7134_BOARD_BEHOLD_405] = { |
| 3666 | /* Beholder Intl. Ltd. 2008 */ | ||
| 3667 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 3652 | .name = "Beholder BeholdTV 405", | 3668 | .name = "Beholder BeholdTV 405", |
| 3653 | .audio_clock = 0x00187de7, | 3669 | .audio_clock = 0x00187de7, |
| 3654 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, | 3670 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, |
| @@ -3656,6 +3672,7 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3656 | .tuner_addr = ADDR_UNSET, | 3672 | .tuner_addr = ADDR_UNSET, |
| 3657 | .radio_addr = ADDR_UNSET, | 3673 | .radio_addr = ADDR_UNSET, |
| 3658 | .tda9887_conf = TDA9887_PRESENT, | 3674 | .tda9887_conf = TDA9887_PRESENT, |
| 3675 | .gpiomask = 0x00008000, | ||
| 3659 | .inputs = {{ | 3676 | .inputs = {{ |
| 3660 | .name = name_svideo, | 3677 | .name = name_svideo, |
| 3661 | .vmux = 8, | 3678 | .vmux = 8, |
| @@ -3673,6 +3690,8 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3673 | }, | 3690 | }, |
| 3674 | [SAA7134_BOARD_BEHOLD_405FM] = { | 3691 | [SAA7134_BOARD_BEHOLD_405FM] = { |
| 3675 | /* Sergey <skiv@orel.ru> */ | 3692 | /* Sergey <skiv@orel.ru> */ |
| 3693 | /* Beholder Intl. Ltd. 2008 */ | ||
| 3694 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 3676 | .name = "Beholder BeholdTV 405 FM", | 3695 | .name = "Beholder BeholdTV 405 FM", |
| 3677 | .audio_clock = 0x00187de7, | 3696 | .audio_clock = 0x00187de7, |
| 3678 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, | 3697 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, |
| @@ -3680,6 +3699,7 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3680 | .tuner_addr = ADDR_UNSET, | 3699 | .tuner_addr = ADDR_UNSET, |
| 3681 | .radio_addr = ADDR_UNSET, | 3700 | .radio_addr = ADDR_UNSET, |
| 3682 | .tda9887_conf = TDA9887_PRESENT, | 3701 | .tda9887_conf = TDA9887_PRESENT, |
| 3702 | .gpiomask = 0x00008000, | ||
| 3683 | .inputs = {{ | 3703 | .inputs = {{ |
| 3684 | .name = name_svideo, | 3704 | .name = name_svideo, |
| 3685 | .vmux = 8, | 3705 | .vmux = 8, |
| @@ -3700,6 +3720,8 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3700 | }, | 3720 | }, |
| 3701 | }, | 3721 | }, |
| 3702 | [SAA7134_BOARD_BEHOLD_407] = { | 3722 | [SAA7134_BOARD_BEHOLD_407] = { |
| 3723 | /* Beholder Intl. Ltd. 2008 */ | ||
| 3724 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 3703 | .name = "Beholder BeholdTV 407", | 3725 | .name = "Beholder BeholdTV 407", |
| 3704 | .audio_clock = 0x00187de7, | 3726 | .audio_clock = 0x00187de7, |
| 3705 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, | 3727 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, |
| @@ -3707,7 +3729,7 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3707 | .tuner_addr = ADDR_UNSET, | 3729 | .tuner_addr = ADDR_UNSET, |
| 3708 | .radio_addr = ADDR_UNSET, | 3730 | .radio_addr = ADDR_UNSET, |
| 3709 | .tda9887_conf = TDA9887_PRESENT, | 3731 | .tda9887_conf = TDA9887_PRESENT, |
| 3710 | .gpiomask = 0xc0c000, | 3732 | .gpiomask = 0x00008000, |
| 3711 | .inputs = {{ | 3733 | .inputs = {{ |
| 3712 | .name = name_svideo, | 3734 | .name = name_svideo, |
| 3713 | .vmux = 8, | 3735 | .vmux = 8, |
| @@ -3727,6 +3749,8 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3727 | }}, | 3749 | }}, |
| 3728 | }, | 3750 | }, |
| 3729 | [SAA7134_BOARD_BEHOLD_407FM] = { | 3751 | [SAA7134_BOARD_BEHOLD_407FM] = { |
| 3752 | /* Beholder Intl. Ltd. 2008 */ | ||
| 3753 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 3730 | .name = "Beholder BeholdTV 407 FM", | 3754 | .name = "Beholder BeholdTV 407 FM", |
| 3731 | .audio_clock = 0x00187de7, | 3755 | .audio_clock = 0x00187de7, |
| 3732 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, | 3756 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, |
| @@ -3734,7 +3758,7 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3734 | .tuner_addr = ADDR_UNSET, | 3758 | .tuner_addr = ADDR_UNSET, |
| 3735 | .radio_addr = ADDR_UNSET, | 3759 | .radio_addr = ADDR_UNSET, |
| 3736 | .tda9887_conf = TDA9887_PRESENT, | 3760 | .tda9887_conf = TDA9887_PRESENT, |
| 3737 | .gpiomask = 0xc0c000, | 3761 | .gpiomask = 0x00008000, |
| 3738 | .inputs = {{ | 3762 | .inputs = {{ |
| 3739 | .name = name_svideo, | 3763 | .name = name_svideo, |
| 3740 | .vmux = 8, | 3764 | .vmux = 8, |
| @@ -3759,6 +3783,8 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3759 | }, | 3783 | }, |
| 3760 | }, | 3784 | }, |
| 3761 | [SAA7134_BOARD_BEHOLD_409] = { | 3785 | [SAA7134_BOARD_BEHOLD_409] = { |
| 3786 | /* Beholder Intl. Ltd. 2008 */ | ||
| 3787 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 3762 | .name = "Beholder BeholdTV 409", | 3788 | .name = "Beholder BeholdTV 409", |
| 3763 | .audio_clock = 0x00187de7, | 3789 | .audio_clock = 0x00187de7, |
| 3764 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, | 3790 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, |
| @@ -3766,6 +3792,7 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3766 | .tuner_addr = ADDR_UNSET, | 3792 | .tuner_addr = ADDR_UNSET, |
| 3767 | .radio_addr = ADDR_UNSET, | 3793 | .radio_addr = ADDR_UNSET, |
| 3768 | .tda9887_conf = TDA9887_PRESENT, | 3794 | .tda9887_conf = TDA9887_PRESENT, |
| 3795 | .gpiomask = 0x00008000, | ||
| 3769 | .inputs = {{ | 3796 | .inputs = {{ |
| 3770 | .name = name_tv, | 3797 | .name = name_tv, |
| 3771 | .vmux = 3, | 3798 | .vmux = 3, |
| @@ -3782,6 +3809,8 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3782 | }}, | 3809 | }}, |
| 3783 | }, | 3810 | }, |
| 3784 | [SAA7134_BOARD_BEHOLD_505FM] = { | 3811 | [SAA7134_BOARD_BEHOLD_505FM] = { |
| 3812 | /* Beholder Intl. Ltd. 2008 */ | ||
| 3813 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 3785 | .name = "Beholder BeholdTV 505 FM/RDS", | 3814 | .name = "Beholder BeholdTV 505 FM/RDS", |
| 3786 | .audio_clock = 0x00200000, | 3815 | .audio_clock = 0x00200000, |
| 3787 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, | 3816 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, |
| @@ -3789,6 +3818,7 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3789 | .tuner_addr = ADDR_UNSET, | 3818 | .tuner_addr = ADDR_UNSET, |
| 3790 | .radio_addr = ADDR_UNSET, | 3819 | .radio_addr = ADDR_UNSET, |
| 3791 | .tda9887_conf = TDA9887_PRESENT, | 3820 | .tda9887_conf = TDA9887_PRESENT, |
| 3821 | .gpiomask = 0x00008000, | ||
| 3792 | .inputs = {{ | 3822 | .inputs = {{ |
| 3793 | .name = name_tv, | 3823 | .name = name_tv, |
| 3794 | .vmux = 3, | 3824 | .vmux = 3, |
| @@ -3813,6 +3843,8 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3813 | }, | 3843 | }, |
| 3814 | }, | 3844 | }, |
| 3815 | [SAA7134_BOARD_BEHOLD_507_9FM] = { | 3845 | [SAA7134_BOARD_BEHOLD_507_9FM] = { |
| 3846 | /* Beholder Intl. Ltd. 2008 */ | ||
| 3847 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 3816 | .name = "Beholder BeholdTV 507 FM/RDS / BeholdTV 509 FM", | 3848 | .name = "Beholder BeholdTV 507 FM/RDS / BeholdTV 509 FM", |
| 3817 | .audio_clock = 0x00187de7, | 3849 | .audio_clock = 0x00187de7, |
| 3818 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, | 3850 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, |
| @@ -3820,6 +3852,7 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3820 | .tuner_addr = ADDR_UNSET, | 3852 | .tuner_addr = ADDR_UNSET, |
| 3821 | .radio_addr = ADDR_UNSET, | 3853 | .radio_addr = ADDR_UNSET, |
| 3822 | .tda9887_conf = TDA9887_PRESENT, | 3854 | .tda9887_conf = TDA9887_PRESENT, |
| 3855 | .gpiomask = 0x00008000, | ||
| 3823 | .inputs = {{ | 3856 | .inputs = {{ |
| 3824 | .name = name_tv, | 3857 | .name = name_tv, |
| 3825 | .vmux = 3, | 3858 | .vmux = 3, |
| @@ -3840,6 +3873,8 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3840 | }, | 3873 | }, |
| 3841 | }, | 3874 | }, |
| 3842 | [SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM] = { | 3875 | [SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM] = { |
| 3876 | /* Beholder Intl. Ltd. 2008 */ | ||
| 3877 | /*Dmitry Belimov <d.belimov@gmail.com> */ | ||
| 3843 | .name = "Beholder BeholdTV Columbus TVFM", | 3878 | .name = "Beholder BeholdTV Columbus TVFM", |
| 3844 | .audio_clock = 0x00187de7, | 3879 | .audio_clock = 0x00187de7, |
| 3845 | .tuner_type = TUNER_ALPS_TSBE5_PAL, | 3880 | .tuner_type = TUNER_ALPS_TSBE5_PAL, |
| @@ -3847,23 +3882,28 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3847 | .tuner_addr = ADDR_UNSET, | 3882 | .tuner_addr = ADDR_UNSET, |
| 3848 | .radio_addr = ADDR_UNSET, | 3883 | .radio_addr = ADDR_UNSET, |
| 3849 | .tda9887_conf = TDA9887_PRESENT, | 3884 | .tda9887_conf = TDA9887_PRESENT, |
| 3885 | .gpiomask = 0x000A8004, | ||
| 3850 | .inputs = {{ | 3886 | .inputs = {{ |
| 3851 | .name = name_tv, | 3887 | .name = name_tv, |
| 3852 | .vmux = 3, | 3888 | .vmux = 3, |
| 3853 | .amux = TV, | 3889 | .amux = TV, |
| 3854 | .tv = 1, | 3890 | .tv = 1, |
| 3855 | },{ | 3891 | .gpio = 0x000A8004, |
| 3892 | }, { | ||
| 3856 | .name = name_comp1, | 3893 | .name = name_comp1, |
| 3857 | .vmux = 1, | 3894 | .vmux = 1, |
| 3858 | .amux = LINE1, | 3895 | .amux = LINE1, |
| 3859 | },{ | 3896 | .gpio = 0x000A8000, |
| 3897 | }, { | ||
| 3860 | .name = name_svideo, | 3898 | .name = name_svideo, |
| 3861 | .vmux = 8, | 3899 | .vmux = 8, |
| 3862 | .amux = LINE1, | 3900 | .amux = LINE1, |
| 3863 | }}, | 3901 | .gpio = 0x000A8000, |
| 3902 | } }, | ||
| 3864 | .radio = { | 3903 | .radio = { |
| 3865 | .name = name_radio, | 3904 | .name = name_radio, |
| 3866 | .amux = LINE2, | 3905 | .amux = LINE2, |
| 3906 | .gpio = 0x000A8000, | ||
| 3867 | }, | 3907 | }, |
| 3868 | }, | 3908 | }, |
| 3869 | [SAA7134_BOARD_BEHOLD_607_9FM] = { | 3909 | [SAA7134_BOARD_BEHOLD_607_9FM] = { |
| @@ -3992,6 +4032,221 @@ struct saa7134_board saa7134_boards[] = { | |||
| 3992 | .gpio = 0x6000, | 4032 | .gpio = 0x6000, |
| 3993 | }, | 4033 | }, |
| 3994 | }, | 4034 | }, |
| 4035 | [SAA7134_BOARD_PHILIPS_SNAKE] = { | ||
| 4036 | .name = "NXP Snake DVB-S reference design", | ||
| 4037 | .audio_clock = 0x00200000, | ||
| 4038 | .tuner_type = TUNER_ABSENT, | ||
| 4039 | .radio_type = UNSET, | ||
| 4040 | .tuner_addr = ADDR_UNSET, | ||
| 4041 | .radio_addr = ADDR_UNSET, | ||
| 4042 | .mpeg = SAA7134_MPEG_DVB, | ||
| 4043 | .inputs = {{ | ||
| 4044 | .name = name_comp1, | ||
| 4045 | .vmux = 3, | ||
| 4046 | .amux = LINE1, | ||
| 4047 | }, { | ||
| 4048 | .name = name_svideo, | ||
| 4049 | .vmux = 8, | ||
| 4050 | .amux = LINE1, | ||
| 4051 | } }, | ||
| 4052 | }, | ||
| 4053 | [SAA7134_BOARD_CREATIX_CTX953] = { | ||
| 4054 | .name = "Medion/Creatix CTX953 Hybrid", | ||
| 4055 | .audio_clock = 0x00187de7, | ||
| 4056 | .tuner_type = TUNER_PHILIPS_TDA8290, | ||
| 4057 | .radio_type = UNSET, | ||
| 4058 | .tuner_addr = ADDR_UNSET, | ||
| 4059 | .radio_addr = ADDR_UNSET, | ||
| 4060 | .tuner_config = 0, | ||
| 4061 | .mpeg = SAA7134_MPEG_DVB, | ||
| 4062 | .inputs = {{ | ||
| 4063 | .name = name_tv, | ||
| 4064 | .vmux = 1, | ||
| 4065 | .amux = TV, | ||
| 4066 | .tv = 1, | ||
| 4067 | }, { | ||
| 4068 | .name = name_comp1, | ||
| 4069 | .vmux = 0, | ||
| 4070 | .amux = LINE1, | ||
| 4071 | }, { | ||
| 4072 | .name = name_svideo, | ||
| 4073 | .vmux = 8, | ||
| 4074 | .amux = LINE1, | ||
| 4075 | } }, | ||
| 4076 | }, | ||
| 4077 | [SAA7134_BOARD_MSI_TVANYWHERE_AD11] = { | ||
| 4078 | .name = "MSI TV@nywhere A/D v1.1", | ||
| 4079 | .audio_clock = 0x00187de7, | ||
| 4080 | .tuner_type = TUNER_PHILIPS_TDA8290, | ||
| 4081 | .radio_type = UNSET, | ||
| 4082 | .tuner_addr = ADDR_UNSET, | ||
| 4083 | .radio_addr = ADDR_UNSET, | ||
| 4084 | .tuner_config = 2, | ||
| 4085 | .mpeg = SAA7134_MPEG_DVB, | ||
| 4086 | .gpiomask = 0x0200000, | ||
| 4087 | .inputs = { { | ||
| 4088 | .name = name_tv, | ||
| 4089 | .vmux = 1, | ||
| 4090 | .amux = TV, | ||
| 4091 | .tv = 1, | ||
| 4092 | }, { | ||
| 4093 | .name = name_comp1, | ||
| 4094 | .vmux = 3, | ||
| 4095 | .amux = LINE1, | ||
| 4096 | }, { | ||
| 4097 | .name = name_svideo, | ||
| 4098 | .vmux = 8, | ||
| 4099 | .amux = LINE1, | ||
| 4100 | } }, | ||
| 4101 | .radio = { | ||
| 4102 | .name = name_radio, | ||
| 4103 | .amux = TV, | ||
| 4104 | .gpio = 0x0200000, | ||
| 4105 | }, | ||
| 4106 | }, | ||
| 4107 | [SAA7134_BOARD_AVERMEDIA_CARDBUS_506] = { | ||
| 4108 | .name = "AVerMedia Cardbus TV/Radio (E506R)", | ||
| 4109 | .audio_clock = 0x187de7, | ||
| 4110 | .tuner_type = TUNER_XC2028, | ||
| 4111 | .radio_type = UNSET, | ||
| 4112 | .tuner_addr = ADDR_UNSET, | ||
| 4113 | .radio_addr = ADDR_UNSET, | ||
| 4114 | /* | ||
| 4115 | TODO: | ||
| 4116 | .mpeg = SAA7134_MPEG_DVB, | ||
| 4117 | */ | ||
| 4118 | |||
| 4119 | .inputs = {{ | ||
| 4120 | .name = name_tv, | ||
| 4121 | .vmux = 1, | ||
| 4122 | .amux = TV, | ||
| 4123 | .tv = 1, | ||
| 4124 | }, { | ||
| 4125 | .name = name_comp1, | ||
| 4126 | .vmux = 3, | ||
| 4127 | .amux = LINE2, | ||
| 4128 | }, { | ||
| 4129 | .name = name_svideo, | ||
| 4130 | .vmux = 8, | ||
| 4131 | .amux = LINE1, | ||
| 4132 | } }, | ||
| 4133 | .radio = { | ||
| 4134 | .name = name_radio, | ||
| 4135 | .amux = TV, | ||
| 4136 | }, | ||
| 4137 | }, | ||
| 4138 | [SAA7134_BOARD_AVERMEDIA_A16D] = { | ||
| 4139 | .name = "AVerMedia Hybrid TV/Radio (A16D)", | ||
| 4140 | .audio_clock = 0x187de7, | ||
| 4141 | .tuner_type = TUNER_XC2028, | ||
| 4142 | .radio_type = UNSET, | ||
| 4143 | .tuner_addr = ADDR_UNSET, | ||
| 4144 | .radio_addr = ADDR_UNSET, | ||
| 4145 | .inputs = {{ | ||
| 4146 | .name = name_tv, | ||
| 4147 | .vmux = 1, | ||
| 4148 | .amux = TV, | ||
| 4149 | .tv = 1, | ||
| 4150 | }, { | ||
| 4151 | .name = name_svideo, | ||
| 4152 | .vmux = 8, | ||
| 4153 | .amux = LINE1, | ||
| 4154 | } }, | ||
| 4155 | .radio = { | ||
| 4156 | .name = name_radio, | ||
| 4157 | .amux = LINE1, | ||
| 4158 | }, | ||
| 4159 | }, | ||
| 4160 | [SAA7134_BOARD_AVERMEDIA_M115] = { | ||
| 4161 | .name = "Avermedia M115", | ||
| 4162 | .audio_clock = 0x187de7, | ||
| 4163 | .tuner_type = TUNER_XC2028, | ||
| 4164 | .radio_type = UNSET, | ||
| 4165 | .tuner_addr = ADDR_UNSET, | ||
| 4166 | .radio_addr = ADDR_UNSET, | ||
| 4167 | .inputs = {{ | ||
| 4168 | .name = name_tv, | ||
| 4169 | .vmux = 1, | ||
| 4170 | .amux = TV, | ||
| 4171 | .tv = 1, | ||
| 4172 | }, { | ||
| 4173 | .name = name_comp1, | ||
| 4174 | .vmux = 3, | ||
| 4175 | .amux = LINE1, | ||
| 4176 | }, { | ||
| 4177 | .name = name_svideo, | ||
| 4178 | .vmux = 8, | ||
| 4179 | .amux = LINE2, | ||
| 4180 | } }, | ||
| 4181 | }, | ||
| 4182 | [SAA7134_BOARD_VIDEOMATE_T750] = { | ||
| 4183 | /* John Newbigin <jn@it.swin.edu.au> */ | ||
| 4184 | .name = "Compro VideoMate T750", | ||
| 4185 | .audio_clock = 0x00187de7, | ||
| 4186 | .tuner_type = TUNER_XC2028, | ||
| 4187 | .radio_type = UNSET, | ||
| 4188 | .tuner_addr = ADDR_UNSET, | ||
| 4189 | .radio_addr = ADDR_UNSET, | ||
| 4190 | .mpeg = SAA7134_MPEG_DVB, | ||
| 4191 | .inputs = {{ | ||
| 4192 | .name = name_tv, | ||
| 4193 | .vmux = 3, | ||
| 4194 | .amux = TV, | ||
| 4195 | .tv = 1, | ||
| 4196 | }, { | ||
| 4197 | .name = name_comp1, | ||
| 4198 | .vmux = 1, | ||
| 4199 | .amux = LINE2, | ||
| 4200 | }, { | ||
| 4201 | .name = name_svideo, | ||
| 4202 | .vmux = 8, | ||
| 4203 | .amux = LINE2, | ||
| 4204 | } }, | ||
| 4205 | .radio = { | ||
| 4206 | .name = name_radio, | ||
| 4207 | .amux = TV, | ||
| 4208 | } | ||
| 4209 | }, | ||
| 4210 | [SAA7134_BOARD_AVERMEDIA_A700_PRO] = { | ||
| 4211 | /* Matthias Schwarzott <zzam@gentoo.org> */ | ||
| 4212 | .name = "Avermedia DVB-S Pro A700", | ||
| 4213 | .audio_clock = 0x00187de7, | ||
| 4214 | .tuner_type = TUNER_ABSENT, | ||
| 4215 | .radio_type = UNSET, | ||
| 4216 | .tuner_addr = ADDR_UNSET, | ||
| 4217 | .radio_addr = ADDR_UNSET, | ||
| 4218 | /* no DVB support for now */ | ||
| 4219 | /* .mpeg = SAA7134_MPEG_DVB, */ | ||
| 4220 | .inputs = { { | ||
| 4221 | .name = name_comp, | ||
| 4222 | .vmux = 1, | ||
| 4223 | .amux = LINE1, | ||
| 4224 | }, { | ||
| 4225 | .name = name_svideo, | ||
| 4226 | .vmux = 6, | ||
| 4227 | .amux = LINE1, | ||
| 4228 | } }, | ||
| 4229 | }, | ||
| 4230 | [SAA7134_BOARD_AVERMEDIA_A700_HYBRID] = { | ||
| 4231 | /* Matthias Schwarzott <zzam@gentoo.org> */ | ||
| 4232 | .name = "Avermedia DVB-S Hybrid+FM A700", | ||
| 4233 | .audio_clock = 0x00187de7, | ||
| 4234 | .tuner_type = TUNER_ABSENT, /* TUNER_XC2028 */ | ||
| 4235 | .radio_type = UNSET, | ||
| 4236 | .tuner_addr = ADDR_UNSET, | ||
| 4237 | .radio_addr = ADDR_UNSET, | ||
| 4238 | /* no DVB support for now */ | ||
| 4239 | /* .mpeg = SAA7134_MPEG_DVB, */ | ||
| 4240 | .inputs = { { | ||
| 4241 | .name = name_comp, | ||
| 4242 | .vmux = 1, | ||
| 4243 | .amux = LINE1, | ||
| 4244 | }, { | ||
| 4245 | .name = name_svideo, | ||
| 4246 | .vmux = 6, | ||
| 4247 | .amux = LINE1, | ||
| 4248 | } }, | ||
| 4249 | }, | ||
| 3995 | }; | 4250 | }; |
| 3996 | 4251 | ||
| 3997 | const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); | 4252 | const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); |
| @@ -4224,6 +4479,18 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
| 4224 | .driver_data = SAA7134_BOARD_MD2819, | 4479 | .driver_data = SAA7134_BOARD_MD2819, |
| 4225 | },{ | 4480 | },{ |
| 4226 | .vendor = PCI_VENDOR_ID_PHILIPS, | 4481 | .vendor = PCI_VENDOR_ID_PHILIPS, |
| 4482 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
| 4483 | .subvendor = 0x1461, /* Avermedia Technologies Inc */ | ||
| 4484 | .subdevice = 0xa7a1, | ||
| 4485 | .driver_data = SAA7134_BOARD_AVERMEDIA_A700_PRO, | ||
| 4486 | }, { | ||
| 4487 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
| 4488 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
| 4489 | .subvendor = 0x1461, /* Avermedia Technologies Inc */ | ||
| 4490 | .subdevice = 0xa7a2, | ||
| 4491 | .driver_data = SAA7134_BOARD_AVERMEDIA_A700_HYBRID, | ||
| 4492 | }, { | ||
| 4493 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
| 4227 | .device = PCI_DEVICE_ID_PHILIPS_SAA7130, | 4494 | .device = PCI_DEVICE_ID_PHILIPS_SAA7130, |
| 4228 | .subvendor = 0x1461, /* Avermedia Technologies Inc */ | 4495 | .subvendor = 0x1461, /* Avermedia Technologies Inc */ |
| 4229 | .subdevice = 0x2115, | 4496 | .subdevice = 0x2115, |
| @@ -4942,7 +5209,43 @@ struct pci_device_id saa7134_pci_tbl[] = { | |||
| 4942 | .subvendor = 0x1822, /*Twinhan Technology Co. Ltd*/ | 5209 | .subvendor = 0x1822, /*Twinhan Technology Co. Ltd*/ |
| 4943 | .subdevice = 0x0022, | 5210 | .subdevice = 0x0022, |
| 4944 | .driver_data = SAA7134_BOARD_TWINHAN_DTV_DVB_3056, | 5211 | .driver_data = SAA7134_BOARD_TWINHAN_DTV_DVB_3056, |
| 5212 | }, { | ||
| 5213 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
| 5214 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
| 5215 | .subvendor = 0x16be, | ||
| 5216 | .subdevice = 0x0010, /* Medion version CTX953_V.1.4.3 */ | ||
| 5217 | .driver_data = SAA7134_BOARD_CREATIX_CTX953, | ||
| 5218 | }, { | ||
| 5219 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
| 5220 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
| 5221 | .subvendor = 0x1462, /* MSI */ | ||
| 5222 | .subdevice = 0x8625, /* TV@nywhere A/D v1.1 */ | ||
| 5223 | .driver_data = SAA7134_BOARD_MSI_TVANYWHERE_AD11, | ||
| 4945 | },{ | 5224 | },{ |
| 5225 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
| 5226 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
| 5227 | .subvendor = 0x1461, /* Avermedia Technologies Inc */ | ||
| 5228 | .subdevice = 0xf436, | ||
| 5229 | .driver_data = SAA7134_BOARD_AVERMEDIA_CARDBUS_506, | ||
| 5230 | }, { | ||
| 5231 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
| 5232 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
| 5233 | .subvendor = 0x1461, /* Avermedia Technologies Inc */ | ||
| 5234 | .subdevice = 0xf936, | ||
| 5235 | .driver_data = SAA7134_BOARD_AVERMEDIA_A16D, | ||
| 5236 | }, { | ||
| 5237 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
| 5238 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
| 5239 | .subvendor = 0x1461, /* Avermedia Technologies Inc */ | ||
| 5240 | .subdevice = 0xa836, | ||
| 5241 | .driver_data = SAA7134_BOARD_AVERMEDIA_M115, | ||
| 5242 | }, { | ||
| 5243 | .vendor = PCI_VENDOR_ID_PHILIPS, | ||
| 5244 | .device = PCI_DEVICE_ID_PHILIPS_SAA7133, | ||
| 5245 | .subvendor = 0x185b, | ||
| 5246 | .subdevice = 0xc900, | ||
| 5247 | .driver_data = SAA7134_BOARD_VIDEOMATE_T750, | ||
| 5248 | }, { | ||
| 4946 | /* --- boards without eeprom + subsystem ID --- */ | 5249 | /* --- boards without eeprom + subsystem ID --- */ |
| 4947 | .vendor = PCI_VENDOR_ID_PHILIPS, | 5250 | .vendor = PCI_VENDOR_ID_PHILIPS, |
| 4948 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, | 5251 | .device = PCI_DEVICE_ID_PHILIPS_SAA7134, |
| @@ -4998,6 +5301,77 @@ static void board_flyvideo(struct saa7134_dev *dev) | |||
| 4998 | dev->name, dev->name, dev->name); | 5301 | dev->name, dev->name, dev->name); |
| 4999 | } | 5302 | } |
| 5000 | 5303 | ||
| 5304 | static int saa7134_xc2028_callback(struct saa7134_dev *dev, | ||
| 5305 | int command, int arg) | ||
| 5306 | { | ||
| 5307 | switch (command) { | ||
| 5308 | case XC2028_TUNER_RESET: | ||
| 5309 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x06e20000, 0x06e20000); | ||
| 5310 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x06a20000, 0x06a20000); | ||
| 5311 | mdelay(250); | ||
| 5312 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x06e20000, 0); | ||
| 5313 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x06a20000, 0); | ||
| 5314 | mdelay(250); | ||
| 5315 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x06e20000, 0x06e20000); | ||
| 5316 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x06a20000, 0x06a20000); | ||
| 5317 | mdelay(250); | ||
| 5318 | saa_andorl(SAA7133_ANALOG_IO_SELECT >> 2, 0x02, 0x02); | ||
| 5319 | saa_andorl(SAA7134_ANALOG_IN_CTRL1 >> 2, 0x81, 0x81); | ||
| 5320 | saa_andorl(SAA7134_AUDIO_CLOCK0 >> 2, 0x03187de7, 0x03187de7); | ||
| 5321 | saa_andorl(SAA7134_AUDIO_PLL_CTRL >> 2, 0x03, 0x03); | ||
| 5322 | saa_andorl(SAA7134_AUDIO_CLOCKS_PER_FIELD0 >> 2, | ||
| 5323 | 0x0001e000, 0x0001e000); | ||
| 5324 | return 0; | ||
| 5325 | } | ||
| 5326 | return -EINVAL; | ||
| 5327 | } | ||
| 5328 | |||
| 5329 | |||
| 5330 | static int saa7134_tda8290_callback(struct saa7134_dev *dev, | ||
| 5331 | int command, int arg) | ||
| 5332 | { | ||
| 5333 | u8 sync_control; | ||
| 5334 | |||
| 5335 | switch (command) { | ||
| 5336 | case 0: /* switch LNA gain through GPIO 22*/ | ||
| 5337 | saa7134_set_gpio(dev, 22, arg) ; | ||
| 5338 | break; | ||
| 5339 | case 1: /* vsync output at GPIO22. 50 / 60Hz */ | ||
| 5340 | saa_andorb(SAA7134_VIDEO_PORT_CTRL3, 0x80, 0x80); | ||
| 5341 | saa_andorb(SAA7134_VIDEO_PORT_CTRL6, 0x0f, 0x03); | ||
| 5342 | if (arg == 1) | ||
| 5343 | sync_control = 11; | ||
| 5344 | else | ||
| 5345 | sync_control = 17; | ||
| 5346 | saa_writeb(SAA7134_VGATE_START, sync_control); | ||
| 5347 | saa_writeb(SAA7134_VGATE_STOP, sync_control + 1); | ||
| 5348 | saa_andorb(SAA7134_MISC_VGATE_MSB, 0x03, 0x00); | ||
| 5349 | break; | ||
| 5350 | default: | ||
| 5351 | return -EINVAL; | ||
| 5352 | } | ||
| 5353 | |||
| 5354 | return 0; | ||
| 5355 | } | ||
| 5356 | |||
| 5357 | int saa7134_tuner_callback(void *priv, int command, int arg) | ||
| 5358 | { | ||
| 5359 | struct saa7134_dev *dev = priv; | ||
| 5360 | if (dev != NULL) { | ||
| 5361 | switch (dev->tuner_type) { | ||
| 5362 | case TUNER_PHILIPS_TDA8290: | ||
| 5363 | return saa7134_tda8290_callback(dev, command, arg); | ||
| 5364 | case TUNER_XC2028: | ||
| 5365 | return saa7134_xc2028_callback(dev, command, arg); | ||
| 5366 | } | ||
| 5367 | } else { | ||
| 5368 | printk(KERN_ERR "saa7134: Error - device struct undefined.\n"); | ||
| 5369 | return -EINVAL; | ||
| 5370 | } | ||
| 5371 | return -EINVAL; | ||
| 5372 | } | ||
| 5373 | EXPORT_SYMBOL(saa7134_tuner_callback); | ||
| 5374 | |||
| 5001 | /* ----------------------------------------------------------- */ | 5375 | /* ----------------------------------------------------------- */ |
| 5002 | 5376 | ||
| 5003 | static void hauppauge_eeprom(struct saa7134_dev *dev, u8 *eeprom_data) | 5377 | static void hauppauge_eeprom(struct saa7134_dev *dev, u8 *eeprom_data) |
| @@ -5067,6 +5441,7 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
| 5067 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: | 5441 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
| 5068 | case SAA7134_BOARD_VIDEOMATE_DVBT_200: | 5442 | case SAA7134_BOARD_VIDEOMATE_DVBT_200: |
| 5069 | case SAA7134_BOARD_VIDEOMATE_DVBT_200A: | 5443 | case SAA7134_BOARD_VIDEOMATE_DVBT_200A: |
| 5444 | case SAA7134_BOARD_VIDEOMATE_T750: | ||
| 5070 | case SAA7134_BOARD_MANLI_MTV001: | 5445 | case SAA7134_BOARD_MANLI_MTV001: |
| 5071 | case SAA7134_BOARD_MANLI_MTV002: | 5446 | case SAA7134_BOARD_MANLI_MTV002: |
| 5072 | case SAA7134_BOARD_BEHOLD_409FM: | 5447 | case SAA7134_BOARD_BEHOLD_409FM: |
| @@ -5133,11 +5508,29 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
| 5133 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x08000000, 0x00000000); | 5508 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x08000000, 0x00000000); |
| 5134 | break; | 5509 | break; |
| 5135 | case SAA7134_BOARD_AVERMEDIA_CARDBUS: | 5510 | case SAA7134_BOARD_AVERMEDIA_CARDBUS: |
| 5136 | case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: | 5511 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: |
| 5512 | case SAA7134_BOARD_AVERMEDIA_M115: | ||
| 5513 | case SAA7134_BOARD_AVERMEDIA_A16D: | ||
| 5514 | /* power-down tuner chip */ | ||
| 5515 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0); | ||
| 5516 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0xffffffff, 0); | ||
| 5517 | msleep(10); | ||
| 5137 | /* power-up tuner chip */ | 5518 | /* power-up tuner chip */ |
| 5138 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff); | 5519 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0xffffffff, 0xffffffff); |
| 5139 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0xffffffff, 0xffffffff); | 5520 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0xffffffff, 0xffffffff); |
| 5140 | msleep(1); | 5521 | msleep(10); |
| 5522 | break; | ||
| 5523 | case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: | ||
| 5524 | /* power-down tuner chip */ | ||
| 5525 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x000A8004, 0x000A8004); | ||
| 5526 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x000A8004, 0); | ||
| 5527 | msleep(10); | ||
| 5528 | /* power-up tuner chip */ | ||
| 5529 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x000A8004, 0x000A8004); | ||
| 5530 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x000A8004, 0x000A8004); | ||
| 5531 | msleep(10); | ||
| 5532 | /* remote via GPIO */ | ||
| 5533 | dev->has_remote = SAA7134_REMOTE_GPIO; | ||
| 5141 | break; | 5534 | break; |
| 5142 | case SAA7134_BOARD_RTD_VFG7350: | 5535 | case SAA7134_BOARD_RTD_VFG7350: |
| 5143 | 5536 | ||
| @@ -5160,7 +5553,6 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
| 5160 | dev->has_remote = SAA7134_REMOTE_I2C; | 5553 | dev->has_remote = SAA7134_REMOTE_I2C; |
| 5161 | break; | 5554 | break; |
| 5162 | case SAA7134_BOARD_AVERMEDIA_A169_B: | 5555 | case SAA7134_BOARD_AVERMEDIA_A169_B: |
| 5163 | case SAA7134_BOARD_MD7134_BRIDGE_2: | ||
| 5164 | printk("%s: %s: dual saa713x broadcast decoders\n" | 5556 | printk("%s: %s: dual saa713x broadcast decoders\n" |
| 5165 | "%s: Sorry, none of the inputs to this chip are supported yet.\n" | 5557 | "%s: Sorry, none of the inputs to this chip are supported yet.\n" |
| 5166 | "%s: Dual decoder functionality is disabled for now, use the other chip.\n", | 5558 | "%s: Dual decoder functionality is disabled for now, use the other chip.\n", |
| @@ -5172,6 +5564,15 @@ int saa7134_board_init1(struct saa7134_dev *dev) | |||
| 5172 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x8c040007, 0x8c040007); | 5564 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x8c040007, 0x8c040007); |
| 5173 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0c0007cd, 0x0c0007cd); | 5565 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x0c0007cd, 0x0c0007cd); |
| 5174 | break; | 5566 | break; |
| 5567 | case SAA7134_BOARD_AVERMEDIA_A700_PRO: | ||
| 5568 | case SAA7134_BOARD_AVERMEDIA_A700_HYBRID: | ||
| 5569 | /* write windows gpio values */ | ||
| 5570 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, 0x80040100, 0x80040100); | ||
| 5571 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, 0x80040100, 0x00040100); | ||
| 5572 | printk("%s: %s: hybrid analog/dvb card\n" | ||
| 5573 | "%s: Sorry, only the analog inputs are supported for now.\n", | ||
| 5574 | dev->name, card(dev).name, dev->name); | ||
| 5575 | break; | ||
| 5175 | } | 5576 | } |
| 5176 | return 0; | 5577 | return 0; |
| 5177 | } | 5578 | } |
| @@ -5200,11 +5601,16 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
| 5200 | dev->tuner_type = saa7134_boards[dev->board].tuner_type; | 5601 | dev->tuner_type = saa7134_boards[dev->board].tuner_type; |
| 5201 | 5602 | ||
| 5202 | if (TUNER_ABSENT != dev->tuner_type) { | 5603 | if (TUNER_ABSENT != dev->tuner_type) { |
| 5203 | tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; | 5604 | tun_setup.mode_mask = T_RADIO | |
| 5204 | tun_setup.type = dev->tuner_type; | 5605 | T_ANALOG_TV | |
| 5205 | tun_setup.addr = ADDR_UNSET; | 5606 | T_DIGITAL_TV; |
| 5607 | tun_setup.type = dev->tuner_type; | ||
| 5608 | tun_setup.addr = ADDR_UNSET; | ||
| 5609 | tun_setup.tuner_callback = saa7134_tuner_callback; | ||
| 5206 | 5610 | ||
| 5207 | saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR, &tun_setup); | 5611 | saa7134_i2c_call_clients(dev, |
| 5612 | TUNER_SET_TYPE_ADDR, | ||
| 5613 | &tun_setup); | ||
| 5208 | } | 5614 | } |
| 5209 | break; | 5615 | break; |
| 5210 | case SAA7134_BOARD_MD7134: | 5616 | case SAA7134_BOARD_MD7134: |
| @@ -5275,14 +5681,25 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
| 5275 | &tda9887_cfg); | 5681 | &tda9887_cfg); |
| 5276 | } | 5682 | } |
| 5277 | 5683 | ||
| 5278 | tun_setup.mode_mask = T_RADIO | T_ANALOG_TV | T_DIGITAL_TV; | 5684 | tun_setup.mode_mask = T_RADIO | |
| 5685 | T_ANALOG_TV | | ||
| 5686 | T_DIGITAL_TV; | ||
| 5279 | tun_setup.type = dev->tuner_type; | 5687 | tun_setup.type = dev->tuner_type; |
| 5280 | tun_setup.addr = ADDR_UNSET; | 5688 | tun_setup.addr = ADDR_UNSET; |
| 5281 | 5689 | ||
| 5282 | saa7134_i2c_call_clients (dev, TUNER_SET_TYPE_ADDR,&tun_setup); | 5690 | saa7134_i2c_call_clients(dev, |
| 5691 | TUNER_SET_TYPE_ADDR, &tun_setup); | ||
| 5283 | } | 5692 | } |
| 5284 | break; | 5693 | break; |
| 5285 | case SAA7134_BOARD_PHILIPS_EUROPA: | 5694 | case SAA7134_BOARD_PHILIPS_EUROPA: |
| 5695 | if (dev->autodetected && (dev->eedata[0x41] == 0x1c)) { | ||
| 5696 | /* Reconfigure board as Snake reference design */ | ||
| 5697 | dev->board = SAA7134_BOARD_PHILIPS_SNAKE; | ||
| 5698 | dev->tuner_type = saa7134_boards[dev->board].tuner_type; | ||
| 5699 | printk(KERN_INFO "%s: Reconfigured board as %s\n", | ||
| 5700 | dev->name, saa7134_boards[dev->board].name); | ||
| 5701 | break; | ||
| 5702 | } | ||
| 5286 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: | 5703 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
| 5287 | case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: | 5704 | case SAA7134_BOARD_ASUS_EUROPA2_HYBRID: |
| 5288 | /* The Philips EUROPA based hybrid boards have the tuner connected through | 5705 | /* The Philips EUROPA based hybrid boards have the tuner connected through |
| @@ -5333,6 +5750,7 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
| 5333 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: | 5750 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: |
| 5334 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: | 5751 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: |
| 5335 | case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: | 5752 | case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: |
| 5753 | case SAA7134_BOARD_CREATIX_CTX953: | ||
| 5336 | /* this is a hybrid board, initialize to analog mode | 5754 | /* this is a hybrid board, initialize to analog mode |
| 5337 | * and configure firmware eeprom address | 5755 | * and configure firmware eeprom address |
| 5338 | */ | 5756 | */ |
| @@ -5402,13 +5820,46 @@ int saa7134_board_init2(struct saa7134_dev *dev) | |||
| 5402 | break; | 5820 | break; |
| 5403 | } | 5821 | } |
| 5404 | break; | 5822 | break; |
| 5823 | case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: | ||
| 5824 | { | ||
| 5825 | struct v4l2_priv_tun_config tea5767_cfg; | ||
| 5826 | struct tea5767_ctrl ctl; | ||
| 5827 | |||
| 5828 | dev->i2c_client.addr = 0xC0; | ||
| 5829 | /* set TEA5767(analog FM) defines */ | ||
| 5830 | memset(&ctl, 0, sizeof(ctl)); | ||
| 5831 | ctl.xtal_freq = TEA5767_HIGH_LO_13MHz; | ||
| 5832 | tea5767_cfg.tuner = TUNER_TEA5767; | ||
| 5833 | tea5767_cfg.priv = &ctl; | ||
| 5834 | saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tea5767_cfg); | ||
| 5835 | } | ||
| 5836 | break; | ||
| 5405 | } | 5837 | } |
| 5838 | |||
| 5839 | if (dev->tuner_type == TUNER_XC2028) { | ||
| 5840 | struct v4l2_priv_tun_config xc2028_cfg; | ||
| 5841 | struct xc2028_ctrl ctl; | ||
| 5842 | |||
| 5843 | memset(&xc2028_cfg, 0, sizeof(ctl)); | ||
| 5844 | memset(&ctl, 0, sizeof(ctl)); | ||
| 5845 | |||
| 5846 | ctl.fname = XC2028_DEFAULT_FIRMWARE; | ||
| 5847 | ctl.max_len = 64; | ||
| 5848 | |||
| 5849 | switch (dev->board) { | ||
| 5850 | case SAA7134_BOARD_AVERMEDIA_A16D: | ||
| 5851 | ctl.demod = XC3028_FE_ZARLINK456; | ||
| 5852 | break; | ||
| 5853 | default: | ||
| 5854 | ctl.demod = XC3028_FE_OREN538; | ||
| 5855 | ctl.mts = 1; | ||
| 5856 | } | ||
| 5857 | |||
| 5858 | xc2028_cfg.tuner = TUNER_XC2028; | ||
| 5859 | xc2028_cfg.priv = &ctl; | ||
| 5860 | |||
| 5861 | saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg); | ||
| 5862 | } | ||
| 5863 | |||
| 5406 | return 0; | 5864 | return 0; |
| 5407 | } | 5865 | } |
| 5408 | |||
| 5409 | /* ----------------------------------------------------------- */ | ||
| 5410 | /* | ||
| 5411 | * Local variables: | ||
| 5412 | * c-basic-offset: 8 | ||
| 5413 | * End: | ||
| 5414 | */ | ||
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c index 58ab163fdbd7..eec127864fe3 100644 --- a/drivers/media/video/saa7134/saa7134-core.c +++ b/drivers/media/video/saa7134/saa7134-core.c | |||
| @@ -42,23 +42,23 @@ MODULE_LICENSE("GPL"); | |||
| 42 | 42 | ||
| 43 | /* ------------------------------------------------------------------ */ | 43 | /* ------------------------------------------------------------------ */ |
| 44 | 44 | ||
| 45 | static unsigned int irq_debug = 0; | 45 | static unsigned int irq_debug; |
| 46 | module_param(irq_debug, int, 0644); | 46 | module_param(irq_debug, int, 0644); |
| 47 | MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]"); | 47 | MODULE_PARM_DESC(irq_debug,"enable debug messages [IRQ handler]"); |
| 48 | 48 | ||
| 49 | static unsigned int core_debug = 0; | 49 | static unsigned int core_debug; |
| 50 | module_param(core_debug, int, 0644); | 50 | module_param(core_debug, int, 0644); |
| 51 | MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); | 51 | MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); |
| 52 | 52 | ||
| 53 | static unsigned int gpio_tracking = 0; | 53 | static unsigned int gpio_tracking; |
| 54 | module_param(gpio_tracking, int, 0644); | 54 | module_param(gpio_tracking, int, 0644); |
| 55 | MODULE_PARM_DESC(gpio_tracking,"enable debug messages [gpio]"); | 55 | MODULE_PARM_DESC(gpio_tracking,"enable debug messages [gpio]"); |
| 56 | 56 | ||
| 57 | static unsigned int alsa = 0; | 57 | static unsigned int alsa; |
| 58 | module_param(alsa, int, 0644); | 58 | module_param(alsa, int, 0644); |
| 59 | MODULE_PARM_DESC(alsa,"enable ALSA DMA sound [dmasound]"); | 59 | MODULE_PARM_DESC(alsa,"enable ALSA DMA sound [dmasound]"); |
| 60 | 60 | ||
| 61 | static unsigned int oss = 0; | 61 | static unsigned int oss; |
| 62 | module_param(oss, int, 0644); | 62 | module_param(oss, int, 0644); |
| 63 | MODULE_PARM_DESC(oss,"enable OSS DMA sound [dmasound]"); | 63 | MODULE_PARM_DESC(oss,"enable OSS DMA sound [dmasound]"); |
| 64 | 64 | ||
| @@ -142,39 +142,6 @@ void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value) | |||
| 142 | } | 142 | } |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | int saa7134_tuner_callback(void *ptr, int command, int arg) | ||
| 146 | { | ||
| 147 | u8 sync_control; | ||
| 148 | struct saa7134_dev *dev = ptr; | ||
| 149 | |||
| 150 | switch (dev->tuner_type) { | ||
| 151 | case TUNER_PHILIPS_TDA8290: | ||
| 152 | switch (command) { | ||
| 153 | case 0: /* switch LNA gain through GPIO 22*/ | ||
| 154 | saa7134_set_gpio(dev, 22, arg) ; | ||
| 155 | break; | ||
| 156 | case 1: /* vsync output at GPIO22. 50 / 60Hz */ | ||
| 157 | dprintk("setting GPIO22 to vsync %d\n", arg); | ||
| 158 | saa_andorb(SAA7134_VIDEO_PORT_CTRL3, 0x80, 0x80); | ||
| 159 | saa_andorb(SAA7134_VIDEO_PORT_CTRL6, 0x0f, 0x03); | ||
| 160 | if (arg == 1) | ||
| 161 | sync_control = 11; | ||
| 162 | else | ||
| 163 | sync_control = 17; | ||
| 164 | saa_writeb(SAA7134_VGATE_START, sync_control); | ||
| 165 | saa_writeb(SAA7134_VGATE_STOP, sync_control + 1); | ||
| 166 | saa_andorb(SAA7134_MISC_VGATE_MSB, 0x03, 0x00); | ||
| 167 | break; | ||
| 168 | default: | ||
| 169 | return -EINVAL; | ||
| 170 | } | ||
| 171 | break; | ||
| 172 | default: | ||
| 173 | return -ENODEV; | ||
| 174 | } | ||
| 175 | return 0; | ||
| 176 | } | ||
| 177 | |||
| 178 | /* ------------------------------------------------------------------ */ | 145 | /* ------------------------------------------------------------------ */ |
| 179 | 146 | ||
| 180 | 147 | ||
| @@ -897,6 +864,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
| 897 | struct saa7134_dev *dev; | 864 | struct saa7134_dev *dev; |
| 898 | struct saa7134_mpeg_ops *mops; | 865 | struct saa7134_mpeg_ops *mops; |
| 899 | int err; | 866 | int err; |
| 867 | int mask; | ||
| 868 | |||
| 869 | if (saa7134_devcount == SAA7134_MAXBOARDS) | ||
| 870 | return -ENOMEM; | ||
| 900 | 871 | ||
| 901 | dev = kzalloc(sizeof(*dev),GFP_KERNEL); | 872 | dev = kzalloc(sizeof(*dev),GFP_KERNEL); |
| 902 | if (NULL == dev) | 873 | if (NULL == dev) |
| @@ -1094,6 +1065,11 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, | |||
| 1094 | if (TUNER_ABSENT != dev->tuner_type) | 1065 | if (TUNER_ABSENT != dev->tuner_type) |
| 1095 | saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); | 1066 | saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); |
| 1096 | 1067 | ||
| 1068 | if (card(dev).gpiomask != 0) { | ||
| 1069 | mask = card(dev).gpiomask; | ||
| 1070 | saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask); | ||
| 1071 | saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, 0); | ||
| 1072 | } | ||
| 1097 | return 0; | 1073 | return 0; |
| 1098 | 1074 | ||
| 1099 | fail4: | 1075 | fail4: |
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c index ea2be9eceeb8..2d16be2259db 100644 --- a/drivers/media/video/saa7134/saa7134-dvb.c +++ b/drivers/media/video/saa7134/saa7134-dvb.c | |||
| @@ -33,33 +33,40 @@ | |||
| 33 | #include "saa7134.h" | 33 | #include "saa7134.h" |
| 34 | #include <media/v4l2-common.h> | 34 | #include <media/v4l2-common.h> |
| 35 | #include "dvb-pll.h" | 35 | #include "dvb-pll.h" |
| 36 | #include <dvb_frontend.h> | ||
| 36 | 37 | ||
| 37 | #include "mt352.h" | 38 | #include "mt352.h" |
| 38 | #include "mt352_priv.h" /* FIXME */ | 39 | #include "mt352_priv.h" /* FIXME */ |
| 39 | #include "tda1004x.h" | 40 | #include "tda1004x.h" |
| 40 | #include "nxt200x.h" | 41 | #include "nxt200x.h" |
| 42 | #include "tuner-xc2028.h" | ||
| 41 | 43 | ||
| 42 | #include "tda10086.h" | 44 | #include "tda10086.h" |
| 43 | #include "tda826x.h" | 45 | #include "tda826x.h" |
| 44 | #include "tda827x.h" | 46 | #include "tda827x.h" |
| 45 | #include "isl6421.h" | 47 | #include "isl6421.h" |
| 48 | #include "isl6405.h" | ||
| 49 | #include "lnbp21.h" | ||
| 50 | #include "tuner-simple.h" | ||
| 46 | 51 | ||
| 47 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); | 52 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
| 48 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
| 49 | 54 | ||
| 50 | static unsigned int antenna_pwr = 0; | 55 | static unsigned int antenna_pwr; |
| 51 | 56 | ||
| 52 | module_param(antenna_pwr, int, 0444); | 57 | module_param(antenna_pwr, int, 0444); |
| 53 | MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)"); | 58 | MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)"); |
| 54 | 59 | ||
| 55 | static int use_frontend = 0; | 60 | static int use_frontend; |
| 56 | module_param(use_frontend, int, 0644); | 61 | module_param(use_frontend, int, 0644); |
| 57 | MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)"); | 62 | MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)"); |
| 58 | 63 | ||
| 59 | static int debug = 0; | 64 | static int debug; |
| 60 | module_param(debug, int, 0644); | 65 | module_param(debug, int, 0644); |
| 61 | MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off)."); | 66 | MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off)."); |
| 62 | 67 | ||
| 68 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | ||
| 69 | |||
| 63 | #define dprintk(fmt, arg...) do { if (debug) \ | 70 | #define dprintk(fmt, arg...) do { if (debug) \ |
| 64 | printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0) | 71 | printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0) |
| 65 | 72 | ||
| @@ -91,7 +98,7 @@ static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on) | |||
| 91 | saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28)); | 98 | saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28)); |
| 92 | udelay(10); | 99 | udelay(10); |
| 93 | ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27); | 100 | ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27); |
| 94 | dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off"); | 101 | dprintk("%s %s\n", __func__, ok ? "on" : "off"); |
| 95 | 102 | ||
| 96 | if (!ok) | 103 | if (!ok) |
| 97 | saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26)); | 104 | saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26)); |
| @@ -111,7 +118,7 @@ static int mt352_pinnacle_init(struct dvb_frontend* fe) | |||
| 111 | static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 }; | 118 | static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 }; |
| 112 | struct saa7134_dev *dev= fe->dvb->priv; | 119 | struct saa7134_dev *dev= fe->dvb->priv; |
| 113 | 120 | ||
| 114 | dprintk("%s called\n", __FUNCTION__); | 121 | dprintk("%s called\n", __func__); |
| 115 | 122 | ||
| 116 | mt352_write(fe, clock_config, sizeof(clock_config)); | 123 | mt352_write(fe, clock_config, sizeof(clock_config)); |
| 117 | udelay(200); | 124 | udelay(200); |
| @@ -146,6 +153,26 @@ static int mt352_aver777_init(struct dvb_frontend* fe) | |||
| 146 | return 0; | 153 | return 0; |
| 147 | } | 154 | } |
| 148 | 155 | ||
| 156 | static int mt352_aver_a16d_init(struct dvb_frontend *fe) | ||
| 157 | { | ||
| 158 | static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d }; | ||
| 159 | static u8 reset [] = { RESET, 0x80 }; | ||
| 160 | static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 }; | ||
| 161 | static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 }; | ||
| 162 | static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 }; | ||
| 163 | |||
| 164 | mt352_write(fe, clock_config, sizeof(clock_config)); | ||
| 165 | udelay(200); | ||
| 166 | mt352_write(fe, reset, sizeof(reset)); | ||
| 167 | mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg)); | ||
| 168 | mt352_write(fe, agc_cfg, sizeof(agc_cfg)); | ||
| 169 | mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg)); | ||
| 170 | |||
| 171 | return 0; | ||
| 172 | } | ||
| 173 | |||
| 174 | |||
| 175 | |||
| 149 | static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe, | 176 | static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe, |
| 150 | struct dvb_frontend_parameters* params) | 177 | struct dvb_frontend_parameters* params) |
| 151 | { | 178 | { |
| @@ -188,6 +215,16 @@ static struct mt352_config avermedia_777 = { | |||
| 188 | .demod_init = mt352_aver777_init, | 215 | .demod_init = mt352_aver777_init, |
| 189 | }; | 216 | }; |
| 190 | 217 | ||
| 218 | static struct mt352_config avermedia_16d = { | ||
| 219 | .demod_address = 0xf, | ||
| 220 | .demod_init = mt352_aver_a16d_init, | ||
| 221 | }; | ||
| 222 | |||
| 223 | static struct mt352_config avermedia_e506r_mt352_dev = { | ||
| 224 | .demod_address = (0x1e >> 1), | ||
| 225 | .no_tuner = 1, | ||
| 226 | }; | ||
| 227 | |||
| 191 | /* ================================================================== | 228 | /* ================================================================== |
| 192 | * tda1004x based DVB-T cards, helper functions | 229 | * tda1004x based DVB-T cards, helper functions |
| 193 | */ | 230 | */ |
| @@ -430,8 +467,6 @@ static struct tda1004x_config philips_europa_config = { | |||
| 430 | .request_firmware = philips_tda1004x_request_firmware | 467 | .request_firmware = philips_tda1004x_request_firmware |
| 431 | }; | 468 | }; |
| 432 | 469 | ||
| 433 | /* ------------------------------------------------------------------ */ | ||
| 434 | |||
| 435 | static struct tda1004x_config medion_cardbus = { | 470 | static struct tda1004x_config medion_cardbus = { |
| 436 | .demod_address = 0x08, | 471 | .demod_address = 0x08, |
| 437 | .invert = 1, | 472 | .invert = 1, |
| @@ -447,47 +482,6 @@ static struct tda1004x_config medion_cardbus = { | |||
| 447 | * tda 1004x based cards with philips silicon tuner | 482 | * tda 1004x based cards with philips silicon tuner |
| 448 | */ | 483 | */ |
| 449 | 484 | ||
| 450 | static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high) | ||
| 451 | { | ||
| 452 | struct saa7134_dev *dev = fe->dvb->priv; | ||
| 453 | struct tda1004x_state *state = fe->demodulator_priv; | ||
| 454 | u8 addr = state->config->i2c_gate; | ||
| 455 | u8 config = state->config->tuner_config; | ||
| 456 | u8 GP00_CF[] = {0x20, 0x01}; | ||
| 457 | u8 GP00_LEV[] = {0x22, 0x00}; | ||
| 458 | |||
| 459 | struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2}; | ||
| 460 | if (config) { | ||
| 461 | if (high) { | ||
| 462 | dprintk("setting LNA to high gain\n"); | ||
| 463 | } else { | ||
| 464 | dprintk("setting LNA to low gain\n"); | ||
| 465 | } | ||
| 466 | } | ||
| 467 | switch (config) { | ||
| 468 | case 0: /* no LNA */ | ||
| 469 | break; | ||
| 470 | case 1: /* switch is GPIO 0 of tda8290 */ | ||
| 471 | case 2: | ||
| 472 | /* turn Vsync off */ | ||
| 473 | saa7134_set_gpio(dev, 22, 0); | ||
| 474 | GP00_LEV[1] = high ? 0 : 1; | ||
| 475 | if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) { | ||
| 476 | wprintk("could not access tda8290 at addr: 0x%02x\n", | ||
| 477 | addr << 1); | ||
| 478 | return; | ||
| 479 | } | ||
| 480 | msg.buf = GP00_LEV; | ||
| 481 | if (config == 2) | ||
| 482 | GP00_LEV[1] = high ? 1 : 0; | ||
| 483 | i2c_transfer(&dev->i2c_adap, &msg, 1); | ||
| 484 | break; | ||
| 485 | case 3: /* switch with GPIO of saa713x */ | ||
| 486 | saa7134_set_gpio(dev, 22, high); | ||
| 487 | break; | ||
| 488 | } | ||
| 489 | } | ||
| 490 | |||
| 491 | static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable) | 485 | static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable) |
| 492 | { | 486 | { |
| 493 | struct tda1004x_state *state = fe->demodulator_priv; | 487 | struct tda1004x_state *state = fe->demodulator_priv; |
| @@ -510,8 +504,6 @@ static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable) | |||
| 510 | return 0; | 504 | return 0; |
| 511 | } | 505 | } |
| 512 | 506 | ||
| 513 | /* ------------------------------------------------------------------ */ | ||
| 514 | |||
| 515 | static int philips_tda827x_tuner_init(struct dvb_frontend *fe) | 507 | static int philips_tda827x_tuner_init(struct dvb_frontend *fe) |
| 516 | { | 508 | { |
| 517 | struct saa7134_dev *dev = fe->dvb->priv; | 509 | struct saa7134_dev *dev = fe->dvb->priv; |
| @@ -546,28 +538,57 @@ static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe) | |||
| 546 | return 0; | 538 | return 0; |
| 547 | } | 539 | } |
| 548 | 540 | ||
| 549 | static struct tda827x_config tda827x_cfg = { | 541 | static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *cdec_conf, |
| 550 | .lna_gain = philips_tda827x_lna_gain, | 542 | struct tda827x_config *tuner_conf) |
| 551 | .init = philips_tda827x_tuner_init, | ||
| 552 | .sleep = philips_tda827x_tuner_sleep | ||
| 553 | }; | ||
| 554 | |||
| 555 | static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf) | ||
| 556 | { | 543 | { |
| 557 | dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap); | 544 | dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap); |
| 558 | if (dev->dvb.frontend) { | 545 | if (dev->dvb.frontend) { |
| 559 | if (tda_conf->i2c_gate) | 546 | if (cdec_conf->i2c_gate) |
| 560 | dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; | 547 | dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; |
| 561 | if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address, | 548 | if (dvb_attach(tda827x_attach, dev->dvb.frontend, cdec_conf->tuner_address, |
| 562 | &dev->i2c_adap,&tda827x_cfg) == NULL) { | 549 | &dev->i2c_adap, tuner_conf) == NULL) { |
| 563 | wprintk("no tda827x tuner found at addr: %02x\n", | 550 | wprintk("no tda827x tuner found at addr: %02x\n", |
| 564 | tda_conf->tuner_address); | 551 | cdec_conf->tuner_address); |
| 565 | } | 552 | } |
| 566 | } | 553 | } |
| 567 | } | 554 | } |
| 568 | 555 | ||
| 569 | /* ------------------------------------------------------------------ */ | 556 | /* ------------------------------------------------------------------ */ |
| 570 | 557 | ||
| 558 | static struct tda827x_config tda827x_cfg_0 = { | ||
| 559 | .tuner_callback = saa7134_tuner_callback, | ||
| 560 | .init = philips_tda827x_tuner_init, | ||
| 561 | .sleep = philips_tda827x_tuner_sleep, | ||
| 562 | .config = 0, | ||
| 563 | .switch_addr = 0 | ||
| 564 | }; | ||
| 565 | |||
| 566 | static struct tda827x_config tda827x_cfg_1 = { | ||
| 567 | .tuner_callback = saa7134_tuner_callback, | ||
| 568 | .init = philips_tda827x_tuner_init, | ||
| 569 | .sleep = philips_tda827x_tuner_sleep, | ||
| 570 | .config = 1, | ||
| 571 | .switch_addr = 0x4b | ||
| 572 | }; | ||
| 573 | |||
| 574 | static struct tda827x_config tda827x_cfg_2 = { | ||
| 575 | .tuner_callback = saa7134_tuner_callback, | ||
| 576 | .init = philips_tda827x_tuner_init, | ||
| 577 | .sleep = philips_tda827x_tuner_sleep, | ||
| 578 | .config = 2, | ||
| 579 | .switch_addr = 0x4b | ||
| 580 | }; | ||
| 581 | |||
| 582 | static struct tda827x_config tda827x_cfg_2_sw42 = { | ||
| 583 | .tuner_callback = saa7134_tuner_callback, | ||
| 584 | .init = philips_tda827x_tuner_init, | ||
| 585 | .sleep = philips_tda827x_tuner_sleep, | ||
| 586 | .config = 2, | ||
| 587 | .switch_addr = 0x42 | ||
| 588 | }; | ||
| 589 | |||
| 590 | /* ------------------------------------------------------------------ */ | ||
| 591 | |||
| 571 | static struct tda1004x_config tda827x_lifeview_config = { | 592 | static struct tda1004x_config tda827x_lifeview_config = { |
| 572 | .demod_address = 0x08, | 593 | .demod_address = 0x08, |
| 573 | .invert = 1, | 594 | .invert = 1, |
| @@ -590,7 +611,6 @@ static struct tda1004x_config philips_tiger_config = { | |||
| 590 | .if_freq = TDA10046_FREQ_045, | 611 | .if_freq = TDA10046_FREQ_045, |
| 591 | .i2c_gate = 0x4b, | 612 | .i2c_gate = 0x4b, |
| 592 | .tuner_address = 0x61, | 613 | .tuner_address = 0x61, |
| 593 | .tuner_config = 0, | ||
| 594 | .antenna_switch= 1, | 614 | .antenna_switch= 1, |
| 595 | .request_firmware = philips_tda1004x_request_firmware | 615 | .request_firmware = philips_tda1004x_request_firmware |
| 596 | }; | 616 | }; |
| @@ -605,7 +625,6 @@ static struct tda1004x_config cinergy_ht_config = { | |||
| 605 | .if_freq = TDA10046_FREQ_045, | 625 | .if_freq = TDA10046_FREQ_045, |
| 606 | .i2c_gate = 0x4b, | 626 | .i2c_gate = 0x4b, |
| 607 | .tuner_address = 0x61, | 627 | .tuner_address = 0x61, |
| 608 | .tuner_config = 0, | ||
| 609 | .request_firmware = philips_tda1004x_request_firmware | 628 | .request_firmware = philips_tda1004x_request_firmware |
| 610 | }; | 629 | }; |
| 611 | 630 | ||
| @@ -619,7 +638,6 @@ static struct tda1004x_config cinergy_ht_pci_config = { | |||
| 619 | .if_freq = TDA10046_FREQ_045, | 638 | .if_freq = TDA10046_FREQ_045, |
| 620 | .i2c_gate = 0x4b, | 639 | .i2c_gate = 0x4b, |
| 621 | .tuner_address = 0x60, | 640 | .tuner_address = 0x60, |
| 622 | .tuner_config = 0, | ||
| 623 | .request_firmware = philips_tda1004x_request_firmware | 641 | .request_firmware = philips_tda1004x_request_firmware |
| 624 | }; | 642 | }; |
| 625 | 643 | ||
| @@ -633,7 +651,6 @@ static struct tda1004x_config philips_tiger_s_config = { | |||
| 633 | .if_freq = TDA10046_FREQ_045, | 651 | .if_freq = TDA10046_FREQ_045, |
| 634 | .i2c_gate = 0x4b, | 652 | .i2c_gate = 0x4b, |
| 635 | .tuner_address = 0x61, | 653 | .tuner_address = 0x61, |
| 636 | .tuner_config = 2, | ||
| 637 | .antenna_switch= 1, | 654 | .antenna_switch= 1, |
| 638 | .request_firmware = philips_tda1004x_request_firmware | 655 | .request_firmware = philips_tda1004x_request_firmware |
| 639 | }; | 656 | }; |
| @@ -648,7 +665,6 @@ static struct tda1004x_config pinnacle_pctv_310i_config = { | |||
| 648 | .if_freq = TDA10046_FREQ_045, | 665 | .if_freq = TDA10046_FREQ_045, |
| 649 | .i2c_gate = 0x4b, | 666 | .i2c_gate = 0x4b, |
| 650 | .tuner_address = 0x61, | 667 | .tuner_address = 0x61, |
| 651 | .tuner_config = 1, | ||
| 652 | .request_firmware = philips_tda1004x_request_firmware | 668 | .request_firmware = philips_tda1004x_request_firmware |
| 653 | }; | 669 | }; |
| 654 | 670 | ||
| @@ -662,7 +678,6 @@ static struct tda1004x_config hauppauge_hvr_1110_config = { | |||
| 662 | .if_freq = TDA10046_FREQ_045, | 678 | .if_freq = TDA10046_FREQ_045, |
| 663 | .i2c_gate = 0x4b, | 679 | .i2c_gate = 0x4b, |
| 664 | .tuner_address = 0x61, | 680 | .tuner_address = 0x61, |
| 665 | .tuner_config = 1, | ||
| 666 | .request_firmware = philips_tda1004x_request_firmware | 681 | .request_firmware = philips_tda1004x_request_firmware |
| 667 | }; | 682 | }; |
| 668 | 683 | ||
| @@ -676,7 +691,6 @@ static struct tda1004x_config asus_p7131_dual_config = { | |||
| 676 | .if_freq = TDA10046_FREQ_045, | 691 | .if_freq = TDA10046_FREQ_045, |
| 677 | .i2c_gate = 0x4b, | 692 | .i2c_gate = 0x4b, |
| 678 | .tuner_address = 0x61, | 693 | .tuner_address = 0x61, |
| 679 | .tuner_config = 0, | ||
| 680 | .antenna_switch= 2, | 694 | .antenna_switch= 2, |
| 681 | .request_firmware = philips_tda1004x_request_firmware | 695 | .request_firmware = philips_tda1004x_request_firmware |
| 682 | }; | 696 | }; |
| @@ -715,7 +729,6 @@ static struct tda1004x_config md8800_dvbt_config = { | |||
| 715 | .if_freq = TDA10046_FREQ_045, | 729 | .if_freq = TDA10046_FREQ_045, |
| 716 | .i2c_gate = 0x4b, | 730 | .i2c_gate = 0x4b, |
| 717 | .tuner_address = 0x60, | 731 | .tuner_address = 0x60, |
| 718 | .tuner_config = 0, | ||
| 719 | .request_firmware = philips_tda1004x_request_firmware | 732 | .request_firmware = philips_tda1004x_request_firmware |
| 720 | }; | 733 | }; |
| 721 | 734 | ||
| @@ -729,7 +742,6 @@ static struct tda1004x_config asus_p7131_4871_config = { | |||
| 729 | .if_freq = TDA10046_FREQ_045, | 742 | .if_freq = TDA10046_FREQ_045, |
| 730 | .i2c_gate = 0x4b, | 743 | .i2c_gate = 0x4b, |
| 731 | .tuner_address = 0x61, | 744 | .tuner_address = 0x61, |
| 732 | .tuner_config = 2, | ||
| 733 | .antenna_switch= 2, | 745 | .antenna_switch= 2, |
| 734 | .request_firmware = philips_tda1004x_request_firmware | 746 | .request_firmware = philips_tda1004x_request_firmware |
| 735 | }; | 747 | }; |
| @@ -744,7 +756,6 @@ static struct tda1004x_config asus_p7131_hybrid_lna_config = { | |||
| 744 | .if_freq = TDA10046_FREQ_045, | 756 | .if_freq = TDA10046_FREQ_045, |
| 745 | .i2c_gate = 0x4b, | 757 | .i2c_gate = 0x4b, |
| 746 | .tuner_address = 0x61, | 758 | .tuner_address = 0x61, |
| 747 | .tuner_config = 2, | ||
| 748 | .antenna_switch= 2, | 759 | .antenna_switch= 2, |
| 749 | .request_firmware = philips_tda1004x_request_firmware | 760 | .request_firmware = philips_tda1004x_request_firmware |
| 750 | }; | 761 | }; |
| @@ -759,7 +770,6 @@ static struct tda1004x_config kworld_dvb_t_210_config = { | |||
| 759 | .if_freq = TDA10046_FREQ_045, | 770 | .if_freq = TDA10046_FREQ_045, |
| 760 | .i2c_gate = 0x4b, | 771 | .i2c_gate = 0x4b, |
| 761 | .tuner_address = 0x61, | 772 | .tuner_address = 0x61, |
| 762 | .tuner_config = 2, | ||
| 763 | .antenna_switch= 1, | 773 | .antenna_switch= 1, |
| 764 | .request_firmware = philips_tda1004x_request_firmware | 774 | .request_firmware = philips_tda1004x_request_firmware |
| 765 | }; | 775 | }; |
| @@ -774,7 +784,6 @@ static struct tda1004x_config avermedia_super_007_config = { | |||
| 774 | .if_freq = TDA10046_FREQ_045, | 784 | .if_freq = TDA10046_FREQ_045, |
| 775 | .i2c_gate = 0x4b, | 785 | .i2c_gate = 0x4b, |
| 776 | .tuner_address = 0x60, | 786 | .tuner_address = 0x60, |
| 777 | .tuner_config = 0, | ||
| 778 | .antenna_switch= 1, | 787 | .antenna_switch= 1, |
| 779 | .request_firmware = philips_tda1004x_request_firmware | 788 | .request_firmware = philips_tda1004x_request_firmware |
| 780 | }; | 789 | }; |
| @@ -789,7 +798,6 @@ static struct tda1004x_config twinhan_dtv_dvb_3056_config = { | |||
| 789 | .if_freq = TDA10046_FREQ_045, | 798 | .if_freq = TDA10046_FREQ_045, |
| 790 | .i2c_gate = 0x42, | 799 | .i2c_gate = 0x42, |
| 791 | .tuner_address = 0x61, | 800 | .tuner_address = 0x61, |
| 792 | .tuner_config = 2, | ||
| 793 | .antenna_switch = 1, | 801 | .antenna_switch = 1, |
| 794 | .request_firmware = philips_tda1004x_request_firmware | 802 | .request_firmware = philips_tda1004x_request_firmware |
| 795 | }; | 803 | }; |
| @@ -817,9 +825,10 @@ static int ads_duo_tuner_sleep(struct dvb_frontend *fe) | |||
| 817 | } | 825 | } |
| 818 | 826 | ||
| 819 | static struct tda827x_config ads_duo_cfg = { | 827 | static struct tda827x_config ads_duo_cfg = { |
| 820 | .lna_gain = philips_tda827x_lna_gain, | 828 | .tuner_callback = saa7134_tuner_callback, |
| 821 | .init = ads_duo_tuner_init, | 829 | .init = ads_duo_tuner_init, |
| 822 | .sleep = ads_duo_tuner_sleep | 830 | .sleep = ads_duo_tuner_sleep, |
| 831 | .config = 0 | ||
| 823 | }; | 832 | }; |
| 824 | 833 | ||
| 825 | static struct tda1004x_config ads_tech_duo_config = { | 834 | static struct tda1004x_config ads_tech_duo_config = { |
| @@ -842,8 +851,73 @@ static struct tda10086_config flydvbs = { | |||
| 842 | .demod_address = 0x0e, | 851 | .demod_address = 0x0e, |
| 843 | .invert = 0, | 852 | .invert = 0, |
| 844 | .diseqc_tone = 0, | 853 | .diseqc_tone = 0, |
| 854 | .xtal_freq = TDA10086_XTAL_16M, | ||
| 845 | }; | 855 | }; |
| 846 | 856 | ||
| 857 | static struct tda10086_config sd1878_4m = { | ||
| 858 | .demod_address = 0x0e, | ||
| 859 | .invert = 0, | ||
| 860 | .diseqc_tone = 0, | ||
| 861 | .xtal_freq = TDA10086_XTAL_4M, | ||
| 862 | }; | ||
| 863 | |||
| 864 | /* ------------------------------------------------------------------ | ||
| 865 | * special case: lnb supply is connected to the gated i2c | ||
| 866 | */ | ||
| 867 | |||
| 868 | static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) | ||
| 869 | { | ||
| 870 | int res = -EIO; | ||
| 871 | struct saa7134_dev *dev = fe->dvb->priv; | ||
| 872 | if (fe->ops.i2c_gate_ctrl) { | ||
| 873 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 874 | if (dev->original_set_voltage) | ||
| 875 | res = dev->original_set_voltage(fe, voltage); | ||
| 876 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 877 | } | ||
| 878 | return res; | ||
| 879 | }; | ||
| 880 | |||
| 881 | static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg) | ||
| 882 | { | ||
| 883 | int res = -EIO; | ||
| 884 | struct saa7134_dev *dev = fe->dvb->priv; | ||
| 885 | if (fe->ops.i2c_gate_ctrl) { | ||
| 886 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 887 | if (dev->original_set_high_voltage) | ||
| 888 | res = dev->original_set_high_voltage(fe, arg); | ||
| 889 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 890 | } | ||
| 891 | return res; | ||
| 892 | }; | ||
| 893 | |||
| 894 | static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage) | ||
| 895 | { | ||
| 896 | struct saa7134_dev *dev = fe->dvb->priv; | ||
| 897 | u8 wbuf[2] = { 0x1f, 00 }; | ||
| 898 | u8 rbuf; | ||
| 899 | struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 }, | ||
| 900 | { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } }; | ||
| 901 | |||
| 902 | if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2) | ||
| 903 | return -EIO; | ||
| 904 | /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */ | ||
| 905 | if (voltage == SEC_VOLTAGE_18) | ||
| 906 | wbuf[1] = rbuf | 0x10; | ||
| 907 | else | ||
| 908 | wbuf[1] = rbuf & 0xef; | ||
| 909 | msg[0].len = 2; | ||
| 910 | i2c_transfer(&dev->i2c_adap, msg, 1); | ||
| 911 | return 0; | ||
| 912 | } | ||
| 913 | |||
| 914 | static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg) | ||
| 915 | { | ||
| 916 | struct saa7134_dev *dev = fe->dvb->priv; | ||
| 917 | wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__); | ||
| 918 | return -EIO; | ||
| 919 | } | ||
| 920 | |||
| 847 | /* ================================================================== | 921 | /* ================================================================== |
| 848 | * nxt200x based ATSC cards, helper functions | 922 | * nxt200x based ATSC cards, helper functions |
| 849 | */ | 923 | */ |
| @@ -863,12 +937,14 @@ static struct nxt200x_config kworldatsc110 = { | |||
| 863 | static int dvb_init(struct saa7134_dev *dev) | 937 | static int dvb_init(struct saa7134_dev *dev) |
| 864 | { | 938 | { |
| 865 | int ret; | 939 | int ret; |
| 940 | int attach_xc3028 = 0; | ||
| 941 | |||
| 866 | /* init struct videobuf_dvb */ | 942 | /* init struct videobuf_dvb */ |
| 867 | dev->ts.nr_bufs = 32; | 943 | dev->ts.nr_bufs = 32; |
| 868 | dev->ts.nr_packets = 32*4; | 944 | dev->ts.nr_packets = 32*4; |
| 869 | dev->dvb.name = dev->name; | 945 | dev->dvb.name = dev->name; |
| 870 | videobuf_queue_pci_init(&dev->dvb.dvbq, &saa7134_ts_qops, | 946 | videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops, |
| 871 | dev->pci, &dev->slock, | 947 | &dev->pci->dev, &dev->slock, |
| 872 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 948 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 873 | V4L2_FIELD_ALTERNATE, | 949 | V4L2_FIELD_ALTERNATE, |
| 874 | sizeof(struct saa7134_buf), | 950 | sizeof(struct saa7134_buf), |
| @@ -889,17 +965,25 @@ static int dvb_init(struct saa7134_dev *dev) | |||
| 889 | dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, | 965 | dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777, |
| 890 | &dev->i2c_adap); | 966 | &dev->i2c_adap); |
| 891 | if (dev->dvb.frontend) { | 967 | if (dev->dvb.frontend) { |
| 892 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 968 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 893 | NULL, DVB_PLL_PHILIPS_TD1316); | 969 | &dev->i2c_adap, 0x61, |
| 970 | TUNER_PHILIPS_TD1316); | ||
| 894 | } | 971 | } |
| 895 | break; | 972 | break; |
| 973 | case SAA7134_BOARD_AVERMEDIA_A16D: | ||
| 974 | dprintk("avertv A16D dvb setup\n"); | ||
| 975 | dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_16d, | ||
| 976 | &dev->i2c_adap); | ||
| 977 | attach_xc3028 = 1; | ||
| 978 | break; | ||
| 896 | case SAA7134_BOARD_MD7134: | 979 | case SAA7134_BOARD_MD7134: |
| 897 | dev->dvb.frontend = dvb_attach(tda10046_attach, | 980 | dev->dvb.frontend = dvb_attach(tda10046_attach, |
| 898 | &medion_cardbus, | 981 | &medion_cardbus, |
| 899 | &dev->i2c_adap); | 982 | &dev->i2c_adap); |
| 900 | if (dev->dvb.frontend) { | 983 | if (dev->dvb.frontend) { |
| 901 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address, | 984 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 902 | &dev->i2c_adap, DVB_PLL_FMD1216ME); | 985 | &dev->i2c_adap, medion_cardbus.tuner_address, |
| 986 | TUNER_PHILIPS_FMD1216ME_MK3); | ||
| 903 | } | 987 | } |
| 904 | break; | 988 | break; |
| 905 | case SAA7134_BOARD_PHILIPS_TOUGH: | 989 | case SAA7134_BOARD_PHILIPS_TOUGH: |
| @@ -913,7 +997,7 @@ static int dvb_init(struct saa7134_dev *dev) | |||
| 913 | break; | 997 | break; |
| 914 | case SAA7134_BOARD_FLYDVBTDUO: | 998 | case SAA7134_BOARD_FLYDVBTDUO: |
| 915 | case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: | 999 | case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: |
| 916 | configure_tda827x_fe(dev, &tda827x_lifeview_config); | 1000 | configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0); |
| 917 | break; | 1001 | break; |
| 918 | case SAA7134_BOARD_PHILIPS_EUROPA: | 1002 | case SAA7134_BOARD_PHILIPS_EUROPA: |
| 919 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: | 1003 | case SAA7134_BOARD_VIDEOMATE_DVBT_300: |
| @@ -938,36 +1022,36 @@ static int dvb_init(struct saa7134_dev *dev) | |||
| 938 | } | 1022 | } |
| 939 | break; | 1023 | break; |
| 940 | case SAA7134_BOARD_KWORLD_DVBT_210: | 1024 | case SAA7134_BOARD_KWORLD_DVBT_210: |
| 941 | configure_tda827x_fe(dev, &kworld_dvb_t_210_config); | 1025 | configure_tda827x_fe(dev, &kworld_dvb_t_210_config, &tda827x_cfg_2); |
| 942 | break; | 1026 | break; |
| 943 | case SAA7134_BOARD_PHILIPS_TIGER: | 1027 | case SAA7134_BOARD_PHILIPS_TIGER: |
| 944 | configure_tda827x_fe(dev, &philips_tiger_config); | 1028 | configure_tda827x_fe(dev, &philips_tiger_config, &tda827x_cfg_0); |
| 945 | break; | 1029 | break; |
| 946 | case SAA7134_BOARD_PINNACLE_PCTV_310i: | 1030 | case SAA7134_BOARD_PINNACLE_PCTV_310i: |
| 947 | configure_tda827x_fe(dev, &pinnacle_pctv_310i_config); | 1031 | configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, &tda827x_cfg_1); |
| 948 | break; | 1032 | break; |
| 949 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: | 1033 | case SAA7134_BOARD_HAUPPAUGE_HVR1110: |
| 950 | configure_tda827x_fe(dev, &hauppauge_hvr_1110_config); | 1034 | configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, &tda827x_cfg_1); |
| 951 | break; | 1035 | break; |
| 952 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: | 1036 | case SAA7134_BOARD_ASUSTeK_P7131_DUAL: |
| 953 | configure_tda827x_fe(dev, &asus_p7131_dual_config); | 1037 | configure_tda827x_fe(dev, &asus_p7131_dual_config, &tda827x_cfg_0); |
| 954 | break; | 1038 | break; |
| 955 | case SAA7134_BOARD_FLYDVBT_LR301: | 1039 | case SAA7134_BOARD_FLYDVBT_LR301: |
| 956 | configure_tda827x_fe(dev, &tda827x_lifeview_config); | 1040 | configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0); |
| 957 | break; | 1041 | break; |
| 958 | case SAA7134_BOARD_FLYDVB_TRIO: | 1042 | case SAA7134_BOARD_FLYDVB_TRIO: |
| 959 | if(! use_frontend) { /* terrestrial */ | 1043 | if(! use_frontend) { /* terrestrial */ |
| 960 | configure_tda827x_fe(dev, &lifeview_trio_config); | 1044 | configure_tda827x_fe(dev, &lifeview_trio_config, &tda827x_cfg_0); |
| 961 | } else { /* satellite */ | 1045 | } else { /* satellite */ |
| 962 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); | 1046 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); |
| 963 | if (dev->dvb.frontend) { | 1047 | if (dev->dvb.frontend) { |
| 964 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, | 1048 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, |
| 965 | &dev->i2c_adap, 0) == NULL) { | 1049 | &dev->i2c_adap, 0) == NULL) { |
| 966 | wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__); | 1050 | wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); |
| 967 | } | 1051 | } |
| 968 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, | 1052 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, |
| 969 | 0x08, 0, 0) == NULL) { | 1053 | 0x08, 0, 0) == NULL) { |
| 970 | wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__); | 1054 | wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); |
| 971 | } | 1055 | } |
| 972 | } | 1056 | } |
| 973 | } | 1057 | } |
| @@ -979,18 +1063,56 @@ static int dvb_init(struct saa7134_dev *dev) | |||
| 979 | &dev->i2c_adap); | 1063 | &dev->i2c_adap); |
| 980 | if (dev->dvb.frontend) { | 1064 | if (dev->dvb.frontend) { |
| 981 | if (dvb_attach(tda827x_attach,dev->dvb.frontend, | 1065 | if (dvb_attach(tda827x_attach,dev->dvb.frontend, |
| 982 | ads_tech_duo_config.tuner_address, | 1066 | ads_tech_duo_config.tuner_address, &dev->i2c_adap, |
| 983 | &dev->i2c_adap,&ads_duo_cfg) == NULL) { | 1067 | &ads_duo_cfg) == NULL) { |
| 984 | wprintk("no tda827x tuner found at addr: %02x\n", | 1068 | wprintk("no tda827x tuner found at addr: %02x\n", |
| 985 | ads_tech_duo_config.tuner_address); | 1069 | ads_tech_duo_config.tuner_address); |
| 986 | } | 1070 | } |
| 987 | } | 1071 | } |
| 988 | break; | 1072 | break; |
| 989 | case SAA7134_BOARD_TEVION_DVBT_220RF: | 1073 | case SAA7134_BOARD_TEVION_DVBT_220RF: |
| 990 | configure_tda827x_fe(dev, &tevion_dvbt220rf_config); | 1074 | configure_tda827x_fe(dev, &tevion_dvbt220rf_config, &tda827x_cfg_0); |
| 991 | break; | 1075 | break; |
| 992 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: | 1076 | case SAA7134_BOARD_MEDION_MD8800_QUADRO: |
| 993 | configure_tda827x_fe(dev, &md8800_dvbt_config); | 1077 | if (!use_frontend) { /* terrestrial */ |
| 1078 | configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0); | ||
| 1079 | } else { /* satellite */ | ||
| 1080 | dev->dvb.frontend = dvb_attach(tda10086_attach, | ||
| 1081 | &flydvbs, &dev->i2c_adap); | ||
| 1082 | if (dev->dvb.frontend) { | ||
| 1083 | struct dvb_frontend *fe = dev->dvb.frontend; | ||
| 1084 | u8 dev_id = dev->eedata[2]; | ||
| 1085 | u8 data = 0xc4; | ||
| 1086 | struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1}; | ||
| 1087 | |||
| 1088 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, | ||
| 1089 | 0x60, &dev->i2c_adap, 0) == NULL) | ||
| 1090 | wprintk("%s: Medion Quadro, no tda826x " | ||
| 1091 | "found !\n", __func__); | ||
| 1092 | if (dev_id != 0x08) { | ||
| 1093 | /* we need to open the i2c gate (we know it exists) */ | ||
| 1094 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 1095 | if (dvb_attach(isl6405_attach, fe, | ||
| 1096 | &dev->i2c_adap, 0x08, 0, 0) == NULL) | ||
| 1097 | wprintk("%s: Medion Quadro, no ISL6405 " | ||
| 1098 | "found !\n", __func__); | ||
| 1099 | if (dev_id == 0x07) { | ||
| 1100 | /* fire up the 2nd section of the LNB supply since | ||
| 1101 | we can't do this from the other section */ | ||
| 1102 | msg.buf = &data; | ||
| 1103 | i2c_transfer(&dev->i2c_adap, &msg, 1); | ||
| 1104 | } | ||
| 1105 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 1106 | dev->original_set_voltage = fe->ops.set_voltage; | ||
| 1107 | fe->ops.set_voltage = md8800_set_voltage; | ||
| 1108 | dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage; | ||
| 1109 | fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage; | ||
| 1110 | } else { | ||
| 1111 | fe->ops.set_voltage = md8800_set_voltage2; | ||
| 1112 | fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2; | ||
| 1113 | } | ||
| 1114 | } | ||
| 1115 | } | ||
| 994 | break; | 1116 | break; |
| 995 | case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: | 1117 | case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: |
| 996 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, | 1118 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, |
| @@ -1004,8 +1126,9 @@ static int dvb_init(struct saa7134_dev *dev) | |||
| 1004 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, | 1126 | dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, |
| 1005 | &dev->i2c_adap); | 1127 | &dev->i2c_adap); |
| 1006 | if (dev->dvb.frontend) { | 1128 | if (dev->dvb.frontend) { |
| 1007 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, | 1129 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 1008 | NULL, DVB_PLL_TUV1236D); | 1130 | &dev->i2c_adap, 0x61, |
| 1131 | TUNER_PHILIPS_TUV1236D); | ||
| 1009 | } | 1132 | } |
| 1010 | break; | 1133 | break; |
| 1011 | case SAA7134_BOARD_FLYDVBS_LR300: | 1134 | case SAA7134_BOARD_FLYDVBS_LR300: |
| @@ -1014,11 +1137,11 @@ static int dvb_init(struct saa7134_dev *dev) | |||
| 1014 | if (dev->dvb.frontend) { | 1137 | if (dev->dvb.frontend) { |
| 1015 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, | 1138 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, |
| 1016 | &dev->i2c_adap, 0) == NULL) { | 1139 | &dev->i2c_adap, 0) == NULL) { |
| 1017 | wprintk("%s: No tda826x found!\n", __FUNCTION__); | 1140 | wprintk("%s: No tda826x found!\n", __func__); |
| 1018 | } | 1141 | } |
| 1019 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, | 1142 | if (dvb_attach(isl6421_attach, dev->dvb.frontend, |
| 1020 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { | 1143 | &dev->i2c_adap, 0x08, 0, 0) == NULL) { |
| 1021 | wprintk("%s: No ISL6421 found!\n", __FUNCTION__); | 1144 | wprintk("%s: No ISL6421 found!\n", __func__); |
| 1022 | } | 1145 | } |
| 1023 | } | 1146 | } |
| 1024 | break; | 1147 | break; |
| @@ -1030,8 +1153,9 @@ static int dvb_init(struct saa7134_dev *dev) | |||
| 1030 | dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; | 1153 | dev->original_demod_sleep = dev->dvb.frontend->ops.sleep; |
| 1031 | dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; | 1154 | dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep; |
| 1032 | 1155 | ||
| 1033 | dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address, | 1156 | dvb_attach(simple_tuner_attach, dev->dvb.frontend, |
| 1034 | &dev->i2c_adap, DVB_PLL_FMD1216ME); | 1157 | &dev->i2c_adap, medion_cardbus.tuner_address, |
| 1158 | TUNER_PHILIPS_FMD1216ME_MK3); | ||
| 1035 | } | 1159 | } |
| 1036 | break; | 1160 | break; |
| 1037 | case SAA7134_BOARD_VIDEOMATE_DVBT_200A: | 1161 | case SAA7134_BOARD_VIDEOMATE_DVBT_200A: |
| @@ -1044,38 +1168,107 @@ static int dvb_init(struct saa7134_dev *dev) | |||
| 1044 | } | 1168 | } |
| 1045 | break; | 1169 | break; |
| 1046 | case SAA7134_BOARD_CINERGY_HT_PCMCIA: | 1170 | case SAA7134_BOARD_CINERGY_HT_PCMCIA: |
| 1047 | configure_tda827x_fe(dev, &cinergy_ht_config); | 1171 | configure_tda827x_fe(dev, &cinergy_ht_config, &tda827x_cfg_0); |
| 1048 | break; | 1172 | break; |
| 1049 | case SAA7134_BOARD_CINERGY_HT_PCI: | 1173 | case SAA7134_BOARD_CINERGY_HT_PCI: |
| 1050 | configure_tda827x_fe(dev, &cinergy_ht_pci_config); | 1174 | configure_tda827x_fe(dev, &cinergy_ht_pci_config, &tda827x_cfg_0); |
| 1051 | break; | 1175 | break; |
| 1052 | case SAA7134_BOARD_PHILIPS_TIGER_S: | 1176 | case SAA7134_BOARD_PHILIPS_TIGER_S: |
| 1053 | configure_tda827x_fe(dev, &philips_tiger_s_config); | 1177 | configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2); |
| 1054 | break; | 1178 | break; |
| 1055 | case SAA7134_BOARD_ASUS_P7131_4871: | 1179 | case SAA7134_BOARD_ASUS_P7131_4871: |
| 1056 | configure_tda827x_fe(dev, &asus_p7131_4871_config); | 1180 | configure_tda827x_fe(dev, &asus_p7131_4871_config, &tda827x_cfg_2); |
| 1057 | break; | 1181 | break; |
| 1058 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: | 1182 | case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: |
| 1059 | configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config); | 1183 | configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config, &tda827x_cfg_2); |
| 1060 | break; | 1184 | break; |
| 1061 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: | 1185 | case SAA7134_BOARD_AVERMEDIA_SUPER_007: |
| 1062 | configure_tda827x_fe(dev, &avermedia_super_007_config); | 1186 | configure_tda827x_fe(dev, &avermedia_super_007_config, &tda827x_cfg_0); |
| 1063 | break; | 1187 | break; |
| 1064 | case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: | 1188 | case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: |
| 1065 | configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config); | 1189 | configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config, &tda827x_cfg_2_sw42); |
| 1190 | break; | ||
| 1191 | case SAA7134_BOARD_PHILIPS_SNAKE: | ||
| 1192 | dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, | ||
| 1193 | &dev->i2c_adap); | ||
| 1194 | if (dev->dvb.frontend) { | ||
| 1195 | if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, | ||
| 1196 | &dev->i2c_adap, 0) == NULL) | ||
| 1197 | wprintk("%s: No tda826x found!\n", __func__); | ||
| 1198 | if (dvb_attach(lnbp21_attach, dev->dvb.frontend, | ||
| 1199 | &dev->i2c_adap, 0, 0) == NULL) | ||
| 1200 | wprintk("%s: No lnbp21 found!\n", __func__); | ||
| 1201 | } | ||
| 1202 | break; | ||
| 1203 | case SAA7134_BOARD_CREATIX_CTX953: | ||
| 1204 | configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0); | ||
| 1205 | break; | ||
| 1206 | case SAA7134_BOARD_MSI_TVANYWHERE_AD11: | ||
| 1207 | configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2); | ||
| 1208 | break; | ||
| 1209 | case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: | ||
| 1210 | dev->dvb.frontend = dvb_attach(mt352_attach, | ||
| 1211 | &avermedia_e506r_mt352_dev, | ||
| 1212 | &dev->i2c_adap); | ||
| 1213 | attach_xc3028 = 1; | ||
| 1214 | break; | ||
| 1215 | case SAA7134_BOARD_MD7134_BRIDGE_2: | ||
| 1216 | dev->dvb.frontend = dvb_attach(tda10086_attach, | ||
| 1217 | &sd1878_4m, &dev->i2c_adap); | ||
| 1218 | if (dev->dvb.frontend) { | ||
| 1219 | struct dvb_frontend *fe; | ||
| 1220 | if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, | ||
| 1221 | &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) | ||
| 1222 | wprintk("%s: MD7134 DVB-S, no SD1878 " | ||
| 1223 | "found !\n", __func__); | ||
| 1224 | /* we need to open the i2c gate (we know it exists) */ | ||
| 1225 | fe = dev->dvb.frontend; | ||
| 1226 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 1227 | if (dvb_attach(isl6405_attach, fe, | ||
| 1228 | &dev->i2c_adap, 0x08, 0, 0) == NULL) | ||
| 1229 | wprintk("%s: MD7134 DVB-S, no ISL6405 " | ||
| 1230 | "found !\n", __func__); | ||
| 1231 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 1232 | dev->original_set_voltage = fe->ops.set_voltage; | ||
| 1233 | fe->ops.set_voltage = md8800_set_voltage; | ||
| 1234 | dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage; | ||
| 1235 | fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage; | ||
| 1236 | } | ||
| 1066 | break; | 1237 | break; |
| 1067 | default: | 1238 | default: |
| 1068 | wprintk("Huh? unknown DVB card?\n"); | 1239 | wprintk("Huh? unknown DVB card?\n"); |
| 1069 | break; | 1240 | break; |
| 1070 | } | 1241 | } |
| 1071 | 1242 | ||
| 1243 | if (attach_xc3028) { | ||
| 1244 | struct dvb_frontend *fe; | ||
| 1245 | struct xc2028_config cfg = { | ||
| 1246 | .i2c_adap = &dev->i2c_adap, | ||
| 1247 | .i2c_addr = 0x61, | ||
| 1248 | }; | ||
| 1249 | |||
| 1250 | if (!dev->dvb.frontend) | ||
| 1251 | return -1; | ||
| 1252 | |||
| 1253 | fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg); | ||
| 1254 | if (!fe) { | ||
| 1255 | printk(KERN_ERR "%s/2: xc3028 attach failed\n", | ||
| 1256 | dev->name); | ||
| 1257 | dvb_frontend_detach(dev->dvb.frontend); | ||
| 1258 | dvb_unregister_frontend(dev->dvb.frontend); | ||
| 1259 | dev->dvb.frontend = NULL; | ||
| 1260 | return -1; | ||
| 1261 | } | ||
| 1262 | } | ||
| 1263 | |||
| 1072 | if (NULL == dev->dvb.frontend) { | 1264 | if (NULL == dev->dvb.frontend) { |
| 1073 | printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name); | 1265 | printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name); |
| 1074 | return -1; | 1266 | return -1; |
| 1075 | } | 1267 | } |
| 1076 | 1268 | ||
| 1077 | /* register everything else */ | 1269 | /* register everything else */ |
| 1078 | ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev); | 1270 | ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev, |
| 1271 | adapter_nr); | ||
| 1079 | 1272 | ||
| 1080 | /* this sequence is necessary to make the tda1004x load its firmware | 1273 | /* this sequence is necessary to make the tda1004x load its firmware |
| 1081 | * and to enter analog mode of hybrid boards | 1274 | * and to enter analog mode of hybrid boards |
| @@ -1106,9 +1299,22 @@ static int dvb_fini(struct saa7134_dev *dev) | |||
| 1106 | 1299 | ||
| 1107 | /* otherwise we don't detect the tuner on next insmod */ | 1300 | /* otherwise we don't detect the tuner on next insmod */ |
| 1108 | saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg); | 1301 | saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg); |
| 1302 | } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) { | ||
| 1303 | if ((dev->eedata[2] == 0x07) && use_frontend) { | ||
| 1304 | /* turn off the 2nd lnb supply */ | ||
| 1305 | u8 data = 0x80; | ||
| 1306 | struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1}; | ||
| 1307 | struct dvb_frontend *fe; | ||
| 1308 | fe = dev->dvb.frontend; | ||
| 1309 | if (fe->ops.i2c_gate_ctrl) { | ||
| 1310 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 1311 | i2c_transfer(&dev->i2c_adap, &msg, 1); | ||
| 1312 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 1313 | } | ||
| 1314 | } | ||
| 1109 | } | 1315 | } |
| 1110 | 1316 | if (dev->dvb.frontend) | |
| 1111 | videobuf_dvb_unregister(&dev->dvb); | 1317 | videobuf_dvb_unregister(&dev->dvb); |
| 1112 | return 0; | 1318 | return 0; |
| 1113 | } | 1319 | } |
| 1114 | 1320 | ||
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c index 3d2ec30de227..1314522a8130 100644 --- a/drivers/media/video/saa7134/saa7134-empress.c +++ b/drivers/media/video/saa7134/saa7134-empress.c | |||
| @@ -40,7 +40,7 @@ static unsigned int empress_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; | |||
| 40 | module_param_array(empress_nr, int, NULL, 0444); | 40 | module_param_array(empress_nr, int, NULL, 0444); |
| 41 | MODULE_PARM_DESC(empress_nr,"ts device number"); | 41 | MODULE_PARM_DESC(empress_nr,"ts device number"); |
| 42 | 42 | ||
| 43 | static unsigned int debug = 0; | 43 | static unsigned int debug; |
| 44 | module_param(debug, int, 0644); | 44 | module_param(debug, int, 0644); |
| 45 | MODULE_PARM_DESC(debug,"enable debug messages"); | 45 | MODULE_PARM_DESC(debug,"enable debug messages"); |
| 46 | 46 | ||
| @@ -402,7 +402,7 @@ static int empress_init(struct saa7134_dev *dev) | |||
| 402 | { | 402 | { |
| 403 | int err; | 403 | int err; |
| 404 | 404 | ||
| 405 | dprintk("%s: %s\n",dev->name,__FUNCTION__); | 405 | dprintk("%s: %s\n",dev->name,__func__); |
| 406 | dev->empress_dev = video_device_alloc(); | 406 | dev->empress_dev = video_device_alloc(); |
| 407 | if (NULL == dev->empress_dev) | 407 | if (NULL == dev->empress_dev) |
| 408 | return -ENOMEM; | 408 | return -ENOMEM; |
| @@ -427,8 +427,8 @@ static int empress_init(struct saa7134_dev *dev) | |||
| 427 | printk(KERN_INFO "%s: registered device video%d [mpeg]\n", | 427 | printk(KERN_INFO "%s: registered device video%d [mpeg]\n", |
| 428 | dev->name,dev->empress_dev->minor & 0x1f); | 428 | dev->name,dev->empress_dev->minor & 0x1f); |
| 429 | 429 | ||
| 430 | videobuf_queue_pci_init(&dev->empress_tsq, &saa7134_ts_qops, | 430 | videobuf_queue_sg_init(&dev->empress_tsq, &saa7134_ts_qops, |
| 431 | dev->pci, &dev->slock, | 431 | &dev->pci->dev, &dev->slock, |
| 432 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 432 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 433 | V4L2_FIELD_ALTERNATE, | 433 | V4L2_FIELD_ALTERNATE, |
| 434 | sizeof(struct saa7134_buf), | 434 | sizeof(struct saa7134_buf), |
| @@ -440,7 +440,7 @@ static int empress_init(struct saa7134_dev *dev) | |||
| 440 | 440 | ||
| 441 | static int empress_fini(struct saa7134_dev *dev) | 441 | static int empress_fini(struct saa7134_dev *dev) |
| 442 | { | 442 | { |
| 443 | dprintk("%s: %s\n",dev->name,__FUNCTION__); | 443 | dprintk("%s: %s\n",dev->name,__func__); |
| 444 | 444 | ||
| 445 | if (NULL == dev->empress_dev) | 445 | if (NULL == dev->empress_dev) |
| 446 | return 0; | 446 | return 0; |
diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c index d3322c3018f2..2ccfaba0c490 100644 --- a/drivers/media/video/saa7134/saa7134-i2c.c +++ b/drivers/media/video/saa7134/saa7134-i2c.c | |||
| @@ -33,11 +33,11 @@ | |||
| 33 | 33 | ||
| 34 | /* ----------------------------------------------------------- */ | 34 | /* ----------------------------------------------------------- */ |
| 35 | 35 | ||
| 36 | static unsigned int i2c_debug = 0; | 36 | static unsigned int i2c_debug; |
| 37 | module_param(i2c_debug, int, 0644); | 37 | module_param(i2c_debug, int, 0644); |
| 38 | MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]"); | 38 | MODULE_PARM_DESC(i2c_debug,"enable debug messages [i2c]"); |
| 39 | 39 | ||
| 40 | static unsigned int i2c_scan = 0; | 40 | static unsigned int i2c_scan; |
| 41 | module_param(i2c_scan, int, 0444); | 41 | module_param(i2c_scan, int, 0444); |
| 42 | MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); | 42 | MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); |
| 43 | 43 | ||
| @@ -140,6 +140,8 @@ static inline int i2c_is_busy(enum i2c_status status) | |||
| 140 | { | 140 | { |
| 141 | switch (status) { | 141 | switch (status) { |
| 142 | case BUSY: | 142 | case BUSY: |
| 143 | case TO_SCL: | ||
| 144 | case TO_ARB: | ||
| 143 | return true; | 145 | return true; |
| 144 | default: | 146 | default: |
| 145 | return false; | 147 | return false; |
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c index b4188819782f..767ff30832f2 100644 --- a/drivers/media/video/saa7134/saa7134-input.c +++ b/drivers/media/video/saa7134/saa7134-input.c | |||
| @@ -27,15 +27,15 @@ | |||
| 27 | #include "saa7134-reg.h" | 27 | #include "saa7134-reg.h" |
| 28 | #include "saa7134.h" | 28 | #include "saa7134.h" |
| 29 | 29 | ||
| 30 | static unsigned int disable_ir = 0; | 30 | static unsigned int disable_ir; |
| 31 | module_param(disable_ir, int, 0444); | 31 | module_param(disable_ir, int, 0444); |
| 32 | MODULE_PARM_DESC(disable_ir,"disable infrared remote support"); | 32 | MODULE_PARM_DESC(disable_ir,"disable infrared remote support"); |
| 33 | 33 | ||
| 34 | static unsigned int ir_debug = 0; | 34 | static unsigned int ir_debug; |
| 35 | module_param(ir_debug, int, 0644); | 35 | module_param(ir_debug, int, 0644); |
| 36 | MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]"); | 36 | MODULE_PARM_DESC(ir_debug,"enable debug messages [IR]"); |
| 37 | 37 | ||
| 38 | static int pinnacle_remote = 0; | 38 | static int pinnacle_remote; |
| 39 | module_param(pinnacle_remote, int, 0644); /* Choose Pinnacle PCTV remote */ | 39 | module_param(pinnacle_remote, int, 0644); /* Choose Pinnacle PCTV remote */ |
| 40 | MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)"); | 40 | MODULE_PARM_DESC(pinnacle_remote, "Specify Pinnacle PCTV remote: 0=coloured, 1=grey (defaults to 0)"); |
| 41 | 41 | ||
| @@ -331,6 +331,11 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
| 331 | break; | 331 | break; |
| 332 | case SAA7134_BOARD_MANLI_MTV001: | 332 | case SAA7134_BOARD_MANLI_MTV001: |
| 333 | case SAA7134_BOARD_MANLI_MTV002: | 333 | case SAA7134_BOARD_MANLI_MTV002: |
| 334 | ir_codes = ir_codes_manli; | ||
| 335 | mask_keycode = 0x001f00; | ||
| 336 | mask_keyup = 0x004000; | ||
| 337 | polling = 50; /* ms */ | ||
| 338 | break; | ||
| 334 | case SAA7134_BOARD_BEHOLD_409FM: | 339 | case SAA7134_BOARD_BEHOLD_409FM: |
| 335 | case SAA7134_BOARD_BEHOLD_401: | 340 | case SAA7134_BOARD_BEHOLD_401: |
| 336 | case SAA7134_BOARD_BEHOLD_403: | 341 | case SAA7134_BOARD_BEHOLD_403: |
| @@ -343,7 +348,13 @@ int saa7134_input_init1(struct saa7134_dev *dev) | |||
| 343 | case SAA7134_BOARD_BEHOLD_505FM: | 348 | case SAA7134_BOARD_BEHOLD_505FM: |
| 344 | case SAA7134_BOARD_BEHOLD_507_9FM: | 349 | case SAA7134_BOARD_BEHOLD_507_9FM: |
| 345 | ir_codes = ir_codes_manli; | 350 | ir_codes = ir_codes_manli; |
| 346 | mask_keycode = 0x001f00; | 351 | mask_keycode = 0x003f00; |
| 352 | mask_keyup = 0x004000; | ||
| 353 | polling = 50; /* ms */ | ||
| 354 | break; | ||
| 355 | case SAA7134_BOARD_BEHOLD_COLUMBUS_TVFM: | ||
| 356 | ir_codes = ir_codes_behold_columbus; | ||
| 357 | mask_keycode = 0x003f00; | ||
| 347 | mask_keyup = 0x004000; | 358 | mask_keyup = 0x004000; |
| 348 | polling = 50; // ms | 359 | polling = 50; // ms |
| 349 | break; | 360 | break; |
diff --git a/drivers/media/video/saa7134/saa7134-reg.h b/drivers/media/video/saa7134/saa7134-reg.h index ac6431ba4fc3..86f5eefdb0f6 100644 --- a/drivers/media/video/saa7134/saa7134-reg.h +++ b/drivers/media/video/saa7134/saa7134-reg.h | |||
| @@ -365,6 +365,9 @@ | |||
| 365 | #define SAA7135_DSP_RWSTATE_RDB (1 << 1) | 365 | #define SAA7135_DSP_RWSTATE_RDB (1 << 1) |
| 366 | #define SAA7135_DSP_RWSTATE_WRR (1 << 0) | 366 | #define SAA7135_DSP_RWSTATE_WRR (1 << 0) |
| 367 | 367 | ||
| 368 | #define SAA7135_DSP_RWCLEAR 0x586 | ||
| 369 | #define SAA7135_DSP_RWCLEAR_RERR 1 | ||
| 370 | |||
| 368 | /* ------------------------------------------------------------------ */ | 371 | /* ------------------------------------------------------------------ */ |
| 369 | /* | 372 | /* |
| 370 | * Local variables: | 373 | * Local variables: |
diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c index f1b8fcaeb43a..eae72fd60cec 100644 --- a/drivers/media/video/saa7134/saa7134-ts.c +++ b/drivers/media/video/saa7134/saa7134-ts.c | |||
| @@ -32,7 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | /* ------------------------------------------------------------------ */ | 33 | /* ------------------------------------------------------------------ */ |
| 34 | 34 | ||
| 35 | static unsigned int ts_debug = 0; | 35 | static unsigned int ts_debug; |
| 36 | module_param(ts_debug, int, 0644); | 36 | module_param(ts_debug, int, 0644); |
| 37 | MODULE_PARM_DESC(ts_debug,"enable debug messages [ts]"); | 37 | MODULE_PARM_DESC(ts_debug,"enable debug messages [ts]"); |
| 38 | 38 | ||
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c index 4e9810469ae3..232af598d947 100644 --- a/drivers/media/video/saa7134/saa7134-tvaudio.c +++ b/drivers/media/video/saa7134/saa7134-tvaudio.c | |||
| @@ -35,18 +35,18 @@ | |||
| 35 | 35 | ||
| 36 | /* ------------------------------------------------------------------ */ | 36 | /* ------------------------------------------------------------------ */ |
| 37 | 37 | ||
| 38 | static unsigned int audio_debug = 0; | 38 | static unsigned int audio_debug; |
| 39 | module_param(audio_debug, int, 0644); | 39 | module_param(audio_debug, int, 0644); |
| 40 | MODULE_PARM_DESC(audio_debug,"enable debug messages [tv audio]"); | 40 | MODULE_PARM_DESC(audio_debug,"enable debug messages [tv audio]"); |
| 41 | 41 | ||
| 42 | static unsigned int audio_ddep = 0; | 42 | static unsigned int audio_ddep; |
| 43 | module_param(audio_ddep, int, 0644); | 43 | module_param(audio_ddep, int, 0644); |
| 44 | MODULE_PARM_DESC(audio_ddep,"audio ddep overwrite"); | 44 | MODULE_PARM_DESC(audio_ddep,"audio ddep overwrite"); |
| 45 | 45 | ||
| 46 | static int audio_clock_override = UNSET; | 46 | static int audio_clock_override = UNSET; |
| 47 | module_param(audio_clock_override, int, 0644); | 47 | module_param(audio_clock_override, int, 0644); |
| 48 | 48 | ||
| 49 | static int audio_clock_tweak = 0; | 49 | static int audio_clock_tweak; |
| 50 | module_param(audio_clock_tweak, int, 0644); | 50 | module_param(audio_clock_tweak, int, 0644); |
| 51 | MODULE_PARM_DESC(audio_clock_tweak, "Audio clock tick fine tuning for cards with audio crystal that's slightly off (range [-1024 .. 1024])"); | 51 | MODULE_PARM_DESC(audio_clock_tweak, "Audio clock tick fine tuning for cards with audio crystal that's slightly off (range [-1024 .. 1024])"); |
| 52 | 52 | ||
| @@ -653,6 +653,17 @@ static char *stdres[0x20] = { | |||
| 653 | 653 | ||
| 654 | #define DSP_RETRY 32 | 654 | #define DSP_RETRY 32 |
| 655 | #define DSP_DELAY 16 | 655 | #define DSP_DELAY 16 |
| 656 | #define SAA7135_DSP_RWCLEAR_RERR 1 | ||
| 657 | |||
| 658 | static inline int saa_dsp_reset_error_bit(struct saa7134_dev *dev) | ||
| 659 | { | ||
| 660 | int state = saa_readb(SAA7135_DSP_RWSTATE); | ||
| 661 | if (unlikely(state & SAA7135_DSP_RWSTATE_ERR)) { | ||
| 662 | d2printk("%s: resetting error bit\n", dev->name); | ||
| 663 | saa_writeb(SAA7135_DSP_RWCLEAR, SAA7135_DSP_RWCLEAR_RERR); | ||
| 664 | } | ||
| 665 | return 0; | ||
| 666 | } | ||
| 656 | 667 | ||
| 657 | static inline int saa_dsp_wait_bit(struct saa7134_dev *dev, int bit) | 668 | static inline int saa_dsp_wait_bit(struct saa7134_dev *dev, int bit) |
| 658 | { | 669 | { |
| @@ -660,8 +671,8 @@ static inline int saa_dsp_wait_bit(struct saa7134_dev *dev, int bit) | |||
| 660 | 671 | ||
| 661 | state = saa_readb(SAA7135_DSP_RWSTATE); | 672 | state = saa_readb(SAA7135_DSP_RWSTATE); |
| 662 | if (unlikely(state & SAA7135_DSP_RWSTATE_ERR)) { | 673 | if (unlikely(state & SAA7135_DSP_RWSTATE_ERR)) { |
| 663 | printk("%s: dsp access error\n",dev->name); | 674 | printk(KERN_WARNING "%s: dsp access error\n", dev->name); |
| 664 | /* FIXME: send ack ... */ | 675 | saa_dsp_reset_error_bit(dev); |
| 665 | return -EIO; | 676 | return -EIO; |
| 666 | } | 677 | } |
| 667 | while (0 == (state & bit)) { | 678 | while (0 == (state & bit)) { |
diff --git a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c index f0d5ed9c2b06..cb0304298a96 100644 --- a/drivers/media/video/saa7134/saa7134-vbi.c +++ b/drivers/media/video/saa7134/saa7134-vbi.c | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | 31 | ||
| 32 | /* ------------------------------------------------------------------ */ | 32 | /* ------------------------------------------------------------------ */ |
| 33 | 33 | ||
| 34 | static unsigned int vbi_debug = 0; | 34 | static unsigned int vbi_debug; |
| 35 | module_param(vbi_debug, int, 0644); | 35 | module_param(vbi_debug, int, 0644); |
| 36 | MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]"); | 36 | MODULE_PARM_DESC(vbi_debug,"enable debug messages [vbi]"); |
| 37 | 37 | ||
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c index 39c41ad97d0e..a0baf2d0ba7f 100644 --- a/drivers/media/video/saa7134/saa7134-video.c +++ b/drivers/media/video/saa7134/saa7134-video.c | |||
| @@ -40,7 +40,7 @@ | |||
| 40 | 40 | ||
| 41 | unsigned int video_debug; | 41 | unsigned int video_debug; |
| 42 | static unsigned int gbuffers = 8; | 42 | static unsigned int gbuffers = 8; |
| 43 | static unsigned int noninterlaced = 0; | 43 | static unsigned int noninterlaced; /* 0 */ |
| 44 | static unsigned int gbufsize = 720*576*4; | 44 | static unsigned int gbufsize = 720*576*4; |
| 45 | static unsigned int gbufsize_max = 720*576*4; | 45 | static unsigned int gbufsize_max = 720*576*4; |
| 46 | static char secam[] = "--"; | 46 | static char secam[] = "--"; |
| @@ -626,13 +626,8 @@ void saa7134_set_tvnorm_hw(struct saa7134_dev *dev) | |||
| 626 | { | 626 | { |
| 627 | saa7134_set_decoder(dev); | 627 | saa7134_set_decoder(dev); |
| 628 | 628 | ||
| 629 | if (card_in(dev, dev->ctl_input).tv) { | 629 | if (card_in(dev, dev->ctl_input).tv) |
| 630 | if ((card(dev).tuner_type == TUNER_PHILIPS_TDA8290) | ||
| 631 | && ((card(dev).tuner_config == 1) | ||
| 632 | || (card(dev).tuner_config == 2))) | ||
| 633 | saa7134_set_gpio(dev, 22, 5); | ||
| 634 | saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id); | 630 | saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id); |
| 635 | } | ||
| 636 | } | 631 | } |
| 637 | 632 | ||
| 638 | static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) | 633 | static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) |
| @@ -1350,14 +1345,14 @@ static int video_open(struct inode *inode, struct file *file) | |||
| 1350 | fh->height = 576; | 1345 | fh->height = 576; |
| 1351 | v4l2_prio_open(&dev->prio,&fh->prio); | 1346 | v4l2_prio_open(&dev->prio,&fh->prio); |
| 1352 | 1347 | ||
| 1353 | videobuf_queue_pci_init(&fh->cap, &video_qops, | 1348 | videobuf_queue_sg_init(&fh->cap, &video_qops, |
| 1354 | dev->pci, &dev->slock, | 1349 | &dev->pci->dev, &dev->slock, |
| 1355 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 1350 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
| 1356 | V4L2_FIELD_INTERLACED, | 1351 | V4L2_FIELD_INTERLACED, |
| 1357 | sizeof(struct saa7134_buf), | 1352 | sizeof(struct saa7134_buf), |
| 1358 | fh); | 1353 | fh); |
| 1359 | videobuf_queue_pci_init(&fh->vbi, &saa7134_vbi_qops, | 1354 | videobuf_queue_sg_init(&fh->vbi, &saa7134_vbi_qops, |
| 1360 | dev->pci, &dev->slock, | 1355 | &dev->pci->dev, &dev->slock, |
| 1361 | V4L2_BUF_TYPE_VBI_CAPTURE, | 1356 | V4L2_BUF_TYPE_VBI_CAPTURE, |
| 1362 | V4L2_FIELD_SEQ_TB, | 1357 | V4L2_FIELD_SEQ_TB, |
| 1363 | sizeof(struct saa7134_buf), | 1358 | sizeof(struct saa7134_buf), |
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h index f940d0254798..924ffd13637e 100644 --- a/drivers/media/video/saa7134/saa7134.h +++ b/drivers/media/video/saa7134/saa7134.h | |||
| @@ -253,7 +253,17 @@ struct saa7134_format { | |||
| 253 | #define SAA7134_BOARD_BEHOLD_607_9FM 129 | 253 | #define SAA7134_BOARD_BEHOLD_607_9FM 129 |
| 254 | #define SAA7134_BOARD_BEHOLD_M6 130 | 254 | #define SAA7134_BOARD_BEHOLD_M6 130 |
| 255 | #define SAA7134_BOARD_TWINHAN_DTV_DVB_3056 131 | 255 | #define SAA7134_BOARD_TWINHAN_DTV_DVB_3056 131 |
| 256 | #define SAA7134_BOARD_GENIUS_TVGO_A11MCE 132 | 256 | #define SAA7134_BOARD_GENIUS_TVGO_A11MCE 132 |
| 257 | #define SAA7134_BOARD_PHILIPS_SNAKE 133 | ||
| 258 | #define SAA7134_BOARD_CREATIX_CTX953 134 | ||
| 259 | #define SAA7134_BOARD_MSI_TVANYWHERE_AD11 135 | ||
| 260 | #define SAA7134_BOARD_AVERMEDIA_CARDBUS_506 136 | ||
| 261 | #define SAA7134_BOARD_AVERMEDIA_A16D 137 | ||
| 262 | #define SAA7134_BOARD_AVERMEDIA_M115 138 | ||
| 263 | #define SAA7134_BOARD_VIDEOMATE_T750 139 | ||
| 264 | #define SAA7134_BOARD_AVERMEDIA_A700_PRO 140 | ||
| 265 | #define SAA7134_BOARD_AVERMEDIA_A700_HYBRID 141 | ||
| 266 | |||
| 257 | 267 | ||
| 258 | #define SAA7134_MAXBOARDS 8 | 268 | #define SAA7134_MAXBOARDS 8 |
| 259 | #define SAA7134_INPUT_MAX 8 | 269 | #define SAA7134_INPUT_MAX 8 |
| @@ -380,9 +390,7 @@ struct saa7134_fh { | |||
| 380 | unsigned int radio; | 390 | unsigned int radio; |
| 381 | enum v4l2_buf_type type; | 391 | enum v4l2_buf_type type; |
| 382 | unsigned int resources; | 392 | unsigned int resources; |
| 383 | #ifdef VIDIOC_G_PRIORITY | ||
| 384 | enum v4l2_priority prio; | 393 | enum v4l2_priority prio; |
| 385 | #endif | ||
| 386 | 394 | ||
| 387 | /* video overlay */ | 395 | /* video overlay */ |
| 388 | struct v4l2_window win; | 396 | struct v4l2_window win; |
| @@ -454,9 +462,7 @@ struct saa7134_dev { | |||
| 454 | struct list_head devlist; | 462 | struct list_head devlist; |
| 455 | struct mutex lock; | 463 | struct mutex lock; |
| 456 | spinlock_t slock; | 464 | spinlock_t slock; |
| 457 | #ifdef VIDIOC_G_PRIORITY | ||
| 458 | struct v4l2_prio_state prio; | 465 | struct v4l2_prio_state prio; |
| 459 | #endif | ||
| 460 | /* workstruct for loading modules */ | 466 | /* workstruct for loading modules */ |
| 461 | struct work_struct request_module_wk; | 467 | struct work_struct request_module_wk; |
| 462 | 468 | ||
| @@ -556,7 +562,9 @@ struct saa7134_dev { | |||
| 556 | #if defined(CONFIG_VIDEO_SAA7134_DVB) || defined(CONFIG_VIDEO_SAA7134_DVB_MODULE) | 562 | #if defined(CONFIG_VIDEO_SAA7134_DVB) || defined(CONFIG_VIDEO_SAA7134_DVB_MODULE) |
| 557 | /* SAA7134_MPEG_DVB only */ | 563 | /* SAA7134_MPEG_DVB only */ |
| 558 | struct videobuf_dvb dvb; | 564 | struct videobuf_dvb dvb; |
| 559 | int (*original_demod_sleep)(struct dvb_frontend* fe); | 565 | int (*original_demod_sleep)(struct dvb_frontend *fe); |
| 566 | int (*original_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage); | ||
| 567 | int (*original_set_high_voltage)(struct dvb_frontend *fe, long arg); | ||
| 560 | #endif | 568 | #endif |
| 561 | }; | 569 | }; |
| 562 | 570 | ||
| @@ -594,7 +602,6 @@ extern int saa7134_no_overlay; | |||
| 594 | 602 | ||
| 595 | void saa7134_track_gpio(struct saa7134_dev *dev, char *msg); | 603 | void saa7134_track_gpio(struct saa7134_dev *dev, char *msg); |
| 596 | void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value); | 604 | void saa7134_set_gpio(struct saa7134_dev *dev, int bit_no, int value); |
| 597 | int saa7134_tuner_callback(void *ptr, int command, int arg); | ||
| 598 | 605 | ||
| 599 | #define SAA7134_PGTABLE_SIZE 4096 | 606 | #define SAA7134_PGTABLE_SIZE 4096 |
| 600 | 607 | ||
| @@ -631,6 +638,7 @@ extern struct pci_device_id __devinitdata saa7134_pci_tbl[]; | |||
| 631 | 638 | ||
| 632 | extern int saa7134_board_init1(struct saa7134_dev *dev); | 639 | extern int saa7134_board_init1(struct saa7134_dev *dev); |
| 633 | extern int saa7134_board_init2(struct saa7134_dev *dev); | 640 | extern int saa7134_board_init2(struct saa7134_dev *dev); |
| 641 | int saa7134_tuner_callback(void *priv, int command, int arg); | ||
| 634 | 642 | ||
| 635 | 643 | ||
| 636 | /* ----------------------------------------------------------- */ | 644 | /* ----------------------------------------------------------- */ |
diff --git a/drivers/media/video/saa717x.c b/drivers/media/video/saa717x.c new file mode 100644 index 000000000000..53c5edbcf7ea --- /dev/null +++ b/drivers/media/video/saa717x.c | |||
| @@ -0,0 +1,1516 @@ | |||
| 1 | /* | ||
| 2 | * saa717x - Philips SAA717xHL video decoder driver | ||
| 3 | * | ||
| 4 | * Based on the saa7115 driver | ||
| 5 | * | ||
| 6 | * Changes by Ohta Kyuma <alpha292@bremen.or.jp> | ||
| 7 | * - Apply to SAA717x,NEC uPD64031,uPD64083. (1/31/2004) | ||
| 8 | * | ||
| 9 | * Changes by T.Adachi (tadachi@tadachi-net.com) | ||
| 10 | * - support audio, video scaler etc, and checked the initialize sequence. | ||
| 11 | * | ||
| 12 | * Cleaned up by Hans Verkuil <hverkuil@xs4all.nl> | ||
| 13 | * | ||
| 14 | * Note: this is a reversed engineered driver based on captures from | ||
| 15 | * the I2C bus under Windows. This chip is very similar to the saa7134, | ||
| 16 | * though. Unfortunately, this driver is currently only working for NTSC. | ||
| 17 | * | ||
| 18 | * This program is free software; you can redistribute it and/or modify | ||
| 19 | * it under the terms of the GNU General Public License as published by | ||
| 20 | * the Free Software Foundation; either version 2 of the License, or | ||
| 21 | * (at your option) any later version. | ||
| 22 | * | ||
| 23 | * This program is distributed in the hope that it will be useful, | ||
| 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 26 | * GNU General Public License for more details. | ||
| 27 | * | ||
| 28 | * You should have received a copy of the GNU General Public License | ||
| 29 | * along with this program; if not, write to the Free Software | ||
| 30 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
| 31 | */ | ||
| 32 | |||
| 33 | #include <linux/version.h> | ||
| 34 | #include <linux/module.h> | ||
| 35 | #include <linux/kernel.h> | ||
| 36 | #include <linux/sched.h> | ||
| 37 | |||
| 38 | #include <linux/videodev.h> | ||
| 39 | #include <linux/videodev2.h> | ||
| 40 | #include <linux/i2c.h> | ||
| 41 | #include <media/v4l2-common.h> | ||
| 42 | #include <media/v4l2-i2c-drv.h> | ||
| 43 | |||
| 44 | MODULE_DESCRIPTION("Philips SAA717x audio/video decoder driver"); | ||
| 45 | MODULE_AUTHOR("K. Ohta, T. Adachi, Hans Verkuil"); | ||
| 46 | MODULE_LICENSE("GPL"); | ||
| 47 | |||
| 48 | static int debug; | ||
| 49 | module_param(debug, int, 0644); | ||
| 50 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | ||
| 51 | |||
| 52 | /* | ||
| 53 | * Generic i2c probe | ||
| 54 | * concerning the addresses: i2c wants 7 bit (without the r/w bit), so '>>1' | ||
| 55 | */ | ||
| 56 | |||
| 57 | struct saa717x_state { | ||
| 58 | v4l2_std_id std; | ||
| 59 | int input; | ||
| 60 | int enable; | ||
| 61 | int radio; | ||
| 62 | int bright; | ||
| 63 | int contrast; | ||
| 64 | int hue; | ||
| 65 | int sat; | ||
| 66 | int playback; | ||
| 67 | int audio; | ||
| 68 | int tuner_audio_mode; | ||
| 69 | int audio_main_mute; | ||
| 70 | int audio_main_vol_r; | ||
| 71 | int audio_main_vol_l; | ||
| 72 | u16 audio_main_bass; | ||
| 73 | u16 audio_main_treble; | ||
| 74 | u16 audio_main_volume; | ||
| 75 | u16 audio_main_balance; | ||
| 76 | int audio_input; | ||
| 77 | }; | ||
| 78 | |||
| 79 | /* ----------------------------------------------------------------------- */ | ||
| 80 | |||
| 81 | /* for audio mode */ | ||
| 82 | #define TUNER_AUDIO_MONO 0 /* LL */ | ||
| 83 | #define TUNER_AUDIO_STEREO 1 /* LR */ | ||
| 84 | #define TUNER_AUDIO_LANG1 2 /* LL */ | ||
| 85 | #define TUNER_AUDIO_LANG2 3 /* RR */ | ||
| 86 | |||
| 87 | #define SAA717X_NTSC_WIDTH (704) | ||
| 88 | #define SAA717X_NTSC_HEIGHT (480) | ||
| 89 | |||
| 90 | /* ----------------------------------------------------------------------- */ | ||
| 91 | |||
| 92 | static int saa717x_write(struct i2c_client *client, u32 reg, u32 value) | ||
| 93 | { | ||
| 94 | struct i2c_adapter *adap = client->adapter; | ||
| 95 | int fw_addr = reg == 0x454 || (reg >= 0x464 && reg <= 0x478) || reg == 0x480 || reg == 0x488; | ||
| 96 | unsigned char mm1[6]; | ||
| 97 | struct i2c_msg msg; | ||
| 98 | |||
| 99 | msg.flags = 0; | ||
| 100 | msg.addr = client->addr; | ||
| 101 | mm1[0] = (reg >> 8) & 0xff; | ||
| 102 | mm1[1] = reg & 0xff; | ||
| 103 | |||
| 104 | if (fw_addr) { | ||
| 105 | mm1[4] = (value >> 16) & 0xff; | ||
| 106 | mm1[3] = (value >> 8) & 0xff; | ||
| 107 | mm1[2] = value & 0xff; | ||
| 108 | } else { | ||
| 109 | mm1[2] = value & 0xff; | ||
| 110 | } | ||
| 111 | msg.len = fw_addr ? 5 : 3; /* Long Registers have *only* three bytes! */ | ||
| 112 | msg.buf = mm1; | ||
| 113 | v4l_dbg(2, debug, client, "wrote: reg 0x%03x=%08x\n", reg, value); | ||
| 114 | return i2c_transfer(adap, &msg, 1) == 1; | ||
| 115 | } | ||
| 116 | |||
| 117 | static void saa717x_write_regs(struct i2c_client *client, u32 *data) | ||
| 118 | { | ||
| 119 | while (data[0] || data[1]) { | ||
| 120 | saa717x_write(client, data[0], data[1]); | ||
| 121 | data += 2; | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 125 | static u32 saa717x_read(struct i2c_client *client, u32 reg) | ||
| 126 | { | ||
| 127 | struct i2c_adapter *adap = client->adapter; | ||
| 128 | int fw_addr = (reg >= 0x404 && reg <= 0x4b8) || reg == 0x528; | ||
| 129 | unsigned char mm1[2]; | ||
| 130 | unsigned char mm2[4] = { 0, 0, 0, 0 }; | ||
| 131 | struct i2c_msg msgs[2]; | ||
| 132 | u32 value; | ||
| 133 | |||
| 134 | msgs[0].flags = 0; | ||
| 135 | msgs[1].flags = I2C_M_RD; | ||
| 136 | msgs[0].addr = msgs[1].addr = client->addr; | ||
| 137 | mm1[0] = (reg >> 8) & 0xff; | ||
| 138 | mm1[1] = reg & 0xff; | ||
| 139 | msgs[0].len = 2; | ||
| 140 | msgs[0].buf = mm1; | ||
| 141 | msgs[1].len = fw_addr ? 3 : 1; /* Multibyte Registers contains *only* 3 bytes */ | ||
| 142 | msgs[1].buf = mm2; | ||
| 143 | i2c_transfer(adap, msgs, 2); | ||
| 144 | |||
| 145 | if (fw_addr) | ||
| 146 | value = (mm2[2] & 0xff) | ((mm2[1] & 0xff) >> 8) | ((mm2[0] & 0xff) >> 16); | ||
| 147 | else | ||
| 148 | value = mm2[0] & 0xff; | ||
| 149 | |||
| 150 | v4l_dbg(2, debug, client, "read: reg 0x%03x=0x%08x\n", reg, value); | ||
| 151 | return value; | ||
| 152 | } | ||
| 153 | |||
| 154 | /* ----------------------------------------------------------------------- */ | ||
| 155 | |||
| 156 | static u32 reg_init_initialize[] = | ||
| 157 | { | ||
| 158 | /* from linux driver */ | ||
| 159 | 0x101, 0x008, /* Increment delay */ | ||
| 160 | |||
| 161 | 0x103, 0x000, /* Analog input control 2 */ | ||
| 162 | 0x104, 0x090, /* Analog input control 3 */ | ||
| 163 | 0x105, 0x090, /* Analog input control 4 */ | ||
| 164 | 0x106, 0x0eb, /* Horizontal sync start */ | ||
| 165 | 0x107, 0x0e0, /* Horizontal sync stop */ | ||
| 166 | 0x109, 0x055, /* Luminance control */ | ||
| 167 | |||
| 168 | 0x10f, 0x02a, /* Chroma gain control */ | ||
| 169 | 0x110, 0x000, /* Chroma control 2 */ | ||
| 170 | |||
| 171 | 0x114, 0x045, /* analog/ADC */ | ||
| 172 | |||
| 173 | 0x118, 0x040, /* RAW data gain */ | ||
| 174 | 0x119, 0x080, /* RAW data offset */ | ||
| 175 | |||
| 176 | 0x044, 0x000, /* VBI horizontal input window start (L) TASK A */ | ||
| 177 | 0x045, 0x000, /* VBI horizontal input window start (H) TASK A */ | ||
| 178 | 0x046, 0x0cf, /* VBI horizontal input window stop (L) TASK A */ | ||
| 179 | 0x047, 0x002, /* VBI horizontal input window stop (H) TASK A */ | ||
| 180 | |||
| 181 | 0x049, 0x000, /* VBI vertical input window start (H) TASK A */ | ||
| 182 | |||
| 183 | 0x04c, 0x0d0, /* VBI horizontal output length (L) TASK A */ | ||
| 184 | 0x04d, 0x002, /* VBI horizontal output length (H) TASK A */ | ||
| 185 | |||
| 186 | 0x064, 0x080, /* Lumina brightness TASK A */ | ||
| 187 | 0x065, 0x040, /* Luminance contrast TASK A */ | ||
| 188 | 0x066, 0x040, /* Chroma saturation TASK A */ | ||
| 189 | /* 067H: Reserved */ | ||
| 190 | 0x068, 0x000, /* VBI horizontal scaling increment (L) TASK A */ | ||
| 191 | 0x069, 0x004, /* VBI horizontal scaling increment (H) TASK A */ | ||
| 192 | 0x06a, 0x000, /* VBI phase offset TASK A */ | ||
| 193 | |||
| 194 | 0x06e, 0x000, /* Horizontal phase offset Luma TASK A */ | ||
| 195 | 0x06f, 0x000, /* Horizontal phase offset Chroma TASK A */ | ||
| 196 | |||
| 197 | 0x072, 0x000, /* Vertical filter mode TASK A */ | ||
| 198 | |||
| 199 | 0x084, 0x000, /* VBI horizontal input window start (L) TAKS B */ | ||
| 200 | 0x085, 0x000, /* VBI horizontal input window start (H) TAKS B */ | ||
| 201 | 0x086, 0x0cf, /* VBI horizontal input window stop (L) TAKS B */ | ||
| 202 | 0x087, 0x002, /* VBI horizontal input window stop (H) TAKS B */ | ||
| 203 | |||
| 204 | 0x089, 0x000, /* VBI vertical input window start (H) TAKS B */ | ||
| 205 | |||
| 206 | 0x08c, 0x0d0, /* VBI horizontal output length (L) TASK B */ | ||
| 207 | 0x08d, 0x002, /* VBI horizontal output length (H) TASK B */ | ||
| 208 | |||
| 209 | 0x0a4, 0x080, /* Lumina brightness TASK B */ | ||
| 210 | 0x0a5, 0x040, /* Luminance contrast TASK B */ | ||
| 211 | 0x0a6, 0x040, /* Chroma saturation TASK B */ | ||
| 212 | /* 0A7H reserved */ | ||
| 213 | 0x0a8, 0x000, /* VBI horizontal scaling increment (L) TASK B */ | ||
| 214 | 0x0a9, 0x004, /* VBI horizontal scaling increment (H) TASK B */ | ||
| 215 | 0x0aa, 0x000, /* VBI phase offset TASK B */ | ||
| 216 | |||
| 217 | 0x0ae, 0x000, /* Horizontal phase offset Luma TASK B */ | ||
| 218 | 0x0af, 0x000, /*Horizontal phase offset Chroma TASK B */ | ||
| 219 | |||
| 220 | 0x0b2, 0x000, /* Vertical filter mode TASK B */ | ||
| 221 | |||
| 222 | 0x00c, 0x000, /* Start point GREEN path */ | ||
| 223 | 0x00d, 0x000, /* Start point BLUE path */ | ||
| 224 | 0x00e, 0x000, /* Start point RED path */ | ||
| 225 | |||
| 226 | 0x010, 0x010, /* GREEN path gamma curve --- */ | ||
| 227 | 0x011, 0x020, | ||
| 228 | 0x012, 0x030, | ||
| 229 | 0x013, 0x040, | ||
| 230 | 0x014, 0x050, | ||
| 231 | 0x015, 0x060, | ||
| 232 | 0x016, 0x070, | ||
| 233 | 0x017, 0x080, | ||
| 234 | 0x018, 0x090, | ||
| 235 | 0x019, 0x0a0, | ||
| 236 | 0x01a, 0x0b0, | ||
| 237 | 0x01b, 0x0c0, | ||
| 238 | 0x01c, 0x0d0, | ||
| 239 | 0x01d, 0x0e0, | ||
| 240 | 0x01e, 0x0f0, | ||
| 241 | 0x01f, 0x0ff, /* --- GREEN path gamma curve */ | ||
| 242 | |||
| 243 | 0x020, 0x010, /* BLUE path gamma curve --- */ | ||
| 244 | 0x021, 0x020, | ||
| 245 | 0x022, 0x030, | ||
| 246 | 0x023, 0x040, | ||
| 247 | 0x024, 0x050, | ||
| 248 | 0x025, 0x060, | ||
| 249 | 0x026, 0x070, | ||
| 250 | 0x027, 0x080, | ||
| 251 | 0x028, 0x090, | ||
| 252 | 0x029, 0x0a0, | ||
| 253 | 0x02a, 0x0b0, | ||
| 254 | 0x02b, 0x0c0, | ||
| 255 | 0x02c, 0x0d0, | ||
| 256 | 0x02d, 0x0e0, | ||
| 257 | 0x02e, 0x0f0, | ||
| 258 | 0x02f, 0x0ff, /* --- BLUE path gamma curve */ | ||
| 259 | |||
| 260 | 0x030, 0x010, /* RED path gamma curve --- */ | ||
| 261 | 0x031, 0x020, | ||
| 262 | 0x032, 0x030, | ||
| 263 | 0x033, 0x040, | ||
| 264 | 0x034, 0x050, | ||
| 265 | 0x035, 0x060, | ||
| 266 | 0x036, 0x070, | ||
| 267 | 0x037, 0x080, | ||
| 268 | 0x038, 0x090, | ||
| 269 | 0x039, 0x0a0, | ||
| 270 | 0x03a, 0x0b0, | ||
| 271 | 0x03b, 0x0c0, | ||
| 272 | 0x03c, 0x0d0, | ||
| 273 | 0x03d, 0x0e0, | ||
| 274 | 0x03e, 0x0f0, | ||
| 275 | 0x03f, 0x0ff, /* --- RED path gamma curve */ | ||
| 276 | |||
| 277 | 0x109, 0x085, /* Luminance control */ | ||
| 278 | |||
| 279 | /**** from app start ****/ | ||
| 280 | 0x584, 0x000, /* AGC gain control */ | ||
| 281 | 0x585, 0x000, /* Program count */ | ||
| 282 | 0x586, 0x003, /* Status reset */ | ||
| 283 | 0x588, 0x0ff, /* Number of audio samples (L) */ | ||
| 284 | 0x589, 0x00f, /* Number of audio samples (M) */ | ||
| 285 | 0x58a, 0x000, /* Number of audio samples (H) */ | ||
| 286 | 0x58b, 0x000, /* Audio select */ | ||
| 287 | 0x58c, 0x010, /* Audio channel assign1 */ | ||
| 288 | 0x58d, 0x032, /* Audio channel assign2 */ | ||
| 289 | 0x58e, 0x054, /* Audio channel assign3 */ | ||
| 290 | 0x58f, 0x023, /* Audio format */ | ||
| 291 | 0x590, 0x000, /* SIF control */ | ||
| 292 | |||
| 293 | 0x595, 0x000, /* ?? */ | ||
| 294 | 0x596, 0x000, /* ?? */ | ||
| 295 | 0x597, 0x000, /* ?? */ | ||
| 296 | |||
| 297 | 0x464, 0x00, /* Digital input crossbar1 */ | ||
| 298 | |||
| 299 | 0x46c, 0xbbbb10, /* Digital output selection1-3 */ | ||
| 300 | 0x470, 0x101010, /* Digital output selection4-6 */ | ||
| 301 | |||
| 302 | 0x478, 0x00, /* Sound feature control */ | ||
| 303 | |||
| 304 | 0x474, 0x18, /* Softmute control */ | ||
| 305 | |||
| 306 | 0x454, 0x0425b9, /* Sound Easy programming(reset) */ | ||
| 307 | 0x454, 0x042539, /* Sound Easy programming(reset) */ | ||
| 308 | |||
| 309 | |||
| 310 | /**** common setting( of DVD play, including scaler commands) ****/ | ||
| 311 | 0x042, 0x003, /* Data path configuration for VBI (TASK A) */ | ||
| 312 | |||
| 313 | 0x082, 0x003, /* Data path configuration for VBI (TASK B) */ | ||
| 314 | |||
| 315 | 0x108, 0x0f8, /* Sync control */ | ||
| 316 | 0x2a9, 0x0fd, /* ??? */ | ||
| 317 | 0x102, 0x089, /* select video input "mode 9" */ | ||
| 318 | 0x111, 0x000, /* Mode/delay control */ | ||
| 319 | |||
| 320 | 0x10e, 0x00a, /* Chroma control 1 */ | ||
| 321 | |||
| 322 | 0x594, 0x002, /* SIF, analog I/O select */ | ||
| 323 | |||
| 324 | 0x454, 0x0425b9, /* Sound */ | ||
| 325 | 0x454, 0x042539, | ||
| 326 | |||
| 327 | 0x111, 0x000, | ||
| 328 | 0x10e, 0x00a, | ||
| 329 | 0x464, 0x000, | ||
| 330 | 0x300, 0x000, | ||
| 331 | 0x301, 0x006, | ||
| 332 | 0x302, 0x000, | ||
| 333 | 0x303, 0x006, | ||
| 334 | 0x308, 0x040, | ||
| 335 | 0x309, 0x000, | ||
| 336 | 0x30a, 0x000, | ||
| 337 | 0x30b, 0x000, | ||
| 338 | 0x000, 0x002, | ||
| 339 | 0x001, 0x000, | ||
| 340 | 0x002, 0x000, | ||
| 341 | 0x003, 0x000, | ||
| 342 | 0x004, 0x033, | ||
| 343 | 0x040, 0x01d, | ||
| 344 | 0x041, 0x001, | ||
| 345 | 0x042, 0x004, | ||
| 346 | 0x043, 0x000, | ||
| 347 | 0x080, 0x01e, | ||
| 348 | 0x081, 0x001, | ||
| 349 | 0x082, 0x004, | ||
| 350 | 0x083, 0x000, | ||
| 351 | 0x190, 0x018, | ||
| 352 | 0x115, 0x000, | ||
| 353 | 0x116, 0x012, | ||
| 354 | 0x117, 0x018, | ||
| 355 | 0x04a, 0x011, | ||
| 356 | 0x08a, 0x011, | ||
| 357 | 0x04b, 0x000, | ||
| 358 | 0x08b, 0x000, | ||
| 359 | 0x048, 0x000, | ||
| 360 | 0x088, 0x000, | ||
| 361 | 0x04e, 0x012, | ||
| 362 | 0x08e, 0x012, | ||
| 363 | 0x058, 0x012, | ||
| 364 | 0x098, 0x012, | ||
| 365 | 0x059, 0x000, | ||
| 366 | 0x099, 0x000, | ||
| 367 | 0x05a, 0x003, | ||
| 368 | 0x09a, 0x003, | ||
| 369 | 0x05b, 0x001, | ||
| 370 | 0x09b, 0x001, | ||
| 371 | 0x054, 0x008, | ||
| 372 | 0x094, 0x008, | ||
| 373 | 0x055, 0x000, | ||
| 374 | 0x095, 0x000, | ||
| 375 | 0x056, 0x0c7, | ||
| 376 | 0x096, 0x0c7, | ||
| 377 | 0x057, 0x002, | ||
| 378 | 0x097, 0x002, | ||
| 379 | 0x0ff, 0x0ff, | ||
| 380 | 0x060, 0x001, | ||
| 381 | 0x0a0, 0x001, | ||
| 382 | 0x061, 0x000, | ||
| 383 | 0x0a1, 0x000, | ||
| 384 | 0x062, 0x000, | ||
| 385 | 0x0a2, 0x000, | ||
| 386 | 0x063, 0x000, | ||
| 387 | 0x0a3, 0x000, | ||
| 388 | 0x070, 0x000, | ||
| 389 | 0x0b0, 0x000, | ||
| 390 | 0x071, 0x004, | ||
| 391 | 0x0b1, 0x004, | ||
| 392 | 0x06c, 0x0e9, | ||
| 393 | 0x0ac, 0x0e9, | ||
| 394 | 0x06d, 0x003, | ||
| 395 | 0x0ad, 0x003, | ||
| 396 | 0x05c, 0x0d0, | ||
| 397 | 0x09c, 0x0d0, | ||
| 398 | 0x05d, 0x002, | ||
| 399 | 0x09d, 0x002, | ||
| 400 | 0x05e, 0x0f2, | ||
| 401 | 0x09e, 0x0f2, | ||
| 402 | 0x05f, 0x000, | ||
| 403 | 0x09f, 0x000, | ||
| 404 | 0x074, 0x000, | ||
| 405 | 0x0b4, 0x000, | ||
| 406 | 0x075, 0x000, | ||
| 407 | 0x0b5, 0x000, | ||
| 408 | 0x076, 0x000, | ||
| 409 | 0x0b6, 0x000, | ||
| 410 | 0x077, 0x000, | ||
| 411 | 0x0b7, 0x000, | ||
| 412 | 0x195, 0x008, | ||
| 413 | 0x0ff, 0x0ff, | ||
| 414 | 0x108, 0x0f8, | ||
| 415 | 0x111, 0x000, | ||
| 416 | 0x10e, 0x00a, | ||
| 417 | 0x2a9, 0x0fd, | ||
| 418 | 0x464, 0x001, | ||
| 419 | 0x454, 0x042135, | ||
| 420 | 0x598, 0x0e7, | ||
| 421 | 0x599, 0x07d, | ||
| 422 | 0x59a, 0x018, | ||
| 423 | 0x59c, 0x066, | ||
| 424 | 0x59d, 0x090, | ||
| 425 | 0x59e, 0x001, | ||
| 426 | 0x584, 0x000, | ||
| 427 | 0x585, 0x000, | ||
| 428 | 0x586, 0x003, | ||
| 429 | 0x588, 0x0ff, | ||
| 430 | 0x589, 0x00f, | ||
| 431 | 0x58a, 0x000, | ||
| 432 | 0x58b, 0x000, | ||
| 433 | 0x58c, 0x010, | ||
| 434 | 0x58d, 0x032, | ||
| 435 | 0x58e, 0x054, | ||
| 436 | 0x58f, 0x023, | ||
| 437 | 0x590, 0x000, | ||
| 438 | 0x595, 0x000, | ||
| 439 | 0x596, 0x000, | ||
| 440 | 0x597, 0x000, | ||
| 441 | 0x464, 0x000, | ||
| 442 | 0x46c, 0xbbbb10, | ||
| 443 | 0x470, 0x101010, | ||
| 444 | |||
| 445 | |||
| 446 | 0x478, 0x000, | ||
| 447 | 0x474, 0x018, | ||
| 448 | 0x454, 0x042135, | ||
| 449 | 0x598, 0x0e7, | ||
| 450 | 0x599, 0x07d, | ||
| 451 | 0x59a, 0x018, | ||
| 452 | 0x59c, 0x066, | ||
| 453 | 0x59d, 0x090, | ||
| 454 | 0x59e, 0x001, | ||
| 455 | 0x584, 0x000, | ||
| 456 | 0x585, 0x000, | ||
| 457 | 0x586, 0x003, | ||
| 458 | 0x588, 0x0ff, | ||
| 459 | 0x589, 0x00f, | ||
| 460 | 0x58a, 0x000, | ||
| 461 | 0x58b, 0x000, | ||
| 462 | 0x58c, 0x010, | ||
| 463 | 0x58d, 0x032, | ||
| 464 | 0x58e, 0x054, | ||
| 465 | 0x58f, 0x023, | ||
| 466 | 0x590, 0x000, | ||
| 467 | 0x595, 0x000, | ||
| 468 | 0x596, 0x000, | ||
| 469 | 0x597, 0x000, | ||
| 470 | 0x464, 0x000, | ||
| 471 | 0x46c, 0xbbbb10, | ||
| 472 | 0x470, 0x101010, | ||
| 473 | |||
| 474 | 0x478, 0x000, | ||
| 475 | 0x474, 0x018, | ||
| 476 | 0x454, 0x042135, | ||
| 477 | 0x598, 0x0e7, | ||
| 478 | 0x599, 0x07d, | ||
| 479 | 0x59a, 0x018, | ||
| 480 | 0x59c, 0x066, | ||
| 481 | 0x59d, 0x090, | ||
| 482 | 0x59e, 0x001, | ||
| 483 | 0x584, 0x000, | ||
| 484 | 0x585, 0x000, | ||
| 485 | 0x586, 0x003, | ||
| 486 | 0x588, 0x0ff, | ||
| 487 | 0x589, 0x00f, | ||
| 488 | 0x58a, 0x000, | ||
| 489 | 0x58b, 0x000, | ||
| 490 | 0x58c, 0x010, | ||
| 491 | 0x58d, 0x032, | ||
| 492 | 0x58e, 0x054, | ||
| 493 | 0x58f, 0x023, | ||
| 494 | 0x590, 0x000, | ||
| 495 | 0x595, 0x000, | ||
| 496 | 0x596, 0x000, | ||
| 497 | 0x597, 0x000, | ||
| 498 | 0x464, 0x000, | ||
| 499 | 0x46c, 0xbbbb10, | ||
| 500 | 0x470, 0x101010, | ||
| 501 | 0x478, 0x000, | ||
| 502 | 0x474, 0x018, | ||
| 503 | 0x454, 0x042135, | ||
| 504 | 0x193, 0x000, | ||
| 505 | 0x300, 0x000, | ||
| 506 | 0x301, 0x006, | ||
| 507 | 0x302, 0x000, | ||
| 508 | 0x303, 0x006, | ||
| 509 | 0x308, 0x040, | ||
| 510 | 0x309, 0x000, | ||
| 511 | 0x30a, 0x000, | ||
| 512 | 0x30b, 0x000, | ||
| 513 | 0x000, 0x002, | ||
| 514 | 0x001, 0x000, | ||
| 515 | 0x002, 0x000, | ||
| 516 | 0x003, 0x000, | ||
| 517 | 0x004, 0x033, | ||
| 518 | 0x040, 0x01d, | ||
| 519 | 0x041, 0x001, | ||
| 520 | 0x042, 0x004, | ||
| 521 | 0x043, 0x000, | ||
| 522 | 0x080, 0x01e, | ||
| 523 | 0x081, 0x001, | ||
| 524 | 0x082, 0x004, | ||
| 525 | 0x083, 0x000, | ||
| 526 | 0x190, 0x018, | ||
| 527 | 0x115, 0x000, | ||
| 528 | 0x116, 0x012, | ||
| 529 | 0x117, 0x018, | ||
| 530 | 0x04a, 0x011, | ||
| 531 | 0x08a, 0x011, | ||
| 532 | 0x04b, 0x000, | ||
| 533 | 0x08b, 0x000, | ||
| 534 | 0x048, 0x000, | ||
| 535 | 0x088, 0x000, | ||
| 536 | 0x04e, 0x012, | ||
| 537 | 0x08e, 0x012, | ||
| 538 | 0x058, 0x012, | ||
| 539 | 0x098, 0x012, | ||
| 540 | 0x059, 0x000, | ||
| 541 | 0x099, 0x000, | ||
| 542 | 0x05a, 0x003, | ||
| 543 | 0x09a, 0x003, | ||
| 544 | 0x05b, 0x001, | ||
| 545 | 0x09b, 0x001, | ||
| 546 | 0x054, 0x008, | ||
| 547 | 0x094, 0x008, | ||
| 548 | 0x055, 0x000, | ||
| 549 | 0x095, 0x000, | ||
| 550 | 0x056, 0x0c7, | ||
| 551 | 0x096, 0x0c7, | ||
| 552 | 0x057, 0x002, | ||
| 553 | 0x097, 0x002, | ||
| 554 | 0x060, 0x001, | ||
| 555 | 0x0a0, 0x001, | ||
| 556 | 0x061, 0x000, | ||
| 557 | 0x0a1, 0x000, | ||
| 558 | 0x062, 0x000, | ||
| 559 | 0x0a2, 0x000, | ||
| 560 | 0x063, 0x000, | ||
| 561 | 0x0a3, 0x000, | ||
| 562 | 0x070, 0x000, | ||
| 563 | 0x0b0, 0x000, | ||
| 564 | 0x071, 0x004, | ||
| 565 | 0x0b1, 0x004, | ||
| 566 | 0x06c, 0x0e9, | ||
| 567 | 0x0ac, 0x0e9, | ||
| 568 | 0x06d, 0x003, | ||
| 569 | 0x0ad, 0x003, | ||
| 570 | 0x05c, 0x0d0, | ||
| 571 | 0x09c, 0x0d0, | ||
| 572 | 0x05d, 0x002, | ||
| 573 | 0x09d, 0x002, | ||
| 574 | 0x05e, 0x0f2, | ||
| 575 | 0x09e, 0x0f2, | ||
| 576 | 0x05f, 0x000, | ||
| 577 | 0x09f, 0x000, | ||
| 578 | 0x074, 0x000, | ||
| 579 | 0x0b4, 0x000, | ||
| 580 | 0x075, 0x000, | ||
| 581 | 0x0b5, 0x000, | ||
| 582 | 0x076, 0x000, | ||
| 583 | 0x0b6, 0x000, | ||
| 584 | 0x077, 0x000, | ||
| 585 | 0x0b7, 0x000, | ||
| 586 | 0x195, 0x008, | ||
| 587 | 0x598, 0x0e7, | ||
| 588 | 0x599, 0x07d, | ||
| 589 | 0x59a, 0x018, | ||
| 590 | 0x59c, 0x066, | ||
| 591 | 0x59d, 0x090, | ||
| 592 | 0x59e, 0x001, | ||
| 593 | 0x584, 0x000, | ||
| 594 | 0x585, 0x000, | ||
| 595 | 0x586, 0x003, | ||
| 596 | 0x588, 0x0ff, | ||
| 597 | 0x589, 0x00f, | ||
| 598 | 0x58a, 0x000, | ||
| 599 | 0x58b, 0x000, | ||
| 600 | 0x58c, 0x010, | ||
| 601 | 0x58d, 0x032, | ||
| 602 | 0x58e, 0x054, | ||
| 603 | 0x58f, 0x023, | ||
| 604 | 0x590, 0x000, | ||
| 605 | 0x595, 0x000, | ||
| 606 | 0x596, 0x000, | ||
| 607 | 0x597, 0x000, | ||
| 608 | 0x464, 0x000, | ||
| 609 | 0x46c, 0xbbbb10, | ||
| 610 | 0x470, 0x101010, | ||
| 611 | 0x478, 0x000, | ||
| 612 | 0x474, 0x018, | ||
| 613 | 0x454, 0x042135, | ||
| 614 | 0x193, 0x0a6, | ||
| 615 | 0x108, 0x0f8, | ||
| 616 | 0x042, 0x003, | ||
| 617 | 0x082, 0x003, | ||
| 618 | 0x454, 0x0425b9, | ||
| 619 | 0x454, 0x042539, | ||
| 620 | 0x193, 0x000, | ||
| 621 | 0x193, 0x0a6, | ||
| 622 | 0x464, 0x000, | ||
| 623 | |||
| 624 | 0, 0 | ||
| 625 | }; | ||
| 626 | |||
| 627 | /* Tuner */ | ||
| 628 | static u32 reg_init_tuner_input[] = { | ||
| 629 | 0x108, 0x0f8, /* Sync control */ | ||
| 630 | 0x111, 0x000, /* Mode/delay control */ | ||
| 631 | 0x10e, 0x00a, /* Chroma control 1 */ | ||
| 632 | 0, 0 | ||
| 633 | }; | ||
| 634 | |||
| 635 | /* Composite */ | ||
| 636 | static u32 reg_init_composite_input[] = { | ||
| 637 | 0x108, 0x0e8, /* Sync control */ | ||
| 638 | 0x111, 0x000, /* Mode/delay control */ | ||
| 639 | 0x10e, 0x04a, /* Chroma control 1 */ | ||
| 640 | 0, 0 | ||
| 641 | }; | ||
| 642 | |||
| 643 | /* S-Video */ | ||
| 644 | static u32 reg_init_svideo_input[] = { | ||
| 645 | 0x108, 0x0e8, /* Sync control */ | ||
| 646 | 0x111, 0x000, /* Mode/delay control */ | ||
| 647 | 0x10e, 0x04a, /* Chroma control 1 */ | ||
| 648 | 0, 0 | ||
| 649 | }; | ||
| 650 | |||
| 651 | static u32 reg_set_audio_template[4][2] = | ||
| 652 | { | ||
| 653 | { /* for MONO | ||
| 654 | tadachi 6/29 DMA audio output select? | ||
| 655 | Register 0x46c | ||
| 656 | 7-4: DMA2, 3-0: DMA1 ch. DMA4, DMA3 DMA2, DMA1 | ||
| 657 | 0: MAIN left, 1: MAIN right | ||
| 658 | 2: AUX1 left, 3: AUX1 right | ||
| 659 | 4: AUX2 left, 5: AUX2 right | ||
| 660 | 6: DPL left, 7: DPL right | ||
| 661 | 8: DPL center, 9: DPL surround | ||
| 662 | A: monitor output, B: digital sense */ | ||
| 663 | 0xbbbb00, | ||
| 664 | |||
| 665 | /* tadachi 6/29 DAC and I2S output select? | ||
| 666 | Register 0x470 | ||
| 667 | 7-4:DAC right ch. 3-0:DAC left ch. | ||
| 668 | I2S1 right,left I2S2 right,left */ | ||
| 669 | 0x00, | ||
| 670 | }, | ||
| 671 | { /* for STEREO */ | ||
| 672 | 0xbbbb10, 0x101010, | ||
| 673 | }, | ||
| 674 | { /* for LANG1 */ | ||
| 675 | 0xbbbb00, 0x00, | ||
| 676 | }, | ||
| 677 | { /* for LANG2/SAP */ | ||
| 678 | 0xbbbb11, 0x111111, | ||
| 679 | } | ||
| 680 | }; | ||
| 681 | |||
| 682 | |||
| 683 | /* Get detected audio flags (from saa7134 driver) */ | ||
| 684 | static void get_inf_dev_status(struct i2c_client *client, | ||
| 685 | int *dual_flag, int *stereo_flag) | ||
| 686 | { | ||
| 687 | u32 reg_data3; | ||
| 688 | |||
| 689 | static char *stdres[0x20] = { | ||
| 690 | [0x00] = "no standard detected", | ||
| 691 | [0x01] = "B/G (in progress)", | ||
| 692 | [0x02] = "D/K (in progress)", | ||
| 693 | [0x03] = "M (in progress)", | ||
| 694 | |||
| 695 | [0x04] = "B/G A2", | ||
| 696 | [0x05] = "B/G NICAM", | ||
| 697 | [0x06] = "D/K A2 (1)", | ||
| 698 | [0x07] = "D/K A2 (2)", | ||
| 699 | [0x08] = "D/K A2 (3)", | ||
| 700 | [0x09] = "D/K NICAM", | ||
| 701 | [0x0a] = "L NICAM", | ||
| 702 | [0x0b] = "I NICAM", | ||
| 703 | |||
| 704 | [0x0c] = "M Korea", | ||
| 705 | [0x0d] = "M BTSC ", | ||
| 706 | [0x0e] = "M EIAJ", | ||
| 707 | |||
| 708 | [0x0f] = "FM radio / IF 10.7 / 50 deemp", | ||
| 709 | [0x10] = "FM radio / IF 10.7 / 75 deemp", | ||
| 710 | [0x11] = "FM radio / IF sel / 50 deemp", | ||
| 711 | [0x12] = "FM radio / IF sel / 75 deemp", | ||
| 712 | |||
| 713 | [0x13 ... 0x1e] = "unknown", | ||
| 714 | [0x1f] = "??? [in progress]", | ||
| 715 | }; | ||
| 716 | |||
| 717 | |||
| 718 | *dual_flag = *stereo_flag = 0; | ||
| 719 | |||
| 720 | /* (demdec status: 0x528) */ | ||
| 721 | |||
| 722 | /* read current status */ | ||
| 723 | reg_data3 = saa717x_read(client, 0x0528); | ||
| 724 | |||
| 725 | v4l_dbg(1, debug, client, "tvaudio thread status: 0x%x [%s%s%s]\n", | ||
| 726 | reg_data3, stdres[reg_data3 & 0x1f], | ||
| 727 | (reg_data3 & 0x000020) ? ",stereo" : "", | ||
| 728 | (reg_data3 & 0x000040) ? ",dual" : ""); | ||
| 729 | v4l_dbg(1, debug, client, "detailed status: " | ||
| 730 | "%s#%s#%s#%s#%s#%s#%s#%s#%s#%s#%s#%s#%s#%s\n", | ||
| 731 | (reg_data3 & 0x000080) ? " A2/EIAJ pilot tone " : "", | ||
| 732 | (reg_data3 & 0x000100) ? " A2/EIAJ dual " : "", | ||
| 733 | (reg_data3 & 0x000200) ? " A2/EIAJ stereo " : "", | ||
| 734 | (reg_data3 & 0x000400) ? " A2/EIAJ noise mute " : "", | ||
| 735 | |||
| 736 | (reg_data3 & 0x000800) ? " BTSC/FM radio pilot " : "", | ||
| 737 | (reg_data3 & 0x001000) ? " SAP carrier " : "", | ||
| 738 | (reg_data3 & 0x002000) ? " BTSC stereo noise mute " : "", | ||
| 739 | (reg_data3 & 0x004000) ? " SAP noise mute " : "", | ||
| 740 | (reg_data3 & 0x008000) ? " VDSP " : "", | ||
| 741 | |||
| 742 | (reg_data3 & 0x010000) ? " NICST " : "", | ||
| 743 | (reg_data3 & 0x020000) ? " NICDU " : "", | ||
| 744 | (reg_data3 & 0x040000) ? " NICAM muted " : "", | ||
| 745 | (reg_data3 & 0x080000) ? " NICAM reserve sound " : "", | ||
| 746 | |||
| 747 | (reg_data3 & 0x100000) ? " init done " : ""); | ||
| 748 | |||
| 749 | if (reg_data3 & 0x000220) { | ||
| 750 | v4l_dbg(1, debug, client, "ST!!!\n"); | ||
| 751 | *stereo_flag = 1; | ||
| 752 | } | ||
| 753 | |||
| 754 | if (reg_data3 & 0x000140) { | ||
| 755 | v4l_dbg(1, debug, client, "DUAL!!!\n"); | ||
| 756 | *dual_flag = 1; | ||
| 757 | } | ||
| 758 | } | ||
| 759 | |||
| 760 | /* regs write to set audio mode */ | ||
| 761 | static void set_audio_mode(struct i2c_client *client, int audio_mode) | ||
| 762 | { | ||
| 763 | v4l_dbg(1, debug, client, "writing registers to set audio mode by set %d\n", | ||
| 764 | audio_mode); | ||
| 765 | |||
| 766 | saa717x_write(client, 0x46c, reg_set_audio_template[audio_mode][0]); | ||
| 767 | saa717x_write(client, 0x470, reg_set_audio_template[audio_mode][1]); | ||
| 768 | } | ||
| 769 | |||
| 770 | /* write regs to video output level (bright,contrast,hue,sat) */ | ||
| 771 | static void set_video_output_level_regs(struct i2c_client *client, | ||
| 772 | struct saa717x_state *decoder) | ||
| 773 | { | ||
| 774 | /* brightness ffh (bright) - 80h (ITU level) - 00h (dark) */ | ||
| 775 | saa717x_write(client, 0x10a, decoder->bright); | ||
| 776 | |||
| 777 | /* contrast 7fh (max: 1.984) - 44h (ITU) - 40h (1.0) - | ||
| 778 | 0h (luminance off) 40: i2c dump | ||
| 779 | c0h (-1.0 inverse chrominance) | ||
| 780 | 80h (-2.0 inverse chrominance) */ | ||
| 781 | saa717x_write(client, 0x10b, decoder->contrast); | ||
| 782 | |||
| 783 | /* saturation? 7fh(max)-40h(ITU)-0h(color off) | ||
| 784 | c0h (-1.0 inverse chrominance) | ||
| 785 | 80h (-2.0 inverse chrominance) */ | ||
| 786 | saa717x_write(client, 0x10c, decoder->sat); | ||
| 787 | |||
| 788 | /* color hue (phase) control | ||
| 789 | 7fh (+178.6) - 0h (0 normal) - 80h (-180.0) */ | ||
| 790 | saa717x_write(client, 0x10d, decoder->hue); | ||
| 791 | } | ||
| 792 | |||
| 793 | /* write regs to set audio volume, bass and treble */ | ||
| 794 | static int set_audio_regs(struct i2c_client *client, | ||
| 795 | struct saa717x_state *decoder) | ||
| 796 | { | ||
| 797 | u8 mute = 0xac; /* -84 dB */ | ||
| 798 | u32 val; | ||
| 799 | unsigned int work_l, work_r; | ||
| 800 | |||
| 801 | /* set SIF analog I/O select */ | ||
| 802 | saa717x_write(client, 0x0594, decoder->audio_input); | ||
| 803 | v4l_dbg(1, debug, client, "set audio input %d\n", | ||
| 804 | decoder->audio_input); | ||
| 805 | |||
| 806 | /* normalize ( 65535 to 0 -> 24 to -40 (not -84)) */ | ||
| 807 | work_l = (min(65536 - decoder->audio_main_balance, 32768) * decoder->audio_main_volume) / 32768; | ||
| 808 | work_r = (min(decoder->audio_main_balance, (u16)32768) * decoder->audio_main_volume) / 32768; | ||
| 809 | decoder->audio_main_vol_l = (long)work_l * (24 - (-40)) / 65535 - 40; | ||
| 810 | decoder->audio_main_vol_r = (long)work_r * (24 - (-40)) / 65535 - 40; | ||
| 811 | |||
| 812 | /* set main volume */ | ||
| 813 | /* main volume L[7-0],R[7-0],0x00 24=24dB,-83dB, -84(mute) */ | ||
| 814 | /* def:0dB->6dB(MPG600GR) */ | ||
| 815 | /* if mute is on, set mute */ | ||
| 816 | if (decoder->audio_main_mute) { | ||
| 817 | val = mute | (mute << 8); | ||
| 818 | } else { | ||
| 819 | val = (u8)decoder->audio_main_vol_l | | ||
| 820 | ((u8)decoder->audio_main_vol_r << 8); | ||
| 821 | } | ||
| 822 | |||
| 823 | saa717x_write(client, 0x480, val); | ||
| 824 | |||
| 825 | /* bass and treble; go to another function */ | ||
| 826 | /* set bass and treble */ | ||
| 827 | val = decoder->audio_main_bass | (decoder->audio_main_treble << 8); | ||
| 828 | saa717x_write(client, 0x488, val); | ||
| 829 | return 0; | ||
| 830 | } | ||
| 831 | |||
| 832 | /********** scaling staff ***********/ | ||
| 833 | static void set_h_prescale(struct i2c_client *client, | ||
| 834 | int task, int prescale) | ||
| 835 | { | ||
| 836 | static const struct { | ||
| 837 | int xpsc; | ||
| 838 | int xacl; | ||
| 839 | int xc2_1; | ||
| 840 | int xdcg; | ||
| 841 | int vpfy; | ||
| 842 | } vals[] = { | ||
| 843 | /* XPSC XACL XC2_1 XDCG VPFY */ | ||
| 844 | { 1, 0, 0, 0, 0 }, | ||
| 845 | { 2, 2, 1, 2, 2 }, | ||
| 846 | { 3, 4, 1, 3, 2 }, | ||
| 847 | { 4, 8, 1, 4, 2 }, | ||
| 848 | { 5, 8, 1, 4, 2 }, | ||
| 849 | { 6, 8, 1, 4, 3 }, | ||
| 850 | { 7, 8, 1, 4, 3 }, | ||
| 851 | { 8, 15, 0, 4, 3 }, | ||
| 852 | { 9, 15, 0, 4, 3 }, | ||
| 853 | { 10, 16, 1, 5, 3 }, | ||
| 854 | }; | ||
| 855 | static const int count = ARRAY_SIZE(vals); | ||
| 856 | int i, task_shift; | ||
| 857 | |||
| 858 | task_shift = task * 0x40; | ||
| 859 | for (i = 0; i < count; i++) | ||
| 860 | if (vals[i].xpsc == prescale) | ||
| 861 | break; | ||
| 862 | if (i == count) | ||
| 863 | return; | ||
| 864 | |||
| 865 | /* horizonal prescaling */ | ||
| 866 | saa717x_write(client, 0x60 + task_shift, vals[i].xpsc); | ||
| 867 | /* accumulation length */ | ||
| 868 | saa717x_write(client, 0x61 + task_shift, vals[i].xacl); | ||
| 869 | /* level control */ | ||
| 870 | saa717x_write(client, 0x62 + task_shift, | ||
| 871 | (vals[i].xc2_1 << 3) | vals[i].xdcg); | ||
| 872 | /*FIR prefilter control */ | ||
| 873 | saa717x_write(client, 0x63 + task_shift, | ||
| 874 | (vals[i].vpfy << 2) | vals[i].vpfy); | ||
| 875 | } | ||
| 876 | |||
| 877 | /********** scaling staff ***********/ | ||
| 878 | static void set_v_scale(struct i2c_client *client, int task, int yscale) | ||
| 879 | { | ||
| 880 | int task_shift; | ||
| 881 | |||
| 882 | task_shift = task * 0x40; | ||
| 883 | /* Vertical scaling ratio (LOW) */ | ||
| 884 | saa717x_write(client, 0x70 + task_shift, yscale & 0xff); | ||
| 885 | /* Vertical scaling ratio (HI) */ | ||
| 886 | saa717x_write(client, 0x71 + task_shift, yscale >> 8); | ||
| 887 | } | ||
| 888 | |||
| 889 | static int saa717x_set_audio_clock_freq(struct i2c_client *client, u32 freq) | ||
| 890 | { | ||
| 891 | /* not yet implament, so saa717x_cfg_??hz_??_audio is not defined. */ | ||
| 892 | return 0; | ||
| 893 | } | ||
| 894 | |||
| 895 | static int saa717x_set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl) | ||
| 896 | { | ||
| 897 | struct saa717x_state *state = i2c_get_clientdata(client); | ||
| 898 | |||
| 899 | switch (ctrl->id) { | ||
| 900 | case V4L2_CID_BRIGHTNESS: | ||
| 901 | if (ctrl->value < 0 || ctrl->value > 255) { | ||
| 902 | v4l_err(client, "invalid brightness setting %d\n", ctrl->value); | ||
| 903 | return -ERANGE; | ||
| 904 | } | ||
| 905 | |||
| 906 | state->bright = ctrl->value; | ||
| 907 | v4l_dbg(1, debug, client, "bright:%d\n", state->bright); | ||
| 908 | saa717x_write(client, 0x10a, state->bright); | ||
| 909 | break; | ||
| 910 | |||
| 911 | case V4L2_CID_CONTRAST: | ||
| 912 | if (ctrl->value < 0 || ctrl->value > 127) { | ||
| 913 | v4l_err(client, "invalid contrast setting %d\n", ctrl->value); | ||
| 914 | return -ERANGE; | ||
| 915 | } | ||
| 916 | |||
| 917 | state->contrast = ctrl->value; | ||
| 918 | v4l_dbg(1, debug, client, "contrast:%d\n", state->contrast); | ||
| 919 | saa717x_write(client, 0x10b, state->contrast); | ||
| 920 | break; | ||
| 921 | |||
| 922 | case V4L2_CID_SATURATION: | ||
| 923 | if (ctrl->value < 0 || ctrl->value > 127) { | ||
| 924 | v4l_err(client, "invalid saturation setting %d\n", ctrl->value); | ||
| 925 | return -ERANGE; | ||
| 926 | } | ||
| 927 | |||
| 928 | state->sat = ctrl->value; | ||
| 929 | v4l_dbg(1, debug, client, "sat:%d\n", state->sat); | ||
| 930 | saa717x_write(client, 0x10c, state->sat); | ||
| 931 | break; | ||
| 932 | |||
| 933 | case V4L2_CID_HUE: | ||
| 934 | if (ctrl->value < -127 || ctrl->value > 127) { | ||
| 935 | v4l_err(client, "invalid hue setting %d\n", ctrl->value); | ||
| 936 | return -ERANGE; | ||
| 937 | } | ||
| 938 | |||
| 939 | state->hue = ctrl->value; | ||
| 940 | v4l_dbg(1, debug, client, "hue:%d\n", state->hue); | ||
| 941 | saa717x_write(client, 0x10d, state->hue); | ||
| 942 | break; | ||
| 943 | |||
| 944 | case V4L2_CID_AUDIO_MUTE: | ||
| 945 | state->audio_main_mute = ctrl->value; | ||
| 946 | set_audio_regs(client, state); | ||
| 947 | break; | ||
| 948 | |||
| 949 | case V4L2_CID_AUDIO_VOLUME: | ||
| 950 | state->audio_main_volume = ctrl->value; | ||
| 951 | set_audio_regs(client, state); | ||
| 952 | break; | ||
| 953 | |||
| 954 | case V4L2_CID_AUDIO_BALANCE: | ||
| 955 | state->audio_main_balance = ctrl->value; | ||
| 956 | set_audio_regs(client, state); | ||
| 957 | break; | ||
| 958 | |||
| 959 | case V4L2_CID_AUDIO_TREBLE: | ||
| 960 | state->audio_main_treble = ctrl->value; | ||
| 961 | set_audio_regs(client, state); | ||
| 962 | break; | ||
| 963 | |||
| 964 | case V4L2_CID_AUDIO_BASS: | ||
| 965 | state->audio_main_bass = ctrl->value; | ||
| 966 | set_audio_regs(client, state); | ||
| 967 | break; | ||
| 968 | |||
| 969 | default: | ||
| 970 | return -EINVAL; | ||
| 971 | } | ||
| 972 | |||
| 973 | return 0; | ||
| 974 | } | ||
| 975 | |||
| 976 | static int saa717x_get_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl) | ||
| 977 | { | ||
| 978 | struct saa717x_state *state = i2c_get_clientdata(client); | ||
| 979 | |||
| 980 | switch (ctrl->id) { | ||
| 981 | case V4L2_CID_BRIGHTNESS: | ||
| 982 | ctrl->value = state->bright; | ||
| 983 | break; | ||
| 984 | |||
| 985 | case V4L2_CID_CONTRAST: | ||
| 986 | ctrl->value = state->contrast; | ||
| 987 | break; | ||
| 988 | |||
| 989 | case V4L2_CID_SATURATION: | ||
| 990 | ctrl->value = state->sat; | ||
| 991 | break; | ||
| 992 | |||
| 993 | case V4L2_CID_HUE: | ||
| 994 | ctrl->value = state->hue; | ||
| 995 | break; | ||
| 996 | |||
| 997 | case V4L2_CID_AUDIO_MUTE: | ||
| 998 | ctrl->value = state->audio_main_mute; | ||
| 999 | break; | ||
| 1000 | |||
| 1001 | case V4L2_CID_AUDIO_VOLUME: | ||
| 1002 | ctrl->value = state->audio_main_volume; | ||
| 1003 | break; | ||
| 1004 | |||
| 1005 | case V4L2_CID_AUDIO_BALANCE: | ||
| 1006 | ctrl->value = state->audio_main_balance; | ||
| 1007 | break; | ||
| 1008 | |||
| 1009 | case V4L2_CID_AUDIO_TREBLE: | ||
| 1010 | ctrl->value = state->audio_main_treble; | ||
| 1011 | break; | ||
| 1012 | |||
| 1013 | case V4L2_CID_AUDIO_BASS: | ||
| 1014 | ctrl->value = state->audio_main_bass; | ||
| 1015 | break; | ||
| 1016 | |||
| 1017 | default: | ||
| 1018 | return -EINVAL; | ||
| 1019 | } | ||
| 1020 | |||
| 1021 | return 0; | ||
| 1022 | } | ||
| 1023 | |||
| 1024 | static struct v4l2_queryctrl saa717x_qctrl[] = { | ||
| 1025 | { | ||
| 1026 | .id = V4L2_CID_BRIGHTNESS, | ||
| 1027 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 1028 | .name = "Brightness", | ||
| 1029 | .minimum = 0, | ||
| 1030 | .maximum = 255, | ||
| 1031 | .step = 1, | ||
| 1032 | .default_value = 128, | ||
| 1033 | .flags = 0, | ||
| 1034 | }, { | ||
| 1035 | .id = V4L2_CID_CONTRAST, | ||
| 1036 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 1037 | .name = "Contrast", | ||
| 1038 | .minimum = 0, | ||
| 1039 | .maximum = 255, | ||
| 1040 | .step = 1, | ||
| 1041 | .default_value = 64, | ||
| 1042 | .flags = 0, | ||
| 1043 | }, { | ||
| 1044 | .id = V4L2_CID_SATURATION, | ||
| 1045 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 1046 | .name = "Saturation", | ||
| 1047 | .minimum = 0, | ||
| 1048 | .maximum = 255, | ||
| 1049 | .step = 1, | ||
| 1050 | .default_value = 64, | ||
| 1051 | .flags = 0, | ||
| 1052 | }, { | ||
| 1053 | .id = V4L2_CID_HUE, | ||
| 1054 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 1055 | .name = "Hue", | ||
| 1056 | .minimum = -128, | ||
| 1057 | .maximum = 127, | ||
| 1058 | .step = 1, | ||
| 1059 | .default_value = 0, | ||
| 1060 | .flags = 0, | ||
| 1061 | }, { | ||
| 1062 | .id = V4L2_CID_AUDIO_VOLUME, | ||
| 1063 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 1064 | .name = "Volume", | ||
| 1065 | .minimum = 0, | ||
| 1066 | .maximum = 65535, | ||
| 1067 | .step = 65535 / 100, | ||
| 1068 | .default_value = 58880, | ||
| 1069 | .flags = 0, | ||
| 1070 | }, { | ||
| 1071 | .id = V4L2_CID_AUDIO_BALANCE, | ||
| 1072 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 1073 | .name = "Balance", | ||
| 1074 | .minimum = 0, | ||
| 1075 | .maximum = 65535, | ||
| 1076 | .step = 65535 / 100, | ||
| 1077 | .default_value = 32768, | ||
| 1078 | .flags = 0, | ||
| 1079 | }, { | ||
| 1080 | .id = V4L2_CID_AUDIO_MUTE, | ||
| 1081 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
| 1082 | .name = "Mute", | ||
| 1083 | .minimum = 0, | ||
| 1084 | .maximum = 1, | ||
| 1085 | .step = 1, | ||
| 1086 | .default_value = 1, | ||
| 1087 | .flags = 0, | ||
| 1088 | }, { | ||
| 1089 | .id = V4L2_CID_AUDIO_BASS, | ||
| 1090 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 1091 | .name = "Bass", | ||
| 1092 | .minimum = 0, | ||
| 1093 | .maximum = 65535, | ||
| 1094 | .step = 65535 / 100, | ||
| 1095 | .default_value = 32768, | ||
| 1096 | }, { | ||
| 1097 | .id = V4L2_CID_AUDIO_TREBLE, | ||
| 1098 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
| 1099 | .name = "Treble", | ||
| 1100 | .minimum = 0, | ||
| 1101 | .maximum = 65535, | ||
| 1102 | .step = 65535 / 100, | ||
| 1103 | .default_value = 32768, | ||
| 1104 | }, | ||
| 1105 | }; | ||
| 1106 | |||
| 1107 | static int saa717x_set_video_input(struct i2c_client *client, struct saa717x_state *decoder, int inp) | ||
| 1108 | { | ||
| 1109 | int is_tuner = inp & 0x80; /* tuner input flag */ | ||
| 1110 | |||
| 1111 | inp &= 0x7f; | ||
| 1112 | |||
| 1113 | v4l_dbg(1, debug, client, "decoder set input (%d)\n", inp); | ||
| 1114 | /* inputs from 0-9 are available*/ | ||
| 1115 | /* saa717x have mode0-mode9 but mode5 is reserved. */ | ||
| 1116 | if (inp < 0 || inp > 9 || inp == 5) | ||
| 1117 | return -EINVAL; | ||
| 1118 | |||
| 1119 | if (decoder->input != inp) { | ||
| 1120 | int input_line = inp; | ||
| 1121 | |||
| 1122 | decoder->input = input_line; | ||
| 1123 | v4l_dbg(1, debug, client, "now setting %s input %d\n", | ||
| 1124 | input_line >= 6 ? "S-Video" : "Composite", | ||
| 1125 | input_line); | ||
| 1126 | |||
| 1127 | /* select mode */ | ||
| 1128 | saa717x_write(client, 0x102, | ||
| 1129 | (saa717x_read(client, 0x102) & 0xf0) | | ||
| 1130 | input_line); | ||
| 1131 | |||
| 1132 | /* bypass chrominance trap for modes 6..9 */ | ||
| 1133 | saa717x_write(client, 0x109, | ||
| 1134 | (saa717x_read(client, 0x109) & 0x7f) | | ||
| 1135 | (input_line < 6 ? 0x0 : 0x80)); | ||
| 1136 | |||
| 1137 | /* change audio_mode */ | ||
| 1138 | if (is_tuner) { | ||
| 1139 | /* tuner */ | ||
| 1140 | set_audio_mode(client, decoder->tuner_audio_mode); | ||
| 1141 | } else { | ||
| 1142 | /* Force to STEREO mode if Composite or | ||
| 1143 | * S-Video were chosen */ | ||
| 1144 | set_audio_mode(client, TUNER_AUDIO_STEREO); | ||
| 1145 | } | ||
| 1146 | /* change initialize procedure (Composite/S-Video) */ | ||
| 1147 | if (is_tuner) | ||
| 1148 | saa717x_write_regs(client, reg_init_tuner_input); | ||
| 1149 | else if (input_line >= 6) | ||
| 1150 | saa717x_write_regs(client, reg_init_svideo_input); | ||
| 1151 | else | ||
| 1152 | saa717x_write_regs(client, reg_init_composite_input); | ||
| 1153 | } | ||
| 1154 | |||
| 1155 | return 0; | ||
| 1156 | } | ||
| 1157 | |||
| 1158 | static int saa717x_command(struct i2c_client *client, unsigned cmd, void *arg) | ||
| 1159 | { | ||
| 1160 | struct saa717x_state *decoder = i2c_get_clientdata(client); | ||
| 1161 | |||
| 1162 | v4l_dbg(1, debug, client, "IOCTL: %08x\n", cmd); | ||
| 1163 | |||
| 1164 | switch (cmd) { | ||
| 1165 | case VIDIOC_INT_AUDIO_CLOCK_FREQ: | ||
| 1166 | return saa717x_set_audio_clock_freq(client, *(u32 *)arg); | ||
| 1167 | |||
| 1168 | case VIDIOC_G_CTRL: | ||
| 1169 | return saa717x_get_v4lctrl(client, (struct v4l2_control *)arg); | ||
| 1170 | |||
| 1171 | case VIDIOC_S_CTRL: | ||
| 1172 | return saa717x_set_v4lctrl(client, (struct v4l2_control *)arg); | ||
| 1173 | |||
| 1174 | case VIDIOC_QUERYCTRL: { | ||
| 1175 | struct v4l2_queryctrl *qc = arg; | ||
| 1176 | int i; | ||
| 1177 | |||
| 1178 | for (i = 0; i < ARRAY_SIZE(saa717x_qctrl); i++) | ||
| 1179 | if (qc->id && qc->id == saa717x_qctrl[i].id) { | ||
| 1180 | memcpy(qc, &saa717x_qctrl[i], sizeof(*qc)); | ||
| 1181 | return 0; | ||
| 1182 | } | ||
| 1183 | return -EINVAL; | ||
| 1184 | } | ||
| 1185 | |||
| 1186 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
| 1187 | case VIDIOC_DBG_G_REGISTER: { | ||
| 1188 | struct v4l2_register *reg = arg; | ||
| 1189 | |||
| 1190 | if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) | ||
| 1191 | return -EINVAL; | ||
| 1192 | if (!capable(CAP_SYS_ADMIN)) | ||
| 1193 | return -EPERM; | ||
| 1194 | reg->val = saa717x_read(client, reg->reg); | ||
| 1195 | break; | ||
| 1196 | } | ||
| 1197 | |||
| 1198 | case VIDIOC_DBG_S_REGISTER: { | ||
| 1199 | struct v4l2_register *reg = arg; | ||
| 1200 | u16 addr = reg->reg & 0xffff; | ||
| 1201 | u8 val = reg->val & 0xff; | ||
| 1202 | |||
| 1203 | if (!v4l2_chip_match_i2c_client(client, reg->match_type, reg->match_chip)) | ||
| 1204 | return -EINVAL; | ||
| 1205 | if (!capable(CAP_SYS_ADMIN)) | ||
| 1206 | return -EPERM; | ||
| 1207 | saa717x_write(client, addr, val); | ||
| 1208 | break; | ||
| 1209 | } | ||
| 1210 | #endif | ||
| 1211 | |||
| 1212 | case VIDIOC_S_FMT: { | ||
| 1213 | struct v4l2_format *fmt = (struct v4l2_format *)arg; | ||
| 1214 | struct v4l2_pix_format *pix; | ||
| 1215 | int prescale, h_scale, v_scale; | ||
| 1216 | |||
| 1217 | pix = &fmt->fmt.pix; | ||
| 1218 | v4l_dbg(1, debug, client, "decoder set size\n"); | ||
| 1219 | |||
| 1220 | /* FIXME need better bounds checking here */ | ||
| 1221 | if (pix->width < 1 || pix->width > 1440) | ||
| 1222 | return -EINVAL; | ||
| 1223 | if (pix->height < 1 || pix->height > 960) | ||
| 1224 | return -EINVAL; | ||
| 1225 | |||
| 1226 | /* scaling setting */ | ||
| 1227 | /* NTSC and interlace only */ | ||
| 1228 | prescale = SAA717X_NTSC_WIDTH / pix->width; | ||
| 1229 | if (prescale == 0) | ||
| 1230 | prescale = 1; | ||
| 1231 | h_scale = 1024 * SAA717X_NTSC_WIDTH / prescale / pix->width; | ||
| 1232 | /* interlace */ | ||
| 1233 | v_scale = 512 * 2 * SAA717X_NTSC_HEIGHT / pix->height; | ||
| 1234 | |||
| 1235 | /* Horizontal prescaling etc */ | ||
| 1236 | set_h_prescale(client, 0, prescale); | ||
| 1237 | set_h_prescale(client, 1, prescale); | ||
| 1238 | |||
| 1239 | /* Horizontal scaling increment */ | ||
| 1240 | /* TASK A */ | ||
| 1241 | saa717x_write(client, 0x6C, (u8)(h_scale & 0xFF)); | ||
| 1242 | saa717x_write(client, 0x6D, (u8)((h_scale >> 8) & 0xFF)); | ||
| 1243 | /* TASK B */ | ||
| 1244 | saa717x_write(client, 0xAC, (u8)(h_scale & 0xFF)); | ||
| 1245 | saa717x_write(client, 0xAD, (u8)((h_scale >> 8) & 0xFF)); | ||
| 1246 | |||
| 1247 | /* Vertical prescaling etc */ | ||
| 1248 | set_v_scale(client, 0, v_scale); | ||
| 1249 | set_v_scale(client, 1, v_scale); | ||
| 1250 | |||
| 1251 | /* set video output size */ | ||
| 1252 | /* video number of pixels at output */ | ||
| 1253 | /* TASK A */ | ||
| 1254 | saa717x_write(client, 0x5C, (u8)(pix->width & 0xFF)); | ||
| 1255 | saa717x_write(client, 0x5D, (u8)((pix->width >> 8) & 0xFF)); | ||
| 1256 | /* TASK B */ | ||
| 1257 | saa717x_write(client, 0x9C, (u8)(pix->width & 0xFF)); | ||
| 1258 | saa717x_write(client, 0x9D, (u8)((pix->width >> 8) & 0xFF)); | ||
| 1259 | |||
| 1260 | /* video number of lines at output */ | ||
| 1261 | /* TASK A */ | ||
| 1262 | saa717x_write(client, 0x5E, (u8)(pix->height & 0xFF)); | ||
| 1263 | saa717x_write(client, 0x5F, (u8)((pix->height >> 8) & 0xFF)); | ||
| 1264 | /* TASK B */ | ||
| 1265 | saa717x_write(client, 0x9E, (u8)(pix->height & 0xFF)); | ||
| 1266 | saa717x_write(client, 0x9F, (u8)((pix->height >> 8) & 0xFF)); | ||
| 1267 | break; | ||
| 1268 | } | ||
| 1269 | |||
| 1270 | case AUDC_SET_RADIO: | ||
| 1271 | decoder->radio = 1; | ||
| 1272 | break; | ||
| 1273 | |||
| 1274 | case VIDIOC_S_STD: { | ||
| 1275 | v4l2_std_id std = *(v4l2_std_id *) arg; | ||
| 1276 | |||
| 1277 | v4l_dbg(1, debug, client, "decoder set norm "); | ||
| 1278 | v4l_dbg(1, debug, client, "(not yet implementd)\n"); | ||
| 1279 | |||
| 1280 | decoder->radio = 0; | ||
| 1281 | decoder->std = std; | ||
| 1282 | break; | ||
| 1283 | } | ||
| 1284 | |||
| 1285 | case VIDIOC_INT_G_AUDIO_ROUTING: { | ||
| 1286 | struct v4l2_routing *route = arg; | ||
| 1287 | |||
| 1288 | route->input = decoder->audio_input; | ||
| 1289 | route->output = 0; | ||
| 1290 | break; | ||
| 1291 | } | ||
| 1292 | |||
| 1293 | case VIDIOC_INT_S_AUDIO_ROUTING: { | ||
| 1294 | struct v4l2_routing *route = arg; | ||
| 1295 | |||
| 1296 | if (route->input < 3) { /* FIXME! --tadachi */ | ||
| 1297 | decoder->audio_input = route->input; | ||
| 1298 | v4l_dbg(1, debug, client, | ||
| 1299 | "set decoder audio input to %d\n", | ||
| 1300 | decoder->audio_input); | ||
| 1301 | set_audio_regs(client, decoder); | ||
| 1302 | break; | ||
| 1303 | } | ||
| 1304 | return -ERANGE; | ||
| 1305 | } | ||
| 1306 | |||
| 1307 | case VIDIOC_INT_S_VIDEO_ROUTING: { | ||
| 1308 | struct v4l2_routing *route = arg; | ||
| 1309 | int inp = route->input; | ||
| 1310 | |||
| 1311 | return saa717x_set_video_input(client, decoder, inp); | ||
| 1312 | } | ||
| 1313 | |||
| 1314 | case VIDIOC_STREAMON: { | ||
| 1315 | v4l_dbg(1, debug, client, "decoder enable output\n"); | ||
| 1316 | decoder->enable = 1; | ||
| 1317 | saa717x_write(client, 0x193, 0xa6); | ||
| 1318 | break; | ||
| 1319 | } | ||
| 1320 | |||
| 1321 | case VIDIOC_STREAMOFF: { | ||
| 1322 | v4l_dbg(1, debug, client, "decoder disable output\n"); | ||
| 1323 | decoder->enable = 0; | ||
| 1324 | saa717x_write(client, 0x193, 0x26); /* right? FIXME!--tadachi */ | ||
| 1325 | break; | ||
| 1326 | } | ||
| 1327 | |||
| 1328 | /* change audio mode */ | ||
| 1329 | case VIDIOC_S_TUNER: { | ||
| 1330 | struct v4l2_tuner *vt = (struct v4l2_tuner *)arg; | ||
| 1331 | int audio_mode; | ||
| 1332 | char *mes[4] = { | ||
| 1333 | "MONO", "STEREO", "LANG1", "LANG2/SAP" | ||
| 1334 | }; | ||
| 1335 | |||
| 1336 | audio_mode = V4L2_TUNER_MODE_STEREO; | ||
| 1337 | |||
| 1338 | switch (vt->audmode) { | ||
| 1339 | case V4L2_TUNER_MODE_MONO: | ||
| 1340 | audio_mode = TUNER_AUDIO_MONO; | ||
| 1341 | break; | ||
| 1342 | case V4L2_TUNER_MODE_STEREO: | ||
| 1343 | audio_mode = TUNER_AUDIO_STEREO; | ||
| 1344 | break; | ||
| 1345 | case V4L2_TUNER_MODE_LANG2: | ||
| 1346 | audio_mode = TUNER_AUDIO_LANG2; | ||
| 1347 | break; | ||
| 1348 | case V4L2_TUNER_MODE_LANG1: | ||
| 1349 | audio_mode = TUNER_AUDIO_LANG1; | ||
| 1350 | break; | ||
| 1351 | } | ||
| 1352 | |||
| 1353 | v4l_dbg(1, debug, client, "change audio mode to %s\n", | ||
| 1354 | mes[audio_mode]); | ||
| 1355 | decoder->tuner_audio_mode = audio_mode; | ||
| 1356 | /* The registers are not changed here. */ | ||
| 1357 | /* See DECODER_ENABLE_OUTPUT section. */ | ||
| 1358 | set_audio_mode(client, decoder->tuner_audio_mode); | ||
| 1359 | break; | ||
| 1360 | } | ||
| 1361 | |||
| 1362 | case VIDIOC_G_TUNER: { | ||
| 1363 | struct v4l2_tuner *vt = (struct v4l2_tuner *)arg; | ||
| 1364 | int dual_f, stereo_f; | ||
| 1365 | |||
| 1366 | if (decoder->radio) | ||
| 1367 | break; | ||
| 1368 | get_inf_dev_status(client, &dual_f, &stereo_f); | ||
| 1369 | |||
| 1370 | v4l_dbg(1, debug, client, "DETECT==st:%d dual:%d\n", | ||
| 1371 | stereo_f, dual_f); | ||
| 1372 | |||
| 1373 | /* mono */ | ||
| 1374 | if ((dual_f == 0) && (stereo_f == 0)) { | ||
| 1375 | vt->rxsubchans = V4L2_TUNER_SUB_MONO; | ||
| 1376 | v4l_dbg(1, debug, client, "DETECT==MONO\n"); | ||
| 1377 | } | ||
| 1378 | |||
| 1379 | /* stereo */ | ||
| 1380 | if (stereo_f == 1) { | ||
| 1381 | if (vt->audmode == V4L2_TUNER_MODE_STEREO || | ||
| 1382 | vt->audmode == V4L2_TUNER_MODE_LANG1) { | ||
| 1383 | vt->rxsubchans = V4L2_TUNER_SUB_STEREO; | ||
| 1384 | v4l_dbg(1, debug, client, "DETECT==ST(ST)\n"); | ||
| 1385 | } else { | ||
| 1386 | vt->rxsubchans = V4L2_TUNER_SUB_MONO; | ||
| 1387 | v4l_dbg(1, debug, client, "DETECT==ST(MONO)\n"); | ||
| 1388 | } | ||
| 1389 | } | ||
| 1390 | |||
| 1391 | /* dual */ | ||
| 1392 | if (dual_f == 1) { | ||
| 1393 | if (vt->audmode == V4L2_TUNER_MODE_LANG2) { | ||
| 1394 | vt->rxsubchans = V4L2_TUNER_SUB_LANG2 | V4L2_TUNER_SUB_MONO; | ||
| 1395 | v4l_dbg(1, debug, client, "DETECT==DUAL1\n"); | ||
| 1396 | } else { | ||
| 1397 | vt->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_MONO; | ||
| 1398 | v4l_dbg(1, debug, client, "DETECT==DUAL2\n"); | ||
| 1399 | } | ||
| 1400 | } | ||
| 1401 | break; | ||
| 1402 | } | ||
| 1403 | |||
| 1404 | case VIDIOC_LOG_STATUS: | ||
| 1405 | /* not yet implemented */ | ||
| 1406 | break; | ||
| 1407 | |||
| 1408 | default: | ||
| 1409 | return -EINVAL; | ||
| 1410 | } | ||
| 1411 | |||
| 1412 | return 0; | ||
| 1413 | } | ||
| 1414 | |||
| 1415 | /* ----------------------------------------------------------------------- */ | ||
| 1416 | |||
| 1417 | |||
| 1418 | /* i2c implementation */ | ||
| 1419 | |||
| 1420 | /* ----------------------------------------------------------------------- */ | ||
| 1421 | static int saa717x_probe(struct i2c_client *client) | ||
| 1422 | { | ||
| 1423 | struct saa717x_state *decoder; | ||
| 1424 | u8 id = 0; | ||
| 1425 | char *p = ""; | ||
| 1426 | |||
| 1427 | /* Check if the adapter supports the needed features */ | ||
| 1428 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
| 1429 | return -EIO; | ||
| 1430 | |||
| 1431 | snprintf(client->name, sizeof(client->name) - 1, "saa717x"); | ||
| 1432 | |||
| 1433 | if (saa717x_write(client, 0x5a4, 0xfe) && | ||
| 1434 | saa717x_write(client, 0x5a5, 0x0f) && | ||
| 1435 | saa717x_write(client, 0x5a6, 0x00) && | ||
| 1436 | saa717x_write(client, 0x5a7, 0x01)) | ||
| 1437 | id = saa717x_read(client, 0x5a0); | ||
| 1438 | if (id != 0xc2 && id != 0x32 && id != 0xf2 && id != 0x6c) { | ||
| 1439 | v4l_dbg(1, debug, client, "saa717x not found (id=%02x)\n", id); | ||
| 1440 | return -ENODEV; | ||
| 1441 | } | ||
| 1442 | if (id == 0xc2) | ||
| 1443 | p = "saa7173"; | ||
| 1444 | else if (id == 0x32) | ||
| 1445 | p = "saa7174A"; | ||
| 1446 | else if (id == 0x6c) | ||
| 1447 | p = "saa7174HL"; | ||
| 1448 | else | ||
| 1449 | p = "saa7171"; | ||
| 1450 | v4l_info(client, "%s found @ 0x%x (%s)\n", p, | ||
| 1451 | client->addr << 1, client->adapter->name); | ||
| 1452 | |||
| 1453 | decoder = kzalloc(sizeof(struct saa717x_state), GFP_KERNEL); | ||
| 1454 | i2c_set_clientdata(client, decoder); | ||
| 1455 | |||
| 1456 | if (decoder == NULL) | ||
| 1457 | return -ENOMEM; | ||
| 1458 | decoder->std = V4L2_STD_NTSC; | ||
| 1459 | decoder->input = -1; | ||
| 1460 | decoder->enable = 1; | ||
| 1461 | |||
| 1462 | /* tune these parameters */ | ||
| 1463 | decoder->bright = 0x80; | ||
| 1464 | decoder->contrast = 0x44; | ||
| 1465 | decoder->sat = 0x40; | ||
| 1466 | decoder->hue = 0x00; | ||
| 1467 | |||
| 1468 | /* FIXME!! */ | ||
| 1469 | decoder->playback = 0; /* initially capture mode used */ | ||
| 1470 | decoder->audio = 1; /* DECODER_AUDIO_48_KHZ */ | ||
| 1471 | |||
| 1472 | decoder->audio_input = 2; /* FIXME!! */ | ||
| 1473 | |||
| 1474 | decoder->tuner_audio_mode = TUNER_AUDIO_STEREO; | ||
| 1475 | /* set volume, bass and treble */ | ||
| 1476 | decoder->audio_main_vol_l = 6; | ||
| 1477 | decoder->audio_main_vol_r = 6; | ||
| 1478 | decoder->audio_main_bass = 0; | ||
| 1479 | decoder->audio_main_treble = 0; | ||
| 1480 | decoder->audio_main_mute = 0; | ||
| 1481 | decoder->audio_main_balance = 32768; | ||
| 1482 | /* normalize (24 to -40 (not -84) -> 65535 to 0) */ | ||
| 1483 | decoder->audio_main_volume = | ||
| 1484 | (decoder->audio_main_vol_r + 41) * 65535 / (24 - (-40)); | ||
| 1485 | |||
| 1486 | v4l_dbg(1, debug, client, "writing init values\n"); | ||
| 1487 | |||
| 1488 | /* FIXME!! */ | ||
| 1489 | saa717x_write_regs(client, reg_init_initialize); | ||
| 1490 | set_video_output_level_regs(client, decoder); | ||
| 1491 | /* set bass,treble to 0db 20041101 K.Ohta */ | ||
| 1492 | decoder->audio_main_bass = 0; | ||
| 1493 | decoder->audio_main_treble = 0; | ||
| 1494 | set_audio_regs(client, decoder); | ||
| 1495 | |||
| 1496 | set_current_state(TASK_INTERRUPTIBLE); | ||
| 1497 | schedule_timeout(2*HZ); | ||
| 1498 | return 0; | ||
| 1499 | } | ||
| 1500 | |||
| 1501 | static int saa717x_remove(struct i2c_client *client) | ||
| 1502 | { | ||
| 1503 | kfree(i2c_get_clientdata(client)); | ||
| 1504 | return 0; | ||
| 1505 | } | ||
| 1506 | |||
| 1507 | /* ----------------------------------------------------------------------- */ | ||
| 1508 | |||
| 1509 | static struct v4l2_i2c_driver_data v4l2_i2c_data = { | ||
| 1510 | .name = "saa717x", | ||
| 1511 | .driverid = I2C_DRIVERID_SAA717X, | ||
| 1512 | .command = saa717x_command, | ||
| 1513 | .probe = saa717x_probe, | ||
| 1514 | .remove = saa717x_remove, | ||
| 1515 | .legacy_class = I2C_CLASS_TV_ANALOG | I2C_CLASS_TV_DIGITAL, | ||
| 1516 | }; | ||
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c index 41f70440fd3b..02fda4eecea3 100644 --- a/drivers/media/video/saa7185.c +++ b/drivers/media/video/saa7185.c | |||
| @@ -52,7 +52,7 @@ MODULE_LICENSE("GPL"); | |||
| 52 | #define I2C_NAME(s) (s)->name | 52 | #define I2C_NAME(s) (s)->name |
| 53 | 53 | ||
| 54 | 54 | ||
| 55 | static int debug = 0; | 55 | static int debug; |
| 56 | module_param(debug, int, 0); | 56 | module_param(debug, int, 0); |
| 57 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 57 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 58 | 58 | ||
diff --git a/drivers/media/video/se401.c b/drivers/media/video/se401.c index d5d7d6cf734a..1cd629380f71 100644 --- a/drivers/media/video/se401.c +++ b/drivers/media/video/se401.c | |||
| @@ -35,7 +35,7 @@ static const char version[] = "0.24"; | |||
| 35 | #include <linux/usb.h> | 35 | #include <linux/usb.h> |
| 36 | #include "se401.h" | 36 | #include "se401.h" |
| 37 | 37 | ||
| 38 | static int flickerless=0; | 38 | static int flickerless; |
| 39 | static int video_nr = -1; | 39 | static int video_nr = -1; |
| 40 | 40 | ||
| 41 | static struct usb_device_id device_table [] = { | 41 | static struct usb_device_id device_table [] = { |
| @@ -300,10 +300,10 @@ static void se401_button_irq(struct urb *urb) | |||
| 300 | case -ENOENT: | 300 | case -ENOENT: |
| 301 | case -ESHUTDOWN: | 301 | case -ESHUTDOWN: |
| 302 | /* this urb is terminated, clean up */ | 302 | /* this urb is terminated, clean up */ |
| 303 | dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); | 303 | dbg("%s - urb shutting down with status: %d", __func__, urb->status); |
| 304 | return; | 304 | return; |
| 305 | default: | 305 | default: |
| 306 | dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); | 306 | dbg("%s - nonzero urb status received: %d", __func__, urb->status); |
| 307 | goto exit; | 307 | goto exit; |
| 308 | } | 308 | } |
| 309 | 309 | ||
| @@ -315,7 +315,7 @@ exit: | |||
| 315 | status = usb_submit_urb (urb, GFP_ATOMIC); | 315 | status = usb_submit_urb (urb, GFP_ATOMIC); |
| 316 | if (status) | 316 | if (status) |
| 317 | err ("%s - usb_submit_urb failed with result %d", | 317 | err ("%s - usb_submit_urb failed with result %d", |
| 318 | __FUNCTION__, status); | 318 | __func__, status); |
| 319 | } | 319 | } |
| 320 | 320 | ||
| 321 | static void se401_video_irq(struct urb *urb) | 321 | static void se401_video_irq(struct urb *urb) |
| @@ -1224,7 +1224,9 @@ static const struct file_operations se401_fops = { | |||
| 1224 | .read = se401_read, | 1224 | .read = se401_read, |
| 1225 | .mmap = se401_mmap, | 1225 | .mmap = se401_mmap, |
| 1226 | .ioctl = se401_ioctl, | 1226 | .ioctl = se401_ioctl, |
| 1227 | #ifdef CONFIG_COMPAT | ||
| 1227 | .compat_ioctl = v4l_compat_ioctl32, | 1228 | .compat_ioctl = v4l_compat_ioctl32, |
| 1229 | #endif | ||
| 1228 | .llseek = no_llseek, | 1230 | .llseek = no_llseek, |
| 1229 | }; | 1231 | }; |
| 1230 | static struct video_device se401_template = { | 1232 | static struct video_device se401_template = { |
| @@ -1279,7 +1281,7 @@ static int se401_init(struct usb_se401 *se401, int button) | |||
| 1279 | rc=se401_sndctrl(0, se401, SE401_REQ_GET_HEIGHT, 0, cp, sizeof(cp)); | 1281 | rc=se401_sndctrl(0, se401, SE401_REQ_GET_HEIGHT, 0, cp, sizeof(cp)); |
| 1280 | se401->cheight=cp[0]+cp[1]*256; | 1282 | se401->cheight=cp[0]+cp[1]*256; |
| 1281 | 1283 | ||
| 1282 | if (!cp[2] && SE401_FORMAT_BAYER) { | 1284 | if (!(cp[2] & SE401_FORMAT_BAYER)) { |
| 1283 | err("Bayer format not supported!"); | 1285 | err("Bayer format not supported!"); |
| 1284 | return 1; | 1286 | return 1; |
| 1285 | } | 1287 | } |
diff --git a/drivers/media/video/sn9c102/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h index 2e3c3de793a7..0c8d87d8d18d 100644 --- a/drivers/media/video/sn9c102/sn9c102.h +++ b/drivers/media/video/sn9c102/sn9c102.h | |||
| @@ -176,7 +176,7 @@ do { \ | |||
| 176 | dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ | 176 | dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ |
| 177 | else if ((level) >= 3) \ | 177 | else if ((level) >= 3) \ |
| 178 | dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ | 178 | dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \ |
| 179 | __FUNCTION__, __LINE__ , ## args); \ | 179 | __func__, __LINE__ , ## args); \ |
| 180 | } \ | 180 | } \ |
| 181 | } while (0) | 181 | } while (0) |
| 182 | # define V4LDBG(level, name, cmd) \ | 182 | # define V4LDBG(level, name, cmd) \ |
| @@ -191,7 +191,7 @@ do { \ | |||
| 191 | pr_info("sn9c102: " fmt "\n", ## args); \ | 191 | pr_info("sn9c102: " fmt "\n", ## args); \ |
| 192 | else if ((level) == 3) \ | 192 | else if ((level) == 3) \ |
| 193 | pr_debug("sn9c102: [%s:%d] " fmt "\n", \ | 193 | pr_debug("sn9c102: [%s:%d] " fmt "\n", \ |
| 194 | __FUNCTION__, __LINE__ , ## args); \ | 194 | __func__, __LINE__ , ## args); \ |
| 195 | } \ | 195 | } \ |
| 196 | } while (0) | 196 | } while (0) |
| 197 | #else | 197 | #else |
| @@ -202,7 +202,7 @@ do { \ | |||
| 202 | 202 | ||
| 203 | #undef PDBG | 203 | #undef PDBG |
| 204 | #define PDBG(fmt, args...) \ | 204 | #define PDBG(fmt, args...) \ |
| 205 | dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", __FILE__, __FUNCTION__, \ | 205 | dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", __FILE__, __func__, \ |
| 206 | __LINE__ , ## args) | 206 | __LINE__ , ## args) |
| 207 | 207 | ||
| 208 | #undef PDBGG | 208 | #undef PDBGG |
diff --git a/drivers/media/video/sn9c102/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c index c40ba3adab21..5748b1e1a128 100644 --- a/drivers/media/video/sn9c102/sn9c102_core.c +++ b/drivers/media/video/sn9c102/sn9c102_core.c | |||
| @@ -464,9 +464,9 @@ sn9c102_i2c_try_read(struct sn9c102_device* cam, | |||
| 464 | } | 464 | } |
| 465 | 465 | ||
| 466 | 466 | ||
| 467 | int | 467 | static int sn9c102_i2c_try_write(struct sn9c102_device* cam, |
| 468 | sn9c102_i2c_try_write(struct sn9c102_device* cam, | 468 | const struct sn9c102_sensor* sensor, |
| 469 | const struct sn9c102_sensor* sensor, u8 address, u8 value) | 469 | u8 address, u8 value) |
| 470 | { | 470 | { |
| 471 | return sn9c102_i2c_try_raw_write(cam, sensor, 3, | 471 | return sn9c102_i2c_try_raw_write(cam, sensor, 3, |
| 472 | sensor->i2c_slave_id, address, | 472 | sensor->i2c_slave_id, address, |
| @@ -528,7 +528,7 @@ sn9c102_find_sof_header(struct sn9c102_device* cam, void* mem, size_t len) | |||
| 528 | 528 | ||
| 529 | /* Search for the SOF marker (fixed part) in the header */ | 529 | /* Search for the SOF marker (fixed part) in the header */ |
| 530 | for (j = 0, b=cam->sof.bytesread; j+b < sizeof(marker); j++) { | 530 | for (j = 0, b=cam->sof.bytesread; j+b < sizeof(marker); j++) { |
| 531 | if (unlikely(i+j) == len) | 531 | if (unlikely(i+j == len)) |
| 532 | return NULL; | 532 | return NULL; |
| 533 | if (*(m+i+j) == marker[cam->sof.bytesread]) { | 533 | if (*(m+i+j) == marker[cam->sof.bytesread]) { |
| 534 | cam->sof.header[cam->sof.bytesread] = *(m+i+j); | 534 | cam->sof.header[cam->sof.bytesread] = *(m+i+j); |
| @@ -3224,7 +3224,9 @@ static const struct file_operations sn9c102_fops = { | |||
| 3224 | .open = sn9c102_open, | 3224 | .open = sn9c102_open, |
| 3225 | .release = sn9c102_release, | 3225 | .release = sn9c102_release, |
| 3226 | .ioctl = sn9c102_ioctl, | 3226 | .ioctl = sn9c102_ioctl, |
| 3227 | #ifdef CONFIG_COMPAT | ||
| 3227 | .compat_ioctl = v4l_compat_ioctl32, | 3228 | .compat_ioctl = v4l_compat_ioctl32, |
| 3229 | #endif | ||
| 3228 | .read = sn9c102_read, | 3230 | .read = sn9c102_read, |
| 3229 | .poll = sn9c102_poll, | 3231 | .poll = sn9c102_poll, |
| 3230 | .mmap = sn9c102_mmap, | 3232 | .mmap = sn9c102_mmap, |
| @@ -3239,7 +3241,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
| 3239 | { | 3241 | { |
| 3240 | struct usb_device *udev = interface_to_usbdev(intf); | 3242 | struct usb_device *udev = interface_to_usbdev(intf); |
| 3241 | struct sn9c102_device* cam; | 3243 | struct sn9c102_device* cam; |
| 3242 | static unsigned int dev_nr = 0; | 3244 | static unsigned int dev_nr; |
| 3243 | unsigned int i; | 3245 | unsigned int i; |
| 3244 | int err = 0, r; | 3246 | int err = 0, r; |
| 3245 | 3247 | ||
diff --git a/drivers/media/video/sn9c102/sn9c102_sensor.h b/drivers/media/video/sn9c102/sn9c102_sensor.h index 2dc7c6869484..4af7382da5c5 100644 --- a/drivers/media/video/sn9c102/sn9c102_sensor.h +++ b/drivers/media/video/sn9c102/sn9c102_sensor.h | |||
| @@ -85,9 +85,6 @@ sn9c102_attach_sensor(struct sn9c102_device* cam, | |||
| 85 | */ | 85 | */ |
| 86 | 86 | ||
| 87 | /* The "try" I2C I/O versions are used when probing the sensor */ | 87 | /* The "try" I2C I/O versions are used when probing the sensor */ |
| 88 | extern int sn9c102_i2c_try_write(struct sn9c102_device*, | ||
| 89 | const struct sn9c102_sensor*, u8 address, | ||
| 90 | u8 value); | ||
| 91 | extern int sn9c102_i2c_try_read(struct sn9c102_device*, | 88 | extern int sn9c102_i2c_try_read(struct sn9c102_device*, |
| 92 | const struct sn9c102_sensor*, u8 address); | 89 | const struct sn9c102_sensor*, u8 address); |
| 93 | 90 | ||
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c new file mode 100644 index 000000000000..a1b92446c8b4 --- /dev/null +++ b/drivers/media/video/soc_camera.c | |||
| @@ -0,0 +1,1031 @@ | |||
| 1 | /* | ||
| 2 | * camera image capture (abstract) bus driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de> | ||
| 5 | * | ||
| 6 | * This driver provides an interface between platform-specific camera | ||
| 7 | * busses and camera devices. It should be used if the camera is | ||
| 8 | * connected not over a "proper" bus like PCI or USB, but over a | ||
| 9 | * special bus, like, for example, the Quick Capture interface on PXA270 | ||
| 10 | * SoCs. Later it should also be used for i.MX31 SoCs from Freescale. | ||
| 11 | * It can handle multiple cameras and / or multiple busses, which can | ||
| 12 | * be used, e.g., in stereo-vision applications. | ||
| 13 | * | ||
| 14 | * This program is free software; you can redistribute it and/or modify | ||
| 15 | * it under the terms of the GNU General Public License version 2 as | ||
| 16 | * published by the Free Software Foundation. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <linux/module.h> | ||
| 20 | #include <linux/init.h> | ||
| 21 | #include <linux/device.h> | ||
| 22 | #include <linux/list.h> | ||
| 23 | #include <linux/err.h> | ||
| 24 | #include <linux/mutex.h> | ||
| 25 | #include <linux/vmalloc.h> | ||
| 26 | |||
| 27 | #include <media/v4l2-common.h> | ||
| 28 | #include <media/v4l2-dev.h> | ||
| 29 | #include <media/soc_camera.h> | ||
| 30 | |||
| 31 | static LIST_HEAD(hosts); | ||
| 32 | static LIST_HEAD(devices); | ||
| 33 | static DEFINE_MUTEX(list_lock); | ||
| 34 | static DEFINE_MUTEX(video_lock); | ||
| 35 | |||
| 36 | const static struct soc_camera_data_format* | ||
| 37 | format_by_fourcc(struct soc_camera_device *icd, unsigned int fourcc) | ||
| 38 | { | ||
| 39 | unsigned int i; | ||
| 40 | |||
| 41 | for (i = 0; i < icd->num_formats; i++) | ||
| 42 | if (icd->formats[i].fourcc == fourcc) | ||
| 43 | return icd->formats + i; | ||
| 44 | return NULL; | ||
| 45 | } | ||
| 46 | |||
| 47 | static int soc_camera_try_fmt_cap(struct file *file, void *priv, | ||
| 48 | struct v4l2_format *f) | ||
| 49 | { | ||
| 50 | struct soc_camera_file *icf = file->private_data; | ||
| 51 | struct soc_camera_device *icd = icf->icd; | ||
| 52 | struct soc_camera_host *ici = | ||
| 53 | to_soc_camera_host(icd->dev.parent); | ||
| 54 | enum v4l2_field field; | ||
| 55 | const struct soc_camera_data_format *fmt; | ||
| 56 | int ret; | ||
| 57 | |||
| 58 | WARN_ON(priv != file->private_data); | ||
| 59 | |||
| 60 | fmt = format_by_fourcc(icd, f->fmt.pix.pixelformat); | ||
| 61 | if (!fmt) { | ||
| 62 | dev_dbg(&icd->dev, "invalid format 0x%08x\n", | ||
| 63 | f->fmt.pix.pixelformat); | ||
| 64 | return -EINVAL; | ||
| 65 | } | ||
| 66 | |||
| 67 | dev_dbg(&icd->dev, "fmt: 0x%08x\n", fmt->fourcc); | ||
| 68 | |||
| 69 | field = f->fmt.pix.field; | ||
| 70 | |||
| 71 | if (field == V4L2_FIELD_ANY) { | ||
| 72 | field = V4L2_FIELD_NONE; | ||
| 73 | } else if (V4L2_FIELD_NONE != field) { | ||
| 74 | dev_err(&icd->dev, "Field type invalid.\n"); | ||
| 75 | return -EINVAL; | ||
| 76 | } | ||
| 77 | |||
| 78 | /* test physical bus parameters */ | ||
| 79 | ret = ici->ops->try_bus_param(icd, f->fmt.pix.pixelformat); | ||
| 80 | if (ret) | ||
| 81 | return ret; | ||
| 82 | |||
| 83 | /* limit format to hardware capabilities */ | ||
| 84 | ret = ici->ops->try_fmt_cap(icd, f); | ||
| 85 | |||
| 86 | /* calculate missing fields */ | ||
| 87 | f->fmt.pix.field = field; | ||
| 88 | f->fmt.pix.bytesperline = | ||
| 89 | (f->fmt.pix.width * fmt->depth) >> 3; | ||
| 90 | f->fmt.pix.sizeimage = | ||
| 91 | f->fmt.pix.height * f->fmt.pix.bytesperline; | ||
| 92 | |||
| 93 | return ret; | ||
| 94 | } | ||
| 95 | |||
| 96 | static int soc_camera_enum_input(struct file *file, void *priv, | ||
| 97 | struct v4l2_input *inp) | ||
| 98 | { | ||
| 99 | if (inp->index != 0) | ||
| 100 | return -EINVAL; | ||
| 101 | |||
| 102 | inp->type = V4L2_INPUT_TYPE_CAMERA; | ||
| 103 | inp->std = V4L2_STD_UNKNOWN; | ||
| 104 | strcpy(inp->name, "Camera"); | ||
| 105 | |||
| 106 | return 0; | ||
| 107 | } | ||
| 108 | |||
| 109 | static int soc_camera_g_input(struct file *file, void *priv, unsigned int *i) | ||
| 110 | { | ||
| 111 | *i = 0; | ||
| 112 | |||
| 113 | return 0; | ||
| 114 | } | ||
| 115 | |||
| 116 | static int soc_camera_s_input(struct file *file, void *priv, unsigned int i) | ||
| 117 | { | ||
| 118 | if (i > 0) | ||
| 119 | return -EINVAL; | ||
| 120 | |||
| 121 | return 0; | ||
| 122 | } | ||
| 123 | |||
| 124 | static int soc_camera_s_std(struct file *file, void *priv, v4l2_std_id *a) | ||
| 125 | { | ||
| 126 | return 0; | ||
| 127 | } | ||
| 128 | |||
| 129 | static int soc_camera_reqbufs(struct file *file, void *priv, | ||
| 130 | struct v4l2_requestbuffers *p) | ||
| 131 | { | ||
| 132 | int ret; | ||
| 133 | struct soc_camera_file *icf = file->private_data; | ||
| 134 | struct soc_camera_device *icd = icf->icd; | ||
| 135 | struct soc_camera_host *ici = | ||
| 136 | to_soc_camera_host(icd->dev.parent); | ||
| 137 | |||
| 138 | WARN_ON(priv != file->private_data); | ||
| 139 | |||
| 140 | dev_dbg(&icd->dev, "%s: %d\n", __func__, p->memory); | ||
| 141 | |||
| 142 | ret = videobuf_reqbufs(&icf->vb_vidq, p); | ||
| 143 | if (ret < 0) | ||
| 144 | return ret; | ||
| 145 | |||
| 146 | return ici->ops->reqbufs(icf, p); | ||
| 147 | } | ||
| 148 | |||
| 149 | static int soc_camera_querybuf(struct file *file, void *priv, | ||
| 150 | struct v4l2_buffer *p) | ||
| 151 | { | ||
| 152 | struct soc_camera_file *icf = file->private_data; | ||
| 153 | |||
| 154 | WARN_ON(priv != file->private_data); | ||
| 155 | |||
| 156 | return videobuf_querybuf(&icf->vb_vidq, p); | ||
| 157 | } | ||
| 158 | |||
| 159 | static int soc_camera_qbuf(struct file *file, void *priv, | ||
| 160 | struct v4l2_buffer *p) | ||
| 161 | { | ||
| 162 | struct soc_camera_file *icf = file->private_data; | ||
| 163 | |||
| 164 | WARN_ON(priv != file->private_data); | ||
| 165 | |||
| 166 | return videobuf_qbuf(&icf->vb_vidq, p); | ||
| 167 | } | ||
| 168 | |||
| 169 | static int soc_camera_dqbuf(struct file *file, void *priv, | ||
| 170 | struct v4l2_buffer *p) | ||
| 171 | { | ||
| 172 | struct soc_camera_file *icf = file->private_data; | ||
| 173 | |||
| 174 | WARN_ON(priv != file->private_data); | ||
| 175 | |||
| 176 | return videobuf_dqbuf(&icf->vb_vidq, p, file->f_flags & O_NONBLOCK); | ||
| 177 | } | ||
| 178 | |||
| 179 | static int soc_camera_open(struct inode *inode, struct file *file) | ||
| 180 | { | ||
| 181 | struct video_device *vdev; | ||
| 182 | struct soc_camera_device *icd; | ||
| 183 | struct soc_camera_host *ici; | ||
| 184 | struct soc_camera_file *icf; | ||
| 185 | spinlock_t *lock; | ||
| 186 | int ret; | ||
| 187 | |||
| 188 | icf = vmalloc(sizeof(*icf)); | ||
| 189 | if (!icf) | ||
| 190 | return -ENOMEM; | ||
| 191 | |||
| 192 | /* Protect against icd->remove() until we module_get() both drivers. */ | ||
| 193 | mutex_lock(&video_lock); | ||
| 194 | |||
| 195 | vdev = video_devdata(file); | ||
| 196 | icd = container_of(vdev->dev, struct soc_camera_device, dev); | ||
| 197 | ici = to_soc_camera_host(icd->dev.parent); | ||
| 198 | |||
| 199 | if (!try_module_get(icd->ops->owner)) { | ||
| 200 | dev_err(&icd->dev, "Couldn't lock sensor driver.\n"); | ||
| 201 | ret = -EINVAL; | ||
| 202 | goto emgd; | ||
| 203 | } | ||
| 204 | |||
| 205 | if (!try_module_get(ici->ops->owner)) { | ||
| 206 | dev_err(&icd->dev, "Couldn't lock capture bus driver.\n"); | ||
| 207 | ret = -EINVAL; | ||
| 208 | goto emgi; | ||
| 209 | } | ||
| 210 | |||
| 211 | icf->icd = icd; | ||
| 212 | |||
| 213 | icf->lock = ici->ops->spinlock_alloc(icf); | ||
| 214 | if (!icf->lock) { | ||
| 215 | ret = -ENOMEM; | ||
| 216 | goto esla; | ||
| 217 | } | ||
| 218 | |||
| 219 | icd->use_count++; | ||
| 220 | |||
| 221 | /* Now we really have to activate the camera */ | ||
| 222 | if (icd->use_count == 1) { | ||
| 223 | ret = ici->ops->add(icd); | ||
| 224 | if (ret < 0) { | ||
| 225 | dev_err(&icd->dev, "Couldn't activate the camera: %d\n", ret); | ||
| 226 | icd->use_count--; | ||
| 227 | goto eiciadd; | ||
| 228 | } | ||
| 229 | } | ||
| 230 | |||
| 231 | mutex_unlock(&video_lock); | ||
| 232 | |||
| 233 | file->private_data = icf; | ||
| 234 | dev_dbg(&icd->dev, "camera device open\n"); | ||
| 235 | |||
| 236 | /* We must pass NULL as dev pointer, then all pci_* dma operations | ||
| 237 | * transform to normal dma_* ones. */ | ||
| 238 | videobuf_queue_sg_init(&icf->vb_vidq, ici->vbq_ops, NULL, icf->lock, | ||
| 239 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, | ||
| 240 | ici->msize, icd); | ||
| 241 | |||
| 242 | return 0; | ||
| 243 | |||
| 244 | /* All errors are entered with the video_lock held */ | ||
| 245 | eiciadd: | ||
| 246 | lock = icf->lock; | ||
| 247 | icf->lock = NULL; | ||
| 248 | if (ici->ops->spinlock_free) | ||
| 249 | ici->ops->spinlock_free(lock); | ||
| 250 | esla: | ||
| 251 | module_put(ici->ops->owner); | ||
| 252 | emgi: | ||
| 253 | module_put(icd->ops->owner); | ||
| 254 | emgd: | ||
| 255 | mutex_unlock(&video_lock); | ||
| 256 | vfree(icf); | ||
| 257 | return ret; | ||
| 258 | } | ||
| 259 | |||
| 260 | static int soc_camera_close(struct inode *inode, struct file *file) | ||
| 261 | { | ||
| 262 | struct soc_camera_file *icf = file->private_data; | ||
| 263 | struct soc_camera_device *icd = icf->icd; | ||
| 264 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
| 265 | struct video_device *vdev = icd->vdev; | ||
| 266 | spinlock_t *lock = icf->lock; | ||
| 267 | |||
| 268 | mutex_lock(&video_lock); | ||
| 269 | icd->use_count--; | ||
| 270 | if (!icd->use_count) | ||
| 271 | ici->ops->remove(icd); | ||
| 272 | icf->lock = NULL; | ||
| 273 | if (ici->ops->spinlock_free) | ||
| 274 | ici->ops->spinlock_free(lock); | ||
| 275 | module_put(icd->ops->owner); | ||
| 276 | module_put(ici->ops->owner); | ||
| 277 | mutex_unlock(&video_lock); | ||
| 278 | |||
| 279 | vfree(icf); | ||
| 280 | |||
| 281 | dev_dbg(vdev->dev, "camera device close\n"); | ||
| 282 | |||
| 283 | return 0; | ||
| 284 | } | ||
| 285 | |||
| 286 | static ssize_t soc_camera_read(struct file *file, char __user *buf, | ||
| 287 | size_t count, loff_t *ppos) | ||
| 288 | { | ||
| 289 | struct soc_camera_file *icf = file->private_data; | ||
| 290 | struct soc_camera_device *icd = icf->icd; | ||
| 291 | struct video_device *vdev = icd->vdev; | ||
| 292 | int err = -EINVAL; | ||
| 293 | |||
| 294 | dev_err(vdev->dev, "camera device read not implemented\n"); | ||
| 295 | |||
| 296 | return err; | ||
| 297 | } | ||
| 298 | |||
| 299 | static int soc_camera_mmap(struct file *file, struct vm_area_struct *vma) | ||
| 300 | { | ||
| 301 | struct soc_camera_file *icf = file->private_data; | ||
| 302 | struct soc_camera_device *icd = icf->icd; | ||
| 303 | int err; | ||
| 304 | |||
| 305 | dev_dbg(&icd->dev, "mmap called, vma=0x%08lx\n", (unsigned long)vma); | ||
| 306 | |||
| 307 | err = videobuf_mmap_mapper(&icf->vb_vidq, vma); | ||
| 308 | |||
| 309 | dev_dbg(&icd->dev, "vma start=0x%08lx, size=%ld, ret=%d\n", | ||
| 310 | (unsigned long)vma->vm_start, | ||
| 311 | (unsigned long)vma->vm_end - (unsigned long)vma->vm_start, | ||
| 312 | err); | ||
| 313 | |||
| 314 | return err; | ||
| 315 | } | ||
| 316 | |||
| 317 | static unsigned int soc_camera_poll(struct file *file, poll_table *pt) | ||
| 318 | { | ||
| 319 | struct soc_camera_file *icf = file->private_data; | ||
| 320 | struct soc_camera_device *icd = icf->icd; | ||
| 321 | struct soc_camera_host *ici = | ||
| 322 | to_soc_camera_host(icd->dev.parent); | ||
| 323 | |||
| 324 | if (list_empty(&icf->vb_vidq.stream)) { | ||
| 325 | dev_err(&icd->dev, "Trying to poll with no queued buffers!\n"); | ||
| 326 | return POLLERR; | ||
| 327 | } | ||
| 328 | |||
| 329 | return ici->ops->poll(file, pt); | ||
| 330 | } | ||
| 331 | |||
| 332 | |||
| 333 | static struct file_operations soc_camera_fops = { | ||
| 334 | .owner = THIS_MODULE, | ||
| 335 | .open = soc_camera_open, | ||
| 336 | .release = soc_camera_close, | ||
| 337 | .ioctl = video_ioctl2, | ||
| 338 | .read = soc_camera_read, | ||
| 339 | .mmap = soc_camera_mmap, | ||
| 340 | .poll = soc_camera_poll, | ||
| 341 | .llseek = no_llseek, | ||
| 342 | }; | ||
| 343 | |||
| 344 | |||
| 345 | static int soc_camera_s_fmt_cap(struct file *file, void *priv, | ||
| 346 | struct v4l2_format *f) | ||
| 347 | { | ||
| 348 | struct soc_camera_file *icf = file->private_data; | ||
| 349 | struct soc_camera_device *icd = icf->icd; | ||
| 350 | struct soc_camera_host *ici = | ||
| 351 | to_soc_camera_host(icd->dev.parent); | ||
| 352 | int ret; | ||
| 353 | struct v4l2_rect rect; | ||
| 354 | const static struct soc_camera_data_format *data_fmt; | ||
| 355 | |||
| 356 | WARN_ON(priv != file->private_data); | ||
| 357 | |||
| 358 | data_fmt = format_by_fourcc(icd, f->fmt.pix.pixelformat); | ||
| 359 | if (!data_fmt) | ||
| 360 | return -EINVAL; | ||
| 361 | |||
| 362 | /* buswidth may be further adjusted by the ici */ | ||
| 363 | icd->buswidth = data_fmt->depth; | ||
| 364 | |||
| 365 | ret = soc_camera_try_fmt_cap(file, icf, f); | ||
| 366 | if (ret < 0) | ||
| 367 | return ret; | ||
| 368 | |||
| 369 | rect.left = icd->x_current; | ||
| 370 | rect.top = icd->y_current; | ||
| 371 | rect.width = f->fmt.pix.width; | ||
| 372 | rect.height = f->fmt.pix.height; | ||
| 373 | ret = ici->ops->set_fmt_cap(icd, f->fmt.pix.pixelformat, &rect); | ||
| 374 | if (ret < 0) | ||
| 375 | return ret; | ||
| 376 | |||
| 377 | icd->current_fmt = data_fmt; | ||
| 378 | icd->width = rect.width; | ||
| 379 | icd->height = rect.height; | ||
| 380 | icf->vb_vidq.field = f->fmt.pix.field; | ||
| 381 | if (V4L2_BUF_TYPE_VIDEO_CAPTURE != f->type) | ||
| 382 | dev_warn(&icd->dev, "Attention! Wrong buf-type %d\n", | ||
| 383 | f->type); | ||
| 384 | |||
| 385 | dev_dbg(&icd->dev, "set width: %d height: %d\n", | ||
| 386 | icd->width, icd->height); | ||
| 387 | |||
| 388 | /* set physical bus parameters */ | ||
| 389 | return ici->ops->set_bus_param(icd, f->fmt.pix.pixelformat); | ||
| 390 | } | ||
| 391 | |||
| 392 | static int soc_camera_enum_fmt_cap(struct file *file, void *priv, | ||
| 393 | struct v4l2_fmtdesc *f) | ||
| 394 | { | ||
| 395 | struct soc_camera_file *icf = file->private_data; | ||
| 396 | struct soc_camera_device *icd = icf->icd; | ||
| 397 | const struct soc_camera_data_format *format; | ||
| 398 | |||
| 399 | WARN_ON(priv != file->private_data); | ||
| 400 | |||
| 401 | if (f->index >= icd->num_formats) | ||
| 402 | return -EINVAL; | ||
| 403 | |||
| 404 | format = &icd->formats[f->index]; | ||
| 405 | |||
| 406 | strlcpy(f->description, format->name, sizeof(f->description)); | ||
| 407 | f->pixelformat = format->fourcc; | ||
| 408 | return 0; | ||
| 409 | } | ||
| 410 | |||
| 411 | static int soc_camera_g_fmt_cap(struct file *file, void *priv, | ||
| 412 | struct v4l2_format *f) | ||
| 413 | { | ||
| 414 | struct soc_camera_file *icf = file->private_data; | ||
| 415 | struct soc_camera_device *icd = icf->icd; | ||
| 416 | |||
| 417 | WARN_ON(priv != file->private_data); | ||
| 418 | |||
| 419 | f->fmt.pix.width = icd->width; | ||
| 420 | f->fmt.pix.height = icd->height; | ||
| 421 | f->fmt.pix.field = icf->vb_vidq.field; | ||
| 422 | f->fmt.pix.pixelformat = icd->current_fmt->fourcc; | ||
| 423 | f->fmt.pix.bytesperline = | ||
| 424 | (f->fmt.pix.width * icd->current_fmt->depth) >> 3; | ||
| 425 | f->fmt.pix.sizeimage = | ||
| 426 | f->fmt.pix.height * f->fmt.pix.bytesperline; | ||
| 427 | dev_dbg(&icd->dev, "current_fmt->fourcc: 0x%08x\n", | ||
| 428 | icd->current_fmt->fourcc); | ||
| 429 | return 0; | ||
| 430 | } | ||
| 431 | |||
| 432 | static int soc_camera_querycap(struct file *file, void *priv, | ||
| 433 | struct v4l2_capability *cap) | ||
| 434 | { | ||
| 435 | struct soc_camera_file *icf = file->private_data; | ||
| 436 | struct soc_camera_device *icd = icf->icd; | ||
| 437 | struct soc_camera_host *ici = | ||
| 438 | to_soc_camera_host(icd->dev.parent); | ||
| 439 | |||
| 440 | WARN_ON(priv != file->private_data); | ||
| 441 | |||
| 442 | strlcpy(cap->driver, ici->drv_name, sizeof(cap->driver)); | ||
| 443 | return ici->ops->querycap(ici, cap); | ||
| 444 | } | ||
| 445 | |||
| 446 | static int soc_camera_streamon(struct file *file, void *priv, | ||
| 447 | enum v4l2_buf_type i) | ||
| 448 | { | ||
| 449 | struct soc_camera_file *icf = file->private_data; | ||
| 450 | struct soc_camera_device *icd = icf->icd; | ||
| 451 | |||
| 452 | WARN_ON(priv != file->private_data); | ||
| 453 | |||
| 454 | dev_dbg(&icd->dev, "%s\n", __func__); | ||
| 455 | |||
| 456 | if (i != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 457 | return -EINVAL; | ||
| 458 | |||
| 459 | icd->ops->start_capture(icd); | ||
| 460 | |||
| 461 | /* This calls buf_queue from host driver's videobuf_queue_ops */ | ||
| 462 | return videobuf_streamon(&icf->vb_vidq); | ||
| 463 | } | ||
| 464 | |||
| 465 | static int soc_camera_streamoff(struct file *file, void *priv, | ||
| 466 | enum v4l2_buf_type i) | ||
| 467 | { | ||
| 468 | struct soc_camera_file *icf = file->private_data; | ||
| 469 | struct soc_camera_device *icd = icf->icd; | ||
| 470 | |||
| 471 | WARN_ON(priv != file->private_data); | ||
| 472 | |||
| 473 | dev_dbg(&icd->dev, "%s\n", __func__); | ||
| 474 | |||
| 475 | if (i != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 476 | return -EINVAL; | ||
| 477 | |||
| 478 | /* This calls buf_release from host driver's videobuf_queue_ops for all | ||
| 479 | * remaining buffers. When the last buffer is freed, stop capture */ | ||
| 480 | videobuf_streamoff(&icf->vb_vidq); | ||
| 481 | |||
| 482 | icd->ops->stop_capture(icd); | ||
| 483 | |||
| 484 | return 0; | ||
| 485 | } | ||
| 486 | |||
| 487 | static int soc_camera_queryctrl(struct file *file, void *priv, | ||
| 488 | struct v4l2_queryctrl *qc) | ||
| 489 | { | ||
| 490 | struct soc_camera_file *icf = file->private_data; | ||
| 491 | struct soc_camera_device *icd = icf->icd; | ||
| 492 | int i; | ||
| 493 | |||
| 494 | WARN_ON(priv != file->private_data); | ||
| 495 | |||
| 496 | if (!qc->id) | ||
| 497 | return -EINVAL; | ||
| 498 | |||
| 499 | for (i = 0; i < icd->ops->num_controls; i++) | ||
| 500 | if (qc->id == icd->ops->controls[i].id) { | ||
| 501 | memcpy(qc, &(icd->ops->controls[i]), | ||
| 502 | sizeof(*qc)); | ||
| 503 | return 0; | ||
| 504 | } | ||
| 505 | |||
| 506 | return -EINVAL; | ||
| 507 | } | ||
| 508 | |||
| 509 | static int soc_camera_g_ctrl(struct file *file, void *priv, | ||
| 510 | struct v4l2_control *ctrl) | ||
| 511 | { | ||
| 512 | struct soc_camera_file *icf = file->private_data; | ||
| 513 | struct soc_camera_device *icd = icf->icd; | ||
| 514 | |||
| 515 | WARN_ON(priv != file->private_data); | ||
| 516 | |||
| 517 | switch (ctrl->id) { | ||
| 518 | case V4L2_CID_GAIN: | ||
| 519 | if (icd->gain == (unsigned short)~0) | ||
| 520 | return -EINVAL; | ||
| 521 | ctrl->value = icd->gain; | ||
| 522 | return 0; | ||
| 523 | case V4L2_CID_EXPOSURE: | ||
| 524 | if (icd->exposure == (unsigned short)~0) | ||
| 525 | return -EINVAL; | ||
| 526 | ctrl->value = icd->exposure; | ||
| 527 | return 0; | ||
| 528 | } | ||
| 529 | |||
| 530 | if (icd->ops->get_control) | ||
| 531 | return icd->ops->get_control(icd, ctrl); | ||
| 532 | return -EINVAL; | ||
| 533 | } | ||
| 534 | |||
| 535 | static int soc_camera_s_ctrl(struct file *file, void *priv, | ||
| 536 | struct v4l2_control *ctrl) | ||
| 537 | { | ||
| 538 | struct soc_camera_file *icf = file->private_data; | ||
| 539 | struct soc_camera_device *icd = icf->icd; | ||
| 540 | |||
| 541 | WARN_ON(priv != file->private_data); | ||
| 542 | |||
| 543 | if (icd->ops->set_control) | ||
| 544 | return icd->ops->set_control(icd, ctrl); | ||
| 545 | return -EINVAL; | ||
| 546 | } | ||
| 547 | |||
| 548 | static int soc_camera_cropcap(struct file *file, void *fh, | ||
| 549 | struct v4l2_cropcap *a) | ||
| 550 | { | ||
| 551 | struct soc_camera_file *icf = file->private_data; | ||
| 552 | struct soc_camera_device *icd = icf->icd; | ||
| 553 | |||
| 554 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 555 | a->bounds.left = icd->x_min; | ||
| 556 | a->bounds.top = icd->y_min; | ||
| 557 | a->bounds.width = icd->width_max; | ||
| 558 | a->bounds.height = icd->height_max; | ||
| 559 | a->defrect.left = icd->x_min; | ||
| 560 | a->defrect.top = icd->y_min; | ||
| 561 | a->defrect.width = 640; | ||
| 562 | a->defrect.height = 480; | ||
| 563 | a->pixelaspect.numerator = 1; | ||
| 564 | a->pixelaspect.denominator = 1; | ||
| 565 | |||
| 566 | return 0; | ||
| 567 | } | ||
| 568 | |||
| 569 | static int soc_camera_g_crop(struct file *file, void *fh, | ||
| 570 | struct v4l2_crop *a) | ||
| 571 | { | ||
| 572 | struct soc_camera_file *icf = file->private_data; | ||
| 573 | struct soc_camera_device *icd = icf->icd; | ||
| 574 | |||
| 575 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 576 | a->c.left = icd->x_current; | ||
| 577 | a->c.top = icd->y_current; | ||
| 578 | a->c.width = icd->width; | ||
| 579 | a->c.height = icd->height; | ||
| 580 | |||
| 581 | return 0; | ||
| 582 | } | ||
| 583 | |||
| 584 | static int soc_camera_s_crop(struct file *file, void *fh, | ||
| 585 | struct v4l2_crop *a) | ||
| 586 | { | ||
| 587 | struct soc_camera_file *icf = file->private_data; | ||
| 588 | struct soc_camera_device *icd = icf->icd; | ||
| 589 | struct soc_camera_host *ici = | ||
| 590 | to_soc_camera_host(icd->dev.parent); | ||
| 591 | int ret; | ||
| 592 | |||
| 593 | if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 594 | return -EINVAL; | ||
| 595 | |||
| 596 | ret = ici->ops->set_fmt_cap(icd, 0, &a->c); | ||
| 597 | if (!ret) { | ||
| 598 | icd->width = a->c.width; | ||
| 599 | icd->height = a->c.height; | ||
| 600 | icd->x_current = a->c.left; | ||
| 601 | icd->y_current = a->c.top; | ||
| 602 | } | ||
| 603 | |||
| 604 | return ret; | ||
| 605 | } | ||
| 606 | |||
| 607 | static int soc_camera_g_chip_ident(struct file *file, void *fh, | ||
| 608 | struct v4l2_chip_ident *id) | ||
| 609 | { | ||
| 610 | struct soc_camera_file *icf = file->private_data; | ||
| 611 | struct soc_camera_device *icd = icf->icd; | ||
| 612 | |||
| 613 | if (!icd->ops->get_chip_id) | ||
| 614 | return -EINVAL; | ||
| 615 | |||
| 616 | return icd->ops->get_chip_id(icd, id); | ||
| 617 | } | ||
| 618 | |||
| 619 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
| 620 | static int soc_camera_g_register(struct file *file, void *fh, | ||
| 621 | struct v4l2_register *reg) | ||
| 622 | { | ||
| 623 | struct soc_camera_file *icf = file->private_data; | ||
| 624 | struct soc_camera_device *icd = icf->icd; | ||
| 625 | |||
| 626 | if (!icd->ops->get_register) | ||
| 627 | return -EINVAL; | ||
| 628 | |||
| 629 | return icd->ops->get_register(icd, reg); | ||
| 630 | } | ||
| 631 | |||
| 632 | static int soc_camera_s_register(struct file *file, void *fh, | ||
| 633 | struct v4l2_register *reg) | ||
| 634 | { | ||
| 635 | struct soc_camera_file *icf = file->private_data; | ||
| 636 | struct soc_camera_device *icd = icf->icd; | ||
| 637 | |||
| 638 | if (!icd->ops->set_register) | ||
| 639 | return -EINVAL; | ||
| 640 | |||
| 641 | return icd->ops->set_register(icd, reg); | ||
| 642 | } | ||
| 643 | #endif | ||
| 644 | |||
| 645 | static int device_register_link(struct soc_camera_device *icd) | ||
| 646 | { | ||
| 647 | int ret = device_register(&icd->dev); | ||
| 648 | |||
| 649 | if (ret < 0) { | ||
| 650 | /* Prevent calling device_unregister() */ | ||
| 651 | icd->dev.parent = NULL; | ||
| 652 | dev_err(&icd->dev, "Cannot register device: %d\n", ret); | ||
| 653 | /* Even if probe() was unsuccessful for all registered drivers, | ||
| 654 | * device_register() returns 0, and we add the link, just to | ||
| 655 | * document this camera's control device */ | ||
| 656 | } else if (icd->control) | ||
| 657 | /* Have to sysfs_remove_link() before device_unregister()? */ | ||
| 658 | if (sysfs_create_link(&icd->dev.kobj, &icd->control->kobj, | ||
| 659 | "control")) | ||
| 660 | dev_warn(&icd->dev, | ||
| 661 | "Failed creating the control symlink\n"); | ||
| 662 | return ret; | ||
| 663 | } | ||
| 664 | |||
| 665 | /* So far this function cannot fail */ | ||
| 666 | static void scan_add_host(struct soc_camera_host *ici) | ||
| 667 | { | ||
| 668 | struct soc_camera_device *icd; | ||
| 669 | |||
| 670 | mutex_lock(&list_lock); | ||
| 671 | |||
| 672 | list_for_each_entry(icd, &devices, list) { | ||
| 673 | if (icd->iface == ici->nr) { | ||
| 674 | icd->dev.parent = &ici->dev; | ||
| 675 | device_register_link(icd); | ||
| 676 | } | ||
| 677 | } | ||
| 678 | |||
| 679 | mutex_unlock(&list_lock); | ||
| 680 | } | ||
| 681 | |||
| 682 | /* return: 0 if no match found or a match found and | ||
| 683 | * device_register() successful, error code otherwise */ | ||
| 684 | static int scan_add_device(struct soc_camera_device *icd) | ||
| 685 | { | ||
| 686 | struct soc_camera_host *ici; | ||
| 687 | int ret = 0; | ||
| 688 | |||
| 689 | mutex_lock(&list_lock); | ||
| 690 | |||
| 691 | list_add_tail(&icd->list, &devices); | ||
| 692 | |||
| 693 | /* Watch out for class_for_each_device / class_find_device API by | ||
| 694 | * Dave Young <hidave.darkstar@gmail.com> */ | ||
| 695 | list_for_each_entry(ici, &hosts, list) { | ||
| 696 | if (icd->iface == ici->nr) { | ||
| 697 | ret = 1; | ||
| 698 | icd->dev.parent = &ici->dev; | ||
| 699 | break; | ||
| 700 | } | ||
| 701 | } | ||
| 702 | |||
| 703 | mutex_unlock(&list_lock); | ||
| 704 | |||
| 705 | if (ret) | ||
| 706 | ret = device_register_link(icd); | ||
| 707 | |||
| 708 | return ret; | ||
| 709 | } | ||
| 710 | |||
| 711 | static int soc_camera_probe(struct device *dev) | ||
| 712 | { | ||
| 713 | struct soc_camera_device *icd = to_soc_camera_dev(dev); | ||
| 714 | struct soc_camera_host *ici = | ||
| 715 | to_soc_camera_host(icd->dev.parent); | ||
| 716 | int ret; | ||
| 717 | |||
| 718 | if (!icd->ops->probe) | ||
| 719 | return -ENODEV; | ||
| 720 | |||
| 721 | /* We only call ->add() here to activate and probe the camera. | ||
| 722 | * We shall ->remove() and deactivate it immediately afterwards. */ | ||
| 723 | ret = ici->ops->add(icd); | ||
| 724 | if (ret < 0) | ||
| 725 | return ret; | ||
| 726 | |||
| 727 | ret = icd->ops->probe(icd); | ||
| 728 | if (ret >= 0) { | ||
| 729 | const struct v4l2_queryctrl *qctrl; | ||
| 730 | |||
| 731 | qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_GAIN); | ||
| 732 | icd->gain = qctrl ? qctrl->default_value : (unsigned short)~0; | ||
| 733 | qctrl = soc_camera_find_qctrl(icd->ops, V4L2_CID_EXPOSURE); | ||
| 734 | icd->exposure = qctrl ? qctrl->default_value : | ||
| 735 | (unsigned short)~0; | ||
| 736 | } | ||
| 737 | ici->ops->remove(icd); | ||
| 738 | |||
| 739 | return ret; | ||
| 740 | } | ||
| 741 | |||
| 742 | /* This is called on device_unregister, which only means we have to disconnect | ||
| 743 | * from the host, but not remove ourselves from the device list */ | ||
| 744 | static int soc_camera_remove(struct device *dev) | ||
| 745 | { | ||
| 746 | struct soc_camera_device *icd = to_soc_camera_dev(dev); | ||
| 747 | |||
| 748 | if (icd->ops->remove) | ||
| 749 | icd->ops->remove(icd); | ||
| 750 | |||
| 751 | return 0; | ||
| 752 | } | ||
| 753 | |||
| 754 | static struct bus_type soc_camera_bus_type = { | ||
| 755 | .name = "soc-camera", | ||
| 756 | .probe = soc_camera_probe, | ||
| 757 | .remove = soc_camera_remove, | ||
| 758 | }; | ||
| 759 | |||
| 760 | static struct device_driver ic_drv = { | ||
| 761 | .name = "camera", | ||
| 762 | .bus = &soc_camera_bus_type, | ||
| 763 | .owner = THIS_MODULE, | ||
| 764 | }; | ||
| 765 | |||
| 766 | /* | ||
| 767 | * Image capture host - this is a host device, not a bus device, so, | ||
| 768 | * no bus reference, no probing. | ||
| 769 | */ | ||
| 770 | static struct class soc_camera_host_class = { | ||
| 771 | .owner = THIS_MODULE, | ||
| 772 | .name = "camera_host", | ||
| 773 | }; | ||
| 774 | |||
| 775 | static void dummy_release(struct device *dev) | ||
| 776 | { | ||
| 777 | } | ||
| 778 | |||
| 779 | static spinlock_t *spinlock_alloc(struct soc_camera_file *icf) | ||
| 780 | { | ||
| 781 | spinlock_t *lock = kmalloc(sizeof(spinlock_t), GFP_KERNEL); | ||
| 782 | |||
| 783 | if (lock) | ||
| 784 | spin_lock_init(lock); | ||
| 785 | |||
| 786 | return lock; | ||
| 787 | } | ||
| 788 | |||
| 789 | static void spinlock_free(spinlock_t *lock) | ||
| 790 | { | ||
| 791 | kfree(lock); | ||
| 792 | } | ||
| 793 | |||
| 794 | int soc_camera_host_register(struct soc_camera_host *ici) | ||
| 795 | { | ||
| 796 | int ret; | ||
| 797 | struct soc_camera_host *ix; | ||
| 798 | |||
| 799 | if (!ici->vbq_ops || !ici->ops->add || !ici->ops->remove) | ||
| 800 | return -EINVAL; | ||
| 801 | |||
| 802 | /* Number might be equal to the platform device ID */ | ||
| 803 | sprintf(ici->dev.bus_id, "camera_host%d", ici->nr); | ||
| 804 | ici->dev.class = &soc_camera_host_class; | ||
| 805 | |||
| 806 | mutex_lock(&list_lock); | ||
| 807 | list_for_each_entry(ix, &hosts, list) { | ||
| 808 | if (ix->nr == ici->nr) { | ||
| 809 | mutex_unlock(&list_lock); | ||
| 810 | return -EBUSY; | ||
| 811 | } | ||
| 812 | } | ||
| 813 | |||
| 814 | list_add_tail(&ici->list, &hosts); | ||
| 815 | mutex_unlock(&list_lock); | ||
| 816 | |||
| 817 | ici->dev.release = dummy_release; | ||
| 818 | |||
| 819 | ret = device_register(&ici->dev); | ||
| 820 | |||
| 821 | if (ret) | ||
| 822 | goto edevr; | ||
| 823 | |||
| 824 | if (!ici->ops->spinlock_alloc) { | ||
| 825 | ici->ops->spinlock_alloc = spinlock_alloc; | ||
| 826 | ici->ops->spinlock_free = spinlock_free; | ||
| 827 | } | ||
| 828 | |||
| 829 | scan_add_host(ici); | ||
| 830 | |||
| 831 | return 0; | ||
| 832 | |||
| 833 | edevr: | ||
| 834 | mutex_lock(&list_lock); | ||
| 835 | list_del(&ici->list); | ||
| 836 | mutex_unlock(&list_lock); | ||
| 837 | |||
| 838 | return ret; | ||
| 839 | } | ||
| 840 | EXPORT_SYMBOL(soc_camera_host_register); | ||
| 841 | |||
| 842 | /* Unregister all clients! */ | ||
| 843 | void soc_camera_host_unregister(struct soc_camera_host *ici) | ||
| 844 | { | ||
| 845 | struct soc_camera_device *icd; | ||
| 846 | |||
| 847 | mutex_lock(&list_lock); | ||
| 848 | |||
| 849 | list_del(&ici->list); | ||
| 850 | |||
| 851 | list_for_each_entry(icd, &devices, list) { | ||
| 852 | if (icd->dev.parent == &ici->dev) { | ||
| 853 | device_unregister(&icd->dev); | ||
| 854 | /* Not before device_unregister(), .remove | ||
| 855 | * needs parent to call ici->ops->remove() */ | ||
| 856 | icd->dev.parent = NULL; | ||
| 857 | memset(&icd->dev.kobj, 0, sizeof(icd->dev.kobj)); | ||
| 858 | } | ||
| 859 | } | ||
| 860 | |||
| 861 | mutex_unlock(&list_lock); | ||
| 862 | |||
| 863 | device_unregister(&ici->dev); | ||
| 864 | } | ||
| 865 | EXPORT_SYMBOL(soc_camera_host_unregister); | ||
| 866 | |||
| 867 | /* Image capture device */ | ||
| 868 | int soc_camera_device_register(struct soc_camera_device *icd) | ||
| 869 | { | ||
| 870 | struct soc_camera_device *ix; | ||
| 871 | int num = -1, i; | ||
| 872 | |||
| 873 | if (!icd) | ||
| 874 | return -EINVAL; | ||
| 875 | |||
| 876 | for (i = 0; i < 256 && num < 0; i++) { | ||
| 877 | num = i; | ||
| 878 | list_for_each_entry(ix, &devices, list) { | ||
| 879 | if (ix->iface == icd->iface && ix->devnum == i) { | ||
| 880 | num = -1; | ||
| 881 | break; | ||
| 882 | } | ||
| 883 | } | ||
| 884 | } | ||
| 885 | |||
| 886 | if (num < 0) | ||
| 887 | /* ok, we have 256 cameras on this host... | ||
| 888 | * man, stay reasonable... */ | ||
| 889 | return -ENOMEM; | ||
| 890 | |||
| 891 | icd->devnum = num; | ||
| 892 | icd->dev.bus = &soc_camera_bus_type; | ||
| 893 | snprintf(icd->dev.bus_id, sizeof(icd->dev.bus_id), | ||
| 894 | "%u-%u", icd->iface, icd->devnum); | ||
| 895 | |||
| 896 | icd->dev.release = dummy_release; | ||
| 897 | |||
| 898 | return scan_add_device(icd); | ||
| 899 | } | ||
| 900 | EXPORT_SYMBOL(soc_camera_device_register); | ||
| 901 | |||
| 902 | void soc_camera_device_unregister(struct soc_camera_device *icd) | ||
| 903 | { | ||
| 904 | mutex_lock(&list_lock); | ||
| 905 | list_del(&icd->list); | ||
| 906 | |||
| 907 | /* The bus->remove will be eventually called */ | ||
| 908 | if (icd->dev.parent) | ||
| 909 | device_unregister(&icd->dev); | ||
| 910 | mutex_unlock(&list_lock); | ||
| 911 | } | ||
| 912 | EXPORT_SYMBOL(soc_camera_device_unregister); | ||
| 913 | |||
| 914 | int soc_camera_video_start(struct soc_camera_device *icd) | ||
| 915 | { | ||
| 916 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | ||
| 917 | int err = -ENOMEM; | ||
| 918 | struct video_device *vdev; | ||
| 919 | |||
| 920 | if (!icd->dev.parent) | ||
| 921 | return -ENODEV; | ||
| 922 | |||
| 923 | vdev = video_device_alloc(); | ||
| 924 | if (!vdev) | ||
| 925 | goto evidallocd; | ||
| 926 | dev_dbg(&ici->dev, "Allocated video_device %p\n", vdev); | ||
| 927 | |||
| 928 | strlcpy(vdev->name, ici->drv_name, sizeof(vdev->name)); | ||
| 929 | /* Maybe better &ici->dev */ | ||
| 930 | vdev->dev = &icd->dev; | ||
| 931 | vdev->type = VID_TYPE_CAPTURE; | ||
| 932 | vdev->current_norm = V4L2_STD_UNKNOWN; | ||
| 933 | vdev->fops = &soc_camera_fops; | ||
| 934 | vdev->release = video_device_release; | ||
| 935 | vdev->minor = -1; | ||
| 936 | vdev->tvnorms = V4L2_STD_UNKNOWN, | ||
| 937 | vdev->vidioc_querycap = soc_camera_querycap; | ||
| 938 | vdev->vidioc_g_fmt_cap = soc_camera_g_fmt_cap; | ||
| 939 | vdev->vidioc_enum_fmt_cap = soc_camera_enum_fmt_cap; | ||
| 940 | vdev->vidioc_s_fmt_cap = soc_camera_s_fmt_cap; | ||
| 941 | vdev->vidioc_enum_input = soc_camera_enum_input; | ||
| 942 | vdev->vidioc_g_input = soc_camera_g_input; | ||
| 943 | vdev->vidioc_s_input = soc_camera_s_input; | ||
| 944 | vdev->vidioc_s_std = soc_camera_s_std; | ||
| 945 | vdev->vidioc_reqbufs = soc_camera_reqbufs; | ||
| 946 | vdev->vidioc_try_fmt_cap = soc_camera_try_fmt_cap; | ||
| 947 | vdev->vidioc_querybuf = soc_camera_querybuf; | ||
| 948 | vdev->vidioc_qbuf = soc_camera_qbuf; | ||
| 949 | vdev->vidioc_dqbuf = soc_camera_dqbuf; | ||
| 950 | vdev->vidioc_streamon = soc_camera_streamon; | ||
| 951 | vdev->vidioc_streamoff = soc_camera_streamoff; | ||
| 952 | vdev->vidioc_queryctrl = soc_camera_queryctrl; | ||
| 953 | vdev->vidioc_g_ctrl = soc_camera_g_ctrl; | ||
| 954 | vdev->vidioc_s_ctrl = soc_camera_s_ctrl; | ||
| 955 | vdev->vidioc_cropcap = soc_camera_cropcap; | ||
| 956 | vdev->vidioc_g_crop = soc_camera_g_crop; | ||
| 957 | vdev->vidioc_s_crop = soc_camera_s_crop; | ||
| 958 | vdev->vidioc_g_chip_ident = soc_camera_g_chip_ident; | ||
| 959 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
| 960 | vdev->vidioc_g_register = soc_camera_g_register; | ||
| 961 | vdev->vidioc_s_register = soc_camera_s_register; | ||
| 962 | #endif | ||
| 963 | |||
| 964 | icd->current_fmt = &icd->formats[0]; | ||
| 965 | |||
| 966 | err = video_register_device(vdev, VFL_TYPE_GRABBER, vdev->minor); | ||
| 967 | if (err < 0) { | ||
| 968 | dev_err(vdev->dev, "video_register_device failed\n"); | ||
| 969 | goto evidregd; | ||
| 970 | } | ||
| 971 | icd->vdev = vdev; | ||
| 972 | |||
| 973 | return 0; | ||
| 974 | |||
| 975 | evidregd: | ||
| 976 | video_device_release(vdev); | ||
| 977 | evidallocd: | ||
| 978 | return err; | ||
| 979 | } | ||
| 980 | EXPORT_SYMBOL(soc_camera_video_start); | ||
| 981 | |||
| 982 | void soc_camera_video_stop(struct soc_camera_device *icd) | ||
| 983 | { | ||
| 984 | struct video_device *vdev = icd->vdev; | ||
| 985 | |||
| 986 | dev_dbg(&icd->dev, "%s\n", __func__); | ||
| 987 | |||
| 988 | if (!icd->dev.parent || !vdev) | ||
| 989 | return; | ||
| 990 | |||
| 991 | mutex_lock(&video_lock); | ||
| 992 | video_unregister_device(vdev); | ||
| 993 | icd->vdev = NULL; | ||
| 994 | mutex_unlock(&video_lock); | ||
| 995 | } | ||
| 996 | EXPORT_SYMBOL(soc_camera_video_stop); | ||
| 997 | |||
| 998 | static int __init soc_camera_init(void) | ||
| 999 | { | ||
| 1000 | int ret = bus_register(&soc_camera_bus_type); | ||
| 1001 | if (ret) | ||
| 1002 | return ret; | ||
| 1003 | ret = driver_register(&ic_drv); | ||
| 1004 | if (ret) | ||
| 1005 | goto edrvr; | ||
| 1006 | ret = class_register(&soc_camera_host_class); | ||
| 1007 | if (ret) | ||
| 1008 | goto eclr; | ||
| 1009 | |||
| 1010 | return 0; | ||
| 1011 | |||
| 1012 | eclr: | ||
| 1013 | driver_unregister(&ic_drv); | ||
| 1014 | edrvr: | ||
| 1015 | bus_unregister(&soc_camera_bus_type); | ||
| 1016 | return ret; | ||
| 1017 | } | ||
| 1018 | |||
| 1019 | static void __exit soc_camera_exit(void) | ||
| 1020 | { | ||
| 1021 | class_unregister(&soc_camera_host_class); | ||
| 1022 | driver_unregister(&ic_drv); | ||
| 1023 | bus_unregister(&soc_camera_bus_type); | ||
| 1024 | } | ||
| 1025 | |||
| 1026 | module_init(soc_camera_init); | ||
| 1027 | module_exit(soc_camera_exit); | ||
| 1028 | |||
| 1029 | MODULE_DESCRIPTION("Image capture bus driver"); | ||
| 1030 | MODULE_AUTHOR("Guennadi Liakhovetski <kernel@pengutronix.de>"); | ||
| 1031 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c index ceba45ad0294..9276ed997388 100644 --- a/drivers/media/video/stk-webcam.c +++ b/drivers/media/video/stk-webcam.c | |||
| @@ -1100,7 +1100,7 @@ static int stk_setup_format(struct stk_camera *dev) | |||
| 1100 | && i < ARRAY_SIZE(stk_sizes)) | 1100 | && i < ARRAY_SIZE(stk_sizes)) |
| 1101 | i++; | 1101 | i++; |
| 1102 | if (i == ARRAY_SIZE(stk_sizes)) { | 1102 | if (i == ARRAY_SIZE(stk_sizes)) { |
| 1103 | STK_ERROR("Something is broken in %s\n", __FUNCTION__); | 1103 | STK_ERROR("Something is broken in %s\n", __func__); |
| 1104 | return -EFAULT; | 1104 | return -EFAULT; |
| 1105 | } | 1105 | } |
| 1106 | /* This registers controls some timings, not sure of what. */ | 1106 | /* This registers controls some timings, not sure of what. */ |
| @@ -1465,7 +1465,7 @@ static void stk_camera_disconnect(struct usb_interface *interface) | |||
| 1465 | } | 1465 | } |
| 1466 | 1466 | ||
| 1467 | #ifdef CONFIG_PM | 1467 | #ifdef CONFIG_PM |
| 1468 | int stk_camera_suspend(struct usb_interface *intf, pm_message_t message) | 1468 | static int stk_camera_suspend(struct usb_interface *intf, pm_message_t message) |
| 1469 | { | 1469 | { |
| 1470 | struct stk_camera *dev = usb_get_intfdata(intf); | 1470 | struct stk_camera *dev = usb_get_intfdata(intf); |
| 1471 | if (is_streaming(dev)) { | 1471 | if (is_streaming(dev)) { |
| @@ -1476,7 +1476,7 @@ int stk_camera_suspend(struct usb_interface *intf, pm_message_t message) | |||
| 1476 | return 0; | 1476 | return 0; |
| 1477 | } | 1477 | } |
| 1478 | 1478 | ||
| 1479 | int stk_camera_resume(struct usb_interface *intf) | 1479 | static int stk_camera_resume(struct usb_interface *intf) |
| 1480 | { | 1480 | { |
| 1481 | struct stk_camera *dev = usb_get_intfdata(intf); | 1481 | struct stk_camera *dev = usb_get_intfdata(intf); |
| 1482 | if (!is_initialised(dev)) | 1482 | if (!is_initialised(dev)) |
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c index 3fb85af5d1f2..c109511f21ea 100644 --- a/drivers/media/video/stradis.c +++ b/drivers/media/video/stradis.c | |||
| @@ -58,7 +58,7 @@ | |||
| 58 | 58 | ||
| 59 | static struct saa7146 saa7146s[SAA7146_MAX]; | 59 | static struct saa7146 saa7146s[SAA7146_MAX]; |
| 60 | 60 | ||
| 61 | static int saa_num = 0; /* number of SAA7146s in use */ | 61 | static int saa_num; /* number of SAA7146s in use */ |
| 62 | 62 | ||
| 63 | static int video_nr = -1; | 63 | static int video_nr = -1; |
| 64 | module_param(video_nr, int, 0); | 64 | module_param(video_nr, int, 0); |
| @@ -248,7 +248,7 @@ static void I2CBusScan(struct saa7146 *saa) | |||
| 248 | attach_inform(saa, i); | 248 | attach_inform(saa, i); |
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | static int debiwait_maxwait = 0; | 251 | static int debiwait_maxwait; |
| 252 | 252 | ||
| 253 | static int wait_for_debi_done(struct saa7146 *saa) | 253 | static int wait_for_debi_done(struct saa7146 *saa) |
| 254 | { | 254 | { |
| @@ -1906,7 +1906,9 @@ static const struct file_operations saa_fops = { | |||
| 1906 | .open = saa_open, | 1906 | .open = saa_open, |
| 1907 | .release = saa_release, | 1907 | .release = saa_release, |
| 1908 | .ioctl = saa_ioctl, | 1908 | .ioctl = saa_ioctl, |
| 1909 | #ifdef CONFIG_COMPAT | ||
| 1909 | .compat_ioctl = v4l_compat_ioctl32, | 1910 | .compat_ioctl = v4l_compat_ioctl32, |
| 1911 | #endif | ||
| 1910 | .read = saa_read, | 1912 | .read = saa_read, |
| 1911 | .llseek = no_llseek, | 1913 | .llseek = no_llseek, |
| 1912 | .write = saa_write, | 1914 | .write = saa_write, |
diff --git a/drivers/media/video/stv680.c b/drivers/media/video/stv680.c index afc32aa56fde..d7f130bedb5f 100644 --- a/drivers/media/video/stv680.c +++ b/drivers/media/video/stv680.c | |||
| @@ -72,15 +72,18 @@ | |||
| 72 | #include "stv680.h" | 72 | #include "stv680.h" |
| 73 | 73 | ||
| 74 | static int video_nr = -1; | 74 | static int video_nr = -1; |
| 75 | static int swapRGB = 0; /* default for auto sleect */ | ||
| 76 | static int swapRGB_on = 0; /* default to allow auto select; -1=swap never, +1= swap always */ | ||
| 77 | 75 | ||
| 78 | static unsigned int debug = 0; | 76 | static int swapRGB; /* 0 = default for auto select */ |
| 77 | |||
| 78 | /* 0 = default to allow auto select; -1 = swap never, +1 = swap always */ | ||
| 79 | static int swapRGB_on; | ||
| 80 | |||
| 81 | static unsigned int debug; | ||
| 79 | 82 | ||
| 80 | #define PDEBUG(level, fmt, args...) \ | 83 | #define PDEBUG(level, fmt, args...) \ |
| 81 | do { \ | 84 | do { \ |
| 82 | if (debug >= level) \ | 85 | if (debug >= level) \ |
| 83 | info("[%s:%d] " fmt, __FUNCTION__, __LINE__ , ## args); \ | 86 | info("[%s:%d] " fmt, __func__, __LINE__ , ## args); \ |
| 84 | } while (0) | 87 | } while (0) |
| 85 | 88 | ||
| 86 | 89 | ||
| @@ -1391,7 +1394,9 @@ static const struct file_operations stv680_fops = { | |||
| 1391 | .read = stv680_read, | 1394 | .read = stv680_read, |
| 1392 | .mmap = stv680_mmap, | 1395 | .mmap = stv680_mmap, |
| 1393 | .ioctl = stv680_ioctl, | 1396 | .ioctl = stv680_ioctl, |
| 1397 | #ifdef CONFIG_COMPAT | ||
| 1394 | .compat_ioctl = v4l_compat_ioctl32, | 1398 | .compat_ioctl = v4l_compat_ioctl32, |
| 1399 | #endif | ||
| 1395 | .llseek = no_llseek, | 1400 | .llseek = no_llseek, |
| 1396 | }; | 1401 | }; |
| 1397 | static struct video_device stv680_template = { | 1402 | static struct video_device stv680_template = { |
diff --git a/drivers/media/video/tcm825x.c b/drivers/media/video/tcm825x.c index fb895f6684a3..6943b447a1bd 100644 --- a/drivers/media/video/tcm825x.c +++ b/drivers/media/video/tcm825x.c | |||
| @@ -906,7 +906,7 @@ static int __init tcm825x_init(void) | |||
| 906 | rval = i2c_add_driver(&tcm825x_i2c_driver); | 906 | rval = i2c_add_driver(&tcm825x_i2c_driver); |
| 907 | if (rval) | 907 | if (rval) |
| 908 | printk(KERN_INFO "%s: failed registering " TCM825X_NAME "\n", | 908 | printk(KERN_INFO "%s: failed registering " TCM825X_NAME "\n", |
| 909 | __FUNCTION__); | 909 | __func__); |
| 910 | 910 | ||
| 911 | return rval; | 911 | return rval; |
| 912 | } | 912 | } |
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c index 55bc89a6f069..0ebb5b525e57 100644 --- a/drivers/media/video/tda8290.c +++ b/drivers/media/video/tda8290.c | |||
| @@ -32,8 +32,6 @@ static int debug; | |||
| 32 | module_param(debug, int, 0644); | 32 | module_param(debug, int, 0644); |
| 33 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 33 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 34 | 34 | ||
| 35 | #define PREFIX "tda8290" | ||
| 36 | |||
| 37 | /* ---------------------------------------------------------------------- */ | 35 | /* ---------------------------------------------------------------------- */ |
| 38 | 36 | ||
| 39 | struct tda8290_priv { | 37 | struct tda8290_priv { |
| @@ -174,7 +172,7 @@ static void tda8290_set_params(struct dvb_frontend *fe, | |||
| 174 | set_audio(fe, params); | 172 | set_audio(fe, params); |
| 175 | 173 | ||
| 176 | if (priv->cfg.config) | 174 | if (priv->cfg.config) |
| 177 | tuner_dbg("tda827xa config is 0x%02x\n", *priv->cfg.config); | 175 | tuner_dbg("tda827xa config is 0x%02x\n", priv->cfg.config); |
| 178 | tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); | 176 | tuner_i2c_xfer_send(&priv->i2c_props, easy_mode, 2); |
| 179 | tuner_i2c_xfer_send(&priv->i2c_props, agc_out_on, 2); | 177 | tuner_i2c_xfer_send(&priv->i2c_props, agc_out_on, 2); |
| 180 | tuner_i2c_xfer_send(&priv->i2c_props, soft_reset, 2); | 178 | tuner_i2c_xfer_send(&priv->i2c_props, soft_reset, 2); |
| @@ -365,7 +363,7 @@ static void tda8295_set_params(struct dvb_frontend *fe, | |||
| 365 | 363 | ||
| 366 | set_audio(fe, params); | 364 | set_audio(fe, params); |
| 367 | 365 | ||
| 368 | tuner_dbg("%s: freq = %d\n", __FUNCTION__, params->frequency); | 366 | tuner_dbg("%s: freq = %d\n", __func__, params->frequency); |
| 369 | 367 | ||
| 370 | tda8295_power(fe, 1); | 368 | tda8295_power(fe, 1); |
| 371 | tda8295_agc1_out(fe, 1); | 369 | tda8295_agc1_out(fe, 1); |
| @@ -444,8 +442,7 @@ static void tda8290_init_if(struct dvb_frontend *fe) | |||
| 444 | unsigned char set_GP00_CF[] = { 0x20, 0x01 }; | 442 | unsigned char set_GP00_CF[] = { 0x20, 0x01 }; |
| 445 | unsigned char set_GP01_CF[] = { 0x20, 0x0B }; | 443 | unsigned char set_GP01_CF[] = { 0x20, 0x0B }; |
| 446 | 444 | ||
| 447 | if ((priv->cfg.config) && | 445 | if ((priv->cfg.config == 1) || (priv->cfg.config == 2)) |
| 448 | ((*priv->cfg.config == 1) || (*priv->cfg.config == 2))) | ||
| 449 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2); | 446 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP00_CF, 2); |
| 450 | else | 447 | else |
| 451 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2); | 448 | tuner_i2c_xfer_send(&priv->i2c_props, set_GP01_CF, 2); |
| @@ -590,8 +587,8 @@ static int tda829x_find_tuner(struct dvb_frontend *fe) | |||
| 590 | else | 587 | else |
| 591 | priv->ver |= TDA8275A; | 588 | priv->ver |= TDA8275A; |
| 592 | 589 | ||
| 593 | tda827x_attach(fe, priv->tda827x_addr, | 590 | tda827x_attach(fe, priv->tda827x_addr, priv->i2c_props.adap, &priv->cfg); |
| 594 | priv->i2c_props.adap, &priv->cfg); | 591 | priv->cfg.switch_addr = priv->i2c_props.addr; |
| 595 | } | 592 | } |
| 596 | if (fe->ops.tuner_ops.init) | 593 | if (fe->ops.tuner_ops.init) |
| 597 | fe->ops.tuner_ops.init(fe); | 594 | fe->ops.tuner_ops.init(fe); |
| @@ -616,7 +613,7 @@ static int tda8290_probe(struct tuner_i2c_props *i2c_props) | |||
| 616 | if (tda8290_id[1] == TDA8290_ID) { | 613 | if (tda8290_id[1] == TDA8290_ID) { |
| 617 | if (debug) | 614 | if (debug) |
| 618 | printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n", | 615 | printk(KERN_DEBUG "%s: tda8290 detected @ %d-%04x\n", |
| 619 | __FUNCTION__, i2c_adapter_id(i2c_props->adap), | 616 | __func__, i2c_adapter_id(i2c_props->adap), |
| 620 | i2c_props->addr); | 617 | i2c_props->addr); |
| 621 | return 0; | 618 | return 0; |
| 622 | } | 619 | } |
| @@ -636,7 +633,7 @@ static int tda8295_probe(struct tuner_i2c_props *i2c_props) | |||
| 636 | if (tda8295_id[1] == TDA8295_ID) { | 633 | if (tda8295_id[1] == TDA8295_ID) { |
| 637 | if (debug) | 634 | if (debug) |
| 638 | printk(KERN_DEBUG "%s: tda8295 detected @ %d-%04x\n", | 635 | printk(KERN_DEBUG "%s: tda8295 detected @ %d-%04x\n", |
| 639 | __FUNCTION__, i2c_adapter_id(i2c_props->adap), | 636 | __func__, i2c_adapter_id(i2c_props->adap), |
| 640 | i2c_props->addr); | 637 | i2c_props->addr); |
| 641 | return 0; | 638 | return 0; |
| 642 | } | 639 | } |
| @@ -674,6 +671,7 @@ struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe, | |||
| 674 | 671 | ||
| 675 | priv->i2c_props.addr = i2c_addr; | 672 | priv->i2c_props.addr = i2c_addr; |
| 676 | priv->i2c_props.adap = i2c_adap; | 673 | priv->i2c_props.adap = i2c_adap; |
| 674 | priv->i2c_props.name = "tda829x"; | ||
| 677 | if (cfg) { | 675 | if (cfg) { |
| 678 | priv->cfg.config = cfg->lna_cfg; | 676 | priv->cfg.config = cfg->lna_cfg; |
| 679 | priv->cfg.tuner_callback = cfg->tuner_callback; | 677 | priv->cfg.tuner_callback = cfg->tuner_callback; |
diff --git a/drivers/media/video/tda8290.h b/drivers/media/video/tda8290.h index dc8ef310b7b2..d3bbf276a469 100644 --- a/drivers/media/video/tda8290.h +++ b/drivers/media/video/tda8290.h | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | #include "dvb_frontend.h" | 21 | #include "dvb_frontend.h" |
| 22 | 22 | ||
| 23 | struct tda829x_config { | 23 | struct tda829x_config { |
| 24 | unsigned int *lna_cfg; | 24 | unsigned int lna_cfg; |
| 25 | int (*tuner_callback) (void *dev, int command, int arg); | 25 | int (*tuner_callback) (void *dev, int command, int arg); |
| 26 | 26 | ||
| 27 | unsigned int probe_tuner:1; | 27 | unsigned int probe_tuner:1; |
| @@ -39,7 +39,7 @@ extern struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe, | |||
| 39 | #else | 39 | #else |
| 40 | static inline int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr) | 40 | static inline int tda829x_probe(struct i2c_adapter *i2c_adap, u8 i2c_addr) |
| 41 | { | 41 | { |
| 42 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 42 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 43 | return -EINVAL; | 43 | return -EINVAL; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| @@ -49,7 +49,7 @@ static inline struct dvb_frontend *tda829x_attach(struct dvb_frontend *fe, | |||
| 49 | struct tda829x_config *cfg) | 49 | struct tda829x_config *cfg) |
| 50 | { | 50 | { |
| 51 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", | 51 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", |
| 52 | __FUNCTION__); | 52 | __func__); |
| 53 | return NULL; | 53 | return NULL; |
| 54 | } | 54 | } |
| 55 | #endif | 55 | #endif |
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c index bdca5d278978..0cee00242782 100644 --- a/drivers/media/video/tda9840.c +++ b/drivers/media/video/tda9840.c | |||
| @@ -31,11 +31,11 @@ | |||
| 31 | 31 | ||
| 32 | #include "tda9840.h" | 32 | #include "tda9840.h" |
| 33 | 33 | ||
| 34 | static int debug = 0; /* insmod parameter */ | 34 | static int debug; /* insmod parameter */ |
| 35 | module_param(debug, int, 0644); | 35 | module_param(debug, int, 0644); |
| 36 | MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); | 36 | MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); |
| 37 | #define dprintk(args...) \ | 37 | #define dprintk(args...) \ |
| 38 | do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) | 38 | do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __func__, __LINE__); printk(args); } } while (0) |
| 39 | 39 | ||
| 40 | #define SWITCH 0x00 | 40 | #define SWITCH 0x00 |
| 41 | #define LEVEL_ADJUST 0x02 | 41 | #define LEVEL_ADJUST 0x02 |
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c index 106c93b8203f..a0545ba957b0 100644 --- a/drivers/media/video/tda9887.c +++ b/drivers/media/video/tda9887.c | |||
| @@ -25,10 +25,12 @@ static int debug; | |||
| 25 | module_param(debug, int, 0644); | 25 | module_param(debug, int, 0644); |
| 26 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 26 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 27 | 27 | ||
| 28 | #define PREFIX "tda9887" | 28 | static DEFINE_MUTEX(tda9887_list_mutex); |
| 29 | static LIST_HEAD(hybrid_tuner_instance_list); | ||
| 29 | 30 | ||
| 30 | struct tda9887_priv { | 31 | struct tda9887_priv { |
| 31 | struct tuner_i2c_props i2c_props; | 32 | struct tuner_i2c_props i2c_props; |
| 33 | struct list_head hybrid_tuner_instance_list; | ||
| 32 | 34 | ||
| 33 | unsigned char data[4]; | 35 | unsigned char data[4]; |
| 34 | unsigned int config; | 36 | unsigned int config; |
| @@ -644,7 +646,15 @@ static int tda9887_set_config(struct dvb_frontend *fe, void *priv_cfg) | |||
| 644 | 646 | ||
| 645 | static void tda9887_release(struct dvb_frontend *fe) | 647 | static void tda9887_release(struct dvb_frontend *fe) |
| 646 | { | 648 | { |
| 647 | kfree(fe->analog_demod_priv); | 649 | struct tda9887_priv *priv = fe->analog_demod_priv; |
| 650 | |||
| 651 | mutex_lock(&tda9887_list_mutex); | ||
| 652 | |||
| 653 | if (priv) | ||
| 654 | hybrid_tuner_release_state(priv); | ||
| 655 | |||
| 656 | mutex_unlock(&tda9887_list_mutex); | ||
| 657 | |||
| 648 | fe->analog_demod_priv = NULL; | 658 | fe->analog_demod_priv = NULL; |
| 649 | } | 659 | } |
| 650 | 660 | ||
| @@ -665,17 +675,29 @@ struct dvb_frontend *tda9887_attach(struct dvb_frontend *fe, | |||
| 665 | u8 i2c_addr) | 675 | u8 i2c_addr) |
| 666 | { | 676 | { |
| 667 | struct tda9887_priv *priv = NULL; | 677 | struct tda9887_priv *priv = NULL; |
| 678 | int instance; | ||
| 668 | 679 | ||
| 669 | priv = kzalloc(sizeof(struct tda9887_priv), GFP_KERNEL); | 680 | mutex_lock(&tda9887_list_mutex); |
| 670 | if (priv == NULL) | ||
| 671 | return NULL; | ||
| 672 | fe->analog_demod_priv = priv; | ||
| 673 | 681 | ||
| 674 | priv->i2c_props.addr = i2c_addr; | 682 | instance = hybrid_tuner_request_state(struct tda9887_priv, priv, |
| 675 | priv->i2c_props.adap = i2c_adap; | 683 | hybrid_tuner_instance_list, |
| 676 | priv->mode = T_STANDBY; | 684 | i2c_adap, i2c_addr, "tda9887"); |
| 685 | switch (instance) { | ||
| 686 | case 0: | ||
| 687 | mutex_unlock(&tda9887_list_mutex); | ||
| 688 | return NULL; | ||
| 689 | break; | ||
| 690 | case 1: | ||
| 691 | fe->analog_demod_priv = priv; | ||
| 692 | priv->mode = T_STANDBY; | ||
| 693 | tuner_info("tda988[5/6/7] found\n"); | ||
| 694 | break; | ||
| 695 | default: | ||
| 696 | fe->analog_demod_priv = priv; | ||
| 697 | break; | ||
| 698 | } | ||
| 677 | 699 | ||
| 678 | tuner_info("tda988[5/6/7] found\n"); | 700 | mutex_unlock(&tda9887_list_mutex); |
| 679 | 701 | ||
| 680 | memcpy(&fe->ops.analog_ops, &tda9887_ops, | 702 | memcpy(&fe->ops.analog_ops, &tda9887_ops, |
| 681 | sizeof(struct analog_demod_ops)); | 703 | sizeof(struct analog_demod_ops)); |
diff --git a/drivers/media/video/tda9887.h b/drivers/media/video/tda9887.h index 8f873a8e6ed2..be49dcbfc70e 100644 --- a/drivers/media/video/tda9887.h +++ b/drivers/media/video/tda9887.h | |||
| @@ -30,7 +30,7 @@ static inline struct dvb_frontend *tda9887_attach(struct dvb_frontend *fe, | |||
| 30 | struct i2c_adapter *i2c_adap, | 30 | struct i2c_adapter *i2c_adap, |
| 31 | u8 i2c_addr) | 31 | u8 i2c_addr) |
| 32 | { | 32 | { |
| 33 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 33 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 34 | return NULL; | 34 | return NULL; |
| 35 | } | 35 | } |
| 36 | #endif | 36 | #endif |
diff --git a/drivers/media/video/tea5761.c b/drivers/media/video/tea5761.c index 5326eeceaacd..b93cdef9ac73 100644 --- a/drivers/media/video/tea5761.c +++ b/drivers/media/video/tea5761.c | |||
| @@ -14,12 +14,10 @@ | |||
| 14 | #include "tuner-i2c.h" | 14 | #include "tuner-i2c.h" |
| 15 | #include "tea5761.h" | 15 | #include "tea5761.h" |
| 16 | 16 | ||
| 17 | static int debug = 0; | 17 | static int debug; |
| 18 | module_param(debug, int, 0644); | 18 | module_param(debug, int, 0644); |
| 19 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 19 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 20 | 20 | ||
| 21 | #define PREFIX "tea5761" | ||
| 22 | |||
| 23 | struct tea5761_priv { | 21 | struct tea5761_priv { |
| 24 | struct tuner_i2c_props i2c_props; | 22 | struct tuner_i2c_props i2c_props; |
| 25 | 23 | ||
| @@ -131,7 +129,7 @@ static void tea5761_status_dump(unsigned char *buffer) | |||
| 131 | 129 | ||
| 132 | frq = 1000 * (div * 32768 / 1000 + FREQ_OFFSET + 225) / 4; /* Freq in KHz */ | 130 | frq = 1000 * (div * 32768 / 1000 + FREQ_OFFSET + 225) / 4; /* Freq in KHz */ |
| 133 | 131 | ||
| 134 | printk(PREFIX "Frequency %d.%03d KHz (divider = 0x%04x)\n", | 132 | printk(KERN_INFO "tea5761: Frequency %d.%03d KHz (divider = 0x%04x)\n", |
| 135 | frq / 1000, frq % 1000, div); | 133 | frq / 1000, frq % 1000, div); |
| 136 | } | 134 | } |
| 137 | 135 | ||
| @@ -249,14 +247,19 @@ int tea5761_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr) | |||
| 249 | 247 | ||
| 250 | if (16 != (rc = tuner_i2c_xfer_recv(&i2c, buffer, 16))) { | 248 | if (16 != (rc = tuner_i2c_xfer_recv(&i2c, buffer, 16))) { |
| 251 | printk(KERN_WARNING "it is not a TEA5761. Received %i chars.\n", rc); | 249 | printk(KERN_WARNING "it is not a TEA5761. Received %i chars.\n", rc); |
| 252 | return EINVAL; | 250 | return -EINVAL; |
| 253 | } | 251 | } |
| 254 | 252 | ||
| 255 | if (!((buffer[13] != 0x2b) || (buffer[14] != 0x57) || (buffer[15] != 0x061))) { | 253 | if ((buffer[13] != 0x2b) || (buffer[14] != 0x57) || (buffer[15] != 0x061)) { |
| 256 | printk(KERN_WARNING "Manufacturer ID= 0x%02x, Chip ID = %02x%02x. It is not a TEA5761\n",buffer[13],buffer[14],buffer[15]); | 254 | printk(KERN_WARNING "Manufacturer ID= 0x%02x, Chip ID = %02x%02x." |
| 257 | return EINVAL; | 255 | " It is not a TEA5761\n", |
| 256 | buffer[13], buffer[14], buffer[15]); | ||
| 257 | return -EINVAL; | ||
| 258 | } | 258 | } |
| 259 | printk(KERN_WARNING "TEA5761 detected.\n"); | 259 | printk(KERN_WARNING "tea5761: TEA%02x%02x detected. " |
| 260 | "Manufacturer ID= 0x%02x\n", | ||
| 261 | buffer[14], buffer[15], buffer[13]); | ||
| 262 | |||
| 260 | return 0; | 263 | return 0; |
| 261 | } | 264 | } |
| 262 | 265 | ||
| @@ -302,6 +305,7 @@ struct dvb_frontend *tea5761_attach(struct dvb_frontend *fe, | |||
| 302 | 305 | ||
| 303 | priv->i2c_props.addr = i2c_addr; | 306 | priv->i2c_props.addr = i2c_addr; |
| 304 | priv->i2c_props.adap = i2c_adap; | 307 | priv->i2c_props.adap = i2c_adap; |
| 308 | priv->i2c_props.name = "tea5761"; | ||
| 305 | 309 | ||
| 306 | memcpy(&fe->ops.tuner_ops, &tea5761_tuner_ops, | 310 | memcpy(&fe->ops.tuner_ops, &tea5761_tuner_ops, |
| 307 | sizeof(struct dvb_tuner_ops)); | 311 | sizeof(struct dvb_tuner_ops)); |
diff --git a/drivers/media/video/tea5761.h b/drivers/media/video/tea5761.h index 73a03b427843..8eb62722b988 100644 --- a/drivers/media/video/tea5761.h +++ b/drivers/media/video/tea5761.h | |||
| @@ -31,7 +31,7 @@ static inline int tea5761_autodetection(struct i2c_adapter* i2c_adap, | |||
| 31 | u8 i2c_addr) | 31 | u8 i2c_addr) |
| 32 | { | 32 | { |
| 33 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", | 33 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", |
| 34 | __FUNCTION__); | 34 | __func__); |
| 35 | return -EINVAL; | 35 | return -EINVAL; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| @@ -39,7 +39,7 @@ static inline struct dvb_frontend *tea5761_attach(struct dvb_frontend *fe, | |||
| 39 | struct i2c_adapter* i2c_adap, | 39 | struct i2c_adapter* i2c_adap, |
| 40 | u8 i2c_addr) | 40 | u8 i2c_addr) |
| 41 | { | 41 | { |
| 42 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 42 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 43 | return NULL; | 43 | return NULL; |
| 44 | } | 44 | } |
| 45 | #endif | 45 | #endif |
diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c index e1b48d87e7b7..f6e7d7ad8424 100644 --- a/drivers/media/video/tea5767.c +++ b/drivers/media/video/tea5767.c | |||
| @@ -16,12 +16,10 @@ | |||
| 16 | #include "tuner-i2c.h" | 16 | #include "tuner-i2c.h" |
| 17 | #include "tea5767.h" | 17 | #include "tea5767.h" |
| 18 | 18 | ||
| 19 | static int debug = 0; | 19 | static int debug; |
| 20 | module_param(debug, int, 0644); | 20 | module_param(debug, int, 0644); |
| 21 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 21 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 22 | 22 | ||
| 23 | #define PREFIX "tea5767" | ||
| 24 | |||
| 25 | /*****************************************************************************/ | 23 | /*****************************************************************************/ |
| 26 | 24 | ||
| 27 | struct tea5767_priv { | 25 | struct tea5767_priv { |
| @@ -137,14 +135,14 @@ static void tea5767_status_dump(struct tea5767_priv *priv, | |||
| 137 | unsigned int div, frq; | 135 | unsigned int div, frq; |
| 138 | 136 | ||
| 139 | if (TEA5767_READY_FLAG_MASK & buffer[0]) | 137 | if (TEA5767_READY_FLAG_MASK & buffer[0]) |
| 140 | printk(PREFIX "Ready Flag ON\n"); | 138 | tuner_info("Ready Flag ON\n"); |
| 141 | else | 139 | else |
| 142 | printk(PREFIX "Ready Flag OFF\n"); | 140 | tuner_info("Ready Flag OFF\n"); |
| 143 | 141 | ||
| 144 | if (TEA5767_BAND_LIMIT_MASK & buffer[0]) | 142 | if (TEA5767_BAND_LIMIT_MASK & buffer[0]) |
| 145 | printk(PREFIX "Tuner at band limit\n"); | 143 | tuner_info("Tuner at band limit\n"); |
| 146 | else | 144 | else |
| 147 | printk(PREFIX "Tuner not at band limit\n"); | 145 | tuner_info("Tuner not at band limit\n"); |
| 148 | 146 | ||
| 149 | div = ((buffer[0] & 0x3f) << 8) | buffer[1]; | 147 | div = ((buffer[0] & 0x3f) << 8) | buffer[1]; |
| 150 | 148 | ||
| @@ -166,23 +164,23 @@ static void tea5767_status_dump(struct tea5767_priv *priv, | |||
| 166 | buffer[0] = (div >> 8) & 0x3f; | 164 | buffer[0] = (div >> 8) & 0x3f; |
| 167 | buffer[1] = div & 0xff; | 165 | buffer[1] = div & 0xff; |
| 168 | 166 | ||
| 169 | printk(PREFIX "Frequency %d.%03d KHz (divider = 0x%04x)\n", | 167 | tuner_info("Frequency %d.%03d KHz (divider = 0x%04x)\n", |
| 170 | frq / 1000, frq % 1000, div); | 168 | frq / 1000, frq % 1000, div); |
| 171 | 169 | ||
| 172 | if (TEA5767_STEREO_MASK & buffer[2]) | 170 | if (TEA5767_STEREO_MASK & buffer[2]) |
| 173 | printk(PREFIX "Stereo\n"); | 171 | tuner_info("Stereo\n"); |
| 174 | else | 172 | else |
| 175 | printk(PREFIX "Mono\n"); | 173 | tuner_info("Mono\n"); |
| 176 | 174 | ||
| 177 | printk(PREFIX "IF Counter = %d\n", buffer[2] & TEA5767_IF_CNTR_MASK); | 175 | tuner_info("IF Counter = %d\n", buffer[2] & TEA5767_IF_CNTR_MASK); |
| 178 | 176 | ||
| 179 | printk(PREFIX "ADC Level = %d\n", | 177 | tuner_info("ADC Level = %d\n", |
| 180 | (buffer[3] & TEA5767_ADC_LEVEL_MASK) >> 4); | 178 | (buffer[3] & TEA5767_ADC_LEVEL_MASK) >> 4); |
| 181 | 179 | ||
| 182 | printk(PREFIX "Chip ID = %d\n", (buffer[3] & TEA5767_CHIP_ID_MASK)); | 180 | tuner_info("Chip ID = %d\n", (buffer[3] & TEA5767_CHIP_ID_MASK)); |
| 183 | 181 | ||
| 184 | printk(PREFIX "Reserved = 0x%02x\n", | 182 | tuner_info("Reserved = 0x%02x\n", |
| 185 | (buffer[4] & TEA5767_RESERVED_MASK)); | 183 | (buffer[4] & TEA5767_RESERVED_MASK)); |
| 186 | } | 184 | } |
| 187 | 185 | ||
| 188 | /* Freq should be specifyed at 62.5 Hz */ | 186 | /* Freq should be specifyed at 62.5 Hz */ |
| @@ -395,11 +393,6 @@ int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr) | |||
| 395 | return EINVAL; | 393 | return EINVAL; |
| 396 | } | 394 | } |
| 397 | 395 | ||
| 398 | /* It seems that tea5767 returns 0xff after the 5th byte */ | ||
| 399 | if ((buffer[5] != 0xff) || (buffer[6] != 0xff)) { | ||
| 400 | printk(KERN_WARNING "Returned more than 5 bytes. It is not a TEA5767\n"); | ||
| 401 | return EINVAL; | ||
| 402 | } | ||
| 403 | 396 | ||
| 404 | return 0; | 397 | return 0; |
| 405 | } | 398 | } |
| @@ -456,6 +449,8 @@ struct dvb_frontend *tea5767_attach(struct dvb_frontend *fe, | |||
| 456 | 449 | ||
| 457 | priv->i2c_props.addr = i2c_addr; | 450 | priv->i2c_props.addr = i2c_addr; |
| 458 | priv->i2c_props.adap = i2c_adap; | 451 | priv->i2c_props.adap = i2c_adap; |
| 452 | priv->i2c_props.name = "tea5767"; | ||
| 453 | |||
| 459 | priv->ctrl.xtal_freq = TEA5767_HIGH_LO_32768; | 454 | priv->ctrl.xtal_freq = TEA5767_HIGH_LO_32768; |
| 460 | priv->ctrl.port1 = 1; | 455 | priv->ctrl.port1 = 1; |
| 461 | priv->ctrl.port2 = 1; | 456 | priv->ctrl.port2 = 1; |
diff --git a/drivers/media/video/tea5767.h b/drivers/media/video/tea5767.h index a44451f61145..7b547c092e25 100644 --- a/drivers/media/video/tea5767.h +++ b/drivers/media/video/tea5767.h | |||
| @@ -50,7 +50,7 @@ static inline int tea5767_autodetection(struct i2c_adapter* i2c_adap, | |||
| 50 | u8 i2c_addr) | 50 | u8 i2c_addr) |
| 51 | { | 51 | { |
| 52 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", | 52 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", |
| 53 | __FUNCTION__); | 53 | __func__); |
| 54 | return -EINVAL; | 54 | return -EINVAL; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| @@ -58,7 +58,7 @@ static inline struct dvb_frontend *tea5767_attach(struct dvb_frontend *fe, | |||
| 58 | struct i2c_adapter* i2c_adap, | 58 | struct i2c_adapter* i2c_adap, |
| 59 | u8 i2c_addr) | 59 | u8 i2c_addr) |
| 60 | { | 60 | { |
| 61 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 61 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 62 | return NULL; | 62 | return NULL; |
| 63 | } | 63 | } |
| 64 | #endif | 64 | #endif |
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c index df2fad9f391e..9513d8611e87 100644 --- a/drivers/media/video/tea6415c.c +++ b/drivers/media/video/tea6415c.c | |||
| @@ -33,11 +33,11 @@ | |||
| 33 | 33 | ||
| 34 | #include "tea6415c.h" | 34 | #include "tea6415c.h" |
| 35 | 35 | ||
| 36 | static int debug = 0; /* insmod parameter */ | 36 | static int debug; /* insmod parameter */ |
| 37 | module_param(debug, int, 0644); | 37 | module_param(debug, int, 0644); |
| 38 | MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); | 38 | MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); |
| 39 | #define dprintk(args...) \ | 39 | #define dprintk(args...) \ |
| 40 | do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) | 40 | do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __func__, __LINE__); printk(args); } } while (0) |
| 41 | 41 | ||
| 42 | #define TEA6415C_NUM_INPUTS 8 | 42 | #define TEA6415C_NUM_INPUTS 8 |
| 43 | #define TEA6415C_NUM_OUTPUTS 6 | 43 | #define TEA6415C_NUM_OUTPUTS 6 |
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c index 4ff6c63f7237..7fd53367c07c 100644 --- a/drivers/media/video/tea6420.c +++ b/drivers/media/video/tea6420.c | |||
| @@ -33,11 +33,11 @@ | |||
| 33 | 33 | ||
| 34 | #include "tea6420.h" | 34 | #include "tea6420.h" |
| 35 | 35 | ||
| 36 | static int debug = 0; /* insmod parameter */ | 36 | static int debug; /* insmod parameter */ |
| 37 | module_param(debug, int, 0644); | 37 | module_param(debug, int, 0644); |
| 38 | MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); | 38 | MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); |
| 39 | #define dprintk(args...) \ | 39 | #define dprintk(args...) \ |
| 40 | do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0) | 40 | do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __func__, __LINE__); printk(args); } } while (0) |
| 41 | 41 | ||
| 42 | /* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ | 42 | /* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ |
| 43 | static unsigned short normal_i2c[] = { I2C_ADDR_TEA6420_1, I2C_ADDR_TEA6420_2, I2C_CLIENT_END }; | 43 | static unsigned short normal_i2c[] = { I2C_ADDR_TEA6420_1, I2C_ADDR_TEA6420_2, I2C_CLIENT_END }; |
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 78a09a2a4857..529e00952a8d 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
| @@ -68,9 +68,9 @@ static unsigned short normal_i2c[] = { | |||
| 68 | I2C_CLIENT_INSMOD; | 68 | I2C_CLIENT_INSMOD; |
| 69 | 69 | ||
| 70 | /* insmod options used at init time => read/only */ | 70 | /* insmod options used at init time => read/only */ |
| 71 | static unsigned int addr = 0; | 71 | static unsigned int addr; |
| 72 | static unsigned int no_autodetect = 0; | 72 | static unsigned int no_autodetect; |
| 73 | static unsigned int show_i2c = 0; | 73 | static unsigned int show_i2c; |
| 74 | 74 | ||
| 75 | /* insmod options used at runtime => read/write */ | 75 | /* insmod options used at runtime => read/write */ |
| 76 | static int tuner_debug; | 76 | static int tuner_debug; |
| @@ -313,24 +313,14 @@ static void tuner_i2c_address_check(struct tuner *t) | |||
| 313 | tuner_warn("output to v4l-dvb-maintainer@linuxtv.org\n"); | 313 | tuner_warn("output to v4l-dvb-maintainer@linuxtv.org\n"); |
| 314 | tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n"); | 314 | tuner_warn("Please use subject line: \"obsolete tuner i2c address.\"\n"); |
| 315 | tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\n", | 315 | tuner_warn("driver: %s, addr: 0x%02x, type: %d (%s)\n", |
| 316 | t->i2c->adapter->name, t->i2c->addr, t->type, | 316 | t->i2c->adapter->name, t->i2c->addr, t->type, t->i2c->name); |
| 317 | tuners[t->type].name); | ||
| 318 | tuner_warn("====================== WARNING! ======================\n"); | 317 | tuner_warn("====================== WARNING! ======================\n"); |
| 319 | } | 318 | } |
| 320 | 319 | ||
| 321 | static void attach_simple_tuner(struct tuner *t) | ||
| 322 | { | ||
| 323 | struct simple_tuner_config cfg = { | ||
| 324 | .type = t->type, | ||
| 325 | .tun = &tuners[t->type] | ||
| 326 | }; | ||
| 327 | simple_tuner_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg); | ||
| 328 | } | ||
| 329 | |||
| 330 | static void attach_tda829x(struct tuner *t) | 320 | static void attach_tda829x(struct tuner *t) |
| 331 | { | 321 | { |
| 332 | struct tda829x_config cfg = { | 322 | struct tda829x_config cfg = { |
| 333 | .lna_cfg = &t->config, | 323 | .lna_cfg = t->config, |
| 334 | .tuner_callback = t->tuner_callback, | 324 | .tuner_callback = t->tuner_callback, |
| 335 | }; | 325 | }; |
| 336 | tda829x_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg); | 326 | tda829x_attach(&t->fe, t->i2c->adapter, t->i2c->addr, &cfg); |
| @@ -352,11 +342,6 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
| 352 | return; | 342 | return; |
| 353 | } | 343 | } |
| 354 | 344 | ||
| 355 | if (type >= tuner_count) { | ||
| 356 | tuner_warn ("tuner 0x%02x: Tuner count greater than %d\n",c->addr,tuner_count); | ||
| 357 | return; | ||
| 358 | } | ||
| 359 | |||
| 360 | t->type = type; | 345 | t->type = type; |
| 361 | t->config = new_config; | 346 | t->config = new_config; |
| 362 | if (tuner_callback != NULL) { | 347 | if (tuner_callback != NULL) { |
| @@ -409,7 +394,12 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
| 409 | buffer[2] = 0x86; | 394 | buffer[2] = 0x86; |
| 410 | buffer[3] = 0x54; | 395 | buffer[3] = 0x54; |
| 411 | i2c_master_send(c, buffer, 4); | 396 | i2c_master_send(c, buffer, 4); |
| 412 | attach_simple_tuner(t); | 397 | if (simple_tuner_attach(&t->fe, t->i2c->adapter, t->i2c->addr, |
| 398 | t->type) == NULL) { | ||
| 399 | t->type = TUNER_ABSENT; | ||
| 400 | t->mode_mask = T_UNINITIALIZED; | ||
| 401 | return; | ||
| 402 | } | ||
| 413 | break; | 403 | break; |
| 414 | case TUNER_PHILIPS_TD1316: | 404 | case TUNER_PHILIPS_TD1316: |
| 415 | buffer[0] = 0x0b; | 405 | buffer[0] = 0x0b; |
| @@ -417,14 +407,18 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
| 417 | buffer[2] = 0x86; | 407 | buffer[2] = 0x86; |
| 418 | buffer[3] = 0xa4; | 408 | buffer[3] = 0xa4; |
| 419 | i2c_master_send(c,buffer,4); | 409 | i2c_master_send(c,buffer,4); |
| 420 | attach_simple_tuner(t); | 410 | if (simple_tuner_attach(&t->fe, t->i2c->adapter, |
| 411 | t->i2c->addr, t->type) == NULL) { | ||
| 412 | t->type = TUNER_ABSENT; | ||
| 413 | t->mode_mask = T_UNINITIALIZED; | ||
| 414 | return; | ||
| 415 | } | ||
| 421 | break; | 416 | break; |
| 422 | case TUNER_XC2028: | 417 | case TUNER_XC2028: |
| 423 | { | 418 | { |
| 424 | struct xc2028_config cfg = { | 419 | struct xc2028_config cfg = { |
| 425 | .i2c_adap = t->i2c->adapter, | 420 | .i2c_adap = t->i2c->adapter, |
| 426 | .i2c_addr = t->i2c->addr, | 421 | .i2c_addr = t->i2c->addr, |
| 427 | .video_dev = c->adapter->algo_data, | ||
| 428 | .callback = t->tuner_callback, | 422 | .callback = t->tuner_callback, |
| 429 | }; | 423 | }; |
| 430 | if (!xc2028_attach(&t->fe, &cfg)) { | 424 | if (!xc2028_attach(&t->fe, &cfg)) { |
| @@ -455,7 +449,12 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
| 455 | } | 449 | } |
| 456 | break; | 450 | break; |
| 457 | default: | 451 | default: |
| 458 | attach_simple_tuner(t); | 452 | if (simple_tuner_attach(&t->fe, t->i2c->adapter, |
| 453 | t->i2c->addr, t->type) == NULL) { | ||
| 454 | t->type = TUNER_ABSENT; | ||
| 455 | t->mode_mask = T_UNINITIALIZED; | ||
| 456 | return; | ||
| 457 | } | ||
| 459 | break; | 458 | break; |
| 460 | } | 459 | } |
| 461 | 460 | ||
| @@ -759,7 +758,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg) | |||
| 759 | if (analog_ops->standby) | 758 | if (analog_ops->standby) |
| 760 | analog_ops->standby(&t->fe); | 759 | analog_ops->standby(&t->fe); |
| 761 | break; | 760 | break; |
| 762 | #ifdef CONFIG_VIDEO_V4L1 | 761 | #ifdef CONFIG_VIDEO_ALLOW_V4L1 |
| 763 | case VIDIOCSAUDIO: | 762 | case VIDIOCSAUDIO: |
| 764 | if (check_mode(t, "VIDIOCSAUDIO") == EINVAL) | 763 | if (check_mode(t, "VIDIOCSAUDIO") == EINVAL) |
| 765 | return 0; | 764 | return 0; |
| @@ -1112,8 +1111,8 @@ static int tuner_probe(struct i2c_client *client) | |||
| 1112 | if (!no_autodetect) { | 1111 | if (!no_autodetect) { |
| 1113 | switch (client->addr) { | 1112 | switch (client->addr) { |
| 1114 | case 0x10: | 1113 | case 0x10: |
| 1115 | if (tea5761_autodetection(t->i2c->adapter, t->i2c->addr) | 1114 | if (tea5761_autodetection(t->i2c->adapter, |
| 1116 | != EINVAL) { | 1115 | t->i2c->addr) >= 0) { |
| 1117 | t->type = TUNER_TEA5761; | 1116 | t->type = TUNER_TEA5761; |
| 1118 | t->mode_mask = T_RADIO; | 1117 | t->mode_mask = T_RADIO; |
| 1119 | t->mode = T_STANDBY; | 1118 | t->mode = T_STANDBY; |
| @@ -1125,7 +1124,7 @@ static int tuner_probe(struct i2c_client *client) | |||
| 1125 | 1124 | ||
| 1126 | goto register_client; | 1125 | goto register_client; |
| 1127 | } | 1126 | } |
| 1128 | break; | 1127 | return -ENODEV; |
| 1129 | case 0x42: | 1128 | case 0x42: |
| 1130 | case 0x43: | 1129 | case 0x43: |
| 1131 | case 0x4a: | 1130 | case 0x4a: |
diff --git a/drivers/media/video/tuner-i2c.h b/drivers/media/video/tuner-i2c.h index de52e8ffd347..3ad6c8e0b04c 100644 --- a/drivers/media/video/tuner-i2c.h +++ b/drivers/media/video/tuner-i2c.h | |||
| @@ -26,6 +26,10 @@ | |||
| 26 | struct tuner_i2c_props { | 26 | struct tuner_i2c_props { |
| 27 | u8 addr; | 27 | u8 addr; |
| 28 | struct i2c_adapter *adap; | 28 | struct i2c_adapter *adap; |
| 29 | |||
| 30 | /* used for tuner instance management */ | ||
| 31 | int count; | ||
| 32 | char *name; | ||
| 29 | }; | 33 | }; |
| 30 | 34 | ||
| 31 | static inline int tuner_i2c_xfer_send(struct tuner_i2c_props *props, char *buf, int len) | 35 | static inline int tuner_i2c_xfer_send(struct tuner_i2c_props *props, char *buf, int len) |
| @@ -59,29 +63,111 @@ static inline int tuner_i2c_xfer_send_recv(struct tuner_i2c_props *props, | |||
| 59 | return (ret == 2) ? ilen : ret; | 63 | return (ret == 2) ? ilen : ret; |
| 60 | } | 64 | } |
| 61 | 65 | ||
| 62 | #define tuner_warn(fmt, arg...) do { \ | 66 | /* Callers must declare as a global for the module: |
| 63 | printk(KERN_WARNING "%s %d-%04x: " fmt, PREFIX, \ | 67 | * |
| 64 | i2c_adapter_id(priv->i2c_props.adap), \ | 68 | * static LIST_HEAD(hybrid_tuner_instance_list); |
| 65 | priv->i2c_props.addr, ##arg); \ | 69 | * |
| 70 | * hybrid_tuner_instance_list should be the third argument | ||
| 71 | * passed into hybrid_tuner_request_state(). | ||
| 72 | * | ||
| 73 | * state structure must contain the following: | ||
| 74 | * | ||
| 75 | * struct list_head hybrid_tuner_instance_list; | ||
| 76 | * struct tuner_i2c_props i2c_props; | ||
| 77 | * | ||
| 78 | * hybrid_tuner_instance_list (both within state structure and globally) | ||
| 79 | * is only required if the driver is using hybrid_tuner_request_state | ||
| 80 | * and hybrid_tuner_release_state to manage state sharing between | ||
| 81 | * multiple instances of hybrid tuners. | ||
| 82 | */ | ||
| 83 | |||
| 84 | #define tuner_printk(kernlvl, i2cprops, fmt, arg...) do { \ | ||
| 85 | printk(kernlvl "%s %d-%04x: " fmt, i2cprops.name, \ | ||
| 86 | i2cprops.adap ? \ | ||
| 87 | i2c_adapter_id(i2cprops.adap) : -1, \ | ||
| 88 | i2cprops.addr, ##arg); \ | ||
| 66 | } while (0) | 89 | } while (0) |
| 67 | 90 | ||
| 68 | #define tuner_info(fmt, arg...) do { \ | 91 | /* TO DO: convert all callers of these macros to pass in |
| 69 | printk(KERN_INFO "%s %d-%04x: " fmt, PREFIX, \ | 92 | * struct tuner_i2c_props, then remove the macro wrappers */ |
| 70 | i2c_adapter_id(priv->i2c_props.adap), \ | 93 | |
| 71 | priv->i2c_props.addr , ##arg); \ | 94 | #define __tuner_warn(i2cprops, fmt, arg...) do { \ |
| 95 | tuner_printk(KERN_WARNING, i2cprops, fmt, ##arg); \ | ||
| 72 | } while (0) | 96 | } while (0) |
| 73 | 97 | ||
| 74 | #define tuner_err(fmt, arg...) do { \ | 98 | #define __tuner_info(i2cprops, fmt, arg...) do { \ |
| 75 | printk(KERN_ERR "%s %d-%04x: " fmt, PREFIX, \ | 99 | tuner_printk(KERN_INFO, i2cprops, fmt, ##arg); \ |
| 76 | i2c_adapter_id(priv->i2c_props.adap), \ | ||
| 77 | priv->i2c_props.addr , ##arg); \ | ||
| 78 | } while (0) | 100 | } while (0) |
| 79 | 101 | ||
| 80 | #define tuner_dbg(fmt, arg...) do { \ | 102 | #define __tuner_err(i2cprops, fmt, arg...) do { \ |
| 103 | tuner_printk(KERN_ERR, i2cprops, fmt, ##arg); \ | ||
| 104 | } while (0) | ||
| 105 | |||
| 106 | #define __tuner_dbg(i2cprops, fmt, arg...) do { \ | ||
| 81 | if ((debug)) \ | 107 | if ((debug)) \ |
| 82 | printk(KERN_DEBUG "%s %d-%04x: " fmt, PREFIX, \ | 108 | tuner_printk(KERN_DEBUG, i2cprops, fmt, ##arg); \ |
| 83 | i2c_adapter_id(priv->i2c_props.adap), \ | ||
| 84 | priv->i2c_props.addr , ##arg); \ | ||
| 85 | } while (0) | 109 | } while (0) |
| 86 | 110 | ||
| 111 | #define tuner_warn(fmt, arg...) __tuner_warn(priv->i2c_props, fmt, ##arg) | ||
| 112 | #define tuner_info(fmt, arg...) __tuner_info(priv->i2c_props, fmt, ##arg) | ||
| 113 | #define tuner_err(fmt, arg...) __tuner_err(priv->i2c_props, fmt, ##arg) | ||
| 114 | #define tuner_dbg(fmt, arg...) __tuner_dbg(priv->i2c_props, fmt, ##arg) | ||
| 115 | |||
| 116 | /****************************************************************************/ | ||
| 117 | |||
| 118 | /* The return value of hybrid_tuner_request_state indicates the number of | ||
| 119 | * instances using this tuner object. | ||
| 120 | * | ||
| 121 | * 0 - no instances, indicates an error - kzalloc must have failed | ||
| 122 | * | ||
| 123 | * 1 - one instance, indicates that the tuner object was created successfully | ||
| 124 | * | ||
| 125 | * 2 (or more) instances, indicates that an existing tuner object was found | ||
| 126 | */ | ||
| 127 | |||
| 128 | #define hybrid_tuner_request_state(type, state, list, i2cadap, i2caddr, devname)\ | ||
| 129 | ({ \ | ||
| 130 | int __ret = 0; \ | ||
| 131 | list_for_each_entry(state, &list, hybrid_tuner_instance_list) { \ | ||
| 132 | if (((i2cadap) && (state->i2c_props.adap)) && \ | ||
| 133 | ((i2c_adapter_id(state->i2c_props.adap) == \ | ||
| 134 | i2c_adapter_id(i2cadap)) && \ | ||
| 135 | (i2caddr == state->i2c_props.addr))) { \ | ||
| 136 | __tuner_info(state->i2c_props, \ | ||
| 137 | "attaching existing instance\n"); \ | ||
| 138 | state->i2c_props.count++; \ | ||
| 139 | __ret = state->i2c_props.count; \ | ||
| 140 | break; \ | ||
| 141 | } \ | ||
| 142 | } \ | ||
| 143 | if (0 == __ret) { \ | ||
| 144 | state = kzalloc(sizeof(type), GFP_KERNEL); \ | ||
| 145 | if (NULL == state) \ | ||
| 146 | goto __fail; \ | ||
| 147 | state->i2c_props.addr = i2caddr; \ | ||
| 148 | state->i2c_props.adap = i2cadap; \ | ||
| 149 | state->i2c_props.name = devname; \ | ||
| 150 | __tuner_info(state->i2c_props, \ | ||
| 151 | "creating new instance\n"); \ | ||
| 152 | list_add_tail(&state->hybrid_tuner_instance_list, &list);\ | ||
| 153 | state->i2c_props.count++; \ | ||
| 154 | __ret = state->i2c_props.count; \ | ||
| 155 | } \ | ||
| 156 | __fail: \ | ||
| 157 | __ret; \ | ||
| 158 | }) | ||
| 159 | |||
| 160 | #define hybrid_tuner_release_state(state) \ | ||
| 161 | ({ \ | ||
| 162 | int __ret; \ | ||
| 163 | state->i2c_props.count--; \ | ||
| 164 | __ret = state->i2c_props.count; \ | ||
| 165 | if (!state->i2c_props.count) { \ | ||
| 166 | __tuner_info(state->i2c_props, "destroying instance\n");\ | ||
| 167 | list_del(&state->hybrid_tuner_instance_list); \ | ||
| 168 | kfree(state); \ | ||
| 169 | } \ | ||
| 170 | __ret; \ | ||
| 171 | }) | ||
| 172 | |||
| 87 | #endif /* __TUNER_I2C_H__ */ | 173 | #endif /* __TUNER_I2C_H__ */ |
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c index c1db576696c6..be8d903171b7 100644 --- a/drivers/media/video/tuner-simple.c +++ b/drivers/media/video/tuner-simple.c | |||
| @@ -13,15 +13,25 @@ | |||
| 13 | #include "tuner-i2c.h" | 13 | #include "tuner-i2c.h" |
| 14 | #include "tuner-simple.h" | 14 | #include "tuner-simple.h" |
| 15 | 15 | ||
| 16 | static int debug = 0; | 16 | static int debug; |
| 17 | module_param(debug, int, 0644); | 17 | module_param(debug, int, 0644); |
| 18 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 18 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| 19 | 19 | ||
| 20 | #define PREFIX "tuner-simple" | 20 | #define TUNER_SIMPLE_MAX 64 |
| 21 | static unsigned int simple_devcount; | ||
| 21 | 22 | ||
| 22 | static int offset = 0; | 23 | static int offset; |
| 23 | module_param(offset, int, 0664); | 24 | module_param(offset, int, 0664); |
| 24 | MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner"); | 25 | MODULE_PARM_DESC(offset, "Allows to specify an offset for tuner"); |
| 26 | |||
| 27 | static unsigned int atv_input[TUNER_SIMPLE_MAX] = \ | ||
| 28 | { [0 ... (TUNER_SIMPLE_MAX-1)] = 0 }; | ||
| 29 | static unsigned int dtv_input[TUNER_SIMPLE_MAX] = \ | ||
| 30 | { [0 ... (TUNER_SIMPLE_MAX-1)] = 0 }; | ||
| 31 | module_param_array(atv_input, int, NULL, 0644); | ||
| 32 | module_param_array(dtv_input, int, NULL, 0644); | ||
| 33 | MODULE_PARM_DESC(atv_input, "specify atv rf input, 0 for autoselect"); | ||
| 34 | MODULE_PARM_DESC(dtv_input, "specify dtv rf input, 0 for autoselect"); | ||
| 25 | 35 | ||
| 26 | /* ---------------------------------------------------------------------- */ | 36 | /* ---------------------------------------------------------------------- */ |
| 27 | 37 | ||
| @@ -36,8 +46,8 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner"); | |||
| 36 | */ | 46 | */ |
| 37 | #define TEMIC_SET_PAL_I 0x05 | 47 | #define TEMIC_SET_PAL_I 0x05 |
| 38 | #define TEMIC_SET_PAL_DK 0x09 | 48 | #define TEMIC_SET_PAL_DK 0x09 |
| 39 | #define TEMIC_SET_PAL_L 0x0a // SECAM ? | 49 | #define TEMIC_SET_PAL_L 0x0a /* SECAM ? */ |
| 40 | #define TEMIC_SET_PAL_L2 0x0b // change IF ! | 50 | #define TEMIC_SET_PAL_L2 0x0b /* change IF ! */ |
| 41 | #define TEMIC_SET_PAL_BG 0x0c | 51 | #define TEMIC_SET_PAL_BG 0x0c |
| 42 | 52 | ||
| 43 | /* tv tuner system standard selection for Philips FQ1216ME | 53 | /* tv tuner system standard selection for Philips FQ1216ME |
| @@ -90,14 +100,21 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner"); | |||
| 90 | #define TUNER_PLL_LOCKED 0x40 | 100 | #define TUNER_PLL_LOCKED 0x40 |
| 91 | #define TUNER_STEREO_MK3 0x04 | 101 | #define TUNER_STEREO_MK3 0x04 |
| 92 | 102 | ||
| 103 | static DEFINE_MUTEX(tuner_simple_list_mutex); | ||
| 104 | static LIST_HEAD(hybrid_tuner_instance_list); | ||
| 105 | |||
| 93 | struct tuner_simple_priv { | 106 | struct tuner_simple_priv { |
| 107 | unsigned int nr; | ||
| 94 | u16 last_div; | 108 | u16 last_div; |
| 109 | |||
| 95 | struct tuner_i2c_props i2c_props; | 110 | struct tuner_i2c_props i2c_props; |
| 111 | struct list_head hybrid_tuner_instance_list; | ||
| 96 | 112 | ||
| 97 | unsigned int type; | 113 | unsigned int type; |
| 98 | struct tunertype *tun; | 114 | struct tunertype *tun; |
| 99 | 115 | ||
| 100 | u32 frequency; | 116 | u32 frequency; |
| 117 | u32 bandwidth; | ||
| 101 | }; | 118 | }; |
| 102 | 119 | ||
| 103 | /* ---------------------------------------------------------------------- */ | 120 | /* ---------------------------------------------------------------------- */ |
| @@ -107,7 +124,7 @@ static int tuner_read_status(struct dvb_frontend *fe) | |||
| 107 | struct tuner_simple_priv *priv = fe->tuner_priv; | 124 | struct tuner_simple_priv *priv = fe->tuner_priv; |
| 108 | unsigned char byte; | 125 | unsigned char byte; |
| 109 | 126 | ||
| 110 | if (1 != tuner_i2c_xfer_recv(&priv->i2c_props,&byte,1)) | 127 | if (1 != tuner_i2c_xfer_recv(&priv->i2c_props, &byte, 1)) |
| 111 | return 0; | 128 | return 0; |
| 112 | 129 | ||
| 113 | return byte; | 130 | return byte; |
| @@ -121,13 +138,13 @@ static inline int tuner_signal(const int status) | |||
| 121 | static inline int tuner_stereo(const int type, const int status) | 138 | static inline int tuner_stereo(const int type, const int status) |
| 122 | { | 139 | { |
| 123 | switch (type) { | 140 | switch (type) { |
| 124 | case TUNER_PHILIPS_FM1216ME_MK3: | 141 | case TUNER_PHILIPS_FM1216ME_MK3: |
| 125 | case TUNER_PHILIPS_FM1236_MK3: | 142 | case TUNER_PHILIPS_FM1236_MK3: |
| 126 | case TUNER_PHILIPS_FM1256_IH3: | 143 | case TUNER_PHILIPS_FM1256_IH3: |
| 127 | case TUNER_LG_NTSC_TAPE: | 144 | case TUNER_LG_NTSC_TAPE: |
| 128 | return ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3); | 145 | return ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3); |
| 129 | default: | 146 | default: |
| 130 | return status & TUNER_STEREO; | 147 | return status & TUNER_STEREO; |
| 131 | } | 148 | } |
| 132 | } | 149 | } |
| 133 | 150 | ||
| @@ -145,7 +162,12 @@ static inline int tuner_afcstatus(const int status) | |||
| 145 | static int simple_get_status(struct dvb_frontend *fe, u32 *status) | 162 | static int simple_get_status(struct dvb_frontend *fe, u32 *status) |
| 146 | { | 163 | { |
| 147 | struct tuner_simple_priv *priv = fe->tuner_priv; | 164 | struct tuner_simple_priv *priv = fe->tuner_priv; |
| 148 | int tuner_status = tuner_read_status(fe); | 165 | int tuner_status; |
| 166 | |||
| 167 | if (priv->i2c_props.adap == NULL) | ||
| 168 | return -EINVAL; | ||
| 169 | |||
| 170 | tuner_status = tuner_read_status(fe); | ||
| 149 | 171 | ||
| 150 | *status = 0; | 172 | *status = 0; |
| 151 | 173 | ||
| @@ -162,7 +184,12 @@ static int simple_get_status(struct dvb_frontend *fe, u32 *status) | |||
| 162 | static int simple_get_rf_strength(struct dvb_frontend *fe, u16 *strength) | 184 | static int simple_get_rf_strength(struct dvb_frontend *fe, u16 *strength) |
| 163 | { | 185 | { |
| 164 | struct tuner_simple_priv *priv = fe->tuner_priv; | 186 | struct tuner_simple_priv *priv = fe->tuner_priv; |
| 165 | int signal = tuner_signal(tuner_read_status(fe)); | 187 | int signal; |
| 188 | |||
| 189 | if (priv->i2c_props.adap == NULL) | ||
| 190 | return -EINVAL; | ||
| 191 | |||
| 192 | signal = tuner_signal(tuner_read_status(fe)); | ||
| 166 | 193 | ||
| 167 | *strength = signal; | 194 | *strength = signal; |
| 168 | 195 | ||
| @@ -173,174 +200,378 @@ static int simple_get_rf_strength(struct dvb_frontend *fe, u16 *strength) | |||
| 173 | 200 | ||
| 174 | /* ---------------------------------------------------------------------- */ | 201 | /* ---------------------------------------------------------------------- */ |
| 175 | 202 | ||
| 176 | static int simple_set_tv_freq(struct dvb_frontend *fe, | 203 | static inline char *tuner_param_name(enum param_type type) |
| 177 | struct analog_parameters *params) | ||
| 178 | { | 204 | { |
| 179 | struct tuner_simple_priv *priv = fe->tuner_priv; | 205 | char *name; |
| 180 | u8 config, cb, tuneraddr; | ||
| 181 | u16 div; | ||
| 182 | struct tunertype *tun; | ||
| 183 | u8 buffer[4]; | ||
| 184 | int rc, IFPCoff, i, j; | ||
| 185 | enum param_type desired_type; | ||
| 186 | struct tuner_params *t_params; | ||
| 187 | 206 | ||
| 188 | tun = priv->tun; | 207 | switch (type) { |
| 208 | case TUNER_PARAM_TYPE_RADIO: | ||
| 209 | name = "radio"; | ||
| 210 | break; | ||
| 211 | case TUNER_PARAM_TYPE_PAL: | ||
| 212 | name = "pal"; | ||
| 213 | break; | ||
| 214 | case TUNER_PARAM_TYPE_SECAM: | ||
| 215 | name = "secam"; | ||
| 216 | break; | ||
| 217 | case TUNER_PARAM_TYPE_NTSC: | ||
| 218 | name = "ntsc"; | ||
| 219 | break; | ||
| 220 | case TUNER_PARAM_TYPE_DIGITAL: | ||
| 221 | name = "digital"; | ||
| 222 | break; | ||
| 223 | default: | ||
| 224 | name = "unknown"; | ||
| 225 | break; | ||
| 226 | } | ||
| 227 | return name; | ||
| 228 | } | ||
| 189 | 229 | ||
| 190 | /* IFPCoff = Video Intermediate Frequency - Vif: | 230 | static struct tuner_params *simple_tuner_params(struct dvb_frontend *fe, |
| 191 | 940 =16*58.75 NTSC/J (Japan) | 231 | enum param_type desired_type) |
| 192 | 732 =16*45.75 M/N STD | 232 | { |
| 193 | 704 =16*44 ATSC (at DVB code) | 233 | struct tuner_simple_priv *priv = fe->tuner_priv; |
| 194 | 632 =16*39.50 I U.K. | 234 | struct tunertype *tun = priv->tun; |
| 195 | 622.4=16*38.90 B/G D/K I, L STD | 235 | int i; |
| 196 | 592 =16*37.00 D China | ||
| 197 | 590 =16.36.875 B Australia | ||
| 198 | 543.2=16*33.95 L' STD | ||
| 199 | 171.2=16*10.70 FM Radio (at set_radio_freq) | ||
| 200 | */ | ||
| 201 | 236 | ||
| 202 | if (params->std == V4L2_STD_NTSC_M_JP) { | 237 | for (i = 0; i < tun->count; i++) |
| 203 | IFPCoff = 940; | 238 | if (desired_type == tun->params[i].type) |
| 204 | desired_type = TUNER_PARAM_TYPE_NTSC; | 239 | break; |
| 205 | } else if ((params->std & V4L2_STD_MN) && | ||
| 206 | !(params->std & ~V4L2_STD_MN)) { | ||
| 207 | IFPCoff = 732; | ||
| 208 | desired_type = TUNER_PARAM_TYPE_NTSC; | ||
| 209 | } else if (params->std == V4L2_STD_SECAM_LC) { | ||
| 210 | IFPCoff = 543; | ||
| 211 | desired_type = TUNER_PARAM_TYPE_SECAM; | ||
| 212 | } else { | ||
| 213 | IFPCoff = 623; | ||
| 214 | desired_type = TUNER_PARAM_TYPE_PAL; | ||
| 215 | } | ||
| 216 | 240 | ||
| 217 | for (j = 0; j < tun->count-1; j++) { | 241 | /* use default tuner params if desired_type not available */ |
| 218 | if (desired_type != tun->params[j].type) | 242 | if (i == tun->count) { |
| 219 | continue; | 243 | tuner_dbg("desired params (%s) undefined for tuner %d\n", |
| 220 | break; | 244 | tuner_param_name(desired_type), priv->type); |
| 221 | } | 245 | i = 0; |
| 222 | /* use default tuner_t_params if desired_type not available */ | ||
| 223 | if (desired_type != tun->params[j].type) { | ||
| 224 | tuner_dbg("IFPCoff = %d: tuner_t_params undefined for tuner %d\n", | ||
| 225 | IFPCoff, priv->type); | ||
| 226 | j = 0; | ||
| 227 | } | 246 | } |
| 228 | t_params = &tun->params[j]; | 247 | |
| 248 | tuner_dbg("using tuner params #%d (%s)\n", i, | ||
| 249 | tuner_param_name(tun->params[i].type)); | ||
| 250 | |||
| 251 | return &tun->params[i]; | ||
| 252 | } | ||
| 253 | |||
| 254 | static int simple_config_lookup(struct dvb_frontend *fe, | ||
| 255 | struct tuner_params *t_params, | ||
| 256 | int *frequency, u8 *config, u8 *cb) | ||
| 257 | { | ||
| 258 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 259 | int i; | ||
| 229 | 260 | ||
| 230 | for (i = 0; i < t_params->count; i++) { | 261 | for (i = 0; i < t_params->count; i++) { |
| 231 | if (params->frequency > t_params->ranges[i].limit) | 262 | if (*frequency > t_params->ranges[i].limit) |
| 232 | continue; | 263 | continue; |
| 233 | break; | 264 | break; |
| 234 | } | 265 | } |
| 235 | if (i == t_params->count) { | 266 | if (i == t_params->count) { |
| 236 | tuner_dbg("TV frequency out of range (%d > %d)", | 267 | tuner_dbg("frequency out of range (%d > %d)\n", |
| 237 | params->frequency, t_params->ranges[i - 1].limit); | 268 | *frequency, t_params->ranges[i - 1].limit); |
| 238 | params->frequency = t_params->ranges[--i].limit; | 269 | *frequency = t_params->ranges[--i].limit; |
| 239 | } | 270 | } |
| 240 | config = t_params->ranges[i].config; | 271 | *config = t_params->ranges[i].config; |
| 241 | cb = t_params->ranges[i].cb; | 272 | *cb = t_params->ranges[i].cb; |
| 242 | /* i == 0 -> VHF_LO | 273 | |
| 243 | * i == 1 -> VHF_HI | 274 | tuner_dbg("freq = %d.%02d (%d), range = %d, " |
| 244 | * i == 2 -> UHF */ | 275 | "config = 0x%02x, cb = 0x%02x\n", |
| 245 | tuner_dbg("tv: param %d, range %d\n",j,i); | 276 | *frequency / 16, *frequency % 16 * 100 / 16, *frequency, |
| 277 | i, *config, *cb); | ||
| 278 | |||
| 279 | return i; | ||
| 280 | } | ||
| 281 | |||
| 282 | /* ---------------------------------------------------------------------- */ | ||
| 283 | |||
| 284 | static void simple_set_rf_input(struct dvb_frontend *fe, | ||
| 285 | u8 *config, u8 *cb, unsigned int rf) | ||
| 286 | { | ||
| 287 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 246 | 288 | ||
| 247 | div=params->frequency + IFPCoff + offset; | 289 | switch (priv->type) { |
| 290 | case TUNER_PHILIPS_TUV1236D: | ||
| 291 | switch (rf) { | ||
| 292 | case 1: | ||
| 293 | *cb |= 0x08; | ||
| 294 | break; | ||
| 295 | default: | ||
| 296 | *cb &= ~0x08; | ||
| 297 | break; | ||
| 298 | } | ||
| 299 | break; | ||
| 300 | case TUNER_PHILIPS_FCV1236D: | ||
| 301 | switch (rf) { | ||
| 302 | case 1: | ||
| 303 | *cb |= 0x01; | ||
| 304 | break; | ||
| 305 | default: | ||
| 306 | *cb &= ~0x01; | ||
| 307 | break; | ||
| 308 | } | ||
| 309 | break; | ||
| 310 | default: | ||
| 311 | break; | ||
| 312 | } | ||
| 313 | } | ||
| 248 | 314 | ||
| 249 | tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, Offset=%d.%02d MHz, div=%0d\n", | 315 | static int simple_std_setup(struct dvb_frontend *fe, |
| 250 | params->frequency / 16, params->frequency % 16 * 100 / 16, | 316 | struct analog_parameters *params, |
| 251 | IFPCoff / 16, IFPCoff % 16 * 100 / 16, | 317 | u8 *config, u8 *cb) |
| 252 | offset / 16, offset % 16 * 100 / 16, | 318 | { |
| 253 | div); | 319 | struct tuner_simple_priv *priv = fe->tuner_priv; |
| 320 | u8 tuneraddr; | ||
| 321 | int rc; | ||
| 254 | 322 | ||
| 255 | /* tv norm specific stuff for multi-norm tuners */ | 323 | /* tv norm specific stuff for multi-norm tuners */ |
| 256 | switch (priv->type) { | 324 | switch (priv->type) { |
| 257 | case TUNER_PHILIPS_SECAM: // FI1216MF | 325 | case TUNER_PHILIPS_SECAM: /* FI1216MF */ |
| 258 | /* 0x01 -> ??? no change ??? */ | 326 | /* 0x01 -> ??? no change ??? */ |
| 259 | /* 0x02 -> PAL BDGHI / SECAM L */ | 327 | /* 0x02 -> PAL BDGHI / SECAM L */ |
| 260 | /* 0x04 -> ??? PAL others / SECAM others ??? */ | 328 | /* 0x04 -> ??? PAL others / SECAM others ??? */ |
| 261 | cb &= ~0x03; | 329 | *cb &= ~0x03; |
| 262 | if (params->std & V4L2_STD_SECAM_L) //also valid for V4L2_STD_SECAM | 330 | if (params->std & V4L2_STD_SECAM_L) |
| 263 | cb |= PHILIPS_MF_SET_STD_L; | 331 | /* also valid for V4L2_STD_SECAM */ |
| 332 | *cb |= PHILIPS_MF_SET_STD_L; | ||
| 264 | else if (params->std & V4L2_STD_SECAM_LC) | 333 | else if (params->std & V4L2_STD_SECAM_LC) |
| 265 | cb |= PHILIPS_MF_SET_STD_LC; | 334 | *cb |= PHILIPS_MF_SET_STD_LC; |
| 266 | else /* V4L2_STD_B|V4L2_STD_GH */ | 335 | else /* V4L2_STD_B|V4L2_STD_GH */ |
| 267 | cb |= PHILIPS_MF_SET_STD_BG; | 336 | *cb |= PHILIPS_MF_SET_STD_BG; |
| 268 | break; | 337 | break; |
| 269 | 338 | ||
| 270 | case TUNER_TEMIC_4046FM5: | 339 | case TUNER_TEMIC_4046FM5: |
| 271 | cb &= ~0x0f; | 340 | *cb &= ~0x0f; |
| 272 | 341 | ||
| 273 | if (params->std & V4L2_STD_PAL_BG) { | 342 | if (params->std & V4L2_STD_PAL_BG) { |
| 274 | cb |= TEMIC_SET_PAL_BG; | 343 | *cb |= TEMIC_SET_PAL_BG; |
| 275 | 344 | ||
| 276 | } else if (params->std & V4L2_STD_PAL_I) { | 345 | } else if (params->std & V4L2_STD_PAL_I) { |
| 277 | cb |= TEMIC_SET_PAL_I; | 346 | *cb |= TEMIC_SET_PAL_I; |
| 278 | 347 | ||
| 279 | } else if (params->std & V4L2_STD_PAL_DK) { | 348 | } else if (params->std & V4L2_STD_PAL_DK) { |
| 280 | cb |= TEMIC_SET_PAL_DK; | 349 | *cb |= TEMIC_SET_PAL_DK; |
| 281 | 350 | ||
| 282 | } else if (params->std & V4L2_STD_SECAM_L) { | 351 | } else if (params->std & V4L2_STD_SECAM_L) { |
| 283 | cb |= TEMIC_SET_PAL_L; | 352 | *cb |= TEMIC_SET_PAL_L; |
| 284 | 353 | ||
| 285 | } | 354 | } |
| 286 | break; | 355 | break; |
| 287 | 356 | ||
| 288 | case TUNER_PHILIPS_FQ1216ME: | 357 | case TUNER_PHILIPS_FQ1216ME: |
| 289 | cb &= ~0x0f; | 358 | *cb &= ~0x0f; |
| 290 | 359 | ||
| 291 | if (params->std & (V4L2_STD_PAL_BG|V4L2_STD_PAL_DK)) { | 360 | if (params->std & (V4L2_STD_PAL_BG|V4L2_STD_PAL_DK)) { |
| 292 | cb |= PHILIPS_SET_PAL_BGDK; | 361 | *cb |= PHILIPS_SET_PAL_BGDK; |
| 293 | 362 | ||
| 294 | } else if (params->std & V4L2_STD_PAL_I) { | 363 | } else if (params->std & V4L2_STD_PAL_I) { |
| 295 | cb |= PHILIPS_SET_PAL_I; | 364 | *cb |= PHILIPS_SET_PAL_I; |
| 296 | 365 | ||
| 297 | } else if (params->std & V4L2_STD_SECAM_L) { | 366 | } else if (params->std & V4L2_STD_SECAM_L) { |
| 298 | cb |= PHILIPS_SET_PAL_L; | 367 | *cb |= PHILIPS_SET_PAL_L; |
| 299 | 368 | ||
| 300 | } | 369 | } |
| 301 | break; | 370 | break; |
| 302 | 371 | ||
| 303 | case TUNER_PHILIPS_ATSC: | 372 | case TUNER_PHILIPS_FCV1236D: |
| 304 | /* 0x00 -> ATSC antenna input 1 */ | 373 | /* 0x00 -> ATSC antenna input 1 */ |
| 305 | /* 0x01 -> ATSC antenna input 2 */ | 374 | /* 0x01 -> ATSC antenna input 2 */ |
| 306 | /* 0x02 -> NTSC antenna input 1 */ | 375 | /* 0x02 -> NTSC antenna input 1 */ |
| 307 | /* 0x03 -> NTSC antenna input 2 */ | 376 | /* 0x03 -> NTSC antenna input 2 */ |
| 308 | cb &= ~0x03; | 377 | *cb &= ~0x03; |
| 309 | if (!(params->std & V4L2_STD_ATSC)) | 378 | if (!(params->std & V4L2_STD_ATSC)) |
| 310 | cb |= 2; | 379 | *cb |= 2; |
| 311 | /* FIXME: input */ | ||
| 312 | break; | 380 | break; |
| 313 | 381 | ||
| 314 | case TUNER_MICROTUNE_4042FI5: | 382 | case TUNER_MICROTUNE_4042FI5: |
| 315 | /* Set the charge pump for fast tuning */ | 383 | /* Set the charge pump for fast tuning */ |
| 316 | config |= TUNER_CHARGE_PUMP; | 384 | *config |= TUNER_CHARGE_PUMP; |
| 317 | break; | 385 | break; |
| 318 | 386 | ||
| 319 | case TUNER_PHILIPS_TUV1236D: | 387 | case TUNER_PHILIPS_TUV1236D: |
| 388 | { | ||
| 320 | /* 0x40 -> ATSC antenna input 1 */ | 389 | /* 0x40 -> ATSC antenna input 1 */ |
| 321 | /* 0x48 -> ATSC antenna input 2 */ | 390 | /* 0x48 -> ATSC antenna input 2 */ |
| 322 | /* 0x00 -> NTSC antenna input 1 */ | 391 | /* 0x00 -> NTSC antenna input 1 */ |
| 323 | /* 0x08 -> NTSC antenna input 2 */ | 392 | /* 0x08 -> NTSC antenna input 2 */ |
| 324 | buffer[0] = 0x14; | 393 | u8 buffer[4] = { 0x14, 0x00, 0x17, 0x00}; |
| 325 | buffer[1] = 0x00; | 394 | *cb &= ~0x40; |
| 326 | buffer[2] = 0x17; | ||
| 327 | buffer[3] = 0x00; | ||
| 328 | cb &= ~0x40; | ||
| 329 | if (params->std & V4L2_STD_ATSC) { | 395 | if (params->std & V4L2_STD_ATSC) { |
| 330 | cb |= 0x40; | 396 | *cb |= 0x40; |
| 331 | buffer[1] = 0x04; | 397 | buffer[1] = 0x04; |
| 332 | } | 398 | } |
| 333 | /* set to the correct mode (analog or digital) */ | 399 | /* set to the correct mode (analog or digital) */ |
| 334 | tuneraddr = priv->i2c_props.addr; | 400 | tuneraddr = priv->i2c_props.addr; |
| 335 | priv->i2c_props.addr = 0x0a; | 401 | priv->i2c_props.addr = 0x0a; |
| 336 | if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[0],2))) | 402 | rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[0], 2); |
| 337 | tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); | 403 | if (2 != rc) |
| 338 | if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[2],2))) | 404 | tuner_warn("i2c i/o error: rc == %d " |
| 339 | tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); | 405 | "(should be 2)\n", rc); |
| 406 | rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[2], 2); | ||
| 407 | if (2 != rc) | ||
| 408 | tuner_warn("i2c i/o error: rc == %d " | ||
| 409 | "(should be 2)\n", rc); | ||
| 340 | priv->i2c_props.addr = tuneraddr; | 410 | priv->i2c_props.addr = tuneraddr; |
| 341 | /* FIXME: input */ | ||
| 342 | break; | 411 | break; |
| 343 | } | 412 | } |
| 413 | } | ||
| 414 | if (atv_input[priv->nr]) | ||
| 415 | simple_set_rf_input(fe, config, cb, atv_input[priv->nr]); | ||
| 416 | |||
| 417 | return 0; | ||
| 418 | } | ||
| 419 | |||
| 420 | static int simple_post_tune(struct dvb_frontend *fe, u8 *buffer, | ||
| 421 | u16 div, u8 config, u8 cb) | ||
| 422 | { | ||
| 423 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 424 | int rc; | ||
| 425 | |||
| 426 | switch (priv->type) { | ||
| 427 | case TUNER_LG_TDVS_H06XF: | ||
| 428 | /* Set the Auxiliary Byte. */ | ||
| 429 | buffer[0] = buffer[2]; | ||
| 430 | buffer[0] &= ~0x20; | ||
| 431 | buffer[0] |= 0x18; | ||
| 432 | buffer[1] = 0x20; | ||
| 433 | tuner_dbg("tv 0x%02x 0x%02x\n", buffer[0], buffer[1]); | ||
| 434 | |||
| 435 | rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 2); | ||
| 436 | if (2 != rc) | ||
| 437 | tuner_warn("i2c i/o error: rc == %d " | ||
| 438 | "(should be 2)\n", rc); | ||
| 439 | break; | ||
| 440 | case TUNER_MICROTUNE_4042FI5: | ||
| 441 | { | ||
| 442 | /* FIXME - this may also work for other tuners */ | ||
| 443 | unsigned long timeout = jiffies + msecs_to_jiffies(1); | ||
| 444 | u8 status_byte = 0; | ||
| 445 | |||
| 446 | /* Wait until the PLL locks */ | ||
| 447 | for (;;) { | ||
| 448 | if (time_after(jiffies, timeout)) | ||
| 449 | return 0; | ||
| 450 | rc = tuner_i2c_xfer_recv(&priv->i2c_props, | ||
| 451 | &status_byte, 1); | ||
| 452 | if (1 != rc) { | ||
| 453 | tuner_warn("i2c i/o read error: rc == %d " | ||
| 454 | "(should be 1)\n", rc); | ||
| 455 | break; | ||
| 456 | } | ||
| 457 | if (status_byte & TUNER_PLL_LOCKED) | ||
| 458 | break; | ||
| 459 | udelay(10); | ||
| 460 | } | ||
| 461 | |||
| 462 | /* Set the charge pump for optimized phase noise figure */ | ||
| 463 | config &= ~TUNER_CHARGE_PUMP; | ||
| 464 | buffer[0] = (div>>8) & 0x7f; | ||
| 465 | buffer[1] = div & 0xff; | ||
| 466 | buffer[2] = config; | ||
| 467 | buffer[3] = cb; | ||
| 468 | tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", | ||
| 469 | buffer[0], buffer[1], buffer[2], buffer[3]); | ||
| 470 | |||
| 471 | rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4); | ||
| 472 | if (4 != rc) | ||
| 473 | tuner_warn("i2c i/o error: rc == %d " | ||
| 474 | "(should be 4)\n", rc); | ||
| 475 | break; | ||
| 476 | } | ||
| 477 | } | ||
| 478 | |||
| 479 | return 0; | ||
| 480 | } | ||
| 481 | |||
| 482 | static int simple_radio_bandswitch(struct dvb_frontend *fe, u8 *buffer) | ||
| 483 | { | ||
| 484 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 485 | |||
| 486 | switch (priv->type) { | ||
| 487 | case TUNER_TENA_9533_DI: | ||
| 488 | case TUNER_YMEC_TVF_5533MF: | ||
| 489 | tuner_dbg("This tuner doesn't have FM. " | ||
| 490 | "Most cards have a TEA5767 for FM\n"); | ||
| 491 | return 0; | ||
| 492 | case TUNER_PHILIPS_FM1216ME_MK3: | ||
| 493 | case TUNER_PHILIPS_FM1236_MK3: | ||
| 494 | case TUNER_PHILIPS_FMD1216ME_MK3: | ||
| 495 | case TUNER_LG_NTSC_TAPE: | ||
| 496 | case TUNER_PHILIPS_FM1256_IH3: | ||
| 497 | buffer[3] = 0x19; | ||
| 498 | break; | ||
| 499 | case TUNER_TNF_5335MF: | ||
| 500 | buffer[3] = 0x11; | ||
| 501 | break; | ||
| 502 | case TUNER_LG_PAL_FM: | ||
| 503 | buffer[3] = 0xa5; | ||
| 504 | break; | ||
| 505 | case TUNER_THOMSON_DTT761X: | ||
| 506 | buffer[3] = 0x39; | ||
| 507 | break; | ||
| 508 | case TUNER_MICROTUNE_4049FM5: | ||
| 509 | default: | ||
| 510 | buffer[3] = 0xa4; | ||
| 511 | break; | ||
| 512 | } | ||
| 513 | |||
| 514 | return 0; | ||
| 515 | } | ||
| 516 | |||
| 517 | /* ---------------------------------------------------------------------- */ | ||
| 518 | |||
| 519 | static int simple_set_tv_freq(struct dvb_frontend *fe, | ||
| 520 | struct analog_parameters *params) | ||
| 521 | { | ||
| 522 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 523 | u8 config, cb; | ||
| 524 | u16 div; | ||
| 525 | struct tunertype *tun; | ||
| 526 | u8 buffer[4]; | ||
| 527 | int rc, IFPCoff, i; | ||
| 528 | enum param_type desired_type; | ||
| 529 | struct tuner_params *t_params; | ||
| 530 | |||
| 531 | tun = priv->tun; | ||
| 532 | |||
| 533 | /* IFPCoff = Video Intermediate Frequency - Vif: | ||
| 534 | 940 =16*58.75 NTSC/J (Japan) | ||
| 535 | 732 =16*45.75 M/N STD | ||
| 536 | 704 =16*44 ATSC (at DVB code) | ||
| 537 | 632 =16*39.50 I U.K. | ||
| 538 | 622.4=16*38.90 B/G D/K I, L STD | ||
| 539 | 592 =16*37.00 D China | ||
| 540 | 590 =16.36.875 B Australia | ||
| 541 | 543.2=16*33.95 L' STD | ||
| 542 | 171.2=16*10.70 FM Radio (at set_radio_freq) | ||
| 543 | */ | ||
| 544 | |||
| 545 | if (params->std == V4L2_STD_NTSC_M_JP) { | ||
| 546 | IFPCoff = 940; | ||
| 547 | desired_type = TUNER_PARAM_TYPE_NTSC; | ||
| 548 | } else if ((params->std & V4L2_STD_MN) && | ||
| 549 | !(params->std & ~V4L2_STD_MN)) { | ||
| 550 | IFPCoff = 732; | ||
| 551 | desired_type = TUNER_PARAM_TYPE_NTSC; | ||
| 552 | } else if (params->std == V4L2_STD_SECAM_LC) { | ||
| 553 | IFPCoff = 543; | ||
| 554 | desired_type = TUNER_PARAM_TYPE_SECAM; | ||
| 555 | } else { | ||
| 556 | IFPCoff = 623; | ||
| 557 | desired_type = TUNER_PARAM_TYPE_PAL; | ||
| 558 | } | ||
| 559 | |||
| 560 | t_params = simple_tuner_params(fe, desired_type); | ||
| 561 | |||
| 562 | i = simple_config_lookup(fe, t_params, ¶ms->frequency, | ||
| 563 | &config, &cb); | ||
| 564 | |||
| 565 | div = params->frequency + IFPCoff + offset; | ||
| 566 | |||
| 567 | tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, " | ||
| 568 | "Offset=%d.%02d MHz, div=%0d\n", | ||
| 569 | params->frequency / 16, params->frequency % 16 * 100 / 16, | ||
| 570 | IFPCoff / 16, IFPCoff % 16 * 100 / 16, | ||
| 571 | offset / 16, offset % 16 * 100 / 16, div); | ||
| 572 | |||
| 573 | /* tv norm specific stuff for multi-norm tuners */ | ||
| 574 | simple_std_setup(fe, params, &config, &cb); | ||
| 344 | 575 | ||
| 345 | if (t_params->cb_first_if_lower_freq && div < priv->last_div) { | 576 | if (t_params->cb_first_if_lower_freq && div < priv->last_div) { |
| 346 | buffer[0] = config; | 577 | buffer[0] = config; |
| @@ -357,8 +588,10 @@ static int simple_set_tv_freq(struct dvb_frontend *fe, | |||
| 357 | if (t_params->has_tda9887) { | 588 | if (t_params->has_tda9887) { |
| 358 | struct v4l2_priv_tun_config tda9887_cfg; | 589 | struct v4l2_priv_tun_config tda9887_cfg; |
| 359 | int config = 0; | 590 | int config = 0; |
| 360 | int is_secam_l = (params->std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) && | 591 | int is_secam_l = (params->std & (V4L2_STD_SECAM_L | |
| 361 | !(params->std & ~(V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)); | 592 | V4L2_STD_SECAM_LC)) && |
| 593 | !(params->std & ~(V4L2_STD_SECAM_L | | ||
| 594 | V4L2_STD_SECAM_LC)); | ||
| 362 | 595 | ||
| 363 | tda9887_cfg.tuner = TUNER_TDA9887; | 596 | tda9887_cfg.tuner = TUNER_TDA9887; |
| 364 | tda9887_cfg.priv = &config; | 597 | tda9887_cfg.priv = &config; |
| @@ -368,8 +601,7 @@ static int simple_set_tv_freq(struct dvb_frontend *fe, | |||
| 368 | config |= TDA9887_PORT1_ACTIVE; | 601 | config |= TDA9887_PORT1_ACTIVE; |
| 369 | if (t_params->port2_active ^ t_params->port2_invert_for_secam_lc) | 602 | if (t_params->port2_active ^ t_params->port2_invert_for_secam_lc) |
| 370 | config |= TDA9887_PORT2_ACTIVE; | 603 | config |= TDA9887_PORT2_ACTIVE; |
| 371 | } | 604 | } else { |
| 372 | else { | ||
| 373 | if (t_params->port1_active) | 605 | if (t_params->port1_active) |
| 374 | config |= TDA9887_PORT1_ACTIVE; | 606 | config |= TDA9887_PORT1_ACTIVE; |
| 375 | if (t_params->port2_active) | 607 | if (t_params->port2_active) |
| @@ -384,8 +616,7 @@ static int simple_set_tv_freq(struct dvb_frontend *fe, | |||
| 384 | config |= TDA9887_TOP(t_params->default_top_secam_mid); | 616 | config |= TDA9887_TOP(t_params->default_top_secam_mid); |
| 385 | else if (t_params->default_top_secam_high) | 617 | else if (t_params->default_top_secam_high) |
| 386 | config |= TDA9887_TOP(t_params->default_top_secam_high); | 618 | config |= TDA9887_TOP(t_params->default_top_secam_high); |
| 387 | } | 619 | } else { |
| 388 | else { | ||
| 389 | if (i == 0 && t_params->default_top_low) | 620 | if (i == 0 && t_params->default_top_low) |
| 390 | config |= TDA9887_TOP(t_params->default_top_low); | 621 | config |= TDA9887_TOP(t_params->default_top_low); |
| 391 | else if (i == 1 && t_params->default_top_mid) | 622 | else if (i == 1 && t_params->default_top_mid) |
| @@ -399,56 +630,14 @@ static int simple_set_tv_freq(struct dvb_frontend *fe, | |||
| 399 | &tda9887_cfg); | 630 | &tda9887_cfg); |
| 400 | } | 631 | } |
| 401 | tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", | 632 | tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", |
| 402 | buffer[0],buffer[1],buffer[2],buffer[3]); | 633 | buffer[0], buffer[1], buffer[2], buffer[3]); |
| 403 | |||
| 404 | if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4))) | ||
| 405 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); | ||
| 406 | |||
| 407 | switch (priv->type) { | ||
| 408 | case TUNER_LG_TDVS_H06XF: | ||
| 409 | /* Set the Auxiliary Byte. */ | ||
| 410 | buffer[0] = buffer[2]; | ||
| 411 | buffer[0] &= ~0x20; | ||
| 412 | buffer[0] |= 0x18; | ||
| 413 | buffer[1] = 0x20; | ||
| 414 | tuner_dbg("tv 0x%02x 0x%02x\n",buffer[0],buffer[1]); | ||
| 415 | |||
| 416 | if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,2))) | ||
| 417 | tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); | ||
| 418 | break; | ||
| 419 | case TUNER_MICROTUNE_4042FI5: | ||
| 420 | { | ||
| 421 | // FIXME - this may also work for other tuners | ||
| 422 | unsigned long timeout = jiffies + msecs_to_jiffies(1); | ||
| 423 | u8 status_byte = 0; | ||
| 424 | 634 | ||
| 425 | /* Wait until the PLL locks */ | 635 | rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4); |
| 426 | for (;;) { | 636 | if (4 != rc) |
| 427 | if (time_after(jiffies,timeout)) | 637 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc); |
| 428 | return 0; | ||
| 429 | if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,&status_byte,1))) { | ||
| 430 | tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc); | ||
| 431 | break; | ||
| 432 | } | ||
| 433 | if (status_byte & TUNER_PLL_LOCKED) | ||
| 434 | break; | ||
| 435 | udelay(10); | ||
| 436 | } | ||
| 437 | 638 | ||
| 438 | /* Set the charge pump for optimized phase noise figure */ | 639 | simple_post_tune(fe, &buffer[0], div, config, cb); |
| 439 | config &= ~TUNER_CHARGE_PUMP; | ||
| 440 | buffer[0] = (div>>8) & 0x7f; | ||
| 441 | buffer[1] = div & 0xff; | ||
| 442 | buffer[2] = config; | ||
| 443 | buffer[3] = cb; | ||
| 444 | tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", | ||
| 445 | buffer[0],buffer[1],buffer[2],buffer[3]); | ||
| 446 | 640 | ||
| 447 | if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4))) | ||
| 448 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); | ||
| 449 | break; | ||
| 450 | } | ||
| 451 | } | ||
| 452 | return 0; | 641 | return 0; |
| 453 | } | 642 | } |
| 454 | 643 | ||
| @@ -483,37 +672,13 @@ static int simple_set_radio_freq(struct dvb_frontend *fe, | |||
| 483 | freq += (unsigned int)(41.3*16000); | 672 | freq += (unsigned int)(41.3*16000); |
| 484 | break; | 673 | break; |
| 485 | default: | 674 | default: |
| 486 | tuner_warn("Unsupported radio_if value %d\n", t_params->radio_if); | 675 | tuner_warn("Unsupported radio_if value %d\n", |
| 676 | t_params->radio_if); | ||
| 487 | return 0; | 677 | return 0; |
| 488 | } | 678 | } |
| 489 | 679 | ||
| 490 | /* Bandswitch byte */ | 680 | /* Bandswitch byte */ |
| 491 | switch (priv->type) { | 681 | simple_radio_bandswitch(fe, &buffer[0]); |
| 492 | case TUNER_TENA_9533_DI: | ||
| 493 | case TUNER_YMEC_TVF_5533MF: | ||
| 494 | tuner_dbg("This tuner doesn't have FM. Most cards have a TEA5767 for FM\n"); | ||
| 495 | return 0; | ||
| 496 | case TUNER_PHILIPS_FM1216ME_MK3: | ||
| 497 | case TUNER_PHILIPS_FM1236_MK3: | ||
| 498 | case TUNER_PHILIPS_FMD1216ME_MK3: | ||
| 499 | case TUNER_LG_NTSC_TAPE: | ||
| 500 | case TUNER_PHILIPS_FM1256_IH3: | ||
| 501 | buffer[3] = 0x19; | ||
| 502 | break; | ||
| 503 | case TUNER_TNF_5335MF: | ||
| 504 | buffer[3] = 0x11; | ||
| 505 | break; | ||
| 506 | case TUNER_LG_PAL_FM: | ||
| 507 | buffer[3] = 0xa5; | ||
| 508 | break; | ||
| 509 | case TUNER_THOMSON_DTT761X: | ||
| 510 | buffer[3] = 0x39; | ||
| 511 | break; | ||
| 512 | case TUNER_MICROTUNE_4049FM5: | ||
| 513 | default: | ||
| 514 | buffer[3] = 0xa4; | ||
| 515 | break; | ||
| 516 | } | ||
| 517 | 682 | ||
| 518 | buffer[2] = (t_params->ranges[0].config & ~TUNER_RATIO_MASK) | | 683 | buffer[2] = (t_params->ranges[0].config & ~TUNER_RATIO_MASK) | |
| 519 | TUNER_RATIO_SELECT_50; /* 50 kHz step */ | 684 | TUNER_RATIO_SELECT_50; /* 50 kHz step */ |
| @@ -534,7 +699,7 @@ static int simple_set_radio_freq(struct dvb_frontend *fe, | |||
| 534 | } | 699 | } |
| 535 | 700 | ||
| 536 | tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n", | 701 | tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n", |
| 537 | buffer[0],buffer[1],buffer[2],buffer[3]); | 702 | buffer[0], buffer[1], buffer[2], buffer[3]); |
| 538 | priv->last_div = div; | 703 | priv->last_div = div; |
| 539 | 704 | ||
| 540 | if (t_params->has_tda9887) { | 705 | if (t_params->has_tda9887) { |
| @@ -544,9 +709,11 @@ static int simple_set_radio_freq(struct dvb_frontend *fe, | |||
| 544 | tda9887_cfg.tuner = TUNER_TDA9887; | 709 | tda9887_cfg.tuner = TUNER_TDA9887; |
| 545 | tda9887_cfg.priv = &config; | 710 | tda9887_cfg.priv = &config; |
| 546 | 711 | ||
| 547 | if (t_params->port1_active && !t_params->port1_fm_high_sensitivity) | 712 | if (t_params->port1_active && |
| 713 | !t_params->port1_fm_high_sensitivity) | ||
| 548 | config |= TDA9887_PORT1_ACTIVE; | 714 | config |= TDA9887_PORT1_ACTIVE; |
| 549 | if (t_params->port2_active && !t_params->port2_fm_high_sensitivity) | 715 | if (t_params->port2_active && |
| 716 | !t_params->port2_fm_high_sensitivity) | ||
| 550 | config |= TDA9887_PORT2_ACTIVE; | 717 | config |= TDA9887_PORT2_ACTIVE; |
| 551 | if (t_params->intercarrier_mode) | 718 | if (t_params->intercarrier_mode) |
| 552 | config |= TDA9887_INTERCARRIER; | 719 | config |= TDA9887_INTERCARRIER; |
| @@ -557,10 +724,11 @@ static int simple_set_radio_freq(struct dvb_frontend *fe, | |||
| 557 | if (t_params->radio_if == 2) | 724 | if (t_params->radio_if == 2) |
| 558 | config |= TDA9887_RIF_41_3; | 725 | config |= TDA9887_RIF_41_3; |
| 559 | i2c_clients_command(priv->i2c_props.adap, TUNER_SET_CONFIG, | 726 | i2c_clients_command(priv->i2c_props.adap, TUNER_SET_CONFIG, |
| 560 | &tda9887_cfg); | 727 | &tda9887_cfg); |
| 561 | } | 728 | } |
| 562 | if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4))) | 729 | rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4); |
| 563 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); | 730 | if (4 != rc) |
| 731 | tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc); | ||
| 564 | 732 | ||
| 565 | return 0; | 733 | return 0; |
| 566 | } | 734 | } |
| @@ -571,6 +739,9 @@ static int simple_set_params(struct dvb_frontend *fe, | |||
| 571 | struct tuner_simple_priv *priv = fe->tuner_priv; | 739 | struct tuner_simple_priv *priv = fe->tuner_priv; |
| 572 | int ret = -EINVAL; | 740 | int ret = -EINVAL; |
| 573 | 741 | ||
| 742 | if (priv->i2c_props.adap == NULL) | ||
| 743 | return -EINVAL; | ||
| 744 | |||
| 574 | switch (params->mode) { | 745 | switch (params->mode) { |
| 575 | case V4L2_TUNER_RADIO: | 746 | case V4L2_TUNER_RADIO: |
| 576 | ret = simple_set_radio_freq(fe, params); | 747 | ret = simple_set_radio_freq(fe, params); |
| @@ -582,14 +753,210 @@ static int simple_set_params(struct dvb_frontend *fe, | |||
| 582 | priv->frequency = params->frequency * 62500; | 753 | priv->frequency = params->frequency * 62500; |
| 583 | break; | 754 | break; |
| 584 | } | 755 | } |
| 756 | priv->bandwidth = 0; | ||
| 585 | 757 | ||
| 586 | return ret; | 758 | return ret; |
| 587 | } | 759 | } |
| 588 | 760 | ||
| 761 | static void simple_set_dvb(struct dvb_frontend *fe, u8 *buf, | ||
| 762 | const struct dvb_frontend_parameters *params) | ||
| 763 | { | ||
| 764 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 765 | |||
| 766 | switch (priv->type) { | ||
| 767 | case TUNER_PHILIPS_FMD1216ME_MK3: | ||
| 768 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ && | ||
| 769 | params->frequency >= 158870000) | ||
| 770 | buf[3] |= 0x08; | ||
| 771 | break; | ||
| 772 | case TUNER_PHILIPS_TD1316: | ||
| 773 | /* determine band */ | ||
| 774 | buf[3] |= (params->frequency < 161000000) ? 1 : | ||
| 775 | (params->frequency < 444000000) ? 2 : 4; | ||
| 776 | |||
| 777 | /* setup PLL filter */ | ||
| 778 | if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) | ||
| 779 | buf[3] |= 1 << 3; | ||
| 780 | break; | ||
| 781 | case TUNER_PHILIPS_TUV1236D: | ||
| 782 | case TUNER_PHILIPS_FCV1236D: | ||
| 783 | { | ||
| 784 | unsigned int new_rf; | ||
| 785 | |||
| 786 | if (dtv_input[priv->nr]) | ||
| 787 | new_rf = dtv_input[priv->nr]; | ||
| 788 | else | ||
| 789 | switch (params->u.vsb.modulation) { | ||
| 790 | case QAM_64: | ||
| 791 | case QAM_256: | ||
| 792 | new_rf = 1; | ||
| 793 | break; | ||
| 794 | case VSB_8: | ||
| 795 | default: | ||
| 796 | new_rf = 0; | ||
| 797 | break; | ||
| 798 | } | ||
| 799 | simple_set_rf_input(fe, &buf[2], &buf[3], new_rf); | ||
| 800 | break; | ||
| 801 | } | ||
| 802 | default: | ||
| 803 | break; | ||
| 804 | } | ||
| 805 | } | ||
| 806 | |||
| 807 | static u32 simple_dvb_configure(struct dvb_frontend *fe, u8 *buf, | ||
| 808 | const struct dvb_frontend_parameters *params) | ||
| 809 | { | ||
| 810 | /* This function returns the tuned frequency on success, 0 on error */ | ||
| 811 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 812 | struct tunertype *tun = priv->tun; | ||
| 813 | static struct tuner_params *t_params; | ||
| 814 | u8 config, cb; | ||
| 815 | u32 div; | ||
| 816 | int ret, frequency = params->frequency / 62500; | ||
| 817 | |||
| 818 | t_params = simple_tuner_params(fe, TUNER_PARAM_TYPE_DIGITAL); | ||
| 819 | ret = simple_config_lookup(fe, t_params, &frequency, &config, &cb); | ||
| 820 | if (ret < 0) | ||
| 821 | return 0; /* failure */ | ||
| 822 | |||
| 823 | div = ((frequency + t_params->iffreq) * 62500 + offset + | ||
| 824 | tun->stepsize/2) / tun->stepsize; | ||
| 825 | |||
| 826 | buf[0] = div >> 8; | ||
| 827 | buf[1] = div & 0xff; | ||
| 828 | buf[2] = config; | ||
| 829 | buf[3] = cb; | ||
| 830 | |||
| 831 | simple_set_dvb(fe, buf, params); | ||
| 832 | |||
| 833 | tuner_dbg("%s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n", | ||
| 834 | tun->name, div, buf[0], buf[1], buf[2], buf[3]); | ||
| 835 | |||
| 836 | /* calculate the frequency we set it to */ | ||
| 837 | return (div * tun->stepsize) - t_params->iffreq; | ||
| 838 | } | ||
| 839 | |||
| 840 | static int simple_dvb_calc_regs(struct dvb_frontend *fe, | ||
| 841 | struct dvb_frontend_parameters *params, | ||
| 842 | u8 *buf, int buf_len) | ||
| 843 | { | ||
| 844 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 845 | u32 frequency; | ||
| 846 | |||
| 847 | if (buf_len < 5) | ||
| 848 | return -EINVAL; | ||
| 849 | |||
| 850 | frequency = simple_dvb_configure(fe, buf+1, params); | ||
| 851 | if (frequency == 0) | ||
| 852 | return -EINVAL; | ||
| 853 | |||
| 854 | buf[0] = priv->i2c_props.addr; | ||
| 855 | |||
| 856 | priv->frequency = frequency; | ||
| 857 | priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? | ||
| 858 | params->u.ofdm.bandwidth : 0; | ||
| 859 | |||
| 860 | return 5; | ||
| 861 | } | ||
| 862 | |||
| 863 | static int simple_dvb_set_params(struct dvb_frontend *fe, | ||
| 864 | struct dvb_frontend_parameters *params) | ||
| 865 | { | ||
| 866 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 867 | u32 prev_freq, prev_bw; | ||
| 868 | int ret; | ||
| 869 | u8 buf[5]; | ||
| 870 | |||
| 871 | if (priv->i2c_props.adap == NULL) | ||
| 872 | return -EINVAL; | ||
| 873 | |||
| 874 | prev_freq = priv->frequency; | ||
| 875 | prev_bw = priv->bandwidth; | ||
| 876 | |||
| 877 | ret = simple_dvb_calc_regs(fe, params, buf, 5); | ||
| 878 | if (ret != 5) | ||
| 879 | goto fail; | ||
| 880 | |||
| 881 | /* put analog demod in standby when tuning digital */ | ||
| 882 | if (fe->ops.analog_ops.standby) | ||
| 883 | fe->ops.analog_ops.standby(fe); | ||
| 884 | |||
| 885 | if (fe->ops.i2c_gate_ctrl) | ||
| 886 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 887 | |||
| 888 | /* buf[0] contains the i2c address, but * | ||
| 889 | * we already have it in i2c_props.addr */ | ||
| 890 | ret = tuner_i2c_xfer_send(&priv->i2c_props, buf+1, 4); | ||
| 891 | if (ret != 4) | ||
| 892 | goto fail; | ||
| 893 | |||
| 894 | return 0; | ||
| 895 | fail: | ||
| 896 | /* calc_regs sets frequency and bandwidth. if we failed, unset them */ | ||
| 897 | priv->frequency = prev_freq; | ||
| 898 | priv->bandwidth = prev_bw; | ||
| 899 | |||
| 900 | return ret; | ||
| 901 | } | ||
| 902 | |||
| 903 | static int simple_init(struct dvb_frontend *fe) | ||
| 904 | { | ||
| 905 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 906 | |||
| 907 | if (priv->i2c_props.adap == NULL) | ||
| 908 | return -EINVAL; | ||
| 909 | |||
| 910 | if (priv->tun->initdata) { | ||
| 911 | int ret; | ||
| 912 | |||
| 913 | if (fe->ops.i2c_gate_ctrl) | ||
| 914 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 915 | |||
| 916 | ret = tuner_i2c_xfer_send(&priv->i2c_props, | ||
| 917 | priv->tun->initdata + 1, | ||
| 918 | priv->tun->initdata[0]); | ||
| 919 | if (ret != priv->tun->initdata[0]) | ||
| 920 | return ret; | ||
| 921 | } | ||
| 922 | |||
| 923 | return 0; | ||
| 924 | } | ||
| 925 | |||
| 926 | static int simple_sleep(struct dvb_frontend *fe) | ||
| 927 | { | ||
| 928 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 929 | |||
| 930 | if (priv->i2c_props.adap == NULL) | ||
| 931 | return -EINVAL; | ||
| 932 | |||
| 933 | if (priv->tun->sleepdata) { | ||
| 934 | int ret; | ||
| 935 | |||
| 936 | if (fe->ops.i2c_gate_ctrl) | ||
| 937 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 938 | |||
| 939 | ret = tuner_i2c_xfer_send(&priv->i2c_props, | ||
| 940 | priv->tun->sleepdata + 1, | ||
| 941 | priv->tun->sleepdata[0]); | ||
| 942 | if (ret != priv->tun->sleepdata[0]) | ||
| 943 | return ret; | ||
| 944 | } | ||
| 945 | |||
| 946 | return 0; | ||
| 947 | } | ||
| 589 | 948 | ||
| 590 | static int simple_release(struct dvb_frontend *fe) | 949 | static int simple_release(struct dvb_frontend *fe) |
| 591 | { | 950 | { |
| 592 | kfree(fe->tuner_priv); | 951 | struct tuner_simple_priv *priv = fe->tuner_priv; |
| 952 | |||
| 953 | mutex_lock(&tuner_simple_list_mutex); | ||
| 954 | |||
| 955 | if (priv) | ||
| 956 | hybrid_tuner_release_state(priv); | ||
| 957 | |||
| 958 | mutex_unlock(&tuner_simple_list_mutex); | ||
| 959 | |||
| 593 | fe->tuner_priv = NULL; | 960 | fe->tuner_priv = NULL; |
| 594 | 961 | ||
| 595 | return 0; | 962 | return 0; |
| @@ -602,10 +969,22 @@ static int simple_get_frequency(struct dvb_frontend *fe, u32 *frequency) | |||
| 602 | return 0; | 969 | return 0; |
| 603 | } | 970 | } |
| 604 | 971 | ||
| 972 | static int simple_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) | ||
| 973 | { | ||
| 974 | struct tuner_simple_priv *priv = fe->tuner_priv; | ||
| 975 | *bandwidth = priv->bandwidth; | ||
| 976 | return 0; | ||
| 977 | } | ||
| 978 | |||
| 605 | static struct dvb_tuner_ops simple_tuner_ops = { | 979 | static struct dvb_tuner_ops simple_tuner_ops = { |
| 980 | .init = simple_init, | ||
| 981 | .sleep = simple_sleep, | ||
| 606 | .set_analog_params = simple_set_params, | 982 | .set_analog_params = simple_set_params, |
| 983 | .set_params = simple_dvb_set_params, | ||
| 984 | .calc_regs = simple_dvb_calc_regs, | ||
| 607 | .release = simple_release, | 985 | .release = simple_release, |
| 608 | .get_frequency = simple_get_frequency, | 986 | .get_frequency = simple_get_frequency, |
| 987 | .get_bandwidth = simple_get_bandwidth, | ||
| 609 | .get_status = simple_get_status, | 988 | .get_status = simple_get_status, |
| 610 | .get_rf_strength = simple_get_rf_strength, | 989 | .get_rf_strength = simple_get_rf_strength, |
| 611 | }; | 990 | }; |
| @@ -613,30 +992,92 @@ static struct dvb_tuner_ops simple_tuner_ops = { | |||
| 613 | struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe, | 992 | struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe, |
| 614 | struct i2c_adapter *i2c_adap, | 993 | struct i2c_adapter *i2c_adap, |
| 615 | u8 i2c_addr, | 994 | u8 i2c_addr, |
| 616 | struct simple_tuner_config *cfg) | 995 | unsigned int type) |
| 617 | { | 996 | { |
| 618 | struct tuner_simple_priv *priv = NULL; | 997 | struct tuner_simple_priv *priv = NULL; |
| 998 | int instance; | ||
| 619 | 999 | ||
| 620 | priv = kzalloc(sizeof(struct tuner_simple_priv), GFP_KERNEL); | 1000 | if (type >= tuner_count) { |
| 621 | if (priv == NULL) | 1001 | printk(KERN_WARNING "%s: invalid tuner type: %d (max: %d)\n", |
| 1002 | __func__, type, tuner_count-1); | ||
| 622 | return NULL; | 1003 | return NULL; |
| 623 | fe->tuner_priv = priv; | 1004 | } |
| 624 | 1005 | ||
| 625 | priv->i2c_props.addr = i2c_addr; | 1006 | /* If i2c_adap is set, check that the tuner is at the correct address. |
| 626 | priv->i2c_props.adap = i2c_adap; | 1007 | * Otherwise, if i2c_adap is NULL, the tuner will be programmed directly |
| 627 | priv->type = cfg->type; | 1008 | * by the digital demod via calc_regs. |
| 628 | priv->tun = cfg->tun; | 1009 | */ |
| 1010 | if (i2c_adap != NULL) { | ||
| 1011 | u8 b[1]; | ||
| 1012 | struct i2c_msg msg = { | ||
| 1013 | .addr = i2c_addr, .flags = I2C_M_RD, | ||
| 1014 | .buf = b, .len = 1, | ||
| 1015 | }; | ||
| 1016 | |||
| 1017 | if (fe->ops.i2c_gate_ctrl) | ||
| 1018 | fe->ops.i2c_gate_ctrl(fe, 1); | ||
| 1019 | |||
| 1020 | if (1 != i2c_transfer(i2c_adap, &msg, 1)) | ||
| 1021 | tuner_warn("unable to probe %s, proceeding anyway.", | ||
| 1022 | tuners[type].name); | ||
| 1023 | |||
| 1024 | if (fe->ops.i2c_gate_ctrl) | ||
| 1025 | fe->ops.i2c_gate_ctrl(fe, 0); | ||
| 1026 | } | ||
| 629 | 1027 | ||
| 630 | memcpy(&fe->ops.tuner_ops, &simple_tuner_ops, sizeof(struct dvb_tuner_ops)); | 1028 | mutex_lock(&tuner_simple_list_mutex); |
| 631 | 1029 | ||
| 632 | tuner_info("type set to %d (%s)\n", cfg->type, cfg->tun->name); | 1030 | instance = hybrid_tuner_request_state(struct tuner_simple_priv, priv, |
| 1031 | hybrid_tuner_instance_list, | ||
| 1032 | i2c_adap, i2c_addr, | ||
| 1033 | "tuner-simple"); | ||
| 1034 | switch (instance) { | ||
| 1035 | case 0: | ||
| 1036 | mutex_unlock(&tuner_simple_list_mutex); | ||
| 1037 | return NULL; | ||
| 1038 | break; | ||
| 1039 | case 1: | ||
| 1040 | fe->tuner_priv = priv; | ||
| 633 | 1041 | ||
| 634 | strlcpy(fe->ops.tuner_ops.info.name, cfg->tun->name, sizeof(fe->ops.tuner_ops.info.name)); | 1042 | priv->type = type; |
| 1043 | priv->tun = &tuners[type]; | ||
| 1044 | priv->nr = simple_devcount++; | ||
| 1045 | break; | ||
| 1046 | default: | ||
| 1047 | fe->tuner_priv = priv; | ||
| 1048 | break; | ||
| 1049 | } | ||
| 635 | 1050 | ||
| 636 | return fe; | 1051 | mutex_unlock(&tuner_simple_list_mutex); |
| 637 | } | 1052 | |
| 1053 | memcpy(&fe->ops.tuner_ops, &simple_tuner_ops, | ||
| 1054 | sizeof(struct dvb_tuner_ops)); | ||
| 1055 | |||
| 1056 | tuner_info("type set to %d (%s)\n", type, priv->tun->name); | ||
| 1057 | |||
| 1058 | if ((debug) || ((atv_input[priv->nr] > 0) || | ||
| 1059 | (dtv_input[priv->nr] > 0))) { | ||
| 1060 | if (0 == atv_input[priv->nr]) | ||
| 1061 | tuner_info("tuner %d atv rf input will be " | ||
| 1062 | "autoselected\n", priv->nr); | ||
| 1063 | else | ||
| 1064 | tuner_info("tuner %d atv rf input will be " | ||
| 1065 | "set to input %d (insmod option)\n", | ||
| 1066 | priv->nr, atv_input[priv->nr]); | ||
| 1067 | if (0 == dtv_input[priv->nr]) | ||
| 1068 | tuner_info("tuner %d dtv rf input will be " | ||
| 1069 | "autoselected\n", priv->nr); | ||
| 1070 | else | ||
| 1071 | tuner_info("tuner %d dtv rf input will be " | ||
| 1072 | "set to input %d (insmod option)\n", | ||
| 1073 | priv->nr, dtv_input[priv->nr]); | ||
| 1074 | } | ||
| 638 | 1075 | ||
| 1076 | strlcpy(fe->ops.tuner_ops.info.name, priv->tun->name, | ||
| 1077 | sizeof(fe->ops.tuner_ops.info.name)); | ||
| 639 | 1078 | ||
| 1079 | return fe; | ||
| 1080 | } | ||
| 640 | EXPORT_SYMBOL_GPL(simple_tuner_attach); | 1081 | EXPORT_SYMBOL_GPL(simple_tuner_attach); |
| 641 | 1082 | ||
| 642 | MODULE_DESCRIPTION("Simple 4-control-bytes style tuner driver"); | 1083 | MODULE_DESCRIPTION("Simple 4-control-bytes style tuner driver"); |
diff --git a/drivers/media/video/tuner-simple.h b/drivers/media/video/tuner-simple.h index 9089939a8c02..e46cf0121e03 100644 --- a/drivers/media/video/tuner-simple.h +++ b/drivers/media/video/tuner-simple.h | |||
| @@ -20,25 +20,18 @@ | |||
| 20 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
| 21 | #include "dvb_frontend.h" | 21 | #include "dvb_frontend.h" |
| 22 | 22 | ||
| 23 | struct simple_tuner_config | ||
| 24 | { | ||
| 25 | /* chip type */ | ||
| 26 | unsigned int type; | ||
| 27 | struct tunertype *tun; | ||
| 28 | }; | ||
| 29 | |||
| 30 | #if defined(CONFIG_TUNER_SIMPLE) || (defined(CONFIG_TUNER_SIMPLE_MODULE) && defined(MODULE)) | 23 | #if defined(CONFIG_TUNER_SIMPLE) || (defined(CONFIG_TUNER_SIMPLE_MODULE) && defined(MODULE)) |
| 31 | extern struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe, | 24 | extern struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe, |
| 32 | struct i2c_adapter *i2c_adap, | 25 | struct i2c_adapter *i2c_adap, |
| 33 | u8 i2c_addr, | 26 | u8 i2c_addr, |
| 34 | struct simple_tuner_config *cfg); | 27 | unsigned int type); |
| 35 | #else | 28 | #else |
| 36 | static inline struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe, | 29 | static inline struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe, |
| 37 | struct i2c_adapter *i2c_adap, | 30 | struct i2c_adapter *i2c_adap, |
| 38 | u8 i2c_addr, | 31 | u8 i2c_addr, |
| 39 | struct simple_tuner_config *cfg) | 32 | unsigned int type) |
| 40 | { | 33 | { |
| 41 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __FUNCTION__); | 34 | printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); |
| 42 | return NULL; | 35 | return NULL; |
| 43 | } | 36 | } |
| 44 | #endif | 37 | #endif |
diff --git a/drivers/media/video/tuner-types.c b/drivers/media/video/tuner-types.c index 883047f9c28c..10dddca8b5d1 100644 --- a/drivers/media/video/tuner-types.c +++ b/drivers/media/video/tuner-types.c | |||
| @@ -35,6 +35,27 @@ | |||
| 35 | * based on the video standard in use. | 35 | * based on the video standard in use. |
| 36 | */ | 36 | */ |
| 37 | 37 | ||
| 38 | /* The following was taken from dvb-pll.c: */ | ||
| 39 | |||
| 40 | /* Set AGC TOP value to 103 dBuV: | ||
| 41 | * 0x80 = Control Byte | ||
| 42 | * 0x40 = 250 uA charge pump (irrelevant) | ||
| 43 | * 0x18 = Aux Byte to follow | ||
| 44 | * 0x06 = 64.5 kHz divider (irrelevant) | ||
| 45 | * 0x01 = Disable Vt (aka sleep) | ||
| 46 | * | ||
| 47 | * 0x00 = AGC Time constant 2s Iagc = 300 nA (vs 0x80 = 9 nA) | ||
| 48 | * 0x50 = AGC Take over point = 103 dBuV | ||
| 49 | */ | ||
| 50 | static u8 tua603x_agc103[] = { 2, 0x80|0x40|0x18|0x06|0x01, 0x00|0x50 }; | ||
| 51 | |||
| 52 | /* 0x04 = 166.67 kHz divider | ||
| 53 | * | ||
| 54 | * 0x80 = AGC Time constant 50ms Iagc = 9 uA | ||
| 55 | * 0x20 = AGC Take over point = 112 dBuV | ||
| 56 | */ | ||
| 57 | static u8 tua603x_agc112[] = { 2, 0x80|0x40|0x18|0x04|0x01, 0x80|0x20 }; | ||
| 58 | |||
| 38 | /* 0-9 */ | 59 | /* 0-9 */ |
| 39 | /* ------------ TUNER_TEMIC_PAL - TEMIC PAL ------------ */ | 60 | /* ------------ TUNER_TEMIC_PAL - TEMIC PAL ------------ */ |
| 40 | 61 | ||
| @@ -594,19 +615,31 @@ static struct tuner_params tuner_philips_pal_mk_params[] = { | |||
| 594 | }, | 615 | }, |
| 595 | }; | 616 | }; |
| 596 | 617 | ||
| 597 | /* ---- TUNER_PHILIPS_ATSC - Philips FCV1236D (ATSC/NTSC) ---- */ | 618 | /* ---- TUNER_PHILIPS_FCV1236D - Philips FCV1236D (ATSC/NTSC) ---- */ |
| 598 | 619 | ||
| 599 | static struct tuner_range tuner_philips_fcv1236d_ranges[] = { | 620 | static struct tuner_range tuner_philips_fcv1236d_ntsc_ranges[] = { |
| 600 | { 16 * 157.25 /*MHz*/, 0x8e, 0xa0, }, | 621 | { 16 * 157.25 /*MHz*/, 0x8e, 0xa2, }, |
| 601 | { 16 * 451.25 /*MHz*/, 0x8e, 0x90, }, | 622 | { 16 * 451.25 /*MHz*/, 0x8e, 0x92, }, |
| 623 | { 16 * 999.99 , 0x8e, 0x32, }, | ||
| 624 | }; | ||
| 625 | |||
| 626 | static struct tuner_range tuner_philips_fcv1236d_atsc_ranges[] = { | ||
| 627 | { 16 * 159.00 /*MHz*/, 0x8e, 0xa0, }, | ||
| 628 | { 16 * 453.00 /*MHz*/, 0x8e, 0x90, }, | ||
| 602 | { 16 * 999.99 , 0x8e, 0x30, }, | 629 | { 16 * 999.99 , 0x8e, 0x30, }, |
| 603 | }; | 630 | }; |
| 604 | 631 | ||
| 605 | static struct tuner_params tuner_philips_fcv1236d_params[] = { | 632 | static struct tuner_params tuner_philips_fcv1236d_params[] = { |
| 606 | { | 633 | { |
| 607 | .type = TUNER_PARAM_TYPE_NTSC, | 634 | .type = TUNER_PARAM_TYPE_NTSC, |
| 608 | .ranges = tuner_philips_fcv1236d_ranges, | 635 | .ranges = tuner_philips_fcv1236d_ntsc_ranges, |
| 609 | .count = ARRAY_SIZE(tuner_philips_fcv1236d_ranges), | 636 | .count = ARRAY_SIZE(tuner_philips_fcv1236d_ntsc_ranges), |
| 637 | }, | ||
| 638 | { | ||
| 639 | .type = TUNER_PARAM_TYPE_DIGITAL, | ||
| 640 | .ranges = tuner_philips_fcv1236d_atsc_ranges, | ||
| 641 | .count = ARRAY_SIZE(tuner_philips_fcv1236d_atsc_ranges), | ||
| 642 | .iffreq = 16 * 44.00, | ||
| 610 | }, | 643 | }, |
| 611 | }; | 644 | }; |
| 612 | 645 | ||
| @@ -701,12 +734,24 @@ static struct tuner_range tuner_microtune_4042fi5_ntsc_ranges[] = { | |||
| 701 | { 16 * 999.99 , 0x8e, 0x31, }, | 734 | { 16 * 999.99 , 0x8e, 0x31, }, |
| 702 | }; | 735 | }; |
| 703 | 736 | ||
| 737 | static struct tuner_range tuner_microtune_4042fi5_atsc_ranges[] = { | ||
| 738 | { 16 * 162.00 /*MHz*/, 0x8e, 0xa1, }, | ||
| 739 | { 16 * 457.00 /*MHz*/, 0x8e, 0x91, }, | ||
| 740 | { 16 * 999.99 , 0x8e, 0x31, }, | ||
| 741 | }; | ||
| 742 | |||
| 704 | static struct tuner_params tuner_microtune_4042fi5_params[] = { | 743 | static struct tuner_params tuner_microtune_4042fi5_params[] = { |
| 705 | { | 744 | { |
| 706 | .type = TUNER_PARAM_TYPE_NTSC, | 745 | .type = TUNER_PARAM_TYPE_NTSC, |
| 707 | .ranges = tuner_microtune_4042fi5_ntsc_ranges, | 746 | .ranges = tuner_microtune_4042fi5_ntsc_ranges, |
| 708 | .count = ARRAY_SIZE(tuner_microtune_4042fi5_ntsc_ranges), | 747 | .count = ARRAY_SIZE(tuner_microtune_4042fi5_ntsc_ranges), |
| 709 | }, | 748 | }, |
| 749 | { | ||
| 750 | .type = TUNER_PARAM_TYPE_DIGITAL, | ||
| 751 | .ranges = tuner_microtune_4042fi5_atsc_ranges, | ||
| 752 | .count = ARRAY_SIZE(tuner_microtune_4042fi5_atsc_ranges), | ||
| 753 | .iffreq = 16 * 44.00 /*MHz*/, | ||
| 754 | }, | ||
| 710 | }; | 755 | }; |
| 711 | 756 | ||
| 712 | /* 50-59 */ | 757 | /* 50-59 */ |
| @@ -740,6 +785,7 @@ static struct tuner_params tuner_philips_fm1256_ih3_params[] = { | |||
| 740 | 785 | ||
| 741 | /* ------------ TUNER_THOMSON_DTT7610 - THOMSON ATSC ------------ */ | 786 | /* ------------ TUNER_THOMSON_DTT7610 - THOMSON ATSC ------------ */ |
| 742 | 787 | ||
| 788 | /* single range used for both ntsc and atsc */ | ||
| 743 | static struct tuner_range tuner_thomson_dtt7610_ntsc_ranges[] = { | 789 | static struct tuner_range tuner_thomson_dtt7610_ntsc_ranges[] = { |
| 744 | { 16 * 157.25 /*MHz*/, 0x8e, 0x39, }, | 790 | { 16 * 157.25 /*MHz*/, 0x8e, 0x39, }, |
| 745 | { 16 * 454.00 /*MHz*/, 0x8e, 0x3a, }, | 791 | { 16 * 454.00 /*MHz*/, 0x8e, 0x3a, }, |
| @@ -752,6 +798,12 @@ static struct tuner_params tuner_thomson_dtt7610_params[] = { | |||
| 752 | .ranges = tuner_thomson_dtt7610_ntsc_ranges, | 798 | .ranges = tuner_thomson_dtt7610_ntsc_ranges, |
| 753 | .count = ARRAY_SIZE(tuner_thomson_dtt7610_ntsc_ranges), | 799 | .count = ARRAY_SIZE(tuner_thomson_dtt7610_ntsc_ranges), |
| 754 | }, | 800 | }, |
| 801 | { | ||
| 802 | .type = TUNER_PARAM_TYPE_DIGITAL, | ||
| 803 | .ranges = tuner_thomson_dtt7610_ntsc_ranges, | ||
| 804 | .count = ARRAY_SIZE(tuner_thomson_dtt7610_ntsc_ranges), | ||
| 805 | .iffreq = 16 * 44.00 /*MHz*/, | ||
| 806 | }, | ||
| 755 | }; | 807 | }; |
| 756 | 808 | ||
| 757 | /* ------------ TUNER_PHILIPS_FQ1286 - Philips NTSC ------------ */ | 809 | /* ------------ TUNER_PHILIPS_FQ1286 - Philips NTSC ------------ */ |
| @@ -855,6 +907,11 @@ static struct tuner_range tuner_thomson_dtt761x_ntsc_ranges[] = { | |||
| 855 | { 16 * 999.99 , 0x8e, 0x3c, }, | 907 | { 16 * 999.99 , 0x8e, 0x3c, }, |
| 856 | }; | 908 | }; |
| 857 | 909 | ||
| 910 | static struct tuner_range tuner_thomson_dtt761x_atsc_ranges[] = { | ||
| 911 | { 16 * 147.00 /*MHz*/, 0x8e, 0x39, }, | ||
| 912 | { 16 * 417.00 /*MHz*/, 0x8e, 0x3a, }, | ||
| 913 | { 16 * 999.99 , 0x8e, 0x3c, }, | ||
| 914 | }; | ||
| 858 | 915 | ||
| 859 | static struct tuner_params tuner_thomson_dtt761x_params[] = { | 916 | static struct tuner_params tuner_thomson_dtt761x_params[] = { |
| 860 | { | 917 | { |
| @@ -865,6 +922,12 @@ static struct tuner_params tuner_thomson_dtt761x_params[] = { | |||
| 865 | .fm_gain_normal = 1, | 922 | .fm_gain_normal = 1, |
| 866 | .radio_if = 2, /* 41.3 MHz */ | 923 | .radio_if = 2, /* 41.3 MHz */ |
| 867 | }, | 924 | }, |
| 925 | { | ||
| 926 | .type = TUNER_PARAM_TYPE_DIGITAL, | ||
| 927 | .ranges = tuner_thomson_dtt761x_atsc_ranges, | ||
| 928 | .count = ARRAY_SIZE(tuner_thomson_dtt761x_atsc_ranges), | ||
| 929 | .iffreq = 16 * 44.00, /*MHz*/ | ||
| 930 | }, | ||
| 868 | }; | 931 | }; |
| 869 | 932 | ||
| 870 | /* ------------ TUNER_TENA_9533_DI - Philips PAL ------------ */ | 933 | /* ------------ TUNER_TENA_9533_DI - Philips PAL ------------ */ |
| @@ -891,6 +954,15 @@ static struct tuner_range tuner_philips_fmd1216me_mk3_pal_ranges[] = { | |||
| 891 | { 16 * 999.99 , 0x86, 0x54, }, | 954 | { 16 * 999.99 , 0x86, 0x54, }, |
| 892 | }; | 955 | }; |
| 893 | 956 | ||
| 957 | static struct tuner_range tuner_philips_fmd1216me_mk3_dvb_ranges[] = { | ||
| 958 | { 16 * 143.87 /*MHz*/, 0xbc, 0x41 }, | ||
| 959 | { 16 * 158.87 /*MHz*/, 0xf4, 0x41 }, | ||
| 960 | { 16 * 329.87 /*MHz*/, 0xbc, 0x42 }, | ||
| 961 | { 16 * 441.87 /*MHz*/, 0xf4, 0x42 }, | ||
| 962 | { 16 * 625.87 /*MHz*/, 0xbc, 0x44 }, | ||
| 963 | { 16 * 803.87 /*MHz*/, 0xf4, 0x44 }, | ||
| 964 | { 16 * 999.99 , 0xfc, 0x44 }, | ||
| 965 | }; | ||
| 894 | 966 | ||
| 895 | static struct tuner_params tuner_philips_fmd1216me_mk3_params[] = { | 967 | static struct tuner_params tuner_philips_fmd1216me_mk3_params[] = { |
| 896 | { | 968 | { |
| @@ -904,6 +976,12 @@ static struct tuner_params tuner_philips_fmd1216me_mk3_params[] = { | |||
| 904 | .port2_invert_for_secam_lc = 1, | 976 | .port2_invert_for_secam_lc = 1, |
| 905 | .port1_set_for_fm_mono = 1, | 977 | .port1_set_for_fm_mono = 1, |
| 906 | }, | 978 | }, |
| 979 | { | ||
| 980 | .type = TUNER_PARAM_TYPE_DIGITAL, | ||
| 981 | .ranges = tuner_philips_fmd1216me_mk3_dvb_ranges, | ||
| 982 | .count = ARRAY_SIZE(tuner_philips_fmd1216me_mk3_dvb_ranges), | ||
| 983 | .iffreq = 16 * 36.125, /*MHz*/ | ||
| 984 | }, | ||
| 907 | }; | 985 | }; |
| 908 | 986 | ||
| 909 | 987 | ||
| @@ -915,6 +993,11 @@ static struct tuner_range tuner_tua6034_ntsc_ranges[] = { | |||
| 915 | { 16 * 999.99 , 0x8e, 0x04 }, | 993 | { 16 * 999.99 , 0x8e, 0x04 }, |
| 916 | }; | 994 | }; |
| 917 | 995 | ||
| 996 | static struct tuner_range tuner_tua6034_atsc_ranges[] = { | ||
| 997 | { 16 * 165.00 /*MHz*/, 0xce, 0x01 }, | ||
| 998 | { 16 * 450.00 /*MHz*/, 0xce, 0x02 }, | ||
| 999 | { 16 * 999.99 , 0xce, 0x04 }, | ||
| 1000 | }; | ||
| 918 | 1001 | ||
| 919 | static struct tuner_params tuner_lg_tdvs_h06xf_params[] = { | 1002 | static struct tuner_params tuner_lg_tdvs_h06xf_params[] = { |
| 920 | { | 1003 | { |
| @@ -922,6 +1005,12 @@ static struct tuner_params tuner_lg_tdvs_h06xf_params[] = { | |||
| 922 | .ranges = tuner_tua6034_ntsc_ranges, | 1005 | .ranges = tuner_tua6034_ntsc_ranges, |
| 923 | .count = ARRAY_SIZE(tuner_tua6034_ntsc_ranges), | 1006 | .count = ARRAY_SIZE(tuner_tua6034_ntsc_ranges), |
| 924 | }, | 1007 | }, |
| 1008 | { | ||
| 1009 | .type = TUNER_PARAM_TYPE_DIGITAL, | ||
| 1010 | .ranges = tuner_tua6034_atsc_ranges, | ||
| 1011 | .count = ARRAY_SIZE(tuner_tua6034_atsc_ranges), | ||
| 1012 | .iffreq = 16 * 44.00, | ||
| 1013 | }, | ||
| 925 | }; | 1014 | }; |
| 926 | 1015 | ||
| 927 | /* ------------ TUNER_YMEC_TVF66T5_B_DFF - Philips PAL ------------ */ | 1016 | /* ------------ TUNER_YMEC_TVF66T5_B_DFF - Philips PAL ------------ */ |
| @@ -974,12 +1063,30 @@ static struct tuner_range tuner_philips_td1316_pal_ranges[] = { | |||
| 974 | { 16 * 999.99 , 0xc8, 0xa4, }, | 1063 | { 16 * 999.99 , 0xc8, 0xa4, }, |
| 975 | }; | 1064 | }; |
| 976 | 1065 | ||
| 1066 | static struct tuner_range tuner_philips_td1316_dvb_ranges[] = { | ||
| 1067 | { 16 * 93.834 /*MHz*/, 0xca, 0x60, }, | ||
| 1068 | { 16 * 123.834 /*MHz*/, 0xca, 0xa0, }, | ||
| 1069 | { 16 * 163.834 /*MHz*/, 0xca, 0xc0, }, | ||
| 1070 | { 16 * 253.834 /*MHz*/, 0xca, 0x60, }, | ||
| 1071 | { 16 * 383.834 /*MHz*/, 0xca, 0xa0, }, | ||
| 1072 | { 16 * 443.834 /*MHz*/, 0xca, 0xc0, }, | ||
| 1073 | { 16 * 583.834 /*MHz*/, 0xca, 0x60, }, | ||
| 1074 | { 16 * 793.834 /*MHz*/, 0xca, 0xa0, }, | ||
| 1075 | { 16 * 999.999 , 0xca, 0xe0, }, | ||
| 1076 | }; | ||
| 1077 | |||
| 977 | static struct tuner_params tuner_philips_td1316_params[] = { | 1078 | static struct tuner_params tuner_philips_td1316_params[] = { |
| 978 | { | 1079 | { |
| 979 | .type = TUNER_PARAM_TYPE_PAL, | 1080 | .type = TUNER_PARAM_TYPE_PAL, |
| 980 | .ranges = tuner_philips_td1316_pal_ranges, | 1081 | .ranges = tuner_philips_td1316_pal_ranges, |
| 981 | .count = ARRAY_SIZE(tuner_philips_td1316_pal_ranges), | 1082 | .count = ARRAY_SIZE(tuner_philips_td1316_pal_ranges), |
| 982 | }, | 1083 | }, |
| 1084 | { | ||
| 1085 | .type = TUNER_PARAM_TYPE_DIGITAL, | ||
| 1086 | .ranges = tuner_philips_td1316_dvb_ranges, | ||
| 1087 | .count = ARRAY_SIZE(tuner_philips_td1316_dvb_ranges), | ||
| 1088 | .iffreq = 16 * 36.166667 /*MHz*/, | ||
| 1089 | }, | ||
| 983 | }; | 1090 | }; |
| 984 | 1091 | ||
| 985 | /* ------------ TUNER_PHILIPS_TUV1236D - Philips ATSC ------------ */ | 1092 | /* ------------ TUNER_PHILIPS_TUV1236D - Philips ATSC ------------ */ |
| @@ -990,6 +1097,11 @@ static struct tuner_range tuner_tuv1236d_ntsc_ranges[] = { | |||
| 990 | { 16 * 999.99 , 0xce, 0x04, }, | 1097 | { 16 * 999.99 , 0xce, 0x04, }, |
| 991 | }; | 1098 | }; |
| 992 | 1099 | ||
| 1100 | static struct tuner_range tuner_tuv1236d_atsc_ranges[] = { | ||
| 1101 | { 16 * 157.25 /*MHz*/, 0xc6, 0x41, }, | ||
| 1102 | { 16 * 454.00 /*MHz*/, 0xc6, 0x42, }, | ||
| 1103 | { 16 * 999.99 , 0xc6, 0x44, }, | ||
| 1104 | }; | ||
| 993 | 1105 | ||
| 994 | static struct tuner_params tuner_tuv1236d_params[] = { | 1106 | static struct tuner_params tuner_tuv1236d_params[] = { |
| 995 | { | 1107 | { |
| @@ -997,6 +1109,12 @@ static struct tuner_params tuner_tuv1236d_params[] = { | |||
| 997 | .ranges = tuner_tuv1236d_ntsc_ranges, | 1109 | .ranges = tuner_tuv1236d_ntsc_ranges, |
| 998 | .count = ARRAY_SIZE(tuner_tuv1236d_ntsc_ranges), | 1110 | .count = ARRAY_SIZE(tuner_tuv1236d_ntsc_ranges), |
| 999 | }, | 1111 | }, |
| 1112 | { | ||
| 1113 | .type = TUNER_PARAM_TYPE_DIGITAL, | ||
| 1114 | .ranges = tuner_tuv1236d_atsc_ranges, | ||
| 1115 | .count = ARRAY_SIZE(tuner_tuv1236d_atsc_ranges), | ||
| 1116 | .iffreq = 16 * 44.00, | ||
| 1117 | }, | ||
| 1000 | }; | 1118 | }; |
| 1001 | 1119 | ||
| 1002 | /* ------------ TUNER_TNF_xxx5 - Texas Instruments--------- */ | 1120 | /* ------------ TUNER_TNF_xxx5 - Texas Instruments--------- */ |
| @@ -1050,17 +1168,30 @@ static struct tuner_params tuner_samsung_tcpn_2121p30a_params[] = { | |||
| 1050 | 1168 | ||
| 1051 | /* ------------ TUNER_THOMSON_FE6600 - DViCO Hybrid PAL ------------ */ | 1169 | /* ------------ TUNER_THOMSON_FE6600 - DViCO Hybrid PAL ------------ */ |
| 1052 | 1170 | ||
| 1053 | static struct tuner_range tuner_thomson_fe6600_ranges[] = { | 1171 | static struct tuner_range tuner_thomson_fe6600_pal_ranges[] = { |
| 1054 | { 16 * 160.00 /*MHz*/, 0xfe, 0x11, }, | 1172 | { 16 * 160.00 /*MHz*/, 0xfe, 0x11, }, |
| 1055 | { 16 * 442.00 /*MHz*/, 0xf6, 0x12, }, | 1173 | { 16 * 442.00 /*MHz*/, 0xf6, 0x12, }, |
| 1056 | { 16 * 999.99 , 0xf6, 0x18, }, | 1174 | { 16 * 999.99 , 0xf6, 0x18, }, |
| 1057 | }; | 1175 | }; |
| 1058 | 1176 | ||
| 1177 | static struct tuner_range tuner_thomson_fe6600_dvb_ranges[] = { | ||
| 1178 | { 16 * 250.00 /*MHz*/, 0xb4, 0x12, }, | ||
| 1179 | { 16 * 455.00 /*MHz*/, 0xfe, 0x11, }, | ||
| 1180 | { 16 * 775.50 /*MHz*/, 0xbc, 0x18, }, | ||
| 1181 | { 16 * 999.99 , 0xf4, 0x18, }, | ||
| 1182 | }; | ||
| 1183 | |||
| 1059 | static struct tuner_params tuner_thomson_fe6600_params[] = { | 1184 | static struct tuner_params tuner_thomson_fe6600_params[] = { |
| 1060 | { | 1185 | { |
| 1061 | .type = TUNER_PARAM_TYPE_PAL, | 1186 | .type = TUNER_PARAM_TYPE_PAL, |
| 1062 | .ranges = tuner_thomson_fe6600_ranges, | 1187 | .ranges = tuner_thomson_fe6600_pal_ranges, |
| 1063 | .count = ARRAY_SIZE(tuner_thomson_fe6600_ranges), | 1188 | .count = ARRAY_SIZE(tuner_thomson_fe6600_pal_ranges), |
| 1189 | }, | ||
| 1190 | { | ||
| 1191 | .type = TUNER_PARAM_TYPE_DIGITAL, | ||
| 1192 | .ranges = tuner_thomson_fe6600_dvb_ranges, | ||
| 1193 | .count = ARRAY_SIZE(tuner_thomson_fe6600_dvb_ranges), | ||
| 1194 | .iffreq = 16 * 36.125 /*MHz*/, | ||
| 1064 | }, | 1195 | }, |
| 1065 | }; | 1196 | }; |
| 1066 | 1197 | ||
| @@ -1303,10 +1434,13 @@ struct tunertype tuners[] = { | |||
| 1303 | .params = tuner_philips_pal_mk_params, | 1434 | .params = tuner_philips_pal_mk_params, |
| 1304 | .count = ARRAY_SIZE(tuner_philips_pal_mk_params), | 1435 | .count = ARRAY_SIZE(tuner_philips_pal_mk_params), |
| 1305 | }, | 1436 | }, |
| 1306 | [TUNER_PHILIPS_ATSC] = { /* Philips ATSC */ | 1437 | [TUNER_PHILIPS_FCV1236D] = { /* Philips ATSC */ |
| 1307 | .name = "Philips FCV1236D ATSC/NTSC dual in", | 1438 | .name = "Philips FCV1236D ATSC/NTSC dual in", |
| 1308 | .params = tuner_philips_fcv1236d_params, | 1439 | .params = tuner_philips_fcv1236d_params, |
| 1309 | .count = ARRAY_SIZE(tuner_philips_fcv1236d_params), | 1440 | .count = ARRAY_SIZE(tuner_philips_fcv1236d_params), |
| 1441 | .min = 16 * 53.00, | ||
| 1442 | .max = 16 * 803.00, | ||
| 1443 | .stepsize = 62500, | ||
| 1310 | }, | 1444 | }, |
| 1311 | [TUNER_PHILIPS_FM1236_MK3] = { /* Philips NTSC */ | 1445 | [TUNER_PHILIPS_FM1236_MK3] = { /* Philips NTSC */ |
| 1312 | .name = "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", | 1446 | .name = "Philips NTSC MK3 (FM1236MK3 or FM1236/F)", |
| @@ -1342,6 +1476,9 @@ struct tunertype tuners[] = { | |||
| 1342 | .name = "Microtune 4042 FI5 ATSC/NTSC dual in", | 1476 | .name = "Microtune 4042 FI5 ATSC/NTSC dual in", |
| 1343 | .params = tuner_microtune_4042fi5_params, | 1477 | .params = tuner_microtune_4042fi5_params, |
| 1344 | .count = ARRAY_SIZE(tuner_microtune_4042fi5_params), | 1478 | .count = ARRAY_SIZE(tuner_microtune_4042fi5_params), |
| 1479 | .min = 16 * 57.00, | ||
| 1480 | .max = 16 * 858.00, | ||
| 1481 | .stepsize = 62500, | ||
| 1345 | }, | 1482 | }, |
| 1346 | 1483 | ||
| 1347 | /* 50-59 */ | 1484 | /* 50-59 */ |
| @@ -1359,6 +1496,9 @@ struct tunertype tuners[] = { | |||
| 1359 | .name = "Thomson DTT 7610 (ATSC/NTSC)", | 1496 | .name = "Thomson DTT 7610 (ATSC/NTSC)", |
| 1360 | .params = tuner_thomson_dtt7610_params, | 1497 | .params = tuner_thomson_dtt7610_params, |
| 1361 | .count = ARRAY_SIZE(tuner_thomson_dtt7610_params), | 1498 | .count = ARRAY_SIZE(tuner_thomson_dtt7610_params), |
| 1499 | .min = 16 * 44.00, | ||
| 1500 | .max = 16 * 958.00, | ||
| 1501 | .stepsize = 62500, | ||
| 1362 | }, | 1502 | }, |
| 1363 | [TUNER_PHILIPS_FQ1286] = { /* Philips NTSC */ | 1503 | [TUNER_PHILIPS_FQ1286] = { /* Philips NTSC */ |
| 1364 | .name = "Philips FQ1286", | 1504 | .name = "Philips FQ1286", |
| @@ -1400,6 +1540,10 @@ struct tunertype tuners[] = { | |||
| 1400 | .name = "Thomson DTT 761X (ATSC/NTSC)", | 1540 | .name = "Thomson DTT 761X (ATSC/NTSC)", |
| 1401 | .params = tuner_thomson_dtt761x_params, | 1541 | .params = tuner_thomson_dtt761x_params, |
| 1402 | .count = ARRAY_SIZE(tuner_thomson_dtt761x_params), | 1542 | .count = ARRAY_SIZE(tuner_thomson_dtt761x_params), |
| 1543 | .min = 16 * 57.00, | ||
| 1544 | .max = 16 * 863.00, | ||
| 1545 | .stepsize = 62500, | ||
| 1546 | .initdata = tua603x_agc103, | ||
| 1403 | }, | 1547 | }, |
| 1404 | [TUNER_TENA_9533_DI] = { /* Philips PAL */ | 1548 | [TUNER_TENA_9533_DI] = { /* Philips PAL */ |
| 1405 | .name = "Tena TNF9533-D/IF/TNF9533-B/DF", | 1549 | .name = "Tena TNF9533-D/IF/TNF9533-B/DF", |
| @@ -1414,11 +1558,20 @@ struct tunertype tuners[] = { | |||
| 1414 | .name = "Philips FMD1216ME MK3 Hybrid Tuner", | 1558 | .name = "Philips FMD1216ME MK3 Hybrid Tuner", |
| 1415 | .params = tuner_philips_fmd1216me_mk3_params, | 1559 | .params = tuner_philips_fmd1216me_mk3_params, |
| 1416 | .count = ARRAY_SIZE(tuner_philips_fmd1216me_mk3_params), | 1560 | .count = ARRAY_SIZE(tuner_philips_fmd1216me_mk3_params), |
| 1561 | .min = 16 * 50.87, | ||
| 1562 | .max = 16 * 858.00, | ||
| 1563 | .stepsize = 166667, | ||
| 1564 | .initdata = tua603x_agc112, | ||
| 1565 | .sleepdata = (u8[]){ 4, 0x9c, 0x60, 0x85, 0x54 }, | ||
| 1417 | }, | 1566 | }, |
| 1418 | [TUNER_LG_TDVS_H06XF] = { /* LGINNOTEK ATSC */ | 1567 | [TUNER_LG_TDVS_H06XF] = { /* LGINNOTEK ATSC */ |
| 1419 | .name = "LG TDVS-H06xF", /* H061F, H062F & H064F */ | 1568 | .name = "LG TDVS-H06xF", /* H061F, H062F & H064F */ |
| 1420 | .params = tuner_lg_tdvs_h06xf_params, | 1569 | .params = tuner_lg_tdvs_h06xf_params, |
| 1421 | .count = ARRAY_SIZE(tuner_lg_tdvs_h06xf_params), | 1570 | .count = ARRAY_SIZE(tuner_lg_tdvs_h06xf_params), |
| 1571 | .min = 16 * 54.00, | ||
| 1572 | .max = 16 * 863.00, | ||
| 1573 | .stepsize = 62500, | ||
| 1574 | .initdata = tua603x_agc103, | ||
| 1422 | }, | 1575 | }, |
| 1423 | [TUNER_YMEC_TVF66T5_B_DFF] = { /* Philips PAL */ | 1576 | [TUNER_YMEC_TVF66T5_B_DFF] = { /* Philips PAL */ |
| 1424 | .name = "Ymec TVF66T5-B/DFF", | 1577 | .name = "Ymec TVF66T5-B/DFF", |
| @@ -1434,11 +1587,17 @@ struct tunertype tuners[] = { | |||
| 1434 | .name = "Philips TD1316 Hybrid Tuner", | 1587 | .name = "Philips TD1316 Hybrid Tuner", |
| 1435 | .params = tuner_philips_td1316_params, | 1588 | .params = tuner_philips_td1316_params, |
| 1436 | .count = ARRAY_SIZE(tuner_philips_td1316_params), | 1589 | .count = ARRAY_SIZE(tuner_philips_td1316_params), |
| 1590 | .min = 16 * 87.00, | ||
| 1591 | .max = 16 * 895.00, | ||
| 1592 | .stepsize = 166667, | ||
| 1437 | }, | 1593 | }, |
| 1438 | [TUNER_PHILIPS_TUV1236D] = { /* Philips ATSC */ | 1594 | [TUNER_PHILIPS_TUV1236D] = { /* Philips ATSC */ |
| 1439 | .name = "Philips TUV1236D ATSC/NTSC dual in", | 1595 | .name = "Philips TUV1236D ATSC/NTSC dual in", |
| 1440 | .params = tuner_tuv1236d_params, | 1596 | .params = tuner_tuv1236d_params, |
| 1441 | .count = ARRAY_SIZE(tuner_tuv1236d_params), | 1597 | .count = ARRAY_SIZE(tuner_tuv1236d_params), |
| 1598 | .min = 16 * 54.00, | ||
| 1599 | .max = 16 * 864.00, | ||
| 1600 | .stepsize = 62500, | ||
| 1442 | }, | 1601 | }, |
| 1443 | [TUNER_TNF_5335MF] = { /* Tenna PAL/NTSC */ | 1602 | [TUNER_TNF_5335MF] = { /* Tenna PAL/NTSC */ |
| 1444 | .name = "Tena TNF 5335 and similar models", | 1603 | .name = "Tena TNF 5335 and similar models", |
| @@ -1460,6 +1619,9 @@ struct tunertype tuners[] = { | |||
| 1460 | .name = "Thomson FE6600", | 1619 | .name = "Thomson FE6600", |
| 1461 | .params = tuner_thomson_fe6600_params, | 1620 | .params = tuner_thomson_fe6600_params, |
| 1462 | .count = ARRAY_SIZE(tuner_thomson_fe6600_params), | 1621 | .count = ARRAY_SIZE(tuner_thomson_fe6600_params), |
| 1622 | .min = 16 * 44.25, | ||
| 1623 | .max = 16 * 858.00, | ||
| 1624 | .stepsize = 166667, | ||
| 1463 | }, | 1625 | }, |
| 1464 | [TUNER_SAMSUNG_TCPG_6121P30A] = { /* Samsung PAL */ | 1626 | [TUNER_SAMSUNG_TCPG_6121P30A] = { /* Samsung PAL */ |
| 1465 | .name = "Samsung TCPG 6121P30A", | 1627 | .name = "Samsung TCPG 6121P30A", |
| @@ -1480,5 +1642,11 @@ struct tunertype tuners[] = { | |||
| 1480 | /* see xc5000.c for details */ | 1642 | /* see xc5000.c for details */ |
| 1481 | }, | 1643 | }, |
| 1482 | }; | 1644 | }; |
| 1645 | EXPORT_SYMBOL(tuners); | ||
| 1483 | 1646 | ||
| 1484 | unsigned const int tuner_count = ARRAY_SIZE(tuners); | 1647 | unsigned const int tuner_count = ARRAY_SIZE(tuners); |
| 1648 | EXPORT_SYMBOL(tuner_count); | ||
| 1649 | |||
| 1650 | MODULE_DESCRIPTION("Simple tuner device type database"); | ||
| 1651 | MODULE_AUTHOR("Ralph Metzler, Gerd Knorr, Gunther Mayer"); | ||
| 1652 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/video/tuner-xc2028-types.h b/drivers/media/video/tuner-xc2028-types.h index d0057fbf0ec7..74dc46a71f64 100644 --- a/drivers/media/video/tuner-xc2028-types.h +++ b/drivers/media/video/tuner-xc2028-types.h | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | /* tuner-xc2028_types | 1 | /* tuner-xc2028_types |
| 2 | * | 2 | * |
| 3 | * Copyright (c) 2007 Mauro Carvalho Chehab (mchehab@infradead.org) | 3 | * This file includes internal tipes to be used inside tuner-xc2028. |
| 4 | * Shouldn't be included outside tuner-xc2028 | ||
| 5 | * | ||
| 6 | * Copyright (c) 2007-2008 Mauro Carvalho Chehab (mchehab@infradead.org) | ||
| 4 | * This code is placed under the terms of the GNU General Public License v2 | 7 | * This code is placed under the terms of the GNU General Public License v2 |
| 5 | */ | 8 | */ |
| 6 | 9 | ||
| @@ -54,11 +57,13 @@ | |||
| 54 | /* LCD firmwares exist only for MTS STD/MN (PAL or NTSC/M) | 57 | /* LCD firmwares exist only for MTS STD/MN (PAL or NTSC/M) |
| 55 | and for non-MTS STD/MN (PAL, NTSC/M or NTSC/Kr) | 58 | and for non-MTS STD/MN (PAL, NTSC/M or NTSC/Kr) |
| 56 | There are variants both with and without NOGD | 59 | There are variants both with and without NOGD |
| 60 | Those firmwares produce better result with LCD displays | ||
| 57 | */ | 61 | */ |
| 58 | #define LCD (1<<12) | 62 | #define LCD (1<<12) |
| 59 | 63 | ||
| 60 | /* NOGD firmwares exist only for MTS STD/MN (PAL or NTSC/M) | 64 | /* NOGD firmwares exist only for MTS STD/MN (PAL or NTSC/M) |
| 61 | and for non-MTS STD/MN (PAL, NTSC/M or NTSC/Kr) | 65 | and for non-MTS STD/MN (PAL, NTSC/M or NTSC/Kr) |
| 66 | The NOGD firmwares don't have group delay compensation filter | ||
| 62 | */ | 67 | */ |
| 63 | #define NOGD (1<<13) | 68 | #define NOGD (1<<13) |
| 64 | 69 | ||
| @@ -85,11 +90,19 @@ | |||
| 85 | /* This flag identifies that the scode table has a new format */ | 90 | /* This flag identifies that the scode table has a new format */ |
| 86 | #define HAS_IF (1 << 30) | 91 | #define HAS_IF (1 << 30) |
| 87 | 92 | ||
| 88 | #define SCODE_TYPES (MTS|DTV6|QAM|DTV7|DTV78|DTV8|LCD|NOGD|MONO|ATSC|IF| \ | 93 | /* There are different scode tables for MTS and non-MTS. |
| 89 | LG60|ATI638|OREN538|OREN36|TOYOTA388|TOYOTA794| \ | 94 | The MTS firmwares support mono only |
| 90 | DIBCOM52|ZARLINK456|CHINA|F6MHZ|SCODE) | 95 | */ |
| 96 | #define SCODE_TYPES (SCODE | MTS) | ||
| 97 | |||
| 91 | 98 | ||
| 92 | /* Newer types to be moved to videodev2.h */ | 99 | /* Newer types not defined on videodev2.h. |
| 100 | The original idea were to move all those types to videodev2.h, but | ||
| 101 | it seemed overkill, since, with the exception of SECAM/K3, the other | ||
| 102 | types seem to be autodetected. | ||
| 103 | It is not clear where secam/k3 is used, nor we have a feedback of this | ||
| 104 | working or being autodetected by the standard secam firmware. | ||
| 105 | */ | ||
| 93 | 106 | ||
| 94 | #define V4L2_STD_SECAM_K3 (0x04000000) | 107 | #define V4L2_STD_SECAM_K3 (0x04000000) |
| 95 | 108 | ||
diff --git a/drivers/media/video/tuner-xc2028.c b/drivers/media/video/tuner-xc2028.c index 50cf876f020f..cc3db7d79a0d 100644 --- a/drivers/media/video/tuner-xc2028.c +++ b/drivers/media/video/tuner-xc2028.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* tuner-xc2028 | 1 | /* tuner-xc2028 |
| 2 | * | 2 | * |
| 3 | * Copyright (c) 2007 Mauro Carvalho Chehab (mchehab@infradead.org) | 3 | * Copyright (c) 2007-2008 Mauro Carvalho Chehab (mchehab@infradead.org) |
| 4 | * | 4 | * |
| 5 | * Copyright (c) 2007 Michel Ludwig (michel.ludwig@gmail.com) | 5 | * Copyright (c) 2007 Michel Ludwig (michel.ludwig@gmail.com) |
| 6 | * - frontend interface | 6 | * - frontend interface |
| @@ -23,8 +23,6 @@ | |||
| 23 | #include "dvb_frontend.h" | 23 | #include "dvb_frontend.h" |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | #define PREFIX "xc2028" | ||
| 27 | |||
| 28 | static int debug; | 26 | static int debug; |
| 29 | module_param(debug, int, 0644); | 27 | module_param(debug, int, 0644); |
| 30 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); | 28 | MODULE_PARM_DESC(debug, "enable verbose debug messages"); |
| @@ -43,6 +41,11 @@ MODULE_PARM_DESC(audio_std, | |||
| 43 | "NICAM/A\n" | 41 | "NICAM/A\n" |
| 44 | "NICAM/B\n"); | 42 | "NICAM/B\n"); |
| 45 | 43 | ||
| 44 | static char firmware_name[FIRMWARE_NAME_MAX]; | ||
| 45 | module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0); | ||
| 46 | MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the " | ||
| 47 | "default firmware name\n"); | ||
| 48 | |||
| 46 | static LIST_HEAD(xc2028_list); | 49 | static LIST_HEAD(xc2028_list); |
| 47 | static DEFINE_MUTEX(xc2028_list_mutex); | 50 | static DEFINE_MUTEX(xc2028_list_mutex); |
| 48 | 51 | ||
| @@ -127,12 +130,12 @@ struct xc2028_data { | |||
| 127 | _rc; \ | 130 | _rc; \ |
| 128 | }) | 131 | }) |
| 129 | 132 | ||
| 130 | static unsigned int xc2028_get_reg(struct xc2028_data *priv, u16 reg, u16 *val) | 133 | static int xc2028_get_reg(struct xc2028_data *priv, u16 reg, u16 *val) |
| 131 | { | 134 | { |
| 132 | unsigned char buf[2]; | 135 | unsigned char buf[2]; |
| 133 | unsigned char ibuf[2]; | 136 | unsigned char ibuf[2]; |
| 134 | 137 | ||
| 135 | tuner_dbg("%s %04x called\n", __FUNCTION__, reg); | 138 | tuner_dbg("%s %04x called\n", __func__, reg); |
| 136 | 139 | ||
| 137 | buf[0] = reg >> 8; | 140 | buf[0] = reg >> 8; |
| 138 | buf[1] = (unsigned char) reg; | 141 | buf[1] = (unsigned char) reg; |
| @@ -145,7 +148,7 @@ static unsigned int xc2028_get_reg(struct xc2028_data *priv, u16 reg, u16 *val) | |||
| 145 | } | 148 | } |
| 146 | 149 | ||
| 147 | #define dump_firm_type(t) dump_firm_type_and_int_freq(t, 0) | 150 | #define dump_firm_type(t) dump_firm_type_and_int_freq(t, 0) |
| 148 | void dump_firm_type_and_int_freq(unsigned int type, u16 int_freq) | 151 | static void dump_firm_type_and_int_freq(unsigned int type, u16 int_freq) |
| 149 | { | 152 | { |
| 150 | if (type & BASE) | 153 | if (type & BASE) |
| 151 | printk("BASE "); | 154 | printk("BASE "); |
| @@ -232,6 +235,7 @@ static v4l2_std_id parse_audio_std_option(void) | |||
| 232 | static void free_firmware(struct xc2028_data *priv) | 235 | static void free_firmware(struct xc2028_data *priv) |
| 233 | { | 236 | { |
| 234 | int i; | 237 | int i; |
| 238 | tuner_dbg("%s called\n", __func__); | ||
| 235 | 239 | ||
| 236 | if (!priv->firm) | 240 | if (!priv->firm) |
| 237 | return; | 241 | return; |
| @@ -255,19 +259,24 @@ static int load_all_firmwares(struct dvb_frontend *fe) | |||
| 255 | int rc = 0; | 259 | int rc = 0; |
| 256 | int n, n_array; | 260 | int n, n_array; |
| 257 | char name[33]; | 261 | char name[33]; |
| 262 | char *fname; | ||
| 263 | |||
| 264 | tuner_dbg("%s called\n", __func__); | ||
| 258 | 265 | ||
| 259 | tuner_dbg("%s called\n", __FUNCTION__); | 266 | if (!firmware_name[0]) |
| 267 | fname = priv->ctrl.fname; | ||
| 268 | else | ||
| 269 | fname = firmware_name; | ||
| 260 | 270 | ||
| 261 | tuner_dbg("Reading firmware %s\n", priv->ctrl.fname); | 271 | tuner_dbg("Reading firmware %s\n", fname); |
| 262 | rc = request_firmware(&fw, priv->ctrl.fname, | 272 | rc = request_firmware(&fw, fname, &priv->i2c_props.adap->dev); |
| 263 | &priv->i2c_props.adap->dev); | ||
| 264 | if (rc < 0) { | 273 | if (rc < 0) { |
| 265 | if (rc == -ENOENT) | 274 | if (rc == -ENOENT) |
| 266 | tuner_err("Error: firmware %s not found.\n", | 275 | tuner_err("Error: firmware %s not found.\n", |
| 267 | priv->ctrl.fname); | 276 | fname); |
| 268 | else | 277 | else |
| 269 | tuner_err("Error %d while requesting firmware %s \n", | 278 | tuner_err("Error %d while requesting firmware %s \n", |
| 270 | rc, priv->ctrl.fname); | 279 | rc, fname); |
| 271 | 280 | ||
| 272 | return rc; | 281 | return rc; |
| 273 | } | 282 | } |
| @@ -276,7 +285,7 @@ static int load_all_firmwares(struct dvb_frontend *fe) | |||
| 276 | 285 | ||
| 277 | if (fw->size < sizeof(name) - 1 + 2 + 2) { | 286 | if (fw->size < sizeof(name) - 1 + 2 + 2) { |
| 278 | tuner_err("Error: firmware file %s has invalid size!\n", | 287 | tuner_err("Error: firmware file %s has invalid size!\n", |
| 279 | priv->ctrl.fname); | 288 | fname); |
| 280 | goto corrupt; | 289 | goto corrupt; |
| 281 | } | 290 | } |
| 282 | 291 | ||
| @@ -291,7 +300,7 @@ static int load_all_firmwares(struct dvb_frontend *fe) | |||
| 291 | p += 2; | 300 | p += 2; |
| 292 | 301 | ||
| 293 | tuner_info("Loading %d firmware images from %s, type: %s, ver %d.%d\n", | 302 | tuner_info("Loading %d firmware images from %s, type: %s, ver %d.%d\n", |
| 294 | n_array, priv->ctrl.fname, name, | 303 | n_array, fname, name, |
| 295 | priv->firm_version >> 8, priv->firm_version & 0xff); | 304 | priv->firm_version >> 8, priv->firm_version & 0xff); |
| 296 | 305 | ||
| 297 | priv->firm = kzalloc(sizeof(*priv->firm) * n_array, GFP_KERNEL); | 306 | priv->firm = kzalloc(sizeof(*priv->firm) * n_array, GFP_KERNEL); |
| @@ -395,9 +404,9 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type, | |||
| 395 | { | 404 | { |
| 396 | struct xc2028_data *priv = fe->tuner_priv; | 405 | struct xc2028_data *priv = fe->tuner_priv; |
| 397 | int i, best_i = -1, best_nr_matches = 0; | 406 | int i, best_i = -1, best_nr_matches = 0; |
| 398 | unsigned int ign_firm_type_mask = 0; | 407 | unsigned int type_mask = 0; |
| 399 | 408 | ||
| 400 | tuner_dbg("%s called, want type=", __FUNCTION__); | 409 | tuner_dbg("%s called, want type=", __func__); |
| 401 | if (debug) { | 410 | if (debug) { |
| 402 | dump_firm_type(type); | 411 | dump_firm_type(type); |
| 403 | printk("(%x), id %016llx.\n", type, (unsigned long long)*id); | 412 | printk("(%x), id %016llx.\n", type, (unsigned long long)*id); |
| @@ -412,18 +421,23 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type, | |||
| 412 | *id = V4L2_STD_PAL; | 421 | *id = V4L2_STD_PAL; |
| 413 | 422 | ||
| 414 | if (type & BASE) | 423 | if (type & BASE) |
| 415 | type &= BASE_TYPES; | 424 | type_mask = BASE_TYPES; |
| 416 | else if (type & SCODE) { | 425 | else if (type & SCODE) { |
| 417 | type &= SCODE_TYPES; | 426 | type &= SCODE_TYPES; |
| 418 | ign_firm_type_mask = HAS_IF; | 427 | type_mask = SCODE_TYPES & ~HAS_IF; |
| 419 | } else if (type & DTV_TYPES) | 428 | } else if (type & DTV_TYPES) |
| 420 | type &= DTV_TYPES; | 429 | type_mask = DTV_TYPES; |
| 421 | else if (type & STD_SPECIFIC_TYPES) | 430 | else if (type & STD_SPECIFIC_TYPES) |
| 422 | type &= STD_SPECIFIC_TYPES; | 431 | type_mask = STD_SPECIFIC_TYPES; |
| 432 | |||
| 433 | type &= type_mask; | ||
| 434 | |||
| 435 | if (!type & SCODE) | ||
| 436 | type_mask = ~0; | ||
| 423 | 437 | ||
| 424 | /* Seek for exact match */ | 438 | /* Seek for exact match */ |
| 425 | for (i = 0; i < priv->firm_size; i++) { | 439 | for (i = 0; i < priv->firm_size; i++) { |
| 426 | if ((type == (priv->firm[i].type & ~ign_firm_type_mask)) && | 440 | if ((type == (priv->firm[i].type & type_mask)) && |
| 427 | (*id == priv->firm[i].id)) | 441 | (*id == priv->firm[i].id)) |
| 428 | goto found; | 442 | goto found; |
| 429 | } | 443 | } |
| @@ -433,7 +447,7 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type, | |||
| 433 | v4l2_std_id match_mask; | 447 | v4l2_std_id match_mask; |
| 434 | int nr_matches; | 448 | int nr_matches; |
| 435 | 449 | ||
| 436 | if (type != (priv->firm[i].type & ~ign_firm_type_mask)) | 450 | if (type != (priv->firm[i].type & type_mask)) |
| 437 | continue; | 451 | continue; |
| 438 | 452 | ||
| 439 | match_mask = *id & priv->firm[i].id; | 453 | match_mask = *id & priv->firm[i].id; |
| @@ -483,7 +497,7 @@ static int load_firmware(struct dvb_frontend *fe, unsigned int type, | |||
| 483 | int pos, rc; | 497 | int pos, rc; |
| 484 | unsigned char *p, *endp, buf[priv->ctrl.max_len]; | 498 | unsigned char *p, *endp, buf[priv->ctrl.max_len]; |
| 485 | 499 | ||
| 486 | tuner_dbg("%s called\n", __FUNCTION__); | 500 | tuner_dbg("%s called\n", __func__); |
| 487 | 501 | ||
| 488 | pos = seek_firmware(fe, type, id); | 502 | pos = seek_firmware(fe, type, id); |
| 489 | if (pos < 0) | 503 | if (pos < 0) |
| @@ -586,7 +600,7 @@ static int load_scode(struct dvb_frontend *fe, unsigned int type, | |||
| 586 | int pos, rc; | 600 | int pos, rc; |
| 587 | unsigned char *p; | 601 | unsigned char *p; |
| 588 | 602 | ||
| 589 | tuner_dbg("%s called\n", __FUNCTION__); | 603 | tuner_dbg("%s called\n", __func__); |
| 590 | 604 | ||
| 591 | if (!int_freq) { | 605 | if (!int_freq) { |
| 592 | pos = seek_firmware(fe, type, id); | 606 | pos = seek_firmware(fe, type, id); |
| @@ -650,7 +664,7 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type, | |||
| 650 | u16 version, hwmodel; | 664 | u16 version, hwmodel; |
| 651 | v4l2_std_id std0; | 665 | v4l2_std_id std0; |
| 652 | 666 | ||
| 653 | tuner_dbg("%s called\n", __FUNCTION__); | 667 | tuner_dbg("%s called\n", __func__); |
| 654 | 668 | ||
| 655 | if (!priv->firm) { | 669 | if (!priv->firm) { |
| 656 | if (!priv->ctrl.fname) { | 670 | if (!priv->ctrl.fname) { |
| @@ -770,10 +784,10 @@ check_device: | |||
| 770 | goto fail; | 784 | goto fail; |
| 771 | } | 785 | } |
| 772 | 786 | ||
| 773 | tuner_info("Device is Xceive %d version %d.%d, " | 787 | tuner_dbg("Device is Xceive %d version %d.%d, " |
| 774 | "firmware version %d.%d\n", | 788 | "firmware version %d.%d\n", |
| 775 | hwmodel, (version & 0xf000) >> 12, (version & 0xf00) >> 8, | 789 | hwmodel, (version & 0xf000) >> 12, (version & 0xf00) >> 8, |
| 776 | (version & 0xf0) >> 4, version & 0xf); | 790 | (version & 0xf0) >> 4, version & 0xf); |
| 777 | 791 | ||
| 778 | /* Check firmware version against what we downloaded. */ | 792 | /* Check firmware version against what we downloaded. */ |
| 779 | if (priv->firm_version != ((version & 0xf0) << 4 | (version & 0x0f))) { | 793 | if (priv->firm_version != ((version & 0xf0) << 4 | (version & 0x0f))) { |
| @@ -824,27 +838,34 @@ static int xc2028_signal(struct dvb_frontend *fe, u16 *strength) | |||
| 824 | u16 frq_lock, signal = 0; | 838 | u16 frq_lock, signal = 0; |
| 825 | int rc; | 839 | int rc; |
| 826 | 840 | ||
| 827 | tuner_dbg("%s called\n", __FUNCTION__); | 841 | tuner_dbg("%s called\n", __func__); |
| 828 | 842 | ||
| 829 | mutex_lock(&priv->lock); | 843 | mutex_lock(&priv->lock); |
| 830 | 844 | ||
| 831 | /* Sync Lock Indicator */ | 845 | /* Sync Lock Indicator */ |
| 832 | rc = xc2028_get_reg(priv, 0x0002, &frq_lock); | 846 | rc = xc2028_get_reg(priv, 0x0002, &frq_lock); |
| 833 | if (rc < 0 || frq_lock == 0) | 847 | if (rc < 0) |
| 834 | goto ret; | 848 | goto ret; |
| 835 | 849 | ||
| 836 | /* Frequency is locked. Return signal quality */ | 850 | /* Frequency is locked */ |
| 851 | if (frq_lock == 1) | ||
| 852 | signal = 32768; | ||
| 837 | 853 | ||
| 838 | /* Get SNR of the video signal */ | 854 | /* Get SNR of the video signal */ |
| 839 | rc = xc2028_get_reg(priv, 0x0040, &signal); | 855 | rc = xc2028_get_reg(priv, 0x0040, &signal); |
| 840 | if (rc < 0) | 856 | if (rc < 0) |
| 841 | signal = -frq_lock; | 857 | goto ret; |
| 858 | |||
| 859 | /* Use both frq_lock and signal to generate the result */ | ||
| 860 | signal = signal || ((signal & 0x07) << 12); | ||
| 842 | 861 | ||
| 843 | ret: | 862 | ret: |
| 844 | mutex_unlock(&priv->lock); | 863 | mutex_unlock(&priv->lock); |
| 845 | 864 | ||
| 846 | *strength = signal; | 865 | *strength = signal; |
| 847 | 866 | ||
| 867 | tuner_dbg("signal strength is %d\n", signal); | ||
| 868 | |||
| 848 | return rc; | 869 | return rc; |
| 849 | } | 870 | } |
| 850 | 871 | ||
| @@ -861,7 +882,7 @@ static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */, | |||
| 861 | unsigned char buf[4]; | 882 | unsigned char buf[4]; |
| 862 | u32 div, offset = 0; | 883 | u32 div, offset = 0; |
| 863 | 884 | ||
| 864 | tuner_dbg("%s called\n", __FUNCTION__); | 885 | tuner_dbg("%s called\n", __func__); |
| 865 | 886 | ||
| 866 | mutex_lock(&priv->lock); | 887 | mutex_lock(&priv->lock); |
| 867 | 888 | ||
| @@ -906,9 +927,11 @@ static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */, | |||
| 906 | if (rc < 0) | 927 | if (rc < 0) |
| 907 | goto ret; | 928 | goto ret; |
| 908 | 929 | ||
| 909 | rc = priv->tuner_callback(priv->video_dev, XC2028_RESET_CLK, 1); | 930 | /* Return code shouldn't be checked. |
| 910 | if (rc < 0) | 931 | The reset CLK is needed only with tm6000. |
| 911 | goto ret; | 932 | Driver should work fine even if this fails. |
| 933 | */ | ||
| 934 | priv->tuner_callback(priv->video_dev, XC2028_RESET_CLK, 1); | ||
| 912 | 935 | ||
| 913 | msleep(10); | 936 | msleep(10); |
| 914 | 937 | ||
| @@ -942,7 +965,7 @@ static int xc2028_set_analog_freq(struct dvb_frontend *fe, | |||
| 942 | struct xc2028_data *priv = fe->tuner_priv; | 965 | struct xc2028_data *priv = fe->tuner_priv; |
| 943 | unsigned int type=0; | 966 | unsigned int type=0; |
| 944 | 967 | ||
| 945 | tuner_dbg("%s called\n", __FUNCTION__); | 968 | tuner_dbg("%s called\n", __func__); |
| 946 | 969 | ||
| 947 | if (p->mode == V4L2_TUNER_RADIO) { | 970 | if (p->mode == V4L2_TUNER_RADIO) { |
| 948 | type |= FM; | 971 | type |= FM; |
| @@ -975,7 +998,7 @@ static int xc2028_set_params(struct dvb_frontend *fe, | |||
| 975 | fe_bandwidth_t bw = BANDWIDTH_8_MHZ; | 998 | fe_bandwidth_t bw = BANDWIDTH_8_MHZ; |
| 976 | u16 demod = 0; | 999 | u16 demod = 0; |
| 977 | 1000 | ||
| 978 | tuner_dbg("%s called\n", __FUNCTION__); | 1001 | tuner_dbg("%s called\n", __func__); |
| 979 | 1002 | ||
| 980 | if (priv->ctrl.d2633) | 1003 | if (priv->ctrl.d2633) |
| 981 | type |= D2633; | 1004 | type |= D2633; |
| @@ -1040,33 +1063,12 @@ static int xc2028_set_params(struct dvb_frontend *fe, | |||
| 1040 | T_DIGITAL_TV, type, 0, demod); | 1063 | T_DIGITAL_TV, type, 0, demod); |
| 1041 | } | 1064 | } |
| 1042 | 1065 | ||
| 1043 | static int xc2028_sleep(struct dvb_frontend *fe) | ||
| 1044 | { | ||
| 1045 | struct xc2028_data *priv = fe->tuner_priv; | ||
| 1046 | int rc = 0; | ||
| 1047 | |||
| 1048 | tuner_dbg("%s called\n", __FUNCTION__); | ||
| 1049 | |||
| 1050 | mutex_lock(&priv->lock); | ||
| 1051 | |||
| 1052 | if (priv->firm_version < 0x0202) | ||
| 1053 | rc = send_seq(priv, {0x00, 0x08, 0x00, 0x00}); | ||
| 1054 | else | ||
| 1055 | rc = send_seq(priv, {0x80, 0x08, 0x00, 0x00}); | ||
| 1056 | |||
| 1057 | priv->cur_fw.type = 0; /* need firmware reload */ | ||
| 1058 | |||
| 1059 | mutex_unlock(&priv->lock); | ||
| 1060 | |||
| 1061 | return rc; | ||
| 1062 | } | ||
| 1063 | |||
| 1064 | 1066 | ||
| 1065 | static int xc2028_dvb_release(struct dvb_frontend *fe) | 1067 | static int xc2028_dvb_release(struct dvb_frontend *fe) |
| 1066 | { | 1068 | { |
| 1067 | struct xc2028_data *priv = fe->tuner_priv; | 1069 | struct xc2028_data *priv = fe->tuner_priv; |
| 1068 | 1070 | ||
| 1069 | tuner_dbg("%s called\n", __FUNCTION__); | 1071 | tuner_dbg("%s called\n", __func__); |
| 1070 | 1072 | ||
| 1071 | mutex_lock(&xc2028_list_mutex); | 1073 | mutex_lock(&xc2028_list_mutex); |
| 1072 | 1074 | ||
| @@ -1091,7 +1093,7 @@ static int xc2028_get_frequency(struct dvb_frontend *fe, u32 *frequency) | |||
| 1091 | { | 1093 | { |
| 1092 | struct xc2028_data *priv = fe->tuner_priv; | 1094 | struct xc2028_data *priv = fe->tuner_priv; |
| 1093 | 1095 | ||
| 1094 | tuner_dbg("%s called\n", __FUNCTION__); | 1096 | tuner_dbg("%s called\n", __func__); |
| 1095 | 1097 | ||
| 1096 | *frequency = priv->frequency; | 1098 | *frequency = priv->frequency; |
| 1097 | 1099 | ||
| @@ -1104,25 +1106,25 @@ static int xc2028_set_config(struct dvb_frontend *fe, void *priv_cfg) | |||
| 1104 | struct xc2028_ctrl *p = priv_cfg; | 1106 | struct xc2028_ctrl *p = priv_cfg; |
| 1105 | int rc = 0; | 1107 | int rc = 0; |
| 1106 | 1108 | ||
| 1107 | tuner_dbg("%s called\n", __FUNCTION__); | 1109 | tuner_dbg("%s called\n", __func__); |
| 1108 | 1110 | ||
| 1109 | mutex_lock(&priv->lock); | 1111 | mutex_lock(&priv->lock); |
| 1110 | 1112 | ||
| 1111 | kfree(priv->ctrl.fname); | ||
| 1112 | free_firmware(priv); | ||
| 1113 | |||
| 1114 | memcpy(&priv->ctrl, p, sizeof(priv->ctrl)); | 1113 | memcpy(&priv->ctrl, p, sizeof(priv->ctrl)); |
| 1115 | priv->ctrl.fname = NULL; | 1114 | if (priv->ctrl.max_len < 9) |
| 1115 | priv->ctrl.max_len = 13; | ||
| 1116 | 1116 | ||
| 1117 | if (p->fname) { | 1117 | if (p->fname) { |
| 1118 | if (priv->ctrl.fname && strcmp(p->fname, priv->ctrl.fname)) { | ||
| 1119 | kfree(priv->ctrl.fname); | ||
| 1120 | free_firmware(priv); | ||
| 1121 | } | ||
| 1122 | |||
| 1118 | priv->ctrl.fname = kstrdup(p->fname, GFP_KERNEL); | 1123 | priv->ctrl.fname = kstrdup(p->fname, GFP_KERNEL); |
| 1119 | if (priv->ctrl.fname == NULL) | 1124 | if (priv->ctrl.fname == NULL) |
| 1120 | rc = -ENOMEM; | 1125 | rc = -ENOMEM; |
| 1121 | } | 1126 | } |
| 1122 | 1127 | ||
| 1123 | if (priv->ctrl.max_len < 9) | ||
| 1124 | priv->ctrl.max_len = 13; | ||
| 1125 | |||
| 1126 | mutex_unlock(&priv->lock); | 1128 | mutex_unlock(&priv->lock); |
| 1127 | 1129 | ||
| 1128 | return rc; | 1130 | return rc; |
| @@ -1142,8 +1144,6 @@ static const struct dvb_tuner_ops xc2028_dvb_tuner_ops = { | |||
| 1142 | .get_frequency = xc2028_get_frequency, | 1144 | .get_frequency = xc2028_get_frequency, |
| 1143 | .get_rf_strength = xc2028_signal, | 1145 | .get_rf_strength = xc2028_signal, |
| 1144 | .set_params = xc2028_set_params, | 1146 | .set_params = xc2028_set_params, |
| 1145 | .sleep = xc2028_sleep, | ||
| 1146 | |||
| 1147 | }; | 1147 | }; |
| 1148 | 1148 | ||
| 1149 | struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe, | 1149 | struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe, |
| @@ -1153,23 +1153,29 @@ struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe, | |||
| 1153 | void *video_dev; | 1153 | void *video_dev; |
| 1154 | 1154 | ||
| 1155 | if (debug) | 1155 | if (debug) |
| 1156 | printk(KERN_DEBUG PREFIX ": Xcv2028/3028 init called!\n"); | 1156 | printk(KERN_DEBUG "xc2028: Xcv2028/3028 init called!\n"); |
| 1157 | 1157 | ||
| 1158 | if (NULL == cfg || NULL == cfg->video_dev) | 1158 | if (NULL == cfg) |
| 1159 | return NULL; | 1159 | return NULL; |
| 1160 | 1160 | ||
| 1161 | if (!fe) { | 1161 | if (!fe) { |
| 1162 | printk(KERN_ERR PREFIX ": No frontend!\n"); | 1162 | printk(KERN_ERR "xc2028: No frontend!\n"); |
| 1163 | return NULL; | 1163 | return NULL; |
| 1164 | } | 1164 | } |
| 1165 | 1165 | ||
| 1166 | video_dev = cfg->video_dev; | 1166 | video_dev = cfg->i2c_adap->algo_data; |
| 1167 | |||
| 1168 | if (debug) | ||
| 1169 | printk(KERN_DEBUG "xc2028: video_dev =%p\n", video_dev); | ||
| 1167 | 1170 | ||
| 1168 | mutex_lock(&xc2028_list_mutex); | 1171 | mutex_lock(&xc2028_list_mutex); |
| 1169 | 1172 | ||
| 1170 | list_for_each_entry(priv, &xc2028_list, xc2028_list) { | 1173 | list_for_each_entry(priv, &xc2028_list, xc2028_list) { |
| 1171 | if (priv->video_dev == cfg->video_dev) { | 1174 | if (&priv->i2c_props.adap->dev == &cfg->i2c_adap->dev) { |
| 1172 | video_dev = NULL; | 1175 | video_dev = NULL; |
| 1176 | if (debug) | ||
| 1177 | printk(KERN_DEBUG "xc2028: reusing device\n"); | ||
| 1178 | |||
| 1173 | break; | 1179 | break; |
| 1174 | } | 1180 | } |
| 1175 | } | 1181 | } |
| @@ -1183,6 +1189,8 @@ struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe, | |||
| 1183 | 1189 | ||
| 1184 | priv->i2c_props.addr = cfg->i2c_addr; | 1190 | priv->i2c_props.addr = cfg->i2c_addr; |
| 1185 | priv->i2c_props.adap = cfg->i2c_adap; | 1191 | priv->i2c_props.adap = cfg->i2c_adap; |
| 1192 | priv->i2c_props.name = "xc2028"; | ||
| 1193 | |||
| 1186 | priv->video_dev = video_dev; | 1194 | priv->video_dev = video_dev; |
| 1187 | priv->tuner_callback = cfg->callback; | 1195 | priv->tuner_callback = cfg->callback; |
| 1188 | priv->ctrl.max_len = 13; | 1196 | priv->ctrl.max_len = 13; |
| @@ -1195,6 +1203,9 @@ struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe, | |||
| 1195 | fe->tuner_priv = priv; | 1203 | fe->tuner_priv = priv; |
| 1196 | priv->count++; | 1204 | priv->count++; |
| 1197 | 1205 | ||
| 1206 | if (debug) | ||
| 1207 | printk(KERN_DEBUG "xc2028: usage count is %i\n", priv->count); | ||
| 1208 | |||
| 1198 | memcpy(&fe->ops.tuner_ops, &xc2028_dvb_tuner_ops, | 1209 | memcpy(&fe->ops.tuner_ops, &xc2028_dvb_tuner_ops, |
| 1199 | sizeof(xc2028_dvb_tuner_ops)); | 1210 | sizeof(xc2028_dvb_tuner_ops)); |
| 1200 | 1211 | ||
diff --git a/drivers/media/video/tuner-xc2028.h b/drivers/media/video/tuner-xc2028.h index 3eb8420379a4..fc2f132a5541 100644 --- a/drivers/media/video/tuner-xc2028.h +++ b/drivers/media/video/tuner-xc2028.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* tuner-xc2028 | 1 | /* tuner-xc2028 |
| 2 | * | 2 | * |
| 3 | * Copyright (c) 2007 Mauro Carvalho Chehab (mchehab@infradead.org) | 3 | * Copyright (c) 2007-2008 Mauro Carvalho Chehab (mchehab@infradead.org) |
| 4 | * This code is placed under the terms of the GNU General Public License v2 | 4 | * This code is placed under the terms of the GNU General Public License v2 |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| @@ -12,7 +12,7 @@ | |||
| 12 | #define XC2028_DEFAULT_FIRMWARE "xc3028-v27.fw" | 12 | #define XC2028_DEFAULT_FIRMWARE "xc3028-v27.fw" |
| 13 | 13 | ||
| 14 | /* Dmoduler IF (kHz) */ | 14 | /* Dmoduler IF (kHz) */ |
| 15 | #define XC3028_FE_DEFAULT 0 | 15 | #define XC3028_FE_DEFAULT 0 /* Don't load SCODE */ |
| 16 | #define XC3028_FE_LG60 6000 | 16 | #define XC3028_FE_LG60 6000 |
| 17 | #define XC3028_FE_ATI638 6380 | 17 | #define XC3028_FE_ATI638 6380 |
| 18 | #define XC3028_FE_OREN538 5380 | 18 | #define XC3028_FE_OREN538 5380 |
| @@ -55,7 +55,7 @@ static inline struct dvb_frontend *xc2028_attach(struct dvb_frontend *fe, | |||
| 55 | struct xc2028_config *cfg) | 55 | struct xc2028_config *cfg) |
| 56 | { | 56 | { |
| 57 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", | 57 | printk(KERN_INFO "%s: not probed - driver disabled by Kconfig\n", |
| 58 | __FUNCTION__); | 58 | __func__); |
| 59 | return NULL; | 59 | return NULL; |
| 60 | } | 60 | } |
| 61 | #endif | 61 | #endif |
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index 01ebcec040c4..f29a2cd0f2f2 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | /* ---------------------------------------------------------------------- */ | 38 | /* ---------------------------------------------------------------------- */ |
| 39 | /* insmod args */ | 39 | /* insmod args */ |
| 40 | 40 | ||
| 41 | static int debug = 0; /* insmod parameter */ | 41 | static int debug; /* insmod parameter */ |
| 42 | module_param(debug, int, 0644); | 42 | module_param(debug, int, 0644); |
| 43 | 43 | ||
| 44 | MODULE_DESCRIPTION("device driver for various i2c TV sound decoder / audiomux chips"); | 44 | MODULE_DESCRIPTION("device driver for various i2c TV sound decoder / audiomux chips"); |
| @@ -1235,11 +1235,11 @@ static int tda9850 = 1; | |||
| 1235 | static int tda9855 = 1; | 1235 | static int tda9855 = 1; |
| 1236 | static int tda9873 = 1; | 1236 | static int tda9873 = 1; |
| 1237 | static int tda9874a = 1; | 1237 | static int tda9874a = 1; |
| 1238 | static int tea6300 = 0; /* address clash with msp34xx */ | 1238 | static int tea6300; /* default 0 - address clash with msp34xx */ |
| 1239 | static int tea6320 = 0; /* address clash with msp34xx */ | 1239 | static int tea6320; /* default 0 - address clash with msp34xx */ |
| 1240 | static int tea6420 = 1; | 1240 | static int tea6420 = 1; |
| 1241 | static int pic16c54 = 1; | 1241 | static int pic16c54 = 1; |
| 1242 | static int ta8874z = 0; /* address clash with tda9840 */ | 1242 | static int ta8874z; /* default 0 - address clash with tda9840 */ |
| 1243 | 1243 | ||
| 1244 | module_param(tda8425, int, 0444); | 1244 | module_param(tda8425, int, 0444); |
| 1245 | module_param(tda9840, int, 0444); | 1245 | module_param(tda9840, int, 0444); |
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c index dc0da44a5af6..3cf8a8e801e5 100644 --- a/drivers/media/video/tveeprom.c +++ b/drivers/media/video/tveeprom.c | |||
| @@ -745,109 +745,6 @@ int tveeprom_read(struct i2c_client *c, unsigned char *eedata, int len) | |||
| 745 | } | 745 | } |
| 746 | EXPORT_SYMBOL(tveeprom_read); | 746 | EXPORT_SYMBOL(tveeprom_read); |
| 747 | 747 | ||
| 748 | /* ----------------------------------------------------------------------- */ | ||
| 749 | /* needed for ivtv.sf.net at the moment. Should go away in the long */ | ||
| 750 | /* run, just call the exported tveeprom_* directly, there is no point in */ | ||
| 751 | /* using the indirect way via i2c_driver->command() */ | ||
| 752 | |||
| 753 | static unsigned short normal_i2c[] = { | ||
| 754 | 0xa0 >> 1, | ||
| 755 | I2C_CLIENT_END, | ||
| 756 | }; | ||
| 757 | |||
| 758 | I2C_CLIENT_INSMOD; | ||
| 759 | |||
| 760 | static struct i2c_driver i2c_driver_tveeprom; | ||
| 761 | |||
| 762 | static int | ||
| 763 | tveeprom_command(struct i2c_client *client, | ||
| 764 | unsigned int cmd, | ||
| 765 | void *arg) | ||
| 766 | { | ||
| 767 | struct tveeprom eeprom; | ||
| 768 | u32 *eeprom_props = arg; | ||
| 769 | u8 *buf; | ||
| 770 | |||
| 771 | switch (cmd) { | ||
| 772 | case 0: | ||
| 773 | buf = kzalloc(256, GFP_KERNEL); | ||
| 774 | tveeprom_read(client, buf, 256); | ||
| 775 | tveeprom_hauppauge_analog(client, &eeprom, buf); | ||
| 776 | kfree(buf); | ||
| 777 | eeprom_props[0] = eeprom.tuner_type; | ||
| 778 | eeprom_props[1] = eeprom.tuner_formats; | ||
| 779 | eeprom_props[2] = eeprom.model; | ||
| 780 | eeprom_props[3] = eeprom.revision; | ||
| 781 | eeprom_props[4] = eeprom.has_radio; | ||
| 782 | break; | ||
| 783 | default: | ||
| 784 | return -EINVAL; | ||
| 785 | } | ||
| 786 | return 0; | ||
| 787 | } | ||
| 788 | |||
| 789 | static int | ||
| 790 | tveeprom_detect_client(struct i2c_adapter *adapter, | ||
| 791 | int address, | ||
| 792 | int kind) | ||
| 793 | { | ||
| 794 | struct i2c_client *client; | ||
| 795 | |||
| 796 | client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); | ||
| 797 | if (NULL == client) | ||
| 798 | return -ENOMEM; | ||
| 799 | client->addr = address; | ||
| 800 | client->adapter = adapter; | ||
| 801 | client->driver = &i2c_driver_tveeprom; | ||
| 802 | snprintf(client->name, sizeof(client->name), "tveeprom"); | ||
| 803 | i2c_attach_client(client); | ||
| 804 | |||
| 805 | return 0; | ||
| 806 | } | ||
| 807 | |||
| 808 | static int | ||
| 809 | tveeprom_attach_adapter(struct i2c_adapter *adapter) | ||
| 810 | { | ||
| 811 | if (adapter->class & I2C_CLASS_TV_ANALOG) | ||
| 812 | return i2c_probe(adapter, &addr_data, tveeprom_detect_client); | ||
| 813 | return 0; | ||
| 814 | } | ||
| 815 | |||
| 816 | static int | ||
| 817 | tveeprom_detach_client(struct i2c_client *client) | ||
| 818 | { | ||
| 819 | int err; | ||
| 820 | |||
| 821 | err = i2c_detach_client(client); | ||
| 822 | if (err < 0) | ||
| 823 | return err; | ||
| 824 | kfree(client); | ||
| 825 | return 0; | ||
| 826 | } | ||
| 827 | |||
| 828 | static struct i2c_driver i2c_driver_tveeprom = { | ||
| 829 | .driver = { | ||
| 830 | .name = "tveeprom", | ||
| 831 | }, | ||
| 832 | .id = I2C_DRIVERID_TVEEPROM, | ||
| 833 | .attach_adapter = tveeprom_attach_adapter, | ||
| 834 | .detach_client = tveeprom_detach_client, | ||
| 835 | .command = tveeprom_command, | ||
| 836 | }; | ||
| 837 | |||
| 838 | static int __init tveeprom_init(void) | ||
| 839 | { | ||
| 840 | return i2c_add_driver(&i2c_driver_tveeprom); | ||
| 841 | } | ||
| 842 | |||
| 843 | static void __exit tveeprom_exit(void) | ||
| 844 | { | ||
| 845 | i2c_del_driver(&i2c_driver_tveeprom); | ||
| 846 | } | ||
| 847 | |||
| 848 | module_init(tveeprom_init); | ||
| 849 | module_exit(tveeprom_exit); | ||
| 850 | |||
| 851 | /* | 748 | /* |
| 852 | * Local variables: | 749 | * Local variables: |
| 853 | * c-basic-offset: 8 | 750 | * c-basic-offset: 8 |
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c index b6e24e714a23..6a3af1005f03 100644 --- a/drivers/media/video/tvp5150.c +++ b/drivers/media/video/tvp5150.c | |||
| @@ -27,7 +27,7 @@ static unsigned short normal_i2c[] = { | |||
| 27 | 27 | ||
| 28 | I2C_CLIENT_INSMOD; | 28 | I2C_CLIENT_INSMOD; |
| 29 | 29 | ||
| 30 | static int debug = 0; | 30 | static int debug; |
| 31 | module_param(debug, int, 0); | 31 | module_param(debug, int, 0); |
| 32 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 32 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 33 | 33 | ||
diff --git a/drivers/media/video/usbvideo/ibmcam.c b/drivers/media/video/usbvideo/ibmcam.c index 14db95e10cfe..59166b760104 100644 --- a/drivers/media/video/usbvideo/ibmcam.c +++ b/drivers/media/video/usbvideo/ibmcam.c | |||
| @@ -121,7 +121,7 @@ static int init_model2_yb = -1; | |||
| 121 | 121 | ||
| 122 | /* 01.01.08 - Added for RCA video in support -LO */ | 122 | /* 01.01.08 - Added for RCA video in support -LO */ |
| 123 | /* Settings for camera model 3 */ | 123 | /* Settings for camera model 3 */ |
| 124 | static int init_model3_input = 0; | 124 | static int init_model3_input; |
| 125 | 125 | ||
| 126 | module_param(debug, int, 0); | 126 | module_param(debug, int, 0); |
| 127 | MODULE_PARM_DESC(debug, "Debug level: 0-9 (default=0)"); | 127 | MODULE_PARM_DESC(debug, "Debug level: 0-9 (default=0)"); |
| @@ -802,6 +802,21 @@ static enum ParseState ibmcam_model2_320x240_parse_lines( | |||
| 802 | return scan_Continue; | 802 | return scan_Continue; |
| 803 | } | 803 | } |
| 804 | 804 | ||
| 805 | /* | ||
| 806 | * ibmcam_model3_parse_lines() | ||
| 807 | * | ||
| 808 | * | Even lines | Odd Lines | | ||
| 809 | * -----------------------------------| | ||
| 810 | * |YYY........Y|UYVYUYVY.........UYVY| | ||
| 811 | * |YYY........Y|UYVYUYVY.........UYVY| | ||
| 812 | * |............|.....................| | ||
| 813 | * |YYY........Y|UYVYUYVY.........UYVY| | ||
| 814 | * |------------+---------------------| | ||
| 815 | * | ||
| 816 | * There is one (U, V) chroma pair for every four luma (Y) values. This | ||
| 817 | * function reads a pair of lines at a time and obtains missing chroma values | ||
| 818 | * from adjacent pixels. | ||
| 819 | */ | ||
| 805 | static enum ParseState ibmcam_model3_parse_lines( | 820 | static enum ParseState ibmcam_model3_parse_lines( |
| 806 | struct uvd *uvd, | 821 | struct uvd *uvd, |
| 807 | struct usbvideo_frame *frame, | 822 | struct usbvideo_frame *frame, |
| @@ -816,6 +831,7 @@ static enum ParseState ibmcam_model3_parse_lines( | |||
| 816 | const int ccm = 128; /* Color correction median - see below */ | 831 | const int ccm = 128; /* Color correction median - see below */ |
| 817 | int i, u, v, rw, data_w=0, data_h=0, color_corr; | 832 | int i, u, v, rw, data_w=0, data_h=0, color_corr; |
| 818 | static unsigned char lineBuffer[640*3]; | 833 | static unsigned char lineBuffer[640*3]; |
| 834 | int line; | ||
| 819 | 835 | ||
| 820 | color_corr = (uvd->vpic.colour - 0x8000) >> 8; /* -128..+127 = -ccm..+(ccm-1)*/ | 836 | color_corr = (uvd->vpic.colour - 0x8000) >> 8; /* -128..+127 = -ccm..+(ccm-1)*/ |
| 821 | RESTRICT_TO_RANGE(color_corr, -ccm, ccm+1); | 837 | RESTRICT_TO_RANGE(color_corr, -ccm, ccm+1); |
| @@ -869,15 +885,15 @@ static enum ParseState ibmcam_model3_parse_lines( | |||
| 869 | return scan_NextFrame; | 885 | return scan_NextFrame; |
| 870 | } | 886 | } |
| 871 | 887 | ||
| 872 | /* Make sure there's enough data for the entire line */ | 888 | /* Make sure that lineBuffer can store two lines of data */ |
| 873 | len = 3 * data_w; /* <y-data> <uv-data> */ | 889 | len = 3 * data_w; /* <y-data> <uyvy-data> */ |
| 874 | assert(len <= sizeof(lineBuffer)); | 890 | assert(len <= sizeof(lineBuffer)); |
| 875 | 891 | ||
| 876 | /* Make sure there's enough data for the entire line */ | 892 | /* Make sure there's enough data for two lines */ |
| 877 | if (RingQueue_GetLength(&uvd->dp) < len) | 893 | if (RingQueue_GetLength(&uvd->dp) < len) |
| 878 | return scan_Out; | 894 | return scan_Out; |
| 879 | 895 | ||
| 880 | /* Suck one line out of the ring queue */ | 896 | /* Suck two lines of data out of the ring queue */ |
| 881 | RingQueue_Dequeue(&uvd->dp, lineBuffer, len); | 897 | RingQueue_Dequeue(&uvd->dp, lineBuffer, len); |
| 882 | 898 | ||
| 883 | data = lineBuffer; | 899 | data = lineBuffer; |
| @@ -887,15 +903,23 @@ static enum ParseState ibmcam_model3_parse_lines( | |||
| 887 | rw = (int)VIDEOSIZE_Y(frame->request) - (int)(frame->curline) - 1; | 903 | rw = (int)VIDEOSIZE_Y(frame->request) - (int)(frame->curline) - 1; |
| 888 | RESTRICT_TO_RANGE(rw, 0, VIDEOSIZE_Y(frame->request)-1); | 904 | RESTRICT_TO_RANGE(rw, 0, VIDEOSIZE_Y(frame->request)-1); |
| 889 | 905 | ||
| 890 | for (i = 0; i < VIDEOSIZE_X(frame->request); i++) { | 906 | /* Iterate over two lines. */ |
| 891 | int y, rv, gv, bv; /* RGB components */ | 907 | for (line = 0; line < 2; line++) { |
| 908 | for (i = 0; i < VIDEOSIZE_X(frame->request); i++) { | ||
| 909 | int y; | ||
| 910 | int rv, gv, bv; /* RGB components */ | ||
| 892 | 911 | ||
| 893 | if (i < data_w) { | 912 | if (i >= data_w) { |
| 894 | y = data[i]; /* Luminosity is the first line */ | 913 | RGB24_PUTPIXEL(frame, i, rw, 0, 0, 0); |
| 914 | continue; | ||
| 915 | } | ||
| 916 | |||
| 917 | /* first line is YYY...Y; second is UYVY...UYVY */ | ||
| 918 | y = data[(line == 0) ? i : (i*2 + 1)]; | ||
| 895 | 919 | ||
| 896 | /* Apply static color correction */ | 920 | /* Apply static color correction */ |
| 897 | u = color[i*2] + hue_corr; | 921 | u = color[(i/2)*4] + hue_corr; |
| 898 | v = color[i*2 + 1] + hue2_corr; | 922 | v = color[(i/2)*4 + 2] + hue2_corr; |
| 899 | 923 | ||
| 900 | /* Apply color correction */ | 924 | /* Apply color correction */ |
| 901 | if (color_corr != 0) { | 925 | if (color_corr != 0) { |
| @@ -903,13 +927,21 @@ static enum ParseState ibmcam_model3_parse_lines( | |||
| 903 | u = 128 + ((ccm + color_corr) * (u - 128)) / ccm; | 927 | u = 128 + ((ccm + color_corr) * (u - 128)) / ccm; |
| 904 | v = 128 + ((ccm + color_corr) * (v - 128)) / ccm; | 928 | v = 128 + ((ccm + color_corr) * (v - 128)) / ccm; |
| 905 | } | 929 | } |
| 906 | } else | ||
| 907 | y = 0, u = v = 128; | ||
| 908 | 930 | ||
| 909 | YUV_TO_RGB_BY_THE_BOOK(y, u, v, rv, gv, bv); | 931 | |
| 910 | RGB24_PUTPIXEL(frame, i, rw, rv, gv, bv); /* Done by deinterlacing now */ | 932 | YUV_TO_RGB_BY_THE_BOOK(y, u, v, rv, gv, bv); |
| 933 | RGB24_PUTPIXEL(frame, i, rw, rv, gv, bv); /* No deinterlacing */ | ||
| 934 | } | ||
| 935 | |||
| 936 | /* Check for the end of requested data */ | ||
| 937 | if (rw == 0) | ||
| 938 | break; | ||
| 939 | |||
| 940 | /* Prepare for the second line */ | ||
| 941 | rw--; | ||
| 942 | data = lineBuffer + data_w; | ||
| 911 | } | 943 | } |
| 912 | frame->deinterlace = Deinterlace_FillEvenLines; | 944 | frame->deinterlace = Deinterlace_None; |
| 913 | 945 | ||
| 914 | /* | 946 | /* |
| 915 | * Account for number of bytes that we wrote into output V4L frame. | 947 | * Account for number of bytes that we wrote into output V4L frame. |
diff --git a/drivers/media/video/usbvideo/konicawc.c b/drivers/media/video/usbvideo/konicawc.c index 719b17ce83f8..1c180284ec6c 100644 --- a/drivers/media/video/usbvideo/konicawc.c +++ b/drivers/media/video/usbvideo/konicawc.c | |||
| @@ -57,11 +57,11 @@ static struct usbvideo *cams; | |||
| 57 | static int debug; | 57 | static int debug; |
| 58 | #define DEBUG(n, format, arg...) \ | 58 | #define DEBUG(n, format, arg...) \ |
| 59 | if (n <= debug) { \ | 59 | if (n <= debug) { \ |
| 60 | printk(KERN_DEBUG __FILE__ ":%s(): " format "\n", __FUNCTION__ , ## arg); \ | 60 | printk(KERN_DEBUG __FILE__ ":%s(): " format "\n", __func__ , ## arg); \ |
| 61 | } | 61 | } |
| 62 | #else | 62 | #else |
| 63 | #define DEBUG(n, arg...) | 63 | #define DEBUG(n, arg...) |
| 64 | static const int debug = 0; | 64 | static const int debug; |
| 65 | #endif | 65 | #endif |
| 66 | 66 | ||
| 67 | 67 | ||
diff --git a/drivers/media/video/usbvideo/quickcam_messenger.c b/drivers/media/video/usbvideo/quickcam_messenger.c index a2acba0bcc47..32e536edf09d 100644 --- a/drivers/media/video/usbvideo/quickcam_messenger.c +++ b/drivers/media/video/usbvideo/quickcam_messenger.c | |||
| @@ -46,11 +46,11 @@ | |||
| 46 | static int debug; | 46 | static int debug; |
| 47 | #define DEBUG(n, format, arg...) \ | 47 | #define DEBUG(n, format, arg...) \ |
| 48 | if (n <= debug) { \ | 48 | if (n <= debug) { \ |
| 49 | printk(KERN_DEBUG __FILE__ ":%s(): " format "\n", __FUNCTION__ , ## arg); \ | 49 | printk(KERN_DEBUG __FILE__ ":%s(): " format "\n", __func__ , ## arg); \ |
| 50 | } | 50 | } |
| 51 | #else | 51 | #else |
| 52 | #define DEBUG(n, arg...) | 52 | #define DEBUG(n, arg...) |
| 53 | static const int debug = 0; | 53 | static const int debug; |
| 54 | #endif | 54 | #endif |
| 55 | 55 | ||
| 56 | #define DRIVER_VERSION "v0.01" | 56 | #define DRIVER_VERSION "v0.01" |
diff --git a/drivers/media/video/usbvideo/ultracam.c b/drivers/media/video/usbvideo/ultracam.c index 95453c108d40..9544e644bf0d 100644 --- a/drivers/media/video/usbvideo/ultracam.c +++ b/drivers/media/video/usbvideo/ultracam.c | |||
| @@ -28,9 +28,9 @@ typedef struct { | |||
| 28 | 28 | ||
| 29 | static struct usbvideo *cams = NULL; | 29 | static struct usbvideo *cams = NULL; |
| 30 | 30 | ||
| 31 | static int debug = 0; | 31 | static int debug; |
| 32 | 32 | ||
| 33 | static int flags = 0; /* FLAGS_DISPLAY_HINTS | FLAGS_OVERLAY_STATS; */ | 33 | static int flags; /* FLAGS_DISPLAY_HINTS | FLAGS_OVERLAY_STATS; */ |
| 34 | 34 | ||
| 35 | static const int min_canvasWidth = 8; | 35 | static const int min_canvasWidth = 8; |
| 36 | static const int min_canvasHeight = 4; | 36 | static const int min_canvasHeight = 4; |
diff --git a/drivers/media/video/usbvideo/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c index 5d363be7bc73..4128ee20b64e 100644 --- a/drivers/media/video/usbvideo/usbvideo.c +++ b/drivers/media/video/usbvideo/usbvideo.c | |||
| @@ -522,14 +522,14 @@ void usbvideo_TestPattern(struct uvd *uvd, int fullframe, int pmode) | |||
| 522 | struct usbvideo_frame *frame; | 522 | struct usbvideo_frame *frame; |
| 523 | int num_cell = 0; | 523 | int num_cell = 0; |
| 524 | int scan_length = 0; | 524 | int scan_length = 0; |
| 525 | static int num_pass = 0; | 525 | static int num_pass; |
| 526 | 526 | ||
| 527 | if (uvd == NULL) { | 527 | if (uvd == NULL) { |
| 528 | err("%s: uvd == NULL", __FUNCTION__); | 528 | err("%s: uvd == NULL", __func__); |
| 529 | return; | 529 | return; |
| 530 | } | 530 | } |
| 531 | if ((uvd->curframe < 0) || (uvd->curframe >= USBVIDEO_NUMFRAMES)) { | 531 | if ((uvd->curframe < 0) || (uvd->curframe >= USBVIDEO_NUMFRAMES)) { |
| 532 | err("%s: uvd->curframe=%d.", __FUNCTION__, uvd->curframe); | 532 | err("%s: uvd->curframe=%d.", __func__, uvd->curframe); |
| 533 | return; | 533 | return; |
| 534 | } | 534 | } |
| 535 | 535 | ||
| @@ -630,15 +630,15 @@ EXPORT_SYMBOL(usbvideo_HexDump); | |||
| 630 | static int usbvideo_ClientIncModCount(struct uvd *uvd) | 630 | static int usbvideo_ClientIncModCount(struct uvd *uvd) |
| 631 | { | 631 | { |
| 632 | if (uvd == NULL) { | 632 | if (uvd == NULL) { |
| 633 | err("%s: uvd == NULL", __FUNCTION__); | 633 | err("%s: uvd == NULL", __func__); |
| 634 | return -EINVAL; | 634 | return -EINVAL; |
| 635 | } | 635 | } |
| 636 | if (uvd->handle == NULL) { | 636 | if (uvd->handle == NULL) { |
| 637 | err("%s: uvd->handle == NULL", __FUNCTION__); | 637 | err("%s: uvd->handle == NULL", __func__); |
| 638 | return -EINVAL; | 638 | return -EINVAL; |
| 639 | } | 639 | } |
| 640 | if (!try_module_get(uvd->handle->md_module)) { | 640 | if (!try_module_get(uvd->handle->md_module)) { |
| 641 | err("%s: try_module_get() == 0", __FUNCTION__); | 641 | err("%s: try_module_get() == 0", __func__); |
| 642 | return -ENODEV; | 642 | return -ENODEV; |
| 643 | } | 643 | } |
| 644 | return 0; | 644 | return 0; |
| @@ -647,15 +647,15 @@ static int usbvideo_ClientIncModCount(struct uvd *uvd) | |||
| 647 | static void usbvideo_ClientDecModCount(struct uvd *uvd) | 647 | static void usbvideo_ClientDecModCount(struct uvd *uvd) |
| 648 | { | 648 | { |
| 649 | if (uvd == NULL) { | 649 | if (uvd == NULL) { |
| 650 | err("%s: uvd == NULL", __FUNCTION__); | 650 | err("%s: uvd == NULL", __func__); |
| 651 | return; | 651 | return; |
| 652 | } | 652 | } |
| 653 | if (uvd->handle == NULL) { | 653 | if (uvd->handle == NULL) { |
| 654 | err("%s: uvd->handle == NULL", __FUNCTION__); | 654 | err("%s: uvd->handle == NULL", __func__); |
| 655 | return; | 655 | return; |
| 656 | } | 656 | } |
| 657 | if (uvd->handle->md_module == NULL) { | 657 | if (uvd->handle->md_module == NULL) { |
| 658 | err("%s: uvd->handle->md_module == NULL", __FUNCTION__); | 658 | err("%s: uvd->handle->md_module == NULL", __func__); |
| 659 | return; | 659 | return; |
| 660 | } | 660 | } |
| 661 | module_put(uvd->handle->md_module); | 661 | module_put(uvd->handle->md_module); |
| @@ -675,13 +675,13 @@ int usbvideo_register( | |||
| 675 | 675 | ||
| 676 | /* Check parameters for sanity */ | 676 | /* Check parameters for sanity */ |
| 677 | if ((num_cams <= 0) || (pCams == NULL) || (cbTbl == NULL)) { | 677 | if ((num_cams <= 0) || (pCams == NULL) || (cbTbl == NULL)) { |
| 678 | err("%s: Illegal call", __FUNCTION__); | 678 | err("%s: Illegal call", __func__); |
| 679 | return -EINVAL; | 679 | return -EINVAL; |
| 680 | } | 680 | } |
| 681 | 681 | ||
| 682 | /* Check registration callback - must be set! */ | 682 | /* Check registration callback - must be set! */ |
| 683 | if (cbTbl->probe == NULL) { | 683 | if (cbTbl->probe == NULL) { |
| 684 | err("%s: probe() is required!", __FUNCTION__); | 684 | err("%s: probe() is required!", __func__); |
| 685 | return -EINVAL; | 685 | return -EINVAL; |
| 686 | } | 686 | } |
| 687 | 687 | ||
| @@ -692,7 +692,7 @@ int usbvideo_register( | |||
| 692 | return -ENOMEM; | 692 | return -ENOMEM; |
| 693 | } | 693 | } |
| 694 | dbg("%s: Allocated $%p (%d. bytes) for %d. cameras", | 694 | dbg("%s: Allocated $%p (%d. bytes) for %d. cameras", |
| 695 | __FUNCTION__, cams, base_size, num_cams); | 695 | __func__, cams, base_size, num_cams); |
| 696 | 696 | ||
| 697 | /* Copy callbacks, apply defaults for those that are not set */ | 697 | /* Copy callbacks, apply defaults for those that are not set */ |
| 698 | memmove(&cams->cb, cbTbl, sizeof(cams->cb)); | 698 | memmove(&cams->cb, cbTbl, sizeof(cams->cb)); |
| @@ -721,7 +721,7 @@ int usbvideo_register( | |||
| 721 | up->user_data = kmalloc(up->user_size, GFP_KERNEL); | 721 | up->user_data = kmalloc(up->user_size, GFP_KERNEL); |
| 722 | if (up->user_data == NULL) { | 722 | if (up->user_data == NULL) { |
| 723 | err("%s: Failed to allocate user_data (%d. bytes)", | 723 | err("%s: Failed to allocate user_data (%d. bytes)", |
| 724 | __FUNCTION__, up->user_size); | 724 | __func__, up->user_size); |
| 725 | while (i) { | 725 | while (i) { |
| 726 | up = &cams->cam[--i]; | 726 | up = &cams->cam[--i]; |
| 727 | kfree(up->user_data); | 727 | kfree(up->user_data); |
| @@ -730,7 +730,7 @@ int usbvideo_register( | |||
| 730 | return -ENOMEM; | 730 | return -ENOMEM; |
| 731 | } | 731 | } |
| 732 | dbg("%s: Allocated cams[%d].user_data=$%p (%d. bytes)", | 732 | dbg("%s: Allocated cams[%d].user_data=$%p (%d. bytes)", |
| 733 | __FUNCTION__, i, up->user_data, up->user_size); | 733 | __func__, i, up->user_data, up->user_size); |
| 734 | } | 734 | } |
| 735 | } | 735 | } |
| 736 | 736 | ||
| @@ -776,19 +776,19 @@ void usbvideo_Deregister(struct usbvideo **pCams) | |||
| 776 | int i; | 776 | int i; |
| 777 | 777 | ||
| 778 | if (pCams == NULL) { | 778 | if (pCams == NULL) { |
| 779 | err("%s: pCams == NULL", __FUNCTION__); | 779 | err("%s: pCams == NULL", __func__); |
| 780 | return; | 780 | return; |
| 781 | } | 781 | } |
| 782 | cams = *pCams; | 782 | cams = *pCams; |
| 783 | if (cams == NULL) { | 783 | if (cams == NULL) { |
| 784 | err("%s: cams == NULL", __FUNCTION__); | 784 | err("%s: cams == NULL", __func__); |
| 785 | return; | 785 | return; |
| 786 | } | 786 | } |
| 787 | 787 | ||
| 788 | dbg("%s: Deregistering %s driver.", __FUNCTION__, cams->drvName); | 788 | dbg("%s: Deregistering %s driver.", __func__, cams->drvName); |
| 789 | usb_deregister(&cams->usbdrv); | 789 | usb_deregister(&cams->usbdrv); |
| 790 | 790 | ||
| 791 | dbg("%s: Deallocating cams=$%p (%d. cameras)", __FUNCTION__, cams, cams->num_cameras); | 791 | dbg("%s: Deallocating cams=$%p (%d. cameras)", __func__, cams, cams->num_cameras); |
| 792 | for (i=0; i < cams->num_cameras; i++) { | 792 | for (i=0; i < cams->num_cameras; i++) { |
| 793 | struct uvd *up = &cams->cam[i]; | 793 | struct uvd *up = &cams->cam[i]; |
| 794 | int warning = 0; | 794 | int warning = 0; |
| @@ -802,16 +802,16 @@ void usbvideo_Deregister(struct usbvideo **pCams) | |||
| 802 | } | 802 | } |
| 803 | if (warning) { | 803 | if (warning) { |
| 804 | err("%s: Warning: user_data=$%p user_size=%d.", | 804 | err("%s: Warning: user_data=$%p user_size=%d.", |
| 805 | __FUNCTION__, up->user_data, up->user_size); | 805 | __func__, up->user_data, up->user_size); |
| 806 | } else { | 806 | } else { |
| 807 | dbg("%s: Freeing %d. $%p->user_data=$%p", | 807 | dbg("%s: Freeing %d. $%p->user_data=$%p", |
| 808 | __FUNCTION__, i, up, up->user_data); | 808 | __func__, i, up, up->user_data); |
| 809 | kfree(up->user_data); | 809 | kfree(up->user_data); |
| 810 | } | 810 | } |
| 811 | } | 811 | } |
| 812 | /* Whole array was allocated in one chunk */ | 812 | /* Whole array was allocated in one chunk */ |
| 813 | dbg("%s: Freed %d uvd structures", | 813 | dbg("%s: Freed %d uvd structures", |
| 814 | __FUNCTION__, cams->num_cameras); | 814 | __func__, cams->num_cameras); |
| 815 | kfree(cams); | 815 | kfree(cams); |
| 816 | *pCams = NULL; | 816 | *pCams = NULL; |
| 817 | } | 817 | } |
| @@ -846,7 +846,7 @@ static void usbvideo_Disconnect(struct usb_interface *intf) | |||
| 846 | int i; | 846 | int i; |
| 847 | 847 | ||
| 848 | if (uvd == NULL) { | 848 | if (uvd == NULL) { |
| 849 | err("%s($%p): Illegal call.", __FUNCTION__, intf); | 849 | err("%s($%p): Illegal call.", __func__, intf); |
| 850 | return; | 850 | return; |
| 851 | } | 851 | } |
| 852 | 852 | ||
| @@ -854,7 +854,7 @@ static void usbvideo_Disconnect(struct usb_interface *intf) | |||
| 854 | 854 | ||
| 855 | usbvideo_ClientIncModCount(uvd); | 855 | usbvideo_ClientIncModCount(uvd); |
| 856 | if (uvd->debug > 0) | 856 | if (uvd->debug > 0) |
| 857 | info("%s(%p.)", __FUNCTION__, intf); | 857 | info("%s(%p.)", __func__, intf); |
| 858 | 858 | ||
| 859 | mutex_lock(&uvd->lock); | 859 | mutex_lock(&uvd->lock); |
| 860 | uvd->remove_pending = 1; /* Now all ISO data will be ignored */ | 860 | uvd->remove_pending = 1; /* Now all ISO data will be ignored */ |
| @@ -870,10 +870,10 @@ static void usbvideo_Disconnect(struct usb_interface *intf) | |||
| 870 | 870 | ||
| 871 | video_unregister_device(&uvd->vdev); | 871 | video_unregister_device(&uvd->vdev); |
| 872 | if (uvd->debug > 0) | 872 | if (uvd->debug > 0) |
| 873 | info("%s: Video unregistered.", __FUNCTION__); | 873 | info("%s: Video unregistered.", __func__); |
| 874 | 874 | ||
| 875 | if (uvd->user) | 875 | if (uvd->user) |
| 876 | info("%s: In use, disconnect pending.", __FUNCTION__); | 876 | info("%s: In use, disconnect pending.", __func__); |
| 877 | else | 877 | else |
| 878 | usbvideo_CameraRelease(uvd); | 878 | usbvideo_CameraRelease(uvd); |
| 879 | mutex_unlock(&uvd->lock); | 879 | mutex_unlock(&uvd->lock); |
| @@ -895,7 +895,7 @@ static void usbvideo_Disconnect(struct usb_interface *intf) | |||
| 895 | static void usbvideo_CameraRelease(struct uvd *uvd) | 895 | static void usbvideo_CameraRelease(struct uvd *uvd) |
| 896 | { | 896 | { |
| 897 | if (uvd == NULL) { | 897 | if (uvd == NULL) { |
| 898 | err("%s: Illegal call", __FUNCTION__); | 898 | err("%s: Illegal call", __func__); |
| 899 | return; | 899 | return; |
| 900 | } | 900 | } |
| 901 | 901 | ||
| @@ -946,7 +946,9 @@ static const struct file_operations usbvideo_fops = { | |||
| 946 | .read = usbvideo_v4l_read, | 946 | .read = usbvideo_v4l_read, |
| 947 | .mmap = usbvideo_v4l_mmap, | 947 | .mmap = usbvideo_v4l_mmap, |
| 948 | .ioctl = usbvideo_v4l_ioctl, | 948 | .ioctl = usbvideo_v4l_ioctl, |
| 949 | #ifdef CONFIG_COMPAT | ||
| 949 | .compat_ioctl = v4l_compat_ioctl32, | 950 | .compat_ioctl = v4l_compat_ioctl32, |
| 951 | #endif | ||
| 950 | .llseek = no_llseek, | 952 | .llseek = no_llseek, |
| 951 | }; | 953 | }; |
| 952 | static const struct video_device usbvideo_template = { | 954 | static const struct video_device usbvideo_template = { |
| @@ -1011,18 +1013,18 @@ int usbvideo_RegisterVideoDevice(struct uvd *uvd) | |||
| 1011 | char tmp1[20], tmp2[20]; /* Buffers for printing */ | 1013 | char tmp1[20], tmp2[20]; /* Buffers for printing */ |
| 1012 | 1014 | ||
| 1013 | if (uvd == NULL) { | 1015 | if (uvd == NULL) { |
| 1014 | err("%s: Illegal call.", __FUNCTION__); | 1016 | err("%s: Illegal call.", __func__); |
| 1015 | return -EINVAL; | 1017 | return -EINVAL; |
| 1016 | } | 1018 | } |
| 1017 | if (uvd->video_endp == 0) { | 1019 | if (uvd->video_endp == 0) { |
| 1018 | info("%s: No video endpoint specified; data pump disabled.", __FUNCTION__); | 1020 | info("%s: No video endpoint specified; data pump disabled.", __func__); |
| 1019 | } | 1021 | } |
| 1020 | if (uvd->paletteBits == 0) { | 1022 | if (uvd->paletteBits == 0) { |
| 1021 | err("%s: No palettes specified!", __FUNCTION__); | 1023 | err("%s: No palettes specified!", __func__); |
| 1022 | return -EINVAL; | 1024 | return -EINVAL; |
| 1023 | } | 1025 | } |
| 1024 | if (uvd->defaultPalette == 0) { | 1026 | if (uvd->defaultPalette == 0) { |
| 1025 | info("%s: No default palette!", __FUNCTION__); | 1027 | info("%s: No default palette!", __func__); |
| 1026 | } | 1028 | } |
| 1027 | 1029 | ||
| 1028 | uvd->max_frame_size = VIDEOSIZE_X(uvd->canvas) * | 1030 | uvd->max_frame_size = VIDEOSIZE_X(uvd->canvas) * |
| @@ -1032,19 +1034,19 @@ int usbvideo_RegisterVideoDevice(struct uvd *uvd) | |||
| 1032 | 1034 | ||
| 1033 | if (uvd->debug > 0) { | 1035 | if (uvd->debug > 0) { |
| 1034 | info("%s: iface=%d. endpoint=$%02x paletteBits=$%08lx", | 1036 | info("%s: iface=%d. endpoint=$%02x paletteBits=$%08lx", |
| 1035 | __FUNCTION__, uvd->iface, uvd->video_endp, uvd->paletteBits); | 1037 | __func__, uvd->iface, uvd->video_endp, uvd->paletteBits); |
| 1036 | } | 1038 | } |
| 1037 | if (uvd->dev == NULL) { | 1039 | if (uvd->dev == NULL) { |
| 1038 | err("%s: uvd->dev == NULL", __FUNCTION__); | 1040 | err("%s: uvd->dev == NULL", __func__); |
| 1039 | return -EINVAL; | 1041 | return -EINVAL; |
| 1040 | } | 1042 | } |
| 1041 | uvd->vdev.dev=&(uvd->dev->dev); | 1043 | uvd->vdev.dev = &uvd->dev->dev; |
| 1042 | if (video_register_device(&uvd->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { | 1044 | if (video_register_device(&uvd->vdev, VFL_TYPE_GRABBER, video_nr) == -1) { |
| 1043 | err("%s: video_register_device failed", __FUNCTION__); | 1045 | err("%s: video_register_device failed", __func__); |
| 1044 | return -EPIPE; | 1046 | return -EPIPE; |
| 1045 | } | 1047 | } |
| 1046 | if (uvd->debug > 1) { | 1048 | if (uvd->debug > 1) { |
| 1047 | info("%s: video_register_device() successful", __FUNCTION__); | 1049 | info("%s: video_register_device() successful", __func__); |
| 1048 | } | 1050 | } |
| 1049 | 1051 | ||
| 1050 | info("%s on /dev/video%d: canvas=%s videosize=%s", | 1052 | info("%s on /dev/video%d: canvas=%s videosize=%s", |
| @@ -1111,14 +1113,14 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) | |||
| 1111 | int i, errCode = 0; | 1113 | int i, errCode = 0; |
| 1112 | 1114 | ||
| 1113 | if (uvd->debug > 1) | 1115 | if (uvd->debug > 1) |
| 1114 | info("%s($%p)", __FUNCTION__, dev); | 1116 | info("%s($%p)", __func__, dev); |
| 1115 | 1117 | ||
| 1116 | if (0 < usbvideo_ClientIncModCount(uvd)) | 1118 | if (0 < usbvideo_ClientIncModCount(uvd)) |
| 1117 | return -ENODEV; | 1119 | return -ENODEV; |
| 1118 | mutex_lock(&uvd->lock); | 1120 | mutex_lock(&uvd->lock); |
| 1119 | 1121 | ||
| 1120 | if (uvd->user) { | 1122 | if (uvd->user) { |
| 1121 | err("%s: Someone tried to open an already opened device!", __FUNCTION__); | 1123 | err("%s: Someone tried to open an already opened device!", __func__); |
| 1122 | errCode = -EBUSY; | 1124 | errCode = -EBUSY; |
| 1123 | } else { | 1125 | } else { |
| 1124 | /* Clear statistics */ | 1126 | /* Clear statistics */ |
| @@ -1134,7 +1136,7 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) | |||
| 1134 | RingQueue_Allocate(&uvd->dp, RING_QUEUE_SIZE); | 1136 | RingQueue_Allocate(&uvd->dp, RING_QUEUE_SIZE); |
| 1135 | if ((uvd->fbuf == NULL) || | 1137 | if ((uvd->fbuf == NULL) || |
| 1136 | (!RingQueue_IsAllocated(&uvd->dp))) { | 1138 | (!RingQueue_IsAllocated(&uvd->dp))) { |
| 1137 | err("%s: Failed to allocate fbuf or dp", __FUNCTION__); | 1139 | err("%s: Failed to allocate fbuf or dp", __func__); |
| 1138 | errCode = -ENOMEM; | 1140 | errCode = -ENOMEM; |
| 1139 | } else { | 1141 | } else { |
| 1140 | /* Allocate all buffers */ | 1142 | /* Allocate all buffers */ |
| @@ -1178,19 +1180,19 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) | |||
| 1178 | if (errCode == 0) { | 1180 | if (errCode == 0) { |
| 1179 | if (VALID_CALLBACK(uvd, setupOnOpen)) { | 1181 | if (VALID_CALLBACK(uvd, setupOnOpen)) { |
| 1180 | if (uvd->debug > 1) | 1182 | if (uvd->debug > 1) |
| 1181 | info("%s: setupOnOpen callback", __FUNCTION__); | 1183 | info("%s: setupOnOpen callback", __func__); |
| 1182 | errCode = GET_CALLBACK(uvd, setupOnOpen)(uvd); | 1184 | errCode = GET_CALLBACK(uvd, setupOnOpen)(uvd); |
| 1183 | if (errCode < 0) { | 1185 | if (errCode < 0) { |
| 1184 | err("%s: setupOnOpen callback failed (%d.).", | 1186 | err("%s: setupOnOpen callback failed (%d.).", |
| 1185 | __FUNCTION__, errCode); | 1187 | __func__, errCode); |
| 1186 | } else if (uvd->debug > 1) { | 1188 | } else if (uvd->debug > 1) { |
| 1187 | info("%s: setupOnOpen callback successful", __FUNCTION__); | 1189 | info("%s: setupOnOpen callback successful", __func__); |
| 1188 | } | 1190 | } |
| 1189 | } | 1191 | } |
| 1190 | if (errCode == 0) { | 1192 | if (errCode == 0) { |
| 1191 | uvd->settingsAdjusted = 0; | 1193 | uvd->settingsAdjusted = 0; |
| 1192 | if (uvd->debug > 1) | 1194 | if (uvd->debug > 1) |
| 1193 | info("%s: Open succeeded.", __FUNCTION__); | 1195 | info("%s: Open succeeded.", __func__); |
| 1194 | uvd->user++; | 1196 | uvd->user++; |
| 1195 | file->private_data = uvd; | 1197 | file->private_data = uvd; |
| 1196 | } | 1198 | } |
| @@ -1200,7 +1202,7 @@ static int usbvideo_v4l_open(struct inode *inode, struct file *file) | |||
| 1200 | if (errCode != 0) | 1202 | if (errCode != 0) |
| 1201 | usbvideo_ClientDecModCount(uvd); | 1203 | usbvideo_ClientDecModCount(uvd); |
| 1202 | if (uvd->debug > 0) | 1204 | if (uvd->debug > 0) |
| 1203 | info("%s: Returning %d.", __FUNCTION__, errCode); | 1205 | info("%s: Returning %d.", __func__, errCode); |
| 1204 | return errCode; | 1206 | return errCode; |
| 1205 | } | 1207 | } |
| 1206 | 1208 | ||
| @@ -1223,7 +1225,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file) | |||
| 1223 | int i; | 1225 | int i; |
| 1224 | 1226 | ||
| 1225 | if (uvd->debug > 1) | 1227 | if (uvd->debug > 1) |
| 1226 | info("%s($%p)", __FUNCTION__, dev); | 1228 | info("%s($%p)", __func__, dev); |
| 1227 | 1229 | ||
| 1228 | mutex_lock(&uvd->lock); | 1230 | mutex_lock(&uvd->lock); |
| 1229 | GET_CALLBACK(uvd, stopDataPump)(uvd); | 1231 | GET_CALLBACK(uvd, stopDataPump)(uvd); |
| @@ -1250,7 +1252,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file) | |||
| 1250 | usbvideo_ClientDecModCount(uvd); | 1252 | usbvideo_ClientDecModCount(uvd); |
| 1251 | 1253 | ||
| 1252 | if (uvd->debug > 1) | 1254 | if (uvd->debug > 1) |
| 1253 | info("%s: Completed.", __FUNCTION__); | 1255 | info("%s: Completed.", __func__); |
| 1254 | file->private_data = NULL; | 1256 | file->private_data = NULL; |
| 1255 | return 0; | 1257 | return 0; |
| 1256 | } | 1258 | } |
| @@ -1504,7 +1506,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, | |||
| 1504 | return -EFAULT; | 1506 | return -EFAULT; |
| 1505 | 1507 | ||
| 1506 | if (uvd->debug >= 1) | 1508 | if (uvd->debug >= 1) |
| 1507 | info("%s: %Zd. bytes, noblock=%d.", __FUNCTION__, count, noblock); | 1509 | info("%s: %Zd. bytes, noblock=%d.", __func__, count, noblock); |
| 1508 | 1510 | ||
| 1509 | mutex_lock(&uvd->lock); | 1511 | mutex_lock(&uvd->lock); |
| 1510 | 1512 | ||
| @@ -1551,7 +1553,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, | |||
| 1551 | */ | 1553 | */ |
| 1552 | if (frmx == -1) { | 1554 | if (frmx == -1) { |
| 1553 | if (uvd->defaultPalette == 0) { | 1555 | if (uvd->defaultPalette == 0) { |
| 1554 | err("%s: No default palette; don't know what to do!", __FUNCTION__); | 1556 | err("%s: No default palette; don't know what to do!", __func__); |
| 1555 | count = -EFAULT; | 1557 | count = -EFAULT; |
| 1556 | goto read_done; | 1558 | goto read_done; |
| 1557 | } | 1559 | } |
| @@ -1623,7 +1625,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, | |||
| 1623 | frame->seqRead_Index += count; | 1625 | frame->seqRead_Index += count; |
| 1624 | if (uvd->debug >= 1) { | 1626 | if (uvd->debug >= 1) { |
| 1625 | err("%s: {copy} count used=%Zd, new seqRead_Index=%ld", | 1627 | err("%s: {copy} count used=%Zd, new seqRead_Index=%ld", |
| 1626 | __FUNCTION__, count, frame->seqRead_Index); | 1628 | __func__, count, frame->seqRead_Index); |
| 1627 | } | 1629 | } |
| 1628 | 1630 | ||
| 1629 | /* Finally check if the frame is done with and "release" it */ | 1631 | /* Finally check if the frame is done with and "release" it */ |
| @@ -1634,7 +1636,7 @@ static ssize_t usbvideo_v4l_read(struct file *file, char __user *buf, | |||
| 1634 | /* Mark it as available to be used again. */ | 1636 | /* Mark it as available to be used again. */ |
| 1635 | uvd->frame[frmx].frameState = FrameState_Unused; | 1637 | uvd->frame[frmx].frameState = FrameState_Unused; |
| 1636 | if (usbvideo_NewFrame(uvd, (frmx + 1) % USBVIDEO_NUMFRAMES)) { | 1638 | if (usbvideo_NewFrame(uvd, (frmx + 1) % USBVIDEO_NUMFRAMES)) { |
| 1637 | err("%s: usbvideo_NewFrame failed.", __FUNCTION__); | 1639 | err("%s: usbvideo_NewFrame failed.", __func__); |
| 1638 | } | 1640 | } |
| 1639 | } | 1641 | } |
| 1640 | read_done: | 1642 | read_done: |
| @@ -1741,10 +1743,10 @@ static int usbvideo_StartDataPump(struct uvd *uvd) | |||
| 1741 | int i, errFlag; | 1743 | int i, errFlag; |
| 1742 | 1744 | ||
| 1743 | if (uvd->debug > 1) | 1745 | if (uvd->debug > 1) |
| 1744 | info("%s($%p)", __FUNCTION__, uvd); | 1746 | info("%s($%p)", __func__, uvd); |
| 1745 | 1747 | ||
| 1746 | if (!CAMERA_IS_OPERATIONAL(uvd)) { | 1748 | if (!CAMERA_IS_OPERATIONAL(uvd)) { |
| 1747 | err("%s: Camera is not operational", __FUNCTION__); | 1749 | err("%s: Camera is not operational", __func__); |
| 1748 | return -EFAULT; | 1750 | return -EFAULT; |
| 1749 | } | 1751 | } |
| 1750 | uvd->curframe = -1; | 1752 | uvd->curframe = -1; |
| @@ -1752,14 +1754,14 @@ static int usbvideo_StartDataPump(struct uvd *uvd) | |||
| 1752 | /* Alternate interface 1 is is the biggest frame size */ | 1754 | /* Alternate interface 1 is is the biggest frame size */ |
| 1753 | i = usb_set_interface(dev, uvd->iface, uvd->ifaceAltActive); | 1755 | i = usb_set_interface(dev, uvd->iface, uvd->ifaceAltActive); |
| 1754 | if (i < 0) { | 1756 | if (i < 0) { |
| 1755 | err("%s: usb_set_interface error", __FUNCTION__); | 1757 | err("%s: usb_set_interface error", __func__); |
| 1756 | uvd->last_error = i; | 1758 | uvd->last_error = i; |
| 1757 | return -EBUSY; | 1759 | return -EBUSY; |
| 1758 | } | 1760 | } |
| 1759 | if (VALID_CALLBACK(uvd, videoStart)) | 1761 | if (VALID_CALLBACK(uvd, videoStart)) |
| 1760 | GET_CALLBACK(uvd, videoStart)(uvd); | 1762 | GET_CALLBACK(uvd, videoStart)(uvd); |
| 1761 | else | 1763 | else |
| 1762 | err("%s: videoStart not set", __FUNCTION__); | 1764 | err("%s: videoStart not set", __func__); |
| 1763 | 1765 | ||
| 1764 | /* We double buffer the Iso lists */ | 1766 | /* We double buffer the Iso lists */ |
| 1765 | for (i=0; i < USBVIDEO_NUMSBUF; i++) { | 1767 | for (i=0; i < USBVIDEO_NUMSBUF; i++) { |
| @@ -1784,12 +1786,12 @@ static int usbvideo_StartDataPump(struct uvd *uvd) | |||
| 1784 | for (i=0; i < USBVIDEO_NUMSBUF; i++) { | 1786 | for (i=0; i < USBVIDEO_NUMSBUF; i++) { |
| 1785 | errFlag = usb_submit_urb(uvd->sbuf[i].urb, GFP_KERNEL); | 1787 | errFlag = usb_submit_urb(uvd->sbuf[i].urb, GFP_KERNEL); |
| 1786 | if (errFlag) | 1788 | if (errFlag) |
| 1787 | err("%s: usb_submit_isoc(%d) ret %d", __FUNCTION__, i, errFlag); | 1789 | err("%s: usb_submit_isoc(%d) ret %d", __func__, i, errFlag); |
| 1788 | } | 1790 | } |
| 1789 | 1791 | ||
| 1790 | uvd->streaming = 1; | 1792 | uvd->streaming = 1; |
| 1791 | if (uvd->debug > 1) | 1793 | if (uvd->debug > 1) |
| 1792 | info("%s: streaming=1 video_endp=$%02x", __FUNCTION__, uvd->video_endp); | 1794 | info("%s: streaming=1 video_endp=$%02x", __func__, uvd->video_endp); |
| 1793 | return 0; | 1795 | return 0; |
| 1794 | } | 1796 | } |
| 1795 | 1797 | ||
| @@ -1811,14 +1813,14 @@ static void usbvideo_StopDataPump(struct uvd *uvd) | |||
| 1811 | return; | 1813 | return; |
| 1812 | 1814 | ||
| 1813 | if (uvd->debug > 1) | 1815 | if (uvd->debug > 1) |
| 1814 | info("%s($%p)", __FUNCTION__, uvd); | 1816 | info("%s($%p)", __func__, uvd); |
| 1815 | 1817 | ||
| 1816 | /* Unschedule all of the iso td's */ | 1818 | /* Unschedule all of the iso td's */ |
| 1817 | for (i=0; i < USBVIDEO_NUMSBUF; i++) { | 1819 | for (i=0; i < USBVIDEO_NUMSBUF; i++) { |
| 1818 | usb_kill_urb(uvd->sbuf[i].urb); | 1820 | usb_kill_urb(uvd->sbuf[i].urb); |
| 1819 | } | 1821 | } |
| 1820 | if (uvd->debug > 1) | 1822 | if (uvd->debug > 1) |
| 1821 | info("%s: streaming=0", __FUNCTION__); | 1823 | info("%s: streaming=0", __func__); |
| 1822 | uvd->streaming = 0; | 1824 | uvd->streaming = 0; |
| 1823 | 1825 | ||
| 1824 | if (!uvd->remove_pending) { | 1826 | if (!uvd->remove_pending) { |
| @@ -1826,12 +1828,12 @@ static void usbvideo_StopDataPump(struct uvd *uvd) | |||
| 1826 | if (VALID_CALLBACK(uvd, videoStop)) | 1828 | if (VALID_CALLBACK(uvd, videoStop)) |
| 1827 | GET_CALLBACK(uvd, videoStop)(uvd); | 1829 | GET_CALLBACK(uvd, videoStop)(uvd); |
| 1828 | else | 1830 | else |
| 1829 | err("%s: videoStop not set", __FUNCTION__); | 1831 | err("%s: videoStop not set", __func__); |
| 1830 | 1832 | ||
| 1831 | /* Set packet size to 0 */ | 1833 | /* Set packet size to 0 */ |
| 1832 | j = usb_set_interface(uvd->dev, uvd->iface, uvd->ifaceAltInactive); | 1834 | j = usb_set_interface(uvd->dev, uvd->iface, uvd->ifaceAltInactive); |
| 1833 | if (j < 0) { | 1835 | if (j < 0) { |
| 1834 | err("%s: usb_set_interface() error %d.", __FUNCTION__, j); | 1836 | err("%s: usb_set_interface() error %d.", __func__, j); |
| 1835 | uvd->last_error = j; | 1837 | uvd->last_error = j; |
| 1836 | } | 1838 | } |
| 1837 | } | 1839 | } |
| @@ -1955,12 +1957,12 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum) | |||
| 1955 | struct usbvideo_frame *frame = &uvd->frame[frameNum]; | 1957 | struct usbvideo_frame *frame = &uvd->frame[frameNum]; |
| 1956 | 1958 | ||
| 1957 | if (uvd->debug >= 2) | 1959 | if (uvd->debug >= 2) |
| 1958 | info("%s($%p,%d.)", __FUNCTION__, uvd, frameNum); | 1960 | info("%s($%p,%d.)", __func__, uvd, frameNum); |
| 1959 | 1961 | ||
| 1960 | switch (frame->frameState) { | 1962 | switch (frame->frameState) { |
| 1961 | case FrameState_Unused: | 1963 | case FrameState_Unused: |
| 1962 | if (uvd->debug >= 2) | 1964 | if (uvd->debug >= 2) |
| 1963 | info("%s: FrameState_Unused", __FUNCTION__); | 1965 | info("%s: FrameState_Unused", __func__); |
| 1964 | return -EINVAL; | 1966 | return -EINVAL; |
| 1965 | case FrameState_Ready: | 1967 | case FrameState_Ready: |
| 1966 | case FrameState_Grabbing: | 1968 | case FrameState_Grabbing: |
| @@ -1970,7 +1972,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum) | |||
| 1970 | redo: | 1972 | redo: |
| 1971 | if (!CAMERA_IS_OPERATIONAL(uvd)) { | 1973 | if (!CAMERA_IS_OPERATIONAL(uvd)) { |
| 1972 | if (uvd->debug >= 2) | 1974 | if (uvd->debug >= 2) |
| 1973 | info("%s: Camera is not operational (1)", __FUNCTION__); | 1975 | info("%s: Camera is not operational (1)", __func__); |
| 1974 | return -EIO; | 1976 | return -EIO; |
| 1975 | } | 1977 | } |
| 1976 | ntries = 0; | 1978 | ntries = 0; |
| @@ -1979,24 +1981,24 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum) | |||
| 1979 | signalPending = signal_pending(current); | 1981 | signalPending = signal_pending(current); |
| 1980 | if (!CAMERA_IS_OPERATIONAL(uvd)) { | 1982 | if (!CAMERA_IS_OPERATIONAL(uvd)) { |
| 1981 | if (uvd->debug >= 2) | 1983 | if (uvd->debug >= 2) |
| 1982 | info("%s: Camera is not operational (2)", __FUNCTION__); | 1984 | info("%s: Camera is not operational (2)", __func__); |
| 1983 | return -EIO; | 1985 | return -EIO; |
| 1984 | } | 1986 | } |
| 1985 | assert(uvd->fbuf != NULL); | 1987 | assert(uvd->fbuf != NULL); |
| 1986 | if (signalPending) { | 1988 | if (signalPending) { |
| 1987 | if (uvd->debug >= 2) | 1989 | if (uvd->debug >= 2) |
| 1988 | info("%s: Signal=$%08x", __FUNCTION__, signalPending); | 1990 | info("%s: Signal=$%08x", __func__, signalPending); |
| 1989 | if (uvd->flags & FLAGS_RETRY_VIDIOCSYNC) { | 1991 | if (uvd->flags & FLAGS_RETRY_VIDIOCSYNC) { |
| 1990 | usbvideo_TestPattern(uvd, 1, 0); | 1992 | usbvideo_TestPattern(uvd, 1, 0); |
| 1991 | uvd->curframe = -1; | 1993 | uvd->curframe = -1; |
| 1992 | uvd->stats.frame_num++; | 1994 | uvd->stats.frame_num++; |
| 1993 | if (uvd->debug >= 2) | 1995 | if (uvd->debug >= 2) |
| 1994 | info("%s: Forced test pattern screen", __FUNCTION__); | 1996 | info("%s: Forced test pattern screen", __func__); |
| 1995 | return 0; | 1997 | return 0; |
| 1996 | } else { | 1998 | } else { |
| 1997 | /* Standard answer: Interrupted! */ | 1999 | /* Standard answer: Interrupted! */ |
| 1998 | if (uvd->debug >= 2) | 2000 | if (uvd->debug >= 2) |
| 1999 | info("%s: Interrupted!", __FUNCTION__); | 2001 | info("%s: Interrupted!", __func__); |
| 2000 | return -EINTR; | 2002 | return -EINTR; |
| 2001 | } | 2003 | } |
| 2002 | } else { | 2004 | } else { |
| @@ -2006,17 +2008,17 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum) | |||
| 2006 | else if (VALID_CALLBACK(uvd, processData)) | 2008 | else if (VALID_CALLBACK(uvd, processData)) |
| 2007 | GET_CALLBACK(uvd, processData)(uvd, frame); | 2009 | GET_CALLBACK(uvd, processData)(uvd, frame); |
| 2008 | else | 2010 | else |
| 2009 | err("%s: processData not set", __FUNCTION__); | 2011 | err("%s: processData not set", __func__); |
| 2010 | } | 2012 | } |
| 2011 | } while (frame->frameState == FrameState_Grabbing); | 2013 | } while (frame->frameState == FrameState_Grabbing); |
| 2012 | if (uvd->debug >= 2) { | 2014 | if (uvd->debug >= 2) { |
| 2013 | info("%s: Grabbing done; state=%d. (%lu. bytes)", | 2015 | info("%s: Grabbing done; state=%d. (%lu. bytes)", |
| 2014 | __FUNCTION__, frame->frameState, frame->seqRead_Length); | 2016 | __func__, frame->frameState, frame->seqRead_Length); |
| 2015 | } | 2017 | } |
| 2016 | if (frame->frameState == FrameState_Error) { | 2018 | if (frame->frameState == FrameState_Error) { |
| 2017 | int ret = usbvideo_NewFrame(uvd, frameNum); | 2019 | int ret = usbvideo_NewFrame(uvd, frameNum); |
| 2018 | if (ret < 0) { | 2020 | if (ret < 0) { |
| 2019 | err("%s: usbvideo_NewFrame() failed (%d.)", __FUNCTION__, ret); | 2021 | err("%s: usbvideo_NewFrame() failed (%d.)", __func__, ret); |
| 2020 | return ret; | 2022 | return ret; |
| 2021 | } | 2023 | } |
| 2022 | goto redo; | 2024 | goto redo; |
| @@ -2048,7 +2050,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum) | |||
| 2048 | } | 2050 | } |
| 2049 | frame->frameState = FrameState_Done_Hold; | 2051 | frame->frameState = FrameState_Done_Hold; |
| 2050 | if (uvd->debug >= 2) | 2052 | if (uvd->debug >= 2) |
| 2051 | info("%s: Entered FrameState_Done_Hold state.", __FUNCTION__); | 2053 | info("%s: Entered FrameState_Done_Hold state.", __func__); |
| 2052 | return 0; | 2054 | return 0; |
| 2053 | 2055 | ||
| 2054 | case FrameState_Done_Hold: | 2056 | case FrameState_Done_Hold: |
| @@ -2059,12 +2061,12 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum) | |||
| 2059 | * it will be released back into the wild to roam freely. | 2061 | * it will be released back into the wild to roam freely. |
| 2060 | */ | 2062 | */ |
| 2061 | if (uvd->debug >= 2) | 2063 | if (uvd->debug >= 2) |
| 2062 | info("%s: FrameState_Done_Hold state.", __FUNCTION__); | 2064 | info("%s: FrameState_Done_Hold state.", __func__); |
| 2063 | return 0; | 2065 | return 0; |
| 2064 | } | 2066 | } |
| 2065 | 2067 | ||
| 2066 | /* Catch-all for other cases. We shall not be here. */ | 2068 | /* Catch-all for other cases. We shall not be here. */ |
| 2067 | err("%s: Invalid state %d.", __FUNCTION__, frame->frameState); | 2069 | err("%s: Invalid state %d.", __func__, frame->frameState); |
| 2068 | frame->frameState = FrameState_Unused; | 2070 | frame->frameState = FrameState_Unused; |
| 2069 | return 0; | 2071 | return 0; |
| 2070 | } | 2072 | } |
| @@ -2160,7 +2162,7 @@ static void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd, | |||
| 2160 | const int ccm = 128; /* Color correction median - see below */ | 2162 | const int ccm = 128; /* Color correction median - see below */ |
| 2161 | 2163 | ||
| 2162 | if ((uvd == NULL) || (frame == NULL)) { | 2164 | if ((uvd == NULL) || (frame == NULL)) { |
| 2163 | err("%s: Illegal call.", __FUNCTION__); | 2165 | err("%s: Illegal call.", __func__); |
| 2164 | return; | 2166 | return; |
| 2165 | } | 2167 | } |
| 2166 | adj = (uvd->vpic.contrast - 0x8000) >> 8; /* -128..+127 = -ccm..+(ccm-1)*/ | 2168 | adj = (uvd->vpic.contrast - 0x8000) >> 8; /* -128..+127 = -ccm..+(ccm-1)*/ |
diff --git a/drivers/media/video/usbvideo/vicam.c b/drivers/media/video/usbvideo/vicam.c index da1ba0211108..64819353276a 100644 --- a/drivers/media/video/usbvideo/vicam.c +++ b/drivers/media/video/usbvideo/vicam.c | |||
| @@ -48,7 +48,7 @@ | |||
| 48 | // #define VICAM_DEBUG | 48 | // #define VICAM_DEBUG |
| 49 | 49 | ||
| 50 | #ifdef VICAM_DEBUG | 50 | #ifdef VICAM_DEBUG |
| 51 | #define ADBG(lineno,fmt,args...) printk(fmt, jiffies, __FUNCTION__, lineno, ##args) | 51 | #define ADBG(lineno,fmt,args...) printk(fmt, jiffies, __func__, lineno, ##args) |
| 52 | #define DBG(fmt,args...) ADBG((__LINE__),KERN_DEBUG __FILE__"(%ld):%s (%d):"fmt,##args) | 52 | #define DBG(fmt,args...) ADBG((__LINE__),KERN_DEBUG __FILE__"(%ld):%s (%d):"fmt,##args) |
| 53 | #else | 53 | #else |
| 54 | #define DBG(fmn,args...) do {} while(0) | 54 | #define DBG(fmn,args...) do {} while(0) |
| @@ -1066,7 +1066,9 @@ static const struct file_operations vicam_fops = { | |||
| 1066 | .read = vicam_read, | 1066 | .read = vicam_read, |
| 1067 | .mmap = vicam_mmap, | 1067 | .mmap = vicam_mmap, |
| 1068 | .ioctl = vicam_ioctl, | 1068 | .ioctl = vicam_ioctl, |
| 1069 | #ifdef CONFIG_COMPAT | ||
| 1069 | .compat_ioctl = v4l_compat_ioctl32, | 1070 | .compat_ioctl = v4l_compat_ioctl32, |
| 1071 | #endif | ||
| 1070 | .llseek = no_llseek, | 1072 | .llseek = no_llseek, |
| 1071 | }; | 1073 | }; |
| 1072 | 1074 | ||
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c index 56775ab8b75d..a9c5e5adba3a 100644 --- a/drivers/media/video/usbvision/usbvision-core.c +++ b/drivers/media/video/usbvision/usbvision-core.c | |||
| @@ -53,19 +53,21 @@ | |||
| 53 | 53 | ||
| 54 | #include "usbvision.h" | 54 | #include "usbvision.h" |
| 55 | 55 | ||
| 56 | static unsigned int core_debug = 0; | 56 | static unsigned int core_debug; |
| 57 | module_param(core_debug,int,0644); | 57 | module_param(core_debug,int,0644); |
| 58 | MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); | 58 | MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); |
| 59 | 59 | ||
| 60 | static unsigned int force_testpattern = 0; | 60 | static unsigned int force_testpattern; |
| 61 | module_param(force_testpattern,int,0644); | 61 | module_param(force_testpattern,int,0644); |
| 62 | MODULE_PARM_DESC(force_testpattern,"enable test pattern display [core]"); | 62 | MODULE_PARM_DESC(force_testpattern,"enable test pattern display [core]"); |
| 63 | 63 | ||
| 64 | static int adjustCompression = 1; // Set the compression to be adaptive | 64 | static int adjustCompression = 1; /* Set the compression to be adaptive */ |
| 65 | module_param(adjustCompression, int, 0444); | 65 | module_param(adjustCompression, int, 0444); |
| 66 | MODULE_PARM_DESC(adjustCompression, " Set the ADPCM compression for the device. Default: 1 (On)"); | 66 | MODULE_PARM_DESC(adjustCompression, " Set the ADPCM compression for the device. Default: 1 (On)"); |
| 67 | 67 | ||
| 68 | static int SwitchSVideoInput = 0; // To help people with Black and White output with using s-video input. Some cables and input device are wired differently. | 68 | /* To help people with Black and White output with using s-video input. |
| 69 | * Some cables and input device are wired differently. */ | ||
| 70 | static int SwitchSVideoInput; | ||
| 69 | module_param(SwitchSVideoInput, int, 0444); | 71 | module_param(SwitchSVideoInput, int, 0444); |
| 70 | MODULE_PARM_DESC(SwitchSVideoInput, " Set the S-Video input. Some cables and input device are wired differently. Default: 0 (Off)"); | 72 | MODULE_PARM_DESC(SwitchSVideoInput, " Set the S-Video input. Some cables and input device are wired differently. Default: 0 (Off)"); |
| 71 | 73 | ||
| @@ -82,8 +84,10 @@ MODULE_PARM_DESC(adjust_Y_Offset, "adjust Y offset display [core]"); | |||
| 82 | 84 | ||
| 83 | 85 | ||
| 84 | #ifdef USBVISION_DEBUG | 86 | #ifdef USBVISION_DEBUG |
| 85 | #define PDEBUG(level, fmt, args...) \ | 87 | #define PDEBUG(level, fmt, args...) { \ |
| 86 | if (core_debug & (level)) info("[%s:%d] " fmt, __PRETTY_FUNCTION__, __LINE__ , ## args) | 88 | if (core_debug & (level)) \ |
| 89 | info("[%s:%d] " fmt, __func__, __LINE__ , ## args); \ | ||
| 90 | } | ||
| 87 | #else | 91 | #else |
| 88 | #define PDEBUG(level, fmt, args...) do {} while(0) | 92 | #define PDEBUG(level, fmt, args...) do {} while(0) |
| 89 | #endif | 93 | #endif |
| @@ -384,7 +388,7 @@ int usbvision_scratch_alloc(struct usb_usbvision *usbvision) | |||
| 384 | scratch_reset(usbvision); | 388 | scratch_reset(usbvision); |
| 385 | if(usbvision->scratch == NULL) { | 389 | if(usbvision->scratch == NULL) { |
| 386 | err("%s: unable to allocate %d bytes for scratch", | 390 | err("%s: unable to allocate %d bytes for scratch", |
| 387 | __FUNCTION__, scratch_buf_size); | 391 | __func__, scratch_buf_size); |
| 388 | return -ENOMEM; | 392 | return -ENOMEM; |
| 389 | } | 393 | } |
| 390 | return 0; | 394 | return 0; |
| @@ -418,7 +422,7 @@ static void usbvision_testpattern(struct usb_usbvision *usbvision, | |||
| 418 | unsigned char *f; | 422 | unsigned char *f; |
| 419 | int num_cell = 0; | 423 | int num_cell = 0; |
| 420 | int scan_length = 0; | 424 | int scan_length = 0; |
| 421 | static int num_pass = 0; | 425 | static int num_pass; |
| 422 | 426 | ||
| 423 | if (usbvision == NULL) { | 427 | if (usbvision == NULL) { |
| 424 | printk(KERN_ERR "%s: usbvision == NULL\n", proc); | 428 | printk(KERN_ERR "%s: usbvision == NULL\n", proc); |
| @@ -493,7 +497,8 @@ int usbvision_decompress_alloc(struct usb_usbvision *usbvision) | |||
| 493 | int IFB_size = MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * 3 / 2; | 497 | int IFB_size = MAX_FRAME_WIDTH * MAX_FRAME_HEIGHT * 3 / 2; |
| 494 | usbvision->IntraFrameBuffer = vmalloc_32(IFB_size); | 498 | usbvision->IntraFrameBuffer = vmalloc_32(IFB_size); |
| 495 | if (usbvision->IntraFrameBuffer == NULL) { | 499 | if (usbvision->IntraFrameBuffer == NULL) { |
| 496 | err("%s: unable to allocate %d for compr. frame buffer", __FUNCTION__, IFB_size); | 500 | err("%s: unable to allocate %d for compr. frame buffer", |
| 501 | __func__, IFB_size); | ||
| 497 | return -ENOMEM; | 502 | return -ENOMEM; |
| 498 | } | 503 | } |
| 499 | return 0; | 504 | return 0; |
| @@ -1430,7 +1435,7 @@ static int usbvision_compress_isochronous(struct usb_usbvision *usbvision, | |||
| 1430 | } | 1435 | } |
| 1431 | #if ENABLE_HEXDUMP | 1436 | #if ENABLE_HEXDUMP |
| 1432 | if (totlen > 0) { | 1437 | if (totlen > 0) { |
| 1433 | static int foo = 0; | 1438 | static int foo; |
| 1434 | if (foo < 1) { | 1439 | if (foo < 1) { |
| 1435 | printk(KERN_DEBUG "+%d.\n", usbvision->scratchlen); | 1440 | printk(KERN_DEBUG "+%d.\n", usbvision->scratchlen); |
| 1436 | usbvision_hexdump(data0, (totlen > 64) ? 64 : totlen); | 1441 | usbvision_hexdump(data0, (totlen > 64) ? 64 : totlen); |
| @@ -1516,7 +1521,7 @@ static void usbvision_isocIrq(struct urb *urb) | |||
| 1516 | 1521 | ||
| 1517 | if(errCode) { | 1522 | if(errCode) { |
| 1518 | err("%s: usb_submit_urb failed: error %d", | 1523 | err("%s: usb_submit_urb failed: error %d", |
| 1519 | __FUNCTION__, errCode); | 1524 | __func__, errCode); |
| 1520 | } | 1525 | } |
| 1521 | 1526 | ||
| 1522 | return; | 1527 | return; |
| @@ -1547,7 +1552,7 @@ int usbvision_read_reg(struct usb_usbvision *usbvision, unsigned char reg) | |||
| 1547 | 0, (__u16) reg, buffer, 1, HZ); | 1552 | 0, (__u16) reg, buffer, 1, HZ); |
| 1548 | 1553 | ||
| 1549 | if (errCode < 0) { | 1554 | if (errCode < 0) { |
| 1550 | err("%s: failed: error %d", __FUNCTION__, errCode); | 1555 | err("%s: failed: error %d", __func__, errCode); |
| 1551 | return errCode; | 1556 | return errCode; |
| 1552 | } | 1557 | } |
| 1553 | return buffer[0]; | 1558 | return buffer[0]; |
| @@ -1575,7 +1580,7 @@ int usbvision_write_reg(struct usb_usbvision *usbvision, unsigned char reg, | |||
| 1575 | USB_RECIP_ENDPOINT, 0, (__u16) reg, &value, 1, HZ); | 1580 | USB_RECIP_ENDPOINT, 0, (__u16) reg, &value, 1, HZ); |
| 1576 | 1581 | ||
| 1577 | if (errCode < 0) { | 1582 | if (errCode < 0) { |
| 1578 | err("%s: failed: error %d", __FUNCTION__, errCode); | 1583 | err("%s: failed: error %d", __func__, errCode); |
| 1579 | } | 1584 | } |
| 1580 | return errCode; | 1585 | return errCode; |
| 1581 | } | 1586 | } |
| @@ -1851,7 +1856,7 @@ int usbvision_set_output(struct usb_usbvision *usbvision, int width, | |||
| 1851 | 0, (__u16) USBVISION_LXSIZE_O, value, 4, HZ); | 1856 | 0, (__u16) USBVISION_LXSIZE_O, value, 4, HZ); |
| 1852 | 1857 | ||
| 1853 | if (errCode < 0) { | 1858 | if (errCode < 0) { |
| 1854 | err("%s failed: error %d", __FUNCTION__, errCode); | 1859 | err("%s failed: error %d", __func__, errCode); |
| 1855 | return errCode; | 1860 | return errCode; |
| 1856 | } | 1861 | } |
| 1857 | usbvision->curwidth = usbvision->stretch_width * UsbWidth; | 1862 | usbvision->curwidth = usbvision->stretch_width * UsbWidth; |
| @@ -2237,7 +2242,7 @@ static int usbvision_set_dram_settings(struct usb_usbvision *usbvision) | |||
| 2237 | (__u16) USBVISION_DRM_PRM1, value, 8, HZ); | 2242 | (__u16) USBVISION_DRM_PRM1, value, 8, HZ); |
| 2238 | 2243 | ||
| 2239 | if (rc < 0) { | 2244 | if (rc < 0) { |
| 2240 | err("%sERROR=%d", __FUNCTION__, rc); | 2245 | err("%sERROR=%d", __func__, rc); |
| 2241 | return rc; | 2246 | return rc; |
| 2242 | } | 2247 | } |
| 2243 | 2248 | ||
| @@ -2486,7 +2491,7 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision) | |||
| 2486 | 2491 | ||
| 2487 | urb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); | 2492 | urb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); |
| 2488 | if (urb == NULL) { | 2493 | if (urb == NULL) { |
| 2489 | err("%s: usb_alloc_urb() failed", __FUNCTION__); | 2494 | err("%s: usb_alloc_urb() failed", __func__); |
| 2490 | return -ENOMEM; | 2495 | return -ENOMEM; |
| 2491 | } | 2496 | } |
| 2492 | usbvision->sbuf[bufIdx].urb = urb; | 2497 | usbvision->sbuf[bufIdx].urb = urb; |
| @@ -2520,13 +2525,13 @@ int usbvision_init_isoc(struct usb_usbvision *usbvision) | |||
| 2520 | GFP_KERNEL); | 2525 | GFP_KERNEL); |
| 2521 | if (errCode) { | 2526 | if (errCode) { |
| 2522 | err("%s: usb_submit_urb(%d) failed: error %d", | 2527 | err("%s: usb_submit_urb(%d) failed: error %d", |
| 2523 | __FUNCTION__, bufIdx, errCode); | 2528 | __func__, bufIdx, errCode); |
| 2524 | } | 2529 | } |
| 2525 | } | 2530 | } |
| 2526 | 2531 | ||
| 2527 | usbvision->streaming = Stream_Idle; | 2532 | usbvision->streaming = Stream_Idle; |
| 2528 | PDEBUG(DBG_ISOC, "%s: streaming=1 usbvision->video_endp=$%02x", | 2533 | PDEBUG(DBG_ISOC, "%s: streaming=1 usbvision->video_endp=$%02x", |
| 2529 | __FUNCTION__, | 2534 | __func__, |
| 2530 | usbvision->video_endp); | 2535 | usbvision->video_endp); |
| 2531 | return 0; | 2536 | return 0; |
| 2532 | } | 2537 | } |
| @@ -2560,7 +2565,7 @@ void usbvision_stop_isoc(struct usb_usbvision *usbvision) | |||
| 2560 | } | 2565 | } |
| 2561 | 2566 | ||
| 2562 | 2567 | ||
| 2563 | PDEBUG(DBG_ISOC, "%s: streaming=Stream_Off\n", __FUNCTION__); | 2568 | PDEBUG(DBG_ISOC, "%s: streaming=Stream_Off\n", __func__); |
| 2564 | usbvision->streaming = Stream_Off; | 2569 | usbvision->streaming = Stream_Off; |
| 2565 | 2570 | ||
| 2566 | if (!usbvision->remove_pending) { | 2571 | if (!usbvision->remove_pending) { |
| @@ -2571,7 +2576,7 @@ void usbvision_stop_isoc(struct usb_usbvision *usbvision) | |||
| 2571 | usbvision->ifaceAlt); | 2576 | usbvision->ifaceAlt); |
| 2572 | if (errCode < 0) { | 2577 | if (errCode < 0) { |
| 2573 | err("%s: usb_set_interface() failed: error %d", | 2578 | err("%s: usb_set_interface() failed: error %d", |
| 2574 | __FUNCTION__, errCode); | 2579 | __func__, errCode); |
| 2575 | usbvision->last_error = errCode; | 2580 | usbvision->last_error = errCode; |
| 2576 | } | 2581 | } |
| 2577 | regValue = (16-usbvision_read_reg(usbvision, USBVISION_ALTER_REG)) & 0x0F; | 2582 | regValue = (16-usbvision_read_reg(usbvision, USBVISION_ALTER_REG)) & 0x0F; |
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c index aabc42cae9c7..e2274d77ea29 100644 --- a/drivers/media/video/usbvision/usbvision-i2c.c +++ b/drivers/media/video/usbvision/usbvision-i2c.c | |||
| @@ -40,13 +40,15 @@ | |||
| 40 | 40 | ||
| 41 | #define DBG_I2C 1<<0 | 41 | #define DBG_I2C 1<<0 |
| 42 | 42 | ||
| 43 | static int i2c_debug = 0; | 43 | static int i2c_debug; |
| 44 | 44 | ||
| 45 | module_param (i2c_debug, int, 0644); // debug_i2c_usb mode of the device driver | 45 | module_param (i2c_debug, int, 0644); // debug_i2c_usb mode of the device driver |
| 46 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); | 46 | MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); |
| 47 | 47 | ||
| 48 | #define PDEBUG(level, fmt, args...) \ | 48 | #define PDEBUG(level, fmt, args...) { \ |
| 49 | if (i2c_debug & (level)) info("[%s:%d] " fmt, __PRETTY_FUNCTION__, __LINE__ , ## args) | 49 | if (i2c_debug & (level)) \ |
| 50 | info("[%s:%d] " fmt, __func__, __LINE__ , ## args); \ | ||
| 51 | } | ||
| 50 | 52 | ||
| 51 | static int usbvision_i2c_write(struct usb_usbvision *usbvision, unsigned char addr, char *buf, | 53 | static int usbvision_i2c_write(struct usb_usbvision *usbvision, unsigned char addr, char *buf, |
| 52 | short len); | 54 | short len); |
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index df52f8a60215..d97261ab430f 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
| @@ -97,10 +97,10 @@ USBVISION_DRIVER_VERSION_PATCHLEVEL) | |||
| 97 | 97 | ||
| 98 | 98 | ||
| 99 | #ifdef USBVISION_DEBUG | 99 | #ifdef USBVISION_DEBUG |
| 100 | #define PDEBUG(level, fmt, args...) \ | 100 | #define PDEBUG(level, fmt, args...) { \ |
| 101 | if (video_debug & (level)) \ | 101 | if (video_debug & (level)) \ |
| 102 | info("[%s:%d] " fmt, __PRETTY_FUNCTION__, __LINE__ ,\ | 102 | info("[%s:%d] " fmt, __func__, __LINE__ , ## args); \ |
| 103 | ## args) | 103 | } |
| 104 | #else | 104 | #else |
| 105 | #define PDEBUG(level, fmt, args...) do {} while(0) | 105 | #define PDEBUG(level, fmt, args...) do {} while(0) |
| 106 | #endif | 106 | #endif |
| @@ -115,7 +115,7 @@ USBVISION_DRIVER_VERSION_PATCHLEVEL) | |||
| 115 | 115 | ||
| 116 | 116 | ||
| 117 | /* sequential number of usbvision device */ | 117 | /* sequential number of usbvision device */ |
| 118 | static int usbvision_nr = 0; | 118 | static int usbvision_nr; |
| 119 | 119 | ||
| 120 | static struct usbvision_v4l2_format_st usbvision_v4l2_format[] = { | 120 | static struct usbvision_v4l2_format_st usbvision_v4l2_format[] = { |
| 121 | { 1, 1, 8, V4L2_PIX_FMT_GREY , "GREY" }, | 121 | { 1, 1, 8, V4L2_PIX_FMT_GREY , "GREY" }, |
| @@ -135,7 +135,7 @@ static void usbvision_release(struct usb_usbvision *usbvision); | |||
| 135 | /* Set the default format for ISOC endpoint */ | 135 | /* Set the default format for ISOC endpoint */ |
| 136 | static int isocMode = ISOC_MODE_COMPRESS; | 136 | static int isocMode = ISOC_MODE_COMPRESS; |
| 137 | /* Set the default Debug Mode of the device driver */ | 137 | /* Set the default Debug Mode of the device driver */ |
| 138 | static int video_debug = 0; | 138 | static int video_debug; |
| 139 | /* Set the default device to power on at startup */ | 139 | /* Set the default device to power on at startup */ |
| 140 | static int PowerOnAtOpen = 1; | 140 | static int PowerOnAtOpen = 1; |
| 141 | /* Sequential Number of Video Device */ | 141 | /* Sequential Number of Video Device */ |
| @@ -343,7 +343,7 @@ static void usbvision_create_sysfs(struct video_device *vdev) | |||
| 343 | return; | 343 | return; |
| 344 | } while (0); | 344 | } while (0); |
| 345 | 345 | ||
| 346 | err("%s error: %d\n", __FUNCTION__, res); | 346 | err("%s error: %d\n", __func__, res); |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | static void usbvision_remove_sysfs(struct video_device *vdev) | 349 | static void usbvision_remove_sysfs(struct video_device *vdev) |
| @@ -490,7 +490,7 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file) | |||
| 490 | mutex_unlock(&usbvision->lock); | 490 | mutex_unlock(&usbvision->lock); |
| 491 | 491 | ||
| 492 | if (usbvision->remove_pending) { | 492 | if (usbvision->remove_pending) { |
| 493 | printk(KERN_INFO "%s: Final disconnect\n", __FUNCTION__); | 493 | printk(KERN_INFO "%s: Final disconnect\n", __func__); |
| 494 | usbvision_release(usbvision); | 494 | usbvision_release(usbvision); |
| 495 | } | 495 | } |
| 496 | 496 | ||
| @@ -522,7 +522,7 @@ static int vidioc_g_register (struct file *file, void *priv, | |||
| 522 | errCode = usbvision_read_reg(usbvision, reg->reg&0xff); | 522 | errCode = usbvision_read_reg(usbvision, reg->reg&0xff); |
| 523 | if (errCode < 0) { | 523 | if (errCode < 0) { |
| 524 | err("%s: VIDIOC_DBG_G_REGISTER failed: error %d", | 524 | err("%s: VIDIOC_DBG_G_REGISTER failed: error %d", |
| 525 | __FUNCTION__, errCode); | 525 | __func__, errCode); |
| 526 | return errCode; | 526 | return errCode; |
| 527 | } | 527 | } |
| 528 | reg->val = errCode; | 528 | reg->val = errCode; |
| @@ -543,7 +543,7 @@ static int vidioc_s_register (struct file *file, void *priv, | |||
| 543 | errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); | 543 | errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); |
| 544 | if (errCode < 0) { | 544 | if (errCode < 0) { |
| 545 | err("%s: VIDIOC_DBG_S_REGISTER failed: error %d", | 545 | err("%s: VIDIOC_DBG_S_REGISTER failed: error %d", |
| 546 | __FUNCTION__, errCode); | 546 | __func__, errCode); |
| 547 | return errCode; | 547 | return errCode; |
| 548 | } | 548 | } |
| 549 | return 0; | 549 | return 0; |
| @@ -1102,7 +1102,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
| 1102 | int ret,i; | 1102 | int ret,i; |
| 1103 | struct usbvision_frame *frame; | 1103 | struct usbvision_frame *frame; |
| 1104 | 1104 | ||
| 1105 | PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __FUNCTION__, | 1105 | PDEBUG(DBG_IO, "%s: %ld bytes, noblock=%d", __func__, |
| 1106 | (unsigned long)count, noblock); | 1106 | (unsigned long)count, noblock); |
| 1107 | 1107 | ||
| 1108 | if (!USBVISION_IS_OPERATIONAL(usbvision) || (buf == NULL)) | 1108 | if (!USBVISION_IS_OPERATIONAL(usbvision) || (buf == NULL)) |
| @@ -1171,7 +1171,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
| 1171 | } | 1171 | } |
| 1172 | 1172 | ||
| 1173 | PDEBUG(DBG_IO, "%s: frmx=%d, bytes_read=%ld, scanlength=%ld", | 1173 | PDEBUG(DBG_IO, "%s: frmx=%d, bytes_read=%ld, scanlength=%ld", |
| 1174 | __FUNCTION__, | 1174 | __func__, |
| 1175 | frame->index, frame->bytes_read, frame->scanlength); | 1175 | frame->index, frame->bytes_read, frame->scanlength); |
| 1176 | 1176 | ||
| 1177 | /* copy bytes to user space; we allow for partials reads */ | 1177 | /* copy bytes to user space; we allow for partials reads */ |
| @@ -1184,7 +1184,7 @@ static ssize_t usbvision_v4l2_read(struct file *file, char __user *buf, | |||
| 1184 | 1184 | ||
| 1185 | frame->bytes_read += count; | 1185 | frame->bytes_read += count; |
| 1186 | PDEBUG(DBG_IO, "%s: {copy} count used=%ld, new bytes_read=%ld", | 1186 | PDEBUG(DBG_IO, "%s: {copy} count used=%ld, new bytes_read=%ld", |
| 1187 | __FUNCTION__, | 1187 | __func__, |
| 1188 | (unsigned long)count, frame->bytes_read); | 1188 | (unsigned long)count, frame->bytes_read); |
| 1189 | 1189 | ||
| 1190 | /* For now, forget the frame if it has not been read in one shot. */ | 1190 | /* For now, forget the frame if it has not been read in one shot. */ |
| @@ -1269,12 +1269,12 @@ static int usbvision_radio_open(struct inode *inode, struct file *file) | |||
| 1269 | (struct usb_usbvision *) video_get_drvdata(dev); | 1269 | (struct usb_usbvision *) video_get_drvdata(dev); |
| 1270 | int errCode = 0; | 1270 | int errCode = 0; |
| 1271 | 1271 | ||
| 1272 | PDEBUG(DBG_IO, "%s:", __FUNCTION__); | 1272 | PDEBUG(DBG_IO, "%s:", __func__); |
| 1273 | 1273 | ||
| 1274 | mutex_lock(&usbvision->lock); | 1274 | mutex_lock(&usbvision->lock); |
| 1275 | 1275 | ||
| 1276 | if (usbvision->user) { | 1276 | if (usbvision->user) { |
| 1277 | err("%s: Someone tried to open an already opened USBVision Radio!", __FUNCTION__); | 1277 | err("%s: Someone tried to open an already opened USBVision Radio!", __func__); |
| 1278 | errCode = -EBUSY; | 1278 | errCode = -EBUSY; |
| 1279 | } | 1279 | } |
| 1280 | else { | 1280 | else { |
| @@ -1342,7 +1342,7 @@ static int usbvision_radio_close(struct inode *inode, struct file *file) | |||
| 1342 | mutex_unlock(&usbvision->lock); | 1342 | mutex_unlock(&usbvision->lock); |
| 1343 | 1343 | ||
| 1344 | if (usbvision->remove_pending) { | 1344 | if (usbvision->remove_pending) { |
| 1345 | printk(KERN_INFO "%s: Final disconnect\n", __FUNCTION__); | 1345 | printk(KERN_INFO "%s: Final disconnect\n", __func__); |
| 1346 | usbvision_release(usbvision); | 1346 | usbvision_release(usbvision); |
| 1347 | } | 1347 | } |
| 1348 | 1348 | ||
| @@ -1507,7 +1507,7 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision, | |||
| 1507 | struct video_device *vdev; | 1507 | struct video_device *vdev; |
| 1508 | 1508 | ||
| 1509 | if (usb_dev == NULL) { | 1509 | if (usb_dev == NULL) { |
| 1510 | err("%s: usbvision->dev is not set", __FUNCTION__); | 1510 | err("%s: usbvision->dev is not set", __func__); |
| 1511 | return NULL; | 1511 | return NULL; |
| 1512 | } | 1512 | } |
| 1513 | 1513 | ||
| @@ -1759,7 +1759,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
| 1759 | PDEBUG(DBG_PROBE, "model out of bounds %d",model); | 1759 | PDEBUG(DBG_PROBE, "model out of bounds %d",model); |
| 1760 | return -ENODEV; | 1760 | return -ENODEV; |
| 1761 | } | 1761 | } |
| 1762 | printk(KERN_INFO "%s: %s found\n", __FUNCTION__, | 1762 | printk(KERN_INFO "%s: %s found\n", __func__, |
| 1763 | usbvision_device_data[model].ModelString); | 1763 | usbvision_device_data[model].ModelString); |
| 1764 | 1764 | ||
| 1765 | if (usbvision_device_data[model].Interface >= 0) { | 1765 | if (usbvision_device_data[model].Interface >= 0) { |
| @@ -1771,20 +1771,20 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
| 1771 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != | 1771 | if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != |
| 1772 | USB_ENDPOINT_XFER_ISOC) { | 1772 | USB_ENDPOINT_XFER_ISOC) { |
| 1773 | err("%s: interface %d. has non-ISO endpoint!", | 1773 | err("%s: interface %d. has non-ISO endpoint!", |
| 1774 | __FUNCTION__, ifnum); | 1774 | __func__, ifnum); |
| 1775 | err("%s: Endpoint attributes %d", | 1775 | err("%s: Endpoint attributes %d", |
| 1776 | __FUNCTION__, endpoint->bmAttributes); | 1776 | __func__, endpoint->bmAttributes); |
| 1777 | return -ENODEV; | 1777 | return -ENODEV; |
| 1778 | } | 1778 | } |
| 1779 | if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == | 1779 | if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == |
| 1780 | USB_DIR_OUT) { | 1780 | USB_DIR_OUT) { |
| 1781 | err("%s: interface %d. has ISO OUT endpoint!", | 1781 | err("%s: interface %d. has ISO OUT endpoint!", |
| 1782 | __FUNCTION__, ifnum); | 1782 | __func__, ifnum); |
| 1783 | return -ENODEV; | 1783 | return -ENODEV; |
| 1784 | } | 1784 | } |
| 1785 | 1785 | ||
| 1786 | if ((usbvision = usbvision_alloc(dev)) == NULL) { | 1786 | if ((usbvision = usbvision_alloc(dev)) == NULL) { |
| 1787 | err("%s: couldn't allocate USBVision struct", __FUNCTION__); | 1787 | err("%s: couldn't allocate USBVision struct", __func__); |
| 1788 | return -ENOMEM; | 1788 | return -ENOMEM; |
| 1789 | } | 1789 | } |
| 1790 | 1790 | ||
| @@ -1868,7 +1868,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf) | |||
| 1868 | PDEBUG(DBG_PROBE, ""); | 1868 | PDEBUG(DBG_PROBE, ""); |
| 1869 | 1869 | ||
| 1870 | if (usbvision == NULL) { | 1870 | if (usbvision == NULL) { |
| 1871 | err("%s: usb_get_intfdata() failed", __FUNCTION__); | 1871 | err("%s: usb_get_intfdata() failed", __func__); |
| 1872 | return; | 1872 | return; |
| 1873 | } | 1873 | } |
| 1874 | usb_set_intfdata (intf, NULL); | 1874 | usb_set_intfdata (intf, NULL); |
| @@ -1891,7 +1891,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf) | |||
| 1891 | 1891 | ||
| 1892 | if (usbvision->user) { | 1892 | if (usbvision->user) { |
| 1893 | printk(KERN_INFO "%s: In use, disconnect pending\n", | 1893 | printk(KERN_INFO "%s: In use, disconnect pending\n", |
| 1894 | __FUNCTION__); | 1894 | __func__); |
| 1895 | wake_up_interruptible(&usbvision->wait_frame); | 1895 | wake_up_interruptible(&usbvision->wait_frame); |
| 1896 | wake_up_interruptible(&usbvision->wait_stream); | 1896 | wake_up_interruptible(&usbvision->wait_stream); |
| 1897 | } else { | 1897 | } else { |
diff --git a/drivers/media/video/v4l1-compat.c b/drivers/media/video/v4l1-compat.c index e3ac5e686075..a0f6c60279ec 100644 --- a/drivers/media/video/v4l1-compat.c +++ b/drivers/media/video/v4l1-compat.c | |||
| @@ -39,15 +39,18 @@ | |||
| 39 | #include <linux/kmod.h> | 39 | #include <linux/kmod.h> |
| 40 | #endif | 40 | #endif |
| 41 | 41 | ||
| 42 | static unsigned int debug = 0; | 42 | static unsigned int debug; |
| 43 | module_param(debug, int, 0644); | 43 | module_param(debug, int, 0644); |
| 44 | MODULE_PARM_DESC(debug,"enable debug messages"); | 44 | MODULE_PARM_DESC(debug, "enable debug messages"); |
| 45 | MODULE_AUTHOR("Bill Dirks"); | 45 | MODULE_AUTHOR("Bill Dirks"); |
| 46 | MODULE_DESCRIPTION("v4l(1) compatibility layer for v4l2 drivers."); | 46 | MODULE_DESCRIPTION("v4l(1) compatibility layer for v4l2 drivers."); |
| 47 | MODULE_LICENSE("GPL"); | 47 | MODULE_LICENSE("GPL"); |
| 48 | 48 | ||
| 49 | #define dprintk(fmt, arg...) if (debug) \ | 49 | #define dprintk(fmt, arg...) \ |
| 50 | printk(KERN_DEBUG "v4l1-compat: " fmt , ## arg) | 50 | do { \ |
| 51 | if (debug) \ | ||
| 52 | printk(KERN_DEBUG "v4l1-compat: " fmt , ## arg);\ | ||
| 53 | } while (0) | ||
| 51 | 54 | ||
| 52 | /* | 55 | /* |
| 53 | * I O C T L T R A N S L A T I O N | 56 | * I O C T L T R A N S L A T I O N |
| @@ -69,14 +72,12 @@ get_v4l_control(struct inode *inode, | |||
| 69 | qctrl2.id = cid; | 72 | qctrl2.id = cid; |
| 70 | err = drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2); | 73 | err = drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2); |
| 71 | if (err < 0) | 74 | if (err < 0) |
| 72 | dprintk("VIDIOC_QUERYCTRL: %d\n",err); | 75 | dprintk("VIDIOC_QUERYCTRL: %d\n", err); |
| 73 | if (err == 0 && | 76 | if (err == 0 && !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED)) { |
| 74 | !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED)) | ||
| 75 | { | ||
| 76 | ctrl2.id = qctrl2.id; | 77 | ctrl2.id = qctrl2.id; |
| 77 | err = drv(inode, file, VIDIOC_G_CTRL, &ctrl2); | 78 | err = drv(inode, file, VIDIOC_G_CTRL, &ctrl2); |
| 78 | if (err < 0) { | 79 | if (err < 0) { |
| 79 | dprintk("VIDIOC_G_CTRL: %d\n",err); | 80 | dprintk("VIDIOC_G_CTRL: %d\n", err); |
| 80 | return 0; | 81 | return 0; |
| 81 | } | 82 | } |
| 82 | return ((ctrl2.value - qctrl2.minimum) * 65535 | 83 | return ((ctrl2.value - qctrl2.minimum) * 65535 |
| @@ -100,11 +101,10 @@ set_v4l_control(struct inode *inode, | |||
| 100 | qctrl2.id = cid; | 101 | qctrl2.id = cid; |
| 101 | err = drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2); | 102 | err = drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2); |
| 102 | if (err < 0) | 103 | if (err < 0) |
| 103 | dprintk("VIDIOC_QUERYCTRL: %d\n",err); | 104 | dprintk("VIDIOC_QUERYCTRL: %d\n", err); |
| 104 | if (err == 0 && | 105 | if (err == 0 && |
| 105 | !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED) && | 106 | !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED) && |
| 106 | !(qctrl2.flags & V4L2_CTRL_FLAG_GRABBED)) | 107 | !(qctrl2.flags & V4L2_CTRL_FLAG_GRABBED)) { |
| 107 | { | ||
| 108 | if (value < 0) | 108 | if (value < 0) |
| 109 | value = 0; | 109 | value = 0; |
| 110 | if (value > 65535) | 110 | if (value > 65535) |
| @@ -119,7 +119,7 @@ set_v4l_control(struct inode *inode, | |||
| 119 | ctrl2.value += qctrl2.minimum; | 119 | ctrl2.value += qctrl2.minimum; |
| 120 | err = drv(inode, file, VIDIOC_S_CTRL, &ctrl2); | 120 | err = drv(inode, file, VIDIOC_S_CTRL, &ctrl2); |
| 121 | if (err < 0) | 121 | if (err < 0) |
| 122 | dprintk("VIDIOC_S_CTRL: %d\n",err); | 122 | dprintk("VIDIOC_S_CTRL: %d\n", err); |
| 123 | } | 123 | } |
| 124 | return 0; | 124 | return 0; |
| 125 | } | 125 | } |
| @@ -157,8 +157,7 @@ static unsigned int __attribute_const__ | |||
| 157 | pixelformat_to_palette(unsigned int pixelformat) | 157 | pixelformat_to_palette(unsigned int pixelformat) |
| 158 | { | 158 | { |
| 159 | int palette = 0; | 159 | int palette = 0; |
| 160 | switch (pixelformat) | 160 | switch (pixelformat) { |
| 161 | { | ||
| 162 | case V4L2_PIX_FMT_GREY: | 161 | case V4L2_PIX_FMT_GREY: |
| 163 | palette = VIDEO_PALETTE_GREY; | 162 | palette = VIDEO_PALETTE_GREY; |
| 164 | break; | 163 | break; |
| @@ -200,14 +199,13 @@ pixelformat_to_palette(unsigned int pixelformat) | |||
| 200 | 199 | ||
| 201 | /* ----------------------------------------------------------------- */ | 200 | /* ----------------------------------------------------------------- */ |
| 202 | 201 | ||
| 203 | static int poll_one(struct file *file) | 202 | static int poll_one(struct file *file, struct poll_wqueues *pwq) |
| 204 | { | 203 | { |
| 205 | int retval = 1; | 204 | int retval = 1; |
| 206 | poll_table *table; | 205 | poll_table *table; |
| 207 | struct poll_wqueues pwq; | ||
| 208 | 206 | ||
| 209 | poll_initwait(&pwq); | 207 | poll_initwait(pwq); |
| 210 | table = &pwq.pt; | 208 | table = &pwq->pt; |
| 211 | for (;;) { | 209 | for (;;) { |
| 212 | int mask; | 210 | int mask; |
| 213 | set_current_state(TASK_INTERRUPTIBLE); | 211 | set_current_state(TASK_INTERRUPTIBLE); |
| @@ -222,878 +220,1073 @@ static int poll_one(struct file *file) | |||
| 222 | schedule(); | 220 | schedule(); |
| 223 | } | 221 | } |
| 224 | set_current_state(TASK_RUNNING); | 222 | set_current_state(TASK_RUNNING); |
| 225 | poll_freewait(&pwq); | 223 | poll_freewait(pwq); |
| 226 | return retval; | 224 | return retval; |
| 227 | } | 225 | } |
| 228 | 226 | ||
| 229 | static int count_inputs(struct inode *inode, | 227 | static int count_inputs( |
| 230 | struct file *file, | 228 | struct inode *inode, |
| 231 | v4l2_kioctl drv) | 229 | struct file *file, |
| 230 | v4l2_kioctl drv) | ||
| 232 | { | 231 | { |
| 233 | struct v4l2_input input2; | 232 | struct v4l2_input input2; |
| 234 | int i; | 233 | int i; |
| 235 | 234 | ||
| 236 | for (i = 0;; i++) { | 235 | for (i = 0;; i++) { |
| 237 | memset(&input2,0,sizeof(input2)); | 236 | memset(&input2, 0, sizeof(input2)); |
| 238 | input2.index = i; | 237 | input2.index = i; |
| 239 | if (0 != drv(inode,file,VIDIOC_ENUMINPUT, &input2)) | 238 | if (0 != drv(inode, file, VIDIOC_ENUMINPUT, &input2)) |
| 240 | break; | 239 | break; |
| 241 | } | 240 | } |
| 242 | return i; | 241 | return i; |
| 243 | } | 242 | } |
| 244 | 243 | ||
| 245 | static int check_size(struct inode *inode, | 244 | static int check_size( |
| 246 | struct file *file, | 245 | struct inode *inode, |
| 247 | v4l2_kioctl drv, | 246 | struct file *file, |
| 248 | int *maxw, int *maxh) | 247 | v4l2_kioctl drv, |
| 248 | int *maxw, | ||
| 249 | int *maxh) | ||
| 249 | { | 250 | { |
| 250 | struct v4l2_fmtdesc desc2; | 251 | struct v4l2_fmtdesc desc2; |
| 251 | struct v4l2_format fmt2; | 252 | struct v4l2_format fmt2; |
| 252 | 253 | ||
| 253 | memset(&desc2,0,sizeof(desc2)); | 254 | memset(&desc2, 0, sizeof(desc2)); |
| 254 | memset(&fmt2,0,sizeof(fmt2)); | 255 | memset(&fmt2, 0, sizeof(fmt2)); |
| 255 | 256 | ||
| 256 | desc2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 257 | desc2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 257 | if (0 != drv(inode,file,VIDIOC_ENUM_FMT, &desc2)) | 258 | if (0 != drv(inode, file, VIDIOC_ENUM_FMT, &desc2)) |
| 258 | goto done; | 259 | goto done; |
| 259 | 260 | ||
| 260 | fmt2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 261 | fmt2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 261 | fmt2.fmt.pix.width = 10000; | 262 | fmt2.fmt.pix.width = 10000; |
| 262 | fmt2.fmt.pix.height = 10000; | 263 | fmt2.fmt.pix.height = 10000; |
| 263 | fmt2.fmt.pix.pixelformat = desc2.pixelformat; | 264 | fmt2.fmt.pix.pixelformat = desc2.pixelformat; |
| 264 | if (0 != drv(inode,file,VIDIOC_TRY_FMT, &fmt2)) | 265 | if (0 != drv(inode, file, VIDIOC_TRY_FMT, &fmt2)) |
| 265 | goto done; | 266 | goto done; |
| 266 | 267 | ||
| 267 | *maxw = fmt2.fmt.pix.width; | 268 | *maxw = fmt2.fmt.pix.width; |
| 268 | *maxh = fmt2.fmt.pix.height; | 269 | *maxh = fmt2.fmt.pix.height; |
| 269 | 270 | ||
| 270 | done: | 271 | done: |
| 271 | return 0; | 272 | return 0; |
| 272 | } | 273 | } |
| 273 | 274 | ||
| 274 | /* ----------------------------------------------------------------- */ | 275 | /* ----------------------------------------------------------------- */ |
| 275 | 276 | ||
| 276 | /* | 277 | static noinline int v4l1_compat_get_capabilities( |
| 277 | * This function is exported. | 278 | struct video_capability *cap, |
| 278 | */ | 279 | struct inode *inode, |
| 279 | int | 280 | struct file *file, |
| 280 | v4l_compat_translate_ioctl(struct inode *inode, | 281 | v4l2_kioctl drv) |
| 281 | struct file *file, | ||
| 282 | int cmd, | ||
| 283 | void *arg, | ||
| 284 | v4l2_kioctl drv) | ||
| 285 | { | 282 | { |
| 286 | struct v4l2_capability *cap2 = NULL; | 283 | int err; |
| 287 | struct v4l2_format *fmt2 = NULL; | 284 | struct v4l2_framebuffer fbuf; |
| 288 | enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 285 | struct v4l2_capability *cap2; |
| 289 | 286 | ||
| 290 | struct v4l2_framebuffer fbuf2; | 287 | cap2 = kzalloc(sizeof(*cap2), GFP_KERNEL); |
| 291 | struct v4l2_input input2; | 288 | if (!cap2) { |
| 292 | struct v4l2_tuner tun2; | 289 | err = -ENOMEM; |
| 293 | struct v4l2_standard std2; | 290 | return err; |
| 294 | struct v4l2_frequency freq2; | 291 | } |
| 295 | struct v4l2_audio aud2; | 292 | memset(cap, 0, sizeof(*cap)); |
| 296 | struct v4l2_queryctrl qctrl2; | 293 | memset(&fbuf, 0, sizeof(fbuf)); |
| 297 | struct v4l2_buffer buf2; | ||
| 298 | v4l2_std_id sid; | ||
| 299 | int i, err = 0; | ||
| 300 | |||
| 301 | switch (cmd) { | ||
| 302 | case VIDIOCGCAP: /* capability */ | ||
| 303 | { | ||
| 304 | struct video_capability *cap = arg; | ||
| 305 | |||
| 306 | cap2 = kzalloc(sizeof(*cap2), GFP_KERNEL); | ||
| 307 | if (!cap2) { | ||
| 308 | err = -ENOMEM; | ||
| 309 | break; | ||
| 310 | } | ||
| 311 | memset(cap, 0, sizeof(*cap)); | ||
| 312 | memset(&fbuf2, 0, sizeof(fbuf2)); | ||
| 313 | 294 | ||
| 314 | err = drv(inode, file, VIDIOC_QUERYCAP, cap2); | 295 | err = drv(inode, file, VIDIOC_QUERYCAP, cap2); |
| 296 | if (err < 0) { | ||
| 297 | dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %d\n", err); | ||
| 298 | goto done; | ||
| 299 | } | ||
| 300 | if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) { | ||
| 301 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf); | ||
| 315 | if (err < 0) { | 302 | if (err < 0) { |
| 316 | dprintk("VIDIOCGCAP / VIDIOC_QUERYCAP: %d\n",err); | 303 | dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %d\n", err); |
| 317 | break; | 304 | memset(&fbuf, 0, sizeof(fbuf)); |
| 318 | } | 305 | } |
| 319 | if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) { | 306 | err = 0; |
| 320 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); | ||
| 321 | if (err < 0) { | ||
| 322 | dprintk("VIDIOCGCAP / VIDIOC_G_FBUF: %d\n",err); | ||
| 323 | memset(&fbuf2, 0, sizeof(fbuf2)); | ||
| 324 | } | ||
| 325 | err = 0; | ||
| 326 | } | ||
| 327 | |||
| 328 | memcpy(cap->name, cap2->card, | ||
| 329 | min(sizeof(cap->name), sizeof(cap2->card))); | ||
| 330 | cap->name[sizeof(cap->name) - 1] = 0; | ||
| 331 | if (cap2->capabilities & V4L2_CAP_VIDEO_CAPTURE) | ||
| 332 | cap->type |= VID_TYPE_CAPTURE; | ||
| 333 | if (cap2->capabilities & V4L2_CAP_TUNER) | ||
| 334 | cap->type |= VID_TYPE_TUNER; | ||
| 335 | if (cap2->capabilities & V4L2_CAP_VBI_CAPTURE) | ||
| 336 | cap->type |= VID_TYPE_TELETEXT; | ||
| 337 | if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) | ||
| 338 | cap->type |= VID_TYPE_OVERLAY; | ||
| 339 | if (fbuf2.capability & V4L2_FBUF_CAP_LIST_CLIPPING) | ||
| 340 | cap->type |= VID_TYPE_CLIPPING; | ||
| 341 | |||
| 342 | cap->channels = count_inputs(inode,file,drv); | ||
| 343 | check_size(inode,file,drv, | ||
| 344 | &cap->maxwidth,&cap->maxheight); | ||
| 345 | cap->audios = 0; /* FIXME */ | ||
| 346 | cap->minwidth = 48; /* FIXME */ | ||
| 347 | cap->minheight = 32; /* FIXME */ | ||
| 348 | break; | ||
| 349 | } | 307 | } |
| 350 | case VIDIOCGFBUF: /* get frame buffer */ | ||
| 351 | { | ||
| 352 | struct video_buffer *buffer = arg; | ||
| 353 | 308 | ||
| 354 | memset(buffer, 0, sizeof(*buffer)); | 309 | memcpy(cap->name, cap2->card, |
| 355 | memset(&fbuf2, 0, sizeof(fbuf2)); | 310 | min(sizeof(cap->name), sizeof(cap2->card))); |
| 311 | cap->name[sizeof(cap->name) - 1] = 0; | ||
| 312 | if (cap2->capabilities & V4L2_CAP_VIDEO_CAPTURE) | ||
| 313 | cap->type |= VID_TYPE_CAPTURE; | ||
| 314 | if (cap2->capabilities & V4L2_CAP_TUNER) | ||
| 315 | cap->type |= VID_TYPE_TUNER; | ||
| 316 | if (cap2->capabilities & V4L2_CAP_VBI_CAPTURE) | ||
| 317 | cap->type |= VID_TYPE_TELETEXT; | ||
| 318 | if (cap2->capabilities & V4L2_CAP_VIDEO_OVERLAY) | ||
| 319 | cap->type |= VID_TYPE_OVERLAY; | ||
| 320 | if (fbuf.capability & V4L2_FBUF_CAP_LIST_CLIPPING) | ||
| 321 | cap->type |= VID_TYPE_CLIPPING; | ||
| 322 | |||
| 323 | cap->channels = count_inputs(inode, file, drv); | ||
| 324 | check_size(inode, file, drv, | ||
| 325 | &cap->maxwidth, &cap->maxheight); | ||
| 326 | cap->audios = 0; /* FIXME */ | ||
| 327 | cap->minwidth = 48; /* FIXME */ | ||
| 328 | cap->minheight = 32; /* FIXME */ | ||
| 329 | |||
| 330 | done: | ||
| 331 | kfree(cap2); | ||
| 332 | return err; | ||
| 333 | } | ||
| 356 | 334 | ||
| 357 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); | 335 | static noinline int v4l1_compat_get_frame_buffer( |
| 358 | if (err < 0) { | 336 | struct video_buffer *buffer, |
| 359 | dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n",err); | 337 | struct inode *inode, |
| 360 | break; | 338 | struct file *file, |
| 361 | } | 339 | v4l2_kioctl drv) |
| 362 | buffer->base = fbuf2.base; | 340 | { |
| 363 | buffer->height = fbuf2.fmt.height; | 341 | int err; |
| 364 | buffer->width = fbuf2.fmt.width; | 342 | struct v4l2_framebuffer fbuf; |
| 365 | 343 | ||
| 366 | switch (fbuf2.fmt.pixelformat) { | 344 | memset(buffer, 0, sizeof(*buffer)); |
| 367 | case V4L2_PIX_FMT_RGB332: | 345 | memset(&fbuf, 0, sizeof(fbuf)); |
| 368 | buffer->depth = 8; | 346 | |
| 369 | break; | 347 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf); |
| 370 | case V4L2_PIX_FMT_RGB555: | 348 | if (err < 0) { |
| 371 | buffer->depth = 15; | 349 | dprintk("VIDIOCGFBUF / VIDIOC_G_FBUF: %d\n", err); |
| 372 | break; | 350 | goto done; |
| 373 | case V4L2_PIX_FMT_RGB565: | 351 | } |
| 374 | buffer->depth = 16; | 352 | buffer->base = fbuf.base; |
| 375 | break; | 353 | buffer->height = fbuf.fmt.height; |
| 376 | case V4L2_PIX_FMT_BGR24: | 354 | buffer->width = fbuf.fmt.width; |
| 377 | buffer->depth = 24; | 355 | |
| 378 | break; | 356 | switch (fbuf.fmt.pixelformat) { |
| 379 | case V4L2_PIX_FMT_BGR32: | 357 | case V4L2_PIX_FMT_RGB332: |
| 380 | buffer->depth = 32; | 358 | buffer->depth = 8; |
| 381 | break; | 359 | break; |
| 382 | default: | 360 | case V4L2_PIX_FMT_RGB555: |
| 383 | buffer->depth = 0; | 361 | buffer->depth = 15; |
| 384 | } | 362 | break; |
| 385 | if (fbuf2.fmt.bytesperline) { | 363 | case V4L2_PIX_FMT_RGB565: |
| 386 | buffer->bytesperline = fbuf2.fmt.bytesperline; | 364 | buffer->depth = 16; |
| 387 | if (!buffer->depth && buffer->width) | 365 | break; |
| 388 | buffer->depth = ((fbuf2.fmt.bytesperline<<3) | 366 | case V4L2_PIX_FMT_BGR24: |
| 389 | + (buffer->width-1) ) | 367 | buffer->depth = 24; |
| 390 | /buffer->width; | 368 | break; |
| 391 | } else { | 369 | case V4L2_PIX_FMT_BGR32: |
| 392 | buffer->bytesperline = | 370 | buffer->depth = 32; |
| 393 | (buffer->width * buffer->depth + 7) & 7; | ||
| 394 | buffer->bytesperline >>= 3; | ||
| 395 | } | ||
| 396 | break; | 371 | break; |
| 372 | default: | ||
| 373 | buffer->depth = 0; | ||
| 397 | } | 374 | } |
| 398 | case VIDIOCSFBUF: /* set frame buffer */ | 375 | if (fbuf.fmt.bytesperline) { |
| 399 | { | 376 | buffer->bytesperline = fbuf.fmt.bytesperline; |
| 400 | struct video_buffer *buffer = arg; | 377 | if (!buffer->depth && buffer->width) |
| 401 | 378 | buffer->depth = ((fbuf.fmt.bytesperline<<3) | |
| 402 | memset(&fbuf2, 0, sizeof(fbuf2)); | 379 | + (buffer->width-1)) |
| 403 | fbuf2.base = buffer->base; | 380 | / buffer->width; |
| 404 | fbuf2.fmt.height = buffer->height; | 381 | } else { |
| 405 | fbuf2.fmt.width = buffer->width; | 382 | buffer->bytesperline = |
| 406 | switch (buffer->depth) { | 383 | (buffer->width * buffer->depth + 7) & 7; |
| 407 | case 8: | 384 | buffer->bytesperline >>= 3; |
| 408 | fbuf2.fmt.pixelformat = V4L2_PIX_FMT_RGB332; | 385 | } |
| 409 | break; | 386 | done: |
| 410 | case 15: | 387 | return err; |
| 411 | fbuf2.fmt.pixelformat = V4L2_PIX_FMT_RGB555; | 388 | } |
| 412 | break; | 389 | |
| 413 | case 16: | 390 | static noinline int v4l1_compat_set_frame_buffer( |
| 414 | fbuf2.fmt.pixelformat = V4L2_PIX_FMT_RGB565; | 391 | struct video_buffer *buffer, |
| 415 | break; | 392 | struct inode *inode, |
| 416 | case 24: | 393 | struct file *file, |
| 417 | fbuf2.fmt.pixelformat = V4L2_PIX_FMT_BGR24; | 394 | v4l2_kioctl drv) |
| 418 | break; | 395 | { |
| 419 | case 32: | 396 | int err; |
| 420 | fbuf2.fmt.pixelformat = V4L2_PIX_FMT_BGR32; | 397 | struct v4l2_framebuffer fbuf; |
| 421 | break; | 398 | |
| 422 | } | 399 | memset(&fbuf, 0, sizeof(fbuf)); |
| 423 | fbuf2.fmt.bytesperline = buffer->bytesperline; | 400 | fbuf.base = buffer->base; |
| 424 | err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); | 401 | fbuf.fmt.height = buffer->height; |
| 425 | if (err < 0) | 402 | fbuf.fmt.width = buffer->width; |
| 426 | dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %d\n",err); | 403 | switch (buffer->depth) { |
| 404 | case 8: | ||
| 405 | fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB332; | ||
| 406 | break; | ||
| 407 | case 15: | ||
| 408 | fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB555; | ||
| 409 | break; | ||
| 410 | case 16: | ||
| 411 | fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB565; | ||
| 412 | break; | ||
| 413 | case 24: | ||
| 414 | fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR24; | ||
| 415 | break; | ||
| 416 | case 32: | ||
| 417 | fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR32; | ||
| 427 | break; | 418 | break; |
| 428 | } | 419 | } |
| 429 | case VIDIOCGWIN: /* get window or capture dimensions */ | 420 | fbuf.fmt.bytesperline = buffer->bytesperline; |
| 430 | { | 421 | err = drv(inode, file, VIDIOC_S_FBUF, &fbuf); |
| 431 | struct video_window *win = arg; | 422 | if (err < 0) |
| 423 | dprintk("VIDIOCSFBUF / VIDIOC_S_FBUF: %d\n", err); | ||
| 424 | return err; | ||
| 425 | } | ||
| 432 | 426 | ||
| 433 | fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); | 427 | static noinline int v4l1_compat_get_win_cap_dimensions( |
| 434 | if (!fmt2) { | 428 | struct video_window *win, |
| 435 | err = -ENOMEM; | 429 | struct inode *inode, |
| 436 | break; | 430 | struct file *file, |
| 437 | } | 431 | v4l2_kioctl drv) |
| 438 | memset(win,0,sizeof(*win)); | 432 | { |
| 433 | int err; | ||
| 434 | struct v4l2_format *fmt; | ||
| 439 | 435 | ||
| 440 | fmt2->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; | 436 | fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); |
| 441 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | 437 | if (!fmt) { |
| 442 | if (err < 0) | 438 | err = -ENOMEM; |
| 443 | dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %d\n",err); | 439 | return err; |
| 444 | if (err == 0) { | 440 | } |
| 445 | win->x = fmt2->fmt.win.w.left; | 441 | memset(win, 0, sizeof(*win)); |
| 446 | win->y = fmt2->fmt.win.w.top; | ||
| 447 | win->width = fmt2->fmt.win.w.width; | ||
| 448 | win->height = fmt2->fmt.win.w.height; | ||
| 449 | win->chromakey = fmt2->fmt.win.chromakey; | ||
| 450 | win->clips = NULL; | ||
| 451 | win->clipcount = 0; | ||
| 452 | break; | ||
| 453 | } | ||
| 454 | 442 | ||
| 455 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 443 | fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; |
| 456 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | 444 | err = drv(inode, file, VIDIOC_G_FMT, fmt); |
| 457 | if (err < 0) { | 445 | if (err < 0) |
| 458 | dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %d\n",err); | 446 | dprintk("VIDIOCGWIN / VIDIOC_G_WIN: %d\n", err); |
| 459 | break; | 447 | if (err == 0) { |
| 460 | } | 448 | win->x = fmt->fmt.win.w.left; |
| 461 | win->x = 0; | 449 | win->y = fmt->fmt.win.w.top; |
| 462 | win->y = 0; | 450 | win->width = fmt->fmt.win.w.width; |
| 463 | win->width = fmt2->fmt.pix.width; | 451 | win->height = fmt->fmt.win.w.height; |
| 464 | win->height = fmt2->fmt.pix.height; | 452 | win->chromakey = fmt->fmt.win.chromakey; |
| 465 | win->chromakey = 0; | ||
| 466 | win->clips = NULL; | 453 | win->clips = NULL; |
| 467 | win->clipcount = 0; | 454 | win->clipcount = 0; |
| 468 | break; | 455 | goto done; |
| 469 | } | 456 | } |
| 470 | case VIDIOCSWIN: /* set window and/or capture dimensions */ | ||
| 471 | { | ||
| 472 | struct video_window *win = arg; | ||
| 473 | int err1,err2; | ||
| 474 | 457 | ||
| 475 | fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); | 458 | fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 476 | if (!fmt2) { | 459 | err = drv(inode, file, VIDIOC_G_FMT, fmt); |
| 477 | err = -ENOMEM; | 460 | if (err < 0) { |
| 478 | break; | 461 | dprintk("VIDIOCGWIN / VIDIOC_G_FMT: %d\n", err); |
| 479 | } | 462 | goto done; |
| 480 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 463 | } |
| 481 | drv(inode, file, VIDIOC_STREAMOFF, &fmt2->type); | 464 | win->x = 0; |
| 482 | err1 = drv(inode, file, VIDIOC_G_FMT, fmt2); | 465 | win->y = 0; |
| 483 | if (err1 < 0) | 466 | win->width = fmt->fmt.pix.width; |
| 484 | dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %d\n",err); | 467 | win->height = fmt->fmt.pix.height; |
| 485 | if (err1 == 0) { | 468 | win->chromakey = 0; |
| 486 | fmt2->fmt.pix.width = win->width; | 469 | win->clips = NULL; |
| 487 | fmt2->fmt.pix.height = win->height; | 470 | win->clipcount = 0; |
| 488 | fmt2->fmt.pix.field = V4L2_FIELD_ANY; | 471 | done: |
| 489 | fmt2->fmt.pix.bytesperline = 0; | 472 | kfree(fmt); |
| 490 | err = drv(inode, file, VIDIOC_S_FMT, fmt2); | 473 | return err; |
| 491 | if (err < 0) | 474 | } |
| 492 | dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %d\n", | ||
| 493 | err); | ||
| 494 | win->width = fmt2->fmt.pix.width; | ||
| 495 | win->height = fmt2->fmt.pix.height; | ||
| 496 | } | ||
| 497 | 475 | ||
| 498 | memset(fmt2,0,sizeof(*fmt2)); | 476 | static noinline int v4l1_compat_set_win_cap_dimensions( |
| 499 | fmt2->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; | 477 | struct video_window *win, |
| 500 | fmt2->fmt.win.w.left = win->x; | 478 | struct inode *inode, |
| 501 | fmt2->fmt.win.w.top = win->y; | 479 | struct file *file, |
| 502 | fmt2->fmt.win.w.width = win->width; | 480 | v4l2_kioctl drv) |
| 503 | fmt2->fmt.win.w.height = win->height; | 481 | { |
| 504 | fmt2->fmt.win.chromakey = win->chromakey; | 482 | int err, err1, err2; |
| 505 | fmt2->fmt.win.clips = (void __user *)win->clips; | 483 | struct v4l2_format *fmt; |
| 506 | fmt2->fmt.win.clipcount = win->clipcount; | 484 | |
| 507 | err2 = drv(inode, file, VIDIOC_S_FMT, fmt2); | 485 | fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); |
| 508 | if (err2 < 0) | 486 | if (!fmt) { |
| 509 | dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %d\n",err); | 487 | err = -ENOMEM; |
| 510 | 488 | return err; | |
| 511 | if (err1 != 0 && err2 != 0) | ||
| 512 | err = err1; | ||
| 513 | break; | ||
| 514 | } | 489 | } |
| 515 | case VIDIOCCAPTURE: /* turn on/off preview */ | 490 | fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 516 | { | 491 | drv(inode, file, VIDIOC_STREAMOFF, &fmt->type); |
| 517 | int *on = arg; | 492 | err1 = drv(inode, file, VIDIOC_G_FMT, fmt); |
| 518 | 493 | if (err1 < 0) | |
| 519 | if (0 == *on) { | 494 | dprintk("VIDIOCSWIN / VIDIOC_G_FMT: %d\n", err1); |
| 520 | /* dirty hack time. But v4l1 has no STREAMOFF | 495 | if (err1 == 0) { |
| 521 | * equivalent in the API, and this one at | 496 | fmt->fmt.pix.width = win->width; |
| 522 | * least comes close ... */ | 497 | fmt->fmt.pix.height = win->height; |
| 523 | drv(inode, file, VIDIOC_STREAMOFF, &captype); | 498 | fmt->fmt.pix.field = V4L2_FIELD_ANY; |
| 524 | } | 499 | fmt->fmt.pix.bytesperline = 0; |
| 525 | err = drv(inode, file, VIDIOC_OVERLAY, arg); | 500 | err = drv(inode, file, VIDIOC_S_FMT, fmt); |
| 526 | if (err < 0) | 501 | if (err < 0) |
| 527 | dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %d\n",err); | 502 | dprintk("VIDIOCSWIN / VIDIOC_S_FMT #1: %d\n", |
| 528 | break; | 503 | err); |
| 504 | win->width = fmt->fmt.pix.width; | ||
| 505 | win->height = fmt->fmt.pix.height; | ||
| 529 | } | 506 | } |
| 530 | case VIDIOCGCHAN: /* get input information */ | ||
| 531 | { | ||
| 532 | struct video_channel *chan = arg; | ||
| 533 | 507 | ||
| 534 | memset(&input2,0,sizeof(input2)); | 508 | memset(fmt, 0, sizeof(*fmt)); |
| 535 | input2.index = chan->channel; | 509 | fmt->type = V4L2_BUF_TYPE_VIDEO_OVERLAY; |
| 536 | err = drv(inode, file, VIDIOC_ENUMINPUT, &input2); | 510 | fmt->fmt.win.w.left = win->x; |
| 537 | if (err < 0) { | 511 | fmt->fmt.win.w.top = win->y; |
| 538 | dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: " | 512 | fmt->fmt.win.w.width = win->width; |
| 539 | "channel=%d err=%d\n",chan->channel,err); | 513 | fmt->fmt.win.w.height = win->height; |
| 540 | break; | 514 | fmt->fmt.win.chromakey = win->chromakey; |
| 541 | } | 515 | fmt->fmt.win.clips = (void __user *)win->clips; |
| 542 | chan->channel = input2.index; | 516 | fmt->fmt.win.clipcount = win->clipcount; |
| 543 | memcpy(chan->name, input2.name, | 517 | err2 = drv(inode, file, VIDIOC_S_FMT, fmt); |
| 544 | min(sizeof(chan->name), sizeof(input2.name))); | 518 | if (err2 < 0) |
| 545 | chan->name[sizeof(chan->name) - 1] = 0; | 519 | dprintk("VIDIOCSWIN / VIDIOC_S_FMT #2: %d\n", err2); |
| 546 | chan->tuners = (input2.type == V4L2_INPUT_TYPE_TUNER) ? 1 : 0; | 520 | |
| 547 | chan->flags = (chan->tuners) ? VIDEO_VC_TUNER : 0; | 521 | if (err1 != 0 && err2 != 0) |
| 548 | switch (input2.type) { | 522 | err = err1; |
| 549 | case V4L2_INPUT_TYPE_TUNER: | 523 | else |
| 550 | chan->type = VIDEO_TYPE_TV; | 524 | err = 0; |
| 551 | break; | 525 | kfree(fmt); |
| 552 | default: | 526 | return err; |
| 553 | case V4L2_INPUT_TYPE_CAMERA: | 527 | } |
| 554 | chan->type = VIDEO_TYPE_CAMERA; | ||
| 555 | break; | ||
| 556 | } | ||
| 557 | chan->norm = 0; | ||
| 558 | err = drv(inode, file, VIDIOC_G_STD, &sid); | ||
| 559 | if (err < 0) | ||
| 560 | dprintk("VIDIOCGCHAN / VIDIOC_G_STD: %d\n",err); | ||
| 561 | if (err == 0) { | ||
| 562 | if (sid & V4L2_STD_PAL) | ||
| 563 | chan->norm = VIDEO_MODE_PAL; | ||
| 564 | if (sid & V4L2_STD_NTSC) | ||
| 565 | chan->norm = VIDEO_MODE_NTSC; | ||
| 566 | if (sid & V4L2_STD_SECAM) | ||
| 567 | chan->norm = VIDEO_MODE_SECAM; | ||
| 568 | } | ||
| 569 | break; | ||
| 570 | } | ||
| 571 | case VIDIOCSCHAN: /* set input */ | ||
| 572 | { | ||
| 573 | struct video_channel *chan = arg; | ||
| 574 | 528 | ||
| 575 | sid = 0; | 529 | static noinline int v4l1_compat_turn_preview_on_off( |
| 576 | err = drv(inode, file, VIDIOC_S_INPUT, &chan->channel); | 530 | int *on, |
| 577 | if (err < 0) | 531 | struct inode *inode, |
| 578 | dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %d\n",err); | 532 | struct file *file, |
| 579 | switch (chan->norm) { | 533 | v4l2_kioctl drv) |
| 580 | case VIDEO_MODE_PAL: | 534 | { |
| 581 | sid = V4L2_STD_PAL; | 535 | int err; |
| 582 | break; | 536 | enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 583 | case VIDEO_MODE_NTSC: | 537 | |
| 584 | sid = V4L2_STD_NTSC; | 538 | if (0 == *on) { |
| 585 | break; | 539 | /* dirty hack time. But v4l1 has no STREAMOFF |
| 586 | case VIDEO_MODE_SECAM: | 540 | * equivalent in the API, and this one at |
| 587 | sid = V4L2_STD_SECAM; | 541 | * least comes close ... */ |
| 588 | break; | 542 | drv(inode, file, VIDIOC_STREAMOFF, &captype); |
| 589 | } | ||
| 590 | if (0 != sid) { | ||
| 591 | err = drv(inode, file, VIDIOC_S_STD, &sid); | ||
| 592 | if (err < 0) | ||
| 593 | dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %d\n",err); | ||
| 594 | } | ||
| 595 | break; | ||
| 596 | } | 543 | } |
| 597 | case VIDIOCGPICT: /* get tone controls & partial capture format */ | 544 | err = drv(inode, file, VIDIOC_OVERLAY, on); |
| 598 | { | 545 | if (err < 0) |
| 599 | struct video_picture *pict = arg; | 546 | dprintk("VIDIOCCAPTURE / VIDIOC_PREVIEW: %d\n", err); |
| 600 | 547 | return err; | |
| 601 | fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); | 548 | } |
| 602 | if (!fmt2) { | ||
| 603 | err = -ENOMEM; | ||
| 604 | break; | ||
| 605 | } | ||
| 606 | 549 | ||
| 607 | pict->brightness = get_v4l_control(inode, file, | 550 | static noinline int v4l1_compat_get_input_info( |
| 608 | V4L2_CID_BRIGHTNESS,drv); | 551 | struct video_channel *chan, |
| 609 | pict->hue = get_v4l_control(inode, file, | 552 | struct inode *inode, |
| 610 | V4L2_CID_HUE, drv); | 553 | struct file *file, |
| 611 | pict->contrast = get_v4l_control(inode, file, | 554 | v4l2_kioctl drv) |
| 612 | V4L2_CID_CONTRAST, drv); | 555 | { |
| 613 | pict->colour = get_v4l_control(inode, file, | 556 | int err; |
| 614 | V4L2_CID_SATURATION, drv); | 557 | struct v4l2_input input2; |
| 615 | pict->whiteness = get_v4l_control(inode, file, | 558 | v4l2_std_id sid; |
| 616 | V4L2_CID_WHITENESS, drv); | ||
| 617 | |||
| 618 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 619 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | ||
| 620 | if (err < 0) { | ||
| 621 | dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n",err); | ||
| 622 | break; | ||
| 623 | } | ||
| 624 | 559 | ||
| 625 | pict->depth = ((fmt2->fmt.pix.bytesperline<<3) | 560 | memset(&input2, 0, sizeof(input2)); |
| 626 | + (fmt2->fmt.pix.width-1) ) | 561 | input2.index = chan->channel; |
| 627 | /fmt2->fmt.pix.width; | 562 | err = drv(inode, file, VIDIOC_ENUMINPUT, &input2); |
| 628 | pict->palette = pixelformat_to_palette( | 563 | if (err < 0) { |
| 629 | fmt2->fmt.pix.pixelformat); | 564 | dprintk("VIDIOCGCHAN / VIDIOC_ENUMINPUT: " |
| 565 | "channel=%d err=%d\n", chan->channel, err); | ||
| 566 | goto done; | ||
| 567 | } | ||
| 568 | chan->channel = input2.index; | ||
| 569 | memcpy(chan->name, input2.name, | ||
| 570 | min(sizeof(chan->name), sizeof(input2.name))); | ||
| 571 | chan->name[sizeof(chan->name) - 1] = 0; | ||
| 572 | chan->tuners = (input2.type == V4L2_INPUT_TYPE_TUNER) ? 1 : 0; | ||
| 573 | chan->flags = (chan->tuners) ? VIDEO_VC_TUNER : 0; | ||
| 574 | switch (input2.type) { | ||
| 575 | case V4L2_INPUT_TYPE_TUNER: | ||
| 576 | chan->type = VIDEO_TYPE_TV; | ||
| 577 | break; | ||
| 578 | default: | ||
| 579 | case V4L2_INPUT_TYPE_CAMERA: | ||
| 580 | chan->type = VIDEO_TYPE_CAMERA; | ||
| 630 | break; | 581 | break; |
| 631 | } | 582 | } |
| 632 | case VIDIOCSPICT: /* set tone controls & partial capture format */ | 583 | chan->norm = 0; |
| 633 | { | 584 | err = drv(inode, file, VIDIOC_G_STD, &sid); |
| 634 | struct video_picture *pict = arg; | 585 | if (err < 0) |
| 635 | int mem_err = 0, ovl_err = 0; | 586 | dprintk("VIDIOCGCHAN / VIDIOC_G_STD: %d\n", err); |
| 587 | if (err == 0) { | ||
| 588 | if (sid & V4L2_STD_PAL) | ||
| 589 | chan->norm = VIDEO_MODE_PAL; | ||
| 590 | if (sid & V4L2_STD_NTSC) | ||
| 591 | chan->norm = VIDEO_MODE_NTSC; | ||
| 592 | if (sid & V4L2_STD_SECAM) | ||
| 593 | chan->norm = VIDEO_MODE_SECAM; | ||
| 594 | } | ||
| 595 | done: | ||
| 596 | return err; | ||
| 597 | } | ||
| 636 | 598 | ||
| 637 | fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); | 599 | static noinline int v4l1_compat_set_input( |
| 638 | if (!fmt2) { | 600 | struct video_channel *chan, |
| 639 | err = -ENOMEM; | 601 | struct inode *inode, |
| 640 | break; | 602 | struct file *file, |
| 641 | } | 603 | v4l2_kioctl drv) |
| 642 | memset(&fbuf2, 0, sizeof(fbuf2)); | 604 | { |
| 643 | 605 | int err; | |
| 644 | set_v4l_control(inode, file, | 606 | v4l2_std_id sid = 0; |
| 645 | V4L2_CID_BRIGHTNESS, pict->brightness, drv); | ||
| 646 | set_v4l_control(inode, file, | ||
| 647 | V4L2_CID_HUE, pict->hue, drv); | ||
| 648 | set_v4l_control(inode, file, | ||
| 649 | V4L2_CID_CONTRAST, pict->contrast, drv); | ||
| 650 | set_v4l_control(inode, file, | ||
| 651 | V4L2_CID_SATURATION, pict->colour, drv); | ||
| 652 | set_v4l_control(inode, file, | ||
| 653 | V4L2_CID_WHITENESS, pict->whiteness, drv); | ||
| 654 | /* | ||
| 655 | * V4L1 uses this ioctl to set both memory capture and overlay | ||
| 656 | * pixel format, while V4L2 has two different ioctls for this. | ||
| 657 | * Some cards may not support one or the other, and may support | ||
| 658 | * different pixel formats for memory vs overlay. | ||
| 659 | */ | ||
| 660 | |||
| 661 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 662 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | ||
| 663 | /* If VIDIOC_G_FMT failed, then the driver likely doesn't | ||
| 664 | support memory capture. Trying to set the memory capture | ||
| 665 | parameters would be pointless. */ | ||
| 666 | if (err < 0) { | ||
| 667 | dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n",err); | ||
| 668 | mem_err = -1000; /* didn't even try */ | ||
| 669 | } else if (fmt2->fmt.pix.pixelformat != | ||
| 670 | palette_to_pixelformat(pict->palette)) { | ||
| 671 | fmt2->fmt.pix.pixelformat = palette_to_pixelformat( | ||
| 672 | pict->palette); | ||
| 673 | mem_err = drv(inode, file, VIDIOC_S_FMT, fmt2); | ||
| 674 | if (mem_err < 0) | ||
| 675 | dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n", | ||
| 676 | mem_err); | ||
| 677 | } | ||
| 678 | 607 | ||
| 679 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf2); | 608 | err = drv(inode, file, VIDIOC_S_INPUT, &chan->channel); |
| 680 | /* If VIDIOC_G_FBUF failed, then the driver likely doesn't | 609 | if (err < 0) |
| 681 | support overlay. Trying to set the overlay parameters | 610 | dprintk("VIDIOCSCHAN / VIDIOC_S_INPUT: %d\n", err); |
| 682 | would be quite pointless. */ | 611 | switch (chan->norm) { |
| 683 | if (err < 0) { | 612 | case VIDEO_MODE_PAL: |
| 684 | dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n",err); | 613 | sid = V4L2_STD_PAL; |
| 685 | ovl_err = -1000; /* didn't even try */ | 614 | break; |
| 686 | } else if (fbuf2.fmt.pixelformat != | 615 | case VIDEO_MODE_NTSC: |
| 687 | palette_to_pixelformat(pict->palette)) { | 616 | sid = V4L2_STD_NTSC; |
| 688 | fbuf2.fmt.pixelformat = palette_to_pixelformat( | 617 | break; |
| 689 | pict->palette); | 618 | case VIDEO_MODE_SECAM: |
| 690 | ovl_err = drv(inode, file, VIDIOC_S_FBUF, &fbuf2); | 619 | sid = V4L2_STD_SECAM; |
| 691 | if (ovl_err < 0) | ||
| 692 | dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n", | ||
| 693 | ovl_err); | ||
| 694 | } | ||
| 695 | if (ovl_err < 0 && mem_err < 0) | ||
| 696 | /* ioctl failed, couldn't set either parameter */ | ||
| 697 | if (mem_err != -1000) { | ||
| 698 | err = mem_err; | ||
| 699 | } else if (ovl_err == -EPERM) { | ||
| 700 | err = 0; | ||
| 701 | } else { | ||
| 702 | err = ovl_err; | ||
| 703 | } | ||
| 704 | else | ||
| 705 | err = 0; | ||
| 706 | break; | 620 | break; |
| 707 | } | 621 | } |
| 708 | case VIDIOCGTUNER: /* get tuner information */ | 622 | if (0 != sid) { |
| 709 | { | 623 | err = drv(inode, file, VIDIOC_S_STD, &sid); |
| 710 | struct video_tuner *tun = arg; | ||
| 711 | |||
| 712 | memset(&tun2,0,sizeof(tun2)); | ||
| 713 | err = drv(inode, file, VIDIOC_G_TUNER, &tun2); | ||
| 714 | if (err < 0) { | ||
| 715 | dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %d\n",err); | ||
| 716 | break; | ||
| 717 | } | ||
| 718 | memcpy(tun->name, tun2.name, | ||
| 719 | min(sizeof(tun->name), sizeof(tun2.name))); | ||
| 720 | tun->name[sizeof(tun->name) - 1] = 0; | ||
| 721 | tun->rangelow = tun2.rangelow; | ||
| 722 | tun->rangehigh = tun2.rangehigh; | ||
| 723 | tun->flags = 0; | ||
| 724 | tun->mode = VIDEO_MODE_AUTO; | ||
| 725 | |||
| 726 | for (i = 0; i < 64; i++) { | ||
| 727 | memset(&std2,0,sizeof(std2)); | ||
| 728 | std2.index = i; | ||
| 729 | if (0 != drv(inode, file, VIDIOC_ENUMSTD, &std2)) | ||
| 730 | break; | ||
| 731 | if (std2.id & V4L2_STD_PAL) | ||
| 732 | tun->flags |= VIDEO_TUNER_PAL; | ||
| 733 | if (std2.id & V4L2_STD_NTSC) | ||
| 734 | tun->flags |= VIDEO_TUNER_NTSC; | ||
| 735 | if (std2.id & V4L2_STD_SECAM) | ||
| 736 | tun->flags |= VIDEO_TUNER_SECAM; | ||
| 737 | } | ||
| 738 | |||
| 739 | err = drv(inode, file, VIDIOC_G_STD, &sid); | ||
| 740 | if (err < 0) | 624 | if (err < 0) |
| 741 | dprintk("VIDIOCGTUNER / VIDIOC_G_STD: %d\n",err); | 625 | dprintk("VIDIOCSCHAN / VIDIOC_S_STD: %d\n", err); |
| 742 | if (err == 0) { | ||
| 743 | if (sid & V4L2_STD_PAL) | ||
| 744 | tun->mode = VIDEO_MODE_PAL; | ||
| 745 | if (sid & V4L2_STD_NTSC) | ||
| 746 | tun->mode = VIDEO_MODE_NTSC; | ||
| 747 | if (sid & V4L2_STD_SECAM) | ||
| 748 | tun->mode = VIDEO_MODE_SECAM; | ||
| 749 | } | ||
| 750 | |||
| 751 | if (tun2.capability & V4L2_TUNER_CAP_LOW) | ||
| 752 | tun->flags |= VIDEO_TUNER_LOW; | ||
| 753 | if (tun2.rxsubchans & V4L2_TUNER_SUB_STEREO) | ||
| 754 | tun->flags |= VIDEO_TUNER_STEREO_ON; | ||
| 755 | tun->signal = tun2.signal; | ||
| 756 | break; | ||
| 757 | } | 626 | } |
| 758 | case VIDIOCSTUNER: /* select a tuner input */ | 627 | return err; |
| 759 | { | 628 | } |
| 760 | struct video_tuner *tun = arg; | ||
| 761 | struct v4l2_tuner t; | ||
| 762 | memset(&t,0,sizeof(t)); | ||
| 763 | |||
| 764 | t.index=tun->tuner; | ||
| 765 | 629 | ||
| 766 | err = drv(inode, file, VIDIOC_S_INPUT, &t); | 630 | static noinline int v4l1_compat_get_picture( |
| 767 | if (err < 0) | 631 | struct video_picture *pict, |
| 768 | dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %d\n",err); | 632 | struct inode *inode, |
| 633 | struct file *file, | ||
| 634 | v4l2_kioctl drv) | ||
| 635 | { | ||
| 636 | int err; | ||
| 637 | struct v4l2_format *fmt; | ||
| 769 | 638 | ||
| 770 | break; | 639 | fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); |
| 640 | if (!fmt) { | ||
| 641 | err = -ENOMEM; | ||
| 642 | return err; | ||
| 771 | } | 643 | } |
| 772 | case VIDIOCGFREQ: /* get frequency */ | ||
| 773 | { | ||
| 774 | unsigned long *freq = arg; | ||
| 775 | memset(&freq2,0,sizeof(freq2)); | ||
| 776 | 644 | ||
| 777 | freq2.tuner = 0; | 645 | pict->brightness = get_v4l_control(inode, file, |
| 778 | err = drv(inode, file, VIDIOC_G_FREQUENCY, &freq2); | 646 | V4L2_CID_BRIGHTNESS, drv); |
| 779 | if (err < 0) | 647 | pict->hue = get_v4l_control(inode, file, |
| 780 | dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %d\n",err); | 648 | V4L2_CID_HUE, drv); |
| 781 | if (0 == err) | 649 | pict->contrast = get_v4l_control(inode, file, |
| 782 | *freq = freq2.frequency; | 650 | V4L2_CID_CONTRAST, drv); |
| 783 | break; | 651 | pict->colour = get_v4l_control(inode, file, |
| 652 | V4L2_CID_SATURATION, drv); | ||
| 653 | pict->whiteness = get_v4l_control(inode, file, | ||
| 654 | V4L2_CID_WHITENESS, drv); | ||
| 655 | |||
| 656 | fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 657 | err = drv(inode, file, VIDIOC_G_FMT, fmt); | ||
| 658 | if (err < 0) { | ||
| 659 | dprintk("VIDIOCGPICT / VIDIOC_G_FMT: %d\n", err); | ||
| 660 | goto done; | ||
| 784 | } | 661 | } |
| 785 | case VIDIOCSFREQ: /* set frequency */ | ||
| 786 | { | ||
| 787 | unsigned long *freq = arg; | ||
| 788 | memset(&freq2,0,sizeof(freq2)); | ||
| 789 | 662 | ||
| 790 | drv(inode, file, VIDIOC_G_FREQUENCY, &freq2); | 663 | pict->depth = ((fmt->fmt.pix.bytesperline << 3) |
| 791 | freq2.frequency = *freq; | 664 | + (fmt->fmt.pix.width - 1)) |
| 792 | err = drv(inode, file, VIDIOC_S_FREQUENCY, &freq2); | 665 | / fmt->fmt.pix.width; |
| 793 | if (err < 0) | 666 | pict->palette = pixelformat_to_palette( |
| 794 | dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %d\n",err); | 667 | fmt->fmt.pix.pixelformat); |
| 795 | break; | 668 | done: |
| 669 | kfree(fmt); | ||
| 670 | return err; | ||
| 671 | } | ||
| 672 | |||
| 673 | static noinline int v4l1_compat_set_picture( | ||
| 674 | struct video_picture *pict, | ||
| 675 | struct inode *inode, | ||
| 676 | struct file *file, | ||
| 677 | v4l2_kioctl drv) | ||
| 678 | { | ||
| 679 | int err; | ||
| 680 | struct v4l2_framebuffer fbuf; | ||
| 681 | int mem_err = 0, ovl_err = 0; | ||
| 682 | struct v4l2_format *fmt; | ||
| 683 | |||
| 684 | fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); | ||
| 685 | if (!fmt) { | ||
| 686 | err = -ENOMEM; | ||
| 687 | return err; | ||
| 688 | } | ||
| 689 | memset(&fbuf, 0, sizeof(fbuf)); | ||
| 690 | |||
| 691 | set_v4l_control(inode, file, | ||
| 692 | V4L2_CID_BRIGHTNESS, pict->brightness, drv); | ||
| 693 | set_v4l_control(inode, file, | ||
| 694 | V4L2_CID_HUE, pict->hue, drv); | ||
| 695 | set_v4l_control(inode, file, | ||
| 696 | V4L2_CID_CONTRAST, pict->contrast, drv); | ||
| 697 | set_v4l_control(inode, file, | ||
| 698 | V4L2_CID_SATURATION, pict->colour, drv); | ||
| 699 | set_v4l_control(inode, file, | ||
| 700 | V4L2_CID_WHITENESS, pict->whiteness, drv); | ||
| 701 | /* | ||
| 702 | * V4L1 uses this ioctl to set both memory capture and overlay | ||
| 703 | * pixel format, while V4L2 has two different ioctls for this. | ||
| 704 | * Some cards may not support one or the other, and may support | ||
| 705 | * different pixel formats for memory vs overlay. | ||
| 706 | */ | ||
| 707 | |||
| 708 | fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 709 | err = drv(inode, file, VIDIOC_G_FMT, fmt); | ||
| 710 | /* If VIDIOC_G_FMT failed, then the driver likely doesn't | ||
| 711 | support memory capture. Trying to set the memory capture | ||
| 712 | parameters would be pointless. */ | ||
| 713 | if (err < 0) { | ||
| 714 | dprintk("VIDIOCSPICT / VIDIOC_G_FMT: %d\n", err); | ||
| 715 | mem_err = -1000; /* didn't even try */ | ||
| 716 | } else if (fmt->fmt.pix.pixelformat != | ||
| 717 | palette_to_pixelformat(pict->palette)) { | ||
| 718 | fmt->fmt.pix.pixelformat = palette_to_pixelformat( | ||
| 719 | pict->palette); | ||
| 720 | mem_err = drv(inode, file, VIDIOC_S_FMT, fmt); | ||
| 721 | if (mem_err < 0) | ||
| 722 | dprintk("VIDIOCSPICT / VIDIOC_S_FMT: %d\n", | ||
| 723 | mem_err); | ||
| 796 | } | 724 | } |
| 797 | case VIDIOCGAUDIO: /* get audio properties/controls */ | ||
| 798 | { | ||
| 799 | struct video_audio *aud = arg; | ||
| 800 | memset(&aud2,0,sizeof(aud2)); | ||
| 801 | 725 | ||
| 802 | err = drv(inode, file, VIDIOC_G_AUDIO, &aud2); | 726 | err = drv(inode, file, VIDIOC_G_FBUF, &fbuf); |
| 803 | if (err < 0) { | 727 | /* If VIDIOC_G_FBUF failed, then the driver likely doesn't |
| 804 | dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %d\n",err); | 728 | support overlay. Trying to set the overlay parameters |
| 805 | break; | 729 | would be quite pointless. */ |
| 806 | } | 730 | if (err < 0) { |
| 807 | memcpy(aud->name, aud2.name, | 731 | dprintk("VIDIOCSPICT / VIDIOC_G_FBUF: %d\n", err); |
| 808 | min(sizeof(aud->name), sizeof(aud2.name))); | 732 | ovl_err = -1000; /* didn't even try */ |
| 809 | aud->name[sizeof(aud->name) - 1] = 0; | 733 | } else if (fbuf.fmt.pixelformat != |
| 810 | aud->audio = aud2.index; | 734 | palette_to_pixelformat(pict->palette)) { |
| 811 | aud->flags = 0; | 735 | fbuf.fmt.pixelformat = palette_to_pixelformat( |
| 812 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME, drv); | 736 | pict->palette); |
| 813 | if (i >= 0) { | 737 | ovl_err = drv(inode, file, VIDIOC_S_FBUF, &fbuf); |
| 814 | aud->volume = i; | 738 | if (ovl_err < 0) |
| 815 | aud->flags |= VIDEO_AUDIO_VOLUME; | 739 | dprintk("VIDIOCSPICT / VIDIOC_S_FBUF: %d\n", |
| 816 | } | 740 | ovl_err); |
| 817 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_BASS, drv); | 741 | } |
| 818 | if (i >= 0) { | 742 | if (ovl_err < 0 && mem_err < 0) { |
| 819 | aud->bass = i; | 743 | /* ioctl failed, couldn't set either parameter */ |
| 820 | aud->flags |= VIDEO_AUDIO_BASS; | 744 | if (mem_err != -1000) |
| 821 | } | 745 | err = mem_err; |
| 822 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_TREBLE, drv); | 746 | else if (ovl_err == -EPERM) |
| 823 | if (i >= 0) { | ||
| 824 | aud->treble = i; | ||
| 825 | aud->flags |= VIDEO_AUDIO_TREBLE; | ||
| 826 | } | ||
| 827 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_BALANCE, drv); | ||
| 828 | if (i >= 0) { | ||
| 829 | aud->balance = i; | ||
| 830 | aud->flags |= VIDEO_AUDIO_BALANCE; | ||
| 831 | } | ||
| 832 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_MUTE, drv); | ||
| 833 | if (i >= 0) { | ||
| 834 | if (i) | ||
| 835 | aud->flags |= VIDEO_AUDIO_MUTE; | ||
| 836 | aud->flags |= VIDEO_AUDIO_MUTABLE; | ||
| 837 | } | ||
| 838 | aud->step = 1; | ||
| 839 | qctrl2.id = V4L2_CID_AUDIO_VOLUME; | ||
| 840 | if (drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2) == 0 && | ||
| 841 | !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED)) | ||
| 842 | aud->step = qctrl2.step; | ||
| 843 | aud->mode = 0; | ||
| 844 | |||
| 845 | memset(&tun2,0,sizeof(tun2)); | ||
| 846 | err = drv(inode, file, VIDIOC_G_TUNER, &tun2); | ||
| 847 | if (err < 0) { | ||
| 848 | dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %d\n",err); | ||
| 849 | err = 0; | 747 | err = 0; |
| 748 | else | ||
| 749 | err = ovl_err; | ||
| 750 | } else | ||
| 751 | err = 0; | ||
| 752 | kfree(fmt); | ||
| 753 | return err; | ||
| 754 | } | ||
| 755 | |||
| 756 | static noinline int v4l1_compat_get_tuner( | ||
| 757 | struct video_tuner *tun, | ||
| 758 | struct inode *inode, | ||
| 759 | struct file *file, | ||
| 760 | v4l2_kioctl drv) | ||
| 761 | { | ||
| 762 | int err, i; | ||
| 763 | struct v4l2_tuner tun2; | ||
| 764 | struct v4l2_standard std2; | ||
| 765 | v4l2_std_id sid; | ||
| 766 | |||
| 767 | memset(&tun2, 0, sizeof(tun2)); | ||
| 768 | err = drv(inode, file, VIDIOC_G_TUNER, &tun2); | ||
| 769 | if (err < 0) { | ||
| 770 | dprintk("VIDIOCGTUNER / VIDIOC_G_TUNER: %d\n", err); | ||
| 771 | goto done; | ||
| 772 | } | ||
| 773 | memcpy(tun->name, tun2.name, | ||
| 774 | min(sizeof(tun->name), sizeof(tun2.name))); | ||
| 775 | tun->name[sizeof(tun->name) - 1] = 0; | ||
| 776 | tun->rangelow = tun2.rangelow; | ||
| 777 | tun->rangehigh = tun2.rangehigh; | ||
| 778 | tun->flags = 0; | ||
| 779 | tun->mode = VIDEO_MODE_AUTO; | ||
| 780 | |||
| 781 | for (i = 0; i < 64; i++) { | ||
| 782 | memset(&std2, 0, sizeof(std2)); | ||
| 783 | std2.index = i; | ||
| 784 | if (0 != drv(inode, file, VIDIOC_ENUMSTD, &std2)) | ||
| 850 | break; | 785 | break; |
| 851 | } | 786 | if (std2.id & V4L2_STD_PAL) |
| 787 | tun->flags |= VIDEO_TUNER_PAL; | ||
| 788 | if (std2.id & V4L2_STD_NTSC) | ||
| 789 | tun->flags |= VIDEO_TUNER_NTSC; | ||
| 790 | if (std2.id & V4L2_STD_SECAM) | ||
| 791 | tun->flags |= VIDEO_TUNER_SECAM; | ||
| 792 | } | ||
| 852 | 793 | ||
| 853 | if (tun2.rxsubchans & V4L2_TUNER_SUB_LANG2) | 794 | err = drv(inode, file, VIDIOC_G_STD, &sid); |
| 854 | aud->mode = VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | 795 | if (err < 0) |
| 855 | else if (tun2.rxsubchans & V4L2_TUNER_SUB_STEREO) | 796 | dprintk("VIDIOCGTUNER / VIDIOC_G_STD: %d\n", err); |
| 856 | aud->mode = VIDEO_SOUND_STEREO; | 797 | if (err == 0) { |
| 857 | else if (tun2.rxsubchans & V4L2_TUNER_SUB_MONO) | 798 | if (sid & V4L2_STD_PAL) |
| 858 | aud->mode = VIDEO_SOUND_MONO; | 799 | tun->mode = VIDEO_MODE_PAL; |
| 859 | break; | 800 | if (sid & V4L2_STD_NTSC) |
| 801 | tun->mode = VIDEO_MODE_NTSC; | ||
| 802 | if (sid & V4L2_STD_SECAM) | ||
| 803 | tun->mode = VIDEO_MODE_SECAM; | ||
| 860 | } | 804 | } |
| 861 | case VIDIOCSAUDIO: /* set audio controls */ | ||
| 862 | { | ||
| 863 | struct video_audio *aud = arg; | ||
| 864 | 805 | ||
| 865 | memset(&aud2,0,sizeof(aud2)); | 806 | if (tun2.capability & V4L2_TUNER_CAP_LOW) |
| 866 | memset(&tun2,0,sizeof(tun2)); | 807 | tun->flags |= VIDEO_TUNER_LOW; |
| 808 | if (tun2.rxsubchans & V4L2_TUNER_SUB_STEREO) | ||
| 809 | tun->flags |= VIDEO_TUNER_STEREO_ON; | ||
| 810 | tun->signal = tun2.signal; | ||
| 811 | done: | ||
| 812 | return err; | ||
| 813 | } | ||
| 867 | 814 | ||
| 868 | aud2.index = aud->audio; | 815 | static noinline int v4l1_compat_select_tuner( |
| 869 | err = drv(inode, file, VIDIOC_S_AUDIO, &aud2); | 816 | struct video_tuner *tun, |
| 870 | if (err < 0) { | 817 | struct inode *inode, |
| 871 | dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %d\n",err); | 818 | struct file *file, |
| 872 | break; | 819 | v4l2_kioctl drv) |
| 873 | } | 820 | { |
| 821 | int err; | ||
| 822 | struct v4l2_tuner t;/*84 bytes on x86_64*/ | ||
| 823 | memset(&t, 0, sizeof(t)); | ||
| 874 | 824 | ||
| 875 | set_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME, | 825 | t.index = tun->tuner; |
| 876 | aud->volume, drv); | 826 | |
| 877 | set_v4l_control(inode, file, V4L2_CID_AUDIO_BASS, | 827 | err = drv(inode, file, VIDIOC_S_INPUT, &t); |
| 878 | aud->bass, drv); | 828 | if (err < 0) |
| 879 | set_v4l_control(inode, file, V4L2_CID_AUDIO_TREBLE, | 829 | dprintk("VIDIOCSTUNER / VIDIOC_S_INPUT: %d\n", err); |
| 880 | aud->treble, drv); | 830 | return err; |
| 881 | set_v4l_control(inode, file, V4L2_CID_AUDIO_BALANCE, | 831 | } |
| 882 | aud->balance, drv); | 832 | |
| 883 | set_v4l_control(inode, file, V4L2_CID_AUDIO_MUTE, | 833 | static noinline int v4l1_compat_get_frequency( |
| 884 | !!(aud->flags & VIDEO_AUDIO_MUTE), drv); | 834 | unsigned long *freq, |
| 885 | 835 | struct inode *inode, | |
| 886 | err = drv(inode, file, VIDIOC_G_TUNER, &tun2); | 836 | struct file *file, |
| 887 | if (err < 0) | 837 | v4l2_kioctl drv) |
| 888 | dprintk("VIDIOCSAUDIO / VIDIOC_G_TUNER: %d\n",err); | 838 | { |
| 889 | if (err == 0) { | 839 | int err; |
| 890 | switch (aud->mode) { | 840 | struct v4l2_frequency freq2; |
| 891 | default: | 841 | memset(&freq2, 0, sizeof(freq2)); |
| 892 | case VIDEO_SOUND_MONO: | 842 | |
| 893 | case VIDEO_SOUND_LANG1: | 843 | freq2.tuner = 0; |
| 894 | tun2.audmode = V4L2_TUNER_MODE_MONO; | 844 | err = drv(inode, file, VIDIOC_G_FREQUENCY, &freq2); |
| 895 | break; | 845 | if (err < 0) |
| 896 | case VIDEO_SOUND_STEREO: | 846 | dprintk("VIDIOCGFREQ / VIDIOC_G_FREQUENCY: %d\n", err); |
| 897 | tun2.audmode = V4L2_TUNER_MODE_STEREO; | 847 | if (0 == err) |
| 898 | break; | 848 | *freq = freq2.frequency; |
| 899 | case VIDEO_SOUND_LANG2: | 849 | return err; |
| 900 | tun2.audmode = V4L2_TUNER_MODE_LANG2; | 850 | } |
| 901 | break; | 851 | |
| 902 | } | 852 | static noinline int v4l1_compat_set_frequency( |
| 903 | err = drv(inode, file, VIDIOC_S_TUNER, &tun2); | 853 | unsigned long *freq, |
| 904 | if (err < 0) | 854 | struct inode *inode, |
| 905 | dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %d\n",err); | 855 | struct file *file, |
| 906 | } | 856 | v4l2_kioctl drv) |
| 857 | { | ||
| 858 | int err; | ||
| 859 | struct v4l2_frequency freq2; | ||
| 860 | memset(&freq2, 0, sizeof(freq2)); | ||
| 861 | |||
| 862 | drv(inode, file, VIDIOC_G_FREQUENCY, &freq2); | ||
| 863 | freq2.frequency = *freq; | ||
| 864 | err = drv(inode, file, VIDIOC_S_FREQUENCY, &freq2); | ||
| 865 | if (err < 0) | ||
| 866 | dprintk("VIDIOCSFREQ / VIDIOC_S_FREQUENCY: %d\n", err); | ||
| 867 | return err; | ||
| 868 | } | ||
| 869 | |||
| 870 | static noinline int v4l1_compat_get_audio( | ||
| 871 | struct video_audio *aud, | ||
| 872 | struct inode *inode, | ||
| 873 | struct file *file, | ||
| 874 | v4l2_kioctl drv) | ||
| 875 | { | ||
| 876 | int err, i; | ||
| 877 | struct v4l2_queryctrl qctrl2; | ||
| 878 | struct v4l2_audio aud2; | ||
| 879 | struct v4l2_tuner tun2; | ||
| 880 | memset(&aud2, 0, sizeof(aud2)); | ||
| 881 | |||
| 882 | err = drv(inode, file, VIDIOC_G_AUDIO, &aud2); | ||
| 883 | if (err < 0) { | ||
| 884 | dprintk("VIDIOCGAUDIO / VIDIOC_G_AUDIO: %d\n", err); | ||
| 885 | goto done; | ||
| 886 | } | ||
| 887 | memcpy(aud->name, aud2.name, | ||
| 888 | min(sizeof(aud->name), sizeof(aud2.name))); | ||
| 889 | aud->name[sizeof(aud->name) - 1] = 0; | ||
| 890 | aud->audio = aud2.index; | ||
| 891 | aud->flags = 0; | ||
| 892 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME, drv); | ||
| 893 | if (i >= 0) { | ||
| 894 | aud->volume = i; | ||
| 895 | aud->flags |= VIDEO_AUDIO_VOLUME; | ||
| 896 | } | ||
| 897 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_BASS, drv); | ||
| 898 | if (i >= 0) { | ||
| 899 | aud->bass = i; | ||
| 900 | aud->flags |= VIDEO_AUDIO_BASS; | ||
| 901 | } | ||
| 902 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_TREBLE, drv); | ||
| 903 | if (i >= 0) { | ||
| 904 | aud->treble = i; | ||
| 905 | aud->flags |= VIDEO_AUDIO_TREBLE; | ||
| 906 | } | ||
| 907 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_BALANCE, drv); | ||
| 908 | if (i >= 0) { | ||
| 909 | aud->balance = i; | ||
| 910 | aud->flags |= VIDEO_AUDIO_BALANCE; | ||
| 911 | } | ||
| 912 | i = get_v4l_control(inode, file, V4L2_CID_AUDIO_MUTE, drv); | ||
| 913 | if (i >= 0) { | ||
| 914 | if (i) | ||
| 915 | aud->flags |= VIDEO_AUDIO_MUTE; | ||
| 916 | aud->flags |= VIDEO_AUDIO_MUTABLE; | ||
| 917 | } | ||
| 918 | aud->step = 1; | ||
| 919 | qctrl2.id = V4L2_CID_AUDIO_VOLUME; | ||
| 920 | if (drv(inode, file, VIDIOC_QUERYCTRL, &qctrl2) == 0 && | ||
| 921 | !(qctrl2.flags & V4L2_CTRL_FLAG_DISABLED)) | ||
| 922 | aud->step = qctrl2.step; | ||
| 923 | aud->mode = 0; | ||
| 924 | |||
| 925 | memset(&tun2, 0, sizeof(tun2)); | ||
| 926 | err = drv(inode, file, VIDIOC_G_TUNER, &tun2); | ||
| 927 | if (err < 0) { | ||
| 928 | dprintk("VIDIOCGAUDIO / VIDIOC_G_TUNER: %d\n", err); | ||
| 907 | err = 0; | 929 | err = 0; |
| 908 | break; | 930 | goto done; |
| 909 | } | 931 | } |
| 910 | case VIDIOCMCAPTURE: /* capture a frame */ | ||
| 911 | { | ||
| 912 | struct video_mmap *mm = arg; | ||
| 913 | 932 | ||
| 914 | fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); | 933 | if (tun2.rxsubchans & V4L2_TUNER_SUB_LANG2) |
| 915 | if (!fmt2) { | 934 | aud->mode = VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; |
| 916 | err = -ENOMEM; | 935 | else if (tun2.rxsubchans & V4L2_TUNER_SUB_STEREO) |
| 917 | break; | 936 | aud->mode = VIDEO_SOUND_STEREO; |
| 918 | } | 937 | else if (tun2.rxsubchans & V4L2_TUNER_SUB_MONO) |
| 919 | memset(&buf2,0,sizeof(buf2)); | 938 | aud->mode = VIDEO_SOUND_MONO; |
| 939 | done: | ||
| 940 | return err; | ||
| 941 | } | ||
| 920 | 942 | ||
| 921 | fmt2->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 943 | static noinline int v4l1_compat_set_audio( |
| 922 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | 944 | struct video_audio *aud, |
| 923 | if (err < 0) { | 945 | struct inode *inode, |
| 924 | dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %d\n",err); | 946 | struct file *file, |
| 947 | v4l2_kioctl drv) | ||
| 948 | { | ||
| 949 | int err; | ||
| 950 | struct v4l2_audio aud2; | ||
| 951 | struct v4l2_tuner tun2; | ||
| 952 | |||
| 953 | memset(&aud2, 0, sizeof(aud2)); | ||
| 954 | memset(&tun2, 0, sizeof(tun2)); | ||
| 955 | |||
| 956 | aud2.index = aud->audio; | ||
| 957 | err = drv(inode, file, VIDIOC_S_AUDIO, &aud2); | ||
| 958 | if (err < 0) { | ||
| 959 | dprintk("VIDIOCSAUDIO / VIDIOC_S_AUDIO: %d\n", err); | ||
| 960 | goto done; | ||
| 961 | } | ||
| 962 | |||
| 963 | set_v4l_control(inode, file, V4L2_CID_AUDIO_VOLUME, | ||
| 964 | aud->volume, drv); | ||
| 965 | set_v4l_control(inode, file, V4L2_CID_AUDIO_BASS, | ||
| 966 | aud->bass, drv); | ||
| 967 | set_v4l_control(inode, file, V4L2_CID_AUDIO_TREBLE, | ||
| 968 | aud->treble, drv); | ||
| 969 | set_v4l_control(inode, file, V4L2_CID_AUDIO_BALANCE, | ||
| 970 | aud->balance, drv); | ||
| 971 | set_v4l_control(inode, file, V4L2_CID_AUDIO_MUTE, | ||
| 972 | !!(aud->flags & VIDEO_AUDIO_MUTE), drv); | ||
| 973 | |||
| 974 | err = drv(inode, file, VIDIOC_G_TUNER, &tun2); | ||
| 975 | if (err < 0) | ||
| 976 | dprintk("VIDIOCSAUDIO / VIDIOC_G_TUNER: %d\n", err); | ||
| 977 | if (err == 0) { | ||
| 978 | switch (aud->mode) { | ||
| 979 | default: | ||
| 980 | case VIDEO_SOUND_MONO: | ||
| 981 | case VIDEO_SOUND_LANG1: | ||
| 982 | tun2.audmode = V4L2_TUNER_MODE_MONO; | ||
| 925 | break; | 983 | break; |
| 926 | } | 984 | case VIDEO_SOUND_STEREO: |
| 927 | if (mm->width != fmt2->fmt.pix.width || | 985 | tun2.audmode = V4L2_TUNER_MODE_STEREO; |
| 928 | mm->height != fmt2->fmt.pix.height || | ||
| 929 | palette_to_pixelformat(mm->format) != | ||
| 930 | fmt2->fmt.pix.pixelformat) | ||
| 931 | {/* New capture format... */ | ||
| 932 | fmt2->fmt.pix.width = mm->width; | ||
| 933 | fmt2->fmt.pix.height = mm->height; | ||
| 934 | fmt2->fmt.pix.pixelformat = | ||
| 935 | palette_to_pixelformat(mm->format); | ||
| 936 | fmt2->fmt.pix.field = V4L2_FIELD_ANY; | ||
| 937 | fmt2->fmt.pix.bytesperline = 0; | ||
| 938 | err = drv(inode, file, VIDIOC_S_FMT, fmt2); | ||
| 939 | if (err < 0) { | ||
| 940 | dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %d\n",err); | ||
| 941 | break; | ||
| 942 | } | ||
| 943 | } | ||
| 944 | buf2.index = mm->frame; | ||
| 945 | buf2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 946 | err = drv(inode, file, VIDIOC_QUERYBUF, &buf2); | ||
| 947 | if (err < 0) { | ||
| 948 | dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %d\n",err); | ||
| 949 | break; | 986 | break; |
| 950 | } | 987 | case VIDEO_SOUND_LANG2: |
| 951 | err = drv(inode, file, VIDIOC_QBUF, &buf2); | 988 | tun2.audmode = V4L2_TUNER_MODE_LANG2; |
| 952 | if (err < 0) { | ||
| 953 | dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n",err); | ||
| 954 | break; | 989 | break; |
| 955 | } | 990 | } |
| 956 | err = drv(inode, file, VIDIOC_STREAMON, &captype); | 991 | err = drv(inode, file, VIDIOC_S_TUNER, &tun2); |
| 957 | if (err < 0) | 992 | if (err < 0) |
| 958 | dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n",err); | 993 | dprintk("VIDIOCSAUDIO / VIDIOC_S_TUNER: %d\n", err); |
| 959 | break; | ||
| 960 | } | 994 | } |
| 961 | case VIDIOCSYNC: /* wait for a frame */ | 995 | err = 0; |
| 962 | { | 996 | done: |
| 963 | int *i = arg; | 997 | return err; |
| 998 | } | ||
| 964 | 999 | ||
| 965 | memset(&buf2,0,sizeof(buf2)); | 1000 | static noinline int v4l1_compat_capture_frame( |
| 966 | buf2.index = *i; | 1001 | struct video_mmap *mm, |
| 967 | buf2.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1002 | struct inode *inode, |
| 968 | err = drv(inode, file, VIDIOC_QUERYBUF, &buf2); | 1003 | struct file *file, |
| 969 | if (err < 0) { | 1004 | v4l2_kioctl drv) |
| 970 | /* No such buffer */ | 1005 | { |
| 971 | dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n",err); | 1006 | int err; |
| 972 | break; | 1007 | enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 973 | } | 1008 | struct v4l2_buffer buf; |
| 974 | if (!(buf2.flags & V4L2_BUF_FLAG_MAPPED)) { | 1009 | struct v4l2_format *fmt; |
| 975 | /* Buffer is not mapped */ | 1010 | |
| 976 | err = -EINVAL; | 1011 | fmt = kzalloc(sizeof(*fmt), GFP_KERNEL); |
| 977 | break; | 1012 | if (!fmt) { |
| 978 | } | 1013 | err = -ENOMEM; |
| 1014 | return err; | ||
| 1015 | } | ||
| 1016 | memset(&buf, 0, sizeof(buf)); | ||
| 979 | 1017 | ||
| 980 | /* make sure capture actually runs so we don't block forever */ | 1018 | fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 981 | err = drv(inode, file, VIDIOC_STREAMON, &captype); | 1019 | err = drv(inode, file, VIDIOC_G_FMT, fmt); |
| 1020 | if (err < 0) { | ||
| 1021 | dprintk("VIDIOCMCAPTURE / VIDIOC_G_FMT: %d\n", err); | ||
| 1022 | goto done; | ||
| 1023 | } | ||
| 1024 | if (mm->width != fmt->fmt.pix.width || | ||
| 1025 | mm->height != fmt->fmt.pix.height || | ||
| 1026 | palette_to_pixelformat(mm->format) != | ||
| 1027 | fmt->fmt.pix.pixelformat) { | ||
| 1028 | /* New capture format... */ | ||
| 1029 | fmt->fmt.pix.width = mm->width; | ||
| 1030 | fmt->fmt.pix.height = mm->height; | ||
| 1031 | fmt->fmt.pix.pixelformat = | ||
| 1032 | palette_to_pixelformat(mm->format); | ||
| 1033 | fmt->fmt.pix.field = V4L2_FIELD_ANY; | ||
| 1034 | fmt->fmt.pix.bytesperline = 0; | ||
| 1035 | err = drv(inode, file, VIDIOC_S_FMT, fmt); | ||
| 982 | if (err < 0) { | 1036 | if (err < 0) { |
| 983 | dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %d\n",err); | 1037 | dprintk("VIDIOCMCAPTURE / VIDIOC_S_FMT: %d\n", err); |
| 984 | break; | 1038 | goto done; |
| 985 | } | 1039 | } |
| 1040 | } | ||
| 1041 | buf.index = mm->frame; | ||
| 1042 | buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
| 1043 | err = drv(inode, file, VIDIOC_QUERYBUF, &buf); | ||
| 1044 | if (err < 0) { | ||
| 1045 | dprintk("VIDIOCMCAPTURE / VIDIOC_QUERYBUF: %d\n", err); | ||
| 1046 | goto done; | ||
| 1047 | } | ||
| 1048 | err = drv(inode, file, VIDIOC_QBUF, &buf); | ||
| 1049 | if (err < 0) { | ||
| 1050 | dprintk("VIDIOCMCAPTURE / VIDIOC_QBUF: %d\n", err); | ||
| 1051 | goto done; | ||
| 1052 | } | ||
| 1053 | err = drv(inode, file, VIDIOC_STREAMON, &captype); | ||
| 1054 | if (err < 0) | ||
| 1055 | dprintk("VIDIOCMCAPTURE / VIDIOC_STREAMON: %d\n", err); | ||
| 1056 | done: | ||
| 1057 | kfree(fmt); | ||
| 1058 | return err; | ||
| 1059 | } | ||
| 986 | 1060 | ||
| 987 | /* Loop as long as the buffer is queued, but not done */ | 1061 | static noinline int v4l1_compat_sync( |
| 988 | while ((buf2.flags & | 1062 | int *i, |
| 989 | (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE)) | 1063 | struct inode *inode, |
| 990 | == V4L2_BUF_FLAG_QUEUED) | 1064 | struct file *file, |
| 991 | { | 1065 | v4l2_kioctl drv) |
| 992 | err = poll_one(file); | 1066 | { |
| 993 | if (err < 0 || /* error or sleep was interrupted */ | 1067 | int err; |
| 994 | err == 0) /* timeout? Shouldn't occur. */ | 1068 | enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 995 | break; | 1069 | struct v4l2_buffer buf; |
| 996 | err = drv(inode, file, VIDIOC_QUERYBUF, &buf2); | 1070 | struct poll_wqueues *pwq; |
| 997 | if (err < 0) | 1071 | |
| 998 | dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n",err); | 1072 | memset(&buf, 0, sizeof(buf)); |
| 999 | } | 1073 | buf.index = *i; |
| 1000 | if (!(buf2.flags & V4L2_BUF_FLAG_DONE)) /* not done */ | 1074 | buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
| 1001 | break; | 1075 | err = drv(inode, file, VIDIOC_QUERYBUF, &buf); |
| 1002 | do { | 1076 | if (err < 0) { |
| 1003 | err = drv(inode, file, VIDIOC_DQBUF, &buf2); | 1077 | /* No such buffer */ |
| 1004 | if (err < 0) | 1078 | dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); |
| 1005 | dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %d\n",err); | 1079 | goto done; |
| 1006 | } while (err == 0 && buf2.index != *i); | 1080 | } |
| 1007 | break; | 1081 | if (!(buf.flags & V4L2_BUF_FLAG_MAPPED)) { |
| 1082 | /* Buffer is not mapped */ | ||
| 1083 | err = -EINVAL; | ||
| 1084 | goto done; | ||
| 1008 | } | 1085 | } |
| 1009 | 1086 | ||
| 1010 | case VIDIOCGVBIFMT: /* query VBI data capture format */ | 1087 | /* make sure capture actually runs so we don't block forever */ |
| 1011 | { | 1088 | err = drv(inode, file, VIDIOC_STREAMON, &captype); |
| 1012 | struct vbi_format *fmt = arg; | 1089 | if (err < 0) { |
| 1090 | dprintk("VIDIOCSYNC / VIDIOC_STREAMON: %d\n", err); | ||
| 1091 | goto done; | ||
| 1092 | } | ||
| 1013 | 1093 | ||
| 1014 | fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); | 1094 | pwq = kmalloc(sizeof(*pwq), GFP_KERNEL); |
| 1015 | if (!fmt2) { | 1095 | /* Loop as long as the buffer is queued, but not done */ |
| 1016 | err = -ENOMEM; | 1096 | while ((buf.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE)) |
| 1097 | == V4L2_BUF_FLAG_QUEUED) { | ||
| 1098 | err = poll_one(file, pwq); | ||
| 1099 | if (err < 0 || /* error or sleep was interrupted */ | ||
| 1100 | err == 0) /* timeout? Shouldn't occur. */ | ||
| 1017 | break; | 1101 | break; |
| 1018 | } | 1102 | err = drv(inode, file, VIDIOC_QUERYBUF, &buf); |
| 1019 | fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; | 1103 | if (err < 0) |
| 1104 | dprintk("VIDIOCSYNC / VIDIOC_QUERYBUF: %d\n", err); | ||
| 1105 | } | ||
| 1106 | kfree(pwq); | ||
| 1107 | if (!(buf.flags & V4L2_BUF_FLAG_DONE)) /* not done */ | ||
| 1108 | goto done; | ||
| 1109 | do { | ||
| 1110 | err = drv(inode, file, VIDIOC_DQBUF, &buf); | ||
| 1111 | if (err < 0) | ||
| 1112 | dprintk("VIDIOCSYNC / VIDIOC_DQBUF: %d\n", err); | ||
| 1113 | } while (err == 0 && buf.index != *i); | ||
| 1114 | done: | ||
| 1115 | return err; | ||
| 1116 | } | ||
| 1020 | 1117 | ||
| 1021 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); | 1118 | static noinline int v4l1_compat_get_vbi_format( |
| 1022 | if (err < 0) { | 1119 | struct vbi_format *fmt, |
| 1023 | dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %d\n", err); | 1120 | struct inode *inode, |
| 1024 | break; | 1121 | struct file *file, |
| 1025 | } | 1122 | v4l2_kioctl drv) |
| 1026 | if (fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) { | 1123 | { |
| 1027 | err = -EINVAL; | 1124 | int err; |
| 1028 | break; | 1125 | struct v4l2_format *fmt2; |
| 1029 | } | 1126 | |
| 1030 | memset(fmt, 0, sizeof(*fmt)); | 1127 | fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); |
| 1031 | fmt->samples_per_line = fmt2->fmt.vbi.samples_per_line; | 1128 | if (!fmt2) { |
| 1032 | fmt->sampling_rate = fmt2->fmt.vbi.sampling_rate; | 1129 | err = -ENOMEM; |
| 1033 | fmt->sample_format = VIDEO_PALETTE_RAW; | 1130 | return err; |
| 1034 | fmt->start[0] = fmt2->fmt.vbi.start[0]; | ||
| 1035 | fmt->count[0] = fmt2->fmt.vbi.count[0]; | ||
| 1036 | fmt->start[1] = fmt2->fmt.vbi.start[1]; | ||
| 1037 | fmt->count[1] = fmt2->fmt.vbi.count[1]; | ||
| 1038 | fmt->flags = fmt2->fmt.vbi.flags & 0x03; | ||
| 1039 | break; | ||
| 1040 | } | 1131 | } |
| 1041 | case VIDIOCSVBIFMT: | 1132 | fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; |
| 1042 | { | ||
| 1043 | struct vbi_format *fmt = arg; | ||
| 1044 | 1133 | ||
| 1045 | if (VIDEO_PALETTE_RAW != fmt->sample_format) { | 1134 | err = drv(inode, file, VIDIOC_G_FMT, fmt2); |
| 1046 | err = -EINVAL; | 1135 | if (err < 0) { |
| 1047 | break; | 1136 | dprintk("VIDIOCGVBIFMT / VIDIOC_G_FMT: %d\n", err); |
| 1048 | } | 1137 | goto done; |
| 1138 | } | ||
| 1139 | if (fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) { | ||
| 1140 | err = -EINVAL; | ||
| 1141 | goto done; | ||
| 1142 | } | ||
| 1143 | memset(fmt, 0, sizeof(*fmt)); | ||
| 1144 | fmt->samples_per_line = fmt2->fmt.vbi.samples_per_line; | ||
| 1145 | fmt->sampling_rate = fmt2->fmt.vbi.sampling_rate; | ||
| 1146 | fmt->sample_format = VIDEO_PALETTE_RAW; | ||
| 1147 | fmt->start[0] = fmt2->fmt.vbi.start[0]; | ||
| 1148 | fmt->count[0] = fmt2->fmt.vbi.count[0]; | ||
| 1149 | fmt->start[1] = fmt2->fmt.vbi.start[1]; | ||
| 1150 | fmt->count[1] = fmt2->fmt.vbi.count[1]; | ||
| 1151 | fmt->flags = fmt2->fmt.vbi.flags & 0x03; | ||
| 1152 | done: | ||
| 1153 | kfree(fmt2); | ||
| 1154 | return err; | ||
| 1155 | } | ||
| 1049 | 1156 | ||
| 1050 | fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); | 1157 | static noinline int v4l1_compat_set_vbi_format( |
| 1051 | if (!fmt2) { | 1158 | struct vbi_format *fmt, |
| 1052 | err = -ENOMEM; | 1159 | struct inode *inode, |
| 1053 | break; | 1160 | struct file *file, |
| 1054 | } | 1161 | v4l2_kioctl drv) |
| 1055 | fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; | 1162 | { |
| 1056 | fmt2->fmt.vbi.samples_per_line = fmt->samples_per_line; | 1163 | int err; |
| 1057 | fmt2->fmt.vbi.sampling_rate = fmt->sampling_rate; | 1164 | struct v4l2_format *fmt2 = NULL; |
| 1058 | fmt2->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; | ||
| 1059 | fmt2->fmt.vbi.start[0] = fmt->start[0]; | ||
| 1060 | fmt2->fmt.vbi.count[0] = fmt->count[0]; | ||
| 1061 | fmt2->fmt.vbi.start[1] = fmt->start[1]; | ||
| 1062 | fmt2->fmt.vbi.count[1] = fmt->count[1]; | ||
| 1063 | fmt2->fmt.vbi.flags = fmt->flags; | ||
| 1064 | err = drv(inode, file, VIDIOC_TRY_FMT, fmt2); | ||
| 1065 | if (err < 0) { | ||
| 1066 | dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %d\n", err); | ||
| 1067 | break; | ||
| 1068 | } | ||
| 1069 | 1165 | ||
| 1070 | if (fmt2->fmt.vbi.samples_per_line != fmt->samples_per_line || | 1166 | if (VIDEO_PALETTE_RAW != fmt->sample_format) { |
| 1071 | fmt2->fmt.vbi.sampling_rate != fmt->sampling_rate || | 1167 | err = -EINVAL; |
| 1072 | fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY || | 1168 | return err; |
| 1073 | fmt2->fmt.vbi.start[0] != fmt->start[0] || | ||
| 1074 | fmt2->fmt.vbi.count[0] != fmt->count[0] || | ||
| 1075 | fmt2->fmt.vbi.start[1] != fmt->start[1] || | ||
| 1076 | fmt2->fmt.vbi.count[1] != fmt->count[1] || | ||
| 1077 | fmt2->fmt.vbi.flags != fmt->flags) { | ||
| 1078 | err = -EINVAL; | ||
| 1079 | break; | ||
| 1080 | } | ||
| 1081 | err = drv(inode, file, VIDIOC_S_FMT, fmt2); | ||
| 1082 | if (err < 0) | ||
| 1083 | dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %d\n", err); | ||
| 1084 | break; | ||
| 1085 | } | 1169 | } |
| 1086 | 1170 | ||
| 1171 | fmt2 = kzalloc(sizeof(*fmt2), GFP_KERNEL); | ||
| 1172 | if (!fmt2) { | ||
| 1173 | err = -ENOMEM; | ||
| 1174 | return err; | ||
| 1175 | } | ||
| 1176 | fmt2->type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
| 1177 | fmt2->fmt.vbi.samples_per_line = fmt->samples_per_line; | ||
| 1178 | fmt2->fmt.vbi.sampling_rate = fmt->sampling_rate; | ||
| 1179 | fmt2->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY; | ||
| 1180 | fmt2->fmt.vbi.start[0] = fmt->start[0]; | ||
| 1181 | fmt2->fmt.vbi.count[0] = fmt->count[0]; | ||
| 1182 | fmt2->fmt.vbi.start[1] = fmt->start[1]; | ||
| 1183 | fmt2->fmt.vbi.count[1] = fmt->count[1]; | ||
| 1184 | fmt2->fmt.vbi.flags = fmt->flags; | ||
| 1185 | err = drv(inode, file, VIDIOC_TRY_FMT, fmt2); | ||
| 1186 | if (err < 0) { | ||
| 1187 | dprintk("VIDIOCSVBIFMT / VIDIOC_TRY_FMT: %d\n", err); | ||
| 1188 | goto done; | ||
| 1189 | } | ||
| 1190 | |||
| 1191 | if (fmt2->fmt.vbi.samples_per_line != fmt->samples_per_line || | ||
| 1192 | fmt2->fmt.vbi.sampling_rate != fmt->sampling_rate || | ||
| 1193 | fmt2->fmt.vbi.sample_format != V4L2_PIX_FMT_GREY || | ||
| 1194 | fmt2->fmt.vbi.start[0] != fmt->start[0] || | ||
| 1195 | fmt2->fmt.vbi.count[0] != fmt->count[0] || | ||
| 1196 | fmt2->fmt.vbi.start[1] != fmt->start[1] || | ||
| 1197 | fmt2->fmt.vbi.count[1] != fmt->count[1] || | ||
| 1198 | fmt2->fmt.vbi.flags != fmt->flags) { | ||
| 1199 | err = -EINVAL; | ||
| 1200 | goto done; | ||
| 1201 | } | ||
| 1202 | err = drv(inode, file, VIDIOC_S_FMT, fmt2); | ||
| 1203 | if (err < 0) | ||
| 1204 | dprintk("VIDIOCSVBIFMT / VIDIOC_S_FMT: %d\n", err); | ||
| 1205 | done: | ||
| 1206 | kfree(fmt2); | ||
| 1207 | return err; | ||
| 1208 | } | ||
| 1209 | |||
| 1210 | /* | ||
| 1211 | * This function is exported. | ||
| 1212 | */ | ||
| 1213 | int | ||
| 1214 | v4l_compat_translate_ioctl(struct inode *inode, | ||
| 1215 | struct file *file, | ||
| 1216 | int cmd, | ||
| 1217 | void *arg, | ||
| 1218 | v4l2_kioctl drv) | ||
| 1219 | { | ||
| 1220 | int err; | ||
| 1221 | |||
| 1222 | switch (cmd) { | ||
| 1223 | case VIDIOCGCAP: /* capability */ | ||
| 1224 | err = v4l1_compat_get_capabilities(arg, inode, file, drv); | ||
| 1225 | break; | ||
| 1226 | case VIDIOCGFBUF: /* get frame buffer */ | ||
| 1227 | err = v4l1_compat_get_frame_buffer(arg, inode, file, drv); | ||
| 1228 | break; | ||
| 1229 | case VIDIOCSFBUF: /* set frame buffer */ | ||
| 1230 | err = v4l1_compat_set_frame_buffer(arg, inode, file, drv); | ||
| 1231 | break; | ||
| 1232 | case VIDIOCGWIN: /* get window or capture dimensions */ | ||
| 1233 | err = v4l1_compat_get_win_cap_dimensions(arg, inode, file, drv); | ||
| 1234 | break; | ||
| 1235 | case VIDIOCSWIN: /* set window and/or capture dimensions */ | ||
| 1236 | err = v4l1_compat_set_win_cap_dimensions(arg, inode, file, drv); | ||
| 1237 | break; | ||
| 1238 | case VIDIOCCAPTURE: /* turn on/off preview */ | ||
| 1239 | err = v4l1_compat_turn_preview_on_off(arg, inode, file, drv); | ||
| 1240 | break; | ||
| 1241 | case VIDIOCGCHAN: /* get input information */ | ||
| 1242 | err = v4l1_compat_get_input_info(arg, inode, file, drv); | ||
| 1243 | break; | ||
| 1244 | case VIDIOCSCHAN: /* set input */ | ||
| 1245 | err = v4l1_compat_set_input(arg, inode, file, drv); | ||
| 1246 | break; | ||
| 1247 | case VIDIOCGPICT: /* get tone controls & partial capture format */ | ||
| 1248 | err = v4l1_compat_get_picture(arg, inode, file, drv); | ||
| 1249 | break; | ||
| 1250 | case VIDIOCSPICT: /* set tone controls & partial capture format */ | ||
| 1251 | err = v4l1_compat_set_picture(arg, inode, file, drv); | ||
| 1252 | break; | ||
| 1253 | case VIDIOCGTUNER: /* get tuner information */ | ||
| 1254 | err = v4l1_compat_get_tuner(arg, inode, file, drv); | ||
| 1255 | break; | ||
| 1256 | case VIDIOCSTUNER: /* select a tuner input */ | ||
| 1257 | err = v4l1_compat_select_tuner(arg, inode, file, drv); | ||
| 1258 | break; | ||
| 1259 | case VIDIOCGFREQ: /* get frequency */ | ||
| 1260 | err = v4l1_compat_get_frequency(arg, inode, file, drv); | ||
| 1261 | break; | ||
| 1262 | case VIDIOCSFREQ: /* set frequency */ | ||
| 1263 | err = v4l1_compat_set_frequency(arg, inode, file, drv); | ||
| 1264 | break; | ||
| 1265 | case VIDIOCGAUDIO: /* get audio properties/controls */ | ||
| 1266 | err = v4l1_compat_get_audio(arg, inode, file, drv); | ||
| 1267 | break; | ||
| 1268 | case VIDIOCSAUDIO: /* set audio controls */ | ||
| 1269 | err = v4l1_compat_set_audio(arg, inode, file, drv); | ||
| 1270 | break; | ||
| 1271 | case VIDIOCMCAPTURE: /* capture a frame */ | ||
| 1272 | err = v4l1_compat_capture_frame(arg, inode, file, drv); | ||
| 1273 | break; | ||
| 1274 | case VIDIOCSYNC: /* wait for a frame */ | ||
| 1275 | err = v4l1_compat_sync(arg, inode, file, drv); | ||
| 1276 | break; | ||
| 1277 | case VIDIOCGVBIFMT: /* query VBI data capture format */ | ||
| 1278 | err = v4l1_compat_get_vbi_format(arg, inode, file, drv); | ||
| 1279 | break; | ||
| 1280 | case VIDIOCSVBIFMT: | ||
| 1281 | err = v4l1_compat_set_vbi_format(arg, inode, file, drv); | ||
| 1282 | break; | ||
| 1087 | default: | 1283 | default: |
| 1088 | err = -ENOIOCTLCMD; | 1284 | err = -ENOIOCTLCMD; |
| 1089 | break; | 1285 | break; |
| 1090 | } | 1286 | } |
| 1091 | 1287 | ||
| 1092 | kfree(cap2); | ||
| 1093 | kfree(fmt2); | ||
| 1094 | return err; | 1288 | return err; |
| 1095 | } | 1289 | } |
| 1096 | |||
| 1097 | EXPORT_SYMBOL(v4l_compat_translate_ioctl); | 1290 | EXPORT_SYMBOL(v4l_compat_translate_ioctl); |
| 1098 | 1291 | ||
| 1099 | /* | 1292 | /* |
diff --git a/drivers/media/video/videobuf-core.c b/drivers/media/video/videobuf-core.c index eab79ffdf56a..fc51e4918bbf 100644 --- a/drivers/media/video/videobuf-core.c +++ b/drivers/media/video/videobuf-core.c | |||
| @@ -64,32 +64,25 @@ void *videobuf_alloc(struct videobuf_queue *q) | |||
| 64 | return vb; | 64 | return vb; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | #define WAITON_CONDITION (vb->state != VIDEOBUF_ACTIVE &&\ | ||
| 68 | vb->state != VIDEOBUF_QUEUED) | ||
| 67 | int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr) | 69 | int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr) |
| 68 | { | 70 | { |
| 69 | int retval = 0; | ||
| 70 | DECLARE_WAITQUEUE(wait, current); | ||
| 71 | |||
| 72 | MAGIC_CHECK(vb->magic, MAGIC_BUFFER); | 71 | MAGIC_CHECK(vb->magic, MAGIC_BUFFER); |
| 73 | add_wait_queue(&vb->done, &wait); | 72 | |
| 74 | while (vb->state == VIDEOBUF_ACTIVE || vb->state == VIDEOBUF_QUEUED) { | 73 | if (non_blocking) { |
| 75 | if (non_blocking) { | 74 | if (WAITON_CONDITION) |
| 76 | retval = -EAGAIN; | 75 | return 0; |
| 77 | break; | 76 | else |
| 78 | } | 77 | return -EAGAIN; |
| 79 | set_current_state(intr ? TASK_INTERRUPTIBLE | ||
| 80 | : TASK_UNINTERRUPTIBLE); | ||
| 81 | if (vb->state == VIDEOBUF_ACTIVE || | ||
| 82 | vb->state == VIDEOBUF_QUEUED) | ||
| 83 | schedule(); | ||
| 84 | set_current_state(TASK_RUNNING); | ||
| 85 | if (intr && signal_pending(current)) { | ||
| 86 | dprintk(1, "buffer waiton: -EINTR\n"); | ||
| 87 | retval = -EINTR; | ||
| 88 | break; | ||
| 89 | } | ||
| 90 | } | 78 | } |
| 91 | remove_wait_queue(&vb->done, &wait); | 79 | |
| 92 | return retval; | 80 | if (intr) |
| 81 | return wait_event_interruptible(vb->done, WAITON_CONDITION); | ||
| 82 | else | ||
| 83 | wait_event(vb->done, WAITON_CONDITION); | ||
| 84 | |||
| 85 | return 0; | ||
| 93 | } | 86 | } |
| 94 | 87 | ||
| 95 | int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, | 88 | int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, |
| @@ -98,29 +91,22 @@ int videobuf_iolock(struct videobuf_queue *q, struct videobuf_buffer *vb, | |||
| 98 | MAGIC_CHECK(vb->magic, MAGIC_BUFFER); | 91 | MAGIC_CHECK(vb->magic, MAGIC_BUFFER); |
| 99 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | 92 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
| 100 | 93 | ||
| 101 | /* This is required to avoid OOPS on some cases, | ||
| 102 | since mmap_mapper() method should be called before _iolock. | ||
| 103 | On some cases, the mmap_mapper() is called only after scheduling. | ||
| 104 | */ | ||
| 105 | if (vb->memory == V4L2_MEMORY_MMAP) { | ||
| 106 | wait_event_timeout(vb->done, q->is_mmapped, | ||
| 107 | msecs_to_jiffies(100)); | ||
| 108 | if (!q->is_mmapped) { | ||
| 109 | printk(KERN_ERR | ||
| 110 | "Error: mmap_mapper() never called!\n"); | ||
| 111 | return -EINVAL; | ||
| 112 | } | ||
| 113 | } | ||
| 114 | |||
| 115 | return CALL(q, iolock, q, vb, fbuf); | 94 | return CALL(q, iolock, q, vb, fbuf); |
| 116 | } | 95 | } |
| 117 | 96 | ||
| 97 | void *videobuf_queue_to_vmalloc (struct videobuf_queue *q, | ||
| 98 | struct videobuf_buffer *buf) | ||
| 99 | { | ||
| 100 | return CALL(q, vmalloc, buf); | ||
| 101 | } | ||
| 102 | EXPORT_SYMBOL_GPL(videobuf_queue_to_vmalloc); | ||
| 103 | |||
| 118 | /* --------------------------------------------------------------------- */ | 104 | /* --------------------------------------------------------------------- */ |
| 119 | 105 | ||
| 120 | 106 | ||
| 121 | void videobuf_queue_core_init(struct videobuf_queue *q, | 107 | void videobuf_queue_core_init(struct videobuf_queue *q, |
| 122 | struct videobuf_queue_ops *ops, | 108 | struct videobuf_queue_ops *ops, |
| 123 | void *dev, | 109 | struct device *dev, |
| 124 | spinlock_t *irqlock, | 110 | spinlock_t *irqlock, |
| 125 | enum v4l2_buf_type type, | 111 | enum v4l2_buf_type type, |
| 126 | enum v4l2_field field, | 112 | enum v4l2_field field, |
| @@ -144,10 +130,14 @@ void videobuf_queue_core_init(struct videobuf_queue *q, | |||
| 144 | BUG_ON(!q->ops->buf_queue); | 130 | BUG_ON(!q->ops->buf_queue); |
| 145 | BUG_ON(!q->ops->buf_release); | 131 | BUG_ON(!q->ops->buf_release); |
| 146 | 132 | ||
| 133 | /* Lock is mandatory for queue_cancel to work */ | ||
| 134 | BUG_ON(!irqlock); | ||
| 135 | |||
| 147 | /* Having implementations for abstract methods are mandatory */ | 136 | /* Having implementations for abstract methods are mandatory */ |
| 148 | BUG_ON(!q->int_ops); | 137 | BUG_ON(!q->int_ops); |
| 149 | 138 | ||
| 150 | mutex_init(&q->vb_lock); | 139 | mutex_init(&q->vb_lock); |
| 140 | init_waitqueue_head(&q->wait); | ||
| 151 | INIT_LIST_HEAD(&q->stream); | 141 | INIT_LIST_HEAD(&q->stream); |
| 152 | } | 142 | } |
| 153 | 143 | ||
| @@ -195,19 +185,22 @@ void videobuf_queue_cancel(struct videobuf_queue *q) | |||
| 195 | unsigned long flags = 0; | 185 | unsigned long flags = 0; |
| 196 | int i; | 186 | int i; |
| 197 | 187 | ||
| 188 | q->streaming = 0; | ||
| 189 | q->reading = 0; | ||
| 190 | wake_up_interruptible_sync(&q->wait); | ||
| 191 | |||
| 198 | /* remove queued buffers from list */ | 192 | /* remove queued buffers from list */ |
| 199 | if (q->irqlock) | 193 | spin_lock_irqsave(q->irqlock, flags); |
| 200 | spin_lock_irqsave(q->irqlock, flags); | ||
| 201 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { | 194 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| 202 | if (NULL == q->bufs[i]) | 195 | if (NULL == q->bufs[i]) |
| 203 | continue; | 196 | continue; |
| 204 | if (q->bufs[i]->state == VIDEOBUF_QUEUED) { | 197 | if (q->bufs[i]->state == VIDEOBUF_QUEUED) { |
| 205 | list_del(&q->bufs[i]->queue); | 198 | list_del(&q->bufs[i]->queue); |
| 206 | q->bufs[i]->state = VIDEOBUF_ERROR; | 199 | q->bufs[i]->state = VIDEOBUF_ERROR; |
| 200 | wake_up_all(&q->bufs[i]->done); | ||
| 207 | } | 201 | } |
| 208 | } | 202 | } |
| 209 | if (q->irqlock) | 203 | spin_unlock_irqrestore(q->irqlock, flags); |
| 210 | spin_unlock_irqrestore(q->irqlock, flags); | ||
| 211 | 204 | ||
| 212 | /* free all buffers + clear queue */ | 205 | /* free all buffers + clear queue */ |
| 213 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { | 206 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| @@ -563,14 +556,13 @@ int videobuf_qbuf(struct videobuf_queue *q, | |||
| 563 | 556 | ||
| 564 | list_add_tail(&buf->stream, &q->stream); | 557 | list_add_tail(&buf->stream, &q->stream); |
| 565 | if (q->streaming) { | 558 | if (q->streaming) { |
| 566 | if (q->irqlock) | 559 | spin_lock_irqsave(q->irqlock, flags); |
| 567 | spin_lock_irqsave(q->irqlock, flags); | ||
| 568 | q->ops->buf_queue(q, buf); | 560 | q->ops->buf_queue(q, buf); |
| 569 | if (q->irqlock) | 561 | spin_unlock_irqrestore(q->irqlock, flags); |
| 570 | spin_unlock_irqrestore(q->irqlock, flags); | ||
| 571 | } | 562 | } |
| 572 | dprintk(1, "qbuf: succeded\n"); | 563 | dprintk(1, "qbuf: succeded\n"); |
| 573 | retval = 0; | 564 | retval = 0; |
| 565 | wake_up_interruptible_sync(&q->wait); | ||
| 574 | 566 | ||
| 575 | done: | 567 | done: |
| 576 | mutex_unlock(&q->vb_lock); | 568 | mutex_unlock(&q->vb_lock); |
| @@ -581,35 +573,88 @@ int videobuf_qbuf(struct videobuf_queue *q, | |||
| 581 | return retval; | 573 | return retval; |
| 582 | } | 574 | } |
| 583 | 575 | ||
| 584 | int videobuf_dqbuf(struct videobuf_queue *q, | 576 | |
| 585 | struct v4l2_buffer *b, int nonblocking) | 577 | /* Locking: Caller holds q->vb_lock */ |
| 578 | static int stream_next_buffer_check_queue(struct videobuf_queue *q, int noblock) | ||
| 586 | { | 579 | { |
| 587 | struct videobuf_buffer *buf; | ||
| 588 | int retval; | 580 | int retval; |
| 589 | 581 | ||
| 590 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | 582 | checks: |
| 591 | 583 | if (!q->streaming) { | |
| 592 | mutex_lock(&q->vb_lock); | 584 | dprintk(1, "next_buffer: Not streaming\n"); |
| 593 | retval = -EBUSY; | 585 | retval = -EINVAL; |
| 594 | if (q->reading) { | ||
| 595 | dprintk(1, "dqbuf: Reading running...\n"); | ||
| 596 | goto done; | ||
| 597 | } | ||
| 598 | retval = -EINVAL; | ||
| 599 | if (b->type != q->type) { | ||
| 600 | dprintk(1, "dqbuf: Wrong type.\n"); | ||
| 601 | goto done; | 586 | goto done; |
| 602 | } | 587 | } |
| 588 | |||
| 603 | if (list_empty(&q->stream)) { | 589 | if (list_empty(&q->stream)) { |
| 604 | dprintk(1, "dqbuf: stream running\n"); | 590 | if (noblock) { |
| 605 | goto done; | 591 | retval = -EAGAIN; |
| 592 | dprintk(2, "next_buffer: no buffers to dequeue\n"); | ||
| 593 | goto done; | ||
| 594 | } else { | ||
| 595 | dprintk(2, "next_buffer: waiting on buffer\n"); | ||
| 596 | |||
| 597 | /* Drop lock to avoid deadlock with qbuf */ | ||
| 598 | mutex_unlock(&q->vb_lock); | ||
| 599 | |||
| 600 | /* Checking list_empty and streaming is safe without | ||
| 601 | * locks because we goto checks to validate while | ||
| 602 | * holding locks before proceeding */ | ||
| 603 | retval = wait_event_interruptible(q->wait, | ||
| 604 | !list_empty(&q->stream) || !q->streaming); | ||
| 605 | mutex_lock(&q->vb_lock); | ||
| 606 | |||
| 607 | if (retval) | ||
| 608 | goto done; | ||
| 609 | |||
| 610 | goto checks; | ||
| 611 | } | ||
| 606 | } | 612 | } |
| 613 | |||
| 614 | retval = 0; | ||
| 615 | |||
| 616 | done: | ||
| 617 | return retval; | ||
| 618 | } | ||
| 619 | |||
| 620 | |||
| 621 | /* Locking: Caller holds q->vb_lock */ | ||
| 622 | static int stream_next_buffer(struct videobuf_queue *q, | ||
| 623 | struct videobuf_buffer **vb, int nonblocking) | ||
| 624 | { | ||
| 625 | int retval; | ||
| 626 | struct videobuf_buffer *buf = NULL; | ||
| 627 | |||
| 628 | retval = stream_next_buffer_check_queue(q, nonblocking); | ||
| 629 | if (retval) | ||
| 630 | goto done; | ||
| 631 | |||
| 607 | buf = list_entry(q->stream.next, struct videobuf_buffer, stream); | 632 | buf = list_entry(q->stream.next, struct videobuf_buffer, stream); |
| 608 | retval = videobuf_waiton(buf, nonblocking, 1); | 633 | retval = videobuf_waiton(buf, nonblocking, 1); |
| 634 | if (retval < 0) | ||
| 635 | goto done; | ||
| 636 | |||
| 637 | *vb = buf; | ||
| 638 | done: | ||
| 639 | return retval; | ||
| 640 | } | ||
| 641 | |||
| 642 | int videobuf_dqbuf(struct videobuf_queue *q, | ||
| 643 | struct v4l2_buffer *b, int nonblocking) | ||
| 644 | { | ||
| 645 | struct videobuf_buffer *buf = NULL; | ||
| 646 | int retval; | ||
| 647 | |||
| 648 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | ||
| 649 | |||
| 650 | mutex_lock(&q->vb_lock); | ||
| 651 | |||
| 652 | retval = stream_next_buffer(q, &buf, nonblocking); | ||
| 609 | if (retval < 0) { | 653 | if (retval < 0) { |
| 610 | dprintk(1, "dqbuf: waiton returned %d\n", retval); | 654 | dprintk(1, "dqbuf: next_buffer error: %i\n", retval); |
| 611 | goto done; | 655 | goto done; |
| 612 | } | 656 | } |
| 657 | |||
| 613 | switch (buf->state) { | 658 | switch (buf->state) { |
| 614 | case VIDEOBUF_ERROR: | 659 | case VIDEOBUF_ERROR: |
| 615 | dprintk(1, "dqbuf: state is error\n"); | 660 | dprintk(1, "dqbuf: state is error\n"); |
| @@ -650,14 +695,13 @@ int videobuf_streamon(struct videobuf_queue *q) | |||
| 650 | if (q->streaming) | 695 | if (q->streaming) |
| 651 | goto done; | 696 | goto done; |
| 652 | q->streaming = 1; | 697 | q->streaming = 1; |
| 653 | if (q->irqlock) | 698 | spin_lock_irqsave(q->irqlock, flags); |
| 654 | spin_lock_irqsave(q->irqlock, flags); | ||
| 655 | list_for_each_entry(buf, &q->stream, stream) | 699 | list_for_each_entry(buf, &q->stream, stream) |
| 656 | if (buf->state == VIDEOBUF_PREPARED) | 700 | if (buf->state == VIDEOBUF_PREPARED) |
| 657 | q->ops->buf_queue(q, buf); | 701 | q->ops->buf_queue(q, buf); |
| 658 | if (q->irqlock) | 702 | spin_unlock_irqrestore(q->irqlock, flags); |
| 659 | spin_unlock_irqrestore(q->irqlock, flags); | ||
| 660 | 703 | ||
| 704 | wake_up_interruptible_sync(&q->wait); | ||
| 661 | done: | 705 | done: |
| 662 | mutex_unlock(&q->vb_lock); | 706 | mutex_unlock(&q->vb_lock); |
| 663 | return retval; | 707 | return retval; |
| @@ -670,7 +714,6 @@ static int __videobuf_streamoff(struct videobuf_queue *q) | |||
| 670 | return -EINVAL; | 714 | return -EINVAL; |
| 671 | 715 | ||
| 672 | videobuf_queue_cancel(q); | 716 | videobuf_queue_cancel(q); |
| 673 | q->streaming = 0; | ||
| 674 | 717 | ||
| 675 | return 0; | 718 | return 0; |
| 676 | } | 719 | } |
| @@ -712,11 +755,9 @@ static ssize_t videobuf_read_zerocopy(struct videobuf_queue *q, | |||
| 712 | goto done; | 755 | goto done; |
| 713 | 756 | ||
| 714 | /* start capture & wait */ | 757 | /* start capture & wait */ |
| 715 | if (q->irqlock) | 758 | spin_lock_irqsave(q->irqlock, flags); |
| 716 | spin_lock_irqsave(q->irqlock, flags); | ||
| 717 | q->ops->buf_queue(q, q->read_buf); | 759 | q->ops->buf_queue(q, q->read_buf); |
| 718 | if (q->irqlock) | 760 | spin_unlock_irqrestore(q->irqlock, flags); |
| 719 | spin_unlock_irqrestore(q->irqlock, flags); | ||
| 720 | retval = videobuf_waiton(q->read_buf, 0, 0); | 761 | retval = videobuf_waiton(q->read_buf, 0, 0); |
| 721 | if (0 == retval) { | 762 | if (0 == retval) { |
| 722 | CALL(q, sync, q, q->read_buf); | 763 | CALL(q, sync, q, q->read_buf); |
| @@ -740,14 +781,13 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, | |||
| 740 | { | 781 | { |
| 741 | enum v4l2_field field; | 782 | enum v4l2_field field; |
| 742 | unsigned long flags = 0; | 783 | unsigned long flags = 0; |
| 743 | unsigned size, nbufs; | 784 | unsigned size = 0, nbufs = 1; |
| 744 | int retval; | 785 | int retval; |
| 745 | 786 | ||
| 746 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | 787 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
| 747 | 788 | ||
| 748 | mutex_lock(&q->vb_lock); | 789 | mutex_lock(&q->vb_lock); |
| 749 | 790 | ||
| 750 | nbufs = 1; size = 0; | ||
| 751 | q->ops->buf_setup(q, &nbufs, &size); | 791 | q->ops->buf_setup(q, &nbufs, &size); |
| 752 | 792 | ||
| 753 | if (NULL == q->read_buf && | 793 | if (NULL == q->read_buf && |
| @@ -778,12 +818,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q, | |||
| 778 | q->read_buf = NULL; | 818 | q->read_buf = NULL; |
| 779 | goto done; | 819 | goto done; |
| 780 | } | 820 | } |
| 781 | if (q->irqlock) | ||
| 782 | spin_lock_irqsave(q->irqlock, flags); | ||
| 783 | 821 | ||
| 822 | spin_lock_irqsave(q->irqlock, flags); | ||
| 784 | q->ops->buf_queue(q, q->read_buf); | 823 | q->ops->buf_queue(q, q->read_buf); |
| 785 | if (q->irqlock) | 824 | spin_unlock_irqrestore(q->irqlock, flags); |
| 786 | spin_unlock_irqrestore(q->irqlock, flags); | 825 | |
| 787 | q->read_off = 0; | 826 | q->read_off = 0; |
| 788 | } | 827 | } |
| 789 | 828 | ||
| @@ -849,12 +888,10 @@ static int __videobuf_read_start(struct videobuf_queue *q) | |||
| 849 | return err; | 888 | return err; |
| 850 | list_add_tail(&q->bufs[i]->stream, &q->stream); | 889 | list_add_tail(&q->bufs[i]->stream, &q->stream); |
| 851 | } | 890 | } |
| 852 | if (q->irqlock) | 891 | spin_lock_irqsave(q->irqlock, flags); |
| 853 | spin_lock_irqsave(q->irqlock, flags); | ||
| 854 | for (i = 0; i < count; i++) | 892 | for (i = 0; i < count; i++) |
| 855 | q->ops->buf_queue(q, q->bufs[i]); | 893 | q->ops->buf_queue(q, q->bufs[i]); |
| 856 | if (q->irqlock) | 894 | spin_unlock_irqrestore(q->irqlock, flags); |
| 857 | spin_unlock_irqrestore(q->irqlock, flags); | ||
| 858 | q->reading = 1; | 895 | q->reading = 1; |
| 859 | return 0; | 896 | return 0; |
| 860 | } | 897 | } |
| @@ -863,7 +900,6 @@ static void __videobuf_read_stop(struct videobuf_queue *q) | |||
| 863 | { | 900 | { |
| 864 | int i; | 901 | int i; |
| 865 | 902 | ||
| 866 | |||
| 867 | videobuf_queue_cancel(q); | 903 | videobuf_queue_cancel(q); |
| 868 | __videobuf_mmap_free(q); | 904 | __videobuf_mmap_free(q); |
| 869 | INIT_LIST_HEAD(&q->stream); | 905 | INIT_LIST_HEAD(&q->stream); |
| @@ -874,7 +910,6 @@ static void __videobuf_read_stop(struct videobuf_queue *q) | |||
| 874 | q->bufs[i] = NULL; | 910 | q->bufs[i] = NULL; |
| 875 | } | 911 | } |
| 876 | q->read_buf = NULL; | 912 | q->read_buf = NULL; |
| 877 | q->reading = 0; | ||
| 878 | 913 | ||
| 879 | } | 914 | } |
| 880 | 915 | ||
| @@ -919,7 +954,7 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, | |||
| 919 | 954 | ||
| 920 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); | 955 | MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); |
| 921 | 956 | ||
| 922 | dprintk(2, "%s\n", __FUNCTION__); | 957 | dprintk(2, "%s\n", __func__); |
| 923 | mutex_lock(&q->vb_lock); | 958 | mutex_lock(&q->vb_lock); |
| 924 | retval = -EBUSY; | 959 | retval = -EBUSY; |
| 925 | if (q->streaming) | 960 | if (q->streaming) |
| @@ -968,11 +1003,9 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q, | |||
| 968 | if (q->read_off == q->read_buf->size) { | 1003 | if (q->read_off == q->read_buf->size) { |
| 969 | list_add_tail(&q->read_buf->stream, | 1004 | list_add_tail(&q->read_buf->stream, |
| 970 | &q->stream); | 1005 | &q->stream); |
| 971 | if (q->irqlock) | 1006 | spin_lock_irqsave(q->irqlock, flags); |
| 972 | spin_lock_irqsave(q->irqlock, flags); | ||
| 973 | q->ops->buf_queue(q, q->read_buf); | 1007 | q->ops->buf_queue(q, q->read_buf); |
| 974 | if (q->irqlock) | 1008 | spin_unlock_irqrestore(q->irqlock, flags); |
| 975 | spin_unlock_irqrestore(q->irqlock, flags); | ||
| 976 | q->read_buf = NULL; | 1009 | q->read_buf = NULL; |
| 977 | } | 1010 | } |
| 978 | if (retval < 0) | 1011 | if (retval < 0) |
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c index 53fed4b74ce9..03a7b946bd54 100644 --- a/drivers/media/video/videobuf-dma-sg.c +++ b/drivers/media/video/videobuf-dma-sg.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * helper functions for PCI DMA video4linux capture buffers | 2 | * helper functions for SG DMA video4linux capture buffers |
| 3 | * | 3 | * |
| 4 | * The functions expect the hardware being able to scatter gatter | 4 | * The functions expect the hardware being able to scatter gatter |
| 5 | * (i.e. the buffers are not linear in physical memory, but fragmented | 5 | * (i.e. the buffers are not linear in physical memory, but fragmented |
| @@ -24,7 +24,7 @@ | |||
| 24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
| 25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
| 26 | 26 | ||
| 27 | #include <linux/pci.h> | 27 | #include <linux/dma-mapping.h> |
| 28 | #include <linux/vmalloc.h> | 28 | #include <linux/vmalloc.h> |
| 29 | #include <linux/pagemap.h> | 29 | #include <linux/pagemap.h> |
| 30 | #include <linux/scatterlist.h> | 30 | #include <linux/scatterlist.h> |
| @@ -39,10 +39,10 @@ | |||
| 39 | #define MAGIC_CHECK(is,should) if (unlikely((is) != (should))) \ | 39 | #define MAGIC_CHECK(is,should) if (unlikely((is) != (should))) \ |
| 40 | { printk(KERN_ERR "magic mismatch: %x (expected %x)\n",is,should); BUG(); } | 40 | { printk(KERN_ERR "magic mismatch: %x (expected %x)\n",is,should); BUG(); } |
| 41 | 41 | ||
| 42 | static int debug = 0; | 42 | static int debug; |
| 43 | module_param(debug, int, 0644); | 43 | module_param(debug, int, 0644); |
| 44 | 44 | ||
| 45 | MODULE_DESCRIPTION("helper module to manage video4linux pci dma sg buffers"); | 45 | MODULE_DESCRIPTION("helper module to manage video4linux dma sg buffers"); |
| 46 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); | 46 | MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); |
| 47 | MODULE_LICENSE("GPL"); | 47 | MODULE_LICENSE("GPL"); |
| 48 | 48 | ||
| @@ -119,10 +119,10 @@ videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset) | |||
| 119 | 119 | ||
| 120 | struct videobuf_dmabuf *videobuf_to_dma (struct videobuf_buffer *buf) | 120 | struct videobuf_dmabuf *videobuf_to_dma (struct videobuf_buffer *buf) |
| 121 | { | 121 | { |
| 122 | struct videbuf_pci_sg_memory *mem=buf->priv; | 122 | struct videobuf_dma_sg_memory *mem = buf->priv; |
| 123 | BUG_ON (!mem); | 123 | BUG_ON(!mem); |
| 124 | 124 | ||
| 125 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 125 | MAGIC_CHECK(mem->magic, MAGIC_SG_MEM); |
| 126 | 126 | ||
| 127 | return &mem->dma; | 127 | return &mem->dma; |
| 128 | } | 128 | } |
| @@ -141,9 +141,14 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, | |||
| 141 | 141 | ||
| 142 | dma->direction = direction; | 142 | dma->direction = direction; |
| 143 | switch (dma->direction) { | 143 | switch (dma->direction) { |
| 144 | case PCI_DMA_FROMDEVICE: rw = READ; break; | 144 | case DMA_FROM_DEVICE: |
| 145 | case PCI_DMA_TODEVICE: rw = WRITE; break; | 145 | rw = READ; |
| 146 | default: BUG(); | 146 | break; |
| 147 | case DMA_TO_DEVICE: | ||
| 148 | rw = WRITE; | ||
| 149 | break; | ||
| 150 | default: | ||
| 151 | BUG(); | ||
| 147 | } | 152 | } |
| 148 | 153 | ||
| 149 | first = (data & PAGE_MASK) >> PAGE_SHIFT; | 154 | first = (data & PAGE_MASK) >> PAGE_SHIFT; |
| @@ -157,9 +162,6 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, | |||
| 157 | dprintk(1,"init user [0x%lx+0x%lx => %d pages]\n", | 162 | dprintk(1,"init user [0x%lx+0x%lx => %d pages]\n", |
| 158 | data,size,dma->nr_pages); | 163 | data,size,dma->nr_pages); |
| 159 | 164 | ||
| 160 | dma->varea = (void *) data; | ||
| 161 | |||
| 162 | |||
| 163 | err = get_user_pages(current,current->mm, | 165 | err = get_user_pages(current,current->mm, |
| 164 | data & PAGE_MASK, dma->nr_pages, | 166 | data & PAGE_MASK, dma->nr_pages, |
| 165 | rw == READ, 1, /* force */ | 167 | rw == READ, 1, /* force */ |
| @@ -216,10 +218,8 @@ int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction, | |||
| 216 | return 0; | 218 | return 0; |
| 217 | } | 219 | } |
| 218 | 220 | ||
| 219 | int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma) | 221 | int videobuf_dma_map(struct videobuf_queue* q, struct videobuf_dmabuf *dma) |
| 220 | { | 222 | { |
| 221 | void *dev=q->dev; | ||
| 222 | |||
| 223 | MAGIC_CHECK(dma->magic,MAGIC_DMABUF); | 223 | MAGIC_CHECK(dma->magic,MAGIC_DMABUF); |
| 224 | BUG_ON(0 == dma->nr_pages); | 224 | BUG_ON(0 == dma->nr_pages); |
| 225 | 225 | ||
| @@ -245,11 +245,11 @@ int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma) | |||
| 245 | return -ENOMEM; | 245 | return -ENOMEM; |
| 246 | } | 246 | } |
| 247 | if (!dma->bus_addr) { | 247 | if (!dma->bus_addr) { |
| 248 | dma->sglen = pci_map_sg(dev,dma->sglist, | 248 | dma->sglen = dma_map_sg(q->dev, dma->sglist, |
| 249 | dma->nr_pages, dma->direction); | 249 | dma->nr_pages, dma->direction); |
| 250 | if (0 == dma->sglen) { | 250 | if (0 == dma->sglen) { |
| 251 | printk(KERN_WARNING | 251 | printk(KERN_WARNING |
| 252 | "%s: videobuf_map_sg failed\n",__FUNCTION__); | 252 | "%s: videobuf_map_sg failed\n",__func__); |
| 253 | kfree(dma->sglist); | 253 | kfree(dma->sglist); |
| 254 | dma->sglist = NULL; | 254 | dma->sglist = NULL; |
| 255 | dma->sglen = 0; | 255 | dma->sglen = 0; |
| @@ -259,26 +259,22 @@ int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma) | |||
| 259 | return 0; | 259 | return 0; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | int videobuf_dma_sync(struct videobuf_queue *q,struct videobuf_dmabuf *dma) | 262 | int videobuf_dma_sync(struct videobuf_queue *q, struct videobuf_dmabuf *dma) |
| 263 | { | 263 | { |
| 264 | void *dev=q->dev; | 264 | MAGIC_CHECK(dma->magic, MAGIC_DMABUF); |
| 265 | |||
| 266 | MAGIC_CHECK(dma->magic,MAGIC_DMABUF); | ||
| 267 | BUG_ON(!dma->sglen); | 265 | BUG_ON(!dma->sglen); |
| 268 | 266 | ||
| 269 | pci_dma_sync_sg_for_cpu (dev,dma->sglist,dma->nr_pages,dma->direction); | 267 | dma_sync_sg_for_cpu(q->dev, dma->sglist, dma->nr_pages, dma->direction); |
| 270 | return 0; | 268 | return 0; |
| 271 | } | 269 | } |
| 272 | 270 | ||
| 273 | int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma) | 271 | int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma) |
| 274 | { | 272 | { |
| 275 | void *dev=q->dev; | 273 | MAGIC_CHECK(dma->magic, MAGIC_DMABUF); |
| 276 | |||
| 277 | MAGIC_CHECK(dma->magic,MAGIC_DMABUF); | ||
| 278 | if (!dma->sglen) | 274 | if (!dma->sglen) |
| 279 | return 0; | 275 | return 0; |
| 280 | 276 | ||
| 281 | pci_unmap_sg (dev,dma->sglist,dma->nr_pages,dma->direction); | 277 | dma_unmap_sg(q->dev, dma->sglist, dma->nr_pages, dma->direction); |
| 282 | 278 | ||
| 283 | kfree(dma->sglist); | 279 | kfree(dma->sglist); |
| 284 | dma->sglist = NULL; | 280 | dma->sglist = NULL; |
| @@ -301,33 +297,32 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma) | |||
| 301 | 297 | ||
| 302 | vfree(dma->vmalloc); | 298 | vfree(dma->vmalloc); |
| 303 | dma->vmalloc = NULL; | 299 | dma->vmalloc = NULL; |
| 304 | dma->varea = NULL; | ||
| 305 | 300 | ||
| 306 | if (dma->bus_addr) { | 301 | if (dma->bus_addr) { |
| 307 | dma->bus_addr = 0; | 302 | dma->bus_addr = 0; |
| 308 | } | 303 | } |
| 309 | dma->direction = PCI_DMA_NONE; | 304 | dma->direction = DMA_NONE; |
| 310 | return 0; | 305 | return 0; |
| 311 | } | 306 | } |
| 312 | 307 | ||
| 313 | /* --------------------------------------------------------------------- */ | 308 | /* --------------------------------------------------------------------- */ |
| 314 | 309 | ||
| 315 | int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma) | 310 | int videobuf_sg_dma_map(struct device *dev, struct videobuf_dmabuf *dma) |
| 316 | { | 311 | { |
| 317 | struct videobuf_queue q; | 312 | struct videobuf_queue q; |
| 318 | 313 | ||
| 319 | q.dev=pci; | 314 | q.dev = dev; |
| 320 | 315 | ||
| 321 | return (videobuf_dma_map(&q,dma)); | 316 | return videobuf_dma_map(&q, dma); |
| 322 | } | 317 | } |
| 323 | 318 | ||
| 324 | int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma) | 319 | int videobuf_sg_dma_unmap(struct device *dev, struct videobuf_dmabuf *dma) |
| 325 | { | 320 | { |
| 326 | struct videobuf_queue q; | 321 | struct videobuf_queue q; |
| 327 | 322 | ||
| 328 | q.dev=pci; | 323 | q.dev = dev; |
| 329 | 324 | ||
| 330 | return (videobuf_dma_unmap(&q,dma)); | 325 | return videobuf_dma_unmap(&q, dma); |
| 331 | } | 326 | } |
| 332 | 327 | ||
| 333 | /* --------------------------------------------------------------------- */ | 328 | /* --------------------------------------------------------------------- */ |
| @@ -347,7 +342,7 @@ videobuf_vm_close(struct vm_area_struct *vma) | |||
| 347 | { | 342 | { |
| 348 | struct videobuf_mapping *map = vma->vm_private_data; | 343 | struct videobuf_mapping *map = vma->vm_private_data; |
| 349 | struct videobuf_queue *q = map->q; | 344 | struct videobuf_queue *q = map->q; |
| 350 | struct videbuf_pci_sg_memory *mem; | 345 | struct videobuf_dma_sg_memory *mem; |
| 351 | int i; | 346 | int i; |
| 352 | 347 | ||
| 353 | dprintk(2,"vm_close %p [count=%d,vma=%08lx-%08lx]\n",map, | 348 | dprintk(2,"vm_close %p [count=%d,vma=%08lx-%08lx]\n",map, |
| @@ -409,18 +404,18 @@ static struct vm_operations_struct videobuf_vm_ops = | |||
| 409 | }; | 404 | }; |
| 410 | 405 | ||
| 411 | /* --------------------------------------------------------------------- | 406 | /* --------------------------------------------------------------------- |
| 412 | * PCI handlers for the generic methods | 407 | * SG handlers for the generic methods |
| 413 | */ | 408 | */ |
| 414 | 409 | ||
| 415 | /* Allocated area consists on 3 parts: | 410 | /* Allocated area consists on 3 parts: |
| 416 | struct video_buffer | 411 | struct video_buffer |
| 417 | struct <driver>_buffer (cx88_buffer, saa7134_buf, ...) | 412 | struct <driver>_buffer (cx88_buffer, saa7134_buf, ...) |
| 418 | struct videobuf_pci_sg_memory | 413 | struct videobuf_dma_sg_memory |
| 419 | */ | 414 | */ |
| 420 | 415 | ||
| 421 | static void *__videobuf_alloc(size_t size) | 416 | static void *__videobuf_alloc(size_t size) |
| 422 | { | 417 | { |
| 423 | struct videbuf_pci_sg_memory *mem; | 418 | struct videobuf_dma_sg_memory *mem; |
| 424 | struct videobuf_buffer *vb; | 419 | struct videobuf_buffer *vb; |
| 425 | 420 | ||
| 426 | vb = kzalloc(size+sizeof(*mem),GFP_KERNEL); | 421 | vb = kzalloc(size+sizeof(*mem),GFP_KERNEL); |
| @@ -431,22 +426,32 @@ static void *__videobuf_alloc(size_t size) | |||
| 431 | videobuf_dma_init(&mem->dma); | 426 | videobuf_dma_init(&mem->dma); |
| 432 | 427 | ||
| 433 | dprintk(1,"%s: allocated at %p(%ld+%ld) & %p(%ld)\n", | 428 | dprintk(1,"%s: allocated at %p(%ld+%ld) & %p(%ld)\n", |
| 434 | __FUNCTION__,vb,(long)sizeof(*vb),(long)size-sizeof(*vb), | 429 | __func__,vb,(long)sizeof(*vb),(long)size-sizeof(*vb), |
| 435 | mem,(long)sizeof(*mem)); | 430 | mem,(long)sizeof(*mem)); |
| 436 | 431 | ||
| 437 | return vb; | 432 | return vb; |
| 438 | } | 433 | } |
| 439 | 434 | ||
| 435 | static void *__videobuf_to_vmalloc (struct videobuf_buffer *buf) | ||
| 436 | { | ||
| 437 | struct videobuf_dma_sg_memory *mem = buf->priv; | ||
| 438 | BUG_ON(!mem); | ||
| 439 | |||
| 440 | MAGIC_CHECK(mem->magic, MAGIC_SG_MEM); | ||
| 441 | |||
| 442 | return mem->dma.vmalloc; | ||
| 443 | } | ||
| 444 | |||
| 440 | static int __videobuf_iolock (struct videobuf_queue* q, | 445 | static int __videobuf_iolock (struct videobuf_queue* q, |
| 441 | struct videobuf_buffer *vb, | 446 | struct videobuf_buffer *vb, |
| 442 | struct v4l2_framebuffer *fbuf) | 447 | struct v4l2_framebuffer *fbuf) |
| 443 | { | 448 | { |
| 444 | int err,pages; | 449 | int err,pages; |
| 445 | dma_addr_t bus; | 450 | dma_addr_t bus; |
| 446 | struct videbuf_pci_sg_memory *mem=vb->priv; | 451 | struct videobuf_dma_sg_memory *mem = vb->priv; |
| 447 | BUG_ON(!mem); | 452 | BUG_ON(!mem); |
| 448 | 453 | ||
| 449 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 454 | MAGIC_CHECK(mem->magic, MAGIC_SG_MEM); |
| 450 | 455 | ||
| 451 | switch (vb->memory) { | 456 | switch (vb->memory) { |
| 452 | case V4L2_MEMORY_MMAP: | 457 | case V4L2_MEMORY_MMAP: |
| @@ -455,14 +460,14 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
| 455 | /* no userspace addr -- kernel bounce buffer */ | 460 | /* no userspace addr -- kernel bounce buffer */ |
| 456 | pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; | 461 | pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; |
| 457 | err = videobuf_dma_init_kernel( &mem->dma, | 462 | err = videobuf_dma_init_kernel( &mem->dma, |
| 458 | PCI_DMA_FROMDEVICE, | 463 | DMA_FROM_DEVICE, |
| 459 | pages ); | 464 | pages ); |
| 460 | if (0 != err) | 465 | if (0 != err) |
| 461 | return err; | 466 | return err; |
| 462 | } else if (vb->memory == V4L2_MEMORY_USERPTR) { | 467 | } else if (vb->memory == V4L2_MEMORY_USERPTR) { |
| 463 | /* dma directly to userspace */ | 468 | /* dma directly to userspace */ |
| 464 | err = videobuf_dma_init_user( &mem->dma, | 469 | err = videobuf_dma_init_user( &mem->dma, |
| 465 | PCI_DMA_FROMDEVICE, | 470 | DMA_FROM_DEVICE, |
| 466 | vb->baddr,vb->bsize ); | 471 | vb->baddr,vb->bsize ); |
| 467 | if (0 != err) | 472 | if (0 != err) |
| 468 | return err; | 473 | return err; |
| @@ -473,7 +478,7 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
| 473 | locking inversion, so don't take it here */ | 478 | locking inversion, so don't take it here */ |
| 474 | 479 | ||
| 475 | err = videobuf_dma_init_user_locked(&mem->dma, | 480 | err = videobuf_dma_init_user_locked(&mem->dma, |
| 476 | PCI_DMA_FROMDEVICE, | 481 | DMA_FROM_DEVICE, |
| 477 | vb->baddr, vb->bsize); | 482 | vb->baddr, vb->bsize); |
| 478 | if (0 != err) | 483 | if (0 != err) |
| 479 | return err; | 484 | return err; |
| @@ -490,7 +495,7 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
| 490 | */ | 495 | */ |
| 491 | bus = (dma_addr_t)(unsigned long)fbuf->base + vb->boff; | 496 | bus = (dma_addr_t)(unsigned long)fbuf->base + vb->boff; |
| 492 | pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; | 497 | pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; |
| 493 | err = videobuf_dma_init_overlay(&mem->dma,PCI_DMA_FROMDEVICE, | 498 | err = videobuf_dma_init_overlay(&mem->dma, DMA_FROM_DEVICE, |
| 494 | bus, pages); | 499 | bus, pages); |
| 495 | if (0 != err) | 500 | if (0 != err) |
| 496 | return err; | 501 | return err; |
| @@ -498,7 +503,7 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
| 498 | default: | 503 | default: |
| 499 | BUG(); | 504 | BUG(); |
| 500 | } | 505 | } |
| 501 | err = videobuf_dma_map(q,&mem->dma); | 506 | err = videobuf_dma_map(q, &mem->dma); |
| 502 | if (0 != err) | 507 | if (0 != err) |
| 503 | return err; | 508 | return err; |
| 504 | 509 | ||
| @@ -508,8 +513,8 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
| 508 | static int __videobuf_sync(struct videobuf_queue *q, | 513 | static int __videobuf_sync(struct videobuf_queue *q, |
| 509 | struct videobuf_buffer *buf) | 514 | struct videobuf_buffer *buf) |
| 510 | { | 515 | { |
| 511 | struct videbuf_pci_sg_memory *mem=buf->priv; | 516 | struct videobuf_dma_sg_memory *mem = buf->priv; |
| 512 | BUG_ON (!mem); | 517 | BUG_ON(!mem); |
| 513 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 518 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); |
| 514 | 519 | ||
| 515 | return videobuf_dma_sync(q,&mem->dma); | 520 | return videobuf_dma_sync(q,&mem->dma); |
| @@ -532,7 +537,7 @@ static int __videobuf_mmap_free(struct videobuf_queue *q) | |||
| 532 | static int __videobuf_mmap_mapper(struct videobuf_queue *q, | 537 | static int __videobuf_mmap_mapper(struct videobuf_queue *q, |
| 533 | struct vm_area_struct *vma) | 538 | struct vm_area_struct *vma) |
| 534 | { | 539 | { |
| 535 | struct videbuf_pci_sg_memory *mem; | 540 | struct videobuf_dma_sg_memory *mem; |
| 536 | struct videobuf_mapping *map; | 541 | struct videobuf_mapping *map; |
| 537 | unsigned int first,last,size,i; | 542 | unsigned int first,last,size,i; |
| 538 | int retval; | 543 | int retval; |
| @@ -547,12 +552,20 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, | |||
| 547 | goto done; | 552 | goto done; |
| 548 | } | 553 | } |
| 549 | 554 | ||
| 555 | /* This function maintains backwards compatibility with V4L1 and will | ||
| 556 | * map more than one buffer if the vma length is equal to the combined | ||
| 557 | * size of multiple buffers than it will map them together. See | ||
| 558 | * VIDIOCGMBUF in the v4l spec | ||
| 559 | * | ||
| 560 | * TODO: Allow drivers to specify if they support this mode | ||
| 561 | */ | ||
| 562 | |||
| 550 | /* look for first buffer to map */ | 563 | /* look for first buffer to map */ |
| 551 | for (first = 0; first < VIDEO_MAX_FRAME; first++) { | 564 | for (first = 0; first < VIDEO_MAX_FRAME; first++) { |
| 552 | if (NULL == q->bufs[first]) | 565 | if (NULL == q->bufs[first]) |
| 553 | continue; | 566 | continue; |
| 554 | mem=q->bufs[first]->priv; | 567 | mem=q->bufs[first]->priv; |
| 555 | BUG_ON (!mem); | 568 | BUG_ON(!mem); |
| 556 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 569 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); |
| 557 | 570 | ||
| 558 | if (V4L2_MEMORY_MMAP != q->bufs[first]->memory) | 571 | if (V4L2_MEMORY_MMAP != q->bufs[first]->memory) |
| @@ -591,10 +604,16 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, | |||
| 591 | map = kmalloc(sizeof(struct videobuf_mapping),GFP_KERNEL); | 604 | map = kmalloc(sizeof(struct videobuf_mapping),GFP_KERNEL); |
| 592 | if (NULL == map) | 605 | if (NULL == map) |
| 593 | goto done; | 606 | goto done; |
| 594 | for (size = 0, i = first; i <= last; size += q->bufs[i++]->bsize) { | 607 | |
| 608 | size = 0; | ||
| 609 | for (i = first; i <= last; i++) { | ||
| 610 | if (NULL == q->bufs[i]) | ||
| 611 | continue; | ||
| 595 | q->bufs[i]->map = map; | 612 | q->bufs[i]->map = map; |
| 596 | q->bufs[i]->baddr = vma->vm_start + size; | 613 | q->bufs[i]->baddr = vma->vm_start + size; |
| 614 | size += q->bufs[i]->bsize; | ||
| 597 | } | 615 | } |
| 616 | |||
| 598 | map->count = 1; | 617 | map->count = 1; |
| 599 | map->start = vma->vm_start; | 618 | map->start = vma->vm_start; |
| 600 | map->end = vma->vm_end; | 619 | map->end = vma->vm_end; |
| @@ -615,8 +634,8 @@ static int __videobuf_copy_to_user ( struct videobuf_queue *q, | |||
| 615 | char __user *data, size_t count, | 634 | char __user *data, size_t count, |
| 616 | int nonblocking ) | 635 | int nonblocking ) |
| 617 | { | 636 | { |
| 618 | struct videbuf_pci_sg_memory *mem=q->read_buf->priv; | 637 | struct videobuf_dma_sg_memory *mem = q->read_buf->priv; |
| 619 | BUG_ON (!mem); | 638 | BUG_ON(!mem); |
| 620 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 639 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); |
| 621 | 640 | ||
| 622 | /* copy to userspace */ | 641 | /* copy to userspace */ |
| @@ -634,8 +653,8 @@ static int __videobuf_copy_stream ( struct videobuf_queue *q, | |||
| 634 | int vbihack, int nonblocking ) | 653 | int vbihack, int nonblocking ) |
| 635 | { | 654 | { |
| 636 | unsigned int *fc; | 655 | unsigned int *fc; |
| 637 | struct videbuf_pci_sg_memory *mem=q->read_buf->priv; | 656 | struct videobuf_dma_sg_memory *mem = q->read_buf->priv; |
| 638 | BUG_ON (!mem); | 657 | BUG_ON(!mem); |
| 639 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); | 658 | MAGIC_CHECK(mem->magic,MAGIC_SG_MEM); |
| 640 | 659 | ||
| 641 | if (vbihack) { | 660 | if (vbihack) { |
| @@ -658,7 +677,7 @@ static int __videobuf_copy_stream ( struct videobuf_queue *q, | |||
| 658 | return count; | 677 | return count; |
| 659 | } | 678 | } |
| 660 | 679 | ||
| 661 | static struct videobuf_qtype_ops pci_ops = { | 680 | static struct videobuf_qtype_ops sg_ops = { |
| 662 | .magic = MAGIC_QTYPE_OPS, | 681 | .magic = MAGIC_QTYPE_OPS, |
| 663 | 682 | ||
| 664 | .alloc = __videobuf_alloc, | 683 | .alloc = __videobuf_alloc, |
| @@ -668,23 +687,24 @@ static struct videobuf_qtype_ops pci_ops = { | |||
| 668 | .mmap_mapper = __videobuf_mmap_mapper, | 687 | .mmap_mapper = __videobuf_mmap_mapper, |
| 669 | .video_copy_to_user = __videobuf_copy_to_user, | 688 | .video_copy_to_user = __videobuf_copy_to_user, |
| 670 | .copy_stream = __videobuf_copy_stream, | 689 | .copy_stream = __videobuf_copy_stream, |
| 690 | .vmalloc = __videobuf_to_vmalloc, | ||
| 671 | }; | 691 | }; |
| 672 | 692 | ||
| 673 | void *videobuf_pci_alloc (size_t size) | 693 | void *videobuf_sg_alloc(size_t size) |
| 674 | { | 694 | { |
| 675 | struct videobuf_queue q; | 695 | struct videobuf_queue q; |
| 676 | 696 | ||
| 677 | /* Required to make generic handler to call __videobuf_alloc */ | 697 | /* Required to make generic handler to call __videobuf_alloc */ |
| 678 | q.int_ops=&pci_ops; | 698 | q.int_ops = &sg_ops; |
| 679 | 699 | ||
| 680 | q.msize=size; | 700 | q.msize = size; |
| 681 | 701 | ||
| 682 | return videobuf_alloc (&q); | 702 | return videobuf_alloc(&q); |
| 683 | } | 703 | } |
| 684 | 704 | ||
| 685 | void videobuf_queue_pci_init(struct videobuf_queue* q, | 705 | void videobuf_queue_sg_init(struct videobuf_queue* q, |
| 686 | struct videobuf_queue_ops *ops, | 706 | struct videobuf_queue_ops *ops, |
| 687 | void *dev, | 707 | struct device *dev, |
| 688 | spinlock_t *irqlock, | 708 | spinlock_t *irqlock, |
| 689 | enum v4l2_buf_type type, | 709 | enum v4l2_buf_type type, |
| 690 | enum v4l2_field field, | 710 | enum v4l2_field field, |
| @@ -692,7 +712,7 @@ void videobuf_queue_pci_init(struct videobuf_queue* q, | |||
| 692 | void *priv) | 712 | void *priv) |
| 693 | { | 713 | { |
| 694 | videobuf_queue_core_init(q, ops, dev, irqlock, type, field, msize, | 714 | videobuf_queue_core_init(q, ops, dev, irqlock, type, field, msize, |
| 695 | priv, &pci_ops); | 715 | priv, &sg_ops); |
| 696 | } | 716 | } |
| 697 | 717 | ||
| 698 | /* --------------------------------------------------------------------- */ | 718 | /* --------------------------------------------------------------------- */ |
| @@ -709,11 +729,11 @@ EXPORT_SYMBOL_GPL(videobuf_dma_sync); | |||
| 709 | EXPORT_SYMBOL_GPL(videobuf_dma_unmap); | 729 | EXPORT_SYMBOL_GPL(videobuf_dma_unmap); |
| 710 | EXPORT_SYMBOL_GPL(videobuf_dma_free); | 730 | EXPORT_SYMBOL_GPL(videobuf_dma_free); |
| 711 | 731 | ||
| 712 | EXPORT_SYMBOL_GPL(videobuf_pci_dma_map); | 732 | EXPORT_SYMBOL_GPL(videobuf_sg_dma_map); |
| 713 | EXPORT_SYMBOL_GPL(videobuf_pci_dma_unmap); | 733 | EXPORT_SYMBOL_GPL(videobuf_sg_dma_unmap); |
| 714 | EXPORT_SYMBOL_GPL(videobuf_pci_alloc); | 734 | EXPORT_SYMBOL_GPL(videobuf_sg_alloc); |
| 715 | 735 | ||
| 716 | EXPORT_SYMBOL_GPL(videobuf_queue_pci_init); | 736 | EXPORT_SYMBOL_GPL(videobuf_queue_sg_init); |
| 717 | 737 | ||
| 718 | /* | 738 | /* |
| 719 | * Local variables: | 739 | * Local variables: |
diff --git a/drivers/media/video/videobuf-dvb.c b/drivers/media/video/videobuf-dvb.c index b73aba65d21d..6e4d73ec6855 100644 --- a/drivers/media/video/videobuf-dvb.c +++ b/drivers/media/video/videobuf-dvb.c | |||
| @@ -20,9 +20,10 @@ | |||
| 20 | #include <linux/fs.h> | 20 | #include <linux/fs.h> |
| 21 | #include <linux/kthread.h> | 21 | #include <linux/kthread.h> |
| 22 | #include <linux/file.h> | 22 | #include <linux/file.h> |
| 23 | |||
| 23 | #include <linux/freezer.h> | 24 | #include <linux/freezer.h> |
| 24 | 25 | ||
| 25 | #include <media/videobuf-dma-sg.h> | 26 | #include <media/videobuf-core.h> |
| 26 | #include <media/videobuf-dvb.h> | 27 | #include <media/videobuf-dvb.h> |
| 27 | 28 | ||
| 28 | /* ------------------------------------------------------------------ */ | 29 | /* ------------------------------------------------------------------ */ |
| @@ -30,7 +31,7 @@ | |||
| 30 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); | 31 | MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); |
| 31 | MODULE_LICENSE("GPL"); | 32 | MODULE_LICENSE("GPL"); |
| 32 | 33 | ||
| 33 | static unsigned int debug = 0; | 34 | static unsigned int debug; |
| 34 | module_param(debug, int, 0644); | 35 | module_param(debug, int, 0644); |
| 35 | MODULE_PARM_DESC(debug,"enable debug messages"); | 36 | MODULE_PARM_DESC(debug,"enable debug messages"); |
| 36 | 37 | ||
| @@ -45,7 +46,7 @@ static int videobuf_dvb_thread(void *data) | |||
| 45 | struct videobuf_buffer *buf; | 46 | struct videobuf_buffer *buf; |
| 46 | unsigned long flags; | 47 | unsigned long flags; |
| 47 | int err; | 48 | int err; |
| 48 | struct videobuf_dmabuf *dma; | 49 | void *outp; |
| 49 | 50 | ||
| 50 | dprintk("dvb thread started\n"); | 51 | dprintk("dvb thread started\n"); |
| 51 | set_freezable(); | 52 | set_freezable(); |
| @@ -66,9 +67,10 @@ static int videobuf_dvb_thread(void *data) | |||
| 66 | try_to_freeze(); | 67 | try_to_freeze(); |
| 67 | 68 | ||
| 68 | /* feed buffer data to demux */ | 69 | /* feed buffer data to demux */ |
| 69 | dma=videobuf_to_dma(buf); | 70 | outp = videobuf_queue_to_vmalloc (&dvb->dvbq, buf); |
| 71 | |||
| 70 | if (buf->state == VIDEOBUF_DONE) | 72 | if (buf->state == VIDEOBUF_DONE) |
| 71 | dvb_dmx_swfilter(&dvb->demux, dma->vmalloc, | 73 | dvb_dmx_swfilter(&dvb->demux, outp, |
| 72 | buf->size); | 74 | buf->size); |
| 73 | 75 | ||
| 74 | /* requeue buffer */ | 76 | /* requeue buffer */ |
| @@ -138,14 +140,16 @@ static int videobuf_dvb_stop_feed(struct dvb_demux_feed *feed) | |||
| 138 | int videobuf_dvb_register(struct videobuf_dvb *dvb, | 140 | int videobuf_dvb_register(struct videobuf_dvb *dvb, |
| 139 | struct module *module, | 141 | struct module *module, |
| 140 | void *adapter_priv, | 142 | void *adapter_priv, |
| 141 | struct device *device) | 143 | struct device *device, |
| 144 | short *adapter_nr) | ||
| 142 | { | 145 | { |
| 143 | int result; | 146 | int result; |
| 144 | 147 | ||
| 145 | mutex_init(&dvb->lock); | 148 | mutex_init(&dvb->lock); |
| 146 | 149 | ||
| 147 | /* register adapter */ | 150 | /* register adapter */ |
| 148 | result = dvb_register_adapter(&dvb->adapter, dvb->name, module, device); | 151 | result = dvb_register_adapter(&dvb->adapter, dvb->name, module, device, |
| 152 | adapter_nr); | ||
| 149 | if (result < 0) { | 153 | if (result < 0) { |
| 150 | printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", | 154 | printk(KERN_WARNING "%s: dvb_register_adapter failed (errno = %d)\n", |
| 151 | dvb->name, result); | 155 | dvb->name, result); |
diff --git a/drivers/media/video/videobuf-vmalloc.c b/drivers/media/video/videobuf-vmalloc.c index 5266ecc91dab..c91e1d8e3802 100644 --- a/drivers/media/video/videobuf-vmalloc.c +++ b/drivers/media/video/videobuf-vmalloc.c | |||
| @@ -33,7 +33,7 @@ | |||
| 33 | #define MAGIC_CHECK(is,should) if (unlikely((is) != (should))) \ | 33 | #define MAGIC_CHECK(is,should) if (unlikely((is) != (should))) \ |
| 34 | { printk(KERN_ERR "magic mismatch: %x (expected %x)\n",is,should); BUG(); } | 34 | { printk(KERN_ERR "magic mismatch: %x (expected %x)\n",is,should); BUG(); } |
| 35 | 35 | ||
| 36 | static int debug = 0; | 36 | static int debug; |
| 37 | module_param(debug, int, 0644); | 37 | module_param(debug, int, 0644); |
| 38 | 38 | ||
| 39 | MODULE_DESCRIPTION("helper module to manage video4linux vmalloc buffers"); | 39 | MODULE_DESCRIPTION("helper module to manage video4linux vmalloc buffers"); |
| @@ -57,20 +57,26 @@ videobuf_vm_open(struct vm_area_struct *vma) | |||
| 57 | map->count++; | 57 | map->count++; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | static void | 60 | static void videobuf_vm_close(struct vm_area_struct *vma) |
| 61 | videobuf_vm_close(struct vm_area_struct *vma) | ||
| 62 | { | 61 | { |
| 63 | struct videobuf_mapping *map = vma->vm_private_data; | 62 | struct videobuf_mapping *map = vma->vm_private_data; |
| 64 | struct videobuf_queue *q = map->q; | 63 | struct videobuf_queue *q = map->q; |
| 65 | int i; | 64 | int i; |
| 66 | 65 | ||
| 67 | dprintk(2,"vm_close %p [count=%u,vma=%08lx-%08lx]\n",map, | 66 | dprintk(2,"vm_close %p [count=%u,vma=%08lx-%08lx]\n", map, |
| 68 | map->count,vma->vm_start,vma->vm_end); | 67 | map->count, vma->vm_start, vma->vm_end); |
| 69 | 68 | ||
| 70 | map->count--; | 69 | map->count--; |
| 71 | if (0 == map->count) { | 70 | if (0 == map->count) { |
| 72 | dprintk(1,"munmap %p q=%p\n",map,q); | 71 | struct videobuf_vmalloc_memory *mem; |
| 72 | |||
| 73 | dprintk(1, "munmap %p q=%p\n", map, q); | ||
| 73 | mutex_lock(&q->vb_lock); | 74 | mutex_lock(&q->vb_lock); |
| 75 | |||
| 76 | /* We need first to cancel streams, before unmapping */ | ||
| 77 | if (q->streaming) | ||
| 78 | videobuf_queue_cancel(q); | ||
| 79 | |||
| 74 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { | 80 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| 75 | if (NULL == q->bufs[i]) | 81 | if (NULL == q->bufs[i]) |
| 76 | continue; | 82 | continue; |
| @@ -78,14 +84,35 @@ videobuf_vm_close(struct vm_area_struct *vma) | |||
| 78 | if (q->bufs[i]->map != map) | 84 | if (q->bufs[i]->map != map) |
| 79 | continue; | 85 | continue; |
| 80 | 86 | ||
| 81 | q->ops->buf_release(q,q->bufs[i]); | 87 | mem = q->bufs[i]->priv; |
| 88 | if (mem) { | ||
| 89 | /* This callback is called only if kernel has | ||
| 90 | allocated memory and this memory is mmapped. | ||
| 91 | In this case, memory should be freed, | ||
| 92 | in order to do memory unmap. | ||
| 93 | */ | ||
| 94 | |||
| 95 | MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); | ||
| 96 | |||
| 97 | /* vfree is not atomic - can't be | ||
| 98 | called with IRQ's disabled | ||
| 99 | */ | ||
| 100 | dprintk(1, "%s: buf[%d] freeing (%p)\n", | ||
| 101 | __func__, i, mem->vmalloc); | ||
| 102 | |||
| 103 | vfree(mem->vmalloc); | ||
| 104 | mem->vmalloc = NULL; | ||
| 105 | } | ||
| 82 | 106 | ||
| 83 | q->bufs[i]->map = NULL; | 107 | q->bufs[i]->map = NULL; |
| 84 | q->bufs[i]->baddr = 0; | 108 | q->bufs[i]->baddr = 0; |
| 85 | } | 109 | } |
| 86 | mutex_unlock(&q->vb_lock); | 110 | |
| 87 | kfree(map); | 111 | kfree(map); |
| 112 | |||
| 113 | mutex_unlock(&q->vb_lock); | ||
| 88 | } | 114 | } |
| 115 | |||
| 89 | return; | 116 | return; |
| 90 | } | 117 | } |
| 91 | 118 | ||
| @@ -102,7 +129,7 @@ static struct vm_operations_struct videobuf_vm_ops = | |||
| 102 | /* Allocated area consists on 3 parts: | 129 | /* Allocated area consists on 3 parts: |
| 103 | struct video_buffer | 130 | struct video_buffer |
| 104 | struct <driver>_buffer (cx88_buffer, saa7134_buf, ...) | 131 | struct <driver>_buffer (cx88_buffer, saa7134_buf, ...) |
| 105 | struct videobuf_pci_sg_memory | 132 | struct videobuf_dma_sg_memory |
| 106 | */ | 133 | */ |
| 107 | 134 | ||
| 108 | static void *__videobuf_alloc(size_t size) | 135 | static void *__videobuf_alloc(size_t size) |
| @@ -116,7 +143,7 @@ static void *__videobuf_alloc(size_t size) | |||
| 116 | mem->magic=MAGIC_VMAL_MEM; | 143 | mem->magic=MAGIC_VMAL_MEM; |
| 117 | 144 | ||
| 118 | dprintk(1,"%s: allocated at %p(%ld+%ld) & %p(%ld)\n", | 145 | dprintk(1,"%s: allocated at %p(%ld+%ld) & %p(%ld)\n", |
| 119 | __FUNCTION__,vb,(long)sizeof(*vb),(long)size-sizeof(*vb), | 146 | __func__,vb,(long)sizeof(*vb),(long)size-sizeof(*vb), |
| 120 | mem,(long)sizeof(*mem)); | 147 | mem,(long)sizeof(*mem)); |
| 121 | 148 | ||
| 122 | return vb; | 149 | return vb; |
| @@ -126,45 +153,74 @@ static int __videobuf_iolock (struct videobuf_queue* q, | |||
| 126 | struct videobuf_buffer *vb, | 153 | struct videobuf_buffer *vb, |
| 127 | struct v4l2_framebuffer *fbuf) | 154 | struct v4l2_framebuffer *fbuf) |
| 128 | { | 155 | { |
| 156 | struct videobuf_vmalloc_memory *mem = vb->priv; | ||
| 129 | int pages; | 157 | int pages; |
| 130 | struct videobuf_vmalloc_memory *mem=vb->priv; | ||
| 131 | 158 | ||
| 132 | BUG_ON(!mem); | 159 | BUG_ON(!mem); |
| 133 | 160 | ||
| 134 | MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); | 161 | MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); |
| 135 | 162 | ||
| 136 | pages = PAGE_ALIGN(vb->size) >> PAGE_SHIFT; | 163 | switch (vb->memory) { |
| 164 | case V4L2_MEMORY_MMAP: | ||
| 165 | dprintk(1, "%s memory method MMAP\n", __func__); | ||
| 137 | 166 | ||
| 138 | /* Currently, doesn't support V4L2_MEMORY_OVERLAY */ | 167 | /* All handling should be done by __videobuf_mmap_mapper() */ |
| 139 | if ((vb->memory != V4L2_MEMORY_MMAP) && | 168 | if (!mem->vmalloc) { |
| 140 | (vb->memory != V4L2_MEMORY_USERPTR) ) { | 169 | printk(KERN_ERR "memory is not alloced/mmapped.\n"); |
| 141 | printk(KERN_ERR "Method currently unsupported.\n"); | 170 | return -EINVAL; |
| 142 | return -EINVAL; | 171 | } |
| 143 | } | 172 | break; |
| 173 | case V4L2_MEMORY_USERPTR: | ||
| 174 | pages = PAGE_ALIGN(vb->size); | ||
| 144 | 175 | ||
| 145 | /* FIXME: should be tested with kernel mmap mem */ | 176 | dprintk(1, "%s memory method USERPTR\n", __func__); |
| 146 | mem->vmalloc=vmalloc_user (PAGE_ALIGN(vb->size)); | ||
| 147 | if (NULL == mem->vmalloc) { | ||
| 148 | printk(KERN_ERR "vmalloc (%d pages) failed\n",pages); | ||
| 149 | return -ENOMEM; | ||
| 150 | } | ||
| 151 | 177 | ||
| 152 | dprintk(1,"vmalloc is at addr 0x%08lx, size=%d\n", | 178 | #if 1 |
| 153 | (unsigned long)mem->vmalloc, | 179 | if (vb->baddr) { |
| 154 | pages << PAGE_SHIFT); | 180 | printk(KERN_ERR "USERPTR is currently not supported\n"); |
| 181 | return -EINVAL; | ||
| 182 | } | ||
| 183 | #endif | ||
| 155 | 184 | ||
| 156 | /* It seems that some kernel versions need to do remap *after* | 185 | /* The only USERPTR currently supported is the one needed for |
| 157 | the mmap() call | 186 | read() method. |
| 158 | */ | 187 | */ |
| 159 | if (mem->vma) { | 188 | |
| 160 | int retval=remap_vmalloc_range(mem->vma, mem->vmalloc,0); | 189 | mem->vmalloc = vmalloc_user(pages); |
| 161 | kfree(mem->vma); | 190 | if (!mem->vmalloc) { |
| 162 | mem->vma=NULL; | 191 | printk(KERN_ERR "vmalloc (%d pages) failed\n", pages); |
| 163 | if (retval<0) { | 192 | return -ENOMEM; |
| 164 | dprintk(1,"mmap app bug: remap_vmalloc_range area %p error %d\n", | 193 | } |
| 165 | mem->vmalloc,retval); | 194 | dprintk(1, "vmalloc is at addr %p (%d pages)\n", |
| 166 | return retval; | 195 | mem->vmalloc, pages); |
| 196 | |||
| 197 | #if 0 | ||
| 198 | int rc; | ||
| 199 | /* Kernel userptr is used also by read() method. In this case, | ||
| 200 | there's no need to remap, since data will be copied to user | ||
| 201 | */ | ||
| 202 | if (!vb->baddr) | ||
| 203 | return 0; | ||
| 204 | |||
| 205 | /* FIXME: to properly support USERPTR, remap should occur. | ||
| 206 | The code bellow won't work, since mem->vma = NULL | ||
| 207 | */ | ||
| 208 | /* Try to remap memory */ | ||
| 209 | rc = remap_vmalloc_range(mem->vma, (void *)vb->baddr, 0); | ||
| 210 | if (rc < 0) { | ||
| 211 | printk(KERN_ERR "mmap: remap failed with error %d. ", rc); | ||
| 212 | return -ENOMEM; | ||
| 167 | } | 213 | } |
| 214 | #endif | ||
| 215 | |||
| 216 | break; | ||
| 217 | case V4L2_MEMORY_OVERLAY: | ||
| 218 | default: | ||
| 219 | dprintk(1, "%s memory method OVERLAY/unknown\n", __func__); | ||
| 220 | |||
| 221 | /* Currently, doesn't support V4L2_MEMORY_OVERLAY */ | ||
| 222 | printk(KERN_ERR "Memory method currently unsupported.\n"); | ||
| 223 | return -EINVAL; | ||
| 168 | } | 224 | } |
| 169 | 225 | ||
| 170 | return 0; | 226 | return 0; |
| @@ -180,6 +236,7 @@ static int __videobuf_mmap_free(struct videobuf_queue *q) | |||
| 180 | { | 236 | { |
| 181 | unsigned int i; | 237 | unsigned int i; |
| 182 | 238 | ||
| 239 | dprintk(1, "%s\n", __func__); | ||
| 183 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { | 240 | for (i = 0; i < VIDEO_MAX_FRAME; i++) { |
| 184 | if (q->bufs[i]) { | 241 | if (q->bufs[i]) { |
| 185 | if (q->bufs[i]->map) | 242 | if (q->bufs[i]->map) |
| @@ -196,10 +253,11 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, | |||
| 196 | struct videobuf_vmalloc_memory *mem; | 253 | struct videobuf_vmalloc_memory *mem; |
| 197 | struct videobuf_mapping *map; | 254 | struct videobuf_mapping *map; |
| 198 | unsigned int first; | 255 | unsigned int first; |
| 199 | int retval; | 256 | int retval, pages; |
| 200 | unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; | 257 | unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; |
| 201 | 258 | ||
| 202 | if (! (vma->vm_flags & VM_WRITE) || ! (vma->vm_flags & VM_SHARED)) | 259 | dprintk(1, "%s\n", __func__); |
| 260 | if (!(vma->vm_flags & VM_WRITE) || !(vma->vm_flags & VM_SHARED)) | ||
| 203 | return -EINVAL; | 261 | return -EINVAL; |
| 204 | 262 | ||
| 205 | /* look for first buffer to map */ | 263 | /* look for first buffer to map */ |
| @@ -219,46 +277,55 @@ static int __videobuf_mmap_mapper(struct videobuf_queue *q, | |||
| 219 | } | 277 | } |
| 220 | 278 | ||
| 221 | /* create mapping + update buffer list */ | 279 | /* create mapping + update buffer list */ |
| 222 | map = q->bufs[first]->map = kzalloc(sizeof(struct videobuf_mapping),GFP_KERNEL); | 280 | map = kzalloc(sizeof(struct videobuf_mapping), GFP_KERNEL); |
| 223 | if (NULL == map) | 281 | if (NULL == map) |
| 224 | return -ENOMEM; | 282 | return -ENOMEM; |
| 225 | 283 | ||
| 284 | q->bufs[first]->map = map; | ||
| 226 | map->start = vma->vm_start; | 285 | map->start = vma->vm_start; |
| 227 | map->end = vma->vm_end; | 286 | map->end = vma->vm_end; |
| 228 | map->q = q; | 287 | map->q = q; |
| 229 | 288 | ||
| 230 | q->bufs[first]->baddr = vma->vm_start; | 289 | q->bufs[first]->baddr = vma->vm_start; |
| 231 | 290 | ||
| 232 | vma->vm_ops = &videobuf_vm_ops; | 291 | mem = q->bufs[first]->priv; |
| 233 | vma->vm_flags |= VM_DONTEXPAND | VM_RESERVED; | 292 | BUG_ON(!mem); |
| 234 | vma->vm_private_data = map; | 293 | MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); |
| 235 | 294 | ||
| 236 | mem=q->bufs[first]->priv; | 295 | pages = PAGE_ALIGN(vma->vm_end - vma->vm_start); |
| 237 | BUG_ON (!mem); | 296 | mem->vmalloc = vmalloc_user(pages); |
| 238 | MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); | 297 | if (!mem->vmalloc) { |
| 298 | printk(KERN_ERR "vmalloc (%d pages) failed\n", pages); | ||
| 299 | goto error; | ||
| 300 | } | ||
| 301 | dprintk(1, "vmalloc is at addr %p (%d pages)\n", | ||
| 302 | mem->vmalloc, pages); | ||
| 239 | 303 | ||
| 240 | /* Try to remap memory */ | 304 | /* Try to remap memory */ |
| 241 | retval=remap_vmalloc_range(vma, mem->vmalloc,0); | 305 | retval = remap_vmalloc_range(vma, mem->vmalloc, 0); |
| 242 | if (retval<0) { | 306 | if (retval < 0) { |
| 243 | dprintk(1,"mmap: postponing remap_vmalloc_range\n"); | 307 | printk(KERN_ERR "mmap: remap failed with error %d. ", retval); |
| 244 | 308 | vfree(mem->vmalloc); | |
| 245 | mem->vma=kmalloc(sizeof(*vma),GFP_KERNEL); | 309 | goto error; |
| 246 | if (!mem->vma) { | ||
| 247 | kfree(map); | ||
| 248 | q->bufs[first]->map=NULL; | ||
| 249 | return -ENOMEM; | ||
| 250 | } | ||
| 251 | memcpy(mem->vma,vma,sizeof(*vma)); | ||
| 252 | } | 310 | } |
| 253 | 311 | ||
| 312 | vma->vm_ops = &videobuf_vm_ops; | ||
| 313 | vma->vm_flags |= VM_DONTEXPAND | VM_RESERVED; | ||
| 314 | vma->vm_private_data = map; | ||
| 315 | |||
| 254 | dprintk(1,"mmap %p: q=%p %08lx-%08lx (%lx) pgoff %08lx buf %d\n", | 316 | dprintk(1,"mmap %p: q=%p %08lx-%08lx (%lx) pgoff %08lx buf %d\n", |
| 255 | map,q,vma->vm_start,vma->vm_end, | 317 | map, q, vma->vm_start, vma->vm_end, |
| 256 | (long int) q->bufs[first]->bsize, | 318 | (long int) q->bufs[first]->bsize, |
| 257 | vma->vm_pgoff,first); | 319 | vma->vm_pgoff, first); |
| 258 | 320 | ||
| 259 | videobuf_vm_open(vma); | 321 | videobuf_vm_open(vma); |
| 260 | 322 | ||
| 261 | return (0); | 323 | return 0; |
| 324 | |||
| 325 | error: | ||
| 326 | mem = NULL; | ||
| 327 | kfree(map); | ||
| 328 | return -ENOMEM; | ||
| 262 | } | 329 | } |
| 263 | 330 | ||
| 264 | static int __videobuf_copy_to_user ( struct videobuf_queue *q, | 331 | static int __videobuf_copy_to_user ( struct videobuf_queue *q, |
| @@ -320,6 +387,7 @@ static struct videobuf_qtype_ops qops = { | |||
| 320 | .mmap_mapper = __videobuf_mmap_mapper, | 387 | .mmap_mapper = __videobuf_mmap_mapper, |
| 321 | .video_copy_to_user = __videobuf_copy_to_user, | 388 | .video_copy_to_user = __videobuf_copy_to_user, |
| 322 | .copy_stream = __videobuf_copy_stream, | 389 | .copy_stream = __videobuf_copy_stream, |
| 390 | .vmalloc = videobuf_to_vmalloc, | ||
| 323 | }; | 391 | }; |
| 324 | 392 | ||
| 325 | void videobuf_queue_vmalloc_init(struct videobuf_queue* q, | 393 | void videobuf_queue_vmalloc_init(struct videobuf_queue* q, |
| @@ -349,13 +417,24 @@ EXPORT_SYMBOL_GPL(videobuf_to_vmalloc); | |||
| 349 | 417 | ||
| 350 | void videobuf_vmalloc_free (struct videobuf_buffer *buf) | 418 | void videobuf_vmalloc_free (struct videobuf_buffer *buf) |
| 351 | { | 419 | { |
| 352 | struct videobuf_vmalloc_memory *mem=buf->priv; | 420 | struct videobuf_vmalloc_memory *mem = buf->priv; |
| 353 | BUG_ON (!mem); | ||
| 354 | 421 | ||
| 355 | MAGIC_CHECK(mem->magic,MAGIC_VMAL_MEM); | 422 | /* mmapped memory can't be freed here, otherwise mmapped region |
| 423 | would be released, while still needed. In this case, the memory | ||
| 424 | release should happen inside videobuf_vm_close(). | ||
| 425 | So, it should free memory only if the memory were allocated for | ||
| 426 | read() operation. | ||
| 427 | */ | ||
| 428 | if ((buf->memory != V4L2_MEMORY_USERPTR) || (buf->baddr == 0)) | ||
| 429 | return; | ||
| 430 | |||
| 431 | if (!mem) | ||
| 432 | return; | ||
| 433 | |||
| 434 | MAGIC_CHECK(mem->magic, MAGIC_VMAL_MEM); | ||
| 356 | 435 | ||
| 357 | vfree(mem->vmalloc); | 436 | vfree(mem->vmalloc); |
| 358 | mem->vmalloc=NULL; | 437 | mem->vmalloc = NULL; |
| 359 | 438 | ||
| 360 | return; | 439 | return; |
| 361 | } | 440 | } |
diff --git a/drivers/media/video/videocodec.c b/drivers/media/video/videocodec.c index 87951ec8254f..cf24956f3204 100644 --- a/drivers/media/video/videocodec.c +++ b/drivers/media/video/videocodec.c | |||
| @@ -39,12 +39,13 @@ | |||
| 39 | 39 | ||
| 40 | #ifdef CONFIG_PROC_FS | 40 | #ifdef CONFIG_PROC_FS |
| 41 | #include <linux/proc_fs.h> | 41 | #include <linux/proc_fs.h> |
| 42 | #include <linux/seq_file.h> | ||
| 42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
| 43 | #endif | 44 | #endif |
| 44 | 45 | ||
| 45 | #include "videocodec.h" | 46 | #include "videocodec.h" |
| 46 | 47 | ||
| 47 | static int debug = 0; | 48 | static int debug; |
| 48 | module_param(debug, int, 0); | 49 | module_param(debug, int, 0); |
| 49 | MODULE_PARM_DESC(debug, "Debug level (0-4)"); | 50 | MODULE_PARM_DESC(debug, "Debug level (0-4)"); |
| 50 | 51 | ||
| @@ -320,56 +321,22 @@ videocodec_unregister (const struct videocodec *codec) | |||
| 320 | } | 321 | } |
| 321 | 322 | ||
| 322 | #ifdef CONFIG_PROC_FS | 323 | #ifdef CONFIG_PROC_FS |
| 323 | /* ============ */ | 324 | static int proc_videocodecs_show(struct seq_file *m, void *v) |
| 324 | /* procfs stuff */ | ||
| 325 | /* ============ */ | ||
| 326 | |||
| 327 | static char *videocodec_buf = NULL; | ||
| 328 | static int videocodec_bufsize = 0; | ||
| 329 | |||
| 330 | static int | ||
| 331 | videocodec_build_table (void) | ||
| 332 | { | 325 | { |
| 333 | struct codec_list *h = codeclist_top; | 326 | struct codec_list *h = codeclist_top; |
| 334 | struct attached_list *a; | 327 | struct attached_list *a; |
| 335 | int i = 0, size; | ||
| 336 | |||
| 337 | // sum up amount of slaves plus their attached masters | ||
| 338 | while (h) { | ||
| 339 | i += h->attached + 1; | ||
| 340 | h = h->next; | ||
| 341 | } | ||
| 342 | #define LINESIZE 100 | ||
| 343 | size = LINESIZE * (i + 1); | ||
| 344 | 328 | ||
| 345 | dprintk(3, "videocodec_build table: %d entries, %d bytes\n", i, | 329 | seq_printf(m, "<S>lave or attached <M>aster name type flags magic "); |
| 346 | size); | 330 | seq_printf(m, "(connected as)\n"); |
| 347 | |||
| 348 | kfree(videocodec_buf); | ||
| 349 | videocodec_buf = kmalloc(size, GFP_KERNEL); | ||
| 350 | |||
| 351 | if (!videocodec_buf) | ||
| 352 | return 0; | ||
| 353 | |||
| 354 | i = 0; | ||
| 355 | i += scnprintf(videocodec_buf + i, size - 1, | ||
| 356 | "<S>lave or attached <M>aster name type flags magic "); | ||
| 357 | i += scnprintf(videocodec_buf + i, size -i - 1, "(connected as)\n"); | ||
| 358 | 331 | ||
| 359 | h = codeclist_top; | 332 | h = codeclist_top; |
| 360 | while (h) { | 333 | while (h) { |
| 361 | if (i > (size - LINESIZE)) | 334 | seq_printf(m, "S %32s %04x %08lx %08lx (TEMPLATE)\n", |
| 362 | break; // security check | ||
| 363 | i += scnprintf(videocodec_buf + i, size -i -1, | ||
| 364 | "S %32s %04x %08lx %08lx (TEMPLATE)\n", | ||
| 365 | h->codec->name, h->codec->type, | 335 | h->codec->name, h->codec->type, |
| 366 | h->codec->flags, h->codec->magic); | 336 | h->codec->flags, h->codec->magic); |
| 367 | a = h->list; | 337 | a = h->list; |
| 368 | while (a) { | 338 | while (a) { |
| 369 | if (i > (size - LINESIZE)) | 339 | seq_printf(m, "M %32s %04x %08lx %08lx (%s)\n", |
| 370 | break; // security check | ||
| 371 | i += scnprintf(videocodec_buf + i, size -i -1, | ||
| 372 | "M %32s %04x %08lx %08lx (%s)\n", | ||
| 373 | a->codec->master_data->name, | 340 | a->codec->master_data->name, |
| 374 | a->codec->master_data->type, | 341 | a->codec->master_data->type, |
| 375 | a->codec->master_data->flags, | 342 | a->codec->master_data->flags, |
| @@ -380,54 +347,21 @@ videocodec_build_table (void) | |||
| 380 | h = h->next; | 347 | h = h->next; |
| 381 | } | 348 | } |
| 382 | 349 | ||
| 383 | return i; | 350 | return 0; |
| 384 | } | 351 | } |
| 385 | 352 | ||
| 386 | //The definition: | 353 | static int proc_videocodecs_open(struct inode *inode, struct file *file) |
| 387 | //typedef int (read_proc_t)(char *page, char **start, off_t off, | ||
| 388 | // int count, int *eof, void *data); | ||
| 389 | |||
| 390 | static int | ||
| 391 | videocodec_info (char *buffer, | ||
| 392 | char **buffer_location, | ||
| 393 | off_t offset, | ||
| 394 | int buffer_length, | ||
| 395 | int *eof, | ||
| 396 | void *data) | ||
| 397 | { | 354 | { |
| 398 | int size; | 355 | return single_open(file, proc_videocodecs_show, NULL); |
| 399 | |||
| 400 | dprintk(3, "videocodec_info: offset: %ld, len %d / size %d\n", | ||
| 401 | offset, buffer_length, videocodec_bufsize); | ||
| 402 | |||
| 403 | if (offset == 0) { | ||
| 404 | videocodec_bufsize = videocodec_build_table(); | ||
| 405 | } | ||
| 406 | if ((offset < 0) || (offset >= videocodec_bufsize)) { | ||
| 407 | dprintk(4, | ||
| 408 | "videocodec_info: call delivers no result, return 0\n"); | ||
| 409 | *eof = 1; | ||
| 410 | return 0; | ||
| 411 | } | ||
| 412 | |||
| 413 | if (buffer_length < (videocodec_bufsize - offset)) { | ||
| 414 | dprintk(4, "videocodec_info: %ld needed, %d got\n", | ||
| 415 | videocodec_bufsize - offset, buffer_length); | ||
| 416 | size = buffer_length; | ||
| 417 | } else { | ||
| 418 | dprintk(4, "videocodec_info: last reading of %ld bytes\n", | ||
| 419 | videocodec_bufsize - offset); | ||
| 420 | size = videocodec_bufsize - offset; | ||
| 421 | *eof = 1; | ||
| 422 | } | ||
| 423 | |||
| 424 | memcpy(buffer, videocodec_buf + offset, size); | ||
| 425 | /* doesn't work... */ | ||
| 426 | /* copy_to_user(buffer, videocodec_buf+offset, size); */ | ||
| 427 | /* *buffer_location = videocodec_buf+offset; */ | ||
| 428 | |||
| 429 | return size; | ||
| 430 | } | 356 | } |
| 357 | |||
| 358 | static const struct file_operations videocodecs_proc_fops = { | ||
| 359 | .owner = THIS_MODULE, | ||
| 360 | .open = proc_videocodecs_open, | ||
| 361 | .read = seq_read, | ||
| 362 | .llseek = seq_lseek, | ||
| 363 | .release = single_release, | ||
| 364 | }; | ||
| 431 | #endif | 365 | #endif |
| 432 | 366 | ||
| 433 | /* ===================== */ | 367 | /* ===================== */ |
| @@ -444,16 +378,8 @@ videocodec_init (void) | |||
| 444 | VIDEOCODEC_VERSION); | 378 | VIDEOCODEC_VERSION); |
| 445 | 379 | ||
| 446 | #ifdef CONFIG_PROC_FS | 380 | #ifdef CONFIG_PROC_FS |
| 447 | videocodec_buf = NULL; | 381 | videocodec_proc_entry = proc_create("videocodecs", 0, NULL, &videocodecs_proc_fops); |
| 448 | videocodec_bufsize = 0; | 382 | if (!videocodec_proc_entry) { |
| 449 | |||
| 450 | videocodec_proc_entry = create_proc_entry("videocodecs", 0, NULL); | ||
| 451 | if (videocodec_proc_entry) { | ||
| 452 | videocodec_proc_entry->read_proc = videocodec_info; | ||
| 453 | videocodec_proc_entry->write_proc = NULL; | ||
| 454 | videocodec_proc_entry->data = NULL; | ||
| 455 | videocodec_proc_entry->owner = THIS_MODULE; | ||
| 456 | } else { | ||
| 457 | dprintk(1, KERN_ERR "videocodec: can't init procfs.\n"); | 383 | dprintk(1, KERN_ERR "videocodec: can't init procfs.\n"); |
| 458 | } | 384 | } |
| 459 | #endif | 385 | #endif |
| @@ -465,7 +391,6 @@ videocodec_exit (void) | |||
| 465 | { | 391 | { |
| 466 | #ifdef CONFIG_PROC_FS | 392 | #ifdef CONFIG_PROC_FS |
| 467 | remove_proc_entry("videocodecs", NULL); | 393 | remove_proc_entry("videocodecs", NULL); |
| 468 | kfree(videocodec_buf); | ||
| 469 | #endif | 394 | #endif |
| 470 | } | 395 | } |
| 471 | 396 | ||
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 0d9b63762a48..31e8af0ba278 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
| @@ -18,14 +18,14 @@ | |||
| 18 | 18 | ||
| 19 | #define dbgarg(cmd, fmt, arg...) \ | 19 | #define dbgarg(cmd, fmt, arg...) \ |
| 20 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \ | 20 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { \ |
| 21 | printk (KERN_DEBUG "%s: ", vfd->name); \ | 21 | printk(KERN_DEBUG "%s: ", vfd->name); \ |
| 22 | v4l_printk_ioctl(cmd); \ | 22 | v4l_printk_ioctl(cmd); \ |
| 23 | printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg); \ | 23 | printk(" " fmt, ## arg); \ |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | #define dbgarg2(fmt, arg...) \ | 26 | #define dbgarg2(fmt, arg...) \ |
| 27 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ | 27 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) \ |
| 28 | printk (KERN_DEBUG "%s: " fmt, vfd->name, ## arg); | 28 | printk(KERN_DEBUG "%s: " fmt, vfd->name, ## arg); |
| 29 | 29 | ||
| 30 | #include <linux/module.h> | 30 | #include <linux/module.h> |
| 31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
| @@ -378,38 +378,45 @@ static const char *v4l2_int_ioctls[] = { | |||
| 378 | external ioctl messages as well as internal V4L ioctl */ | 378 | external ioctl messages as well as internal V4L ioctl */ |
| 379 | void v4l_printk_ioctl(unsigned int cmd) | 379 | void v4l_printk_ioctl(unsigned int cmd) |
| 380 | { | 380 | { |
| 381 | char *dir; | 381 | char *dir, *type; |
| 382 | 382 | ||
| 383 | switch (_IOC_DIR(cmd)) { | ||
| 384 | case _IOC_NONE: dir = "--"; break; | ||
| 385 | case _IOC_READ: dir = "r-"; break; | ||
| 386 | case _IOC_WRITE: dir = "-w"; break; | ||
| 387 | case _IOC_READ | _IOC_WRITE: dir = "rw"; break; | ||
| 388 | default: dir = "*ERR*"; break; | ||
| 389 | } | ||
| 390 | switch (_IOC_TYPE(cmd)) { | 383 | switch (_IOC_TYPE(cmd)) { |
| 391 | case 'd': | 384 | case 'd': |
| 392 | printk("v4l2_int ioctl %s, dir=%s (0x%08x)\n", | 385 | if (_IOC_NR(cmd) >= V4L2_INT_IOCTLS) { |
| 393 | (_IOC_NR(cmd) < V4L2_INT_IOCTLS) ? | 386 | type = "v4l2_int"; |
| 394 | v4l2_int_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); | 387 | break; |
| 395 | break; | 388 | } |
| 389 | printk("%s", v4l2_int_ioctls[_IOC_NR(cmd)]); | ||
| 390 | return; | ||
| 396 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | 391 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
| 397 | case 'v': | 392 | case 'v': |
| 398 | printk("v4l1 ioctl %s, dir=%s (0x%08x)\n", | 393 | if (_IOC_NR(cmd) >= V4L1_IOCTLS) { |
| 399 | (_IOC_NR(cmd) < V4L1_IOCTLS) ? | 394 | type = "v4l1"; |
| 400 | v4l1_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); | 395 | break; |
| 401 | break; | 396 | } |
| 397 | printk("%s", v4l1_ioctls[_IOC_NR(cmd)]); | ||
| 398 | return; | ||
| 402 | #endif | 399 | #endif |
| 403 | case 'V': | 400 | case 'V': |
| 404 | printk("v4l2 ioctl %s, dir=%s (0x%08x)\n", | 401 | if (_IOC_NR(cmd) >= V4L2_IOCTLS) { |
| 405 | (_IOC_NR(cmd) < V4L2_IOCTLS) ? | 402 | type = "v4l2"; |
| 406 | v4l2_ioctls[_IOC_NR(cmd)] : "UNKNOWN", dir, cmd); | 403 | break; |
| 407 | break; | 404 | } |
| 408 | 405 | printk("%s", v4l2_ioctls[_IOC_NR(cmd)]); | |
| 406 | return; | ||
| 409 | default: | 407 | default: |
| 410 | printk("unknown ioctl '%c', dir=%s, #%d (0x%08x)\n", | 408 | type = "unknown"; |
| 411 | _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd); | 409 | } |
| 410 | |||
| 411 | switch (_IOC_DIR(cmd)) { | ||
| 412 | case _IOC_NONE: dir = "--"; break; | ||
| 413 | case _IOC_READ: dir = "r-"; break; | ||
| 414 | case _IOC_WRITE: dir = "-w"; break; | ||
| 415 | case _IOC_READ | _IOC_WRITE: dir = "rw"; break; | ||
| 416 | default: dir = "*ERR*"; break; | ||
| 412 | } | 417 | } |
| 418 | printk("%s ioctl '%c', dir=%s, #%d (0x%08x)", | ||
| 419 | type, _IOC_TYPE(cmd), dir, _IOC_NR(cmd), cmd); | ||
| 413 | } | 420 | } |
| 414 | EXPORT_SYMBOL(v4l_printk_ioctl); | 421 | EXPORT_SYMBOL(v4l_printk_ioctl); |
| 415 | 422 | ||
| @@ -774,6 +781,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
| 774 | if ( (vfd->debug & V4L2_DEBUG_IOCTL) && | 781 | if ( (vfd->debug & V4L2_DEBUG_IOCTL) && |
| 775 | !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { | 782 | !(vfd->debug & V4L2_DEBUG_IOCTL_ARG)) { |
| 776 | v4l_print_ioctl(vfd->name, cmd); | 783 | v4l_print_ioctl(vfd->name, cmd); |
| 784 | printk("\n"); | ||
| 777 | } | 785 | } |
| 778 | 786 | ||
| 779 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | 787 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
| @@ -1853,12 +1861,20 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
| 1853 | dbgarg (cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision); | 1861 | dbgarg (cmd, "chip_ident=%u, revision=0x%x\n", p->ident, p->revision); |
| 1854 | break; | 1862 | break; |
| 1855 | } | 1863 | } |
| 1864 | default: | ||
| 1865 | { | ||
| 1866 | if (!vfd->vidioc_default) | ||
| 1867 | break; | ||
| 1868 | ret = vfd->vidioc_default(file, fh, cmd, arg); | ||
| 1869 | break; | ||
| 1870 | } | ||
| 1856 | } /* switch */ | 1871 | } /* switch */ |
| 1857 | 1872 | ||
| 1858 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { | 1873 | if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { |
| 1859 | if (ret<0) { | 1874 | if (ret<0) { |
| 1860 | printk ("%s: err:\n", vfd->name); | 1875 | printk("%s: err: on ", vfd->name); |
| 1861 | v4l_print_ioctl(vfd->name, cmd); | 1876 | v4l_print_ioctl(vfd->name, cmd); |
| 1877 | printk("\n"); | ||
| 1862 | } | 1878 | } |
| 1863 | } | 1879 | } |
| 1864 | 1880 | ||
| @@ -2019,7 +2035,7 @@ int video_register_device(struct video_device *vfd, int type, int nr) | |||
| 2019 | break; | 2035 | break; |
| 2020 | default: | 2036 | default: |
| 2021 | printk(KERN_ERR "%s called with unknown type: %d\n", | 2037 | printk(KERN_ERR "%s called with unknown type: %d\n", |
| 2022 | __FUNCTION__, type); | 2038 | __func__, type); |
| 2023 | return -1; | 2039 | return -1; |
| 2024 | } | 2040 | } |
| 2025 | 2041 | ||
| @@ -2057,7 +2073,7 @@ int video_register_device(struct video_device *vfd, int type, int nr) | |||
| 2057 | ret = device_register(&vfd->class_dev); | 2073 | ret = device_register(&vfd->class_dev); |
| 2058 | if (ret < 0) { | 2074 | if (ret < 0) { |
| 2059 | printk(KERN_ERR "%s: device_register failed\n", | 2075 | printk(KERN_ERR "%s: device_register failed\n", |
| 2060 | __FUNCTION__); | 2076 | __func__); |
| 2061 | goto fail_minor; | 2077 | goto fail_minor; |
| 2062 | } | 2078 | } |
| 2063 | 2079 | ||
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c index 5bb75294b5aa..d545c98dd5e7 100644 --- a/drivers/media/video/vino.c +++ b/drivers/media/video/vino.c | |||
| @@ -333,7 +333,7 @@ struct vino_settings { | |||
| 333 | * | 333 | * |
| 334 | * Use non-zero value to enable conversion. | 334 | * Use non-zero value to enable conversion. |
| 335 | */ | 335 | */ |
| 336 | static int vino_pixel_conversion = 0; | 336 | static int vino_pixel_conversion; |
| 337 | 337 | ||
| 338 | module_param_named(pixelconv, vino_pixel_conversion, int, 0); | 338 | module_param_named(pixelconv, vino_pixel_conversion, int, 0); |
| 339 | 339 | ||
| @@ -4370,8 +4370,8 @@ static int vino_ioctl(struct inode *inode, struct file *file, | |||
| 4370 | 4370 | ||
| 4371 | /* Initialization and cleanup */ | 4371 | /* Initialization and cleanup */ |
| 4372 | 4372 | ||
| 4373 | // __initdata | 4373 | /* __initdata */ |
| 4374 | static int vino_init_stage = 0; | 4374 | static int vino_init_stage; |
| 4375 | 4375 | ||
| 4376 | static const struct file_operations vino_fops = { | 4376 | static const struct file_operations vino_fops = { |
| 4377 | .owner = THIS_MODULE, | 4377 | .owner = THIS_MODULE, |
| @@ -4385,8 +4385,8 @@ static const struct file_operations vino_fops = { | |||
| 4385 | 4385 | ||
| 4386 | static struct video_device v4l_device_template = { | 4386 | static struct video_device v4l_device_template = { |
| 4387 | .name = "NOT SET", | 4387 | .name = "NOT SET", |
| 4388 | //.type = VID_TYPE_CAPTURE | VID_TYPE_SUBCAPTURE | | 4388 | /*.type = VID_TYPE_CAPTURE | VID_TYPE_SUBCAPTURE | */ |
| 4389 | // VID_TYPE_CLIPPING | VID_TYPE_SCALES, VID_TYPE_OVERLAY | 4389 | /* VID_TYPE_CLIPPING | VID_TYPE_SCALES, VID_TYPE_OVERLAY */ |
| 4390 | .fops = &vino_fops, | 4390 | .fops = &vino_fops, |
| 4391 | .minor = -1, | 4391 | .minor = -1, |
| 4392 | }; | 4392 | }; |
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 1db067c02815..b1e9592acb90 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
| @@ -146,8 +146,6 @@ struct vivi_buffer { | |||
| 146 | 146 | ||
| 147 | struct vivi_dmaqueue { | 147 | struct vivi_dmaqueue { |
| 148 | struct list_head active; | 148 | struct list_head active; |
| 149 | struct list_head queued; | ||
| 150 | struct timer_list timeout; | ||
| 151 | 149 | ||
| 152 | /* thread for generating video stream*/ | 150 | /* thread for generating video stream*/ |
| 153 | struct task_struct *kthread; | 151 | struct task_struct *kthread; |
| @@ -162,8 +160,8 @@ static LIST_HEAD(vivi_devlist); | |||
| 162 | struct vivi_dev { | 160 | struct vivi_dev { |
| 163 | struct list_head vivi_devlist; | 161 | struct list_head vivi_devlist; |
| 164 | 162 | ||
| 165 | struct mutex lock; | ||
| 166 | spinlock_t slock; | 163 | spinlock_t slock; |
| 164 | struct mutex mutex; | ||
| 167 | 165 | ||
| 168 | int users; | 166 | int users; |
| 169 | 167 | ||
| @@ -322,24 +320,26 @@ static void gen_line(char *basep, int inipos, int wmax, | |||
| 322 | end: | 320 | end: |
| 323 | return; | 321 | return; |
| 324 | } | 322 | } |
| 323 | |||
| 325 | static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) | 324 | static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) |
| 326 | { | 325 | { |
| 327 | int h , pos = 0; | 326 | int h , pos = 0; |
| 328 | int hmax = buf->vb.height; | 327 | int hmax = buf->vb.height; |
| 329 | int wmax = buf->vb.width; | 328 | int wmax = buf->vb.width; |
| 330 | struct timeval ts; | 329 | struct timeval ts; |
| 331 | char *tmpbuf = kmalloc(wmax * 2, GFP_KERNEL); | 330 | char *tmpbuf = kmalloc(wmax * 2, GFP_ATOMIC); |
| 332 | void *vbuf = videobuf_to_vmalloc(&buf->vb); | 331 | void *vbuf = videobuf_to_vmalloc(&buf->vb); |
| 333 | 332 | ||
| 334 | if (!tmpbuf) | 333 | if (!tmpbuf) |
| 335 | return; | 334 | return; |
| 336 | 335 | ||
| 336 | if (!vbuf) | ||
| 337 | return; | ||
| 338 | |||
| 337 | for (h = 0; h < hmax; h++) { | 339 | for (h = 0; h < hmax; h++) { |
| 338 | gen_line(tmpbuf, 0, wmax, hmax, h, dev->mv_count, | 340 | gen_line(tmpbuf, 0, wmax, hmax, h, dev->mv_count, |
| 339 | dev->timestr); | 341 | dev->timestr); |
| 340 | /* FIXME: replacing to __copy_to_user */ | 342 | memcpy(vbuf + pos, tmpbuf, wmax * 2); |
| 341 | if (copy_to_user(vbuf + pos, tmpbuf, wmax * 2) != 0) | ||
| 342 | dprintk(dev, 2, "vivifill copy_to_user failed.\n"); | ||
| 343 | pos += wmax*2; | 343 | pos += wmax*2; |
| 344 | } | 344 | } |
| 345 | 345 | ||
| @@ -372,107 +372,71 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) | |||
| 372 | dev->timestr, (unsigned long)tmpbuf, pos); | 372 | dev->timestr, (unsigned long)tmpbuf, pos); |
| 373 | 373 | ||
| 374 | /* Advice that buffer was filled */ | 374 | /* Advice that buffer was filled */ |
| 375 | buf->vb.state = VIDEOBUF_DONE; | ||
| 376 | buf->vb.field_count++; | 375 | buf->vb.field_count++; |
| 377 | do_gettimeofday(&ts); | 376 | do_gettimeofday(&ts); |
| 378 | buf->vb.ts = ts; | 377 | buf->vb.ts = ts; |
| 379 | 378 | buf->vb.state = VIDEOBUF_DONE; | |
| 380 | list_del(&buf->vb.queue); | ||
| 381 | wake_up(&buf->vb.done); | ||
| 382 | } | 379 | } |
| 383 | 380 | ||
| 384 | static int restart_video_queue(struct vivi_dmaqueue *dma_q); | 381 | static void vivi_thread_tick(struct vivi_fh *fh) |
| 385 | |||
| 386 | static void vivi_thread_tick(struct vivi_dmaqueue *dma_q) | ||
| 387 | { | 382 | { |
| 388 | struct vivi_buffer *buf; | 383 | struct vivi_buffer *buf; |
| 389 | struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); | 384 | struct vivi_dev *dev = fh->dev; |
| 385 | struct vivi_dmaqueue *dma_q = &dev->vidq; | ||
| 390 | 386 | ||
| 391 | int bc; | 387 | unsigned long flags = 0; |
| 392 | 388 | ||
| 393 | spin_lock(&dev->slock); | 389 | dprintk(dev, 1, "Thread tick\n"); |
| 394 | /* Announces videobuf that all went ok */ | ||
| 395 | for (bc = 0;; bc++) { | ||
| 396 | if (list_empty(&dma_q->active)) { | ||
| 397 | dprintk(dev, 1, "No active queue to serve\n"); | ||
| 398 | break; | ||
| 399 | } | ||
| 400 | 390 | ||
| 401 | buf = list_entry(dma_q->active.next, | 391 | spin_lock_irqsave(&dev->slock, flags); |
| 402 | struct vivi_buffer, vb.queue); | 392 | if (list_empty(&dma_q->active)) { |
| 393 | dprintk(dev, 1, "No active queue to serve\n"); | ||
| 394 | goto unlock; | ||
| 395 | } | ||
| 403 | 396 | ||
| 404 | /* Nobody is waiting something to be done, just return */ | 397 | buf = list_entry(dma_q->active.next, |
| 405 | if (!waitqueue_active(&buf->vb.done)) { | 398 | struct vivi_buffer, vb.queue); |
| 406 | mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT); | 399 | |
| 407 | spin_unlock(&dev->slock); | 400 | /* Nobody is waiting on this buffer, return */ |
| 408 | return; | 401 | if (!waitqueue_active(&buf->vb.done)) |
| 409 | } | 402 | goto unlock; |
| 410 | 403 | ||
| 411 | do_gettimeofday(&buf->vb.ts); | 404 | list_del(&buf->vb.queue); |
| 412 | dprintk(dev, 2, "[%p/%d] wakeup\n", buf, buf->vb. i); | ||
| 413 | 405 | ||
| 414 | /* Fill buffer */ | 406 | do_gettimeofday(&buf->vb.ts); |
| 415 | vivi_fillbuff(dev, buf); | ||
| 416 | 407 | ||
| 417 | if (list_empty(&dma_q->active)) { | 408 | /* Fill buffer */ |
| 418 | del_timer(&dma_q->timeout); | 409 | vivi_fillbuff(dev, buf); |
| 419 | } else { | 410 | dprintk(dev, 1, "filled buffer %p\n", buf); |
| 420 | mod_timer(&dma_q->timeout, jiffies + BUFFER_TIMEOUT); | 411 | |
| 421 | } | 412 | wake_up(&buf->vb.done); |
| 422 | } | 413 | dprintk(dev, 2, "[%p/%d] wakeup\n", buf, buf->vb. i); |
| 423 | if (bc != 1) | 414 | unlock: |
| 424 | dprintk(dev, 1, "%s: %d buffers handled (should be 1)\n", | 415 | spin_unlock_irqrestore(&dev->slock, flags); |
| 425 | __FUNCTION__, bc); | 416 | return; |
| 426 | spin_unlock(&dev->slock); | ||
| 427 | } | 417 | } |
| 428 | 418 | ||
| 429 | #define frames_to_ms(frames) \ | 419 | #define frames_to_ms(frames) \ |
| 430 | ((frames * WAKE_NUMERATOR * 1000) / WAKE_DENOMINATOR) | 420 | ((frames * WAKE_NUMERATOR * 1000) / WAKE_DENOMINATOR) |
| 431 | 421 | ||
| 432 | static void vivi_sleep(struct vivi_dmaqueue *dma_q) | 422 | static void vivi_sleep(struct vivi_fh *fh) |
| 433 | { | 423 | { |
| 434 | struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); | 424 | struct vivi_dev *dev = fh->dev; |
| 435 | int timeout, running_time; | 425 | struct vivi_dmaqueue *dma_q = &dev->vidq; |
| 426 | int timeout; | ||
| 436 | DECLARE_WAITQUEUE(wait, current); | 427 | DECLARE_WAITQUEUE(wait, current); |
| 437 | 428 | ||
| 438 | dprintk(dev, 1, "%s dma_q=0x%08lx\n", __FUNCTION__, | 429 | dprintk(dev, 1, "%s dma_q=0x%08lx\n", __func__, |
| 439 | (unsigned long)dma_q); | 430 | (unsigned long)dma_q); |
| 440 | 431 | ||
| 441 | add_wait_queue(&dma_q->wq, &wait); | 432 | add_wait_queue(&dma_q->wq, &wait); |
| 442 | if (kthread_should_stop()) | 433 | if (kthread_should_stop()) |
| 443 | goto stop_task; | 434 | goto stop_task; |
| 444 | 435 | ||
| 445 | running_time = jiffies - dma_q->ini_jiffies; | ||
| 446 | dma_q->frame++; | ||
| 447 | |||
| 448 | /* Calculate time to wake up */ | 436 | /* Calculate time to wake up */ |
| 449 | timeout = msecs_to_jiffies(frames_to_ms(dma_q->frame)) - running_time; | 437 | timeout = msecs_to_jiffies(frames_to_ms(1)); |
| 450 | |||
| 451 | if (timeout > msecs_to_jiffies(frames_to_ms(2)) || timeout <= 0) { | ||
| 452 | int old = dma_q->frame; | ||
| 453 | int nframes; | ||
| 454 | |||
| 455 | dma_q->frame = (jiffies_to_msecs(running_time) / | ||
| 456 | frames_to_ms(1)) + 1; | ||
| 457 | |||
| 458 | timeout = msecs_to_jiffies(frames_to_ms(dma_q->frame)) | ||
| 459 | - running_time; | ||
| 460 | |||
| 461 | if (unlikely (timeout <= 0)) | ||
| 462 | timeout = 1; | ||
| 463 | |||
| 464 | nframes = (dma_q->frame > old)? | ||
| 465 | dma_q->frame - old : old - dma_q->frame; | ||
| 466 | |||
| 467 | dprintk(dev, 1, "%ld: %s %d frames. " | ||
| 468 | "Current frame is %d. Will sleep for %d jiffies\n", | ||
| 469 | jiffies, | ||
| 470 | (dma_q->frame > old)? "Underrun, losed" : "Overrun of", | ||
| 471 | nframes, dma_q->frame, timeout); | ||
| 472 | } else | ||
| 473 | dprintk(dev, 1, "will sleep for %d jiffies\n", timeout); | ||
| 474 | 438 | ||
| 475 | vivi_thread_tick(dma_q); | 439 | vivi_thread_tick(fh); |
| 476 | 440 | ||
| 477 | schedule_timeout_interruptible(timeout); | 441 | schedule_timeout_interruptible(timeout); |
| 478 | 442 | ||
| @@ -483,16 +447,15 @@ stop_task: | |||
| 483 | 447 | ||
| 484 | static int vivi_thread(void *data) | 448 | static int vivi_thread(void *data) |
| 485 | { | 449 | { |
| 486 | struct vivi_dmaqueue *dma_q = data; | 450 | struct vivi_fh *fh = data; |
| 487 | struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); | 451 | struct vivi_dev *dev = fh->dev; |
| 488 | 452 | ||
| 489 | dprintk(dev, 1, "thread started\n"); | 453 | dprintk(dev, 1, "thread started\n"); |
| 490 | 454 | ||
| 491 | mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT); | ||
| 492 | set_freezable(); | 455 | set_freezable(); |
| 493 | 456 | ||
| 494 | for (;;) { | 457 | for (;;) { |
| 495 | vivi_sleep(dma_q); | 458 | vivi_sleep(fh); |
| 496 | 459 | ||
| 497 | if (kthread_should_stop()) | 460 | if (kthread_should_stop()) |
| 498 | break; | 461 | break; |
| @@ -501,16 +464,17 @@ static int vivi_thread(void *data) | |||
| 501 | return 0; | 464 | return 0; |
| 502 | } | 465 | } |
| 503 | 466 | ||
| 504 | static int vivi_start_thread(struct vivi_dmaqueue *dma_q) | 467 | static int vivi_start_thread(struct vivi_fh *fh) |
| 505 | { | 468 | { |
| 506 | struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); | 469 | struct vivi_dev *dev = fh->dev; |
| 470 | struct vivi_dmaqueue *dma_q = &dev->vidq; | ||
| 507 | 471 | ||
| 508 | dma_q->frame = 0; | 472 | dma_q->frame = 0; |
| 509 | dma_q->ini_jiffies = jiffies; | 473 | dma_q->ini_jiffies = jiffies; |
| 510 | 474 | ||
| 511 | dprintk(dev, 1, "%s\n", __FUNCTION__); | 475 | dprintk(dev, 1, "%s\n", __func__); |
| 512 | 476 | ||
| 513 | dma_q->kthread = kthread_run(vivi_thread, dma_q, "vivi"); | 477 | dma_q->kthread = kthread_run(vivi_thread, fh, "vivi"); |
| 514 | 478 | ||
| 515 | if (IS_ERR(dma_q->kthread)) { | 479 | if (IS_ERR(dma_q->kthread)) { |
| 516 | printk(KERN_ERR "vivi: kernel_thread() failed\n"); | 480 | printk(KERN_ERR "vivi: kernel_thread() failed\n"); |
| @@ -519,7 +483,7 @@ static int vivi_start_thread(struct vivi_dmaqueue *dma_q) | |||
| 519 | /* Wakes thread */ | 483 | /* Wakes thread */ |
| 520 | wake_up_interruptible(&dma_q->wq); | 484 | wake_up_interruptible(&dma_q->wq); |
| 521 | 485 | ||
| 522 | dprintk(dev, 1, "returning from %s\n", __FUNCTION__); | 486 | dprintk(dev, 1, "returning from %s\n", __func__); |
| 523 | return 0; | 487 | return 0; |
| 524 | } | 488 | } |
| 525 | 489 | ||
| @@ -527,7 +491,7 @@ static void vivi_stop_thread(struct vivi_dmaqueue *dma_q) | |||
| 527 | { | 491 | { |
| 528 | struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); | 492 | struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); |
| 529 | 493 | ||
| 530 | dprintk(dev, 1, "%s\n", __FUNCTION__); | 494 | dprintk(dev, 1, "%s\n", __func__); |
| 531 | /* shutdown control thread */ | 495 | /* shutdown control thread */ |
| 532 | if (dma_q->kthread) { | 496 | if (dma_q->kthread) { |
| 533 | kthread_stop(dma_q->kthread); | 497 | kthread_stop(dma_q->kthread); |
| @@ -535,91 +499,6 @@ static void vivi_stop_thread(struct vivi_dmaqueue *dma_q) | |||
| 535 | } | 499 | } |
| 536 | } | 500 | } |
| 537 | 501 | ||
| 538 | static int restart_video_queue(struct vivi_dmaqueue *dma_q) | ||
| 539 | { | ||
| 540 | struct vivi_dev *dev = container_of(dma_q, struct vivi_dev, vidq); | ||
| 541 | struct vivi_buffer *buf, *prev; | ||
| 542 | |||
| 543 | dprintk(dev, 1, "%s dma_q=0x%08lx\n", __FUNCTION__, | ||
| 544 | (unsigned long)dma_q); | ||
| 545 | |||
| 546 | if (!list_empty(&dma_q->active)) { | ||
| 547 | buf = list_entry(dma_q->active.next, | ||
| 548 | struct vivi_buffer, vb.queue); | ||
| 549 | dprintk(dev, 2, "restart_queue [%p/%d]: restart dma\n", | ||
| 550 | buf, buf->vb.i); | ||
| 551 | |||
| 552 | dprintk(dev, 1, "Restarting video dma\n"); | ||
| 553 | vivi_stop_thread(dma_q); | ||
| 554 | |||
| 555 | /* cancel all outstanding capture / vbi requests */ | ||
| 556 | list_for_each_entry_safe(buf, prev, &dma_q->active, vb.queue) { | ||
| 557 | list_del(&buf->vb.queue); | ||
| 558 | buf->vb.state = VIDEOBUF_ERROR; | ||
| 559 | wake_up(&buf->vb.done); | ||
| 560 | } | ||
| 561 | mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT); | ||
| 562 | |||
| 563 | return 0; | ||
| 564 | } | ||
| 565 | |||
| 566 | prev = NULL; | ||
| 567 | for (;;) { | ||
| 568 | if (list_empty(&dma_q->queued)) | ||
| 569 | return 0; | ||
| 570 | buf = list_entry(dma_q->queued.next, | ||
| 571 | struct vivi_buffer, vb.queue); | ||
| 572 | if (NULL == prev) { | ||
| 573 | list_del(&buf->vb.queue); | ||
| 574 | list_add_tail(&buf->vb.queue, &dma_q->active); | ||
| 575 | |||
| 576 | dprintk(dev, 1, "Restarting video dma\n"); | ||
| 577 | vivi_stop_thread(dma_q); | ||
| 578 | vivi_start_thread(dma_q); | ||
| 579 | |||
| 580 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
| 581 | mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT); | ||
| 582 | dprintk(dev, 2, | ||
| 583 | "[%p/%d] restart_queue - first active\n", | ||
| 584 | buf, buf->vb.i); | ||
| 585 | |||
| 586 | } else if (prev->vb.width == buf->vb.width && | ||
| 587 | prev->vb.height == buf->vb.height && | ||
| 588 | prev->fmt == buf->fmt) { | ||
| 589 | list_del(&buf->vb.queue); | ||
| 590 | list_add_tail(&buf->vb.queue, &dma_q->active); | ||
| 591 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
| 592 | dprintk(dev, 2, | ||
| 593 | "[%p/%d] restart_queue - move to active\n", | ||
| 594 | buf, buf->vb.i); | ||
| 595 | } else { | ||
| 596 | return 0; | ||
| 597 | } | ||
| 598 | prev = buf; | ||
| 599 | } | ||
| 600 | } | ||
| 601 | |||
| 602 | static void vivi_vid_timeout(unsigned long data) | ||
| 603 | { | ||
| 604 | struct vivi_dev *dev = (struct vivi_dev *)data; | ||
| 605 | struct vivi_dmaqueue *vidq = &dev->vidq; | ||
| 606 | struct vivi_buffer *buf; | ||
| 607 | |||
| 608 | spin_lock(&dev->slock); | ||
| 609 | |||
| 610 | while (!list_empty(&vidq->active)) { | ||
| 611 | buf = list_entry(vidq->active.next, | ||
| 612 | struct vivi_buffer, vb.queue); | ||
| 613 | list_del(&buf->vb.queue); | ||
| 614 | buf->vb.state = VIDEOBUF_ERROR; | ||
| 615 | wake_up(&buf->vb.done); | ||
| 616 | printk(KERN_INFO "vivi/0: [%p/%d] timeout\n", buf, buf->vb.i); | ||
| 617 | } | ||
| 618 | restart_video_queue(vidq); | ||
| 619 | |||
| 620 | spin_unlock(&dev->slock); | ||
| 621 | } | ||
| 622 | |||
| 623 | /* ------------------------------------------------------------------ | 502 | /* ------------------------------------------------------------------ |
| 624 | Videobuf operations | 503 | Videobuf operations |
| 625 | ------------------------------------------------------------------*/ | 504 | ------------------------------------------------------------------*/ |
| @@ -637,7 +516,7 @@ buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size) | |||
| 637 | while (*size * *count > vid_limit * 1024 * 1024) | 516 | while (*size * *count > vid_limit * 1024 * 1024) |
| 638 | (*count)--; | 517 | (*count)--; |
| 639 | 518 | ||
| 640 | dprintk(dev, 1, "%s, count=%d, size=%d\n", __FUNCTION__, | 519 | dprintk(dev, 1, "%s, count=%d, size=%d\n", __func__, |
| 641 | *count, *size); | 520 | *count, *size); |
| 642 | 521 | ||
| 643 | return 0; | 522 | return 0; |
| @@ -648,13 +527,13 @@ static void free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf) | |||
| 648 | struct vivi_fh *fh = vq->priv_data; | 527 | struct vivi_fh *fh = vq->priv_data; |
| 649 | struct vivi_dev *dev = fh->dev; | 528 | struct vivi_dev *dev = fh->dev; |
| 650 | 529 | ||
| 651 | dprintk(dev, 1, "%s\n", __FUNCTION__); | 530 | dprintk(dev, 1, "%s, state: %i\n", __func__, buf->vb.state); |
| 652 | 531 | ||
| 653 | if (in_interrupt()) | 532 | if (in_interrupt()) |
| 654 | BUG(); | 533 | BUG(); |
| 655 | 534 | ||
| 656 | videobuf_waiton(&buf->vb, 0, 0); | ||
| 657 | videobuf_vmalloc_free(&buf->vb); | 535 | videobuf_vmalloc_free(&buf->vb); |
| 536 | dprintk(dev, 1, "free_buffer: freed\n"); | ||
| 658 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | 537 | buf->vb.state = VIDEOBUF_NEEDS_INIT; |
| 659 | } | 538 | } |
| 660 | 539 | ||
| @@ -667,28 +546,25 @@ buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, | |||
| 667 | struct vivi_fh *fh = vq->priv_data; | 546 | struct vivi_fh *fh = vq->priv_data; |
| 668 | struct vivi_dev *dev = fh->dev; | 547 | struct vivi_dev *dev = fh->dev; |
| 669 | struct vivi_buffer *buf = container_of(vb, struct vivi_buffer, vb); | 548 | struct vivi_buffer *buf = container_of(vb, struct vivi_buffer, vb); |
| 670 | int rc, init_buffer = 0; | 549 | int rc; |
| 671 | 550 | ||
| 672 | dprintk(dev, 1, "%s, field=%d\n", __FUNCTION__, field); | 551 | dprintk(dev, 1, "%s, field=%d\n", __func__, field); |
| 673 | 552 | ||
| 674 | BUG_ON(NULL == fh->fmt); | 553 | BUG_ON(NULL == fh->fmt); |
| 554 | |||
| 675 | if (fh->width < 48 || fh->width > norm_maxw() || | 555 | if (fh->width < 48 || fh->width > norm_maxw() || |
| 676 | fh->height < 32 || fh->height > norm_maxh()) | 556 | fh->height < 32 || fh->height > norm_maxh()) |
| 677 | return -EINVAL; | 557 | return -EINVAL; |
| 558 | |||
| 678 | buf->vb.size = fh->width*fh->height*2; | 559 | buf->vb.size = fh->width*fh->height*2; |
| 679 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | 560 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) |
| 680 | return -EINVAL; | 561 | return -EINVAL; |
| 681 | 562 | ||
| 682 | if (buf->fmt != fh->fmt || | 563 | /* These properties only change when queue is idle, see s_fmt */ |
| 683 | buf->vb.width != fh->width || | 564 | buf->fmt = fh->fmt; |
| 684 | buf->vb.height != fh->height || | 565 | buf->vb.width = fh->width; |
| 685 | buf->vb.field != field) { | 566 | buf->vb.height = fh->height; |
| 686 | buf->fmt = fh->fmt; | 567 | buf->vb.field = field; |
| 687 | buf->vb.width = fh->width; | ||
| 688 | buf->vb.height = fh->height; | ||
| 689 | buf->vb.field = field; | ||
| 690 | init_buffer = 1; | ||
| 691 | } | ||
| 692 | 568 | ||
| 693 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | 569 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { |
| 694 | rc = videobuf_iolock(vq, &buf->vb, NULL); | 570 | rc = videobuf_iolock(vq, &buf->vb, NULL); |
| @@ -711,45 +587,12 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb) | |||
| 711 | struct vivi_buffer *buf = container_of(vb, struct vivi_buffer, vb); | 587 | struct vivi_buffer *buf = container_of(vb, struct vivi_buffer, vb); |
| 712 | struct vivi_fh *fh = vq->priv_data; | 588 | struct vivi_fh *fh = vq->priv_data; |
| 713 | struct vivi_dev *dev = fh->dev; | 589 | struct vivi_dev *dev = fh->dev; |
| 714 | struct vivi_dmaqueue *vidq = &dev->vidq; | 590 | struct vivi_dmaqueue *vidq = &dev->vidq; |
| 715 | struct vivi_buffer *prev; | 591 | |
| 716 | 592 | dprintk(dev, 1, "%s\n", __func__); | |
| 717 | if (!list_empty(&vidq->queued)) { | 593 | |
| 718 | dprintk(dev, 1, "adding vb queue=0x%08lx\n", | 594 | buf->vb.state = VIDEOBUF_QUEUED; |
| 719 | (unsigned long)&buf->vb.queue); | 595 | list_add_tail(&buf->vb.queue, &vidq->active); |
| 720 | list_add_tail(&buf->vb.queue, &vidq->queued); | ||
| 721 | buf->vb.state = VIDEOBUF_QUEUED; | ||
| 722 | dprintk(dev, 2, "[%p/%d] buffer_queue - append to queued\n", | ||
| 723 | buf, buf->vb.i); | ||
| 724 | } else if (list_empty(&vidq->active)) { | ||
| 725 | list_add_tail(&buf->vb.queue, &vidq->active); | ||
| 726 | |||
| 727 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
| 728 | mod_timer(&vidq->timeout, jiffies+BUFFER_TIMEOUT); | ||
| 729 | dprintk(dev, 2, "[%p/%d] buffer_queue - first active\n", | ||
| 730 | buf, buf->vb.i); | ||
| 731 | |||
| 732 | vivi_start_thread(vidq); | ||
| 733 | } else { | ||
| 734 | prev = list_entry(vidq->active.prev, | ||
| 735 | struct vivi_buffer, vb.queue); | ||
| 736 | if (prev->vb.width == buf->vb.width && | ||
| 737 | prev->vb.height == buf->vb.height && | ||
| 738 | prev->fmt == buf->fmt) { | ||
| 739 | list_add_tail(&buf->vb.queue, &vidq->active); | ||
| 740 | buf->vb.state = VIDEOBUF_ACTIVE; | ||
| 741 | dprintk(dev, 2, | ||
| 742 | "[%p/%d] buffer_queue - append to active\n", | ||
| 743 | buf, buf->vb.i); | ||
| 744 | |||
| 745 | } else { | ||
| 746 | list_add_tail(&buf->vb.queue, &vidq->queued); | ||
| 747 | buf->vb.state = VIDEOBUF_QUEUED; | ||
| 748 | dprintk(dev, 2, | ||
| 749 | "[%p/%d] buffer_queue - first queued\n", | ||
| 750 | buf, buf->vb.i); | ||
| 751 | } | ||
| 752 | } | ||
| 753 | } | 596 | } |
| 754 | 597 | ||
| 755 | static void buffer_release(struct videobuf_queue *vq, | 598 | static void buffer_release(struct videobuf_queue *vq, |
| @@ -758,11 +601,8 @@ static void buffer_release(struct videobuf_queue *vq, | |||
| 758 | struct vivi_buffer *buf = container_of(vb, struct vivi_buffer, vb); | 601 | struct vivi_buffer *buf = container_of(vb, struct vivi_buffer, vb); |
| 759 | struct vivi_fh *fh = vq->priv_data; | 602 | struct vivi_fh *fh = vq->priv_data; |
| 760 | struct vivi_dev *dev = (struct vivi_dev *)fh->dev; | 603 | struct vivi_dev *dev = (struct vivi_dev *)fh->dev; |
| 761 | struct vivi_dmaqueue *vidq = &dev->vidq; | ||
| 762 | |||
| 763 | dprintk(dev, 1, "%s\n", __FUNCTION__); | ||
| 764 | 604 | ||
| 765 | vivi_stop_thread(vidq); | 605 | dprintk(dev, 1, "%s\n", __func__); |
| 766 | 606 | ||
| 767 | free_buffer(vq, buf); | 607 | free_buffer(vq, buf); |
| 768 | } | 608 | } |
| @@ -869,17 +709,31 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv, | |||
| 869 | struct v4l2_format *f) | 709 | struct v4l2_format *f) |
| 870 | { | 710 | { |
| 871 | struct vivi_fh *fh = priv; | 711 | struct vivi_fh *fh = priv; |
| 712 | struct videobuf_queue *q = &fh->vb_vidq; | ||
| 713 | |||
| 872 | int ret = vidioc_try_fmt_cap(file, fh, f); | 714 | int ret = vidioc_try_fmt_cap(file, fh, f); |
| 873 | if (ret < 0) | 715 | if (ret < 0) |
| 874 | return (ret); | 716 | return (ret); |
| 875 | 717 | ||
| 718 | mutex_lock(&q->vb_lock); | ||
| 719 | |||
| 720 | if (videobuf_queue_is_busy(&fh->vb_vidq)) { | ||
| 721 | dprintk(fh->dev, 1, "%s queue busy\n", __func__); | ||
| 722 | ret = -EBUSY; | ||
| 723 | goto out; | ||
| 724 | } | ||
| 725 | |||
| 876 | fh->fmt = &format; | 726 | fh->fmt = &format; |
| 877 | fh->width = f->fmt.pix.width; | 727 | fh->width = f->fmt.pix.width; |
| 878 | fh->height = f->fmt.pix.height; | 728 | fh->height = f->fmt.pix.height; |
| 879 | fh->vb_vidq.field = f->fmt.pix.field; | 729 | fh->vb_vidq.field = f->fmt.pix.field; |
| 880 | fh->type = f->type; | 730 | fh->type = f->type; |
| 881 | 731 | ||
| 882 | return (0); | 732 | ret = 0; |
| 733 | out: | ||
| 734 | mutex_unlock(&q->vb_lock); | ||
| 735 | |||
| 736 | return (ret); | ||
| 883 | } | 737 | } |
| 884 | 738 | ||
| 885 | static int vidioc_reqbufs(struct file *file, void *priv, | 739 | static int vidioc_reqbufs(struct file *file, void *priv, |
| @@ -1036,6 +890,7 @@ static int vivi_open(struct inode *inode, struct file *file) | |||
| 1036 | struct vivi_dev *dev; | 890 | struct vivi_dev *dev; |
| 1037 | struct vivi_fh *fh; | 891 | struct vivi_fh *fh; |
| 1038 | int i; | 892 | int i; |
| 893 | int retval = 0; | ||
| 1039 | 894 | ||
| 1040 | printk(KERN_DEBUG "vivi: open called (minor=%d)\n", minor); | 895 | printk(KERN_DEBUG "vivi: open called (minor=%d)\n", minor); |
| 1041 | 896 | ||
| @@ -1045,9 +900,15 @@ static int vivi_open(struct inode *inode, struct file *file) | |||
| 1045 | return -ENODEV; | 900 | return -ENODEV; |
| 1046 | 901 | ||
| 1047 | found: | 902 | found: |
| 1048 | /* If more than one user, mutex should be added */ | 903 | mutex_lock(&dev->mutex); |
| 1049 | dev->users++; | 904 | dev->users++; |
| 1050 | 905 | ||
| 906 | if (dev->users > 1) { | ||
| 907 | dev->users--; | ||
| 908 | retval = -EBUSY; | ||
| 909 | goto unlock; | ||
| 910 | } | ||
| 911 | |||
| 1051 | dprintk(dev, 1, "open minor=%d type=%s users=%d\n", minor, | 912 | dprintk(dev, 1, "open minor=%d type=%s users=%d\n", minor, |
| 1052 | v4l2_type_names[V4L2_BUF_TYPE_VIDEO_CAPTURE], dev->users); | 913 | v4l2_type_names[V4L2_BUF_TYPE_VIDEO_CAPTURE], dev->users); |
| 1053 | 914 | ||
| @@ -1055,8 +916,13 @@ found: | |||
| 1055 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); | 916 | fh = kzalloc(sizeof(*fh), GFP_KERNEL); |
| 1056 | if (NULL == fh) { | 917 | if (NULL == fh) { |
| 1057 | dev->users--; | 918 | dev->users--; |
| 1058 | return -ENOMEM; | 919 | retval = -ENOMEM; |
| 920 | goto unlock; | ||
| 1059 | } | 921 | } |
| 922 | unlock: | ||
| 923 | mutex_unlock(&dev->mutex); | ||
| 924 | if (retval) | ||
| 925 | return retval; | ||
| 1060 | 926 | ||
| 1061 | file->private_data = fh; | 927 | file->private_data = fh; |
| 1062 | fh->dev = dev; | 928 | fh->dev = dev; |
| @@ -1084,6 +950,8 @@ found: | |||
| 1084 | NULL, &dev->slock, fh->type, V4L2_FIELD_INTERLACED, | 950 | NULL, &dev->slock, fh->type, V4L2_FIELD_INTERLACED, |
| 1085 | sizeof(struct vivi_buffer), fh); | 951 | sizeof(struct vivi_buffer), fh); |
| 1086 | 952 | ||
| 953 | vivi_start_thread(fh); | ||
| 954 | |||
| 1087 | return 0; | 955 | return 0; |
| 1088 | } | 956 | } |
| 1089 | 957 | ||
| @@ -1106,7 +974,7 @@ vivi_poll(struct file *file, struct poll_table_struct *wait) | |||
| 1106 | struct vivi_dev *dev = fh->dev; | 974 | struct vivi_dev *dev = fh->dev; |
| 1107 | struct videobuf_queue *q = &fh->vb_vidq; | 975 | struct videobuf_queue *q = &fh->vb_vidq; |
| 1108 | 976 | ||
| 1109 | dprintk(dev, 1, "%s\n", __FUNCTION__); | 977 | dprintk(dev, 1, "%s\n", __func__); |
| 1110 | 978 | ||
| 1111 | if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) | 979 | if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) |
| 1112 | return POLLERR; | 980 | return POLLERR; |
| @@ -1128,7 +996,9 @@ static int vivi_close(struct inode *inode, struct file *file) | |||
| 1128 | 996 | ||
| 1129 | kfree(fh); | 997 | kfree(fh); |
| 1130 | 998 | ||
| 999 | mutex_lock(&dev->mutex); | ||
| 1131 | dev->users--; | 1000 | dev->users--; |
| 1001 | mutex_unlock(&dev->mutex); | ||
| 1132 | 1002 | ||
| 1133 | dprintk(dev, 1, "close called (minor=%d, users=%d)\n", | 1003 | dprintk(dev, 1, "close called (minor=%d, users=%d)\n", |
| 1134 | minor, dev->users); | 1004 | minor, dev->users); |
| @@ -1182,6 +1052,7 @@ static const struct file_operations vivi_fops = { | |||
| 1182 | .read = vivi_read, | 1052 | .read = vivi_read, |
| 1183 | .poll = vivi_poll, | 1053 | .poll = vivi_poll, |
| 1184 | .ioctl = video_ioctl2, /* V4L2 ioctl handler */ | 1054 | .ioctl = video_ioctl2, /* V4L2 ioctl handler */ |
| 1055 | .compat_ioctl = v4l_compat_ioctl32, | ||
| 1185 | .mmap = vivi_mmap, | 1056 | .mmap = vivi_mmap, |
| 1186 | .llseek = no_llseek, | 1057 | .llseek = no_llseek, |
| 1187 | }; | 1058 | }; |
| @@ -1236,16 +1107,11 @@ static int __init vivi_init(void) | |||
| 1236 | 1107 | ||
| 1237 | /* init video dma queues */ | 1108 | /* init video dma queues */ |
| 1238 | INIT_LIST_HEAD(&dev->vidq.active); | 1109 | INIT_LIST_HEAD(&dev->vidq.active); |
| 1239 | INIT_LIST_HEAD(&dev->vidq.queued); | ||
| 1240 | init_waitqueue_head(&dev->vidq.wq); | 1110 | init_waitqueue_head(&dev->vidq.wq); |
| 1241 | 1111 | ||
| 1242 | /* initialize locks */ | 1112 | /* initialize locks */ |
| 1243 | mutex_init(&dev->lock); | ||
| 1244 | spin_lock_init(&dev->slock); | 1113 | spin_lock_init(&dev->slock); |
| 1245 | 1114 | mutex_init(&dev->mutex); | |
| 1246 | dev->vidq.timeout.function = vivi_vid_timeout; | ||
| 1247 | dev->vidq.timeout.data = (unsigned long)dev; | ||
| 1248 | init_timer(&dev->vidq.timeout); | ||
| 1249 | 1115 | ||
| 1250 | vfd = video_device_alloc(); | 1116 | vfd = video_device_alloc(); |
| 1251 | if (NULL == vfd) | 1117 | if (NULL == vfd) |
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c index a9133858e913..35293029da02 100644 --- a/drivers/media/video/vpx3220.c +++ b/drivers/media/video/vpx3220.c | |||
| @@ -40,7 +40,7 @@ | |||
| 40 | #define I2C_VPX3220 0x86 | 40 | #define I2C_VPX3220 0x86 |
| 41 | #define VPX3220_DEBUG KERN_DEBUG "vpx3220: " | 41 | #define VPX3220_DEBUG KERN_DEBUG "vpx3220: " |
| 42 | 42 | ||
| 43 | static int debug = 0; | 43 | static int debug; |
| 44 | module_param(debug, int, 0); | 44 | module_param(debug, int, 0); |
| 45 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); | 45 | MODULE_PARM_DESC(debug, "Debug level (0-1)"); |
| 46 | 46 | ||
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c index 08aaae07c7e0..33f702698a56 100644 --- a/drivers/media/video/w9966.c +++ b/drivers/media/video/w9966.c | |||
| @@ -61,10 +61,10 @@ | |||
| 61 | #include <media/v4l2-common.h> | 61 | #include <media/v4l2-common.h> |
| 62 | #include <linux/parport.h> | 62 | #include <linux/parport.h> |
| 63 | 63 | ||
| 64 | //#define DEBUG // Undef me for production | 64 | /*#define DEBUG*/ /* Undef me for production */ |
| 65 | 65 | ||
| 66 | #ifdef DEBUG | 66 | #ifdef DEBUG |
| 67 | #define DPRINTF(x, a...) printk(KERN_DEBUG "W9966: %s(): "x, __FUNCTION__ , ##a) | 67 | #define DPRINTF(x, a...) printk(KERN_DEBUG "W9966: %s(): "x, __func__ , ##a) |
| 68 | #else | 68 | #else |
| 69 | #define DPRINTF(x...) | 69 | #define DPRINTF(x...) |
| 70 | #endif | 70 | #endif |
| @@ -134,7 +134,7 @@ MODULE_PARM_DESC(pardev, "pardev: where to search for\n\ | |||
| 134 | \tEg: >pardev=parport3,aggressive,parport2,parport1< would assign\n\ | 134 | \tEg: >pardev=parport3,aggressive,parport2,parport1< would assign\n\ |
| 135 | \tcam 1 to parport3 and search every parport for cam 2 etc..."); | 135 | \tcam 1 to parport3 and search every parport for cam 2 etc..."); |
| 136 | 136 | ||
| 137 | static int parmode = 0; | 137 | static int parmode; |
| 138 | module_param(parmode, int, 0); | 138 | module_param(parmode, int, 0); |
| 139 | MODULE_PARM_DESC(parmode, "parmode: transfer mode (0=auto, 1=ecp, 2=epp"); | 139 | MODULE_PARM_DESC(parmode, "parmode: transfer mode (0=auto, 1=ecp, 2=epp"); |
| 140 | 140 | ||
| @@ -188,7 +188,9 @@ static const struct file_operations w9966_fops = { | |||
| 188 | .open = video_exclusive_open, | 188 | .open = video_exclusive_open, |
| 189 | .release = video_exclusive_release, | 189 | .release = video_exclusive_release, |
| 190 | .ioctl = w9966_v4l_ioctl, | 190 | .ioctl = w9966_v4l_ioctl, |
| 191 | #ifdef CONFIG_COMPAT | ||
| 191 | .compat_ioctl = v4l_compat_ioctl32, | 192 | .compat_ioctl = v4l_compat_ioctl32, |
| 193 | #endif | ||
| 192 | .read = w9966_v4l_read, | 194 | .read = w9966_v4l_read, |
| 193 | .llseek = no_llseek, | 195 | .llseek = no_llseek, |
| 194 | }; | 196 | }; |
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c index 2ae1430f5f7d..840522442d07 100644 --- a/drivers/media/video/w9968cf.c +++ b/drivers/media/video/w9968cf.c | |||
| @@ -3461,7 +3461,9 @@ static const struct file_operations w9968cf_fops = { | |||
| 3461 | .release = w9968cf_release, | 3461 | .release = w9968cf_release, |
| 3462 | .read = w9968cf_read, | 3462 | .read = w9968cf_read, |
| 3463 | .ioctl = w9968cf_ioctl, | 3463 | .ioctl = w9968cf_ioctl, |
| 3464 | #ifdef CONFIG_COMPAT | ||
| 3464 | .compat_ioctl = v4l_compat_ioctl32, | 3465 | .compat_ioctl = v4l_compat_ioctl32, |
| 3466 | #endif | ||
| 3465 | .mmap = w9968cf_mmap, | 3467 | .mmap = w9968cf_mmap, |
| 3466 | .llseek = no_llseek, | 3468 | .llseek = no_llseek, |
| 3467 | }; | 3469 | }; |
| @@ -3481,7 +3483,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
| 3481 | enum w9968cf_model_id mod_id; | 3483 | enum w9968cf_model_id mod_id; |
| 3482 | struct list_head* ptr; | 3484 | struct list_head* ptr; |
| 3483 | u8 sc = 0; /* number of simultaneous cameras */ | 3485 | u8 sc = 0; /* number of simultaneous cameras */ |
| 3484 | static unsigned short dev_nr = 0; /* we are handling device number n */ | 3486 | static unsigned short dev_nr; /* 0 - we are handling device number n */ |
| 3485 | 3487 | ||
| 3486 | if (le16_to_cpu(udev->descriptor.idVendor) == winbond_id_table[0].idVendor && | 3488 | if (le16_to_cpu(udev->descriptor.idVendor) == winbond_id_table[0].idVendor && |
| 3487 | le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct) | 3489 | le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct) |
diff --git a/drivers/media/video/w9968cf.h b/drivers/media/video/w9968cf.h index ec7696e8f1fa..3c95316bc030 100644 --- a/drivers/media/video/w9968cf.h +++ b/drivers/media/video/w9968cf.h | |||
| @@ -298,7 +298,7 @@ struct w9968cf_device { | |||
| 298 | dev_warn(&cam->dev, fmt "\n", ## args); \ | 298 | dev_warn(&cam->dev, fmt "\n", ## args); \ |
| 299 | else if ((level) >= 5) \ | 299 | else if ((level) >= 5) \ |
| 300 | dev_info(&cam->dev, "[%s:%d] " fmt "\n", \ | 300 | dev_info(&cam->dev, "[%s:%d] " fmt "\n", \ |
| 301 | __FUNCTION__, __LINE__ , ## args); \ | 301 | __func__, __LINE__ , ## args); \ |
| 302 | } \ | 302 | } \ |
| 303 | } | 303 | } |
| 304 | /* For generic kernel (not device specific) messages */ | 304 | /* For generic kernel (not device specific) messages */ |
| @@ -309,7 +309,7 @@ struct w9968cf_device { | |||
| 309 | if ((level) >= 1 && (level) <= 4) \ | 309 | if ((level) >= 1 && (level) <= 4) \ |
| 310 | pr_info("w9968cf: " fmt "\n", ## args); \ | 310 | pr_info("w9968cf: " fmt "\n", ## args); \ |
| 311 | else if ((level) >= 5) \ | 311 | else if ((level) >= 5) \ |
| 312 | pr_debug("w9968cf: [%s:%d] " fmt "\n", __FUNCTION__, \ | 312 | pr_debug("w9968cf: [%s:%d] " fmt "\n", __func__, \ |
| 313 | __LINE__ , ## args); \ | 313 | __LINE__ , ## args); \ |
| 314 | } \ | 314 | } \ |
| 315 | } | 315 | } |
| @@ -321,7 +321,7 @@ struct w9968cf_device { | |||
| 321 | 321 | ||
| 322 | #undef PDBG | 322 | #undef PDBG |
| 323 | #define PDBG(fmt, args...) \ | 323 | #define PDBG(fmt, args...) \ |
| 324 | dev_info(&cam->dev, "[%s:%d] " fmt "\n", __FUNCTION__, __LINE__ , ## args); | 324 | dev_info(&cam->dev, "[%s:%d] " fmt "\n", __func__, __LINE__ , ## args); |
| 325 | 325 | ||
| 326 | #undef PDBGG | 326 | #undef PDBGG |
| 327 | #define PDBGG(fmt, args...) do {;} while(0); /* nothing: it's a placeholder */ | 327 | #define PDBGG(fmt, args...) do {;} while(0); /* nothing: it's a placeholder */ |
diff --git a/drivers/media/video/zc0301/zc0301.h b/drivers/media/video/zc0301/zc0301.h index a2de50efa31a..7bbab541a309 100644 --- a/drivers/media/video/zc0301/zc0301.h +++ b/drivers/media/video/zc0301/zc0301.h | |||
| @@ -160,7 +160,7 @@ do { \ | |||
| 160 | dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ | 160 | dev_info(&cam->usbdev->dev, fmt "\n", ## args); \ |
| 161 | else if ((level) >= 3) \ | 161 | else if ((level) >= 3) \ |
| 162 | dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", \ | 162 | dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", \ |
| 163 | __FILE__, __FUNCTION__, __LINE__ , ## args); \ | 163 | __FILE__, __func__, __LINE__ , ## args); \ |
| 164 | } \ | 164 | } \ |
| 165 | } while (0) | 165 | } while (0) |
| 166 | # define KDBG(level, fmt, args...) \ | 166 | # define KDBG(level, fmt, args...) \ |
| @@ -170,7 +170,7 @@ do { \ | |||
| 170 | pr_info("zc0301: " fmt "\n", ## args); \ | 170 | pr_info("zc0301: " fmt "\n", ## args); \ |
| 171 | else if ((level) == 3) \ | 171 | else if ((level) == 3) \ |
| 172 | pr_debug("sn9c102: [%s:%s:%d] " fmt "\n", __FILE__, \ | 172 | pr_debug("sn9c102: [%s:%s:%d] " fmt "\n", __FILE__, \ |
| 173 | __FUNCTION__, __LINE__ , ## args); \ | 173 | __func__, __LINE__ , ## args); \ |
| 174 | } \ | 174 | } \ |
| 175 | } while (0) | 175 | } while (0) |
| 176 | # define V4LDBG(level, name, cmd) \ | 176 | # define V4LDBG(level, name, cmd) \ |
| @@ -186,7 +186,7 @@ do { \ | |||
| 186 | 186 | ||
| 187 | #undef PDBG | 187 | #undef PDBG |
| 188 | #define PDBG(fmt, args...) \ | 188 | #define PDBG(fmt, args...) \ |
| 189 | dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", __FILE__, __FUNCTION__, \ | 189 | dev_info(&cam->usbdev->dev, "[%s:%s:%d] " fmt "\n", __FILE__, __func__, \ |
| 190 | __LINE__ , ## args) | 190 | __LINE__ , ## args) |
| 191 | 191 | ||
| 192 | #undef PDBGG | 192 | #undef PDBGG |
diff --git a/drivers/media/video/zc0301/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c index 2c5665c82442..363dd2b9475c 100644 --- a/drivers/media/video/zc0301/zc0301_core.c +++ b/drivers/media/video/zc0301/zc0301_core.c | |||
| @@ -1925,7 +1925,9 @@ static const struct file_operations zc0301_fops = { | |||
| 1925 | .open = zc0301_open, | 1925 | .open = zc0301_open, |
| 1926 | .release = zc0301_release, | 1926 | .release = zc0301_release, |
| 1927 | .ioctl = zc0301_ioctl, | 1927 | .ioctl = zc0301_ioctl, |
| 1928 | #ifdef CONFIG_COMPAT | ||
| 1928 | .compat_ioctl = v4l_compat_ioctl32, | 1929 | .compat_ioctl = v4l_compat_ioctl32, |
| 1930 | #endif | ||
| 1929 | .read = zc0301_read, | 1931 | .read = zc0301_read, |
| 1930 | .poll = zc0301_poll, | 1932 | .poll = zc0301_poll, |
| 1931 | .mmap = zc0301_mmap, | 1933 | .mmap = zc0301_mmap, |
| @@ -1939,7 +1941,7 @@ zc0301_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
| 1939 | { | 1941 | { |
| 1940 | struct usb_device *udev = interface_to_usbdev(intf); | 1942 | struct usb_device *udev = interface_to_usbdev(intf); |
| 1941 | struct zc0301_device* cam; | 1943 | struct zc0301_device* cam; |
| 1942 | static unsigned int dev_nr = 0; | 1944 | static unsigned int dev_nr; |
| 1943 | unsigned int i; | 1945 | unsigned int i; |
| 1944 | int err = 0; | 1946 | int err = 0; |
| 1945 | 1947 | ||
diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h index 498a43c1f2b1..81cc3b00a079 100644 --- a/drivers/media/video/zoran.h +++ b/drivers/media/video/zoran.h | |||
| @@ -243,10 +243,8 @@ struct zoran_format { | |||
| 243 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | 243 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
| 244 | int palette; | 244 | int palette; |
| 245 | #endif | 245 | #endif |
| 246 | #ifdef CONFIG_VIDEO_V4L2 | ||
| 247 | __u32 fourcc; | 246 | __u32 fourcc; |
| 248 | int colorspace; | 247 | int colorspace; |
| 249 | #endif | ||
| 250 | int depth; | 248 | int depth; |
| 251 | __u32 flags; | 249 | __u32 flags; |
| 252 | __u32 vfespfr; | 250 | __u32 vfespfr; |
| @@ -271,20 +269,6 @@ struct zoran_v4l_settings { | |||
| 271 | const struct zoran_format *format; /* capture format */ | 269 | const struct zoran_format *format; /* capture format */ |
| 272 | }; | 270 | }; |
| 273 | 271 | ||
| 274 | /* whoops, this one is undeclared if !v4l2 */ | ||
| 275 | #ifndef CONFIG_VIDEO_V4L2 | ||
| 276 | struct v4l2_jpegcompression { | ||
| 277 | int quality; | ||
| 278 | int APPn; | ||
| 279 | int APP_len; | ||
| 280 | char APP_data[60]; | ||
| 281 | int COM_len; | ||
| 282 | char COM_data[60]; | ||
| 283 | __u32 jpeg_markers; | ||
| 284 | __u8 reserved[116]; | ||
| 285 | }; | ||
| 286 | #endif | ||
| 287 | |||
| 288 | /* jpg-capture/-playback settings */ | 272 | /* jpg-capture/-playback settings */ |
| 289 | struct zoran_jpg_settings { | 273 | struct zoran_jpg_settings { |
| 290 | int decimation; /* this bit is used to set everything to default */ | 274 | int decimation; /* this bit is used to set everything to default */ |
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c index 690281bb59ee..006d48847e24 100644 --- a/drivers/media/video/zoran_card.c +++ b/drivers/media/video/zoran_card.c | |||
| @@ -83,7 +83,7 @@ MODULE_PARM_DESC(decoder, "i2c TV decoder"); | |||
| 83 | or set in in a VIDIOCSFBUF ioctl | 83 | or set in in a VIDIOCSFBUF ioctl |
| 84 | */ | 84 | */ |
| 85 | 85 | ||
| 86 | static unsigned long vidmem = 0; /* Video memory base address */ | 86 | static unsigned long vidmem; /* default = 0 - Video memory base address */ |
| 87 | module_param(vidmem, ulong, 0444); | 87 | module_param(vidmem, ulong, 0444); |
| 88 | MODULE_PARM_DESC(vidmem, "Default video memory base address"); | 88 | MODULE_PARM_DESC(vidmem, "Default video memory base address"); |
| 89 | 89 | ||
| @@ -91,7 +91,7 @@ MODULE_PARM_DESC(vidmem, "Default video memory base address"); | |||
| 91 | Default input and video norm at startup of the driver. | 91 | Default input and video norm at startup of the driver. |
| 92 | */ | 92 | */ |
| 93 | 93 | ||
| 94 | static unsigned int default_input = 0; /* 0=Composite, 1=S-Video */ | 94 | static unsigned int default_input; /* default 0 = Composite, 1 = S-Video */ |
| 95 | module_param(default_input, uint, 0444); | 95 | module_param(default_input, uint, 0444); |
| 96 | MODULE_PARM_DESC(default_input, | 96 | MODULE_PARM_DESC(default_input, |
| 97 | "Default input (0=Composite, 1=S-Video, 2=Internal)"); | 97 | "Default input (0=Composite, 1=S-Video, 2=Internal)"); |
| @@ -101,7 +101,7 @@ module_param(default_mux, int, 0644); | |||
| 101 | MODULE_PARM_DESC(default_mux, | 101 | MODULE_PARM_DESC(default_mux, |
| 102 | "Default 6 Eyes mux setting (Input selection)"); | 102 | "Default 6 Eyes mux setting (Input selection)"); |
| 103 | 103 | ||
| 104 | static int default_norm = 0; /* 0=PAL, 1=NTSC 2=SECAM */ | 104 | static int default_norm; /* default 0 = PAL, 1 = NTSC 2 = SECAM */ |
| 105 | module_param(default_norm, int, 0444); | 105 | module_param(default_norm, int, 0444); |
| 106 | MODULE_PARM_DESC(default_norm, "Default norm (0=PAL, 1=NTSC, 2=SECAM)"); | 106 | MODULE_PARM_DESC(default_norm, "Default norm (0=PAL, 1=NTSC, 2=SECAM)"); |
| 107 | 107 | ||
diff --git a/drivers/media/video/zoran_card.h b/drivers/media/video/zoran_card.h index 8444ca0a5f3f..1b5c4171cf9c 100644 --- a/drivers/media/video/zoran_card.h +++ b/drivers/media/video/zoran_card.h | |||
| @@ -50,4 +50,6 @@ extern int zoran_check_jpg_settings(struct zoran *zr, | |||
| 50 | extern void zoran_open_init_params(struct zoran *zr); | 50 | extern void zoran_open_init_params(struct zoran *zr); |
| 51 | extern void zoran_vdev_release(struct video_device *vdev); | 51 | extern void zoran_vdev_release(struct video_device *vdev); |
| 52 | 52 | ||
| 53 | void zr36016_write(struct videocodec *codec, u16 reg, u32 val); | ||
| 54 | |||
| 53 | #endif /* __ZORAN_CARD_H__ */ | 55 | #endif /* __ZORAN_CARD_H__ */ |
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c index f97c20692057..7b60533efe45 100644 --- a/drivers/media/video/zoran_device.c +++ b/drivers/media/video/zoran_device.c | |||
| @@ -60,7 +60,8 @@ | |||
| 60 | 60 | ||
| 61 | extern const struct zoran_format zoran_formats[]; | 61 | extern const struct zoran_format zoran_formats[]; |
| 62 | 62 | ||
| 63 | static int lml33dpath = 0; /* 1 will use digital path in capture | 63 | static int lml33dpath; /* default = 0 |
| 64 | * 1 will use digital path in capture | ||
| 64 | * mode instead of analog. It can be | 65 | * mode instead of analog. It can be |
| 65 | * used for picture adjustments using | 66 | * used for picture adjustments using |
| 66 | * tool like xawtv while watching image | 67 | * tool like xawtv while watching image |
| @@ -927,11 +928,6 @@ count_reset_interrupt (struct zoran *zr) | |||
| 927 | return isr; | 928 | return isr; |
| 928 | } | 929 | } |
| 929 | 930 | ||
| 930 | /* hack */ | ||
| 931 | extern void zr36016_write (struct videocodec *codec, | ||
| 932 | u16 reg, | ||
| 933 | u32 val); | ||
| 934 | |||
| 935 | void | 931 | void |
| 936 | jpeg_start (struct zoran *zr) | 932 | jpeg_start (struct zoran *zr) |
| 937 | { | 933 | { |
| @@ -987,7 +983,7 @@ void | |||
| 987 | zr36057_enable_jpg (struct zoran *zr, | 983 | zr36057_enable_jpg (struct zoran *zr, |
| 988 | enum zoran_codec_mode mode) | 984 | enum zoran_codec_mode mode) |
| 989 | { | 985 | { |
| 990 | static int zero = 0; | 986 | static int zero; |
| 991 | static int one = 1; | 987 | static int one = 1; |
| 992 | struct vfe_settings cap; | 988 | struct vfe_settings cap; |
| 993 | int field_size = | 989 | int field_size = |
| @@ -1726,7 +1722,7 @@ decoder_command (struct zoran *zr, | |||
| 1726 | return -EIO; | 1722 | return -EIO; |
| 1727 | 1723 | ||
| 1728 | if (zr->card.type == LML33 && | 1724 | if (zr->card.type == LML33 && |
| 1729 | (cmd == DECODER_SET_NORM || DECODER_SET_INPUT)) { | 1725 | (cmd == DECODER_SET_NORM || cmd == DECODER_SET_INPUT)) { |
| 1730 | int res; | 1726 | int res; |
| 1731 | 1727 | ||
| 1732 | // Bt819 needs to reset its FIFO buffer using #FRST pin and | 1728 | // Bt819 needs to reset its FIFO buffer using #FRST pin and |
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c index fea4946ee713..0134bec1e399 100644 --- a/drivers/media/video/zoran_driver.c +++ b/drivers/media/video/zoran_driver.c | |||
| @@ -85,7 +85,6 @@ | |||
| 85 | #include "zoran_device.h" | 85 | #include "zoran_device.h" |
| 86 | #include "zoran_card.h" | 86 | #include "zoran_card.h" |
| 87 | 87 | ||
| 88 | #ifdef CONFIG_VIDEO_V4L2 | ||
| 89 | /* we declare some card type definitions here, they mean | 88 | /* we declare some card type definitions here, they mean |
| 90 | * the same as the v4l1 ZORAN_VID_TYPE above, except it's v4l2 */ | 89 | * the same as the v4l1 ZORAN_VID_TYPE above, except it's v4l2 */ |
| 91 | #define ZORAN_V4L2_VID_FLAGS ( \ | 90 | #define ZORAN_V4L2_VID_FLAGS ( \ |
| @@ -94,19 +93,15 @@ | |||
| 94 | V4L2_CAP_VIDEO_OUTPUT |\ | 93 | V4L2_CAP_VIDEO_OUTPUT |\ |
| 95 | V4L2_CAP_VIDEO_OVERLAY \ | 94 | V4L2_CAP_VIDEO_OVERLAY \ |
| 96 | ) | 95 | ) |
| 97 | #endif | ||
| 98 | 96 | ||
| 99 | #include <asm/byteorder.h> | 97 | #include <asm/byteorder.h> |
| 100 | 98 | ||
| 101 | #if defined(CONFIG_VIDEO_V4L2) && defined(CONFIG_VIDEO_V4L1_COMPAT) | 99 | #if defined(CONFIG_VIDEO_V4L1_COMPAT) |
| 102 | #define ZFMT(pal, fcc, cs) \ | 100 | #define ZFMT(pal, fcc, cs) \ |
| 103 | .palette = (pal), .fourcc = (fcc), .colorspace = (cs) | 101 | .palette = (pal), .fourcc = (fcc), .colorspace = (cs) |
| 104 | #elif defined(CONFIG_VIDEO_V4L2) | ||
| 105 | #define ZFMT(pal, fcc, cs) \ | ||
| 106 | .fourcc = (fcc), .colorspace = (cs) | ||
| 107 | #else | 102 | #else |
| 108 | #define ZFMT(pal, fcc, cs) \ | 103 | #define ZFMT(pal, fcc, cs) \ |
| 109 | .palette = (pal) | 104 | .fourcc = (fcc), .colorspace = (cs) |
| 110 | #endif | 105 | #endif |
| 111 | 106 | ||
| 112 | const struct zoran_format zoran_formats[] = { | 107 | const struct zoran_format zoran_formats[] = { |
| @@ -205,11 +200,10 @@ extern int jpg_nbufs; | |||
| 205 | extern int jpg_bufsize; | 200 | extern int jpg_bufsize; |
| 206 | extern int pass_through; | 201 | extern int pass_through; |
| 207 | 202 | ||
| 208 | static int lock_norm = 0; /* 1=Don't change TV standard (norm) */ | 203 | static int lock_norm; /* 0 = default 1 = Don't change TV standard (norm) */ |
| 209 | module_param(lock_norm, int, 0644); | 204 | module_param(lock_norm, int, 0644); |
| 210 | MODULE_PARM_DESC(lock_norm, "Prevent norm changes (1 = ignore, >1 = fail)"); | 205 | MODULE_PARM_DESC(lock_norm, "Prevent norm changes (1 = ignore, >1 = fail)"); |
| 211 | 206 | ||
| 212 | #ifdef CONFIG_VIDEO_V4L2 | ||
| 213 | /* small helper function for calculating buffersizes for v4l2 | 207 | /* small helper function for calculating buffersizes for v4l2 |
| 214 | * we calculate the nearest higher power-of-two, which | 208 | * we calculate the nearest higher power-of-two, which |
| 215 | * will be the recommended buffersize */ | 209 | * will be the recommended buffersize */ |
| @@ -232,7 +226,6 @@ zoran_v4l2_calc_bufsize (struct zoran_jpg_settings *settings) | |||
| 232 | return 8192; | 226 | return 8192; |
| 233 | return result; | 227 | return result; |
| 234 | } | 228 | } |
| 235 | #endif | ||
| 236 | 229 | ||
| 237 | /* forward references */ | 230 | /* forward references */ |
| 238 | static void v4l_fbuffer_free(struct file *file); | 231 | static void v4l_fbuffer_free(struct file *file); |
| @@ -1709,7 +1702,6 @@ setup_overlay (struct file *file, | |||
| 1709 | return wait_grab_pending(zr); | 1702 | return wait_grab_pending(zr); |
| 1710 | } | 1703 | } |
| 1711 | 1704 | ||
| 1712 | #ifdef CONFIG_VIDEO_V4L2 | ||
| 1713 | /* get the status of a buffer in the clients buffer queue */ | 1705 | /* get the status of a buffer in the clients buffer queue */ |
| 1714 | static int | 1706 | static int |
| 1715 | zoran_v4l2_buffer_status (struct file *file, | 1707 | zoran_v4l2_buffer_status (struct file *file, |
| @@ -1815,7 +1807,6 @@ zoran_v4l2_buffer_status (struct file *file, | |||
| 1815 | 1807 | ||
| 1816 | return 0; | 1808 | return 0; |
| 1817 | } | 1809 | } |
| 1818 | #endif | ||
| 1819 | 1810 | ||
| 1820 | static int | 1811 | static int |
| 1821 | zoran_set_norm (struct zoran *zr, | 1812 | zoran_set_norm (struct zoran *zr, |
| @@ -2624,8 +2615,6 @@ zoran_do_ioctl (struct inode *inode, | |||
| 2624 | } | 2615 | } |
| 2625 | break; | 2616 | break; |
| 2626 | 2617 | ||
| 2627 | #ifdef CONFIG_VIDEO_V4L2 | ||
| 2628 | |||
| 2629 | /* The new video4linux2 capture interface - much nicer than video4linux1, since | 2618 | /* The new video4linux2 capture interface - much nicer than video4linux1, since |
| 2630 | * it allows for integrating the JPEG capturing calls inside standard v4l2 | 2619 | * it allows for integrating the JPEG capturing calls inside standard v4l2 |
| 2631 | */ | 2620 | */ |
| @@ -4197,7 +4186,6 @@ zoran_do_ioctl (struct inode *inode, | |||
| 4197 | return 0; | 4186 | return 0; |
| 4198 | } | 4187 | } |
| 4199 | break; | 4188 | break; |
| 4200 | #endif | ||
| 4201 | 4189 | ||
| 4202 | default: | 4190 | default: |
| 4203 | dprintk(1, KERN_DEBUG "%s: UNKNOWN ioctl cmd: 0x%x\n", | 4191 | dprintk(1, KERN_DEBUG "%s: UNKNOWN ioctl cmd: 0x%x\n", |
| @@ -4247,7 +4235,7 @@ zoran_poll (struct file *file, | |||
| 4247 | dprintk(3, | 4235 | dprintk(3, |
| 4248 | KERN_DEBUG | 4236 | KERN_DEBUG |
| 4249 | "%s: %s() raw - active=%c, sync_tail=%lu/%c, pend_tail=%lu, pend_head=%lu\n", | 4237 | "%s: %s() raw - active=%c, sync_tail=%lu/%c, pend_tail=%lu, pend_head=%lu\n", |
| 4250 | ZR_DEVNAME(zr), __FUNCTION__, | 4238 | ZR_DEVNAME(zr), __func__, |
| 4251 | "FAL"[fh->v4l_buffers.active], zr->v4l_sync_tail, | 4239 | "FAL"[fh->v4l_buffers.active], zr->v4l_sync_tail, |
| 4252 | "UPMD"[zr->v4l_buffers.buffer[frame].state], | 4240 | "UPMD"[zr->v4l_buffers.buffer[frame].state], |
| 4253 | zr->v4l_pend_tail, zr->v4l_pend_head); | 4241 | zr->v4l_pend_tail, zr->v4l_pend_head); |
| @@ -4269,7 +4257,7 @@ zoran_poll (struct file *file, | |||
| 4269 | dprintk(3, | 4257 | dprintk(3, |
| 4270 | KERN_DEBUG | 4258 | KERN_DEBUG |
| 4271 | "%s: %s() jpg - active=%c, que_tail=%lu/%c, que_head=%lu, dma=%lu/%lu\n", | 4259 | "%s: %s() jpg - active=%c, que_tail=%lu/%c, que_head=%lu, dma=%lu/%lu\n", |
| 4272 | ZR_DEVNAME(zr), __FUNCTION__, | 4260 | ZR_DEVNAME(zr), __func__, |
| 4273 | "FAL"[fh->jpg_buffers.active], zr->jpg_que_tail, | 4261 | "FAL"[fh->jpg_buffers.active], zr->jpg_que_tail, |
| 4274 | "UPMD"[zr->jpg_buffers.buffer[frame].state], | 4262 | "UPMD"[zr->jpg_buffers.buffer[frame].state], |
| 4275 | zr->jpg_que_head, zr->jpg_dma_tail, zr->jpg_dma_head); | 4263 | zr->jpg_que_head, zr->jpg_dma_tail, zr->jpg_dma_head); |
| @@ -4644,7 +4632,9 @@ static const struct file_operations zoran_fops = { | |||
| 4644 | .open = zoran_open, | 4632 | .open = zoran_open, |
| 4645 | .release = zoran_close, | 4633 | .release = zoran_close, |
| 4646 | .ioctl = zoran_ioctl, | 4634 | .ioctl = zoran_ioctl, |
| 4635 | #ifdef CONFIG_COMPAT | ||
| 4647 | .compat_ioctl = v4l_compat_ioctl32, | 4636 | .compat_ioctl = v4l_compat_ioctl32, |
| 4637 | #endif | ||
| 4648 | .llseek = no_llseek, | 4638 | .llseek = no_llseek, |
| 4649 | .read = zoran_read, | 4639 | .read = zoran_read, |
| 4650 | .write = zoran_write, | 4640 | .write = zoran_write, |
| @@ -4655,9 +4645,7 @@ static const struct file_operations zoran_fops = { | |||
| 4655 | struct video_device zoran_template __devinitdata = { | 4645 | struct video_device zoran_template __devinitdata = { |
| 4656 | .name = ZORAN_NAME, | 4646 | .name = ZORAN_NAME, |
| 4657 | .type = ZORAN_VID_TYPE, | 4647 | .type = ZORAN_VID_TYPE, |
| 4658 | #ifdef CONFIG_VIDEO_V4L2 | ||
| 4659 | .type2 = ZORAN_V4L2_VID_FLAGS, | 4648 | .type2 = ZORAN_V4L2_VID_FLAGS, |
| 4660 | #endif | ||
| 4661 | .fops = &zoran_fops, | 4649 | .fops = &zoran_fops, |
| 4662 | .release = &zoran_vdev_release, | 4650 | .release = &zoran_vdev_release, |
| 4663 | .minor = -1 | 4651 | .minor = -1 |
diff --git a/drivers/media/video/zr36016.c b/drivers/media/video/zr36016.c index dd084555da8f..00d132bcd1e4 100644 --- a/drivers/media/video/zr36016.c +++ b/drivers/media/video/zr36016.c | |||
| @@ -55,11 +55,10 @@ | |||
| 55 | #define MAX_CODECS 20 | 55 | #define MAX_CODECS 20 |
| 56 | 56 | ||
| 57 | /* amount of chips attached via this driver */ | 57 | /* amount of chips attached via this driver */ |
| 58 | static int zr36016_codecs = 0; | 58 | static int zr36016_codecs; |
| 59 | 59 | ||
| 60 | /* debugging is available via module parameter */ | 60 | /* debugging is available via module parameter */ |
| 61 | 61 | static int debug; | |
| 62 | static int debug = 0; | ||
| 63 | module_param(debug, int, 0); | 62 | module_param(debug, int, 0); |
| 64 | MODULE_PARM_DESC(debug, "Debug level (0-4)"); | 63 | MODULE_PARM_DESC(debug, "Debug level (0-4)"); |
| 65 | 64 | ||
diff --git a/drivers/media/video/zr36050.c b/drivers/media/video/zr36050.c index faae4ec3ea0b..cf8b271a1c8f 100644 --- a/drivers/media/video/zr36050.c +++ b/drivers/media/video/zr36050.c | |||
| @@ -52,11 +52,10 @@ | |||
| 52 | #define MAX_CODECS 20 | 52 | #define MAX_CODECS 20 |
| 53 | 53 | ||
| 54 | /* amount of chips attached via this driver */ | 54 | /* amount of chips attached via this driver */ |
| 55 | static int zr36050_codecs = 0; | 55 | static int zr36050_codecs; |
| 56 | 56 | ||
| 57 | /* debugging is available via module parameter */ | 57 | /* debugging is available via module parameter */ |
| 58 | 58 | static int debug; | |
| 59 | static int debug = 0; | ||
| 60 | module_param(debug, int, 0); | 59 | module_param(debug, int, 0); |
| 61 | MODULE_PARM_DESC(debug, "Debug level (0-4)"); | 60 | MODULE_PARM_DESC(debug, "Debug level (0-4)"); |
| 62 | 61 | ||
diff --git a/drivers/media/video/zr36060.c b/drivers/media/video/zr36060.c index 7849b65969d0..8e74054d5ef1 100644 --- a/drivers/media/video/zr36060.c +++ b/drivers/media/video/zr36060.c | |||
| @@ -52,14 +52,14 @@ | |||
| 52 | #define MAX_CODECS 20 | 52 | #define MAX_CODECS 20 |
| 53 | 53 | ||
| 54 | /* amount of chips attached via this driver */ | 54 | /* amount of chips attached via this driver */ |
| 55 | static int zr36060_codecs = 0; | 55 | static int zr36060_codecs; |
| 56 | 56 | ||
| 57 | static int low_bitrate = 0; | 57 | static int low_bitrate; |
| 58 | module_param(low_bitrate, bool, 0); | 58 | module_param(low_bitrate, bool, 0); |
| 59 | MODULE_PARM_DESC(low_bitrate, "Buz compatibility option, halves bitrate"); | 59 | MODULE_PARM_DESC(low_bitrate, "Buz compatibility option, halves bitrate"); |
| 60 | 60 | ||
| 61 | /* debugging is available via module parameter */ | 61 | /* debugging is available via module parameter */ |
| 62 | static int debug = 0; | 62 | static int debug; |
| 63 | module_param(debug, int, 0); | 63 | module_param(debug, int, 0); |
| 64 | MODULE_PARM_DESC(debug, "Debug level (0-4)"); | 64 | MODULE_PARM_DESC(debug, "Debug level (0-4)"); |
| 65 | 65 | ||
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c index 04949c823654..a0e49dc66301 100644 --- a/drivers/media/video/zr364xx.c +++ b/drivers/media/video/zr364xx.c | |||
| @@ -62,8 +62,8 @@ | |||
| 62 | 62 | ||
| 63 | 63 | ||
| 64 | /* Module parameters */ | 64 | /* Module parameters */ |
| 65 | static int debug = 0; | 65 | static int debug; |
| 66 | static int mode = 0; | 66 | static int mode; |
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | /* Module parameters interface */ | 69 | /* Module parameters interface */ |
diff --git a/include/linux/dvb/dmx.h b/include/linux/dvb/dmx.h index c6a2353c4e68..402fb7a8d922 100644 --- a/include/linux/dvb/dmx.h +++ b/include/linux/dvb/dmx.h | |||
| @@ -39,9 +39,10 @@ typedef enum | |||
| 39 | DMX_OUT_DECODER, /* Streaming directly to decoder. */ | 39 | DMX_OUT_DECODER, /* Streaming directly to decoder. */ |
| 40 | DMX_OUT_TAP, /* Output going to a memory buffer */ | 40 | DMX_OUT_TAP, /* Output going to a memory buffer */ |
| 41 | /* (to be retrieved via the read command).*/ | 41 | /* (to be retrieved via the read command).*/ |
| 42 | DMX_OUT_TS_TAP /* Output multiplexed into a new TS */ | 42 | DMX_OUT_TS_TAP, /* Output multiplexed into a new TS */ |
| 43 | /* (to be retrieved by reading from the */ | 43 | /* (to be retrieved by reading from the */ |
| 44 | /* logical DVR device). */ | 44 | /* logical DVR device). */ |
| 45 | DMX_OUT_TSDEMUX_TAP /* Like TS_TAP but retrieved from the DMX device */ | ||
| 45 | } dmx_output_t; | 46 | } dmx_output_t; |
| 46 | 47 | ||
| 47 | 48 | ||
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h index b979112f74e0..32eb8bbe4831 100644 --- a/include/linux/i2c-id.h +++ b/include/linux/i2c-id.h | |||
| @@ -125,6 +125,7 @@ | |||
| 125 | #define I2C_HW_B_CX2341X 0x010020 /* Conexant CX2341X MPEG encoder cards */ | 125 | #define I2C_HW_B_CX2341X 0x010020 /* Conexant CX2341X MPEG encoder cards */ |
| 126 | #define I2C_HW_B_INTELFB 0x010021 /* intel framebuffer driver */ | 126 | #define I2C_HW_B_INTELFB 0x010021 /* intel framebuffer driver */ |
| 127 | #define I2C_HW_B_CX23885 0x010022 /* conexant 23885 based tv cards (bus1) */ | 127 | #define I2C_HW_B_CX23885 0x010022 /* conexant 23885 based tv cards (bus1) */ |
| 128 | #define I2C_HW_B_AU0828 0x010023 /* auvitek au0828 usb bridge */ | ||
| 128 | 129 | ||
| 129 | /* --- PCF 8584 based algorithms */ | 130 | /* --- PCF 8584 based algorithms */ |
| 130 | #define I2C_HW_P_ELEK 0x020002 /* Elektor ISA Bus inteface card */ | 131 | #define I2C_HW_P_ELEK 0x020002 /* Elektor ISA Bus inteface card */ |
diff --git a/include/linux/meye.h b/include/linux/meye.h index 39fd9c8ddd4b..12010ace1f04 100644 --- a/include/linux/meye.h +++ b/include/linux/meye.h | |||
| @@ -58,7 +58,7 @@ struct meye_params { | |||
| 58 | 58 | ||
| 59 | /* V4L2 private controls */ | 59 | /* V4L2 private controls */ |
| 60 | #define V4L2_CID_AGC V4L2_CID_PRIVATE_BASE | 60 | #define V4L2_CID_AGC V4L2_CID_PRIVATE_BASE |
| 61 | #define V4L2_CID_SHARPNESS (V4L2_CID_PRIVATE_BASE + 1) | 61 | #define V4L2_CID_MEYE_SHARPNESS (V4L2_CID_PRIVATE_BASE + 1) |
| 62 | #define V4L2_CID_PICTURE (V4L2_CID_PRIVATE_BASE + 2) | 62 | #define V4L2_CID_PICTURE (V4L2_CID_PRIVATE_BASE + 2) |
| 63 | #define V4L2_CID_JPEGQUAL (V4L2_CID_PRIVATE_BASE + 3) | 63 | #define V4L2_CID_JPEGQUAL (V4L2_CID_PRIVATE_BASE + 3) |
| 64 | #define V4L2_CID_FRAMERATE (V4L2_CID_PRIVATE_BASE + 4) | 64 | #define V4L2_CID_FRAMERATE (V4L2_CID_PRIVATE_BASE + 4) |
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h index 17a80177a674..c1411189ba6c 100644 --- a/include/linux/videodev2.h +++ b/include/linux/videodev2.h | |||
| @@ -282,6 +282,7 @@ struct v4l2_pix_format | |||
| 282 | #define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */ | 282 | #define V4L2_PIX_FMT_BGR32 v4l2_fourcc('B','G','R','4') /* 32 BGR-8-8-8-8 */ |
| 283 | #define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */ | 283 | #define V4L2_PIX_FMT_RGB32 v4l2_fourcc('R','G','B','4') /* 32 RGB-8-8-8-8 */ |
| 284 | #define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */ | 284 | #define V4L2_PIX_FMT_GREY v4l2_fourcc('G','R','E','Y') /* 8 Greyscale */ |
| 285 | #define V4L2_PIX_FMT_Y16 v4l2_fourcc('Y','1','6',' ') /* 16 Greyscale */ | ||
| 285 | #define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P','A','L','8') /* 8 8-bit palette */ | 286 | #define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P','A','L','8') /* 8 8-bit palette */ |
| 286 | #define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */ | 287 | #define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y','V','U','9') /* 9 YVU 4:1:0 */ |
| 287 | #define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ | 288 | #define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y','V','1','2') /* 12 YVU 4:2:0 */ |
| @@ -308,6 +309,7 @@ struct v4l2_pix_format | |||
| 308 | 309 | ||
| 309 | /* see http://www.siliconimaging.com/RGB%20Bayer.htm */ | 310 | /* see http://www.siliconimaging.com/RGB%20Bayer.htm */ |
| 310 | #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ | 311 | #define V4L2_PIX_FMT_SBGGR8 v4l2_fourcc('B','A','8','1') /* 8 BGBG.. GRGR.. */ |
| 312 | #define V4L2_PIX_FMT_SBGGR16 v4l2_fourcc('B','Y','R','2') /* 16 BGBG.. GRGR.. */ | ||
| 311 | 313 | ||
| 312 | /* compressed formats */ | 314 | /* compressed formats */ |
| 313 | #define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ | 315 | #define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M','J','P','G') /* Motion-JPEG */ |
| @@ -793,6 +795,7 @@ struct v4l2_ext_controls | |||
| 793 | /* Values for ctrl_class field */ | 795 | /* Values for ctrl_class field */ |
| 794 | #define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ | 796 | #define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */ |
| 795 | #define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ | 797 | #define V4L2_CTRL_CLASS_MPEG 0x00990000 /* MPEG-compression controls */ |
| 798 | #define V4L2_CTRL_CLASS_CAMERA 0x009a0000 /* Camera class controls */ | ||
| 796 | 799 | ||
| 797 | #define V4L2_CTRL_ID_MASK (0x0fffffff) | 800 | #define V4L2_CTRL_ID_MASK (0x0fffffff) |
| 798 | #define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) | 801 | #define V4L2_CTRL_ID2CLASS(id) ((id) & 0x0fff0000UL) |
| @@ -849,21 +852,37 @@ struct v4l2_querymenu | |||
| 849 | #define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8) | 852 | #define V4L2_CID_AUDIO_TREBLE (V4L2_CID_BASE+8) |
| 850 | #define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9) | 853 | #define V4L2_CID_AUDIO_MUTE (V4L2_CID_BASE+9) |
| 851 | #define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10) | 854 | #define V4L2_CID_AUDIO_LOUDNESS (V4L2_CID_BASE+10) |
| 852 | #define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) | 855 | #define V4L2_CID_BLACK_LEVEL (V4L2_CID_BASE+11) /* Deprecated */ |
| 853 | #define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12) | 856 | #define V4L2_CID_AUTO_WHITE_BALANCE (V4L2_CID_BASE+12) |
| 854 | #define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13) | 857 | #define V4L2_CID_DO_WHITE_BALANCE (V4L2_CID_BASE+13) |
| 855 | #define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14) | 858 | #define V4L2_CID_RED_BALANCE (V4L2_CID_BASE+14) |
| 856 | #define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15) | 859 | #define V4L2_CID_BLUE_BALANCE (V4L2_CID_BASE+15) |
| 857 | #define V4L2_CID_GAMMA (V4L2_CID_BASE+16) | 860 | #define V4L2_CID_GAMMA (V4L2_CID_BASE+16) |
| 858 | #define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* ? Not sure */ | 861 | #define V4L2_CID_WHITENESS (V4L2_CID_GAMMA) /* Deprecated */ |
| 859 | #define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17) | 862 | #define V4L2_CID_EXPOSURE (V4L2_CID_BASE+17) |
| 860 | #define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18) | 863 | #define V4L2_CID_AUTOGAIN (V4L2_CID_BASE+18) |
| 861 | #define V4L2_CID_GAIN (V4L2_CID_BASE+19) | 864 | #define V4L2_CID_GAIN (V4L2_CID_BASE+19) |
| 862 | #define V4L2_CID_HFLIP (V4L2_CID_BASE+20) | 865 | #define V4L2_CID_HFLIP (V4L2_CID_BASE+20) |
| 863 | #define V4L2_CID_VFLIP (V4L2_CID_BASE+21) | 866 | #define V4L2_CID_VFLIP (V4L2_CID_BASE+21) |
| 864 | #define V4L2_CID_HCENTER (V4L2_CID_BASE+22) | 867 | |
| 865 | #define V4L2_CID_VCENTER (V4L2_CID_BASE+23) | 868 | /* Deprecated, use V4L2_CID_PAN_RESET and V4L2_CID_TILT_RESET */ |
| 866 | #define V4L2_CID_LASTP1 (V4L2_CID_BASE+24) /* last CID + 1 */ | 869 | #define V4L2_CID_HCENTER_DEPRECATED (V4L2_CID_BASE+22) |
| 870 | #define V4L2_CID_VCENTER_DEPRECATED (V4L2_CID_BASE+23) | ||
| 871 | |||
| 872 | #define V4L2_CID_POWER_LINE_FREQUENCY (V4L2_CID_BASE+24) | ||
| 873 | enum v4l2_power_line_frequency { | ||
| 874 | V4L2_CID_POWER_LINE_FREQUENCY_DISABLED = 0, | ||
| 875 | V4L2_CID_POWER_LINE_FREQUENCY_50HZ = 1, | ||
| 876 | V4L2_CID_POWER_LINE_FREQUENCY_60HZ = 2, | ||
| 877 | }; | ||
| 878 | #define V4L2_CID_HUE_AUTO (V4L2_CID_BASE+25) | ||
| 879 | #define V4L2_CID_WHITE_BALANCE_TEMPERATURE (V4L2_CID_BASE+26) | ||
| 880 | #define V4L2_CID_SHARPNESS (V4L2_CID_BASE+27) | ||
| 881 | #define V4L2_CID_BACKLIGHT_COMPENSATION (V4L2_CID_BASE+28) | ||
| 882 | #define V4L2_CID_CHROMA_AGC (V4L2_CID_BASE+29) | ||
| 883 | #define V4L2_CID_COLOR_KILLER (V4L2_CID_BASE+30) | ||
| 884 | /* last CID + 1 */ | ||
| 885 | #define V4L2_CID_LASTP1 (V4L2_CID_BASE+31) | ||
| 867 | 886 | ||
| 868 | /* MPEG-class control IDs defined by V4L2 */ | 887 | /* MPEG-class control IDs defined by V4L2 */ |
| 869 | #define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) | 888 | #define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) |
| @@ -1051,6 +1070,32 @@ enum v4l2_mpeg_cx2341x_video_median_filter_type { | |||
| 1051 | #define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10) | 1070 | #define V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (V4L2_CID_MPEG_CX2341X_BASE+10) |
| 1052 | #define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11) | 1071 | #define V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (V4L2_CID_MPEG_CX2341X_BASE+11) |
| 1053 | 1072 | ||
| 1073 | /* Camera class control IDs */ | ||
| 1074 | #define V4L2_CID_CAMERA_CLASS_BASE (V4L2_CTRL_CLASS_CAMERA | 0x900) | ||
| 1075 | #define V4L2_CID_CAMERA_CLASS (V4L2_CTRL_CLASS_CAMERA | 1) | ||
| 1076 | |||
| 1077 | #define V4L2_CID_EXPOSURE_AUTO (V4L2_CID_CAMERA_CLASS_BASE+1) | ||
| 1078 | enum v4l2_exposure_auto_type { | ||
| 1079 | V4L2_EXPOSURE_AUTO = 0, | ||
| 1080 | V4L2_EXPOSURE_MANUAL = 1, | ||
| 1081 | V4L2_EXPOSURE_SHUTTER_PRIORITY = 2, | ||
| 1082 | V4L2_EXPOSURE_APERTURE_PRIORITY = 3 | ||
| 1083 | }; | ||
| 1084 | #define V4L2_CID_EXPOSURE_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+2) | ||
| 1085 | #define V4L2_CID_EXPOSURE_AUTO_PRIORITY (V4L2_CID_CAMERA_CLASS_BASE+3) | ||
| 1086 | |||
| 1087 | #define V4L2_CID_PAN_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+4) | ||
| 1088 | #define V4L2_CID_TILT_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+5) | ||
| 1089 | #define V4L2_CID_PAN_RESET (V4L2_CID_CAMERA_CLASS_BASE+6) | ||
| 1090 | #define V4L2_CID_TILT_RESET (V4L2_CID_CAMERA_CLASS_BASE+7) | ||
| 1091 | |||
| 1092 | #define V4L2_CID_PAN_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+8) | ||
| 1093 | #define V4L2_CID_TILT_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+9) | ||
| 1094 | |||
| 1095 | #define V4L2_CID_FOCUS_ABSOLUTE (V4L2_CID_CAMERA_CLASS_BASE+10) | ||
| 1096 | #define V4L2_CID_FOCUS_RELATIVE (V4L2_CID_CAMERA_CLASS_BASE+11) | ||
| 1097 | #define V4L2_CID_FOCUS_AUTO (V4L2_CID_CAMERA_CLASS_BASE+12) | ||
| 1098 | |||
| 1054 | /* | 1099 | /* |
| 1055 | * T U N I N G | 1100 | * T U N I N G |
| 1056 | */ | 1101 | */ |
diff --git a/include/media/ir-common.h b/include/media/ir-common.h index a4274203f252..bfee8be5d63f 100644 --- a/include/media/ir-common.h +++ b/include/media/ir-common.h | |||
| @@ -107,6 +107,7 @@ extern IR_KEYTAB_TYPE ir_codes_avermedia[IR_KEYTAB_SIZE]; | |||
| 107 | extern IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE]; | 107 | extern IR_KEYTAB_TYPE ir_codes_avermedia_dvbt[IR_KEYTAB_SIZE]; |
| 108 | extern IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE]; | 108 | extern IR_KEYTAB_TYPE ir_codes_apac_viewcomp[IR_KEYTAB_SIZE]; |
| 109 | extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE]; | 109 | extern IR_KEYTAB_TYPE ir_codes_pixelview[IR_KEYTAB_SIZE]; |
| 110 | extern IR_KEYTAB_TYPE ir_codes_pixelview_new[IR_KEYTAB_SIZE]; | ||
| 110 | extern IR_KEYTAB_TYPE ir_codes_nebula[IR_KEYTAB_SIZE]; | 111 | extern IR_KEYTAB_TYPE ir_codes_nebula[IR_KEYTAB_SIZE]; |
| 111 | extern IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE]; | 112 | extern IR_KEYTAB_TYPE ir_codes_dntv_live_dvb_t[IR_KEYTAB_SIZE]; |
| 112 | extern IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE]; | 113 | extern IR_KEYTAB_TYPE ir_codes_iodata_bctv7e[IR_KEYTAB_SIZE]; |
| @@ -141,8 +142,10 @@ extern IR_KEYTAB_TYPE ir_codes_encore_enltv[IR_KEYTAB_SIZE]; | |||
| 141 | extern IR_KEYTAB_TYPE ir_codes_tt_1500[IR_KEYTAB_SIZE]; | 142 | extern IR_KEYTAB_TYPE ir_codes_tt_1500[IR_KEYTAB_SIZE]; |
| 142 | extern IR_KEYTAB_TYPE ir_codes_fusionhdtv_mce[IR_KEYTAB_SIZE]; | 143 | extern IR_KEYTAB_TYPE ir_codes_fusionhdtv_mce[IR_KEYTAB_SIZE]; |
| 143 | extern IR_KEYTAB_TYPE ir_codes_behold[IR_KEYTAB_SIZE]; | 144 | extern IR_KEYTAB_TYPE ir_codes_behold[IR_KEYTAB_SIZE]; |
| 145 | extern IR_KEYTAB_TYPE ir_codes_behold_columbus[IR_KEYTAB_SIZE]; | ||
| 144 | extern IR_KEYTAB_TYPE ir_codes_pinnacle_pctv_hd[IR_KEYTAB_SIZE]; | 146 | extern IR_KEYTAB_TYPE ir_codes_pinnacle_pctv_hd[IR_KEYTAB_SIZE]; |
| 145 | extern IR_KEYTAB_TYPE ir_codes_genius_tvgo_a11mce[IR_KEYTAB_SIZE]; | 147 | extern IR_KEYTAB_TYPE ir_codes_genius_tvgo_a11mce[IR_KEYTAB_SIZE]; |
| 148 | extern IR_KEYTAB_TYPE ir_codes_powercolor_real_angel[IR_KEYTAB_SIZE]; | ||
| 146 | 149 | ||
| 147 | #endif | 150 | #endif |
| 148 | 151 | ||
diff --git a/include/media/soc_camera.h b/include/media/soc_camera.h new file mode 100644 index 000000000000..6a8c8be7a1ae --- /dev/null +++ b/include/media/soc_camera.h | |||
| @@ -0,0 +1,179 @@ | |||
| 1 | /* | ||
| 2 | * camera image capture (abstract) bus driver header | ||
| 3 | * | ||
| 4 | * Copyright (C) 2006, Sascha Hauer, Pengutronix | ||
| 5 | * Copyright (C) 2008, Guennadi Liakhovetski <kernel@pengutronix.de> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License version 2 as | ||
| 9 | * published by the Free Software Foundation. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef SOC_CAMERA_H | ||
| 13 | #define SOC_CAMERA_H | ||
| 14 | |||
| 15 | #include <linux/videodev2.h> | ||
| 16 | #include <media/videobuf-dma-sg.h> | ||
| 17 | |||
| 18 | struct soc_camera_device { | ||
| 19 | struct list_head list; | ||
| 20 | struct device dev; | ||
| 21 | struct device *control; | ||
| 22 | unsigned short width; /* Current window */ | ||
| 23 | unsigned short height; /* sizes */ | ||
| 24 | unsigned short x_min; /* Camera capabilities */ | ||
| 25 | unsigned short y_min; | ||
| 26 | unsigned short x_current; /* Current window location */ | ||
| 27 | unsigned short y_current; | ||
| 28 | unsigned short width_min; | ||
| 29 | unsigned short width_max; | ||
| 30 | unsigned short height_min; | ||
| 31 | unsigned short height_max; | ||
| 32 | unsigned short y_skip_top; /* Lines to skip at the top */ | ||
| 33 | unsigned short gain; | ||
| 34 | unsigned short exposure; | ||
| 35 | unsigned char iface; /* Host number */ | ||
| 36 | unsigned char devnum; /* Device number per host */ | ||
| 37 | unsigned char buswidth; /* See comment in .c */ | ||
| 38 | struct soc_camera_ops *ops; | ||
| 39 | struct video_device *vdev; | ||
| 40 | const struct soc_camera_data_format *current_fmt; | ||
| 41 | const struct soc_camera_data_format *formats; | ||
| 42 | int num_formats; | ||
| 43 | struct module *owner; | ||
| 44 | /* soc_camera.c private count. Only accessed with video_lock held */ | ||
| 45 | int use_count; | ||
| 46 | }; | ||
| 47 | |||
| 48 | struct soc_camera_file { | ||
| 49 | struct soc_camera_device *icd; | ||
| 50 | struct videobuf_queue vb_vidq; | ||
| 51 | spinlock_t *lock; | ||
| 52 | }; | ||
| 53 | |||
| 54 | struct soc_camera_host { | ||
| 55 | struct list_head list; | ||
| 56 | struct device dev; | ||
| 57 | unsigned char nr; /* Host number */ | ||
| 58 | size_t msize; | ||
| 59 | struct videobuf_queue_ops *vbq_ops; | ||
| 60 | void *priv; | ||
| 61 | char *drv_name; | ||
| 62 | struct soc_camera_host_ops *ops; | ||
| 63 | }; | ||
| 64 | |||
| 65 | struct soc_camera_host_ops { | ||
| 66 | struct module *owner; | ||
| 67 | int (*add)(struct soc_camera_device *); | ||
| 68 | void (*remove)(struct soc_camera_device *); | ||
| 69 | int (*set_fmt_cap)(struct soc_camera_device *, __u32, | ||
| 70 | struct v4l2_rect *); | ||
| 71 | int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *); | ||
| 72 | int (*reqbufs)(struct soc_camera_file *, struct v4l2_requestbuffers *); | ||
| 73 | int (*querycap)(struct soc_camera_host *, struct v4l2_capability *); | ||
| 74 | int (*try_bus_param)(struct soc_camera_device *, __u32); | ||
| 75 | int (*set_bus_param)(struct soc_camera_device *, __u32); | ||
| 76 | unsigned int (*poll)(struct file *, poll_table *); | ||
| 77 | spinlock_t* (*spinlock_alloc)(struct soc_camera_file *); | ||
| 78 | void (*spinlock_free)(spinlock_t *); | ||
| 79 | }; | ||
| 80 | |||
| 81 | struct soc_camera_link { | ||
| 82 | /* Camera bus id, used to match a camera and a bus */ | ||
| 83 | int bus_id; | ||
| 84 | /* GPIO number to switch between 8 and 10 bit modes */ | ||
| 85 | unsigned int gpio; | ||
| 86 | }; | ||
| 87 | |||
| 88 | static inline struct soc_camera_device *to_soc_camera_dev(struct device *dev) | ||
| 89 | { | ||
| 90 | return container_of(dev, struct soc_camera_device, dev); | ||
| 91 | } | ||
| 92 | |||
| 93 | static inline struct soc_camera_host *to_soc_camera_host(struct device *dev) | ||
| 94 | { | ||
| 95 | return container_of(dev, struct soc_camera_host, dev); | ||
| 96 | } | ||
| 97 | |||
| 98 | extern int soc_camera_host_register(struct soc_camera_host *ici); | ||
| 99 | extern void soc_camera_host_unregister(struct soc_camera_host *ici); | ||
| 100 | extern int soc_camera_device_register(struct soc_camera_device *icd); | ||
| 101 | extern void soc_camera_device_unregister(struct soc_camera_device *icd); | ||
| 102 | |||
| 103 | extern int soc_camera_video_start(struct soc_camera_device *icd); | ||
| 104 | extern void soc_camera_video_stop(struct soc_camera_device *icd); | ||
| 105 | |||
| 106 | struct soc_camera_data_format { | ||
| 107 | char *name; | ||
| 108 | unsigned int depth; | ||
| 109 | __u32 fourcc; | ||
| 110 | enum v4l2_colorspace colorspace; | ||
| 111 | }; | ||
| 112 | |||
| 113 | struct soc_camera_ops { | ||
| 114 | struct module *owner; | ||
| 115 | int (*probe)(struct soc_camera_device *); | ||
| 116 | void (*remove)(struct soc_camera_device *); | ||
| 117 | int (*init)(struct soc_camera_device *); | ||
| 118 | int (*release)(struct soc_camera_device *); | ||
| 119 | int (*start_capture)(struct soc_camera_device *); | ||
| 120 | int (*stop_capture)(struct soc_camera_device *); | ||
| 121 | int (*set_fmt_cap)(struct soc_camera_device *, __u32, | ||
| 122 | struct v4l2_rect *); | ||
| 123 | int (*try_fmt_cap)(struct soc_camera_device *, struct v4l2_format *); | ||
| 124 | unsigned long (*query_bus_param)(struct soc_camera_device *); | ||
| 125 | int (*set_bus_param)(struct soc_camera_device *, unsigned long); | ||
| 126 | int (*get_chip_id)(struct soc_camera_device *, | ||
| 127 | struct v4l2_chip_ident *); | ||
| 128 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
| 129 | int (*get_register)(struct soc_camera_device *, struct v4l2_register *); | ||
| 130 | int (*set_register)(struct soc_camera_device *, struct v4l2_register *); | ||
| 131 | #endif | ||
| 132 | int (*get_control)(struct soc_camera_device *, struct v4l2_control *); | ||
| 133 | int (*set_control)(struct soc_camera_device *, struct v4l2_control *); | ||
| 134 | const struct v4l2_queryctrl *controls; | ||
| 135 | int num_controls; | ||
| 136 | }; | ||
| 137 | |||
| 138 | static inline struct v4l2_queryctrl const *soc_camera_find_qctrl( | ||
| 139 | struct soc_camera_ops *ops, int id) | ||
| 140 | { | ||
| 141 | int i; | ||
| 142 | |||
| 143 | for (i = 0; i < ops->num_controls; i++) | ||
| 144 | if (ops->controls[i].id == id) | ||
| 145 | return &ops->controls[i]; | ||
| 146 | |||
| 147 | return NULL; | ||
| 148 | } | ||
| 149 | |||
| 150 | #define SOCAM_MASTER (1 << 0) | ||
| 151 | #define SOCAM_SLAVE (1 << 1) | ||
| 152 | #define SOCAM_HSYNC_ACTIVE_HIGH (1 << 2) | ||
| 153 | #define SOCAM_HSYNC_ACTIVE_LOW (1 << 3) | ||
| 154 | #define SOCAM_VSYNC_ACTIVE_HIGH (1 << 4) | ||
| 155 | #define SOCAM_VSYNC_ACTIVE_LOW (1 << 5) | ||
| 156 | #define SOCAM_DATAWIDTH_8 (1 << 6) | ||
| 157 | #define SOCAM_DATAWIDTH_9 (1 << 7) | ||
| 158 | #define SOCAM_DATAWIDTH_10 (1 << 8) | ||
| 159 | #define SOCAM_PCLK_SAMPLE_RISING (1 << 9) | ||
| 160 | #define SOCAM_PCLK_SAMPLE_FALLING (1 << 10) | ||
| 161 | |||
| 162 | #define SOCAM_DATAWIDTH_MASK (SOCAM_DATAWIDTH_8 | SOCAM_DATAWIDTH_9 | \ | ||
| 163 | SOCAM_DATAWIDTH_10) | ||
| 164 | |||
| 165 | static inline unsigned long soc_camera_bus_param_compatible( | ||
| 166 | unsigned long camera_flags, unsigned long bus_flags) | ||
| 167 | { | ||
| 168 | unsigned long common_flags, hsync, vsync, pclk; | ||
| 169 | |||
| 170 | common_flags = camera_flags & bus_flags; | ||
| 171 | |||
| 172 | hsync = common_flags & (SOCAM_HSYNC_ACTIVE_HIGH | SOCAM_HSYNC_ACTIVE_LOW); | ||
| 173 | vsync = common_flags & (SOCAM_VSYNC_ACTIVE_HIGH | SOCAM_VSYNC_ACTIVE_LOW); | ||
| 174 | pclk = common_flags & (SOCAM_PCLK_SAMPLE_RISING | SOCAM_PCLK_SAMPLE_FALLING); | ||
| 175 | |||
| 176 | return (!hsync || !vsync || !pclk) ? 0 : common_flags; | ||
| 177 | } | ||
| 178 | |||
| 179 | #endif | ||
diff --git a/include/media/tuner-types.h b/include/media/tuner-types.h index b201371416a0..ab03c5344209 100644 --- a/include/media/tuner-types.h +++ b/include/media/tuner-types.h | |||
| @@ -6,10 +6,11 @@ | |||
| 6 | #define __TUNER_TYPES_H__ | 6 | #define __TUNER_TYPES_H__ |
| 7 | 7 | ||
| 8 | enum param_type { | 8 | enum param_type { |
| 9 | TUNER_PARAM_TYPE_RADIO, \ | 9 | TUNER_PARAM_TYPE_RADIO, |
| 10 | TUNER_PARAM_TYPE_PAL, \ | 10 | TUNER_PARAM_TYPE_PAL, |
| 11 | TUNER_PARAM_TYPE_SECAM, \ | 11 | TUNER_PARAM_TYPE_SECAM, |
| 12 | TUNER_PARAM_TYPE_NTSC | 12 | TUNER_PARAM_TYPE_NTSC, |
| 13 | TUNER_PARAM_TYPE_DIGITAL, | ||
| 13 | }; | 14 | }; |
| 14 | 15 | ||
| 15 | struct tuner_range { | 16 | struct tuner_range { |
| @@ -105,6 +106,7 @@ struct tuner_params { | |||
| 105 | the SECAM-L/L' standards. Range: -16:+15 */ | 106 | the SECAM-L/L' standards. Range: -16:+15 */ |
| 106 | signed int default_top_secam_high:5; | 107 | signed int default_top_secam_high:5; |
| 107 | 108 | ||
| 109 | u16 iffreq; | ||
| 108 | 110 | ||
| 109 | unsigned int count; | 111 | unsigned int count; |
| 110 | struct tuner_range *ranges; | 112 | struct tuner_range *ranges; |
| @@ -114,6 +116,13 @@ struct tunertype { | |||
| 114 | char *name; | 116 | char *name; |
| 115 | unsigned int count; | 117 | unsigned int count; |
| 116 | struct tuner_params *params; | 118 | struct tuner_params *params; |
| 119 | |||
| 120 | u16 min; | ||
| 121 | u16 max; | ||
| 122 | u32 stepsize; | ||
| 123 | |||
| 124 | u8 *initdata; | ||
| 125 | u8 *sleepdata; | ||
| 117 | }; | 126 | }; |
| 118 | 127 | ||
| 119 | extern struct tunertype tuners[]; | 128 | extern struct tunertype tuners[]; |
diff --git a/include/media/tuner.h b/include/media/tuner.h index 1bf24a6ed8f1..77068fcc86bd 100644 --- a/include/media/tuner.h +++ b/include/media/tuner.h | |||
| @@ -78,7 +78,7 @@ | |||
| 78 | 78 | ||
| 79 | #define TUNER_HITACHI_NTSC 40 | 79 | #define TUNER_HITACHI_NTSC 40 |
| 80 | #define TUNER_PHILIPS_PAL_MK 41 | 80 | #define TUNER_PHILIPS_PAL_MK 41 |
| 81 | #define TUNER_PHILIPS_ATSC 42 | 81 | #define TUNER_PHILIPS_FCV1236D 42 |
| 82 | #define TUNER_PHILIPS_FM1236_MK3 43 | 82 | #define TUNER_PHILIPS_FM1236_MK3 43 |
| 83 | 83 | ||
| 84 | #define TUNER_PHILIPS_4IN1 44 /* ATI TV Wonder Pro - Conexant */ | 84 | #define TUNER_PHILIPS_4IN1 44 /* ATI TV Wonder Pro - Conexant */ |
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h index 032bb75f69c2..0ea0bd85c036 100644 --- a/include/media/v4l2-chip-ident.h +++ b/include/media/v4l2-chip-ident.h | |||
| @@ -153,6 +153,12 @@ enum { | |||
| 153 | V4L2_IDENT_MSP4428G = 44287, | 153 | V4L2_IDENT_MSP4428G = 44287, |
| 154 | V4L2_IDENT_MSP4448G = 44487, | 154 | V4L2_IDENT_MSP4448G = 44487, |
| 155 | V4L2_IDENT_MSP4458G = 44587, | 155 | V4L2_IDENT_MSP4458G = 44587, |
| 156 | |||
| 157 | /* Micron CMOS sensor chips: 45000-45099 */ | ||
| 158 | V4L2_IDENT_MT9M001C12ST = 45000, | ||
| 159 | V4L2_IDENT_MT9M001C12STM = 45005, | ||
| 160 | V4L2_IDENT_MT9V022IX7ATC = 45010, /* No way to detect "normal" I77ATx */ | ||
| 161 | V4L2_IDENT_MT9V022IX7ATM = 45015, /* and "lead free" IA7ATx chips */ | ||
| 156 | }; | 162 | }; |
| 157 | 163 | ||
| 158 | #endif | 164 | #endif |
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index f2114459995d..a807d2f86ee8 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h | |||
| @@ -318,6 +318,10 @@ struct video_device | |||
| 318 | int (*vidioc_g_chip_ident) (struct file *file, void *fh, | 318 | int (*vidioc_g_chip_ident) (struct file *file, void *fh, |
| 319 | struct v4l2_chip_ident *chip); | 319 | struct v4l2_chip_ident *chip); |
| 320 | 320 | ||
| 321 | /* For other private ioctls */ | ||
| 322 | int (*vidioc_default) (struct file *file, void *fh, | ||
| 323 | int cmd, void *arg); | ||
| 324 | |||
| 321 | 325 | ||
| 322 | #ifdef OBSOLETE_OWNER /* to be removed soon */ | 326 | #ifdef OBSOLETE_OWNER /* to be removed soon */ |
| 323 | /* obsolete -- fops->owner is used instead */ | 327 | /* obsolete -- fops->owner is used instead */ |
diff --git a/include/media/videobuf-core.h b/include/media/videobuf-core.h index 99033945cdee..5b39a22533fe 100644 --- a/include/media/videobuf-core.h +++ b/include/media/videobuf-core.h | |||
| @@ -13,6 +13,9 @@ | |||
| 13 | * the Free Software Foundation; either version 2 | 13 | * the Free Software Foundation; either version 2 |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #ifndef _VIDEOBUF_CORE_H | ||
| 17 | #define _VIDEOBUF_CORE_H | ||
| 18 | |||
| 16 | #include <linux/poll.h> | 19 | #include <linux/poll.h> |
| 17 | #ifdef CONFIG_VIDEO_V4L1_COMPAT | 20 | #ifdef CONFIG_VIDEO_V4L1_COMPAT |
| 18 | #include <linux/videodev.h> | 21 | #include <linux/videodev.h> |
| @@ -123,7 +126,8 @@ struct videobuf_queue_ops { | |||
| 123 | struct videobuf_qtype_ops { | 126 | struct videobuf_qtype_ops { |
| 124 | u32 magic; | 127 | u32 magic; |
| 125 | 128 | ||
| 126 | void* (*alloc) (size_t size); | 129 | void *(*alloc) (size_t size); |
| 130 | void *(*vmalloc) (struct videobuf_buffer *buf); | ||
| 127 | int (*iolock) (struct videobuf_queue* q, | 131 | int (*iolock) (struct videobuf_queue* q, |
| 128 | struct videobuf_buffer *vb, | 132 | struct videobuf_buffer *vb, |
| 129 | struct v4l2_framebuffer *fbuf); | 133 | struct v4l2_framebuffer *fbuf); |
| @@ -151,7 +155,9 @@ struct videobuf_qtype_ops { | |||
| 151 | struct videobuf_queue { | 155 | struct videobuf_queue { |
| 152 | struct mutex vb_lock; | 156 | struct mutex vb_lock; |
| 153 | spinlock_t *irqlock; | 157 | spinlock_t *irqlock; |
| 154 | void *dev; /* on pci, points to struct pci_dev */ | 158 | struct device *dev; |
| 159 | |||
| 160 | wait_queue_head_t wait; /* wait if queue is empty */ | ||
| 155 | 161 | ||
| 156 | enum v4l2_buf_type type; | 162 | enum v4l2_buf_type type; |
| 157 | unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */ | 163 | unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */ |
| @@ -183,9 +189,13 @@ int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb, | |||
| 183 | 189 | ||
| 184 | void *videobuf_alloc(struct videobuf_queue* q); | 190 | void *videobuf_alloc(struct videobuf_queue* q); |
| 185 | 191 | ||
| 192 | /* Used on videobuf-dvb */ | ||
| 193 | void *videobuf_queue_to_vmalloc (struct videobuf_queue* q, | ||
| 194 | struct videobuf_buffer *buf); | ||
| 195 | |||
| 186 | void videobuf_queue_core_init(struct videobuf_queue *q, | 196 | void videobuf_queue_core_init(struct videobuf_queue *q, |
| 187 | struct videobuf_queue_ops *ops, | 197 | struct videobuf_queue_ops *ops, |
| 188 | void *dev, | 198 | struct device *dev, |
| 189 | spinlock_t *irqlock, | 199 | spinlock_t *irqlock, |
| 190 | enum v4l2_buf_type type, | 200 | enum v4l2_buf_type type, |
| 191 | enum v4l2_field field, | 201 | enum v4l2_field field, |
| @@ -231,10 +241,4 @@ int videobuf_mmap_free(struct videobuf_queue *q); | |||
| 231 | int videobuf_mmap_mapper(struct videobuf_queue *q, | 241 | int videobuf_mmap_mapper(struct videobuf_queue *q, |
| 232 | struct vm_area_struct *vma); | 242 | struct vm_area_struct *vma); |
| 233 | 243 | ||
| 234 | /* --------------------------------------------------------------------- */ | 244 | #endif |
| 235 | |||
| 236 | /* | ||
| 237 | * Local variables: | ||
| 238 | * c-basic-offset: 8 | ||
| 239 | * End: | ||
| 240 | */ | ||
diff --git a/include/media/videobuf-dma-sg.h b/include/media/videobuf-dma-sg.h index 38105031db23..be8da269ee33 100644 --- a/include/media/videobuf-dma-sg.h +++ b/include/media/videobuf-dma-sg.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * helper functions for PCI DMA video4linux capture buffers | 2 | * helper functions for SG DMA video4linux capture buffers |
| 3 | * | 3 | * |
| 4 | * The functions expect the hardware being able to scatter gatter | 4 | * The functions expect the hardware being able to scatter gatter |
| 5 | * (i.e. the buffers are not linear in physical memory, but fragmented | 5 | * (i.e. the buffers are not linear in physical memory, but fragmented |
| @@ -68,9 +68,6 @@ struct videobuf_dmabuf { | |||
| 68 | /* for kernel buffers */ | 68 | /* for kernel buffers */ |
| 69 | void *vmalloc; | 69 | void *vmalloc; |
| 70 | 70 | ||
| 71 | /* Stores the userspace pointer to vmalloc area */ | ||
| 72 | void *varea; | ||
| 73 | |||
| 74 | /* for overlay buffers (pci-pci dma) */ | 71 | /* for overlay buffers (pci-pci dma) */ |
| 75 | dma_addr_t bus_addr; | 72 | dma_addr_t bus_addr; |
| 76 | 73 | ||
| @@ -81,7 +78,7 @@ struct videobuf_dmabuf { | |||
| 81 | int direction; | 78 | int direction; |
| 82 | }; | 79 | }; |
| 83 | 80 | ||
| 84 | struct videbuf_pci_sg_memory | 81 | struct videobuf_dma_sg_memory |
| 85 | { | 82 | { |
| 86 | u32 magic; | 83 | u32 magic; |
| 87 | 84 | ||
| @@ -103,11 +100,11 @@ int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma); | |||
| 103 | int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma); | 100 | int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma); |
| 104 | struct videobuf_dmabuf *videobuf_to_dma (struct videobuf_buffer *buf); | 101 | struct videobuf_dmabuf *videobuf_to_dma (struct videobuf_buffer *buf); |
| 105 | 102 | ||
| 106 | void *videobuf_pci_alloc (size_t size); | 103 | void *videobuf_sg_alloc(size_t size); |
| 107 | 104 | ||
| 108 | void videobuf_queue_pci_init(struct videobuf_queue* q, | 105 | void videobuf_queue_sg_init(struct videobuf_queue* q, |
| 109 | struct videobuf_queue_ops *ops, | 106 | struct videobuf_queue_ops *ops, |
| 110 | void *dev, | 107 | struct device *dev, |
| 111 | spinlock_t *irqlock, | 108 | spinlock_t *irqlock, |
| 112 | enum v4l2_buf_type type, | 109 | enum v4l2_buf_type type, |
| 113 | enum v4l2_field field, | 110 | enum v4l2_field field, |
| @@ -117,6 +114,6 @@ void videobuf_queue_pci_init(struct videobuf_queue* q, | |||
| 117 | /*FIXME: these variants are used only on *-alsa code, where videobuf is | 114 | /*FIXME: these variants are used only on *-alsa code, where videobuf is |
| 118 | * used without queue | 115 | * used without queue |
| 119 | */ | 116 | */ |
| 120 | int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma); | 117 | int videobuf_sg_dma_map(struct device *dev, struct videobuf_dmabuf *dma); |
| 121 | int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma); | 118 | int videobuf_sg_dma_unmap(struct device *dev, struct videobuf_dmabuf *dma); |
| 122 | 119 | ||
diff --git a/include/media/videobuf-dvb.h b/include/media/videobuf-dvb.h index 8233cafdeef6..b77748696329 100644 --- a/include/media/videobuf-dvb.h +++ b/include/media/videobuf-dvb.h | |||
| @@ -27,7 +27,8 @@ struct videobuf_dvb { | |||
| 27 | int videobuf_dvb_register(struct videobuf_dvb *dvb, | 27 | int videobuf_dvb_register(struct videobuf_dvb *dvb, |
| 28 | struct module *module, | 28 | struct module *module, |
| 29 | void *adapter_priv, | 29 | void *adapter_priv, |
| 30 | struct device *device); | 30 | struct device *device, |
| 31 | short *adapter_nr); | ||
| 31 | void videobuf_dvb_unregister(struct videobuf_dvb *dvb); | 32 | void videobuf_dvb_unregister(struct videobuf_dvb *dvb); |
| 32 | 33 | ||
| 33 | /* | 34 | /* |
diff --git a/include/media/videobuf-vmalloc.h b/include/media/videobuf-vmalloc.h index ec63ab0fab93..aed39460c154 100644 --- a/include/media/videobuf-vmalloc.h +++ b/include/media/videobuf-vmalloc.h | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 | 13 | * the Free Software Foundation; either version 2 |
| 14 | */ | 14 | */ |
| 15 | #ifndef _VIDEOBUF_VMALLOC_H | ||
| 16 | #define _VIDEOBUF_VMALLOC_H | ||
| 15 | 17 | ||
| 16 | #include <media/videobuf-core.h> | 18 | #include <media/videobuf-core.h> |
| 17 | 19 | ||
| @@ -39,3 +41,5 @@ void videobuf_queue_vmalloc_init(struct videobuf_queue* q, | |||
| 39 | void *videobuf_to_vmalloc (struct videobuf_buffer *buf); | 41 | void *videobuf_to_vmalloc (struct videobuf_buffer *buf); |
| 40 | 42 | ||
| 41 | void videobuf_vmalloc_free (struct videobuf_buffer *buf); | 43 | void videobuf_vmalloc_free (struct videobuf_buffer *buf); |
| 44 | |||
| 45 | #endif | ||
