From 1cbd5ee024cc50d2d8ab69c3a2198509e563179f Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Sun, 14 Jul 2019 22:20:49 +0100 Subject: [PATCH] e wl randr and screen setup - fix rotation mapping a few problems i found on my rpi's... 1. rpi's retun that they do NO rotations (not even the normal 0 degree default), so assume 0 degrees if none listed. this makes screen setup even try and configure things on these kinds of drivers/devices 2. there was a mistmatch of 0, 90, 180, 270 srtyle rotation ints vs the enum stype ecore drm2 uses. this fixes that so it uses ecore_drm2 considtently as ecore_drm2 expects. this stops output becomeing odd. 3. also seemingly we forgot to set the max mouse region based on res. re-enable that commented out function. now i can change res on my rpi3 and rpi4 in wl mode and it works right... hooray! --- src/bin/e_randr2.c | 23 +++++++++++++++++--- src/modules/wl_drm/e_mod_main.c | 37 ++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/src/bin/e_randr2.c b/src/bin/e_randr2.c index ee319b79a..89617a995 100644 --- a/src/bin/e_randr2.c +++ b/src/bin/e_randr2.c @@ -479,6 +479,7 @@ _config_really_apply(E_Randr2_Screen *s, E_Config_Randr2_Screen *cs) s->config.mode.h = cs->mode_h; s->config.mode.refresh = cs->mode_refresh; s->config.mode.preferred = EINA_FALSE; + printf("RRR: really apply rotation=%i\n", cs->rotation); s->config.rotation = cs->rotation; s->config.priority = cs->priority; free(s->config.relative.to); @@ -918,6 +919,7 @@ _config_screen_clone_resolve(E_Config_Randr2 *cfg, const char *id, int *x, int * return _config_screen_clone_resolve(cfg, cs->rel_to, x, y); return NULL; } + printf("RRR: resolve clone... [%s]\n", cs->id); _screen_config_do(s); *x = s->config.geom.x; *y = s->config.geom.y; @@ -983,12 +985,17 @@ _screen_clones_common_sync(Eina_List *clones) int d, diff = 0x7fffffff; // find the base/root/master screen for clones + printf("RRR: find base/root for list=%p count=%i\n", clones, eina_list_count(clones)); EINA_LIST_FOREACH(clones, l, s) { // simple check - if it doesn't clone something else - then it's // the master (doesn't handle missing screens) - if (s->config.relative.mode != E_RANDR2_RELATIVE_CLONE) + printf("RRR: clone=%p mode=%i\n", s, s->config.relative.mode); + if ((s->config.relative.mode != E_RANDR2_RELATIVE_CLONE) && + (s->config.relative.mode != E_RANDR2_RELATIVE_NONE) && + (s->config.relative.mode != E_RANDR2_RELATIVE_UNKNOWN)) { + printf("RRR: got it\n"); sbase = s; break; } @@ -1000,6 +1007,7 @@ _screen_clones_common_sync(Eina_List *clones) modes = eina_list_append(modes, m); } // ensure it's configured + printf("RRR: clone common sync... %p %p\n", sbase, s); _screen_config_do(sbase); again: // we took all modes in the "master" @@ -1068,6 +1076,7 @@ again: s->config.mode.w = mcommon->w; s->config.mode.h = mcommon->h; s->config.mode.refresh = mcommon->refresh; + printf("RRR: clones common sync=%ix%i rotation=%i\n", s->config.mode.w, s->config.mode.h, s->config.rotation); if ((s->config.rotation == 0) || (s->config.rotation == 180)) { s->config.geom.w = s->config.mode.w; @@ -1119,6 +1128,7 @@ _screen_config_do(E_Randr2_Screen *s) } s->config.geom.x = 0; s->config.geom.y = 0; + printf("RRR: screen config do %ix%i rotation=%i\n", s->config.mode.w, s->config.mode.h, s->config.rotation); if ((s->config.rotation == 0) || (s->config.rotation == 180)) { s->config.geom.w = s->config.mode.w; @@ -1140,6 +1150,7 @@ _screen_config_do(E_Randr2_Screen *s) s->config.geom.h = s2->config.geom.h; s->config.mode.w = s2->config.mode.w; s->config.mode.h = s2->config.mode.h; + printf("RRR: screen config do rotation=%i\n", s2->config.rotation); s->config.rotation = s2->config.rotation; s->config.mode.refresh = s2->config.mode.refresh; } @@ -1193,6 +1204,7 @@ _screen_config_do(E_Randr2_Screen *s) s->config.geom.y = y; s->config.mode.w = cs->mode_w; s->config.mode.h = cs->mode_h; + printf("RRR: clone cs rotation=%i\n", cs->rotation); s->config.rotation = cs->rotation; s->config.mode.refresh = cs->mode_refresh; if ((cs->rotation == 0) || (cs->rotation == 180)) @@ -1218,15 +1230,20 @@ _screen_config_eval(void) E_Randr2_Screen *s; int minx, miny, maxx, maxy; + printf("RRR:--------------------------------1\n"); EINA_LIST_FOREACH(e_randr2->screens, l, s) { - if (s->config.configured) _screen_config_do(s); + if (s->config.configured) + { + printf("RRR: screen config eval this...\n"); + _screen_config_do(s); + } } minx = 65535; miny = 65535; maxx = -65536; maxy = -65536; - printf("RRR:--------------------------------\n"); + printf("RRR:--------------------------------2\n"); EINA_LIST_FOREACH(e_randr2->screens, l, s) { if (!s->config.enabled) continue; diff --git a/src/modules/wl_drm/e_mod_main.c b/src/modules/wl_drm/e_mod_main.c index db993f7f8..df262d2c9 100644 --- a/src/modules/wl_drm/e_mod_main.c +++ b/src/modules/wl_drm/e_mod_main.c @@ -396,7 +396,7 @@ _drm2_randr_create(void) if (ok) { - int rotations; + int rotations, outrot; if (!possible) { @@ -419,7 +419,22 @@ _drm2_randr_create(void) s->config.geom.w, s->config.geom.h); } - s->config.rotation = e_drm2_output_rotation_get(output); + outrot = e_drm2_output_rotation_get(output); + if (outrot & ECORE_DRM2_ROTATION_NORMAL) + s->config.rotation = 0; + else if (outrot & ECORE_DRM2_ROTATION_90) + s->config.rotation = 90; + else if (outrot & ECORE_DRM2_ROTATION_180) + s->config.rotation = 180; + else if (outrot & ECORE_DRM2_ROTATION_270) + s->config.rotation = 270; + else + { + printf("DRM2 RRR: caution - rotation flags empty - assum 0\n"); + s->config.rotation = 0; + } + + printf("DRM2 RRR: drm output rotation=%i\n", s->config.rotation); s->info.can_rot_0 = EINA_FALSE; s->info.can_rot_90 = EINA_FALSE; @@ -428,6 +443,10 @@ _drm2_randr_create(void) rotations = ecore_drm2_output_supported_rotations_get(output); + if (!(rotations & + (ECORE_DRM2_ROTATION_NORMAL | ECORE_DRM2_ROTATION_90 | + ECORE_DRM2_ROTATION_180 | ECORE_DRM2_ROTATION_270))) + rotations |= ECORE_DRM2_ROTATION_NORMAL; if (rotations & ECORE_DRM2_ROTATION_NORMAL) s->info.can_rot_0 = EINA_TRUE; @@ -532,6 +551,12 @@ _drm2_rotation_exists(Ecore_Drm2_Output *output, int rot) int rots; rots = ecore_drm2_output_supported_rotations_get(output); + printf("RRR: DRM2 ..... rots for %p rots=%x input=%x\n", output, rots, rot); + // hack for ... broken drivers that don't say anything about rotations + if (!(rots & + (ECORE_DRM2_ROTATION_NORMAL | ECORE_DRM2_ROTATION_90 | + ECORE_DRM2_ROTATION_180 | ECORE_DRM2_ROTATION_270))) + rots |= ECORE_DRM2_ROTATION_NORMAL; if (rots >= 0) { if ((rot == 0) && (rots & ECORE_DRM2_ROTATION_NORMAL)) @@ -544,6 +569,7 @@ _drm2_rotation_exists(Ecore_Drm2_Output *output, int rot) return EINA_TRUE; } + printf("RRR: DRM2 ..... no rot matches!\n"); return EINA_FALSE; } @@ -611,9 +637,10 @@ _drm2_randr_apply(void) printf("RRR: crtc slot empty: %i\n", i); if (ecore_drm2_output_possible_crtc_get(out, crtcs[i])) { + printf("RRR: output is possible...\n"); if (_drm2_rotation_exists(out, s->config.rotation)) { - printf("RRR: assign slot out: %p\n", out); + printf("RRR: assign slot out: %p\n", out); outconf[i] = out; screenconf[i] = s; break; @@ -696,9 +723,9 @@ _drm2_randr_apply(void) if (nh > maxh) nh = maxh; if (nw < minw) nw = minw; if (nh < minh) nh = minh; - printf("RRR: set vsize: %ix%i\n", nw, nh); + printf("RRR: set vsize: %ix%i, rot=%i\n", nw, nh, ecore_evas_rotation_get(e_comp->ee)); ecore_drm2_device_calibrate(dev, nw, nh); - /* ecore_drm2_device_pointer_max_set(dev, nw, nh); */ + ecore_drm2_device_pointer_max_set(dev, nw, nh); ecore_drm2_device_pointer_rotation_set(dev, ecore_evas_rotation_get(e_comp->ee)); if (!e_randr2_cfg->ignore_hotplug_events)