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,50)
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 unsigned int bttv_verbose;
47 extern unsigned int bttv_debug;
48 extern unsigned int bttv_gpio;
49 extern void bttv_gpio_tracking(struct bttv *btv, char *comment);
50
51 /* Anybody who uses more than four? */
52 #define BTTV_MAX 4
53 extern int bttv_num; /* number of Bt848s in use */
54 extern struct bttv bttvs[BTTV_MAX];
55
56
57 #ifndef O_NONCAP
58 #define O_NONCAP O_TRUNC
59 #endif
60
61 #define MAX_GBUFFERS 64
62 #define RISCMEM_LEN (32744*2)
63 #define VBI_MAXLINES 16
64 #define VBIBUF_SIZE (2048*VBI_MAXLINES*2)
65
66 #define BTTV_MAX_FBUF 0x208000
67
68 struct bttv_window
69 {
70 int x, y;
71 ushort width, height;
72 ushort bpp, bpl;
73 ushort swidth, sheight;
74 unsigned long vidadr;
75 ushort freq;
76 int norm;
77 int interlace;
78 int color_fmt;
79 ushort depth;
80 };
81
82 struct bttv_pll_info {
83 unsigned int pll_ifreq; /* PLL input frequency */
84 unsigned int pll_ofreq; /* PLL output frequency */
85 unsigned int pll_crystal; /* Crystal used for input */
86 unsigned int pll_current; /* Currently programmed ofreq */
87 };
88
89 struct bttv_gbuf {
90 int stat;
91 #define GBUFFER_UNUSED 0
92 #define GBUFFER_GRABBING 1
93 #define GBUFFER_DONE 2
94 #define GBUFFER_ERROR 3
95 struct timeval tv;
96
97 u16 width;
98 u16 height;
99 u16 fmt;
100
101 u32 *risc;
102 unsigned long ro;
103 unsigned long re;
104 };
105
106 struct bttv {
107 struct video_device video_dev;
108 struct video_device radio_dev;
109 struct video_device vbi_dev;
110 struct video_picture picture; /* Current picture params */
111 struct video_audio audio_dev; /* Current audio params */
112
113 spinlock_t s_lock;
114 struct semaphore lock;
115 int user;
116 int capuser;
117
118 /* i2c */
119 struct i2c_adapter i2c_adap;
120 struct i2c_algo_bit_data i2c_algo;
121 struct i2c_client i2c_client;
122 int i2c_state, i2c_rc;
123 struct i2c_client *i2c_clients[I2C_CLIENTS_MAX];
124
125 int tuner_type;
126 int channel;
127
128 unsigned int nr;
129 unsigned short id;
130 struct pci_dev *dev;
131 unsigned int irq; /* IRQ used by Bt848 card */
132 unsigned char revision;
133 unsigned long bt848_adr; /* bus address of IO mem returned by PCI BIOS */
134 unsigned char *bt848_mem; /* pointer to mapped IO memory */
135 unsigned long busriscmem;
136 u32 *riscmem;
137
138 unsigned char *vbibuf;
139 struct bttv_window win;
140 int fb_color_ctl;
141 int type; /* card type */
142 int cardid;
143 int audio; /* audio mode */
144 int audio_chip; /* set to one of the chips supported by bttv.c */
145 int radio;
146
147 u32 *risc_jmp;
148 u32 *vbi_odd;
149 u32 *vbi_even;
150 u32 bus_vbi_even;
151 u32 bus_vbi_odd;
152 wait_queue_head_t vbiq;
153 wait_queue_head_t capq;
154 int vbip;
155
156 u32 *risc_scr_odd;
157 u32 *risc_scr_even;
158 u32 risc_cap_odd;
159 u32 risc_cap_even;
160 int scr_on;
161 int vbi_on;
162 struct video_clip *cliprecs;
163
164 struct bttv_gbuf *gbuf;
165 int gqueue[MAX_GBUFFERS];
166 int gq_in,gq_out,gq_grab,gq_start;
167 char *fbuffer;
168
169 struct bttv_pll_info pll;
170 unsigned int Fsc;
171 unsigned int field;
172 unsigned int last_field; /* number of last grabbed field */
173 int i2c_command;
174 int triton1;
175
176 int errors;
177 int needs_restart;
178
179 wait_queue_head_t gpioq;
180 int shutdown;
181 };
182 #endif
183
184 #if defined(__powerpc__) /* big-endian */
185 extern __inline__ void io_st_le32(volatile unsigned *addr, unsigned val)
186 {
187 __asm__ __volatile__ ("stwbrx %1,0,%2" : \
188 "=m" (*addr) : "r" (val), "r" (addr));
189 __asm__ __volatile__ ("eieio" : : : "memory");
190 }
191
192 #define btwrite(dat,adr) io_st_le32((unsigned *)(btv->bt848_mem+(adr)),(dat))
193 #define btread(adr) ld_le32((unsigned *)(btv->bt848_mem+(adr)))
194 #else
195 #define btwrite(dat,adr) writel((dat), (char *) (btv->bt848_mem+(adr)))
196 #define btread(adr) readl(btv->bt848_mem+(adr))
197 #endif
198
199 #define btand(dat,adr) btwrite((dat) & btread(adr), adr)
200 #define btor(dat,adr) btwrite((dat) | btread(adr), adr)
201 #define btaor(dat,mask,adr) btwrite((dat) | ((mask) & btread(adr)), adr)
202
203 /* bttv ioctls */
204
205 #define BTTV_READEE _IOW('v', BASE_VIDIOCPRIVATE+0, char [256])
206 #define BTTV_WRITEE _IOR('v', BASE_VIDIOCPRIVATE+1, char [256])
207 #define BTTV_FIELDNR _IOR('v' , BASE_VIDIOCPRIVATE+2, unsigned int)
208 #define BTTV_PLLSET _IOW('v' , BASE_VIDIOCPRIVATE+3, struct bttv_pll_info)
209 #define BTTV_BURST_ON _IOR('v' , BASE_VIDIOCPRIVATE+4, int)
210 #define BTTV_BURST_OFF _IOR('v' , BASE_VIDIOCPRIVATE+5, int)
211 #define BTTV_VERSION _IOR('v' , BASE_VIDIOCPRIVATE+6, int)
212 #define BTTV_PICNR _IOR('v' , BASE_VIDIOCPRIVATE+7, int)
213 #define BTTV_VBISIZE _IOR('v' , BASE_VIDIOCPRIVATE+8, int)
214
215 #define TDA9850 0x01
216 #define TDA9840 0x02
217 #define TDA8425 0x03
218 #define TEA6300 0x04
219
220 #endif /* _BTTVP_H_ */
221
222 /*
223 * Local variables:
224 * c-basic-offset: 8
225 * End:
226 */
227
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.