From 01c8327667c249818d3712c3e25c7ad2aca7f389 Mon Sep 17 00:00:00 2001 From: Libin Yang Date: Sat, 13 Apr 2019 21:18:12 +0800 Subject: ASoC: codec: hdac_hdmi add device_link to card device In resume from S3, HDAC HDMI codec driver dapm event callback may be operated before HDMI codec driver turns on the display audio power domain because of the contest between display driver and hdmi codec driver. This patch adds the device_link between soc card device (consumer) and hdmi codec device (supplier) to make sure the sequence is always correct. Signed-off-by: Libin Yang Reviewed-by: Takashi Iwai Acked-by: Pierre-Louis Bossart Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- sound/soc/codecs/hdac_hdmi.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 5eeb0fe836a9..4de1fbfa8827 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -1854,6 +1854,17 @@ static int hdmi_codec_probe(struct snd_soc_component *component) /* Imp: Store the card pointer in hda_codec */ hdmi->card = dapm->card->snd_card; + /* + * Setup a device_link between card device and HDMI codec device. + * The card device is the consumer and the HDMI codec device is + * the supplier. With this setting, we can make sure that the audio + * domain in display power will be always turned on before operating + * on the HDMI audio codec registers. + * Let's use the flag DL_FLAG_AUTOREMOVE_CONSUMER. This can make + * sure the device link is freed when the machine driver is removed. + */ + device_link_add(component->card->dev, &hdev->dev, DL_FLAG_RPM_ACTIVE | + DL_FLAG_AUTOREMOVE_CONSUMER); /* * hdac_device core already sets the state to active and calls * get_noresume. So enable runtime and set the device to suspend. -- cgit v1.2.3 From 66287def435315d9d8de740da4c543e37630b897 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 25 Apr 2019 15:16:58 +0900 Subject: ASoC: rsnd: fixup 6ch settings to 8ch rsnd need to use 8ch clock settings for 6ch for TDM. Otherwise, it can't work correctly. This patch fixup it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 18 +++++++++++++----- sound/soc/sh/rcar/rsnd.h | 1 + sound/soc/sh/rcar/ssi.c | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 4fe83e611c01..37cb61553d5f 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -300,6 +300,18 @@ int rsnd_runtime_channel_after_ctu_with_params(struct rsnd_dai_stream *io, return chan; } +int rsnd_channel_normalization(int chan) +{ + if ((chan > 8) || (chan < 0)) + return 0; + + /* TDM Extend Mode needs 8ch */ + if (chan == 6) + chan = 8; + + return chan; +} + int rsnd_runtime_channel_for_ssi_with_params(struct rsnd_dai_stream *io, struct snd_pcm_hw_params *params) { @@ -312,11 +324,7 @@ int rsnd_runtime_channel_for_ssi_with_params(struct rsnd_dai_stream *io, if (rsnd_runtime_is_multi_ssi(io)) chan /= rsnd_rdai_ssi_lane_get(rdai); - /* TDM Extend Mode needs 8ch */ - if (chan == 6) - chan = 8; - - return chan; + return rsnd_channel_normalization(chan); } int rsnd_runtime_is_multi_ssi(struct rsnd_dai_stream *io) diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 0e6ef4e18400..7727add3eb1a 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -446,6 +446,7 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, struct device_node *playback, struct device_node *capture); +int rsnd_channel_normalization(int chan); #define rsnd_runtime_channel_original(io) \ rsnd_runtime_channel_original_with_params(io, NULL) int rsnd_runtime_channel_original_with_params(struct rsnd_dai_stream *io, diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index f5afab631abb..44bda210256e 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -303,6 +303,8 @@ static int rsnd_ssi_master_clk_start(struct rsnd_mod *mod, if (rsnd_runtime_is_tdm_split(io)) chan = rsnd_io_converted_chan(io); + chan = rsnd_channel_normalization(chan); + main_rate = rsnd_ssi_clk_query(rdai, rate, chan, &idx); if (!main_rate) { dev_err(dev, "unsupported clock rate\n"); -- cgit v1.2.3 From 0bbf4084e0cfbbbff8673f3b9867778d5d4b1d6f Mon Sep 17 00:00:00 2001 From: Fabien Dessenne Date: Wed, 24 Apr 2019 17:28:44 +0200 Subject: ASoC: stm32: i2s: return the get_irq error During probe, return the "get_irq" error value instead of -ENOENT. This allows the driver to be deferred probed if needed. Signed-off-by: Fabien Dessenne Signed-off-by: Mark Brown --- sound/soc/stm/stm32_i2s.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/stm/stm32_i2s.c b/sound/soc/stm/stm32_i2s.c index 8968458eec62..e707d28cb203 100644 --- a/sound/soc/stm/stm32_i2s.c +++ b/sound/soc/stm/stm32_i2s.c @@ -845,8 +845,9 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev, /* Get irqs */ irq = platform_get_irq(pdev, 0); if (irq < 0) { - dev_err(&pdev->dev, "no irq for node %s\n", pdev->name); - return -ENOENT; + if (irq != -EPROBE_DEFER) + dev_err(&pdev->dev, "no irq for node %s\n", pdev->name); + return irq; } ret = devm_request_irq(&pdev->dev, irq, stm32_i2s_isr, IRQF_ONESHOT, -- cgit v1.2.3 From c46ab1510de1d3dd9871ae36fbec0da3e0d2d6c5 Mon Sep 17 00:00:00 2001 From: Xun Zhang Date: Fri, 19 Apr 2019 15:53:49 -0500 Subject: ASoC: codecs: rt5682: initialize mutex before using In rt5682 codec driver, a mutex called "calibrate_mutex" is used in rt5682_calibrate() before initialization, which causes warning in lock debug. Move the initialization before the usage of mutex. Signed-off-by: Xun Zhang Signed-off-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/codecs/rt5682.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c index 86a7fa31c294..505fb3d7b1c5 100644 --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -2588,6 +2588,7 @@ static int rt5682_i2c_probe(struct i2c_client *i2c, rt5682_reset(rt5682->regmap); + mutex_init(&rt5682->calibrate_mutex); rt5682_calibrate(rt5682); ret = regmap_multi_reg_write(rt5682->regmap, patch_list, @@ -2654,7 +2655,6 @@ static int rt5682_i2c_probe(struct i2c_client *i2c, INIT_DELAYED_WORK(&rt5682->jd_check_work, rt5682_jd_check_handler); - mutex_init(&rt5682->calibrate_mutex); if (i2c->irq) { ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, -- cgit v1.2.3 From 780f202f2bf48aaa09282efc4dd6c39a146cc1f3 Mon Sep 17 00:00:00 2001 From: KaiChieh Chuang Date: Fri, 26 Apr 2019 10:09:43 +0800 Subject: ASoC: mediatek: btcvsd fix irq mask disable = 1 enable = 0 prevent AP wake up, when not AP BTSCO scenario Signed-off-by: KaiChieh Chuang Signed-off-by: Mark Brown --- sound/soc/mediatek/common/mtk-btcvsd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/mediatek/common/mtk-btcvsd.c b/sound/soc/mediatek/common/mtk-btcvsd.c index 9a163d7064d1..bd55c546e790 100644 --- a/sound/soc/mediatek/common/mtk-btcvsd.c +++ b/sound/soc/mediatek/common/mtk-btcvsd.c @@ -193,13 +193,13 @@ static const u8 table_msbc_silence[SCO_PACKET_180] = { static void mtk_btcvsd_snd_irq_enable(struct mtk_btcvsd_snd *bt) { regmap_update_bits(bt->infra, bt->infra_misc_offset, - bt->conn_bt_cvsd_mask, bt->conn_bt_cvsd_mask); + bt->conn_bt_cvsd_mask, 0); } static void mtk_btcvsd_snd_irq_disable(struct mtk_btcvsd_snd *bt) { regmap_update_bits(bt->infra, bt->infra_misc_offset, - bt->conn_bt_cvsd_mask, 0); + bt->conn_bt_cvsd_mask, bt->conn_bt_cvsd_mask); } static void mtk_btcvsd_snd_set_state(struct mtk_btcvsd_snd *bt, -- cgit v1.2.3 From 882c8b4af315bf921431142c1e9f5f69df99da34 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 30 Apr 2019 18:11:34 -0500 Subject: ASoC: dapm: fix kcontrols for effect widgets This patch adds the handling of snd_soc_dapm_effect that was missing. Signed-off-by: Ranjani Sridharan Signed-off-by: Seppo Ingalsuo Signed-off-by: Pierre-Louis Bossart Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 0382a47b30bd..29cdfbf4c888 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -883,6 +883,7 @@ static int dapm_create_or_share_kcontrol(struct snd_soc_dapm_widget *w, case snd_soc_dapm_switch: case snd_soc_dapm_mixer: case snd_soc_dapm_pga: + case snd_soc_dapm_effect: case snd_soc_dapm_out_drv: wname_in_long_name = true; kcname_in_long_name = true; @@ -2370,6 +2371,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt, case snd_soc_dapm_dac: case snd_soc_dapm_adc: case snd_soc_dapm_pga: + case snd_soc_dapm_effect: case snd_soc_dapm_out_drv: case snd_soc_dapm_mixer: case snd_soc_dapm_mixer_named_ctl: @@ -3197,6 +3199,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) dapm_new_mux(w); break; case snd_soc_dapm_pga: + case snd_soc_dapm_effect: case snd_soc_dapm_out_drv: dapm_new_pga(w); break; -- cgit v1.2.3 From 414a7321d60bc0abced4a760e22b8187e2b4aecf Mon Sep 17 00:00:00 2001 From: Logesh Date: Wed, 1 May 2019 14:34:24 +0530 Subject: ASoC: da7213: fix DAI_CLK_EN register bit overwrite If the da7213 codec is configured as Master with the DAPM power down delay time set, 'snd_soc_component_write' function overwrites the DAI_CLK_EN bit of DAI_CLK_MODE register which leads to audio play only once until it re-initialize after codec power up. Signed-off-by: Logesh Reviewed-by: Adam Thomson Signed-off-by: Mark Brown --- sound/soc/codecs/da7213.c | 5 ++++- sound/soc/codecs/da7213.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index 92d006a5283e..425c11d63e49 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -1305,7 +1305,10 @@ static int da7213_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) /* By default only 64 BCLK per WCLK is supported */ dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_64; - snd_soc_component_write(component, DA7213_DAI_CLK_MODE, dai_clk_mode); + snd_soc_component_update_bits(component, DA7213_DAI_CLK_MODE, + DA7213_DAI_BCLKS_PER_WCLK_MASK | + DA7213_DAI_CLK_POL_MASK | DA7213_DAI_WCLK_POL_MASK, + dai_clk_mode); snd_soc_component_update_bits(component, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK, dai_ctrl); snd_soc_component_write(component, DA7213_DAI_OFFSET, dai_offset); diff --git a/sound/soc/codecs/da7213.h b/sound/soc/codecs/da7213.h index 5a78dba1dcb5..9d31efc3cfe5 100644 --- a/sound/soc/codecs/da7213.h +++ b/sound/soc/codecs/da7213.h @@ -181,7 +181,9 @@ #define DA7213_DAI_BCLKS_PER_WCLK_256 (0x3 << 0) #define DA7213_DAI_BCLKS_PER_WCLK_MASK (0x3 << 0) #define DA7213_DAI_CLK_POL_INV (0x1 << 2) +#define DA7213_DAI_CLK_POL_MASK (0x1 << 2) #define DA7213_DAI_WCLK_POL_INV (0x1 << 3) +#define DA7213_DAI_WCLK_POL_MASK (0x1 << 3) #define DA7213_DAI_CLK_EN_MASK (0x1 << 7) /* DA7213_DAI_CTRL = 0x29 */ -- cgit v1.2.3 From cd8926e38e8cc53413a2a4ed2f705db7437a55fb Mon Sep 17 00:00:00 2001 From: Yu-Hsuan Hsu Date: Thu, 2 May 2019 12:07:43 +0800 Subject: ASoC: da7219: Update the support rate list If we want to set rate to 64000 on da7219, it fails and returns "snd_pcm_hw_params: Invalid argument". We should remove 64000 from support rate list because it is not available. Signed-off-by: Yu-Hsuan Hsu Reviewed-by: Adam Thomson Signed-off-by: Mark Brown --- sound/soc/codecs/da7219.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c index 121a8190f93e..9f6970eed6f6 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -1583,20 +1583,26 @@ static const struct snd_soc_dai_ops da7219_dai_ops = { #define DA7219_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) +#define DA7219_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ + SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 |\ + SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |\ + SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_88200 |\ + SNDRV_PCM_RATE_96000) + static struct snd_soc_dai_driver da7219_dai = { .name = "da7219-hifi", .playback = { .stream_name = "Playback", .channels_min = 1, .channels_max = DA7219_DAI_CH_NUM_MAX, - .rates = SNDRV_PCM_RATE_8000_96000, + .rates = DA7219_RATES, .formats = DA7219_FORMATS, }, .capture = { .stream_name = "Capture", .channels_min = 1, .channels_max = DA7219_DAI_CH_NUM_MAX, - .rates = SNDRV_PCM_RATE_8000_96000, + .rates = DA7219_RATES, .formats = DA7219_FORMATS, }, .ops = &da7219_dai_ops, -- cgit v1.2.3 From 30180e8436046344b12813dc954b2e01dfdcd22d Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Mon, 29 Apr 2019 15:29:39 +0200 Subject: ASoC: hdmi-codec: unlock the device on startup errors If the hdmi codec startup fails, it should clear the current_substream pointer to free the device. This is properly done for the audio_startup() callback but for snd_pcm_hw_constraint_eld(). Make sure the pointer cleared if an error is reported. Signed-off-by: Jerome Brunet Signed-off-by: Mark Brown --- sound/soc/codecs/hdmi-codec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sound/soc') diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 35df73e42cbc..fb2f0ac1f16f 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -439,8 +439,12 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, if (!ret) { ret = snd_pcm_hw_constraint_eld(substream->runtime, hcp->eld); - if (ret) + if (ret) { + mutex_lock(&hcp->current_stream_lock); + hcp->current_stream = NULL; + mutex_unlock(&hcp->current_stream_lock); return ret; + } } /* Select chmap supported */ hdmi_codec_eld_chmap(hcp); -- cgit v1.2.3 From 6a7c59c6d9f3b280e81d7a04bbe4e55e90152dce Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Mon, 29 Apr 2019 11:47:49 +0200 Subject: ASoC: fix valid stream condition A stream may specify a rate range using 'rate_min' and 'rate_max', so a stream may be valid and not specify any rates. However, as stream cannot be valid and not have any channel. Let's use this condition instead to determine if a stream is valid or not. Fixes: cde79035c6cf ("ASoC: Handle multiple codecs with split playback / capture") Signed-off-by: Jerome Brunet Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound/soc') diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index d21247546f7f..57088bd69e5d 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -43,8 +43,8 @@ static bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream) else codec_stream = &dai->driver->capture; - /* If the codec specifies any rate at all, it supports the stream. */ - return codec_stream->rates; + /* If the codec specifies any channels at all, it supports the stream */ + return codec_stream->channels_min; } /** -- cgit v1.2.3 From f47b9ad927c6370b80922af434dda98764a43804 Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Mon, 29 Apr 2019 11:47:50 +0200 Subject: ASoC: skip hw_free on codec dai for which the stream is invalid Like for hw_params, hw_free should not be called on codec dai for which the current stream is invalid. Fixes: cde79035c6cf ("ASoC: Handle multiple codecs with split playback / capture") Signed-off-by: Jerome Brunet Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sound/soc') diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 57088bd69e5d..a810f6eeffee 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1031,6 +1031,9 @@ interface_err: codec_err: for_each_rtd_codec_dai_rollback(rtd, i, codec_dai) { + if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) + continue; + if (codec_dai->driver->ops->hw_free) codec_dai->driver->ops->hw_free(substream, codec_dai); codec_dai->rate = 0; @@ -1088,6 +1091,9 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) /* now free hw params for the DAIs */ for_each_rtd_codec_dai(rtd, i, codec_dai) { + if (!snd_soc_dai_stream_valid(codec_dai, substream->stream)) + continue; + if (codec_dai->driver->ops->hw_free) codec_dai->driver->ops->hw_free(substream, codec_dai); } -- cgit v1.2.3