aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r--sound/soc/codecs/hdac_hdmi.c116
-rw-r--r--sound/soc/codecs/hdmi-codec.c4
-rw-r--r--sound/soc/codecs/pcm512x.c11
-rw-r--r--sound/soc/codecs/rt274.c5
-rw-r--r--sound/soc/codecs/rt5514-spi.c2
-rw-r--r--sound/soc/codecs/rt5682.c3
-rw-r--r--sound/soc/codecs/rt5682.h24
-rw-r--r--sound/soc/codecs/tlv320aic32x4.c4
8 files changed, 44 insertions, 125 deletions
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c
index 3ab2949c1dfa..b19d7a3e7a2c 100644
--- a/sound/soc/codecs/hdac_hdmi.c
+++ b/sound/soc/codecs/hdac_hdmi.c
@@ -1890,51 +1890,31 @@ static void hdmi_codec_remove(struct snd_soc_component *component)
1890 pm_runtime_disable(&hdev->dev); 1890 pm_runtime_disable(&hdev->dev);
1891} 1891}
1892 1892
1893#ifdef CONFIG_PM 1893#ifdef CONFIG_PM_SLEEP
1894static int hdmi_codec_prepare(struct device *dev) 1894static int hdmi_codec_resume(struct device *dev)
1895{
1896 struct hdac_device *hdev = dev_to_hdac_dev(dev);
1897
1898 pm_runtime_get_sync(&hdev->dev);
1899
1900 /*
1901 * Power down afg.
1902 * codec_read is preferred over codec_write to set the power state.
1903 * This way verb is send to set the power state and response
1904 * is received. So setting power state is ensured without using loop
1905 * to read the state.
1906 */
1907 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE,
1908 AC_PWRST_D3);
1909
1910 return 0;
1911}
1912
1913static void hdmi_codec_complete(struct device *dev)
1914{ 1895{
1915 struct hdac_device *hdev = dev_to_hdac_dev(dev); 1896 struct hdac_device *hdev = dev_to_hdac_dev(dev);
1916 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev); 1897 struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(hdev);
1898 int ret;
1917 1899
1918 /* Power up afg */ 1900 ret = pm_runtime_force_resume(dev);
1919 snd_hdac_codec_read(hdev, hdev->afg, 0, AC_VERB_SET_POWER_STATE, 1901 if (ret < 0)
1920 AC_PWRST_D0); 1902 return ret;
1921
1922 hdac_hdmi_skl_enable_all_pins(hdev);
1923 hdac_hdmi_skl_enable_dp12(hdev);
1924
1925 /* 1903 /*
1926 * As the ELD notify callback request is not entertained while the 1904 * As the ELD notify callback request is not entertained while the
1927 * device is in suspend state. Need to manually check detection of 1905 * device is in suspend state. Need to manually check detection of
1928 * all pins here. pin capablity change is not support, so use the 1906 * all pins here. pin capablity change is not support, so use the
1929 * already set pin caps. 1907 * already set pin caps.
1908 *
1909 * NOTE: this is safe to call even if the codec doesn't actually resume.
1910 * The pin check involves only with DRM audio component hooks, so it
1911 * works even if the HD-audio side is still dreaming peacefully.
1930 */ 1912 */
1931 hdac_hdmi_present_sense_all_pins(hdev, hdmi, false); 1913 hdac_hdmi_present_sense_all_pins(hdev, hdmi, false);
1932 1914 return 0;
1933 pm_runtime_put_sync(&hdev->dev);
1934} 1915}
1935#else 1916#else
1936#define hdmi_codec_prepare NULL 1917#define hdmi_codec_resume NULL
1937#define hdmi_codec_complete NULL
1938#endif 1918#endif
1939 1919
1940static const struct snd_soc_component_driver hdmi_hda_codec = { 1920static const struct snd_soc_component_driver hdmi_hda_codec = {
@@ -2135,75 +2115,6 @@ static int hdac_hdmi_dev_remove(struct hdac_device *hdev)
2135} 2115}
2136 2116
2137#ifdef CONFIG_PM 2117#ifdef CONFIG_PM
2138/*
2139 * Power management sequences
2140 * ==========================
2141 *
2142 * The following explains the PM handling of HDAC HDMI with its parent
2143 * device SKL and display power usage
2144 *
2145 * Probe
2146 * -----
2147 * In SKL probe,
2148 * 1. skl_probe_work() powers up the display (refcount++ -> 1)
2149 * 2. enumerates the codecs on the link
2150 * 3. powers down the display (refcount-- -> 0)
2151 *
2152 * In HDAC HDMI probe,
2153 * 1. hdac_hdmi_dev_probe() powers up the display (refcount++ -> 1)
2154 * 2. probe the codec
2155 * 3. put the HDAC HDMI device to runtime suspend
2156 * 4. hdac_hdmi_runtime_suspend() powers down the display (refcount-- -> 0)
2157 *
2158 * Once children are runtime suspended, SKL device also goes to runtime
2159 * suspend
2160 *
2161 * HDMI Playback
2162 * -------------
2163 * Open HDMI device,
2164 * 1. skl_runtime_resume() invoked
2165 * 2. hdac_hdmi_runtime_resume() powers up the display (refcount++ -> 1)
2166 *
2167 * Close HDMI device,
2168 * 1. hdac_hdmi_runtime_suspend() powers down the display (refcount-- -> 0)
2169 * 2. skl_runtime_suspend() invoked
2170 *
2171 * S0/S3 Cycle with playback in progress
2172 * -------------------------------------
2173 * When the device is opened for playback, the device is runtime active
2174 * already and the display refcount is 1 as explained above.
2175 *
2176 * Entering to S3,
2177 * 1. hdmi_codec_prepare() invoke the runtime resume of codec which just
2178 * increments the PM runtime usage count of the codec since the device
2179 * is in use already
2180 * 2. skl_suspend() powers down the display (refcount-- -> 0)
2181 *
2182 * Wakeup from S3,
2183 * 1. skl_resume() powers up the display (refcount++ -> 1)
2184 * 2. hdmi_codec_complete() invokes the runtime suspend of codec which just
2185 * decrements the PM runtime usage count of the codec since the device
2186 * is in use already
2187 *
2188 * Once playback is stopped, the display refcount is set to 0 as explained
2189 * above in the HDMI playback sequence. The PM handlings are designed in
2190 * such way that to balance the refcount of display power when the codec
2191 * device put to S3 while playback is going on.
2192 *
2193 * S0/S3 Cycle without playback in progress
2194 * ----------------------------------------
2195 * Entering to S3,
2196 * 1. hdmi_codec_prepare() invoke the runtime resume of codec
2197 * 2. skl_runtime_resume() invoked
2198 * 3. hdac_hdmi_runtime_resume() powers up the display (refcount++ -> 1)
2199 * 4. skl_suspend() powers down the display (refcount-- -> 0)
2200 *
2201 * Wakeup from S3,
2202 * 1. skl_resume() powers up the display (refcount++ -> 1)
2203 * 2. hdmi_codec_complete() invokes the runtime suspend of codec
2204 * 3. hdac_hdmi_runtime_suspend() powers down the display (refcount-- -> 0)
2205 * 4. skl_runtime_suspend() invoked
2206 */
2207static int hdac_hdmi_runtime_suspend(struct device *dev) 2118static int hdac_hdmi_runtime_suspend(struct device *dev)
2208{ 2119{
2209 struct hdac_device *hdev = dev_to_hdac_dev(dev); 2120 struct hdac_device *hdev = dev_to_hdac_dev(dev);
@@ -2277,8 +2188,7 @@ static int hdac_hdmi_runtime_resume(struct device *dev)
2277 2188
2278static const struct dev_pm_ops hdac_hdmi_pm = { 2189static const struct dev_pm_ops hdac_hdmi_pm = {
2279 SET_RUNTIME_PM_OPS(hdac_hdmi_runtime_suspend, hdac_hdmi_runtime_resume, NULL) 2190 SET_RUNTIME_PM_OPS(hdac_hdmi_runtime_suspend, hdac_hdmi_runtime_resume, NULL)
2280 .prepare = hdmi_codec_prepare, 2191 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, hdmi_codec_resume)
2281 .complete = hdmi_codec_complete,
2282}; 2192};
2283 2193
2284static const struct hda_device_id hdmi_list[] = { 2194static const struct hda_device_id hdmi_list[] = {
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index d00734d31e04..e5b6769b9797 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -795,6 +795,8 @@ static int hdmi_codec_probe(struct platform_device *pdev)
795 if (hcd->spdif) 795 if (hcd->spdif)
796 hcp->daidrv[i] = hdmi_spdif_dai; 796 hcp->daidrv[i] = hdmi_spdif_dai;
797 797
798 dev_set_drvdata(dev, hcp);
799
798 ret = devm_snd_soc_register_component(dev, &hdmi_driver, hcp->daidrv, 800 ret = devm_snd_soc_register_component(dev, &hdmi_driver, hcp->daidrv,
799 dai_count); 801 dai_count);
800 if (ret) { 802 if (ret) {
@@ -802,8 +804,6 @@ static int hdmi_codec_probe(struct platform_device *pdev)
802 __func__, ret); 804 __func__, ret);
803 return ret; 805 return ret;
804 } 806 }
805
806 dev_set_drvdata(dev, hcp);
807 return 0; 807 return 0;
808} 808}
809 809
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 6cb1653be804..4cc24a5d5c31 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -1400,24 +1400,20 @@ static int pcm512x_digital_mute(struct snd_soc_dai *dai, int mute)
1400 if (ret != 0) { 1400 if (ret != 0) {
1401 dev_err(component->dev, 1401 dev_err(component->dev,
1402 "Failed to set digital mute: %d\n", ret); 1402 "Failed to set digital mute: %d\n", ret);
1403 mutex_unlock(&pcm512x->mutex); 1403 goto unlock;
1404 return ret;
1405 } 1404 }
1406 1405
1407 regmap_read_poll_timeout(pcm512x->regmap, 1406 regmap_read_poll_timeout(pcm512x->regmap,
1408 PCM512x_ANALOG_MUTE_DET, 1407 PCM512x_ANALOG_MUTE_DET,
1409 mute_det, (mute_det & 0x3) == 0, 1408 mute_det, (mute_det & 0x3) == 0,
1410 200, 10000); 1409 200, 10000);
1411
1412 mutex_unlock(&pcm512x->mutex);
1413 } else { 1410 } else {
1414 pcm512x->mute &= ~0x1; 1411 pcm512x->mute &= ~0x1;
1415 ret = pcm512x_update_mute(pcm512x); 1412 ret = pcm512x_update_mute(pcm512x);
1416 if (ret != 0) { 1413 if (ret != 0) {
1417 dev_err(component->dev, 1414 dev_err(component->dev,
1418 "Failed to update digital mute: %d\n", ret); 1415 "Failed to update digital mute: %d\n", ret);
1419 mutex_unlock(&pcm512x->mutex); 1416 goto unlock;
1420 return ret;
1421 } 1417 }
1422 1418
1423 regmap_read_poll_timeout(pcm512x->regmap, 1419 regmap_read_poll_timeout(pcm512x->regmap,
@@ -1428,9 +1424,10 @@ static int pcm512x_digital_mute(struct snd_soc_dai *dai, int mute)
1428 200, 10000); 1424 200, 10000);
1429 } 1425 }
1430 1426
1427unlock:
1431 mutex_unlock(&pcm512x->mutex); 1428 mutex_unlock(&pcm512x->mutex);
1432 1429
1433 return 0; 1430 return ret;
1434} 1431}
1435 1432
1436static const struct snd_soc_dai_ops pcm512x_dai_ops = { 1433static const struct snd_soc_dai_ops pcm512x_dai_ops = {
diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c
index 0ef966d56bac..e2855ab9a2c6 100644
--- a/sound/soc/codecs/rt274.c
+++ b/sound/soc/codecs/rt274.c
@@ -1128,8 +1128,11 @@ static int rt274_i2c_probe(struct i2c_client *i2c,
1128 return ret; 1128 return ret;
1129 } 1129 }
1130 1130
1131 regmap_read(rt274->regmap, 1131 ret = regmap_read(rt274->regmap,
1132 RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val); 1132 RT274_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val);
1133 if (ret)
1134 return ret;
1135
1133 if (val != RT274_VENDOR_ID) { 1136 if (val != RT274_VENDOR_ID) {
1134 dev_err(&i2c->dev, 1137 dev_err(&i2c->dev,
1135 "Device with ID register %#x is not rt274\n", val); 1138 "Device with ID register %#x is not rt274\n", val);
diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c
index 4d46f4567c3a..bec2eefa8b0f 100644
--- a/sound/soc/codecs/rt5514-spi.c
+++ b/sound/soc/codecs/rt5514-spi.c
@@ -280,6 +280,8 @@ static int rt5514_spi_pcm_probe(struct snd_soc_component *component)
280 280
281 rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp), 281 rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp),
282 GFP_KERNEL); 282 GFP_KERNEL);
283 if (!rt5514_dsp)
284 return -ENOMEM;
283 285
284 rt5514_dsp->dev = &rt5514_spi->dev; 286 rt5514_dsp->dev = &rt5514_spi->dev;
285 mutex_init(&rt5514_dsp->dma_lock); 287 mutex_init(&rt5514_dsp->dma_lock);
diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
index 34cfaf8f6f34..a9b91bcfcc09 100644
--- a/sound/soc/codecs/rt5682.c
+++ b/sound/soc/codecs/rt5682.c
@@ -1778,7 +1778,9 @@ static const struct snd_soc_dapm_route rt5682_dapm_routes[] = {
1778 {"ADC Stereo1 Filter", NULL, "ADC STO1 ASRC", is_using_asrc}, 1778 {"ADC Stereo1 Filter", NULL, "ADC STO1 ASRC", is_using_asrc},
1779 {"DAC Stereo1 Filter", NULL, "DAC STO1 ASRC", is_using_asrc}, 1779 {"DAC Stereo1 Filter", NULL, "DAC STO1 ASRC", is_using_asrc},
1780 {"ADC STO1 ASRC", NULL, "AD ASRC"}, 1780 {"ADC STO1 ASRC", NULL, "AD ASRC"},
1781 {"ADC STO1 ASRC", NULL, "DA ASRC"},
1781 {"ADC STO1 ASRC", NULL, "CLKDET"}, 1782 {"ADC STO1 ASRC", NULL, "CLKDET"},
1783 {"DAC STO1 ASRC", NULL, "AD ASRC"},
1782 {"DAC STO1 ASRC", NULL, "DA ASRC"}, 1784 {"DAC STO1 ASRC", NULL, "DA ASRC"},
1783 {"DAC STO1 ASRC", NULL, "CLKDET"}, 1785 {"DAC STO1 ASRC", NULL, "CLKDET"},
1784 1786
@@ -2512,6 +2514,7 @@ static void rt5682_calibrate(struct rt5682_priv *rt5682)
2512 regmap_write(rt5682->regmap, RT5682_PWR_DIG_1, 0x0000); 2514 regmap_write(rt5682->regmap, RT5682_PWR_DIG_1, 0x0000);
2513 regmap_write(rt5682->regmap, RT5682_CHOP_DAC, 0x2000); 2515 regmap_write(rt5682->regmap, RT5682_CHOP_DAC, 0x2000);
2514 regmap_write(rt5682->regmap, RT5682_CALIB_ADC_CTRL, 0x2005); 2516 regmap_write(rt5682->regmap, RT5682_CALIB_ADC_CTRL, 0x2005);
2517 regmap_write(rt5682->regmap, RT5682_STO1_ADC_MIXER, 0xc0c4);
2515 2518
2516 mutex_unlock(&rt5682->calibrate_mutex); 2519 mutex_unlock(&rt5682->calibrate_mutex);
2517 2520
diff --git a/sound/soc/codecs/rt5682.h b/sound/soc/codecs/rt5682.h
index d82a8301fd74..96944cff0ed7 100644
--- a/sound/soc/codecs/rt5682.h
+++ b/sound/soc/codecs/rt5682.h
@@ -849,18 +849,18 @@
849#define RT5682_SCLK_SRC_PLL2 (0x2 << 13) 849#define RT5682_SCLK_SRC_PLL2 (0x2 << 13)
850#define RT5682_SCLK_SRC_SDW (0x3 << 13) 850#define RT5682_SCLK_SRC_SDW (0x3 << 13)
851#define RT5682_SCLK_SRC_RCCLK (0x4 << 13) 851#define RT5682_SCLK_SRC_RCCLK (0x4 << 13)
852#define RT5682_PLL1_SRC_MASK (0x3 << 10) 852#define RT5682_PLL2_SRC_MASK (0x3 << 10)
853#define RT5682_PLL1_SRC_SFT 10 853#define RT5682_PLL2_SRC_SFT 10
854#define RT5682_PLL1_SRC_MCLK (0x0 << 10) 854#define RT5682_PLL2_SRC_MCLK (0x0 << 10)
855#define RT5682_PLL1_SRC_BCLK1 (0x1 << 10) 855#define RT5682_PLL2_SRC_BCLK1 (0x1 << 10)
856#define RT5682_PLL1_SRC_SDW (0x2 << 10) 856#define RT5682_PLL2_SRC_SDW (0x2 << 10)
857#define RT5682_PLL1_SRC_RC (0x3 << 10) 857#define RT5682_PLL2_SRC_RC (0x3 << 10)
858#define RT5682_PLL2_SRC_MASK (0x3 << 8) 858#define RT5682_PLL1_SRC_MASK (0x3 << 8)
859#define RT5682_PLL2_SRC_SFT 8 859#define RT5682_PLL1_SRC_SFT 8
860#define RT5682_PLL2_SRC_MCLK (0x0 << 8) 860#define RT5682_PLL1_SRC_MCLK (0x0 << 8)
861#define RT5682_PLL2_SRC_BCLK1 (0x1 << 8) 861#define RT5682_PLL1_SRC_BCLK1 (0x1 << 8)
862#define RT5682_PLL2_SRC_SDW (0x2 << 8) 862#define RT5682_PLL1_SRC_SDW (0x2 << 8)
863#define RT5682_PLL2_SRC_RC (0x3 << 8) 863#define RT5682_PLL1_SRC_RC (0x3 << 8)
864 864
865 865
866 866
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index e2b5a11b16d1..f03195d2ab2e 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -822,6 +822,10 @@ static int aic32x4_set_bias_level(struct snd_soc_component *component,
822 case SND_SOC_BIAS_PREPARE: 822 case SND_SOC_BIAS_PREPARE:
823 break; 823 break;
824 case SND_SOC_BIAS_STANDBY: 824 case SND_SOC_BIAS_STANDBY:
825 /* Initial cold start */
826 if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF)
827 break;
828
825 /* Switch off BCLK_N Divider */ 829 /* Switch off BCLK_N Divider */
826 snd_soc_component_update_bits(component, AIC32X4_BCLKN, 830 snd_soc_component_update_bits(component, AIC32X4_BCLKN,
827 AIC32X4_BCLKEN, 0); 831 AIC32X4_BCLKEN, 0);