diff options
Diffstat (limited to 'drivers/media/video/bt8xx')
-rw-r--r-- | drivers/media/video/bt8xx/Kconfig | 27 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/Makefile | 13 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bt848.h | 369 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-audio-hook.c | 382 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-audio-hook.h | 23 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-cards.c | 4895 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-driver.c | 4630 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-gpio.c | 189 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-i2c.c | 397 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-if.c | 121 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-input.c | 589 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-risc.c | 909 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv-vbi.c | 459 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttv.h | 376 | ||||
-rw-r--r-- | drivers/media/video/bt8xx/bttvp.h | 535 |
15 files changed, 0 insertions, 13914 deletions
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig deleted file mode 100644 index 7da5c2e1fc12..000000000000 --- a/drivers/media/video/bt8xx/Kconfig +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | config VIDEO_BT848 | ||
2 | tristate "BT848 Video For Linux" | ||
3 | depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2 | ||
4 | select I2C_ALGOBIT | ||
5 | select VIDEO_BTCX | ||
6 | select VIDEOBUF_DMA_SG | ||
7 | depends on RC_CORE | ||
8 | select VIDEO_TUNER | ||
9 | select VIDEO_TVEEPROM | ||
10 | select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO | ||
11 | select VIDEO_TVAUDIO if VIDEO_HELPER_CHIPS_AUTO | ||
12 | select VIDEO_TDA7432 if VIDEO_HELPER_CHIPS_AUTO | ||
13 | select VIDEO_SAA6588 if VIDEO_HELPER_CHIPS_AUTO | ||
14 | ---help--- | ||
15 | Support for BT848 based frame grabber/overlay boards. This includes | ||
16 | the Miro, Hauppauge and STB boards. Please read the material in | ||
17 | <file:Documentation/video4linux/bttv/> for more information. | ||
18 | |||
19 | To compile this driver as a module, choose M here: the | ||
20 | module will be called bttv. | ||
21 | |||
22 | config VIDEO_BT848_DVB | ||
23 | bool "DVB/ATSC Support for bt878 based TV cards" | ||
24 | depends on VIDEO_BT848 && DVB_CORE | ||
25 | select DVB_BT8XX | ||
26 | ---help--- | ||
27 | This adds support for DVB/ATSC cards based on the BT878 chip. | ||
diff --git a/drivers/media/video/bt8xx/Makefile b/drivers/media/video/bt8xx/Makefile deleted file mode 100644 index f6351a25c267..000000000000 --- a/drivers/media/video/bt8xx/Makefile +++ /dev/null | |||
@@ -1,13 +0,0 @@ | |||
1 | # | ||
2 | # Makefile for the video capture/playback device drivers. | ||
3 | # | ||
4 | |||
5 | bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \ | ||
6 | bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o \ | ||
7 | bttv-input.o bttv-audio-hook.o | ||
8 | |||
9 | obj-$(CONFIG_VIDEO_BT848) += bttv.o | ||
10 | |||
11 | ccflags-y += -Idrivers/media/video | ||
12 | ccflags-y += -Idrivers/media/tuners | ||
13 | ccflags-y += -Idrivers/media/dvb-core | ||
diff --git a/drivers/media/video/bt8xx/bt848.h b/drivers/media/video/bt8xx/bt848.h deleted file mode 100644 index c37e6acffded..000000000000 --- a/drivers/media/video/bt8xx/bt848.h +++ /dev/null | |||
@@ -1,369 +0,0 @@ | |||
1 | /* | ||
2 | bt848.h - Bt848 register offsets | ||
3 | |||
4 | Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.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 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 | #ifndef _BT848_H_ | ||
22 | #define _BT848_H_ | ||
23 | |||
24 | #ifndef PCI_VENDOR_ID_BROOKTREE | ||
25 | #define PCI_VENDOR_ID_BROOKTREE 0x109e | ||
26 | #endif | ||
27 | #ifndef PCI_DEVICE_ID_BT848 | ||
28 | #define PCI_DEVICE_ID_BT848 0x350 | ||
29 | #endif | ||
30 | #ifndef PCI_DEVICE_ID_BT849 | ||
31 | #define PCI_DEVICE_ID_BT849 0x351 | ||
32 | #endif | ||
33 | #ifndef PCI_DEVICE_ID_FUSION879 | ||
34 | #define PCI_DEVICE_ID_FUSION879 0x36c | ||
35 | #endif | ||
36 | |||
37 | #ifndef PCI_DEVICE_ID_BT878 | ||
38 | #define PCI_DEVICE_ID_BT878 0x36e | ||
39 | #endif | ||
40 | #ifndef PCI_DEVICE_ID_BT879 | ||
41 | #define PCI_DEVICE_ID_BT879 0x36f | ||
42 | #endif | ||
43 | |||
44 | /* Brooktree 848 registers */ | ||
45 | |||
46 | #define BT848_DSTATUS 0x000 | ||
47 | #define BT848_DSTATUS_PRES (1<<7) | ||
48 | #define BT848_DSTATUS_HLOC (1<<6) | ||
49 | #define BT848_DSTATUS_FIELD (1<<5) | ||
50 | #define BT848_DSTATUS_NUML (1<<4) | ||
51 | #define BT848_DSTATUS_CSEL (1<<3) | ||
52 | #define BT848_DSTATUS_PLOCK (1<<2) | ||
53 | #define BT848_DSTATUS_LOF (1<<1) | ||
54 | #define BT848_DSTATUS_COF (1<<0) | ||
55 | |||
56 | #define BT848_IFORM 0x004 | ||
57 | #define BT848_IFORM_HACTIVE (1<<7) | ||
58 | #define BT848_IFORM_MUXSEL (3<<5) | ||
59 | #define BT848_IFORM_MUX0 (2<<5) | ||
60 | #define BT848_IFORM_MUX1 (3<<5) | ||
61 | #define BT848_IFORM_MUX2 (1<<5) | ||
62 | #define BT848_IFORM_XTSEL (3<<3) | ||
63 | #define BT848_IFORM_XT0 (1<<3) | ||
64 | #define BT848_IFORM_XT1 (2<<3) | ||
65 | #define BT848_IFORM_XTAUTO (3<<3) | ||
66 | #define BT848_IFORM_XTBOTH (3<<3) | ||
67 | #define BT848_IFORM_NTSC 1 | ||
68 | #define BT848_IFORM_NTSC_J 2 | ||
69 | #define BT848_IFORM_PAL_BDGHI 3 | ||
70 | #define BT848_IFORM_PAL_M 4 | ||
71 | #define BT848_IFORM_PAL_N 5 | ||
72 | #define BT848_IFORM_SECAM 6 | ||
73 | #define BT848_IFORM_PAL_NC 7 | ||
74 | #define BT848_IFORM_AUTO 0 | ||
75 | #define BT848_IFORM_NORM 7 | ||
76 | |||
77 | #define BT848_TDEC 0x008 | ||
78 | #define BT848_TDEC_DEC_FIELD (1<<7) | ||
79 | #define BT848_TDEC_FLDALIGN (1<<6) | ||
80 | #define BT848_TDEC_DEC_RAT (0x1f) | ||
81 | |||
82 | #define BT848_E_CROP 0x00C | ||
83 | #define BT848_O_CROP 0x08C | ||
84 | |||
85 | #define BT848_E_VDELAY_LO 0x010 | ||
86 | #define BT848_O_VDELAY_LO 0x090 | ||
87 | |||
88 | #define BT848_E_VACTIVE_LO 0x014 | ||
89 | #define BT848_O_VACTIVE_LO 0x094 | ||
90 | |||
91 | #define BT848_E_HDELAY_LO 0x018 | ||
92 | #define BT848_O_HDELAY_LO 0x098 | ||
93 | |||
94 | #define BT848_E_HACTIVE_LO 0x01C | ||
95 | #define BT848_O_HACTIVE_LO 0x09C | ||
96 | |||
97 | #define BT848_E_HSCALE_HI 0x020 | ||
98 | #define BT848_O_HSCALE_HI 0x0A0 | ||
99 | |||
100 | #define BT848_E_HSCALE_LO 0x024 | ||
101 | #define BT848_O_HSCALE_LO 0x0A4 | ||
102 | |||
103 | #define BT848_BRIGHT 0x028 | ||
104 | |||
105 | #define BT848_E_CONTROL 0x02C | ||
106 | #define BT848_O_CONTROL 0x0AC | ||
107 | #define BT848_CONTROL_LNOTCH (1<<7) | ||
108 | #define BT848_CONTROL_COMP (1<<6) | ||
109 | #define BT848_CONTROL_LDEC (1<<5) | ||
110 | #define BT848_CONTROL_CBSENSE (1<<4) | ||
111 | #define BT848_CONTROL_CON_MSB (1<<2) | ||
112 | #define BT848_CONTROL_SAT_U_MSB (1<<1) | ||
113 | #define BT848_CONTROL_SAT_V_MSB (1<<0) | ||
114 | |||
115 | #define BT848_CONTRAST_LO 0x030 | ||
116 | #define BT848_SAT_U_LO 0x034 | ||
117 | #define BT848_SAT_V_LO 0x038 | ||
118 | #define BT848_HUE 0x03C | ||
119 | |||
120 | #define BT848_E_SCLOOP 0x040 | ||
121 | #define BT848_O_SCLOOP 0x0C0 | ||
122 | #define BT848_SCLOOP_CAGC (1<<6) | ||
123 | #define BT848_SCLOOP_CKILL (1<<5) | ||
124 | #define BT848_SCLOOP_HFILT_AUTO (0<<3) | ||
125 | #define BT848_SCLOOP_HFILT_CIF (1<<3) | ||
126 | #define BT848_SCLOOP_HFILT_QCIF (2<<3) | ||
127 | #define BT848_SCLOOP_HFILT_ICON (3<<3) | ||
128 | |||
129 | #define BT848_SCLOOP_PEAK (1<<7) | ||
130 | #define BT848_SCLOOP_HFILT_MINP (1<<3) | ||
131 | #define BT848_SCLOOP_HFILT_MEDP (2<<3) | ||
132 | #define BT848_SCLOOP_HFILT_MAXP (3<<3) | ||
133 | |||
134 | |||
135 | #define BT848_OFORM 0x048 | ||
136 | #define BT848_OFORM_RANGE (1<<7) | ||
137 | #define BT848_OFORM_CORE0 (0<<5) | ||
138 | #define BT848_OFORM_CORE8 (1<<5) | ||
139 | #define BT848_OFORM_CORE16 (2<<5) | ||
140 | #define BT848_OFORM_CORE32 (3<<5) | ||
141 | |||
142 | #define BT848_E_VSCALE_HI 0x04C | ||
143 | #define BT848_O_VSCALE_HI 0x0CC | ||
144 | #define BT848_VSCALE_YCOMB (1<<7) | ||
145 | #define BT848_VSCALE_COMB (1<<6) | ||
146 | #define BT848_VSCALE_INT (1<<5) | ||
147 | #define BT848_VSCALE_HI 15 | ||
148 | |||
149 | #define BT848_E_VSCALE_LO 0x050 | ||
150 | #define BT848_O_VSCALE_LO 0x0D0 | ||
151 | #define BT848_TEST 0x054 | ||
152 | #define BT848_ADELAY 0x060 | ||
153 | #define BT848_BDELAY 0x064 | ||
154 | |||
155 | #define BT848_ADC 0x068 | ||
156 | #define BT848_ADC_RESERVED (2<<6) | ||
157 | #define BT848_ADC_SYNC_T (1<<5) | ||
158 | #define BT848_ADC_AGC_EN (1<<4) | ||
159 | #define BT848_ADC_CLK_SLEEP (1<<3) | ||
160 | #define BT848_ADC_Y_SLEEP (1<<2) | ||
161 | #define BT848_ADC_C_SLEEP (1<<1) | ||
162 | #define BT848_ADC_CRUSH (1<<0) | ||
163 | |||
164 | #define BT848_WC_UP 0x044 | ||
165 | #define BT848_WC_DOWN 0x078 | ||
166 | |||
167 | #define BT848_E_VTC 0x06C | ||
168 | #define BT848_O_VTC 0x0EC | ||
169 | #define BT848_VTC_HSFMT (1<<7) | ||
170 | #define BT848_VTC_VFILT_2TAP 0 | ||
171 | #define BT848_VTC_VFILT_3TAP 1 | ||
172 | #define BT848_VTC_VFILT_4TAP 2 | ||
173 | #define BT848_VTC_VFILT_5TAP 3 | ||
174 | |||
175 | #define BT848_SRESET 0x07C | ||
176 | |||
177 | #define BT848_COLOR_FMT 0x0D4 | ||
178 | #define BT848_COLOR_FMT_O_RGB32 (0<<4) | ||
179 | #define BT848_COLOR_FMT_O_RGB24 (1<<4) | ||
180 | #define BT848_COLOR_FMT_O_RGB16 (2<<4) | ||
181 | #define BT848_COLOR_FMT_O_RGB15 (3<<4) | ||
182 | #define BT848_COLOR_FMT_O_YUY2 (4<<4) | ||
183 | #define BT848_COLOR_FMT_O_BtYUV (5<<4) | ||
184 | #define BT848_COLOR_FMT_O_Y8 (6<<4) | ||
185 | #define BT848_COLOR_FMT_O_RGB8 (7<<4) | ||
186 | #define BT848_COLOR_FMT_O_YCrCb422 (8<<4) | ||
187 | #define BT848_COLOR_FMT_O_YCrCb411 (9<<4) | ||
188 | #define BT848_COLOR_FMT_O_RAW (14<<4) | ||
189 | #define BT848_COLOR_FMT_E_RGB32 0 | ||
190 | #define BT848_COLOR_FMT_E_RGB24 1 | ||
191 | #define BT848_COLOR_FMT_E_RGB16 2 | ||
192 | #define BT848_COLOR_FMT_E_RGB15 3 | ||
193 | #define BT848_COLOR_FMT_E_YUY2 4 | ||
194 | #define BT848_COLOR_FMT_E_BtYUV 5 | ||
195 | #define BT848_COLOR_FMT_E_Y8 6 | ||
196 | #define BT848_COLOR_FMT_E_RGB8 7 | ||
197 | #define BT848_COLOR_FMT_E_YCrCb422 8 | ||
198 | #define BT848_COLOR_FMT_E_YCrCb411 9 | ||
199 | #define BT848_COLOR_FMT_E_RAW 14 | ||
200 | |||
201 | #define BT848_COLOR_FMT_RGB32 0x00 | ||
202 | #define BT848_COLOR_FMT_RGB24 0x11 | ||
203 | #define BT848_COLOR_FMT_RGB16 0x22 | ||
204 | #define BT848_COLOR_FMT_RGB15 0x33 | ||
205 | #define BT848_COLOR_FMT_YUY2 0x44 | ||
206 | #define BT848_COLOR_FMT_BtYUV 0x55 | ||
207 | #define BT848_COLOR_FMT_Y8 0x66 | ||
208 | #define BT848_COLOR_FMT_RGB8 0x77 | ||
209 | #define BT848_COLOR_FMT_YCrCb422 0x88 | ||
210 | #define BT848_COLOR_FMT_YCrCb411 0x99 | ||
211 | #define BT848_COLOR_FMT_RAW 0xee | ||
212 | |||
213 | #define BT848_VTOTAL_LO 0xB0 | ||
214 | #define BT848_VTOTAL_HI 0xB4 | ||
215 | |||
216 | #define BT848_COLOR_CTL 0x0D8 | ||
217 | #define BT848_COLOR_CTL_EXT_FRMRATE (1<<7) | ||
218 | #define BT848_COLOR_CTL_COLOR_BARS (1<<6) | ||
219 | #define BT848_COLOR_CTL_RGB_DED (1<<5) | ||
220 | #define BT848_COLOR_CTL_GAMMA (1<<4) | ||
221 | #define BT848_COLOR_CTL_WSWAP_ODD (1<<3) | ||
222 | #define BT848_COLOR_CTL_WSWAP_EVEN (1<<2) | ||
223 | #define BT848_COLOR_CTL_BSWAP_ODD (1<<1) | ||
224 | #define BT848_COLOR_CTL_BSWAP_EVEN (1<<0) | ||
225 | |||
226 | #define BT848_CAP_CTL 0x0DC | ||
227 | #define BT848_CAP_CTL_DITH_FRAME (1<<4) | ||
228 | #define BT848_CAP_CTL_CAPTURE_VBI_ODD (1<<3) | ||
229 | #define BT848_CAP_CTL_CAPTURE_VBI_EVEN (1<<2) | ||
230 | #define BT848_CAP_CTL_CAPTURE_ODD (1<<1) | ||
231 | #define BT848_CAP_CTL_CAPTURE_EVEN (1<<0) | ||
232 | |||
233 | #define BT848_VBI_PACK_SIZE 0x0E0 | ||
234 | |||
235 | #define BT848_VBI_PACK_DEL 0x0E4 | ||
236 | #define BT848_VBI_PACK_DEL_VBI_HDELAY 0xfc | ||
237 | #define BT848_VBI_PACK_DEL_EXT_FRAME 2 | ||
238 | #define BT848_VBI_PACK_DEL_VBI_PKT_HI 1 | ||
239 | |||
240 | |||
241 | #define BT848_INT_STAT 0x100 | ||
242 | #define BT848_INT_MASK 0x104 | ||
243 | |||
244 | #define BT848_INT_ETBF (1<<23) | ||
245 | |||
246 | #define BT848_INT_RISCS (0xf<<28) | ||
247 | #define BT848_INT_RISC_EN (1<<27) | ||
248 | #define BT848_INT_RACK (1<<25) | ||
249 | #define BT848_INT_FIELD (1<<24) | ||
250 | #define BT848_INT_SCERR (1<<19) | ||
251 | #define BT848_INT_OCERR (1<<18) | ||
252 | #define BT848_INT_PABORT (1<<17) | ||
253 | #define BT848_INT_RIPERR (1<<16) | ||
254 | #define BT848_INT_PPERR (1<<15) | ||
255 | #define BT848_INT_FDSR (1<<14) | ||
256 | #define BT848_INT_FTRGT (1<<13) | ||
257 | #define BT848_INT_FBUS (1<<12) | ||
258 | #define BT848_INT_RISCI (1<<11) | ||
259 | #define BT848_INT_GPINT (1<<9) | ||
260 | #define BT848_INT_I2CDONE (1<<8) | ||
261 | #define BT848_INT_VPRES (1<<5) | ||
262 | #define BT848_INT_HLOCK (1<<4) | ||
263 | #define BT848_INT_OFLOW (1<<3) | ||
264 | #define BT848_INT_HSYNC (1<<2) | ||
265 | #define BT848_INT_VSYNC (1<<1) | ||
266 | #define BT848_INT_FMTCHG (1<<0) | ||
267 | |||
268 | |||
269 | #define BT848_GPIO_DMA_CTL 0x10C | ||
270 | #define BT848_GPIO_DMA_CTL_GPINTC (1<<15) | ||
271 | #define BT848_GPIO_DMA_CTL_GPINTI (1<<14) | ||
272 | #define BT848_GPIO_DMA_CTL_GPWEC (1<<13) | ||
273 | #define BT848_GPIO_DMA_CTL_GPIOMODE (3<<11) | ||
274 | #define BT848_GPIO_DMA_CTL_GPCLKMODE (1<<10) | ||
275 | #define BT848_GPIO_DMA_CTL_PLTP23_4 (0<<6) | ||
276 | #define BT848_GPIO_DMA_CTL_PLTP23_8 (1<<6) | ||
277 | #define BT848_GPIO_DMA_CTL_PLTP23_16 (2<<6) | ||
278 | #define BT848_GPIO_DMA_CTL_PLTP23_32 (3<<6) | ||
279 | #define BT848_GPIO_DMA_CTL_PLTP1_4 (0<<4) | ||
280 | #define BT848_GPIO_DMA_CTL_PLTP1_8 (1<<4) | ||
281 | #define BT848_GPIO_DMA_CTL_PLTP1_16 (2<<4) | ||
282 | #define BT848_GPIO_DMA_CTL_PLTP1_32 (3<<4) | ||
283 | #define BT848_GPIO_DMA_CTL_PKTP_4 (0<<2) | ||
284 | #define BT848_GPIO_DMA_CTL_PKTP_8 (1<<2) | ||
285 | #define BT848_GPIO_DMA_CTL_PKTP_16 (2<<2) | ||
286 | #define BT848_GPIO_DMA_CTL_PKTP_32 (3<<2) | ||
287 | #define BT848_GPIO_DMA_CTL_RISC_ENABLE (1<<1) | ||
288 | #define BT848_GPIO_DMA_CTL_FIFO_ENABLE (1<<0) | ||
289 | |||
290 | #define BT848_I2C 0x110 | ||
291 | #define BT878_I2C_MODE (1<<7) | ||
292 | #define BT878_I2C_RATE (1<<6) | ||
293 | #define BT878_I2C_NOSTOP (1<<5) | ||
294 | #define BT878_I2C_NOSTART (1<<4) | ||
295 | #define BT848_I2C_DIV (0xf<<4) | ||
296 | #define BT848_I2C_SYNC (1<<3) | ||
297 | #define BT848_I2C_W3B (1<<2) | ||
298 | #define BT848_I2C_SCL (1<<1) | ||
299 | #define BT848_I2C_SDA (1<<0) | ||
300 | |||
301 | #define BT848_RISC_STRT_ADD 0x114 | ||
302 | #define BT848_GPIO_OUT_EN 0x118 | ||
303 | #define BT848_GPIO_REG_INP 0x11C | ||
304 | #define BT848_RISC_COUNT 0x120 | ||
305 | #define BT848_GPIO_DATA 0x200 | ||
306 | |||
307 | |||
308 | /* Bt848 RISC commands */ | ||
309 | |||
310 | /* only for the SYNC RISC command */ | ||
311 | #define BT848_FIFO_STATUS_FM1 0x06 | ||
312 | #define BT848_FIFO_STATUS_FM3 0x0e | ||
313 | #define BT848_FIFO_STATUS_SOL 0x02 | ||
314 | #define BT848_FIFO_STATUS_EOL4 0x01 | ||
315 | #define BT848_FIFO_STATUS_EOL3 0x0d | ||
316 | #define BT848_FIFO_STATUS_EOL2 0x09 | ||
317 | #define BT848_FIFO_STATUS_EOL1 0x05 | ||
318 | #define BT848_FIFO_STATUS_VRE 0x04 | ||
319 | #define BT848_FIFO_STATUS_VRO 0x0c | ||
320 | #define BT848_FIFO_STATUS_PXV 0x00 | ||
321 | |||
322 | #define BT848_RISC_RESYNC (1<<15) | ||
323 | |||
324 | /* WRITE and SKIP */ | ||
325 | /* disable which bytes of each DWORD */ | ||
326 | #define BT848_RISC_BYTE0 (1U<<12) | ||
327 | #define BT848_RISC_BYTE1 (1U<<13) | ||
328 | #define BT848_RISC_BYTE2 (1U<<14) | ||
329 | #define BT848_RISC_BYTE3 (1U<<15) | ||
330 | #define BT848_RISC_BYTE_ALL (0x0fU<<12) | ||
331 | #define BT848_RISC_BYTE_NONE 0 | ||
332 | /* cause RISCI */ | ||
333 | #define BT848_RISC_IRQ (1U<<24) | ||
334 | /* RISC command is last one in this line */ | ||
335 | #define BT848_RISC_EOL (1U<<26) | ||
336 | /* RISC command is first one in this line */ | ||
337 | #define BT848_RISC_SOL (1U<<27) | ||
338 | |||
339 | #define BT848_RISC_WRITE (0x01U<<28) | ||
340 | #define BT848_RISC_SKIP (0x02U<<28) | ||
341 | #define BT848_RISC_WRITEC (0x05U<<28) | ||
342 | #define BT848_RISC_JUMP (0x07U<<28) | ||
343 | #define BT848_RISC_SYNC (0x08U<<28) | ||
344 | |||
345 | #define BT848_RISC_WRITE123 (0x09U<<28) | ||
346 | #define BT848_RISC_SKIP123 (0x0aU<<28) | ||
347 | #define BT848_RISC_WRITE1S23 (0x0bU<<28) | ||
348 | |||
349 | |||
350 | /* Bt848A and higher only !! */ | ||
351 | #define BT848_TGLB 0x080 | ||
352 | #define BT848_TGCTRL 0x084 | ||
353 | #define BT848_FCAP 0x0E8 | ||
354 | #define BT848_PLL_F_LO 0x0F0 | ||
355 | #define BT848_PLL_F_HI 0x0F4 | ||
356 | |||
357 | #define BT848_PLL_XCI 0x0F8 | ||
358 | #define BT848_PLL_X (1<<7) | ||
359 | #define BT848_PLL_C (1<<6) | ||
360 | |||
361 | #define BT848_DVSIF 0x0FC | ||
362 | |||
363 | /* Bt878 register */ | ||
364 | |||
365 | #define BT878_DEVCTRL 0x40 | ||
366 | #define BT878_EN_TBFX 0x02 | ||
367 | #define BT878_EN_VSFX 0x04 | ||
368 | |||
369 | #endif | ||
diff --git a/drivers/media/video/bt8xx/bttv-audio-hook.c b/drivers/media/video/bt8xx/bttv-audio-hook.c deleted file mode 100644 index 2364d16586b3..000000000000 --- a/drivers/media/video/bt8xx/bttv-audio-hook.c +++ /dev/null | |||
@@ -1,382 +0,0 @@ | |||
1 | /* | ||
2 | * Handlers for board audio hooks, splitted from bttv-cards | ||
3 | * | ||
4 | * Copyright (c) 2006 Mauro Carvalho Chehab (mchehab@infradead.org) | ||
5 | * This code is placed under the terms of the GNU General Public License | ||
6 | */ | ||
7 | |||
8 | #include "bttv-audio-hook.h" | ||
9 | |||
10 | #include <linux/delay.h> | ||
11 | |||
12 | /* ----------------------------------------------------------------------- */ | ||
13 | /* winview */ | ||
14 | |||
15 | void winview_volume(struct bttv *btv, __u16 volume) | ||
16 | { | ||
17 | /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */ | ||
18 | int bits_out, loops, vol, data; | ||
19 | |||
20 | /* 32 levels logarithmic */ | ||
21 | vol = 32 - ((volume>>11)); | ||
22 | /* units */ | ||
23 | bits_out = (PT2254_DBS_IN_2>>(vol%5)); | ||
24 | /* tens */ | ||
25 | bits_out |= (PT2254_DBS_IN_10>>(vol/5)); | ||
26 | bits_out |= PT2254_L_CHANNEL | PT2254_R_CHANNEL; | ||
27 | data = gpio_read(); | ||
28 | data &= ~(WINVIEW_PT2254_CLK| WINVIEW_PT2254_DATA| | ||
29 | WINVIEW_PT2254_STROBE); | ||
30 | for (loops = 17; loops >= 0 ; loops--) { | ||
31 | if (bits_out & (1<<loops)) | ||
32 | data |= WINVIEW_PT2254_DATA; | ||
33 | else | ||
34 | data &= ~WINVIEW_PT2254_DATA; | ||
35 | gpio_write(data); | ||
36 | udelay(5); | ||
37 | data |= WINVIEW_PT2254_CLK; | ||
38 | gpio_write(data); | ||
39 | udelay(5); | ||
40 | data &= ~WINVIEW_PT2254_CLK; | ||
41 | gpio_write(data); | ||
42 | } | ||
43 | data |= WINVIEW_PT2254_STROBE; | ||
44 | data &= ~WINVIEW_PT2254_DATA; | ||
45 | gpio_write(data); | ||
46 | udelay(10); | ||
47 | data &= ~WINVIEW_PT2254_STROBE; | ||
48 | gpio_write(data); | ||
49 | } | ||
50 | |||
51 | /* ----------------------------------------------------------------------- */ | ||
52 | /* mono/stereo control for various cards (which don't use i2c chips but */ | ||
53 | /* connect something to the GPIO pins */ | ||
54 | |||
55 | void gvbctv3pci_audio(struct bttv *btv, struct v4l2_tuner *t, int set) | ||
56 | { | ||
57 | unsigned int con = 0; | ||
58 | |||
59 | if (set) { | ||
60 | gpio_inout(0x300, 0x300); | ||
61 | if (t->audmode & V4L2_TUNER_MODE_LANG1) | ||
62 | con = 0x000; | ||
63 | if (t->audmode & V4L2_TUNER_MODE_LANG2) | ||
64 | con = 0x300; | ||
65 | if (t->audmode & V4L2_TUNER_MODE_STEREO) | ||
66 | con = 0x200; | ||
67 | /* if (t->audmode & V4L2_TUNER_MODE_MONO) | ||
68 | * con = 0x100; */ | ||
69 | gpio_bits(0x300, con); | ||
70 | } else { | ||
71 | t->audmode = V4L2_TUNER_MODE_STEREO | | ||
72 | V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | ||
73 | } | ||
74 | } | ||
75 | |||
76 | void gvbctv5pci_audio(struct bttv *btv, struct v4l2_tuner *t, int set) | ||
77 | { | ||
78 | unsigned int val, con; | ||
79 | |||
80 | if (btv->radio_user) | ||
81 | return; | ||
82 | |||
83 | val = gpio_read(); | ||
84 | if (set) { | ||
85 | con = 0x000; | ||
86 | if (t->audmode & V4L2_TUNER_MODE_LANG2) { | ||
87 | if (t->audmode & V4L2_TUNER_MODE_LANG1) { | ||
88 | /* LANG1 + LANG2 */ | ||
89 | con = 0x100; | ||
90 | } | ||
91 | else { | ||
92 | /* LANG2 */ | ||
93 | con = 0x300; | ||
94 | } | ||
95 | } | ||
96 | if (con != (val & 0x300)) { | ||
97 | gpio_bits(0x300, con); | ||
98 | if (bttv_gpio) | ||
99 | bttv_gpio_tracking(btv,"gvbctv5pci"); | ||
100 | } | ||
101 | } else { | ||
102 | switch (val & 0x70) { | ||
103 | case 0x10: | ||
104 | t->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2; | ||
105 | break; | ||
106 | case 0x30: | ||
107 | t->rxsubchans = V4L2_TUNER_SUB_LANG2; | ||
108 | break; | ||
109 | case 0x50: | ||
110 | t->rxsubchans = V4L2_TUNER_SUB_LANG1; | ||
111 | break; | ||
112 | case 0x60: | ||
113 | t->rxsubchans = V4L2_TUNER_SUB_STEREO; | ||
114 | break; | ||
115 | case 0x70: | ||
116 | t->rxsubchans = V4L2_TUNER_SUB_MONO; | ||
117 | break; | ||
118 | default: | ||
119 | t->rxsubchans = V4L2_TUNER_SUB_MONO | | ||
120 | V4L2_TUNER_SUB_STEREO | | ||
121 | V4L2_TUNER_SUB_LANG1 | | ||
122 | V4L2_TUNER_SUB_LANG2; | ||
123 | } | ||
124 | t->audmode = V4L2_TUNER_MODE_STEREO | | ||
125 | V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | /* | ||
130 | * Mario Medina Nussbaum <medisoft@alohabbs.org.mx> | ||
131 | * I discover that on BT848_GPIO_DATA address a byte 0xcce enable stereo, | ||
132 | * 0xdde enables mono and 0xccd enables sap | ||
133 | * | ||
134 | * Petr Vandrovec <VANDROVE@vc.cvut.cz> | ||
135 | * P.S.: At least mask in line above is wrong - GPIO pins 3,2 select | ||
136 | * input/output sound connection, so both must be set for output mode. | ||
137 | * | ||
138 | * Looks like it's needed only for the "tvphone", the "tvphone 98" | ||
139 | * handles this with a tda9840 | ||
140 | * | ||
141 | */ | ||
142 | |||
143 | void avermedia_tvphone_audio(struct bttv *btv, struct v4l2_tuner *t, int set) | ||
144 | { | ||
145 | int val = 0; | ||
146 | |||
147 | if (set) { | ||
148 | if (t->audmode & V4L2_TUNER_MODE_LANG2) /* SAP */ | ||
149 | val = 0x02; | ||
150 | if (t->audmode & V4L2_TUNER_MODE_STEREO) | ||
151 | val = 0x01; | ||
152 | if (val) { | ||
153 | gpio_bits(0x03,val); | ||
154 | if (bttv_gpio) | ||
155 | bttv_gpio_tracking(btv,"avermedia"); | ||
156 | } | ||
157 | } else { | ||
158 | t->audmode = V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO | | ||
159 | V4L2_TUNER_MODE_LANG1; | ||
160 | return; | ||
161 | } | ||
162 | } | ||
163 | |||
164 | |||
165 | void avermedia_tv_stereo_audio(struct bttv *btv, struct v4l2_tuner *t, int set) | ||
166 | { | ||
167 | int val = 0; | ||
168 | |||
169 | if (set) { | ||
170 | if (t->audmode & V4L2_TUNER_MODE_LANG2) /* SAP */ | ||
171 | val = 0x01; | ||
172 | if (t->audmode & V4L2_TUNER_MODE_STEREO) /* STEREO */ | ||
173 | val = 0x02; | ||
174 | btaor(val, ~0x03, BT848_GPIO_DATA); | ||
175 | if (bttv_gpio) | ||
176 | bttv_gpio_tracking(btv,"avermedia"); | ||
177 | } else { | ||
178 | t->audmode = V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO | | ||
179 | V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | ||
180 | return; | ||
181 | } | ||
182 | } | ||
183 | |||
184 | /* Lifetec 9415 handling */ | ||
185 | |||
186 | void lt9415_audio(struct bttv *btv, struct v4l2_tuner *t, int set) | ||
187 | { | ||
188 | int val = 0; | ||
189 | |||
190 | if (gpio_read() & 0x4000) { | ||
191 | t->audmode = V4L2_TUNER_MODE_MONO; | ||
192 | return; | ||
193 | } | ||
194 | |||
195 | if (set) { | ||
196 | if (t->audmode & V4L2_TUNER_MODE_LANG2) /* A2 SAP */ | ||
197 | val = 0x0080; | ||
198 | if (t->audmode & V4L2_TUNER_MODE_STEREO) /* A2 stereo */ | ||
199 | val = 0x0880; | ||
200 | if ((t->audmode & V4L2_TUNER_MODE_LANG1) || | ||
201 | (t->audmode & V4L2_TUNER_MODE_MONO)) | ||
202 | val = 0; | ||
203 | gpio_bits(0x0880, val); | ||
204 | if (bttv_gpio) | ||
205 | bttv_gpio_tracking(btv,"lt9415"); | ||
206 | } else { | ||
207 | /* autodetect doesn't work with this card :-( */ | ||
208 | t->audmode = V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO | | ||
209 | V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | ||
210 | return; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | /* TDA9821 on TerraTV+ Bt848, Bt878 */ | ||
215 | void terratv_audio(struct bttv *btv, struct v4l2_tuner *t, int set) | ||
216 | { | ||
217 | unsigned int con = 0; | ||
218 | |||
219 | if (set) { | ||
220 | gpio_inout(0x180000,0x180000); | ||
221 | if (t->audmode & V4L2_TUNER_MODE_LANG2) | ||
222 | con = 0x080000; | ||
223 | if (t->audmode & V4L2_TUNER_MODE_STEREO) | ||
224 | con = 0x180000; | ||
225 | gpio_bits(0x180000, con); | ||
226 | if (bttv_gpio) | ||
227 | bttv_gpio_tracking(btv,"terratv"); | ||
228 | } else { | ||
229 | t->audmode = V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO | | ||
230 | V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | ||
231 | } | ||
232 | } | ||
233 | |||
234 | |||
235 | void winfast2000_audio(struct bttv *btv, struct v4l2_tuner *t, int set) | ||
236 | { | ||
237 | unsigned long val = 0; | ||
238 | |||
239 | if (set) { | ||
240 | /*btor (0xc32000, BT848_GPIO_OUT_EN);*/ | ||
241 | if (t->audmode & V4L2_TUNER_MODE_MONO) /* Mono */ | ||
242 | val = 0x420000; | ||
243 | if (t->audmode & V4L2_TUNER_MODE_LANG1) /* Mono */ | ||
244 | val = 0x420000; | ||
245 | if (t->audmode & V4L2_TUNER_MODE_LANG2) /* SAP */ | ||
246 | val = 0x410000; | ||
247 | if (t->audmode & V4L2_TUNER_MODE_STEREO) /* Stereo */ | ||
248 | val = 0x020000; | ||
249 | if (val) { | ||
250 | gpio_bits(0x430000, val); | ||
251 | if (bttv_gpio) | ||
252 | bttv_gpio_tracking(btv,"winfast2000"); | ||
253 | } | ||
254 | } else { | ||
255 | t->audmode = V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO | | ||
256 | V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | ||
257 | } | ||
258 | } | ||
259 | |||
260 | /* | ||
261 | * Dariusz Kowalewski <darekk@automex.pl> | ||
262 | * sound control for Prolink PV-BT878P+9B (PixelView PlayTV Pro FM+NICAM | ||
263 | * revision 9B has on-board TDA9874A sound decoder). | ||
264 | * | ||
265 | * Note: There are card variants without tda9874a. Forcing the "stereo sound route" | ||
266 | * will mute this cards. | ||
267 | */ | ||
268 | void pvbt878p9b_audio(struct bttv *btv, struct v4l2_tuner *t, int set) | ||
269 | { | ||
270 | unsigned int val = 0; | ||
271 | |||
272 | if (btv->radio_user) | ||
273 | return; | ||
274 | |||
275 | if (set) { | ||
276 | if (t->audmode & V4L2_TUNER_MODE_MONO) { | ||
277 | val = 0x01; | ||
278 | } | ||
279 | if ((t->audmode & (V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2)) | ||
280 | || (t->audmode & V4L2_TUNER_MODE_STEREO)) { | ||
281 | val = 0x02; | ||
282 | } | ||
283 | if (val) { | ||
284 | gpio_bits(0x03,val); | ||
285 | if (bttv_gpio) | ||
286 | bttv_gpio_tracking(btv,"pvbt878p9b"); | ||
287 | } | ||
288 | } else { | ||
289 | t->audmode = V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO | | ||
290 | V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | ||
291 | } | ||
292 | } | ||
293 | |||
294 | /* | ||
295 | * Dariusz Kowalewski <darekk@automex.pl> | ||
296 | * sound control for FlyVideo 2000S (with tda9874 decoder) | ||
297 | * based on pvbt878p9b_audio() - this is not tested, please fix!!! | ||
298 | */ | ||
299 | void fv2000s_audio(struct bttv *btv, struct v4l2_tuner *t, int set) | ||
300 | { | ||
301 | unsigned int val = 0xffff; | ||
302 | |||
303 | if (btv->radio_user) | ||
304 | return; | ||
305 | |||
306 | if (set) { | ||
307 | if (t->audmode & V4L2_TUNER_MODE_MONO) { | ||
308 | val = 0x0000; | ||
309 | } | ||
310 | if ((t->audmode & (V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2)) | ||
311 | || (t->audmode & V4L2_TUNER_MODE_STEREO)) { | ||
312 | val = 0x1080; /*-dk-???: 0x0880, 0x0080, 0x1800 ... */ | ||
313 | } | ||
314 | if (val != 0xffff) { | ||
315 | gpio_bits(0x1800, val); | ||
316 | if (bttv_gpio) | ||
317 | bttv_gpio_tracking(btv,"fv2000s"); | ||
318 | } | ||
319 | } else { | ||
320 | t->audmode = V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO | | ||
321 | V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | ||
322 | } | ||
323 | } | ||
324 | |||
325 | /* | ||
326 | * sound control for Canopus WinDVR PCI | ||
327 | * Masaki Suzuki <masaki@btree.org> | ||
328 | */ | ||
329 | void windvr_audio(struct bttv *btv, struct v4l2_tuner *t, int set) | ||
330 | { | ||
331 | unsigned long val = 0; | ||
332 | |||
333 | if (set) { | ||
334 | if (t->audmode & V4L2_TUNER_MODE_MONO) | ||
335 | val = 0x040000; | ||
336 | if (t->audmode & V4L2_TUNER_MODE_LANG1) | ||
337 | val = 0; | ||
338 | if (t->audmode & V4L2_TUNER_MODE_LANG2) | ||
339 | val = 0x100000; | ||
340 | if (t->audmode & V4L2_TUNER_MODE_STEREO) | ||
341 | val = 0; | ||
342 | if (val) { | ||
343 | gpio_bits(0x140000, val); | ||
344 | if (bttv_gpio) | ||
345 | bttv_gpio_tracking(btv,"windvr"); | ||
346 | } | ||
347 | } else { | ||
348 | t->audmode = V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO | | ||
349 | V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | ||
350 | } | ||
351 | } | ||
352 | |||
353 | /* | ||
354 | * sound control for AD-TVK503 | ||
355 | * Hiroshi Takekawa <sian@big.or.jp> | ||
356 | */ | ||
357 | void adtvk503_audio(struct bttv *btv, struct v4l2_tuner *t, int set) | ||
358 | { | ||
359 | unsigned int con = 0xffffff; | ||
360 | |||
361 | /* btaor(0x1e0000, ~0x1e0000, BT848_GPIO_OUT_EN); */ | ||
362 | |||
363 | if (set) { | ||
364 | /* btor(***, BT848_GPIO_OUT_EN); */ | ||
365 | if (t->audmode & V4L2_TUNER_MODE_LANG1) | ||
366 | con = 0x00000000; | ||
367 | if (t->audmode & V4L2_TUNER_MODE_LANG2) | ||
368 | con = 0x00180000; | ||
369 | if (t->audmode & V4L2_TUNER_MODE_STEREO) | ||
370 | con = 0x00000000; | ||
371 | if (t->audmode & V4L2_TUNER_MODE_MONO) | ||
372 | con = 0x00060000; | ||
373 | if (con != 0xffffff) { | ||
374 | gpio_bits(0x1e0000,con); | ||
375 | if (bttv_gpio) | ||
376 | bttv_gpio_tracking(btv, "adtvk503"); | ||
377 | } | ||
378 | } else { | ||
379 | t->audmode = V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO | | ||
380 | V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; | ||
381 | } | ||
382 | } | ||
diff --git a/drivers/media/video/bt8xx/bttv-audio-hook.h b/drivers/media/video/bt8xx/bttv-audio-hook.h deleted file mode 100644 index 159d07adeff8..000000000000 --- a/drivers/media/video/bt8xx/bttv-audio-hook.h +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | /* | ||
2 | * Handlers for board audio hooks, splitted from bttv-cards | ||
3 | * | ||
4 | * Copyright (c) 2006 Mauro Carvalho Chehab (mchehab@infradead.org) | ||
5 | * This code is placed under the terms of the GNU General Public License | ||
6 | */ | ||
7 | |||
8 | #include "bttvp.h" | ||
9 | |||
10 | void winview_volume (struct bttv *btv, __u16 volume); | ||
11 | |||
12 | void lt9415_audio(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
13 | void avermedia_tvphone_audio(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
14 | void avermedia_tv_stereo_audio(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
15 | void terratv_audio(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
16 | void gvbctv3pci_audio(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
17 | void gvbctv5pci_audio(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
18 | void winfast2000_audio(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
19 | void pvbt878p9b_audio(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
20 | void fv2000s_audio(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
21 | void windvr_audio(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
22 | void adtvk503_audio(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
23 | |||
diff --git a/drivers/media/video/bt8xx/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c deleted file mode 100644 index 38952faaffda..000000000000 --- a/drivers/media/video/bt8xx/bttv-cards.c +++ /dev/null | |||
@@ -1,4895 +0,0 @@ | |||
1 | /* | ||
2 | |||
3 | bttv-cards.c | ||
4 | |||
5 | this file has configuration informations - card-specific stuff | ||
6 | like the big tvcards array for the most part | ||
7 | |||
8 | Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) | ||
9 | & Marcus Metzler (mocm@thp.uni-koeln.de) | ||
10 | (c) 1999-2001 Gerd Knorr <kraxel@goldbach.in-berlin.de> | ||
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 | |||
28 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
29 | |||
30 | #include <linux/delay.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/kmod.h> | ||
33 | #include <linux/init.h> | ||
34 | #include <linux/pci.h> | ||
35 | #include <linux/vmalloc.h> | ||
36 | #include <linux/firmware.h> | ||
37 | #include <net/checksum.h> | ||
38 | |||
39 | #include <asm/unaligned.h> | ||
40 | #include <asm/io.h> | ||
41 | |||
42 | #include "bttvp.h" | ||
43 | #include <media/v4l2-common.h> | ||
44 | #include <media/tvaudio.h> | ||
45 | #include "bttv-audio-hook.h" | ||
46 | |||
47 | /* fwd decl */ | ||
48 | static void boot_msp34xx(struct bttv *btv, int pin); | ||
49 | static void hauppauge_eeprom(struct bttv *btv); | ||
50 | static void avermedia_eeprom(struct bttv *btv); | ||
51 | static void osprey_eeprom(struct bttv *btv, const u8 ee[256]); | ||
52 | static void modtec_eeprom(struct bttv *btv); | ||
53 | static void init_PXC200(struct bttv *btv); | ||
54 | static void init_RTV24(struct bttv *btv); | ||
55 | |||
56 | static void rv605_muxsel(struct bttv *btv, unsigned int input); | ||
57 | static void eagle_muxsel(struct bttv *btv, unsigned int input); | ||
58 | static void xguard_muxsel(struct bttv *btv, unsigned int input); | ||
59 | static void ivc120_muxsel(struct bttv *btv, unsigned int input); | ||
60 | static void gvc1100_muxsel(struct bttv *btv, unsigned int input); | ||
61 | |||
62 | static void PXC200_muxsel(struct bttv *btv, unsigned int input); | ||
63 | |||
64 | static void picolo_tetra_muxsel(struct bttv *btv, unsigned int input); | ||
65 | static void picolo_tetra_init(struct bttv *btv); | ||
66 | |||
67 | static void tibetCS16_muxsel(struct bttv *btv, unsigned int input); | ||
68 | static void tibetCS16_init(struct bttv *btv); | ||
69 | |||
70 | static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input); | ||
71 | static void kodicom4400r_init(struct bttv *btv); | ||
72 | |||
73 | static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input); | ||
74 | static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input); | ||
75 | |||
76 | static void geovision_muxsel(struct bttv *btv, unsigned int input); | ||
77 | |||
78 | static void phytec_muxsel(struct bttv *btv, unsigned int input); | ||
79 | |||
80 | static void gv800s_muxsel(struct bttv *btv, unsigned int input); | ||
81 | static void gv800s_init(struct bttv *btv); | ||
82 | |||
83 | static void td3116_muxsel(struct bttv *btv, unsigned int input); | ||
84 | |||
85 | static int terratec_active_radio_upgrade(struct bttv *btv); | ||
86 | static int tea5757_read(struct bttv *btv); | ||
87 | static int tea5757_write(struct bttv *btv, int value); | ||
88 | static void identify_by_eeprom(struct bttv *btv, | ||
89 | unsigned char eeprom_data[256]); | ||
90 | static int __devinit pvr_boot(struct bttv *btv); | ||
91 | |||
92 | /* config variables */ | ||
93 | static unsigned int triton1; | ||
94 | static unsigned int vsfx; | ||
95 | static unsigned int latency = UNSET; | ||
96 | int no_overlay=-1; | ||
97 | |||
98 | static unsigned int card[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; | ||
99 | static unsigned int pll[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; | ||
100 | static unsigned int tuner[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; | ||
101 | static unsigned int svhs[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; | ||
102 | static unsigned int remote[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = UNSET }; | ||
103 | static unsigned int audiodev[BTTV_MAX]; | ||
104 | static unsigned int saa6588[BTTV_MAX]; | ||
105 | static struct bttv *master[BTTV_MAX] = { [ 0 ... (BTTV_MAX-1) ] = NULL }; | ||
106 | static unsigned int autoload = UNSET; | ||
107 | static unsigned int gpiomask = UNSET; | ||
108 | static unsigned int audioall = UNSET; | ||
109 | static unsigned int audiomux[5] = { [ 0 ... 4 ] = UNSET }; | ||
110 | |||
111 | /* insmod options */ | ||
112 | module_param(triton1, int, 0444); | ||
113 | module_param(vsfx, int, 0444); | ||
114 | module_param(no_overlay, int, 0444); | ||
115 | module_param(latency, int, 0444); | ||
116 | module_param(gpiomask, int, 0444); | ||
117 | module_param(audioall, int, 0444); | ||
118 | module_param(autoload, int, 0444); | ||
119 | |||
120 | module_param_array(card, int, NULL, 0444); | ||
121 | module_param_array(pll, int, NULL, 0444); | ||
122 | module_param_array(tuner, int, NULL, 0444); | ||
123 | module_param_array(svhs, int, NULL, 0444); | ||
124 | module_param_array(remote, int, NULL, 0444); | ||
125 | module_param_array(audiodev, int, NULL, 0444); | ||
126 | module_param_array(audiomux, int, NULL, 0444); | ||
127 | |||
128 | MODULE_PARM_DESC(triton1,"set ETBF pci config bit " | ||
129 | "[enable bug compatibility for triton1 + others]"); | ||
130 | MODULE_PARM_DESC(vsfx,"set VSFX pci config bit " | ||
131 | "[yet another chipset flaw workaround]"); | ||
132 | MODULE_PARM_DESC(latency,"pci latency timer"); | ||
133 | MODULE_PARM_DESC(card,"specify TV/grabber card model, see CARDLIST file for a list"); | ||
134 | MODULE_PARM_DESC(pll,"specify installed crystal (0=none, 28=28 MHz, 35=35 MHz)"); | ||
135 | MODULE_PARM_DESC(tuner,"specify installed tuner type"); | ||
136 | MODULE_PARM_DESC(autoload, "obsolete option, please do not use anymore"); | ||
137 | MODULE_PARM_DESC(audiodev, "specify audio device:\n" | ||
138 | "\t\t-1 = no audio\n" | ||
139 | "\t\t 0 = autodetect (default)\n" | ||
140 | "\t\t 1 = msp3400\n" | ||
141 | "\t\t 2 = tda7432\n" | ||
142 | "\t\t 3 = tvaudio"); | ||
143 | MODULE_PARM_DESC(saa6588, "if 1, then load the saa6588 RDS module, default (0) is to use the card definition."); | ||
144 | MODULE_PARM_DESC(no_overlay,"allow override overlay default (0 disables, 1 enables)" | ||
145 | " [some VIA/SIS chipsets are known to have problem with overlay]"); | ||
146 | |||
147 | /* ----------------------------------------------------------------------- */ | ||
148 | /* list of card IDs for bt878+ cards */ | ||
149 | |||
150 | static struct CARD { | ||
151 | unsigned id; | ||
152 | int cardnr; | ||
153 | char *name; | ||
154 | } cards[] __devinitdata = { | ||
155 | { 0x13eb0070, BTTV_BOARD_HAUPPAUGE878, "Hauppauge WinTV" }, | ||
156 | { 0x39000070, BTTV_BOARD_HAUPPAUGE878, "Hauppauge WinTV-D" }, | ||
157 | { 0x45000070, BTTV_BOARD_HAUPPAUGEPVR, "Hauppauge WinTV/PVR" }, | ||
158 | { 0xff000070, BTTV_BOARD_OSPREY1x0, "Osprey-100" }, | ||
159 | { 0xff010070, BTTV_BOARD_OSPREY2x0_SVID,"Osprey-200" }, | ||
160 | { 0xff020070, BTTV_BOARD_OSPREY500, "Osprey-500" }, | ||
161 | { 0xff030070, BTTV_BOARD_OSPREY2000, "Osprey-2000" }, | ||
162 | { 0xff040070, BTTV_BOARD_OSPREY540, "Osprey-540" }, | ||
163 | { 0xff070070, BTTV_BOARD_OSPREY440, "Osprey-440" }, | ||
164 | |||
165 | { 0x00011002, BTTV_BOARD_ATI_TVWONDER, "ATI TV Wonder" }, | ||
166 | { 0x00031002, BTTV_BOARD_ATI_TVWONDERVE,"ATI TV Wonder/VE" }, | ||
167 | |||
168 | { 0x6606107d, BTTV_BOARD_WINFAST2000, "Leadtek WinFast TV 2000" }, | ||
169 | { 0x6607107d, BTTV_BOARD_WINFASTVC100, "Leadtek WinFast VC 100" }, | ||
170 | { 0x6609107d, BTTV_BOARD_WINFAST2000, "Leadtek TV 2000 XP" }, | ||
171 | { 0x263610b4, BTTV_BOARD_STB2, "STB TV PCI FM, Gateway P/N 6000704" }, | ||
172 | { 0x264510b4, BTTV_BOARD_STB2, "STB TV PCI FM, Gateway P/N 6000704" }, | ||
173 | { 0x402010fc, BTTV_BOARD_GVBCTV3PCI, "I-O Data Co. GV-BCTV3/PCI" }, | ||
174 | { 0x405010fc, BTTV_BOARD_GVBCTV4PCI, "I-O Data Co. GV-BCTV4/PCI" }, | ||
175 | { 0x407010fc, BTTV_BOARD_GVBCTV5PCI, "I-O Data Co. GV-BCTV5/PCI" }, | ||
176 | { 0xd01810fc, BTTV_BOARD_GVBCTV5PCI, "I-O Data Co. GV-BCTV5/PCI" }, | ||
177 | |||
178 | { 0x001211bd, BTTV_BOARD_PINNACLE, "Pinnacle PCTV" }, | ||
179 | /* some cards ship with byteswapped IDs ... */ | ||
180 | { 0x1200bd11, BTTV_BOARD_PINNACLE, "Pinnacle PCTV [bswap]" }, | ||
181 | { 0xff00bd11, BTTV_BOARD_PINNACLE, "Pinnacle PCTV [bswap]" }, | ||
182 | /* this seems to happen as well ... */ | ||
183 | { 0xff1211bd, BTTV_BOARD_PINNACLE, "Pinnacle PCTV" }, | ||
184 | |||
185 | { 0x3000121a, BTTV_BOARD_VOODOOTV_200, "3Dfx VoodooTV 200" }, | ||
186 | { 0x263710b4, BTTV_BOARD_VOODOOTV_FM, "3Dfx VoodooTV FM" }, | ||
187 | { 0x3060121a, BTTV_BOARD_STB2, "3Dfx VoodooTV 100/ STB OEM" }, | ||
188 | |||
189 | { 0x3000144f, BTTV_BOARD_MAGICTVIEW063, "(Askey Magic/others) TView99 CPH06x" }, | ||
190 | { 0xa005144f, BTTV_BOARD_MAGICTVIEW063, "CPH06X TView99-Card" }, | ||
191 | { 0x3002144f, BTTV_BOARD_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH05x" }, | ||
192 | { 0x3005144f, BTTV_BOARD_MAGICTVIEW061, "(Askey Magic/others) TView99 CPH061/06L (T1/LC)" }, | ||
193 | { 0x5000144f, BTTV_BOARD_MAGICTVIEW061, "Askey CPH050" }, | ||
194 | { 0x300014ff, BTTV_BOARD_MAGICTVIEW061, "TView 99 (CPH061)" }, | ||
195 | { 0x300214ff, BTTV_BOARD_PHOEBE_TVMAS, "Phoebe TV Master (CPH060)" }, | ||
196 | |||
197 | { 0x00011461, BTTV_BOARD_AVPHONE98, "AVerMedia TVPhone98" }, | ||
198 | { 0x00021461, BTTV_BOARD_AVERMEDIA98, "AVermedia TVCapture 98" }, | ||
199 | { 0x00031461, BTTV_BOARD_AVPHONE98, "AVerMedia TVPhone98" }, | ||
200 | { 0x00041461, BTTV_BOARD_AVERMEDIA98, "AVerMedia TVCapture 98" }, | ||
201 | { 0x03001461, BTTV_BOARD_AVERMEDIA98, "VDOMATE TV TUNER CARD" }, | ||
202 | |||
203 | { 0x1117153b, BTTV_BOARD_TERRATVALUE, "Terratec TValue (Philips PAL B/G)" }, | ||
204 | { 0x1118153b, BTTV_BOARD_TERRATVALUE, "Terratec TValue (Temic PAL B/G)" }, | ||
205 | { 0x1119153b, BTTV_BOARD_TERRATVALUE, "Terratec TValue (Philips PAL I)" }, | ||
206 | { 0x111a153b, BTTV_BOARD_TERRATVALUE, "Terratec TValue (Temic PAL I)" }, | ||
207 | |||
208 | { 0x1123153b, BTTV_BOARD_TERRATVRADIO, "Terratec TV Radio+" }, | ||
209 | { 0x1127153b, BTTV_BOARD_TERRATV, "Terratec TV+ (V1.05)" }, | ||
210 | /* clashes with FlyVideo | ||
211 | *{ 0x18521852, BTTV_BOARD_TERRATV, "Terratec TV+ (V1.10)" }, */ | ||
212 | { 0x1134153b, BTTV_BOARD_TERRATVALUE, "Terratec TValue (LR102)" }, | ||
213 | { 0x1135153b, BTTV_BOARD_TERRATVALUER, "Terratec TValue Radio" }, /* LR102 */ | ||
214 | { 0x5018153b, BTTV_BOARD_TERRATVALUE, "Terratec TValue" }, /* ?? */ | ||
215 | { 0xff3b153b, BTTV_BOARD_TERRATVALUER, "Terratec TValue Radio" }, /* ?? */ | ||
216 | |||
217 | { 0x400015b0, BTTV_BOARD_ZOLTRIX_GENIE, "Zoltrix Genie TV" }, | ||
218 | { 0x400a15b0, BTTV_BOARD_ZOLTRIX_GENIE, "Zoltrix Genie TV" }, | ||
219 | { 0x400d15b0, BTTV_BOARD_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" }, | ||
220 | { 0x401015b0, BTTV_BOARD_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" }, | ||
221 | { 0x401615b0, BTTV_BOARD_ZOLTRIX_GENIE, "Zoltrix Genie TV / Radio" }, | ||
222 | |||
223 | { 0x1430aa00, BTTV_BOARD_PV143, "Provideo PV143A" }, | ||
224 | { 0x1431aa00, BTTV_BOARD_PV143, "Provideo PV143B" }, | ||
225 | { 0x1432aa00, BTTV_BOARD_PV143, "Provideo PV143C" }, | ||
226 | { 0x1433aa00, BTTV_BOARD_PV143, "Provideo PV143D" }, | ||
227 | { 0x1433aa03, BTTV_BOARD_PV143, "Security Eyes" }, | ||
228 | |||
229 | { 0x1460aa00, BTTV_BOARD_PV150, "Provideo PV150A-1" }, | ||
230 | { 0x1461aa01, BTTV_BOARD_PV150, "Provideo PV150A-2" }, | ||
231 | { 0x1462aa02, BTTV_BOARD_PV150, "Provideo PV150A-3" }, | ||
232 | { 0x1463aa03, BTTV_BOARD_PV150, "Provideo PV150A-4" }, | ||
233 | |||
234 | { 0x1464aa04, BTTV_BOARD_PV150, "Provideo PV150B-1" }, | ||
235 | { 0x1465aa05, BTTV_BOARD_PV150, "Provideo PV150B-2" }, | ||
236 | { 0x1466aa06, BTTV_BOARD_PV150, "Provideo PV150B-3" }, | ||
237 | { 0x1467aa07, BTTV_BOARD_PV150, "Provideo PV150B-4" }, | ||
238 | |||
239 | { 0xa132ff00, BTTV_BOARD_IVC100, "IVC-100" }, | ||
240 | { 0xa1550000, BTTV_BOARD_IVC200, "IVC-200" }, | ||
241 | { 0xa1550001, BTTV_BOARD_IVC200, "IVC-200" }, | ||
242 | { 0xa1550002, BTTV_BOARD_IVC200, "IVC-200" }, | ||
243 | { 0xa1550003, BTTV_BOARD_IVC200, "IVC-200" }, | ||
244 | { 0xa1550100, BTTV_BOARD_IVC200, "IVC-200G" }, | ||
245 | { 0xa1550101, BTTV_BOARD_IVC200, "IVC-200G" }, | ||
246 | { 0xa1550102, BTTV_BOARD_IVC200, "IVC-200G" }, | ||
247 | { 0xa1550103, BTTV_BOARD_IVC200, "IVC-200G" }, | ||
248 | { 0xa1550800, BTTV_BOARD_IVC200, "IVC-200" }, | ||
249 | { 0xa1550801, BTTV_BOARD_IVC200, "IVC-200" }, | ||
250 | { 0xa1550802, BTTV_BOARD_IVC200, "IVC-200" }, | ||
251 | { 0xa1550803, BTTV_BOARD_IVC200, "IVC-200" }, | ||
252 | { 0xa182ff00, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
253 | { 0xa182ff01, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
254 | { 0xa182ff02, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
255 | { 0xa182ff03, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
256 | { 0xa182ff04, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
257 | { 0xa182ff05, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
258 | { 0xa182ff06, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
259 | { 0xa182ff07, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
260 | { 0xa182ff08, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
261 | { 0xa182ff09, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
262 | { 0xa182ff0a, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
263 | { 0xa182ff0b, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
264 | { 0xa182ff0c, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
265 | { 0xa182ff0d, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
266 | { 0xa182ff0e, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
267 | { 0xa182ff0f, BTTV_BOARD_IVC120, "IVC-120G" }, | ||
268 | { 0xf0500000, BTTV_BOARD_IVCE8784, "IVCE-8784" }, | ||
269 | { 0xf0500001, BTTV_BOARD_IVCE8784, "IVCE-8784" }, | ||
270 | { 0xf0500002, BTTV_BOARD_IVCE8784, "IVCE-8784" }, | ||
271 | { 0xf0500003, BTTV_BOARD_IVCE8784, "IVCE-8784" }, | ||
272 | |||
273 | { 0x41424344, BTTV_BOARD_GRANDTEC, "GrandTec Multi Capture" }, | ||
274 | { 0x01020304, BTTV_BOARD_XGUARD, "Grandtec Grand X-Guard" }, | ||
275 | |||
276 | { 0x18501851, BTTV_BOARD_CHRONOS_VS2, "FlyVideo 98 (LR50)/ Chronos Video Shuttle II" }, | ||
277 | { 0xa0501851, BTTV_BOARD_CHRONOS_VS2, "FlyVideo 98 (LR50)/ Chronos Video Shuttle II" }, | ||
278 | { 0x18511851, BTTV_BOARD_FLYVIDEO98EZ, "FlyVideo 98EZ (LR51)/ CyberMail AV" }, | ||
279 | { 0x18521852, BTTV_BOARD_TYPHOON_TVIEW, "FlyVideo 98FM (LR50)/ Typhoon TView TV/FM Tuner" }, | ||
280 | { 0x41a0a051, BTTV_BOARD_FLYVIDEO_98FM, "Lifeview FlyVideo 98 LR50 Rev Q" }, | ||
281 | { 0x18501f7f, BTTV_BOARD_FLYVIDEO_98, "Lifeview Flyvideo 98" }, | ||
282 | |||
283 | { 0x010115cb, BTTV_BOARD_GMV1, "AG GMV1" }, | ||
284 | { 0x010114c7, BTTV_BOARD_MODTEC_205, "Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV" }, | ||
285 | |||
286 | { 0x10b42636, BTTV_BOARD_HAUPPAUGE878, "STB ???" }, | ||
287 | { 0x217d6606, BTTV_BOARD_WINFAST2000, "Leadtek WinFast TV 2000" }, | ||
288 | { 0xfff6f6ff, BTTV_BOARD_WINFAST2000, "Leadtek WinFast TV 2000" }, | ||
289 | { 0x03116000, BTTV_BOARD_SENSORAY311_611, "Sensoray 311" }, | ||
290 | { 0x06116000, BTTV_BOARD_SENSORAY311_611, "Sensoray 611" }, | ||
291 | { 0x00790e11, BTTV_BOARD_WINDVR, "Canopus WinDVR PCI" }, | ||
292 | { 0xa0fca1a0, BTTV_BOARD_ZOLTRIX, "Face to Face Tvmax" }, | ||
293 | { 0x82b2aa6a, BTTV_BOARD_SIMUS_GVC1100, "SIMUS GVC1100" }, | ||
294 | { 0x146caa0c, BTTV_BOARD_PV951, "ituner spectra8" }, | ||
295 | { 0x200a1295, BTTV_BOARD_PXC200, "ImageNation PXC200A" }, | ||
296 | |||
297 | { 0x40111554, BTTV_BOARD_PV_BT878P_9B, "Prolink Pixelview PV-BT" }, | ||
298 | { 0x17de0a01, BTTV_BOARD_KWORLD, "Mecer TV/FM/Video Tuner" }, | ||
299 | |||
300 | { 0x01051805, BTTV_BOARD_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #1" }, | ||
301 | { 0x01061805, BTTV_BOARD_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #2" }, | ||
302 | { 0x01071805, BTTV_BOARD_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #3" }, | ||
303 | { 0x01081805, BTTV_BOARD_PICOLO_TETRA_CHIP, "Picolo Tetra Chip #4" }, | ||
304 | |||
305 | { 0x15409511, BTTV_BOARD_ACORP_Y878F, "Acorp Y878F" }, | ||
306 | |||
307 | { 0x53534149, BTTV_BOARD_SSAI_SECURITY, "SSAI Security Video Interface" }, | ||
308 | { 0x5353414a, BTTV_BOARD_SSAI_ULTRASOUND, "SSAI Ultrasound Video Interface" }, | ||
309 | |||
310 | /* likely broken, vendor id doesn't match the other magic views ... | ||
311 | * { 0xa0fca04f, BTTV_BOARD_MAGICTVIEW063, "Guillemot Maxi TV Video 3" }, */ | ||
312 | |||
313 | /* Duplicate PCI ID, reconfigure for this board during the eeprom read. | ||
314 | * { 0x13eb0070, BTTV_BOARD_HAUPPAUGE_IMPACTVCB, "Hauppauge ImpactVCB" }, */ | ||
315 | |||
316 | { 0x109e036e, BTTV_BOARD_CONCEPTRONIC_CTVFMI2, "Conceptronic CTVFMi v2"}, | ||
317 | |||
318 | /* DVB cards (using pci function .1 for mpeg data xfer) */ | ||
319 | { 0x001c11bd, BTTV_BOARD_PINNACLESAT, "Pinnacle PCTV Sat" }, | ||
320 | { 0x01010071, BTTV_BOARD_NEBULA_DIGITV, "Nebula Electronics DigiTV" }, | ||
321 | { 0x20007063, BTTV_BOARD_PC_HDTV, "pcHDTV HD-2000 TV"}, | ||
322 | { 0x002611bd, BTTV_BOARD_TWINHAN_DST, "Pinnacle PCTV SAT CI" }, | ||
323 | { 0x00011822, BTTV_BOARD_TWINHAN_DST, "Twinhan VisionPlus DVB" }, | ||
324 | { 0xfc00270f, BTTV_BOARD_TWINHAN_DST, "ChainTech digitop DST-1000 DVB-S" }, | ||
325 | { 0x07711461, BTTV_BOARD_AVDVBT_771, "AVermedia AverTV DVB-T 771" }, | ||
326 | { 0x07611461, BTTV_BOARD_AVDVBT_761, "AverMedia AverTV DVB-T 761" }, | ||
327 | { 0xdb1018ac, BTTV_BOARD_DVICO_DVBT_LITE, "DViCO FusionHDTV DVB-T Lite" }, | ||
328 | { 0xdb1118ac, BTTV_BOARD_DVICO_DVBT_LITE, "Ultraview DVB-T Lite" }, | ||
329 | { 0xd50018ac, BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE, "DViCO FusionHDTV 5 Lite" }, | ||
330 | { 0x00261822, BTTV_BOARD_TWINHAN_DST, "DNTV Live! Mini "}, | ||
331 | { 0xd200dbc0, BTTV_BOARD_DVICO_FUSIONHDTV_2, "DViCO FusionHDTV 2" }, | ||
332 | { 0x763c008a, BTTV_BOARD_GEOVISION_GV600, "GeoVision GV-600" }, | ||
333 | { 0x18011000, BTTV_BOARD_ENLTV_FM_2, "Encore ENL TV-FM-2" }, | ||
334 | { 0x763d800a, BTTV_BOARD_GEOVISION_GV800S, "GeoVision GV-800(S) (master)" }, | ||
335 | { 0x763d800b, BTTV_BOARD_GEOVISION_GV800S_SL, "GeoVision GV-800(S) (slave)" }, | ||
336 | { 0x763d800c, BTTV_BOARD_GEOVISION_GV800S_SL, "GeoVision GV-800(S) (slave)" }, | ||
337 | { 0x763d800d, BTTV_BOARD_GEOVISION_GV800S_SL, "GeoVision GV-800(S) (slave)" }, | ||
338 | |||
339 | { 0x15401830, BTTV_BOARD_PV183, "Provideo PV183-1" }, | ||
340 | { 0x15401831, BTTV_BOARD_PV183, "Provideo PV183-2" }, | ||
341 | { 0x15401832, BTTV_BOARD_PV183, "Provideo PV183-3" }, | ||
342 | { 0x15401833, BTTV_BOARD_PV183, "Provideo PV183-4" }, | ||
343 | { 0x15401834, BTTV_BOARD_PV183, "Provideo PV183-5" }, | ||
344 | { 0x15401835, BTTV_BOARD_PV183, "Provideo PV183-6" }, | ||
345 | { 0x15401836, BTTV_BOARD_PV183, "Provideo PV183-7" }, | ||
346 | { 0x15401837, BTTV_BOARD_PV183, "Provideo PV183-8" }, | ||
347 | { 0x3116f200, BTTV_BOARD_TVT_TD3116, "Tongwei Video Technology TD-3116" }, | ||
348 | { 0x02280279, BTTV_BOARD_APOSONIC_WDVR, "Aposonic W-DVR" }, | ||
349 | { 0, -1, NULL } | ||
350 | }; | ||
351 | |||
352 | /* ----------------------------------------------------------------------- */ | ||
353 | /* array with description for bt848 / bt878 tv/grabber cards */ | ||
354 | |||
355 | struct tvcard bttv_tvcards[] = { | ||
356 | /* ---- card 0x00 ---------------------------------- */ | ||
357 | [BTTV_BOARD_UNKNOWN] = { | ||
358 | .name = " *** UNKNOWN/GENERIC *** ", | ||
359 | .video_inputs = 4, | ||
360 | .svhs = 2, | ||
361 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
362 | .tuner_type = UNSET, | ||
363 | .tuner_addr = ADDR_UNSET, | ||
364 | }, | ||
365 | [BTTV_BOARD_MIRO] = { | ||
366 | .name = "MIRO PCTV", | ||
367 | .video_inputs = 4, | ||
368 | /* .audio_inputs= 1, */ | ||
369 | .svhs = 2, | ||
370 | .gpiomask = 15, | ||
371 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
372 | .gpiomux = { 2, 0, 0, 0 }, | ||
373 | .gpiomute = 10, | ||
374 | .tuner_type = UNSET, | ||
375 | .tuner_addr = ADDR_UNSET, | ||
376 | }, | ||
377 | [BTTV_BOARD_HAUPPAUGE] = { | ||
378 | .name = "Hauppauge (bt848)", | ||
379 | .video_inputs = 4, | ||
380 | /* .audio_inputs= 1, */ | ||
381 | .svhs = 2, | ||
382 | .gpiomask = 7, | ||
383 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
384 | .gpiomux = { 0, 1, 2, 3 }, | ||
385 | .gpiomute = 4, | ||
386 | .tuner_type = UNSET, | ||
387 | .tuner_addr = ADDR_UNSET, | ||
388 | }, | ||
389 | [BTTV_BOARD_STB] = { | ||
390 | .name = "STB, Gateway P/N 6000699 (bt848)", | ||
391 | .video_inputs = 3, | ||
392 | /* .audio_inputs= 1, */ | ||
393 | .svhs = 2, | ||
394 | .gpiomask = 7, | ||
395 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
396 | .gpiomux = { 4, 0, 2, 3 }, | ||
397 | .gpiomute = 1, | ||
398 | .no_msp34xx = 1, | ||
399 | .tuner_type = TUNER_PHILIPS_NTSC, | ||
400 | .tuner_addr = ADDR_UNSET, | ||
401 | .pll = PLL_28, | ||
402 | .has_radio = 1, | ||
403 | }, | ||
404 | |||
405 | /* ---- card 0x04 ---------------------------------- */ | ||
406 | [BTTV_BOARD_INTEL] = { | ||
407 | .name = "Intel Create and Share PCI/ Smart Video Recorder III", | ||
408 | .video_inputs = 4, | ||
409 | /* .audio_inputs= 0, */ | ||
410 | .svhs = 2, | ||
411 | .gpiomask = 0, | ||
412 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
413 | .gpiomux = { 0 }, | ||
414 | .tuner_type = TUNER_ABSENT, | ||
415 | .tuner_addr = ADDR_UNSET, | ||
416 | }, | ||
417 | [BTTV_BOARD_DIAMOND] = { | ||
418 | .name = "Diamond DTV2000", | ||
419 | .video_inputs = 4, | ||
420 | /* .audio_inputs= 1, */ | ||
421 | .svhs = 2, | ||
422 | .gpiomask = 3, | ||
423 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
424 | .gpiomux = { 0, 1, 0, 1 }, | ||
425 | .gpiomute = 3, | ||
426 | .tuner_type = UNSET, | ||
427 | .tuner_addr = ADDR_UNSET, | ||
428 | }, | ||
429 | [BTTV_BOARD_AVERMEDIA] = { | ||
430 | .name = "AVerMedia TVPhone", | ||
431 | .video_inputs = 3, | ||
432 | /* .audio_inputs= 1, */ | ||
433 | .svhs = 3, | ||
434 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
435 | .gpiomask = 0x0f, | ||
436 | .gpiomux = { 0x0c, 0x04, 0x08, 0x04 }, | ||
437 | /* 0x04 for some cards ?? */ | ||
438 | .tuner_type = UNSET, | ||
439 | .tuner_addr = ADDR_UNSET, | ||
440 | .audio_mode_gpio= avermedia_tvphone_audio, | ||
441 | .has_remote = 1, | ||
442 | }, | ||
443 | [BTTV_BOARD_MATRIX_VISION] = { | ||
444 | .name = "MATRIX-Vision MV-Delta", | ||
445 | .video_inputs = 5, | ||
446 | /* .audio_inputs= 1, */ | ||
447 | .svhs = 3, | ||
448 | .gpiomask = 0, | ||
449 | .muxsel = MUXSEL(2, 3, 1, 0, 0), | ||
450 | .gpiomux = { 0 }, | ||
451 | .tuner_type = TUNER_ABSENT, | ||
452 | .tuner_addr = ADDR_UNSET, | ||
453 | }, | ||
454 | |||
455 | /* ---- card 0x08 ---------------------------------- */ | ||
456 | [BTTV_BOARD_FLYVIDEO] = { | ||
457 | .name = "Lifeview FlyVideo II (Bt848) LR26 / MAXI TV Video PCI2 LR26", | ||
458 | .video_inputs = 4, | ||
459 | /* .audio_inputs= 1, */ | ||
460 | .svhs = 2, | ||
461 | .gpiomask = 0xc00, | ||
462 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
463 | .gpiomux = { 0, 0xc00, 0x800, 0x400 }, | ||
464 | .gpiomute = 0xc00, | ||
465 | .pll = PLL_28, | ||
466 | .tuner_type = UNSET, | ||
467 | .tuner_addr = ADDR_UNSET, | ||
468 | }, | ||
469 | [BTTV_BOARD_TURBOTV] = { | ||
470 | .name = "IMS/IXmicro TurboTV", | ||
471 | .video_inputs = 3, | ||
472 | /* .audio_inputs= 1, */ | ||
473 | .svhs = 2, | ||
474 | .gpiomask = 3, | ||
475 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
476 | .gpiomux = { 1, 1, 2, 3 }, | ||
477 | .pll = PLL_28, | ||
478 | .tuner_type = TUNER_TEMIC_PAL, | ||
479 | .tuner_addr = ADDR_UNSET, | ||
480 | }, | ||
481 | [BTTV_BOARD_HAUPPAUGE878] = { | ||
482 | .name = "Hauppauge (bt878)", | ||
483 | .video_inputs = 4, | ||
484 | /* .audio_inputs= 1, */ | ||
485 | .svhs = 2, | ||
486 | .gpiomask = 0x0f, /* old: 7 */ | ||
487 | .muxsel = MUXSEL(2, 0, 1, 1), | ||
488 | .gpiomux = { 0, 1, 2, 3 }, | ||
489 | .gpiomute = 4, | ||
490 | .pll = PLL_28, | ||
491 | .tuner_type = UNSET, | ||
492 | .tuner_addr = ADDR_UNSET, | ||
493 | }, | ||
494 | [BTTV_BOARD_MIROPRO] = { | ||
495 | .name = "MIRO PCTV pro", | ||
496 | .video_inputs = 3, | ||
497 | /* .audio_inputs= 1, */ | ||
498 | .svhs = 2, | ||
499 | .gpiomask = 0x3014f, | ||
500 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
501 | .gpiomux = { 0x20001,0x10001, 0, 0 }, | ||
502 | .gpiomute = 10, | ||
503 | .tuner_type = UNSET, | ||
504 | .tuner_addr = ADDR_UNSET, | ||
505 | }, | ||
506 | |||
507 | /* ---- card 0x0c ---------------------------------- */ | ||
508 | [BTTV_BOARD_ADSTECH_TV] = { | ||
509 | .name = "ADS Technologies Channel Surfer TV (bt848)", | ||
510 | .video_inputs = 3, | ||
511 | /* .audio_inputs= 1, */ | ||
512 | .svhs = 2, | ||
513 | .gpiomask = 15, | ||
514 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
515 | .gpiomux = { 13, 14, 11, 7 }, | ||
516 | .tuner_type = UNSET, | ||
517 | .tuner_addr = ADDR_UNSET, | ||
518 | }, | ||
519 | [BTTV_BOARD_AVERMEDIA98] = { | ||
520 | .name = "AVerMedia TVCapture 98", | ||
521 | .video_inputs = 3, | ||
522 | /* .audio_inputs= 4, */ | ||
523 | .svhs = 2, | ||
524 | .gpiomask = 15, | ||
525 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
526 | .gpiomux = { 13, 14, 11, 7 }, | ||
527 | .msp34xx_alt = 1, | ||
528 | .pll = PLL_28, | ||
529 | .tuner_type = TUNER_PHILIPS_PAL, | ||
530 | .tuner_addr = ADDR_UNSET, | ||
531 | .audio_mode_gpio= avermedia_tv_stereo_audio, | ||
532 | .no_gpioirq = 1, | ||
533 | }, | ||
534 | [BTTV_BOARD_VHX] = { | ||
535 | .name = "Aimslab Video Highway Xtreme (VHX)", | ||
536 | .video_inputs = 3, | ||
537 | /* .audio_inputs= 1, */ | ||
538 | .svhs = 2, | ||
539 | .gpiomask = 7, | ||
540 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
541 | .gpiomux = { 0, 2, 1, 3 }, /* old: {0, 1, 2, 3, 4} */ | ||
542 | .gpiomute = 4, | ||
543 | .pll = PLL_28, | ||
544 | .tuner_type = UNSET, | ||
545 | .tuner_addr = ADDR_UNSET, | ||
546 | }, | ||
547 | [BTTV_BOARD_ZOLTRIX] = { | ||
548 | .name = "Zoltrix TV-Max", | ||
549 | .video_inputs = 3, | ||
550 | /* .audio_inputs= 1, */ | ||
551 | .svhs = 2, | ||
552 | .gpiomask = 15, | ||
553 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
554 | .gpiomux = { 0, 0, 1, 0 }, | ||
555 | .gpiomute = 10, | ||
556 | .tuner_type = UNSET, | ||
557 | .tuner_addr = ADDR_UNSET, | ||
558 | }, | ||
559 | |||
560 | /* ---- card 0x10 ---------------------------------- */ | ||
561 | [BTTV_BOARD_PIXVIEWPLAYTV] = { | ||
562 | .name = "Prolink Pixelview PlayTV (bt878)", | ||
563 | .video_inputs = 3, | ||
564 | /* .audio_inputs= 1, */ | ||
565 | .svhs = 2, | ||
566 | .gpiomask = 0x01fe00, | ||
567 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
568 | /* 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru> */ | ||
569 | .gpiomux = { 0x001e00, 0, 0x018000, 0x014000 }, | ||
570 | .gpiomute = 0x002000, | ||
571 | .pll = PLL_28, | ||
572 | .tuner_type = UNSET, | ||
573 | .tuner_addr = ADDR_UNSET, | ||
574 | }, | ||
575 | [BTTV_BOARD_WINVIEW_601] = { | ||
576 | .name = "Leadtek WinView 601", | ||
577 | .video_inputs = 3, | ||
578 | /* .audio_inputs= 1, */ | ||
579 | .svhs = 2, | ||
580 | .gpiomask = 0x8300f8, | ||
581 | .muxsel = MUXSEL(2, 3, 1, 1, 0), | ||
582 | .gpiomux = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007 }, | ||
583 | .gpiomute = 0xcfa007, | ||
584 | .tuner_type = UNSET, | ||
585 | .tuner_addr = ADDR_UNSET, | ||
586 | .volume_gpio = winview_volume, | ||
587 | .has_radio = 1, | ||
588 | }, | ||
589 | [BTTV_BOARD_AVEC_INTERCAP] = { | ||
590 | .name = "AVEC Intercapture", | ||
591 | .video_inputs = 3, | ||
592 | /* .audio_inputs= 2, */ | ||
593 | .svhs = 2, | ||
594 | .gpiomask = 0, | ||
595 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
596 | .gpiomux = { 1, 0, 0, 0 }, | ||
597 | .tuner_type = UNSET, | ||
598 | .tuner_addr = ADDR_UNSET, | ||
599 | }, | ||
600 | [BTTV_BOARD_LIFE_FLYKIT] = { | ||
601 | .name = "Lifeview FlyVideo II EZ /FlyKit LR38 Bt848 (capture only)", | ||
602 | .video_inputs = 4, | ||
603 | /* .audio_inputs= 1, */ | ||
604 | .svhs = NO_SVHS, | ||
605 | .gpiomask = 0x8dff00, | ||
606 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
607 | .gpiomux = { 0 }, | ||
608 | .no_msp34xx = 1, | ||
609 | .tuner_type = TUNER_ABSENT, | ||
610 | .tuner_addr = ADDR_UNSET, | ||
611 | }, | ||
612 | |||
613 | /* ---- card 0x14 ---------------------------------- */ | ||
614 | [BTTV_BOARD_CEI_RAFFLES] = { | ||
615 | .name = "CEI Raffles Card", | ||
616 | .video_inputs = 3, | ||
617 | /* .audio_inputs= 3, */ | ||
618 | .svhs = 2, | ||
619 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
620 | .tuner_type = UNSET, | ||
621 | .tuner_addr = ADDR_UNSET, | ||
622 | }, | ||
623 | [BTTV_BOARD_CONFERENCETV] = { | ||
624 | .name = "Lifeview FlyVideo 98/ Lucky Star Image World ConferenceTV LR50", | ||
625 | .video_inputs = 4, | ||
626 | /* .audio_inputs= 2, tuner, line in */ | ||
627 | .svhs = 2, | ||
628 | .gpiomask = 0x1800, | ||
629 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
630 | .gpiomux = { 0, 0x800, 0x1000, 0x1000 }, | ||
631 | .gpiomute = 0x1800, | ||
632 | .pll = PLL_28, | ||
633 | .tuner_type = TUNER_PHILIPS_PAL_I, | ||
634 | .tuner_addr = ADDR_UNSET, | ||
635 | }, | ||
636 | [BTTV_BOARD_PHOEBE_TVMAS] = { | ||
637 | .name = "Askey CPH050/ Phoebe Tv Master + FM", | ||
638 | .video_inputs = 3, | ||
639 | /* .audio_inputs= 1, */ | ||
640 | .svhs = 2, | ||
641 | .gpiomask = 0xc00, | ||
642 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
643 | .gpiomux = { 0, 1, 0x800, 0x400 }, | ||
644 | .gpiomute = 0xc00, | ||
645 | .pll = PLL_28, | ||
646 | .tuner_type = UNSET, | ||
647 | .tuner_addr = ADDR_UNSET, | ||
648 | }, | ||
649 | [BTTV_BOARD_MODTEC_205] = { | ||
650 | .name = "Modular Technology MM201/MM202/MM205/MM210/MM215 PCTV, bt878", | ||
651 | .video_inputs = 3, | ||
652 | /* .audio_inputs= 1, */ | ||
653 | .svhs = NO_SVHS, | ||
654 | .has_dig_in = 1, | ||
655 | .gpiomask = 7, | ||
656 | .muxsel = MUXSEL(2, 3, 0), /* input 2 is digital */ | ||
657 | /* .digital_mode= DIGITAL_MODE_CAMERA, */ | ||
658 | .gpiomux = { 0, 0, 0, 0 }, | ||
659 | .no_msp34xx = 1, | ||
660 | .pll = PLL_28, | ||
661 | .tuner_type = TUNER_ALPS_TSBB5_PAL_I, | ||
662 | .tuner_addr = ADDR_UNSET, | ||
663 | }, | ||
664 | |||
665 | /* ---- card 0x18 ---------------------------------- */ | ||
666 | [BTTV_BOARD_MAGICTVIEW061] = { | ||
667 | .name = "Askey CPH05X/06X (bt878) [many vendors]", | ||
668 | .video_inputs = 3, | ||
669 | /* .audio_inputs= 1, */ | ||
670 | .svhs = 2, | ||
671 | .gpiomask = 0xe00, | ||
672 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
673 | .gpiomux = {0x400, 0x400, 0x400, 0x400 }, | ||
674 | .gpiomute = 0xc00, | ||
675 | .pll = PLL_28, | ||
676 | .tuner_type = UNSET, | ||
677 | .tuner_addr = ADDR_UNSET, | ||
678 | .has_remote = 1, | ||
679 | .has_radio = 1, /* not every card has radio */ | ||
680 | }, | ||
681 | [BTTV_BOARD_VOBIS_BOOSTAR] = { | ||
682 | .name = "Terratec TerraTV+ Version 1.0 (Bt848)/ Terra TValue Version 1.0/ Vobis TV-Boostar", | ||
683 | .video_inputs = 3, | ||
684 | /* .audio_inputs= 1, */ | ||
685 | .svhs = 2, | ||
686 | .gpiomask = 0x1f0fff, | ||
687 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
688 | .gpiomux = { 0x20000, 0x30000, 0x10000, 0 }, | ||
689 | .gpiomute = 0x40000, | ||
690 | .tuner_type = TUNER_PHILIPS_PAL, | ||
691 | .tuner_addr = ADDR_UNSET, | ||
692 | .audio_mode_gpio= terratv_audio, | ||
693 | }, | ||
694 | [BTTV_BOARD_HAUPPAUG_WCAM] = { | ||
695 | .name = "Hauppauge WinCam newer (bt878)", | ||
696 | .video_inputs = 4, | ||
697 | /* .audio_inputs= 1, */ | ||
698 | .svhs = 3, | ||
699 | .gpiomask = 7, | ||
700 | .muxsel = MUXSEL(2, 0, 1, 1), | ||
701 | .gpiomux = { 0, 1, 2, 3 }, | ||
702 | .gpiomute = 4, | ||
703 | .tuner_type = UNSET, | ||
704 | .tuner_addr = ADDR_UNSET, | ||
705 | }, | ||
706 | [BTTV_BOARD_MAXI] = { | ||
707 | .name = "Lifeview FlyVideo 98/ MAXI TV Video PCI2 LR50", | ||
708 | .video_inputs = 4, | ||
709 | /* .audio_inputs= 2, */ | ||
710 | .svhs = 2, | ||
711 | .gpiomask = 0x1800, | ||
712 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
713 | .gpiomux = { 0, 0x800, 0x1000, 0x1000 }, | ||
714 | .gpiomute = 0x1800, | ||
715 | .pll = PLL_28, | ||
716 | .tuner_type = TUNER_PHILIPS_SECAM, | ||
717 | .tuner_addr = ADDR_UNSET, | ||
718 | }, | ||
719 | |||
720 | /* ---- card 0x1c ---------------------------------- */ | ||
721 | [BTTV_BOARD_TERRATV] = { | ||
722 | .name = "Terratec TerraTV+ Version 1.1 (bt878)", | ||
723 | .video_inputs = 3, | ||
724 | /* .audio_inputs= 1, */ | ||
725 | .svhs = 2, | ||
726 | .gpiomask = 0x1f0fff, | ||
727 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
728 | .gpiomux = { 0x20000, 0x30000, 0x10000, 0x00000 }, | ||
729 | .gpiomute = 0x40000, | ||
730 | .tuner_type = TUNER_PHILIPS_PAL, | ||
731 | .tuner_addr = ADDR_UNSET, | ||
732 | .audio_mode_gpio= terratv_audio, | ||
733 | /* GPIO wiring: | ||
734 | External 20 pin connector (for Active Radio Upgrade board) | ||
735 | gpio00: i2c-sda | ||
736 | gpio01: i2c-scl | ||
737 | gpio02: om5610-data | ||
738 | gpio03: om5610-clk | ||
739 | gpio04: om5610-wre | ||
740 | gpio05: om5610-stereo | ||
741 | gpio06: rds6588-davn | ||
742 | gpio07: Pin 7 n.c. | ||
743 | gpio08: nIOW | ||
744 | gpio09+10: nIOR, nSEL ?? (bt878) | ||
745 | gpio09: nIOR (bt848) | ||
746 | gpio10: nSEL (bt848) | ||
747 | Sound Routing: | ||
748 | gpio16: u2-A0 (1st 4052bt) | ||
749 | gpio17: u2-A1 | ||
750 | gpio18: u2-nEN | ||
751 | gpio19: u4-A0 (2nd 4052) | ||
752 | gpio20: u4-A1 | ||
753 | u4-nEN - GND | ||
754 | Btspy: | ||
755 | 00000 : Cdrom (internal audio input) | ||
756 | 10000 : ext. Video audio input | ||
757 | 20000 : TV Mono | ||
758 | a0000 : TV Mono/2 | ||
759 | 1a0000 : TV Stereo | ||
760 | 30000 : Radio | ||
761 | 40000 : Mute | ||
762 | */ | ||
763 | |||
764 | }, | ||
765 | [BTTV_BOARD_PXC200] = { | ||
766 | /* Jannik Fritsch <jannik@techfak.uni-bielefeld.de> */ | ||
767 | .name = "Imagenation PXC200", | ||
768 | .video_inputs = 5, | ||
769 | /* .audio_inputs= 1, */ | ||
770 | .svhs = 1, /* was: 4 */ | ||
771 | .gpiomask = 0, | ||
772 | .muxsel = MUXSEL(2, 3, 1, 0, 0), | ||
773 | .gpiomux = { 0 }, | ||
774 | .tuner_type = TUNER_ABSENT, | ||
775 | .tuner_addr = ADDR_UNSET, | ||
776 | .muxsel_hook = PXC200_muxsel, | ||
777 | |||
778 | }, | ||
779 | [BTTV_BOARD_FLYVIDEO_98] = { | ||
780 | .name = "Lifeview FlyVideo 98 LR50", | ||
781 | .video_inputs = 4, | ||
782 | /* .audio_inputs= 1, */ | ||
783 | .svhs = 2, | ||
784 | .gpiomask = 0x1800, /* 0x8dfe00 */ | ||
785 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
786 | .gpiomux = { 0, 0x0800, 0x1000, 0x1000 }, | ||
787 | .gpiomute = 0x1800, | ||
788 | .pll = PLL_28, | ||
789 | .tuner_type = UNSET, | ||
790 | .tuner_addr = ADDR_UNSET, | ||
791 | }, | ||
792 | [BTTV_BOARD_IPROTV] = { | ||
793 | .name = "Formac iProTV, Formac ProTV I (bt848)", | ||
794 | .video_inputs = 4, | ||
795 | /* .audio_inputs= 1, */ | ||
796 | .svhs = 3, | ||
797 | .gpiomask = 1, | ||
798 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
799 | .gpiomux = { 1, 0, 0, 0 }, | ||
800 | .pll = PLL_28, | ||
801 | .tuner_type = TUNER_PHILIPS_PAL, | ||
802 | .tuner_addr = ADDR_UNSET, | ||
803 | }, | ||
804 | |||
805 | /* ---- card 0x20 ---------------------------------- */ | ||
806 | [BTTV_BOARD_INTEL_C_S_PCI] = { | ||
807 | .name = "Intel Create and Share PCI/ Smart Video Recorder III", | ||
808 | .video_inputs = 4, | ||
809 | /* .audio_inputs= 0, */ | ||
810 | .svhs = 2, | ||
811 | .gpiomask = 0, | ||
812 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
813 | .gpiomux = { 0 }, | ||
814 | .tuner_type = TUNER_ABSENT, | ||
815 | .tuner_addr = ADDR_UNSET, | ||
816 | }, | ||
817 | [BTTV_BOARD_TERRATVALUE] = { | ||
818 | .name = "Terratec TerraTValue Version Bt878", | ||
819 | .video_inputs = 3, | ||
820 | /* .audio_inputs= 1, */ | ||
821 | .svhs = 2, | ||
822 | .gpiomask = 0xffff00, | ||
823 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
824 | .gpiomux = { 0x500, 0, 0x300, 0x900 }, | ||
825 | .gpiomute = 0x900, | ||
826 | .pll = PLL_28, | ||
827 | .tuner_type = TUNER_PHILIPS_PAL, | ||
828 | .tuner_addr = ADDR_UNSET, | ||
829 | }, | ||
830 | [BTTV_BOARD_WINFAST2000] = { | ||
831 | .name = "Leadtek WinFast 2000/ WinFast 2000 XP", | ||
832 | .video_inputs = 4, | ||
833 | /* .audio_inputs= 1, */ | ||
834 | .svhs = 2, | ||
835 | /* TV, CVid, SVid, CVid over SVid connector */ | ||
836 | .muxsel = MUXSEL(2, 3, 1, 1, 0), | ||
837 | /* Alexander Varakin <avarakin@hotmail.com> [stereo version] */ | ||
838 | .gpiomask = 0xb33000, | ||
839 | .gpiomux = { 0x122000,0x1000,0x0000,0x620000 }, | ||
840 | .gpiomute = 0x800000, | ||
841 | /* Audio Routing for "WinFast 2000 XP" (no tv stereo !) | ||
842 | gpio23 -- hef4052:nEnable (0x800000) | ||
843 | gpio12 -- hef4052:A1 | ||
844 | gpio13 -- hef4052:A0 | ||
845 | 0x0000: external audio | ||
846 | 0x1000: FM | ||
847 | 0x2000: TV | ||
848 | 0x3000: n.c. | ||
849 | Note: There exists another variant "Winfast 2000" with tv stereo !? | ||
850 | Note: eeprom only contains FF and pci subsystem id 107d:6606 | ||
851 | */ | ||
852 | .pll = PLL_28, | ||
853 | .has_radio = 1, | ||
854 | .tuner_type = TUNER_PHILIPS_PAL, /* default for now, gpio reads BFFF06 for Pal bg+dk */ | ||
855 | .tuner_addr = ADDR_UNSET, | ||
856 | .audio_mode_gpio= winfast2000_audio, | ||
857 | .has_remote = 1, | ||
858 | }, | ||
859 | [BTTV_BOARD_CHRONOS_VS2] = { | ||
860 | .name = "Lifeview FlyVideo 98 LR50 / Chronos Video Shuttle II", | ||
861 | .video_inputs = 4, | ||
862 | /* .audio_inputs= 3, */ | ||
863 | .svhs = 2, | ||
864 | .gpiomask = 0x1800, | ||
865 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
866 | .gpiomux = { 0, 0x800, 0x1000, 0x1000 }, | ||
867 | .gpiomute = 0x1800, | ||
868 | .pll = PLL_28, | ||
869 | .tuner_type = UNSET, | ||
870 | .tuner_addr = ADDR_UNSET, | ||
871 | }, | ||
872 | |||
873 | /* ---- card 0x24 ---------------------------------- */ | ||
874 | [BTTV_BOARD_TYPHOON_TVIEW] = { | ||
875 | .name = "Lifeview FlyVideo 98FM LR50 / Typhoon TView TV/FM Tuner", | ||
876 | .video_inputs = 4, | ||
877 | /* .audio_inputs= 3, */ | ||
878 | .svhs = 2, | ||
879 | .gpiomask = 0x1800, | ||
880 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
881 | .gpiomux = { 0, 0x800, 0x1000, 0x1000 }, | ||
882 | .gpiomute = 0x1800, | ||
883 | .pll = PLL_28, | ||
884 | .tuner_type = UNSET, | ||
885 | .tuner_addr = ADDR_UNSET, | ||
886 | .has_radio = 1, | ||
887 | }, | ||
888 | [BTTV_BOARD_PXELVWPLTVPRO] = { | ||
889 | .name = "Prolink PixelView PlayTV pro", | ||
890 | .video_inputs = 3, | ||
891 | /* .audio_inputs= 1, */ | ||
892 | .svhs = 2, | ||
893 | .gpiomask = 0xff, | ||
894 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
895 | .gpiomux = { 0x21, 0x20, 0x24, 0x2c }, | ||
896 | .gpiomute = 0x29, | ||
897 | .no_msp34xx = 1, | ||
898 | .pll = PLL_28, | ||
899 | .tuner_type = UNSET, | ||
900 | .tuner_addr = ADDR_UNSET, | ||
901 | }, | ||
902 | [BTTV_BOARD_MAGICTVIEW063] = { | ||
903 | .name = "Askey CPH06X TView99", | ||
904 | .video_inputs = 4, | ||
905 | /* .audio_inputs= 1, */ | ||
906 | .svhs = 2, | ||
907 | .gpiomask = 0x551e00, | ||
908 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
909 | .gpiomux = { 0x551400, 0x551200, 0, 0 }, | ||
910 | .gpiomute = 0x551c00, | ||
911 | .pll = PLL_28, | ||
912 | .tuner_type = TUNER_PHILIPS_PAL_I, | ||
913 | .tuner_addr = ADDR_UNSET, | ||
914 | .has_remote = 1, | ||
915 | }, | ||
916 | [BTTV_BOARD_PINNACLE] = { | ||
917 | .name = "Pinnacle PCTV Studio/Rave", | ||
918 | .video_inputs = 3, | ||
919 | /* .audio_inputs= 1, */ | ||
920 | .svhs = 2, | ||
921 | .gpiomask = 0x03000F, | ||
922 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
923 | .gpiomux = { 2, 0xd0001, 0, 0 }, | ||
924 | .gpiomute = 1, | ||
925 | .pll = PLL_28, | ||
926 | .tuner_type = UNSET, | ||
927 | .tuner_addr = ADDR_UNSET, | ||
928 | }, | ||
929 | |||
930 | /* ---- card 0x28 ---------------------------------- */ | ||
931 | [BTTV_BOARD_STB2] = { | ||
932 | .name = "STB TV PCI FM, Gateway P/N 6000704 (bt878), 3Dfx VoodooTV 100", | ||
933 | .video_inputs = 3, | ||
934 | /* .audio_inputs= 1, */ | ||
935 | .svhs = 2, | ||
936 | .gpiomask = 7, | ||
937 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
938 | .gpiomux = { 4, 0, 2, 3 }, | ||
939 | .gpiomute = 1, | ||
940 | .no_msp34xx = 1, | ||
941 | .tuner_type = TUNER_PHILIPS_NTSC, | ||
942 | .tuner_addr = ADDR_UNSET, | ||
943 | .pll = PLL_28, | ||
944 | .has_radio = 1, | ||
945 | }, | ||
946 | [BTTV_BOARD_AVPHONE98] = { | ||
947 | .name = "AVerMedia TVPhone 98", | ||
948 | .video_inputs = 3, | ||
949 | /* .audio_inputs= 4, */ | ||
950 | .svhs = 2, | ||
951 | .gpiomask = 15, | ||
952 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
953 | .gpiomux = { 13, 4, 11, 7 }, | ||
954 | .pll = PLL_28, | ||
955 | .tuner_type = UNSET, | ||
956 | .tuner_addr = ADDR_UNSET, | ||
957 | .has_radio = 1, | ||
958 | .audio_mode_gpio= avermedia_tvphone_audio, | ||
959 | }, | ||
960 | [BTTV_BOARD_PV951] = { | ||
961 | .name = "ProVideo PV951", /* pic16c54 */ | ||
962 | .video_inputs = 3, | ||
963 | /* .audio_inputs= 1, */ | ||
964 | .svhs = 2, | ||
965 | .gpiomask = 0, | ||
966 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
967 | .gpiomux = { 0, 0, 0, 0}, | ||
968 | .no_msp34xx = 1, | ||
969 | .pll = PLL_28, | ||
970 | .tuner_type = TUNER_PHILIPS_PAL_I, | ||
971 | .tuner_addr = ADDR_UNSET, | ||
972 | }, | ||
973 | [BTTV_BOARD_ONAIR_TV] = { | ||
974 | .name = "Little OnAir TV", | ||
975 | .video_inputs = 3, | ||
976 | /* .audio_inputs= 1, */ | ||
977 | .svhs = 2, | ||
978 | .gpiomask = 0xe00b, | ||
979 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
980 | .gpiomux = { 0xff9ff6, 0xff9ff6, 0xff1ff7, 0 }, | ||
981 | .gpiomute = 0xff3ffc, | ||
982 | .no_msp34xx = 1, | ||
983 | .tuner_type = UNSET, | ||
984 | .tuner_addr = ADDR_UNSET, | ||
985 | }, | ||
986 | |||
987 | /* ---- card 0x2c ---------------------------------- */ | ||
988 | [BTTV_BOARD_SIGMA_TVII_FM] = { | ||
989 | .name = "Sigma TVII-FM", | ||
990 | .video_inputs = 2, | ||
991 | /* .audio_inputs= 1, */ | ||
992 | .svhs = NO_SVHS, | ||
993 | .gpiomask = 3, | ||
994 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
995 | .gpiomux = { 1, 1, 0, 2 }, | ||
996 | .gpiomute = 3, | ||
997 | .no_msp34xx = 1, | ||
998 | .pll = PLL_NONE, | ||
999 | .tuner_type = UNSET, | ||
1000 | .tuner_addr = ADDR_UNSET, | ||
1001 | }, | ||
1002 | [BTTV_BOARD_MATRIX_VISION2] = { | ||
1003 | .name = "MATRIX-Vision MV-Delta 2", | ||
1004 | .video_inputs = 5, | ||
1005 | /* .audio_inputs= 1, */ | ||
1006 | .svhs = 3, | ||
1007 | .gpiomask = 0, | ||
1008 | .muxsel = MUXSEL(2, 3, 1, 0, 0), | ||
1009 | .gpiomux = { 0 }, | ||
1010 | .no_msp34xx = 1, | ||
1011 | .pll = PLL_28, | ||
1012 | .tuner_type = TUNER_ABSENT, | ||
1013 | .tuner_addr = ADDR_UNSET, | ||
1014 | }, | ||
1015 | [BTTV_BOARD_ZOLTRIX_GENIE] = { | ||
1016 | .name = "Zoltrix Genie TV/FM", | ||
1017 | .video_inputs = 3, | ||
1018 | /* .audio_inputs= 1, */ | ||
1019 | .svhs = 2, | ||
1020 | .gpiomask = 0xbcf03f, | ||
1021 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1022 | .gpiomux = { 0xbc803f, 0xbc903f, 0xbcb03f, 0 }, | ||
1023 | .gpiomute = 0xbcb03f, | ||
1024 | .no_msp34xx = 1, | ||
1025 | .pll = PLL_28, | ||
1026 | .tuner_type = TUNER_TEMIC_4039FR5_NTSC, | ||
1027 | .tuner_addr = ADDR_UNSET, | ||
1028 | }, | ||
1029 | [BTTV_BOARD_TERRATVRADIO] = { | ||
1030 | .name = "Terratec TV/Radio+", | ||
1031 | .video_inputs = 3, | ||
1032 | /* .audio_inputs= 1, */ | ||
1033 | .svhs = 2, | ||
1034 | .gpiomask = 0x70000, | ||
1035 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1036 | .gpiomux = { 0x20000, 0x30000, 0x10000, 0 }, | ||
1037 | .gpiomute = 0x40000, | ||
1038 | .no_msp34xx = 1, | ||
1039 | .pll = PLL_35, | ||
1040 | .tuner_type = TUNER_PHILIPS_PAL_I, | ||
1041 | .tuner_addr = ADDR_UNSET, | ||
1042 | .has_radio = 1, | ||
1043 | }, | ||
1044 | |||
1045 | /* ---- card 0x30 ---------------------------------- */ | ||
1046 | [BTTV_BOARD_DYNALINK] = { | ||
1047 | .name = "Askey CPH03x/ Dynalink Magic TView", | ||
1048 | .video_inputs = 3, | ||
1049 | /* .audio_inputs= 1, */ | ||
1050 | .svhs = 2, | ||
1051 | .gpiomask = 15, | ||
1052 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1053 | .gpiomux = {2,0,0,0 }, | ||
1054 | .gpiomute = 1, | ||
1055 | .pll = PLL_28, | ||
1056 | .tuner_type = UNSET, | ||
1057 | .tuner_addr = ADDR_UNSET, | ||
1058 | }, | ||
1059 | [BTTV_BOARD_GVBCTV3PCI] = { | ||
1060 | .name = "IODATA GV-BCTV3/PCI", | ||
1061 | .video_inputs = 3, | ||
1062 | /* .audio_inputs= 1, */ | ||
1063 | .svhs = 2, | ||
1064 | .gpiomask = 0x010f00, | ||
1065 | .muxsel = MUXSEL(2, 3, 0, 0), | ||
1066 | .gpiomux = {0x10000, 0, 0x10000, 0 }, | ||
1067 | .no_msp34xx = 1, | ||
1068 | .pll = PLL_28, | ||
1069 | .tuner_type = TUNER_ALPS_TSHC6_NTSC, | ||
1070 | .tuner_addr = ADDR_UNSET, | ||
1071 | .audio_mode_gpio= gvbctv3pci_audio, | ||
1072 | }, | ||
1073 | [BTTV_BOARD_PXELVWPLTVPAK] = { | ||
1074 | .name = "Prolink PV-BT878P+4E / PixelView PlayTV PAK / Lenco MXTV-9578 CP", | ||
1075 | .video_inputs = 5, | ||
1076 | /* .audio_inputs= 1, */ | ||
1077 | .svhs = 3, | ||
1078 | .has_dig_in = 1, | ||
1079 | .gpiomask = 0xAA0000, | ||
1080 | .muxsel = MUXSEL(2, 3, 1, 1, 0), /* in 4 is digital */ | ||
1081 | /* .digital_mode= DIGITAL_MODE_CAMERA, */ | ||
1082 | .gpiomux = { 0x20000, 0, 0x80000, 0x80000 }, | ||
1083 | .gpiomute = 0xa8000, | ||
1084 | .no_msp34xx = 1, | ||
1085 | .pll = PLL_28, | ||
1086 | .tuner_type = TUNER_PHILIPS_PAL_I, | ||
1087 | .tuner_addr = ADDR_UNSET, | ||
1088 | .has_remote = 1, | ||
1089 | /* GPIO wiring: (different from Rev.4C !) | ||
1090 | GPIO17: U4.A0 (first hef4052bt) | ||
1091 | GPIO19: U4.A1 | ||
1092 | GPIO20: U5.A1 (second hef4052bt) | ||
1093 | GPIO21: U4.nEN | ||
1094 | GPIO22: BT832 Reset Line | ||
1095 | GPIO23: A5,A0, U5,nEN | ||
1096 | Note: At i2c=0x8a is a Bt832 chip, which changes to 0x88 after being reset via GPIO22 | ||
1097 | */ | ||
1098 | }, | ||
1099 | [BTTV_BOARD_EAGLE] = { | ||
1100 | .name = "Eagle Wireless Capricorn2 (bt878A)", | ||
1101 | .video_inputs = 4, | ||
1102 | /* .audio_inputs= 1, */ | ||
1103 | .svhs = 2, | ||
1104 | .gpiomask = 7, | ||
1105 | .muxsel = MUXSEL(2, 0, 1, 1), | ||
1106 | .gpiomux = { 0, 1, 2, 3 }, | ||
1107 | .gpiomute = 4, | ||
1108 | .pll = PLL_28, | ||
1109 | .tuner_type = UNSET /* TUNER_ALPS_TMDH2_NTSC */, | ||
1110 | .tuner_addr = ADDR_UNSET, | ||
1111 | }, | ||
1112 | |||
1113 | /* ---- card 0x34 ---------------------------------- */ | ||
1114 | [BTTV_BOARD_PINNACLEPRO] = { | ||
1115 | /* David Härdeman <david@2gen.com> */ | ||
1116 | .name = "Pinnacle PCTV Studio Pro", | ||
1117 | .video_inputs = 4, | ||
1118 | /* .audio_inputs= 1, */ | ||
1119 | .svhs = 3, | ||
1120 | .gpiomask = 0x03000F, | ||
1121 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1122 | .gpiomux = { 1, 0xd0001, 0, 0 }, | ||
1123 | .gpiomute = 10, | ||
1124 | /* sound path (5 sources): | ||
1125 | MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable) | ||
1126 | 0= ext. Audio IN | ||
1127 | 1= from MUX2 | ||
1128 | 2= Mono TV sound from Tuner | ||
1129 | 3= not connected | ||
1130 | MUX2 (mask 0x30000): | ||
1131 | 0,2,3= from MSP34xx | ||
1132 | 1= FM stereo Radio from Tuner */ | ||
1133 | .pll = PLL_28, | ||
1134 | .tuner_type = UNSET, | ||
1135 | .tuner_addr = ADDR_UNSET, | ||
1136 | }, | ||
1137 | [BTTV_BOARD_TVIEW_RDS_FM] = { | ||
1138 | /* Claas Langbehn <claas@bigfoot.com>, | ||
1139 | Sven Grothklags <sven@upb.de> */ | ||
1140 | .name = "Typhoon TView RDS + FM Stereo / KNC1 TV Station RDS", | ||
1141 | .video_inputs = 4, | ||
1142 | /* .audio_inputs= 3, */ | ||
1143 | .svhs = 2, | ||
1144 | .gpiomask = 0x1c, | ||
1145 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1146 | .gpiomux = { 0, 0, 0x10, 8 }, | ||
1147 | .gpiomute = 4, | ||
1148 | .pll = PLL_28, | ||
1149 | .tuner_type = TUNER_PHILIPS_PAL, | ||
1150 | .tuner_addr = ADDR_UNSET, | ||
1151 | .has_radio = 1, | ||
1152 | }, | ||
1153 | [BTTV_BOARD_LIFETEC_9415] = { | ||
1154 | /* Tim Röstermundt <rosterm@uni-muenster.de> | ||
1155 | in de.comp.os.unix.linux.hardware: | ||
1156 | options bttv card=0 pll=1 radio=1 gpiomask=0x18e0 | ||
1157 | gpiomux =0x44c71f,0x44d71f,0,0x44d71f,0x44dfff | ||
1158 | options tuner type=5 */ | ||
1159 | .name = "Lifeview FlyVideo 2000 /FlyVideo A2/ Lifetec LT 9415 TV [LR90]", | ||
1160 | .video_inputs = 4, | ||
1161 | /* .audio_inputs= 1, */ | ||
1162 | .svhs = 2, | ||
1163 | .gpiomask = 0x18e0, | ||
1164 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1165 | .gpiomux = { 0x0000,0x0800,0x1000,0x1000 }, | ||
1166 | .gpiomute = 0x18e0, | ||
1167 | /* For cards with tda9820/tda9821: | ||
1168 | 0x0000: Tuner normal stereo | ||
1169 | 0x0080: Tuner A2 SAP (second audio program = Zweikanalton) | ||
1170 | 0x0880: Tuner A2 stereo */ | ||
1171 | .pll = PLL_28, | ||
1172 | .tuner_type = UNSET, | ||
1173 | .tuner_addr = ADDR_UNSET, | ||
1174 | }, | ||
1175 | [BTTV_BOARD_BESTBUY_EASYTV] = { | ||
1176 | /* Miguel Angel Alvarez <maacruz@navegalia.com> | ||
1177 | old Easy TV BT848 version (model CPH031) */ | ||
1178 | .name = "Askey CPH031/ BESTBUY Easy TV", | ||
1179 | .video_inputs = 4, | ||
1180 | /* .audio_inputs= 1, */ | ||
1181 | .svhs = 2, | ||
1182 | .gpiomask = 0xF, | ||
1183 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
1184 | .gpiomux = { 2, 0, 0, 0 }, | ||
1185 | .gpiomute = 10, | ||
1186 | .pll = PLL_28, | ||
1187 | .tuner_type = TUNER_TEMIC_PAL, | ||
1188 | .tuner_addr = ADDR_UNSET, | ||
1189 | }, | ||
1190 | |||
1191 | /* ---- card 0x38 ---------------------------------- */ | ||
1192 | [BTTV_BOARD_FLYVIDEO_98FM] = { | ||
1193 | /* Gordon Heydon <gjheydon@bigfoot.com ('98) */ | ||
1194 | .name = "Lifeview FlyVideo 98FM LR50", | ||
1195 | .video_inputs = 4, | ||
1196 | /* .audio_inputs= 3, */ | ||
1197 | .svhs = 2, | ||
1198 | .gpiomask = 0x1800, | ||
1199 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1200 | .gpiomux = { 0, 0x800, 0x1000, 0x1000 }, | ||
1201 | .gpiomute = 0x1800, | ||
1202 | .pll = PLL_28, | ||
1203 | .tuner_type = TUNER_PHILIPS_PAL, | ||
1204 | .tuner_addr = ADDR_UNSET, | ||
1205 | }, | ||
1206 | /* This is the ultimate cheapo capture card | ||
1207 | * just a BT848A on a small PCB! | ||
1208 | * Steve Hosgood <steve@equiinet.com> */ | ||
1209 | [BTTV_BOARD_GRANDTEC] = { | ||
1210 | .name = "GrandTec 'Grand Video Capture' (Bt848)", | ||
1211 | .video_inputs = 2, | ||
1212 | /* .audio_inputs= 0, */ | ||
1213 | .svhs = 1, | ||
1214 | .gpiomask = 0, | ||
1215 | .muxsel = MUXSEL(3, 1), | ||
1216 | .gpiomux = { 0 }, | ||
1217 | .no_msp34xx = 1, | ||
1218 | .pll = PLL_35, | ||
1219 | .tuner_type = TUNER_ABSENT, | ||
1220 | .tuner_addr = ADDR_UNSET, | ||
1221 | }, | ||
1222 | [BTTV_BOARD_ASKEY_CPH060] = { | ||
1223 | /* Daniel Herrington <daniel.herrington@home.com> */ | ||
1224 | .name = "Askey CPH060/ Phoebe TV Master Only (No FM)", | ||
1225 | .video_inputs = 3, | ||
1226 | /* .audio_inputs= 1, */ | ||
1227 | .svhs = 2, | ||
1228 | .gpiomask = 0xe00, | ||
1229 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1230 | .gpiomux = { 0x400, 0x400, 0x400, 0x400 }, | ||
1231 | .gpiomute = 0x800, | ||
1232 | .pll = PLL_28, | ||
1233 | .tuner_type = TUNER_TEMIC_4036FY5_NTSC, | ||
1234 | .tuner_addr = ADDR_UNSET, | ||
1235 | }, | ||
1236 | [BTTV_BOARD_ASKEY_CPH03X] = { | ||
1237 | /* Matti Mottus <mottus@physic.ut.ee> */ | ||
1238 | .name = "Askey CPH03x TV Capturer", | ||
1239 | .video_inputs = 4, | ||
1240 | /* .audio_inputs= 1, */ | ||
1241 | .svhs = 2, | ||
1242 | .gpiomask = 0x03000F, | ||
1243 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
1244 | .gpiomux = { 2, 0, 0, 0 }, | ||
1245 | .gpiomute = 1, | ||
1246 | .pll = PLL_28, | ||
1247 | .tuner_type = TUNER_TEMIC_PAL, | ||
1248 | .tuner_addr = ADDR_UNSET, | ||
1249 | .has_remote = 1, | ||
1250 | }, | ||
1251 | |||
1252 | /* ---- card 0x3c ---------------------------------- */ | ||
1253 | [BTTV_BOARD_MM100PCTV] = { | ||
1254 | /* Philip Blundell <philb@gnu.org> */ | ||
1255 | .name = "Modular Technology MM100PCTV", | ||
1256 | .video_inputs = 2, | ||
1257 | /* .audio_inputs= 2, */ | ||
1258 | .svhs = NO_SVHS, | ||
1259 | .gpiomask = 11, | ||
1260 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1261 | .gpiomux = { 2, 0, 0, 1 }, | ||
1262 | .gpiomute = 8, | ||
1263 | .pll = PLL_35, | ||
1264 | .tuner_type = TUNER_TEMIC_PAL, | ||
1265 | .tuner_addr = ADDR_UNSET, | ||
1266 | }, | ||
1267 | [BTTV_BOARD_GMV1] = { | ||
1268 | /* Adrian Cox <adrian@humboldt.co.uk */ | ||
1269 | .name = "AG Electronics GMV1", | ||
1270 | .video_inputs = 2, | ||
1271 | /* .audio_inputs= 0, */ | ||
1272 | .svhs = 1, | ||
1273 | .gpiomask = 0xF, | ||
1274 | .muxsel = MUXSEL(2, 2), | ||
1275 | .gpiomux = { }, | ||
1276 | .no_msp34xx = 1, | ||
1277 | .pll = PLL_28, | ||
1278 | .tuner_type = TUNER_ABSENT, | ||
1279 | .tuner_addr = ADDR_UNSET, | ||
1280 | }, | ||
1281 | [BTTV_BOARD_BESTBUY_EASYTV2] = { | ||
1282 | /* Miguel Angel Alvarez <maacruz@navegalia.com> | ||
1283 | new Easy TV BT878 version (model CPH061) | ||
1284 | special thanks to Informatica Mieres for providing the card */ | ||
1285 | .name = "Askey CPH061/ BESTBUY Easy TV (bt878)", | ||
1286 | .video_inputs = 3, | ||
1287 | /* .audio_inputs= 2, */ | ||
1288 | .svhs = 2, | ||
1289 | .gpiomask = 0xFF, | ||
1290 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
1291 | .gpiomux = { 1, 0, 4, 4 }, | ||
1292 | .gpiomute = 9, | ||
1293 | .pll = PLL_28, | ||
1294 | .tuner_type = TUNER_PHILIPS_PAL, | ||
1295 | .tuner_addr = ADDR_UNSET, | ||
1296 | }, | ||
1297 | [BTTV_BOARD_ATI_TVWONDER] = { | ||
1298 | /* Lukas Gebauer <geby@volny.cz> */ | ||
1299 | .name = "ATI TV-Wonder", | ||
1300 | .video_inputs = 3, | ||
1301 | /* .audio_inputs= 1, */ | ||
1302 | .svhs = 2, | ||
1303 | .gpiomask = 0xf03f, | ||
1304 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
1305 | .gpiomux = { 0xbffe, 0, 0xbfff, 0 }, | ||
1306 | .gpiomute = 0xbffe, | ||
1307 | .pll = PLL_28, | ||
1308 | .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, | ||
1309 | .tuner_addr = ADDR_UNSET, | ||
1310 | }, | ||
1311 | |||
1312 | /* ---- card 0x40 ---------------------------------- */ | ||
1313 | [BTTV_BOARD_ATI_TVWONDERVE] = { | ||
1314 | /* Lukas Gebauer <geby@volny.cz> */ | ||
1315 | .name = "ATI TV-Wonder VE", | ||
1316 | .video_inputs = 2, | ||
1317 | /* .audio_inputs= 1, */ | ||
1318 | .svhs = NO_SVHS, | ||
1319 | .gpiomask = 1, | ||
1320 | .muxsel = MUXSEL(2, 3, 0, 1), | ||
1321 | .gpiomux = { 0, 0, 1, 0 }, | ||
1322 | .no_msp34xx = 1, | ||
1323 | .pll = PLL_28, | ||
1324 | .tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL, | ||
1325 | .tuner_addr = ADDR_UNSET, | ||
1326 | }, | ||
1327 | [BTTV_BOARD_FLYVIDEO2000] = { | ||
1328 | /* DeeJay <deejay@westel900.net (2000S) */ | ||
1329 | .name = "Lifeview FlyVideo 2000S LR90", | ||
1330 | .video_inputs = 3, | ||
1331 | /* .audio_inputs= 3, */ | ||
1332 | .svhs = 2, | ||
1333 | .gpiomask = 0x18e0, | ||
1334 | .muxsel = MUXSEL(2, 3, 0, 1), | ||
1335 | /* Radio changed from 1e80 to 0x800 to make | ||
1336 | FlyVideo2000S in .hu happy (gm)*/ | ||
1337 | /* -dk-???: set mute=0x1800 for tda9874h daughterboard */ | ||
1338 | .gpiomux = { 0x0000,0x0800,0x1000,0x1000 }, | ||
1339 | .gpiomute = 0x1800, | ||
1340 | .audio_mode_gpio= fv2000s_audio, | ||
1341 | .no_msp34xx = 1, | ||
1342 | .pll = PLL_28, | ||
1343 | .tuner_type = TUNER_PHILIPS_PAL, | ||
1344 | .tuner_addr = ADDR_UNSET, | ||
1345 | }, | ||
1346 | [BTTV_BOARD_TERRATVALUER] = { | ||
1347 | .name = "Terratec TValueRadio", | ||
1348 | .video_inputs = 3, | ||
1349 | /* .audio_inputs= 1, */ | ||
1350 | .svhs = 2, | ||
1351 | .gpiomask = 0xffff00, | ||
1352 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1353 | .gpiomux = { 0x500, 0x500, 0x300, 0x900 }, | ||
1354 | .gpiomute = 0x900, | ||
1355 | .pll = PLL_28, | ||
1356 | .tuner_type = TUNER_PHILIPS_PAL, | ||
1357 | .tuner_addr = ADDR_UNSET, | ||
1358 | .has_radio = 1, | ||
1359 | }, | ||
1360 | [BTTV_BOARD_GVBCTV4PCI] = { | ||
1361 | /* TANAKA Kei <peg00625@nifty.com> */ | ||
1362 | .name = "IODATA GV-BCTV4/PCI", | ||
1363 | .video_inputs = 3, | ||
1364 | /* .audio_inputs= 1, */ | ||
1365 | .svhs = 2, | ||
1366 | .gpiomask = 0x010f00, | ||
1367 | .muxsel = MUXSEL(2, 3, 0, 0), | ||
1368 | .gpiomux = {0x10000, 0, 0x10000, 0 }, | ||
1369 | .no_msp34xx = 1, | ||
1370 | .pll = PLL_28, | ||
1371 | .tuner_type = TUNER_SHARP_2U5JF5540_NTSC, | ||
1372 | .tuner_addr = ADDR_UNSET, | ||
1373 | .audio_mode_gpio= gvbctv3pci_audio, | ||
1374 | }, | ||
1375 | |||
1376 | /* ---- card 0x44 ---------------------------------- */ | ||
1377 | [BTTV_BOARD_VOODOOTV_FM] = { | ||
1378 | .name = "3Dfx VoodooTV FM (Euro)", | ||
1379 | /* try "insmod msp3400 simple=0" if you have | ||
1380 | * sound problems with this card. */ | ||
1381 | .video_inputs = 4, | ||
1382 | /* .audio_inputs= 1, */ | ||
1383 | .svhs = NO_SVHS, | ||
1384 | .gpiomask = 0x4f8a00, | ||
1385 | /* 0x100000: 1=MSP enabled (0=disable again) | ||
1386 | * 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC) */ | ||
1387 | .gpiomux = {0x947fff, 0x987fff,0x947fff,0x947fff }, | ||
1388 | .gpiomute = 0x947fff, | ||
1389 | /* tvtuner, radio, external,internal, mute, stereo | ||
1390 | * tuner, Composit, SVid, Composit-on-Svid-adapter */ | ||
1391 | .muxsel = MUXSEL(2, 3, 0, 1), | ||
1392 | .tuner_type = TUNER_MT2032, | ||
1393 | .tuner_addr = ADDR_UNSET, | ||
1394 | .pll = PLL_28, | ||
1395 | .has_radio = 1, | ||
1396 | }, | ||
1397 | [BTTV_BOARD_VOODOOTV_200] = { | ||
1398 | .name = "VoodooTV 200 (USA)", | ||
1399 | /* try "insmod msp3400 simple=0" if you have | ||
1400 | * sound problems with this card. */ | ||
1401 | .video_inputs = 4, | ||
1402 | /* .audio_inputs= 1, */ | ||
1403 | .svhs = NO_SVHS, | ||
1404 | .gpiomask = 0x4f8a00, | ||
1405 | /* 0x100000: 1=MSP enabled (0=disable again) | ||
1406 | * 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC) */ | ||
1407 | .gpiomux = {0x947fff, 0x987fff,0x947fff,0x947fff }, | ||
1408 | .gpiomute = 0x947fff, | ||
1409 | /* tvtuner, radio, external,internal, mute, stereo | ||
1410 | * tuner, Composit, SVid, Composit-on-Svid-adapter */ | ||
1411 | .muxsel = MUXSEL(2, 3, 0, 1), | ||
1412 | .tuner_type = TUNER_MT2032, | ||
1413 | .tuner_addr = ADDR_UNSET, | ||
1414 | .pll = PLL_28, | ||
1415 | .has_radio = 1, | ||
1416 | }, | ||
1417 | [BTTV_BOARD_AIMMS] = { | ||
1418 | /* Philip Blundell <pb@nexus.co.uk> */ | ||
1419 | .name = "Active Imaging AIMMS", | ||
1420 | .video_inputs = 1, | ||
1421 | /* .audio_inputs= 0, */ | ||
1422 | .tuner_type = TUNER_ABSENT, | ||
1423 | .tuner_addr = ADDR_UNSET, | ||
1424 | .pll = PLL_28, | ||
1425 | .muxsel = MUXSEL(2), | ||
1426 | .gpiomask = 0 | ||
1427 | }, | ||
1428 | [BTTV_BOARD_PV_BT878P_PLUS] = { | ||
1429 | /* Tomasz Pyra <hellfire@sedez.iq.pl> */ | ||
1430 | .name = "Prolink Pixelview PV-BT878P+ (Rev.4C,8E)", | ||
1431 | .video_inputs = 3, | ||
1432 | /* .audio_inputs= 4, */ | ||
1433 | .svhs = 2, | ||
1434 | .gpiomask = 15, | ||
1435 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1436 | .gpiomux = { 0, 0, 11, 7 }, /* TV and Radio with same GPIO ! */ | ||
1437 | .gpiomute = 13, | ||
1438 | .pll = PLL_28, | ||
1439 | .tuner_type = TUNER_LG_PAL_I_FM, | ||
1440 | .tuner_addr = ADDR_UNSET, | ||
1441 | .has_remote = 1, | ||
1442 | /* GPIO wiring: | ||
1443 | GPIO0: U4.A0 (hef4052bt) | ||
1444 | GPIO1: U4.A1 | ||
1445 | GPIO2: U4.A1 (second hef4052bt) | ||
1446 | GPIO3: U4.nEN, U5.A0, A5.nEN | ||
1447 | GPIO8-15: vrd866b ? | ||
1448 | */ | ||
1449 | }, | ||
1450 | [BTTV_BOARD_FLYVIDEO98EZ] = { | ||
1451 | .name = "Lifeview FlyVideo 98EZ (capture only) LR51", | ||
1452 | .video_inputs = 4, | ||
1453 | /* .audio_inputs= 0, */ | ||
1454 | .svhs = 2, | ||
1455 | /* AV1, AV2, SVHS, CVid adapter on SVHS */ | ||
1456 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1457 | .pll = PLL_28, | ||
1458 | .no_msp34xx = 1, | ||
1459 | .tuner_type = TUNER_ABSENT, | ||
1460 | .tuner_addr = ADDR_UNSET, | ||
1461 | }, | ||
1462 | |||
1463 | /* ---- card 0x48 ---------------------------------- */ | ||
1464 | [BTTV_BOARD_PV_BT878P_9B] = { | ||
1465 | /* Dariusz Kowalewski <darekk@automex.pl> */ | ||
1466 | .name = "Prolink Pixelview PV-BT878P+9B (PlayTV Pro rev.9B FM+NICAM)", | ||
1467 | .video_inputs = 4, | ||
1468 | /* .audio_inputs= 1, */ | ||
1469 | .svhs = 2, | ||
1470 | .gpiomask = 0x3f, | ||
1471 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1472 | .gpiomux = { 0x01, 0x00, 0x03, 0x03 }, | ||
1473 | .gpiomute = 0x09, | ||
1474 | .no_msp34xx = 1, | ||
1475 | .pll = PLL_28, | ||
1476 | .tuner_type = TUNER_PHILIPS_PAL, | ||
1477 | .tuner_addr = ADDR_UNSET, | ||
1478 | .audio_mode_gpio= pvbt878p9b_audio, /* Note: not all cards have stereo */ | ||
1479 | .has_radio = 1, /* Note: not all cards have radio */ | ||
1480 | .has_remote = 1, | ||
1481 | /* GPIO wiring: | ||
1482 | GPIO0: A0 hef4052 | ||
1483 | GPIO1: A1 hef4052 | ||
1484 | GPIO3: nEN hef4052 | ||
1485 | GPIO8-15: vrd866b | ||
1486 | GPIO20,22,23: R30,R29,R28 | ||
1487 | */ | ||
1488 | }, | ||
1489 | [BTTV_BOARD_SENSORAY311_611] = { | ||
1490 | /* Clay Kunz <ckunz@mail.arc.nasa.gov> */ | ||
1491 | /* you must jumper JP5 for the 311 card (PC/104+) to work */ | ||
1492 | .name = "Sensoray 311/611", | ||
1493 | .video_inputs = 5, | ||
1494 | /* .audio_inputs= 0, */ | ||
1495 | .svhs = 4, | ||
1496 | .gpiomask = 0, | ||
1497 | .muxsel = MUXSEL(2, 3, 1, 0, 0), | ||
1498 | .gpiomux = { 0 }, | ||
1499 | .tuner_type = TUNER_ABSENT, | ||
1500 | .tuner_addr = ADDR_UNSET, | ||
1501 | }, | ||
1502 | [BTTV_BOARD_RV605] = { | ||
1503 | /* Miguel Freitas <miguel@cetuc.puc-rio.br> */ | ||
1504 | .name = "RemoteVision MX (RV605)", | ||
1505 | .video_inputs = 16, | ||
1506 | /* .audio_inputs= 0, */ | ||
1507 | .svhs = NO_SVHS, | ||
1508 | .gpiomask = 0x00, | ||
1509 | .gpiomask2 = 0x07ff, | ||
1510 | .muxsel = MUXSEL(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), | ||
1511 | .no_msp34xx = 1, | ||
1512 | .tuner_type = TUNER_ABSENT, | ||
1513 | .tuner_addr = ADDR_UNSET, | ||
1514 | .muxsel_hook = rv605_muxsel, | ||
1515 | }, | ||
1516 | [BTTV_BOARD_POWERCLR_MTV878] = { | ||
1517 | .name = "Powercolor MTV878/ MTV878R/ MTV878F", | ||
1518 | .video_inputs = 3, | ||
1519 | /* .audio_inputs= 2, */ | ||
1520 | .svhs = 2, | ||
1521 | .gpiomask = 0x1C800F, /* Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset */ | ||
1522 | .muxsel = MUXSEL(2, 1, 1), | ||
1523 | .gpiomux = { 0, 1, 2, 2 }, | ||
1524 | .gpiomute = 4, | ||
1525 | .tuner_type = TUNER_PHILIPS_PAL, | ||
1526 | .tuner_addr = ADDR_UNSET, | ||
1527 | .pll = PLL_28, | ||
1528 | .has_radio = 1, | ||
1529 | }, | ||
1530 | |||
1531 | /* ---- card 0x4c ---------------------------------- */ | ||
1532 | [BTTV_BOARD_WINDVR] = { | ||
1533 | /* Masaki Suzuki <masaki@btree.org> */ | ||
1534 | .name = "Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)", | ||
1535 | .video_inputs = 3, | ||
1536 | /* .audio_inputs= 1, */ | ||
1537 | .svhs = 2, | ||
1538 | .gpiomask = 0x140007, | ||
1539 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1540 | .gpiomux = { 0, 1, 2, 3 }, | ||
1541 | .gpiomute = 4, | ||
1542 | .tuner_type = TUNER_PHILIPS_NTSC, | ||
1543 | .tuner_addr = ADDR_UNSET, | ||
1544 | .audio_mode_gpio= windvr_audio, | ||
1545 | }, | ||
1546 | [BTTV_BOARD_GRANDTEC_MULTI] = { | ||
1547 | .name = "GrandTec Multi Capture Card (Bt878)", | ||
1548 | .video_inputs = 4, | ||
1549 | /* .audio_inputs= 0, */ | ||
1550 | .svhs = NO_SVHS, | ||
1551 | .gpiomask = 0, | ||
1552 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
1553 | .gpiomux = { 0 }, | ||
1554 | .no_msp34xx = 1, | ||
1555 | .pll = PLL_28, | ||
1556 | .tuner_type = TUNER_ABSENT, | ||
1557 | .tuner_addr = ADDR_UNSET, | ||
1558 | }, | ||
1559 | [BTTV_BOARD_KWORLD] = { | ||
1560 | .name = "Jetway TV/Capture JW-TV878-FBK, Kworld KW-TV878RF", | ||
1561 | .video_inputs = 4, | ||
1562 | /* .audio_inputs= 3, */ | ||
1563 | .svhs = 2, | ||
1564 | .gpiomask = 7, | ||
1565 | /* Tuner, SVid, SVHS, SVid to SVHS connector */ | ||
1566 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1567 | .gpiomux = { 0, 0, 4, 4 },/* Yes, this tuner uses the same audio output for TV and FM radio! | ||
1568 | * This card lacks external Audio In, so we mute it on Ext. & Int. | ||
1569 | * The PCB can take a sbx1637/sbx1673, wiring unknown. | ||
1570 | * This card lacks PCI subsystem ID, sigh. | ||
1571 | * gpiomux =1: lower volume, 2+3: mute | ||
1572 | * btwincap uses 0x80000/0x80003 | ||
1573 | */ | ||
1574 | .gpiomute = 4, | ||
1575 | .no_msp34xx = 1, | ||
1576 | .pll = PLL_28, | ||
1577 | .tuner_type = TUNER_PHILIPS_PAL, | ||
1578 | .tuner_addr = ADDR_UNSET, | ||
1579 | /* Samsung TCPA9095PC27A (BG+DK), philips compatible, w/FM, stereo and | ||
1580 | radio signal strength indicators work fine. */ | ||
1581 | .has_radio = 1, | ||
1582 | /* GPIO Info: | ||
1583 | GPIO0,1: HEF4052 A0,A1 | ||
1584 | GPIO2: HEF4052 nENABLE | ||
1585 | GPIO3-7: n.c. | ||
1586 | GPIO8-13: IRDC357 data0-5 (data6 n.c. ?) [chip not present on my card] | ||
1587 | GPIO14,15: ?? | ||
1588 | GPIO16-21: n.c. | ||
1589 | GPIO22,23: ?? | ||
1590 | ?? : mtu8b56ep microcontroller for IR (GPIO wiring unknown)*/ | ||
1591 | }, | ||
1592 | [BTTV_BOARD_DSP_TCVIDEO] = { | ||
1593 | /* Arthur Tetzlaff-Deas, DSP Design Ltd <software@dspdesign.com> */ | ||
1594 | .name = "DSP Design TCVIDEO", | ||
1595 | .video_inputs = 4, | ||
1596 | .svhs = NO_SVHS, | ||
1597 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
1598 | .pll = PLL_28, | ||
1599 | .tuner_type = UNSET, | ||
1600 | .tuner_addr = ADDR_UNSET, | ||
1601 | }, | ||
1602 | |||
1603 | /* ---- card 0x50 ---------------------------------- */ | ||
1604 | [BTTV_BOARD_HAUPPAUGEPVR] = { | ||
1605 | .name = "Hauppauge WinTV PVR", | ||
1606 | .video_inputs = 4, | ||
1607 | /* .audio_inputs= 1, */ | ||
1608 | .svhs = 2, | ||
1609 | .muxsel = MUXSEL(2, 0, 1, 1), | ||
1610 | .pll = PLL_28, | ||
1611 | .tuner_type = UNSET, | ||
1612 | .tuner_addr = ADDR_UNSET, | ||
1613 | |||
1614 | .gpiomask = 7, | ||
1615 | .gpiomux = {7}, | ||
1616 | }, | ||
1617 | [BTTV_BOARD_GVBCTV5PCI] = { | ||
1618 | .name = "IODATA GV-BCTV5/PCI", | ||
1619 | .video_inputs = 3, | ||
1620 | /* .audio_inputs= 1, */ | ||
1621 | .svhs = 2, | ||
1622 | .gpiomask = 0x0f0f80, | ||
1623 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
1624 | .gpiomux = {0x030000, 0x010000, 0, 0 }, | ||
1625 | .gpiomute = 0x020000, | ||
1626 | .no_msp34xx = 1, | ||
1627 | .pll = PLL_28, | ||
1628 | .tuner_type = TUNER_PHILIPS_NTSC_M, | ||
1629 | .tuner_addr = ADDR_UNSET, | ||
1630 | .audio_mode_gpio= gvbctv5pci_audio, | ||
1631 | .has_radio = 1, | ||
1632 | }, | ||
1633 | [BTTV_BOARD_OSPREY1x0] = { | ||
1634 | .name = "Osprey 100/150 (878)", /* 0x1(2|3)-45C6-C1 */ | ||
1635 | .video_inputs = 4, /* id-inputs-clock */ | ||
1636 | /* .audio_inputs= 0, */ | ||
1637 | .svhs = 3, | ||
1638 | .muxsel = MUXSEL(3, 2, 0, 1), | ||
1639 | .pll = PLL_28, | ||
1640 | .tuner_type = TUNER_ABSENT, | ||
1641 | .tuner_addr = ADDR_UNSET, | ||
1642 | .no_msp34xx = 1, | ||
1643 | .no_tda7432 = 1, | ||
1644 | }, | ||
1645 | [BTTV_BOARD_OSPREY1x0_848] = { | ||
1646 | .name = "Osprey 100/150 (848)", /* 0x04-54C0-C1 & older boards */ | ||
1647 | .video_inputs = 3, | ||
1648 | /* .audio_inputs= 0, */ | ||
1649 | .svhs = 2, | ||
1650 | .muxsel = MUXSEL(2, 3, 1), | ||
1651 | .pll = PLL_28, | ||
1652 | .tuner_type = TUNER_ABSENT, | ||
1653 | .tuner_addr = ADDR_UNSET, | ||
1654 | .no_msp34xx = 1, | ||
1655 | .no_tda7432 = 1, | ||
1656 | }, | ||
1657 | |||
1658 | /* ---- card 0x54 ---------------------------------- */ | ||
1659 | [BTTV_BOARD_OSPREY101_848] = { | ||
1660 | .name = "Osprey 101 (848)", /* 0x05-40C0-C1 */ | ||
1661 | .video_inputs = 2, | ||
1662 | /* .audio_inputs= 0, */ | ||
1663 | .svhs = 1, | ||
1664 | .muxsel = MUXSEL(3, 1), | ||
1665 | .pll = PLL_28, | ||
1666 | .tuner_type = TUNER_ABSENT, | ||
1667 | .tuner_addr = ADDR_UNSET, | ||
1668 | .no_msp34xx = 1, | ||
1669 | .no_tda7432 = 1, | ||
1670 | }, | ||
1671 | [BTTV_BOARD_OSPREY1x1] = { | ||
1672 | .name = "Osprey 101/151", /* 0x1(4|5)-0004-C4 */ | ||
1673 | .video_inputs = 1, | ||
1674 | /* .audio_inputs= 0, */ | ||
1675 | .svhs = NO_SVHS, | ||
1676 | .muxsel = MUXSEL(0), | ||
1677 | .pll = PLL_28, | ||
1678 | .tuner_type = TUNER_ABSENT, | ||
1679 | .tuner_addr = ADDR_UNSET, | ||
1680 | .no_msp34xx = 1, | ||
1681 | .no_tda7432 = 1, | ||
1682 | }, | ||
1683 | [BTTV_BOARD_OSPREY1x1_SVID] = { | ||
1684 | .name = "Osprey 101/151 w/ svid", /* 0x(16|17|20)-00C4-C1 */ | ||
1685 | .video_inputs = 2, | ||
1686 | /* .audio_inputs= 0, */ | ||
1687 | .svhs = 1, | ||
1688 | .muxsel = MUXSEL(0, 1), | ||
1689 | .pll = PLL_28, | ||
1690 | .tuner_type = TUNER_ABSENT, | ||
1691 | .tuner_addr = ADDR_UNSET, | ||
1692 | .no_msp34xx = 1, | ||
1693 | .no_tda7432 = 1, | ||
1694 | }, | ||
1695 | [BTTV_BOARD_OSPREY2xx] = { | ||
1696 | .name = "Osprey 200/201/250/251", /* 0x1(8|9|E|F)-0004-C4 */ | ||
1697 | .video_inputs = 1, | ||
1698 | /* .audio_inputs= 1, */ | ||
1699 | .svhs = NO_SVHS, | ||
1700 | .muxsel = MUXSEL(0), | ||
1701 | .pll = PLL_28, | ||
1702 | .tuner_type = TUNER_ABSENT, | ||
1703 | .tuner_addr = ADDR_UNSET, | ||
1704 | .no_msp34xx = 1, | ||
1705 | .no_tda7432 = 1, | ||
1706 | }, | ||
1707 | |||
1708 | /* ---- card 0x58 ---------------------------------- */ | ||
1709 | [BTTV_BOARD_OSPREY2x0_SVID] = { | ||
1710 | .name = "Osprey 200/250", /* 0x1(A|B)-00C4-C1 */ | ||
1711 | .video_inputs = 2, | ||
1712 | /* .audio_inputs= 1, */ | ||
1713 | .svhs = 1, | ||
1714 | .muxsel = MUXSEL(0, 1), | ||
1715 | .pll = PLL_28, | ||
1716 | .tuner_type = TUNER_ABSENT, | ||
1717 | .tuner_addr = ADDR_UNSET, | ||
1718 | .no_msp34xx = 1, | ||
1719 | .no_tda7432 = 1, | ||
1720 | }, | ||
1721 | [BTTV_BOARD_OSPREY2x0] = { | ||
1722 | .name = "Osprey 210/220/230", /* 0x1(A|B)-04C0-C1 */ | ||
1723 | .video_inputs = 2, | ||
1724 | /* .audio_inputs= 1, */ | ||
1725 | .svhs = 1, | ||
1726 | .muxsel = MUXSEL(2, 3), | ||
1727 | .pll = PLL_28, | ||
1728 | .tuner_type = TUNER_ABSENT, | ||
1729 | .tuner_addr = ADDR_UNSET, | ||
1730 | .no_msp34xx = 1, | ||
1731 | .no_tda7432 = 1, | ||
1732 | }, | ||
1733 | [BTTV_BOARD_OSPREY500] = { | ||
1734 | .name = "Osprey 500", /* 500 */ | ||
1735 | .video_inputs = 2, | ||
1736 | /* .audio_inputs= 1, */ | ||
1737 | .svhs = 1, | ||
1738 | .muxsel = MUXSEL(2, 3), | ||
1739 | .pll = PLL_28, | ||
1740 | .tuner_type = TUNER_ABSENT, | ||
1741 | .tuner_addr = ADDR_UNSET, | ||
1742 | .no_msp34xx = 1, | ||
1743 | .no_tda7432 = 1, | ||
1744 | }, | ||
1745 | [BTTV_BOARD_OSPREY540] = { | ||
1746 | .name = "Osprey 540", /* 540 */ | ||
1747 | .video_inputs = 4, | ||
1748 | /* .audio_inputs= 1, */ | ||
1749 | .pll = PLL_28, | ||
1750 | .tuner_type = TUNER_ABSENT, | ||
1751 | .tuner_addr = ADDR_UNSET, | ||
1752 | .no_msp34xx = 1, | ||
1753 | .no_tda7432 = 1, | ||
1754 | }, | ||
1755 | |||
1756 | /* ---- card 0x5C ---------------------------------- */ | ||
1757 | [BTTV_BOARD_OSPREY2000] = { | ||
1758 | .name = "Osprey 2000", /* 2000 */ | ||
1759 | .video_inputs = 2, | ||
1760 | /* .audio_inputs= 1, */ | ||
1761 | .svhs = 1, | ||
1762 | .muxsel = MUXSEL(2, 3), | ||
1763 | .pll = PLL_28, | ||
1764 | .tuner_type = TUNER_ABSENT, | ||
1765 | .tuner_addr = ADDR_UNSET, | ||
1766 | .no_msp34xx = 1, | ||
1767 | .no_tda7432 = 1, /* must avoid, conflicts with the bt860 */ | ||
1768 | }, | ||
1769 | [BTTV_BOARD_IDS_EAGLE] = { | ||
1770 | /* M G Berberich <berberic@forwiss.uni-passau.de> */ | ||
1771 | .name = "IDS Eagle", | ||
1772 | .video_inputs = 4, | ||
1773 | /* .audio_inputs= 0, */ | ||
1774 | .tuner_type = TUNER_ABSENT, | ||
1775 | .tuner_addr = ADDR_UNSET, | ||
1776 | .svhs = NO_SVHS, | ||
1777 | .gpiomask = 0, | ||
1778 | .muxsel = MUXSEL(2, 2, 2, 2), | ||
1779 | .muxsel_hook = eagle_muxsel, | ||
1780 | .no_msp34xx = 1, | ||
1781 | .pll = PLL_28, | ||
1782 | }, | ||
1783 | [BTTV_BOARD_PINNACLESAT] = { | ||
1784 | .name = "Pinnacle PCTV Sat", | ||
1785 | .video_inputs = 2, | ||
1786 | /* .audio_inputs= 0, */ | ||
1787 | .svhs = 1, | ||
1788 | .tuner_type = TUNER_ABSENT, | ||
1789 | .tuner_addr = ADDR_UNSET, | ||
1790 | .no_msp34xx = 1, | ||
1791 | .no_tda7432 = 1, | ||
1792 | .muxsel = MUXSEL(3, 1), | ||
1793 | .pll = PLL_28, | ||
1794 | .no_gpioirq = 1, | ||
1795 | .has_dvb = 1, | ||
1796 | }, | ||
1797 | [BTTV_BOARD_FORMAC_PROTV] = { | ||
1798 | .name = "Formac ProTV II (bt878)", | ||
1799 | .video_inputs = 4, | ||
1800 | /* .audio_inputs= 1, */ | ||
1801 | .svhs = 3, | ||
1802 | .gpiomask = 2, | ||
1803 | /* TV, Comp1, Composite over SVID con, SVID */ | ||
1804 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1805 | .gpiomux = { 2, 2, 0, 0 }, | ||
1806 | .pll = PLL_28, | ||
1807 | .has_radio = 1, | ||
1808 | .tuner_type = TUNER_PHILIPS_PAL, | ||
1809 | .tuner_addr = ADDR_UNSET, | ||
1810 | /* sound routing: | ||
1811 | GPIO=0x00,0x01,0x03: mute (?) | ||
1812 | 0x02: both TV and radio (tuner: FM1216/I) | ||
1813 | The card has onboard audio connectors labeled "cdrom" and "board", | ||
1814 | not soldered here, though unknown wiring. | ||
1815 | Card lacks: external audio in, pci subsystem id. | ||
1816 | */ | ||
1817 | }, | ||
1818 | |||
1819 | /* ---- card 0x60 ---------------------------------- */ | ||
1820 | [BTTV_BOARD_MACHTV] = { | ||
1821 | .name = "MachTV", | ||
1822 | .video_inputs = 3, | ||
1823 | /* .audio_inputs= 1, */ | ||
1824 | .svhs = NO_SVHS, | ||
1825 | .gpiomask = 7, | ||
1826 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1827 | .gpiomux = { 0, 1, 2, 3}, | ||
1828 | .gpiomute = 4, | ||
1829 | .tuner_type = TUNER_PHILIPS_PAL, | ||
1830 | .tuner_addr = ADDR_UNSET, | ||
1831 | .pll = PLL_28, | ||
1832 | }, | ||
1833 | [BTTV_BOARD_EURESYS_PICOLO] = { | ||
1834 | .name = "Euresys Picolo", | ||
1835 | .video_inputs = 3, | ||
1836 | /* .audio_inputs= 0, */ | ||
1837 | .svhs = 2, | ||
1838 | .gpiomask = 0, | ||
1839 | .no_msp34xx = 1, | ||
1840 | .no_tda7432 = 1, | ||
1841 | .muxsel = MUXSEL(2, 0, 1), | ||
1842 | .pll = PLL_28, | ||
1843 | .tuner_type = TUNER_ABSENT, | ||
1844 | .tuner_addr = ADDR_UNSET, | ||
1845 | }, | ||
1846 | [BTTV_BOARD_PV150] = { | ||
1847 | /* Luc Van Hoeylandt <luc@e-magic.be> */ | ||
1848 | .name = "ProVideo PV150", /* 0x4f */ | ||
1849 | .video_inputs = 2, | ||
1850 | /* .audio_inputs= 0, */ | ||
1851 | .svhs = NO_SVHS, | ||
1852 | .gpiomask = 0, | ||
1853 | .muxsel = MUXSEL(2, 3), | ||
1854 | .gpiomux = { 0 }, | ||
1855 | .no_msp34xx = 1, | ||
1856 | .pll = PLL_28, | ||
1857 | .tuner_type = TUNER_ABSENT, | ||
1858 | .tuner_addr = ADDR_UNSET, | ||
1859 | }, | ||
1860 | [BTTV_BOARD_AD_TVK503] = { | ||
1861 | /* Hiroshi Takekawa <sian@big.or.jp> */ | ||
1862 | /* This card lacks subsystem ID */ | ||
1863 | .name = "AD-TVK503", /* 0x63 */ | ||
1864 | .video_inputs = 4, | ||
1865 | /* .audio_inputs= 1, */ | ||
1866 | .svhs = 2, | ||
1867 | .gpiomask = 0x001e8007, | ||
1868 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
1869 | /* Tuner, Radio, external, internal, off, on */ | ||
1870 | .gpiomux = { 0x08, 0x0f, 0x0a, 0x08 }, | ||
1871 | .gpiomute = 0x0f, | ||
1872 | .no_msp34xx = 1, | ||
1873 | .pll = PLL_28, | ||
1874 | .tuner_type = TUNER_PHILIPS_NTSC, | ||
1875 | .tuner_addr = ADDR_UNSET, | ||
1876 | .audio_mode_gpio= adtvk503_audio, | ||
1877 | }, | ||
1878 | |||
1879 | /* ---- card 0x64 ---------------------------------- */ | ||
1880 | [BTTV_BOARD_HERCULES_SM_TV] = { | ||
1881 | .name = "Hercules Smart TV Stereo", | ||
1882 | .video_inputs = 4, | ||
1883 | /* .audio_inputs= 1, */ | ||
1884 | .svhs = 2, | ||
1885 | .gpiomask = 0x00, | ||
1886 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1887 | .no_msp34xx = 1, | ||
1888 | .pll = PLL_28, | ||
1889 | .tuner_type = TUNER_PHILIPS_PAL, | ||
1890 | .tuner_addr = ADDR_UNSET, | ||
1891 | /* Notes: | ||
1892 | - card lacks subsystem ID | ||
1893 | - stereo variant w/ daughter board with tda9874a @0xb0 | ||
1894 | - Audio Routing: | ||
1895 | always from tda9874 independent of GPIO (?) | ||
1896 | external line in: unknown | ||
1897 | - Other chips: em78p156elp @ 0x96 (probably IR remote control) | ||
1898 | hef4053 (instead 4052) for unknown function | ||
1899 | */ | ||
1900 | }, | ||
1901 | [BTTV_BOARD_PACETV] = { | ||
1902 | .name = "Pace TV & Radio Card", | ||
1903 | .video_inputs = 4, | ||
1904 | /* .audio_inputs= 1, */ | ||
1905 | .svhs = 2, | ||
1906 | /* Tuner, CVid, SVid, CVid over SVid connector */ | ||
1907 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
1908 | .gpiomask = 0, | ||
1909 | .no_tda7432 = 1, | ||
1910 | .tuner_type = TUNER_PHILIPS_PAL_I, | ||
1911 | .tuner_addr = ADDR_UNSET, | ||
1912 | .has_radio = 1, | ||
1913 | .pll = PLL_28, | ||
1914 | /* Bt878, Bt832, FI1246 tuner; no pci subsystem id | ||
1915 | only internal line out: (4pin header) RGGL | ||
1916 | Radio must be decoded by msp3410d (not routed through)*/ | ||
1917 | /* | ||
1918 | .digital_mode = DIGITAL_MODE_CAMERA, todo! | ||
1919 | */ | ||
1920 | }, | ||
1921 | [BTTV_BOARD_IVC200] = { | ||
1922 | /* Chris Willing <chris@vislab.usyd.edu.au> */ | ||
1923 | .name = "IVC-200", | ||
1924 | .video_inputs = 1, | ||
1925 | /* .audio_inputs= 0, */ | ||
1926 | .tuner_type = TUNER_ABSENT, | ||
1927 | .tuner_addr = ADDR_UNSET, | ||
1928 | .svhs = NO_SVHS, | ||
1929 | .gpiomask = 0xdf, | ||
1930 | .muxsel = MUXSEL(2), | ||
1931 | .pll = PLL_28, | ||
1932 | }, | ||
1933 | [BTTV_BOARD_IVCE8784] = { | ||
1934 | .name = "IVCE-8784", | ||
1935 | .video_inputs = 1, | ||
1936 | /* .audio_inputs= 0, */ | ||
1937 | .tuner_type = TUNER_ABSENT, | ||
1938 | .tuner_addr = ADDR_UNSET, | ||
1939 | .svhs = NO_SVHS, | ||
1940 | .gpiomask = 0xdf, | ||
1941 | .muxsel = MUXSEL(2), | ||
1942 | .pll = PLL_28, | ||
1943 | }, | ||
1944 | [BTTV_BOARD_XGUARD] = { | ||
1945 | .name = "Grand X-Guard / Trust 814PCI", | ||
1946 | .video_inputs = 16, | ||
1947 | /* .audio_inputs= 0, */ | ||
1948 | .svhs = NO_SVHS, | ||
1949 | .tuner_type = TUNER_ABSENT, | ||
1950 | .tuner_addr = ADDR_UNSET, | ||
1951 | .gpiomask2 = 0xff, | ||
1952 | .muxsel = MUXSEL(2,2,2,2, 3,3,3,3, 1,1,1,1, 0,0,0,0), | ||
1953 | .muxsel_hook = xguard_muxsel, | ||
1954 | .no_msp34xx = 1, | ||
1955 | .no_tda7432 = 1, | ||
1956 | .pll = PLL_28, | ||
1957 | }, | ||
1958 | |||
1959 | /* ---- card 0x68 ---------------------------------- */ | ||
1960 | [BTTV_BOARD_NEBULA_DIGITV] = { | ||
1961 | .name = "Nebula Electronics DigiTV", | ||
1962 | .video_inputs = 1, | ||
1963 | .svhs = NO_SVHS, | ||
1964 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
1965 | .no_msp34xx = 1, | ||
1966 | .no_tda7432 = 1, | ||
1967 | .pll = PLL_28, | ||
1968 | .tuner_type = TUNER_ABSENT, | ||
1969 | .tuner_addr = ADDR_UNSET, | ||
1970 | .has_dvb = 1, | ||
1971 | .has_remote = 1, | ||
1972 | .gpiomask = 0x1b, | ||
1973 | .no_gpioirq = 1, | ||
1974 | }, | ||
1975 | [BTTV_BOARD_PV143] = { | ||
1976 | /* Jorge Boncompte - DTI2 <jorge@dti2.net> */ | ||
1977 | .name = "ProVideo PV143", | ||
1978 | .video_inputs = 4, | ||
1979 | /* .audio_inputs= 0, */ | ||
1980 | .svhs = NO_SVHS, | ||
1981 | .gpiomask = 0, | ||
1982 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
1983 | .gpiomux = { 0 }, | ||
1984 | .no_msp34xx = 1, | ||
1985 | .pll = PLL_28, | ||
1986 | .tuner_type = TUNER_ABSENT, | ||
1987 | .tuner_addr = ADDR_UNSET, | ||
1988 | }, | ||
1989 | [BTTV_BOARD_VD009X1_VD011_MINIDIN] = { | ||
1990 | /* M.Klahr@phytec.de */ | ||
1991 | .name = "PHYTEC VD-009-X1 VD-011 MiniDIN (bt878)", | ||
1992 | .video_inputs = 4, | ||
1993 | /* .audio_inputs= 0, */ | ||
1994 | .svhs = 3, | ||
1995 | .gpiomask = 0x00, | ||
1996 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
1997 | .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */ | ||
1998 | .pll = PLL_28, | ||
1999 | .tuner_type = TUNER_ABSENT, | ||
2000 | .tuner_addr = ADDR_UNSET, | ||
2001 | }, | ||
2002 | [BTTV_BOARD_VD009X1_VD011_COMBI] = { | ||
2003 | .name = "PHYTEC VD-009-X1 VD-011 Combi (bt878)", | ||
2004 | .video_inputs = 4, | ||
2005 | /* .audio_inputs= 0, */ | ||
2006 | .svhs = 3, | ||
2007 | .gpiomask = 0x00, | ||
2008 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2009 | .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */ | ||
2010 | .pll = PLL_28, | ||
2011 | .tuner_type = TUNER_ABSENT, | ||
2012 | .tuner_addr = ADDR_UNSET, | ||
2013 | }, | ||
2014 | |||
2015 | /* ---- card 0x6c ---------------------------------- */ | ||
2016 | [BTTV_BOARD_VD009_MINIDIN] = { | ||
2017 | .name = "PHYTEC VD-009 MiniDIN (bt878)", | ||
2018 | .video_inputs = 10, | ||
2019 | /* .audio_inputs= 0, */ | ||
2020 | .svhs = 9, | ||
2021 | .gpiomask = 0x00, | ||
2022 | .gpiomask2 = 0x03, /* used for external vodeo mux */ | ||
2023 | .muxsel = MUXSEL(2, 2, 2, 2, 3, 3, 3, 3, 1, 0), | ||
2024 | .muxsel_hook = phytec_muxsel, | ||
2025 | .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */ | ||
2026 | .pll = PLL_28, | ||
2027 | .tuner_type = TUNER_ABSENT, | ||
2028 | .tuner_addr = ADDR_UNSET, | ||
2029 | }, | ||
2030 | [BTTV_BOARD_VD009_COMBI] = { | ||
2031 | .name = "PHYTEC VD-009 Combi (bt878)", | ||
2032 | .video_inputs = 10, | ||
2033 | /* .audio_inputs= 0, */ | ||
2034 | .svhs = 9, | ||
2035 | .gpiomask = 0x00, | ||
2036 | .gpiomask2 = 0x03, /* used for external vodeo mux */ | ||
2037 | .muxsel = MUXSEL(2, 2, 2, 2, 3, 3, 3, 3, 1, 1), | ||
2038 | .muxsel_hook = phytec_muxsel, | ||
2039 | .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */ | ||
2040 | .pll = PLL_28, | ||
2041 | .tuner_type = TUNER_ABSENT, | ||
2042 | .tuner_addr = ADDR_UNSET, | ||
2043 | }, | ||
2044 | [BTTV_BOARD_IVC100] = { | ||
2045 | .name = "IVC-100", | ||
2046 | .video_inputs = 4, | ||
2047 | /* .audio_inputs= 0, */ | ||
2048 | .tuner_type = TUNER_ABSENT, | ||
2049 | .tuner_addr = ADDR_UNSET, | ||
2050 | .svhs = NO_SVHS, | ||
2051 | .gpiomask = 0xdf, | ||
2052 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
2053 | .pll = PLL_28, | ||
2054 | }, | ||
2055 | [BTTV_BOARD_IVC120] = { | ||
2056 | /* IVC-120G - Alan Garfield <alan@fromorbit.com> */ | ||
2057 | .name = "IVC-120G", | ||
2058 | .video_inputs = 16, | ||
2059 | /* .audio_inputs= 0, */ | ||
2060 | .tuner_type = TUNER_ABSENT, | ||
2061 | .tuner_addr = ADDR_UNSET, | ||
2062 | .svhs = NO_SVHS, /* card has no svhs */ | ||
2063 | .no_msp34xx = 1, | ||
2064 | .no_tda7432 = 1, | ||
2065 | .gpiomask = 0x00, | ||
2066 | .muxsel = MUXSEL(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), | ||
2067 | .muxsel_hook = ivc120_muxsel, | ||
2068 | .pll = PLL_28, | ||
2069 | }, | ||
2070 | |||
2071 | /* ---- card 0x70 ---------------------------------- */ | ||
2072 | [BTTV_BOARD_PC_HDTV] = { | ||
2073 | .name = "pcHDTV HD-2000 TV", | ||
2074 | .video_inputs = 4, | ||
2075 | /* .audio_inputs= 1, */ | ||
2076 | .svhs = 2, | ||
2077 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
2078 | .tuner_type = TUNER_PHILIPS_FCV1236D, | ||
2079 | .tuner_addr = ADDR_UNSET, | ||
2080 | .has_dvb = 1, | ||
2081 | }, | ||
2082 | [BTTV_BOARD_TWINHAN_DST] = { | ||
2083 | .name = "Twinhan DST + clones", | ||
2084 | .no_msp34xx = 1, | ||
2085 | .no_tda7432 = 1, | ||
2086 | .tuner_type = TUNER_ABSENT, | ||
2087 | .tuner_addr = ADDR_UNSET, | ||
2088 | .no_video = 1, | ||
2089 | .has_dvb = 1, | ||
2090 | }, | ||
2091 | [BTTV_BOARD_WINFASTVC100] = { | ||
2092 | .name = "Winfast VC100", | ||
2093 | .video_inputs = 3, | ||
2094 | /* .audio_inputs= 0, */ | ||
2095 | .svhs = 1, | ||
2096 | /* Vid In, SVid In, Vid over SVid in connector */ | ||
2097 | .muxsel = MUXSEL(3, 1, 1, 3), | ||
2098 | .no_msp34xx = 1, | ||
2099 | .no_tda7432 = 1, | ||
2100 | .tuner_type = TUNER_ABSENT, | ||
2101 | .tuner_addr = ADDR_UNSET, | ||
2102 | .pll = PLL_28, | ||
2103 | }, | ||
2104 | [BTTV_BOARD_TEV560] = { | ||
2105 | .name = "Teppro TEV-560/InterVision IV-560", | ||
2106 | .video_inputs = 3, | ||
2107 | /* .audio_inputs= 1, */ | ||
2108 | .svhs = 2, | ||
2109 | .gpiomask = 3, | ||
2110 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2111 | .gpiomux = { 1, 1, 1, 1 }, | ||
2112 | .tuner_type = TUNER_PHILIPS_PAL, | ||
2113 | .tuner_addr = ADDR_UNSET, | ||
2114 | .pll = PLL_35, | ||
2115 | }, | ||
2116 | |||
2117 | /* ---- card 0x74 ---------------------------------- */ | ||
2118 | [BTTV_BOARD_SIMUS_GVC1100] = { | ||
2119 | .name = "SIMUS GVC1100", | ||
2120 | .video_inputs = 4, | ||
2121 | /* .audio_inputs= 0, */ | ||
2122 | .svhs = NO_SVHS, | ||
2123 | .tuner_type = TUNER_ABSENT, | ||
2124 | .tuner_addr = ADDR_UNSET, | ||
2125 | .pll = PLL_28, | ||
2126 | .muxsel = MUXSEL(2, 2, 2, 2), | ||
2127 | .gpiomask = 0x3F, | ||
2128 | .muxsel_hook = gvc1100_muxsel, | ||
2129 | }, | ||
2130 | [BTTV_BOARD_NGSTV_PLUS] = { | ||
2131 | /* Carlos Silva r3pek@r3pek.homelinux.org || card 0x75 */ | ||
2132 | .name = "NGS NGSTV+", | ||
2133 | .video_inputs = 3, | ||
2134 | .svhs = 2, | ||
2135 | .gpiomask = 0x008007, | ||
2136 | .muxsel = MUXSEL(2, 3, 0, 0), | ||
2137 | .gpiomux = { 0, 0, 0, 0 }, | ||
2138 | .gpiomute = 0x000003, | ||
2139 | .pll = PLL_28, | ||
2140 | .tuner_type = TUNER_PHILIPS_PAL, | ||
2141 | .tuner_addr = ADDR_UNSET, | ||
2142 | .has_remote = 1, | ||
2143 | }, | ||
2144 | [BTTV_BOARD_LMLBT4] = { | ||
2145 | /* http://linuxmedialabs.com */ | ||
2146 | .name = "LMLBT4", | ||
2147 | .video_inputs = 4, /* IN1,IN2,IN3,IN4 */ | ||
2148 | /* .audio_inputs= 0, */ | ||
2149 | .svhs = NO_SVHS, | ||
2150 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
2151 | .no_msp34xx = 1, | ||
2152 | .no_tda7432 = 1, | ||
2153 | .tuner_type = TUNER_ABSENT, | ||
2154 | .tuner_addr = ADDR_UNSET, | ||
2155 | }, | ||
2156 | [BTTV_BOARD_TEKRAM_M205] = { | ||
2157 | /* Helmroos Harri <harri.helmroos@pp.inet.fi> */ | ||
2158 | .name = "Tekram M205 PRO", | ||
2159 | .video_inputs = 3, | ||
2160 | /* .audio_inputs= 1, */ | ||
2161 | .tuner_type = TUNER_PHILIPS_PAL, | ||
2162 | .tuner_addr = ADDR_UNSET, | ||
2163 | .svhs = 2, | ||
2164 | .gpiomask = 0x68, | ||
2165 | .muxsel = MUXSEL(2, 3, 1), | ||
2166 | .gpiomux = { 0x68, 0x68, 0x61, 0x61 }, | ||
2167 | .pll = PLL_28, | ||
2168 | }, | ||
2169 | |||
2170 | /* ---- card 0x78 ---------------------------------- */ | ||
2171 | [BTTV_BOARD_CONTVFMI] = { | ||
2172 | /* Javier Cendan Ares <jcendan@lycos.es> */ | ||
2173 | /* bt878 TV + FM without subsystem ID */ | ||
2174 | .name = "Conceptronic CONTVFMi", | ||
2175 | .video_inputs = 3, | ||
2176 | /* .audio_inputs= 1, */ | ||
2177 | .svhs = 2, | ||
2178 | .gpiomask = 0x008007, | ||
2179 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2180 | .gpiomux = { 0, 1, 2, 2 }, | ||
2181 | .gpiomute = 3, | ||
2182 | .pll = PLL_28, | ||
2183 | .tuner_type = TUNER_PHILIPS_PAL, | ||
2184 | .tuner_addr = ADDR_UNSET, | ||
2185 | .has_remote = 1, | ||
2186 | .has_radio = 1, | ||
2187 | }, | ||
2188 | [BTTV_BOARD_PICOLO_TETRA_CHIP] = { | ||
2189 | /*Eric DEBIEF <debief@telemsa.com>*/ | ||
2190 | /*EURESYS Picolo Tetra : 4 Conexant Fusion 878A, no audio, video input set with analog multiplexers GPIO controlled*/ | ||
2191 | /* adds picolo_tetra_muxsel(), picolo_tetra_init(), the following declaration strucure, and #define BTTV_BOARD_PICOLO_TETRA_CHIP*/ | ||
2192 | /*0x79 in bttv.h*/ | ||
2193 | .name = "Euresys Picolo Tetra", | ||
2194 | .video_inputs = 4, | ||
2195 | /* .audio_inputs= 0, */ | ||
2196 | .svhs = NO_SVHS, | ||
2197 | .gpiomask = 0, | ||
2198 | .gpiomask2 = 0x3C<<16,/*Set the GPIO[18]->GPIO[21] as output pin.==> drive the video inputs through analog multiplexers*/ | ||
2199 | .no_msp34xx = 1, | ||
2200 | .no_tda7432 = 1, | ||
2201 | /*878A input is always MUX0, see above.*/ | ||
2202 | .muxsel = MUXSEL(2, 2, 2, 2), | ||
2203 | .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */ | ||
2204 | .pll = PLL_28, | ||
2205 | .muxsel_hook = picolo_tetra_muxsel,/*Required as it doesn't follow the classic input selection policy*/ | ||
2206 | .tuner_type = TUNER_ABSENT, | ||
2207 | .tuner_addr = ADDR_UNSET, | ||
2208 | }, | ||
2209 | [BTTV_BOARD_SPIRIT_TV] = { | ||
2210 | /* Spirit TV Tuner from http://spiritmodems.com.au */ | ||
2211 | /* Stafford Goodsell <surge@goliath.homeunix.org> */ | ||
2212 | .name = "Spirit TV Tuner", | ||
2213 | .video_inputs = 3, | ||
2214 | /* .audio_inputs= 1, */ | ||
2215 | .svhs = 2, | ||
2216 | .gpiomask = 0x0000000f, | ||
2217 | .muxsel = MUXSEL(2, 1, 1), | ||
2218 | .gpiomux = { 0x02, 0x00, 0x00, 0x00 }, | ||
2219 | .tuner_type = TUNER_TEMIC_PAL, | ||
2220 | .tuner_addr = ADDR_UNSET, | ||
2221 | .no_msp34xx = 1, | ||
2222 | }, | ||
2223 | [BTTV_BOARD_AVDVBT_771] = { | ||
2224 | /* Wolfram Joost <wojo@frokaschwei.de> */ | ||
2225 | .name = "AVerMedia AVerTV DVB-T 771", | ||
2226 | .video_inputs = 2, | ||
2227 | .svhs = 1, | ||
2228 | .tuner_type = TUNER_ABSENT, | ||
2229 | .tuner_addr = ADDR_UNSET, | ||
2230 | .muxsel = MUXSEL(3, 3), | ||
2231 | .no_msp34xx = 1, | ||
2232 | .no_tda7432 = 1, | ||
2233 | .pll = PLL_28, | ||
2234 | .has_dvb = 1, | ||
2235 | .no_gpioirq = 1, | ||
2236 | .has_remote = 1, | ||
2237 | }, | ||
2238 | /* ---- card 0x7c ---------------------------------- */ | ||
2239 | [BTTV_BOARD_AVDVBT_761] = { | ||
2240 | /* Matt Jesson <dvb@jesson.eclipse.co.uk> */ | ||
2241 | /* Based on the Nebula card data - added remote and new card number - BTTV_BOARD_AVDVBT_761, see also ir-kbd-gpio.c */ | ||
2242 | .name = "AverMedia AverTV DVB-T 761", | ||
2243 | .video_inputs = 2, | ||
2244 | .svhs = 1, | ||
2245 | .muxsel = MUXSEL(3, 1, 2, 0), /* Comp0, S-Video, ?, ? */ | ||
2246 | .no_msp34xx = 1, | ||
2247 | .no_tda7432 = 1, | ||
2248 | .pll = PLL_28, | ||
2249 | .tuner_type = TUNER_ABSENT, | ||
2250 | .tuner_addr = ADDR_UNSET, | ||
2251 | .has_dvb = 1, | ||
2252 | .no_gpioirq = 1, | ||
2253 | .has_remote = 1, | ||
2254 | }, | ||
2255 | [BTTV_BOARD_MATRIX_VISIONSQ] = { | ||
2256 | /* andre.schwarz@matrix-vision.de */ | ||
2257 | .name = "MATRIX Vision Sigma-SQ", | ||
2258 | .video_inputs = 16, | ||
2259 | /* .audio_inputs= 0, */ | ||
2260 | .svhs = NO_SVHS, | ||
2261 | .gpiomask = 0x0, | ||
2262 | .muxsel = MUXSEL(2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3), | ||
2263 | .muxsel_hook = sigmaSQ_muxsel, | ||
2264 | .gpiomux = { 0 }, | ||
2265 | .no_msp34xx = 1, | ||
2266 | .pll = PLL_28, | ||
2267 | .tuner_type = TUNER_ABSENT, | ||
2268 | .tuner_addr = ADDR_UNSET, | ||
2269 | }, | ||
2270 | [BTTV_BOARD_MATRIX_VISIONSLC] = { | ||
2271 | /* andre.schwarz@matrix-vision.de */ | ||
2272 | .name = "MATRIX Vision Sigma-SLC", | ||
2273 | .video_inputs = 4, | ||
2274 | /* .audio_inputs= 0, */ | ||
2275 | .svhs = NO_SVHS, | ||
2276 | .gpiomask = 0x0, | ||
2277 | .muxsel = MUXSEL(2, 2, 2, 2), | ||
2278 | .muxsel_hook = sigmaSLC_muxsel, | ||
2279 | .gpiomux = { 0 }, | ||
2280 | .no_msp34xx = 1, | ||
2281 | .pll = PLL_28, | ||
2282 | .tuner_type = TUNER_ABSENT, | ||
2283 | .tuner_addr = ADDR_UNSET, | ||
2284 | }, | ||
2285 | /* BTTV_BOARD_APAC_VIEWCOMP */ | ||
2286 | [BTTV_BOARD_APAC_VIEWCOMP] = { | ||
2287 | /* Attila Kondoros <attila.kondoros@chello.hu> */ | ||
2288 | /* bt878 TV + FM 0x00000000 subsystem ID */ | ||
2289 | .name = "APAC Viewcomp 878(AMAX)", | ||
2290 | .video_inputs = 2, | ||
2291 | /* .audio_inputs= 1, */ | ||
2292 | .svhs = NO_SVHS, | ||
2293 | .gpiomask = 0xFF, | ||
2294 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2295 | .gpiomux = { 2, 0, 0, 0 }, | ||
2296 | .gpiomute = 10, | ||
2297 | .pll = PLL_28, | ||
2298 | .tuner_type = TUNER_PHILIPS_PAL, | ||
2299 | .tuner_addr = ADDR_UNSET, | ||
2300 | .has_remote = 1, /* miniremote works, see ir-kbd-gpio.c */ | ||
2301 | .has_radio = 1, /* not every card has radio */ | ||
2302 | }, | ||
2303 | |||
2304 | /* ---- card 0x80 ---------------------------------- */ | ||
2305 | [BTTV_BOARD_DVICO_DVBT_LITE] = { | ||
2306 | /* Chris Pascoe <c.pascoe@itee.uq.edu.au> */ | ||
2307 | .name = "DViCO FusionHDTV DVB-T Lite", | ||
2308 | .no_msp34xx = 1, | ||
2309 | .no_tda7432 = 1, | ||
2310 | .pll = PLL_28, | ||
2311 | .no_video = 1, | ||
2312 | .has_dvb = 1, | ||
2313 | .tuner_type = TUNER_ABSENT, | ||
2314 | .tuner_addr = ADDR_UNSET, | ||
2315 | }, | ||
2316 | [BTTV_BOARD_VGEAR_MYVCD] = { | ||
2317 | /* Steven <photon38@pchome.com.tw> */ | ||
2318 | .name = "V-Gear MyVCD", | ||
2319 | .video_inputs = 3, | ||
2320 | /* .audio_inputs= 1, */ | ||
2321 | .svhs = 2, | ||
2322 | .gpiomask = 0x3f, | ||
2323 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
2324 | .gpiomux = {0x31, 0x31, 0x31, 0x31 }, | ||
2325 | .gpiomute = 0x31, | ||
2326 | .no_msp34xx = 1, | ||
2327 | .pll = PLL_28, | ||
2328 | .tuner_type = TUNER_PHILIPS_NTSC_M, | ||
2329 | .tuner_addr = ADDR_UNSET, | ||
2330 | .has_radio = 0, | ||
2331 | }, | ||
2332 | [BTTV_BOARD_SUPER_TV] = { | ||
2333 | /* Rick C <cryptdragoon@gmail.com> */ | ||
2334 | .name = "Super TV Tuner", | ||
2335 | .video_inputs = 4, | ||
2336 | /* .audio_inputs= 1, */ | ||
2337 | .svhs = 2, | ||
2338 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
2339 | .tuner_type = TUNER_PHILIPS_NTSC, | ||
2340 | .tuner_addr = ADDR_UNSET, | ||
2341 | .gpiomask = 0x008007, | ||
2342 | .gpiomux = { 0, 0x000001,0,0 }, | ||
2343 | .has_radio = 1, | ||
2344 | }, | ||
2345 | [BTTV_BOARD_TIBET_CS16] = { | ||
2346 | /* Chris Fanning <video4linux@haydon.net> */ | ||
2347 | .name = "Tibet Systems 'Progress DVR' CS16", | ||
2348 | .video_inputs = 16, | ||
2349 | /* .audio_inputs= 0, */ | ||
2350 | .svhs = NO_SVHS, | ||
2351 | .muxsel = MUXSEL(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), | ||
2352 | .pll = PLL_28, | ||
2353 | .no_msp34xx = 1, | ||
2354 | .no_tda7432 = 1, | ||
2355 | .tuner_type = TUNER_ABSENT, | ||
2356 | .tuner_addr = ADDR_UNSET, | ||
2357 | .muxsel_hook = tibetCS16_muxsel, | ||
2358 | }, | ||
2359 | [BTTV_BOARD_KODICOM_4400R] = { | ||
2360 | /* Bill Brack <wbrack@mmm.com.hk> */ | ||
2361 | /* | ||
2362 | * Note that, because of the card's wiring, the "master" | ||
2363 | * BT878A chip (i.e. the one which controls the analog switch | ||
2364 | * and must use this card type) is the 2nd one detected. The | ||
2365 | * other 3 chips should use card type 0x85, whose description | ||
2366 | * follows this one. There is a EEPROM on the card (which is | ||
2367 | * connected to the I2C of one of those other chips), but is | ||
2368 | * not currently handled. There is also a facility for a | ||
2369 | * "monitor", which is also not currently implemented. | ||
2370 | */ | ||
2371 | .name = "Kodicom 4400R (master)", | ||
2372 | .video_inputs = 16, | ||
2373 | /* .audio_inputs= 0, */ | ||
2374 | .tuner_type = TUNER_ABSENT, | ||
2375 | .tuner_addr = ADDR_UNSET, | ||
2376 | .svhs = NO_SVHS, | ||
2377 | /* GPIO bits 0-9 used for analog switch: | ||
2378 | * 00 - 03: camera selector | ||
2379 | * 04 - 06: channel (controller) selector | ||
2380 | * 07: data (1->on, 0->off) | ||
2381 | * 08: strobe | ||
2382 | * 09: reset | ||
2383 | * bit 16 is input from sync separator for the channel | ||
2384 | */ | ||
2385 | .gpiomask = 0x0003ff, | ||
2386 | .no_gpioirq = 1, | ||
2387 | .muxsel = MUXSEL(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), | ||
2388 | .pll = PLL_28, | ||
2389 | .no_msp34xx = 1, | ||
2390 | .no_tda7432 = 1, | ||
2391 | .muxsel_hook = kodicom4400r_muxsel, | ||
2392 | }, | ||
2393 | [BTTV_BOARD_KODICOM_4400R_SL] = { | ||
2394 | /* Bill Brack <wbrack@mmm.com.hk> */ | ||
2395 | /* Note that, for reasons unknown, the "master" BT878A chip (i.e. the | ||
2396 | * one which controls the analog switch, and must use the card type) | ||
2397 | * is the 2nd one detected. The other 3 chips should use this card | ||
2398 | * type | ||
2399 | */ | ||
2400 | .name = "Kodicom 4400R (slave)", | ||
2401 | .video_inputs = 16, | ||
2402 | /* .audio_inputs= 0, */ | ||
2403 | .tuner_type = TUNER_ABSENT, | ||
2404 | .tuner_addr = ADDR_UNSET, | ||
2405 | .svhs = NO_SVHS, | ||
2406 | .gpiomask = 0x010000, | ||
2407 | .no_gpioirq = 1, | ||
2408 | .muxsel = MUXSEL(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), | ||
2409 | .pll = PLL_28, | ||
2410 | .no_msp34xx = 1, | ||
2411 | .no_tda7432 = 1, | ||
2412 | .muxsel_hook = kodicom4400r_muxsel, | ||
2413 | }, | ||
2414 | /* ---- card 0x86---------------------------------- */ | ||
2415 | [BTTV_BOARD_ADLINK_RTV24] = { | ||
2416 | /* Michael Henson <mhenson@clarityvi.com> */ | ||
2417 | /* Adlink RTV24 with special unlock codes */ | ||
2418 | .name = "Adlink RTV24", | ||
2419 | .video_inputs = 4, | ||
2420 | /* .audio_inputs= 1, */ | ||
2421 | .svhs = 2, | ||
2422 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
2423 | .tuner_type = UNSET, | ||
2424 | .tuner_addr = ADDR_UNSET, | ||
2425 | .pll = PLL_28, | ||
2426 | }, | ||
2427 | /* ---- card 0x87---------------------------------- */ | ||
2428 | [BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE] = { | ||
2429 | /* Michael Krufky <mkrufky@m1k.net> */ | ||
2430 | .name = "DViCO FusionHDTV 5 Lite", | ||
2431 | .tuner_type = TUNER_LG_TDVS_H06XF, /* TDVS-H064F */ | ||
2432 | .tuner_addr = ADDR_UNSET, | ||
2433 | .video_inputs = 3, | ||
2434 | /* .audio_inputs= 1, */ | ||
2435 | .svhs = 2, | ||
2436 | .muxsel = MUXSEL(2, 3, 1), | ||
2437 | .gpiomask = 0x00e00007, | ||
2438 | .gpiomux = { 0x00400005, 0, 0x00000001, 0 }, | ||
2439 | .gpiomute = 0x00c00007, | ||
2440 | .no_msp34xx = 1, | ||
2441 | .no_tda7432 = 1, | ||
2442 | .has_dvb = 1, | ||
2443 | }, | ||
2444 | /* ---- card 0x88---------------------------------- */ | ||
2445 | [BTTV_BOARD_ACORP_Y878F] = { | ||
2446 | /* Mauro Carvalho Chehab <mchehab@infradead.org> */ | ||
2447 | .name = "Acorp Y878F", | ||
2448 | .video_inputs = 3, | ||
2449 | /* .audio_inputs= 1, */ | ||
2450 | .svhs = 2, | ||
2451 | .gpiomask = 0x01fe00, | ||
2452 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2453 | .gpiomux = { 0x001e00, 0, 0x018000, 0x014000 }, | ||
2454 | .gpiomute = 0x002000, | ||
2455 | .pll = PLL_28, | ||
2456 | .tuner_type = TUNER_YMEC_TVF66T5_B_DFF, | ||
2457 | .tuner_addr = 0xc1 >>1, | ||
2458 | .has_radio = 1, | ||
2459 | }, | ||
2460 | /* ---- card 0x89 ---------------------------------- */ | ||
2461 | [BTTV_BOARD_CONCEPTRONIC_CTVFMI2] = { | ||
2462 | .name = "Conceptronic CTVFMi v2", | ||
2463 | .video_inputs = 3, | ||
2464 | /* .audio_inputs= 1, */ | ||
2465 | .svhs = 2, | ||
2466 | .gpiomask = 0x001c0007, | ||
2467 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2468 | .gpiomux = { 0, 1, 2, 2 }, | ||
2469 | .gpiomute = 3, | ||
2470 | .pll = PLL_28, | ||
2471 | .tuner_type = TUNER_TENA_9533_DI, | ||
2472 | .tuner_addr = ADDR_UNSET, | ||
2473 | .has_remote = 1, | ||
2474 | .has_radio = 1, | ||
2475 | }, | ||
2476 | /* ---- card 0x8a ---------------------------------- */ | ||
2477 | [BTTV_BOARD_PV_BT878P_2E] = { | ||
2478 | .name = "Prolink Pixelview PV-BT878P+ (Rev.2E)", | ||
2479 | .video_inputs = 5, | ||
2480 | /* .audio_inputs= 1, */ | ||
2481 | .svhs = 3, | ||
2482 | .has_dig_in = 1, | ||
2483 | .gpiomask = 0x01fe00, | ||
2484 | .muxsel = MUXSEL(2, 3, 1, 1, 0), /* in 4 is digital */ | ||
2485 | /* .digital_mode= DIGITAL_MODE_CAMERA, */ | ||
2486 | .gpiomux = { 0x00400, 0x10400, 0x04400, 0x80000 }, | ||
2487 | .gpiomute = 0x12400, | ||
2488 | .no_msp34xx = 1, | ||
2489 | .pll = PLL_28, | ||
2490 | .tuner_type = TUNER_LG_PAL_FM, | ||
2491 | .tuner_addr = ADDR_UNSET, | ||
2492 | .has_remote = 1, | ||
2493 | }, | ||
2494 | /* ---- card 0x8b ---------------------------------- */ | ||
2495 | [BTTV_BOARD_PV_M4900] = { | ||
2496 | /* Sérgio Fortier <sergiofortier@yahoo.com.br> */ | ||
2497 | .name = "Prolink PixelView PlayTV MPEG2 PV-M4900", | ||
2498 | .video_inputs = 3, | ||
2499 | /* .audio_inputs= 1, */ | ||
2500 | .svhs = 2, | ||
2501 | .gpiomask = 0x3f, | ||
2502 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2503 | .gpiomux = { 0x21, 0x20, 0x24, 0x2c }, | ||
2504 | .gpiomute = 0x29, | ||
2505 | .no_msp34xx = 1, | ||
2506 | .pll = PLL_28, | ||
2507 | .tuner_type = TUNER_YMEC_TVF_5533MF, | ||
2508 | .tuner_addr = ADDR_UNSET, | ||
2509 | .has_radio = 1, | ||
2510 | .has_remote = 1, | ||
2511 | }, | ||
2512 | /* ---- card 0x8c ---------------------------------- */ | ||
2513 | /* Has four Bt878 chips behind a PCI bridge, each chip has: | ||
2514 | one external BNC composite input (mux 2) | ||
2515 | three internal composite inputs (unknown muxes) | ||
2516 | an 18-bit stereo A/D (CS5331A), which has: | ||
2517 | one external stereo unblanced (RCA) audio connection | ||
2518 | one (or 3?) internal stereo balanced (XLR) audio connection | ||
2519 | input is selected via gpio to a 14052B mux | ||
2520 | (mask=0x300, unbal=0x000, bal=0x100, ??=0x200,0x300) | ||
2521 | gain is controlled via an X9221A chip on the I2C bus @0x28 | ||
2522 | sample rate is controlled via gpio to an MK1413S | ||
2523 | (mask=0x3, 32kHz=0x0, 44.1kHz=0x1, 48kHz=0x2, ??=0x3) | ||
2524 | There is neither a tuner nor an svideo input. */ | ||
2525 | [BTTV_BOARD_OSPREY440] = { | ||
2526 | .name = "Osprey 440", | ||
2527 | .video_inputs = 4, | ||
2528 | /* .audio_inputs= 2, */ | ||
2529 | .svhs = NO_SVHS, | ||
2530 | .muxsel = MUXSEL(2, 3, 0, 1), /* 3,0,1 are guesses */ | ||
2531 | .gpiomask = 0x303, | ||
2532 | .gpiomute = 0x000, /* int + 32kHz */ | ||
2533 | .gpiomux = { 0, 0, 0x000, 0x100}, | ||
2534 | .pll = PLL_28, | ||
2535 | .tuner_type = TUNER_ABSENT, | ||
2536 | .tuner_addr = ADDR_UNSET, | ||
2537 | .no_msp34xx = 1, | ||
2538 | .no_tda7432 = 1, | ||
2539 | }, | ||
2540 | /* ---- card 0x8d ---------------------------------- */ | ||
2541 | [BTTV_BOARD_ASOUND_SKYEYE] = { | ||
2542 | .name = "Asound Skyeye PCTV", | ||
2543 | .video_inputs = 3, | ||
2544 | /* .audio_inputs= 1, */ | ||
2545 | .svhs = 2, | ||
2546 | .gpiomask = 15, | ||
2547 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2548 | .gpiomux = { 2, 0, 0, 0 }, | ||
2549 | .gpiomute = 1, | ||
2550 | .pll = PLL_28, | ||
2551 | .tuner_type = TUNER_PHILIPS_NTSC, | ||
2552 | .tuner_addr = ADDR_UNSET, | ||
2553 | }, | ||
2554 | /* ---- card 0x8e ---------------------------------- */ | ||
2555 | [BTTV_BOARD_SABRENT_TVFM] = { | ||
2556 | .name = "Sabrent TV-FM (bttv version)", | ||
2557 | .video_inputs = 3, | ||
2558 | /* .audio_inputs= 1, */ | ||
2559 | .svhs = 2, | ||
2560 | .gpiomask = 0x108007, | ||
2561 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2562 | .gpiomux = { 100000, 100002, 100002, 100000 }, | ||
2563 | .no_msp34xx = 1, | ||
2564 | .no_tda7432 = 1, | ||
2565 | .pll = PLL_28, | ||
2566 | .tuner_type = TUNER_TNF_5335MF, | ||
2567 | .tuner_addr = ADDR_UNSET, | ||
2568 | .has_radio = 1, | ||
2569 | }, | ||
2570 | /* ---- card 0x8f ---------------------------------- */ | ||
2571 | [BTTV_BOARD_HAUPPAUGE_IMPACTVCB] = { | ||
2572 | .name = "Hauppauge ImpactVCB (bt878)", | ||
2573 | .video_inputs = 4, | ||
2574 | /* .audio_inputs= 0, */ | ||
2575 | .svhs = NO_SVHS, | ||
2576 | .gpiomask = 0x0f, /* old: 7 */ | ||
2577 | .muxsel = MUXSEL(0, 1, 3, 2), /* Composite 0-3 */ | ||
2578 | .no_msp34xx = 1, | ||
2579 | .no_tda7432 = 1, | ||
2580 | .tuner_type = TUNER_ABSENT, | ||
2581 | .tuner_addr = ADDR_UNSET, | ||
2582 | }, | ||
2583 | [BTTV_BOARD_MACHTV_MAGICTV] = { | ||
2584 | /* Julian Calaby <julian.calaby@gmail.com> | ||
2585 | * Slightly different from original MachTV definition (0x60) | ||
2586 | |||
2587 | * FIXME: RegSpy says gpiomask should be "0x001c800f", but it | ||
2588 | * stuffs up remote chip. Bug is a pin on the jaecs is not set | ||
2589 | * properly (methinks) causing no keyup bits being set */ | ||
2590 | |||
2591 | .name = "MagicTV", /* rebranded MachTV */ | ||
2592 | .video_inputs = 3, | ||
2593 | /* .audio_inputs= 1, */ | ||
2594 | .svhs = 2, | ||
2595 | .gpiomask = 7, | ||
2596 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2597 | .gpiomux = { 0, 1, 2, 3 }, | ||
2598 | .gpiomute = 4, | ||
2599 | .tuner_type = TUNER_TEMIC_4009FR5_PAL, | ||
2600 | .tuner_addr = ADDR_UNSET, | ||
2601 | .pll = PLL_28, | ||
2602 | .has_radio = 1, | ||
2603 | .has_remote = 1, | ||
2604 | }, | ||
2605 | [BTTV_BOARD_SSAI_SECURITY] = { | ||
2606 | .name = "SSAI Security Video Interface", | ||
2607 | .video_inputs = 4, | ||
2608 | /* .audio_inputs= 0, */ | ||
2609 | .svhs = NO_SVHS, | ||
2610 | .muxsel = MUXSEL(0, 1, 2, 3), | ||
2611 | .tuner_type = TUNER_ABSENT, | ||
2612 | .tuner_addr = ADDR_UNSET, | ||
2613 | }, | ||
2614 | [BTTV_BOARD_SSAI_ULTRASOUND] = { | ||
2615 | .name = "SSAI Ultrasound Video Interface", | ||
2616 | .video_inputs = 2, | ||
2617 | /* .audio_inputs= 0, */ | ||
2618 | .svhs = 1, | ||
2619 | .muxsel = MUXSEL(2, 0, 1, 3), | ||
2620 | .tuner_type = TUNER_ABSENT, | ||
2621 | .tuner_addr = ADDR_UNSET, | ||
2622 | }, | ||
2623 | /* ---- card 0x94---------------------------------- */ | ||
2624 | [BTTV_BOARD_DVICO_FUSIONHDTV_2] = { | ||
2625 | .name = "DViCO FusionHDTV 2", | ||
2626 | .tuner_type = TUNER_PHILIPS_FCV1236D, | ||
2627 | .tuner_addr = ADDR_UNSET, | ||
2628 | .video_inputs = 3, | ||
2629 | /* .audio_inputs= 1, */ | ||
2630 | .svhs = 2, | ||
2631 | .muxsel = MUXSEL(2, 3, 1), | ||
2632 | .gpiomask = 0x00e00007, | ||
2633 | .gpiomux = { 0x00400005, 0, 0x00000001, 0 }, | ||
2634 | .gpiomute = 0x00c00007, | ||
2635 | .no_msp34xx = 1, | ||
2636 | .no_tda7432 = 1, | ||
2637 | }, | ||
2638 | /* ---- card 0x95---------------------------------- */ | ||
2639 | [BTTV_BOARD_TYPHOON_TVTUNERPCI] = { | ||
2640 | .name = "Typhoon TV-Tuner PCI (50684)", | ||
2641 | .video_inputs = 3, | ||
2642 | /* .audio_inputs= 1, */ | ||
2643 | .svhs = 2, | ||
2644 | .gpiomask = 0x3014f, | ||
2645 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2646 | .gpiomux = { 0x20001,0x10001, 0, 0 }, | ||
2647 | .gpiomute = 10, | ||
2648 | .pll = PLL_28, | ||
2649 | .tuner_type = TUNER_PHILIPS_PAL_I, | ||
2650 | .tuner_addr = ADDR_UNSET, | ||
2651 | }, | ||
2652 | [BTTV_BOARD_GEOVISION_GV600] = { | ||
2653 | /* emhn@usb.ve */ | ||
2654 | .name = "Geovision GV-600", | ||
2655 | .video_inputs = 16, | ||
2656 | /* .audio_inputs= 0, */ | ||
2657 | .svhs = NO_SVHS, | ||
2658 | .gpiomask = 0x0, | ||
2659 | .muxsel = MUXSEL(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), | ||
2660 | .muxsel_hook = geovision_muxsel, | ||
2661 | .gpiomux = { 0 }, | ||
2662 | .no_msp34xx = 1, | ||
2663 | .pll = PLL_28, | ||
2664 | .tuner_type = TUNER_ABSENT, | ||
2665 | .tuner_addr = ADDR_UNSET, | ||
2666 | }, | ||
2667 | [BTTV_BOARD_KOZUMI_KTV_01C] = { | ||
2668 | /* Mauro Lacy <mauro@lacy.com.ar> | ||
2669 | * Based on MagicTV and Conceptronic CONTVFMi */ | ||
2670 | |||
2671 | .name = "Kozumi KTV-01C", | ||
2672 | .video_inputs = 3, | ||
2673 | /* .audio_inputs= 1, */ | ||
2674 | .svhs = 2, | ||
2675 | .gpiomask = 0x008007, | ||
2676 | .muxsel = MUXSEL(2, 3, 1, 1), | ||
2677 | .gpiomux = { 0, 1, 2, 2 }, /* CONTVFMi */ | ||
2678 | .gpiomute = 3, /* CONTVFMi */ | ||
2679 | .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, /* TCL MK3 */ | ||
2680 | .tuner_addr = ADDR_UNSET, | ||
2681 | .pll = PLL_28, | ||
2682 | .has_radio = 1, | ||
2683 | .has_remote = 1, | ||
2684 | }, | ||
2685 | [BTTV_BOARD_ENLTV_FM_2] = { | ||
2686 | /* Encore TV Tuner Pro ENL TV-FM-2 | ||
2687 | Mauro Carvalho Chehab <mchehab@infradead.org */ | ||
2688 | .name = "Encore ENL TV-FM-2", | ||
2689 | .video_inputs = 3, | ||
2690 | /* .audio_inputs= 1, */ | ||
2691 | .svhs = 2, | ||
2692 | /* bit 6 -> IR disabled | ||
2693 | bit 18/17 = 00 -> mute | ||
2694 | 01 -> enable external audio input | ||
2695 | 10 -> internal audio input (mono?) | ||
2696 | 11 -> internal audio input | ||
2697 | */ | ||
2698 | .gpiomask = 0x060040, | ||
2699 | .muxsel = MUXSEL(2, 3, 3), | ||
2700 | .gpiomux = { 0x60000, 0x60000, 0x20000, 0x20000 }, | ||
2701 | .gpiomute = 0, | ||
2702 | .tuner_type = TUNER_TCL_MF02GIP_5N, | ||
2703 | .tuner_addr = ADDR_UNSET, | ||
2704 | .pll = PLL_28, | ||
2705 | .has_radio = 1, | ||
2706 | .has_remote = 1, | ||
2707 | }, | ||
2708 | [BTTV_BOARD_VD012] = { | ||
2709 | /* D.Heer@Phytec.de */ | ||
2710 | .name = "PHYTEC VD-012 (bt878)", | ||
2711 | .video_inputs = 4, | ||
2712 | /* .audio_inputs= 0, */ | ||
2713 | .svhs = NO_SVHS, | ||
2714 | .gpiomask = 0x00, | ||
2715 | .muxsel = MUXSEL(0, 2, 3, 1), | ||
2716 | .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */ | ||
2717 | .pll = PLL_28, | ||
2718 | .tuner_type = TUNER_ABSENT, | ||
2719 | .tuner_addr = ADDR_UNSET, | ||
2720 | }, | ||
2721 | [BTTV_BOARD_VD012_X1] = { | ||
2722 | /* D.Heer@Phytec.de */ | ||
2723 | .name = "PHYTEC VD-012-X1 (bt878)", | ||
2724 | .video_inputs = 4, | ||
2725 | /* .audio_inputs= 0, */ | ||
2726 | .svhs = 3, | ||
2727 | .gpiomask = 0x00, | ||
2728 | .muxsel = MUXSEL(2, 3, 1), | ||
2729 | .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */ | ||
2730 | .pll = PLL_28, | ||
2731 | .tuner_type = TUNER_ABSENT, | ||
2732 | .tuner_addr = ADDR_UNSET, | ||
2733 | }, | ||
2734 | [BTTV_BOARD_VD012_X2] = { | ||
2735 | /* D.Heer@Phytec.de */ | ||
2736 | .name = "PHYTEC VD-012-X2 (bt878)", | ||
2737 | .video_inputs = 4, | ||
2738 | /* .audio_inputs= 0, */ | ||
2739 | .svhs = 3, | ||
2740 | .gpiomask = 0x00, | ||
2741 | .muxsel = MUXSEL(3, 2, 1), | ||
2742 | .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */ | ||
2743 | .pll = PLL_28, | ||
2744 | .tuner_type = TUNER_ABSENT, | ||
2745 | .tuner_addr = ADDR_UNSET, | ||
2746 | }, | ||
2747 | [BTTV_BOARD_GEOVISION_GV800S] = { | ||
2748 | /* Bruno Christo <bchristo@inf.ufsm.br> | ||
2749 | * | ||
2750 | * GeoVision GV-800(S) has 4 Conexant Fusion 878A: | ||
2751 | * 1 audio input per BT878A = 4 audio inputs | ||
2752 | * 4 video inputs per BT878A = 16 video inputs | ||
2753 | * This is the first BT878A chip of the GV-800(S). It's the | ||
2754 | * "master" chip and it controls the video inputs through an | ||
2755 | * analog multiplexer (a CD22M3494) via some GPIO pins. The | ||
2756 | * slaves should use card type 0x9e (following this one). | ||
2757 | * There is a EEPROM on the card which is currently not handled. | ||
2758 | * The audio input is not working yet. | ||
2759 | */ | ||
2760 | .name = "Geovision GV-800(S) (master)", | ||
2761 | .video_inputs = 4, | ||
2762 | /* .audio_inputs= 1, */ | ||
2763 | .tuner_type = TUNER_ABSENT, | ||
2764 | .tuner_addr = ADDR_UNSET, | ||
2765 | .svhs = NO_SVHS, | ||
2766 | .gpiomask = 0xf107f, | ||
2767 | .no_gpioirq = 1, | ||
2768 | .muxsel = MUXSEL(2, 2, 2, 2), | ||
2769 | .pll = PLL_28, | ||
2770 | .no_msp34xx = 1, | ||
2771 | .no_tda7432 = 1, | ||
2772 | .muxsel_hook = gv800s_muxsel, | ||
2773 | }, | ||
2774 | [BTTV_BOARD_GEOVISION_GV800S_SL] = { | ||
2775 | /* Bruno Christo <bchristo@inf.ufsm.br> | ||
2776 | * | ||
2777 | * GeoVision GV-800(S) has 4 Conexant Fusion 878A: | ||
2778 | * 1 audio input per BT878A = 4 audio inputs | ||
2779 | * 4 video inputs per BT878A = 16 video inputs | ||
2780 | * The 3 other BT878A chips are "slave" chips of the GV-800(S) | ||
2781 | * and should use this card type. | ||
2782 | * The audio input is not working yet. | ||
2783 | */ | ||
2784 | .name = "Geovision GV-800(S) (slave)", | ||
2785 | .video_inputs = 4, | ||
2786 | /* .audio_inputs= 1, */ | ||
2787 | .tuner_type = TUNER_ABSENT, | ||
2788 | .tuner_addr = ADDR_UNSET, | ||
2789 | .svhs = NO_SVHS, | ||
2790 | .gpiomask = 0x00, | ||
2791 | .no_gpioirq = 1, | ||
2792 | .muxsel = MUXSEL(2, 2, 2, 2), | ||
2793 | .pll = PLL_28, | ||
2794 | .no_msp34xx = 1, | ||
2795 | .no_tda7432 = 1, | ||
2796 | .muxsel_hook = gv800s_muxsel, | ||
2797 | }, | ||
2798 | [BTTV_BOARD_PV183] = { | ||
2799 | .name = "ProVideo PV183", /* 0x9f */ | ||
2800 | .video_inputs = 2, | ||
2801 | /* .audio_inputs= 0, */ | ||
2802 | .svhs = NO_SVHS, | ||
2803 | .gpiomask = 0, | ||
2804 | .muxsel = MUXSEL(2, 3), | ||
2805 | .gpiomux = { 0 }, | ||
2806 | .no_msp34xx = 1, | ||
2807 | .pll = PLL_28, | ||
2808 | .tuner_type = TUNER_ABSENT, | ||
2809 | .tuner_addr = ADDR_UNSET, | ||
2810 | }, | ||
2811 | [BTTV_BOARD_TVT_TD3116] = { | ||
2812 | .name = "Tongwei Video Technology TD-3116", | ||
2813 | .video_inputs = 16, | ||
2814 | .gpiomask = 0xc00ff, | ||
2815 | .muxsel = MUXSEL(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2), | ||
2816 | .muxsel_hook = td3116_muxsel, | ||
2817 | .svhs = NO_SVHS, | ||
2818 | .pll = PLL_28, | ||
2819 | .tuner_type = TUNER_ABSENT, | ||
2820 | }, | ||
2821 | [BTTV_BOARD_APOSONIC_WDVR] = { | ||
2822 | .name = "Aposonic W-DVR", | ||
2823 | .video_inputs = 4, | ||
2824 | .svhs = NO_SVHS, | ||
2825 | .muxsel = MUXSEL(2, 3, 1, 0), | ||
2826 | .tuner_type = TUNER_ABSENT, | ||
2827 | }, | ||
2828 | |||
2829 | }; | ||
2830 | |||
2831 | static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards); | ||
2832 | |||
2833 | /* ----------------------------------------------------------------------- */ | ||
2834 | |||
2835 | static unsigned char eeprom_data[256]; | ||
2836 | |||
2837 | /* | ||
2838 | * identify card | ||
2839 | */ | ||
2840 | void __devinit bttv_idcard(struct bttv *btv) | ||
2841 | { | ||
2842 | unsigned int gpiobits; | ||
2843 | int i,type; | ||
2844 | |||
2845 | /* read PCI subsystem ID */ | ||
2846 | btv->cardid = btv->c.pci->subsystem_device << 16; | ||
2847 | btv->cardid |= btv->c.pci->subsystem_vendor; | ||
2848 | |||
2849 | if (0 != btv->cardid && 0xffffffff != btv->cardid) { | ||
2850 | /* look for the card */ | ||
2851 | for (type = -1, i = 0; cards[i].id != 0; i++) | ||
2852 | if (cards[i].id == btv->cardid) | ||
2853 | type = i; | ||
2854 | |||
2855 | if (type != -1) { | ||
2856 | /* found it */ | ||
2857 | pr_info("%d: detected: %s [card=%d], PCI subsystem ID is %04x:%04x\n", | ||
2858 | btv->c.nr, cards[type].name, cards[type].cardnr, | ||
2859 | btv->cardid & 0xffff, | ||
2860 | (btv->cardid >> 16) & 0xffff); | ||
2861 | btv->c.type = cards[type].cardnr; | ||
2862 | } else { | ||
2863 | /* 404 */ | ||
2864 | pr_info("%d: subsystem: %04x:%04x (UNKNOWN)\n", | ||
2865 | btv->c.nr, btv->cardid & 0xffff, | ||
2866 | (btv->cardid >> 16) & 0xffff); | ||
2867 | pr_debug("please mail id, board name and the correct card= insmod option to linux-media@vger.kernel.org\n"); | ||
2868 | } | ||
2869 | } | ||
2870 | |||
2871 | /* let the user override the autodetected type */ | ||
2872 | if (card[btv->c.nr] < bttv_num_tvcards) | ||
2873 | btv->c.type=card[btv->c.nr]; | ||
2874 | |||
2875 | /* print which card config we are using */ | ||
2876 | pr_info("%d: using: %s [card=%d,%s]\n", | ||
2877 | btv->c.nr, bttv_tvcards[btv->c.type].name, btv->c.type, | ||
2878 | card[btv->c.nr] < bttv_num_tvcards | ||
2879 | ? "insmod option" : "autodetected"); | ||
2880 | |||
2881 | /* overwrite gpio stuff ?? */ | ||
2882 | if (UNSET == audioall && UNSET == audiomux[0]) | ||
2883 | return; | ||
2884 | |||
2885 | if (UNSET != audiomux[0]) { | ||
2886 | gpiobits = 0; | ||
2887 | for (i = 0; i < ARRAY_SIZE(bttv_tvcards->gpiomux); i++) { | ||
2888 | bttv_tvcards[btv->c.type].gpiomux[i] = audiomux[i]; | ||
2889 | gpiobits |= audiomux[i]; | ||
2890 | } | ||
2891 | } else { | ||
2892 | gpiobits = audioall; | ||
2893 | for (i = 0; i < ARRAY_SIZE(bttv_tvcards->gpiomux); i++) { | ||
2894 | bttv_tvcards[btv->c.type].gpiomux[i] = audioall; | ||
2895 | } | ||
2896 | } | ||
2897 | bttv_tvcards[btv->c.type].gpiomask = (UNSET != gpiomask) ? gpiomask : gpiobits; | ||
2898 | pr_info("%d: gpio config override: mask=0x%x, mux=", | ||
2899 | btv->c.nr, bttv_tvcards[btv->c.type].gpiomask); | ||
2900 | for (i = 0; i < ARRAY_SIZE(bttv_tvcards->gpiomux); i++) { | ||
2901 | pr_cont("%s0x%x", | ||
2902 | i ? "," : "", bttv_tvcards[btv->c.type].gpiomux[i]); | ||
2903 | } | ||
2904 | pr_cont("\n"); | ||
2905 | } | ||
2906 | |||
2907 | /* | ||
2908 | * (most) board specific initialisations goes here | ||
2909 | */ | ||
2910 | |||
2911 | /* Some Modular Technology cards have an eeprom, but no subsystem ID */ | ||
2912 | static void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256]) | ||
2913 | { | ||
2914 | int type = -1; | ||
2915 | |||
2916 | if (0 == strncmp(eeprom_data,"GET MM20xPCTV",13)) | ||
2917 | type = BTTV_BOARD_MODTEC_205; | ||
2918 | else if (0 == strncmp(eeprom_data+20,"Picolo",7)) | ||
2919 | type = BTTV_BOARD_EURESYS_PICOLO; | ||
2920 | else if (eeprom_data[0] == 0x84 && eeprom_data[2]== 0) | ||
2921 | type = BTTV_BOARD_HAUPPAUGE; /* old bt848 */ | ||
2922 | |||
2923 | if (-1 != type) { | ||
2924 | btv->c.type = type; | ||
2925 | pr_info("%d: detected by eeprom: %s [card=%d]\n", | ||
2926 | btv->c.nr, bttv_tvcards[btv->c.type].name, btv->c.type); | ||
2927 | } | ||
2928 | } | ||
2929 | |||
2930 | static void flyvideo_gpio(struct bttv *btv) | ||
2931 | { | ||
2932 | int gpio, has_remote, has_radio, is_capture_only; | ||
2933 | int is_lr90, has_tda9820_tda9821; | ||
2934 | int tuner_type = UNSET, ttype; | ||
2935 | |||
2936 | gpio_inout(0xffffff, 0); | ||
2937 | udelay(8); /* without this we would see the 0x1800 mask */ | ||
2938 | gpio = gpio_read(); | ||
2939 | /* FIXME: must restore OUR_EN ??? */ | ||
2940 | |||
2941 | /* all cards provide GPIO info, some have an additional eeprom | ||
2942 | * LR50: GPIO coding can be found lower right CP1 .. CP9 | ||
2943 | * CP9=GPIO23 .. CP1=GPIO15; when OPEN, the corresponding GPIO reads 1. | ||
2944 | * GPIO14-12: n.c. | ||
2945 | * LR90: GP9=GPIO23 .. GP1=GPIO15 (right above the bt878) | ||
2946 | |||
2947 | * lowest 3 bytes are remote control codes (no handshake needed) | ||
2948 | * xxxFFF: No remote control chip soldered | ||
2949 | * xxxF00(LR26/LR50), xxxFE0(LR90): Remote control chip (LVA001 or CF45) soldered | ||
2950 | * Note: Some bits are Audio_Mask ! | ||
2951 | */ | ||
2952 | ttype = (gpio & 0x0f0000) >> 16; | ||
2953 | switch (ttype) { | ||
2954 | case 0x0: | ||
2955 | tuner_type = 2; /* NTSC, e.g. TPI8NSR11P */ | ||
2956 | break; | ||
2957 | case 0x2: | ||
2958 | tuner_type = 39; /* LG NTSC (newer TAPC series) TAPC-H701P */ | ||
2959 | break; | ||
2960 | case 0x4: | ||
2961 | tuner_type = 5; /* Philips PAL TPI8PSB02P, TPI8PSB12P, TPI8PSB12D or FI1216, FM1216 */ | ||
2962 | break; | ||
2963 | case 0x6: | ||
2964 | tuner_type = 37; /* LG PAL (newer TAPC series) TAPC-G702P */ | ||
2965 | break; | ||
2966 | case 0xC: | ||
2967 | tuner_type = 3; /* Philips SECAM(+PAL) FQ1216ME or FI1216MF */ | ||
2968 | break; | ||
2969 | default: | ||
2970 | pr_info("%d: FlyVideo_gpio: unknown tuner type\n", btv->c.nr); | ||
2971 | break; | ||
2972 | } | ||
2973 | |||
2974 | has_remote = gpio & 0x800000; | ||
2975 | has_radio = gpio & 0x400000; | ||
2976 | /* unknown 0x200000; | ||
2977 | * unknown2 0x100000; */ | ||
2978 | is_capture_only = !(gpio & 0x008000); /* GPIO15 */ | ||
2979 | has_tda9820_tda9821 = !(gpio & 0x004000); | ||
2980 | is_lr90 = !(gpio & 0x002000); /* else LR26/LR50 (LR38/LR51 f. capture only) */ | ||
2981 | /* | ||
2982 | * gpio & 0x001000 output bit for audio routing */ | ||
2983 | |||
2984 | if (is_capture_only) | ||
2985 | tuner_type = TUNER_ABSENT; /* No tuner present */ | ||
2986 | |||
2987 | pr_info("%d: FlyVideo Radio=%s RemoteControl=%s Tuner=%d gpio=0x%06x\n", | ||
2988 | btv->c.nr, has_radio ? "yes" : "no", | ||
2989 | has_remote ? "yes" : "no", tuner_type, gpio); | ||
2990 | pr_info("%d: FlyVideo LR90=%s tda9821/tda9820=%s capture_only=%s\n", | ||
2991 | btv->c.nr, is_lr90 ? "yes" : "no", | ||
2992 | has_tda9820_tda9821 ? "yes" : "no", | ||
2993 | is_capture_only ? "yes" : "no"); | ||
2994 | |||
2995 | if (tuner_type != UNSET) /* only set if known tuner autodetected, else let insmod option through */ | ||
2996 | btv->tuner_type = tuner_type; | ||
2997 | btv->has_radio = has_radio; | ||
2998 | |||
2999 | /* LR90 Audio Routing is done by 2 hef4052, so Audio_Mask has 4 bits: 0x001c80 | ||
3000 | * LR26/LR50 only has 1 hef4052, Audio_Mask 0x000c00 | ||
3001 | * Audio options: from tuner, from tda9821/tda9821(mono,stereo,sap), from tda9874, ext., mute */ | ||
3002 | if (has_tda9820_tda9821) | ||
3003 | btv->audio_mode_gpio = lt9415_audio; | ||
3004 | /* todo: if(has_tda9874) btv->audio_mode_gpio = fv2000s_audio; */ | ||
3005 | } | ||
3006 | |||
3007 | static int miro_tunermap[] = { 0,6,2,3, 4,5,6,0, 3,0,4,5, 5,2,16,1, | ||
3008 | 14,2,17,1, 4,1,4,3, 1,2,16,1, 4,4,4,4 }; | ||
3009 | static int miro_fmtuner[] = { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1, | ||
3010 | 1,1,1,1, 1,1,1,0, 0,0,0,0, 0,1,0,0 }; | ||
3011 | |||
3012 | static void miro_pinnacle_gpio(struct bttv *btv) | ||
3013 | { | ||
3014 | int id,msp,gpio; | ||
3015 | char *info; | ||
3016 | |||
3017 | gpio_inout(0xffffff, 0); | ||
3018 | gpio = gpio_read(); | ||
3019 | id = ((gpio>>10) & 63) -1; | ||
3020 | msp = bttv_I2CRead(btv, I2C_ADDR_MSP3400, "MSP34xx"); | ||
3021 | if (id < 32) { | ||
3022 | btv->tuner_type = miro_tunermap[id]; | ||
3023 | if (0 == (gpio & 0x20)) { | ||
3024 | btv->has_radio = 1; | ||
3025 | if (!miro_fmtuner[id]) { | ||
3026 | btv->has_matchbox = 1; | ||
3027 | btv->mbox_we = (1<<6); | ||
3028 | btv->mbox_most = (1<<7); | ||
3029 | btv->mbox_clk = (1<<8); | ||
3030 | btv->mbox_data = (1<<9); | ||
3031 | btv->mbox_mask = (1<<6)|(1<<7)|(1<<8)|(1<<9); | ||
3032 | } | ||
3033 | } else { | ||
3034 | btv->has_radio = 0; | ||
3035 | } | ||
3036 | if (-1 != msp) { | ||
3037 | if (btv->c.type == BTTV_BOARD_MIRO) | ||
3038 | btv->c.type = BTTV_BOARD_MIROPRO; | ||
3039 | if (btv->c.type == BTTV_BOARD_PINNACLE) | ||
3040 | btv->c.type = BTTV_BOARD_PINNACLEPRO; | ||
3041 | } | ||
3042 | pr_info("%d: miro: id=%d tuner=%d radio=%s stereo=%s\n", | ||
3043 | btv->c.nr, id+1, btv->tuner_type, | ||
3044 | !btv->has_radio ? "no" : | ||
3045 | (btv->has_matchbox ? "matchbox" : "fmtuner"), | ||
3046 | (-1 == msp) ? "no" : "yes"); | ||
3047 | } else { | ||
3048 | /* new cards with microtune tuner */ | ||
3049 | id = 63 - id; | ||
3050 | btv->has_radio = 0; | ||
3051 | switch (id) { | ||
3052 | case 1: | ||
3053 | info = "PAL / mono"; | ||
3054 | btv->tda9887_conf = TDA9887_INTERCARRIER; | ||
3055 | break; | ||
3056 | case 2: | ||
3057 | info = "PAL+SECAM / stereo"; | ||
3058 | btv->has_radio = 1; | ||
3059 | btv->tda9887_conf = TDA9887_QSS; | ||
3060 | break; | ||
3061 | case 3: | ||
3062 | info = "NTSC / stereo"; | ||
3063 | btv->has_radio = 1; | ||
3064 | btv->tda9887_conf = TDA9887_QSS; | ||
3065 | break; | ||
3066 | case 4: | ||
3067 | info = "PAL+SECAM / mono"; | ||
3068 | btv->tda9887_conf = TDA9887_QSS; | ||
3069 | break; | ||
3070 | case 5: | ||
3071 | info = "NTSC / mono"; | ||
3072 | btv->tda9887_conf = TDA9887_INTERCARRIER; | ||
3073 | break; | ||
3074 | case 6: | ||
3075 | info = "NTSC / stereo"; | ||
3076 | btv->tda9887_conf = TDA9887_INTERCARRIER; | ||
3077 | break; | ||
3078 | case 7: | ||
3079 | info = "PAL / stereo"; | ||
3080 | btv->tda9887_conf = TDA9887_INTERCARRIER; | ||
3081 | break; | ||
3082 | default: | ||
3083 | info = "oops: unknown card"; | ||
3084 | break; | ||
3085 | } | ||
3086 | if (-1 != msp) | ||
3087 | btv->c.type = BTTV_BOARD_PINNACLEPRO; | ||
3088 | pr_info("%d: pinnacle/mt: id=%d info=\"%s\" radio=%s\n", | ||
3089 | btv->c.nr, id, info, btv->has_radio ? "yes" : "no"); | ||
3090 | btv->tuner_type = TUNER_MT2032; | ||
3091 | } | ||
3092 | } | ||
3093 | |||
3094 | /* GPIO21 L: Buffer aktiv, H: Buffer inaktiv */ | ||
3095 | #define LM1882_SYNC_DRIVE 0x200000L | ||
3096 | |||
3097 | static void init_ids_eagle(struct bttv *btv) | ||
3098 | { | ||
3099 | gpio_inout(0xffffff,0xFFFF37); | ||
3100 | gpio_write(0x200020); | ||
3101 | |||
3102 | /* flash strobe inverter ?! */ | ||
3103 | gpio_write(0x200024); | ||
3104 | |||
3105 | /* switch sync drive off */ | ||
3106 | gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE); | ||
3107 | |||
3108 | /* set BT848 muxel to 2 */ | ||
3109 | btaor((2)<<5, ~(2<<5), BT848_IFORM); | ||
3110 | } | ||
3111 | |||
3112 | /* Muxsel helper for the IDS Eagle. | ||
3113 | * the eagles does not use the standard muxsel-bits but | ||
3114 | * has its own multiplexer */ | ||
3115 | static void eagle_muxsel(struct bttv *btv, unsigned int input) | ||
3116 | { | ||
3117 | gpio_bits(3, input & 3); | ||
3118 | |||
3119 | /* composite */ | ||
3120 | /* set chroma ADC to sleep */ | ||
3121 | btor(BT848_ADC_C_SLEEP, BT848_ADC); | ||
3122 | /* set to composite video */ | ||
3123 | btand(~BT848_CONTROL_COMP, BT848_E_CONTROL); | ||
3124 | btand(~BT848_CONTROL_COMP, BT848_O_CONTROL); | ||
3125 | |||
3126 | /* switch sync drive off */ | ||
3127 | gpio_bits(LM1882_SYNC_DRIVE,LM1882_SYNC_DRIVE); | ||
3128 | } | ||
3129 | |||
3130 | static void gvc1100_muxsel(struct bttv *btv, unsigned int input) | ||
3131 | { | ||
3132 | static const int masks[] = {0x30, 0x01, 0x12, 0x23}; | ||
3133 | gpio_write(masks[input%4]); | ||
3134 | } | ||
3135 | |||
3136 | /* LMLBT4x initialization - to allow access to GPIO bits for sensors input and | ||
3137 | alarms output | ||
3138 | |||
3139 | GPIObit | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | | ||
3140 | assignment | TI | O3|INx| O2| O1|IN4|IN3|IN2|IN1| | | | ||
3141 | |||
3142 | IN - sensor inputs, INx - sensor inputs and TI XORed together | ||
3143 | O1,O2,O3 - alarm outputs (relays) | ||
3144 | |||
3145 | OUT ENABLE 1 1 0 . 1 1 0 0 . 0 0 0 0 = 0x6C0 | ||
3146 | |||
3147 | */ | ||
3148 | |||
3149 | static void init_lmlbt4x(struct bttv *btv) | ||
3150 | { | ||
3151 | pr_debug("LMLBT4x init\n"); | ||
3152 | btwrite(0x000000, BT848_GPIO_REG_INP); | ||
3153 | gpio_inout(0xffffff, 0x0006C0); | ||
3154 | gpio_write(0x000000); | ||
3155 | } | ||
3156 | |||
3157 | static void sigmaSQ_muxsel(struct bttv *btv, unsigned int input) | ||
3158 | { | ||
3159 | unsigned int inmux = input % 8; | ||
3160 | gpio_inout( 0xf, 0xf ); | ||
3161 | gpio_bits( 0xf, inmux ); | ||
3162 | } | ||
3163 | |||
3164 | static void sigmaSLC_muxsel(struct bttv *btv, unsigned int input) | ||
3165 | { | ||
3166 | unsigned int inmux = input % 4; | ||
3167 | gpio_inout( 3<<9, 3<<9 ); | ||
3168 | gpio_bits( 3<<9, inmux<<9 ); | ||
3169 | } | ||
3170 | |||
3171 | static void geovision_muxsel(struct bttv *btv, unsigned int input) | ||
3172 | { | ||
3173 | unsigned int inmux = input % 16; | ||
3174 | gpio_inout(0xf, 0xf); | ||
3175 | gpio_bits(0xf, inmux); | ||
3176 | } | ||
3177 | |||
3178 | /* | ||
3179 | * The TD3116 has 2 74HC4051 muxes wired to the MUX0 input of a bt878. | ||
3180 | * The first 74HC4051 has the lower 8 inputs, the second one the higher 8. | ||
3181 | * The muxes are controlled via a 74HC373 latch which is connected to | ||
3182 | * GPIOs 0-7. GPIO 18 is connected to the LE signal of the latch. | ||
3183 | * Q0 of the latch is connected to the Enable (~E) input of the first | ||
3184 | * 74HC4051. Q1 - Q3 are connected to S0 - S2 of the same 74HC4051. | ||
3185 | * Q4 - Q7 are connected to the second 74HC4051 in the same way. | ||
3186 | */ | ||
3187 | |||
3188 | static void td3116_latch_value(struct bttv *btv, u32 value) | ||
3189 | { | ||
3190 | gpio_bits((1<<18) | 0xff, value); | ||
3191 | gpio_bits((1<<18) | 0xff, (1<<18) | value); | ||
3192 | udelay(1); | ||
3193 | gpio_bits((1<<18) | 0xff, value); | ||
3194 | } | ||
3195 | |||
3196 | static void td3116_muxsel(struct bttv *btv, unsigned int input) | ||
3197 | { | ||
3198 | u32 value; | ||
3199 | u32 highbit; | ||
3200 | |||
3201 | highbit = (input & 0x8) >> 3 ; | ||
3202 | |||
3203 | /* Disable outputs and set value in the mux */ | ||
3204 | value = 0x11; /* Disable outputs */ | ||
3205 | value |= ((input & 0x7) << 1) << (4 * highbit); | ||
3206 | td3116_latch_value(btv, value); | ||
3207 | |||
3208 | /* Enable the correct output */ | ||
3209 | value &= ~0x11; | ||
3210 | value |= ((highbit ^ 0x1) << 4) | highbit; | ||
3211 | td3116_latch_value(btv, value); | ||
3212 | } | ||
3213 | |||
3214 | /* ----------------------------------------------------------------------- */ | ||
3215 | |||
3216 | static void bttv_reset_audio(struct bttv *btv) | ||
3217 | { | ||
3218 | /* | ||
3219 | * BT878A has a audio-reset register. | ||
3220 | * 1. This register is an audio reset function but it is in | ||
3221 | * function-0 (video capture) address space. | ||
3222 | * 2. It is enough to do this once per power-up of the card. | ||
3223 | * 3. There is a typo in the Conexant doc -- it is not at | ||
3224 | * 0x5B, but at 0x058. (B is an odd-number, obviously a typo!). | ||
3225 | * --//Shrikumar 030609 | ||
3226 | */ | ||
3227 | if (btv->id != 878) | ||
3228 | return; | ||
3229 | |||
3230 | if (bttv_debug) | ||
3231 | pr_debug("%d: BT878A ARESET\n", btv->c.nr); | ||
3232 | btwrite((1<<7), 0x058); | ||
3233 | udelay(10); | ||
3234 | btwrite( 0, 0x058); | ||
3235 | } | ||
3236 | |||
3237 | /* initialization part one -- before registering i2c bus */ | ||
3238 | void __devinit bttv_init_card1(struct bttv *btv) | ||
3239 | { | ||
3240 | switch (btv->c.type) { | ||
3241 | case BTTV_BOARD_HAUPPAUGE: | ||
3242 | case BTTV_BOARD_HAUPPAUGE878: | ||
3243 | boot_msp34xx(btv,5); | ||
3244 | break; | ||
3245 | case BTTV_BOARD_VOODOOTV_200: | ||
3246 | case BTTV_BOARD_VOODOOTV_FM: | ||
3247 | boot_msp34xx(btv,20); | ||
3248 | break; | ||
3249 | case BTTV_BOARD_AVERMEDIA98: | ||
3250 | boot_msp34xx(btv,11); | ||
3251 | break; | ||
3252 | case BTTV_BOARD_HAUPPAUGEPVR: | ||
3253 | pvr_boot(btv); | ||
3254 | break; | ||
3255 | case BTTV_BOARD_TWINHAN_DST: | ||
3256 | case BTTV_BOARD_AVDVBT_771: | ||
3257 | case BTTV_BOARD_PINNACLESAT: | ||
3258 | btv->use_i2c_hw = 1; | ||
3259 | break; | ||
3260 | case BTTV_BOARD_ADLINK_RTV24: | ||
3261 | init_RTV24( btv ); | ||
3262 | break; | ||
3263 | |||
3264 | } | ||
3265 | if (!bttv_tvcards[btv->c.type].has_dvb) | ||
3266 | bttv_reset_audio(btv); | ||
3267 | } | ||
3268 | |||
3269 | /* initialization part two -- after registering i2c bus */ | ||
3270 | void __devinit bttv_init_card2(struct bttv *btv) | ||
3271 | { | ||
3272 | btv->tuner_type = UNSET; | ||
3273 | |||
3274 | if (BTTV_BOARD_UNKNOWN == btv->c.type) { | ||
3275 | bttv_readee(btv,eeprom_data,0xa0); | ||
3276 | identify_by_eeprom(btv,eeprom_data); | ||
3277 | } | ||
3278 | |||
3279 | switch (btv->c.type) { | ||
3280 | case BTTV_BOARD_MIRO: | ||
3281 | case BTTV_BOARD_MIROPRO: | ||
3282 | case BTTV_BOARD_PINNACLE: | ||
3283 | case BTTV_BOARD_PINNACLEPRO: | ||
3284 | /* miro/pinnacle */ | ||
3285 | miro_pinnacle_gpio(btv); | ||
3286 | break; | ||
3287 | case BTTV_BOARD_FLYVIDEO_98: | ||
3288 | case BTTV_BOARD_MAXI: | ||
3289 | case BTTV_BOARD_LIFE_FLYKIT: | ||
3290 | case BTTV_BOARD_FLYVIDEO: | ||
3291 | case BTTV_BOARD_TYPHOON_TVIEW: | ||
3292 | case BTTV_BOARD_CHRONOS_VS2: | ||
3293 | case BTTV_BOARD_FLYVIDEO_98FM: | ||
3294 | case BTTV_BOARD_FLYVIDEO2000: | ||
3295 | case BTTV_BOARD_FLYVIDEO98EZ: | ||
3296 | case BTTV_BOARD_CONFERENCETV: | ||
3297 | case BTTV_BOARD_LIFETEC_9415: | ||
3298 | flyvideo_gpio(btv); | ||
3299 | break; | ||
3300 | case BTTV_BOARD_HAUPPAUGE: | ||
3301 | case BTTV_BOARD_HAUPPAUGE878: | ||
3302 | case BTTV_BOARD_HAUPPAUGEPVR: | ||
3303 | /* pick up some config infos from the eeprom */ | ||
3304 | bttv_readee(btv,eeprom_data,0xa0); | ||
3305 | hauppauge_eeprom(btv); | ||
3306 | break; | ||
3307 | case BTTV_BOARD_AVERMEDIA98: | ||
3308 | case BTTV_BOARD_AVPHONE98: | ||
3309 | bttv_readee(btv,eeprom_data,0xa0); | ||
3310 | avermedia_eeprom(btv); | ||
3311 | break; | ||
3312 | case BTTV_BOARD_PXC200: | ||
3313 | init_PXC200(btv); | ||
3314 | break; | ||
3315 | case BTTV_BOARD_PICOLO_TETRA_CHIP: | ||
3316 | picolo_tetra_init(btv); | ||
3317 | break; | ||
3318 | case BTTV_BOARD_VHX: | ||
3319 | btv->has_radio = 1; | ||
3320 | btv->has_matchbox = 1; | ||
3321 | btv->mbox_we = 0x20; | ||
3322 | btv->mbox_most = 0; | ||
3323 | btv->mbox_clk = 0x08; | ||
3324 | btv->mbox_data = 0x10; | ||
3325 | btv->mbox_mask = 0x38; | ||
3326 | break; | ||
3327 | case BTTV_BOARD_VOBIS_BOOSTAR: | ||
3328 | case BTTV_BOARD_TERRATV: | ||
3329 | terratec_active_radio_upgrade(btv); | ||
3330 | break; | ||
3331 | case BTTV_BOARD_MAGICTVIEW061: | ||
3332 | if (btv->cardid == 0x3002144f) { | ||
3333 | btv->has_radio=1; | ||
3334 | pr_info("%d: radio detected by subsystem id (CPH05x)\n", | ||
3335 | btv->c.nr); | ||
3336 | } | ||
3337 | break; | ||
3338 | case BTTV_BOARD_STB2: | ||
3339 | if (btv->cardid == 0x3060121a) { | ||
3340 | /* Fix up entry for 3DFX VoodooTV 100, | ||
3341 | which is an OEM STB card variant. */ | ||
3342 | btv->has_radio=0; | ||
3343 | btv->tuner_type=TUNER_TEMIC_NTSC; | ||
3344 | } | ||
3345 | break; | ||
3346 | case BTTV_BOARD_OSPREY1x0: | ||
3347 | case BTTV_BOARD_OSPREY1x0_848: | ||
3348 | case BTTV_BOARD_OSPREY101_848: | ||
3349 | case BTTV_BOARD_OSPREY1x1: | ||
3350 | case BTTV_BOARD_OSPREY1x1_SVID: | ||
3351 | case BTTV_BOARD_OSPREY2xx: | ||
3352 | case BTTV_BOARD_OSPREY2x0_SVID: | ||
3353 | case BTTV_BOARD_OSPREY2x0: | ||
3354 | case BTTV_BOARD_OSPREY440: | ||
3355 | case BTTV_BOARD_OSPREY500: | ||
3356 | case BTTV_BOARD_OSPREY540: | ||
3357 | case BTTV_BOARD_OSPREY2000: | ||
3358 | bttv_readee(btv,eeprom_data,0xa0); | ||
3359 | osprey_eeprom(btv, eeprom_data); | ||
3360 | break; | ||
3361 | case BTTV_BOARD_IDS_EAGLE: | ||
3362 | init_ids_eagle(btv); | ||
3363 | break; | ||
3364 | case BTTV_BOARD_MODTEC_205: | ||
3365 | bttv_readee(btv,eeprom_data,0xa0); | ||
3366 | modtec_eeprom(btv); | ||
3367 | break; | ||
3368 | case BTTV_BOARD_LMLBT4: | ||
3369 | init_lmlbt4x(btv); | ||
3370 | break; | ||
3371 | case BTTV_BOARD_TIBET_CS16: | ||
3372 | tibetCS16_init(btv); | ||
3373 | break; | ||
3374 | case BTTV_BOARD_KODICOM_4400R: | ||
3375 | kodicom4400r_init(btv); | ||
3376 | break; | ||
3377 | case BTTV_BOARD_GEOVISION_GV800S: | ||
3378 | gv800s_init(btv); | ||
3379 | break; | ||
3380 | } | ||
3381 | |||
3382 | /* pll configuration */ | ||
3383 | if (!(btv->id==848 && btv->revision==0x11)) { | ||
3384 | /* defaults from card list */ | ||
3385 | if (PLL_28 == bttv_tvcards[btv->c.type].pll) { | ||
3386 | btv->pll.pll_ifreq=28636363; | ||
3387 | btv->pll.pll_crystal=BT848_IFORM_XT0; | ||
3388 | } | ||
3389 | if (PLL_35 == bttv_tvcards[btv->c.type].pll) { | ||
3390 | btv->pll.pll_ifreq=35468950; | ||
3391 | btv->pll.pll_crystal=BT848_IFORM_XT1; | ||
3392 | } | ||
3393 | /* insmod options can override */ | ||
3394 | switch (pll[btv->c.nr]) { | ||
3395 | case 0: /* none */ | ||
3396 | btv->pll.pll_crystal = 0; | ||
3397 | btv->pll.pll_ifreq = 0; | ||
3398 | btv->pll.pll_ofreq = 0; | ||
3399 | break; | ||
3400 | case 1: /* 28 MHz */ | ||
3401 | case 28: | ||
3402 | btv->pll.pll_ifreq = 28636363; | ||
3403 | btv->pll.pll_ofreq = 0; | ||
3404 | btv->pll.pll_crystal = BT848_IFORM_XT0; | ||
3405 | break; | ||
3406 | case 2: /* 35 MHz */ | ||
3407 | case 35: | ||
3408 | btv->pll.pll_ifreq = 35468950; | ||
3409 | btv->pll.pll_ofreq = 0; | ||
3410 | btv->pll.pll_crystal = BT848_IFORM_XT1; | ||
3411 | break; | ||
3412 | } | ||
3413 | } | ||
3414 | btv->pll.pll_current = -1; | ||
3415 | |||
3416 | /* tuner configuration (from card list / autodetect / insmod option) */ | ||
3417 | if (UNSET != bttv_tvcards[btv->c.type].tuner_type) | ||
3418 | if (UNSET == btv->tuner_type) | ||
3419 | btv->tuner_type = bttv_tvcards[btv->c.type].tuner_type; | ||
3420 | if (UNSET != tuner[btv->c.nr]) | ||
3421 | btv->tuner_type = tuner[btv->c.nr]; | ||
3422 | |||
3423 | if (btv->tuner_type == TUNER_ABSENT) | ||
3424 | pr_info("%d: tuner absent\n", btv->c.nr); | ||
3425 | else if (btv->tuner_type == UNSET) | ||
3426 | pr_warn("%d: tuner type unset\n", btv->c.nr); | ||
3427 | else | ||
3428 | pr_info("%d: tuner type=%d\n", btv->c.nr, btv->tuner_type); | ||
3429 | |||
3430 | if (autoload != UNSET) { | ||
3431 | pr_warn("%d: the autoload option is obsolete\n", btv->c.nr); | ||
3432 | pr_warn("%d: use option msp3400, tda7432 or tvaudio to override which audio module should be used\n", | ||
3433 | btv->c.nr); | ||
3434 | } | ||
3435 | |||
3436 | if (UNSET == btv->tuner_type) | ||
3437 | btv->tuner_type = TUNER_ABSENT; | ||
3438 | |||
3439 | btv->dig = bttv_tvcards[btv->c.type].has_dig_in ? | ||
3440 | bttv_tvcards[btv->c.type].video_inputs - 1 : UNSET; | ||
3441 | btv->svhs = bttv_tvcards[btv->c.type].svhs == NO_SVHS ? | ||
3442 | UNSET : bttv_tvcards[btv->c.type].svhs; | ||
3443 | if (svhs[btv->c.nr] != UNSET) | ||
3444 | btv->svhs = svhs[btv->c.nr]; | ||
3445 | if (remote[btv->c.nr] != UNSET) | ||
3446 | btv->has_remote = remote[btv->c.nr]; | ||
3447 | |||
3448 | if (bttv_tvcards[btv->c.type].has_radio) | ||
3449 | btv->has_radio = 1; | ||
3450 | if (bttv_tvcards[btv->c.type].has_remote) | ||
3451 | btv->has_remote = 1; | ||
3452 | if (!bttv_tvcards[btv->c.type].no_gpioirq) | ||
3453 | btv->gpioirq = 1; | ||
3454 | if (bttv_tvcards[btv->c.type].volume_gpio) | ||
3455 | btv->volume_gpio = bttv_tvcards[btv->c.type].volume_gpio; | ||
3456 | if (bttv_tvcards[btv->c.type].audio_mode_gpio) | ||
3457 | btv->audio_mode_gpio = bttv_tvcards[btv->c.type].audio_mode_gpio; | ||
3458 | |||
3459 | if (btv->tuner_type == TUNER_ABSENT) | ||
3460 | return; /* no tuner or related drivers to load */ | ||
3461 | |||
3462 | if (btv->has_saa6588 || saa6588[btv->c.nr]) { | ||
3463 | /* Probe for RDS receiver chip */ | ||
3464 | static const unsigned short addrs[] = { | ||
3465 | 0x20 >> 1, | ||
3466 | 0x22 >> 1, | ||
3467 | I2C_CLIENT_END | ||
3468 | }; | ||
3469 | struct v4l2_subdev *sd; | ||
3470 | |||
3471 | sd = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, | ||
3472 | &btv->c.i2c_adap, "saa6588", 0, addrs); | ||
3473 | btv->has_saa6588 = (sd != NULL); | ||
3474 | } | ||
3475 | |||
3476 | /* try to detect audio/fader chips */ | ||
3477 | |||
3478 | /* First check if the user specified the audio chip via a module | ||
3479 | option. */ | ||
3480 | |||
3481 | switch (audiodev[btv->c.nr]) { | ||
3482 | case -1: | ||
3483 | return; /* do not load any audio module */ | ||
3484 | |||
3485 | case 0: /* autodetect */ | ||
3486 | break; | ||
3487 | |||
3488 | case 1: { | ||
3489 | /* The user specified that we should probe for msp3400 */ | ||
3490 | static const unsigned short addrs[] = { | ||
3491 | I2C_ADDR_MSP3400 >> 1, | ||
3492 | I2C_ADDR_MSP3400_ALT >> 1, | ||
3493 | I2C_CLIENT_END | ||
3494 | }; | ||
3495 | |||
3496 | btv->sd_msp34xx = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, | ||
3497 | &btv->c.i2c_adap, "msp3400", 0, addrs); | ||
3498 | if (btv->sd_msp34xx) | ||
3499 | return; | ||
3500 | goto no_audio; | ||
3501 | } | ||
3502 | |||
3503 | case 2: { | ||
3504 | /* The user specified that we should probe for tda7432 */ | ||
3505 | static const unsigned short addrs[] = { | ||
3506 | I2C_ADDR_TDA7432 >> 1, | ||
3507 | I2C_CLIENT_END | ||
3508 | }; | ||
3509 | |||
3510 | if (v4l2_i2c_new_subdev(&btv->c.v4l2_dev, | ||
3511 | &btv->c.i2c_adap, "tda7432", 0, addrs)) | ||
3512 | return; | ||
3513 | goto no_audio; | ||
3514 | } | ||
3515 | |||
3516 | case 3: { | ||
3517 | /* The user specified that we should probe for tvaudio */ | ||
3518 | btv->sd_tvaudio = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, | ||
3519 | &btv->c.i2c_adap, "tvaudio", 0, tvaudio_addrs()); | ||
3520 | if (btv->sd_tvaudio) | ||
3521 | return; | ||
3522 | goto no_audio; | ||
3523 | } | ||
3524 | |||
3525 | default: | ||
3526 | pr_warn("%d: unknown audiodev value!\n", btv->c.nr); | ||
3527 | return; | ||
3528 | } | ||
3529 | |||
3530 | /* There were no overrides, so now we try to discover this through the | ||
3531 | card definition */ | ||
3532 | |||
3533 | /* probe for msp3400 first: this driver can detect whether or not | ||
3534 | it really is a msp3400, so it will return NULL when the device | ||
3535 | found is really something else (e.g. a tea6300). */ | ||
3536 | if (!bttv_tvcards[btv->c.type].no_msp34xx) { | ||
3537 | btv->sd_msp34xx = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, | ||
3538 | &btv->c.i2c_adap, "msp3400", | ||
3539 | 0, I2C_ADDRS(I2C_ADDR_MSP3400 >> 1)); | ||
3540 | } else if (bttv_tvcards[btv->c.type].msp34xx_alt) { | ||
3541 | btv->sd_msp34xx = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, | ||
3542 | &btv->c.i2c_adap, "msp3400", | ||
3543 | 0, I2C_ADDRS(I2C_ADDR_MSP3400_ALT >> 1)); | ||
3544 | } | ||
3545 | |||
3546 | /* If we found a msp34xx, then we're done. */ | ||
3547 | if (btv->sd_msp34xx) | ||
3548 | return; | ||
3549 | |||
3550 | /* it might also be a tda7432. */ | ||
3551 | if (!bttv_tvcards[btv->c.type].no_tda7432) { | ||
3552 | static const unsigned short addrs[] = { | ||
3553 | I2C_ADDR_TDA7432 >> 1, | ||
3554 | I2C_CLIENT_END | ||
3555 | }; | ||
3556 | |||
3557 | if (v4l2_i2c_new_subdev(&btv->c.v4l2_dev, | ||
3558 | &btv->c.i2c_adap, "tda7432", 0, addrs)) | ||
3559 | return; | ||
3560 | } | ||
3561 | |||
3562 | /* Now see if we can find one of the tvaudio devices. */ | ||
3563 | btv->sd_tvaudio = v4l2_i2c_new_subdev(&btv->c.v4l2_dev, | ||
3564 | &btv->c.i2c_adap, "tvaudio", 0, tvaudio_addrs()); | ||
3565 | if (btv->sd_tvaudio) | ||
3566 | return; | ||
3567 | |||
3568 | no_audio: | ||
3569 | pr_warn("%d: audio absent, no audio device found!\n", btv->c.nr); | ||
3570 | } | ||
3571 | |||
3572 | |||
3573 | /* initialize the tuner */ | ||
3574 | void __devinit bttv_init_tuner(struct bttv *btv) | ||
3575 | { | ||
3576 | int addr = ADDR_UNSET; | ||
3577 | |||
3578 | if (ADDR_UNSET != bttv_tvcards[btv->c.type].tuner_addr) | ||
3579 | addr = bttv_tvcards[btv->c.type].tuner_addr; | ||
3580 | |||
3581 | if (btv->tuner_type != TUNER_ABSENT) { | ||
3582 | struct tuner_setup tun_setup; | ||
3583 | |||
3584 | /* Load tuner module before issuing tuner config call! */ | ||
3585 | if (btv->has_radio) | ||
3586 | v4l2_i2c_new_subdev(&btv->c.v4l2_dev, | ||
3587 | &btv->c.i2c_adap, "tuner", | ||
3588 | 0, v4l2_i2c_tuner_addrs(ADDRS_RADIO)); | ||
3589 | v4l2_i2c_new_subdev(&btv->c.v4l2_dev, | ||
3590 | &btv->c.i2c_adap, "tuner", | ||
3591 | 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | ||
3592 | v4l2_i2c_new_subdev(&btv->c.v4l2_dev, | ||
3593 | &btv->c.i2c_adap, "tuner", | ||
3594 | 0, v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD)); | ||
3595 | |||
3596 | tun_setup.mode_mask = T_ANALOG_TV; | ||
3597 | tun_setup.type = btv->tuner_type; | ||
3598 | tun_setup.addr = addr; | ||
3599 | |||
3600 | if (btv->has_radio) | ||
3601 | tun_setup.mode_mask |= T_RADIO; | ||
3602 | |||
3603 | bttv_call_all(btv, tuner, s_type_addr, &tun_setup); | ||
3604 | } | ||
3605 | |||
3606 | if (btv->tda9887_conf) { | ||
3607 | struct v4l2_priv_tun_config tda9887_cfg; | ||
3608 | |||
3609 | tda9887_cfg.tuner = TUNER_TDA9887; | ||
3610 | tda9887_cfg.priv = &btv->tda9887_conf; | ||
3611 | |||
3612 | bttv_call_all(btv, tuner, s_config, &tda9887_cfg); | ||
3613 | } | ||
3614 | } | ||
3615 | |||
3616 | /* ----------------------------------------------------------------------- */ | ||
3617 | |||
3618 | static void modtec_eeprom(struct bttv *btv) | ||
3619 | { | ||
3620 | if( strncmp(&(eeprom_data[0x1e]),"Temic 4066 FY5",14) ==0) { | ||
3621 | btv->tuner_type=TUNER_TEMIC_4066FY5_PAL_I; | ||
3622 | pr_info("%d: Modtec: Tuner autodetected by eeprom: %s\n", | ||
3623 | btv->c.nr, &eeprom_data[0x1e]); | ||
3624 | } else if (strncmp(&(eeprom_data[0x1e]),"Alps TSBB5",10) ==0) { | ||
3625 | btv->tuner_type=TUNER_ALPS_TSBB5_PAL_I; | ||
3626 | pr_info("%d: Modtec: Tuner autodetected by eeprom: %s\n", | ||
3627 | btv->c.nr, &eeprom_data[0x1e]); | ||
3628 | } else if (strncmp(&(eeprom_data[0x1e]),"Philips FM1246",14) ==0) { | ||
3629 | btv->tuner_type=TUNER_PHILIPS_NTSC; | ||
3630 | pr_info("%d: Modtec: Tuner autodetected by eeprom: %s\n", | ||
3631 | btv->c.nr, &eeprom_data[0x1e]); | ||
3632 | } else { | ||
3633 | pr_info("%d: Modtec: Unknown TunerString: %s\n", | ||
3634 | btv->c.nr, &eeprom_data[0x1e]); | ||
3635 | } | ||
3636 | } | ||
3637 | |||
3638 | static void __devinit hauppauge_eeprom(struct bttv *btv) | ||
3639 | { | ||
3640 | struct tveeprom tv; | ||
3641 | |||
3642 | tveeprom_hauppauge_analog(&btv->i2c_client, &tv, eeprom_data); | ||
3643 | btv->tuner_type = tv.tuner_type; | ||
3644 | btv->has_radio = tv.has_radio; | ||
3645 | |||
3646 | pr_info("%d: Hauppauge eeprom indicates model#%d\n", | ||
3647 | btv->c.nr, tv.model); | ||
3648 | |||
3649 | /* | ||
3650 | * Some of the 878 boards have duplicate PCI IDs. Switch the board | ||
3651 | * type based on model #. | ||
3652 | */ | ||
3653 | if(tv.model == 64900) { | ||
3654 | pr_info("%d: Switching board type from %s to %s\n", | ||
3655 | btv->c.nr, | ||
3656 | bttv_tvcards[btv->c.type].name, | ||
3657 | bttv_tvcards[BTTV_BOARD_HAUPPAUGE_IMPACTVCB].name); | ||
3658 | btv->c.type = BTTV_BOARD_HAUPPAUGE_IMPACTVCB; | ||
3659 | } | ||
3660 | |||
3661 | /* The 61334 needs the msp3410 to do the radio demod to get sound */ | ||
3662 | if (tv.model == 61334) | ||
3663 | btv->radio_uses_msp_demodulator = 1; | ||
3664 | } | ||
3665 | |||
3666 | static int terratec_active_radio_upgrade(struct bttv *btv) | ||
3667 | { | ||
3668 | int freq; | ||
3669 | |||
3670 | btv->has_radio = 1; | ||
3671 | btv->has_matchbox = 1; | ||
3672 | btv->mbox_we = 0x10; | ||
3673 | btv->mbox_most = 0x20; | ||
3674 | btv->mbox_clk = 0x08; | ||
3675 | btv->mbox_data = 0x04; | ||
3676 | btv->mbox_mask = 0x3c; | ||
3677 | |||
3678 | btv->mbox_iow = 1 << 8; | ||
3679 | btv->mbox_ior = 1 << 9; | ||
3680 | btv->mbox_csel = 1 << 10; | ||
3681 | |||
3682 | freq=88000/62.5; | ||
3683 | tea5757_write(btv, 5 * freq + 0x358); /* write 0x1ed8 */ | ||
3684 | if (0x1ed8 == tea5757_read(btv)) { | ||
3685 | pr_info("%d: Terratec Active Radio Upgrade found\n", btv->c.nr); | ||
3686 | btv->has_radio = 1; | ||
3687 | btv->has_saa6588 = 1; | ||
3688 | btv->has_matchbox = 1; | ||
3689 | } else { | ||
3690 | btv->has_radio = 0; | ||
3691 | btv->has_matchbox = 0; | ||
3692 | } | ||
3693 | return 0; | ||
3694 | } | ||
3695 | |||
3696 | |||
3697 | /* ----------------------------------------------------------------------- */ | ||
3698 | |||
3699 | /* | ||
3700 | * minimal bootstrap for the WinTV/PVR -- upload altera firmware. | ||
3701 | * | ||
3702 | * The hcwamc.rbf firmware file is on the Hauppauge driver CD. Have | ||
3703 | * a look at Pvr/pvr45xxx.EXE (self-extracting zip archive, can be | ||
3704 | * unpacked with unzip). | ||
3705 | */ | ||
3706 | #define PVR_GPIO_DELAY 10 | ||
3707 | |||
3708 | #define BTTV_ALT_DATA 0x000001 | ||
3709 | #define BTTV_ALT_DCLK 0x100000 | ||
3710 | #define BTTV_ALT_NCONFIG 0x800000 | ||
3711 | |||
3712 | static int __devinit pvr_altera_load(struct bttv *btv, const u8 *micro, | ||
3713 | u32 microlen) | ||
3714 | { | ||
3715 | u32 n; | ||
3716 | u8 bits; | ||
3717 | int i; | ||
3718 | |||
3719 | gpio_inout(0xffffff,BTTV_ALT_DATA|BTTV_ALT_DCLK|BTTV_ALT_NCONFIG); | ||
3720 | gpio_write(0); | ||
3721 | udelay(PVR_GPIO_DELAY); | ||
3722 | |||
3723 | gpio_write(BTTV_ALT_NCONFIG); | ||
3724 | udelay(PVR_GPIO_DELAY); | ||
3725 | |||
3726 | for (n = 0; n < microlen; n++) { | ||
3727 | bits = micro[n]; | ||
3728 | for (i = 0 ; i < 8 ; i++) { | ||
3729 | gpio_bits(BTTV_ALT_DCLK,0); | ||
3730 | if (bits & 0x01) | ||
3731 | gpio_bits(BTTV_ALT_DATA,BTTV_ALT_DATA); | ||
3732 | else | ||
3733 | gpio_bits(BTTV_ALT_DATA,0); | ||
3734 | gpio_bits(BTTV_ALT_DCLK,BTTV_ALT_DCLK); | ||
3735 | bits >>= 1; | ||
3736 | } | ||
3737 | } | ||
3738 | gpio_bits(BTTV_ALT_DCLK,0); | ||
3739 | udelay(PVR_GPIO_DELAY); | ||
3740 | |||
3741 | /* begin Altera init loop (Not necessary,but doesn't hurt) */ | ||
3742 | for (i = 0 ; i < 30 ; i++) { | ||
3743 | gpio_bits(BTTV_ALT_DCLK,0); | ||
3744 | gpio_bits(BTTV_ALT_DCLK,BTTV_ALT_DCLK); | ||
3745 | } | ||
3746 | gpio_bits(BTTV_ALT_DCLK,0); | ||
3747 | return 0; | ||
3748 | } | ||
3749 | |||
3750 | static int __devinit pvr_boot(struct bttv *btv) | ||
3751 | { | ||
3752 | const struct firmware *fw_entry; | ||
3753 | int rc; | ||
3754 | |||
3755 | rc = request_firmware(&fw_entry, "hcwamc.rbf", &btv->c.pci->dev); | ||
3756 | if (rc != 0) { | ||
3757 | pr_warn("%d: no altera firmware [via hotplug]\n", btv->c.nr); | ||
3758 | return rc; | ||
3759 | } | ||
3760 | rc = pvr_altera_load(btv, fw_entry->data, fw_entry->size); | ||
3761 | pr_info("%d: altera firmware upload %s\n", | ||
3762 | btv->c.nr, (rc < 0) ? "failed" : "ok"); | ||
3763 | release_firmware(fw_entry); | ||
3764 | return rc; | ||
3765 | } | ||
3766 | |||
3767 | /* ----------------------------------------------------------------------- */ | ||
3768 | /* some osprey specific stuff */ | ||
3769 | |||
3770 | static void __devinit osprey_eeprom(struct bttv *btv, const u8 ee[256]) | ||
3771 | { | ||
3772 | int i; | ||
3773 | u32 serial = 0; | ||
3774 | int cardid = -1; | ||
3775 | |||
3776 | /* This code will nevery actually get called in this case.... */ | ||
3777 | if (btv->c.type == BTTV_BOARD_UNKNOWN) { | ||
3778 | /* this might be an antique... check for MMAC label in eeprom */ | ||
3779 | if (!strncmp(ee, "MMAC", 4)) { | ||
3780 | u8 checksum = 0; | ||
3781 | for (i = 0; i < 21; i++) | ||
3782 | checksum += ee[i]; | ||
3783 | if (checksum != ee[21]) | ||
3784 | return; | ||
3785 | cardid = BTTV_BOARD_OSPREY1x0_848; | ||
3786 | for (i = 12; i < 21; i++) | ||
3787 | serial *= 10, serial += ee[i] - '0'; | ||
3788 | } | ||
3789 | } else { | ||
3790 | unsigned short type; | ||
3791 | |||
3792 | for (i = 4*16; i < 8*16; i += 16) { | ||
3793 | u16 checksum = ip_compute_csum(ee + i, 16); | ||
3794 | |||
3795 | if ((checksum&0xff) + (checksum>>8) == 0xff) | ||
3796 | break; | ||
3797 | } | ||
3798 | if (i >= 8*16) | ||
3799 | return; | ||
3800 | ee += i; | ||
3801 | |||
3802 | /* found a valid descriptor */ | ||
3803 | type = get_unaligned_be16((__be16 *)(ee+4)); | ||
3804 | |||
3805 | switch(type) { | ||
3806 | /* 848 based */ | ||
3807 | case 0x0004: | ||
3808 | cardid = BTTV_BOARD_OSPREY1x0_848; | ||
3809 | break; | ||
3810 | case 0x0005: | ||
3811 | cardid = BTTV_BOARD_OSPREY101_848; | ||
3812 | break; | ||
3813 | |||
3814 | /* 878 based */ | ||
3815 | case 0x0012: | ||
3816 | case 0x0013: | ||
3817 | cardid = BTTV_BOARD_OSPREY1x0; | ||
3818 | break; | ||
3819 | case 0x0014: | ||
3820 | case 0x0015: | ||
3821 | cardid = BTTV_BOARD_OSPREY1x1; | ||
3822 | break; | ||
3823 | case 0x0016: | ||
3824 | case 0x0017: | ||
3825 | case 0x0020: | ||
3826 | cardid = BTTV_BOARD_OSPREY1x1_SVID; | ||
3827 | break; | ||
3828 | case 0x0018: | ||
3829 | case 0x0019: | ||
3830 | case 0x001E: | ||
3831 | case 0x001F: | ||
3832 | cardid = BTTV_BOARD_OSPREY2xx; | ||
3833 | break; | ||
3834 | case 0x001A: | ||
3835 | case 0x001B: | ||
3836 | cardid = BTTV_BOARD_OSPREY2x0_SVID; | ||
3837 | break; | ||
3838 | case 0x0040: | ||
3839 | cardid = BTTV_BOARD_OSPREY500; | ||
3840 | break; | ||
3841 | case 0x0050: | ||
3842 | case 0x0056: | ||
3843 | cardid = BTTV_BOARD_OSPREY540; | ||
3844 | /* bttv_osprey_540_init(btv); */ | ||
3845 | break; | ||
3846 | case 0x0060: | ||
3847 | case 0x0070: | ||
3848 | case 0x00A0: | ||
3849 | cardid = BTTV_BOARD_OSPREY2x0; | ||
3850 | /* enable output on select control lines */ | ||
3851 | gpio_inout(0xffffff,0x000303); | ||
3852 | break; | ||
3853 | case 0x00D8: | ||
3854 | cardid = BTTV_BOARD_OSPREY440; | ||
3855 | break; | ||
3856 | default: | ||
3857 | /* unknown...leave generic, but get serial # */ | ||
3858 | pr_info("%d: osprey eeprom: unknown card type 0x%04x\n", | ||
3859 | btv->c.nr, type); | ||
3860 | break; | ||
3861 | } | ||
3862 | serial = get_unaligned_be32((__be32 *)(ee+6)); | ||
3863 | } | ||
3864 | |||
3865 | pr_info("%d: osprey eeprom: card=%d '%s' serial=%u\n", | ||
3866 | btv->c.nr, cardid, | ||
3867 | cardid > 0 ? bttv_tvcards[cardid].name : "Unknown", serial); | ||
3868 | |||
3869 | if (cardid<0 || btv->c.type == cardid) | ||
3870 | return; | ||
3871 | |||
3872 | /* card type isn't set correctly */ | ||
3873 | if (card[btv->c.nr] < bttv_num_tvcards) { | ||
3874 | pr_warn("%d: osprey eeprom: Not overriding user specified card type\n", | ||
3875 | btv->c.nr); | ||
3876 | } else { | ||
3877 | pr_info("%d: osprey eeprom: Changing card type from %d to %d\n", | ||
3878 | btv->c.nr, btv->c.type, cardid); | ||
3879 | btv->c.type = cardid; | ||
3880 | } | ||
3881 | } | ||
3882 | |||
3883 | /* ----------------------------------------------------------------------- */ | ||
3884 | /* AVermedia specific stuff, from bktr_card.c */ | ||
3885 | |||
3886 | static int tuner_0_table[] = { | ||
3887 | TUNER_PHILIPS_NTSC, TUNER_PHILIPS_PAL /* PAL-BG*/, | ||
3888 | TUNER_PHILIPS_PAL, TUNER_PHILIPS_PAL /* PAL-I*/, | ||
3889 | TUNER_PHILIPS_PAL, TUNER_PHILIPS_PAL, | ||
3890 | TUNER_PHILIPS_SECAM, TUNER_PHILIPS_SECAM, | ||
3891 | TUNER_PHILIPS_SECAM, TUNER_PHILIPS_PAL, | ||
3892 | TUNER_PHILIPS_FM1216ME_MK3 }; | ||
3893 | |||
3894 | static int tuner_1_table[] = { | ||
3895 | TUNER_TEMIC_NTSC, TUNER_TEMIC_PAL, | ||
3896 | TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, | ||
3897 | TUNER_TEMIC_PAL, TUNER_TEMIC_PAL, | ||
3898 | TUNER_TEMIC_4012FY5, TUNER_TEMIC_4012FY5, /* TUNER_TEMIC_SECAM */ | ||
3899 | TUNER_TEMIC_4012FY5, TUNER_TEMIC_PAL}; | ||
3900 | |||
3901 | static void __devinit avermedia_eeprom(struct bttv *btv) | ||
3902 | { | ||
3903 | int tuner_make, tuner_tv_fm, tuner_format, tuner_type = 0; | ||
3904 | |||
3905 | tuner_make = (eeprom_data[0x41] & 0x7); | ||
3906 | tuner_tv_fm = (eeprom_data[0x41] & 0x18) >> 3; | ||
3907 | tuner_format = (eeprom_data[0x42] & 0xf0) >> 4; | ||
3908 | btv->has_remote = (eeprom_data[0x42] & 0x01); | ||
3909 | |||
3910 | if (tuner_make == 0 || tuner_make == 2) | ||
3911 | if (tuner_format <= 0x0a) | ||
3912 | tuner_type = tuner_0_table[tuner_format]; | ||
3913 | if (tuner_make == 1) | ||
3914 | if (tuner_format <= 9) | ||
3915 | tuner_type = tuner_1_table[tuner_format]; | ||
3916 | |||
3917 | if (tuner_make == 4) | ||
3918 | if (tuner_format == 0x09) | ||
3919 | tuner_type = TUNER_LG_NTSC_NEW_TAPC; /* TAPC-G702P */ | ||
3920 | |||
3921 | pr_info("%d: Avermedia eeprom[0x%02x%02x]: tuner=", | ||
3922 | btv->c.nr, eeprom_data[0x41], eeprom_data[0x42]); | ||
3923 | if (tuner_type) { | ||
3924 | btv->tuner_type = tuner_type; | ||
3925 | pr_cont("%d", tuner_type); | ||
3926 | } else | ||
3927 | pr_cont("Unknown type"); | ||
3928 | pr_cont(" radio:%s remote control:%s\n", | ||
3929 | tuner_tv_fm ? "yes" : "no", | ||
3930 | btv->has_remote ? "yes" : "no"); | ||
3931 | } | ||
3932 | |||
3933 | /* | ||
3934 | * For Voodoo TV/FM and Voodoo 200. These cards' tuners use a TDA9880 | ||
3935 | * analog demod, which is not I2C controlled like the newer and more common | ||
3936 | * TDA9887 series. Instead is has two tri-state input pins, S0 and S1, | ||
3937 | * that control the IF for the video and audio. Apparently, bttv GPIO | ||
3938 | * 0x10000 is connected to S0. S0 low selects a 38.9 MHz VIF for B/G/D/K/I | ||
3939 | * (i.e., PAL) while high selects 45.75 MHz for M/N (i.e., NTSC). | ||
3940 | */ | ||
3941 | u32 bttv_tda9880_setnorm(struct bttv *btv, u32 gpiobits) | ||
3942 | { | ||
3943 | |||
3944 | if (btv->audio == TVAUDIO_INPUT_TUNER) { | ||
3945 | if (bttv_tvnorms[btv->tvnorm].v4l2_id & V4L2_STD_MN) | ||
3946 | gpiobits |= 0x10000; | ||
3947 | else | ||
3948 | gpiobits &= ~0x10000; | ||
3949 | } | ||
3950 | |||
3951 | gpio_bits(bttv_tvcards[btv->c.type].gpiomask, gpiobits); | ||
3952 | return gpiobits; | ||
3953 | } | ||
3954 | |||
3955 | |||
3956 | /* | ||
3957 | * reset/enable the MSP on some Hauppauge cards | ||
3958 | * Thanks to Kyösti Mälkki (kmalkki@cc.hut.fi)! | ||
3959 | * | ||
3960 | * Hauppauge: pin 5 | ||
3961 | * Voodoo: pin 20 | ||
3962 | */ | ||
3963 | static void __devinit boot_msp34xx(struct bttv *btv, int pin) | ||
3964 | { | ||
3965 | int mask = (1 << pin); | ||
3966 | |||
3967 | gpio_inout(mask,mask); | ||
3968 | gpio_bits(mask,0); | ||
3969 | mdelay(2); | ||
3970 | udelay(500); | ||
3971 | gpio_bits(mask,mask); | ||
3972 | |||
3973 | if (bttv_gpio) | ||
3974 | bttv_gpio_tracking(btv,"msp34xx"); | ||
3975 | if (bttv_verbose) | ||
3976 | pr_info("%d: Hauppauge/Voodoo msp34xx: reset line init [%d]\n", | ||
3977 | btv->c.nr, pin); | ||
3978 | } | ||
3979 | |||
3980 | /* ----------------------------------------------------------------------- */ | ||
3981 | /* Imagenation L-Model PXC200 Framegrabber */ | ||
3982 | /* This is basically the same procedure as | ||
3983 | * used by Alessandro Rubini in his pxc200 | ||
3984 | * driver, but using BTTV functions */ | ||
3985 | |||
3986 | static void __devinit init_PXC200(struct bttv *btv) | ||
3987 | { | ||
3988 | static int vals[] __devinitdata = { 0x08, 0x09, 0x0a, 0x0b, 0x0d, 0x0d, | ||
3989 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, | ||
3990 | 0x00 }; | ||
3991 | unsigned int i; | ||
3992 | int tmp; | ||
3993 | u32 val; | ||
3994 | |||
3995 | /* Initialise GPIO-connevted stuff */ | ||
3996 | gpio_inout(0xffffff, (1<<13)); | ||
3997 | gpio_write(0); | ||
3998 | udelay(3); | ||
3999 | gpio_write(1<<13); | ||
4000 | /* GPIO inputs are pulled up, so no need to drive | ||
4001 | * reset pin any longer */ | ||
4002 | gpio_bits(0xffffff, 0); | ||
4003 | if (bttv_gpio) | ||
4004 | bttv_gpio_tracking(btv,"pxc200"); | ||
4005 | |||
4006 | /* we could/should try and reset/control the AD pots? but | ||
4007 | right now we simply turned off the crushing. Without | ||
4008 | this the AGC drifts drifts | ||
4009 | remember the EN is reverse logic --> | ||
4010 | setting BT848_ADC_AGC_EN disable the AGC | ||
4011 | tboult@eecs.lehigh.edu | ||
4012 | */ | ||
4013 | |||
4014 | btwrite(BT848_ADC_RESERVED|BT848_ADC_AGC_EN, BT848_ADC); | ||
4015 | |||
4016 | /* Initialise MAX517 DAC */ | ||
4017 | pr_info("Setting DAC reference voltage level ...\n"); | ||
4018 | bttv_I2CWrite(btv,0x5E,0,0x80,1); | ||
4019 | |||
4020 | /* Initialise 12C508 PIC */ | ||
4021 | /* The I2CWrite and I2CRead commmands are actually to the | ||
4022 | * same chips - but the R/W bit is included in the address | ||
4023 | * argument so the numbers are different */ | ||
4024 | |||
4025 | |||
4026 | pr_info("Initialising 12C508 PIC chip ...\n"); | ||
4027 | |||
4028 | /* First of all, enable the clock line. This is used in the PXC200-F */ | ||
4029 | val = btread(BT848_GPIO_DMA_CTL); | ||
4030 | val |= BT848_GPIO_DMA_CTL_GPCLKMODE; | ||
4031 | btwrite(val, BT848_GPIO_DMA_CTL); | ||
4032 | |||
4033 | /* Then, push to 0 the reset pin long enough to reset the * | ||
4034 | * device same as above for the reset line, but not the same | ||
4035 | * value sent to the GPIO-connected stuff | ||
4036 | * which one is the good one? */ | ||
4037 | gpio_inout(0xffffff,(1<<2)); | ||
4038 | gpio_write(0); | ||
4039 | udelay(10); | ||
4040 | gpio_write(1<<2); | ||
4041 | |||
4042 | for (i = 0; i < ARRAY_SIZE(vals); i++) { | ||
4043 | tmp=bttv_I2CWrite(btv,0x1E,0,vals[i],1); | ||
4044 | if (tmp != -1) { | ||
4045 | pr_info("I2C Write(%2.2x) = %i\nI2C Read () = %2.2x\n\n", | ||
4046 | vals[i],tmp,bttv_I2CRead(btv,0x1F,NULL)); | ||
4047 | } | ||
4048 | } | ||
4049 | |||
4050 | pr_info("PXC200 Initialised\n"); | ||
4051 | } | ||
4052 | |||
4053 | |||
4054 | |||
4055 | /* ----------------------------------------------------------------------- */ | ||
4056 | /* | ||
4057 | * The Adlink RTV-24 (aka Angelo) has some special initialisation to unlock | ||
4058 | * it. This apparently involves the following procedure for each 878 chip: | ||
4059 | * | ||
4060 | * 1) write 0x00C3FEFF to the GPIO_OUT_EN register | ||
4061 | * | ||
4062 | * 2) write to GPIO_DATA | ||
4063 | * - 0x0E | ||
4064 | * - sleep 1ms | ||
4065 | * - 0x10 + 0x0E | ||
4066 | * - sleep 10ms | ||
4067 | * - 0x0E | ||
4068 | * read from GPIO_DATA into buf (uint_32) | ||
4069 | * - if ( data>>18 & 0x01 != 0) || ( buf>>19 & 0x01 != 1 ) | ||
4070 | * error. ERROR_CPLD_Check_Failed stop. | ||
4071 | * | ||
4072 | * 3) write to GPIO_DATA | ||
4073 | * - write 0x4400 + 0x0E | ||
4074 | * - sleep 10ms | ||
4075 | * - write 0x4410 + 0x0E | ||
4076 | * - sleep 1ms | ||
4077 | * - write 0x0E | ||
4078 | * read from GPIO_DATA into buf (uint_32) | ||
4079 | * - if ( buf>>18 & 0x01 ) || ( buf>>19 & 0x01 != 0 ) | ||
4080 | * error. ERROR_CPLD_Check_Failed. | ||
4081 | */ | ||
4082 | /* ----------------------------------------------------------------------- */ | ||
4083 | static void | ||
4084 | init_RTV24 (struct bttv *btv) | ||
4085 | { | ||
4086 | uint32_t dataRead = 0; | ||
4087 | long watchdog_value = 0x0E; | ||
4088 | |||
4089 | pr_info("%d: Adlink RTV-24 initialisation in progress ...\n", | ||
4090 | btv->c.nr); | ||
4091 | |||
4092 | btwrite (0x00c3feff, BT848_GPIO_OUT_EN); | ||
4093 | |||
4094 | btwrite (0 + watchdog_value, BT848_GPIO_DATA); | ||
4095 | msleep (1); | ||
4096 | btwrite (0x10 + watchdog_value, BT848_GPIO_DATA); | ||
4097 | msleep (10); | ||
4098 | btwrite (0 + watchdog_value, BT848_GPIO_DATA); | ||
4099 | |||
4100 | dataRead = btread (BT848_GPIO_DATA); | ||
4101 | |||
4102 | if ((((dataRead >> 18) & 0x01) != 0) || (((dataRead >> 19) & 0x01) != 1)) { | ||
4103 | pr_info("%d: Adlink RTV-24 initialisation(1) ERROR_CPLD_Check_Failed (read %d)\n", | ||
4104 | btv->c.nr, dataRead); | ||
4105 | } | ||
4106 | |||
4107 | btwrite (0x4400 + watchdog_value, BT848_GPIO_DATA); | ||
4108 | msleep (10); | ||
4109 | btwrite (0x4410 + watchdog_value, BT848_GPIO_DATA); | ||
4110 | msleep (1); | ||
4111 | btwrite (watchdog_value, BT848_GPIO_DATA); | ||
4112 | msleep (1); | ||
4113 | dataRead = btread (BT848_GPIO_DATA); | ||
4114 | |||
4115 | if ((((dataRead >> 18) & 0x01) != 0) || (((dataRead >> 19) & 0x01) != 0)) { | ||
4116 | pr_info("%d: Adlink RTV-24 initialisation(2) ERROR_CPLD_Check_Failed (read %d)\n", | ||
4117 | btv->c.nr, dataRead); | ||
4118 | |||
4119 | return; | ||
4120 | } | ||
4121 | |||
4122 | pr_info("%d: Adlink RTV-24 initialisation complete\n", btv->c.nr); | ||
4123 | } | ||
4124 | |||
4125 | |||
4126 | |||
4127 | /* ----------------------------------------------------------------------- */ | ||
4128 | /* Miro Pro radio stuff -- the tea5757 is connected to some GPIO ports */ | ||
4129 | /* | ||
4130 | * Copyright (c) 1999 Csaba Halasz <qgehali@uni-miskolc.hu> | ||
4131 | * This code is placed under the terms of the GNU General Public License | ||
4132 | * | ||
4133 | * Brutally hacked by Dan Sheridan <dan.sheridan@contact.org.uk> djs52 8/3/00 | ||
4134 | */ | ||
4135 | |||
4136 | static void bus_low(struct bttv *btv, int bit) | ||
4137 | { | ||
4138 | if (btv->mbox_ior) { | ||
4139 | gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel, | ||
4140 | btv->mbox_ior | btv->mbox_iow | btv->mbox_csel); | ||
4141 | udelay(5); | ||
4142 | } | ||
4143 | |||
4144 | gpio_bits(bit,0); | ||
4145 | udelay(5); | ||
4146 | |||
4147 | if (btv->mbox_ior) { | ||
4148 | gpio_bits(btv->mbox_iow | btv->mbox_csel, 0); | ||
4149 | udelay(5); | ||
4150 | } | ||
4151 | } | ||
4152 | |||
4153 | static void bus_high(struct bttv *btv, int bit) | ||
4154 | { | ||
4155 | if (btv->mbox_ior) { | ||
4156 | gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel, | ||
4157 | btv->mbox_ior | btv->mbox_iow | btv->mbox_csel); | ||
4158 | udelay(5); | ||
4159 | } | ||
4160 | |||
4161 | gpio_bits(bit,bit); | ||
4162 | udelay(5); | ||
4163 | |||
4164 | if (btv->mbox_ior) { | ||
4165 | gpio_bits(btv->mbox_iow | btv->mbox_csel, 0); | ||
4166 | udelay(5); | ||
4167 | } | ||
4168 | } | ||
4169 | |||
4170 | static int bus_in(struct bttv *btv, int bit) | ||
4171 | { | ||
4172 | if (btv->mbox_ior) { | ||
4173 | gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel, | ||
4174 | btv->mbox_ior | btv->mbox_iow | btv->mbox_csel); | ||
4175 | udelay(5); | ||
4176 | |||
4177 | gpio_bits(btv->mbox_iow | btv->mbox_csel, 0); | ||
4178 | udelay(5); | ||
4179 | } | ||
4180 | return gpio_read() & (bit); | ||
4181 | } | ||
4182 | |||
4183 | /* TEA5757 register bits */ | ||
4184 | #define TEA_FREQ 0:14 | ||
4185 | #define TEA_BUFFER 15:15 | ||
4186 | |||
4187 | #define TEA_SIGNAL_STRENGTH 16:17 | ||
4188 | |||
4189 | #define TEA_PORT1 18:18 | ||
4190 | #define TEA_PORT0 19:19 | ||
4191 | |||
4192 | #define TEA_BAND 20:21 | ||
4193 | #define TEA_BAND_FM 0 | ||
4194 | #define TEA_BAND_MW 1 | ||
4195 | #define TEA_BAND_LW 2 | ||
4196 | #define TEA_BAND_SW 3 | ||
4197 | |||
4198 | #define TEA_MONO 22:22 | ||
4199 | #define TEA_ALLOW_STEREO 0 | ||
4200 | #define TEA_FORCE_MONO 1 | ||
4201 | |||
4202 | #define TEA_SEARCH_DIRECTION 23:23 | ||
4203 | #define TEA_SEARCH_DOWN 0 | ||
4204 | #define TEA_SEARCH_UP 1 | ||
4205 | |||
4206 | #define TEA_STATUS 24:24 | ||
4207 | #define TEA_STATUS_TUNED 0 | ||
4208 | #define TEA_STATUS_SEARCHING 1 | ||
4209 | |||
4210 | /* Low-level stuff */ | ||
4211 | static int tea5757_read(struct bttv *btv) | ||
4212 | { | ||
4213 | unsigned long timeout; | ||
4214 | int value = 0; | ||
4215 | int i; | ||
4216 | |||
4217 | /* better safe than sorry */ | ||
4218 | gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we); | ||
4219 | |||
4220 | if (btv->mbox_ior) { | ||
4221 | gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel, | ||
4222 | btv->mbox_ior | btv->mbox_iow | btv->mbox_csel); | ||
4223 | udelay(5); | ||
4224 | } | ||
4225 | |||
4226 | if (bttv_gpio) | ||
4227 | bttv_gpio_tracking(btv,"tea5757 read"); | ||
4228 | |||
4229 | bus_low(btv,btv->mbox_we); | ||
4230 | bus_low(btv,btv->mbox_clk); | ||
4231 | |||
4232 | udelay(10); | ||
4233 | timeout= jiffies + msecs_to_jiffies(1000); | ||
4234 | |||
4235 | /* wait for DATA line to go low; error if it doesn't */ | ||
4236 | while (bus_in(btv,btv->mbox_data) && time_before(jiffies, timeout)) | ||
4237 | schedule(); | ||
4238 | if (bus_in(btv,btv->mbox_data)) { | ||
4239 | pr_warn("%d: tea5757: read timeout\n", btv->c.nr); | ||
4240 | return -1; | ||
4241 | } | ||
4242 | |||
4243 | dprintk("%d: tea5757:", btv->c.nr); | ||
4244 | for (i = 0; i < 24; i++) { | ||
4245 | udelay(5); | ||
4246 | bus_high(btv,btv->mbox_clk); | ||
4247 | udelay(5); | ||
4248 | dprintk_cont("%c", | ||
4249 | bus_in(btv, btv->mbox_most) == 0 ? 'T' : '-'); | ||
4250 | bus_low(btv,btv->mbox_clk); | ||
4251 | value <<= 1; | ||
4252 | value |= (bus_in(btv,btv->mbox_data) == 0)?0:1; /* MSB first */ | ||
4253 | dprintk_cont("%c", | ||
4254 | bus_in(btv, btv->mbox_most) == 0 ? 'S' : 'M'); | ||
4255 | } | ||
4256 | dprintk_cont("\n"); | ||
4257 | dprintk("%d: tea5757: read 0x%X\n", btv->c.nr, value); | ||
4258 | return value; | ||
4259 | } | ||
4260 | |||
4261 | static int tea5757_write(struct bttv *btv, int value) | ||
4262 | { | ||
4263 | int i; | ||
4264 | int reg = value; | ||
4265 | |||
4266 | gpio_inout(btv->mbox_mask, btv->mbox_clk | btv->mbox_we | btv->mbox_data); | ||
4267 | |||
4268 | if (btv->mbox_ior) { | ||
4269 | gpio_bits(btv->mbox_ior | btv->mbox_iow | btv->mbox_csel, | ||
4270 | btv->mbox_ior | btv->mbox_iow | btv->mbox_csel); | ||
4271 | udelay(5); | ||
4272 | } | ||
4273 | if (bttv_gpio) | ||
4274 | bttv_gpio_tracking(btv,"tea5757 write"); | ||
4275 | |||
4276 | dprintk("%d: tea5757: write 0x%X\n", btv->c.nr, value); | ||
4277 | bus_low(btv,btv->mbox_clk); | ||
4278 | bus_high(btv,btv->mbox_we); | ||
4279 | for (i = 0; i < 25; i++) { | ||
4280 | if (reg & 0x1000000) | ||
4281 | bus_high(btv,btv->mbox_data); | ||
4282 | else | ||
4283 | bus_low(btv,btv->mbox_data); | ||
4284 | reg <<= 1; | ||
4285 | bus_high(btv,btv->mbox_clk); | ||
4286 | udelay(10); | ||
4287 | bus_low(btv,btv->mbox_clk); | ||
4288 | udelay(10); | ||
4289 | } | ||
4290 | bus_low(btv,btv->mbox_we); /* unmute !!! */ | ||
4291 | return 0; | ||
4292 | } | ||
4293 | |||
4294 | void tea5757_set_freq(struct bttv *btv, unsigned short freq) | ||
4295 | { | ||
4296 | dprintk("tea5757_set_freq %d\n",freq); | ||
4297 | tea5757_write(btv, 5 * freq + 0x358); /* add 10.7MHz (see docs) */ | ||
4298 | } | ||
4299 | |||
4300 | /* RemoteVision MX (rv605) muxsel helper [Miguel Freitas] | ||
4301 | * | ||
4302 | * This is needed because rv605 don't use a normal multiplex, but a crosspoint | ||
4303 | * switch instead (CD22M3494E). This IC can have multiple active connections | ||
4304 | * between Xn (input) and Yn (output) pins. We need to clear any existing | ||
4305 | * connection prior to establish a new one, pulsing the STROBE pin. | ||
4306 | * | ||
4307 | * The board hardwire Y0 (xpoint) to MUX1 and MUXOUT to Yin. | ||
4308 | * GPIO pins are wired as: | ||
4309 | * GPIO[0:3] - AX[0:3] (xpoint) - P1[0:3] (microcontroller) | ||
4310 | * GPIO[4:6] - AY[0:2] (xpoint) - P1[4:6] (microcontroller) | ||
4311 | * GPIO[7] - DATA (xpoint) - P1[7] (microcontroller) | ||
4312 | * GPIO[8] - - P3[5] (microcontroller) | ||
4313 | * GPIO[9] - RESET (xpoint) - P3[6] (microcontroller) | ||
4314 | * GPIO[10] - STROBE (xpoint) - P3[7] (microcontroller) | ||
4315 | * GPINTR - - P3[4] (microcontroller) | ||
4316 | * | ||
4317 | * The microcontroller is a 80C32 like. It should be possible to change xpoint | ||
4318 | * configuration either directly (as we are doing) or using the microcontroller | ||
4319 | * which is also wired to I2C interface. I have no further info on the | ||
4320 | * microcontroller features, one would need to disassembly the firmware. | ||
4321 | * note: the vendor refused to give any information on this product, all | ||
4322 | * that stuff was found using a multimeter! :) | ||
4323 | */ | ||
4324 | static void rv605_muxsel(struct bttv *btv, unsigned int input) | ||
4325 | { | ||
4326 | static const u8 muxgpio[] = { 0x3, 0x1, 0x2, 0x4, 0xf, 0x7, 0xe, 0x0, | ||
4327 | 0xd, 0xb, 0xc, 0x6, 0x9, 0x5, 0x8, 0xa }; | ||
4328 | |||
4329 | gpio_bits(0x07f, muxgpio[input]); | ||
4330 | |||
4331 | /* reset all conections */ | ||
4332 | gpio_bits(0x200,0x200); | ||
4333 | mdelay(1); | ||
4334 | gpio_bits(0x200,0x000); | ||
4335 | mdelay(1); | ||
4336 | |||
4337 | /* create a new connection */ | ||
4338 | gpio_bits(0x480,0x480); | ||
4339 | mdelay(1); | ||
4340 | gpio_bits(0x480,0x080); | ||
4341 | mdelay(1); | ||
4342 | } | ||
4343 | |||
4344 | /* Tibet Systems 'Progress DVR' CS16 muxsel helper [Chris Fanning] | ||
4345 | * | ||
4346 | * The CS16 (available on eBay cheap) is a PCI board with four Fusion | ||
4347 | * 878A chips, a PCI bridge, an Atmel microcontroller, four sync separator | ||
4348 | * chips, ten eight input analog multiplexors, a not chip and a few | ||
4349 | * other components. | ||
4350 | * | ||
4351 | * 16 inputs on a secondary bracket are provided and can be selected | ||
4352 | * from each of the four capture chips. Two of the eight input | ||
4353 | * multiplexors are used to select from any of the 16 input signals. | ||
4354 | * | ||
4355 | * Unsupported hardware capabilities: | ||
4356 | * . A video output monitor on the secondary bracket can be selected from | ||
4357 | * one of the 878A chips. | ||
4358 | * . Another passthrough but I haven't spent any time investigating it. | ||
4359 | * . Digital I/O (logic level connected to GPIO) is available from an | ||
4360 | * onboard header. | ||
4361 | * | ||
4362 | * The on chip input mux should always be set to 2. | ||
4363 | * GPIO[16:19] - Video input selection | ||
4364 | * GPIO[0:3] - Video output monitor select (only available from one 878A) | ||
4365 | * GPIO[?:?] - Digital I/O. | ||
4366 | * | ||
4367 | * There is an ATMEL microcontroller with an 8031 core on board. I have not | ||
4368 | * determined what function (if any) it provides. With the microcontroller | ||
4369 | * and sync separator chips a guess is that it might have to do with video | ||
4370 | * switching and maybe some digital I/O. | ||
4371 | */ | ||
4372 | static void tibetCS16_muxsel(struct bttv *btv, unsigned int input) | ||
4373 | { | ||
4374 | /* video mux */ | ||
4375 | gpio_bits(0x0f0000, input << 16); | ||
4376 | } | ||
4377 | |||
4378 | static void tibetCS16_init(struct bttv *btv) | ||
4379 | { | ||
4380 | /* enable gpio bits, mask obtained via btSpy */ | ||
4381 | gpio_inout(0xffffff, 0x0f7fff); | ||
4382 | gpio_write(0x0f7fff); | ||
4383 | } | ||
4384 | |||
4385 | /* | ||
4386 | * The following routines for the Kodicom-4400r get a little mind-twisting. | ||
4387 | * There is a "master" controller and three "slave" controllers, together | ||
4388 | * an analog switch which connects any of 16 cameras to any of the BT87A's. | ||
4389 | * The analog switch is controlled by the "master", but the detection order | ||
4390 | * of the four BT878A chips is in an order which I just don't understand. | ||
4391 | * The "master" is actually the second controller to be detected. The | ||
4392 | * logic on the board uses logical numbers for the 4 controllers, but | ||
4393 | * those numbers are different from the detection sequence. When working | ||
4394 | * with the analog switch, we need to "map" from the detection sequence | ||
4395 | * over to the board's logical controller number. This mapping sequence | ||
4396 | * is {3, 0, 2, 1}, i.e. the first controller to be detected is logical | ||
4397 | * unit 3, the second (which is the master) is logical unit 0, etc. | ||
4398 | * We need to maintain the status of the analog switch (which of the 16 | ||
4399 | * cameras is connected to which of the 4 controllers). Rather than | ||
4400 | * add to the bttv structure for this, we use the data reserved for | ||
4401 | * the mbox (unused for this card type). | ||
4402 | */ | ||
4403 | |||
4404 | /* | ||
4405 | * First a routine to set the analog switch, which controls which camera | ||
4406 | * is routed to which controller. The switch comprises an X-address | ||
4407 | * (gpio bits 0-3, representing the camera, ranging from 0-15), and a | ||
4408 | * Y-address (gpio bits 4-6, representing the controller, ranging from 0-3). | ||
4409 | * A data value (gpio bit 7) of '1' enables the switch, and '0' disables | ||
4410 | * the switch. A STROBE bit (gpio bit 8) latches the data value into the | ||
4411 | * specified address. The idea is to set the address and data, then bring | ||
4412 | * STROBE high, and finally bring STROBE back to low. | ||
4413 | */ | ||
4414 | static void kodicom4400r_write(struct bttv *btv, | ||
4415 | unsigned char xaddr, | ||
4416 | unsigned char yaddr, | ||
4417 | unsigned char data) { | ||
4418 | unsigned int udata; | ||
4419 | |||
4420 | udata = (data << 7) | ((yaddr&3) << 4) | (xaddr&0xf); | ||
4421 | gpio_bits(0x1ff, udata); /* write ADDR and DAT */ | ||
4422 | gpio_bits(0x1ff, udata | (1 << 8)); /* strobe high */ | ||
4423 | gpio_bits(0x1ff, udata); /* strobe low */ | ||
4424 | } | ||
4425 | |||
4426 | /* | ||
4427 | * Next the mux select. Both the "master" and "slave" 'cards' (controllers) | ||
4428 | * use this routine. The routine finds the "master" for the card, maps | ||
4429 | * the controller number from the detected position over to the logical | ||
4430 | * number, writes the appropriate data to the analog switch, and housekeeps | ||
4431 | * the local copy of the switch information. The parameter 'input' is the | ||
4432 | * requested camera number (0 - 15). | ||
4433 | */ | ||
4434 | static void kodicom4400r_muxsel(struct bttv *btv, unsigned int input) | ||
4435 | { | ||
4436 | char *sw_status; | ||
4437 | int xaddr, yaddr; | ||
4438 | struct bttv *mctlr; | ||
4439 | static unsigned char map[4] = {3, 0, 2, 1}; | ||
4440 | |||
4441 | mctlr = master[btv->c.nr]; | ||
4442 | if (mctlr == NULL) { /* ignore if master not yet detected */ | ||
4443 | return; | ||
4444 | } | ||
4445 | yaddr = (btv->c.nr - mctlr->c.nr + 1) & 3; /* the '&' is for safety */ | ||
4446 | yaddr = map[yaddr]; | ||
4447 | sw_status = (char *)(&mctlr->mbox_we); | ||
4448 | xaddr = input & 0xf; | ||
4449 | /* Check if the controller/camera pair has changed, else ignore */ | ||
4450 | if (sw_status[yaddr] != xaddr) | ||
4451 | { | ||
4452 | /* "open" the old switch, "close" the new one, save the new */ | ||
4453 | kodicom4400r_write(mctlr, sw_status[yaddr], yaddr, 0); | ||
4454 | sw_status[yaddr] = xaddr; | ||
4455 | kodicom4400r_write(mctlr, xaddr, yaddr, 1); | ||
4456 | } | ||
4457 | } | ||
4458 | |||
4459 | /* | ||
4460 | * During initialisation, we need to reset the analog switch. We | ||
4461 | * also preset the switch to map the 4 connectors on the card to the | ||
4462 | * *user's* (see above description of kodicom4400r_muxsel) channels | ||
4463 | * 0 through 3 | ||
4464 | */ | ||
4465 | static void kodicom4400r_init(struct bttv *btv) | ||
4466 | { | ||
4467 | char *sw_status = (char *)(&btv->mbox_we); | ||
4468 | int ix; | ||
4469 | |||
4470 | gpio_inout(0x0003ff, 0x0003ff); | ||
4471 | gpio_write(1 << 9); /* reset MUX */ | ||
4472 | gpio_write(0); | ||
4473 | /* Preset camera 0 to the 4 controllers */ | ||
4474 | for (ix = 0; ix < 4; ix++) { | ||
4475 | sw_status[ix] = ix; | ||
4476 | kodicom4400r_write(btv, ix, ix, 1); | ||
4477 | } | ||
4478 | /* | ||
4479 | * Since this is the "master", we need to set up the | ||
4480 | * other three controller chips' pointers to this structure | ||
4481 | * for later use in the muxsel routine. | ||
4482 | */ | ||
4483 | if ((btv->c.nr<1) || (btv->c.nr>BTTV_MAX-3)) | ||
4484 | return; | ||
4485 | master[btv->c.nr-1] = btv; | ||
4486 | master[btv->c.nr] = btv; | ||
4487 | master[btv->c.nr+1] = btv; | ||
4488 | master[btv->c.nr+2] = btv; | ||
4489 | } | ||
4490 | |||
4491 | /* The Grandtec X-Guard framegrabber card uses two Dual 4-channel | ||
4492 | * video multiplexers to provide up to 16 video inputs. These | ||
4493 | * multiplexers are controlled by the lower 8 GPIO pins of the | ||
4494 | * bt878. The multiplexers probably Pericom PI5V331Q or similar. | ||
4495 | |||
4496 | * xxx0 is pin xxx of multiplexer U5, | ||
4497 | * yyy1 is pin yyy of multiplexer U2 | ||
4498 | */ | ||
4499 | #define ENA0 0x01 | ||
4500 | #define ENB0 0x02 | ||
4501 | #define ENA1 0x04 | ||
4502 | #define ENB1 0x08 | ||
4503 | |||
4504 | #define IN10 0x10 | ||
4505 | #define IN00 0x20 | ||
4506 | #define IN11 0x40 | ||
4507 | #define IN01 0x80 | ||
4508 | |||
4509 | static void xguard_muxsel(struct bttv *btv, unsigned int input) | ||
4510 | { | ||
4511 | static const int masks[] = { | ||
4512 | ENB0, ENB0|IN00, ENB0|IN10, ENB0|IN00|IN10, | ||
4513 | ENA0, ENA0|IN00, ENA0|IN10, ENA0|IN00|IN10, | ||
4514 | ENB1, ENB1|IN01, ENB1|IN11, ENB1|IN01|IN11, | ||
4515 | ENA1, ENA1|IN01, ENA1|IN11, ENA1|IN01|IN11, | ||
4516 | }; | ||
4517 | gpio_write(masks[input%16]); | ||
4518 | } | ||
4519 | static void picolo_tetra_init(struct bttv *btv) | ||
4520 | { | ||
4521 | /*This is the video input redirection fonctionality : I DID NOT USED IT. */ | ||
4522 | btwrite (0x08<<16,BT848_GPIO_DATA);/*GPIO[19] [==> 4053 B+C] set to 1 */ | ||
4523 | btwrite (0x04<<16,BT848_GPIO_DATA);/*GPIO[18] [==> 4053 A] set to 1*/ | ||
4524 | } | ||
4525 | static void picolo_tetra_muxsel (struct bttv* btv, unsigned int input) | ||
4526 | { | ||
4527 | |||
4528 | dprintk("%d : picolo_tetra_muxsel => input = %d\n", btv->c.nr, input); | ||
4529 | /*Just set the right path in the analog multiplexers : channel 1 -> 4 ==> Analog Mux ==> MUX0*/ | ||
4530 | /*GPIO[20]&GPIO[21] used to choose the right input*/ | ||
4531 | btwrite (input<<20,BT848_GPIO_DATA); | ||
4532 | |||
4533 | } | ||
4534 | |||
4535 | /* | ||
4536 | * ivc120_muxsel [Added by Alan Garfield <alan@fromorbit.com>] | ||
4537 | * | ||
4538 | * The IVC120G security card has 4 i2c controlled TDA8540 matrix | ||
4539 | * swichers to provide 16 channels to MUX0. The TDA8540's have | ||
4540 | * 4 independent outputs and as such the IVC120G also has the | ||
4541 | * optional "Monitor Out" bus. This allows the card to be looking | ||
4542 | * at one input while the monitor is looking at another. | ||
4543 | * | ||
4544 | * Since I've couldn't be bothered figuring out how to add an | ||
4545 | * independent muxsel for the monitor bus, I've just set it to | ||
4546 | * whatever the card is looking at. | ||
4547 | * | ||
4548 | * OUT0 of the TDA8540's is connected to MUX0 (0x03) | ||
4549 | * OUT1 of the TDA8540's is connected to "Monitor Out" (0x0C) | ||
4550 | * | ||
4551 | * TDA8540_ALT3 IN0-3 = Channel 13 - 16 (0x03) | ||
4552 | * TDA8540_ALT4 IN0-3 = Channel 1 - 4 (0x03) | ||
4553 | * TDA8540_ALT5 IN0-3 = Channel 5 - 8 (0x03) | ||
4554 | * TDA8540_ALT6 IN0-3 = Channel 9 - 12 (0x03) | ||
4555 | * | ||
4556 | */ | ||
4557 | |||
4558 | /* All 7 possible sub-ids for the TDA8540 Matrix Switcher */ | ||
4559 | #define I2C_TDA8540 0x90 | ||
4560 | #define I2C_TDA8540_ALT1 0x92 | ||
4561 | #define I2C_TDA8540_ALT2 0x94 | ||
4562 | #define I2C_TDA8540_ALT3 0x96 | ||
4563 | #define I2C_TDA8540_ALT4 0x98 | ||
4564 | #define I2C_TDA8540_ALT5 0x9a | ||
4565 | #define I2C_TDA8540_ALT6 0x9c | ||
4566 | |||
4567 | static void ivc120_muxsel(struct bttv *btv, unsigned int input) | ||
4568 | { | ||
4569 | /* Simple maths */ | ||
4570 | int key = input % 4; | ||
4571 | int matrix = input / 4; | ||
4572 | |||
4573 | dprintk("%d: ivc120_muxsel: Input - %02d | TDA - %02d | In - %02d\n", | ||
4574 | btv->c.nr, input, matrix, key); | ||
4575 | |||
4576 | /* Handles the input selection on the TDA8540's */ | ||
4577 | bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x00, | ||
4578 | ((matrix == 3) ? (key | key << 2) : 0x00), 1); | ||
4579 | bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x00, | ||
4580 | ((matrix == 0) ? (key | key << 2) : 0x00), 1); | ||
4581 | bttv_I2CWrite(btv, I2C_TDA8540_ALT5, 0x00, | ||
4582 | ((matrix == 1) ? (key | key << 2) : 0x00), 1); | ||
4583 | bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x00, | ||
4584 | ((matrix == 2) ? (key | key << 2) : 0x00), 1); | ||
4585 | |||
4586 | /* Handles the output enables on the TDA8540's */ | ||
4587 | bttv_I2CWrite(btv, I2C_TDA8540_ALT3, 0x02, | ||
4588 | ((matrix == 3) ? 0x03 : 0x00), 1); /* 13 - 16 */ | ||
4589 | bttv_I2CWrite(btv, I2C_TDA8540_ALT4, 0x02, | ||
4590 | ((matrix == 0) ? 0x03 : 0x00), 1); /* 1-4 */ | ||
4591 | bttv_I2CWrite(btv, I2C_TDA8540_ALT5, 0x02, | ||
4592 | ((matrix == 1) ? 0x03 : 0x00), 1); /* 5-8 */ | ||
4593 | bttv_I2CWrite(btv, I2C_TDA8540_ALT6, 0x02, | ||
4594 | ((matrix == 2) ? 0x03 : 0x00), 1); /* 9-12 */ | ||
4595 | |||
4596 | /* 878's MUX0 is already selected for input via muxsel values */ | ||
4597 | } | ||
4598 | |||
4599 | |||
4600 | /* PXC200 muxsel helper | ||
4601 | * luke@syseng.anu.edu.au | ||
4602 | * another transplant | ||
4603 | * from Alessandro Rubini (rubini@linux.it) | ||
4604 | * | ||
4605 | * There are 4 kinds of cards: | ||
4606 | * PXC200L which is bt848 | ||
4607 | * PXC200F which is bt848 with PIC controlling mux | ||
4608 | * PXC200AL which is bt878 | ||
4609 | * PXC200AF which is bt878 with PIC controlling mux | ||
4610 | */ | ||
4611 | #define PX_CFG_PXC200F 0x01 | ||
4612 | #define PX_FLAG_PXC200A 0x00001000 /* a pxc200A is bt-878 based */ | ||
4613 | #define PX_I2C_PIC 0x0f | ||
4614 | #define PX_PXC200A_CARDID 0x200a1295 | ||
4615 | #define PX_I2C_CMD_CFG 0x00 | ||
4616 | |||
4617 | static void PXC200_muxsel(struct bttv *btv, unsigned int input) | ||
4618 | { | ||
4619 | int rc; | ||
4620 | long mux; | ||
4621 | int bitmask; | ||
4622 | unsigned char buf[2]; | ||
4623 | |||
4624 | /* Read PIC config to determine if this is a PXC200F */ | ||
4625 | /* PX_I2C_CMD_CFG*/ | ||
4626 | buf[0]=0; | ||
4627 | buf[1]=0; | ||
4628 | rc=bttv_I2CWrite(btv,(PX_I2C_PIC<<1),buf[0],buf[1],1); | ||
4629 | if (rc) { | ||
4630 | pr_debug("%d: PXC200_muxsel: pic cfg write failed:%d\n", | ||
4631 | btv->c.nr, rc); | ||
4632 | /* not PXC ? do nothing */ | ||
4633 | return; | ||
4634 | } | ||
4635 | |||
4636 | rc=bttv_I2CRead(btv,(PX_I2C_PIC<<1),NULL); | ||
4637 | if (!(rc & PX_CFG_PXC200F)) { | ||
4638 | pr_debug("%d: PXC200_muxsel: not PXC200F rc:%d\n", | ||
4639 | btv->c.nr, rc); | ||
4640 | return; | ||
4641 | } | ||
4642 | |||
4643 | |||
4644 | /* The multiplexer in the 200F is handled by the GPIO port */ | ||
4645 | /* get correct mapping between inputs */ | ||
4646 | /* mux = bttv_tvcards[btv->type].muxsel[input] & 3; */ | ||
4647 | /* ** not needed!? */ | ||
4648 | mux = input; | ||
4649 | |||
4650 | /* make sure output pins are enabled */ | ||
4651 | /* bitmask=0x30f; */ | ||
4652 | bitmask=0x302; | ||
4653 | /* check whether we have a PXC200A */ | ||
4654 | if (btv->cardid == PX_PXC200A_CARDID) { | ||
4655 | bitmask ^= 0x180; /* use 7 and 9, not 8 and 9 */ | ||
4656 | bitmask |= 7<<4; /* the DAC */ | ||
4657 | } | ||
4658 | btwrite(bitmask, BT848_GPIO_OUT_EN); | ||
4659 | |||
4660 | bitmask = btread(BT848_GPIO_DATA); | ||
4661 | if (btv->cardid == PX_PXC200A_CARDID) | ||
4662 | bitmask = (bitmask & ~0x280) | ((mux & 2) << 8) | ((mux & 1) << 7); | ||
4663 | else /* older device */ | ||
4664 | bitmask = (bitmask & ~0x300) | ((mux & 3) << 8); | ||
4665 | btwrite(bitmask,BT848_GPIO_DATA); | ||
4666 | |||
4667 | /* | ||
4668 | * Was "to be safe, set the bt848 to input 0" | ||
4669 | * Actually, since it's ok at load time, better not messing | ||
4670 | * with these bits (on PXC200AF you need to set mux 2 here) | ||
4671 | * | ||
4672 | * needed because bttv-driver sets mux before calling this function | ||
4673 | */ | ||
4674 | if (btv->cardid == PX_PXC200A_CARDID) | ||
4675 | btaor(2<<5, ~BT848_IFORM_MUXSEL, BT848_IFORM); | ||
4676 | else /* older device */ | ||
4677 | btand(~BT848_IFORM_MUXSEL,BT848_IFORM); | ||
4678 | |||
4679 | pr_debug("%d: setting input channel to:%d\n", btv->c.nr, (int)mux); | ||
4680 | } | ||
4681 | |||
4682 | static void phytec_muxsel(struct bttv *btv, unsigned int input) | ||
4683 | { | ||
4684 | unsigned int mux = input % 4; | ||
4685 | |||
4686 | if (input == btv->svhs) | ||
4687 | mux = 0; | ||
4688 | |||
4689 | gpio_bits(0x3, mux); | ||
4690 | } | ||
4691 | |||
4692 | /* | ||
4693 | * GeoVision GV-800(S) functions | ||
4694 | * Bruno Christo <bchristo@inf.ufsm.br> | ||
4695 | */ | ||
4696 | |||
4697 | /* This is a function to control the analog switch, which determines which | ||
4698 | * camera is routed to which controller. The switch comprises an X-address | ||
4699 | * (gpio bits 0-3, representing the camera, ranging from 0-15), and a | ||
4700 | * Y-address (gpio bits 4-6, representing the controller, ranging from 0-3). | ||
4701 | * A data value (gpio bit 18) of '1' enables the switch, and '0' disables | ||
4702 | * the switch. A STROBE bit (gpio bit 17) latches the data value into the | ||
4703 | * specified address. There is also a chip select (gpio bit 16). | ||
4704 | * The idea is to set the address and chip select together, bring | ||
4705 | * STROBE high, write the data, and finally bring STROBE back to low. | ||
4706 | */ | ||
4707 | static void gv800s_write(struct bttv *btv, | ||
4708 | unsigned char xaddr, | ||
4709 | unsigned char yaddr, | ||
4710 | unsigned char data) { | ||
4711 | /* On the "master" 878A: | ||
4712 | * GPIO bits 0-9 are used for the analog switch: | ||
4713 | * 00 - 03: camera selector | ||
4714 | * 04 - 06: 878A (controller) selector | ||
4715 | * 16: cselect | ||
4716 | * 17: strobe | ||
4717 | * 18: data (1->on, 0->off) | ||
4718 | * 19: reset | ||
4719 | */ | ||
4720 | const u32 ADDRESS = ((xaddr&0xf) | (yaddr&3)<<4); | ||
4721 | const u32 CSELECT = 1<<16; | ||
4722 | const u32 STROBE = 1<<17; | ||
4723 | const u32 DATA = data<<18; | ||
4724 | |||
4725 | gpio_bits(0x1007f, ADDRESS | CSELECT); /* write ADDRESS and CSELECT */ | ||
4726 | gpio_bits(0x20000, STROBE); /* STROBE high */ | ||
4727 | gpio_bits(0x40000, DATA); /* write DATA */ | ||
4728 | gpio_bits(0x20000, ~STROBE); /* STROBE low */ | ||
4729 | } | ||
4730 | |||
4731 | /* | ||
4732 | * GeoVision GV-800(S) muxsel | ||
4733 | * | ||
4734 | * Each of the 4 cards (controllers) use this function. | ||
4735 | * The controller using this function selects the input through the GPIO pins | ||
4736 | * of the "master" card. A pointer to this card is stored in master[btv->c.nr]. | ||
4737 | * | ||
4738 | * The parameter 'input' is the requested camera number (0-4) on the controller. | ||
4739 | * The map array has the address of each input. Note that the addresses in the | ||
4740 | * array are in the sequence the original GeoVision driver uses, that is, set | ||
4741 | * every controller to input 0, then to input 1, 2, 3, repeat. This means that | ||
4742 | * the physical "camera 1" connector corresponds to controller 0 input 0, | ||
4743 | * "camera 2" corresponds to controller 1 input 0, and so on. | ||
4744 | * | ||
4745 | * After getting the input address, the function then writes the appropriate | ||
4746 | * data to the analog switch, and housekeeps the local copy of the switch | ||
4747 | * information. | ||
4748 | */ | ||
4749 | static void gv800s_muxsel(struct bttv *btv, unsigned int input) | ||
4750 | { | ||
4751 | struct bttv *mctlr; | ||
4752 | char *sw_status; | ||
4753 | int xaddr, yaddr; | ||
4754 | static unsigned int map[4][4] = { { 0x0, 0x4, 0xa, 0x6 }, | ||
4755 | { 0x1, 0x5, 0xb, 0x7 }, | ||
4756 | { 0x2, 0x8, 0xc, 0xe }, | ||
4757 | { 0x3, 0x9, 0xd, 0xf } }; | ||
4758 | input = input%4; | ||
4759 | mctlr = master[btv->c.nr]; | ||
4760 | if (mctlr == NULL) { | ||
4761 | /* do nothing until the "master" is detected */ | ||
4762 | return; | ||
4763 | } | ||
4764 | yaddr = (btv->c.nr - mctlr->c.nr) & 3; | ||
4765 | sw_status = (char *)(&mctlr->mbox_we); | ||
4766 | xaddr = map[yaddr][input] & 0xf; | ||
4767 | |||
4768 | /* Check if the controller/camera pair has changed, ignore otherwise */ | ||
4769 | if (sw_status[yaddr] != xaddr) { | ||
4770 | /* disable the old switch, enable the new one and save status */ | ||
4771 | gv800s_write(mctlr, sw_status[yaddr], yaddr, 0); | ||
4772 | sw_status[yaddr] = xaddr; | ||
4773 | gv800s_write(mctlr, xaddr, yaddr, 1); | ||
4774 | } | ||
4775 | } | ||
4776 | |||
4777 | /* GeoVision GV-800(S) "master" chip init */ | ||
4778 | static void gv800s_init(struct bttv *btv) | ||
4779 | { | ||
4780 | char *sw_status = (char *)(&btv->mbox_we); | ||
4781 | int ix; | ||
4782 | |||
4783 | gpio_inout(0xf107f, 0xf107f); | ||
4784 | gpio_write(1<<19); /* reset the analog MUX */ | ||
4785 | gpio_write(0); | ||
4786 | |||
4787 | /* Preset camera 0 to the 4 controllers */ | ||
4788 | for (ix = 0; ix < 4; ix++) { | ||
4789 | sw_status[ix] = ix; | ||
4790 | gv800s_write(btv, ix, ix, 1); | ||
4791 | } | ||
4792 | |||
4793 | /* Inputs on the "master" controller need this brightness fix */ | ||
4794 | bttv_I2CWrite(btv, 0x18, 0x5, 0x90, 1); | ||
4795 | |||
4796 | if (btv->c.nr > BTTV_MAX-4) | ||
4797 | return; | ||
4798 | /* | ||
4799 | * Store the "master" controller pointer in the master | ||
4800 | * array for later use in the muxsel function. | ||
4801 | */ | ||
4802 | master[btv->c.nr] = btv; | ||
4803 | master[btv->c.nr+1] = btv; | ||
4804 | master[btv->c.nr+2] = btv; | ||
4805 | master[btv->c.nr+3] = btv; | ||
4806 | } | ||
4807 | |||
4808 | /* ----------------------------------------------------------------------- */ | ||
4809 | /* motherboard chipset specific stuff */ | ||
4810 | |||
4811 | void __init bttv_check_chipset(void) | ||
4812 | { | ||
4813 | int pcipci_fail = 0; | ||
4814 | struct pci_dev *dev = NULL; | ||
4815 | |||
4816 | if (pci_pci_problems & (PCIPCI_FAIL|PCIAGP_FAIL)) /* should check if target is AGP */ | ||
4817 | pcipci_fail = 1; | ||
4818 | if (pci_pci_problems & (PCIPCI_TRITON|PCIPCI_NATOMA|PCIPCI_VIAETBF)) | ||
4819 | triton1 = 1; | ||
4820 | if (pci_pci_problems & PCIPCI_VSFX) | ||
4821 | vsfx = 1; | ||
4822 | #ifdef PCIPCI_ALIMAGIK | ||
4823 | if (pci_pci_problems & PCIPCI_ALIMAGIK) | ||
4824 | latency = 0x0A; | ||
4825 | #endif | ||
4826 | |||
4827 | |||
4828 | /* print warnings about any quirks found */ | ||
4829 | if (triton1) | ||
4830 | pr_info("Host bridge needs ETBF enabled\n"); | ||
4831 | if (vsfx) | ||
4832 | pr_info("Host bridge needs VSFX enabled\n"); | ||
4833 | if (pcipci_fail) { | ||
4834 | pr_info("bttv and your chipset may not work together\n"); | ||
4835 | if (!no_overlay) { | ||
4836 | pr_info("overlay will be disabled\n"); | ||
4837 | no_overlay = 1; | ||
4838 | } else { | ||
4839 | pr_info("overlay forced. Use this option at your own risk.\n"); | ||
4840 | } | ||
4841 | } | ||
4842 | if (UNSET != latency) | ||
4843 | pr_info("pci latency fixup [%d]\n", latency); | ||
4844 | while ((dev = pci_get_device(PCI_VENDOR_ID_INTEL, | ||
4845 | PCI_DEVICE_ID_INTEL_82441, dev))) { | ||
4846 | unsigned char b; | ||
4847 | pci_read_config_byte(dev, 0x53, &b); | ||
4848 | if (bttv_debug) | ||
4849 | pr_info("Host bridge: 82441FX Natoma, bufcon=0x%02x\n", | ||
4850 | b); | ||
4851 | } | ||
4852 | } | ||
4853 | |||
4854 | int __devinit bttv_handle_chipset(struct bttv *btv) | ||
4855 | { | ||
4856 | unsigned char command; | ||
4857 | |||
4858 | if (!triton1 && !vsfx && UNSET == latency) | ||
4859 | return 0; | ||
4860 | |||
4861 | if (bttv_verbose) { | ||
4862 | if (triton1) | ||
4863 | pr_info("%d: enabling ETBF (430FX/VP3 compatibility)\n", | ||
4864 | btv->c.nr); | ||
4865 | if (vsfx && btv->id >= 878) | ||
4866 | pr_info("%d: enabling VSFX\n", btv->c.nr); | ||
4867 | if (UNSET != latency) | ||
4868 | pr_info("%d: setting pci timer to %d\n", | ||
4869 | btv->c.nr, latency); | ||
4870 | } | ||
4871 | |||
4872 | if (btv->id < 878) { | ||
4873 | /* bt848 (mis)uses a bit in the irq mask for etbf */ | ||
4874 | if (triton1) | ||
4875 | btv->triton1 = BT848_INT_ETBF; | ||
4876 | } else { | ||
4877 | /* bt878 has a bit in the pci config space for it */ | ||
4878 | pci_read_config_byte(btv->c.pci, BT878_DEVCTRL, &command); | ||
4879 | if (triton1) | ||
4880 | command |= BT878_EN_TBFX; | ||
4881 | if (vsfx) | ||
4882 | command |= BT878_EN_VSFX; | ||
4883 | pci_write_config_byte(btv->c.pci, BT878_DEVCTRL, command); | ||
4884 | } | ||
4885 | if (UNSET != latency) | ||
4886 | pci_write_config_byte(btv->c.pci, PCI_LATENCY_TIMER, latency); | ||
4887 | return 0; | ||
4888 | } | ||
4889 | |||
4890 | |||
4891 | /* | ||
4892 | * Local variables: | ||
4893 | * c-basic-offset: 8 | ||
4894 | * End: | ||
4895 | */ | ||
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c deleted file mode 100644 index b58ff87db771..000000000000 --- a/drivers/media/video/bt8xx/bttv-driver.c +++ /dev/null | |||
@@ -1,4630 +0,0 @@ | |||
1 | /* | ||
2 | |||
3 | bttv - Bt848 frame grabber driver | ||
4 | |||
5 | Copyright (C) 1996,97,98 Ralph Metzler <rjkm@thp.uni-koeln.de> | ||
6 | & Marcus Metzler <mocm@thp.uni-koeln.de> | ||
7 | (c) 1999-2002 Gerd Knorr <kraxel@bytesex.org> | ||
8 | |||
9 | some v4l2 code lines are taken from Justin's bttv2 driver which is | ||
10 | (c) 2000 Justin Schoeman <justin@suntiger.ee.up.ac.za> | ||
11 | |||
12 | V4L1 removal from: | ||
13 | (c) 2005-2006 Nickolay V. Shmyrev <nshmyrev@yandex.ru> | ||
14 | |||
15 | Fixes to be fully V4L2 compliant by | ||
16 | (c) 2006 Mauro Carvalho Chehab <mchehab@infradead.org> | ||
17 | |||
18 | Cropping and overscan support | ||
19 | Copyright (C) 2005, 2006 Michael H. Schimek <mschimek@gmx.at> | ||
20 | Sponsored by OPQ Systems AB | ||
21 | |||
22 | This program is free software; you can redistribute it and/or modify | ||
23 | it under the terms of the GNU General Public License as published by | ||
24 | the Free Software Foundation; either version 2 of the License, or | ||
25 | (at your option) any later version. | ||
26 | |||
27 | This program is distributed in the hope that it will be useful, | ||
28 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
29 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
30 | GNU General Public License for more details. | ||
31 | |||
32 | You should have received a copy of the GNU General Public License | ||
33 | along with this program; if not, write to the Free Software | ||
34 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
35 | */ | ||
36 | |||
37 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
38 | |||
39 | #include <linux/init.h> | ||
40 | #include <linux/module.h> | ||
41 | #include <linux/delay.h> | ||
42 | #include <linux/slab.h> | ||
43 | #include <linux/errno.h> | ||
44 | #include <linux/fs.h> | ||
45 | #include <linux/kernel.h> | ||
46 | #include <linux/sched.h> | ||
47 | #include <linux/interrupt.h> | ||
48 | #include <linux/kdev_t.h> | ||
49 | #include "bttvp.h" | ||
50 | #include <media/v4l2-common.h> | ||
51 | #include <media/v4l2-ioctl.h> | ||
52 | #include <media/tvaudio.h> | ||
53 | #include <media/msp3400.h> | ||
54 | |||
55 | #include <linux/dma-mapping.h> | ||
56 | |||
57 | #include <asm/io.h> | ||
58 | #include <asm/byteorder.h> | ||
59 | |||
60 | #include <media/saa6588.h> | ||
61 | |||
62 | #define BTTV_VERSION "0.9.19" | ||
63 | |||
64 | unsigned int bttv_num; /* number of Bt848s in use */ | ||
65 | struct bttv *bttvs[BTTV_MAX]; | ||
66 | |||
67 | unsigned int bttv_debug; | ||
68 | unsigned int bttv_verbose = 1; | ||
69 | unsigned int bttv_gpio; | ||
70 | |||
71 | /* config variables */ | ||
72 | #ifdef __BIG_ENDIAN | ||
73 | static unsigned int bigendian=1; | ||
74 | #else | ||
75 | static unsigned int bigendian; | ||
76 | #endif | ||
77 | static unsigned int radio[BTTV_MAX]; | ||
78 | static unsigned int irq_debug; | ||
79 | static unsigned int gbuffers = 8; | ||
80 | static unsigned int gbufsize = 0x208000; | ||
81 | static unsigned int reset_crop = 1; | ||
82 | |||
83 | static int video_nr[BTTV_MAX] = { [0 ... (BTTV_MAX-1)] = -1 }; | ||
84 | static int radio_nr[BTTV_MAX] = { [0 ... (BTTV_MAX-1)] = -1 }; | ||
85 | static int vbi_nr[BTTV_MAX] = { [0 ... (BTTV_MAX-1)] = -1 }; | ||
86 | static int debug_latency; | ||
87 | static int disable_ir; | ||
88 | |||
89 | static unsigned int fdsr; | ||
90 | |||
91 | /* options */ | ||
92 | static unsigned int combfilter; | ||
93 | static unsigned int lumafilter; | ||
94 | static unsigned int automute = 1; | ||
95 | static unsigned int chroma_agc; | ||
96 | static unsigned int adc_crush = 1; | ||
97 | static unsigned int whitecrush_upper = 0xCF; | ||
98 | static unsigned int whitecrush_lower = 0x7F; | ||
99 | static unsigned int vcr_hack; | ||
100 | static unsigned int irq_iswitch; | ||
101 | static unsigned int uv_ratio = 50; | ||
102 | static unsigned int full_luma_range; | ||
103 | static unsigned int coring; | ||
104 | |||
105 | /* API features (turn on/off stuff for testing) */ | ||
106 | static unsigned int v4l2 = 1; | ||
107 | |||
108 | /* insmod args */ | ||
109 | module_param(bttv_verbose, int, 0644); | ||
110 | module_param(bttv_gpio, int, 0644); | ||
111 | module_param(bttv_debug, int, 0644); | ||
112 | module_param(irq_debug, int, 0644); | ||
113 | module_param(debug_latency, int, 0644); | ||
114 | module_param(disable_ir, int, 0444); | ||
115 | |||
116 | module_param(fdsr, int, 0444); | ||
117 | module_param(gbuffers, int, 0444); | ||
118 | module_param(gbufsize, int, 0444); | ||
119 | module_param(reset_crop, int, 0444); | ||
120 | |||
121 | module_param(v4l2, int, 0644); | ||
122 | module_param(bigendian, int, 0644); | ||
123 | module_param(irq_iswitch, int, 0644); | ||
124 | module_param(combfilter, int, 0444); | ||
125 | module_param(lumafilter, int, 0444); | ||
126 | module_param(automute, int, 0444); | ||
127 | module_param(chroma_agc, int, 0444); | ||
128 | module_param(adc_crush, int, 0444); | ||
129 | module_param(whitecrush_upper, int, 0444); | ||
130 | module_param(whitecrush_lower, int, 0444); | ||
131 | module_param(vcr_hack, int, 0444); | ||
132 | module_param(uv_ratio, int, 0444); | ||
133 | module_param(full_luma_range, int, 0444); | ||
134 | module_param(coring, int, 0444); | ||
135 | |||
136 | module_param_array(radio, int, NULL, 0444); | ||
137 | module_param_array(video_nr, int, NULL, 0444); | ||
138 | module_param_array(radio_nr, int, NULL, 0444); | ||
139 | module_param_array(vbi_nr, int, NULL, 0444); | ||
140 | |||
141 | MODULE_PARM_DESC(radio,"The TV card supports radio, default is 0 (no)"); | ||
142 | MODULE_PARM_DESC(bigendian,"byte order of the framebuffer, default is native endian"); | ||
143 | MODULE_PARM_DESC(bttv_verbose,"verbose startup messages, default is 1 (yes)"); | ||
144 | MODULE_PARM_DESC(bttv_gpio,"log gpio changes, default is 0 (no)"); | ||
145 | MODULE_PARM_DESC(bttv_debug,"debug messages, default is 0 (no)"); | ||
146 | MODULE_PARM_DESC(irq_debug,"irq handler debug messages, default is 0 (no)"); | ||
147 | MODULE_PARM_DESC(disable_ir, "disable infrared remote support"); | ||
148 | MODULE_PARM_DESC(gbuffers,"number of capture buffers. range 2-32, default 8"); | ||
149 | MODULE_PARM_DESC(gbufsize,"size of the capture buffers, default is 0x208000"); | ||
150 | MODULE_PARM_DESC(reset_crop,"reset cropping parameters at open(), default " | ||
151 | "is 1 (yes) for compatibility with older applications"); | ||
152 | MODULE_PARM_DESC(automute,"mute audio on bad/missing video signal, default is 1 (yes)"); | ||
153 | MODULE_PARM_DESC(chroma_agc,"enables the AGC of chroma signal, default is 0 (no)"); | ||
154 | MODULE_PARM_DESC(adc_crush,"enables the luminance ADC crush, default is 1 (yes)"); | ||
155 | MODULE_PARM_DESC(whitecrush_upper,"sets the white crush upper value, default is 207"); | ||
156 | MODULE_PARM_DESC(whitecrush_lower,"sets the white crush lower value, default is 127"); | ||
157 | MODULE_PARM_DESC(vcr_hack,"enables the VCR hack (improves synch on poor VCR tapes), default is 0 (no)"); | ||
158 | MODULE_PARM_DESC(irq_iswitch,"switch inputs in irq handler"); | ||
159 | MODULE_PARM_DESC(uv_ratio,"ratio between u and v gains, default is 50"); | ||
160 | MODULE_PARM_DESC(full_luma_range,"use the full luma range, default is 0 (no)"); | ||
161 | MODULE_PARM_DESC(coring,"set the luma coring level, default is 0 (no)"); | ||
162 | MODULE_PARM_DESC(video_nr, "video device numbers"); | ||
163 | MODULE_PARM_DESC(vbi_nr, "vbi device numbers"); | ||
164 | MODULE_PARM_DESC(radio_nr, "radio device numbers"); | ||
165 | |||
166 | MODULE_DESCRIPTION("bttv - v4l/v4l2 driver module for bt848/878 based cards"); | ||
167 | MODULE_AUTHOR("Ralph Metzler & Marcus Metzler & Gerd Knorr"); | ||
168 | MODULE_LICENSE("GPL"); | ||
169 | MODULE_VERSION(BTTV_VERSION); | ||
170 | |||
171 | /* ----------------------------------------------------------------------- */ | ||
172 | /* sysfs */ | ||
173 | |||
174 | static ssize_t show_card(struct device *cd, | ||
175 | struct device_attribute *attr, char *buf) | ||
176 | { | ||
177 | struct video_device *vfd = container_of(cd, struct video_device, dev); | ||
178 | struct bttv *btv = video_get_drvdata(vfd); | ||
179 | return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET); | ||
180 | } | ||
181 | static DEVICE_ATTR(card, S_IRUGO, show_card, NULL); | ||
182 | |||
183 | /* ----------------------------------------------------------------------- */ | ||
184 | /* dvb auto-load setup */ | ||
185 | #if defined(CONFIG_MODULES) && defined(MODULE) | ||
186 | static void request_module_async(struct work_struct *work) | ||
187 | { | ||
188 | request_module("dvb-bt8xx"); | ||
189 | } | ||
190 | |||
191 | static void request_modules(struct bttv *dev) | ||
192 | { | ||
193 | INIT_WORK(&dev->request_module_wk, request_module_async); | ||
194 | schedule_work(&dev->request_module_wk); | ||
195 | } | ||
196 | |||
197 | static void flush_request_modules(struct bttv *dev) | ||
198 | { | ||
199 | flush_work_sync(&dev->request_module_wk); | ||
200 | } | ||
201 | #else | ||
202 | #define request_modules(dev) | ||
203 | #define flush_request_modules(dev) | ||
204 | #endif /* CONFIG_MODULES */ | ||
205 | |||
206 | |||
207 | /* ----------------------------------------------------------------------- */ | ||
208 | /* static data */ | ||
209 | |||
210 | /* special timing tables from conexant... */ | ||
211 | static u8 SRAM_Table[][60] = | ||
212 | { | ||
213 | /* PAL digital input over GPIO[7:0] */ | ||
214 | { | ||
215 | 45, // 45 bytes following | ||
216 | 0x36,0x11,0x01,0x00,0x90,0x02,0x05,0x10,0x04,0x16, | ||
217 | 0x12,0x05,0x11,0x00,0x04,0x12,0xC0,0x00,0x31,0x00, | ||
218 | 0x06,0x51,0x08,0x03,0x89,0x08,0x07,0xC0,0x44,0x00, | ||
219 | 0x81,0x01,0x01,0xA9,0x0D,0x02,0x02,0x50,0x03,0x37, | ||
220 | 0x37,0x00,0xAF,0x21,0x00 | ||
221 | }, | ||
222 | /* NTSC digital input over GPIO[7:0] */ | ||
223 | { | ||
224 | 51, // 51 bytes following | ||
225 | 0x0C,0xC0,0x00,0x00,0x90,0x02,0x03,0x10,0x03,0x06, | ||
226 | 0x10,0x04,0x12,0x12,0x05,0x02,0x13,0x04,0x19,0x00, | ||
227 | 0x04,0x39,0x00,0x06,0x59,0x08,0x03,0x83,0x08,0x07, | ||
228 | 0x03,0x50,0x00,0xC0,0x40,0x00,0x86,0x01,0x01,0xA6, | ||
229 | 0x0D,0x02,0x03,0x11,0x01,0x05,0x37,0x00,0xAC,0x21, | ||
230 | 0x00, | ||
231 | }, | ||
232 | // TGB_NTSC392 // quartzsight | ||
233 | // This table has been modified to be used for Fusion Rev D | ||
234 | { | ||
235 | 0x2A, // size of table = 42 | ||
236 | 0x06, 0x08, 0x04, 0x0a, 0xc0, 0x00, 0x18, 0x08, 0x03, 0x24, | ||
237 | 0x08, 0x07, 0x02, 0x90, 0x02, 0x08, 0x10, 0x04, 0x0c, 0x10, | ||
238 | 0x05, 0x2c, 0x11, 0x04, 0x55, 0x48, 0x00, 0x05, 0x50, 0x00, | ||
239 | 0xbf, 0x0c, 0x02, 0x2f, 0x3d, 0x00, 0x2f, 0x3f, 0x00, 0xc3, | ||
240 | 0x20, 0x00 | ||
241 | } | ||
242 | }; | ||
243 | |||
244 | /* minhdelayx1 first video pixel we can capture on a line and | ||
245 | hdelayx1 start of active video, both relative to rising edge of | ||
246 | /HRESET pulse (0H) in 1 / fCLKx1. | ||
247 | swidth width of active video and | ||
248 | totalwidth total line width, both in 1 / fCLKx1. | ||
249 | sqwidth total line width in square pixels. | ||
250 | vdelay start of active video in 2 * field lines relative to | ||
251 | trailing edge of /VRESET pulse (VDELAY register). | ||
252 | sheight height of active video in 2 * field lines. | ||
253 | videostart0 ITU-R frame line number of the line corresponding | ||
254 | to vdelay in the first field. */ | ||
255 | #define CROPCAP(minhdelayx1, hdelayx1, swidth, totalwidth, sqwidth, \ | ||
256 | vdelay, sheight, videostart0) \ | ||
257 | .cropcap.bounds.left = minhdelayx1, \ | ||
258 | /* * 2 because vertically we count field lines times two, */ \ | ||
259 | /* e.g. 23 * 2 to 23 * 2 + 576 in PAL-BGHI defrect. */ \ | ||
260 | .cropcap.bounds.top = (videostart0) * 2 - (vdelay) + MIN_VDELAY, \ | ||
261 | /* 4 is a safety margin at the end of the line. */ \ | ||
262 | .cropcap.bounds.width = (totalwidth) - (minhdelayx1) - 4, \ | ||
263 | .cropcap.bounds.height = (sheight) + (vdelay) - MIN_VDELAY, \ | ||
264 | .cropcap.defrect.left = hdelayx1, \ | ||
265 | .cropcap.defrect.top = (videostart0) * 2, \ | ||
266 | .cropcap.defrect.width = swidth, \ | ||
267 | .cropcap.defrect.height = sheight, \ | ||
268 | .cropcap.pixelaspect.numerator = totalwidth, \ | ||
269 | .cropcap.pixelaspect.denominator = sqwidth, | ||
270 | |||
271 | const struct bttv_tvnorm bttv_tvnorms[] = { | ||
272 | /* PAL-BDGHI */ | ||
273 | /* max. active video is actually 922, but 924 is divisible by 4 and 3! */ | ||
274 | /* actually, max active PAL with HSCALE=0 is 948, NTSC is 768 - nil */ | ||
275 | { | ||
276 | .v4l2_id = V4L2_STD_PAL, | ||
277 | .name = "PAL", | ||
278 | .Fsc = 35468950, | ||
279 | .swidth = 924, | ||
280 | .sheight = 576, | ||
281 | .totalwidth = 1135, | ||
282 | .adelay = 0x7f, | ||
283 | .bdelay = 0x72, | ||
284 | .iform = (BT848_IFORM_PAL_BDGHI|BT848_IFORM_XT1), | ||
285 | .scaledtwidth = 1135, | ||
286 | .hdelayx1 = 186, | ||
287 | .hactivex1 = 924, | ||
288 | .vdelay = 0x20, | ||
289 | .vbipack = 255, /* min (2048 / 4, 0x1ff) & 0xff */ | ||
290 | .sram = 0, | ||
291 | /* ITU-R frame line number of the first VBI line | ||
292 | we can capture, of the first and second field. | ||
293 | The last line is determined by cropcap.bounds. */ | ||
294 | .vbistart = { 7, 320 }, | ||
295 | CROPCAP(/* minhdelayx1 */ 68, | ||
296 | /* hdelayx1 */ 186, | ||
297 | /* Should be (768 * 1135 + 944 / 2) / 944. | ||
298 | cropcap.defrect is used for image width | ||
299 | checks, so we keep the old value 924. */ | ||
300 | /* swidth */ 924, | ||
301 | /* totalwidth */ 1135, | ||
302 | /* sqwidth */ 944, | ||
303 | /* vdelay */ 0x20, | ||
304 | /* sheight */ 576, | ||
305 | /* videostart0 */ 23) | ||
306 | /* bt878 (and bt848?) can capture another | ||
307 | line below active video. */ | ||
308 | .cropcap.bounds.height = (576 + 2) + 0x20 - 2, | ||
309 | },{ | ||
310 | .v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR, | ||
311 | .name = "NTSC", | ||
312 | .Fsc = 28636363, | ||
313 | .swidth = 768, | ||
314 | .sheight = 480, | ||
315 | .totalwidth = 910, | ||
316 | .adelay = 0x68, | ||
317 | .bdelay = 0x5d, | ||
318 | .iform = (BT848_IFORM_NTSC|BT848_IFORM_XT0), | ||
319 | .scaledtwidth = 910, | ||
320 | .hdelayx1 = 128, | ||
321 | .hactivex1 = 910, | ||
322 | .vdelay = 0x1a, | ||
323 | .vbipack = 144, /* min (1600 / 4, 0x1ff) & 0xff */ | ||
324 | .sram = 1, | ||
325 | .vbistart = { 10, 273 }, | ||
326 | CROPCAP(/* minhdelayx1 */ 68, | ||
327 | /* hdelayx1 */ 128, | ||
328 | /* Should be (640 * 910 + 780 / 2) / 780? */ | ||
329 | /* swidth */ 768, | ||
330 | /* totalwidth */ 910, | ||
331 | /* sqwidth */ 780, | ||
332 | /* vdelay */ 0x1a, | ||
333 | /* sheight */ 480, | ||
334 | /* videostart0 */ 23) | ||
335 | },{ | ||
336 | .v4l2_id = V4L2_STD_SECAM, | ||
337 | .name = "SECAM", | ||
338 | .Fsc = 35468950, | ||
339 | .swidth = 924, | ||
340 | .sheight = 576, | ||
341 | .totalwidth = 1135, | ||
342 | .adelay = 0x7f, | ||
343 | .bdelay = 0xb0, | ||
344 | .iform = (BT848_IFORM_SECAM|BT848_IFORM_XT1), | ||
345 | .scaledtwidth = 1135, | ||
346 | .hdelayx1 = 186, | ||
347 | .hactivex1 = 922, | ||
348 | .vdelay = 0x20, | ||
349 | .vbipack = 255, | ||
350 | .sram = 0, /* like PAL, correct? */ | ||
351 | .vbistart = { 7, 320 }, | ||
352 | CROPCAP(/* minhdelayx1 */ 68, | ||
353 | /* hdelayx1 */ 186, | ||
354 | /* swidth */ 924, | ||
355 | /* totalwidth */ 1135, | ||
356 | /* sqwidth */ 944, | ||
357 | /* vdelay */ 0x20, | ||
358 | /* sheight */ 576, | ||
359 | /* videostart0 */ 23) | ||
360 | },{ | ||
361 | .v4l2_id = V4L2_STD_PAL_Nc, | ||
362 | .name = "PAL-Nc", | ||
363 | .Fsc = 28636363, | ||
364 | .swidth = 640, | ||
365 | .sheight = 576, | ||
366 | .totalwidth = 910, | ||
367 | .adelay = 0x68, | ||
368 | .bdelay = 0x5d, | ||
369 | .iform = (BT848_IFORM_PAL_NC|BT848_IFORM_XT0), | ||
370 | .scaledtwidth = 780, | ||
371 | .hdelayx1 = 130, | ||
372 | .hactivex1 = 734, | ||
373 | .vdelay = 0x1a, | ||
374 | .vbipack = 144, | ||
375 | .sram = -1, | ||
376 | .vbistart = { 7, 320 }, | ||
377 | CROPCAP(/* minhdelayx1 */ 68, | ||
378 | /* hdelayx1 */ 130, | ||
379 | /* swidth */ (640 * 910 + 780 / 2) / 780, | ||
380 | /* totalwidth */ 910, | ||
381 | /* sqwidth */ 780, | ||
382 | /* vdelay */ 0x1a, | ||
383 | /* sheight */ 576, | ||
384 | /* videostart0 */ 23) | ||
385 | },{ | ||
386 | .v4l2_id = V4L2_STD_PAL_M, | ||
387 | .name = "PAL-M", | ||
388 | .Fsc = 28636363, | ||
389 | .swidth = 640, | ||
390 | .sheight = 480, | ||
391 | .totalwidth = 910, | ||
392 | .adelay = 0x68, | ||
393 | .bdelay = 0x5d, | ||
394 | .iform = (BT848_IFORM_PAL_M|BT848_IFORM_XT0), | ||
395 | .scaledtwidth = 780, | ||
396 | .hdelayx1 = 135, | ||
397 | .hactivex1 = 754, | ||
398 | .vdelay = 0x1a, | ||
399 | .vbipack = 144, | ||
400 | .sram = -1, | ||
401 | .vbistart = { 10, 273 }, | ||
402 | CROPCAP(/* minhdelayx1 */ 68, | ||
403 | /* hdelayx1 */ 135, | ||
404 | /* swidth */ (640 * 910 + 780 / 2) / 780, | ||
405 | /* totalwidth */ 910, | ||
406 | /* sqwidth */ 780, | ||
407 | /* vdelay */ 0x1a, | ||
408 | /* sheight */ 480, | ||
409 | /* videostart0 */ 23) | ||
410 | },{ | ||
411 | .v4l2_id = V4L2_STD_PAL_N, | ||
412 | .name = "PAL-N", | ||
413 | .Fsc = 35468950, | ||
414 | .swidth = 768, | ||
415 | .sheight = 576, | ||
416 | .totalwidth = 1135, | ||
417 | .adelay = 0x7f, | ||
418 | .bdelay = 0x72, | ||
419 | .iform = (BT848_IFORM_PAL_N|BT848_IFORM_XT1), | ||
420 | .scaledtwidth = 944, | ||
421 | .hdelayx1 = 186, | ||
422 | .hactivex1 = 922, | ||
423 | .vdelay = 0x20, | ||
424 | .vbipack = 144, | ||
425 | .sram = -1, | ||
426 | .vbistart = { 7, 320 }, | ||
427 | CROPCAP(/* minhdelayx1 */ 68, | ||
428 | /* hdelayx1 */ 186, | ||
429 | /* swidth */ (768 * 1135 + 944 / 2) / 944, | ||
430 | /* totalwidth */ 1135, | ||
431 | /* sqwidth */ 944, | ||
432 | /* vdelay */ 0x20, | ||
433 | /* sheight */ 576, | ||
434 | /* videostart0 */ 23) | ||
435 | },{ | ||
436 | .v4l2_id = V4L2_STD_NTSC_M_JP, | ||
437 | .name = "NTSC-JP", | ||
438 | .Fsc = 28636363, | ||
439 | .swidth = 640, | ||
440 | .sheight = 480, | ||
441 | .totalwidth = 910, | ||
442 | .adelay = 0x68, | ||
443 | .bdelay = 0x5d, | ||
444 | .iform = (BT848_IFORM_NTSC_J|BT848_IFORM_XT0), | ||
445 | .scaledtwidth = 780, | ||
446 | .hdelayx1 = 135, | ||
447 | .hactivex1 = 754, | ||
448 | .vdelay = 0x16, | ||
449 | .vbipack = 144, | ||
450 | .sram = -1, | ||
451 | .vbistart = { 10, 273 }, | ||
452 | CROPCAP(/* minhdelayx1 */ 68, | ||
453 | /* hdelayx1 */ 135, | ||
454 | /* swidth */ (640 * 910 + 780 / 2) / 780, | ||
455 | /* totalwidth */ 910, | ||
456 | /* sqwidth */ 780, | ||
457 | /* vdelay */ 0x16, | ||
458 | /* sheight */ 480, | ||
459 | /* videostart0 */ 23) | ||
460 | },{ | ||
461 | /* that one hopefully works with the strange timing | ||
462 | * which video recorders produce when playing a NTSC | ||
463 | * tape on a PAL TV ... */ | ||
464 | .v4l2_id = V4L2_STD_PAL_60, | ||
465 | .name = "PAL-60", | ||
466 | .Fsc = 35468950, | ||
467 | .swidth = 924, | ||
468 | .sheight = 480, | ||
469 | .totalwidth = 1135, | ||
470 | .adelay = 0x7f, | ||
471 | .bdelay = 0x72, | ||
472 | .iform = (BT848_IFORM_PAL_BDGHI|BT848_IFORM_XT1), | ||
473 | .scaledtwidth = 1135, | ||
474 | .hdelayx1 = 186, | ||
475 | .hactivex1 = 924, | ||
476 | .vdelay = 0x1a, | ||
477 | .vbipack = 255, | ||
478 | .vtotal = 524, | ||
479 | .sram = -1, | ||
480 | .vbistart = { 10, 273 }, | ||
481 | CROPCAP(/* minhdelayx1 */ 68, | ||
482 | /* hdelayx1 */ 186, | ||
483 | /* swidth */ 924, | ||
484 | /* totalwidth */ 1135, | ||
485 | /* sqwidth */ 944, | ||
486 | /* vdelay */ 0x1a, | ||
487 | /* sheight */ 480, | ||
488 | /* videostart0 */ 23) | ||
489 | } | ||
490 | }; | ||
491 | static const unsigned int BTTV_TVNORMS = ARRAY_SIZE(bttv_tvnorms); | ||
492 | |||
493 | /* ----------------------------------------------------------------------- */ | ||
494 | /* bttv format list | ||
495 | packed pixel formats must come first */ | ||
496 | static const struct bttv_format formats[] = { | ||
497 | { | ||
498 | .name = "8 bpp, gray", | ||
499 | .fourcc = V4L2_PIX_FMT_GREY, | ||
500 | .btformat = BT848_COLOR_FMT_Y8, | ||
501 | .depth = 8, | ||
502 | .flags = FORMAT_FLAGS_PACKED, | ||
503 | },{ | ||
504 | .name = "8 bpp, dithered color", | ||
505 | .fourcc = V4L2_PIX_FMT_HI240, | ||
506 | .btformat = BT848_COLOR_FMT_RGB8, | ||
507 | .depth = 8, | ||
508 | .flags = FORMAT_FLAGS_PACKED | FORMAT_FLAGS_DITHER, | ||
509 | },{ | ||
510 | .name = "15 bpp RGB, le", | ||
511 | .fourcc = V4L2_PIX_FMT_RGB555, | ||
512 | .btformat = BT848_COLOR_FMT_RGB15, | ||
513 | .depth = 16, | ||
514 | .flags = FORMAT_FLAGS_PACKED, | ||
515 | },{ | ||
516 | .name = "15 bpp RGB, be", | ||
517 | .fourcc = V4L2_PIX_FMT_RGB555X, | ||
518 | .btformat = BT848_COLOR_FMT_RGB15, | ||
519 | .btswap = 0x03, /* byteswap */ | ||
520 | .depth = 16, | ||
521 | .flags = FORMAT_FLAGS_PACKED, | ||
522 | },{ | ||
523 | .name = "16 bpp RGB, le", | ||
524 | .fourcc = V4L2_PIX_FMT_RGB565, | ||
525 | .btformat = BT848_COLOR_FMT_RGB16, | ||
526 | .depth = 16, | ||
527 | .flags = FORMAT_FLAGS_PACKED, | ||
528 | },{ | ||
529 | .name = "16 bpp RGB, be", | ||
530 | .fourcc = V4L2_PIX_FMT_RGB565X, | ||
531 | .btformat = BT848_COLOR_FMT_RGB16, | ||
532 | .btswap = 0x03, /* byteswap */ | ||
533 | .depth = 16, | ||
534 | .flags = FORMAT_FLAGS_PACKED, | ||
535 | },{ | ||
536 | .name = "24 bpp RGB, le", | ||
537 | .fourcc = V4L2_PIX_FMT_BGR24, | ||
538 | .btformat = BT848_COLOR_FMT_RGB24, | ||
539 | .depth = 24, | ||
540 | .flags = FORMAT_FLAGS_PACKED, | ||
541 | },{ | ||
542 | .name = "32 bpp RGB, le", | ||
543 | .fourcc = V4L2_PIX_FMT_BGR32, | ||
544 | .btformat = BT848_COLOR_FMT_RGB32, | ||
545 | .depth = 32, | ||
546 | .flags = FORMAT_FLAGS_PACKED, | ||
547 | },{ | ||
548 | .name = "32 bpp RGB, be", | ||
549 | .fourcc = V4L2_PIX_FMT_RGB32, | ||
550 | .btformat = BT848_COLOR_FMT_RGB32, | ||
551 | .btswap = 0x0f, /* byte+word swap */ | ||
552 | .depth = 32, | ||
553 | .flags = FORMAT_FLAGS_PACKED, | ||
554 | },{ | ||
555 | .name = "4:2:2, packed, YUYV", | ||
556 | .fourcc = V4L2_PIX_FMT_YUYV, | ||
557 | .btformat = BT848_COLOR_FMT_YUY2, | ||
558 | .depth = 16, | ||
559 | .flags = FORMAT_FLAGS_PACKED, | ||
560 | },{ | ||
561 | .name = "4:2:2, packed, UYVY", | ||
562 | .fourcc = V4L2_PIX_FMT_UYVY, | ||
563 | .btformat = BT848_COLOR_FMT_YUY2, | ||
564 | .btswap = 0x03, /* byteswap */ | ||
565 | .depth = 16, | ||
566 | .flags = FORMAT_FLAGS_PACKED, | ||
567 | },{ | ||
568 | .name = "4:2:2, planar, Y-Cb-Cr", | ||
569 | .fourcc = V4L2_PIX_FMT_YUV422P, | ||
570 | .btformat = BT848_COLOR_FMT_YCrCb422, | ||
571 | .depth = 16, | ||
572 | .flags = FORMAT_FLAGS_PLANAR, | ||
573 | .hshift = 1, | ||
574 | .vshift = 0, | ||
575 | },{ | ||
576 | .name = "4:2:0, planar, Y-Cb-Cr", | ||
577 | .fourcc = V4L2_PIX_FMT_YUV420, | ||
578 | .btformat = BT848_COLOR_FMT_YCrCb422, | ||
579 | .depth = 12, | ||
580 | .flags = FORMAT_FLAGS_PLANAR, | ||
581 | .hshift = 1, | ||
582 | .vshift = 1, | ||
583 | },{ | ||
584 | .name = "4:2:0, planar, Y-Cr-Cb", | ||
585 | .fourcc = V4L2_PIX_FMT_YVU420, | ||
586 | .btformat = BT848_COLOR_FMT_YCrCb422, | ||
587 | .depth = 12, | ||
588 | .flags = FORMAT_FLAGS_PLANAR | FORMAT_FLAGS_CrCb, | ||
589 | .hshift = 1, | ||
590 | .vshift = 1, | ||
591 | },{ | ||
592 | .name = "4:1:1, planar, Y-Cb-Cr", | ||
593 | .fourcc = V4L2_PIX_FMT_YUV411P, | ||
594 | .btformat = BT848_COLOR_FMT_YCrCb411, | ||
595 | .depth = 12, | ||
596 | .flags = FORMAT_FLAGS_PLANAR, | ||
597 | .hshift = 2, | ||
598 | .vshift = 0, | ||
599 | },{ | ||
600 | .name = "4:1:0, planar, Y-Cb-Cr", | ||
601 | .fourcc = V4L2_PIX_FMT_YUV410, | ||
602 | .btformat = BT848_COLOR_FMT_YCrCb411, | ||
603 | .depth = 9, | ||
604 | .flags = FORMAT_FLAGS_PLANAR, | ||
605 | .hshift = 2, | ||
606 | .vshift = 2, | ||
607 | },{ | ||
608 | .name = "4:1:0, planar, Y-Cr-Cb", | ||
609 | .fourcc = V4L2_PIX_FMT_YVU410, | ||
610 | .btformat = BT848_COLOR_FMT_YCrCb411, | ||
611 | .depth = 9, | ||
612 | .flags = FORMAT_FLAGS_PLANAR | FORMAT_FLAGS_CrCb, | ||
613 | .hshift = 2, | ||
614 | .vshift = 2, | ||
615 | },{ | ||
616 | .name = "raw scanlines", | ||
617 | .fourcc = -1, | ||
618 | .btformat = BT848_COLOR_FMT_RAW, | ||
619 | .depth = 8, | ||
620 | .flags = FORMAT_FLAGS_RAW, | ||
621 | } | ||
622 | }; | ||
623 | static const unsigned int FORMATS = ARRAY_SIZE(formats); | ||
624 | |||
625 | /* ----------------------------------------------------------------------- */ | ||
626 | |||
627 | #define V4L2_CID_PRIVATE_CHROMA_AGC (V4L2_CID_PRIVATE_BASE + 0) | ||
628 | #define V4L2_CID_PRIVATE_COMBFILTER (V4L2_CID_PRIVATE_BASE + 1) | ||
629 | #define V4L2_CID_PRIVATE_AUTOMUTE (V4L2_CID_PRIVATE_BASE + 2) | ||
630 | #define V4L2_CID_PRIVATE_LUMAFILTER (V4L2_CID_PRIVATE_BASE + 3) | ||
631 | #define V4L2_CID_PRIVATE_AGC_CRUSH (V4L2_CID_PRIVATE_BASE + 4) | ||
632 | #define V4L2_CID_PRIVATE_VCR_HACK (V4L2_CID_PRIVATE_BASE + 5) | ||
633 | #define V4L2_CID_PRIVATE_WHITECRUSH_UPPER (V4L2_CID_PRIVATE_BASE + 6) | ||
634 | #define V4L2_CID_PRIVATE_WHITECRUSH_LOWER (V4L2_CID_PRIVATE_BASE + 7) | ||
635 | #define V4L2_CID_PRIVATE_UV_RATIO (V4L2_CID_PRIVATE_BASE + 8) | ||
636 | #define V4L2_CID_PRIVATE_FULL_LUMA_RANGE (V4L2_CID_PRIVATE_BASE + 9) | ||
637 | #define V4L2_CID_PRIVATE_CORING (V4L2_CID_PRIVATE_BASE + 10) | ||
638 | #define V4L2_CID_PRIVATE_LASTP1 (V4L2_CID_PRIVATE_BASE + 11) | ||
639 | |||
640 | static const struct v4l2_queryctrl no_ctl = { | ||
641 | .name = "42", | ||
642 | .flags = V4L2_CTRL_FLAG_DISABLED, | ||
643 | }; | ||
644 | static const struct v4l2_queryctrl bttv_ctls[] = { | ||
645 | /* --- video --- */ | ||
646 | { | ||
647 | .id = V4L2_CID_BRIGHTNESS, | ||
648 | .name = "Brightness", | ||
649 | .minimum = 0, | ||
650 | .maximum = 65535, | ||
651 | .step = 256, | ||
652 | .default_value = 32768, | ||
653 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
654 | },{ | ||
655 | .id = V4L2_CID_CONTRAST, | ||
656 | .name = "Contrast", | ||
657 | .minimum = 0, | ||
658 | .maximum = 65535, | ||
659 | .step = 128, | ||
660 | .default_value = 27648, | ||
661 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
662 | },{ | ||
663 | .id = V4L2_CID_SATURATION, | ||
664 | .name = "Saturation", | ||
665 | .minimum = 0, | ||
666 | .maximum = 65535, | ||
667 | .step = 128, | ||
668 | .default_value = 32768, | ||
669 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
670 | },{ | ||
671 | .id = V4L2_CID_HUE, | ||
672 | .name = "Hue", | ||
673 | .minimum = 0, | ||
674 | .maximum = 65535, | ||
675 | .step = 256, | ||
676 | .default_value = 32768, | ||
677 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
678 | }, | ||
679 | /* --- audio --- */ | ||
680 | { | ||
681 | .id = V4L2_CID_AUDIO_MUTE, | ||
682 | .name = "Mute", | ||
683 | .minimum = 0, | ||
684 | .maximum = 1, | ||
685 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
686 | },{ | ||
687 | .id = V4L2_CID_AUDIO_VOLUME, | ||
688 | .name = "Volume", | ||
689 | .minimum = 0, | ||
690 | .maximum = 65535, | ||
691 | .step = 65535/100, | ||
692 | .default_value = 65535, | ||
693 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
694 | },{ | ||
695 | .id = V4L2_CID_AUDIO_BALANCE, | ||
696 | .name = "Balance", | ||
697 | .minimum = 0, | ||
698 | .maximum = 65535, | ||
699 | .step = 65535/100, | ||
700 | .default_value = 32768, | ||
701 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
702 | },{ | ||
703 | .id = V4L2_CID_AUDIO_BASS, | ||
704 | .name = "Bass", | ||
705 | .minimum = 0, | ||
706 | .maximum = 65535, | ||
707 | .step = 65535/100, | ||
708 | .default_value = 32768, | ||
709 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
710 | },{ | ||
711 | .id = V4L2_CID_AUDIO_TREBLE, | ||
712 | .name = "Treble", | ||
713 | .minimum = 0, | ||
714 | .maximum = 65535, | ||
715 | .step = 65535/100, | ||
716 | .default_value = 32768, | ||
717 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
718 | }, | ||
719 | /* --- private --- */ | ||
720 | { | ||
721 | .id = V4L2_CID_PRIVATE_CHROMA_AGC, | ||
722 | .name = "chroma agc", | ||
723 | .minimum = 0, | ||
724 | .maximum = 1, | ||
725 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
726 | },{ | ||
727 | .id = V4L2_CID_PRIVATE_COMBFILTER, | ||
728 | .name = "combfilter", | ||
729 | .minimum = 0, | ||
730 | .maximum = 1, | ||
731 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
732 | },{ | ||
733 | .id = V4L2_CID_PRIVATE_AUTOMUTE, | ||
734 | .name = "automute", | ||
735 | .minimum = 0, | ||
736 | .maximum = 1, | ||
737 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
738 | },{ | ||
739 | .id = V4L2_CID_PRIVATE_LUMAFILTER, | ||
740 | .name = "luma decimation filter", | ||
741 | .minimum = 0, | ||
742 | .maximum = 1, | ||
743 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
744 | },{ | ||
745 | .id = V4L2_CID_PRIVATE_AGC_CRUSH, | ||
746 | .name = "agc crush", | ||
747 | .minimum = 0, | ||
748 | .maximum = 1, | ||
749 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
750 | },{ | ||
751 | .id = V4L2_CID_PRIVATE_VCR_HACK, | ||
752 | .name = "vcr hack", | ||
753 | .minimum = 0, | ||
754 | .maximum = 1, | ||
755 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
756 | },{ | ||
757 | .id = V4L2_CID_PRIVATE_WHITECRUSH_UPPER, | ||
758 | .name = "whitecrush upper", | ||
759 | .minimum = 0, | ||
760 | .maximum = 255, | ||
761 | .step = 1, | ||
762 | .default_value = 0xCF, | ||
763 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
764 | },{ | ||
765 | .id = V4L2_CID_PRIVATE_WHITECRUSH_LOWER, | ||
766 | .name = "whitecrush lower", | ||
767 | .minimum = 0, | ||
768 | .maximum = 255, | ||
769 | .step = 1, | ||
770 | .default_value = 0x7F, | ||
771 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
772 | },{ | ||
773 | .id = V4L2_CID_PRIVATE_UV_RATIO, | ||
774 | .name = "uv ratio", | ||
775 | .minimum = 0, | ||
776 | .maximum = 100, | ||
777 | .step = 1, | ||
778 | .default_value = 50, | ||
779 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
780 | },{ | ||
781 | .id = V4L2_CID_PRIVATE_FULL_LUMA_RANGE, | ||
782 | .name = "full luma range", | ||
783 | .minimum = 0, | ||
784 | .maximum = 1, | ||
785 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
786 | },{ | ||
787 | .id = V4L2_CID_PRIVATE_CORING, | ||
788 | .name = "coring", | ||
789 | .minimum = 0, | ||
790 | .maximum = 3, | ||
791 | .step = 1, | ||
792 | .default_value = 0, | ||
793 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
794 | } | ||
795 | |||
796 | |||
797 | |||
798 | }; | ||
799 | |||
800 | static const struct v4l2_queryctrl *ctrl_by_id(int id) | ||
801 | { | ||
802 | int i; | ||
803 | |||
804 | for (i = 0; i < ARRAY_SIZE(bttv_ctls); i++) | ||
805 | if (bttv_ctls[i].id == id) | ||
806 | return bttv_ctls+i; | ||
807 | |||
808 | return NULL; | ||
809 | } | ||
810 | |||
811 | /* ----------------------------------------------------------------------- */ | ||
812 | /* resource management */ | ||
813 | |||
814 | /* | ||
815 | RESOURCE_ allocated by freed by | ||
816 | |||
817 | VIDEO_READ bttv_read 1) bttv_read 2) | ||
818 | |||
819 | VIDEO_STREAM VIDIOC_STREAMON VIDIOC_STREAMOFF | ||
820 | VIDIOC_QBUF 1) bttv_release | ||
821 | VIDIOCMCAPTURE 1) | ||
822 | |||
823 | OVERLAY VIDIOCCAPTURE on VIDIOCCAPTURE off | ||
824 | VIDIOC_OVERLAY on VIDIOC_OVERLAY off | ||
825 | 3) bttv_release | ||
826 | |||
827 | VBI VIDIOC_STREAMON VIDIOC_STREAMOFF | ||
828 | VIDIOC_QBUF 1) bttv_release | ||
829 | bttv_read, bttv_poll 1) 4) | ||
830 | |||
831 | 1) The resource must be allocated when we enter buffer prepare functions | ||
832 | and remain allocated while buffers are in the DMA queue. | ||
833 | 2) This is a single frame read. | ||
834 | 3) VIDIOC_S_FBUF and VIDIOC_S_FMT (OVERLAY) still work when | ||
835 | RESOURCE_OVERLAY is allocated. | ||
836 | 4) This is a continuous read, implies VIDIOC_STREAMON. | ||
837 | |||
838 | Note this driver permits video input and standard changes regardless if | ||
839 | resources are allocated. | ||
840 | */ | ||
841 | |||
842 | #define VBI_RESOURCES (RESOURCE_VBI) | ||
843 | #define VIDEO_RESOURCES (RESOURCE_VIDEO_READ | \ | ||
844 | RESOURCE_VIDEO_STREAM | \ | ||
845 | RESOURCE_OVERLAY) | ||
846 | |||
847 | static | ||
848 | int check_alloc_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bit) | ||
849 | { | ||
850 | int xbits; /* mutual exclusive resources */ | ||
851 | |||
852 | if (fh->resources & bit) | ||
853 | /* have it already allocated */ | ||
854 | return 1; | ||
855 | |||
856 | xbits = bit; | ||
857 | if (bit & (RESOURCE_VIDEO_READ | RESOURCE_VIDEO_STREAM)) | ||
858 | xbits |= RESOURCE_VIDEO_READ | RESOURCE_VIDEO_STREAM; | ||
859 | |||
860 | /* is it free? */ | ||
861 | if (btv->resources & xbits) { | ||
862 | /* no, someone else uses it */ | ||
863 | goto fail; | ||
864 | } | ||
865 | |||
866 | if ((bit & VIDEO_RESOURCES) | ||
867 | && 0 == (btv->resources & VIDEO_RESOURCES)) { | ||
868 | /* Do crop - use current, don't - use default parameters. */ | ||
869 | __s32 top = btv->crop[!!fh->do_crop].rect.top; | ||
870 | |||
871 | if (btv->vbi_end > top) | ||
872 | goto fail; | ||
873 | |||
874 | /* We cannot capture the same line as video and VBI data. | ||
875 | Claim scan lines crop[].rect.top to bottom. */ | ||
876 | btv->crop_start = top; | ||
877 | } else if (bit & VBI_RESOURCES) { | ||
878 | __s32 end = fh->vbi_fmt.end; | ||
879 | |||
880 | if (end > btv->crop_start) | ||
881 | goto fail; | ||
882 | |||
883 | /* Claim scan lines above fh->vbi_fmt.end. */ | ||
884 | btv->vbi_end = end; | ||
885 | } | ||
886 | |||
887 | /* it's free, grab it */ | ||
888 | fh->resources |= bit; | ||
889 | btv->resources |= bit; | ||
890 | return 1; | ||
891 | |||
892 | fail: | ||
893 | return 0; | ||
894 | } | ||
895 | |||
896 | static | ||
897 | int check_btres(struct bttv_fh *fh, int bit) | ||
898 | { | ||
899 | return (fh->resources & bit); | ||
900 | } | ||
901 | |||
902 | static | ||
903 | int locked_btres(struct bttv *btv, int bit) | ||
904 | { | ||
905 | return (btv->resources & bit); | ||
906 | } | ||
907 | |||
908 | /* Call with btv->lock down. */ | ||
909 | static void | ||
910 | disclaim_vbi_lines(struct bttv *btv) | ||
911 | { | ||
912 | btv->vbi_end = 0; | ||
913 | } | ||
914 | |||
915 | /* Call with btv->lock down. */ | ||
916 | static void | ||
917 | disclaim_video_lines(struct bttv *btv) | ||
918 | { | ||
919 | const struct bttv_tvnorm *tvnorm; | ||
920 | u8 crop; | ||
921 | |||
922 | tvnorm = &bttv_tvnorms[btv->tvnorm]; | ||
923 | btv->crop_start = tvnorm->cropcap.bounds.top | ||
924 | + tvnorm->cropcap.bounds.height; | ||
925 | |||
926 | /* VBI capturing ends at VDELAY, start of video capturing, no | ||
927 | matter how many lines the VBI RISC program expects. When video | ||
928 | capturing is off, it shall no longer "preempt" VBI capturing, | ||
929 | so we set VDELAY to maximum. */ | ||
930 | crop = btread(BT848_E_CROP) | 0xc0; | ||
931 | btwrite(crop, BT848_E_CROP); | ||
932 | btwrite(0xfe, BT848_E_VDELAY_LO); | ||
933 | btwrite(crop, BT848_O_CROP); | ||
934 | btwrite(0xfe, BT848_O_VDELAY_LO); | ||
935 | } | ||
936 | |||
937 | static | ||
938 | void free_btres_lock(struct bttv *btv, struct bttv_fh *fh, int bits) | ||
939 | { | ||
940 | if ((fh->resources & bits) != bits) { | ||
941 | /* trying to free resources not allocated by us ... */ | ||
942 | pr_err("BUG! (btres)\n"); | ||
943 | } | ||
944 | fh->resources &= ~bits; | ||
945 | btv->resources &= ~bits; | ||
946 | |||
947 | bits = btv->resources; | ||
948 | |||
949 | if (0 == (bits & VIDEO_RESOURCES)) | ||
950 | disclaim_video_lines(btv); | ||
951 | |||
952 | if (0 == (bits & VBI_RESOURCES)) | ||
953 | disclaim_vbi_lines(btv); | ||
954 | } | ||
955 | |||
956 | /* ----------------------------------------------------------------------- */ | ||
957 | /* If Bt848a or Bt849, use PLL for PAL/SECAM and crystal for NTSC */ | ||
958 | |||
959 | /* Frequency = (F_input / PLL_X) * PLL_I.PLL_F/PLL_C | ||
960 | PLL_X = Reference pre-divider (0=1, 1=2) | ||
961 | PLL_C = Post divider (0=6, 1=4) | ||
962 | PLL_I = Integer input | ||
963 | PLL_F = Fractional input | ||
964 | |||
965 | F_input = 28.636363 MHz: | ||
966 | PAL (CLKx2 = 35.46895 MHz): PLL_X = 1, PLL_I = 0x0E, PLL_F = 0xDCF9, PLL_C = 0 | ||
967 | */ | ||
968 | |||
969 | static void set_pll_freq(struct bttv *btv, unsigned int fin, unsigned int fout) | ||
970 | { | ||
971 | unsigned char fl, fh, fi; | ||
972 | |||
973 | /* prevent overflows */ | ||
974 | fin/=4; | ||
975 | fout/=4; | ||
976 | |||
977 | fout*=12; | ||
978 | fi=fout/fin; | ||
979 | |||
980 | fout=(fout%fin)*256; | ||
981 | fh=fout/fin; | ||
982 | |||
983 | fout=(fout%fin)*256; | ||
984 | fl=fout/fin; | ||
985 | |||
986 | btwrite(fl, BT848_PLL_F_LO); | ||
987 | btwrite(fh, BT848_PLL_F_HI); | ||
988 | btwrite(fi|BT848_PLL_X, BT848_PLL_XCI); | ||
989 | } | ||
990 | |||
991 | static void set_pll(struct bttv *btv) | ||
992 | { | ||
993 | int i; | ||
994 | |||
995 | if (!btv->pll.pll_crystal) | ||
996 | return; | ||
997 | |||
998 | if (btv->pll.pll_ofreq == btv->pll.pll_current) { | ||
999 | dprintk("%d: PLL: no change required\n", btv->c.nr); | ||
1000 | return; | ||
1001 | } | ||
1002 | |||
1003 | if (btv->pll.pll_ifreq == btv->pll.pll_ofreq) { | ||
1004 | /* no PLL needed */ | ||
1005 | if (btv->pll.pll_current == 0) | ||
1006 | return; | ||
1007 | if (bttv_verbose) | ||
1008 | pr_info("%d: PLL can sleep, using XTAL (%d)\n", | ||
1009 | btv->c.nr, btv->pll.pll_ifreq); | ||
1010 | btwrite(0x00,BT848_TGCTRL); | ||
1011 | btwrite(0x00,BT848_PLL_XCI); | ||
1012 | btv->pll.pll_current = 0; | ||
1013 | return; | ||
1014 | } | ||
1015 | |||
1016 | if (bttv_verbose) | ||
1017 | pr_info("%d: Setting PLL: %d => %d (needs up to 100ms)\n", | ||
1018 | btv->c.nr, | ||
1019 | btv->pll.pll_ifreq, btv->pll.pll_ofreq); | ||
1020 | set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq); | ||
1021 | |||
1022 | for (i=0; i<10; i++) { | ||
1023 | /* Let other people run while the PLL stabilizes */ | ||
1024 | msleep(10); | ||
1025 | |||
1026 | if (btread(BT848_DSTATUS) & BT848_DSTATUS_PLOCK) { | ||
1027 | btwrite(0,BT848_DSTATUS); | ||
1028 | } else { | ||
1029 | btwrite(0x08,BT848_TGCTRL); | ||
1030 | btv->pll.pll_current = btv->pll.pll_ofreq; | ||
1031 | if (bttv_verbose) | ||
1032 | pr_info("PLL set ok\n"); | ||
1033 | return; | ||
1034 | } | ||
1035 | } | ||
1036 | btv->pll.pll_current = -1; | ||
1037 | if (bttv_verbose) | ||
1038 | pr_info("Setting PLL failed\n"); | ||
1039 | return; | ||
1040 | } | ||
1041 | |||
1042 | /* used to switch between the bt848's analog/digital video capture modes */ | ||
1043 | static void bt848A_set_timing(struct bttv *btv) | ||
1044 | { | ||
1045 | int i, len; | ||
1046 | int table_idx = bttv_tvnorms[btv->tvnorm].sram; | ||
1047 | int fsc = bttv_tvnorms[btv->tvnorm].Fsc; | ||
1048 | |||
1049 | if (btv->input == btv->dig) { | ||
1050 | dprintk("%d: load digital timing table (table_idx=%d)\n", | ||
1051 | btv->c.nr,table_idx); | ||
1052 | |||
1053 | /* timing change...reset timing generator address */ | ||
1054 | btwrite(0x00, BT848_TGCTRL); | ||
1055 | btwrite(0x02, BT848_TGCTRL); | ||
1056 | btwrite(0x00, BT848_TGCTRL); | ||
1057 | |||
1058 | len=SRAM_Table[table_idx][0]; | ||
1059 | for(i = 1; i <= len; i++) | ||
1060 | btwrite(SRAM_Table[table_idx][i],BT848_TGLB); | ||
1061 | btv->pll.pll_ofreq = 27000000; | ||
1062 | |||
1063 | set_pll(btv); | ||
1064 | btwrite(0x11, BT848_TGCTRL); | ||
1065 | btwrite(0x41, BT848_DVSIF); | ||
1066 | } else { | ||
1067 | btv->pll.pll_ofreq = fsc; | ||
1068 | set_pll(btv); | ||
1069 | btwrite(0x0, BT848_DVSIF); | ||
1070 | } | ||
1071 | } | ||
1072 | |||
1073 | /* ----------------------------------------------------------------------- */ | ||
1074 | |||
1075 | static void bt848_bright(struct bttv *btv, int bright) | ||
1076 | { | ||
1077 | int value; | ||
1078 | |||
1079 | // printk("set bright: %d\n", bright); // DEBUG | ||
1080 | btv->bright = bright; | ||
1081 | |||
1082 | /* We want -128 to 127 we get 0-65535 */ | ||
1083 | value = (bright >> 8) - 128; | ||
1084 | btwrite(value & 0xff, BT848_BRIGHT); | ||
1085 | } | ||
1086 | |||
1087 | static void bt848_hue(struct bttv *btv, int hue) | ||
1088 | { | ||
1089 | int value; | ||
1090 | |||
1091 | btv->hue = hue; | ||
1092 | |||
1093 | /* -128 to 127 */ | ||
1094 | value = (hue >> 8) - 128; | ||
1095 | btwrite(value & 0xff, BT848_HUE); | ||
1096 | } | ||
1097 | |||
1098 | static void bt848_contrast(struct bttv *btv, int cont) | ||
1099 | { | ||
1100 | int value,hibit; | ||
1101 | |||
1102 | btv->contrast = cont; | ||
1103 | |||
1104 | /* 0-511 */ | ||
1105 | value = (cont >> 7); | ||
1106 | hibit = (value >> 6) & 4; | ||
1107 | btwrite(value & 0xff, BT848_CONTRAST_LO); | ||
1108 | btaor(hibit, ~4, BT848_E_CONTROL); | ||
1109 | btaor(hibit, ~4, BT848_O_CONTROL); | ||
1110 | } | ||
1111 | |||
1112 | static void bt848_sat(struct bttv *btv, int color) | ||
1113 | { | ||
1114 | int val_u,val_v,hibits; | ||
1115 | |||
1116 | btv->saturation = color; | ||
1117 | |||
1118 | /* 0-511 for the color */ | ||
1119 | val_u = ((color * btv->opt_uv_ratio) / 50) >> 7; | ||
1120 | val_v = (((color * (100 - btv->opt_uv_ratio) / 50) >>7)*180L)/254; | ||
1121 | hibits = (val_u >> 7) & 2; | ||
1122 | hibits |= (val_v >> 8) & 1; | ||
1123 | btwrite(val_u & 0xff, BT848_SAT_U_LO); | ||
1124 | btwrite(val_v & 0xff, BT848_SAT_V_LO); | ||
1125 | btaor(hibits, ~3, BT848_E_CONTROL); | ||
1126 | btaor(hibits, ~3, BT848_O_CONTROL); | ||
1127 | } | ||
1128 | |||
1129 | /* ----------------------------------------------------------------------- */ | ||
1130 | |||
1131 | static int | ||
1132 | video_mux(struct bttv *btv, unsigned int input) | ||
1133 | { | ||
1134 | int mux,mask2; | ||
1135 | |||
1136 | if (input >= bttv_tvcards[btv->c.type].video_inputs) | ||
1137 | return -EINVAL; | ||
1138 | |||
1139 | /* needed by RemoteVideo MX */ | ||
1140 | mask2 = bttv_tvcards[btv->c.type].gpiomask2; | ||
1141 | if (mask2) | ||
1142 | gpio_inout(mask2,mask2); | ||
1143 | |||
1144 | if (input == btv->svhs) { | ||
1145 | btor(BT848_CONTROL_COMP, BT848_E_CONTROL); | ||
1146 | btor(BT848_CONTROL_COMP, BT848_O_CONTROL); | ||
1147 | } else { | ||
1148 | btand(~BT848_CONTROL_COMP, BT848_E_CONTROL); | ||
1149 | btand(~BT848_CONTROL_COMP, BT848_O_CONTROL); | ||
1150 | } | ||
1151 | mux = bttv_muxsel(btv, input); | ||
1152 | btaor(mux<<5, ~(3<<5), BT848_IFORM); | ||
1153 | dprintk("%d: video mux: input=%d mux=%d\n", btv->c.nr, input, mux); | ||
1154 | |||
1155 | /* card specific hook */ | ||
1156 | if(bttv_tvcards[btv->c.type].muxsel_hook) | ||
1157 | bttv_tvcards[btv->c.type].muxsel_hook (btv, input); | ||
1158 | return 0; | ||
1159 | } | ||
1160 | |||
1161 | static char *audio_modes[] = { | ||
1162 | "audio: tuner", "audio: radio", "audio: extern", | ||
1163 | "audio: intern", "audio: mute" | ||
1164 | }; | ||
1165 | |||
1166 | static int | ||
1167 | audio_mux(struct bttv *btv, int input, int mute) | ||
1168 | { | ||
1169 | int gpio_val, signal; | ||
1170 | struct v4l2_control ctrl; | ||
1171 | |||
1172 | gpio_inout(bttv_tvcards[btv->c.type].gpiomask, | ||
1173 | bttv_tvcards[btv->c.type].gpiomask); | ||
1174 | signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC; | ||
1175 | |||
1176 | btv->mute = mute; | ||
1177 | btv->audio = input; | ||
1178 | |||
1179 | /* automute */ | ||
1180 | mute = mute || (btv->opt_automute && !signal && !btv->radio_user); | ||
1181 | |||
1182 | if (mute) | ||
1183 | gpio_val = bttv_tvcards[btv->c.type].gpiomute; | ||
1184 | else | ||
1185 | gpio_val = bttv_tvcards[btv->c.type].gpiomux[input]; | ||
1186 | |||
1187 | switch (btv->c.type) { | ||
1188 | case BTTV_BOARD_VOODOOTV_FM: | ||
1189 | case BTTV_BOARD_VOODOOTV_200: | ||
1190 | gpio_val = bttv_tda9880_setnorm(btv, gpio_val); | ||
1191 | break; | ||
1192 | |||
1193 | default: | ||
1194 | gpio_bits(bttv_tvcards[btv->c.type].gpiomask, gpio_val); | ||
1195 | } | ||
1196 | |||
1197 | if (bttv_gpio) | ||
1198 | bttv_gpio_tracking(btv, audio_modes[mute ? 4 : input]); | ||
1199 | if (in_interrupt()) | ||
1200 | return 0; | ||
1201 | |||
1202 | ctrl.id = V4L2_CID_AUDIO_MUTE; | ||
1203 | ctrl.value = btv->mute; | ||
1204 | bttv_call_all(btv, core, s_ctrl, &ctrl); | ||
1205 | if (btv->sd_msp34xx) { | ||
1206 | u32 in; | ||
1207 | |||
1208 | /* Note: the inputs tuner/radio/extern/intern are translated | ||
1209 | to msp routings. This assumes common behavior for all msp3400 | ||
1210 | based TV cards. When this assumption fails, then the | ||
1211 | specific MSP routing must be added to the card table. | ||
1212 | For now this is sufficient. */ | ||
1213 | switch (input) { | ||
1214 | case TVAUDIO_INPUT_RADIO: | ||
1215 | /* Some boards need the msp do to the radio demod */ | ||
1216 | if (btv->radio_uses_msp_demodulator) { | ||
1217 | in = MSP_INPUT_DEFAULT; | ||
1218 | break; | ||
1219 | } | ||
1220 | in = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1, | ||
1221 | MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); | ||
1222 | break; | ||
1223 | case TVAUDIO_INPUT_EXTERN: | ||
1224 | in = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1, | ||
1225 | MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); | ||
1226 | break; | ||
1227 | case TVAUDIO_INPUT_INTERN: | ||
1228 | /* Yes, this is the same input as for RADIO. I doubt | ||
1229 | if this is ever used. The only board with an INTERN | ||
1230 | input is the BTTV_BOARD_AVERMEDIA98. I wonder how | ||
1231 | that was tested. My guess is that the whole INTERN | ||
1232 | input does not work. */ | ||
1233 | in = MSP_INPUT(MSP_IN_SCART2, MSP_IN_TUNER1, | ||
1234 | MSP_DSP_IN_SCART, MSP_DSP_IN_SCART); | ||
1235 | break; | ||
1236 | case TVAUDIO_INPUT_TUNER: | ||
1237 | default: | ||
1238 | /* This is the only card that uses TUNER2, and afaik, | ||
1239 | is the only difference between the VOODOOTV_FM | ||
1240 | and VOODOOTV_200 */ | ||
1241 | if (btv->c.type == BTTV_BOARD_VOODOOTV_200) | ||
1242 | in = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER2, \ | ||
1243 | MSP_DSP_IN_TUNER, MSP_DSP_IN_TUNER); | ||
1244 | else | ||
1245 | in = MSP_INPUT_DEFAULT; | ||
1246 | break; | ||
1247 | } | ||
1248 | v4l2_subdev_call(btv->sd_msp34xx, audio, s_routing, | ||
1249 | in, MSP_OUTPUT_DEFAULT, 0); | ||
1250 | } | ||
1251 | if (btv->sd_tvaudio) { | ||
1252 | v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing, | ||
1253 | input, 0, 0); | ||
1254 | } | ||
1255 | return 0; | ||
1256 | } | ||
1257 | |||
1258 | static inline int | ||
1259 | audio_mute(struct bttv *btv, int mute) | ||
1260 | { | ||
1261 | return audio_mux(btv, btv->audio, mute); | ||
1262 | } | ||
1263 | |||
1264 | static inline int | ||
1265 | audio_input(struct bttv *btv, int input) | ||
1266 | { | ||
1267 | return audio_mux(btv, input, btv->mute); | ||
1268 | } | ||
1269 | |||
1270 | static void | ||
1271 | bttv_crop_calc_limits(struct bttv_crop *c) | ||
1272 | { | ||
1273 | /* Scale factor min. 1:1, max. 16:1. Min. image size | ||
1274 | 48 x 32. Scaled width must be a multiple of 4. */ | ||
1275 | |||
1276 | if (1) { | ||
1277 | /* For bug compatibility with VIDIOCGCAP and image | ||
1278 | size checks in earlier driver versions. */ | ||
1279 | c->min_scaled_width = 48; | ||
1280 | c->min_scaled_height = 32; | ||
1281 | } else { | ||
1282 | c->min_scaled_width = | ||
1283 | (max(48, c->rect.width >> 4) + 3) & ~3; | ||
1284 | c->min_scaled_height = | ||
1285 | max(32, c->rect.height >> 4); | ||
1286 | } | ||
1287 | |||
1288 | c->max_scaled_width = c->rect.width & ~3; | ||
1289 | c->max_scaled_height = c->rect.height; | ||
1290 | } | ||
1291 | |||
1292 | static void | ||
1293 | bttv_crop_reset(struct bttv_crop *c, unsigned int norm) | ||
1294 | { | ||
1295 | c->rect = bttv_tvnorms[norm].cropcap.defrect; | ||
1296 | bttv_crop_calc_limits(c); | ||
1297 | } | ||
1298 | |||
1299 | /* Call with btv->lock down. */ | ||
1300 | static int | ||
1301 | set_tvnorm(struct bttv *btv, unsigned int norm) | ||
1302 | { | ||
1303 | const struct bttv_tvnorm *tvnorm; | ||
1304 | v4l2_std_id id; | ||
1305 | |||
1306 | BUG_ON(norm >= BTTV_TVNORMS); | ||
1307 | BUG_ON(btv->tvnorm >= BTTV_TVNORMS); | ||
1308 | |||
1309 | tvnorm = &bttv_tvnorms[norm]; | ||
1310 | |||
1311 | if (memcmp(&bttv_tvnorms[btv->tvnorm].cropcap, &tvnorm->cropcap, | ||
1312 | sizeof (tvnorm->cropcap))) { | ||
1313 | bttv_crop_reset(&btv->crop[0], norm); | ||
1314 | btv->crop[1] = btv->crop[0]; /* current = default */ | ||
1315 | |||
1316 | if (0 == (btv->resources & VIDEO_RESOURCES)) { | ||
1317 | btv->crop_start = tvnorm->cropcap.bounds.top | ||
1318 | + tvnorm->cropcap.bounds.height; | ||
1319 | } | ||
1320 | } | ||
1321 | |||
1322 | btv->tvnorm = norm; | ||
1323 | |||
1324 | btwrite(tvnorm->adelay, BT848_ADELAY); | ||
1325 | btwrite(tvnorm->bdelay, BT848_BDELAY); | ||
1326 | btaor(tvnorm->iform,~(BT848_IFORM_NORM|BT848_IFORM_XTBOTH), | ||
1327 | BT848_IFORM); | ||
1328 | btwrite(tvnorm->vbipack, BT848_VBI_PACK_SIZE); | ||
1329 | btwrite(1, BT848_VBI_PACK_DEL); | ||
1330 | bt848A_set_timing(btv); | ||
1331 | |||
1332 | switch (btv->c.type) { | ||
1333 | case BTTV_BOARD_VOODOOTV_FM: | ||
1334 | case BTTV_BOARD_VOODOOTV_200: | ||
1335 | bttv_tda9880_setnorm(btv, gpio_read()); | ||
1336 | break; | ||
1337 | } | ||
1338 | id = tvnorm->v4l2_id; | ||
1339 | bttv_call_all(btv, core, s_std, id); | ||
1340 | |||
1341 | return 0; | ||
1342 | } | ||
1343 | |||
1344 | /* Call with btv->lock down. */ | ||
1345 | static void | ||
1346 | set_input(struct bttv *btv, unsigned int input, unsigned int norm) | ||
1347 | { | ||
1348 | unsigned long flags; | ||
1349 | |||
1350 | btv->input = input; | ||
1351 | if (irq_iswitch) { | ||
1352 | spin_lock_irqsave(&btv->s_lock,flags); | ||
1353 | if (btv->curr.frame_irq) { | ||
1354 | /* active capture -> delayed input switch */ | ||
1355 | btv->new_input = input; | ||
1356 | } else { | ||
1357 | video_mux(btv,input); | ||
1358 | } | ||
1359 | spin_unlock_irqrestore(&btv->s_lock,flags); | ||
1360 | } else { | ||
1361 | video_mux(btv,input); | ||
1362 | } | ||
1363 | audio_input(btv, (btv->tuner_type != TUNER_ABSENT && input == 0) ? | ||
1364 | TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN); | ||
1365 | set_tvnorm(btv, norm); | ||
1366 | } | ||
1367 | |||
1368 | static void init_irqreg(struct bttv *btv) | ||
1369 | { | ||
1370 | /* clear status */ | ||
1371 | btwrite(0xfffffUL, BT848_INT_STAT); | ||
1372 | |||
1373 | if (bttv_tvcards[btv->c.type].no_video) { | ||
1374 | /* i2c only */ | ||
1375 | btwrite(BT848_INT_I2CDONE, | ||
1376 | BT848_INT_MASK); | ||
1377 | } else { | ||
1378 | /* full video */ | ||
1379 | btwrite((btv->triton1) | | ||
1380 | (btv->gpioirq ? BT848_INT_GPINT : 0) | | ||
1381 | BT848_INT_SCERR | | ||
1382 | (fdsr ? BT848_INT_FDSR : 0) | | ||
1383 | BT848_INT_RISCI | BT848_INT_OCERR | | ||
1384 | BT848_INT_FMTCHG|BT848_INT_HLOCK| | ||
1385 | BT848_INT_I2CDONE, | ||
1386 | BT848_INT_MASK); | ||
1387 | } | ||
1388 | } | ||
1389 | |||
1390 | static void init_bt848(struct bttv *btv) | ||
1391 | { | ||
1392 | int val; | ||
1393 | |||
1394 | if (bttv_tvcards[btv->c.type].no_video) { | ||
1395 | /* very basic init only */ | ||
1396 | init_irqreg(btv); | ||
1397 | return; | ||
1398 | } | ||
1399 | |||
1400 | btwrite(0x00, BT848_CAP_CTL); | ||
1401 | btwrite(BT848_COLOR_CTL_GAMMA, BT848_COLOR_CTL); | ||
1402 | btwrite(BT848_IFORM_XTAUTO | BT848_IFORM_AUTO, BT848_IFORM); | ||
1403 | |||
1404 | /* set planar and packed mode trigger points and */ | ||
1405 | /* set rising edge of inverted GPINTR pin as irq trigger */ | ||
1406 | btwrite(BT848_GPIO_DMA_CTL_PKTP_32| | ||
1407 | BT848_GPIO_DMA_CTL_PLTP1_16| | ||
1408 | BT848_GPIO_DMA_CTL_PLTP23_16| | ||
1409 | BT848_GPIO_DMA_CTL_GPINTC| | ||
1410 | BT848_GPIO_DMA_CTL_GPINTI, | ||
1411 | BT848_GPIO_DMA_CTL); | ||
1412 | |||
1413 | val = btv->opt_chroma_agc ? BT848_SCLOOP_CAGC : 0; | ||
1414 | btwrite(val, BT848_E_SCLOOP); | ||
1415 | btwrite(val, BT848_O_SCLOOP); | ||
1416 | |||
1417 | btwrite(0x20, BT848_E_VSCALE_HI); | ||
1418 | btwrite(0x20, BT848_O_VSCALE_HI); | ||
1419 | btwrite(BT848_ADC_RESERVED | (btv->opt_adc_crush ? BT848_ADC_CRUSH : 0), | ||
1420 | BT848_ADC); | ||
1421 | |||
1422 | btwrite(whitecrush_upper, BT848_WC_UP); | ||
1423 | btwrite(whitecrush_lower, BT848_WC_DOWN); | ||
1424 | |||
1425 | if (btv->opt_lumafilter) { | ||
1426 | btwrite(0, BT848_E_CONTROL); | ||
1427 | btwrite(0, BT848_O_CONTROL); | ||
1428 | } else { | ||
1429 | btwrite(BT848_CONTROL_LDEC, BT848_E_CONTROL); | ||
1430 | btwrite(BT848_CONTROL_LDEC, BT848_O_CONTROL); | ||
1431 | } | ||
1432 | |||
1433 | bt848_bright(btv, btv->bright); | ||
1434 | bt848_hue(btv, btv->hue); | ||
1435 | bt848_contrast(btv, btv->contrast); | ||
1436 | bt848_sat(btv, btv->saturation); | ||
1437 | |||
1438 | /* interrupt */ | ||
1439 | init_irqreg(btv); | ||
1440 | } | ||
1441 | |||
1442 | static void bttv_reinit_bt848(struct bttv *btv) | ||
1443 | { | ||
1444 | unsigned long flags; | ||
1445 | |||
1446 | if (bttv_verbose) | ||
1447 | pr_info("%d: reset, reinitialize\n", btv->c.nr); | ||
1448 | spin_lock_irqsave(&btv->s_lock,flags); | ||
1449 | btv->errors=0; | ||
1450 | bttv_set_dma(btv,0); | ||
1451 | spin_unlock_irqrestore(&btv->s_lock,flags); | ||
1452 | |||
1453 | init_bt848(btv); | ||
1454 | btv->pll.pll_current = -1; | ||
1455 | set_input(btv, btv->input, btv->tvnorm); | ||
1456 | } | ||
1457 | |||
1458 | static int bttv_g_ctrl(struct file *file, void *priv, | ||
1459 | struct v4l2_control *c) | ||
1460 | { | ||
1461 | struct bttv_fh *fh = priv; | ||
1462 | struct bttv *btv = fh->btv; | ||
1463 | |||
1464 | switch (c->id) { | ||
1465 | case V4L2_CID_BRIGHTNESS: | ||
1466 | c->value = btv->bright; | ||
1467 | break; | ||
1468 | case V4L2_CID_HUE: | ||
1469 | c->value = btv->hue; | ||
1470 | break; | ||
1471 | case V4L2_CID_CONTRAST: | ||
1472 | c->value = btv->contrast; | ||
1473 | break; | ||
1474 | case V4L2_CID_SATURATION: | ||
1475 | c->value = btv->saturation; | ||
1476 | break; | ||
1477 | |||
1478 | case V4L2_CID_AUDIO_MUTE: | ||
1479 | case V4L2_CID_AUDIO_VOLUME: | ||
1480 | case V4L2_CID_AUDIO_BALANCE: | ||
1481 | case V4L2_CID_AUDIO_BASS: | ||
1482 | case V4L2_CID_AUDIO_TREBLE: | ||
1483 | bttv_call_all(btv, core, g_ctrl, c); | ||
1484 | break; | ||
1485 | |||
1486 | case V4L2_CID_PRIVATE_CHROMA_AGC: | ||
1487 | c->value = btv->opt_chroma_agc; | ||
1488 | break; | ||
1489 | case V4L2_CID_PRIVATE_COMBFILTER: | ||
1490 | c->value = btv->opt_combfilter; | ||
1491 | break; | ||
1492 | case V4L2_CID_PRIVATE_LUMAFILTER: | ||
1493 | c->value = btv->opt_lumafilter; | ||
1494 | break; | ||
1495 | case V4L2_CID_PRIVATE_AUTOMUTE: | ||
1496 | c->value = btv->opt_automute; | ||
1497 | break; | ||
1498 | case V4L2_CID_PRIVATE_AGC_CRUSH: | ||
1499 | c->value = btv->opt_adc_crush; | ||
1500 | break; | ||
1501 | case V4L2_CID_PRIVATE_VCR_HACK: | ||
1502 | c->value = btv->opt_vcr_hack; | ||
1503 | break; | ||
1504 | case V4L2_CID_PRIVATE_WHITECRUSH_UPPER: | ||
1505 | c->value = btv->opt_whitecrush_upper; | ||
1506 | break; | ||
1507 | case V4L2_CID_PRIVATE_WHITECRUSH_LOWER: | ||
1508 | c->value = btv->opt_whitecrush_lower; | ||
1509 | break; | ||
1510 | case V4L2_CID_PRIVATE_UV_RATIO: | ||
1511 | c->value = btv->opt_uv_ratio; | ||
1512 | break; | ||
1513 | case V4L2_CID_PRIVATE_FULL_LUMA_RANGE: | ||
1514 | c->value = btv->opt_full_luma_range; | ||
1515 | break; | ||
1516 | case V4L2_CID_PRIVATE_CORING: | ||
1517 | c->value = btv->opt_coring; | ||
1518 | break; | ||
1519 | default: | ||
1520 | return -EINVAL; | ||
1521 | } | ||
1522 | return 0; | ||
1523 | } | ||
1524 | |||
1525 | static int bttv_s_ctrl(struct file *file, void *f, | ||
1526 | struct v4l2_control *c) | ||
1527 | { | ||
1528 | int err; | ||
1529 | int val; | ||
1530 | struct bttv_fh *fh = f; | ||
1531 | struct bttv *btv = fh->btv; | ||
1532 | |||
1533 | err = v4l2_prio_check(&btv->prio, fh->prio); | ||
1534 | if (0 != err) | ||
1535 | return err; | ||
1536 | |||
1537 | switch (c->id) { | ||
1538 | case V4L2_CID_BRIGHTNESS: | ||
1539 | bt848_bright(btv, c->value); | ||
1540 | break; | ||
1541 | case V4L2_CID_HUE: | ||
1542 | bt848_hue(btv, c->value); | ||
1543 | break; | ||
1544 | case V4L2_CID_CONTRAST: | ||
1545 | bt848_contrast(btv, c->value); | ||
1546 | break; | ||
1547 | case V4L2_CID_SATURATION: | ||
1548 | bt848_sat(btv, c->value); | ||
1549 | break; | ||
1550 | case V4L2_CID_AUDIO_MUTE: | ||
1551 | audio_mute(btv, c->value); | ||
1552 | /* fall through */ | ||
1553 | case V4L2_CID_AUDIO_VOLUME: | ||
1554 | if (btv->volume_gpio) | ||
1555 | btv->volume_gpio(btv, c->value); | ||
1556 | |||
1557 | bttv_call_all(btv, core, s_ctrl, c); | ||
1558 | break; | ||
1559 | case V4L2_CID_AUDIO_BALANCE: | ||
1560 | case V4L2_CID_AUDIO_BASS: | ||
1561 | case V4L2_CID_AUDIO_TREBLE: | ||
1562 | bttv_call_all(btv, core, s_ctrl, c); | ||
1563 | break; | ||
1564 | |||
1565 | case V4L2_CID_PRIVATE_CHROMA_AGC: | ||
1566 | btv->opt_chroma_agc = c->value; | ||
1567 | val = btv->opt_chroma_agc ? BT848_SCLOOP_CAGC : 0; | ||
1568 | btwrite(val, BT848_E_SCLOOP); | ||
1569 | btwrite(val, BT848_O_SCLOOP); | ||
1570 | break; | ||
1571 | case V4L2_CID_PRIVATE_COMBFILTER: | ||
1572 | btv->opt_combfilter = c->value; | ||
1573 | break; | ||
1574 | case V4L2_CID_PRIVATE_LUMAFILTER: | ||
1575 | btv->opt_lumafilter = c->value; | ||
1576 | if (btv->opt_lumafilter) { | ||
1577 | btand(~BT848_CONTROL_LDEC, BT848_E_CONTROL); | ||
1578 | btand(~BT848_CONTROL_LDEC, BT848_O_CONTROL); | ||
1579 | } else { | ||
1580 | btor(BT848_CONTROL_LDEC, BT848_E_CONTROL); | ||
1581 | btor(BT848_CONTROL_LDEC, BT848_O_CONTROL); | ||
1582 | } | ||
1583 | break; | ||
1584 | case V4L2_CID_PRIVATE_AUTOMUTE: | ||
1585 | btv->opt_automute = c->value; | ||
1586 | break; | ||
1587 | case V4L2_CID_PRIVATE_AGC_CRUSH: | ||
1588 | btv->opt_adc_crush = c->value; | ||
1589 | btwrite(BT848_ADC_RESERVED | | ||
1590 | (btv->opt_adc_crush ? BT848_ADC_CRUSH : 0), | ||
1591 | BT848_ADC); | ||
1592 | break; | ||
1593 | case V4L2_CID_PRIVATE_VCR_HACK: | ||
1594 | btv->opt_vcr_hack = c->value; | ||
1595 | break; | ||
1596 | case V4L2_CID_PRIVATE_WHITECRUSH_UPPER: | ||
1597 | btv->opt_whitecrush_upper = c->value; | ||
1598 | btwrite(c->value, BT848_WC_UP); | ||
1599 | break; | ||
1600 | case V4L2_CID_PRIVATE_WHITECRUSH_LOWER: | ||
1601 | btv->opt_whitecrush_lower = c->value; | ||
1602 | btwrite(c->value, BT848_WC_DOWN); | ||
1603 | break; | ||
1604 | case V4L2_CID_PRIVATE_UV_RATIO: | ||
1605 | btv->opt_uv_ratio = c->value; | ||
1606 | bt848_sat(btv, btv->saturation); | ||
1607 | break; | ||
1608 | case V4L2_CID_PRIVATE_FULL_LUMA_RANGE: | ||
1609 | btv->opt_full_luma_range = c->value; | ||
1610 | btaor((c->value<<7), ~BT848_OFORM_RANGE, BT848_OFORM); | ||
1611 | break; | ||
1612 | case V4L2_CID_PRIVATE_CORING: | ||
1613 | btv->opt_coring = c->value; | ||
1614 | btaor((c->value<<5), ~BT848_OFORM_CORE32, BT848_OFORM); | ||
1615 | break; | ||
1616 | default: | ||
1617 | return -EINVAL; | ||
1618 | } | ||
1619 | return 0; | ||
1620 | } | ||
1621 | |||
1622 | /* ----------------------------------------------------------------------- */ | ||
1623 | |||
1624 | void bttv_gpio_tracking(struct bttv *btv, char *comment) | ||
1625 | { | ||
1626 | unsigned int outbits, data; | ||
1627 | outbits = btread(BT848_GPIO_OUT_EN); | ||
1628 | data = btread(BT848_GPIO_DATA); | ||
1629 | pr_debug("%d: gpio: en=%08x, out=%08x in=%08x [%s]\n", | ||
1630 | btv->c.nr, outbits, data & outbits, data & ~outbits, comment); | ||
1631 | } | ||
1632 | |||
1633 | static void bttv_field_count(struct bttv *btv) | ||
1634 | { | ||
1635 | int need_count = 0; | ||
1636 | |||
1637 | if (btv->users) | ||
1638 | need_count++; | ||
1639 | |||
1640 | if (need_count) { | ||
1641 | /* start field counter */ | ||
1642 | btor(BT848_INT_VSYNC,BT848_INT_MASK); | ||
1643 | } else { | ||
1644 | /* stop field counter */ | ||
1645 | btand(~BT848_INT_VSYNC,BT848_INT_MASK); | ||
1646 | btv->field_count = 0; | ||
1647 | } | ||
1648 | } | ||
1649 | |||
1650 | static const struct bttv_format* | ||
1651 | format_by_fourcc(int fourcc) | ||
1652 | { | ||
1653 | unsigned int i; | ||
1654 | |||
1655 | for (i = 0; i < FORMATS; i++) { | ||
1656 | if (-1 == formats[i].fourcc) | ||
1657 | continue; | ||
1658 | if (formats[i].fourcc == fourcc) | ||
1659 | return formats+i; | ||
1660 | } | ||
1661 | return NULL; | ||
1662 | } | ||
1663 | |||
1664 | /* ----------------------------------------------------------------------- */ | ||
1665 | /* misc helpers */ | ||
1666 | |||
1667 | static int | ||
1668 | bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh, | ||
1669 | struct bttv_buffer *new) | ||
1670 | { | ||
1671 | struct bttv_buffer *old; | ||
1672 | unsigned long flags; | ||
1673 | int retval = 0; | ||
1674 | |||
1675 | dprintk("switch_overlay: enter [new=%p]\n", new); | ||
1676 | if (new) | ||
1677 | new->vb.state = VIDEOBUF_DONE; | ||
1678 | spin_lock_irqsave(&btv->s_lock,flags); | ||
1679 | old = btv->screen; | ||
1680 | btv->screen = new; | ||
1681 | btv->loop_irq |= 1; | ||
1682 | bttv_set_dma(btv, 0x03); | ||
1683 | spin_unlock_irqrestore(&btv->s_lock,flags); | ||
1684 | if (NULL != old) { | ||
1685 | dprintk("switch_overlay: old=%p state is %d\n", | ||
1686 | old, old->vb.state); | ||
1687 | bttv_dma_free(&fh->cap,btv, old); | ||
1688 | kfree(old); | ||
1689 | } | ||
1690 | if (NULL == new) | ||
1691 | free_btres_lock(btv,fh,RESOURCE_OVERLAY); | ||
1692 | dprintk("switch_overlay: done\n"); | ||
1693 | return retval; | ||
1694 | } | ||
1695 | |||
1696 | /* ----------------------------------------------------------------------- */ | ||
1697 | /* video4linux (1) interface */ | ||
1698 | |||
1699 | static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv, | ||
1700 | struct bttv_buffer *buf, | ||
1701 | const struct bttv_format *fmt, | ||
1702 | unsigned int width, unsigned int height, | ||
1703 | enum v4l2_field field) | ||
1704 | { | ||
1705 | struct bttv_fh *fh = q->priv_data; | ||
1706 | int redo_dma_risc = 0; | ||
1707 | struct bttv_crop c; | ||
1708 | int norm; | ||
1709 | int rc; | ||
1710 | |||
1711 | /* check settings */ | ||
1712 | if (NULL == fmt) | ||
1713 | return -EINVAL; | ||
1714 | if (fmt->btformat == BT848_COLOR_FMT_RAW) { | ||
1715 | width = RAW_BPL; | ||
1716 | height = RAW_LINES*2; | ||
1717 | if (width*height > buf->vb.bsize) | ||
1718 | return -EINVAL; | ||
1719 | buf->vb.size = buf->vb.bsize; | ||
1720 | |||
1721 | /* Make sure tvnorm and vbi_end remain consistent | ||
1722 | until we're done. */ | ||
1723 | |||
1724 | norm = btv->tvnorm; | ||
1725 | |||
1726 | /* In this mode capturing always starts at defrect.top | ||
1727 | (default VDELAY), ignoring cropping parameters. */ | ||
1728 | if (btv->vbi_end > bttv_tvnorms[norm].cropcap.defrect.top) { | ||
1729 | return -EINVAL; | ||
1730 | } | ||
1731 | |||
1732 | c.rect = bttv_tvnorms[norm].cropcap.defrect; | ||
1733 | } else { | ||
1734 | norm = btv->tvnorm; | ||
1735 | c = btv->crop[!!fh->do_crop]; | ||
1736 | |||
1737 | if (width < c.min_scaled_width || | ||
1738 | width > c.max_scaled_width || | ||
1739 | height < c.min_scaled_height) | ||
1740 | return -EINVAL; | ||
1741 | |||
1742 | switch (field) { | ||
1743 | case V4L2_FIELD_TOP: | ||
1744 | case V4L2_FIELD_BOTTOM: | ||
1745 | case V4L2_FIELD_ALTERNATE: | ||
1746 | /* btv->crop counts frame lines. Max. scale | ||
1747 | factor is 16:1 for frames, 8:1 for fields. */ | ||
1748 | if (height * 2 > c.max_scaled_height) | ||
1749 | return -EINVAL; | ||
1750 | break; | ||
1751 | |||
1752 | default: | ||
1753 | if (height > c.max_scaled_height) | ||
1754 | return -EINVAL; | ||
1755 | break; | ||
1756 | } | ||
1757 | |||
1758 | buf->vb.size = (width * height * fmt->depth) >> 3; | ||
1759 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | ||
1760 | return -EINVAL; | ||
1761 | } | ||
1762 | |||
1763 | /* alloc + fill struct bttv_buffer (if changed) */ | ||
1764 | if (buf->vb.width != width || buf->vb.height != height || | ||
1765 | buf->vb.field != field || | ||
1766 | buf->tvnorm != norm || buf->fmt != fmt || | ||
1767 | buf->crop.top != c.rect.top || | ||
1768 | buf->crop.left != c.rect.left || | ||
1769 | buf->crop.width != c.rect.width || | ||
1770 | buf->crop.height != c.rect.height) { | ||
1771 | buf->vb.width = width; | ||
1772 | buf->vb.height = height; | ||
1773 | buf->vb.field = field; | ||
1774 | buf->tvnorm = norm; | ||
1775 | buf->fmt = fmt; | ||
1776 | buf->crop = c.rect; | ||
1777 | redo_dma_risc = 1; | ||
1778 | } | ||
1779 | |||
1780 | /* alloc risc memory */ | ||
1781 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | ||
1782 | redo_dma_risc = 1; | ||
1783 | if (0 != (rc = videobuf_iolock(q,&buf->vb,&btv->fbuf))) | ||
1784 | goto fail; | ||
1785 | } | ||
1786 | |||
1787 | if (redo_dma_risc) | ||
1788 | if (0 != (rc = bttv_buffer_risc(btv,buf))) | ||
1789 | goto fail; | ||
1790 | |||
1791 | buf->vb.state = VIDEOBUF_PREPARED; | ||
1792 | return 0; | ||
1793 | |||
1794 | fail: | ||
1795 | bttv_dma_free(q,btv,buf); | ||
1796 | return rc; | ||
1797 | } | ||
1798 | |||
1799 | static int | ||
1800 | buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) | ||
1801 | { | ||
1802 | struct bttv_fh *fh = q->priv_data; | ||
1803 | |||
1804 | *size = fh->fmt->depth*fh->width*fh->height >> 3; | ||
1805 | if (0 == *count) | ||
1806 | *count = gbuffers; | ||
1807 | if (*size * *count > gbuffers * gbufsize) | ||
1808 | *count = (gbuffers * gbufsize) / *size; | ||
1809 | return 0; | ||
1810 | } | ||
1811 | |||
1812 | static int | ||
1813 | buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb, | ||
1814 | enum v4l2_field field) | ||
1815 | { | ||
1816 | struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); | ||
1817 | struct bttv_fh *fh = q->priv_data; | ||
1818 | |||
1819 | return bttv_prepare_buffer(q,fh->btv, buf, fh->fmt, | ||
1820 | fh->width, fh->height, field); | ||
1821 | } | ||
1822 | |||
1823 | static void | ||
1824 | buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) | ||
1825 | { | ||
1826 | struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); | ||
1827 | struct bttv_fh *fh = q->priv_data; | ||
1828 | struct bttv *btv = fh->btv; | ||
1829 | |||
1830 | buf->vb.state = VIDEOBUF_QUEUED; | ||
1831 | list_add_tail(&buf->vb.queue,&btv->capture); | ||
1832 | if (!btv->curr.frame_irq) { | ||
1833 | btv->loop_irq |= 1; | ||
1834 | bttv_set_dma(btv, 0x03); | ||
1835 | } | ||
1836 | } | ||
1837 | |||
1838 | static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) | ||
1839 | { | ||
1840 | struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); | ||
1841 | struct bttv_fh *fh = q->priv_data; | ||
1842 | |||
1843 | bttv_dma_free(q,fh->btv,buf); | ||
1844 | } | ||
1845 | |||
1846 | static struct videobuf_queue_ops bttv_video_qops = { | ||
1847 | .buf_setup = buffer_setup, | ||
1848 | .buf_prepare = buffer_prepare, | ||
1849 | .buf_queue = buffer_queue, | ||
1850 | .buf_release = buffer_release, | ||
1851 | }; | ||
1852 | |||
1853 | static int bttv_s_std(struct file *file, void *priv, v4l2_std_id *id) | ||
1854 | { | ||
1855 | struct bttv_fh *fh = priv; | ||
1856 | struct bttv *btv = fh->btv; | ||
1857 | unsigned int i; | ||
1858 | int err; | ||
1859 | |||
1860 | err = v4l2_prio_check(&btv->prio, fh->prio); | ||
1861 | if (err) | ||
1862 | goto err; | ||
1863 | |||
1864 | for (i = 0; i < BTTV_TVNORMS; i++) | ||
1865 | if (*id & bttv_tvnorms[i].v4l2_id) | ||
1866 | break; | ||
1867 | if (i == BTTV_TVNORMS) { | ||
1868 | err = -EINVAL; | ||
1869 | goto err; | ||
1870 | } | ||
1871 | |||
1872 | set_tvnorm(btv, i); | ||
1873 | |||
1874 | err: | ||
1875 | |||
1876 | return err; | ||
1877 | } | ||
1878 | |||
1879 | static int bttv_querystd(struct file *file, void *f, v4l2_std_id *id) | ||
1880 | { | ||
1881 | struct bttv_fh *fh = f; | ||
1882 | struct bttv *btv = fh->btv; | ||
1883 | |||
1884 | if (btread(BT848_DSTATUS) & BT848_DSTATUS_NUML) | ||
1885 | *id = V4L2_STD_625_50; | ||
1886 | else | ||
1887 | *id = V4L2_STD_525_60; | ||
1888 | return 0; | ||
1889 | } | ||
1890 | |||
1891 | static int bttv_enum_input(struct file *file, void *priv, | ||
1892 | struct v4l2_input *i) | ||
1893 | { | ||
1894 | struct bttv_fh *fh = priv; | ||
1895 | struct bttv *btv = fh->btv; | ||
1896 | int rc = 0; | ||
1897 | |||
1898 | if (i->index >= bttv_tvcards[btv->c.type].video_inputs) { | ||
1899 | rc = -EINVAL; | ||
1900 | goto err; | ||
1901 | } | ||
1902 | |||
1903 | i->type = V4L2_INPUT_TYPE_CAMERA; | ||
1904 | i->audioset = 1; | ||
1905 | |||
1906 | if (btv->tuner_type != TUNER_ABSENT && i->index == 0) { | ||
1907 | sprintf(i->name, "Television"); | ||
1908 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
1909 | i->tuner = 0; | ||
1910 | } else if (i->index == btv->svhs) { | ||
1911 | sprintf(i->name, "S-Video"); | ||
1912 | } else { | ||
1913 | sprintf(i->name, "Composite%d", i->index); | ||
1914 | } | ||
1915 | |||
1916 | if (i->index == btv->input) { | ||
1917 | __u32 dstatus = btread(BT848_DSTATUS); | ||
1918 | if (0 == (dstatus & BT848_DSTATUS_PRES)) | ||
1919 | i->status |= V4L2_IN_ST_NO_SIGNAL; | ||
1920 | if (0 == (dstatus & BT848_DSTATUS_HLOC)) | ||
1921 | i->status |= V4L2_IN_ST_NO_H_LOCK; | ||
1922 | } | ||
1923 | |||
1924 | i->std = BTTV_NORMS; | ||
1925 | |||
1926 | err: | ||
1927 | |||
1928 | return rc; | ||
1929 | } | ||
1930 | |||
1931 | static int bttv_g_input(struct file *file, void *priv, unsigned int *i) | ||
1932 | { | ||
1933 | struct bttv_fh *fh = priv; | ||
1934 | struct bttv *btv = fh->btv; | ||
1935 | |||
1936 | *i = btv->input; | ||
1937 | |||
1938 | return 0; | ||
1939 | } | ||
1940 | |||
1941 | static int bttv_s_input(struct file *file, void *priv, unsigned int i) | ||
1942 | { | ||
1943 | struct bttv_fh *fh = priv; | ||
1944 | struct bttv *btv = fh->btv; | ||
1945 | |||
1946 | int err; | ||
1947 | |||
1948 | err = v4l2_prio_check(&btv->prio, fh->prio); | ||
1949 | if (unlikely(err)) | ||
1950 | goto err; | ||
1951 | |||
1952 | if (i > bttv_tvcards[btv->c.type].video_inputs) { | ||
1953 | err = -EINVAL; | ||
1954 | goto err; | ||
1955 | } | ||
1956 | |||
1957 | set_input(btv, i, btv->tvnorm); | ||
1958 | |||
1959 | err: | ||
1960 | return 0; | ||
1961 | } | ||
1962 | |||
1963 | static int bttv_s_tuner(struct file *file, void *priv, | ||
1964 | struct v4l2_tuner *t) | ||
1965 | { | ||
1966 | struct bttv_fh *fh = priv; | ||
1967 | struct bttv *btv = fh->btv; | ||
1968 | int err; | ||
1969 | |||
1970 | if (unlikely(0 != t->index)) | ||
1971 | return -EINVAL; | ||
1972 | |||
1973 | if (unlikely(btv->tuner_type == TUNER_ABSENT)) { | ||
1974 | err = -EINVAL; | ||
1975 | goto err; | ||
1976 | } | ||
1977 | |||
1978 | err = v4l2_prio_check(&btv->prio, fh->prio); | ||
1979 | if (unlikely(err)) | ||
1980 | goto err; | ||
1981 | |||
1982 | bttv_call_all(btv, tuner, s_tuner, t); | ||
1983 | |||
1984 | if (btv->audio_mode_gpio) | ||
1985 | btv->audio_mode_gpio(btv, t, 1); | ||
1986 | |||
1987 | err: | ||
1988 | |||
1989 | return 0; | ||
1990 | } | ||
1991 | |||
1992 | static int bttv_g_frequency(struct file *file, void *priv, | ||
1993 | struct v4l2_frequency *f) | ||
1994 | { | ||
1995 | struct bttv_fh *fh = priv; | ||
1996 | struct bttv *btv = fh->btv; | ||
1997 | |||
1998 | f->type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; | ||
1999 | f->frequency = btv->freq; | ||
2000 | |||
2001 | return 0; | ||
2002 | } | ||
2003 | |||
2004 | static int bttv_s_frequency(struct file *file, void *priv, | ||
2005 | struct v4l2_frequency *f) | ||
2006 | { | ||
2007 | struct bttv_fh *fh = priv; | ||
2008 | struct bttv *btv = fh->btv; | ||
2009 | int err; | ||
2010 | |||
2011 | if (unlikely(f->tuner != 0)) | ||
2012 | return -EINVAL; | ||
2013 | |||
2014 | err = v4l2_prio_check(&btv->prio, fh->prio); | ||
2015 | if (unlikely(err)) | ||
2016 | goto err; | ||
2017 | |||
2018 | if (unlikely(f->type != (btv->radio_user | ||
2019 | ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV))) { | ||
2020 | err = -EINVAL; | ||
2021 | goto err; | ||
2022 | } | ||
2023 | btv->freq = f->frequency; | ||
2024 | bttv_call_all(btv, tuner, s_frequency, f); | ||
2025 | if (btv->has_matchbox && btv->radio_user) | ||
2026 | tea5757_set_freq(btv, btv->freq); | ||
2027 | err: | ||
2028 | |||
2029 | return 0; | ||
2030 | } | ||
2031 | |||
2032 | static int bttv_log_status(struct file *file, void *f) | ||
2033 | { | ||
2034 | struct bttv_fh *fh = f; | ||
2035 | struct bttv *btv = fh->btv; | ||
2036 | |||
2037 | bttv_call_all(btv, core, log_status); | ||
2038 | return 0; | ||
2039 | } | ||
2040 | |||
2041 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
2042 | static int bttv_g_register(struct file *file, void *f, | ||
2043 | struct v4l2_dbg_register *reg) | ||
2044 | { | ||
2045 | struct bttv_fh *fh = f; | ||
2046 | struct bttv *btv = fh->btv; | ||
2047 | |||
2048 | if (!capable(CAP_SYS_ADMIN)) | ||
2049 | return -EPERM; | ||
2050 | |||
2051 | if (!v4l2_chip_match_host(®->match)) | ||
2052 | return -EINVAL; | ||
2053 | |||
2054 | /* bt848 has a 12-bit register space */ | ||
2055 | reg->reg &= 0xfff; | ||
2056 | reg->val = btread(reg->reg); | ||
2057 | reg->size = 1; | ||
2058 | |||
2059 | return 0; | ||
2060 | } | ||
2061 | |||
2062 | static int bttv_s_register(struct file *file, void *f, | ||
2063 | struct v4l2_dbg_register *reg) | ||
2064 | { | ||
2065 | struct bttv_fh *fh = f; | ||
2066 | struct bttv *btv = fh->btv; | ||
2067 | |||
2068 | if (!capable(CAP_SYS_ADMIN)) | ||
2069 | return -EPERM; | ||
2070 | |||
2071 | if (!v4l2_chip_match_host(®->match)) | ||
2072 | return -EINVAL; | ||
2073 | |||
2074 | /* bt848 has a 12-bit register space */ | ||
2075 | reg->reg &= 0xfff; | ||
2076 | btwrite(reg->val, reg->reg); | ||
2077 | |||
2078 | return 0; | ||
2079 | } | ||
2080 | #endif | ||
2081 | |||
2082 | /* Given cropping boundaries b and the scaled width and height of a | ||
2083 | single field or frame, which must not exceed hardware limits, this | ||
2084 | function adjusts the cropping parameters c. */ | ||
2085 | static void | ||
2086 | bttv_crop_adjust (struct bttv_crop * c, | ||
2087 | const struct v4l2_rect * b, | ||
2088 | __s32 width, | ||
2089 | __s32 height, | ||
2090 | enum v4l2_field field) | ||
2091 | { | ||
2092 | __s32 frame_height = height << !V4L2_FIELD_HAS_BOTH(field); | ||
2093 | __s32 max_left; | ||
2094 | __s32 max_top; | ||
2095 | |||
2096 | if (width < c->min_scaled_width) { | ||
2097 | /* Max. hor. scale factor 16:1. */ | ||
2098 | c->rect.width = width * 16; | ||
2099 | } else if (width > c->max_scaled_width) { | ||
2100 | /* Min. hor. scale factor 1:1. */ | ||
2101 | c->rect.width = width; | ||
2102 | |||
2103 | max_left = b->left + b->width - width; | ||
2104 | max_left = min(max_left, (__s32) MAX_HDELAY); | ||
2105 | if (c->rect.left > max_left) | ||
2106 | c->rect.left = max_left; | ||
2107 | } | ||
2108 | |||
2109 | if (height < c->min_scaled_height) { | ||
2110 | /* Max. vert. scale factor 16:1, single fields 8:1. */ | ||
2111 | c->rect.height = height * 16; | ||
2112 | } else if (frame_height > c->max_scaled_height) { | ||
2113 | /* Min. vert. scale factor 1:1. | ||
2114 | Top and height count field lines times two. */ | ||
2115 | c->rect.height = (frame_height + 1) & ~1; | ||
2116 | |||
2117 | max_top = b->top + b->height - c->rect.height; | ||
2118 | if (c->rect.top > max_top) | ||
2119 | c->rect.top = max_top; | ||
2120 | } | ||
2121 | |||
2122 | bttv_crop_calc_limits(c); | ||
2123 | } | ||
2124 | |||
2125 | /* Returns an error if scaling to a frame or single field with the given | ||
2126 | width and height is not possible with the current cropping parameters | ||
2127 | and width aligned according to width_mask. If adjust_size is TRUE the | ||
2128 | function may adjust the width and/or height instead, rounding width | ||
2129 | to (width + width_bias) & width_mask. If adjust_crop is TRUE it may | ||
2130 | also adjust the current cropping parameters to get closer to the | ||
2131 | desired image size. */ | ||
2132 | static int | ||
2133 | limit_scaled_size_lock (struct bttv_fh * fh, | ||
2134 | __s32 * width, | ||
2135 | __s32 * height, | ||
2136 | enum v4l2_field field, | ||
2137 | unsigned int width_mask, | ||
2138 | unsigned int width_bias, | ||
2139 | int adjust_size, | ||
2140 | int adjust_crop) | ||
2141 | { | ||
2142 | struct bttv *btv = fh->btv; | ||
2143 | const struct v4l2_rect *b; | ||
2144 | struct bttv_crop *c; | ||
2145 | __s32 min_width; | ||
2146 | __s32 min_height; | ||
2147 | __s32 max_width; | ||
2148 | __s32 max_height; | ||
2149 | int rc; | ||
2150 | |||
2151 | BUG_ON((int) width_mask >= 0 || | ||
2152 | width_bias >= (unsigned int) -width_mask); | ||
2153 | |||
2154 | /* Make sure tvnorm, vbi_end and the current cropping parameters | ||
2155 | remain consistent until we're done. */ | ||
2156 | |||
2157 | b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; | ||
2158 | |||
2159 | /* Do crop - use current, don't - use default parameters. */ | ||
2160 | c = &btv->crop[!!fh->do_crop]; | ||
2161 | |||
2162 | if (fh->do_crop | ||
2163 | && adjust_size | ||
2164 | && adjust_crop | ||
2165 | && !locked_btres(btv, VIDEO_RESOURCES)) { | ||
2166 | min_width = 48; | ||
2167 | min_height = 32; | ||
2168 | |||
2169 | /* We cannot scale up. When the scaled image is larger | ||
2170 | than crop.rect we adjust the crop.rect as required | ||
2171 | by the V4L2 spec, hence cropcap.bounds are our limit. */ | ||
2172 | max_width = min(b->width, (__s32) MAX_HACTIVE); | ||
2173 | max_height = b->height; | ||
2174 | |||
2175 | /* We cannot capture the same line as video and VBI data. | ||
2176 | Note btv->vbi_end is really a minimum, see | ||
2177 | bttv_vbi_try_fmt(). */ | ||
2178 | if (btv->vbi_end > b->top) { | ||
2179 | max_height -= btv->vbi_end - b->top; | ||
2180 | rc = -EBUSY; | ||
2181 | if (min_height > max_height) | ||
2182 | goto fail; | ||
2183 | } | ||
2184 | } else { | ||
2185 | rc = -EBUSY; | ||
2186 | if (btv->vbi_end > c->rect.top) | ||
2187 | goto fail; | ||
2188 | |||
2189 | min_width = c->min_scaled_width; | ||
2190 | min_height = c->min_scaled_height; | ||
2191 | max_width = c->max_scaled_width; | ||
2192 | max_height = c->max_scaled_height; | ||
2193 | |||
2194 | adjust_crop = 0; | ||
2195 | } | ||
2196 | |||
2197 | min_width = (min_width - width_mask - 1) & width_mask; | ||
2198 | max_width = max_width & width_mask; | ||
2199 | |||
2200 | /* Max. scale factor is 16:1 for frames, 8:1 for fields. */ | ||
2201 | min_height = min_height; | ||
2202 | /* Min. scale factor is 1:1. */ | ||
2203 | max_height >>= !V4L2_FIELD_HAS_BOTH(field); | ||
2204 | |||
2205 | if (adjust_size) { | ||
2206 | *width = clamp(*width, min_width, max_width); | ||
2207 | *height = clamp(*height, min_height, max_height); | ||
2208 | |||
2209 | /* Round after clamping to avoid overflow. */ | ||
2210 | *width = (*width + width_bias) & width_mask; | ||
2211 | |||
2212 | if (adjust_crop) { | ||
2213 | bttv_crop_adjust(c, b, *width, *height, field); | ||
2214 | |||
2215 | if (btv->vbi_end > c->rect.top) { | ||
2216 | /* Move the crop window out of the way. */ | ||
2217 | c->rect.top = btv->vbi_end; | ||
2218 | } | ||
2219 | } | ||
2220 | } else { | ||
2221 | rc = -EINVAL; | ||
2222 | if (*width < min_width || | ||
2223 | *height < min_height || | ||
2224 | *width > max_width || | ||
2225 | *height > max_height || | ||
2226 | 0 != (*width & ~width_mask)) | ||
2227 | goto fail; | ||
2228 | } | ||
2229 | |||
2230 | rc = 0; /* success */ | ||
2231 | |||
2232 | fail: | ||
2233 | |||
2234 | return rc; | ||
2235 | } | ||
2236 | |||
2237 | /* Returns an error if the given overlay window dimensions are not | ||
2238 | possible with the current cropping parameters. If adjust_size is | ||
2239 | TRUE the function may adjust the window width and/or height | ||
2240 | instead, however it always rounds the horizontal position and | ||
2241 | width as btcx_align() does. If adjust_crop is TRUE the function | ||
2242 | may also adjust the current cropping parameters to get closer | ||
2243 | to the desired window size. */ | ||
2244 | static int | ||
2245 | verify_window_lock (struct bttv_fh * fh, | ||
2246 | struct v4l2_window * win, | ||
2247 | int adjust_size, | ||
2248 | int adjust_crop) | ||
2249 | { | ||
2250 | enum v4l2_field field; | ||
2251 | unsigned int width_mask; | ||
2252 | int rc; | ||
2253 | |||
2254 | if (win->w.width < 48 || win->w.height < 32) | ||
2255 | return -EINVAL; | ||
2256 | if (win->clipcount > 2048) | ||
2257 | return -EINVAL; | ||
2258 | |||
2259 | field = win->field; | ||
2260 | |||
2261 | if (V4L2_FIELD_ANY == field) { | ||
2262 | __s32 height2; | ||
2263 | |||
2264 | height2 = fh->btv->crop[!!fh->do_crop].rect.height >> 1; | ||
2265 | field = (win->w.height > height2) | ||
2266 | ? V4L2_FIELD_INTERLACED | ||
2267 | : V4L2_FIELD_TOP; | ||
2268 | } | ||
2269 | switch (field) { | ||
2270 | case V4L2_FIELD_TOP: | ||
2271 | case V4L2_FIELD_BOTTOM: | ||
2272 | case V4L2_FIELD_INTERLACED: | ||
2273 | break; | ||
2274 | default: | ||
2275 | return -EINVAL; | ||
2276 | } | ||
2277 | |||
2278 | /* 4-byte alignment. */ | ||
2279 | if (NULL == fh->ovfmt) | ||
2280 | return -EINVAL; | ||
2281 | width_mask = ~0; | ||
2282 | switch (fh->ovfmt->depth) { | ||
2283 | case 8: | ||
2284 | case 24: | ||
2285 | width_mask = ~3; | ||
2286 | break; | ||
2287 | case 16: | ||
2288 | width_mask = ~1; | ||
2289 | break; | ||
2290 | case 32: | ||
2291 | break; | ||
2292 | default: | ||
2293 | BUG(); | ||
2294 | } | ||
2295 | |||
2296 | win->w.width -= win->w.left & ~width_mask; | ||
2297 | win->w.left = (win->w.left - width_mask - 1) & width_mask; | ||
2298 | |||
2299 | rc = limit_scaled_size_lock(fh, &win->w.width, &win->w.height, | ||
2300 | field, width_mask, | ||
2301 | /* width_bias: round down */ 0, | ||
2302 | adjust_size, adjust_crop); | ||
2303 | if (0 != rc) | ||
2304 | return rc; | ||
2305 | |||
2306 | win->field = field; | ||
2307 | return 0; | ||
2308 | } | ||
2309 | |||
2310 | static int setup_window_lock(struct bttv_fh *fh, struct bttv *btv, | ||
2311 | struct v4l2_window *win, int fixup) | ||
2312 | { | ||
2313 | struct v4l2_clip *clips = NULL; | ||
2314 | int n,size,retval = 0; | ||
2315 | |||
2316 | if (NULL == fh->ovfmt) | ||
2317 | return -EINVAL; | ||
2318 | if (!(fh->ovfmt->flags & FORMAT_FLAGS_PACKED)) | ||
2319 | return -EINVAL; | ||
2320 | retval = verify_window_lock(fh, win, | ||
2321 | /* adjust_size */ fixup, | ||
2322 | /* adjust_crop */ fixup); | ||
2323 | if (0 != retval) | ||
2324 | return retval; | ||
2325 | |||
2326 | /* copy clips -- luckily v4l1 + v4l2 are binary | ||
2327 | compatible here ...*/ | ||
2328 | n = win->clipcount; | ||
2329 | size = sizeof(*clips)*(n+4); | ||
2330 | clips = kmalloc(size,GFP_KERNEL); | ||
2331 | if (NULL == clips) | ||
2332 | return -ENOMEM; | ||
2333 | if (n > 0) { | ||
2334 | if (copy_from_user(clips,win->clips,sizeof(struct v4l2_clip)*n)) { | ||
2335 | kfree(clips); | ||
2336 | return -EFAULT; | ||
2337 | } | ||
2338 | } | ||
2339 | |||
2340 | /* clip against screen */ | ||
2341 | if (NULL != btv->fbuf.base) | ||
2342 | n = btcx_screen_clips(btv->fbuf.fmt.width, btv->fbuf.fmt.height, | ||
2343 | &win->w, clips, n); | ||
2344 | btcx_sort_clips(clips,n); | ||
2345 | |||
2346 | /* 4-byte alignments */ | ||
2347 | switch (fh->ovfmt->depth) { | ||
2348 | case 8: | ||
2349 | case 24: | ||
2350 | btcx_align(&win->w, clips, n, 3); | ||
2351 | break; | ||
2352 | case 16: | ||
2353 | btcx_align(&win->w, clips, n, 1); | ||
2354 | break; | ||
2355 | case 32: | ||
2356 | /* no alignment fixups needed */ | ||
2357 | break; | ||
2358 | default: | ||
2359 | BUG(); | ||
2360 | } | ||
2361 | |||
2362 | kfree(fh->ov.clips); | ||
2363 | fh->ov.clips = clips; | ||
2364 | fh->ov.nclips = n; | ||
2365 | |||
2366 | fh->ov.w = win->w; | ||
2367 | fh->ov.field = win->field; | ||
2368 | fh->ov.setup_ok = 1; | ||
2369 | |||
2370 | btv->init.ov.w.width = win->w.width; | ||
2371 | btv->init.ov.w.height = win->w.height; | ||
2372 | btv->init.ov.field = win->field; | ||
2373 | |||
2374 | /* update overlay if needed */ | ||
2375 | retval = 0; | ||
2376 | if (check_btres(fh, RESOURCE_OVERLAY)) { | ||
2377 | struct bttv_buffer *new; | ||
2378 | |||
2379 | new = videobuf_sg_alloc(sizeof(*new)); | ||
2380 | new->crop = btv->crop[!!fh->do_crop].rect; | ||
2381 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); | ||
2382 | retval = bttv_switch_overlay(btv,fh,new); | ||
2383 | } | ||
2384 | return retval; | ||
2385 | } | ||
2386 | |||
2387 | /* ----------------------------------------------------------------------- */ | ||
2388 | |||
2389 | static struct videobuf_queue* bttv_queue(struct bttv_fh *fh) | ||
2390 | { | ||
2391 | struct videobuf_queue* q = NULL; | ||
2392 | |||
2393 | switch (fh->type) { | ||
2394 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
2395 | q = &fh->cap; | ||
2396 | break; | ||
2397 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
2398 | q = &fh->vbi; | ||
2399 | break; | ||
2400 | default: | ||
2401 | BUG(); | ||
2402 | } | ||
2403 | return q; | ||
2404 | } | ||
2405 | |||
2406 | static int bttv_resource(struct bttv_fh *fh) | ||
2407 | { | ||
2408 | int res = 0; | ||
2409 | |||
2410 | switch (fh->type) { | ||
2411 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
2412 | res = RESOURCE_VIDEO_STREAM; | ||
2413 | break; | ||
2414 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
2415 | res = RESOURCE_VBI; | ||
2416 | break; | ||
2417 | default: | ||
2418 | BUG(); | ||
2419 | } | ||
2420 | return res; | ||
2421 | } | ||
2422 | |||
2423 | static int bttv_switch_type(struct bttv_fh *fh, enum v4l2_buf_type type) | ||
2424 | { | ||
2425 | struct videobuf_queue *q = bttv_queue(fh); | ||
2426 | int res = bttv_resource(fh); | ||
2427 | |||
2428 | if (check_btres(fh,res)) | ||
2429 | return -EBUSY; | ||
2430 | if (videobuf_queue_is_busy(q)) | ||
2431 | return -EBUSY; | ||
2432 | fh->type = type; | ||
2433 | return 0; | ||
2434 | } | ||
2435 | |||
2436 | static void | ||
2437 | pix_format_set_size (struct v4l2_pix_format * f, | ||
2438 | const struct bttv_format * fmt, | ||
2439 | unsigned int width, | ||
2440 | unsigned int height) | ||
2441 | { | ||
2442 | f->width = width; | ||
2443 | f->height = height; | ||
2444 | |||
2445 | if (fmt->flags & FORMAT_FLAGS_PLANAR) { | ||
2446 | f->bytesperline = width; /* Y plane */ | ||
2447 | f->sizeimage = (width * height * fmt->depth) >> 3; | ||
2448 | } else { | ||
2449 | f->bytesperline = (width * fmt->depth) >> 3; | ||
2450 | f->sizeimage = height * f->bytesperline; | ||
2451 | } | ||
2452 | } | ||
2453 | |||
2454 | static int bttv_g_fmt_vid_cap(struct file *file, void *priv, | ||
2455 | struct v4l2_format *f) | ||
2456 | { | ||
2457 | struct bttv_fh *fh = priv; | ||
2458 | |||
2459 | pix_format_set_size(&f->fmt.pix, fh->fmt, | ||
2460 | fh->width, fh->height); | ||
2461 | f->fmt.pix.field = fh->cap.field; | ||
2462 | f->fmt.pix.pixelformat = fh->fmt->fourcc; | ||
2463 | |||
2464 | return 0; | ||
2465 | } | ||
2466 | |||
2467 | static int bttv_g_fmt_vid_overlay(struct file *file, void *priv, | ||
2468 | struct v4l2_format *f) | ||
2469 | { | ||
2470 | struct bttv_fh *fh = priv; | ||
2471 | |||
2472 | f->fmt.win.w = fh->ov.w; | ||
2473 | f->fmt.win.field = fh->ov.field; | ||
2474 | |||
2475 | return 0; | ||
2476 | } | ||
2477 | |||
2478 | static int bttv_try_fmt_vid_cap(struct file *file, void *priv, | ||
2479 | struct v4l2_format *f) | ||
2480 | { | ||
2481 | const struct bttv_format *fmt; | ||
2482 | struct bttv_fh *fh = priv; | ||
2483 | struct bttv *btv = fh->btv; | ||
2484 | enum v4l2_field field; | ||
2485 | __s32 width, height; | ||
2486 | int rc; | ||
2487 | |||
2488 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | ||
2489 | if (NULL == fmt) | ||
2490 | return -EINVAL; | ||
2491 | |||
2492 | field = f->fmt.pix.field; | ||
2493 | |||
2494 | if (V4L2_FIELD_ANY == field) { | ||
2495 | __s32 height2; | ||
2496 | |||
2497 | height2 = btv->crop[!!fh->do_crop].rect.height >> 1; | ||
2498 | field = (f->fmt.pix.height > height2) | ||
2499 | ? V4L2_FIELD_INTERLACED | ||
2500 | : V4L2_FIELD_BOTTOM; | ||
2501 | } | ||
2502 | |||
2503 | if (V4L2_FIELD_SEQ_BT == field) | ||
2504 | field = V4L2_FIELD_SEQ_TB; | ||
2505 | |||
2506 | switch (field) { | ||
2507 | case V4L2_FIELD_TOP: | ||
2508 | case V4L2_FIELD_BOTTOM: | ||
2509 | case V4L2_FIELD_ALTERNATE: | ||
2510 | case V4L2_FIELD_INTERLACED: | ||
2511 | break; | ||
2512 | case V4L2_FIELD_SEQ_TB: | ||
2513 | if (fmt->flags & FORMAT_FLAGS_PLANAR) | ||
2514 | return -EINVAL; | ||
2515 | break; | ||
2516 | default: | ||
2517 | return -EINVAL; | ||
2518 | } | ||
2519 | |||
2520 | width = f->fmt.pix.width; | ||
2521 | height = f->fmt.pix.height; | ||
2522 | |||
2523 | rc = limit_scaled_size_lock(fh, &width, &height, field, | ||
2524 | /* width_mask: 4 pixels */ ~3, | ||
2525 | /* width_bias: nearest */ 2, | ||
2526 | /* adjust_size */ 1, | ||
2527 | /* adjust_crop */ 0); | ||
2528 | if (0 != rc) | ||
2529 | return rc; | ||
2530 | |||
2531 | /* update data for the application */ | ||
2532 | f->fmt.pix.field = field; | ||
2533 | pix_format_set_size(&f->fmt.pix, fmt, width, height); | ||
2534 | |||
2535 | return 0; | ||
2536 | } | ||
2537 | |||
2538 | static int bttv_try_fmt_vid_overlay(struct file *file, void *priv, | ||
2539 | struct v4l2_format *f) | ||
2540 | { | ||
2541 | struct bttv_fh *fh = priv; | ||
2542 | |||
2543 | return verify_window_lock(fh, &f->fmt.win, | ||
2544 | /* adjust_size */ 1, | ||
2545 | /* adjust_crop */ 0); | ||
2546 | } | ||
2547 | |||
2548 | static int bttv_s_fmt_vid_cap(struct file *file, void *priv, | ||
2549 | struct v4l2_format *f) | ||
2550 | { | ||
2551 | int retval; | ||
2552 | const struct bttv_format *fmt; | ||
2553 | struct bttv_fh *fh = priv; | ||
2554 | struct bttv *btv = fh->btv; | ||
2555 | __s32 width, height; | ||
2556 | enum v4l2_field field; | ||
2557 | |||
2558 | retval = bttv_switch_type(fh, f->type); | ||
2559 | if (0 != retval) | ||
2560 | return retval; | ||
2561 | |||
2562 | retval = bttv_try_fmt_vid_cap(file, priv, f); | ||
2563 | if (0 != retval) | ||
2564 | return retval; | ||
2565 | |||
2566 | width = f->fmt.pix.width; | ||
2567 | height = f->fmt.pix.height; | ||
2568 | field = f->fmt.pix.field; | ||
2569 | |||
2570 | retval = limit_scaled_size_lock(fh, &width, &height, f->fmt.pix.field, | ||
2571 | /* width_mask: 4 pixels */ ~3, | ||
2572 | /* width_bias: nearest */ 2, | ||
2573 | /* adjust_size */ 1, | ||
2574 | /* adjust_crop */ 1); | ||
2575 | if (0 != retval) | ||
2576 | return retval; | ||
2577 | |||
2578 | f->fmt.pix.field = field; | ||
2579 | |||
2580 | fmt = format_by_fourcc(f->fmt.pix.pixelformat); | ||
2581 | |||
2582 | /* update our state informations */ | ||
2583 | fh->fmt = fmt; | ||
2584 | fh->cap.field = f->fmt.pix.field; | ||
2585 | fh->cap.last = V4L2_FIELD_NONE; | ||
2586 | fh->width = f->fmt.pix.width; | ||
2587 | fh->height = f->fmt.pix.height; | ||
2588 | btv->init.fmt = fmt; | ||
2589 | btv->init.width = f->fmt.pix.width; | ||
2590 | btv->init.height = f->fmt.pix.height; | ||
2591 | |||
2592 | return 0; | ||
2593 | } | ||
2594 | |||
2595 | static int bttv_s_fmt_vid_overlay(struct file *file, void *priv, | ||
2596 | struct v4l2_format *f) | ||
2597 | { | ||
2598 | struct bttv_fh *fh = priv; | ||
2599 | struct bttv *btv = fh->btv; | ||
2600 | |||
2601 | if (no_overlay > 0) { | ||
2602 | pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); | ||
2603 | return -EINVAL; | ||
2604 | } | ||
2605 | |||
2606 | return setup_window_lock(fh, btv, &f->fmt.win, 1); | ||
2607 | } | ||
2608 | |||
2609 | static int bttv_querycap(struct file *file, void *priv, | ||
2610 | struct v4l2_capability *cap) | ||
2611 | { | ||
2612 | struct bttv_fh *fh = priv; | ||
2613 | struct bttv *btv = fh->btv; | ||
2614 | |||
2615 | if (0 == v4l2) | ||
2616 | return -EINVAL; | ||
2617 | |||
2618 | strlcpy(cap->driver, "bttv", sizeof(cap->driver)); | ||
2619 | strlcpy(cap->card, btv->video_dev->name, sizeof(cap->card)); | ||
2620 | snprintf(cap->bus_info, sizeof(cap->bus_info), | ||
2621 | "PCI:%s", pci_name(btv->c.pci)); | ||
2622 | cap->capabilities = | ||
2623 | V4L2_CAP_VIDEO_CAPTURE | | ||
2624 | V4L2_CAP_VBI_CAPTURE | | ||
2625 | V4L2_CAP_READWRITE | | ||
2626 | V4L2_CAP_STREAMING; | ||
2627 | if (no_overlay <= 0) | ||
2628 | cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY; | ||
2629 | |||
2630 | /* | ||
2631 | * No need to lock here: those vars are initialized during board | ||
2632 | * probe and remains untouched during the rest of the driver lifecycle | ||
2633 | */ | ||
2634 | if (btv->has_saa6588) | ||
2635 | cap->capabilities |= V4L2_CAP_RDS_CAPTURE; | ||
2636 | if (btv->tuner_type != TUNER_ABSENT) | ||
2637 | cap->capabilities |= V4L2_CAP_TUNER; | ||
2638 | return 0; | ||
2639 | } | ||
2640 | |||
2641 | static int bttv_enum_fmt_cap_ovr(struct v4l2_fmtdesc *f) | ||
2642 | { | ||
2643 | int index = -1, i; | ||
2644 | |||
2645 | for (i = 0; i < FORMATS; i++) { | ||
2646 | if (formats[i].fourcc != -1) | ||
2647 | index++; | ||
2648 | if ((unsigned int)index == f->index) | ||
2649 | break; | ||
2650 | } | ||
2651 | if (FORMATS == i) | ||
2652 | return -EINVAL; | ||
2653 | |||
2654 | f->pixelformat = formats[i].fourcc; | ||
2655 | strlcpy(f->description, formats[i].name, sizeof(f->description)); | ||
2656 | |||
2657 | return i; | ||
2658 | } | ||
2659 | |||
2660 | static int bttv_enum_fmt_vid_cap(struct file *file, void *priv, | ||
2661 | struct v4l2_fmtdesc *f) | ||
2662 | { | ||
2663 | int rc = bttv_enum_fmt_cap_ovr(f); | ||
2664 | |||
2665 | if (rc < 0) | ||
2666 | return rc; | ||
2667 | |||
2668 | return 0; | ||
2669 | } | ||
2670 | |||
2671 | static int bttv_enum_fmt_vid_overlay(struct file *file, void *priv, | ||
2672 | struct v4l2_fmtdesc *f) | ||
2673 | { | ||
2674 | int rc; | ||
2675 | |||
2676 | if (no_overlay > 0) { | ||
2677 | pr_err("V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); | ||
2678 | return -EINVAL; | ||
2679 | } | ||
2680 | |||
2681 | rc = bttv_enum_fmt_cap_ovr(f); | ||
2682 | |||
2683 | if (rc < 0) | ||
2684 | return rc; | ||
2685 | |||
2686 | if (!(formats[rc].flags & FORMAT_FLAGS_PACKED)) | ||
2687 | return -EINVAL; | ||
2688 | |||
2689 | return 0; | ||
2690 | } | ||
2691 | |||
2692 | static int bttv_g_fbuf(struct file *file, void *f, | ||
2693 | struct v4l2_framebuffer *fb) | ||
2694 | { | ||
2695 | struct bttv_fh *fh = f; | ||
2696 | struct bttv *btv = fh->btv; | ||
2697 | |||
2698 | *fb = btv->fbuf; | ||
2699 | fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING; | ||
2700 | if (fh->ovfmt) | ||
2701 | fb->fmt.pixelformat = fh->ovfmt->fourcc; | ||
2702 | return 0; | ||
2703 | } | ||
2704 | |||
2705 | static int bttv_overlay(struct file *file, void *f, unsigned int on) | ||
2706 | { | ||
2707 | struct bttv_fh *fh = f; | ||
2708 | struct bttv *btv = fh->btv; | ||
2709 | struct bttv_buffer *new; | ||
2710 | int retval = 0; | ||
2711 | |||
2712 | if (on) { | ||
2713 | /* verify args */ | ||
2714 | if (unlikely(!btv->fbuf.base)) { | ||
2715 | return -EINVAL; | ||
2716 | } | ||
2717 | if (unlikely(!fh->ov.setup_ok)) { | ||
2718 | dprintk("%d: overlay: !setup_ok\n", btv->c.nr); | ||
2719 | retval = -EINVAL; | ||
2720 | } | ||
2721 | if (retval) | ||
2722 | return retval; | ||
2723 | } | ||
2724 | |||
2725 | if (!check_alloc_btres_lock(btv, fh, RESOURCE_OVERLAY)) | ||
2726 | return -EBUSY; | ||
2727 | |||
2728 | if (on) { | ||
2729 | fh->ov.tvnorm = btv->tvnorm; | ||
2730 | new = videobuf_sg_alloc(sizeof(*new)); | ||
2731 | new->crop = btv->crop[!!fh->do_crop].rect; | ||
2732 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); | ||
2733 | } else { | ||
2734 | new = NULL; | ||
2735 | } | ||
2736 | |||
2737 | /* switch over */ | ||
2738 | retval = bttv_switch_overlay(btv, fh, new); | ||
2739 | return retval; | ||
2740 | } | ||
2741 | |||
2742 | static int bttv_s_fbuf(struct file *file, void *f, | ||
2743 | struct v4l2_framebuffer *fb) | ||
2744 | { | ||
2745 | struct bttv_fh *fh = f; | ||
2746 | struct bttv *btv = fh->btv; | ||
2747 | const struct bttv_format *fmt; | ||
2748 | int retval; | ||
2749 | |||
2750 | if (!capable(CAP_SYS_ADMIN) && | ||
2751 | !capable(CAP_SYS_RAWIO)) | ||
2752 | return -EPERM; | ||
2753 | |||
2754 | /* check args */ | ||
2755 | fmt = format_by_fourcc(fb->fmt.pixelformat); | ||
2756 | if (NULL == fmt) | ||
2757 | return -EINVAL; | ||
2758 | if (0 == (fmt->flags & FORMAT_FLAGS_PACKED)) | ||
2759 | return -EINVAL; | ||
2760 | |||
2761 | retval = -EINVAL; | ||
2762 | if (fb->flags & V4L2_FBUF_FLAG_OVERLAY) { | ||
2763 | __s32 width = fb->fmt.width; | ||
2764 | __s32 height = fb->fmt.height; | ||
2765 | |||
2766 | retval = limit_scaled_size_lock(fh, &width, &height, | ||
2767 | V4L2_FIELD_INTERLACED, | ||
2768 | /* width_mask */ ~3, | ||
2769 | /* width_bias */ 2, | ||
2770 | /* adjust_size */ 0, | ||
2771 | /* adjust_crop */ 0); | ||
2772 | if (0 != retval) | ||
2773 | return retval; | ||
2774 | } | ||
2775 | |||
2776 | /* ok, accept it */ | ||
2777 | btv->fbuf.base = fb->base; | ||
2778 | btv->fbuf.fmt.width = fb->fmt.width; | ||
2779 | btv->fbuf.fmt.height = fb->fmt.height; | ||
2780 | if (0 != fb->fmt.bytesperline) | ||
2781 | btv->fbuf.fmt.bytesperline = fb->fmt.bytesperline; | ||
2782 | else | ||
2783 | btv->fbuf.fmt.bytesperline = btv->fbuf.fmt.width*fmt->depth/8; | ||
2784 | |||
2785 | retval = 0; | ||
2786 | fh->ovfmt = fmt; | ||
2787 | btv->init.ovfmt = fmt; | ||
2788 | if (fb->flags & V4L2_FBUF_FLAG_OVERLAY) { | ||
2789 | fh->ov.w.left = 0; | ||
2790 | fh->ov.w.top = 0; | ||
2791 | fh->ov.w.width = fb->fmt.width; | ||
2792 | fh->ov.w.height = fb->fmt.height; | ||
2793 | btv->init.ov.w.width = fb->fmt.width; | ||
2794 | btv->init.ov.w.height = fb->fmt.height; | ||
2795 | kfree(fh->ov.clips); | ||
2796 | fh->ov.clips = NULL; | ||
2797 | fh->ov.nclips = 0; | ||
2798 | |||
2799 | if (check_btres(fh, RESOURCE_OVERLAY)) { | ||
2800 | struct bttv_buffer *new; | ||
2801 | |||
2802 | new = videobuf_sg_alloc(sizeof(*new)); | ||
2803 | new->crop = btv->crop[!!fh->do_crop].rect; | ||
2804 | bttv_overlay_risc(btv, &fh->ov, fh->ovfmt, new); | ||
2805 | retval = bttv_switch_overlay(btv, fh, new); | ||
2806 | } | ||
2807 | } | ||
2808 | return retval; | ||
2809 | } | ||
2810 | |||
2811 | static int bttv_reqbufs(struct file *file, void *priv, | ||
2812 | struct v4l2_requestbuffers *p) | ||
2813 | { | ||
2814 | struct bttv_fh *fh = priv; | ||
2815 | return videobuf_reqbufs(bttv_queue(fh), p); | ||
2816 | } | ||
2817 | |||
2818 | static int bttv_querybuf(struct file *file, void *priv, | ||
2819 | struct v4l2_buffer *b) | ||
2820 | { | ||
2821 | struct bttv_fh *fh = priv; | ||
2822 | return videobuf_querybuf(bttv_queue(fh), b); | ||
2823 | } | ||
2824 | |||
2825 | static int bttv_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
2826 | { | ||
2827 | struct bttv_fh *fh = priv; | ||
2828 | struct bttv *btv = fh->btv; | ||
2829 | int res = bttv_resource(fh); | ||
2830 | |||
2831 | if (!check_alloc_btres_lock(btv, fh, res)) | ||
2832 | return -EBUSY; | ||
2833 | |||
2834 | return videobuf_qbuf(bttv_queue(fh), b); | ||
2835 | } | ||
2836 | |||
2837 | static int bttv_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) | ||
2838 | { | ||
2839 | struct bttv_fh *fh = priv; | ||
2840 | return videobuf_dqbuf(bttv_queue(fh), b, | ||
2841 | file->f_flags & O_NONBLOCK); | ||
2842 | } | ||
2843 | |||
2844 | static int bttv_streamon(struct file *file, void *priv, | ||
2845 | enum v4l2_buf_type type) | ||
2846 | { | ||
2847 | struct bttv_fh *fh = priv; | ||
2848 | struct bttv *btv = fh->btv; | ||
2849 | int res = bttv_resource(fh); | ||
2850 | |||
2851 | if (!check_alloc_btres_lock(btv, fh, res)) | ||
2852 | return -EBUSY; | ||
2853 | return videobuf_streamon(bttv_queue(fh)); | ||
2854 | } | ||
2855 | |||
2856 | |||
2857 | static int bttv_streamoff(struct file *file, void *priv, | ||
2858 | enum v4l2_buf_type type) | ||
2859 | { | ||
2860 | struct bttv_fh *fh = priv; | ||
2861 | struct bttv *btv = fh->btv; | ||
2862 | int retval; | ||
2863 | int res = bttv_resource(fh); | ||
2864 | |||
2865 | |||
2866 | retval = videobuf_streamoff(bttv_queue(fh)); | ||
2867 | if (retval < 0) | ||
2868 | return retval; | ||
2869 | free_btres_lock(btv, fh, res); | ||
2870 | return 0; | ||
2871 | } | ||
2872 | |||
2873 | static int bttv_queryctrl(struct file *file, void *priv, | ||
2874 | struct v4l2_queryctrl *c) | ||
2875 | { | ||
2876 | struct bttv_fh *fh = priv; | ||
2877 | struct bttv *btv = fh->btv; | ||
2878 | const struct v4l2_queryctrl *ctrl; | ||
2879 | |||
2880 | if ((c->id < V4L2_CID_BASE || | ||
2881 | c->id >= V4L2_CID_LASTP1) && | ||
2882 | (c->id < V4L2_CID_PRIVATE_BASE || | ||
2883 | c->id >= V4L2_CID_PRIVATE_LASTP1)) | ||
2884 | return -EINVAL; | ||
2885 | |||
2886 | if (!btv->volume_gpio && (c->id == V4L2_CID_AUDIO_VOLUME)) | ||
2887 | *c = no_ctl; | ||
2888 | else { | ||
2889 | ctrl = ctrl_by_id(c->id); | ||
2890 | |||
2891 | *c = (NULL != ctrl) ? *ctrl : no_ctl; | ||
2892 | } | ||
2893 | |||
2894 | return 0; | ||
2895 | } | ||
2896 | |||
2897 | static int bttv_g_parm(struct file *file, void *f, | ||
2898 | struct v4l2_streamparm *parm) | ||
2899 | { | ||
2900 | struct bttv_fh *fh = f; | ||
2901 | struct bttv *btv = fh->btv; | ||
2902 | |||
2903 | v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id, | ||
2904 | &parm->parm.capture.timeperframe); | ||
2905 | |||
2906 | return 0; | ||
2907 | } | ||
2908 | |||
2909 | static int bttv_g_tuner(struct file *file, void *priv, | ||
2910 | struct v4l2_tuner *t) | ||
2911 | { | ||
2912 | struct bttv_fh *fh = priv; | ||
2913 | struct bttv *btv = fh->btv; | ||
2914 | |||
2915 | if (btv->tuner_type == TUNER_ABSENT) | ||
2916 | return -EINVAL; | ||
2917 | if (0 != t->index) | ||
2918 | return -EINVAL; | ||
2919 | |||
2920 | t->rxsubchans = V4L2_TUNER_SUB_MONO; | ||
2921 | bttv_call_all(btv, tuner, g_tuner, t); | ||
2922 | strcpy(t->name, "Television"); | ||
2923 | t->capability = V4L2_TUNER_CAP_NORM; | ||
2924 | t->type = V4L2_TUNER_ANALOG_TV; | ||
2925 | if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC) | ||
2926 | t->signal = 0xffff; | ||
2927 | |||
2928 | if (btv->audio_mode_gpio) | ||
2929 | btv->audio_mode_gpio(btv, t, 0); | ||
2930 | |||
2931 | return 0; | ||
2932 | } | ||
2933 | |||
2934 | static int bttv_g_priority(struct file *file, void *f, enum v4l2_priority *p) | ||
2935 | { | ||
2936 | struct bttv_fh *fh = f; | ||
2937 | struct bttv *btv = fh->btv; | ||
2938 | |||
2939 | *p = v4l2_prio_max(&btv->prio); | ||
2940 | |||
2941 | return 0; | ||
2942 | } | ||
2943 | |||
2944 | static int bttv_s_priority(struct file *file, void *f, | ||
2945 | enum v4l2_priority prio) | ||
2946 | { | ||
2947 | struct bttv_fh *fh = f; | ||
2948 | struct bttv *btv = fh->btv; | ||
2949 | int rc; | ||
2950 | |||
2951 | rc = v4l2_prio_change(&btv->prio, &fh->prio, prio); | ||
2952 | |||
2953 | return rc; | ||
2954 | } | ||
2955 | |||
2956 | static int bttv_cropcap(struct file *file, void *priv, | ||
2957 | struct v4l2_cropcap *cap) | ||
2958 | { | ||
2959 | struct bttv_fh *fh = priv; | ||
2960 | struct bttv *btv = fh->btv; | ||
2961 | |||
2962 | if (cap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && | ||
2963 | cap->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) | ||
2964 | return -EINVAL; | ||
2965 | |||
2966 | *cap = bttv_tvnorms[btv->tvnorm].cropcap; | ||
2967 | |||
2968 | return 0; | ||
2969 | } | ||
2970 | |||
2971 | static int bttv_g_crop(struct file *file, void *f, struct v4l2_crop *crop) | ||
2972 | { | ||
2973 | struct bttv_fh *fh = f; | ||
2974 | struct bttv *btv = fh->btv; | ||
2975 | |||
2976 | if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && | ||
2977 | crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) | ||
2978 | return -EINVAL; | ||
2979 | |||
2980 | /* No fh->do_crop = 1; because btv->crop[1] may be | ||
2981 | inconsistent with fh->width or fh->height and apps | ||
2982 | do not expect a change here. */ | ||
2983 | |||
2984 | crop->c = btv->crop[!!fh->do_crop].rect; | ||
2985 | |||
2986 | return 0; | ||
2987 | } | ||
2988 | |||
2989 | static int bttv_s_crop(struct file *file, void *f, struct v4l2_crop *crop) | ||
2990 | { | ||
2991 | struct bttv_fh *fh = f; | ||
2992 | struct bttv *btv = fh->btv; | ||
2993 | const struct v4l2_rect *b; | ||
2994 | int retval; | ||
2995 | struct bttv_crop c; | ||
2996 | __s32 b_left; | ||
2997 | __s32 b_top; | ||
2998 | __s32 b_right; | ||
2999 | __s32 b_bottom; | ||
3000 | |||
3001 | if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && | ||
3002 | crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY) | ||
3003 | return -EINVAL; | ||
3004 | |||
3005 | /* Make sure tvnorm, vbi_end and the current cropping | ||
3006 | parameters remain consistent until we're done. Note | ||
3007 | read() may change vbi_end in check_alloc_btres_lock(). */ | ||
3008 | retval = v4l2_prio_check(&btv->prio, fh->prio); | ||
3009 | if (0 != retval) { | ||
3010 | return retval; | ||
3011 | } | ||
3012 | |||
3013 | retval = -EBUSY; | ||
3014 | |||
3015 | if (locked_btres(fh->btv, VIDEO_RESOURCES)) { | ||
3016 | return retval; | ||
3017 | } | ||
3018 | |||
3019 | b = &bttv_tvnorms[btv->tvnorm].cropcap.bounds; | ||
3020 | |||
3021 | b_left = b->left; | ||
3022 | b_right = b_left + b->width; | ||
3023 | b_bottom = b->top + b->height; | ||
3024 | |||
3025 | b_top = max(b->top, btv->vbi_end); | ||
3026 | if (b_top + 32 >= b_bottom) { | ||
3027 | return retval; | ||
3028 | } | ||
3029 | |||
3030 | /* Min. scaled size 48 x 32. */ | ||
3031 | c.rect.left = clamp(crop->c.left, b_left, b_right - 48); | ||
3032 | c.rect.left = min(c.rect.left, (__s32) MAX_HDELAY); | ||
3033 | |||
3034 | c.rect.width = clamp(crop->c.width, | ||
3035 | 48, b_right - c.rect.left); | ||
3036 | |||
3037 | c.rect.top = clamp(crop->c.top, b_top, b_bottom - 32); | ||
3038 | /* Top and height must be a multiple of two. */ | ||
3039 | c.rect.top = (c.rect.top + 1) & ~1; | ||
3040 | |||
3041 | c.rect.height = clamp(crop->c.height, | ||
3042 | 32, b_bottom - c.rect.top); | ||
3043 | c.rect.height = (c.rect.height + 1) & ~1; | ||
3044 | |||
3045 | bttv_crop_calc_limits(&c); | ||
3046 | |||
3047 | btv->crop[1] = c; | ||
3048 | |||
3049 | fh->do_crop = 1; | ||
3050 | |||
3051 | if (fh->width < c.min_scaled_width) { | ||
3052 | fh->width = c.min_scaled_width; | ||
3053 | btv->init.width = c.min_scaled_width; | ||
3054 | } else if (fh->width > c.max_scaled_width) { | ||
3055 | fh->width = c.max_scaled_width; | ||
3056 | btv->init.width = c.max_scaled_width; | ||
3057 | } | ||
3058 | |||
3059 | if (fh->height < c.min_scaled_height) { | ||
3060 | fh->height = c.min_scaled_height; | ||
3061 | btv->init.height = c.min_scaled_height; | ||
3062 | } else if (fh->height > c.max_scaled_height) { | ||
3063 | fh->height = c.max_scaled_height; | ||
3064 | btv->init.height = c.max_scaled_height; | ||
3065 | } | ||
3066 | |||
3067 | return 0; | ||
3068 | } | ||
3069 | |||
3070 | static int bttv_g_audio(struct file *file, void *priv, struct v4l2_audio *a) | ||
3071 | { | ||
3072 | if (unlikely(a->index)) | ||
3073 | return -EINVAL; | ||
3074 | |||
3075 | strcpy(a->name, "audio"); | ||
3076 | return 0; | ||
3077 | } | ||
3078 | |||
3079 | static int bttv_s_audio(struct file *file, void *priv, struct v4l2_audio *a) | ||
3080 | { | ||
3081 | if (unlikely(a->index)) | ||
3082 | return -EINVAL; | ||
3083 | |||
3084 | return 0; | ||
3085 | } | ||
3086 | |||
3087 | static ssize_t bttv_read(struct file *file, char __user *data, | ||
3088 | size_t count, loff_t *ppos) | ||
3089 | { | ||
3090 | struct bttv_fh *fh = file->private_data; | ||
3091 | int retval = 0; | ||
3092 | |||
3093 | if (fh->btv->errors) | ||
3094 | bttv_reinit_bt848(fh->btv); | ||
3095 | dprintk("%d: read count=%d type=%s\n", | ||
3096 | fh->btv->c.nr, (int)count, v4l2_type_names[fh->type]); | ||
3097 | |||
3098 | switch (fh->type) { | ||
3099 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: | ||
3100 | if (!check_alloc_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ)) { | ||
3101 | /* VIDEO_READ in use by another fh, | ||
3102 | or VIDEO_STREAM by any fh. */ | ||
3103 | return -EBUSY; | ||
3104 | } | ||
3105 | retval = videobuf_read_one(&fh->cap, data, count, ppos, | ||
3106 | file->f_flags & O_NONBLOCK); | ||
3107 | free_btres_lock(fh->btv, fh, RESOURCE_VIDEO_READ); | ||
3108 | break; | ||
3109 | case V4L2_BUF_TYPE_VBI_CAPTURE: | ||
3110 | if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) | ||
3111 | return -EBUSY; | ||
3112 | retval = videobuf_read_stream(&fh->vbi, data, count, ppos, 1, | ||
3113 | file->f_flags & O_NONBLOCK); | ||
3114 | break; | ||
3115 | default: | ||
3116 | BUG(); | ||
3117 | } | ||
3118 | return retval; | ||
3119 | } | ||
3120 | |||
3121 | static unsigned int bttv_poll(struct file *file, poll_table *wait) | ||
3122 | { | ||
3123 | struct bttv_fh *fh = file->private_data; | ||
3124 | struct bttv_buffer *buf; | ||
3125 | enum v4l2_field field; | ||
3126 | unsigned int rc = POLLERR; | ||
3127 | |||
3128 | if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { | ||
3129 | if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) | ||
3130 | return POLLERR; | ||
3131 | return videobuf_poll_stream(file, &fh->vbi, wait); | ||
3132 | } | ||
3133 | |||
3134 | if (check_btres(fh,RESOURCE_VIDEO_STREAM)) { | ||
3135 | /* streaming capture */ | ||
3136 | if (list_empty(&fh->cap.stream)) | ||
3137 | goto err; | ||
3138 | buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); | ||
3139 | } else { | ||
3140 | /* read() capture */ | ||
3141 | if (NULL == fh->cap.read_buf) { | ||
3142 | /* need to capture a new frame */ | ||
3143 | if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) | ||
3144 | goto err; | ||
3145 | fh->cap.read_buf = videobuf_sg_alloc(fh->cap.msize); | ||
3146 | if (NULL == fh->cap.read_buf) | ||
3147 | goto err; | ||
3148 | fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; | ||
3149 | field = videobuf_next_field(&fh->cap); | ||
3150 | if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { | ||
3151 | kfree (fh->cap.read_buf); | ||
3152 | fh->cap.read_buf = NULL; | ||
3153 | goto err; | ||
3154 | } | ||
3155 | fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); | ||
3156 | fh->cap.read_off = 0; | ||
3157 | } | ||
3158 | buf = (struct bttv_buffer*)fh->cap.read_buf; | ||
3159 | } | ||
3160 | |||
3161 | poll_wait(file, &buf->vb.done, wait); | ||
3162 | if (buf->vb.state == VIDEOBUF_DONE || | ||
3163 | buf->vb.state == VIDEOBUF_ERROR) | ||
3164 | rc = POLLIN|POLLRDNORM; | ||
3165 | else | ||
3166 | rc = 0; | ||
3167 | err: | ||
3168 | return rc; | ||
3169 | } | ||
3170 | |||
3171 | static int bttv_open(struct file *file) | ||
3172 | { | ||
3173 | struct video_device *vdev = video_devdata(file); | ||
3174 | struct bttv *btv = video_drvdata(file); | ||
3175 | struct bttv_fh *fh; | ||
3176 | enum v4l2_buf_type type = 0; | ||
3177 | |||
3178 | dprintk("open dev=%s\n", video_device_node_name(vdev)); | ||
3179 | |||
3180 | if (vdev->vfl_type == VFL_TYPE_GRABBER) { | ||
3181 | type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
3182 | } else if (vdev->vfl_type == VFL_TYPE_VBI) { | ||
3183 | type = V4L2_BUF_TYPE_VBI_CAPTURE; | ||
3184 | } else { | ||
3185 | WARN_ON(1); | ||
3186 | return -ENODEV; | ||
3187 | } | ||
3188 | |||
3189 | dprintk("%d: open called (type=%s)\n", | ||
3190 | btv->c.nr, v4l2_type_names[type]); | ||
3191 | |||
3192 | /* allocate per filehandle data */ | ||
3193 | fh = kmalloc(sizeof(*fh), GFP_KERNEL); | ||
3194 | if (unlikely(!fh)) | ||
3195 | return -ENOMEM; | ||
3196 | file->private_data = fh; | ||
3197 | |||
3198 | *fh = btv->init; | ||
3199 | |||
3200 | fh->type = type; | ||
3201 | fh->ov.setup_ok = 0; | ||
3202 | |||
3203 | v4l2_prio_open(&btv->prio, &fh->prio); | ||
3204 | |||
3205 | videobuf_queue_sg_init(&fh->cap, &bttv_video_qops, | ||
3206 | &btv->c.pci->dev, &btv->s_lock, | ||
3207 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | ||
3208 | V4L2_FIELD_INTERLACED, | ||
3209 | sizeof(struct bttv_buffer), | ||
3210 | fh, &btv->lock); | ||
3211 | videobuf_queue_sg_init(&fh->vbi, &bttv_vbi_qops, | ||
3212 | &btv->c.pci->dev, &btv->s_lock, | ||
3213 | V4L2_BUF_TYPE_VBI_CAPTURE, | ||
3214 | V4L2_FIELD_SEQ_TB, | ||
3215 | sizeof(struct bttv_buffer), | ||
3216 | fh, &btv->lock); | ||
3217 | set_tvnorm(btv,btv->tvnorm); | ||
3218 | set_input(btv, btv->input, btv->tvnorm); | ||
3219 | |||
3220 | btv->users++; | ||
3221 | |||
3222 | /* The V4L2 spec requires one global set of cropping parameters | ||
3223 | which only change on request. These are stored in btv->crop[1]. | ||
3224 | However for compatibility with V4L apps and cropping unaware | ||
3225 | V4L2 apps we now reset the cropping parameters as seen through | ||
3226 | this fh, which is to say VIDIOC_G_CROP and scaling limit checks | ||
3227 | will use btv->crop[0], the default cropping parameters for the | ||
3228 | current video standard, and VIDIOC_S_FMT will not implicitely | ||
3229 | change the cropping parameters until VIDIOC_S_CROP has been | ||
3230 | called. */ | ||
3231 | fh->do_crop = !reset_crop; /* module parameter */ | ||
3232 | |||
3233 | /* Likewise there should be one global set of VBI capture | ||
3234 | parameters, but for compatibility with V4L apps and earlier | ||
3235 | driver versions each fh has its own parameters. */ | ||
3236 | bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); | ||
3237 | |||
3238 | bttv_field_count(btv); | ||
3239 | return 0; | ||
3240 | } | ||
3241 | |||
3242 | static int bttv_release(struct file *file) | ||
3243 | { | ||
3244 | struct bttv_fh *fh = file->private_data; | ||
3245 | struct bttv *btv = fh->btv; | ||
3246 | |||
3247 | /* turn off overlay */ | ||
3248 | if (check_btres(fh, RESOURCE_OVERLAY)) | ||
3249 | bttv_switch_overlay(btv,fh,NULL); | ||
3250 | |||
3251 | /* stop video capture */ | ||
3252 | if (check_btres(fh, RESOURCE_VIDEO_STREAM)) { | ||
3253 | videobuf_streamoff(&fh->cap); | ||
3254 | free_btres_lock(btv,fh,RESOURCE_VIDEO_STREAM); | ||
3255 | } | ||
3256 | if (fh->cap.read_buf) { | ||
3257 | buffer_release(&fh->cap,fh->cap.read_buf); | ||
3258 | kfree(fh->cap.read_buf); | ||
3259 | } | ||
3260 | if (check_btres(fh, RESOURCE_VIDEO_READ)) { | ||
3261 | free_btres_lock(btv, fh, RESOURCE_VIDEO_READ); | ||
3262 | } | ||
3263 | |||
3264 | /* stop vbi capture */ | ||
3265 | if (check_btres(fh, RESOURCE_VBI)) { | ||
3266 | videobuf_stop(&fh->vbi); | ||
3267 | free_btres_lock(btv,fh,RESOURCE_VBI); | ||
3268 | } | ||
3269 | |||
3270 | /* free stuff */ | ||
3271 | |||
3272 | videobuf_mmap_free(&fh->cap); | ||
3273 | videobuf_mmap_free(&fh->vbi); | ||
3274 | v4l2_prio_close(&btv->prio, fh->prio); | ||
3275 | file->private_data = NULL; | ||
3276 | kfree(fh); | ||
3277 | |||
3278 | btv->users--; | ||
3279 | bttv_field_count(btv); | ||
3280 | |||
3281 | if (!btv->users) | ||
3282 | audio_mute(btv, 1); | ||
3283 | |||
3284 | return 0; | ||
3285 | } | ||
3286 | |||
3287 | static int | ||
3288 | bttv_mmap(struct file *file, struct vm_area_struct *vma) | ||
3289 | { | ||
3290 | struct bttv_fh *fh = file->private_data; | ||
3291 | |||
3292 | dprintk("%d: mmap type=%s 0x%lx+%ld\n", | ||
3293 | fh->btv->c.nr, v4l2_type_names[fh->type], | ||
3294 | vma->vm_start, vma->vm_end - vma->vm_start); | ||
3295 | return videobuf_mmap_mapper(bttv_queue(fh),vma); | ||
3296 | } | ||
3297 | |||
3298 | static const struct v4l2_file_operations bttv_fops = | ||
3299 | { | ||
3300 | .owner = THIS_MODULE, | ||
3301 | .open = bttv_open, | ||
3302 | .release = bttv_release, | ||
3303 | .unlocked_ioctl = video_ioctl2, | ||
3304 | .read = bttv_read, | ||
3305 | .mmap = bttv_mmap, | ||
3306 | .poll = bttv_poll, | ||
3307 | }; | ||
3308 | |||
3309 | static const struct v4l2_ioctl_ops bttv_ioctl_ops = { | ||
3310 | .vidioc_querycap = bttv_querycap, | ||
3311 | .vidioc_enum_fmt_vid_cap = bttv_enum_fmt_vid_cap, | ||
3312 | .vidioc_g_fmt_vid_cap = bttv_g_fmt_vid_cap, | ||
3313 | .vidioc_try_fmt_vid_cap = bttv_try_fmt_vid_cap, | ||
3314 | .vidioc_s_fmt_vid_cap = bttv_s_fmt_vid_cap, | ||
3315 | .vidioc_enum_fmt_vid_overlay = bttv_enum_fmt_vid_overlay, | ||
3316 | .vidioc_g_fmt_vid_overlay = bttv_g_fmt_vid_overlay, | ||
3317 | .vidioc_try_fmt_vid_overlay = bttv_try_fmt_vid_overlay, | ||
3318 | .vidioc_s_fmt_vid_overlay = bttv_s_fmt_vid_overlay, | ||
3319 | .vidioc_g_fmt_vbi_cap = bttv_g_fmt_vbi_cap, | ||
3320 | .vidioc_try_fmt_vbi_cap = bttv_try_fmt_vbi_cap, | ||
3321 | .vidioc_s_fmt_vbi_cap = bttv_s_fmt_vbi_cap, | ||
3322 | .vidioc_g_audio = bttv_g_audio, | ||
3323 | .vidioc_s_audio = bttv_s_audio, | ||
3324 | .vidioc_cropcap = bttv_cropcap, | ||
3325 | .vidioc_reqbufs = bttv_reqbufs, | ||
3326 | .vidioc_querybuf = bttv_querybuf, | ||
3327 | .vidioc_qbuf = bttv_qbuf, | ||
3328 | .vidioc_dqbuf = bttv_dqbuf, | ||
3329 | .vidioc_s_std = bttv_s_std, | ||
3330 | .vidioc_enum_input = bttv_enum_input, | ||
3331 | .vidioc_g_input = bttv_g_input, | ||
3332 | .vidioc_s_input = bttv_s_input, | ||
3333 | .vidioc_queryctrl = bttv_queryctrl, | ||
3334 | .vidioc_g_ctrl = bttv_g_ctrl, | ||
3335 | .vidioc_s_ctrl = bttv_s_ctrl, | ||
3336 | .vidioc_streamon = bttv_streamon, | ||
3337 | .vidioc_streamoff = bttv_streamoff, | ||
3338 | .vidioc_g_tuner = bttv_g_tuner, | ||
3339 | .vidioc_s_tuner = bttv_s_tuner, | ||
3340 | .vidioc_g_crop = bttv_g_crop, | ||
3341 | .vidioc_s_crop = bttv_s_crop, | ||
3342 | .vidioc_g_fbuf = bttv_g_fbuf, | ||
3343 | .vidioc_s_fbuf = bttv_s_fbuf, | ||
3344 | .vidioc_overlay = bttv_overlay, | ||
3345 | .vidioc_g_priority = bttv_g_priority, | ||
3346 | .vidioc_s_priority = bttv_s_priority, | ||
3347 | .vidioc_g_parm = bttv_g_parm, | ||
3348 | .vidioc_g_frequency = bttv_g_frequency, | ||
3349 | .vidioc_s_frequency = bttv_s_frequency, | ||
3350 | .vidioc_log_status = bttv_log_status, | ||
3351 | .vidioc_querystd = bttv_querystd, | ||
3352 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
3353 | .vidioc_g_register = bttv_g_register, | ||
3354 | .vidioc_s_register = bttv_s_register, | ||
3355 | #endif | ||
3356 | }; | ||
3357 | |||
3358 | static struct video_device bttv_video_template = { | ||
3359 | .fops = &bttv_fops, | ||
3360 | .ioctl_ops = &bttv_ioctl_ops, | ||
3361 | .tvnorms = BTTV_NORMS, | ||
3362 | .current_norm = V4L2_STD_PAL, | ||
3363 | }; | ||
3364 | |||
3365 | /* ----------------------------------------------------------------------- */ | ||
3366 | /* radio interface */ | ||
3367 | |||
3368 | static int radio_open(struct file *file) | ||
3369 | { | ||
3370 | struct video_device *vdev = video_devdata(file); | ||
3371 | struct bttv *btv = video_drvdata(file); | ||
3372 | struct bttv_fh *fh; | ||
3373 | |||
3374 | dprintk("open dev=%s\n", video_device_node_name(vdev)); | ||
3375 | |||
3376 | dprintk("%d: open called (radio)\n", btv->c.nr); | ||
3377 | |||
3378 | /* allocate per filehandle data */ | ||
3379 | fh = kmalloc(sizeof(*fh), GFP_KERNEL); | ||
3380 | if (unlikely(!fh)) | ||
3381 | return -ENOMEM; | ||
3382 | file->private_data = fh; | ||
3383 | *fh = btv->init; | ||
3384 | |||
3385 | v4l2_prio_open(&btv->prio, &fh->prio); | ||
3386 | |||
3387 | btv->radio_user++; | ||
3388 | |||
3389 | bttv_call_all(btv, tuner, s_radio); | ||
3390 | audio_input(btv,TVAUDIO_INPUT_RADIO); | ||
3391 | |||
3392 | return 0; | ||
3393 | } | ||
3394 | |||
3395 | static int radio_release(struct file *file) | ||
3396 | { | ||
3397 | struct bttv_fh *fh = file->private_data; | ||
3398 | struct bttv *btv = fh->btv; | ||
3399 | struct saa6588_command cmd; | ||
3400 | |||
3401 | v4l2_prio_close(&btv->prio, fh->prio); | ||
3402 | file->private_data = NULL; | ||
3403 | kfree(fh); | ||
3404 | |||
3405 | btv->radio_user--; | ||
3406 | |||
3407 | bttv_call_all(btv, core, ioctl, SAA6588_CMD_CLOSE, &cmd); | ||
3408 | |||
3409 | return 0; | ||
3410 | } | ||
3411 | |||
3412 | static int radio_querycap(struct file *file, void *priv, | ||
3413 | struct v4l2_capability *cap) | ||
3414 | { | ||
3415 | struct bttv_fh *fh = priv; | ||
3416 | struct bttv *btv = fh->btv; | ||
3417 | |||
3418 | strcpy(cap->driver, "bttv"); | ||
3419 | strlcpy(cap->card, btv->radio_dev->name, sizeof(cap->card)); | ||
3420 | sprintf(cap->bus_info, "PCI:%s", pci_name(btv->c.pci)); | ||
3421 | cap->capabilities = V4L2_CAP_TUNER; | ||
3422 | |||
3423 | return 0; | ||
3424 | } | ||
3425 | |||
3426 | static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t) | ||
3427 | { | ||
3428 | struct bttv_fh *fh = priv; | ||
3429 | struct bttv *btv = fh->btv; | ||
3430 | |||
3431 | if (btv->tuner_type == TUNER_ABSENT) | ||
3432 | return -EINVAL; | ||
3433 | if (0 != t->index) | ||
3434 | return -EINVAL; | ||
3435 | strcpy(t->name, "Radio"); | ||
3436 | t->type = V4L2_TUNER_RADIO; | ||
3437 | |||
3438 | bttv_call_all(btv, tuner, g_tuner, t); | ||
3439 | |||
3440 | if (btv->audio_mode_gpio) | ||
3441 | btv->audio_mode_gpio(btv, t, 0); | ||
3442 | |||
3443 | return 0; | ||
3444 | } | ||
3445 | |||
3446 | static int radio_enum_input(struct file *file, void *priv, | ||
3447 | struct v4l2_input *i) | ||
3448 | { | ||
3449 | if (i->index != 0) | ||
3450 | return -EINVAL; | ||
3451 | |||
3452 | strcpy(i->name, "Radio"); | ||
3453 | i->type = V4L2_INPUT_TYPE_TUNER; | ||
3454 | |||
3455 | return 0; | ||
3456 | } | ||
3457 | |||
3458 | static int radio_g_audio(struct file *file, void *priv, | ||
3459 | struct v4l2_audio *a) | ||
3460 | { | ||
3461 | if (unlikely(a->index)) | ||
3462 | return -EINVAL; | ||
3463 | |||
3464 | strcpy(a->name, "Radio"); | ||
3465 | |||
3466 | return 0; | ||
3467 | } | ||
3468 | |||
3469 | static int radio_s_tuner(struct file *file, void *priv, | ||
3470 | struct v4l2_tuner *t) | ||
3471 | { | ||
3472 | struct bttv_fh *fh = priv; | ||
3473 | struct bttv *btv = fh->btv; | ||
3474 | |||
3475 | if (0 != t->index) | ||
3476 | return -EINVAL; | ||
3477 | |||
3478 | bttv_call_all(btv, tuner, s_tuner, t); | ||
3479 | return 0; | ||
3480 | } | ||
3481 | |||
3482 | static int radio_s_audio(struct file *file, void *priv, | ||
3483 | struct v4l2_audio *a) | ||
3484 | { | ||
3485 | if (unlikely(a->index)) | ||
3486 | return -EINVAL; | ||
3487 | |||
3488 | return 0; | ||
3489 | } | ||
3490 | |||
3491 | static int radio_s_input(struct file *filp, void *priv, unsigned int i) | ||
3492 | { | ||
3493 | if (unlikely(i)) | ||
3494 | return -EINVAL; | ||
3495 | |||
3496 | return 0; | ||
3497 | } | ||
3498 | |||
3499 | static int radio_s_std(struct file *file, void *fh, v4l2_std_id *norm) | ||
3500 | { | ||
3501 | return 0; | ||
3502 | } | ||
3503 | |||
3504 | static int radio_queryctrl(struct file *file, void *priv, | ||
3505 | struct v4l2_queryctrl *c) | ||
3506 | { | ||
3507 | const struct v4l2_queryctrl *ctrl; | ||
3508 | |||
3509 | if (c->id < V4L2_CID_BASE || | ||
3510 | c->id >= V4L2_CID_LASTP1) | ||
3511 | return -EINVAL; | ||
3512 | |||
3513 | if (c->id == V4L2_CID_AUDIO_MUTE) { | ||
3514 | ctrl = ctrl_by_id(c->id); | ||
3515 | *c = *ctrl; | ||
3516 | } else | ||
3517 | *c = no_ctl; | ||
3518 | |||
3519 | return 0; | ||
3520 | } | ||
3521 | |||
3522 | static int radio_g_input(struct file *filp, void *priv, unsigned int *i) | ||
3523 | { | ||
3524 | *i = 0; | ||
3525 | return 0; | ||
3526 | } | ||
3527 | |||
3528 | static ssize_t radio_read(struct file *file, char __user *data, | ||
3529 | size_t count, loff_t *ppos) | ||
3530 | { | ||
3531 | struct bttv_fh *fh = file->private_data; | ||
3532 | struct bttv *btv = fh->btv; | ||
3533 | struct saa6588_command cmd; | ||
3534 | cmd.block_count = count/3; | ||
3535 | cmd.buffer = data; | ||
3536 | cmd.instance = file; | ||
3537 | cmd.result = -ENODEV; | ||
3538 | |||
3539 | bttv_call_all(btv, core, ioctl, SAA6588_CMD_READ, &cmd); | ||
3540 | |||
3541 | return cmd.result; | ||
3542 | } | ||
3543 | |||
3544 | static unsigned int radio_poll(struct file *file, poll_table *wait) | ||
3545 | { | ||
3546 | struct bttv_fh *fh = file->private_data; | ||
3547 | struct bttv *btv = fh->btv; | ||
3548 | struct saa6588_command cmd; | ||
3549 | cmd.instance = file; | ||
3550 | cmd.event_list = wait; | ||
3551 | cmd.result = -ENODEV; | ||
3552 | bttv_call_all(btv, core, ioctl, SAA6588_CMD_POLL, &cmd); | ||
3553 | |||
3554 | return cmd.result; | ||
3555 | } | ||
3556 | |||
3557 | static const struct v4l2_file_operations radio_fops = | ||
3558 | { | ||
3559 | .owner = THIS_MODULE, | ||
3560 | .open = radio_open, | ||
3561 | .read = radio_read, | ||
3562 | .release = radio_release, | ||
3563 | .unlocked_ioctl = video_ioctl2, | ||
3564 | .poll = radio_poll, | ||
3565 | }; | ||
3566 | |||
3567 | static const struct v4l2_ioctl_ops radio_ioctl_ops = { | ||
3568 | .vidioc_querycap = radio_querycap, | ||
3569 | .vidioc_g_tuner = radio_g_tuner, | ||
3570 | .vidioc_enum_input = radio_enum_input, | ||
3571 | .vidioc_g_audio = radio_g_audio, | ||
3572 | .vidioc_s_tuner = radio_s_tuner, | ||
3573 | .vidioc_s_audio = radio_s_audio, | ||
3574 | .vidioc_s_input = radio_s_input, | ||
3575 | .vidioc_s_std = radio_s_std, | ||
3576 | .vidioc_queryctrl = radio_queryctrl, | ||
3577 | .vidioc_g_input = radio_g_input, | ||
3578 | .vidioc_g_ctrl = bttv_g_ctrl, | ||
3579 | .vidioc_s_ctrl = bttv_s_ctrl, | ||
3580 | .vidioc_g_frequency = bttv_g_frequency, | ||
3581 | .vidioc_s_frequency = bttv_s_frequency, | ||
3582 | }; | ||
3583 | |||
3584 | static struct video_device radio_template = { | ||
3585 | .fops = &radio_fops, | ||
3586 | .ioctl_ops = &radio_ioctl_ops, | ||
3587 | }; | ||
3588 | |||
3589 | /* ----------------------------------------------------------------------- */ | ||
3590 | /* some debug code */ | ||
3591 | |||
3592 | static int bttv_risc_decode(u32 risc) | ||
3593 | { | ||
3594 | static char *instr[16] = { | ||
3595 | [ BT848_RISC_WRITE >> 28 ] = "write", | ||
3596 | [ BT848_RISC_SKIP >> 28 ] = "skip", | ||
3597 | [ BT848_RISC_WRITEC >> 28 ] = "writec", | ||
3598 | [ BT848_RISC_JUMP >> 28 ] = "jump", | ||
3599 | [ BT848_RISC_SYNC >> 28 ] = "sync", | ||
3600 | [ BT848_RISC_WRITE123 >> 28 ] = "write123", | ||
3601 | [ BT848_RISC_SKIP123 >> 28 ] = "skip123", | ||
3602 | [ BT848_RISC_WRITE1S23 >> 28 ] = "write1s23", | ||
3603 | }; | ||
3604 | static int incr[16] = { | ||
3605 | [ BT848_RISC_WRITE >> 28 ] = 2, | ||
3606 | [ BT848_RISC_JUMP >> 28 ] = 2, | ||
3607 | [ BT848_RISC_SYNC >> 28 ] = 2, | ||
3608 | [ BT848_RISC_WRITE123 >> 28 ] = 5, | ||
3609 | [ BT848_RISC_SKIP123 >> 28 ] = 2, | ||
3610 | [ BT848_RISC_WRITE1S23 >> 28 ] = 3, | ||
3611 | }; | ||
3612 | static char *bits[] = { | ||
3613 | "be0", "be1", "be2", "be3/resync", | ||
3614 | "set0", "set1", "set2", "set3", | ||
3615 | "clr0", "clr1", "clr2", "clr3", | ||
3616 | "irq", "res", "eol", "sol", | ||
3617 | }; | ||
3618 | int i; | ||
3619 | |||
3620 | pr_cont("0x%08x [ %s", risc, | ||
3621 | instr[risc >> 28] ? instr[risc >> 28] : "INVALID"); | ||
3622 | for (i = ARRAY_SIZE(bits)-1; i >= 0; i--) | ||
3623 | if (risc & (1 << (i + 12))) | ||
3624 | pr_cont(" %s", bits[i]); | ||
3625 | pr_cont(" count=%d ]\n", risc & 0xfff); | ||
3626 | return incr[risc >> 28] ? incr[risc >> 28] : 1; | ||
3627 | } | ||
3628 | |||
3629 | static void bttv_risc_disasm(struct bttv *btv, | ||
3630 | struct btcx_riscmem *risc) | ||
3631 | { | ||
3632 | unsigned int i,j,n; | ||
3633 | |||
3634 | pr_info("%s: risc disasm: %p [dma=0x%08lx]\n", | ||
3635 | btv->c.v4l2_dev.name, risc->cpu, (unsigned long)risc->dma); | ||
3636 | for (i = 0; i < (risc->size >> 2); i += n) { | ||
3637 | pr_info("%s: 0x%lx: ", | ||
3638 | btv->c.v4l2_dev.name, | ||
3639 | (unsigned long)(risc->dma + (i<<2))); | ||
3640 | n = bttv_risc_decode(le32_to_cpu(risc->cpu[i])); | ||
3641 | for (j = 1; j < n; j++) | ||
3642 | pr_info("%s: 0x%lx: 0x%08x [ arg #%d ]\n", | ||
3643 | btv->c.v4l2_dev.name, | ||
3644 | (unsigned long)(risc->dma + ((i+j)<<2)), | ||
3645 | risc->cpu[i+j], j); | ||
3646 | if (0 == risc->cpu[i]) | ||
3647 | break; | ||
3648 | } | ||
3649 | } | ||
3650 | |||
3651 | static void bttv_print_riscaddr(struct bttv *btv) | ||
3652 | { | ||
3653 | pr_info(" main: %08llx\n", (unsigned long long)btv->main.dma); | ||
3654 | pr_info(" vbi : o=%08llx e=%08llx\n", | ||
3655 | btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0, | ||
3656 | btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0); | ||
3657 | pr_info(" cap : o=%08llx e=%08llx\n", | ||
3658 | btv->curr.top | ||
3659 | ? (unsigned long long)btv->curr.top->top.dma : 0, | ||
3660 | btv->curr.bottom | ||
3661 | ? (unsigned long long)btv->curr.bottom->bottom.dma : 0); | ||
3662 | pr_info(" scr : o=%08llx e=%08llx\n", | ||
3663 | btv->screen ? (unsigned long long)btv->screen->top.dma : 0, | ||
3664 | btv->screen ? (unsigned long long)btv->screen->bottom.dma : 0); | ||
3665 | bttv_risc_disasm(btv, &btv->main); | ||
3666 | } | ||
3667 | |||
3668 | /* ----------------------------------------------------------------------- */ | ||
3669 | /* irq handler */ | ||
3670 | |||
3671 | static char *irq_name[] = { | ||
3672 | "FMTCHG", // format change detected (525 vs. 625) | ||
3673 | "VSYNC", // vertical sync (new field) | ||
3674 | "HSYNC", // horizontal sync | ||
3675 | "OFLOW", // chroma/luma AGC overflow | ||
3676 | "HLOCK", // horizontal lock changed | ||
3677 | "VPRES", // video presence changed | ||
3678 | "6", "7", | ||
3679 | "I2CDONE", // hw irc operation finished | ||
3680 | "GPINT", // gpio port triggered irq | ||
3681 | "10", | ||
3682 | "RISCI", // risc instruction triggered irq | ||
3683 | "FBUS", // pixel data fifo dropped data (high pci bus latencies) | ||
3684 | "FTRGT", // pixel data fifo overrun | ||
3685 | "FDSR", // fifo data stream resyncronisation | ||
3686 | "PPERR", // parity error (data transfer) | ||
3687 | "RIPERR", // parity error (read risc instructions) | ||
3688 | "PABORT", // pci abort | ||
3689 | "OCERR", // risc instruction error | ||
3690 | "SCERR", // syncronisation error | ||
3691 | }; | ||
3692 | |||
3693 | static void bttv_print_irqbits(u32 print, u32 mark) | ||
3694 | { | ||
3695 | unsigned int i; | ||
3696 | |||
3697 | pr_cont("bits:"); | ||
3698 | for (i = 0; i < ARRAY_SIZE(irq_name); i++) { | ||
3699 | if (print & (1 << i)) | ||
3700 | pr_cont(" %s", irq_name[i]); | ||
3701 | if (mark & (1 << i)) | ||
3702 | pr_cont("*"); | ||
3703 | } | ||
3704 | } | ||
3705 | |||
3706 | static void bttv_irq_debug_low_latency(struct bttv *btv, u32 rc) | ||
3707 | { | ||
3708 | pr_warn("%d: irq: skipped frame [main=%lx,o_vbi=%lx,o_field=%lx,rc=%lx]\n", | ||
3709 | btv->c.nr, | ||
3710 | (unsigned long)btv->main.dma, | ||
3711 | (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_VBI+1]), | ||
3712 | (unsigned long)le32_to_cpu(btv->main.cpu[RISC_SLOT_O_FIELD+1]), | ||
3713 | (unsigned long)rc); | ||
3714 | |||
3715 | if (0 == (btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC)) { | ||
3716 | pr_notice("%d: Oh, there (temporarily?) is no input signal. " | ||
3717 | "Ok, then this is harmless, don't worry ;)\n", | ||
3718 | btv->c.nr); | ||
3719 | return; | ||
3720 | } | ||
3721 | pr_notice("%d: Uhm. Looks like we have unusual high IRQ latencies\n", | ||
3722 | btv->c.nr); | ||
3723 | pr_notice("%d: Lets try to catch the culpit red-handed ...\n", | ||
3724 | btv->c.nr); | ||
3725 | dump_stack(); | ||
3726 | } | ||
3727 | |||
3728 | static int | ||
3729 | bttv_irq_next_video(struct bttv *btv, struct bttv_buffer_set *set) | ||
3730 | { | ||
3731 | struct bttv_buffer *item; | ||
3732 | |||
3733 | memset(set,0,sizeof(*set)); | ||
3734 | |||
3735 | /* capture request ? */ | ||
3736 | if (!list_empty(&btv->capture)) { | ||
3737 | set->frame_irq = 1; | ||
3738 | item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue); | ||
3739 | if (V4L2_FIELD_HAS_TOP(item->vb.field)) | ||
3740 | set->top = item; | ||
3741 | if (V4L2_FIELD_HAS_BOTTOM(item->vb.field)) | ||
3742 | set->bottom = item; | ||
3743 | |||
3744 | /* capture request for other field ? */ | ||
3745 | if (!V4L2_FIELD_HAS_BOTH(item->vb.field) && | ||
3746 | (item->vb.queue.next != &btv->capture)) { | ||
3747 | item = list_entry(item->vb.queue.next, struct bttv_buffer, vb.queue); | ||
3748 | /* Mike Isely <isely@pobox.com> - Only check | ||
3749 | * and set up the bottom field in the logic | ||
3750 | * below. Don't ever do the top field. This | ||
3751 | * of course means that if we set up the | ||
3752 | * bottom field in the above code that we'll | ||
3753 | * actually skip a field. But that's OK. | ||
3754 | * Having processed only a single buffer this | ||
3755 | * time, then the next time around the first | ||
3756 | * available buffer should be for a top field. | ||
3757 | * That will then cause us here to set up a | ||
3758 | * top then a bottom field in the normal way. | ||
3759 | * The alternative to this understanding is | ||
3760 | * that we set up the second available buffer | ||
3761 | * as a top field, but that's out of order | ||
3762 | * since this driver always processes the top | ||
3763 | * field first - the effect will be the two | ||
3764 | * buffers being returned in the wrong order, | ||
3765 | * with the second buffer also being delayed | ||
3766 | * by one field time (owing to the fifo nature | ||
3767 | * of videobuf). Worse still, we'll be stuck | ||
3768 | * doing fields out of order now every time | ||
3769 | * until something else causes a field to be | ||
3770 | * dropped. By effectively forcing a field to | ||
3771 | * drop this way then we always get back into | ||
3772 | * sync within a single frame time. (Out of | ||
3773 | * order fields can screw up deinterlacing | ||
3774 | * algorithms.) */ | ||
3775 | if (!V4L2_FIELD_HAS_BOTH(item->vb.field)) { | ||
3776 | if (NULL == set->bottom && | ||
3777 | V4L2_FIELD_BOTTOM == item->vb.field) { | ||
3778 | set->bottom = item; | ||
3779 | } | ||
3780 | if (NULL != set->top && NULL != set->bottom) | ||
3781 | set->top_irq = 2; | ||
3782 | } | ||
3783 | } | ||
3784 | } | ||
3785 | |||
3786 | /* screen overlay ? */ | ||
3787 | if (NULL != btv->screen) { | ||
3788 | if (V4L2_FIELD_HAS_BOTH(btv->screen->vb.field)) { | ||
3789 | if (NULL == set->top && NULL == set->bottom) { | ||
3790 | set->top = btv->screen; | ||
3791 | set->bottom = btv->screen; | ||
3792 | } | ||
3793 | } else { | ||
3794 | if (V4L2_FIELD_TOP == btv->screen->vb.field && | ||
3795 | NULL == set->top) { | ||
3796 | set->top = btv->screen; | ||
3797 | } | ||
3798 | if (V4L2_FIELD_BOTTOM == btv->screen->vb.field && | ||
3799 | NULL == set->bottom) { | ||
3800 | set->bottom = btv->screen; | ||
3801 | } | ||
3802 | } | ||
3803 | } | ||
3804 | |||
3805 | dprintk("%d: next set: top=%p bottom=%p [screen=%p,irq=%d,%d]\n", | ||
3806 | btv->c.nr, set->top, set->bottom, | ||
3807 | btv->screen, set->frame_irq, set->top_irq); | ||
3808 | return 0; | ||
3809 | } | ||
3810 | |||
3811 | static void | ||
3812 | bttv_irq_wakeup_video(struct bttv *btv, struct bttv_buffer_set *wakeup, | ||
3813 | struct bttv_buffer_set *curr, unsigned int state) | ||
3814 | { | ||
3815 | struct timeval ts; | ||
3816 | |||
3817 | do_gettimeofday(&ts); | ||
3818 | |||
3819 | if (wakeup->top == wakeup->bottom) { | ||
3820 | if (NULL != wakeup->top && curr->top != wakeup->top) { | ||
3821 | if (irq_debug > 1) | ||
3822 | pr_debug("%d: wakeup: both=%p\n", | ||
3823 | btv->c.nr, wakeup->top); | ||
3824 | wakeup->top->vb.ts = ts; | ||
3825 | wakeup->top->vb.field_count = btv->field_count; | ||
3826 | wakeup->top->vb.state = state; | ||
3827 | wake_up(&wakeup->top->vb.done); | ||
3828 | } | ||
3829 | } else { | ||
3830 | if (NULL != wakeup->top && curr->top != wakeup->top) { | ||
3831 | if (irq_debug > 1) | ||
3832 | pr_debug("%d: wakeup: top=%p\n", | ||
3833 | btv->c.nr, wakeup->top); | ||
3834 | wakeup->top->vb.ts = ts; | ||
3835 | wakeup->top->vb.field_count = btv->field_count; | ||
3836 | wakeup->top->vb.state = state; | ||
3837 | wake_up(&wakeup->top->vb.done); | ||
3838 | } | ||
3839 | if (NULL != wakeup->bottom && curr->bottom != wakeup->bottom) { | ||
3840 | if (irq_debug > 1) | ||
3841 | pr_debug("%d: wakeup: bottom=%p\n", | ||
3842 | btv->c.nr, wakeup->bottom); | ||
3843 | wakeup->bottom->vb.ts = ts; | ||
3844 | wakeup->bottom->vb.field_count = btv->field_count; | ||
3845 | wakeup->bottom->vb.state = state; | ||
3846 | wake_up(&wakeup->bottom->vb.done); | ||
3847 | } | ||
3848 | } | ||
3849 | } | ||
3850 | |||
3851 | static void | ||
3852 | bttv_irq_wakeup_vbi(struct bttv *btv, struct bttv_buffer *wakeup, | ||
3853 | unsigned int state) | ||
3854 | { | ||
3855 | struct timeval ts; | ||
3856 | |||
3857 | if (NULL == wakeup) | ||
3858 | return; | ||
3859 | |||
3860 | do_gettimeofday(&ts); | ||
3861 | wakeup->vb.ts = ts; | ||
3862 | wakeup->vb.field_count = btv->field_count; | ||
3863 | wakeup->vb.state = state; | ||
3864 | wake_up(&wakeup->vb.done); | ||
3865 | } | ||
3866 | |||
3867 | static void bttv_irq_timeout(unsigned long data) | ||
3868 | { | ||
3869 | struct bttv *btv = (struct bttv *)data; | ||
3870 | struct bttv_buffer_set old,new; | ||
3871 | struct bttv_buffer *ovbi; | ||
3872 | struct bttv_buffer *item; | ||
3873 | unsigned long flags; | ||
3874 | |||
3875 | if (bttv_verbose) { | ||
3876 | pr_info("%d: timeout: drop=%d irq=%d/%d, risc=%08x, ", | ||
3877 | btv->c.nr, btv->framedrop, btv->irq_me, btv->irq_total, | ||
3878 | btread(BT848_RISC_COUNT)); | ||
3879 | bttv_print_irqbits(btread(BT848_INT_STAT),0); | ||
3880 | pr_cont("\n"); | ||
3881 | } | ||
3882 | |||
3883 | spin_lock_irqsave(&btv->s_lock,flags); | ||
3884 | |||
3885 | /* deactivate stuff */ | ||
3886 | memset(&new,0,sizeof(new)); | ||
3887 | old = btv->curr; | ||
3888 | ovbi = btv->cvbi; | ||
3889 | btv->curr = new; | ||
3890 | btv->cvbi = NULL; | ||
3891 | btv->loop_irq = 0; | ||
3892 | bttv_buffer_activate_video(btv, &new); | ||
3893 | bttv_buffer_activate_vbi(btv, NULL); | ||
3894 | bttv_set_dma(btv, 0); | ||
3895 | |||
3896 | /* wake up */ | ||
3897 | bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_ERROR); | ||
3898 | bttv_irq_wakeup_vbi(btv, ovbi, VIDEOBUF_ERROR); | ||
3899 | |||
3900 | /* cancel all outstanding capture / vbi requests */ | ||
3901 | while (!list_empty(&btv->capture)) { | ||
3902 | item = list_entry(btv->capture.next, struct bttv_buffer, vb.queue); | ||
3903 | list_del(&item->vb.queue); | ||
3904 | item->vb.state = VIDEOBUF_ERROR; | ||
3905 | wake_up(&item->vb.done); | ||
3906 | } | ||
3907 | while (!list_empty(&btv->vcapture)) { | ||
3908 | item = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue); | ||
3909 | list_del(&item->vb.queue); | ||
3910 | item->vb.state = VIDEOBUF_ERROR; | ||
3911 | wake_up(&item->vb.done); | ||
3912 | } | ||
3913 | |||
3914 | btv->errors++; | ||
3915 | spin_unlock_irqrestore(&btv->s_lock,flags); | ||
3916 | } | ||
3917 | |||
3918 | static void | ||
3919 | bttv_irq_wakeup_top(struct bttv *btv) | ||
3920 | { | ||
3921 | struct bttv_buffer *wakeup = btv->curr.top; | ||
3922 | |||
3923 | if (NULL == wakeup) | ||
3924 | return; | ||
3925 | |||
3926 | spin_lock(&btv->s_lock); | ||
3927 | btv->curr.top_irq = 0; | ||
3928 | btv->curr.top = NULL; | ||
3929 | bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0); | ||
3930 | |||
3931 | do_gettimeofday(&wakeup->vb.ts); | ||
3932 | wakeup->vb.field_count = btv->field_count; | ||
3933 | wakeup->vb.state = VIDEOBUF_DONE; | ||
3934 | wake_up(&wakeup->vb.done); | ||
3935 | spin_unlock(&btv->s_lock); | ||
3936 | } | ||
3937 | |||
3938 | static inline int is_active(struct btcx_riscmem *risc, u32 rc) | ||
3939 | { | ||
3940 | if (rc < risc->dma) | ||
3941 | return 0; | ||
3942 | if (rc > risc->dma + risc->size) | ||
3943 | return 0; | ||
3944 | return 1; | ||
3945 | } | ||
3946 | |||
3947 | static void | ||
3948 | bttv_irq_switch_video(struct bttv *btv) | ||
3949 | { | ||
3950 | struct bttv_buffer_set new; | ||
3951 | struct bttv_buffer_set old; | ||
3952 | dma_addr_t rc; | ||
3953 | |||
3954 | spin_lock(&btv->s_lock); | ||
3955 | |||
3956 | /* new buffer set */ | ||
3957 | bttv_irq_next_video(btv, &new); | ||
3958 | rc = btread(BT848_RISC_COUNT); | ||
3959 | if ((btv->curr.top && is_active(&btv->curr.top->top, rc)) || | ||
3960 | (btv->curr.bottom && is_active(&btv->curr.bottom->bottom, rc))) { | ||
3961 | btv->framedrop++; | ||
3962 | if (debug_latency) | ||
3963 | bttv_irq_debug_low_latency(btv, rc); | ||
3964 | spin_unlock(&btv->s_lock); | ||
3965 | return; | ||
3966 | } | ||
3967 | |||
3968 | /* switch over */ | ||
3969 | old = btv->curr; | ||
3970 | btv->curr = new; | ||
3971 | btv->loop_irq &= ~1; | ||
3972 | bttv_buffer_activate_video(btv, &new); | ||
3973 | bttv_set_dma(btv, 0); | ||
3974 | |||
3975 | /* switch input */ | ||
3976 | if (UNSET != btv->new_input) { | ||
3977 | video_mux(btv,btv->new_input); | ||
3978 | btv->new_input = UNSET; | ||
3979 | } | ||
3980 | |||
3981 | /* wake up finished buffers */ | ||
3982 | bttv_irq_wakeup_video(btv, &old, &new, VIDEOBUF_DONE); | ||
3983 | spin_unlock(&btv->s_lock); | ||
3984 | } | ||
3985 | |||
3986 | static void | ||
3987 | bttv_irq_switch_vbi(struct bttv *btv) | ||
3988 | { | ||
3989 | struct bttv_buffer *new = NULL; | ||
3990 | struct bttv_buffer *old; | ||
3991 | u32 rc; | ||
3992 | |||
3993 | spin_lock(&btv->s_lock); | ||
3994 | |||
3995 | if (!list_empty(&btv->vcapture)) | ||
3996 | new = list_entry(btv->vcapture.next, struct bttv_buffer, vb.queue); | ||
3997 | old = btv->cvbi; | ||
3998 | |||
3999 | rc = btread(BT848_RISC_COUNT); | ||
4000 | if (NULL != old && (is_active(&old->top, rc) || | ||
4001 | is_active(&old->bottom, rc))) { | ||
4002 | btv->framedrop++; | ||
4003 | if (debug_latency) | ||
4004 | bttv_irq_debug_low_latency(btv, rc); | ||
4005 | spin_unlock(&btv->s_lock); | ||
4006 | return; | ||
4007 | } | ||
4008 | |||
4009 | /* switch */ | ||
4010 | btv->cvbi = new; | ||
4011 | btv->loop_irq &= ~4; | ||
4012 | bttv_buffer_activate_vbi(btv, new); | ||
4013 | bttv_set_dma(btv, 0); | ||
4014 | |||
4015 | bttv_irq_wakeup_vbi(btv, old, VIDEOBUF_DONE); | ||
4016 | spin_unlock(&btv->s_lock); | ||
4017 | } | ||
4018 | |||
4019 | static irqreturn_t bttv_irq(int irq, void *dev_id) | ||
4020 | { | ||
4021 | u32 stat,astat; | ||
4022 | u32 dstat; | ||
4023 | int count; | ||
4024 | struct bttv *btv; | ||
4025 | int handled = 0; | ||
4026 | |||
4027 | btv=(struct bttv *)dev_id; | ||
4028 | |||
4029 | count=0; | ||
4030 | while (1) { | ||
4031 | /* get/clear interrupt status bits */ | ||
4032 | stat=btread(BT848_INT_STAT); | ||
4033 | astat=stat&btread(BT848_INT_MASK); | ||
4034 | if (!astat) | ||
4035 | break; | ||
4036 | handled = 1; | ||
4037 | btwrite(stat,BT848_INT_STAT); | ||
4038 | |||
4039 | /* get device status bits */ | ||
4040 | dstat=btread(BT848_DSTATUS); | ||
4041 | |||
4042 | if (irq_debug) { | ||
4043 | pr_debug("%d: irq loop=%d fc=%d riscs=%x, riscc=%08x, ", | ||
4044 | btv->c.nr, count, btv->field_count, | ||
4045 | stat>>28, btread(BT848_RISC_COUNT)); | ||
4046 | bttv_print_irqbits(stat,astat); | ||
4047 | if (stat & BT848_INT_HLOCK) | ||
4048 | pr_cont(" HLOC => %s", | ||
4049 | dstat & BT848_DSTATUS_HLOC | ||
4050 | ? "yes" : "no"); | ||
4051 | if (stat & BT848_INT_VPRES) | ||
4052 | pr_cont(" PRES => %s", | ||
4053 | dstat & BT848_DSTATUS_PRES | ||
4054 | ? "yes" : "no"); | ||
4055 | if (stat & BT848_INT_FMTCHG) | ||
4056 | pr_cont(" NUML => %s", | ||
4057 | dstat & BT848_DSTATUS_NUML | ||
4058 | ? "625" : "525"); | ||
4059 | pr_cont("\n"); | ||
4060 | } | ||
4061 | |||
4062 | if (astat&BT848_INT_VSYNC) | ||
4063 | btv->field_count++; | ||
4064 | |||
4065 | if ((astat & BT848_INT_GPINT) && btv->remote) { | ||
4066 | bttv_input_irq(btv); | ||
4067 | } | ||
4068 | |||
4069 | if (astat & BT848_INT_I2CDONE) { | ||
4070 | btv->i2c_done = stat; | ||
4071 | wake_up(&btv->i2c_queue); | ||
4072 | } | ||
4073 | |||
4074 | if ((astat & BT848_INT_RISCI) && (stat & (4<<28))) | ||
4075 | bttv_irq_switch_vbi(btv); | ||
4076 | |||
4077 | if ((astat & BT848_INT_RISCI) && (stat & (2<<28))) | ||
4078 | bttv_irq_wakeup_top(btv); | ||
4079 | |||
4080 | if ((astat & BT848_INT_RISCI) && (stat & (1<<28))) | ||
4081 | bttv_irq_switch_video(btv); | ||
4082 | |||
4083 | if ((astat & BT848_INT_HLOCK) && btv->opt_automute) | ||
4084 | audio_mute(btv, btv->mute); /* trigger automute */ | ||
4085 | |||
4086 | if (astat & (BT848_INT_SCERR|BT848_INT_OCERR)) { | ||
4087 | pr_info("%d: %s%s @ %08x,", | ||
4088 | btv->c.nr, | ||
4089 | (astat & BT848_INT_SCERR) ? "SCERR" : "", | ||
4090 | (astat & BT848_INT_OCERR) ? "OCERR" : "", | ||
4091 | btread(BT848_RISC_COUNT)); | ||
4092 | bttv_print_irqbits(stat,astat); | ||
4093 | pr_cont("\n"); | ||
4094 | if (bttv_debug) | ||
4095 | bttv_print_riscaddr(btv); | ||
4096 | } | ||
4097 | if (fdsr && astat & BT848_INT_FDSR) { | ||
4098 | pr_info("%d: FDSR @ %08x\n", | ||
4099 | btv->c.nr, btread(BT848_RISC_COUNT)); | ||
4100 | if (bttv_debug) | ||
4101 | bttv_print_riscaddr(btv); | ||
4102 | } | ||
4103 | |||
4104 | count++; | ||
4105 | if (count > 4) { | ||
4106 | |||
4107 | if (count > 8 || !(astat & BT848_INT_GPINT)) { | ||
4108 | btwrite(0, BT848_INT_MASK); | ||
4109 | |||
4110 | pr_err("%d: IRQ lockup, cleared int mask [", | ||
4111 | btv->c.nr); | ||
4112 | } else { | ||
4113 | pr_err("%d: IRQ lockup, clearing GPINT from int mask [", | ||
4114 | btv->c.nr); | ||
4115 | |||
4116 | btwrite(btread(BT848_INT_MASK) & (-1 ^ BT848_INT_GPINT), | ||
4117 | BT848_INT_MASK); | ||
4118 | }; | ||
4119 | |||
4120 | bttv_print_irqbits(stat,astat); | ||
4121 | |||
4122 | pr_cont("]\n"); | ||
4123 | } | ||
4124 | } | ||
4125 | btv->irq_total++; | ||
4126 | if (handled) | ||
4127 | btv->irq_me++; | ||
4128 | return IRQ_RETVAL(handled); | ||
4129 | } | ||
4130 | |||
4131 | |||
4132 | /* ----------------------------------------------------------------------- */ | ||
4133 | /* initialitation */ | ||
4134 | |||
4135 | static struct video_device *vdev_init(struct bttv *btv, | ||
4136 | const struct video_device *template, | ||
4137 | const char *type_name) | ||
4138 | { | ||
4139 | struct video_device *vfd; | ||
4140 | |||
4141 | vfd = video_device_alloc(); | ||
4142 | if (NULL == vfd) | ||
4143 | return NULL; | ||
4144 | *vfd = *template; | ||
4145 | vfd->v4l2_dev = &btv->c.v4l2_dev; | ||
4146 | vfd->release = video_device_release; | ||
4147 | vfd->debug = bttv_debug; | ||
4148 | video_set_drvdata(vfd, btv); | ||
4149 | snprintf(vfd->name, sizeof(vfd->name), "BT%d%s %s (%s)", | ||
4150 | btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "", | ||
4151 | type_name, bttv_tvcards[btv->c.type].name); | ||
4152 | return vfd; | ||
4153 | } | ||
4154 | |||
4155 | static void bttv_unregister_video(struct bttv *btv) | ||
4156 | { | ||
4157 | if (btv->video_dev) { | ||
4158 | if (video_is_registered(btv->video_dev)) | ||
4159 | video_unregister_device(btv->video_dev); | ||
4160 | else | ||
4161 | video_device_release(btv->video_dev); | ||
4162 | btv->video_dev = NULL; | ||
4163 | } | ||
4164 | if (btv->vbi_dev) { | ||
4165 | if (video_is_registered(btv->vbi_dev)) | ||
4166 | video_unregister_device(btv->vbi_dev); | ||
4167 | else | ||
4168 | video_device_release(btv->vbi_dev); | ||
4169 | btv->vbi_dev = NULL; | ||
4170 | } | ||
4171 | if (btv->radio_dev) { | ||
4172 | if (video_is_registered(btv->radio_dev)) | ||
4173 | video_unregister_device(btv->radio_dev); | ||
4174 | else | ||
4175 | video_device_release(btv->radio_dev); | ||
4176 | btv->radio_dev = NULL; | ||
4177 | } | ||
4178 | } | ||
4179 | |||
4180 | /* register video4linux devices */ | ||
4181 | static int __devinit bttv_register_video(struct bttv *btv) | ||
4182 | { | ||
4183 | if (no_overlay > 0) | ||
4184 | pr_notice("Overlay support disabled\n"); | ||
4185 | |||
4186 | /* video */ | ||
4187 | btv->video_dev = vdev_init(btv, &bttv_video_template, "video"); | ||
4188 | |||
4189 | if (NULL == btv->video_dev) | ||
4190 | goto err; | ||
4191 | if (video_register_device(btv->video_dev, VFL_TYPE_GRABBER, | ||
4192 | video_nr[btv->c.nr]) < 0) | ||
4193 | goto err; | ||
4194 | pr_info("%d: registered device %s\n", | ||
4195 | btv->c.nr, video_device_node_name(btv->video_dev)); | ||
4196 | if (device_create_file(&btv->video_dev->dev, | ||
4197 | &dev_attr_card)<0) { | ||
4198 | pr_err("%d: device_create_file 'card' failed\n", btv->c.nr); | ||
4199 | goto err; | ||
4200 | } | ||
4201 | |||
4202 | /* vbi */ | ||
4203 | btv->vbi_dev = vdev_init(btv, &bttv_video_template, "vbi"); | ||
4204 | |||
4205 | if (NULL == btv->vbi_dev) | ||
4206 | goto err; | ||
4207 | if (video_register_device(btv->vbi_dev, VFL_TYPE_VBI, | ||
4208 | vbi_nr[btv->c.nr]) < 0) | ||
4209 | goto err; | ||
4210 | pr_info("%d: registered device %s\n", | ||
4211 | btv->c.nr, video_device_node_name(btv->vbi_dev)); | ||
4212 | |||
4213 | if (!btv->has_radio) | ||
4214 | return 0; | ||
4215 | /* radio */ | ||
4216 | btv->radio_dev = vdev_init(btv, &radio_template, "radio"); | ||
4217 | if (NULL == btv->radio_dev) | ||
4218 | goto err; | ||
4219 | if (video_register_device(btv->radio_dev, VFL_TYPE_RADIO, | ||
4220 | radio_nr[btv->c.nr]) < 0) | ||
4221 | goto err; | ||
4222 | pr_info("%d: registered device %s\n", | ||
4223 | btv->c.nr, video_device_node_name(btv->radio_dev)); | ||
4224 | |||
4225 | /* all done */ | ||
4226 | return 0; | ||
4227 | |||
4228 | err: | ||
4229 | bttv_unregister_video(btv); | ||
4230 | return -1; | ||
4231 | } | ||
4232 | |||
4233 | |||
4234 | /* on OpenFirmware machines (PowerMac at least), PCI memory cycle */ | ||
4235 | /* response on cards with no firmware is not enabled by OF */ | ||
4236 | static void pci_set_command(struct pci_dev *dev) | ||
4237 | { | ||
4238 | #if defined(__powerpc__) | ||
4239 | unsigned int cmd; | ||
4240 | |||
4241 | pci_read_config_dword(dev, PCI_COMMAND, &cmd); | ||
4242 | cmd = (cmd | PCI_COMMAND_MEMORY ); | ||
4243 | pci_write_config_dword(dev, PCI_COMMAND, cmd); | ||
4244 | #endif | ||
4245 | } | ||
4246 | |||
4247 | static int __devinit bttv_probe(struct pci_dev *dev, | ||
4248 | const struct pci_device_id *pci_id) | ||
4249 | { | ||
4250 | int result; | ||
4251 | unsigned char lat; | ||
4252 | struct bttv *btv; | ||
4253 | |||
4254 | if (bttv_num == BTTV_MAX) | ||
4255 | return -ENOMEM; | ||
4256 | pr_info("Bt8xx card found (%d)\n", bttv_num); | ||
4257 | bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL); | ||
4258 | if (btv == NULL) { | ||
4259 | pr_err("out of memory\n"); | ||
4260 | return -ENOMEM; | ||
4261 | } | ||
4262 | btv->c.nr = bttv_num; | ||
4263 | snprintf(btv->c.v4l2_dev.name, sizeof(btv->c.v4l2_dev.name), | ||
4264 | "bttv%d", btv->c.nr); | ||
4265 | |||
4266 | /* initialize structs / fill in defaults */ | ||
4267 | mutex_init(&btv->lock); | ||
4268 | spin_lock_init(&btv->s_lock); | ||
4269 | spin_lock_init(&btv->gpio_lock); | ||
4270 | init_waitqueue_head(&btv->i2c_queue); | ||
4271 | INIT_LIST_HEAD(&btv->c.subs); | ||
4272 | INIT_LIST_HEAD(&btv->capture); | ||
4273 | INIT_LIST_HEAD(&btv->vcapture); | ||
4274 | v4l2_prio_init(&btv->prio); | ||
4275 | |||
4276 | init_timer(&btv->timeout); | ||
4277 | btv->timeout.function = bttv_irq_timeout; | ||
4278 | btv->timeout.data = (unsigned long)btv; | ||
4279 | |||
4280 | btv->i2c_rc = -1; | ||
4281 | btv->tuner_type = UNSET; | ||
4282 | btv->new_input = UNSET; | ||
4283 | btv->has_radio=radio[btv->c.nr]; | ||
4284 | |||
4285 | /* pci stuff (init, get irq/mmio, ... */ | ||
4286 | btv->c.pci = dev; | ||
4287 | btv->id = dev->device; | ||
4288 | if (pci_enable_device(dev)) { | ||
4289 | pr_warn("%d: Can't enable device\n", btv->c.nr); | ||
4290 | return -EIO; | ||
4291 | } | ||
4292 | if (pci_set_dma_mask(dev, DMA_BIT_MASK(32))) { | ||
4293 | pr_warn("%d: No suitable DMA available\n", btv->c.nr); | ||
4294 | return -EIO; | ||
4295 | } | ||
4296 | if (!request_mem_region(pci_resource_start(dev,0), | ||
4297 | pci_resource_len(dev,0), | ||
4298 | btv->c.v4l2_dev.name)) { | ||
4299 | pr_warn("%d: can't request iomem (0x%llx)\n", | ||
4300 | btv->c.nr, | ||
4301 | (unsigned long long)pci_resource_start(dev, 0)); | ||
4302 | return -EBUSY; | ||
4303 | } | ||
4304 | pci_set_master(dev); | ||
4305 | pci_set_command(dev); | ||
4306 | |||
4307 | result = v4l2_device_register(&dev->dev, &btv->c.v4l2_dev); | ||
4308 | if (result < 0) { | ||
4309 | pr_warn("%d: v4l2_device_register() failed\n", btv->c.nr); | ||
4310 | goto fail0; | ||
4311 | } | ||
4312 | |||
4313 | btv->revision = dev->revision; | ||
4314 | pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); | ||
4315 | pr_info("%d: Bt%d (rev %d) at %s, irq: %d, latency: %d, mmio: 0x%llx\n", | ||
4316 | bttv_num, btv->id, btv->revision, pci_name(dev), | ||
4317 | btv->c.pci->irq, lat, | ||
4318 | (unsigned long long)pci_resource_start(dev, 0)); | ||
4319 | schedule(); | ||
4320 | |||
4321 | btv->bt848_mmio = ioremap(pci_resource_start(dev, 0), 0x1000); | ||
4322 | if (NULL == btv->bt848_mmio) { | ||
4323 | pr_err("%d: ioremap() failed\n", btv->c.nr); | ||
4324 | result = -EIO; | ||
4325 | goto fail1; | ||
4326 | } | ||
4327 | |||
4328 | /* identify card */ | ||
4329 | bttv_idcard(btv); | ||
4330 | |||
4331 | /* disable irqs, register irq handler */ | ||
4332 | btwrite(0, BT848_INT_MASK); | ||
4333 | result = request_irq(btv->c.pci->irq, bttv_irq, | ||
4334 | IRQF_SHARED | IRQF_DISABLED, btv->c.v4l2_dev.name, (void *)btv); | ||
4335 | if (result < 0) { | ||
4336 | pr_err("%d: can't get IRQ %d\n", | ||
4337 | bttv_num, btv->c.pci->irq); | ||
4338 | goto fail1; | ||
4339 | } | ||
4340 | |||
4341 | if (0 != bttv_handle_chipset(btv)) { | ||
4342 | result = -EIO; | ||
4343 | goto fail2; | ||
4344 | } | ||
4345 | |||
4346 | /* init options from insmod args */ | ||
4347 | btv->opt_combfilter = combfilter; | ||
4348 | btv->opt_lumafilter = lumafilter; | ||
4349 | btv->opt_automute = automute; | ||
4350 | btv->opt_chroma_agc = chroma_agc; | ||
4351 | btv->opt_adc_crush = adc_crush; | ||
4352 | btv->opt_vcr_hack = vcr_hack; | ||
4353 | btv->opt_whitecrush_upper = whitecrush_upper; | ||
4354 | btv->opt_whitecrush_lower = whitecrush_lower; | ||
4355 | btv->opt_uv_ratio = uv_ratio; | ||
4356 | btv->opt_full_luma_range = full_luma_range; | ||
4357 | btv->opt_coring = coring; | ||
4358 | |||
4359 | /* fill struct bttv with some useful defaults */ | ||
4360 | btv->init.btv = btv; | ||
4361 | btv->init.ov.w.width = 320; | ||
4362 | btv->init.ov.w.height = 240; | ||
4363 | btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); | ||
4364 | btv->init.width = 320; | ||
4365 | btv->init.height = 240; | ||
4366 | btv->input = 0; | ||
4367 | |||
4368 | /* initialize hardware */ | ||
4369 | if (bttv_gpio) | ||
4370 | bttv_gpio_tracking(btv,"pre-init"); | ||
4371 | |||
4372 | bttv_risc_init_main(btv); | ||
4373 | init_bt848(btv); | ||
4374 | |||
4375 | /* gpio */ | ||
4376 | btwrite(0x00, BT848_GPIO_REG_INP); | ||
4377 | btwrite(0x00, BT848_GPIO_OUT_EN); | ||
4378 | if (bttv_verbose) | ||
4379 | bttv_gpio_tracking(btv,"init"); | ||
4380 | |||
4381 | /* needs to be done before i2c is registered */ | ||
4382 | bttv_init_card1(btv); | ||
4383 | |||
4384 | /* register i2c + gpio */ | ||
4385 | init_bttv_i2c(btv); | ||
4386 | |||
4387 | /* some card-specific stuff (needs working i2c) */ | ||
4388 | bttv_init_card2(btv); | ||
4389 | bttv_init_tuner(btv); | ||
4390 | init_irqreg(btv); | ||
4391 | |||
4392 | /* register video4linux + input */ | ||
4393 | if (!bttv_tvcards[btv->c.type].no_video) { | ||
4394 | bttv_register_video(btv); | ||
4395 | bt848_bright(btv,32768); | ||
4396 | bt848_contrast(btv, 27648); | ||
4397 | bt848_hue(btv,32768); | ||
4398 | bt848_sat(btv,32768); | ||
4399 | audio_mute(btv, 1); | ||
4400 | set_input(btv, 0, btv->tvnorm); | ||
4401 | bttv_crop_reset(&btv->crop[0], btv->tvnorm); | ||
4402 | btv->crop[1] = btv->crop[0]; /* current = default */ | ||
4403 | disclaim_vbi_lines(btv); | ||
4404 | disclaim_video_lines(btv); | ||
4405 | } | ||
4406 | |||
4407 | /* add subdevices and autoload dvb-bt8xx if needed */ | ||
4408 | if (bttv_tvcards[btv->c.type].has_dvb) { | ||
4409 | bttv_sub_add_device(&btv->c, "dvb"); | ||
4410 | request_modules(btv); | ||
4411 | } | ||
4412 | |||
4413 | if (!disable_ir) { | ||
4414 | init_bttv_i2c_ir(btv); | ||
4415 | bttv_input_init(btv); | ||
4416 | } | ||
4417 | |||
4418 | /* everything is fine */ | ||
4419 | bttv_num++; | ||
4420 | return 0; | ||
4421 | |||
4422 | fail2: | ||
4423 | free_irq(btv->c.pci->irq,btv); | ||
4424 | |||
4425 | fail1: | ||
4426 | v4l2_device_unregister(&btv->c.v4l2_dev); | ||
4427 | |||
4428 | fail0: | ||
4429 | if (btv->bt848_mmio) | ||
4430 | iounmap(btv->bt848_mmio); | ||
4431 | release_mem_region(pci_resource_start(btv->c.pci,0), | ||
4432 | pci_resource_len(btv->c.pci,0)); | ||
4433 | return result; | ||
4434 | } | ||
4435 | |||
4436 | static void __devexit bttv_remove(struct pci_dev *pci_dev) | ||
4437 | { | ||
4438 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); | ||
4439 | struct bttv *btv = to_bttv(v4l2_dev); | ||
4440 | |||
4441 | if (bttv_verbose) | ||
4442 | pr_info("%d: unloading\n", btv->c.nr); | ||
4443 | |||
4444 | if (bttv_tvcards[btv->c.type].has_dvb) | ||
4445 | flush_request_modules(btv); | ||
4446 | |||
4447 | /* shutdown everything (DMA+IRQs) */ | ||
4448 | btand(~15, BT848_GPIO_DMA_CTL); | ||
4449 | btwrite(0, BT848_INT_MASK); | ||
4450 | btwrite(~0x0, BT848_INT_STAT); | ||
4451 | btwrite(0x0, BT848_GPIO_OUT_EN); | ||
4452 | if (bttv_gpio) | ||
4453 | bttv_gpio_tracking(btv,"cleanup"); | ||
4454 | |||
4455 | /* tell gpio modules we are leaving ... */ | ||
4456 | btv->shutdown=1; | ||
4457 | bttv_input_fini(btv); | ||
4458 | bttv_sub_del_devices(&btv->c); | ||
4459 | |||
4460 | /* unregister i2c_bus + input */ | ||
4461 | fini_bttv_i2c(btv); | ||
4462 | |||
4463 | /* unregister video4linux */ | ||
4464 | bttv_unregister_video(btv); | ||
4465 | |||
4466 | /* free allocated memory */ | ||
4467 | btcx_riscmem_free(btv->c.pci,&btv->main); | ||
4468 | |||
4469 | /* free ressources */ | ||
4470 | free_irq(btv->c.pci->irq,btv); | ||
4471 | iounmap(btv->bt848_mmio); | ||
4472 | release_mem_region(pci_resource_start(btv->c.pci,0), | ||
4473 | pci_resource_len(btv->c.pci,0)); | ||
4474 | |||
4475 | v4l2_device_unregister(&btv->c.v4l2_dev); | ||
4476 | bttvs[btv->c.nr] = NULL; | ||
4477 | kfree(btv); | ||
4478 | |||
4479 | return; | ||
4480 | } | ||
4481 | |||
4482 | #ifdef CONFIG_PM | ||
4483 | static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state) | ||
4484 | { | ||
4485 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); | ||
4486 | struct bttv *btv = to_bttv(v4l2_dev); | ||
4487 | struct bttv_buffer_set idle; | ||
4488 | unsigned long flags; | ||
4489 | |||
4490 | dprintk("%d: suspend %d\n", btv->c.nr, state.event); | ||
4491 | |||
4492 | /* stop dma + irqs */ | ||
4493 | spin_lock_irqsave(&btv->s_lock,flags); | ||
4494 | memset(&idle, 0, sizeof(idle)); | ||
4495 | btv->state.video = btv->curr; | ||
4496 | btv->state.vbi = btv->cvbi; | ||
4497 | btv->state.loop_irq = btv->loop_irq; | ||
4498 | btv->curr = idle; | ||
4499 | btv->loop_irq = 0; | ||
4500 | bttv_buffer_activate_video(btv, &idle); | ||
4501 | bttv_buffer_activate_vbi(btv, NULL); | ||
4502 | bttv_set_dma(btv, 0); | ||
4503 | btwrite(0, BT848_INT_MASK); | ||
4504 | spin_unlock_irqrestore(&btv->s_lock,flags); | ||
4505 | |||
4506 | /* save bt878 state */ | ||
4507 | btv->state.gpio_enable = btread(BT848_GPIO_OUT_EN); | ||
4508 | btv->state.gpio_data = gpio_read(); | ||
4509 | |||
4510 | /* save pci state */ | ||
4511 | pci_save_state(pci_dev); | ||
4512 | if (0 != pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state))) { | ||
4513 | pci_disable_device(pci_dev); | ||
4514 | btv->state.disabled = 1; | ||
4515 | } | ||
4516 | return 0; | ||
4517 | } | ||
4518 | |||
4519 | static int bttv_resume(struct pci_dev *pci_dev) | ||
4520 | { | ||
4521 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); | ||
4522 | struct bttv *btv = to_bttv(v4l2_dev); | ||
4523 | unsigned long flags; | ||
4524 | int err; | ||
4525 | |||
4526 | dprintk("%d: resume\n", btv->c.nr); | ||
4527 | |||
4528 | /* restore pci state */ | ||
4529 | if (btv->state.disabled) { | ||
4530 | err=pci_enable_device(pci_dev); | ||
4531 | if (err) { | ||
4532 | pr_warn("%d: Can't enable device\n", btv->c.nr); | ||
4533 | return err; | ||
4534 | } | ||
4535 | btv->state.disabled = 0; | ||
4536 | } | ||
4537 | err=pci_set_power_state(pci_dev, PCI_D0); | ||
4538 | if (err) { | ||
4539 | pci_disable_device(pci_dev); | ||
4540 | pr_warn("%d: Can't enable device\n", btv->c.nr); | ||
4541 | btv->state.disabled = 1; | ||
4542 | return err; | ||
4543 | } | ||
4544 | |||
4545 | pci_restore_state(pci_dev); | ||
4546 | |||
4547 | /* restore bt878 state */ | ||
4548 | bttv_reinit_bt848(btv); | ||
4549 | gpio_inout(0xffffff, btv->state.gpio_enable); | ||
4550 | gpio_write(btv->state.gpio_data); | ||
4551 | |||
4552 | /* restart dma */ | ||
4553 | spin_lock_irqsave(&btv->s_lock,flags); | ||
4554 | btv->curr = btv->state.video; | ||
4555 | btv->cvbi = btv->state.vbi; | ||
4556 | btv->loop_irq = btv->state.loop_irq; | ||
4557 | bttv_buffer_activate_video(btv, &btv->curr); | ||
4558 | bttv_buffer_activate_vbi(btv, btv->cvbi); | ||
4559 | bttv_set_dma(btv, 0); | ||
4560 | spin_unlock_irqrestore(&btv->s_lock,flags); | ||
4561 | return 0; | ||
4562 | } | ||
4563 | #endif | ||
4564 | |||
4565 | static struct pci_device_id bttv_pci_tbl[] = { | ||
4566 | {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT848), 0}, | ||
4567 | {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT849), 0}, | ||
4568 | {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT878), 0}, | ||
4569 | {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_BT879), 0}, | ||
4570 | {PCI_VDEVICE(BROOKTREE, PCI_DEVICE_ID_FUSION879), 0}, | ||
4571 | {0,} | ||
4572 | }; | ||
4573 | |||
4574 | MODULE_DEVICE_TABLE(pci, bttv_pci_tbl); | ||
4575 | |||
4576 | static struct pci_driver bttv_pci_driver = { | ||
4577 | .name = "bttv", | ||
4578 | .id_table = bttv_pci_tbl, | ||
4579 | .probe = bttv_probe, | ||
4580 | .remove = __devexit_p(bttv_remove), | ||
4581 | #ifdef CONFIG_PM | ||
4582 | .suspend = bttv_suspend, | ||
4583 | .resume = bttv_resume, | ||
4584 | #endif | ||
4585 | }; | ||
4586 | |||
4587 | static int __init bttv_init_module(void) | ||
4588 | { | ||
4589 | int ret; | ||
4590 | |||
4591 | bttv_num = 0; | ||
4592 | |||
4593 | pr_info("driver version %s loaded\n", BTTV_VERSION); | ||
4594 | if (gbuffers < 2 || gbuffers > VIDEO_MAX_FRAME) | ||
4595 | gbuffers = 2; | ||
4596 | if (gbufsize > BTTV_MAX_FBUF) | ||
4597 | gbufsize = BTTV_MAX_FBUF; | ||
4598 | gbufsize = (gbufsize + PAGE_SIZE - 1) & PAGE_MASK; | ||
4599 | if (bttv_verbose) | ||
4600 | pr_info("using %d buffers with %dk (%d pages) each for capture\n", | ||
4601 | gbuffers, gbufsize >> 10, gbufsize >> PAGE_SHIFT); | ||
4602 | |||
4603 | bttv_check_chipset(); | ||
4604 | |||
4605 | ret = bus_register(&bttv_sub_bus_type); | ||
4606 | if (ret < 0) { | ||
4607 | pr_warn("bus_register error: %d\n", ret); | ||
4608 | return ret; | ||
4609 | } | ||
4610 | ret = pci_register_driver(&bttv_pci_driver); | ||
4611 | if (ret < 0) | ||
4612 | bus_unregister(&bttv_sub_bus_type); | ||
4613 | |||
4614 | return ret; | ||
4615 | } | ||
4616 | |||
4617 | static void __exit bttv_cleanup_module(void) | ||
4618 | { | ||
4619 | pci_unregister_driver(&bttv_pci_driver); | ||
4620 | bus_unregister(&bttv_sub_bus_type); | ||
4621 | } | ||
4622 | |||
4623 | module_init(bttv_init_module); | ||
4624 | module_exit(bttv_cleanup_module); | ||
4625 | |||
4626 | /* | ||
4627 | * Local variables: | ||
4628 | * c-basic-offset: 8 | ||
4629 | * End: | ||
4630 | */ | ||
diff --git a/drivers/media/video/bt8xx/bttv-gpio.c b/drivers/media/video/bt8xx/bttv-gpio.c deleted file mode 100644 index 922e8233fd0b..000000000000 --- a/drivers/media/video/bt8xx/bttv-gpio.c +++ /dev/null | |||
@@ -1,189 +0,0 @@ | |||
1 | /* | ||
2 | |||
3 | bttv-gpio.c -- gpio sub drivers | ||
4 | |||
5 | sysfs-based sub driver interface for bttv | ||
6 | mainly intended for gpio access | ||
7 | |||
8 | |||
9 | Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) | ||
10 | & Marcus Metzler (mocm@thp.uni-koeln.de) | ||
11 | (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org> | ||
12 | |||
13 | This program is free software; you can redistribute it and/or modify | ||
14 | it under the terms of the GNU General Public License as published by | ||
15 | the Free Software Foundation; either version 2 of the License, or | ||
16 | (at your option) any later version. | ||
17 | |||
18 | This program is distributed in the hope that it will be useful, | ||
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | GNU General Public License for more details. | ||
22 | |||
23 | You should have received a copy of the GNU General Public License | ||
24 | along with this program; if not, write to the Free Software | ||
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
30 | |||
31 | #include <linux/module.h> | ||
32 | #include <linux/init.h> | ||
33 | #include <linux/delay.h> | ||
34 | #include <linux/device.h> | ||
35 | #include <linux/slab.h> | ||
36 | #include <asm/io.h> | ||
37 | |||
38 | #include "bttvp.h" | ||
39 | |||
40 | /* ----------------------------------------------------------------------- */ | ||
41 | /* internal: the bttv "bus" */ | ||
42 | |||
43 | static int bttv_sub_bus_match(struct device *dev, struct device_driver *drv) | ||
44 | { | ||
45 | struct bttv_sub_driver *sub = to_bttv_sub_drv(drv); | ||
46 | int len = strlen(sub->wanted); | ||
47 | |||
48 | if (0 == strncmp(dev_name(dev), sub->wanted, len)) | ||
49 | return 1; | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | static int bttv_sub_probe(struct device *dev) | ||
54 | { | ||
55 | struct bttv_sub_device *sdev = to_bttv_sub_dev(dev); | ||
56 | struct bttv_sub_driver *sub = to_bttv_sub_drv(dev->driver); | ||
57 | |||
58 | return sub->probe ? sub->probe(sdev) : -ENODEV; | ||
59 | } | ||
60 | |||
61 | static int bttv_sub_remove(struct device *dev) | ||
62 | { | ||
63 | struct bttv_sub_device *sdev = to_bttv_sub_dev(dev); | ||
64 | struct bttv_sub_driver *sub = to_bttv_sub_drv(dev->driver); | ||
65 | |||
66 | if (sub->remove) | ||
67 | sub->remove(sdev); | ||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | struct bus_type bttv_sub_bus_type = { | ||
72 | .name = "bttv-sub", | ||
73 | .match = &bttv_sub_bus_match, | ||
74 | .probe = bttv_sub_probe, | ||
75 | .remove = bttv_sub_remove, | ||
76 | }; | ||
77 | |||
78 | static void release_sub_device(struct device *dev) | ||
79 | { | ||
80 | struct bttv_sub_device *sub = to_bttv_sub_dev(dev); | ||
81 | kfree(sub); | ||
82 | } | ||
83 | |||
84 | int bttv_sub_add_device(struct bttv_core *core, char *name) | ||
85 | { | ||
86 | struct bttv_sub_device *sub; | ||
87 | int err; | ||
88 | |||
89 | sub = kzalloc(sizeof(*sub),GFP_KERNEL); | ||
90 | if (NULL == sub) | ||
91 | return -ENOMEM; | ||
92 | |||
93 | sub->core = core; | ||
94 | sub->dev.parent = &core->pci->dev; | ||
95 | sub->dev.bus = &bttv_sub_bus_type; | ||
96 | sub->dev.release = release_sub_device; | ||
97 | dev_set_name(&sub->dev, "%s%d", name, core->nr); | ||
98 | |||
99 | err = device_register(&sub->dev); | ||
100 | if (0 != err) { | ||
101 | kfree(sub); | ||
102 | return err; | ||
103 | } | ||
104 | pr_info("%d: add subdevice \"%s\"\n", core->nr, dev_name(&sub->dev)); | ||
105 | list_add_tail(&sub->list,&core->subs); | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | int bttv_sub_del_devices(struct bttv_core *core) | ||
110 | { | ||
111 | struct bttv_sub_device *sub, *save; | ||
112 | |||
113 | list_for_each_entry_safe(sub, save, &core->subs, list) { | ||
114 | list_del(&sub->list); | ||
115 | device_unregister(&sub->dev); | ||
116 | } | ||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | /* ----------------------------------------------------------------------- */ | ||
121 | /* external: sub-driver register/unregister */ | ||
122 | |||
123 | int bttv_sub_register(struct bttv_sub_driver *sub, char *wanted) | ||
124 | { | ||
125 | sub->drv.bus = &bttv_sub_bus_type; | ||
126 | snprintf(sub->wanted,sizeof(sub->wanted),"%s",wanted); | ||
127 | return driver_register(&sub->drv); | ||
128 | } | ||
129 | EXPORT_SYMBOL(bttv_sub_register); | ||
130 | |||
131 | int bttv_sub_unregister(struct bttv_sub_driver *sub) | ||
132 | { | ||
133 | driver_unregister(&sub->drv); | ||
134 | return 0; | ||
135 | } | ||
136 | EXPORT_SYMBOL(bttv_sub_unregister); | ||
137 | |||
138 | /* ----------------------------------------------------------------------- */ | ||
139 | /* external: gpio access functions */ | ||
140 | |||
141 | void bttv_gpio_inout(struct bttv_core *core, u32 mask, u32 outbits) | ||
142 | { | ||
143 | struct bttv *btv = container_of(core, struct bttv, c); | ||
144 | unsigned long flags; | ||
145 | u32 data; | ||
146 | |||
147 | spin_lock_irqsave(&btv->gpio_lock,flags); | ||
148 | data = btread(BT848_GPIO_OUT_EN); | ||
149 | data = data & ~mask; | ||
150 | data = data | (mask & outbits); | ||
151 | btwrite(data,BT848_GPIO_OUT_EN); | ||
152 | spin_unlock_irqrestore(&btv->gpio_lock,flags); | ||
153 | } | ||
154 | |||
155 | u32 bttv_gpio_read(struct bttv_core *core) | ||
156 | { | ||
157 | struct bttv *btv = container_of(core, struct bttv, c); | ||
158 | u32 value; | ||
159 | |||
160 | value = btread(BT848_GPIO_DATA); | ||
161 | return value; | ||
162 | } | ||
163 | |||
164 | void bttv_gpio_write(struct bttv_core *core, u32 value) | ||
165 | { | ||
166 | struct bttv *btv = container_of(core, struct bttv, c); | ||
167 | |||
168 | btwrite(value,BT848_GPIO_DATA); | ||
169 | } | ||
170 | |||
171 | void bttv_gpio_bits(struct bttv_core *core, u32 mask, u32 bits) | ||
172 | { | ||
173 | struct bttv *btv = container_of(core, struct bttv, c); | ||
174 | unsigned long flags; | ||
175 | u32 data; | ||
176 | |||
177 | spin_lock_irqsave(&btv->gpio_lock,flags); | ||
178 | data = btread(BT848_GPIO_DATA); | ||
179 | data = data & ~mask; | ||
180 | data = data | (mask & bits); | ||
181 | btwrite(data,BT848_GPIO_DATA); | ||
182 | spin_unlock_irqrestore(&btv->gpio_lock,flags); | ||
183 | } | ||
184 | |||
185 | /* | ||
186 | * Local variables: | ||
187 | * c-basic-offset: 8 | ||
188 | * End: | ||
189 | */ | ||
diff --git a/drivers/media/video/bt8xx/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c deleted file mode 100644 index 580c8e682392..000000000000 --- a/drivers/media/video/bt8xx/bttv-i2c.c +++ /dev/null | |||
@@ -1,397 +0,0 @@ | |||
1 | /* | ||
2 | |||
3 | bttv-i2c.c -- all the i2c code is here | ||
4 | |||
5 | bttv - Bt848 frame grabber driver | ||
6 | |||
7 | Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) | ||
8 | & Marcus Metzler (mocm@thp.uni-koeln.de) | ||
9 | (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org> | ||
10 | |||
11 | (c) 2005 Mauro Carvalho Chehab <mchehab@infradead.org> | ||
12 | - Multituner support and i2c address binding | ||
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 as published by | ||
16 | the Free Software Foundation; either version 2 of the License, or | ||
17 | (at your option) any later version. | ||
18 | |||
19 | This program is distributed in the hope that it will be useful, | ||
20 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | GNU General Public License for more details. | ||
23 | |||
24 | You should have received a copy of the GNU General Public License | ||
25 | along with this program; if not, write to the Free Software | ||
26 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
27 | |||
28 | */ | ||
29 | |||
30 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
31 | |||
32 | #include <linux/module.h> | ||
33 | #include <linux/init.h> | ||
34 | #include <linux/delay.h> | ||
35 | |||
36 | #include "bttvp.h" | ||
37 | #include <media/v4l2-common.h> | ||
38 | #include <linux/jiffies.h> | ||
39 | #include <asm/io.h> | ||
40 | |||
41 | static int i2c_debug; | ||
42 | static int i2c_hw; | ||
43 | static int i2c_scan; | ||
44 | module_param(i2c_debug, int, 0644); | ||
45 | MODULE_PARM_DESC(i2c_debug, "configure i2c debug level"); | ||
46 | module_param(i2c_hw, int, 0444); | ||
47 | MODULE_PARM_DESC(i2c_hw,"force use of hardware i2c support, " | ||
48 | "instead of software bitbang"); | ||
49 | module_param(i2c_scan, int, 0444); | ||
50 | MODULE_PARM_DESC(i2c_scan,"scan i2c bus at insmod time"); | ||
51 | |||
52 | static unsigned int i2c_udelay = 5; | ||
53 | module_param(i2c_udelay, int, 0444); | ||
54 | MODULE_PARM_DESC(i2c_udelay,"soft i2c delay at insmod time, in usecs " | ||
55 | "(should be 5 or higher). Lower value means higher bus speed."); | ||
56 | |||
57 | /* ----------------------------------------------------------------------- */ | ||
58 | /* I2C functions - bitbanging adapter (software i2c) */ | ||
59 | |||
60 | static void bttv_bit_setscl(void *data, int state) | ||
61 | { | ||
62 | struct bttv *btv = (struct bttv*)data; | ||
63 | |||
64 | if (state) | ||
65 | btv->i2c_state |= 0x02; | ||
66 | else | ||
67 | btv->i2c_state &= ~0x02; | ||
68 | btwrite(btv->i2c_state, BT848_I2C); | ||
69 | btread(BT848_I2C); | ||
70 | } | ||
71 | |||
72 | static void bttv_bit_setsda(void *data, int state) | ||
73 | { | ||
74 | struct bttv *btv = (struct bttv*)data; | ||
75 | |||
76 | if (state) | ||
77 | btv->i2c_state |= 0x01; | ||
78 | else | ||
79 | btv->i2c_state &= ~0x01; | ||
80 | btwrite(btv->i2c_state, BT848_I2C); | ||
81 | btread(BT848_I2C); | ||
82 | } | ||
83 | |||
84 | static int bttv_bit_getscl(void *data) | ||
85 | { | ||
86 | struct bttv *btv = (struct bttv*)data; | ||
87 | int state; | ||
88 | |||
89 | state = btread(BT848_I2C) & 0x02 ? 1 : 0; | ||
90 | return state; | ||
91 | } | ||
92 | |||
93 | static int bttv_bit_getsda(void *data) | ||
94 | { | ||
95 | struct bttv *btv = (struct bttv*)data; | ||
96 | int state; | ||
97 | |||
98 | state = btread(BT848_I2C) & 0x01; | ||
99 | return state; | ||
100 | } | ||
101 | |||
102 | static struct i2c_algo_bit_data __devinitdata bttv_i2c_algo_bit_template = { | ||
103 | .setsda = bttv_bit_setsda, | ||
104 | .setscl = bttv_bit_setscl, | ||
105 | .getsda = bttv_bit_getsda, | ||
106 | .getscl = bttv_bit_getscl, | ||
107 | .udelay = 16, | ||
108 | .timeout = 200, | ||
109 | }; | ||
110 | |||
111 | /* ----------------------------------------------------------------------- */ | ||
112 | /* I2C functions - hardware i2c */ | ||
113 | |||
114 | static u32 functionality(struct i2c_adapter *adap) | ||
115 | { | ||
116 | return I2C_FUNC_SMBUS_EMUL; | ||
117 | } | ||
118 | |||
119 | static int | ||
120 | bttv_i2c_wait_done(struct bttv *btv) | ||
121 | { | ||
122 | int rc = 0; | ||
123 | |||
124 | /* timeout */ | ||
125 | if (wait_event_interruptible_timeout(btv->i2c_queue, | ||
126 | btv->i2c_done, msecs_to_jiffies(85)) == -ERESTARTSYS) | ||
127 | rc = -EIO; | ||
128 | |||
129 | if (btv->i2c_done & BT848_INT_RACK) | ||
130 | rc = 1; | ||
131 | btv->i2c_done = 0; | ||
132 | return rc; | ||
133 | } | ||
134 | |||
135 | #define I2C_HW (BT878_I2C_MODE | BT848_I2C_SYNC |\ | ||
136 | BT848_I2C_SCL | BT848_I2C_SDA) | ||
137 | |||
138 | static int | ||
139 | bttv_i2c_sendbytes(struct bttv *btv, const struct i2c_msg *msg, int last) | ||
140 | { | ||
141 | u32 xmit; | ||
142 | int retval,cnt; | ||
143 | |||
144 | /* sanity checks */ | ||
145 | if (0 == msg->len) | ||
146 | return -EINVAL; | ||
147 | |||
148 | /* start, address + first byte */ | ||
149 | xmit = (msg->addr << 25) | (msg->buf[0] << 16) | I2C_HW; | ||
150 | if (msg->len > 1 || !last) | ||
151 | xmit |= BT878_I2C_NOSTOP; | ||
152 | btwrite(xmit, BT848_I2C); | ||
153 | retval = bttv_i2c_wait_done(btv); | ||
154 | if (retval < 0) | ||
155 | goto err; | ||
156 | if (retval == 0) | ||
157 | goto eio; | ||
158 | if (i2c_debug) { | ||
159 | pr_cont(" <W %02x %02x", msg->addr << 1, msg->buf[0]); | ||
160 | } | ||
161 | |||
162 | for (cnt = 1; cnt < msg->len; cnt++ ) { | ||
163 | /* following bytes */ | ||
164 | xmit = (msg->buf[cnt] << 24) | I2C_HW | BT878_I2C_NOSTART; | ||
165 | if (cnt < msg->len-1 || !last) | ||
166 | xmit |= BT878_I2C_NOSTOP; | ||
167 | btwrite(xmit, BT848_I2C); | ||
168 | retval = bttv_i2c_wait_done(btv); | ||
169 | if (retval < 0) | ||
170 | goto err; | ||
171 | if (retval == 0) | ||
172 | goto eio; | ||
173 | if (i2c_debug) | ||
174 | pr_cont(" %02x", msg->buf[cnt]); | ||
175 | } | ||
176 | if (!(xmit & BT878_I2C_NOSTOP)) | ||
177 | pr_cont(">\n"); | ||
178 | return msg->len; | ||
179 | |||
180 | eio: | ||
181 | retval = -EIO; | ||
182 | err: | ||
183 | if (i2c_debug) | ||
184 | pr_cont(" ERR: %d\n",retval); | ||
185 | return retval; | ||
186 | } | ||
187 | |||
188 | static int | ||
189 | bttv_i2c_readbytes(struct bttv *btv, const struct i2c_msg *msg, int last) | ||
190 | { | ||
191 | u32 xmit; | ||
192 | u32 cnt; | ||
193 | int retval; | ||
194 | |||
195 | for (cnt = 0; cnt < msg->len; cnt++) { | ||
196 | xmit = (msg->addr << 25) | (1 << 24) | I2C_HW; | ||
197 | if (cnt < msg->len-1) | ||
198 | xmit |= BT848_I2C_W3B; | ||
199 | if (cnt < msg->len-1 || !last) | ||
200 | xmit |= BT878_I2C_NOSTOP; | ||
201 | if (cnt) | ||
202 | xmit |= BT878_I2C_NOSTART; | ||
203 | |||
204 | if (i2c_debug) { | ||
205 | if (!(xmit & BT878_I2C_NOSTART)) | ||
206 | pr_cont(" <R %02x", (msg->addr << 1) +1); | ||
207 | } | ||
208 | |||
209 | btwrite(xmit, BT848_I2C); | ||
210 | retval = bttv_i2c_wait_done(btv); | ||
211 | if (retval < 0) | ||
212 | goto err; | ||
213 | if (retval == 0) | ||
214 | goto eio; | ||
215 | msg->buf[cnt] = ((u32)btread(BT848_I2C) >> 8) & 0xff; | ||
216 | if (i2c_debug) { | ||
217 | pr_cont(" =%02x", msg->buf[cnt]); | ||
218 | } | ||
219 | if (i2c_debug && !(xmit & BT878_I2C_NOSTOP)) | ||
220 | pr_cont(" >\n"); | ||
221 | } | ||
222 | |||
223 | |||
224 | return msg->len; | ||
225 | |||
226 | eio: | ||
227 | retval = -EIO; | ||
228 | err: | ||
229 | if (i2c_debug) | ||
230 | pr_cont(" ERR: %d\n",retval); | ||
231 | return retval; | ||
232 | } | ||
233 | |||
234 | static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) | ||
235 | { | ||
236 | struct v4l2_device *v4l2_dev = i2c_get_adapdata(i2c_adap); | ||
237 | struct bttv *btv = to_bttv(v4l2_dev); | ||
238 | int retval = 0; | ||
239 | int i; | ||
240 | |||
241 | if (i2c_debug) | ||
242 | pr_debug("bt-i2c:"); | ||
243 | |||
244 | btwrite(BT848_INT_I2CDONE|BT848_INT_RACK, BT848_INT_STAT); | ||
245 | for (i = 0 ; i < num; i++) { | ||
246 | if (msgs[i].flags & I2C_M_RD) { | ||
247 | /* read */ | ||
248 | retval = bttv_i2c_readbytes(btv, &msgs[i], i+1 == num); | ||
249 | if (retval < 0) | ||
250 | goto err; | ||
251 | } else { | ||
252 | /* write */ | ||
253 | retval = bttv_i2c_sendbytes(btv, &msgs[i], i+1 == num); | ||
254 | if (retval < 0) | ||
255 | goto err; | ||
256 | } | ||
257 | } | ||
258 | return num; | ||
259 | |||
260 | err: | ||
261 | return retval; | ||
262 | } | ||
263 | |||
264 | static const struct i2c_algorithm bttv_algo = { | ||
265 | .master_xfer = bttv_i2c_xfer, | ||
266 | .functionality = functionality, | ||
267 | }; | ||
268 | |||
269 | /* ----------------------------------------------------------------------- */ | ||
270 | /* I2C functions - common stuff */ | ||
271 | |||
272 | /* read I2C */ | ||
273 | int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for) | ||
274 | { | ||
275 | unsigned char buffer = 0; | ||
276 | |||
277 | if (0 != btv->i2c_rc) | ||
278 | return -1; | ||
279 | if (bttv_verbose && NULL != probe_for) | ||
280 | pr_info("%d: i2c: checking for %s @ 0x%02x... ", | ||
281 | btv->c.nr, probe_for, addr); | ||
282 | btv->i2c_client.addr = addr >> 1; | ||
283 | if (1 != i2c_master_recv(&btv->i2c_client, &buffer, 1)) { | ||
284 | if (NULL != probe_for) { | ||
285 | if (bttv_verbose) | ||
286 | pr_cont("not found\n"); | ||
287 | } else | ||
288 | pr_warn("%d: i2c read 0x%x: error\n", | ||
289 | btv->c.nr, addr); | ||
290 | return -1; | ||
291 | } | ||
292 | if (bttv_verbose && NULL != probe_for) | ||
293 | pr_cont("found\n"); | ||
294 | return buffer; | ||
295 | } | ||
296 | |||
297 | /* write I2C */ | ||
298 | int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1, | ||
299 | unsigned char b2, int both) | ||
300 | { | ||
301 | unsigned char buffer[2]; | ||
302 | int bytes = both ? 2 : 1; | ||
303 | |||
304 | if (0 != btv->i2c_rc) | ||
305 | return -1; | ||
306 | btv->i2c_client.addr = addr >> 1; | ||
307 | buffer[0] = b1; | ||
308 | buffer[1] = b2; | ||
309 | if (bytes != i2c_master_send(&btv->i2c_client, buffer, bytes)) | ||
310 | return -1; | ||
311 | return 0; | ||
312 | } | ||
313 | |||
314 | /* read EEPROM content */ | ||
315 | void __devinit bttv_readee(struct bttv *btv, unsigned char *eedata, int addr) | ||
316 | { | ||
317 | memset(eedata, 0, 256); | ||
318 | if (0 != btv->i2c_rc) | ||
319 | return; | ||
320 | btv->i2c_client.addr = addr >> 1; | ||
321 | tveeprom_read(&btv->i2c_client, eedata, 256); | ||
322 | } | ||
323 | |||
324 | static char *i2c_devs[128] = { | ||
325 | [ 0x1c >> 1 ] = "lgdt330x", | ||
326 | [ 0x30 >> 1 ] = "IR (hauppauge)", | ||
327 | [ 0x80 >> 1 ] = "msp34xx", | ||
328 | [ 0x86 >> 1 ] = "tda9887", | ||
329 | [ 0xa0 >> 1 ] = "eeprom", | ||
330 | [ 0xc0 >> 1 ] = "tuner (analog)", | ||
331 | [ 0xc2 >> 1 ] = "tuner (analog)", | ||
332 | }; | ||
333 | |||
334 | static void do_i2c_scan(char *name, struct i2c_client *c) | ||
335 | { | ||
336 | unsigned char buf; | ||
337 | int i,rc; | ||
338 | |||
339 | for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) { | ||
340 | c->addr = i; | ||
341 | rc = i2c_master_recv(c,&buf,0); | ||
342 | if (rc < 0) | ||
343 | continue; | ||
344 | pr_info("%s: i2c scan: found device @ 0x%x [%s]\n", | ||
345 | name, i << 1, i2c_devs[i] ? i2c_devs[i] : "???"); | ||
346 | } | ||
347 | } | ||
348 | |||
349 | /* init + register i2c adapter */ | ||
350 | int __devinit init_bttv_i2c(struct bttv *btv) | ||
351 | { | ||
352 | strlcpy(btv->i2c_client.name, "bttv internal", I2C_NAME_SIZE); | ||
353 | |||
354 | if (i2c_hw) | ||
355 | btv->use_i2c_hw = 1; | ||
356 | if (btv->use_i2c_hw) { | ||
357 | /* bt878 */ | ||
358 | strlcpy(btv->c.i2c_adap.name, "bt878", | ||
359 | sizeof(btv->c.i2c_adap.name)); | ||
360 | btv->c.i2c_adap.algo = &bttv_algo; | ||
361 | } else { | ||
362 | /* bt848 */ | ||
363 | /* Prevents usage of invalid delay values */ | ||
364 | if (i2c_udelay<5) | ||
365 | i2c_udelay=5; | ||
366 | |||
367 | strlcpy(btv->c.i2c_adap.name, "bttv", | ||
368 | sizeof(btv->c.i2c_adap.name)); | ||
369 | memcpy(&btv->i2c_algo, &bttv_i2c_algo_bit_template, | ||
370 | sizeof(bttv_i2c_algo_bit_template)); | ||
371 | btv->i2c_algo.udelay = i2c_udelay; | ||
372 | btv->i2c_algo.data = btv; | ||
373 | btv->c.i2c_adap.algo_data = &btv->i2c_algo; | ||
374 | } | ||
375 | btv->c.i2c_adap.owner = THIS_MODULE; | ||
376 | |||
377 | btv->c.i2c_adap.dev.parent = &btv->c.pci->dev; | ||
378 | snprintf(btv->c.i2c_adap.name, sizeof(btv->c.i2c_adap.name), | ||
379 | "bt%d #%d [%s]", btv->id, btv->c.nr, | ||
380 | btv->use_i2c_hw ? "hw" : "sw"); | ||
381 | |||
382 | i2c_set_adapdata(&btv->c.i2c_adap, &btv->c.v4l2_dev); | ||
383 | btv->i2c_client.adapter = &btv->c.i2c_adap; | ||
384 | |||
385 | |||
386 | if (btv->use_i2c_hw) { | ||
387 | btv->i2c_rc = i2c_add_adapter(&btv->c.i2c_adap); | ||
388 | } else { | ||
389 | bttv_bit_setscl(btv,1); | ||
390 | bttv_bit_setsda(btv,1); | ||
391 | btv->i2c_rc = i2c_bit_add_bus(&btv->c.i2c_adap); | ||
392 | } | ||
393 | if (0 == btv->i2c_rc && i2c_scan) | ||
394 | do_i2c_scan(btv->c.v4l2_dev.name, &btv->i2c_client); | ||
395 | |||
396 | return btv->i2c_rc; | ||
397 | } | ||
diff --git a/drivers/media/video/bt8xx/bttv-if.c b/drivers/media/video/bt8xx/bttv-if.c deleted file mode 100644 index a6a540dc9e4b..000000000000 --- a/drivers/media/video/bt8xx/bttv-if.c +++ /dev/null | |||
@@ -1,121 +0,0 @@ | |||
1 | /* | ||
2 | |||
3 | bttv-if.c -- old gpio interface to other kernel modules | ||
4 | don't use in new code, will go away in 2.7 | ||
5 | have a look at bttv-gpio.c instead. | ||
6 | |||
7 | bttv - Bt848 frame grabber driver | ||
8 | |||
9 | Copyright (C) 1996,97,98 Ralph Metzler (rjkm@thp.uni-koeln.de) | ||
10 | & Marcus Metzler (mocm@thp.uni-koeln.de) | ||
11 | (c) 1999-2003 Gerd Knorr <kraxel@bytesex.org> | ||
12 | |||
13 | This program is free software; you can redistribute it and/or modify | ||
14 | it under the terms of the GNU General Public License as published by | ||
15 | the Free Software Foundation; either version 2 of the License, or | ||
16 | (at your option) any later version. | ||
17 | |||
18 | This program is distributed in the hope that it will be useful, | ||
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | GNU General Public License for more details. | ||
22 | |||
23 | You should have received a copy of the GNU General Public License | ||
24 | along with this program; if not, write to the Free Software | ||
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
26 | |||
27 | */ | ||
28 | |||
29 | #include <linux/module.h> | ||
30 | #include <linux/init.h> | ||
31 | #include <linux/delay.h> | ||
32 | #include <asm/io.h> | ||
33 | |||
34 | #include "bttvp.h" | ||
35 | |||
36 | EXPORT_SYMBOL(bttv_get_pcidev); | ||
37 | EXPORT_SYMBOL(bttv_gpio_enable); | ||
38 | EXPORT_SYMBOL(bttv_read_gpio); | ||
39 | EXPORT_SYMBOL(bttv_write_gpio); | ||
40 | |||
41 | /* ----------------------------------------------------------------------- */ | ||
42 | /* Exported functions - for other modules which want to access the */ | ||
43 | /* gpio ports (IR for example) */ | ||
44 | /* see bttv.h for comments */ | ||
45 | |||
46 | struct pci_dev* bttv_get_pcidev(unsigned int card) | ||
47 | { | ||
48 | if (card >= bttv_num) | ||
49 | return NULL; | ||
50 | if (!bttvs[card]) | ||
51 | return NULL; | ||
52 | |||
53 | return bttvs[card]->c.pci; | ||
54 | } | ||
55 | |||
56 | |||
57 | int bttv_gpio_enable(unsigned int card, unsigned long mask, unsigned long data) | ||
58 | { | ||
59 | struct bttv *btv; | ||
60 | |||
61 | if (card >= bttv_num) { | ||
62 | return -EINVAL; | ||
63 | } | ||
64 | |||
65 | btv = bttvs[card]; | ||
66 | if (!btv) | ||
67 | return -ENODEV; | ||
68 | |||
69 | gpio_inout(mask,data); | ||
70 | if (bttv_gpio) | ||
71 | bttv_gpio_tracking(btv,"extern enable"); | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | int bttv_read_gpio(unsigned int card, unsigned long *data) | ||
76 | { | ||
77 | struct bttv *btv; | ||
78 | |||
79 | if (card >= bttv_num) { | ||
80 | return -EINVAL; | ||
81 | } | ||
82 | |||
83 | btv = bttvs[card]; | ||
84 | if (!btv) | ||
85 | return -ENODEV; | ||
86 | |||
87 | if(btv->shutdown) { | ||
88 | return -ENODEV; | ||
89 | } | ||
90 | |||
91 | /* prior setting BT848_GPIO_REG_INP is (probably) not needed | ||
92 | because we set direct input on init */ | ||
93 | *data = gpio_read(); | ||
94 | return 0; | ||
95 | } | ||
96 | |||
97 | int bttv_write_gpio(unsigned int card, unsigned long mask, unsigned long data) | ||
98 | { | ||
99 | struct bttv *btv; | ||
100 | |||
101 | if (card >= bttv_num) { | ||
102 | return -EINVAL; | ||
103 | } | ||
104 | |||
105 | btv = bttvs[card]; | ||
106 | if (!btv) | ||
107 | return -ENODEV; | ||
108 | |||
109 | /* prior setting BT848_GPIO_REG_INP is (probably) not needed | ||
110 | because direct input is set on init */ | ||
111 | gpio_bits(mask,data); | ||
112 | if (bttv_gpio) | ||
113 | bttv_gpio_tracking(btv,"extern write"); | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | /* | ||
118 | * Local variables: | ||
119 | * c-basic-offset: 8 | ||
120 | * End: | ||
121 | */ | ||
diff --git a/drivers/media/video/bt8xx/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c deleted file mode 100644 index ef4c7cd41982..000000000000 --- a/drivers/media/video/bt8xx/bttv-input.c +++ /dev/null | |||
@@ -1,589 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * Copyright (c) 2003 Gerd Knorr | ||
4 | * Copyright (c) 2003 Pavel Machek | ||
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/delay.h> | ||
26 | #include <linux/interrupt.h> | ||
27 | #include <linux/input.h> | ||
28 | #include <linux/slab.h> | ||
29 | |||
30 | #include "bttv.h" | ||
31 | #include "bttvp.h" | ||
32 | |||
33 | |||
34 | static int ir_debug; | ||
35 | module_param(ir_debug, int, 0644); | ||
36 | |||
37 | static int ir_rc5_remote_gap = 885; | ||
38 | module_param(ir_rc5_remote_gap, int, 0644); | ||
39 | |||
40 | #undef dprintk | ||
41 | #define dprintk(fmt, ...) \ | ||
42 | do { \ | ||
43 | if (ir_debug >= 1) \ | ||
44 | pr_info(fmt, ##__VA_ARGS__); \ | ||
45 | } while (0) | ||
46 | |||
47 | #define DEVNAME "bttv-input" | ||
48 | |||
49 | #define MODULE_NAME "bttv" | ||
50 | |||
51 | /* ---------------------------------------------------------------------- */ | ||
52 | |||
53 | static void ir_handle_key(struct bttv *btv) | ||
54 | { | ||
55 | struct bttv_ir *ir = btv->remote; | ||
56 | u32 gpio,data; | ||
57 | |||
58 | /* read gpio value */ | ||
59 | gpio = bttv_gpio_read(&btv->c); | ||
60 | if (ir->polling) { | ||
61 | if (ir->last_gpio == gpio) | ||
62 | return; | ||
63 | ir->last_gpio = gpio; | ||
64 | } | ||
65 | |||
66 | /* extract data */ | ||
67 | data = ir_extract_bits(gpio, ir->mask_keycode); | ||
68 | dprintk("irq gpio=0x%x code=%d | %s%s%s\n", | ||
69 | gpio, data, | ||
70 | ir->polling ? "poll" : "irq", | ||
71 | (gpio & ir->mask_keydown) ? " down" : "", | ||
72 | (gpio & ir->mask_keyup) ? " up" : ""); | ||
73 | |||
74 | if ((ir->mask_keydown && (gpio & ir->mask_keydown)) || | ||
75 | (ir->mask_keyup && !(gpio & ir->mask_keyup))) { | ||
76 | rc_keydown_notimeout(ir->dev, data, 0); | ||
77 | } else { | ||
78 | /* HACK: Probably, ir->mask_keydown is missing | ||
79 | for this board */ | ||
80 | if (btv->c.type == BTTV_BOARD_WINFAST2000) | ||
81 | rc_keydown_notimeout(ir->dev, data, 0); | ||
82 | |||
83 | rc_keyup(ir->dev); | ||
84 | } | ||
85 | } | ||
86 | |||
87 | static void ir_enltv_handle_key(struct bttv *btv) | ||
88 | { | ||
89 | struct bttv_ir *ir = btv->remote; | ||
90 | u32 gpio, data, keyup; | ||
91 | |||
92 | /* read gpio value */ | ||
93 | gpio = bttv_gpio_read(&btv->c); | ||
94 | |||
95 | /* extract data */ | ||
96 | data = ir_extract_bits(gpio, ir->mask_keycode); | ||
97 | |||
98 | /* Check if it is keyup */ | ||
99 | keyup = (gpio & ir->mask_keyup) ? 1 << 31 : 0; | ||
100 | |||
101 | if ((ir->last_gpio & 0x7f) != data) { | ||
102 | dprintk("gpio=0x%x code=%d | %s\n", | ||
103 | gpio, data, | ||
104 | (gpio & ir->mask_keyup) ? " up" : "up/down"); | ||
105 | |||
106 | rc_keydown_notimeout(ir->dev, data, 0); | ||
107 | if (keyup) | ||
108 | rc_keyup(ir->dev); | ||
109 | } else { | ||
110 | if ((ir->last_gpio & 1 << 31) == keyup) | ||
111 | return; | ||
112 | |||
113 | dprintk("(cnt) gpio=0x%x code=%d | %s\n", | ||
114 | gpio, data, | ||
115 | (gpio & ir->mask_keyup) ? " up" : "down"); | ||
116 | |||
117 | if (keyup) | ||
118 | rc_keyup(ir->dev); | ||
119 | else | ||
120 | rc_keydown_notimeout(ir->dev, data, 0); | ||
121 | } | ||
122 | |||
123 | ir->last_gpio = data | keyup; | ||
124 | } | ||
125 | |||
126 | static int bttv_rc5_irq(struct bttv *btv); | ||
127 | |||
128 | void bttv_input_irq(struct bttv *btv) | ||
129 | { | ||
130 | struct bttv_ir *ir = btv->remote; | ||
131 | |||
132 | if (ir->rc5_gpio) | ||
133 | bttv_rc5_irq(btv); | ||
134 | else if (!ir->polling) | ||
135 | ir_handle_key(btv); | ||
136 | } | ||
137 | |||
138 | static void bttv_input_timer(unsigned long data) | ||
139 | { | ||
140 | struct bttv *btv = (struct bttv*)data; | ||
141 | struct bttv_ir *ir = btv->remote; | ||
142 | |||
143 | if (btv->c.type == BTTV_BOARD_ENLTV_FM_2) | ||
144 | ir_enltv_handle_key(btv); | ||
145 | else | ||
146 | ir_handle_key(btv); | ||
147 | mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling)); | ||
148 | } | ||
149 | |||
150 | /* | ||
151 | * FIXME: Nebula digi uses the legacy way to decode RC5, instead of relying | ||
152 | * on the rc-core way. As we need to be sure that both IRQ transitions are | ||
153 | * properly triggered, Better to touch it only with this hardware for | ||
154 | * testing. | ||
155 | */ | ||
156 | |||
157 | #define RC5_START(x) (((x) >> 12) & 3) | ||
158 | #define RC5_TOGGLE(x) (((x) >> 11) & 1) | ||
159 | #define RC5_ADDR(x) (((x) >> 6) & 31) | ||
160 | #define RC5_INSTR(x) ((x) & 63) | ||
161 | |||
162 | /* decode raw bit pattern to RC5 code */ | ||
163 | static u32 bttv_rc5_decode(unsigned int code) | ||
164 | { | ||
165 | unsigned int org_code = code; | ||
166 | unsigned int pair; | ||
167 | unsigned int rc5 = 0; | ||
168 | int i; | ||
169 | |||
170 | for (i = 0; i < 14; ++i) { | ||
171 | pair = code & 0x3; | ||
172 | code >>= 2; | ||
173 | |||
174 | rc5 <<= 1; | ||
175 | switch (pair) { | ||
176 | case 0: | ||
177 | case 2: | ||
178 | break; | ||
179 | case 1: | ||
180 | rc5 |= 1; | ||
181 | break; | ||
182 | case 3: | ||
183 | dprintk("rc5_decode(%x) bad code\n", | ||
184 | org_code); | ||
185 | return 0; | ||
186 | } | ||
187 | } | ||
188 | dprintk("code=%x, rc5=%x, start=%x, toggle=%x, address=%x, " | ||
189 | "instr=%x\n", rc5, org_code, RC5_START(rc5), | ||
190 | RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5)); | ||
191 | return rc5; | ||
192 | } | ||
193 | |||
194 | static void bttv_rc5_timer_end(unsigned long data) | ||
195 | { | ||
196 | struct bttv_ir *ir = (struct bttv_ir *)data; | ||
197 | struct timeval tv; | ||
198 | u32 gap; | ||
199 | u32 rc5 = 0; | ||
200 | |||
201 | /* get time */ | ||
202 | do_gettimeofday(&tv); | ||
203 | |||
204 | /* avoid overflow with gap >1s */ | ||
205 | if (tv.tv_sec - ir->base_time.tv_sec > 1) { | ||
206 | gap = 200000; | ||
207 | } else { | ||
208 | gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) + | ||
209 | tv.tv_usec - ir->base_time.tv_usec; | ||
210 | } | ||
211 | |||
212 | /* signal we're ready to start a new code */ | ||
213 | ir->active = false; | ||
214 | |||
215 | /* Allow some timer jitter (RC5 is ~24ms anyway so this is ok) */ | ||
216 | if (gap < 28000) { | ||
217 | dprintk("spurious timer_end\n"); | ||
218 | return; | ||
219 | } | ||
220 | |||
221 | if (ir->last_bit < 20) { | ||
222 | /* ignore spurious codes (caused by light/other remotes) */ | ||
223 | dprintk("short code: %x\n", ir->code); | ||
224 | } else { | ||
225 | ir->code = (ir->code << ir->shift_by) | 1; | ||
226 | rc5 = bttv_rc5_decode(ir->code); | ||
227 | |||
228 | /* two start bits? */ | ||
229 | if (RC5_START(rc5) != ir->start) { | ||
230 | pr_info(DEVNAME ":" | ||
231 | " rc5 start bits invalid: %u\n", RC5_START(rc5)); | ||
232 | |||
233 | /* right address? */ | ||
234 | } else if (RC5_ADDR(rc5) == ir->addr) { | ||
235 | u32 toggle = RC5_TOGGLE(rc5); | ||
236 | u32 instr = RC5_INSTR(rc5); | ||
237 | |||
238 | /* Good code */ | ||
239 | rc_keydown(ir->dev, instr, toggle); | ||
240 | dprintk("instruction %x, toggle %x\n", | ||
241 | instr, toggle); | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | |||
246 | static int bttv_rc5_irq(struct bttv *btv) | ||
247 | { | ||
248 | struct bttv_ir *ir = btv->remote; | ||
249 | struct timeval tv; | ||
250 | u32 gpio; | ||
251 | u32 gap; | ||
252 | unsigned long current_jiffies; | ||
253 | |||
254 | /* read gpio port */ | ||
255 | gpio = bttv_gpio_read(&btv->c); | ||
256 | |||
257 | /* get time of bit */ | ||
258 | current_jiffies = jiffies; | ||
259 | do_gettimeofday(&tv); | ||
260 | |||
261 | /* avoid overflow with gap >1s */ | ||
262 | if (tv.tv_sec - ir->base_time.tv_sec > 1) { | ||
263 | gap = 200000; | ||
264 | } else { | ||
265 | gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) + | ||
266 | tv.tv_usec - ir->base_time.tv_usec; | ||
267 | } | ||
268 | |||
269 | dprintk("RC5 IRQ: gap %d us for %s\n", | ||
270 | gap, (gpio & 0x20) ? "mark" : "space"); | ||
271 | |||
272 | /* remote IRQ? */ | ||
273 | if (!(gpio & 0x20)) | ||
274 | return 0; | ||
275 | |||
276 | /* active code => add bit */ | ||
277 | if (ir->active) { | ||
278 | /* only if in the code (otherwise spurious IRQ or timer | ||
279 | late) */ | ||
280 | if (ir->last_bit < 28) { | ||
281 | ir->last_bit = (gap - ir_rc5_remote_gap / 2) / | ||
282 | ir_rc5_remote_gap; | ||
283 | ir->code |= 1 << ir->last_bit; | ||
284 | } | ||
285 | /* starting new code */ | ||
286 | } else { | ||
287 | ir->active = true; | ||
288 | ir->code = 0; | ||
289 | ir->base_time = tv; | ||
290 | ir->last_bit = 0; | ||
291 | |||
292 | mod_timer(&ir->timer, current_jiffies + msecs_to_jiffies(30)); | ||
293 | } | ||
294 | |||
295 | /* toggle GPIO pin 4 to reset the irq */ | ||
296 | bttv_gpio_write(&btv->c, gpio & ~(1 << 4)); | ||
297 | bttv_gpio_write(&btv->c, gpio | (1 << 4)); | ||
298 | return 1; | ||
299 | } | ||
300 | |||
301 | /* ---------------------------------------------------------------------- */ | ||
302 | |||
303 | static void bttv_ir_start(struct bttv *btv, struct bttv_ir *ir) | ||
304 | { | ||
305 | if (ir->polling) { | ||
306 | setup_timer(&ir->timer, bttv_input_timer, (unsigned long)btv); | ||
307 | ir->timer.expires = jiffies + msecs_to_jiffies(1000); | ||
308 | add_timer(&ir->timer); | ||
309 | } else if (ir->rc5_gpio) { | ||
310 | /* set timer_end for code completion */ | ||
311 | setup_timer(&ir->timer, bttv_rc5_timer_end, (unsigned long)ir); | ||
312 | ir->shift_by = 1; | ||
313 | ir->start = 3; | ||
314 | ir->addr = 0x0; | ||
315 | ir->rc5_remote_gap = ir_rc5_remote_gap; | ||
316 | } | ||
317 | } | ||
318 | |||
319 | static void bttv_ir_stop(struct bttv *btv) | ||
320 | { | ||
321 | if (btv->remote->polling) | ||
322 | del_timer_sync(&btv->remote->timer); | ||
323 | |||
324 | if (btv->remote->rc5_gpio) { | ||
325 | u32 gpio; | ||
326 | |||
327 | del_timer_sync(&btv->remote->timer); | ||
328 | |||
329 | gpio = bttv_gpio_read(&btv->c); | ||
330 | bttv_gpio_write(&btv->c, gpio & ~(1 << 4)); | ||
331 | } | ||
332 | } | ||
333 | |||
334 | /* | ||
335 | * Get_key functions used by I2C remotes | ||
336 | */ | ||
337 | |||
338 | static int get_key_pv951(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw) | ||
339 | { | ||
340 | unsigned char b; | ||
341 | |||
342 | /* poll IR chip */ | ||
343 | if (1 != i2c_master_recv(ir->c, &b, 1)) { | ||
344 | dprintk("read error\n"); | ||
345 | return -EIO; | ||
346 | } | ||
347 | |||
348 | /* ignore 0xaa */ | ||
349 | if (b==0xaa) | ||
350 | return 0; | ||
351 | dprintk("key %02x\n", b); | ||
352 | |||
353 | /* | ||
354 | * NOTE: | ||
355 | * lirc_i2c maps the pv951 code as: | ||
356 | * addr = 0x61D6 | ||
357 | * cmd = bit_reverse (b) | ||
358 | * So, it seems that this device uses NEC extended | ||
359 | * I decided to not fix the table, due to two reasons: | ||
360 | * 1) Without the actual device, this is only a guess; | ||
361 | * 2) As the addr is not reported via I2C, nor can be changed, | ||
362 | * the device is bound to the vendor-provided RC. | ||
363 | */ | ||
364 | |||
365 | *ir_key = b; | ||
366 | *ir_raw = b; | ||
367 | return 1; | ||
368 | } | ||
369 | |||
370 | /* Instantiate the I2C IR receiver device, if present */ | ||
371 | void __devinit init_bttv_i2c_ir(struct bttv *btv) | ||
372 | { | ||
373 | const unsigned short addr_list[] = { | ||
374 | 0x1a, 0x18, 0x64, 0x30, 0x71, | ||
375 | I2C_CLIENT_END | ||
376 | }; | ||
377 | struct i2c_board_info info; | ||
378 | |||
379 | if (0 != btv->i2c_rc) | ||
380 | return; | ||
381 | |||
382 | memset(&info, 0, sizeof(struct i2c_board_info)); | ||
383 | memset(&btv->init_data, 0, sizeof(btv->init_data)); | ||
384 | strlcpy(info.type, "ir_video", I2C_NAME_SIZE); | ||
385 | |||
386 | switch (btv->c.type) { | ||
387 | case BTTV_BOARD_PV951: | ||
388 | btv->init_data.name = "PV951"; | ||
389 | btv->init_data.get_key = get_key_pv951; | ||
390 | btv->init_data.ir_codes = RC_MAP_PV951; | ||
391 | info.addr = 0x4b; | ||
392 | break; | ||
393 | default: | ||
394 | /* | ||
395 | * The external IR receiver is at i2c address 0x34 (0x35 for | ||
396 | * reads). Future Hauppauge cards will have an internal | ||
397 | * receiver at 0x30 (0x31 for reads). In theory, both can be | ||
398 | * fitted, and Hauppauge suggest an external overrides an | ||
399 | * internal. | ||
400 | * That's why we probe 0x1a (~0x34) first. CB | ||
401 | */ | ||
402 | |||
403 | i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list, NULL); | ||
404 | return; | ||
405 | } | ||
406 | |||
407 | if (btv->init_data.name) | ||
408 | info.platform_data = &btv->init_data; | ||
409 | i2c_new_device(&btv->c.i2c_adap, &info); | ||
410 | |||
411 | return; | ||
412 | } | ||
413 | |||
414 | int __devexit fini_bttv_i2c(struct bttv *btv) | ||
415 | { | ||
416 | if (0 != btv->i2c_rc) | ||
417 | return 0; | ||
418 | |||
419 | return i2c_del_adapter(&btv->c.i2c_adap); | ||
420 | } | ||
421 | |||
422 | int bttv_input_init(struct bttv *btv) | ||
423 | { | ||
424 | struct bttv_ir *ir; | ||
425 | char *ir_codes = NULL; | ||
426 | struct rc_dev *rc; | ||
427 | int err = -ENOMEM; | ||
428 | |||
429 | if (!btv->has_remote) | ||
430 | return -ENODEV; | ||
431 | |||
432 | ir = kzalloc(sizeof(*ir),GFP_KERNEL); | ||
433 | rc = rc_allocate_device(); | ||
434 | if (!ir || !rc) | ||
435 | goto err_out_free; | ||
436 | |||
437 | /* detect & configure */ | ||
438 | switch (btv->c.type) { | ||
439 | case BTTV_BOARD_AVERMEDIA: | ||
440 | case BTTV_BOARD_AVPHONE98: | ||
441 | case BTTV_BOARD_AVERMEDIA98: | ||
442 | ir_codes = RC_MAP_AVERMEDIA; | ||
443 | ir->mask_keycode = 0xf88000; | ||
444 | ir->mask_keydown = 0x010000; | ||
445 | ir->polling = 50; // ms | ||
446 | break; | ||
447 | |||
448 | case BTTV_BOARD_AVDVBT_761: | ||
449 | case BTTV_BOARD_AVDVBT_771: | ||
450 | ir_codes = RC_MAP_AVERMEDIA_DVBT; | ||
451 | ir->mask_keycode = 0x0f00c0; | ||
452 | ir->mask_keydown = 0x000020; | ||
453 | ir->polling = 50; // ms | ||
454 | break; | ||
455 | |||
456 | case BTTV_BOARD_PXELVWPLTVPAK: | ||
457 | ir_codes = RC_MAP_PIXELVIEW; | ||
458 | ir->mask_keycode = 0x003e00; | ||
459 | ir->mask_keyup = 0x010000; | ||
460 | ir->polling = 50; // ms | ||
461 | break; | ||
462 | case BTTV_BOARD_PV_M4900: | ||
463 | case BTTV_BOARD_PV_BT878P_9B: | ||
464 | case BTTV_BOARD_PV_BT878P_PLUS: | ||
465 | ir_codes = RC_MAP_PIXELVIEW; | ||
466 | ir->mask_keycode = 0x001f00; | ||
467 | ir->mask_keyup = 0x008000; | ||
468 | ir->polling = 50; // ms | ||
469 | break; | ||
470 | |||
471 | case BTTV_BOARD_WINFAST2000: | ||
472 | ir_codes = RC_MAP_WINFAST; | ||
473 | ir->mask_keycode = 0x1f8; | ||
474 | break; | ||
475 | case BTTV_BOARD_MAGICTVIEW061: | ||
476 | case BTTV_BOARD_MAGICTVIEW063: | ||
477 | ir_codes = RC_MAP_WINFAST; | ||
478 | ir->mask_keycode = 0x0008e000; | ||
479 | ir->mask_keydown = 0x00200000; | ||
480 | break; | ||
481 | case BTTV_BOARD_APAC_VIEWCOMP: | ||
482 | ir_codes = RC_MAP_APAC_VIEWCOMP; | ||
483 | ir->mask_keycode = 0x001f00; | ||
484 | ir->mask_keyup = 0x008000; | ||
485 | ir->polling = 50; // ms | ||
486 | break; | ||
487 | case BTTV_BOARD_ASKEY_CPH03X: | ||
488 | case BTTV_BOARD_CONCEPTRONIC_CTVFMI2: | ||
489 | case BTTV_BOARD_CONTVFMI: | ||
490 | ir_codes = RC_MAP_PIXELVIEW; | ||
491 | ir->mask_keycode = 0x001F00; | ||
492 | ir->mask_keyup = 0x006000; | ||
493 | ir->polling = 50; // ms | ||
494 | break; | ||
495 | case BTTV_BOARD_NEBULA_DIGITV: | ||
496 | ir_codes = RC_MAP_NEBULA; | ||
497 | ir->rc5_gpio = true; | ||
498 | break; | ||
499 | case BTTV_BOARD_MACHTV_MAGICTV: | ||
500 | ir_codes = RC_MAP_APAC_VIEWCOMP; | ||
501 | ir->mask_keycode = 0x001F00; | ||
502 | ir->mask_keyup = 0x004000; | ||
503 | ir->polling = 50; /* ms */ | ||
504 | break; | ||
505 | case BTTV_BOARD_KOZUMI_KTV_01C: | ||
506 | ir_codes = RC_MAP_PCTV_SEDNA; | ||
507 | ir->mask_keycode = 0x001f00; | ||
508 | ir->mask_keyup = 0x006000; | ||
509 | ir->polling = 50; /* ms */ | ||
510 | break; | ||
511 | case BTTV_BOARD_ENLTV_FM_2: | ||
512 | ir_codes = RC_MAP_ENCORE_ENLTV2; | ||
513 | ir->mask_keycode = 0x00fd00; | ||
514 | ir->mask_keyup = 0x000080; | ||
515 | ir->polling = 1; /* ms */ | ||
516 | ir->last_gpio = ir_extract_bits(bttv_gpio_read(&btv->c), | ||
517 | ir->mask_keycode); | ||
518 | break; | ||
519 | } | ||
520 | if (NULL == ir_codes) { | ||
521 | dprintk("Ooops: IR config error [card=%d]\n", btv->c.type); | ||
522 | err = -ENODEV; | ||
523 | goto err_out_free; | ||
524 | } | ||
525 | |||
526 | if (ir->rc5_gpio) { | ||
527 | u32 gpio; | ||
528 | /* enable remote irq */ | ||
529 | bttv_gpio_inout(&btv->c, (1 << 4), 1 << 4); | ||
530 | gpio = bttv_gpio_read(&btv->c); | ||
531 | bttv_gpio_write(&btv->c, gpio & ~(1 << 4)); | ||
532 | bttv_gpio_write(&btv->c, gpio | (1 << 4)); | ||
533 | } else { | ||
534 | /* init hardware-specific stuff */ | ||
535 | bttv_gpio_inout(&btv->c, ir->mask_keycode | ir->mask_keydown, 0); | ||
536 | } | ||
537 | |||
538 | /* init input device */ | ||
539 | ir->dev = rc; | ||
540 | |||
541 | snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)", | ||
542 | btv->c.type); | ||
543 | snprintf(ir->phys, sizeof(ir->phys), "pci-%s/ir0", | ||
544 | pci_name(btv->c.pci)); | ||
545 | |||
546 | rc->input_name = ir->name; | ||
547 | rc->input_phys = ir->phys; | ||
548 | rc->input_id.bustype = BUS_PCI; | ||
549 | rc->input_id.version = 1; | ||
550 | if (btv->c.pci->subsystem_vendor) { | ||
551 | rc->input_id.vendor = btv->c.pci->subsystem_vendor; | ||
552 | rc->input_id.product = btv->c.pci->subsystem_device; | ||
553 | } else { | ||
554 | rc->input_id.vendor = btv->c.pci->vendor; | ||
555 | rc->input_id.product = btv->c.pci->device; | ||
556 | } | ||
557 | rc->dev.parent = &btv->c.pci->dev; | ||
558 | rc->map_name = ir_codes; | ||
559 | rc->driver_name = MODULE_NAME; | ||
560 | |||
561 | btv->remote = ir; | ||
562 | bttv_ir_start(btv, ir); | ||
563 | |||
564 | /* all done */ | ||
565 | err = rc_register_device(rc); | ||
566 | if (err) | ||
567 | goto err_out_stop; | ||
568 | |||
569 | return 0; | ||
570 | |||
571 | err_out_stop: | ||
572 | bttv_ir_stop(btv); | ||
573 | btv->remote = NULL; | ||
574 | err_out_free: | ||
575 | rc_free_device(rc); | ||
576 | kfree(ir); | ||
577 | return err; | ||
578 | } | ||
579 | |||
580 | void bttv_input_fini(struct bttv *btv) | ||
581 | { | ||
582 | if (btv->remote == NULL) | ||
583 | return; | ||
584 | |||
585 | bttv_ir_stop(btv); | ||
586 | rc_unregister_device(btv->remote->dev); | ||
587 | kfree(btv->remote); | ||
588 | btv->remote = NULL; | ||
589 | } | ||
diff --git a/drivers/media/video/bt8xx/bttv-risc.c b/drivers/media/video/bt8xx/bttv-risc.c deleted file mode 100644 index 82cc47d2e3fa..000000000000 --- a/drivers/media/video/bt8xx/bttv-risc.c +++ /dev/null | |||
@@ -1,909 +0,0 @@ | |||
1 | /* | ||
2 | |||
3 | bttv-risc.c -- interfaces to other kernel modules | ||
4 | |||
5 | bttv risc code handling | ||
6 | - memory management | ||
7 | - generation | ||
8 | |||
9 | (c) 2000-2003 Gerd Knorr <kraxel@bytesex.org> | ||
10 | |||
11 | This program is free software; you can redistribute it and/or modify | ||
12 | it under the terms of the GNU General Public License as published by | ||
13 | the Free Software Foundation; either version 2 of the License, or | ||
14 | (at your option) any later version. | ||
15 | |||
16 | This program is distributed in the hope that it will be useful, | ||
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | GNU General Public License for more details. | ||
20 | |||
21 | You should have received a copy of the GNU General Public License | ||
22 | along with this program; if not, write to the Free Software | ||
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | |||
25 | */ | ||
26 | |||
27 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
28 | |||
29 | #include <linux/module.h> | ||
30 | #include <linux/init.h> | ||
31 | #include <linux/slab.h> | ||
32 | #include <linux/pci.h> | ||
33 | #include <linux/vmalloc.h> | ||
34 | #include <linux/interrupt.h> | ||
35 | #include <asm/page.h> | ||
36 | #include <asm/pgtable.h> | ||
37 | #include <media/v4l2-ioctl.h> | ||
38 | |||
39 | #include "bttvp.h" | ||
40 | |||
41 | #define VCR_HACK_LINES 4 | ||
42 | |||
43 | /* ---------------------------------------------------------- */ | ||
44 | /* risc code generators */ | ||
45 | |||
46 | int | ||
47 | bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc, | ||
48 | struct scatterlist *sglist, | ||
49 | unsigned int offset, unsigned int bpl, | ||
50 | unsigned int padding, unsigned int skip_lines, | ||
51 | unsigned int store_lines) | ||
52 | { | ||
53 | u32 instructions,line,todo; | ||
54 | struct scatterlist *sg; | ||
55 | __le32 *rp; | ||
56 | int rc; | ||
57 | |||
58 | /* estimate risc mem: worst case is one write per page border + | ||
59 | one write per scan line + sync + jump (all 2 dwords). padding | ||
60 | can cause next bpl to start close to a page border. First DMA | ||
61 | region may be smaller than PAGE_SIZE */ | ||
62 | instructions = skip_lines * 4; | ||
63 | instructions += (1 + ((bpl + padding) * store_lines) | ||
64 | / PAGE_SIZE + store_lines) * 8; | ||
65 | instructions += 2 * 8; | ||
66 | if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions)) < 0) | ||
67 | return rc; | ||
68 | |||
69 | /* sync instruction */ | ||
70 | rp = risc->cpu; | ||
71 | *(rp++) = cpu_to_le32(BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1); | ||
72 | *(rp++) = cpu_to_le32(0); | ||
73 | |||
74 | while (skip_lines-- > 0) { | ||
75 | *(rp++) = cpu_to_le32(BT848_RISC_SKIP | BT848_RISC_SOL | | ||
76 | BT848_RISC_EOL | bpl); | ||
77 | } | ||
78 | |||
79 | /* scan lines */ | ||
80 | sg = sglist; | ||
81 | for (line = 0; line < store_lines; line++) { | ||
82 | if ((btv->opt_vcr_hack) && | ||
83 | (line >= (store_lines - VCR_HACK_LINES))) | ||
84 | continue; | ||
85 | while (offset && offset >= sg_dma_len(sg)) { | ||
86 | offset -= sg_dma_len(sg); | ||
87 | sg++; | ||
88 | } | ||
89 | if (bpl <= sg_dma_len(sg)-offset) { | ||
90 | /* fits into current chunk */ | ||
91 | *(rp++)=cpu_to_le32(BT848_RISC_WRITE|BT848_RISC_SOL| | ||
92 | BT848_RISC_EOL|bpl); | ||
93 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); | ||
94 | offset+=bpl; | ||
95 | } else { | ||
96 | /* scanline needs to be splitted */ | ||
97 | todo = bpl; | ||
98 | *(rp++)=cpu_to_le32(BT848_RISC_WRITE|BT848_RISC_SOL| | ||
99 | (sg_dma_len(sg)-offset)); | ||
100 | *(rp++)=cpu_to_le32(sg_dma_address(sg)+offset); | ||
101 | todo -= (sg_dma_len(sg)-offset); | ||
102 | offset = 0; | ||
103 | sg++; | ||
104 | while (todo > sg_dma_len(sg)) { | ||
105 | *(rp++)=cpu_to_le32(BT848_RISC_WRITE| | ||
106 | sg_dma_len(sg)); | ||
107 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); | ||
108 | todo -= sg_dma_len(sg); | ||
109 | sg++; | ||
110 | } | ||
111 | *(rp++)=cpu_to_le32(BT848_RISC_WRITE|BT848_RISC_EOL| | ||
112 | todo); | ||
113 | *(rp++)=cpu_to_le32(sg_dma_address(sg)); | ||
114 | offset += todo; | ||
115 | } | ||
116 | offset += padding; | ||
117 | } | ||
118 | |||
119 | /* save pointer to jmp instruction address */ | ||
120 | risc->jmp = rp; | ||
121 | BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); | ||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | static int | ||
126 | bttv_risc_planar(struct bttv *btv, struct btcx_riscmem *risc, | ||
127 | struct scatterlist *sglist, | ||
128 | unsigned int yoffset, unsigned int ybpl, | ||
129 | unsigned int ypadding, unsigned int ylines, | ||
130 | unsigned int uoffset, unsigned int voffset, | ||
131 | unsigned int hshift, unsigned int vshift, | ||
132 | unsigned int cpadding) | ||
133 | { | ||
134 | unsigned int instructions,line,todo,ylen,chroma; | ||
135 | __le32 *rp; | ||
136 | u32 ri; | ||
137 | struct scatterlist *ysg; | ||
138 | struct scatterlist *usg; | ||
139 | struct scatterlist *vsg; | ||
140 | int topfield = (0 == yoffset); | ||
141 | int rc; | ||
142 | |||
143 | /* estimate risc mem: worst case is one write per page border + | ||
144 | one write per scan line (5 dwords) | ||
145 | plus sync + jump (2 dwords) */ | ||
146 | instructions = ((3 + (ybpl + ypadding) * ylines * 2) | ||
147 | / PAGE_SIZE) + ylines; | ||
148 | instructions += 2; | ||
149 | if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,instructions*4*5)) < 0) | ||
150 | return rc; | ||
151 | |||
152 | /* sync instruction */ | ||
153 | rp = risc->cpu; | ||
154 | *(rp++) = cpu_to_le32(BT848_RISC_SYNC|BT848_FIFO_STATUS_FM3); | ||
155 | *(rp++) = cpu_to_le32(0); | ||
156 | |||
157 | /* scan lines */ | ||
158 | ysg = sglist; | ||
159 | usg = sglist; | ||
160 | vsg = sglist; | ||
161 | for (line = 0; line < ylines; line++) { | ||
162 | if ((btv->opt_vcr_hack) && | ||
163 | (line >= (ylines - VCR_HACK_LINES))) | ||
164 | continue; | ||
165 | switch (vshift) { | ||
166 | case 0: | ||
167 | chroma = 1; | ||
168 | break; | ||
169 | case 1: | ||
170 | if (topfield) | ||
171 | chroma = ((line & 1) == 0); | ||
172 | else | ||
173 | chroma = ((line & 1) == 1); | ||
174 | break; | ||
175 | case 2: | ||
176 | if (topfield) | ||
177 | chroma = ((line & 3) == 0); | ||
178 | else | ||
179 | chroma = ((line & 3) == 2); | ||
180 | break; | ||
181 | default: | ||
182 | chroma = 0; | ||
183 | break; | ||
184 | } | ||
185 | |||
186 | for (todo = ybpl; todo > 0; todo -= ylen) { | ||
187 | /* go to next sg entry if needed */ | ||
188 | while (yoffset && yoffset >= sg_dma_len(ysg)) { | ||
189 | yoffset -= sg_dma_len(ysg); | ||
190 | ysg++; | ||
191 | } | ||
192 | while (uoffset && uoffset >= sg_dma_len(usg)) { | ||
193 | uoffset -= sg_dma_len(usg); | ||
194 | usg++; | ||
195 | } | ||
196 | while (voffset && voffset >= sg_dma_len(vsg)) { | ||
197 | voffset -= sg_dma_len(vsg); | ||
198 | vsg++; | ||
199 | } | ||
200 | |||
201 | /* calculate max number of bytes we can write */ | ||
202 | ylen = todo; | ||
203 | if (yoffset + ylen > sg_dma_len(ysg)) | ||
204 | ylen = sg_dma_len(ysg) - yoffset; | ||
205 | if (chroma) { | ||
206 | if (uoffset + (ylen>>hshift) > sg_dma_len(usg)) | ||
207 | ylen = (sg_dma_len(usg) - uoffset) << hshift; | ||
208 | if (voffset + (ylen>>hshift) > sg_dma_len(vsg)) | ||
209 | ylen = (sg_dma_len(vsg) - voffset) << hshift; | ||
210 | ri = BT848_RISC_WRITE123; | ||
211 | } else { | ||
212 | ri = BT848_RISC_WRITE1S23; | ||
213 | } | ||
214 | if (ybpl == todo) | ||
215 | ri |= BT848_RISC_SOL; | ||
216 | if (ylen == todo) | ||
217 | ri |= BT848_RISC_EOL; | ||
218 | |||
219 | /* write risc instruction */ | ||
220 | *(rp++)=cpu_to_le32(ri | ylen); | ||
221 | *(rp++)=cpu_to_le32(((ylen >> hshift) << 16) | | ||
222 | (ylen >> hshift)); | ||
223 | *(rp++)=cpu_to_le32(sg_dma_address(ysg)+yoffset); | ||
224 | yoffset += ylen; | ||
225 | if (chroma) { | ||
226 | *(rp++)=cpu_to_le32(sg_dma_address(usg)+uoffset); | ||
227 | uoffset += ylen >> hshift; | ||
228 | *(rp++)=cpu_to_le32(sg_dma_address(vsg)+voffset); | ||
229 | voffset += ylen >> hshift; | ||
230 | } | ||
231 | } | ||
232 | yoffset += ypadding; | ||
233 | if (chroma) { | ||
234 | uoffset += cpadding; | ||
235 | voffset += cpadding; | ||
236 | } | ||
237 | } | ||
238 | |||
239 | /* save pointer to jmp instruction address */ | ||
240 | risc->jmp = rp; | ||
241 | BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); | ||
242 | return 0; | ||
243 | } | ||
244 | |||
245 | static int | ||
246 | bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc, | ||
247 | const struct bttv_format *fmt, struct bttv_overlay *ov, | ||
248 | int skip_even, int skip_odd) | ||
249 | { | ||
250 | int dwords, rc, line, maxy, start, end; | ||
251 | unsigned skip, nskips; | ||
252 | struct btcx_skiplist *skips; | ||
253 | __le32 *rp; | ||
254 | u32 ri,ra; | ||
255 | u32 addr; | ||
256 | |||
257 | /* skip list for window clipping */ | ||
258 | if (NULL == (skips = kmalloc(sizeof(*skips) * ov->nclips,GFP_KERNEL))) | ||
259 | return -ENOMEM; | ||
260 | |||
261 | /* estimate risc mem: worst case is (1.5*clip+1) * lines instructions | ||
262 | + sync + jump (all 2 dwords) */ | ||
263 | dwords = (3 * ov->nclips + 2) * | ||
264 | ((skip_even || skip_odd) ? (ov->w.height+1)>>1 : ov->w.height); | ||
265 | dwords += 4; | ||
266 | if ((rc = btcx_riscmem_alloc(btv->c.pci,risc,dwords*4)) < 0) { | ||
267 | kfree(skips); | ||
268 | return rc; | ||
269 | } | ||
270 | |||
271 | /* sync instruction */ | ||
272 | rp = risc->cpu; | ||
273 | *(rp++) = cpu_to_le32(BT848_RISC_SYNC|BT848_FIFO_STATUS_FM1); | ||
274 | *(rp++) = cpu_to_le32(0); | ||
275 | |||
276 | addr = (unsigned long)btv->fbuf.base; | ||
277 | addr += btv->fbuf.fmt.bytesperline * ov->w.top; | ||
278 | addr += (fmt->depth >> 3) * ov->w.left; | ||
279 | |||
280 | /* scan lines */ | ||
281 | for (maxy = -1, line = 0; line < ov->w.height; | ||
282 | line++, addr += btv->fbuf.fmt.bytesperline) { | ||
283 | if ((btv->opt_vcr_hack) && | ||
284 | (line >= (ov->w.height - VCR_HACK_LINES))) | ||
285 | continue; | ||
286 | if ((line%2) == 0 && skip_even) | ||
287 | continue; | ||
288 | if ((line%2) == 1 && skip_odd) | ||
289 | continue; | ||
290 | |||
291 | /* calculate clipping */ | ||
292 | if (line > maxy) | ||
293 | btcx_calc_skips(line, ov->w.width, &maxy, | ||
294 | skips, &nskips, ov->clips, ov->nclips); | ||
295 | |||
296 | /* write out risc code */ | ||
297 | for (start = 0, skip = 0; start < ov->w.width; start = end) { | ||
298 | if (skip >= nskips) { | ||
299 | ri = BT848_RISC_WRITE; | ||
300 | end = ov->w.width; | ||
301 | } else if (start < skips[skip].start) { | ||
302 | ri = BT848_RISC_WRITE; | ||
303 | end = skips[skip].start; | ||
304 | } else { | ||
305 | ri = BT848_RISC_SKIP; | ||
306 | end = skips[skip].end; | ||
307 | skip++; | ||
308 | } | ||
309 | if (BT848_RISC_WRITE == ri) | ||
310 | ra = addr + (fmt->depth>>3)*start; | ||
311 | else | ||
312 | ra = 0; | ||
313 | |||
314 | if (0 == start) | ||
315 | ri |= BT848_RISC_SOL; | ||
316 | if (ov->w.width == end) | ||
317 | ri |= BT848_RISC_EOL; | ||
318 | ri |= (fmt->depth>>3) * (end-start); | ||
319 | |||
320 | *(rp++)=cpu_to_le32(ri); | ||
321 | if (0 != ra) | ||
322 | *(rp++)=cpu_to_le32(ra); | ||
323 | } | ||
324 | } | ||
325 | |||
326 | /* save pointer to jmp instruction address */ | ||
327 | risc->jmp = rp; | ||
328 | BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size); | ||
329 | kfree(skips); | ||
330 | return 0; | ||
331 | } | ||
332 | |||
333 | /* ---------------------------------------------------------- */ | ||
334 | |||
335 | static void | ||
336 | bttv_calc_geo_old(struct bttv *btv, struct bttv_geometry *geo, | ||
337 | int width, int height, int interleaved, | ||
338 | const struct bttv_tvnorm *tvnorm) | ||
339 | { | ||
340 | u32 xsf, sr; | ||
341 | int vdelay; | ||
342 | |||
343 | int swidth = tvnorm->swidth; | ||
344 | int totalwidth = tvnorm->totalwidth; | ||
345 | int scaledtwidth = tvnorm->scaledtwidth; | ||
346 | |||
347 | if (btv->input == btv->dig) { | ||
348 | swidth = 720; | ||
349 | totalwidth = 858; | ||
350 | scaledtwidth = 858; | ||
351 | } | ||
352 | |||
353 | vdelay = tvnorm->vdelay; | ||
354 | |||
355 | xsf = (width*scaledtwidth)/swidth; | ||
356 | geo->hscale = ((totalwidth*4096UL)/xsf-4096); | ||
357 | geo->hdelay = tvnorm->hdelayx1; | ||
358 | geo->hdelay = (geo->hdelay*width)/swidth; | ||
359 | geo->hdelay &= 0x3fe; | ||
360 | sr = ((tvnorm->sheight >> (interleaved?0:1))*512)/height - 512; | ||
361 | geo->vscale = (0x10000UL-sr) & 0x1fff; | ||
362 | geo->crop = ((width>>8)&0x03) | ((geo->hdelay>>6)&0x0c) | | ||
363 | ((tvnorm->sheight>>4)&0x30) | ((vdelay>>2)&0xc0); | ||
364 | geo->vscale |= interleaved ? (BT848_VSCALE_INT<<8) : 0; | ||
365 | geo->vdelay = vdelay; | ||
366 | geo->width = width; | ||
367 | geo->sheight = tvnorm->sheight; | ||
368 | geo->vtotal = tvnorm->vtotal; | ||
369 | |||
370 | if (btv->opt_combfilter) { | ||
371 | geo->vtc = (width < 193) ? 2 : ((width < 385) ? 1 : 0); | ||
372 | geo->comb = (width < 769) ? 1 : 0; | ||
373 | } else { | ||
374 | geo->vtc = 0; | ||
375 | geo->comb = 0; | ||
376 | } | ||
377 | } | ||
378 | |||
379 | static void | ||
380 | bttv_calc_geo (struct bttv * btv, | ||
381 | struct bttv_geometry * geo, | ||
382 | unsigned int width, | ||
383 | unsigned int height, | ||
384 | int both_fields, | ||
385 | const struct bttv_tvnorm * tvnorm, | ||
386 | const struct v4l2_rect * crop) | ||
387 | { | ||
388 | unsigned int c_width; | ||
389 | unsigned int c_height; | ||
390 | u32 sr; | ||
391 | |||
392 | if ((crop->left == tvnorm->cropcap.defrect.left | ||
393 | && crop->top == tvnorm->cropcap.defrect.top | ||
394 | && crop->width == tvnorm->cropcap.defrect.width | ||
395 | && crop->height == tvnorm->cropcap.defrect.height | ||
396 | && width <= tvnorm->swidth /* see PAL-Nc et al */) | ||
397 | || btv->input == btv->dig) { | ||
398 | bttv_calc_geo_old(btv, geo, width, height, | ||
399 | both_fields, tvnorm); | ||
400 | return; | ||
401 | } | ||
402 | |||
403 | /* For bug compatibility the image size checks permit scale | ||
404 | factors > 16. See bttv_crop_calc_limits(). */ | ||
405 | c_width = min((unsigned int) crop->width, width * 16); | ||
406 | c_height = min((unsigned int) crop->height, height * 16); | ||
407 | |||
408 | geo->width = width; | ||
409 | geo->hscale = (c_width * 4096U + (width >> 1)) / width - 4096; | ||
410 | /* Even to store Cb first, odd for Cr. */ | ||
411 | geo->hdelay = ((crop->left * width + c_width) / c_width) & ~1; | ||
412 | |||
413 | geo->sheight = c_height; | ||
414 | geo->vdelay = crop->top - tvnorm->cropcap.bounds.top + MIN_VDELAY; | ||
415 | sr = c_height >> !both_fields; | ||
416 | sr = (sr * 512U + (height >> 1)) / height - 512; | ||
417 | geo->vscale = (0x10000UL - sr) & 0x1fff; | ||
418 | geo->vscale |= both_fields ? (BT848_VSCALE_INT << 8) : 0; | ||
419 | geo->vtotal = tvnorm->vtotal; | ||
420 | |||
421 | geo->crop = (((geo->width >> 8) & 0x03) | | ||
422 | ((geo->hdelay >> 6) & 0x0c) | | ||
423 | ((geo->sheight >> 4) & 0x30) | | ||
424 | ((geo->vdelay >> 2) & 0xc0)); | ||
425 | |||
426 | if (btv->opt_combfilter) { | ||
427 | geo->vtc = (width < 193) ? 2 : ((width < 385) ? 1 : 0); | ||
428 | geo->comb = (width < 769) ? 1 : 0; | ||
429 | } else { | ||
430 | geo->vtc = 0; | ||
431 | geo->comb = 0; | ||
432 | } | ||
433 | } | ||
434 | |||
435 | static void | ||
436 | bttv_apply_geo(struct bttv *btv, struct bttv_geometry *geo, int odd) | ||
437 | { | ||
438 | int off = odd ? 0x80 : 0x00; | ||
439 | |||
440 | if (geo->comb) | ||
441 | btor(BT848_VSCALE_COMB, BT848_E_VSCALE_HI+off); | ||
442 | else | ||
443 | btand(~BT848_VSCALE_COMB, BT848_E_VSCALE_HI+off); | ||
444 | |||
445 | btwrite(geo->vtc, BT848_E_VTC+off); | ||
446 | btwrite(geo->hscale >> 8, BT848_E_HSCALE_HI+off); | ||
447 | btwrite(geo->hscale & 0xff, BT848_E_HSCALE_LO+off); | ||
448 | btaor((geo->vscale>>8), 0xe0, BT848_E_VSCALE_HI+off); | ||
449 | btwrite(geo->vscale & 0xff, BT848_E_VSCALE_LO+off); | ||
450 | btwrite(geo->width & 0xff, BT848_E_HACTIVE_LO+off); | ||
451 | btwrite(geo->hdelay & 0xff, BT848_E_HDELAY_LO+off); | ||
452 | btwrite(geo->sheight & 0xff, BT848_E_VACTIVE_LO+off); | ||
453 | btwrite(geo->vdelay & 0xff, BT848_E_VDELAY_LO+off); | ||
454 | btwrite(geo->crop, BT848_E_CROP+off); | ||
455 | btwrite(geo->vtotal>>8, BT848_VTOTAL_HI); | ||
456 | btwrite(geo->vtotal & 0xff, BT848_VTOTAL_LO); | ||
457 | } | ||
458 | |||
459 | /* ---------------------------------------------------------- */ | ||
460 | /* risc group / risc main loop / dma management */ | ||
461 | |||
462 | void | ||
463 | bttv_set_dma(struct bttv *btv, int override) | ||
464 | { | ||
465 | unsigned long cmd; | ||
466 | int capctl; | ||
467 | |||
468 | btv->cap_ctl = 0; | ||
469 | if (NULL != btv->curr.top) btv->cap_ctl |= 0x02; | ||
470 | if (NULL != btv->curr.bottom) btv->cap_ctl |= 0x01; | ||
471 | if (NULL != btv->cvbi) btv->cap_ctl |= 0x0c; | ||
472 | |||
473 | capctl = 0; | ||
474 | capctl |= (btv->cap_ctl & 0x03) ? 0x03 : 0x00; /* capture */ | ||
475 | capctl |= (btv->cap_ctl & 0x0c) ? 0x0c : 0x00; /* vbi data */ | ||
476 | capctl |= override; | ||
477 | |||
478 | d2printk("%d: capctl=%x lirq=%d top=%08llx/%08llx even=%08llx/%08llx\n", | ||
479 | btv->c.nr,capctl,btv->loop_irq, | ||
480 | btv->cvbi ? (unsigned long long)btv->cvbi->top.dma : 0, | ||
481 | btv->curr.top ? (unsigned long long)btv->curr.top->top.dma : 0, | ||
482 | btv->cvbi ? (unsigned long long)btv->cvbi->bottom.dma : 0, | ||
483 | btv->curr.bottom ? (unsigned long long)btv->curr.bottom->bottom.dma : 0); | ||
484 | |||
485 | cmd = BT848_RISC_JUMP; | ||
486 | if (btv->loop_irq) { | ||
487 | cmd |= BT848_RISC_IRQ; | ||
488 | cmd |= (btv->loop_irq & 0x0f) << 16; | ||
489 | cmd |= (~btv->loop_irq & 0x0f) << 20; | ||
490 | } | ||
491 | if (btv->curr.frame_irq || btv->loop_irq || btv->cvbi) { | ||
492 | mod_timer(&btv->timeout, jiffies+BTTV_TIMEOUT); | ||
493 | } else { | ||
494 | del_timer(&btv->timeout); | ||
495 | } | ||
496 | btv->main.cpu[RISC_SLOT_LOOP] = cpu_to_le32(cmd); | ||
497 | |||
498 | btaor(capctl, ~0x0f, BT848_CAP_CTL); | ||
499 | if (capctl) { | ||
500 | if (btv->dma_on) | ||
501 | return; | ||
502 | btwrite(btv->main.dma, BT848_RISC_STRT_ADD); | ||
503 | btor(3, BT848_GPIO_DMA_CTL); | ||
504 | btv->dma_on = 1; | ||
505 | } else { | ||
506 | if (!btv->dma_on) | ||
507 | return; | ||
508 | btand(~3, BT848_GPIO_DMA_CTL); | ||
509 | btv->dma_on = 0; | ||
510 | } | ||
511 | return; | ||
512 | } | ||
513 | |||
514 | int | ||
515 | bttv_risc_init_main(struct bttv *btv) | ||
516 | { | ||
517 | int rc; | ||
518 | |||
519 | if ((rc = btcx_riscmem_alloc(btv->c.pci,&btv->main,PAGE_SIZE)) < 0) | ||
520 | return rc; | ||
521 | dprintk("%d: risc main @ %08llx\n", | ||
522 | btv->c.nr, (unsigned long long)btv->main.dma); | ||
523 | |||
524 | btv->main.cpu[0] = cpu_to_le32(BT848_RISC_SYNC | BT848_RISC_RESYNC | | ||
525 | BT848_FIFO_STATUS_VRE); | ||
526 | btv->main.cpu[1] = cpu_to_le32(0); | ||
527 | btv->main.cpu[2] = cpu_to_le32(BT848_RISC_JUMP); | ||
528 | btv->main.cpu[3] = cpu_to_le32(btv->main.dma + (4<<2)); | ||
529 | |||
530 | /* top field */ | ||
531 | btv->main.cpu[4] = cpu_to_le32(BT848_RISC_JUMP); | ||
532 | btv->main.cpu[5] = cpu_to_le32(btv->main.dma + (6<<2)); | ||
533 | btv->main.cpu[6] = cpu_to_le32(BT848_RISC_JUMP); | ||
534 | btv->main.cpu[7] = cpu_to_le32(btv->main.dma + (8<<2)); | ||
535 | |||
536 | btv->main.cpu[8] = cpu_to_le32(BT848_RISC_SYNC | BT848_RISC_RESYNC | | ||
537 | BT848_FIFO_STATUS_VRO); | ||
538 | btv->main.cpu[9] = cpu_to_le32(0); | ||
539 | |||
540 | /* bottom field */ | ||
541 | btv->main.cpu[10] = cpu_to_le32(BT848_RISC_JUMP); | ||
542 | btv->main.cpu[11] = cpu_to_le32(btv->main.dma + (12<<2)); | ||
543 | btv->main.cpu[12] = cpu_to_le32(BT848_RISC_JUMP); | ||
544 | btv->main.cpu[13] = cpu_to_le32(btv->main.dma + (14<<2)); | ||
545 | |||
546 | /* jump back to top field */ | ||
547 | btv->main.cpu[14] = cpu_to_le32(BT848_RISC_JUMP); | ||
548 | btv->main.cpu[15] = cpu_to_le32(btv->main.dma + (0<<2)); | ||
549 | |||
550 | return 0; | ||
551 | } | ||
552 | |||
553 | int | ||
554 | bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc, | ||
555 | int irqflags) | ||
556 | { | ||
557 | unsigned long cmd; | ||
558 | unsigned long next = btv->main.dma + ((slot+2) << 2); | ||
559 | |||
560 | if (NULL == risc) { | ||
561 | d2printk("%d: risc=%p slot[%d]=NULL\n", btv->c.nr, risc, slot); | ||
562 | btv->main.cpu[slot+1] = cpu_to_le32(next); | ||
563 | } else { | ||
564 | d2printk("%d: risc=%p slot[%d]=%08llx irq=%d\n", | ||
565 | btv->c.nr, risc, slot, | ||
566 | (unsigned long long)risc->dma, irqflags); | ||
567 | cmd = BT848_RISC_JUMP; | ||
568 | if (irqflags) { | ||
569 | cmd |= BT848_RISC_IRQ; | ||
570 | cmd |= (irqflags & 0x0f) << 16; | ||
571 | cmd |= (~irqflags & 0x0f) << 20; | ||
572 | } | ||
573 | risc->jmp[0] = cpu_to_le32(cmd); | ||
574 | risc->jmp[1] = cpu_to_le32(next); | ||
575 | btv->main.cpu[slot+1] = cpu_to_le32(risc->dma); | ||
576 | } | ||
577 | return 0; | ||
578 | } | ||
579 | |||
580 | void | ||
581 | bttv_dma_free(struct videobuf_queue *q,struct bttv *btv, struct bttv_buffer *buf) | ||
582 | { | ||
583 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); | ||
584 | |||
585 | BUG_ON(in_interrupt()); | ||
586 | videobuf_waiton(q, &buf->vb, 0, 0); | ||
587 | videobuf_dma_unmap(q->dev, dma); | ||
588 | videobuf_dma_free(dma); | ||
589 | btcx_riscmem_free(btv->c.pci,&buf->bottom); | ||
590 | btcx_riscmem_free(btv->c.pci,&buf->top); | ||
591 | buf->vb.state = VIDEOBUF_NEEDS_INIT; | ||
592 | } | ||
593 | |||
594 | int | ||
595 | bttv_buffer_activate_vbi(struct bttv *btv, | ||
596 | struct bttv_buffer *vbi) | ||
597 | { | ||
598 | struct btcx_riscmem *top; | ||
599 | struct btcx_riscmem *bottom; | ||
600 | int top_irq_flags; | ||
601 | int bottom_irq_flags; | ||
602 | |||
603 | top = NULL; | ||
604 | bottom = NULL; | ||
605 | top_irq_flags = 0; | ||
606 | bottom_irq_flags = 0; | ||
607 | |||
608 | if (vbi) { | ||
609 | unsigned int crop, vdelay; | ||
610 | |||
611 | vbi->vb.state = VIDEOBUF_ACTIVE; | ||
612 | list_del(&vbi->vb.queue); | ||
613 | |||
614 | /* VDELAY is start of video, end of VBI capturing. */ | ||
615 | crop = btread(BT848_E_CROP); | ||
616 | vdelay = btread(BT848_E_VDELAY_LO) + ((crop & 0xc0) << 2); | ||
617 | |||
618 | if (vbi->geo.vdelay > vdelay) { | ||
619 | vdelay = vbi->geo.vdelay & 0xfe; | ||
620 | crop = (crop & 0x3f) | ((vbi->geo.vdelay >> 2) & 0xc0); | ||
621 | |||
622 | btwrite(vdelay, BT848_E_VDELAY_LO); | ||
623 | btwrite(crop, BT848_E_CROP); | ||
624 | btwrite(vdelay, BT848_O_VDELAY_LO); | ||
625 | btwrite(crop, BT848_O_CROP); | ||
626 | } | ||
627 | |||
628 | if (vbi->vbi_count[0] > 0) { | ||
629 | top = &vbi->top; | ||
630 | top_irq_flags = 4; | ||
631 | } | ||
632 | |||
633 | if (vbi->vbi_count[1] > 0) { | ||
634 | top_irq_flags = 0; | ||
635 | bottom = &vbi->bottom; | ||
636 | bottom_irq_flags = 4; | ||
637 | } | ||
638 | } | ||
639 | |||
640 | bttv_risc_hook(btv, RISC_SLOT_O_VBI, top, top_irq_flags); | ||
641 | bttv_risc_hook(btv, RISC_SLOT_E_VBI, bottom, bottom_irq_flags); | ||
642 | |||
643 | return 0; | ||
644 | } | ||
645 | |||
646 | int | ||
647 | bttv_buffer_activate_video(struct bttv *btv, | ||
648 | struct bttv_buffer_set *set) | ||
649 | { | ||
650 | /* video capture */ | ||
651 | if (NULL != set->top && NULL != set->bottom) { | ||
652 | if (set->top == set->bottom) { | ||
653 | set->top->vb.state = VIDEOBUF_ACTIVE; | ||
654 | if (set->top->vb.queue.next) | ||
655 | list_del(&set->top->vb.queue); | ||
656 | } else { | ||
657 | set->top->vb.state = VIDEOBUF_ACTIVE; | ||
658 | set->bottom->vb.state = VIDEOBUF_ACTIVE; | ||
659 | if (set->top->vb.queue.next) | ||
660 | list_del(&set->top->vb.queue); | ||
661 | if (set->bottom->vb.queue.next) | ||
662 | list_del(&set->bottom->vb.queue); | ||
663 | } | ||
664 | bttv_apply_geo(btv, &set->top->geo, 1); | ||
665 | bttv_apply_geo(btv, &set->bottom->geo,0); | ||
666 | bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top, | ||
667 | set->top_irq); | ||
668 | bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom, | ||
669 | set->frame_irq); | ||
670 | btaor((set->top->btformat & 0xf0) | (set->bottom->btformat & 0x0f), | ||
671 | ~0xff, BT848_COLOR_FMT); | ||
672 | btaor((set->top->btswap & 0x0a) | (set->bottom->btswap & 0x05), | ||
673 | ~0x0f, BT848_COLOR_CTL); | ||
674 | } else if (NULL != set->top) { | ||
675 | set->top->vb.state = VIDEOBUF_ACTIVE; | ||
676 | if (set->top->vb.queue.next) | ||
677 | list_del(&set->top->vb.queue); | ||
678 | bttv_apply_geo(btv, &set->top->geo,1); | ||
679 | bttv_apply_geo(btv, &set->top->geo,0); | ||
680 | bttv_risc_hook(btv, RISC_SLOT_O_FIELD, &set->top->top, | ||
681 | set->frame_irq); | ||
682 | bttv_risc_hook(btv, RISC_SLOT_E_FIELD, NULL, 0); | ||
683 | btaor(set->top->btformat & 0xff, ~0xff, BT848_COLOR_FMT); | ||
684 | btaor(set->top->btswap & 0x0f, ~0x0f, BT848_COLOR_CTL); | ||
685 | } else if (NULL != set->bottom) { | ||
686 | set->bottom->vb.state = VIDEOBUF_ACTIVE; | ||
687 | if (set->bottom->vb.queue.next) | ||
688 | list_del(&set->bottom->vb.queue); | ||
689 | bttv_apply_geo(btv, &set->bottom->geo,1); | ||
690 | bttv_apply_geo(btv, &set->bottom->geo,0); | ||
691 | bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0); | ||
692 | bttv_risc_hook(btv, RISC_SLOT_E_FIELD, &set->bottom->bottom, | ||
693 | set->frame_irq); | ||
694 | btaor(set->bottom->btformat & 0xff, ~0xff, BT848_COLOR_FMT); | ||
695 | btaor(set->bottom->btswap & 0x0f, ~0x0f, BT848_COLOR_CTL); | ||
696 | } else { | ||
697 | bttv_risc_hook(btv, RISC_SLOT_O_FIELD, NULL, 0); | ||
698 | bttv_risc_hook(btv, RISC_SLOT_E_FIELD, NULL, 0); | ||
699 | } | ||
700 | return 0; | ||
701 | } | ||
702 | |||
703 | /* ---------------------------------------------------------- */ | ||
704 | |||
705 | /* calculate geometry, build risc code */ | ||
706 | int | ||
707 | bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf) | ||
708 | { | ||
709 | const struct bttv_tvnorm *tvnorm = bttv_tvnorms + buf->tvnorm; | ||
710 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); | ||
711 | |||
712 | dprintk("%d: buffer field: %s format: %s size: %dx%d\n", | ||
713 | btv->c.nr, v4l2_field_names[buf->vb.field], | ||
714 | buf->fmt->name, buf->vb.width, buf->vb.height); | ||
715 | |||
716 | /* packed pixel modes */ | ||
717 | if (buf->fmt->flags & FORMAT_FLAGS_PACKED) { | ||
718 | int bpl = (buf->fmt->depth >> 3) * buf->vb.width; | ||
719 | int bpf = bpl * (buf->vb.height >> 1); | ||
720 | |||
721 | bttv_calc_geo(btv,&buf->geo,buf->vb.width,buf->vb.height, | ||
722 | V4L2_FIELD_HAS_BOTH(buf->vb.field), | ||
723 | tvnorm,&buf->crop); | ||
724 | |||
725 | switch (buf->vb.field) { | ||
726 | case V4L2_FIELD_TOP: | ||
727 | bttv_risc_packed(btv,&buf->top,dma->sglist, | ||
728 | /* offset */ 0,bpl, | ||
729 | /* padding */ 0,/* skip_lines */ 0, | ||
730 | buf->vb.height); | ||
731 | break; | ||
732 | case V4L2_FIELD_BOTTOM: | ||
733 | bttv_risc_packed(btv,&buf->bottom,dma->sglist, | ||
734 | 0,bpl,0,0,buf->vb.height); | ||
735 | break; | ||
736 | case V4L2_FIELD_INTERLACED: | ||
737 | bttv_risc_packed(btv,&buf->top,dma->sglist, | ||
738 | 0,bpl,bpl,0,buf->vb.height >> 1); | ||
739 | bttv_risc_packed(btv,&buf->bottom,dma->sglist, | ||
740 | bpl,bpl,bpl,0,buf->vb.height >> 1); | ||
741 | break; | ||
742 | case V4L2_FIELD_SEQ_TB: | ||
743 | bttv_risc_packed(btv,&buf->top,dma->sglist, | ||
744 | 0,bpl,0,0,buf->vb.height >> 1); | ||
745 | bttv_risc_packed(btv,&buf->bottom,dma->sglist, | ||
746 | bpf,bpl,0,0,buf->vb.height >> 1); | ||
747 | break; | ||
748 | default: | ||
749 | BUG(); | ||
750 | } | ||
751 | } | ||
752 | |||
753 | /* planar modes */ | ||
754 | if (buf->fmt->flags & FORMAT_FLAGS_PLANAR) { | ||
755 | int uoffset, voffset; | ||
756 | int ypadding, cpadding, lines; | ||
757 | |||
758 | /* calculate chroma offsets */ | ||
759 | uoffset = buf->vb.width * buf->vb.height; | ||
760 | voffset = buf->vb.width * buf->vb.height; | ||
761 | if (buf->fmt->flags & FORMAT_FLAGS_CrCb) { | ||
762 | /* Y-Cr-Cb plane order */ | ||
763 | uoffset >>= buf->fmt->hshift; | ||
764 | uoffset >>= buf->fmt->vshift; | ||
765 | uoffset += voffset; | ||
766 | } else { | ||
767 | /* Y-Cb-Cr plane order */ | ||
768 | voffset >>= buf->fmt->hshift; | ||
769 | voffset >>= buf->fmt->vshift; | ||
770 | voffset += uoffset; | ||
771 | } | ||
772 | |||
773 | switch (buf->vb.field) { | ||
774 | case V4L2_FIELD_TOP: | ||
775 | bttv_calc_geo(btv,&buf->geo,buf->vb.width, | ||
776 | buf->vb.height,/* both_fields */ 0, | ||
777 | tvnorm,&buf->crop); | ||
778 | bttv_risc_planar(btv, &buf->top, dma->sglist, | ||
779 | 0,buf->vb.width,0,buf->vb.height, | ||
780 | uoffset,voffset,buf->fmt->hshift, | ||
781 | buf->fmt->vshift,0); | ||
782 | break; | ||
783 | case V4L2_FIELD_BOTTOM: | ||
784 | bttv_calc_geo(btv,&buf->geo,buf->vb.width, | ||
785 | buf->vb.height,0, | ||
786 | tvnorm,&buf->crop); | ||
787 | bttv_risc_planar(btv, &buf->bottom, dma->sglist, | ||
788 | 0,buf->vb.width,0,buf->vb.height, | ||
789 | uoffset,voffset,buf->fmt->hshift, | ||
790 | buf->fmt->vshift,0); | ||
791 | break; | ||
792 | case V4L2_FIELD_INTERLACED: | ||
793 | bttv_calc_geo(btv,&buf->geo,buf->vb.width, | ||
794 | buf->vb.height,1, | ||
795 | tvnorm,&buf->crop); | ||
796 | lines = buf->vb.height >> 1; | ||
797 | ypadding = buf->vb.width; | ||
798 | cpadding = buf->vb.width >> buf->fmt->hshift; | ||
799 | bttv_risc_planar(btv,&buf->top, | ||
800 | dma->sglist, | ||
801 | 0,buf->vb.width,ypadding,lines, | ||
802 | uoffset,voffset, | ||
803 | buf->fmt->hshift, | ||
804 | buf->fmt->vshift, | ||
805 | cpadding); | ||
806 | bttv_risc_planar(btv,&buf->bottom, | ||
807 | dma->sglist, | ||
808 | ypadding,buf->vb.width,ypadding,lines, | ||
809 | uoffset+cpadding, | ||
810 | voffset+cpadding, | ||
811 | buf->fmt->hshift, | ||
812 | buf->fmt->vshift, | ||
813 | cpadding); | ||
814 | break; | ||
815 | case V4L2_FIELD_SEQ_TB: | ||
816 | bttv_calc_geo(btv,&buf->geo,buf->vb.width, | ||
817 | buf->vb.height,1, | ||
818 | tvnorm,&buf->crop); | ||
819 | lines = buf->vb.height >> 1; | ||
820 | ypadding = buf->vb.width; | ||
821 | cpadding = buf->vb.width >> buf->fmt->hshift; | ||
822 | bttv_risc_planar(btv,&buf->top, | ||
823 | dma->sglist, | ||
824 | 0,buf->vb.width,0,lines, | ||
825 | uoffset >> 1, | ||
826 | voffset >> 1, | ||
827 | buf->fmt->hshift, | ||
828 | buf->fmt->vshift, | ||
829 | 0); | ||
830 | bttv_risc_planar(btv,&buf->bottom, | ||
831 | dma->sglist, | ||
832 | lines * ypadding,buf->vb.width,0,lines, | ||
833 | lines * ypadding + (uoffset >> 1), | ||
834 | lines * ypadding + (voffset >> 1), | ||
835 | buf->fmt->hshift, | ||
836 | buf->fmt->vshift, | ||
837 | 0); | ||
838 | break; | ||
839 | default: | ||
840 | BUG(); | ||
841 | } | ||
842 | } | ||
843 | |||
844 | /* raw data */ | ||
845 | if (buf->fmt->flags & FORMAT_FLAGS_RAW) { | ||
846 | /* build risc code */ | ||
847 | buf->vb.field = V4L2_FIELD_SEQ_TB; | ||
848 | bttv_calc_geo(btv,&buf->geo,tvnorm->swidth,tvnorm->sheight, | ||
849 | 1,tvnorm,&buf->crop); | ||
850 | bttv_risc_packed(btv, &buf->top, dma->sglist, | ||
851 | /* offset */ 0, RAW_BPL, /* padding */ 0, | ||
852 | /* skip_lines */ 0, RAW_LINES); | ||
853 | bttv_risc_packed(btv, &buf->bottom, dma->sglist, | ||
854 | buf->vb.size/2 , RAW_BPL, 0, 0, RAW_LINES); | ||
855 | } | ||
856 | |||
857 | /* copy format info */ | ||
858 | buf->btformat = buf->fmt->btformat; | ||
859 | buf->btswap = buf->fmt->btswap; | ||
860 | return 0; | ||
861 | } | ||
862 | |||
863 | /* ---------------------------------------------------------- */ | ||
864 | |||
865 | /* calculate geometry, build risc code */ | ||
866 | int | ||
867 | bttv_overlay_risc(struct bttv *btv, | ||
868 | struct bttv_overlay *ov, | ||
869 | const struct bttv_format *fmt, | ||
870 | struct bttv_buffer *buf) | ||
871 | { | ||
872 | /* check interleave, bottom+top fields */ | ||
873 | dprintk("%d: overlay fields: %s format: %s size: %dx%d\n", | ||
874 | btv->c.nr, v4l2_field_names[buf->vb.field], | ||
875 | fmt->name, ov->w.width, ov->w.height); | ||
876 | |||
877 | /* calculate geometry */ | ||
878 | bttv_calc_geo(btv,&buf->geo,ov->w.width,ov->w.height, | ||
879 | V4L2_FIELD_HAS_BOTH(ov->field), | ||
880 | &bttv_tvnorms[ov->tvnorm],&buf->crop); | ||
881 | |||
882 | /* build risc code */ | ||
883 | switch (ov->field) { | ||
884 | case V4L2_FIELD_TOP: | ||
885 | bttv_risc_overlay(btv, &buf->top, fmt, ov, 0, 0); | ||
886 | break; | ||
887 | case V4L2_FIELD_BOTTOM: | ||
888 | bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 0, 0); | ||
889 | break; | ||
890 | case V4L2_FIELD_INTERLACED: | ||
891 | bttv_risc_overlay(btv, &buf->top, fmt, ov, 0, 1); | ||
892 | bttv_risc_overlay(btv, &buf->bottom, fmt, ov, 1, 0); | ||
893 | break; | ||
894 | default: | ||
895 | BUG(); | ||
896 | } | ||
897 | |||
898 | /* copy format info */ | ||
899 | buf->btformat = fmt->btformat; | ||
900 | buf->btswap = fmt->btswap; | ||
901 | buf->vb.field = ov->field; | ||
902 | return 0; | ||
903 | } | ||
904 | |||
905 | /* | ||
906 | * Local variables: | ||
907 | * c-basic-offset: 8 | ||
908 | * End: | ||
909 | */ | ||
diff --git a/drivers/media/video/bt8xx/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c deleted file mode 100644 index b433267d9aa9..000000000000 --- a/drivers/media/video/bt8xx/bttv-vbi.c +++ /dev/null | |||
@@ -1,459 +0,0 @@ | |||
1 | /* | ||
2 | |||
3 | bttv - Bt848 frame grabber driver | ||
4 | vbi interface | ||
5 | |||
6 | (c) 2002 Gerd Knorr <kraxel@bytesex.org> | ||
7 | |||
8 | Copyright (C) 2005, 2006 Michael H. Schimek <mschimek@gmx.at> | ||
9 | Sponsored by OPQ Systems AB | ||
10 | |||
11 | This program is free software; you can redistribute it and/or modify | ||
12 | it under the terms of the GNU General Public License as published by | ||
13 | the Free Software Foundation; either version 2 of the License, or | ||
14 | (at your option) any later version. | ||
15 | |||
16 | This program is distributed in the hope that it will be useful, | ||
17 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
19 | GNU General Public License for more details. | ||
20 | |||
21 | You should have received a copy of the GNU General Public License | ||
22 | along with this program; if not, write to the Free Software | ||
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | */ | ||
25 | |||
26 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
27 | |||
28 | #include <linux/module.h> | ||
29 | #include <linux/errno.h> | ||
30 | #include <linux/fs.h> | ||
31 | #include <linux/kernel.h> | ||
32 | #include <linux/interrupt.h> | ||
33 | #include <linux/kdev_t.h> | ||
34 | #include <media/v4l2-ioctl.h> | ||
35 | #include <asm/io.h> | ||
36 | #include "bttvp.h" | ||
37 | |||
38 | /* Offset from line sync pulse leading edge (0H) to start of VBI capture, | ||
39 | in fCLKx2 pixels. According to the datasheet, VBI capture starts | ||
40 | VBI_HDELAY fCLKx1 pixels from the tailing edgeof /HRESET, and /HRESET | ||
41 | is 64 fCLKx1 pixels wide. VBI_HDELAY is set to 0, so this should be | ||
42 | (64 + 0) * 2 = 128 fCLKx2 pixels. But it's not! The datasheet is | ||
43 | Just Plain Wrong. The real value appears to be different for | ||
44 | different revisions of the bt8x8 chips, and to be affected by the | ||
45 | horizontal scaling factor. Experimentally, the value is measured | ||
46 | to be about 244. */ | ||
47 | #define VBI_OFFSET 244 | ||
48 | |||
49 | /* 2048 for compatibility with earlier driver versions. The driver | ||
50 | really stores 1024 + tvnorm->vbipack * 4 samples per line in the | ||
51 | buffer. Note tvnorm->vbipack is <= 0xFF (limit of VBIPACK_LO + HI | ||
52 | is 0x1FF DWORDs) and VBI read()s store a frame counter in the last | ||
53 | four bytes of the VBI image. */ | ||
54 | #define VBI_BPL 2048 | ||
55 | |||
56 | /* Compatibility. */ | ||
57 | #define VBI_DEFLINES 16 | ||
58 | |||
59 | static unsigned int vbibufs = 4; | ||
60 | static unsigned int vbi_debug; | ||
61 | |||
62 | module_param(vbibufs, int, 0444); | ||
63 | module_param(vbi_debug, int, 0644); | ||
64 | MODULE_PARM_DESC(vbibufs,"number of vbi buffers, range 2-32, default 4"); | ||
65 | MODULE_PARM_DESC(vbi_debug,"vbi code debug messages, default is 0 (no)"); | ||
66 | |||
67 | #ifdef dprintk | ||
68 | # undef dprintk | ||
69 | #endif | ||
70 | #define dprintk(fmt, ...) \ | ||
71 | do { \ | ||
72 | if (vbi_debug) \ | ||
73 | pr_debug("%d: " fmt, btv->c.nr, ##__VA_ARGS__); \ | ||
74 | } while (0) | ||
75 | |||
76 | #define IMAGE_SIZE(fmt) \ | ||
77 | (((fmt)->count[0] + (fmt)->count[1]) * (fmt)->samples_per_line) | ||
78 | |||
79 | /* ----------------------------------------------------------------------- */ | ||
80 | /* vbi risc code + mm */ | ||
81 | |||
82 | static int vbi_buffer_setup(struct videobuf_queue *q, | ||
83 | unsigned int *count, unsigned int *size) | ||
84 | { | ||
85 | struct bttv_fh *fh = q->priv_data; | ||
86 | struct bttv *btv = fh->btv; | ||
87 | |||
88 | if (0 == *count) | ||
89 | *count = vbibufs; | ||
90 | |||
91 | *size = IMAGE_SIZE(&fh->vbi_fmt.fmt); | ||
92 | |||
93 | dprintk("setup: samples=%u start=%d,%d count=%u,%u\n", | ||
94 | fh->vbi_fmt.fmt.samples_per_line, | ||
95 | fh->vbi_fmt.fmt.start[0], | ||
96 | fh->vbi_fmt.fmt.start[1], | ||
97 | fh->vbi_fmt.fmt.count[0], | ||
98 | fh->vbi_fmt.fmt.count[1]); | ||
99 | |||
100 | return 0; | ||
101 | } | ||
102 | |||
103 | static int vbi_buffer_prepare(struct videobuf_queue *q, | ||
104 | struct videobuf_buffer *vb, | ||
105 | enum v4l2_field field) | ||
106 | { | ||
107 | struct bttv_fh *fh = q->priv_data; | ||
108 | struct bttv *btv = fh->btv; | ||
109 | struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); | ||
110 | const struct bttv_tvnorm *tvnorm; | ||
111 | unsigned int skip_lines0, skip_lines1, min_vdelay; | ||
112 | int redo_dma_risc; | ||
113 | int rc; | ||
114 | |||
115 | buf->vb.size = IMAGE_SIZE(&fh->vbi_fmt.fmt); | ||
116 | if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size) | ||
117 | return -EINVAL; | ||
118 | |||
119 | tvnorm = fh->vbi_fmt.tvnorm; | ||
120 | |||
121 | /* There's no VBI_VDELAY register, RISC must skip the lines | ||
122 | we don't want. With default parameters we skip zero lines | ||
123 | as earlier driver versions did. The driver permits video | ||
124 | standard changes while capturing, so we use vbi_fmt.tvnorm | ||
125 | instead of btv->tvnorm to skip zero lines after video | ||
126 | standard changes as well. */ | ||
127 | |||
128 | skip_lines0 = 0; | ||
129 | skip_lines1 = 0; | ||
130 | |||
131 | if (fh->vbi_fmt.fmt.count[0] > 0) | ||
132 | skip_lines0 = max(0, (fh->vbi_fmt.fmt.start[0] | ||
133 | - tvnorm->vbistart[0])); | ||
134 | if (fh->vbi_fmt.fmt.count[1] > 0) | ||
135 | skip_lines1 = max(0, (fh->vbi_fmt.fmt.start[1] | ||
136 | - tvnorm->vbistart[1])); | ||
137 | |||
138 | redo_dma_risc = 0; | ||
139 | |||
140 | if (buf->vbi_skip[0] != skip_lines0 || | ||
141 | buf->vbi_skip[1] != skip_lines1 || | ||
142 | buf->vbi_count[0] != fh->vbi_fmt.fmt.count[0] || | ||
143 | buf->vbi_count[1] != fh->vbi_fmt.fmt.count[1]) { | ||
144 | buf->vbi_skip[0] = skip_lines0; | ||
145 | buf->vbi_skip[1] = skip_lines1; | ||
146 | buf->vbi_count[0] = fh->vbi_fmt.fmt.count[0]; | ||
147 | buf->vbi_count[1] = fh->vbi_fmt.fmt.count[1]; | ||
148 | redo_dma_risc = 1; | ||
149 | } | ||
150 | |||
151 | if (VIDEOBUF_NEEDS_INIT == buf->vb.state) { | ||
152 | redo_dma_risc = 1; | ||
153 | if (0 != (rc = videobuf_iolock(q, &buf->vb, NULL))) | ||
154 | goto fail; | ||
155 | } | ||
156 | |||
157 | if (redo_dma_risc) { | ||
158 | unsigned int bpl, padding, offset; | ||
159 | struct videobuf_dmabuf *dma=videobuf_to_dma(&buf->vb); | ||
160 | |||
161 | bpl = 2044; /* max. vbipack */ | ||
162 | padding = VBI_BPL - bpl; | ||
163 | |||
164 | if (fh->vbi_fmt.fmt.count[0] > 0) { | ||
165 | rc = bttv_risc_packed(btv, &buf->top, | ||
166 | dma->sglist, | ||
167 | /* offset */ 0, bpl, | ||
168 | padding, skip_lines0, | ||
169 | fh->vbi_fmt.fmt.count[0]); | ||
170 | if (0 != rc) | ||
171 | goto fail; | ||
172 | } | ||
173 | |||
174 | if (fh->vbi_fmt.fmt.count[1] > 0) { | ||
175 | offset = fh->vbi_fmt.fmt.count[0] * VBI_BPL; | ||
176 | |||
177 | rc = bttv_risc_packed(btv, &buf->bottom, | ||
178 | dma->sglist, | ||
179 | offset, bpl, | ||
180 | padding, skip_lines1, | ||
181 | fh->vbi_fmt.fmt.count[1]); | ||
182 | if (0 != rc) | ||
183 | goto fail; | ||
184 | } | ||
185 | } | ||
186 | |||
187 | /* VBI capturing ends at VDELAY, start of video capturing, | ||
188 | no matter where the RISC program ends. VDELAY minimum is 2, | ||
189 | bounds.top is the corresponding first field line number | ||
190 | times two. VDELAY counts half field lines. */ | ||
191 | min_vdelay = MIN_VDELAY; | ||
192 | if (fh->vbi_fmt.end >= tvnorm->cropcap.bounds.top) | ||
193 | min_vdelay += fh->vbi_fmt.end - tvnorm->cropcap.bounds.top; | ||
194 | |||
195 | /* For bttv_buffer_activate_vbi(). */ | ||
196 | buf->geo.vdelay = min_vdelay; | ||
197 | |||
198 | buf->vb.state = VIDEOBUF_PREPARED; | ||
199 | buf->vb.field = field; | ||
200 | dprintk("buf prepare %p: top=%p bottom=%p field=%s\n", | ||
201 | vb, &buf->top, &buf->bottom, | ||
202 | v4l2_field_names[buf->vb.field]); | ||
203 | return 0; | ||
204 | |||
205 | fail: | ||
206 | bttv_dma_free(q,btv,buf); | ||
207 | return rc; | ||
208 | } | ||
209 | |||
210 | static void | ||
211 | vbi_buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) | ||
212 | { | ||
213 | struct bttv_fh *fh = q->priv_data; | ||
214 | struct bttv *btv = fh->btv; | ||
215 | struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); | ||
216 | |||
217 | dprintk("queue %p\n",vb); | ||
218 | buf->vb.state = VIDEOBUF_QUEUED; | ||
219 | list_add_tail(&buf->vb.queue,&btv->vcapture); | ||
220 | if (NULL == btv->cvbi) { | ||
221 | fh->btv->loop_irq |= 4; | ||
222 | bttv_set_dma(btv,0x0c); | ||
223 | } | ||
224 | } | ||
225 | |||
226 | static void vbi_buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) | ||
227 | { | ||
228 | struct bttv_fh *fh = q->priv_data; | ||
229 | struct bttv *btv = fh->btv; | ||
230 | struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb); | ||
231 | |||
232 | dprintk("free %p\n",vb); | ||
233 | bttv_dma_free(q,fh->btv,buf); | ||
234 | } | ||
235 | |||
236 | struct videobuf_queue_ops bttv_vbi_qops = { | ||
237 | .buf_setup = vbi_buffer_setup, | ||
238 | .buf_prepare = vbi_buffer_prepare, | ||
239 | .buf_queue = vbi_buffer_queue, | ||
240 | .buf_release = vbi_buffer_release, | ||
241 | }; | ||
242 | |||
243 | /* ----------------------------------------------------------------------- */ | ||
244 | |||
245 | static int try_fmt(struct v4l2_vbi_format *f, const struct bttv_tvnorm *tvnorm, | ||
246 | __s32 crop_start) | ||
247 | { | ||
248 | __s32 min_start, max_start, max_end, f2_offset; | ||
249 | unsigned int i; | ||
250 | |||
251 | /* For compatibility with earlier driver versions we must pretend | ||
252 | the VBI and video capture window may overlap. In reality RISC | ||
253 | magic aborts VBI capturing at the first line of video capturing, | ||
254 | leaving the rest of the buffer unchanged, usually all zero. | ||
255 | VBI capturing must always start before video capturing. >> 1 | ||
256 | because cropping counts field lines times two. */ | ||
257 | min_start = tvnorm->vbistart[0]; | ||
258 | max_start = (crop_start >> 1) - 1; | ||
259 | max_end = (tvnorm->cropcap.bounds.top | ||
260 | + tvnorm->cropcap.bounds.height) >> 1; | ||
261 | |||
262 | if (min_start > max_start) | ||
263 | return -EBUSY; | ||
264 | |||
265 | BUG_ON(max_start >= max_end); | ||
266 | |||
267 | f->sampling_rate = tvnorm->Fsc; | ||
268 | f->samples_per_line = VBI_BPL; | ||
269 | f->sample_format = V4L2_PIX_FMT_GREY; | ||
270 | f->offset = VBI_OFFSET; | ||
271 | |||
272 | f2_offset = tvnorm->vbistart[1] - tvnorm->vbistart[0]; | ||
273 | |||
274 | for (i = 0; i < 2; ++i) { | ||
275 | if (0 == f->count[i]) { | ||
276 | /* No data from this field. We leave f->start[i] | ||
277 | alone because VIDIOCSVBIFMT is w/o and EINVALs | ||
278 | when a driver does not support exactly the | ||
279 | requested parameters. */ | ||
280 | } else { | ||
281 | s64 start, count; | ||
282 | |||
283 | start = clamp(f->start[i], min_start, max_start); | ||
284 | /* s64 to prevent overflow. */ | ||
285 | count = (s64) f->start[i] + f->count[i] - start; | ||
286 | f->start[i] = start; | ||
287 | f->count[i] = clamp(count, (s64) 1, | ||
288 | max_end - start); | ||
289 | } | ||
290 | |||
291 | min_start += f2_offset; | ||
292 | max_start += f2_offset; | ||
293 | max_end += f2_offset; | ||
294 | } | ||
295 | |||
296 | if (0 == (f->count[0] | f->count[1])) { | ||
297 | /* As in earlier driver versions. */ | ||
298 | f->start[0] = tvnorm->vbistart[0]; | ||
299 | f->start[1] = tvnorm->vbistart[1]; | ||
300 | f->count[0] = 1; | ||
301 | f->count[1] = 1; | ||
302 | } | ||
303 | |||
304 | f->flags = 0; | ||
305 | |||
306 | f->reserved[0] = 0; | ||
307 | f->reserved[1] = 0; | ||
308 | |||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | int bttv_try_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt) | ||
313 | { | ||
314 | struct bttv_fh *fh = f; | ||
315 | struct bttv *btv = fh->btv; | ||
316 | const struct bttv_tvnorm *tvnorm; | ||
317 | __s32 crop_start; | ||
318 | |||
319 | mutex_lock(&btv->lock); | ||
320 | |||
321 | tvnorm = &bttv_tvnorms[btv->tvnorm]; | ||
322 | crop_start = btv->crop_start; | ||
323 | |||
324 | mutex_unlock(&btv->lock); | ||
325 | |||
326 | return try_fmt(&frt->fmt.vbi, tvnorm, crop_start); | ||
327 | } | ||
328 | |||
329 | |||
330 | int bttv_s_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt) | ||
331 | { | ||
332 | struct bttv_fh *fh = f; | ||
333 | struct bttv *btv = fh->btv; | ||
334 | const struct bttv_tvnorm *tvnorm; | ||
335 | __s32 start1, end; | ||
336 | int rc; | ||
337 | |||
338 | mutex_lock(&btv->lock); | ||
339 | |||
340 | rc = -EBUSY; | ||
341 | if (fh->resources & RESOURCE_VBI) | ||
342 | goto fail; | ||
343 | |||
344 | tvnorm = &bttv_tvnorms[btv->tvnorm]; | ||
345 | |||
346 | rc = try_fmt(&frt->fmt.vbi, tvnorm, btv->crop_start); | ||
347 | if (0 != rc) | ||
348 | goto fail; | ||
349 | |||
350 | start1 = frt->fmt.vbi.start[1] - tvnorm->vbistart[1] + | ||
351 | tvnorm->vbistart[0]; | ||
352 | |||
353 | /* First possible line of video capturing. Should be | ||
354 | max(f->start[0] + f->count[0], start1 + f->count[1]) * 2 | ||
355 | when capturing both fields. But for compatibility we must | ||
356 | pretend the VBI and video capture window may overlap, | ||
357 | so end = start + 1, the lowest possible value, times two | ||
358 | because vbi_fmt.end counts field lines times two. */ | ||
359 | end = max(frt->fmt.vbi.start[0], start1) * 2 + 2; | ||
360 | |||
361 | mutex_lock(&fh->vbi.vb_lock); | ||
362 | |||
363 | fh->vbi_fmt.fmt = frt->fmt.vbi; | ||
364 | fh->vbi_fmt.tvnorm = tvnorm; | ||
365 | fh->vbi_fmt.end = end; | ||
366 | |||
367 | mutex_unlock(&fh->vbi.vb_lock); | ||
368 | |||
369 | rc = 0; | ||
370 | |||
371 | fail: | ||
372 | mutex_unlock(&btv->lock); | ||
373 | |||
374 | return rc; | ||
375 | } | ||
376 | |||
377 | |||
378 | int bttv_g_fmt_vbi_cap(struct file *file, void *f, struct v4l2_format *frt) | ||
379 | { | ||
380 | struct bttv_fh *fh = f; | ||
381 | const struct bttv_tvnorm *tvnorm; | ||
382 | |||
383 | frt->fmt.vbi = fh->vbi_fmt.fmt; | ||
384 | |||
385 | tvnorm = &bttv_tvnorms[fh->btv->tvnorm]; | ||
386 | |||
387 | if (tvnorm != fh->vbi_fmt.tvnorm) { | ||
388 | __s32 max_end; | ||
389 | unsigned int i; | ||
390 | |||
391 | /* As in vbi_buffer_prepare() this imitates the | ||
392 | behaviour of earlier driver versions after video | ||
393 | standard changes, with default parameters anyway. */ | ||
394 | |||
395 | max_end = (tvnorm->cropcap.bounds.top | ||
396 | + tvnorm->cropcap.bounds.height) >> 1; | ||
397 | |||
398 | frt->fmt.vbi.sampling_rate = tvnorm->Fsc; | ||
399 | |||
400 | for (i = 0; i < 2; ++i) { | ||
401 | __s32 new_start; | ||
402 | |||
403 | new_start = frt->fmt.vbi.start[i] | ||
404 | + tvnorm->vbistart[i] | ||
405 | - fh->vbi_fmt.tvnorm->vbistart[i]; | ||
406 | |||
407 | frt->fmt.vbi.start[i] = min(new_start, max_end - 1); | ||
408 | frt->fmt.vbi.count[i] = | ||
409 | min((__s32) frt->fmt.vbi.count[i], | ||
410 | max_end - frt->fmt.vbi.start[i]); | ||
411 | |||
412 | max_end += tvnorm->vbistart[1] | ||
413 | - tvnorm->vbistart[0]; | ||
414 | } | ||
415 | } | ||
416 | return 0; | ||
417 | } | ||
418 | |||
419 | void bttv_vbi_fmt_reset(struct bttv_vbi_fmt *f, unsigned int norm) | ||
420 | { | ||
421 | const struct bttv_tvnorm *tvnorm; | ||
422 | unsigned int real_samples_per_line; | ||
423 | unsigned int real_count; | ||
424 | |||
425 | tvnorm = &bttv_tvnorms[norm]; | ||
426 | |||
427 | f->fmt.sampling_rate = tvnorm->Fsc; | ||
428 | f->fmt.samples_per_line = VBI_BPL; | ||
429 | f->fmt.sample_format = V4L2_PIX_FMT_GREY; | ||
430 | f->fmt.offset = VBI_OFFSET; | ||
431 | f->fmt.start[0] = tvnorm->vbistart[0]; | ||
432 | f->fmt.start[1] = tvnorm->vbistart[1]; | ||
433 | f->fmt.count[0] = VBI_DEFLINES; | ||
434 | f->fmt.count[1] = VBI_DEFLINES; | ||
435 | f->fmt.flags = 0; | ||
436 | f->fmt.reserved[0] = 0; | ||
437 | f->fmt.reserved[1] = 0; | ||
438 | |||
439 | /* For compatibility the buffer size must be 2 * VBI_DEFLINES * | ||
440 | VBI_BPL regardless of the current video standard. */ | ||
441 | real_samples_per_line = 1024 + tvnorm->vbipack * 4; | ||
442 | real_count = ((tvnorm->cropcap.defrect.top >> 1) | ||
443 | - tvnorm->vbistart[0]); | ||
444 | |||
445 | BUG_ON(real_samples_per_line > VBI_BPL); | ||
446 | BUG_ON(real_count > VBI_DEFLINES); | ||
447 | |||
448 | f->tvnorm = tvnorm; | ||
449 | |||
450 | /* See bttv_vbi_fmt_set(). */ | ||
451 | f->end = tvnorm->vbistart[0] * 2 + 2; | ||
452 | } | ||
453 | |||
454 | /* ----------------------------------------------------------------------- */ | ||
455 | /* | ||
456 | * Local variables: | ||
457 | * c-basic-offset: 8 | ||
458 | * End: | ||
459 | */ | ||
diff --git a/drivers/media/video/bt8xx/bttv.h b/drivers/media/video/bt8xx/bttv.h deleted file mode 100644 index 79a11240a590..000000000000 --- a/drivers/media/video/bt8xx/bttv.h +++ /dev/null | |||
@@ -1,376 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * bttv - Bt848 frame grabber driver | ||
4 | * | ||
5 | * card ID's and external interfaces of the bttv driver | ||
6 | * basically stuff needed by other drivers (i2c, lirc, ...) | ||
7 | * and is supported not to change much over time. | ||
8 | * | ||
9 | * Copyright (C) 1996,97 Ralph Metzler (rjkm@thp.uni-koeln.de) | ||
10 | * (c) 1999,2000 Gerd Knorr <kraxel@goldbach.in-berlin.de> | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #ifndef _BTTV_H_ | ||
15 | #define _BTTV_H_ | ||
16 | |||
17 | #include <linux/videodev2.h> | ||
18 | #include <linux/i2c.h> | ||
19 | #include <media/v4l2-device.h> | ||
20 | #include <media/i2c-addr.h> | ||
21 | #include <media/tuner.h> | ||
22 | |||
23 | /* ---------------------------------------------------------- */ | ||
24 | /* exported by bttv-cards.c */ | ||
25 | |||
26 | #define BTTV_BOARD_UNKNOWN 0x00 | ||
27 | #define BTTV_BOARD_MIRO 0x01 | ||
28 | #define BTTV_BOARD_HAUPPAUGE 0x02 | ||
29 | #define BTTV_BOARD_STB 0x03 | ||
30 | #define BTTV_BOARD_INTEL 0x04 | ||
31 | #define BTTV_BOARD_DIAMOND 0x05 | ||
32 | #define BTTV_BOARD_AVERMEDIA 0x06 | ||
33 | #define BTTV_BOARD_MATRIX_VISION 0x07 | ||
34 | #define BTTV_BOARD_FLYVIDEO 0x08 | ||
35 | #define BTTV_BOARD_TURBOTV 0x09 | ||
36 | #define BTTV_BOARD_HAUPPAUGE878 0x0a | ||
37 | #define BTTV_BOARD_MIROPRO 0x0b | ||
38 | #define BTTV_BOARD_ADSTECH_TV 0x0c | ||
39 | #define BTTV_BOARD_AVERMEDIA98 0x0d | ||
40 | #define BTTV_BOARD_VHX 0x0e | ||
41 | #define BTTV_BOARD_ZOLTRIX 0x0f | ||
42 | #define BTTV_BOARD_PIXVIEWPLAYTV 0x10 | ||
43 | #define BTTV_BOARD_WINVIEW_601 0x11 | ||
44 | #define BTTV_BOARD_AVEC_INTERCAP 0x12 | ||
45 | #define BTTV_BOARD_LIFE_FLYKIT 0x13 | ||
46 | #define BTTV_BOARD_CEI_RAFFLES 0x14 | ||
47 | #define BTTV_BOARD_CONFERENCETV 0x15 | ||
48 | #define BTTV_BOARD_PHOEBE_TVMAS 0x16 | ||
49 | #define BTTV_BOARD_MODTEC_205 0x17 | ||
50 | #define BTTV_BOARD_MAGICTVIEW061 0x18 | ||
51 | #define BTTV_BOARD_VOBIS_BOOSTAR 0x19 | ||
52 | #define BTTV_BOARD_HAUPPAUG_WCAM 0x1a | ||
53 | #define BTTV_BOARD_MAXI 0x1b | ||
54 | #define BTTV_BOARD_TERRATV 0x1c | ||
55 | #define BTTV_BOARD_PXC200 0x1d | ||
56 | #define BTTV_BOARD_FLYVIDEO_98 0x1e | ||
57 | #define BTTV_BOARD_IPROTV 0x1f | ||
58 | #define BTTV_BOARD_INTEL_C_S_PCI 0x20 | ||
59 | #define BTTV_BOARD_TERRATVALUE 0x21 | ||
60 | #define BTTV_BOARD_WINFAST2000 0x22 | ||
61 | #define BTTV_BOARD_CHRONOS_VS2 0x23 | ||
62 | #define BTTV_BOARD_TYPHOON_TVIEW 0x24 | ||
63 | #define BTTV_BOARD_PXELVWPLTVPRO 0x25 | ||
64 | #define BTTV_BOARD_MAGICTVIEW063 0x26 | ||
65 | #define BTTV_BOARD_PINNACLE 0x27 | ||
66 | #define BTTV_BOARD_STB2 0x28 | ||
67 | #define BTTV_BOARD_AVPHONE98 0x29 | ||
68 | #define BTTV_BOARD_PV951 0x2a | ||
69 | #define BTTV_BOARD_ONAIR_TV 0x2b | ||
70 | #define BTTV_BOARD_SIGMA_TVII_FM 0x2c | ||
71 | #define BTTV_BOARD_MATRIX_VISION2 0x2d | ||
72 | #define BTTV_BOARD_ZOLTRIX_GENIE 0x2e | ||
73 | #define BTTV_BOARD_TERRATVRADIO 0x2f | ||
74 | #define BTTV_BOARD_DYNALINK 0x30 | ||
75 | #define BTTV_BOARD_GVBCTV3PCI 0x31 | ||
76 | #define BTTV_BOARD_PXELVWPLTVPAK 0x32 | ||
77 | #define BTTV_BOARD_EAGLE 0x33 | ||
78 | #define BTTV_BOARD_PINNACLEPRO 0x34 | ||
79 | #define BTTV_BOARD_TVIEW_RDS_FM 0x35 | ||
80 | #define BTTV_BOARD_LIFETEC_9415 0x36 | ||
81 | #define BTTV_BOARD_BESTBUY_EASYTV 0x37 | ||
82 | #define BTTV_BOARD_FLYVIDEO_98FM 0x38 | ||
83 | #define BTTV_BOARD_GRANDTEC 0x39 | ||
84 | #define BTTV_BOARD_ASKEY_CPH060 0x3a | ||
85 | #define BTTV_BOARD_ASKEY_CPH03X 0x3b | ||
86 | #define BTTV_BOARD_MM100PCTV 0x3c | ||
87 | #define BTTV_BOARD_GMV1 0x3d | ||
88 | #define BTTV_BOARD_BESTBUY_EASYTV2 0x3e | ||
89 | #define BTTV_BOARD_ATI_TVWONDER 0x3f | ||
90 | #define BTTV_BOARD_ATI_TVWONDERVE 0x40 | ||
91 | #define BTTV_BOARD_FLYVIDEO2000 0x41 | ||
92 | #define BTTV_BOARD_TERRATVALUER 0x42 | ||
93 | #define BTTV_BOARD_GVBCTV4PCI 0x43 | ||
94 | #define BTTV_BOARD_VOODOOTV_FM 0x44 | ||
95 | #define BTTV_BOARD_AIMMS 0x45 | ||
96 | #define BTTV_BOARD_PV_BT878P_PLUS 0x46 | ||
97 | #define BTTV_BOARD_FLYVIDEO98EZ 0x47 | ||
98 | #define BTTV_BOARD_PV_BT878P_9B 0x48 | ||
99 | #define BTTV_BOARD_SENSORAY311_611 0x49 | ||
100 | #define BTTV_BOARD_RV605 0x4a | ||
101 | #define BTTV_BOARD_POWERCLR_MTV878 0x4b | ||
102 | #define BTTV_BOARD_WINDVR 0x4c | ||
103 | #define BTTV_BOARD_GRANDTEC_MULTI 0x4d | ||
104 | #define BTTV_BOARD_KWORLD 0x4e | ||
105 | #define BTTV_BOARD_DSP_TCVIDEO 0x4f | ||
106 | #define BTTV_BOARD_HAUPPAUGEPVR 0x50 | ||
107 | #define BTTV_BOARD_GVBCTV5PCI 0x51 | ||
108 | #define BTTV_BOARD_OSPREY1x0 0x52 | ||
109 | #define BTTV_BOARD_OSPREY1x0_848 0x53 | ||
110 | #define BTTV_BOARD_OSPREY101_848 0x54 | ||
111 | #define BTTV_BOARD_OSPREY1x1 0x55 | ||
112 | #define BTTV_BOARD_OSPREY1x1_SVID 0x56 | ||
113 | #define BTTV_BOARD_OSPREY2xx 0x57 | ||
114 | #define BTTV_BOARD_OSPREY2x0_SVID 0x58 | ||
115 | #define BTTV_BOARD_OSPREY2x0 0x59 | ||
116 | #define BTTV_BOARD_OSPREY500 0x5a | ||
117 | #define BTTV_BOARD_OSPREY540 0x5b | ||
118 | #define BTTV_BOARD_OSPREY2000 0x5c | ||
119 | #define BTTV_BOARD_IDS_EAGLE 0x5d | ||
120 | #define BTTV_BOARD_PINNACLESAT 0x5e | ||
121 | #define BTTV_BOARD_FORMAC_PROTV 0x5f | ||
122 | #define BTTV_BOARD_MACHTV 0x60 | ||
123 | #define BTTV_BOARD_EURESYS_PICOLO 0x61 | ||
124 | #define BTTV_BOARD_PV150 0x62 | ||
125 | #define BTTV_BOARD_AD_TVK503 0x63 | ||
126 | #define BTTV_BOARD_HERCULES_SM_TV 0x64 | ||
127 | #define BTTV_BOARD_PACETV 0x65 | ||
128 | #define BTTV_BOARD_IVC200 0x66 | ||
129 | #define BTTV_BOARD_XGUARD 0x67 | ||
130 | #define BTTV_BOARD_NEBULA_DIGITV 0x68 | ||
131 | #define BTTV_BOARD_PV143 0x69 | ||
132 | #define BTTV_BOARD_VD009X1_VD011_MINIDIN 0x6a | ||
133 | #define BTTV_BOARD_VD009X1_VD011_COMBI 0x6b | ||
134 | #define BTTV_BOARD_VD009_MINIDIN 0x6c | ||
135 | #define BTTV_BOARD_VD009_COMBI 0x6d | ||
136 | #define BTTV_BOARD_IVC100 0x6e | ||
137 | #define BTTV_BOARD_IVC120 0x6f | ||
138 | #define BTTV_BOARD_PC_HDTV 0x70 | ||
139 | #define BTTV_BOARD_TWINHAN_DST 0x71 | ||
140 | #define BTTV_BOARD_WINFASTVC100 0x72 | ||
141 | #define BTTV_BOARD_TEV560 0x73 | ||
142 | #define BTTV_BOARD_SIMUS_GVC1100 0x74 | ||
143 | #define BTTV_BOARD_NGSTV_PLUS 0x75 | ||
144 | #define BTTV_BOARD_LMLBT4 0x76 | ||
145 | #define BTTV_BOARD_TEKRAM_M205 0x77 | ||
146 | #define BTTV_BOARD_CONTVFMI 0x78 | ||
147 | #define BTTV_BOARD_PICOLO_TETRA_CHIP 0x79 | ||
148 | #define BTTV_BOARD_SPIRIT_TV 0x7a | ||
149 | #define BTTV_BOARD_AVDVBT_771 0x7b | ||
150 | #define BTTV_BOARD_AVDVBT_761 0x7c | ||
151 | #define BTTV_BOARD_MATRIX_VISIONSQ 0x7d | ||
152 | #define BTTV_BOARD_MATRIX_VISIONSLC 0x7e | ||
153 | #define BTTV_BOARD_APAC_VIEWCOMP 0x7f | ||
154 | #define BTTV_BOARD_DVICO_DVBT_LITE 0x80 | ||
155 | #define BTTV_BOARD_VGEAR_MYVCD 0x81 | ||
156 | #define BTTV_BOARD_SUPER_TV 0x82 | ||
157 | #define BTTV_BOARD_TIBET_CS16 0x83 | ||
158 | #define BTTV_BOARD_KODICOM_4400R 0x84 | ||
159 | #define BTTV_BOARD_KODICOM_4400R_SL 0x85 | ||
160 | #define BTTV_BOARD_ADLINK_RTV24 0x86 | ||
161 | #define BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE 0x87 | ||
162 | #define BTTV_BOARD_ACORP_Y878F 0x88 | ||
163 | #define BTTV_BOARD_CONCEPTRONIC_CTVFMI2 0x89 | ||
164 | #define BTTV_BOARD_PV_BT878P_2E 0x8a | ||
165 | #define BTTV_BOARD_PV_M4900 0x8b | ||
166 | #define BTTV_BOARD_OSPREY440 0x8c | ||
167 | #define BTTV_BOARD_ASOUND_SKYEYE 0x8d | ||
168 | #define BTTV_BOARD_SABRENT_TVFM 0x8e | ||
169 | #define BTTV_BOARD_HAUPPAUGE_IMPACTVCB 0x8f | ||
170 | #define BTTV_BOARD_MACHTV_MAGICTV 0x90 | ||
171 | #define BTTV_BOARD_SSAI_SECURITY 0x91 | ||
172 | #define BTTV_BOARD_SSAI_ULTRASOUND 0x92 | ||
173 | #define BTTV_BOARD_VOODOOTV_200 0x93 | ||
174 | #define BTTV_BOARD_DVICO_FUSIONHDTV_2 0x94 | ||
175 | #define BTTV_BOARD_TYPHOON_TVTUNERPCI 0x95 | ||
176 | #define BTTV_BOARD_GEOVISION_GV600 0x96 | ||
177 | #define BTTV_BOARD_KOZUMI_KTV_01C 0x97 | ||
178 | #define BTTV_BOARD_ENLTV_FM_2 0x98 | ||
179 | #define BTTV_BOARD_VD012 0x99 | ||
180 | #define BTTV_BOARD_VD012_X1 0x9a | ||
181 | #define BTTV_BOARD_VD012_X2 0x9b | ||
182 | #define BTTV_BOARD_IVCE8784 0x9c | ||
183 | #define BTTV_BOARD_GEOVISION_GV800S 0x9d | ||
184 | #define BTTV_BOARD_GEOVISION_GV800S_SL 0x9e | ||
185 | #define BTTV_BOARD_PV183 0x9f | ||
186 | #define BTTV_BOARD_TVT_TD3116 0xa0 | ||
187 | #define BTTV_BOARD_APOSONIC_WDVR 0xa1 | ||
188 | |||
189 | /* more card-specific defines */ | ||
190 | #define PT2254_L_CHANNEL 0x10 | ||
191 | #define PT2254_R_CHANNEL 0x08 | ||
192 | #define PT2254_DBS_IN_2 0x400 | ||
193 | #define PT2254_DBS_IN_10 0x20000 | ||
194 | #define WINVIEW_PT2254_CLK 0x40 | ||
195 | #define WINVIEW_PT2254_DATA 0x20 | ||
196 | #define WINVIEW_PT2254_STROBE 0x80 | ||
197 | |||
198 | struct bttv_core { | ||
199 | /* device structs */ | ||
200 | struct v4l2_device v4l2_dev; | ||
201 | struct pci_dev *pci; | ||
202 | struct i2c_adapter i2c_adap; | ||
203 | struct list_head subs; /* struct bttv_sub_device */ | ||
204 | |||
205 | /* device config */ | ||
206 | unsigned int nr; /* dev nr (for printk("bttv%d: ..."); */ | ||
207 | unsigned int type; /* card type (pointer into tvcards[]) */ | ||
208 | }; | ||
209 | |||
210 | struct bttv; | ||
211 | |||
212 | struct tvcard { | ||
213 | char *name; | ||
214 | void (*volume_gpio)(struct bttv *btv, __u16 volume); | ||
215 | void (*audio_mode_gpio)(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
216 | void (*muxsel_hook)(struct bttv *btv, unsigned int input); | ||
217 | |||
218 | /* MUX bits for each input, two bits per input starting with the LSB */ | ||
219 | u32 muxsel; /* Use MUXSEL() to set */ | ||
220 | |||
221 | u32 gpiomask; | ||
222 | u32 gpiomux[4]; /* Tuner, Radio, external, internal */ | ||
223 | u32 gpiomute; /* GPIO mute setting */ | ||
224 | u32 gpiomask2; /* GPIO MUX mask */ | ||
225 | |||
226 | unsigned int tuner_type; | ||
227 | u8 tuner_addr; | ||
228 | u8 video_inputs; /* Number of inputs */ | ||
229 | unsigned int svhs:4; /* Which input is s-video */ | ||
230 | #define NO_SVHS 15 | ||
231 | unsigned int pll:2; | ||
232 | #define PLL_NONE 0 | ||
233 | #define PLL_28 1 | ||
234 | #define PLL_35 2 | ||
235 | |||
236 | /* i2c audio flags */ | ||
237 | unsigned int no_msp34xx:1; | ||
238 | unsigned int no_tda7432:1; | ||
239 | unsigned int msp34xx_alt:1; | ||
240 | /* Note: currently no card definition needs to mark the presence | ||
241 | of a RDS saa6588 chip. If this is ever needed, then add a new | ||
242 | 'has_saa6588' bit here. */ | ||
243 | |||
244 | unsigned int no_video:1; /* video pci function is unused */ | ||
245 | unsigned int has_dvb:1; | ||
246 | unsigned int has_remote:1; | ||
247 | unsigned int has_radio:1; | ||
248 | unsigned int has_dig_in:1; /* Has digital input (always last input) */ | ||
249 | unsigned int no_gpioirq:1; | ||
250 | }; | ||
251 | |||
252 | extern struct tvcard bttv_tvcards[]; | ||
253 | |||
254 | /* | ||
255 | * This bit of cpp voodoo is used to create a macro with a variable number of | ||
256 | * arguments (1 to 16). It will pack each argument into a word two bits at a | ||
257 | * time. It can't be a function because it needs to be compile time constant to | ||
258 | * initialize structures. Since each argument must fit in two bits, it's ok | ||
259 | * that they are changed to octal. One should not use hex number, macros, or | ||
260 | * anything else with this macro. Just use plain integers from 0 to 3. | ||
261 | */ | ||
262 | #define _MUXSELf(a) 0##a << 30 | ||
263 | #define _MUXSELe(a, b...) 0##a << 28 | _MUXSELf(b) | ||
264 | #define _MUXSELd(a, b...) 0##a << 26 | _MUXSELe(b) | ||
265 | #define _MUXSELc(a, b...) 0##a << 24 | _MUXSELd(b) | ||
266 | #define _MUXSELb(a, b...) 0##a << 22 | _MUXSELc(b) | ||
267 | #define _MUXSELa(a, b...) 0##a << 20 | _MUXSELb(b) | ||
268 | #define _MUXSEL9(a, b...) 0##a << 18 | _MUXSELa(b) | ||
269 | #define _MUXSEL8(a, b...) 0##a << 16 | _MUXSEL9(b) | ||
270 | #define _MUXSEL7(a, b...) 0##a << 14 | _MUXSEL8(b) | ||
271 | #define _MUXSEL6(a, b...) 0##a << 12 | _MUXSEL7(b) | ||
272 | #define _MUXSEL5(a, b...) 0##a << 10 | _MUXSEL6(b) | ||
273 | #define _MUXSEL4(a, b...) 0##a << 8 | _MUXSEL5(b) | ||
274 | #define _MUXSEL3(a, b...) 0##a << 6 | _MUXSEL4(b) | ||
275 | #define _MUXSEL2(a, b...) 0##a << 4 | _MUXSEL3(b) | ||
276 | #define _MUXSEL1(a, b...) 0##a << 2 | _MUXSEL2(b) | ||
277 | #define MUXSEL(a, b...) (a | _MUXSEL1(b)) | ||
278 | |||
279 | /* identification / initialization of the card */ | ||
280 | extern void bttv_idcard(struct bttv *btv); | ||
281 | extern void bttv_init_card1(struct bttv *btv); | ||
282 | extern void bttv_init_card2(struct bttv *btv); | ||
283 | extern void bttv_init_tuner(struct bttv *btv); | ||
284 | |||
285 | /* card-specific funtions */ | ||
286 | extern void tea5757_set_freq(struct bttv *btv, unsigned short freq); | ||
287 | extern u32 bttv_tda9880_setnorm(struct bttv *btv, u32 gpiobits); | ||
288 | |||
289 | /* extra tweaks for some chipsets */ | ||
290 | extern void bttv_check_chipset(void); | ||
291 | extern int bttv_handle_chipset(struct bttv *btv); | ||
292 | |||
293 | /* ---------------------------------------------------------- */ | ||
294 | /* exported by bttv-if.c */ | ||
295 | |||
296 | /* this obsolete -- please use the sysfs-based | ||
297 | interface below for new code */ | ||
298 | |||
299 | extern struct pci_dev* bttv_get_pcidev(unsigned int card); | ||
300 | |||
301 | /* sets GPOE register (BT848_GPIO_OUT_EN) to new value: | ||
302 | data | (current_GPOE_value & ~mask) | ||
303 | returns negative value if error occurred | ||
304 | */ | ||
305 | extern int bttv_gpio_enable(unsigned int card, | ||
306 | unsigned long mask, unsigned long data); | ||
307 | |||
308 | /* fills data with GPDATA register contents | ||
309 | returns negative value if error occurred | ||
310 | */ | ||
311 | extern int bttv_read_gpio(unsigned int card, unsigned long *data); | ||
312 | |||
313 | /* sets GPDATA register to new value: | ||
314 | (data & mask) | (current_GPDATA_value & ~mask) | ||
315 | returns negative value if error occurred | ||
316 | */ | ||
317 | extern int bttv_write_gpio(unsigned int card, | ||
318 | unsigned long mask, unsigned long data); | ||
319 | |||
320 | |||
321 | |||
322 | |||
323 | /* ---------------------------------------------------------- */ | ||
324 | /* sysfs/driver-moded based gpio access interface */ | ||
325 | |||
326 | struct bttv_sub_device { | ||
327 | struct device dev; | ||
328 | struct bttv_core *core; | ||
329 | struct list_head list; | ||
330 | }; | ||
331 | #define to_bttv_sub_dev(x) container_of((x), struct bttv_sub_device, dev) | ||
332 | |||
333 | struct bttv_sub_driver { | ||
334 | struct device_driver drv; | ||
335 | char wanted[20]; | ||
336 | int (*probe)(struct bttv_sub_device *sub); | ||
337 | void (*remove)(struct bttv_sub_device *sub); | ||
338 | }; | ||
339 | #define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv) | ||
340 | |||
341 | int bttv_sub_register(struct bttv_sub_driver *drv, char *wanted); | ||
342 | int bttv_sub_unregister(struct bttv_sub_driver *drv); | ||
343 | |||
344 | /* gpio access functions */ | ||
345 | void bttv_gpio_inout(struct bttv_core *core, u32 mask, u32 outbits); | ||
346 | u32 bttv_gpio_read(struct bttv_core *core); | ||
347 | void bttv_gpio_write(struct bttv_core *core, u32 value); | ||
348 | void bttv_gpio_bits(struct bttv_core *core, u32 mask, u32 bits); | ||
349 | |||
350 | #define gpio_inout(mask,bits) bttv_gpio_inout(&btv->c, mask, bits) | ||
351 | #define gpio_read() bttv_gpio_read(&btv->c) | ||
352 | #define gpio_write(value) bttv_gpio_write(&btv->c, value) | ||
353 | #define gpio_bits(mask,bits) bttv_gpio_bits(&btv->c, mask, bits) | ||
354 | |||
355 | |||
356 | /* ---------------------------------------------------------- */ | ||
357 | /* i2c */ | ||
358 | |||
359 | #define bttv_call_all(btv, o, f, args...) \ | ||
360 | v4l2_device_call_all(&btv->c.v4l2_dev, 0, o, f, ##args) | ||
361 | |||
362 | extern int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for); | ||
363 | extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1, | ||
364 | unsigned char b2, int both); | ||
365 | extern void bttv_readee(struct bttv *btv, unsigned char *eedata, int addr); | ||
366 | |||
367 | extern int bttv_input_init(struct bttv *dev); | ||
368 | extern void bttv_input_fini(struct bttv *dev); | ||
369 | extern void bttv_input_irq(struct bttv *dev); | ||
370 | |||
371 | #endif /* _BTTV_H_ */ | ||
372 | /* | ||
373 | * Local variables: | ||
374 | * c-basic-offset: 8 | ||
375 | * End: | ||
376 | */ | ||
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h deleted file mode 100644 index 70fd4f23f605..000000000000 --- a/drivers/media/video/bt8xx/bttvp.h +++ /dev/null | |||
@@ -1,535 +0,0 @@ | |||
1 | /* | ||
2 | |||
3 | bttv - Bt848 frame grabber driver | ||
4 | |||
5 | bttv's *private* header file -- nobody other than bttv itself | ||
6 | should ever include this file. | ||
7 | |||
8 | (c) 2000-2002 Gerd Knorr <kraxel@bytesex.org> | ||
9 | |||
10 | This program is free software; you can redistribute it and/or modify | ||
11 | it under the terms of the GNU General Public License as published by | ||
12 | the Free Software Foundation; either version 2 of the License, or | ||
13 | (at your option) any later version. | ||
14 | |||
15 | This program is distributed in the hope that it will be useful, | ||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | GNU General Public License for more details. | ||
19 | |||
20 | You should have received a copy of the GNU General Public License | ||
21 | along with this program; if not, write to the Free Software | ||
22 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
23 | */ | ||
24 | |||
25 | #ifndef _BTTVP_H_ | ||
26 | #define _BTTVP_H_ | ||
27 | |||
28 | #include <linux/types.h> | ||
29 | #include <linux/wait.h> | ||
30 | #include <linux/i2c.h> | ||
31 | #include <linux/i2c-algo-bit.h> | ||
32 | #include <linux/pci.h> | ||
33 | #include <linux/input.h> | ||
34 | #include <linux/mutex.h> | ||
35 | #include <linux/scatterlist.h> | ||
36 | #include <asm/io.h> | ||
37 | #include <media/v4l2-common.h> | ||
38 | #include <linux/device.h> | ||
39 | #include <media/videobuf-dma-sg.h> | ||
40 | #include <media/tveeprom.h> | ||
41 | #include <media/rc-core.h> | ||
42 | #include <media/ir-kbd-i2c.h> | ||
43 | |||
44 | #include "bt848.h" | ||
45 | #include "bttv.h" | ||
46 | #include "btcx-risc.h" | ||
47 | |||
48 | #ifdef __KERNEL__ | ||
49 | |||
50 | #define FORMAT_FLAGS_DITHER 0x01 | ||
51 | #define FORMAT_FLAGS_PACKED 0x02 | ||
52 | #define FORMAT_FLAGS_PLANAR 0x04 | ||
53 | #define FORMAT_FLAGS_RAW 0x08 | ||
54 | #define FORMAT_FLAGS_CrCb 0x10 | ||
55 | |||
56 | #define RISC_SLOT_O_VBI 4 | ||
57 | #define RISC_SLOT_O_FIELD 6 | ||
58 | #define RISC_SLOT_E_VBI 10 | ||
59 | #define RISC_SLOT_E_FIELD 12 | ||
60 | #define RISC_SLOT_LOOP 14 | ||
61 | |||
62 | #define RESOURCE_OVERLAY 1 | ||
63 | #define RESOURCE_VIDEO_STREAM 2 | ||
64 | #define RESOURCE_VBI 4 | ||
65 | #define RESOURCE_VIDEO_READ 8 | ||
66 | |||
67 | #define RAW_LINES 640 | ||
68 | #define RAW_BPL 1024 | ||
69 | |||
70 | #define UNSET (-1U) | ||
71 | |||
72 | /* Min. value in VDELAY register. */ | ||
73 | #define MIN_VDELAY 2 | ||
74 | /* Even to get Cb first, odd for Cr. */ | ||
75 | #define MAX_HDELAY (0x3FF & -2) | ||
76 | /* Limits scaled width, which must be a multiple of 4. */ | ||
77 | #define MAX_HACTIVE (0x3FF & -4) | ||
78 | |||
79 | #define BTTV_NORMS (\ | ||
80 | V4L2_STD_PAL | V4L2_STD_PAL_N | \ | ||
81 | V4L2_STD_PAL_Nc | V4L2_STD_SECAM | \ | ||
82 | V4L2_STD_NTSC | V4L2_STD_PAL_M | \ | ||
83 | V4L2_STD_PAL_60) | ||
84 | /* ---------------------------------------------------------- */ | ||
85 | |||
86 | struct bttv_tvnorm { | ||
87 | int v4l2_id; | ||
88 | char *name; | ||
89 | u32 Fsc; | ||
90 | u16 swidth, sheight; /* scaled standard width, height */ | ||
91 | u16 totalwidth; | ||
92 | u8 adelay, bdelay, iform; | ||
93 | u32 scaledtwidth; | ||
94 | u16 hdelayx1, hactivex1; | ||
95 | u16 vdelay; | ||
96 | u8 vbipack; | ||
97 | u16 vtotal; | ||
98 | int sram; | ||
99 | /* ITU-R frame line number of the first VBI line we can | ||
100 | capture, of the first and second field. The last possible line | ||
101 | is determined by cropcap.bounds. */ | ||
102 | u16 vbistart[2]; | ||
103 | /* Horizontally this counts fCLKx1 samples following the leading | ||
104 | edge of the horizontal sync pulse, vertically ITU-R frame line | ||
105 | numbers of the first field times two (2, 4, 6, ... 524 or 624). */ | ||
106 | struct v4l2_cropcap cropcap; | ||
107 | }; | ||
108 | extern const struct bttv_tvnorm bttv_tvnorms[]; | ||
109 | |||
110 | struct bttv_format { | ||
111 | char *name; | ||
112 | int fourcc; /* video4linux 2 */ | ||
113 | int btformat; /* BT848_COLOR_FMT_* */ | ||
114 | int btswap; /* BT848_COLOR_CTL_* */ | ||
115 | int depth; /* bit/pixel */ | ||
116 | int flags; | ||
117 | int hshift,vshift; /* for planar modes */ | ||
118 | }; | ||
119 | |||
120 | struct bttv_ir { | ||
121 | struct rc_dev *dev; | ||
122 | struct timer_list timer; | ||
123 | |||
124 | char name[32]; | ||
125 | char phys[32]; | ||
126 | |||
127 | /* Usual gpio signalling */ | ||
128 | u32 mask_keycode; | ||
129 | u32 mask_keydown; | ||
130 | u32 mask_keyup; | ||
131 | u32 polling; | ||
132 | u32 last_gpio; | ||
133 | int shift_by; | ||
134 | int start; // What should RC5_START() be | ||
135 | int addr; // What RC5_ADDR() should be. | ||
136 | int rc5_remote_gap; | ||
137 | |||
138 | /* RC5 gpio */ | ||
139 | bool rc5_gpio; /* Is RC5 legacy GPIO enabled? */ | ||
140 | u32 last_bit; /* last raw bit seen */ | ||
141 | u32 code; /* raw code under construction */ | ||
142 | struct timeval base_time; /* time of last seen code */ | ||
143 | bool active; /* building raw code */ | ||
144 | }; | ||
145 | |||
146 | |||
147 | /* ---------------------------------------------------------- */ | ||
148 | |||
149 | struct bttv_geometry { | ||
150 | u8 vtc,crop,comb; | ||
151 | u16 width,hscale,hdelay; | ||
152 | u16 sheight,vscale,vdelay,vtotal; | ||
153 | }; | ||
154 | |||
155 | struct bttv_buffer { | ||
156 | /* common v4l buffer stuff -- must be first */ | ||
157 | struct videobuf_buffer vb; | ||
158 | |||
159 | /* bttv specific */ | ||
160 | const struct bttv_format *fmt; | ||
161 | unsigned int tvnorm; | ||
162 | int btformat; | ||
163 | int btswap; | ||
164 | struct bttv_geometry geo; | ||
165 | struct btcx_riscmem top; | ||
166 | struct btcx_riscmem bottom; | ||
167 | struct v4l2_rect crop; | ||
168 | unsigned int vbi_skip[2]; | ||
169 | unsigned int vbi_count[2]; | ||
170 | }; | ||
171 | |||
172 | struct bttv_buffer_set { | ||
173 | struct bttv_buffer *top; /* top field buffer */ | ||
174 | struct bttv_buffer *bottom; /* bottom field buffer */ | ||
175 | unsigned int top_irq; | ||
176 | unsigned int frame_irq; | ||
177 | }; | ||
178 | |||
179 | struct bttv_overlay { | ||
180 | unsigned int tvnorm; | ||
181 | struct v4l2_rect w; | ||
182 | enum v4l2_field field; | ||
183 | struct v4l2_clip *clips; | ||
184 | int nclips; | ||
185 | int setup_ok; | ||
186 | }; | ||
187 | |||
188 | struct bttv_vbi_fmt { | ||
189 | struct v4l2_vbi_format fmt; | ||
190 | |||
191 | /* fmt.start[] and count[] refer to this video standard. */ | ||
192 | const struct bttv_tvnorm *tvnorm; | ||
193 | |||
194 | /* Earliest possible start of video capturing with this | ||
195 | v4l2_vbi_format, in struct bttv_crop.rect units. */ | ||
196 | __s32 end; | ||
197 | }; | ||
198 | |||
199 | /* bttv-vbi.c */ | ||
200 | void bttv_vbi_fmt_reset(struct bttv_vbi_fmt *f, unsigned int norm); | ||
201 | |||
202 | struct bttv_crop { | ||
203 | /* A cropping rectangle in struct bttv_tvnorm.cropcap units. */ | ||
204 | struct v4l2_rect rect; | ||
205 | |||
206 | /* Scaled image size limits with this crop rect. Divide | ||
207 | max_height, but not min_height, by two when capturing | ||
208 | single fields. See also bttv_crop_reset() and | ||
209 | bttv_crop_adjust() in bttv-driver.c. */ | ||
210 | __s32 min_scaled_width; | ||
211 | __s32 min_scaled_height; | ||
212 | __s32 max_scaled_width; | ||
213 | __s32 max_scaled_height; | ||
214 | }; | ||
215 | |||
216 | struct bttv_fh { | ||
217 | struct bttv *btv; | ||
218 | int resources; | ||
219 | #ifdef VIDIOC_G_PRIORITY | ||
220 | enum v4l2_priority prio; | ||
221 | #endif | ||
222 | enum v4l2_buf_type type; | ||
223 | |||
224 | /* video capture */ | ||
225 | struct videobuf_queue cap; | ||
226 | const struct bttv_format *fmt; | ||
227 | int width; | ||
228 | int height; | ||
229 | |||
230 | /* video overlay */ | ||
231 | const struct bttv_format *ovfmt; | ||
232 | struct bttv_overlay ov; | ||
233 | |||
234 | /* Application called VIDIOC_S_CROP. */ | ||
235 | int do_crop; | ||
236 | |||
237 | /* vbi capture */ | ||
238 | struct videobuf_queue vbi; | ||
239 | /* Current VBI capture window as seen through this fh (cannot | ||
240 | be global for compatibility with earlier drivers). Protected | ||
241 | by struct bttv.lock and struct bttv_fh.vbi.lock. */ | ||
242 | struct bttv_vbi_fmt vbi_fmt; | ||
243 | }; | ||
244 | |||
245 | /* ---------------------------------------------------------- */ | ||
246 | /* bttv-risc.c */ | ||
247 | |||
248 | /* risc code generators - capture */ | ||
249 | int bttv_risc_packed(struct bttv *btv, struct btcx_riscmem *risc, | ||
250 | struct scatterlist *sglist, | ||
251 | unsigned int offset, unsigned int bpl, | ||
252 | unsigned int pitch, unsigned int skip_lines, | ||
253 | unsigned int store_lines); | ||
254 | |||
255 | /* control dma register + risc main loop */ | ||
256 | void bttv_set_dma(struct bttv *btv, int override); | ||
257 | int bttv_risc_init_main(struct bttv *btv); | ||
258 | int bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc, | ||
259 | int irqflags); | ||
260 | |||
261 | /* capture buffer handling */ | ||
262 | int bttv_buffer_risc(struct bttv *btv, struct bttv_buffer *buf); | ||
263 | int bttv_buffer_activate_video(struct bttv *btv, | ||
264 | struct bttv_buffer_set *set); | ||
265 | int bttv_buffer_activate_vbi(struct bttv *btv, | ||
266 | struct bttv_buffer *vbi); | ||
267 | void bttv_dma_free(struct videobuf_queue *q, struct bttv *btv, | ||
268 | struct bttv_buffer *buf); | ||
269 | |||
270 | /* overlay handling */ | ||
271 | int bttv_overlay_risc(struct bttv *btv, struct bttv_overlay *ov, | ||
272 | const struct bttv_format *fmt, | ||
273 | struct bttv_buffer *buf); | ||
274 | |||
275 | |||
276 | /* ---------------------------------------------------------- */ | ||
277 | /* bttv-vbi.c */ | ||
278 | |||
279 | int bttv_try_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f); | ||
280 | int bttv_g_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f); | ||
281 | int bttv_s_fmt_vbi_cap(struct file *file, void *fh, struct v4l2_format *f); | ||
282 | |||
283 | extern struct videobuf_queue_ops bttv_vbi_qops; | ||
284 | |||
285 | /* ---------------------------------------------------------- */ | ||
286 | /* bttv-gpio.c */ | ||
287 | |||
288 | extern struct bus_type bttv_sub_bus_type; | ||
289 | int bttv_sub_add_device(struct bttv_core *core, char *name); | ||
290 | int bttv_sub_del_devices(struct bttv_core *core); | ||
291 | |||
292 | /* ---------------------------------------------------------- */ | ||
293 | /* bttv-cards.c */ | ||
294 | |||
295 | extern int no_overlay; | ||
296 | |||
297 | /* ---------------------------------------------------------- */ | ||
298 | /* bttv-input.c */ | ||
299 | |||
300 | extern void init_bttv_i2c_ir(struct bttv *btv); | ||
301 | extern int fini_bttv_i2c(struct bttv *btv); | ||
302 | |||
303 | /* ---------------------------------------------------------- */ | ||
304 | /* bttv-driver.c */ | ||
305 | |||
306 | /* insmod options */ | ||
307 | extern unsigned int bttv_verbose; | ||
308 | extern unsigned int bttv_debug; | ||
309 | extern unsigned int bttv_gpio; | ||
310 | extern void bttv_gpio_tracking(struct bttv *btv, char *comment); | ||
311 | extern int init_bttv_i2c(struct bttv *btv); | ||
312 | |||
313 | #define dprintk(fmt, ...) \ | ||
314 | do { \ | ||
315 | if (bttv_debug >= 1) \ | ||
316 | pr_debug(fmt, ##__VA_ARGS__); \ | ||
317 | } while (0) | ||
318 | #define dprintk_cont(fmt, ...) \ | ||
319 | do { \ | ||
320 | if (bttv_debug >= 1) \ | ||
321 | pr_cont(fmt, ##__VA_ARGS__); \ | ||
322 | } while (0) | ||
323 | #define d2printk(fmt, ...) \ | ||
324 | do { \ | ||
325 | if (bttv_debug >= 2) \ | ||
326 | printk(fmt, ##__VA_ARGS__); \ | ||
327 | } while (0) | ||
328 | |||
329 | #define BTTV_MAX_FBUF 0x208000 | ||
330 | #define BTTV_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */ | ||
331 | #define BTTV_FREE_IDLE msecs_to_jiffies(1000) /* one second */ | ||
332 | |||
333 | |||
334 | struct bttv_pll_info { | ||
335 | unsigned int pll_ifreq; /* PLL input frequency */ | ||
336 | unsigned int pll_ofreq; /* PLL output frequency */ | ||
337 | unsigned int pll_crystal; /* Crystal used for input */ | ||
338 | unsigned int pll_current; /* Currently programmed ofreq */ | ||
339 | }; | ||
340 | |||
341 | /* for gpio-connected remote control */ | ||
342 | struct bttv_input { | ||
343 | struct input_dev *dev; | ||
344 | char name[32]; | ||
345 | char phys[32]; | ||
346 | u32 mask_keycode; | ||
347 | u32 mask_keydown; | ||
348 | }; | ||
349 | |||
350 | struct bttv_suspend_state { | ||
351 | u32 gpio_enable; | ||
352 | u32 gpio_data; | ||
353 | int disabled; | ||
354 | int loop_irq; | ||
355 | struct bttv_buffer_set video; | ||
356 | struct bttv_buffer *vbi; | ||
357 | }; | ||
358 | |||
359 | struct bttv { | ||
360 | struct bttv_core c; | ||
361 | |||
362 | /* pci device config */ | ||
363 | unsigned short id; | ||
364 | unsigned char revision; | ||
365 | unsigned char __iomem *bt848_mmio; /* pointer to mmio */ | ||
366 | |||
367 | /* card configuration info */ | ||
368 | unsigned int cardid; /* pci subsystem id (bt878 based ones) */ | ||
369 | unsigned int tuner_type; /* tuner chip type */ | ||
370 | unsigned int tda9887_conf; | ||
371 | unsigned int svhs, dig; | ||
372 | unsigned int has_saa6588:1; | ||
373 | struct bttv_pll_info pll; | ||
374 | int triton1; | ||
375 | int gpioirq; | ||
376 | |||
377 | int use_i2c_hw; | ||
378 | |||
379 | /* old gpio interface */ | ||
380 | int shutdown; | ||
381 | |||
382 | void (*volume_gpio)(struct bttv *btv, __u16 volume); | ||
383 | void (*audio_mode_gpio)(struct bttv *btv, struct v4l2_tuner *tuner, int set); | ||
384 | |||
385 | /* new gpio interface */ | ||
386 | spinlock_t gpio_lock; | ||
387 | |||
388 | /* i2c layer */ | ||
389 | struct i2c_algo_bit_data i2c_algo; | ||
390 | struct i2c_client i2c_client; | ||
391 | int i2c_state, i2c_rc; | ||
392 | int i2c_done; | ||
393 | wait_queue_head_t i2c_queue; | ||
394 | struct v4l2_subdev *sd_msp34xx; | ||
395 | struct v4l2_subdev *sd_tvaudio; | ||
396 | |||
397 | /* video4linux (1) */ | ||
398 | struct video_device *video_dev; | ||
399 | struct video_device *radio_dev; | ||
400 | struct video_device *vbi_dev; | ||
401 | |||
402 | /* infrared remote */ | ||
403 | int has_remote; | ||
404 | struct bttv_ir *remote; | ||
405 | |||
406 | /* I2C remote data */ | ||
407 | struct IR_i2c_init_data init_data; | ||
408 | |||
409 | /* locking */ | ||
410 | spinlock_t s_lock; | ||
411 | struct mutex lock; | ||
412 | int resources; | ||
413 | #ifdef VIDIOC_G_PRIORITY | ||
414 | struct v4l2_prio_state prio; | ||
415 | #endif | ||
416 | |||
417 | /* video state */ | ||
418 | unsigned int input; | ||
419 | unsigned int audio; | ||
420 | unsigned int mute; | ||
421 | unsigned long freq; | ||
422 | unsigned int tvnorm; | ||
423 | int hue, contrast, bright, saturation; | ||
424 | struct v4l2_framebuffer fbuf; | ||
425 | unsigned int field_count; | ||
426 | |||
427 | /* various options */ | ||
428 | int opt_combfilter; | ||
429 | int opt_lumafilter; | ||
430 | int opt_automute; | ||
431 | int opt_chroma_agc; | ||
432 | int opt_adc_crush; | ||
433 | int opt_vcr_hack; | ||
434 | int opt_whitecrush_upper; | ||
435 | int opt_whitecrush_lower; | ||
436 | int opt_uv_ratio; | ||
437 | int opt_full_luma_range; | ||
438 | int opt_coring; | ||
439 | |||
440 | /* radio data/state */ | ||
441 | int has_radio; | ||
442 | int radio_user; | ||
443 | int radio_uses_msp_demodulator; | ||
444 | |||
445 | /* miro/pinnacle + Aimslab VHX | ||
446 | philips matchbox (tea5757 radio tuner) support */ | ||
447 | int has_matchbox; | ||
448 | int mbox_we; | ||
449 | int mbox_data; | ||
450 | int mbox_clk; | ||
451 | int mbox_most; | ||
452 | int mbox_mask; | ||
453 | |||
454 | /* ISA stuff (Terratec Active Radio Upgrade) */ | ||
455 | int mbox_ior; | ||
456 | int mbox_iow; | ||
457 | int mbox_csel; | ||
458 | |||
459 | /* risc memory management data | ||
460 | - must acquire s_lock before changing these | ||
461 | - only the irq handler is supported to touch top + bottom + vcurr */ | ||
462 | struct btcx_riscmem main; | ||
463 | struct bttv_buffer *screen; /* overlay */ | ||
464 | struct list_head capture; /* video capture queue */ | ||
465 | struct list_head vcapture; /* vbi capture queue */ | ||
466 | struct bttv_buffer_set curr; /* active buffers */ | ||
467 | struct bttv_buffer *cvbi; /* active vbi buffer */ | ||
468 | int loop_irq; | ||
469 | int new_input; | ||
470 | |||
471 | unsigned long cap_ctl; | ||
472 | unsigned long dma_on; | ||
473 | struct timer_list timeout; | ||
474 | struct bttv_suspend_state state; | ||
475 | |||
476 | /* stats */ | ||
477 | unsigned int errors; | ||
478 | unsigned int framedrop; | ||
479 | unsigned int irq_total; | ||
480 | unsigned int irq_me; | ||
481 | |||
482 | unsigned int users; | ||
483 | struct bttv_fh init; | ||
484 | |||
485 | /* used to make dvb-bt8xx autoloadable */ | ||
486 | struct work_struct request_module_wk; | ||
487 | |||
488 | /* Default (0) and current (1) video capturing and overlay | ||
489 | cropping parameters in bttv_tvnorm.cropcap units. Protected | ||
490 | by bttv.lock. */ | ||
491 | struct bttv_crop crop[2]; | ||
492 | |||
493 | /* Earliest possible start of video capturing in | ||
494 | bttv_tvnorm.cropcap line units. Set by check_alloc_btres() | ||
495 | and free_btres(). Protected by bttv.lock. */ | ||
496 | __s32 vbi_end; | ||
497 | |||
498 | /* Latest possible end of VBI capturing (= crop[x].rect.top when | ||
499 | VIDEO_RESOURCES are locked). Set by check_alloc_btres() | ||
500 | and free_btres(). Protected by bttv.lock. */ | ||
501 | __s32 crop_start; | ||
502 | }; | ||
503 | |||
504 | static inline struct bttv *to_bttv(struct v4l2_device *v4l2_dev) | ||
505 | { | ||
506 | return container_of(v4l2_dev, struct bttv, c.v4l2_dev); | ||
507 | } | ||
508 | |||
509 | /* our devices */ | ||
510 | #define BTTV_MAX 32 | ||
511 | extern unsigned int bttv_num; | ||
512 | extern struct bttv *bttvs[BTTV_MAX]; | ||
513 | |||
514 | static inline unsigned int bttv_muxsel(const struct bttv *btv, | ||
515 | unsigned int input) | ||
516 | { | ||
517 | return (bttv_tvcards[btv->c.type].muxsel >> (input * 2)) & 3; | ||
518 | } | ||
519 | |||
520 | #endif | ||
521 | |||
522 | #define btwrite(dat,adr) writel((dat), btv->bt848_mmio+(adr)) | ||
523 | #define btread(adr) readl(btv->bt848_mmio+(adr)) | ||
524 | |||
525 | #define btand(dat,adr) btwrite((dat) & btread(adr), adr) | ||
526 | #define btor(dat,adr) btwrite((dat) | btread(adr), adr) | ||
527 | #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr) | ||
528 | |||
529 | #endif /* _BTTVP_H_ */ | ||
530 | |||
531 | /* | ||
532 | * Local variables: | ||
533 | * c-basic-offset: 8 | ||
534 | * End: | ||
535 | */ | ||