1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/module.h>
21#include <linux/delay.h>
22#include <linux/errno.h>
23#include <linux/fs.h>
24#include <linux/kernel.h>
25#include <linux/pci.h>
26
27#include <asm/io.h>
28
29#include "sound_config.h"
30
31
32
33
34
35#ifndef PCI_VENDOR_MYIDENT
36#define PCI_VENDOR_MYIDENT 0x125D
37
38
39
40
41
42#define PCI_DEVICE_ID_MYIDENT_MYCARD1 0x1969
43#endif
44
45#define CARD_NAME "ExampleWave 3D Pro Ultra ThingyWotsit"
46
47#define MAX_CARDS 8
48
49
50
51
52
53
54
55static struct address_info mss_data[MAX_CARDS];
56static int cards = 0;
57
58
59
60
61
62static int mycard_install(struct pci_dev *pcidev)
63{
64 int iobase;
65 int mssbase;
66 int mpubase;
67 u8 x;
68 u16 w;
69 u32 v;
70 int i;
71 int dma;
72
73
74
75
76
77
78
79
80 iobase = pci_resource_start(pcidev, 0);
81 mssbase = pci_resource_start(pcidev, 1);
82 mpubase = pci_resource_start(pcidev, 2);
83
84
85
86
87
88
89
90
91
92 udelay(100);
93
94
95
96
97
98
99 dma = card_specific_magic(ioaddr);
100
101
102
103
104
105
106 pci_read_config_word(pcidev, 0x40, &w);
107 w&=~(1<<15);
108 w|=(1<<14);
109 w|=(1<<3)|(1<<1)|(1<<0);
110 pci_write_config_word(pcidev, 0x40, w);
111
112
113
114
115
116 printk(KERN_INFO "Programmed "CARD_NAME" at 0x%X to legacy mode.\n",
117 iobase);
118
119
120
121
122
123 mss_data[cards].io_base = mssbase;
124 mss_data[cards].irq = pcidev->irq;
125 mss_data[cards].dma = dma;
126
127
128
129
130
131 if(ad1848_detect(mssbase, NULL, mss_data[cards].osp)==0)
132 return 0;
133
134
135
136
137
138 mss_data[cards].slots[3] = ad1848_init("MyCard MSS 16bit",
139 mssbase,
140 mss_data[cards].irq,
141 mss_data[cards].dma,
142 mss_data[cards].dma,
143 0,
144 0,
145 THIS_MODULE);
146
147 cards++;
148 return 1;
149}
150
151
152
153
154
155
156
157int init_mycard(void)
158{
159 struct pci_dev *pcidev=NULL;
160 int count=0;
161
162 if(!pci_present())
163 return -ENODEV;
164
165
166 while((pcidev = pci_find_device(PCI_VENDOR_MYIDENT, PCI_DEVICE_ID_MYIDENT_MYCARD1, pcidev))!=NULL)
167 {
168 if (pci_enable_device(pcidev))
169 continue;
170 count+=mycard_install(pcidev);
171 if(count)
172 return 0;
173 if(count==MAX_CARDS)
174 break;
175 }
176
177 if(count==0)
178 return -ENODEV;
179 return 0;
180}
181
182
183
184
185
186
187
188int init_module(void)
189{
190 if(init_mycard()<0)
191 {
192 printk(KERN_ERR "No "CARD_NAME" cards found.\n");
193 return -ENODEV;
194 }
195
196 return 0;
197}
198
199
200
201
202
203
204void cleanup_module(void)
205{
206 for(i=0;i< cards; i++)
207 {
208
209
210
211
212 ad1848_unload(mss_data[i].io_base,
213 mss_data[i].irq,
214 mss_data[i].dma,
215 mss_data[i].dma,
216 0);
217
218
219
220 sound_unload_audiodevice(mss_data[i].slots[3]);
221 }
222}
223
224