1From 8bf03f5eb10235ba285bc8f841d2312f14eb17c4 Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Mon, 7 Mar 2022 17:20:59 +0800 4Subject: [PATCH 61/95] backend-drm: Allow overriding plane type when using 5 atomic 6 7Set env DRM_PLANE_TYPE_<plane id> to primary|overlay|cursor. 8 9Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 10--- 11 libweston/backend-drm/drm-internal.h | 3 +++ 12 libweston/backend-drm/drm.c | 6 ++---- 13 libweston/backend-drm/kms.c | 29 ++++++++++++++++++++++++++++ 14 3 files changed, 34 insertions(+), 4 deletions(-) 15 16diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h 17index f7f042d..b7deeb0 100644 18--- a/libweston/backend-drm/drm-internal.h 19+++ b/libweston/backend-drm/drm-internal.h 20@@ -792,6 +792,9 @@ drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane, 21 void 22 drm_property_info_free(struct drm_property_info *info, int num_props); 23 24+enum wdrm_plane_type 25+drm_plane_get_type(struct drm_plane *plane, drmModeObjectProperties *props); 26+ 27 extern struct drm_property_enum_info plane_type_enums[]; 28 extern const struct drm_property_info plane_props[]; 29 extern struct drm_property_enum_info dpms_state_enums[]; 30diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c 31index 2ab08df..cb40715 100644 32--- a/libweston/backend-drm/drm.c 33+++ b/libweston/backend-drm/drm.c 34@@ -1207,10 +1207,8 @@ drm_plane_create(struct drm_device *device, const drmModePlane *kplane) 35 36 drm_property_info_populate(device, plane_props, plane->props, 37 WDRM_PLANE__COUNT, props); 38- plane->type = 39- drm_property_get_value(&plane->props[WDRM_PLANE_TYPE], 40- props, 41- WDRM_PLANE_TYPE__COUNT); 42+ 43+ plane->type = drm_plane_get_type(plane, props); 44 45 plane->can_scale = 46 drm_property_has_feature(plane->props, 47diff --git a/libweston/backend-drm/kms.c b/libweston/backend-drm/kms.c 48index 690ada0..122160c 100644 49--- a/libweston/backend-drm/kms.c 50+++ b/libweston/backend-drm/kms.c 51@@ -461,6 +461,35 @@ drm_property_info_free(struct drm_property_info *info, int num_props) 52 memset(info, 0, sizeof(*info) * num_props); 53 } 54 55+enum wdrm_plane_type 56+drm_plane_get_type(struct drm_plane *plane, drmModeObjectProperties *props) 57+{ 58+ struct drm_device *device = plane->device; 59+ enum wdrm_plane_type type; 60+ const char *env; 61+ char buf[256]; 62+ 63+ type = drm_property_get_value(&plane->props[WDRM_PLANE_TYPE], 64+ props, 65+ WDRM_PLANE_TYPE__COUNT); 66+ if (!device->atomic_modeset) 67+ return type; 68+ 69+ snprintf(buf, sizeof(buf), "DRM_PLANE_TYPE_%d", plane->plane_id); 70+ env = getenv(buf); 71+ if (!env) 72+ return type; 73+ 74+ if (!strcmp(env, "primary")) 75+ return WDRM_PLANE_TYPE_PRIMARY; 76+ else if (!strcmp(env, "overlay")) 77+ return WDRM_PLANE_TYPE_OVERLAY; 78+ else if (!strcmp(env, "cursor")) 79+ return WDRM_PLANE_TYPE_CURSOR; 80+ 81+ return type; 82+} 83+ 84 /** 85 * Populates the plane's formats array, using either the IN_FORMATS blob 86 * property (if available), or the plane's format list if not. 87-- 882.20.1 89 90