{
struct snd_pcm_runtime *runtime = substream->runtime;
struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
-- - int ret;
++ + struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai;
++ + struct lpass_data *drvdata =
++ + snd_soc_platform_get_drvdata(soc_runtime->platform);
++ + struct lpass_variant *v = drvdata->variant;
++ + int ret, dma_ch, dir = substream->stream;
++ + struct lpass_pcm_data *data;
++ +
++ + data = devm_kzalloc(soc_runtime->dev, sizeof(*data), GFP_KERNEL);
++ + if (!data)
++ + return -ENOMEM;
++ +
++ + data->i2s_port = cpu_dai->driver->id;
++ + runtime->private_data = data;
++ +
++++ dma_ch = 0;
++ + if (v->alloc_dma_channel)
++ + dma_ch = v->alloc_dma_channel(drvdata, dir);
++++ else
++++ dma_ch = 0;
++++
++ + if (dma_ch < 0)
++ + return dma_ch;
++ +
++ + drvdata->substream[dma_ch] = substream;
++ +
++ + ret = regmap_write(drvdata->lpaif_map,
++ + LPAIF_DMACTL_REG(v, dma_ch, dir), 0);
++ + if (ret) {
++ + dev_err(soc_runtime->dev,
++ + "%s() error writing to rdmactl reg: %d\n",
++ + __func__, ret);
++ + return ret;
++ + }
++ +
- if (dir == SNDRV_PCM_STREAM_PLAYBACK)
- data->rdma_ch = dma_ch;
- else
- data->wrdma_ch = dma_ch;
+++ + data->dma_ch = dma_ch;
snd_soc_set_runtime_hwparams(substream, &lpass_platform_pcm_hardware);
return 0;
}
- int dma_ch, dir = substream->stream;
++ +static int lpass_platform_pcmops_close(struct snd_pcm_substream *substream)
++ +{
++ + struct snd_pcm_runtime *runtime = substream->runtime;
++ + struct snd_soc_pcm_runtime *soc_runtime = substream->private_data;
++ + struct lpass_data *drvdata =
++ + snd_soc_platform_get_drvdata(soc_runtime->platform);
++ + struct lpass_variant *v = drvdata->variant;
++ + struct lpass_pcm_data *data;
-
- if (dir == SNDRV_PCM_STREAM_PLAYBACK)
- dma_ch = data->rdma_ch;
- else
- dma_ch = data->wrdma_ch;
-
- drvdata->substream[dma_ch] = NULL;
-
++ +
++ + data = runtime->private_data;
++ + v = drvdata->variant;
- v->free_dma_channel(drvdata, dma_ch);
+++ + drvdata->substream[data->dma_ch] = NULL;
++ + if (v->free_dma_channel)
+++ + v->free_dma_channel(drvdata, data->dma_ch);
++ +
++ + return 0;
++ +}
++ +
static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{