From 56ddd871897d34e7e30abc569bbd08aedde72a9f Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Fri, 14 Jul 2023 14:38:47 +0800 Subject: [PATCH] debug --- src/newgal/drm/drmvideo.c | 54 ++++++++++++++++++-------------------- src/newgal/fbcon/fbvideo.c | 11 +++++--- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/newgal/drm/drmvideo.c b/src/newgal/drm/drmvideo.c index 8223e836..52c3e8dc 100644 --- a/src/newgal/drm/drmvideo.c +++ b/src/newgal/drm/drmvideo.c @@ -47,7 +47,7 @@ #include #include -// #define _DEBUG +#define _DEBUG #include "common.h" @@ -1827,14 +1827,30 @@ done: vdata->crtc_idx = pipe; return pipe; #else - int i; + int pipe = -1; - for (i = 0; i < res->count_crtcs; ++i) { - if (res->crtcs[i] == id) - return i; + for (int i = 0; i < 66; i++) { + drmVBlank vbl; + memset(&vbl, 0, sizeof(vbl)); + vbl.request.type = DRM_VBLANK_RELATIVE; + if (vdata->cap_vblank_high_crtc) + vbl.request.type |= + (i << DRM_VBLANK_HIGH_CRTC_SHIFT); + vbl.request.sequence = 1; + vbl.request.signal = 0; + _DBG_PRINTF("VBL type: 0x%08x\n", vbl.request.type); + if (drmWaitVBlank(vdata->dev_fd, &vbl)) { + _WRN_PRINTF("Failed drmWaitVBlank(%d): %m\n", i); + } + else { + pipe = i; + _DBG_PRINTF("Found crtc_idx: %d\n", i); + break; + } } - return -1; + vdata->crtc_idx = pipe; + return pipe; #endif } @@ -2540,27 +2556,6 @@ static void* task_do_update(void *data) BOOL vbl_ok = FALSE; drmVBlank vbl; -#if 0 - for (int i = 0; i < 65; i++) { - memset(&vbl, 0, sizeof(vbl)); - vbl.request.type = DRM_VBLANK_RELATIVE; - if (this->hidden->cap_vblank_high_crtc) - vbl.request.type |= - (i << DRM_VBLANK_HIGH_CRTC_SHIFT); - vbl.request.sequence = 1; - vbl.request.signal = 0; - _DBG_PRINTF("VBL type: 0x%08x\n", vbl.request.type); - if (drmWaitVBlank(this->hidden->dev_fd, &vbl)) { - _WRN_PRINTF("Failed drmWaitVBlank(%d): %m\n", i); - } - else { - vbl_ok = TRUE; - this->hidden->crtc_idx = i; - _DBG_PRINTF("Found crtc_idx: %d\n", i); - break; - } - } -#else if (this->hidden->crtc_idx >= 0) { memset(&vbl, 0, sizeof(vbl)); vbl.request.type = DRM_VBLANK_RELATIVE; @@ -2575,10 +2570,8 @@ static void* task_do_update(void *data) } else { vbl_ok = TRUE; - this->WaitVBlank = DRM_WaitVBlank; } } -#endif this->hidden->updater_ready = 1; sem_post(&this->hidden->sync_sem); @@ -2747,6 +2740,9 @@ static GAL_Surface *DRM_SetVideoMode(_THIS, GAL_Surface *current, goto error; } + if (vdata->crtc_idx >= 0) + this->WaitVBlank = DRM_WaitVBlank; + vdata->real_screen = create_surface_from_buffer (this, real_buffer, bpp, RGBAmasks); if (vdata->real_screen == NULL) diff --git a/src/newgal/fbcon/fbvideo.c b/src/newgal/fbcon/fbvideo.c index a9dfee40..d2104027 100644 --- a/src/newgal/fbcon/fbvideo.c +++ b/src/newgal/fbcon/fbvideo.c @@ -191,11 +191,12 @@ static BOOL FB_SyncUpdatePanning (_THIS) static BOOL FB_WaitVBlank(_THIS) { + int dummy; if (wait_vbl) { wait_vbl(this); } - else if (ioctl(console_fd, FBIO_WAITFORVSYNC, 0)) { - _WRN_PRINTF("Failed VSync.\n"); + else if (ioctl(console_fd, FBIO_WAITFORVSYNC, &dummy)) { + _DBG_PRINTF("Failed VSync: %m\n"); return FALSE; } @@ -903,10 +904,12 @@ static GAL_Surface *FB_SetVideoMode(_THIS, GAL_Surface *current, } } - if (FB_WaitVBlank(this)) + if (FB_WaitVBlank(this)) { this->WaitVBlank = FB_WaitVBlank; - else + } + else { _WRN_PRINTF("The FBCon device does not support VSync.\n"); + } /* We're done */ return (current);