diff --git a/hw/xfree86/drivers/video/modesetting/driver.c b/hw/xfree86/drivers/video/modesetting/driver.c index 4c40075e88..3f54f02978 100644 --- a/hw/xfree86/drivers/video/modesetting/driver.c +++ b/hw/xfree86/drivers/video/modesetting/driver.c @@ -1460,7 +1460,7 @@ msShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset, int mode, stride = (pScrn->displayWidth * ms->drmmode.kbpp) / 8; *size = stride; - return ((uint8_t *) ms->drmmode.front_bo.dumb->ptr + row * stride + offset); + return ((uint8_t *) gbm_bo_get_map(ms->drmmode.front_bo.gbm) + row * stride + offset); } /* somewhat arbitrary tile size, in pixels */ diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_display.c b/hw/xfree86/drivers/video/modesetting/drmmode_display.c index 0bda242c18..9c4941b363 100644 --- a/hw/xfree86/drivers/video/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/video/modesetting/drmmode_display.c @@ -38,7 +38,6 @@ #include "os/fmt.h" #include "present/present_priv.h" -#include "dumb_bo.h" #include "inputstr.h" #include "xf86str.h" #include "X11/Xatom.h" @@ -1009,78 +1008,10 @@ drmmode_crtc_flip(xf86CrtcPtr crtc, uint32_t fb_id, int x, int y, fb_id, flags, data); } -void -drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo) -{ -#ifdef GLAMOR_HAS_GBM - if (bo->gbm) { - if (bo->map_addr) { - gbm_bo_unmap(bo->gbm, bo->map_addr); - bo->map_addr = NULL; - bo->map_data = NULL; - } - gbm_bo_destroy(bo->gbm); - bo->gbm = NULL; - } -#endif - - if (bo->dumb) { - int ret = dumb_bo_destroy(drmmode->fd, bo->dumb); - if (ret == 0) { - bo->map_addr = NULL; - bo->map_data = NULL; - bo->dumb = NULL; - } - } -} - -static void* -drmmode_bo_map(drmmode_ptr drmmode, drmmode_bo *bo) -{ - if (bo->map_data) { - return bo->map_data; - } - -#ifdef GLAMOR_HAS_GBM - if (bo->gbm) { - /** - * We shouldn't read from gpu memory, as it's really slow. - * We do allow it though, so nothing breaks. - */ - uint32_t stride = 0; - void* map_addr = NULL; - void* map_data = gbm_bo_map(bo->gbm, 0, 0, bo->width, bo->height, GBM_BO_TRANSFER_READ_WRITE, &stride, &map_addr); - if (map_data) { - bo->map_data = map_data; - bo->map_addr = map_addr; - return bo->map_data; - } - } -#endif - - if (bo->dumb) { - int ret = dumb_bo_map(drmmode->fd, bo->dumb); - if (ret) { - return NULL; - } - - bo->map_data = bo->dumb->ptr; - bo->map_addr = bo->map_data; - return bo->map_data; - } - - return NULL; -} - static Bool drmmode_create_front_bo(drmmode_ptr drmmode, drmmode_bo *bo, unsigned width, unsigned height, unsigned bpp) { - memset(bo, 0, sizeof(*bo)); - - bo->width = width; - bo->height = height; - #ifdef GLAMOR_HAS_GBM bo->gbm = gbm_create_best_bo(drmmode, !drmmode->glamor, width, height, DRMMODE_FRONT_BO); return !!bo->gbm; @@ -3948,7 +3879,7 @@ drmmode_set_pixmap_bo(drmmode_ptr drmmode, PixmapPtr pixmap, drmmode_bo *bo) return TRUE; if (!ms->glamor.egl_create_textured_pixmap_from_gbm_bo(pixmap, bo->gbm, - bo->used_modifiers)) { + gbm_bo_get_used_modifiers(bo->gbm))) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to create pixmap\n"); return FALSE; } @@ -4970,12 +4901,6 @@ drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode) return TRUE; } -void * -drmmode_map_front_bo(drmmode_ptr drmmode) -{ - return drmmode_bo_map(drmmode, &drmmode->front_bo); -} - void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode) { diff --git a/hw/xfree86/drivers/video/modesetting/drmmode_display.h b/hw/xfree86/drivers/video/modesetting/drmmode_display.h index 968a84a56e..d9f41b014e 100644 --- a/hw/xfree86/drivers/video/modesetting/drmmode_display.h +++ b/hw/xfree86/drivers/video/modesetting/drmmode_display.h @@ -34,8 +34,6 @@ #include "libudev.h" #endif -#include "dumb_bo.h" - struct gbm_device; enum drmmode_plane_property { @@ -78,15 +76,7 @@ enum drmmode_crtc_property { }; typedef struct { - uint32_t width; - uint32_t height; - struct dumb_bo *dumb; -#ifdef GLAMOR_HAS_GBM - Bool used_modifiers; struct gbm_bo *gbm; -#endif - void* map_data; /* Actual pixel data we are interesed in */ - void* map_addr; /* Address of the map that we have to unmap */ } drmmode_bo; typedef struct { @@ -353,7 +343,6 @@ extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode); extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode); Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode); -void *drmmode_map_front_bo(drmmode_ptr drmmode); void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode); void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode, int *depth, int *bpp); diff --git a/hw/xfree86/drivers/video/modesetting/dumb_bo.c b/hw/xfree86/drivers/video/modesetting/dumb_bo.c deleted file mode 100644 index cdff166ce7..0000000000 --- a/hw/xfree86/drivers/video/modesetting/dumb_bo.c +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright © 2007 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Dave Airlie - * - */ - -#include "dix-config.h" - -#include "dumb_bo.h" - -#include -#include -#include -#include -#include -#include -#include - -struct dumb_bo * -dumb_bo_create(int fd, - const unsigned width, const unsigned height, const unsigned bpp) -{ - struct drm_mode_create_dumb arg; - struct dumb_bo *bo; - int ret; - - bo = calloc(1, sizeof(*bo)); - if (!bo) - return NULL; - - memset(&arg, 0, sizeof(arg)); - arg.width = width; - arg.height = height; - arg.bpp = bpp; - - ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg); - if (ret) - goto err_free; - - bo->handle = arg.handle; - bo->size = arg.size; - bo->pitch = arg.pitch; - - return bo; - err_free: - free(bo); - return NULL; -} - -int -dumb_bo_map(int fd, struct dumb_bo *bo) -{ - struct drm_mode_map_dumb arg; - int ret; - void *map; - - if (bo->ptr) { - return 0; - } - - memset(&arg, 0, sizeof(arg)); - arg.handle = bo->handle; - - ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg); - if (ret) - return ret; - - map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, arg.offset); - if (map == MAP_FAILED) - return -errno; - - bo->ptr = map; - return 0; -} - -int -dumb_bo_destroy(int fd, struct dumb_bo *bo) -{ - struct drm_mode_destroy_dumb arg; - int ret; - - if (bo->ptr) { - munmap(bo->ptr, bo->size); - bo->ptr = NULL; - } - - memset(&arg, 0, sizeof(arg)); - arg.handle = bo->handle; - ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg); - if (ret) - return -errno; - - free(bo); - return 0; -} - -struct dumb_bo * -dumb_get_bo_from_fd(int fd, int handle, int pitch, int size) -{ - struct dumb_bo *bo; - int ret; - - bo = calloc(1, sizeof(*bo)); - if (!bo) - return NULL; - - ret = drmPrimeFDToHandle(fd, handle, &bo->handle); - if (ret) { - free(bo); - return NULL; - } - bo->pitch = pitch; - bo->size = size; - return bo; -} diff --git a/hw/xfree86/drivers/video/modesetting/dumb_bo.h b/hw/xfree86/drivers/video/modesetting/dumb_bo.h deleted file mode 100644 index 9235e61e2f..0000000000 --- a/hw/xfree86/drivers/video/modesetting/dumb_bo.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2007 Red Hat, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Authors: - * Dave Airlie - * - */ -#ifndef DUMB_BO_H -#define DUMB_BO_H - -#include - -struct dumb_bo { - uint32_t handle; - uint32_t size; - void *ptr; - uint32_t pitch; -}; - -struct dumb_bo *dumb_bo_create(int fd, const unsigned width, - const unsigned height, const unsigned bpp); -int dumb_bo_map(int fd, struct dumb_bo *bo); -int dumb_bo_destroy(int fd, struct dumb_bo *bo); -struct dumb_bo *dumb_get_bo_from_fd(int fd, int handle, int pitch, int size); - -#endif diff --git a/hw/xfree86/drivers/video/modesetting/meson.build b/hw/xfree86/drivers/video/modesetting/meson.build index 90f9654f31..3a6abb3802 100644 --- a/hw/xfree86/drivers/video/modesetting/meson.build +++ b/hw/xfree86/drivers/video/modesetting/meson.build @@ -3,7 +3,6 @@ modesetting_srcs = [ 'driver.c', 'drmmode_bo.c', 'drmmode_display.c', - 'dumb_bo.c', 'pageflip.c', 'present.c', 'vblank.c',