static int tegra_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct device *dev = rtd->platform->dev; struct tegra_runtime_data *prtd; int ret; if (rtd->dai_link->no_pcm) return 0; prtd = kzalloc(sizeof(struct tegra_runtime_data), GFP_KERNEL); if (prtd == NULL) return -ENOMEM; /* Set HW params now that initialization is complete */ snd_soc_set_runtime_hwparams(substream, &tegra_pcm_hardware); /* Ensure period size is multiple of 8 */ ret = snd_pcm_hw_constraint_step(substream->runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 0x8); if (ret) { dev_err(dev, "failed to set constraint %d\n", ret); kfree(prtd); return ret; } ret = snd_dmaengine_pcm_open_request_chan(substream, NULL, NULL); if (ret) { dev_err(dev, "dmaengine pcm open failed with err %d\n", ret); kfree(prtd); return ret; } snd_dmaengine_pcm_set_data(substream, prtd); return 0; }
static int omap_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_dmaengine_dai_dma_data *dma_data; int ret; snd_soc_set_runtime_hwparams(substream, &omap_pcm_hardware); dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); /* DT boot: filter_data is the DMA name */ if (rtd->cpu_dai->dev->of_node) { struct dma_chan *chan; chan = dma_request_slave_channel(rtd->cpu_dai->dev, dma_data->filter_data); ret = snd_dmaengine_pcm_open(substream, chan); } else { ret = snd_dmaengine_pcm_open_request_chan(substream, omap_dma_filter_fn, dma_data->filter_data); } return ret; }