From 7e2c8d2a0d83fd54731d2184d55a5ec7bec070c1 Mon Sep 17 00:00:00 2001
From: Rudolf Cornelissen
Date: Tue, 23 Mar 2004 19:39:02 +0000
Subject: [PATCH] full 2D acc works on NM2097 and NM2160 (still with
softcursor)
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7062 a95241bf-73f2-0310-859d-f6bbb57e9c96
---
.../accelerants/neomagic/Acceleration.c | 32 ++-
.../accelerants/neomagic/GetAccelerantHook.c | 8 +-
.../accelerants/neomagic/engine/nm_acc.c | 230 +++++++-----------
.../accelerants/neomagic/engine/nm_general.c | 2 +-
.../accelerants/neomagic/engine/nm_proto.h | 6 +-
.../drivers/graphics/neomagic/UPDATE.html | 4 +-
6 files changed, 121 insertions(+), 161 deletions(-)
diff --git a/src/add-ons/accelerants/neomagic/Acceleration.c b/src/add-ons/accelerants/neomagic/Acceleration.c
index 3e7a22c6d6..665e390890 100644
--- a/src/add-ons/accelerants/neomagic/Acceleration.c
+++ b/src/add-ons/accelerants/neomagic/Acceleration.c
@@ -3,7 +3,7 @@
This file may be used under the terms of the Be Sample Code License.
Other authors:
- Rudolf Cornelissen 4/2003-
+ Rudolf Cornelissen 4/2003-3/2004
*/
#define MODULE_BIT 0x40000000
@@ -13,7 +13,7 @@
void SCREEN_TO_SCREEN_BLIT(engine_token *et, blit_params *list, uint32 count) {
int i;
- /*do each blit*/
+ /* do each blit */
i=0;
while (count--)
{
@@ -33,7 +33,7 @@ void SCREEN_TO_SCREEN_BLIT(engine_token *et, blit_params *list, uint32 count) {
void SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT(engine_token *et, scaled_blit_params *list, uint32 count) {
int i;
- /*do each blit*/
+ /* do each blit */
i=0;
while (count--)
{
@@ -55,7 +55,7 @@ void SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT(engine_token *et, scaled_blit_params
void SCREEN_TO_SCREEN_TRANSPARENT_BLIT(engine_token *et, uint32 transparent_colour, blit_params *list, uint32 count) {
int i;
- /*do each blit*/
+ /* do each blit */
i=0;
while (count--)
{
@@ -76,7 +76,10 @@ void SCREEN_TO_SCREEN_TRANSPARENT_BLIT(engine_token *et, uint32 transparent_colo
void FILL_RECTANGLE(engine_token *et, uint32 colorIndex, fill_rect_params *list, uint32 count) {
int i;
- /*draw each rectangle*/
+ /* init acc engine for fill function */
+ nm_acc_setup_rectangle(colorIndex);
+
+ /* draw each rectangle */
i=0;
while (count--)
{
@@ -85,8 +88,7 @@ void FILL_RECTANGLE(engine_token *et, uint32 colorIndex, fill_rect_params *list,
list[i].left,
(list[i].right)+1,
list[i].top,
- (list[i].bottom-list[i].top)+1,
- colorIndex
+ (list[i].bottom-list[i].top)+1
);
i++;
}
@@ -95,7 +97,10 @@ void FILL_RECTANGLE(engine_token *et, uint32 colorIndex, fill_rect_params *list,
void INVERT_RECTANGLE(engine_token *et, fill_rect_params *list, uint32 count) {
int i;
- /*draw each rectangle*/
+ /* init acc engine for invert function */
+ nm_acc_setup_rect_invert();
+
+ /* invert each rectangle */
i=0;
while (count--)
{
@@ -104,8 +109,7 @@ void INVERT_RECTANGLE(engine_token *et, fill_rect_params *list, uint32 count) {
list[i].left,
(list[i].right)+1,
list[i].top,
- (list[i].bottom-list[i].top)+1,
- 0
+ (list[i].bottom-list[i].top)+1
);
i++;
}
@@ -114,7 +118,10 @@ void INVERT_RECTANGLE(engine_token *et, fill_rect_params *list, uint32 count) {
void FILL_SPAN(engine_token *et, uint32 colorIndex, uint16 *list, uint32 count) {
int i;
- /*draw each span*/
+ /* init acc engine for fill function */
+ nm_acc_setup_rectangle(colorIndex);
+
+ /* draw each span */
i=0;
while (count--)
{
@@ -123,8 +130,7 @@ void FILL_SPAN(engine_token *et, uint32 colorIndex, uint16 *list, uint32 count)
list[i+1],
list[i+2]+1,
list[i],
- 1,
- colorIndex
+ 1
);
i+=3;
}
diff --git a/src/add-ons/accelerants/neomagic/GetAccelerantHook.c b/src/add-ons/accelerants/neomagic/GetAccelerantHook.c
index 2988cdf316..4a11f88bdb 100644
--- a/src/add-ons/accelerants/neomagic/GetAccelerantHook.c
+++ b/src/add-ons/accelerants/neomagic/GetAccelerantHook.c
@@ -112,12 +112,12 @@ void * get_accelerant_hook(uint32 feature, void *data)
/* only export 2D acceleration functions in modes that are capable of it */
/* used by the app_server and applications (BWindowScreen) */
CHKA(SCREEN_TO_SCREEN_BLIT);
-// CHKA(FILL_RECTANGLE);
-// CHKA(INVERT_RECTANGLE);
-// CHKA(FILL_SPAN);
+ CHKA(FILL_RECTANGLE);
+ CHKA(INVERT_RECTANGLE);
+ CHKA(FILL_SPAN);
/* not (yet) used by the app_server:
* so just for application use (BWindowScreen) */
-// CHKA(SCREEN_TO_SCREEN_TRANSPARENT_BLIT);
+ //CHKA(SCREEN_TO_SCREEN_TRANSPARENT_BLIT);
//CHKA(SCREEN_TO_SCREEN_SCALED_FILTERED_BLIT;
}
diff --git a/src/add-ons/accelerants/neomagic/engine/nm_acc.c b/src/add-ons/accelerants/neomagic/engine/nm_acc.c
index c498c4cdca..a5e62f9b58 100644
--- a/src/add-ons/accelerants/neomagic/engine/nm_acc.c
+++ b/src/add-ons/accelerants/neomagic/engine/nm_acc.c
@@ -8,7 +8,7 @@
#include "nm_std.h"
-static status_t nm_acc_wait_fifo(uint32 n);
+//static status_t nm_acc_wait_fifo(uint32 n);
/*acceleration notes*/
@@ -33,35 +33,31 @@ status_t nm_acc_wait_idle()
}
/* wait for enough room in fifo */
-static status_t nm_acc_wait_fifo(uint32 n)
-{
- while (((ACCR(STATUS) & 0x0000ff00) >> 8) < n)
- {
+//static status_t nm_acc_wait_fifo(uint32 n)
+//{
+// while (((ACCR(STATUS) & 0x0000ff00) >> 8) < n)
+// {
/* snooze a bit so I do not hammer the bus */
- snooze (10);
- }
-}
+// snooze (10);
+// }
+//}
/* AFAIK this must be done for every new screenmode.
* Engine required init. */
status_t nm_acc_init()
{
- uint32 depth;
-
/* Set pixel width */
switch(si->dm.space)
{
case B_CMAP8:
/* b8-9 determine engine colordepth */
si->engine.control = (1 << 8);
-// nAcl->ColorShiftAmt = 8;
- depth = 1;
+ si->engine.depth = 1;
break;
case B_RGB15_LITTLE:case B_RGB16_LITTLE:
/* b8-9 determine engine colordepth */
si->engine.control = (2 << 8);
-// nAcl->ColorShiftAmt = 0;
- depth = 2;
+ si->engine.depth = 2;
break;
case B_RGB24_LITTLE:
/* no acceleration supported on NM2097 and NM2160 */
@@ -72,7 +68,7 @@ status_t nm_acc_init()
/* setup memory pitch (b10-12):
* this works with a table, there are very few fixed settings.. */
- switch(si->fbc.bytes_per_row / depth)
+ switch(si->fbc.bytes_per_row / si->engine.depth)
{
case 640:
si->engine.control |= (2 << 10);
@@ -98,13 +94,18 @@ status_t nm_acc_init()
}
/* enable engine FIFO */
-//fixme: does not work yet..
- si->engine.control |= (1 << 27);
+ /* fixme when/if possible:
+ * does not work on most cards.. (tried NM2160)
+ * workaround: always wait until engine completely idle before programming. */
+// si->engine.control |= (1 << 27);
/* setup buffer startadress */
-//fixme! setup..
+ /* fixme when/if possible:
+ * not possible on all cards or not enough specs known :-/ (tried NM2160)
+ * workaround: place cursor bitmap _after_ screenbuffer instead of vice versa. */
- /* fixme?: setup clipping */
+ /* setup clipping */
+ /* apparantly not needed. */
return B_OK;
}
@@ -113,9 +114,10 @@ status_t nm_acc_init()
status_t nm_acc_blit(uint16 xs,uint16 ys,uint16 xd,uint16 yd,uint16 w,uint16 h)
{
/* make sure the previous command (if any) is completed */
- nm_acc_wait_idle();
-//does not work yet:
+// does not work yet:
// nm_acc_wait_fifo(4);
+// so:
+ nm_acc_wait_idle();
if ((yd < ys) || ((yd == ys) && (xd < xs)))
{
@@ -141,129 +143,79 @@ status_t nm_acc_blit(uint16 xs,uint16 ys,uint16 xd,uint16 yd,uint16 w,uint16 h)
return B_OK;
}
-/* screen to screen tranparent blit - not sure what uses this.
- * Engine function bitblit, paragraph 4.5.7.2 */
+/* rectangle fill - i.e. workspace and window background color */
+/* span fill - i.e. (selected) menuitem background color (Dano) */
+status_t nm_acc_setup_rectangle(uint32 color)
+{
+// does not work yet:
+// nm_acc_wait_fifo(2);
+// so:
+ nm_acc_wait_idle();
+
+ /* use ROP GXcopy (b16-19), use XY coord. system (b24-25), do foreground color (b3) */
+ ACCW(BLTCNTL, (si->engine.control | 0x830c0008));
+ /* setup color */
+ ACCW(FGCOLOR, color);
+
+ return B_OK;
+}
+
+status_t nm_acc_rectangle(uint32 xs,uint32 xe,uint32 ys,uint32 yl)
+{
+ /* make sure the previous command (if any) is completed */
+// does not work yet:
+// nm_acc_wait_fifo(2);
+// so:
+ nm_acc_wait_idle();
+
+ /* send command and exexute */
+ ACCW(DSTSTARTOFF, ((ys << 16) | (xs & 0x0000ffff)));
+ ACCW(XYEXT, ((yl << 16) | ((xe - xs) & 0x0000ffff)));
+
+ return B_OK;
+}
+
+/* rectangle invert - i.e. text cursor and text selection */
+status_t nm_acc_setup_rect_invert()
+{
+ /* make sure the previous command (if any) is completed */
+// does not work yet:
+// nm_acc_wait_fifo(4);
+// so:
+ nm_acc_wait_idle();
+
+ /* use ROP GXinvert (b16-19), use XY coord. system (b24-25), do foreground color (b3) */
+ ACCW(BLTCNTL, (si->engine.control | 0x83050008));
+ /* reset color */
+ ACCW(FGCOLOR, 0);
+
+ return B_OK;
+}
+
+status_t nm_acc_rectangle_invert(uint32 xs,uint32 xe,uint32 ys,uint32 yl)
+{
+ /* make sure the previous command (if any) is completed */
+// does not work yet:
+// nm_acc_wait_fifo(4);
+// so:
+ nm_acc_wait_idle();
+
+ /* send command and exexute */
+ ACCW(DSTSTARTOFF, ((ys << 16) | (xs & 0x0000ffff)));
+ ACCW(XYEXT, ((yl << 16) | ((xe - xs) & 0x0000ffff)));
+
+ return B_OK;
+}
+
+/* screen to screen tranparent blit */
status_t nm_acc_transparent_blit(uint16 xs,uint16 ys,uint16 xd,uint16 yd,uint16 w,uint16 h,uint32 colour)
{
+ //fixme: implement.
+
return B_ERROR;
-
- /*find where the top,bottom and offset are*/
-// offset = (si->fbc.bytes_per_row / (depth >> 3));
-
-// t_end = t_start = xs + (offset*ys) + src_dst;
-// t_end += w;
-
-// b_end = b_start = xs + (offset*(ys+h)) + src_dst;
-// b_end +=w;
-
- /* sgnzero bit _must_ be '0' before accessing SGN! */
-// ACCW(DWGCTL,0x00000000);
-
- /*find which quadrant */
- switch((yd>ys)|((xd>xs)<<1))
- {
- case 0: /*L->R,down*/
-// ACCW(SGN,0);
-
-// ACCW(AR3,t_start);
-// ACCW(AR0,t_end);
-// ACCW(AR5,offset);
-
-// ACCW_YDSTLEN(yd,h+1);
- break;
- case 1: /*L->R,up*/
-// ACCW(SGN,4);
-
-// ACCW(AR3,b_start);
-// ACCW(AR0,b_end);
-// ACCW(AR5,-offset);
-
-// ACCW_YDSTLEN(yd+h,h+1);
- break;
- case 2: /*R->L,down*/
-// ACCW(SGN,1);
-
-// ACCW(AR3,t_end);
-// ACCW(AR0,t_start);
-// ACCW(AR5,offset);
-
-// ACCW_YDSTLEN(yd,h+1);
- break;
- case 3: /*R->L,up*/
-// ACCW(SGN,5);
-
-// ACCW(AR3,b_end);
-// ACCW(AR0,b_start);
-// ACCW(AR5,-offset);
-
-// ACCW_YDSTLEN(yd+h,h+1);
- break;
- }
-// ACCW(FXBNDRY,((xd+w)<<16)|xd);
-
- /*do the blit*/
-// ACCW(FCOL,colour);
-// ACCW(BCOL,0xffffffff);
-// ACCGO(DWGCTL,0x440C4018); // atype RSTR
- return B_OK;
}
-/* rectangle fill.
- * Engine function rectangle_fill: paragraph 4.5.5.2 */
-/*colorIndex,fill_rect_params,count*/
-status_t nm_acc_rectangle(uint32 xs,uint32 xe,uint32 ys,uint32 yl,uint32 col)
-{
-/*
- FXBNDRY - left and right coordinates a
- YDSTLEN - y start and no of lines a
- (or YDST and LEN)
- DWGCTL - atype must be RSTR or BLK a
- FCOL - foreground colour a
-*/
-
-// ACCW(FXBNDRY,(xe<<16)|xs); /*set x start and end*/
-// ACCW_YDSTLEN(ys,yl); /*set y start and length*/
-// ACCW(FCOL,col); /*set colour*/
-
-//acc fixme: checkout blockmode constraints for G100+ (mil: nc?): also add blockmode
-// for other functions, and use fastblt on MIL1/2 if possible...
-//or is CMAP8 contraint a non-blockmode contraint? (linearisation problem maybe?)
- if (si->dm.space==B_CMAP8)
- {
-// ACCGO(DWGCTL,0x400C7814); // atype RSTR
- }
- else
- {
-// ACCGO(DWGCTL,0x400C7844); // atype BLK
- }
- return B_OK;
-}
-
-/* rectangle invert.
- * Engine function rectangle_fill: paragraph 4.5.5.2 */
-/*colorIndex,fill_rect_params,count*/
-status_t nm_acc_rectangle_invert(uint32 xs,uint32 xe,uint32 ys,uint32 yl,uint32 col)
-{
-/*
- FXBNDRY - left and right coordinates a
- YDSTLEN - y start and no of lines a
- (or YDST and LEN)
- DWGCTL - atype must be RSTR or BLK a
- FCOL - foreground colour a
-*/
-
-// ACCW(FXBNDRY,(xe<<16)|xs); /*set x start and end*/
-// ACCW_YDSTLEN(ys,yl); /*set y start and length*/
-// ACCW(FCOL,col); /*set colour*/
-
- /*draw it! top nibble is c is clipping enabled*/
-// ACCGO(DWGCTL,0x40057814); // atype RSTR
-
- return B_OK;
-}
-
-/* screen to screen scaled filtered blit - i.e. scale video in memory.
- * Engine function texture mapping for video, paragraphs 4.5.5.5 - 4.5.5.9 */
+/* screen to screen scaled filtered blit - i.e. scale video in memory */
status_t nm_acc_video_blit(uint16 xs,uint16 ys,uint16 ws, uint16 hs,
uint16 xd,uint16 yd,uint16 wd,uint16 hd)
{
diff --git a/src/add-ons/accelerants/neomagic/engine/nm_general.c b/src/add-ons/accelerants/neomagic/engine/nm_general.c
index e6160a8874..e71fcf63be 100644
--- a/src/add-ons/accelerants/neomagic/engine/nm_general.c
+++ b/src/add-ons/accelerants/neomagic/engine/nm_general.c
@@ -47,7 +47,7 @@ status_t nm_general_powerup()
{
status_t status;
- LOG(1,("POWERUP: Neomagic (open)BeOS Accelerant 0.06-2 running.\n"));
+ LOG(1,("POWERUP: Neomagic (open)BeOS Accelerant 0.06-3 running.\n"));
/* detect card type and power it up */
switch(CFGR(DEVID))
diff --git a/src/add-ons/accelerants/neomagic/engine/nm_proto.h b/src/add-ons/accelerants/neomagic/engine/nm_proto.h
index c4cf956d35..376dff1e5b 100644
--- a/src/add-ons/accelerants/neomagic/engine/nm_proto.h
+++ b/src/add-ons/accelerants/neomagic/engine/nm_proto.h
@@ -55,9 +55,11 @@ status_t nm_crtc_cursor_hide(void);
/*acceleration functions*/
status_t check_acc_capability(uint32 feature);
status_t nm_acc_init(void);
-status_t nm_acc_rectangle(uint32 xs,uint32 xe,uint32 ys,uint32 yl,uint32 col);
-status_t nm_acc_rectangle_invert(uint32 xs,uint32 xe,uint32 ys,uint32 yl,uint32 col);
status_t nm_acc_blit(uint16,uint16,uint16, uint16,uint16,uint16 );
+status_t nm_acc_setup_rectangle(uint32 color);
+status_t nm_acc_rectangle(uint32 xs,uint32 xe,uint32 ys,uint32 yl);
+status_t nm_acc_setup_rect_invert(void);
+status_t nm_acc_rectangle_invert(uint32 xs,uint32 xe,uint32 ys,uint32 yl);
status_t nm_acc_transparent_blit(uint16,uint16,uint16, uint16,uint16,uint16, uint32);
status_t nm_acc_video_blit(uint16 xs,uint16 ys,uint16 ws, uint16 hs,
uint16 xd,uint16 yd,uint16 wd,uint16 hd);
diff --git a/src/add-ons/kernel/drivers/graphics/neomagic/UPDATE.html b/src/add-ons/kernel/drivers/graphics/neomagic/UPDATE.html
index 886d54ff8a..4562a14420 100644
--- a/src/add-ons/kernel/drivers/graphics/neomagic/UPDATE.html
+++ b/src/add-ons/kernel/drivers/graphics/neomagic/UPDATE.html
@@ -4,14 +4,14 @@
Changes done for each driverversion:
-head (0.06-2, Rudolf)
+head (0.06-3, Rudolf)
- Updated modelist to include one more suggested mode for 800x600 resolution: Done by Andrew Bachmann;
- CRTC timing restriction checking updated: Modelists exported adhere to every cards max. CRTC capability now: the oldest cards support upto and including 1024x1000, while the newest cards support upto and including 1280x1024 resolution;
- Kernel driver now signals abort on not being able to setup the INT routine instead of letting the machine freeze during accelerant initialisation;
- BWindowScreen R3-style function update for acceleration (once setup) and page flipping/virtualscreens in apps ('Allegro' update): fixed cloning accelerants;
- Updated acceleration engine management code;
-
- Added partial acceleration for NM2097 and NM2160 (screen_to_screen blit).
+
- Added full 2D acceleration for NM2097 and NM2160 cards (the others will be added later): use softcursor for now!!
nm_driver 0.05 (Rudolf)