This source file includes following definitions.
- probe_cs4232_mpu
- attach_cs4232_mpu
- probe_cs4232
- attach_cs4232
- unload_cs4232
- unload_cs4232_mpu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 #include "sound_config.h"
36
37 #if defined(CONFIGURE_SOUNDCARD) && !defined(EXCLUDE_CS4232)
38
39 #define KEY_PORT 0x279
40 #define CSN_NUM 0x99
41
42 #define CS_OUT(a) outb( a, KEY_PORT)
43 #define CS_OUT2(a, b) {CS_OUT(a);CS_OUT(b);}
44 #define CS_OUT3(a, b, c) {CS_OUT(a);CS_OUT(b);CS_OUT(c);}
45
46 static int mpu_base = 0, mpu_irq = 0;
47
48 int
49 probe_cs4232_mpu (struct address_info *hw_config)
50 {
51
52
53
54
55 mpu_base = hw_config->io_base;
56 mpu_irq = hw_config->irq;
57 return 0;
58 }
59
60 long
61 attach_cs4232_mpu (long mem_start, struct address_info *hw_config)
62 {
63 return mem_start;
64 }
65
66 static unsigned char crystal_key[] =
67 {
68 0x96, 0x35, 0x9a, 0xcd, 0xe6, 0xf3, 0x79, 0xbc,
69 0x5e, 0xaf, 0x57, 0x2b, 0x15, 0x8a, 0xc5, 0xe2,
70 0xf1, 0xf8, 0x7c, 0x3e, 0x9f, 0x4f, 0x27, 0x13,
71 0x09, 0x84, 0x42, 0xa1, 0xd0, 0x68, 0x34, 0x1a
72 };
73
74 int
75 probe_cs4232 (struct address_info *hw_config)
76 {
77 int i;
78 int base = hw_config->io_base, irq = hw_config->irq;
79 int dma1 = hw_config->dma, dma2 = hw_config->dma2;
80
81
82
83
84
85 if (check_region (base, 4))
86 {
87 printk ("cs4232.c: I/O port 0x%03x not free\n", base);
88 return 0;
89 }
90
91
92
93
94
95
96
97
98
99
100
101
102 for (i = 0; i < 32; i++)
103 CS_OUT (crystal_key[i]);
104
105
106
107
108
109 CS_OUT2 (0x06, CSN_NUM);
110
111
112
113
114
115 CS_OUT2 (0x15, 0x00);
116 CS_OUT2 (0x33, 0x00);
117 if (ad1848_detect (hw_config->io_base, NULL, hw_config->osp))
118 return 0;
119
120
121
122
123
124 CS_OUT2 (0x15, 0x00);
125 CS_OUT3 (0x47, (base >> 8) & 0xff, base & 0xff);
126
127 if (check_region (0x388, 4))
128 CS_OUT3 (0x48, 0x00, 0x00)
129 else
130 CS_OUT3 (0x48, 0x03, 0x88);
131
132 CS_OUT3 (0x42, 0x00, 0x00);
133 CS_OUT2 (0x22, irq);
134 CS_OUT2 (0x2a, dma1);
135
136 if (dma2 != -1)
137 CS_OUT2 (0x25, dma2)
138 else
139 CS_OUT2 (0x25, 4);
140
141 CS_OUT2 (0x33, 0x01);
142
143
144
145
146
147 #if (!defined(EXCLUDE_MPU401) || !defined(EXCLUDE_MPU_EMU)) && !defined(EXCLUDE_MIDI)
148 if (mpu_base != 0 && mpu_irq != 0)
149 {
150 CS_OUT2 (0x15, 0x03);
151 CS_OUT3 (0x47, (mpu_base >> 8) & 0xff, mpu_base & 0xff);
152 CS_OUT2 (0x22, mpu_irq);
153 CS_OUT2 (0x33, 0x01);
154 }
155 #endif
156
157
158
159
160 CS_OUT (0x79);
161
162
163
164
165
166 return ad1848_detect (hw_config->io_base, NULL, hw_config->osp);
167 }
168
169 long
170 attach_cs4232 (long mem_start, struct address_info *hw_config)
171 {
172 int base = hw_config->io_base, irq = hw_config->irq;
173 int dma1 = hw_config->dma, dma2 = hw_config->dma2;
174
175 if (dma2 == -1)
176 dma2 = dma1;
177
178 ad1848_init ("CS4232", base,
179 irq,
180 dma1,
181 dma2,
182 0,
183 hw_config->osp);
184
185 #if (!defined(EXCLUDE_MPU401) || !defined(EXCLUDE_MPU_EMU)) && !defined(EXCLUDE_MIDI)
186 if (mpu_base != 0 && mpu_irq != 0)
187 {
188 static struct address_info hw_config2 =
189 {0};
190
191 hw_config2.io_base = mpu_base;
192 hw_config2.irq = mpu_irq;
193 hw_config2.dma = -1;
194 hw_config2.dma2 = -1;
195 hw_config2.always_detect = 0;
196 hw_config2.name = NULL;
197 hw_config2.driver_use_1 = 0;
198 hw_config2.driver_use_2 = 0;
199 hw_config2.osp = hw_config->osp;
200
201 if (probe_mpu401 (&hw_config2))
202 {
203 mem_start = attach_mpu401 (mem_start, &hw_config2);
204 }
205 else
206 {
207 mpu_base = mpu_irq = 0;
208 }
209 }
210 #endif
211 return mem_start;
212 }
213
214 void
215 unload_cs4232 (struct address_info *hw_config)
216 {
217 int base = hw_config->io_base, irq = hw_config->irq;
218 int dma1 = hw_config->dma, dma2 = hw_config->dma2;
219
220 if (dma2 == -1)
221 dma2 = dma1;
222
223 ad1848_unload (base,
224 irq,
225 dma1,
226 dma2,
227 0);
228
229 #if (!defined(EXCLUDE_MPU401) || !defined(EXCLUDE_MPU_EMU)) && !defined(EXCLUDE_MIDI)
230 if (mpu_base != 0 && mpu_irq != 0)
231 {
232 static struct address_info hw_config2 =
233 {0};
234
235 hw_config2.io_base = mpu_base;
236 hw_config2.irq = mpu_irq;
237 hw_config2.dma = -1;
238 hw_config2.dma2 = -1;
239 hw_config2.always_detect = 0;
240 hw_config2.name = NULL;
241 hw_config2.driver_use_1 = 0;
242 hw_config2.driver_use_2 = 0;
243 hw_config2.osp = hw_config->osp;
244
245 unload_mpu401 (&hw_config2);
246 }
247 #endif
248 }
249
250 void
251 unload_cs4232_mpu (struct address_info *hw_config)
252 {
253
254 }
255
256 #endif