mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 01:34:11 +00:00
modesetting: Remove out in-tree dumb buffer implementation
Since libgbm was split from mesa, and a backend that works with only dumb buffers was written, there is no reason why we should roll out own dumb buffer implementation. Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
This commit is contained in:
committed by
Enrico Weigelt
parent
f9589b3c3c
commit
119ef93615
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <airlied@redhat.com>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "dix-config.h"
|
||||
|
||||
#include "dumb_bo.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <xf86drm.h>
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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 <airlied@redhat.com>
|
||||
*
|
||||
*/
|
||||
#ifndef DUMB_BO_H
|
||||
#define DUMB_BO_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
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
|
||||
@@ -3,7 +3,6 @@ modesetting_srcs = [
|
||||
'driver.c',
|
||||
'drmmode_bo.c',
|
||||
'drmmode_display.c',
|
||||
'dumb_bo.c',
|
||||
'pageflip.c',
|
||||
'present.c',
|
||||
'vblank.c',
|
||||
|
||||
Reference in New Issue
Block a user