sna: Wrap xf86DPMSSet

We need to wrap xf86DPMSSet() so that we can reintialize our bookkeeping
and auxiliary planes after disabling/re-enabling CRTC during DPMS
operations.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2014-07-03 18:18:04 +00:00
parent 57d0cc82d8
commit 18ae7722db
2 changed files with 40 additions and 24 deletions

View File

@ -170,9 +170,10 @@ struct sna_output {
uint32_t *prop_ids;
uint64_t *prop_values;
struct sna_property *props;
};
static void sna_crtc_disable_cursor(struct sna *sna, struct sna_crtc *crtc);
inline static unsigned count_to_mask(int x)
{
return (1 << x) - 1;
@ -972,6 +973,7 @@ sna_crtc_apply(xf86CrtcPtr crtc)
DBG(("%s CRTC:%d [pipe=%d], handle=%d\n", __FUNCTION__, sna_crtc->id, sna_crtc->pipe, sna_crtc->bo->handle));
assert(sna->mode.num_real_output < ARRAY_SIZE(output_ids));
sna_crtc_disable_cursor(sna, sna_crtc);
if (!rotation_set(sna, &sna_crtc->primary_rotation, sna_crtc->rotation)) {
ERR(("%s: set-primary-rotation failed (rotation-id=%d, rotation=%d) on CRTC:%d [pipe=%d], errno=%d\n",
@ -1430,8 +1432,8 @@ sna_crtc_disable(xf86CrtcPtr crtc)
sna_crtc->mode_serial++;
sna_crtc_disable_cursor(sna, sna_crtc);
rotation_set(sna, &sna_crtc->primary_rotation, RR_Rotate_0);
sna_crtc_disable_shadow(sna, sna_crtc);
if (sna_crtc->bo) {
@ -4273,6 +4275,29 @@ sna_set_cursor_colors(ScrnInfoPtr scrn, int _bg, int _fg)
sna_show_cursors(scrn);
}
static void
sna_crtc_disable_cursor(struct sna *sna, struct sna_crtc *crtc)
{
struct drm_mode_cursor arg;
if (!crtc->cursor)
return;
DBG(("%s: CRTC:%d, handle=%d\n", __FUNCTION__, crtc->id, crtc->cursor->handle));
assert(crtc->cursor->ref);
VG_CLEAR(arg);
arg.flags = DRM_MODE_CURSOR_BO;
arg.crtc_id = crtc->id;
arg.width = arg.height = 0;
arg.handle = 0;
(void)drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_CURSOR, &arg);
assert(crtc->cursor->ref > 0);
crtc->cursor->ref--;
crtc->cursor = NULL;
}
static void
sna_hide_cursors(ScrnInfoPtr scrn)
{
@ -4285,27 +4310,8 @@ sna_hide_cursors(ScrnInfoPtr scrn)
sigio = sigio_block();
for (c = 0; c < sna->mode.num_real_crtc; c++) {
xf86CrtcPtr crtc = xf86_config->crtc[c];
struct sna_crtc *sna_crtc = to_sna_crtc(crtc);
struct drm_mode_cursor arg;
assert(sna_crtc != NULL);
if (!sna_crtc->cursor)
continue;
__DBG(("%s: CRTC:%d, handle=%d\n", __FUNCTION__, sna_crtc->id, sna_crtc->cursor->handle));
assert(sna_crtc->cursor->ref);
VG_CLEAR(arg);
arg.flags = DRM_MODE_CURSOR_BO;
arg.crtc_id = sna_crtc->id;
arg.width = arg.height = 0;
arg.handle = 0;
(void)drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_CURSOR, &arg);
assert(sna_crtc->cursor->ref > 0);
sna_crtc->cursor->ref--;
sna_crtc->cursor = NULL;
assert(to_sna_crtc(xf86_config->crtc[c]));
sna_crtc_disable_cursor(sna, to_sna_crtc(xf86_config->crtc[c]));
}
for (prev = &sna->cursor.cursors; (cursor = *prev) != NULL; ) {

View File

@ -300,6 +300,16 @@ static Bool sna_save_screen(ScreenPtr screen, int mode)
return TRUE;
}
static void sna_dpms_set(ScrnInfoPtr scrn, int mode, int flags)
{
DBG(("%s(mode=%d, flags=%d)\n", __FUNCTION__, mode));
if (!scrn->vtSema)
return;
xf86DPMSSet(scrn, mode, flags);
sna_crtc_config_notify(xf86ScrnToScreen(scrn));
}
static void sna_selftest(void)
{
sna_damage_selftest();
@ -1107,7 +1117,7 @@ sna_screen_init(SCREEN_INIT_ARGS_DECL)
CMAP_PALETTED_TRUECOLOR))
return FALSE;
xf86DPMSInit(screen, xf86DPMSSet, 0);
xf86DPMSInit(screen, sna_dpms_set, 0);
sna_video_init(sna, screen);
sna_dri_init(sna, screen);