Skip to contentSkip to conversation

drm/exynos: Add exynos drm specific fb_mmap function

PATCH Superseded Prathyush K 1 participant 1 message Jul 9, 2012

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/exynos: Add exynos drm specific fb_mmap function

This patch adds a exynos drm specific implementation of fb_mmap which supports mapping a non-contiguous buffer to user space. This new function does not assume that the frame buffer is contiguous and calls dma_mmap_writecombine for mapping the buffer to user space. dma_mmap_writecombine will be able to map a contiguous buffer as well as non-contig buffer depending on whether an IOMMU mapping is created for drm or not.

---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_fbdev.c +16 -0
index d5586cc..b53e638 100644
@@ -46,8 +46,24 @@ struct exynos_drm_fbdev {
 	struct exynos_drm_gem_obj	*exynos_gem_obj;
 };
 
+static int exynos_drm_fb_mmap(struct fb_info *info,
+			      struct vm_area_struct *vma)
+{
+	if ((vma->vm_end - vma->vm_start) > info->fix.smem_len)
+		return -EINVAL;
+
+	vma->vm_pgoff = 0;
+	vma->vm_flags |= VM_IO | VM_RESERVED;
+	if (dma_mmap_writecombine(info->device, vma, info->screen_base,
+			info->fix.smem_start, vma->vm_end - vma->vm_start))
+		return -EAGAIN;
+
+	return 0;
+}
+
 static struct fb_ops exynos_drm_fb_ops = {
 	.owner		= THIS_MODULE,
+	.fb_mmap	= exynos_drm_fb_mmap,
 	.fb_fillrect	= cfb_fillrect,
 	.fb_copyarea	= cfb_copyarea,
 	.fb_imageblit	= cfb_imageblit,
Signature · 1 line
1.7.0.4