blob: 2830b5e33aec97c90b94acfd9756def5aa50d13c [file] [log] [blame]
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -03001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 saa7146.h - definitions philips saa7146 based cards
3 Copyright (C) 1999 Nathan Laredo (laredo@gnu.org)
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -03004
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 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/videodev.h>
29
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -030030#ifndef O_NONCAP
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#define O_NONCAP O_TRUNC
32#endif
33
34#define MAX_GBUFFERS 2
35#define FBUF_SIZE 0x190000
36
37#ifdef __KERNEL__
38
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -030039struct saa7146_window
Linus Torvalds1da177e2005-04-16 15:20:36 -070040{
41 int x, y;
42 ushort width, height;
43 ushort bpp, bpl;
44 ushort swidth, sheight;
45 short cropx, cropy;
46 ushort cropwidth, cropheight;
47 unsigned long vidadr;
48 int color_fmt;
49 ushort depth;
50};
51
52/* Per-open data for handling multiple opens on one device */
53struct device_open
54{
55 int isopen;
56 int noncapturing;
57 struct saa7146 *dev;
58};
59#define MAX_OPENS 3
60
61struct saa7146
62{
63 struct video_device video_dev;
64 struct video_picture picture;
65 struct video_audio audio_dev;
66 struct video_info vidinfo;
67 int user;
68 int cap;
69 int capuser;
70 int irqstate; /* irq routine is state driven */
71 int writemode;
72 int playmode;
Mauro Carvalho Chehabd56410e2006-03-25 09:19:53 -030073 unsigned int nr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 unsigned long irq; /* IRQ used by SAA7146 card */
75 unsigned short id;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 unsigned char revision;
77 unsigned char boardcfg[64]; /* 64 bytes of config from eeprom */
78 unsigned long saa7146_adr; /* bus address of IO mem from PCI BIOS */
79 struct saa7146_window win;
80 unsigned char __iomem *saa7146_mem; /* pointer to mapped IO memory */
81 struct device_open open_data[MAX_OPENS];
82#define MAX_MARKS 16
83 /* for a/v sync */
84 int endmark[MAX_MARKS], endmarkhead, endmarktail;
85 u32 *dmaRPS1, *pageRPS1, *dmaRPS2, *pageRPS2, *dmavid1, *dmavid2,
86 *dmavid3, *dmaa1in, *dmaa1out, *dmaa2in, *dmaa2out,
87 *pagedebi, *pagevid1, *pagevid2, *pagevid3, *pagea1in,
88 *pagea1out, *pagea2in, *pagea2out;
89 wait_queue_head_t i2cq, debiq, audq, vidq;
90 u8 *vidbuf, *audbuf, *osdbuf, *dmadebi;
91 int audhead, vidhead, osdhead, audtail, vidtail, osdtail;
92 spinlock_t lock; /* the device lock */
93};
94#endif
95
96#ifdef _ALPHA_SAA7146
97#define saawrite(dat,adr) writel((dat), saa->saa7146_adr+(adr))
98#define saaread(adr) readl(saa->saa7146_adr+(adr))
99#else
100#define saawrite(dat,adr) writel((dat), saa->saa7146_mem+(adr))
101#define saaread(adr) readl(saa->saa7146_mem+(adr))
102#endif
103
104#define saaand(dat,adr) saawrite((dat) & saaread(adr), adr)
105#define saaor(dat,adr) saawrite((dat) | saaread(adr), adr)
106#define saaaor(dat,mask,adr) saawrite((dat) | ((mask) & saaread(adr)), adr)
107
108/* bitmask of attached hardware found */
109#define SAA7146_UNKNOWN 0x00000000
110#define SAA7146_SAA7111 0x00000001
111#define SAA7146_SAA7121 0x00000002
112#define SAA7146_IBMMPEG 0x00000004
113
114#endif