/programs/system/drivers/ati2d/malloc.c |
---|
File deleted |
/programs/system/drivers/ati2d/string.c |
---|
File deleted |
/programs/system/drivers/ati2d/xmd.h |
---|
File deleted |
/programs/system/drivers/ati2d/cursor.inc |
---|
File deleted |
/programs/system/drivers/ati2d/helper.c |
---|
File deleted |
/programs/system/drivers/ati2d/dbg.c |
---|
File deleted |
/programs/system/drivers/ati2d/curhelp.asm |
---|
File deleted |
/programs/system/drivers/ati2d/memset.asm |
---|
File deleted |
/programs/system/drivers/ati2d/common.h |
---|
File deleted |
/programs/system/drivers/ati2d/accel_2d.h |
---|
1,17 → 1,17 |
#define FILL_RECT 1 |
#define DRAW_RECT 2 |
#define LINE_2P 3 |
#define BLIT 4 |
#define COMPIZ 5 |
#define PX_CREATE 6 |
#define PIXBLIT 7 |
#define PIXLOCK 8 |
#define PIXUNLOCK 9 |
#define PIXDESTROY 10 |
#define TRANSBLIT 11 |
#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 BLIT 4 |
//#define COMPIZ 5 |
typedef unsigned int color_t; |
typedef struct |
/programs/system/drivers/ati2d/accel_2d.inc |
---|
1,5 → 1,73 |
int Line(draw_t *draw) |
{ |
local_pixmap_t *dstpixmap; |
clip_t clip; |
int x0, y0, x1, y1; |
dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ; |
x0 = draw->x0; |
y0 = draw->y0; |
x1 = draw->x1; |
y1 = draw->y1; |
clip.xmin = 0; |
clip.ymin = 0; |
clip.xmax = dstpixmap->width-1; |
clip.ymax = dstpixmap->height-1; |
if ( !LineClip(&clip, &x0, &y0, &x1, &y1 )) |
{ |
u32_t efl; |
u32_t *ring, write; |
efl = safe_cli(); |
#if R300_PIO |
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 | |
R5XX_ROP3_P |
); |
OUTREG(R5XX_DST_LINE_PATCOUNT, 0x55 << R5XX_BRES_CNTL_SHIFT); |
OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color); |
OUTREG(R5XX_DST_PITCH_OFFSET, dstpixmap->pitch_offset); |
OUTREG(R5XX_DST_LINE_START,(y0<<16)|x0); |
OUTREG(R5XX_DST_LINE_END,(y1<<16)|x1); |
#else |
BEGIN_RING(); |
OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_POLYLINE, 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(draw->color); |
OUT_RING((y0<<16)|x0); |
OUT_RING((y1<<16)|x1); |
COMMIT_RING(); |
#endif |
safe_sti(efl); |
}; |
return ERR_OK; |
} |
int DrawRect(draw_t* draw) |
{ |
int x0, y0, x1, y1; |
215,171 → 283,9 |
return ERR_OK; |
} |
int Line2P(draw_t *draw) |
{ |
local_pixmap_t *dstpixmap; |
int x0, y0, x1, y1; |
dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ; |
x0 = draw->x0; |
y0 = draw->y0; |
x1 = draw->x1; |
y1 = draw->y1; |
if ( !LineClip(&clip, &x0, &y0, &x1, &y1 )) |
{ |
u32 efl; |
u32 *ring, write; |
efl = safe_cli(); |
#if R300_PIO |
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 | |
R5XX_ROP3_P |
); |
OUTREG(R5XX_DST_LINE_PATCOUNT, 0x55 << R5XX_BRES_CNTL_SHIFT); |
OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color); |
OUTREG(R5XX_DST_PITCH_OFFSET, rhd.dst_pitch_offset); |
OUTREG(R5XX_DST_LINE_START,(y0<<16)|x0); |
OUTREG(R5XX_DST_LINE_END,(y1<<16)|x1); |
#else |
BEGIN_RING(); |
OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_POLYLINE, 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(rhd.dst_pitch_offset); |
OUT_RING(draw->color); |
OUT_RING((y0<<16)|x0); |
OUT_RING((y1<<16)|x1); |
COMMIT_RING(); |
#endif |
safe_sti(efl); |
}; |
return ERR_OK; |
} |
#endif |
int CreatePixmap(pixmap_t *io) |
{ |
local_pixmap_t *pixmap; |
unsigned pitch; |
size_t size; |
void *local; |
if( (io->width == 0) || (io->width > 2048)|| |
(io->height == 0)|| (io->height > 2048)) |
{ |
dbgprintf("Invalid pixmap size w:%d h:%d\n", io->width,io->height); |
return ERR_PARAM; |
}; |
pitch = ((io->width+15)&~15)*4; |
size = pitch*io->height; |
dbgprintf("pitch = %d\n", pitch); |
local = rhd_mem_alloc(&rhd,RHD_MEM_FB,size) ; |
if ( !local) |
{ |
dbgprintf("Not enough memory for pixmap\n"); |
return ERR_PARAM; |
}; |
pixmap = malloc(sizeof(local_pixmap_t)); |
if(!pixmap) |
{ |
rhd_mem_free(&rhd, RHD_MEM_FB,local); |
return ERR_PARAM; |
} |
else |
{ |
void *mapped; |
size = (size+4095) & ~ 4095; |
if (mapped = UserAlloc(size)) |
{ |
CommitPages(mapped, ((u32_t)local+rhd.PhisBase)|7|(1<<9), size); |
io->mapped = mapped; |
io->pitch = pitch; |
io->handle = (u32_t)pixmap; |
pixmap->width = io->width; |
pixmap->height = io->height; |
pixmap->format = PICT_a8r8g8b8; |
pixmap->flags = io->flags; |
pixmap->pitch = pitch; |
pixmap->mapped = mapped; |
pixmap->pitch_offset = ((pitch/64)<<22)| (((u32_t)local+rhd.FbIntAddress)>>10); |
pixmap->local = local; |
dbgprintf("pixmap.pitch_offset: %x\n", pixmap->pitch_offset); |
dbgprintf("width: %d height: %d\n",pixmap->width,pixmap->height ); |
dbgprintf("map at %x\n", pixmap->mapped); |
return ERR_OK; |
}; |
rhd_mem_free(&rhd, RHD_MEM_FB,local); |
free(pixmap); |
}; |
return ERR_PARAM; |
}; |
int DestroyPixmap( pixmap_t *io ) |
{ |
local_pixmap_t *pixmap; |
size_t size; |
dbgprintf("Destroy pixmap %x\n", io->handle); |
if(io->handle == -1) |
return ERR_PARAM; |
else |
pixmap = (local_pixmap_t*)io->handle; |
size = (pixmap->pitch*pixmap->height+4095) & ~ 4095; |
UnmapPages(pixmap->mapped, size); |
UserFree(pixmap->mapped); |
rhd_mem_free(&rhd,RHD_MEM_FB,pixmap->local); |
free(pixmap); |
io->format = 0; |
io->pitch = 0; |
io->mapped = NULL; |
io->handle = 0; |
return ERR_OK; |
}; |
#if 0 |
int LockPixmap(userpixmap_t *io) |
/programs/system/drivers/ati2d/accel_3d.inc |
---|
59,7 → 59,7 |
u32_t gb_tile_config, su_reg_dest, vap_cntl; |
// ACCEL_PREAMBLE(); |
u32 *ring, write; |
u32_t *ring, write; |
// info->texW[0] = info->texH[0] = info->texW[1] = info->texH[1] = 1; |
1098,7 → 1098,7 |
xPointFixed srcTopLeft, srcTopRight, srcBottomLeft, srcBottomRight; |
xPointFixed maskTopLeft, maskTopRight, maskBottomLeft, maskBottomRight; |
u32 *ring, write; |
u32_t *ring, write; |
// ACCEL_PREAMBLE(); |
/programs/system/drivers/ati2d/ati2d.c |
---|
1,8 → 1,12 |
//ld -T ld.x -s --shared --image-base 0 --file-alignment 32 -o test.exe test.obj core.lib |
#include "types.h" |
#include "common.h" |
#include <stdio.h> |
#include <malloc.h> |
#include <memory.h> |
#include "syscall.h" |
#include "ati2d.h" |
#include "accel_2d.h" |
12,26 → 16,14 |
static local_pixmap_t scr_pixmap; |
static void Init3DEngine(RHDPtr rhdPtr); |
/* |
void STDCALL (*SelectHwCursor)(cursor_t*)__asm__("SelectHwCursor"); |
void STDCALL (*SetHwCursor)(cursor_t*,int x,int y)__asm__("SetHwCursor"); |
void STDCALL (*HwCursorRestore)(int x, int y)__asm("HwCursorRestore"); |
cursor_t* IMPORT (*HwCursorCreate)(void)__asm("HwCursorCreate"); //params eax, ebx, ecx |
int __stdcall srv_2d(ioctl_t *io); |
void (__stdcall *old_select)(cursor_t*); |
void (__stdcall *old_set)(cursor_t*,int x,int y); |
void (__stdcall *old_restore)(int x, int y); |
cursor_t* (*old_create)(void); |
cursor_t* __create_cursor(void); |
*/ |
static void Init3DEngine(RHDPtr rhdPtr); |
u32 __stdcall drvEntry(int action) |
u32_t __stdcall drvEntry(int action) |
{ |
RHDPtr rhdPtr; |
u32 retval; |
u32_t retval; |
int i; |
65,26 → 57,17 |
if(!RHDPreInit()) |
return 0; |
// old_select = SelectHwCursor; |
// old_set = SetHwCursor; |
// old_restore = HwCursorRestore ; |
// old_create = HwCursorCreate; |
R5xx2DInit(); |
rhd.has_tcl = 1; |
// Init3DEngine(&rhd); |
//init_r500(); |
// SelectHwCursor = r500_SelectCursor; |
// SetHwCursor = r500_SetCursor; |
// HwCursorCreate = __create_cursor; |
// HwCursorRestore = r500_CursorRestore; |
retval = RegService("HDRAW", srv_2d); |
dbgprintf("reg service %s as: %x\n", "HDRAW", retval); |
// retval = RegService("HWCURSOR", srv_cursor); |
return retval; |
}; |
93,36 → 76,11 |
#define SRV_GETVERSION 0 |
/* |
int _stdcall srv_cursor(ioctl_t *io) |
{ |
u32 *inp; |
u32 *outp; |
inp = io->input; |
outp = io->output; |
switch(io->io_code) |
{ |
case SRV_GETVERSION: |
if(io->out_size==4) |
{ |
*(u32*)io->output = API_VERSION; |
return 0; |
} |
break; |
default: |
return ERR_PARAM; |
}; |
return ERR_PARAM; |
} |
*/ |
int _stdcall srv_2d(ioctl_t *io) |
{ |
u32 *inp; |
u32 *outp; |
u32_t *inp; |
u32_t *outp; |
inp = io->input; |
outp = io->output; |
137,21 → 95,42 |
} |
break; |
case DRAW_RECT: |
case PX_CREATE: |
if(io->inp_size==7) |
return CreatePixmap((pixmap_t*)inp); |
break; |
case PX_DESTROY: |
if(io->inp_size==7) |
return DestroyPixmap((pixmap_t*)inp); |
break; |
case PX_DRAW_RECT: |
if(io->inp_size==6) |
return DrawRect((draw_t*)inp); |
break; |
case FILL_RECT: |
case PX_FILL_RECT: |
if(io->inp_size==9) |
return FillRect((fill_t*)inp); |
break; |
/* |
case LINE_2P: |
case PX_BLIT: |
if(io->inp_size==8) |
return PixBlit((pixblit_t*)inp); |
break; |
case PX_BLIT_TRANSPARENT: |
if(io->inp_size==8) |
return TransBlit((pixblit_t*)inp); |
break; |
case PX_LINE: |
if(io->inp_size==6) |
return Line2P((draw_t*)inp); |
return Line((draw_t*)inp); |
break; |
/* |
case BLIT: |
if(io->inp_size==6) |
return Blit((blit_t*)inp); |
162,37 → 141,7 |
return RadeonComposite((blit_t*)inp); |
break; |
*/ |
case PX_CREATE: |
if(io->inp_size==7) |
return CreatePixmap((pixmap_t*)inp); |
break; |
case PIXBLIT: |
if(io->inp_size==8) |
return PixBlit((pixblit_t*)inp); |
break; |
// case PIXLOCK: |
// if(io->inp_size==6) |
// return LockPixmap((userpixmap_t*)inp); |
// break; |
// case PIXUNLOCK: |
// if(io->inp_size==6) |
// return UnlockPixmap((userpixmap_t*)inp); |
// break; |
case PIXDESTROY: |
if(io->inp_size==6) |
return DestroyPixmap((pixmap_t*)inp); |
break; |
case TRANSBLIT: |
if(io->inp_size==8) |
return TransBlit((pixblit_t*)inp); |
break; |
default: |
return ERR_PARAM; |
}; |
208,6 → 157,7 |
#include "r500.inc" |
#include "clip.inc" |
#include "pixmap.inc" |
#include "accel_2d.inc" |
#include "accel_3d.inc" |
/programs/system/drivers/ati2d/ati2d.h |
---|
1,4 → 1,13 |
typedef void *pointer; |
typedef unsigned int Bool; |
typedef unsigned int memType; |
typedef struct { float hi, lo; } range; |
#include "pci.h" |
#include "rhd_regs.h" |
105,17 → 114,17 |
typedef struct RHDRec |
{ |
CARD32 MMIOBase; |
CARD32 MMIOMapSize; |
CARD32 videoRam; |
u32_t MMIOBase; |
u32_t MMIOMapSize; |
u32_t videoRam; |
// CARD32 FbBase; /* map base of fb */ |
CARD32 PhisBase; |
CARD32 FbIntAddress; /* card internal address of FB */ |
CARD32 FbMapSize; |
u32_t PhisBase; |
u32_t FbIntAddress; /* card internal address of FB */ |
u32_t FbMapSize; |
CARD32 FbFreeStart; |
CARD32 FbFreeSize; |
u32_t FbFreeStart; |
u32_t FbFreeSize; |
/* visible part of the framebuffer */ |
unsigned int FbScanoutStart; |
128,38 → 137,38 |
Bool IsIGP; |
CARD32 bus; |
CARD32 devfn; |
u32_t bus; |
u32_t devfn; |
PCITAG PciTag; |
CARD16 PciDeviceID; |
u16_t PciDeviceID; |
CARD16 subvendor_id; |
CARD16 subdevice_id; |
u16_t subvendor_id; |
u16_t subdevice_id; |
CARD32 memBase[6]; |
CARD32 ioBase[6]; |
CARD32 memtype[6]; |
CARD32 memsize[6]; |
u32_t memBase[6]; |
u32_t ioBase[6]; |
u32_t memtype[6]; |
u32_t memsize[6]; |
struct mem_block *fb_heap; |
struct mem_block *gart_heap; |
CARD32 displayWidth; |
CARD32 displayHeight; |
u32_t displayWidth; |
u32_t displayHeight; |
CARD32 __xmin; |
CARD32 __ymin; |
CARD32 __xmax; |
CARD32 __ymax; |
int __xmin; |
int __ymin; |
int __xmax; |
int __ymax; |
CARD32 gui_control; |
CARD32 dst_pitch_offset; |
CARD32 surface_cntl; |
u32_t gui_control; |
u32_t dst_pitch_offset; |
u32_t surface_cntl; |
u32 *ring_base; |
u32 ring_rp; |
u32 ring_wp; |
u32_t *ring_base; |
u32_t ring_rp; |
u32_t ring_wp; |
int num_gb_pipes; |
Bool has_tcl; |
253,34 → 262,34 |
extern inline void |
OUTREG8(CARD16 offset, u8 value) |
OUTREG8(u16_t offset, u8_t value) |
{ |
*(volatile CARD8 *)((CARD8 *)(rhd.MMIOBase + offset)) = value; |
*(volatile u8_t *)((u8_t *)(rhd.MMIOBase + offset)) = value; |
} |
extern inline CARD32 INREG(CARD16 offset) |
extern inline u32_t INREG(u16_t offset) |
{ |
return *(volatile CARD32 *)((CARD8*)(rhd.MMIOBase + offset)); |
return *(volatile u32_t *)((u8_t*)(rhd.MMIOBase + offset)); |
} |
//#define INREG(offset) *(volatile CARD32 *)((CARD8*)(rhd.MMIOBase + (offset))) |
extern inline void |
OUTREG(CARD16 offset, CARD32 value) |
OUTREG(u16_t offset, u32_t value) |
{ |
*(volatile CARD32 *)((CARD8 *)(rhd.MMIOBase + offset)) = value; |
*(volatile u32_t *)((u8_t *)(rhd.MMIOBase + offset)) = value; |
} |
extern inline CARD32 _RHDRegRead(RHDPtr rhdPtr, CARD16 offset) |
extern inline u32_t _RHDRegRead(RHDPtr rhdPtr, u16_t offset) |
{ |
return *(volatile CARD32 *)((CARD8*)(rhdPtr->MMIOBase + offset)); |
return *(volatile u32_t *)((u8_t*)(rhdPtr->MMIOBase + offset)); |
} |
extern inline void |
MASKREG(CARD16 offset, CARD32 value, CARD32 mask) |
MASKREG(u16_t offset, u32_t value, u32_t mask) |
{ |
CARD32 tmp; |
u32_t tmp; |
tmp = INREG(offset); |
tmp &= ~mask; |
289,15 → 298,15 |
}; |
extern inline void |
_RHDRegWrite(RHDPtr rhdPtr, CARD16 offset, CARD32 value) |
_RHDRegWrite(RHDPtr rhdPtr, u16_t offset, u32_t value) |
{ |
*(volatile CARD32 *)((CARD8 *)(rhdPtr->MMIOBase + offset)) = value; |
*(volatile u32_t *)((u8_t *)(rhdPtr->MMIOBase + offset)) = value; |
} |
extern inline void |
_RHDRegMask(RHDPtr rhdPtr, CARD16 offset, CARD32 value, CARD32 mask) |
_RHDRegMask(RHDPtr rhdPtr, u16_t offset, u32_t value, u32_t mask) |
{ |
CARD32 tmp; |
u32_t tmp; |
tmp = _RHDRegRead(rhdPtr, offset); |
tmp &= ~mask; |
325,15 → 334,15 |
#pragma pack (push,1) |
typedef struct s_cursor |
{ |
u32 magic; // 'CURS' |
u32_t magic; // 'CURS' |
void (*destroy)(struct s_cursor*); // destructor |
u32 fd; // next object in list |
u32 bk; // prev object in list |
u32 pid; // owner id |
u32_t fd; // next object in list |
u32_t bk; // prev object in list |
u32_t pid; // owner id |
void *base; // allocated memory |
u32 hot_x; // hotspot coords |
u32 hot_y; |
u32_t hot_x; // hotspot coords |
u32_t hot_y; |
}cursor_t; |
#pragma pack (pop) |
341,7 → 350,7 |
#define LOAD_FROM_MEM 1 |
#define LOAD_INDIRECT 2 |
cursor_t *create_cursor(u32 pid, void *src, u32 flags); |
cursor_t *create_cursor(u32_t pid, void *src, u32_t flags); |
void __stdcall copy_cursor(void *img, void *src); |
void destroy_cursor(cursor_t *cursor); |
void __destroy_cursor(cursor_t *cursor); // wrap |
/programs/system/drivers/ati2d/clip.inc |
---|
0,0 → 1,181 |
#define CLIP_TOP 1 |
#define CLIP_BOTTOM 2 |
#define CLIP_RIGHT 4 |
#define CLIP_LEFT 8 |
static int _L1OutCode( clip_t *clip, int x, int y ) |
/*================================= |
Verify that a point is inside or outside the active viewport. */ |
{ |
int flag; |
flag = 0; |
if( x < clip->xmin ) { |
flag |= CLIP_LEFT; |
} else if( x > clip->xmax ) { |
flag |= CLIP_RIGHT; |
} |
if( y < clip->ymin ) { |
flag |= CLIP_TOP; |
} else if( y > clip->ymax ) { |
flag |= CLIP_BOTTOM; |
} |
return( flag ); |
} |
static void line_inter( int * x1, int* y1, int x2, int y2, int x ) |
/*=========================================================================== |
Find the intersection of a line with a boundary of the viewport. |
(x1, y1) is outside and ( x2, y2 ) is inside the viewport. |
NOTE : the signs of denom and ( x - *x1 ) cancel out during division |
so make both of them positive before rounding. */ |
{ |
int numer; |
int denom; |
denom = abs( x2 - *x1 ); |
numer = 2L * (long)( y2 - *y1 ) * abs( x - *x1 ); |
if( numer > 0 ) { |
numer += denom; /* round to closest pixel */ |
} else { |
numer -= denom; |
} |
*y1 += numer / ( denom << 1 ); |
*x1 = x; |
} |
int LineClip( clip_t *clip, int *x1, int *y1, int *x2, int *y2 ) |
/*============================================================= |
Clips the line with end points (x1,y1) and (x2,y2) to the active |
viewport using the Cohen-Sutherland clipping algorithm. Return the |
clipped coordinates and a decision drawing flag. */ |
{ |
int flag1; |
int flag2; |
flag1 = _L1OutCode( clip, *x1, *y1 ); |
flag2 = _L1OutCode( clip, *x2, *y2 ); |
for( ;; ) { |
if( flag1 & flag2 ) break; /* trivially outside */ |
if( flag1 == flag2 ) break; /* completely inside */ |
if( flag1 == 0 ) { /* first point inside */ |
if( flag2 & CLIP_TOP ) { |
line_inter( y2, x2, *y1, *x1, clip->ymin ); |
} else if( flag2 & CLIP_BOTTOM ) { |
line_inter( y2, x2, *y1, *x1, clip->ymax ); |
} else if( flag2 & CLIP_RIGHT ) { |
line_inter( x2, y2, *x1, *y1, clip->xmax ); |
} else if( flag2 & CLIP_LEFT ) { |
line_inter( x2, y2, *x1, *y1, clip->xmin ); |
} |
flag2 = _L1OutCode( clip, *x2, *y2 ); |
} else { /* second point inside */ |
if( flag1 & CLIP_TOP ) { |
line_inter( y1, x1, *y2, *x2, clip->ymin ); |
} else if( flag1 & CLIP_BOTTOM ) { |
line_inter( y1, x1, *y2, *x2, clip->ymax ); |
} else if( flag1 & CLIP_RIGHT ) { |
line_inter( x1, y1, *x2, *y2, clip->xmax ); |
} else if( flag1 & CLIP_LEFT ) { |
line_inter( x1, y1, *x2, *y2, clip->xmin ); |
} |
flag1 = _L1OutCode( clip, *x1, *y1 ); |
} |
} |
return( flag1 & flag2 ); |
} |
static void block_inter( clip_t *clip, int *x, int *y, int flag ) |
/*====================================================== |
Find the intersection of a block with a boundary of the viewport. */ |
{ |
if( flag & CLIP_TOP ) { |
*y = clip->ymin; |
} else if( flag & CLIP_BOTTOM ) { |
*y = clip->ymax; |
} else if( flag & CLIP_RIGHT ) { |
*x = clip->xmax; |
} else if( flag & CLIP_LEFT ) { |
*x = clip->xmin; |
} |
} |
int BlockClip(clip_t *clip, int *x1, int *y1, int *x2, int* y2 ) |
/*============================================================== |
Clip a block with opposite corners (x1,y1) and (x2,y2) to the |
active viewport based on the Cohen-Sutherland algorithm for line |
clipping. Return the clipped coordinates and a decision drawing |
flag ( 0 draw : 1 don't draw ). */ |
{ |
int flag1; |
int flag2; |
flag1 = _L1OutCode( clip, *x1, *y1 ); |
flag2 = _L1OutCode( clip, *x2, *y2 ); |
for( ;; ) { |
if( flag1 & flag2 ) break; /* trivially outside */ |
if( flag1 == flag2 ) break; /* completely inside */ |
if( flag1 == 0 ) { |
block_inter( clip, x2, y2, flag2 ); |
flag2 = _L1OutCode( clip, *x2, *y2 ); |
} else { |
block_inter( clip, x1, y1, flag1 ); |
flag1 = _L1OutCode( clip, *x1, *y1 ); |
} |
} |
return( flag1 & flag2 ); |
} |
int blit_clip(clip_t *dst_clip,int *dst_x,int *dst_y, |
clip_t *src_clip,int *src_x, int *src_y, |
int *w, int *h) |
{ |
int sx0, sy0, sx1, sy1; |
sx0 = *src_x; |
sy0 = *src_y; |
sx1 = sx0 + *w - 1; |
sy1 = sy0 + *h - 1; |
if( ! BlockClip( src_clip, &sx0, &sy0, &sx1, &sy1)) |
{ |
int dx0, dy0, dx1, dy1; |
dx0 = *dst_x + sx0 - *src_x; |
dy0 = *dst_y + sy0 - *src_y; |
dx1 = dx0 + sx1 - sx0; |
dy1 = dy0 + sy1 - sy0; |
if( ! BlockClip( dst_clip, &dx0, &dy0, &dx1, &dy1)) |
{ |
*w = dx1 - dx0 + 1; |
*h = dy1 - dy0 + 1; |
*src_x += dx0 - *dst_x; |
*src_y += dy0 - *dst_y; |
*dst_x = dx0; |
*dst_y = dx0; |
return 0; |
}; |
return 1; |
} |
return 1; |
}; |
/programs/system/drivers/ati2d/init.c |
---|
4,7 → 4,7 |
rhdMapMMIO(RHDPtr rhdPtr) |
{ |
rhdPtr->MMIOMapSize = 1 << rhdPtr->memsize[RHD_MMIO_BAR]; |
rhdPtr->MMIOBase = MapIoMem(rhdPtr->memBase[RHD_MMIO_BAR], |
rhdPtr->MMIOBase = MapIoMem((void*)rhdPtr->memBase[RHD_MMIO_BAR], |
rhdPtr->MMIOMapSize,PG_SW+PG_NOCACHE); |
if( rhdPtr->MMIOBase==0) |
return 0; |
15,10 → 15,9 |
#define RADEON_NB_TOM 0x15c |
static CARD32 |
rhdGetVideoRamSize(RHDPtr rhdPtr) |
static size_t rhdGetVideoRamSize(RHDPtr rhdPtr) |
{ |
CARD32 RamSize, BARSize; |
size_t RamSize, BARSize; |
if (rhdPtr->ChipSet == RHD_RS690) |
RamSize = (_RHDRegRead(rhdPtr, R5XX_CONFIG_MEMSIZE))>>10; |
25,7 → 24,7 |
else |
if (rhdPtr->IsIGP) |
{ |
CARD32 tom = _RHDRegRead(rhdPtr, RADEON_NB_TOM); |
u32_t tom = _RHDRegRead(rhdPtr, RADEON_NB_TOM); |
RamSize = (((tom >> 16) - (tom & 0xffff) + 1) << 6); |
_RHDRegWrite(rhdPtr,R5XX_CONFIG_MEMSIZE, RamSize<<10); |
} |
118,9 → 117,9 |
return FALSE; |
}; |
int KernelFree(void *p) |
{ |
//int KernelFree(void *p) |
//{ |
// |
// return 0; |
//} |
return 0; |
} |
/programs/system/drivers/ati2d/makefile |
---|
5,7 → 5,7 |
LDRHD = -shared -T ld.x -s --file-alignment 32 |
HFILES:= ati2d.h \ |
common.h \ |
syscall.h \ |
pci.h \ |
accel_2d.h \ |
r5xx_regs.h \ |
15,15 → 15,11 |
pci.c \ |
ati_mem.c \ |
r500.inc \ |
pixmap.inc \ |
accel_2d.inc \ |
accel_3d.inc |
ATI_SRC:= ati2d.c \ |
malloc.c \ |
helper.c \ |
string.c \ |
dbg.c \ |
memset.asm |
ATI_SRC:= ati2d.c |
ATI_OBJ:= ati2d.obj |
37,7 → 33,7 |
all: $(ATI2D) |
$(ATI2D): $(ATI_OBJ) $(SRC_DEP) $(HFILES) Makefile |
wlink name ati2d.dll SYS nt_dll op offset=0 op nod op maxe=25 op el op STUB=stub.exe op START=_drvEntry @rhd.lk1 |
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) |
/programs/system/drivers/ati2d/microcode.h |
---|
1,5 → 1,5 |
static const u32 R300_cp_microcode[][2]={ |
static const u32_t R300_cp_microcode[][2]={ |
{ 0x4200e000, 0000000000 }, |
{ 0x4000e000, 0000000000 }, |
{ 0x000000ae, 0x00000008 }, |
258,7 → 258,7 |
{ 0000000000, 0000000000 }, |
}; |
static const u32 R520_cp_microcode[][2]={ |
static const u32_t R520_cp_microcode[][2]={ |
{ 0x4200e000, 0000000000 }, |
{ 0x4000e000, 0000000000 }, |
{ 0x00000099, 0x00000008 }, |
/programs/system/drivers/ati2d/pci.c |
---|
315,7 → 315,7 |
RHDPtr FindPciDevice() |
{ |
const PciChipset_t *dev; |
u32 bus, last_bus; |
u32_t bus, last_bus; |
if( (last_bus = PciApi(1))==-1) |
return 0; |
322,19 → 322,19 |
for(bus=0;bus<=last_bus;bus++) |
{ |
u32 devfn; |
u32_t devfn; |
for(devfn=0;devfn<256;devfn++) |
{ |
u32 id; |
u32_t id; |
id = PciRead32(bus,devfn, 0); |
if( (CARD16)id != VENDOR_ATI) |
if( (u16_t)id != VENDOR_ATI) |
continue; |
if( (dev=PciDevMatch(id>>16,RHDPCIchipsets))!=NULL) |
{ |
CARD32 reg2C; |
u32_t reg2C; |
int i; |
rhd.PciDeviceID = (id>>16); |
352,7 → 352,7 |
for (i = 0; i < 6; i++) |
{ |
CARD32 base; |
u32_t base; |
Bool validSize; |
base = PciRead32(bus,devfn, PCI_MAP_REG_START + (i << 2)); |
360,12 → 360,12 |
{ |
if (base & PCI_MAP_IO) |
{ |
rhd.ioBase[i] = (CARD32)PCIGETIO(base); |
rhd.ioBase[i] = (u32_t)PCIGETIO(base); |
rhd.memtype[i] = base & PCI_MAP_IO_ATTR_MASK; |
} |
else |
{ |
rhd.memBase[i] = (CARD32)PCIGETMEMORY(base); |
rhd.memBase[i] = (u32_t)PCIGETMEMORY(base); |
rhd.memtype[i] = base & PCI_MAP_MEMORY_ATTR_MASK; |
} |
} |
380,7 → 380,7 |
return NULL; |
} |
const PciChipset_t *PciDevMatch(CARD16 dev,const PciChipset_t *list) |
const PciChipset_t *PciDevMatch(u16_t dev,const PciChipset_t *list) |
{ |
while(list->device) |
{ |
392,13 → 392,13 |
} |
CARD32 pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min) |
u32_t pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min) |
{ |
int offset; |
CARD32 addr1; |
CARD32 addr2; |
CARD32 mask1; |
CARD32 mask2; |
u32_t addr1; |
u32_t addr2; |
u32_t mask1; |
u32_t mask2; |
int bits = 0; |
/* |
/programs/system/drivers/ati2d/pci.h |
---|
3,8 → 3,8 |
#pragma pack(push, 1) |
typedef struct |
{ |
CARD16 device; |
CARD16 ChipSet; |
u16_t device; |
u16_t ChipSet; |
}PciChipset_t; |
#pragma pack(pop) |
75,5 → 75,5 |
return(PCI_MAKE_TAG(busnum,devnum,funcnum)); |
} |
const PciChipset_t *PciDevMatch(CARD16 dev,const PciChipset_t *list); |
CARD32 pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min); |
const PciChipset_t *PciDevMatch(u16_t dev,const PciChipset_t *list); |
u32_t pciGetBaseSize(int bus, int devfn, int index, Bool destructive, Bool *min); |
/programs/system/drivers/ati2d/pixmap.inc |
---|
0,0 → 1,98 |
int CreatePixmap(pixmap_t *io) |
{ |
local_pixmap_t *pixmap; |
unsigned pitch; |
size_t size; |
void *local; |
if( (io->width == 0) || (io->width > 2048)|| |
(io->height == 0)|| (io->height > 2048)) |
{ |
dbgprintf("Invalid pixmap size w:%d h:%d\n", io->width,io->height); |
return ERR_PARAM; |
}; |
pitch = ((io->width+15)&~15)*4; |
size = pitch*io->height; |
dbgprintf("pitch = %d\n", pitch); |
local = rhd_mem_alloc(&rhd,RHD_MEM_FB,size) ; |
if ( !local) |
{ |
dbgprintf("Not enough memory for pixmap\n"); |
return ERR_PARAM; |
}; |
pixmap = malloc(sizeof(local_pixmap_t)); |
if(!pixmap) |
{ |
rhd_mem_free(&rhd, RHD_MEM_FB,local); |
return ERR_PARAM; |
} |
else |
{ |
void *mapped; |
size = (size+4095) & ~ 4095; |
if (mapped = UserAlloc(size)) |
{ |
CommitPages(mapped, ((u32_t)local+rhd.PhisBase)|7|(1<<9), size); |
io->mapped = mapped; |
io->pitch = pitch; |
io->handle = (u32_t)pixmap; |
pixmap->width = io->width; |
pixmap->height = io->height; |
pixmap->format = PICT_a8r8g8b8; |
pixmap->flags = io->flags; |
pixmap->pitch = pitch; |
pixmap->mapped = mapped; |
pixmap->pitch_offset = ((pitch/64)<<22)| (((u32_t)local+rhd.FbIntAddress)>>10); |
pixmap->local = local; |
dbgprintf("pixmap.pitch_offset: %x\n", pixmap->pitch_offset); |
dbgprintf("width: %d height: %d\n",pixmap->width,pixmap->height ); |
dbgprintf("map at %x\n", pixmap->mapped); |
return ERR_OK; |
}; |
rhd_mem_free(&rhd, RHD_MEM_FB,local); |
free(pixmap); |
}; |
return ERR_PARAM; |
}; |
int DestroyPixmap( pixmap_t *io ) |
{ |
local_pixmap_t *pixmap; |
size_t size; |
dbgprintf("Destroy pixmap %x\n", io->handle); |
if(io->handle == -1) |
return ERR_PARAM; |
else |
pixmap = (local_pixmap_t*)io->handle; |
size = (pixmap->pitch*pixmap->height+4095) & ~ 4095; |
UnmapPages(pixmap->mapped, size); |
UserFree(pixmap->mapped); |
rhd_mem_free(&rhd,RHD_MEM_FB,pixmap->local); |
free(pixmap); |
io->format = 0; |
io->pitch = 0; |
io->mapped = NULL; |
io->handle = 0; |
return ERR_OK; |
}; |
/programs/system/drivers/ati2d/r500.inc |
---|
119,7 → 119,7 |
static Bool |
R5xxFIFOWaitLocal(CARD32 required) //R100-R500 |
R5xxFIFOWaitLocal(u32_t required) //R100-R500 |
{ |
int i; |
183,7 → 183,7 |
static void |
R5xx2DReset() |
{ |
CARD32 save, tmp; |
u32_t save, tmp; |
u32_t clock_cntl_index; |
u32_t mclk_cntl; |
285,7 → 285,7 |
R5xx2DIdleLocal(); |
} |
void R5xxFIFOWait(CARD32 required) |
void R5xxFIFOWait(u32_t required) |
{ |
if (!R5xxFIFOWaitLocal(required)) { |
R5xx2DReset(); |
303,7 → 303,7 |
static void load_microcode() |
{ |
u32 ifl; |
u32_t ifl; |
int i; |
ifl = safe_cli(); |
350,7 → 350,7 |
void R5xx2DInit() |
{ |
u32 base; |
u32_t base; |
#ifdef R300_TEST |
rhd.displayWidth = 1024; |
/programs/system/drivers/ati2d/rhd.lk1 |
---|
1,5 → 1,6 |
IMP |
_KernelAlloc core.KernelAlloc, |
_KernelFree core.KernelFree, |
_UserAlloc core.UserAlloc, |
_UserFree core.UserFree, |
_CommitPages core.CommitPages, |
21,10 → 22,5 |
FIL ati2d.obj, |
helper.obj, |
dbg.obj, |
malloc.obj, |
memset.obj, |
string.obj, |
vsprintf.obj, |
icompute.obj |
/programs/system/drivers/ati2d/syscall.h |
---|
0,0 → 1,205 |
#define OS_BASE 0x80000000 |
typedef struct |
{ |
u32_t handle; |
u32_t io_code; |
void *input; |
int inp_size; |
void *output; |
int out_size; |
}ioctl_t; |
typedef int (__stdcall *srv_proc_t)(ioctl_t *); |
#define ERR_OK 0 |
#define ERR_PARAM -1 |
u32_t __stdcall drvEntry(int)__asm__("_drvEntry"); |
/////////////////////////////////////////////////////////////////////////////// |
#define STDCALL __attribute__ ((stdcall)) __attribute__ ((dllimport)) |
#define IMPORT __attribute__ ((dllimport)) |
/////////////////////////////////////////////////////////////////////////////// |
#define SysMsgBoardStr __SysMsgBoardStr |
#define PciApi __PciApi |
//#define RegService __RegService |
#define CreateObject __CreateObject |
#define DestroyObject __DestroyObject |
/////////////////////////////////////////////////////////////////////////////// |
#define PG_SW 0x003 |
#define PG_NOCACHE 0x018 |
void* STDCALL AllocKernelSpace(size_t size)__asm__("AllocKernelSpace"); |
void* STDCALL KernelAlloc(size_t size)__asm__("KernelAlloc"); |
void* STDCALL KernelFree(void *mem)__asm__("KernelFree"); |
void* STDCALL UserAlloc(size_t size)__asm__("UserAlloc"); |
int STDCALL UserFree(void *mem)__asm__("UserFree"); |
void* STDCALL CreateRingBuffer(size_t size, u32_t map)__asm__("CreateRingBuffer"); |
u32_t STDCALL RegService(char *name, srv_proc_t proc)__asm__("RegService"); |
//void *CreateObject(u32 pid, size_t size); |
//void *DestroyObject(void *obj); |
u32_t STDCALL MapIoMem(void* base,size_t size,u32_t flags)__asm__("MapIoMem"); |
/////////////////////////////////////////////////////////////////////////////// |
static u32_t PciApi(int cmd); |
u8_t STDCALL PciRead8 (u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead8"); |
u16_t STDCALL PciRead16(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead16"); |
u32_t STDCALL PciRead32(u32_t bus, u32_t devfn, u32_t reg)__asm__("PciRead32"); |
u32_t STDCALL PciWrite8 (u32_t bus, u32_t devfn, u32_t reg,u8_t val) __asm__("PciWrite8"); |
u32_t STDCALL PciWrite16(u32_t bus, u32_t devfn, u32_t reg,u16_t val)__asm__("PciWrite16"); |
u32_t STDCALL PciWrite32(u32_t bus, u32_t devfn, u32_t reg,u32_t val)__asm__("PciWrite32"); |
/////////////////////////////////////////////////////////////////////////////// |
int dbg_open(char *path); |
int dbgprintf(const char* format, ...); |
/////////////////////////////////////////////////////////////////////////////// |
extern inline u32_t GetPgAddr(void *mem) |
{ |
u32_t retval; |
__asm__ __volatile__ ( |
"call *__imp__GetPgAddr \n\t" |
:"=eax" (retval) |
:"a" (mem) ); |
return retval; |
}; |
extern inline void CommitPages(void *mem, u32_t page, u32_t size) |
{ |
size = (size+4095) & ~4095; |
__asm__ __volatile__ ( |
"call *__imp__CommitPages" |
::"a" (page), "b"(mem),"c"(size>>12) |
:"edx" ); |
__asm__ __volatile__ ("":::"eax","ebx","ecx"); |
}; |
extern inline void UnmapPages(void *mem, size_t size) |
{ |
size = (size+4095) & ~4095; |
__asm__ __volatile__ ( |
"call *__imp__UnmapPages" |
::"a" (mem), "c"(size>>12) |
:"edx"); |
__asm__ __volatile__ ("":::"eax","ecx"); |
}; |
extern inline void usleep(u32_t delay) |
{ |
if( !delay ) |
delay++; |
delay*=2000; |
__asm__ __volatile__ ( |
"1:\n\t" |
"xorl %%eax, %%eax \n\t" |
"cpuid \n\t" |
"decl %%edi \n\t" |
"jnz 1b" |
: |
:"D"(delay) |
:"eax","ebx","ecx","edx"); |
}; |
extern inline u32_t __PciApi(int cmd) |
{ |
u32_t retval; |
__asm__ __volatile__ ( |
"call *__imp__PciApi" |
:"=a" (retval) |
:"a" (cmd) |
:"memory"); |
return retval; |
}; |
extern inline void* __CreateObject(u32_t pid, size_t size) |
{ |
void *retval; |
__asm__ __volatile__ ( |
"call *__imp__CreateObject \n\t" |
:"=a" (retval) |
:"a" (size),"b"(pid) |
:"esi","edi", "memory"); |
return retval; |
} |
extern inline void *__DestroyObject(void *obj) |
{ |
__asm__ __volatile__ ( |
"call *__imp__DestroyObject" |
: |
:"a" (obj) |
:"ebx","edx","esi","edi", "memory"); |
} |
/* |
u32 __RegService(char *name, srv_proc_t proc) |
{ |
u32 retval; |
asm __volatile__ |
( |
"pushl %%eax \n\t" |
"pushl %%ebx \n\t" |
"call *__imp__RegService \n\t" |
:"=eax" (retval) |
:"a" (proc), "b" (name) |
:"memory" |
); |
return retval; |
}; |
*/ |
extern inline u32_t safe_cli(void) |
{ |
u32_t ifl; |
__asm__ __volatile__ ( |
"pushf\n\t" |
"popl %0\n\t" |
"cli\n" |
: "=r" (ifl)); |
return ifl; |
} |
extern inline void safe_sti(u32_t ifl) |
{ |
__asm__ __volatile__ ( |
"pushl %0\n\t" |
"popf\n" |
: : "r" (ifl) |
); |
} |
extern inline void __clear (void * dst, unsigned len) |
{ |
u32_t tmp; |
__asm__ __volatile__ ( |
// "xorl %%eax, %%eax \n\t" |
"cld \n\t" |
"rep stosb \n" |
:"=c"(tmp),"=D"(tmp) |
:"a"(0),"c"(len),"D"(dst)); |
__asm__ __volatile__ ("":::"ecx","edi"); |
}; |
/programs/system/drivers/ati2d/types.h |
---|
0,0 → 1,19 |
#define NULL (void*)0 |
typedef unsigned char u8_t; |
typedef unsigned short int u16_t; |
typedef unsigned int u32_t; |
typedef unsigned long long u64_t; |
typedef unsigned int size_t; |
typedef unsigned int count_t; |
typedef unsigned int eflags_t; |
typedef int bool; |
#define TRUE (bool)1 |
#define FALSE (bool)0 |