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 &&
|
if (glamor->root != EGL_NO_IMAGE_KHR &&
|
||||||
scrn->virtualX == width && scrn->virtualY == height)
|
scrn->virtualX == width && scrn->virtualY == height)
|
||||||
return TRUE;
|
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_FORMAT_ARGB8888,
|
||||||
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
|
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
|
||||||
|
}
|
||||||
|
|
||||||
if (glamor->root_bo == NULL)
|
if (glamor->root_bo == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -206,10 +213,8 @@ glamor_ddx_enter_vt(int scrnIndex, int flags)
|
||||||
"drmSetMaster failed: %s\n", strerror(errno));
|
"drmSetMaster failed: %s\n", strerror(errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (!xf86SetDesiredModes(scrn))
|
if (!xf86SetDesiredModes(scrn))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
#endif
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,15 +232,15 @@ glamor_ddx_create_screen_resources(ScreenPtr screen)
|
||||||
{
|
{
|
||||||
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
|
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
|
||||||
struct glamor_ddx_screen_private *glamor = glamor_ddx_get_screen_private(scrn);
|
struct glamor_ddx_screen_private *glamor = glamor_ddx_get_screen_private(scrn);
|
||||||
|
int width = scrn->virtualX;
|
||||||
|
int height = scrn->virtualY;
|
||||||
|
|
||||||
screen->CreateScreenResources = glamor->CreateScreenResources;
|
screen->CreateScreenResources = glamor->CreateScreenResources;
|
||||||
if (!(*screen->CreateScreenResources) (screen))
|
if (!(*screen->CreateScreenResources) (screen))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!glamor_glyphs_init(screen))
|
if (!glamor_glyphs_init(screen))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
glamor_resize(scrn, width, height);
|
||||||
if (!xf86SetDesiredModes(scrn))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -293,7 +298,23 @@ glamor_egl_has_extension(struct glamor_ddx_screen_private *glamor, char *extensi
|
||||||
return FALSE;
|
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
|
static Bool
|
||||||
glamor_ddx_screen_init(int scrnIndex, ScreenPtr screen, int argc, char **argv)
|
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;
|
VisualPtr visual;
|
||||||
EGLint config_attribs[] = {
|
EGLint config_attribs[] = {
|
||||||
#ifdef GLAMOR_GLES2
|
#ifdef GLAMOR_GLES2
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||||
#endif
|
#endif
|
||||||
EGL_NONE
|
EGL_NONE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* If serverGeneration != 1 then fd was closed during the last
|
/* 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())
|
if (!miSetPixmapDepths())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if (!glamor_ddx_init_front_buffer(scrn))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if (!fbScreenInit(screen, NULL,
|
if (!fbScreenInit(screen, NULL,
|
||||||
scrn->virtualX, scrn->virtualY,
|
scrn->virtualX, scrn->virtualY,
|
||||||
scrn->xDpi, scrn->yDpi,
|
scrn->xDpi, scrn->yDpi,
|
||||||
|
|
|
@ -372,10 +372,22 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
|
||||||
int ret = TRUE;
|
int ret = TRUE;
|
||||||
int i;
|
int i;
|
||||||
int fb_id;
|
int fb_id;
|
||||||
|
uint32_t handle, pitch;
|
||||||
drmModeModeInfo kmode;
|
drmModeModeInfo kmode;
|
||||||
|
|
||||||
if (!drmmode_update_fb(scrn, scrn->virtualX, scrn->virtualY))
|
if (drmmode->fb_id == 0) {
|
||||||
return FALSE;
|
|
||||||
|
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_mode = crtc->mode;
|
||||||
saved_x = crtc->x;
|
saved_x = crtc->x;
|
||||||
|
|
Loading…
Reference in New Issue