The ioctl DRM_EXYNOS_GEM_MAP_OFFSET and DRM_EXYNOS_GEM_MMAP are removed from the linux kernel. This patch modifies libdrm and libkms to use drm generic ioctls instead of the removed ioctls.
Signed-off-by: Hyungwon Hwang human.hwang@samsung.com Signed-off-by: Inki Dae inki.dae@samsung.com --- exynos/exynos_drm.c | 24 +++++++++++++----------- libkms/exynos.c | 7 ++++--- 2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/exynos/exynos_drm.c b/exynos/exynos_drm.c index 4c7dd13..4cb6a6d 100644 --- a/exynos/exynos_drm.c +++ b/exynos/exynos_drm.c @@ -283,20 +283,22 @@ drm_public void *exynos_bo_map(struct exynos_bo *bo) { if (!bo->vaddr) { struct exynos_device *dev = bo->dev; - struct drm_exynos_gem_mmap req = { - .handle = bo->handle, - .size = bo->size, - }; + struct drm_mode_map_dumb arg; + void *map = NULL; int ret;
- ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_MMAP, &req); - if (ret) { - fprintf(stderr, "failed to mmap[%s].\n", - strerror(errno)); - return NULL; - } + memset(&arg, 0, sizeof(arg)); + arg.handle = bo->handle; + + ret = drmIoctl(dev->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg); + if (ret) + return ret;
- bo->vaddr = (void *)(uintptr_t)req.mapped; + map = drm_mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, + dev->fd, arg.offset); + + if (map == MAP_FAILED) + return NULL; }
return bo->vaddr; diff --git a/libkms/exynos.c b/libkms/exynos.c index 92e329c..1123482 100644 --- a/libkms/exynos.c +++ b/libkms/exynos.c @@ -25,6 +25,7 @@ #include <sys/ioctl.h> #include "xf86drm.h"
+#include "libdrm.h" #include "exynos_drm.h"
struct exynos_bo @@ -124,7 +125,7 @@ static int exynos_bo_map(struct kms_bo *_bo, void **out) { struct exynos_bo *bo = (struct exynos_bo *)_bo; - struct drm_exynos_gem_map_off arg; + struct drm_mode_map_dumb arg; void *map = NULL; int ret;
@@ -137,11 +138,11 @@ exynos_bo_map(struct kms_bo *_bo, void **out) memset(&arg, 0, sizeof(arg)); arg.handle = bo->base.handle;
- ret = drmCommandWriteRead(bo->base.kms->fd, DRM_EXYNOS_GEM_MAP_OFFSET, &arg, sizeof(arg)); + ret = drmIoctl(bo->base.kms->fd, DRM_IOCTL_MODE_MAP_DUMB, &arg); if (ret) return ret;
- map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset); + map = drm_mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.kms->fd, arg.offset); if (map == MAP_FAILED) return -errno;
This patch removes the ioctls which are removed from the linux kernel.
Signed-off-by: Hyungwon Hwang human.hwang@samsung.com Signed-off-by: Inki Dae inki.dae@samsung.com --- exynos/exynos_drm.h | 40 ---------------------------------------- 1 file changed, 40 deletions(-)
diff --git a/exynos/exynos_drm.h b/exynos/exynos_drm.h index c3c6579..256c02f 100644 --- a/exynos/exynos_drm.h +++ b/exynos/exynos_drm.h @@ -47,38 +47,6 @@ struct drm_exynos_gem_create { };
/** - * A structure for getting buffer offset. - * - * @handle: a pointer to gem object created. - * @pad: just padding to be 64-bit aligned. - * @offset: relatived offset value of the memory region allocated. - * - this value should be set by user. - */ -struct drm_exynos_gem_map_off { - unsigned int handle; - unsigned int pad; - uint64_t offset; -}; - -/** - * A structure for mapping buffer. - * - * @handle: a handle to gem object created. - * @pad: just padding to be 64-bit aligned. - * @size: memory size to be mapped. - * @mapped: having user virtual address mmaped. - * - this variable would be filled by exynos gem module - * of kernel side with user virtual address which is allocated - * by do_mmap(). - */ -struct drm_exynos_gem_mmap { - unsigned int handle; - unsigned int pad; - uint64_t size; - uint64_t mapped; -}; - -/** * A structure to gem information. * * @handle: a handle to gem object created. @@ -164,8 +132,6 @@ struct drm_exynos_g2d_exec { };
#define DRM_EXYNOS_GEM_CREATE 0x00 -#define DRM_EXYNOS_GEM_MAP_OFFSET 0x01 -#define DRM_EXYNOS_GEM_MMAP 0x02 /* Reserved 0x04 ~ 0x05 for exynos specific gem ioctl */ #define DRM_EXYNOS_GEM_GET 0x04 #define DRM_EXYNOS_VIDI_CONNECTION 0x07 @@ -178,12 +144,6 @@ struct drm_exynos_g2d_exec { #define DRM_IOCTL_EXYNOS_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
-#define DRM_IOCTL_EXYNOS_GEM_MAP_OFFSET DRM_IOWR(DRM_COMMAND_BASE + \ - DRM_EXYNOS_GEM_MAP_OFFSET, struct drm_exynos_gem_map_off) - -#define DRM_IOCTL_EXYNOS_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + \ - DRM_EXYNOS_GEM_MMAP, struct drm_exynos_gem_mmap) - #define DRM_IOCTL_EXYNOS_GEM_GET DRM_IOWR(DRM_COMMAND_BASE + \ DRM_EXYNOS_GEM_GET, struct drm_exynos_gem_info)
+CC Rob clark
I sent these patches about a month ago, but could not get any response. Can you review these patches? You can find the whole patch set from
https://patchwork.kernel.org/patch/5478981/ https://patchwork.kernel.org/patch/5478991/
On Fri, 12 Dec 2014 14:44:39 +0900 Hyungwon Hwang human.hwang@samsung.com wrote:
The ioctl DRM_EXYNOS_GEM_MAP_OFFSET and DRM_EXYNOS_GEM_MMAP are removed from the linux kernel. This patch modifies libdrm and libkms to use drm generic ioctls instead of the removed ioctls.
Signed-off-by: Hyungwon Hwang human.hwang@samsung.com Signed-off-by: Inki Dae inki.dae@samsung.com
exynos/exynos_drm.c | 24 +++++++++++++----------- libkms/exynos.c | 7 ++++--- 2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/exynos/exynos_drm.c b/exynos/exynos_drm.c index 4c7dd13..4cb6a6d 100644 --- a/exynos/exynos_drm.c +++ b/exynos/exynos_drm.c @@ -283,20 +283,22 @@ drm_public void *exynos_bo_map(struct exynos_bo *bo) { if (!bo->vaddr) { struct exynos_device *dev = bo->dev;
struct drm_exynos_gem_mmap req = {
.handle = bo->handle,
.size = bo->size,
};
struct drm_mode_map_dumb arg;
int ret;void *map = NULL;
ret = drmIoctl(dev->fd, DRM_IOCTL_EXYNOS_GEM_MMAP,
&req);
if (ret) {
fprintf(stderr, "failed to mmap[%s].\n",
strerror(errno));
return NULL;
}
memset(&arg, 0, sizeof(arg));
arg.handle = bo->handle;
ret = drmIoctl(dev->fd, DRM_IOCTL_MODE_MAP_DUMB,
&arg);
if (ret)
return ret;
bo->vaddr = (void *)(uintptr_t)req.mapped;
map = drm_mmap(0, bo->size, PROT_READ | PROT_WRITE,
MAP_SHARED,
dev->fd, arg.offset);
if (map == MAP_FAILED)
return NULL;
}
return bo->vaddr;
diff --git a/libkms/exynos.c b/libkms/exynos.c index 92e329c..1123482 100644 --- a/libkms/exynos.c +++ b/libkms/exynos.c @@ -25,6 +25,7 @@ #include <sys/ioctl.h> #include "xf86drm.h"
+#include "libdrm.h" #include "exynos_drm.h"
struct exynos_bo @@ -124,7 +125,7 @@ static int exynos_bo_map(struct kms_bo *_bo, void **out) { struct exynos_bo *bo = (struct exynos_bo *)_bo;
- struct drm_exynos_gem_map_off arg;
- struct drm_mode_map_dumb arg; void *map = NULL; int ret;
@@ -137,11 +138,11 @@ exynos_bo_map(struct kms_bo *_bo, void **out) memset(&arg, 0, sizeof(arg)); arg.handle = bo->base.handle;
- ret = drmCommandWriteRead(bo->base.kms->fd,
DRM_EXYNOS_GEM_MAP_OFFSET, &arg, sizeof(arg));
- ret = drmIoctl(bo->base.kms->fd, DRM_IOCTL_MODE_MAP_DUMB,
&arg); if (ret) return ret;
- map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE,
MAP_SHARED, bo->base.kms->fd, arg.offset);
- map = drm_mmap(0, bo->base.size, PROT_READ | PROT_WRITE,
MAP_SHARED, bo->base.kms->fd, arg.offset); if (map == MAP_FAILED) return -errno;
Best regards, Hyungwon Hwang
dri-devel@lists.freedesktop.org