mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-23 08:33:55 +08:00
use WaitVBlank
This commit is contained in:
@@ -120,6 +120,7 @@ static int DRM_FillHWRect_Accl(_THIS, GAL_Surface *dst, GAL_Rect *rect,
|
||||
Uint32 color);
|
||||
|
||||
static void DRM_UpdateRects(_THIS, int numrects, GAL_Rect *rects);
|
||||
static BOOL DRM_WaitVBlank(_THIS);
|
||||
static BOOL DRM_SyncUpdate(_THIS);
|
||||
static BOOL DRM_SyncUpdateAsync(_THIS);
|
||||
|
||||
@@ -2574,6 +2575,7 @@ static void* task_do_update(void *data)
|
||||
}
|
||||
else {
|
||||
vbl_ok = TRUE;
|
||||
this->WaitVBlank = DRM_WaitVBlank;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -3713,6 +3715,21 @@ static void DRM_UpdateRects (_THIS, int numrects, GAL_Rect *rects)
|
||||
#endif
|
||||
}
|
||||
|
||||
static BOOL DRM_WaitVBlank(_THIS)
|
||||
{
|
||||
drmVBlank vbl;
|
||||
vbl.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_NEXTONMISS;
|
||||
if (this->hidden->cap_vblank_high_crtc)
|
||||
vbl.request.type |=
|
||||
(this->hidden->crtc_idx << DRM_VBLANK_HIGH_CRTC_SHIFT);
|
||||
vbl.request.sequence = 1;
|
||||
vbl.request.signal = 0;
|
||||
if (drmWaitVBlank(this->hidden->dev_fd, &vbl))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL DRM_SyncUpdate(_THIS)
|
||||
{
|
||||
BOOL retval = FALSE;
|
||||
|
||||
+18
-17
@@ -99,8 +99,6 @@ static void FB_RequestHWSurface (_THIS, const REQ_HWSURFACE* request,
|
||||
REP_HWSURFACE* reply);
|
||||
static int FB_AllocHWSurface(_THIS, GAL_Surface *surface);
|
||||
static void FB_FreeHWSurface(_THIS, GAL_Surface *surface);
|
||||
static void FB_WaitVBL(_THIS);
|
||||
static void FB_WaitIdle(_THIS);
|
||||
|
||||
#include "../shadow-screen.h"
|
||||
#include "debug.h"
|
||||
@@ -191,6 +189,19 @@ static BOOL FB_SyncUpdatePanning (_THIS)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL FB_WaitVBlank(_THIS)
|
||||
{
|
||||
if (wait_vbl) {
|
||||
wait_vbl(this);
|
||||
}
|
||||
else if (ioctl(console_fd, FBIO_WAITFORVSYNC, 0)) {
|
||||
_WRN_PRINTF("Failed VSync.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL FB_SyncUpdate (_THIS)
|
||||
{
|
||||
if (IsRectEmpty (&this->hidden->dirty_rc))
|
||||
@@ -269,8 +280,6 @@ static GAL_VideoDevice *FB_CreateDevice(int devindex)
|
||||
memset(this->hidden, 0, (sizeof *this->hidden));
|
||||
this->hidden->magic = MAGIC_SHADOW_SCREEN_HEADER;
|
||||
this->hidden->version = 0;
|
||||
wait_vbl = FB_WaitVBL;
|
||||
wait_idle = FB_WaitIdle;
|
||||
|
||||
/* Set the function pointers */
|
||||
this->VideoInit = FB_VideoInit;
|
||||
@@ -894,6 +903,11 @@ static GAL_Surface *FB_SetVideoMode(_THIS, GAL_Surface *current,
|
||||
}
|
||||
}
|
||||
|
||||
if (FB_WaitVBlank(this))
|
||||
this->WaitVBlank = FB_WaitVBlank;
|
||||
else
|
||||
_WRN_PRINTF("The FBCon device does not support VSync.\n");
|
||||
|
||||
/* We're done */
|
||||
return (current);
|
||||
}
|
||||
@@ -1176,19 +1190,6 @@ static void FB_FreeHWSurface(_THIS, GAL_Surface *surface)
|
||||
surface->hwdata = NULL;
|
||||
}
|
||||
|
||||
static void FB_WaitVBL(_THIS)
|
||||
{
|
||||
#ifdef FBIOWAITRETRACE /* Heheh, this didn't make it into the main kernel */
|
||||
ioctl(console_fd, FBIOWAITRETRACE, 0);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
static void FB_WaitIdle(_THIS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void FB_SavePaletteTo(_THIS, int palette_len, __u16 *area)
|
||||
{
|
||||
struct fb_cmap cmap;
|
||||
|
||||
@@ -630,7 +630,12 @@ static void *task_do_update(void *data)
|
||||
sem_post(&this->hidden->sync_sem);
|
||||
|
||||
do {
|
||||
usleep(this->hidden->update_interval * 1000);
|
||||
if (this->WaitVBlank) {
|
||||
this->WaitVBlank(this);
|
||||
}
|
||||
else {
|
||||
usleep(this->hidden->update_interval * 1000);
|
||||
}
|
||||
|
||||
#if USE_UPDATE_SEM
|
||||
if (sem_wait(&this->hidden->update_sem))
|
||||
|
||||
@@ -128,6 +128,9 @@ struct GAL_VideoDevice {
|
||||
*/
|
||||
void (*UpdateRects)(_THIS, int numrects, GAL_Rect *rects);
|
||||
|
||||
/* Wait vertical blank */
|
||||
BOOL (*WaitVBlank)(_THIS);
|
||||
|
||||
/* Synchronize the dirty content */
|
||||
BOOL (*SyncUpdate)(_THIS);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user