1 /*
2     saa7146.h - definitions philips saa7146 based cards
3     Copyright (C) 1999 Nathan Laredo (laredo@gnu.org)
4 
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9 
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14 
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 
20 #ifndef __SAA7146__
21 #define __SAA7146__
22 
23 #define SAA7146_VERSION_CODE 0x000101
24 
25 #include <linux/types.h>
26 #include <linux/wait.h>
27 
28 #include <linux/i2c-old.h>
29 #include <linux/videodev.h>
30 
31 #ifndef O_NONCAP
32 #define O_NONCAP	O_TRUNC
33 #endif
34 
35 #define MAX_GBUFFERS	2
36 #define FBUF_SIZE	0x190000
37 
38 #ifdef __KERNEL__
39 
40 struct saa7146_window
41 {
42 	int x, y;
43 	ushort width, height;
44 	ushort bpp, bpl;
45 	ushort swidth, sheight;
46 	short cropx, cropy;
47 	ushort cropwidth, cropheight;
48 	unsigned long vidadr;
49 	int color_fmt;
50 	ushort depth;
51 };
52 
53 /*  Per-open data for handling multiple opens on one device */
54 struct device_open
55 {
56 	int	     isopen;
57 	int	     noncapturing;
58 	struct saa7146  *dev;
59 };
60 #define MAX_OPENS 3
61 
62 struct saa7146
63 {
64 	struct video_device video_dev;
65 	struct video_picture picture;
66 	struct video_audio audio_dev;
67 	struct video_info vidinfo;
68 	int user;
69 	int cap;
70 	int capuser;
71 	int irqstate;		/* irq routine is state driven */
72 	int writemode;
73 	int playmode;
74         unsigned int nr;
75 	unsigned long irq;          /* IRQ used by SAA7146 card */
76 	unsigned short id;
77 	struct i2c_bus i2c;
78 	struct pci_dev *dev;
79 	unsigned char revision;
80 	unsigned char boardcfg[64];	/* 64 bytes of config from eeprom */
81 	unsigned long saa7146_adr;   /* bus address of IO mem from PCI BIOS */
82 	struct saa7146_window win;
83 	unsigned char *saa7146_mem; /* pointer to mapped IO memory */
84 	struct device_open open_data[MAX_OPENS];
85 #define MAX_MARKS 16
86 	/* for a/v sync */
87 	int endmark[MAX_MARKS], endmarkhead, endmarktail;
88 	u32 *dmaRPS1, *pageRPS1, *dmaRPS2, *pageRPS2, *dmavid1, *dmavid2,
89 		*dmavid3, *dmaa1in, *dmaa1out, *dmaa2in, *dmaa2out,
90 		*pagedebi, *pagevid1, *pagevid2, *pagevid3, *pagea1in,
91 		*pagea1out, *pagea2in, *pagea2out;
92 	wait_queue_head_t i2cq, debiq, audq, vidq;
93 	u8  *vidbuf, *audbuf, *osdbuf, *dmadebi;
94 	int audhead, vidhead, osdhead, audtail, vidtail, osdtail;
95 	spinlock_t lock;	/* the device lock */
96 };
97 #endif
98 
99 #ifdef _ALPHA_SAA7146
100 #define saawrite(dat,adr)    writel((dat),(char *) (saa->saa7146_adr+(adr)))
101 #define saaread(adr)         readl(saa->saa7146_adr+(adr))
102 #else
103 #define saawrite(dat,adr)    writel((dat), (char *) (saa->saa7146_mem+(adr)))
104 #define saaread(adr)         readl(saa->saa7146_mem+(adr))
105 #endif
106 
107 #define saaand(dat,adr)      saawrite((dat) & saaread(adr), adr)
108 #define saaor(dat,adr)       saawrite((dat) | saaread(adr), adr)
109 #define saaaor(dat,mask,adr) saawrite((dat) | ((mask) & saaread(adr)), adr)
110 
111 /* bitmask of attached hardware found */
112 #define SAA7146_UNKNOWN		0x00000000
113 #define SAA7146_SAA7111		0x00000001
114 #define SAA7146_SAA7121		0x00000002
115 #define SAA7146_IBMMPEG		0x00000004
116 
117 #endif
118