aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-12-02 12:29:57 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-12-02 12:29:57 +0100
commit88aea3146426a0b2034de37aba46bc1fcb193dc3 (patch)
treee723b750480427c8285f2ec2a1b6bcb51c970163
parent98e80ffc82aa732a0a87c5b3af9bbb6c7d52fac0 (diff)
downloaddrminfo-88aea3146426a0b2034de37aba46bc1fcb193dc3.tar.gz
more vgem code restruction
-rw-r--r--drmtest.c42
-rw-r--r--drmtools.c8
2 files changed, 29 insertions, 21 deletions
diff --git a/drmtest.c b/drmtest.c
index a834dd9..17b0cde 100644
--- a/drmtest.c
+++ b/drmtest.c
@@ -219,7 +219,7 @@ static void drm_zap_mappings(void)
/* ------------------------------------------------------------------ */
-static void drm_init_dumb_obj(int fd)
+static void drm_init_dumb_obj(int fd, bool create_dmabuf)
{
struct drm_mode_map_dumb mreq;
int rc;
@@ -248,6 +248,25 @@ static void drm_init_dumb_obj(int fd)
fprintf(stderr, "framebuffer mmap: %s\n", strerror(errno));
exit(1);
}
+
+ if (create_dmabuf) {
+ print_head("create dma-buf");
+ rc = drmPrimeHandleToFD(drm_fd, creq.handle, 0, &dmabuf_fd);
+ print_test_errno("dma-buf export", rc < 0, errno);
+ if (rc == 0) {
+ dmabuf_mem = mmap(NULL, creq.size, PROT_READ, MAP_SHARED, dmabuf_fd, 0);
+ print_test_errno("dma-buf mmap", dmabuf_mem == MAP_FAILED, errno);
+ if (dmabuf_mem != MAP_FAILED) {
+ pxdma = pixman_image_create_bits(fmt->pixman,
+ creq.width,
+ creq.height,
+ (void*)dmabuf_mem,
+ creq.pitch);
+ } else {
+ dmabuf_mem = NULL;
+ }
+ }
+ }
}
static void drm_init_dumb_fb(bool use_pixman, bool create_dmabuf)
@@ -255,7 +274,7 @@ static void drm_init_dumb_fb(bool use_pixman, bool create_dmabuf)
uint32_t zero = 0;
int rc;
- drm_init_dumb_obj(drm_fd);
+ drm_init_dumb_obj(drm_fd, create_dmabuf);
if (fmt->fourcc) {
rc = drmModeAddFB2(drm_fd, creq.width, creq.height, fmt->fourcc,
@@ -279,25 +298,6 @@ static void drm_init_dumb_fb(bool use_pixman, bool create_dmabuf)
}
}
- if (create_dmabuf) {
- print_head("create dma-buf");
- rc = drmPrimeHandleToFD(drm_fd, creq.handle, 0, &dmabuf_fd);
- print_test_errno("dma-buf export", rc < 0, errno);
- if (rc == 0) {
- dmabuf_mem = mmap(NULL, creq.size, PROT_READ, MAP_SHARED, dmabuf_fd, 0);
- print_test_errno("dma-buf mmap", dmabuf_mem == MAP_FAILED, errno);
- if (dmabuf_mem != MAP_FAILED) {
- pxdma = pixman_image_create_bits(fmt->pixman,
- creq.width,
- creq.height,
- (void*)dmabuf_mem,
- creq.pitch);
- } else {
- dmabuf_mem = NULL;
- }
- }
- }
-
if (use_pixman) {
pxfb = pixman_image_create_bits(fmt->pixman,
creq.width,
diff --git a/drmtools.c b/drmtools.c
index cebf719..9e4537c 100644
--- a/drmtools.c
+++ b/drmtools.c
@@ -705,6 +705,7 @@ void drm_print_format_hdr(FILE *fp, int indent, bool libs, bool virtio)
/* ------------------------------------------------------------------ */
+int drm_nr;
int drm_fd;
uint32_t fb_id;
drmModeConnector *drm_conn = NULL;
@@ -732,6 +733,7 @@ void drm_init_dev(int devnr, const char *output,
snprintf(dev, sizeof(dev), DRM_DEV_NAME, DRM_DIR_NAME, devnr);
drm_fd = device_open(dev);
}
+ drm_nr = devnr;
version = drmGetVersion(drm_fd);
if (need_dumb) {
@@ -820,7 +822,13 @@ int drm_init_vgem(void)
int fd, i;
for (i = 0; i < 128; i++) {
+ if (i == drm_nr)
+ continue;
+#if 1
snprintf(dev, sizeof(dev), "/dev/dri/card%d", i);
+#else
+ snprintf(dev, sizeof(dev), "/dev/dri/renderD%d", i + 128);
+#endif
fd = device_open(dev);
if (fd < 0)
goto out;