static int sun7i_pcm_prepare(struct snd_pcm_substream *substream) { struct sun7i_runtime_data *prtd = substream->runtime->private_data; dma_config_t spdif_dma_conf; int ret = 0; if (!prtd->params) return 0; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK){ //spdif_dma_conf.drqsrc_type = DRQ_TYPE_SDRAM; //spdif_dma_conf.drqdst_type = DRQ_TYPE_SPDIF; /* config para */ memset(&spdif_dma_conf, 0, sizeof(spdif_dma_conf)); spdif_dma_conf.xfer_type.src_data_width = DATA_WIDTH_16BIT; spdif_dma_conf.xfer_type.src_bst_len = DATA_BRST_4; spdif_dma_conf.xfer_type.dst_data_width = DATA_WIDTH_16BIT; spdif_dma_conf.xfer_type.dst_bst_len = DATA_BRST_4; spdif_dma_conf.address_type.src_addr_mode = NDMA_ADDR_INCREMENT; spdif_dma_conf.address_type.dst_addr_mode = NDMA_ADDR_NOCHANGE; if (substream->runtime->channels== 4) { printk("%s, line:%d\n", __func__, __LINE__); spdif_dma_conf.bconti_mode = true; spdif_dma_conf.irq_spt = CHAN_IRQ_FD|CHAN_IRQ_HD; strcpy(substream->pcm->card->id, "sndspdifraw"); printk("%s, line:%d, substream->pcm->card->id:%s\n", __func__, __LINE__, substream->pcm->card->id); } else { printk("%s, line:%d\n", __func__, __LINE__); spdif_dma_conf.bconti_mode = false; spdif_dma_conf.irq_spt = CHAN_IRQ_FD; strcpy(substream->pcm->card->id, "sndspdif"); } spdif_dma_conf.src_drq_type = N_SRC_SDRAM; spdif_dma_conf.dst_drq_type = N_DST_SPDIF_TX;//DRQDST_SPDIFTX; if (0 != sw_dma_config(prtd->dma_hdl, &spdif_dma_conf)) { printk("err:%s,line:%d\n", __func__, __LINE__); return -EINVAL; } } else { return -EINVAL; } /* 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 */ sun7i_pcm_enqueue(substream); return ret; }
static int sun7i_pcm_prepare(struct snd_pcm_substream *substream) { struct sun7i_runtime_data *prtd = substream->runtime->private_data; dma_config_t codec_dma_conf; int ret = 0; //printk("pcm:::%s,line:%d\n", __func__, __LINE__); if (!prtd->params) return 0; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK){ memset(&codec_dma_conf, 0, sizeof(codec_dma_conf)); codec_dma_conf.xfer_type.src_data_width = DATA_WIDTH_32BIT; codec_dma_conf.xfer_type.src_bst_len = DATA_BRST_4; codec_dma_conf.xfer_type.dst_data_width = DATA_WIDTH_32BIT; codec_dma_conf.xfer_type.dst_bst_len = DATA_BRST_4; codec_dma_conf.address_type.src_addr_mode = DDMA_ADDR_LINEAR; codec_dma_conf.address_type.dst_addr_mode = DDMA_ADDR_IO; codec_dma_conf.src_drq_type = D_SRC_SDRAM; codec_dma_conf.dst_drq_type = D_DST_HDMI_AUD; codec_dma_conf.bconti_mode = false; codec_dma_conf.irq_spt = CHAN_IRQ_FD; if(0 != sw_dma_config(prtd->dma_hdl, &codec_dma_conf)) { printk("err:%s,line:%d\n", __func__, __LINE__); return -EINVAL; return -EINVAL; } /* dma_para_t para; para.src_blk_sz = 0; para.src_wait_cyc = 0; para.dst_blk_sz = 0; para.dst_wait_cyc = 0;*/ u32 tmp = 0x1F071F07; if(0 != sw_dma_ctl(prtd->dma_hdl, DMA_OP_SET_PARA_REG, &tmp)) { return -EINVAL; } }else{ return -EINVAL; } /* 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 */ sun7i_pcm_enqueue(substream); return ret; }
static void sun7i_audio_buffdone(dma_hdl_t dma_hdl, void *parg) { struct sun7i_runtime_data *prtd; struct snd_pcm_substream *substream = parg; prtd = substream->runtime->private_data; if (substream) { snd_pcm_period_elapsed(substream); } spin_lock(&prtd->lock); { prtd->dma_loaded--; sun7i_pcm_enqueue(substream); } spin_unlock(&prtd->lock); }
static void sun7i_audio_play_buffdone(dma_hdl_t dma_hdl, void *parg) { struct sun7i_playback_runtime_data *play_prtd; struct snd_pcm_substream *substream = parg; /*pr_info("sun7i_i2sdma.c::func:%s(line:%d)\n",__func__,__LINE__);*/ play_prtd = substream->runtime->private_data; if ((substream) && (play_prtd)) { snd_pcm_period_elapsed(substream); } spin_lock(&play_prtd->lock); { play_prtd->dma_loaded--; sun7i_pcm_enqueue(substream); } spin_unlock(&play_prtd->lock); }
static void sun7i_audio_capture_buffdone(dma_hdl_t dma_hdl, void *parg) { struct sun7i_capture_runtime_data *capture_prtd; struct snd_pcm_substream *substream = parg; /*pr_info("CAPTUR:sun7i_i2sdma.c::func:%s(line:%d)\n",__func__,__LINE__);*/ capture_prtd = substream->runtime->private_data; if (substream && capture_prtd) { snd_pcm_period_elapsed(substream); } spin_lock(&capture_prtd->lock); { capture_prtd->dma_loaded--; sun7i_pcm_enqueue(substream); } spin_unlock(&capture_prtd->lock); }
static int sun7i_pcm_prepare(struct snd_pcm_substream *substream) { dma_config_t codec_play_dma_conf; dma_config_t codec_capture_dma_conf; int play_ret = 0, capture_ret = 0; struct sun7i_playback_runtime_data *play_prtd = NULL; struct sun7i_capture_runtime_data *capture_prtd = NULL; /*pr_info("sun7i_i2sdma.c::substream->stream%d)\n",substream->stream);*/ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { play_prtd = substream->runtime->private_data; if (!play_prtd->params) { return 0; } /*pr_info("play:sun7i_i2sdma.c::func:%s(line:%d)\n",__func__,__LINE__);*/ memset(&codec_play_dma_conf, 0, sizeof(codec_play_dma_conf)); codec_play_dma_conf.xfer_type.src_data_width = DATA_WIDTH_16BIT; codec_play_dma_conf.xfer_type.src_bst_len = DATA_BRST_1; codec_play_dma_conf.xfer_type.dst_data_width = DATA_WIDTH_16BIT; codec_play_dma_conf.xfer_type.dst_bst_len = DATA_BRST_1; codec_play_dma_conf.address_type.src_addr_mode = NDMA_ADDR_INCREMENT; codec_play_dma_conf.address_type.dst_addr_mode = NDMA_ADDR_NOCHANGE; codec_play_dma_conf.src_drq_type = N_SRC_SDRAM; codec_play_dma_conf.dst_drq_type = N_DST_IIS0_TX; codec_play_dma_conf.bconti_mode = false; codec_play_dma_conf.irq_spt = CHAN_IRQ_FD; if(0 !=(play_ret = sw_dma_config(play_prtd->dma_hdl, &codec_play_dma_conf))) { printk("err:%s,line:%d\n", __func__, __LINE__); return -EINVAL; } /* flush the DMA channel */ play_prtd->dma_loaded = 0; play_prtd->dma_pos = play_prtd->dma_start; /* enqueue dma buffers */ sun7i_pcm_enqueue(substream); return play_ret; } else { capture_prtd = substream->runtime->private_data; if (!capture_prtd->params) { return 0; } /*pr_info("CAPTUR:sun7i_i2sdma.c::func:%s(line:%d)\n",__func__,__LINE__);*/ memset(&codec_capture_dma_conf, 0, sizeof(codec_capture_dma_conf)); codec_capture_dma_conf.xfer_type.src_data_width = DATA_WIDTH_16BIT; codec_capture_dma_conf.xfer_type.src_bst_len = DATA_BRST_1; codec_capture_dma_conf.xfer_type.dst_data_width = DATA_WIDTH_16BIT; codec_capture_dma_conf.xfer_type.dst_bst_len = DATA_BRST_1; codec_capture_dma_conf.address_type.src_addr_mode = NDMA_ADDR_NOCHANGE; codec_capture_dma_conf.address_type.dst_addr_mode = NDMA_ADDR_INCREMENT; codec_capture_dma_conf.src_drq_type = N_SRC_IIS0_RX; codec_capture_dma_conf.dst_drq_type = N_DST_SDRAM; codec_capture_dma_conf.bconti_mode = false; codec_capture_dma_conf.irq_spt = CHAN_IRQ_FD; //capture_ret = sw_dma_config(capture_dma_config->dma_hdl, &capture_dma_config); if(0!=(capture_ret = sw_dma_config(capture_prtd->dma_hdl, &codec_capture_dma_conf))){ printk("err:%s,line:%d\n", __func__, __LINE__); return -EINVAL; } /* flush the DMA channel */ capture_prtd->dma_loaded = 0; capture_prtd->dma_pos = capture_prtd->dma_start; /* enqueue dma buffers */ sun7i_pcm_enqueue(substream); return capture_ret; } }