diff options
author | Takashi Iwai <tiwai@suse.de> | 2014-06-26 11:19:20 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2014-06-26 12:00:01 -0400 |
commit | 9a34af4a33270acbd60a85f819553463866aecbb (patch) | |
tree | 6383c219caead0b64a17d77e6a9016acc69053c9 /sound/pci/hda/hda_intel.c | |
parent | b6050ef664219a0bc97d0626759ef070ed77fcba (diff) |
ALSA: hda - Move more PCI-controller-specific stuff from generic code
Just move struct fields between struct azx and struct hda_intel, and
move some definitions from hda_priv.h to hda_intel.c.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_intel.c')
-rw-r--r-- | sound/pci/hda/hda_intel.c | 117 |
1 files changed, 85 insertions, 32 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index cb5d807bbd0c..bbb446aef67a 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
@@ -75,6 +75,26 @@ enum { | |||
75 | POS_FIX_COMBO, | 75 | POS_FIX_COMBO, |
76 | }; | 76 | }; |
77 | 77 | ||
78 | /* Defines for ATI HD Audio support in SB450 south bridge */ | ||
79 | #define ATI_SB450_HDAUDIO_MISC_CNTR2_ADDR 0x42 | ||
80 | #define ATI_SB450_HDAUDIO_ENABLE_SNOOP 0x02 | ||
81 | |||
82 | /* Defines for Nvidia HDA support */ | ||
83 | #define NVIDIA_HDA_TRANSREG_ADDR 0x4e | ||
84 | #define NVIDIA_HDA_ENABLE_COHBITS 0x0f | ||
85 | #define NVIDIA_HDA_ISTRM_COH 0x4d | ||
86 | #define NVIDIA_HDA_OSTRM_COH 0x4c | ||
87 | #define NVIDIA_HDA_ENABLE_COHBIT 0x01 | ||
88 | |||
89 | /* Defines for Intel SCH HDA snoop control */ | ||
90 | #define INTEL_SCH_HDA_DEVC 0x78 | ||
91 | #define INTEL_SCH_HDA_DEVC_NOSNOOP (0x1<<11) | ||
92 | |||
93 | /* Define IN stream 0 FIFO size offset in VIA controller */ | ||
94 | #define VIA_IN_STREAM0_FIFO_SIZE_OFFSET 0x90 | ||
95 | /* Define VIA HD Audio Device ID*/ | ||
96 | #define VIA_HDAC_DEVICE_ID 0x3288 | ||
97 | |||
78 | 98 | ||
79 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | 99 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; |
80 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; | 100 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; |
@@ -312,8 +332,28 @@ struct hda_intel { | |||
312 | /* HSW/BDW display HDA controller to restore BCLK from CDCLK */ | 332 | /* HSW/BDW display HDA controller to restore BCLK from CDCLK */ |
313 | unsigned int bclk_m; | 333 | unsigned int bclk_m; |
314 | unsigned int bclk_n; | 334 | unsigned int bclk_n; |
315 | }; | ||
316 | 335 | ||
336 | /* for pending irqs */ | ||
337 | struct work_struct irq_pending_work; | ||
338 | |||
339 | /* sync probing */ | ||
340 | struct completion probe_wait; | ||
341 | struct work_struct probe_work; | ||
342 | |||
343 | /* card list (for power_save trigger) */ | ||
344 | struct list_head list; | ||
345 | |||
346 | /* extra flags */ | ||
347 | unsigned int irq_pending_warned:1; | ||
348 | |||
349 | /* VGA-switcheroo setup */ | ||
350 | unsigned int use_vga_switcheroo:1; | ||
351 | unsigned int vga_switcheroo_registered:1; | ||
352 | unsigned int init_failed:1; /* delayed init failed */ | ||
353 | |||
354 | /* secondary power domain for hdmi audio under vga device */ | ||
355 | struct dev_pm_domain hdmi_pm_domain; | ||
356 | }; | ||
317 | 357 | ||
318 | #ifdef CONFIG_X86 | 358 | #ifdef CONFIG_X86 |
319 | static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool on) | 359 | static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool on) |
@@ -480,6 +520,7 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev); | |||
480 | /* called from IRQ */ | 520 | /* called from IRQ */ |
481 | static int azx_position_check(struct azx *chip, struct azx_dev *azx_dev) | 521 | static int azx_position_check(struct azx *chip, struct azx_dev *azx_dev) |
482 | { | 522 | { |
523 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); | ||
483 | int ok; | 524 | int ok; |
484 | 525 | ||
485 | ok = azx_position_ok(chip, azx_dev); | 526 | ok = azx_position_ok(chip, azx_dev); |
@@ -489,7 +530,7 @@ static int azx_position_check(struct azx *chip, struct azx_dev *azx_dev) | |||
489 | } else if (ok == 0 && chip->bus && chip->bus->workq) { | 530 | } else if (ok == 0 && chip->bus && chip->bus->workq) { |
490 | /* bogus IRQ, process it later */ | 531 | /* bogus IRQ, process it later */ |
491 | azx_dev->irq_pending = 1; | 532 | azx_dev->irq_pending = 1; |
492 | queue_work(chip->bus->workq, &chip->irq_pending_work); | 533 | queue_work(chip->bus->workq, &hda->irq_pending_work); |
493 | } | 534 | } |
494 | return 0; | 535 | return 0; |
495 | } | 536 | } |
@@ -550,14 +591,15 @@ static int azx_position_ok(struct azx *chip, struct azx_dev *azx_dev) | |||
550 | */ | 591 | */ |
551 | static void azx_irq_pending_work(struct work_struct *work) | 592 | static void azx_irq_pending_work(struct work_struct *work) |
552 | { | 593 | { |
553 | struct azx *chip = container_of(work, struct azx, irq_pending_work); | 594 | struct hda_intel *hda = container_of(work, struct hda_intel, irq_pending_work); |
595 | struct azx *chip = &hda->chip; | ||
554 | int i, pending, ok; | 596 | int i, pending, ok; |
555 | 597 | ||
556 | if (!chip->irq_pending_warned) { | 598 | if (!hda->irq_pending_warned) { |
557 | dev_info(chip->card->dev, | 599 | dev_info(chip->card->dev, |
558 | "IRQ timing workaround is activated for card #%d. Suggest a bigger bdl_pos_adj.\n", | 600 | "IRQ timing workaround is activated for card #%d. Suggest a bigger bdl_pos_adj.\n", |
559 | chip->card->number); | 601 | chip->card->number); |
560 | chip->irq_pending_warned = 1; | 602 | hda->irq_pending_warned = 1; |
561 | } | 603 | } |
562 | 604 | ||
563 | for (;;) { | 605 | for (;;) { |
@@ -677,21 +719,24 @@ static LIST_HEAD(card_list); | |||
677 | 719 | ||
678 | static void azx_add_card_list(struct azx *chip) | 720 | static void azx_add_card_list(struct azx *chip) |
679 | { | 721 | { |
722 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); | ||
680 | mutex_lock(&card_list_lock); | 723 | mutex_lock(&card_list_lock); |
681 | list_add(&chip->list, &card_list); | 724 | list_add(&hda->list, &card_list); |
682 | mutex_unlock(&card_list_lock); | 725 | mutex_unlock(&card_list_lock); |
683 | } | 726 | } |
684 | 727 | ||
685 | static void azx_del_card_list(struct azx *chip) | 728 | static void azx_del_card_list(struct azx *chip) |
686 | { | 729 | { |
730 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); | ||
687 | mutex_lock(&card_list_lock); | 731 | mutex_lock(&card_list_lock); |
688 | list_del_init(&chip->list); | 732 | list_del_init(&hda->list); |
689 | mutex_unlock(&card_list_lock); | 733 | mutex_unlock(&card_list_lock); |
690 | } | 734 | } |
691 | 735 | ||
692 | /* trigger power-save check at writing parameter */ | 736 | /* trigger power-save check at writing parameter */ |
693 | static int param_set_xint(const char *val, const struct kernel_param *kp) | 737 | static int param_set_xint(const char *val, const struct kernel_param *kp) |
694 | { | 738 | { |
739 | struct hda_intel *hda; | ||
695 | struct azx *chip; | 740 | struct azx *chip; |
696 | struct hda_codec *c; | 741 | struct hda_codec *c; |
697 | int prev = power_save; | 742 | int prev = power_save; |
@@ -701,7 +746,8 @@ static int param_set_xint(const char *val, const struct kernel_param *kp) | |||
701 | return ret; | 746 | return ret; |
702 | 747 | ||
703 | mutex_lock(&card_list_lock); | 748 | mutex_lock(&card_list_lock); |
704 | list_for_each_entry(chip, &card_list, list) { | 749 | list_for_each_entry(hda, &card_list, list) { |
750 | chip = &hda->chip; | ||
705 | if (!chip->bus || chip->disabled) | 751 | if (!chip->bus || chip->disabled) |
706 | continue; | 752 | continue; |
707 | list_for_each_entry(c, &chip->bus->codec_list, list) | 753 | list_for_each_entry(c, &chip->bus->codec_list, list) |
@@ -939,10 +985,11 @@ static void azx_vs_set_state(struct pci_dev *pci, | |||
939 | { | 985 | { |
940 | struct snd_card *card = pci_get_drvdata(pci); | 986 | struct snd_card *card = pci_get_drvdata(pci); |
941 | struct azx *chip = card->private_data; | 987 | struct azx *chip = card->private_data; |
988 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); | ||
942 | bool disabled; | 989 | bool disabled; |
943 | 990 | ||
944 | wait_for_completion(&chip->probe_wait); | 991 | wait_for_completion(&hda->probe_wait); |
945 | if (chip->init_failed) | 992 | if (hda->init_failed) |
946 | return; | 993 | return; |
947 | 994 | ||
948 | disabled = (state == VGA_SWITCHEROO_OFF); | 995 | disabled = (state == VGA_SWITCHEROO_OFF); |
@@ -956,7 +1003,7 @@ static void azx_vs_set_state(struct pci_dev *pci, | |||
956 | "Start delayed initialization\n"); | 1003 | "Start delayed initialization\n"); |
957 | if (azx_probe_continue(chip) < 0) { | 1004 | if (azx_probe_continue(chip) < 0) { |
958 | dev_err(chip->card->dev, "initialization error\n"); | 1005 | dev_err(chip->card->dev, "initialization error\n"); |
959 | chip->init_failed = true; | 1006 | hda->init_failed = true; |
960 | } | 1007 | } |
961 | } | 1008 | } |
962 | } else { | 1009 | } else { |
@@ -986,9 +1033,10 @@ static bool azx_vs_can_switch(struct pci_dev *pci) | |||
986 | { | 1033 | { |
987 | struct snd_card *card = pci_get_drvdata(pci); | 1034 | struct snd_card *card = pci_get_drvdata(pci); |
988 | struct azx *chip = card->private_data; | 1035 | struct azx *chip = card->private_data; |
1036 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); | ||
989 | 1037 | ||
990 | wait_for_completion(&chip->probe_wait); | 1038 | wait_for_completion(&hda->probe_wait); |
991 | if (chip->init_failed) | 1039 | if (hda->init_failed) |
992 | return false; | 1040 | return false; |
993 | if (chip->disabled || !chip->bus) | 1041 | if (chip->disabled || !chip->bus) |
994 | return true; | 1042 | return true; |
@@ -1000,11 +1048,12 @@ static bool azx_vs_can_switch(struct pci_dev *pci) | |||
1000 | 1048 | ||
1001 | static void init_vga_switcheroo(struct azx *chip) | 1049 | static void init_vga_switcheroo(struct azx *chip) |
1002 | { | 1050 | { |
1051 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); | ||
1003 | struct pci_dev *p = get_bound_vga(chip->pci); | 1052 | struct pci_dev *p = get_bound_vga(chip->pci); |
1004 | if (p) { | 1053 | if (p) { |
1005 | dev_info(chip->card->dev, | 1054 | dev_info(chip->card->dev, |
1006 | "Handle VGA-switcheroo audio client\n"); | 1055 | "Handle VGA-switcheroo audio client\n"); |
1007 | chip->use_vga_switcheroo = 1; | 1056 | hda->use_vga_switcheroo = 1; |
1008 | pci_dev_put(p); | 1057 | pci_dev_put(p); |
1009 | } | 1058 | } |
1010 | } | 1059 | } |
@@ -1016,9 +1065,10 @@ static const struct vga_switcheroo_client_ops azx_vs_ops = { | |||
1016 | 1065 | ||
1017 | static int register_vga_switcheroo(struct azx *chip) | 1066 | static int register_vga_switcheroo(struct azx *chip) |
1018 | { | 1067 | { |
1068 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); | ||
1019 | int err; | 1069 | int err; |
1020 | 1070 | ||
1021 | if (!chip->use_vga_switcheroo) | 1071 | if (!hda->use_vga_switcheroo) |
1022 | return 0; | 1072 | return 0; |
1023 | /* FIXME: currently only handling DIS controller | 1073 | /* FIXME: currently only handling DIS controller |
1024 | * is there any machine with two switchable HDMI audio controllers? | 1074 | * is there any machine with two switchable HDMI audio controllers? |
@@ -1028,11 +1078,11 @@ static int register_vga_switcheroo(struct azx *chip) | |||
1028 | chip->bus != NULL); | 1078 | chip->bus != NULL); |
1029 | if (err < 0) | 1079 | if (err < 0) |
1030 | return err; | 1080 | return err; |
1031 | chip->vga_switcheroo_registered = 1; | 1081 | hda->vga_switcheroo_registered = 1; |
1032 | 1082 | ||
1033 | /* register as an optimus hdmi audio power domain */ | 1083 | /* register as an optimus hdmi audio power domain */ |
1034 | vga_switcheroo_init_domain_pm_optimus_hdmi_audio(chip->card->dev, | 1084 | vga_switcheroo_init_domain_pm_optimus_hdmi_audio(chip->card->dev, |
1035 | &chip->hdmi_pm_domain); | 1085 | &hda->hdmi_pm_domain); |
1036 | return 0; | 1086 | return 0; |
1037 | } | 1087 | } |
1038 | #else | 1088 | #else |
@@ -1048,7 +1098,6 @@ static int azx_free(struct azx *chip) | |||
1048 | { | 1098 | { |
1049 | struct pci_dev *pci = chip->pci; | 1099 | struct pci_dev *pci = chip->pci; |
1050 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); | 1100 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); |
1051 | |||
1052 | int i; | 1101 | int i; |
1053 | 1102 | ||
1054 | if ((chip->driver_caps & AZX_DCAPS_PM_RUNTIME) | 1103 | if ((chip->driver_caps & AZX_DCAPS_PM_RUNTIME) |
@@ -1059,13 +1108,13 @@ static int azx_free(struct azx *chip) | |||
1059 | 1108 | ||
1060 | azx_notifier_unregister(chip); | 1109 | azx_notifier_unregister(chip); |
1061 | 1110 | ||
1062 | chip->init_failed = 1; /* to be sure */ | 1111 | hda->init_failed = 1; /* to be sure */ |
1063 | complete_all(&chip->probe_wait); | 1112 | complete_all(&hda->probe_wait); |
1064 | 1113 | ||
1065 | if (use_vga_switcheroo(chip)) { | 1114 | if (use_vga_switcheroo(hda)) { |
1066 | if (chip->disabled && chip->bus) | 1115 | if (chip->disabled && chip->bus) |
1067 | snd_hda_unlock_devices(chip->bus); | 1116 | snd_hda_unlock_devices(chip->bus); |
1068 | if (chip->vga_switcheroo_registered) | 1117 | if (hda->vga_switcheroo_registered) |
1069 | vga_switcheroo_unregister_client(chip->pci); | 1118 | vga_switcheroo_unregister_client(chip->pci); |
1070 | } | 1119 | } |
1071 | 1120 | ||
@@ -1350,7 +1399,8 @@ static void azx_check_snoop_available(struct azx *chip) | |||
1350 | 1399 | ||
1351 | static void azx_probe_work(struct work_struct *work) | 1400 | static void azx_probe_work(struct work_struct *work) |
1352 | { | 1401 | { |
1353 | azx_probe_continue(container_of(work, struct azx, probe_work)); | 1402 | struct hda_intel *hda = container_of(work, struct hda_intel, probe_work); |
1403 | azx_probe_continue(&hda->chip); | ||
1354 | } | 1404 | } |
1355 | 1405 | ||
1356 | /* | 1406 | /* |
@@ -1393,11 +1443,11 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci, | |||
1393 | check_msi(chip); | 1443 | check_msi(chip); |
1394 | chip->dev_index = dev; | 1444 | chip->dev_index = dev; |
1395 | chip->jackpoll_ms = jackpoll_ms; | 1445 | chip->jackpoll_ms = jackpoll_ms; |
1396 | INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work); | ||
1397 | INIT_LIST_HEAD(&chip->pcm_list); | 1446 | INIT_LIST_HEAD(&chip->pcm_list); |
1398 | INIT_LIST_HEAD(&chip->list); | 1447 | INIT_WORK(&hda->irq_pending_work, azx_irq_pending_work); |
1448 | INIT_LIST_HEAD(&hda->list); | ||
1399 | init_vga_switcheroo(chip); | 1449 | init_vga_switcheroo(chip); |
1400 | init_completion(&chip->probe_wait); | 1450 | init_completion(&hda->probe_wait); |
1401 | 1451 | ||
1402 | assign_position_fix(chip, check_position_fix(chip, position_fix[dev])); | 1452 | assign_position_fix(chip, check_position_fix(chip, position_fix[dev])); |
1403 | 1453 | ||
@@ -1428,7 +1478,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci, | |||
1428 | } | 1478 | } |
1429 | 1479 | ||
1430 | /* continue probing in work context as may trigger request module */ | 1480 | /* continue probing in work context as may trigger request module */ |
1431 | INIT_WORK(&chip->probe_work, azx_probe_work); | 1481 | INIT_WORK(&hda->probe_work, azx_probe_work); |
1432 | 1482 | ||
1433 | *rchip = chip; | 1483 | *rchip = chip; |
1434 | 1484 | ||
@@ -1750,6 +1800,7 @@ static int azx_probe(struct pci_dev *pci, | |||
1750 | { | 1800 | { |
1751 | static int dev; | 1801 | static int dev; |
1752 | struct snd_card *card; | 1802 | struct snd_card *card; |
1803 | struct hda_intel *hda; | ||
1753 | struct azx *chip; | 1804 | struct azx *chip; |
1754 | bool schedule_probe; | 1805 | bool schedule_probe; |
1755 | int err; | 1806 | int err; |
@@ -1773,6 +1824,7 @@ static int azx_probe(struct pci_dev *pci, | |||
1773 | if (err < 0) | 1824 | if (err < 0) |
1774 | goto out_free; | 1825 | goto out_free; |
1775 | card->private_data = chip; | 1826 | card->private_data = chip; |
1827 | hda = container_of(chip, struct hda_intel, chip); | ||
1776 | 1828 | ||
1777 | pci_set_drvdata(pci, card); | 1829 | pci_set_drvdata(pci, card); |
1778 | 1830 | ||
@@ -1809,11 +1861,11 @@ static int azx_probe(struct pci_dev *pci, | |||
1809 | #endif | 1861 | #endif |
1810 | 1862 | ||
1811 | if (schedule_probe) | 1863 | if (schedule_probe) |
1812 | schedule_work(&chip->probe_work); | 1864 | schedule_work(&hda->probe_work); |
1813 | 1865 | ||
1814 | dev++; | 1866 | dev++; |
1815 | if (chip->disabled) | 1867 | if (chip->disabled) |
1816 | complete_all(&chip->probe_wait); | 1868 | complete_all(&hda->probe_wait); |
1817 | return 0; | 1869 | return 0; |
1818 | 1870 | ||
1819 | out_free: | 1871 | out_free: |
@@ -1829,6 +1881,7 @@ static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] = { | |||
1829 | 1881 | ||
1830 | static int azx_probe_continue(struct azx *chip) | 1882 | static int azx_probe_continue(struct azx *chip) |
1831 | { | 1883 | { |
1884 | struct hda_intel *hda = container_of(chip, struct hda_intel, chip); | ||
1832 | struct pci_dev *pci = chip->pci; | 1885 | struct pci_dev *pci = chip->pci; |
1833 | int dev = chip->dev_index; | 1886 | int dev = chip->dev_index; |
1834 | int err; | 1887 | int err; |
@@ -1902,13 +1955,13 @@ static int azx_probe_continue(struct azx *chip) | |||
1902 | power_down_all_codecs(chip); | 1955 | power_down_all_codecs(chip); |
1903 | azx_notifier_register(chip); | 1956 | azx_notifier_register(chip); |
1904 | azx_add_card_list(chip); | 1957 | azx_add_card_list(chip); |
1905 | if ((chip->driver_caps & AZX_DCAPS_PM_RUNTIME) || chip->use_vga_switcheroo) | 1958 | if ((chip->driver_caps & AZX_DCAPS_PM_RUNTIME) || hda->use_vga_switcheroo) |
1906 | pm_runtime_put_noidle(&pci->dev); | 1959 | pm_runtime_put_noidle(&pci->dev); |
1907 | 1960 | ||
1908 | out_free: | 1961 | out_free: |
1909 | if (err < 0) | 1962 | if (err < 0) |
1910 | chip->init_failed = 1; | 1963 | hda->init_failed = 1; |
1911 | complete_all(&chip->probe_wait); | 1964 | complete_all(&hda->probe_wait); |
1912 | return err; | 1965 | return err; |
1913 | } | 1966 | } |
1914 | 1967 | ||