Ejemplo n.º 1
0
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_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;
}