Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
1da177e4 LT |
2 | * |
3 | * v4l2 device driver for philips saa7134 based TV cards | |
4 | * | |
5 | * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> | |
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 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
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 | ||
1990d50b | 22 | #define SAA7134_VERSION "0, 2, 17" |
1da177e4 LT |
23 | |
24 | #include <linux/pci.h> | |
25 | #include <linux/i2c.h> | |
79436633 | 26 | #include <linux/videodev2.h> |
1da177e4 LT |
27 | #include <linux/kdev_t.h> |
28 | #include <linux/input.h> | |
67081a46 MK |
29 | #include <linux/notifier.h> |
30 | #include <linux/delay.h> | |
3593cab5 | 31 | #include <linux/mutex.h> |
1da177e4 LT |
32 | |
33 | #include <asm/io.h> | |
34 | ||
401998fa | 35 | #include <media/v4l2-common.h> |
35ea11ff | 36 | #include <media/v4l2-ioctl.h> |
fac6986c | 37 | #include <media/v4l2-device.h> |
1da177e4 | 38 | #include <media/tuner.h> |
6bda9644 | 39 | #include <media/rc-core.h> |
ac9cd976 | 40 | #include <media/ir-kbd-i2c.h> |
c1accaa2 | 41 | #include <media/videobuf-dma-sg.h> |
d21838dd MCC |
42 | #include <sound/core.h> |
43 | #include <sound/pcm.h> | |
5a3ebe87 | 44 | #if defined(CONFIG_VIDEO_SAA7134_DVB) || defined(CONFIG_VIDEO_SAA7134_DVB_MODULE) |
ba366a23 | 45 | #include <media/videobuf-dvb.h> |
05ad3907 | 46 | #endif |
1da177e4 | 47 | |
1da177e4 LT |
48 | #define UNSET (-1U) |
49 | ||
1da177e4 LT |
50 | /* ----------------------------------------------------------- */ |
51 | /* enums */ | |
52 | ||
53 | enum saa7134_tvaudio_mode { | |
54 | TVAUDIO_FM_MONO = 1, | |
55 | TVAUDIO_FM_BG_STEREO = 2, | |
56 | TVAUDIO_FM_SAT_STEREO = 3, | |
57 | TVAUDIO_FM_K_STEREO = 4, | |
58 | TVAUDIO_NICAM_AM = 5, | |
59 | TVAUDIO_NICAM_FM = 6, | |
60 | }; | |
61 | ||
62 | enum saa7134_audio_in { | |
63 | TV = 1, | |
64 | LINE1 = 2, | |
65 | LINE2 = 3, | |
66 | LINE2_LEFT, | |
67 | }; | |
68 | ||
69 | enum saa7134_video_out { | |
70 | CCIR656 = 1, | |
71 | }; | |
72 | ||
73 | /* ----------------------------------------------------------- */ | |
74 | /* static data */ | |
75 | ||
76 | struct saa7134_tvnorm { | |
77 | char *name; | |
78 | v4l2_std_id id; | |
79 | ||
80 | /* video decoder */ | |
81 | unsigned int sync_control; | |
82 | unsigned int luma_control; | |
83 | unsigned int chroma_ctrl1; | |
84 | unsigned int chroma_gain; | |
85 | unsigned int chroma_ctrl2; | |
86 | unsigned int vgate_misc; | |
87 | ||
88 | /* video scaler */ | |
89 | unsigned int h_start; | |
90 | unsigned int h_stop; | |
91 | unsigned int video_v_start; | |
92 | unsigned int video_v_stop; | |
f246a817 MS |
93 | unsigned int vbi_v_start_0; |
94 | unsigned int vbi_v_stop_0; | |
1da177e4 | 95 | unsigned int src_timing; |
f246a817 | 96 | unsigned int vbi_v_start_1; |
1da177e4 LT |
97 | }; |
98 | ||
99 | struct saa7134_tvaudio { | |
100 | char *name; | |
101 | v4l2_std_id std; | |
102 | enum saa7134_tvaudio_mode mode; | |
103 | int carr1; | |
104 | int carr2; | |
105 | }; | |
106 | ||
107 | struct saa7134_format { | |
108 | char *name; | |
109 | unsigned int fourcc; | |
110 | unsigned int depth; | |
111 | unsigned int pm; | |
112 | unsigned int vshift; /* vertical downsampling (for planar yuv) */ | |
113 | unsigned int hshift; /* horizontal downsampling (for planar yuv) */ | |
114 | unsigned int bswap:1; | |
115 | unsigned int wswap:1; | |
116 | unsigned int yuv:1; | |
117 | unsigned int planar:1; | |
118 | unsigned int uvswap:1; | |
119 | }; | |
120 | ||
a6e3b81f MCC |
121 | struct saa7134_card_ir { |
122 | struct rc_dev *dev; | |
123 | ||
124 | char name[32]; | |
125 | char phys[32]; | |
651c7a5f | 126 | unsigned users; |
a6e3b81f MCC |
127 | |
128 | u32 polling; | |
25fa2071 KS |
129 | u32 last_gpio; |
130 | u32 mask_keycode, mask_keydown, mask_keyup; | |
a6e3b81f MCC |
131 | |
132 | bool running; | |
a6e3b81f MCC |
133 | |
134 | struct timer_list timer; | |
a6e3b81f MCC |
135 | |
136 | /* IR core raw decoding */ | |
137 | u32 raw_decode; | |
138 | }; | |
139 | ||
1da177e4 LT |
140 | /* ----------------------------------------------------------- */ |
141 | /* card configuration */ | |
142 | ||
143 | #define SAA7134_BOARD_NOAUTO UNSET | |
144 | #define SAA7134_BOARD_UNKNOWN 0 | |
145 | #define SAA7134_BOARD_PROTEUS_PRO 1 | |
146 | #define SAA7134_BOARD_FLYVIDEO3000 2 | |
147 | #define SAA7134_BOARD_FLYVIDEO2000 3 | |
148 | #define SAA7134_BOARD_EMPRESS 4 | |
149 | #define SAA7134_BOARD_MONSTERTV 5 | |
150 | #define SAA7134_BOARD_MD9717 6 | |
151 | #define SAA7134_BOARD_TVSTATION_RDS 7 | |
152 | #define SAA7134_BOARD_CINERGY400 8 | |
153 | #define SAA7134_BOARD_MD5044 9 | |
154 | #define SAA7134_BOARD_KWORLD 10 | |
155 | #define SAA7134_BOARD_CINERGY600 11 | |
156 | #define SAA7134_BOARD_MD7134 12 | |
157 | #define SAA7134_BOARD_TYPHOON_90031 13 | |
158 | #define SAA7134_BOARD_ELSA 14 | |
159 | #define SAA7134_BOARD_ELSA_500TV 15 | |
160 | #define SAA7134_BOARD_ASUSTeK_TVFM7134 16 | |
161 | #define SAA7134_BOARD_VA1000POWER 17 | |
162 | #define SAA7134_BOARD_BMK_MPEX_NOTUNER 18 | |
163 | #define SAA7134_BOARD_VIDEOMATE_TV 19 | |
164 | #define SAA7134_BOARD_CRONOS_PLUS 20 | |
165 | #define SAA7134_BOARD_10MOONSTVMASTER 21 | |
166 | #define SAA7134_BOARD_MD2819 22 | |
167 | #define SAA7134_BOARD_BMK_MPEX_TUNER 23 | |
168 | #define SAA7134_BOARD_TVSTATION_DVR 24 | |
169 | #define SAA7134_BOARD_ASUSTEK_TVFM7133 25 | |
170 | #define SAA7134_BOARD_PINNACLE_PCTV_STEREO 26 | |
171 | #define SAA7134_BOARD_MANLI_MTV002 27 | |
172 | #define SAA7134_BOARD_MANLI_MTV001 28 | |
173 | #define SAA7134_BOARD_TG3000TV 29 | |
174 | #define SAA7134_BOARD_ECS_TVP3XP 30 | |
175 | #define SAA7134_BOARD_ECS_TVP3XP_4CB5 31 | |
176 | #define SAA7134_BOARD_AVACSSMARTTV 32 | |
177 | #define SAA7134_BOARD_AVERMEDIA_DVD_EZMAKER 33 | |
178 | #define SAA7134_BOARD_NOVAC_PRIMETV7133 34 | |
179 | #define SAA7134_BOARD_AVERMEDIA_STUDIO_305 35 | |
330a115a | 180 | #define SAA7134_BOARD_UPMOST_PURPLE_TV 36 |
1da177e4 LT |
181 | #define SAA7134_BOARD_ITEMS_MTV005 37 |
182 | #define SAA7134_BOARD_CINERGY200 38 | |
183 | #define SAA7134_BOARD_FLYTVPLATINUM_MINI 39 | |
184 | #define SAA7134_BOARD_VIDEOMATE_TV_PVR 40 | |
185 | #define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUS 41 | |
186 | #define SAA7134_BOARD_SABRENT_SBTTVFM 42 | |
187 | #define SAA7134_BOARD_ZOLID_XPERT_TV7134 43 | |
188 | #define SAA7134_BOARD_EMPIRE_PCI_TV_RADIO_LE 44 | |
ac19ecc6 | 189 | #define SAA7134_BOARD_AVERMEDIA_STUDIO_307 45 |
1da177e4 LT |
190 | #define SAA7134_BOARD_AVERMEDIA_CARDBUS 46 |
191 | #define SAA7134_BOARD_CINERGY400_CARDBUS 47 | |
192 | #define SAA7134_BOARD_CINERGY600_MK3 48 | |
193 | #define SAA7134_BOARD_VIDEOMATE_GOLD_PLUS 49 | |
194 | #define SAA7134_BOARD_PINNACLE_300I_DVBT_PAL 50 | |
195 | #define SAA7134_BOARD_PROVIDEO_PV952 51 | |
196 | #define SAA7134_BOARD_AVERMEDIA_305 52 | |
330a115a | 197 | #define SAA7134_BOARD_ASUSTeK_TVFM7135 53 |
1da177e4 LT |
198 | #define SAA7134_BOARD_FLYTVPLATINUM_FM 54 |
199 | #define SAA7134_BOARD_FLYDVBTDUO 55 | |
ac19ecc6 MCC |
200 | #define SAA7134_BOARD_AVERMEDIA_307 56 |
201 | #define SAA7134_BOARD_AVERMEDIA_GO_007_FM 57 | |
202 | #define SAA7134_BOARD_ADS_INSTANT_TV 58 | |
203 | #define SAA7134_BOARD_KWORLD_VSTREAM_XPERT 59 | |
de7e8d78 | 204 | #define SAA7134_BOARD_FLYDVBT_DUO_CARDBUS 60 |
330a115a MCC |
205 | #define SAA7134_BOARD_PHILIPS_TOUGH 61 |
206 | #define SAA7134_BOARD_VIDEOMATE_TV_GOLD_PLUSII 62 | |
207 | #define SAA7134_BOARD_KWORLD_XPERT 63 | |
2f180710 | 208 | #define SAA7134_BOARD_FLYTV_DIGIMATRIX 64 |
260784dc | 209 | #define SAA7134_BOARD_KWORLD_TERMINATOR 65 |
4279f024 | 210 | #define SAA7134_BOARD_YUAN_TUN900 66 |
a8ff417e | 211 | #define SAA7134_BOARD_BEHOLD_409FM 67 |
6b961440 | 212 | #define SAA7134_BOARD_GOTVIEW_7135 68 |
2cf36ac4 HH |
213 | #define SAA7134_BOARD_PHILIPS_EUROPA 69 |
214 | #define SAA7134_BOARD_VIDEOMATE_DVBT_300 70 | |
215 | #define SAA7134_BOARD_VIDEOMATE_DVBT_200 71 | |
bb881f14 NS |
216 | #define SAA7134_BOARD_RTD_VFG7350 72 |
217 | #define SAA7134_BOARD_RTD_VFG7330 73 | |
058afaf8 | 218 | #define SAA7134_BOARD_FLYTVPLATINUM_MINI2 74 |
76bc3a39 | 219 | #define SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180 75 |
cf1c5d1d | 220 | #define SAA7134_BOARD_MONSTERTV_MOBILE 76 |
c2f6f9d8 | 221 | #define SAA7134_BOARD_PINNACLE_PCTV_110i 77 |
28f02241 | 222 | #define SAA7134_BOARD_ASUSTeK_P7131_DUAL 78 |
17ce1ff9 | 223 | #define SAA7134_BOARD_SEDNA_PC_TV_CARDBUS 79 |
5d5c9904 | 224 | #define SAA7134_BOARD_ASUSTEK_DIGIMATRIX_TV 80 |
90e9df7f | 225 | #define SAA7134_BOARD_PHILIPS_TIGER 81 |
80d2ad92 | 226 | #define SAA7134_BOARD_MSI_TVATANYWHERE_PLUS 82 |