mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 05:54:08 +00:00
modesetting: move drmmode_bo_import to drmmode_bo.c
Signed-off-by: stefan11111 <stefan11111@shitposting.expert>
This commit is contained in:
committed by
Enrico Weigelt
parent
466ec86669
commit
501b60f1d5
@@ -330,3 +330,47 @@ gbm_back_bo_from_fd(drmmode_ptr drmmode, Bool do_map, int fd_handle, uint32_t pi
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* A bit of a misnomer, this is a dmabuf export */
|
||||
int
|
||||
drmmode_bo_import(drmmode_ptr drmmode, drmmode_bo *bo,
|
||||
uint32_t *fb_id)
|
||||
{
|
||||
uint32_t width = gbm_bo_get_width(bo->gbm);
|
||||
uint32_t height = gbm_bo_get_height(bo->gbm);
|
||||
|
||||
#ifdef GBM_BO_WITH_MODIFIERS
|
||||
modesettingPtr ms = modesettingPTR(drmmode->scrn);
|
||||
if (bo->gbm && ms->kms_has_modifiers &&
|
||||
gbm_bo_get_modifier(bo->gbm) != DRM_FORMAT_MOD_INVALID) {
|
||||
int num_fds;
|
||||
|
||||
num_fds = gbm_bo_get_plane_count(bo->gbm);
|
||||
if (num_fds > 0) {
|
||||
int i;
|
||||
uint32_t format;
|
||||
uint32_t handles[GBM_MAX_PLANES] = {0};
|
||||
uint32_t strides[GBM_MAX_PLANES] = {0};
|
||||
uint32_t offsets[GBM_MAX_PLANES] = {0};
|
||||
uint64_t modifiers[GBM_MAX_PLANES] = {0};
|
||||
|
||||
format = gbm_bo_get_format(bo->gbm);
|
||||
format = get_opaque_format(format);
|
||||
for (i = 0; i < num_fds; i++) {
|
||||
handles[i] = gbm_bo_get_handle_for_plane(bo->gbm, i).u32;
|
||||
strides[i] = gbm_bo_get_stride_for_plane(bo->gbm, i);
|
||||
offsets[i] = gbm_bo_get_offset(bo->gbm, i);
|
||||
modifiers[i] = gbm_bo_get_modifier(bo->gbm);
|
||||
}
|
||||
|
||||
return drmModeAddFB2WithModifiers(drmmode->fd, width, height,
|
||||
format, handles, strides,
|
||||
offsets, modifiers, fb_id,
|
||||
DRM_MODE_FB_MODIFIERS);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return drmModeAddFB(drmmode->fd, width, height,
|
||||
drmmode->scrn->depth, drmmode->kbpp,
|
||||
gbm_bo_get_stride(bo->gbm),
|
||||
gbm_bo_get_handle(bo->gbm).u32, fb_id);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,12 @@ struct gbm_bo*
|
||||
gbm_back_bo_from_fd(drmmode_ptr drmmode, Bool do_map,
|
||||
int fd_handle, uint32_t pitch, uint32_t size);
|
||||
|
||||
/* A bit of a misnomer, this is a dmabuf export */
|
||||
int
|
||||
drmmode_bo_import(drmmode_ptr drmmode, drmmode_bo *bo,
|
||||
uint32_t *fb_id);
|
||||
|
||||
|
||||
static inline uint32_t
|
||||
drmmode_gbm_format_for_depth(int depth)
|
||||
{
|
||||
|
||||
@@ -1116,52 +1116,6 @@ drmmode_bo_map(drmmode_ptr drmmode, drmmode_bo *bo)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
drmmode_bo_import(drmmode_ptr drmmode, drmmode_bo *bo,
|
||||
uint32_t *fb_id)
|
||||
{
|
||||
#ifdef GBM_BO_WITH_MODIFIERS
|
||||
modesettingPtr ms = modesettingPTR(drmmode->scrn);
|
||||
if (bo->gbm && ms->kms_has_modifiers &&
|
||||
gbm_bo_get_modifier(bo->gbm) != DRM_FORMAT_MOD_INVALID) {
|
||||
int num_fds;
|
||||
|
||||
num_fds = gbm_bo_get_plane_count(bo->gbm);
|
||||
if (num_fds > 0) {
|
||||
int i;
|
||||
uint32_t format;
|
||||
uint32_t handles[4];
|
||||
uint32_t strides[4];
|
||||
uint32_t offsets[4];
|
||||
uint64_t modifiers[4];
|
||||
|
||||
memset(handles, 0, sizeof(handles));
|
||||
memset(strides, 0, sizeof(strides));
|
||||
memset(offsets, 0, sizeof(offsets));
|
||||
memset(modifiers, 0, sizeof(modifiers));
|
||||
|
||||
format = gbm_bo_get_format(bo->gbm);
|
||||
format = get_opaque_format(format);
|
||||
for (i = 0; i < num_fds; i++) {
|
||||
handles[i] = gbm_bo_get_handle_for_plane(bo->gbm, i).u32;
|
||||
strides[i] = gbm_bo_get_stride_for_plane(bo->gbm, i);
|
||||
offsets[i] = gbm_bo_get_offset(bo->gbm, i);
|
||||
modifiers[i] = gbm_bo_get_modifier(bo->gbm);
|
||||
}
|
||||
|
||||
return drmModeAddFB2WithModifiers(drmmode->fd, bo->width, bo->height,
|
||||
format, handles, strides,
|
||||
offsets, modifiers, fb_id,
|
||||
DRM_MODE_FB_MODIFIERS);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return drmModeAddFB(drmmode->fd, bo->width, bo->height,
|
||||
drmmode->scrn->depth, drmmode->kbpp,
|
||||
drmmode_bo_get_pitch(bo),
|
||||
drmmode_bo_get_handle(bo), fb_id);
|
||||
}
|
||||
|
||||
static Bool
|
||||
drmmode_create_front_bo(drmmode_ptr drmmode, drmmode_bo *bo,
|
||||
unsigned width, unsigned height, unsigned bpp)
|
||||
|
||||
@@ -326,8 +326,6 @@ extern miPointerSpriteFuncRec drmmode_sprite_funcs;
|
||||
|
||||
Bool drmmode_is_format_supported(ScrnInfoPtr scrn, uint32_t format,
|
||||
uint64_t modifier, Bool async_flip);
|
||||
int drmmode_bo_import(drmmode_ptr drmmode, drmmode_bo *bo,
|
||||
uint32_t *fb_id);
|
||||
void drmmode_bo_destroy(drmmode_ptr drmmode, drmmode_bo *bo);
|
||||
uint32_t drmmode_bo_get_pitch(drmmode_bo *bo);
|
||||
Bool drmmode_glamor_handle_new_screen_pixmap(drmmode_ptr drmmode);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <xf86drm.h>
|
||||
|
||||
#include "driver.h"
|
||||
#include "drmmode_bo.h"
|
||||
|
||||
/*
|
||||
* Flush the DRM event queue when full; makes space for new events.
|
||||
|
||||
Reference in New Issue
Block a user