Commit ec4b2099 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: intel: use helper function

Current ASoC has many helper function.
This patch use it.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87tu07ea45.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e87abb83
...@@ -1327,15 +1327,13 @@ static bool is_sst_dapm_widget(struct snd_soc_dapm_widget *w) ...@@ -1327,15 +1327,13 @@ static bool is_sst_dapm_widget(struct snd_soc_dapm_widget *w)
int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute) int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute)
{ {
struct sst_data *drv = snd_soc_dai_get_drvdata(dai); struct sst_data *drv = snd_soc_dai_get_drvdata(dai);
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, stream);
struct snd_soc_dapm_path *p; struct snd_soc_dapm_path *p;
dev_dbg(dai->dev, "enter, dai-name=%s dir=%d\n", dai->name, stream); dev_dbg(dai->dev, "enter, dai-name=%s dir=%d\n", dai->name, stream);
dev_dbg(dai->dev, "Stream name=%s\n", w->name);
if (stream == SNDRV_PCM_STREAM_PLAYBACK) { if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
dev_dbg(dai->dev, "Stream name=%s\n",
dai->playback_widget->name);
w = dai->playback_widget;
snd_soc_dapm_widget_for_each_sink_path(w, p) { snd_soc_dapm_widget_for_each_sink_path(w, p) {
if (p->connected && !p->connected(w, p->sink)) if (p->connected && !p->connected(w, p->sink))
continue; continue;
...@@ -1352,9 +1350,6 @@ int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute) ...@@ -1352,9 +1350,6 @@ int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute)
} }
} }
} else { } else {
dev_dbg(dai->dev, "Stream name=%s\n",
dai->capture_widget->name);
w = dai->capture_widget;
snd_soc_dapm_widget_for_each_source_path(w, p) { snd_soc_dapm_widget_for_each_source_path(w, p) {
if (p->connected && !p->connected(w, p->source)) if (p->connected && !p->connected(w, p->source))
continue; continue;
......
...@@ -258,14 +258,15 @@ static int avs_card_resume_post(struct snd_soc_card *card) ...@@ -258,14 +258,15 @@ static int avs_card_resume_post(struct snd_soc_card *card)
{ {
struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI); struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI);
struct snd_soc_jack *jack = snd_soc_card_get_drvdata(card); struct snd_soc_jack *jack = snd_soc_card_get_drvdata(card);
int stream = SNDRV_PCM_STREAM_PLAYBACK;
if (!codec_dai) { if (!codec_dai) {
dev_err(card->dev, "Codec dai not found\n"); dev_err(card->dev, "Codec dai not found\n");
return -EINVAL; return -EINVAL;
} }
if (codec_dai->stream_active[SNDRV_PCM_STREAM_PLAYBACK] && if (snd_soc_dai_stream_active(codec_dai, stream) &&
codec_dai->playback_widget->active) snd_soc_dai_get_widget(codec_dai, stream)->active)
snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_FLL_FS, 0, SND_SOC_CLOCK_IN); snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_FLL_FS, 0, SND_SOC_CLOCK_IN);
return snd_soc_component_set_jack(codec_dai->component, jack, NULL); return snd_soc_component_set_jack(codec_dai->component, jack, NULL);
......
...@@ -35,15 +35,13 @@ struct avs_dma_data { ...@@ -35,15 +35,13 @@ struct avs_dma_data {
static struct avs_tplg_path_template * static struct avs_tplg_path_template *
avs_dai_find_path_template(struct snd_soc_dai *dai, bool is_fe, int direction) avs_dai_find_path_template(struct snd_soc_dai *dai, bool is_fe, int direction)
{ {
struct snd_soc_dapm_widget *dw; struct snd_soc_dapm_widget *dw = snd_soc_dai_get_widget(dai, direction);
struct snd_soc_dapm_path *dp; struct snd_soc_dapm_path *dp;
enum snd_soc_dapm_direction dir; enum snd_soc_dapm_direction dir;
if (direction == SNDRV_PCM_STREAM_CAPTURE) { if (direction == SNDRV_PCM_STREAM_CAPTURE) {
dw = dai->capture_widget;
dir = is_fe ? SND_SOC_DAPM_DIR_OUT : SND_SOC_DAPM_DIR_IN; dir = is_fe ? SND_SOC_DAPM_DIR_OUT : SND_SOC_DAPM_DIR_IN;
} else { } else {
dw = dai->playback_widget;
dir = is_fe ? SND_SOC_DAPM_DIR_IN : SND_SOC_DAPM_DIR_OUT; dir = is_fe ? SND_SOC_DAPM_DIR_IN : SND_SOC_DAPM_DIR_OUT;
} }
...@@ -929,7 +927,7 @@ static int avs_component_pm_op(struct snd_soc_component *component, bool be, ...@@ -929,7 +927,7 @@ static int avs_component_pm_op(struct snd_soc_component *component, bool be,
int ret; int ret;
for_each_component_dais(component, dai) { for_each_component_dais(component, dai) {
data = dai->playback_dma_data; data = snd_soc_dai_dma_data_get_playback(dai);
if (data) { if (data) {
rtd = asoc_substream_to_rtd(data->substream); rtd = asoc_substream_to_rtd(data->substream);
if (rtd->dai_link->no_pcm == be && !rtd->dai_link->ignore_suspend) { if (rtd->dai_link->no_pcm == be && !rtd->dai_link->ignore_suspend) {
...@@ -942,7 +940,7 @@ static int avs_component_pm_op(struct snd_soc_component *component, bool be, ...@@ -942,7 +940,7 @@ static int avs_component_pm_op(struct snd_soc_component *component, bool be,
} }
} }
data = dai->capture_dma_data; data = snd_soc_dai_dma_data_get_capture(dai);
if (data) { if (data) {
rtd = asoc_substream_to_rtd(data->substream); rtd = asoc_substream_to_rtd(data->substream);
if (rtd->dai_link->no_pcm == be && !rtd->dai_link->ignore_suspend) { if (rtd->dai_link->no_pcm == be && !rtd->dai_link->ignore_suspend) {
...@@ -1291,11 +1289,14 @@ static void avs_component_hda_unregister_dais(struct snd_soc_component *componen ...@@ -1291,11 +1289,14 @@ static void avs_component_hda_unregister_dais(struct snd_soc_component *componen
sprintf(name, "%s-cpu", dev_name(&codec->core.dev)); sprintf(name, "%s-cpu", dev_name(&codec->core.dev));
for_each_component_dais_safe(component, dai, save) { for_each_component_dais_safe(component, dai, save) {
int stream;
if (!strstr(dai->driver->name, name)) if (!strstr(dai->driver->name, name))
continue; continue;
snd_soc_dapm_free_widget(dai->playback_widget); for_each_pcm_streams(stream)
snd_soc_dapm_free_widget(dai->capture_widget); snd_soc_dapm_free_widget(snd_soc_dai_get_widget(dai, stream));
snd_soc_unregister_dai(dai); snd_soc_unregister_dai(dai);
} }
} }
......
...@@ -1663,11 +1663,10 @@ int skl_tplg_update_pipe_params(struct device *dev, ...@@ -1663,11 +1663,10 @@ int skl_tplg_update_pipe_params(struct device *dev,
struct skl_module_cfg * struct skl_module_cfg *
skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream) skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream)
{ {
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, stream);
struct snd_soc_dapm_path *p = NULL; struct snd_soc_dapm_path *p = NULL;
if (stream == SNDRV_PCM_STREAM_PLAYBACK) { if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
w = dai->playback_widget;
snd_soc_dapm_widget_for_each_sink_path(w, p) { snd_soc_dapm_widget_for_each_sink_path(w, p) {
if (p->connect && p->sink->power && if (p->connect && p->sink->power &&
!is_skl_dsp_widget_type(p->sink, dai->dev)) !is_skl_dsp_widget_type(p->sink, dai->dev))
...@@ -1680,7 +1679,6 @@ skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream) ...@@ -1680,7 +1679,6 @@ skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream)
} }
} }
} else { } else {
w = dai->capture_widget;
snd_soc_dapm_widget_for_each_source_path(w, p) { snd_soc_dapm_widget_for_each_source_path(w, p) {
if (p->connect && p->source->power && if (p->connect && p->source->power &&
!is_skl_dsp_widget_type(p->source, dai->dev)) !is_skl_dsp_widget_type(p->source, dai->dev))
...@@ -1744,14 +1742,12 @@ static struct skl_module_cfg *skl_get_mconfig_cap_cpr( ...@@ -1744,14 +1742,12 @@ static struct skl_module_cfg *skl_get_mconfig_cap_cpr(
struct skl_module_cfg * struct skl_module_cfg *
skl_tplg_be_get_cpr_module(struct snd_soc_dai *dai, int stream) skl_tplg_be_get_cpr_module(struct snd_soc_dai *dai, int stream)
{ {
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, stream);
struct skl_module_cfg *mconfig; struct skl_module_cfg *mconfig;
if (stream == SNDRV_PCM_STREAM_PLAYBACK) { if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
w = dai->playback_widget;
mconfig = skl_get_mconfig_pb_cpr(dai, w); mconfig = skl_get_mconfig_pb_cpr(dai, w);
} else { } else {
w = dai->capture_widget;
mconfig = skl_get_mconfig_cap_cpr(dai, w); mconfig = skl_get_mconfig_cap_cpr(dai, w);
} }
return mconfig; return mconfig;
...@@ -1905,20 +1901,13 @@ static int skl_tplg_be_set_sink_pipe_params(struct snd_soc_dai *dai, ...@@ -1905,20 +1901,13 @@ static int skl_tplg_be_set_sink_pipe_params(struct snd_soc_dai *dai,
int skl_tplg_be_update_params(struct snd_soc_dai *dai, int skl_tplg_be_update_params(struct snd_soc_dai *dai,
struct skl_pipe_params *params) struct skl_pipe_params *params)
{ {
struct snd_soc_dapm_widget *w; struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(dai, params->stream);
if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) { if (params->stream == SNDRV_PCM_STREAM_PLAYBACK) {
w = dai->playback_widget;
return skl_tplg_be_set_src_pipe_params(dai, w, params); return skl_tplg_be_set_src_pipe_params(dai, w, params);
} else { } else {
w = dai->capture_widget;
return skl_tplg_be_set_sink_pipe_params(dai, w, params); return skl_tplg_be_set_sink_pipe_params(dai, w, params);
} }
return 0;
} }
static const struct snd_soc_tplg_widget_events skl_tplg_widget_ops[] = { static const struct snd_soc_tplg_widget_events skl_tplg_widget_ops[] = {
...@@ -2978,7 +2967,7 @@ void skl_cleanup_resources(struct skl_dev *skl) ...@@ -2978,7 +2967,7 @@ void skl_cleanup_resources(struct skl_dev *skl)
return; return;
card = soc_component->card; card = soc_component->card;
if (!card || !card->instantiated) if (!snd_soc_card_is_instantiated(card))
return; return;
list_for_each_entry(w, &card->widgets, list) { list_for_each_entry(w, &card->widgets, list) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment