switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
ret = fsl_asrc_dma_prepare_and_submit(substream, component); if (ret) return ret;
dma_async_issue_pending(pair->dma_chan[IN]);
dma_async_issue_pending(pair->dma_chan[OUT]); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
dmaengine_terminate_async(pair->dma_chan[OUT]);
dmaengine_terminate_async(pair->dma_chan[IN]); break; default: return -EINVAL;
}
/* * With audio graph card, original cpu dai is changed to codec * device in backend, so if cpu dai is dummy device in backend, * get the codec dai device, which is the real hardware device * connected.
*/ if (!snd_soc_dai_is_dummy(dai_cpu))
dai = dai_cpu; else
dai = dai_codec;
if (!dma_params_be) {
dev_err(dev, "failed to get the substream of Back-End\n"); return -EINVAL;
}
/* Override dma_data of the Front-End and config its dmaengine */
dma_params_fe = snd_soc_dai_get_dma_data(snd_soc_rtd_to_cpu(rtd, 0), substream);
dma_params_fe->addr = asrc->paddr + asrc->get_fifo_addr(!dir, index);
dma_params_fe->maxburst = dma_params_be->maxburst;
pair->dma_chan[!dir] = asrc->get_dma_channel(pair, !dir); if (!pair->dma_chan[!dir]) {
dev_err(dev, "failed to request DMA channel\n"); return -EINVAL;
}
ret = snd_dmaengine_pcm_prepare_slave_config(substream, params, &config_fe); if (ret) {
dev_err(dev, "failed to prepare DMA config for Front-End\n"); return ret;
}
ret = dmaengine_slave_config(pair->dma_chan[!dir], &config_fe); if (ret) {
dev_err(dev, "failed to config DMA channel for Front-End\n"); return ret;
}
/* Request and config DMA channel for Back-End */
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
dma_cap_set(DMA_CYCLIC, mask);
/* * The Back-End device might have already requested a DMA channel, * so try to reuse it first, and then request a new one upon NULL.
*/
component_be = snd_soc_lookup_component_nolocked(dev_be, SND_DMAENGINE_PCM_DRV_NAME); if (component_be) {
be_chan = soc_component_to_pcm(component_be)->chan[substream->stream];
tmp_chan = be_chan;
} if (!tmp_chan) {
tmp_chan = dma_request_chan(dev_be, tx ? "tx" : "rx"); if (IS_ERR(tmp_chan)) {
dev_err(dev, "failed to request DMA channel for Back-End\n"); return -EINVAL;
}
}
/* * An EDMA DEV_TO_DEV channel is fixed and bound with DMA event of each * peripheral, unlike SDMA channel that is allocated dynamically. So no * need to configure dma_request and dma_request2, but get dma_chan of * Back-End device directly via dma_request_chan.
*/ if (!asrc->use_edma) { /* Get DMA request of Back-End */
tmp_data = tmp_chan->private;
pair->dma_data.dma_request = tmp_data->dma_request;
be_peripheral_type = tmp_data->peripheral_type; if (!be_chan)
dma_release_channel(tmp_chan);
of_dma_node = pair->dma_chan[!dir]->device->dev->of_node;
pair->dma_chan[dir] =
__dma_request_channel(&mask, filter, &pair->dma_data,
of_dma_node);
pair->req_dma_chan = true;
} else {
pair->dma_chan[dir] = tmp_chan; /* Do not flag to release if we are reusing the Back-End one */
pair->req_dma_chan = !be_chan;
}
if (!pair->dma_chan[dir]) {
dev_err(dev, "failed to request DMA channel for Back-End\n"); return -EINVAL;
}
ret = dmaengine_slave_config(pair->dma_chan[dir], &config_be); if (ret) {
dev_err(dev, "failed to config DMA channel for Back-End\n"); if (pair->req_dma_chan)
dma_release_channel(pair->dma_chan[dir]); return ret;
}
if (pair->dma_chan[!dir])
dma_release_channel(pair->dma_chan[!dir]);
/* release dev_to_dev chan if we aren't reusing the Back-End one */ if (pair->dma_chan[dir] && pair->req_dma_chan)
dma_release_channel(pair->dma_chan[dir]);
ret = snd_pcm_hw_constraint_integer(substream->runtime,
SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) {
dev_err(dev, "failed to set pcm hw params periods\n"); return ret;
}
pair = kzalloc(sizeof(*pair) + asrc->pair_priv_size, GFP_KERNEL); if (!pair) return -ENOMEM;
/* Request a dummy pair, which will be released later. * Request pair function needs channel num as input, for this * dummy pair, we just request "1" channel temporarily.
*/
ret = asrc->request_pair(1, pair); if (ret < 0) {
dev_err(dev, "failed to request asrc pair\n"); goto req_pair_err;
}
/* Request a dummy dma channel, which will be released later. */
tmp_chan = asrc->get_dma_channel(pair, dir); if (!tmp_chan) {
dev_err(dev, "failed to get dma channel\n");
ret = -EINVAL; goto dma_chan_err;
}
/* Refine the snd_imx_hardware according to caps of DMA. */
ret = snd_dmaengine_pcm_refine_runtime_hwparams(substream,
dma_data,
&snd_imx_hardware,
tmp_chan); if (ret < 0) {
dev_err(dev, "failed to refine runtime hwparams\n"); goto out;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.