aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrathyush K <prathyush.k@samsung.com>2012-11-19 03:25:28 -0500
committerInki Dae <inki.dae@samsung.com>2012-12-05 00:39:20 -0500
commitdd265850f10a16e4525ed002f0173a1acd8c8876 (patch)
tree40273609dda2a2bb854d71070e8743454f17a401
parent1daa892c1df5c329375d791ca169db22f18e5c28 (diff)
drm/exynos: add exynos drm specific fb_mmap function
Changelog v3: Passing the actual buffer size instead of vm_size to dma_mmap_attrs. Changelog v2: Extracting the private data from fb_info structure to obtain the exynos gem buffer structure. Now, dma address is obtained from the exynos gem buffer structure and not from smem_start. Also calling dma_mmap_attrs (instead of dma_mmap_writecombine) with the same attributes used during allocation. Changelog v1: 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. Signed-off-by: Prathyush K <prathyush.k@samsung.com> Signed-off-by: Inki Dae <inki.dae@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fbdev.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index e7466c4414cb..151c4c9c50c7 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -46,8 +46,38 @@ struct exynos_drm_fbdev {
46 struct exynos_drm_gem_obj *exynos_gem_obj; 46 struct exynos_drm_gem_obj *exynos_gem_obj;
47}; 47};
48 48
49static int exynos_drm_fb_mmap(struct fb_info *info,
50 struct vm_area_struct *vma)
51{
52 struct drm_fb_helper *helper = info->par;
53 struct exynos_drm_fbdev *exynos_fbd = to_exynos_fbdev(helper);
54 struct exynos_drm_gem_obj *exynos_gem_obj = exynos_fbd->exynos_gem_obj;
55 struct exynos_drm_gem_buf *buffer = exynos_gem_obj->buffer;
56 unsigned long vm_size;
57 int ret;
58
59 DRM_DEBUG_KMS("%s\n", __func__);
60
61 vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
62
63 vm_size = vma->vm_end - vma->vm_start;
64
65 if (vm_size > buffer->size)
66 return -EINVAL;
67
68 ret = dma_mmap_attrs(helper->dev->dev, vma, buffer->kvaddr,
69 buffer->dma_addr, buffer->size, &buffer->dma_attrs);
70 if (ret < 0) {
71 DRM_ERROR("failed to mmap.\n");
72 return ret;
73 }
74
75 return 0;
76}
77
49static struct fb_ops exynos_drm_fb_ops = { 78static struct fb_ops exynos_drm_fb_ops = {
50 .owner = THIS_MODULE, 79 .owner = THIS_MODULE,
80 .fb_mmap = exynos_drm_fb_mmap,
51 .fb_fillrect = cfb_fillrect, 81 .fb_fillrect = cfb_fillrect,
52 .fb_copyarea = cfb_copyarea, 82 .fb_copyarea = cfb_copyarea,
53 .fb_imageblit = cfb_imageblit, 83 .fb_imageblit = cfb_imageblit,