From 7299d2a275190a293f2191ee72ebb6cef270f61d Mon Sep 17 00:00:00 2001 From: Oliver Clarke Date: Wed, 2 Sep 2026 08:40:30 -0500 Subject: [PATCH] drm/apple: Use preferred display mode from dcp The DCP display properties contains a preferred mode flag. This patch takes that into account when picking which mode to assign DRM_MODE_TYPE_PREFERRED Note: the mode with the highest DCP score isn't necessarily the best mode, the IsPreferred flag in DCP needs to be taken into account as well. We add (1 << 32) to the score when the preferred flag is set for simplicity. Signed-off-by: Oliver Clarke --- drivers/gpu/drm/apple/parser.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/apple/parser.c b/drivers/gpu/drm/apple/parser.c index 56960fa1fda265..74f268212db3f3 100644 --- a/drivers/gpu/drm/apple/parser.c +++ b/drivers/gpu/drm/apple/parser.c @@ -452,6 +452,7 @@ static int parse_mode(struct dcp_parse_ctx *handle, s64 id = -1; s64 best_color_mode = -1; bool is_virtual = false; + bool is_preferred = false; struct drm_display_mode *mode = &out->mode; dcp_parse_foreach_in_dict(handle, it) { @@ -475,6 +476,8 @@ static int parse_mode(struct dcp_parse_ctx *handle, ret = parse_int(it.handle, &id); else if (!strcmp(key, "IsVirtual")) ret = parse_bool(it.handle, &is_virtual); + else if (!strcmp(key, "IsPreferred")) + ret = parse_bool(it.handle, &is_preferred); else if (!strcmp(key, "Score")) ret = parse_int(it.handle, score); else @@ -488,6 +491,11 @@ static int parse_mode(struct dcp_parse_ctx *handle, return ret; } } + + if (is_preferred) { + *score |= (1L << 32); + } + if (out->sdr_rgb.score >= 0) best_color_mode = out->sdr_rgb.id; else if (out->sdr_444.score >= 0)