diff options
Diffstat (limited to 'sound/pci')
55 files changed, 3865 insertions, 1583 deletions
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig index caebf296b62b..6e3a1848447c 100644 --- a/sound/pci/Kconfig +++ b/sound/pci/Kconfig | |||
@@ -208,7 +208,8 @@ config SND_OXYGEN | |||
208 | * AuzenTech X-Meridian | 208 | * AuzenTech X-Meridian |
209 | * Bgears b-Enspirer | 209 | * Bgears b-Enspirer |
210 | * Club3D Theatron DTS | 210 | * Club3D Theatron DTS |
211 | * HT-Omega Claro | 211 | * HT-Omega Claro (plus) |
212 | * HT-Omega Claro halo (XT) | ||
212 | * Razer Barracuda AC-1 | 213 | * Razer Barracuda AC-1 |
213 | * Sondigo Inferno | 214 | * Sondigo Inferno |
214 | 215 | ||
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 6704acbca8c0..e2b843b4f9d0 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 }, |
@@ -1927,9 +1927,9 @@ static int snd_ac97_dev_register(struct snd_device *device) | |||
1927 | ac97->dev.bus = &ac97_bus_type; | 1927 | ac97->dev.bus = &ac97_bus_type; |
1928 | ac97->dev.parent = ac97->bus->card->dev; | 1928 | ac97->dev.parent = ac97->bus->card->dev; |
1929 | ac97->dev.release = ac97_device_release; | 1929 | ac97->dev.release = ac97_device_release; |
1930 | snprintf(ac97->dev.bus_id, BUS_ID_SIZE, "%d-%d:%s", | 1930 | dev_set_name(&ac97->dev, "%d-%d:%s", |
1931 | ac97->bus->card->number, ac97->num, | 1931 | ac97->bus->card->number, ac97->num, |
1932 | snd_ac97_get_short_name(ac97)); | 1932 | snd_ac97_get_short_name(ac97)); |
1933 | if ((err = device_register(&ac97->dev)) < 0) { | 1933 | if ((err = device_register(&ac97->dev)) < 0) { |
1934 | snd_printk(KERN_ERR "Can't register ac97 bus\n"); | 1934 | snd_printk(KERN_ERR "Can't register ac97 bus\n"); |
1935 | ac97->dev.bus = NULL; | 1935 | ac97->dev.bus = NULL; |
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index 6ce3cbe98a6a..81bc93e5f1e3 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c | |||
@@ -476,7 +476,7 @@ static int patch_yamaha_ymf753(struct snd_ac97 * ac97) | |||
476 | } | 476 | } |
477 | 477 | ||
478 | /* | 478 | /* |
479 | * May 2, 2003 Liam Girdwood <liam.girdwood@wolfsonmicro.com> | 479 | * May 2, 2003 Liam Girdwood <lrg@slimlogic.co.uk> |
480 | * removed broken wolfson00 patch. | 480 | * removed broken wolfson00 patch. |
481 | * added support for WM9705,WM9708,WM9709,WM9710,WM9711,WM9712 and WM9717. | 481 | * added support for WM9705,WM9708,WM9709,WM9710,WM9711,WM9712 and WM9717. |
482 | */ | 482 | */ |
@@ -2054,8 +2054,9 @@ static const struct snd_kcontrol_new snd_ac97_ad1888_controls[] = { | |||
2054 | .get = snd_ac97_ad1888_lohpsel_get, | 2054 | .get = snd_ac97_ad1888_lohpsel_get, |
2055 | .put = snd_ac97_ad1888_lohpsel_put | 2055 | .put = snd_ac97_ad1888_lohpsel_put |
2056 | }, | 2056 | }, |
2057 | AC97_SINGLE("V_REFOUT Enable", AC97_AD_MISC, 2, 1, 1), | 2057 | AC97_SINGLE("V_REFOUT Enable", AC97_AD_MISC, AC97_AD_VREFD_SHIFT, 1, 1), |
2058 | AC97_SINGLE("High Pass Filter Enable", AC97_AD_TEST2, 12, 1, 1), | 2058 | AC97_SINGLE("High Pass Filter Enable", AC97_AD_TEST2, |
2059 | AC97_AD_HPFD_SHIFT, 1, 1), | ||
2059 | AC97_SINGLE("Spread Front to Surround and Center/LFE", AC97_AD_MISC, 7, 1, 0), | 2060 | AC97_SINGLE("Spread Front to Surround and Center/LFE", AC97_AD_MISC, 7, 1, 0), |
2060 | { | 2061 | { |
2061 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 2062 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
@@ -2832,6 +2833,8 @@ static int patch_alc655(struct snd_ac97 * ac97) | |||
2832 | val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */ | 2833 | val &= ~(1 << 1); /* Pin 47 is EAPD (for internal speaker) */ |
2833 | else | 2834 | else |
2834 | val |= (1 << 1); /* Pin 47 is spdif input pin */ | 2835 | val |= (1 << 1); /* Pin 47 is spdif input pin */ |
2836 | /* this seems missing on some hardwares */ | ||
2837 | ac97->ext_id |= AC97_EI_SPDIF; | ||
2835 | } | 2838 | } |
2836 | val &= ~(1 << 12); /* vref enable */ | 2839 | val &= ~(1 << 12); /* vref enable */ |
2837 | snd_ac97_write_cache(ac97, 0x7a, val); | 2840 | snd_ac97_write_cache(ac97, 0x7a, val); |
diff --git a/sound/pci/ad1889.c b/sound/pci/ad1889.c index 92f3a976ef2e..a7f38e63303f 100644 --- a/sound/pci/ad1889.c +++ b/sound/pci/ad1889.c | |||
@@ -932,7 +932,7 @@ snd_ad1889_create(struct snd_card *card, | |||
932 | goto free_and_ret; | 932 | goto free_and_ret; |
933 | 933 | ||
934 | chip->bar = pci_resource_start(pci, 0); | 934 | chip->bar = pci_resource_start(pci, 0); |
935 | chip->iobase = ioremap_nocache(chip->bar, pci_resource_len(pci, 0)); | 935 | chip->iobase = pci_ioremap_bar(pci, 0); |
936 | if (chip->iobase == NULL) { | 936 | if (chip->iobase == NULL) { |
937 | printk(KERN_ERR PFX "unable to reserve region.\n"); | 937 | printk(KERN_ERR PFX "unable to reserve region.\n"); |
938 | err = -EBUSY; | 938 | err = -EBUSY; |
diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index 085a52b8c807..226fe8237d31 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c | |||
@@ -1609,7 +1609,7 @@ static int __devinit snd_atiixp_create(struct snd_card *card, | |||
1609 | return err; | 1609 | return err; |
1610 | } | 1610 | } |
1611 | chip->addr = pci_resource_start(pci, 0); | 1611 | chip->addr = pci_resource_start(pci, 0); |
1612 | chip->remap_addr = ioremap_nocache(chip->addr, pci_resource_len(pci, 0)); | 1612 | chip->remap_addr = pci_ioremap_bar(pci, 0); |
1613 | if (chip->remap_addr == NULL) { | 1613 | if (chip->remap_addr == NULL) { |
1614 | snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); | 1614 | snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); |
1615 | snd_atiixp_free(chip); | 1615 | snd_atiixp_free(chip); |
diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index 2f106306c7fe..0e6e5cc1c501 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c | |||
@@ -1252,7 +1252,7 @@ static int __devinit snd_atiixp_create(struct snd_card *card, | |||
1252 | return err; | 1252 | return err; |
1253 | } | 1253 | } |
1254 | chip->addr = pci_resource_start(pci, 0); | 1254 | chip->addr = pci_resource_start(pci, 0); |
1255 | chip->remap_addr = ioremap_nocache(chip->addr, pci_resource_len(pci, 0)); | 1255 | chip->remap_addr = pci_ioremap_bar(pci, 0); |
1256 | if (chip->remap_addr == NULL) { | 1256 | if (chip->remap_addr == NULL) { |
1257 | snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); | 1257 | snd_printk(KERN_ERR "AC'97 space ioremap problem\n"); |
1258 | snd_atiixp_free(chip); | 1258 | snd_atiixp_free(chip); |
diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c index 68368e490074..a36d4d1fd419 100644 --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c | |||
@@ -180,8 +180,7 @@ snd_vortex_create(struct snd_card *card, struct pci_dev *pci, vortex_t ** rchip) | |||
180 | if ((err = pci_request_regions(pci, CARD_NAME_SHORT)) != 0) | 180 | if ((err = pci_request_regions(pci, CARD_NAME_SHORT)) != 0) |
181 | goto regions_out; | 181 | goto regions_out; |
182 | 182 | ||
183 | chip->mmio = ioremap_nocache(pci_resource_start(pci, 0), | 183 | chip->mmio = pci_ioremap_bar(pci, 0); |
184 | pci_resource_len(pci, 0)); | ||
185 | if (!chip->mmio) { | 184 | if (!chip->mmio) { |
186 | printk(KERN_ERR "MMIO area remap failed.\n"); | 185 | printk(KERN_ERR "MMIO area remap failed.\n"); |
187 | err = -ENOMEM; | 186 | err = -ENOMEM; |
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 3aa8d973540a..1aa1c0402540 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c | |||
@@ -749,8 +749,7 @@ static int __devinit snd_bt87x_create(struct snd_card *card, | |||
749 | pci_disable_device(pci); | 749 | pci_disable_device(pci); |
750 | return err; | 750 | return err; |
751 | } | 751 | } |
752 | chip->mmio = ioremap_nocache(pci_resource_start(pci, 0), | 752 | chip->mmio = pci_ioremap_bar(pci, 0); |
753 | pci_resource_len(pci, 0)); | ||
754 | if (!chip->mmio) { | 753 | if (!chip->mmio) { |
755 | snd_printk(KERN_ERR "cannot remap io memory\n"); | 754 | snd_printk(KERN_ERR "cannot remap io memory\n"); |
756 | err = -ENOMEM; | 755 | err = -ENOMEM; |
diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h index 74175fc80c7f..14b8d9a91aae 100644 --- a/sound/pci/ca0106/ca0106.h +++ b/sound/pci/ca0106/ca0106.h | |||
@@ -664,10 +664,14 @@ struct snd_ca0106_pcm { | |||
664 | struct snd_ca0106_details { | 664 | struct 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 | ||
708 | int snd_ca0106_mixer(struct snd_ca0106 *emu); | 718 | int 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 | ||
722 | int snd_ca0106_spi_write(struct snd_ca0106 * emu, | 732 | int snd_ca0106_spi_write(struct snd_ca0106 * emu, |
723 | unsigned int data); | 733 | unsigned int data); |
734 | |||
735 | #ifdef CONFIG_PM | ||
736 | void snd_ca0106_mixer_suspend(struct snd_ca0106 *chip); | ||
737 | void 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 a7d89662acf6..0e62205d4081 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 | ||
488 | static 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 */ |
483 | static int snd_ca0106_pcm_open_playback_channel(struct snd_pcm_substream *substream, | 498 | static 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 | ||
@@ -759,7 +779,6 @@ static int snd_ca0106_pcm_prepare_playback(struct snd_pcm_substream *substream) | |||
759 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | | 779 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | |
760 | SPCS_GENERATIONSTATUS | 0x00001200 | | 780 | SPCS_GENERATIONSTATUS | 0x00001200 | |
761 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT ); | 781 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT ); |
762 | } | ||
763 | #endif | 782 | #endif |
764 | 783 | ||
765 | return 0; | 784 | return 0; |
@@ -848,15 +867,18 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream, | |||
848 | struct snd_pcm_substream *s; | 867 | struct snd_pcm_substream *s; |
849 | u32 basic = 0; | 868 | u32 basic = 0; |
850 | u32 extended = 0; | 869 | u32 extended = 0; |
851 | int running=0; | 870 | u32 bits; |
871 | int running = 0; | ||
852 | 872 | ||
853 | switch (cmd) { | 873 | switch (cmd) { |
854 | case SNDRV_PCM_TRIGGER_START: | 874 | case SNDRV_PCM_TRIGGER_START: |
855 | running=1; | 875 | case SNDRV_PCM_TRIGGER_RESUME: |
876 | running = 1; | ||
856 | break; | 877 | break; |
857 | case SNDRV_PCM_TRIGGER_STOP: | 878 | case SNDRV_PCM_TRIGGER_STOP: |
879 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
858 | default: | 880 | default: |
859 | running=0; | 881 | running = 0; |
860 | break; | 882 | break; |
861 | } | 883 | } |
862 | snd_pcm_group_for_each_entry(s, substream) { | 884 | snd_pcm_group_for_each_entry(s, substream) { |
@@ -866,22 +888,32 @@ static int snd_ca0106_pcm_trigger_playback(struct snd_pcm_substream *substream, | |||
866 | runtime = s->runtime; | 888 | runtime = s->runtime; |
867 | epcm = runtime->private_data; | 889 | epcm = runtime->private_data; |
868 | channel = epcm->channel_id; | 890 | channel = epcm->channel_id; |
869 | //snd_printk("channel=%d\n",channel); | 891 | /* snd_printk("channel=%d\n",channel); */ |
870 | epcm->running = running; | 892 | epcm->running = running; |
871 | basic |= (0x1<<channel); | 893 | basic |= (0x1 << channel); |
872 | extended |= (0x10<<channel); | 894 | extended |= (0x10 << channel); |
873 | snd_pcm_trigger_done(s, substream); | 895 | snd_pcm_trigger_done(s, substream); |
874 | } | 896 | } |
875 | //snd_printk("basic=0x%x, extended=0x%x\n",basic, extended); | 897 | /* snd_printk("basic=0x%x, extended=0x%x\n",basic, extended); */ |
876 | 898 | ||
877 | switch (cmd) { | 899 | switch (cmd) { |
878 | case SNDRV_PCM_TRIGGER_START: | 900 | case SNDRV_PCM_TRIGGER_START: |
879 | 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: |
880 | 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); | ||
881 | break; | 908 | break; |
882 | case SNDRV_PCM_TRIGGER_STOP: | 909 | case SNDRV_PCM_TRIGGER_STOP: |
883 | snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0) & ~(basic)); | 910 | case SNDRV_PCM_TRIGGER_SUSPEND: |
884 | 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); | ||
885 | break; | 917 | break; |
886 | default: | 918 | default: |
887 | result = -EINVAL; | 919 | result = -EINVAL; |
@@ -1104,21 +1136,13 @@ static int snd_ca0106_ac97(struct snd_ca0106 *chip) | |||
1104 | return snd_ac97_mixer(pbus, &ac97, &chip->ac97); | 1136 | return snd_ac97_mixer(pbus, &ac97, &chip->ac97); |
1105 | } | 1137 | } |
1106 | 1138 | ||
1139 | static void ca0106_stop_chip(struct snd_ca0106 *chip); | ||
1140 | |||
1107 | static int snd_ca0106_free(struct snd_ca0106 *chip) | 1141 | static int snd_ca0106_free(struct snd_ca0106 *chip) |
1108 | { | 1142 | { |
1109 | if (chip->res_port != NULL) { /* avoid access to already used hardware */ | 1143 | if (chip->res_port != NULL) { |
1110 | // disable interrupts | 1144 | /* avoid access to already used hardware */ |
1111 | snd_ca0106_ptr_write(chip, BASIC_INTERRUPT, 0, 0); | 1145 | ca0106_stop_chip(chip); |
1112 | outl(0, chip->port + INTE); | ||
1113 | snd_ca0106_ptr_write(chip, EXTENDED_INT_MASK, 0, 0); | ||
1114 | udelay(1000); | ||
1115 | // disable audio | ||
1116 | //outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); | ||
1117 | outl(0, chip->port + HCFG); | ||
1118 | /* FIXME: We need to stop and DMA transfers here. | ||
1119 | * But as I am not sure how yet, we cannot from the dma pages. | ||
1120 | * So we can fix: snd-malloc: Memory leak? pages not freed = 8 | ||
1121 | */ | ||
1122 | } | 1146 | } |
1123 | if (chip->irq >= 0) | 1147 | if (chip->irq >= 0) |
1124 | free_irq(chip->irq, chip); | 1148 | free_irq(chip->irq, chip); |
@@ -1204,15 +1228,14 @@ static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id) | |||
1204 | return IRQ_HANDLED; | 1228 | return IRQ_HANDLED; |
1205 | } | 1229 | } |
1206 | 1230 | ||
1207 | static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct snd_pcm **rpcm) | 1231 | static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device) |
1208 | { | 1232 | { |
1209 | struct snd_pcm *pcm; | 1233 | struct snd_pcm *pcm; |
1210 | struct snd_pcm_substream *substream; | 1234 | struct snd_pcm_substream *substream; |
1211 | int err; | 1235 | int err; |
1212 | 1236 | ||
1213 | if (rpcm) | 1237 | err = snd_pcm_new(emu->card, "ca0106", device, 1, 1, &pcm); |
1214 | *rpcm = NULL; | 1238 | if (err < 0) |
1215 | if ((err = snd_pcm_new(emu->card, "ca0106", device, 1, 1, &pcm)) < 0) | ||
1216 | return err; | 1239 | return err; |
1217 | 1240 | ||
1218 | pcm->private_data = emu; | 1241 | pcm->private_data = emu; |
@@ -1239,7 +1262,6 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct s | |||
1239 | pcm->info_flags = 0; | 1262 | pcm->info_flags = 0; |
1240 | pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; | 1263 | pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; |
1241 | strcpy(pcm->name, "CA0106"); | 1264 | strcpy(pcm->name, "CA0106"); |
1242 | emu->pcm = pcm; | ||
1243 | 1265 | ||
1244 | for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; | 1266 | for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; |
1245 | substream; | 1267 | substream; |
@@ -1261,8 +1283,7 @@ static int __devinit snd_ca0106_pcm(struct snd_ca0106 *emu, int device, struct s | |||
1261 | return err; | 1283 | return err; |
1262 | } | 1284 | } |
1263 | 1285 | ||
1264 | if (rpcm) | 1286 | emu->pcm[device] = pcm; |
1265 | *rpcm = pcm; | ||
1266 | 1287 | ||
1267 | return 0; | 1288 | return 0; |
1268 | } | 1289 | } |
@@ -1302,89 +1323,10 @@ static unsigned int i2c_adc_init[][2] = { | |||
1302 | { 0x15, ADC_MUX_LINEIN }, /* ADC Mixer control */ | 1323 | { 0x15, ADC_MUX_LINEIN }, /* ADC Mixer control */ |
1303 | }; | 1324 | }; |
1304 | 1325 | ||
1305 | static int __devinit snd_ca0106_create(int dev, struct snd_card *card, | 1326 | static void ca0106_init_chip(struct snd_ca0106 *chip, int resume) |
1306 | struct pci_dev *pci, | ||
1307 | struct snd_ca0106 **rchip) | ||
1308 | { | 1327 | { |
1309 | struct snd_ca0106 *chip; | ||
1310 | struct snd_ca0106_details *c; | ||
1311 | int err; | ||
1312 | int ch; | 1328 | int ch; |
1313 | static struct snd_device_ops ops = { | 1329 | unsigned int def_bits; |
1314 | .dev_free = snd_ca0106_dev_free, | ||
1315 | }; | ||
1316 | |||
1317 | *rchip = NULL; | ||
1318 | |||
1319 | if ((err = pci_enable_device(pci)) < 0) | ||
1320 | return err; | ||
1321 | if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0 || | ||
1322 | pci_set_consistent_dma_mask(pci, DMA_32BIT_MASK) < 0) { | ||
1323 | printk(KERN_ERR "error to set 32bit mask DMA\n"); | ||
1324 | pci_disable_device(pci); | ||
1325 | return -ENXIO; | ||
1326 | } | ||
1327 | |||
1328 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | ||
1329 | if (chip == NULL) { | ||
1330 | pci_disable_device(pci); | ||
1331 | return -ENOMEM; | ||
1332 | } | ||
1333 | |||
1334 | chip->card = card; | ||
1335 | chip->pci = pci; | ||
1336 | chip->irq = -1; | ||
1337 | |||
1338 | spin_lock_init(&chip->emu_lock); | ||
1339 | |||
1340 | chip->port = pci_resource_start(pci, 0); | ||
1341 | if ((chip->res_port = request_region(chip->port, 0x20, | ||
1342 | "snd_ca0106")) == NULL) { | ||
1343 | snd_ca0106_free(chip); | ||
1344 | printk(KERN_ERR "cannot allocate the port\n"); | ||
1345 | return -EBUSY; | ||
1346 | } | ||
1347 | |||
1348 | if (request_irq(pci->irq, snd_ca0106_interrupt, | ||
1349 | IRQF_SHARED, "snd_ca0106", chip)) { | ||
1350 | snd_ca0106_free(chip); | ||
1351 | printk(KERN_ERR "cannot grab irq\n"); | ||
1352 | return -EBUSY; | ||
1353 | } | ||
1354 | chip->irq = pci->irq; | ||
1355 | |||
1356 | /* This stores the periods table. */ | ||
1357 | if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1024, &chip->buffer) < 0) { | ||
1358 | snd_ca0106_free(chip); | ||
1359 | return -ENOMEM; | ||
1360 | } | ||
1361 | |||
1362 | pci_set_master(pci); | ||
1363 | /* read serial */ | ||
1364 | pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); | ||
1365 | pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); | ||
1366 | #if 1 | ||
1367 | printk(KERN_INFO "snd-ca0106: Model %04x Rev %08x Serial %08x\n", chip->model, | ||
1368 | pci->revision, chip->serial); | ||
1369 | #endif | ||
1370 | strcpy(card->driver, "CA0106"); | ||
1371 | strcpy(card->shortname, "CA0106"); | ||
1372 | |||
1373 | for (c = ca0106_chip_details; c->serial; c++) { | ||
1374 | if (subsystem[dev]) { | ||
1375 | if (c->serial == subsystem[dev]) | ||
1376 | break; | ||
1377 | } else if (c->serial == chip->serial) | ||
1378 | break; | ||
1379 | } | ||
1380 | chip->details = c; | ||
1381 | if (subsystem[dev]) { | ||
1382 | printk(KERN_INFO "snd-ca0106: Sound card name=%s, subsystem=0x%x. Forced to subsystem=0x%x\n", | ||
1383 | c->name, chip->serial, subsystem[dev]); | ||
1384 | } | ||
1385 | |||
1386 | sprintf(card->longname, "%s at 0x%lx irq %i", | ||
1387 | c->name, chip->port, chip->irq); | ||
1388 | 1330 | ||
1389 | outl(0, chip->port + INTE); | 1331 | outl(0, chip->port + INTE); |
1390 | 1332 | ||
@@ -1402,31 +1344,22 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card, | |||
1402 | * AN = 0 (Audio data) | 1344 | * AN = 0 (Audio data) |
1403 | * P = 0 (Consumer) | 1345 | * P = 0 (Consumer) |
1404 | */ | 1346 | */ |
1405 | snd_ca0106_ptr_write(chip, SPCS0, 0, | 1347 | def_bits = |
1406 | chip->spdif_bits[0] = | 1348 | SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | |
1407 | SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | | 1349 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | |
1408 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | | 1350 | SPCS_GENERATIONSTATUS | 0x00001200 | |
1409 | SPCS_GENERATIONSTATUS | 0x00001200 | | 1351 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT; |
1410 | 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 | } | ||
1411 | /* Only SPCS1 has been tested */ | 1358 | /* Only SPCS1 has been tested */ |
1412 | snd_ca0106_ptr_write(chip, SPCS1, 0, | 1359 | snd_ca0106_ptr_write(chip, SPCS1, 0, chip->spdif_str_bits[1]); |
1413 | chip->spdif_bits[1] = | 1360 | snd_ca0106_ptr_write(chip, SPCS0, 0, chip->spdif_str_bits[0]); |
1414 | SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | | 1361 | snd_ca0106_ptr_write(chip, SPCS2, 0, chip->spdif_str_bits[2]); |
1415 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | | 1362 | snd_ca0106_ptr_write(chip, SPCS3, 0, chip->spdif_str_bits[3]); |
1416 | SPCS_GENERATIONSTATUS | 0x00001200 | | ||
1417 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); | ||
1418 | snd_ca0106_ptr_write(chip, SPCS2, 0, | ||
1419 | chip->spdif_bits[2] = | ||
1420 | SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | | ||
1421 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | | ||
1422 | SPCS_GENERATIONSTATUS | 0x00001200 | | ||
1423 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); | ||
1424 | snd_ca0106_ptr_write(chip, SPCS3, 0, | ||
1425 | chip->spdif_bits[3] = | ||
1426 | SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | | ||
1427 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | | ||
1428 | SPCS_GENERATIONSTATUS | 0x00001200 | | ||
1429 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); | ||
1430 | 1363 | ||
1431 | snd_ca0106_ptr_write(chip, PLAYBACK_MUTE, 0, 0x00fc0000); | 1364 | snd_ca0106_ptr_write(chip, PLAYBACK_MUTE, 0, 0x00fc0000); |
1432 | snd_ca0106_ptr_write(chip, CAPTURE_MUTE, 0, 0x00fc0000); | 1365 | snd_ca0106_ptr_write(chip, CAPTURE_MUTE, 0, 0x00fc0000); |
@@ -1434,92 +1367,124 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card, | |||
1434 | /* Write 0x8000 to AC97_REC_GAIN to mute it. */ | 1367 | /* Write 0x8000 to AC97_REC_GAIN to mute it. */ |
1435 | outb(AC97_REC_GAIN, chip->port + AC97ADDRESS); | 1368 | outb(AC97_REC_GAIN, chip->port + AC97ADDRESS); |
1436 | outw(0x8000, chip->port + AC97DATA); | 1369 | outw(0x8000, chip->port + AC97DATA); |
1437 | #if 0 | 1370 | #if 0 /* FIXME: what are these? */ |
1438 | snd_ca0106_ptr_write(chip, SPCS0, 0, 0x2108006); | 1371 | snd_ca0106_ptr_write(chip, SPCS0, 0, 0x2108006); |
1439 | snd_ca0106_ptr_write(chip, 0x42, 0, 0x2108006); | 1372 | snd_ca0106_ptr_write(chip, 0x42, 0, 0x2108006); |
1440 | snd_ca0106_ptr_write(chip, 0x43, 0, 0x2108006); | 1373 | snd_ca0106_ptr_write(chip, 0x43, 0, 0x2108006); |
1441 | snd_ca0106_ptr_write(chip, 0x44, 0, 0x2108006); | 1374 | snd_ca0106_ptr_write(chip, 0x44, 0, 0x2108006); |
1442 | #endif | 1375 | #endif |
1443 | 1376 | ||
1444 | //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 | |||
1445 | /* Analog or Digital output */ | 1380 | /* Analog or Digital output */ |
1446 | snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf); | 1381 | snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf); |
1447 | 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 | |||
1448 | chip->spdif_enable = 0; /* Set digital SPDIF output off */ | 1387 | chip->spdif_enable = 0; /* Set digital SPDIF output off */ |
1449 | //snd_ca0106_ptr_write(chip, 0x45, 0, 0); /* Analogue out */ | 1388 | /*snd_ca0106_ptr_write(chip, 0x45, 0, 0);*/ /* Analogue out */ |
1450 | //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); | ||
1451 | 1401 | ||
1452 | snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 0, 0x40c81000); /* goes to 0x40c80000 when doing SPDIF IN/OUT */ | ||
1453 | snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 1, 0xffffffff); /* (Mute) CAPTURE feedback into PLAYBACK volume. Only lower 16 bits matter. */ | ||
1454 | snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 2, 0x30300000); /* SPDIF IN Volume */ | ||
1455 | snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 3, 0x00700000); /* SPDIF IN Volume, 0x70 = (vol & 0x3f) | 0x40 */ | ||
1456 | snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING1, 0, 0x32765410); | 1402 | snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING1, 0, 0x32765410); |
1457 | snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING2, 0, 0x76767676); | 1403 | snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING2, 0, 0x76767676); |
1458 | snd_ca0106_ptr_write(chip, CAPTURE_ROUTING1, 0, 0x32765410); | 1404 | snd_ca0106_ptr_write(chip, CAPTURE_ROUTING1, 0, 0x32765410); |
1459 | snd_ca0106_ptr_write(chip, CAPTURE_ROUTING2, 0, 0x76767676); | 1405 | snd_ca0106_ptr_write(chip, CAPTURE_ROUTING2, 0, 0x76767676); |
1460 | for(ch = 0; ch < 4; ch++) { | 1406 | |
1461 | 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); | ||
1462 | snd_ca0106_ptr_write(chip, CAPTURE_VOLUME2, ch, 0x30303030); | 1410 | snd_ca0106_ptr_write(chip, CAPTURE_VOLUME2, ch, 0x30303030); |
1463 | //snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0x40404040); /* Mute */ | 1411 | #if 0 /* Mute */ |
1464 | //snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0x40404040); /* Mute */ | 1412 | snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0x40404040); |
1465 | snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0xffffffff); /* Mute */ | 1413 | snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0x40404040); |
1466 | 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 | ||
1467 | } | 1417 | } |
1468 | if (chip->details->i2c_adc == 1) { | 1418 | if (chip->details->i2c_adc == 1) { |
1469 | /* Select MIC, Line in, TAD in, AUX in */ | 1419 | /* Select MIC, Line in, TAD in, AUX in */ |
1470 | snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); | 1420 | snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); |
1471 | /* Default to CAPTURE_SOURCE to i2s in */ | 1421 | /* Default to CAPTURE_SOURCE to i2s in */ |
1472 | chip->capture_source = 3; | 1422 | if (!resume) |
1423 | chip->capture_source = 3; | ||
1473 | } else if (chip->details->ac97 == 1) { | 1424 | } else if (chip->details->ac97 == 1) { |
1474 | /* Default to AC97 in */ | 1425 | /* Default to AC97 in */ |
1475 | snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x444400e4); | 1426 | snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x444400e4); |
1476 | /* Default to CAPTURE_SOURCE to AC97 in */ | 1427 | /* Default to CAPTURE_SOURCE to AC97 in */ |
1477 | chip->capture_source = 4; | 1428 | if (!resume) |
1429 | chip->capture_source = 4; | ||
1478 | } else { | 1430 | } else { |
1479 | /* Select MIC, Line in, TAD in, AUX in */ | 1431 | /* Select MIC, Line in, TAD in, AUX in */ |
1480 | snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); | 1432 | snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); |
1481 | /* Default to Set CAPTURE_SOURCE to i2s in */ | 1433 | /* Default to Set CAPTURE_SOURCE to i2s in */ |
1482 | chip->capture_source = 3; | 1434 | if (!resume) |
1435 | chip->capture_source = 3; | ||
1483 | } | 1436 | } |
1484 | 1437 | ||
1485 | if (chip->details->gpio_type == 2) { /* The SB0438 use GPIO differently. */ | 1438 | if (chip->details->gpio_type == 2) { |
1486 | /* 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 | */ | ||
1487 | outl(0x0, chip->port+GPIO); | 1443 | outl(0x0, chip->port+GPIO); |
1488 | //outl(0x00f0e000, chip->port+GPIO); /* Analog */ | 1444 | /* outl(0x00f0e000, chip->port+GPIO); */ /* Analog */ |
1489 | outl(0x005f5301, chip->port+GPIO); /* Analog */ | 1445 | outl(0x005f5301, chip->port+GPIO); /* Analog */ |
1490 | } else if (chip->details->gpio_type == 1) { /* The SB0410 and SB0413 use GPIO differently. */ | 1446 | } else if (chip->details->gpio_type == 1) { |
1491 | /* 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 | */ | ||
1492 | outl(0x0, chip->port+GPIO); | 1451 | outl(0x0, chip->port+GPIO); |
1493 | //outl(0x00f0e000, chip->port+GPIO); /* Analog */ | 1452 | /* outl(0x00f0e000, chip->port+GPIO); */ /* Analog */ |
1494 | outl(0x005f5301, chip->port+GPIO); /* Analog */ | 1453 | outl(0x005f5301, chip->port+GPIO); /* Analog */ |
1495 | } else { | 1454 | } else { |
1496 | outl(0x0, chip->port+GPIO); | 1455 | outl(0x0, chip->port+GPIO); |
1497 | outl(0x005f03a3, chip->port+GPIO); /* Analog */ | 1456 | outl(0x005f03a3, chip->port+GPIO); /* Analog */ |
1498 | //outl(0x005f02a2, chip->port+GPIO); /* SPDIF */ | 1457 | /* outl(0x005f02a2, chip->port+GPIO); */ /* SPDIF */ |
1499 | } | 1458 | } |
1500 | snd_ca0106_intr_enable(chip, 0x105); /* Win2000 uses 0x1e0 */ | 1459 | snd_ca0106_intr_enable(chip, 0x105); /* Win2000 uses 0x1e0 */ |
1501 | 1460 | ||
1502 | //outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG); | 1461 | /* outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG); */ |
1503 | //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. */ |
1504 | //outl(0x00000009, chip->port+HCFG); | 1463 | /* outl(0x00001409, chip->port+HCFG); */ |
1505 | 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); | ||
1506 | 1467 | ||
1507 | 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. */ | ||
1508 | int size, n; | 1470 | int size, n; |
1509 | 1471 | ||
1510 | size = ARRAY_SIZE(i2c_adc_init); | 1472 | size = ARRAY_SIZE(i2c_adc_init); |
1511 | //snd_printk("I2C:array size=0x%x\n", size); | 1473 | /* snd_printk("I2C:array size=0x%x\n", size); */ |
1512 | for (n=0; n < size; n++) { | 1474 | for (n = 0; n < size; n++) |
1513 | 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], |
1514 | } | 1476 | i2c_adc_init[n][1]); |
1515 | for (n=0; n < 4; n++) { | 1477 | for (n = 0; n < 4; n++) { |
1516 | chip->i2c_capture_volume[n][0]= 0xcf; | 1478 | chip->i2c_capture_volume[n][0] = 0xcf; |
1517 | chip->i2c_capture_volume[n][1]= 0xcf; | 1479 | chip->i2c_capture_volume[n][1] = 0xcf; |
1518 | } | 1480 | } |
1519 | chip->i2c_capture_source=2; /* Line in */ | 1481 | chip->i2c_capture_source = 2; /* Line in */ |
1520 | //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); */ | ||
1521 | } | 1484 | } |
1522 | 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. */ | ||
1523 | int size, n; | 1488 | int size, n; |
1524 | 1489 | ||
1525 | size = ARRAY_SIZE(spi_dac_init); | 1490 | size = ARRAY_SIZE(spi_dac_init); |
@@ -1531,9 +1496,112 @@ static int __devinit snd_ca0106_create(int dev, struct snd_card *card, | |||
1531 | chip->spi_dac_reg[reg] = spi_dac_init[n]; | 1496 | chip->spi_dac_reg[reg] = spi_dac_init[n]; |
1532 | } | 1497 | } |
1533 | } | 1498 | } |
1499 | } | ||
1500 | |||
1501 | static void ca0106_stop_chip(struct snd_ca0106 *chip) | ||
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 | |||
1517 | static 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); | ||
1534 | 1600 | ||
1535 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, | 1601 | ca0106_init_chip(chip, 0); |
1536 | chip, &ops)) < 0) { | 1602 | |
1603 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); | ||
1604 | if (err < 0) { | ||
1537 | snd_ca0106_free(chip); | 1605 | snd_ca0106_free(chip); |
1538 | return err; | 1606 | return err; |
1539 | } | 1607 | } |
@@ -1630,7 +1698,7 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci, | |||
1630 | static int dev; | 1698 | static int dev; |
1631 | struct snd_card *card; | 1699 | struct snd_card *card; |
1632 | struct snd_ca0106 *chip; | 1700 | struct snd_ca0106 *chip; |
1633 | int err; | 1701 | int i, err; |
1634 | 1702 | ||
1635 | if (dev >= SNDRV_CARDS) | 1703 | if (dev >= SNDRV_CARDS) |
1636 | return -ENODEV; | 1704 | return -ENODEV; |
@@ -1643,44 +1711,31 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci, | |||
1643 | if (card == NULL) | 1711 | if (card == NULL) |
1644 | return -ENOMEM; | 1712 | return -ENOMEM; |
1645 | 1713 | ||
1646 | if ((err = snd_ca0106_create(dev, card, pci, &chip)) < 0) { | 1714 | err = snd_ca0106_create(dev, card, pci, &chip); |
1647 | snd_card_free(card); | 1715 | if (err < 0) |
1648 | return err; | 1716 | goto error; |
1649 | } | 1717 | card->private_data = chip; |
1650 | 1718 | ||
1651 | if ((err = snd_ca0106_pcm(chip, 0, NULL)) < 0) { | 1719 | for (i = 0; i < 4; i++) { |
1652 | snd_card_free(card); | 1720 | err = snd_ca0106_pcm(chip, i); |
1653 | return err; | 1721 | if (err < 0) |
1654 | } | 1722 | goto error; |
1655 | if ((err = snd_ca0106_pcm(chip, 1, NULL)) < 0) { | ||
1656 | snd_card_free(card); | ||
1657 | return err; | ||
1658 | } | ||
1659 | if ((err = snd_ca0106_pcm(chip, 2, NULL)) < 0) { | ||
1660 | snd_card_free(card); | ||
1661 | return err; | ||
1662 | } | ||
1663 | if ((err = snd_ca0106_pcm(chip, 3, NULL)) < 0) { | ||
1664 | snd_card_free(card); | ||
1665 | return err; | ||
1666 | } | ||
1667 | if (chip->details->ac97 == 1) { /* The SB0410 and SB0413 do not have an AC97 chip. */ | ||
1668 | if ((err = snd_ca0106_ac97(chip)) < 0) { | ||
1669 | snd_card_free(card); | ||
1670 | return err; | ||
1671 | } | ||
1672 | } | 1723 | } |
1673 | if ((err = snd_ca0106_mixer(chip)) < 0) { | 1724 | |
1674 | snd_card_free(card); | 1725 | if (chip->details->ac97 == 1) { |
1675 | 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; | ||
1676 | } | 1730 | } |
1731 | err = snd_ca0106_mixer(chip); | ||
1732 | if (err < 0) | ||
1733 | goto error; | ||
1677 | 1734 | ||
1678 | snd_printdd("ca0106: probe for MIDI channel A ..."); | 1735 | snd_printdd("ca0106: probe for MIDI channel A ..."); |
1679 | if ((err = snd_ca0106_midi(chip,CA0106_MIDI_CHAN_A)) < 0) { | 1736 | err = snd_ca0106_midi(chip, CA0106_MIDI_CHAN_A); |
1680 | snd_card_free(card); | 1737 | if (err < 0) |
1681 | snd_printdd(" failed, err=0x%x\n",err); | 1738 | goto error; |
1682 | return err; | ||
1683 | } | ||
1684 | snd_printdd(" done.\n"); | 1739 | snd_printdd(" done.\n"); |
1685 | 1740 | ||
1686 | #ifdef CONFIG_PROC_FS | 1741 | #ifdef CONFIG_PROC_FS |
@@ -1689,14 +1744,17 @@ static int __devinit snd_ca0106_probe(struct pci_dev *pci, | |||
1689 | 1744 | ||
1690 | snd_card_set_dev(card, &pci->dev); | 1745 | snd_card_set_dev(card, &pci->dev); |
1691 | 1746 | ||
1692 | if ((err = snd_card_register(card)) < 0) { | 1747 | err = snd_card_register(card); |
1693 | snd_card_free(card); | 1748 | if (err < 0) |
1694 | return err; | 1749 | goto error; |
1695 | } | ||
1696 | 1750 | ||
1697 | pci_set_drvdata(pci, card); | 1751 | pci_set_drvdata(pci, card); |
1698 | dev++; | 1752 | dev++; |
1699 | return 0; | 1753 | return 0; |
1754 | |||
1755 | error: | ||
1756 | snd_card_free(card); | ||
1757 | return err; | ||
1700 | } | 1758 | } |
1701 | 1759 | ||
1702 | static void __devexit snd_ca0106_remove(struct pci_dev *pci) | 1760 | static void __devexit snd_ca0106_remove(struct pci_dev *pci) |
@@ -1705,6 +1763,59 @@ static void __devexit snd_ca0106_remove(struct pci_dev *pci) | |||
1705 | pci_set_drvdata(pci, NULL); | 1763 | pci_set_drvdata(pci, NULL); |
1706 | } | 1764 | } |
1707 | 1765 | ||
1766 | #ifdef CONFIG_PM | ||
1767 | static 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 | |||
1788 | static 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 | |||
1708 | // PCI IDs | 1819 | // PCI IDs |
1709 | static struct pci_device_id snd_ca0106_ids[] = { | 1820 | static struct pci_device_id snd_ca0106_ids[] = { |
1710 | { 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 */ |
@@ -1718,6 +1829,10 @@ static struct pci_driver driver = { | |||
1718 | .id_table = snd_ca0106_ids, | 1829 | .id_table = snd_ca0106_ids, |
1719 | .probe = snd_ca0106_probe, | 1830 | .probe = snd_ca0106_probe, |
1720 | .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 | ||
1721 | }; | 1836 | }; |
1722 | 1837 | ||
1723 | // 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 3025ed1b6e1e..ad2888705d2a 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 | ||
78 | static 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 | |||
102 | static 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 | |||
111 | static 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 | |||
131 | static 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 | |||
149 | static 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 | */ | ||
78 | static const DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale1, -5175, 25, 1); | 156 | static const DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale1, -5175, 25, 1); |
79 | static const DECLARE_TLV_DB_SCALE(snd_ca0106_db_scale2, -10350, 50, 1); | 157 | static 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 | ||
325 | static int snd_ca0106_spdif_get(struct snd_kcontrol *kcontrol, | 356 | static 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 | |||
364 | static 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 | |||
375 | static 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 | ||
348 | static int snd_ca0106_spdif_put(struct snd_kcontrol *kcontrol, | 396 | static 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 | |||
404 | static 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 | |||
424 | static 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 | ||
368 | static int snd_ca0106_volume_info(struct snd_kcontrol *kcontrol, | 440 | static 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 | ||
857 | struct ca0106_vol_tbl { | ||
858 | unsigned int channel_id; | ||
859 | unsigned int reg; | ||
860 | }; | ||
861 | |||
862 | static 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 | |||
874 | void 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 | |||
885 | void 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/cs4281.c b/sound/pci/cs4281.c index ef9308f7c45b..192e7842e181 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c | |||
@@ -1382,8 +1382,8 @@ static int __devinit snd_cs4281_create(struct snd_card *card, | |||
1382 | chip->ba0_addr = pci_resource_start(pci, 0); | 1382 | chip->ba0_addr = pci_resource_start(pci, 0); |
1383 | chip->ba1_addr = pci_resource_start(pci, 1); | 1383 | chip->ba1_addr = pci_resource_start(pci, 1); |
1384 | 1384 | ||
1385 | chip->ba0 = ioremap_nocache(chip->ba0_addr, pci_resource_len(pci, 0)); | 1385 | chip->ba0 = pci_ioremap_bar(pci, 0); |
1386 | chip->ba1 = ioremap_nocache(chip->ba1_addr, pci_resource_len(pci, 1)); | 1386 | chip->ba1 = pci_ioremap_bar(pci, 1); |
1387 | if (!chip->ba0 || !chip->ba1) { | 1387 | if (!chip->ba0 || !chip->ba1) { |
1388 | snd_cs4281_free(chip); | 1388 | snd_cs4281_free(chip); |
1389 | return -ENOMEM; | 1389 | return -ENOMEM; |
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index fb6dc3980257..8ab07aa63652 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/cs5530.c b/sound/pci/cs5530.c index 7ff8b68e997e..6dea5b5cc774 100644 --- a/sound/pci/cs5530.c +++ b/sound/pci/cs5530.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * cs5530.c - Initialisation code for Cyrix/NatSemi VSA1 softaudio | 2 | * cs5530.c - Initialisation code for Cyrix/NatSemi VSA1 softaudio |
3 | * | 3 | * |
4 | * (C) Copyright 2007 Ash Willis <ashwillis@programmer.net> | 4 | * (C) Copyright 2007 Ash Willis <ashwillis@programmer.net> |
5 | * (C) Copyright 2003 Red Hat Inc <alan@redhat.com> | 5 | * (C) Copyright 2003 Red Hat Inc <alan@lxorguk.ukuu.org.uk> |
6 | * | 6 | * |
7 | * This driver was ported (shamelessly ripped ;) from oss/kahlua.c but I did | 7 | * This driver was ported (shamelessly ripped ;) from oss/kahlua.c but I did |
8 | * mess with it a bit. The chip seems to have to have trouble with full duplex | 8 | * mess with it a bit. The chip seems to have to have trouble with full duplex |
@@ -132,7 +132,7 @@ static int __devinit snd_cs5530_create(struct snd_card *card, | |||
132 | } | 132 | } |
133 | chip->pci_base = pci_resource_start(pci, 0); | 133 | chip->pci_base = pci_resource_start(pci, 0); |
134 | 134 | ||
135 | mem = ioremap_nocache(chip->pci_base, pci_resource_len(pci, 0)); | 135 | mem = pci_ioremap_bar(pci, 0); |
136 | if (mem == NULL) { | 136 | if (mem == NULL) { |
137 | kfree(chip); | 137 | kfree(chip); |
138 | pci_disable_device(pci); | 138 | pci_disable_device(pci); |
diff --git a/sound/pci/cs5535audio/Makefile b/sound/pci/cs5535audio/Makefile index bb3d57e6a3cb..fda7a94c992f 100644 --- a/sound/pci/cs5535audio/Makefile +++ b/sound/pci/cs5535audio/Makefile | |||
@@ -4,6 +4,9 @@ | |||
4 | 4 | ||
5 | snd-cs5535audio-y := cs5535audio.o cs5535audio_pcm.o | 5 | snd-cs5535audio-y := cs5535audio.o cs5535audio_pcm.o |
6 | snd-cs5535audio-$(CONFIG_PM) += cs5535audio_pm.o | 6 | snd-cs5535audio-$(CONFIG_PM) += cs5535audio_pm.o |
7 | ifdef CONFIG_MGEODE_LX | ||
8 | snd-cs5535audio-$(CONFIG_OLPC) += cs5535audio_olpc.o | ||
9 | endif | ||
7 | 10 | ||
8 | # Toplevel Module Dependency | 11 | # Toplevel Module Dependency |
9 | obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o | 12 | obj-$(CONFIG_SND_CS5535AUDIO) += snd-cs5535audio.o |
diff --git a/sound/pci/cs5535audio/cs5535audio.c b/sound/pci/cs5535audio/cs5535audio.c index 1d8b16052535..826e6dec2e97 100644 --- a/sound/pci/cs5535audio/cs5535audio.c +++ b/sound/pci/cs5535audio/cs5535audio.c | |||
@@ -159,10 +159,14 @@ static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au) | |||
159 | return err; | 159 | return err; |
160 | 160 | ||
161 | memset(&ac97, 0, sizeof(ac97)); | 161 | memset(&ac97, 0, sizeof(ac97)); |
162 | ac97.scaps = AC97_SCAP_AUDIO|AC97_SCAP_SKIP_MODEM; | 162 | ac97.scaps = AC97_SCAP_AUDIO | AC97_SCAP_SKIP_MODEM |
163 | | AC97_SCAP_POWER_SAVE; | ||
163 | ac97.private_data = cs5535au; | 164 | ac97.private_data = cs5535au; |
164 | ac97.pci = cs5535au->pci; | 165 | ac97.pci = cs5535au->pci; |
165 | 166 | ||
167 | /* set any OLPC-specific scaps */ | ||
168 | olpc_prequirks(card, &ac97); | ||
169 | |||
166 | if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) { | 170 | if ((err = snd_ac97_mixer(pbus, &ac97, &cs5535au->ac97)) < 0) { |
167 | snd_printk(KERN_ERR "mixer failed\n"); | 171 | snd_printk(KERN_ERR "mixer failed\n"); |
168 | return err; | 172 | return err; |
@@ -170,6 +174,12 @@ static int __devinit snd_cs5535audio_mixer(struct cs5535audio *cs5535au) | |||
170 | 174 | ||
171 | snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk); | 175 | snd_ac97_tune_hardware(cs5535au->ac97, ac97_quirks, ac97_quirk); |
172 | 176 | ||
177 | err = olpc_quirks(card, cs5535au->ac97); | ||
178 | if (err < 0) { | ||
179 | snd_printk(KERN_ERR "olpc quirks failed\n"); | ||
180 | return err; | ||
181 | } | ||
182 | |||
173 | return 0; | 183 | return 0; |
174 | } | 184 | } |
175 | 185 | ||
diff --git a/sound/pci/cs5535audio/cs5535audio.h b/sound/pci/cs5535audio/cs5535audio.h index 66bae7664193..7a298ac662e3 100644 --- a/sound/pci/cs5535audio/cs5535audio.h +++ b/sound/pci/cs5535audio/cs5535audio.h | |||
@@ -78,6 +78,7 @@ struct cs5535audio_dma { | |||
78 | unsigned int buf_addr, buf_bytes; | 78 | unsigned int buf_addr, buf_bytes; |
79 | unsigned int period_bytes, periods; | 79 | unsigned int period_bytes, periods; |
80 | u32 saved_prd; | 80 | u32 saved_prd; |
81 | int pcm_open_flag; | ||
81 | }; | 82 | }; |
82 | 83 | ||
83 | struct cs5535audio { | 84 | struct cs5535audio { |
@@ -93,8 +94,46 @@ struct cs5535audio { | |||
93 | struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS]; | 94 | struct cs5535audio_dma dmas[NUM_CS5535AUDIO_DMAS]; |
94 | }; | 95 | }; |
95 | 96 | ||
97 | #ifdef CONFIG_PM | ||
96 | int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state); | 98 | int snd_cs5535audio_suspend(struct pci_dev *pci, pm_message_t state); |
97 | int snd_cs5535audio_resume(struct pci_dev *pci); | 99 | int snd_cs5535audio_resume(struct pci_dev *pci); |
100 | #endif | ||
101 | |||
102 | #if defined(CONFIG_OLPC) && defined(CONFIG_MGEODE_LX) | ||
103 | void __devinit olpc_prequirks(struct snd_card *card, | ||
104 | struct snd_ac97_template *ac97); | ||
105 | int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97); | ||
106 | void olpc_analog_input(struct snd_ac97 *ac97, int on); | ||
107 | void olpc_mic_bias(struct snd_ac97 *ac97, int on); | ||
108 | |||
109 | static inline void olpc_capture_open(struct snd_ac97 *ac97) | ||
110 | { | ||
111 | /* default to Analog Input off */ | ||
112 | olpc_analog_input(ac97, 0); | ||
113 | /* enable MIC Bias for recording */ | ||
114 | olpc_mic_bias(ac97, 1); | ||
115 | } | ||
116 | |||
117 | static inline void olpc_capture_close(struct snd_ac97 *ac97) | ||
118 | { | ||
119 | /* disable Analog Input */ | ||
120 | olpc_analog_input(ac97, 0); | ||
121 | /* disable the MIC Bias (so the recording LED turns off) */ | ||
122 | olpc_mic_bias(ac97, 0); | ||
123 | } | ||
124 | #else | ||
125 | static inline void olpc_prequirks(struct snd_card *card, | ||
126 | struct snd_ac97_template *ac97) { } | ||
127 | static inline int olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) | ||
128 | { | ||
129 | return 0; | ||
130 | } | ||
131 | static inline void olpc_analog_input(struct snd_ac97 *ac97, int on) { } | ||
132 | static inline void olpc_mic_bias(struct snd_ac97 *ac97, int on) { } | ||
133 | static inline void olpc_capture_open(struct snd_ac97 *ac97) { } | ||
134 | static inline void olpc_capture_close(struct snd_ac97 *ac97) { } | ||
135 | #endif | ||
136 | |||
98 | int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535audio); | 137 | int __devinit snd_cs5535audio_pcm(struct cs5535audio *cs5535audio); |
99 | 138 | ||
100 | #endif /* __SOUND_CS5535AUDIO_H */ | 139 | #endif /* __SOUND_CS5535AUDIO_H */ |
diff --git a/sound/pci/cs5535audio/cs5535audio_olpc.c b/sound/pci/cs5535audio/cs5535audio_olpc.c new file mode 100644 index 000000000000..5c6814335cd7 --- /dev/null +++ b/sound/pci/cs5535audio/cs5535audio_olpc.c | |||
@@ -0,0 +1,179 @@ | |||
1 | /* | ||
2 | * OLPC XO-1 additional sound features | ||
3 | * | ||
4 | * Copyright © 2006 Jaya Kumar <jayakumar.lkml@gmail.com> | ||
5 | * Copyright © 2007-2008 Andres Salomon <dilinger@debian.org> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | #include <sound/core.h> | ||
13 | #include <sound/info.h> | ||
14 | #include <sound/control.h> | ||
15 | #include <sound/ac97_codec.h> | ||
16 | |||
17 | #include <asm/olpc.h> | ||
18 | #include "cs5535audio.h" | ||
19 | |||
20 | /* | ||
21 | * OLPC has an additional feature on top of the regular AD1888 codec features. | ||
22 | * It has an Analog Input mode that is switched into (after disabling the | ||
23 | * High Pass Filter) via GPIO. It is supported on B2 and later models. | ||
24 | */ | ||
25 | void olpc_analog_input(struct snd_ac97 *ac97, int on) | ||
26 | { | ||
27 | int err; | ||
28 | |||
29 | if (!machine_is_olpc()) | ||
30 | return; | ||
31 | |||
32 | /* update the High Pass Filter (via AC97_AD_TEST2) */ | ||
33 | err = snd_ac97_update_bits(ac97, AC97_AD_TEST2, | ||
34 | 1 << AC97_AD_HPFD_SHIFT, on << AC97_AD_HPFD_SHIFT); | ||
35 | if (err < 0) { | ||
36 | snd_printk(KERN_ERR "setting High Pass Filter - %d\n", err); | ||
37 | return; | ||
38 | } | ||
39 | |||
40 | /* set Analog Input through GPIO */ | ||
41 | if (on) | ||
42 | geode_gpio_set(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); | ||
43 | else | ||
44 | geode_gpio_clear(OLPC_GPIO_MIC_AC, GPIO_OUTPUT_VAL); | ||
45 | } | ||
46 | |||
47 | /* | ||
48 | * OLPC XO-1's V_REFOUT is a mic bias enable. | ||
49 | */ | ||
50 | void olpc_mic_bias(struct snd_ac97 *ac97, int on) | ||
51 | { | ||
52 | int err; | ||
53 | |||
54 | if (!machine_is_olpc()) | ||
55 | return; | ||
56 | |||
57 | on = on ? 0 : 1; | ||
58 | err = snd_ac97_update_bits(ac97, AC97_AD_MISC, | ||
59 | 1 << AC97_AD_VREFD_SHIFT, on << AC97_AD_VREFD_SHIFT); | ||
60 | if (err < 0) | ||
61 | snd_printk(KERN_ERR "setting MIC Bias - %d\n", err); | ||
62 | } | ||
63 | |||
64 | static int olpc_dc_info(struct snd_kcontrol *kctl, | ||
65 | struct snd_ctl_elem_info *uinfo) | ||
66 | { | ||
67 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
68 | uinfo->count = 1; | ||
69 | uinfo->value.integer.min = 0; | ||
70 | uinfo->value.integer.max = 1; | ||
71 | return 0; | ||
72 | } | ||
73 | |||
74 | static int olpc_dc_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) | ||
75 | { | ||
76 | v->value.integer.value[0] = geode_gpio_isset(OLPC_GPIO_MIC_AC, | ||
77 | GPIO_OUTPUT_VAL); | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | static int olpc_dc_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) | ||
82 | { | ||
83 | struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl); | ||
84 | |||
85 | olpc_analog_input(cs5535au->ac97, v->value.integer.value[0]); | ||
86 | return 1; | ||
87 | } | ||
88 | |||
89 | static int olpc_mic_info(struct snd_kcontrol *kctl, | ||
90 | struct snd_ctl_elem_info *uinfo) | ||
91 | { | ||
92 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
93 | uinfo->count = 1; | ||
94 | uinfo->value.integer.min = 0; | ||
95 | uinfo->value.integer.max = 1; | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static int olpc_mic_get(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) | ||
100 | { | ||
101 | struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl); | ||
102 | struct snd_ac97 *ac97 = cs5535au->ac97; | ||
103 | int i; | ||
104 | |||
105 | i = (snd_ac97_read(ac97, AC97_AD_MISC) >> AC97_AD_VREFD_SHIFT) & 0x1; | ||
106 | v->value.integer.value[0] = i ? 0 : 1; | ||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static int olpc_mic_put(struct snd_kcontrol *kctl, struct snd_ctl_elem_value *v) | ||
111 | { | ||
112 | struct cs5535audio *cs5535au = snd_kcontrol_chip(kctl); | ||
113 | |||
114 | olpc_mic_bias(cs5535au->ac97, v->value.integer.value[0]); | ||
115 | return 1; | ||
116 | } | ||
117 | |||
118 | static struct snd_kcontrol_new olpc_cs5535audio_ctls[] __devinitdata = { | ||
119 | { | ||
120 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
121 | .name = "DC Mode Enable", | ||
122 | .info = olpc_dc_info, | ||
123 | .get = olpc_dc_get, | ||
124 | .put = olpc_dc_put, | ||
125 | .private_value = 0, | ||
126 | }, | ||
127 | { | ||
128 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
129 | .name = "MIC Bias Enable", | ||
130 | .info = olpc_mic_info, | ||
131 | .get = olpc_mic_get, | ||
132 | .put = olpc_mic_put, | ||
133 | .private_value = 0, | ||
134 | }, | ||
135 | }; | ||
136 | |||
137 | void __devinit olpc_prequirks(struct snd_card *card, | ||
138 | struct snd_ac97_template *ac97) | ||
139 | { | ||
140 | if (!machine_is_olpc()) | ||
141 | return; | ||
142 | |||
143 | /* invert EAPD if on an OLPC B3 or higher */ | ||
144 | if (olpc_board_at_least(olpc_board_pre(0xb3))) | ||
145 | ac97->scaps |= AC97_SCAP_INV_EAPD; | ||
146 | } | ||
147 | |||
148 | int __devinit olpc_quirks(struct snd_card *card, struct snd_ac97 *ac97) | ||
149 | { | ||
150 | struct snd_ctl_elem_id elem; | ||
151 | int i, err; | ||
152 | |||
153 | if (!machine_is_olpc()) | ||
154 | return 0; | ||
155 | |||
156 | /* drop the original AD1888 HPF control */ | ||
157 | memset(&elem, 0, sizeof(elem)); | ||
158 | elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | ||
159 | strncpy(elem.name, "High Pass Filter Enable", sizeof(elem.name)); | ||
160 | snd_ctl_remove_id(card, &elem); | ||
161 | |||
162 | /* drop the original V_REFOUT control */ | ||
163 | memset(&elem, 0, sizeof(elem)); | ||
164 | elem.iface = SNDRV_CTL_ELEM_IFACE_MIXER; | ||
165 | strncpy(elem.name, "V_REFOUT Enable", sizeof(elem.name)); | ||
166 | snd_ctl_remove_id(card, &elem); | ||
167 | |||
168 | /* add the OLPC-specific controls */ | ||
169 | for (i = 0; i < ARRAY_SIZE(olpc_cs5535audio_ctls); i++) { | ||
170 | err = snd_ctl_add(card, snd_ctl_new1(&olpc_cs5535audio_ctls[i], | ||
171 | ac97->private_data)); | ||
172 | if (err < 0) | ||
173 | return err; | ||
174 | } | ||
175 | |||
176 | /* turn off the mic by default */ | ||
177 | olpc_mic_bias(ac97, 0); | ||
178 | return 0; | ||
179 | } | ||
diff --git a/sound/pci/cs5535audio/cs5535audio_pcm.c b/sound/pci/cs5535audio/cs5535audio_pcm.c index cdcda87116c3..0f48a871f17b 100644 --- a/sound/pci/cs5535audio/cs5535audio_pcm.c +++ b/sound/pci/cs5535audio/cs5535audio_pcm.c | |||
@@ -260,6 +260,9 @@ static int snd_cs5535audio_hw_params(struct snd_pcm_substream *substream, | |||
260 | err = cs5535audio_build_dma_packets(cs5535au, dma, substream, | 260 | err = cs5535audio_build_dma_packets(cs5535au, dma, substream, |
261 | params_periods(hw_params), | 261 | params_periods(hw_params), |
262 | params_period_bytes(hw_params)); | 262 | params_period_bytes(hw_params)); |
263 | if (!err) | ||
264 | dma->pcm_open_flag = 1; | ||
265 | |||
263 | return err; | 266 | return err; |
264 | } | 267 | } |
265 | 268 | ||
@@ -268,6 +271,15 @@ static int snd_cs5535audio_hw_free(struct snd_pcm_substream *substream) | |||
268 | struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); | 271 | struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); |
269 | struct cs5535audio_dma *dma = substream->runtime->private_data; | 272 | struct cs5535audio_dma *dma = substream->runtime->private_data; |
270 | 273 | ||
274 | if (dma->pcm_open_flag) { | ||
275 | if (substream == cs5535au->playback_substream) | ||
276 | snd_ac97_update_power(cs5535au->ac97, | ||
277 | AC97_PCM_FRONT_DAC_RATE, 0); | ||
278 | else | ||
279 | snd_ac97_update_power(cs5535au->ac97, | ||
280 | AC97_PCM_LR_ADC_RATE, 0); | ||
281 | dma->pcm_open_flag = 0; | ||
282 | } | ||
271 | cs5535audio_clear_dma_packets(cs5535au, dma, substream); | 283 | cs5535audio_clear_dma_packets(cs5535au, dma, substream); |
272 | return snd_pcm_lib_free_pages(substream); | 284 | return snd_pcm_lib_free_pages(substream); |
273 | } | 285 | } |
@@ -351,11 +363,14 @@ static int snd_cs5535audio_capture_open(struct snd_pcm_substream *substream) | |||
351 | if ((err = snd_pcm_hw_constraint_integer(runtime, | 363 | if ((err = snd_pcm_hw_constraint_integer(runtime, |
352 | SNDRV_PCM_HW_PARAM_PERIODS)) < 0) | 364 | SNDRV_PCM_HW_PARAM_PERIODS)) < 0) |
353 | return err; | 365 | return err; |
366 | olpc_capture_open(cs5535au->ac97); | ||
354 | return 0; | 367 | return 0; |
355 | } | 368 | } |
356 | 369 | ||
357 | static int snd_cs5535audio_capture_close(struct snd_pcm_substream *substream) | 370 | static int snd_cs5535audio_capture_close(struct snd_pcm_substream *substream) |
358 | { | 371 | { |
372 | struct cs5535audio *cs5535au = snd_pcm_substream_chip(substream); | ||
373 | olpc_capture_close(cs5535au->ac97); | ||
359 | return 0; | 374 | return 0; |
360 | } | 375 | } |
361 | 376 | ||
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 2f283ea6ad9a..7958006a1d66 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 | ||
72 | void snd_emu10k1_voice_init(struct snd_emu10k1 * emu, int ch) | 72 | void 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 | ||
157 | static int snd_emu10k1_init(struct snd_emu10k1 *emu, int enable_ir, int resume) | 157 | static 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 | ||
403 | int snd_emu10k1_done(struct snd_emu10k1 * emu) | 403 | int 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 | ||
526 | static void snd_emu10k1_ecard_write(struct snd_emu10k1 * emu, unsigned int value) | 526 | static 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 | ||
564 | static void snd_emu10k1_ecard_setadcgain(struct snd_emu10k1 * emu, | 564 | static 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 | ||
592 | static int snd_emu10k1_ecard_init(struct snd_emu10k1 * emu) | 592 | static 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 | ||
632 | static int snd_emu10k1_cardbus_init(struct snd_emu10k1 * emu) | 632 | static 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 | ||
659 | static int snd_emu1010_load_firmware(struct snd_emu10k1 * emu, const char * filename) | 659 | static 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 | ||
710 | static int emu1010_firmware_thread(void *data) | 711 | static 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, ® ); /* OPTIONS: Which cards are attached to the EMU */ | 724 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); /* 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, ® ); | 748 | snd_emu1010_fpga_read(emu, EMU_HANA_IRQ_STATUS, ®); |
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, ® ); | 751 | snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); |
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 | */ |
803 | static int snd_emu10k1_emu1010_init(struct snd_emu10k1 * emu) | 804 | static 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, ® ); | 836 | snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); |
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, ® ); | 844 | snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); |
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, ® ); | 880 | snd_emu1010_fpga_read(emu, EMU_HANA_ID, ®); |
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, ® ); | 894 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); |
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, ® ); | 896 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); |
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, ® ); | 935 | snd_emu1010_fpga_read(emu, EMU_HANA_OPTION_CARDS, ®); |
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); | |||
1247 | static int snd_emu10k1_free(struct snd_emu10k1 *emu) | 1249 | static 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 | ||
1294 | static struct snd_emu_chip_details emu_chip_details[] = { | 1296 | static 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,31 +1463,34 @@ 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, |
1464 | .ca0151_chip = 1, | 1470 | .ca0151_chip = 1, |
1465 | .spk71 = 1, | 1471 | .spk71 = 1, |
1466 | .spdif_bug = 1, | 1472 | .spdif_bug = 1, |
1473 | .invert_shared_spdif = 1, /* digital/analog switch swapped */ | ||
1467 | .ac97_chip = 1} , | 1474 | .ac97_chip = 1} , |
1468 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, | 1475 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20021102, |
1469 | .driver = "Audigy2", .name = "Audigy 2 ZS [SB0350]", | 1476 | .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0350]", |
1470 | .id = "Audigy2", | 1477 | .id = "Audigy2", |
1471 | .emu10k2_chip = 1, | 1478 | .emu10k2_chip = 1, |
1472 | .ca0102_chip = 1, | 1479 | .ca0102_chip = 1, |
1473 | .ca0151_chip = 1, | 1480 | .ca0151_chip = 1, |
1474 | .spk71 = 1, | 1481 | .spk71 = 1, |
1475 | .spdif_bug = 1, | 1482 | .spdif_bug = 1, |
1483 | .invert_shared_spdif = 1, /* digital/analog switch swapped */ | ||
1476 | .ac97_chip = 1} , | 1484 | .ac97_chip = 1} , |
1477 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, | 1485 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x20011102, |
1478 | .driver = "Audigy2", .name = "Audigy 2 ZS [2001]", | 1486 | .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0360]", |
1479 | .id = "Audigy2", | 1487 | .id = "Audigy2", |
1480 | .emu10k2_chip = 1, | 1488 | .emu10k2_chip = 1, |
1481 | .ca0102_chip = 1, | 1489 | .ca0102_chip = 1, |
1482 | .ca0151_chip = 1, | 1490 | .ca0151_chip = 1, |
1483 | .spk71 = 1, | 1491 | .spk71 = 1, |
1484 | .spdif_bug = 1, | 1492 | .spdif_bug = 1, |
1493 | .invert_shared_spdif = 1, /* digital/analog switch swapped */ | ||
1485 | .ac97_chip = 1} , | 1494 | .ac97_chip = 1} , |
1486 | /* Audigy 2 */ | 1495 | /* Audigy 2 */ |
1487 | /* Tested by James@superbug.co.uk 3rd July 2005 */ | 1496 | /* Tested by James@superbug.co.uk 3rd July 2005 */ |
@@ -1492,7 +1501,7 @@ static struct snd_emu_chip_details emu_chip_details[] = { | |||
1492 | * CA0151: Yes | 1501 | * CA0151: Yes |
1493 | */ | 1502 | */ |
1494 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, | 1503 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10071102, |
1495 | .driver = "Audigy2", .name = "Audigy 2 [SB0240]", | 1504 | .driver = "Audigy2", .name = "SB Audigy 2 [SB0240]", |
1496 | .id = "Audigy2", | 1505 | .id = "Audigy2", |
1497 | .emu10k2_chip = 1, | 1506 | .emu10k2_chip = 1, |
1498 | .ca0102_chip = 1, | 1507 | .ca0102_chip = 1, |
@@ -1502,7 +1511,7 @@ static struct snd_emu_chip_details emu_chip_details[] = { | |||
1502 | .adc_1361t = 1, /* 24 bit capture instead of 16bit */ | 1511 | .adc_1361t = 1, /* 24 bit capture instead of 16bit */ |
1503 | .ac97_chip = 1} , | 1512 | .ac97_chip = 1} , |
1504 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, | 1513 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10051102, |
1505 | .driver = "Audigy2", .name = "Audigy 2 EX [1005]", | 1514 | .driver = "Audigy2", .name = "SB Audigy 2 Platinum EX [SB0280]", |
1506 | .id = "Audigy2", | 1515 | .id = "Audigy2", |
1507 | .emu10k2_chip = 1, | 1516 | .emu10k2_chip = 1, |
1508 | .ca0102_chip = 1, | 1517 | .ca0102_chip = 1, |
@@ -1512,7 +1521,7 @@ static struct snd_emu_chip_details emu_chip_details[] = { | |||
1512 | /* Dell OEM/Creative Labs Audigy 2 ZS */ | 1521 | /* Dell OEM/Creative Labs Audigy 2 ZS */ |
1513 | /* See ALSA bug#1365 */ | 1522 | /* See ALSA bug#1365 */ |
1514 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102, | 1523 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10031102, |
1515 | .driver = "Audigy2", .name = "Audigy 2 ZS [SB0353]", | 1524 | .driver = "Audigy2", .name = "SB Audigy 2 ZS [SB0353]", |
1516 | .id = "Audigy2", | 1525 | .id = "Audigy2", |
1517 | .emu10k2_chip = 1, | 1526 | .emu10k2_chip = 1, |
1518 | .ca0102_chip = 1, | 1527 | .ca0102_chip = 1, |
@@ -1521,7 +1530,7 @@ static struct snd_emu_chip_details emu_chip_details[] = { | |||
1521 | .spdif_bug = 1, | 1530 | .spdif_bug = 1, |
1522 | .ac97_chip = 1} , | 1531 | .ac97_chip = 1} , |
1523 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, | 1532 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x10021102, |
1524 | .driver = "Audigy2", .name = "Audigy 2 Platinum [SB0240P]", | 1533 | .driver = "Audigy2", .name = "SB Audigy 2 Platinum [SB0240P]", |
1525 | .id = "Audigy2", | 1534 | .id = "Audigy2", |
1526 | .emu10k2_chip = 1, | 1535 | .emu10k2_chip = 1, |
1527 | .ca0102_chip = 1, | 1536 | .ca0102_chip = 1, |
@@ -1532,7 +1541,7 @@ static struct snd_emu_chip_details emu_chip_details[] = { | |||
1532 | .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 */ |
1533 | .ac97_chip = 1} , | 1542 | .ac97_chip = 1} , |
1534 | {.vendor = 0x1102, .device = 0x0004, .revision = 0x04, | 1543 | {.vendor = 0x1102, .device = 0x0004, .revision = 0x04, |
1535 | .driver = "Audigy2", .name = "Audigy 2 [Unknown]", | 1544 | .driver = "Audigy2", .name = "SB Audigy 2 [Unknown]", |
1536 | .id = "Audigy2", | 1545 | .id = "Audigy2", |
1537 | .emu10k2_chip = 1, | 1546 | .emu10k2_chip = 1, |
1538 | .ca0102_chip = 1, | 1547 | .ca0102_chip = 1, |
@@ -1540,78 +1549,79 @@ static struct snd_emu_chip_details emu_chip_details[] = { | |||
1540 | .spdif_bug = 1, | 1549 | .spdif_bug = 1, |
1541 | .ac97_chip = 1} , | 1550 | .ac97_chip = 1} , |
1542 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102, | 1551 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00531102, |
1543 | .driver = "Audigy", .name = "Audigy 1 [SB0090]", | 1552 | .driver = "Audigy", .name = "SB Audigy 1 [SB0092]", |
1544 | .id = "Audigy", | 1553 | .id = "Audigy", |
1545 | .emu10k2_chip = 1, | 1554 | .emu10k2_chip = 1, |
1546 | .ca0102_chip = 1, | 1555 | .ca0102_chip = 1, |
1547 | .ac97_chip = 1} , | 1556 | .ac97_chip = 1} , |
1548 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102, | 1557 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00521102, |
1549 | .driver = "Audigy", .name = "Audigy 1 ES [SB0160]", | 1558 | .driver = "Audigy", .name = "SB Audigy 1 ES [SB0160]", |
1550 | .id = "Audigy", | 1559 | .id = "Audigy", |
1551 | .emu10k2_chip = 1, | 1560 | .emu10k2_chip = 1, |
1552 | .ca0102_chip = 1, | 1561 | .ca0102_chip = 1, |
1553 | .spdif_bug = 1, | 1562 | .spdif_bug = 1, |
1554 | .ac97_chip = 1} , | 1563 | .ac97_chip = 1} , |
1555 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102, | 1564 | {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x00511102, |
1556 | .driver = "Audigy", .name = "Audigy 1 [SB0090]", | 1565 | .driver = "Audigy", .name = "SB Audigy 1 [SB0090]", |
1557 | .id = "Audigy", | 1566 | .id = "Audigy", |
1558 | .emu10k2_chip = 1, | 1567 | .emu10k2_chip = 1, |
1559 | .ca0102_chip = 1, | 1568 | .ca0102_chip = 1, |
1560 | .ac97_chip = 1} , | 1569 | .ac97_chip = 1} , |
1561 | {.vendor = 0x1102, .device = 0x0004, | 1570 | {.vendor = 0x1102, .device = 0x0004, |
1562 | .driver = "Audigy", .name = "Audigy 1 [Unknown]", | 1571 | .driver = "Audigy", .name = "Audigy 1 [Unknown]", |
1563 | .id = "Audigy", | 1572 | .id = "Audigy", |
1564 | .emu10k2_chip = 1, | 1573 | .emu10k2_chip = 1, |
1565 | .ca0102_chip = 1, | 1574 | .ca0102_chip = 1, |
1566 | .ac97_chip = 1} , | 1575 | .ac97_chip = 1} , |
1567 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806B1102, | 1576 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102, |
1568 | .driver = "EMU10K1", .name = "SBLive! [SB0105]", | 1577 | .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0220]", |
1569 | .id = "Live", | 1578 | .id = "Live", |
1570 | .emu10k1_chip = 1, | 1579 | .emu10k1_chip = 1, |
1571 | .ac97_chip = 1, | 1580 | .ac97_chip = 1, |
1572 | .sblive51 = 1} , | 1581 | .sblive51 = 1} , |
1573 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806A1102, | 1582 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806b1102, |
1574 | .driver = "EMU10K1", .name = "SBLive! Value [SB0103]", | 1583 | .driver = "EMU10K1", .name = "SB Live! [SB0105]", |
1584 | .id = "Live", | ||
1585 | .emu10k1_chip = 1, | ||
1586 | .ac97_chip = 1, | ||
1587 | .sblive51 = 1} , | ||
1588 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x806a1102, | ||
1589 | .driver = "EMU10K1", .name = "SB Live! Value [SB0103]", | ||
1575 | .id = "Live", | 1590 | .id = "Live", |
1576 | .emu10k1_chip = 1, | 1591 | .emu10k1_chip = 1, |
1577 | .ac97_chip = 1, | 1592 | .ac97_chip = 1, |
1578 | .sblive51 = 1} , | 1593 | .sblive51 = 1} , |
1579 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102, | 1594 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80691102, |
1580 | .driver = "EMU10K1", .name = "SBLive! Value [SB0101]", | 1595 | .driver = "EMU10K1", .name = "SB Live! Value [SB0101]", |
1581 | .id = "Live", | 1596 | .id = "Live", |
1582 | .emu10k1_chip = 1, | 1597 | .emu10k1_chip = 1, |
1583 | .ac97_chip = 1, | 1598 | .ac97_chip = 1, |
1584 | .sblive51 = 1} , | 1599 | .sblive51 = 1} , |
1585 | /* Tested by ALSA bug#1680 26th December 2005 */ | 1600 | /* Tested by ALSA bug#1680 26th December 2005 */ |
1586 | /* 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 */ | ||
1587 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102, | 1603 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80661102, |
1588 | .driver = "EMU10K1", .name = "SB Live 5.1 Dell OEM [SB0220]", | 1604 | .driver = "EMU10K1", .name = "SB Live! 5.1 Dell OEM [SB0228]", |
1589 | .id = "Live", | 1605 | .id = "Live", |
1590 | .emu10k1_chip = 1, | 1606 | .emu10k1_chip = 1, |
1591 | .ac97_chip = 1, | 1607 | .ac97_chip = 1, |
1592 | .sblive51 = 1} , | 1608 | .sblive51 = 1} , |
1593 | /* Tested by Thomas Zehetbauer 27th Aug 2005 */ | 1609 | /* Tested by Thomas Zehetbauer 27th Aug 2005 */ |
1594 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102, | 1610 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80651102, |
1595 | .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", | 1611 | .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0220]", |
1596 | .id = "Live", | ||
1597 | .emu10k1_chip = 1, | ||
1598 | .ac97_chip = 1, | ||
1599 | .sblive51 = 1} , | ||
1600 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x100a1102, | ||
1601 | .driver = "EMU10K1", .name = "SB Live 5.1 [SB0220]", | ||
1602 | .id = "Live", | 1612 | .id = "Live", |
1603 | .emu10k1_chip = 1, | 1613 | .emu10k1_chip = 1, |
1604 | .ac97_chip = 1, | 1614 | .ac97_chip = 1, |
1605 | .sblive51 = 1} , | 1615 | .sblive51 = 1} , |
1606 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, | 1616 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80641102, |
1607 | .driver = "EMU10K1", .name = "SB Live 5.1", | 1617 | .driver = "EMU10K1", .name = "SB Live! 5.1", |
1608 | .id = "Live", | 1618 | .id = "Live", |
1609 | .emu10k1_chip = 1, | 1619 | .emu10k1_chip = 1, |
1610 | .ac97_chip = 1, | 1620 | .ac97_chip = 1, |
1611 | .sblive51 = 1} , | 1621 | .sblive51 = 1} , |
1612 | /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */ | 1622 | /* Tested by alsa bugtrack user "hus" bug #1297 12th Aug 2005 */ |
1613 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, | 1623 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80611102, |
1614 | .driver = "EMU10K1", .name = "SBLive 5.1 [SB0060]", | 1624 | .driver = "EMU10K1", .name = "SB Live! 5.1 [SB0060]", |
1615 | .id = "Live", | 1625 | .id = "Live", |
1616 | .emu10k1_chip = 1, | 1626 | .emu10k1_chip = 1, |
1617 | .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 |
@@ -1619,78 +1629,78 @@ static struct snd_emu_chip_details emu_chip_details[] = { | |||
1619 | */ | 1629 | */ |
1620 | .sblive51 = 1} , | 1630 | .sblive51 = 1} , |
1621 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, | 1631 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80511102, |
1622 | .driver = "EMU10K1", .name = "SBLive! Value [CT4850]", | 1632 | .driver = "EMU10K1", .name = "SB Live! Value [CT4850]", |
1623 | .id = "Live", | 1633 | .id = "Live", |
1624 | .emu10k1_chip = 1, | 1634 | .emu10k1_chip = 1, |
1625 | .ac97_chip = 1, | 1635 | .ac97_chip = 1, |
1626 | .sblive51 = 1} , | 1636 | .sblive51 = 1} , |
1627 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102, | 1637 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80401102, |
1628 | .driver = "EMU10K1", .name = "SBLive! Platinum [CT4760P]", | 1638 | .driver = "EMU10K1", .name = "SB Live! Platinum [CT4760P]", |
1629 | .id = "Live", | 1639 | .id = "Live", |
1630 | .emu10k1_chip = 1, | 1640 | .emu10k1_chip = 1, |
1631 | .ac97_chip = 1} , | 1641 | .ac97_chip = 1} , |
1632 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102, | 1642 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80321102, |
1633 | .driver = "EMU10K1", .name = "SBLive! Value [CT4871]", | 1643 | .driver = "EMU10K1", .name = "SB Live! Value [CT4871]", |
1634 | .id = "Live", | 1644 | .id = "Live", |
1635 | .emu10k1_chip = 1, | 1645 | .emu10k1_chip = 1, |
1636 | .ac97_chip = 1, | 1646 | .ac97_chip = 1, |
1637 | .sblive51 = 1} , | 1647 | .sblive51 = 1} , |
1638 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102, | 1648 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80311102, |
1639 | .driver = "EMU10K1", .name = "SBLive! Value [CT4831]", | 1649 | .driver = "EMU10K1", .name = "SB Live! Value [CT4831]", |
1640 | .id = "Live", | 1650 | .id = "Live", |
1641 | .emu10k1_chip = 1, | 1651 | .emu10k1_chip = 1, |
1642 | .ac97_chip = 1, | 1652 | .ac97_chip = 1, |
1643 | .sblive51 = 1} , | 1653 | .sblive51 = 1} , |
1644 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102, | 1654 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80281102, |
1645 | .driver = "EMU10K1", .name = "SBLive! Value [CT4870]", | 1655 | .driver = "EMU10K1", .name = "SB Live! Value [CT4870]", |
1646 | .id = "Live", | 1656 | .id = "Live", |
1647 | .emu10k1_chip = 1, | 1657 | .emu10k1_chip = 1, |
1648 | .ac97_chip = 1, | 1658 | .ac97_chip = 1, |
1649 | .sblive51 = 1} , | 1659 | .sblive51 = 1} , |
1650 | /* Tested by James@superbug.co.uk 3rd July 2005 */ | 1660 | /* Tested by James@superbug.co.uk 3rd July 2005 */ |
1651 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102, | 1661 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80271102, |
1652 | .driver = "EMU10K1", .name = "SBLive! Value [CT4832]", | 1662 | .driver = "EMU10K1", .name = "SB Live! Value [CT4832]", |
1653 | .id = "Live", | 1663 | .id = "Live", |
1654 | .emu10k1_chip = 1, | 1664 | .emu10k1_chip = 1, |
1655 | .ac97_chip = 1, | 1665 | .ac97_chip = 1, |
1656 | .sblive51 = 1} , | 1666 | .sblive51 = 1} , |
1657 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102, | 1667 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80261102, |
1658 | .driver = "EMU10K1", .name = "SBLive! Value [CT4830]", | 1668 | .driver = "EMU10K1", .name = "SB Live! Value [CT4830]", |
1659 | .id = "Live", | 1669 | .id = "Live", |
1660 | .emu10k1_chip = 1, | 1670 | .emu10k1_chip = 1, |
1661 | .ac97_chip = 1, | 1671 | .ac97_chip = 1, |
1662 | .sblive51 = 1} , | 1672 | .sblive51 = 1} , |
1663 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102, | 1673 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80231102, |
1664 | .driver = "EMU10K1", .name = "SB PCI512 [CT4790]", | 1674 | .driver = "EMU10K1", .name = "SB PCI512 [CT4790]", |
1665 | .id = "Live", | 1675 | .id = "Live", |
1666 | .emu10k1_chip = 1, | 1676 | .emu10k1_chip = 1, |
1667 | .ac97_chip = 1, | 1677 | .ac97_chip = 1, |
1668 | .sblive51 = 1} , | 1678 | .sblive51 = 1} , |
1669 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102, | 1679 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x80221102, |
1670 | .driver = "EMU10K1", .name = "SBLive! Value [CT4780]", | 1680 | .driver = "EMU10K1", .name = "SB Live! Value [CT4780]", |
1671 | .id = "Live", | 1681 | .id = "Live", |
1672 | .emu10k1_chip = 1, | 1682 | .emu10k1_chip = 1, |
1673 | .ac97_chip = 1, | 1683 | .ac97_chip = 1, |
1674 | .sblive51 = 1} , | 1684 | .sblive51 = 1} , |
1675 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, | 1685 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x40011102, |
1676 | .driver = "EMU10K1", .name = "E-mu APS [4001]", | 1686 | .driver = "EMU10K1", .name = "E-mu APS [PC545]", |
1677 | .id = "APS", | 1687 | .id = "APS", |
1678 | .emu10k1_chip = 1, | 1688 | .emu10k1_chip = 1, |
1679 | .ecard = 1} , | 1689 | .ecard = 1} , |
1680 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102, | 1690 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00211102, |
1681 | .driver = "EMU10K1", .name = "SBLive! [CT4620]", | 1691 | .driver = "EMU10K1", .name = "SB Live! [CT4620]", |
1682 | .id = "Live", | 1692 | .id = "Live", |
1683 | .emu10k1_chip = 1, | 1693 | .emu10k1_chip = 1, |
1684 | .ac97_chip = 1, | 1694 | .ac97_chip = 1, |
1685 | .sblive51 = 1} , | 1695 | .sblive51 = 1} , |
1686 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102, | 1696 | {.vendor = 0x1102, .device = 0x0002, .subsystem = 0x00201102, |
1687 | .driver = "EMU10K1", .name = "SBLive! Value [CT4670]", | 1697 | .driver = "EMU10K1", .name = "SB Live! Value [CT4670]", |
1688 | .id = "Live", | 1698 | .id = "Live", |
1689 | .emu10k1_chip = 1, | 1699 | .emu10k1_chip = 1, |
1690 | .ac97_chip = 1, | 1700 | .ac97_chip = 1, |
1691 | .sblive51 = 1} , | 1701 | .sblive51 = 1} , |
1692 | {.vendor = 0x1102, .device = 0x0002, | 1702 | {.vendor = 0x1102, .device = 0x0002, |
1693 | .driver = "EMU10K1", .name = "SB Live [Unknown]", | 1703 | .driver = "EMU10K1", .name = "SB Live! [Unknown]", |
1694 | .id = "Live", | 1704 | .id = "Live", |
1695 | .emu10k1_chip = 1, | 1705 | .emu10k1_chip = 1, |
1696 | .ac97_chip = 1, | 1706 | .ac97_chip = 1, |
@@ -1699,13 +1709,13 @@ static struct snd_emu_chip_details emu_chip_details[] = { | |||
1699 | }; | 1709 | }; |
1700 | 1710 | ||
1701 | int __devinit snd_emu10k1_create(struct snd_card *card, | 1711 | int __devinit snd_emu10k1_create(struct snd_card *card, |
1702 | struct pci_dev * pci, | 1712 | struct pci_dev *pci, |
1703 | unsigned short extin_mask, | 1713 | unsigned short extin_mask, |
1704 | unsigned short extout_mask, | 1714 | unsigned short extout_mask, |
1705 | long max_cache_bytes, | 1715 | long max_cache_bytes, |
1706 | int enable_ir, | 1716 | int enable_ir, |
1707 | uint subsystem, | 1717 | uint subsystem, |
1708 | struct snd_emu10k1 ** remu) | 1718 | struct snd_emu10k1 **remu) |
1709 | { | 1719 | { |
1710 | struct snd_emu10k1 *emu; | 1720 | struct snd_emu10k1 *emu; |
1711 | int idx, err; | 1721 | int idx, err; |
@@ -1715,11 +1725,12 @@ int __devinit snd_emu10k1_create(struct snd_card *card, | |||
1715 | static struct snd_device_ops ops = { | 1725 | static struct snd_device_ops ops = { |
1716 | .dev_free = snd_emu10k1_dev_free, | 1726 | .dev_free = snd_emu10k1_dev_free, |
1717 | }; | 1727 | }; |
1718 | 1728 | ||
1719 | *remu = NULL; | 1729 | *remu = NULL; |
1720 | 1730 | ||
1721 | /* enable PCI device */ | 1731 | /* enable PCI device */ |
1722 | if ((err = pci_enable_device(pci)) < 0) | 1732 | err = pci_enable_device(pci); |
1733 | if (err < 0) | ||
1723 | return err; | 1734 | return err; |
1724 | 1735 | ||
1725 | emu = kzalloc(sizeof(*emu), GFP_KERNEL); | 1736 | emu = kzalloc(sizeof(*emu), GFP_KERNEL); |
@@ -1746,16 +1757,17 @@ int __devinit snd_emu10k1_create(struct snd_card *card, | |||
1746 | emu->revision = pci->revision; | 1757 | emu->revision = pci->revision; |
1747 | pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); | 1758 | pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &emu->serial); |
1748 | pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); | 1759 | pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &emu->model); |
1749 | 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); |
1750 | 1761 | ||
1751 | for (c = emu_chip_details; c->vendor; c++) { | 1762 | for (c = emu_chip_details; c->vendor; c++) { |
1752 | if (c->vendor == pci->vendor && c->device == pci->device) { | 1763 | if (c->vendor == pci->vendor && c->device == pci->device) { |
1753 | if (subsystem) { | 1764 | if (subsystem) { |
1754 | if (c->subsystem && (c->subsystem == subsystem) ) { | 1765 | if (c->subsystem && (c->subsystem == subsystem)) |
1755 | break; | 1766 | break; |
1756 | } else continue; | 1767 | else |
1768 | continue; | ||
1757 | } else { | 1769 | } else { |
1758 | if (c->subsystem && (c->subsystem != emu->serial) ) | 1770 | if (c->subsystem && (c->subsystem != emu->serial)) |
1759 | continue; | 1771 | continue; |
1760 | if (c->revision && c->revision != emu->revision) | 1772 | if (c->revision && c->revision != emu->revision) |
1761 | continue; | 1773 | continue; |
@@ -1771,14 +1783,18 @@ int __devinit snd_emu10k1_create(struct snd_card *card, | |||
1771 | } | 1783 | } |
1772 | emu->card_capabilities = c; | 1784 | emu->card_capabilities = c; |
1773 | if (c->subsystem && !subsystem) | 1785 | if (c->subsystem && !subsystem) |
1774 | snd_printdd("Sound card name=%s\n", c->name); | 1786 | snd_printdd("Sound card name = %s\n", c->name); |
1775 | else if (subsystem) | 1787 | else if (subsystem) |
1776 | 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, " |
1777 | c->name, pci->vendor, pci->device, emu->serial, c->subsystem); | 1789 | "vendor = 0x%x, device = 0x%x, subsystem = 0x%x. " |
1778 | else | 1790 | "Forced to subsytem = 0x%x\n", c->name, |
1779 | 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); |
1780 | c->name, pci->vendor, pci->device, emu->serial); | 1792 | else |
1781 | 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 | |||
1782 | if (!*card->id && c->id) { | 1798 | if (!*card->id && c->id) { |
1783 | int i, n = 0; | 1799 | int i, n = 0; |
1784 | strlcpy(card->id, c->id, sizeof(card->id)); | 1800 | strlcpy(card->id, c->id, sizeof(card->id)); |
@@ -1812,7 +1828,8 @@ int __devinit snd_emu10k1_create(struct snd_card *card, | |||
1812 | else | 1828 | else |
1813 | emu->gpr_base = FXGPREGBASE; | 1829 | emu->gpr_base = FXGPREGBASE; |
1814 | 1830 | ||
1815 | if ((err = pci_request_regions(pci, "EMU10K1")) < 0) { | 1831 | err = pci_request_regions(pci, "EMU10K1"); |
1832 | if (err < 0) { | ||
1816 | kfree(emu); | 1833 | kfree(emu); |
1817 | pci_disable_device(pci); | 1834 | pci_disable_device(pci); |
1818 | return err; | 1835 | return err; |
@@ -1859,21 +1876,25 @@ int __devinit snd_emu10k1_create(struct snd_card *card, | |||
1859 | emu->enable_ir = enable_ir; | 1876 | emu->enable_ir = enable_ir; |
1860 | 1877 | ||
1861 | if (emu->card_capabilities->ca_cardbus_chip) { | 1878 | if (emu->card_capabilities->ca_cardbus_chip) { |
1862 | if ((err = snd_emu10k1_cardbus_init(emu)) < 0) | 1879 | err = snd_emu10k1_cardbus_init(emu); |
1880 | if (err < 0) | ||
1863 | goto error; | 1881 | goto error; |
1864 | } | 1882 | } |
1865 | if (emu->card_capabilities->ecard) { | 1883 | if (emu->card_capabilities->ecard) { |
1866 | if ((err = snd_emu10k1_ecard_init(emu)) < 0) | 1884 | err = snd_emu10k1_ecard_init(emu); |
1885 | if (err < 0) | ||
1867 | goto error; | 1886 | goto error; |
1868 | } else if (emu->card_capabilities->emu_model) { | 1887 | } else if (emu->card_capabilities->emu_model) { |
1869 | if ((err = snd_emu10k1_emu1010_init(emu)) < 0) { | 1888 | err = snd_emu10k1_emu1010_init(emu); |
1870 | snd_emu10k1_free(emu); | 1889 | if (err < 0) { |
1871 | return err; | 1890 | snd_emu10k1_free(emu); |
1872 | } | 1891 | return err; |
1892 | } | ||
1873 | } else { | 1893 | } else { |
1874 | /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version | 1894 | /* 5.1: Enable the additional AC97 Slots. If the emu10k1 version |
1875 | does not support this, it shouldn't do any harm */ | 1895 | does not support this, it shouldn't do any harm */ |
1876 | snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); | 1896 | snd_emu10k1_ptr_write(emu, AC97SLOT, 0, |
1897 | AC97SLOT_CNTR|AC97SLOT_LFE); | ||
1877 | } | 1898 | } |
1878 | 1899 | ||
1879 | /* initialize TRAM setup */ | 1900 | /* initialize TRAM setup */ |
@@ -1913,7 +1934,7 @@ int __devinit snd_emu10k1_create(struct snd_card *card, | |||
1913 | snd_emu10k1_synth_alloc(emu, 4096); | 1934 | snd_emu10k1_synth_alloc(emu, 4096); |
1914 | if (emu->reserved_page) | 1935 | if (emu->reserved_page) |
1915 | emu->reserved_page->map_locked = 1; | 1936 | emu->reserved_page->map_locked = 1; |
1916 | 1937 | ||
1917 | /* Clear silent pages and set up pointers */ | 1938 | /* Clear silent pages and set up pointers */ |
1918 | memset(emu->silent_page.area, 0, PAGE_SIZE); | 1939 | memset(emu->silent_page.area, 0, PAGE_SIZE); |
1919 | silent_page = emu->silent_page.addr << 1; | 1940 | silent_page = emu->silent_page.addr << 1; |
@@ -1926,19 +1947,23 @@ int __devinit snd_emu10k1_create(struct snd_card *card, | |||
1926 | emu->voices[idx].number = idx; | 1947 | emu->voices[idx].number = idx; |
1927 | } | 1948 | } |
1928 | 1949 | ||
1929 | if ((err = snd_emu10k1_init(emu, enable_ir, 0)) < 0) | 1950 | err = snd_emu10k1_init(emu, enable_ir, 0); |
1951 | if (err < 0) | ||
1930 | goto error; | 1952 | goto error; |
1931 | #ifdef CONFIG_PM | 1953 | #ifdef CONFIG_PM |
1932 | if ((err = alloc_pm_buffer(emu)) < 0) | 1954 | err = alloc_pm_buffer(emu); |
1955 | if (err < 0) | ||
1933 | goto error; | 1956 | goto error; |
1934 | #endif | 1957 | #endif |
1935 | 1958 | ||
1936 | /* Initialize the effect engine */ | 1959 | /* Initialize the effect engine */ |
1937 | if ((err = snd_emu10k1_init_efx(emu)) < 0) | 1960 | err = snd_emu10k1_init_efx(emu); |
1961 | if (err < 0) | ||
1938 | goto error; | 1962 | goto error; |
1939 | snd_emu10k1_audio_enable(emu); | 1963 | snd_emu10k1_audio_enable(emu); |
1940 | 1964 | ||
1941 | 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) | ||
1942 | goto error; | 1967 | goto error; |
1943 | 1968 | ||
1944 | #ifdef CONFIG_PROC_FS | 1969 | #ifdef CONFIG_PROC_FS |
@@ -1978,7 +2003,7 @@ static int __devinit alloc_pm_buffer(struct snd_emu10k1 *emu) | |||
1978 | if (emu->audigy) | 2003 | if (emu->audigy) |
1979 | size += ARRAY_SIZE(saved_regs_audigy); | 2004 | size += ARRAY_SIZE(saved_regs_audigy); |
1980 | emu->saved_ptr = vmalloc(4 * NUM_G * size); | 2005 | emu->saved_ptr = vmalloc(4 * NUM_G * size); |
1981 | if (! emu->saved_ptr) | 2006 | if (!emu->saved_ptr) |
1982 | return -ENOMEM; | 2007 | return -ENOMEM; |
1983 | if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) | 2008 | if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) |
1984 | return -ENOMEM; | 2009 | return -ENOMEM; |
@@ -2023,7 +2048,7 @@ void snd_emu10k1_resume_init(struct snd_emu10k1 *emu) | |||
2023 | if (emu->card_capabilities->ecard) | 2048 | if (emu->card_capabilities->ecard) |
2024 | snd_emu10k1_ecard_init(emu); | 2049 | snd_emu10k1_ecard_init(emu); |
2025 | else if (emu->card_capabilities->emu_model) | 2050 | else if (emu->card_capabilities->emu_model) |
2026 | snd_emu10k1_emu1010_init(emu); | 2051 | snd_emu10k1_emu1010_init(emu); |
2027 | else | 2052 | else |
2028 | snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); | 2053 | snd_emu10k1_ptr_write(emu, AC97SLOT, 0, AC97SLOT_CNTR|AC97SLOT_LFE); |
2029 | 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 f34bbfb705f5..b0fb6c917c38 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 | |||
1646 | static 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 | |||
1658 | static 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 | |||
1671 | static 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 | */ |
1644 | static void snd_emu10k1_mixer_free_ac97(struct snd_ac97 *ac97) | 1683 | static 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/es1968.c b/sound/pci/es1968.c index 20ee7599600b..e9c3794bbcb8 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c | |||
@@ -1953,7 +1953,7 @@ static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id) | |||
1953 | outw(inw(chip->io_port + 4) & 1, chip->io_port + 4); | 1953 | outw(inw(chip->io_port + 4) & 1, chip->io_port + 4); |
1954 | 1954 | ||
1955 | if (event & ESM_HWVOL_IRQ) | 1955 | if (event & ESM_HWVOL_IRQ) |
1956 | tasklet_hi_schedule(&chip->hwvol_tq); /* we'll do this later */ | 1956 | tasklet_schedule(&chip->hwvol_tq); /* we'll do this later */ |
1957 | 1957 | ||
1958 | /* else ack 'em all, i imagine */ | 1958 | /* else ack 'em all, i imagine */ |
1959 | outb(0xFF, chip->io_port + 0x1A); | 1959 | outb(0xFF, chip->io_port + 0x1A); |
diff --git a/sound/pci/hda/Kconfig b/sound/pci/hda/Kconfig index 717040a491b9..eb2a19b894a0 100644 --- a/sound/pci/hda/Kconfig +++ b/sound/pci/hda/Kconfig | |||
@@ -172,7 +172,6 @@ config SND_HDA_GENERIC | |||
172 | 172 | ||
173 | config SND_HDA_POWER_SAVE | 173 | config SND_HDA_POWER_SAVE |
174 | bool "Aggressive power-saving on HD-audio" | 174 | bool "Aggressive power-saving on HD-audio" |
175 | depends on EXPERIMENTAL | ||
176 | help | 175 | help |
177 | Say Y here to enable more aggressive power-saving mode on | 176 | Say Y here to enable more aggressive power-saving mode on |
178 | HD-audio driver. The power-saving timeout can be configured | 177 | HD-audio driver. The power-saving timeout can be configured |
diff --git a/sound/pci/hda/hda_beep.c b/sound/pci/hda/hda_beep.c index e00421c0d8ba..960fd7970384 100644 --- a/sound/pci/hda/hda_beep.c +++ b/sound/pci/hda/hda_beep.c | |||
@@ -135,7 +135,6 @@ void snd_hda_detach_beep_device(struct hda_codec *codec) | |||
135 | struct hda_beep *beep = codec->beep; | 135 | struct hda_beep *beep = codec->beep; |
136 | if (beep) { | 136 | if (beep) { |
137 | cancel_work_sync(&beep->beep_work); | 137 | cancel_work_sync(&beep->beep_work); |
138 | flush_scheduled_work(); | ||
139 | 138 | ||
140 | input_unregister_device(beep->dev); | 139 | input_unregister_device(beep->dev); |
141 | kfree(beep); | 140 | kfree(beep); |
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 9c1af0101dde..b7bba7dc7cf1 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -46,6 +46,7 @@ static struct hda_vendor_id hda_vendor_ids[] = { | |||
46 | { 0x1002, "ATI" }, | 46 | { 0x1002, "ATI" }, |
47 | { 0x1057, "Motorola" }, | 47 | { 0x1057, "Motorola" }, |
48 | { 0x1095, "Silicon Image" }, | 48 | { 0x1095, "Silicon Image" }, |
49 | { 0x10de, "Nvidia" }, | ||
49 | { 0x10ec, "Realtek" }, | 50 | { 0x10ec, "Realtek" }, |
50 | { 0x1106, "VIA" }, | 51 | { 0x1106, "VIA" }, |
51 | { 0x111d, "IDT" }, | 52 | { 0x111d, "IDT" }, |
@@ -57,6 +58,7 @@ static struct hda_vendor_id hda_vendor_ids[] = { | |||
57 | { 0x1854, "LG" }, | 58 | { 0x1854, "LG" }, |
58 | { 0x1aec, "Wolfson Microelectronics" }, | 59 | { 0x1aec, "Wolfson Microelectronics" }, |
59 | { 0x434d, "C-Media" }, | 60 | { 0x434d, "C-Media" }, |
61 | { 0x8086, "Intel" }, | ||
60 | { 0x8384, "SigmaTel" }, | 62 | { 0x8384, "SigmaTel" }, |
61 | {} /* terminator */ | 63 | {} /* terminator */ |
62 | }; | 64 | }; |
@@ -371,7 +373,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex) | |||
371 | unsol->queue[wp] = res; | 373 | unsol->queue[wp] = res; |
372 | unsol->queue[wp + 1] = res_ex; | 374 | unsol->queue[wp + 1] = res_ex; |
373 | 375 | ||
374 | schedule_work(&unsol->work); | 376 | queue_work(bus->workq, &unsol->work); |
375 | 377 | ||
376 | return 0; | 378 | return 0; |
377 | } | 379 | } |
@@ -435,15 +437,17 @@ static int snd_hda_bus_free(struct hda_bus *bus) | |||
435 | 437 | ||
436 | if (!bus) | 438 | if (!bus) |
437 | return 0; | 439 | return 0; |
438 | if (bus->unsol) { | 440 | if (bus->workq) |
439 | flush_scheduled_work(); | 441 | flush_workqueue(bus->workq); |
442 | if (bus->unsol) | ||
440 | kfree(bus->unsol); | 443 | kfree(bus->unsol); |
441 | } | ||
442 | list_for_each_entry_safe(codec, n, &bus->codec_list, list) { | 444 | list_for_each_entry_safe(codec, n, &bus->codec_list, list) { |
443 | snd_hda_codec_free(codec); | 445 | snd_hda_codec_free(codec); |
444 | } | 446 | } |
445 | if (bus->ops.private_free) | 447 | if (bus->ops.private_free) |
446 | bus->ops.private_free(bus); | 448 | bus->ops.private_free(bus); |
449 | if (bus->workq) | ||
450 | destroy_workqueue(bus->workq); | ||
447 | kfree(bus); | 451 | kfree(bus); |
448 | return 0; | 452 | return 0; |
449 | } | 453 | } |
@@ -483,6 +487,7 @@ int /*__devinit*/ snd_hda_bus_new(struct snd_card *card, | |||
483 | { | 487 | { |
484 | struct hda_bus *bus; | 488 | struct hda_bus *bus; |
485 | int err; | 489 | int err; |
490 | char qname[8]; | ||
486 | static struct snd_device_ops dev_ops = { | 491 | static struct snd_device_ops dev_ops = { |
487 | .dev_register = snd_hda_bus_dev_register, | 492 | .dev_register = snd_hda_bus_dev_register, |
488 | .dev_free = snd_hda_bus_dev_free, | 493 | .dev_free = snd_hda_bus_dev_free, |
@@ -512,6 +517,14 @@ int /*__devinit*/ snd_hda_bus_new(struct snd_card *card, | |||
512 | mutex_init(&bus->cmd_mutex); | 517 | mutex_init(&bus->cmd_mutex); |
513 | INIT_LIST_HEAD(&bus->codec_list); | 518 | INIT_LIST_HEAD(&bus->codec_list); |
514 | 519 | ||
520 | snprintf(qname, sizeof(qname), "hda%d", card->number); | ||
521 | bus->workq = create_workqueue(qname); | ||
522 | if (!bus->workq) { | ||
523 | snd_printk(KERN_ERR "cannot create workqueue %s\n", qname); | ||
524 | kfree(bus); | ||
525 | return -ENOMEM; | ||
526 | } | ||
527 | |||
515 | err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops); | 528 | err = snd_device_new(card, SNDRV_DEV_BUS, bus, &dev_ops); |
516 | if (err < 0) { | 529 | if (err < 0) { |
517 | snd_hda_bus_free(bus); | 530 | snd_hda_bus_free(bus); |
@@ -682,7 +695,7 @@ static void snd_hda_codec_free(struct hda_codec *codec) | |||
682 | return; | 695 | return; |
683 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 696 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
684 | cancel_delayed_work(&codec->power_work); | 697 | cancel_delayed_work(&codec->power_work); |
685 | flush_scheduled_work(); | 698 | flush_workqueue(codec->bus->workq); |
686 | #endif | 699 | #endif |
687 | list_del(&codec->list); | 700 | list_del(&codec->list); |
688 | snd_array_free(&codec->mixers); | 701 | snd_array_free(&codec->mixers); |
@@ -707,7 +720,7 @@ static void snd_hda_codec_free(struct hda_codec *codec) | |||
707 | * Returns 0 if successful, or a negative error code. | 720 | * Returns 0 if successful, or a negative error code. |
708 | */ | 721 | */ |
709 | int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, | 722 | int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, |
710 | struct hda_codec **codecp) | 723 | int do_init, struct hda_codec **codecp) |
711 | { | 724 | { |
712 | struct hda_codec *codec; | 725 | struct hda_codec *codec; |
713 | char component[31]; | 726 | char component[31]; |
@@ -733,6 +746,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr | |||
733 | codec->bus = bus; | 746 | codec->bus = bus; |
734 | codec->addr = codec_addr; | 747 | codec->addr = codec_addr; |
735 | mutex_init(&codec->spdif_mutex); | 748 | mutex_init(&codec->spdif_mutex); |
749 | mutex_init(&codec->control_mutex); | ||
736 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); | 750 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); |
737 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); | 751 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); |
738 | snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32); | 752 | snd_array_init(&codec->mixers, sizeof(struct snd_kcontrol *), 32); |
@@ -791,10 +805,12 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr | |||
791 | if (bus->modelname) | 805 | if (bus->modelname) |
792 | codec->modelname = kstrdup(bus->modelname, GFP_KERNEL); | 806 | codec->modelname = kstrdup(bus->modelname, GFP_KERNEL); |
793 | 807 | ||
794 | err = snd_hda_codec_configure(codec); | 808 | if (do_init) { |
795 | if (err < 0) { | 809 | err = snd_hda_codec_configure(codec); |
796 | snd_hda_codec_free(codec); | 810 | if (err < 0) { |
797 | return err; | 811 | snd_hda_codec_free(codec); |
812 | return err; | ||
813 | } | ||
798 | } | 814 | } |
799 | snd_hda_codec_proc_new(codec); | 815 | snd_hda_codec_proc_new(codec); |
800 | 816 | ||
@@ -1268,7 +1284,7 @@ void snd_hda_codec_reset(struct hda_codec *codec) | |||
1268 | 1284 | ||
1269 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 1285 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
1270 | cancel_delayed_work(&codec->power_work); | 1286 | cancel_delayed_work(&codec->power_work); |
1271 | flush_scheduled_work(); | 1287 | flush_workqueue(codec->bus->workq); |
1272 | #endif | 1288 | #endif |
1273 | snd_hda_ctls_clear(codec); | 1289 | snd_hda_ctls_clear(codec); |
1274 | /* relase PCMs */ | 1290 | /* relase PCMs */ |
@@ -1282,9 +1298,12 @@ void snd_hda_codec_reset(struct hda_codec *codec) | |||
1282 | } | 1298 | } |
1283 | if (codec->patch_ops.free) | 1299 | if (codec->patch_ops.free) |
1284 | codec->patch_ops.free(codec); | 1300 | codec->patch_ops.free(codec); |
1301 | codec->proc_widget_hook = NULL; | ||
1285 | codec->spec = NULL; | 1302 | codec->spec = NULL; |
1286 | free_hda_cache(&codec->amp_cache); | 1303 | free_hda_cache(&codec->amp_cache); |
1287 | free_hda_cache(&codec->cmd_cache); | 1304 | free_hda_cache(&codec->cmd_cache); |
1305 | init_hda_cache(&codec->amp_cache, sizeof(struct hda_amp_info)); | ||
1306 | init_hda_cache(&codec->cmd_cache, sizeof(struct hda_cache_head)); | ||
1288 | codec->num_pcms = 0; | 1307 | codec->num_pcms = 0; |
1289 | codec->pcm_info = NULL; | 1308 | codec->pcm_info = NULL; |
1290 | codec->preset = NULL; | 1309 | codec->preset = NULL; |
@@ -1411,12 +1430,12 @@ int snd_hda_mixer_bind_switch_get(struct snd_kcontrol *kcontrol, | |||
1411 | unsigned long pval; | 1430 | unsigned long pval; |
1412 | int err; | 1431 | int err; |
1413 | 1432 | ||
1414 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1433 | mutex_lock(&codec->control_mutex); |
1415 | pval = kcontrol->private_value; | 1434 | pval = kcontrol->private_value; |
1416 | kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ | 1435 | kcontrol->private_value = pval & ~AMP_VAL_IDX_MASK; /* index 0 */ |
1417 | err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); | 1436 | err = snd_hda_mixer_amp_switch_get(kcontrol, ucontrol); |
1418 | kcontrol->private_value = pval; | 1437 | kcontrol->private_value = pval; |
1419 | mutex_unlock(&codec->spdif_mutex); | 1438 | mutex_unlock(&codec->control_mutex); |
1420 | return err; | 1439 | return err; |
1421 | } | 1440 | } |
1422 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_get); | 1441 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_get); |
@@ -1428,7 +1447,7 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, | |||
1428 | unsigned long pval; | 1447 | unsigned long pval; |
1429 | int i, indices, err = 0, change = 0; | 1448 | int i, indices, err = 0, change = 0; |
1430 | 1449 | ||
1431 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1450 | mutex_lock(&codec->control_mutex); |
1432 | pval = kcontrol->private_value; | 1451 | pval = kcontrol->private_value; |
1433 | indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; | 1452 | indices = (pval & AMP_VAL_IDX_MASK) >> AMP_VAL_IDX_SHIFT; |
1434 | for (i = 0; i < indices; i++) { | 1453 | for (i = 0; i < indices; i++) { |
@@ -1440,7 +1459,7 @@ int snd_hda_mixer_bind_switch_put(struct snd_kcontrol *kcontrol, | |||
1440 | change |= err; | 1459 | change |= err; |
1441 | } | 1460 | } |
1442 | kcontrol->private_value = pval; | 1461 | kcontrol->private_value = pval; |
1443 | mutex_unlock(&codec->spdif_mutex); | 1462 | mutex_unlock(&codec->control_mutex); |
1444 | return err < 0 ? err : change; | 1463 | return err < 0 ? err : change; |
1445 | } | 1464 | } |
1446 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_put); | 1465 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_switch_put); |
@@ -1455,12 +1474,12 @@ int snd_hda_mixer_bind_ctls_info(struct snd_kcontrol *kcontrol, | |||
1455 | struct hda_bind_ctls *c; | 1474 | struct hda_bind_ctls *c; |
1456 | int err; | 1475 | int err; |
1457 | 1476 | ||
1458 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1477 | mutex_lock(&codec->control_mutex); |
1459 | c = (struct hda_bind_ctls *)kcontrol->private_value; | 1478 | c = (struct hda_bind_ctls *)kcontrol->private_value; |
1460 | kcontrol->private_value = *c->values; | 1479 | kcontrol->private_value = *c->values; |
1461 | err = c->ops->info(kcontrol, uinfo); | 1480 | err = c->ops->info(kcontrol, uinfo); |
1462 | kcontrol->private_value = (long)c; | 1481 | kcontrol->private_value = (long)c; |
1463 | mutex_unlock(&codec->spdif_mutex); | 1482 | mutex_unlock(&codec->control_mutex); |
1464 | return err; | 1483 | return err; |
1465 | } | 1484 | } |
1466 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_info); | 1485 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_info); |
@@ -1472,12 +1491,12 @@ int snd_hda_mixer_bind_ctls_get(struct snd_kcontrol *kcontrol, | |||
1472 | struct hda_bind_ctls *c; | 1491 | struct hda_bind_ctls *c; |
1473 | int err; | 1492 | int err; |
1474 | 1493 | ||
1475 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1494 | mutex_lock(&codec->control_mutex); |
1476 | c = (struct hda_bind_ctls *)kcontrol->private_value; | 1495 | c = (struct hda_bind_ctls *)kcontrol->private_value; |
1477 | kcontrol->private_value = *c->values; | 1496 | kcontrol->private_value = *c->values; |
1478 | err = c->ops->get(kcontrol, ucontrol); | 1497 | err = c->ops->get(kcontrol, ucontrol); |
1479 | kcontrol->private_value = (long)c; | 1498 | kcontrol->private_value = (long)c; |
1480 | mutex_unlock(&codec->spdif_mutex); | 1499 | mutex_unlock(&codec->control_mutex); |
1481 | return err; | 1500 | return err; |
1482 | } | 1501 | } |
1483 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_get); | 1502 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_get); |
@@ -1490,7 +1509,7 @@ int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, | |||
1490 | unsigned long *vals; | 1509 | unsigned long *vals; |
1491 | int err = 0, change = 0; | 1510 | int err = 0, change = 0; |
1492 | 1511 | ||
1493 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1512 | mutex_lock(&codec->control_mutex); |
1494 | c = (struct hda_bind_ctls *)kcontrol->private_value; | 1513 | c = (struct hda_bind_ctls *)kcontrol->private_value; |
1495 | for (vals = c->values; *vals; vals++) { | 1514 | for (vals = c->values; *vals; vals++) { |
1496 | kcontrol->private_value = *vals; | 1515 | kcontrol->private_value = *vals; |
@@ -1500,7 +1519,7 @@ int snd_hda_mixer_bind_ctls_put(struct snd_kcontrol *kcontrol, | |||
1500 | change |= err; | 1519 | change |= err; |
1501 | } | 1520 | } |
1502 | kcontrol->private_value = (long)c; | 1521 | kcontrol->private_value = (long)c; |
1503 | mutex_unlock(&codec->spdif_mutex); | 1522 | mutex_unlock(&codec->control_mutex); |
1504 | return err < 0 ? err : change; | 1523 | return err < 0 ? err : change; |
1505 | } | 1524 | } |
1506 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_put); | 1525 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_ctls_put); |
@@ -1512,12 +1531,12 @@ int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |||
1512 | struct hda_bind_ctls *c; | 1531 | struct hda_bind_ctls *c; |
1513 | int err; | 1532 | int err; |
1514 | 1533 | ||
1515 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1534 | mutex_lock(&codec->control_mutex); |
1516 | c = (struct hda_bind_ctls *)kcontrol->private_value; | 1535 | c = (struct hda_bind_ctls *)kcontrol->private_value; |
1517 | kcontrol->private_value = *c->values; | 1536 | kcontrol->private_value = *c->values; |
1518 | err = c->ops->tlv(kcontrol, op_flag, size, tlv); | 1537 | err = c->ops->tlv(kcontrol, op_flag, size, tlv); |
1519 | kcontrol->private_value = (long)c; | 1538 | kcontrol->private_value = (long)c; |
1520 | mutex_unlock(&codec->spdif_mutex); | 1539 | mutex_unlock(&codec->control_mutex); |
1521 | return err; | 1540 | return err; |
1522 | } | 1541 | } |
1523 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_tlv); | 1542 | EXPORT_SYMBOL_HDA(snd_hda_mixer_bind_tlv); |
@@ -2857,7 +2876,7 @@ void snd_hda_power_down(struct hda_codec *codec) | |||
2857 | return; | 2876 | return; |
2858 | if (power_save(codec)) { | 2877 | if (power_save(codec)) { |
2859 | codec->power_transition = 1; /* avoid reentrance */ | 2878 | codec->power_transition = 1; /* avoid reentrance */ |
2860 | schedule_delayed_work(&codec->power_work, | 2879 | queue_delayed_work(codec->bus->workq, &codec->power_work, |
2861 | msecs_to_jiffies(power_save(codec) * 1000)); | 2880 | msecs_to_jiffies(power_save(codec) * 1000)); |
2862 | } | 2881 | } |
2863 | } | 2882 | } |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 6612d0f20bc6..5810ef588402 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -614,8 +614,7 @@ struct hda_bus { | |||
614 | 614 | ||
615 | /* unsolicited event queue */ | 615 | /* unsolicited event queue */ |
616 | struct hda_bus_unsolicited *unsol; | 616 | struct hda_bus_unsolicited *unsol; |
617 | 617 | struct workqueue_struct *workq; /* common workqueue for codecs */ | |
618 | struct snd_info_entry *proc; | ||
619 | 618 | ||
620 | /* assigned PCMs */ | 619 | /* assigned PCMs */ |
621 | DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES); | 620 | DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES); |
@@ -773,6 +772,7 @@ struct hda_codec { | |||
773 | struct hda_cache_rec cmd_cache; /* cache for other commands */ | 772 | struct hda_cache_rec cmd_cache; /* cache for other commands */ |
774 | 773 | ||
775 | struct mutex spdif_mutex; | 774 | struct mutex spdif_mutex; |
775 | struct mutex control_mutex; | ||
776 | unsigned int spdif_status; /* IEC958 status bits */ | 776 | unsigned int spdif_status; /* IEC958 status bits */ |
777 | unsigned short spdif_ctls; /* SPDIF control bits */ | 777 | unsigned short spdif_ctls; /* SPDIF control bits */ |
778 | unsigned int spdif_in_enable; /* SPDIF input enable? */ | 778 | unsigned int spdif_in_enable; /* SPDIF input enable? */ |
@@ -795,6 +795,10 @@ struct hda_codec { | |||
795 | int power_count; /* current (global) power refcount */ | 795 | int power_count; /* current (global) power refcount */ |
796 | struct delayed_work power_work; /* delayed task for powerdown */ | 796 | struct delayed_work power_work; /* delayed task for powerdown */ |
797 | #endif | 797 | #endif |
798 | |||
799 | /* codec-specific additional proc output */ | ||
800 | void (*proc_widget_hook)(struct snd_info_buffer *buffer, | ||
801 | struct hda_codec *codec, hda_nid_t nid); | ||
798 | }; | 802 | }; |
799 | 803 | ||
800 | /* direction */ | 804 | /* direction */ |
@@ -809,7 +813,7 @@ enum { | |||
809 | int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, | 813 | int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, |
810 | struct hda_bus **busp); | 814 | struct hda_bus **busp); |
811 | int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, | 815 | int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, |
812 | struct hda_codec **codecp); | 816 | int do_init, struct hda_codec **codecp); |
813 | 817 | ||
814 | /* | 818 | /* |
815 | * low level functions | 819 | * low level functions |
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index f17ccd513350..11e791b965f6 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -58,6 +58,7 @@ static char *model[SNDRV_CARDS]; | |||
58 | static int position_fix[SNDRV_CARDS]; | 58 | static int position_fix[SNDRV_CARDS]; |
59 | static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; | 59 | static int bdl_pos_adj[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; |
60 | static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; | 60 | static int probe_mask[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS-1)] = -1}; |
61 | static int probe_only[SNDRV_CARDS]; | ||
61 | static int single_cmd; | 62 | static int single_cmd; |
62 | static int enable_msi; | 63 | static int enable_msi; |
63 | 64 | ||
@@ -76,6 +77,8 @@ module_param_array(bdl_pos_adj, int, NULL, 0644); | |||
76 | MODULE_PARM_DESC(bdl_pos_adj, "BDL position adjustment offset."); | 77 | MODULE_PARM_DESC(bdl_pos_adj, "BDL position adjustment offset."); |
77 | module_param_array(probe_mask, int, NULL, 0444); | 78 | module_param_array(probe_mask, int, NULL, 0444); |
78 | MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1)."); | 79 | MODULE_PARM_DESC(probe_mask, "Bitmask to probe codecs (default = -1)."); |
80 | module_param_array(probe_only, bool, NULL, 0444); | ||
81 | MODULE_PARM_DESC(probe_only, "Only probing and no codec initialization."); | ||
79 | module_param(single_cmd, bool, 0444); | 82 | module_param(single_cmd, bool, 0444); |
80 | MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs " | 83 | MODULE_PARM_DESC(single_cmd, "Use single command to communicate with codecs " |
81 | "(for debugging only)."); | 84 | "(for debugging only)."); |
@@ -993,10 +996,11 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) | |||
993 | spin_unlock(&chip->reg_lock); | 996 | spin_unlock(&chip->reg_lock); |
994 | snd_pcm_period_elapsed(azx_dev->substream); | 997 | snd_pcm_period_elapsed(azx_dev->substream); |
995 | spin_lock(&chip->reg_lock); | 998 | spin_lock(&chip->reg_lock); |
996 | } else { | 999 | } else if (chip->bus && chip->bus->workq) { |
997 | /* bogus IRQ, process it later */ | 1000 | /* bogus IRQ, process it later */ |
998 | azx_dev->irq_pending = 1; | 1001 | azx_dev->irq_pending = 1; |
999 | schedule_work(&chip->irq_pending_work); | 1002 | queue_work(chip->bus->workq, |
1003 | &chip->irq_pending_work); | ||
1000 | } | 1004 | } |
1001 | } | 1005 | } |
1002 | } | 1006 | } |
@@ -1224,7 +1228,8 @@ static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = { | |||
1224 | }; | 1228 | }; |
1225 | 1229 | ||
1226 | static int __devinit azx_codec_create(struct azx *chip, const char *model, | 1230 | static int __devinit azx_codec_create(struct azx *chip, const char *model, |
1227 | unsigned int codec_probe_mask) | 1231 | unsigned int codec_probe_mask, |
1232 | int no_init) | ||
1228 | { | 1233 | { |
1229 | struct hda_bus_template bus_temp; | 1234 | struct hda_bus_template bus_temp; |
1230 | int c, codecs, err; | 1235 | int c, codecs, err; |
@@ -1233,12 +1238,12 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model, | |||
1233 | memset(&bus_temp, 0, sizeof(bus_temp)); | 1238 | memset(&bus_temp, 0, sizeof(bus_temp)); |
1234 | bus_temp.private_data = chip; | 1239 | bus_temp.private_data = chip; |
1235 | bus_temp.modelname = model; | 1240 | bus_temp.modelname = model; |
1236 | bus_temp.power_save = &power_save; | ||
1237 | bus_temp.pci = chip->pci; | 1241 | bus_temp.pci = chip->pci; |
1238 | bus_temp.ops.command = azx_send_cmd; | 1242 | bus_temp.ops.command = azx_send_cmd; |
1239 | bus_temp.ops.get_response = azx_get_response; | 1243 | bus_temp.ops.get_response = azx_get_response; |
1240 | bus_temp.ops.attach_pcm = azx_attach_pcm_stream; | 1244 | bus_temp.ops.attach_pcm = azx_attach_pcm_stream; |
1241 | #ifdef CONFIG_SND_HDA_POWER_SAVE | 1245 | #ifdef CONFIG_SND_HDA_POWER_SAVE |
1246 | bus_temp.power_save = &power_save; | ||
1242 | bus_temp.ops.pm_notify = azx_power_notify; | 1247 | bus_temp.ops.pm_notify = azx_power_notify; |
1243 | #endif | 1248 | #endif |
1244 | 1249 | ||
@@ -1282,7 +1287,7 @@ static int __devinit azx_codec_create(struct azx *chip, const char *model, | |||
1282 | for (c = 0; c < max_slots; c++) { | 1287 | for (c = 0; c < max_slots; c++) { |
1283 | if ((chip->codec_mask & (1 << c)) & codec_probe_mask) { | 1288 | if ((chip->codec_mask & (1 << c)) & codec_probe_mask) { |
1284 | struct hda_codec *codec; | 1289 | struct hda_codec *codec; |
1285 | err = snd_hda_codec_new(chip->bus, c, &codec); | 1290 | err = snd_hda_codec_new(chip->bus, c, !no_init, &codec); |
1286 | if (err < 0) | 1291 | if (err < 0) |
1287 | continue; | 1292 | continue; |
1288 | codecs++; | 1293 | codecs++; |
@@ -1737,7 +1742,6 @@ static void azx_clear_irq_pending(struct azx *chip) | |||
1737 | for (i = 0; i < chip->num_streams; i++) | 1742 | for (i = 0; i < chip->num_streams; i++) |
1738 | chip->azx_dev[i].irq_pending = 0; | 1743 | chip->azx_dev[i].irq_pending = 0; |
1739 | spin_unlock_irq(&chip->reg_lock); | 1744 | spin_unlock_irq(&chip->reg_lock); |
1740 | flush_scheduled_work(); | ||
1741 | } | 1745 | } |
1742 | 1746 | ||
1743 | static struct snd_pcm_ops azx_pcm_ops = { | 1747 | static struct snd_pcm_ops azx_pcm_ops = { |
@@ -1900,6 +1904,12 @@ static void azx_power_notify(struct hda_bus *bus) | |||
1900 | else if (chip->running && power_save_controller) | 1904 | else if (chip->running && power_save_controller) |
1901 | azx_stop_chip(chip); | 1905 | azx_stop_chip(chip); |
1902 | } | 1906 | } |
1907 | #endif /* CONFIG_SND_HDA_POWER_SAVE */ | ||
1908 | |||
1909 | #ifdef CONFIG_PM | ||
1910 | /* | ||
1911 | * power management | ||
1912 | */ | ||
1903 | 1913 | ||
1904 | static int snd_hda_codecs_inuse(struct hda_bus *bus) | 1914 | static int snd_hda_codecs_inuse(struct hda_bus *bus) |
1905 | { | 1915 | { |
@@ -1911,14 +1921,7 @@ static int snd_hda_codecs_inuse(struct hda_bus *bus) | |||
1911 | } | 1921 | } |
1912 | return 0; | 1922 | return 0; |
1913 | } | 1923 | } |
1914 | #else /* !CONFIG_SND_HDA_POWER_SAVE */ | ||
1915 | #define snd_hda_codecs_inuse(bus) 1 | ||
1916 | #endif /* CONFIG_SND_HDA_POWER_SAVE */ | ||
1917 | 1924 | ||
1918 | #ifdef CONFIG_PM | ||
1919 | /* | ||
1920 | * power management | ||
1921 | */ | ||
1922 | static int azx_suspend(struct pci_dev *pci, pm_message_t state) | 1925 | static int azx_suspend(struct pci_dev *pci, pm_message_t state) |
1923 | { | 1926 | { |
1924 | struct snd_card *card = pci_get_drvdata(pci); | 1927 | struct snd_card *card = pci_get_drvdata(pci); |
@@ -1944,13 +1947,16 @@ static int azx_suspend(struct pci_dev *pci, pm_message_t state) | |||
1944 | return 0; | 1947 | return 0; |
1945 | } | 1948 | } |
1946 | 1949 | ||
1950 | static int azx_resume_early(struct pci_dev *pci) | ||
1951 | { | ||
1952 | return pci_restore_state(pci); | ||
1953 | } | ||
1954 | |||
1947 | static int azx_resume(struct pci_dev *pci) | 1955 | static int azx_resume(struct pci_dev *pci) |
1948 | { | 1956 | { |
1949 | struct snd_card *card = pci_get_drvdata(pci); | 1957 | struct snd_card *card = pci_get_drvdata(pci); |
1950 | struct azx *chip = card->private_data; | 1958 | struct azx *chip = card->private_data; |
1951 | 1959 | ||
1952 | pci_set_power_state(pci, PCI_D0); | ||
1953 | pci_restore_state(pci); | ||
1954 | if (pci_enable_device(pci) < 0) { | 1960 | if (pci_enable_device(pci) < 0) { |
1955 | printk(KERN_ERR "hda-intel: pci_enable_device failed, " | 1961 | printk(KERN_ERR "hda-intel: pci_enable_device failed, " |
1956 | "disabling device\n"); | 1962 | "disabling device\n"); |
@@ -2183,7 +2189,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
2183 | } | 2189 | } |
2184 | 2190 | ||
2185 | chip->addr = pci_resource_start(pci, 0); | 2191 | chip->addr = pci_resource_start(pci, 0); |
2186 | chip->remap_addr = ioremap_nocache(chip->addr, pci_resource_len(pci,0)); | 2192 | chip->remap_addr = pci_ioremap_bar(pci, 0); |
2187 | if (chip->remap_addr == NULL) { | 2193 | if (chip->remap_addr == NULL) { |
2188 | snd_printk(KERN_ERR SFX "ioremap error\n"); | 2194 | snd_printk(KERN_ERR SFX "ioremap error\n"); |
2189 | err = -ENXIO; | 2195 | err = -ENXIO; |
@@ -2341,7 +2347,8 @@ static int __devinit azx_probe(struct pci_dev *pci, | |||
2341 | card->private_data = chip; | 2347 | card->private_data = chip; |
2342 | 2348 | ||
2343 | /* create codec instances */ | 2349 | /* create codec instances */ |
2344 | err = azx_codec_create(chip, model[dev], probe_mask[dev]); | 2350 | err = azx_codec_create(chip, model[dev], probe_mask[dev], |
2351 | probe_only[dev]); | ||
2345 | if (err < 0) | 2352 | if (err < 0) |
2346 | goto out_free; | 2353 | goto out_free; |
2347 | 2354 | ||
@@ -2461,6 +2468,7 @@ static struct pci_driver driver = { | |||
2461 | .remove = __devexit_p(azx_remove), | 2468 | .remove = __devexit_p(azx_remove), |
2462 | #ifdef CONFIG_PM | 2469 | #ifdef CONFIG_PM |
2463 | .suspend = azx_suspend, | 2470 | .suspend = azx_suspend, |
2471 | .resume_early = azx_resume_early, | ||
2464 | .resume = azx_resume, | 2472 | .resume = azx_resume, |
2465 | #endif | 2473 | #endif |
2466 | }; | 2474 | }; |
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 9a8498456e6c..7ca66d654148 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c | |||
@@ -414,17 +414,6 @@ static void print_conn_list(struct snd_info_buffer *buffer, | |||
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | static void print_realtek_coef(struct snd_info_buffer *buffer, | ||
418 | struct hda_codec *codec, hda_nid_t nid) | ||
419 | { | ||
420 | int coeff = snd_hda_codec_read(codec, nid, 0, | ||
421 | AC_VERB_GET_PROC_COEF, 0); | ||
422 | snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff); | ||
423 | coeff = snd_hda_codec_read(codec, nid, 0, | ||
424 | AC_VERB_GET_COEF_INDEX, 0); | ||
425 | snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff); | ||
426 | } | ||
427 | |||
428 | static void print_gpio(struct snd_info_buffer *buffer, | 417 | static void print_gpio(struct snd_info_buffer *buffer, |
429 | struct hda_codec *codec, hda_nid_t nid) | 418 | struct hda_codec *codec, hda_nid_t nid) |
430 | { | 419 | { |
@@ -504,6 +493,8 @@ static void print_codec_info(struct snd_info_entry *entry, | |||
504 | } | 493 | } |
505 | 494 | ||
506 | print_gpio(buffer, codec, codec->afg); | 495 | print_gpio(buffer, codec, codec->afg); |
496 | if (codec->proc_widget_hook) | ||
497 | codec->proc_widget_hook(buffer, codec, codec->afg); | ||
507 | 498 | ||
508 | for (i = 0; i < nodes; i++, nid++) { | 499 | for (i = 0; i < nodes; i++, nid++) { |
509 | unsigned int wid_caps = | 500 | unsigned int wid_caps = |
@@ -606,9 +597,8 @@ static void print_codec_info(struct snd_info_entry *entry, | |||
606 | if (wid_caps & AC_WCAP_PROC_WID) | 597 | if (wid_caps & AC_WCAP_PROC_WID) |
607 | print_proc_caps(buffer, codec, nid); | 598 | print_proc_caps(buffer, codec, nid); |
608 | 599 | ||
609 | /* NID 0x20 == Realtek Define Registers */ | 600 | if (codec->proc_widget_hook) |
610 | if (codec->vendor_id == 0x10ec && nid == 0x20) | 601 | codec->proc_widget_hook(buffer, codec, nid); |
611 | print_realtek_coef(buffer, codec, nid); | ||
612 | } | 602 | } |
613 | snd_hda_power_down(codec); | 603 | snd_hda_power_down(codec); |
614 | } | 604 | } |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index c1918a1a6df9..2e7371ec2e23 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -3900,7 +3900,9 @@ static const char *ad1884a_models[AD1884A_MODELS] = { | |||
3900 | 3900 | ||
3901 | static struct snd_pci_quirk ad1884a_cfg_tbl[] = { | 3901 | static struct snd_pci_quirk ad1884a_cfg_tbl[] = { |
3902 | SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE), | 3902 | SND_PCI_QUIRK(0x103c, 0x3030, "HP", AD1884A_MOBILE), |
3903 | SND_PCI_QUIRK(0x103c, 0x3037, "HP 2230s", AD1884A_LAPTOP), | ||
3903 | SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), | 3904 | SND_PCI_QUIRK(0x103c, 0x3056, "HP", AD1884A_MOBILE), |
3905 | SND_PCI_QUIRK(0x103c, 0x30e6, "HP 6730b", AD1884A_LAPTOP), | ||
3904 | SND_PCI_QUIRK(0x103c, 0x30e7, "HP EliteBook 8530p", AD1884A_LAPTOP), | 3906 | SND_PCI_QUIRK(0x103c, 0x30e7, "HP EliteBook 8530p", AD1884A_LAPTOP), |
3905 | SND_PCI_QUIRK(0x103c, 0x3614, "HP 6730s", AD1884A_LAPTOP), | 3907 | SND_PCI_QUIRK(0x103c, 0x3614, "HP 6730s", AD1884A_LAPTOP), |
3906 | SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), | 3908 | SND_PCI_QUIRK(0x17aa, 0x20ac, "Thinkpad X300", AD1884A_THINKPAD), |
@@ -4261,13 +4263,13 @@ static int patch_ad1882(struct hda_codec *codec) | |||
4261 | spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids); | 4263 | spec->num_adc_nids = ARRAY_SIZE(ad1882_adc_nids); |
4262 | spec->adc_nids = ad1882_adc_nids; | 4264 | spec->adc_nids = ad1882_adc_nids; |
4263 | spec->capsrc_nids = ad1882_capsrc_nids; | 4265 | spec->capsrc_nids = ad1882_capsrc_nids; |
4264 | if (codec->vendor_id == 0x11d1882) | 4266 | if (codec->vendor_id == 0x11d41882) |
4265 | spec->input_mux = &ad1882_capture_source; | 4267 | spec->input_mux = &ad1882_capture_source; |
4266 | else | 4268 | else |
4267 | spec->input_mux = &ad1882a_capture_source; | 4269 | spec->input_mux = &ad1882a_capture_source; |
4268 | spec->num_mixers = 2; | 4270 | spec->num_mixers = 2; |
4269 | spec->mixers[0] = ad1882_base_mixers; | 4271 | spec->mixers[0] = ad1882_base_mixers; |
4270 | if (codec->vendor_id == 0x11d1882) | 4272 | if (codec->vendor_id == 0x11d41882) |
4271 | spec->mixers[1] = ad1882_loopback_mixers; | 4273 | spec->mixers[1] = ad1882_loopback_mixers; |
4272 | else | 4274 | else |
4273 | spec->mixers[1] = ad1882a_loopback_mixers; | 4275 | spec->mixers[1] = ad1882a_loopback_mixers; |
diff --git a/sound/pci/hda/patch_atihdmi.c b/sound/pci/hda/patch_atihdmi.c index 5887b827bb32..233e4778bba9 100644 --- a/sound/pci/hda/patch_atihdmi.c +++ b/sound/pci/hda/patch_atihdmi.c | |||
@@ -187,10 +187,10 @@ static int patch_atihdmi(struct hda_codec *codec) | |||
187 | * patch entries | 187 | * patch entries |
188 | */ | 188 | */ |
189 | static struct hda_codec_preset snd_hda_preset_atihdmi[] = { | 189 | static struct hda_codec_preset snd_hda_preset_atihdmi[] = { |
190 | { .id = 0x1002793c, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, | 190 | { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi }, |
191 | { .id = 0x10027919, .name = "ATI RS600 HDMI", .patch = patch_atihdmi }, | 191 | { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi }, |
192 | { .id = 0x1002791a, .name = "ATI RS690/780 HDMI", .patch = patch_atihdmi }, | 192 | { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi }, |
193 | { .id = 0x1002aa01, .name = "ATI R6xx HDMI", .patch = patch_atihdmi }, | 193 | { .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_atihdmi }, |
194 | { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_atihdmi }, | 194 | { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_atihdmi }, |
195 | { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_atihdmi }, | 195 | { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_atihdmi }, |
196 | {} /* terminator */ | 196 | {} /* terminator */ |
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index b20e1cede00b..75de40aaab0a 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/pci.h> | 26 | #include <linux/pci.h> |
27 | #include <sound/core.h> | 27 | #include <sound/core.h> |
28 | #include <sound/jack.h> | ||
29 | |||
28 | #include "hda_codec.h" | 30 | #include "hda_codec.h" |
29 | #include "hda_local.h" | 31 | #include "hda_local.h" |
30 | 32 | ||
@@ -37,8 +39,21 @@ | |||
37 | #define CONEXANT_HP_EVENT 0x37 | 39 | #define CONEXANT_HP_EVENT 0x37 |
38 | #define CONEXANT_MIC_EVENT 0x38 | 40 | #define CONEXANT_MIC_EVENT 0x38 |
39 | 41 | ||
42 | /* Conexant 5051 specific */ | ||
43 | |||
44 | #define CXT5051_SPDIF_OUT 0x1C | ||
45 | #define CXT5051_PORTB_EVENT 0x38 | ||
46 | #define CXT5051_PORTC_EVENT 0x39 | ||
40 | 47 | ||
41 | 48 | ||
49 | struct conexant_jack { | ||
50 | |||
51 | hda_nid_t nid; | ||
52 | int type; | ||
53 | struct snd_jack *jack; | ||
54 | |||
55 | }; | ||
56 | |||
42 | struct conexant_spec { | 57 | struct conexant_spec { |
43 | 58 | ||
44 | struct snd_kcontrol_new *mixers[5]; | 59 | struct snd_kcontrol_new *mixers[5]; |
@@ -83,6 +98,9 @@ struct conexant_spec { | |||
83 | 98 | ||
84 | unsigned int spdif_route; | 99 | unsigned int spdif_route; |
85 | 100 | ||
101 | /* jack detection */ | ||
102 | struct snd_array jacks; | ||
103 | |||
86 | /* dynamic controls, init_verbs and input_mux */ | 104 | /* dynamic controls, init_verbs and input_mux */ |
87 | struct auto_pin_cfg autocfg; | 105 | struct auto_pin_cfg autocfg; |
88 | struct hda_input_mux private_imux; | 106 | struct hda_input_mux private_imux; |
@@ -329,6 +347,86 @@ static int conexant_mux_enum_put(struct snd_kcontrol *kcontrol, | |||
329 | &spec->cur_mux[adc_idx]); | 347 | &spec->cur_mux[adc_idx]); |
330 | } | 348 | } |
331 | 349 | ||
350 | static int conexant_add_jack(struct hda_codec *codec, | ||
351 | hda_nid_t nid, int type) | ||
352 | { | ||
353 | struct conexant_spec *spec; | ||
354 | struct conexant_jack *jack; | ||
355 | const char *name; | ||
356 | |||
357 | spec = codec->spec; | ||
358 | snd_array_init(&spec->jacks, sizeof(*jack), 32); | ||
359 | jack = snd_array_new(&spec->jacks); | ||
360 | name = (type == SND_JACK_HEADPHONE) ? "Headphone" : "Mic" ; | ||
361 | |||
362 | if (!jack) | ||
363 | return -ENOMEM; | ||
364 | |||
365 | jack->nid = nid; | ||
366 | jack->type = type; | ||
367 | |||
368 | return snd_jack_new(codec->bus->card, name, type, &jack->jack); | ||
369 | } | ||
370 | |||
371 | static void conexant_report_jack(struct hda_codec *codec, hda_nid_t nid) | ||
372 | { | ||
373 | struct conexant_spec *spec = codec->spec; | ||
374 | struct conexant_jack *jacks = spec->jacks.list; | ||
375 | |||
376 | if (jacks) { | ||
377 | int i; | ||
378 | for (i = 0; i < spec->jacks.used; i++) { | ||
379 | if (jacks->nid == nid) { | ||
380 | unsigned int present; | ||
381 | present = snd_hda_codec_read(codec, nid, 0, | ||
382 | AC_VERB_GET_PIN_SENSE, 0) & | ||
383 | AC_PINSENSE_PRESENCE; | ||
384 | |||
385 | present = (present) ? jacks->type : 0 ; | ||
386 | |||
387 | snd_jack_report(jacks->jack, | ||
388 | present); | ||
389 | } | ||
390 | jacks++; | ||
391 | } | ||
392 | } | ||
393 | } | ||
394 | |||
395 | static int conexant_init_jacks(struct hda_codec *codec) | ||
396 | { | ||
397 | #ifdef CONFIG_SND_JACK | ||
398 | struct conexant_spec *spec = codec->spec; | ||
399 | int i; | ||
400 | |||
401 | for (i = 0; i < spec->num_init_verbs; i++) { | ||
402 | const struct hda_verb *hv; | ||
403 | |||
404 | hv = spec->init_verbs[i]; | ||
405 | while (hv->nid) { | ||
406 | int err = 0; | ||
407 | switch (hv->param ^ AC_USRSP_EN) { | ||
408 | case CONEXANT_HP_EVENT: | ||
409 | err = conexant_add_jack(codec, hv->nid, | ||
410 | SND_JACK_HEADPHONE); | ||
411 | conexant_report_jack(codec, hv->nid); | ||
412 | break; | ||
413 | case CXT5051_PORTC_EVENT: | ||
414 | case CONEXANT_MIC_EVENT: | ||
415 | err = conexant_add_jack(codec, hv->nid, | ||
416 | SND_JACK_MICROPHONE); | ||
417 | conexant_report_jack(codec, hv->nid); | ||
418 | break; | ||
419 | } | ||
420 | if (err < 0) | ||
421 | return err; | ||
422 | ++hv; | ||
423 | } | ||
424 | } | ||
425 | #endif | ||
426 | return 0; | ||
427 | |||
428 | } | ||
429 | |||
332 | static int conexant_init(struct hda_codec *codec) | 430 | static int conexant_init(struct hda_codec *codec) |
333 | { | 431 | { |
334 | struct conexant_spec *spec = codec->spec; | 432 | struct conexant_spec *spec = codec->spec; |
@@ -341,6 +439,16 @@ static int conexant_init(struct hda_codec *codec) | |||
341 | 439 | ||
342 | static void conexant_free(struct hda_codec *codec) | 440 | static void conexant_free(struct hda_codec *codec) |
343 | { | 441 | { |
442 | #ifdef CONFIG_SND_JACK | ||
443 | struct conexant_spec *spec = codec->spec; | ||
444 | if (spec->jacks.list) { | ||
445 | struct conexant_jack *jacks = spec->jacks.list; | ||
446 | int i; | ||
447 | for (i = 0; i < spec->jacks.used; i++) | ||
448 | snd_device_free(codec->bus->card, &jacks[i].jack); | ||
449 | snd_array_free(&spec->jacks); | ||
450 | } | ||
451 | #endif | ||
344 | kfree(codec->spec); | 452 | kfree(codec->spec); |
345 | } | 453 | } |
346 | 454 | ||
@@ -1526,9 +1634,6 @@ static int patch_cxt5047(struct hda_codec *codec) | |||
1526 | /* Conexant 5051 specific */ | 1634 | /* Conexant 5051 specific */ |
1527 | static hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; | 1635 | static hda_nid_t cxt5051_dac_nids[1] = { 0x10 }; |
1528 | static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; | 1636 | static hda_nid_t cxt5051_adc_nids[2] = { 0x14, 0x15 }; |
1529 | #define CXT5051_SPDIF_OUT 0x1C | ||
1530 | #define CXT5051_PORTB_EVENT 0x38 | ||
1531 | #define CXT5051_PORTC_EVENT 0x39 | ||
1532 | 1637 | ||
1533 | static struct hda_channel_mode cxt5051_modes[1] = { | 1638 | static struct hda_channel_mode cxt5051_modes[1] = { |
1534 | { 2, NULL }, | 1639 | { 2, NULL }, |
@@ -1608,6 +1713,7 @@ static void cxt5051_hp_automute(struct hda_codec *codec) | |||
1608 | static void cxt5051_hp_unsol_event(struct hda_codec *codec, | 1713 | static void cxt5051_hp_unsol_event(struct hda_codec *codec, |
1609 | unsigned int res) | 1714 | unsigned int res) |
1610 | { | 1715 | { |
1716 | int nid = (res & AC_UNSOL_RES_SUBTAG) >> 20; | ||
1611 | switch (res >> 26) { | 1717 | switch (res >> 26) { |
1612 | case CONEXANT_HP_EVENT: | 1718 | case CONEXANT_HP_EVENT: |
1613 | cxt5051_hp_automute(codec); | 1719 | cxt5051_hp_automute(codec); |
@@ -1619,6 +1725,7 @@ static void cxt5051_hp_unsol_event(struct hda_codec *codec, | |||
1619 | cxt5051_portc_automic(codec); | 1725 | cxt5051_portc_automic(codec); |
1620 | break; | 1726 | break; |
1621 | } | 1727 | } |
1728 | conexant_report_jack(codec, nid); | ||
1622 | } | 1729 | } |
1623 | 1730 | ||
1624 | static struct snd_kcontrol_new cxt5051_mixers[] = { | 1731 | static struct snd_kcontrol_new cxt5051_mixers[] = { |
@@ -1693,6 +1800,7 @@ static struct hda_verb cxt5051_init_verbs[] = { | |||
1693 | static int cxt5051_init(struct hda_codec *codec) | 1800 | static int cxt5051_init(struct hda_codec *codec) |
1694 | { | 1801 | { |
1695 | conexant_init(codec); | 1802 | conexant_init(codec); |
1803 | conexant_init_jacks(codec); | ||
1696 | if (codec->patch_ops.unsol_event) { | 1804 | if (codec->patch_ops.unsol_event) { |
1697 | cxt5051_hp_automute(codec); | 1805 | cxt5051_hp_automute(codec); |
1698 | cxt5051_portb_automic(codec); | 1806 | cxt5051_portb_automic(codec); |
diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c index 290da562f29b..3564f4e4b74c 100644 --- a/sound/pci/hda/patch_intelhdmi.c +++ b/sound/pci/hda/patch_intelhdmi.c | |||
@@ -675,10 +675,10 @@ static int patch_intel_hdmi(struct hda_codec *codec) | |||
675 | } | 675 | } |
676 | 676 | ||
677 | static struct hda_codec_preset snd_hda_preset_intelhdmi[] = { | 677 | static struct hda_codec_preset snd_hda_preset_intelhdmi[] = { |
678 | { .id = 0x808629fb, .name = "INTEL G45 DEVCL", .patch = patch_intel_hdmi }, | 678 | { .id = 0x808629fb, .name = "G45 DEVCL", .patch = patch_intel_hdmi }, |
679 | { .id = 0x80862801, .name = "INTEL G45 DEVBLC", .patch = patch_intel_hdmi }, | 679 | { .id = 0x80862801, .name = "G45 DEVBLC", .patch = patch_intel_hdmi }, |
680 | { .id = 0x80862802, .name = "INTEL G45 DEVCTG", .patch = patch_intel_hdmi }, | 680 | { .id = 0x80862802, .name = "G45 DEVCTG", .patch = patch_intel_hdmi }, |
681 | { .id = 0x80862803, .name = "INTEL G45 DEVELK", .patch = patch_intel_hdmi }, | 681 | { .id = 0x80862803, .name = "G45 DEVELK", .patch = patch_intel_hdmi }, |
682 | { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, | 682 | { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_intel_hdmi }, |
683 | {} /* terminator */ | 683 | {} /* terminator */ |
684 | }; | 684 | }; |
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c index e23de5594b6e..d57d8132a06e 100644 --- a/sound/pci/hda/patch_nvhdmi.c +++ b/sound/pci/hda/patch_nvhdmi.c | |||
@@ -159,13 +159,19 @@ static int patch_nvhdmi(struct hda_codec *codec) | |||
159 | * patch entries | 159 | * patch entries |
160 | */ | 160 | */ |
161 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { | 161 | static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { |
162 | { .id = 0x10de0002, .name = "NVIDIA MCP78 HDMI", .patch = patch_nvhdmi }, | 162 | { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi }, |
163 | { .id = 0x10de0007, .name = "NVIDIA MCP7A HDMI", .patch = patch_nvhdmi }, | 163 | { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi }, |
164 | { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi }, | ||
165 | { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi }, | ||
166 | { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi }, | ||
164 | {} /* terminator */ | 167 | {} /* terminator */ |
165 | }; | 168 | }; |
166 | 169 | ||
167 | MODULE_ALIAS("snd-hda-codec-id:10de0002"); | 170 | MODULE_ALIAS("snd-hda-codec-id:10de0002"); |
171 | MODULE_ALIAS("snd-hda-codec-id:10de0006"); | ||
168 | MODULE_ALIAS("snd-hda-codec-id:10de0007"); | 172 | MODULE_ALIAS("snd-hda-codec-id:10de0007"); |
173 | MODULE_ALIAS("snd-hda-codec-id:10de0067"); | ||
174 | MODULE_ALIAS("snd-hda-codec-id:10de8001"); | ||
169 | 175 | ||
170 | MODULE_LICENSE("GPL"); | 176 | MODULE_LICENSE("GPL"); |
171 | MODULE_DESCRIPTION("Nvidia HDMI HD-audio codec"); | 177 | MODULE_DESCRIPTION("Nvidia HDMI HD-audio codec"); |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index ba640d36d648..ea4c88fe05c4 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -765,6 +765,27 @@ static void add_verb(struct alc_spec *spec, const struct hda_verb *verb) | |||
765 | spec->init_verbs[spec->num_init_verbs++] = verb; | 765 | spec->init_verbs[spec->num_init_verbs++] = verb; |
766 | } | 766 | } |
767 | 767 | ||
768 | #ifdef CONFIG_PROC_FS | ||
769 | /* | ||
770 | * hook for proc | ||
771 | */ | ||
772 | static void print_realtek_coef(struct snd_info_buffer *buffer, | ||
773 | struct hda_codec *codec, hda_nid_t nid) | ||
774 | { | ||
775 | int coeff; | ||
776 | |||
777 | if (nid != 0x20) | ||
778 | return; | ||
779 | coeff = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PROC_COEF, 0); | ||
780 | snd_iprintf(buffer, " Processing Coefficient: 0x%02x\n", coeff); | ||
781 | coeff = snd_hda_codec_read(codec, nid, 0, | ||
782 | AC_VERB_GET_COEF_INDEX, 0); | ||
783 | snd_iprintf(buffer, " Coefficient Index: 0x%02x\n", coeff); | ||
784 | } | ||
785 | #else | ||
786 | #define print_realtek_coef NULL | ||
787 | #endif | ||
788 | |||
768 | /* | 789 | /* |
769 | * set up from the preset table | 790 | * set up from the preset table |
770 | */ | 791 | */ |
@@ -1481,11 +1502,11 @@ static int alc_cap_vol_info(struct snd_kcontrol *kcontrol, | |||
1481 | struct alc_spec *spec = codec->spec; | 1502 | struct alc_spec *spec = codec->spec; |
1482 | int err; | 1503 | int err; |
1483 | 1504 | ||
1484 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1505 | mutex_lock(&codec->control_mutex); |
1485 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, | 1506 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, |
1486 | HDA_INPUT); | 1507 | HDA_INPUT); |
1487 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); | 1508 | err = snd_hda_mixer_amp_volume_info(kcontrol, uinfo); |
1488 | mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1509 | mutex_unlock(&codec->control_mutex); |
1489 | return err; | 1510 | return err; |
1490 | } | 1511 | } |
1491 | 1512 | ||
@@ -1496,11 +1517,11 @@ static int alc_cap_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag, | |||
1496 | struct alc_spec *spec = codec->spec; | 1517 | struct alc_spec *spec = codec->spec; |
1497 | int err; | 1518 | int err; |
1498 | 1519 | ||
1499 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1520 | mutex_lock(&codec->control_mutex); |
1500 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, | 1521 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[0], 3, 0, |
1501 | HDA_INPUT); | 1522 | HDA_INPUT); |
1502 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); | 1523 | err = snd_hda_mixer_amp_tlv(kcontrol, op_flag, size, tlv); |
1503 | mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1524 | mutex_unlock(&codec->control_mutex); |
1504 | return err; | 1525 | return err; |
1505 | } | 1526 | } |
1506 | 1527 | ||
@@ -1516,11 +1537,11 @@ static int alc_cap_getput_caller(struct snd_kcontrol *kcontrol, | |||
1516 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); | 1537 | unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); |
1517 | int err; | 1538 | int err; |
1518 | 1539 | ||
1519 | mutex_lock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1540 | mutex_lock(&codec->control_mutex); |
1520 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx], | 1541 | kcontrol->private_value = HDA_COMPOSE_AMP_VAL(spec->adc_nids[adc_idx], |
1521 | 3, 0, HDA_INPUT); | 1542 | 3, 0, HDA_INPUT); |
1522 | err = func(kcontrol, ucontrol); | 1543 | err = func(kcontrol, ucontrol); |
1523 | mutex_unlock(&codec->spdif_mutex); /* reuse spdif_mutex */ | 1544 | mutex_unlock(&codec->control_mutex); |
1524 | return err; | 1545 | return err; |
1525 | } | 1546 | } |
1526 | 1547 | ||
@@ -4343,6 +4364,7 @@ static int patch_alc880(struct hda_codec *codec) | |||
4343 | if (!spec->loopback.amplist) | 4364 | if (!spec->loopback.amplist) |
4344 | spec->loopback.amplist = alc880_loopbacks; | 4365 | spec->loopback.amplist = alc880_loopbacks; |
4345 | #endif | 4366 | #endif |
4367 | codec->proc_widget_hook = print_realtek_coef; | ||
4346 | 4368 | ||
4347 | return 0; | 4369 | return 0; |
4348 | } | 4370 | } |
@@ -5868,6 +5890,7 @@ static int patch_alc260(struct hda_codec *codec) | |||
5868 | if (!spec->loopback.amplist) | 5890 | if (!spec->loopback.amplist) |
5869 | spec->loopback.amplist = alc260_loopbacks; | 5891 | spec->loopback.amplist = alc260_loopbacks; |
5870 | #endif | 5892 | #endif |
5893 | codec->proc_widget_hook = print_realtek_coef; | ||
5871 | 5894 | ||
5872 | return 0; | 5895 | return 0; |
5873 | } | 5896 | } |
@@ -7073,6 +7096,7 @@ static int patch_alc882(struct hda_codec *codec) | |||
7073 | if (!spec->loopback.amplist) | 7096 | if (!spec->loopback.amplist) |
7074 | spec->loopback.amplist = alc882_loopbacks; | 7097 | spec->loopback.amplist = alc882_loopbacks; |
7075 | #endif | 7098 | #endif |
7099 | codec->proc_widget_hook = print_realtek_coef; | ||
7076 | 7100 | ||
7077 | return 0; | 7101 | return 0; |
7078 | } | 7102 | } |
@@ -8437,12 +8461,17 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
8437 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), | 8461 | SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_ACER_ASPIRE), |
8438 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", | 8462 | SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G", |
8439 | ALC888_ACER_ASPIRE_4930G), | 8463 | ALC888_ACER_ASPIRE_4930G), |
8464 | SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G", | ||
8465 | ALC888_ACER_ASPIRE_4930G), | ||
8466 | SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G", | ||
8467 | ALC888_ACER_ASPIRE_4930G), | ||
8440 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ | 8468 | SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER), /* default Acer */ |
8441 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), | 8469 | SND_PCI_QUIRK(0x1028, 0x020d, "Dell Inspiron 530", ALC888_6ST_DELL), |
8442 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), | 8470 | SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG), |
8443 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), | 8471 | SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP), |
8444 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), | 8472 | SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP), |
8445 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), | 8473 | SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC883_6ST_DIG), |
8474 | SND_PCI_QUIRK(0x103c, 0x2a66, "HP Acacia", ALC888_3ST_HP), | ||
8446 | SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), | 8475 | SND_PCI_QUIRK(0x1043, 0x1873, "Asus M90V", ALC888_ASUS_M90V), |
8447 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), | 8476 | SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG), |
8448 | SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), | 8477 | SND_PCI_QUIRK(0x1043, 0x82fe, "Asus P5Q-EM HDMI", ALC1200_ASUS_P5Q), |
@@ -8497,6 +8526,7 @@ static struct snd_pci_quirk alc883_cfg_tbl[] = { | |||
8497 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), | 8526 | SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66), |
8498 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), | 8527 | SND_PCI_QUIRK(0x8086, 0x0001, "DG33BUC", ALC883_3ST_6ch_INTEL), |
8499 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), | 8528 | SND_PCI_QUIRK(0x8086, 0x0002, "DG33FBC", ALC883_3ST_6ch_INTEL), |
8529 | SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC883_3ST_6ch_INTEL), | ||
8500 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), | 8530 | SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch), |
8501 | {} | 8531 | {} |
8502 | }; | 8532 | }; |
@@ -9041,6 +9071,7 @@ static int patch_alc883(struct hda_codec *codec) | |||
9041 | if (!spec->loopback.amplist) | 9071 | if (!spec->loopback.amplist) |
9042 | spec->loopback.amplist = alc883_loopbacks; | 9072 | spec->loopback.amplist = alc883_loopbacks; |
9043 | #endif | 9073 | #endif |
9074 | codec->proc_widget_hook = print_realtek_coef; | ||
9044 | 9075 | ||
9045 | return 0; | 9076 | return 0; |
9046 | } | 9077 | } |
@@ -10533,6 +10564,8 @@ static struct snd_pci_quirk alc262_cfg_tbl[] = { | |||
10533 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), | 10564 | SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
10534 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), | 10565 | SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD), |
10535 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), | 10566 | SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD), |
10567 | SND_PCI_QUIRK(0x104d, 0x9033, "Sony VAIO VGN-SR19XN", | ||
10568 | ALC262_SONY_ASSAMD), | ||
10536 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", | 10569 | SND_PCI_QUIRK(0x1179, 0x0001, "Toshiba dynabook SS RX1", |
10537 | ALC262_TOSHIBA_RX1), | 10570 | ALC262_TOSHIBA_RX1), |
10538 | SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), | 10571 | SND_PCI_QUIRK(0x1179, 0xff7b, "Toshiba S06", ALC262_TOSHIBA_S06), |
@@ -10847,6 +10880,7 @@ static int patch_alc262(struct hda_codec *codec) | |||
10847 | if (!spec->loopback.amplist) | 10880 | if (!spec->loopback.amplist) |
10848 | spec->loopback.amplist = alc262_loopbacks; | 10881 | spec->loopback.amplist = alc262_loopbacks; |
10849 | #endif | 10882 | #endif |
10883 | codec->proc_widget_hook = print_realtek_coef; | ||
10850 | 10884 | ||
10851 | return 0; | 10885 | return 0; |
10852 | } | 10886 | } |
@@ -11660,6 +11694,7 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = { | |||
11660 | SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One", | 11694 | SND_PCI_QUIRK(0x1025, 0x015b, "Acer Aspire One", |
11661 | ALC268_ACER_ASPIRE_ONE), | 11695 | ALC268_ACER_ASPIRE_ONE), |
11662 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), | 11696 | SND_PCI_QUIRK(0x1028, 0x0253, "Dell OEM", ALC268_DELL), |
11697 | SND_PCI_QUIRK(0x1028, 0x02b0, "Dell Inspiron Mini9", ALC268_DELL), | ||
11663 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), | 11698 | SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA), |
11664 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), | 11699 | SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), |
11665 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), | 11700 | SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA), |
@@ -11912,6 +11947,8 @@ static int patch_alc268(struct hda_codec *codec) | |||
11912 | if (board_config == ALC268_AUTO) | 11947 | if (board_config == ALC268_AUTO) |
11913 | spec->init_hook = alc268_auto_init; | 11948 | spec->init_hook = alc268_auto_init; |
11914 | 11949 | ||
11950 | codec->proc_widget_hook = print_realtek_coef; | ||
11951 | |||
11915 | return 0; | 11952 | return 0; |
11916 | } | 11953 | } |
11917 | 11954 | ||
@@ -12713,6 +12750,7 @@ static int patch_alc269(struct hda_codec *codec) | |||
12713 | if (!spec->loopback.amplist) | 12750 | if (!spec->loopback.amplist) |
12714 | spec->loopback.amplist = alc269_loopbacks; | 12751 | spec->loopback.amplist = alc269_loopbacks; |
12715 | #endif | 12752 | #endif |
12753 | codec->proc_widget_hook = print_realtek_coef; | ||
12716 | 12754 | ||
12717 | return 0; | 12755 | return 0; |
12718 | } | 12756 | } |
@@ -13801,6 +13839,7 @@ static int patch_alc861(struct hda_codec *codec) | |||
13801 | if (!spec->loopback.amplist) | 13839 | if (!spec->loopback.amplist) |
13802 | spec->loopback.amplist = alc861_loopbacks; | 13840 | spec->loopback.amplist = alc861_loopbacks; |
13803 | #endif | 13841 | #endif |
13842 | codec->proc_widget_hook = print_realtek_coef; | ||
13804 | 13843 | ||
13805 | return 0; | 13844 | return 0; |
13806 | } | 13845 | } |
@@ -14762,6 +14801,7 @@ static int patch_alc861vd(struct hda_codec *codec) | |||
14762 | if (!spec->loopback.amplist) | 14801 | if (!spec->loopback.amplist) |
14763 | spec->loopback.amplist = alc861vd_loopbacks; | 14802 | spec->loopback.amplist = alc861vd_loopbacks; |
14764 | #endif | 14803 | #endif |
14804 | codec->proc_widget_hook = print_realtek_coef; | ||
14765 | 14805 | ||
14766 | return 0; | 14806 | return 0; |
14767 | } | 14807 | } |
@@ -16571,6 +16611,7 @@ static int patch_alc662(struct hda_codec *codec) | |||
16571 | if (!spec->loopback.amplist) | 16611 | if (!spec->loopback.amplist) |
16572 | spec->loopback.amplist = alc662_loopbacks; | 16612 | spec->loopback.amplist = alc662_loopbacks; |
16573 | #endif | 16613 | #endif |
16614 | codec->proc_widget_hook = print_realtek_coef; | ||
16574 | 16615 | ||
16575 | return 0; | 16616 | return 0; |
16576 | } | 16617 | } |
@@ -16604,9 +16645,9 @@ static struct hda_codec_preset snd_hda_preset_realtek[] = { | |||
16604 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ | 16645 | .patch = patch_alc882 }, /* should be patch_alc883() in future */ |
16605 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, | 16646 | { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 }, |
16606 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, | 16647 | { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc883 }, |
16607 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, | ||
16608 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", | 16648 | { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200", |
16609 | .patch = patch_alc883 }, | 16649 | .patch = patch_alc883 }, |
16650 | { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 }, | ||
16610 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, | 16651 | { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 }, |
16611 | {} /* terminator */ | 16652 | {} /* terminator */ |
16612 | }; | 16653 | }; |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index c05d4643afd5..0e6fc56fa378 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -70,6 +70,7 @@ enum { | |||
70 | }; | 70 | }; |
71 | 71 | ||
72 | enum { | 72 | enum { |
73 | STAC_92HD73XX_NO_JD, /* no jack-detection */ | ||
73 | STAC_92HD73XX_REF, | 74 | STAC_92HD73XX_REF, |
74 | STAC_DELL_M6_AMIC, | 75 | STAC_DELL_M6_AMIC, |
75 | STAC_DELL_M6_DMIC, | 76 | STAC_DELL_M6_DMIC, |
@@ -132,6 +133,7 @@ enum { | |||
132 | }; | 133 | }; |
133 | 134 | ||
134 | enum { | 135 | enum { |
136 | STAC_D965_REF_NO_JD, /* no jack-detection */ | ||
135 | STAC_D965_REF, | 137 | STAC_D965_REF, |
136 | STAC_D965_3ST, | 138 | STAC_D965_3ST, |
137 | STAC_D965_5ST, | 139 | STAC_D965_5ST, |
@@ -160,8 +162,6 @@ struct sigmatel_spec { | |||
160 | int board_config; | 162 | int board_config; |
161 | unsigned int eapd_switch: 1; | 163 | unsigned int eapd_switch: 1; |
162 | unsigned int surr_switch: 1; | 164 | unsigned int surr_switch: 1; |
163 | unsigned int line_switch: 1; | ||
164 | unsigned int mic_switch: 1; | ||
165 | unsigned int alt_switch: 1; | 165 | unsigned int alt_switch: 1; |
166 | unsigned int hp_detect: 1; | 166 | unsigned int hp_detect: 1; |
167 | unsigned int spdif_mute: 1; | 167 | unsigned int spdif_mute: 1; |
@@ -198,6 +198,8 @@ struct sigmatel_spec { | |||
198 | unsigned int cur_mmux; | 198 | unsigned int cur_mmux; |
199 | struct hda_multi_out multiout; | 199 | struct hda_multi_out multiout; |
200 | hda_nid_t dac_nids[5]; | 200 | hda_nid_t dac_nids[5]; |
201 | hda_nid_t hp_dacs[5]; | ||
202 | hda_nid_t speaker_dacs[5]; | ||
201 | 203 | ||
202 | /* capture */ | 204 | /* capture */ |
203 | hda_nid_t *adc_nids; | 205 | hda_nid_t *adc_nids; |
@@ -241,7 +243,9 @@ struct sigmatel_spec { | |||
241 | /* i/o switches */ | 243 | /* i/o switches */ |
242 | unsigned int io_switch[2]; | 244 | unsigned int io_switch[2]; |
243 | unsigned int clfe_swap; | 245 | unsigned int clfe_swap; |
244 | unsigned int hp_switch; /* NID of HP as line-out */ | 246 | hda_nid_t line_switch; /* shared line-in for input and output */ |
247 | hda_nid_t mic_switch; /* shared mic-in for input and output */ | ||
248 | hda_nid_t hp_switch; /* NID of HP as line-out */ | ||
245 | unsigned int aloopback; | 249 | unsigned int aloopback; |
246 | 250 | ||
247 | struct hda_pcm pcm_rec[2]; /* PCM information */ | 251 | struct hda_pcm pcm_rec[2]; /* PCM information */ |
@@ -292,9 +296,6 @@ static hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = { | |||
292 | }; | 296 | }; |
293 | 297 | ||
294 | #define STAC92HD73_DAC_COUNT 5 | 298 | #define STAC92HD73_DAC_COUNT 5 |
295 | static hda_nid_t stac92hd73xx_dac_nids[STAC92HD73_DAC_COUNT] = { | ||
296 | 0x15, 0x16, 0x17, 0x18, 0x19, | ||
297 | }; | ||
298 | 299 | ||
299 | static hda_nid_t stac92hd73xx_mux_nids[4] = { | 300 | static hda_nid_t stac92hd73xx_mux_nids[4] = { |
300 | 0x28, 0x29, 0x2a, 0x2b, | 301 | 0x28, 0x29, 0x2a, 0x2b, |
@@ -313,11 +314,7 @@ static hda_nid_t stac92hd83xxx_dmic_nids[STAC92HD83XXX_NUM_DMICS + 1] = { | |||
313 | 0x11, 0x12, 0 | 314 | 0x11, 0x12, 0 |
314 | }; | 315 | }; |
315 | 316 | ||
316 | #define STAC92HD81_DAC_COUNT 2 | ||
317 | #define STAC92HD83_DAC_COUNT 3 | 317 | #define STAC92HD83_DAC_COUNT 3 |
318 | static hda_nid_t stac92hd83xxx_dac_nids[STAC92HD73_DAC_COUNT] = { | ||
319 | 0x13, 0x14, 0x22, | ||
320 | }; | ||
321 | 318 | ||
322 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { | 319 | static hda_nid_t stac92hd83xxx_dmux_nids[2] = { |
323 | 0x17, 0x18, | 320 | 0x17, 0x18, |
@@ -359,10 +356,6 @@ static hda_nid_t stac92hd71bxx_smux_nids[2] = { | |||
359 | 0x24, 0x25, | 356 | 0x24, 0x25, |
360 | }; | 357 | }; |
361 | 358 | ||
362 | static hda_nid_t stac92hd71bxx_dac_nids[1] = { | ||
363 | 0x10, /*0x11, */ | ||
364 | }; | ||
365 | |||
366 | #define STAC92HD71BXX_NUM_DMICS 2 | 359 | #define STAC92HD71BXX_NUM_DMICS 2 |
367 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { | 360 | static hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = { |
368 | 0x18, 0x19, 0 | 361 | 0x18, 0x19, 0 |
@@ -594,12 +587,12 @@ static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol, | |||
594 | else | 587 | else |
595 | nid = codec->slave_dig_outs[smux_idx - 1]; | 588 | nid = codec->slave_dig_outs[smux_idx - 1]; |
596 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) | 589 | if (spec->cur_smux[smux_idx] == smux->num_items - 1) |
597 | val = AMP_OUT_MUTE; | 590 | val = HDA_AMP_MUTE; |
598 | else | 591 | else |
599 | val = AMP_OUT_UNMUTE; | 592 | val = 0; |
600 | /* un/mute SPDIF out */ | 593 | /* un/mute SPDIF out */ |
601 | snd_hda_codec_write_cache(codec, nid, 0, | 594 | snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0, |
602 | AC_VERB_SET_AMP_GAIN_MUTE, val); | 595 | HDA_AMP_MUTE, val); |
603 | } | 596 | } |
604 | return 0; | 597 | return 0; |
605 | } | 598 | } |
@@ -764,10 +757,6 @@ static struct hda_verb stac9200_eapd_init[] = { | |||
764 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { | 757 | static struct hda_verb stac92hd73xx_6ch_core_init[] = { |
765 | /* set master volume and direct control */ | 758 | /* set master volume and direct control */ |
766 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 759 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
767 | /* setup audio connections */ | ||
768 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
769 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
770 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
771 | /* setup adcs to point to mixer */ | 760 | /* setup adcs to point to mixer */ |
772 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 761 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
773 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 762 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
@@ -786,10 +775,6 @@ static struct hda_verb dell_eq_core_init[] = { | |||
786 | /* set master volume to max value without distortion | 775 | /* set master volume to max value without distortion |
787 | * and direct control */ | 776 | * and direct control */ |
788 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, | 777 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec}, |
789 | /* setup audio connections */ | ||
790 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
791 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
792 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
793 | /* setup adcs to point to mixer */ | 778 | /* setup adcs to point to mixer */ |
794 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 779 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
795 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 780 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
@@ -803,10 +788,6 @@ static struct hda_verb dell_eq_core_init[] = { | |||
803 | 788 | ||
804 | static struct hda_verb dell_m6_core_init[] = { | 789 | static struct hda_verb dell_m6_core_init[] = { |
805 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 790 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
806 | /* setup audio connections */ | ||
807 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
808 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
809 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
810 | /* setup adcs to point to mixer */ | 791 | /* setup adcs to point to mixer */ |
811 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 792 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
812 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 793 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
@@ -821,13 +802,6 @@ static struct hda_verb dell_m6_core_init[] = { | |||
821 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { | 802 | static struct hda_verb stac92hd73xx_8ch_core_init[] = { |
822 | /* set master volume and direct control */ | 803 | /* set master volume and direct control */ |
823 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 804 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
824 | /* setup audio connections */ | ||
825 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00}, | ||
826 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
827 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02}, | ||
828 | /* connect hp ports to dac3 */ | ||
829 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
830 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x03}, | ||
831 | /* setup adcs to point to mixer */ | 805 | /* setup adcs to point to mixer */ |
832 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 806 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
833 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 807 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
@@ -845,15 +819,8 @@ static struct hda_verb stac92hd73xx_8ch_core_init[] = { | |||
845 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { | 819 | static struct hda_verb stac92hd73xx_10ch_core_init[] = { |
846 | /* set master volume and direct control */ | 820 | /* set master volume and direct control */ |
847 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 821 | { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
848 | /* setup audio connections */ | ||
849 | { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 }, | ||
850 | { 0x10, AC_VERB_SET_CONNECT_SEL, 0x01 }, | ||
851 | { 0x11, AC_VERB_SET_CONNECT_SEL, 0x02 }, | ||
852 | /* dac3 is connected to import3 mux */ | 822 | /* dac3 is connected to import3 mux */ |
853 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, | 823 | { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0xb07f}, |
854 | /* connect hp ports to dac4 */ | ||
855 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x04}, | ||
856 | { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x04}, | ||
857 | /* setup adcs to point to mixer */ | 824 | /* setup adcs to point to mixer */ |
858 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 825 | { 0x20, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
859 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, | 826 | { 0x21, AC_VERB_SET_CONNECT_SEL, 0x0b}, |
@@ -879,17 +846,17 @@ static struct hda_verb stac92hd83xxx_core_init[] = { | |||
879 | 846 | ||
880 | /* power state controls amps */ | 847 | /* power state controls amps */ |
881 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, | 848 | { 0x01, AC_VERB_SET_EAPD, 1 << 2}, |
849 | {} | ||
882 | }; | 850 | }; |
883 | 851 | ||
884 | static struct hda_verb stac92hd71bxx_core_init[] = { | 852 | static struct hda_verb stac92hd71bxx_core_init[] = { |
885 | /* set master volume and direct control */ | 853 | /* set master volume and direct control */ |
886 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 854 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
887 | /* connect headphone jack to dac1 */ | ||
888 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
889 | /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */ | 855 | /* unmute right and left channels for nodes 0x0a, 0xd, 0x0f */ |
890 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 856 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
891 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 857 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
892 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 858 | { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
859 | {} | ||
893 | }; | 860 | }; |
894 | 861 | ||
895 | #define HD_DISABLE_PORTF 2 | 862 | #define HD_DISABLE_PORTF 2 |
@@ -904,8 +871,6 @@ static struct hda_verb stac92hd71bxx_analog_core_init[] = { | |||
904 | 871 | ||
905 | /* set master volume and direct control */ | 872 | /* set master volume and direct control */ |
906 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, | 873 | { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff}, |
907 | /* connect headphone jack to dac1 */ | ||
908 | { 0x0a, AC_VERB_SET_CONNECT_SEL, 0x01}, | ||
909 | /* unmute right and left channels for nodes 0x0a, 0xd */ | 874 | /* unmute right and left channels for nodes 0x0a, 0xd */ |
910 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 875 | { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
911 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, | 876 | { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, |
@@ -1105,21 +1070,21 @@ static struct snd_kcontrol_new stac92hd83xxx_mixer[] = { | |||
1105 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), | 1070 | HDA_CODEC_VOLUME_IDX("Capture Volume", 0x1, 0x18, 0x0, HDA_OUTPUT), |
1106 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), | 1071 | HDA_CODEC_MUTE_IDX("Capture Switch", 0x1, 0x18, 0x0, HDA_OUTPUT), |
1107 | 1072 | ||
1108 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0, HDA_INPUT), | 1073 | HDA_CODEC_VOLUME("DAC0 Capture Volume", 0x1b, 0x3, HDA_INPUT), |
1109 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0, HDA_INPUT), | 1074 | HDA_CODEC_MUTE("DAC0 Capture Switch", 0x1b, 0x3, HDA_INPUT), |
1110 | 1075 | ||
1111 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x1, HDA_INPUT), | 1076 | HDA_CODEC_VOLUME("DAC1 Capture Volume", 0x1b, 0x4, HDA_INPUT), |
1112 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x1, HDA_INPUT), | 1077 | HDA_CODEC_MUTE("DAC1 Capture Switch", 0x1b, 0x4, HDA_INPUT), |
1113 | 1078 | ||
1114 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x2, HDA_INPUT), | 1079 | HDA_CODEC_VOLUME("Front Mic Capture Volume", 0x1b, 0x0, HDA_INPUT), |
1115 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x2, HDA_INPUT), | 1080 | HDA_CODEC_MUTE("Front Mic Capture Switch", 0x1b, 0x0, HDA_INPUT), |
1116 | 1081 | ||
1117 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x3, HDA_INPUT), | 1082 | HDA_CODEC_VOLUME("Line In Capture Volume", 0x1b, 0x2, HDA_INPUT), |
1118 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x3, HDA_INPUT), | 1083 | HDA_CODEC_MUTE("Line In Capture Switch", 0x1b, 0x2, HDA_INPUT), |
1119 | 1084 | ||
1120 | /* | 1085 | /* |
1121 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x4, HDA_INPUT), | 1086 | HDA_CODEC_VOLUME("Mic Capture Volume", 0x1b, 0x1, HDA_INPUT), |
1122 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x4, HDA_INPUT), | 1087 | HDA_CODEC_MUTE("Mic Capture Switch", 0x1b 0x1, HDA_INPUT), |
1123 | */ | 1088 | */ |
1124 | { } /* end */ | 1089 | { } /* end */ |
1125 | }; | 1090 | }; |
@@ -1296,7 +1261,7 @@ static int stac92xx_build_controls(struct hda_codec *codec) | |||
1296 | spec->spdif_mute = 1; | 1261 | spec->spdif_mute = 1; |
1297 | } | 1262 | } |
1298 | stac_smux_mixer.count = spec->num_smuxes; | 1263 | stac_smux_mixer.count = spec->num_smuxes; |
1299 | err = snd_ctl_add(codec->bus->card, | 1264 | err = snd_hda_ctl_add(codec, |
1300 | snd_ctl_new1(&stac_smux_mixer, codec)); | 1265 | snd_ctl_new1(&stac_smux_mixer, codec)); |
1301 | if (err < 0) | 1266 | if (err < 0) |
1302 | return err; | 1267 | return err; |
@@ -1720,6 +1685,7 @@ static unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = { | |||
1720 | }; | 1685 | }; |
1721 | 1686 | ||
1722 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { | 1687 | static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = { |
1688 | [STAC_92HD73XX_NO_JD] = "no-jd", | ||
1723 | [STAC_92HD73XX_REF] = "ref", | 1689 | [STAC_92HD73XX_REF] = "ref", |
1724 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", | 1690 | [STAC_DELL_M6_AMIC] = "dell-m6-amic", |
1725 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", | 1691 | [STAC_DELL_M6_DMIC] = "dell-m6-dmic", |
@@ -1749,6 +1715,8 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = { | |||
1749 | "unknown Dell", STAC_DELL_M6_DMIC), | 1715 | "unknown Dell", STAC_DELL_M6_DMIC), |
1750 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, | 1716 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f, |
1751 | "Dell Studio 1537", STAC_DELL_M6_DMIC), | 1717 | "Dell Studio 1537", STAC_DELL_M6_DMIC), |
1718 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0, | ||
1719 | "Dell Studio 17", STAC_DELL_M6_DMIC), | ||
1752 | {} /* terminator */ | 1720 | {} /* terminator */ |
1753 | }; | 1721 | }; |
1754 | 1722 | ||
@@ -1770,7 +1738,8 @@ static const char *stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = { | |||
1770 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { | 1738 | static struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = { |
1771 | /* SigmaTel reference board */ | 1739 | /* SigmaTel reference board */ |
1772 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, | 1740 | SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, |
1773 | "DFI LanParty", STAC_92HD71BXX_REF), | 1741 | "DFI LanParty", STAC_92HD83XXX_REF), |
1742 | {} /* terminator */ | ||
1774 | }; | 1743 | }; |
1775 | 1744 | ||
1776 | static unsigned int ref92hd71bxx_pin_configs[11] = { | 1745 | static unsigned int ref92hd71bxx_pin_configs[11] = { |
@@ -1821,6 +1790,10 @@ static struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = { | |||
1821 | "HP dv5", STAC_HP_M4), | 1790 | "HP dv5", STAC_HP_M4), |
1822 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4, | 1791 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30f4, |
1823 | "HP dv7", STAC_HP_M4), | 1792 | "HP dv7", STAC_HP_M4), |
1793 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fc, | ||
1794 | "HP dv7", STAC_HP_M4), | ||
1795 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3603, | ||
1796 | "HP dv5", STAC_HP_M4), | ||
1824 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, | 1797 | SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a, |
1825 | "unknown HP", STAC_HP_M4), | 1798 | "unknown HP", STAC_HP_M4), |
1826 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, | 1799 | SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233, |
@@ -2136,6 +2109,7 @@ static unsigned int dell_3st_pin_configs[14] = { | |||
2136 | }; | 2109 | }; |
2137 | 2110 | ||
2138 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { | 2111 | static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { |
2112 | [STAC_D965_REF_NO_JD] = ref927x_pin_configs, | ||
2139 | [STAC_D965_REF] = ref927x_pin_configs, | 2113 | [STAC_D965_REF] = ref927x_pin_configs, |
2140 | [STAC_D965_3ST] = d965_3st_pin_configs, | 2114 | [STAC_D965_3ST] = d965_3st_pin_configs, |
2141 | [STAC_D965_5ST] = d965_5st_pin_configs, | 2115 | [STAC_D965_5ST] = d965_5st_pin_configs, |
@@ -2144,6 +2118,7 @@ static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = { | |||
2144 | }; | 2118 | }; |
2145 | 2119 | ||
2146 | static const char *stac927x_models[STAC_927X_MODELS] = { | 2120 | static const char *stac927x_models[STAC_927X_MODELS] = { |
2121 | [STAC_D965_REF_NO_JD] = "ref-no-jd", | ||
2147 | [STAC_D965_REF] = "ref", | 2122 | [STAC_D965_REF] = "ref", |
2148 | [STAC_D965_3ST] = "3stack", | 2123 | [STAC_D965_3ST] = "3stack", |
2149 | [STAC_D965_5ST] = "5stack", | 2124 | [STAC_D965_5ST] = "5stack", |
@@ -2468,7 +2443,7 @@ static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo, | |||
2468 | 2443 | ||
2469 | if (spec->powerdown_adcs) { | 2444 | if (spec->powerdown_adcs) { |
2470 | msleep(40); | 2445 | msleep(40); |
2471 | snd_hda_codec_write_cache(codec, nid, 0, | 2446 | snd_hda_codec_write(codec, nid, 0, |
2472 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); | 2447 | AC_VERB_SET_POWER_STATE, AC_PWRST_D0); |
2473 | } | 2448 | } |
2474 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); | 2449 | snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); |
@@ -2484,7 +2459,7 @@ static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo, | |||
2484 | 2459 | ||
2485 | snd_hda_codec_cleanup_stream(codec, nid); | 2460 | snd_hda_codec_cleanup_stream(codec, nid); |
2486 | if (spec->powerdown_adcs) | 2461 | if (spec->powerdown_adcs) |
2487 | snd_hda_codec_write_cache(codec, nid, 0, | 2462 | snd_hda_codec_write(codec, nid, 0, |
2488 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | 2463 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
2489 | return 0; | 2464 | return 0; |
2490 | } | 2465 | } |
@@ -2796,70 +2771,53 @@ static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type, | |||
2796 | return stac92xx_add_control_idx(spec, type, 0, name, val); | 2771 | return stac92xx_add_control_idx(spec, type, 0, name, val); |
2797 | } | 2772 | } |
2798 | 2773 | ||
2799 | /* flag inputs as additional dynamic lineouts */ | 2774 | /* check whether the line-input can be used as line-out */ |
2800 | static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg) | 2775 | static hda_nid_t check_line_out_switch(struct hda_codec *codec) |
2801 | { | 2776 | { |
2802 | struct sigmatel_spec *spec = codec->spec; | 2777 | struct sigmatel_spec *spec = codec->spec; |
2803 | unsigned int wcaps, wtype; | 2778 | struct auto_pin_cfg *cfg = &spec->autocfg; |
2804 | int i, num_dacs = 0; | 2779 | hda_nid_t nid; |
2805 | 2780 | unsigned int pincap; | |
2806 | /* use the wcaps cache to count all DACs available for line-outs */ | ||
2807 | for (i = 0; i < codec->num_nodes; i++) { | ||
2808 | wcaps = codec->wcaps[i]; | ||
2809 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
2810 | 2781 | ||
2811 | if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL)) | 2782 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
2812 | num_dacs++; | 2783 | return 0; |
2813 | } | 2784 | nid = cfg->input_pins[AUTO_PIN_LINE]; |
2785 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); | ||
2786 | if (pincap & AC_PINCAP_OUT) | ||
2787 | return nid; | ||
2788 | return 0; | ||
2789 | } | ||
2814 | 2790 | ||
2815 | snd_printdd("%s: total dac count=%d\n", __func__, num_dacs); | 2791 | /* check whether the mic-input can be used as line-out */ |
2816 | 2792 | static hda_nid_t check_mic_out_switch(struct hda_codec *codec) | |
2817 | switch (cfg->line_outs) { | 2793 | { |
2818 | case 3: | 2794 | struct sigmatel_spec *spec = codec->spec; |
2819 | /* add line-in as side */ | 2795 | struct auto_pin_cfg *cfg = &spec->autocfg; |
2820 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) { | 2796 | unsigned int def_conf, pincap; |
2821 | cfg->line_out_pins[cfg->line_outs] = | 2797 | unsigned int mic_pin; |
2822 | cfg->input_pins[AUTO_PIN_LINE]; | 2798 | |
2823 | spec->line_switch = 1; | 2799 | if (cfg->line_out_type != AUTO_PIN_LINE_OUT) |
2824 | cfg->line_outs++; | 2800 | return 0; |
2825 | } | 2801 | mic_pin = AUTO_PIN_MIC; |
2826 | break; | 2802 | for (;;) { |
2827 | case 2: | 2803 | hda_nid_t nid = cfg->input_pins[mic_pin]; |
2828 | /* add line-in as clfe and mic as side */ | 2804 | def_conf = snd_hda_codec_read(codec, nid, 0, |
2829 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) { | 2805 | AC_VERB_GET_CONFIG_DEFAULT, 0); |
2830 | cfg->line_out_pins[cfg->line_outs] = | 2806 | /* some laptops have an internal analog microphone |
2831 | cfg->input_pins[AUTO_PIN_LINE]; | 2807 | * which can't be used as a output */ |
2832 | spec->line_switch = 1; | 2808 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { |
2833 | cfg->line_outs++; | 2809 | pincap = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); |
2834 | } | 2810 | if (pincap & AC_PINCAP_OUT) |
2835 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) { | 2811 | return nid; |
2836 | cfg->line_out_pins[cfg->line_outs] = | ||
2837 | cfg->input_pins[AUTO_PIN_MIC]; | ||
2838 | spec->mic_switch = 1; | ||
2839 | cfg->line_outs++; | ||
2840 | } | ||
2841 | break; | ||
2842 | case 1: | ||
2843 | /* add line-in as surr and mic as clfe */ | ||
2844 | if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) { | ||
2845 | cfg->line_out_pins[cfg->line_outs] = | ||
2846 | cfg->input_pins[AUTO_PIN_LINE]; | ||
2847 | spec->line_switch = 1; | ||
2848 | cfg->line_outs++; | ||
2849 | } | ||
2850 | if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) { | ||
2851 | cfg->line_out_pins[cfg->line_outs] = | ||
2852 | cfg->input_pins[AUTO_PIN_MIC]; | ||
2853 | spec->mic_switch = 1; | ||
2854 | cfg->line_outs++; | ||
2855 | } | 2812 | } |
2856 | break; | 2813 | if (mic_pin == AUTO_PIN_MIC) |
2814 | mic_pin = AUTO_PIN_FRONT_MIC; | ||
2815 | else | ||
2816 | break; | ||
2857 | } | 2817 | } |
2858 | |||
2859 | return 0; | 2818 | return 0; |
2860 | } | 2819 | } |
2861 | 2820 | ||
2862 | |||
2863 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | 2821 | static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) |
2864 | { | 2822 | { |
2865 | int i; | 2823 | int i; |
@@ -2872,6 +2830,52 @@ static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | |||
2872 | return 0; | 2830 | return 0; |
2873 | } | 2831 | } |
2874 | 2832 | ||
2833 | static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | ||
2834 | { | ||
2835 | int i; | ||
2836 | if (is_in_dac_nids(spec, nid)) | ||
2837 | return 1; | ||
2838 | for (i = 0; i < spec->autocfg.hp_outs; i++) | ||
2839 | if (spec->hp_dacs[i] == nid) | ||
2840 | return 1; | ||
2841 | for (i = 0; i < spec->autocfg.speaker_outs; i++) | ||
2842 | if (spec->speaker_dacs[i] == nid) | ||
2843 | return 1; | ||
2844 | return 0; | ||
2845 | } | ||
2846 | |||
2847 | static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid) | ||
2848 | { | ||
2849 | struct sigmatel_spec *spec = codec->spec; | ||
2850 | int j, conn_len; | ||
2851 | hda_nid_t conn[HDA_MAX_CONNECTIONS]; | ||
2852 | unsigned int wcaps, wtype; | ||
2853 | |||
2854 | conn_len = snd_hda_get_connections(codec, nid, conn, | ||
2855 | HDA_MAX_CONNECTIONS); | ||
2856 | for (j = 0; j < conn_len; j++) { | ||
2857 | wcaps = snd_hda_param_read(codec, conn[j], | ||
2858 | AC_PAR_AUDIO_WIDGET_CAP); | ||
2859 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
2860 | /* we check only analog outputs */ | ||
2861 | if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL)) | ||
2862 | continue; | ||
2863 | /* if this route has a free DAC, assign it */ | ||
2864 | if (!check_all_dac_nids(spec, conn[j])) { | ||
2865 | if (conn_len > 1) { | ||
2866 | /* select this DAC in the pin's input mux */ | ||
2867 | snd_hda_codec_write_cache(codec, nid, 0, | ||
2868 | AC_VERB_SET_CONNECT_SEL, j); | ||
2869 | } | ||
2870 | return conn[j]; | ||
2871 | } | ||
2872 | } | ||
2873 | return 0; | ||
2874 | } | ||
2875 | |||
2876 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid); | ||
2877 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid); | ||
2878 | |||
2875 | /* | 2879 | /* |
2876 | * Fill in the dac_nids table from the parsed pin configuration | 2880 | * Fill in the dac_nids table from the parsed pin configuration |
2877 | * This function only works when every pin in line_out_pins[] | 2881 | * This function only works when every pin in line_out_pins[] |
@@ -2879,31 +2883,17 @@ static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | |||
2879 | * codecs are not connected directly to a DAC, such as the 9200 | 2883 | * codecs are not connected directly to a DAC, such as the 9200 |
2880 | * and 9202/925x. For those, dac_nids[] must be hard-coded. | 2884 | * and 9202/925x. For those, dac_nids[] must be hard-coded. |
2881 | */ | 2885 | */ |
2882 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, | 2886 | static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec) |
2883 | struct auto_pin_cfg *cfg) | ||
2884 | { | 2887 | { |
2885 | struct sigmatel_spec *spec = codec->spec; | 2888 | struct sigmatel_spec *spec = codec->spec; |
2886 | int i, j, conn_len = 0; | 2889 | struct auto_pin_cfg *cfg = &spec->autocfg; |
2887 | hda_nid_t nid, conn[HDA_MAX_CONNECTIONS]; | 2890 | int i; |
2888 | unsigned int wcaps, wtype; | 2891 | hda_nid_t nid, dac; |
2889 | 2892 | ||
2890 | for (i = 0; i < cfg->line_outs; i++) { | 2893 | for (i = 0; i < cfg->line_outs; i++) { |
2891 | nid = cfg->line_out_pins[i]; | 2894 | nid = cfg->line_out_pins[i]; |
2892 | conn_len = snd_hda_get_connections(codec, nid, conn, | 2895 | dac = get_unassigned_dac(codec, nid); |
2893 | HDA_MAX_CONNECTIONS); | 2896 | if (!dac) { |
2894 | for (j = 0; j < conn_len; j++) { | ||
2895 | wcaps = snd_hda_param_read(codec, conn[j], | ||
2896 | AC_PAR_AUDIO_WIDGET_CAP); | ||
2897 | wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; | ||
2898 | if (wtype != AC_WID_AUD_OUT || | ||
2899 | (wcaps & AC_WCAP_DIGITAL)) | ||
2900 | continue; | ||
2901 | /* conn[j] is a DAC routed to this line-out */ | ||
2902 | if (!is_in_dac_nids(spec, conn[j])) | ||
2903 | break; | ||
2904 | } | ||
2905 | |||
2906 | if (j == conn_len) { | ||
2907 | if (spec->multiout.num_dacs > 0) { | 2897 | if (spec->multiout.num_dacs > 0) { |
2908 | /* we have already working output pins, | 2898 | /* we have already working output pins, |
2909 | * so let's drop the broken ones again | 2899 | * so let's drop the broken ones again |
@@ -2917,24 +2907,64 @@ static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, | |||
2917 | __func__, nid); | 2907 | __func__, nid); |
2918 | return -ENODEV; | 2908 | return -ENODEV; |
2919 | } | 2909 | } |
2910 | add_spec_dacs(spec, dac); | ||
2911 | } | ||
2920 | 2912 | ||
2921 | spec->multiout.dac_nids[i] = conn[j]; | 2913 | /* add line-in as output */ |
2922 | spec->multiout.num_dacs++; | 2914 | nid = check_line_out_switch(codec); |
2923 | if (conn_len > 1) { | 2915 | if (nid) { |
2924 | /* select this DAC in the pin's input mux */ | 2916 | dac = get_unassigned_dac(codec, nid); |
2925 | snd_hda_codec_write_cache(codec, nid, 0, | 2917 | if (dac) { |
2926 | AC_VERB_SET_CONNECT_SEL, j); | 2918 | snd_printdd("STAC: Add line-in 0x%x as output %d\n", |
2919 | nid, cfg->line_outs); | ||
2920 | cfg->line_out_pins[cfg->line_outs] = nid; | ||
2921 | cfg->line_outs++; | ||
2922 | spec->line_switch = nid; | ||
2923 | add_spec_dacs(spec, dac); | ||
2924 | } | ||
2925 | } | ||
2926 | /* add mic as output */ | ||
2927 | nid = check_mic_out_switch(codec); | ||
2928 | if (nid) { | ||
2929 | dac = get_unassigned_dac(codec, nid); | ||
2930 | if (dac) { | ||
2931 | snd_printdd("STAC: Add mic-in 0x%x as output %d\n", | ||
2932 | nid, cfg->line_outs); | ||
2933 | cfg->line_out_pins[cfg->line_outs] = nid; | ||
2934 | cfg->line_outs++; | ||
2935 | spec->mic_switch = nid; | ||
2936 | add_spec_dacs(spec, dac); | ||
2937 | } | ||
2938 | } | ||
2927 | 2939 | ||
2940 | for (i = 0; i < cfg->hp_outs; i++) { | ||
2941 | nid = cfg->hp_pins[i]; | ||
2942 | dac = get_unassigned_dac(codec, nid); | ||
2943 | if (dac) { | ||
2944 | if (!spec->multiout.hp_nid) | ||
2945 | spec->multiout.hp_nid = dac; | ||
2946 | else | ||
2947 | add_spec_extra_dacs(spec, dac); | ||
2928 | } | 2948 | } |
2949 | spec->hp_dacs[i] = dac; | ||
2929 | } | 2950 | } |
2930 | 2951 | ||
2931 | snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", | 2952 | for (i = 0; i < cfg->speaker_outs; i++) { |
2953 | nid = cfg->speaker_pins[i]; | ||
2954 | dac = get_unassigned_dac(codec, nid); | ||
2955 | if (dac) | ||
2956 | add_spec_extra_dacs(spec, dac); | ||
2957 | spec->speaker_dacs[i] = dac; | ||
2958 | } | ||
2959 | |||
2960 | snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n", | ||
2932 | spec->multiout.num_dacs, | 2961 | spec->multiout.num_dacs, |
2933 | spec->multiout.dac_nids[0], | 2962 | spec->multiout.dac_nids[0], |
2934 | spec->multiout.dac_nids[1], | 2963 | spec->multiout.dac_nids[1], |
2935 | spec->multiout.dac_nids[2], | 2964 | spec->multiout.dac_nids[2], |
2936 | spec->multiout.dac_nids[3], | 2965 | spec->multiout.dac_nids[3], |
2937 | spec->multiout.dac_nids[4]); | 2966 | spec->multiout.dac_nids[4]); |
2967 | |||
2938 | return 0; | 2968 | return 0; |
2939 | } | 2969 | } |
2940 | 2970 | ||
@@ -2959,9 +2989,7 @@ static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_ | |||
2959 | 2989 | ||
2960 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) | 2990 | static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
2961 | { | 2991 | { |
2962 | if (!spec->multiout.hp_nid) | 2992 | if (spec->multiout.num_dacs > 4) { |
2963 | spec->multiout.hp_nid = nid; | ||
2964 | else if (spec->multiout.num_dacs > 4) { | ||
2965 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); | 2993 | printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid); |
2966 | return 1; | 2994 | return 1; |
2967 | } else { | 2995 | } else { |
@@ -2971,35 +2999,47 @@ static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid) | |||
2971 | return 0; | 2999 | return 0; |
2972 | } | 3000 | } |
2973 | 3001 | ||
2974 | static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid) | 3002 | static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid) |
2975 | { | 3003 | { |
2976 | if (is_in_dac_nids(spec, nid)) | 3004 | int i; |
2977 | return 1; | 3005 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) { |
3006 | if (!spec->multiout.extra_out_nid[i]) { | ||
3007 | spec->multiout.extra_out_nid[i] = nid; | ||
3008 | return 0; | ||
3009 | } | ||
3010 | } | ||
3011 | printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid); | ||
3012 | return 1; | ||
3013 | } | ||
3014 | |||
3015 | static int is_unique_dac(struct sigmatel_spec *spec, hda_nid_t nid) | ||
3016 | { | ||
3017 | int i; | ||
3018 | |||
3019 | if (spec->autocfg.line_outs != 1) | ||
3020 | return 0; | ||
2978 | if (spec->multiout.hp_nid == nid) | 3021 | if (spec->multiout.hp_nid == nid) |
2979 | return 1; | 3022 | return 0; |
2980 | return 0; | 3023 | for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) |
3024 | if (spec->multiout.extra_out_nid[i] == nid) | ||
3025 | return 0; | ||
3026 | return 1; | ||
2981 | } | 3027 | } |
2982 | 3028 | ||
2983 | /* add playback controls from the parsed DAC table */ | 3029 | /* add playback controls from the parsed DAC table */ |
2984 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | 3030 | static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, |
2985 | const struct auto_pin_cfg *cfg) | 3031 | const struct auto_pin_cfg *cfg) |
2986 | { | 3032 | { |
3033 | struct sigmatel_spec *spec = codec->spec; | ||
2987 | static const char *chname[4] = { | 3034 | static const char *chname[4] = { |
2988 | "Front", "Surround", NULL /*CLFE*/, "Side" | 3035 | "Front", "Surround", NULL /*CLFE*/, "Side" |
2989 | }; | 3036 | }; |
2990 | hda_nid_t nid = 0; | 3037 | hda_nid_t nid = 0; |
2991 | int i, err; | 3038 | int i, err; |
3039 | unsigned int wid_caps; | ||
2992 | 3040 | ||
2993 | struct sigmatel_spec *spec = codec->spec; | 3041 | for (i = 0; i < cfg->line_outs && spec->multiout.dac_nids[i]; i++) { |
2994 | unsigned int wid_caps, pincap; | ||
2995 | |||
2996 | |||
2997 | for (i = 0; i < cfg->line_outs && i < spec->multiout.num_dacs; i++) { | ||
2998 | if (!spec->multiout.dac_nids[i]) | ||
2999 | continue; | ||
3000 | |||
3001 | nid = spec->multiout.dac_nids[i]; | 3042 | nid = spec->multiout.dac_nids[i]; |
3002 | |||
3003 | if (i == 2) { | 3043 | if (i == 2) { |
3004 | /* Center/LFE */ | 3044 | /* Center/LFE */ |
3005 | err = create_controls(spec, "Center", nid, 1); | 3045 | err = create_controls(spec, "Center", nid, 1); |
@@ -3021,16 +3061,24 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | |||
3021 | } | 3061 | } |
3022 | 3062 | ||
3023 | } else { | 3063 | } else { |
3024 | err = create_controls(spec, chname[i], nid, 3); | 3064 | const char *name = chname[i]; |
3065 | /* if it's a single DAC, assign a better name */ | ||
3066 | if (!i && is_unique_dac(spec, nid)) { | ||
3067 | switch (cfg->line_out_type) { | ||
3068 | case AUTO_PIN_HP_OUT: | ||
3069 | name = "Headphone"; | ||
3070 | break; | ||
3071 | case AUTO_PIN_SPEAKER_OUT: | ||
3072 | name = "Speaker"; | ||
3073 | break; | ||
3074 | } | ||
3075 | } | ||
3076 | err = create_controls(spec, name, nid, 3); | ||
3025 | if (err < 0) | 3077 | if (err < 0) |
3026 | return err; | 3078 | return err; |
3027 | } | 3079 | } |
3028 | } | 3080 | } |
3029 | 3081 | ||
3030 | if ((spec->multiout.num_dacs - cfg->line_outs) > 0 && | ||
3031 | cfg->hp_outs && !spec->multiout.hp_nid) | ||
3032 | spec->multiout.hp_nid = nid; | ||
3033 | |||
3034 | if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) { | 3082 | if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) { |
3035 | err = stac92xx_add_control(spec, | 3083 | err = stac92xx_add_control(spec, |
3036 | STAC_CTL_WIDGET_HP_SWITCH, | 3084 | STAC_CTL_WIDGET_HP_SWITCH, |
@@ -3041,45 +3089,19 @@ static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec, | |||
3041 | } | 3089 | } |
3042 | 3090 | ||
3043 | if (spec->line_switch) { | 3091 | if (spec->line_switch) { |
3044 | nid = cfg->input_pins[AUTO_PIN_LINE]; | 3092 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
3045 | pincap = snd_hda_param_read(codec, nid, | 3093 | "Line In as Output Switch", |
3046 | AC_PAR_PIN_CAP); | 3094 | spec->line_switch << 8); |
3047 | if (pincap & AC_PINCAP_OUT) { | 3095 | if (err < 0) |
3048 | err = stac92xx_add_control(spec, | 3096 | return err; |
3049 | STAC_CTL_WIDGET_IO_SWITCH, | ||
3050 | "Line In as Output Switch", nid << 8); | ||
3051 | if (err < 0) | ||
3052 | return err; | ||
3053 | } | ||
3054 | } | 3097 | } |
3055 | 3098 | ||
3056 | if (spec->mic_switch) { | 3099 | if (spec->mic_switch) { |
3057 | unsigned int def_conf; | 3100 | err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, |
3058 | unsigned int mic_pin = AUTO_PIN_MIC; | 3101 | "Mic as Output Switch", |
3059 | again: | 3102 | (spec->mic_switch << 8) | 1); |
3060 | nid = cfg->input_pins[mic_pin]; | 3103 | if (err < 0) |
3061 | def_conf = snd_hda_codec_read(codec, nid, 0, | 3104 | return err; |
3062 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
3063 | /* some laptops have an internal analog microphone | ||
3064 | * which can't be used as a output */ | ||
3065 | if (get_defcfg_connect(def_conf) != AC_JACK_PORT_FIXED) { | ||
3066 | pincap = snd_hda_param_read(codec, nid, | ||
3067 | AC_PAR_PIN_CAP); | ||
3068 | if (pincap & AC_PINCAP_OUT) { | ||
3069 | err = stac92xx_add_control(spec, | ||
3070 | STAC_CTL_WIDGET_IO_SWITCH, | ||
3071 | "Mic as Output Switch", (nid << 8) | 1); | ||
3072 | nid = snd_hda_codec_read(codec, nid, 0, | ||
3073 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; | ||
3074 | if (!check_in_dac_nids(spec, nid)) | ||
3075 | add_spec_dacs(spec, nid); | ||
3076 | if (err < 0) | ||
3077 | return err; | ||
3078 | } | ||
3079 | } else if (mic_pin == AUTO_PIN_MIC) { | ||
3080 | mic_pin = AUTO_PIN_FRONT_MIC; | ||
3081 | goto again; | ||
3082 | } | ||
3083 | } | 3105 | } |
3084 | 3106 | ||
3085 | return 0; | 3107 | return 0; |
@@ -3091,55 +3113,39 @@ static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, | |||
3091 | { | 3113 | { |
3092 | struct sigmatel_spec *spec = codec->spec; | 3114 | struct sigmatel_spec *spec = codec->spec; |
3093 | hda_nid_t nid; | 3115 | hda_nid_t nid; |
3094 | int i, old_num_dacs, err; | 3116 | int i, err, nums; |
3095 | 3117 | ||
3096 | old_num_dacs = spec->multiout.num_dacs; | 3118 | nums = 0; |
3097 | for (i = 0; i < cfg->hp_outs; i++) { | 3119 | for (i = 0; i < cfg->hp_outs; i++) { |
3120 | static const char *pfxs[] = { | ||
3121 | "Headphone", "Headphone2", "Headphone3", | ||
3122 | }; | ||
3098 | unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]); | 3123 | unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]); |
3099 | if (wid_caps & AC_WCAP_UNSOL_CAP) | 3124 | if (wid_caps & AC_WCAP_UNSOL_CAP) |
3100 | spec->hp_detect = 1; | 3125 | spec->hp_detect = 1; |
3101 | nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, | 3126 | if (nums >= ARRAY_SIZE(pfxs)) |
3102 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; | ||
3103 | if (check_in_dac_nids(spec, nid)) | ||
3104 | nid = 0; | ||
3105 | if (! nid) | ||
3106 | continue; | ||
3107 | add_spec_dacs(spec, nid); | ||
3108 | } | ||
3109 | for (i = 0; i < cfg->speaker_outs; i++) { | ||
3110 | nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0, | ||
3111 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; | ||
3112 | if (check_in_dac_nids(spec, nid)) | ||
3113 | nid = 0; | ||
3114 | if (! nid) | ||
3115 | continue; | 3127 | continue; |
3116 | add_spec_dacs(spec, nid); | 3128 | nid = spec->hp_dacs[i]; |
3117 | } | 3129 | if (!nid) |
3118 | for (i = 0; i < cfg->line_outs; i++) { | ||
3119 | nid = snd_hda_codec_read(codec, cfg->line_out_pins[i], 0, | ||
3120 | AC_VERB_GET_CONNECT_LIST, 0) & 0xff; | ||
3121 | if (check_in_dac_nids(spec, nid)) | ||
3122 | nid = 0; | ||
3123 | if (! nid) | ||
3124 | continue; | 3130 | continue; |
3125 | add_spec_dacs(spec, nid); | 3131 | err = create_controls(spec, pfxs[nums++], nid, 3); |
3132 | if (err < 0) | ||
3133 | return err; | ||
3126 | } | 3134 | } |
3127 | for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) { | 3135 | nums = 0; |
3136 | for (i = 0; i < cfg->speaker_outs; i++) { | ||
3128 | static const char *pfxs[] = { | 3137 | static const char *pfxs[] = { |
3129 | "Speaker", "External Speaker", "Speaker2", | 3138 | "Speaker", "External Speaker", "Speaker2", |
3130 | }; | 3139 | }; |
3131 | err = create_controls(spec, pfxs[i - old_num_dacs], | 3140 | if (nums >= ARRAY_SIZE(pfxs)) |
3132 | spec->multiout.dac_nids[i], 3); | 3141 | continue; |
3133 | if (err < 0) | 3142 | nid = spec->speaker_dacs[i]; |
3134 | return err; | 3143 | if (!nid) |
3135 | } | 3144 | continue; |
3136 | if (spec->multiout.hp_nid) { | 3145 | err = create_controls(spec, pfxs[nums++], nid, 3); |
3137 | err = create_controls(spec, "Headphone", | ||
3138 | spec->multiout.hp_nid, 3); | ||
3139 | if (err < 0) | 3146 | if (err < 0) |
3140 | return err; | 3147 | return err; |
3141 | } | 3148 | } |
3142 | |||
3143 | return 0; | 3149 | return 0; |
3144 | } | 3150 | } |
3145 | 3151 | ||
@@ -3477,7 +3483,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3477 | { | 3483 | { |
3478 | struct sigmatel_spec *spec = codec->spec; | 3484 | struct sigmatel_spec *spec = codec->spec; |
3479 | int err; | 3485 | int err; |
3480 | int hp_speaker_swap = 0; | ||
3481 | 3486 | ||
3482 | if ((err = snd_hda_parse_pin_def_config(codec, | 3487 | if ((err = snd_hda_parse_pin_def_config(codec, |
3483 | &spec->autocfg, | 3488 | &spec->autocfg, |
@@ -3495,13 +3500,15 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3495 | * speaker_outs so that the following routines can handle | 3500 | * speaker_outs so that the following routines can handle |
3496 | * HP pins as primary outputs. | 3501 | * HP pins as primary outputs. |
3497 | */ | 3502 | */ |
3503 | snd_printdd("stac92xx: Enabling multi-HPs workaround\n"); | ||
3498 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, | 3504 | memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins, |
3499 | sizeof(spec->autocfg.line_out_pins)); | 3505 | sizeof(spec->autocfg.line_out_pins)); |
3500 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; | 3506 | spec->autocfg.speaker_outs = spec->autocfg.line_outs; |
3501 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, | 3507 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins, |
3502 | sizeof(spec->autocfg.hp_pins)); | 3508 | sizeof(spec->autocfg.hp_pins)); |
3503 | spec->autocfg.line_outs = spec->autocfg.hp_outs; | 3509 | spec->autocfg.line_outs = spec->autocfg.hp_outs; |
3504 | hp_speaker_swap = 1; | 3510 | spec->autocfg.line_out_type = AUTO_PIN_HP_OUT; |
3511 | spec->autocfg.hp_outs = 0; | ||
3505 | } | 3512 | } |
3506 | if (spec->autocfg.mono_out_pin) { | 3513 | if (spec->autocfg.mono_out_pin) { |
3507 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & | 3514 | int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) & |
@@ -3553,11 +3560,11 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3553 | AC_PINCTL_OUT_EN); | 3560 | AC_PINCTL_OUT_EN); |
3554 | } | 3561 | } |
3555 | 3562 | ||
3556 | if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0) | 3563 | if (!spec->multiout.num_dacs) { |
3557 | return err; | 3564 | err = stac92xx_auto_fill_dac_nids(codec); |
3558 | if (spec->multiout.num_dacs == 0) | 3565 | if (err < 0) |
3559 | if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0) | ||
3560 | return err; | 3566 | return err; |
3567 | } | ||
3561 | 3568 | ||
3562 | err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg); | 3569 | err = stac92xx_auto_create_multi_out_ctls(codec, &spec->autocfg); |
3563 | 3570 | ||
@@ -3595,19 +3602,6 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3595 | } | 3602 | } |
3596 | #endif | 3603 | #endif |
3597 | 3604 | ||
3598 | if (hp_speaker_swap == 1) { | ||
3599 | /* Restore the hp_outs and line_outs */ | ||
3600 | memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins, | ||
3601 | sizeof(spec->autocfg.line_out_pins)); | ||
3602 | spec->autocfg.hp_outs = spec->autocfg.line_outs; | ||
3603 | memcpy(spec->autocfg.line_out_pins, spec->autocfg.speaker_pins, | ||
3604 | sizeof(spec->autocfg.speaker_pins)); | ||
3605 | spec->autocfg.line_outs = spec->autocfg.speaker_outs; | ||
3606 | memset(spec->autocfg.speaker_pins, 0, | ||
3607 | sizeof(spec->autocfg.speaker_pins)); | ||
3608 | spec->autocfg.speaker_outs = 0; | ||
3609 | } | ||
3610 | |||
3611 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); | 3605 | err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg); |
3612 | 3606 | ||
3613 | if (err < 0) | 3607 | if (err < 0) |
@@ -3656,7 +3650,8 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out | |||
3656 | spec->mixers[spec->num_mixers++] = spec->kctls.list; | 3650 | spec->mixers[spec->num_mixers++] = spec->kctls.list; |
3657 | 3651 | ||
3658 | spec->input_mux = &spec->private_imux; | 3652 | spec->input_mux = &spec->private_imux; |
3659 | spec->dinput_mux = &spec->private_dimux; | 3653 | if (!spec->dinput_mux) |
3654 | spec->dinput_mux = &spec->private_dimux; | ||
3660 | spec->sinput_mux = &spec->private_smux; | 3655 | spec->sinput_mux = &spec->private_smux; |
3661 | spec->mono_mux = &spec->private_mono_mux; | 3656 | spec->mono_mux = &spec->private_mono_mux; |
3662 | spec->amp_mux = &spec->private_amp_mux; | 3657 | spec->amp_mux = &spec->private_amp_mux; |
@@ -3919,9 +3914,8 @@ static void stac92xx_power_down(struct hda_codec *codec) | |||
3919 | /* power down inactive DACs */ | 3914 | /* power down inactive DACs */ |
3920 | hda_nid_t *dac; | 3915 | hda_nid_t *dac; |
3921 | for (dac = spec->dac_list; *dac; dac++) | 3916 | for (dac = spec->dac_list; *dac; dac++) |
3922 | if (!is_in_dac_nids(spec, *dac) && | 3917 | if (!check_all_dac_nids(spec, *dac)) |
3923 | spec->multiout.hp_nid != *dac) | 3918 | snd_hda_codec_write(codec, *dac, 0, |
3924 | snd_hda_codec_write_cache(codec, *dac, 0, | ||
3925 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | 3919 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
3926 | } | 3920 | } |
3927 | 3921 | ||
@@ -3940,7 +3934,7 @@ static int stac92xx_init(struct hda_codec *codec) | |||
3940 | /* power down adcs initially */ | 3934 | /* power down adcs initially */ |
3941 | if (spec->powerdown_adcs) | 3935 | if (spec->powerdown_adcs) |
3942 | for (i = 0; i < spec->num_adcs; i++) | 3936 | for (i = 0; i < spec->num_adcs; i++) |
3943 | snd_hda_codec_write_cache(codec, | 3937 | snd_hda_codec_write(codec, |
3944 | spec->adc_nids[i], 0, | 3938 | spec->adc_nids[i], 0, |
3945 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); | 3939 | AC_VERB_SET_POWER_STATE, AC_PWRST_D3); |
3946 | 3940 | ||
@@ -3971,24 +3965,36 @@ static int stac92xx_init(struct hda_codec *codec) | |||
3971 | } else { | 3965 | } else { |
3972 | stac92xx_auto_init_multi_out(codec); | 3966 | stac92xx_auto_init_multi_out(codec); |
3973 | stac92xx_auto_init_hp_out(codec); | 3967 | stac92xx_auto_init_hp_out(codec); |
3968 | for (i = 0; i < cfg->hp_outs; i++) | ||
3969 | stac_toggle_power_map(codec, cfg->hp_pins[i], 1); | ||
3974 | } | 3970 | } |
3975 | for (i = 0; i < AUTO_PIN_LAST; i++) { | 3971 | for (i = 0; i < AUTO_PIN_LAST; i++) { |
3976 | hda_nid_t nid = cfg->input_pins[i]; | 3972 | hda_nid_t nid = cfg->input_pins[i]; |
3977 | if (nid) { | 3973 | if (nid) { |
3978 | unsigned int pinctl; | 3974 | unsigned int pinctl, conf; |
3979 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { | 3975 | if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC) { |
3980 | /* for mic pins, force to initialize */ | 3976 | /* for mic pins, force to initialize */ |
3981 | pinctl = stac92xx_get_vref(codec, nid); | 3977 | pinctl = stac92xx_get_vref(codec, nid); |
3978 | pinctl |= AC_PINCTL_IN_EN; | ||
3979 | stac92xx_auto_set_pinctl(codec, nid, pinctl); | ||
3982 | } else { | 3980 | } else { |
3983 | pinctl = snd_hda_codec_read(codec, nid, 0, | 3981 | pinctl = snd_hda_codec_read(codec, nid, 0, |
3984 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | 3982 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); |
3985 | /* if PINCTL already set then skip */ | 3983 | /* if PINCTL already set then skip */ |
3986 | if (pinctl & AC_PINCTL_IN_EN) | 3984 | if (!(pinctl & AC_PINCTL_IN_EN)) { |
3987 | continue; | 3985 | pinctl |= AC_PINCTL_IN_EN; |
3986 | stac92xx_auto_set_pinctl(codec, nid, | ||
3987 | pinctl); | ||
3988 | } | ||
3989 | } | ||
3990 | conf = snd_hda_codec_read(codec, nid, 0, | ||
3991 | AC_VERB_GET_CONFIG_DEFAULT, 0); | ||
3992 | if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) { | ||
3993 | enable_pin_detect(codec, nid, | ||
3994 | STAC_INSERT_EVENT); | ||
3995 | stac_issue_unsol_event(codec, nid, | ||
3996 | STAC_INSERT_EVENT); | ||
3988 | } | 3997 | } |
3989 | pinctl |= AC_PINCTL_IN_EN; | ||
3990 | stac92xx_auto_set_pinctl(codec, nid, pinctl); | ||
3991 | enable_pin_detect(codec, nid, STAC_INSERT_EVENT); | ||
3992 | } | 3998 | } |
3993 | } | 3999 | } |
3994 | for (i = 0; i < spec->num_dmics; i++) | 4000 | for (i = 0; i < spec->num_dmics; i++) |
@@ -4004,7 +4010,13 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4004 | hda_nid_t nid = spec->pwr_nids[i]; | 4010 | hda_nid_t nid = spec->pwr_nids[i]; |
4005 | int pinctl, def_conf; | 4011 | int pinctl, def_conf; |
4006 | 4012 | ||
4007 | if (is_nid_hp_pin(cfg, nid) && spec->hp_detect) | 4013 | /* power on when no jack detection is available */ |
4014 | if (!spec->hp_detect) { | ||
4015 | stac_toggle_power_map(codec, nid, 1); | ||
4016 | continue; | ||
4017 | } | ||
4018 | |||
4019 | if (is_nid_hp_pin(cfg, nid)) | ||
4008 | continue; /* already has an unsol event */ | 4020 | continue; /* already has an unsol event */ |
4009 | 4021 | ||
4010 | pinctl = snd_hda_codec_read(codec, nid, 0, | 4022 | pinctl = snd_hda_codec_read(codec, nid, 0, |
@@ -4013,8 +4025,10 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4013 | * any attempts on powering down a input port cause the | 4025 | * any attempts on powering down a input port cause the |
4014 | * referenced VREF to act quirky. | 4026 | * referenced VREF to act quirky. |
4015 | */ | 4027 | */ |
4016 | if (pinctl & AC_PINCTL_IN_EN) | 4028 | if (pinctl & AC_PINCTL_IN_EN) { |
4029 | stac_toggle_power_map(codec, nid, 1); | ||
4017 | continue; | 4030 | continue; |
4031 | } | ||
4018 | def_conf = snd_hda_codec_read(codec, nid, 0, | 4032 | def_conf = snd_hda_codec_read(codec, nid, 0, |
4019 | AC_VERB_GET_CONFIG_DEFAULT, 0); | 4033 | AC_VERB_GET_CONFIG_DEFAULT, 0); |
4020 | def_conf = get_defcfg_connect(def_conf); | 4034 | def_conf = get_defcfg_connect(def_conf); |
@@ -4025,8 +4039,10 @@ static int stac92xx_init(struct hda_codec *codec) | |||
4025 | stac_toggle_power_map(codec, nid, 1); | 4039 | stac_toggle_power_map(codec, nid, 1); |
4026 | continue; | 4040 | continue; |
4027 | } | 4041 | } |
4028 | enable_pin_detect(codec, nid, STAC_PWR_EVENT); | 4042 | if (!stac_get_event(codec, nid, STAC_INSERT_EVENT)) { |
4029 | stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT); | 4043 | enable_pin_detect(codec, nid, STAC_PWR_EVENT); |
4044 | stac_issue_unsol_event(codec, nid, STAC_PWR_EVENT); | ||
4045 | } | ||
4030 | } | 4046 | } |
4031 | if (spec->dac_list) | 4047 | if (spec->dac_list) |
4032 | stac92xx_power_down(codec); | 4048 | stac92xx_power_down(codec); |
@@ -4089,11 +4105,7 @@ static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid, | |||
4089 | * "xxx as Output" mixer switch | 4105 | * "xxx as Output" mixer switch |
4090 | */ | 4106 | */ |
4091 | struct sigmatel_spec *spec = codec->spec; | 4107 | struct sigmatel_spec *spec = codec->spec; |
4092 | struct auto_pin_cfg *cfg = &spec->autocfg; | 4108 | if (nid == spec->line_switch || nid == spec->mic_switch) |
4093 | if ((nid == cfg->input_pins[AUTO_PIN_LINE] && | ||
4094 | spec->line_switch) || | ||
4095 | (nid == cfg->input_pins[AUTO_PIN_MIC] && | ||
4096 | spec->mic_switch)) | ||
4097 | return; | 4109 | return; |
4098 | } | 4110 | } |
4099 | 4111 | ||
@@ -4117,20 +4129,13 @@ static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid, | |||
4117 | pin_ctl & ~flag); | 4129 | pin_ctl & ~flag); |
4118 | } | 4130 | } |
4119 | 4131 | ||
4120 | static int get_hp_pin_presence(struct hda_codec *codec, hda_nid_t nid) | 4132 | static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid) |
4121 | { | 4133 | { |
4122 | if (!nid) | 4134 | if (!nid) |
4123 | return 0; | 4135 | return 0; |
4124 | if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) | 4136 | if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00) |
4125 | & (1 << 31)) { | 4137 | & (1 << 31)) |
4126 | unsigned int pinctl; | 4138 | return 1; |
4127 | pinctl = snd_hda_codec_read(codec, nid, 0, | ||
4128 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | ||
4129 | if (pinctl & AC_PINCTL_IN_EN) | ||
4130 | return 0; /* mic- or line-input */ | ||
4131 | else | ||
4132 | return 1; /* HP-output */ | ||
4133 | } | ||
4134 | return 0; | 4139 | return 0; |
4135 | } | 4140 | } |
4136 | 4141 | ||
@@ -4142,11 +4147,9 @@ static int no_hp_sensing(struct sigmatel_spec *spec, int i) | |||
4142 | struct auto_pin_cfg *cfg = &spec->autocfg; | 4147 | struct auto_pin_cfg *cfg = &spec->autocfg; |
4143 | 4148 | ||
4144 | /* ignore sensing of shared line and mic jacks */ | 4149 | /* ignore sensing of shared line and mic jacks */ |
4145 | if (spec->line_switch && | 4150 | if (cfg->hp_pins[i] == spec->line_switch) |
4146 | cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_LINE]) | ||
4147 | return 1; | 4151 | return 1; |
4148 | if (spec->mic_switch && | 4152 | if (cfg->hp_pins[i] == spec->mic_switch) |
4149 | cfg->hp_pins[i] == cfg->input_pins[AUTO_PIN_MIC]) | ||
4150 | return 1; | 4153 | return 1; |
4151 | /* ignore if the pin is set as line-out */ | 4154 | /* ignore if the pin is set as line-out */ |
4152 | if (cfg->hp_pins[i] == spec->hp_switch) | 4155 | if (cfg->hp_pins[i] == spec->hp_switch) |
@@ -4170,7 +4173,14 @@ static void stac92xx_hp_detect(struct hda_codec *codec) | |||
4170 | break; | 4173 | break; |
4171 | if (no_hp_sensing(spec, i)) | 4174 | if (no_hp_sensing(spec, i)) |
4172 | continue; | 4175 | continue; |
4173 | presence = get_hp_pin_presence(codec, cfg->hp_pins[i]); | 4176 | presence = get_pin_presence(codec, cfg->hp_pins[i]); |
4177 | if (presence) { | ||
4178 | unsigned int pinctl; | ||
4179 | pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0, | ||
4180 | AC_VERB_GET_PIN_WIDGET_CONTROL, 0); | ||
4181 | if (pinctl & AC_PINCTL_IN_EN) | ||
4182 | presence = 0; /* mic- or line-input */ | ||
4183 | } | ||
4174 | } | 4184 | } |
4175 | 4185 | ||
4176 | if (presence) { | 4186 | if (presence) { |
@@ -4247,7 +4257,7 @@ static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid, | |||
4247 | 4257 | ||
4248 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) | 4258 | static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid) |
4249 | { | 4259 | { |
4250 | stac_toggle_power_map(codec, nid, get_hp_pin_presence(codec, nid)); | 4260 | stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid)); |
4251 | } | 4261 | } |
4252 | 4262 | ||
4253 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) | 4263 | static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) |
@@ -4269,7 +4279,7 @@ static void stac92xx_report_jack(struct hda_codec *codec, hda_nid_t nid) | |||
4269 | type = (pin_ctl & AC_PINCTL_HP_EN) | 4279 | type = (pin_ctl & AC_PINCTL_HP_EN) |
4270 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; | 4280 | ? SND_JACK_HEADPHONE : SND_JACK_LINEOUT; |
4271 | snd_jack_report(jacks->jack, | 4281 | snd_jack_report(jacks->jack, |
4272 | get_hp_pin_presence(codec, nid) | 4282 | get_pin_presence(codec, nid) |
4273 | ? type : 0); | 4283 | ? type : 0); |
4274 | } | 4284 | } |
4275 | jacks++; | 4285 | jacks++; |
@@ -4317,6 +4327,52 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) | |||
4317 | } | 4327 | } |
4318 | } | 4328 | } |
4319 | 4329 | ||
4330 | #ifdef CONFIG_PROC_FS | ||
4331 | static void stac92hd_proc_hook(struct snd_info_buffer *buffer, | ||
4332 | struct hda_codec *codec, hda_nid_t nid) | ||
4333 | { | ||
4334 | if (nid == codec->afg) | ||
4335 | snd_iprintf(buffer, "Power-Map: 0x%02x\n", | ||
4336 | snd_hda_codec_read(codec, nid, 0, 0x0fec, 0x0)); | ||
4337 | } | ||
4338 | |||
4339 | static void analog_loop_proc_hook(struct snd_info_buffer *buffer, | ||
4340 | struct hda_codec *codec, | ||
4341 | unsigned int verb) | ||
4342 | { | ||
4343 | snd_iprintf(buffer, "Analog Loopback: 0x%02x\n", | ||
4344 | snd_hda_codec_read(codec, codec->afg, 0, verb, 0)); | ||
4345 | } | ||
4346 | |||
4347 | /* stac92hd71bxx, stac92hd73xx */ | ||
4348 | static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer, | ||
4349 | struct hda_codec *codec, hda_nid_t nid) | ||
4350 | { | ||
4351 | stac92hd_proc_hook(buffer, codec, nid); | ||
4352 | if (nid == codec->afg) | ||
4353 | analog_loop_proc_hook(buffer, codec, 0xfa0); | ||
4354 | } | ||
4355 | |||
4356 | static void stac9205_proc_hook(struct snd_info_buffer *buffer, | ||
4357 | struct hda_codec *codec, hda_nid_t nid) | ||
4358 | { | ||
4359 | if (nid == codec->afg) | ||
4360 | analog_loop_proc_hook(buffer, codec, 0xfe0); | ||
4361 | } | ||
4362 | |||
4363 | static void stac927x_proc_hook(struct snd_info_buffer *buffer, | ||
4364 | struct hda_codec *codec, hda_nid_t nid) | ||
4365 | { | ||
4366 | if (nid == codec->afg) | ||
4367 | analog_loop_proc_hook(buffer, codec, 0xfeb); | ||
4368 | } | ||
4369 | #else | ||
4370 | #define stac92hd_proc_hook NULL | ||
4371 | #define stac92hd7x_proc_hook NULL | ||
4372 | #define stac9205_proc_hook NULL | ||
4373 | #define stac927x_proc_hook NULL | ||
4374 | #endif | ||
4375 | |||
4320 | #ifdef SND_HDA_NEEDS_RESUME | 4376 | #ifdef SND_HDA_NEEDS_RESUME |
4321 | static int stac92xx_resume(struct hda_codec *codec) | 4377 | static int stac92xx_resume(struct hda_codec *codec) |
4322 | { | 4378 | { |
@@ -4515,6 +4571,7 @@ static int patch_stac92hd73xx(struct hda_codec *codec) | |||
4515 | struct sigmatel_spec *spec; | 4571 | struct sigmatel_spec *spec; |
4516 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; | 4572 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
4517 | int err = 0; | 4573 | int err = 0; |
4574 | int num_dacs; | ||
4518 | 4575 | ||
4519 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 4576 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
4520 | if (spec == NULL) | 4577 | if (spec == NULL) |
@@ -4541,16 +4598,15 @@ again: | |||
4541 | return err; | 4598 | return err; |
4542 | } | 4599 | } |
4543 | 4600 | ||
4544 | spec->multiout.num_dacs = snd_hda_get_connections(codec, 0x0a, | 4601 | num_dacs = snd_hda_get_connections(codec, 0x0a, |
4545 | conn, STAC92HD73_DAC_COUNT + 2) - 1; | 4602 | conn, STAC92HD73_DAC_COUNT + 2) - 1; |
4546 | 4603 | ||
4547 | if (spec->multiout.num_dacs < 0) { | 4604 | if (num_dacs < 3 || num_dacs > 5) { |
4548 | printk(KERN_WARNING "hda_codec: Could not determine " | 4605 | printk(KERN_WARNING "hda_codec: Could not determine " |
4549 | "number of channels defaulting to DAC count\n"); | 4606 | "number of channels defaulting to DAC count\n"); |
4550 | spec->multiout.num_dacs = STAC92HD73_DAC_COUNT; | 4607 | num_dacs = STAC92HD73_DAC_COUNT; |
4551 | } | 4608 | } |
4552 | 4609 | switch (num_dacs) { | |
4553 | switch (spec->multiout.num_dacs) { | ||
4554 | case 0x3: /* 6 Channel */ | 4610 | case 0x3: /* 6 Channel */ |
4555 | spec->mixer = stac92hd73xx_6ch_mixer; | 4611 | spec->mixer = stac92hd73xx_6ch_mixer; |
4556 | spec->init = stac92hd73xx_6ch_core_init; | 4612 | spec->init = stac92hd73xx_6ch_core_init; |
@@ -4562,9 +4618,9 @@ again: | |||
4562 | case 0x5: /* 10 Channel */ | 4618 | case 0x5: /* 10 Channel */ |
4563 | spec->mixer = stac92hd73xx_10ch_mixer; | 4619 | spec->mixer = stac92hd73xx_10ch_mixer; |
4564 | spec->init = stac92hd73xx_10ch_core_init; | 4620 | spec->init = stac92hd73xx_10ch_core_init; |
4565 | }; | 4621 | } |
4622 | spec->multiout.dac_nids = spec->dac_nids; | ||
4566 | 4623 | ||
4567 | spec->multiout.dac_nids = stac92hd73xx_dac_nids; | ||
4568 | spec->aloopback_mask = 0x01; | 4624 | spec->aloopback_mask = 0x01; |
4569 | spec->aloopback_shift = 8; | 4625 | spec->aloopback_shift = 8; |
4570 | 4626 | ||
@@ -4596,7 +4652,7 @@ again: | |||
4596 | spec->eapd_switch = 0; | 4652 | spec->eapd_switch = 0; |
4597 | spec->num_amps = 1; | 4653 | spec->num_amps = 1; |
4598 | 4654 | ||
4599 | if (!spec->init) | 4655 | if (spec->board_config != STAC_DELL_EQ) |
4600 | spec->init = dell_m6_core_init; | 4656 | spec->init = dell_m6_core_init; |
4601 | switch (spec->board_config) { | 4657 | switch (spec->board_config) { |
4602 | case STAC_DELL_M6_AMIC: /* Analog Mics */ | 4658 | case STAC_DELL_M6_AMIC: /* Analog Mics */ |
@@ -4649,8 +4705,13 @@ again: | |||
4649 | return err; | 4705 | return err; |
4650 | } | 4706 | } |
4651 | 4707 | ||
4708 | if (spec->board_config == STAC_92HD73XX_NO_JD) | ||
4709 | spec->hp_detect = 0; | ||
4710 | |||
4652 | codec->patch_ops = stac92xx_patch_ops; | 4711 | codec->patch_ops = stac92xx_patch_ops; |
4653 | 4712 | ||
4713 | codec->proc_widget_hook = stac92hd7x_proc_hook; | ||
4714 | |||
4654 | return 0; | 4715 | return 0; |
4655 | } | 4716 | } |
4656 | 4717 | ||
@@ -4682,17 +4743,15 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
4682 | spec->pwr_nids = stac92hd83xxx_pwr_nids; | 4743 | spec->pwr_nids = stac92hd83xxx_pwr_nids; |
4683 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; | 4744 | spec->pwr_mapping = stac92hd83xxx_pwr_mapping; |
4684 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); | 4745 | spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids); |
4685 | spec->multiout.dac_nids = stac92hd83xxx_dac_nids; | 4746 | spec->multiout.dac_nids = spec->dac_nids; |
4686 | 4747 | ||
4687 | spec->init = stac92hd83xxx_core_init; | 4748 | spec->init = stac92hd83xxx_core_init; |
4688 | switch (codec->vendor_id) { | 4749 | switch (codec->vendor_id) { |
4689 | case 0x111d7605: | 4750 | case 0x111d7605: |
4690 | spec->multiout.num_dacs = STAC92HD81_DAC_COUNT; | ||
4691 | break; | 4751 | break; |
4692 | default: | 4752 | default: |
4693 | spec->num_pwrs--; | 4753 | spec->num_pwrs--; |
4694 | spec->init++; /* switch to config #2 */ | 4754 | spec->init++; /* switch to config #2 */ |
4695 | spec->multiout.num_dacs = STAC92HD83_DAC_COUNT; | ||
4696 | } | 4755 | } |
4697 | 4756 | ||
4698 | spec->mixer = stac92hd83xxx_mixer; | 4757 | spec->mixer = stac92hd83xxx_mixer; |
@@ -4737,51 +4796,11 @@ again: | |||
4737 | 4796 | ||
4738 | codec->patch_ops = stac92xx_patch_ops; | 4797 | codec->patch_ops = stac92xx_patch_ops; |
4739 | 4798 | ||
4740 | return 0; | 4799 | codec->proc_widget_hook = stac92hd_proc_hook; |
4741 | } | ||
4742 | 4800 | ||
4743 | #ifdef SND_HDA_NEEDS_RESUME | 4801 | return 0; |
4744 | static void stac92hd71xx_set_power_state(struct hda_codec *codec, int pwr) | ||
4745 | { | ||
4746 | struct sigmatel_spec *spec = codec->spec; | ||
4747 | int i; | ||
4748 | snd_hda_codec_write_cache(codec, codec->afg, 0, | ||
4749 | AC_VERB_SET_POWER_STATE, pwr); | ||
4750 | |||
4751 | msleep(1); | ||
4752 | for (i = 0; i < spec->num_adcs; i++) { | ||
4753 | snd_hda_codec_write_cache(codec, | ||
4754 | spec->adc_nids[i], 0, | ||
4755 | AC_VERB_SET_POWER_STATE, pwr); | ||
4756 | } | ||
4757 | }; | ||
4758 | |||
4759 | static int stac92hd71xx_resume(struct hda_codec *codec) | ||
4760 | { | ||
4761 | stac92hd71xx_set_power_state(codec, AC_PWRST_D0); | ||
4762 | return stac92xx_resume(codec); | ||
4763 | } | 4802 | } |
4764 | 4803 | ||
4765 | static int stac92hd71xx_suspend(struct hda_codec *codec, pm_message_t state) | ||
4766 | { | ||
4767 | stac92hd71xx_set_power_state(codec, AC_PWRST_D3); | ||
4768 | return stac92xx_suspend(codec, state); | ||
4769 | }; | ||
4770 | |||
4771 | #endif | ||
4772 | |||
4773 | static struct hda_codec_ops stac92hd71bxx_patch_ops = { | ||
4774 | .build_controls = stac92xx_build_controls, | ||
4775 | .build_pcms = stac92xx_build_pcms, | ||
4776 | .init = stac92xx_init, | ||
4777 | .free = stac92xx_free, | ||
4778 | .unsol_event = stac92xx_unsol_event, | ||
4779 | #ifdef SND_HDA_NEEDS_RESUME | ||
4780 | .suspend = stac92hd71xx_suspend, | ||
4781 | .resume = stac92hd71xx_resume, | ||
4782 | #endif | ||
4783 | }; | ||
4784 | |||
4785 | static struct hda_input_mux stac92hd71bxx_dmux = { | 4804 | static struct hda_input_mux stac92hd71bxx_dmux = { |
4786 | .num_items = 4, | 4805 | .num_items = 4, |
4787 | .items = { | 4806 | .items = { |
@@ -4858,12 +4877,8 @@ again: | |||
4858 | break; | 4877 | break; |
4859 | } | 4878 | } |
4860 | if ((codec->revision_id & 0xf) == 0 || | 4879 | if ((codec->revision_id & 0xf) == 0 || |
4861 | (codec->revision_id & 0xf) == 1) { | 4880 | (codec->revision_id & 0xf) == 1) |
4862 | #ifdef SND_HDA_NEEDS_RESUME | ||
4863 | codec->patch_ops = stac92hd71bxx_patch_ops; | ||
4864 | #endif | ||
4865 | spec->stream_delay = 40; /* 40 milliseconds */ | 4881 | spec->stream_delay = 40; /* 40 milliseconds */ |
4866 | } | ||
4867 | 4882 | ||
4868 | /* no output amps */ | 4883 | /* no output amps */ |
4869 | spec->num_pwrs = 0; | 4884 | spec->num_pwrs = 0; |
@@ -4875,12 +4890,8 @@ again: | |||
4875 | stac_change_pin_config(codec, 0xf, 0x40f000f0); | 4890 | stac_change_pin_config(codec, 0xf, 0x40f000f0); |
4876 | break; | 4891 | break; |
4877 | case 0x111d7603: /* 6 Port with Analog Mixer */ | 4892 | case 0x111d7603: /* 6 Port with Analog Mixer */ |
4878 | if ((codec->revision_id & 0xf) == 1) { | 4893 | if ((codec->revision_id & 0xf) == 1) |
4879 | #ifdef SND_HDA_NEEDS_RESUME | ||
4880 | codec->patch_ops = stac92hd71bxx_patch_ops; | ||
4881 | #endif | ||
4882 | spec->stream_delay = 40; /* 40 milliseconds */ | 4894 | spec->stream_delay = 40; /* 40 milliseconds */ |
4883 | } | ||
4884 | 4895 | ||
4885 | /* no output amps */ | 4896 | /* no output amps */ |
4886 | spec->num_pwrs = 0; | 4897 | spec->num_pwrs = 0; |
@@ -4931,9 +4942,7 @@ again: | |||
4931 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); | 4942 | spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids); |
4932 | }; | 4943 | }; |
4933 | 4944 | ||
4934 | spec->multiout.num_dacs = 1; | 4945 | spec->multiout.dac_nids = spec->dac_nids; |
4935 | spec->multiout.hp_nid = 0x11; | ||
4936 | spec->multiout.dac_nids = stac92hd71bxx_dac_nids; | ||
4937 | if (spec->dinput_mux) | 4946 | if (spec->dinput_mux) |
4938 | spec->private_dimux.num_items += | 4947 | spec->private_dimux.num_items += |
4939 | spec->num_dmics - | 4948 | spec->num_dmics - |
@@ -4955,6 +4964,8 @@ again: | |||
4955 | return err; | 4964 | return err; |
4956 | } | 4965 | } |
4957 | 4966 | ||
4967 | codec->proc_widget_hook = stac92hd7x_proc_hook; | ||
4968 | |||
4958 | return 0; | 4969 | return 0; |
4959 | }; | 4970 | }; |
4960 | 4971 | ||
@@ -5175,6 +5186,8 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5175 | 5186 | ||
5176 | codec->patch_ops = stac92xx_patch_ops; | 5187 | codec->patch_ops = stac92xx_patch_ops; |
5177 | 5188 | ||
5189 | codec->proc_widget_hook = stac927x_proc_hook; | ||
5190 | |||
5178 | /* | 5191 | /* |
5179 | * !!FIXME!! | 5192 | * !!FIXME!! |
5180 | * The STAC927x seem to require fairly long delays for certain | 5193 | * The STAC927x seem to require fairly long delays for certain |
@@ -5187,6 +5200,10 @@ static int patch_stac927x(struct hda_codec *codec) | |||
5187 | */ | 5200 | */ |
5188 | codec->bus->needs_damn_long_delay = 1; | 5201 | codec->bus->needs_damn_long_delay = 1; |
5189 | 5202 | ||
5203 | /* no jack detecion for ref-no-jd model */ | ||
5204 | if (spec->board_config == STAC_D965_REF_NO_JD) | ||
5205 | spec->hp_detect = 0; | ||
5206 | |||
5190 | return 0; | 5207 | return 0; |
5191 | } | 5208 | } |
5192 | 5209 | ||
@@ -5290,6 +5307,8 @@ static int patch_stac9205(struct hda_codec *codec) | |||
5290 | 5307 | ||
5291 | codec->patch_ops = stac92xx_patch_ops; | 5308 | codec->patch_ops = stac92xx_patch_ops; |
5292 | 5309 | ||
5310 | codec->proc_widget_hook = stac9205_proc_hook; | ||
5311 | |||
5293 | return 0; | 5312 | return 0; |
5294 | } | 5313 | } |
5295 | 5314 | ||
@@ -5410,7 +5429,7 @@ static int stac9872_vaio_init(struct hda_codec *codec) | |||
5410 | 5429 | ||
5411 | static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res) | 5430 | static void stac9872_vaio_hp_detect(struct hda_codec *codec, unsigned int res) |
5412 | { | 5431 | { |
5413 | if (get_hp_pin_presence(codec, 0x0a)) { | 5432 | if (get_pin_presence(codec, 0x0a)) { |
5414 | stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN); | 5433 | stac92xx_reset_pinctl(codec, 0x0f, AC_PINCTL_OUT_EN); |
5415 | stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN); | 5434 | stac92xx_set_pinctl(codec, 0x0a, AC_PINCTL_OUT_EN); |
5416 | } else { | 5435 | } else { |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 6e4d01d1d502..c761394cbe84 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -3249,73 +3249,73 @@ static int patch_vt1702(struct hda_codec *codec) | |||
3249 | * patch entries | 3249 | * patch entries |
3250 | */ | 3250 | */ |
3251 | static struct hda_codec_preset snd_hda_preset_via[] = { | 3251 | static struct hda_codec_preset snd_hda_preset_via[] = { |
3252 | { .id = 0x11061708, .name = "VIA VT1708", .patch = patch_vt1708}, | 3252 | { .id = 0x11061708, .name = "VT1708", .patch = patch_vt1708}, |
3253 | { .id = 0x11061709, .name = "VIA VT1708", .patch = patch_vt1708}, | 3253 | { .id = 0x11061709, .name = "VT1708", .patch = patch_vt1708}, |
3254 | { .id = 0x1106170A, .name = "VIA VT1708", .patch = patch_vt1708}, | 3254 | { .id = 0x1106170a, .name = "VT1708", .patch = patch_vt1708}, |
3255 | { .id = 0x1106170B, .name = "VIA VT1708", .patch = patch_vt1708}, | 3255 | { .id = 0x1106170b, .name = "VT1708", .patch = patch_vt1708}, |
3256 | { .id = 0x1106E710, .name = "VIA VT1709 10-Ch", | 3256 | { .id = 0x1106e710, .name = "VT1709 10-Ch", |
3257 | .patch = patch_vt1709_10ch}, | 3257 | .patch = patch_vt1709_10ch}, |
3258 | { .id = 0x1106E711, .name = "VIA VT1709 10-Ch", | 3258 | { .id = 0x1106e711, .name = "VT1709 10-Ch", |
3259 | .patch = patch_vt1709_10ch}, | 3259 | .patch = patch_vt1709_10ch}, |
3260 | { .id = 0x1106E712, .name = "VIA VT1709 10-Ch", | 3260 | { .id = 0x1106e712, .name = "VT1709 10-Ch", |
3261 | .patch = patch_vt1709_10ch}, | 3261 | .patch = patch_vt1709_10ch}, |
3262 | { .id = 0x1106E713, .name = "VIA VT1709 10-Ch", | 3262 | { .id = 0x1106e713, .name = "VT1709 10-Ch", |
3263 | .patch = patch_vt1709_10ch}, | 3263 | .patch = patch_vt1709_10ch}, |
3264 | { .id = 0x1106E714, .name = "VIA VT1709 6-Ch", | 3264 | { .id = 0x1106e714, .name = "VT1709 6-Ch", |
3265 | .patch = patch_vt1709_6ch}, | 3265 | .patch = patch_vt1709_6ch}, |
3266 | { .id = 0x1106E715, .name = "VIA VT1709 6-Ch", | 3266 | { .id = 0x1106e715, .name = "VT1709 6-Ch", |
3267 | .patch = patch_vt1709_6ch}, | 3267 | .patch = patch_vt1709_6ch}, |
3268 | { .id = 0x1106E716, .name = "VIA VT1709 6-Ch", | 3268 | { .id = 0x1106e716, .name = "VT1709 6-Ch", |
3269 | .patch = patch_vt1709_6ch}, | 3269 | .patch = patch_vt1709_6ch}, |
3270 | { .id = 0x1106E717, .name = "VIA VT1709 6-Ch", | 3270 | { .id = 0x1106e717, .name = "VT1709 6-Ch", |
3271 | .patch = patch_vt1709_6ch}, | 3271 | .patch = patch_vt1709_6ch}, |
3272 | { .id = 0x1106E720, .name = "VIA VT1708B 8-Ch", | 3272 | { .id = 0x1106e720, .name = "VT1708B 8-Ch", |
3273 | .patch = patch_vt1708B_8ch}, | 3273 | .patch = patch_vt1708B_8ch}, |
3274 | { .id = 0x1106E721, .name = "VIA VT1708B 8-Ch", | 3274 | { .id = 0x1106e721, .name = "VT1708B 8-Ch", |
3275 | .patch = patch_vt1708B_8ch}, | 3275 | .patch = patch_vt1708B_8ch}, |
3276 | { .id = 0x1106E722, .name = "VIA VT1708B 8-Ch", | 3276 | { .id = 0x1106e722, .name = "VT1708B 8-Ch", |
3277 | .patch = patch_vt1708B_8ch}, | 3277 | .patch = patch_vt1708B_8ch}, |
3278 | { .id = 0x1106E723, .name = "VIA VT1708B 8-Ch", | 3278 | { .id = 0x1106e723, .name = "VT1708B 8-Ch", |
3279 | .patch = patch_vt1708B_8ch}, | 3279 | .patch = patch_vt1708B_8ch}, |
3280 | { .id = 0x1106E724, .name = "VIA VT1708B 4-Ch", | 3280 | { .id = 0x1106e724, .name = "VT1708B 4-Ch", |
3281 | .patch = patch_vt1708B_4ch}, | 3281 | .patch = patch_vt1708B_4ch}, |
3282 | { .id = 0x1106E725, .name = "VIA VT1708B 4-Ch", | 3282 | { .id = 0x1106e725, .name = "VT1708B 4-Ch", |
3283 | .patch = patch_vt1708B_4ch}, | 3283 | .patch = patch_vt1708B_4ch}, |
3284 | { .id = 0x1106E726, .name = "VIA VT1708B 4-Ch", | 3284 | { .id = 0x1106e726, .name = "VT1708B 4-Ch", |
3285 | .patch = patch_vt1708B_4ch}, | 3285 | .patch = patch_vt1708B_4ch}, |
3286 | { .id = 0x1106E727, .name = "VIA VT1708B 4-Ch", | 3286 | { .id = 0x1106e727, .name = "VT1708B 4-Ch", |
3287 | .patch = patch_vt1708B_4ch}, | 3287 | .patch = patch_vt1708B_4ch}, |
3288 | { .id = 0x11060397, .name = "VIA VT1708S", | 3288 | { .id = 0x11060397, .name = "VT1708S", |
3289 | .patch = patch_vt1708S}, | 3289 | .patch = patch_vt1708S}, |
3290 | { .id = 0x11061397, .name = "VIA VT1708S", | 3290 | { .id = 0x11061397, .name = "VT1708S", |
3291 | .patch = patch_vt1708S}, | 3291 | .patch = patch_vt1708S}, |
3292 | { .id = 0x11062397, .name = "VIA VT1708S", | 3292 | { .id = 0x11062397, .name = "VT1708S", |
3293 | .patch = patch_vt1708S}, | 3293 | .patch = patch_vt1708S}, |
3294 | { .id = 0x11063397, .name = "VIA VT1708S", | 3294 | { .id = 0x11063397, .name = "VT1708S", |
3295 | .patch = patch_vt1708S}, | 3295 | .patch = patch_vt1708S}, |
3296 | { .id = 0x11064397, .name = "VIA VT1708S", | 3296 | { .id = 0x11064397, .name = "VT1708S", |
3297 | .patch = patch_vt1708S}, | 3297 | .patch = patch_vt1708S}, |
3298 | { .id = 0x11065397, .name = "VIA VT1708S", | 3298 | { .id = 0x11065397, .name = "VT1708S", |
3299 | .patch = patch_vt1708S}, | 3299 | .patch = patch_vt1708S}, |
3300 | { .id = 0x11066397, .name = "VIA VT1708S", | 3300 | { .id = 0x11066397, .name = "VT1708S", |
3301 | .patch = patch_vt1708S}, | 3301 | .patch = patch_vt1708S}, |
3302 | { .id = 0x11067397, .name = "VIA VT1708S", | 3302 | { .id = 0x11067397, .name = "VT1708S", |
3303 | .patch = patch_vt1708S}, | 3303 | .patch = patch_vt1708S}, |
3304 | { .id = 0x11060398, .name = "VIA VT1702", | 3304 | { .id = 0x11060398, .name = "VT1702", |
3305 | .patch = patch_vt1702}, | 3305 | .patch = patch_vt1702}, |
3306 | { .id = 0x11061398, .name = "VIA VT1702", | 3306 | { .id = 0x11061398, .name = "VT1702", |
3307 | .patch = patch_vt1702}, | 3307 | .patch = patch_vt1702}, |
3308 | { .id = 0x11062398, .name = "VIA VT1702", | 3308 | { .id = 0x11062398, .name = "VT1702", |
3309 | .patch = patch_vt1702}, | 3309 | .patch = patch_vt1702}, |
3310 | { .id = 0x11063398, .name = "VIA VT1702", | 3310 | { .id = 0x11063398, .name = "VT1702", |
3311 | .patch = patch_vt1702}, | 3311 | .patch = patch_vt1702}, |
3312 | { .id = 0x11064398, .name = "VIA VT1702", | 3312 | { .id = 0x11064398, .name = "VT1702", |
3313 | .patch = patch_vt1702}, | 3313 | .patch = patch_vt1702}, |
3314 | { .id = 0x11065398, .name = "VIA VT1702", | 3314 | { .id = 0x11065398, .name = "VT1702", |
3315 | .patch = patch_vt1702}, | 3315 | .patch = patch_vt1702}, |
3316 | { .id = 0x11066398, .name = "VIA VT1702", | 3316 | { .id = 0x11066398, .name = "VT1702", |
3317 | .patch = patch_vt1702}, | 3317 | .patch = patch_vt1702}, |
3318 | { .id = 0x11067398, .name = "VIA VT1702", | 3318 | { .id = 0x11067398, .name = "VT1702", |
3319 | .patch = patch_vt1702}, | 3319 | .patch = patch_vt1702}, |
3320 | {} /* terminator */ | 3320 | {} /* terminator */ |
3321 | }; | 3321 | }; |
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c index 5b442383fcda..58d7cda03de5 100644 --- a/sound/pci/ice1712/ice1712.c +++ b/sound/pci/ice1712/ice1712.c | |||
@@ -2688,12 +2688,13 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci, | |||
2688 | return err; | 2688 | return err; |
2689 | } | 2689 | } |
2690 | 2690 | ||
2691 | if (ice_has_con_ac97(ice)) | 2691 | if (ice_has_con_ac97(ice)) { |
2692 | err = snd_ice1712_pcm(ice, pcm_dev++, NULL); | 2692 | err = snd_ice1712_pcm(ice, pcm_dev++, NULL); |
2693 | if (err < 0) { | 2693 | if (err < 0) { |
2694 | snd_card_free(card); | 2694 | snd_card_free(card); |
2695 | return err; | 2695 | return err; |
2696 | } | 2696 | } |
2697 | } | ||
2697 | 2698 | ||
2698 | err = snd_ice1712_ac97_mixer(ice); | 2699 | err = snd_ice1712_ac97_mixer(ice); |
2699 | if (err < 0) { | 2700 | if (err < 0) { |
@@ -2715,12 +2716,13 @@ static int __devinit snd_ice1712_probe(struct pci_dev *pci, | |||
2715 | } | 2716 | } |
2716 | } | 2717 | } |
2717 | 2718 | ||
2718 | if (ice_has_con_ac97(ice)) | 2719 | if (ice_has_con_ac97(ice)) { |
2719 | err = snd_ice1712_pcm_ds(ice, pcm_dev++, NULL); | 2720 | err = snd_ice1712_pcm_ds(ice, pcm_dev++, NULL); |
2720 | if (err < 0) { | 2721 | if (err < 0) { |
2721 | snd_card_free(card); | 2722 | snd_card_free(card); |
2722 | return err; | 2723 | return err; |
2723 | } | 2724 | } |
2725 | } | ||
2724 | 2726 | ||
2725 | if (!c->no_mpu401) { | 2727 | if (!c->no_mpu401) { |
2726 | err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712, | 2728 | err = snd_mpu401_uart_new(card, 0, MPU401_HW_ICE1712, |
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c index 1b3f11702713..bb8d8c766b9d 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); |
@@ -1237,7 +1239,7 @@ static int __devinit snd_vt1724_pcm_spdif(struct snd_ice1712 *ice, int device) | |||
1237 | if (ice->force_pdma4 || ice->force_rdma1) | 1239 | if (ice->force_pdma4 || ice->force_rdma1) |
1238 | name = "ICE1724 Secondary"; | 1240 | name = "ICE1724 Secondary"; |
1239 | else | 1241 | else |
1240 | name = "IEC1724 IEC958"; | 1242 | name = "ICE1724 IEC958"; |
1241 | err = snd_pcm_new(ice->card, name, device, play, capt, &pcm); | 1243 | err = snd_pcm_new(ice->card, name, device, play, capt, &pcm); |
1242 | if (err < 0) | 1244 | if (err < 0) |
1243 | return err; | 1245 | return err; |
@@ -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/intel8x0.c b/sound/pci/intel8x0.c index c88d1eace1c4..19d3391e229f 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c | |||
@@ -2702,6 +2702,7 @@ static struct snd_pci_quirk intel8x0_clock_list[] __devinitdata = { | |||
2702 | SND_PCI_QUIRK(0x0e11, 0x008a, "AD1885", 41000), | 2702 | SND_PCI_QUIRK(0x0e11, 0x008a, "AD1885", 41000), |
2703 | SND_PCI_QUIRK(0x1028, 0x00be, "AD1885", 44100), | 2703 | SND_PCI_QUIRK(0x1028, 0x00be, "AD1885", 44100), |
2704 | SND_PCI_QUIRK(0x1028, 0x0177, "AD1980", 48000), | 2704 | SND_PCI_QUIRK(0x1028, 0x0177, "AD1980", 48000), |
2705 | SND_PCI_QUIRK(0x1028, 0x01ad, "AD1981B", 48000), | ||
2705 | SND_PCI_QUIRK(0x1043, 0x80f3, "AD1985", 48000), | 2706 | SND_PCI_QUIRK(0x1043, 0x80f3, "AD1985", 48000), |
2706 | { } /* terminator */ | 2707 | { } /* terminator */ |
2707 | }; | 2708 | }; |
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 9ff3f9e34404..59bbaf8f3e5b 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c | |||
@@ -1670,7 +1670,7 @@ static irqreturn_t snd_m3_interrupt(int irq, void *dev_id) | |||
1670 | return IRQ_NONE; | 1670 | return IRQ_NONE; |
1671 | 1671 | ||
1672 | if (status & HV_INT_PENDING) | 1672 | if (status & HV_INT_PENDING) |
1673 | tasklet_hi_schedule(&chip->hwvol_tq); | 1673 | tasklet_schedule(&chip->hwvol_tq); |
1674 | 1674 | ||
1675 | /* | 1675 | /* |
1676 | * ack an assp int if its running | 1676 | * ack an assp int if its running |
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 2d0dce649a64..f23a73577c22 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; |
@@ -1314,8 +1315,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, | |||
1314 | } | 1315 | } |
1315 | for (i = 0; i < 2; i++) { | 1316 | for (i = 0; i < 2; i++) { |
1316 | mgr->mem[i].phys = pci_resource_start(pci, i); | 1317 | mgr->mem[i].phys = pci_resource_start(pci, i); |
1317 | mgr->mem[i].virt = ioremap_nocache(mgr->mem[i].phys, | 1318 | mgr->mem[i].virt = pci_ioremap_bar(pci, i); |
1318 | pci_resource_len(pci, i)); | ||
1319 | if (!mgr->mem[i].virt) { | 1319 | if (!mgr->mem[i].virt) { |
1320 | printk(KERN_ERR "unable to remap resource 0x%lx\n", | 1320 | printk(KERN_ERR "unable to remap resource 0x%lx\n", |
1321 | mgr->mem[i].phys); | 1321 | mgr->mem[i].phys); |
@@ -1378,6 +1378,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci, | |||
1378 | sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); | 1378 | sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); |
1379 | 1379 | ||
1380 | if ((err = snd_mixart_create(mgr, card, i)) < 0) { | 1380 | if ((err = snd_mixart_create(mgr, card, i)) < 0) { |
1381 | snd_card_free(card); | ||
1381 | snd_mixart_free(mgr); | 1382 | snd_mixart_free(mgr); |
1382 | return err; | 1383 | return err; |
1383 | } | 1384 | } |
diff --git a/sound/pci/mixart/mixart_core.c b/sound/pci/mixart/mixart_core.c index b9a06c279397..d3350f383966 100644 --- a/sound/pci/mixart/mixart_core.c +++ b/sound/pci/mixart/mixart_core.c | |||
@@ -550,7 +550,7 @@ irqreturn_t snd_mixart_interrupt(int irq, void *dev_id) | |||
550 | mgr->msg_fifo[mgr->msg_fifo_writeptr] = msg; | 550 | mgr->msg_fifo[mgr->msg_fifo_writeptr] = msg; |
551 | mgr->msg_fifo_writeptr++; | 551 | mgr->msg_fifo_writeptr++; |
552 | mgr->msg_fifo_writeptr %= MSG_FIFO_SIZE; | 552 | mgr->msg_fifo_writeptr %= MSG_FIFO_SIZE; |
553 | tasklet_hi_schedule(&mgr->msg_taskq); | 553 | tasklet_schedule(&mgr->msg_taskq); |
554 | } | 554 | } |
555 | spin_unlock(&mgr->msg_lock); | 555 | spin_unlock(&mgr->msg_lock); |
556 | break; | 556 | break; |
diff --git a/sound/pci/oxygen/oxygen.c b/sound/pci/oxygen/oxygen.c index b60f6212745a..de999c6d6dd3 100644 --- a/sound/pci/oxygen/oxygen.c +++ b/sound/pci/oxygen/oxygen.c | |||
@@ -61,6 +61,7 @@ MODULE_PARM_DESC(enable, "enable card"); | |||
61 | enum { | 61 | enum { |
62 | MODEL_CMEDIA_REF, /* C-Media's reference design */ | 62 | MODEL_CMEDIA_REF, /* C-Media's reference design */ |
63 | MODEL_MERIDIAN, /* AuzenTech X-Meridian */ | 63 | MODEL_MERIDIAN, /* AuzenTech X-Meridian */ |
64 | MODEL_HALO, /* HT-Omega Claro halo */ | ||
64 | }; | 65 | }; |
65 | 66 | ||
66 | static struct pci_device_id oxygen_ids[] __devinitdata = { | 67 | static struct pci_device_id oxygen_ids[] __devinitdata = { |
@@ -74,6 +75,7 @@ static struct pci_device_id oxygen_ids[] __devinitdata = { | |||
74 | { OXYGEN_PCI_SUBID(0x1a58, 0x0910), .driver_data = MODEL_CMEDIA_REF }, | 75 | { OXYGEN_PCI_SUBID(0x1a58, 0x0910), .driver_data = MODEL_CMEDIA_REF }, |
75 | { OXYGEN_PCI_SUBID(0x415a, 0x5431), .driver_data = MODEL_MERIDIAN }, | 76 | { OXYGEN_PCI_SUBID(0x415a, 0x5431), .driver_data = MODEL_MERIDIAN }, |
76 | { OXYGEN_PCI_SUBID(0x7284, 0x9761), .driver_data = MODEL_CMEDIA_REF }, | 77 | { OXYGEN_PCI_SUBID(0x7284, 0x9761), .driver_data = MODEL_CMEDIA_REF }, |
78 | { OXYGEN_PCI_SUBID(0x7284, 0x9781), .driver_data = MODEL_HALO }, | ||
77 | { } | 79 | { } |
78 | }; | 80 | }; |
79 | MODULE_DEVICE_TABLE(pci, oxygen_ids); | 81 | MODULE_DEVICE_TABLE(pci, oxygen_ids); |
@@ -301,6 +303,8 @@ static int generic_probe(struct oxygen *chip, unsigned long driver_data) | |||
301 | PLAYBACK_1_TO_SPDIF | | 303 | PLAYBACK_1_TO_SPDIF | |
302 | CAPTURE_0_FROM_I2S_2 | | 304 | CAPTURE_0_FROM_I2S_2 | |
303 | CAPTURE_1_FROM_SPDIF; | 305 | CAPTURE_1_FROM_SPDIF; |
306 | } | ||
307 | if (driver_data == MODEL_MERIDIAN || driver_data == MODEL_HALO) { | ||
304 | chip->model.misc_flags = OXYGEN_MISC_MIDI; | 308 | chip->model.misc_flags = OXYGEN_MISC_MIDI; |
305 | chip->model.device_config |= MIDI_OUTPUT | MIDI_INPUT; | 309 | chip->model.device_config |= MIDI_OUTPUT | MIDI_INPUT; |
306 | } | 310 | } |
diff --git a/sound/pci/pcxhr/Makefile b/sound/pci/pcxhr/Makefile index 10473c05918d..b06128e918ca 100644 --- a/sound/pci/pcxhr/Makefile +++ b/sound/pci/pcxhr/Makefile | |||
@@ -1,2 +1,2 @@ | |||
1 | snd-pcxhr-objs := pcxhr.o pcxhr_hwdep.o pcxhr_mixer.o pcxhr_core.o | 1 | snd-pcxhr-objs := pcxhr.o pcxhr_hwdep.o pcxhr_mixer.o pcxhr_core.o pcxhr_mix22.o |
2 | obj-$(CONFIG_SND_PCXHR) += snd-pcxhr.o | 2 | obj-$(CONFIG_SND_PCXHR) += snd-pcxhr.o |
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 0e06c6c9fcc0..27cf2c28d113 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c | |||
@@ -40,18 +40,20 @@ | |||
40 | #include "pcxhr_mixer.h" | 40 | #include "pcxhr_mixer.h" |
41 | #include "pcxhr_hwdep.h" | 41 | #include "pcxhr_hwdep.h" |
42 | #include "pcxhr_core.h" | 42 | #include "pcxhr_core.h" |
43 | #include "pcxhr_mix22.h" | ||
43 | 44 | ||
44 | #define DRIVER_NAME "pcxhr" | 45 | #define DRIVER_NAME "pcxhr" |
45 | 46 | ||
46 | MODULE_AUTHOR("Markus Bollinger <bollinger@digigram.com>"); | 47 | MODULE_AUTHOR("Markus Bollinger <bollinger@digigram.com>, " |
48 | "Marc Titinger <titinger@digigram.com>"); | ||
47 | MODULE_DESCRIPTION("Digigram " DRIVER_NAME " " PCXHR_DRIVER_VERSION_STRING); | 49 | MODULE_DESCRIPTION("Digigram " DRIVER_NAME " " PCXHR_DRIVER_VERSION_STRING); |
48 | MODULE_LICENSE("GPL"); | 50 | MODULE_LICENSE("GPL"); |
49 | MODULE_SUPPORTED_DEVICE("{{Digigram," DRIVER_NAME "}}"); | 51 | MODULE_SUPPORTED_DEVICE("{{Digigram," DRIVER_NAME "}}"); |
50 | 52 | ||
51 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | 53 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ |
52 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | 54 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ |
53 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ | 55 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;/* Enable this card */ |
54 | static int mono[SNDRV_CARDS]; /* capture in mono only */ | 56 | static int mono[SNDRV_CARDS]; /* capture mono only */ |
55 | 57 | ||
56 | module_param_array(index, int, NULL, 0444); | 58 | module_param_array(index, int, NULL, 0444); |
57 | MODULE_PARM_DESC(index, "Index value for Digigram " DRIVER_NAME " soundcard"); | 59 | MODULE_PARM_DESC(index, "Index value for Digigram " DRIVER_NAME " soundcard"); |
@@ -67,18 +69,58 @@ enum { | |||
67 | PCI_ID_PCX882HR, | 69 | PCI_ID_PCX882HR, |
68 | PCI_ID_VX881HR, | 70 | PCI_ID_VX881HR, |
69 | PCI_ID_PCX881HR, | 71 | PCI_ID_PCX881HR, |
72 | PCI_ID_VX882E, | ||
73 | PCI_ID_PCX882E, | ||
74 | PCI_ID_VX881E, | ||
75 | PCI_ID_PCX881E, | ||
76 | PCI_ID_VX1222HR, | ||
70 | PCI_ID_PCX1222HR, | 77 | PCI_ID_PCX1222HR, |
78 | PCI_ID_VX1221HR, | ||
71 | PCI_ID_PCX1221HR, | 79 | PCI_ID_PCX1221HR, |
80 | PCI_ID_VX1222E, | ||
81 | PCI_ID_PCX1222E, | ||
82 | PCI_ID_VX1221E, | ||
83 | PCI_ID_PCX1221E, | ||
84 | PCI_ID_VX222HR, | ||
85 | PCI_ID_VX222E, | ||
86 | PCI_ID_PCX22HR, | ||
87 | PCI_ID_PCX22E, | ||
88 | PCI_ID_VX222HRMIC, | ||
89 | PCI_ID_VX222E_MIC, | ||
90 | PCI_ID_PCX924HR, | ||
91 | PCI_ID_PCX924E, | ||
92 | PCI_ID_PCX924HRMIC, | ||
93 | PCI_ID_PCX924E_MIC, | ||
72 | PCI_ID_LAST | 94 | PCI_ID_LAST |
73 | }; | 95 | }; |
74 | 96 | ||
75 | static struct pci_device_id pcxhr_ids[] = { | 97 | static struct pci_device_id pcxhr_ids[] = { |
76 | { 0x10b5, 0x9656, 0x1369, 0xb001, 0, 0, PCI_ID_VX882HR, }, /* VX882HR */ | 98 | { 0x10b5, 0x9656, 0x1369, 0xb001, 0, 0, PCI_ID_VX882HR, }, |
77 | { 0x10b5, 0x9656, 0x1369, 0xb101, 0, 0, PCI_ID_PCX882HR, }, /* PCX882HR */ | 99 | { 0x10b5, 0x9656, 0x1369, 0xb101, 0, 0, PCI_ID_PCX882HR, }, |
78 | { 0x10b5, 0x9656, 0x1369, 0xb201, 0, 0, PCI_ID_VX881HR, }, /* VX881HR */ | 100 | { 0x10b5, 0x9656, 0x1369, 0xb201, 0, 0, PCI_ID_VX881HR, }, |
79 | { 0x10b5, 0x9656, 0x1369, 0xb301, 0, 0, PCI_ID_PCX881HR, }, /* PCX881HR */ | 101 | { 0x10b5, 0x9656, 0x1369, 0xb301, 0, 0, PCI_ID_PCX881HR, }, |
80 | { 0x10b5, 0x9656, 0x1369, 0xb501, 0, 0, PCI_ID_PCX1222HR, }, /* PCX1222HR */ | 102 | { 0x10b5, 0x9056, 0x1369, 0xb021, 0, 0, PCI_ID_VX882E, }, |
81 | { 0x10b5, 0x9656, 0x1369, 0xb701, 0, 0, PCI_ID_PCX1221HR, }, /* PCX1221HR */ | 103 | { 0x10b5, 0x9056, 0x1369, 0xb121, 0, 0, PCI_ID_PCX882E, }, |
104 | { 0x10b5, 0x9056, 0x1369, 0xb221, 0, 0, PCI_ID_VX881E, }, | ||
105 | { 0x10b5, 0x9056, 0x1369, 0xb321, 0, 0, PCI_ID_PCX881E, }, | ||
106 | { 0x10b5, 0x9656, 0x1369, 0xb401, 0, 0, PCI_ID_VX1222HR, }, | ||
107 | { 0x10b5, 0x9656, 0x1369, 0xb501, 0, 0, PCI_ID_PCX1222HR, }, | ||
108 | { 0x10b5, 0x9656, 0x1369, 0xb601, 0, 0, PCI_ID_VX1221HR, }, | ||
109 | { 0x10b5, 0x9656, 0x1369, 0xb701, 0, 0, PCI_ID_PCX1221HR, }, | ||
110 | { 0x10b5, 0x9056, 0x1369, 0xb421, 0, 0, PCI_ID_VX1222E, }, | ||
111 | { 0x10b5, 0x9056, 0x1369, 0xb521, 0, 0, PCI_ID_PCX1222E, }, | ||
112 | { 0x10b5, 0x9056, 0x1369, 0xb621, 0, 0, PCI_ID_VX1221E, }, | ||
113 | { 0x10b5, 0x9056, 0x1369, 0xb721, 0, 0, PCI_ID_PCX1221E, }, | ||
114 | { 0x10b5, 0x9056, 0x1369, 0xba01, 0, 0, PCI_ID_VX222HR, }, | ||
115 | { 0x10b5, 0x9056, 0x1369, 0xba21, 0, 0, PCI_ID_VX222E, }, | ||
116 | { 0x10b5, 0x9056, 0x1369, 0xbd01, 0, 0, PCI_ID_PCX22HR, }, | ||
117 | { 0x10b5, 0x9056, 0x1369, 0xbd21, 0, 0, PCI_ID_PCX22E, }, | ||
118 | { 0x10b5, 0x9056, 0x1369, 0xbc01, 0, 0, PCI_ID_VX222HRMIC, }, | ||
119 | { 0x10b5, 0x9056, 0x1369, 0xbc21, 0, 0, PCI_ID_VX222E_MIC, }, | ||
120 | { 0x10b5, 0x9056, 0x1369, 0xbb01, 0, 0, PCI_ID_PCX924HR, }, | ||
121 | { 0x10b5, 0x9056, 0x1369, 0xbb21, 0, 0, PCI_ID_PCX924E, }, | ||
122 | { 0x10b5, 0x9056, 0x1369, 0xbf01, 0, 0, PCI_ID_PCX924HRMIC, }, | ||
123 | { 0x10b5, 0x9056, 0x1369, 0xbf21, 0, 0, PCI_ID_PCX924E_MIC, }, | ||
82 | { 0, } | 124 | { 0, } |
83 | }; | 125 | }; |
84 | 126 | ||
@@ -88,27 +130,55 @@ struct board_parameters { | |||
88 | char* board_name; | 130 | char* board_name; |
89 | short playback_chips; | 131 | short playback_chips; |
90 | short capture_chips; | 132 | short capture_chips; |
133 | short fw_file_set; | ||
91 | short firmware_num; | 134 | short firmware_num; |
92 | }; | 135 | }; |
93 | static struct board_parameters pcxhr_board_params[] = { | 136 | static struct board_parameters pcxhr_board_params[] = { |
94 | [PCI_ID_VX882HR] = { "VX882HR", 4, 4, 41, }, | 137 | [PCI_ID_VX882HR] = { "VX882HR", 4, 4, 0, 41 }, |
95 | [PCI_ID_PCX882HR] = { "PCX882HR", 4, 4, 41, }, | 138 | [PCI_ID_PCX882HR] = { "PCX882HR", 4, 4, 0, 41 }, |
96 | [PCI_ID_VX881HR] = { "VX881HR", 4, 4, 41, }, | 139 | [PCI_ID_VX881HR] = { "VX881HR", 4, 4, 0, 41 }, |
97 | [PCI_ID_PCX881HR] = { "PCX881HR", 4, 4, 41, }, | 140 | [PCI_ID_PCX881HR] = { "PCX881HR", 4, 4, 0, 41 }, |
98 | [PCI_ID_PCX1222HR] = { "PCX1222HR", 6, 1, 42, }, | 141 | [PCI_ID_VX882E] = { "VX882e", 4, 4, 1, 41 }, |
99 | [PCI_ID_PCX1221HR] = { "PCX1221HR", 6, 1, 42, }, | 142 | [PCI_ID_PCX882E] = { "PCX882e", 4, 4, 1, 41 }, |
143 | [PCI_ID_VX881E] = { "VX881e", 4, 4, 1, 41 }, | ||
144 | [PCI_ID_PCX881E] = { "PCX881e", 4, 4, 1, 41 }, | ||
145 | [PCI_ID_VX1222HR] = { "VX1222HR", 6, 1, 2, 42 }, | ||
146 | [PCI_ID_PCX1222HR] = { "PCX1222HR", 6, 1, 2, 42 }, | ||
147 | [PCI_ID_VX1221HR] = { "VX1221HR", 6, 1, 2, 42 }, | ||
148 | [PCI_ID_PCX1221HR] = { "PCX1221HR", 6, 1, 2, 42 }, | ||
149 | [PCI_ID_VX1222E] = { "VX1222e", 6, 1, 3, 42 }, | ||
150 | [PCI_ID_PCX1222E] = { "PCX1222e", 6, 1, 3, 42 }, | ||
151 | [PCI_ID_VX1221E] = { "VX1221e", 6, 1, 3, 42 }, | ||
152 | [PCI_ID_PCX1221E] = { "PCX1221e", 6, 1, 3, 42 }, | ||
153 | [PCI_ID_VX222HR] = { "VX222HR", 1, 1, 4, 44 }, | ||
154 | [PCI_ID_VX222E] = { "VX222e", 1, 1, 4, 44 }, | ||
155 | [PCI_ID_PCX22HR] = { "PCX22HR", 1, 0, 4, 44 }, | ||
156 | [PCI_ID_PCX22E] = { "PCX22e", 1, 0, 4, 44 }, | ||
157 | [PCI_ID_VX222HRMIC] = { "VX222HR-Mic", 1, 1, 5, 44 }, | ||
158 | [PCI_ID_VX222E_MIC] = { "VX222e-Mic", 1, 1, 5, 44 }, | ||
159 | [PCI_ID_PCX924HR] = { "PCX924HR", 1, 1, 5, 44 }, | ||
160 | [PCI_ID_PCX924E] = { "PCX924e", 1, 1, 5, 44 }, | ||
161 | [PCI_ID_PCX924HRMIC] = { "PCX924HR-Mic", 1, 1, 5, 44 }, | ||
162 | [PCI_ID_PCX924E_MIC] = { "PCX924e-Mic", 1, 1, 5, 44 }, | ||
100 | }; | 163 | }; |
101 | 164 | ||
165 | /* boards without hw AES1 and SRC onboard are all using fw_file_set==4 */ | ||
166 | /* VX222HR, VX222e, PCX22HR and PCX22e */ | ||
167 | #define PCXHR_BOARD_HAS_AES1(x) (x->fw_file_set != 4) | ||
168 | /* some boards do not support 192kHz on digital AES input plugs */ | ||
169 | #define PCXHR_BOARD_AESIN_NO_192K(x) ((x->capture_chips == 0) || \ | ||
170 | (x->fw_file_set == 0) || \ | ||
171 | (x->fw_file_set == 2)) | ||
102 | 172 | ||
103 | static int pcxhr_pll_freq_register(unsigned int freq, unsigned int* pllreg, | 173 | static int pcxhr_pll_freq_register(unsigned int freq, unsigned int* pllreg, |
104 | unsigned int* realfreq) | 174 | unsigned int* realfreq) |
105 | { | 175 | { |
106 | unsigned int reg; | 176 | unsigned int reg; |
107 | 177 | ||
108 | if (freq < 6900 || freq > 110250) | 178 | if (freq < 6900 || freq > 110000) |
109 | return -EINVAL; | 179 | return -EINVAL; |
110 | reg = (28224000 * 10) / freq; | 180 | reg = (28224000 * 2) / freq; |
111 | reg = (reg + 5) / 10; | 181 | reg = (reg - 1) / 2; |
112 | if (reg < 0x200) | 182 | if (reg < 0x200) |
113 | *pllreg = reg + 0x800; | 183 | *pllreg = reg + 0x800; |
114 | else if (reg < 0x400) | 184 | else if (reg < 0x400) |
@@ -121,7 +191,7 @@ static int pcxhr_pll_freq_register(unsigned int freq, unsigned int* pllreg, | |||
121 | reg &= ~3; | 191 | reg &= ~3; |
122 | } | 192 | } |
123 | if (realfreq) | 193 | if (realfreq) |
124 | *realfreq = ((28224000 * 10) / reg + 5) / 10; | 194 | *realfreq = (28224000 / (reg + 1)); |
125 | return 0; | 195 | return 0; |
126 | } | 196 | } |
127 | 197 | ||
@@ -151,11 +221,6 @@ static int pcxhr_pll_freq_register(unsigned int freq, unsigned int* pllreg, | |||
151 | #define PCXHR_FREQ_AES_3 0x03 | 221 | #define PCXHR_FREQ_AES_3 0x03 |
152 | #define PCXHR_FREQ_AES_4 0x0d | 222 | #define PCXHR_FREQ_AES_4 0x0d |
153 | 223 | ||
154 | #define PCXHR_MODIFY_CLOCK_S_BIT 0x04 | ||
155 | |||
156 | #define PCXHR_IRQ_TIMER_FREQ 92000 | ||
157 | #define PCXHR_IRQ_TIMER_PERIOD 48 | ||
158 | |||
159 | static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate, | 224 | static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate, |
160 | unsigned int *reg, unsigned int *freq) | 225 | unsigned int *reg, unsigned int *freq) |
161 | { | 226 | { |
@@ -196,19 +261,32 @@ static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate, | |||
196 | err = pcxhr_send_msg(mgr, &rmh); | 261 | err = pcxhr_send_msg(mgr, &rmh); |
197 | if (err < 0) { | 262 | if (err < 0) { |
198 | snd_printk(KERN_ERR | 263 | snd_printk(KERN_ERR |
199 | "error CMD_ACCESS_IO_WRITE for PLL register : %x!\n", | 264 | "error CMD_ACCESS_IO_WRITE " |
200 | err ); | 265 | "for PLL register : %x!\n", err); |
201 | return err; | 266 | return err; |
202 | } | 267 | } |
203 | } | 268 | } |
204 | break; | 269 | break; |
205 | case PCXHR_CLOCK_TYPE_WORD_CLOCK : val = PCXHR_FREQ_WORD_CLOCK; break; | 270 | case PCXHR_CLOCK_TYPE_WORD_CLOCK: |
206 | case PCXHR_CLOCK_TYPE_AES_SYNC : val = PCXHR_FREQ_SYNC_AES; break; | 271 | val = PCXHR_FREQ_WORD_CLOCK; |
207 | case PCXHR_CLOCK_TYPE_AES_1 : val = PCXHR_FREQ_AES_1; break; | 272 | break; |
208 | case PCXHR_CLOCK_TYPE_AES_2 : val = PCXHR_FREQ_AES_2; break; | 273 | case PCXHR_CLOCK_TYPE_AES_SYNC: |
209 | case PCXHR_CLOCK_TYPE_AES_3 : val = PCXHR_FREQ_AES_3; break; | 274 | val = PCXHR_FREQ_SYNC_AES; |
210 | case PCXHR_CLOCK_TYPE_AES_4 : val = PCXHR_FREQ_AES_4; break; | 275 | break; |
211 | default : return -EINVAL; | 276 | case PCXHR_CLOCK_TYPE_AES_1: |
277 | val = PCXHR_FREQ_AES_1; | ||
278 | break; | ||
279 | case PCXHR_CLOCK_TYPE_AES_2: | ||
280 | val = PCXHR_FREQ_AES_2; | ||
281 | break; | ||
282 | case PCXHR_CLOCK_TYPE_AES_3: | ||
283 | val = PCXHR_FREQ_AES_3; | ||
284 | break; | ||
285 | case PCXHR_CLOCK_TYPE_AES_4: | ||
286 | val = PCXHR_FREQ_AES_4; | ||
287 | break; | ||
288 | default: | ||
289 | return -EINVAL; | ||
212 | } | 290 | } |
213 | *reg = val; | 291 | *reg = val; |
214 | *freq = realfreq; | 292 | *freq = realfreq; |
@@ -216,14 +294,13 @@ static int pcxhr_get_clock_reg(struct pcxhr_mgr *mgr, unsigned int rate, | |||
216 | } | 294 | } |
217 | 295 | ||
218 | 296 | ||
219 | int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate) | 297 | static int pcxhr_sub_set_clock(struct pcxhr_mgr *mgr, |
298 | unsigned int rate, | ||
299 | int *changed) | ||
220 | { | 300 | { |
221 | unsigned int val, realfreq, speed; | 301 | unsigned int val, realfreq, speed; |
222 | struct pcxhr_rmh rmh; | 302 | struct pcxhr_rmh rmh; |
223 | int err, changed; | 303 | int err; |
224 | |||
225 | if (rate == 0) | ||
226 | return 0; /* nothing to do */ | ||
227 | 304 | ||
228 | err = pcxhr_get_clock_reg(mgr, rate, &val, &realfreq); | 305 | err = pcxhr_get_clock_reg(mgr, rate, &val, &realfreq); |
229 | if (err) | 306 | if (err) |
@@ -237,13 +314,17 @@ int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate) | |||
237 | else | 314 | else |
238 | speed = 2; /* quad speed */ | 315 | speed = 2; /* quad speed */ |
239 | if (mgr->codec_speed != speed) { | 316 | if (mgr->codec_speed != speed) { |
240 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); /* mute outputs */ | 317 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); /* mute outputs */ |
241 | rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; | 318 | rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; |
319 | if (DSP_EXT_CMD_SET(mgr)) { | ||
320 | rmh.cmd[1] = 1; | ||
321 | rmh.cmd_len = 2; | ||
322 | } | ||
242 | err = pcxhr_send_msg(mgr, &rmh); | 323 | err = pcxhr_send_msg(mgr, &rmh); |
243 | if (err) | 324 | if (err) |
244 | return err; | 325 | return err; |
245 | 326 | ||
246 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); /* set speed ratio */ | 327 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); /* set speed ratio */ |
247 | rmh.cmd[0] |= IO_NUM_SPEED_RATIO; | 328 | rmh.cmd[0] |= IO_NUM_SPEED_RATIO; |
248 | rmh.cmd[1] = speed; | 329 | rmh.cmd[1] = speed; |
249 | rmh.cmd_len = 2; | 330 | rmh.cmd_len = 2; |
@@ -253,25 +334,57 @@ int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate) | |||
253 | } | 334 | } |
254 | /* set the new frequency */ | 335 | /* set the new frequency */ |
255 | snd_printdd("clock register : set %x\n", val); | 336 | snd_printdd("clock register : set %x\n", val); |
256 | err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK, val, &changed); | 337 | err = pcxhr_write_io_num_reg_cont(mgr, PCXHR_FREQ_REG_MASK, |
338 | val, changed); | ||
257 | if (err) | 339 | if (err) |
258 | return err; | 340 | return err; |
341 | |||
259 | mgr->sample_rate_real = realfreq; | 342 | mgr->sample_rate_real = realfreq; |
260 | mgr->cur_clock_type = mgr->use_clock_type; | 343 | mgr->cur_clock_type = mgr->use_clock_type; |
261 | 344 | ||
262 | /* unmute after codec speed modes */ | 345 | /* unmute after codec speed modes */ |
263 | if (mgr->codec_speed != speed) { | 346 | if (mgr->codec_speed != speed) { |
264 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); /* unmute outputs */ | 347 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); /* unmute outputs */ |
265 | rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; | 348 | rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; |
349 | if (DSP_EXT_CMD_SET(mgr)) { | ||
350 | rmh.cmd[1] = 1; | ||
351 | rmh.cmd_len = 2; | ||
352 | } | ||
266 | err = pcxhr_send_msg(mgr, &rmh); | 353 | err = pcxhr_send_msg(mgr, &rmh); |
267 | if (err) | 354 | if (err) |
268 | return err; | 355 | return err; |
269 | mgr->codec_speed = speed; /* save new codec speed */ | 356 | mgr->codec_speed = speed; /* save new codec speed */ |
270 | } | 357 | } |
271 | 358 | ||
359 | snd_printdd("pcxhr_sub_set_clock to %dHz (realfreq=%d)\n", | ||
360 | rate, realfreq); | ||
361 | return 0; | ||
362 | } | ||
363 | |||
364 | #define PCXHR_MODIFY_CLOCK_S_BIT 0x04 | ||
365 | |||
366 | #define PCXHR_IRQ_TIMER_FREQ 92000 | ||
367 | #define PCXHR_IRQ_TIMER_PERIOD 48 | ||
368 | |||
369 | int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate) | ||
370 | { | ||
371 | struct pcxhr_rmh rmh; | ||
372 | int err, changed; | ||
373 | |||
374 | if (rate == 0) | ||
375 | return 0; /* nothing to do */ | ||
376 | |||
377 | if (mgr->is_hr_stereo) | ||
378 | err = hr222_sub_set_clock(mgr, rate, &changed); | ||
379 | else | ||
380 | err = pcxhr_sub_set_clock(mgr, rate, &changed); | ||
381 | |||
382 | if (err) | ||
383 | return err; | ||
384 | |||
272 | if (changed) { | 385 | if (changed) { |
273 | pcxhr_init_rmh(&rmh, CMD_MODIFY_CLOCK); | 386 | pcxhr_init_rmh(&rmh, CMD_MODIFY_CLOCK); |
274 | rmh.cmd[0] |= PCXHR_MODIFY_CLOCK_S_BIT; /* resync fifos */ | 387 | rmh.cmd[0] |= PCXHR_MODIFY_CLOCK_S_BIT; /* resync fifos */ |
275 | if (rate < PCXHR_IRQ_TIMER_FREQ) | 388 | if (rate < PCXHR_IRQ_TIMER_FREQ) |
276 | rmh.cmd[1] = PCXHR_IRQ_TIMER_PERIOD; | 389 | rmh.cmd[1] = PCXHR_IRQ_TIMER_PERIOD; |
277 | else | 390 | else |
@@ -282,26 +395,39 @@ int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate) | |||
282 | if (err) | 395 | if (err) |
283 | return err; | 396 | return err; |
284 | } | 397 | } |
285 | snd_printdd("pcxhr_set_clock to %dHz (realfreq=%d)\n", rate, realfreq); | ||
286 | return 0; | 398 | return 0; |
287 | } | 399 | } |
288 | 400 | ||
289 | 401 | ||
290 | int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, enum pcxhr_clock_type clock_type, | 402 | static int pcxhr_sub_get_external_clock(struct pcxhr_mgr *mgr, |
291 | int *sample_rate) | 403 | enum pcxhr_clock_type clock_type, |
404 | int *sample_rate) | ||
292 | { | 405 | { |
293 | struct pcxhr_rmh rmh; | 406 | struct pcxhr_rmh rmh; |
294 | unsigned char reg; | 407 | unsigned char reg; |
295 | int err, rate; | 408 | int err, rate; |
296 | 409 | ||
297 | switch (clock_type) { | 410 | switch (clock_type) { |
298 | case PCXHR_CLOCK_TYPE_WORD_CLOCK : reg = REG_STATUS_WORD_CLOCK; break; | 411 | case PCXHR_CLOCK_TYPE_WORD_CLOCK: |
299 | case PCXHR_CLOCK_TYPE_AES_SYNC : reg = REG_STATUS_AES_SYNC; break; | 412 | reg = REG_STATUS_WORD_CLOCK; |
300 | case PCXHR_CLOCK_TYPE_AES_1 : reg = REG_STATUS_AES_1; break; | 413 | break; |
301 | case PCXHR_CLOCK_TYPE_AES_2 : reg = REG_STATUS_AES_2; break; | 414 | case PCXHR_CLOCK_TYPE_AES_SYNC: |
302 | case PCXHR_CLOCK_TYPE_AES_3 : reg = REG_STATUS_AES_3; break; | 415 | reg = REG_STATUS_AES_SYNC; |
303 | case PCXHR_CLOCK_TYPE_AES_4 : reg = REG_STATUS_AES_4; break; | 416 | break; |
304 | default : return -EINVAL; | 417 | case PCXHR_CLOCK_TYPE_AES_1: |
418 | reg = REG_STATUS_AES_1; | ||
419 | break; | ||
420 | case PCXHR_CLOCK_TYPE_AES_2: | ||
421 | reg = REG_STATUS_AES_2; | ||
422 | break; | ||
423 | case PCXHR_CLOCK_TYPE_AES_3: | ||
424 | reg = REG_STATUS_AES_3; | ||
425 | break; | ||
426 | case PCXHR_CLOCK_TYPE_AES_4: | ||
427 | reg = REG_STATUS_AES_4; | ||
428 | break; | ||
429 | default: | ||
430 | return -EINVAL; | ||
305 | } | 431 | } |
306 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); | 432 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); |
307 | rmh.cmd_len = 2; | 433 | rmh.cmd_len = 2; |
@@ -311,7 +437,7 @@ int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, enum pcxhr_clock_type clock_ | |||
311 | err = pcxhr_send_msg(mgr, &rmh); | 437 | err = pcxhr_send_msg(mgr, &rmh); |
312 | if (err) | 438 | if (err) |
313 | return err; | 439 | return err; |
314 | udelay(100); /* wait minimum 2 sample_frames at 32kHz ! */ | 440 | udelay(100); /* wait minimum 2 sample_frames at 32kHz ! */ |
315 | mgr->last_reg_stat = reg; | 441 | mgr->last_reg_stat = reg; |
316 | } | 442 | } |
317 | rmh.cmd[1] = REG_STATUS_CURRENT; | 443 | rmh.cmd[1] = REG_STATUS_CURRENT; |
@@ -336,6 +462,18 @@ int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, enum pcxhr_clock_type clock_ | |||
336 | } | 462 | } |
337 | 463 | ||
338 | 464 | ||
465 | int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, | ||
466 | enum pcxhr_clock_type clock_type, | ||
467 | int *sample_rate) | ||
468 | { | ||
469 | if (mgr->is_hr_stereo) | ||
470 | return hr222_get_external_clock(mgr, clock_type, | ||
471 | sample_rate); | ||
472 | else | ||
473 | return pcxhr_sub_get_external_clock(mgr, clock_type, | ||
474 | sample_rate); | ||
475 | } | ||
476 | |||
339 | /* | 477 | /* |
340 | * start or stop playback/capture substream | 478 | * start or stop playback/capture substream |
341 | */ | 479 | */ |
@@ -350,7 +488,8 @@ static int pcxhr_set_stream_state(struct pcxhr_stream *stream) | |||
350 | start = 1; | 488 | start = 1; |
351 | else { | 489 | else { |
352 | if (stream->status != PCXHR_STREAM_STATUS_SCHEDULE_STOP) { | 490 | if (stream->status != PCXHR_STREAM_STATUS_SCHEDULE_STOP) { |
353 | snd_printk(KERN_ERR "ERROR pcxhr_set_stream_state CANNOT be stopped\n"); | 491 | snd_printk(KERN_ERR "ERROR pcxhr_set_stream_state " |
492 | "CANNOT be stopped\n"); | ||
354 | return -EINVAL; | 493 | return -EINVAL; |
355 | } | 494 | } |
356 | start = 0; | 495 | start = 0; |
@@ -359,11 +498,12 @@ static int pcxhr_set_stream_state(struct pcxhr_stream *stream) | |||
359 | return -EINVAL; | 498 | return -EINVAL; |
360 | 499 | ||
361 | stream->timer_abs_periods = 0; | 500 | stream->timer_abs_periods = 0; |
362 | stream->timer_period_frag = 0; /* reset theoretical stream pos */ | 501 | stream->timer_period_frag = 0; /* reset theoretical stream pos */ |
363 | stream->timer_buf_periods = 0; | 502 | stream->timer_buf_periods = 0; |
364 | stream->timer_is_synced = 0; | 503 | stream->timer_is_synced = 0; |
365 | 504 | ||
366 | stream_mask = stream->pipe->is_capture ? 1 : 1<<stream->substream->number; | 505 | stream_mask = |
506 | stream->pipe->is_capture ? 1 : 1<<stream->substream->number; | ||
367 | 507 | ||
368 | pcxhr_init_rmh(&rmh, start ? CMD_START_STREAM : CMD_STOP_STREAM); | 508 | pcxhr_init_rmh(&rmh, start ? CMD_START_STREAM : CMD_STOP_STREAM); |
369 | pcxhr_set_pipe_cmd_params(&rmh, stream->pipe->is_capture, | 509 | pcxhr_set_pipe_cmd_params(&rmh, stream->pipe->is_capture, |
@@ -373,8 +513,10 @@ static int pcxhr_set_stream_state(struct pcxhr_stream *stream) | |||
373 | 513 | ||
374 | err = pcxhr_send_msg(chip->mgr, &rmh); | 514 | err = pcxhr_send_msg(chip->mgr, &rmh); |
375 | if (err) | 515 | if (err) |
376 | snd_printk(KERN_ERR "ERROR pcxhr_set_stream_state err=%x;\n", err); | 516 | snd_printk(KERN_ERR "ERROR pcxhr_set_stream_state err=%x;\n", |
377 | stream->status = start ? PCXHR_STREAM_STATUS_STARTED : PCXHR_STREAM_STATUS_STOPPED; | 517 | err); |
518 | stream->status = | ||
519 | start ? PCXHR_STREAM_STATUS_STARTED : PCXHR_STREAM_STATUS_STOPPED; | ||
378 | return err; | 520 | return err; |
379 | } | 521 | } |
380 | 522 | ||
@@ -399,13 +541,15 @@ static int pcxhr_set_format(struct pcxhr_stream *stream) | |||
399 | header = HEADER_FMT_BASE_LIN; | 541 | header = HEADER_FMT_BASE_LIN; |
400 | break; | 542 | break; |
401 | case SNDRV_PCM_FORMAT_S16_LE: | 543 | case SNDRV_PCM_FORMAT_S16_LE: |
402 | header = HEADER_FMT_BASE_LIN | HEADER_FMT_16BITS | HEADER_FMT_INTEL; | 544 | header = HEADER_FMT_BASE_LIN | |
545 | HEADER_FMT_16BITS | HEADER_FMT_INTEL; | ||
403 | break; | 546 | break; |
404 | case SNDRV_PCM_FORMAT_S16_BE: | 547 | case SNDRV_PCM_FORMAT_S16_BE: |
405 | header = HEADER_FMT_BASE_LIN | HEADER_FMT_16BITS; | 548 | header = HEADER_FMT_BASE_LIN | HEADER_FMT_16BITS; |
406 | break; | 549 | break; |
407 | case SNDRV_PCM_FORMAT_S24_3LE: | 550 | case SNDRV_PCM_FORMAT_S24_3LE: |
408 | header = HEADER_FMT_BASE_LIN | HEADER_FMT_24BITS | HEADER_FMT_INTEL; | 551 | header = HEADER_FMT_BASE_LIN | |
552 | HEADER_FMT_24BITS | HEADER_FMT_INTEL; | ||
409 | break; | 553 | break; |
410 | case SNDRV_PCM_FORMAT_S24_3BE: | 554 | case SNDRV_PCM_FORMAT_S24_3BE: |
411 | header = HEADER_FMT_BASE_LIN | HEADER_FMT_24BITS; | 555 | header = HEADER_FMT_BASE_LIN | HEADER_FMT_24BITS; |
@@ -414,7 +558,8 @@ static int pcxhr_set_format(struct pcxhr_stream *stream) | |||
414 | header = HEADER_FMT_BASE_FLOAT | HEADER_FMT_INTEL; | 558 | header = HEADER_FMT_BASE_FLOAT | HEADER_FMT_INTEL; |
415 | break; | 559 | break; |
416 | default: | 560 | default: |
417 | snd_printk(KERN_ERR "error pcxhr_set_format() : unknown format\n"); | 561 | snd_printk(KERN_ERR |
562 | "error pcxhr_set_format() : unknown format\n"); | ||
418 | return -EINVAL; | 563 | return -EINVAL; |
419 | } | 564 | } |
420 | chip = snd_pcm_substream_chip(stream->substream); | 565 | chip = snd_pcm_substream_chip(stream->substream); |
@@ -432,14 +577,31 @@ static int pcxhr_set_format(struct pcxhr_stream *stream) | |||
432 | is_capture = stream->pipe->is_capture; | 577 | is_capture = stream->pipe->is_capture; |
433 | stream_num = is_capture ? 0 : stream->substream->number; | 578 | stream_num = is_capture ? 0 : stream->substream->number; |
434 | 579 | ||
435 | pcxhr_init_rmh(&rmh, is_capture ? CMD_FORMAT_STREAM_IN : CMD_FORMAT_STREAM_OUT); | 580 | pcxhr_init_rmh(&rmh, is_capture ? |
436 | pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, stream_num, 0); | 581 | CMD_FORMAT_STREAM_IN : CMD_FORMAT_STREAM_OUT); |
437 | if (is_capture) | 582 | pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, |
438 | rmh.cmd[0] |= 1<<12; | 583 | stream_num, 0); |
584 | if (is_capture) { | ||
585 | /* bug with old dsp versions: */ | ||
586 | /* bit 12 also sets the format of the playback stream */ | ||
587 | if (DSP_EXT_CMD_SET(chip->mgr)) | ||
588 | rmh.cmd[0] |= 1<<10; | ||
589 | else | ||
590 | rmh.cmd[0] |= 1<<12; | ||
591 | } | ||
439 | rmh.cmd[1] = 0; | 592 | rmh.cmd[1] = 0; |
440 | rmh.cmd[2] = header >> 8; | 593 | rmh.cmd_len = 2; |
441 | rmh.cmd[3] = (header & 0xff) << 16; | 594 | if (DSP_EXT_CMD_SET(chip->mgr)) { |
442 | rmh.cmd_len = 4; | 595 | /* add channels and set bit 19 if channels>2 */ |
596 | rmh.cmd[1] = stream->channels; | ||
597 | if (!is_capture) { | ||
598 | /* playback : add channel mask to command */ | ||
599 | rmh.cmd[2] = (stream->channels == 1) ? 0x01 : 0x03; | ||
600 | rmh.cmd_len = 3; | ||
601 | } | ||
602 | } | ||
603 | rmh.cmd[rmh.cmd_len++] = header >> 8; | ||
604 | rmh.cmd[rmh.cmd_len++] = (header & 0xff) << 16; | ||
443 | err = pcxhr_send_msg(chip->mgr, &rmh); | 605 | err = pcxhr_send_msg(chip->mgr, &rmh); |
444 | if (err) | 606 | if (err) |
445 | snd_printk(KERN_ERR "ERROR pcxhr_set_format err=%x;\n", err); | 607 | snd_printk(KERN_ERR "ERROR pcxhr_set_format err=%x;\n", err); |
@@ -456,30 +618,38 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream) | |||
456 | is_capture = (subs->stream == SNDRV_PCM_STREAM_CAPTURE); | 618 | is_capture = (subs->stream == SNDRV_PCM_STREAM_CAPTURE); |
457 | stream_num = is_capture ? 0 : subs->number; | 619 | stream_num = is_capture ? 0 : subs->number; |
458 | 620 | ||
459 | snd_printdd("pcxhr_update_r_buffer(pcm%c%d) : addr(%p) bytes(%zx) subs(%d)\n", | 621 | snd_printdd("pcxhr_update_r_buffer(pcm%c%d) : " |
622 | "addr(%p) bytes(%zx) subs(%d)\n", | ||
460 | is_capture ? 'c' : 'p', | 623 | is_capture ? 'c' : 'p', |
461 | chip->chip_idx, (void *)(long)subs->runtime->dma_addr, | 624 | chip->chip_idx, (void *)(long)subs->runtime->dma_addr, |
462 | subs->runtime->dma_bytes, subs->number); | 625 | subs->runtime->dma_bytes, subs->number); |
463 | 626 | ||
464 | pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS); | 627 | pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS); |
465 | pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, stream_num, 0); | 628 | pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, |
629 | stream_num, 0); | ||
466 | 630 | ||
467 | /* max buffer size is 2 MByte */ | 631 | /* max buffer size is 2 MByte */ |
468 | snd_BUG_ON(subs->runtime->dma_bytes >= 0x200000); | 632 | snd_BUG_ON(subs->runtime->dma_bytes >= 0x200000); |
469 | rmh.cmd[1] = subs->runtime->dma_bytes * 8; /* size in bits */ | 633 | /* size in bits */ |
470 | rmh.cmd[2] = subs->runtime->dma_addr >> 24; /* most significant byte */ | 634 | rmh.cmd[1] = subs->runtime->dma_bytes * 8; |
471 | rmh.cmd[2] |= 1<<19; /* this is a circular buffer */ | 635 | /* most significant byte */ |
472 | rmh.cmd[3] = subs->runtime->dma_addr & MASK_DSP_WORD; /* least 3 significant bytes */ | 636 | rmh.cmd[2] = subs->runtime->dma_addr >> 24; |
637 | /* this is a circular buffer */ | ||
638 | rmh.cmd[2] |= 1<<19; | ||
639 | /* least 3 significant bytes */ | ||
640 | rmh.cmd[3] = subs->runtime->dma_addr & MASK_DSP_WORD; | ||
473 | rmh.cmd_len = 4; | 641 | rmh.cmd_len = 4; |
474 | err = pcxhr_send_msg(chip->mgr, &rmh); | 642 | err = pcxhr_send_msg(chip->mgr, &rmh); |
475 | if (err) | 643 | if (err) |
476 | snd_printk(KERN_ERR "ERROR CMD_UPDATE_R_BUFFERS err=%x;\n", err); | 644 | snd_printk(KERN_ERR |
645 | "ERROR CMD_UPDATE_R_BUFFERS err=%x;\n", err); | ||
477 | return err; | 646 | return err; |
478 | } | 647 | } |
479 | 648 | ||
480 | 649 | ||
481 | #if 0 | 650 | #if 0 |
482 | static int pcxhr_pipe_sample_count(struct pcxhr_stream *stream, snd_pcm_uframes_t *sample_count) | 651 | static int pcxhr_pipe_sample_count(struct pcxhr_stream *stream, |
652 | snd_pcm_uframes_t *sample_count) | ||
483 | { | 653 | { |
484 | struct pcxhr_rmh rmh; | 654 | struct pcxhr_rmh rmh; |
485 | int err; | 655 | int err; |
@@ -533,8 +703,8 @@ static void pcxhr_trigger_tasklet(unsigned long arg) | |||
533 | for (j = 0; j < chip->nb_streams_play; j++) { | 703 | for (j = 0; j < chip->nb_streams_play; j++) { |
534 | if (pcxhr_stream_scheduled_get_pipe(&chip->playback_stream[j], &pipe)) { | 704 | if (pcxhr_stream_scheduled_get_pipe(&chip->playback_stream[j], &pipe)) { |
535 | playback_mask |= (1 << pipe->first_audio); | 705 | playback_mask |= (1 << pipe->first_audio); |
536 | break; /* add only once, as all playback streams of | 706 | break; /* add only once, as all playback |
537 | * one chip use the same pipe | 707 | * streams of one chip use the same pipe |
538 | */ | 708 | */ |
539 | } | 709 | } |
540 | } | 710 | } |
@@ -545,19 +715,21 @@ static void pcxhr_trigger_tasklet(unsigned long arg) | |||
545 | return; | 715 | return; |
546 | } | 716 | } |
547 | 717 | ||
548 | snd_printdd("pcxhr_trigger_tasklet : playback_mask=%x capture_mask=%x\n", | 718 | snd_printdd("pcxhr_trigger_tasklet : " |
719 | "playback_mask=%x capture_mask=%x\n", | ||
549 | playback_mask, capture_mask); | 720 | playback_mask, capture_mask); |
550 | 721 | ||
551 | /* synchronous stop of all the pipes concerned */ | 722 | /* synchronous stop of all the pipes concerned */ |
552 | err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0); | 723 | err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 0); |
553 | if (err) { | 724 | if (err) { |
554 | mutex_unlock(&mgr->setup_mutex); | 725 | mutex_unlock(&mgr->setup_mutex); |
555 | snd_printk(KERN_ERR "pcxhr_trigger_tasklet : error stop pipes (P%x C%x)\n", | 726 | snd_printk(KERN_ERR "pcxhr_trigger_tasklet : " |
727 | "error stop pipes (P%x C%x)\n", | ||
556 | playback_mask, capture_mask); | 728 | playback_mask, capture_mask); |
557 | return; | 729 | return; |
558 | } | 730 | } |
559 | 731 | ||
560 | /* unfortunately the dsp lost format and buffer info with the stop pipe */ | 732 | /* the dsp lost format and buffer info with the stop pipe */ |
561 | for (i = 0; i < mgr->num_cards; i++) { | 733 | for (i = 0; i < mgr->num_cards; i++) { |
562 | struct pcxhr_stream *stream; | 734 | struct pcxhr_stream *stream; |
563 | chip = mgr->chip[i]; | 735 | chip = mgr->chip[i]; |
@@ -596,12 +768,15 @@ static void pcxhr_trigger_tasklet(unsigned long arg) | |||
596 | err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1); | 768 | err = pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1); |
597 | if (err) { | 769 | if (err) { |
598 | mutex_unlock(&mgr->setup_mutex); | 770 | mutex_unlock(&mgr->setup_mutex); |
599 | snd_printk(KERN_ERR "pcxhr_trigger_tasklet : error start pipes (P%x C%x)\n", | 771 | snd_printk(KERN_ERR "pcxhr_trigger_tasklet : " |
772 | "error start pipes (P%x C%x)\n", | ||
600 | playback_mask, capture_mask); | 773 | playback_mask, capture_mask); |
601 | return; | 774 | return; |
602 | } | 775 | } |
603 | 776 | ||
604 | /* put the streams into the running state now (increment pointer by interrupt) */ | 777 | /* put the streams into the running state now |
778 | * (increment pointer by interrupt) | ||
779 | */ | ||
605 | spin_lock_irqsave(&mgr->lock, flags); | 780 | spin_lock_irqsave(&mgr->lock, flags); |
606 | for ( i =0; i < mgr->num_cards; i++) { | 781 | for ( i =0; i < mgr->num_cards; i++) { |
607 | struct pcxhr_stream *stream; | 782 | struct pcxhr_stream *stream; |
@@ -615,7 +790,7 @@ static void pcxhr_trigger_tasklet(unsigned long arg) | |||
615 | stream = &chip->playback_stream[j]; | 790 | stream = &chip->playback_stream[j]; |
616 | if (stream->status == PCXHR_STREAM_STATUS_STARTED) { | 791 | if (stream->status == PCXHR_STREAM_STATUS_STARTED) { |
617 | /* playback will already have advanced ! */ | 792 | /* playback will already have advanced ! */ |
618 | stream->timer_period_frag += PCXHR_GRANULARITY; | 793 | stream->timer_period_frag += mgr->granularity; |
619 | stream->status = PCXHR_STREAM_STATUS_RUNNING; | 794 | stream->status = PCXHR_STREAM_STATUS_RUNNING; |
620 | } | 795 | } |
621 | } | 796 | } |
@@ -653,7 +828,7 @@ static int pcxhr_trigger(struct snd_pcm_substream *subs, int cmd) | |||
653 | PCXHR_STREAM_STATUS_SCHEDULE_RUN; | 828 | PCXHR_STREAM_STATUS_SCHEDULE_RUN; |
654 | snd_pcm_trigger_done(s, subs); | 829 | snd_pcm_trigger_done(s, subs); |
655 | } | 830 | } |
656 | tasklet_hi_schedule(&chip->mgr->trigger_taskq); | 831 | tasklet_schedule(&chip->mgr->trigger_taskq); |
657 | } else { | 832 | } else { |
658 | stream = subs->runtime->private_data; | 833 | stream = subs->runtime->private_data; |
659 | snd_printdd("Only one Substream %c %d\n", | 834 | snd_printdd("Only one Substream %c %d\n", |
@@ -697,12 +872,14 @@ static int pcxhr_hardware_timer(struct pcxhr_mgr *mgr, int start) | |||
697 | 872 | ||
698 | pcxhr_init_rmh(&rmh, CMD_SET_TIMER_INTERRUPT); | 873 | pcxhr_init_rmh(&rmh, CMD_SET_TIMER_INTERRUPT); |
699 | if (start) { | 874 | if (start) { |
700 | mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID; /* last dsp time invalid */ | 875 | /* last dsp time invalid */ |
701 | rmh.cmd[0] |= PCXHR_GRANULARITY; | 876 | mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID; |
877 | rmh.cmd[0] |= mgr->granularity; | ||
702 | } | 878 | } |
703 | err = pcxhr_send_msg(mgr, &rmh); | 879 | err = pcxhr_send_msg(mgr, &rmh); |
704 | if (err < 0) | 880 | if (err < 0) |
705 | snd_printk(KERN_ERR "error pcxhr_hardware_timer err(%x)\n", err); | 881 | snd_printk(KERN_ERR "error pcxhr_hardware_timer err(%x)\n", |
882 | err); | ||
706 | return err; | 883 | return err; |
707 | } | 884 | } |
708 | 885 | ||
@@ -713,38 +890,16 @@ static int pcxhr_prepare(struct snd_pcm_substream *subs) | |||
713 | { | 890 | { |
714 | struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); | 891 | struct snd_pcxhr *chip = snd_pcm_substream_chip(subs); |
715 | struct pcxhr_mgr *mgr = chip->mgr; | 892 | struct pcxhr_mgr *mgr = chip->mgr; |
716 | /* | ||
717 | struct pcxhr_stream *stream = (pcxhr_stream_t*)subs->runtime->private_data; | ||
718 | */ | ||
719 | int err = 0; | 893 | int err = 0; |
720 | 894 | ||
721 | snd_printdd("pcxhr_prepare : period_size(%lx) periods(%x) buffer_size(%lx)\n", | 895 | snd_printdd("pcxhr_prepare : period_size(%lx) periods(%x) buffer_size(%lx)\n", |
722 | subs->runtime->period_size, subs->runtime->periods, | 896 | subs->runtime->period_size, subs->runtime->periods, |
723 | subs->runtime->buffer_size); | 897 | subs->runtime->buffer_size); |
724 | 898 | ||
725 | /* | ||
726 | if(subs->runtime->period_size <= PCXHR_GRANULARITY) { | ||
727 | snd_printk(KERN_ERR "pcxhr_prepare : error period_size too small (%x)\n", | ||
728 | (unsigned int)subs->runtime->period_size); | ||
729 | return -EINVAL; | ||
730 | } | ||
731 | */ | ||
732 | |||
733 | mutex_lock(&mgr->setup_mutex); | 899 | mutex_lock(&mgr->setup_mutex); |
734 | 900 | ||
735 | do { | 901 | do { |
736 | /* if the stream was stopped before, format and buffer were reset */ | ||
737 | /* | ||
738 | if(stream->status == PCXHR_STREAM_STATUS_STOPPED) { | ||
739 | err = pcxhr_set_format(stream); | ||
740 | if(err) break; | ||
741 | err = pcxhr_update_r_buffer(stream); | ||
742 | if(err) break; | ||
743 | } | ||
744 | */ | ||
745 | |||
746 | /* only the first stream can choose the sample rate */ | 902 | /* only the first stream can choose the sample rate */ |
747 | /* the further opened streams will be limited to its frequency (see open) */ | ||
748 | /* set the clock only once (first stream) */ | 903 | /* set the clock only once (first stream) */ |
749 | if (mgr->sample_rate != subs->runtime->rate) { | 904 | if (mgr->sample_rate != subs->runtime->rate) { |
750 | err = pcxhr_set_clock(mgr, subs->runtime->rate); | 905 | err = pcxhr_set_clock(mgr, subs->runtime->rate); |
@@ -787,22 +942,9 @@ static int pcxhr_hw_params(struct snd_pcm_substream *subs, | |||
787 | stream->channels = channels; | 942 | stream->channels = channels; |
788 | stream->format = format; | 943 | stream->format = format; |
789 | 944 | ||
790 | /* set the format to the board */ | ||
791 | /* | ||
792 | err = pcxhr_set_format(stream); | ||
793 | if(err) { | ||
794 | mutex_unlock(&mgr->setup_mutex); | ||
795 | return err; | ||
796 | } | ||
797 | */ | ||
798 | /* allocate buffer */ | 945 | /* allocate buffer */ |
799 | err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw)); | 946 | err = snd_pcm_lib_malloc_pages(subs, params_buffer_bytes(hw)); |
800 | 947 | ||
801 | /* | ||
802 | if (err > 0) { | ||
803 | err = pcxhr_update_r_buffer(stream); | ||
804 | } | ||
805 | */ | ||
806 | mutex_unlock(&mgr->setup_mutex); | 948 | mutex_unlock(&mgr->setup_mutex); |
807 | 949 | ||
808 | return err; | 950 | return err; |
@@ -820,14 +962,18 @@ static int pcxhr_hw_free(struct snd_pcm_substream *subs) | |||
820 | */ | 962 | */ |
821 | static struct snd_pcm_hardware pcxhr_caps = | 963 | static struct snd_pcm_hardware pcxhr_caps = |
822 | { | 964 | { |
823 | .info = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 965 | .info = (SNDRV_PCM_INFO_MMAP | |
824 | SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START | | 966 | SNDRV_PCM_INFO_INTERLEAVED | |
825 | 0 /*SNDRV_PCM_INFO_PAUSE*/), | 967 | SNDRV_PCM_INFO_MMAP_VALID | |
826 | .formats = ( SNDRV_PCM_FMTBIT_U8 | | 968 | SNDRV_PCM_INFO_SYNC_START), |
827 | SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE | | 969 | .formats = (SNDRV_PCM_FMTBIT_U8 | |
828 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE | | 970 | SNDRV_PCM_FMTBIT_S16_LE | |
829 | SNDRV_PCM_FMTBIT_FLOAT_LE ), | 971 | SNDRV_PCM_FMTBIT_S16_BE | |
830 | .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_192000, | 972 | SNDRV_PCM_FMTBIT_S24_3LE | |
973 | SNDRV_PCM_FMTBIT_S24_3BE | | ||
974 | SNDRV_PCM_FMTBIT_FLOAT_LE), | ||
975 | .rates = (SNDRV_PCM_RATE_CONTINUOUS | | ||
976 | SNDRV_PCM_RATE_8000_192000), | ||
831 | .rate_min = 8000, | 977 | .rate_min = 8000, |
832 | .rate_max = 192000, | 978 | .rate_max = 192000, |
833 | .channels_min = 1, | 979 | .channels_min = 1, |
@@ -847,6 +993,7 @@ static int pcxhr_open(struct snd_pcm_substream *subs) | |||
847 | struct pcxhr_mgr *mgr = chip->mgr; | 993 | struct pcxhr_mgr *mgr = chip->mgr; |
848 | struct snd_pcm_runtime *runtime = subs->runtime; | 994 | struct snd_pcm_runtime *runtime = subs->runtime; |
849 | struct pcxhr_stream *stream; | 995 | struct pcxhr_stream *stream; |
996 | int err; | ||
850 | 997 | ||
851 | mutex_lock(&mgr->setup_mutex); | 998 | mutex_lock(&mgr->setup_mutex); |
852 | 999 | ||
@@ -874,6 +1021,18 @@ static int pcxhr_open(struct snd_pcm_substream *subs) | |||
874 | return -EBUSY; | 1021 | return -EBUSY; |
875 | } | 1022 | } |
876 | 1023 | ||
1024 | /* float format support is in some cases buggy on stereo cards */ | ||
1025 | if (mgr->is_hr_stereo) | ||
1026 | runtime->hw.formats &= ~SNDRV_PCM_FMTBIT_FLOAT_LE; | ||
1027 | |||
1028 | /* buffer-size should better be multiple of period-size */ | ||
1029 | err = snd_pcm_hw_constraint_integer(runtime, | ||
1030 | SNDRV_PCM_HW_PARAM_PERIODS); | ||
1031 | if (err < 0) { | ||
1032 | mutex_unlock(&mgr->setup_mutex); | ||
1033 | return err; | ||
1034 | } | ||
1035 | |||
877 | /* if a sample rate is already used or fixed by external clock, | 1036 | /* if a sample rate is already used or fixed by external clock, |
878 | * the stream cannot change | 1037 | * the stream cannot change |
879 | */ | 1038 | */ |
@@ -889,7 +1048,8 @@ static int pcxhr_open(struct snd_pcm_substream *subs) | |||
889 | mutex_unlock(&mgr->setup_mutex); | 1048 | mutex_unlock(&mgr->setup_mutex); |
890 | return -EBUSY; | 1049 | return -EBUSY; |
891 | } | 1050 | } |
892 | runtime->hw.rate_min = runtime->hw.rate_max = external_rate; | 1051 | runtime->hw.rate_min = external_rate; |
1052 | runtime->hw.rate_max = external_rate; | ||
893 | } | 1053 | } |
894 | } | 1054 | } |
895 | 1055 | ||
@@ -899,9 +1059,11 @@ static int pcxhr_open(struct snd_pcm_substream *subs) | |||
899 | 1059 | ||
900 | runtime->private_data = stream; | 1060 | runtime->private_data = stream; |
901 | 1061 | ||
902 | snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 4); | 1062 | /* better get a divisor of granularity values (96 or 192) */ |
903 | snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 4); | 1063 | snd_pcm_hw_constraint_step(runtime, 0, |
904 | 1064 | SNDRV_PCM_HW_PARAM_BUFFER_SIZE, 32); | |
1065 | snd_pcm_hw_constraint_step(runtime, 0, | ||
1066 | SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 32); | ||
905 | snd_pcm_set_sync(subs); | 1067 | snd_pcm_set_sync(subs); |
906 | 1068 | ||
907 | mgr->ref_count_rate++; | 1069 | mgr->ref_count_rate++; |
@@ -919,11 +1081,12 @@ static int pcxhr_close(struct snd_pcm_substream *subs) | |||
919 | 1081 | ||
920 | mutex_lock(&mgr->setup_mutex); | 1082 | mutex_lock(&mgr->setup_mutex); |
921 | 1083 | ||
922 | snd_printdd("pcxhr_close chip%d subs%d\n", chip->chip_idx, subs->number); | 1084 | snd_printdd("pcxhr_close chip%d subs%d\n", |
1085 | chip->chip_idx, subs->number); | ||
923 | 1086 | ||
924 | /* sample rate released */ | 1087 | /* sample rate released */ |
925 | if (--mgr->ref_count_rate == 0) { | 1088 | if (--mgr->ref_count_rate == 0) { |
926 | mgr->sample_rate = 0; /* the sample rate is no more locked */ | 1089 | mgr->sample_rate = 0; /* the sample rate is no more locked */ |
927 | pcxhr_hardware_timer(mgr, 0); /* stop the DSP-timer */ | 1090 | pcxhr_hardware_timer(mgr, 0); /* stop the DSP-timer */ |
928 | } | 1091 | } |
929 | 1092 | ||
@@ -1016,7 +1179,8 @@ static int pcxhr_chip_dev_free(struct snd_device *device) | |||
1016 | 1179 | ||
1017 | /* | 1180 | /* |
1018 | */ | 1181 | */ |
1019 | static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card, int idx) | 1182 | static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, |
1183 | struct snd_card *card, int idx) | ||
1020 | { | 1184 | { |
1021 | int err; | 1185 | int err; |
1022 | struct snd_pcxhr *chip; | 1186 | struct snd_pcxhr *chip; |
@@ -1024,7 +1188,7 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card, | |||
1024 | .dev_free = pcxhr_chip_dev_free, | 1188 | .dev_free = pcxhr_chip_dev_free, |
1025 | }; | 1189 | }; |
1026 | 1190 | ||
1027 | mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 1191 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
1028 | if (! chip) { | 1192 | if (! chip) { |
1029 | snd_printk(KERN_ERR "cannot allocate chip\n"); | 1193 | snd_printk(KERN_ERR "cannot allocate chip\n"); |
1030 | return -ENOMEM; | 1194 | return -ENOMEM; |
@@ -1040,7 +1204,7 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card, | |||
1040 | 1204 | ||
1041 | if (idx < mgr->capture_chips) { | 1205 | if (idx < mgr->capture_chips) { |
1042 | if (mgr->mono_capture) | 1206 | if (mgr->mono_capture) |
1043 | chip->nb_streams_capt = 2; /* 2 mono streams (left+right) */ | 1207 | chip->nb_streams_capt = 2; /* 2 mono streams */ |
1044 | else | 1208 | else |
1045 | chip->nb_streams_capt = 1; /* or 1 stereo stream */ | 1209 | chip->nb_streams_capt = 1; /* or 1 stereo stream */ |
1046 | } | 1210 | } |
@@ -1050,13 +1214,15 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card, | |||
1050 | return err; | 1214 | return err; |
1051 | } | 1215 | } |
1052 | 1216 | ||
1217 | mgr->chip[idx] = chip; | ||
1053 | snd_card_set_dev(card, &mgr->pci->dev); | 1218 | snd_card_set_dev(card, &mgr->pci->dev); |
1054 | 1219 | ||
1055 | return 0; | 1220 | return 0; |
1056 | } | 1221 | } |
1057 | 1222 | ||
1058 | /* proc interface */ | 1223 | /* proc interface */ |
1059 | static void pcxhr_proc_info(struct snd_info_entry *entry, struct snd_info_buffer *buffer) | 1224 | static void pcxhr_proc_info(struct snd_info_entry *entry, |
1225 | struct snd_info_buffer *buffer) | ||
1060 | { | 1226 | { |
1061 | struct snd_pcxhr *chip = entry->private_data; | 1227 | struct snd_pcxhr *chip = entry->private_data; |
1062 | struct pcxhr_mgr *mgr = chip->mgr; | 1228 | struct pcxhr_mgr *mgr = chip->mgr; |
@@ -1069,8 +1235,10 @@ static void pcxhr_proc_info(struct snd_info_entry *entry, struct snd_info_buffer | |||
1069 | short ver_maj = (mgr->dsp_version >> 16) & 0xff; | 1235 | short ver_maj = (mgr->dsp_version >> 16) & 0xff; |
1070 | short ver_min = (mgr->dsp_version >> 8) & 0xff; | 1236 | short ver_min = (mgr->dsp_version >> 8) & 0xff; |
1071 | short ver_build = mgr->dsp_version & 0xff; | 1237 | short ver_build = mgr->dsp_version & 0xff; |
1072 | snd_iprintf(buffer, "module version %s\n", PCXHR_DRIVER_VERSION_STRING); | 1238 | snd_iprintf(buffer, "module version %s\n", |
1073 | snd_iprintf(buffer, "dsp version %d.%d.%d\n", ver_maj, ver_min, ver_build); | 1239 | PCXHR_DRIVER_VERSION_STRING); |
1240 | snd_iprintf(buffer, "dsp version %d.%d.%d\n", | ||
1241 | ver_maj, ver_min, ver_build); | ||
1074 | if (mgr->board_has_analog) | 1242 | if (mgr->board_has_analog) |
1075 | snd_iprintf(buffer, "analog io available\n"); | 1243 | snd_iprintf(buffer, "analog io available\n"); |
1076 | else | 1244 | else |
@@ -1084,18 +1252,22 @@ static void pcxhr_proc_info(struct snd_info_entry *entry, struct snd_info_buffer | |||
1084 | if (ref > 0) { | 1252 | if (ref > 0) { |
1085 | if (mgr->sample_rate_real != 0 && | 1253 | if (mgr->sample_rate_real != 0 && |
1086 | mgr->sample_rate_real != 48000) { | 1254 | mgr->sample_rate_real != 48000) { |
1087 | ref = (ref * 48000) / mgr->sample_rate_real; | 1255 | ref = (ref * 48000) / |
1088 | if (mgr->sample_rate_real >= PCXHR_IRQ_TIMER_FREQ) | 1256 | mgr->sample_rate_real; |
1257 | if (mgr->sample_rate_real >= | ||
1258 | PCXHR_IRQ_TIMER_FREQ) | ||
1089 | ref *= 2; | 1259 | ref *= 2; |
1090 | } | 1260 | } |
1091 | cur = 100 - (100 * cur) / ref; | 1261 | cur = 100 - (100 * cur) / ref; |
1092 | snd_iprintf(buffer, "cpu load %d%%\n", cur); | 1262 | snd_iprintf(buffer, "cpu load %d%%\n", cur); |
1093 | snd_iprintf(buffer, "buffer pool %d/%d kWords\n", | 1263 | snd_iprintf(buffer, "buffer pool %d/%d\n", |
1094 | rmh.stat[2], rmh.stat[3]); | 1264 | rmh.stat[2], rmh.stat[3]); |
1095 | } | 1265 | } |
1096 | } | 1266 | } |
1097 | snd_iprintf(buffer, "dma granularity : %d\n", PCXHR_GRANULARITY); | 1267 | snd_iprintf(buffer, "dma granularity : %d\n", |
1098 | snd_iprintf(buffer, "dsp time errors : %d\n", mgr->dsp_time_err); | 1268 | mgr->granularity); |
1269 | snd_iprintf(buffer, "dsp time errors : %d\n", | ||
1270 | mgr->dsp_time_err); | ||
1099 | snd_iprintf(buffer, "dsp async pipe xrun errors : %d\n", | 1271 | snd_iprintf(buffer, "dsp async pipe xrun errors : %d\n", |
1100 | mgr->async_err_pipe_xrun); | 1272 | mgr->async_err_pipe_xrun); |
1101 | snd_iprintf(buffer, "dsp async stream xrun errors : %d\n", | 1273 | snd_iprintf(buffer, "dsp async stream xrun errors : %d\n", |
@@ -1110,33 +1282,52 @@ static void pcxhr_proc_info(struct snd_info_entry *entry, struct snd_info_buffer | |||
1110 | rmh.cmd_idx = CMD_LAST_INDEX; | 1282 | rmh.cmd_idx = CMD_LAST_INDEX; |
1111 | if( ! pcxhr_send_msg(mgr, &rmh) ) { | 1283 | if( ! pcxhr_send_msg(mgr, &rmh) ) { |
1112 | int i; | 1284 | int i; |
1285 | if (rmh.stat_len > 8) | ||
1286 | rmh.stat_len = 8; | ||
1113 | for (i = 0; i < rmh.stat_len; i++) | 1287 | for (i = 0; i < rmh.stat_len; i++) |
1114 | snd_iprintf(buffer, "debug[%02d] = %06x\n", i, rmh.stat[i]); | 1288 | snd_iprintf(buffer, "debug[%02d] = %06x\n", |
1289 | i, rmh.stat[i]); | ||
1115 | } | 1290 | } |
1116 | } else | 1291 | } else |
1117 | snd_iprintf(buffer, "no firmware loaded\n"); | 1292 | snd_iprintf(buffer, "no firmware loaded\n"); |
1118 | snd_iprintf(buffer, "\n"); | 1293 | snd_iprintf(buffer, "\n"); |
1119 | } | 1294 | } |
1120 | static void pcxhr_proc_sync(struct snd_info_entry *entry, struct snd_info_buffer *buffer) | 1295 | static void pcxhr_proc_sync(struct snd_info_entry *entry, |
1296 | struct snd_info_buffer *buffer) | ||
1121 | { | 1297 | { |
1122 | struct snd_pcxhr *chip = entry->private_data; | 1298 | struct snd_pcxhr *chip = entry->private_data; |
1123 | struct pcxhr_mgr *mgr = chip->mgr; | 1299 | struct pcxhr_mgr *mgr = chip->mgr; |
1124 | static char *texts[7] = { | 1300 | static const char *textsHR22[3] = { |
1125 | "Internal", "Word", "AES Sync", "AES 1", "AES 2", "AES 3", "AES 4" | 1301 | "Internal", "AES Sync", "AES 1" |
1302 | }; | ||
1303 | static const char *textsPCXHR[7] = { | ||
1304 | "Internal", "Word", "AES Sync", | ||
1305 | "AES 1", "AES 2", "AES 3", "AES 4" | ||
1126 | }; | 1306 | }; |
1307 | const char **texts; | ||
1308 | int max_clock; | ||
1309 | if (mgr->is_hr_stereo) { | ||
1310 | texts = textsHR22; | ||
1311 | max_clock = HR22_CLOCK_TYPE_MAX; | ||
1312 | } else { | ||
1313 | texts = textsPCXHR; | ||
1314 | max_clock = PCXHR_CLOCK_TYPE_MAX; | ||
1315 | } | ||
1127 | 1316 | ||
1128 | snd_iprintf(buffer, "\n%s\n", mgr->longname); | 1317 | snd_iprintf(buffer, "\n%s\n", mgr->longname); |
1129 | snd_iprintf(buffer, "Current Sample Clock\t: %s\n", texts[mgr->cur_clock_type]); | 1318 | snd_iprintf(buffer, "Current Sample Clock\t: %s\n", |
1130 | snd_iprintf(buffer, "Current Sample Rate\t= %d\n", mgr->sample_rate_real); | 1319 | texts[mgr->cur_clock_type]); |
1131 | 1320 | snd_iprintf(buffer, "Current Sample Rate\t= %d\n", | |
1321 | mgr->sample_rate_real); | ||
1132 | /* commands available when embedded DSP is running */ | 1322 | /* commands available when embedded DSP is running */ |
1133 | if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { | 1323 | if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { |
1134 | int i, err, sample_rate; | 1324 | int i, err, sample_rate; |
1135 | for (i = PCXHR_CLOCK_TYPE_WORD_CLOCK; i< (3 + mgr->capture_chips); i++) { | 1325 | for (i = 1; i <= max_clock; i++) { |
1136 | err = pcxhr_get_external_clock(mgr, i, &sample_rate); | 1326 | err = pcxhr_get_external_clock(mgr, i, &sample_rate); |
1137 | if (err) | 1327 | if (err) |
1138 | break; | 1328 | break; |
1139 | snd_iprintf(buffer, "%s Clock\t\t= %d\n", texts[i], sample_rate); | 1329 | snd_iprintf(buffer, "%s Clock\t\t= %d\n", |
1330 | texts[i], sample_rate); | ||
1140 | } | 1331 | } |
1141 | } else | 1332 | } else |
1142 | snd_iprintf(buffer, "no firmware loaded\n"); | 1333 | snd_iprintf(buffer, "no firmware loaded\n"); |
@@ -1194,7 +1385,8 @@ static int pcxhr_free(struct pcxhr_mgr *mgr) | |||
1194 | /* | 1385 | /* |
1195 | * probe function - creates the card manager | 1386 | * probe function - creates the card manager |
1196 | */ | 1387 | */ |
1197 | static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) | 1388 | static int __devinit pcxhr_probe(struct pci_dev *pci, |
1389 | const struct pci_device_id *pci_id) | ||
1198 | { | 1390 | { |
1199 | static int dev; | 1391 | static int dev; |
1200 | struct pcxhr_mgr *mgr; | 1392 | struct pcxhr_mgr *mgr; |
@@ -1217,7 +1409,8 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id | |||
1217 | 1409 | ||
1218 | /* check if we can restrict PCI DMA transfers to 32 bits */ | 1410 | /* check if we can restrict PCI DMA transfers to 32 bits */ |
1219 | if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0) { | 1411 | if (pci_set_dma_mask(pci, DMA_32BIT_MASK) < 0) { |
1220 | snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n"); | 1412 | snd_printk(KERN_ERR "architecture does not support " |
1413 | "32bit PCI busmaster DMA\n"); | ||
1221 | pci_disable_device(pci); | 1414 | pci_disable_device(pci); |
1222 | return -ENXIO; | 1415 | return -ENXIO; |
1223 | } | 1416 | } |
@@ -1229,13 +1422,30 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id | |||
1229 | return -ENOMEM; | 1422 | return -ENOMEM; |
1230 | } | 1423 | } |
1231 | 1424 | ||
1232 | if (snd_BUG_ON(pci_id->driver_data >= PCI_ID_LAST)) | 1425 | if (snd_BUG_ON(pci_id->driver_data >= PCI_ID_LAST)) { |
1426 | kfree(mgr); | ||
1427 | pci_disable_device(pci); | ||
1233 | return -ENODEV; | 1428 | return -ENODEV; |
1234 | card_name = pcxhr_board_params[pci_id->driver_data].board_name; | 1429 | } |
1235 | mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips; | 1430 | card_name = |
1236 | mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips; | 1431 | pcxhr_board_params[pci_id->driver_data].board_name; |
1237 | mgr->firmware_num = pcxhr_board_params[pci_id->driver_data].firmware_num; | 1432 | mgr->playback_chips = |
1433 | pcxhr_board_params[pci_id->driver_data].playback_chips; | ||
1434 | mgr->capture_chips = | ||
1435 | pcxhr_board_params[pci_id->driver_data].capture_chips; | ||
1436 | mgr->fw_file_set = | ||
1437 | pcxhr_board_params[pci_id->driver_data].fw_file_set; | ||
1438 | mgr->firmware_num = | ||
1439 | pcxhr_board_params[pci_id->driver_data].firmware_num; | ||
1238 | mgr->mono_capture = mono[dev]; | 1440 | mgr->mono_capture = mono[dev]; |
1441 | mgr->is_hr_stereo = (mgr->playback_chips == 1); | ||
1442 | mgr->board_has_aes1 = PCXHR_BOARD_HAS_AES1(mgr); | ||
1443 | mgr->board_aes_in_192k = !PCXHR_BOARD_AESIN_NO_192K(mgr); | ||
1444 | |||
1445 | if (mgr->is_hr_stereo) | ||
1446 | mgr->granularity = PCXHR_GRANULARITY_HR22; | ||
1447 | else | ||
1448 | mgr->granularity = PCXHR_GRANULARITY; | ||
1239 | 1449 | ||
1240 | /* resource assignment */ | 1450 | /* resource assignment */ |
1241 | if ((err = pci_request_regions(pci, card_name)) < 0) { | 1451 | if ((err = pci_request_regions(pci, card_name)) < 0) { |
@@ -1258,7 +1468,8 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id | |||
1258 | mgr->irq = pci->irq; | 1468 | mgr->irq = pci->irq; |
1259 | 1469 | ||
1260 | sprintf(mgr->shortname, "Digigram %s", card_name); | 1470 | sprintf(mgr->shortname, "Digigram %s", card_name); |
1261 | sprintf(mgr->longname, "%s at 0x%lx & 0x%lx, 0x%lx irq %i", mgr->shortname, | 1471 | sprintf(mgr->longname, "%s at 0x%lx & 0x%lx, 0x%lx irq %i", |
1472 | mgr->shortname, | ||
1262 | mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq); | 1473 | mgr->port[0], mgr->port[1], mgr->port[2], mgr->irq); |
1263 | 1474 | ||
1264 | /* ISR spinlock */ | 1475 | /* ISR spinlock */ |
@@ -1269,10 +1480,14 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id | |||
1269 | mutex_init(&mgr->setup_mutex); | 1480 | mutex_init(&mgr->setup_mutex); |
1270 | 1481 | ||
1271 | /* init taslket */ | 1482 | /* init taslket */ |
1272 | tasklet_init(&mgr->msg_taskq, pcxhr_msg_tasklet, (unsigned long) mgr); | 1483 | tasklet_init(&mgr->msg_taskq, pcxhr_msg_tasklet, |
1273 | tasklet_init(&mgr->trigger_taskq, pcxhr_trigger_tasklet, (unsigned long) mgr); | 1484 | (unsigned long) mgr); |
1485 | tasklet_init(&mgr->trigger_taskq, pcxhr_trigger_tasklet, | ||
1486 | (unsigned long) mgr); | ||
1487 | |||
1274 | mgr->prmh = kmalloc(sizeof(*mgr->prmh) + | 1488 | mgr->prmh = kmalloc(sizeof(*mgr->prmh) + |
1275 | sizeof(u32) * (PCXHR_SIZE_MAX_LONG_STATUS - PCXHR_SIZE_MAX_STATUS), | 1489 | sizeof(u32) * (PCXHR_SIZE_MAX_LONG_STATUS - |
1490 | PCXHR_SIZE_MAX_STATUS), | ||
1276 | GFP_KERNEL); | 1491 | GFP_KERNEL); |
1277 | if (! mgr->prmh) { | 1492 | if (! mgr->prmh) { |
1278 | pcxhr_free(mgr); | 1493 | pcxhr_free(mgr); |
@@ -1293,7 +1508,8 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id | |||
1293 | else | 1508 | else |
1294 | idx = index[dev] + i; | 1509 | idx = index[dev] + i; |
1295 | 1510 | ||
1296 | snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : card_name, i); | 1511 | snprintf(tmpid, sizeof(tmpid), "%s-%d", |
1512 | id[dev] ? id[dev] : card_name, i); | ||
1297 | card = snd_card_new(idx, tmpid, THIS_MODULE, 0); | 1513 | card = snd_card_new(idx, tmpid, THIS_MODULE, 0); |
1298 | 1514 | ||
1299 | if (! card) { | 1515 | if (! card) { |
@@ -1307,6 +1523,7 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id | |||
1307 | sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); | 1523 | sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i); |
1308 | 1524 | ||
1309 | if ((err = pcxhr_create(mgr, card, i)) < 0) { | 1525 | if ((err = pcxhr_create(mgr, card, i)) < 0) { |
1526 | snd_card_free(card); | ||
1310 | pcxhr_free(mgr); | 1527 | pcxhr_free(mgr); |
1311 | return err; | 1528 | return err; |
1312 | } | 1529 | } |
diff --git a/sound/pci/pcxhr/pcxhr.h b/sound/pci/pcxhr/pcxhr.h index 652064787a55..84131a916c92 100644 --- a/sound/pci/pcxhr/pcxhr.h +++ b/sound/pci/pcxhr/pcxhr.h | |||
@@ -27,15 +27,18 @@ | |||
27 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
28 | #include <sound/pcm.h> | 28 | #include <sound/pcm.h> |
29 | 29 | ||
30 | #define PCXHR_DRIVER_VERSION 0x000804 /* 0.8.4 */ | 30 | #define PCXHR_DRIVER_VERSION 0x000905 /* 0.9.5 */ |
31 | #define PCXHR_DRIVER_VERSION_STRING "0.8.4" /* 0.8.4 */ | 31 | #define PCXHR_DRIVER_VERSION_STRING "0.9.5" /* 0.9.5 */ |
32 | 32 | ||
33 | 33 | ||
34 | #define PCXHR_MAX_CARDS 6 | 34 | #define PCXHR_MAX_CARDS 6 |
35 | #define PCXHR_PLAYBACK_STREAMS 4 | 35 | #define PCXHR_PLAYBACK_STREAMS 4 |
36 | 36 | ||
37 | #define PCXHR_GRANULARITY 96 /* transfer granularity (should be min 96 and multiple of 48) */ | 37 | #define PCXHR_GRANULARITY 96 /* min 96 and multiple of 48 */ |
38 | #define PCXHR_GRANULARITY_MIN 96 /* transfer granularity of pipes and the dsp time (MBOX4) */ | 38 | /* transfer granularity of pipes and the dsp time (MBOX4) */ |
39 | #define PCXHR_GRANULARITY_MIN 96 | ||
40 | /* TODO : granularity could be 64 or 128 */ | ||
41 | #define PCXHR_GRANULARITY_HR22 192 /* granularity for stereo cards */ | ||
39 | 42 | ||
40 | struct snd_pcxhr; | 43 | struct snd_pcxhr; |
41 | struct pcxhr_mgr; | 44 | struct pcxhr_mgr; |
@@ -51,6 +54,11 @@ enum pcxhr_clock_type { | |||
51 | PCXHR_CLOCK_TYPE_AES_2, | 54 | PCXHR_CLOCK_TYPE_AES_2, |
52 | PCXHR_CLOCK_TYPE_AES_3, | 55 | PCXHR_CLOCK_TYPE_AES_3, |
53 | PCXHR_CLOCK_TYPE_AES_4, | 56 | PCXHR_CLOCK_TYPE_AES_4, |
57 | PCXHR_CLOCK_TYPE_MAX = PCXHR_CLOCK_TYPE_AES_4, | ||
58 | HR22_CLOCK_TYPE_INTERNAL = PCXHR_CLOCK_TYPE_INTERNAL, | ||
59 | HR22_CLOCK_TYPE_AES_SYNC, | ||
60 | HR22_CLOCK_TYPE_AES_1, | ||
61 | HR22_CLOCK_TYPE_MAX = HR22_CLOCK_TYPE_AES_1, | ||
54 | }; | 62 | }; |
55 | 63 | ||
56 | struct pcxhr_mgr { | 64 | struct pcxhr_mgr { |
@@ -61,6 +69,8 @@ struct pcxhr_mgr { | |||
61 | 69 | ||
62 | int irq; | 70 | int irq; |
63 | 71 | ||
72 | int granularity; | ||
73 | |||
64 | /* card access with 1 mem bar and 2 io bar's */ | 74 | /* card access with 1 mem bar and 2 io bar's */ |
65 | unsigned long port[3]; | 75 | unsigned long port[3]; |
66 | 76 | ||
@@ -83,11 +93,16 @@ struct pcxhr_mgr { | |||
83 | /* hardware interface */ | 93 | /* hardware interface */ |
84 | unsigned int dsp_loaded; /* bit flags of loaded dsp indices */ | 94 | unsigned int dsp_loaded; /* bit flags of loaded dsp indices */ |
85 | unsigned int dsp_version; /* read from embedded once firmware is loaded */ | 95 | unsigned int dsp_version; /* read from embedded once firmware is loaded */ |
86 | int board_has_analog; /* if 0 the board is digital only */ | 96 | int playback_chips; |
87 | int mono_capture; /* if 1 the board does mono capture */ | 97 | int capture_chips; |
88 | int playback_chips; /* 4 or 6 */ | 98 | int fw_file_set; |
89 | int capture_chips; /* 4 or 1 */ | 99 | int firmware_num; |
90 | int firmware_num; /* 41 or 42 */ | 100 | int is_hr_stereo:1; |
101 | int board_has_aes1:1; /* if 1 board has AES1 plug and SRC */ | ||
102 | int board_has_analog:1; /* if 0 the board is digital only */ | ||
103 | int board_has_mic:1; /* if 1 the board has microphone input */ | ||
104 | int board_aes_in_192k:1;/* if 1 the aes input plugs do support 192kHz */ | ||
105 | int mono_capture:1; /* if 1 the board does mono capture */ | ||
91 | 106 | ||
92 | struct snd_dma_buffer hostport; | 107 | struct snd_dma_buffer hostport; |
93 | 108 | ||
@@ -106,6 +121,9 @@ struct pcxhr_mgr { | |||
106 | int async_err_stream_xrun; | 121 | int async_err_stream_xrun; |
107 | int async_err_pipe_xrun; | 122 | int async_err_pipe_xrun; |
108 | int async_err_other_last; | 123 | int async_err_other_last; |
124 | |||
125 | unsigned char xlx_cfg; /* copy of PCXHR_XLX_CFG register */ | ||
126 | unsigned char xlx_selmic; /* copy of PCXHR_XLX_SELMIC register */ | ||
109 | }; | 127 | }; |
110 | 128 | ||
111 | 129 | ||
@@ -155,24 +173,30 @@ struct snd_pcxhr { | |||
155 | 173 | ||
156 | struct snd_pcm *pcm; /* PCM */ | 174 | struct snd_pcm *pcm; /* PCM */ |
157 | 175 | ||
158 | struct pcxhr_pipe playback_pipe; /* 1 stereo pipe only */ | 176 | struct pcxhr_pipe playback_pipe; /* 1 stereo pipe only */ |
159 | struct pcxhr_pipe capture_pipe[2]; /* 1 stereo pipe or 2 mono pipes */ | 177 | struct pcxhr_pipe capture_pipe[2]; /* 1 stereo or 2 mono pipes */ |
160 | 178 | ||
161 | struct pcxhr_stream playback_stream[PCXHR_PLAYBACK_STREAMS]; | 179 | struct pcxhr_stream playback_stream[PCXHR_PLAYBACK_STREAMS]; |
162 | struct pcxhr_stream capture_stream[2]; /* 1 stereo stream or 2 mono streams */ | 180 | struct pcxhr_stream capture_stream[2]; /* 1 stereo or 2 mono streams */ |
163 | int nb_streams_play; | 181 | int nb_streams_play; |
164 | int nb_streams_capt; | 182 | int nb_streams_capt; |
165 | 183 | ||
166 | int analog_playback_active[2]; /* Mixer : Master Playback active (!mute) */ | 184 | int analog_playback_active[2]; /* Mixer : Master Playback !mute */ |
167 | int analog_playback_volume[2]; /* Mixer : Master Playback Volume */ | 185 | int analog_playback_volume[2]; /* Mixer : Master Playback Volume */ |
168 | int analog_capture_volume[2]; /* Mixer : Master Capture Volume */ | 186 | int analog_capture_volume[2]; /* Mixer : Master Capture Volume */ |
169 | int digital_playback_active[PCXHR_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Active [streams][stereo]*/ | 187 | int digital_playback_active[PCXHR_PLAYBACK_STREAMS][2]; |
170 | int digital_playback_volume[PCXHR_PLAYBACK_STREAMS][2]; /* Mixer : Digital Playback Volume [streams][stereo]*/ | 188 | int digital_playback_volume[PCXHR_PLAYBACK_STREAMS][2]; |
171 | int digital_capture_volume[2]; /* Mixer : Digital Capture Volume [stereo] */ | 189 | int digital_capture_volume[2]; /* Mixer : Digital Capture Volume */ |
172 | int monitoring_active[2]; /* Mixer : Monitoring Active */ | 190 | int monitoring_active[2]; /* Mixer : Monitoring Active */ |
173 | int monitoring_volume[2]; /* Mixer : Monitoring Volume */ | 191 | int monitoring_volume[2]; /* Mixer : Monitoring Volume */ |
174 | int audio_capture_source; /* Mixer : Audio Capture Source */ | 192 | int audio_capture_source; /* Mixer : Audio Capture Source */ |
175 | unsigned char aes_bits[5]; /* Mixer : IEC958_AES bits */ | 193 | int mic_volume; /* used by cards with MIC only */ |
194 | int mic_boost; /* used by cards with MIC only */ | ||
195 | int mic_active; /* used by cards with MIC only */ | ||
196 | int analog_capture_active; /* used by cards with MIC only */ | ||
197 | int phantom_power; /* used by cards with MIC only */ | ||
198 | |||
199 | unsigned char aes_bits[5]; /* Mixer : IEC958_AES bits */ | ||
176 | }; | 200 | }; |
177 | 201 | ||
178 | struct pcxhr_hostport | 202 | struct pcxhr_hostport |
@@ -184,6 +208,8 @@ struct pcxhr_hostport | |||
184 | /* exported */ | 208 | /* exported */ |
185 | int pcxhr_create_pcm(struct snd_pcxhr *chip); | 209 | int pcxhr_create_pcm(struct snd_pcxhr *chip); |
186 | int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate); | 210 | int pcxhr_set_clock(struct pcxhr_mgr *mgr, unsigned int rate); |
187 | int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, enum pcxhr_clock_type clock_type, int *sample_rate); | 211 | int pcxhr_get_external_clock(struct pcxhr_mgr *mgr, |
212 | enum pcxhr_clock_type clock_type, | ||
213 | int *sample_rate); | ||
188 | 214 | ||
189 | #endif /* __SOUND_PCXHR_H */ | 215 | #endif /* __SOUND_PCXHR_H */ |
diff --git a/sound/pci/pcxhr/pcxhr_core.c b/sound/pci/pcxhr/pcxhr_core.c index 7143259cfe34..833e7180ad2d 100644 --- a/sound/pci/pcxhr/pcxhr_core.c +++ b/sound/pci/pcxhr/pcxhr_core.c | |||
@@ -132,13 +132,15 @@ static int pcxhr_check_reg_bit(struct pcxhr_mgr *mgr, unsigned int reg, | |||
132 | *read = PCXHR_INPB(mgr, reg); | 132 | *read = PCXHR_INPB(mgr, reg); |
133 | if ((*read & mask) == bit) { | 133 | if ((*read & mask) == bit) { |
134 | if (i > 100) | 134 | if (i > 100) |
135 | snd_printdd("ATTENTION! check_reg(%x) loopcount=%d\n", | 135 | snd_printdd("ATTENTION! check_reg(%x) " |
136 | "loopcount=%d\n", | ||
136 | reg, i); | 137 | reg, i); |
137 | return 0; | 138 | return 0; |
138 | } | 139 | } |
139 | i++; | 140 | i++; |
140 | } while (time_after_eq(end_time, jiffies)); | 141 | } while (time_after_eq(end_time, jiffies)); |
141 | snd_printk(KERN_ERR "pcxhr_check_reg_bit: timeout, reg=%x, mask=0x%x, val=0x%x\n", | 142 | snd_printk(KERN_ERR |
143 | "pcxhr_check_reg_bit: timeout, reg=%x, mask=0x%x, val=%x\n", | ||
142 | reg, mask, *read); | 144 | reg, mask, *read); |
143 | return -EIO; | 145 | return -EIO; |
144 | } | 146 | } |
@@ -159,18 +161,22 @@ static int pcxhr_check_reg_bit(struct pcxhr_mgr *mgr, unsigned int reg, | |||
159 | #define PCXHR_IT_TEST_XILINX (0x0000003C | PCXHR_MASK_IT_HF1 | \ | 161 | #define PCXHR_IT_TEST_XILINX (0x0000003C | PCXHR_MASK_IT_HF1 | \ |
160 | PCXHR_MASK_IT_MANAGE_HF5) | 162 | PCXHR_MASK_IT_MANAGE_HF5) |
161 | #define PCXHR_IT_DOWNLOAD_BOOT (0x0000000C | PCXHR_MASK_IT_HF1 | \ | 163 | #define PCXHR_IT_DOWNLOAD_BOOT (0x0000000C | PCXHR_MASK_IT_HF1 | \ |
162 | PCXHR_MASK_IT_MANAGE_HF5 | PCXHR_MASK_IT_WAIT) | 164 | PCXHR_MASK_IT_MANAGE_HF5 | \ |
165 | PCXHR_MASK_IT_WAIT) | ||
163 | #define PCXHR_IT_RESET_BOARD_FUNC (0x0000000C | PCXHR_MASK_IT_HF0 | \ | 166 | #define PCXHR_IT_RESET_BOARD_FUNC (0x0000000C | PCXHR_MASK_IT_HF0 | \ |
164 | PCXHR_MASK_IT_MANAGE_HF5 | PCXHR_MASK_IT_WAIT_EXTRA) | 167 | PCXHR_MASK_IT_MANAGE_HF5 | \ |
168 | PCXHR_MASK_IT_WAIT_EXTRA) | ||
165 | #define PCXHR_IT_DOWNLOAD_DSP (0x0000000C | \ | 169 | #define PCXHR_IT_DOWNLOAD_DSP (0x0000000C | \ |
166 | PCXHR_MASK_IT_MANAGE_HF5 | PCXHR_MASK_IT_WAIT) | 170 | PCXHR_MASK_IT_MANAGE_HF5 | \ |
171 | PCXHR_MASK_IT_WAIT) | ||
167 | #define PCXHR_IT_DEBUG (0x0000005A | PCXHR_MASK_IT_NO_HF0_HF1) | 172 | #define PCXHR_IT_DEBUG (0x0000005A | PCXHR_MASK_IT_NO_HF0_HF1) |
168 | #define PCXHR_IT_RESET_SEMAPHORE (0x0000005C | PCXHR_MASK_IT_NO_HF0_HF1) | 173 | #define PCXHR_IT_RESET_SEMAPHORE (0x0000005C | PCXHR_MASK_IT_NO_HF0_HF1) |
169 | #define PCXHR_IT_MESSAGE (0x00000074 | PCXHR_MASK_IT_NO_HF0_HF1) | 174 | #define PCXHR_IT_MESSAGE (0x00000074 | PCXHR_MASK_IT_NO_HF0_HF1) |
170 | #define PCXHR_IT_RESET_CHK (0x00000076 | PCXHR_MASK_IT_NO_HF0_HF1) | 175 | #define PCXHR_IT_RESET_CHK (0x00000076 | PCXHR_MASK_IT_NO_HF0_HF1) |
171 | #define PCXHR_IT_UPDATE_RBUFFER (0x00000078 | PCXHR_MASK_IT_NO_HF0_HF1) | 176 | #define PCXHR_IT_UPDATE_RBUFFER (0x00000078 | PCXHR_MASK_IT_NO_HF0_HF1) |
172 | 177 | ||
173 | static int pcxhr_send_it_dsp(struct pcxhr_mgr *mgr, unsigned int itdsp, int atomic) | 178 | static int pcxhr_send_it_dsp(struct pcxhr_mgr *mgr, |
179 | unsigned int itdsp, int atomic) | ||
174 | { | 180 | { |
175 | int err; | 181 | int err; |
176 | unsigned char reg; | 182 | unsigned char reg; |
@@ -178,17 +184,21 @@ static int pcxhr_send_it_dsp(struct pcxhr_mgr *mgr, unsigned int itdsp, int atom | |||
178 | if (itdsp & PCXHR_MASK_IT_MANAGE_HF5) { | 184 | if (itdsp & PCXHR_MASK_IT_MANAGE_HF5) { |
179 | /* clear hf5 bit */ | 185 | /* clear hf5 bit */ |
180 | PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX0, | 186 | PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX0, |
181 | PCXHR_INPL(mgr, PCXHR_PLX_MBOX0) & ~PCXHR_MBOX0_HF5); | 187 | PCXHR_INPL(mgr, PCXHR_PLX_MBOX0) & |
188 | ~PCXHR_MBOX0_HF5); | ||
182 | } | 189 | } |
183 | if ((itdsp & PCXHR_MASK_IT_NO_HF0_HF1) == 0) { | 190 | if ((itdsp & PCXHR_MASK_IT_NO_HF0_HF1) == 0) { |
184 | reg = PCXHR_ICR_HI08_RREQ | PCXHR_ICR_HI08_TREQ | PCXHR_ICR_HI08_HDRQ; | 191 | reg = (PCXHR_ICR_HI08_RREQ | |
192 | PCXHR_ICR_HI08_TREQ | | ||
193 | PCXHR_ICR_HI08_HDRQ); | ||
185 | if (itdsp & PCXHR_MASK_IT_HF0) | 194 | if (itdsp & PCXHR_MASK_IT_HF0) |
186 | reg |= PCXHR_ICR_HI08_HF0; | 195 | reg |= PCXHR_ICR_HI08_HF0; |
187 | if (itdsp & PCXHR_MASK_IT_HF1) | 196 | if (itdsp & PCXHR_MASK_IT_HF1) |
188 | reg |= PCXHR_ICR_HI08_HF1; | 197 | reg |= PCXHR_ICR_HI08_HF1; |
189 | PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg); | 198 | PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg); |
190 | } | 199 | } |
191 | reg = (unsigned char)(((itdsp & PCXHR_MASK_EXTRA_INFO) >> 1) | PCXHR_CVR_HI08_HC); | 200 | reg = (unsigned char)(((itdsp & PCXHR_MASK_EXTRA_INFO) >> 1) | |
201 | PCXHR_CVR_HI08_HC); | ||
192 | PCXHR_OUTPB(mgr, PCXHR_DSP_CVR, reg); | 202 | PCXHR_OUTPB(mgr, PCXHR_DSP_CVR, reg); |
193 | if (itdsp & PCXHR_MASK_IT_WAIT) { | 203 | if (itdsp & PCXHR_MASK_IT_WAIT) { |
194 | if (atomic) | 204 | if (atomic) |
@@ -211,10 +221,14 @@ static int pcxhr_send_it_dsp(struct pcxhr_mgr *mgr, unsigned int itdsp, int atom | |||
211 | } | 221 | } |
212 | if (itdsp & PCXHR_MASK_IT_MANAGE_HF5) { | 222 | if (itdsp & PCXHR_MASK_IT_MANAGE_HF5) { |
213 | /* wait for hf5 bit */ | 223 | /* wait for hf5 bit */ |
214 | err = pcxhr_check_reg_bit(mgr, PCXHR_PLX_MBOX0, PCXHR_MBOX0_HF5, | 224 | err = pcxhr_check_reg_bit(mgr, PCXHR_PLX_MBOX0, |
215 | PCXHR_MBOX0_HF5, PCXHR_TIMEOUT_DSP, ®); | 225 | PCXHR_MBOX0_HF5, |
226 | PCXHR_MBOX0_HF5, | ||
227 | PCXHR_TIMEOUT_DSP, | ||
228 | ®); | ||
216 | if (err) { | 229 | if (err) { |
217 | snd_printk(KERN_ERR "pcxhr_send_it_dsp : TIMEOUT HF5\n"); | 230 | snd_printk(KERN_ERR |
231 | "pcxhr_send_it_dsp : TIMEOUT HF5\n"); | ||
218 | return err; | 232 | return err; |
219 | } | 233 | } |
220 | } | 234 | } |
@@ -263,7 +277,8 @@ void pcxhr_enable_dsp(struct pcxhr_mgr *mgr) | |||
263 | /* | 277 | /* |
264 | * load the xilinx image | 278 | * load the xilinx image |
265 | */ | 279 | */ |
266 | int pcxhr_load_xilinx_binary(struct pcxhr_mgr *mgr, const struct firmware *xilinx, int second) | 280 | int pcxhr_load_xilinx_binary(struct pcxhr_mgr *mgr, |
281 | const struct firmware *xilinx, int second) | ||
267 | { | 282 | { |
268 | unsigned int i; | 283 | unsigned int i; |
269 | unsigned int chipsc; | 284 | unsigned int chipsc; |
@@ -274,7 +289,9 @@ int pcxhr_load_xilinx_binary(struct pcxhr_mgr *mgr, const struct firmware *xilin | |||
274 | /* test first xilinx */ | 289 | /* test first xilinx */ |
275 | chipsc = PCXHR_INPL(mgr, PCXHR_PLX_CHIPSC); | 290 | chipsc = PCXHR_INPL(mgr, PCXHR_PLX_CHIPSC); |
276 | /* REV01 cards do not support the PCXHR_CHIPSC_GPI_USERI bit anymore */ | 291 | /* REV01 cards do not support the PCXHR_CHIPSC_GPI_USERI bit anymore */ |
277 | /* this bit will always be 1; no possibility to test presence of first xilinx */ | 292 | /* this bit will always be 1; |
293 | * no possibility to test presence of first xilinx | ||
294 | */ | ||
278 | if(second) { | 295 | if(second) { |
279 | if ((chipsc & PCXHR_CHIPSC_GPI_USERI) == 0) { | 296 | if ((chipsc & PCXHR_CHIPSC_GPI_USERI) == 0) { |
280 | snd_printk(KERN_ERR "error loading first xilinx\n"); | 297 | snd_printk(KERN_ERR "error loading first xilinx\n"); |
@@ -290,7 +307,8 @@ int pcxhr_load_xilinx_binary(struct pcxhr_mgr *mgr, const struct firmware *xilin | |||
290 | data = *image; | 307 | data = *image; |
291 | mask = 0x80; | 308 | mask = 0x80; |
292 | while (mask) { | 309 | while (mask) { |
293 | chipsc &= ~(PCXHR_CHIPSC_DATA_CLK | PCXHR_CHIPSC_DATA_IN); | 310 | chipsc &= ~(PCXHR_CHIPSC_DATA_CLK | |
311 | PCXHR_CHIPSC_DATA_IN); | ||
294 | if (data & mask) | 312 | if (data & mask) |
295 | chipsc |= PCXHR_CHIPSC_DATA_IN; | 313 | chipsc |= PCXHR_CHIPSC_DATA_IN; |
296 | PCXHR_OUTPL(mgr, PCXHR_PLX_CHIPSC, chipsc); | 314 | PCXHR_OUTPL(mgr, PCXHR_PLX_CHIPSC, chipsc); |
@@ -330,15 +348,20 @@ static int pcxhr_download_dsp(struct pcxhr_mgr *mgr, const struct firmware *dsp) | |||
330 | data = dsp->data + i; | 348 | data = dsp->data + i; |
331 | if (i == 0) { | 349 | if (i == 0) { |
332 | /* test data header consistency */ | 350 | /* test data header consistency */ |
333 | len = (unsigned int)((data[0]<<16) + (data[1]<<8) + data[2]); | 351 | len = (unsigned int)((data[0]<<16) + |
334 | if (len && dsp->size != (len + 2) * 3) | 352 | (data[1]<<8) + |
353 | data[2]); | ||
354 | if (len && (dsp->size != (len + 2) * 3)) | ||
335 | return -EINVAL; | 355 | return -EINVAL; |
336 | } | 356 | } |
337 | /* wait DSP ready for new transfer */ | 357 | /* wait DSP ready for new transfer */ |
338 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY, | 358 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, |
339 | PCXHR_ISR_HI08_TRDY, PCXHR_TIMEOUT_DSP, &dummy); | 359 | PCXHR_ISR_HI08_TRDY, |
360 | PCXHR_ISR_HI08_TRDY, | ||
361 | PCXHR_TIMEOUT_DSP, &dummy); | ||
340 | if (err) { | 362 | if (err) { |
341 | snd_printk(KERN_ERR "dsp loading error at position %d\n", i); | 363 | snd_printk(KERN_ERR |
364 | "dsp loading error at position %d\n", i); | ||
342 | return err; | 365 | return err; |
343 | } | 366 | } |
344 | /* send host data */ | 367 | /* send host data */ |
@@ -357,7 +380,8 @@ static int pcxhr_download_dsp(struct pcxhr_mgr *mgr, const struct firmware *dsp) | |||
357 | /* | 380 | /* |
358 | * load the eeprom image | 381 | * load the eeprom image |
359 | */ | 382 | */ |
360 | int pcxhr_load_eeprom_binary(struct pcxhr_mgr *mgr, const struct firmware *eeprom) | 383 | int pcxhr_load_eeprom_binary(struct pcxhr_mgr *mgr, |
384 | const struct firmware *eeprom) | ||
361 | { | 385 | { |
362 | int err; | 386 | int err; |
363 | unsigned char reg; | 387 | unsigned char reg; |
@@ -365,7 +389,9 @@ int pcxhr_load_eeprom_binary(struct pcxhr_mgr *mgr, const struct firmware *eepro | |||
365 | /* init value of the ICR register */ | 389 | /* init value of the ICR register */ |
366 | reg = PCXHR_ICR_HI08_RREQ | PCXHR_ICR_HI08_TREQ | PCXHR_ICR_HI08_HDRQ; | 390 | reg = PCXHR_ICR_HI08_RREQ | PCXHR_ICR_HI08_TREQ | PCXHR_ICR_HI08_HDRQ; |
367 | if (PCXHR_INPL(mgr, PCXHR_PLX_MBOX0) & PCXHR_MBOX0_BOOT_HERE) { | 391 | if (PCXHR_INPL(mgr, PCXHR_PLX_MBOX0) & PCXHR_MBOX0_BOOT_HERE) { |
368 | /* no need to load the eeprom binary, but init the HI08 interface */ | 392 | /* no need to load the eeprom binary, |
393 | * but init the HI08 interface | ||
394 | */ | ||
369 | PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg | PCXHR_ICR_HI08_INIT); | 395 | PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg | PCXHR_ICR_HI08_INIT); |
370 | msleep(PCXHR_WAIT_DEFAULT); | 396 | msleep(PCXHR_WAIT_DEFAULT); |
371 | PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg); | 397 | PCXHR_OUTPB(mgr, PCXHR_DSP_ICR, reg); |
@@ -429,8 +455,10 @@ int pcxhr_load_dsp_binary(struct pcxhr_mgr *mgr, const struct firmware *dsp) | |||
429 | if (err) | 455 | if (err) |
430 | return err; | 456 | return err; |
431 | /* wait for chk bit */ | 457 | /* wait for chk bit */ |
432 | return pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_CHK, | 458 | return pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, |
433 | PCXHR_ISR_HI08_CHK, PCXHR_TIMEOUT_DSP, &dummy); | 459 | PCXHR_ISR_HI08_CHK, |
460 | PCXHR_ISR_HI08_CHK, | ||
461 | PCXHR_TIMEOUT_DSP, &dummy); | ||
434 | } | 462 | } |
435 | 463 | ||
436 | 464 | ||
@@ -443,8 +471,8 @@ struct pcxhr_cmd_info { | |||
443 | /* RMH status type */ | 471 | /* RMH status type */ |
444 | enum { | 472 | enum { |
445 | RMH_SSIZE_FIXED = 0, /* status size fix (st_length = 0..x) */ | 473 | RMH_SSIZE_FIXED = 0, /* status size fix (st_length = 0..x) */ |
446 | RMH_SSIZE_ARG = 1, /* status size given in the LSB byte (used with st_length = 1) */ | 474 | RMH_SSIZE_ARG = 1, /* status size given in the LSB byte */ |
447 | RMH_SSIZE_MASK = 2, /* status size given in bitmask (used with st_length = 1) */ | 475 | RMH_SSIZE_MASK = 2, /* status size given in bitmask */ |
448 | }; | 476 | }; |
449 | 477 | ||
450 | /* | 478 | /* |
@@ -474,7 +502,7 @@ static struct pcxhr_cmd_info pcxhr_dsp_cmds[] = { | |||
474 | [CMD_UPDATE_R_BUFFERS] = { 0x840000, 0, RMH_SSIZE_FIXED }, | 502 | [CMD_UPDATE_R_BUFFERS] = { 0x840000, 0, RMH_SSIZE_FIXED }, |
475 | [CMD_FORMAT_STREAM_OUT] = { 0x860000, 0, RMH_SSIZE_FIXED }, | 503 | [CMD_FORMAT_STREAM_OUT] = { 0x860000, 0, RMH_SSIZE_FIXED }, |
476 | [CMD_FORMAT_STREAM_IN] = { 0x870000, 0, RMH_SSIZE_FIXED }, | 504 | [CMD_FORMAT_STREAM_IN] = { 0x870000, 0, RMH_SSIZE_FIXED }, |
477 | [CMD_STREAM_SAMPLE_COUNT] = { 0x902000, 2, RMH_SSIZE_FIXED }, /* stat_len = nb_streams * 2 */ | 505 | [CMD_STREAM_SAMPLE_COUNT] = { 0x902000, 2, RMH_SSIZE_FIXED }, |
478 | [CMD_AUDIO_LEVEL_ADJUST] = { 0xc22000, 0, RMH_SSIZE_FIXED }, | 506 | [CMD_AUDIO_LEVEL_ADJUST] = { 0xc22000, 0, RMH_SSIZE_FIXED }, |
479 | }; | 507 | }; |
480 | 508 | ||
@@ -524,10 +552,13 @@ static int pcxhr_read_rmh_status(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) | |||
524 | 552 | ||
525 | for (i = 0; i < rmh->stat_len; i++) { | 553 | for (i = 0; i < rmh->stat_len; i++) { |
526 | /* wait for receiver full */ | 554 | /* wait for receiver full */ |
527 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_RXDF, | 555 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, |
528 | PCXHR_ISR_HI08_RXDF, PCXHR_TIMEOUT_DSP, ®); | 556 | PCXHR_ISR_HI08_RXDF, |
557 | PCXHR_ISR_HI08_RXDF, | ||
558 | PCXHR_TIMEOUT_DSP, ®); | ||
529 | if (err) { | 559 | if (err) { |
530 | snd_printk(KERN_ERR "ERROR RMH stat: ISR:RXDF=1 (ISR = %x; i=%d )\n", | 560 | snd_printk(KERN_ERR "ERROR RMH stat: " |
561 | "ISR:RXDF=1 (ISR = %x; i=%d )\n", | ||
531 | reg, i); | 562 | reg, i); |
532 | return err; | 563 | return err; |
533 | } | 564 | } |
@@ -537,10 +568,10 @@ static int pcxhr_read_rmh_status(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) | |||
537 | data |= PCXHR_INPB(mgr, PCXHR_DSP_TXL); | 568 | data |= PCXHR_INPB(mgr, PCXHR_DSP_TXL); |
538 | 569 | ||
539 | /* need to update rmh->stat_len on the fly ?? */ | 570 | /* need to update rmh->stat_len on the fly ?? */ |
540 | if (i==0) { | 571 | if (!i) { |
541 | if (rmh->dsp_stat != RMH_SSIZE_FIXED) { | 572 | if (rmh->dsp_stat != RMH_SSIZE_FIXED) { |
542 | if (rmh->dsp_stat == RMH_SSIZE_ARG) { | 573 | if (rmh->dsp_stat == RMH_SSIZE_ARG) { |
543 | rmh->stat_len = (u16)(data & 0x0000ff) + 1; | 574 | rmh->stat_len = (data & 0x0000ff) + 1; |
544 | data &= 0xffff00; | 575 | data &= 0xffff00; |
545 | } else { | 576 | } else { |
546 | /* rmh->dsp_stat == RMH_SSIZE_MASK */ | 577 | /* rmh->dsp_stat == RMH_SSIZE_MASK */ |
@@ -562,7 +593,8 @@ static int pcxhr_read_rmh_status(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) | |||
562 | rmh->stat[i] = data; | 593 | rmh->stat[i] = data; |
563 | } | 594 | } |
564 | if (rmh->stat_len > max_stat_len) { | 595 | if (rmh->stat_len > max_stat_len) { |
565 | snd_printdd("PCXHR : rmh->stat_len=%x too big\n", rmh->stat_len); | 596 | snd_printdd("PCXHR : rmh->stat_len=%x too big\n", |
597 | rmh->stat_len); | ||
566 | rmh->stat_len = max_stat_len; | 598 | rmh->stat_len = max_stat_len; |
567 | } | 599 | } |
568 | return 0; | 600 | return 0; |
@@ -605,7 +637,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) | |||
605 | data &= 0xff7fff; /* MASK_1_WORD_COMMAND */ | 637 | data &= 0xff7fff; /* MASK_1_WORD_COMMAND */ |
606 | #ifdef CONFIG_SND_DEBUG_VERBOSE | 638 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
607 | if (rmh->cmd_idx < CMD_LAST_INDEX) | 639 | if (rmh->cmd_idx < CMD_LAST_INDEX) |
608 | snd_printdd("MSG cmd[0]=%x (%s)\n", data, cmd_names[rmh->cmd_idx]); | 640 | snd_printdd("MSG cmd[0]=%x (%s)\n", |
641 | data, cmd_names[rmh->cmd_idx]); | ||
609 | #endif | 642 | #endif |
610 | 643 | ||
611 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY, | 644 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY, |
@@ -619,8 +652,10 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) | |||
619 | if (rmh->cmd_len > 1) { | 652 | if (rmh->cmd_len > 1) { |
620 | /* send length */ | 653 | /* send length */ |
621 | data = rmh->cmd_len - 1; | 654 | data = rmh->cmd_len - 1; |
622 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY, | 655 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, |
623 | PCXHR_ISR_HI08_TRDY, PCXHR_TIMEOUT_DSP, ®); | 656 | PCXHR_ISR_HI08_TRDY, |
657 | PCXHR_ISR_HI08_TRDY, | ||
658 | PCXHR_TIMEOUT_DSP, ®); | ||
624 | if (err) | 659 | if (err) |
625 | return err; | 660 | return err; |
626 | PCXHR_OUTPB(mgr, PCXHR_DSP_TXH, (data>>16)&0xFF); | 661 | PCXHR_OUTPB(mgr, PCXHR_DSP_TXH, (data>>16)&0xFF); |
@@ -653,8 +688,10 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) | |||
653 | /* test status ISR */ | 688 | /* test status ISR */ |
654 | if (reg & PCXHR_ISR_HI08_ERR) { | 689 | if (reg & PCXHR_ISR_HI08_ERR) { |
655 | /* ERROR, wait for receiver full */ | 690 | /* ERROR, wait for receiver full */ |
656 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_RXDF, | 691 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, |
657 | PCXHR_ISR_HI08_RXDF, PCXHR_TIMEOUT_DSP, ®); | 692 | PCXHR_ISR_HI08_RXDF, |
693 | PCXHR_ISR_HI08_RXDF, | ||
694 | PCXHR_TIMEOUT_DSP, ®); | ||
658 | if (err) { | 695 | if (err) { |
659 | snd_printk(KERN_ERR "ERROR RMH: ISR:RXDF=1 (ISR = %x)\n", reg); | 696 | snd_printk(KERN_ERR "ERROR RMH: ISR:RXDF=1 (ISR = %x)\n", reg); |
660 | return err; | 697 | return err; |
@@ -663,7 +700,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) | |||
663 | data = PCXHR_INPB(mgr, PCXHR_DSP_TXH) << 16; | 700 | data = PCXHR_INPB(mgr, PCXHR_DSP_TXH) << 16; |
664 | data |= PCXHR_INPB(mgr, PCXHR_DSP_TXM) << 8; | 701 | data |= PCXHR_INPB(mgr, PCXHR_DSP_TXM) << 8; |
665 | data |= PCXHR_INPB(mgr, PCXHR_DSP_TXL); | 702 | data |= PCXHR_INPB(mgr, PCXHR_DSP_TXL); |
666 | snd_printk(KERN_ERR "ERROR RMH(%d): 0x%x\n", rmh->cmd_idx, data); | 703 | snd_printk(KERN_ERR "ERROR RMH(%d): 0x%x\n", |
704 | rmh->cmd_idx, data); | ||
667 | err = -EINVAL; | 705 | err = -EINVAL; |
668 | } else { | 706 | } else { |
669 | /* read the response data */ | 707 | /* read the response data */ |
@@ -732,8 +770,9 @@ int pcxhr_send_msg(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) | |||
732 | static inline int pcxhr_pipes_running(struct pcxhr_mgr *mgr) | 770 | static inline int pcxhr_pipes_running(struct pcxhr_mgr *mgr) |
733 | { | 771 | { |
734 | int start_mask = PCXHR_INPL(mgr, PCXHR_PLX_MBOX2); | 772 | int start_mask = PCXHR_INPL(mgr, PCXHR_PLX_MBOX2); |
735 | /* least segnificant 12 bits are the pipe states for the playback audios */ | 773 | /* least segnificant 12 bits are the pipe states |
736 | /* next 12 bits are the pipe states for the capture audios | 774 | * for the playback audios |
775 | * next 12 bits are the pipe states for the capture audios | ||
737 | * (PCXHR_PIPE_STATE_CAPTURE_OFFSET) | 776 | * (PCXHR_PIPE_STATE_CAPTURE_OFFSET) |
738 | */ | 777 | */ |
739 | start_mask &= 0xffffff; | 778 | start_mask &= 0xffffff; |
@@ -744,7 +783,8 @@ static inline int pcxhr_pipes_running(struct pcxhr_mgr *mgr) | |||
744 | #define PCXHR_PIPE_STATE_CAPTURE_OFFSET 12 | 783 | #define PCXHR_PIPE_STATE_CAPTURE_OFFSET 12 |
745 | #define MAX_WAIT_FOR_DSP 20 | 784 | #define MAX_WAIT_FOR_DSP 20 |
746 | 785 | ||
747 | static int pcxhr_prepair_pipe_start(struct pcxhr_mgr *mgr, int audio_mask, int *retry) | 786 | static int pcxhr_prepair_pipe_start(struct pcxhr_mgr *mgr, |
787 | int audio_mask, int *retry) | ||
748 | { | 788 | { |
749 | struct pcxhr_rmh rmh; | 789 | struct pcxhr_rmh rmh; |
750 | int err; | 790 | int err; |
@@ -760,17 +800,20 @@ static int pcxhr_prepair_pipe_start(struct pcxhr_mgr *mgr, int audio_mask, int * | |||
760 | } else { | 800 | } else { |
761 | /* can start capture pipe */ | 801 | /* can start capture pipe */ |
762 | pcxhr_set_pipe_cmd_params(&rmh, 1, audio - | 802 | pcxhr_set_pipe_cmd_params(&rmh, 1, audio - |
763 | PCXHR_PIPE_STATE_CAPTURE_OFFSET, | 803 | PCXHR_PIPE_STATE_CAPTURE_OFFSET, |
764 | 0, 0); | 804 | 0, 0); |
765 | } | 805 | } |
766 | err = pcxhr_send_msg(mgr, &rmh); | 806 | err = pcxhr_send_msg(mgr, &rmh); |
767 | if (err) { | 807 | if (err) { |
768 | snd_printk(KERN_ERR | 808 | snd_printk(KERN_ERR |
769 | "error pipe start (CMD_CAN_START_PIPE) err=%x!\n", | 809 | "error pipe start " |
810 | "(CMD_CAN_START_PIPE) err=%x!\n", | ||
770 | err); | 811 | err); |
771 | return err; | 812 | return err; |
772 | } | 813 | } |
773 | /* if the pipe couldn't be prepaired for start, retry it later */ | 814 | /* if the pipe couldn't be prepaired for start, |
815 | * retry it later | ||
816 | */ | ||
774 | if (rmh.stat[0] == 0) | 817 | if (rmh.stat[0] == 0) |
775 | *retry |= (1<<audio); | 818 | *retry |= (1<<audio); |
776 | } | 819 | } |
@@ -795,14 +838,14 @@ static int pcxhr_stop_pipes(struct pcxhr_mgr *mgr, int audio_mask) | |||
795 | } else { | 838 | } else { |
796 | /* stop capture pipe */ | 839 | /* stop capture pipe */ |
797 | pcxhr_set_pipe_cmd_params(&rmh, 1, audio - | 840 | pcxhr_set_pipe_cmd_params(&rmh, 1, audio - |
798 | PCXHR_PIPE_STATE_CAPTURE_OFFSET, | 841 | PCXHR_PIPE_STATE_CAPTURE_OFFSET, |
799 | 0, 0); | 842 | 0, 0); |
800 | } | 843 | } |
801 | err = pcxhr_send_msg(mgr, &rmh); | 844 | err = pcxhr_send_msg(mgr, &rmh); |
802 | if (err) { | 845 | if (err) { |
803 | snd_printk(KERN_ERR | 846 | snd_printk(KERN_ERR |
804 | "error pipe stop (CMD_STOP_PIPE) err=%x!\n", | 847 | "error pipe stop " |
805 | err); | 848 | "(CMD_STOP_PIPE) err=%x!\n", err); |
806 | return err; | 849 | return err; |
807 | } | 850 | } |
808 | } | 851 | } |
@@ -822,15 +865,16 @@ static int pcxhr_toggle_pipes(struct pcxhr_mgr *mgr, int audio_mask) | |||
822 | if (audio_mask & 1) { | 865 | if (audio_mask & 1) { |
823 | pcxhr_init_rmh(&rmh, CMD_CONF_PIPE); | 866 | pcxhr_init_rmh(&rmh, CMD_CONF_PIPE); |
824 | if (audio < PCXHR_PIPE_STATE_CAPTURE_OFFSET) | 867 | if (audio < PCXHR_PIPE_STATE_CAPTURE_OFFSET) |
825 | pcxhr_set_pipe_cmd_params(&rmh, 0, 0, 0, 1 << audio); | 868 | pcxhr_set_pipe_cmd_params(&rmh, 0, 0, 0, |
869 | 1 << audio); | ||
826 | else | 870 | else |
827 | pcxhr_set_pipe_cmd_params(&rmh, 1, 0, 0, | 871 | pcxhr_set_pipe_cmd_params(&rmh, 1, 0, 0, |
828 | 1 << (audio - PCXHR_PIPE_STATE_CAPTURE_OFFSET)); | 872 | 1 << (audio - PCXHR_PIPE_STATE_CAPTURE_OFFSET)); |
829 | err = pcxhr_send_msg(mgr, &rmh); | 873 | err = pcxhr_send_msg(mgr, &rmh); |
830 | if (err) { | 874 | if (err) { |
831 | snd_printk(KERN_ERR | 875 | snd_printk(KERN_ERR |
832 | "error pipe start (CMD_CONF_PIPE) err=%x!\n", | 876 | "error pipe start " |
833 | err); | 877 | "(CMD_CONF_PIPE) err=%x!\n", err); |
834 | return err; | 878 | return err; |
835 | } | 879 | } |
836 | } | 880 | } |
@@ -841,7 +885,9 @@ static int pcxhr_toggle_pipes(struct pcxhr_mgr *mgr, int audio_mask) | |||
841 | pcxhr_init_rmh(&rmh, CMD_SEND_IRQA); | 885 | pcxhr_init_rmh(&rmh, CMD_SEND_IRQA); |
842 | err = pcxhr_send_msg(mgr, &rmh); | 886 | err = pcxhr_send_msg(mgr, &rmh); |
843 | if (err) { | 887 | if (err) { |
844 | snd_printk(KERN_ERR "error pipe start (CMD_SEND_IRQA) err=%x!\n", err ); | 888 | snd_printk(KERN_ERR |
889 | "error pipe start (CMD_SEND_IRQA) err=%x!\n", | ||
890 | err); | ||
845 | return err; | 891 | return err; |
846 | } | 892 | } |
847 | return 0; | 893 | return 0; |
@@ -849,7 +895,8 @@ static int pcxhr_toggle_pipes(struct pcxhr_mgr *mgr, int audio_mask) | |||
849 | 895 | ||
850 | 896 | ||
851 | 897 | ||
852 | int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask, int capture_mask, int start) | 898 | int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask, |
899 | int capture_mask, int start) | ||
853 | { | 900 | { |
854 | int state, i, err; | 901 | int state, i, err; |
855 | int audio_mask; | 902 | int audio_mask; |
@@ -858,21 +905,23 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask, int capture_m | |||
858 | struct timeval my_tv1, my_tv2; | 905 | struct timeval my_tv1, my_tv2; |
859 | do_gettimeofday(&my_tv1); | 906 | do_gettimeofday(&my_tv1); |
860 | #endif | 907 | #endif |
861 | audio_mask = (playback_mask | (capture_mask << PCXHR_PIPE_STATE_CAPTURE_OFFSET)); | 908 | audio_mask = (playback_mask | |
909 | (capture_mask << PCXHR_PIPE_STATE_CAPTURE_OFFSET)); | ||
862 | /* current pipe state (playback + record) */ | 910 | /* current pipe state (playback + record) */ |
863 | state = pcxhr_pipes_running(mgr); | 911 | state = pcxhr_pipes_running(mgr); |
864 | snd_printdd("pcxhr_set_pipe_state %s (mask %x current %x)\n", | 912 | snd_printdd("pcxhr_set_pipe_state %s (mask %x current %x)\n", |
865 | start ? "START" : "STOP", audio_mask, state); | 913 | start ? "START" : "STOP", audio_mask, state); |
866 | if (start) { | 914 | if (start) { |
867 | audio_mask &= ~state; /* start only pipes that are not yet started */ | 915 | /* start only pipes that are not yet started */ |
916 | audio_mask &= ~state; | ||
868 | state = audio_mask; | 917 | state = audio_mask; |
869 | for (i = 0; i < MAX_WAIT_FOR_DSP; i++) { | 918 | for (i = 0; i < MAX_WAIT_FOR_DSP; i++) { |
870 | err = pcxhr_prepair_pipe_start(mgr, state, &state); | 919 | err = pcxhr_prepair_pipe_start(mgr, state, &state); |
871 | if (err) | 920 | if (err) |
872 | return err; | 921 | return err; |
873 | if (state == 0) | 922 | if (state == 0) |
874 | break; /* success, all pipes prepaired for start */ | 923 | break; /* success, all pipes prepaired */ |
875 | mdelay(1); /* otherwise wait 1 millisecond and retry */ | 924 | mdelay(1); /* wait 1 millisecond and retry */ |
876 | } | 925 | } |
877 | } else { | 926 | } else { |
878 | audio_mask &= state; /* stop only pipes that are started */ | 927 | audio_mask &= state; /* stop only pipes that are started */ |
@@ -891,7 +940,7 @@ int pcxhr_set_pipe_state(struct pcxhr_mgr *mgr, int playback_mask, int capture_m | |||
891 | if ((state & audio_mask) == (start ? audio_mask : 0)) | 940 | if ((state & audio_mask) == (start ? audio_mask : 0)) |
892 | break; | 941 | break; |
893 | if (++i >= MAX_WAIT_FOR_DSP * 100) { | 942 | if (++i >= MAX_WAIT_FOR_DSP * 100) { |
894 | snd_printk(KERN_ERR "error pipe start/stop (ED_NO_RESPONSE_AT_IRQA)\n"); | 943 | snd_printk(KERN_ERR "error pipe start/stop\n"); |
895 | return -EBUSY; | 944 | return -EBUSY; |
896 | } | 945 | } |
897 | udelay(10); /* wait 10 microseconds */ | 946 | udelay(10); /* wait 10 microseconds */ |
@@ -918,7 +967,8 @@ int pcxhr_write_io_num_reg_cont(struct pcxhr_mgr *mgr, unsigned int mask, | |||
918 | 967 | ||
919 | spin_lock_irqsave(&mgr->msg_lock, flags); | 968 | spin_lock_irqsave(&mgr->msg_lock, flags); |
920 | if ((mgr->io_num_reg_cont & mask) == value) { | 969 | if ((mgr->io_num_reg_cont & mask) == value) { |
921 | snd_printdd("IO_NUM_REG_CONT mask %x already is set to %x\n", mask, value); | 970 | snd_printdd("IO_NUM_REG_CONT mask %x already is set to %x\n", |
971 | mask, value); | ||
922 | if (changed) | 972 | if (changed) |
923 | *changed = 0; | 973 | *changed = 0; |
924 | spin_unlock_irqrestore(&mgr->msg_lock, flags); | 974 | spin_unlock_irqrestore(&mgr->msg_lock, flags); |
@@ -971,7 +1021,8 @@ static int pcxhr_handle_async_err(struct pcxhr_mgr *mgr, u32 err, | |||
971 | err = ((err >> 12) & 0xfff); | 1021 | err = ((err >> 12) & 0xfff); |
972 | if (!err) | 1022 | if (!err) |
973 | return 0; | 1023 | return 0; |
974 | snd_printdd("CMD_ASYNC : Error %s %s Pipe %d err=%x\n", err_src_name[err_src], | 1024 | snd_printdd("CMD_ASYNC : Error %s %s Pipe %d err=%x\n", |
1025 | err_src_name[err_src], | ||
975 | is_capture ? "Record" : "Play", pipe, err); | 1026 | is_capture ? "Record" : "Play", pipe, err); |
976 | if (err == 0xe01) | 1027 | if (err == 0xe01) |
977 | mgr->async_err_stream_xrun++; | 1028 | mgr->async_err_stream_xrun++; |
@@ -996,6 +1047,13 @@ void pcxhr_msg_tasklet(unsigned long arg) | |||
996 | snd_printdd("TASKLET : PCXHR_IRQ_TIME_CODE event occured\n"); | 1047 | snd_printdd("TASKLET : PCXHR_IRQ_TIME_CODE event occured\n"); |
997 | if (mgr->src_it_dsp & PCXHR_IRQ_NOTIFY) | 1048 | if (mgr->src_it_dsp & PCXHR_IRQ_NOTIFY) |
998 | snd_printdd("TASKLET : PCXHR_IRQ_NOTIFY event occured\n"); | 1049 | snd_printdd("TASKLET : PCXHR_IRQ_NOTIFY event occured\n"); |
1050 | if (mgr->src_it_dsp & (PCXHR_IRQ_FREQ_CHANGE | PCXHR_IRQ_TIME_CODE)) { | ||
1051 | /* clear events FREQ_CHANGE and TIME_CODE */ | ||
1052 | pcxhr_init_rmh(prmh, CMD_TEST_IT); | ||
1053 | err = pcxhr_send_msg(mgr, prmh); | ||
1054 | snd_printdd("CMD_TEST_IT : err=%x, stat=%x\n", | ||
1055 | err, prmh->stat[0]); | ||
1056 | } | ||
999 | if (mgr->src_it_dsp & PCXHR_IRQ_ASYNC) { | 1057 | if (mgr->src_it_dsp & PCXHR_IRQ_ASYNC) { |
1000 | snd_printdd("TASKLET : PCXHR_IRQ_ASYNC event occured\n"); | 1058 | snd_printdd("TASKLET : PCXHR_IRQ_ASYNC event occured\n"); |
1001 | 1059 | ||
@@ -1005,18 +1063,22 @@ void pcxhr_msg_tasklet(unsigned long arg) | |||
1005 | prmh->stat_len = PCXHR_SIZE_MAX_LONG_STATUS; | 1063 | prmh->stat_len = PCXHR_SIZE_MAX_LONG_STATUS; |
1006 | err = pcxhr_send_msg(mgr, prmh); | 1064 | err = pcxhr_send_msg(mgr, prmh); |
1007 | if (err) | 1065 | if (err) |
1008 | snd_printk(KERN_ERR "ERROR pcxhr_msg_tasklet=%x;\n", err); | 1066 | snd_printk(KERN_ERR "ERROR pcxhr_msg_tasklet=%x;\n", |
1067 | err); | ||
1009 | i = 1; | 1068 | i = 1; |
1010 | while (i < prmh->stat_len) { | 1069 | while (i < prmh->stat_len) { |
1011 | int nb_audio = (prmh->stat[i] >> FIELD_SIZE) & MASK_FIRST_FIELD; | 1070 | int nb_audio = ((prmh->stat[i] >> FIELD_SIZE) & |
1012 | int nb_stream = (prmh->stat[i] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD; | 1071 | MASK_FIRST_FIELD); |
1072 | int nb_stream = ((prmh->stat[i] >> (2*FIELD_SIZE)) & | ||
1073 | MASK_FIRST_FIELD); | ||
1013 | int pipe = prmh->stat[i] & MASK_FIRST_FIELD; | 1074 | int pipe = prmh->stat[i] & MASK_FIRST_FIELD; |
1014 | int is_capture = prmh->stat[i] & 0x400000; | 1075 | int is_capture = prmh->stat[i] & 0x400000; |
1015 | u32 err2; | 1076 | u32 err2; |
1016 | 1077 | ||
1017 | if (prmh->stat[i] & 0x800000) { /* if BIT_END */ | 1078 | if (prmh->stat[i] & 0x800000) { /* if BIT_END */ |
1018 | snd_printdd("TASKLET : End%sPipe %d\n", | 1079 | snd_printdd("TASKLET : End%sPipe %d\n", |
1019 | is_capture ? "Record" : "Play", pipe); | 1080 | is_capture ? "Record" : "Play", |
1081 | pipe); | ||
1020 | } | 1082 | } |
1021 | i++; | 1083 | i++; |
1022 | err2 = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1]; | 1084 | err2 = prmh->stat[i] ? prmh->stat[i] : prmh->stat[i+1]; |
@@ -1062,7 +1124,7 @@ static u_int64_t pcxhr_stream_read_position(struct pcxhr_mgr *mgr, | |||
1062 | pcxhr_init_rmh(&rmh, CMD_STREAM_SAMPLE_COUNT); | 1124 | pcxhr_init_rmh(&rmh, CMD_STREAM_SAMPLE_COUNT); |
1063 | pcxhr_set_pipe_cmd_params(&rmh, stream->pipe->is_capture, | 1125 | pcxhr_set_pipe_cmd_params(&rmh, stream->pipe->is_capture, |
1064 | stream->pipe->first_audio, 0, stream_mask); | 1126 | stream->pipe->first_audio, 0, stream_mask); |
1065 | /* rmh.stat_len = 2; */ /* 2 resp data for each stream of the pipe */ | 1127 | /* rmh.stat_len = 2; */ /* 2 resp data for each stream of the pipe */ |
1066 | 1128 | ||
1067 | err = pcxhr_send_msg(mgr, &rmh); | 1129 | err = pcxhr_send_msg(mgr, &rmh); |
1068 | if (err) | 1130 | if (err) |
@@ -1072,18 +1134,21 @@ static u_int64_t pcxhr_stream_read_position(struct pcxhr_mgr *mgr, | |||
1072 | hw_sample_count += (u_int64_t)rmh.stat[1]; | 1134 | hw_sample_count += (u_int64_t)rmh.stat[1]; |
1073 | 1135 | ||
1074 | snd_printdd("stream %c%d : abs samples real(%ld) timer(%ld)\n", | 1136 | snd_printdd("stream %c%d : abs samples real(%ld) timer(%ld)\n", |
1075 | stream->pipe->is_capture ? 'C':'P', stream->substream->number, | 1137 | stream->pipe->is_capture ? 'C' : 'P', |
1138 | stream->substream->number, | ||
1076 | (long unsigned int)hw_sample_count, | 1139 | (long unsigned int)hw_sample_count, |
1077 | (long unsigned int)(stream->timer_abs_periods + | 1140 | (long unsigned int)(stream->timer_abs_periods + |
1078 | stream->timer_period_frag + PCXHR_GRANULARITY)); | 1141 | stream->timer_period_frag + |
1079 | 1142 | mgr->granularity)); | |
1080 | return hw_sample_count; | 1143 | return hw_sample_count; |
1081 | } | 1144 | } |
1082 | 1145 | ||
1083 | static void pcxhr_update_timer_pos(struct pcxhr_mgr *mgr, | 1146 | static void pcxhr_update_timer_pos(struct pcxhr_mgr *mgr, |
1084 | struct pcxhr_stream *stream, int samples_to_add) | 1147 | struct pcxhr_stream *stream, |
1148 | int samples_to_add) | ||
1085 | { | 1149 | { |
1086 | if (stream->substream && (stream->status == PCXHR_STREAM_STATUS_RUNNING)) { | 1150 | if (stream->substream && |
1151 | (stream->status == PCXHR_STREAM_STATUS_RUNNING)) { | ||
1087 | u_int64_t new_sample_count; | 1152 | u_int64_t new_sample_count; |
1088 | int elapsed = 0; | 1153 | int elapsed = 0; |
1089 | int hardware_read = 0; | 1154 | int hardware_read = 0; |
@@ -1092,20 +1157,22 @@ static void pcxhr_update_timer_pos(struct pcxhr_mgr *mgr, | |||
1092 | if (samples_to_add < 0) { | 1157 | if (samples_to_add < 0) { |
1093 | stream->timer_is_synced = 0; | 1158 | stream->timer_is_synced = 0; |
1094 | /* add default if no hardware_read possible */ | 1159 | /* add default if no hardware_read possible */ |
1095 | samples_to_add = PCXHR_GRANULARITY; | 1160 | samples_to_add = mgr->granularity; |
1096 | } | 1161 | } |
1097 | 1162 | ||
1098 | if (!stream->timer_is_synced) { | 1163 | if (!stream->timer_is_synced) { |
1099 | if (stream->timer_abs_periods != 0 || | 1164 | if ((stream->timer_abs_periods != 0) || |
1100 | stream->timer_period_frag + PCXHR_GRANULARITY >= | 1165 | ((stream->timer_period_frag + samples_to_add) >= |
1101 | runtime->period_size) { | 1166 | runtime->period_size)) { |
1102 | new_sample_count = pcxhr_stream_read_position(mgr, stream); | 1167 | new_sample_count = |
1168 | pcxhr_stream_read_position(mgr, stream); | ||
1103 | hardware_read = 1; | 1169 | hardware_read = 1; |
1104 | if (new_sample_count >= PCXHR_GRANULARITY_MIN) { | 1170 | if (new_sample_count >= mgr->granularity) { |
1105 | /* sub security offset because of jitter and | 1171 | /* sub security offset because of |
1106 | * finer granularity of dsp time (MBOX4) | 1172 | * jitter and finer granularity of |
1173 | * dsp time (MBOX4) | ||
1107 | */ | 1174 | */ |
1108 | new_sample_count -= PCXHR_GRANULARITY_MIN; | 1175 | new_sample_count -= mgr->granularity; |
1109 | stream->timer_is_synced = 1; | 1176 | stream->timer_is_synced = 1; |
1110 | } | 1177 | } |
1111 | } | 1178 | } |
@@ -1128,12 +1195,15 @@ static void pcxhr_update_timer_pos(struct pcxhr_mgr *mgr, | |||
1128 | stream->timer_buf_periods = 0; | 1195 | stream->timer_buf_periods = 0; |
1129 | stream->timer_abs_periods = new_elapse_pos; | 1196 | stream->timer_abs_periods = new_elapse_pos; |
1130 | } | 1197 | } |
1131 | if (new_sample_count >= stream->timer_abs_periods) | 1198 | if (new_sample_count >= stream->timer_abs_periods) { |
1132 | stream->timer_period_frag = (u_int32_t)(new_sample_count - | 1199 | stream->timer_period_frag = |
1133 | stream->timer_abs_periods); | 1200 | (u_int32_t)(new_sample_count - |
1134 | else | 1201 | stream->timer_abs_periods); |
1135 | snd_printk(KERN_ERR "ERROR new_sample_count too small ??? %lx\n", | 1202 | } else { |
1203 | snd_printk(KERN_ERR | ||
1204 | "ERROR new_sample_count too small ??? %ld\n", | ||
1136 | (long unsigned int)new_sample_count); | 1205 | (long unsigned int)new_sample_count); |
1206 | } | ||
1137 | 1207 | ||
1138 | if (elapsed) { | 1208 | if (elapsed) { |
1139 | spin_unlock(&mgr->lock); | 1209 | spin_unlock(&mgr->lock); |
@@ -1143,7 +1213,6 @@ static void pcxhr_update_timer_pos(struct pcxhr_mgr *mgr, | |||
1143 | } | 1213 | } |
1144 | } | 1214 | } |
1145 | 1215 | ||
1146 | |||
1147 | irqreturn_t pcxhr_interrupt(int irq, void *dev_id) | 1216 | irqreturn_t pcxhr_interrupt(int irq, void *dev_id) |
1148 | { | 1217 | { |
1149 | struct pcxhr_mgr *mgr = dev_id; | 1218 | struct pcxhr_mgr *mgr = dev_id; |
@@ -1156,7 +1225,8 @@ irqreturn_t pcxhr_interrupt(int irq, void *dev_id) | |||
1156 | reg = PCXHR_INPL(mgr, PCXHR_PLX_IRQCS); | 1225 | reg = PCXHR_INPL(mgr, PCXHR_PLX_IRQCS); |
1157 | if (! (reg & PCXHR_IRQCS_ACTIVE_PCIDB)) { | 1226 | if (! (reg & PCXHR_IRQCS_ACTIVE_PCIDB)) { |
1158 | spin_unlock(&mgr->lock); | 1227 | spin_unlock(&mgr->lock); |
1159 | return IRQ_NONE; /* this device did not cause the interrupt */ | 1228 | /* this device did not cause the interrupt */ |
1229 | return IRQ_NONE; | ||
1160 | } | 1230 | } |
1161 | 1231 | ||
1162 | /* clear interrupt */ | 1232 | /* clear interrupt */ |
@@ -1167,10 +1237,12 @@ irqreturn_t pcxhr_interrupt(int irq, void *dev_id) | |||
1167 | if (reg & PCXHR_IRQ_TIMER) { | 1237 | if (reg & PCXHR_IRQ_TIMER) { |
1168 | int timer_toggle = reg & PCXHR_IRQ_TIMER; | 1238 | int timer_toggle = reg & PCXHR_IRQ_TIMER; |
1169 | /* is a 24 bit counter */ | 1239 | /* is a 24 bit counter */ |
1170 | int dsp_time_new = PCXHR_INPL(mgr, PCXHR_PLX_MBOX4) & PCXHR_DSP_TIME_MASK; | 1240 | int dsp_time_new = |
1241 | PCXHR_INPL(mgr, PCXHR_PLX_MBOX4) & PCXHR_DSP_TIME_MASK; | ||
1171 | int dsp_time_diff = dsp_time_new - mgr->dsp_time_last; | 1242 | int dsp_time_diff = dsp_time_new - mgr->dsp_time_last; |
1172 | 1243 | ||
1173 | if (dsp_time_diff < 0 && mgr->dsp_time_last != PCXHR_DSP_TIME_INVALID) { | 1244 | if ((dsp_time_diff < 0) && |
1245 | (mgr->dsp_time_last != PCXHR_DSP_TIME_INVALID)) { | ||
1174 | snd_printdd("ERROR DSP TIME old(%d) new(%d) -> " | 1246 | snd_printdd("ERROR DSP TIME old(%d) new(%d) -> " |
1175 | "resynchronize all streams\n", | 1247 | "resynchronize all streams\n", |
1176 | mgr->dsp_time_last, dsp_time_new); | 1248 | mgr->dsp_time_last, dsp_time_new); |
@@ -1178,42 +1250,51 @@ irqreturn_t pcxhr_interrupt(int irq, void *dev_id) | |||
1178 | } | 1250 | } |
1179 | #ifdef CONFIG_SND_DEBUG_VERBOSE | 1251 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
1180 | if (dsp_time_diff == 0) | 1252 | if (dsp_time_diff == 0) |
1181 | snd_printdd("ERROR DSP TIME NO DIFF time(%d)\n", dsp_time_new); | 1253 | snd_printdd("ERROR DSP TIME NO DIFF time(%d)\n", |
1182 | else if (dsp_time_diff >= (2*PCXHR_GRANULARITY)) | 1254 | dsp_time_new); |
1255 | else if (dsp_time_diff >= (2*mgr->granularity)) | ||
1183 | snd_printdd("ERROR DSP TIME TOO BIG old(%d) add(%d)\n", | 1256 | snd_printdd("ERROR DSP TIME TOO BIG old(%d) add(%d)\n", |
1184 | mgr->dsp_time_last, dsp_time_new - mgr->dsp_time_last); | 1257 | mgr->dsp_time_last, |
1258 | dsp_time_new - mgr->dsp_time_last); | ||
1259 | else if (dsp_time_diff % mgr->granularity) | ||
1260 | snd_printdd("ERROR DSP TIME increased by %d\n", | ||
1261 | dsp_time_diff); | ||
1185 | #endif | 1262 | #endif |
1186 | mgr->dsp_time_last = dsp_time_new; | 1263 | mgr->dsp_time_last = dsp_time_new; |
1187 | 1264 | ||
1188 | if (timer_toggle == mgr->timer_toggle) | 1265 | if (timer_toggle == mgr->timer_toggle) { |
1189 | snd_printdd("ERROR TIMER TOGGLE\n"); | 1266 | snd_printdd("ERROR TIMER TOGGLE\n"); |
1267 | mgr->dsp_time_err++; | ||
1268 | } | ||
1190 | mgr->timer_toggle = timer_toggle; | 1269 | mgr->timer_toggle = timer_toggle; |
1191 | 1270 | ||
1192 | reg &= ~PCXHR_IRQ_TIMER; | 1271 | reg &= ~PCXHR_IRQ_TIMER; |
1193 | for (i = 0; i < mgr->num_cards; i++) { | 1272 | for (i = 0; i < mgr->num_cards; i++) { |
1194 | chip = mgr->chip[i]; | 1273 | chip = mgr->chip[i]; |
1195 | for (j = 0; j < chip->nb_streams_capt; j++) | 1274 | for (j = 0; j < chip->nb_streams_capt; j++) |
1196 | pcxhr_update_timer_pos(mgr, &chip->capture_stream[j], | 1275 | pcxhr_update_timer_pos(mgr, |
1197 | dsp_time_diff); | 1276 | &chip->capture_stream[j], |
1277 | dsp_time_diff); | ||
1198 | } | 1278 | } |
1199 | for (i = 0; i < mgr->num_cards; i++) { | 1279 | for (i = 0; i < mgr->num_cards; i++) { |
1200 | chip = mgr->chip[i]; | 1280 | chip = mgr->chip[i]; |
1201 | for (j = 0; j < chip->nb_streams_play; j++) | 1281 | for (j = 0; j < chip->nb_streams_play; j++) |
1202 | pcxhr_update_timer_pos(mgr, &chip->playback_stream[j], | 1282 | pcxhr_update_timer_pos(mgr, |
1203 | dsp_time_diff); | 1283 | &chip->playback_stream[j], |
1284 | dsp_time_diff); | ||
1204 | } | 1285 | } |
1205 | } | 1286 | } |
1206 | /* other irq's handled in the tasklet */ | 1287 | /* other irq's handled in the tasklet */ |
1207 | if (reg & PCXHR_IRQ_MASK) { | 1288 | if (reg & PCXHR_IRQ_MASK) { |
1208 | 1289 | if (reg & PCXHR_IRQ_ASYNC) { | |
1209 | /* as we didn't request any notifications, some kind of xrun error | 1290 | /* as we didn't request any async notifications, |
1210 | * will probably occured | 1291 | * some kind of xrun error will probably occured |
1211 | */ | 1292 | */ |
1212 | /* better resynchronize all streams next interrupt : */ | 1293 | /* better resynchronize all streams next interrupt : */ |
1213 | mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID; | 1294 | mgr->dsp_time_last = PCXHR_DSP_TIME_INVALID; |
1214 | 1295 | } | |
1215 | mgr->src_it_dsp = reg; | 1296 | mgr->src_it_dsp = reg; |
1216 | tasklet_hi_schedule(&mgr->msg_taskq); | 1297 | tasklet_schedule(&mgr->msg_taskq); |
1217 | } | 1298 | } |
1218 | #ifdef CONFIG_SND_DEBUG_VERBOSE | 1299 | #ifdef CONFIG_SND_DEBUG_VERBOSE |
1219 | if (reg & PCXHR_FATAL_DSP_ERR) | 1300 | if (reg & PCXHR_FATAL_DSP_ERR) |
diff --git a/sound/pci/pcxhr/pcxhr_core.h b/sound/pci/pcxhr/pcxhr_core.h index d9a4ab609875..bbbd66d13a64 100644 --- a/sound/pci/pcxhr/pcxhr_core.h +++ b/sound/pci/pcxhr/pcxhr_core.h | |||
@@ -65,7 +65,7 @@ enum { | |||
65 | CMD_RESYNC_AUDIO_INPUTS, /* cmd_len = 1 stat_len = 0 */ | 65 | CMD_RESYNC_AUDIO_INPUTS, /* cmd_len = 1 stat_len = 0 */ |
66 | CMD_GET_DSP_RESOURCES, /* cmd_len = 1 stat_len = 4 */ | 66 | CMD_GET_DSP_RESOURCES, /* cmd_len = 1 stat_len = 4 */ |
67 | CMD_SET_TIMER_INTERRUPT, /* cmd_len = 1 stat_len = 0 */ | 67 | CMD_SET_TIMER_INTERRUPT, /* cmd_len = 1 stat_len = 0 */ |
68 | CMD_RES_PIPE, /* cmd_len = 2 stat_len = 0 */ | 68 | CMD_RES_PIPE, /* cmd_len >=2 stat_len = 0 */ |
69 | CMD_FREE_PIPE, /* cmd_len = 1 stat_len = 0 */ | 69 | CMD_FREE_PIPE, /* cmd_len = 1 stat_len = 0 */ |
70 | CMD_CONF_PIPE, /* cmd_len = 2 stat_len = 0 */ | 70 | CMD_CONF_PIPE, /* cmd_len = 2 stat_len = 0 */ |
71 | CMD_STOP_PIPE, /* cmd_len = 1 stat_len = 0 */ | 71 | CMD_STOP_PIPE, /* cmd_len = 1 stat_len = 0 */ |
@@ -96,6 +96,8 @@ void pcxhr_init_rmh(struct pcxhr_rmh *rmh, int cmd); | |||
96 | void pcxhr_set_pipe_cmd_params(struct pcxhr_rmh* rmh, int capture, unsigned int param1, | 96 | void pcxhr_set_pipe_cmd_params(struct pcxhr_rmh* rmh, int capture, unsigned int param1, |
97 | unsigned int param2, unsigned int param3); | 97 | unsigned int param2, unsigned int param3); |
98 | 98 | ||
99 | #define DSP_EXT_CMD_SET(x) (x->dsp_version > 0x012800) | ||
100 | |||
99 | /* | 101 | /* |
100 | send the rmh | 102 | send the rmh |
101 | */ | 103 | */ |
@@ -110,6 +112,7 @@ int pcxhr_send_msg(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh); | |||
110 | #define IO_NUM_REG_STATUS 5 | 112 | #define IO_NUM_REG_STATUS 5 |
111 | #define IO_NUM_REG_CUER 10 | 113 | #define IO_NUM_REG_CUER 10 |
112 | #define IO_NUM_UER_CHIP_REG 11 | 114 | #define IO_NUM_UER_CHIP_REG 11 |
115 | #define IO_NUM_REG_CONFIG_SRC 12 | ||
113 | #define IO_NUM_REG_OUT_ANA_LEVEL 20 | 116 | #define IO_NUM_REG_OUT_ANA_LEVEL 20 |
114 | #define IO_NUM_REG_IN_ANA_LEVEL 21 | 117 | #define IO_NUM_REG_IN_ANA_LEVEL 21 |
115 | 118 | ||
diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c index 96640d9c227d..592743a298b0 100644 --- a/sound/pci/pcxhr/pcxhr_hwdep.c +++ b/sound/pci/pcxhr/pcxhr_hwdep.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "pcxhr_mixer.h" | 31 | #include "pcxhr_mixer.h" |
32 | #include "pcxhr_hwdep.h" | 32 | #include "pcxhr_hwdep.h" |
33 | #include "pcxhr_core.h" | 33 | #include "pcxhr_core.h" |
34 | #include "pcxhr_mix22.h" | ||
34 | 35 | ||
35 | 36 | ||
36 | #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) | 37 | #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) |
@@ -40,10 +41,10 @@ | |||
40 | #endif | 41 | #endif |
41 | 42 | ||
42 | 43 | ||
44 | static int pcxhr_sub_init(struct pcxhr_mgr *mgr); | ||
43 | /* | 45 | /* |
44 | * get basic information and init pcxhr card | 46 | * get basic information and init pcxhr card |
45 | */ | 47 | */ |
46 | |||
47 | static int pcxhr_init_board(struct pcxhr_mgr *mgr) | 48 | static int pcxhr_init_board(struct pcxhr_mgr *mgr) |
48 | { | 49 | { |
49 | int err; | 50 | int err; |
@@ -68,7 +69,7 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr) | |||
68 | if ((rmh.stat[0] & MASK_FIRST_FIELD) != mgr->playback_chips * 2) | 69 | if ((rmh.stat[0] & MASK_FIRST_FIELD) != mgr->playback_chips * 2) |
69 | return -EINVAL; | 70 | return -EINVAL; |
70 | /* test 8 or 2 phys in */ | 71 | /* test 8 or 2 phys in */ |
71 | if (((rmh.stat[0] >> (2 * FIELD_SIZE)) & MASK_FIRST_FIELD) != | 72 | if (((rmh.stat[0] >> (2 * FIELD_SIZE)) & MASK_FIRST_FIELD) < |
72 | mgr->capture_chips * 2) | 73 | mgr->capture_chips * 2) |
73 | return -EINVAL; | 74 | return -EINVAL; |
74 | /* test max nb substream per board */ | 75 | /* test max nb substream per board */ |
@@ -77,20 +78,34 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr) | |||
77 | /* test max nb substream per pipe */ | 78 | /* test max nb substream per pipe */ |
78 | if (((rmh.stat[1] >> 7) & 0x5F) < PCXHR_PLAYBACK_STREAMS) | 79 | if (((rmh.stat[1] >> 7) & 0x5F) < PCXHR_PLAYBACK_STREAMS) |
79 | return -EINVAL; | 80 | return -EINVAL; |
81 | snd_printdd("supported formats : playback=%x capture=%x\n", | ||
82 | rmh.stat[2], rmh.stat[3]); | ||
80 | 83 | ||
81 | pcxhr_init_rmh(&rmh, CMD_VERSION); | 84 | pcxhr_init_rmh(&rmh, CMD_VERSION); |
82 | /* firmware num for DSP */ | 85 | /* firmware num for DSP */ |
83 | rmh.cmd[0] |= mgr->firmware_num; | 86 | rmh.cmd[0] |= mgr->firmware_num; |
84 | /* transfer granularity in samples (should be multiple of 48) */ | 87 | /* transfer granularity in samples (should be multiple of 48) */ |
85 | rmh.cmd[1] = (1<<23) + PCXHR_GRANULARITY; | 88 | rmh.cmd[1] = (1<<23) + mgr->granularity; |
86 | rmh.cmd_len = 2; | 89 | rmh.cmd_len = 2; |
87 | err = pcxhr_send_msg(mgr, &rmh); | 90 | err = pcxhr_send_msg(mgr, &rmh); |
88 | if (err) | 91 | if (err) |
89 | return err; | 92 | return err; |
90 | snd_printdd("PCXHR DSP version is %d.%d.%d\n", | 93 | snd_printdd("PCXHR DSP version is %d.%d.%d\n", (rmh.stat[0]>>16)&0xff, |
91 | (rmh.stat[0]>>16)&0xff, (rmh.stat[0]>>8)&0xff, rmh.stat[0]&0xff); | 94 | (rmh.stat[0]>>8)&0xff, rmh.stat[0]&0xff); |
92 | mgr->dsp_version = rmh.stat[0]; | 95 | mgr->dsp_version = rmh.stat[0]; |
93 | 96 | ||
97 | if (mgr->is_hr_stereo) | ||
98 | err = hr222_sub_init(mgr); | ||
99 | else | ||
100 | err = pcxhr_sub_init(mgr); | ||
101 | return err; | ||
102 | } | ||
103 | |||
104 | static int pcxhr_sub_init(struct pcxhr_mgr *mgr) | ||
105 | { | ||
106 | int err; | ||
107 | struct pcxhr_rmh rmh; | ||
108 | |||
94 | /* get options */ | 109 | /* get options */ |
95 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); | 110 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); |
96 | rmh.cmd[0] |= IO_NUM_REG_STATUS; | 111 | rmh.cmd[0] |= IO_NUM_REG_STATUS; |
@@ -100,20 +115,22 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr) | |||
100 | if (err) | 115 | if (err) |
101 | return err; | 116 | return err; |
102 | 117 | ||
103 | if ((rmh.stat[1] & REG_STATUS_OPT_DAUGHTER_MASK) == REG_STATUS_OPT_ANALOG_BOARD) | 118 | if ((rmh.stat[1] & REG_STATUS_OPT_DAUGHTER_MASK) == |
104 | mgr->board_has_analog = 1; /* analog addon board available */ | 119 | REG_STATUS_OPT_ANALOG_BOARD) |
105 | else | 120 | mgr->board_has_analog = 1; /* analog addon board found */ |
106 | /* analog addon board not available -> no support for instance */ | ||
107 | return -EINVAL; | ||
108 | 121 | ||
109 | /* unmute inputs */ | 122 | /* unmute inputs */ |
110 | err = pcxhr_write_io_num_reg_cont(mgr, REG_CONT_UNMUTE_INPUTS, | 123 | err = pcxhr_write_io_num_reg_cont(mgr, REG_CONT_UNMUTE_INPUTS, |
111 | REG_CONT_UNMUTE_INPUTS, NULL); | 124 | REG_CONT_UNMUTE_INPUTS, NULL); |
112 | if (err) | 125 | if (err) |
113 | return err; | 126 | return err; |
114 | /* unmute outputs */ | 127 | /* unmute outputs (a write to IO_NUM_REG_MUTE_OUT mutes!) */ |
115 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); /* a write to IO_NUM_REG_MUTE_OUT mutes! */ | 128 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); |
116 | rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; | 129 | rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; |
130 | if (DSP_EXT_CMD_SET(mgr)) { | ||
131 | rmh.cmd[1] = 1; /* unmute digital plugs */ | ||
132 | rmh.cmd_len = 2; | ||
133 | } | ||
117 | err = pcxhr_send_msg(mgr, &rmh); | 134 | err = pcxhr_send_msg(mgr, &rmh); |
118 | return err; | 135 | return err; |
119 | } | 136 | } |
@@ -124,19 +141,25 @@ void pcxhr_reset_board(struct pcxhr_mgr *mgr) | |||
124 | 141 | ||
125 | if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { | 142 | if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) { |
126 | /* mute outputs */ | 143 | /* mute outputs */ |
144 | if (!mgr->is_hr_stereo) { | ||
127 | /* a read to IO_NUM_REG_MUTE_OUT register unmutes! */ | 145 | /* a read to IO_NUM_REG_MUTE_OUT register unmutes! */ |
128 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); | 146 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); |
129 | rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; | 147 | rmh.cmd[0] |= IO_NUM_REG_MUTE_OUT; |
130 | pcxhr_send_msg(mgr, &rmh); | 148 | pcxhr_send_msg(mgr, &rmh); |
131 | /* mute inputs */ | 149 | /* mute inputs */ |
132 | pcxhr_write_io_num_reg_cont(mgr, REG_CONT_UNMUTE_INPUTS, 0, NULL); | 150 | pcxhr_write_io_num_reg_cont(mgr, REG_CONT_UNMUTE_INPUTS, |
151 | 0, NULL); | ||
152 | } | ||
153 | /* stereo cards mute with reset of dsp */ | ||
133 | } | 154 | } |
134 | /* reset pcxhr dsp */ | 155 | /* reset pcxhr dsp */ |
135 | if (mgr->dsp_loaded & ( 1 << PCXHR_FIRMWARE_DSP_EPRM_INDEX)) | 156 | if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_EPRM_INDEX)) |
136 | pcxhr_reset_dsp(mgr); | 157 | pcxhr_reset_dsp(mgr); |
137 | /* reset second xilinx */ | 158 | /* reset second xilinx */ |
138 | if (mgr->dsp_loaded & ( 1 << PCXHR_FIRMWARE_XLX_COM_INDEX)) | 159 | if (mgr->dsp_loaded & (1 << PCXHR_FIRMWARE_XLX_COM_INDEX)) { |
139 | pcxhr_reset_xilinx_com(mgr); | 160 | pcxhr_reset_xilinx_com(mgr); |
161 | mgr->dsp_loaded = 1; | ||
162 | } | ||
140 | return; | 163 | return; |
141 | } | 164 | } |
142 | 165 | ||
@@ -144,8 +167,9 @@ void pcxhr_reset_board(struct pcxhr_mgr *mgr) | |||
144 | /* | 167 | /* |
145 | * allocate a playback/capture pipe (pcmp0/pcmc0) | 168 | * allocate a playback/capture pipe (pcmp0/pcmc0) |
146 | */ | 169 | */ |
147 | static int pcxhr_dsp_allocate_pipe( struct pcxhr_mgr *mgr, struct pcxhr_pipe *pipe, | 170 | static int pcxhr_dsp_allocate_pipe(struct pcxhr_mgr *mgr, |
148 | int is_capture, int pin) | 171 | struct pcxhr_pipe *pipe, |
172 | int is_capture, int pin) | ||
149 | { | 173 | { |
150 | int stream_count, audio_count; | 174 | int stream_count, audio_count; |
151 | int err; | 175 | int err; |
@@ -161,15 +185,23 @@ static int pcxhr_dsp_allocate_pipe( struct pcxhr_mgr *mgr, struct pcxhr_pipe *pi | |||
161 | stream_count = PCXHR_PLAYBACK_STREAMS; | 185 | stream_count = PCXHR_PLAYBACK_STREAMS; |
162 | audio_count = 2; /* always stereo */ | 186 | audio_count = 2; /* always stereo */ |
163 | } | 187 | } |
164 | snd_printdd("snd_add_ref_pipe pin(%d) pcm%c0\n", pin, is_capture ? 'c' : 'p'); | 188 | snd_printdd("snd_add_ref_pipe pin(%d) pcm%c0\n", |
189 | pin, is_capture ? 'c' : 'p'); | ||
165 | pipe->is_capture = is_capture; | 190 | pipe->is_capture = is_capture; |
166 | pipe->first_audio = pin; | 191 | pipe->first_audio = pin; |
167 | /* define pipe (P_PCM_ONLY_MASK (0x020000) is not necessary) */ | 192 | /* define pipe (P_PCM_ONLY_MASK (0x020000) is not necessary) */ |
168 | pcxhr_init_rmh(&rmh, CMD_RES_PIPE); | 193 | pcxhr_init_rmh(&rmh, CMD_RES_PIPE); |
169 | pcxhr_set_pipe_cmd_params(&rmh, is_capture, pin, audio_count, stream_count); | 194 | pcxhr_set_pipe_cmd_params(&rmh, is_capture, pin, |
195 | audio_count, stream_count); | ||
196 | rmh.cmd[1] |= 0x020000; /* add P_PCM_ONLY_MASK */ | ||
197 | if (DSP_EXT_CMD_SET(mgr)) { | ||
198 | /* add channel mask to command */ | ||
199 | rmh.cmd[rmh.cmd_len++] = (audio_count == 1) ? 0x01 : 0x03; | ||
200 | } | ||
170 | err = pcxhr_send_msg(mgr, &rmh); | 201 | err = pcxhr_send_msg(mgr, &rmh); |
171 | if (err < 0) { | 202 | if (err < 0) { |
172 | snd_printk(KERN_ERR "error pipe allocation (CMD_RES_PIPE) err=%x!\n", err ); | 203 | snd_printk(KERN_ERR "error pipe allocation " |
204 | "(CMD_RES_PIPE) err=%x!\n", err); | ||
173 | return err; | 205 | return err; |
174 | } | 206 | } |
175 | pipe->status = PCXHR_PIPE_DEFINED; | 207 | pipe->status = PCXHR_PIPE_DEFINED; |
@@ -199,10 +231,12 @@ static int pcxhr_dsp_free_pipe( struct pcxhr_mgr *mgr, struct pcxhr_pipe *pipe) | |||
199 | snd_printk(KERN_ERR "error stopping pipe!\n"); | 231 | snd_printk(KERN_ERR "error stopping pipe!\n"); |
200 | /* release the pipe */ | 232 | /* release the pipe */ |
201 | pcxhr_init_rmh(&rmh, CMD_FREE_PIPE); | 233 | pcxhr_init_rmh(&rmh, CMD_FREE_PIPE); |
202 | pcxhr_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->first_audio, 0, 0); | 234 | pcxhr_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->first_audio, |
235 | 0, 0); | ||
203 | err = pcxhr_send_msg(mgr, &rmh); | 236 | err = pcxhr_send_msg(mgr, &rmh); |
204 | if (err < 0) | 237 | if (err < 0) |
205 | snd_printk(KERN_ERR "error pipe release (CMD_FREE_PIPE) err(%x)\n", err); | 238 | snd_printk(KERN_ERR "error pipe release " |
239 | "(CMD_FREE_PIPE) err(%x)\n", err); | ||
206 | pipe->status = PCXHR_PIPE_UNDEFINED; | 240 | pipe->status = PCXHR_PIPE_UNDEFINED; |
207 | return err; | 241 | return err; |
208 | } | 242 | } |
@@ -248,15 +282,16 @@ static int pcxhr_start_pipes(struct pcxhr_mgr *mgr) | |||
248 | for (i = 0; i < mgr->num_cards; i++) { | 282 | for (i = 0; i < mgr->num_cards; i++) { |
249 | chip = mgr->chip[i]; | 283 | chip = mgr->chip[i]; |
250 | if (chip->nb_streams_play) | 284 | if (chip->nb_streams_play) |
251 | playback_mask |= (1 << chip->playback_pipe.first_audio); | 285 | playback_mask |= 1 << chip->playback_pipe.first_audio; |
252 | for (j = 0; j < chip->nb_streams_capt; j++) | 286 | for (j = 0; j < chip->nb_streams_capt; j++) |
253 | capture_mask |= (1 << chip->capture_pipe[j].first_audio); | 287 | capture_mask |= 1 << chip->capture_pipe[j].first_audio; |
254 | } | 288 | } |
255 | return pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1); | 289 | return pcxhr_set_pipe_state(mgr, playback_mask, capture_mask, 1); |
256 | } | 290 | } |
257 | 291 | ||
258 | 292 | ||
259 | static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index, const struct firmware *dsp) | 293 | static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index, |
294 | const struct firmware *dsp) | ||
260 | { | 295 | { |
261 | int err, card_index; | 296 | int err, card_index; |
262 | 297 | ||
@@ -330,22 +365,33 @@ static int pcxhr_dsp_load(struct pcxhr_mgr *mgr, int index, const struct firmwar | |||
330 | 365 | ||
331 | int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) | 366 | int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) |
332 | { | 367 | { |
333 | static char *fw_files[5] = { | 368 | static char *fw_files[][5] = { |
334 | "xi_1_882.dat", | 369 | [0] = { "xlxint.dat", "xlxc882hr.dat", |
335 | "xc_1_882.dat", | 370 | "dspe882.e56", "dspb882hr.b56", "dspd882.d56" }, |
336 | "e321_512.e56", | 371 | [1] = { "xlxint.dat", "xlxc882e.dat", |
337 | "b321_512.b56", | 372 | "dspe882.e56", "dspb882e.b56", "dspd882.d56" }, |
338 | "d321_512.d56" | 373 | [2] = { "xlxint.dat", "xlxc1222hr.dat", |
374 | "dspe882.e56", "dspb1222hr.b56", "dspd1222.d56" }, | ||
375 | [3] = { "xlxint.dat", "xlxc1222e.dat", | ||
376 | "dspe882.e56", "dspb1222e.b56", "dspd1222.d56" }, | ||
377 | [4] = { NULL, "xlxc222.dat", | ||
378 | "dspe924.e56", "dspb924.b56", "dspd222.d56" }, | ||
379 | [5] = { NULL, "xlxc924.dat", | ||
380 | "dspe924.e56", "dspb924.b56", "dspd222.d56" }, | ||
339 | }; | 381 | }; |
340 | char path[32]; | 382 | char path[32]; |
341 | 383 | ||
342 | const struct firmware *fw_entry; | 384 | const struct firmware *fw_entry; |
343 | int i, err; | 385 | int i, err; |
386 | int fw_set = mgr->fw_file_set; | ||
344 | 387 | ||
345 | for (i = 0; i < ARRAY_SIZE(fw_files); i++) { | 388 | for (i = 0; i < 5; i++) { |
346 | sprintf(path, "pcxhr/%s", fw_files[i]); | 389 | if (!fw_files[fw_set][i]) |
390 | continue; | ||
391 | sprintf(path, "pcxhr/%s", fw_files[fw_set][i]); | ||
347 | if (request_firmware(&fw_entry, path, &mgr->pci->dev)) { | 392 | if (request_firmware(&fw_entry, path, &mgr->pci->dev)) { |
348 | snd_printk(KERN_ERR "pcxhr: can't load firmware %s\n", path); | 393 | snd_printk(KERN_ERR "pcxhr: can't load firmware %s\n", |
394 | path); | ||
349 | return -ENOENT; | 395 | return -ENOENT; |
350 | } | 396 | } |
351 | /* fake hwdep dsp record */ | 397 | /* fake hwdep dsp record */ |
@@ -358,11 +404,26 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) | |||
358 | return 0; | 404 | return 0; |
359 | } | 405 | } |
360 | 406 | ||
361 | MODULE_FIRMWARE("pcxhr/xi_1_882.dat"); | 407 | MODULE_FIRMWARE("pcxhr/xlxint.dat"); |
362 | MODULE_FIRMWARE("pcxhr/xc_1_882.dat"); | 408 | MODULE_FIRMWARE("pcxhr/xlxc882hr.dat"); |
363 | MODULE_FIRMWARE("pcxhr/e321_512.e56"); | 409 | MODULE_FIRMWARE("pcxhr/xlxc882e.dat"); |
364 | MODULE_FIRMWARE("pcxhr/b321_512.b56"); | 410 | MODULE_FIRMWARE("pcxhr/dspe882.e56"); |
365 | MODULE_FIRMWARE("pcxhr/d321_512.d56"); | 411 | MODULE_FIRMWARE("pcxhr/dspb882hr.b56"); |
412 | MODULE_FIRMWARE("pcxhr/dspb882e.b56"); | ||
413 | MODULE_FIRMWARE("pcxhr/dspd882.d56"); | ||
414 | |||
415 | MODULE_FIRMWARE("pcxhr/xlxc1222hr.dat"); | ||
416 | MODULE_FIRMWARE("pcxhr/xlxc1222e.dat"); | ||
417 | MODULE_FIRMWARE("pcxhr/dspb1222hr.b56"); | ||
418 | MODULE_FIRMWARE("pcxhr/dspb1222e.b56"); | ||
419 | MODULE_FIRMWARE("pcxhr/dspd1222.d56"); | ||
420 | |||
421 | MODULE_FIRMWARE("pcxhr/xlxc222.dat"); | ||
422 | MODULE_FIRMWARE("pcxhr/xlxc924.dat"); | ||
423 | MODULE_FIRMWARE("pcxhr/dspe924.e56"); | ||
424 | MODULE_FIRMWARE("pcxhr/dspb924.b56"); | ||
425 | MODULE_FIRMWARE("pcxhr/dspd222.d56"); | ||
426 | |||
366 | 427 | ||
367 | #else /* old style firmware loading */ | 428 | #else /* old style firmware loading */ |
368 | 429 | ||
@@ -373,7 +434,8 @@ MODULE_FIRMWARE("pcxhr/d321_512.d56"); | |||
373 | static int pcxhr_hwdep_dsp_status(struct snd_hwdep *hw, | 434 | static int pcxhr_hwdep_dsp_status(struct snd_hwdep *hw, |
374 | struct snd_hwdep_dsp_status *info) | 435 | struct snd_hwdep_dsp_status *info) |
375 | { | 436 | { |
376 | strcpy(info->id, "pcxhr"); | 437 | struct pcxhr_mgr *mgr = hw->private_data; |
438 | sprintf(info->id, "pcxhr%d", mgr->fw_file_set); | ||
377 | info->num_dsps = PCXHR_FIRMWARE_FILES_MAX_INDEX; | 439 | info->num_dsps = PCXHR_FIRMWARE_FILES_MAX_INDEX; |
378 | 440 | ||
379 | if (hw->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) | 441 | if (hw->dsp_loaded & (1 << PCXHR_FIRMWARE_DSP_MAIN_INDEX)) |
@@ -393,8 +455,8 @@ static int pcxhr_hwdep_dsp_load(struct snd_hwdep *hw, | |||
393 | fw.size = dsp->length; | 455 | fw.size = dsp->length; |
394 | fw.data = vmalloc(fw.size); | 456 | fw.data = vmalloc(fw.size); |
395 | if (! fw.data) { | 457 | if (! fw.data) { |
396 | snd_printk(KERN_ERR "pcxhr: cannot allocate dsp image (%lu bytes)\n", | 458 | snd_printk(KERN_ERR "pcxhr: cannot allocate dsp image " |
397 | (unsigned long)fw.size); | 459 | "(%lu bytes)\n", (unsigned long)fw.size); |
398 | return -ENOMEM; | 460 | return -ENOMEM; |
399 | } | 461 | } |
400 | if (copy_from_user((void *)fw.data, dsp->image, dsp->length)) { | 462 | if (copy_from_user((void *)fw.data, dsp->image, dsp->length)) { |
@@ -424,8 +486,11 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) | |||
424 | int err; | 486 | int err; |
425 | struct snd_hwdep *hw; | 487 | struct snd_hwdep *hw; |
426 | 488 | ||
427 | /* only create hwdep interface for first cardX (see "index" module parameter)*/ | 489 | /* only create hwdep interface for first cardX |
428 | if ((err = snd_hwdep_new(mgr->chip[0]->card, PCXHR_HWDEP_ID, 0, &hw)) < 0) | 490 | * (see "index" module parameter) |
491 | */ | ||
492 | err = snd_hwdep_new(mgr->chip[0]->card, PCXHR_HWDEP_ID, 0, &hw); | ||
493 | if (err < 0) | ||
429 | return err; | 494 | return err; |
430 | 495 | ||
431 | hw->iface = SNDRV_HWDEP_IFACE_PCXHR; | 496 | hw->iface = SNDRV_HWDEP_IFACE_PCXHR; |
@@ -435,10 +500,13 @@ int pcxhr_setup_firmware(struct pcxhr_mgr *mgr) | |||
435 | hw->ops.dsp_status = pcxhr_hwdep_dsp_status; | 500 | hw->ops.dsp_status = pcxhr_hwdep_dsp_status; |
436 | hw->ops.dsp_load = pcxhr_hwdep_dsp_load; | 501 | hw->ops.dsp_load = pcxhr_hwdep_dsp_load; |
437 | hw->exclusive = 1; | 502 | hw->exclusive = 1; |
503 | /* stereo cards don't need fw_file_0 -> dsp_loaded = 1 */ | ||
504 | hw->dsp_loaded = mgr->is_hr_stereo ? 1 : 0; | ||
438 | mgr->dsp_loaded = 0; | 505 | mgr->dsp_loaded = 0; |
439 | sprintf(hw->name, PCXHR_HWDEP_ID); | 506 | sprintf(hw->name, PCXHR_HWDEP_ID); |
440 | 507 | ||
441 | if ((err = snd_card_register(mgr->chip[0]->card)) < 0) | 508 | err = snd_card_register(mgr->chip[0]->card); |
509 | if (err < 0) | ||
442 | return err; | 510 | return err; |
443 | return 0; | 511 | return 0; |
444 | } | 512 | } |
diff --git a/sound/pci/pcxhr/pcxhr_mix22.c b/sound/pci/pcxhr/pcxhr_mix22.c new file mode 100644 index 000000000000..ff019126b672 --- /dev/null +++ b/sound/pci/pcxhr/pcxhr_mix22.c | |||
@@ -0,0 +1,820 @@ | |||
1 | /* | ||
2 | * Driver for Digigram pcxhr compatible soundcards | ||
3 | * | ||
4 | * mixer interface for stereo cards | ||
5 | * | ||
6 | * Copyright (c) 2004 by Digigram <alsa@digigram.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #include <linux/delay.h> | ||
24 | #include <linux/io.h> | ||
25 | #include <sound/core.h> | ||
26 | #include <sound/control.h> | ||
27 | #include <sound/tlv.h> | ||
28 | #include <sound/asoundef.h> | ||
29 | #include "pcxhr.h" | ||
30 | #include "pcxhr_core.h" | ||
31 | #include "pcxhr_mix22.h" | ||
32 | |||
33 | |||
34 | /* registers used on the DSP and Xilinx (port 2) : HR stereo cards only */ | ||
35 | #define PCXHR_DSP_RESET 0x20 | ||
36 | #define PCXHR_XLX_CFG 0x24 | ||
37 | #define PCXHR_XLX_RUER 0x28 | ||
38 | #define PCXHR_XLX_DATA 0x2C | ||
39 | #define PCXHR_XLX_STATUS 0x30 | ||
40 | #define PCXHR_XLX_LOFREQ 0x34 | ||
41 | #define PCXHR_XLX_HIFREQ 0x38 | ||
42 | #define PCXHR_XLX_CSUER 0x3C | ||
43 | #define PCXHR_XLX_SELMIC 0x40 | ||
44 | |||
45 | #define PCXHR_DSP 2 | ||
46 | |||
47 | /* byte access only ! */ | ||
48 | #define PCXHR_INPB(mgr, x) inb((mgr)->port[PCXHR_DSP] + (x)) | ||
49 | #define PCXHR_OUTPB(mgr, x, data) outb((data), (mgr)->port[PCXHR_DSP] + (x)) | ||
50 | |||
51 | |||
52 | /* values for PCHR_DSP_RESET register */ | ||
53 | #define PCXHR_DSP_RESET_DSP 0x01 | ||
54 | #define PCXHR_DSP_RESET_MUTE 0x02 | ||
55 | #define PCXHR_DSP_RESET_CODEC 0x08 | ||
56 | |||
57 | /* values for PCHR_XLX_CFG register */ | ||
58 | #define PCXHR_CFG_SYNCDSP_MASK 0x80 | ||
59 | #define PCXHR_CFG_DEPENDENCY_MASK 0x60 | ||
60 | #define PCXHR_CFG_INDEPENDANT_SEL 0x00 | ||
61 | #define PCXHR_CFG_MASTER_SEL 0x40 | ||
62 | #define PCXHR_CFG_SLAVE_SEL 0x20 | ||
63 | #define PCXHR_CFG_DATA_UER1_SEL_MASK 0x10 /* 0 (UER0), 1(UER1) */ | ||
64 | #define PCXHR_CFG_DATAIN_SEL_MASK 0x08 /* 0 (ana), 1 (UER) */ | ||
65 | #define PCXHR_CFG_SRC_MASK 0x04 /* 0 (Bypass), 1 (SRC Actif) */ | ||
66 | #define PCXHR_CFG_CLOCK_UER1_SEL_MASK 0x02 /* 0 (UER0), 1(UER1) */ | ||
67 | #define PCXHR_CFG_CLOCKIN_SEL_MASK 0x01 /* 0 (internal), 1 (AES/EBU) */ | ||
68 | |||
69 | /* values for PCHR_XLX_DATA register */ | ||
70 | #define PCXHR_DATA_CODEC 0x80 | ||
71 | #define AKM_POWER_CONTROL_CMD 0xA007 | ||
72 | #define AKM_RESET_ON_CMD 0xA100 | ||
73 | #define AKM_RESET_OFF_CMD 0xA103 | ||
74 | #define AKM_CLOCK_INF_55K_CMD 0xA240 | ||
75 | #define AKM_CLOCK_SUP_55K_CMD 0xA24D | ||
76 | #define AKM_MUTE_CMD 0xA38D | ||
77 | #define AKM_UNMUTE_CMD 0xA30D | ||
78 | #define AKM_LEFT_LEVEL_CMD 0xA600 | ||
79 | #define AKM_RIGHT_LEVEL_CMD 0xA700 | ||
80 | |||
81 | /* values for PCHR_XLX_STATUS register - READ */ | ||
82 | #define PCXHR_STAT_SRC_LOCK 0x01 | ||
83 | #define PCXHR_STAT_LEVEL_IN 0x02 | ||
84 | #define PCXHR_STAT_MIC_CAPS 0x10 | ||
85 | /* values for PCHR_XLX_STATUS register - WRITE */ | ||
86 | #define PCXHR_STAT_FREQ_SYNC_MASK 0x01 | ||
87 | #define PCXHR_STAT_FREQ_UER1_MASK 0x02 | ||
88 | #define PCXHR_STAT_FREQ_SAVE_MASK 0x80 | ||
89 | |||
90 | /* values for PCHR_XLX_CSUER register */ | ||
91 | #define PCXHR_SUER1_BIT_U_READ_MASK 0x80 | ||
92 | #define PCXHR_SUER1_BIT_C_READ_MASK 0x40 | ||
93 | #define PCXHR_SUER1_DATA_PRESENT_MASK 0x20 | ||
94 | #define PCXHR_SUER1_CLOCK_PRESENT_MASK 0x10 | ||
95 | #define PCXHR_SUER_BIT_U_READ_MASK 0x08 | ||
96 | #define PCXHR_SUER_BIT_C_READ_MASK 0x04 | ||
97 | #define PCXHR_SUER_DATA_PRESENT_MASK 0x02 | ||
98 | #define PCXHR_SUER_CLOCK_PRESENT_MASK 0x01 | ||
99 | |||
100 | #define PCXHR_SUER_BIT_U_WRITE_MASK 0x02 | ||
101 | #define PCXHR_SUER_BIT_C_WRITE_MASK 0x01 | ||
102 | |||
103 | /* values for PCXHR_XLX_SELMIC register - WRITE */ | ||
104 | #define PCXHR_SELMIC_PREAMPLI_OFFSET 2 | ||
105 | #define PCXHR_SELMIC_PREAMPLI_MASK 0x0C | ||
106 | #define PCXHR_SELMIC_PHANTOM_ALIM 0x80 | ||
107 | |||
108 | |||
109 | static const unsigned char g_hr222_p_level[] = { | ||
110 | 0x00, /* [000] -49.5 dB: AKM[000] = -1.#INF dB (mute) */ | ||
111 | 0x01, /* [001] -49.0 dB: AKM[001] = -48.131 dB (diff=0.86920 dB) */ | ||
112 | 0x01, /* [002] -48.5 dB: AKM[001] = -48.131 dB (diff=0.36920 dB) */ | ||
113 | 0x01, /* [003] -48.0 dB: AKM[001] = -48.131 dB (diff=0.13080 dB) */ | ||
114 | 0x01, /* [004] -47.5 dB: AKM[001] = -48.131 dB (diff=0.63080 dB) */ | ||
115 | 0x01, /* [005] -46.5 dB: AKM[001] = -48.131 dB (diff=1.63080 dB) */ | ||
116 | 0x01, /* [006] -47.0 dB: AKM[001] = -48.131 dB (diff=1.13080 dB) */ | ||
117 | 0x01, /* [007] -46.0 dB: AKM[001] = -48.131 dB (diff=2.13080 dB) */ | ||
118 | 0x01, /* [008] -45.5 dB: AKM[001] = -48.131 dB (diff=2.63080 dB) */ | ||
119 | 0x02, /* [009] -45.0 dB: AKM[002] = -42.110 dB (diff=2.88980 dB) */ | ||
120 | 0x02, /* [010] -44.5 dB: AKM[002] = -42.110 dB (diff=2.38980 dB) */ | ||
121 | 0x02, /* [011] -44.0 dB: AKM[002] = -42.110 dB (diff=1.88980 dB) */ | ||
122 | 0x02, /* [012] -43.5 dB: AKM[002] = -42.110 dB (diff=1.38980 dB) */ | ||
123 | 0x02, /* [013] -43.0 dB: AKM[002] = -42.110 dB (diff=0.88980 dB) */ | ||
124 | 0x02, /* [014] -42.5 dB: AKM[002] = -42.110 dB (diff=0.38980 dB) */ | ||
125 | 0x02, /* [015] -42.0 dB: AKM[002] = -42.110 dB (diff=0.11020 dB) */ | ||
126 | 0x02, /* [016] -41.5 dB: AKM[002] = -42.110 dB (diff=0.61020 dB) */ | ||
127 | 0x02, /* [017] -41.0 dB: AKM[002] = -42.110 dB (diff=1.11020 dB) */ | ||
128 | 0x02, /* [018] -40.5 dB: AKM[002] = -42.110 dB (diff=1.61020 dB) */ | ||
129 | 0x03, /* [019] -40.0 dB: AKM[003] = -38.588 dB (diff=1.41162 dB) */ | ||
130 | 0x03, /* [020] -39.5 dB: AKM[003] = -38.588 dB (diff=0.91162 dB) */ | ||
131 | 0x03, /* [021] -39.0 dB: AKM[003] = -38.588 dB (diff=0.41162 dB) */ | ||
132 | 0x03, /* [022] -38.5 dB: AKM[003] = -38.588 dB (diff=0.08838 dB) */ | ||
133 | 0x03, /* [023] -38.0 dB: AKM[003] = -38.588 dB (diff=0.58838 dB) */ | ||
134 | 0x03, /* [024] -37.5 dB: AKM[003] = -38.588 dB (diff=1.08838 dB) */ | ||
135 | 0x04, /* [025] -37.0 dB: AKM[004] = -36.090 dB (diff=0.91040 dB) */ | ||
136 | 0x04, /* [026] -36.5 dB: AKM[004] = -36.090 dB (diff=0.41040 dB) */ | ||
137 | 0x04, /* [027] -36.0 dB: AKM[004] = -36.090 dB (diff=0.08960 dB) */ | ||
138 | 0x04, /* [028] -35.5 dB: AKM[004] = -36.090 dB (diff=0.58960 dB) */ | ||
139 | 0x05, /* [029] -35.0 dB: AKM[005] = -34.151 dB (diff=0.84860 dB) */ | ||
140 | 0x05, /* [030] -34.5 dB: AKM[005] = -34.151 dB (diff=0.34860 dB) */ | ||
141 | 0x05, /* [031] -34.0 dB: AKM[005] = -34.151 dB (diff=0.15140 dB) */ | ||
142 | 0x05, /* [032] -33.5 dB: AKM[005] = -34.151 dB (diff=0.65140 dB) */ | ||
143 | 0x06, /* [033] -33.0 dB: AKM[006] = -32.568 dB (diff=0.43222 dB) */ | ||
144 | 0x06, /* [034] -32.5 dB: AKM[006] = -32.568 dB (diff=0.06778 dB) */ | ||
145 | 0x06, /* [035] -32.0 dB: AKM[006] = -32.568 dB (diff=0.56778 dB) */ | ||
146 | 0x07, /* [036] -31.5 dB: AKM[007] = -31.229 dB (diff=0.27116 dB) */ | ||
147 | 0x07, /* [037] -31.0 dB: AKM[007] = -31.229 dB (diff=0.22884 dB) */ | ||
148 | 0x08, /* [038] -30.5 dB: AKM[008] = -30.069 dB (diff=0.43100 dB) */ | ||
149 | 0x08, /* [039] -30.0 dB: AKM[008] = -30.069 dB (diff=0.06900 dB) */ | ||
150 | 0x09, /* [040] -29.5 dB: AKM[009] = -29.046 dB (diff=0.45405 dB) */ | ||
151 | 0x09, /* [041] -29.0 dB: AKM[009] = -29.046 dB (diff=0.04595 dB) */ | ||
152 | 0x0a, /* [042] -28.5 dB: AKM[010] = -28.131 dB (diff=0.36920 dB) */ | ||
153 | 0x0a, /* [043] -28.0 dB: AKM[010] = -28.131 dB (diff=0.13080 dB) */ | ||
154 | 0x0b, /* [044] -27.5 dB: AKM[011] = -27.303 dB (diff=0.19705 dB) */ | ||
155 | 0x0b, /* [045] -27.0 dB: AKM[011] = -27.303 dB (diff=0.30295 dB) */ | ||
156 | 0x0c, /* [046] -26.5 dB: AKM[012] = -26.547 dB (diff=0.04718 dB) */ | ||
157 | 0x0d, /* [047] -26.0 dB: AKM[013] = -25.852 dB (diff=0.14806 dB) */ | ||
158 | 0x0e, /* [048] -25.5 dB: AKM[014] = -25.208 dB (diff=0.29176 dB) */ | ||
159 | 0x0e, /* [049] -25.0 dB: AKM[014] = -25.208 dB (diff=0.20824 dB) */ | ||
160 | 0x0f, /* [050] -24.5 dB: AKM[015] = -24.609 dB (diff=0.10898 dB) */ | ||
161 | 0x10, /* [051] -24.0 dB: AKM[016] = -24.048 dB (diff=0.04840 dB) */ | ||
162 | 0x11, /* [052] -23.5 dB: AKM[017] = -23.522 dB (diff=0.02183 dB) */ | ||
163 | 0x12, /* [053] -23.0 dB: AKM[018] = -23.025 dB (diff=0.02535 dB) */ | ||
164 | 0x13, /* [054] -22.5 dB: AKM[019] = -22.556 dB (diff=0.05573 dB) */ | ||
165 | 0x14, /* [055] -22.0 dB: AKM[020] = -22.110 dB (diff=0.11020 dB) */ | ||
166 | 0x15, /* [056] -21.5 dB: AKM[021] = -21.686 dB (diff=0.18642 dB) */ | ||
167 | 0x17, /* [057] -21.0 dB: AKM[023] = -20.896 dB (diff=0.10375 dB) */ | ||
168 | 0x18, /* [058] -20.5 dB: AKM[024] = -20.527 dB (diff=0.02658 dB) */ | ||
169 | 0x1a, /* [059] -20.0 dB: AKM[026] = -19.831 dB (diff=0.16866 dB) */ | ||
170 | 0x1b, /* [060] -19.5 dB: AKM[027] = -19.504 dB (diff=0.00353 dB) */ | ||
171 | 0x1d, /* [061] -19.0 dB: AKM[029] = -18.883 dB (diff=0.11716 dB) */ | ||
172 | 0x1e, /* [062] -18.5 dB: AKM[030] = -18.588 dB (diff=0.08838 dB) */ | ||
173 | 0x20, /* [063] -18.0 dB: AKM[032] = -18.028 dB (diff=0.02780 dB) */ | ||
174 | 0x22, /* [064] -17.5 dB: AKM[034] = -17.501 dB (diff=0.00123 dB) */ | ||
175 | 0x24, /* [065] -17.0 dB: AKM[036] = -17.005 dB (diff=0.00475 dB) */ | ||
176 | 0x26, /* [066] -16.5 dB: AKM[038] = -16.535 dB (diff=0.03513 dB) */ | ||
177 | 0x28, /* [067] -16.0 dB: AKM[040] = -16.090 dB (diff=0.08960 dB) */ | ||
178 | 0x2b, /* [068] -15.5 dB: AKM[043] = -15.461 dB (diff=0.03857 dB) */ | ||
179 | 0x2d, /* [069] -15.0 dB: AKM[045] = -15.067 dB (diff=0.06655 dB) */ | ||
180 | 0x30, /* [070] -14.5 dB: AKM[048] = -14.506 dB (diff=0.00598 dB) */ | ||
181 | 0x33, /* [071] -14.0 dB: AKM[051] = -13.979 dB (diff=0.02060 dB) */ | ||
182 | 0x36, /* [072] -13.5 dB: AKM[054] = -13.483 dB (diff=0.01707 dB) */ | ||
183 | 0x39, /* [073] -13.0 dB: AKM[057] = -13.013 dB (diff=0.01331 dB) */ | ||
184 | 0x3c, /* [074] -12.5 dB: AKM[060] = -12.568 dB (diff=0.06778 dB) */ | ||
185 | 0x40, /* [075] -12.0 dB: AKM[064] = -12.007 dB (diff=0.00720 dB) */ | ||
186 | 0x44, /* [076] -11.5 dB: AKM[068] = -11.481 dB (diff=0.01937 dB) */ | ||
187 | 0x48, /* [077] -11.0 dB: AKM[072] = -10.984 dB (diff=0.01585 dB) */ | ||
188 | 0x4c, /* [078] -10.5 dB: AKM[076] = -10.515 dB (diff=0.01453 dB) */ | ||
189 | 0x51, /* [079] -10.0 dB: AKM[081] = -9.961 dB (diff=0.03890 dB) */ | ||
190 | 0x55, /* [080] -9.5 dB: AKM[085] = -9.542 dB (diff=0.04243 dB) */ | ||
191 | 0x5a, /* [081] -9.0 dB: AKM[090] = -9.046 dB (diff=0.04595 dB) */ | ||
192 | 0x60, /* [082] -8.5 dB: AKM[096] = -8.485 dB (diff=0.01462 dB) */ | ||
193 | 0x66, /* [083] -8.0 dB: AKM[102] = -7.959 dB (diff=0.04120 dB) */ | ||
194 | 0x6c, /* [084] -7.5 dB: AKM[108] = -7.462 dB (diff=0.03767 dB) */ | ||
195 | 0x72, /* [085] -7.0 dB: AKM[114] = -6.993 dB (diff=0.00729 dB) */ | ||
196 | 0x79, /* [086] -6.5 dB: AKM[121] = -6.475 dB (diff=0.02490 dB) */ | ||
197 | 0x80, /* [087] -6.0 dB: AKM[128] = -5.987 dB (diff=0.01340 dB) */ | ||
198 | 0x87, /* [088] -5.5 dB: AKM[135] = -5.524 dB (diff=0.02413 dB) */ | ||
199 | 0x8f, /* [089] -5.0 dB: AKM[143] = -5.024 dB (diff=0.02408 dB) */ | ||
200 | 0x98, /* [090] -4.5 dB: AKM[152] = -4.494 dB (diff=0.00607 dB) */ | ||
201 | 0xa1, /* [091] -4.0 dB: AKM[161] = -3.994 dB (diff=0.00571 dB) */ | ||
202 | 0xaa, /* [092] -3.5 dB: AKM[170] = -3.522 dB (diff=0.02183 dB) */ | ||
203 | 0xb5, /* [093] -3.0 dB: AKM[181] = -2.977 dB (diff=0.02277 dB) */ | ||
204 | 0xbf, /* [094] -2.5 dB: AKM[191] = -2.510 dB (diff=0.01014 dB) */ | ||
205 | 0xcb, /* [095] -2.0 dB: AKM[203] = -1.981 dB (diff=0.01912 dB) */ | ||
206 | 0xd7, /* [096] -1.5 dB: AKM[215] = -1.482 dB (diff=0.01797 dB) */ | ||
207 | 0xe3, /* [097] -1.0 dB: AKM[227] = -1.010 dB (diff=0.01029 dB) */ | ||
208 | 0xf1, /* [098] -0.5 dB: AKM[241] = -0.490 dB (diff=0.00954 dB) */ | ||
209 | 0xff, /* [099] +0.0 dB: AKM[255] = +0.000 dB (diff=0.00000 dB) */ | ||
210 | }; | ||
211 | |||
212 | |||
213 | static void hr222_config_akm(struct pcxhr_mgr *mgr, unsigned short data) | ||
214 | { | ||
215 | unsigned short mask = 0x8000; | ||
216 | /* activate access to codec registers */ | ||
217 | PCXHR_INPB(mgr, PCXHR_XLX_HIFREQ); | ||
218 | |||
219 | while (mask) { | ||
220 | PCXHR_OUTPB(mgr, PCXHR_XLX_DATA, | ||
221 | data & mask ? PCXHR_DATA_CODEC : 0); | ||
222 | mask >>= 1; | ||
223 | } | ||
224 | /* termiate access to codec registers */ | ||
225 | PCXHR_INPB(mgr, PCXHR_XLX_RUER); | ||
226 | } | ||
227 | |||
228 | |||
229 | static int hr222_set_hw_playback_level(struct pcxhr_mgr *mgr, | ||
230 | int idx, int level) | ||
231 | { | ||
232 | unsigned short cmd; | ||
233 | if (idx > 1 || | ||
234 | level < 0 || | ||
235 | level >= ARRAY_SIZE(g_hr222_p_level)) | ||
236 | return -EINVAL; | ||
237 | |||
238 | if (idx == 0) | ||
239 | cmd = AKM_LEFT_LEVEL_CMD; | ||
240 | else | ||
241 | cmd = AKM_RIGHT_LEVEL_CMD; | ||
242 | |||
243 | /* conversion from PmBoardCodedLevel to AKM nonlinear programming */ | ||
244 | cmd += g_hr222_p_level[level]; | ||
245 | |||
246 | hr222_config_akm(mgr, cmd); | ||
247 | return 0; | ||
248 | } | ||
249 | |||
250 | |||
251 | static int hr222_set_hw_capture_level(struct pcxhr_mgr *mgr, | ||
252 | int level_l, int level_r, int level_mic) | ||
253 | { | ||
254 | /* program all input levels at the same time */ | ||
255 | unsigned int data; | ||
256 | int i; | ||
257 | |||
258 | if (!mgr->capture_chips) | ||
259 | return -EINVAL; /* no PCX22 */ | ||
260 | |||
261 | data = ((level_mic & 0xff) << 24); /* micro is mono, but apply */ | ||
262 | data |= ((level_mic & 0xff) << 16); /* level on both channels */ | ||
263 | data |= ((level_r & 0xff) << 8); /* line input right channel */ | ||
264 | data |= (level_l & 0xff); /* line input left channel */ | ||
265 | |||
266 | PCXHR_INPB(mgr, PCXHR_XLX_DATA); /* activate input codec */ | ||
267 | /* send 32 bits (4 x 8 bits) */ | ||
268 | for (i = 0; i < 32; i++, data <<= 1) { | ||
269 | PCXHR_OUTPB(mgr, PCXHR_XLX_DATA, | ||
270 | (data & 0x80000000) ? PCXHR_DATA_CODEC : 0); | ||
271 | } | ||
272 | PCXHR_INPB(mgr, PCXHR_XLX_RUER); /* close input level codec */ | ||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | static void hr222_micro_boost(struct pcxhr_mgr *mgr, int level); | ||
277 | |||
278 | int hr222_sub_init(struct pcxhr_mgr *mgr) | ||
279 | { | ||
280 | unsigned char reg; | ||
281 | |||
282 | mgr->board_has_analog = 1; /* analog always available */ | ||
283 | mgr->xlx_cfg = PCXHR_CFG_SYNCDSP_MASK; | ||
284 | |||
285 | reg = PCXHR_INPB(mgr, PCXHR_XLX_STATUS); | ||
286 | if (reg & PCXHR_STAT_MIC_CAPS) | ||
287 | mgr->board_has_mic = 1; /* microphone available */ | ||
288 | snd_printdd("MIC input available = %d\n", mgr->board_has_mic); | ||
289 | |||
290 | /* reset codec */ | ||
291 | PCXHR_OUTPB(mgr, PCXHR_DSP_RESET, | ||
292 | PCXHR_DSP_RESET_DSP); | ||
293 | msleep(5); | ||
294 | PCXHR_OUTPB(mgr, PCXHR_DSP_RESET, | ||
295 | PCXHR_DSP_RESET_DSP | | ||
296 | PCXHR_DSP_RESET_MUTE | | ||
297 | PCXHR_DSP_RESET_CODEC); | ||
298 | msleep(5); | ||
299 | |||
300 | /* config AKM */ | ||
301 | hr222_config_akm(mgr, AKM_POWER_CONTROL_CMD); | ||
302 | hr222_config_akm(mgr, AKM_CLOCK_INF_55K_CMD); | ||
303 | hr222_config_akm(mgr, AKM_UNMUTE_CMD); | ||
304 | hr222_config_akm(mgr, AKM_RESET_OFF_CMD); | ||
305 | |||
306 | /* init micro boost */ | ||
307 | hr222_micro_boost(mgr, 0); | ||
308 | |||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | |||
313 | /* calc PLL register */ | ||
314 | /* TODO : there is a very similar fct in pcxhr.c */ | ||
315 | static int hr222_pll_freq_register(unsigned int freq, | ||
316 | unsigned int *pllreg, | ||
317 | unsigned int *realfreq) | ||
318 | { | ||
319 | unsigned int reg; | ||
320 | |||
321 | if (freq < 6900 || freq > 219000) | ||
322 | return -EINVAL; | ||
323 | reg = (28224000 * 2) / freq; | ||
324 | reg = (reg - 1) / 2; | ||
325 | if (reg < 0x100) | ||
326 | *pllreg = reg + 0xC00; | ||
327 | else if (reg < 0x200) | ||
328 | *pllreg = reg + 0x800; | ||
329 | else if (reg < 0x400) | ||
330 | *pllreg = reg & 0x1ff; | ||
331 | else if (reg < 0x800) { | ||
332 | *pllreg = ((reg >> 1) & 0x1ff) + 0x200; | ||
333 | reg &= ~1; | ||
334 | } else { | ||
335 | *pllreg = ((reg >> 2) & 0x1ff) + 0x400; | ||
336 | reg &= ~3; | ||
337 | } | ||
338 | if (realfreq) | ||
339 | *realfreq = (28224000 / (reg + 1)); | ||
340 | return 0; | ||
341 | } | ||
342 | |||
343 | int hr222_sub_set_clock(struct pcxhr_mgr *mgr, | ||
344 | unsigned int rate, | ||
345 | int *changed) | ||
346 | { | ||
347 | unsigned int speed, pllreg = 0; | ||
348 | int err; | ||
349 | unsigned realfreq = rate; | ||
350 | |||
351 | switch (mgr->use_clock_type) { | ||
352 | case HR22_CLOCK_TYPE_INTERNAL: | ||
353 | err = hr222_pll_freq_register(rate, &pllreg, &realfreq); | ||
354 | if (err) | ||
355 | return err; | ||
356 | |||
357 | mgr->xlx_cfg &= ~(PCXHR_CFG_CLOCKIN_SEL_MASK | | ||
358 | PCXHR_CFG_CLOCK_UER1_SEL_MASK); | ||
359 | break; | ||
360 | case HR22_CLOCK_TYPE_AES_SYNC: | ||
361 | mgr->xlx_cfg |= PCXHR_CFG_CLOCKIN_SEL_MASK; | ||
362 | mgr->xlx_cfg &= ~PCXHR_CFG_CLOCK_UER1_SEL_MASK; | ||
363 | break; | ||
364 | case HR22_CLOCK_TYPE_AES_1: | ||
365 | if (!mgr->board_has_aes1) | ||
366 | return -EINVAL; | ||
367 | |||
368 | mgr->xlx_cfg |= (PCXHR_CFG_CLOCKIN_SEL_MASK | | ||
369 | PCXHR_CFG_CLOCK_UER1_SEL_MASK); | ||
370 | break; | ||
371 | default: | ||
372 | return -EINVAL; | ||
373 | } | ||
374 | hr222_config_akm(mgr, AKM_MUTE_CMD); | ||
375 | |||
376 | if (mgr->use_clock_type == HR22_CLOCK_TYPE_INTERNAL) { | ||
377 | PCXHR_OUTPB(mgr, PCXHR_XLX_HIFREQ, pllreg >> 8); | ||
378 | PCXHR_OUTPB(mgr, PCXHR_XLX_LOFREQ, pllreg & 0xff); | ||
379 | } | ||
380 | |||
381 | /* set clock source */ | ||
382 | PCXHR_OUTPB(mgr, PCXHR_XLX_CFG, mgr->xlx_cfg); | ||
383 | |||
384 | /* codec speed modes */ | ||
385 | speed = rate < 55000 ? 0 : 1; | ||
386 | if (mgr->codec_speed != speed) { | ||
387 | mgr->codec_speed = speed; | ||
388 | if (speed == 0) | ||
389 | hr222_config_akm(mgr, AKM_CLOCK_INF_55K_CMD); | ||
390 | else | ||
391 | hr222_config_akm(mgr, AKM_CLOCK_SUP_55K_CMD); | ||
392 | } | ||
393 | |||
394 | mgr->sample_rate_real = realfreq; | ||
395 | mgr->cur_clock_type = mgr->use_clock_type; | ||
396 | |||
397 | if (changed) | ||
398 | *changed = 1; | ||
399 | |||
400 | hr222_config_akm(mgr, AKM_UNMUTE_CMD); | ||
401 | |||
402 | snd_printdd("set_clock to %dHz (realfreq=%d pllreg=%x)\n", | ||
403 | rate, realfreq, pllreg); | ||
404 | return 0; | ||
405 | } | ||
406 | |||
407 | int hr222_get_external_clock(struct pcxhr_mgr *mgr, | ||
408 | enum pcxhr_clock_type clock_type, | ||
409 | int *sample_rate) | ||
410 | { | ||
411 | int rate, calc_rate = 0; | ||
412 | unsigned int ticks; | ||
413 | unsigned char mask, reg; | ||
414 | |||
415 | if (clock_type == HR22_CLOCK_TYPE_AES_SYNC) { | ||
416 | |||
417 | mask = (PCXHR_SUER_CLOCK_PRESENT_MASK | | ||
418 | PCXHR_SUER_DATA_PRESENT_MASK); | ||
419 | reg = PCXHR_STAT_FREQ_SYNC_MASK; | ||
420 | |||
421 | } else if (clock_type == HR22_CLOCK_TYPE_AES_1 && mgr->board_has_aes1) { | ||
422 | |||
423 | mask = (PCXHR_SUER1_CLOCK_PRESENT_MASK | | ||
424 | PCXHR_SUER1_DATA_PRESENT_MASK); | ||
425 | reg = PCXHR_STAT_FREQ_UER1_MASK; | ||
426 | |||
427 | } else { | ||
428 | snd_printdd("get_external_clock : type %d not supported\n", | ||
429 | clock_type); | ||
430 | return -EINVAL; /* other clocks not supported */ | ||
431 | } | ||
432 | |||
433 | if ((PCXHR_INPB(mgr, PCXHR_XLX_CSUER) & mask) != mask) { | ||
434 | snd_printdd("get_external_clock(%d) = 0 Hz\n", clock_type); | ||
435 | *sample_rate = 0; | ||
436 | return 0; /* no external clock locked */ | ||
437 | } | ||
438 | |||
439 | PCXHR_OUTPB(mgr, PCXHR_XLX_STATUS, reg); /* calculate freq */ | ||
440 | |||
441 | /* save the measured clock frequency */ | ||
442 | reg |= PCXHR_STAT_FREQ_SAVE_MASK; | ||
443 | |||
444 | if (mgr->last_reg_stat != reg) { | ||
445 | udelay(500); /* wait min 2 cycles of lowest freq (8000) */ | ||
446 | mgr->last_reg_stat = reg; | ||
447 | } | ||
448 | |||
449 | PCXHR_OUTPB(mgr, PCXHR_XLX_STATUS, reg); /* save */ | ||
450 | |||
451 | /* get the frequency */ | ||
452 | ticks = (unsigned int)PCXHR_INPB(mgr, PCXHR_XLX_CFG); | ||
453 | ticks = (ticks & 0x03) << 8; | ||
454 | ticks |= (unsigned int)PCXHR_INPB(mgr, PCXHR_DSP_RESET); | ||
455 | |||
456 | if (ticks != 0) | ||
457 | calc_rate = 28224000 / ticks; | ||
458 | /* rounding */ | ||
459 | if (calc_rate > 184200) | ||
460 | rate = 192000; | ||
461 | else if (calc_rate > 152200) | ||
462 | rate = 176400; | ||
463 | else if (calc_rate > 112000) | ||
464 | rate = 128000; | ||
465 | else if (calc_rate > 92100) | ||
466 | rate = 96000; | ||
467 | else if (calc_rate > 76100) | ||
468 | rate = 88200; | ||
469 | else if (calc_rate > 56000) | ||
470 | rate = 64000; | ||
471 | else if (calc_rate > 46050) | ||
472 | rate = 48000; | ||
473 | else if (calc_rate > 38050) | ||
474 | rate = 44100; | ||
475 | else if (calc_rate > 28000) | ||
476 | rate = 32000; | ||
477 | else if (calc_rate > 23025) | ||
478 | rate = 24000; | ||
479 | else if (calc_rate > 19025) | ||
480 | rate = 22050; | ||
481 | else if (calc_rate > 14000) | ||
482 | rate = 16000; | ||
483 | else if (calc_rate > 11512) | ||
484 | rate = 12000; | ||
485 | else if (calc_rate > 9512) | ||
486 | rate = 11025; | ||
487 | else if (calc_rate > 7000) | ||
488 | rate = 8000; | ||
489 | else | ||
490 | rate = 0; | ||
491 | |||
492 | snd_printdd("External clock is at %d Hz (measured %d Hz)\n", | ||
493 | rate, calc_rate); | ||
494 | *sample_rate = rate; | ||
495 | return 0; | ||
496 | } | ||
497 | |||
498 | |||
499 | int hr222_update_analog_audio_level(struct snd_pcxhr *chip, | ||
500 | int is_capture, int channel) | ||
501 | { | ||
502 | snd_printdd("hr222_update_analog_audio_level(%s chan=%d)\n", | ||
503 | is_capture ? "capture" : "playback", channel); | ||
504 | if (is_capture) { | ||
505 | int level_l, level_r, level_mic; | ||
506 | /* we have to update all levels */ | ||
507 | if (chip->analog_capture_active) { | ||
508 | level_l = chip->analog_capture_volume[0]; | ||
509 | level_r = chip->analog_capture_volume[1]; | ||
510 | } else { | ||
511 | level_l = HR222_LINE_CAPTURE_LEVEL_MIN; | ||
512 | level_r = HR222_LINE_CAPTURE_LEVEL_MIN; | ||
513 | } | ||
514 | if (chip->mic_active) | ||
515 | level_mic = chip->mic_volume; | ||
516 | else | ||
517 | level_mic = HR222_MICRO_CAPTURE_LEVEL_MIN; | ||
518 | return hr222_set_hw_capture_level(chip->mgr, | ||
519 | level_l, level_r, level_mic); | ||
520 | } else { | ||
521 | int vol; | ||
522 | if (chip->analog_playback_active[channel]) | ||
523 | vol = chip->analog_playback_volume[channel]; | ||
524 | else | ||
525 | vol = HR222_LINE_PLAYBACK_LEVEL_MIN; | ||
526 | return hr222_set_hw_playback_level(chip->mgr, channel, vol); | ||
527 | } | ||
528 | } | ||
529 | |||
530 | |||
531 | /*texts[5] = {"Line", "Digital", "Digi+SRC", "Mic", "Line+Mic"}*/ | ||
532 | #define SOURCE_LINE 0 | ||
533 | #define SOURCE_DIGITAL 1 | ||
534 | #define SOURCE_DIGISRC 2 | ||
535 | #define SOURCE_MIC 3 | ||
536 | #define SOURCE_LINEMIC 4 | ||
537 | |||
538 | int hr222_set_audio_source(struct snd_pcxhr *chip) | ||
539 | { | ||
540 | int digital = 0; | ||
541 | /* default analog source */ | ||
542 | chip->mgr->xlx_cfg &= ~(PCXHR_CFG_SRC_MASK | | ||
543 | PCXHR_CFG_DATAIN_SEL_MASK | | ||
544 | PCXHR_CFG_DATA_UER1_SEL_MASK); | ||
545 | |||
546 | if (chip->audio_capture_source == SOURCE_DIGISRC) { | ||
547 | chip->mgr->xlx_cfg |= PCXHR_CFG_SRC_MASK; | ||
548 | digital = 1; | ||
549 | } else { | ||
550 | if (chip->audio_capture_source == SOURCE_DIGITAL) | ||
551 | digital = 1; | ||
552 | } | ||
553 | if (digital) { | ||
554 | chip->mgr->xlx_cfg |= PCXHR_CFG_DATAIN_SEL_MASK; | ||
555 | if (chip->mgr->board_has_aes1) { | ||
556 | /* get data from the AES1 plug */ | ||
557 | chip->mgr->xlx_cfg |= PCXHR_CFG_DATA_UER1_SEL_MASK; | ||
558 | } | ||
559 | /* chip->mic_active = 0; */ | ||
560 | /* chip->analog_capture_active = 0; */ | ||
561 | } else { | ||
562 | int update_lvl = 0; | ||
563 | chip->analog_capture_active = 0; | ||
564 | chip->mic_active = 0; | ||
565 | if (chip->audio_capture_source == SOURCE_LINE || | ||
566 | chip->audio_capture_source == SOURCE_LINEMIC) { | ||
567 | if (chip->analog_capture_active == 0) | ||
568 | update_lvl = 1; | ||
569 | chip->analog_capture_active = 1; | ||
570 | } | ||
571 | if (chip->audio_capture_source == SOURCE_MIC || | ||
572 | chip->audio_capture_source == SOURCE_LINEMIC) { | ||
573 | if (chip->mic_active == 0) | ||
574 | update_lvl = 1; | ||
575 | chip->mic_active = 1; | ||
576 | } | ||
577 | if (update_lvl) { | ||
578 | /* capture: update all 3 mutes/unmutes with one call */ | ||
579 | hr222_update_analog_audio_level(chip, 1, 0); | ||
580 | } | ||
581 | } | ||
582 | /* set the source infos (max 3 bits modified) */ | ||
583 | PCXHR_OUTPB(chip->mgr, PCXHR_XLX_CFG, chip->mgr->xlx_cfg); | ||
584 | return 0; | ||
585 | } | ||
586 | |||
587 | |||
588 | int hr222_iec958_capture_byte(struct snd_pcxhr *chip, | ||
589 | int aes_idx, unsigned char *aes_bits) | ||
590 | { | ||
591 | unsigned char idx = (unsigned char)(aes_idx * 8); | ||
592 | unsigned char temp = 0; | ||
593 | unsigned char mask = chip->mgr->board_has_aes1 ? | ||
594 | PCXHR_SUER1_BIT_C_READ_MASK : PCXHR_SUER_BIT_C_READ_MASK; | ||
595 | int i; | ||
596 | for (i = 0; i < 8; i++) { | ||
597 | PCXHR_OUTPB(chip->mgr, PCXHR_XLX_RUER, idx++); /* idx < 192 */ | ||
598 | temp <<= 1; | ||
599 | if (PCXHR_INPB(chip->mgr, PCXHR_XLX_CSUER) & mask) | ||
600 | temp |= 1; | ||
601 | } | ||
602 | snd_printdd("read iec958 AES %d byte %d = 0x%x\n", | ||
603 | chip->chip_idx, aes_idx, temp); | ||
604 | *aes_bits = temp; | ||
605 | return 0; | ||
606 | } | ||
607 | |||
608 | |||
609 | int hr222_iec958_update_byte(struct snd_pcxhr *chip, | ||
610 | int aes_idx, unsigned char aes_bits) | ||
611 | { | ||
612 | int i; | ||
613 | unsigned char new_bits = aes_bits; | ||
614 | unsigned char old_bits = chip->aes_bits[aes_idx]; | ||
615 | unsigned char idx = (unsigned char)(aes_idx * 8); | ||
616 | for (i = 0; i < 8; i++) { | ||
617 | if ((old_bits & 0x01) != (new_bits & 0x01)) { | ||
618 | /* idx < 192 */ | ||
619 | PCXHR_OUTPB(chip->mgr, PCXHR_XLX_RUER, idx); | ||
620 | /* write C and U bit */ | ||
621 | PCXHR_OUTPB(chip->mgr, PCXHR_XLX_CSUER, new_bits&0x01 ? | ||
622 | PCXHR_SUER_BIT_C_WRITE_MASK : 0); | ||
623 | } | ||
624 | idx++; | ||
625 | old_bits >>= 1; | ||
626 | new_bits >>= 1; | ||
627 | } | ||
628 | chip->aes_bits[aes_idx] = aes_bits; | ||
629 | return 0; | ||
630 | } | ||
631 | |||
632 | static void hr222_micro_boost(struct pcxhr_mgr *mgr, int level) | ||
633 | { | ||
634 | unsigned char boost_mask; | ||
635 | boost_mask = (unsigned char) (level << PCXHR_SELMIC_PREAMPLI_OFFSET); | ||
636 | if (boost_mask & (~PCXHR_SELMIC_PREAMPLI_MASK)) | ||
637 | return; /* only values form 0 to 3 accepted */ | ||
638 | |||
639 | mgr->xlx_selmic &= ~PCXHR_SELMIC_PREAMPLI_MASK; | ||
640 | mgr->xlx_selmic |= boost_mask; | ||
641 | |||
642 | PCXHR_OUTPB(mgr, PCXHR_XLX_SELMIC, mgr->xlx_selmic); | ||
643 | |||
644 | snd_printdd("hr222_micro_boost : set %x\n", boost_mask); | ||
645 | } | ||
646 | |||
647 | static void hr222_phantom_power(struct pcxhr_mgr *mgr, int power) | ||
648 | { | ||
649 | if (power) | ||
650 | mgr->xlx_selmic |= PCXHR_SELMIC_PHANTOM_ALIM; | ||
651 | else | ||
652 | mgr->xlx_selmic &= ~PCXHR_SELMIC_PHANTOM_ALIM; | ||
653 | |||
654 | PCXHR_OUTPB(mgr, PCXHR_XLX_SELMIC, mgr->xlx_selmic); | ||
655 | |||
656 | snd_printdd("hr222_phantom_power : set %d\n", power); | ||
657 | } | ||
658 | |||
659 | |||
660 | /* mic level */ | ||
661 | static const DECLARE_TLV_DB_SCALE(db_scale_mic_hr222, -9850, 50, 650); | ||
662 | |||
663 | static int hr222_mic_vol_info(struct snd_kcontrol *kcontrol, | ||
664 | struct snd_ctl_elem_info *uinfo) | ||
665 | { | ||
666 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
667 | uinfo->count = 1; | ||
668 | uinfo->value.integer.min = HR222_MICRO_CAPTURE_LEVEL_MIN; /* -98 dB */ | ||
669 | /* gains from 9 dB to 31.5 dB not recommended; use micboost instead */ | ||
670 | uinfo->value.integer.max = HR222_MICRO_CAPTURE_LEVEL_MAX; /* +7 dB */ | ||
671 | return 0; | ||
672 | } | ||
673 | |||
674 | static int hr222_mic_vol_get(struct snd_kcontrol *kcontrol, | ||
675 | struct snd_ctl_elem_value *ucontrol) | ||
676 | { | ||
677 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | ||
678 | mutex_lock(&chip->mgr->mixer_mutex); | ||
679 | ucontrol->value.integer.value[0] = chip->mic_volume; | ||
680 | mutex_unlock(&chip->mgr->mixer_mutex); | ||
681 | return 0; | ||
682 | } | ||
683 | |||
684 | static int hr222_mic_vol_put(struct snd_kcontrol *kcontrol, | ||
685 | struct snd_ctl_elem_value *ucontrol) | ||
686 | { | ||
687 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | ||
688 | int changed = 0; | ||
689 | mutex_lock(&chip->mgr->mixer_mutex); | ||
690 | if (chip->mic_volume != ucontrol->value.integer.value[0]) { | ||
691 | changed = 1; | ||
692 | chip->mic_volume = ucontrol->value.integer.value[0]; | ||
693 | hr222_update_analog_audio_level(chip, 1, 0); | ||
694 | } | ||
695 | mutex_unlock(&chip->mgr->mixer_mutex); | ||
696 | return changed; | ||
697 | } | ||
698 | |||
699 | static struct snd_kcontrol_new hr222_control_mic_level = { | ||
700 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
701 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | | ||
702 | SNDRV_CTL_ELEM_ACCESS_TLV_READ), | ||
703 | .name = "Mic Capture Volume", | ||
704 | .info = hr222_mic_vol_info, | ||
705 | .get = hr222_mic_vol_get, | ||
706 | .put = hr222_mic_vol_put, | ||
707 | .tlv = { .p = db_scale_mic_hr222 }, | ||
708 | }; | ||
709 | |||
710 | |||
711 | /* mic boost level */ | ||
712 | static const DECLARE_TLV_DB_SCALE(db_scale_micboost_hr222, 0, 1800, 5400); | ||
713 | |||
714 | static int hr222_mic_boost_info(struct snd_kcontrol *kcontrol, | ||
715 | struct snd_ctl_elem_info *uinfo) | ||
716 | { | ||
717 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
718 | uinfo->count = 1; | ||
719 | uinfo->value.integer.min = 0; /* 0 dB */ | ||
720 | uinfo->value.integer.max = 3; /* 54 dB */ | ||
721 | return 0; | ||
722 | } | ||
723 | |||
724 | static int hr222_mic_boost_get(struct snd_kcontrol *kcontrol, | ||
725 | struct snd_ctl_elem_value *ucontrol) | ||
726 | { | ||
727 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | ||
728 | mutex_lock(&chip->mgr->mixer_mutex); | ||
729 | ucontrol->value.integer.value[0] = chip->mic_boost; | ||
730 | mutex_unlock(&chip->mgr->mixer_mutex); | ||
731 | return 0; | ||
732 | } | ||
733 | |||
734 | static int hr222_mic_boost_put(struct snd_kcontrol *kcontrol, | ||
735 | struct snd_ctl_elem_value *ucontrol) | ||
736 | { | ||
737 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | ||
738 | int changed = 0; | ||
739 | mutex_lock(&chip->mgr->mixer_mutex); | ||
740 | if (chip->mic_boost != ucontrol->value.integer.value[0]) { | ||
741 | changed = 1; | ||
742 | chip->mic_boost = ucontrol->value.integer.value[0]; | ||
743 | hr222_micro_boost(chip->mgr, chip->mic_boost); | ||
744 | } | ||
745 | mutex_unlock(&chip->mgr->mixer_mutex); | ||
746 | return changed; | ||
747 | } | ||
748 | |||
749 | static struct snd_kcontrol_new hr222_control_mic_boost = { | ||
750 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
751 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | | ||
752 | SNDRV_CTL_ELEM_ACCESS_TLV_READ), | ||
753 | .name = "MicBoost Capture Volume", | ||
754 | .info = hr222_mic_boost_info, | ||
755 | .get = hr222_mic_boost_get, | ||
756 | .put = hr222_mic_boost_put, | ||
757 | .tlv = { .p = db_scale_micboost_hr222 }, | ||
758 | }; | ||
759 | |||
760 | |||
761 | /******************* Phantom power switch *******************/ | ||
762 | #define hr222_phantom_power_info snd_ctl_boolean_mono_info | ||
763 | |||
764 | static int hr222_phantom_power_get(struct snd_kcontrol *kcontrol, | ||
765 | struct snd_ctl_elem_value *ucontrol) | ||
766 | { | ||
767 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | ||
768 | mutex_lock(&chip->mgr->mixer_mutex); | ||
769 | ucontrol->value.integer.value[0] = chip->phantom_power; | ||
770 | mutex_unlock(&chip->mgr->mixer_mutex); | ||
771 | return 0; | ||
772 | } | ||
773 | |||
774 | static int hr222_phantom_power_put(struct snd_kcontrol *kcontrol, | ||
775 | struct snd_ctl_elem_value *ucontrol) | ||
776 | { | ||
777 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | ||
778 | int power, changed = 0; | ||
779 | |||
780 | mutex_lock(&chip->mgr->mixer_mutex); | ||
781 | power = !!ucontrol->value.integer.value[0]; | ||
782 | if (chip->phantom_power != power) { | ||
783 | hr222_phantom_power(chip->mgr, power); | ||
784 | chip->phantom_power = power; | ||
785 | changed = 1; | ||
786 | } | ||
787 | mutex_unlock(&chip->mgr->mixer_mutex); | ||
788 | return changed; | ||
789 | } | ||
790 | |||
791 | static struct snd_kcontrol_new hr222_phantom_power_switch = { | ||
792 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
793 | .name = "Phantom Power Switch", | ||
794 | .info = hr222_phantom_power_info, | ||
795 | .get = hr222_phantom_power_get, | ||
796 | .put = hr222_phantom_power_put, | ||
797 | }; | ||
798 | |||
799 | |||
800 | int hr222_add_mic_controls(struct snd_pcxhr *chip) | ||
801 | { | ||
802 | int err; | ||
803 | if (!chip->mgr->board_has_mic) | ||
804 | return 0; | ||
805 | |||
806 | /* controls */ | ||
807 | err = snd_ctl_add(chip->card, snd_ctl_new1(&hr222_control_mic_level, | ||
808 | chip)); | ||
809 | if (err < 0) | ||
810 | return err; | ||
811 | |||
812 | err = snd_ctl_add(chip->card, snd_ctl_new1(&hr222_control_mic_boost, | ||
813 | chip)); | ||
814 | if (err < 0) | ||
815 | return err; | ||
816 | |||
817 | err = snd_ctl_add(chip->card, snd_ctl_new1(&hr222_phantom_power_switch, | ||
818 | chip)); | ||
819 | return err; | ||
820 | } | ||
diff --git a/sound/pci/pcxhr/pcxhr_mix22.h b/sound/pci/pcxhr/pcxhr_mix22.h new file mode 100644 index 000000000000..6b318b2f0100 --- /dev/null +++ b/sound/pci/pcxhr/pcxhr_mix22.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Driver for Digigram pcxhr compatible soundcards | ||
3 | * | ||
4 | * low level interface with interrupt ans message handling | ||
5 | * | ||
6 | * Copyright (c) 2004 by Digigram <alsa@digigram.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #ifndef __SOUND_PCXHR_MIX22_H | ||
24 | #define __SOUND_PCXHR_MIX22_H | ||
25 | |||
26 | struct pcxhr_mgr; | ||
27 | |||
28 | int hr222_sub_init(struct pcxhr_mgr *mgr); | ||
29 | int hr222_sub_set_clock(struct pcxhr_mgr *mgr, unsigned int rate, | ||
30 | int *changed); | ||
31 | int hr222_get_external_clock(struct pcxhr_mgr *mgr, | ||
32 | enum pcxhr_clock_type clock_type, | ||
33 | int *sample_rate); | ||
34 | |||
35 | #define HR222_LINE_PLAYBACK_LEVEL_MIN 0 /* -25.5 dB */ | ||
36 | #define HR222_LINE_PLAYBACK_ZERO_LEVEL 51 /* 0.0 dB */ | ||
37 | #define HR222_LINE_PLAYBACK_LEVEL_MAX 99 /* +24.0 dB */ | ||
38 | |||
39 | #define HR222_LINE_CAPTURE_LEVEL_MIN 0 /* -111.5 dB */ | ||
40 | #define HR222_LINE_CAPTURE_ZERO_LEVEL 223 /* 0.0 dB */ | ||
41 | #define HR222_LINE_CAPTURE_LEVEL_MAX 255 /* +16 dB */ | ||
42 | #define HR222_MICRO_CAPTURE_LEVEL_MIN 0 /* -98.5 dB */ | ||
43 | #define HR222_MICRO_CAPTURE_LEVEL_MAX 210 /* +6.5 dB */ | ||
44 | |||
45 | int hr222_update_analog_audio_level(struct snd_pcxhr *chip, | ||
46 | int is_capture, | ||
47 | int channel); | ||
48 | int hr222_set_audio_source(struct snd_pcxhr *chip); | ||
49 | int hr222_iec958_capture_byte(struct snd_pcxhr *chip, int aes_idx, | ||
50 | unsigned char *aes_bits); | ||
51 | int hr222_iec958_update_byte(struct snd_pcxhr *chip, int aes_idx, | ||
52 | unsigned char aes_bits); | ||
53 | |||
54 | int hr222_add_mic_controls(struct snd_pcxhr *chip); | ||
55 | |||
56 | #endif /* __SOUND_PCXHR_MIX22_H */ | ||
diff --git a/sound/pci/pcxhr/pcxhr_mixer.c b/sound/pci/pcxhr/pcxhr_mixer.c index aabc7bc5321e..2436e374586f 100644 --- a/sound/pci/pcxhr/pcxhr_mixer.c +++ b/sound/pci/pcxhr/pcxhr_mixer.c | |||
@@ -33,20 +33,24 @@ | |||
33 | #include <sound/tlv.h> | 33 | #include <sound/tlv.h> |
34 | #include <sound/asoundef.h> | 34 | #include <sound/asoundef.h> |
35 | #include "pcxhr_mixer.h" | 35 | #include "pcxhr_mixer.h" |
36 | #include "pcxhr_mix22.h" | ||
36 | 37 | ||
38 | #define PCXHR_LINE_CAPTURE_LEVEL_MIN 0 /* -112.0 dB */ | ||
39 | #define PCXHR_LINE_CAPTURE_LEVEL_MAX 255 /* +15.5 dB */ | ||
40 | #define PCXHR_LINE_CAPTURE_ZERO_LEVEL 224 /* 0.0 dB ( 0 dBu -> 0 dBFS ) */ | ||
37 | 41 | ||
38 | #define PCXHR_ANALOG_CAPTURE_LEVEL_MIN 0 /* -96.0 dB */ | 42 | #define PCXHR_LINE_PLAYBACK_LEVEL_MIN 0 /* -104.0 dB */ |
39 | #define PCXHR_ANALOG_CAPTURE_LEVEL_MAX 255 /* +31.5 dB */ | 43 | #define PCXHR_LINE_PLAYBACK_LEVEL_MAX 128 /* +24.0 dB */ |
40 | #define PCXHR_ANALOG_CAPTURE_ZERO_LEVEL 224 /* +16.0 dB ( +31.5 dB - fix level +15.5 dB ) */ | 44 | #define PCXHR_LINE_PLAYBACK_ZERO_LEVEL 104 /* 0.0 dB ( 0 dBFS -> 0 dBu ) */ |
41 | 45 | ||
42 | #define PCXHR_ANALOG_PLAYBACK_LEVEL_MIN 0 /* -128.0 dB */ | 46 | static const DECLARE_TLV_DB_SCALE(db_scale_analog_capture, -11200, 50, 1550); |
43 | #define PCXHR_ANALOG_PLAYBACK_LEVEL_MAX 128 /* 0.0 dB */ | ||
44 | #define PCXHR_ANALOG_PLAYBACK_ZERO_LEVEL 104 /* -24.0 dB ( 0.0 dB - fix level +24.0 dB ) */ | ||
45 | |||
46 | static const DECLARE_TLV_DB_SCALE(db_scale_analog_capture, -9600, 50, 3150); | ||
47 | static const DECLARE_TLV_DB_SCALE(db_scale_analog_playback, -10400, 100, 2400); | 47 | static const DECLARE_TLV_DB_SCALE(db_scale_analog_playback, -10400, 100, 2400); |
48 | 48 | ||
49 | static int pcxhr_update_analog_audio_level(struct snd_pcxhr *chip, int is_capture, int channel) | 49 | static const DECLARE_TLV_DB_SCALE(db_scale_a_hr222_capture, -11150, 50, 1600); |
50 | static const DECLARE_TLV_DB_SCALE(db_scale_a_hr222_playback, -2550, 50, 2400); | ||
51 | |||
52 | static int pcxhr_update_analog_audio_level(struct snd_pcxhr *chip, | ||
53 | int is_capture, int channel) | ||
50 | { | 54 | { |
51 | int err, vol; | 55 | int err, vol; |
52 | struct pcxhr_rmh rmh; | 56 | struct pcxhr_rmh rmh; |
@@ -60,15 +64,17 @@ static int pcxhr_update_analog_audio_level(struct snd_pcxhr *chip, int is_captur | |||
60 | if (chip->analog_playback_active[channel]) | 64 | if (chip->analog_playback_active[channel]) |
61 | vol = chip->analog_playback_volume[channel]; | 65 | vol = chip->analog_playback_volume[channel]; |
62 | else | 66 | else |
63 | vol = PCXHR_ANALOG_PLAYBACK_LEVEL_MIN; | 67 | vol = PCXHR_LINE_PLAYBACK_LEVEL_MIN; |
64 | rmh.cmd[2] = PCXHR_ANALOG_PLAYBACK_LEVEL_MAX - vol; /* playback analog levels are inversed */ | 68 | /* playback analog levels are inversed */ |
69 | rmh.cmd[2] = PCXHR_LINE_PLAYBACK_LEVEL_MAX - vol; | ||
65 | } | 70 | } |
66 | rmh.cmd[1] = 1 << ((2 * chip->chip_idx) + channel); /* audio mask */ | 71 | rmh.cmd[1] = 1 << ((2 * chip->chip_idx) + channel); /* audio mask */ |
67 | rmh.cmd_len = 3; | 72 | rmh.cmd_len = 3; |
68 | err = pcxhr_send_msg(chip->mgr, &rmh); | 73 | err = pcxhr_send_msg(chip->mgr, &rmh); |
69 | if (err < 0) { | 74 | if (err < 0) { |
70 | snd_printk(KERN_DEBUG "error update_analog_audio_level card(%d) " | 75 | snd_printk(KERN_DEBUG "error update_analog_audio_level card(%d)" |
71 | "is_capture(%d) err(%x)\n", chip->chip_idx, is_capture, err); | 76 | " is_capture(%d) err(%x)\n", |
77 | chip->chip_idx, is_capture, err); | ||
72 | return -EINVAL; | 78 | return -EINVAL; |
73 | } | 79 | } |
74 | return 0; | 80 | return 0; |
@@ -80,14 +86,34 @@ static int pcxhr_update_analog_audio_level(struct snd_pcxhr *chip, int is_captur | |||
80 | static int pcxhr_analog_vol_info(struct snd_kcontrol *kcontrol, | 86 | static int pcxhr_analog_vol_info(struct snd_kcontrol *kcontrol, |
81 | struct snd_ctl_elem_info *uinfo) | 87 | struct snd_ctl_elem_info *uinfo) |
82 | { | 88 | { |
89 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | ||
90 | |||
83 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 91 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
84 | uinfo->count = 2; | 92 | uinfo->count = 2; |
85 | if (kcontrol->private_value == 0) { /* playback */ | 93 | if (kcontrol->private_value == 0) { /* playback */ |
86 | uinfo->value.integer.min = PCXHR_ANALOG_PLAYBACK_LEVEL_MIN; /* -128 dB */ | 94 | if (chip->mgr->is_hr_stereo) { |
87 | uinfo->value.integer.max = PCXHR_ANALOG_PLAYBACK_LEVEL_MAX; /* 0 dB */ | 95 | uinfo->value.integer.min = |
96 | HR222_LINE_PLAYBACK_LEVEL_MIN; /* -25 dB */ | ||
97 | uinfo->value.integer.max = | ||
98 | HR222_LINE_PLAYBACK_LEVEL_MAX; /* +24 dB */ | ||
99 | } else { | ||
100 | uinfo->value.integer.min = | ||
101 | PCXHR_LINE_PLAYBACK_LEVEL_MIN; /*-104 dB */ | ||
102 | uinfo->value.integer.max = | ||
103 | PCXHR_LINE_PLAYBACK_LEVEL_MAX; /* +24 dB */ | ||
104 | } | ||
88 | } else { /* capture */ | 105 | } else { /* capture */ |
89 | uinfo->value.integer.min = PCXHR_ANALOG_CAPTURE_LEVEL_MIN; /* -96 dB */ | 106 | if (chip->mgr->is_hr_stereo) { |
90 | uinfo->value.integer.max = PCXHR_ANALOG_CAPTURE_LEVEL_MAX; /* 31.5 dB */ | 107 | uinfo->value.integer.min = |
108 | HR222_LINE_CAPTURE_LEVEL_MIN; /*-112 dB */ | ||
109 | uinfo->value.integer.max = | ||
110 | HR222_LINE_CAPTURE_LEVEL_MAX; /* +15.5 dB */ | ||
111 | } else { | ||
112 | uinfo->value.integer.min = | ||
113 | PCXHR_LINE_CAPTURE_LEVEL_MIN; /*-112 dB */ | ||
114 | uinfo->value.integer.max = | ||
115 | PCXHR_LINE_CAPTURE_LEVEL_MAX; /* +15.5 dB */ | ||
116 | } | ||
91 | } | 117 | } |
92 | return 0; | 118 | return 0; |
93 | } | 119 | } |
@@ -98,11 +124,11 @@ static int pcxhr_analog_vol_get(struct snd_kcontrol *kcontrol, | |||
98 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | 124 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); |
99 | mutex_lock(&chip->mgr->mixer_mutex); | 125 | mutex_lock(&chip->mgr->mixer_mutex); |
100 | if (kcontrol->private_value == 0) { /* playback */ | 126 | if (kcontrol->private_value == 0) { /* playback */ |
101 | ucontrol->value.integer.value[0] = chip->analog_playback_volume[0]; | 127 | ucontrol->value.integer.value[0] = chip->analog_playback_volume[0]; |
102 | ucontrol->value.integer.value[1] = chip->analog_playback_volume[1]; | 128 | ucontrol->value.integer.value[1] = chip->analog_playback_volume[1]; |
103 | } else { /* capture */ | 129 | } else { /* capture */ |
104 | ucontrol->value.integer.value[0] = chip->analog_capture_volume[0]; | 130 | ucontrol->value.integer.value[0] = chip->analog_capture_volume[0]; |
105 | ucontrol->value.integer.value[1] = chip->analog_capture_volume[1]; | 131 | ucontrol->value.integer.value[1] = chip->analog_capture_volume[1]; |
106 | } | 132 | } |
107 | mutex_unlock(&chip->mgr->mixer_mutex); | 133 | mutex_unlock(&chip->mgr->mixer_mutex); |
108 | return 0; | 134 | return 0; |
@@ -123,18 +149,35 @@ static int pcxhr_analog_vol_put(struct snd_kcontrol *kcontrol, | |||
123 | &chip->analog_capture_volume[i] : | 149 | &chip->analog_capture_volume[i] : |
124 | &chip->analog_playback_volume[i]; | 150 | &chip->analog_playback_volume[i]; |
125 | if (is_capture) { | 151 | if (is_capture) { |
126 | if (new_volume < PCXHR_ANALOG_CAPTURE_LEVEL_MIN || | 152 | if (chip->mgr->is_hr_stereo) { |
127 | new_volume > PCXHR_ANALOG_CAPTURE_LEVEL_MAX) | 153 | if (new_volume < HR222_LINE_CAPTURE_LEVEL_MIN || |
128 | continue; | 154 | new_volume > HR222_LINE_CAPTURE_LEVEL_MAX) |
155 | continue; | ||
156 | } else { | ||
157 | if (new_volume < PCXHR_LINE_CAPTURE_LEVEL_MIN || | ||
158 | new_volume > PCXHR_LINE_CAPTURE_LEVEL_MAX) | ||
159 | continue; | ||
160 | } | ||
129 | } else { | 161 | } else { |
130 | if (new_volume < PCXHR_ANALOG_PLAYBACK_LEVEL_MIN || | 162 | if (chip->mgr->is_hr_stereo) { |
131 | new_volume > PCXHR_ANALOG_PLAYBACK_LEVEL_MAX) | 163 | if (new_volume < HR222_LINE_PLAYBACK_LEVEL_MIN || |
132 | continue; | 164 | new_volume > HR222_LINE_PLAYBACK_LEVEL_MAX) |
165 | continue; | ||
166 | } else { | ||
167 | if (new_volume < PCXHR_LINE_PLAYBACK_LEVEL_MIN || | ||
168 | new_volume > PCXHR_LINE_PLAYBACK_LEVEL_MAX) | ||
169 | continue; | ||
170 | } | ||
133 | } | 171 | } |
134 | if (*stored_volume != new_volume) { | 172 | if (*stored_volume != new_volume) { |
135 | *stored_volume = new_volume; | 173 | *stored_volume = new_volume; |
136 | changed = 1; | 174 | changed = 1; |
137 | pcxhr_update_analog_audio_level(chip, is_capture, i); | 175 | if (chip->mgr->is_hr_stereo) |
176 | hr222_update_analog_audio_level(chip, | ||
177 | is_capture, i); | ||
178 | else | ||
179 | pcxhr_update_analog_audio_level(chip, | ||
180 | is_capture, i); | ||
138 | } | 181 | } |
139 | } | 182 | } |
140 | mutex_unlock(&chip->mgr->mixer_mutex); | 183 | mutex_unlock(&chip->mgr->mixer_mutex); |
@@ -153,6 +196,7 @@ static struct snd_kcontrol_new pcxhr_control_analog_level = { | |||
153 | }; | 196 | }; |
154 | 197 | ||
155 | /* shared */ | 198 | /* shared */ |
199 | |||
156 | #define pcxhr_sw_info snd_ctl_boolean_stereo_info | 200 | #define pcxhr_sw_info snd_ctl_boolean_stereo_info |
157 | 201 | ||
158 | static int pcxhr_audio_sw_get(struct snd_kcontrol *kcontrol, | 202 | static int pcxhr_audio_sw_get(struct snd_kcontrol *kcontrol, |
@@ -180,7 +224,10 @@ static int pcxhr_audio_sw_put(struct snd_kcontrol *kcontrol, | |||
180 | !!ucontrol->value.integer.value[i]; | 224 | !!ucontrol->value.integer.value[i]; |
181 | changed = 1; | 225 | changed = 1; |
182 | /* update playback levels */ | 226 | /* update playback levels */ |
183 | pcxhr_update_analog_audio_level(chip, 0, i); | 227 | if (chip->mgr->is_hr_stereo) |
228 | hr222_update_analog_audio_level(chip, 0, i); | ||
229 | else | ||
230 | pcxhr_update_analog_audio_level(chip, 0, i); | ||
184 | } | 231 | } |
185 | } | 232 | } |
186 | mutex_unlock(&chip->mgr->mixer_mutex); | 233 | mutex_unlock(&chip->mgr->mixer_mutex); |
@@ -251,7 +298,8 @@ static int pcxhr_update_playback_stream_level(struct snd_pcxhr* chip, int idx) | |||
251 | #define VALID_AUDIO_IO_MUTE_LEVEL 0x000004 | 298 | #define VALID_AUDIO_IO_MUTE_LEVEL 0x000004 |
252 | #define VALID_AUDIO_IO_MUTE_MONITOR_1 0x000008 | 299 | #define VALID_AUDIO_IO_MUTE_MONITOR_1 0x000008 |
253 | 300 | ||
254 | static int pcxhr_update_audio_pipe_level(struct snd_pcxhr* chip, int capture, int channel) | 301 | static int pcxhr_update_audio_pipe_level(struct snd_pcxhr *chip, |
302 | int capture, int channel) | ||
255 | { | 303 | { |
256 | int err; | 304 | int err; |
257 | struct pcxhr_rmh rmh; | 305 | struct pcxhr_rmh rmh; |
@@ -264,18 +312,20 @@ static int pcxhr_update_audio_pipe_level(struct snd_pcxhr* chip, int capture, in | |||
264 | 312 | ||
265 | pcxhr_init_rmh(&rmh, CMD_AUDIO_LEVEL_ADJUST); | 313 | pcxhr_init_rmh(&rmh, CMD_AUDIO_LEVEL_ADJUST); |
266 | /* add channel mask */ | 314 | /* add channel mask */ |
267 | pcxhr_set_pipe_cmd_params(&rmh, capture, 0, 0, 1 << (channel + pipe->first_audio)); | 315 | pcxhr_set_pipe_cmd_params(&rmh, capture, 0, 0, |
268 | /* TODO : if mask (3 << pipe->first_audio) is used, left and right channel | 316 | 1 << (channel + pipe->first_audio)); |
269 | * will be programmed to the same params | 317 | /* TODO : if mask (3 << pipe->first_audio) is used, left and right |
270 | */ | 318 | * channel will be programmed to the same params */ |
271 | if (capture) { | 319 | if (capture) { |
272 | rmh.cmd[0] |= VALID_AUDIO_IO_DIGITAL_LEVEL; | 320 | rmh.cmd[0] |= VALID_AUDIO_IO_DIGITAL_LEVEL; |
273 | /* VALID_AUDIO_IO_MUTE_LEVEL not yet handled (capture pipe level) */ | 321 | /* VALID_AUDIO_IO_MUTE_LEVEL not yet handled |
322 | * (capture pipe level) */ | ||
274 | rmh.cmd[2] = chip->digital_capture_volume[channel]; | 323 | rmh.cmd[2] = chip->digital_capture_volume[channel]; |
275 | } else { | 324 | } else { |
276 | rmh.cmd[0] |= VALID_AUDIO_IO_MONITOR_LEVEL | VALID_AUDIO_IO_MUTE_MONITOR_1; | 325 | rmh.cmd[0] |= VALID_AUDIO_IO_MONITOR_LEVEL | |
277 | /* VALID_AUDIO_IO_DIGITAL_LEVEL and VALID_AUDIO_IO_MUTE_LEVEL not yet | 326 | VALID_AUDIO_IO_MUTE_MONITOR_1; |
278 | * handled (playback pipe level) | 327 | /* VALID_AUDIO_IO_DIGITAL_LEVEL and VALID_AUDIO_IO_MUTE_LEVEL |
328 | * not yet handled (playback pipe level) | ||
279 | */ | 329 | */ |
280 | rmh.cmd[2] = chip->monitoring_volume[channel] << 10; | 330 | rmh.cmd[2] = chip->monitoring_volume[channel] << 10; |
281 | if (chip->monitoring_active[channel] == 0) | 331 | if (chip->monitoring_active[channel] == 0) |
@@ -284,8 +334,8 @@ static int pcxhr_update_audio_pipe_level(struct snd_pcxhr* chip, int capture, in | |||
284 | rmh.cmd_len = 3; | 334 | rmh.cmd_len = 3; |
285 | 335 | ||
286 | err = pcxhr_send_msg(chip->mgr, &rmh); | 336 | err = pcxhr_send_msg(chip->mgr, &rmh); |
287 | if(err<0) { | 337 | if (err < 0) { |
288 | snd_printk(KERN_DEBUG "error update_audio_level card(%d) err(%x)\n", | 338 | snd_printk(KERN_DEBUG "error update_audio_level(%d) err=%x\n", |
289 | chip->chip_idx, err); | 339 | chip->chip_idx, err); |
290 | return -EINVAL; | 340 | return -EINVAL; |
291 | } | 341 | } |
@@ -309,15 +359,15 @@ static int pcxhr_pcm_vol_get(struct snd_kcontrol *kcontrol, | |||
309 | struct snd_ctl_elem_value *ucontrol) | 359 | struct snd_ctl_elem_value *ucontrol) |
310 | { | 360 | { |
311 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | 361 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); |
312 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ | 362 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ |
313 | int *stored_volume; | 363 | int *stored_volume; |
314 | int is_capture = kcontrol->private_value; | 364 | int is_capture = kcontrol->private_value; |
315 | 365 | ||
316 | mutex_lock(&chip->mgr->mixer_mutex); | 366 | mutex_lock(&chip->mgr->mixer_mutex); |
317 | if (is_capture) | 367 | if (is_capture) /* digital capture */ |
318 | stored_volume = chip->digital_capture_volume; /* digital capture */ | 368 | stored_volume = chip->digital_capture_volume; |
319 | else | 369 | else /* digital playback */ |
320 | stored_volume = chip->digital_playback_volume[idx]; /* digital playback */ | 370 | stored_volume = chip->digital_playback_volume[idx]; |
321 | ucontrol->value.integer.value[0] = stored_volume[0]; | 371 | ucontrol->value.integer.value[0] = stored_volume[0]; |
322 | ucontrol->value.integer.value[1] = stored_volume[1]; | 372 | ucontrol->value.integer.value[1] = stored_volume[1]; |
323 | mutex_unlock(&chip->mgr->mixer_mutex); | 373 | mutex_unlock(&chip->mgr->mixer_mutex); |
@@ -328,7 +378,7 @@ static int pcxhr_pcm_vol_put(struct snd_kcontrol *kcontrol, | |||
328 | struct snd_ctl_elem_value *ucontrol) | 378 | struct snd_ctl_elem_value *ucontrol) |
329 | { | 379 | { |
330 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | 380 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); |
331 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ | 381 | int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); /* index */ |
332 | int changed = 0; | 382 | int changed = 0; |
333 | int is_capture = kcontrol->private_value; | 383 | int is_capture = kcontrol->private_value; |
334 | int *stored_volume; | 384 | int *stored_volume; |
@@ -384,7 +434,8 @@ static int pcxhr_pcm_sw_get(struct snd_kcontrol *kcontrol, | |||
384 | return 0; | 434 | return 0; |
385 | } | 435 | } |
386 | 436 | ||
387 | static int pcxhr_pcm_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 437 | static int pcxhr_pcm_sw_put(struct snd_kcontrol *kcontrol, |
438 | struct snd_ctl_elem_value *ucontrol) | ||
388 | { | 439 | { |
389 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | 440 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); |
390 | int changed = 0; | 441 | int changed = 0; |
@@ -444,8 +495,8 @@ static int pcxhr_monitor_vol_put(struct snd_kcontrol *kcontrol, | |||
444 | if (chip->monitoring_volume[i] != | 495 | if (chip->monitoring_volume[i] != |
445 | ucontrol->value.integer.value[i]) { | 496 | ucontrol->value.integer.value[i]) { |
446 | chip->monitoring_volume[i] = | 497 | chip->monitoring_volume[i] = |
447 | !!ucontrol->value.integer.value[i]; | 498 | ucontrol->value.integer.value[i]; |
448 | if(chip->monitoring_active[i]) | 499 | if (chip->monitoring_active[i]) |
449 | /* update monitoring volume and mute */ | 500 | /* update monitoring volume and mute */ |
450 | /* do only when monitoring is unmuted */ | 501 | /* do only when monitoring is unmuted */ |
451 | pcxhr_update_audio_pipe_level(chip, 0, i); | 502 | pcxhr_update_audio_pipe_level(chip, 0, i); |
@@ -460,7 +511,7 @@ static struct snd_kcontrol_new pcxhr_control_monitor_vol = { | |||
460 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 511 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
461 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | | 512 | .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE | |
462 | SNDRV_CTL_ELEM_ACCESS_TLV_READ), | 513 | SNDRV_CTL_ELEM_ACCESS_TLV_READ), |
463 | .name = "Monitoring Volume", | 514 | .name = "Monitoring Playback Volume", |
464 | .info = pcxhr_digital_vol_info, /* shared */ | 515 | .info = pcxhr_digital_vol_info, /* shared */ |
465 | .get = pcxhr_monitor_vol_get, | 516 | .get = pcxhr_monitor_vol_get, |
466 | .put = pcxhr_monitor_vol_put, | 517 | .put = pcxhr_monitor_vol_put, |
@@ -511,7 +562,7 @@ static int pcxhr_monitor_sw_put(struct snd_kcontrol *kcontrol, | |||
511 | 562 | ||
512 | static struct snd_kcontrol_new pcxhr_control_monitor_sw = { | 563 | static struct snd_kcontrol_new pcxhr_control_monitor_sw = { |
513 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 564 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
514 | .name = "Monitoring Switch", | 565 | .name = "Monitoring Playback Switch", |
515 | .info = pcxhr_sw_info, /* shared */ | 566 | .info = pcxhr_sw_info, /* shared */ |
516 | .get = pcxhr_monitor_sw_get, | 567 | .get = pcxhr_monitor_sw_get, |
517 | .put = pcxhr_monitor_sw_put | 568 | .put = pcxhr_monitor_sw_put |
@@ -533,7 +584,7 @@ static int pcxhr_set_audio_source(struct snd_pcxhr* chip) | |||
533 | struct pcxhr_rmh rmh; | 584 | struct pcxhr_rmh rmh; |
534 | unsigned int mask, reg; | 585 | unsigned int mask, reg; |
535 | unsigned int codec; | 586 | unsigned int codec; |
536 | int err, use_src, changed; | 587 | int err, changed; |
537 | 588 | ||
538 | switch (chip->chip_idx) { | 589 | switch (chip->chip_idx) { |
539 | case 0 : mask = PCXHR_SOURCE_AUDIO01_UER; codec = CS8420_01_CS; break; | 590 | case 0 : mask = PCXHR_SOURCE_AUDIO01_UER; codec = CS8420_01_CS; break; |
@@ -542,13 +593,10 @@ static int pcxhr_set_audio_source(struct snd_pcxhr* chip) | |||
542 | case 3 : mask = PCXHR_SOURCE_AUDIO67_UER; codec = CS8420_67_CS; break; | 593 | case 3 : mask = PCXHR_SOURCE_AUDIO67_UER; codec = CS8420_67_CS; break; |
543 | default: return -EINVAL; | 594 | default: return -EINVAL; |
544 | } | 595 | } |
545 | reg = 0; /* audio source from analog plug */ | ||
546 | use_src = 0; /* do not activate codec SRC */ | ||
547 | |||
548 | if (chip->audio_capture_source != 0) { | 596 | if (chip->audio_capture_source != 0) { |
549 | reg = mask; /* audio source from digital plug */ | 597 | reg = mask; /* audio source from digital plug */ |
550 | if (chip->audio_capture_source == 2) | 598 | } else { |
551 | use_src = 1; | 599 | reg = 0; /* audio source from analog plug */ |
552 | } | 600 | } |
553 | /* set the input source */ | 601 | /* set the input source */ |
554 | pcxhr_write_io_num_reg_cont(chip->mgr, mask, reg, &changed); | 602 | pcxhr_write_io_num_reg_cont(chip->mgr, mask, reg, &changed); |
@@ -560,29 +608,61 @@ static int pcxhr_set_audio_source(struct snd_pcxhr* chip) | |||
560 | if (err) | 608 | if (err) |
561 | return err; | 609 | return err; |
562 | } | 610 | } |
563 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); /* set codec SRC on off */ | 611 | if (chip->mgr->board_aes_in_192k) { |
564 | rmh.cmd_len = 3; | 612 | int i; |
565 | rmh.cmd[0] |= IO_NUM_UER_CHIP_REG; | 613 | unsigned int src_config = 0xC0; |
566 | rmh.cmd[1] = codec; | 614 | /* update all src configs with one call */ |
567 | rmh.cmd[2] = (CS8420_DATA_FLOW_CTL & CHIP_SIG_AND_MAP_SPI) | (use_src ? 0x41 : 0x54); | 615 | for (i = 0; (i < 4) && (i < chip->mgr->capture_chips); i++) { |
568 | err = pcxhr_send_msg(chip->mgr, &rmh); | 616 | if (chip->mgr->chip[i]->audio_capture_source == 2) |
569 | if(err) | 617 | src_config |= (1 << (3 - i)); |
570 | return err; | 618 | } |
571 | rmh.cmd[2] = (CS8420_CLOCK_SRC_CTL & CHIP_SIG_AND_MAP_SPI) | (use_src ? 0x41 : 0x49); | 619 | /* set codec SRC on off */ |
572 | err = pcxhr_send_msg(chip->mgr, &rmh); | 620 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); |
621 | rmh.cmd_len = 2; | ||
622 | rmh.cmd[0] |= IO_NUM_REG_CONFIG_SRC; | ||
623 | rmh.cmd[1] = src_config; | ||
624 | err = pcxhr_send_msg(chip->mgr, &rmh); | ||
625 | } else { | ||
626 | int use_src = 0; | ||
627 | if (chip->audio_capture_source == 2) | ||
628 | use_src = 1; | ||
629 | /* set codec SRC on off */ | ||
630 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); | ||
631 | rmh.cmd_len = 3; | ||
632 | rmh.cmd[0] |= IO_NUM_UER_CHIP_REG; | ||
633 | rmh.cmd[1] = codec; | ||
634 | rmh.cmd[2] = ((CS8420_DATA_FLOW_CTL & CHIP_SIG_AND_MAP_SPI) | | ||
635 | (use_src ? 0x41 : 0x54)); | ||
636 | err = pcxhr_send_msg(chip->mgr, &rmh); | ||
637 | if (err) | ||
638 | return err; | ||
639 | rmh.cmd[2] = ((CS8420_CLOCK_SRC_CTL & CHIP_SIG_AND_MAP_SPI) | | ||
640 | (use_src ? 0x41 : 0x49)); | ||
641 | err = pcxhr_send_msg(chip->mgr, &rmh); | ||
642 | } | ||
573 | return err; | 643 | return err; |
574 | } | 644 | } |
575 | 645 | ||
576 | static int pcxhr_audio_src_info(struct snd_kcontrol *kcontrol, | 646 | static int pcxhr_audio_src_info(struct snd_kcontrol *kcontrol, |
577 | struct snd_ctl_elem_info *uinfo) | 647 | struct snd_ctl_elem_info *uinfo) |
578 | { | 648 | { |
579 | static char *texts[3] = {"Analog", "Digital", "Digi+SRC"}; | 649 | static const char *texts[5] = { |
650 | "Line", "Digital", "Digi+SRC", "Mic", "Line+Mic" | ||
651 | }; | ||
652 | int i; | ||
653 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | ||
580 | 654 | ||
655 | i = 2; /* no SRC, no Mic available */ | ||
656 | if (chip->mgr->board_has_aes1) { | ||
657 | i = 3; /* SRC available */ | ||
658 | if (chip->mgr->board_has_mic) | ||
659 | i = 5; /* Mic and MicroMix available */ | ||
660 | } | ||
581 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 661 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
582 | uinfo->count = 1; | 662 | uinfo->count = 1; |
583 | uinfo->value.enumerated.items = 3; | 663 | uinfo->value.enumerated.items = i; |
584 | if (uinfo->value.enumerated.item > 2) | 664 | if (uinfo->value.enumerated.item > (i-1)) |
585 | uinfo->value.enumerated.item = 2; | 665 | uinfo->value.enumerated.item = i-1; |
586 | strcpy(uinfo->value.enumerated.name, | 666 | strcpy(uinfo->value.enumerated.name, |
587 | texts[uinfo->value.enumerated.item]); | 667 | texts[uinfo->value.enumerated.item]); |
588 | return 0; | 668 | return 0; |
@@ -601,13 +681,21 @@ static int pcxhr_audio_src_put(struct snd_kcontrol *kcontrol, | |||
601 | { | 681 | { |
602 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | 682 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); |
603 | int ret = 0; | 683 | int ret = 0; |
604 | 684 | int i = 2; /* no SRC, no Mic available */ | |
605 | if (ucontrol->value.enumerated.item[0] >= 3) | 685 | if (chip->mgr->board_has_aes1) { |
686 | i = 3; /* SRC available */ | ||
687 | if (chip->mgr->board_has_mic) | ||
688 | i = 5; /* Mic and MicroMix available */ | ||
689 | } | ||
690 | if (ucontrol->value.enumerated.item[0] >= i) | ||
606 | return -EINVAL; | 691 | return -EINVAL; |
607 | mutex_lock(&chip->mgr->mixer_mutex); | 692 | mutex_lock(&chip->mgr->mixer_mutex); |
608 | if (chip->audio_capture_source != ucontrol->value.enumerated.item[0]) { | 693 | if (chip->audio_capture_source != ucontrol->value.enumerated.item[0]) { |
609 | chip->audio_capture_source = ucontrol->value.enumerated.item[0]; | 694 | chip->audio_capture_source = ucontrol->value.enumerated.item[0]; |
610 | pcxhr_set_audio_source(chip); | 695 | if (chip->mgr->is_hr_stereo) |
696 | hr222_set_audio_source(chip); | ||
697 | else | ||
698 | pcxhr_set_audio_source(chip); | ||
611 | ret = 1; | 699 | ret = 1; |
612 | } | 700 | } |
613 | mutex_unlock(&chip->mgr->mixer_mutex); | 701 | mutex_unlock(&chip->mgr->mixer_mutex); |
@@ -626,25 +714,46 @@ static struct snd_kcontrol_new pcxhr_control_audio_src = { | |||
626 | /* | 714 | /* |
627 | * clock type selection | 715 | * clock type selection |
628 | * enum pcxhr_clock_type { | 716 | * enum pcxhr_clock_type { |
629 | * PCXHR_CLOCK_TYPE_INTERNAL = 0, | 717 | * PCXHR_CLOCK_TYPE_INTERNAL = 0, |
630 | * PCXHR_CLOCK_TYPE_WORD_CLOCK, | 718 | * PCXHR_CLOCK_TYPE_WORD_CLOCK, |
631 | * PCXHR_CLOCK_TYPE_AES_SYNC, | 719 | * PCXHR_CLOCK_TYPE_AES_SYNC, |
632 | * PCXHR_CLOCK_TYPE_AES_1, | 720 | * PCXHR_CLOCK_TYPE_AES_1, |
633 | * PCXHR_CLOCK_TYPE_AES_2, | 721 | * PCXHR_CLOCK_TYPE_AES_2, |
634 | * PCXHR_CLOCK_TYPE_AES_3, | 722 | * PCXHR_CLOCK_TYPE_AES_3, |
635 | * PCXHR_CLOCK_TYPE_AES_4, | 723 | * PCXHR_CLOCK_TYPE_AES_4, |
636 | * }; | 724 | * PCXHR_CLOCK_TYPE_MAX = PCXHR_CLOCK_TYPE_AES_4, |
725 | * HR22_CLOCK_TYPE_INTERNAL = PCXHR_CLOCK_TYPE_INTERNAL, | ||
726 | * HR22_CLOCK_TYPE_AES_SYNC, | ||
727 | * HR22_CLOCK_TYPE_AES_1, | ||
728 | * HR22_CLOCK_TYPE_MAX = HR22_CLOCK_TYPE_AES_1, | ||
729 | * }; | ||
637 | */ | 730 | */ |
638 | 731 | ||
639 | static int pcxhr_clock_type_info(struct snd_kcontrol *kcontrol, | 732 | static int pcxhr_clock_type_info(struct snd_kcontrol *kcontrol, |
640 | struct snd_ctl_elem_info *uinfo) | 733 | struct snd_ctl_elem_info *uinfo) |
641 | { | 734 | { |
642 | static char *texts[7] = { | 735 | static const char *textsPCXHR[7] = { |
643 | "Internal", "WordClock", "AES Sync", "AES 1", "AES 2", "AES 3", "AES 4" | 736 | "Internal", "WordClock", "AES Sync", |
737 | "AES 1", "AES 2", "AES 3", "AES 4" | ||
738 | }; | ||
739 | static const char *textsHR22[3] = { | ||
740 | "Internal", "AES Sync", "AES 1" | ||
644 | }; | 741 | }; |
742 | const char **texts; | ||
645 | struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); | 743 | struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); |
646 | int clock_items = 3 + mgr->capture_chips; | 744 | int clock_items = 2; /* at least Internal and AES Sync clock */ |
647 | 745 | if (mgr->board_has_aes1) { | |
746 | clock_items += mgr->capture_chips; /* add AES x */ | ||
747 | if (!mgr->is_hr_stereo) | ||
748 | clock_items += 1; /* add word clock */ | ||
749 | } | ||
750 | if (mgr->is_hr_stereo) { | ||
751 | texts = textsHR22; | ||
752 | snd_BUG_ON(clock_items > (HR22_CLOCK_TYPE_MAX+1)); | ||
753 | } else { | ||
754 | texts = textsPCXHR; | ||
755 | snd_BUG_ON(clock_items > (PCXHR_CLOCK_TYPE_MAX+1)); | ||
756 | } | ||
648 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 757 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
649 | uinfo->count = 1; | 758 | uinfo->count = 1; |
650 | uinfo->value.enumerated.items = clock_items; | 759 | uinfo->value.enumerated.items = clock_items; |
@@ -667,9 +776,13 @@ static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol, | |||
667 | struct snd_ctl_elem_value *ucontrol) | 776 | struct snd_ctl_elem_value *ucontrol) |
668 | { | 777 | { |
669 | struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); | 778 | struct pcxhr_mgr *mgr = snd_kcontrol_chip(kcontrol); |
670 | unsigned int clock_items = 3 + mgr->capture_chips; | ||
671 | int rate, ret = 0; | 779 | int rate, ret = 0; |
672 | 780 | unsigned int clock_items = 2; /* at least Internal and AES Sync clock */ | |
781 | if (mgr->board_has_aes1) { | ||
782 | clock_items += mgr->capture_chips; /* add AES x */ | ||
783 | if (!mgr->is_hr_stereo) | ||
784 | clock_items += 1; /* add word clock */ | ||
785 | } | ||
673 | if (ucontrol->value.enumerated.item[0] >= clock_items) | 786 | if (ucontrol->value.enumerated.item[0] >= clock_items) |
674 | return -EINVAL; | 787 | return -EINVAL; |
675 | mutex_lock(&mgr->mixer_mutex); | 788 | mutex_lock(&mgr->mixer_mutex); |
@@ -677,7 +790,8 @@ static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol, | |||
677 | mutex_lock(&mgr->setup_mutex); | 790 | mutex_lock(&mgr->setup_mutex); |
678 | mgr->use_clock_type = ucontrol->value.enumerated.item[0]; | 791 | mgr->use_clock_type = ucontrol->value.enumerated.item[0]; |
679 | if (mgr->use_clock_type) | 792 | if (mgr->use_clock_type) |
680 | pcxhr_get_external_clock(mgr, mgr->use_clock_type, &rate); | 793 | pcxhr_get_external_clock(mgr, mgr->use_clock_type, |
794 | &rate); | ||
681 | else | 795 | else |
682 | rate = mgr->sample_rate; | 796 | rate = mgr->sample_rate; |
683 | if (rate) { | 797 | if (rate) { |
@@ -686,7 +800,7 @@ static int pcxhr_clock_type_put(struct snd_kcontrol *kcontrol, | |||
686 | mgr->sample_rate = rate; | 800 | mgr->sample_rate = rate; |
687 | } | 801 | } |
688 | mutex_unlock(&mgr->setup_mutex); | 802 | mutex_unlock(&mgr->setup_mutex); |
689 | ret = 1; /* return 1 even if the set was not done. ok ? */ | 803 | ret = 1; /* return 1 even if the set was not done. ok ? */ |
690 | } | 804 | } |
691 | mutex_unlock(&mgr->mixer_mutex); | 805 | mutex_unlock(&mgr->mixer_mutex); |
692 | return ret; | 806 | return ret; |
@@ -747,14 +861,16 @@ static struct snd_kcontrol_new pcxhr_control_clock_rate = { | |||
747 | /* | 861 | /* |
748 | * IEC958 status bits | 862 | * IEC958 status bits |
749 | */ | 863 | */ |
750 | static int pcxhr_iec958_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) | 864 | static int pcxhr_iec958_info(struct snd_kcontrol *kcontrol, |
865 | struct snd_ctl_elem_info *uinfo) | ||
751 | { | 866 | { |
752 | uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; | 867 | uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; |
753 | uinfo->count = 1; | 868 | uinfo->count = 1; |
754 | return 0; | 869 | return 0; |
755 | } | 870 | } |
756 | 871 | ||
757 | static int pcxhr_iec958_capture_byte(struct snd_pcxhr *chip, int aes_idx, unsigned char* aes_bits) | 872 | static int pcxhr_iec958_capture_byte(struct snd_pcxhr *chip, |
873 | int aes_idx, unsigned char *aes_bits) | ||
758 | { | 874 | { |
759 | int i, err; | 875 | int i, err; |
760 | unsigned char temp; | 876 | unsigned char temp; |
@@ -763,39 +879,61 @@ static int pcxhr_iec958_capture_byte(struct snd_pcxhr *chip, int aes_idx, unsign | |||
763 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); | 879 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_READ); |
764 | rmh.cmd[0] |= IO_NUM_UER_CHIP_REG; | 880 | rmh.cmd[0] |= IO_NUM_UER_CHIP_REG; |
765 | switch (chip->chip_idx) { | 881 | switch (chip->chip_idx) { |
766 | case 0: rmh.cmd[1] = CS8420_01_CS; break; /* use CS8416_01_CS for AES SYNC plug */ | 882 | /* instead of CS8420_01_CS use CS8416_01_CS for AES SYNC plug */ |
883 | case 0: rmh.cmd[1] = CS8420_01_CS; break; | ||
767 | case 1: rmh.cmd[1] = CS8420_23_CS; break; | 884 | case 1: rmh.cmd[1] = CS8420_23_CS; break; |
768 | case 2: rmh.cmd[1] = CS8420_45_CS; break; | 885 | case 2: rmh.cmd[1] = CS8420_45_CS; break; |
769 | case 3: rmh.cmd[1] = CS8420_67_CS; break; | 886 | case 3: rmh.cmd[1] = CS8420_67_CS; break; |
770 | default: return -EINVAL; | 887 | default: return -EINVAL; |
771 | } | 888 | } |
772 | switch (aes_idx) { | 889 | if (chip->mgr->board_aes_in_192k) { |
773 | case 0: rmh.cmd[2] = CS8420_CSB0; break; /* use CS8416_CSBx for AES SYNC plug */ | 890 | switch (aes_idx) { |
774 | case 1: rmh.cmd[2] = CS8420_CSB1; break; | 891 | case 0: rmh.cmd[2] = CS8416_CSB0; break; |
775 | case 2: rmh.cmd[2] = CS8420_CSB2; break; | 892 | case 1: rmh.cmd[2] = CS8416_CSB1; break; |
776 | case 3: rmh.cmd[2] = CS8420_CSB3; break; | 893 | case 2: rmh.cmd[2] = CS8416_CSB2; break; |
777 | case 4: rmh.cmd[2] = CS8420_CSB4; break; | 894 | case 3: rmh.cmd[2] = CS8416_CSB3; break; |
778 | default: return -EINVAL; | 895 | case 4: rmh.cmd[2] = CS8416_CSB4; break; |
896 | default: return -EINVAL; | ||
897 | } | ||
898 | } else { | ||
899 | switch (aes_idx) { | ||
900 | /* instead of CS8420_CSB0 use CS8416_CSBx for AES SYNC plug */ | ||
901 | case 0: rmh.cmd[2] = CS8420_CSB0; break; | ||
902 | case 1: rmh.cmd[2] = CS8420_CSB1; break; | ||
903 | case 2: rmh.cmd[2] = CS8420_CSB2; break; | ||
904 | case 3: rmh.cmd[2] = CS8420_CSB3; break; | ||
905 | case 4: rmh.cmd[2] = CS8420_CSB4; break; | ||
906 | default: return -EINVAL; | ||
907 | } | ||
779 | } | 908 | } |
780 | rmh.cmd[1] &= 0x0fffff; /* size and code the chip id for the fpga */ | 909 | /* size and code the chip id for the fpga */ |
781 | rmh.cmd[2] &= CHIP_SIG_AND_MAP_SPI; /* chip signature + map for spi read */ | 910 | rmh.cmd[1] &= 0x0fffff; |
911 | /* chip signature + map for spi read */ | ||
912 | rmh.cmd[2] &= CHIP_SIG_AND_MAP_SPI; | ||
782 | rmh.cmd_len = 3; | 913 | rmh.cmd_len = 3; |
783 | err = pcxhr_send_msg(chip->mgr, &rmh); | 914 | err = pcxhr_send_msg(chip->mgr, &rmh); |
784 | if (err) | 915 | if (err) |
785 | return err; | 916 | return err; |
786 | temp = 0; | 917 | |
787 | for (i = 0; i < 8; i++) { | 918 | if (chip->mgr->board_aes_in_192k) { |
788 | /* attention : reversed bit order (not with CS8416_01_CS) */ | 919 | temp = (unsigned char)rmh.stat[1]; |
789 | temp <<= 1; | 920 | } else { |
790 | if (rmh.stat[1] & (1 << i)) | 921 | temp = 0; |
791 | temp |= 1; | 922 | /* reversed bit order (not with CS8416_01_CS) */ |
923 | for (i = 0; i < 8; i++) { | ||
924 | temp <<= 1; | ||
925 | if (rmh.stat[1] & (1 << i)) | ||
926 | temp |= 1; | ||
927 | } | ||
792 | } | 928 | } |
793 | snd_printdd("read iec958 AES %d byte %d = 0x%x\n", chip->chip_idx, aes_idx, temp); | 929 | snd_printdd("read iec958 AES %d byte %d = 0x%x\n", |
930 | chip->chip_idx, aes_idx, temp); | ||
794 | *aes_bits = temp; | 931 | *aes_bits = temp; |
795 | return 0; | 932 | return 0; |
796 | } | 933 | } |
797 | 934 | ||
798 | static int pcxhr_iec958_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 935 | static int pcxhr_iec958_get(struct snd_kcontrol *kcontrol, |
936 | struct snd_ctl_elem_value *ucontrol) | ||
799 | { | 937 | { |
800 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); | 938 | struct snd_pcxhr *chip = snd_kcontrol_chip(kcontrol); |
801 | unsigned char aes_bits; | 939 | unsigned char aes_bits; |
@@ -806,7 +944,12 @@ static int pcxhr_iec958_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v | |||
806 | if (kcontrol->private_value == 0) /* playback */ | 944 | if (kcontrol->private_value == 0) /* playback */ |
807 | aes_bits = chip->aes_bits[i]; | 945 | aes_bits = chip->aes_bits[i]; |
808 | else { /* capture */ | 946 | else { /* capture */ |
809 | err = pcxhr_iec958_capture_byte(chip, i, &aes_bits); | 947 | if (chip->mgr->is_hr_stereo) |
948 | err = hr222_iec958_capture_byte(chip, i, | ||
949 | &aes_bits); | ||
950 | else | ||
951 | err = pcxhr_iec958_capture_byte(chip, i, | ||
952 | &aes_bits); | ||
810 | if (err) | 953 | if (err) |
811 | break; | 954 | break; |
812 | } | 955 | } |
@@ -825,7 +968,8 @@ static int pcxhr_iec958_mask_get(struct snd_kcontrol *kcontrol, | |||
825 | return 0; | 968 | return 0; |
826 | } | 969 | } |
827 | 970 | ||
828 | static int pcxhr_iec958_update_byte(struct snd_pcxhr *chip, int aes_idx, unsigned char aes_bits) | 971 | static int pcxhr_iec958_update_byte(struct snd_pcxhr *chip, |
972 | int aes_idx, unsigned char aes_bits) | ||
829 | { | 973 | { |
830 | int i, err, cmd; | 974 | int i, err, cmd; |
831 | unsigned char new_bits = aes_bits; | 975 | unsigned char new_bits = aes_bits; |
@@ -834,12 +978,12 @@ static int pcxhr_iec958_update_byte(struct snd_pcxhr *chip, int aes_idx, unsigne | |||
834 | 978 | ||
835 | for (i = 0; i < 8; i++) { | 979 | for (i = 0; i < 8; i++) { |
836 | if ((old_bits & 0x01) != (new_bits & 0x01)) { | 980 | if ((old_bits & 0x01) != (new_bits & 0x01)) { |
837 | cmd = chip->chip_idx & 0x03; /* chip index 0..3 */ | 981 | cmd = chip->chip_idx & 0x03; /* chip index 0..3 */ |
838 | if(chip->chip_idx > 3) | 982 | if (chip->chip_idx > 3) |
839 | /* new bit used if chip_idx>3 (PCX1222HR) */ | 983 | /* new bit used if chip_idx>3 (PCX1222HR) */ |
840 | cmd |= 1 << 22; | 984 | cmd |= 1 << 22; |
841 | cmd |= ((aes_idx << 3) + i) << 2; /* add bit offset */ | 985 | cmd |= ((aes_idx << 3) + i) << 2; /* add bit offset */ |
842 | cmd |= (new_bits & 0x01) << 23; /* add bit value */ | 986 | cmd |= (new_bits & 0x01) << 23; /* add bit value */ |
843 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); | 987 | pcxhr_init_rmh(&rmh, CMD_ACCESS_IO_WRITE); |
844 | rmh.cmd[0] |= IO_NUM_REG_CUER; | 988 | rmh.cmd[0] |= IO_NUM_REG_CUER; |
845 | rmh.cmd[1] = cmd; | 989 | rmh.cmd[1] = cmd; |
@@ -867,7 +1011,12 @@ static int pcxhr_iec958_put(struct snd_kcontrol *kcontrol, | |||
867 | mutex_lock(&chip->mgr->mixer_mutex); | 1011 | mutex_lock(&chip->mgr->mixer_mutex); |
868 | for (i = 0; i < 5; i++) { | 1012 | for (i = 0; i < 5; i++) { |
869 | if (ucontrol->value.iec958.status[i] != chip->aes_bits[i]) { | 1013 | if (ucontrol->value.iec958.status[i] != chip->aes_bits[i]) { |
870 | pcxhr_iec958_update_byte(chip, i, ucontrol->value.iec958.status[i]); | 1014 | if (chip->mgr->is_hr_stereo) |
1015 | hr222_iec958_update_byte(chip, i, | ||
1016 | ucontrol->value.iec958.status[i]); | ||
1017 | else | ||
1018 | pcxhr_iec958_update_byte(chip, i, | ||
1019 | ucontrol->value.iec958.status[i]); | ||
871 | changed = 1; | 1020 | changed = 1; |
872 | } | 1021 | } |
873 | } | 1022 | } |
@@ -917,29 +1066,53 @@ static void pcxhr_init_audio_levels(struct snd_pcxhr *chip) | |||
917 | /* at boot time the digital volumes are unmuted 0dB */ | 1066 | /* at boot time the digital volumes are unmuted 0dB */ |
918 | for (j = 0; j < PCXHR_PLAYBACK_STREAMS; j++) { | 1067 | for (j = 0; j < PCXHR_PLAYBACK_STREAMS; j++) { |
919 | chip->digital_playback_active[j][i] = 1; | 1068 | chip->digital_playback_active[j][i] = 1; |
920 | chip->digital_playback_volume[j][i] = PCXHR_DIGITAL_ZERO_LEVEL; | 1069 | chip->digital_playback_volume[j][i] = |
1070 | PCXHR_DIGITAL_ZERO_LEVEL; | ||
921 | } | 1071 | } |
922 | /* after boot, only two bits are set on the uer interface */ | 1072 | /* after boot, only two bits are set on the uer |
923 | chip->aes_bits[0] = IEC958_AES0_PROFESSIONAL | IEC958_AES0_PRO_FS_48000; | 1073 | * interface |
924 | /* only for test purpose, remove later */ | 1074 | */ |
1075 | chip->aes_bits[0] = (IEC958_AES0_PROFESSIONAL | | ||
1076 | IEC958_AES0_PRO_FS_48000); | ||
925 | #ifdef CONFIG_SND_DEBUG | 1077 | #ifdef CONFIG_SND_DEBUG |
926 | /* analog volumes for playback (is LEVEL_MIN after boot) */ | 1078 | /* analog volumes for playback |
1079 | * (is LEVEL_MIN after boot) | ||
1080 | */ | ||
927 | chip->analog_playback_active[i] = 1; | 1081 | chip->analog_playback_active[i] = 1; |
928 | chip->analog_playback_volume[i] = PCXHR_ANALOG_PLAYBACK_ZERO_LEVEL; | 1082 | if (chip->mgr->is_hr_stereo) |
929 | pcxhr_update_analog_audio_level(chip, 0, i); | 1083 | chip->analog_playback_volume[i] = |
1084 | HR222_LINE_PLAYBACK_ZERO_LEVEL; | ||
1085 | else { | ||
1086 | chip->analog_playback_volume[i] = | ||
1087 | PCXHR_LINE_PLAYBACK_ZERO_LEVEL; | ||
1088 | pcxhr_update_analog_audio_level(chip, 0, i); | ||
1089 | } | ||
930 | #endif | 1090 | #endif |
931 | /* test end */ | 1091 | /* stereo cards need to be initialised after boot */ |
1092 | if (chip->mgr->is_hr_stereo) | ||
1093 | hr222_update_analog_audio_level(chip, 0, i); | ||
932 | } | 1094 | } |
933 | if (chip->nb_streams_capt) { | 1095 | if (chip->nb_streams_capt) { |
934 | /* at boot time the digital volumes are unmuted 0dB */ | 1096 | /* at boot time the digital volumes are unmuted 0dB */ |
935 | chip->digital_capture_volume[i] = PCXHR_DIGITAL_ZERO_LEVEL; | 1097 | chip->digital_capture_volume[i] = |
936 | /* only for test purpose, remove later */ | 1098 | PCXHR_DIGITAL_ZERO_LEVEL; |
1099 | chip->analog_capture_active = 1; | ||
937 | #ifdef CONFIG_SND_DEBUG | 1100 | #ifdef CONFIG_SND_DEBUG |
938 | /* analog volumes for playback (is LEVEL_MIN after boot) */ | 1101 | /* analog volumes for playback |
939 | chip->analog_capture_volume[i] = PCXHR_ANALOG_CAPTURE_ZERO_LEVEL; | 1102 | * (is LEVEL_MIN after boot) |
940 | pcxhr_update_analog_audio_level(chip, 1, i); | 1103 | */ |
1104 | if (chip->mgr->is_hr_stereo) | ||
1105 | chip->analog_capture_volume[i] = | ||
1106 | HR222_LINE_CAPTURE_ZERO_LEVEL; | ||
1107 | else { | ||
1108 | chip->analog_capture_volume[i] = | ||
1109 | PCXHR_LINE_CAPTURE_ZERO_LEVEL; | ||
1110 | pcxhr_update_analog_audio_level(chip, 1, i); | ||
1111 | } | ||
941 | #endif | 1112 | #endif |
942 | /* test end */ | 1113 | /* stereo cards need to be initialised after boot */ |
1114 | if (chip->mgr->is_hr_stereo) | ||
1115 | hr222_update_analog_audio_level(chip, 1, i); | ||
943 | } | 1116 | } |
944 | } | 1117 | } |
945 | 1118 | ||
@@ -963,90 +1136,125 @@ int pcxhr_create_mixer(struct pcxhr_mgr *mgr) | |||
963 | temp = pcxhr_control_analog_level; | 1136 | temp = pcxhr_control_analog_level; |
964 | temp.name = "Master Playback Volume"; | 1137 | temp.name = "Master Playback Volume"; |
965 | temp.private_value = 0; /* playback */ | 1138 | temp.private_value = 0; /* playback */ |
966 | temp.tlv.p = db_scale_analog_playback; | 1139 | if (mgr->is_hr_stereo) |
967 | if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0) | 1140 | temp.tlv.p = db_scale_a_hr222_playback; |
1141 | else | ||
1142 | temp.tlv.p = db_scale_analog_playback; | ||
1143 | err = snd_ctl_add(chip->card, | ||
1144 | snd_ctl_new1(&temp, chip)); | ||
1145 | if (err < 0) | ||
968 | return err; | 1146 | return err; |
1147 | |||
969 | /* output mute controls */ | 1148 | /* output mute controls */ |
970 | if ((err = snd_ctl_add(chip->card, | 1149 | err = snd_ctl_add(chip->card, |
971 | snd_ctl_new1(&pcxhr_control_output_switch, | 1150 | snd_ctl_new1(&pcxhr_control_output_switch, |
972 | chip))) < 0) | 1151 | chip)); |
1152 | if (err < 0) | ||
973 | return err; | 1153 | return err; |
974 | 1154 | ||
975 | temp = snd_pcxhr_pcm_vol; | 1155 | temp = snd_pcxhr_pcm_vol; |
976 | temp.name = "PCM Playback Volume"; | 1156 | temp.name = "PCM Playback Volume"; |
977 | temp.count = PCXHR_PLAYBACK_STREAMS; | 1157 | temp.count = PCXHR_PLAYBACK_STREAMS; |
978 | temp.private_value = 0; /* playback */ | 1158 | temp.private_value = 0; /* playback */ |
979 | if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0) | 1159 | err = snd_ctl_add(chip->card, |
1160 | snd_ctl_new1(&temp, chip)); | ||
1161 | if (err < 0) | ||
980 | return err; | 1162 | return err; |
981 | 1163 | ||
982 | if ((err = snd_ctl_add(chip->card, | 1164 | err = snd_ctl_add(chip->card, |
983 | snd_ctl_new1(&pcxhr_control_pcm_switch, | 1165 | snd_ctl_new1(&pcxhr_control_pcm_switch, chip)); |
984 | chip))) < 0) | 1166 | if (err < 0) |
985 | return err; | 1167 | return err; |
986 | 1168 | ||
987 | /* IEC958 controls */ | 1169 | /* IEC958 controls */ |
988 | if ((err = snd_ctl_add(chip->card, | 1170 | err = snd_ctl_add(chip->card, |
989 | snd_ctl_new1(&pcxhr_control_playback_iec958_mask, | 1171 | snd_ctl_new1(&pcxhr_control_playback_iec958_mask, |
990 | chip))) < 0) | 1172 | chip)); |
1173 | if (err < 0) | ||
991 | return err; | 1174 | return err; |
992 | if ((err = snd_ctl_add(chip->card, | 1175 | |
993 | snd_ctl_new1(&pcxhr_control_playback_iec958, | 1176 | err = snd_ctl_add(chip->card, |
994 | chip))) < 0) | 1177 | snd_ctl_new1(&pcxhr_control_playback_iec958, |
1178 | chip)); | ||
1179 | if (err < 0) | ||
995 | return err; | 1180 | return err; |
996 | } | 1181 | } |
997 | if (chip->nb_streams_capt) { | 1182 | if (chip->nb_streams_capt) { |
998 | /* analog input level control only on first two chips !*/ | 1183 | /* analog input level control */ |
999 | temp = pcxhr_control_analog_level; | 1184 | temp = pcxhr_control_analog_level; |
1000 | temp.name = "Master Capture Volume"; | 1185 | temp.name = "Line Capture Volume"; |
1001 | temp.private_value = 1; /* capture */ | 1186 | temp.private_value = 1; /* capture */ |
1002 | temp.tlv.p = db_scale_analog_capture; | 1187 | if (mgr->is_hr_stereo) |
1003 | if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0) | 1188 | temp.tlv.p = db_scale_a_hr222_capture; |
1189 | else | ||
1190 | temp.tlv.p = db_scale_analog_capture; | ||
1191 | |||
1192 | err = snd_ctl_add(chip->card, | ||
1193 | snd_ctl_new1(&temp, chip)); | ||
1194 | if (err < 0) | ||
1004 | return err; | 1195 | return err; |
1005 | 1196 | ||
1006 | temp = snd_pcxhr_pcm_vol; | 1197 | temp = snd_pcxhr_pcm_vol; |
1007 | temp.name = "PCM Capture Volume"; | 1198 | temp.name = "PCM Capture Volume"; |
1008 | temp.count = 1; | 1199 | temp.count = 1; |
1009 | temp.private_value = 1; /* capture */ | 1200 | temp.private_value = 1; /* capture */ |
1010 | if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&temp, chip))) < 0) | 1201 | |
1202 | err = snd_ctl_add(chip->card, | ||
1203 | snd_ctl_new1(&temp, chip)); | ||
1204 | if (err < 0) | ||
1011 | return err; | 1205 | return err; |
1206 | |||
1012 | /* Audio source */ | 1207 | /* Audio source */ |
1013 | if ((err = snd_ctl_add(chip->card, | 1208 | err = snd_ctl_add(chip->card, |
1014 | snd_ctl_new1(&pcxhr_control_audio_src, | 1209 | snd_ctl_new1(&pcxhr_control_audio_src, chip)); |
1015 | chip))) < 0) | 1210 | if (err < 0) |
1016 | return err; | 1211 | return err; |
1212 | |||
1017 | /* IEC958 controls */ | 1213 | /* IEC958 controls */ |
1018 | if ((err = snd_ctl_add(chip->card, | 1214 | err = snd_ctl_add(chip->card, |
1019 | snd_ctl_new1(&pcxhr_control_capture_iec958_mask, | 1215 | snd_ctl_new1(&pcxhr_control_capture_iec958_mask, |
1020 | chip))) < 0) | 1216 | chip)); |
1217 | if (err < 0) | ||
1021 | return err; | 1218 | return err; |
1022 | if ((err = snd_ctl_add(chip->card, | 1219 | |
1023 | snd_ctl_new1(&pcxhr_control_capture_iec958, | 1220 | err = snd_ctl_add(chip->card, |
1024 | chip))) < 0) | 1221 | snd_ctl_new1(&pcxhr_control_capture_iec958, |
1222 | chip)); | ||
1223 | if (err < 0) | ||
1025 | return err; | 1224 | return err; |
1225 | |||
1226 | if (mgr->is_hr_stereo) { | ||
1227 | err = hr222_add_mic_controls(chip); | ||
1228 | if (err < 0) | ||
1229 | return err; | ||
1230 | } | ||
1026 | } | 1231 | } |
1027 | /* monitoring only if playback and capture device available */ | 1232 | /* monitoring only if playback and capture device available */ |
1028 | if (chip->nb_streams_capt > 0 && chip->nb_streams_play > 0) { | 1233 | if (chip->nb_streams_capt > 0 && chip->nb_streams_play > 0) { |
1029 | /* monitoring */ | 1234 | /* monitoring */ |
1030 | if ((err = snd_ctl_add(chip->card, | 1235 | err = snd_ctl_add(chip->card, |
1031 | snd_ctl_new1(&pcxhr_control_monitor_vol, | 1236 | snd_ctl_new1(&pcxhr_control_monitor_vol, chip)); |
1032 | chip))) < 0) | 1237 | if (err < 0) |
1033 | return err; | 1238 | return err; |
1034 | if ((err = snd_ctl_add(chip->card, | 1239 | |
1035 | snd_ctl_new1(&pcxhr_control_monitor_sw, | 1240 | err = snd_ctl_add(chip->card, |
1036 | chip))) < 0) | 1241 | snd_ctl_new1(&pcxhr_control_monitor_sw, chip)); |
1242 | if (err < 0) | ||
1037 | return err; | 1243 | return err; |
1038 | } | 1244 | } |
1039 | 1245 | ||
1040 | if (i == 0) { | 1246 | if (i == 0) { |
1041 | /* clock mode only one control per pcxhr */ | 1247 | /* clock mode only one control per pcxhr */ |
1042 | if ((err = snd_ctl_add(chip->card, | 1248 | err = snd_ctl_add(chip->card, |
1043 | snd_ctl_new1(&pcxhr_control_clock_type, | 1249 | snd_ctl_new1(&pcxhr_control_clock_type, mgr)); |
1044 | mgr))) < 0) | 1250 | if (err < 0) |
1045 | return err; | 1251 | return err; |
1046 | /* non standard control used to scan the external clock presence/frequencies */ | 1252 | /* non standard control used to scan |
1047 | if ((err = snd_ctl_add(chip->card, | 1253 | * the external clock presence/frequencies |
1048 | snd_ctl_new1(&pcxhr_control_clock_rate, | 1254 | */ |
1049 | mgr))) < 0) | 1255 | err = snd_ctl_add(chip->card, |
1256 | snd_ctl_new1(&pcxhr_control_clock_rate, mgr)); | ||
1257 | if (err < 0) | ||
1050 | return err; | 1258 | return err; |
1051 | } | 1259 | } |
1052 | 1260 | ||
diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index e9f0706ed3e4..3caacfb9d8e0 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)) |
@@ -1754,7 +1754,7 @@ snd_riptide_interrupt(int irq, void *dev_id) | |||
1754 | if (IS_EOBIRQ(cif->hwport) || IS_EOSIRQ(cif->hwport) || | 1754 | if (IS_EOBIRQ(cif->hwport) || IS_EOSIRQ(cif->hwport) || |
1755 | IS_EOCIRQ(cif->hwport)) { | 1755 | IS_EOCIRQ(cif->hwport)) { |
1756 | chip->handled_irqs++; | 1756 | chip->handled_irqs++; |
1757 | tasklet_hi_schedule(&chip->riptide_tq); | 1757 | tasklet_schedule(&chip->riptide_tq); |
1758 | } | 1758 | } |
1759 | if (chip->rmidi && IS_MPUIRQ(cif->hwport)) { | 1759 | if (chip->rmidi && IS_MPUIRQ(cif->hwport)) { |
1760 | chip->handled_irqs++; | 1760 | chip->handled_irqs++; |
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index d723543beadd..44d0c15e2b71 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c | |||
@@ -1452,7 +1452,7 @@ static int snd_hdsp_create_midi (struct snd_card *card, struct hdsp *hdsp, int i | |||
1452 | if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0) | 1452 | if (snd_rawmidi_new (card, buf, id, 1, 1, &hdsp->midi[id].rmidi) < 0) |
1453 | return -1; | 1453 | return -1; |
1454 | 1454 | ||
1455 | sprintf (hdsp->midi[id].rmidi->name, "%s MIDI %d", card->id, id+1); | 1455 | sprintf(hdsp->midi[id].rmidi->name, "HDSP MIDI %d", id+1); |
1456 | hdsp->midi[id].rmidi->private_data = &hdsp->midi[id]; | 1456 | hdsp->midi[id].rmidi->private_data = &hdsp->midi[id]; |
1457 | 1457 | ||
1458 | snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_hdsp_midi_output); | 1458 | snd_rawmidi_set_ops (hdsp->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &snd_hdsp_midi_output); |
@@ -3750,7 +3750,7 @@ static irqreturn_t snd_hdsp_interrupt(int irq, void *dev_id) | |||
3750 | } | 3750 | } |
3751 | } | 3751 | } |
3752 | if (hdsp->use_midi_tasklet && schedule) | 3752 | if (hdsp->use_midi_tasklet && schedule) |
3753 | tasklet_hi_schedule(&hdsp->midi_tasklet); | 3753 | tasklet_schedule(&hdsp->midi_tasklet); |
3754 | return IRQ_HANDLED; | 3754 | return IRQ_HANDLED; |
3755 | } | 3755 | } |
3756 | 3756 | ||
@@ -4548,11 +4548,20 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne | |||
4548 | { | 4548 | { |
4549 | struct hdsp *hdsp = (struct hdsp *)hw->private_data; | 4549 | struct hdsp *hdsp = (struct hdsp *)hw->private_data; |
4550 | void __user *argp = (void __user *)arg; | 4550 | void __user *argp = (void __user *)arg; |
4551 | int err; | ||
4551 | 4552 | ||
4552 | switch (cmd) { | 4553 | switch (cmd) { |
4553 | case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: { | 4554 | case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: { |
4554 | struct hdsp_peak_rms __user *peak_rms = (struct hdsp_peak_rms __user *)arg; | 4555 | struct hdsp_peak_rms __user *peak_rms = (struct hdsp_peak_rms __user *)arg; |
4555 | 4556 | ||
4557 | err = hdsp_check_for_iobox(hdsp); | ||
4558 | if (err < 0) | ||
4559 | return err; | ||
4560 | |||
4561 | err = hdsp_check_for_firmware(hdsp, 1); | ||
4562 | if (err < 0) | ||
4563 | return err; | ||
4564 | |||
4556 | if (!(hdsp->state & HDSP_FirmwareLoaded)) { | 4565 | if (!(hdsp->state & HDSP_FirmwareLoaded)) { |
4557 | snd_printk(KERN_ERR "Hammerfall-DSP: firmware needs to be uploaded to the card.\n"); | 4566 | snd_printk(KERN_ERR "Hammerfall-DSP: firmware needs to be uploaded to the card.\n"); |
4558 | return -EINVAL; | 4567 | return -EINVAL; |
@@ -4572,10 +4581,14 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne | |||
4572 | unsigned long flags; | 4581 | unsigned long flags; |
4573 | int i; | 4582 | int i; |
4574 | 4583 | ||
4575 | if (!(hdsp->state & HDSP_FirmwareLoaded)) { | 4584 | err = hdsp_check_for_iobox(hdsp); |
4576 | snd_printk(KERN_ERR "Hammerfall-DSP: Firmware needs to be uploaded to the card.\n"); | 4585 | if (err < 0) |
4577 | return -EINVAL; | 4586 | return err; |
4578 | } | 4587 | |
4588 | err = hdsp_check_for_firmware(hdsp, 1); | ||
4589 | if (err < 0) | ||
4590 | return err; | ||
4591 | |||
4579 | spin_lock_irqsave(&hdsp->lock, flags); | 4592 | spin_lock_irqsave(&hdsp->lock, flags); |
4580 | info.pref_sync_ref = (unsigned char)hdsp_pref_sync_ref(hdsp); | 4593 | info.pref_sync_ref = (unsigned char)hdsp_pref_sync_ref(hdsp); |
4581 | info.wordclock_sync_check = (unsigned char)hdsp_wc_sync_check(hdsp); | 4594 | info.wordclock_sync_check = (unsigned char)hdsp_wc_sync_check(hdsp); |
@@ -5045,6 +5058,10 @@ static int __devinit snd_hdsp_create(struct snd_card *card, | |||
5045 | /* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */ | 5058 | /* we wait 2 seconds to let freshly inserted cardbus cards do their hardware init */ |
5046 | ssleep(2); | 5059 | ssleep(2); |
5047 | 5060 | ||
5061 | err = hdsp_check_for_iobox(hdsp); | ||
5062 | if (err < 0) | ||
5063 | return err; | ||
5064 | |||
5048 | if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { | 5065 | if ((hdsp_read (hdsp, HDSP_statusRegister) & HDSP_DllError) != 0) { |
5049 | #ifdef HDSP_FW_LOADER | 5066 | #ifdef HDSP_FW_LOADER |
5050 | if ((err = hdsp_request_fw_loader(hdsp)) < 0) | 5067 | if ((err = hdsp_request_fw_loader(hdsp)) < 0) |
@@ -5057,7 +5074,7 @@ static int __devinit snd_hdsp_create(struct snd_card *card, | |||
5057 | /* init is complete, we return */ | 5074 | /* init is complete, we return */ |
5058 | return 0; | 5075 | return 0; |
5059 | #endif | 5076 | #endif |
5060 | /* no iobox connected, we defer initialization */ | 5077 | /* we defer initialization */ |
5061 | snd_printk(KERN_INFO "Hammerfall-DSP: card initialization pending : waiting for firmware\n"); | 5078 | snd_printk(KERN_INFO "Hammerfall-DSP: card initialization pending : waiting for firmware\n"); |
5062 | if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) | 5079 | if ((err = snd_hdsp_create_hwdep(card, hdsp)) < 0) |
5063 | return err; | 5080 | return err; |
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c index 98762f909d64..71231cf1b2b0 100644 --- a/sound/pci/rme9652/hdspm.c +++ b/sound/pci/rme9652/hdspm.c | |||
@@ -1293,7 +1293,7 @@ static int __devinit snd_hdspm_create_midi (struct snd_card *card, | |||
1293 | if (err < 0) | 1293 | if (err < 0) |
1294 | return err; | 1294 | return err; |
1295 | 1295 | ||
1296 | sprintf (hdspm->midi[id].rmidi->name, "%s MIDI %d", card->id, id+1); | 1296 | sprintf(hdspm->midi[id].rmidi->name, "HDSPM MIDI %d", id+1); |
1297 | hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; | 1297 | hdspm->midi[id].rmidi->private_data = &hdspm->midi[id]; |
1298 | 1298 | ||
1299 | snd_rawmidi_set_ops(hdspm->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, | 1299 | snd_rawmidi_set_ops(hdspm->midi[id].rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, |
@@ -3476,7 +3476,7 @@ static irqreturn_t snd_hdspm_interrupt(int irq, void *dev_id) | |||
3476 | schedule = 1; | 3476 | schedule = 1; |
3477 | } | 3477 | } |
3478 | if (schedule) | 3478 | if (schedule) |
3479 | tasklet_hi_schedule(&hdspm->midi_tasklet); | 3479 | tasklet_schedule(&hdspm->midi_tasklet); |
3480 | return IRQ_HANDLED; | 3480 | return IRQ_HANDLED; |
3481 | } | 3481 | } |
3482 | 3482 | ||