Beispiel #1
0
static int imx_pcm_prepare(struct snd_pcm_substream *substream)
{
	struct snd_pcm_runtime *runtime = substream->runtime;
	struct mxc_runtime_data *prtd = runtime->private_data;
	int ret = 0, channel = 0;

	if (prtd->dma_alloc) {
		mxc_dma_free(prtd->dma_wchannel);
		prtd->dma_alloc = 0;
	}

	/* only allocate the DMA chn once */
	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
#if defined(CONFIG_MXC_ASRC) || defined(CONFIG_MXC_ASRC_MODULE)
		if (prtd->asrc_enable == 1) {
			struct dma_channel_info info;
			mxc_dma_requestbuf_t sdma_request;
			info.asrc.channs = runtime->channels;
			if (prtd->dma_asrc) {
				mxc_dma_free(prtd->dma_asrc);
				prtd->dma_asrc = 0;
			}
			memset(&sdma_request, 0, sizeof(mxc_dma_requestbuf_t));
			/* num_of_bytes can be set any value except for zero */
			sdma_request.num_of_bytes = 0x40;
			channel =
			    mxc_dma_request_ext(prtd->dma_ch,
						"ALSA TX SDMA", &info);

			mxc_dma_config(channel, &sdma_request,
				       1, MXC_DMA_MODE_WRITE);
			prtd->dma_asrc = channel;
			if (prtd->asrc_index == 0)
				prtd->dma_ch = MXC_DMA_ASRC_A_RX;
			else if (prtd->asrc_index == 1)
				prtd->dma_ch = MXC_DMA_ASRC_B_RX;
			else
				prtd->dma_ch = MXC_DMA_ASRC_C_RX;

			channel =
			    mxc_dma_request(MXC_DMA_ASRC_A_RX, "ALSA ASRC RX");
		} else
			channel = mxc_dma_request(prtd->dma_ch, "ALSA TX SDMA");
#else
		channel = mxc_dma_request(prtd->dma_ch, "ALSA TX SDMA");
#endif
		if (channel < 0) {
			pr_err("imx-pcm: error requesting \
					a write dma channel\n");
			return channel;
		}
		ret = mxc_dma_callback_set(channel, (mxc_dma_callback_t)
					   audio_dma_irq, (void *)substream);

	} else {
static void mxcmci_setup_dma(struct mxcmci_priv *priv)
{
	switch (priv->id) {
	case 0:
		priv->dma_1bit = mxc_dma_request(MXC_DMA_MMC1_WIDTH_1,
						 "MMC1-1bit");
		priv->dma_4bit = mxc_dma_request(MXC_DMA_MMC1_WIDTH_4,
						 "MMC1-4bit");
		break;
	case 1:
		priv->dma_1bit = mxc_dma_request(MXC_DMA_MMC2_WIDTH_1,
						 "MMC2-1bit");
		priv->dma_4bit = mxc_dma_request(MXC_DMA_MMC2_WIDTH_4,
						 "MMC2-4bit");
		break;
	default:
		dev_err(priv->host->parent, "unknown dma-id(%d)\n", priv->id);
		return;
	}

	mxc_dma_callback_set(priv->dma_1bit, mxcmci_dma_irq, (void *)priv);
	mxc_dma_callback_set(priv->dma_4bit, mxcmci_dma_irq, (void *)priv);
}