From patchwork Tue Mar 30 20:13:58 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 89389 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2UKE5g8013150 for ; Tue, 30 Mar 2010 20:14:40 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD5C89E9EB; Tue, 30 Mar 2010 13:14:04 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 97B089E913 for ; Tue, 30 Mar 2010 13:14:03 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 30 Mar 2010 13:14:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.51,336,1267430400"; d="scan'208";a="608910091" Received: from unknown (HELO localhost.localdomain) ([10.255.17.253]) by orsmga001.jf.intel.com with ESMTP; 30 Mar 2010 13:14:02 -0700 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 30 Mar 2010 21:13:58 +0100 Message-Id: <1269980038-26550-1-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 1.7.0.3 Subject: [Intel-gfx] [PATCH] Review i830_pad_drawable_width() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 30 Mar 2010 20:14:40 +0000 (UTC) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index 1348e08..d8b158e 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -476,7 +476,7 @@ drmmode_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height) int size, ret; unsigned long rotate_pitch; - width = i830_pad_drawable_width(width, drmmode->cpp); + width = i830_pad_drawable_width(width); rotate_pitch = width * drmmode->cpp; size = rotate_pitch * height; @@ -523,8 +523,7 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height) } } - rotate_pitch = - i830_pad_drawable_width(width, drmmode->cpp) * drmmode->cpp; + rotate_pitch = i830_pad_drawable_width(width) * drmmode->cpp; rotate_pixmap = GetScratchPixmapHeader(scrn->pScreen, width, height, scrn->depth, @@ -1257,13 +1256,14 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height) Bool ret; ScreenPtr screen = screenInfo.screens[scrn->scrnIndex]; uint32_t old_fb_id; - int i, pitch, old_width, old_height, old_pitch; + int i, w, pitch, old_width, old_height, old_pitch; if (scrn->virtualX == width && scrn->virtualY == height) return TRUE; - pitch = i830_pad_drawable_width(width, intel->cpp); - i830_tiled_width(intel, &pitch, intel->cpp); + w = i830_pad_drawable_width(width); + i830_tiled_width(intel, &w, intel->cpp); + pitch = w * intel->cpp; xf86DrvMsg(scrn->scrnIndex, X_INFO, "Allocate new frame buffer %dx%d stride %d\n", width, height, pitch); @@ -1276,13 +1276,13 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height) scrn->virtualX = width; scrn->virtualY = height; - scrn->displayWidth = pitch; + scrn->displayWidth = w; intel->front_buffer = i830_allocate_framebuffer(scrn); if (!intel->front_buffer) goto fail; ret = drmModeAddFB(drmmode->fd, width, height, scrn->depth, - scrn->bitsPerPixel, pitch * intel->cpp, + scrn->bitsPerPixel, pitch, intel->front_buffer->handle, &drmmode->fb_id); if (ret) @@ -1291,7 +1291,7 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height) i830_set_pixmap_bo(screen->GetScreenPixmap(screen), intel->front_buffer); screen->ModifyPixmapHeader(screen->GetScreenPixmap(screen), - width, height, -1, -1, pitch * intel->cpp, NULL); + width, height, -1, -1, pitch, NULL); for (i = 0; i < xf86_config->num_crtc; i++) { xf86CrtcPtr crtc = xf86_config->crtc[i]; diff --git a/src/i830.h b/src/i830.h index 7593cde..43c5887 100644 --- a/src/i830.h +++ b/src/i830.h @@ -429,8 +429,6 @@ void i830_init_bufmgr(ScrnInfoPtr scrn); Bool i830_tiled_width(intel_screen_private *intel, int *width, int cpp); -int i830_pad_drawable_width(int width, int cpp); - /* i830_memory.c */ unsigned long i830_get_fence_size(intel_screen_private *intel, unsigned long size); unsigned long i830_get_fence_pitch(intel_screen_private *intel, unsigned long pitch, @@ -587,4 +585,13 @@ static inline Bool pixmap_is_scanout(PixmapPtr pixmap) return pixmap == screen->GetScreenPixmap(screen); } +/* + * Pad to accelerator requirement + */ +static inline int i830_pad_drawable_width(int width) +{ + return (width + 63) & ~63; +} + + #endif /* _I830_H_ */ diff --git a/src/i830_driver.c b/src/i830_driver.c index 22e8472..148675e 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -374,11 +374,13 @@ Bool i830_tiled_width(intel_screen_private *intel, int *width, int cpp) 8192, 0 }; + int pitch; int i; + pitch = *width * cpp; for (i = 0; pitches[i] != 0; i++) { - if (pitches[i] >= *width) { - *width = pitches[i]; + if (pitches[i] >= pitch) { + *width = pitches[i] / cpp; tiled = TRUE; break; } @@ -389,14 +391,6 @@ Bool i830_tiled_width(intel_screen_private *intel, int *width, int cpp) } /* - * Pad to accelerator requirement - */ -int i830_pad_drawable_width(int width, int cpp) -{ - return (width + 63) & ~63; -} - -/* * DRM mode setting Linux only at this point... later on we could * add a wrapper here. */ @@ -1100,8 +1094,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr screen, int argc, char **argv) struct pci_device *const device = intel->PciInfo; int fb_bar = IS_I9XX(intel) ? 2 : 0; - scrn->displayWidth = - i830_pad_drawable_width(scrn->virtualX, intel->cpp); + scrn->displayWidth = i830_pad_drawable_width(scrn->virtualX); /* * The "VideoRam" config file parameter specifies the maximum amount of