From 6093772f45a4c451703b73e3894d77077645fb7f Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 26 Nov 2019 10:48:12 +0000 Subject: [PATCH] backend-drm: Use aspect-ratio bit definitions from libdrm When the aspect-ratio-aware mode support was added to Weston, it was done before the libdrm support was finalised and merged. Between it being added to Weston and being merged, it changed to no longer provide the offset for the bitmask. Instead of using the mask and a compatible enum, if we update our libdrm dependency, we can use the flag definitions directly from libdrm. In 94e4068ba171, the libdrm dependency was bumped to 2.4.83, which enabled us to remove a bunch of error-prone ifdefs by making atomic and modifier support mandatory. We determined in the discussion of !311 that it was safe to push the dependency as high as 2.4.91, as that was what was available in major distributions. Bumping to 2.4.86 allows us to safely remove the ifdef and go with upstream flags, as that was added in mesa/drm@0d889201d106. Signed-off-by: Daniel Stone --- libweston/backend-drm/drm-internal.h | 9 --------- libweston/backend-drm/modes.c | 15 +++++++++++++-- meson.build | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h index 21bece8d..975fa268 100644 --- a/libweston/backend-drm/drm-internal.h +++ b/libweston/backend-drm/drm-internal.h @@ -114,15 +114,6 @@ #define MAX_CLONED_CONNECTORS 4 -/** - * aspect ratio info taken from the drmModeModeInfo flag bits 19-22, - * which should be used to fill the aspect ratio field in weston_mode. - */ -#define DRM_MODE_FLAG_PIC_AR_BITS_POS 19 -#ifndef DRM_MODE_FLAG_PIC_AR_MASK -#define DRM_MODE_FLAG_PIC_AR_MASK (0xF << DRM_MODE_FLAG_PIC_AR_BITS_POS) -#endif - /** * Represents the values of an enum-type KMS property */ diff --git a/libweston/backend-drm/modes.c b/libweston/backend-drm/modes.c index 12514cfe..7c45e50a 100644 --- a/libweston/backend-drm/modes.c +++ b/libweston/backend-drm/modes.c @@ -52,8 +52,19 @@ static const char *const aspect_ratio_as_string[] = { static enum weston_mode_aspect_ratio drm_to_weston_mode_aspect_ratio(uint32_t drm_mode_flags) { - return (drm_mode_flags & DRM_MODE_FLAG_PIC_AR_MASK) >> - DRM_MODE_FLAG_PIC_AR_BITS_POS; + switch (drm_mode_flags & DRM_MODE_FLAG_PIC_AR_MASK) { + case DRM_MODE_FLAG_PIC_AR_4_3: + return WESTON_MODE_PIC_AR_4_3; + case DRM_MODE_FLAG_PIC_AR_16_9: + return WESTON_MODE_PIC_AR_16_9; + case DRM_MODE_FLAG_PIC_AR_64_27: + return WESTON_MODE_PIC_AR_64_27; + case DRM_MODE_FLAG_PIC_AR_256_135: + return WESTON_MODE_PIC_AR_256_135; + case DRM_MODE_FLAG_PIC_AR_NONE: + default: + return WESTON_MODE_PIC_AR_NONE; + } } static const char * diff --git a/meson.build b/meson.build index 764a1960..f1fa6ba6 100644 --- a/meson.build +++ b/meson.build @@ -139,7 +139,7 @@ dep_libinput = dependency('libinput', version: '>= 0.8.0') dep_libevdev = dependency('libevdev') dep_libm = cc.find_library('m') dep_libdl = cc.find_library('dl') -dep_libdrm = dependency('libdrm', version: '>= 2.4.83') +dep_libdrm = dependency('libdrm', version: '>= 2.4.86') dep_libdrm_headers = dep_libdrm.partial_dependency(compile_args: true) dep_threads = dependency('threads')