1From 7e43521bb942516f810dde29745ba9f8360708e0 Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Wed, 21 Oct 2020 15:27:38 +0800 4Subject: [PATCH 33/79] backend-drm: Support setting interlaced mode 5 6Tested with: 7echo "output:HDMI-A-1:mode=1920x1080i" > /tmp/.weston_drm.conf 8> Output HDMI-A-1 changed to 1920x1080i@60 for mode(1920x1080i) 9 10Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 11--- 12 libweston/backend-drm/drm.c | 4 ++-- 13 libweston/backend-drm/modes.c | 24 ++++++++++++++---------- 14 2 files changed, 16 insertions(+), 12 deletions(-) 15 16diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c 17index e829d77..3667b8d 100644 18--- a/libweston/backend-drm/drm.c 19+++ b/libweston/backend-drm/drm.c 20@@ -3575,9 +3575,9 @@ drm_output_modeset(struct drm_output *output, const char *modeline) 21 22 mode = to_drm_mode(output->base.current_mode); 23 24- weston_log("Output %s changed to %dx%d@%d for mode(%s)\n", 25+ weston_log("Output %s changed to %s@%d for mode(%s)\n", 26 output->base.name, 27- mode->mode_info.hdisplay, mode->mode_info.vdisplay, 28+ mode->mode_info.name, 29 mode->mode_info.vrefresh, 30 modeline); 31 32diff --git a/libweston/backend-drm/modes.c b/libweston/backend-drm/modes.c 33index ff7421d..25f61b8 100644 34--- a/libweston/backend-drm/modes.c 35+++ b/libweston/backend-drm/modes.c 36@@ -450,9 +450,8 @@ drm_output_print_modes(struct drm_output *output) 37 dm = to_drm_mode(m); 38 39 aspect_ratio = aspect_ratio_to_string(m->aspect_ratio); 40- weston_log_continue(STAMP_SPACE "%dx%d@%.1f%s%s%s, %.1f MHz\n", 41- dm->mode_info.hdisplay, 42- dm->mode_info.vdisplay, 43+ weston_log_continue(STAMP_SPACE "%s@%.1f%s%s%s, %.1f MHz\n", 44+ dm->mode_info.name, 45 m->refresh / 1000.0, 46 aspect_ratio, 47 m->flags & WL_OUTPUT_MODE_PREFERRED ? 48@@ -495,11 +494,14 @@ drm_output_choose_mode(struct drm_output *output, 49 enum weston_mode_aspect_ratio target_aspect = WESTON_MODE_PIC_AR_NONE; 50 struct drm_backend *b; 51 52+#define WESTON_MODE_NAME(mode) \ 53+ to_drm_mode(mode)->mode_info.name 54+ 55 b = to_drm_backend(output->base.compositor); 56 target_aspect = target_mode->aspect_ratio; 57 src_aspect = output->base.current_mode->aspect_ratio; 58- if (output->base.current_mode->width == target_mode->width && 59- output->base.current_mode->height == target_mode->height && 60+ if (!strcmp(WESTON_MODE_NAME(output->base.current_mode), 61+ WESTON_MODE_NAME(target_mode)) && 62 (output->base.current_mode->refresh == target_mode->refresh || 63 target_mode->refresh == 0)) { 64 if (!b->aspect_ratio_supported || src_aspect == target_aspect) 65@@ -509,8 +511,8 @@ drm_output_choose_mode(struct drm_output *output, 66 wl_list_for_each(mode, &output->base.mode_list, base.link) { 67 68 src_aspect = mode->base.aspect_ratio; 69- if (mode->mode_info.hdisplay == target_mode->width && 70- mode->mode_info.vdisplay == target_mode->height) { 71+ if (!strcmp(mode->mode_info.name, 72+ WESTON_MODE_NAME(target_mode))) { 73 if (mode->base.refresh == target_mode->refresh || 74 target_mode->refresh == 0) { 75 if (!b->aspect_ratio_supported || 76@@ -584,6 +586,7 @@ drm_output_choose_initial_mode(struct drm_backend *backend, 77 struct drm_mode *best = NULL; 78 struct drm_mode *drm_mode; 79 drmModeModeInfo drm_modeline; 80+ char name[16] = {0}; 81 int32_t width = 0; 82 int32_t height = 0; 83 uint32_t refresh = 0; 84@@ -593,7 +596,9 @@ drm_output_choose_initial_mode(struct drm_backend *backend, 85 int n; 86 87 if (mode == WESTON_DRM_BACKEND_OUTPUT_PREFERRED && modeline) { 88- n = sscanf(modeline, "%dx%d@%d %u:%u", &width, &height, 89+ sscanf(modeline, "%12[^@pP]", name); 90+ 91+ n = sscanf(modeline, "%dx%d%*[^0-9]%d %u:%u", &width, &height, 92 &refresh, &aspect_width, &aspect_height); 93 if (backend->aspect_ratio_supported && n == 5) { 94 if (aspect_width == 4 && aspect_height == 3) 95@@ -623,8 +628,7 @@ drm_output_choose_initial_mode(struct drm_backend *backend, 96 } 97 98 wl_list_for_each_reverse(drm_mode, &output->base.mode_list, base.link) { 99- if (width == drm_mode->mode_info.hdisplay && 100- height == drm_mode->mode_info.vdisplay && 101+ if (!strcmp(name, drm_mode->mode_info.name) && 102 (refresh == 0 || refresh == drm_mode->mode_info.vrefresh)) { 103 if (!backend->aspect_ratio_supported || 104 aspect_ratio == drm_mode->base.aspect_ratio) 105-- 1062.20.1 107 108