Merge tag 'sound-fix-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
"Here are a few remaining patches for 6.1-rc1.

The major changes are the hibernation fixes for HD-audio CS35L41 codec
and the USB-audio small fixes against the last change. In addition, a
couple of HD-audio regression fixes and a couple of potential
mutex-deadlock fixes with OSS emulation in ALSA core side are seen"

* tag 'sound-fix-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
ALSA: hda: cs35l41: Support System Suspend
ALSA: hda: cs35l41: Remove suspend/resume hda hooks
ALSA: hda/cs_dsp_ctl: Fix mutex inversion when creating controls
ALSA: hda: hda_cs_dsp_ctl: Ensure pwr_lock is held before reading/writing controls
ALSA: hda: hda_cs_dsp_ctl: Minor clean and redundant code removal
ALSA: oss: Fix potential deadlock at unregistration
ALSA: rawmidi: Drop register_mutex in snd_rawmidi_free()
ALSA: hda/realtek: Add Intel Reference SSID to support headset keys
ALSA: hda/realtek: Add quirk for ASUS GV601R laptop
ALSA: hda/realtek: Correct pin configs for ASUS G533Z
ALSA: usb-audio: Avoid superfluous endpoint setup
ALSA: usb-audio: Correct the return code from snd_usb_endpoint_set_params()
ALSA: usb-audio: Apply mutex around snd_usb_endpoint_set_params()
ALSA: usb-audio: Avoid unnecessary interface change at EP close
ALSA: hda: Update register polling macros
ALSA: hda/realtek: remove ALC289_FIXUP_DUAL_SPK for Dell 5530

