From: Harald Welte <HaraldWelte@viatech.com>
To: linux-fbdev-devel@lists.sourceforge.net
Cc: Harald Welte <HaraldWelte@viatech.com>
Subject: [PATCH 11/15] viafb: clean up duplicated code from 2D acceleration
Date: Thu, 21 May 2009 04:28:49 +0800 [thread overview]
Message-ID: <1242851333-325-11-git-send-email-HaraldWelte@viatech.com> (raw)
In-Reply-To: <1242851333-325-10-git-send-email-HaraldWelte@viatech.com>
From: Harald Welte <laforge@gnumonks.org>
There are four parts of the viafb code who initialize the bigtblit
screen base and pitch, some of them actually broken. This patch
unifies them in one function called viafb_set_2d_mode() which
replaces and enhances the old function to just set the bpp.
Signed-off-by: Harald Welte <HaraldWelte@viatech.com>
---
drivers/video/via/accel.c | 35 ++++++++++++-----------
drivers/video/via/accel.h | 2 +-
drivers/video/via/viafbdev.c | 62 +++++-------------------------------------
3 files changed, 26 insertions(+), 73 deletions(-)
diff --git a/drivers/video/via/accel.c b/drivers/video/via/accel.c
index 45c54bf..4a1183f 100644
--- a/drivers/video/via/accel.c
+++ b/drivers/video/via/accel.c
@@ -191,26 +191,18 @@ void viafb_init_2d_engine(void)
}
}
- viafb_set_2d_color_depth(viaparinfo->bpp);
-
- writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
- writel(0x0, viaparinfo->io_virt + VIA_REG_DSTBASE);
-
- writel(VIA_PITCH_ENABLE |
- (((viaparinfo->hres *
- viaparinfo->bpp >> 3) >> 3) | (((viaparinfo->hres *
- viaparinfo->
- bpp >> 3) >> 3) << 16)),
- viaparinfo->io_virt + VIA_REG_PITCH);
+ viafb_set_2d_mode(viafbinfo);
}
-void viafb_set_2d_color_depth(int bpp)
+/* Set the mode-specific parameters for the 2D acceleration, such as
+ * BPP, source and destination base, as well as pitch */
+void viafb_set_2d_mode(struct fb_info *info)
{
- u32 dwGEMode;
+ u32 dwGEMode, pitch, pitch_reg, base;
+ /* Set BPP */
dwGEMode = readl(viaparinfo->io_virt + 0x04) & 0xFFFFFCFF;
-
- switch (bpp) {
+ switch (viaparinfo->bpp) {
case 16:
dwGEMode |= VIA_GEM_16bpp;
break;
@@ -221,9 +213,18 @@ void viafb_set_2d_color_depth(int bpp)
dwGEMode |= VIA_GEM_8bpp;
break;
}
-
- /* Set BPP and Pitch */
writel(dwGEMode, viaparinfo->io_virt + VIA_REG_GEMODE);
+
+ /* Set source and destination base */
+ base = ((void *)info->screen_base - viafb_FB_MM);
+ writel(base >> 3, viaparinfo->io_virt + VIA_REG_SRCBASE);
+ writel(base >> 3, viaparinfo->io_virt + VIA_REG_DSTBASE);
+
+ /* Set source and destination pitch (128bit aligned) */
+ pitch = (viaparinfo->hres * viaparinfo->bpp >> 3) >> 3;
+ pitch_reg = pitch | (pitch << 16);
+ pitch_reg |= VIA_PITCH_ENABLE;
+ writel(pitch_reg, viaparinfo->io_virt + VIA_REG_PITCH);
}
void viafb_hw_cursor_init(void)
diff --git a/drivers/video/via/accel.h b/drivers/video/via/accel.h
index 29bf854..bef3134 100644
--- a/drivers/video/via/accel.h
+++ b/drivers/video/via/accel.h
@@ -161,7 +161,7 @@
void viafb_init_accel(void);
void viafb_init_2d_engine(void);
-void set_2d_color_depth(int);
+void viafb_set_2d_mode(struct fb_info *info);
void viafb_hw_cursor_init(void);
void viafb_show_hw_cursor(struct fb_info *info, int Status); int
viafb_wait_engine_idle(void); void viafb_set_2d_color_depth(int bpp);
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 980eab8..af8acfe 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -264,7 +264,7 @@ static int viafb_set_par(struct fb_info *info)
viafb_accel = info->var.accel_flags;
if (viafb_accel)
- viafb_set_2d_color_depth(info->var.bits_per_pixel);
+ viafb_set_2d_mode(info);
}
return 0;
@@ -865,7 +865,6 @@ static void viafb_fillrect(struct fb_info *info,
const struct fb_fillrect *rect)
{
u32 col = 0, rop = 0;
- int pitch;
if (!viafb_accel) {
cfb_fillrect(info, rect);
@@ -897,22 +896,8 @@ static void viafb_fillrect(struct fb_info *info,
break;
}
- /* BitBlt Source Address */
- writel(0x0, viaparinfo->io_virt + VIA_REG_SRCPOS);
- /* Source Base Address */
- writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
- /* Destination Base Address */
- writel(((unsigned long) (info->screen_base) -
- (unsigned long) viafb_FB_MM) >> 3,
- viaparinfo->io_virt + VIA_REG_DSTBASE);
- /* Pitch */
- pitch = (info->var.xres_virtual + 7) & ~7;
- writel(VIA_PITCH_ENABLE |
- (((pitch *
- info->var.bits_per_pixel >> 3) >> 3) |
- (((pitch * info->
- var.bits_per_pixel >> 3) >> 3) << 16)),
- viaparinfo->io_virt + VIA_REG_PITCH);
+ viafb_set_2d_mode(info);
+
/* BitBlt Destination Address */
writel(((rect->dy << 16) | rect->dx),
viaparinfo->io_virt + VIA_REG_DSTPOS);
@@ -932,7 +917,6 @@ static void viafb_copyarea(struct fb_info *info,
{
u32 dy = area->dy, sy = area->sy, direction = 0x0;
u32 sx = area->sx, dx = area->dx, width = area->width;
- int pitch;
DEBUG_MSG(KERN_INFO "viafb_copyarea!!\n");
@@ -956,25 +940,8 @@ static void viafb_copyarea(struct fb_info *info,
direction |= 0x8000;
}
- /* Source Base Address */
- writel(((unsigned long) (info->screen_base) -
- (unsigned long) viafb_FB_MM) >> 3,
- viaparinfo->io_virt + VIA_REG_SRCBASE);
- /* Destination Base Address */
- writel(((unsigned long) (info->screen_base) -
- (unsigned long) viafb_FB_MM) >> 3,
- viaparinfo->io_virt + VIA_REG_DSTBASE);
- /* Pitch */
- pitch = (info->var.xres_virtual + 7) & ~7;
- /* VIA_PITCH_ENABLE can be omitted now. */
- writel(VIA_PITCH_ENABLE |
- (((pitch *
- info->var.bits_per_pixel >> 3) >> 3) | (((pitch *
- info->var.
- bits_per_pixel
- >> 3) >> 3)
- << 16)),
- viaparinfo->io_virt + VIA_REG_PITCH);
+ viafb_set_2d_mode(info);
+
/* BitBlt Source Address */
writel(((sy << 16) | sx), viaparinfo->io_virt + VIA_REG_SRCPOS);
/* BitBlt Destination Address */
@@ -993,7 +960,6 @@ static void viafb_imageblit(struct fb_info *info,
{
u32 size, bg_col = 0, fg_col = 0, *udata;
int i;
- int pitch;
if (!viafb_accel) {
cfb_imageblit(info, image);
@@ -1018,22 +984,8 @@ static void viafb_imageblit(struct fb_info *info,
}
size = image->width * image->height;
- /* Source Base Address */
- writel(0x0, viaparinfo->io_virt + VIA_REG_SRCBASE);
- /* Destination Base Address */
- writel(((unsigned long) (info->screen_base) -
- (unsigned long) viafb_FB_MM) >> 3,
- viaparinfo->io_virt + VIA_REG_DSTBASE);
- /* Pitch */
- pitch = (info->var.xres_virtual + 7) & ~7;
- writel(VIA_PITCH_ENABLE |
- (((pitch *
- info->var.bits_per_pixel >> 3) >> 3) | (((pitch *
- info->var.
- bits_per_pixel
- >> 3) >> 3)
- << 16)),
- viaparinfo->io_virt + VIA_REG_PITCH);
+ viafb_set_2d_mode(info);
+
/* BitBlt Source Address */
writel(0x0, viaparinfo->io_virt + VIA_REG_SRCPOS);
/* BitBlt Destination Address */
--
1.6.2.4
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables
unlimited royalty-free distribution of the report engine
for externally facing server and web deployment.
http://p.sf.net/sfu/businessobjects
next prev parent reply other threads:[~2009-05-20 20:48 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-20 20:28 [PATCH 01/15] [FB] make viafb work on x86_64 Harald Welte
2009-05-20 20:28 ` [PATCH 02/15] [FB] viafb: Add missing break statement in switch Harald Welte
2009-05-20 20:28 ` [PATCH 03/15] [FB] viafb: Add support for the VX855 chipset Harald Welte
2009-05-20 20:28 ` [PATCH 04/15] [FB] viafb: Fix various resource leaks during module_init() Harald Welte
2009-05-20 20:28 ` [PATCH 05/15] [FB] viafb: make viafb a first-class citizen using pci_driver Harald Welte
2009-05-20 20:28 ` [PATCH 06/15] viafb: pass reference to pci device when calling framebuffer_alloc() Harald Welte
2009-05-20 20:28 ` [PATCH 07/15] viafb: use proper pci config API Harald Welte
2009-05-20 20:28 ` [PATCH 08/15] viafb: get rid of some duplicated fields in private structure Harald Welte
2009-05-20 20:28 ` [PATCH 09/15] viafb: Remove MMIO from " Harald Welte
2009-05-20 20:28 ` [PATCH 10/15] viafb: make module parameters visible in sysfs Harald Welte
2009-05-20 20:28 ` Harald Welte [this message]
2009-05-20 20:28 ` [PATCH 12/15] viafb: introduce wrapper for 2D engine registers Harald Welte
2009-05-20 20:28 ` [PATCH 13/15] viafb: initialize 2D engine registers from loop Harald Welte
2009-05-20 20:28 ` [PATCH 14/15] viafb: Determine type of 2D engine and store it in chip_info Harald Welte
2009-05-20 20:28 ` [PATCH 15/15] viafb: Add support for 2D accelerated framebuffer on VX800/VX855 Harald Welte
2009-05-23 6:31 ` Krzysztof Helt
2009-05-23 6:29 ` [PATCH 14/15] viafb: Determine type of 2D engine and store it in chip_info Krzysztof Helt
2009-05-23 6:27 ` [PATCH 13/15] viafb: initialize 2D engine registers from loop Krzysztof Helt
2009-05-23 9:33 ` Harald Welte
2009-05-23 6:28 ` [PATCH 12/15] viafb: introduce wrapper for 2D engine registers Krzysztof Helt
2009-05-23 6:28 ` [PATCH 11/15] viafb: clean up duplicated code from 2D acceleration Krzysztof Helt
2009-05-23 6:32 ` [PATCH 10/15] viafb: make module parameters visible in sysfs Krzysztof Helt
2009-05-23 6:32 ` [PATCH 09/15] viafb: Remove MMIO from private structure Krzysztof Helt
2009-05-23 6:34 ` [PATCH 08/15] viafb: get rid of some duplicated fields in " Krzysztof Helt
2009-05-23 6:52 ` [PATCH 07/15] viafb: use proper pci config API Krzysztof Helt
2009-05-23 6:52 ` [PATCH 06/15] viafb: pass reference to pci device when calling framebuffer_alloc() Krzysztof Helt
2009-05-23 6:53 ` [PATCH 05/15] [FB] viafb: make viafb a first-class citizen using pci_driver Krzysztof Helt
2009-05-23 6:53 ` [PATCH 04/15] [FB] viafb: Fix various resource leaks during module_init() Krzysztof Helt
2009-05-23 6:54 ` [PATCH 03/15] [FB] viafb: Add support for the VX855 chipset Krzysztof Helt
2009-05-23 6:54 ` [PATCH 02/15] [FB] viafb: Add missing break statement in switch Krzysztof Helt
2009-05-21 16:57 ` [PATCH 01/15] [FB] make viafb work on x86_64 Krzysztof Helt
2009-05-23 6:57 ` Krzysztof Helt
2009-05-23 9:06 ` Harald Welte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1242851333-325-11-git-send-email-HaraldWelte@viatech.com \
--to=haraldwelte@viatech.com \
--cc=linux-fbdev-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).