Merge series "ASoC: sdm845: fix soundwire stream handling" from Srinivas Kandagatla <srinivas.kandagatla@linaro.org>:
Recent addition of SoundWire stream state-machine checks in linux-next have shown an existing issue with handling soundwire streams in codec drivers. In general soundwire stream prepare/enable/disable can be called from either codec/machine/controller driver. However calling it in codec driver means that if multiple instances(Left/Right speakers) of the same codec is connected to the same stream then it will endup calling stream prepare/enable/disable more than once. This will mess up the stream state-machine checks in the soundwire core. Moving this stream handling to machine driver would fix this issue and also allow board/platform specfic power sequencing. Changes since v1: - removed false error check while setting sruntime. Srinivas Kandagatla (2): ASoC: qcom: sdm845: handle soundwire stream ASoC: codecs: wsa881x: remove soundwire stream handling sound/soc/codecs/wsa881x.c | 44 +------------------------ sound/soc/qcom/Kconfig | 2 +- sound/soc/qcom/sdm845.c | 67 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 44 deletions(-) -- 2.21.0
This commit is contained in:
Коммит
8d34d09139
|
@ -676,7 +676,6 @@ struct wsa881x_priv {
|
|||
int active_ports;
|
||||
bool port_prepared[WSA881X_MAX_SWR_PORTS];
|
||||
bool port_enable[WSA881X_MAX_SWR_PORTS];
|
||||
bool stream_prepared;
|
||||
};
|
||||
|
||||
static void wsa881x_init(struct wsa881x_priv *wsa881x)
|
||||
|
@ -954,41 +953,6 @@ static const struct snd_soc_dapm_widget wsa881x_dapm_widgets[] = {
|
|||
SND_SOC_DAPM_OUTPUT("SPKR"),
|
||||
};
|
||||
|
||||
static int wsa881x_prepare(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_dai *dai)
|
||||
{
|
||||
struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev);
|
||||
int ret;
|
||||
|
||||
if (wsa881x->stream_prepared) {
|
||||
sdw_disable_stream(wsa881x->sruntime);
|
||||
sdw_deprepare_stream(wsa881x->sruntime);
|
||||
wsa881x->stream_prepared = false;
|
||||
}
|
||||
|
||||
|
||||
ret = sdw_prepare_stream(wsa881x->sruntime);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/**
|
||||
* NOTE: there is a strict hw requirement about the ordering of port
|
||||
* enables and actual PA enable. PA enable should only happen after
|
||||
* soundwire ports are enabled if not DC on the line is accumulated
|
||||
* resulting in Click/Pop Noise
|
||||
* PA enable/mute are handled as part of DAPM and digital mute.
|
||||
*/
|
||||
|
||||
ret = sdw_enable_stream(wsa881x->sruntime);
|
||||
if (ret) {
|
||||
sdw_deprepare_stream(wsa881x->sruntime);
|
||||
return ret;
|
||||
}
|
||||
wsa881x->stream_prepared = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int wsa881x_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params,
|
||||
struct snd_soc_dai *dai)
|
||||
|
@ -1016,12 +980,7 @@ static int wsa881x_hw_free(struct snd_pcm_substream *substream,
|
|||
{
|
||||
struct wsa881x_priv *wsa881x = dev_get_drvdata(dai->dev);
|
||||
|
||||
if (wsa881x->stream_prepared) {
|
||||
sdw_disable_stream(wsa881x->sruntime);
|
||||
sdw_deprepare_stream(wsa881x->sruntime);
|
||||
sdw_stream_remove_slave(wsa881x->slave, wsa881x->sruntime);
|
||||
wsa881x->stream_prepared = false;
|
||||
}
|
||||
sdw_stream_remove_slave(wsa881x->slave, wsa881x->sruntime);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1052,7 +1011,6 @@ static int wsa881x_digital_mute(struct snd_soc_dai *dai, int mute, int stream)
|
|||
|
||||
static struct snd_soc_dai_ops wsa881x_dai_ops = {
|
||||
.hw_params = wsa881x_hw_params,
|
||||
.prepare = wsa881x_prepare,
|
||||
.hw_free = wsa881x_hw_free,
|
||||
.mute_stream = wsa881x_digital_mute,
|
||||
.set_sdw_stream = wsa881x_set_sdw_stream,
|
||||
|
|
|
@ -99,7 +99,7 @@ config SND_SOC_MSM8996
|
|||
|
||||
config SND_SOC_SDM845
|
||||
tristate "SoC Machine driver for SDM845 boards"
|
||||
depends on QCOM_APR && CROS_EC && I2C
|
||||
depends on QCOM_APR && CROS_EC && I2C && SOUNDWIRE
|
||||
select SND_SOC_QDSP6
|
||||
select SND_SOC_QCOM_COMMON
|
||||
select SND_SOC_RT5663
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <sound/pcm_params.h>
|
||||
#include <sound/jack.h>
|
||||
#include <sound/soc.h>
|
||||
#include <linux/soundwire/sdw.h>
|
||||
#include <uapi/linux/input-event-codes.h>
|
||||
#include "common.h"
|
||||
#include "qdsp6/q6afe.h"
|
||||
|
@ -31,10 +32,12 @@
|
|||
struct sdm845_snd_data {
|
||||
struct snd_soc_jack jack;
|
||||
bool jack_setup;
|
||||
bool stream_prepared[SLIM_MAX_RX_PORTS];
|
||||
struct snd_soc_card *card;
|
||||
uint32_t pri_mi2s_clk_count;
|
||||
uint32_t sec_mi2s_clk_count;
|
||||
uint32_t quat_tdm_clk_count;
|
||||
struct sdw_stream_runtime *sruntime[SLIM_MAX_RX_PORTS];
|
||||
};
|
||||
|
||||
static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28};
|
||||
|
@ -45,11 +48,18 @@ static int sdm845_slim_snd_hw_params(struct snd_pcm_substream *substream,
|
|||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||
struct snd_soc_dai *codec_dai;
|
||||
struct sdm845_snd_data *pdata = snd_soc_card_get_drvdata(rtd->card);
|
||||
u32 rx_ch[SLIM_MAX_RX_PORTS], tx_ch[SLIM_MAX_TX_PORTS];
|
||||
struct sdw_stream_runtime *sruntime;
|
||||
u32 rx_ch_cnt = 0, tx_ch_cnt = 0;
|
||||
int ret = 0, i;
|
||||
|
||||
for_each_rtd_codec_dais(rtd, i, codec_dai) {
|
||||
sruntime = snd_soc_dai_get_sdw_stream(codec_dai,
|
||||
substream->stream);
|
||||
if (sruntime != ERR_PTR(-ENOTSUPP))
|
||||
pdata->sruntime[cpu_dai->id] = sruntime;
|
||||
|
||||
ret = snd_soc_dai_get_channel_map(codec_dai,
|
||||
&tx_ch_cnt, tx_ch, &rx_ch_cnt, rx_ch);
|
||||
|
||||
|
@ -425,8 +435,65 @@ static void sdm845_snd_shutdown(struct snd_pcm_substream *substream)
|
|||
}
|
||||
}
|
||||
|
||||
static int sdm845_snd_prepare(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
struct sdm845_snd_data *data = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||
struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id];
|
||||
int ret;
|
||||
|
||||
if (!sruntime)
|
||||
return 0;
|
||||
|
||||
if (data->stream_prepared[cpu_dai->id]) {
|
||||
sdw_disable_stream(sruntime);
|
||||
sdw_deprepare_stream(sruntime);
|
||||
data->stream_prepared[cpu_dai->id] = false;
|
||||
}
|
||||
|
||||
ret = sdw_prepare_stream(sruntime);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/**
|
||||
* NOTE: there is a strict hw requirement about the ordering of port
|
||||
* enables and actual WSA881x PA enable. PA enable should only happen
|
||||
* after soundwire ports are enabled if not DC on the line is
|
||||
* accumulated resulting in Click/Pop Noise
|
||||
* PA enable/mute are handled as part of codec DAPM and digital mute.
|
||||
*/
|
||||
|
||||
ret = sdw_enable_stream(sruntime);
|
||||
if (ret) {
|
||||
sdw_deprepare_stream(sruntime);
|
||||
return ret;
|
||||
}
|
||||
data->stream_prepared[cpu_dai->id] = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int sdm845_snd_hw_free(struct snd_pcm_substream *substream)
|
||||
{
|
||||
struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
||||
struct sdm845_snd_data *data = snd_soc_card_get_drvdata(rtd->card);
|
||||
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
|
||||
struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id];
|
||||
|
||||
if (sruntime && data->stream_prepared[cpu_dai->id]) {
|
||||
sdw_disable_stream(sruntime);
|
||||
sdw_deprepare_stream(sruntime);
|
||||
data->stream_prepared[cpu_dai->id] = false;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct snd_soc_ops sdm845_be_ops = {
|
||||
.hw_params = sdm845_snd_hw_params,
|
||||
.hw_free = sdm845_snd_hw_free,
|
||||
.prepare = sdm845_snd_prepare,
|
||||
.startup = sdm845_snd_startup,
|
||||
.shutdown = sdm845_snd_shutdown,
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче