This commit is contained in:
Vincent Wei
2023-07-14 14:38:47 +08:00
parent 5cdd258046
commit 56ddd87189
2 changed files with 32 additions and 33 deletions
+25 -29
View File
@@ -47,7 +47,7 @@
#include <stdlib.h>
#include <string.h>
// #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)
+7 -4
View File
@@ -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);