summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeung-Woo Kim <sw0312.kim@samsung.com>2015-02-03 14:15:02 +0900
committerJoonyoung Shim <jy0922.shim@samsung.com>2017-02-15 13:37:33 +0900
commit89ab3b7422f0f9bdf6ab83a3f0b302fbff17a0d7 (patch)
tree0a3c9b31c7537283b18144552051c2a4fe82ef8f
parent70bca47a88d0f2e7c35a445195c383a2639b3675 (diff)
downloadlibdrm-89ab3b7422f0f9bdf6ab83a3f0b302fbff17a0d7.tar.gz
libdrm-89ab3b7422f0f9bdf6ab83a3f0b302fbff17a0d7.tar.bz2
libdrm-89ab3b7422f0f9bdf6ab83a3f0b302fbff17a0d7.zip
ipptest: replace DRM_EXYNOS_GEM_MAP_OFFSET/MMAP with generic mmap
The DRM_EXYNOS_GEM_MAP_OFFSET and DRM_EXYNOS_GEM_MMAP ioctls are removed from the linux kernel because there is already generic way to mmap gem. This patch replaces the ioctls from ipptest for fimc and rotator to drm generic ioctl and mmap. Change-Id: I49d6bfac511946a6ad7bb898e77d03a812774629 Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
-rw-r--r--tests/ipptest/fimc.c10
-rw-r--r--tests/ipptest/gem.c36
-rw-r--r--tests/ipptest/gem.h9
-rw-r--r--tests/ipptest/util.c4
-rw-r--r--tests/ipptest/util.h2
-rw-r--r--tests/rottest/gem.c36
-rw-r--r--tests/rottest/gem.h9
-rw-r--r--tests/rottest/rotator.c17
-rw-r--r--tests/rottest/util.c7
-rw-r--r--tests/rottest/util.h3
10 files changed, 97 insertions, 36 deletions
diff --git a/tests/ipptest/fimc.c b/tests/ipptest/fimc.c
index cf8fbb08..df5d04d4 100644
--- a/tests/ipptest/fimc.c
+++ b/tests/ipptest/fimc.c
@@ -261,7 +261,7 @@ void fimc_m2m_set_mode(struct connector *c, int count, int page_flip,
unsigned int width=720, height=1280, stride;
int ret, i, j, x;
struct drm_exynos_gem_create gem1[MAX_BUF], gem2[MAX_BUF];
- struct drm_exynos_gem_mmap mmap1[MAX_BUF], mmap2[MAX_BUF];
+ struct exynos_gem_mmap_data mmap1[MAX_BUF], mmap2[MAX_BUF];
void *usr_addr1[MAX_BUF], *usr_addr2[MAX_BUF];
struct timeval begin, end;
struct drm_gem_close args;
@@ -300,7 +300,7 @@ void fimc_m2m_set_mode(struct connector *c, int count, int page_flip,
else if (ret == -2)
goto err_ipp_ctrl_close;
}
- usr_addr1[i] = (void *)(unsigned long)mmap1[i].mapped;
+ usr_addr1[i] = mmap1[i].addr;
/* For source buffer map to IPP */
ret = exynos_drm_ipp_queue_buf(fd, &qbuf1[i], EXYNOS_DRM_OPS_SRC,
@@ -326,7 +326,7 @@ void fimc_m2m_set_mode(struct connector *c, int count, int page_flip,
else if (ret == -2)
goto err_ipp_ctrl_close;
}
- usr_addr2[i] = (void*)(unsigned long)mmap2[i].mapped;
+ usr_addr2[i] = mmap2[i].addr;
/* For destination buffer map to IPP */
ret = exynos_drm_ipp_queue_buf(fd, &qbuf2[i], EXYNOS_DRM_OPS_DST,
@@ -433,7 +433,7 @@ void fimc_wb_set_mode(struct connector *c, int count, int page_flip,
struct drm_exynos_sz def_sz = {720, 1280};
struct drm_exynos_ipp_property property;
struct drm_exynos_gem_create gem[MAX_BUF];
- struct drm_exynos_gem_mmap mmap[MAX_BUF];
+ struct exynos_gem_mmap_data mmap[MAX_BUF];
struct drm_exynos_ipp_queue_buf qbuf[MAX_BUF];
void *usr_addr[MAX_BUF];
struct drm_exynos_ipp_cmd_ctrl cmd_ctrl;
@@ -471,7 +471,7 @@ void fimc_wb_set_mode(struct connector *c, int count, int page_flip,
if (ret == -1) return;
else if (ret == -2) goto err_ipp_ctrl_close;
}
- usr_addr[i] = (void *)(unsigned long)mmap[i].mapped;
+ usr_addr[i] = mmap[i].addr;
/* For destination buffer map to IPP */
ret = exynos_drm_ipp_queue_buf(fd, &qbuf[i], EXYNOS_DRM_OPS_DST,
IPP_BUF_ENQUEUE, property.prop_id, i, gem[i].handle);
diff --git a/tests/ipptest/gem.c b/tests/ipptest/gem.c
index fa228df8..5710d6f2 100644
--- a/tests/ipptest/gem.c
+++ b/tests/ipptest/gem.c
@@ -29,12 +29,15 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
#include "xf86drm.h"
#include "xf86drmMode.h"
#include "libkms.h"
#include "exynos_drm.h"
+#include "gem.h"
int exynos_gem_create(int fd, struct drm_exynos_gem_create *gem)
{
@@ -51,14 +54,35 @@ int exynos_gem_create(int fd, struct drm_exynos_gem_create *gem)
return ret;
}
-int exynos_gem_mmap(int fd, struct drm_exynos_gem_mmap *in_mmap)
+int exynos_gem_mmap(int fd, struct exynos_gem_mmap_data *in_mmap)
{
- int ret = 0;
+ int ret;
+ void *map;
+ struct drm_mode_map_dumb arg;
- ret = ioctl(fd, DRM_IOCTL_EXYNOS_GEM_MMAP, in_mmap);
- if (ret < 0)
- fprintf(stderr, "failed to mmap: %s\n", strerror(-ret));
- return ret;
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = in_mmap->handle;
+
+ ret = ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+ if (ret) {
+ fprintf(stderr, "failed to map dumb buffer: %s\n",
+ strerror(errno));
+ return ret;
+ }
+
+ in_mmap->offset = arg.offset;
+
+ map = mmap(NULL, (size_t)in_mmap->size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, (off_t)arg.offset);
+ if (map == MAP_FAILED) {
+ fprintf(stderr, "failed to mmap buffer: %s\n",
+ strerror(errno));
+ return -EFAULT;
+ }
+
+ in_mmap->addr = map;
+
+ return 0;
}
int exynos_gem_close(int fd, struct drm_gem_close *gem_close)
diff --git a/tests/ipptest/gem.h b/tests/ipptest/gem.h
index 8d4d9f14..0f59782e 100644
--- a/tests/ipptest/gem.h
+++ b/tests/ipptest/gem.h
@@ -1,8 +1,15 @@
#ifndef __GEM_H__
#define __GEM_H__
+struct exynos_gem_mmap_data {
+ uint32_t handle;
+ uint64_t size;
+ uint64_t offset;
+ void *addr;
+};
+
extern int exynos_gem_create(int fd, struct drm_exynos_gem_create *gem);
-extern int exynos_gem_mmap(int fd, struct drm_exynos_gem_mmap *in_mmap);
+extern int exynos_gem_mmap(int fd, struct exynos_gem_mmap_data *in_mmap);
extern int exynos_gem_close(int fd, struct drm_gem_close *gem_close);
#endif
diff --git a/tests/ipptest/util.c b/tests/ipptest/util.c
index 745c2120..20498a26 100644
--- a/tests/ipptest/util.c
+++ b/tests/ipptest/util.c
@@ -33,7 +33,7 @@
#include "gem.h"
int util_gem_create_mmap(int fd, struct drm_exynos_gem_create *gem,
- struct drm_exynos_gem_mmap *mmap,
+ struct exynos_gem_mmap_data *mmap,
unsigned int size)
{
/* initialize structure for gem create */
@@ -46,7 +46,7 @@ int util_gem_create_mmap(int fd, struct drm_exynos_gem_create *gem,
}
/* initialize structure for gem mmap */
- memset(mmap, 0x00, sizeof(struct drm_exynos_gem_mmap));
+ memset(mmap, 0x00, sizeof(struct exynos_gem_mmap_data));
mmap->handle = gem->handle;
mmap->size = gem->size;
diff --git a/tests/ipptest/util.h b/tests/ipptest/util.h
index e1ffcca4..0bbeac66 100644
--- a/tests/ipptest/util.h
+++ b/tests/ipptest/util.h
@@ -2,7 +2,7 @@
#define __UTIL_H__
extern int util_gem_create_mmap(int fd, struct drm_exynos_gem_create *gem,
- struct drm_exynos_gem_mmap *mmap,
+ struct exynos_gem_mmap_data *mmap,
unsigned int size);
extern void util_draw_buffer(void *addr, unsigned int stripe,
unsigned int width, unsigned int height,
diff --git a/tests/rottest/gem.c b/tests/rottest/gem.c
index 001aea08..071d8a69 100644
--- a/tests/rottest/gem.c
+++ b/tests/rottest/gem.c
@@ -29,12 +29,15 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
#include "xf86drm.h"
#include "xf86drmMode.h"
#include "libkms.h"
#include "exynos_drm.h"
+#include "gem.h"
int exynos_gem_create(int fd, struct drm_exynos_gem_create *gem)
{
@@ -51,14 +54,35 @@ int exynos_gem_create(int fd, struct drm_exynos_gem_create *gem)
return ret;
}
-int exynos_gem_mmap(int fd, struct drm_exynos_gem_mmap *in_mmap)
+int exynos_gem_mmap(int fd, struct exynos_gem_mmap_data *in_mmap)
{
- int ret = 0;
+ int ret;
+ void *map;
+ struct drm_mode_map_dumb arg;
- ret = ioctl(fd, DRM_IOCTL_EXYNOS_GEM_MMAP, in_mmap);
- if (ret < 0)
- fprintf(stderr, "failed to mmap: %s\n", strerror(-ret));
- return ret;
+ memset(&arg, 0, sizeof(arg));
+ arg.handle = in_mmap->handle;
+
+ ret = ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+ if (ret) {
+ fprintf(stderr, "failed to map dumb buffer: %s\n",
+ strerror(errno));
+ return ret;
+ }
+
+ in_mmap->offset = arg.offset;
+
+ map = mmap(NULL, (size_t)in_mmap->size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, (off_t)arg.offset);
+ if (map == MAP_FAILED) {
+ fprintf(stderr, "failed to mmap buffer: %s\n",
+ strerror(errno));
+ return -EFAULT;
+ }
+
+ in_mmap->addr = map;
+
+ return 0;
}
int exynos_gem_close(int fd, struct drm_gem_close *gem_close)
diff --git a/tests/rottest/gem.h b/tests/rottest/gem.h
index 8d4d9f14..0f59782e 100644
--- a/tests/rottest/gem.h
+++ b/tests/rottest/gem.h
@@ -1,8 +1,15 @@
#ifndef __GEM_H__
#define __GEM_H__
+struct exynos_gem_mmap_data {
+ uint32_t handle;
+ uint64_t size;
+ uint64_t offset;
+ void *addr;
+};
+
extern int exynos_gem_create(int fd, struct drm_exynos_gem_create *gem);
-extern int exynos_gem_mmap(int fd, struct drm_exynos_gem_mmap *in_mmap);
+extern int exynos_gem_mmap(int fd, struct exynos_gem_mmap_data *in_mmap);
extern int exynos_gem_close(int fd, struct drm_gem_close *gem_close);
#endif
diff --git a/tests/rottest/rotator.c b/tests/rottest/rotator.c
index a7cf50bc..bd2586b5 100644
--- a/tests/rottest/rotator.c
+++ b/tests/rottest/rotator.c
@@ -231,7 +231,7 @@ void rotator_1_N_set_mode(struct connector *c, int count, int page_flip,
unsigned int width, height, stride;
int ret, i, counter;
struct drm_exynos_gem_create gem1, gem2[MAX_BUF];
- struct drm_exynos_gem_mmap mmap1, mmap2[MAX_BUF];
+ struct exynos_gem_mmap_data mmap1, mmap2[MAX_BUF];
void *usr_addr1, *usr_addr2[MAX_BUF];
struct timeval begin, end;
struct drm_gem_close args;
@@ -248,13 +248,13 @@ void rotator_1_N_set_mode(struct connector *c, int count, int page_flip,
/* For GEM create / mmap / draw buffer */
/* For source buffer */
- ret = util_gem_create_mmap(fd, &gem1, &mmap1, &usr_addr1,
- stride * height);
+ ret = util_gem_create_mmap(fd, &gem1, &mmap1, stride * height);
if (ret) {
fprintf(stderr, "failed to gem create mmap: %s\n",
strerror(errno));
return;
}
+ usr_addr1 = mmap1.addr;
util_draw_buffer(usr_addr1, 1, width, height, stride, 0);
sprintf(filename, "/opt/media/rot_src.bmp");
util_write_bmp(filename, usr_addr1, width, height);
@@ -262,12 +262,13 @@ void rotator_1_N_set_mode(struct connector *c, int count, int page_flip,
/* For destination buffer */
for (i = 0; i < MAX_BUF; i++) {
ret = util_gem_create_mmap(fd, &gem2[i], &mmap2[i],
- &usr_addr2[i], stride * height);
+ stride * height);
if (ret) {
fprintf(stderr, "failed to gem create mmap: %d : %s\n",
i, strerror(errno));
goto err_gem_create_mmap;
}
+ usr_addr2[i] = mmap2[i].addr;
util_draw_buffer(usr_addr2[i], 0, 0, 0, 0, stride * height);
sprintf(filename, "/opt/media/rot_dst%d.bmp", i);
util_write_bmp(filename, usr_addr2[i], height, width);
@@ -420,7 +421,7 @@ void rotator_N_N_set_mode(struct connector *c, int count, int page_flip,
unsigned int width, height, stride;
int ret, i, counter;
struct drm_exynos_gem_create gem1[MAX_BUF], gem2[MAX_BUF];
- struct drm_exynos_gem_mmap mmap1[MAX_BUF], mmap2[MAX_BUF];
+ struct exynos_gem_mmap_data mmap1[MAX_BUF], mmap2[MAX_BUF];
void *usr_addr1[MAX_BUF], *usr_addr2[MAX_BUF];
struct timeval begin, end;
struct drm_gem_close args;
@@ -439,24 +440,26 @@ void rotator_N_N_set_mode(struct connector *c, int count, int page_flip,
for (i = 0; i < MAX_BUF; i++) {
/* For source buffer */
ret = util_gem_create_mmap(fd, &gem1[i], &mmap1[i],
- &usr_addr1[i], stride * height);
+ stride * height);
if (ret) {
fprintf(stderr, "failed to gem create mmap: %d : %s\n",
i, strerror(errno));
goto err_gem_create_mmap;
}
+ usr_addr1[i] = mmap1[i].addr;
util_draw_buffer(usr_addr1[i], 1, width, height, stride, 0);
sprintf(filename, "/opt/media/rot_src%d.bmp", i);
util_write_bmp(filename, usr_addr1[i], width, height);
/* For destination buffer */
ret = util_gem_create_mmap(fd, &gem2[i], &mmap2[i],
- &usr_addr2[i], stride * height);
+ stride * height);
if (ret) {
fprintf(stderr, "failed to gem create mmap: %d : %s\n",
i, strerror(errno));
goto err_gem_create_mmap;
}
+ usr_addr2[i] = mmap2[i].addr;
util_draw_buffer(usr_addr2[i], 0, 0, 0, 0, stride * height);
sprintf(filename, "/opt/media/rot_dst%d.bmp", i);
util_write_bmp(filename, usr_addr2[i], height, width);
diff --git a/tests/rottest/util.c b/tests/rottest/util.c
index 5520de38..e7435bf0 100644
--- a/tests/rottest/util.c
+++ b/tests/rottest/util.c
@@ -33,8 +33,7 @@
#include "gem.h"
int util_gem_create_mmap(int fd, struct drm_exynos_gem_create *gem,
- struct drm_exynos_gem_mmap *mmap,
- void **addr,
+ struct exynos_gem_mmap_data *mmap,
unsigned int size)
{
struct drm_gem_close args;
@@ -49,7 +48,7 @@ int util_gem_create_mmap(int fd, struct drm_exynos_gem_create *gem,
}
/* initialize structure for gem mmap */
- memset(mmap, 0x00, sizeof(struct drm_exynos_gem_mmap));
+ memset(mmap, 0x00, sizeof(struct exynos_gem_mmap_data));
mmap->handle = gem->handle;
mmap->size = gem->size;
@@ -61,8 +60,6 @@ int util_gem_create_mmap(int fd, struct drm_exynos_gem_create *gem,
return -2;
}
- *addr = (void *)(unsigned long)mmap->mapped;
-
return 0;
}
diff --git a/tests/rottest/util.h b/tests/rottest/util.h
index 5b2ba98c..0bbeac66 100644
--- a/tests/rottest/util.h
+++ b/tests/rottest/util.h
@@ -2,8 +2,7 @@
#define __UTIL_H__
extern int util_gem_create_mmap(int fd, struct drm_exynos_gem_create *gem,
- struct drm_exynos_gem_mmap *mmap,
- void **addr,
+ struct exynos_gem_mmap_data *mmap,
unsigned int size);
extern void util_draw_buffer(void *addr, unsigned int stripe,
unsigned int width, unsigned int height,