diff options
Diffstat (limited to 'sound/pci/hda/hda_intel.c')
-rw-r--r-- | sound/pci/hda/hda_intel.c | 89 |
1 files changed, 32 insertions, 57 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 4ca3d5d02436..060f7a2b1aeb 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -62,7 +62,6 @@ | |||
62 | #include <linux/firmware.h> | 62 | #include <linux/firmware.h> |
63 | #include "hda_codec.h" | 63 | #include "hda_codec.h" |
64 | #include "hda_controller.h" | 64 | #include "hda_controller.h" |
65 | #include "hda_priv.h" | ||
66 | #include "hda_intel.h" | 65 | #include "hda_intel.h" |
67 | 66 | ||
68 | /* position fix mode */ | 67 | /* position fix mode */ |
@@ -174,7 +173,6 @@ static struct kernel_param_ops param_ops_xint = { | |||
174 | #define param_check_xint param_check_int | 173 | #define param_check_xint param_check_int |
175 | 174 | ||
176 | static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; | 175 | static int power_save = CONFIG_SND_HDA_POWER_SAVE_DEFAULT; |
177 | static int *power_save_addr = &power_save; | ||
178 | module_param(power_save, xint, 0644); | 176 | module_param(power_save, xint, 0644); |
179 | MODULE_PARM_DESC(power_save, "Automatic power-saving timeout " | 177 | MODULE_PARM_DESC(power_save, "Automatic power-saving timeout " |
180 | "(in second, 0 = disable)."); | 178 | "(in second, 0 = disable)."); |
@@ -187,7 +185,7 @@ static bool power_save_controller = 1; | |||
187 | module_param(power_save_controller, bool, 0644); | 185 | module_param(power_save_controller, bool, 0644); |
188 | MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode."); | 186 | MODULE_PARM_DESC(power_save_controller, "Reset controller in power save mode."); |
189 | #else | 187 | #else |
190 | static int *power_save_addr; | 188 | #define power_save 0 |
191 | #endif /* CONFIG_PM */ | 189 | #endif /* CONFIG_PM */ |
192 | 190 | ||
193 | static int align_buffer_size = -1; | 191 | static int align_buffer_size = -1; |
@@ -530,10 +528,10 @@ static int azx_position_check(struct azx *chip, struct azx_dev *azx_dev) | |||
530 | if (ok == 1) { | 528 | if (ok == 1) { |
531 | azx_dev->irq_pending = 0; | 529 | azx_dev->irq_pending = 0; |
532 | return ok; | 530 | return ok; |
533 | } else if (ok == 0 && chip->bus && chip->bus->workq) { | 531 | } else if (ok == 0) { |
534 | /* bogus IRQ, process it later */ | 532 | /* bogus IRQ, process it later */ |
535 | azx_dev->irq_pending = 1; | 533 | azx_dev->irq_pending = 1; |
536 | queue_work(chip->bus->workq, &hda->irq_pending_work); | 534 | schedule_work(&hda->irq_pending_work); |
537 | } | 535 | } |
538 | return 0; | 536 | return 0; |
539 | } | 537 | } |
@@ -741,7 +739,6 @@ static int param_set_xint(const char *val, const struct kernel_param *kp) | |||
741 | { | 739 | { |
742 | struct hda_intel *hda; | 740 | struct hda_intel *hda; |
743 | struct azx *chip; | 741 | struct azx *chip; |
744 | struct hda_codec *c; | ||
745 | int prev = power_save; | 742 | int prev = power_save; |
746 | int ret = param_set_int(val, kp); | 743 | int ret = param_set_int(val, kp); |
747 | 744 | ||
@@ -753,8 +750,7 @@ static int param_set_xint(const char *val, const struct kernel_param *kp) | |||
753 | chip = &hda->chip; | 750 | chip = &hda->chip; |
754 | if (!chip->bus || chip->disabled) | 751 | if (!chip->bus || chip->disabled) |
755 | continue; | 752 | continue; |
756 | list_for_each_entry(c, &chip->bus->codec_list, list) | 753 | snd_hda_set_power_save(chip->bus, power_save * 1000); |
757 | snd_hda_power_sync(c); | ||
758 | } | 754 | } |
759 | mutex_unlock(&card_list_lock); | 755 | mutex_unlock(&card_list_lock); |
760 | return 0; | 756 | return 0; |
@@ -773,7 +769,6 @@ static int azx_suspend(struct device *dev) | |||
773 | struct snd_card *card = dev_get_drvdata(dev); | 769 | struct snd_card *card = dev_get_drvdata(dev); |
774 | struct azx *chip; | 770 | struct azx *chip; |
775 | struct hda_intel *hda; | 771 | struct hda_intel *hda; |
776 | struct azx_pcm *p; | ||
777 | 772 | ||
778 | if (!card) | 773 | if (!card) |
779 | return 0; | 774 | return 0; |
@@ -785,10 +780,6 @@ static int azx_suspend(struct device *dev) | |||
785 | 780 | ||
786 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); | 781 | snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); |
787 | azx_clear_irq_pending(chip); | 782 | azx_clear_irq_pending(chip); |
788 | list_for_each_entry(p, &chip->pcm_list, list) | ||
789 | snd_pcm_suspend_all(p->pcm); | ||
790 | if (chip->initialized) | ||
791 | snd_hda_suspend(chip->bus); | ||
792 | azx_stop_chip(chip); | 783 | azx_stop_chip(chip); |
793 | azx_enter_link_reset(chip); | 784 | azx_enter_link_reset(chip); |
794 | if (chip->irq >= 0) { | 785 | if (chip->irq >= 0) { |
@@ -831,7 +822,6 @@ static int azx_resume(struct device *dev) | |||
831 | 822 | ||
832 | azx_init_chip(chip, true); | 823 | azx_init_chip(chip, true); |
833 | 824 | ||
834 | snd_hda_resume(chip->bus); | ||
835 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); | 825 | snd_power_change_state(card, SNDRV_CTL_POWER_D0); |
836 | return 0; | 826 | return 0; |
837 | } | 827 | } |
@@ -852,7 +842,7 @@ static int azx_runtime_suspend(struct device *dev) | |||
852 | if (chip->disabled || hda->init_failed) | 842 | if (chip->disabled || hda->init_failed) |
853 | return 0; | 843 | return 0; |
854 | 844 | ||
855 | if (!(chip->driver_caps & AZX_DCAPS_PM_RUNTIME)) | 845 | if (!azx_has_pm_runtime(chip)) |
856 | return 0; | 846 | return 0; |
857 | 847 | ||
858 | /* enable controller wake up event */ | 848 | /* enable controller wake up event */ |
@@ -885,7 +875,7 @@ static int azx_runtime_resume(struct device *dev) | |||
885 | if (chip->disabled || hda->init_failed) | 875 | if (chip->disabled || hda->init_failed) |
886 | return 0; | 876 | return 0; |
887 | 877 | ||
888 | if (!(chip->driver_caps & AZX_DCAPS_PM_RUNTIME)) | 878 | if (!azx_has_pm_runtime(chip)) |
889 | return 0; | 879 | return 0; |
890 | 880 | ||
891 | if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { | 881 | if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { |
@@ -903,8 +893,8 @@ static int azx_runtime_resume(struct device *dev) | |||
903 | if (status && bus) { | 893 | if (status && bus) { |
904 | list_for_each_entry(codec, &bus->codec_list, list) | 894 | list_for_each_entry(codec, &bus->codec_list, list) |
905 | if (status & (1 << codec->addr)) | 895 | if (status & (1 << codec->addr)) |
906 | queue_delayed_work(codec->bus->workq, | 896 | schedule_delayed_work(&codec->jackpoll_work, |
907 | &codec->jackpoll_work, codec->jackpoll_interval); | 897 | codec->jackpoll_interval); |
908 | } | 898 | } |
909 | 899 | ||
910 | /* disable controller Wake Up event*/ | 900 | /* disable controller Wake Up event*/ |
@@ -928,8 +918,8 @@ static int azx_runtime_idle(struct device *dev) | |||
928 | if (chip->disabled || hda->init_failed) | 918 | if (chip->disabled || hda->init_failed) |
929 | return 0; | 919 | return 0; |
930 | 920 | ||
931 | if (!power_save_controller || | 921 | if (!power_save_controller || !azx_has_pm_runtime(chip) || |
932 | !(chip->driver_caps & AZX_DCAPS_PM_RUNTIME)) | 922 | chip->bus->codec_powered) |
933 | return -EBUSY; | 923 | return -EBUSY; |
934 | 924 | ||
935 | return 0; | 925 | return 0; |
@@ -1071,14 +1061,11 @@ static int azx_free(struct azx *chip) | |||
1071 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); | 1061 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); |
1072 | int i; | 1062 | int i; |
1073 | 1063 | ||
1074 | if ((chip->driver_caps & AZX_DCAPS_PM_RUNTIME) | 1064 | if (azx_has_pm_runtime(chip) && chip->running) |
1075 | && chip->running) | ||
1076 | pm_runtime_get_noresume(&pci->dev); | 1065 | pm_runtime_get_noresume(&pci->dev); |
1077 | 1066 | ||
1078 | azx_del_card_list(chip); | 1067 | azx_del_card_list(chip); |
1079 | 1068 | ||
1080 | azx_notifier_unregister(chip); | ||
1081 | |||
1082 | hda->init_failed = 1; /* to be sure */ | 1069 | hda->init_failed = 1; /* to be sure */ |
1083 | complete_all(&hda->probe_wait); | 1070 | complete_all(&hda->probe_wait); |
1084 | 1071 | ||
@@ -1394,7 +1381,6 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci, | |||
1394 | 1381 | ||
1395 | hda = kzalloc(sizeof(*hda), GFP_KERNEL); | 1382 | hda = kzalloc(sizeof(*hda), GFP_KERNEL); |
1396 | if (!hda) { | 1383 | if (!hda) { |
1397 | dev_err(card->dev, "Cannot allocate hda\n"); | ||
1398 | pci_disable_device(pci); | 1384 | pci_disable_device(pci); |
1399 | return -ENOMEM; | 1385 | return -ENOMEM; |
1400 | } | 1386 | } |
@@ -1575,10 +1561,8 @@ static int azx_first_init(struct azx *chip) | |||
1575 | chip->num_streams = chip->playback_streams + chip->capture_streams; | 1561 | chip->num_streams = chip->playback_streams + chip->capture_streams; |
1576 | chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), | 1562 | chip->azx_dev = kcalloc(chip->num_streams, sizeof(*chip->azx_dev), |
1577 | GFP_KERNEL); | 1563 | GFP_KERNEL); |
1578 | if (!chip->azx_dev) { | 1564 | if (!chip->azx_dev) |
1579 | dev_err(card->dev, "cannot malloc azx_dev\n"); | ||
1580 | return -ENOMEM; | 1565 | return -ENOMEM; |
1581 | } | ||
1582 | 1566 | ||
1583 | err = azx_alloc_stream_pages(chip); | 1567 | err = azx_alloc_stream_pages(chip); |
1584 | if (err < 0) | 1568 | if (err < 0) |
@@ -1615,19 +1599,6 @@ static int azx_first_init(struct azx *chip) | |||
1615 | return 0; | 1599 | return 0; |
1616 | } | 1600 | } |
1617 | 1601 | ||
1618 | static void power_down_all_codecs(struct azx *chip) | ||
1619 | { | ||
1620 | #ifdef CONFIG_PM | ||
1621 | /* The codecs were powered up in snd_hda_codec_new(). | ||
1622 | * Now all initialization done, so turn them down if possible | ||
1623 | */ | ||
1624 | struct hda_codec *codec; | ||
1625 | list_for_each_entry(codec, &chip->bus->codec_list, list) { | ||
1626 | snd_hda_power_down(codec); | ||
1627 | } | ||
1628 | #endif | ||
1629 | } | ||
1630 | |||
1631 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | 1602 | #ifdef CONFIG_SND_HDA_PATCH_LOADER |
1632 | /* callback from request_firmware_nowait() */ | 1603 | /* callback from request_firmware_nowait() */ |
1633 | static void azx_firmware_cb(const struct firmware *fw, void *context) | 1604 | static void azx_firmware_cb(const struct firmware *fw, void *context) |
@@ -1896,12 +1867,14 @@ static int azx_probe_continue(struct azx *chip) | |||
1896 | #endif | 1867 | #endif |
1897 | 1868 | ||
1898 | /* create codec instances */ | 1869 | /* create codec instances */ |
1899 | err = azx_codec_create(chip, model[dev], | 1870 | err = azx_bus_create(chip, model[dev]); |
1900 | azx_max_codecs[chip->driver_type], | 1871 | if (err < 0) |
1901 | power_save_addr); | 1872 | goto out_free; |
1902 | 1873 | ||
1874 | err = azx_probe_codecs(chip, azx_max_codecs[chip->driver_type]); | ||
1903 | if (err < 0) | 1875 | if (err < 0) |
1904 | goto out_free; | 1876 | goto out_free; |
1877 | |||
1905 | #ifdef CONFIG_SND_HDA_PATCH_LOADER | 1878 | #ifdef CONFIG_SND_HDA_PATCH_LOADER |
1906 | if (chip->fw) { | 1879 | if (chip->fw) { |
1907 | err = snd_hda_load_patch(chip->bus, chip->fw->size, | 1880 | err = snd_hda_load_patch(chip->bus, chip->fw->size, |
@@ -1920,25 +1893,14 @@ static int azx_probe_continue(struct azx *chip) | |||
1920 | goto out_free; | 1893 | goto out_free; |
1921 | } | 1894 | } |
1922 | 1895 | ||
1923 | /* create PCM streams */ | ||
1924 | err = snd_hda_build_pcms(chip->bus); | ||
1925 | if (err < 0) | ||
1926 | goto out_free; | ||
1927 | |||
1928 | /* create mixer controls */ | ||
1929 | err = azx_mixer_create(chip); | ||
1930 | if (err < 0) | ||
1931 | goto out_free; | ||
1932 | |||
1933 | err = snd_card_register(chip->card); | 1896 | err = snd_card_register(chip->card); |
1934 | if (err < 0) | 1897 | if (err < 0) |
1935 | goto out_free; | 1898 | goto out_free; |
1936 | 1899 | ||
1937 | chip->running = 1; | 1900 | chip->running = 1; |
1938 | power_down_all_codecs(chip); | ||
1939 | azx_notifier_register(chip); | ||
1940 | azx_add_card_list(chip); | 1901 | azx_add_card_list(chip); |
1941 | if ((chip->driver_caps & AZX_DCAPS_PM_RUNTIME) || hda->use_vga_switcheroo) | 1902 | snd_hda_set_power_save(chip->bus, power_save * 1000); |
1903 | if (azx_has_pm_runtime(chip) || hda->use_vga_switcheroo) | ||
1942 | pm_runtime_put_noidle(&pci->dev); | 1904 | pm_runtime_put_noidle(&pci->dev); |
1943 | 1905 | ||
1944 | out_free: | 1906 | out_free: |
@@ -1956,6 +1918,18 @@ static void azx_remove(struct pci_dev *pci) | |||
1956 | snd_card_free(card); | 1918 | snd_card_free(card); |
1957 | } | 1919 | } |
1958 | 1920 | ||
1921 | static void azx_shutdown(struct pci_dev *pci) | ||
1922 | { | ||
1923 | struct snd_card *card = pci_get_drvdata(pci); | ||
1924 | struct azx *chip; | ||
1925 | |||
1926 | if (!card) | ||
1927 | return; | ||
1928 | chip = card->private_data; | ||
1929 | if (chip && chip->running) | ||
1930 | azx_stop_chip(chip); | ||
1931 | } | ||
1932 | |||
1959 | /* PCI IDs */ | 1933 | /* PCI IDs */ |
1960 | static const struct pci_device_id azx_ids[] = { | 1934 | static const struct pci_device_id azx_ids[] = { |
1961 | /* CPT */ | 1935 | /* CPT */ |
@@ -2178,6 +2152,7 @@ static struct pci_driver azx_driver = { | |||
2178 | .id_table = azx_ids, | 2152 | .id_table = azx_ids, |
2179 | .probe = azx_probe, | 2153 | .probe = azx_probe, |
2180 | .remove = azx_remove, | 2154 | .remove = azx_remove, |
2155 | .shutdown = azx_shutdown, | ||
2181 | .driver = { | 2156 | .driver = { |
2182 | .pm = AZX_PM_OPS, | 2157 | .pm = AZX_PM_OPS, |
2183 | }, | 2158 | }, |