Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'sound-4.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound

Pull sound fixes from Takashi Iwai:
"Usually we get a big collection of fixes for ASoC once during rc. And
this is it.

At this time, most of fixes are about Intel Skylake ASoC driver, which
is a new and still on-going development. Along with it, a slight
large LOC is seen in legacy HD-audio driver, but it's merely a code
move to the upper layer.

Other than that, the rest are small or trivial fixes to various
drivers, in addition to an ASoC dapm debugfs code fix"

* tag 'sound-4.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (24 commits)
ALSA: hda - Update BCLK also at hotplug for i915 HSW/BDW
ALSA: hda - Add dock support for ThinkPad X260
ASoC: wm5102: Free compressed IRQ in CODEC remove
ASoC: arizona: Free speaker thermal IRQs in CODEC remove
ASoC: Intel: Skylake: Fix ibs/obs calc for non-integral sampling rates
ASoC: Intel: sst: fix a loop timeout in sst_hsw_stream_reset()
ASoC: Intel: Skylake: Fix to turn OFF codec power when entering S3
ASoC: hdac_hdmi: Fix codec power state in S3 during playback
ASoC: hdac_hdmi: Fix to use dev_pm ops instead soc pm
ASoC: wm8962: Correct typo when setting DSPCLK rate
ASoC: nau8825: Fix jack detection across suspend
ASoC: Intel: Skylake: Fix DSP resource de-allocation
ASoC: Intel: Skylake: Fix for unloading module only when it is loaded
ASoC: Intel: Skylake: Fix kbuild dependency
ASoC: dapm: Make sure we have a card when displaying component widgets
ASoC: rt5640: Correct the digital interface data select
ASoC: Intel: Skylake: remove call to pci_dev_put
ASoC: Intel: Skylake: Call i915 exit last
ASoC: Intel: Skylake: Unmap the address last
ASoC: Intel: Skylake: Freeup properly on skl_dsp_free
...

