Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

static int mxcfb_map_video_memory ( struct fb_info *  fbi  )  [static]

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.

Parameters:
fbi framebuffer information pointer
Returns:
Error code indicating success or failure

Definition at line 865 of file mxcfb_epson.c.

References mxcfb_info::alloc_size, mxcfb_info::alloc_start_paddr, and mxcfb_info::alloc_start_vaddr.

{
      u32 msb;
      u32 offset;
      struct mxcfb_info *mxcfbi = fbi->par;

      fbi->fix.smem_len = fbi->var.xres_virtual * fbi->var.yres_virtual * 4;

      // Set size to power of 2.
      msb = fls(fbi->fix.smem_len);
      if (!(fbi->fix.smem_len & ((1UL << msb) - 1)))
            msb--;            // Already aligned to power 2
      if (msb < 11)
            msb = 11;
      mxcfbi->alloc_size = (1UL << msb) * 2;

      mxcfbi->alloc_start_vaddr = dma_alloc_coherent(fbi->device,
                                           mxcfbi->alloc_size,
                                           &mxcfbi->
                                           alloc_start_paddr,
                                           GFP_KERNEL | GFP_DMA);

      if (mxcfbi->alloc_start_vaddr == 0) {
            dev_err(fbi->device, "Unable to allocate framebuffer memory\n");
            return -ENOMEM;
      }
      dev_dbg(fbi->device, "allocated fb memory @ paddr=0x%08X, size=%d.\n",
            (uint32_t) mxcfbi->alloc_start_paddr, mxcfbi->alloc_size);

      offset =
          ((mxcfbi->alloc_size / 2) - 1) & ~((mxcfbi->alloc_size / 2) - 1);
      fbi->fix.smem_start = mxcfbi->alloc_start_paddr + offset;
      dev_dbg(fbi->device, "aligned fb start @ paddr=0x%08lX, size=%u.\n",
            fbi->fix.smem_start, fbi->fix.smem_len);

      fbi->screen_base = mxcfbi->alloc_start_vaddr + offset;

      /* Clear the screen */
      memset(fbi->screen_base, 0, fbi->fix.smem_len);
      return 0;
}


Generated by  Doxygen 1.6.0   Back to index