diff options
Diffstat (limited to 'drivers/media/dvb/mantis')
-rw-r--r-- | drivers/media/dvb/mantis/Kconfig | 13 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/Makefile | 7 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_common.h | 135 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_core.c | 215 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_core.h | 61 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_dma.c | 238 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_dvb.c | 304 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_i2c.c | 189 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_reg.h | 109 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_vp1033.c | 151 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_vp1033.h | 35 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_vp1034.c | 52 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_vp1034.h | 30 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_vp2033.c | 73 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_vp2033.h | 33 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_vp3030.c | 53 | ||||
-rw-r--r-- | drivers/media/dvb/mantis/mantis_vp3030.h | 30 |
17 files changed, 1728 insertions, 0 deletions
diff --git a/drivers/media/dvb/mantis/Kconfig b/drivers/media/dvb/mantis/Kconfig new file mode 100644 index 000000000000..4ba16d0ad96b --- /dev/null +++ b/drivers/media/dvb/mantis/Kconfig | |||
@@ -0,0 +1,13 @@ | |||
1 | config DVB_MANTIS | ||
2 | tristate "MANTIS based cards" | ||
3 | depends on DVB_CORE && PCI && I2C | ||
4 | select DVB_MB86A16 | ||
5 | select DVB_CU1216 | ||
6 | select DVB_ZL10353 | ||
7 | select DVB_STV0299 | ||
8 | select DVB_PLL | ||
9 | help | ||
10 | Support for PCI cards based on the Mantis PCI bridge. | ||
11 | Say Y when you have a Mantis based DVB card and want to use it. | ||
12 | |||
13 | If unsure say N. | ||
diff --git a/drivers/media/dvb/mantis/Makefile b/drivers/media/dvb/mantis/Makefile new file mode 100644 index 000000000000..a980ff2382b7 --- /dev/null +++ b/drivers/media/dvb/mantis/Makefile | |||
@@ -0,0 +1,7 @@ | |||
1 | mantis-objs = mantis_core.o mantis_dma.o mantis_pci.o mantis_i2c.o \ | ||
2 | mantis_dvb.o mantis_vp1033.o mantis_vp1034.o mantis_vp2033.o \ | ||
3 | mantis_vp3030.o | ||
4 | |||
5 | obj-$(CONFIG_DVB_MANTIS) += mantis.o | ||
6 | |||
7 | EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/dvb/frontends/ | ||
diff --git a/drivers/media/dvb/mantis/mantis_common.h b/drivers/media/dvb/mantis/mantis_common.h new file mode 100644 index 000000000000..ba360f884967 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_common.h | |||
@@ -0,0 +1,135 @@ | |||
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 | |||
29 | #include "dvbdev.h" | ||
30 | #include "dvb_demux.h" | ||
31 | #include "dmxdev.h" | ||
32 | #include "dvb_frontend.h" | ||
33 | #include "dvb_net.h" | ||
34 | #include <linux/i2c.h> | ||
35 | #include "mantis_reg.h" | ||
36 | |||
37 | #define MANTIS_ERROR 0 | ||
38 | #define MANTIS_NOTICE 1 | ||
39 | #define MANTIS_INFO 2 | ||
40 | #define MANTIS_DEBUG 3 | ||
41 | |||
42 | #define dprintk(x, y, z, format, arg...) do { \ | ||
43 | if (z) { \ | ||
44 | if ((x > MANTIS_ERROR) && (x > y)) \ | ||
45 | printk(KERN_ERR "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ | ||
46 | else if ((x > MANTIS_NOTICE) && (x > y)) \ | ||
47 | printk(KERN_NOTICE "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ | ||
48 | else if ((x > MANTIS_INFO) && (x > y)) \ | ||
49 | printk(KERN_INFO "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ | ||
50 | else if ((x > MANTIS_DEBUG) && (x > y)) \ | ||
51 | printk(KERN_DEBUG "%s (%d): " format "\n" , __func__ , mantis->num , ##arg); \ | ||
52 | } else { \ | ||
53 | if (x > y) \ | ||
54 | printk(format , ##arg); \ | ||
55 | } \ | ||
56 | } while(0) | ||
57 | |||
58 | #define mwrite(dat, addr) writel((dat), addr) | ||
59 | #define mread(addr) readl(addr) | ||
60 | |||
61 | #define mmwrite(dat, addr) mwrite((dat), (mantis->mantis_mmio + (addr))) | ||
62 | #define mmread(addr) mread(mantis->mantis_mmio + (addr)) | ||
63 | #define mmand(dat, addr) mmwrite((dat) & mmread(addr), addr) | ||
64 | #define mmor(dat, addr) mmwrite((dat) | mmread(addr), addr) | ||
65 | #define mmaor(dat, addr) mmwrite((dat) | ((mask) & mmread(addr)), addr) | ||
66 | |||
67 | |||
68 | struct mantis_pci { | ||
69 | /* PCI stuff */ | ||
70 | u16 vendor_id; | ||
71 | u16 device_id; | ||
72 | u8 latency; | ||
73 | |||
74 | struct pci_dev *pdev; | ||
75 | |||
76 | unsigned long mantis_addr; | ||
77 | volatile void __iomem *mantis_mmio; | ||
78 | |||
79 | u8 irq; | ||
80 | u8 revision; | ||
81 | |||
82 | unsigned int num; | ||
83 | u16 ts_size; | ||
84 | |||
85 | /* RISC Core */ | ||
86 | u32 finished_block; | ||
87 | u32 last_block; | ||
88 | u32 line_bytes; | ||
89 | u32 line_count; | ||
90 | u32 risc_pos; | ||
91 | u8 *buf_cpu; | ||
92 | dma_addr_t buf_dma; | ||
93 | u32 *risc_cpu; | ||
94 | dma_addr_t risc_dma; | ||
95 | |||
96 | struct tasklet_struct tasklet; | ||
97 | |||
98 | struct i2c_adapter adapter; | ||
99 | int i2c_rc; | ||
100 | wait_queue_head_t i2c_wq; | ||
101 | |||
102 | /* DVB stuff */ | ||
103 | struct dvb_adapter dvb_adapter; | ||
104 | struct dvb_frontend *fe; | ||
105 | struct dvb_demux demux; | ||
106 | struct dmxdev dmxdev; | ||
107 | struct dmx_frontend fe_hw; | ||
108 | struct dmx_frontend fe_mem; | ||
109 | struct dvb_net dvbnet; | ||
110 | |||
111 | u8 feeds; | ||
112 | |||
113 | struct mantis_config *config; | ||
114 | |||
115 | u32 mantis_int_stat; | ||
116 | u32 mantis_int_mask; | ||
117 | |||
118 | /* board specific */ | ||
119 | u8 mac_address[8]; | ||
120 | u32 sub_vendor_id; | ||
121 | u32 sub_device_id; | ||
122 | |||
123 | /* A12 A13 A14 */ | ||
124 | int gpio_status;}; | ||
125 | |||
126 | extern unsigned int verbose; | ||
127 | extern unsigned int devs; | ||
128 | extern unsigned int i2c; | ||
129 | extern int mantis_dvb_init(struct mantis_pci *mantis); | ||
130 | extern int mantis_frontend_init(struct mantis_pci *mantis); | ||
131 | extern int mantis_dvb_exit(struct mantis_pci *mantis); | ||
132 | extern void mantis_dma_xfer(unsigned long data); | ||
133 | extern void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value); | ||
134 | |||
135 | #endif //__MANTIS_COMMON_H | ||
diff --git a/drivers/media/dvb/mantis/mantis_core.c b/drivers/media/dvb/mantis/mantis_core.c new file mode 100644 index 000000000000..111227752452 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_core.c | |||
@@ -0,0 +1,215 @@ | |||
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 | #include "mantis_common.h" | ||
22 | #include "mantis_core.h" | ||
23 | |||
24 | |||
25 | static int read_eeprom_byte(struct mantis_pci *mantis, u8 *data, u8 length) | ||
26 | { | ||
27 | int err; | ||
28 | struct i2c_msg msg[] = { | ||
29 | { | ||
30 | .addr = 0x50, | ||
31 | .flags = 0, | ||
32 | .buf = data, | ||
33 | .len = 1 | ||
34 | },{ | ||
35 | .addr = 0x50, | ||
36 | .flags = I2C_M_RD, | ||
37 | .buf = data, | ||
38 | .len = length | ||
39 | }, | ||
40 | }; | ||
41 | if ((err = i2c_transfer(&mantis->adapter, msg, 2)) < 0) { | ||
42 | dprintk(verbose, MANTIS_ERROR, 1, | ||
43 | "ERROR: i2c read: < err=%i d0=0x%02x d1=0x%02x >", | ||
44 | err, data[0], data[1]); | ||
45 | |||
46 | return err; | ||
47 | } | ||
48 | msleep_interruptible(2); | ||
49 | |||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | static int write_eeprom_byte(struct mantis_pci *mantis, u8 *data, u8 length) | ||
54 | { | ||
55 | int err; | ||
56 | |||
57 | struct i2c_msg msg = { | ||
58 | .addr = 0x50, | ||
59 | .flags = 0, | ||
60 | .buf = data, | ||
61 | .len = length | ||
62 | }; | ||
63 | |||
64 | if ((err = i2c_transfer(&mantis->adapter, &msg, 1)) < 0) { | ||
65 | dprintk(verbose, MANTIS_ERROR, 1, | ||
66 | "ERROR: i2c write: < err=%i length=0x%02x d0=0x%02x, d1=0x%02x >", | ||
67 | err, length, data[0], data[1]); | ||
68 | |||
69 | return err; | ||
70 | } | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static int get_subdevice_id(struct mantis_pci *mantis) | ||
76 | { | ||
77 | int err; | ||
78 | static u8 sub_device_id[2]; | ||
79 | |||
80 | mantis->sub_device_id = 0; | ||
81 | sub_device_id[0] = 0xfc; | ||
82 | if ((err = read_eeprom_byte(mantis, &sub_device_id[0], 2)) < 0) { | ||
83 | dprintk(verbose, MANTIS_ERROR, 1, "Mantis EEPROM read error"); | ||
84 | return err; | ||
85 | } | ||
86 | mantis->sub_device_id = (sub_device_id[0] << 8) | sub_device_id[1]; | ||
87 | dprintk(verbose, MANTIS_ERROR, 1, "Sub Device ID=[0x%04x]", | ||
88 | mantis->sub_device_id); | ||
89 | |||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | static int get_subvendor_id(struct mantis_pci *mantis) | ||
94 | { | ||
95 | int err; | ||
96 | static u8 sub_vendor_id[2]; | ||
97 | |||
98 | mantis->sub_vendor_id = 0; | ||
99 | sub_vendor_id[0] = 0xfe; | ||
100 | if ((err = read_eeprom_byte(mantis, &sub_vendor_id[0], 2)) < 0) { | ||
101 | dprintk(verbose, MANTIS_ERROR, 1, "Mantis EEPROM read error"); | ||
102 | return err; | ||
103 | } | ||
104 | mantis->sub_vendor_id = (sub_vendor_id[0] << 8) | sub_vendor_id[1]; | ||
105 | dprintk(verbose, MANTIS_ERROR, 1, "Sub Vendor ID=[0x%04x]", | ||
106 | mantis->sub_vendor_id); | ||
107 | |||
108 | return 0; | ||
109 | } | ||
110 | |||
111 | static int get_mac_address(struct mantis_pci *mantis) | ||
112 | { | ||
113 | int err; | ||
114 | |||
115 | mantis->mac_address[0] = 0x08; | ||
116 | if ((err = read_eeprom_byte(mantis, &mantis->mac_address[0], 6)) < 0) { | ||
117 | dprintk(verbose, MANTIS_ERROR, 1, "Mantis EEPROM read error"); | ||
118 | |||
119 | return err; | ||
120 | } | ||
121 | dprintk(verbose, MANTIS_ERROR, 1, | ||
122 | "MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]", | ||
123 | mantis->mac_address[0], mantis->mac_address[1], | ||
124 | mantis->mac_address[2], mantis->mac_address[3], | ||
125 | mantis->mac_address[4], mantis->mac_address[5]); | ||
126 | |||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | |||
131 | int mantis_core_init(struct mantis_pci *mantis) | ||
132 | { | ||
133 | int err = 0; | ||
134 | |||
135 | if ((err = mantis_i2c_init(mantis)) < 0) { | ||
136 | dprintk(verbose, MANTIS_ERROR, 1, "Mantis I2C init failed"); | ||
137 | return err; | ||
138 | } | ||
139 | if ((err = get_mac_address(mantis)) < 0) { | ||
140 | dprintk(verbose, MANTIS_ERROR, 1, "get MAC address failed"); | ||
141 | return err; | ||
142 | } | ||
143 | if ((err = get_subvendor_id(mantis)) < 0) { | ||
144 | dprintk(verbose, MANTIS_ERROR, 1, "get Sub vendor ID failed"); | ||
145 | return err; | ||
146 | } | ||
147 | if ((err = get_subdevice_id(mantis)) < 0) { | ||
148 | dprintk(verbose, MANTIS_ERROR, 1, "get Sub device ID failed"); | ||
149 | return err; | ||
150 | } | ||
151 | if ((err = mantis_dma_init(mantis)) < 0) { | ||
152 | dprintk(verbose, MANTIS_ERROR, 1, "Mantis DMA init failed"); | ||
153 | return err; | ||
154 | } | ||
155 | if ((err = mantis_dvb_init(mantis)) < 0) { | ||
156 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis DVB init failed"); | ||
157 | return err; | ||
158 | } | ||
159 | |||
160 | return 0; | ||
161 | } | ||
162 | |||
163 | int mantis_core_exit(struct mantis_pci *mantis) | ||
164 | { | ||
165 | |||
166 | mantis_dma_stop(mantis); | ||
167 | dprintk(verbose, MANTIS_ERROR, 1, "DMA engine stopping"); | ||
168 | if (mantis_dma_exit(mantis) < 0) | ||
169 | dprintk(verbose, MANTIS_ERROR, 1, "DMA exit failed"); | ||
170 | if (mantis_dvb_exit(mantis) < 0) | ||
171 | dprintk(verbose, MANTIS_ERROR, 1, "DVB exit failed"); | ||
172 | if (mantis_i2c_exit(mantis) < 0) | ||
173 | dprintk(verbose, MANTIS_ERROR, 1, "I2C adapter delete.. failed"); | ||
174 | |||
175 | return 0; | ||
176 | } | ||
177 | |||
178 | void gpio_set_bits(struct mantis_pci *mantis, u32 bitpos, u8 value) | ||
179 | { | ||
180 | u32 reg; | ||
181 | |||
182 | if (value) | ||
183 | reg = 0x0000; | ||
184 | else | ||
185 | reg = 0xffff; | ||
186 | |||
187 | reg = (value << bitpos); | ||
188 | |||
189 | mmwrite(mmread(MANTIS_GPIF_ADDR) | reg, MANTIS_GPIF_ADDR); | ||
190 | mmwrite(0x00, MANTIS_GPIF_DOUT); | ||
191 | udelay(100); | ||
192 | mmwrite(mmread(MANTIS_GPIF_ADDR) | reg, MANTIS_GPIF_ADDR); | ||
193 | mmwrite(0x00, MANTIS_GPIF_DOUT); | ||
194 | } | ||
195 | |||
196 | |||
197 | //direction = 0 , no CI passthrough ; 1 , CI passthrough | ||
198 | void mantis_set_direction(struct mantis_pci *mantis, int direction) | ||
199 | { | ||
200 | u32 reg; | ||
201 | |||
202 | reg = mmread(0x28); | ||
203 | dprintk(verbose, MANTIS_DEBUG, 1, "TS direction setup"); | ||
204 | if (direction == 0x01) { //to CI | ||
205 | reg |= 0x04; | ||
206 | mmwrite(reg, 0x28); | ||
207 | reg &= 0xff - 0x04; | ||
208 | mmwrite(reg, 0x28); | ||
209 | } else { | ||
210 | reg &= 0xff - 0x04; | ||
211 | mmwrite(reg, 0x28); | ||
212 | reg |= 0x04; | ||
213 | mmwrite(reg, 0x28); | ||
214 | } | ||
215 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_core.h b/drivers/media/dvb/mantis/mantis_core.h new file mode 100644 index 000000000000..31b2a756d99e --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_core.h | |||
@@ -0,0 +1,61 @@ | |||
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_CORE_H | ||
22 | #define __MANTIS_CORE_H | ||
23 | |||
24 | #include "mantis_common.h" | ||
25 | |||
26 | |||
27 | #define FE_TYPE_SAT 0 | ||
28 | #define FE_TYPE_CAB 1 | ||
29 | #define FE_TYPE_TER 2 | ||
30 | |||
31 | #define FE_TYPE_TS204 0 | ||
32 | #define FE_TYPE_TS188 1 | ||
33 | |||
34 | |||
35 | struct vendorname { | ||
36 | __u8 *sub_vendor_name; | ||
37 | __u32 sub_vendor_id; | ||
38 | }; | ||
39 | |||
40 | struct devicetype { | ||
41 | __u8 *sub_device_name; | ||
42 | __u32 sub_device_id; | ||
43 | __u8 device_type; | ||
44 | __u32 type_flags; | ||
45 | }; | ||
46 | |||
47 | |||
48 | extern int mantis_dma_init(struct mantis_pci *mantis); | ||
49 | extern int mantis_dma_exit(struct mantis_pci *mantis); | ||
50 | extern void mantis_dma_start(struct mantis_pci *mantis); | ||
51 | extern void mantis_dma_stop(struct mantis_pci *mantis); | ||
52 | extern int mantis_i2c_init(struct mantis_pci *mantis); | ||
53 | extern int mantis_i2c_exit(struct mantis_pci *mantis); | ||
54 | extern int mantis_core_init(struct mantis_pci *mantis); | ||
55 | extern int mantis_core_exit(struct mantis_pci *mantis); | ||
56 | //extern void mantis_fe_powerup(struct mantis_pci *mantis); | ||
57 | //extern void mantis_fe_powerdown(struct mantis_pci *mantis); | ||
58 | //extern void mantis_fe_reset(struct dvb_frontend *fe); | ||
59 | extern void mantis_set_direction(struct mantis_pci *mantis, int direction); | ||
60 | |||
61 | #endif //__MANTIS_CORE_H | ||
diff --git a/drivers/media/dvb/mantis/mantis_dma.c b/drivers/media/dvb/mantis/mantis_dma.c new file mode 100644 index 000000000000..9e3aa5ec1645 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_dma.c | |||
@@ -0,0 +1,238 @@ | |||
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 | #include <asm/page.h> | ||
22 | #include <linux/vmalloc.h> | ||
23 | #include "mantis_common.h" | ||
24 | |||
25 | #define RISC_WRITE (0x01 << 28) | ||
26 | #define RISC_JUMP (0x07 << 28) | ||
27 | #define RISC_IRQ (0x01 << 24) | ||
28 | |||
29 | #define RISC_STATUS(status) ((((~status) & 0x0f) << 20) | ((status & 0x0f) << 16)) | ||
30 | #define RISC_FLUSH() mantis->risc_pos = 0 | ||
31 | #define RISC_INSTR(opcode) mantis->risc_cpu[mantis->risc_pos++] = cpu_to_le32(opcode) | ||
32 | |||
33 | #define MANTIS_BUF_SIZE 64 * 1024 | ||
34 | #define MANTIS_BLOCK_BYTES (MANTIS_BUF_SIZE >> 4) | ||
35 | #define MANTIS_BLOCK_COUNT (1 << 4) | ||
36 | #define MANTIS_RISC_SIZE PAGE_SIZE | ||
37 | |||
38 | int mantis_dma_exit(struct mantis_pci *mantis) | ||
39 | { | ||
40 | if (mantis->buf_cpu) { | ||
41 | dprintk(verbose, MANTIS_ERROR, 1, | ||
42 | "DMA=0x%lx cpu=0x%p size=%d", | ||
43 | (unsigned long) mantis->buf_dma, | ||
44 | mantis->buf_cpu, | ||
45 | MANTIS_BUF_SIZE); | ||
46 | |||
47 | pci_free_consistent(mantis->pdev, MANTIS_BUF_SIZE, | ||
48 | mantis->buf_cpu, mantis->buf_dma); | ||
49 | |||
50 | mantis->buf_cpu = NULL; | ||
51 | } | ||
52 | if (mantis->risc_cpu) { | ||
53 | dprintk(verbose, MANTIS_ERROR, 1, | ||
54 | "RISC=0x%lx cpu=0x%p size=%lx", | ||
55 | (unsigned long) mantis->risc_dma, | ||
56 | mantis->risc_cpu, | ||
57 | MANTIS_RISC_SIZE); | ||
58 | |||
59 | pci_free_consistent(mantis->pdev, MANTIS_RISC_SIZE, | ||
60 | mantis->risc_cpu, mantis->risc_dma); | ||
61 | |||
62 | mantis->risc_cpu = NULL; | ||
63 | } | ||
64 | |||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | static inline int mantis_alloc_buffers(struct mantis_pci *mantis) | ||
69 | { | ||
70 | if (!mantis->buf_cpu) { | ||
71 | mantis->buf_cpu = pci_alloc_consistent(mantis->pdev, | ||
72 | MANTIS_BUF_SIZE, | ||
73 | &mantis->buf_dma); | ||
74 | if (!mantis->buf_cpu) { | ||
75 | dprintk(verbose, MANTIS_ERROR, 1, | ||
76 | "DMA buffer allocation failed"); | ||
77 | |||
78 | goto err; | ||
79 | } | ||
80 | dprintk(verbose, MANTIS_ERROR, 1, | ||
81 | "DMA=0x%lx cpu=0x%p size=%d", | ||
82 | (unsigned long) mantis->buf_dma, | ||
83 | mantis->buf_cpu, MANTIS_BUF_SIZE); | ||
84 | } | ||
85 | if (!mantis->risc_cpu) { | ||
86 | mantis->risc_cpu = pci_alloc_consistent(mantis->pdev, | ||
87 | MANTIS_RISC_SIZE, | ||
88 | &mantis->risc_dma); | ||
89 | |||
90 | if (!mantis->risc_cpu) { | ||
91 | dprintk(verbose, MANTIS_ERROR, 1, | ||
92 | "RISC program allocation failed"); | ||
93 | |||
94 | mantis_dma_exit(mantis); | ||
95 | |||
96 | goto err; | ||
97 | } | ||
98 | dprintk(verbose, MANTIS_ERROR, 1, | ||
99 | "RISC=0x%lx cpu=0x%p size=%lx", | ||
100 | (unsigned long) mantis->risc_dma, | ||
101 | mantis->risc_cpu, MANTIS_RISC_SIZE); | ||
102 | } | ||
103 | |||
104 | return 0; | ||
105 | err: | ||
106 | dprintk(verbose, MANTIS_ERROR, 1, "Out of memory (?) ....."); | ||
107 | return -ENOMEM; | ||
108 | } | ||
109 | |||
110 | static inline int mantis_calc_lines(struct mantis_pci *mantis) | ||
111 | { | ||
112 | mantis->line_bytes = MANTIS_BLOCK_BYTES; | ||
113 | mantis->line_count = MANTIS_BLOCK_COUNT; | ||
114 | |||
115 | while (mantis->line_bytes > 4095) { | ||
116 | mantis->line_bytes >>= 1; | ||
117 | mantis->line_count <<= 1; | ||
118 | } | ||
119 | |||
120 | dprintk(verbose, MANTIS_DEBUG, 1, | ||
121 | "Mantis RISC block bytes=[%d], line bytes=[%d], line count=[%d]", | ||
122 | MANTIS_BLOCK_BYTES, mantis->line_bytes, mantis->line_count); | ||
123 | |||
124 | if (mantis->line_count > 255) { | ||
125 | dprintk(verbose, MANTIS_ERROR, 1, "Buffer size error"); | ||
126 | return -EINVAL; | ||
127 | } | ||
128 | |||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | int mantis_dma_init(struct mantis_pci *mantis) | ||
133 | { | ||
134 | int err = 0; | ||
135 | |||
136 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis DMA init"); | ||
137 | if (mantis_alloc_buffers(mantis) < 0) { | ||
138 | dprintk(verbose, MANTIS_ERROR, 1, "Error allocating DMA buffer"); | ||
139 | |||
140 | // Stop RISC Engine | ||
141 | // mmwrite(mmread(MANTIS_DMA_CTL) & ~MANTIS_RISC_EN, MANTIS_DMA_CTL); | ||
142 | mmwrite(0, MANTIS_DMA_CTL); | ||
143 | |||
144 | goto err; | ||
145 | } | ||
146 | if ((err = mantis_calc_lines(mantis)) < 0) { | ||
147 | dprintk(verbose, MANTIS_ERROR, 1, "Mantis calc lines failed"); | ||
148 | |||
149 | goto err; | ||
150 | } | ||
151 | |||
152 | return 0; | ||
153 | err: | ||
154 | return err; | ||
155 | } | ||
156 | |||
157 | |||
158 | |||
159 | static inline void mantis_risc_program(struct mantis_pci *mantis) | ||
160 | { | ||
161 | u32 buf_pos = 0; | ||
162 | u32 line; | ||
163 | |||
164 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis create RISC program"); | ||
165 | RISC_FLUSH(); | ||
166 | |||
167 | dprintk(verbose, MANTIS_DEBUG, 1, "risc len lines %u, bytes per line %u", | ||
168 | mantis->line_count, mantis->line_bytes); | ||
169 | |||
170 | for (line = 0; line < mantis->line_count; line++) { | ||
171 | dprintk(verbose, MANTIS_DEBUG, 1, "RISC PROG line=[%d]", line); | ||
172 | if (!(buf_pos % MANTIS_BLOCK_BYTES)) { | ||
173 | RISC_INSTR(RISC_WRITE | | ||
174 | RISC_IRQ | | ||
175 | RISC_STATUS(((buf_pos / MANTIS_BLOCK_BYTES) + | ||
176 | (MANTIS_BLOCK_COUNT - 1)) % | ||
177 | MANTIS_BLOCK_COUNT) | | ||
178 | mantis->line_bytes); | ||
179 | } else { | ||
180 | RISC_INSTR(RISC_WRITE | mantis->line_bytes); | ||
181 | } | ||
182 | RISC_INSTR(mantis->buf_dma + buf_pos); | ||
183 | buf_pos += mantis->line_bytes; | ||
184 | } | ||
185 | RISC_INSTR(RISC_JUMP); | ||
186 | RISC_INSTR(mantis->risc_dma); | ||
187 | } | ||
188 | |||
189 | void mantis_dma_start(struct mantis_pci *mantis) | ||
190 | { | ||
191 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Start DMA engine"); | ||
192 | |||
193 | mantis_risc_program(mantis); | ||
194 | mmwrite(cpu_to_le32(mantis->risc_dma), MANTIS_RISC_START); | ||
195 | mmwrite(MANTIS_GPIF_RDWRN, MANTIS_GPIF_ADDR); | ||
196 | |||
197 | mmwrite(0, MANTIS_DMA_CTL); | ||
198 | mantis->last_block = mantis->finished_block = 0; | ||
199 | |||
200 | mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_RISCI, MANTIS_INT_MASK); | ||
201 | |||
202 | mmwrite(MANTIS_FIFO_EN | MANTIS_DCAP_EN | ||
203 | | MANTIS_RISC_EN, MANTIS_DMA_CTL); | ||
204 | |||
205 | } | ||
206 | |||
207 | void mantis_dma_stop(struct mantis_pci *mantis) | ||
208 | { | ||
209 | u32 stat = 0, mask = 0; | ||
210 | |||
211 | stat = mmread(MANTIS_INT_STAT); | ||
212 | mask = mmread(MANTIS_INT_MASK); | ||
213 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Stop DMA engine"); | ||
214 | |||
215 | mmwrite((mmread(MANTIS_DMA_CTL) & ~(MANTIS_FIFO_EN | | ||
216 | MANTIS_DCAP_EN | | ||
217 | MANTIS_RISC_EN)), MANTIS_DMA_CTL); | ||
218 | |||
219 | mmwrite(mmread(MANTIS_INT_STAT), MANTIS_INT_STAT); | ||
220 | |||
221 | mmwrite(mmread(MANTIS_INT_MASK) & ~(MANTIS_INT_RISCI | | ||
222 | MANTIS_INT_RISCEN), MANTIS_INT_MASK); | ||
223 | } | ||
224 | |||
225 | |||
226 | void mantis_dma_xfer(unsigned long data) | ||
227 | { | ||
228 | struct mantis_pci *mantis = (struct mantis_pci *) data; | ||
229 | |||
230 | while (mantis->last_block != mantis->finished_block) { | ||
231 | dprintk(verbose, MANTIS_DEBUG, 1, "last block=[%d] finished block=[%d]", | ||
232 | mantis->last_block, mantis->finished_block); | ||
233 | |||
234 | (mantis->ts_size ? dvb_dmx_swfilter_204: dvb_dmx_swfilter) | ||
235 | (&mantis->demux, &mantis->buf_cpu[mantis->last_block * MANTIS_BLOCK_BYTES], MANTIS_BLOCK_BYTES); | ||
236 | mantis->last_block = (mantis->last_block + 1) % MANTIS_BLOCK_COUNT; | ||
237 | } | ||
238 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_dvb.c b/drivers/media/dvb/mantis/mantis_dvb.c new file mode 100644 index 000000000000..5830d4a7bda2 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_dvb.c | |||
@@ -0,0 +1,304 @@ | |||
1 | /* | ||
2 | Mantis PCI bridge driver | ||
3 | Copyright (C) 2005, 2006 Manu Abraham (abraham.manu@gmail.com) | ||
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 | #include <linux/bitops.h> | ||
21 | #include "mantis_common.h" | ||
22 | #include "mantis_core.h" | ||
23 | |||
24 | #include "dmxdev.h" | ||
25 | #include "dvbdev.h" | ||
26 | #include "dvb_demux.h" | ||
27 | #include "dvb_frontend.h" | ||
28 | #include "mantis_vp1033.h" | ||
29 | #include "mantis_vp1034.h" | ||
30 | #include "mantis_vp2033.h" | ||
31 | #include "mantis_vp3030.h" | ||
32 | |||
33 | /* Tuner power supply control */ | ||
34 | void mantis_fe_powerup(struct mantis_pci *mantis) | ||
35 | { | ||
36 | dprintk(verbose, MANTIS_DEBUG, 1, "Frontend Power ON"); | ||
37 | gpio_set_bits(mantis, 0x0c, 1); | ||
38 | msleep_interruptible(100); | ||
39 | gpio_set_bits(mantis, 0x0c, 1); | ||
40 | msleep_interruptible(100); | ||
41 | } | ||
42 | |||
43 | void mantis_fe_powerdown(struct mantis_pci *mantis) | ||
44 | { | ||
45 | dprintk(verbose, MANTIS_DEBUG, 1, "Frontend Power OFF"); | ||
46 | gpio_set_bits(mantis, 0x0c, 0); | ||
47 | } | ||
48 | |||
49 | static int mantis_fe_reset(struct dvb_frontend *fe) | ||
50 | { | ||
51 | struct mantis_pci *mantis = fe->dvb->priv; | ||
52 | |||
53 | dprintk(verbose, MANTIS_DEBUG, 1, "Frontend Reset"); | ||
54 | gpio_set_bits(mantis, 13, 0); | ||
55 | msleep_interruptible(100); | ||
56 | gpio_set_bits(mantis, 13, 0); | ||
57 | msleep_interruptible(100); | ||
58 | gpio_set_bits(mantis, 13, 1); | ||
59 | msleep_interruptible(100); | ||
60 | gpio_set_bits(mantis, 13, 1); | ||
61 | |||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | static int mantis_frontend_reset(struct mantis_pci *mantis) | ||
66 | { | ||
67 | dprintk(verbose, MANTIS_DEBUG, 1, "Frontend Reset"); | ||
68 | gpio_set_bits(mantis, 13, 0); | ||
69 | msleep_interruptible(100); | ||
70 | gpio_set_bits(mantis, 13, 0); | ||
71 | msleep_interruptible(100); | ||
72 | gpio_set_bits(mantis, 13, 1); | ||
73 | msleep_interruptible(100); | ||
74 | gpio_set_bits(mantis, 13, 1); | ||
75 | |||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static int mantis_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed) | ||
80 | { | ||
81 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; | ||
82 | struct mantis_pci *mantis = dvbdmx->priv; | ||
83 | |||
84 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis DVB Start feed"); | ||
85 | if (!dvbdmx->dmx.frontend) { | ||
86 | dprintk(verbose, MANTIS_DEBUG, 1, "no frontend ?"); | ||
87 | return -EINVAL; | ||
88 | } | ||
89 | mantis->feeds++; | ||
90 | dprintk(verbose, MANTIS_DEBUG, 1, | ||
91 | "mantis start feed, feeds=%d", | ||
92 | mantis->feeds); | ||
93 | |||
94 | if (mantis->feeds == 1) { | ||
95 | dprintk(verbose, MANTIS_DEBUG, 1, "mantis start feed & dma"); | ||
96 | printk("mantis start feed & dma\n"); | ||
97 | mantis_dma_start(mantis); | ||
98 | } | ||
99 | |||
100 | return mantis->feeds; | ||
101 | } | ||
102 | |||
103 | static int mantis_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) | ||
104 | { | ||
105 | struct dvb_demux *dvbdmx = dvbdmxfeed->demux; | ||
106 | struct mantis_pci *mantis = dvbdmx->priv; | ||
107 | |||
108 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis DVB Stop feed"); | ||
109 | if (!dvbdmx->dmx.frontend) { | ||
110 | dprintk(verbose, MANTIS_DEBUG, 1, "no frontend ?"); | ||
111 | return -EINVAL; | ||
112 | } | ||
113 | mantis->feeds--; | ||
114 | if (mantis->feeds == 0) { | ||
115 | dprintk(verbose, MANTIS_DEBUG, 1, "mantis stop feed and dma"); | ||
116 | printk("mantis stop feed and dma\n"); | ||
117 | mantis_dma_stop(mantis); | ||
118 | } | ||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | int __devinit mantis_dvb_init(struct mantis_pci *mantis) | ||
123 | { | ||
124 | int result; | ||
125 | |||
126 | dprintk(verbose, MANTIS_DEBUG, 1, "dvb_register_adapter"); | ||
127 | if (dvb_register_adapter(&mantis->dvb_adapter, | ||
128 | "Mantis dvb adapter", THIS_MODULE, | ||
129 | &mantis->pdev->dev) < 0) { | ||
130 | |||
131 | dprintk(verbose, MANTIS_ERROR, 1, "Error registering adapter"); | ||
132 | return -ENODEV; | ||
133 | } | ||
134 | mantis->dvb_adapter.priv = mantis; | ||
135 | mantis->demux.dmx.capabilities = DMX_TS_FILTERING | | ||
136 | DMX_SECTION_FILTERING | | ||
137 | DMX_MEMORY_BASED_FILTERING; | ||
138 | |||
139 | mantis->demux.priv = mantis; | ||
140 | mantis->demux.filternum = 256; | ||
141 | mantis->demux.feednum = 256; | ||
142 | mantis->demux.start_feed = mantis_dvb_start_feed; | ||
143 | mantis->demux.stop_feed = mantis_dvb_stop_feed; | ||
144 | mantis->demux.write_to_decoder = NULL; | ||
145 | mantis->ts_size = 1; //188 | ||
146 | dprintk(verbose, MANTIS_DEBUG, 1, "dvb_dmx_init"); | ||
147 | if ((result = dvb_dmx_init(&mantis->demux)) < 0) { | ||
148 | dprintk(verbose, MANTIS_ERROR, 1, | ||
149 | "dvb_dmx_init failed, ERROR=%d", result); | ||
150 | |||
151 | goto err0; | ||
152 | } | ||
153 | mantis->dmxdev.filternum = 256; | ||
154 | mantis->dmxdev.demux = &mantis->demux.dmx; | ||
155 | mantis->dmxdev.capabilities = 0; | ||
156 | dprintk(verbose, MANTIS_DEBUG, 1, "dvb_dmxdev_init"); | ||
157 | if ((result = dvb_dmxdev_init(&mantis->dmxdev, | ||
158 | &mantis->dvb_adapter)) < 0) { | ||
159 | |||
160 | dprintk(verbose, MANTIS_ERROR, 1, | ||
161 | "dvb_dmxdev_init failed, ERROR=%d", result); | ||
162 | goto err1; | ||
163 | } | ||
164 | mantis->fe_hw.source = DMX_FRONTEND_0; | ||
165 | if ((result = mantis->demux.dmx.add_frontend(&mantis->demux.dmx, | ||
166 | &mantis->fe_hw)) < 0) { | ||
167 | |||
168 | dprintk(verbose, MANTIS_ERROR, 1, | ||
169 | "dvb_dmx_init failed, ERROR=%d", result); | ||
170 | |||
171 | goto err2; | ||
172 | } | ||
173 | mantis->fe_mem.source = DMX_MEMORY_FE; | ||
174 | if ((result = mantis->demux.dmx.add_frontend(&mantis->demux.dmx, | ||
175 | &mantis->fe_mem)) < 0) { | ||
176 | dprintk(verbose, MANTIS_ERROR, 1, | ||
177 | "dvb_dmx_init failed, ERROR=%d", result); | ||
178 | |||
179 | goto err3; | ||
180 | } | ||
181 | if ((result = mantis->demux.dmx.connect_frontend(&mantis->demux.dmx, | ||
182 | &mantis->fe_hw)) < 0) { | ||
183 | |||
184 | dprintk(verbose, MANTIS_ERROR, 1, | ||
185 | "dvb_dmx_init failed, ERROR=%d", result); | ||
186 | |||
187 | goto err4; | ||
188 | } | ||
189 | dvb_net_init(&mantis->dvb_adapter, &mantis->dvbnet, &mantis->demux.dmx); | ||
190 | tasklet_init(&mantis->tasklet, mantis_dma_xfer, (unsigned long) mantis); | ||
191 | mantis_frontend_init(mantis); | ||
192 | return 0; | ||
193 | |||
194 | /* Error conditions .. */ | ||
195 | err4: | ||
196 | mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_mem); | ||
197 | err3: | ||
198 | mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_hw); | ||
199 | err2: | ||
200 | dvb_dmxdev_release(&mantis->dmxdev); | ||
201 | err1: | ||
202 | dvb_dmx_release(&mantis->demux); | ||
203 | err0: | ||
204 | dvb_unregister_adapter(&mantis->dvb_adapter); | ||
205 | |||
206 | return result; | ||
207 | } | ||
208 | |||
209 | #define MANTIS_VP_1027_DVB_S 0x0013 | ||
210 | #define MANTIS_VP_1033_DVB_S 0x0016 | ||
211 | #define MANTIS_VP_1034_DVB_S 0x0014 | ||
212 | #define MANTIS_VP_1040_DVB_S2 | ||
213 | #define MANTIS_VP_1041_DVB_S2 | ||
214 | #define MANTIS_VP_2033_DVB_C 0x0008 | ||
215 | #define MANTIS_VP_3024_DVB_T 0x0009 | ||
216 | #define MANTIS_VP_3030_DVB_T 0x0024 | ||
217 | |||
218 | int __devinit mantis_frontend_init(struct mantis_pci *mantis) | ||
219 | { | ||
220 | dprintk(verbose, MANTIS_DEBUG, 1, "Mantis frontend Init"); | ||
221 | mantis_fe_powerup(mantis); | ||
222 | mantis_frontend_reset(mantis); | ||
223 | dprintk(verbose, MANTIS_DEBUG, 1, "Device ID=%02x", mantis->sub_device_id); | ||
224 | switch (mantis->sub_device_id) { | ||
225 | case MANTIS_VP_1033_DVB_S: // VP-1033 | ||
226 | dprintk(verbose, MANTIS_ERROR, 1, "Probing for STV0299 (DVB-S)"); | ||
227 | mantis->fe = stv0299_attach(&lgtdqcs001f_config, | ||
228 | &mantis->adapter); | ||
229 | |||
230 | if (mantis->fe) { | ||
231 | mantis->fe->ops.tuner_ops.set_params = lgtdqcs001f_tuner_set; | ||
232 | dprintk(verbose, MANTIS_ERROR, 1, | ||
233 | "found STV0299 DVB-S frontend @ 0x%02x", | ||
234 | lgtdqcs001f_config.demod_address); | ||
235 | |||
236 | dprintk(verbose, MANTIS_ERROR, 1, | ||
237 | "Mantis DVB-S STV0299 frontend attach success"); | ||
238 | } | ||
239 | break; | ||
240 | case MANTIS_VP_1034_DVB_S: // VP-1034 | ||
241 | dprintk(verbose, MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)"); | ||
242 | mantis->fe = mb86a16_attach(&vp1034_config, &mantis->adapter); | ||
243 | if (mantis->fe) { | ||
244 | dprintk(verbose, MANTIS_ERROR, 1, | ||
245 | "found MB86A16 DVB-S/DSS frontend @0x%02x", | ||
246 | vp1034_config.demod_address); | ||
247 | |||
248 | } | ||
249 | break; | ||
250 | case MANTIS_VP_2033_DVB_C: // VP-2033 | ||
251 | dprintk(verbose, MANTIS_ERROR, 1, "Probing for CU1216 (DVB-C)"); | ||
252 | mantis->fe = cu1216_attach(&philips_cu1216_config, &mantis->adapter); | ||
253 | if (mantis->fe) { | ||
254 | mantis->fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set; | ||
255 | dprintk(verbose, MANTIS_ERROR, 1, | ||
256 | "found Philips CU1216 DVB-C frontend @ 0x%02x", | ||
257 | philips_cu1216_config.demod_address); | ||
258 | |||
259 | dprintk(verbose, MANTIS_ERROR, 1, | ||
260 | "Mantis DVB-C Philips CU1216 frontend attach success"); | ||
261 | |||
262 | } | ||
263 | break; | ||
264 | default: | ||
265 | dprintk(verbose, MANTIS_DEBUG, 1, "Unknown frontend:[0x%02x]", | ||
266 | mantis->sub_device_id); | ||
267 | |||
268 | return -ENODEV; | ||
269 | } | ||
270 | if (mantis->fe == NULL) { | ||
271 | dprintk(verbose, MANTIS_ERROR, 1, "!!! NO Frontends found !!!"); | ||
272 | return -ENODEV; | ||
273 | } else { | ||
274 | if (dvb_register_frontend(&mantis->dvb_adapter, mantis->fe)) { | ||
275 | dprintk(verbose, MANTIS_ERROR, 1, | ||
276 | "ERROR: Frontend registration failed"); | ||
277 | |||
278 | if (mantis->fe->ops.release) | ||
279 | mantis->fe->ops.release(mantis->fe); | ||
280 | |||
281 | mantis->fe = NULL; | ||
282 | return -ENODEV; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | return 0; | ||
287 | } | ||
288 | |||
289 | int __devexit mantis_dvb_exit(struct mantis_pci *mantis) | ||
290 | { | ||
291 | tasklet_kill(&mantis->tasklet); | ||
292 | dvb_net_release(&mantis->dvbnet); | ||
293 | mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_mem); | ||
294 | mantis->demux.dmx.remove_frontend(&mantis->demux.dmx, &mantis->fe_hw); | ||
295 | dvb_dmxdev_release(&mantis->dmxdev); | ||
296 | dvb_dmx_release(&mantis->demux); | ||
297 | |||
298 | if (mantis->fe) | ||
299 | dvb_unregister_frontend(mantis->fe); | ||
300 | dprintk(verbose, MANTIS_DEBUG, 1, "dvb_unregister_adapter"); | ||
301 | dvb_unregister_adapter(&mantis->dvb_adapter); | ||
302 | |||
303 | return 0; | ||
304 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_i2c.c b/drivers/media/dvb/mantis/mantis_i2c.c new file mode 100644 index 000000000000..cfecb344bb7a --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_i2c.c | |||
@@ -0,0 +1,189 @@ | |||
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 | #include <linux/module.h> | ||
22 | #include <linux/moduleparam.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/delay.h> | ||
25 | #include <asm/io.h> | ||
26 | #include <linux/ioport.h> | ||
27 | #include <asm/pgtable.h> | ||
28 | #include <asm/page.h> | ||
29 | #include "mantis_common.h" | ||
30 | |||
31 | #define I2C_HW_B_MANTIS 0x1c | ||
32 | |||
33 | static int mantis_ack_wait(struct mantis_pci *mantis) | ||
34 | { | ||
35 | int rc = 0; | ||
36 | |||
37 | if (wait_event_interruptible_timeout(mantis->i2c_wq, | ||
38 | mantis->mantis_int_stat & MANTIS_INT_I2CRACK, | ||
39 | msecs_to_jiffies(50)) == -ERESTARTSYS) | ||
40 | |||
41 | rc = -EREMOTEIO; | ||
42 | /* | ||
43 | // Wait till we are done | ||
44 | while (mantis->mantis_int_stat & MANTIS_INT_I2CRACK){ | ||
45 | if (mantis->mantis_int_stat & MANTIS_INT_I2CDONE) { | ||
46 | mantis->mantis_int_stat &= ~MANTIS_INT_I2CRACK; | ||
47 | // dprintk(verbose, MANTIS_DEBUG, 1, "SLAVE RACK 'ed .. Waiting for I2CDONE"); | ||
48 | break; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | if (mantis->mantis_int_stat & MANTIS_INT_I2CDONE) { | ||
53 | // dprintk(verbose, MANTIS_DEBUG, 1, "Mantis Int I2CDONE"); | ||
54 | rc = 1; | ||
55 | } | ||
56 | |||
57 | mantis->mantis_int_stat &= ~MANTIS_INT_I2CDONE; | ||
58 | */ | ||
59 | // .. | ||
60 | if (mantis->mantis_int_stat & MANTIS_INT_I2CRACK) | ||
61 | msleep_interruptible(10); | ||
62 | |||
63 | return rc; | ||
64 | } | ||
65 | |||
66 | static int mantis_i2c_read(struct mantis_pci *mantis, const struct i2c_msg *msg) | ||
67 | { | ||
68 | u32 rxd, i; | ||
69 | |||
70 | dprintk(verbose, MANTIS_DEBUG, 1, "Address=[0x%02x]", msg->addr); | ||
71 | for (i = 0; i < msg->len; i++) { | ||
72 | rxd = (msg->addr << 25) | (1 << 24) | ||
73 | | MANTIS_I2C_RATE_3 | ||
74 | | MANTIS_I2C_STOP | ||
75 | | MANTIS_I2C_PGMODE; | ||
76 | |||
77 | if (i == (msg->len - 1)) | ||
78 | rxd &= ~MANTIS_I2C_STOP; | ||
79 | |||
80 | mmwrite(rxd, MANTIS_I2CDATA_CTL); | ||
81 | if (mantis_ack_wait(mantis) < 0) { | ||
82 | dprintk(verbose, MANTIS_DEBUG, 1, "ACK failed<R>"); | ||
83 | return -EIO; | ||
84 | } | ||
85 | rxd = mmread(MANTIS_I2CDATA_CTL); | ||
86 | msg->buf[i] = (u8)((rxd >> 8) & 0xFF); | ||
87 | dprintk(verbose, MANTIS_DEBUG, 1, | ||
88 | "Data<R[%d]>=[0x%02x]", i, msg->buf[i]); | ||
89 | |||
90 | msleep_interruptible(2); | ||
91 | } | ||
92 | |||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static int mantis_i2c_write(struct mantis_pci *mantis, const struct i2c_msg *msg) | ||
97 | { | ||
98 | int i; | ||
99 | u32 txd = 0; | ||
100 | |||
101 | dprintk(verbose, MANTIS_DEBUG, 1, "Address=[0x%02x]", msg->addr); | ||
102 | for (i = 0; i < msg->len; i++) { | ||
103 | dprintk(verbose, MANTIS_DEBUG, 1, "Data<W[%d]>=[0x%02x]", i, msg->buf[i]); | ||
104 | txd = (msg->addr << 25) | (msg->buf[i] << 8) | ||
105 | | MANTIS_I2C_RATE_3 | ||
106 | | MANTIS_I2C_STOP | ||
107 | | MANTIS_I2C_PGMODE; | ||
108 | |||
109 | if (i == (msg->len - 1)) | ||
110 | txd &= ~MANTIS_I2C_STOP; | ||
111 | |||
112 | mmwrite(txd, MANTIS_I2CDATA_CTL); | ||
113 | if (mantis_ack_wait(mantis) < 0) { | ||
114 | dprintk(verbose, MANTIS_DEBUG, 1, "ACK failed<W>"); | ||
115 | return -1; | ||
116 | } | ||
117 | udelay(500); | ||
118 | } | ||
119 | |||
120 | return 0; | ||
121 | } | ||
122 | |||
123 | static int mantis_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) | ||
124 | { | ||
125 | int ret = 0, i; | ||
126 | struct mantis_pci *mantis; | ||
127 | |||
128 | mantis = i2c_get_adapdata(adapter); | ||
129 | for (i = 0; i < num; i++) { | ||
130 | if (msgs[i].flags & I2C_M_RD) | ||
131 | ret = mantis_i2c_read(mantis, &msgs[i]); | ||
132 | else | ||
133 | ret = mantis_i2c_write(mantis, &msgs[i]); | ||
134 | |||
135 | if (ret < 0) | ||
136 | return ret; | ||
137 | } | ||
138 | |||
139 | return num; | ||
140 | } | ||
141 | |||
142 | static u32 mantis_i2c_func(struct i2c_adapter *adapter) | ||
143 | { | ||
144 | return I2C_FUNC_SMBUS_EMUL; | ||
145 | } | ||
146 | |||
147 | static struct i2c_algorithm mantis_algo = { | ||
148 | .master_xfer = mantis_i2c_xfer, | ||
149 | .functionality = mantis_i2c_func, | ||
150 | }; | ||
151 | |||
152 | static struct i2c_adapter mantis_i2c_adapter = { | ||
153 | .owner = THIS_MODULE, | ||
154 | .name = "Mantis I2C", | ||
155 | .id = I2C_HW_B_MANTIS, | ||
156 | .class = I2C_CLASS_TV_DIGITAL, | ||
157 | .algo = &mantis_algo, | ||
158 | }; | ||
159 | |||
160 | int __devinit mantis_i2c_init(struct mantis_pci *mantis) | ||
161 | { | ||
162 | u32 intstat; | ||
163 | |||
164 | memcpy(&mantis->adapter, &mantis_i2c_adapter, sizeof (mantis_i2c_adapter)); | ||
165 | i2c_set_adapdata(&mantis->adapter, mantis); | ||
166 | mantis->i2c_rc = i2c_add_adapter(&mantis->adapter); | ||
167 | if (mantis->i2c_rc < 0) | ||
168 | return mantis->i2c_rc; | ||
169 | |||
170 | dprintk(verbose, MANTIS_DEBUG, 1, "Initializing I2C .."); | ||
171 | |||
172 | // Clear all interrupts | ||
173 | intstat = mmread(MANTIS_INT_STAT); | ||
174 | mmwrite(intstat, MANTIS_INT_STAT); | ||
175 | |||
176 | mmwrite(mmread(MANTIS_INT_MASK) | MANTIS_INT_I2CDONE, | ||
177 | MANTIS_INT_MASK); | ||
178 | |||
179 | dprintk(verbose, MANTIS_DEBUG, 1, "[0x%08x/%08x]", | ||
180 | mmread(MANTIS_INT_STAT), mmread(MANTIS_INT_MASK)); | ||
181 | |||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | int __devexit mantis_i2c_exit(struct mantis_pci *mantis) | ||
186 | { | ||
187 | dprintk(verbose, MANTIS_DEBUG, 1, "Removing I2C adapter"); | ||
188 | return i2c_del_adapter(&mantis->adapter); | ||
189 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_reg.h b/drivers/media/dvb/mantis/mantis_reg.h new file mode 100644 index 000000000000..1b54e09fd862 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_reg.h | |||
@@ -0,0 +1,109 @@ | |||
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_REG_H | ||
22 | #define __MANTIS_REG_H | ||
23 | |||
24 | // Interrupts | ||
25 | #define MANTIS_INT_STAT 0x00 | ||
26 | #define MANTIS_INT_MASK 0x04 | ||
27 | |||
28 | #define MANTIS_INT_RISCSTAT (0x0f << 28) | ||
29 | #define MANTIS_INT_RISCEN (0x01 << 27) | ||
30 | #define MANTIS_INT_I2CRACK (0x01 << 26) | ||
31 | |||
32 | //#define MANTIS_INT_GPIF (0xff << 12) | ||
33 | |||
34 | #define MANTIS_INT_PCMCIA7 (0x01 << 19) | ||
35 | #define MANTIS_INT_PCMCIA6 (0x01 << 18) | ||
36 | #define MANTIS_INT_PCMCIA5 (0x01 << 17) | ||
37 | #define MANTIS_INT_PCMCIA4 (0x01 << 16) | ||
38 | #define MANTIS_INT_PCMCIA3 (0x01 << 15) | ||
39 | #define MANTIS_INT_PCMCIA2 (0x01 << 14) | ||
40 | #define MANTIS_INT_PCMCIA1 (0x01 << 13) | ||
41 | #define MANTIS_INT_PCMCIA0 (0x01 << 12) | ||
42 | #define MANTIS_INT_IRQ1 (0x01 << 11) | ||
43 | #define MANTIS_INT_IRQ0 (0x01 << 10) | ||
44 | #define MANTIS_INT_OCERR (0x01 << 8) | ||
45 | #define MANTIS_INT_PABORT (0x01 << 7) | ||
46 | #define MANTIS_INT_RIPERR (0x01 << 6) | ||
47 | #define MANTIS_INT_PPERR (0x01 << 5) | ||
48 | #define MANTIS_INT_FTRGT (0x01 << 3) | ||
49 | #define MANTIS_INT_RISCI (0x01 << 1) | ||
50 | #define MANTIS_INT_I2CDONE (0x01 << 0) | ||
51 | |||
52 | // DMA | ||
53 | #define MANTIS_DMA_CTL 0x08 | ||
54 | #define MANTIS_I2C_RD (0x01 << 7) | ||
55 | #define MANTIS_I2C_WR (0x01 << 6) | ||
56 | #define MANTIS_DCAP_MODE (0x01 << 5) | ||
57 | #define MANTIS_FIFO_TP_4 (0x00 << 3) | ||
58 | #define MANTIS_FIFO_TP_8 (0x01 << 3) | ||
59 | #define MANTIS_FIFO_TP_16 (0x02 << 3) | ||
60 | #define MANTIS_FIFO_EN (0x01 << 2) | ||
61 | #define MANTIS_DCAP_EN (0x01 << 1) | ||
62 | #define MANTIS_RISC_EN (0x01 << 0) | ||
63 | |||
64 | #define MANTIS_RISC_START 0x10 | ||
65 | #define MANTIS_RISC_PC 0x14 | ||
66 | |||
67 | // I2C | ||
68 | #define MANTIS_I2CDATA_CTL 0x18 | ||
69 | #define MANTIS_I2C_RATE_1 (0x00 << 6) | ||
70 | #define MANTIS_I2C_RATE_2 (0x01 << 6) | ||
71 | #define MANTIS_I2C_RATE_3 (0x02 << 6) | ||
72 | #define MANTIS_I2C_RATE_4 (0x03 << 6) | ||
73 | #define MANTIS_I2C_STOP (0x01 << 5) | ||
74 | #define MANTIS_I2C_PGMODE (0x01 << 3) | ||
75 | |||
76 | #define MANTIS_GPIF_IRQCFG 0x98 | ||
77 | #define MANTIS_GPIF_IRQPOL (0x01 << 8) | ||
78 | #define MANTIS_MASK_WRACK (0x01 << 7) | ||
79 | #define MANTIS_MASK_BRRDY (0x01 << 6) | ||
80 | #define MANTIS_MASK_OVFLW (0x01 << 5) | ||
81 | #define MANTIS_MASK_OTHERR (0x01 << 4) | ||
82 | #define MANTIS_MASK_WSTO (0x01 << 3) | ||
83 | #define MANTIS_MASK_EXTIRQ (0x01 << 2) | ||
84 | #define MANTIS_MASK_PLUGIN (0x01 << 1) | ||
85 | #define MANTIS_MASK_PLUGOUT (0x01 << 0) | ||
86 | |||
87 | #define MANTIS_GPIF_STATUS 0x9c | ||
88 | #define MANTIS_SBUF_KILLOP (0x01 << 15) | ||
89 | #define MANTIS_SBUF_OPDONE (0x01 << 14) | ||
90 | #define MANTIS_SBUF_EMPTY (0x01 << 13) | ||
91 | #define MANTIS_GPIF_DETSTAT (0x01 << 9) | ||
92 | #define MANTIS_GPIF_INTSTAT (0x01 << 8) | ||
93 | #define MANTIS_GPIF_WRACK (0x01 << 7) | ||
94 | #define MANTIS_GPIF_BRRDY (0x01 << 6) | ||
95 | #define MANTIS_SBUF_OVFLW (0x01 << 5) | ||
96 | #define MANTIS_GPIF_OTHERR (0x01 << 4) | ||
97 | #define MANTIS_SBUF_WSTO (0x01 << 3) | ||
98 | #define MANTIS_GPIF_EXTIRQ (0x01 << 2) | ||
99 | #define MANTIS_CARD_PLUGIN (0x01 << 1) | ||
100 | #define MANTIS_CARD_PLUGOUT (0x01 << 0) | ||
101 | |||
102 | #define MANTIS_GPIF_ADDR 0xb0 | ||
103 | #define MANTIS_GPIF_RDWRN (0x01 << 31) | ||
104 | |||
105 | #define MANTIS_GPIF_DOUT 0xb4 | ||
106 | #define MANTIS_GPIF_DIN 0xb8 | ||
107 | |||
108 | |||
109 | #endif //__MANTIS_REG_H | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp1033.c b/drivers/media/dvb/mantis/mantis_vp1033.c new file mode 100644 index 000000000000..720f4fb7e925 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp1033.c | |||
@@ -0,0 +1,151 @@ | |||
1 | /* | ||
2 | Mantis VP-1033 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 | #include "mantis_common.h" | ||
22 | #include "mantis_vp1033.h" | ||
23 | |||
24 | u8 lgtdqcs001f_inittab[] = { | ||
25 | 0x01, 0x15, | ||
26 | 0x02, 0x00, | ||
27 | 0x03, 0x00, | ||
28 | 0x04, 0x2a, | ||
29 | 0x05, 0x85, | ||
30 | 0x06, 0x02, | ||
31 | 0x07, 0x00, | ||
32 | 0x08, 0x00, | ||
33 | 0x0c, 0x01, | ||
34 | 0x0d, 0x81, | ||
35 | 0x0e, 0x44, | ||
36 | 0x0f, 0x94, | ||
37 | 0x10, 0x3c, | ||
38 | 0x11, 0x84, | ||
39 | 0x12, 0xb9, | ||
40 | 0x13, 0xb5, | ||
41 | 0x14, 0x4f, | ||
42 | 0x15, 0xc9, | ||
43 | 0x16, 0x80, | ||
44 | 0x17, 0x36, | ||
45 | 0x18, 0xfb, | ||
46 | 0x19, 0xcf, | ||
47 | 0x1a, 0xbc, | ||
48 | 0x1c, 0x2b, | ||
49 | 0x1d, 0x27, | ||
50 | 0x1e, 0x00, | ||
51 | 0x1f, 0x0b, | ||
52 | 0x20, 0xa1, | ||
53 | 0x21, 0x60, | ||
54 | 0x22, 0x00, | ||
55 | 0x23, 0x00, | ||
56 | 0x28, 0x00, | ||
57 | 0x29, 0x28, | ||
58 | 0x2a, 0x14, | ||
59 | 0x2b, 0x0f, | ||
60 | 0x2c, 0x09, | ||
61 | 0x2d, 0x05, | ||
62 | 0x31, 0x1f, | ||
63 | 0x32, 0x19, | ||
64 | 0x33, 0xfc, | ||
65 | 0x34, 0x13, | ||
66 | 0xff, 0xff, | ||
67 | }; | ||
68 | |||
69 | struct stv0299_config lgtdqcs001f_config = { | ||
70 | .demod_address = 0x68, | ||
71 | .inittab = lgtdqcs001f_inittab, | ||
72 | .mclk = 88000000UL, | ||
73 | // .invert = 0, | ||
74 | .invert = 1, | ||
75 | // .enhanced_tuning = 0, | ||
76 | .skip_reinit = 0, | ||
77 | .lock_output = STV0229_LOCKOUTPUT_0, | ||
78 | .volt13_op0_op1 = STV0299_VOLT13_OP0, | ||
79 | .min_delay_ms = 100, | ||
80 | .set_symbol_rate = lgtdqcs001f_set_symbol_rate, | ||
81 | // .pll_set = lgtdqcs001f_pll_set, | ||
82 | }; | ||
83 | |||
84 | int lgtdqcs001f_tuner_set(struct dvb_frontend *fe, | ||
85 | struct dvb_frontend_parameters *params) | ||
86 | { | ||
87 | u8 buf[4]; | ||
88 | u32 div; | ||
89 | |||
90 | struct mantis_pci *mantis = fe->dvb->priv; | ||
91 | |||
92 | struct i2c_msg msg = { | ||
93 | .addr = 0x61, | ||
94 | .flags = 0, | ||
95 | .buf = buf, | ||
96 | .len = sizeof (buf) | ||
97 | }; | ||
98 | div = params->frequency / 250; | ||
99 | |||
100 | buf[0] = (div >> 8) & 0x7f; | ||
101 | buf[1] = div & 0xff; | ||
102 | buf[2] = 0x83; | ||
103 | buf[3] = 0xc0; | ||
104 | |||
105 | if (params->frequency < 1531000) | ||
106 | buf[3] |= 0x04; | ||
107 | else | ||
108 | buf[3] &= ~0x04; | ||
109 | if (i2c_transfer(&mantis->adapter, &msg, 1) < 0) { | ||
110 | dprintk(verbose, MANTIS_ERROR, 1, "Write: I2C Transfer failed"); | ||
111 | return -EIO; | ||
112 | } | ||
113 | msleep_interruptible(100); | ||
114 | |||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | int lgtdqcs001f_set_symbol_rate(struct dvb_frontend *fe, | ||
119 | u32 srate, u32 ratio) | ||
120 | { | ||
121 | u8 aclk = 0; | ||
122 | u8 bclk = 0; | ||
123 | |||
124 | if (srate < 1500000) { | ||
125 | aclk = 0xb7; | ||
126 | bclk = 0x47; | ||
127 | } else if (srate < 3000000) { | ||
128 | aclk = 0xb7; | ||
129 | bclk = 0x4b; | ||
130 | } else if (srate < 7000000) { | ||
131 | aclk = 0xb7; | ||
132 | bclk = 0x4f; | ||
133 | } else if (srate < 14000000) { | ||
134 | aclk = 0xb7; | ||
135 | bclk = 0x53; | ||
136 | } else if (srate < 30000000) { | ||
137 | aclk = 0xb6; | ||
138 | bclk = 0x53; | ||
139 | } else if (srate < 45000000) { | ||
140 | aclk = 0xb4; | ||
141 | bclk = 0x51; | ||
142 | } | ||
143 | stv0299_writereg (fe, 0x13, aclk); | ||
144 | stv0299_writereg (fe, 0x14, bclk); | ||
145 | |||
146 | stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff); | ||
147 | stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff); | ||
148 | stv0299_writereg (fe, 0x21, (ratio ) & 0xf0); | ||
149 | |||
150 | return 0; | ||
151 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp1033.h b/drivers/media/dvb/mantis/mantis_vp1033.h new file mode 100644 index 000000000000..d50f09233ffb --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp1033.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | Mantis VP-1033 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_VP1033_H | ||
22 | #define __MANTIS_VP1033_H | ||
23 | |||
24 | #include "stv0299.h" | ||
25 | #include "dvb_frontend.h" | ||
26 | |||
27 | extern struct stv0299_config lgtdqcs001f_config; | ||
28 | |||
29 | extern int lgtdqcs001f_tuner_set(struct dvb_frontend *fe, | ||
30 | struct dvb_frontend_parameters *params); | ||
31 | |||
32 | extern int lgtdqcs001f_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio); | ||
33 | |||
34 | |||
35 | #endif // __MANTIS_VP1033_H | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp1034.c b/drivers/media/dvb/mantis/mantis_vp1034.c new file mode 100644 index 000000000000..b85ac29691d0 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp1034.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | Mantis VP-1034 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 | #include "mantis_common.h" | ||
22 | #include "mantis_vp1034.h" | ||
23 | |||
24 | struct mb86a16_config vp1034_config = { | ||
25 | .demod_address = 0x08, | ||
26 | .set_voltage = vp1034_set_voltage, | ||
27 | }; | ||
28 | |||
29 | int vp1034_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) | ||
30 | { | ||
31 | struct mantis_pci *mantis = fe->dvb->priv; | ||
32 | |||
33 | switch (voltage) { | ||
34 | case SEC_VOLTAGE_13: | ||
35 | mmwrite((mmread(MANTIS_GPIF_ADDR)) | voltage, MANTIS_GPIF_ADDR); | ||
36 | dprintk(verbose, MANTIS_ERROR, 1, "Polarization=[13V]"); | ||
37 | break; | ||
38 | case SEC_VOLTAGE_18: | ||
39 | mmwrite((mmread(MANTIS_GPIF_ADDR)) & voltage, MANTIS_GPIF_ADDR); | ||
40 | dprintk(verbose, MANTIS_ERROR, 1, "Polarization=[18V]"); | ||
41 | break; | ||
42 | case SEC_VOLTAGE_OFF: | ||
43 | dprintk(verbose, MANTIS_ERROR, 1, "Frontend (dummy) POWERDOWN"); | ||
44 | break; | ||
45 | default: | ||
46 | dprintk(verbose, MANTIS_ERROR, 1, "Invalid = (%d)", (u32 ) voltage); | ||
47 | return -EINVAL; | ||
48 | } | ||
49 | mmwrite(0x00, MANTIS_GPIF_DOUT); | ||
50 | |||
51 | return 0; | ||
52 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp1034.h b/drivers/media/dvb/mantis/mantis_vp1034.h new file mode 100644 index 000000000000..2324dada09de --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp1034.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | Mantis VP-1034 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_VP1034_H | ||
22 | #define __MANTIS_VP1034_H | ||
23 | |||
24 | #include "mb86a16.h" | ||
25 | #include "dvb_frontend.h" | ||
26 | |||
27 | extern struct mb86a16_config vp1034_config; | ||
28 | extern int vp1034_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage); | ||
29 | |||
30 | #endif // __MANTIS_VP1034_H | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp2033.c b/drivers/media/dvb/mantis/mantis_vp2033.c new file mode 100644 index 000000000000..bca9ebaf39d7 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp2033.c | |||
@@ -0,0 +1,73 @@ | |||
1 | /* | ||
2 | Mantis VP-2033 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 | #include "mantis_common.h" | ||
22 | #include "mantis_vp2033.h" | ||
23 | |||
24 | struct tda10021_state { | ||
25 | struct i2c_adapter *i2c; | ||
26 | struct dvb_frontend_ops ops; | ||
27 | /* configuration settings */ | ||
28 | const struct tda10021_config *config; | ||
29 | struct dvb_frontend frontend; | ||
30 | |||
31 | u8 pwm; | ||
32 | u8 reg0; | ||
33 | }; | ||
34 | |||
35 | struct cu1216_config philips_cu1216_config = { | ||
36 | .demod_address = 0x18 >> 1, | ||
37 | .pll_set = philips_cu1216_tuner_set, | ||
38 | // .fe_reset = mantis_fe_reset, | ||
39 | }; | ||
40 | |||
41 | int philips_cu1216_tuner_set(struct dvb_frontend *fe, | ||
42 | struct dvb_frontend_parameters *params) | ||
43 | { | ||
44 | // struct tda10021_state *state = fe->demodulator_priv; | ||
45 | struct mantis_pci *mantis = fe->dvb->priv; | ||
46 | |||
47 | u8 buf[4]; | ||
48 | |||
49 | struct i2c_msg msg = { | ||
50 | .addr = 0xc0 >> 1, | ||
51 | .flags = 0, | ||
52 | .buf = buf, | ||
53 | .len = sizeof (buf) | ||
54 | }; | ||
55 | |||
56 | #define TUNER_MUL 62500 | ||
57 | |||
58 | u32 div = (params->frequency + 36125000 + TUNER_MUL / 2) / TUNER_MUL; | ||
59 | |||
60 | buf[0] = (div >> 8) & 0x7f; | ||
61 | buf[1] = div & 0xff; | ||
62 | buf[2] = 0x86; | ||
63 | buf[3] = (params->frequency < 150000000 ? 0xA1 : | ||
64 | params->frequency < 445000000 ? 0x92 : 0x34); | ||
65 | |||
66 | // if (i2c_transfer(state->i2c, &msg, 1) < 0) { | ||
67 | if (i2c_transfer(&mantis->adapter, &msg, 1) < 0) { | ||
68 | printk("%s tuner not ack!\n", __FUNCTION__); | ||
69 | return -EIO; | ||
70 | } | ||
71 | msleep(100); | ||
72 | return 0; | ||
73 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp2033.h b/drivers/media/dvb/mantis/mantis_vp2033.h new file mode 100644 index 000000000000..29baba180961 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp2033.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | Mantis VP-2033 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_VP2033_H | ||
22 | #define __MANTIS_VP2033_H | ||
23 | |||
24 | #include "cu1216.h" | ||
25 | #include "dvb_frontend.h" | ||
26 | |||
27 | extern struct cu1216_config philips_cu1216_config; | ||
28 | |||
29 | extern int philips_cu1216_tuner_set(struct dvb_frontend *fe, | ||
30 | struct dvb_frontend_parameters *params); | ||
31 | |||
32 | |||
33 | #endif // __MANTIS_VP2033_H | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp3030.c b/drivers/media/dvb/mantis/mantis_vp3030.c new file mode 100644 index 000000000000..f44f226ce9ab --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp3030.c | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | Mantis VP-3030 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 | #include "mantis_common.h" | ||
22 | #include "mantis_vp3030.h" | ||
23 | |||
24 | struct zl10353_config mantis_vp3030_config = { | ||
25 | .demod_address = 0x0f, | ||
26 | }; | ||
27 | |||
28 | int panasonic_en57h12d5_set_params(struct dvb_frontend *fe, | ||
29 | struct dvb_frontend_parameters *params) | ||
30 | { | ||
31 | u8 buf[4]; | ||
32 | int rc; | ||
33 | struct mantis_pci *mantis = fe->dvb->priv; | ||
34 | |||
35 | struct i2c_msg tuner_msg = { | ||
36 | .addr = 0x60, | ||
37 | .flags = 0, | ||
38 | .buf = buf, | ||
39 | .len = sizeof (buf) | ||
40 | }; | ||
41 | |||
42 | if ((params->frequency < 950000) || (params->frequency > 2150000)) | ||
43 | return -EINVAL; | ||
44 | rc = i2c_transfer(&mantis->adapter, &tuner_msg, 1); | ||
45 | if (rc != 1) { | ||
46 | printk("%s: I2C Transfer returned [%d]\n", __func__, rc); | ||
47 | return -EIO; | ||
48 | } | ||
49 | msleep_interruptible(1); | ||
50 | printk("%s: Send params to tuner ok!!!\n", __func__); | ||
51 | |||
52 | return 0; | ||
53 | } | ||
diff --git a/drivers/media/dvb/mantis/mantis_vp3030.h b/drivers/media/dvb/mantis/mantis_vp3030.h new file mode 100644 index 000000000000..f8e72cce7e69 --- /dev/null +++ b/drivers/media/dvb/mantis/mantis_vp3030.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | Mantis VP-3030 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_VP3030_H | ||
22 | #define __MANTIS_VP3030_H | ||
23 | |||
24 | #include "zl10353.h" | ||
25 | #include "dvb-pll.h" | ||
26 | #include "dvb_frontend.h" | ||
27 | |||
28 | extern struct zl10353_config mantis_vp3030_config; | ||
29 | |||
30 | #endif // __MANTIS_VP3030_H | ||