From: Ilija Hadzic Subject: Re: [PATCH] xf86-video-ati: vblank wait on crtc > 1 Date: Sun, 20 Mar 2011 12:33:53 -0500 (CDT) Message-ID: References: Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-559023410-959030623-1300642433=:20979" Return-path: Received: from ihemail3.lucent.com (ihemail3.lucent.com [135.245.0.37]) by gabe.freedesktop.org (Postfix) with ESMTP id 85E229E8C3 for ; Sun, 20 Mar 2011 10:33:55 -0700 (PDT) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org Errors-To: dri-devel-bounces+sf-dri-devel=m.gmane.org@lists.freedesktop.org To: Alex Deucher Cc: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---559023410-959030623-1300642433=:20979 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE On Sat, 19 Mar 2011, Alex Deucher wrote: > On Fri, Mar 18, 2011 at 5:58 PM, Ilija Hadzic > wrote: >> >> Hi Alex, >> >> Below is a patch against the master branch of xf86-video-ati that adds >> support for waits on vblank events on CRTCs that are greater than 1 (and >> thus cannot be represented using current primary/secondary flags interfa= ce). >> The patch makes use of GET_CAP ioctl to check whether >> vblanks on crtc > 1 are supported by the kernel. If they are not >> falls back to legacy behavior. Otherwise, it uses correct crtc numbers >> when waiting on vblank and thus corrects the problem seen in certain >> multiscreen configurations. >> >> The issue was discussed on the dri-devel list in these two threads >> >> http://lists.freedesktop.org/archives/dri-devel/2011-March/009009.html >> http://lists.freedesktop.org/archives/dri-devel/2011-March/009025.html >> >> regards, >> >> Ilija >> >> Reviewed-by: Mario Kleiner >> Acked-by: Mario Kleiner > > > Reviewed-by: Alex Deucher > Tested-by: Alex Deucher > Signed-off-by: Ilija Hadzic >> >> diff --git a/src/radeon.h b/src/radeon.h >> index a6d20d7..1a746c7 100644 >> --- a/src/radeon.h >> +++ b/src/radeon.h >> @@ -931,6 +931,9 @@ typedef struct { >> >> =A0 =A0 RADEONFBLayout =A0 =A0CurrentLayout; >> >> +#ifdef RADEON_DRI2 >> + =A0 =A0Bool =A0 =A0 =A0 =A0 =A0 =A0 =A0high_crtc_works; >> +#endif >> =A0#ifdef XF86DRI >> =A0 =A0 Bool =A0 =A0 =A0 =A0 =A0 =A0 =A0directRenderingEnabled; >> =A0 =A0 Bool =A0 =A0 =A0 =A0 =A0 =A0 =A0directRenderingInited; >> diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c >> index 66df03c..ed27dad 100644 >> --- a/src/radeon_dri2.c >> +++ b/src/radeon_dri2.c >> @@ -783,6 +783,7 @@ static int radeon_dri2_get_msc(DrawablePtr draw, CAR= D64 >> *ust, CARD64 *msc) >> =A0 =A0 drmVBlank vbl; >> =A0 =A0 int ret; >> =A0 =A0 int crtc =3D radeon_dri2_drawable_crtc(draw); >> + =A0 =A0int high_crtc =3D 0; >> >> =A0 =A0 /* Drawable not displayed, make up a value */ >> =A0 =A0 if (crtc =3D=3D -1) { >> @@ -791,8 +792,16 @@ static int radeon_dri2_get_msc(DrawablePtr draw, CA= RD64 >> *ust, CARD64 *msc) >> =A0 =A0 =A0 =A0 return TRUE; >> =A0 =A0 } >> =A0 =A0 vbl.request.type =3D DRM_VBLANK_RELATIVE; >> - =A0 =A0if (crtc > 0) >> + =A0 =A0if (crtc =3D=3D 1) >> =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0else if (crtc > 1) { >> + =A0 =A0 =A0 if (info->high_crtc_works) { >> + =A0 =A0 =A0 =A0 =A0 high_crtc =3D (crtc << DRM_VBLANK_HIGH_CRTC_SHIFT)= & >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 DRM_VBLANK_HIGH_CRTC_MASK; >> + =A0 =A0 =A0 } else >> + =A0 =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0} >> + =A0 =A0vbl.request.type |=3D high_crtc; >> =A0 =A0 vbl.request.sequence =3D 0; >> >> =A0 =A0 ret =3D drmWaitVBlank(info->dri2.drm_fd, &vbl); >> @@ -825,6 +834,7 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr >> client, DrawablePtr draw, >> =A0 =A0 drmVBlank vbl; >> =A0 =A0 int ret, crtc =3D radeon_dri2_drawable_crtc(draw); >> =A0 =A0 CARD64 current_msc; >> + =A0 =A0int high_crtc =3D 0; >> >> =A0 =A0 /* Truncate to match kernel interfaces; means occasional overflo= w >> =A0 =A0 =A0* misses, but that's generally not a big deal */ >> @@ -855,8 +865,16 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr >> client, DrawablePtr draw, >> >> =A0 =A0 /* Get current count */ >> =A0 =A0 vbl.request.type =3D DRM_VBLANK_RELATIVE; >> - =A0 =A0if (crtc > 0) >> + =A0 =A0if (crtc =3D=3D 1) >> =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0else if (crtc > 1) { >> + =A0 =A0 =A0 if (info->high_crtc_works) { >> + =A0 =A0 =A0 =A0 =A0 high_crtc =3D (crtc << DRM_VBLANK_HIGH_CRTC_SHIFT)= & >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 DRM_VBLANK_HIGH_CRTC_MASK; >> + =A0 =A0 =A0 } else >> + =A0 =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0} >> + =A0 =A0vbl.request.type |=3D high_crtc; >> =A0 =A0 vbl.request.sequence =3D 0; >> =A0 =A0 ret =3D drmWaitVBlank(info->dri2.drm_fd, &vbl); >> =A0 =A0 if (ret) { >> @@ -882,8 +900,16 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr >> client, DrawablePtr draw, >> =A0 =A0 =A0 =A0 if (current_msc >=3D target_msc) >> =A0 =A0 =A0 =A0 =A0 =A0 target_msc =3D current_msc; >> =A0 =A0 =A0 =A0 vbl.request.type =3D DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EV= ENT; >> - =A0 =A0 =A0 =A0if (crtc > 0) >> + =A0 =A0 =A0 =A0if (crtc =3D=3D 1) >> =A0 =A0 =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0 =A0 else if (crtc > 1) { >> + =A0 =A0 =A0 =A0 =A0 if (info->high_crtc_works) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 high_crtc =3D (crtc << DRM_VBLANK_HIGH_CRT= C_SHIFT) & >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 DRM_VBLANK_HIGH_CRTC_MASK; >> + =A0 =A0 =A0 =A0 =A0 } else >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY= ; >> + =A0 =A0 =A0 } >> + =A0 =A0 =A0 vbl.request.type |=3D high_crtc; >> =A0 =A0 =A0 =A0 vbl.request.sequence =3D target_msc; >> =A0 =A0 =A0 =A0 vbl.request.signal =3D (unsigned long)wait_info; >> =A0 =A0 =A0 =A0 ret =3D drmWaitVBlank(info->dri2.drm_fd, &vbl); >> @@ -903,8 +929,16 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr >> client, DrawablePtr draw, >> =A0 =A0 =A0* so we queue an event that will satisfy the divisor/remainde= r >> equation. >> =A0 =A0 =A0*/ >> =A0 =A0 vbl.request.type =3D DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT; >> - =A0 =A0if (crtc > 0) >> + =A0 =A0if (crtc =3D=3D 1) >> =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0else if (crtc > 1) { >> + =A0 =A0 =A0 if (info->high_crtc_works) { >> + =A0 =A0 =A0 =A0 =A0 high_crtc =3D (crtc << DRM_VBLANK_HIGH_CRTC_SHIFT)= & >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 DRM_VBLANK_HIGH_CRTC_MASK; >> + =A0 =A0 =A0 } else >> + =A0 =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0} >> + =A0 =A0vbl.request.type |=3D high_crtc; >> >> =A0 =A0 vbl.request.sequence =3D current_msc - (current_msc % divisor) + >> =A0 =A0 =A0 =A0 remainder; >> @@ -1029,6 +1063,7 @@ static int radeon_dri2_schedule_swap(ClientPtr cli= ent, >> DrawablePtr draw, >> =A0 =A0 CARD64 current_msc; >> =A0 =A0 BoxRec box; >> =A0 =A0 RegionRec region; >> + =A0 =A0int high_crtc =3D 0; >> >> =A0 =A0 /* Truncate to match kernel interfaces; means occasional overflo= w >> =A0 =A0 =A0* misses, but that's generally not a big deal */ >> @@ -1068,8 +1103,16 @@ static int radeon_dri2_schedule_swap(ClientPtr >> client, DrawablePtr draw, >> >> =A0 =A0 /* Get current count */ >> =A0 =A0 vbl.request.type =3D DRM_VBLANK_RELATIVE; >> - =A0 =A0if (crtc > 0) >> + =A0 =A0if (crtc =3D=3D 1) >> =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0else if (crtc > 1) { >> + =A0 =A0 =A0 if (info->high_crtc_works) { >> + =A0 =A0 =A0 =A0 =A0 high_crtc =3D (crtc << DRM_VBLANK_HIGH_CRTC_SHIFT)= & >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 DRM_VBLANK_HIGH_CRTC_MASK; >> + =A0 =A0 =A0 } else >> + =A0 =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0} >> + =A0 =A0vbl.request.type |=3D high_crtc; >> =A0 =A0 vbl.request.sequence =3D 0; >> =A0 =A0 ret =3D drmWaitVBlank(info->dri2.drm_fd, &vbl); >> =A0 =A0 if (ret) { >> @@ -1111,8 +1154,16 @@ static int radeon_dri2_schedule_swap(ClientPtr >> client, DrawablePtr draw, >> =A0 =A0 =A0 =A0 =A0*/ >> =A0 =A0 =A0 =A0 if (flip =3D=3D 0) >> =A0 =A0 =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_NEXTONMISS; >> - =A0 =A0 =A0 =A0if (crtc > 0) >> + =A0 =A0 =A0 =A0if (crtc =3D=3D 1) >> =A0 =A0 =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0 =A0 else if (crtc > 1) { >> + =A0 =A0 =A0 =A0 =A0 if (info->high_crtc_works) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 high_crtc =3D (crtc << DRM_VBLANK_HIGH_CRT= C_SHIFT) & >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 DRM_VBLANK_HIGH_CRTC_MASK; >> + =A0 =A0 =A0 =A0 =A0 } else >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY= ; >> + =A0 =A0 =A0 } >> + =A0 =A0 =A0 vbl.request.type |=3D high_crtc; >> >> =A0 =A0 =A0 =A0 /* If target_msc already reached or passed, set it to >> =A0 =A0 =A0 =A0 =A0* current_msc to ensure we return a reasonable value = back >> @@ -1145,8 +1196,16 @@ static int radeon_dri2_schedule_swap(ClientPtr >> client, DrawablePtr draw, >> =A0 =A0 vbl.request.type =3D DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT; >> =A0 =A0 if (flip =3D=3D 0) >> =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_NEXTONMISS; >> - =A0 =A0if (crtc > 0) >> + =A0 =A0if (crtc =3D=3D 1) >> =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0else if (crtc > 1) { >> + =A0 =A0 =A0 if (info->high_crtc_works) { >> + =A0 =A0 =A0 =A0 =A0 high_crtc =3D (crtc << DRM_VBLANK_HIGH_CRTC_SHIFT)= & >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 DRM_VBLANK_HIGH_CRTC_MASK; >> + =A0 =A0 =A0 } else >> + =A0 =A0 =A0 =A0 =A0 vbl.request.type |=3D DRM_VBLANK_SECONDARY; >> + =A0 =A0} >> + =A0 =A0vbl.request.type |=3D high_crtc; >> >> =A0 =A0 vbl.request.sequence =3D current_msc - (current_msc % divisor) + >> =A0 =A0 =A0 =A0 remainder; >> @@ -1217,6 +1276,7 @@ radeon_dri2_screen_init(ScreenPtr pScreen) >> =A0 =A0 DRI2InfoRec dri2_info =3D { 0 }; >> =A0#ifdef USE_DRI2_SCHEDULING >> =A0 =A0 const char *driverNames[1]; >> + =A0 =A0uint64_t cap_value; >> =A0#endif >> >> =A0 =A0 if (!info->useEXA) { >> @@ -1248,6 +1308,7 @@ radeon_dri2_screen_init(ScreenPtr pScreen) >> =A0#endif >> =A0 =A0 dri2_info.CopyRegion =3D radeon_dri2_copy_region; >> >> + =A0 =A0info->high_crtc_works =3D FALSE; >> =A0#ifdef USE_DRI2_SCHEDULING >> =A0 =A0 if (info->dri->pKernelDRMVersion->version_minor >=3D 4) { >> =A0 =A0 =A0 =A0 dri2_info.version =3D 4; >> @@ -1261,6 +1322,20 @@ radeon_dri2_screen_init(ScreenPtr pScreen) >> =A0 =A0 =A0 =A0 xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "You need a newe= r kernel for >> sync extension\n"); >> =A0 =A0 } >> >> + =A0 =A0if (info->drmmode.mode_res->count_crtcs > 2) { >> + =A0 =A0 =A0 if (drmGetCap(info->dri2.drm_fd, DRM_CAP_HIGH_CRTC, &cap_v= alue)) { >> + =A0 =A0 =A0 =A0 =A0 info->high_crtc_works =3D FALSE; >> + =A0 =A0 =A0 =A0 =A0 xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "You need = a newer kernel >> for VBLANKs on CRTC>1\n"); >> + =A0 =A0 =A0 } else { >> + =A0 =A0 =A0 =A0 =A0 if (cap_value) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 info->high_crtc_works =3D TRUE; >> + =A0 =A0 =A0 =A0 =A0 } else { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Y= our kernel does >> not handle VBLANKs on CRTC>1\n"); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 info->high_crtc_works =3D FALSE; >> + =A0 =A0 =A0 =A0 =A0 } >> + =A0 =A0 =A0 } >> + =A0 =A0} >> + >> =A0 =A0 if (pRADEONEnt->dri2_info_cnt =3D=3D 0) { >> =A0#if HAS_DIXREGISTERPRIVATEKEY >> =A0 =A0 =A0 =A0if (!dixRegisterPrivateKey(DRI2ClientEventsPrivateKey, >> PRIVATE_CLIENT, sizeof(DRI2ClientEventsRec))) { >> > ---559023410-959030623-1300642433=:20979 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel ---559023410-959030623-1300642433=:20979--