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

ASoC: meson: use helper function

Current ASoC has many helper function.
This patch use it.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Link: https://lore.kernel.org/r/87r0vbea3r.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0df2ec8e
...@@ -88,7 +88,7 @@ static int aiu_fifo_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -88,7 +88,7 @@ static int aiu_fifo_i2s_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_component *component = dai->component; struct snd_soc_component *component = dai->component;
struct aiu_fifo *fifo = dai->playback_dma_data; struct aiu_fifo *fifo = snd_soc_dai_dma_data_get_playback(dai);
unsigned int val; unsigned int val;
int ret; int ret;
...@@ -158,7 +158,7 @@ int aiu_fifo_i2s_dai_probe(struct snd_soc_dai *dai) ...@@ -158,7 +158,7 @@ int aiu_fifo_i2s_dai_probe(struct snd_soc_dai *dai)
if (ret) if (ret)
return ret; return ret;
fifo = dai->playback_dma_data; fifo = snd_soc_dai_dma_data_get_playback(dai);
fifo->pcm = &fifo_i2s_pcm; fifo->pcm = &fifo_i2s_pcm;
fifo->mem_offset = AIU_MEM_I2S_START; fifo->mem_offset = AIU_MEM_I2S_START;
......
...@@ -173,7 +173,7 @@ int aiu_fifo_spdif_dai_probe(struct snd_soc_dai *dai) ...@@ -173,7 +173,7 @@ int aiu_fifo_spdif_dai_probe(struct snd_soc_dai *dai)
if (ret) if (ret)
return ret; return ret;
fifo = dai->playback_dma_data; fifo = snd_soc_dai_dma_data_get_playback(dai);
fifo->pcm = &fifo_spdif_pcm; fifo->pcm = &fifo_spdif_pcm;
fifo->mem_offset = AIU_MEM_IEC958_START; fifo->mem_offset = AIU_MEM_IEC958_START;
......
...@@ -34,7 +34,7 @@ snd_pcm_uframes_t aiu_fifo_pointer(struct snd_soc_component *component, ...@@ -34,7 +34,7 @@ snd_pcm_uframes_t aiu_fifo_pointer(struct snd_soc_component *component,
struct snd_pcm_substream *substream) struct snd_pcm_substream *substream)
{ {
struct snd_soc_dai *dai = aiu_fifo_dai(substream); struct snd_soc_dai *dai = aiu_fifo_dai(substream);
struct aiu_fifo *fifo = dai->playback_dma_data; struct aiu_fifo *fifo = snd_soc_dai_dma_data_get_playback(dai);
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
unsigned int addr; unsigned int addr;
...@@ -46,7 +46,7 @@ snd_pcm_uframes_t aiu_fifo_pointer(struct snd_soc_component *component, ...@@ -46,7 +46,7 @@ snd_pcm_uframes_t aiu_fifo_pointer(struct snd_soc_component *component,
static void aiu_fifo_enable(struct snd_soc_dai *dai, bool enable) static void aiu_fifo_enable(struct snd_soc_dai *dai, bool enable)
{ {
struct snd_soc_component *component = dai->component; struct snd_soc_component *component = dai->component;
struct aiu_fifo *fifo = dai->playback_dma_data; struct aiu_fifo *fifo = snd_soc_dai_dma_data_get_playback(dai);
unsigned int en_mask = (AIU_MEM_CONTROL_FILL_EN | unsigned int en_mask = (AIU_MEM_CONTROL_FILL_EN |
AIU_MEM_CONTROL_EMPTY_EN); AIU_MEM_CONTROL_EMPTY_EN);
...@@ -80,7 +80,7 @@ int aiu_fifo_prepare(struct snd_pcm_substream *substream, ...@@ -80,7 +80,7 @@ int aiu_fifo_prepare(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_component *component = dai->component; struct snd_soc_component *component = dai->component;
struct aiu_fifo *fifo = dai->playback_dma_data; struct aiu_fifo *fifo = snd_soc_dai_dma_data_get_playback(dai);
snd_soc_component_update_bits(component, snd_soc_component_update_bits(component,
fifo->mem_offset + AIU_MEM_CONTROL, fifo->mem_offset + AIU_MEM_CONTROL,
...@@ -98,7 +98,7 @@ int aiu_fifo_hw_params(struct snd_pcm_substream *substream, ...@@ -98,7 +98,7 @@ int aiu_fifo_hw_params(struct snd_pcm_substream *substream,
{ {
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_component *component = dai->component; struct snd_soc_component *component = dai->component;
struct aiu_fifo *fifo = dai->playback_dma_data; struct aiu_fifo *fifo = snd_soc_dai_dma_data_get_playback(dai);
dma_addr_t end; dma_addr_t end;
/* Setup the fifo boundaries */ /* Setup the fifo boundaries */
...@@ -132,7 +132,7 @@ static irqreturn_t aiu_fifo_isr(int irq, void *dev_id) ...@@ -132,7 +132,7 @@ static irqreturn_t aiu_fifo_isr(int irq, void *dev_id)
int aiu_fifo_startup(struct snd_pcm_substream *substream, int aiu_fifo_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct aiu_fifo *fifo = dai->playback_dma_data; struct aiu_fifo *fifo = snd_soc_dai_dma_data_get_playback(dai);
int ret; int ret;
snd_soc_set_runtime_hwparams(substream, fifo->pcm); snd_soc_set_runtime_hwparams(substream, fifo->pcm);
...@@ -168,7 +168,7 @@ int aiu_fifo_startup(struct snd_pcm_substream *substream, ...@@ -168,7 +168,7 @@ int aiu_fifo_startup(struct snd_pcm_substream *substream,
void aiu_fifo_shutdown(struct snd_pcm_substream *substream, void aiu_fifo_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct aiu_fifo *fifo = dai->playback_dma_data; struct aiu_fifo *fifo = snd_soc_dai_dma_data_get_playback(dai);
free_irq(fifo->irq, substream); free_irq(fifo->irq, substream);
clk_disable_unprepare(fifo->pclk); clk_disable_unprepare(fifo->pclk);
...@@ -178,7 +178,7 @@ int aiu_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd, ...@@ -178,7 +178,7 @@ int aiu_fifo_pcm_new(struct snd_soc_pcm_runtime *rtd,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_card *card = rtd->card->snd_card; struct snd_card *card = rtd->card->snd_card;
struct aiu_fifo *fifo = dai->playback_dma_data; struct aiu_fifo *fifo = snd_soc_dai_dma_data_get_playback(dai);
size_t size = fifo->pcm->buffer_bytes_max; size_t size = fifo->pcm->buffer_bytes_max;
int ret; int ret;
...@@ -200,15 +200,16 @@ int aiu_fifo_dai_probe(struct snd_soc_dai *dai) ...@@ -200,15 +200,16 @@ int aiu_fifo_dai_probe(struct snd_soc_dai *dai)
if (!fifo) if (!fifo)
return -ENOMEM; return -ENOMEM;
dai->playback_dma_data = fifo; snd_soc_dai_dma_data_set_playback(dai, fifo);
return 0; return 0;
} }
int aiu_fifo_dai_remove(struct snd_soc_dai *dai) int aiu_fifo_dai_remove(struct snd_soc_dai *dai)
{ {
kfree(dai->playback_dma_data); struct aiu_fifo *fifo = snd_soc_dai_dma_data_get_playback(dai);
kfree(fifo);
return 0; return 0;
} }
...@@ -37,10 +37,8 @@ int axg_tdm_set_tdm_slots(struct snd_soc_dai *dai, u32 *tx_mask, ...@@ -37,10 +37,8 @@ int axg_tdm_set_tdm_slots(struct snd_soc_dai *dai, u32 *tx_mask,
unsigned int slot_width) unsigned int slot_width)
{ {
struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai); struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai);
struct axg_tdm_stream *tx = (struct axg_tdm_stream *) struct axg_tdm_stream *tx = snd_soc_dai_dma_data_get_playback(dai);
dai->playback_dma_data; struct axg_tdm_stream *rx = snd_soc_dai_dma_data_get_capture(dai);
struct axg_tdm_stream *rx = (struct axg_tdm_stream *)
dai->capture_dma_data;
unsigned int tx_slots, rx_slots; unsigned int tx_slots, rx_slots;
unsigned int fmt = 0; unsigned int fmt = 0;
...@@ -362,11 +360,14 @@ static int axg_tdm_iface_prepare(struct snd_pcm_substream *substream, ...@@ -362,11 +360,14 @@ static int axg_tdm_iface_prepare(struct snd_pcm_substream *substream,
static int axg_tdm_iface_remove_dai(struct snd_soc_dai *dai) static int axg_tdm_iface_remove_dai(struct snd_soc_dai *dai)
{ {
if (dai->capture_dma_data) int stream;
axg_tdm_stream_free(dai->capture_dma_data);
if (dai->playback_dma_data) for_each_pcm_streams(stream) {
axg_tdm_stream_free(dai->playback_dma_data); struct axg_tdm_stream *ts = snd_soc_dai_dma_data_get(dai, stream);
if (ts)
axg_tdm_stream_free(ts);
}
return 0; return 0;
} }
...@@ -374,19 +375,20 @@ static int axg_tdm_iface_remove_dai(struct snd_soc_dai *dai) ...@@ -374,19 +375,20 @@ static int axg_tdm_iface_remove_dai(struct snd_soc_dai *dai)
static int axg_tdm_iface_probe_dai(struct snd_soc_dai *dai) static int axg_tdm_iface_probe_dai(struct snd_soc_dai *dai)
{ {
struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai); struct axg_tdm_iface *iface = snd_soc_dai_get_drvdata(dai);
int stream;
if (dai->capture_widget) { for_each_pcm_streams(stream) {
dai->capture_dma_data = axg_tdm_stream_alloc(iface); struct axg_tdm_stream *ts;
if (!dai->capture_dma_data)
return -ENOMEM; if (!snd_soc_dai_get_widget(dai, stream))
} continue;
if (dai->playback_widget) { ts = axg_tdm_stream_alloc(iface);
dai->playback_dma_data = axg_tdm_stream_alloc(iface); if (!ts) {
if (!dai->playback_dma_data) {
axg_tdm_iface_remove_dai(dai); axg_tdm_iface_remove_dai(dai);
return -ENOMEM; return -ENOMEM;
} }
snd_soc_dai_dma_data_set(dai, stream, ts);
} }
return 0; return 0;
......
...@@ -83,7 +83,7 @@ axg_tdmin_get_tdm_stream(struct snd_soc_dapm_widget *w) ...@@ -83,7 +83,7 @@ axg_tdmin_get_tdm_stream(struct snd_soc_dapm_widget *w)
if (!be) if (!be)
return NULL; return NULL;
return be->capture_dma_data; return snd_soc_dai_dma_data_get_capture(be);
} }
static void axg_tdmin_enable(struct regmap *map) static void axg_tdmin_enable(struct regmap *map)
......
...@@ -81,7 +81,7 @@ axg_tdmout_get_tdm_stream(struct snd_soc_dapm_widget *w) ...@@ -81,7 +81,7 @@ axg_tdmout_get_tdm_stream(struct snd_soc_dapm_widget *w)
if (!be) if (!be)
return NULL; return NULL;
return be->playback_dma_data; return snd_soc_dai_dma_data_get_playback(be);
} }
static void axg_tdmout_enable(struct regmap *map) static void axg_tdmout_enable(struct regmap *map)
......
...@@ -39,13 +39,13 @@ meson_codec_glue_get_input(struct snd_soc_dapm_widget *w) ...@@ -39,13 +39,13 @@ meson_codec_glue_get_input(struct snd_soc_dapm_widget *w)
static void meson_codec_glue_input_set_data(struct snd_soc_dai *dai, static void meson_codec_glue_input_set_data(struct snd_soc_dai *dai,
struct meson_codec_glue_input *data) struct meson_codec_glue_input *data)
{ {
dai->playback_dma_data = data; snd_soc_dai_dma_data_set_playback(dai, data);
} }
struct meson_codec_glue_input * struct meson_codec_glue_input *
meson_codec_glue_input_get_data(struct snd_soc_dai *dai) meson_codec_glue_input_get_data(struct snd_soc_dai *dai)
{ {
return dai->playback_dma_data; return snd_soc_dai_dma_data_get_playback(dai);
} }
EXPORT_SYMBOL_GPL(meson_codec_glue_input_get_data); EXPORT_SYMBOL_GPL(meson_codec_glue_input_get_data);
...@@ -99,8 +99,8 @@ int meson_codec_glue_output_startup(struct snd_pcm_substream *substream, ...@@ -99,8 +99,8 @@ int meson_codec_glue_output_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
struct meson_codec_glue_input *in_data = struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget_capture(dai);
meson_codec_glue_output_get_input_data(dai->capture_widget); struct meson_codec_glue_input *in_data = meson_codec_glue_output_get_input_data(w);
if (!in_data) if (!in_data)
return -ENODEV; return -ENODEV;
......
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