diff options
| author | Takashi Iwai <tiwai@suse.de> | 2012-04-26 06:23:42 -0400 |
|---|---|---|
| committer | Takashi Iwai <tiwai@suse.de> | 2012-05-14 08:55:18 -0400 |
| commit | a82d51ed24bb7994f1f3dff18ec2eefe19385840 (patch) | |
| tree | a01316a2a21d0863fea1b78efcb5b21b35735c78 | |
| parent | d3d020bd11d6f1c45444b208e77268b43d3782ef (diff) | |
ALSA: hda - Support VGA-switcheroo
Add the support for VGA-switcheroo in the HD-audio controller side.
When the graphics controller is disabled, the HD-audio driver also delays
the initialization until it's activated by VGA-switcheroo.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=43155
Signed-off-by: Takashi Iwai <tiwai@suse.de>
| -rw-r--r-- | sound/pci/hda/hda_intel.c | 272 |
1 files changed, 227 insertions, 45 deletions
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index 06a4ad3e5cd2..e7a60402b23f 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c | |||
| @@ -54,6 +54,7 @@ | |||
| 54 | #include <sound/core.h> | 54 | #include <sound/core.h> |
| 55 | #include <sound/initval.h> | 55 | #include <sound/initval.h> |
| 56 | #include <linux/vgaarb.h> | 56 | #include <linux/vgaarb.h> |
| 57 | #include <linux/vga_switcheroo.h> | ||
| 57 | #include "hda_codec.h" | 58 | #include "hda_codec.h" |
| 58 | 59 | ||
| 59 | 60 | ||
| @@ -176,6 +177,13 @@ MODULE_DESCRIPTION("Intel HDA driver"); | |||
| 176 | #define SFX "hda-intel: " | 177 | #define SFX "hda-intel: " |
| 177 | #endif | 178 | #endif |
| 178 | 179 | ||
| 180 | #if defined(CONFIG_PM) && defined(CONFIG_VGA_SWITCHEROO) | ||
| 181 | #ifdef CONFIG_SND_HDA_CODEC_HDMI | ||
| 182 | #define SUPPORT_VGA_SWITCHEROO | ||
| 183 | #endif | ||
| 184 | #endif | ||
| 185 | |||
| 186 | |||
| 179 | /* | 187 | /* |
| 180 | * registers | 188 | * registers |
| 181 | */ | 189 | */ |
| @@ -473,6 +481,12 @@ struct azx { | |||
| 473 | unsigned int probing :1; /* codec probing phase */ | 481 | unsigned int probing :1; /* codec probing phase */ |
| 474 | unsigned int snoop:1; | 482 | unsigned int snoop:1; |
| 475 | unsigned int align_buffer_size:1; | 483 | unsigned int align_buffer_size:1; |
| 484 | unsigned int region_requested:1; | ||
| 485 | |||
| 486 | /* VGA-switcheroo setup */ | ||
| 487 | unsigned int use_vga_switcheroo:1; | ||
| 488 | unsigned int init_failed:1; /* delayed init failed */ | ||
| 489 | unsigned int disabled:1; /* disabled by VGA-switcher */ | ||
| 476 | 490 | ||
| 477 | /* for debugging */ | 491 | /* for debugging */ |
| 478 | unsigned int last_cmd[AZX_MAX_CODECS]; | 492 | unsigned int last_cmd[AZX_MAX_CODECS]; |
| @@ -539,7 +553,20 @@ enum { | |||
| 539 | #define AZX_DCAPS_PRESET_CTHDA \ | 553 | #define AZX_DCAPS_PRESET_CTHDA \ |
| 540 | (AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY) | 554 | (AZX_DCAPS_NO_MSI | AZX_DCAPS_POSFIX_LPIB | AZX_DCAPS_4K_BDLE_BOUNDARY) |
| 541 | 555 | ||
| 542 | static char *driver_short_names[] __devinitdata = { | 556 | /* |
| 557 | * VGA-switcher support | ||
| 558 | */ | ||
| 559 | #ifdef SUPPORT_VGA_SWITCHEROO | ||
| 560 | #define DELAYED_INIT_MARK | ||
| 561 | #define DELAYED_INITDATA_MARK | ||
| 562 | #define use_vga_switcheroo(chip) ((chip)->use_vga_switcheroo) | ||
| 563 | #else | ||
| 564 | #define DELAYED_INIT_MARK __devinit | ||
| 565 | #define DELAYED_INITDATA_MARK __devinitdata | ||
| 566 | #define use_vga_switcheroo(chip) 0 | ||
| 567 | #endif | ||
| 568 | |||
| 569 | static char *driver_short_names[] DELAYED_INITDATA_MARK = { | ||
| 543 | [AZX_DRIVER_ICH] = "HDA Intel", | 570 | [AZX_DRIVER_ICH] = "HDA Intel", |
| 544 | [AZX_DRIVER_PCH] = "HDA Intel PCH", | 571 | [AZX_DRIVER_PCH] = "HDA Intel PCH", |
| 545 | [AZX_DRIVER_SCH] = "HDA Intel MID", | 572 | [AZX_DRIVER_SCH] = "HDA Intel MID", |
| @@ -958,6 +985,8 @@ static int azx_send_cmd(struct hda_bus *bus, unsigned int val) | |||
| 958 | { | 985 | { |
| 959 | struct azx *chip = bus->private_data; | 986 | struct azx *chip = bus->private_data; |
| 960 | 987 | ||
| 988 | if (chip->disabled) | ||
| 989 | return 0; | ||
| 961 | chip->last_cmd[azx_command_addr(val)] = val; | 990 | chip->last_cmd[azx_command_addr(val)] = val; |
| 962 | if (chip->single_cmd) | 991 | if (chip->single_cmd) |
| 963 | return azx_single_send_cmd(bus, val); | 992 | return azx_single_send_cmd(bus, val); |
| @@ -970,6 +999,8 @@ static unsigned int azx_get_response(struct hda_bus *bus, | |||
| 970 | unsigned int addr) | 999 | unsigned int addr) |
| 971 | { | 1000 | { |
| 972 | struct azx *chip = bus->private_data; | 1001 | struct azx *chip = bus->private_data; |
| 1002 | if (chip->disabled) | ||
| 1003 | return 0; | ||
| 973 | if (chip->single_cmd) | 1004 | if (chip->single_cmd) |
| 974 | return azx_single_get_response(bus, addr); | 1005 | return azx_single_get_response(bus, addr); |
| 975 | else | 1006 | else |
| @@ -1235,6 +1266,9 @@ static irqreturn_t azx_interrupt(int irq, void *dev_id) | |||
| 1235 | 1266 | ||
| 1236 | spin_lock(&chip->reg_lock); | 1267 | spin_lock(&chip->reg_lock); |
| 1237 | 1268 | ||
| 1269 | if (chip->disabled) | ||
| 1270 | return IRQ_NONE; | ||
| 1271 | |||
| 1238 | status = azx_readl(chip, INTSTS); | 1272 | status = azx_readl(chip, INTSTS); |
| 1239 | if (status == 0) { | 1273 | if (status == 0) { |
| 1240 | spin_unlock(&chip->reg_lock); | 1274 | spin_unlock(&chip->reg_lock); |
| @@ -1520,12 +1554,12 @@ static void azx_bus_reset(struct hda_bus *bus) | |||
| 1520 | */ | 1554 | */ |
| 1521 | 1555 | ||
| 1522 | /* number of codec slots for each chipset: 0 = default slots (i.e. 4) */ | 1556 | /* number of codec slots for each chipset: 0 = default slots (i.e. 4) */ |
| 1523 | static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = { | 1557 | static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] DELAYED_INITDATA_MARK = { |
| 1524 | [AZX_DRIVER_NVIDIA] = 8, | 1558 | [AZX_DRIVER_NVIDIA] = 8, |
| 1525 | [AZX_DRIVER_TERA] = 1, | 1559 | [AZX_DRIVER_TERA] = 1, |
| 1526 | }; | 1560 | }; |
| 1527 | 1561 | ||
| 1528 | static int __devinit azx_codec_create(struct azx *chip, const char *model) | 1562 | static int DELAYED_INIT_MARK azx_codec_create(struct azx *chip, const char *model) |
| 1529 | { | 1563 | { |
| 1530 | struct hda_bus_template bus_temp; | 1564 | struct hda_bus_template bus_temp; |
| 1531 | int c, codecs, err; | 1565 | int c, codecs, err; |
| @@ -2443,6 +2477,105 @@ static void azx_notifier_unregister(struct azx *chip) | |||
| 2443 | unregister_reboot_notifier(&chip->reboot_notifier); | 2477 | unregister_reboot_notifier(&chip->reboot_notifier); |
| 2444 | } | 2478 | } |
| 2445 | 2479 | ||
| 2480 | static int DELAYED_INIT_MARK azx_first_init(struct azx *chip); | ||
| 2481 | static int DELAYED_INIT_MARK azx_probe_continue(struct azx *chip); | ||
| 2482 | |||
| 2483 | static struct pci_dev __devinit *get_bound_vga(struct pci_dev *pci); | ||
| 2484 | |||
| 2485 | #ifdef SUPPORT_VGA_SWITCHEROO | ||
| 2486 | static void azx_vs_set_state(struct pci_dev *pci, | ||
| 2487 | enum vga_switcheroo_state state) | ||
| 2488 | { | ||
| 2489 | struct snd_card *card = pci_get_drvdata(pci); | ||
| 2490 | struct azx *chip = card->private_data; | ||
| 2491 | bool disabled; | ||
| 2492 | |||
| 2493 | if (chip->init_failed) | ||
| 2494 | return; | ||
| 2495 | |||
| 2496 | disabled = (state == VGA_SWITCHEROO_OFF); | ||
| 2497 | if (chip->disabled == disabled) | ||
| 2498 | return; | ||
| 2499 | |||
| 2500 | if (!chip->bus) { | ||
| 2501 | chip->disabled = disabled; | ||
| 2502 | if (!disabled) { | ||
| 2503 | snd_printk(KERN_INFO SFX | ||
| 2504 | "%s: Start delayed initialization\n", | ||
| 2505 | pci_name(chip->pci)); | ||
| 2506 | if (azx_first_init(chip) < 0 || | ||
| 2507 | azx_probe_continue(chip) < 0) { | ||
| 2508 | snd_printk(KERN_ERR SFX | ||
| 2509 | "%s: initialization error\n", | ||
| 2510 | pci_name(chip->pci)); | ||
| 2511 | chip->init_failed = true; | ||
| 2512 | } | ||
| 2513 | } | ||
| 2514 | } else { | ||
| 2515 | snd_printk(KERN_INFO SFX | ||
| 2516 | "%s %s via VGA-switcheroo\n", | ||
| 2517 | disabled ? "Disabling" : "Enabling", | ||
| 2518 | pci_name(chip->pci)); | ||
| 2519 | if (disabled) { | ||
| 2520 | azx_suspend(pci, PMSG_FREEZE); | ||
| 2521 | chip->disabled = true; | ||
| 2522 | snd_hda_lock_devices(chip->bus); | ||
| 2523 | } else { | ||
| 2524 | snd_hda_unlock_devices(chip->bus); | ||
| 2525 | chip->disabled = false; | ||
| 2526 | azx_resume(pci); | ||
| 2527 | } | ||
| 2528 | } | ||
| 2529 | } | ||
| 2530 | |||
| 2531 | static bool azx_vs_can_switch(struct pci_dev *pci) | ||
| 2532 | { | ||
| 2533 | struct snd_card *card = pci_get_drvdata(pci); | ||
| 2534 | struct azx *chip = card->private_data; | ||
| 2535 | |||
| 2536 | if (chip->init_failed) | ||
| 2537 | return false; | ||
| 2538 | if (chip->disabled || !chip->bus) | ||
| 2539 | return true; | ||
| 2540 | if (snd_hda_lock_devices(chip->bus)) | ||
| 2541 | return false; | ||
| 2542 | snd_hda_unlock_devices(chip->bus); | ||
| 2543 | return true; | ||
| 2544 | } | ||
| 2545 | |||
| 2546 | static void __devinit init_vga_switcheroo(struct azx *chip) | ||
| 2547 | { | ||
| 2548 | struct pci_dev *p = get_bound_vga(chip->pci); | ||
| 2549 | if (p) { | ||
| 2550 | snd_printk(KERN_INFO SFX | ||
| 2551 | "%s: Handle VGA-switcheroo audio client\n", | ||
| 2552 | pci_name(chip->pci)); | ||
| 2553 | chip->use_vga_switcheroo = 1; | ||
| 2554 | pci_dev_put(p); | ||
| 2555 | } | ||
| 2556 | } | ||
| 2557 | |||
| 2558 | static const struct vga_switcheroo_client_ops azx_vs_ops = { | ||
| 2559 | .set_gpu_state = azx_vs_set_state, | ||
| 2560 | .can_switch = azx_vs_can_switch, | ||
| 2561 | }; | ||
| 2562 | |||
| 2563 | static int __devinit register_vga_switcheroo(struct azx *chip) | ||
| 2564 | { | ||
| 2565 | if (!chip->use_vga_switcheroo) | ||
| 2566 | return 0; | ||
| 2567 | /* FIXME: currently only handling DIS controller | ||
| 2568 | * is there any machine with two switchable HDMI audio controllers? | ||
| 2569 | */ | ||
| 2570 | return vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, | ||
| 2571 | VGA_SWITCHEROO_DIS, | ||
| 2572 | chip->bus != NULL); | ||
| 2573 | } | ||
| 2574 | #else | ||
| 2575 | #define init_vga_switcheroo(chip) /* NOP */ | ||
| 2576 | #define register_vga_switcheroo(chip) 0 | ||
| 2577 | #endif /* SUPPORT_VGA_SWITCHER */ | ||
| 2578 | |||
| 2446 | /* | 2579 | /* |
| 2447 | * destructor | 2580 | * destructor |
| 2448 | */ | 2581 | */ |
| @@ -2452,6 +2585,12 @@ static int azx_free(struct azx *chip) | |||
| 2452 | 2585 | ||
| 2453 | azx_notifier_unregister(chip); | 2586 | azx_notifier_unregister(chip); |
| 2454 | 2587 | ||
| 2588 | if (use_vga_switcheroo(chip)) { | ||
| 2589 | if (chip->disabled && chip->bus) | ||
| 2590 | snd_hda_unlock_devices(chip->bus); | ||
| 2591 | vga_switcheroo_unregister_client(chip->pci); | ||
| 2592 | } | ||
| 2593 | |||
| 2455 | if (chip->initialized) { | 2594 | if (chip->initialized) { |
| 2456 | azx_clear_irq_pending(chip); | 2595 | azx_clear_irq_pending(chip); |
| 2457 | for (i = 0; i < chip->num_streams; i++) | 2596 | for (i = 0; i < chip->num_streams; i++) |
| @@ -2481,7 +2620,8 @@ static int azx_free(struct azx *chip) | |||
| 2481 | mark_pages_wc(chip, &chip->posbuf, false); | 2620 | mark_pages_wc(chip, &chip->posbuf, false); |
| 2482 | snd_dma_free_pages(&chip->posbuf); | 2621 | snd_dma_free_pages(&chip->posbuf); |
| 2483 | } | 2622 | } |
| 2484 | pci_release_regions(chip->pci); | 2623 | if (chip->region_requested) |
| 2624 | pci_release_regions(chip->pci); | ||
| 2485 | pci_disable_device(chip->pci); | 2625 | pci_disable_device(chip->pci); |
| 2486 | kfree(chip->azx_dev); | 2626 | kfree(chip->azx_dev); |
| 2487 | kfree(chip); | 2627 | kfree(chip); |
| @@ -2708,12 +2848,11 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
| 2708 | int dev, unsigned int driver_caps, | 2848 | int dev, unsigned int driver_caps, |
| 2709 | struct azx **rchip) | 2849 | struct azx **rchip) |
| 2710 | { | 2850 | { |
| 2711 | struct azx *chip; | ||
| 2712 | int i, err; | ||
| 2713 | unsigned short gcap; | ||
| 2714 | static struct snd_device_ops ops = { | 2851 | static struct snd_device_ops ops = { |
| 2715 | .dev_free = azx_dev_free, | 2852 | .dev_free = azx_dev_free, |
| 2716 | }; | 2853 | }; |
| 2854 | struct azx *chip; | ||
| 2855 | int err; | ||
| 2717 | 2856 | ||
| 2718 | *rchip = NULL; | 2857 | *rchip = NULL; |
| 2719 | 2858 | ||
| @@ -2739,6 +2878,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
| 2739 | chip->dev_index = dev; | 2878 | chip->dev_index = dev; |
| 2740 | INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work); | 2879 | INIT_WORK(&chip->irq_pending_work, azx_irq_pending_work); |
| 2741 | INIT_LIST_HEAD(&chip->pcm_list); | 2880 | INIT_LIST_HEAD(&chip->pcm_list); |
| 2881 | init_vga_switcheroo(chip); | ||
| 2742 | 2882 | ||
| 2743 | chip->position_fix[0] = chip->position_fix[1] = | 2883 | chip->position_fix[0] = chip->position_fix[1] = |
| 2744 | check_position_fix(chip, position_fix[dev]); | 2884 | check_position_fix(chip, position_fix[dev]); |
| @@ -2766,6 +2906,53 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
| 2766 | } | 2906 | } |
| 2767 | } | 2907 | } |
| 2768 | 2908 | ||
| 2909 | if (check_hdmi_disabled(pci)) { | ||
| 2910 | snd_printk(KERN_INFO SFX "VGA controller for %s is disabled\n", | ||
| 2911 | pci_name(pci)); | ||
| 2912 | if (use_vga_switcheroo(chip)) { | ||
| 2913 | snd_printk(KERN_INFO SFX "Delaying initialization\n"); | ||
| 2914 | chip->disabled = true; | ||
| 2915 | goto ok; | ||
| 2916 | } | ||
| 2917 | kfree(chip); | ||
| 2918 | pci_disable_device(pci); | ||
| 2919 | return -ENXIO; | ||
| 2920 | } | ||
| 2921 | |||
| 2922 | err = azx_first_init(chip); | ||
| 2923 | if (err < 0) { | ||
| 2924 | azx_free(chip); | ||
| 2925 | return err; | ||
| 2926 | } | ||
| 2927 | |||
| 2928 | ok: | ||
| 2929 | err = register_vga_switcheroo(chip); | ||
| 2930 | if (err < 0) { | ||
| 2931 | snd_printk(KERN_ERR SFX | ||
| 2932 | "Error registering VGA-switcheroo client\n"); | ||
| 2933 | azx_free(chip); | ||
| 2934 | return err; | ||
| 2935 | } | ||
| 2936 | |||
| 2937 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); | ||
| 2938 | if (err < 0) { | ||
| 2939 | snd_printk(KERN_ERR SFX "Error creating device [card]!\n"); | ||
| 2940 | azx_free(chip); | ||
| 2941 | return err; | ||
| 2942 | } | ||
| 2943 | |||
| 2944 | *rchip = chip; | ||
| 2945 | return 0; | ||
| 2946 | } | ||
| 2947 | |||
| 2948 | static int DELAYED_INIT_MARK azx_first_init(struct azx *chip) | ||
| 2949 | { | ||
| 2950 | int dev = chip->dev_index; | ||
| 2951 | struct pci_dev *pci = chip->pci; | ||
| 2952 | struct snd_card *card = chip->card; | ||
| 2953 | int i, err; | ||
| 2954 | unsigned short gcap; | ||
| 2955 | |||
| 2769 | #if BITS_PER_LONG != 64 | 2956 | #if BITS_PER_LONG != 64 |
| 2770 | /* Fix up base address on ULI M5461 */ | 2957 | /* Fix up base address on ULI M5461 */ |
| 2771 | if (chip->driver_type == AZX_DRIVER_ULI) { | 2958 | if (chip->driver_type == AZX_DRIVER_ULI) { |
| @@ -2777,28 +2964,23 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
| 2777 | #endif | 2964 | #endif |
| 2778 | 2965 | ||
| 2779 | err = pci_request_regions(pci, "ICH HD audio"); | 2966 | err = pci_request_regions(pci, "ICH HD audio"); |
| 2780 | if (err < 0) { | 2967 | if (err < 0) |
| 2781 | kfree(chip); | ||
| 2782 | pci_disable_device(pci); | ||
| 2783 | return err; | 2968 | return err; |
| 2784 | } | 2969 | chip->region_requested = 1; |
| 2785 | 2970 | ||
| 2786 | chip->addr = pci_resource_start(pci, 0); | 2971 | chip->addr = pci_resource_start(pci, 0); |
| 2787 | chip->remap_addr = pci_ioremap_bar(pci, 0); | 2972 | chip->remap_addr = pci_ioremap_bar(pci, 0); |
| 2788 | if (chip->remap_addr == NULL) { | 2973 | if (chip->remap_addr == NULL) { |
| 2789 | snd_printk(KERN_ERR SFX "ioremap error\n"); | 2974 | snd_printk(KERN_ERR SFX "ioremap error\n"); |
| 2790 | err = -ENXIO; | 2975 | return -ENXIO; |
| 2791 | goto errout; | ||
| 2792 | } | 2976 | } |
| 2793 | 2977 | ||
| 2794 | if (chip->msi) | 2978 | if (chip->msi) |
| 2795 | if (pci_enable_msi(pci) < 0) | 2979 | if (pci_enable_msi(pci) < 0) |
| 2796 | chip->msi = 0; | 2980 | chip->msi = 0; |
| 2797 | 2981 | ||
| 2798 | if (azx_acquire_irq(chip, 0) < 0) { | 2982 | if (azx_acquire_irq(chip, 0) < 0) |
| 2799 | err = -EBUSY; | 2983 | return -EBUSY; |
| 2800 | goto errout; | ||
| 2801 | } | ||
| 2802 | 2984 | ||
| 2803 | pci_set_master(pci); | 2985 | pci_set_master(pci); |
| 2804 | synchronize_irq(chip->irq); | 2986 | synchronize_irq(chip->irq); |
| @@ -2877,7 +3059,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
| 2877 | GFP_KERNEL); | 3059 | GFP_KERNEL); |
| 2878 | if (!chip->azx_dev) { | 3060 | if (!chip->azx_dev) { |
| 2879 | snd_printk(KERN_ERR SFX "cannot malloc azx_dev\n"); | 3061 | snd_printk(KERN_ERR SFX "cannot malloc azx_dev\n"); |
| 2880 | goto errout; | 3062 | return -ENOMEM; |
| 2881 | } | 3063 | } |
| 2882 | 3064 | ||
| 2883 | for (i = 0; i < chip->num_streams; i++) { | 3065 | for (i = 0; i < chip->num_streams; i++) { |
| @@ -2887,7 +3069,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
| 2887 | BDL_SIZE, &chip->azx_dev[i].bdl); | 3069 | BDL_SIZE, &chip->azx_dev[i].bdl); |
| 2888 | if (err < 0) { | 3070 | if (err < 0) { |
| 2889 | snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); | 3071 | snd_printk(KERN_ERR SFX "cannot allocate BDL\n"); |
| 2890 | goto errout; | 3072 | return -ENOMEM; |
| 2891 | } | 3073 | } |
| 2892 | mark_pages_wc(chip, &chip->azx_dev[i].bdl, true); | 3074 | mark_pages_wc(chip, &chip->azx_dev[i].bdl, true); |
| 2893 | } | 3075 | } |
| @@ -2897,13 +3079,13 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
| 2897 | chip->num_streams * 8, &chip->posbuf); | 3079 | chip->num_streams * 8, &chip->posbuf); |
| 2898 | if (err < 0) { | 3080 | if (err < 0) { |
| 2899 | snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); | 3081 | snd_printk(KERN_ERR SFX "cannot allocate posbuf\n"); |
| 2900 | goto errout; | 3082 | return -ENOMEM; |
| 2901 | } | 3083 | } |
| 2902 | mark_pages_wc(chip, &chip->posbuf, true); | 3084 | mark_pages_wc(chip, &chip->posbuf, true); |
| 2903 | /* allocate CORB/RIRB */ | 3085 | /* allocate CORB/RIRB */ |
| 2904 | err = azx_alloc_cmd_io(chip); | 3086 | err = azx_alloc_cmd_io(chip); |
| 2905 | if (err < 0) | 3087 | if (err < 0) |
| 2906 | goto errout; | 3088 | return err; |
| 2907 | 3089 | ||
| 2908 | /* initialize streams */ | 3090 | /* initialize streams */ |
| 2909 | azx_init_stream(chip); | 3091 | azx_init_stream(chip); |
| @@ -2915,14 +3097,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
| 2915 | /* codec detection */ | 3097 | /* codec detection */ |
| 2916 | if (!chip->codec_mask) { | 3098 | if (!chip->codec_mask) { |
| 2917 | snd_printk(KERN_ERR SFX "no codecs found!\n"); | 3099 | snd_printk(KERN_ERR SFX "no codecs found!\n"); |
| 2918 | err = -ENODEV; | 3100 | return -ENODEV; |
| 2919 | goto errout; | ||
| 2920 | } | ||
| 2921 | |||
| 2922 | err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); | ||
| 2923 | if (err <0) { | ||
| 2924 | snd_printk(KERN_ERR SFX "Error creating device [card]!\n"); | ||
| 2925 | goto errout; | ||
| 2926 | } | 3101 | } |
| 2927 | 3102 | ||
| 2928 | strcpy(card->driver, "HDA-Intel"); | 3103 | strcpy(card->driver, "HDA-Intel"); |
| @@ -2932,12 +3107,7 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci, | |||
| 2932 | "%s at 0x%lx irq %i", | 3107 | "%s at 0x%lx irq %i", |
| 2933 | card->shortname, chip->addr, chip->irq); | 3108 | card->shortname, chip->addr, chip->irq); |
| 2934 | 3109 | ||
| 2935 | *rchip = chip; | ||
| 2936 | return 0; | 3110 | return 0; |
| 2937 | |||
| 2938 | errout: | ||
| 2939 | azx_free(chip); | ||
| 2940 | return err; | ||
| 2941 | } | 3111 | } |
| 2942 | 3112 | ||
| 2943 | static void power_down_all_codecs(struct azx *chip) | 3113 | static void power_down_all_codecs(struct azx *chip) |
| @@ -2968,12 +3138,6 @@ static int __devinit azx_probe(struct pci_dev *pci, | |||
| 2968 | return -ENOENT; | 3138 | return -ENOENT; |
| 2969 | } | 3139 | } |
| 2970 | 3140 | ||
| 2971 | if (check_hdmi_disabled(pci)) { | ||
| 2972 | snd_printk(KERN_INFO SFX | ||
| 2973 | "Inactive VGA controller; disabled audio, too\n"); | ||
| 2974 | goto out; | ||
| 2975 | } | ||
| 2976 | |||
| 2977 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); | 3141 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); |
| 2978 | if (err < 0) { | 3142 | if (err < 0) { |
| 2979 | snd_printk(KERN_ERR SFX "Error creating card!\n"); | 3143 | snd_printk(KERN_ERR SFX "Error creating card!\n"); |
| @@ -2988,6 +3152,27 @@ static int __devinit azx_probe(struct pci_dev *pci, | |||
| 2988 | goto out_free; | 3152 | goto out_free; |
| 2989 | card->private_data = chip; | 3153 | card->private_data = chip; |
| 2990 | 3154 | ||
| 3155 | if (!chip->disabled) { | ||
| 3156 | err = azx_probe_continue(chip); | ||
| 3157 | if (err < 0) | ||
| 3158 | goto out_free; | ||
| 3159 | } | ||
| 3160 | |||
| 3161 | pci_set_drvdata(pci, card); | ||
| 3162 | |||
| 3163 | dev++; | ||
| 3164 | return 0; | ||
| 3165 | |||
| 3166 | out_free: | ||
| 3167 | snd_card_free(card); | ||
| 3168 | return err; | ||
| 3169 | } | ||
| 3170 | |||
| 3171 | static int DELAYED_INIT_MARK azx_probe_continue(struct azx *chip) | ||
| 3172 | { | ||
| 3173 | int dev = chip->dev_index; | ||
| 3174 | int err; | ||
| 3175 | |||
| 2991 | #ifdef CONFIG_SND_HDA_INPUT_BEEP | 3176 | #ifdef CONFIG_SND_HDA_INPUT_BEEP |
| 2992 | chip->beep_mode = beep_mode[dev]; | 3177 | chip->beep_mode = beep_mode[dev]; |
| 2993 | #endif | 3178 | #endif |
| @@ -3021,21 +3206,18 @@ static int __devinit azx_probe(struct pci_dev *pci, | |||
| 3021 | if (err < 0) | 3206 | if (err < 0) |
| 3022 | goto out_free; | 3207 | goto out_free; |
| 3023 | 3208 | ||
| 3024 | err = snd_card_register(card); | 3209 | err = snd_card_register(chip->card); |
| 3025 | if (err < 0) | 3210 | if (err < 0) |
| 3026 | goto out_free; | 3211 | goto out_free; |
| 3027 | 3212 | ||
| 3028 | pci_set_drvdata(pci, card); | ||
| 3029 | chip->running = 1; | 3213 | chip->running = 1; |
| 3030 | power_down_all_codecs(chip); | 3214 | power_down_all_codecs(chip); |
| 3031 | azx_notifier_register(chip); | 3215 | azx_notifier_register(chip); |
| 3032 | 3216 | ||
| 3033 | out: | ||
| 3034 | dev++; | ||
| 3035 | return 0; | 3217 | return 0; |
| 3036 | 3218 | ||
| 3037 | out_free: | 3219 | out_free: |
| 3038 | snd_card_free(card); | 3220 | chip->init_failed = 1; |
| 3039 | return err; | 3221 | return err; |
| 3040 | } | 3222 | } |
| 3041 | 3223 | ||
