From b3fee1b5e74004dd4d9be867979ae8c0cb98cdcd Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Thu, 16 Oct 2008 12:00:10 +0000 Subject: [PATCH] cleanup git-svn-id: svn://kolibrios.org@879 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/develop/sdk/trunk/HDraw/hdraw.inc | 122 ------- programs/develop/sdk/trunk/pixlib/pixlib.inc | 260 ++++++++++++++ programs/develop/sdk/trunk/pixlib/readme.txt | 224 ++++++++++++ programs/system/drivers/ati2d/accel_2d.h | 61 ++-- programs/system/drivers/ati2d/accel_2d.inc | 351 +++++++++++-------- programs/system/drivers/ati2d/accel_3d.inc | 2 + programs/system/drivers/ati2d/ati2d.c | 32 +- programs/system/drivers/ati2d/init.c | 6 +- programs/system/drivers/ati2d/makefile | 2 +- programs/system/drivers/ati2d/r500.inc | 36 +- 10 files changed, 756 insertions(+), 340 deletions(-) delete mode 100644 programs/develop/sdk/trunk/HDraw/hdraw.inc create mode 100644 programs/develop/sdk/trunk/pixlib/pixlib.inc create mode 100644 programs/develop/sdk/trunk/pixlib/readme.txt diff --git a/programs/develop/sdk/trunk/HDraw/hdraw.inc b/programs/develop/sdk/trunk/HDraw/hdraw.inc deleted file mode 100644 index 2814f118a4..0000000000 --- a/programs/develop/sdk/trunk/HDraw/hdraw.inc +++ /dev/null @@ -1,122 +0,0 @@ - -SRV_GETVERSION equ 0 -SOLID_FILL equ 1 -LINE2P equ 2 - -io.handle equ esp -io.code equ esp+4 -io.input equ esp+8 -io.inp_size equ esp+12 -io.output equ esp+16 -io.out_size equ esp+20 - -IOSIZE equ 24 - -; retval -; ebx= service version -; eax= error code -; 0= no error -; -1= common error - -align 4 - -init_HDraw: - mov eax, 68 - mov ebx, 16 - mov ecx, szHDraw - int 0x40 - - mov [HDraw], eax - test eax, eax - jz .fail - - push 0 ;storage for version - mov eax, esp - xor ebx, ebx - - push 4 ;.out_size - push eax ;.output - push ebx ;.inp_size - push ebx ;.input - push SRV_GETVERSION ;.code - push [HDraw] ;.handle - - mov eax, 68 - mov ebx, 17 - mov ecx, esp - int 0x40 - add esp, IOSIZE - pop ebx ;version - ret -.fail: - or eax, -1 - ret - -; param -; eax= color -; ebx= x -; ecx= y -; edx= w -; esi= h - -; retval -; eax= error code - -align 4 -solid_fill: - - push esi - push edx - push ecx - push ebx - push eax - - xor eax, eax - mov ebx, esp ;FILL - - push eax ;.out_size - push eax ;.output - push 5 ;.inp_size - push ebx ;.input - push SOLID_FILL ;.code - push [HDraw] ;.handle - - mov eax, 68 - mov ebx, 17 - mov ecx, esp - int 0x40 - add esp, (IOSIZE+5*4) ;io_control+FILL - ret - -align 4 -line2p: - push esi ;y2 - push edx ;x2 - push ecx ;y1 - push ebx ;x1 - push eax ;color - - xor eax, eax - mov ebx, esp ;LINE2P - - push eax ;.out_size - push eax ;.output - push 5 ;.inp_size - push ebx ;.input - push LINE2P ;.code - push [HDraw] ;.handle - - mov eax, 68 - mov ebx, 17 - mov ecx, esp - int 0x40 - add esp, (IOSIZE+5*4) ;io_control+LINE2P - ret - - -align 4 -HDraw rd 1 - -szHDraw db 'HDRAW',0 - - diff --git a/programs/develop/sdk/trunk/pixlib/pixlib.inc b/programs/develop/sdk/trunk/pixlib/pixlib.inc new file mode 100644 index 0000000000..30e0634754 --- /dev/null +++ b/programs/develop/sdk/trunk/pixlib/pixlib.inc @@ -0,0 +1,260 @@ + +REQ_DLL_VER = 1 +DLL_ENTRY = 1 + +HS_HORIZONTAL = 0 +HS_VERTICAL = 1 +HS_FDIAGONAL = 2 +HS_BDIAGONAL = 3 +HS_CROSS = 4 +HS_DIAGCROSS = 5 + +SCR_PIXMAP = -1 + +PX_MEM_SYSTEM = 0 +PX_MEM_LOCAL = 1 +PX_MEM_GART = 2 + +PX_MEM_MASK = 3 + +ARGB32 = ((32 shl 24) or (2 shl 16) or 0x8888) + +macro CreateHatch hatch, bkcolor, fcolor +{ + pushd fcolor + pushd bkcolor + pushd hatch + call [imp_CreateHatch] + add esp, 3*4 +} + +macro DestroyBrush brush +{ + pushd brush + call [imp_DestroyBrush] + add esp, 4 +} + +macro CreatePixmap width, height, format, flags +{ + pushd flags + pushd format + pushd height + pushd width + call [imp_CreatePixmap] + add esp, 4*4 +} + +macro DestroyPixmap pixmap +{ + pushd pixmap + call [imp_DestroyPixmap] + add esp, 4 +}; + +macro LockPixmap pixmap +{ + pushd pixmap + call [imp_LockPixmap] + add esp, 4 +} + +macro UnlockPixmap pixmap +{ + pushd pixmap + call [imp_UnlockPixmap] + add esp, 4 +} + +macro ClearPixmap pixmap, color +{ + pushd color + pushd pixmap + call [imp_ClearPixmap] + add esp, 2*4 +} + +macro Line pixmap, x0,y0,x1,y1,color +{ + pushd color + pushd y1 + pushd x1 + pushd y0 + pushd x0 + pushd pixmap + call [imp_Line] + add esp, 6*4 +}; + +macro DrawRect pixmap,x,y,w,h,color,border +{ + pushd border + pushd color + pushd h + pushd w + pushd y + pushd x + pushd pixmap + call [imp_DrawRect] + add esp, 7*4 +} + +macro FillRect pixmap,x,y,w,h,brush,border +{ + pushd border + pushd brush + pushd h + pushd w + pushd y + pushd x + pushd pixmap + call [imp_FillRect] + add esp, 7*4 +} + +macro Blit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h +{ + pushd h + pushd w + pushd srcy + pushd srcx + pushd srcpix + pushd dsty + pushd dstx + pushd dstpix + call [imp_Blit] + add esp, 8*4 +} + +macro TransparentBlit dstpix, dstx, dsty, srcpix, srcx, srcy, w, h, key +{ + pushd key + pushd h + pushd w + pushd srcy + pushd srcx + pushd srcpix + pushd dsty + pushd dstx + pushd dstpix + call [imp_TransparentBlit] + add esp, 9*4 +} + +szPxlib db '/rd/1/lib/pixlib.obj',0 + +szStart db 'START',0 +szVersion db 'version',0 + +szCreatePixmap db 'CreatePixmap',0 +szDestroyPixmap db 'DestroyPixmap',0 +szLockPixmap db 'LockPixmap',0 +szUnlockPixmap db 'UnlockPixmap',0 +szGetPixmapPitch db 'GetPixmapPitch',0 + +szCreateHatch db 'CreateHatch',0 +szCreateMonoBrush db 'CreateMonoBrush',0 +szDestroyBrush db 'DestroyBrush',0 + +szClearPixmap db 'ClearPixmap',0 +szLine db 'Line',0 +szDrawRect db 'DrawRect',0 +szFillRect db 'FillRect',0 +szBlit db 'Blit',0 +szTransparentBlit db 'TransparentBlit',0 + +align 4 + +px_import: + +imp_start dd szStart +imp_ver dd szVersion + +imp_CreatePixmap dd szCreatePixmap +imp_DestroyPixmap dd szDestroyPixmap +imp_LockPixmap dd szLockPixmap +imp_UnlockPixmap dd szUnlockPixmap +imp_GetPixmapPitch dd szGetPixmapPitch + +imp_CreateHatch dd szCreateHatch +imp_CreateMonoBrush dd szCreateMonoBrush +imp_DestroyBrush dd szDestroyBrush + +imp_ClearPixmap dd szClearPixmap +imp_Line dd szLine +imp_DrawRect dd szDrawRect +imp_FillRect dd szFillRect +imp_Blit dd szBlit +imp_TransparentBlit dd szTransparentBlit + + dd 0 + + +;szBlockClip db 'BlockClip',0 +;szLineClip db 'LineClip',0 +;imp_BlockClip dd szBlockClip +;imp_LineClip dd szLineClip + + +align 4 + +load_pxlib: + mov eax, 68 + mov ebx, 19 + mov ecx, szPxlib + int 0x40 + test eax, eax + jz .fail + + mov edx, eax + mov esi, px_import +.import_loop: + lodsd + test eax, eax + jz .import_done + push edx +.import_find: + mov ebx, [edx] + test ebx, ebx + jz .fail ;import_not_found + + push eax +@@: + mov cl, [eax] + cmp cl, [ebx] + jnz .import_find_next + + test cl, cl + jz .import_found + + inc eax + inc ebx + jmp @b +.import_find_next: + pop eax + add edx, 8 + jmp .import_find +.import_found: + pop eax + mov eax, [edx+4] + mov [esi-4], eax + pop edx + jmp .import_loop +.import_done: + + cmp word [imp_ver], REQ_DLL_VER + jb .fail + cmp word [imp_ver+2], REQ_DLL_VER + ja .fail + + push DLL_ENTRY + call [imp_start] + test eax, eax + jz .fail + + ret +.fail: + xor eax, eax + ret + + diff --git a/programs/develop/sdk/trunk/pixlib/readme.txt b/programs/develop/sdk/trunk/pixlib/readme.txt new file mode 100644 index 0000000000..9f5b643244 --- /dev/null +++ b/programs/develop/sdk/trunk/pixlib/readme.txt @@ -0,0 +1,224 @@ + +typedef unsigned int u32_t; +typedef unsignet int handle; +typedef unsigned int color_t; + + +handle CreateHatchBrush(int hatch, color_t bkcolor, color_t fcolor); + +Создать штрихованную кисть размером 8х8 пикселей + +hatch тип штриховки + +bkcolor цвет "0" + +fcolor цвет "1" + + +Возвращаемое значение: логический номер кисти или 0 + + + + +handle CreateMonoBrush(color_t bkcolor, color_t fcolor, + u32_t bmp0, u32_t bmp1); + +Создать монохромную кисть размером 8х8 пикселей + +bkcolor цвет "0" + +fcolor цвет "1" + +bmp0 bmp1 монохромный битмап 8х8 пикселей + + +Возвращаемое значение: логический номер кисти или 0 + + + +void DestroyBrush(handle brush); + +Уничтожить кисть. + +brush логический номер кисти. + + +Кисть должна быть создана вызовом CreateHatchBrush или CreateMonoBrush + + + + +handle CreatePixmap(unsigned width, unsigned height, u32_t format, u32_t flags); + +Создать битмап + +width ширина в пикселях. Максимум 2048 + +height высота в пикселях. Максимум 2048 + +format формат пикселей. Сейчас поддерживается только ARGB32 + +flags дополнительные флаги: + + PX_MEM_SYSTEM = 0 битмап в системной памяти + PX_MEM_LOCAL = 1 битмап в локальной видеопамяти + PX_MEM_GART = 2 зарезервировано + остальные биты зарезервированы и должны быть 0 + + +Возвращаемое значение: логический номер битмапа в случае успеха или 0 + + + + +int DestroyPixmap( handle pixmap) + +Уничтожить битмап. + +pixmap логический номер битмапа. + +Битмап должен быть создан CreatePixmap. + + +Возвращаемое значение: ERR_OK в случае успеха или ERR_PARAM в случае неудачи. + + + + +int ClearPixmap(handle pixmap, color_t color) + +Заполняет битмап указанным цветом; + +pixmap логический номер битмапа. SCR_PIXMAP для первичного экрана. + +color цвет в формате ARGB32 + + +Возвращаемое значение: ERR_OK в случае успеха или ERR_PARAM в случае неудачи. + + + + +int Line(handle pixmap, int x0, int y0, int x1, int y1, color_t color) + +Нарисовать сплошную линию указаного цвета толщиной в 1 пиксель. + +pixmap логический номер битмапа в который будет производится отрисовка. + SCR_PIXMAP для первичного экрана + +x0,y0 x1,y1 координаты начальной и конечной точек линиии + +color цвет в формате ARGB32 + + +Возвращаемое значение: ERR_OK в случае успеха или ERR_PARAM в случае неудачи. + + + + +int DrawRect(handle pixmap, int xorg, int yorg, + int width, int height, + color_t dst_color, color_t border) + +Нарисовать сплошной прямоугльник указаного цвета c окантовкой. + +pixmap логический номер битмапа в который будет производится отрисовка. + SCR_PIXMAP для первичного экрана + +xorg,yorg координаты левого верхнего угла прямоугольника в пикселях + +width ширина прямоугольника в пикселях + +height высота прямоугольника в пикселях + +color цвет прямоугольника в формате ARGB32 + +border цвет окантовки в формате ARGB32. Толщина окантовки 1 пиксел. + + +Возвращаемое значение: ERR_OK в случае успеха или ERR_PARAM в случае неудачи. + + + + +int FillRect(handle pixmap, int xorg, int yorg, + int width, int height, + brush_t *brush, color_t border) + +Нарисовать прямоугольник используя кисть + +pixmap логический номер битмапа в который будет производится отрисовка. + SCR_PIXMAP для первичного экрана + +xorg,yorg координаты левого верхнего угла прямоугольника в пикселях + +width ширина прямоугольника в пикселях + +height высота прямоугольника в пикселях + +brush монохромная кисть размером 8х8 пикселей + +border цвет окантовки в формате ARGB32. Толщина окантовки 1 пиксел. + Окантовка не рисуется если альфа компонен цвета равен 0. + + +Кисть должна быть создана CreateHatch или CreateMonoBrush. + + +Возвращаемое значение: ERR_OK в случае успеха или ERR_PARAM в случае неудачи. + + + + +int Blit(handle dst_pixmap, int dst_x, int dst_y, + handle src_pixmap, int src_x, int src_y, + int width, int height) + +Скопировать прямоугольную область пикселей. + +dst_pixmap логический номер битмапа в который будет производится + копирование. SCR_PIXMAP для первичного экрана. + +dst_x, dst_y координаты левого верхнего угла области назначения + +src_pixmap логический номер битмапа - источника пикселей. + SCR_PIXMAP для первичного экрана. + +src_x,src_y координаты левого верхнего угла копируемой области + +width ширина копируемой области + +height высота копируемой области + +Возвращаемое значение: ERR_OK в случае успеха или ERR_PARAM в случае неудачи. + + + + +int TransparentBlit(handle dst_pixmap, int dst_x, int dst_y, + handle src_pixmap, int src_x, int src_y, + int width, int height, color_t key) + +Скопировать прямоугольную область пикселей используя прозрачный цвет. + +dst_pixmap логический номер битмапа в который будет производится + копирование. SCR_PIXMAP для первичного экрана. + +dst_x, dst_y координаты левого верхнего угла области назначения + +src_pixmap логический номер битмапа - источника пикселей. + SCR_PIXMAP для первичного экрана. + +src_x,src_y координаты левого верхнего угла копируемой области + +width ширина копируемой области + +height высота копируемой области + +key прозрачный цвет в формате ARGB32 + + +Функция не копирует пиксели цвет которых совпадает с key. + + +Возвращаемое значение: ERR_OK в случае успеха или ERR_PARAM в случае неудачи. diff --git a/programs/system/drivers/ati2d/accel_2d.h b/programs/system/drivers/ati2d/accel_2d.h index b2f9dfc3da..615da15f94 100644 --- a/programs/system/drivers/ati2d/accel_2d.h +++ b/programs/system/drivers/ati2d/accel_2d.h @@ -1,15 +1,14 @@ #define PX_CREATE 1 #define PX_DESTROY 2 -#define PX_DRAW_RECT 3 -#define PX_FILL_RECT 4 -#define PX_LINE 5 -#define PX_BLIT 6 -#define PX_BLIT_TRANSPARENT 7 -#define PX_BLIT_ALPHA 8 +#define PX_CLEAR 3 +#define PX_DRAW_RECT 4 +#define PX_FILL_RECT 5 +#define PX_LINE 6 +#define PX_BLIT 7 +#define PX_BLIT_TRANSPARENT 8 +#define PX_BLIT_ALPHA 9 -//#define BLIT 4 -//#define COMPIZ 5 typedef unsigned int color_t; @@ -65,13 +64,16 @@ typedef struct void *local; }local_pixmap_t; -//int CreatePixmap(userpixmap_t *io); -//int DestroyPixmap(userpixmap_t *io); -//int LockPixmap(userpixmap_t *io); -//int UnlockPixmap(userpixmap_t *io); #define PX_LOCK 1 +typedef struct +{ + local_pixmap_t *dstpix; + + color_t color; +}io_clear_t; + typedef struct { local_pixmap_t *dstpix; @@ -96,7 +98,7 @@ typedef struct }; color_t color; color_t border; -}draw_t; +}io_draw_t; typedef struct { @@ -112,17 +114,8 @@ typedef struct u32_t bmp0; u32_t bmp1; -}fill_t; - -typedef struct -{ - int src_x; - int src_y; - int dst_x; - int dst_y; - int w; - int h; -}blit_t; + color_t border; +}io_fill_t; typedef struct { @@ -135,20 +128,26 @@ typedef struct int src_y; int w; int h; -}pixblit_t; + + color_t key; +}io_blit_t; -int Line2P(draw_t *draw); +int CreatePixmap(pixmap_t *io); -int DrawRect(draw_t * draw); -int FillRect(fill_t * fill); +int DestroyPixmap(pixmap_t *io); -int Blit(blit_t *blit); +int ClearPixmap(io_clear_t *io); -int RadeonComposite( blit_t *blit); +int Line(io_draw_t *draw); +int DrawRect(io_draw_t * draw); -int PixBlit(pixblit_t* blit); +int FillRect(io_fill_t * fill); + +int Blit(io_blit_t* blit); + +int BlitTransparent(io_blit_t* blit); diff --git a/programs/system/drivers/ati2d/accel_2d.inc b/programs/system/drivers/ati2d/accel_2d.inc index 2c5ffcb235..ba4b1d8d76 100644 --- a/programs/system/drivers/ati2d/accel_2d.inc +++ b/programs/system/drivers/ati2d/accel_2d.inc @@ -1,5 +1,64 @@ -int Line(draw_t *draw) + +int ClearPixmap(io_clear_t *io) +{ + u32_t ifl; + u32_t *ring, write; + + local_pixmap_t *dstpixmap; + + dstpixmap = (io->dstpix == (void*)-1) ? &scr_pixmap : io->dstpix ; + + ifl = safe_cli(); + +#if R300_PIO + + R5xxFIFOWait(6); + + OUTREG(R5XX_DP_GUI_MASTER_CNTL, + RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_32BPP | + RADEON_GMC_SRC_DATATYPE_COLOR | + R5XX_GMC_CLR_CMP_CNTL_DIS | + R5XX_GMC_WR_MSK_DIS | + R5XX_ROP3_P + ); + + OUTREG(R5XX_DP_BRUSH_FRGD_CLR, io->color); + OUTREG(R5XX_DP_CNTL, R5XX_DST_X_LEFT_TO_RIGHT | R5XX_DST_Y_TOP_TO_BOTTOM); + OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset); + OUTREG(R5XX_DST_Y_X, 0); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(dstpixmap->width<<16)|dstpixmap->height); + +#else + BEGIN_RING(); + OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4)); + + OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_32BPP | + RADEON_GMC_SRC_DATATYPE_COLOR | + R5XX_GMC_CLR_CMP_CNTL_DIS | + R5XX_GMC_WR_MSK_DIS | + R5XX_ROP3_P + ); + + OUT_RING(dstpixmap->pitch_offset); + OUT_RING(io->color); + OUT_RING( 0 ); + OUT_RING((dstpixmap->width<<16)|dstpixmap->height); + COMMIT_RING(); + +#endif + + safe_sti(ifl); + + return ERR_OK; +} + + +int Line(io_draw_t *draw) { local_pixmap_t *dstpixmap; clip_t clip; @@ -30,11 +89,12 @@ int Line(draw_t *draw) R5xxFIFOWait(6); OUTREG(R5XX_DP_GUI_MASTER_CNTL, - rhd.gui_control | - R5XX_GMC_BRUSH_SOLID_COLOR | - R5XX_GMC_SRC_DATATYPE_COLOR | - R5XX_GMC_CLR_CMP_CNTL_DIS | - R5XX_GMC_WR_MSK_DIS | + RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_32BPP | + RADEON_GMC_SRC_DATATYPE_COLOR | + R5XX_GMC_CLR_CMP_CNTL_DIS | + R5XX_GMC_WR_MSK_DIS | R5XX_ROP3_P ); @@ -68,7 +128,7 @@ int Line(draw_t *draw) return ERR_OK; } -int DrawRect(draw_t* draw) +int DrawRect(io_draw_t* draw) { int x0, y0, x1, y1, xend, yend; @@ -108,12 +168,13 @@ int DrawRect(draw_t* draw) R5xxFIFOWait(6); OUTREG(R5XX_DP_GUI_MASTER_CNTL, - rhd.gui_control | - R5XX_ROP3_P | - R5XX_GMC_BRUSH_SOLID_COLOR | - R5XX_GMC_SRC_DATATYPE_COLOR | - R5XX_GMC_CLR_CMP_CNTL_DIS | - R5XX_GMC_WR_MSK_DIS + RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_32BPP | + RADEON_GMC_SRC_DATATYPE_COLOR | + R5XX_GMC_CLR_CMP_CNTL_DIS | + R5XX_GMC_WR_MSK_DIS | + R5XX_ROP3_P ); OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color); @@ -182,19 +243,19 @@ int DrawRect(draw_t* draw) return ERR_OK; } -int FillRect(fill_t *fill) +int FillRect(io_fill_t *fill) { local_pixmap_t *dstpixmap; clip_t dst_clip; - int x0, y0, x1, y1; + int x0, y0, x1, y1, xend, yend; dstpixmap = (fill->dstpix == (void*)-1) ? &scr_pixmap : fill->dstpix ; x0 = fill->x; y0 = fill->y; - x1 = x0+fill->w-1; - y1 = y0+fill->h-1; + xend = x1 = x0 + fill->w - 1; + yend = y1 = y0 + fill->h - 1; dst_clip.xmin = 0; dst_clip.ymin = 0; @@ -211,8 +272,8 @@ int FillRect(fill_t *fill) #if R300_PIO - int w = x1-x0+1; - int h = y1-y0+1; + int w = x1 - x0 + 1; + int h = y1 - y0 + 1; R5xxFIFOWait(9); @@ -237,6 +298,57 @@ int FillRect(fill_t *fill) OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); OUTREG(R5XX_DST_HEIGHT_WIDTH,(h<<16)|w); + + if( (fill->border & 0xFF000000) != 0) + { + R5xxFIFOWait(2); + + OUTREG(R5XX_DP_GUI_MASTER_CNTL, + RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_SOLID_COLOR | + RADEON_GMC_DST_32BPP | + RADEON_GMC_SRC_DATATYPE_COLOR | + R5XX_GMC_CLR_CMP_CNTL_DIS | + R5XX_GMC_WR_MSK_DIS | + R5XX_ROP3_P + ); + + OUTREG(R5XX_DP_BRUSH_FRGD_CLR, fill->border); + + if( y0 == fill->y) + { + R5xxFIFOWait(2); + + OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); + y0++; + h--; + } + if( y1 == yend ) + { + R5xxFIFOWait(2); + + OUTREG(R5XX_DST_Y_X,(y1<<16)|x0); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|1); + h--; + } + if( x0 == fill->x) + { + R5xxFIFOWait(2); + + OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); + } + if( x1 == xend) + { + R5xxFIFOWait(2); + + OUTREG(R5XX_DST_Y_X,(y0<<16)|x1); + OUTREG(R5XX_DST_WIDTH_HEIGHT,(1<<16)|h); + } + }; + + #else BEGIN_RING(); OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT, 7)); @@ -266,135 +378,9 @@ int FillRect(fill_t *fill) return ERR_OK; }; -#if 0 -int Blit(blit_t *blit) -{ - int x0, y0, x1, y1; - - x0 = blit->src_x; - y0 = blit->src_y; - - x1 = x0+blit->w-1; - y1 = y0+blit->h-1; - if( ! BlockClip(&clip, &x0, &y0, &x1, &y1)) - { - u32 *ring, write; - int w, h; - u32 ifl; - - w = x1-x0+1; - h = y1-y0+1; - - ifl = safe_cli(); - -#if R300_PIO - - -#else - - BEGIN_RING(); - OUT_RING(CP_PACKET3(RADEON_CNTL_BITBLT, 5)); - - OUT_RING(RADEON_GMC_SRC_PITCH_OFFSET_CNTL | - RADEON_GMC_DST_PITCH_OFFSET_CNTL | - RADEON_GMC_BRUSH_NONE | - RADEON_GMC_DST_32BPP | - RADEON_GMC_SRC_DATATYPE_COLOR | - RADEON_DP_SRC_SOURCE_MEMORY | - (1 << 28)+(1 << 30) | R5XX_ROP3_S); - - OUT_RING(rhd.dst_pitch_offset); - OUT_RING(rhd.dst_pitch_offset); - - OUT_RING((x0<<16)|y0); - OUT_RING((blit->dst_x<<16)|blit->dst_y); - OUT_RING((w<<16)|h); - COMMIT_RING(); - -#endif - - safe_sti(ifl); - } ; - return ERR_OK; -} - -#endif - - -#if 0 - -int LockPixmap(userpixmap_t *io) -{ - pixmap_t *pixmap; - size_t size; - void *usermap; - - dbgprintf("Lock pixmap %x\n", io->pixmap); - - if(io->pixmap == (pixmap_t*)-1) - return ERR_PARAM; - else - pixmap = io->pixmap; - - if( (pixmap->flags & 1) == PX_LOCK ) - return ERR_PARAM; - - size = (pixmap->pitch*pixmap->width+4095) & ~ 4095; - if (usermap = UserAlloc(size)) - { - CommitPages(usermap, ((u32_t)pixmap->raw+rhd.PhisBase)|7|(1<<9), size); - pixmap->flags |= PX_LOCK; - pixmap->usermap = usermap; - io->usermap = usermap; - io->pitch = pixmap->pitch; - dbgprintf("map at %x\n", io->usermap); - - return ERR_OK; - } - else - return ERR_PARAM; -}; - -int UnlockPixmap(userpixmap_t *io) -{ - pixmap_t *pixmap; - size_t size; - - dbgprintf("Unlock pixmap %x\n", io->pixmap); - - if(io->pixmap == (pixmap_t*)-1) - return ERR_PARAM; - else - pixmap = io->pixmap; - - if( (pixmap->flags & 1) != PX_LOCK ) - return ERR_PARAM; - -/* Sanity checks */ - - if( (pixmap->usermap == 0)|| - ((u32_t)pixmap->usermap >= 0x80000000) || - ((u32_t)pixmap->usermap & 4095) - ) - return ERR_PARAM; - - size = (pixmap->pitch*pixmap->width+4095) & ~ 4095; - - UnmapPages(pixmap->usermap, size); - UserFree(pixmap->usermap); - pixmap->usermap = NULL; - pixmap->flags &= ~PX_LOCK; - io->usermap = NULL; - io->pitch = 0; - - return ERR_OK; -}; - -#endif - -int PixBlit(pixblit_t *blit) +int Blit(io_blit_t *blit) { clip_t src_clip, dst_clip; @@ -487,7 +473,7 @@ int PixBlit(pixblit_t *blit) }; -int TransBlit(pixblit_t *blit) +int BlitTransparent(io_blit_t *blit) { clip_t src_clip, dst_clip; @@ -586,3 +572,74 @@ int TransBlit(pixblit_t *blit) return ERR_OK; } + +#if 0 + +int LockPixmap(userpixmap_t *io) +{ + pixmap_t *pixmap; + size_t size; + void *usermap; + + dbgprintf("Lock pixmap %x\n", io->pixmap); + + if(io->pixmap == (pixmap_t*)-1) + return ERR_PARAM; + else + pixmap = io->pixmap; + + if( (pixmap->flags & 1) == PX_LOCK ) + return ERR_PARAM; + + size = (pixmap->pitch*pixmap->width+4095) & ~ 4095; + if (usermap = UserAlloc(size)) + { + CommitPages(usermap, ((u32_t)pixmap->raw+rhd.PhisBase)|7|(1<<9), size); + pixmap->flags |= PX_LOCK; + pixmap->usermap = usermap; + io->usermap = usermap; + io->pitch = pixmap->pitch; + dbgprintf("map at %x\n", io->usermap); + + return ERR_OK; + } + else + return ERR_PARAM; +}; + +int UnlockPixmap(userpixmap_t *io) +{ + pixmap_t *pixmap; + size_t size; + + dbgprintf("Unlock pixmap %x\n", io->pixmap); + + if(io->pixmap == (pixmap_t*)-1) + return ERR_PARAM; + else + pixmap = io->pixmap; + + if( (pixmap->flags & 1) != PX_LOCK ) + return ERR_PARAM; + +/* Sanity checks */ + + if( (pixmap->usermap == 0)|| + ((u32_t)pixmap->usermap >= 0x80000000) || + ((u32_t)pixmap->usermap & 4095) + ) + return ERR_PARAM; + + size = (pixmap->pitch*pixmap->width+4095) & ~ 4095; + + UnmapPages(pixmap->usermap, size); + UserFree(pixmap->usermap); + pixmap->usermap = NULL; + pixmap->flags &= ~PX_LOCK; + io->usermap = NULL; + io->pitch = 0; + + return ERR_OK; +}; + +#endif diff --git a/programs/system/drivers/ati2d/accel_3d.inc b/programs/system/drivers/ati2d/accel_3d.inc index 325679aa3d..e7bb3c3d5c 100644 --- a/programs/system/drivers/ati2d/accel_3d.inc +++ b/programs/system/drivers/ati2d/accel_3d.inc @@ -1174,6 +1174,7 @@ static void RadeonCompositeTile(int srcX, int srcY, #undef VTX_OUT #undef VTX_OUT_MASK +#if 0 int RadeonComposite( blit_t *blit) { @@ -1235,3 +1236,4 @@ int RadeonComposite( blit_t *blit) #endif } +#endif diff --git a/programs/system/drivers/ati2d/ati2d.c b/programs/system/drivers/ati2d/ati2d.c index 63b4f83766..ac1c3aa7ea 100644 --- a/programs/system/drivers/ati2d/ati2d.c +++ b/programs/system/drivers/ati2d/ati2d.c @@ -30,14 +30,14 @@ u32_t __stdcall drvEntry(int action) if(action != 1) return 0; - if(!dbg_open("/hd0/2/ati2d.log")) + if(!dbg_open("/rd/1/drivers/ati2d.log")) { printf("Can't open /rd/1/drivers/ati2d.log\nExit\n"); return 0; } if( GetScreenBpp() != 32) { - printf("32 bpp dispaly mode required !\nExit\t"); + dbgprintf("32 bpp dispaly mode required !\nExit\t"); return 0; } @@ -82,7 +82,7 @@ u32_t __stdcall drvEntry(int action) #define SRV_GETVERSION 0 -int _stdcall srv_2d(ioctl_t *io) +int __stdcall srv_2d(ioctl_t *io) { u32_t *inp; u32_t *outp; @@ -110,36 +110,37 @@ int _stdcall srv_2d(ioctl_t *io) return DestroyPixmap((pixmap_t*)inp); break; + case PX_CLEAR: + if(io->inp_size==2) + return ClearPixmap((io_clear_t*)inp); + break; + case PX_DRAW_RECT: if(io->inp_size==7) - return DrawRect((draw_t*)inp); + return DrawRect((io_draw_t*)inp); break; case PX_FILL_RECT: - if(io->inp_size==9) - return FillRect((fill_t*)inp); + if(io->inp_size==10) + return FillRect((io_fill_t*)inp); break; case PX_BLIT: if(io->inp_size==8) - return PixBlit((pixblit_t*)inp); + return Blit((io_blit_t*)inp); break; case PX_BLIT_TRANSPARENT: - if(io->inp_size==8) - return TransBlit((pixblit_t*)inp); + if(io->inp_size==9) + return BlitTransparent((io_blit_t*)inp); break; case PX_LINE: if(io->inp_size==6) - return Line((draw_t*)inp); + return Line((io_draw_t*)inp); break; /* - case BLIT: - if(io->inp_size==6) - return Blit((blit_t*)inp); - break; case COMPIZ: if(io->inp_size==6) @@ -157,13 +158,12 @@ int _stdcall srv_2d(ioctl_t *io) #include "init.c" #include "pci.c" #include "ati_mem.c" -//#include "cursor.inc" #include "r500.inc" #include "clip.inc" #include "pixmap.inc" #include "accel_2d.inc" -#include "accel_3d.inc" +//#include "accel_3d.inc" diff --git a/programs/system/drivers/ati2d/init.c b/programs/system/drivers/ati2d/init.c index 4fcf0a8664..7e661573bc 100644 --- a/programs/system/drivers/ati2d/init.c +++ b/programs/system/drivers/ati2d/init.c @@ -117,9 +117,5 @@ error1: return FALSE; }; -//int KernelFree(void *p) -//{ -// -// return 0; -//} + diff --git a/programs/system/drivers/ati2d/makefile b/programs/system/drivers/ati2d/makefile index 98aa6acd84..daa18d5cb1 100644 --- a/programs/system/drivers/ati2d/makefile +++ b/programs/system/drivers/ati2d/makefile @@ -36,7 +36,7 @@ $(ATI2D): $(ATI_OBJ) $(SRC_DEP) $(HFILES) Makefile wlink name ati2d.dll SYS nt_dll lib libdrv op offset=0 op nod op maxe=25 op el op STUB=stub.exe op START=_drvEntry @rhd.lk1 kpack.exe ati2d.dll ati2d.drv -ati2d.obj : ati2d.c $(SRC_DEP) $(HFILES) +ati2d.obj : ati2d.c $(SRC_DEP) $(HFILES) Makefile $(CC) $(CFLAGS) -o ati2d.obj ati2d.c curhelp.obj : curhelp.asm diff --git a/programs/system/drivers/ati2d/r500.inc b/programs/system/drivers/ati2d/r500.inc index 0cf1aeed23..2b74987961 100644 --- a/programs/system/drivers/ati2d/r500.inc +++ b/programs/system/drivers/ati2d/r500.inc @@ -409,33 +409,33 @@ void R5xx2DInit() // load_microcode(); - rhd.ring_base = CreateRingBuffer(0x8000, PG_SW | PG_NOCACHE); - dbgprintf("create cp ring buffer %x\n", rhd.ring_base); - base = GetPgAddr(rhd.ring_base); + // rhd.ring_base = CreateRingBuffer(0x8000, PG_SW | PG_NOCACHE); + // dbgprintf("create cp ring buffer %x\n", rhd.ring_base); + // base = GetPgAddr(rhd.ring_base); - OUTREG(RADEON_CP_RB_BASE, base); - dbgprintf("ring base %x\n", base); + // OUTREG(RADEON_CP_RB_BASE, base); + // dbgprintf("ring base %x\n", base); - OUTREG(RADEON_CP_RB_WPTR_DELAY, 0); + // OUTREG(RADEON_CP_RB_WPTR_DELAY, 0); - rhd.ring_rp = rhd.ring_wp = INREG(RADEON_CP_RB_RPTR); - OUTREG(RADEON_CP_RB_WPTR,rhd.ring_rp); + // rhd.ring_rp = rhd.ring_wp = INREG(RADEON_CP_RB_RPTR); + // OUTREG(RADEON_CP_RB_WPTR,rhd.ring_rp); - OUTREG(RADEON_CP_RB_RPTR_ADDR, 0); // ring buffer read pointer no update + // OUTREG(RADEON_CP_RB_RPTR_ADDR, 0); // ring buffer read pointer no update - OUTREG(RADEON_CP_RB_CNTL, RADEON_RB_NO_UPDATE | 12); - OUTREG(RADEON_SCRATCH_UMSK, 0); // no scratch update + // OUTREG(RADEON_CP_RB_CNTL, RADEON_RB_NO_UPDATE | 12); + // OUTREG(RADEON_SCRATCH_UMSK, 0); // no scratch update - MASKREG(RADEON_BUS_CNTL,0,RADEON_BUS_MASTER_DIS); + // MASKREG(RADEON_BUS_CNTL,0,RADEON_BUS_MASTER_DIS); - R5xx2DIdleLocal(); + // R5xx2DIdleLocal(); - OUTREG(RADEON_ISYNC_CNTL, RADEON_ISYNC_ANY2D_IDLE3D | - RADEON_ISYNC_ANY3D_IDLE2D | - RADEON_ISYNC_WAIT_IDLEGUI | - RADEON_ISYNC_CPSCRATCH_IDLEGUI); + // OUTREG(RADEON_ISYNC_CNTL, RADEON_ISYNC_ANY2D_IDLE3D | + // RADEON_ISYNC_ANY3D_IDLE2D | + // RADEON_ISYNC_WAIT_IDLEGUI | + // RADEON_ISYNC_CPSCRATCH_IDLEGUI); - OUTREG(RADEON_CP_CSQ_CNTL, RADEON_CSQ_PRIBM_INDBM); // run + // OUTREG(RADEON_CP_CSQ_CNTL, RADEON_CSQ_PRIBM_INDBM); // run }