static int mtk_pcm_fmtx_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_dma_buffer *dma_buf = &substream->dma_buffer; int ret = 0; PRINTK_AUD_FMTX("mtk_pcm_fmtx_hw_params \n"); if (fake_buffer) { /* runtime->dma_bytes has to be set manually to allow mmap */ substream->runtime->dma_bytes = params_buffer_bytes(hw_params); // here to allcoate sram to hardware --------------------------- AudDrv_Allocate_mem_Buffer(mDev, Soc_Aud_Digital_Block_MEM_DL1, substream->runtime->dma_bytes); substream->runtime->dma_area = (unsigned char *)Get_Afe_SramBase_Pointer(); substream->runtime->dma_addr = AFE_INTERNAL_SRAM_PHY_BASE; // ------------------------------------------------------- PRINTK_AUD_FMTX("1 dma_bytes = %d dma_area = %p dma_addr = 0x%x\n", substream->runtime->dma_bytes, substream->runtime->dma_area, substream->runtime->dma_addr); return 0; } else { dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; dma_buf->dev.dev = substream->pcm->card->dev; dma_buf->private_data = NULL; ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } PRINTK_AUD_FMTX("2 dma_bytes = %d dma_area = %p dma_addr = 0x%x\n", substream->runtime->dma_bytes, substream->runtime->dma_area, substream->runtime->dma_addr); return ret; }
static int mtk_pcm_I2S0dl1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { int ret = 0; substream->runtime->dma_bytes = params_buffer_bytes(hw_params); if(mPlaybackSramState == SRAM_STATE_PLAYBACKFULL) { //substream->runtime->dma_bytes = AFE_INTERNAL_SRAM_SIZE; substream->runtime->dma_area = (unsigned char *)Get_Afe_SramBase_Pointer(); substream->runtime->dma_addr = AFE_INTERNAL_SRAM_PHY_BASE; AudDrv_Allocate_DL1_Buffer( substream->runtime->dma_bytes); } else { substream->runtime->dma_bytes = params_buffer_bytes(hw_params); substream->runtime->dma_area = Dl1_Playback_dma_buf->area; substream->runtime->dma_addr = Dl1_Playback_dma_buf->addr; SetDL1Buffer(substream, hw_params); } // ------------------------------------------------------- pr_debug("dma_bytes = %d dma_area = %p dma_addr = 0x%x\n", substream->runtime->dma_bytes, substream->runtime->dma_area, substream->runtime->dma_addr); return ret; }
static int mtk_pcm_fmtx_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { int ret = 0; substream->runtime->dma_bytes = params_buffer_bytes(hw_params); if (mPlaybackSramState == SRAM_STATE_PLAYBACKFULL) { //substream->runtime->dma_bytes = AFE_INTERNAL_SRAM_SIZE; substream->runtime->dma_area = (unsigned char *)Get_Afe_SramBase_Pointer(); substream->runtime->dma_addr = AFE_INTERNAL_SRAM_PHY_BASE; AudDrv_Allocate_DL1_Buffer(mDev, substream->runtime->dma_bytes); } else { substream->runtime->dma_bytes = params_buffer_bytes(hw_params); substream->runtime->dma_area = FMTX_Playback_dma_buf->area; substream->runtime->dma_addr = FMTX_Playback_dma_buf->addr; SetFMTXBuffer(substream, hw_params); } // ------------------------------------------------------- printk("1 dma_bytes = %zu dma_area = %p dma_addr = 0x%lx\n", substream->runtime->dma_bytes, substream->runtime->dma_area, (long)substream->runtime->dma_addr); return ret; }
static int mtk_pcm_dl1_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { //struct snd_dma_buffer *dma_buf = &substream->dma_buffer; int ret = 0; PRINTK_AUDDRV("mtk_pcm_dl1_params \n"); /* runtime->dma_bytes has to be set manually to allow mmap */ substream->runtime->dma_bytes = params_buffer_bytes(hw_params); if (mPlaybackSramState == SRAM_STATE_PLAYBACKFULL) { //substream->runtime->dma_bytes = AFE_INTERNAL_SRAM_SIZE; substream->runtime->dma_area = (unsigned char *)Get_Afe_SramBase_Pointer(); substream->runtime->dma_addr = AFE_INTERNAL_SRAM_PHY_BASE; AudDrv_Allocate_DL1_Buffer(mDev, substream->runtime->dma_bytes); } else { substream->runtime->dma_bytes = params_buffer_bytes(hw_params); substream->runtime->dma_area = Dl1_Playback_dma_buf->area; substream->runtime->dma_addr = Dl1_Playback_dma_buf->addr; SetDL1Buffer(substream, hw_params); } PRINTK_AUDDRV("dma_bytes = %zu dma_area = %p dma_addr = 0x%lx\n", substream->runtime->dma_bytes, substream->runtime->dma_area, (long)substream->runtime->dma_addr); return ret; }
static int mtk_pcm_I2S0dl1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { int ret = 0; substream->runtime->dma_bytes = params_buffer_bytes(hw_params); //printk("mtk_pcm_hw_params dma_bytes = %d\n",substream->runtime->dma_bytes); #if 1 if (mPlaybackSramState == SRAM_STATE_PLAYBACKFULL) { //substream->runtime->dma_bytes = AFE_INTERNAL_SRAM_SIZE; substream->runtime->dma_area = (unsigned char *)Get_Afe_SramBase_Pointer(); substream->runtime->dma_addr = AFE_INTERNAL_SRAM_PHY_BASE; AudDrv_Allocate_DL1_Buffer(mDev, substream->runtime->dma_bytes); } else { substream->runtime->dma_bytes = params_buffer_bytes(hw_params); substream->runtime->dma_area = Dl1_Playback_dma_buf->area; substream->runtime->dma_addr = Dl1_Playback_dma_buf->addr; SetDL1Buffer(substream, hw_params); } #else //old // here to allcoate sram to hardware --------------------------- AudDrv_Allocate_mem_Buffer(Soc_Aud_Digital_Block_MEM_DL1, substream->runtime->dma_bytes); #ifdef AUDIO_MEMORY_SRAM //substream->runtime->dma_bytes = AFE_INTERNAL_SRAM_SIZE; substream->runtime->dma_area = (unsigned char *)Get_Afe_SramBase_Pointer(); substream->runtime->dma_addr = AFE_INTERNAL_SRAM_PHY_BASE; #else pI2S0dl1MemControl = Get_Mem_ControlT(Soc_Aud_Digital_Block_MEM_DL1); Afe_Block = &pI2S0dl1MemControl->rBlock;; substream->runtime->dma_area = (unsigned char *)Afe_Block->pucVirtBufAddr; substream->runtime->dma_addr = Afe_Block->pucPhysBufAddr; #endif // ------------------------------------------------------- #endif printk("1 dma_bytes = %zu dma_area = %p dma_addr = 0x%lx\n", substream->runtime->dma_bytes, substream->runtime->dma_area, (long)substream->runtime->dma_addr); return ret; }
static int mtk_pcm_dl1bt_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { int ret = 0; PRINTK_AUDDRV("mtk_pcm_dl1bt_hw_params\n"); /* runtime->dma_bytes has to be set manually to allow mmap */ substream->runtime->dma_bytes = params_buffer_bytes(hw_params); /* here to allcoate sram to hardware --------------------------- */ AudDrv_Allocate_mem_Buffer(mDev, Soc_Aud_Digital_Block_MEM_DL1, substream->runtime->dma_bytes); /* substream->runtime->dma_bytes = AFE_INTERNAL_SRAM_SIZE; */ substream->runtime->dma_area = (unsigned char *)Get_Afe_SramBase_Pointer(); substream->runtime->dma_addr = AFE_INTERNAL_SRAM_PHY_BASE; PRINTK_AUDDRV(" dma_bytes = %zu dma_area = %p dma_addr = 0x%lx\n", substream->runtime->dma_bytes, substream->runtime->dma_area, (long)substream->runtime->dma_addr); return ret; }
static int mtk_pcm_hdmi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_dma_buffer *dma_buf = &substream->dma_buffer; int ret = 0; pr_debug("mtk_pcm_hdmi_hw_params\n"); dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; dma_buf->dev.dev = substream->pcm->card->dev; dma_buf->private_data = NULL; if (fake_buffer) { PRINTK_AUD_HDMI("[mtk_pcm_hdmi_hw_params] HDMI_dma_buf->area\n"); #ifdef _NO_SRAM_USAGE_ runtime->dma_area = HDMI_dma_buf->area; runtime->dma_addr = HDMI_dma_buf->addr; /* runtime->dma_bytes = HDMI_dma_buf->bytes; */ /* runtime->buffer_size = HDMI_dma_buf->bytes; */ runtime->dma_bytes = params_buffer_bytes(hw_params); runtime->buffer_size = runtime->dma_bytes; #else runtime->dma_area = (unsigned char *)Get_Afe_SramBase_Pointer(); runtime->dma_addr = AFE_INTERNAL_SRAM_PHY_BASE; runtime->dma_bytes = params_buffer_bytes(hw_params); runtime->buffer_size = runtime->dma_bytes; #endif } else { PRINTK_AUD_HDMI("[mtk_pcm_hdmi_hw_params] snd_pcm_lib_malloc_pages\n"); ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } PRINTK_AUD_HDMI("%s, dma_bytes = %zu, dma_area = %p, dma_addr = 0x%lx\n", __func__, substream->runtime->dma_bytes, substream->runtime->dma_area, (long)substream->runtime->dma_addr); SetHDMIBuffer(substream, hw_params); return ret; }
static int mtk_capture_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_dma_buffer *dma_buf = &substream->dma_buffer; int ret = 0; printk("mtk_capture_pcm_hw_params \n"); dma_buf->dev.type = SNDRV_DMA_TYPE_DEV; dma_buf->dev.dev = substream->pcm->card->dev; dma_buf->private_data = NULL; if (mCaptureUseSram == true) { runtime->dma_bytes = params_buffer_bytes(hw_params); printk("mtk_capture_pcm_hw_params mCaptureUseSram dma_bytes = %zu \n", runtime->dma_bytes); substream->runtime->dma_area = (unsigned char *)Get_Afe_SramBase_Pointer(); substream->runtime->dma_addr = Get_Afe_Sram_Phys_Addr(); } else if (Capture_dma_buf->area) { printk("Capture_dma_buf = %p Capture_dma_buf->area = %p apture_dma_buf->addr = 0x%lx\n", Capture_dma_buf, Capture_dma_buf->area, (long) Capture_dma_buf->addr); runtime->dma_bytes = params_buffer_bytes(hw_params); runtime->dma_area = Capture_dma_buf->area; runtime->dma_addr = Capture_dma_buf->addr; } else { printk("mtk_capture_pcm_hw_params snd_pcm_lib_malloc_pages\n"); ret = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); } SetVULBuffer(substream, hw_params); printk("dma_bytes = %zu dma_area = %p dma_addr = 0x%lx\n", substream->runtime->dma_bytes, substream->runtime->dma_area, (long)substream->runtime->dma_addr); return ret; }