linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] cirrusfb: do not calculate line length twice
@ 2009-02-14 17:50 Krzysztof Helt
  2009-02-20  0:27 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Helt @ 2009-02-14 17:50 UTC (permalink / raw)
  To: Linux-fbdev-devel; +Cc: Andrew Morton, Arthur Marsh

From: Krzysztof Helt <krzysztof.h1@wp.pl>

A line length is calculated twice: first in
the cirrusfb_decode_var() then in 
the cirrusfb_set_par_foo().

Use the first calculated value. A nice side
effect is that 32bpp mode works now.

Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
---
 drivers/video/cirrusfb.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index e8cd60a..c98efd0 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -694,7 +694,8 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
 	struct cirrusfb_regs regs;
 	u8 __iomem *regbase = cinfo->regbase;
 	unsigned char tmp;
-	int offset = 0, err;
+	int err;
+	int pitch;
 	const struct cirrusfb_board_info_rec *bi;
 	int hdispend, hsyncstart, hsyncend, htotal;
 	int yres, vdispend, vsyncstart, vsyncend, vtotal;
@@ -1027,7 +1028,6 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
 		vga_wseq(regbase, VGA_SEQ_MEMORY_MODE, 0x06);
 		/* plane mask: only write to first plane */
 		vga_wseq(regbase, VGA_SEQ_PLANE_WRITE, 0x01);
-		offset = var->xres_virtual / 16;
 	}
 
 	/******************************************************
@@ -1113,7 +1113,6 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
 		vga_wseq(regbase, VGA_SEQ_MEMORY_MODE, 0x0a);
 		/* plane mask: enable writing to all 4 planes */
 		vga_wseq(regbase, VGA_SEQ_PLANE_WRITE, 0xff);
-		offset = var->xres_virtual / 8;
 	}
 
 	/******************************************************
@@ -1190,7 +1189,6 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
 		vga_wseq(regbase, VGA_SEQ_MEMORY_MODE, 0x0a);
 		/* plane mask: enable writing to all 4 planes */
 		vga_wseq(regbase, VGA_SEQ_PLANE_WRITE, 0xff);
-		offset = var->xres_virtual / 4;
 	}
 
 	/******************************************************
@@ -1263,7 +1261,6 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
 		vga_wseq(regbase, VGA_SEQ_MEMORY_MODE, 0x0a);
 		/* plane mask: enable writing to all 4 planes */
 		vga_wseq(regbase, VGA_SEQ_PLANE_WRITE, 0xff);
-		offset = var->xres_virtual / 4;
 	}
 
 	/******************************************************
@@ -1277,9 +1274,10 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
 			"What's this? requested color depth == %d.\n",
 			var->bits_per_pixel);
 
-	vga_wcrt(regbase, VGA_CRTC_OFFSET, offset & 0xff);
+	pitch = info->fix.line_length >> 3;
+	vga_wcrt(regbase, VGA_CRTC_OFFSET, pitch & 0xff);
 	tmp = 0x22;
-	if (offset & 0x100)
+	if (pitch & 0x100)
 		tmp |= 0x10;	/* offset overflow bit */
 
 	/* screen start addr #16-18, fastpagemode cycles */
@@ -1287,7 +1285,7 @@ static int cirrusfb_set_par_foo(struct fb_info *info)
 
 	/* screen start address bit 19 */
 	if (cirrusfb_board_info[cinfo->btype].scrn_start_bit19)
-		vga_wcrt(regbase, CL_CRT1D, 0x00);
+		vga_wcrt(regbase, CL_CRT1D, (pitch >> 9) & 1);
 
 	if (cinfo->btype == BT_LAGUNA ||
 	    cinfo->btype == BT_GD5480) {
-- 
1.5.2.2


----------------------------------------------------------------------
Wrozby dla zakochanych!
Sprawdz >> http://link.interia.pl/f2054



------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/2] cirrusfb: do not calculate line length twice
  2009-02-14 17:50 [PATCH 1/2] cirrusfb: do not calculate line length twice Krzysztof Helt
@ 2009-02-20  0:27 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2009-02-20  0:27 UTC (permalink / raw)
  To: Krzysztof Helt; +Cc: arthur.marsh, linux-fbdev-devel

On Sat, 14 Feb 2009 18:50:45 +0100
Krzysztof Helt <krzysztof.h1@poczta.fm> wrote:

> A line length is calculated twice: first in
> the cirrusfb_decode_var() then in 
> the cirrusfb_set_par_foo().
> 
> Use the first calculated value. A nice side
> effect is that 32bpp mode works now.

Do you get these as well?

drivers/video/cirrusfb.c: In function 'cirrusfb_set_par_foo':
drivers/video/cirrusfb.c:663: warning: 'format' may be used uninitialized in this function
drivers/video/cirrusfb.c:663: warning: 'threshold' may be used uninitialized in this function
drivers/video/cirrusfb.c:663: warning: 'control' may be used uninitialized in this function

they're false positives, but it would be nice to squash them somehow.


------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-20  0:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-14 17:50 [PATCH 1/2] cirrusfb: do not calculate line length twice Krzysztof Helt
2009-02-20  0:27 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).