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,
fb->handles, fb->strides,
fb->offsets, mods, &fb->fb_id,
DRM_MODE_FB_MODIFIERS);
-#endif
return ret;
}
memset(info, 0, sizeof(*info) * num_props);
}
-#ifdef HAVE_DRM_FORMATS_BLOB
static inline uint32_t *
formats_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
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;
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++) {
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)
drm_pending_state_free(pending_state);
return ret;
}
-#endif
/**
* Tests a pending state, to see if the kernel will accept the update as
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. */
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
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
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)
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);
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)
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;
/*