+246 -124
+4 -4
include/sound/hdaudio.h
··· 592 #define snd_hdac_stream_readb(dev, reg) \ 593 snd_hdac_reg_readb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) 594 #define snd_hdac_stream_readb_poll(dev, reg, val, cond, delay_us, timeout_us) \ 595 - readb_poll_timeout((dev)->sd_addr + AZX_REG_ ## reg, val, cond, \ 596 - delay_us, timeout_us) 597 #define snd_hdac_stream_readl_poll(dev, reg, val, cond, delay_us, timeout_us) \ 598 - readl_poll_timeout((dev)->sd_addr + AZX_REG_ ## reg, val, cond, \ 599 - delay_us, timeout_us) 600 601 /* update a register, pass without AZX_REG_ prefix */ 602 #define snd_hdac_stream_updatel(dev, reg, mask, val) \
··· 592 #define snd_hdac_stream_readb(dev, reg) \ 593 snd_hdac_reg_readb((dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) 594 #define snd_hdac_stream_readb_poll(dev, reg, val, cond, delay_us, timeout_us) \ 595 + read_poll_timeout_atomic(snd_hdac_reg_readb, val, cond, delay_us, timeout_us, \ 596 + false, (dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) 597 #define snd_hdac_stream_readl_poll(dev, reg, val, cond, delay_us, timeout_us) \ 598 + read_poll_timeout_atomic(snd_hdac_reg_readl, val, cond, delay_us, timeout_us, \ 599 + false, (dev)->bus, (dev)->sd_addr + AZX_REG_ ## reg) 600 601 /* update a register, pass without AZX_REG_ prefix */ 602 #define snd_hdac_stream_updatel(dev, reg, mask, val) \
-2
sound/core/rawmidi.c
··· 1899 1900 snd_info_free_entry(rmidi->proc_entry); 1901 rmidi->proc_entry = NULL; 1902 - mutex_lock(&register_mutex); 1903 if (rmidi->ops && rmidi->ops->dev_unregister) 1904 rmidi->ops->dev_unregister(rmidi); 1905 - mutex_unlock(&register_mutex); 1906 1907 snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]); 1908 snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]);
··· 1899 1900 snd_info_free_entry(rmidi->proc_entry); 1901 rmidi->proc_entry = NULL; 1902 if (rmidi->ops && rmidi->ops->dev_unregister) 1903 rmidi->ops->dev_unregister(rmidi); 1904 1905 snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]); 1906 snd_rawmidi_free_substreams(&rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]);
+9 -4
sound/core/sound_oss.c
··· 162 mutex_unlock(&sound_oss_mutex); 163 return -ENOENT; 164 } 165 - unregister_sound_special(minor); 166 switch (SNDRV_MINOR_OSS_DEVICE(minor)) { 167 case SNDRV_MINOR_OSS_PCM: 168 track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_AUDIO); ··· 173 track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1); 174 break; 175 } 176 - if (track2 >= 0) { 177 - unregister_sound_special(track2); 178 snd_oss_minors[track2] = NULL; 179 - } 180 snd_oss_minors[minor] = NULL; 181 mutex_unlock(&sound_oss_mutex); 182 kfree(mptr); 183 return 0; 184 }
··· 162 mutex_unlock(&sound_oss_mutex); 163 return -ENOENT; 164 } 165 switch (SNDRV_MINOR_OSS_DEVICE(minor)) { 166 case SNDRV_MINOR_OSS_PCM: 167 track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_AUDIO); ··· 174 track2 = SNDRV_MINOR_OSS(cidx, SNDRV_MINOR_OSS_DMMIDI1); 175 break; 176 } 177 + if (track2 >= 0) 178 snd_oss_minors[track2] = NULL; 179 snd_oss_minors[minor] = NULL; 180 mutex_unlock(&sound_oss_mutex); 181 + 182 + /* call unregister_sound_special() outside sound_oss_mutex; 183 + * otherwise may deadlock, as it can trigger the release of a card 184 + */ 185 + unregister_sound_special(minor); 186 + if (track2 >= 0) 187 + unregister_sound_special(track2); 188 + 189 kfree(mptr); 190 return 0; 191 }
+151 -46
sound/pci/hda/cs35l41_hda.c
··· 91 { CS35L41_AMP_DIG_VOL_CTRL, 0x0000A678 }, // AMP_VOL_PCM Mute 92 }; 93 94 - static int cs35l41_control_add(struct cs_dsp_coeff_ctl *cs_ctl) 95 { 96 - struct cs35l41_hda *cs35l41 = container_of(cs_ctl->dsp, struct cs35l41_hda, cs_dsp); 97 struct hda_cs_dsp_ctl_info info; 98 99 info.device_name = cs35l41->amp_name; 100 info.fw_type = cs35l41->firmware_type; 101 info.card = cs35l41->codec->card; 102 103 - return hda_cs_dsp_control_add(cs_ctl, &info); 104 } 105 106 static const struct cs_dsp_client_ops client_ops = { 107 - .control_add = cs35l41_control_add, 108 .control_remove = hda_cs_dsp_control_remove, 109 }; 110 ··· 433 if (ret) 434 goto err_release; 435 436 ret = cs35l41_save_calibration(cs35l41); 437 438 err_release: ··· 461 struct cs_dsp *dsp = &cs35l41->cs_dsp; 462 463 cancel_work_sync(&cs35l41->fw_load_work); 464 cs35l41_shutdown_dsp(cs35l41); 465 cs_dsp_remove(dsp); 466 cs35l41->halo_initialized = false; 467 } 468 469 /* Protection release cycle to get the speaker out of Safe-Mode */ ··· 490 struct regmap *reg = cs35l41->regmap; 491 int ret = 0; 492 493 - mutex_lock(&cs35l41->fw_mutex); 494 - 495 switch (action) { 496 case HDA_GEN_PCM_ACT_OPEN: 497 cs35l41->playback_started = true; 498 if (cs35l41->firmware_running) { 499 regmap_multi_reg_write(reg, cs35l41_hda_config_dsp, ··· 511 CS35L41_AMP_EN_MASK, 1 << CS35L41_AMP_EN_SHIFT); 512 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) 513 regmap_write(reg, CS35L41_GPIO1_CTRL1, 0x00008001); 514 break; 515 case HDA_GEN_PCM_ACT_PREPARE: 516 ret = cs35l41_global_enable(reg, cs35l41->hw_cfg.bst_type, 1); 517 break; 518 case HDA_GEN_PCM_ACT_CLEANUP: 519 regmap_multi_reg_write(reg, cs35l41_hda_mute, ARRAY_SIZE(cs35l41_hda_mute)); 520 ret = cs35l41_global_enable(reg, cs35l41->hw_cfg.bst_type, 0); 521 break; 522 case HDA_GEN_PCM_ACT_CLOSE: 523 ret = regmap_update_bits(reg, CS35L41_PWR_CTRL2, 524 CS35L41_AMP_EN_MASK, 0 << CS35L41_AMP_EN_SHIFT); 525 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) ··· 539 } 540 cs35l41_irq_release(cs35l41); 541 cs35l41->playback_started = false; 542 break; 543 default: 544 dev_warn(cs35l41->dev, "Playback action not supported: %d\n", action); 545 break; 546 } 547 - 548 - mutex_unlock(&cs35l41->fw_mutex); 549 550 if (ret) 551 dev_err(cs35l41->dev, "Regmap access fail: %d\n", ret); ··· 573 rx_slot); 574 } 575 576 static int cs35l41_runtime_suspend(struct device *dev) 577 { 578 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); 579 580 - dev_dbg(cs35l41->dev, "Suspend\n"); 581 582 - if (!cs35l41->firmware_running) 583 return 0; 584 585 - if (cs35l41_enter_hibernate(cs35l41->dev, cs35l41->regmap, cs35l41->hw_cfg.bst_type) < 0) 586 - return 0; 587 588 regcache_cache_only(cs35l41->regmap, true); 589 regcache_mark_dirty(cs35l41->regmap); 590 591 - return 0; 592 } 593 594 static int cs35l41_runtime_resume(struct device *dev) 595 { 596 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); 597 - int ret; 598 599 - dev_dbg(cs35l41->dev, "Resume.\n"); 600 601 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { 602 - dev_dbg(cs35l41->dev, "System does not support Resume\n"); 603 return 0; 604 } 605 606 - if (!cs35l41->firmware_running) 607 - return 0; 608 609 regcache_cache_only(cs35l41->regmap, false); 610 611 - ret = cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); 612 - if (ret) { 613 - regcache_cache_only(cs35l41->regmap, true); 614 - return ret; 615 } 616 617 /* Test key needs to be unlocked to allow the OTP settings to re-apply */ ··· 723 cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); 724 if (ret) { 725 dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret); 726 - return ret; 727 } 728 729 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) 730 cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, &cs35l41->hw_cfg); 731 732 - return 0; 733 - } 734 735 - static int cs35l41_hda_suspend_hook(struct device *dev) 736 - { 737 - dev_dbg(dev, "Request Suspend\n"); 738 - pm_runtime_mark_last_busy(dev); 739 - return pm_runtime_put_autosuspend(dev); 740 - } 741 - 742 - static int cs35l41_hda_resume_hook(struct device *dev) 743 - { 744 - dev_dbg(dev, "Request Resume\n"); 745 - return pm_runtime_get_sync(dev); 746 } 747 748 static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41) ··· 782 783 static void cs35l41_load_firmware(struct cs35l41_hda *cs35l41, bool load) 784 { 785 - pm_runtime_get_sync(cs35l41->dev); 786 - 787 if (cs35l41->firmware_running && !load) { 788 dev_dbg(cs35l41->dev, "Unloading Firmware\n"); 789 cs35l41_shutdown_dsp(cs35l41); ··· 791 } else { 792 dev_dbg(cs35l41->dev, "Unable to Load firmware.\n"); 793 } 794 - 795 - pm_runtime_mark_last_busy(cs35l41->dev); 796 - pm_runtime_put_autosuspend(cs35l41->dev); 797 } 798 799 static int cs35l41_fw_load_ctl_get(struct snd_kcontrol *kcontrol, ··· 806 { 807 struct cs35l41_hda *cs35l41 = container_of(work, struct cs35l41_hda, fw_load_work); 808 809 mutex_lock(&cs35l41->fw_mutex); 810 811 /* Recheck if playback is ongoing, mutex will block playback during firmware loading */ 812 if (cs35l41->playback_started) 813 - dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback\n"); 814 else 815 cs35l41_load_firmware(cs35l41, cs35l41->request_fw_load); 816 817 cs35l41->fw_request_ongoing = false; 818 mutex_unlock(&cs35l41->fw_mutex); 819 } 820 821 static int cs35l41_fw_load_ctl_put(struct snd_kcontrol *kcontrol, ··· 944 945 pm_runtime_get_sync(dev); 946 947 comps->dev = dev; 948 if (!cs35l41->acpi_subsystem_id) 949 cs35l41->acpi_subsystem_id = kasprintf(GFP_KERNEL, "%.8x", ··· 958 if (firmware_autostart) { 959 dev_dbg(cs35l41->dev, "Firmware Autostart.\n"); 960 cs35l41->request_fw_load = true; 961 - mutex_lock(&cs35l41->fw_mutex); 962 if (cs35l41_smart_amp(cs35l41) < 0) 963 dev_warn(cs35l41->dev, "Cannot Run Firmware, reverting to dsp bypass...\n"); 964 - mutex_unlock(&cs35l41->fw_mutex); 965 } else { 966 dev_dbg(cs35l41->dev, "Firmware Autostart is disabled.\n"); 967 } ··· 967 ret = cs35l41_create_controls(cs35l41); 968 969 comps->playback_hook = cs35l41_hda_playback_hook; 970 - comps->suspend_hook = cs35l41_hda_suspend_hook; 971 - comps->resume_hook = cs35l41_hda_resume_hook; 972 973 pm_runtime_mark_last_busy(dev); 974 pm_runtime_put_autosuspend(dev); ··· 1537 1538 const struct dev_pm_ops cs35l41_hda_pm_ops = { 1539 RUNTIME_PM_OPS(cs35l41_runtime_suspend, cs35l41_runtime_resume, NULL) 1540 }; 1541 EXPORT_SYMBOL_NS_GPL(cs35l41_hda_pm_ops, SND_HDA_SCODEC_CS35L41); 1542
··· 91 { CS35L41_AMP_DIG_VOL_CTRL, 0x0000A678 }, // AMP_VOL_PCM Mute 92 }; 93 94 + static void cs35l41_add_controls(struct cs35l41_hda *cs35l41) 95 { 96 struct hda_cs_dsp_ctl_info info; 97 98 info.device_name = cs35l41->amp_name; 99 info.fw_type = cs35l41->firmware_type; 100 info.card = cs35l41->codec->card; 101 102 + hda_cs_dsp_add_controls(&cs35l41->cs_dsp, &info); 103 } 104 105 static const struct cs_dsp_client_ops client_ops = { 106 .control_remove = hda_cs_dsp_control_remove, 107 }; 108 ··· 435 if (ret) 436 goto err_release; 437 438 + cs35l41_add_controls(cs35l41); 439 + 440 ret = cs35l41_save_calibration(cs35l41); 441 442 err_release: ··· 461 struct cs_dsp *dsp = &cs35l41->cs_dsp; 462 463 cancel_work_sync(&cs35l41->fw_load_work); 464 + 465 + mutex_lock(&cs35l41->fw_mutex); 466 cs35l41_shutdown_dsp(cs35l41); 467 cs_dsp_remove(dsp); 468 cs35l41->halo_initialized = false; 469 + mutex_unlock(&cs35l41->fw_mutex); 470 } 471 472 /* Protection release cycle to get the speaker out of Safe-Mode */ ··· 487 struct regmap *reg = cs35l41->regmap; 488 int ret = 0; 489 490 switch (action) { 491 case HDA_GEN_PCM_ACT_OPEN: 492 + pm_runtime_get_sync(dev); 493 + mutex_lock(&cs35l41->fw_mutex); 494 cs35l41->playback_started = true; 495 if (cs35l41->firmware_running) { 496 regmap_multi_reg_write(reg, cs35l41_hda_config_dsp, ··· 508 CS35L41_AMP_EN_MASK, 1 << CS35L41_AMP_EN_SHIFT); 509 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) 510 regmap_write(reg, CS35L41_GPIO1_CTRL1, 0x00008001); 511 + mutex_unlock(&cs35l41->fw_mutex); 512 break; 513 case HDA_GEN_PCM_ACT_PREPARE: 514 + mutex_lock(&cs35l41->fw_mutex); 515 ret = cs35l41_global_enable(reg, cs35l41->hw_cfg.bst_type, 1); 516 + mutex_unlock(&cs35l41->fw_mutex); 517 break; 518 case HDA_GEN_PCM_ACT_CLEANUP: 519 + mutex_lock(&cs35l41->fw_mutex); 520 regmap_multi_reg_write(reg, cs35l41_hda_mute, ARRAY_SIZE(cs35l41_hda_mute)); 521 ret = cs35l41_global_enable(reg, cs35l41->hw_cfg.bst_type, 0); 522 + mutex_unlock(&cs35l41->fw_mutex); 523 break; 524 case HDA_GEN_PCM_ACT_CLOSE: 525 + mutex_lock(&cs35l41->fw_mutex); 526 ret = regmap_update_bits(reg, CS35L41_PWR_CTRL2, 527 CS35L41_AMP_EN_MASK, 0 << CS35L41_AMP_EN_SHIFT); 528 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) ··· 530 } 531 cs35l41_irq_release(cs35l41); 532 cs35l41->playback_started = false; 533 + mutex_unlock(&cs35l41->fw_mutex); 534 + 535 + pm_runtime_mark_last_busy(dev); 536 + pm_runtime_put_autosuspend(dev); 537 break; 538 default: 539 dev_warn(cs35l41->dev, "Playback action not supported: %d\n", action); 540 break; 541 } 542 543 if (ret) 544 dev_err(cs35l41->dev, "Regmap access fail: %d\n", ret); ··· 562 rx_slot); 563 } 564 565 + static void cs35l41_ready_for_reset(struct cs35l41_hda *cs35l41) 566 + { 567 + mutex_lock(&cs35l41->fw_mutex); 568 + if (cs35l41->firmware_running) { 569 + 570 + regcache_cache_only(cs35l41->regmap, false); 571 + 572 + cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); 573 + cs35l41_shutdown_dsp(cs35l41); 574 + cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type); 575 + 576 + regcache_cache_only(cs35l41->regmap, true); 577 + regcache_mark_dirty(cs35l41->regmap); 578 + } 579 + mutex_unlock(&cs35l41->fw_mutex); 580 + } 581 + 582 + static int cs35l41_system_suspend(struct device *dev) 583 + { 584 + struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); 585 + int ret; 586 + 587 + dev_dbg(cs35l41->dev, "System Suspend\n"); 588 + 589 + if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { 590 + dev_err(cs35l41->dev, "System Suspend not supported\n"); 591 + return -EINVAL; 592 + } 593 + 594 + ret = pm_runtime_force_suspend(dev); 595 + if (ret) 596 + return ret; 597 + 598 + /* Shutdown DSP before system suspend */ 599 + cs35l41_ready_for_reset(cs35l41); 600 + 601 + /* 602 + * Reset GPIO may be shared, so cannot reset here. 603 + * However beyond this point, amps may be powered down. 604 + */ 605 + return 0; 606 + } 607 + 608 + static int cs35l41_system_resume(struct device *dev) 609 + { 610 + struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); 611 + int ret; 612 + 613 + dev_dbg(cs35l41->dev, "System Resume\n"); 614 + 615 + if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { 616 + dev_err(cs35l41->dev, "System Resume not supported\n"); 617 + return -EINVAL; 618 + } 619 + 620 + if (cs35l41->reset_gpio) { 621 + usleep_range(2000, 2100); 622 + gpiod_set_value_cansleep(cs35l41->reset_gpio, 1); 623 + } 624 + 625 + usleep_range(2000, 2100); 626 + 627 + ret = pm_runtime_force_resume(dev); 628 + 629 + mutex_lock(&cs35l41->fw_mutex); 630 + if (!ret && cs35l41->request_fw_load && !cs35l41->fw_request_ongoing) { 631 + cs35l41->fw_request_ongoing = true; 632 + schedule_work(&cs35l41->fw_load_work); 633 + } 634 + mutex_unlock(&cs35l41->fw_mutex); 635 + 636 + return ret; 637 + } 638 + 639 static int cs35l41_runtime_suspend(struct device *dev) 640 { 641 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); 642 + int ret = 0; 643 644 + dev_dbg(cs35l41->dev, "Runtime Suspend\n"); 645 646 + if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { 647 + dev_dbg(cs35l41->dev, "Runtime Suspend not supported\n"); 648 return 0; 649 + } 650 651 + mutex_lock(&cs35l41->fw_mutex); 652 + 653 + if (cs35l41->playback_started) { 654 + regmap_multi_reg_write(cs35l41->regmap, cs35l41_hda_mute, 655 + ARRAY_SIZE(cs35l41_hda_mute)); 656 + cs35l41_global_enable(cs35l41->regmap, cs35l41->hw_cfg.bst_type, 0); 657 + regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2, 658 + CS35L41_AMP_EN_MASK, 0 << CS35L41_AMP_EN_SHIFT); 659 + if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) 660 + regmap_write(cs35l41->regmap, CS35L41_GPIO1_CTRL1, 0x00000001); 661 + regmap_update_bits(cs35l41->regmap, CS35L41_PWR_CTRL2, 662 + CS35L41_VMON_EN_MASK | CS35L41_IMON_EN_MASK, 663 + 0 << CS35L41_VMON_EN_SHIFT | 0 << CS35L41_IMON_EN_SHIFT); 664 + cs35l41->playback_started = false; 665 + } 666 + 667 + if (cs35l41->firmware_running) { 668 + ret = cs35l41_enter_hibernate(cs35l41->dev, cs35l41->regmap, 669 + cs35l41->hw_cfg.bst_type); 670 + if (ret) 671 + goto err; 672 + } else { 673 + cs35l41_safe_reset(cs35l41->regmap, cs35l41->hw_cfg.bst_type); 674 + } 675 676 regcache_cache_only(cs35l41->regmap, true); 677 regcache_mark_dirty(cs35l41->regmap); 678 679 + err: 680 + mutex_unlock(&cs35l41->fw_mutex); 681 + 682 + return ret; 683 } 684 685 static int cs35l41_runtime_resume(struct device *dev) 686 { 687 struct cs35l41_hda *cs35l41 = dev_get_drvdata(dev); 688 + int ret = 0; 689 690 + dev_dbg(cs35l41->dev, "Runtime Resume\n"); 691 692 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST_NO_VSPK_SWITCH) { 693 + dev_dbg(cs35l41->dev, "Runtime Resume not supported\n"); 694 return 0; 695 } 696 697 + mutex_lock(&cs35l41->fw_mutex); 698 699 regcache_cache_only(cs35l41->regmap, false); 700 701 + if (cs35l41->firmware_running) { 702 + ret = cs35l41_exit_hibernate(cs35l41->dev, cs35l41->regmap); 703 + if (ret) { 704 + dev_warn(cs35l41->dev, "Unable to exit Hibernate."); 705 + goto err; 706 + } 707 } 708 709 /* Test key needs to be unlocked to allow the OTP settings to re-apply */ ··· 609 cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap); 610 if (ret) { 611 dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret); 612 + goto err; 613 } 614 615 if (cs35l41->hw_cfg.bst_type == CS35L41_EXT_BOOST) 616 cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, &cs35l41->hw_cfg); 617 618 + err: 619 + mutex_unlock(&cs35l41->fw_mutex); 620 621 + return ret; 622 } 623 624 static int cs35l41_smart_amp(struct cs35l41_hda *cs35l41) ··· 678 679 static void cs35l41_load_firmware(struct cs35l41_hda *cs35l41, bool load) 680 { 681 if (cs35l41->firmware_running && !load) { 682 dev_dbg(cs35l41->dev, "Unloading Firmware\n"); 683 cs35l41_shutdown_dsp(cs35l41); ··· 689 } else { 690 dev_dbg(cs35l41->dev, "Unable to Load firmware.\n"); 691 } 692 } 693 694 static int cs35l41_fw_load_ctl_get(struct snd_kcontrol *kcontrol, ··· 707 { 708 struct cs35l41_hda *cs35l41 = container_of(work, struct cs35l41_hda, fw_load_work); 709 710 + pm_runtime_get_sync(cs35l41->dev); 711 + 712 mutex_lock(&cs35l41->fw_mutex); 713 714 /* Recheck if playback is ongoing, mutex will block playback during firmware loading */ 715 if (cs35l41->playback_started) 716 + dev_err(cs35l41->dev, "Cannot Load/Unload firmware during Playback. Retrying...\n"); 717 else 718 cs35l41_load_firmware(cs35l41, cs35l41->request_fw_load); 719 720 cs35l41->fw_request_ongoing = false; 721 mutex_unlock(&cs35l41->fw_mutex); 722 + 723 + pm_runtime_mark_last_busy(cs35l41->dev); 724 + pm_runtime_put_autosuspend(cs35l41->dev); 725 } 726 727 static int cs35l41_fw_load_ctl_put(struct snd_kcontrol *kcontrol, ··· 840 841 pm_runtime_get_sync(dev); 842 843 + mutex_lock(&cs35l41->fw_mutex); 844 + 845 comps->dev = dev; 846 if (!cs35l41->acpi_subsystem_id) 847 cs35l41->acpi_subsystem_id = kasprintf(GFP_KERNEL, "%.8x", ··· 852 if (firmware_autostart) { 853 dev_dbg(cs35l41->dev, "Firmware Autostart.\n"); 854 cs35l41->request_fw_load = true; 855 if (cs35l41_smart_amp(cs35l41) < 0) 856 dev_warn(cs35l41->dev, "Cannot Run Firmware, reverting to dsp bypass...\n"); 857 } else { 858 dev_dbg(cs35l41->dev, "Firmware Autostart is disabled.\n"); 859 } ··· 863 ret = cs35l41_create_controls(cs35l41); 864 865 comps->playback_hook = cs35l41_hda_playback_hook; 866 + 867 + mutex_unlock(&cs35l41->fw_mutex); 868 869 pm_runtime_mark_last_busy(dev); 870 pm_runtime_put_autosuspend(dev); ··· 1433 1434 const struct dev_pm_ops cs35l41_hda_pm_ops = { 1435 RUNTIME_PM_OPS(cs35l41_runtime_suspend, cs35l41_runtime_resume, NULL) 1436 + SYSTEM_SLEEP_PM_OPS(cs35l41_system_suspend, cs35l41_system_resume) 1437 }; 1438 EXPORT_SYMBOL_NS_GPL(cs35l41_hda_pm_ops, SND_HDA_SCODEC_CS35L41); 1439
-2
sound/pci/hda/hda_component.h
··· 16 char name[HDA_MAX_NAME_SIZE]; 17 struct hda_codec *codec; 18 void (*playback_hook)(struct device *dev, int action); 19 - int (*suspend_hook)(struct device *dev); 20 - int (*resume_hook)(struct device *dev); 21 };
··· 16 char name[HDA_MAX_NAME_SIZE]; 17 struct hda_codec *codec; 18 void (*playback_hook)(struct device *dev, int action); 19 };
+46 -35
sound/pci/hda/hda_cs_dsp_ctl.c
··· 97 return out; 98 } 99 100 - static int hda_cs_dsp_add_kcontrol(struct hda_cs_dsp_coeff_ctl *ctl, const char *name) 101 { 102 struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; 103 struct snd_kcontrol_new kcontrol = {0}; ··· 107 if (cs_ctl->len > ADSP_MAX_STD_CTRL_SIZE) { 108 dev_err(cs_ctl->dsp->dev, "KControl %s: length %zu exceeds maximum %d\n", name, 109 cs_ctl->len, ADSP_MAX_STD_CTRL_SIZE); 110 - return -EINVAL; 111 } 112 113 kcontrol.name = name; ··· 120 /* Save ctl inside private_data, ctl is owned by cs_dsp, 121 * and will be freed when cs_dsp removes the control */ 122 kctl = snd_ctl_new1(&kcontrol, (void *)ctl); 123 - if (!kctl) { 124 - ret = -ENOMEM; 125 - return ret; 126 - } 127 128 ret = snd_ctl_add(ctl->card, kctl); 129 if (ret) { 130 dev_err(cs_ctl->dsp->dev, "Failed to add KControl %s = %d\n", kcontrol.name, ret); 131 - return ret; 132 } 133 134 dev_dbg(cs_ctl->dsp->dev, "Added KControl: %s\n", kcontrol.name); 135 ctl->kctl = kctl; 136 - 137 - return 0; 138 } 139 140 - int hda_cs_dsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl, struct hda_cs_dsp_ctl_info *info) 141 { 142 struct cs_dsp *cs_dsp = cs_ctl->dsp; 143 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; ··· 142 const char *region_name; 143 int ret; 144 145 - if (cs_ctl->flags & WMFW_CTL_FLAG_SYS) 146 - return 0; 147 - 148 region_name = cs_dsp_mem_region_name(cs_ctl->alg_region.type); 149 if (!region_name) { 150 - dev_err(cs_dsp->dev, "Unknown region type: %d\n", cs_ctl->alg_region.type); 151 - return -EINVAL; 152 } 153 154 ret = scnprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s %s %.12s %x", info->device_name, ··· 165 166 ctl = kzalloc(sizeof(*ctl), GFP_KERNEL); 167 if (!ctl) 168 - return -ENOMEM; 169 170 ctl->cs_ctl = cs_ctl; 171 ctl->card = info->card; 172 cs_ctl->priv = ctl; 173 174 - ret = hda_cs_dsp_add_kcontrol(ctl, name); 175 - if (ret) { 176 - dev_err(cs_dsp->dev, "Error (%d) adding control %s\n", ret, name); 177 - kfree(ctl); 178 - return ret; 179 - } 180 - 181 - return 0; 182 } 183 - EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_control_add, SND_HDA_CS_DSP_CONTROLS); 184 185 void hda_cs_dsp_control_remove(struct cs_dsp_coeff_ctl *cs_ctl) 186 { ··· 214 struct hda_cs_dsp_coeff_ctl *ctl; 215 int ret; 216 217 cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg); 218 - if (!cs_ctl) 219 - return -EINVAL; 220 - 221 - ctl = cs_ctl->priv; 222 - 223 ret = cs_dsp_coeff_write_ctrl(cs_ctl, 0, buf, len); 224 if (ret) 225 return ret; 226 227 if (cs_ctl->flags & WMFW_CTL_FLAG_SYS) 228 return 0; 229 230 snd_ctl_notify(ctl->card, SNDRV_CTL_EVENT_MASK_VALUE, &ctl->kctl->id); 231 ··· 235 int hda_cs_dsp_read_ctl(struct cs_dsp *dsp, const char *name, int type, 236 unsigned int alg, void *buf, size_t len) 237 { 238 - struct cs_dsp_coeff_ctl *cs_ctl; 239 240 - cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg); 241 - if (!cs_ctl) 242 - return -EINVAL; 243 244 - return cs_dsp_coeff_read_ctrl(cs_ctl, 0, buf, len); 245 } 246 EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_read_ctl, SND_HDA_CS_DSP_CONTROLS); 247
··· 97 return out; 98 } 99 100 + static void hda_cs_dsp_add_kcontrol(struct hda_cs_dsp_coeff_ctl *ctl, const char *name) 101 { 102 struct cs_dsp_coeff_ctl *cs_ctl = ctl->cs_ctl; 103 struct snd_kcontrol_new kcontrol = {0}; ··· 107 if (cs_ctl->len > ADSP_MAX_STD_CTRL_SIZE) { 108 dev_err(cs_ctl->dsp->dev, "KControl %s: length %zu exceeds maximum %d\n", name, 109 cs_ctl->len, ADSP_MAX_STD_CTRL_SIZE); 110 + return; 111 } 112 113 kcontrol.name = name; ··· 120 /* Save ctl inside private_data, ctl is owned by cs_dsp, 121 * and will be freed when cs_dsp removes the control */ 122 kctl = snd_ctl_new1(&kcontrol, (void *)ctl); 123 + if (!kctl) 124 + return; 125 126 ret = snd_ctl_add(ctl->card, kctl); 127 if (ret) { 128 dev_err(cs_ctl->dsp->dev, "Failed to add KControl %s = %d\n", kcontrol.name, ret); 129 + return; 130 } 131 132 dev_dbg(cs_ctl->dsp->dev, "Added KControl: %s\n", kcontrol.name); 133 ctl->kctl = kctl; 134 } 135 136 + static void hda_cs_dsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl, 137 + const struct hda_cs_dsp_ctl_info *info) 138 { 139 struct cs_dsp *cs_dsp = cs_ctl->dsp; 140 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; ··· 145 const char *region_name; 146 int ret; 147 148 region_name = cs_dsp_mem_region_name(cs_ctl->alg_region.type); 149 if (!region_name) { 150 + dev_warn(cs_dsp->dev, "Unknown region type: %d\n", cs_ctl->alg_region.type); 151 + return; 152 } 153 154 ret = scnprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s %s %.12s %x", info->device_name, ··· 171 172 ctl = kzalloc(sizeof(*ctl), GFP_KERNEL); 173 if (!ctl) 174 + return; 175 176 ctl->cs_ctl = cs_ctl; 177 ctl->card = info->card; 178 cs_ctl->priv = ctl; 179 180 + hda_cs_dsp_add_kcontrol(ctl, name); 181 } 182 + 183 + void hda_cs_dsp_add_controls(struct cs_dsp *dsp, const struct hda_cs_dsp_ctl_info *info) 184 + { 185 + struct cs_dsp_coeff_ctl *cs_ctl; 186 + 187 + /* 188 + * pwr_lock would cause mutex inversion with ALSA control lock compared 189 + * to the get/put functions. 190 + * It is safe to walk the list without holding a mutex because entries 191 + * are persistent and only cs_dsp_power_up() or cs_dsp_remove() can 192 + * change the list. 193 + */ 194 + lockdep_assert_not_held(&dsp->pwr_lock); 195 + 196 + list_for_each_entry(cs_ctl, &dsp->ctl_list, list) { 197 + if (cs_ctl->flags & WMFW_CTL_FLAG_SYS) 198 + continue; 199 + 200 + if (cs_ctl->priv) 201 + continue; 202 + 203 + hda_cs_dsp_control_add(cs_ctl, info); 204 + } 205 + } 206 + EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_add_controls, SND_HDA_CS_DSP_CONTROLS); 207 208 void hda_cs_dsp_control_remove(struct cs_dsp_coeff_ctl *cs_ctl) 209 { ··· 203 struct hda_cs_dsp_coeff_ctl *ctl; 204 int ret; 205 206 + mutex_lock(&dsp->pwr_lock); 207 cs_ctl = cs_dsp_get_ctl(dsp, name, type, alg); 208 ret = cs_dsp_coeff_write_ctrl(cs_ctl, 0, buf, len); 209 + mutex_unlock(&dsp->pwr_lock); 210 if (ret) 211 return ret; 212 213 if (cs_ctl->flags & WMFW_CTL_FLAG_SYS) 214 return 0; 215 + 216 + ctl = cs_ctl->priv; 217 218 snd_ctl_notify(ctl->card, SNDRV_CTL_EVENT_MASK_VALUE, &ctl->kctl->id); 219 ··· 225 int hda_cs_dsp_read_ctl(struct cs_dsp *dsp, const char *name, int type, 226 unsigned int alg, void *buf, size_t len) 227 { 228 + int ret; 229 230 + mutex_lock(&dsp->pwr_lock); 231 + ret = cs_dsp_coeff_read_ctrl(cs_dsp_get_ctl(dsp, name, type, alg), 0, buf, len); 232 + mutex_unlock(&dsp->pwr_lock); 233 234 + return ret; 235 + 236 } 237 EXPORT_SYMBOL_NS_GPL(hda_cs_dsp_read_ctl, SND_HDA_CS_DSP_CONTROLS); 238
+1 -1
sound/pci/hda/hda_cs_dsp_ctl.h
··· 29 30 extern const char * const hda_cs_dsp_fw_ids[HDA_CS_DSP_NUM_FW]; 31 32 - int hda_cs_dsp_control_add(struct cs_dsp_coeff_ctl *cs_ctl, struct hda_cs_dsp_ctl_info *info); 33 void hda_cs_dsp_control_remove(struct cs_dsp_coeff_ctl *cs_ctl); 34 int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type, 35 unsigned int alg, const void *buf, size_t len);
··· 29 30 extern const char * const hda_cs_dsp_fw_ids[HDA_CS_DSP_NUM_FW]; 31 32 + void hda_cs_dsp_add_controls(struct cs_dsp *dsp, const struct hda_cs_dsp_ctl_info *info); 33 void hda_cs_dsp_control_remove(struct cs_dsp_coeff_ctl *cs_ctl); 34 int hda_cs_dsp_write_ctl(struct cs_dsp *dsp, const char *name, int type, 35 unsigned int alg, const void *buf, size_t len);
+8 -22
sound/pci/hda/patch_realtek.c
··· 4022 static int alc269_suspend(struct hda_codec *codec) 4023 { 4024 struct alc_spec *spec = codec->spec; 4025 - int i; 4026 4027 if (spec->has_alc5505_dsp) 4028 alc5505_dsp_suspend(codec); 4029 - 4030 - for (i = 0; i < HDA_MAX_COMPONENTS; i++) 4031 - if (spec->comps[i].suspend_hook) 4032 - spec->comps[i].suspend_hook(spec->comps[i].dev); 4033 4034 return alc_suspend(codec); 4035 } ··· 4032 static int alc269_resume(struct hda_codec *codec) 4033 { 4034 struct alc_spec *spec = codec->spec; 4035 - int i; 4036 4037 if (spec->codec_variant == ALC269_TYPE_ALC269VB) 4038 alc269vb_toggle_power_output(codec, 0); ··· 4061 4062 if (spec->has_alc5505_dsp) 4063 alc5505_dsp_resume(codec); 4064 - 4065 - for (i = 0; i < HDA_MAX_COMPONENTS; i++) 4066 - if (spec->comps[i].resume_hook) 4067 - spec->comps[i].resume_hook(spec->comps[i].dev); 4068 4069 return 0; 4070 } ··· 6654 { 6655 struct hda_codec *cdc = dev_to_hda_codec(dev); 6656 struct alc_spec *spec = cdc->spec; 6657 - int ret, i; 6658 6659 ret = component_bind_all(dev, spec->comps); 6660 if (ret) 6661 return ret; 6662 - 6663 - if (snd_hdac_is_power_on(&cdc->core)) { 6664 - codec_dbg(cdc, "Resuming after bind.\n"); 6665 - for (i = 0; i < HDA_MAX_COMPONENTS; i++) 6666 - if (spec->comps[i].resume_hook) 6667 - spec->comps[i].resume_hook(spec->comps[i].dev); 6668 - } 6669 6670 return 0; 6671 } ··· 8432 [ALC285_FIXUP_ASUS_G533Z_PINS] = { 8433 .type = HDA_FIXUP_PINS, 8434 .v.pins = (const struct hda_pintbl[]) { 8435 - { 0x14, 0x90170120 }, 8436 { } 8437 }, 8438 - .chained = true, 8439 - .chain_id = ALC294_FIXUP_ASUS_G513_PINS, 8440 }, 8441 [ALC294_FIXUP_ASUS_COEF_1B] = { 8442 .type = HDA_FIXUP_VERBS, ··· 9183 SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC), 9184 SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC), 9185 SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB), 9186 - SND_PCI_QUIRK(0x1028, 0x087d, "Dell Precision 5530", ALC289_FIXUP_DUAL_SPK), 9187 SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE), 9188 SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE), 9189 SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB), ··· 9406 SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401), 9407 SND_PCI_QUIRK(0x1043, 0x1c52, "ASUS Zephyrus G15 2022", ALC289_FIXUP_ASUS_GA401), 9408 SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401), 9409 SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2), 9410 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), 9411 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), ··· 9428 SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE), 9429 SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE), 9430 SND_PCI_QUIRK(0x10ec, 0x1230, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK), 9431 SND_PCI_QUIRK(0x10ec, 0x1252, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK), 9432 SND_PCI_QUIRK(0x10ec, 0x1254, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK), 9433 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
··· 4022 static int alc269_suspend(struct hda_codec *codec) 4023 { 4024 struct alc_spec *spec = codec->spec; 4025 4026 if (spec->has_alc5505_dsp) 4027 alc5505_dsp_suspend(codec); 4028 4029 return alc_suspend(codec); 4030 } ··· 4037 static int alc269_resume(struct hda_codec *codec) 4038 { 4039 struct alc_spec *spec = codec->spec; 4040 4041 if (spec->codec_variant == ALC269_TYPE_ALC269VB) 4042 alc269vb_toggle_power_output(codec, 0); ··· 4067 4068 if (spec->has_alc5505_dsp) 4069 alc5505_dsp_resume(codec); 4070 4071 return 0; 4072 } ··· 6664 { 6665 struct hda_codec *cdc = dev_to_hda_codec(dev); 6666 struct alc_spec *spec = cdc->spec; 6667 + int ret; 6668 6669 ret = component_bind_all(dev, spec->comps); 6670 if (ret) 6671 return ret; 6672 6673 return 0; 6674 } ··· 8449 [ALC285_FIXUP_ASUS_G533Z_PINS] = { 8450 .type = HDA_FIXUP_PINS, 8451 .v.pins = (const struct hda_pintbl[]) { 8452 + { 0x14, 0x90170152 }, /* Speaker Surround Playback Switch */ 8453 + { 0x19, 0x03a19020 }, /* Mic Boost Volume */ 8454 + { 0x1a, 0x03a11c30 }, /* Mic Boost Volume */ 8455 + { 0x1e, 0x90170151 }, /* Rear jack, IN OUT EAPD Detect */ 8456 + { 0x21, 0x03211420 }, 8457 { } 8458 }, 8459 }, 8460 [ALC294_FIXUP_ASUS_COEF_1B] = { 8461 .type = HDA_FIXUP_VERBS, ··· 9198 SND_PCI_QUIRK(0x1028, 0x0871, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC), 9199 SND_PCI_QUIRK(0x1028, 0x0872, "Dell Precision 3630", ALC255_FIXUP_DELL_HEADSET_MIC), 9200 SND_PCI_QUIRK(0x1028, 0x0873, "Dell Precision 3930", ALC255_FIXUP_DUMMY_LINEOUT_VERB), 9201 SND_PCI_QUIRK(0x1028, 0x08ad, "Dell WYSE AIO", ALC225_FIXUP_DELL_WYSE_AIO_MIC_NO_PRESENCE), 9202 SND_PCI_QUIRK(0x1028, 0x08ae, "Dell WYSE NB", ALC225_FIXUP_DELL1_MIC_NO_PRESENCE), 9203 SND_PCI_QUIRK(0x1028, 0x0935, "Dell", ALC274_FIXUP_DELL_AIO_LINEOUT_VERB), ··· 9422 SND_PCI_QUIRK(0x1043, 0x1e8e, "ASUS Zephyrus G15", ALC289_FIXUP_ASUS_GA401), 9423 SND_PCI_QUIRK(0x1043, 0x1c52, "ASUS Zephyrus G15 2022", ALC289_FIXUP_ASUS_GA401), 9424 SND_PCI_QUIRK(0x1043, 0x1f11, "ASUS Zephyrus G14", ALC289_FIXUP_ASUS_GA401), 9425 + SND_PCI_QUIRK(0x1043, 0x1f92, "ASUS ROG Flow X16", ALC289_FIXUP_ASUS_GA401), 9426 SND_PCI_QUIRK(0x1043, 0x3030, "ASUS ZN270IE", ALC256_FIXUP_ASUS_AIO_GPIO2), 9427 SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC), 9428 SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC), ··· 9443 SND_PCI_QUIRK(0x10ec, 0x10f2, "Intel Reference board", ALC700_FIXUP_INTEL_REFERENCE), 9444 SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE), 9445 SND_PCI_QUIRK(0x10ec, 0x1230, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK), 9446 + SND_PCI_QUIRK(0x10ec, 0x124c, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK), 9447 SND_PCI_QUIRK(0x10ec, 0x1252, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK), 9448 SND_PCI_QUIRK(0x10ec, 0x1254, "Intel Reference board", ALC295_FIXUP_CHROME_BOOK), 9449 SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-SZ6", ALC269_FIXUP_HEADSET_MODE),
+2 -1
sound/usb/card.h
··· 129 in a stream */ 130 bool implicit_fb_sync; /* syncs with implicit feedback */ 131 bool lowlatency_playback; /* low-latency playback mode */ 132 - bool need_setup; /* (re-)need for configure? */ 133 134 /* for hw constraints */ 135 const struct audioformat *cur_audiofmt;
··· 129 in a stream */ 130 bool implicit_fb_sync; /* syncs with implicit feedback */ 131 bool lowlatency_playback; /* low-latency playback mode */ 132 + bool need_setup; /* (re-)need for hw_params? */ 133 + bool need_prepare; /* (re-)need for prepare? */ 134 135 /* for hw constraints */ 136 const struct audioformat *cur_audiofmt;
+25 -7
sound/usb/endpoint.c
··· 32 unsigned char iface; 33 bool need_setup; 34 int opened; 35 struct list_head list; 36 }; 37 ··· 824 825 ep->implicit_fb_sync = fp->implicit_fb; 826 ep->need_setup = true; 827 828 usb_audio_dbg(chip, " channels=%d, rate=%d, format=%s, period_bytes=%d, periods=%d, implicit_fb=%d\n", 829 ep->cur_channels, ep->cur_rate, ··· 901 int altset = set ? ep->altsetting : 0; 902 int err; 903 904 usb_audio_dbg(chip, "Setting usb interface %d:%d for EP 0x%x\n", 905 ep->iface, altset, ep->ep_num); 906 err = usb_set_interface(chip->dev, ep->iface, altset); ··· 915 916 if (chip->quirk_flags & QUIRK_FLAG_IFACE_DELAY) 917 msleep(50); 918 return 0; 919 } 920 ··· 953 /* Prepare for suspening EP, called from the main suspend handler */ 954 void snd_usb_endpoint_suspend(struct snd_usb_endpoint *ep) 955 { 956 - ep->need_setup = true; 957 if (ep->iface_ref) 958 ep->iface_ref->need_setup = true; 959 if (ep->clock_ref) ··· 1336 struct snd_usb_endpoint *ep) 1337 { 1338 const struct audioformat *fmt = ep->cur_audiofmt; 1339 - int err; 1340 1341 /* release old buffers, if any */ 1342 err = release_urbs(ep, false); 1343 if (err < 0) 1344 - return err; 1345 1346 ep->datainterval = fmt->datainterval; 1347 ep->maxpacksize = fmt->maxpacksize; ··· 1383 usb_audio_dbg(chip, "Set up %d URBS, ret=%d\n", ep->nurbs, err); 1384 1385 if (err < 0) 1386 - return err; 1387 1388 /* some unit conversions in runtime */ 1389 ep->maxframesize = ep->maxpacksize / ep->cur_frame_bytes; 1390 ep->curframesize = ep->curpacksize / ep->cur_frame_bytes; 1391 1392 - return update_clock_ref_rate(chip, ep); 1393 } 1394 1395 static int init_sample_rate(struct snd_usb_audio *chip, ··· 1444 mutex_lock(&chip->mutex); 1445 if (WARN_ON(!ep->iface_ref)) 1446 goto unlock; 1447 - if (!ep->need_setup) 1448 goto unlock; 1449 1450 /* If the interface has been already set up, just set EP parameters */ ··· 1498 ep->iface_ref->need_setup = false; 1499 1500 done: 1501 - ep->need_setup = false; 1502 err = 1; 1503 1504 unlock:
··· 32 unsigned char iface; 33 bool need_setup; 34 int opened; 35 + int altset; 36 struct list_head list; 37 }; 38 ··· 823 824 ep->implicit_fb_sync = fp->implicit_fb; 825 ep->need_setup = true; 826 + ep->need_prepare = true; 827 828 usb_audio_dbg(chip, " channels=%d, rate=%d, format=%s, period_bytes=%d, periods=%d, implicit_fb=%d\n", 829 ep->cur_channels, ep->cur_rate, ··· 899 int altset = set ? ep->altsetting : 0; 900 int err; 901 902 + if (ep->iface_ref->altset == altset) 903 + return 0; 904 + 905 usb_audio_dbg(chip, "Setting usb interface %d:%d for EP 0x%x\n", 906 ep->iface, altset, ep->ep_num); 907 err = usb_set_interface(chip->dev, ep->iface, altset); ··· 910 911 if (chip->quirk_flags & QUIRK_FLAG_IFACE_DELAY) 912 msleep(50); 913 + ep->iface_ref->altset = altset; 914 return 0; 915 } 916 ··· 947 /* Prepare for suspening EP, called from the main suspend handler */ 948 void snd_usb_endpoint_suspend(struct snd_usb_endpoint *ep) 949 { 950 + ep->need_prepare = true; 951 if (ep->iface_ref) 952 ep->iface_ref->need_setup = true; 953 if (ep->clock_ref) ··· 1330 struct snd_usb_endpoint *ep) 1331 { 1332 const struct audioformat *fmt = ep->cur_audiofmt; 1333 + int err = 0; 1334 + 1335 + mutex_lock(&chip->mutex); 1336 + if (!ep->need_setup) 1337 + goto unlock; 1338 1339 /* release old buffers, if any */ 1340 err = release_urbs(ep, false); 1341 if (err < 0) 1342 + goto unlock; 1343 1344 ep->datainterval = fmt->datainterval; 1345 ep->maxpacksize = fmt->maxpacksize; ··· 1373 usb_audio_dbg(chip, "Set up %d URBS, ret=%d\n", ep->nurbs, err); 1374 1375 if (err < 0) 1376 + goto unlock; 1377 1378 /* some unit conversions in runtime */ 1379 ep->maxframesize = ep->maxpacksize / ep->cur_frame_bytes; 1380 ep->curframesize = ep->curpacksize / ep->cur_frame_bytes; 1381 1382 + err = update_clock_ref_rate(chip, ep); 1383 + if (err >= 0) { 1384 + ep->need_setup = false; 1385 + err = 0; 1386 + } 1387 + 1388 + unlock: 1389 + mutex_unlock(&chip->mutex); 1390 + return err; 1391 } 1392 1393 static int init_sample_rate(struct snd_usb_audio *chip, ··· 1426 mutex_lock(&chip->mutex); 1427 if (WARN_ON(!ep->iface_ref)) 1428 goto unlock; 1429 + if (!ep->need_prepare) 1430 goto unlock; 1431 1432 /* If the interface has been already set up, just set EP parameters */ ··· 1480 ep->iface_ref->need_setup = false; 1481 1482 done: 1483 + ep->need_prepare = false; 1484 err = 1; 1485 1486 unlock: