]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/media/dvb/mantis/mantis_common.h
d4865e4f3468f677ef3b3481c34a2734e53c860d
[karo-tx-linux.git] / drivers / media / dvb / mantis / mantis_common.h
1 /*
2         Mantis PCI bridge driver
3
4         Copyright (C) 2005, 2006 Manu Abraham (abraham.manu@gmail.com)
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 __MANTIS_COMMON_H
22 #define __MANTIS_COMMON_H
23
24 #include <linux/module.h>
25 #include <linux/moduleparam.h>
26 #include <linux/kernel.h>
27 #include <linux/pci.h>
28 #include <linux/mutex.h>
29
30 #include "dvbdev.h"
31 #include "dvb_demux.h"
32 #include "dmxdev.h"
33 #include "dvb_frontend.h"
34 #include "dvb_net.h"
35 #include <linux/i2c.h>
36 #include "mantis_reg.h"
37
38 #define MANTIS_ERROR            0
39 #define MANTIS_NOTICE           1
40 #define MANTIS_INFO             2
41 #define MANTIS_DEBUG            3
42
43 #define dprintk(x, y, z, format, arg...) do {                                                           \
44         if (z) {                                                                                        \
45                 if      ((x > MANTIS_ERROR) && (x > y))                                                 \
46                         printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);      \
47                 else if ((x > MANTIS_NOTICE) && (x > y))                                                \
48                         printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);   \
49                 else if ((x > MANTIS_INFO) && (x > y))                                                  \
50                         printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);     \
51                 else if ((x > MANTIS_DEBUG) && (x > y))                                                 \
52                         printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg);    \
53         } else {                                                                                        \
54                 if (x > y)                                                                              \
55                         printk(format , ##arg);                                                         \
56         }                                                                                               \
57 } while(0)
58
59 #define mwrite(dat, addr)       writel((dat), addr)
60 #define mread(addr)             readl(addr)
61
62 #define mmwrite(dat, addr)      mwrite((dat), (mantis->mantis_mmio + (addr)))
63 #define mmread(addr)            mread(mantis->mantis_mmio + (addr))
64 #define mmand(dat, addr)        mmwrite((dat) & mmread(addr), addr)
65 #define mmor(dat, addr)         mmwrite((dat) | mmread(addr), addr)
66 #define mmaor(dat, addr)        mmwrite((dat) | ((mask) & mmread(addr)), addr)
67
68 #define MANTIS_TS_188           0
69 #define MANTIS_TS_204           1
70
71 struct mantis_hwconfig {
72         char                    *model_name;
73         char                    *dev_type;
74         u32                     ts_size;
75 };
76
77 struct mantis_pci {
78         /*      PCI stuff               */
79         u16                     vendor_id;
80         u16                     device_id;
81         u16                     subsystem_vendor;
82         u16                     subsystem_device;
83
84         u8                      latency;
85
86         struct                  pci_dev *pdev;
87
88         unsigned long           mantis_addr;
89         volatile void __iomem   *mantis_mmio;
90
91         u8                      irq;
92         u8                      revision;
93
94         unsigned int            num;
95
96         /*      RISC Core               */
97         u32                     finished_block;
98         u32                     last_block;
99         u32                     line_bytes;
100         u32                     line_count;
101         u32                     risc_pos;
102         u8                      *buf_cpu;
103         dma_addr_t              buf_dma;
104         u32                     *risc_cpu;
105         dma_addr_t              risc_dma;
106
107         struct tasklet_struct   tasklet;
108
109         struct i2c_adapter      adapter;
110         int                     i2c_rc;
111         wait_queue_head_t       i2c_wq;
112         struct mutex            i2c_lock;
113
114         /*      DVB stuff               */
115         struct dvb_adapter      dvb_adapter;
116         struct dvb_frontend     *fe;
117         struct dvb_demux        demux;
118         struct dmxdev           dmxdev;
119         struct dmx_frontend     fe_hw;
120         struct dmx_frontend     fe_mem;
121         struct dvb_net          dvbnet;
122
123         u8                      feeds;
124
125         struct mantis_hwconfig  *hwconfig;
126
127         u32                     mantis_int_stat;
128         u32                     mantis_int_mask;
129
130         /*      board specific          */
131         u8                      mac_address[8];
132         u32                     sub_vendor_id;
133         u32                     sub_device_id;
134
135          /*     A12 A13 A14             */
136         int                     gpio_status;
137 };
138
139 extern unsigned int verbose;
140 extern unsigned int devs;
141 extern unsigned int i2c;
142 extern int mantis_dvb_init(struct mantis_pci *mantis);
143 extern int mantis_frontend_init(struct mantis_pci *mantis);
144 extern int mantis_dvb_exit(struct mantis_pci *mantis);
145 extern void mantis_dma_xfer(unsigned long data);
146 extern void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value);
147
148 #endif //__MANTIS_COMMON_H