85 #include <linux/module.h>
96 #define SNDRV_LEGACY_FIND_FREE_IRQ
97 #define SNDRV_LEGACY_FIND_FREE_DMA
100 #define PFX "es18xx: "
134 unsigned char pm_reg;
142 #define AUDIO1_IRQ 0x01
143 #define AUDIO2_IRQ 0x02
147 #define ES18XX_PCM2 0x0001
148 #define ES18XX_SPATIALIZER 0x0002
149 #define ES18XX_RECMIX 0x0004
150 #define ES18XX_DUPLEX_MONO 0x0008
151 #define ES18XX_DUPLEX_SAME 0x0010
152 #define ES18XX_NEW_RATE 0x0020
153 #define ES18XX_AUXB 0x0040
154 #define ES18XX_HWV 0x0080
155 #define ES18XX_MONO 0x0100
156 #define ES18XX_I2S 0x0200
157 #define ES18XX_MUTEREC 0x0400
158 #define ES18XX_CONTROL 0x0800
161 #define ES18XX_PM 0x07
162 #define ES18XX_PM_GPO0 0x01
163 #define ES18XX_PM_GPO1 0x02
164 #define ES18XX_PM_PDR 0x04
165 #define ES18XX_PM_ANA 0x08
166 #define ES18XX_PM_FM 0x020
167 #define ES18XX_PM_SUS 0x080
174 #define MILLISECOND 10000
181 if ((
inb(chip->
port + 0x0C) & 0x80) == 0) {
194 if (
inb(chip->
port + 0x0C) & 0x40)
203 static int snd_es18xx_write(
struct snd_es18xx *chip,
204 unsigned char reg,
unsigned char data)
210 ret = snd_es18xx_dsp_command(chip, reg);
213 ret = snd_es18xx_dsp_command(chip, data);
215 spin_unlock_irqrestore(&chip->
reg_lock, flags);
222 static int snd_es18xx_read(
struct snd_es18xx *chip,
unsigned char reg)
227 ret = snd_es18xx_dsp_command(chip, 0xC0);
230 ret = snd_es18xx_dsp_command(chip, reg);
233 data = snd_es18xx_dsp_get_byte(chip);
239 spin_unlock_irqrestore(&chip->
reg_lock, flags);
244 static int snd_es18xx_bits(
struct snd_es18xx *chip,
unsigned char reg,
245 unsigned char mask,
unsigned char val)
248 unsigned char old,
new, oval;
251 ret = snd_es18xx_dsp_command(chip, 0xC0);
254 ret = snd_es18xx_dsp_command(chip, reg);
257 ret = snd_es18xx_dsp_get_byte(chip);
264 ret = snd_es18xx_dsp_command(chip, reg);
267 new = (old & ~mask) | (val & mask);
268 ret = snd_es18xx_dsp_command(chip,
new);
278 spin_unlock_irqrestore(&chip->
reg_lock, flags);
282 static inline void snd_es18xx_mixer_write(
struct snd_es18xx *chip,
283 unsigned char reg,
unsigned char data)
289 spin_unlock_irqrestore(&chip->
mixer_lock, flags);
295 static inline int snd_es18xx_mixer_read(
struct snd_es18xx *chip,
unsigned char reg)
302 spin_unlock_irqrestore(&chip->
mixer_lock, flags);
310 static inline int snd_es18xx_mixer_bits(
struct snd_es18xx *chip,
unsigned char reg,
311 unsigned char mask,
unsigned char val)
313 unsigned char old,
new, oval;
320 new = (old & ~mask) | (val & mask);
327 spin_unlock_irqrestore(&chip->
mixer_lock, flags);
331 static inline int snd_es18xx_mixer_writable(
struct snd_es18xx *chip,
unsigned char reg,
334 int old, expected,
new;
339 expected = old ^
mask;
342 spin_unlock_irqrestore(&chip->
mixer_lock, flags);
345 reg, old, expected,
new);
347 return expected ==
new;
358 if (
inb(chip->
port + 0x0A) != 0xAA)
363 static int snd_es18xx_reset_fifo(
struct snd_es18xx *chip)
412 static void snd_es18xx_rate_set(
struct snd_es18xx *chip,
416 unsigned int bits, div0;
431 div0 = 256 - 7160000*20/(8*82*runtime->
rate);
434 snd_es18xx_mixer_write(chip, 0x70, bits);
439 snd_es18xx_write(chip, 0xA2, div0);
440 snd_es18xx_mixer_write(chip, 0x72, div0);
442 snd_es18xx_write(chip, 0xA1, bits);
443 snd_es18xx_write(chip, 0xA2, div0);
480 static int snd_es18xx_playback1_prepare(
struct snd_es18xx *chip,
484 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
485 unsigned int count = snd_pcm_lib_period_bytes(substream);
487 snd_es18xx_rate_set(chip, substream,
DAC2);
490 count = 0x10000 -
count;
491 snd_es18xx_mixer_write(chip, 0x74, count & 0xff);
492 snd_es18xx_mixer_write(chip, 0x76, count >> 8);
495 snd_es18xx_mixer_bits(chip, 0x7A, 0x07,
496 ((runtime->
channels == 1) ? 0x00 : 0x02) |
506 static int snd_es18xx_playback1_trigger(
struct snd_es18xx *chip,
518 snd_es18xx_mixer_write(chip, 0x78, 0xb3);
520 snd_es18xx_mixer_write(chip, 0x78, 0x93);
526 snd_es18xx_mixer_write(chip, 0x7C, chip->
audio2_vol);
529 snd_es18xx_dsp_command(chip, 0xD1);
538 snd_es18xx_mixer_write(chip, 0x78, 0x00);
543 snd_es18xx_mixer_write(chip, 0x7C, 0);
546 snd_es18xx_dsp_command(chip, 0xD3);
583 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
584 unsigned int count = snd_pcm_lib_period_bytes(substream);
586 snd_es18xx_reset_fifo(chip);
589 snd_es18xx_bits(chip, 0xA8, 0x03, runtime->
channels == 1 ? 0x02 : 0x01);
591 snd_es18xx_rate_set(chip, substream,
ADC1);
594 count = 0x10000 -
count;
595 snd_es18xx_write(chip, 0xA4, count & 0xff);
596 snd_es18xx_write(chip, 0xA5, count >> 8);
603 snd_es18xx_write(chip, 0xB7,
605 snd_es18xx_write(chip, 0xB7, 0x90 |
606 ((runtime->
channels == 1) ? 0x40 : 0x08) |
628 snd_es18xx_write(chip, 0xB8, 0x0f);
636 snd_es18xx_write(chip, 0xB8, 0x00);
645 static int snd_es18xx_playback2_prepare(
struct snd_es18xx *chip,
649 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
650 unsigned int count = snd_pcm_lib_period_bytes(substream);
652 snd_es18xx_reset_fifo(chip);
655 snd_es18xx_bits(chip, 0xA8, 0x03, runtime->
channels == 1 ? 0x02 : 0x01);
657 snd_es18xx_rate_set(chip, substream,
DAC1);
660 count = 0x10000 -
count;
661 snd_es18xx_write(chip, 0xA4, count & 0xff);
662 snd_es18xx_write(chip, 0xA5, count >> 8);
665 snd_es18xx_write(chip, 0xB6,
667 snd_es18xx_write(chip, 0xB7,
669 snd_es18xx_write(chip, 0xB7, 0x90 |
670 (runtime->
channels == 1 ? 0x40 : 0x08) |
680 static int snd_es18xx_playback2_trigger(
struct snd_es18xx *chip,
691 snd_es18xx_write(chip, 0xB8, 0x05);
696 snd_es18xx_dsp_command(chip, 0xD1);
705 snd_es18xx_write(chip, 0xB8, 0x00);
710 snd_es18xx_dsp_command(chip, 0xD3);
724 return snd_es18xx_playback1_prepare(chip, substream);
726 return snd_es18xx_playback2_prepare(chip, substream);
734 return snd_es18xx_playback1_trigger(chip, substream, cmd);
736 return snd_es18xx_playback2_trigger(chip, substream, cmd);
750 status = snd_es18xx_mixer_read(chip, 0x7f) >> 4;
755 if (
inb(chip->
port + 0x0C) & 0x01)
757 if (snd_es18xx_mixer_read(chip, 0x7A) & 0x80)
760 snd_es18xx_mixer_read(chip, 0x64) & 0x10)
770 snd_es18xx_mixer_bits(chip, 0x7A, 0x80, 0x00);
791 split = snd_es18xx_mixer_read(chip, 0x64) & 0x80;
804 snd_es18xx_mixer_write(chip, 0x66, 0x00);
812 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
831 unsigned int size = snd_pcm_lib_buffer_bytes(substream);
852 .buffer_bytes_max = 65536,
853 .period_bytes_min = 64,
854 .period_bytes_max = 65536,
872 .buffer_bytes_max = 65536,
873 .period_bytes_min = 64,
874 .period_bytes_max = 65536,
891 }
else if (substream->
number <= 1) {
899 substream->
runtime->hw = snd_es18xx_playback;
917 substream->
runtime->hw = snd_es18xx_capture;
967 static char *texts5Source[5] = {
968 "Mic",
"CD",
"Line",
"Master",
"Mix"
970 static char *texts8Source[8] = {
971 "Mic",
"Mic Master",
"CD",
"AOUT",
972 "Mic1",
"Mix",
"Line",
"Master"
1009 static unsigned char invMap4Source[8] = {0, 0, 1, 1, 0, 0, 2, 3};
1011 int muxSource = snd_es18xx_mixer_read(chip, 0x1c) & 0x07;
1013 muxSource = invMap4Source[muxSource];
1016 (snd_es18xx_mixer_read(chip, 0x7a) & 0x08)
1020 ucontrol->
value.enumerated.item[0] = muxSource;
1026 static unsigned char map4Source[4] = {0, 2, 6, 7};
1028 unsigned char val = ucontrol->
value.enumerated.item[0];
1029 unsigned char retVal = 0;
1038 retVal = snd_es18xx_mixer_bits(chip, 0x7a, 0x08, 0x08) != 0x08;
1041 retVal = snd_es18xx_mixer_bits(chip, 0x7a, 0x08, 0x00) != 0x00;
1047 val = map4Source[
val];
1058 return (snd_es18xx_mixer_bits(chip, 0x1c, 0x07, val) != val) || retVal;
1061 #define snd_es18xx_info_spatializer_enable snd_ctl_boolean_mono_info
1066 unsigned char val = snd_es18xx_mixer_read(chip, 0x50);
1067 ucontrol->
value.integer.value[0] = !!(val & 8);
1074 unsigned char oval, nval;
1076 nval = ucontrol->
value.integer.value[0] ? 0x0c : 0x04;
1077 oval = snd_es18xx_mixer_read(chip, 0x50) & 0x0c;
1078 change = nval != oval;
1080 snd_es18xx_mixer_write(chip, 0x50, nval & ~0x04);
1081 snd_es18xx_mixer_write(chip, 0x50, nval);
1098 ucontrol->
value.integer.value[0] = snd_es18xx_mixer_read(chip, 0x61) & 0x3f;
1099 ucontrol->
value.integer.value[1] = snd_es18xx_mixer_read(chip, 0x63) & 0x3f;
1103 #define snd_es18xx_info_hw_switch snd_ctl_boolean_stereo_info
1108 ucontrol->
value.integer.value[0] = !(snd_es18xx_mixer_read(chip, 0x61) & 0x40);
1109 ucontrol->
value.integer.value[1] = !(snd_es18xx_mixer_read(chip, 0x63) & 0x40);
1113 static void snd_es18xx_hwv_free(
struct snd_kcontrol *kcontrol)
1122 static int snd_es18xx_reg_bits(
struct snd_es18xx *chip,
unsigned char reg,
1123 unsigned char mask,
unsigned char val)
1126 return snd_es18xx_mixer_bits(chip, reg, mask, val);
1128 return snd_es18xx_bits(chip, reg, mask, val);
1131 static int snd_es18xx_reg_read(
struct snd_es18xx *chip,
unsigned char reg)
1134 return snd_es18xx_mixer_read(chip, reg);
1136 return snd_es18xx_read(chip, reg);
1139 #define ES18XX_SINGLE(xname, xindex, reg, shift, mask, invert) \
1140 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
1141 .info = snd_es18xx_info_single, \
1142 .get = snd_es18xx_get_single, .put = snd_es18xx_put_single, \
1143 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
1165 val = snd_es18xx_reg_read(chip, reg);
1166 ucontrol->
value.integer.value[0] = (val >> shift) & mask;
1168 ucontrol->
value.integer.value[0] = mask - ucontrol->
value.integer.value[0];
1181 val = (ucontrol->
value.integer.value[0] &
mask);
1186 return snd_es18xx_reg_bits(chip, reg, mask, val) !=
val;
1189 #define ES18XX_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
1190 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
1191 .info = snd_es18xx_info_double, \
1192 .get = snd_es18xx_get_double, .put = snd_es18xx_put_double, \
1193 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
1217 left = snd_es18xx_reg_read(chip, left_reg);
1218 if (left_reg != right_reg)
1219 right = snd_es18xx_reg_read(chip, right_reg);
1222 ucontrol->
value.integer.value[0] = (left >> shift_left) & mask;
1225 ucontrol->
value.integer.value[0] = mask - ucontrol->
value.integer.value[0];
1226 ucontrol->
value.integer.value[1] = mask - ucontrol->
value.integer.value[1];
1241 unsigned char val1, val2, mask1, mask2;
1243 val1 = ucontrol->
value.integer.value[0] &
mask;
1244 val2 = ucontrol->
value.integer.value[1] &
mask;
1249 val1 <<= shift_left;
1251 mask1 = mask << shift_left;
1253 if (left_reg != right_reg) {
1255 if (snd_es18xx_reg_bits(chip, left_reg, mask1, val1) != val1)
1257 if (snd_es18xx_reg_bits(chip, right_reg, mask2, val2) != val2)
1260 change = (snd_es18xx_reg_bits(chip, left_reg, mask1 | mask2,
1261 val1 | val2) != (val1 | val2));
1273 ES18XX_DOUBLE(
"Master Playback Volume", 0, 0x60, 0x62, 0, 0, 63, 0),
1274 ES18XX_DOUBLE(
"Master Playback Switch", 0, 0x60, 0x62, 6, 6, 1, 1),
1275 ES18XX_DOUBLE(
"Line Playback Volume", 0, 0x3e, 0x3e, 4, 0, 15, 0),
1276 ES18XX_DOUBLE(
"CD Playback Volume", 0, 0x38, 0x38, 4, 0, 15, 0),
1277 ES18XX_DOUBLE(
"FM Playback Volume", 0, 0x36, 0x36, 4, 0, 15, 0),
1278 ES18XX_DOUBLE(
"Mic Playback Volume", 0, 0x1a, 0x1a, 4, 0, 15, 0),
1279 ES18XX_DOUBLE(
"Aux Playback Volume", 0, 0x3a, 0x3a, 4, 0, 15, 0),
1281 ES18XX_DOUBLE(
"Capture Volume", 0, 0xb4, 0xb4, 4, 0, 15, 0),
1284 .name =
"Capture Source",
1285 .info = snd_es18xx_info_mux,
1286 .get = snd_es18xx_get_mux,
1287 .put = snd_es18xx_put_mux,
1292 ES18XX_DOUBLE(
"PCM Capture Volume", 0, 0x69, 0x69, 4, 0, 15, 0),
1293 ES18XX_DOUBLE(
"Mic Capture Volume", 0, 0x68, 0x68, 4, 0, 15, 0),
1294 ES18XX_DOUBLE(
"Line Capture Volume", 0, 0x6e, 0x6e, 4, 0, 15, 0),
1295 ES18XX_DOUBLE(
"FM Capture Volume", 0, 0x6b, 0x6b, 4, 0, 15, 0),
1296 ES18XX_DOUBLE(
"CD Capture Volume", 0, 0x6a, 0x6a, 4, 0, 15, 0),
1297 ES18XX_DOUBLE(
"Aux Capture Volume", 0, 0x6c, 0x6c, 4, 0, 15, 0)
1309 ES18XX_DOUBLE(
"Mono Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0),
1310 ES18XX_DOUBLE(
"Mono Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0)
1314 ES18XX_DOUBLE(
"Video Playback Volume", 0, 0x68, 0x68, 4, 0, 15, 0);
1318 ES18XX_DOUBLE(
"Video Playback Volume", 0, 0x6d, 0x6d, 4, 0, 15, 0),
1319 ES18XX_DOUBLE(
"Video Capture Volume", 0, 0x6f, 0x6f, 4, 0, 15, 0)
1323 ES18XX_DOUBLE(
"PCM Playback Volume", 0, 0x14, 0x14, 4, 0, 15, 0),
1327 ES18XX_DOUBLE(
"PCM Playback Volume", 0, 0x7c, 0x7c, 4, 0, 15, 0),
1328 ES18XX_DOUBLE(
"PCM Playback Volume", 1, 0x14, 0x14, 4, 0, 15, 0)
1335 .name =
"3D Control - Switch",
1337 .get = snd_es18xx_get_spatializer_enable,
1338 .put = snd_es18xx_put_spatializer_enable,
1351 .name =
"Hardware Master Playback Volume",
1353 .info = snd_es18xx_info_hw_volume,
1354 .get = snd_es18xx_get_hw_volume,
1358 .name =
"Hardware Master Playback Switch",
1361 .get = snd_es18xx_get_hw_switch,
1363 ES18XX_SINGLE(
"Hardware Master Volume Split", 0, 0x64, 7, 1, 0),
1376 unsigned char reg,
unsigned char data)
1388 unsigned long mpu_port,
1389 unsigned long fm_port)
1394 snd_es18xx_dsp_command(chip, 0xC6);
1396 snd_es18xx_mixer_write(chip, 0x00, 0x00);
1399 snd_es18xx_write(chip, 0xB9, 2);
1402 snd_es18xx_config_write(chip, 0x27, chip->
irq);
1405 snd_es18xx_config_write(chip, 0x62, fm_port >> 8);
1406 snd_es18xx_config_write(chip, 0x63, fm_port & 0xff);
1410 snd_es18xx_config_write(chip, 0x64, mpu_port >> 8);
1411 snd_es18xx_config_write(chip, 0x65, mpu_port & 0xff);
1413 snd_es18xx_config_write(chip, 0x28, chip->
irq);
1416 snd_es18xx_config_write(chip, 0x70, chip->
irq);
1418 snd_es18xx_config_write(chip, 0x72, chip->
irq);
1420 snd_es18xx_config_write(chip, 0x74, chip->
dma1);
1422 snd_es18xx_config_write(chip, 0x75, chip->
dma2);
1425 snd_es18xx_write(chip, 0xB1, 0x50);
1427 snd_es18xx_mixer_write(chip, 0x7A, 0x40);
1429 snd_es18xx_write(chip, 0xB2, 0x50);
1431 snd_es18xx_mixer_write(chip, 0x64, 0x42);
1433 snd_es18xx_mixer_bits(chip, 0x48, 0x10, 0x10);
1436 int irqmask, dma1mask, dma2mask;
1437 switch (chip->
irq) {
1455 switch (chip->
dma1) {
1469 switch (chip->
dma2) {
1488 snd_es18xx_write(chip, 0xB1, 0x50 | (irqmask << 2));
1490 snd_es18xx_write(chip, 0xB2, 0x50 | (dma1mask << 2));
1492 snd_es18xx_mixer_bits(chip, 0x7d, 0x07, 0x04 | dma2mask);
1495 snd_es18xx_mixer_write(chip, 0x7A, 0x68);
1497 snd_es18xx_mixer_write(chip, 0x64, 0x06);
1502 snd_es18xx_mixer_write(chip, 0x40,
1503 0x43 | (mpu_port & 0xf0) >> 1);
1505 snd_es18xx_mixer_write(chip, 0x7f, ((irqmask + 1) << 1) | 0x01);
1511 snd_es18xx_mixer_write(chip, 0x71, 0x32);
1515 snd_es18xx_write(chip, 0xB7, 0x80);
1519 snd_es18xx_mixer_write(chip, 0x54, 0x8f);
1520 snd_es18xx_mixer_write(chip, 0x56, 0x95);
1521 snd_es18xx_mixer_write(chip, 0x58, 0x94);
1522 snd_es18xx_mixer_write(chip, 0x5a, 0x80);
1532 snd_es18xx_config_write(chip, 0x29, snd_es18xx_config_read(chip, 0x29) | 0x40);
1539 snd_es18xx_mixer_write(chip, 0x1c, 0x05 | mask);
1541 snd_es18xx_mixer_write(chip, 0x1c, 0x00 | mask);
1542 snd_es18xx_write(chip, 0xb4, 0x00);
1546 snd_es18xx_dsp_command(chip, 0xD1);
1557 if (snd_es18xx_reset(chip) < 0) {
1562 snd_es18xx_dsp_command(chip, 0xe7);
1563 hi = snd_es18xx_dsp_get_byte(chip);
1567 lo = snd_es18xx_dsp_get_byte(chip);
1568 if ((lo & 0xf0) != 0x80) {
1578 if ((lo & 0x0f) < 8) {
1603 if (snd_es18xx_mixer_writable(chip, 0x64, 0x04)) {
1605 if (snd_es18xx_mixer_writable(chip, 0x70, 0x7f)) {
1607 if (snd_es18xx_mixer_writable(chip, 0x64, 0x20)) {
1622 unsigned long mpu_port,
1623 unsigned long fm_port)
1625 if (snd_es18xx_identify(chip) < 0) {
1658 return snd_es18xx_initialize(chip, mpu_port, fm_port);
1661 static struct snd_pcm_ops snd_es18xx_playback_ops = {
1662 .open = snd_es18xx_playback_open,
1663 .close = snd_es18xx_playback_close,
1665 .hw_params = snd_es18xx_playback_hw_params,
1666 .hw_free = snd_es18xx_pcm_hw_free,
1667 .prepare = snd_es18xx_playback_prepare,
1668 .trigger = snd_es18xx_playback_trigger,
1669 .pointer = snd_es18xx_playback_pointer,
1672 static struct snd_pcm_ops snd_es18xx_capture_ops = {
1673 .open = snd_es18xx_capture_open,
1674 .close = snd_es18xx_capture_close,
1676 .hw_params = snd_es18xx_capture_hw_params,
1677 .hw_free = snd_es18xx_pcm_hw_free,
1678 .prepare = snd_es18xx_capture_prepare,
1679 .trigger = snd_es18xx_capture_trigger,
1680 .pointer = snd_es18xx_capture_pointer,
1717 chip->
dma1 > 3 || chip->
dma2 > 3 ? 128*1024 : 64*1024);
1732 snd_pcm_suspend_all(chip->
pcm);
1735 chip->pm_reg = (
unsigned char)snd_es18xx_read(chip,
ES18XX_PM);
1737 snd_es18xx_write(chip,
ES18XX_PM, chip->pm_reg);
1743 static int snd_es18xx_resume(
struct snd_card *card)
1755 static int snd_es18xx_free(
struct snd_card *card)
1764 if (chip->
dma1 >= 0) {
1775 static int snd_es18xx_dev_free(
struct snd_device *device)
1777 return snd_es18xx_free(device->
card);
1782 unsigned long mpu_port,
1783 unsigned long fm_port,
1788 .dev_free = snd_es18xx_dev_free,
1803 snd_es18xx_free(card);
1808 if (
request_irq(irq, snd_es18xx_interrupt, 0,
"ES18xx",
1810 snd_es18xx_free(card);
1817 snd_es18xx_free(card);
1823 if (dma2 != dma1 &&
request_dma(dma2,
"ES18xx DMA 2")) {
1824 snd_es18xx_free(card);
1830 if (snd_es18xx_probe(chip, mpu_port, fm_port) < 0) {
1831 snd_es18xx_free(card);
1836 snd_es18xx_free(card);
1850 for (idx = 0; idx <
ARRAY_SIZE(snd_es18xx_base_controls); idx++) {
1852 kctl =
snd_ctl_new1(&snd_es18xx_base_controls[idx], chip);
1869 for (idx = 0; idx <
ARRAY_SIZE(snd_es18xx_pcm2_controls); idx++) {
1874 for (idx = 0; idx <
ARRAY_SIZE(snd_es18xx_pcm1_controls); idx++) {
1881 for (idx = 0; idx <
ARRAY_SIZE(snd_es18xx_recmix_controls); idx++) {
1898 for (idx = 0; idx <
ARRAY_SIZE(snd_es18xx_spatializer_controls); idx++) {
1904 for (idx = 0; idx <
ARRAY_SIZE(snd_es18xx_hw_volume_controls); idx++) {
1906 kctl =
snd_ctl_new1(&snd_es18xx_hw_volume_controls[idx], chip);
1919 if (chip->
version != 0x1868) {
1925 if (chip->
version == 0x1869) {
1926 for (idx = 0; idx <
ARRAY_SIZE(snd_es18xx_opt_1869); idx++) {
1933 }
else if (chip->
version == 0x1878) {
1938 }
else if (chip->
version == 0x1879) {
1939 for (idx = 0; idx <
ARRAY_SIZE(snd_es18xx_opt_1879); idx++) {
1957 "{ESS,ES1869 PnP AudioDrive},"
1958 "{ESS,ES1878 PnP AudioDrive},"
1959 "{ESS,ES1879 PnP AudioDrive},"
1960 "{ESS,ES1887 PnP AudioDrive},"
1961 "{ESS,ES1888 PnP AudioDrive},"
1962 "{ESS,ES1887 AudioDrive},"
1963 "{ESS,ES1888 AudioDrive}}");
2006 static int isa_registered;
2007 static int pnp_registered;
2008 static int pnpc_registered;
2011 { .
id =
"ESS1869" },
2012 { .id =
"ESS1879" },
2035 port[
dev] = pnp_port_start(pdev, 0);
2036 fm_port[
dev] = pnp_port_start(pdev, 1);
2037 mpu_port[
dev] = pnp_port_start(pdev, 2);
2041 snd_printdd(
"PnP ES18xx: port=0x%lx, fm port=0x%lx, mpu port=0x%lx\n", port[dev], fm_port[dev], mpu_port[dev]);
2042 snd_printdd(
"PnP ES18xx: dma1=%i, dma2=%i, irq=%i\n", dma1[dev], dma2[dev], irq[dev]);
2050 if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0)
2057 { .
id =
"ESS1868", .devs = { {
"ESS1868" }, {
"ESS0000" } } },
2059 { .id =
"ESS1868", .devs = { {
"ESS8601" }, {
"ESS8600" } } },
2061 { .id =
"ESS1868", .devs = { {
"ESS8611" }, {
"ESS8610" } } },
2063 { .id =
"ESS0003", .devs = { {
"ESS1869" }, {
"ESS0006" } } },
2065 { .id =
"ESS1869", .devs = { {
"ESS1869" }, {
"ESS0006" } } },
2067 { .id =
"ESS1878", .devs = { {
"ESS1878" }, {
"ESS0004" } } },
2069 { .id =
"ESS1879", .devs = { {
"ESS1879" }, {
"ESS0009" } } },
2081 if (chip->dev ==
NULL)
2085 if (chip->devc ==
NULL)
2094 (
unsigned long long)pnp_port_start(chip->devc, 0));
2095 if (snd_audiodrive_pnp_init_main(dev, chip->dev) < 0)
2103 #define is_isapnp_selected(dev) isapnp[dev]
2105 #define is_isapnp_selected(dev) 0
2108 static int snd_es18xx_card_new(
int dev,
struct snd_card **cardp)
2120 err = snd_es18xx_new_device(card,
2121 port[dev], mpu_port[dev], fm_port[dev],
2122 irq[dev], dma1[dev], dma2[dev]);
2129 if (dma1[dev] != dma2[dev])
2133 irq[dev], dma1[dev], dma2[dev]);
2138 irq[dev], dma1[dev]);
2140 err = snd_es18xx_pcm(card, 0,
NULL);
2144 err = snd_es18xx_mixer(card);
2152 "opl3 not detected at 0x%lx\n",
2172 static int __devinit snd_es18xx_isa_match(
struct device *pdev,
unsigned int dev)
2177 static int __devinit snd_es18xx_isa_probe1(
int dev,
struct device *devptr)
2182 err = snd_es18xx_card_new(dev, &card);
2186 if ((err = snd_audiodrive_probe(card, dev)) < 0) {
2194 static int __devinit snd_es18xx_isa_probe(
struct device *pdev,
unsigned int dev)
2197 static int possible_irqs[] = {5, 9, 10, 7, 11, 12, -1};
2198 static int possible_dmas[] = {1, 0, 3, 5, -1};
2201 if ((irq[dev] = snd_legacy_find_free_irq(possible_irqs)) < 0) {
2207 if ((dma1[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) {
2213 if ((dma2[dev] = snd_legacy_find_free_dma(possible_dmas)) < 0) {
2220 return snd_es18xx_isa_probe1(dev, pdev);
2222 static unsigned long possible_ports[] = {0x220, 0x240, 0x260, 0x280};
2224 for (i = 0; i <
ARRAY_SIZE(possible_ports); i++) {
2225 port[
dev] = possible_ports[
i];
2226 err = snd_es18xx_isa_probe1(dev, pdev);
2234 static int __devexit snd_es18xx_isa_remove(
struct device *devptr,
2243 static int snd_es18xx_isa_suspend(
struct device *dev,
unsigned int n,
2249 static int snd_es18xx_isa_resume(
struct device *dev,
unsigned int n)
2255 #define DEV_NAME "es18xx"
2257 static struct isa_driver snd_es18xx_isa_driver = {
2258 .match = snd_es18xx_isa_match,
2259 .probe = snd_es18xx_isa_probe,
2262 .suspend = snd_es18xx_isa_suspend,
2263 .resume = snd_es18xx_isa_resume,
2282 if (enable[dev] && isapnp[dev])
2285 if (dev >= SNDRV_CARDS)
2288 err = snd_es18xx_card_new(dev, &card);
2291 if ((err = snd_audiodrive_pnp(dev, card->
private_data, pdev)) < 0) {
2296 if ((err = snd_audiodrive_probe(card, dev)) < 0) {
2300 pnp_set_drvdata(pdev, card);
2308 pnp_set_drvdata(pdev,
NULL);
2314 return snd_es18xx_suspend(pnp_get_drvdata(pdev), state);
2316 static int snd_audiodrive_pnp_resume(
struct pnp_dev *pdev)
2318 return snd_es18xx_resume(pnp_get_drvdata(pdev));
2322 static struct pnp_driver es18xx_pnp_driver = {
2323 .
name =
"es18xx-pnpbios",
2324 .id_table = snd_audiodrive_pnpbiosids,
2325 .probe = snd_audiodrive_pnp_detect,
2328 .suspend = snd_audiodrive_pnp_suspend,
2329 .resume = snd_audiodrive_pnp_resume,
2341 if (enable[dev] && isapnp[dev])
2344 if (dev >= SNDRV_CARDS)
2347 res = snd_es18xx_card_new(dev, &card);
2351 if ((res = snd_audiodrive_pnpc(dev, card->
private_data, pcard, pid)) < 0) {
2356 if ((res = snd_audiodrive_probe(card, dev)) < 0) {
2361 pnp_set_card_drvdata(pcard, card);
2369 pnp_set_card_drvdata(pcard,
NULL);
2375 return snd_es18xx_suspend(pnp_get_card_drvdata(pcard), state);
2378 static int snd_audiodrive_pnpc_resume(
struct pnp_card_link *pcard)
2380 return snd_es18xx_resume(pnp_get_card_drvdata(pcard));
2388 .id_table = snd_audiodrive_pnpids,
2389 .probe = snd_audiodrive_pnpc_detect,
2390 .remove =
__devexit_p(snd_audiodrive_pnpc_remove),
2392 .suspend = snd_audiodrive_pnpc_suspend,
2393 .resume = snd_audiodrive_pnpc_resume,
2398 static int __init alsa_card_es18xx_init(
void)
2413 pnpc_registered = 1;
2415 if (isa_registered || pnp_registered)
2421 static void __exit alsa_card_es18xx_exit(
void)
2424 if (pnpc_registered)