backend-drm: Use aspect-ratio bit definitions from libdrm
authorDaniel Stone <daniels@collabora.com>
Tue, 26 Nov 2019 10:48:12 +0000 (10:48 +0000)
committerDaniel Stone <daniels@collabora.com>
Wed, 27 Nov 2019 17:52:16 +0000 (17:52 +0000)
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 <daniels@collabora.com>
libweston/backend-drm/drm-internal.h
libweston/backend-drm/modes.c
meson.build

index 21bece8d274638321d4be1b4fb8a59a26b452942..975fa2687a36d2edbcffa3e469d2d02120de5a1a 100644 (file)
 
 #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
  */
index 12514cfe4eff2f5e1ca6b5c814ed6e1fec62dec2..7c45e50a0be4b9914e974bffb087ac274114ec01 100644 (file)
@@ -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 *
index 764a196038967d4960f83ba0258aba0be7b63520..f1fa6ba6ed71821a43108ad0bcc9f1a8b257edd9 100644 (file)
@@ -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')