+302 -227
+2 -3
include/sound/hda_i915.h
··· 9 9 #ifdef CONFIG_SND_HDA_I915 10 10 int snd_hdac_set_codec_wakeup(struct hdac_bus *bus, bool enable); 11 11 int snd_hdac_display_power(struct hdac_bus *bus, bool enable); 12 - int snd_hdac_get_display_clk(struct hdac_bus *bus); 12 + void snd_hdac_i915_set_bclk(struct hdac_bus *bus); 13 13 int snd_hdac_sync_audio_rate(struct hdac_bus *bus, hda_nid_t nid, int rate); 14 14 int snd_hdac_acomp_get_eld(struct hdac_bus *bus, hda_nid_t nid, 15 15 bool *audio_enabled, char *buffer, int max_bytes); ··· 25 25 { 26 26 return 0; 27 27 } 28 - static inline int snd_hdac_get_display_clk(struct hdac_bus *bus) 28 + static inline void snd_hdac_i915_set_bclk(struct hdac_bus *bus) 29 29 { 30 - return 0; 31 30 } 32 31 static inline int snd_hdac_sync_audio_rate(struct hdac_bus *bus, hda_nid_t nid, 33 32 int rate)
+2 -3
sound/hda/ext/hdac_ext_stream.c
··· 104 104 */ 105 105 void snd_hdac_stream_free_all(struct hdac_ext_bus *ebus) 106 106 { 107 - struct hdac_stream *s; 107 + struct hdac_stream *s, *_s; 108 108 struct hdac_ext_stream *stream; 109 109 struct hdac_bus *bus = ebus_to_hbus(ebus); 110 110 111 - while (!list_empty(&bus->stream_list)) { 112 - s = list_first_entry(&bus->stream_list, struct hdac_stream, list); 111 + list_for_each_entry_safe(s, _s, &bus->stream_list, list) { 113 112 stream = stream_to_hdac_ext_stream(s); 114 113 snd_hdac_ext_stream_decouple(ebus, stream, false); 115 114 list_del(&s->list);
+50 -10
sound/hda/hdac_i915.c
··· 20 20 #include <sound/core.h> 21 21 #include <sound/hdaudio.h> 22 22 #include <sound/hda_i915.h> 23 + #include <sound/hda_register.h> 23 24 24 25 static struct i915_audio_component *hdac_acomp; 25 26 ··· 98 97 } 99 98 EXPORT_SYMBOL_GPL(snd_hdac_display_power); 100 99 100 + #define CONTROLLER_IN_GPU(pci) (((pci)->device == 0x0a0c) || \ 101 + ((pci)->device == 0x0c0c) || \ 102 + ((pci)->device == 0x0d0c) || \ 103 + ((pci)->device == 0x160c)) 104 + 101 105 /** 102 - * snd_hdac_get_display_clk - Get CDCLK in kHz 106 + * snd_hdac_i915_set_bclk - Reprogram BCLK for HSW/BDW 103 107 * @bus: HDA core bus 104 108 * 105 - * This function is supposed to be used only by a HD-audio controller 106 - * driver that needs the interaction with i915 graphics. 109 + * Intel HSW/BDW display HDA controller is in GPU. Both its power and link BCLK 110 + * depends on GPU. Two Extended Mode registers EM4 (M value) and EM5 (N Value) 111 + * are used to convert CDClk (Core Display Clock) to 24MHz BCLK: 112 + * BCLK = CDCLK * M / N 113 + * The values will be lost when the display power well is disabled and need to 114 + * be restored to avoid abnormal playback speed. 107 115 * 108 - * This function queries CDCLK value in kHz from the graphics driver and 109 - * returns the value. A negative code is returned in error. 116 + * Call this function at initializing and changing power well, as well as 117 + * at ELD notifier for the hotplug. 110 118 */ 111 - int snd_hdac_get_display_clk(struct hdac_bus *bus) 119 + void snd_hdac_i915_set_bclk(struct hdac_bus *bus) 112 120 { 113 121 struct i915_audio_component *acomp = bus->audio_component; 122 + struct pci_dev *pci = to_pci_dev(bus->dev); 123 + int cdclk_freq; 124 + unsigned int bclk_m, bclk_n; 114 125 115 - if (!acomp || !acomp->ops) 116 - return -ENODEV; 126 + if (!acomp || !acomp->ops || !acomp->ops->get_cdclk_freq) 127 + return; /* only for i915 binding */ 128 + if (!CONTROLLER_IN_GPU(pci)) 129 + return; /* only HSW/BDW */ 117 130 118 - return acomp->ops->get_cdclk_freq(acomp->dev); 131 + cdclk_freq = acomp->ops->get_cdclk_freq(acomp->dev); 132 + switch (cdclk_freq) { 133 + case 337500: 134 + bclk_m = 16; 135 + bclk_n = 225; 136 + break; 137 + 138 + case 450000: 139 + default: /* default CDCLK 450MHz */ 140 + bclk_m = 4; 141 + bclk_n = 75; 142 + break; 143 + 144 + case 540000: 145 + bclk_m = 4; 146 + bclk_n = 90; 147 + break; 148 + 149 + case 675000: 150 + bclk_m = 8; 151 + bclk_n = 225; 152 + break; 153 + } 154 + 155 + snd_hdac_chip_writew(bus, HSW_EM4, bclk_m); 156 + snd_hdac_chip_writew(bus, HSW_EM5, bclk_n); 119 157 } 120 - EXPORT_SYMBOL_GPL(snd_hdac_get_display_clk); 158 + EXPORT_SYMBOL_GPL(snd_hdac_i915_set_bclk); 121 159 122 160 /* There is a fixed mapping between audio pin node and display port 123 161 * on current Intel platforms:
+4 -52
sound/pci/hda/hda_intel.c
··· 857 857 #define azx_del_card_list(chip) /* NOP */ 858 858 #endif /* CONFIG_PM */ 859 859 860 - /* Intel HSW/BDW display HDA controller is in GPU. Both its power and link BCLK 861 - * depends on GPU. Two Extended Mode registers EM4 (M value) and EM5 (N Value) 862 - * are used to convert CDClk (Core Display Clock) to 24MHz BCLK: 863 - * BCLK = CDCLK * M / N 864 - * The values will be lost when the display power well is disabled and need to 865 - * be restored to avoid abnormal playback speed. 866 - */ 867 - static void haswell_set_bclk(struct hda_intel *hda) 868 - { 869 - struct azx *chip = &hda->chip; 870 - int cdclk_freq; 871 - unsigned int bclk_m, bclk_n; 872 - 873 - if (!hda->need_i915_power) 874 - return; 875 - 876 - cdclk_freq = snd_hdac_get_display_clk(azx_bus(chip)); 877 - switch (cdclk_freq) { 878 - case 337500: 879 - bclk_m = 16; 880 - bclk_n = 225; 881 - break; 882 - 883 - case 450000: 884 - default: /* default CDCLK 450MHz */ 885 - bclk_m = 4; 886 - bclk_n = 75; 887 - break; 888 - 889 - case 540000: 890 - bclk_m = 4; 891 - bclk_n = 90; 892 - break; 893 - 894 - case 675000: 895 - bclk_m = 8; 896 - bclk_n = 225; 897 - break; 898 - } 899 - 900 - azx_writew(chip, HSW_EM4, bclk_m); 901 - azx_writew(chip, HSW_EM5, bclk_n); 902 - } 903 - 904 860 #if defined(CONFIG_PM_SLEEP) || defined(SUPPORT_VGA_SWITCHEROO) 905 861 /* 906 862 * power management ··· 914 958 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL 915 959 && hda->need_i915_power) { 916 960 snd_hdac_display_power(azx_bus(chip), true); 917 - haswell_set_bclk(hda); 961 + snd_hdac_i915_set_bclk(azx_bus(chip)); 918 962 } 919 963 if (chip->msi) 920 964 if (pci_enable_msi(pci) < 0) ··· 1014 1058 bus = azx_bus(chip); 1015 1059 if (hda->need_i915_power) { 1016 1060 snd_hdac_display_power(bus, true); 1017 - haswell_set_bclk(hda); 1061 + snd_hdac_i915_set_bclk(bus); 1018 1062 } else { 1019 1063 /* toggle codec wakeup bit for STATESTS read */ 1020 1064 snd_hdac_set_codec_wakeup(bus, true); ··· 1752 1796 /* initialize chip */ 1753 1797 azx_init_pci(chip); 1754 1798 1755 - if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) { 1756 - struct hda_intel *hda; 1757 - 1758 - hda = container_of(chip, struct hda_intel, chip); 1759 - haswell_set_bclk(hda); 1760 - } 1799 + if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) 1800 + snd_hdac_i915_set_bclk(bus); 1761 1801 1762 1802 hda_intel_init_chip(chip, (probe_only[dev] & 2) == 0); 1763 1803
+1
sound/pci/hda/patch_hdmi.c
··· 2232 2232 if (atomic_read(&(codec)->core.in_pm)) 2233 2233 return; 2234 2234 2235 + snd_hdac_i915_set_bclk(&codec->bus->core); 2235 2236 check_presence_and_report(codec, pin_nid); 2236 2237 } 2237 2238
+1
sound/pci/hda/patch_realtek.c
··· 5584 5584 SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK), 5585 5585 SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK), 5586 5586 SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK), 5587 + SND_PCI_QUIRK(0x17aa, 0x504a, "ThinkPad X260", ALC292_FIXUP_TPT440_DOCK), 5587 5588 SND_PCI_QUIRK(0x17aa, 0x504b, "Thinkpad", ALC293_FIXUP_LENOVO_SPK_NOISE), 5588 5589 SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), 5589 5590 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
+1
sound/soc/codecs/Kconfig
··· 629 629 630 630 config SND_SOC_RT5616 631 631 tristate "Realtek RT5616 CODEC" 632 + depends on I2C 632 633 633 634 config SND_SOC_RT5631 634 635 tristate "Realtek ALC5631/RT5631 CODEC"
+12
sound/soc/codecs/arizona.c
··· 249 249 } 250 250 EXPORT_SYMBOL_GPL(arizona_init_spk); 251 251 252 + int arizona_free_spk(struct snd_soc_codec *codec) 253 + { 254 + struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); 255 + struct arizona *arizona = priv->arizona; 256 + 257 + arizona_free_irq(arizona, ARIZONA_IRQ_SPK_OVERHEAT_WARN, arizona); 258 + arizona_free_irq(arizona, ARIZONA_IRQ_SPK_OVERHEAT, arizona); 259 + 260 + return 0; 261 + } 262 + EXPORT_SYMBOL_GPL(arizona_free_spk); 263 + 252 264 static const struct snd_soc_dapm_route arizona_mono_routes[] = { 253 265 { "OUT1R", NULL, "OUT1L" }, 254 266 { "OUT2R", NULL, "OUT2L" },
+2
sound/soc/codecs/arizona.h
··· 307 307 extern int arizona_init_gpio(struct snd_soc_codec *codec); 308 308 extern int arizona_init_mono(struct snd_soc_codec *codec); 309 309 310 + extern int arizona_free_spk(struct snd_soc_codec *codec); 311 + 310 312 extern int arizona_init_dai(struct arizona_priv *priv, int dai); 311 313 312 314 int arizona_set_output_mode(struct snd_soc_codec *codec, int output,
+13 -4
sound/soc/codecs/cs35l32.c
··· 274 274 if (of_property_read_u32(np, "cirrus,sdout-share", &val) >= 0) 275 275 pdata->sdout_share = val; 276 276 277 - of_property_read_u32(np, "cirrus,boost-manager", &val); 277 + if (of_property_read_u32(np, "cirrus,boost-manager", &val)) 278 + val = -1u; 279 + 278 280 switch (val) { 279 281 case CS35L32_BOOST_MGR_AUTO: 280 282 case CS35L32_BOOST_MGR_AUTO_AUDIO: ··· 284 282 case CS35L32_BOOST_MGR_FIXED: 285 283 pdata->boost_mng = val; 286 284 break; 285 + case -1u: 287 286 default: 288 287 dev_err(&i2c_client->dev, 289 288 "Wrong cirrus,boost-manager DT value %d\n", val); 290 289 pdata->boost_mng = CS35L32_BOOST_MGR_BYPASS; 291 290 } 292 291 293 - of_property_read_u32(np, "cirrus,sdout-datacfg", &val); 292 + if (of_property_read_u32(np, "cirrus,sdout-datacfg", &val)) 293 + val = -1u; 294 294 switch (val) { 295 295 case CS35L32_DATA_CFG_LR_VP: 296 296 case CS35L32_DATA_CFG_LR_STAT: ··· 300 296 case CS35L32_DATA_CFG_LR_VPSTAT: 301 297 pdata->sdout_datacfg = val; 302 298 break; 299 + case -1u: 303 300 default: 304 301 dev_err(&i2c_client->dev, 305 302 "Wrong cirrus,sdout-datacfg DT value %d\n", val); 306 303 pdata->sdout_datacfg = CS35L32_DATA_CFG_LR; 307 304 } 308 305 309 - of_property_read_u32(np, "cirrus,battery-threshold", &val); 306 + if (of_property_read_u32(np, "cirrus,battery-threshold", &val)) 307 + val = -1u; 310 308 switch (val) { 311 309 case CS35L32_BATT_THRESH_3_1V: 312 310 case CS35L32_BATT_THRESH_3_2V: ··· 316 310 case CS35L32_BATT_THRESH_3_4V: 317 311 pdata->batt_thresh = val; 318 312 break; 313 + case -1u: 319 314 default: 320 315 dev_err(&i2c_client->dev, 321 316 "Wrong cirrus,battery-threshold DT value %d\n", val); 322 317 pdata->batt_thresh = CS35L32_BATT_THRESH_3_3V; 323 318 } 324 319 325 - of_property_read_u32(np, "cirrus,battery-recovery", &val); 320 + if (of_property_read_u32(np, "cirrus,battery-recovery", &val)) 321 + val = -1u; 326 322 switch (val) { 327 323 case CS35L32_BATT_RECOV_3_1V: 328 324 case CS35L32_BATT_RECOV_3_2V: ··· 334 326 case CS35L32_BATT_RECOV_3_6V: 335 327 pdata->batt_recov = val; 336 328 break; 329 + case -1u: 337 330 default: 338 331 dev_err(&i2c_client->dev, 339 332 "Wrong cirrus,battery-recovery DT value %d\n", val);
+3
sound/soc/codecs/cs47l24.c
··· 1108 1108 priv->core.arizona->dapm = NULL; 1109 1109 1110 1110 arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, priv); 1111 + 1112 + arizona_free_spk(codec); 1113 + 1111 1114 return 0; 1112 1115 } 1113 1116
+42 -52
sound/soc/codecs/hdac_hdmi.c
··· 1420 1420 } 1421 1421 1422 1422 #ifdef CONFIG_PM 1423 - static int hdmi_codec_resume(struct snd_soc_codec *codec) 1423 + static int hdmi_codec_prepare(struct device *dev) 1424 1424 { 1425 - struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); 1425 + struct hdac_ext_device *edev = to_hda_ext_device(dev); 1426 + struct hdac_device *hdac = &edev->hdac; 1427 + 1428 + pm_runtime_get_sync(&edev->hdac.dev); 1429 + 1430 + /* 1431 + * Power down afg. 1432 + * codec_read is preferred over codec_write to set the power state. 1433 + * This way verb is send to set the power state and response 1434 + * is received. So setting power state is ensured without using loop 1435 + * to read the state. 1436 + */ 1437 + snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, 1438 + AC_PWRST_D3); 1439 + 1440 + return 0; 1441 + } 1442 + 1443 + static void hdmi_codec_complete(struct device *dev) 1444 + { 1445 + struct hdac_ext_device *edev = to_hda_ext_device(dev); 1426 1446 struct hdac_hdmi_priv *hdmi = edev->private_data; 1427 1447 struct hdac_hdmi_pin *pin; 1428 1448 struct hdac_device *hdac = &edev->hdac; 1429 - struct hdac_bus *bus = hdac->bus; 1430 - int err; 1431 - unsigned long timeout; 1449 + 1450 + /* Power up afg */ 1451 + snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, 1452 + AC_PWRST_D0); 1432 1453 1433 1454 hdac_hdmi_skl_enable_all_pins(&edev->hdac); 1434 1455 hdac_hdmi_skl_enable_dp12(&edev->hdac); 1435 - 1436 - /* Power up afg */ 1437 - if (!snd_hdac_check_power_state(hdac, hdac->afg, AC_PWRST_D0)) { 1438 - 1439 - snd_hdac_codec_write(hdac, hdac->afg, 0, 1440 - AC_VERB_SET_POWER_STATE, AC_PWRST_D0); 1441 - 1442 - /* Wait till power state is set to D0 */ 1443 - timeout = jiffies + msecs_to_jiffies(1000); 1444 - while (!snd_hdac_check_power_state(hdac, hdac->afg, AC_PWRST_D0) 1445 - && time_before(jiffies, timeout)) { 1446 - msleep(50); 1447 - } 1448 - } 1449 1456 1450 1457 /* 1451 1458 * As the ELD notify callback request is not entertained while the ··· 1462 1455 list_for_each_entry(pin, &hdmi->pin_list, head) 1463 1456 hdac_hdmi_present_sense(pin, 1); 1464 1457 1465 - /* 1466 - * Codec power is turned ON during controller resume. 1467 - * Turn it OFF here 1468 - */ 1469 - err = snd_hdac_display_power(bus, false); 1470 - if (err < 0) { 1471 - dev_err(bus->dev, 1472 - "Cannot turn OFF display power on i915, err: %d\n", 1473 - err); 1474 - return err; 1475 - } 1476 - 1477 - return 0; 1458 + pm_runtime_put_sync(&edev->hdac.dev); 1478 1459 } 1479 1460 #else 1480 - #define hdmi_codec_resume NULL 1461 + #define hdmi_codec_prepare NULL 1462 + #define hdmi_codec_complete NULL 1481 1463 #endif 1482 1464 1483 1465 static struct snd_soc_codec_driver hdmi_hda_codec = { 1484 1466 .probe = hdmi_codec_probe, 1485 1467 .remove = hdmi_codec_remove, 1486 - .resume = hdmi_codec_resume, 1487 1468 .idle_bias_off = true, 1488 1469 }; 1489 1470 ··· 1556 1561 struct hdac_ext_device *edev = to_hda_ext_device(dev); 1557 1562 struct hdac_device *hdac = &edev->hdac; 1558 1563 struct hdac_bus *bus = hdac->bus; 1559 - unsigned long timeout; 1560 1564 int err; 1561 1565 1562 1566 dev_dbg(dev, "Enter: %s\n", __func__); ··· 1564 1570 if (!bus) 1565 1571 return 0; 1566 1572 1567 - /* Power down afg */ 1568 - if (!snd_hdac_check_power_state(hdac, hdac->afg, AC_PWRST_D3)) { 1569 - snd_hdac_codec_write(hdac, hdac->afg, 0, 1570 - AC_VERB_SET_POWER_STATE, AC_PWRST_D3); 1571 - 1572 - /* Wait till power state is set to D3 */ 1573 - timeout = jiffies + msecs_to_jiffies(1000); 1574 - while (!snd_hdac_check_power_state(hdac, hdac->afg, AC_PWRST_D3) 1575 - && time_before(jiffies, timeout)) { 1576 - 1577 - msleep(50); 1578 - } 1579 - } 1580 - 1573 + /* 1574 + * Power down afg. 1575 + * codec_read is preferred over codec_write to set the power state. 1576 + * This way verb is send to set the power state and response 1577 + * is received. So setting power state is ensured without using loop 1578 + * to read the state. 1579 + */ 1580 + snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, 1581 + AC_PWRST_D3); 1581 1582 err = snd_hdac_display_power(bus, false); 1582 1583 if (err < 0) { 1583 1584 dev_err(bus->dev, "Cannot turn on display power on i915\n"); ··· 1605 1616 hdac_hdmi_skl_enable_dp12(&edev->hdac); 1606 1617 1607 1618 /* Power up afg */ 1608 - if (!snd_hdac_check_power_state(hdac, hdac->afg, AC_PWRST_D0)) 1609 - snd_hdac_codec_write(hdac, hdac->afg, 0, 1610 - AC_VERB_SET_POWER_STATE, AC_PWRST_D0); 1619 + snd_hdac_codec_read(hdac, hdac->afg, 0, AC_VERB_SET_POWER_STATE, 1620 + AC_PWRST_D0); 1611 1621 1612 1622 return 0; 1613 1623 } ··· 1617 1629 1618 1630 static const struct dev_pm_ops hdac_hdmi_pm = { 1619 1631 SET_RUNTIME_PM_OPS(hdac_hdmi_runtime_suspend, hdac_hdmi_runtime_resume, NULL) 1632 + .prepare = hdmi_codec_prepare, 1633 + .complete = hdmi_codec_complete, 1620 1634 }; 1621 1635 1622 1636 static const struct hda_device_id hdmi_list[] = {
+71 -55
sound/soc/codecs/nau8825.c
··· 343 343 SND_SOC_DAPM_SUPPLY("ADC Power", NAU8825_REG_ANALOG_ADC_2, 6, 0, NULL, 344 344 0), 345 345 346 - /* ADC for button press detection */ 347 - SND_SOC_DAPM_ADC("SAR", NULL, NAU8825_REG_SAR_CTRL, 348 - NAU8825_SAR_ADC_EN_SFT, 0), 346 + /* ADC for button press detection. A dapm supply widget is used to 347 + * prevent dapm_power_widgets keeping the codec at SND_SOC_BIAS_ON 348 + * during suspend. 349 + */ 350 + SND_SOC_DAPM_SUPPLY("SAR", NAU8825_REG_SAR_CTRL, 351 + NAU8825_SAR_ADC_EN_SFT, 0, NULL, 0), 349 352 350 353 SND_SOC_DAPM_PGA_S("ADACL", 2, NAU8825_REG_RDAC, 12, 0, NULL, 0), 351 354 SND_SOC_DAPM_PGA_S("ADACR", 2, NAU8825_REG_RDAC, 13, 0, NULL, 0), ··· 610 607 611 608 static void nau8825_restart_jack_detection(struct regmap *regmap) 612 609 { 610 + /* Chip needs one FSCLK cycle in order to generate interrupts, 611 + * as we cannot guarantee one will be provided by the system. Turning 612 + * master mode on then off enables us to generate that FSCLK cycle 613 + * with a minimum of contention on the clock bus. 614 + */ 615 + regmap_update_bits(regmap, NAU8825_REG_I2S_PCM_CTRL2, 616 + NAU8825_I2S_MS_MASK, NAU8825_I2S_MS_MASTER); 617 + regmap_update_bits(regmap, NAU8825_REG_I2S_PCM_CTRL2, 618 + NAU8825_I2S_MS_MASK, NAU8825_I2S_MS_SLAVE); 619 + 613 620 /* this will restart the entire jack detection process including MIC/GND 614 621 * switching and create interrupts. We have to go from 0 to 1 and back 615 622 * to 0 to restart. ··· 741 728 struct regmap *regmap = nau8825->regmap; 742 729 int active_irq, clear_irq = 0, event = 0, event_mask = 0; 743 730 744 - regmap_read(regmap, NAU8825_REG_IRQ_STATUS, &active_irq); 731 + if (regmap_read(regmap, NAU8825_REG_IRQ_STATUS, &active_irq)) { 732 + dev_err(nau8825->dev, "failed to read irq status\n"); 733 + return IRQ_NONE; 734 + } 745 735 746 736 if ((active_irq & NAU8825_JACK_EJECTION_IRQ_MASK) == 747 737 NAU8825_JACK_EJECTION_DETECTED) { ··· 1157 1141 return ret; 1158 1142 } 1159 1143 } 1160 - 1161 - ret = regcache_sync(nau8825->regmap); 1162 - if (ret) { 1163 - dev_err(codec->dev, 1164 - "Failed to sync cache: %d\n", ret); 1165 - return ret; 1166 - } 1167 1144 } 1168 - 1169 1145 break; 1170 1146 1171 1147 case SND_SOC_BIAS_OFF: 1172 1148 if (nau8825->mclk_freq) 1173 1149 clk_disable_unprepare(nau8825->mclk); 1174 - 1175 - regcache_mark_dirty(nau8825->regmap); 1176 1150 break; 1177 1151 } 1178 1152 return 0; 1179 1153 } 1154 + 1155 + #ifdef CONFIG_PM 1156 + static int nau8825_suspend(struct snd_soc_codec *codec) 1157 + { 1158 + struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); 1159 + 1160 + disable_irq(nau8825->irq); 1161 + regcache_cache_only(nau8825->regmap, true); 1162 + regcache_mark_dirty(nau8825->regmap); 1163 + 1164 + return 0; 1165 + } 1166 + 1167 + static int nau8825_resume(struct snd_soc_codec *codec) 1168 + { 1169 + struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); 1170 + 1171 + /* The chip may lose power and reset in S3. regcache_sync restores 1172 + * register values including configurations for sysclk, irq, and 1173 + * jack/button detection. 1174 + */ 1175 + regcache_cache_only(nau8825->regmap, false); 1176 + regcache_sync(nau8825->regmap); 1177 + 1178 + /* Check the jack plug status directly. If the headset is unplugged 1179 + * during S3 when the chip has no power, there will be no jack 1180 + * detection irq even after the nau8825_restart_jack_detection below, 1181 + * because the chip just thinks no headset has ever been plugged in. 1182 + */ 1183 + if (!nau8825_is_jack_inserted(nau8825->regmap)) { 1184 + nau8825_eject_jack(nau8825); 1185 + snd_soc_jack_report(nau8825->jack, 0, SND_JACK_HEADSET); 1186 + } 1187 + 1188 + enable_irq(nau8825->irq); 1189 + 1190 + /* Run jack detection to check the type (OMTP or CTIA) of the headset 1191 + * if there is one. This handles the case where a different type of 1192 + * headset is plugged in during S3. This triggers an IRQ iff a headset 1193 + * is already plugged in. 1194 + */ 1195 + nau8825_restart_jack_detection(nau8825->regmap); 1196 + 1197 + return 0; 1198 + } 1199 + #else 1200 + #define nau8825_suspend NULL 1201 + #define nau8825_resume NULL 1202 + #endif 1180 1203 1181 1204 static struct snd_soc_codec_driver nau8825_codec_driver = { 1182 1205 .probe = nau8825_codec_probe, ··· 1223 1168 .set_pll = nau8825_set_pll, 1224 1169 .set_bias_level = nau8825_set_bias_level, 1225 1170 .suspend_bias_off = true, 1171 + .suspend = nau8825_suspend, 1172 + .resume = nau8825_resume, 1226 1173 1227 1174 .controls = nau8825_controls, 1228 1175 .num_controls = ARRAY_SIZE(nau8825_controls), ··· 1334 1277 regmap_update_bits(regmap, NAU8825_REG_ENA_CTRL, 1335 1278 NAU8825_ENABLE_DACR, NAU8825_ENABLE_DACR); 1336 1279 1337 - /* Chip needs one FSCLK cycle in order to generate interrupts, 1338 - * as we cannot guarantee one will be provided by the system. Turning 1339 - * master mode on then off enables us to generate that FSCLK cycle 1340 - * with a minimum of contention on the clock bus. 1341 - */ 1342 - regmap_update_bits(regmap, NAU8825_REG_I2S_PCM_CTRL2, 1343 - NAU8825_I2S_MS_MASK, NAU8825_I2S_MS_MASTER); 1344 - regmap_update_bits(regmap, NAU8825_REG_I2S_PCM_CTRL2, 1345 - NAU8825_I2S_MS_MASK, NAU8825_I2S_MS_SLAVE); 1346 - 1347 1280 ret = devm_request_threaded_irq(nau8825->dev, nau8825->irq, NULL, 1348 1281 nau8825_interrupt, IRQF_TRIGGER_LOW | IRQF_ONESHOT, 1349 1282 "nau8825", nau8825); ··· 1401 1354 return 0; 1402 1355 } 1403 1356 1404 - #ifdef CONFIG_PM_SLEEP 1405 - static int nau8825_suspend(struct device *dev) 1406 - { 1407 - struct i2c_client *client = to_i2c_client(dev); 1408 - struct nau8825 *nau8825 = dev_get_drvdata(dev); 1409 - 1410 - disable_irq(client->irq); 1411 - regcache_cache_only(nau8825->regmap, true); 1412 - regcache_mark_dirty(nau8825->regmap); 1413 - 1414 - return 0; 1415 - } 1416 - 1417 - static int nau8825_resume(struct device *dev) 1418 - { 1419 - struct i2c_client *client = to_i2c_client(dev); 1420 - struct nau8825 *nau8825 = dev_get_drvdata(dev); 1421 - 1422 - regcache_cache_only(nau8825->regmap, false); 1423 - regcache_sync(nau8825->regmap); 1424 - enable_irq(client->irq); 1425 - 1426 - return 0; 1427 - } 1428 - #endif 1429 - 1430 - static const struct dev_pm_ops nau8825_pm = { 1431 - SET_SYSTEM_SLEEP_PM_OPS(nau8825_suspend, nau8825_resume) 1432 - }; 1433 - 1434 1357 static const struct i2c_device_id nau8825_i2c_ids[] = { 1435 1358 { "nau8825", 0 }, 1436 1359 { } ··· 1427 1410 .name = "nau8825", 1428 1411 .of_match_table = of_match_ptr(nau8825_of_ids), 1429 1412 .acpi_match_table = ACPI_PTR(nau8825_acpi_match), 1430 - .pm = &nau8825_pm, 1431 1413 }, 1432 1414 .probe = nau8825_i2c_probe, 1433 1415 .remove = nau8825_i2c_remove,
+1 -1
sound/soc/codecs/rt5640.c
··· 359 359 360 360 /* Interface data select */ 361 361 static const char * const rt5640_data_select[] = { 362 - "Normal", "left copy to right", "right copy to left", "Swap"}; 362 + "Normal", "Swap", "left copy to right", "right copy to left"}; 363 363 364 364 static SOC_ENUM_SINGLE_DECL(rt5640_if1_dac_enum, RT5640_DIG_INF_DATA, 365 365 RT5640_IF1_DAC_SEL_SFT, rt5640_data_select);
+18 -18
sound/soc/codecs/rt5640.h
··· 443 443 #define RT5640_IF1_DAC_SEL_MASK (0x3 << 14) 444 444 #define RT5640_IF1_DAC_SEL_SFT 14 445 445 #define RT5640_IF1_DAC_SEL_NOR (0x0 << 14) 446 - #define RT5640_IF1_DAC_SEL_L2R (0x1 << 14) 447 - #define RT5640_IF1_DAC_SEL_R2L (0x2 << 14) 448 - #define RT5640_IF1_DAC_SEL_SWAP (0x3 << 14) 446 + #define RT5640_IF1_DAC_SEL_SWAP (0x1 << 14) 447 + #define RT5640_IF1_DAC_SEL_L2R (0x2 << 14) 448 + #define RT5640_IF1_DAC_SEL_R2L (0x3 << 14) 449 449 #define RT5640_IF1_ADC_SEL_MASK (0x3 << 12) 450 450 #define RT5640_IF1_ADC_SEL_SFT 12 451 451 #define RT5640_IF1_ADC_SEL_NOR (0x0 << 12) 452 - #define RT5640_IF1_ADC_SEL_L2R (0x1 << 12) 453 - #define RT5640_IF1_ADC_SEL_R2L (0x2 << 12) 454 - #define RT5640_IF1_ADC_SEL_SWAP (0x3 << 12) 452 + #define RT5640_IF1_ADC_SEL_SWAP (0x1 << 12) 453 + #define RT5640_IF1_ADC_SEL_L2R (0x2 << 12) 454 + #define RT5640_IF1_ADC_SEL_R2L (0x3 << 12) 455 455 #define RT5640_IF2_DAC_SEL_MASK (0x3 << 10) 456 456 #define RT5640_IF2_DAC_SEL_SFT 10 457 457 #define RT5640_IF2_DAC_SEL_NOR (0x0 << 10) 458 - #define RT5640_IF2_DAC_SEL_L2R (0x1 << 10) 459 - #define RT5640_IF2_DAC_SEL_R2L (0x2 << 10) 460 - #define RT5640_IF2_DAC_SEL_SWAP (0x3 << 10) 458 + #define RT5640_IF2_DAC_SEL_SWAP (0x1 << 10) 459 + #define RT5640_IF2_DAC_SEL_L2R (0x2 << 10) 460 + #define RT5640_IF2_DAC_SEL_R2L (0x3 << 10) 461 461 #define RT5640_IF2_ADC_SEL_MASK (0x3 << 8) 462 462 #define RT5640_IF2_ADC_SEL_SFT 8 463 463 #define RT5640_IF2_ADC_SEL_NOR (0x0 << 8) 464 - #define RT5640_IF2_ADC_SEL_L2R (0x1 << 8) 465 - #define RT5640_IF2_ADC_SEL_R2L (0x2 << 8) 466 - #define RT5640_IF2_ADC_SEL_SWAP (0x3 << 8) 464 + #define RT5640_IF2_ADC_SEL_SWAP (0x1 << 8) 465 + #define RT5640_IF2_ADC_SEL_L2R (0x2 << 8) 466 + #define RT5640_IF2_ADC_SEL_R2L (0x3 << 8) 467 467 #define RT5640_IF3_DAC_SEL_MASK (0x3 << 6) 468 468 #define RT5640_IF3_DAC_SEL_SFT 6 469 469 #define RT5640_IF3_DAC_SEL_NOR (0x0 << 6) 470 - #define RT5640_IF3_DAC_SEL_L2R (0x1 << 6) 471 - #define RT5640_IF3_DAC_SEL_R2L (0x2 << 6) 472 - #define RT5640_IF3_DAC_SEL_SWAP (0x3 << 6) 470 + #define RT5640_IF3_DAC_SEL_SWAP (0x1 << 6) 471 + #define RT5640_IF3_DAC_SEL_L2R (0x2 << 6) 472 + #define RT5640_IF3_DAC_SEL_R2L (0x3 << 6) 473 473 #define RT5640_IF3_ADC_SEL_MASK (0x3 << 4) 474 474 #define RT5640_IF3_ADC_SEL_SFT 4 475 475 #define RT5640_IF3_ADC_SEL_NOR (0x0 << 4) 476 - #define RT5640_IF3_ADC_SEL_L2R (0x1 << 4) 477 - #define RT5640_IF3_ADC_SEL_R2L (0x2 << 4) 478 - #define RT5640_IF3_ADC_SEL_SWAP (0x3 << 4) 476 + #define RT5640_IF3_ADC_SEL_SWAP (0x1 << 4) 477 + #define RT5640_IF3_ADC_SEL_L2R (0x2 << 4) 478 + #define RT5640_IF3_ADC_SEL_R2L (0x3 << 4) 479 479 480 480 /* REC Left Mixer Control 1 (0x3b) */ 481 481 #define RT5640_G_HP_L_RM_L_MASK (0x7 << 13)
+5
sound/soc/codecs/wm5102.c
··· 1955 1955 static int wm5102_codec_remove(struct snd_soc_codec *codec) 1956 1956 { 1957 1957 struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); 1958 + struct arizona *arizona = priv->core.arizona; 1958 1959 1959 1960 wm_adsp2_codec_remove(&priv->core.adsp[0], codec); 1960 1961 1961 1962 priv->core.arizona->dapm = NULL; 1963 + 1964 + arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, priv); 1965 + 1966 + arizona_free_spk(codec); 1962 1967 1963 1968 return 0; 1964 1969 }
+2
sound/soc/codecs/wm5110.c
··· 2298 2298 2299 2299 arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, priv); 2300 2300 2301 + arizona_free_spk(codec); 2302 + 2301 2303 return 0; 2302 2304 } 2303 2305
+1 -1
sound/soc/codecs/wm8962.c
··· 2471 2471 break; 2472 2472 default: 2473 2473 dev_warn(codec->dev, "Unknown DSPCLK divisor read back\n"); 2474 - dspclk = wm8962->sysclk; 2474 + dspclk = wm8962->sysclk_rate; 2475 2475 } 2476 2476 2477 2477 dev_dbg(codec->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk);
+2
sound/soc/codecs/wm8997.c
··· 1072 1072 1073 1073 priv->core.arizona->dapm = NULL; 1074 1074 1075 + arizona_free_spk(codec); 1076 + 1075 1077 return 0; 1076 1078 } 1077 1079
+2
sound/soc/codecs/wm8998.c
··· 1324 1324 1325 1325 priv->core.arizona->dapm = NULL; 1326 1326 1327 + arizona_free_spk(codec); 1328 + 1327 1329 return 0; 1328 1330 } 1329 1331
-1
sound/soc/intel/Kconfig
··· 163 163 tristate 164 164 select SND_HDA_EXT_CORE 165 165 select SND_SOC_TOPOLOGY 166 - select SND_HDA_I915 167 166 select SND_SOC_INTEL_SST 168 167 169 168 config SND_SOC_INTEL_SKL_RT286_MACH
+1 -1
sound/soc/intel/haswell/sst-haswell-ipc.c
··· 1345 1345 return 0; 1346 1346 1347 1347 /* wait for pause to complete before we reset the stream */ 1348 - while (stream->running && tries--) 1348 + while (stream->running && --tries) 1349 1349 msleep(1); 1350 1350 if (!tries) { 1351 1351 dev_err(hsw->dev, "error: reset stream %d still running\n",
+5
sound/soc/intel/skylake/skl-sst-dsp.c
··· 336 336 skl_ipc_int_disable(dsp); 337 337 338 338 free_irq(dsp->irq, dsp); 339 + dsp->cl_dev.ops.cl_cleanup_controller(dsp); 340 + skl_cldma_int_disable(dsp); 341 + skl_ipc_op_int_disable(dsp); 342 + skl_ipc_int_disable(dsp); 343 + 339 344 skl_dsp_disable_core(dsp); 340 345 } 341 346 EXPORT_SYMBOL_GPL(skl_dsp_free);
+27 -13
sound/soc/intel/skylake/skl-topology.c
··· 239 239 { 240 240 int multiplier = 1; 241 241 struct skl_module_fmt *in_fmt, *out_fmt; 242 + int in_rate, out_rate; 242 243 243 244 244 245 /* Since fixups is applied to pin 0 only, ibs, obs needs ··· 250 249 251 250 if (mcfg->m_type == SKL_MODULE_TYPE_SRCINT) 252 251 multiplier = 5; 253 - mcfg->ibs = (in_fmt->s_freq / 1000) * 254 - (mcfg->in_fmt->channels) * 255 - (mcfg->in_fmt->bit_depth >> 3) * 256 - multiplier; 257 252 258 - mcfg->obs = (mcfg->out_fmt->s_freq / 1000) * 259 - (mcfg->out_fmt->channels) * 260 - (mcfg->out_fmt->bit_depth >> 3) * 261 - multiplier; 253 + if (in_fmt->s_freq % 1000) 254 + in_rate = (in_fmt->s_freq / 1000) + 1; 255 + else 256 + in_rate = (in_fmt->s_freq / 1000); 257 + 258 + mcfg->ibs = in_rate * (mcfg->in_fmt->channels) * 259 + (mcfg->in_fmt->bit_depth >> 3) * 260 + multiplier; 261 + 262 + if (mcfg->out_fmt->s_freq % 1000) 263 + out_rate = (mcfg->out_fmt->s_freq / 1000) + 1; 264 + else 265 + out_rate = (mcfg->out_fmt->s_freq / 1000); 266 + 267 + mcfg->obs = out_rate * (mcfg->out_fmt->channels) * 268 + (mcfg->out_fmt->bit_depth >> 3) * 269 + multiplier; 262 270 } 263 271 264 272 static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, ··· 495 485 if (!skl_is_pipe_mcps_avail(skl, mconfig)) 496 486 return -ENOMEM; 497 487 488 + skl_tplg_alloc_pipe_mcps(skl, mconfig); 489 + 498 490 if (mconfig->is_loadable && ctx->dsp->fw_ops.load_mod) { 499 491 ret = ctx->dsp->fw_ops.load_mod(ctx->dsp, 500 492 mconfig->id.module_id, mconfig->guid); 501 493 if (ret < 0) 502 494 return ret; 495 + 496 + mconfig->m_state = SKL_MODULE_LOADED; 503 497 } 504 498 505 499 /* update blob if blob is null for be with default value */ ··· 523 509 ret = skl_tplg_set_module_params(w, ctx); 524 510 if (ret < 0) 525 511 return ret; 526 - skl_tplg_alloc_pipe_mcps(skl, mconfig); 527 512 } 528 513 529 514 return 0; ··· 537 524 list_for_each_entry(w_module, &pipe->w_list, node) { 538 525 mconfig = w_module->w->priv; 539 526 540 - if (mconfig->is_loadable && ctx->dsp->fw_ops.unload_mod) 527 + if (mconfig->is_loadable && ctx->dsp->fw_ops.unload_mod && 528 + mconfig->m_state > SKL_MODULE_UNINIT) 541 529 return ctx->dsp->fw_ops.unload_mod(ctx->dsp, 542 530 mconfig->id.module_id); 543 531 } ··· 571 557 572 558 if (!skl_is_pipe_mem_avail(skl, mconfig)) 573 559 return -ENOMEM; 560 + 561 + skl_tplg_alloc_pipe_mem(skl, mconfig); 562 + skl_tplg_alloc_pipe_mcps(skl, mconfig); 574 563 575 564 /* 576 565 * Create a list of modules for pipe. ··· 617 600 618 601 src_module = dst_module; 619 602 } 620 - 621 - skl_tplg_alloc_pipe_mem(skl, mconfig); 622 - skl_tplg_alloc_pipe_mcps(skl, mconfig); 623 603 624 604 return 0; 625 605 }
+4 -4
sound/soc/intel/skylake/skl-topology.h
··· 274 274 275 275 enum skl_module_state { 276 276 SKL_MODULE_UNINIT = 0, 277 - SKL_MODULE_INIT_DONE = 1, 278 - SKL_MODULE_LOADED = 2, 279 - SKL_MODULE_UNLOADED = 3, 280 - SKL_MODULE_BIND_DONE = 4 277 + SKL_MODULE_LOADED = 1, 278 + SKL_MODULE_INIT_DONE = 2, 279 + SKL_MODULE_BIND_DONE = 3, 280 + SKL_MODULE_UNLOADED = 4, 281 281 }; 282 282 283 283 struct skl_module_cfg {
+23 -9
sound/soc/intel/skylake/skl.c
··· 222 222 struct hdac_ext_bus *ebus = pci_get_drvdata(pci); 223 223 struct skl *skl = ebus_to_skl(ebus); 224 224 struct hdac_bus *bus = ebus_to_hbus(ebus); 225 + int ret = 0; 225 226 226 227 /* 227 228 * Do not suspend if streams which are marked ignore suspend are ··· 233 232 enable_irq_wake(bus->irq); 234 233 pci_save_state(pci); 235 234 pci_disable_device(pci); 236 - return 0; 237 235 } else { 238 - return _skl_suspend(ebus); 236 + ret = _skl_suspend(ebus); 237 + if (ret < 0) 238 + return ret; 239 239 } 240 + 241 + if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { 242 + ret = snd_hdac_display_power(bus, false); 243 + if (ret < 0) 244 + dev_err(bus->dev, 245 + "Cannot turn OFF display power on i915\n"); 246 + } 247 + 248 + return ret; 240 249 } 241 250 242 251 static int skl_resume(struct device *dev) ··· 327 316 328 317 if (bus->irq >= 0) 329 318 free_irq(bus->irq, (void *)bus); 330 - if (bus->remap_addr) 331 - iounmap(bus->remap_addr); 332 - 333 319 snd_hdac_bus_free_stream_pages(bus); 334 320 snd_hdac_stream_free_all(ebus); 335 321 snd_hdac_link_free_all(ebus); 322 + 323 + if (bus->remap_addr) 324 + iounmap(bus->remap_addr); 325 + 336 326 pci_release_regions(skl->pci); 337 327 pci_disable_device(skl->pci); 338 328 339 329 snd_hdac_ext_bus_exit(ebus); 340 330 331 + if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) 332 + snd_hdac_i915_exit(&ebus->bus); 341 333 return 0; 342 334 } 343 335 ··· 733 719 if (skl->tplg) 734 720 release_firmware(skl->tplg); 735 721 736 - if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) 737 - snd_hdac_i915_exit(&ebus->bus); 738 - 739 722 if (pci_dev_run_wake(pci)) 740 723 pm_runtime_get_noresume(&pci->dev); 741 - pci_dev_put(pci); 724 + 725 + /* codec removal, invoke bus_device_remove */ 726 + snd_hdac_ext_bus_device_remove(ebus); 727 + 742 728 skl_platform_unregister(&pci->dev); 743 729 skl_free_dsp(skl); 744 730 skl_machine_device_unregister(skl);
+7
sound/soc/soc-dapm.c
··· 2188 2188 int count = 0; 2189 2189 char *state = "not set"; 2190 2190 2191 + /* card won't be set for the dummy component, as a spot fix 2192 + * we're checking for that case specifically here but in future 2193 + * we will ensure that the dummy component looks like others. 2194 + */ 2195 + if (!cmpnt->card) 2196 + return 0; 2197 + 2191 2198 list_for_each_entry(w, &cmpnt->card->widgets, list) { 2192 2199 if (w->dapm != dapm) 2193 2200 continue;