Date:2011-09-18 15:05:00 (9 years 5 days ago)
Author:Maarten ter Huurne
Commit:2452f67a22b19aaea8c907f46ebf52fd346f1ae0
Message:MIPS: JZ4740: SLCD: Enable caching on mmap-ed frame buffer.

Override the mmap operation.
The implementation of mmap is based on that from the ps3fb driver.

Thanks to Lars-Peter Clausen for his help.
Files: drivers/video/jz4740_slcd_fb.c (3 diffs)

Change Details

drivers/video/jz4740_slcd_fb.c
240240{
241241    struct fb_info *fb = jzfb->fb;
242242    struct fb_videomode *mode = fb->mode;
243    __u32 bytes_per_line = fb->fix.line_length;
243    __u32 offset = fb->fix.line_length * fb->var.yoffset;
244    __u32 size = fb->fix.line_length * mode->yres;
244245
245    jz4740_dma_set_src_addr(jzfb->dma, jzfb->vidmem_phys +
246                       bytes_per_line * fb->var.yoffset);
246    /* Ensure that the data to be uploaded is in memory. */
247    dma_cache_sync(fb->device, jzfb->vidmem + offset, size,
248               DMA_TO_DEVICE);
249
250    jz4740_dma_set_src_addr(jzfb->dma, jzfb->vidmem_phys + offset);
247251    jz4740_dma_set_dst_addr(jzfb->dma,
248252                CPHYSADDR(jzfb->base + JZ_REG_SLCD_FIFO));
249    jz4740_dma_set_transfer_count(jzfb->dma, bytes_per_line * mode->yres);
253    jz4740_dma_set_transfer_count(jzfb->dma, size);
250254
251255    while (readb(jzfb->base + JZ_REG_SLCD_STATE) & SLCD_STATE_BUSY);
252256    writeb(readb(jzfb->base + JZ_REG_SLCD_CTRL) | SLCD_CTRL_DMA_EN,
...... 
508512    return 0;
509513}
510514
515static int jzfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
516{
517    const unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
518    const unsigned long size = vma->vm_end - vma->vm_start;
519
520    if (offset + size > info->fix.smem_len)
521        return -EINVAL;
522
523    if (remap_pfn_range(vma, vma->vm_start,
524                (info->fix.smem_start + offset) >> PAGE_SHIFT,
525                size, vma->vm_page_prot))
526        return -EAGAIN;
527
528    return 0;
529}
530
511531static int jzfb_alloc_devmem(struct jzfb *jzfb)
512532{
513533    int max_framesize = 0;
...... 
670690    .fb_copyarea = sys_copyarea,
671691    .fb_imageblit = sys_imageblit,
672692    .fb_ioctl = jzfb_ioctl,
693    .fb_mmap = jzfb_mmap,
673694};
674695
675696static int __devinit jzfb_probe(struct platform_device *pdev)

Archive Download the corresponding diff file



interactive