s3c2410fb_map_video_memory

来源:互联网 发布:代源码百度云 编辑:程序博客网 时间:2024/05/09 09:35

 

s3c2410fb_map_video_memory

/*

 * s3c2410fb_map_video_memory():

 *  Allocates the DRAM memory for the frame buffer.  This buffer is

 *  remapped into a non-cached, non-buffered, memory region to

 *  allow palette and pixel writes to occur without flushing the

 *  cache.  Once this area is remapped, all virtual memory

 *  access to the video memory should occur at the new region.

 */

static int __init s3c2410fb_map_video_memory(struct s3c2410fb_info *fbi)

{

    dprintk("map_video_memory(fbi=%p)\n", fbi);

    fbi->map_size = PAGE_ALIGN(fbi->fb->fix.smem_len + PAGE_SIZE); /*分配总数对齐*/

    fbi->map_cpu  = dma_alloc_writecombine(fbi->dev, fbi->map_size,

                          &fbi->map_dma, GFP_KERNEL);  /*分配DMA地址*/

    fbi->map_size = fbi->fb->fix.smem_len;

    if (fbi->map_cpu) {

        /* prevent initial garbage on screen */

        dprintk("map_video_memory: clear %p:%08x\n",

            fbi->map_cpu, fbi->map_size);

        memset(fbi->map_cpu, 0xf0, fbi->map_size);

        fbi->screen_dma    = fbi->map_dma;

        fbi->fb->screen_base   = fbi->map_cpu;

        fbi->fb->fix.smem_start  = fbi->screen_dma;

        dprintk("map_video_memory: dma=%08x cpu=%p size=%08x\n",

            fbi->map_dma, fbi->map_cpu, fbi->fb->fix.smem_len);

    }

     return fbi->map_cpu ? 0 : -ENOMEM;

}

这个函数分配完frame buffer地址后,设置好相关参数就返回了.