static int sun4i_pcm_prepare(struct snd_pcm_substream *substream) { struct sun4i_runtime_data *prtd = substream->runtime->private_data; struct dma_hw_conf codec_dma_conf; int ret = 0; if (!prtd->params) return 0; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK){ codec_dma_conf.drqsrc_type = DRQ_TYPE_SDRAM; codec_dma_conf.drqdst_type = DRQ_TYPE_IIS; codec_dma_conf.xfer_type = DMAXFER_D_BHALF_S_BHALF; codec_dma_conf.address_type = DMAADDRT_D_FIX_S_INC; codec_dma_conf.dir = SW_DMA_WDEV; codec_dma_conf.reload = 0; codec_dma_conf.hf_irq = SW_DMA_IRQ_FULL; codec_dma_conf.from = prtd->dma_start; codec_dma_conf.to = prtd->params->dma_addr; ret = sw_dma_config(prtd->params->channel, &codec_dma_conf); } /* flush the DMA channel */ sw_dma_ctrl(prtd->params->channel, SW_DMAOP_FLUSH); prtd->dma_loaded = 0; prtd->dma_pos = prtd->dma_start; /* enqueue dma buffers */ sun4i_pcm_enqueue(substream); return ret; }
static void sun4i_audio_buffdone(struct sw_dma_chan *channel, void *dev_id, int size, enum sw_dma_buffresult result) { struct sun4i_runtime_data *prtd; struct snd_pcm_substream *substream = dev_id; if (result == SW_RES_ABORT || result == SW_RES_ERR) return; prtd = substream->runtime->private_data; if (substream) { snd_pcm_period_elapsed(substream); } spin_lock(&prtd->lock); { prtd->dma_loaded--; sun4i_pcm_enqueue(substream); } spin_unlock(&prtd->lock); }
static int sun4i_pcm_prepare(struct snd_pcm_substream *substream) { struct sun4i_runtime_data *prtd = substream->runtime->private_data; struct dma_hw_conf codec_dma_conf; int ret = 0; // codec_dma_conf = kmalloc(sizeof(struct dma_hw_conf), GFP_KERNEL); // if (!codec_dma_conf) // { // ret = - ENOMEM; // return ret; // } if (!prtd->params) return 0; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK){ codec_dma_conf.drqsrc_type = DRQ_TYPE_SDRAM; codec_dma_conf.drqdst_type = DRQ_TYPE_HDMIAUDIO; codec_dma_conf.xfer_type = DMAXFER_D_BWORD_S_BWORD; codec_dma_conf.address_type = DMAADDRT_D_IO_S_LN; codec_dma_conf.dir = SW_DMA_WDEV; codec_dma_conf.reload = 0; codec_dma_conf.hf_irq = SW_DMA_IRQ_FULL; codec_dma_conf.from = prtd->dma_start; codec_dma_conf.to = prtd->params->dma_addr; codec_dma_conf.cmbk = 0x1F071F07; ret = sw_dma_config(prtd->params->channel, &codec_dma_conf); } /* flush the DMA channel */ sw_dma_ctrl(prtd->params->channel, SW_DMAOP_FLUSH); prtd->dma_loaded = 0; prtd->dma_pos = prtd->dma_start; /* enqueue dma buffers */ sun4i_pcm_enqueue(substream); return ret; }