aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/ac97/ac97_codec.c2
-rw-r--r--sound/pci/ac97/ac97_patch.c2
-rw-r--r--sound/pci/ca0106/ca0106.h30
-rw-r--r--sound/pci/ca0106/ca0106_main.c550
-rw-r--r--sound/pci/ca0106/ca0106_mixer.c263
-rw-r--r--sound/pci/cs46xx/cs46xx_lib.c5
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c494
-rw-r--r--sound/pci/emu10k1/emumixer.c46
-rw-r--r--sound/pci/hda/patch_sigmatel.c23
-rw-r--r--sound/pci/ice1712/ice1724.c23
-rw-r--r--sound/pci/mixart/mixart.c4
-rw-r--r--sound/pci/pcxhr/pcxhr.c4
-rw-r--r--sound/pci/riptide/riptide.c2
13 files changed, 904 insertions, 544 deletions
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index bd510eceff1..e2b843b4f9d 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -175,7 +175,7 @@ static const struct ac97_codec_id snd_ac97_codec_ids[] = {
175{ 0x574d4C04, 0xffffffff, "WM9704M,WM9704Q", patch_wolfson04, NULL}, 175{ 0x574d4C04, 0xffffffff, "WM9704M,WM9704Q", patch_wolfson04, NULL},
176{ 0x574d4C05, 0xffffffff, "WM9705,WM9710", patch_wolfson05, NULL}, 176{ 0x574d4C05, 0xffffffff, "WM9705,WM9710", patch_wolfson05, NULL},
177{ 0x574d4C09, 0xffffffff, "WM9709", NULL, NULL}, 177{ 0x574d4C09, 0xffffffff, "WM9709", NULL, NULL},
178{ 0x574d4C12, 0xffffffff, "WM9711,WM9712", patch_wolfson11, NULL}, 178{ 0x574d4C12, 0xffffffff, "WM9711,WM9712,WM9715", patch_wolfson11, NULL},
179{ 0x574d4c13, 0xffffffff, "WM9713,WM9714", patch_wolfson13, NULL, AC97_DEFAULT_POWER_OFF}, 179{ 0x574d4c13, 0xffffffff, "WM9713,WM9714", patch_wolfson13, NULL, AC97_DEFAULT_POWER_OFF},
180{ 0x594d4800, 0xffffffff, "YMF743", patch_yamaha_ymf743, NULL }, 180{ 0x594d4800, 0xffffffff, "YMF743", patch_yamaha_ymf743, NULL },
181{ 0x594d4802, 0xffffffff, "YMF752", NULL, NULL }, 181{ 0x594d4802, 0xffffffff, "YMF752", NULL, NULL },
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 6e831aff1bd..2c7cd97d223 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -2832,6 +2832,8 @@ static int patch_alc655(struct snd_ac97 * ac97)
2832 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */ 2832 val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */
2833 else 2833 else
2834 val |= (1 << 1); /* Pin 47 is spdif input pin */ 2834 val |= (1 << 1); /* Pin 47 is spdif input pin */
2835 /* this seems missing on some hardwares */
2836 ac97->ext_id |= AC97_EI_SPDIF;
2835 } 2837 }
2836 val &= ~(1 << 12); /* vref enable */ 2838 val &= ~(1 << 12); /* vref enable */
2837 snd_ac97_write_cache(ac97, 0x7a, val); 2839 snd_ac97_write_cache(ac97, 0x7a, val);
diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h
index 74175fc80c7..14b8d9a91aa 100644
--- a/sound/pci/ca0106/ca0106.h
+++ b/sound/pci/ca0106/ca0106.h
@@ -664,10 +664,14 @@ struct snd_ca0106_pcm {
664struct snd_ca0106_details { 664struct snd_ca0106_details {
665 u32 serial; 665 u32 serial;
666 char * name; 666 char * name;
667 int ac97; 667 int ac97; /* ac97 = 0 -> Select MIC, Line in, TAD in, AUX in.
668 int gpio_type; 668 ac97 = 1 -> Default to AC97 in. */
669 int i2c_adc; 669 int gpio_type; /* gpio_type = 1 -> shared mic-in/line-in
670 int spi_dac; 670 gpio_type = 2 -> shared side-out/line-in. */
671 int i2c_adc; /* with i2c_adc=1, the driver adds some capture volume
672 controls, phone, mic, line-in and aux. */
673 int spi_dac; /* spi_dac=1 adds the mute switch for each analog
674 output, front, rear, etc. */
671}; 675};
672 676
673// definition of the chip-specific record 677// definition of the chip-specific record
@@ -686,11 +690,12 @@ struct snd_ca0106 {
686 spinlock_t emu_lock; 690 spinlock_t emu_lock;
687 691
688 struct snd_ac97 *ac97; 692 struct snd_ac97 *ac97;
689 struct snd_pcm *pcm; 693 struct snd_pcm *pcm[4];
690 694
691 struct snd_ca0106_channel playback_channels[4]; 695 struct snd_ca0106_channel playback_channels[4];
692 struct snd_ca0106_channel capture_channels[4]; 696 struct snd_ca0106_channel capture_channels[4];
693 u32 spdif_bits[4]; /* s/pdif out setup */ 697 u32 spdif_bits[4]; /* s/pdif out default setup */
698 u32 spdif_str_bits[4]; /* s/pdif out per-stream setup */
694 int spdif_enable; 699 int spdif_enable;
695 int capture_source; 700 int capture_source;
696 int i2c_capture_source; 701 int i2c_capture_source;
@@ -703,6 +708,11 @@ struct snd_ca0106 {
703 struct snd_ca_midi midi2; 708 struct snd_ca_midi midi2;
704 709
705 u16 spi_dac_reg[16]; 710 u16 spi_dac_reg[16];
711
712#ifdef CONFIG_PM
713#define NUM_SAVED_VOLUMES 9
714 unsigned int saved_vol[NUM_SAVED_VOLUMES];
715#endif
706}; 716};
707 717
708int snd_ca0106_mixer(struct snd_ca0106 *emu); 718int snd_ca0106_mixer(struct snd_ca0106 *emu);
@@ -721,3 +731,11 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu, u32 reg, u32 value);
721 731
722int snd_ca0106_spi_write(struct snd_ca0106 * emu, 732int snd_ca0106_spi_write(struct snd_ca0106 * emu,
723 unsigned int data); 733 unsigned int data);
734
735#ifdef CONFIG_PM
736void snd_ca0106_mixer_suspend(struct snd_ca0106 *chip);
737void snd_ca0106_mixer_resume(struct snd_ca0106 *chip);
738#else
739#define snd_ca0106_mixer_suspend(chip) do { } while (0)
740#define snd_ca0106_mixer_resume(chip) do { } while (0)
741#endif
diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c
index 88fbf285d2b..0e62205d408 100644
--- a/sound/pci/ca0106/ca0106_main.c
+++ b/sound/pci/ca0106/ca0106_main.c
@@ -254,7 +254,7 @@ static struct snd_ca0106_details ca0106_chip_details[] = {
254 .name = "MSI K8N Diamond MB", 254 .name = "MSI K8N Diamond MB",
255 .gpio_type = 2, 255 .gpio_type = 2,
256 .i2c_adc = 1, 256 .i2c_adc = 1,
257 .spi_dac = 2 } , 257 .spi_dac = 1 } ,
258 /* Shuttle XPC SD31P which has an onboard Creative Labs 258 /* Shuttle XPC SD31P which has an onboard Creative Labs
259 * Sound Blaster Live! 24-bit EAX 259 * Sound Blaster Live! 24-bit EAX
260 * high-definition 7.1 audio processor". 260 * high-definition 7.1 audio processor".
@@ -305,9 +305,15 @@ static struct snd_pcm_hardware snd_ca0106_capture_hw = {
305 SNDRV_PCM_INFO_BLOCK_TRANSFER | 305 SNDRV_PCM_INFO_BLOCK_TRANSFER |
306 SNDRV_PCM_INFO_MMAP_VALID), 306 SNDRV_PCM_INFO_MMAP_VALID),
307 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, 307 .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
308#if 0 /* FIXME: looks like 44.1kHz capture causes noisy output on 48kHz */
308 .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | 309 .rates = (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
309 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000), 310 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000),
310 .rate_min = 44100, 311 .rate_min = 44100,
312#else
313 .rates = (SNDRV_PCM_RATE_48000 |
314 SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000),
315 .rate_min = 48000,
316#endif /* FIXME */
311 .rate_max = 192000, 317 .rate_max = 192000,
312 .channels_min = 2, 318 .channels_min = 2,
313 .channels_max = 2, 319 .channels_max = 2,
@@ -479,6 +485,15 @@ static const int spi_dacd_bit[] = {
479 [PCM_UNKNOWN_CHANNEL] = SPI_DACD1_BIT, 485 [PCM_UNKNOWN_CHANNEL] = SPI_DACD1_BIT,
480}; 486};
481 487
488static void restore_spdif_bits(struct snd_ca0106 *chip, int idx)
489{
490 if (chip->spdif_str_bits[idx] != chip->spdif_bits[idx]) {
491 chip->spdif_str_bits[idx] = chip->spdif_bits[idx];
492 snd_ca0106_ptr_write(chip, SPCS0 + idx, 0,
493 chip->spdif_str_bits[idx]);
494 }
495}
496
482/* open_playback callback */ 497/* open_playback callback */
483static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream, 498static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream,
484 int channel_id) 499 int channel_id)
@@ -524,6 +539,9 @@ static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substr
524 if (err < 0) 539 if (err < 0)
525 return err; 540 return err;
526 } 541 }
542
543 restore_spdif_bits(chip, channel_id);
544
527 return 0; 545 return 0;
528} 546}
529 547
@@ -535,6 +553,8 @@ static int snd_ca0106_pcm_close_playback(struct snd_pcm_substream *substream)
535 struct snd_ca0106_pcm *epcm = runtime->private_data; 553 struct snd_ca0106_pcm *epcm = runtime->private_data;
536 chip->playback_channels[epcm->channel_id].use = 0; 554 chip->playback_channels[epcm->channel_id].use = 0;
537 555
556 restore_spdif_bits(chip, epcm->channel_id);
557
538 if (chip->details->spi_dac && epcm->channel_id != PCM_FRONT_CHANNEL) { 558 if (chip->details->spi_dac && epcm->channel_id != PCM_FRONT_CHANNEL) {
539 const int reg = spi_dacd_reg[epcm->channel_id]; 559 const int reg = spi_dacd_reg[epcm->channel_id];
540 560
@@ -847,15 +867,18 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
847 struct snd_pcm_substream *s; 867 struct snd_pcm_substream *s;
848 u32 basic = 0; 868 u32 basic = 0;
849 u32 extended = 0; 869 u32 extended = 0;
850 int running=0; 870 u32 bits;
871 int running = 0;
851 872
852 switch (cmd) { 873 switch (cmd) {
853 case SNDRV_PCM_TRIGGER_START: 874 case SNDRV_PCM_TRIGGER_START:
854 running=1; 875 case SNDRV_PCM_TRIGGER_RESUME:
876 running = 1;
855 break; 877 break;
856 case SNDRV_PCM_TRIGGER_STOP: 878 case SNDRV_PCM_TRIGGER_STOP:
879 case SNDRV_PCM_TRIGGER_SUSPEND:
857 default: 880 default:
858 running=0; 881 running = 0;
859 break; 882 break;
860 } 883 }
861 snd_pcm_group_for_each_entry(s, substream) { 884 snd_pcm_group_for_each_entry(s, substream) {
@@ -865,22 +888,32 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream,
865 runtime = s->runtime; 888 runtime = s->runtime;
866 epcm = runtime->private_data; 889 epcm = runtime->private_data;
867 channel = epcm->channel_id; 890 channel = epcm->channel_id;
868 //snd_printk("channel=%d\n",channel); 891 /* snd_printk("channel=%d\n",channel); */
869 epcm->running = running; 892 epcm->running = running;
870 basic |= (0x1<<channel); 893 basic |= (0x1 << channel);
871 extended |= (0x10<<channel); 894 extended |= (0x10 << channel);
872 snd_pcm_trigger_done(s, substream); 895 snd_pcm_trigger_done(s, substream);
873 } 896 }
874 //snd_printk("basic=0x%x, extended=0x%x\n",basic, extended); 897 /* snd_printk("basic=0x%x, extended=0x%x\n",basic, extended); */
875 898
876 switch (cmd) { 899 switch (cmd) {
877 case SNDRV_PCM_TRIGGER_START: 900 case SNDRV_PCM_TRIGGER_START:
878 snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0) | (extended)); 901 case SNDRV_PCM_TRIGGER_RESUME:
879 snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0)|(basic)); 902 bits = snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0);
903 bits |= extended;
904 snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, bits);
905 bits = snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0);
906 bits |= basic;
907 snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, bits);
880 break; 908 break;
881 case SNDRV_PCM_TRIGGER_STOP: 909 case SNDRV_PCM_TRIGGER_STOP:
882 snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0) & ~(basic)); 910 case SNDRV_PCM_TRIGGER_SUSPEND:
883 snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0) & ~(extended)); 911 bits = snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0);
912 bits &= ~basic;
913 snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, bits);
914 bits = snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0);
915 bits &= ~extended;
916 snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, bits);
884 break; 917 break;
885 default: 918 default:
886 result = -EINVAL; 919 result = -EINVAL;
@@ -1103,21 +1136,13 @@ static int snd_ca0106_ac97(struct snd_ca0106 *chip)
1103 return snd_ac97_mixer(pbus, &ac97, &chip->ac97); 1136 return snd_ac97_mixer(pbus, &ac97, &chip->ac97);
1104} 1137}
1105 1138
1139static void ca0106_stop_chip(struct snd_ca0106 *chip);
1140
1106static int snd_ca0106_free(struct snd_ca0106 *chip) 1141static int snd_ca0106_free(struct snd_ca0106 *chip)
1107{ 1142{
1108 if (chip->res_port != NULL) { /* avoid access to already used hardware */ 1143 if (chip->res_port != NULL) {
1109 // disable interrupts 1144 /* avoid access to already used hardware */
1110 snd_ca0106_ptr_write(chip, BASIC_INTERRUPT, 0, 0); 1145 ca0106_stop_chip(chip);
1111 outl(0, chip->port + INTE);
1112 snd_ca0106_ptr_write(chip, EXTENDED_INT_MASK, 0, 0);
1113 udelay(1000);
1114 // disable audio
1115 //outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG);
1116 outl(0, chip->port + HCFG);
1117 /* FIXME: We need to stop and DMA transfers here.
1118 * But as I am not sure how yet, we cannot from the dma pages.
1119 * So we can fix: snd-malloc: Memory leak? pages not freed = 8
1120 */
1121 } 1146 }
1122 if (chip->irq >= 0) 1147 if (chip->irq >= 0)
1123 free_irq(chip->irq, chip); 1148 free_irq(chip->irq, chip);
@@ -1203,15 +1228,14 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id)
1203 return IRQ_HANDLED; 1228 return IRQ_HANDLED;
1204} 1229}
1205 1230
1206static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct snd_pcm **rpcm) 1231static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device)
1207{ 1232{
1208 struct snd_pcm *pcm; 1233 struct snd_pcm *pcm;
1209 struct snd_pcm_substream *substream; 1234 struct snd_pcm_substream *substream;
1210 int err; 1235 int err;
1211 1236
1212 if (rpcm) 1237 err = snd_pcm_new(emu->card, "ca0106", device, 1, 1, &pcm);
1213 *rpcm = NULL; 1238 if (err < 0)
1214 if ((err = snd_pcm_new(emu->card, "ca0106", device, 1, 1, &pcm)) < 0)
1215 return err; 1239 return err;
1216 1240
1217 pcm->private_data = emu; 1241 pcm->private_data = emu;
@@ -1238,7 +1262,6 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct s
1238 pcm->info_flags = 0; 1262 pcm->info_flags = 0;
1239 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; 1263 pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX;
1240 strcpy(pcm->name, "CA0106"); 1264 strcpy(pcm->name, "CA0106");
1241 emu->pcm = pcm;
1242 1265
1243 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; 1266 for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream;
1244 substream; 1267 substream;
@@ -1260,8 +1283,7 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct s
1260 return err; 1283 return err;
1261 } 1284 }
1262 1285
1263 if (rpcm) 1286 emu->pcm[device] = pcm;
1264 *rpcm = pcm;
1265 1287
1266 return 0; 1288 return 0;
1267} 1289}
@@ -1301,89 +1323,10 @@ static unsigned int i2c_adc_init[][2] = {
1301 { 0x15, ADC_MUX_LINEIN }, /* ADC Mixer control */ 1323 { 0x15, ADC_MUX_LINEIN }, /* ADC Mixer control */
1302}; 1324};
1303 1325
1304static int __devinit snd_ca0106_create(int dev, struct snd_card *card, 1326static void ca0106_init_chip(struct snd_ca0106 *chip, int resume)
1305 struct pci_dev *pci,
1306 struct snd_ca0106 **rchip)
1307{ 1327{
1308 struct snd_ca0106 *chip;
1309 struct snd_ca0106_details *c;
1310 int err;
1311 int ch; 1328 int ch;
1312 static struct snd_device_ops ops = { 1329 unsigned int def_bits;
1313 .dev_free = snd_ca0106_dev_free,
1314 };
1315
1316 *rchip = NULL;
1317
1318 if ((err = pci_enable_device(pci)) < 0)
1319 return err;
1320 if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 ||
1321 pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) {
1322 printk(KERN_ERR "error to set 32bit mask DMA\n");
1323 pci_disable_device(pci);
1324 return -ENXIO;
1325 }
1326
1327 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1328 if (chip == NULL) {
1329 pci_disable_device(pci);
1330 return -ENOMEM;
1331 }
1332
1333 chip->card = card;
1334 chip->pci = pci;
1335 chip->irq = -1;
1336
1337 spin_lock_init(&chip->emu_lock);
1338
1339 chip->port = pci_resource_start(pci, 0);
1340 if ((chip->res_port = request_region(chip->port, 0x20,
1341 "snd_ca0106")) == NULL) {
1342 snd_ca0106_free(chip);
1343 printk(KERN_ERR "cannot allocate the port\n");
1344 return -EBUSY;
1345 }
1346
1347 if (request_irq(pci->irq, snd_ca0106_interrupt,
1348 IRQF_SHARED, "snd_ca0106", chip)) {
1349 snd_ca0106_free(chip);
1350 printk(KERN_ERR "cannot grab irq\n");
1351 return -EBUSY;
1352 }
1353 chip->irq = pci->irq;
1354
1355 /* This stores the periods table. */
1356 if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1024, &chip->buffer) < 0) {
1357 snd_ca0106_free(chip);
1358 return -ENOMEM;
1359 }
1360
1361 pci_set_master(pci);
1362 /* read serial */
1363 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
1364 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
1365#if 1
1366 printk(KERN_INFO "snd-ca0106: Model %04x Rev %08x Serial %08x\n", chip->model,
1367 pci->revision, chip->serial);
1368#endif
1369 strcpy(card->driver, "CA0106");
1370 strcpy(card->shortname, "CA0106");
1371
1372 for (c = ca0106_chip_details; c->serial; c++) {
1373 if (subsystem[dev]) {
1374 if (c->serial == subsystem[dev])
1375 break;
1376 } else if (c->serial == chip->serial)
1377 break;
1378 }
1379 chip->details = c;
1380 if (subsystem[dev]) {
1381 printk(KERN_INFO "snd-ca0106: Sound card name=%s, subsystem=0x%x. Forced to subsystem=0x%x\n",
1382 c->name, chip->serial, subsystem[dev]);
1383 }
1384
1385 sprintf(card->longname, "%s at 0x%lx irq %i",
1386 c->name, chip->port, chip->irq);
1387 1330
1388 outl(0, chip->port + INTE); 1331 outl(0, chip->port + INTE);
1389 1332
@@ -1401,31 +1344,22 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
1401 * AN = 0 (Audio data) 1344 * AN = 0 (Audio data)
1402 * P = 0 (Consumer) 1345 * P = 0 (Consumer)
1403 */ 1346 */
1404 snd_ca0106_ptr_write(chip, SPCS0, 0, 1347 def_bits =
1405 chip->spdif_bits[0] = 1348 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 |
1406 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 1349 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC |
1407 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | 1350 SPCS_GENERATIONSTATUS | 0x00001200 |
1408 SPCS_GENERATIONSTATUS | 0x00001200 | 1351 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT;
1409 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); 1352 if (!resume) {
1353 chip->spdif_str_bits[0] = chip->spdif_bits[0] = def_bits;
1354 chip->spdif_str_bits[1] = chip->spdif_bits[1] = def_bits;
1355 chip->spdif_str_bits[2] = chip->spdif_bits[2] = def_bits;
1356 chip->spdif_str_bits[3] = chip->spdif_bits[3] = def_bits;
1357 }
1410 /* Only SPCS1 has been tested */ 1358 /* Only SPCS1 has been tested */
1411 snd_ca0106_ptr_write(chip, SPCS1, 0, 1359 snd_ca0106_ptr_write(chip, SPCS1, 0, chip->spdif_str_bits[1]);
1412 chip->spdif_bits[1] = 1360 snd_ca0106_ptr_write(chip, SPCS0, 0, chip->spdif_str_bits[0]);
1413 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | 1361 snd_ca0106_ptr_write(chip, SPCS2, 0, chip->spdif_str_bits[2]);
1414 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | 1362 snd_ca0106_ptr_write(chip, SPCS3, 0, chip->spdif_str_bits[3]);
1415 SPCS_GENERATIONSTATUS | 0x00001200 |
1416 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT);
1417 snd_ca0106_ptr_write(chip, SPCS2, 0,
1418 chip->spdif_bits[2] =
1419 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 |
1420 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC |
1421 SPCS_GENERATIONSTATUS | 0x00001200 |
1422 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT);
1423 snd_ca0106_ptr_write(chip, SPCS3, 0,
1424 chip->spdif_bits[3] =
1425 SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 |
1426 SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC |
1427 SPCS_GENERATIONSTATUS | 0x00001200 |
1428 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT);
1429 1363
1430 snd_ca0106_ptr_write(chip, PLAYBACK_MUTE, 0, 0x00fc0000); 1364 snd_ca0106_ptr_write(chip, PLAYBACK_MUTE, 0, 0x00fc0000);
1431 snd_ca0106_ptr_write(chip, CAPTURE_MUTE, 0, 0x00fc0000); 1365 snd_ca0106_ptr_write(chip, CAPTURE_MUTE, 0, 0x00fc0000);
@@ -1433,92 +1367,124 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
1433 /* Write 0x8000 to AC97_REC_GAIN to mute it. */ 1367 /* Write 0x8000 to AC97_REC_GAIN to mute it. */
1434 outb(AC97_REC_GAIN, chip->port + AC97ADDRESS); 1368 outb(AC97_REC_GAIN, chip->port + AC97ADDRESS);
1435 outw(0x8000, chip->port + AC97DATA); 1369 outw(0x8000, chip->port + AC97DATA);
1436#if 0 1370#if 0 /* FIXME: what are these? */
1437 snd_ca0106_ptr_write(chip, SPCS0, 0, 0x2108006); 1371 snd_ca0106_ptr_write(chip, SPCS0, 0, 0x2108006);
1438 snd_ca0106_ptr_write(chip, 0x42, 0, 0x2108006); 1372 snd_ca0106_ptr_write(chip, 0x42, 0, 0x2108006);
1439 snd_ca0106_ptr_write(chip, 0x43, 0, 0x2108006); 1373 snd_ca0106_ptr_write(chip, 0x43, 0, 0x2108006);
1440 snd_ca0106_ptr_write(chip, 0x44, 0, 0x2108006); 1374 snd_ca0106_ptr_write(chip, 0x44, 0, 0x2108006);
1441#endif 1375#endif
1442 1376
1443 //snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0xf0f003f); /* OSS drivers set this. */ 1377 /* OSS drivers set this. */
1378 /* snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0xf0f003f); */
1379
1444 /* Analog or Digital output */ 1380 /* Analog or Digital output */
1445 snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf); 1381 snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf);
1446 snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000f0000); /* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers. Use 0x000f0000 for surround71 */ 1382 /* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers.
1383 * Use 0x000f0000 for surround71
1384 */
1385 snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000f0000);
1386
1447 chip->spdif_enable = 0; /* Set digital SPDIF output off */ 1387 chip->spdif_enable = 0; /* Set digital SPDIF output off */
1448 //snd_ca0106_ptr_write(chip, 0x45, 0, 0); /* Analogue out */ 1388 /*snd_ca0106_ptr_write(chip, 0x45, 0, 0);*/ /* Analogue out */
1449 //snd_ca0106_ptr_write(chip, 0x45, 0, 0xf00); /* Digital out */ 1389 /*snd_ca0106_ptr_write(chip, 0x45, 0, 0xf00);*/ /* Digital out */
1390
1391 /* goes to 0x40c80000 when doing SPDIF IN/OUT */
1392 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 0, 0x40c81000);
1393 /* (Mute) CAPTURE feedback into PLAYBACK volume.
1394 * Only lower 16 bits matter.
1395 */
1396 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 1, 0xffffffff);
1397 /* SPDIF IN Volume */
1398 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 2, 0x30300000);
1399 /* SPDIF IN Volume, 0x70 = (vol & 0x3f) | 0x40 */
1400 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 3, 0x00700000);
1450 1401
1451 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 0, 0x40c81000); /* goes to 0x40c80000 when doing SPDIF IN/OUT */
1452 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 1, 0xffffffff); /* (Mute) CAPTURE feedback into PLAYBACK volume. Only lower 16 bits matter. */
1453 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 2, 0x30300000); /* SPDIF IN Volume */
1454 snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 3, 0x00700000); /* SPDIF IN Volume, 0x70 = (vol & 0x3f) | 0x40 */
1455 snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING1, 0, 0x32765410); 1402 snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING1, 0, 0x32765410);
1456 snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING2, 0, 0x76767676); 1403 snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING2, 0, 0x76767676);
1457 snd_ca0106_ptr_write(chip, CAPTURE_ROUTING1, 0, 0x32765410); 1404 snd_ca0106_ptr_write(chip, CAPTURE_ROUTING1, 0, 0x32765410);
1458 snd_ca0106_ptr_write(chip, CAPTURE_ROUTING2, 0, 0x76767676); 1405 snd_ca0106_ptr_write(chip, CAPTURE_ROUTING2, 0, 0x76767676);
1459 for(ch = 0; ch < 4; ch++) { 1406
1460 snd_ca0106_ptr_write(chip, CAPTURE_VOLUME1, ch, 0x30303030); /* Only high 16 bits matter */ 1407 for (ch = 0; ch < 4; ch++) {
1408 /* Only high 16 bits matter */
1409 snd_ca0106_ptr_write(chip, CAPTURE_VOLUME1, ch, 0x30303030);
1461 snd_ca0106_ptr_write(chip, CAPTURE_VOLUME2, ch, 0x30303030); 1410 snd_ca0106_ptr_write(chip, CAPTURE_VOLUME2, ch, 0x30303030);
1462 //snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0x40404040); /* Mute */ 1411#if 0 /* Mute */
1463 //snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0x40404040); /* Mute */ 1412 snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0x40404040);
1464 snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0xffffffff); /* Mute */ 1413 snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0x40404040);
1465 snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0xffffffff); /* Mute */ 1414 snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0xffffffff);
1415 snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0xffffffff);
1416#endif
1466 } 1417 }
1467 if (chip->details->i2c_adc == 1) { 1418 if (chip->details->i2c_adc == 1) {
1468 /* Select MIC, Line in, TAD in, AUX in */ 1419 /* Select MIC, Line in, TAD in, AUX in */
1469 snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); 1420 snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4);
1470 /* Default to CAPTURE_SOURCE to i2s in */ 1421 /* Default to CAPTURE_SOURCE to i2s in */
1471 chip->capture_source = 3; 1422 if (!resume)
1423 chip->capture_source = 3;
1472 } else if (chip->details->ac97 == 1) { 1424 } else if (chip->details->ac97 == 1) {
1473 /* Default to AC97 in */ 1425 /* Default to AC97 in */
1474 snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x444400e4); 1426 snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x444400e4);
1475 /* Default to CAPTURE_SOURCE to AC97 in */ 1427 /* Default to CAPTURE_SOURCE to AC97 in */
1476 chip->capture_source = 4; 1428 if (!resume)
1429 chip->capture_source = 4;
1477 } else { 1430 } else {
1478 /* Select MIC, Line in, TAD in, AUX in */ 1431 /* Select MIC, Line in, TAD in, AUX in */
1479 snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); 1432 snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4);
1480 /* Default to Set CAPTURE_SOURCE to i2s in */ 1433 /* Default to Set CAPTURE_SOURCE to i2s in */
1481 chip->capture_source = 3; 1434 if (!resume)
1435 chip->capture_source = 3;
1482 } 1436 }
1483 1437
1484 if (chip->details->gpio_type == 2) { /* The SB0438 use GPIO differently. */ 1438 if (chip->details->gpio_type == 2) {
1485 /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */ 1439 /* The SB0438 use GPIO differently. */
1440 /* FIXME: Still need to find out what the other GPIO bits do.
1441 * E.g. For digital spdif out.
1442 */
1486 outl(0x0, chip->port+GPIO); 1443 outl(0x0, chip->port+GPIO);
1487 //outl(0x00f0e000, chip->port+GPIO); /* Analog */ 1444 /* outl(0x00f0e000, chip->port+GPIO); */ /* Analog */
1488 outl(0x005f5301, chip->port+GPIO); /* Analog */ 1445 outl(0x005f5301, chip->port+GPIO); /* Analog */
1489 } else if (chip->details->gpio_type == 1) { /* The SB0410 and SB0413 use GPIO differently. */ 1446 } else if (chip->details->gpio_type == 1) {
1490 /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */ 1447 /* The SB0410 and SB0413 use GPIO differently. */
1448 /* FIXME: Still need to find out what the other GPIO bits do.
1449 * E.g. For digital spdif out.
1450 */
1491 outl(0x0, chip->port+GPIO); 1451 outl(0x0, chip->port+GPIO);
1492 //outl(0x00f0e000, chip->port+GPIO); /* Analog */ 1452 /* outl(0x00f0e000, chip->port+GPIO); */ /* Analog */
1493 outl(0x005f5301, chip->port+GPIO); /* Analog */ 1453 outl(0x005f5301, chip->port+GPIO); /* Analog */
1494 } else { 1454 } else {
1495 outl(0x0, chip->port+GPIO); 1455 outl(0x0, chip->port+GPIO);
1496 outl(0x005f03a3, chip->port+GPIO); /* Analog */ 1456 outl(0x005f03a3, chip->port+GPIO); /* Analog */
1497 //outl(0x005f02a2, chip->port+GPIO); /* SPDIF */ 1457 /* outl(0x005f02a2, chip->port+GPIO); */ /* SPDIF */
1498 } 1458 }
1499 snd_ca0106_intr_enable(chip, 0x105); /* Win2000 uses 0x1e0 */ 1459 snd_ca0106_intr_enable(chip, 0x105); /* Win2000 uses 0x1e0 */
1500 1460
1501 //outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG); 1461 /* outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG); */
1502 //outl(0x00001409, chip->port+HCFG); /* 0x1000 causes AC3 to fails. Maybe it effects 24 bit output. */ 1462 /* 0x1000 causes AC3 to fails. Maybe it effects 24 bit output. */
1503 //outl(0x00000009, chip->port+HCFG); 1463 /* outl(0x00001409, chip->port+HCFG); */
1504 outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG); /* AC97 2.0, Enable outputs. */ 1464 /* outl(0x00000009, chip->port+HCFG); */
1465 /* AC97 2.0, Enable outputs. */
1466 outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG);
1505 1467
1506 if (chip->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ 1468 if (chip->details->i2c_adc == 1) {
1469 /* The SB0410 and SB0413 use I2C to control ADC. */
1507 int size, n; 1470 int size, n;
1508 1471
1509 size = ARRAY_SIZE(i2c_adc_init); 1472 size = ARRAY_SIZE(i2c_adc_init);
1510 //snd_printk("I2C:array size=0x%x\n", size); 1473 /* snd_printk("I2C:array size=0x%x\n", size); */
1511 for (n=0; n < size; n++) { 1474 for (n = 0; n < size; n++)
1512 snd_ca0106_i2c_write(chip, i2c_adc_init[n][0], i2c_adc_init[n][1]); 1475 snd_ca0106_i2c_write(chip, i2c_adc_init[n][0],
1513 } 1476 i2c_adc_init[n][1]);
1514 for (n=0; n < 4; n++) { 1477 for (n = 0; n < 4; n++) {
1515 chip->i2c_capture_volume[n][0]= 0xcf; 1478 chip->i2c_capture_volume[n][0] = 0xcf;
1516 chip->i2c_capture_volume[n][1]= 0xcf; 1479 chip->i2c_capture_volume[n][1] = 0xcf;
1517 } 1480 }
1518 chip->i2c_capture_source=2; /* Line in */ 1481 chip->i2c_capture_source = 2; /* Line in */
1519 //snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */ 1482 /* Enable Line-in capture. MIC in currently untested. */
1483 /* snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); */
1520 } 1484 }
1521 if (chip->details->spi_dac == 1) { /* The SB0570 use SPI to control DAC. */ 1485
1486 if (chip->details->spi_dac == 1) {
1487 /* The SB0570 use SPI to control DAC. */
1522 int size, n; 1488 int size, n;
1523 1489
1524 size = ARRAY_SIZE(spi_dac_init); 1490 size = ARRAY_SIZE(spi_dac_init);
@@ -1530,9 +1496,112 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
1530 chip->spi_dac_reg[reg] = spi_dac_init[n]; 1496 chip->spi_dac_reg[reg] = spi_dac_init[n];
1531 } 1497 }
1532 } 1498 }
1499}
1533 1500
1534 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, 1501static void ca0106_stop_chip(struct snd_ca0106 *chip)
1535 chip, &ops)) < 0) { 1502{
1503 /* disable interrupts */
1504 snd_ca0106_ptr_write(chip, BASIC_INTERRUPT, 0, 0);
1505 outl(0, chip->port + INTE);
1506 snd_ca0106_ptr_write(chip, EXTENDED_INT_MASK, 0, 0);
1507 udelay(1000);
1508 /* disable audio */
1509 /* outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); */
1510 outl(0, chip->port + HCFG);
1511 /* FIXME: We need to stop and DMA transfers here.
1512 * But as I am not sure how yet, we cannot from the dma pages.
1513 * So we can fix: snd-malloc: Memory leak? pages not freed = 8
1514 */
1515}
1516
1517static int __devinit snd_ca0106_create(int dev, struct snd_card *card,
1518 struct pci_dev *pci,
1519 struct snd_ca0106 **rchip)
1520{
1521 struct snd_ca0106 *chip;
1522 struct snd_ca0106_details *c;
1523 int err;
1524 static struct snd_device_ops ops = {
1525 .dev_free = snd_ca0106_dev_free,
1526 };
1527
1528 *rchip = NULL;
1529
1530 err = pci_enable_device(pci);
1531 if (err < 0)
1532 return err;
1533 if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 ||
1534 pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) {
1535 printk(KERN_ERR "error to set 32bit mask DMA\n");
1536 pci_disable_device(pci);
1537 return -ENXIO;
1538 }
1539
1540 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1541 if (chip == NULL) {
1542 pci_disable_device(pci);
1543 return -ENOMEM;
1544 }
1545
1546 chip->card = card;
1547 chip->pci = pci;
1548 chip->irq = -1;
1549
1550 spin_lock_init(&chip->emu_lock);
1551
1552 chip->port = pci_resource_start(pci, 0);
1553 chip->res_port = request_region(chip->port, 0x20, "snd_ca0106");
1554 if (!chip->res_port) {
1555 snd_ca0106_free(chip);
1556 printk(KERN_ERR "cannot allocate the port\n");
1557 return -EBUSY;
1558 }
1559
1560 if (request_irq(pci->irq, snd_ca0106_interrupt,
1561 IRQF_SHARED, "snd_ca0106", chip)) {
1562 snd_ca0106_free(chip);
1563 printk(KERN_ERR "cannot grab irq\n");
1564 return -EBUSY;
1565 }
1566 chip->irq = pci->irq;
1567
1568 /* This stores the periods table. */
1569 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
1570 1024, &chip->buffer) < 0) {
1571 snd_ca0106_free(chip);
1572 return -ENOMEM;
1573 }
1574
1575 pci_set_master(pci);
1576 /* read serial */
1577 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial);
1578 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model);
1579 printk(KERN_INFO "snd-ca0106: Model %04x Rev %08x Serial %08x\n",
1580 chip->model, pci->revision, chip->serial);
1581 strcpy(card->driver, "CA0106");
1582 strcpy(card->shortname, "CA0106");
1583
1584 for (c = ca0106_chip_details; c->serial; c++) {
1585 if (subsystem[dev]) {
1586 if (c->serial == subsystem[dev])
1587 break;
1588 } else if (c->serial == chip->serial)
1589 break;
1590 }
1591 chip->details = c;
1592 if (subsystem[dev]) {
1593 printk(KERN_INFO "snd-ca0106: Sound card name=%s, "
1594 "subsystem=0x%x. Forced to subsystem=0x%x\n",
1595 c->name, chip->serial, subsystem[dev]);
1596 }
1597
1598 sprintf(card->longname, "%s at 0x%lx irq %i",
1599 c->name, chip->port, chip->irq);
1600
1601 ca0106_init_chip(chip, 0);
1602
1603 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
1604 if (err < 0) {
1536 snd_ca0106_free(chip); 1605 snd_ca0106_free(chip);
1537 return err; 1606 return err;
1538 } 1607 }
@@ -1629,7 +1698,7 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci,
1629 static int dev; 1698 static int dev;
1630 struct snd_card *card; 1699 struct snd_card *card;
1631 struct snd_ca0106 *chip; 1700 struct snd_ca0106 *chip;
1632 int err; 1701 int i, err;
1633 1702
1634 if (dev >= SNDRV_CARDS) 1703 if (dev >= SNDRV_CARDS)
1635 return -ENODEV; 1704 return -ENODEV;
@@ -1642,44 +1711,31 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci,
1642 if (card == NULL) 1711 if (card == NULL)
1643 return -ENOMEM; 1712 return -ENOMEM;
1644 1713
1645 if ((err = snd_ca0106_create(dev, card, pci, &chip)) < 0) { 1714 err = snd_ca0106_create(dev, card, pci, &chip);
1646 snd_card_free(card); 1715 if (err < 0)
1647 return err; 1716 goto error;
1648 } 1717 card->private_data = chip;
1649 1718
1650 if ((err = snd_ca0106_pcm(chip, 0, NULL)) < 0) { 1719 for (i = 0; i < 4; i++) {
1651 snd_card_free(card); 1720 err = snd_ca0106_pcm(chip, i);
1652 return err; 1721 if (err < 0)
1653 } 1722 goto error;
1654 if ((err = snd_ca0106_pcm(chip, 1, NULL)) < 0) {
1655 snd_card_free(card);
1656 return err;
1657 }
1658 if ((err = snd_ca0106_pcm(chip, 2, NULL)) < 0) {
1659 snd_card_free(card);
1660 return err;
1661 }
1662 if ((err = snd_ca0106_pcm(chip, 3, NULL)) < 0) {
1663 snd_card_free(card);
1664 return err;
1665 }
1666 if (chip->details->ac97 == 1) { /* The SB0410 and SB0413 do not have an AC97 chip. */
1667 if ((err = snd_ca0106_ac97(chip)) < 0) {
1668 snd_card_free(card);
1669 return err;
1670 }
1671 } 1723 }
1672 if ((err = snd_ca0106_mixer(chip)) < 0) { 1724
1673 snd_card_free(card); 1725 if (chip->details->ac97 == 1) {
1674 return err; 1726 /* The SB0410 and SB0413 do not have an AC97 chip. */
1727 err = snd_ca0106_ac97(chip);
1728 if (err < 0)
1729 goto error;
1675 } 1730 }
1731 err = snd_ca0106_mixer(chip);
1732 if (err < 0)
1733 goto error;
1676 1734
1677 snd_printdd("ca0106: probe for MIDI channel A ..."); 1735 snd_printdd("ca0106: probe for MIDI channel A ...");
1678 if ((err = snd_ca0106_midi(chip,CA0106_MIDI_CHAN_A)) < 0) { 1736 err = snd_ca0106_midi(chip, CA0106_MIDI_CHAN_A);
1679 snd_card_free(card); 1737 if (err < 0)
1680 snd_printdd(" failed, err=0x%x\n",err); 1738 goto error;
1681 return err;
1682 }
1683 snd_printdd(" done.\n"); 1739 snd_printdd(" done.\n");
1684 1740
1685#ifdef CONFIG_PROC_FS 1741#ifdef CONFIG_PROC_FS
@@ -1688,14 +1744,17 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci,
1688 1744
1689 snd_card_set_dev(card, &pci->dev); 1745 snd_card_set_dev(card, &pci->dev);
1690 1746
1691 if ((err = snd_card_register(card)) < 0) { 1747 err = snd_card_register(card);
1692 snd_card_free(card); 1748 if (err < 0)
1693 return err; 1749 goto error;
1694 }
1695 1750
1696 pci_set_drvdata(pci, card); 1751 pci_set_drvdata(pci, card);
1697 dev++; 1752 dev++;
1698 return 0; 1753 return 0;
1754
1755 error:
1756 snd_card_free(card);
1757 return err;
1699} 1758}
1700 1759
1701static void __devexit snd_ca0106_remove(struct pci_dev *pci) 1760static void __devexit snd_ca0106_remove(struct pci_dev *pci)
@@ -1704,6 +1763,59 @@ static void __devexit snd_ca0106_remove(struct pci_dev *pci)
1704 pci_set_drvdata(pci, NULL); 1763 pci_set_drvdata(pci, NULL);
1705} 1764}
1706 1765
1766#ifdef CONFIG_PM
1767static int snd_ca0106_suspend(struct pci_dev *pci, pm_message_t state)
1768{
1769 struct snd_card *card = pci_get_drvdata(pci);
1770 struct snd_ca0106 *chip = card->private_data;
1771 int i;
1772
1773 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
1774 for (i = 0; i < 4; i++)
1775 snd_pcm_suspend_all(chip->pcm[i]);
1776 if (chip->details->ac97)
1777 snd_ac97_suspend(chip->ac97);
1778 snd_ca0106_mixer_suspend(chip);
1779
1780 ca0106_stop_chip(chip);
1781
1782 pci_disable_device(pci);
1783 pci_save_state(pci);
1784 pci_set_power_state(pci, pci_choose_state(pci, state));
1785 return 0;
1786}
1787
1788static int snd_ca0106_resume(struct pci_dev *pci)
1789{
1790 struct snd_card *card = pci_get_drvdata(pci);
1791 struct snd_ca0106 *chip = card->private_data;
1792 int i;
1793
1794 pci_set_power_state(pci, PCI_D0);
1795 pci_restore_state(pci);
1796
1797 if (pci_enable_device(pci) < 0) {
1798 snd_card_disconnect(card);
1799 return -EIO;
1800 }
1801
1802 pci_set_master(pci);
1803
1804 ca0106_init_chip(chip, 1);
1805
1806 if (chip->details->ac97)
1807 snd_ac97_resume(chip->ac97);
1808 snd_ca0106_mixer_resume(chip);
1809 if (chip->details->spi_dac) {
1810 for (i = 0; i < ARRAY_SIZE(chip->spi_dac_reg); i++)
1811 snd_ca0106_spi_write(chip, chip->spi_dac_reg[i]);
1812 }
1813
1814 snd_power_change_state(card, SNDRV_CTL_POWER_D0);
1815 return 0;
1816}
1817#endif
1818
1707// PCI IDs 1819// PCI IDs
1708static struct pci_device_id snd_ca0106_ids[] = { 1820static struct pci_device_id snd_ca0106_ids[] = {
1709 { 0x1102, 0x0007, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Audigy LS or Live 24bit */ 1821 { 0x1102, 0x0007, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Audigy LS or Live 24bit */
@@ -1717,6 +1829,10 @@ static struct pci_driver driver = {
1717 .id_table = snd_ca0106_ids, 1829 .id_table = snd_ca0106_ids,
1718 .probe = snd_ca0106_probe, 1830 .probe = snd_ca0106_probe,
1719 .remove = __devexit_p(snd_ca0106_remove), 1831 .remove = __devexit_p(snd_ca0106_remove),
1832#ifdef CONFIG_PM
1833 .suspend = snd_ca0106_suspend,
1834 .resume = snd_ca0106_resume,
1835#endif
1720}; 1836};
1721 1837
1722// initialization of the module 1838// initialization of the module
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c
index 3025ed1b6e1..ad2888705d2 100644
--- a/sound/pci/ca0106/ca0106_mixer.c
+++ b/sound/pci/ca0106/ca0106_mixer.c
@@ -75,6 +75,84 @@
75 75
76#include "ca0106.h" 76#include "ca0106.h"
77 77
78static void ca0106_spdif_enable(struct snd_ca0106 *emu)
79{
80 unsigned int val;
81
82 if (emu->spdif_enable) {
83 /* Digital */
84 snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf);
85 snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x0b000000);
86 val = snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) & ~0x1000;
87 snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0, val);
88 val = inl(emu->port + GPIO) & ~0x101;
89 outl(val, emu->port + GPIO);
90
91 } else {
92 /* Analog */
93 snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf);
94 snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x000f0000);
95 val = snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) | 0x1000;
96 snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0, val);
97 val = inl(emu->port + GPIO) | 0x101;
98 outl(val, emu->port + GPIO);
99 }
100}
101
102static void ca0106_set_capture_source(struct snd_ca0106 *emu)
103{
104 unsigned int val = emu->capture_source;
105 unsigned int source, mask;
106 source = (val << 28) | (val << 24) | (val << 20) | (val << 16);
107 mask = snd_ca0106_ptr_read(emu, CAPTURE_SOURCE, 0) & 0xffff;
108 snd_ca0106_ptr_write(emu, CAPTURE_SOURCE, 0, source | mask);
109}
110
111static void ca0106_set_i2c_capture_source(struct snd_ca0106 *emu,
112 unsigned int val, int force)
113{
114 unsigned int ngain, ogain;
115 u32 source;
116
117 snd_ca0106_i2c_write(emu, ADC_MUX, 0); /* Mute input */
118 ngain = emu->i2c_capture_volume[val][0]; /* Left */
119 ogain = emu->i2c_capture_volume[emu->i2c_capture_source][0]; /* Left */
120 if (force || ngain != ogain)
121 snd_ca0106_i2c_write(emu, ADC_ATTEN_ADCL, ngain & 0xff);
122 ngain = emu->i2c_capture_volume[val][1]; /* Right */
123 ogain = emu->i2c_capture_volume[emu->i2c_capture_source][1]; /* Right */
124 if (force || ngain != ogain)
125 snd_ca0106_i2c_write(emu, ADC_ATTEN_ADCR, ngain & 0xff);
126 source = 1 << val;
127 snd_ca0106_i2c_write(emu, ADC_MUX, source); /* Set source */
128 emu->i2c_capture_source = val;
129}
130
131static void ca0106_set_capture_mic_line_in(struct snd_ca0106 *emu)
132{
133 u32 tmp;
134
135 if (emu->capture_mic_line_in) {
136 /* snd_ca0106_i2c_write(emu, ADC_MUX, 0); */ /* Mute input */
137 tmp = inl(emu->port+GPIO) & ~0x400;
138 tmp = tmp | 0x400;
139 outl(tmp, emu->port+GPIO);
140 /* snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_MIC); */
141 } else {
142 /* snd_ca0106_i2c_write(emu, ADC_MUX, 0); */ /* Mute input */
143 tmp = inl(emu->port+GPIO) & ~0x400;
144 outl(tmp, emu->port+GPIO);
145 /* snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_LINEIN); */
146 }
147}
148
149static void ca0106_set_spdif_bits(struct snd_ca0106 *emu, int idx)
150{
151 snd_ca0106_ptr_write(emu, SPCS0 + idx, 0, emu->spdif_str_bits[idx]);
152}
153
154/*
155 */
78static const DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale1, -5175, 25, 1); 156static const DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale1, -5175, 25, 1);
79static const DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale2, -10350, 50, 1); 157static const DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale2, -10350, 50, 1);
80 158
@@ -95,30 +173,12 @@ static int snd_ca0106_shared_spdif_put(struct snd_kcontrol *kcontrol,
95 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 173 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
96 unsigned int val; 174 unsigned int val;
97 int change = 0; 175 int change = 0;
98 u32 mask;
99 176
100 val = !!ucontrol->value.integer.value[0]; 177 val = !!ucontrol->value.integer.value[0];
101 change = (emu->spdif_enable != val); 178 change = (emu->spdif_enable != val);
102 if (change) { 179 if (change) {
103 emu->spdif_enable = val; 180 emu->spdif_enable = val;
104 if (val) { 181 ca0106_spdif_enable(emu);
105 /* Digital */
106 snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf);
107 snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x0b000000);
108 snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0,
109 snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) & ~0x1000);
110 mask = inl(emu->port + GPIO) & ~0x101;
111 outl(mask, emu->port + GPIO);
112
113 } else {
114 /* Analog */
115 snd_ca0106_ptr_write(emu, SPDIF_SELECT1, 0, 0xf);
116 snd_ca0106_ptr_write(emu, SPDIF_SELECT2, 0, 0x000f0000);
117 snd_ca0106_ptr_write(emu, CAPTURE_CONTROL, 0,
118 snd_ca0106_ptr_read(emu, CAPTURE_CONTROL, 0) | 0x1000);
119 mask = inl(emu->port + GPIO) | 0x101;
120 outl(mask, emu->port + GPIO);
121 }
122 } 182 }
123 return change; 183 return change;
124} 184}
@@ -154,8 +214,6 @@ static int snd_ca0106_capture_source_put(struct snd_kcontrol *kcontrol,
154 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 214 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
155 unsigned int val; 215 unsigned int val;
156 int change = 0; 216 int change = 0;
157 u32 mask;
158 u32 source;
159 217
160 val = ucontrol->value.enumerated.item[0] ; 218 val = ucontrol->value.enumerated.item[0] ;
161 if (val >= 6) 219 if (val >= 6)
@@ -163,9 +221,7 @@ static int snd_ca0106_capture_source_put(struct snd_kcontrol *kcontrol,
163 change = (emu->capture_source != val); 221 change = (emu->capture_source != val);
164 if (change) { 222 if (change) {
165 emu->capture_source = val; 223 emu->capture_source = val;
166 source = (val << 28) | (val << 24) | (val << 20) | (val << 16); 224 ca0106_set_capture_source(emu);
167 mask = snd_ca0106_ptr_read(emu, CAPTURE_SOURCE, 0) & 0xffff;
168 snd_ca0106_ptr_write(emu, CAPTURE_SOURCE, 0, source | mask);
169 } 225 }
170 return change; 226 return change;
171} 227}
@@ -200,9 +256,7 @@ static int snd_ca0106_i2c_capture_source_put(struct snd_kcontrol *kcontrol,
200{ 256{
201 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 257 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
202 unsigned int source_id; 258 unsigned int source_id;
203 unsigned int ngain, ogain;
204 int change = 0; 259 int change = 0;
205 u32 source;
206 /* If the capture source has changed, 260 /* If the capture source has changed,
207 * update the capture volume from the cached value 261 * update the capture volume from the cached value
208 * for the particular source. 262 * for the particular source.
@@ -212,18 +266,7 @@ static int snd_ca0106_i2c_capture_source_put(struct snd_kcontrol *kcontrol,
212 return -EINVAL; 266 return -EINVAL;
213 change = (emu->i2c_capture_source != source_id); 267 change = (emu->i2c_capture_source != source_id);
214 if (change) { 268 if (change) {
215 snd_ca0106_i2c_write(emu, ADC_MUX, 0); /* Mute input */ 269 ca0106_set_i2c_capture_source(emu, source_id, 0);
216 ngain = emu->i2c_capture_volume[source_id][0]; /* Left */
217 ogain = emu->i2c_capture_volume[emu->i2c_capture_source][0]; /* Left */
218 if (ngain != ogain)
219 snd_ca0106_i2c_write(emu, ADC_ATTEN_ADCL, ((ngain) & 0xff));
220 ngain = emu->i2c_capture_volume[source_id][1]; /* Left */
221 ogain = emu->i2c_capture_volume[emu->i2c_capture_source][1]; /* Left */
222 if (ngain != ogain)
223 snd_ca0106_i2c_write(emu, ADC_ATTEN_ADCR, ((ngain) & 0xff));
224 source = 1 << source_id;
225 snd_ca0106_i2c_write(emu, ADC_MUX, source); /* Set source */
226 emu->i2c_capture_source = source_id;
227 } 270 }
228 return change; 271 return change;
229} 272}
@@ -271,7 +314,6 @@ static int snd_ca0106_capture_mic_line_in_put(struct snd_kcontrol *kcontrol,
271 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 314 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
272 unsigned int val; 315 unsigned int val;
273 int change = 0; 316 int change = 0;
274 u32 tmp;
275 317
276 val = ucontrol->value.enumerated.item[0] ; 318 val = ucontrol->value.enumerated.item[0] ;
277 if (val > 1) 319 if (val > 1)
@@ -279,18 +321,7 @@ static int snd_ca0106_capture_mic_line_in_put(struct snd_kcontrol *kcontrol,
279 change = (emu->capture_mic_line_in != val); 321 change = (emu->capture_mic_line_in != val);
280 if (change) { 322 if (change) {
281 emu->capture_mic_line_in = val; 323 emu->capture_mic_line_in = val;
282 if (val) { 324 ca0106_set_capture_mic_line_in(emu);
283 //snd_ca0106_i2c_write(emu, ADC_MUX, 0); /* Mute input */
284 tmp = inl(emu->port+GPIO) & ~0x400;
285 tmp = tmp | 0x400;
286 outl(tmp, emu->port+GPIO);
287 //snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_MIC);
288 } else {
289 //snd_ca0106_i2c_write(emu, ADC_MUX, 0); /* Mute input */
290 tmp = inl(emu->port+GPIO) & ~0x400;
291 outl(tmp, emu->port+GPIO);
292 //snd_ca0106_i2c_write(emu, ADC_MUX, ADC_MUX_LINEIN);
293 }
294 } 325 }
295 return change; 326 return change;
296} 327}
@@ -322,16 +353,33 @@ static int snd_ca0106_spdif_info(struct snd_kcontrol *kcontrol,
322 return 0; 353 return 0;
323} 354}
324 355
325static int snd_ca0106_spdif_get(struct snd_kcontrol *kcontrol, 356static void decode_spdif_bits(unsigned char *status, unsigned int bits)
357{
358 status[0] = (bits >> 0) & 0xff;
359 status[1] = (bits >> 8) & 0xff;
360 status[2] = (bits >> 16) & 0xff;
361 status[3] = (bits >> 24) & 0xff;
362}
363
364static int snd_ca0106_spdif_get_default(struct snd_kcontrol *kcontrol,
326 struct snd_ctl_elem_value *ucontrol) 365 struct snd_ctl_elem_value *ucontrol)
327{ 366{
328 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 367 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
329 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 368 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
330 369
331 ucontrol->value.iec958.status[0] = (emu->spdif_bits[idx] >> 0) & 0xff; 370 decode_spdif_bits(ucontrol->value.iec958.status,
332 ucontrol->value.iec958.status[1] = (emu->spdif_bits[idx] >> 8) & 0xff; 371 emu->spdif_bits[idx]);
333 ucontrol->value.iec958.status[2] = (emu->spdif_bits[idx] >> 16) & 0xff; 372 return 0;
334 ucontrol->value.iec958.status[3] = (emu->spdif_bits[idx] >> 24) & 0xff; 373}
374
375static int snd_ca0106_spdif_get_stream(struct snd_kcontrol *kcontrol,
376 struct snd_ctl_elem_value *ucontrol)
377{
378 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
379 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
380
381 decode_spdif_bits(ucontrol->value.iec958.status,
382 emu->spdif_str_bits[idx]);
335 return 0; 383 return 0;
336} 384}
337 385
@@ -345,24 +393,48 @@ static int snd_ca0106_spdif_get_mask(struct snd_kcontrol *kcontrol,
345 return 0; 393 return 0;
346} 394}
347 395
348static int snd_ca0106_spdif_put(struct snd_kcontrol *kcontrol, 396static unsigned int encode_spdif_bits(unsigned char *status)
397{
398 return ((unsigned int)status[0] << 0) |
399 ((unsigned int)status[1] << 8) |
400 ((unsigned int)status[2] << 16) |
401 ((unsigned int)status[3] << 24);
402}
403
404static int snd_ca0106_spdif_put_default(struct snd_kcontrol *kcontrol,
349 struct snd_ctl_elem_value *ucontrol) 405 struct snd_ctl_elem_value *ucontrol)
350{ 406{
351 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol); 407 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
352 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 408 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
353 int change;
354 unsigned int val; 409 unsigned int val;
355 410
356 val = (ucontrol->value.iec958.status[0] << 0) | 411 val = encode_spdif_bits(ucontrol->value.iec958.status);
357 (ucontrol->value.iec958.status[1] << 8) | 412 if (val != emu->spdif_bits[idx]) {
358 (ucontrol->value.iec958.status[2] << 16) |
359 (ucontrol->value.iec958.status[3] << 24);
360 change = val != emu->spdif_bits[idx];
361 if (change) {
362 snd_ca0106_ptr_write(emu, SPCS0 + idx, 0, val);
363 emu->spdif_bits[idx] = val; 413 emu->spdif_bits[idx] = val;
414 /* FIXME: this isn't safe, but needed to keep the compatibility
415 * with older alsa-lib config
416 */
417 emu->spdif_str_bits[idx] = val;
418 ca0106_set_spdif_bits(emu, idx);
419 return 1;
364 } 420 }
365 return change; 421 return 0;
422}
423
424static int snd_ca0106_spdif_put_stream(struct snd_kcontrol *kcontrol,
425 struct snd_ctl_elem_value *ucontrol)
426{
427 struct snd_ca0106 *emu = snd_kcontrol_chip(kcontrol);
428 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
429 unsigned int val;
430
431 val = encode_spdif_bits(ucontrol->value.iec958.status);
432 if (val != emu->spdif_str_bits[idx]) {
433 emu->spdif_str_bits[idx] = val;
434 ca0106_set_spdif_bits(emu, idx);
435 return 1;
436 }
437 return 0;
366} 438}
367 439
368static int snd_ca0106_volume_info(struct snd_kcontrol *kcontrol, 440static int snd_ca0106_volume_info(struct snd_kcontrol *kcontrol,
@@ -573,8 +645,16 @@ static struct snd_kcontrol_new snd_ca0106_volume_ctls[] __devinitdata = {
573 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 645 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT),
574 .count = 4, 646 .count = 4,
575 .info = snd_ca0106_spdif_info, 647 .info = snd_ca0106_spdif_info,
576 .get = snd_ca0106_spdif_get, 648 .get = snd_ca0106_spdif_get_default,
577 .put = snd_ca0106_spdif_put 649 .put = snd_ca0106_spdif_put_default
650 },
651 {
652 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
653 .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PCM_STREAM),
654 .count = 4,
655 .info = snd_ca0106_spdif_info,
656 .get = snd_ca0106_spdif_get_stream,
657 .put = snd_ca0106_spdif_put_stream
578 }, 658 },
579}; 659};
580 660
@@ -773,3 +853,50 @@ int __devinit snd_ca0106_mixer(struct snd_ca0106 *emu)
773 return 0; 853 return 0;
774} 854}
775 855
856#ifdef CONFIG_PM
857struct ca0106_vol_tbl {
858 unsigned int channel_id;
859 unsigned int reg;
860};
861
862static struct ca0106_vol_tbl saved_volumes[NUM_SAVED_VOLUMES] = {
863 { CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME2 },
864 { CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME2 },
865 { CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME2 },
866 { CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME2 },
867 { CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME1 },
868 { CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME1 },
869 { CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME1 },
870 { CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME1 },
871 { 1, CAPTURE_CONTROL },
872};
873
874void snd_ca0106_mixer_suspend(struct snd_ca0106 *chip)
875{
876 int i;
877
878 /* save volumes */
879 for (i = 0; i < NUM_SAVED_VOLUMES; i++)
880 chip->saved_vol[i] =
881 snd_ca0106_ptr_read(chip, saved_volumes[i].reg,
882 saved_volumes[i].channel_id);
883}
884
885void snd_ca0106_mixer_resume(struct snd_ca0106 *chip)
886{
887 int i;
888
889 for (i = 0; i < NUM_SAVED_VOLUMES; i++)
890 snd_ca0106_ptr_write(chip, saved_volumes[i].reg,
891 saved_volumes[i].channel_id,
892 chip->saved_vol[i]);
893
894 ca0106_spdif_enable(chip);
895 ca0106_set_capture_source(chip);
896 ca0106_set_i2c_capture_source(chip, chip->i2c_capture_source, 1);
897 for (i = 0; i < 4; i++)
898 ca0106_set_spdif_bits(chip, i);
899 if (chip->details->i2c_adc)
900 ca0106_set_capture_mic_line_in(chip);
901}
902#endif /* CONFIG_PM */
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
index fb6dc398025..8ab07aa6365 100644
--- a/sound/pci/cs46xx/cs46xx_lib.c
+++ b/sound/pci/cs46xx/cs46xx_lib.c
@@ -3640,7 +3640,10 @@ int snd_cs46xx_resume(struct pci_dev *pci)
3640{ 3640{
3641 struct snd_card *card = pci_get_drvdata(pci); 3641 struct snd_card *card = pci_get_drvdata(pci);
3642 struct snd_cs46xx *chip = card->private_data; 3642 struct snd_cs46xx *chip = card->private_data;
3643 int i, amp_saved; 3643 int amp_saved;
3644#ifdef CONFIG_SND_CS46XX_NEW_DSP
3645 int i;
3646#endif
3644 3647
3645 pci_set_power_state(pci, PCI_D0); 3648 pci_set_power_state(pci, PCI_D0);
3646 pci_restore_state(pci); 3649 pci_restore_state(pci);
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index de5ee8f097f..7958006a1d6 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -69,7 +69,7 @@ MODULE_FIRMWARE(EMU1010_NOTEBOOK_FILENAME);
69 * EMU10K1 init / done 69 * EMU10K1 init / done
70 *************************************************************************/ 70 *************************************************************************/
71 71
72void snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int ch) 72void snd_emu10k1_voice_init(struct snd_emu10k1 *emu, int ch)
73{ 73{
74 snd_emu10k1_ptr_write(emu, DCYSUSV, ch, 0); 74 snd_emu10k1_ptr_write(emu, DCYSUSV, ch, 0);
75 snd_emu10k1_ptr_write(emu, IP, ch, 0); 75 snd_emu10k1_ptr_write(emu, IP, ch, 0);
@@ -151,9 +151,9 @@ static unsigned int i2c_adc_init[][2] = {
151 { 0x12, 0x32 }, /* ALC Control 3 */ 151 { 0x12, 0x32 }, /* ALC Control 3 */
152 { 0x13, 0x00 }, /* Noise gate control */ 152 { 0x13, 0x00 }, /* Noise gate control */
153 { 0x14, 0xa6 }, /* Limiter control */ 153 { 0x14, 0xa6 }, /* Limiter control */
154 { 0x15, ADC_MUX_2 }, /* ADC Mixer control. Mic for Audigy 2 ZS Notebook */ 154 { 0x15, ADC_MUX_2 }, /* ADC Mixer control. Mic for A2ZS Notebook */
155}; 155};
156 156
157static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) 157static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
158{ 158{
159 unsigned int silent_page; 159 unsigned int silent_page;
@@ -161,8 +161,8 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
161 u32 tmp; 161 u32 tmp;
162 162
163 /* disable audio and lock cache */ 163 /* disable audio and lock cache */
164 outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK | HCFG_MUTEBUTTONENABLE, 164 outl(HCFG_LOCKSOUNDCACHE | HCFG_LOCKTANKCACHE_MASK |
165 emu->port + HCFG); 165 HCFG_MUTEBUTTONENABLE, emu->port + HCFG);
166 166
167 /* reset recording buffers */ 167 /* reset recording buffers */
168 snd_emu10k1_ptr_write(emu, MICBS, 0, ADCBS_BUFSIZE_NONE); 168 snd_emu10k1_ptr_write(emu, MICBS, 0, ADCBS_BUFSIZE_NONE);
@@ -179,7 +179,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
179 snd_emu10k1_ptr_write(emu, SOLEL, 0, 0); 179 snd_emu10k1_ptr_write(emu, SOLEL, 0, 0);
180 snd_emu10k1_ptr_write(emu, SOLEH, 0, 0); 180 snd_emu10k1_ptr_write(emu, SOLEH, 0, 0);
181 181
182 if (emu->audigy){ 182 if (emu->audigy) {
183 /* set SPDIF bypass mode */ 183 /* set SPDIF bypass mode */
184 snd_emu10k1_ptr_write(emu, SPBYPASS, 0, SPBYPASS_FORMAT); 184 snd_emu10k1_ptr_write(emu, SPBYPASS, 0, SPBYPASS_FORMAT);
185 /* enable rear left + rear right AC97 slots */ 185 /* enable rear left + rear right AC97 slots */
@@ -197,12 +197,12 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
197 197
198 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ 198 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */
199 /* Hacks for Alice3 to work independent of haP16V driver */ 199 /* Hacks for Alice3 to work independent of haP16V driver */
200 //Setup SRCMulti_I2S SamplingRate 200 /* Setup SRCMulti_I2S SamplingRate */
201 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); 201 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
202 tmp &= 0xfffff1ff; 202 tmp &= 0xfffff1ff;
203 tmp |= (0x2<<9); 203 tmp |= (0x2<<9);
204 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, 0, tmp); 204 snd_emu10k1_ptr_write(emu, A_SPDIF_SAMPLERATE, 0, tmp);
205 205
206 /* Setup SRCSel (Enable Spdif,I2S SRCMulti) */ 206 /* Setup SRCSel (Enable Spdif,I2S SRCMulti) */
207 snd_emu10k1_ptr20_write(emu, SRCSel, 0, 0x14); 207 snd_emu10k1_ptr20_write(emu, SRCSel, 0, 0x14);
208 /* Setup SRCMulti Input Audio Enable */ 208 /* Setup SRCMulti Input Audio Enable */
@@ -217,7 +217,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
217 if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */ 217 if (emu->card_capabilities->ca0108_chip) { /* audigy2 Value */
218 /* Hacks for Alice3 to work independent of haP16V driver */ 218 /* Hacks for Alice3 to work independent of haP16V driver */
219 snd_printk(KERN_INFO "Audigy2 value: Special config.\n"); 219 snd_printk(KERN_INFO "Audigy2 value: Special config.\n");
220 //Setup SRCMulti_I2S SamplingRate 220 /* Setup SRCMulti_I2S SamplingRate */
221 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0); 221 tmp = snd_emu10k1_ptr_read(emu, A_SPDIF_SAMPLERATE, 0);
222 tmp &= 0xfffff1ff; 222 tmp &= 0xfffff1ff;
223 tmp |= (0x2<<9); 223 tmp |= (0x2<<9);
@@ -270,13 +270,13 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
270 size = ARRAY_SIZE(i2c_adc_init); 270 size = ARRAY_SIZE(i2c_adc_init);
271 for (n = 0; n < size; n++) 271 for (n = 0; n < size; n++)
272 snd_emu10k1_i2c_write(emu, i2c_adc_init[n][0], i2c_adc_init[n][1]); 272 snd_emu10k1_i2c_write(emu, i2c_adc_init[n][0], i2c_adc_init[n][1]);
273 for (n=0; n < 4; n++) { 273 for (n = 0; n < 4; n++) {
274 emu->i2c_capture_volume[n][0]= 0xcf; 274 emu->i2c_capture_volume[n][0] = 0xcf;
275 emu->i2c_capture_volume[n][1]= 0xcf; 275 emu->i2c_capture_volume[n][1] = 0xcf;
276 } 276 }
277 } 277 }
278 278
279 279
280 snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr); 280 snd_emu10k1_ptr_write(emu, PTB, 0, emu->ptb_pages.addr);
281 snd_emu10k1_ptr_write(emu, TCB, 0, 0); /* taken from original driver */ 281 snd_emu10k1_ptr_write(emu, TCB, 0, 0); /* taken from original driver */
282 snd_emu10k1_ptr_write(emu, TCBS, 0, 4); /* taken from original driver */ 282 snd_emu10k1_ptr_write(emu, TCBS, 0, 4); /* taken from original driver */
@@ -313,7 +313,7 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
313 (emu->model == 0x21 && emu->revision < 6)) 313 (emu->model == 0x21 && emu->revision < 6))
314 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE, emu->port + HCFG); 314 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE, emu->port + HCFG);
315 else 315 else
316 // With on-chip joystick 316 /* With on-chip joystick */
317 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG); 317 outl(HCFG_LOCKTANKCACHE_MASK | HCFG_AUTOMUTE | HCFG_JOYENABLE, emu->port + HCFG);
318 318
319 if (enable_ir) { /* enable IR for SB Live */ 319 if (enable_ir) { /* enable IR for SB Live */
@@ -335,9 +335,9 @@ static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume)
335 outl(reg | HCFG_GPOUT1 | HCFG_GPOUT2, emu->port + HCFG); 335 outl(reg | HCFG_GPOUT1 | HCFG_GPOUT2, emu->port + HCFG);
336 udelay(100); 336 udelay(100);
337 outl(reg, emu->port + HCFG); 337 outl(reg, emu->port + HCFG);
338 } 338 }
339 } 339 }
340 340
341 if (emu->card_capabilities->emu_model) { 341 if (emu->card_capabilities->emu_model) {
342 ; /* Disable all access to A_IOCFG for the emu1010 */ 342 ; /* Disable all access to A_IOCFG for the emu1010 */
343 } else if (emu->card_capabilities->i2c_adc) { 343 } else if (emu->card_capabilities->i2c_adc) {
@@ -364,7 +364,7 @@ static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu)
364 ; /* Disable A_IOCFG for Audigy 2 ZS Notebook */ 364 ; /* Disable A_IOCFG for Audigy 2 ZS Notebook */
365 } else if (emu->audigy) { 365 } else if (emu->audigy) {
366 outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG); 366 outl(inl(emu->port + A_IOCFG) & ~0x44, emu->port + A_IOCFG);
367 367
368 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */ 368 if (emu->card_capabilities->ca0151_chip) { /* audigy2 */
369 /* Unmute Analog now. Set GPO6 to 1 for Apollo. 369 /* Unmute Analog now. Set GPO6 to 1 for Apollo.
370 * This has to be done after init ALice3 I2SOut beyond 48KHz. 370 * This has to be done after init ALice3 I2SOut beyond 48KHz.
@@ -378,12 +378,12 @@ static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu)
378 outl(inl(emu->port + A_IOCFG) | 0x0080, emu->port + A_IOCFG); 378 outl(inl(emu->port + A_IOCFG) | 0x0080, emu->port + A_IOCFG);
379 } 379 }
380 } 380 }
381 381
382#if 0 382#if 0
383 { 383 {
384 unsigned int tmp; 384 unsigned int tmp;
385 /* FIXME: the following routine disables LiveDrive-II !! */ 385 /* FIXME: the following routine disables LiveDrive-II !! */
386 // TOSLink detection 386 /* TOSLink detection */
387 emu->tos_link = 0; 387 emu->tos_link = 0;
388 tmp = inl(emu->port + HCFG); 388 tmp = inl(emu->port + HCFG);
389 if (tmp & (HCFG_GPINPUT0 | HCFG_GPINPUT1)) { 389 if (tmp & (HCFG_GPINPUT0 | HCFG_GPINPUT1)) {
@@ -400,7 +400,7 @@ static void snd_emu10k1_audio_enable(struct snd_emu10k1 *emu)
400 snd_emu10k1_intr_enable(emu, INTE_PCIERRORENABLE); 400 snd_emu10k1_intr_enable(emu, INTE_PCIERRORENABLE);
401} 401}
402 402
403int snd_emu10k1_done(struct snd_emu10k1 * emu) 403int snd_emu10k1_done(struct snd_emu10k1 *emu)
404{ 404{
405 int ch; 405 int ch;
406 406
@@ -495,7 +495,7 @@ int snd_emu10k1_done(struct snd_emu10k1 * emu)
495 495
496#define EC_LAST_PROMFILE_ADDR 0x2f 496#define EC_LAST_PROMFILE_ADDR 0x2f
497 497
498#define EC_SERIALNUM_ADDR 0x30 /* First word of serial number. The 498#define EC_SERIALNUM_ADDR 0x30 /* First word of serial number. The
499 * can be up to 30 characters in length 499 * can be up to 30 characters in length
500 * and is stored as a NULL-terminated 500 * and is stored as a NULL-terminated
501 * ASCII string. Any unused bytes must be 501 * ASCII string. Any unused bytes must be
@@ -503,8 +503,8 @@ int snd_emu10k1_done(struct snd_emu10k1 * emu)
503#define EC_CHECKSUM_ADDR 0x3f /* Location at which checksum is stored */ 503#define EC_CHECKSUM_ADDR 0x3f /* Location at which checksum is stored */
504 504
505 505
506/* Most of this stuff is pretty self-evident. According to the hardware 506/* Most of this stuff is pretty self-evident. According to the hardware
507 * dudes, we need to leave the ADCCAL bit low in order to avoid a DC 507 * dudes, we need to leave the ADCCAL bit low in order to avoid a DC
508 * offset problem. Weird. 508 * offset problem. Weird.
509 */ 509 */
510#define EC_RAW_RUN_MODE (EC_DACMUTEN | EC_ADCRSTN | EC_TRIM_MUTEN | \ 510#define EC_RAW_RUN_MODE (EC_DACMUTEN | EC_ADCRSTN | EC_TRIM_MUTEN | \
@@ -523,7 +523,7 @@ int snd_emu10k1_done(struct snd_emu10k1 * emu)
523 * register. 523 * register.
524 */ 524 */
525 525
526static void snd_emu10k1_ecard_write(struct snd_emu10k1 * emu, unsigned int value) 526static void snd_emu10k1_ecard_write(struct snd_emu10k1 *emu, unsigned int value)
527{ 527{
528 unsigned short count; 528 unsigned short count;
529 unsigned int data; 529 unsigned int data;
@@ -561,7 +561,7 @@ static void snd_emu10k1_ecard_write(struct snd_emu10k1 * emu, unsigned int value
561 * channel. 561 * channel.
562 */ 562 */
563 563
564static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 * emu, 564static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 *emu,
565 unsigned short gain) 565 unsigned short gain)
566{ 566{
567 unsigned int bit; 567 unsigned int bit;
@@ -574,7 +574,7 @@ static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 * emu,
574 574
575 for (bit = (1 << 15); bit; bit >>= 1) { 575 for (bit = (1 << 15); bit; bit >>= 1) {
576 unsigned int value; 576 unsigned int value;
577 577
578 value = emu->ecard_ctrl & ~(EC_TRIM_CSN | EC_TRIM_SDATA); 578 value = emu->ecard_ctrl & ~(EC_TRIM_CSN | EC_TRIM_SDATA);
579 579
580 if (gain & bit) 580 if (gain & bit)
@@ -589,7 +589,7 @@ static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 * emu,
589 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl); 589 snd_emu10k1_ecard_write(emu, emu->ecard_ctrl);
590} 590}
591 591
592static int snd_emu10k1_ecard_init(struct snd_emu10k1 * emu) 592static int snd_emu10k1_ecard_init(struct snd_emu10k1 *emu)
593{ 593{
594 unsigned int hc_value; 594 unsigned int hc_value;
595 595
@@ -598,7 +598,7 @@ static int snd_emu10k1_ecard_init(struct snd_emu10k1 * emu)
598 EC_SPDIF0_SELECT(EC_DEFAULT_SPDIF0_SEL) | 598 EC_SPDIF0_SELECT(EC_DEFAULT_SPDIF0_SEL) |
599 EC_SPDIF1_SELECT(EC_DEFAULT_SPDIF1_SEL); 599 EC_SPDIF1_SELECT(EC_DEFAULT_SPDIF1_SEL);
600 600
601 /* Step 0: Set the codec type in the hardware control register 601 /* Step 0: Set the codec type in the hardware control register
602 * and enable audio output */ 602 * and enable audio output */
603 hc_value = inl(emu->port + HCFG); 603 hc_value = inl(emu->port + HCFG);
604 outl(hc_value | HCFG_AUDIOENABLE | HCFG_CODECFORMAT_I2S, emu->port + HCFG); 604 outl(hc_value | HCFG_AUDIOENABLE | HCFG_CODECFORMAT_I2S, emu->port + HCFG);
@@ -629,7 +629,7 @@ static int snd_emu10k1_ecard_init(struct snd_emu10k1 * emu)
629 return 0; 629 return 0;
630} 630}
631 631
632static int snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu) 632static int snd_emu10k1_cardbus_init(struct snd_emu10k1 *emu)
633{ 633{
634 unsigned long special_port; 634 unsigned long special_port;
635 unsigned int value; 635 unsigned int value;
@@ -656,7 +656,7 @@ static int snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu)
656 return 0; 656 return 0;
657} 657}
658 658
659static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * filename) 659static int snd_emu1010_load_firmware(struct snd_emu10k1 *emu, const char *filename)
660{ 660{
661 int err; 661 int err;
662 int n, i; 662 int n, i;
@@ -666,11 +666,12 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * file
666 unsigned long flags; 666 unsigned long flags;
667 const struct firmware *fw_entry; 667 const struct firmware *fw_entry;
668 668
669 if ((err = request_firmware(&fw_entry, filename, &emu->pci->dev)) != 0) { 669 err = request_firmware(&fw_entry, filename, &emu->pci->dev);
670 snd_printk(KERN_ERR "firmware: %s not found. Err=%d\n",filename, err); 670 if (err != 0) {
671 snd_printk(KERN_ERR "firmware: %s not found. Err = %d\n", filename, err);
671 return err; 672 return err;
672 } 673 }
673 snd_printk(KERN_INFO "firmware size=0x%zx\n", fw_entry->size); 674 snd_printk(KERN_INFO "firmware size = 0x%zx\n", fw_entry->size);
674 675
675 /* The FPGA is a Xilinx Spartan IIE XC2S50E */ 676 /* The FPGA is a Xilinx Spartan IIE XC2S50E */
676 /* GPIO7 -> FPGA PGMN 677 /* GPIO7 -> FPGA PGMN
@@ -685,13 +686,13 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * file
685 outl(0x80, emu->port + A_IOCFG); /* Leave bit 7 set during netlist setup. */ 686 outl(0x80, emu->port + A_IOCFG); /* Leave bit 7 set during netlist setup. */
686 write_post = inl(emu->port + A_IOCFG); 687 write_post = inl(emu->port + A_IOCFG);
687 udelay(100); /* Allow FPGA memory to clean */ 688 udelay(100); /* Allow FPGA memory to clean */
688 for(n = 0; n < fw_entry->size; n++) { 689 for (n = 0; n < fw_entry->size; n++) {
689 value=fw_entry->data[n]; 690 value = fw_entry->data[n];
690 for(i = 0; i < 8; i++) { 691 for (i = 0; i < 8; i++) {
691 reg = 0x80; 692 reg = 0x80;
692 if (value & 0x1) 693 if (value & 0x1)
693 reg = reg | 0x20; 694 reg = reg | 0x20;
694 value = value >> 1; 695 value = value >> 1;
695 outl(reg, emu->port + A_IOCFG); 696 outl(reg, emu->port + A_IOCFG);
696 write_post = inl(emu->port + A_IOCFG); 697 write_post = inl(emu->port + A_IOCFG);
697 outl(reg | 0x40, emu->port + A_IOCFG); 698 outl(reg | 0x40, emu->port + A_IOCFG);
@@ -703,14 +704,14 @@ static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * file
703 write_post = inl(emu->port + A_IOCFG); 704 write_post = inl(emu->port + A_IOCFG);
704 spin_unlock_irqrestore(&emu->emu_lock, flags); 705 spin_unlock_irqrestore(&emu->emu_lock, flags);
705 706
706 release_firmware(fw_entry); 707 release_firmware(fw_entry);
707 return 0; 708 return 0;
708} 709}
709 710
710static int emu1010_firmware_thread(void *data) 711static int emu1010_firmware_thread(void *data)
711{ 712{
712 struct snd_emu10k1 * emu = data; 713 struct snd_emu10k1 *emu = data;
713 int tmp,tmp2; 714 int tmp, tmp2;
714 int reg; 715 int reg;
715 int err; 716 int err;
716 717
@@ -719,50 +720,50 @@ static int emu1010_firmware_thread(void *data)
719 msleep_interruptible(1000); 720 msleep_interruptible(1000);
720 if (kthread_should_stop()) 721 if (kthread_should_stop())
721 break; 722 break;
722 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp ); /* IRQ Status */ 723 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &tmp); /* IRQ Status */
723 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg ); /* OPTIONS: Which cards are attached to the EMU */ 724 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg); /* OPTIONS: Which cards are attached to the EMU */
724 if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) { 725 if (reg & EMU_HANA_OPTION_DOCK_OFFLINE) {
725 /* Audio Dock attached */ 726 /* Audio Dock attached */
726 /* Return to Audio Dock programming mode */ 727 /* Return to Audio Dock programming mode */
727 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n"); 728 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware\n");
728 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK ); 729 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, EMU_HANA_FPGA_CONFIG_AUDIODOCK);
729 if (emu->card_capabilities->emu_model == 730 if (emu->card_capabilities->emu_model ==
730 EMU_MODEL_EMU1010) { 731 EMU_MODEL_EMU1010) {
731 if ((err = snd_emu1010_load_firmware(emu, DOCK_FILENAME)) != 0) { 732 err = snd_emu1010_load_firmware(emu, DOCK_FILENAME);
733 if (err != 0)
732 continue; 734 continue;
733 }
734 } else if (emu->card_capabilities->emu_model == 735 } else if (emu->card_capabilities->emu_model ==
735 EMU_MODEL_EMU1010B) { 736 EMU_MODEL_EMU1010B) {
736 if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) { 737 err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME);
738 if (err != 0)
737 continue; 739 continue;
738 }
739 } else if (emu->card_capabilities->emu_model == 740 } else if (emu->card_capabilities->emu_model ==
740 EMU_MODEL_EMU1616) { 741 EMU_MODEL_EMU1616) {
741 if ((err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME)) != 0) { 742 err = snd_emu1010_load_firmware(emu, MICRO_DOCK_FILENAME);
743 if (err != 0)
742 continue; 744 continue;
743 }
744 } 745 }
745 746
746 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0 ); 747 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0);
747 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg ); 748 snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, &reg);
748 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS=0x%x\n",reg); 749 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_IRQ_STATUS = 0x%x\n", reg);
749 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 750 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
750 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 751 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
751 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID=0x%x\n",reg); 752 snd_printk(KERN_INFO "emu1010: EMU_HANA+DOCK_ID = 0x%x\n", reg);
752 if ((reg & 0x1f) != 0x15) { 753 if ((reg & 0x1f) != 0x15) {
753 /* FPGA failed to be programmed */ 754 /* FPGA failed to be programmed */
754 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg=0x%x\n", reg); 755 snd_printk(KERN_INFO "emu1010: Loading Audio Dock Firmware file failed, reg = 0x%x\n", reg);
755 continue; 756 continue;
756 } 757 }
757 snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n"); 758 snd_printk(KERN_INFO "emu1010: Audio Dock Firmware loaded\n");
758 snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp ); 759 snd_emu1010_fpga_read(emu, EMU_DOCK_MAJOR_REV, &tmp);
759 snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2 ); 760 snd_emu1010_fpga_read(emu, EMU_DOCK_MINOR_REV, &tmp2);
760 snd_printk("Audio Dock ver:%d.%d\n",tmp ,tmp2); 761 snd_printk("Audio Dock ver:%d.%d\n", tmp, tmp2);
761 /* Sync clocking between 1010 and Dock */ 762 /* Sync clocking between 1010 and Dock */
762 /* Allow DLL to settle */ 763 /* Allow DLL to settle */
763 msleep(10); 764 msleep(10);
764 /* Unmute all. Default is muted after a firmware load */ 765 /* Unmute all. Default is muted after a firmware load */
765 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE ); 766 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, EMU_UNMUTE);
766 } 767 }
767 } 768 }
768 snd_printk(KERN_INFO "emu1010: firmware thread stopping\n"); 769 snd_printk(KERN_INFO "emu1010: firmware thread stopping\n");
@@ -800,10 +801,10 @@ static int emu1010_firmware_thread(void *data)
800 * 16 x 16-bit playback - snd_emu10k1_fx8010_playback_ops 801 * 16 x 16-bit playback - snd_emu10k1_fx8010_playback_ops
801 * 16 x 32-bit capture - snd_emu10k1_capture_efx_ops 802 * 16 x 32-bit capture - snd_emu10k1_capture_efx_ops
802 */ 803 */
803static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu) 804static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
804{ 805{
805 unsigned int i; 806 unsigned int i;
806 int tmp,tmp2; 807 int tmp, tmp2;
807 int reg; 808 int reg;
808 int err; 809 int err;
809 const char *filename = NULL; 810 const char *filename = NULL;
@@ -818,7 +819,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
818 * Lock Tank Memory Cache, 819 * Lock Tank Memory Cache,
819 * Mute all codecs. 820 * Mute all codecs.
820 */ 821 */
821 outl(0x0005a004, emu->port + HCFG); 822 outl(0x0005a004, emu->port + HCFG);
822 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave, 823 /* AC97 2.1, Any 16Meg of 4Gig address, Auto-Mute, EMU32 Slave,
823 * Mute all codecs. 824 * Mute all codecs.
824 */ 825 */
@@ -829,25 +830,25 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
829 outl(0x0005a000, emu->port + HCFG); 830 outl(0x0005a000, emu->port + HCFG);
830 831
831 /* Disable 48Volt power to Audio Dock */ 832 /* Disable 48Volt power to Audio Dock */
832 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); 833 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0);
833 834
834 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */ 835 /* ID, should read & 0x7f = 0x55. (Bit 7 is the IRQ bit) */
835 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 836 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
836 snd_printdd("reg1=0x%x\n",reg); 837 snd_printdd("reg1 = 0x%x\n", reg);
837 if ((reg & 0x3f) == 0x15) { 838 if ((reg & 0x3f) == 0x15) {
838 /* FPGA netlist already present so clear it */ 839 /* FPGA netlist already present so clear it */
839 /* Return to programming mode */ 840 /* Return to programming mode */
840 841
841 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02 ); 842 snd_emu1010_fpga_write(emu, EMU_HANA_FPGA_CONFIG, 0x02);
842 } 843 }
843 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 844 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
844 snd_printdd("reg2=0x%x\n",reg); 845 snd_printdd("reg2 = 0x%x\n", reg);
845 if ((reg & 0x3f) == 0x15) { 846 if ((reg & 0x3f) == 0x15) {
846 /* FPGA failed to return to programming mode */ 847 /* FPGA failed to return to programming mode */
847 snd_printk(KERN_INFO "emu1010: FPGA failed to return to programming mode\n"); 848 snd_printk(KERN_INFO "emu1010: FPGA failed to return to programming mode\n");
848 return -ENODEV; 849 return -ENODEV;
849 } 850 }
850 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID=0x%x\n",reg); 851 snd_printk(KERN_INFO "emu1010: EMU_HANA_ID = 0x%x\n", reg);
851 switch (emu->card_capabilities->emu_model) { 852 switch (emu->card_capabilities->emu_model) {
852 case EMU_MODEL_EMU1010: 853 case EMU_MODEL_EMU1010:
853 filename = HANA_FILENAME; 854 filename = HANA_FILENAME;
@@ -876,25 +877,25 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
876 } 877 }
877 878
878 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */ 879 /* ID, should read & 0x7f = 0x55 when FPGA programmed. */
879 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg ); 880 snd_emu1010_fpga_read(emu, EMU_HANA_ID, &reg);
880 if ((reg & 0x3f) != 0x15) { 881 if ((reg & 0x3f) != 0x15) {
881 /* FPGA failed to be programmed */ 882 /* FPGA failed to be programmed */
882 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg=0x%x\n", reg); 883 snd_printk(KERN_INFO "emu1010: Loading Hana Firmware file failed, reg = 0x%x\n", reg);
883 return -ENODEV; 884 return -ENODEV;
884 } 885 }
885 886
886 snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n"); 887 snd_printk(KERN_INFO "emu1010: Hana Firmware loaded\n");
887 snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp ); 888 snd_emu1010_fpga_read(emu, EMU_HANA_MAJOR_REV, &tmp);
888 snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2 ); 889 snd_emu1010_fpga_read(emu, EMU_HANA_MINOR_REV, &tmp2);
889 snd_printk("Hana ver:%d.%d\n",tmp ,tmp2); 890 snd_printk("emu1010: Hana version: %d.%d\n", tmp, tmp2);
890 /* Enable 48Volt power to Audio Dock */ 891 /* Enable 48Volt power to Audio Dock */
891 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON ); 892 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, EMU_HANA_DOCK_PWR_ON);
892 893
893 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg ); 894 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
894 snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); 895 snd_printk(KERN_INFO "emu1010: Card options = 0x%x\n", reg);
895 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg ); 896 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
896 snd_printk(KERN_INFO "emu1010: Card options=0x%x\n",reg); 897 snd_printk(KERN_INFO "emu1010: Card options = 0x%x\n", reg);
897 snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp ); 898 snd_emu1010_fpga_read(emu, EMU_HANA_OPTICAL_TYPE, &tmp);
898 /* Optical -> ADAT I/O */ 899 /* Optical -> ADAT I/O */
899 /* 0 : SPDIF 900 /* 0 : SPDIF
900 * 1 : ADAT 901 * 1 : ADAT
@@ -904,41 +905,42 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
904 tmp = 0; 905 tmp = 0;
905 tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : 0) | 906 tmp = (emu->emu1010.optical_in ? EMU_HANA_OPTICAL_IN_ADAT : 0) |
906 (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : 0); 907 (emu->emu1010.optical_out ? EMU_HANA_OPTICAL_OUT_ADAT : 0);
907 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp ); 908 snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, tmp);
908 snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp ); 909 snd_emu1010_fpga_read(emu, EMU_HANA_ADC_PADS, &tmp);
909 /* Set no attenuation on Audio Dock pads. */ 910 /* Set no attenuation on Audio Dock pads. */
910 snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00 ); 911 snd_emu1010_fpga_write(emu, EMU_HANA_ADC_PADS, 0x00);
911 emu->emu1010.adc_pads = 0x00; 912 emu->emu1010.adc_pads = 0x00;
912 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp ); 913 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp);
913 /* Unmute Audio dock DACs, Headphone source DAC-4. */ 914 /* Unmute Audio dock DACs, Headphone source DAC-4. */
914 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 ); 915 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30);
915 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 ); 916 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12);
916 snd_emu1010_fpga_read(emu, EMU_HANA_DAC_PADS, &tmp ); 917 snd_emu1010_fpga_read(emu, EMU_HANA_DAC_PADS, &tmp);
917 /* DAC PADs. */ 918 /* DAC PADs. */
918 snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, 0x0f ); 919 snd_emu1010_fpga_write(emu, EMU_HANA_DAC_PADS, 0x0f);
919 emu->emu1010.dac_pads = 0x0f; 920 emu->emu1010.dac_pads = 0x0f;
920 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp ); 921 snd_emu1010_fpga_read(emu, EMU_HANA_DOCK_MISC, &tmp);
921 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30 ); 922 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_MISC, 0x30);
922 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); 923 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp);
923 /* SPDIF Format. Set Consumer mode, 24bit, copy enable */ 924 /* SPDIF Format. Set Consumer mode, 24bit, copy enable */
924 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); 925 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10);
925 /* MIDI routing */ 926 /* MIDI routing */
926 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); 927 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19);
927 /* Unknown. */ 928 /* Unknown. */
928 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); 929 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c);
929 /* snd_emu1010_fpga_write(emu, 0x09, 0x0f ); // IRQ Enable: All on */ 930 /* IRQ Enable: Alll on */
931 /* snd_emu1010_fpga_write(emu, 0x09, 0x0f ); */
930 /* IRQ Enable: All off */ 932 /* IRQ Enable: All off */
931 snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00 ); 933 snd_emu1010_fpga_write(emu, EMU_HANA_IRQ_ENABLE, 0x00);
932 934
933 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg ); 935 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &reg);
934 snd_printk(KERN_INFO "emu1010: Card options3=0x%x\n",reg); 936 snd_printk(KERN_INFO "emu1010: Card options3 = 0x%x\n", reg);
935 /* Default WCLK set to 48kHz. */ 937 /* Default WCLK set to 48kHz. */
936 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00 ); 938 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x00);
937 /* Word Clock source, Internal 48kHz x1 */ 939 /* Word Clock source, Internal 48kHz x1 */
938 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K ); 940 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K);
939 //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X ); 941 /* snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X); */
940 /* Audio Dock LEDs. */ 942 /* Audio Dock LEDs. */
941 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12 ); 943 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12);
942 944
943#if 0 945#if 0
944 /* For 96kHz */ 946 /* For 96kHz */
@@ -992,7 +994,7 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
992 * Defaults only, users will set their own values anyways, let's 994 * Defaults only, users will set their own values anyways, let's
993 * just copy/paste. 995 * just copy/paste.
994 */ 996 */
995 997
996 snd_emu1010_fpga_link_dst_src_write(emu, 998 snd_emu1010_fpga_link_dst_src_write(emu,
997 EMU_DST_ALICE2_EMU32_8, EMU_SRC_DOCK_MIC_A1); 999 EMU_DST_ALICE2_EMU32_8, EMU_SRC_DOCK_MIC_A1);
998 snd_emu1010_fpga_link_dst_src_write(emu, 1000 snd_emu1010_fpga_link_dst_src_write(emu,
@@ -1037,19 +1039,19 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
1037 snd_emu1010_fpga_link_dst_src_write(emu, 1039 snd_emu1010_fpga_link_dst_src_write(emu,
1038 EMU_DST_ALICE2_EMU32_F, EMU_SRC_HAMOA_ADC_LEFT2); 1040 EMU_DST_ALICE2_EMU32_F, EMU_SRC_HAMOA_ADC_LEFT2);
1039#endif 1041#endif
1040 for (i = 0;i < 0x20; i++ ) { 1042 for (i = 0; i < 0x20; i++) {
1041 /* AudioDock Elink <- Silence */ 1043 /* AudioDock Elink <- Silence */
1042 snd_emu1010_fpga_link_dst_src_write(emu, 0x0100+i, EMU_SRC_SILENCE); 1044 snd_emu1010_fpga_link_dst_src_write(emu, 0x0100 + i, EMU_SRC_SILENCE);
1043 } 1045 }
1044 for (i = 0;i < 4; i++) { 1046 for (i = 0; i < 4; i++) {
1045 /* Hana SPDIF Out <- Silence */ 1047 /* Hana SPDIF Out <- Silence */
1046 snd_emu1010_fpga_link_dst_src_write(emu, 0x0200+i, EMU_SRC_SILENCE); 1048 snd_emu1010_fpga_link_dst_src_write(emu, 0x0200 + i, EMU_SRC_SILENCE);
1047 } 1049 }
1048 for (i = 0;i < 7; i++) { 1050 for (i = 0; i < 7; i++) {
1049 /* Hamoa DAC <- Silence */ 1051 /* Hamoa DAC <- Silence */
1050 snd_emu1010_fpga_link_dst_src_write(emu, 0x0300+i, EMU_SRC_SILENCE); 1052 snd_emu1010_fpga_link_dst_src_write(emu, 0x0300 + i, EMU_SRC_SILENCE);
1051 } 1053 }
1052 for (i = 0;i < 7; i++) { 1054 for (i = 0; i < 7; i++) {
1053 /* Hana ADAT Out <- Silence */ 1055 /* Hana ADAT Out <- Silence */
1054 snd_emu1010_fpga_link_dst_src_write(emu, EMU_DST_HANA_ADAT + i, EMU_SRC_SILENCE); 1056 snd_emu1010_fpga_link_dst_src_write(emu, EMU_DST_HANA_ADAT + i, EMU_SRC_SILENCE);
1055 } 1057 }
@@ -1065,30 +1067,30 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
1065 EMU_DST_ALICE_I2S2_LEFT, EMU_SRC_DOCK_ADC3_LEFT1); 1067 EMU_DST_ALICE_I2S2_LEFT, EMU_SRC_DOCK_ADC3_LEFT1);
1066 snd_emu1010_fpga_link_dst_src_write(emu, 1068 snd_emu1010_fpga_link_dst_src_write(emu,
1067 EMU_DST_ALICE_I2S2_RIGHT, EMU_SRC_DOCK_ADC3_RIGHT1); 1069 EMU_DST_ALICE_I2S2_RIGHT, EMU_SRC_DOCK_ADC3_RIGHT1);
1068 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x01 ); // Unmute all 1070 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x01); /* Unmute all */
1071
1072 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp);
1069 1073
1070 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp );
1071
1072 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave, 1074 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave,
1073 * Lock Sound Memory Cache, Lock Tank Memory Cache, 1075 * Lock Sound Memory Cache, Lock Tank Memory Cache,
1074 * Mute all codecs. 1076 * Mute all codecs.
1075 */ 1077 */
1076 outl(0x0000a000, emu->port + HCFG); 1078 outl(0x0000a000, emu->port + HCFG);
1077 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave, 1079 /* AC97 1.03, Any 32Meg of 2Gig address, Auto-Mute, EMU32 Slave,
1078 * Lock Sound Memory Cache, Lock Tank Memory Cache, 1080 * Lock Sound Memory Cache, Lock Tank Memory Cache,
1079 * Un-Mute all codecs. 1081 * Un-Mute all codecs.
1080 */ 1082 */
1081 outl(0x0000a001, emu->port + HCFG); 1083 outl(0x0000a001, emu->port + HCFG);
1082 1084
1083 /* Initial boot complete. Now patches */ 1085 /* Initial boot complete. Now patches */
1084 1086
1085 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp ); 1087 snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, &tmp);
1086 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */ 1088 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19); /* MIDI Route */
1087 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */ 1089 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c); /* Unknown */
1088 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19 ); /* MIDI Route */ 1090 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_IN, 0x19); /* MIDI Route */
1089 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c ); /* Unknown */ 1091 snd_emu1010_fpga_write(emu, EMU_HANA_MIDI_OUT, 0x0c); /* Unknown */
1090 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp ); 1092 snd_emu1010_fpga_read(emu, EMU_HANA_SPDIF_MODE, &tmp);
1091 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10 ); /* SPDIF Format spdif (or 0x11 for aes/ebu) */ 1093 snd_emu1010_fpga_write(emu, EMU_HANA_SPDIF_MODE, 0x10); /* SPDIF Format spdif (or 0x11 for aes/ebu) */
1092 1094
1093 /* Start Micro/Audio Dock firmware loader thread */ 1095 /* Start Micro/Audio Dock firmware loader thread */
1094 if (!emu->emu1010.firmware_thread) { 1096 if (!emu->emu1010.firmware_thread) {
@@ -1218,20 +1220,20 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu)
1218 emu->emu1010.output_source[23] = 28; 1220 emu->emu1010.output_source[23] = 28;
1219 } 1221 }
1220 /* TEMP: Select SPDIF in/out */ 1222 /* TEMP: Select SPDIF in/out */
1221 //snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x0); /* Output spdif */ 1223 /* snd_emu1010_fpga_write(emu, EMU_HANA_OPTICAL_TYPE, 0x0); */ /* Output spdif */
1222 1224
1223 /* TEMP: Select 48kHz SPDIF out */ 1225 /* TEMP: Select 48kHz SPDIF out */
1224 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x0); /* Mute all */ 1226 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x0); /* Mute all */
1225 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x0); /* Default fallback clock 48kHz */ 1227 snd_emu1010_fpga_write(emu, EMU_HANA_DEFCLOCK, 0x0); /* Default fallback clock 48kHz */
1226 /* Word Clock source, Internal 48kHz x1 */ 1228 /* Word Clock source, Internal 48kHz x1 */
1227 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K ); 1229 snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K);
1228 //snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X ); 1230 /* snd_emu1010_fpga_write(emu, EMU_HANA_WCLOCK, EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_4X); */
1229 emu->emu1010.internal_clock = 1; /* 48000 */ 1231 emu->emu1010.internal_clock = 1; /* 48000 */
1230 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12);/* Set LEDs on Audio Dock */ 1232 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_LEDS_2, 0x12); /* Set LEDs on Audio Dock */
1231 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x1); /* Unmute all */ 1233 snd_emu1010_fpga_write(emu, EMU_HANA_UNMUTE, 0x1); /* Unmute all */
1232 //snd_emu1010_fpga_write(emu, 0x7, 0x0); /* Mute all */ 1234 /* snd_emu1010_fpga_write(emu, 0x7, 0x0); */ /* Mute all */
1233 //snd_emu1010_fpga_write(emu, 0x7, 0x1); /* Unmute all */ 1235 /* snd_emu1010_fpga_write(emu, 0x7, 0x1); */ /* Unmute all */
1234 //snd_emu1010_fpga_write(emu, 0xe, 0x12); /* Set LEDs on Audio Dock */ 1236 /* snd_emu1010_fpga_write(emu, 0xe, 0x12); */ /* Set LEDs on Audio Dock */
1235 1237
1236 return 0; 1238 return 0;
1237} 1239}
@@ -1247,13 +1249,13 @@ static void free_pm_buffer(struct snd_emu10k1 *emu);
1247static int snd_emu10k1_free(struct snd_emu10k1 *emu) 1249static int snd_emu10k1_free(struct snd_emu10k1 *emu)
1248{ 1250{
1249 if (emu->port) { /* avoid access to already used hardware */ 1251 if (emu->port) { /* avoid access to already used hardware */
1250 snd_emu10k1_fx8010_tram_setup(emu, 0); 1252 snd_emu10k1_fx8010_tram_setup(emu, 0);
1251 snd_emu10k1_done(emu); 1253 snd_emu10k1_done(emu);
1252 snd_emu10k1_free_efx(emu); 1254 snd_emu10k1_free_efx(emu);
1253 } 1255 }
1254 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) { 1256 if (emu->card_capabilities->emu_model == EMU_MODEL_EMU1010) {
1255 /* Disable 48Volt power to Audio Dock */ 1257 /* Disable 48Volt power to Audio Dock */
1256 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0 ); 1258 snd_emu1010_fpga_write(emu, EMU_HANA_DOCK_PWR, 0);
1257 } 1259 }
1258 if (emu->emu1010.firmware_thread) 1260 if (emu->emu1010.firmware_thread)
1259 kthread_stop(emu->emu1010.firmware_thread); 1261 kthread_stop(emu->emu1010.firmware_thread);
@@ -1278,7 +1280,7 @@ static int snd_emu10k1_free(struct snd_emu10k1 *emu)
1278#endif 1280#endif
1279 if (emu->port) 1281 if (emu->port)
1280 pci_release_regions(emu->pci); 1282 pci_release_regions(emu->pci);
1281 if (emu->card_capabilities->ca0151_chip) /* P16V */ 1283 if (emu->card_capabilities->ca0151_chip) /* P16V */
1282 snd_p16v_free(emu); 1284 snd_p16v_free(emu);
1283 pci_disable_device(emu->pci); 1285 pci_disable_device(emu->pci);
1284 kfree(emu); 1286 kfree(emu);
@@ -1292,21 +1294,6 @@ static int snd_emu10k1_dev_free(struct snd_device *device)
1292} 1294}
1293 1295
1294static struct snd_emu_chip_details emu_chip_details[] = { 1296static struct snd_emu_chip_details emu_chip_details[] = {
1295 /* Audigy 2 Value AC3 out does not work yet. Need to find out how to turn off interpolators.*/
1296 /* Tested by James@superbug.co.uk 3rd July 2005 */
1297 /* DSP: CA0108-IAT
1298 * DAC: CS4382-KQ
1299 * ADC: Philips 1361T
1300 * AC97: STAC9750
1301 * CA0151: None
1302 */
1303 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102,
1304 .driver = "Audigy2", .name = "Audigy 2 Value [SB0400]",
1305 .id = "Audigy2",
1306 .emu10k2_chip = 1,
1307 .ca0108_chip = 1,
1308 .spk71 = 1,
1309 .ac97_chip = 1} ,
1310 /* Audigy4 (Not PRO) SB0610 */ 1297 /* Audigy4 (Not PRO) SB0610 */
1311 /* Tested by James@superbug.co.uk 4th April 2006 */ 1298 /* Tested by James@superbug.co.uk 4th April 2006 */
1312 /* A_IOCFG bits 1299 /* A_IOCFG bits
@@ -1346,20 +1333,37 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1346 * CA0151: None 1333 * CA0151: None
1347 */ 1334 */
1348 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10211102, 1335 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10211102,
1349 .driver = "Audigy2", .name = "Audigy 4 [SB0610]", 1336 .driver = "Audigy2", .name = "SB Audigy 4 [SB0610]",
1350 .id = "Audigy2", 1337 .id = "Audigy2",
1351 .emu10k2_chip = 1, 1338 .emu10k2_chip = 1,
1352 .ca0108_chip = 1, 1339 .ca0108_chip = 1,
1353 .spk71 = 1, 1340 .spk71 = 1,
1354 .adc_1361t = 1, /* 24 bit capture instead of 16bit */ 1341 .adc_1361t = 1, /* 24 bit capture instead of 16bit */
1355 .ac97_chip = 1} , 1342 .ac97_chip = 1} ,
1343 /* Audigy 2 Value AC3 out does not work yet.
1344 * Need to find out how to turn off interpolators.
1345 */
1346 /* Tested by James@superbug.co.uk 3rd July 2005 */
1347 /* DSP: CA0108-IAT
1348 * DAC: CS4382-KQ
1349 * ADC: Philips 1361T
1350 * AC97: STAC9750
1351 * CA0151: None
1352 */
1353 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x10011102,
1354 .driver = "Audigy2", .name = "SB Audigy 2 Value [SB0400]",
1355 .id = "Audigy2",
1356 .emu10k2_chip = 1,
1357 .ca0108_chip = 1,
1358 .spk71 = 1,
1359 .ac97_chip = 1} ,
1356 /* Audigy 2 ZS Notebook Cardbus card.*/ 1360 /* Audigy 2 ZS Notebook Cardbus card.*/
1357 /* Tested by James@superbug.co.uk 6th November 2006 */ 1361 /* Tested by James@superbug.co.uk 6th November 2006 */
1358 /* Audio output 7.1/Headphones working. 1362 /* Audio output 7.1/Headphones working.
1359 * Digital output working. (AC3 not checked, only PCM) 1363 * Digital output working. (AC3 not checked, only PCM)
1360 * Audio Mic/Line inputs working. 1364 * Audio Mic/Line inputs working.
1361 * Digital input not tested. 1365 * Digital input not tested.
1362 */ 1366 */
1363 /* DSP: Tina2 1367 /* DSP: Tina2
1364 * DAC: Wolfson WM8768/WM8568 1368 * DAC: Wolfson WM8768/WM8568
1365 * ADC: Wolfson WM8775 1369 * ADC: Wolfson WM8775
@@ -1386,7 +1390,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1386 * 1390 *
1387 */ 1391 */
1388 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102, 1392 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x20011102,
1389 .driver = "Audigy2", .name = "Audigy 2 ZS Notebook [SB0530]", 1393 .driver = "Audigy2", .name = "SB Audigy 2 ZS Notebook [SB0530]",
1390 .id = "Audigy2", 1394 .id = "Audigy2",
1391 .emu10k2_chip = 1, 1395 .emu10k2_chip = 1,
1392 .ca0108_chip = 1, 1396 .ca0108_chip = 1,
@@ -1396,7 +1400,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1396 .spk71 = 1} , 1400 .spk71 = 1} ,
1397 /* Tested by James@superbug.co.uk 4th Nov 2007. */ 1401 /* Tested by James@superbug.co.uk 4th Nov 2007. */
1398 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x42011102, 1402 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x42011102,
1399 .driver = "Audigy2", .name = "E-mu 1010 Notebook [MAEM8950]", 1403 .driver = "Audigy2", .name = "E-mu 1010 Notebook [MAEM8950]",
1400 .id = "EMU1010", 1404 .id = "EMU1010",
1401 .emu10k2_chip = 1, 1405 .emu10k2_chip = 1,
1402 .ca0108_chip = 1, 1406 .ca0108_chip = 1,
@@ -1404,47 +1408,49 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1404 .spk71 = 1 , 1408 .spk71 = 1 ,
1405 .emu_model = EMU_MODEL_EMU1616}, 1409 .emu_model = EMU_MODEL_EMU1616},
1406 /* Tested by James@superbug.co.uk 4th Nov 2007. */ 1410 /* Tested by James@superbug.co.uk 4th Nov 2007. */
1411 /* This is MAEM8960, 0202 is MAEM 8980 */
1407 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40041102, 1412 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40041102,
1408 .driver = "Audigy2", .name = "E-mu 1010b PCI [MAEM????]", 1413 .driver = "Audigy2", .name = "E-mu 1010b PCI [MAEM8960]",
1409 .id = "EMU1010", 1414 .id = "EMU1010",
1410 .emu10k2_chip = 1, 1415 .emu10k2_chip = 1,
1411 .ca0108_chip = 1, 1416 .ca0108_chip = 1,
1412 .spk71 = 1, 1417 .spk71 = 1,
1413 .emu_model = EMU_MODEL_EMU1010B}, 1418 .emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 new revision */
1414 /* Tested by James@superbug.co.uk 8th July 2005. */ 1419 /* Tested by James@superbug.co.uk 8th July 2005. */
1420 /* This is MAEM8810, 0202 is MAEM8820 */
1415 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102, 1421 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102,
1416 .driver = "Audigy2", .name = "E-mu 1010 [4001]", 1422 .driver = "Audigy2", .name = "E-mu 1010 [MAEM8810]",
1417 .id = "EMU1010", 1423 .id = "EMU1010",
1418 .emu10k2_chip = 1, 1424 .emu10k2_chip = 1,
1419 .ca0102_chip = 1, 1425 .ca0102_chip = 1,
1420 .spk71 = 1, 1426 .spk71 = 1,
1421 .emu_model = EMU_MODEL_EMU1010}, /* Emu 1010 */ 1427 .emu_model = EMU_MODEL_EMU1010}, /* EMU 1010 old revision */
1422 /* EMU0404b */ 1428 /* EMU0404b */
1423 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40021102, 1429 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40021102,
1424 .driver = "Audigy2", .name = "E-mu 0404b [4002]", 1430 .driver = "Audigy2", .name = "E-mu 0404b PCI [MAEM8852]",
1425 .id = "EMU0404", 1431 .id = "EMU0404",
1426 .emu10k2_chip = 1, 1432 .emu10k2_chip = 1,
1427 .ca0108_chip = 1, 1433 .ca0108_chip = 1,
1428 .spk71 = 1, 1434 .spk71 = 1,
1429 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 */ 1435 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 new revision */
1430 /* Tested by James@superbug.co.uk 20-3-2007. */ 1436 /* Tested by James@superbug.co.uk 20-3-2007. */
1431 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40021102, 1437 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40021102,
1432 .driver = "Audigy2", .name = "E-mu 0404 [4002]", 1438 .driver = "Audigy2", .name = "E-mu 0404 [MAEM8850]",
1433 .id = "EMU0404", 1439 .id = "EMU0404",
1434 .emu10k2_chip = 1, 1440 .emu10k2_chip = 1,
1435 .ca0102_chip = 1, 1441 .ca0102_chip = 1,
1436 .spk71 = 1, 1442 .spk71 = 1,
1437 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 */ 1443 .emu_model = EMU_MODEL_EMU0404}, /* EMU 0404 */
1438 /* Audigy4 (Not PRO) SB0610 */ 1444 /* Note that all E-mu cards require kernel 2.6 or newer. */
1439 {.vendor = 0x1102, .device = 0x0008, 1445 {.vendor = 0x1102, .device = 0x0008,
1440 .driver = "Audigy2", .name = "Audigy 2 Value [Unknown]", 1446 .driver = "Audigy2", .name = "SB Audigy 2 Value [Unknown]",
1441 .id = "Audigy2", 1447 .id = "Audigy2",
1442 .emu10k2_chip = 1, 1448 .emu10k2_chip = 1,
1443 .ca0108_chip = 1, 1449 .ca0108_chip = 1,
1444 .ac97_chip = 1} , 1450 .ac97_chip = 1} ,
1445 /* Tested by James@superbug.co.uk 3rd July 2005 */ 1451 /* Tested by James@superbug.co.uk 3rd July 2005 */
1446 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102, 1452 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20071102,
1447 .driver = "Audigy2", .name = "Audigy 4 PRO [SB0380]", 1453 .driver = "Audigy2", .name = "SB Audigy 4 PRO [SB0380]",
1448 .id = "Audigy2", 1454 .id = "Audigy2",
1449 .emu10k2_chip = 1, 1455 .emu10k2_chip = 1,
1450 .ca0102_chip = 1, 1456 .ca0102_chip = 1,
@@ -1457,7 +1463,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1457 * Just like 0x20021102 1463 * Just like 0x20021102
1458 */ 1464 */
1459 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20061102, 1465 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20061102,
1460 .driver = "Audigy2", .name = "Audigy 2 [SB0350b]", 1466 .driver = "Audigy2", .name = "SB Audigy 2 [SB0350b]",
1461 .id = "Audigy2", 1467 .id = "Audigy2",
1462 .emu10k2_chip = 1, 1468 .emu10k2_chip = 1,
1463 .ca0102_chip = 1, 1469 .ca0102_chip = 1,
@@ -1467,7 +1473,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1467 .invert_shared_spdif = 1, /* digital/analog switch swapped */ 1473 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1468 .ac97_chip = 1} , 1474 .ac97_chip = 1} ,
1469 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, 1475 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102,
1470 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", 1476 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0350]",
1471 .id = "Audigy2", 1477 .id = "Audigy2",
1472 .emu10k2_chip = 1, 1478 .emu10k2_chip = 1,
1473 .ca0102_chip = 1, 1479 .ca0102_chip = 1,
@@ -1477,7 +1483,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1477 .invert_shared_spdif = 1, /* digital/analog switch swapped */ 1483 .invert_shared_spdif = 1, /* digital/analog switch swapped */
1478 .ac97_chip = 1} , 1484 .ac97_chip = 1} ,
1479 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, 1485 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102,
1480 .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", 1486 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0360]",
1481 .id = "Audigy2", 1487 .id = "Audigy2",
1482 .emu10k2_chip = 1, 1488 .emu10k2_chip = 1,
1483 .ca0102_chip = 1, 1489 .ca0102_chip = 1,
@@ -1495,7 +1501,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1495 * CA0151: Yes 1501 * CA0151: Yes
1496 */ 1502 */
1497 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, 1503 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102,
1498 .driver = "Audigy2", .name = "Audigy 2 [SB0240]", 1504 .driver = "Audigy2", .name = "SB Audigy 2 [SB0240]",
1499 .id = "Audigy2", 1505 .id = "Audigy2",
1500 .emu10k2_chip = 1, 1506 .emu10k2_chip = 1,
1501 .ca0102_chip = 1, 1507 .ca0102_chip = 1,
@@ -1505,7 +1511,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1505 .adc_1361t = 1, /* 24 bit capture instead of 16bit */ 1511 .adc_1361t = 1, /* 24 bit capture instead of 16bit */
1506 .ac97_chip = 1} , 1512 .ac97_chip = 1} ,
1507 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, 1513 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102,
1508 .driver = "Audigy2", .name = "Audigy 2 EX [1005]", 1514 .driver = "Audigy2", .name = "SB Audigy 2 Platinum EX [SB0280]",
1509 .id = "Audigy2", 1515 .id = "Audigy2",
1510 .emu10k2_chip = 1, 1516 .emu10k2_chip = 1,
1511 .ca0102_chip = 1, 1517 .ca0102_chip = 1,
@@ -1515,7 +1521,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1515 /* Dell OEM/Creative Labs Audigy 2 ZS */ 1521 /* Dell OEM/Creative Labs Audigy 2 ZS */
1516 /* See ALSA bug#1365 */ 1522 /* See ALSA bug#1365 */
1517 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102, 1523 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102,
1518 .driver = "Audigy2", .name = "Audigy 2 ZS [SB0353]", 1524 .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0353]",
1519 .id = "Audigy2", 1525 .id = "Audigy2",
1520 .emu10k2_chip = 1, 1526 .emu10k2_chip = 1,
1521 .ca0102_chip = 1, 1527 .ca0102_chip = 1,
@@ -1524,7 +1530,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1524 .spdif_bug = 1, 1530 .spdif_bug = 1,
1525 .ac97_chip = 1} , 1531 .ac97_chip = 1} ,
1526 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, 1532 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102,
1527 .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", 1533 .driver = "Audigy2", .name = "SB Audigy 2 Platinum [SB0240P]",
1528 .id = "Audigy2", 1534 .id = "Audigy2",
1529 .emu10k2_chip = 1, 1535 .emu10k2_chip = 1,
1530 .ca0102_chip = 1, 1536 .ca0102_chip = 1,
@@ -1535,7 +1541,7 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1535 .adc_1361t = 1, /* 24 bit capture instead of 16bit. Fixes ALSA bug#324 */ 1541 .adc_1361t = 1, /* 24 bit capture instead of 16bit. Fixes ALSA bug#324 */
1536 .ac97_chip = 1} , 1542 .ac97_chip = 1} ,
1537 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04, 1543 {.vendor = 0x1102, .device = 0x0004, .revision = 0x04,
1538 .driver = "Audigy2", .name = "Audigy 2 [Unknown]", 1544 .driver = "Audigy2", .name = "SB Audigy 2 [Unknown]",
1539 .id = "Audigy2", 1545 .id = "Audigy2",
1540 .emu10k2_chip = 1, 1546 .emu10k2_chip = 1,
1541 .ca0102_chip = 1, 1547 .ca0102_chip = 1,
@@ -1543,78 +1549,79 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1543 .spdif_bug = 1, 1549 .spdif_bug = 1,
1544 .ac97_chip = 1} , 1550 .ac97_chip = 1} ,
1545 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102, 1551 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102,
1546 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 1552 .driver = "Audigy", .name = "SB Audigy 1 [SB0092]",
1547 .id = "Audigy", 1553 .id = "Audigy",
1548 .emu10k2_chip = 1, 1554 .emu10k2_chip = 1,
1549 .ca0102_chip = 1, 1555 .ca0102_chip = 1,
1550 .ac97_chip = 1} , 1556 .ac97_chip = 1} ,
1551 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102, 1557 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102,
1552 .driver = "Audigy", .name = "Audigy 1 ES [SB0160]", 1558 .driver = "Audigy", .name = "SB Audigy 1 ES [SB0160]",
1553 .id = "Audigy", 1559 .id = "Audigy",
1554 .emu10k2_chip = 1, 1560 .emu10k2_chip = 1,
1555 .ca0102_chip = 1, 1561 .ca0102_chip = 1,
1556 .spdif_bug = 1, 1562 .spdif_bug = 1,
1557 .ac97_chip = 1} , 1563 .ac97_chip = 1} ,
1558 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102, 1564 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102,
1559 .driver = "Audigy", .name = "Audigy 1 [SB0090]", 1565 .driver = "Audigy", .name = "SB Audigy 1 [SB0090]",
1560 .id = "Audigy", 1566 .id = "Audigy",
1561 .emu10k2_chip = 1, 1567 .emu10k2_chip = 1,
1562 .ca0102_chip = 1, 1568 .ca0102_chip = 1,
1563 .ac97_chip = 1} , 1569 .ac97_chip = 1} ,
1564 {.vendor = 0x1102, .device = 0x0004, 1570 {.vendor = 0x1102, .device = 0x0004,
1565 .driver = "Audigy", .name = "Audigy 1 [Unknown]", 1571 .driver = "Audigy", .name = "Audigy 1 [Unknown]",
1566 .id = "Audigy", 1572 .id = "Audigy",
1567 .emu10k2_chip = 1, 1573 .emu10k2_chip = 1,
1568 .ca0102_chip = 1, 1574 .ca0102_chip = 1,
1569 .ac97_chip = 1} , 1575 .ac97_chip = 1} ,
1570 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806B1102, 1576 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102,
1571 .driver = "EMU10K1", .name = "SBLive! [SB0105]", 1577 .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0220]",
1578 .id = "Live",
1579 .emu10k1_chip = 1,
1580 .ac97_chip = 1,
1581 .sblive51 = 1} ,
1582 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806b1102,
1583 .driver = "EMU10K1", .name = "SB Live! [SB0105]",
1572 .id = "Live", 1584 .id = "Live",
1573 .emu10k1_chip = 1, 1585 .emu10k1_chip = 1,
1574 .ac97_chip = 1, 1586 .ac97_chip = 1,
1575 .sblive51 = 1} , 1587 .sblive51 = 1} ,
1576 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806A1102, 1588 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806a1102,
1577 .driver = "EMU10K1", .name = "SBLive! Value [SB0103]", 1589 .driver = "EMU10K1", .name = "SB Live! Value [SB0103]",
1578 .id = "Live", 1590 .id = "Live",
1579 .emu10k1_chip = 1, 1591 .emu10k1_chip = 1,
1580 .ac97_chip = 1, 1592 .ac97_chip = 1,
1581 .sblive51 = 1} , 1593 .sblive51 = 1} ,
1582 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102, 1594 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102,
1583 .driver = "EMU10K1", .name = "SBLive! Value [SB0101]", 1595 .driver = "EMU10K1", .name = "SB Live! Value [SB0101]",
1584 .id = "Live", 1596 .id = "Live",
1585 .emu10k1_chip = 1, 1597 .emu10k1_chip = 1,
1586 .ac97_chip = 1, 1598 .ac97_chip = 1,
1587 .sblive51 = 1} , 1599 .sblive51 = 1} ,
1588 /* Tested by ALSA bug#1680 26th December 2005 */ 1600 /* Tested by ALSA bug#1680 26th December 2005 */
1589 /* note: It really has SB0220 written on the card. */ 1601 /* note: It really has SB0220 written on the card, */
1602 /* but it's SB0228 according to kx.inf */
1590 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102, 1603 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102,
1591 .driver = "EMU10K1", .name = "SB Live 5.1 Dell OEM [SB0220]", 1604 .driver = "EMU10K1", .name = "SB Live! 5.1 Dell OEM [SB0228]",
1592 .id = "Live", 1605 .id = "Live",
1593 .emu10k1_chip = 1, 1606 .emu10k1_chip = 1,
1594 .ac97_chip = 1, 1607 .ac97_chip = 1,
1595 .sblive51 = 1} , 1608 .sblive51 = 1} ,
1596 /* Tested by Thomas Zehetbauer 27th Aug 2005 */ 1609 /* Tested by Thomas Zehetbauer 27th Aug 2005 */
1597 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102, 1610 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102,
1598 .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", 1611 .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0220]",
1599 .id = "Live",
1600 .emu10k1_chip = 1,
1601 .ac97_chip = 1,
1602 .sblive51 = 1} ,
1603 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102,
1604 .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]",
1605 .id = "Live", 1612 .id = "Live",
1606 .emu10k1_chip = 1, 1613 .emu10k1_chip = 1,
1607 .ac97_chip = 1, 1614 .ac97_chip = 1,
1608 .sblive51 = 1} , 1615 .sblive51 = 1} ,
1609 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, 1616 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102,
1610 .driver = "EMU10K1", .name = "SB Live 5.1", 1617 .driver = "EMU10K1", .name = "SB Live! 5.1",
1611 .id = "Live", 1618 .id = "Live",
1612 .emu10k1_chip = 1, 1619 .emu10k1_chip = 1,
1613 .ac97_chip = 1, 1620 .ac97_chip = 1,
1614 .sblive51 = 1} , 1621 .sblive51 = 1} ,
1615 /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */ 1622 /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */
1616 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, 1623 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102,
1617 .driver = "EMU10K1", .name = "SBLive 5.1 [SB0060]", 1624 .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0060]",
1618 .id = "Live", 1625 .id = "Live",
1619 .emu10k1_chip = 1, 1626 .emu10k1_chip = 1,
1620 .ac97_chip = 2, /* ac97 is optional; both SBLive 5.1 and platinum 1627 .ac97_chip = 2, /* ac97 is optional; both SBLive 5.1 and platinum
@@ -1622,78 +1629,78 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1622 */ 1629 */
1623 .sblive51 = 1} , 1630 .sblive51 = 1} ,
1624 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, 1631 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102,
1625 .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", 1632 .driver = "EMU10K1", .name = "SB Live! Value [CT4850]",
1626 .id = "Live", 1633 .id = "Live",
1627 .emu10k1_chip = 1, 1634 .emu10k1_chip = 1,
1628 .ac97_chip = 1, 1635 .ac97_chip = 1,
1629 .sblive51 = 1} , 1636 .sblive51 = 1} ,
1630 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102, 1637 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102,
1631 .driver = "EMU10K1", .name = "SBLive! Platinum [CT4760P]", 1638 .driver = "EMU10K1", .name = "SB Live! Platinum [CT4760P]",
1632 .id = "Live", 1639 .id = "Live",
1633 .emu10k1_chip = 1, 1640 .emu10k1_chip = 1,
1634 .ac97_chip = 1} , 1641 .ac97_chip = 1} ,
1635 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102, 1642 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102,
1636 .driver = "EMU10K1", .name = "SBLive! Value [CT4871]", 1643 .driver = "EMU10K1", .name = "SB Live! Value [CT4871]",
1637 .id = "Live", 1644 .id = "Live",
1638 .emu10k1_chip = 1, 1645 .emu10k1_chip = 1,
1639 .ac97_chip = 1, 1646 .ac97_chip = 1,
1640 .sblive51 = 1} , 1647 .sblive51 = 1} ,
1641 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102, 1648 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102,
1642 .driver = "EMU10K1", .name = "SBLive! Value [CT4831]", 1649 .driver = "EMU10K1", .name = "SB Live! Value [CT4831]",
1643 .id = "Live", 1650 .id = "Live",
1644 .emu10k1_chip = 1, 1651 .emu10k1_chip = 1,
1645 .ac97_chip = 1, 1652 .ac97_chip = 1,
1646 .sblive51 = 1} , 1653 .sblive51 = 1} ,
1647 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102, 1654 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102,
1648 .driver = "EMU10K1", .name = "SBLive! Value [CT4870]", 1655 .driver = "EMU10K1", .name = "SB Live! Value [CT4870]",
1649 .id = "Live", 1656 .id = "Live",
1650 .emu10k1_chip = 1, 1657 .emu10k1_chip = 1,
1651 .ac97_chip = 1, 1658 .ac97_chip = 1,
1652 .sblive51 = 1} , 1659 .sblive51 = 1} ,
1653 /* Tested by James@superbug.co.uk 3rd July 2005 */ 1660 /* Tested by James@superbug.co.uk 3rd July 2005 */
1654 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102, 1661 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102,
1655 .driver = "EMU10K1", .name = "SBLive! Value [CT4832]", 1662 .driver = "EMU10K1", .name = "SB Live! Value [CT4832]",
1656 .id = "Live", 1663 .id = "Live",
1657 .emu10k1_chip = 1, 1664 .emu10k1_chip = 1,
1658 .ac97_chip = 1, 1665 .ac97_chip = 1,
1659 .sblive51 = 1} , 1666 .sblive51 = 1} ,
1660 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102, 1667 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102,
1661 .driver = "EMU10K1", .name = "SBLive! Value [CT4830]", 1668 .driver = "EMU10K1", .name = "SB Live! Value [CT4830]",
1662 .id = "Live", 1669 .id = "Live",
1663 .emu10k1_chip = 1, 1670 .emu10k1_chip = 1,
1664 .ac97_chip = 1, 1671 .ac97_chip = 1,
1665 .sblive51 = 1} , 1672 .sblive51 = 1} ,
1666 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102, 1673 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102,
1667 .driver = "EMU10K1", .name = "SB PCI512 [CT4790]", 1674 .driver = "EMU10K1", .name = "SB PCI512 [CT4790]",
1668 .id = "Live", 1675 .id = "Live",
1669 .emu10k1_chip = 1, 1676 .emu10k1_chip = 1,
1670 .ac97_chip = 1, 1677 .ac97_chip = 1,
1671 .sblive51 = 1} , 1678 .sblive51 = 1} ,
1672 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102, 1679 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102,
1673 .driver = "EMU10K1", .name = "SBLive! Value [CT4780]", 1680 .driver = "EMU10K1", .name = "SB Live! Value [CT4780]",
1674 .id = "Live", 1681 .id = "Live",
1675 .emu10k1_chip = 1, 1682 .emu10k1_chip = 1,
1676 .ac97_chip = 1, 1683 .ac97_chip = 1,
1677 .sblive51 = 1} , 1684 .sblive51 = 1} ,
1678 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, 1685 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102,
1679 .driver = "EMU10K1", .name = "E-mu APS [4001]", 1686 .driver = "EMU10K1", .name = "E-mu APS [PC545]",
1680 .id = "APS", 1687 .id = "APS",
1681 .emu10k1_chip = 1, 1688 .emu10k1_chip = 1,
1682 .ecard = 1} , 1689 .ecard = 1} ,
1683 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102, 1690 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102,
1684 .driver = "EMU10K1", .name = "SBLive! [CT4620]", 1691 .driver = "EMU10K1", .name = "SB Live! [CT4620]",
1685 .id = "Live", 1692 .id = "Live",
1686 .emu10k1_chip = 1, 1693 .emu10k1_chip = 1,
1687 .ac97_chip = 1, 1694 .ac97_chip = 1,
1688 .sblive51 = 1} , 1695 .sblive51 = 1} ,
1689 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102, 1696 {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102,
1690 .driver = "EMU10K1", .name = "SBLive! Value [CT4670]", 1697 .driver = "EMU10K1", .name = "SB Live! Value [CT4670]",
1691 .id = "Live", 1698 .id = "Live",
1692 .emu10k1_chip = 1, 1699 .emu10k1_chip = 1,
1693 .ac97_chip = 1, 1700 .ac97_chip = 1,
1694 .sblive51 = 1} , 1701 .sblive51 = 1} ,
1695 {.vendor = 0x1102, .device = 0x0002, 1702 {.vendor = 0x1102, .device = 0x0002,
1696 .driver = "EMU10K1", .name = "SB Live [Unknown]", 1703 .driver = "EMU10K1", .name = "SB Live! [Unknown]",
1697 .id = "Live", 1704 .id = "Live",
1698 .emu10k1_chip = 1, 1705 .emu10k1_chip = 1,
1699 .ac97_chip = 1, 1706 .ac97_chip = 1,
@@ -1702,13 +1709,13 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1702}; 1709};
1703 1710
1704int __devinit snd_emu10k1_create(struct snd_card *card, 1711int __devinit snd_emu10k1_create(struct snd_card *card,
1705 struct pci_dev * pci, 1712 struct pci_dev *pci,
1706 unsigned short extin_mask, 1713 unsigned short extin_mask,
1707 unsigned short extout_mask, 1714 unsigned short extout_mask,
1708 long max_cache_bytes, 1715 long max_cache_bytes,
1709 int enable_ir, 1716 int enable_ir,
1710 uint subsystem, 1717 uint subsystem,
1711 struct snd_emu10k1 ** remu) 1718 struct snd_emu10k1 **remu)
1712{ 1719{
1713 struct snd_emu10k1 *emu; 1720 struct snd_emu10k1 *emu;
1714 int idx, err; 1721 int idx, err;
@@ -1718,11 +1725,12 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1718 static struct snd_device_ops ops = { 1725 static struct snd_device_ops ops = {
1719 .dev_free = snd_emu10k1_dev_free, 1726 .dev_free = snd_emu10k1_dev_free,
1720 }; 1727 };
1721 1728
1722 *remu = NULL; 1729 *remu = NULL;
1723 1730
1724 /* enable PCI device */ 1731 /* enable PCI device */
1725 if ((err = pci_enable_device(pci)) < 0) 1732 err = pci_enable_device(pci);
1733 if (err < 0)
1726 return err; 1734 return err;
1727 1735
1728 emu = kzalloc(sizeof(*emu), GFP_KERNEL); 1736 emu = kzalloc(sizeof(*emu), GFP_KERNEL);
@@ -1749,16 +1757,17 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1749 emu->revision = pci->revision; 1757 emu->revision = pci->revision;
1750 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); 1758 pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial);
1751 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); 1759 pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model);
1752 snd_printdd("vendor=0x%x, device=0x%x, subsystem_vendor_id=0x%x, subsystem_id=0x%x\n",pci->vendor, pci->device, emu->serial, emu->model); 1760 snd_printdd("vendor = 0x%x, device = 0x%x, subsystem_vendor_id = 0x%x, subsystem_id = 0x%x\n", pci->vendor, pci->device, emu->serial, emu->model);
1753 1761
1754 for (c = emu_chip_details; c->vendor; c++) { 1762 for (c = emu_chip_details; c->vendor; c++) {
1755 if (c->vendor == pci->vendor && c->device == pci->device) { 1763 if (c->vendor == pci->vendor && c->device == pci->device) {
1756 if (subsystem) { 1764 if (subsystem) {
1757 if (c->subsystem && (c->subsystem == subsystem) ) { 1765 if (c->subsystem && (c->subsystem == subsystem))
1758 break; 1766 break;
1759 } else continue; 1767 else
1768 continue;
1760 } else { 1769 } else {
1761 if (c->subsystem && (c->subsystem != emu->serial) ) 1770 if (c->subsystem && (c->subsystem != emu->serial))
1762 continue; 1771 continue;
1763 if (c->revision && c->revision != emu->revision) 1772 if (c->revision && c->revision != emu->revision)
1764 continue; 1773 continue;
@@ -1774,14 +1783,18 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1774 } 1783 }
1775 emu->card_capabilities = c; 1784 emu->card_capabilities = c;
1776 if (c->subsystem && !subsystem) 1785 if (c->subsystem && !subsystem)
1777 snd_printdd("Sound card name=%s\n", c->name); 1786 snd_printdd("Sound card name = %s\n", c->name);
1778 else if (subsystem) 1787 else if (subsystem)
1779 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x. Forced to subsytem=0x%x\n", 1788 snd_printdd("Sound card name = %s, "
1780 c->name, pci->vendor, pci->device, emu->serial, c->subsystem); 1789 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x. "
1781 else 1790 "Forced to subsytem = 0x%x\n", c->name,
1782 snd_printdd("Sound card name=%s, vendor=0x%x, device=0x%x, subsystem=0x%x.\n", 1791 pci->vendor, pci->device, emu->serial, c->subsystem);
1783 c->name, pci->vendor, pci->device, emu->serial); 1792 else
1784 1793 snd_printdd("Sound card name = %s, "
1794 "vendor = 0x%x, device = 0x%x, subsystem = 0x%x.\n",
1795 c->name, pci->vendor, pci->device,
1796 emu->serial);
1797
1785 if (!*card->id && c->id) { 1798 if (!*card->id && c->id) {
1786 int i, n = 0; 1799 int i, n = 0;
1787 strlcpy(card->id, c->id, sizeof(card->id)); 1800 strlcpy(card->id, c->id, sizeof(card->id));
@@ -1815,7 +1828,8 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1815 else 1828 else
1816 emu->gpr_base = FXGPREGBASE; 1829 emu->gpr_base = FXGPREGBASE;
1817 1830
1818 if ((err = pci_request_regions(pci, "EMU10K1")) < 0) { 1831 err = pci_request_regions(pci, "EMU10K1");
1832 if (err < 0) {
1819 kfree(emu); 1833 kfree(emu);
1820 pci_disable_device(pci); 1834 pci_disable_device(pci);
1821 return err; 1835 return err;
@@ -1862,21 +1876,25 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1862 emu->enable_ir = enable_ir; 1876 emu->enable_ir = enable_ir;
1863 1877
1864 if (emu->card_capabilities->ca_cardbus_chip) { 1878 if (emu->card_capabilities->ca_cardbus_chip) {
1865 if ((err = snd_emu10k1_cardbus_init(emu)) < 0) 1879 err = snd_emu10k1_cardbus_init(emu);
1880 if (err < 0)
1866 goto error; 1881 goto error;
1867 } 1882 }
1868 if (emu->card_capabilities->ecard) { 1883 if (emu->card_capabilities->ecard) {
1869 if ((err = snd_emu10k1_ecard_init(emu)) < 0) 1884 err = snd_emu10k1_ecard_init(emu);
1885 if (err < 0)
1870 goto error; 1886 goto error;
1871 } else if (emu->card_capabilities->emu_model) { 1887 } else if (emu->card_capabilities->emu_model) {
1872 if ((err = snd_emu10k1_emu1010_init(emu)) < 0) { 1888 err = snd_emu10k1_emu1010_init(emu);
1873 snd_emu10k1_free(emu); 1889 if (err < 0) {
1874 return err; 1890 snd_emu10k1_free(emu);
1875 } 1891 return err;
1892 }
1876 } else { 1893 } else {
1877 /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version 1894 /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version
1878 does not support this, it shouldn't do any harm */ 1895 does not support this, it shouldn't do any harm */
1879 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); 1896 snd_emu10k1_ptr_write(emu, AC97SLOT, 0,
1897 AC97SLOT_CNTR|AC97SLOT_LFE);
1880 } 1898 }
1881 1899
1882 /* initialize TRAM setup */ 1900 /* initialize TRAM setup */
@@ -1916,7 +1934,7 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1916 snd_emu10k1_synth_alloc(emu, 4096); 1934 snd_emu10k1_synth_alloc(emu, 4096);
1917 if (emu->reserved_page) 1935 if (emu->reserved_page)
1918 emu->reserved_page->map_locked = 1; 1936 emu->reserved_page->map_locked = 1;
1919 1937
1920 /* Clear silent pages and set up pointers */ 1938 /* Clear silent pages and set up pointers */
1921 memset(emu->silent_page.area, 0, PAGE_SIZE); 1939 memset(emu->silent_page.area, 0, PAGE_SIZE);
1922 silent_page = emu->silent_page.addr << 1; 1940 silent_page = emu->silent_page.addr << 1;
@@ -1929,19 +1947,23 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
1929 emu->voices[idx].number = idx; 1947 emu->voices[idx].number = idx;
1930 } 1948 }
1931 1949
1932 if ((err = snd_emu10k1_init(emu, enable_ir, 0)) < 0) 1950 err = snd_emu10k1_init(emu, enable_ir, 0);
1951 if (err < 0)
1933 goto error; 1952 goto error;
1934#ifdef CONFIG_PM 1953#ifdef CONFIG_PM
1935 if ((err = alloc_pm_buffer(emu)) < 0) 1954 err = alloc_pm_buffer(emu);
1955 if (err < 0)
1936 goto error; 1956 goto error;
1937#endif 1957#endif
1938 1958
1939 /* Initialize the effect engine */ 1959 /* Initialize the effect engine */
1940 if ((err = snd_emu10k1_init_efx(emu)) < 0) 1960 err = snd_emu10k1_init_efx(emu);
1961 if (err < 0)
1941 goto error; 1962 goto error;
1942 snd_emu10k1_audio_enable(emu); 1963 snd_emu10k1_audio_enable(emu);
1943 1964
1944 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops)) < 0) 1965 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, emu, &ops);
1966 if (err < 0)
1945 goto error; 1967 goto error;
1946 1968
1947#ifdef CONFIG_PROC_FS 1969#ifdef CONFIG_PROC_FS
@@ -1981,7 +2003,7 @@ static int __devinit alloc_pm_buffer(struct snd_emu10k1 *emu)
1981 if (emu->audigy) 2003 if (emu->audigy)
1982 size += ARRAY_SIZE(saved_regs_audigy); 2004 size += ARRAY_SIZE(saved_regs_audigy);
1983 emu->saved_ptr = vmalloc(4 * NUM_G * size); 2005 emu->saved_ptr = vmalloc(4 * NUM_G * size);
1984 if (! emu->saved_ptr) 2006 if (!emu->saved_ptr)
1985 return -ENOMEM; 2007 return -ENOMEM;
1986 if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) 2008 if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0)
1987 return -ENOMEM; 2009 return -ENOMEM;
@@ -2026,7 +2048,7 @@ void snd_emu10k1_resume_init(struct snd_emu10k1 *emu)
2026 if (emu->card_capabilities->ecard) 2048 if (emu->card_capabilities->ecard)
2027 snd_emu10k1_ecard_init(emu); 2049 snd_emu10k1_ecard_init(emu);
2028 else if (emu->card_capabilities->emu_model) 2050 else if (emu->card_capabilities->emu_model)
2029 snd_emu10k1_emu1010_init(emu); 2051 snd_emu10k1_emu1010_init(emu);
2030 else 2052 else
2031 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); 2053 snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE);
2032 snd_emu10k1_init(emu, emu->enable_ir, 1); 2054 snd_emu10k1_init(emu, emu->enable_ir, 1);
diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c
index f34bbfb705f..b0fb6c917c3 100644
--- a/sound/pci/emu10k1/emumixer.c
+++ b/sound/pci/emu10k1/emumixer.c
@@ -1639,6 +1639,45 @@ static struct snd_kcontrol_new snd_audigy_shared_spdif __devinitdata =
1639 .put = snd_emu10k1_shared_spdif_put 1639 .put = snd_emu10k1_shared_spdif_put
1640}; 1640};
1641 1641
1642/* workaround for too low volume on Audigy due to 16bit/24bit conversion */
1643
1644#define snd_audigy_capture_boost_info snd_ctl_boolean_mono_info
1645
1646static int snd_audigy_capture_boost_get(struct snd_kcontrol *kcontrol,
1647 struct snd_ctl_elem_value *ucontrol)
1648{
1649 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1650 unsigned int val;
1651
1652 /* FIXME: better to use a cached version */
1653 val = snd_ac97_read(emu->ac97, AC97_REC_GAIN);
1654 ucontrol->value.integer.value[0] = !!val;
1655 return 0;
1656}
1657
1658static int snd_audigy_capture_boost_put(struct snd_kcontrol *kcontrol,
1659 struct snd_ctl_elem_value *ucontrol)
1660{
1661 struct snd_emu10k1 *emu = snd_kcontrol_chip(kcontrol);
1662 unsigned int val;
1663
1664 if (ucontrol->value.integer.value[0])
1665 val = 0x0f0f;
1666 else
1667 val = 0;
1668 return snd_ac97_update(emu->ac97, AC97_REC_GAIN, val);
1669}
1670
1671static struct snd_kcontrol_new snd_audigy_capture_boost __devinitdata =
1672{
1673 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1674 .name = "Analog Capture Boost",
1675 .info = snd_audigy_capture_boost_info,
1676 .get = snd_audigy_capture_boost_get,
1677 .put = snd_audigy_capture_boost_put
1678};
1679
1680
1642/* 1681/*
1643 */ 1682 */
1644static void snd_emu10k1_mixer_free_ac97(struct snd_ac97 *ac97) 1683static void snd_emu10k1_mixer_free_ac97(struct snd_ac97 *ac97)
@@ -2087,5 +2126,12 @@ int __devinit snd_emu10k1_mixer(struct snd_emu10k1 *emu,
2087 } 2126 }
2088 } 2127 }
2089 2128
2129 if (emu->card_capabilities->ac97_chip && emu->audigy) {
2130 err = snd_ctl_add(card, snd_ctl_new1(&snd_audigy_capture_boost,
2131 emu));
2132 if (err < 0)
2133 return err;
2134 }
2135
2090 return 0; 2136 return 0;
2091} 2137}
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 5dd3e89f620..b77f330d265 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -69,6 +69,7 @@ enum {
69}; 69};
70 70
71enum { 71enum {
72 STAC_92HD73XX_NO_JD, /* no jack-detection */
72 STAC_92HD73XX_REF, 73 STAC_92HD73XX_REF,
73 STAC_DELL_M6_AMIC, 74 STAC_DELL_M6_AMIC,
74 STAC_DELL_M6_DMIC, 75 STAC_DELL_M6_DMIC,
@@ -127,6 +128,7 @@ enum {
127}; 128};
128 129
129enum { 130enum {
131 STAC_D965_REF_NO_JD, /* no jack-detection */
130 STAC_D965_REF, 132 STAC_D965_REF,
131 STAC_D965_3ST, 133 STAC_D965_3ST,
132 STAC_D965_5ST, 134 STAC_D965_5ST,
@@ -857,6 +859,7 @@ static struct hda_verb stac92hd83xxx_core_init[] = {
857 859
858 /* power state controls amps */ 860 /* power state controls amps */
859 { 0x01, AC_VERB_SET_EAPD, 1 << 2}, 861 { 0x01, AC_VERB_SET_EAPD, 1 << 2},
862 {}
860}; 863};
861 864
862static struct hda_verb stac92hd71bxx_core_init[] = { 865static struct hda_verb stac92hd71bxx_core_init[] = {
@@ -868,6 +871,7 @@ static struct hda_verb stac92hd71bxx_core_init[] = {
868 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 871 { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
869 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 872 { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
870 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, 873 { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
874 {}
871}; 875};
872 876
873#define HD_DISABLE_PORTF 2 877#define HD_DISABLE_PORTF 2
@@ -1611,6 +1615,7 @@ static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
1611}; 1615};
1612 1616
1613static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { 1617static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1618 [STAC_92HD73XX_NO_JD] = "no-jd",
1614 [STAC_92HD73XX_REF] = "ref", 1619 [STAC_92HD73XX_REF] = "ref",
1615 [STAC_DELL_M6_AMIC] = "dell-m6-amic", 1620 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1616 [STAC_DELL_M6_DMIC] = "dell-m6-dmic", 1621 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
@@ -1640,6 +1645,8 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1640 "unknown Dell", STAC_DELL_M6_DMIC), 1645 "unknown Dell", STAC_DELL_M6_DMIC),
1641 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, 1646 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
1642 "Dell Studio 1537", STAC_DELL_M6_DMIC), 1647 "Dell Studio 1537", STAC_DELL_M6_DMIC),
1648 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
1649 "Dell Studio 17", STAC_DELL_M6_DMIC),
1643 {} /* terminator */ 1650 {} /* terminator */
1644}; 1651};
1645 1652
@@ -1662,6 +1669,7 @@ static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1662 /* SigmaTel reference board */ 1669 /* SigmaTel reference board */
1663 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, 1670 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
1664 "DFI LanParty", STAC_92HD71BXX_REF), 1671 "DFI LanParty", STAC_92HD71BXX_REF),
1672 {} /* terminator */
1665}; 1673};
1666 1674
1667static unsigned int ref92hd71bxx_pin_configs[11] = { 1675static unsigned int ref92hd71bxx_pin_configs[11] = {
@@ -2027,6 +2035,7 @@ static unsigned int dell_3st_pin_configs[14] = {
2027}; 2035};
2028 2036
2029static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { 2037static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2038 [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
2030 [STAC_D965_REF] = ref927x_pin_configs, 2039 [STAC_D965_REF] = ref927x_pin_configs,
2031 [STAC_D965_3ST] = d965_3st_pin_configs, 2040 [STAC_D965_3ST] = d965_3st_pin_configs,
2032 [STAC_D965_5ST] = d965_5st_pin_configs, 2041 [STAC_D965_5ST] = d965_5st_pin_configs,
@@ -2035,6 +2044,7 @@ static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
2035}; 2044};
2036 2045
2037static const char *stac927x_models[STAC_927X_MODELS] = { 2046static const char *stac927x_models[STAC_927X_MODELS] = {
2047 [STAC_D965_REF_NO_JD] = "ref-no-jd",
2038 [STAC_D965_REF] = "ref", 2048 [STAC_D965_REF] = "ref",
2039 [STAC_D965_3ST] = "3stack", 2049 [STAC_D965_3ST] = "3stack",
2040 [STAC_D965_5ST] = "5stack", 2050 [STAC_D965_5ST] = "5stack",
@@ -2896,7 +2906,7 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
2896 } 2906 }
2897 2907
2898 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 && 2908 if ((spec->multiout.num_dacs - cfg->line_outs) > 0 &&
2899 cfg->hp_outs && !spec->multiout.hp_nid) 2909 cfg->hp_outs == 1 && !spec->multiout.hp_nid)
2900 spec->multiout.hp_nid = nid; 2910 spec->multiout.hp_nid = nid;
2901 2911
2902 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) { 2912 if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
@@ -4254,14 +4264,17 @@ again:
4254 4264
4255 switch (spec->multiout.num_dacs) { 4265 switch (spec->multiout.num_dacs) {
4256 case 0x3: /* 6 Channel */ 4266 case 0x3: /* 6 Channel */
4267 spec->multiout.hp_nid = 0x17;
4257 spec->mixer = stac92hd73xx_6ch_mixer; 4268 spec->mixer = stac92hd73xx_6ch_mixer;
4258 spec->init = stac92hd73xx_6ch_core_init; 4269 spec->init = stac92hd73xx_6ch_core_init;
4259 break; 4270 break;
4260 case 0x4: /* 8 Channel */ 4271 case 0x4: /* 8 Channel */
4272 spec->multiout.hp_nid = 0x18;
4261 spec->mixer = stac92hd73xx_8ch_mixer; 4273 spec->mixer = stac92hd73xx_8ch_mixer;
4262 spec->init = stac92hd73xx_8ch_core_init; 4274 spec->init = stac92hd73xx_8ch_core_init;
4263 break; 4275 break;
4264 case 0x5: /* 10 Channel */ 4276 case 0x5: /* 10 Channel */
4277 spec->multiout.hp_nid = 0x19;
4265 spec->mixer = stac92hd73xx_10ch_mixer; 4278 spec->mixer = stac92hd73xx_10ch_mixer;
4266 spec->init = stac92hd73xx_10ch_core_init; 4279 spec->init = stac92hd73xx_10ch_core_init;
4267 }; 4280 };
@@ -4297,6 +4310,7 @@ again:
4297 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP]; 4310 spec->amp_nids = &stac92hd73xx_amp_nids[DELL_M6_AMP];
4298 spec->eapd_switch = 0; 4311 spec->eapd_switch = 0;
4299 spec->num_amps = 1; 4312 spec->num_amps = 1;
4313 spec->multiout.hp_nid = 0; /* dual HPs */
4300 4314
4301 if (!spec->init) 4315 if (!spec->init)
4302 spec->init = dell_m6_core_init; 4316 spec->init = dell_m6_core_init;
@@ -4351,6 +4365,9 @@ again:
4351 return err; 4365 return err;
4352 } 4366 }
4353 4367
4368 if (spec->board_config == STAC_92HD73XX_NO_JD)
4369 spec->hp_detect = 0;
4370
4354 codec->patch_ops = stac92xx_patch_ops; 4371 codec->patch_ops = stac92xx_patch_ops;
4355 4372
4356 return 0; 4373 return 0;
@@ -4899,6 +4916,10 @@ static int patch_stac927x(struct hda_codec *codec)
4899 */ 4916 */
4900 codec->bus->needs_damn_long_delay = 1; 4917 codec->bus->needs_damn_long_delay = 1;
4901 4918
4919 /* no jack detecion for ref-no-jd model */
4920 if (spec->board_config == STAC_D965_REF_NO_JD)
4921 spec->hp_detect = 0;
4922
4902 return 0; 4923 return 0;
4903} 4924}
4904 4925
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 1b3f1170271..0dfa0540ce2 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -382,23 +382,25 @@ static irqreturn_t snd_vt1724_interrupt(int irq, void *dev_id)
382 unsigned char status_mask = 382 unsigned char status_mask =
383 VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX | VT1724_IRQ_MTPCM; 383 VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX | VT1724_IRQ_MTPCM;
384 int handled = 0; 384 int handled = 0;
385#ifdef CONFIG_SND_DEBUG
386 int timeout = 0; 385 int timeout = 0;
387#endif
388 386
389 while (1) { 387 while (1) {
390 status = inb(ICEREG1724(ice, IRQSTAT)); 388 status = inb(ICEREG1724(ice, IRQSTAT));
391 status &= status_mask; 389 status &= status_mask;
392 if (status == 0) 390 if (status == 0)
393 break; 391 break;
394#ifdef CONFIG_SND_DEBUG
395 if (++timeout > 10) { 392 if (++timeout > 10) {
396 printk(KERN_ERR 393 status = inb(ICEREG1724(ice, IRQSTAT));
397 "ice1724: Too long irq loop, status = 0x%x\n", 394 printk(KERN_ERR "ice1724: Too long irq loop, "
398 status); 395 "status = 0x%x\n", status);
396 if (status & VT1724_IRQ_MPU_TX) {
397 printk(KERN_ERR "ice1724: Disabling MPU_TX\n");
398 outb(inb(ICEREG1724(ice, IRQMASK)) |
399 VT1724_IRQ_MPU_TX,
400 ICEREG1724(ice, IRQMASK));
401 }
399 break; 402 break;
400 } 403 }
401#endif
402 handled = 1; 404 handled = 1;
403 if (status & VT1724_IRQ_MPU_TX) { 405 if (status & VT1724_IRQ_MPU_TX) {
404 spin_lock(&ice->reg_lock); 406 spin_lock(&ice->reg_lock);
@@ -2351,7 +2353,6 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2351{ 2353{
2352 struct snd_ice1712 *ice; 2354 struct snd_ice1712 *ice;
2353 int err; 2355 int err;
2354 unsigned char mask;
2355 static struct snd_device_ops ops = { 2356 static struct snd_device_ops ops = {
2356 .dev_free = snd_vt1724_dev_free, 2357 .dev_free = snd_vt1724_dev_free,
2357 }; 2358 };
@@ -2412,9 +2413,9 @@ static int __devinit snd_vt1724_create(struct snd_card *card,
2412 return -EIO; 2413 return -EIO;
2413 } 2414 }
2414 2415
2415 /* unmask used interrupts */ 2416 /* MPU_RX and TX irq masks are cleared later dynamically */
2416 mask = VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX; 2417 outb(VT1724_IRQ_MPU_RX | VT1724_IRQ_MPU_TX , ICEREG1724(ice, IRQMASK));
2417 outb(mask, ICEREG1724(ice, IRQMASK)); 2418
2418 /* don't handle FIFO overrun/underruns (just yet), 2419 /* don't handle FIFO overrun/underruns (just yet),
2419 * since they cause machine lockups 2420 * since they cause machine lockups
2420 */ 2421 */
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index ae7601f353a..f23a73577c2 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -1010,7 +1010,7 @@ static int __devinit snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *
1010 .dev_free = snd_mixart_chip_dev_free, 1010 .dev_free = snd_mixart_chip_dev_free,
1011 }; 1011 };
1012 1012
1013 mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1013 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1014 if (! chip) { 1014 if (! chip) {
1015 snd_printk(KERN_ERR "cannot allocate chip\n"); 1015 snd_printk(KERN_ERR "cannot allocate chip\n");
1016 return -ENOMEM; 1016 return -ENOMEM;
@@ -1025,6 +1025,7 @@ static int __devinit snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *
1025 return err; 1025 return err;
1026 } 1026 }
1027 1027
1028 mgr->chip[idx] = chip;
1028 snd_card_set_dev(card, &mgr->pci->dev); 1029 snd_card_set_dev(card, &mgr->pci->dev);
1029 1030
1030 return 0; 1031 return 0;
@@ -1377,6 +1378,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
1377 sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); 1378 sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i);
1378 1379
1379 if ((err = snd_mixart_create(mgr, card, i)) < 0) { 1380 if ((err = snd_mixart_create(mgr, card, i)) < 0) {
1381 snd_card_free(card);
1380 snd_mixart_free(mgr); 1382 snd_mixart_free(mgr);
1381 return err; 1383 return err;
1382 } 1384 }
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c
index 8309d448772..471ee27e6c8 100644
--- a/sound/pci/pcxhr/pcxhr.c
+++ b/sound/pci/pcxhr/pcxhr.c
@@ -1024,7 +1024,7 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card,
1024 .dev_free = pcxhr_chip_dev_free, 1024 .dev_free = pcxhr_chip_dev_free,
1025 }; 1025 };
1026 1026
1027 mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL); 1027 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1028 if (! chip) { 1028 if (! chip) {
1029 snd_printk(KERN_ERR "cannot allocate chip\n"); 1029 snd_printk(KERN_ERR "cannot allocate chip\n");
1030 return -ENOMEM; 1030 return -ENOMEM;
@@ -1050,6 +1050,7 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card,
1050 return err; 1050 return err;
1051 } 1051 }
1052 1052
1053 mgr->chip[idx] = chip;
1053 snd_card_set_dev(card, &mgr->pci->dev); 1054 snd_card_set_dev(card, &mgr->pci->dev);
1054 1055
1055 return 0; 1056 return 0;
@@ -1310,6 +1311,7 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id
1310 sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); 1311 sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i);
1311 1312
1312 if ((err = pcxhr_create(mgr, card, i)) < 0) { 1313 if ((err = pcxhr_create(mgr, card, i)) < 0) {
1314 snd_card_free(card);
1313 pcxhr_free(mgr); 1315 pcxhr_free(mgr);
1314 return err; 1316 return err;
1315 } 1317 }
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
index 1d0eeb1f506..3caacfb9d8e 100644
--- a/sound/pci/riptide/riptide.c
+++ b/sound/pci/riptide/riptide.c
@@ -172,7 +172,7 @@ MODULE_PARM_DESC(opl3_port, "OPL3 port # for Riptide driver.");
172 172
173#define MAX_WRITE_RETRY 10 /* cmd interface limits */ 173#define MAX_WRITE_RETRY 10 /* cmd interface limits */
174#define MAX_ERROR_COUNT 10 174#define MAX_ERROR_COUNT 10
175#define CMDIF_TIMEOUT 500000 175#define CMDIF_TIMEOUT 50000
176#define RESET_TRIES 5 176#define RESET_TRIES 5
177 177
178#define READ_PORT_ULONG(p) inl((unsigned long)&(p)) 178#define READ_PORT_ULONG(p) inl((unsigned long)&(p))