[PATCH 2/4] ASoC: intel: baytrail: don't use snd_soc_rtdcom_lookup()
Kuninori Morimoto
kuninori.morimoto.gx at renesas.com
Wed Apr 22 06:48:12 CEST 2020
From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
We shouldn't use snd_soc_rtdcom_lookup() as much as possible.
It works today, but, will not work in the future if we support multi
CPU/Codec/Platform, because 1 rtd might have multiple same driver
named component.
intel baytrail driver is using it, but we can avoid it easily
by having component pointer at sst_byt_pcm_data.
This patch removes snd_soc_rtdcom_lookup() from this driver.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
sound/soc/intel/baytrail/sst-baytrail-pcm.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c
index 53383055c8dc..dbd830375bc4 100644
--- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c
+++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c
@@ -36,6 +36,7 @@ static const struct snd_pcm_hardware sst_byt_pcm_hardware = {
/* private data for each PCM DSP stream */
struct sst_byt_pcm_data {
struct sst_byt_stream *stream;
+ struct snd_soc_component *component;
struct snd_pcm_substream *substream;
struct mutex mutex;
@@ -119,12 +120,11 @@ static int sst_byt_pcm_hw_params(struct snd_soc_component *component,
return 0;
}
-static int sst_byt_pcm_restore_stream_context(struct snd_pcm_substream *substream)
+static int sst_byt_pcm_restore_stream_context(struct sst_byt_pcm_data *pcm_data)
{
- struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
+ struct snd_soc_pcm_runtime *rtd = pcm_data->substream->private_data;
+ struct snd_soc_component *component = pcm_data->component;
struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component);
- struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream];
struct sst_byt *byt = pdata->byt;
int ret;
@@ -149,7 +149,7 @@ static void sst_byt_pcm_work(struct work_struct *work)
container_of(work, struct sst_byt_pcm_data, work);
if (snd_pcm_running(pcm_data->substream))
- sst_byt_pcm_restore_stream_context(pcm_data->substream);
+ sst_byt_pcm_restore_stream_context(pcm_data);
}
static int sst_byt_pcm_trigger(struct snd_soc_component *component,
@@ -198,7 +198,7 @@ static u32 byt_notify_pointer(struct sst_byt_stream *stream, void *data)
struct snd_pcm_substream *substream = pcm_data->substream;
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_pcm_runtime *rtd = substream->private_data;
- struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
+ struct snd_soc_component *component = pcm_data->component;
struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component);
struct sst_byt *byt = pdata->byt;
u32 pos, hw_pos;
@@ -242,6 +242,7 @@ static int sst_byt_pcm_open(struct snd_soc_component *component,
mutex_lock(&pcm_data->mutex);
pcm_data->substream = substream;
+ pcm_data->component = component;
snd_soc_set_runtime_hwparams(substream, &sst_byt_pcm_hardware);
--
2.17.1
More information about the Alsa-devel
mailing list