diff mbox

drm/exynos: Add exynos drm specific fb_mmap function

Message ID 1352286490-10797-1-git-send-email-rahul.sharma@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rahul Sharma Nov. 7, 2012, 11:08 a.m. UTC
From: Prathyush K <prathyush.k@samsung.com>

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: Rahul Sharma <rahul.sharma@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_fbdev.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

Comments

Rahul Sharma Nov. 9, 2012, 11:45 a.m. UTC | #1
Hi All,

Please review the following patch.

regards,
Rahul Sharma

On Wed, Nov 7, 2012 at 4:38 PM, Rahul Sharma <rahul.sharma@samsung.com> wrote:
> From: Prathyush K <prathyush.k@samsung.com>
>
> 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: Rahul Sharma <rahul.sharma@samsung.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_fbdev.c |   26 ++++++++++++++++++++++++++
>  1 files changed, 26 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> index 67eb6ba..3939f7f 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> @@ -46,8 +46,34 @@ 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)
> +{
> +       DRM_DEBUG_KMS("%s\n", __func__);
> +
> +       if (!vma || !info) {
> +               DRM_ERROR("invalid arguments vma 0x%x, info 0x%x.\n",
> +                               (unsigned int)vma, (unsigned int)info);
> +               return -EINVAL;
> +       }
> +
> +       if (!info->screen_base || info->screen_size == 0) {
> +               DRM_ERROR("invalid screen information.\n");
> +               return -EINVAL;
> +       }
> +
> +       vma->vm_pgoff = 0;
> +       vma->vm_flags |= VM_IO;
> +       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,
> --
> 1.7.0.4
>
Inki Dae Nov. 9, 2012, 1:38 p.m. UTC | #2
sorry for being late.

2012/11/7 Rahul Sharma <rahul.sharma@samsung.com>

> From: Prathyush K <prathyush.k@samsung.com>
>
> 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: Rahul Sharma <rahul.sharma@samsung.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_fbdev.c |   26
> ++++++++++++++++++++++++++
>  1 files changed, 26 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> index 67eb6ba..3939f7f 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
> @@ -46,8 +46,34 @@ 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)
> +{
> +       DRM_DEBUG_KMS("%s\n", __func__);
> +
> +       if (!vma || !info) {
> +               DRM_ERROR("invalid arguments vma 0x%x, info 0x%x.\n",
> +                               (unsigned int)vma, (unsigned int)info);
> +               return -EINVAL;
> +       }
> +
> +       if (!info->screen_base || info->screen_size == 0) {
> +               DRM_ERROR("invalid screen information.\n");
> +               return -EINVAL;
> +       }
> +
> +       vma->vm_pgoff = 0;
> +       vma->vm_flags |= VM_IO;
> +       if (dma_mmap_writecombine(info->device, vma, info->screen_base,
> +                       info->fix.smem_start, vma->vm_end - vma->vm_start))
>

fix.smem_start should have physical address. Please see the below comment
of framebuffer header,
        struct  fb_fix_screeninfo {
                ...
                unsigned long smem_start;            /* Start of frame
buffer mem */
                                                                       /*
(physical address) */

For this, I posted fixup patch so smem_start has physical address always.

Thanks,
Inki Dae


> +               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,
> --
> 1.7.0.4
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
index 67eb6ba..3939f7f 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c
@@ -46,8 +46,34 @@  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)
+{
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (!vma || !info) {
+		DRM_ERROR("invalid arguments vma 0x%x, info 0x%x.\n",
+				(unsigned int)vma, (unsigned int)info);
+		return -EINVAL;
+	}
+
+	if (!info->screen_base || info->screen_size == 0) {
+		DRM_ERROR("invalid screen information.\n");
+		return -EINVAL;
+	}
+
+	vma->vm_pgoff = 0;
+	vma->vm_flags |= VM_IO;
+	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,