From patchwork Wed May 25 22:58:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 818622 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4PMwAsn026945 for ; Wed, 25 May 2011 22:58:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756992Ab1EYW6T (ORCPT ); Wed, 25 May 2011 18:58:19 -0400 Received: from perceval.ideasonboard.com ([95.142.166.194]:53778 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756994Ab1EYW6Q (ORCPT ); Wed, 25 May 2011 18:58:16 -0400 Received: from localhost.localdomain (unknown [91.178.57.18]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 127E235B71; Wed, 25 May 2011 22:58:13 +0000 (UTC) From: Laurent Pinchart To: linux-fbdev@vger.kernel.org Cc: Antonino Daplas Subject: [PATCH 21/29] s3fb: use display information in info not in var for panning Date: Thu, 26 May 2011 00:58:13 +0200 Message-Id: <1306364301-8195-22-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <201105232211.40154.laurent.pinchart@ideasonboard.com> References: <201105232211.40154.laurent.pinchart@ideasonboard.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 25 May 2011 22:58:20 +0000 (UTC) We must not use any information in the passed var besides xoffset, yoffset and vmode as otherwise applications might abuse it. Also use the aligned fix.line_length and not the (possible) unaligned xres_virtual. Signed-off-by: Laurent Pinchart Cc: Antonino Daplas --- drivers/video/savage/savagefb_driver.c | 16 +++++++--------- 1 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c index a2dc1a7..6db8485 100644 --- a/drivers/video/savage/savagefb_driver.c +++ b/drivers/video/savage/savagefb_driver.c @@ -1475,15 +1475,9 @@ static void savagefb_set_par_int(struct savagefb_par *par, struct savage_reg *r vgaHWProtect(par, 0); } -static void savagefb_update_start(struct savagefb_par *par, - struct fb_var_screeninfo *var) +static void savagefb_update_start(struct savagefb_par *par, int base) { - int base; - - base = ((var->yoffset * var->xres_virtual + (var->xoffset & ~1)) - * ((var->bits_per_pixel+7) / 8)) >> 2; - - /* now program the start address registers */ + /* program the start address registers */ vga_out16(0x3d4, (base & 0x00ff00) | 0x0c, par); vga_out16(0x3d4, ((base & 0x00ff) << 8) | 0x0d, par); vga_out8(0x3d4, 0x69, par); @@ -1548,8 +1542,12 @@ static int savagefb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) { struct savagefb_par *par = info->par; + int base; + + base = (var->yoffset * info->fix.line_length + + (var->xoffset & ~1) * ((info->var.bits_per_pixel+7) / 8)) >> 2; - savagefb_update_start(par, var); + savagefb_update_start(par, base); return 0; }