2 * ALSA driver for ICEnsemble ICE1712 (Envy24)
4 * Lowlevel functions for Hoontech STDSP24
6 * Copyright (c) 2000 Jaroslav Kysela <perex@suse.cz>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <sound/driver.h>
26 #include <linux/delay.h>
27 #include <linux/interrupt.h>
28 #include <linux/init.h>
29 #include <linux/slab.h>
30 #include <sound/core.h>
36 static void __devinit
snd_ice1712_stdsp24_gpio_write(ice1712_t
*ice
, unsigned char byte
)
38 byte
|= ICE1712_STDSP24_CLOCK_BIT
;
40 snd_ice1712_write(ice
, ICE1712_IREG_GPIO_DATA
, byte
);
41 byte
&= ~ICE1712_STDSP24_CLOCK_BIT
;
43 snd_ice1712_write(ice
, ICE1712_IREG_GPIO_DATA
, byte
);
44 byte
|= ICE1712_STDSP24_CLOCK_BIT
;
46 snd_ice1712_write(ice
, ICE1712_IREG_GPIO_DATA
, byte
);
49 static void __devinit
snd_ice1712_stdsp24_darear(ice1712_t
*ice
, int activate
)
51 down(&ice
->gpio_mutex
);
52 ICE1712_STDSP24_0_DAREAR(ice
->spec
.hoontech
.boxbits
, activate
);
53 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[0]);
57 static void __devinit
snd_ice1712_stdsp24_mute(ice1712_t
*ice
, int activate
)
59 down(&ice
->gpio_mutex
);
60 ICE1712_STDSP24_3_MUTE(ice
->spec
.hoontech
.boxbits
, activate
);
61 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[3]);
65 static void __devinit
snd_ice1712_stdsp24_insel(ice1712_t
*ice
, int activate
)
67 down(&ice
->gpio_mutex
);
68 ICE1712_STDSP24_3_INSEL(ice
->spec
.hoontech
.boxbits
, activate
);
69 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[3]);
73 static void __devinit
snd_ice1712_stdsp24_box_channel(ice1712_t
*ice
, int box
, int chn
, int activate
)
75 down(&ice
->gpio_mutex
);
78 ICE1712_STDSP24_0_BOX(ice
->spec
.hoontech
.boxbits
, box
);
79 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[0]);
81 /* prepare for write */
83 ICE1712_STDSP24_2_CHN4(ice
->spec
.hoontech
.boxbits
, 0);
84 ICE1712_STDSP24_2_MIDI1(ice
->spec
.hoontech
.boxbits
, activate
);
85 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[2]);
86 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[3]);
88 ICE1712_STDSP24_1_CHN1(ice
->spec
.hoontech
.boxbits
, 1);
89 ICE1712_STDSP24_1_CHN2(ice
->spec
.hoontech
.boxbits
, 1);
90 ICE1712_STDSP24_1_CHN3(ice
->spec
.hoontech
.boxbits
, 1);
91 ICE1712_STDSP24_2_CHN4(ice
->spec
.hoontech
.boxbits
, 1);
92 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[1]);
93 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[2]);
96 ICE1712_STDSP24_2_CHN4(ice
->spec
.hoontech
.boxbits
, 0);
97 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[2]);
100 case 0: ICE1712_STDSP24_1_CHN1(ice
->spec
.hoontech
.boxbits
, 0); break;
101 case 1: ICE1712_STDSP24_1_CHN2(ice
->spec
.hoontech
.boxbits
, 0); break;
102 case 2: ICE1712_STDSP24_1_CHN3(ice
->spec
.hoontech
.boxbits
, 0); break;
104 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[1]);
107 ICE1712_STDSP24_1_CHN1(ice
->spec
.hoontech
.boxbits
, 1);
108 ICE1712_STDSP24_1_CHN2(ice
->spec
.hoontech
.boxbits
, 1);
109 ICE1712_STDSP24_1_CHN3(ice
->spec
.hoontech
.boxbits
, 1);
110 ICE1712_STDSP24_2_CHN4(ice
->spec
.hoontech
.boxbits
, 1);
111 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[1]);
112 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[2]);
115 ICE1712_STDSP24_2_MIDI1(ice
->spec
.hoontech
.boxbits
, 0);
116 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[2]);
118 up(&ice
->gpio_mutex
);
121 static void __devinit
snd_ice1712_stdsp24_box_midi(ice1712_t
*ice
, int box
, int master
)
123 down(&ice
->gpio_mutex
);
126 ICE1712_STDSP24_0_BOX(ice
->spec
.hoontech
.boxbits
, box
);
127 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[0]);
129 ICE1712_STDSP24_2_MIDIIN(ice
->spec
.hoontech
.boxbits
, 1);
130 ICE1712_STDSP24_2_MIDI1(ice
->spec
.hoontech
.boxbits
, master
);
131 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[2]);
132 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[3]);
136 ICE1712_STDSP24_2_MIDIIN(ice
->spec
.hoontech
.boxbits
, 0);
137 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[2]);
141 ICE1712_STDSP24_2_MIDIIN(ice
->spec
.hoontech
.boxbits
, 1);
142 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[2]);
144 up(&ice
->gpio_mutex
);
147 static void __devinit
snd_ice1712_stdsp24_midi2(ice1712_t
*ice
, int activate
)
149 down(&ice
->gpio_mutex
);
150 ICE1712_STDSP24_3_MIDI2(ice
->spec
.hoontech
.boxbits
, activate
);
151 snd_ice1712_stdsp24_gpio_write(ice
, ice
->spec
.hoontech
.boxbits
[3]);
152 up(&ice
->gpio_mutex
);
155 static int __devinit
snd_ice1712_hoontech_init(ice1712_t
*ice
)
159 ice
->num_total_dacs
= 8;
160 ice
->num_total_adcs
= 8;
162 ice
->spec
.hoontech
.boxbits
[0] =
163 ice
->spec
.hoontech
.boxbits
[1] =
164 ice
->spec
.hoontech
.boxbits
[2] =
165 ice
->spec
.hoontech
.boxbits
[3] = 0; /* should be already */
167 ICE1712_STDSP24_SET_ADDR(ice
->spec
.hoontech
.boxbits
, 0);
168 ICE1712_STDSP24_CLOCK(ice
->spec
.hoontech
.boxbits
, 0, 1);
169 ICE1712_STDSP24_0_BOX(ice
->spec
.hoontech
.boxbits
, 0);
170 ICE1712_STDSP24_0_DAREAR(ice
->spec
.hoontech
.boxbits
, 0);
172 ICE1712_STDSP24_SET_ADDR(ice
->spec
.hoontech
.boxbits
, 1);
173 ICE1712_STDSP24_CLOCK(ice
->spec
.hoontech
.boxbits
, 1, 1);
174 ICE1712_STDSP24_1_CHN1(ice
->spec
.hoontech
.boxbits
, 1);
175 ICE1712_STDSP24_1_CHN2(ice
->spec
.hoontech
.boxbits
, 1);
176 ICE1712_STDSP24_1_CHN3(ice
->spec
.hoontech
.boxbits
, 1);
178 ICE1712_STDSP24_SET_ADDR(ice
->spec
.hoontech
.boxbits
, 2);
179 ICE1712_STDSP24_CLOCK(ice
->spec
.hoontech
.boxbits
, 2, 1);
180 ICE1712_STDSP24_2_CHN4(ice
->spec
.hoontech
.boxbits
, 1);
181 ICE1712_STDSP24_2_MIDIIN(ice
->spec
.hoontech
.boxbits
, 1);
182 ICE1712_STDSP24_2_MIDI1(ice
->spec
.hoontech
.boxbits
, 0);
184 ICE1712_STDSP24_SET_ADDR(ice
->spec
.hoontech
.boxbits
, 3);
185 ICE1712_STDSP24_CLOCK(ice
->spec
.hoontech
.boxbits
, 3, 1);
186 ICE1712_STDSP24_3_MIDI2(ice
->spec
.hoontech
.boxbits
, 0);
187 ICE1712_STDSP24_3_MUTE(ice
->spec
.hoontech
.boxbits
, 1);
188 ICE1712_STDSP24_3_INSEL(ice
->spec
.hoontech
.boxbits
, 0);
190 /* let's go - activate only functions in first box */
191 ice
->spec
.hoontech
.config
= 0;
192 /* ICE1712_STDSP24_MUTE |
193 ICE1712_STDSP24_INSEL |
194 ICE1712_STDSP24_DAREAR; */
195 ice
->spec
.hoontech
.boxconfig
[0] = ICE1712_STDSP24_BOX_CHN1
|
196 ICE1712_STDSP24_BOX_CHN2
|
197 ICE1712_STDSP24_BOX_CHN3
|
198 ICE1712_STDSP24_BOX_CHN4
|
199 ICE1712_STDSP24_BOX_MIDI1
|
200 ICE1712_STDSP24_BOX_MIDI2
;
201 ice
->spec
.hoontech
.boxconfig
[1] =
202 ice
->spec
.hoontech
.boxconfig
[2] =
203 ice
->spec
.hoontech
.boxconfig
[3] = 0;
204 snd_ice1712_stdsp24_darear(ice
, (ice
->spec
.hoontech
.config
& ICE1712_STDSP24_DAREAR
) ? 1 : 0);
205 snd_ice1712_stdsp24_mute(ice
, (ice
->spec
.hoontech
.config
& ICE1712_STDSP24_MUTE
) ? 1 : 0);
206 snd_ice1712_stdsp24_insel(ice
, (ice
->spec
.hoontech
.config
& ICE1712_STDSP24_INSEL
) ? 1 : 0);
207 for (box
= 0; box
< 4; box
++) {
208 for (chn
= 0; chn
< 4; chn
++)
209 snd_ice1712_stdsp24_box_channel(ice
, box
, chn
, (ice
->spec
.hoontech
.boxconfig
[box
] & (1 << chn
)) ? 1 : 0);
210 snd_ice1712_stdsp24_box_midi(ice
, box
,
211 (ice
->spec
.hoontech
.boxconfig
[box
] & ICE1712_STDSP24_BOX_MIDI1
) ? 1 : 0);
212 if (ice
->spec
.hoontech
.boxconfig
[box
] & ICE1712_STDSP24_BOX_MIDI2
)
213 snd_ice1712_stdsp24_midi2(ice
, 1);
223 /* start callback for STDSP24 with modified hardware */
224 static void stdsp24_ak4524_lock(akm4xxx_t
*ak
, int chip
)
226 ice1712_t
*ice
= ak
->private_data
[0];
228 snd_ice1712_save_gpio_status(ice
);
229 tmp
= ICE1712_STDSP24_SERIAL_DATA
|
230 ICE1712_STDSP24_SERIAL_CLOCK
|
231 ICE1712_STDSP24_AK4524_CS
;
232 snd_ice1712_write(ice
, ICE1712_IREG_GPIO_DIRECTION
,
233 ice
->gpio
.direction
| tmp
);
234 snd_ice1712_write(ice
, ICE1712_IREG_GPIO_WRITE_MASK
, ~tmp
);
237 static int __devinit
snd_ice1712_value_init(ice1712_t
*ice
)
239 /* Hoontech STDSP24 with modified hardware */
240 static akm4xxx_t akm_stdsp24_mv __devinitdata
= {
245 .lock
= stdsp24_ak4524_lock
249 static struct snd_ak4xxx_private akm_stdsp24_mv_priv __devinitdata
= {
251 .cif
= 1, /* CIF high */
252 .data_mask
= ICE1712_STDSP24_SERIAL_DATA
,
253 .clk_mask
= ICE1712_STDSP24_SERIAL_CLOCK
,
254 .cs_mask
= ICE1712_STDSP24_AK4524_CS
,
255 .cs_addr
= ICE1712_STDSP24_AK4524_CS
,
263 /* set the analog DACs */
264 ice
->num_total_dacs
= 2;
266 /* set the analog ADCs */
267 ice
->num_total_adcs
= 2;
270 ak
= ice
->akm
= kmalloc(sizeof(akm4xxx_t
), GFP_KERNEL
);
275 err
= snd_ice1712_akm4xxx_init(ak
, &akm_stdsp24_mv
, &akm_stdsp24_mv_priv
, ice
);
279 /* ak4524 controls */
280 err
= snd_ice1712_akm4xxx_build_controls(ice
);
287 static int __devinit
snd_ice1712_ez8_init(ice1712_t
*ice
)
289 ice
->gpio
.write_mask
= ice
->eeprom
.gpiomask
;
290 ice
->gpio
.direction
= ice
->eeprom
.gpiodir
;
291 snd_ice1712_write(ice
, ICE1712_IREG_GPIO_WRITE_MASK
, ice
->eeprom
.gpiomask
);
292 snd_ice1712_write(ice
, ICE1712_IREG_GPIO_DIRECTION
, ice
->eeprom
.gpiodir
);
293 snd_ice1712_write(ice
, ICE1712_IREG_GPIO_DATA
, ice
->eeprom
.gpiostate
);
299 struct snd_ice1712_card_info snd_ice1712_hoontech_cards
[] __devinitdata
= {
301 .subvendor
= ICE1712_SUBDEVICE_STDSP24
,
302 .name
= "Hoontech SoundTrack Audio DSP24",
304 .chip_init
= snd_ice1712_hoontech_init
,
307 .subvendor
= ICE1712_SUBDEVICE_STDSP24_VALUE
, /* a dummy id */
308 .name
= "Hoontech SoundTrack Audio DSP24 Value",
309 .model
= "dsp24_value",
310 .chip_init
= snd_ice1712_value_init
,
313 .subvendor
= ICE1712_SUBDEVICE_STDSP24_MEDIA7_1
,
314 .name
= "Hoontech STA DSP24 Media 7.1",
316 .chip_init
= snd_ice1712_hoontech_init
,
319 .subvendor
= ICE1712_SUBDEVICE_EVENT_EZ8
, /* a dummy id */
320 .name
= "Event Electronics EZ8",
322 .chip_init
= snd_ice1712_ez8_init
,