1From 5f484c213e6a508c4b602315f73eb206748caa1d Mon Sep 17 00:00:00 2001 2From: Jeffy Chen <jeffy.chen@rock-chips.com> 3Date: Fri, 1 Jul 2022 19:20:48 +0800 4Subject: [PATCH 06/10] ecore_drm2: Fallback to first possible CRTC of encoder 5 6TODO: Avoid using assigned CRTC. 7 8Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> 9--- 10 src/lib/ecore_drm2/ecore_drm2_outputs.c | 12 ++++++++---- 11 1 file changed, 8 insertions(+), 4 deletions(-) 12 13diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c b/src/lib/ecore_drm2/ecore_drm2_outputs.c 14index 77123c9..d7ff6a2 100644 15--- a/src/lib/ecore_drm2/ecore_drm2_outputs.c 16+++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c 17@@ -253,7 +253,7 @@ static int 18 _output_crtc_find(const drmModeRes *res, const drmModeConnector *conn, int fd) 19 { 20 drmModeEncoder *enc; 21- uint32_t crtc; 22+ uint32_t crtc, possible_crtcs; 23 int i = 0, j = 0; 24 25 /* Skip all disconnected connectors... 26@@ -271,8 +271,12 @@ _output_crtc_find(const drmModeRes *res, const drmModeConnector *conn, int fd) 27 if (!enc) continue; 28 29 crtc = enc->crtc_id; 30+ possible_crtcs = enc->possible_crtcs; 31 sym_drmModeFreeEncoder(enc); 32 33+ if (!crtc) 34+ return ffs(possible_crtcs) - 1; 35+ 36 for (i = 0; i < res->count_crtcs; i++) 37 if (crtc == res->crtcs[i]) 38 return i; 39@@ -1433,6 +1437,9 @@ ecore_drm2_output_possible_crtc_get(Ecore_Drm2_Output *output, unsigned int crtc 40 EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE); 41 EINA_SAFETY_ON_TRUE_RETURN_VAL((output->fd < 0), EINA_FALSE); 42 43+ if (output->crtc_id != crtc) 44+ return EINA_FALSE; 45+ 46 res = sym_drmModeGetResources(output->fd); 47 if (!res) return EINA_FALSE; 48 49@@ -1446,8 +1453,6 @@ ecore_drm2_output_possible_crtc_get(Ecore_Drm2_Output *output, unsigned int crtc 50 enc = sym_drmModeGetEncoder(output->fd, conn->encoders[j]); 51 if (!enc) continue; 52 53- if (enc->crtc_id != crtc) goto next; 54- 55 p = enc->possible_crtcs; 56 57 for (k = 0; k < res->count_crtcs; k++) 58@@ -1461,7 +1466,6 @@ ecore_drm2_output_possible_crtc_get(Ecore_Drm2_Output *output, unsigned int crtc 59 } 60 } 61 62-next: 63 sym_drmModeFreeEncoder(enc); 64 if (ret) break; 65 } 66-- 672.20.1 68 69