glamor-ddx: Fix the broken switching between VTs.
Now we can allocate frame buffer during the screen initialization. And set mode major when enter VT. This is the correct logic. The previous implementation defer the set mode major to create screen resource which will cause the switching between VTs broken. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
parent
4c8ed1756a
commit
2d4d40a4b5
|
@ -70,11 +70,18 @@ glamor_resize(ScrnInfoPtr scrn, int width, int height)
|
|||
if (glamor->root != EGL_NO_IMAGE_KHR &&
|
||||
scrn->virtualX == width && scrn->virtualY == height)
|
||||
return TRUE;
|
||||
else if (scrn->virtualX != width || scrn->virtualY != height) {
|
||||
|
||||
glamor->root_bo = gbm_bo_create(glamor->gbm, width, height,
|
||||
if (glamor->root != EGL_NO_IMAGE_KHR) {
|
||||
eglDestroyImageKHR(glamor->display, glamor->root);
|
||||
gbm_bo_destroy(glamor->root_bo);
|
||||
glamor->root = EGL_NO_IMAGE_KHR;
|
||||
}
|
||||
glamor->root_bo = gbm_bo_create(glamor->gbm, width, height,
|
||||
GBM_BO_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
|
||||
|
||||
}
|
||||
|
||||
if (glamor->root_bo == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -206,10 +213,8 @@ glamor_ddx_enter_vt(int scrnIndex, int flags)
|
|||
"drmSetMaster failed: %s\n", strerror(errno));
|
||||
return FALSE;
|
||||
}
|
||||
#if 0
|
||||
if (!xf86SetDesiredModes(scrn))
|
||||
return FALSE;
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -227,15 +232,15 @@ glamor_ddx_create_screen_resources(ScreenPtr screen)
|
|||
{
|
||||
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
|
||||
struct glamor_ddx_screen_private *glamor = glamor_ddx_get_screen_private(scrn);
|
||||
int width = scrn->virtualX;
|
||||
int height = scrn->virtualY;
|
||||
|
||||
screen->CreateScreenResources = glamor->CreateScreenResources;
|
||||
if (!(*screen->CreateScreenResources) (screen))
|
||||
return FALSE;
|
||||
if (!glamor_glyphs_init(screen))
|
||||
return FALSE;
|
||||
|
||||
if (!xf86SetDesiredModes(scrn))
|
||||
return FALSE;
|
||||
glamor_resize(scrn, width, height);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -293,7 +298,23 @@ glamor_egl_has_extension(struct glamor_ddx_screen_private *glamor, char *extensi
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
glamor_ddx_init_front_buffer(ScrnInfoPtr scrn)
|
||||
{
|
||||
struct glamor_ddx_screen_private *glamor = glamor_ddx_get_screen_private(scrn);
|
||||
int width = scrn->virtualX;
|
||||
int height = scrn->virtualY;
|
||||
|
||||
glamor->root_bo = gbm_bo_create(glamor->gbm, width, height,
|
||||
GBM_BO_FORMAT_ARGB8888,
|
||||
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
|
||||
|
||||
if (glamor->root_bo == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* XXX shall we update displayWidth here ? */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static Bool
|
||||
glamor_ddx_screen_init(int scrnIndex, ScreenPtr screen, int argc, char **argv)
|
||||
|
@ -304,10 +325,10 @@ glamor_ddx_screen_init(int scrnIndex, ScreenPtr screen, int argc, char **argv)
|
|||
VisualPtr visual;
|
||||
EGLint config_attribs[] = {
|
||||
#ifdef GLAMOR_GLES2
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
#endif
|
||||
EGL_NONE
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/* If serverGeneration != 1 then fd was closed during the last
|
||||
|
@ -398,6 +419,9 @@ glamor_ddx_screen_init(int scrnIndex, ScreenPtr screen, int argc, char **argv)
|
|||
if (!miSetPixmapDepths())
|
||||
return FALSE;
|
||||
|
||||
if (!glamor_ddx_init_front_buffer(scrn))
|
||||
return FALSE;
|
||||
|
||||
if (!fbScreenInit(screen, NULL,
|
||||
scrn->virtualX, scrn->virtualY,
|
||||
scrn->xDpi, scrn->yDpi,
|
||||
|
|
|
@ -372,10 +372,22 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
|
|||
int ret = TRUE;
|
||||
int i;
|
||||
int fb_id;
|
||||
uint32_t handle, pitch;
|
||||
drmModeModeInfo kmode;
|
||||
|
||||
if (!drmmode_update_fb(scrn, scrn->virtualX, scrn->virtualY))
|
||||
return FALSE;
|
||||
if (drmmode->fb_id == 0) {
|
||||
|
||||
glamor_frontbuffer_handle(scrn, &handle, &pitch);
|
||||
ret = drmModeAddFB(drmmode->fd,
|
||||
scrn->virtualX, scrn->virtualY,
|
||||
scrn->depth, scrn->bitsPerPixel,
|
||||
pitch, handle,
|
||||
&drmmode->fb_id);
|
||||
if (ret < 0) {
|
||||
ErrorF("failed to add fb\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
saved_mode = crtc->mode;
|
||||
saved_x = crtc->x;
|
||||
|
|
Loading…
Reference in New Issue
Block a user