* [PATCH] pm2fb: accelerated fillrect and copyarea
@ 2007-04-30 18:57 Krzysztof Helt
2007-04-30 21:21 ` Antonino A. Daplas
0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Helt @ 2007-04-30 18:57 UTC (permalink / raw)
To: linux-fbdev-devel
[-- Attachment #1: Type: text/plain, Size: 465 bytes --]
From: Krzysztof Helt <krzysztof.h1@wp.pl>
This is port of accelerated functions from 2.4 kernel. Only
fillrect and copyarea are accelerated. Fillrect is not
accelerated in 24-bit mode.
Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
---
This is patch against 2.6.21 kernel.
----------------------------------------------------
Sprawdź ile wart jest Twój samochód.
Wycena aut jak na dłoni: http://klik.wp.pl/?adr=www.wycenyaut.wp.pl&sid=1117
[-- Attachment #2: pm2fb-fillrect.diff --]
[-- Type: application/octet-stream, Size: 4261 bytes --]
--- linux-2.6.21.new/drivers/video/pm2fb.c 2007-04-29 21:01:48.079784118 +0200
+++ linux-2.6.21/drivers/video/pm2fb.c 2007-04-29 21:07:37.182526781 +0200
@@ -103,7 +103,7 @@ static struct fb_fix_screeninfo pm2fb_fi
.xpanstep = 1,
.ypanstep = 1,
.ywrapstep = 0,
- .accel = FB_ACCEL_NONE,
+ .accel = FB_ACCEL_3DLABS_PERMEDIA2,
};
/*
@@ -206,6 +206,17 @@ static inline void WAIT_FIFO(struct pm2f
}
#endif
+static void wait_pm2(struct pm2fb_par* par) {
+
+ WAIT_FIFO(par, 1);
+ pm2_WR(par, PM2R_SYNC, 0);
+ mb();
+ do {
+ while (pm2_RD(par, PM2R_OUT_FIFO_WORDS) == 0);
+ rmb();
+ } while (pm2_RD(par, PM2R_OUT_FIFO) != PM2TAG(PM2R_SYNC));
+}
+
/*
* partial products for the supported horizontal resolutions.
*/
@@ -1039,6 +1052,117 @@ static int pm2fb_blank(int blank_mode, s
return 0;
}
+/*
+ * block operation. copy=0: rectangle fill, copy=1: rectangle copy.
+ */
+static void pm2fb_block_op(struct pm2fb_par* par, int copy,
+ s32 xsrc, s32 ysrc,
+ s32 x, s32 y, s32 w, s32 h,
+ u32 color) {
+
+ if (!w || !h)
+ return;
+ WAIT_FIFO(par, 6);
+ pm2_WR(par, PM2R_CONFIG, PM2F_CONFIG_FB_WRITE_ENABLE |
+ PM2F_CONFIG_FB_READ_SOURCE_ENABLE);
+ pm2_WR(par, PM2R_FB_PIXEL_OFFSET, 0);
+ if (copy)
+ pm2_WR(par, PM2R_FB_SOURCE_DELTA,
+ ((ysrc-y) & 0xfff) << 16 | ((xsrc-x) & 0xfff));
+ else
+ pm2_WR(par, PM2R_FB_BLOCK_COLOR, color);
+ pm2_WR(par, PM2R_RECTANGLE_ORIGIN, (y << 16) | x);
+ pm2_WR(par, PM2R_RECTANGLE_SIZE, (h << 16) | w);
+ wmb();
+ pm2_WR(par, PM2R_RENDER,PM2F_RENDER_RECTANGLE |
+ (x<xsrc ? PM2F_INCREASE_X : 0) |
+ (y<ysrc ? PM2F_INCREASE_Y : 0) |
+ (copy ? 0 : PM2F_RENDER_FASTFILL));
+ wait_pm2(par);
+}
+
+static void pm2fb_fillrect (struct fb_info *info,
+ const struct fb_fillrect *region)
+{
+ struct pm2fb_par *par = info->par;
+ struct fb_fillrect modded;
+ int vxres, vyres;
+ u32 color = (info->fix.visual == FB_VISUAL_TRUECOLOR) ?
+ ((u32*)info->pseudo_palette)[region->color] : region->color;
+
+ if (info->state != FBINFO_STATE_RUNNING)
+ return;
+ if ((info->flags & FBINFO_HWACCEL_DISABLED) ||
+ region->rop != ROP_COPY ) {
+ cfb_fillrect(info, region);
+ return;
+ }
+
+ vxres = info->var.xres_virtual;
+ vyres = info->var.yres_virtual;
+
+ memcpy(&modded, region, sizeof(struct fb_fillrect));
+
+ if(!modded.width || !modded.height ||
+ modded.dx >= vxres || modded.dy >= vyres)
+ return;
+
+ if(modded.dx + modded.width > vxres)
+ modded.width = vxres - modded.dx;
+ if(modded.dy + modded.height > vyres)
+ modded.height = vyres - modded.dy;
+
+ if(info->var.bits_per_pixel == 8)
+ color |= color << 8;
+ if(info->var.bits_per_pixel <= 16)
+ color |= color << 16;
+
+ if(info->var.bits_per_pixel != 24)
+ pm2fb_block_op(par, 0, 0, 0,
+ modded.dx, modded.dy,
+ modded.width, modded.height, color);
+ else
+ cfb_fillrect(info, region);
+}
+
+static void pm2fb_copyarea(struct fb_info *info,
+ const struct fb_copyarea *area)
+{
+ struct pm2fb_par *par = info->par;
+ struct fb_copyarea modded;
+ u32 vxres, vyres;
+
+ if (info->state != FBINFO_STATE_RUNNING)
+ return;
+ if (info->flags & FBINFO_HWACCEL_DISABLED) {
+ cfb_copyarea(info, area);
+ return;
+ }
+
+ memcpy(&modded, area, sizeof(struct fb_copyarea));
+
+ vxres = info->var.xres_virtual;
+ vyres = info->var.yres_virtual;
+
+ if(!modded.width || !modded.height ||
+ modded.sx >= vxres || modded.sy >= vyres ||
+ modded.dx >= vxres || modded.dy >= vyres)
+ return;
+
+ if(modded.sx + modded.width > vxres)
+ modded.width = vxres - modded.sx;
+ if(modded.dx + modded.width > vxres)
+ modded.width = vxres - modded.dx;
+ if(modded.sy + modded.height > vyres)
+ modded.height = vyres - modded.sy;
+ if(modded.dy + modded.height > vyres)
+ modded.height = vyres - modded.dy;
+
+ pm2fb_block_op(par, 1, modded.sx, modded.sy,
+ modded.dx, modded.dy,
+ modded.width, modded.height, 0);
+}
+
/* ------------ Hardware Independent Functions ------------ */
/*
@@ -1052,8 +1176,8 @@ static struct fb_ops pm2fb_ops = {
.fb_setcolreg = pm2fb_setcolreg,
.fb_blank = pm2fb_blank,
.fb_pan_display = pm2fb_pan_display,
- .fb_fillrect = cfb_fillrect,
- .fb_copyarea = cfb_copyarea,
+ .fb_fillrect = pm2fb_fillrect,
+ .fb_copyarea = pm2fb_copyarea,
.fb_imageblit = cfb_imageblit,
};
[-- Attachment #3: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #4: Type: text/plain, Size: 182 bytes --]
_______________________________________________
Linux-fbdev-devel mailing list
Linux-fbdev-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-fbdev-devel
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] pm2fb: accelerated fillrect and copyarea
2007-04-30 18:57 [PATCH] pm2fb: accelerated fillrect and copyarea Krzysztof Helt
@ 2007-04-30 21:21 ` Antonino A. Daplas
2007-05-01 10:11 ` [PATCH] pm2fb: accelerated fillrect andcopyarea Krzysztof Helt
0 siblings, 1 reply; 3+ messages in thread
From: Antonino A. Daplas @ 2007-04-30 21:21 UTC (permalink / raw)
To: linux-fbdev-devel
On Mon, 2007-04-30 at 20:57 +0200, Krzysztof Helt wrote:
> From: Krzysztof Helt <krzysztof.h1@wp.pl>
>
> This is port of accelerated functions from 2.4 kernel. Only
> fillrect and copyarea are accelerated. Fillrect is not
> accelerated in 24-bit mode.
For the best scrolling mode, you would want to advertise the driver's
capability with:
info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT;
I'll add this myself.
Tony
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pm2fb: accelerated fillrect andcopyarea
2007-04-30 21:21 ` Antonino A. Daplas
@ 2007-05-01 10:11 ` Krzysztof Helt
0 siblings, 0 replies; 3+ messages in thread
From: Krzysztof Helt @ 2007-05-01 10:11 UTC (permalink / raw)
To: Antonino A.Daplas; +Cc: linux-fbdev-devel
Dnia 30-04-2007 o godz. 23:21 Antonino A. Daplas napisa³(a):
> For the best scrolling mode, you would want to advertise the
driver's
> capability with:
>
> info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
> FBINFO_HWACCEL_COPYAREA | FBINFO_HWACCEL_FILLRECT;
>
> I'll add this myself.
>
Thank you. I am quite new to fbdev and I still learn.
Regards,
Krzysztof
----------------------------------------------------
Zobacz, jak± walkê stoczy superbohater, by ocaliæ siebie
i swych bliskich. A najwiêksza bitwa rozegra siê w jego duszy.
SPIDER-MAN 3 w kinach od 4 maja.
http://klik.wp.pl/?adr=http%3A%2F%2Fadv.reklama.wp.pl%2Fas%2Fspiderman3.html&sid=1122
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-05-01 10:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-30 18:57 [PATCH] pm2fb: accelerated fillrect and copyarea Krzysztof Helt
2007-04-30 21:21 ` Antonino A. Daplas
2007-05-01 10:11 ` [PATCH] pm2fb: accelerated fillrect andcopyarea Krzysztof Helt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.