Skip to content

Commit bb6a40f

Browse files
tiwaibroonie
authored andcommitted
ASoC: kirkwood: Fix reference to PCM buffer address
The transition to the managed PCM buffers allowed the dynamically buffer allocation, while the driver code still assumes the fixed preallocation buffer and sets up the DMA stuff at the open call. This needs to be moved to hw_params after the buffer allocation and setup. Also, the reference to the buffer address has to be corrected to runtime->dma_addr. Fixes: b3c0ae7 ("ASoC: kirkwood: Use managed DMA buffer allocation") Cc: Lars-Peter Clausen <[email protected]> Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 827f316 commit bb6a40f

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

sound/soc/kirkwood/kirkwood-dma.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ static int kirkwood_dma_open(struct snd_soc_component *component,
104104
int err;
105105
struct snd_pcm_runtime *runtime = substream->runtime;
106106
struct kirkwood_dma_data *priv = kirkwood_priv(substream);
107-
const struct mbus_dram_target_info *dram;
108-
unsigned long addr;
109107

110108
snd_soc_set_runtime_hwparams(substream, &kirkwood_dma_snd_hw);
111109

@@ -142,20 +140,14 @@ static int kirkwood_dma_open(struct snd_soc_component *component,
142140
writel((unsigned int)-1, priv->io + KIRKWOOD_ERR_MASK);
143141
}
144142

145-
dram = mv_mbus_dram_info();
146-
addr = substream->dma_buffer.addr;
147143
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
148144
if (priv->substream_play)
149145
return -EBUSY;
150146
priv->substream_play = substream;
151-
kirkwood_dma_conf_mbus_windows(priv->io,
152-
KIRKWOOD_PLAYBACK_WIN, addr, dram);
153147
} else {
154148
if (priv->substream_rec)
155149
return -EBUSY;
156150
priv->substream_rec = substream;
157-
kirkwood_dma_conf_mbus_windows(priv->io,
158-
KIRKWOOD_RECORD_WIN, addr, dram);
159151
}
160152

161153
return 0;
@@ -182,6 +174,23 @@ static int kirkwood_dma_close(struct snd_soc_component *component,
182174
return 0;
183175
}
184176

177+
static int kirkwood_dma_hw_params(struct snd_soc_component *component,
178+
struct snd_pcm_substream *substream,
179+
struct snd_pcm_hw_params *params)
180+
{
181+
struct kirkwood_dma_data *priv = kirkwood_priv(substream);
182+
const struct mbus_dram_target_info *dram = mv_mbus_dram_info();
183+
unsigned long addr = substream->runtime->dma_addr;
184+
185+
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
186+
kirkwood_dma_conf_mbus_windows(priv->io,
187+
KIRKWOOD_PLAYBACK_WIN, addr, dram);
188+
else
189+
kirkwood_dma_conf_mbus_windows(priv->io,
190+
KIRKWOOD_RECORD_WIN, addr, dram);
191+
return 0;
192+
}
193+
185194
static int kirkwood_dma_prepare(struct snd_soc_component *component,
186195
struct snd_pcm_substream *substream)
187196
{
@@ -246,6 +255,7 @@ const struct snd_soc_component_driver kirkwood_soc_component = {
246255
.name = DRV_NAME,
247256
.open = kirkwood_dma_open,
248257
.close = kirkwood_dma_close,
258+
.hw_params = kirkwood_dma_hw_params,
249259
.prepare = kirkwood_dma_prepare,
250260
.pointer = kirkwood_dma_pointer,
251261
.pcm_construct = kirkwood_dma_new,

0 commit comments

Comments
 (0)