mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
backend/drm: fallback to drmModeAddFB2
This commit is contained in:
parent
e07ffaa249
commit
e8057bb60c
5 changed files with 25 additions and 11 deletions
|
@ -172,7 +172,8 @@ static bool atomic_crtc_set_cursor(struct wlr_drm_backend *drm,
|
||||||
atomic_begin(crtc, &atom);
|
atomic_begin(crtc, &atom);
|
||||||
|
|
||||||
if (bo) {
|
if (bo) {
|
||||||
uint32_t fb_id = get_fb_for_bo(bo, plane->drm_format);
|
uint32_t fb_id =
|
||||||
|
get_fb_for_bo(bo, plane->drm_format, drm->addfb2_modifiers);
|
||||||
set_plane_props(&atom, plane, crtc->id, fb_id, false);
|
set_plane_props(&atom, plane, crtc->id, fb_id, false);
|
||||||
} else {
|
} else {
|
||||||
atomic_add(&atom, plane->id, plane->props.fb_id, 0);
|
atomic_add(&atom, plane->id, plane->props.fb_id, 0);
|
||||||
|
|
|
@ -66,6 +66,9 @@ bool check_drm_features(struct wlr_drm_backend *drm) {
|
||||||
int ret = drmGetCap(drm->fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap);
|
int ret = drmGetCap(drm->fd, DRM_CAP_TIMESTAMP_MONOTONIC, &cap);
|
||||||
drm->clock = (ret == 0 && cap == 1) ? CLOCK_MONOTONIC : CLOCK_REALTIME;
|
drm->clock = (ret == 0 && cap == 1) ? CLOCK_MONOTONIC : CLOCK_REALTIME;
|
||||||
|
|
||||||
|
ret = drmGetCap(drm->fd, DRM_CAP_ADDFB2_MODIFIERS, &cap);
|
||||||
|
drm->addfb2_modifiers = ret == 0 && cap == 1;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +322,7 @@ static bool drm_connector_commit(struct wlr_output *output) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fb_id = get_fb_for_bo(bo, plane->drm_format);
|
fb_id = get_fb_for_bo(bo, plane->drm_format, drm->addfb2_modifiers);
|
||||||
if (fb_id == 0) {
|
if (fb_id == 0) {
|
||||||
wlr_log(WLR_ERROR, "get_fb_for_bo failed");
|
wlr_log(WLR_ERROR, "get_fb_for_bo failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -332,7 +335,7 @@ static bool drm_connector_commit(struct wlr_output *output) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fb_id = get_fb_for_bo(bo, gbm_bo_get_format(bo));
|
fb_id = get_fb_for_bo(bo, gbm_bo_get_format(bo), drm->addfb2_modifiers);
|
||||||
if (fb_id == 0) {
|
if (fb_id == 0) {
|
||||||
wlr_log(WLR_ERROR, "get_fb_for_bo failed");
|
wlr_log(WLR_ERROR, "get_fb_for_bo failed");
|
||||||
return false;
|
return false;
|
||||||
|
@ -462,7 +465,7 @@ static void drm_connector_start_renderer(struct wlr_drm_connector *conn) {
|
||||||
|
|
||||||
struct gbm_bo *bo = get_drm_surface_front(
|
struct gbm_bo *bo = get_drm_surface_front(
|
||||||
drm->parent ? &plane->mgpu_surf : &plane->surf);
|
drm->parent ? &plane->mgpu_surf : &plane->surf);
|
||||||
uint32_t fb_id = get_fb_for_bo(bo, plane->drm_format);
|
uint32_t fb_id = get_fb_for_bo(bo, plane->drm_format, drm->addfb2_modifiers);
|
||||||
|
|
||||||
struct wlr_drm_mode *mode = (struct wlr_drm_mode *)conn->output.current_mode;
|
struct wlr_drm_mode *mode = (struct wlr_drm_mode *)conn->output.current_mode;
|
||||||
if (drm->iface->crtc_pageflip(drm, conn, crtc, fb_id, &mode->drm_mode)) {
|
if (drm->iface->crtc_pageflip(drm, conn, crtc, fb_id, &mode->drm_mode)) {
|
||||||
|
@ -887,7 +890,7 @@ static bool drm_connector_schedule_frame(struct wlr_output *output) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t fb_id = get_fb_for_bo(bo, plane->drm_format);
|
uint32_t fb_id = get_fb_for_bo(bo, plane->drm_format, drm->addfb2_modifiers);
|
||||||
if (!drm->iface->crtc_pageflip(drm, conn, crtc, fb_id, NULL)) {
|
if (!drm->iface->crtc_pageflip(drm, conn, crtc, fb_id, NULL)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,8 @@ static void free_fb(struct gbm_bo *bo, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t get_fb_for_bo(struct gbm_bo *bo, uint32_t drm_format) {
|
uint32_t get_fb_for_bo(struct gbm_bo *bo, uint32_t drm_format,
|
||||||
|
bool with_modifiers) {
|
||||||
uint32_t id = (uintptr_t)gbm_bo_get_user_data(bo);
|
uint32_t id = (uintptr_t)gbm_bo_get_user_data(bo);
|
||||||
if (id) {
|
if (id) {
|
||||||
return id;
|
return id;
|
||||||
|
@ -192,12 +193,19 @@ uint32_t get_fb_for_bo(struct gbm_bo *bo, uint32_t drm_format) {
|
||||||
uint32_t handles[4] = {gbm_bo_get_handle(bo).u32};
|
uint32_t handles[4] = {gbm_bo_get_handle(bo).u32};
|
||||||
uint32_t strides[4] = {gbm_bo_get_stride(bo)};
|
uint32_t strides[4] = {gbm_bo_get_stride(bo)};
|
||||||
uint32_t offsets[4] = {gbm_bo_get_offset(bo, 0)};
|
uint32_t offsets[4] = {gbm_bo_get_offset(bo, 0)};
|
||||||
uint64_t modifiers[4] = {gbm_bo_get_modifier(bo)};
|
|
||||||
|
|
||||||
if (drmModeAddFB2WithModifiers(fd, width, height, drm_format,
|
if (with_modifiers && gbm_bo_get_modifier(bo) != DRM_FORMAT_MOD_INVALID) {
|
||||||
handles, strides, offsets, modifiers, &id, DRM_MODE_FB_MODIFIERS)) {
|
uint64_t modifiers[4] = {gbm_bo_get_modifier(bo)};
|
||||||
|
if (drmModeAddFB2WithModifiers(fd, width, height, drm_format, handles,
|
||||||
|
strides, offsets, modifiers, &id, DRM_MODE_FB_MODIFIERS)) {
|
||||||
wlr_log_errno(WLR_ERROR, "Unable to add DRM framebuffer");
|
wlr_log_errno(WLR_ERROR, "Unable to add DRM framebuffer");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (drmModeAddFB2(fd, width, height, drm_format, handles, strides,
|
||||||
|
offsets, &id, 0)) {
|
||||||
|
wlr_log_errno(WLR_ERROR, "Unable to add DRM framebuffer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gbm_bo_set_user_data(bo, (void *)(uintptr_t)id, free_fb);
|
gbm_bo_set_user_data(bo, (void *)(uintptr_t)id, free_fb);
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ struct wlr_drm_backend {
|
||||||
struct wlr_drm_backend *parent;
|
struct wlr_drm_backend *parent;
|
||||||
const struct wlr_drm_interface *iface;
|
const struct wlr_drm_interface *iface;
|
||||||
clockid_t clock;
|
clockid_t clock;
|
||||||
|
bool addfb2_modifiers;
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@ void parse_edid(struct wlr_output *restrict output, size_t len,
|
||||||
// Returns the string representation of a DRM output type
|
// Returns the string representation of a DRM output type
|
||||||
const char *conn_get_name(uint32_t type_id);
|
const char *conn_get_name(uint32_t type_id);
|
||||||
// Returns the DRM framebuffer id for a gbm_bo
|
// Returns the DRM framebuffer id for a gbm_bo
|
||||||
uint32_t get_fb_for_bo(struct gbm_bo *bo, uint32_t drm_format);
|
uint32_t get_fb_for_bo(struct gbm_bo *bo, uint32_t drm_format,
|
||||||
|
bool with_modifiers);
|
||||||
|
|
||||||
// Part of match_obj
|
// Part of match_obj
|
||||||
enum {
|
enum {
|
||||||
|
|
Loading…
Reference in a new issue