backend-drm: remove unecessary ifdef checks

Since commit 28d26483 ("build: bump libdrm requirement to newer version
(2.4.83)"), all supported libdrm versions provide modifier formats,
atomic API and blob formats. Remove ifdef checks (HAVE_DRM_ADDFB2_MODIFIERS,
HAVE_DRM_ATOMIC, HAVE_DRM_FORMATS_BLOB) to improve the code and make it
simpler.

Signed-off-by: Leandro Ribeiro <leandrohr@riseup.net>
This commit is contained in:
Leandro Ribeiro 2019-11-22 16:55:56 -03:00 committed by Daniel Stone
parent 94e4068ba1
commit 6196b201be
3 changed files with 0 additions and 40 deletions

View file

@ -74,17 +74,14 @@ static int
drm_fb_addfb(struct drm_backend *b, struct drm_fb *fb)
{
int ret = -EINVAL;
#ifdef HAVE_DRM_ADDFB2_MODIFIERS
uint64_t mods[4] = { };
size_t i;
#endif
/* If we have a modifier set, we must only use the WithModifiers
* entrypoint; we cannot import it through legacy ioctls. */
if (b->fb_modifiers && fb->modifier != DRM_FORMAT_MOD_INVALID) {
/* KMS demands that if a modifier is set, it must be the same
* for all planes. */
#ifdef HAVE_DRM_ADDFB2_MODIFIERS
for (i = 0; i < ARRAY_LENGTH(mods) && fb->handles[i]; i++)
mods[i] = fb->modifier;
ret = drmModeAddFB2WithModifiers(fb->fd, fb->width, fb->height,
@ -92,7 +89,6 @@ drm_fb_addfb(struct drm_backend *b, struct drm_fb *fb)
fb->handles, fb->strides,
fb->offsets, mods, &fb->fb_id,
DRM_MODE_FB_MODIFIERS);
#endif
return ret;
}

View file

@ -403,7 +403,6 @@ drm_property_info_free(struct drm_property_info *info, int num_props)
memset(info, 0, sizeof(*info) * num_props);
}
#ifdef HAVE_DRM_FORMATS_BLOB
static inline uint32_t *
formats_ptr(struct drm_format_modifier_blob *blob)
{
@ -416,7 +415,6 @@ modifiers_ptr(struct drm_format_modifier_blob *blob)
return (struct drm_format_modifier *)
(((char *)blob) + blob->modifiers_offset);
}
#endif
/**
* Populates the plane's formats array, using either the IN_FORMATS blob
@ -427,7 +425,6 @@ drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane,
const drmModeObjectProperties *props)
{
unsigned i;
#ifdef HAVE_DRM_FORMATS_BLOB
drmModePropertyBlobRes *blob;
struct drm_format_modifier_blob *fmt_mod_blob;
struct drm_format_modifier *blob_modifiers;
@ -494,7 +491,6 @@ drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane,
return 0;
fallback:
#endif
/* No IN_FORMATS blob available, so just use the old. */
assert(plane->count_formats == kplane->count_formats);
for (i = 0; i < kplane->count_formats; i++) {
@ -782,7 +778,6 @@ err:
return -1;
}
#ifdef HAVE_DRM_ATOMIC
static int
crtc_add_prop(drmModeAtomicReq *req, struct drm_output *output,
enum wdrm_crtc_property prop, uint64_t val)
@ -1241,7 +1236,6 @@ out:
drm_pending_state_free(pending_state);
return ret;
}
#endif
/**
* Tests a pending state, to see if the kernel will accept the update as
@ -1264,13 +1258,11 @@ out:
int
drm_pending_state_test(struct drm_pending_state *pending_state)
{
#ifdef HAVE_DRM_ATOMIC
struct drm_backend *b = pending_state->backend;
if (b->atomic_modeset)
return drm_pending_state_apply_atomic(pending_state,
DRM_STATE_TEST_ONLY);
#endif
/* We have no way to test state before application on the legacy
* modesetting API, so just claim it succeeded. */
@ -1291,11 +1283,9 @@ drm_pending_state_apply(struct drm_pending_state *pending_state)
struct drm_output_state *output_state, *tmp;
uint32_t *unused;
#ifdef HAVE_DRM_ATOMIC
if (b->atomic_modeset)
return drm_pending_state_apply_atomic(pending_state,
DRM_STATE_APPLY_ASYNC);
#endif
if (b->state_invalid) {
/* If we need to reset all our state (e.g. because we've
@ -1349,11 +1339,9 @@ drm_pending_state_apply_sync(struct drm_pending_state *pending_state)
struct drm_output_state *output_state, *tmp;
uint32_t *unused;
#ifdef HAVE_DRM_ATOMIC
if (b->atomic_modeset)
return drm_pending_state_apply_atomic(pending_state,
DRM_STATE_APPLY_SYNC);
#endif
if (b->state_invalid) {
/* If we need to reset all our state (e.g. because we've
@ -1417,7 +1405,6 @@ page_flip_handler(int fd, unsigned int frame,
drm_output_update_complete(output, flags, sec, usec);
}
#ifdef HAVE_DRM_ATOMIC
static void
atomic_flip_handler(int fd, unsigned int frame, unsigned int sec,
unsigned int usec, unsigned int crtc_id, void *data)
@ -1444,25 +1431,18 @@ atomic_flip_handler(int fd, unsigned int frame, unsigned int sec,
drm_output_update_complete(output, flags, sec, usec);
drm_debug(b, "[atomic][CRTC:%u] flip processing completed\n", crtc_id);
}
#endif
int
on_drm_input(int fd, uint32_t mask, void *data)
{
#ifdef HAVE_DRM_ATOMIC
struct drm_backend *b = data;
#endif
drmEventContext evctx;
memset(&evctx, 0, sizeof evctx);
#ifndef HAVE_DRM_ATOMIC
evctx.version = 2;
#else
evctx.version = 3;
if (b->atomic_modeset)
evctx.page_flip_handler2 = atomic_flip_handler;
else
#endif
evctx.page_flip_handler = page_flip_handler;
drmHandleEvent(fd, &evctx);
@ -1509,7 +1489,6 @@ init_kms_caps(struct drm_backend *b)
weston_log("DRM: %s universal planes\n",
b->universal_planes ? "supports" : "does not support");
#ifdef HAVE_DRM_ATOMIC
if (b->universal_planes && !getenv("WESTON_DISABLE_ATOMIC")) {
ret = drmGetCap(b->drm.fd, DRM_CAP_CRTC_IN_VBLANK_EVENT, &cap);
if (ret != 0)
@ -1517,16 +1496,13 @@ init_kms_caps(struct drm_backend *b)
ret = drmSetClientCap(b->drm.fd, DRM_CLIENT_CAP_ATOMIC, 1);
b->atomic_modeset = ((ret == 0) && (cap == 1));
}
#endif
weston_log("DRM: %s atomic modesetting\n",
b->atomic_modeset ? "supports" : "does not support");
#ifdef HAVE_DRM_ADDFB2_MODIFIERS
ret = drmGetCap(b->drm.fd, DRM_CAP_ADDFB2_MODIFIERS, &cap);
if (ret == 0)
b->fb_modifiers = cap;
else
#endif
b->fb_modifiers = 0;
/*

View file

@ -79,18 +79,6 @@ if get_option('remoting')
config_h.set('BUILD_DRM_VIRTUAL', '1')
endif
if dep_libdrm.version().version_compare('>= 2.4.71')
config_h.set('HAVE_DRM_ADDFB2_MODIFIERS', '1')
endif
if dep_libdrm.version().version_compare('>= 2.4.78')
config_h.set('HAVE_DRM_ATOMIC', '1')
endif
if dep_libdrm.version().version_compare('>= 2.4.83')
config_h.set('HAVE_DRM_FORMATS_BLOB', '1')
endif
plugin_drm = shared_library(
'drm-backend',
srcs_drm,