File: /usr/src/linux/drivers/media/video/bttvp.h
1 /*
2 bttv - Bt848 frame grabber driver
3
4 bttv's *private* header file -- nobody else than bttv itself
5 should ever include this file.
6
7 Copyright (C) 1996,97 Ralph Metzler (rjkm@thp.uni-koeln.de)
8 (c) 1999,2000 Gerd Knorr <kraxel@goldbach.in-berlin.de>
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 #define BTTV_VERSION_CODE KERNEL_VERSION(0,7,72)
29
30
31 #include <linux/types.h>
32 #include <linux/wait.h>
33 #include <linux/i2c.h>
34 #include <linux/i2c-algo-bit.h>
35
36 #include "bt848.h"
37 #include "bttv.h"
38 #include "audiochip.h"
39
40 #ifdef __KERNEL__
41
42 /* ---------------------------------------------------------- */
43 /* bttv-driver.c */
44
45 /* insmod options / kernel args */
46 extern int no_overlay;
47 extern unsigned int bttv_verbose;
48 extern unsigned int bttv_debug;
49 extern unsigned int bttv_gpio;
50 extern void bttv_gpio_tracking(struct bttv *btv, char *comment);
51 extern int init_bttv_i2c(struct bttv *btv);
52
53 #define dprintk if (bttv_debug) printk
54
55 /* Anybody who uses more than four? */
56 #define BTTV_MAX 4
57 extern int bttv_num; /* number of Bt848s in use */
58 extern struct bttv bttvs[BTTV_MAX];
59
60
61 #ifndef O_NONCAP
62 #define O_NONCAP O_TRUNC
63 #endif
64
65 #define MAX_GBUFFERS 64
66 #define RISCMEM_LEN (32744*2)
67 #define VBI_MAXLINES 16
68 #define VBIBUF_SIZE (2048*VBI_MAXLINES*2)
69
70 #define BTTV_MAX_FBUF 0x208000
71
72 struct bttv_window
73 {
74 int x, y;
75 ushort width, height;
76 ushort bpp, bpl;
77 ushort swidth, sheight;
78 unsigned long vidadr;
79 ushort freq;
80 int norm;
81 int interlace;
82 int color_fmt;
83 ushort depth;
84 };
85
86 struct bttv_pll_info {
87 unsigned int pll_ifreq; /* PLL input frequency */
88 unsigned int pll_ofreq; /* PLL output frequency */
89 unsigned int pll_crystal; /* Crystal used for input */
90 unsigned int pll_current; /* Currently programmed ofreq */
91 };
92
93 struct bttv_gbuf {
94 int stat;
95 #define GBUFFER_UNUSED 0
96 #define GBUFFER_GRABBING 1
97 #define GBUFFER_DONE 2
98 #define GBUFFER_ERROR 3
99 struct timeval tv;
100
101 u16 width;
102 u16 height;
103 u16 fmt;
104
105 u32 *risc;
106 unsigned long ro;
107 unsigned long re;
108 };
109
110 struct bttv {
111 struct video_device video_dev;
112 struct video_device radio_dev;
113 struct video_device vbi_dev;
114 struct video_picture picture; /* Current picture params */
115 struct video_audio audio_dev; /* Current audio params */
116
117 spinlock_t s_lock;
118 struct semaphore lock;
119 int user;
120 int capuser;
121
122 /* i2c */
123 struct i2c_adapter i2c_adap;
124 struct i2c_algo_bit_data i2c_algo;
125 struct i2c_client i2c_client;
126 int i2c_state, i2c_rc;
127 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX];
128
129 int tuner_type;
130 int channel;
131
132 unsigned int nr;
133 unsigned short id;
134 struct pci_dev *dev;
135 unsigned int irq; /* IRQ used by Bt848 card */
136 unsigned char revision;
137 unsigned long bt848_adr; /* bus address of IO mem returned by PCI BIOS */
138 unsigned char *bt848_mem; /* pointer to mapped IO memory */
139 unsigned long busriscmem;
140 u32 *riscmem;
141
142 unsigned char *vbibuf;
143 struct bttv_window win;
144 int fb_color_ctl;
145 int type; /* card type */
146 int cardid;
147 int audio; /* audio mode */
148 int audio_chip; /* set to one of the chips supported by bttv.c */
149 int radio;
150 int has_radio;
151
152 /* miro/pinnacle + Aimslab VHX
153 philips matchbox (tea5757 radio tuner) support */
154 int has_matchbox;
155 int mbox_we;
156 int mbox_data;
157 int mbox_clk;
158 int mbox_most;
159 int mbox_mask;
160
161 u32 *risc_jmp;
162 u32 *vbi_odd;
163 u32 *vbi_even;
164 u32 bus_vbi_even;
165 u32 bus_vbi_odd;
166 wait_queue_head_t vbiq;
167 wait_queue_head_t capq;
168 int vbip;
169
170 u32 *risc_scr_odd;
171 u32 *risc_scr_even;
172 u32 risc_cap_odd;
173 u32 risc_cap_even;
174 int scr_on;
175 int vbi_on;
176 struct video_clip *cliprecs;
177
178 struct bttv_gbuf *gbuf;
179 int gqueue[MAX_GBUFFERS];
180 int gq_in,gq_out,gq_grab,gq_start;
181 char *fbuffer;
182
183 struct bttv_pll_info pll;
184 unsigned int Fsc;
185 unsigned int field;
186 unsigned int last_field; /* number of last grabbed field */
187 int i2c_command;
188 int triton1;
189
190 int errors;
191 int needs_restart;
192
193 wait_queue_head_t gpioq;
194 int shutdown;
195 };
196 #endif
197
198 #define btwrite(dat,adr) writel((dat), (char *) (btv->bt848_mem+(adr)))
199 #define btread(adr) readl(btv->bt848_mem+(adr))
200
201 #define btand(dat,adr) btwrite((dat) & btread(adr), adr)
202 #define btor(dat,adr) btwrite((dat) | btread(adr), adr)
203 #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
204
205 /* bttv ioctls */
206
207 #define BTTV_READEE _IOW('v', BASE_VIDIOCPRIVATE+0, char [256])
208 #define BTTV_WRITEE _IOR('v', BASE_VIDIOCPRIVATE+1, char [256])
209 #define BTTV_FIELDNR _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)
210 #define BTTV_PLLSET _IOW('v' , BASE_VIDIOCPRIVATE+3, struct bttv_pll_info)
211 #define BTTV_BURST_ON _IOR('v' , BASE_VIDIOCPRIVATE+4, int)
212 #define BTTV_BURST_OFF _IOR('v' , BASE_VIDIOCPRIVATE+5, int)
213 #define BTTV_VERSION _IOR('v' , BASE_VIDIOCPRIVATE+6, int)
214 #define BTTV_PICNR _IOR('v' , BASE_VIDIOCPRIVATE+7, int)
215 #define BTTV_VBISIZE _IOR('v' , BASE_VIDIOCPRIVATE+8, int)
216
217 #define TDA9850 0x01
218 #define TDA9840 0x02
219 #define TDA8425 0x03
220 #define TEA6300 0x04
221
222 #endif /* _BTTVP_H_ */
223
224 /*
225 * Local variables:
226 * c-basic-offset: 8
227 * End:
228 */
229