参照元

説明

引数

返り値

参考

実装

static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
        struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform);
        const struct snd_dmaengine_pcm_config *config = pcm->config;
        struct device *dev = rtd->platform->dev;
        struct snd_dmaengine_dai_dma_data *dma_data;
        struct snd_pcm_substream *substream;
        size_t prealloc_buffer_size;
        size_t max_buffer_size;
        unsigned int i;
        int ret;
        if (config && config->prealloc_buffer_size) {
                prealloc_buffer_size = config->prealloc_buffer_size;
                max_buffer_size = config->pcm_hardware->buffer_bytes_max;
        } else {
                prealloc_buffer_size = 512 * 1024;
                max_buffer_size = SIZE_MAX;
        }

        for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) {
                substream = rtd->pcm->streams[i].substream;
                if (!substream)
                        continue;
                dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
                if (!pcm->chan[i] &&
                    (pcm->flags & SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME))
                        pcm->chan[i] = dma_request_slave_channel(dev,
                                dma_data->chan_name);
                if (!pcm->chan[i] && (pcm->flags & SND_DMAENGINE_PCM_FLAG_COMPAT)) {
                        pcm->chan[i] = dmaengine_pcm_compat_request_channel(rtd,
                                substream);
                }
                if (!pcm->chan[i]) {
                        dev_err(rtd->platform->dev,
                                "Missing dma channel for stream: %d\n", i);
                        return -EINVAL;
                }
                ret = snd_pcm_lib_preallocate_pages(substream,
                                SNDRV_DMA_TYPE_DEV_IRAM,
                                dmaengine_dma_dev(pcm, substream),
                                prealloc_buffer_size,
                                max_buffer_size);
                if (ret)
                        return ret;
                if (!dmaengine_pcm_can_report_residue(dev, pcm->chan[i]))
                        pcm->flags |= SND_DMAENGINE_PCM_FLAG_NO_RESIDUE;
        }

        return 0;
}

コメント


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-04-28 (木) 21:34:40