From 1b2e14f90979aacda0543a8a003cd5b07a9065c4 Mon Sep 17 00:00:00 2001 From: Owain Ainsworth Date: Tue, 26 Aug 2008 19:00:33 +0000 Subject: Use the modeset_ctl ioctl to let the drm know that we're setting the mode from userland. This means we can switch of the vblank ioctl when no 3d client is using it. Backported from newer ddxen to make use of the new libdrm. ok matthieu@ --- driver/xf86-video-intel/src/i830_display.c | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'driver/xf86-video-intel') diff --git a/driver/xf86-video-intel/src/i830_display.c b/driver/xf86-video-intel/src/i830_display.c index df2f1a24a..3d0fe57f9 100644 --- a/driver/xf86-video-intel/src/i830_display.c +++ b/driver/xf86-video-intel/src/i830_display.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "xf86.h" #include "i830.h" @@ -730,6 +731,43 @@ i830_use_fb_compression(xf86CrtcPtr crtc) return TRUE; } +#if defined(DRM_IOCTL_MODESET_CTL) && defined(XF86DRI) +static void i830_modeset_ctl(xf86CrtcPtr crtc, int pre) +{ + ScrnInfoPtr pScrn = crtc->scrn; + I830Ptr pI830 = I830PTR(pScrn); + I830CrtcPrivatePtr intel_crtc = crtc->driver_private; + struct drm_modeset_ctl modeset; + + if (!pI830->directRenderingEnabled) + return; + + modeset.crtc = intel_crtc->plane; + + /* + * DPMS will be called many times (especially off), but we only + * want to catch the transition from on->off and off->on. + */ + if (pre && intel_crtc->dpms_mode != DPMSModeOff) { + /* On -> off is a pre modeset */ + modeset.cmd = _DRM_PRE_MODESET; + ioctl(pI830->drmSubFD, DRM_IOCTL_MODESET_CTL, &modeset); + ErrorF("modeset: on -> off on plane %d\n", modeset.crtc); + } else if (!pre && intel_crtc->dpms_mode == DPMSModeOff) { + /* Off -> on means post modeset */ + modeset.cmd = _DRM_POST_MODESET; + ioctl(pI830->drmSubFD, DRM_IOCTL_MODESET_CTL, &modeset); + ErrorF("modeset: off -> on on plane %d\n", modeset.crtc); + } +} +#else +static void i830_modeset_ctl(xf86CrtcPtr crtc, int dpms_state) +{ + return; +} +#endif /* DRM_IOCTL_MODESET_CTL && XF86DRI */ + + /** * Sets the power management mode of the pipe and plane. * @@ -797,8 +835,10 @@ i830_crtc_dpms(xf86CrtcPtr crtc, int mode) /* Reenable compression if needed */ if (i830_use_fb_compression(crtc)) i830_enable_fb_compression(crtc); + i830_modeset_ctl(crtc, 0); break; case DPMSModeOff: + i830_modeset_ctl(crtc, 1); /* Shut off compression if in use */ if (i830_use_fb_compression(crtc)) i830_disable_fb_compression(crtc); -- cgit v1.2.3