/programs/system/drivers/ati2d/accel_2d.h |
---|
4,7 → 4,7 |
#define LINE_2P 3 |
#define BLIT 4 |
#define COMPIZ 5 |
#define PIXMAP 6 |
#define PX_CREATE 6 |
#define PIXBLIT 7 |
#define PIXLOCK 8 |
#define PIXUNLOCK 9 |
16,18 → 16,90 |
typedef struct |
{ |
pixmap_t *dstpix; |
int x; |
int y; |
u32_t w; |
u32_t h; |
}pt_t; |
/*********** Clipping **********/ |
typedef struct |
{ |
int xmin; |
int ymin; |
int xmax; |
int ymax; |
}clip_t, *PTRclip; |
#define CLIP_TOP 1 |
#define CLIP_BOTTOM 2 |
#define CLIP_RIGHT 4 |
#define CLIP_LEFT 8 |
int LineClip ( clip_t *clip, int *x1, int *y1, int *x2, int *y2 ); |
int BlockClip( clip_t *clip, int *x1, int *y1, int *x2, int* y2 ); |
typedef struct |
{ |
unsigned width; |
unsigned height; |
u32_t format; |
u32_t flags; |
unsigned pitch; |
void *mapped; |
u32_t handle; |
}pixmap_t; |
typedef struct |
{ |
unsigned width; |
unsigned height; |
u32_t format; |
u32_t flags; |
unsigned pitch; |
void *mapped; |
unsigned pitch_offset; |
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; |
struct |
{ |
int x0; |
int y0; |
}; |
union |
{ |
struct |
{ |
int x1; |
int y1; |
}; |
struct |
{ |
int w; |
int h; |
}; |
}; |
color_t color; |
}draw_t; |
typedef struct |
{ |
pixmap_t *dstpix; |
local_pixmap_t *dstpix; |
int x; |
int y; |
53,31 → 125,11 |
typedef struct |
{ |
int x0; |
int y0; |
int x1; |
int y1; |
u32 color; |
}line2p_t; |
typedef struct |
{ |
pixmap_t *pixmap; |
void *usermap; |
u32_t format; |
u32_t pitch; |
u32_t width; |
u32_t height; |
}userpixmap_t; |
typedef struct |
{ |
pixmap_t *dstpix; |
local_pixmap_t *dstpix; |
int dst_x; |
int dst_y; |
pixmap_t *srcpix; |
local_pixmap_t *srcpix; |
int src_x; |
int src_y; |
int w; |
85,94 → 137,18 |
}pixblit_t; |
int LineClip( int *x1, int *y1, int *x2, int *y2 ); |
int BlockClip( int *x1, int *y1, int *x2, int* y2); |
int Line2P(draw_t *draw); |
int DrawRect(draw_t * draw); |
int FillRect(fill_t * fill); |
int Line2P(line2p_t *draw); |
int Blit(blit_t *blit); |
int RadeonComposite( blit_t *blit); |
int CreatePixmap(userpixmap_t *io); |
int DestroyPixmap(userpixmap_t *io); |
int LockPixmap(userpixmap_t *io); |
int UnlockPixmap(userpixmap_t *io); |
int PixBlit(pixblit_t* blit); |
# define RADEON_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0) |
# define RADEON_GMC_DST_PITCH_OFFSET_CNTL (1 << 1) |
# define RADEON_GMC_BRUSH_SOLID_COLOR (13 << 4) |
# define RADEON_GMC_BRUSH_NONE (15 << 4) |
# define RADEON_GMC_DST_16BPP (4 << 8) |
# define RADEON_GMC_DST_24BPP (5 << 8) |
# define RADEON_GMC_DST_32BPP (6 << 8) |
# define RADEON_GMC_DST_DATATYPE_SHIFT 8 |
# define RADEON_GMC_SRC_DATATYPE_COLOR (3 << 12) |
# define RADEON_DP_SRC_SOURCE_MEMORY (2 << 24) |
# define RADEON_DP_SRC_SOURCE_HOST_DATA (3 << 24) |
# define RADEON_GMC_CLR_CMP_CNTL_DIS (1 << 28) |
# define RADEON_GMC_WR_MSK_DIS (1 << 30) |
# define RADEON_ROP3_S 0x00cc0000 |
# define RADEON_ROP3_P 0x00f00000 |
#define RADEON_CP_PACKET0 0x00000000 |
#define RADEON_CP_PACKET1 0x40000000 |
#define RADEON_CP_PACKET2 0x80000000 |
#define RADEON_CP_PACKET3 0xC0000000 |
# define RADEON_CNTL_PAINT 0x00009100 |
# define RADEON_CNTL_BITBLT 0x00009200 |
# define RADEON_CNTL_TRANBLT 0x00009C00 |
# define RADEON_CNTL_PAINT_POLYLINE 0x00009500 |
# define RADEON_CNTL_PAINT_MULTI 0x00009A00 |
#define CP_PACKET0(reg, n) \ |
(RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2)) |
#define CP_PACKET1(reg0, reg1) \ |
(RADEON_CP_PACKET1 | (((reg1) >> 2) << 11) | ((reg0) >> 2)) |
#define CP_PACKET2() \ |
(RADEON_CP_PACKET2) |
#define CP_PACKET3( pkt, n ) \ |
(RADEON_CP_PACKET3 | (pkt) | ((n) << 16)) |
#define BEGIN_RING( n ) do { \ |
ring = rhd.ring_base; \ |
write = rhd.ring_wp; \ |
} while (0) |
#define ADVANCE_RING() |
#define OUT_RING( x ) do { \ |
ring[write++] = (x); \ |
} while (0) |
#define OUT_RING_REG(reg, val) \ |
do { \ |
OUT_RING(CP_PACKET0(reg, 0)); \ |
OUT_RING(val); \ |
} while (0) |
#define DRM_MEMORYBARRIER() __asm volatile("lock; addl $0,0(%%esp)" : : : "memory"); |
#define COMMIT_RING() do { \ |
rhd.ring_wp = write & 0x1FFF; \ |
/* Flush writes to ring */ \ |
DRM_MEMORYBARRIER(); \ |
/*GET_RING_HEAD( dev_priv ); */ \ |
OUTREG( RADEON_CP_RB_WPTR, rhd.ring_wp); \ |
/* read from PCI bus to ensure correct posting */ \ |
INREG( RADEON_CP_RB_RPTR ); \ |
} while (0) |
/programs/system/drivers/ati2d/accel_2d.inc |
---|
1,29 → 1,34 |
#define BRUSH_MONO (0<<4) |
int DrawRect(draw_t* draw) |
{ |
int x0, y0, x1, y1; |
pixmap_t *dstpixmap; |
local_pixmap_t *dstpixmap; |
clip_t dst_clip; |
dstpixmap = (draw->dstpix == (void*)-1) ? &scr_pixmap : draw->dstpix ; |
x0 = draw->x; |
y0 = draw->y; |
x0 = draw->x0; |
y0 = draw->y0; |
x1 = x0+draw->w-1; |
y1 = y0+draw->h-1; |
dst_clip.xmin = 0; |
dst_clip.ymin = 0; |
dst_clip.xmax = dstpixmap->width-1; |
dst_clip.ymax = dstpixmap->height-1; |
// dbgprintf("draw rect x0:%d, y0:%d, x1:%d, y1:%d, color: %x\n", |
// x0, y0, x1, y1, draw->color); |
if( ! BlockClip( &x0, &y0, &x1, &y1)) |
if( ! BlockClip( &dst_clip, &x0, &y0, &x1, &y1)) |
{ |
u32 *ring, write; |
u32_t *ring, write; |
u32_t ifl; |
int w, h; |
u32 ifl; |
w = x1-x0+1; |
h = y1-y0+1; |
30,24 → 35,25 |
ifl = safe_cli(); |
#if R300_PIO |
R5xxFIFOWait(7); |
R5xxFIFOWait(6); |
OUTREG(R5XX_DP_GUI_MASTER_CNTL, rhd.gui_control | R5XX_ROP3_P | |
OUTREG(R5XX_DP_GUI_MASTER_CNTL, |
rhd.gui_control | |
R5XX_ROP3_P | |
R5XX_GMC_BRUSH_SOLID_COLOR | |
R5XX_GMC_SRC_DATATYPE_COLOR); |
R5XX_GMC_SRC_DATATYPE_COLOR | |
R5XX_GMC_CLR_CMP_CNTL_DIS | |
R5XX_GMC_WR_MSK_DIS |
); |
OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->color); |
OUTREG(R5XX_DP_WRITE_MASK, 0xFFFFFFFF); |
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,(y0<<16)|x0); |
OUTREG(R5XX_DST_Y_X,(draw->y0<<16)|draw->x0); |
OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|h); |
#else |
BEGIN_RING(); |
OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT_MULTI, 4)); |
55,16 → 61,17 |
RADEON_GMC_BRUSH_SOLID_COLOR | |
RADEON_GMC_DST_32BPP | |
RADEON_GMC_SRC_DATATYPE_COLOR | |
(1 << 28)+(1 << 30) | R5XX_ROP3_P); |
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((x0<<16)|y0); |
OUT_RING((draw->x0<<16)|y0); |
OUT_RING((w<<16)|h); |
COMMIT_RING(); |
#endif |
safe_sti(ifl); |
} ; |
return ERR_OK; |
72,7 → 79,8 |
int FillRect(fill_t *fill) |
{ |
pixmap_t *dstpixmap; |
local_pixmap_t *dstpixmap; |
clip_t dst_clip; |
int x0, y0, x1, y1; |
dstpixmap = (fill->dstpix == (void*)-1) ? &scr_pixmap : fill->dstpix ; |
83,27 → 91,58 |
x1 = x0+fill->w-1; |
y1 = y0+fill->h-1; |
dst_clip.xmin = 0; |
dst_clip.ymin = 0; |
dst_clip.xmax = dstpixmap->width-1; |
dst_clip.ymax = dstpixmap->height-1; |
// dbgprintf("fill rect x0:%d, y0:%d, x1:%d, y1:%d\n", |
// x0, y0, x1, y1); |
if( ! BlockClip( &x0, &y0, &x1, &y1)) |
if( ! BlockClip(&dst_clip, &x0, &y0, &x1, &y1)) |
{ |
u32 *ring, write; |
u32 ifl; |
u32_t *ring, write; |
u32_t ifl = safe_cli(); |
ifl = safe_cli(); |
#if R300_PIO |
int w = x1-x0+1; |
int h = y1-y0+1; |
R5xxFIFOWait(9); |
OUTREG(R5XX_DP_GUI_MASTER_CNTL, |
RADEON_GMC_DST_PITCH_OFFSET_CNTL | |
R5XX_GMC_BRUSH_8X8_MONO_FG_BG | |
RADEON_GMC_DST_32BPP | |
R5XX_GMC_SRC_DATATYPE_COLOR | |
R5XX_GMC_CLR_CMP_CNTL_DIS | |
R5XX_GMC_WR_MSK_DIS | |
R5XX_ROP3_P |
); |
OUTREG(R5XX_DP_BRUSH_BKGD_CLR, fill->bkcolor); |
OUTREG(R5XX_DP_BRUSH_FRGD_CLR, fill->fcolor); |
OUTREG(R5XX_BRUSH_DATA0, fill->bmp0); |
OUTREG(R5XX_BRUSH_DATA1, fill->bmp1); |
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,(y0<<16)|x0); |
OUTREG(R5XX_DST_HEIGHT_WIDTH,(h<<16)|w); |
#else |
BEGIN_RING(); |
OUT_RING(CP_PACKET3(RADEON_CNTL_PAINT, 7)); |
OUT_RING(RADEON_GMC_DST_PITCH_OFFSET_CNTL | |
BRUSH_MONO | |
R5XX_GMC_BRUSH_8X8_MONO_FG_BG | |
RADEON_GMC_DST_32BPP | |
RADEON_GMC_SRC_DATATYPE_COLOR | |
(1 << 28)+(1 << 30) | R5XX_ROP3_P); |
R5XX_GMC_CLR_CMP_CNTL_DIS | |
R5XX_GMC_WR_MSK_DIS | |
R5XX_ROP3_P |
); |
OUT_RING(dstpixmap->pitch_offset); |
OUT_RING(fill->bkcolor); |
117,12 → 156,12 |
COMMIT_RING(); |
#endif |
safe_sti(ifl); |
}; |
return ERR_OK; |
} |
}; |
#if 0 |
int Blit(blit_t *blit) |
{ |
int x0, y0, x1, y1; |
134,7 → 173,7 |
y1 = y0+blit->h-1; |
if( ! BlockClip( &x0, &y0, &x1, &y1)) |
if( ! BlockClip(&clip, &x0, &y0, &x1, &y1)) |
{ |
u32 *ring, write; |
int w, h; |
176,11 → 215,13 |
return ERR_OK; |
} |
int Line2P(line2p_t *draw) |
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; |
187,12 → 228,12 |
x1 = draw->x1; |
y1 = draw->y1; |
if ( !LineClip( &x0, &y0, &x1, &y1 )) |
if ( !LineClip(&clip, &x0, &y0, &x1, &y1 )) |
{ |
u32 ifl; |
u32 efl; |
u32 *ring, write; |
ifl = safe_cli(); |
efl = safe_cli(); |
#if R300_PIO |
234,20 → 275,21 |
COMMIT_RING(); |
#endif |
safe_sti(ifl); |
safe_sti(efl); |
}; |
return ERR_OK; |
} |
#endif |
int CreatePixmap(userpixmap_t *io) |
int CreatePixmap(pixmap_t *io) |
{ |
local_pixmap_t *pixmap; |
pixmap_t *pixmap; |
unsigned pitch; |
size_t size; |
u32_t pitch; |
void *raw; |
void *local; |
if( (io->width == 0) || (io->width > 2048)|| |
(io->height == 0)|| (io->height > 2048)) |
254,76 → 296,92 |
{ |
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); |
raw = rhd_mem_alloc(&rhd,RHD_MEM_FB,pitch*io->height) ; |
if (! raw) |
local = rhd_mem_alloc(&rhd,RHD_MEM_FB,size) ; |
if ( !local) |
{ |
dbgprintf("Not enough memory for pixmap\n"); |
return ERR_PARAM; |
}; |
pixmap = malloc(sizeof(pixmap_t)); |
pixmap = malloc(sizeof(local_pixmap_t)); |
if(!pixmap) |
{ |
rhd_mem_free(&rhd, RHD_MEM_FB,raw); |
rhd_mem_free(&rhd, RHD_MEM_FB,local); |
return ERR_PARAM; |
} |
else |
{ |
io->pixmap = pixmap; |
io->usermap = NULL; |
io->format = PICT_a8r8g8b8; |
io->pitch = 0; |
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 = 0; |
pixmap->flags = io->flags; |
pixmap->pitch = pitch; |
pixmap->offset = (u32_t)raw+rhd.FbIntAddress; |
pixmap->pitch_offset = ((pitch/64)<<22)| (pixmap->offset>>10); |
pixmap->raw = raw; |
pixmap->usermap = NULL; |
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("pixmap.offset: %x\n", pixmap->offset); |
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( userpixmap_t *io) |
int DestroyPixmap( pixmap_t *io ) |
{ |
pixmap_t *pixmap; |
local_pixmap_t *pixmap; |
size_t size; |
dbgprintf("Destroy pixmap %x\n", io->pixmap); |
dbgprintf("Destroy pixmap %x\n", io->handle); |
if(io->pixmap == (pixmap_t*)-1) |
if(io->handle == -1) |
return ERR_PARAM; |
else |
pixmap = io->pixmap; |
pixmap = (local_pixmap_t*)io->handle; |
if( (pixmap->flags & 1) == PX_LOCK ) |
UnlockPixmap(io); |
size = (pixmap->pitch*pixmap->height+4095) & ~ 4095; |
UserFree(pixmap->usermap); |
rhd_mem_free(&rhd,RHD_MEM_FB,pixmap->raw); |
UnmapPages(pixmap->mapped, size); |
UserFree(pixmap->mapped); |
rhd_mem_free(&rhd,RHD_MEM_FB,pixmap->local); |
free(pixmap); |
io->pixmap = NULL; |
io->usermap = NULL; |
io->format = 0; |
io->pitch = 0; |
io->mapped = NULL; |
io->handle = 0; |
return ERR_OK; |
}; |
#if 0 |
int LockPixmap(userpixmap_t *io) |
{ |
pixmap_t *pixmap; |
391,18 → 449,15 |
return ERR_OK; |
}; |
#endif |
int PixBlit(pixblit_t *blit) |
{ |
clip_t src_clip, dst_clip; |
u32 *ring, write; |
int w, h; |
u32 ifl; |
int x0, y0; |
local_pixmap_t *srcpixmap; |
local_pixmap_t *dstpixmap; |
pixmap_t *srcpixmap; |
pixmap_t *dstpixmap; |
//dbgprintf("Pixblit src: %x dst: %x\n",blit->srcpix, blit->dstpix); |
dstpixmap = (blit->dstpix == (void*)-1) ? &scr_pixmap : blit->dstpix ; |
415,8 → 470,24 |
//dbgprintf("srcpitch: %x dstpitch: %x\n", |
// srcpixmap->pitch_offset,dstpixmap->pitch_offset); |
ifl = safe_cli(); |
src_clip.xmin = 0; |
src_clip.ymin = 0; |
src_clip.xmax = srcpixmap->width-1; |
src_clip.ymax = srcpixmap->height-1; |
dst_clip.xmin = 0; |
dst_clip.ymin = 0; |
dst_clip.xmax = dstpixmap->width-1; |
dst_clip.ymax = dstpixmap->height-1; |
if( !blit_clip(&dst_clip, &blit->dst_x, &blit->dst_y, |
&src_clip, &blit->src_x, &blit->src_y, |
&blit->w, &blit->h) ) |
{ |
u32_t *ring, write; |
u32_t ifl = safe_cli(); |
#if R300_PIO |
R5xxFIFOWait(7); |
467,23 → 538,19 |
COMMIT_RING(); |
#endif |
safe_sti(ifl); |
}; |
return ERR_OK; |
} |
}; |
int TransBlit(pixblit_t *blit) |
{ |
clip_t src_clip, dst_clip; |
u32 *ring, write; |
int w, h; |
u32 ifl; |
int x0, y0; |
local_pixmap_t *srcpixmap; |
local_pixmap_t *dstpixmap; |
pixmap_t *srcpixmap; |
pixmap_t *dstpixmap; |
// dbgprintf("Transblit src: %x dst: %x\n",blit->srcpix, blit->dstpix); |
dstpixmap = (blit->dstpix == (void*)-1) ? &scr_pixmap : blit->dstpix ; |
495,9 → 562,24 |
//dbgprintf("src.width: %d src.height: %d\n", srcpixmap->width,srcpixmap->height); |
//dbgprintf("srcpitch: %x dstpitch: %x\n", |
// srcpixmap->pitch_offset,dstpixmap->pitch_offset); |
src_clip.xmin = 0; |
src_clip.ymin = 0; |
src_clip.xmax = srcpixmap->width-1; |
src_clip.ymax = srcpixmap->height-1; |
ifl = safe_cli(); |
dst_clip.xmin = 0; |
dst_clip.ymin = 0; |
dst_clip.xmax = dstpixmap->width-1; |
dst_clip.ymax = dstpixmap->height-1; |
if( !blit_clip(&dst_clip, &blit->dst_x, &blit->dst_y, |
&src_clip, &blit->src_x, &blit->src_y, |
&blit->w, &blit->h) ) |
{ |
u32_t *ring, write; |
u32_t ifl = safe_cli(); |
#if R300_PIO |
R5xxFIFOWait(10); |
557,6 → 639,7 |
#endif |
safe_sti(ifl); |
}; |
return ERR_OK; |
} |
/programs/system/drivers/ati2d/ati2d.c |
---|
2,16 → 2,18 |
//ld -T ld.x -s --shared --image-base 0 --file-alignment 32 -o test.exe test.obj core.lib |
#include "common.h" |
#include "ati2d.h" |
#include "accel_2d.h" |
RHD_t rhd; |
pixmap_t scr_pixmap; |
static clip_t clip; |
static local_pixmap_t scr_pixmap; |
/* |
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"); |
22,6 → 24,7 |
void (__stdcall *old_restore)(int x, int y); |
cursor_t* (*old_create)(void); |
cursor_t* __create_cursor(void); |
*/ |
static void Init3DEngine(RHDPtr rhdPtr); |
86,14 → 89,11 |
}; |
#pragma pack (push,1) |
#pragma pack (pop) |
#define API_VERSION 0x01000100 |
#define SRV_GETVERSION 0 |
/* |
int _stdcall srv_cursor(ioctl_t *io) |
{ |
u32 *inp; |
117,8 → 117,8 |
}; |
return ERR_PARAM; |
} |
*/ |
int _stdcall srv_2d(ioctl_t *io) |
{ |
u32 *inp; |
146,10 → 146,10 |
if(io->inp_size==9) |
return FillRect((fill_t*)inp); |
break; |
/* |
case LINE_2P: |
if(io->inp_size==5) |
return Line2P((line2p_t*)inp); |
if(io->inp_size==6) |
return Line2P((draw_t*)inp); |
break; |
case BLIT: |
161,10 → 161,10 |
if(io->inp_size==6) |
return RadeonComposite((blit_t*)inp); |
break; |
case PIXMAP: |
if(io->inp_size==6) |
return CreatePixmap((userpixmap_t*)inp); |
*/ |
case PX_CREATE: |
if(io->inp_size==7) |
return CreatePixmap((pixmap_t*)inp); |
break; |
case PIXBLIT: |
172,19 → 172,19 |
return PixBlit((pixblit_t*)inp); |
break; |
case PIXLOCK: |
if(io->inp_size==6) |
return LockPixmap((userpixmap_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 PIXUNLOCK: |
// if(io->inp_size==6) |
// return UnlockPixmap((userpixmap_t*)inp); |
// break; |
case PIXDESTROY: |
if(io->inp_size==6) |
return DestroyPixmap((userpixmap_t*)inp); |
return DestroyPixmap((pixmap_t*)inp); |
break; |
case TRANSBLIT: |
206,214 → 206,9 |
//#include "cursor.inc" |
#include "r500.inc" |
#include "clip.inc" |
#include "accel_2d.inc" |
#include "accel_3d.inc" |
#define CLIP_TOP 1 |
#define CLIP_BOTTOM 2 |
#define CLIP_RIGHT 4 |
#define CLIP_LEFT 8 |
char _L1OutCode( int x, int y ) |
/*================================= |
Verify that a point is inside or outside the active viewport. */ |
{ |
char 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( 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. */ |
{ |
char flag1; |
char flag2; |
flag1 = _L1OutCode( *x1, *y1 ); |
flag2 = _L1OutCode( *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( *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( *x1, *y1 ); |
} |
} |
return( flag1 & flag2 ); |
} |
static void block_inter( 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( 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 ). */ |
{ |
char flag1; |
char flag2; |
flag1 = _L1OutCode( *x1, *y1 ); |
flag2 = _L1OutCode( *x2, *y2 ); |
for( ;; ) { |
if( flag1 & flag2 ) break; /* trivially outside */ |
if( flag1 == flag2 ) break; /* completely inside */ |
if( flag1 == 0 ) { |
block_inter( x2, y2, flag2 ); |
flag2 = _L1OutCode( *x2, *y2 ); |
} else { |
block_inter( x1, y1, flag1 ); |
flag1 = _L1OutCode( *x1, *y1 ); |
} |
} |
return( flag1 & flag2 ); |
} |
#if 0 |
typedef struct |
{ |
int left; |
int top; |
int right; |
int bottom; |
}rect_t; |
typedef struct _window |
{ |
struct _window *fd; |
struct _window *bk; |
rect_t pos; |
int width; |
int height; |
int level; |
}win_t, *WINPTR; |
WINPTR top = NULL; |
WINPTR bottom = NULL; |
WINPTR alloc_window() |
{ |
WINPTR pwin = malloc(sizeof(win_t)); |
return pwin; |
}; |
WINPTR create_win(int l, int t, int w, int h, int level) |
{ |
WINPTR pwin = alloc_window(); |
pwin->pos.left = l; |
pwin->pos.top = t; |
pwin->pos.right = l+w-1; |
pwin->pos.bottom = t+h-1; |
pwin->width = w; |
pwin->height = h; |
pwin->level = level; |
return pwin; |
}; |
void insert_window(WINPTR pwin) |
{ |
WINPTR p = top; |
if(p) |
{ |
if(pwin->level <= p->level) |
{ |
pwin->fd = p; |
pwin->bk = p->bk; |
pwin->bk->fd = pwin; |
p->bk = pwin; |
} |
else |
p = p->fd; |
} |
else |
top = pwin; |
} |
#endif |
/programs/system/drivers/ati2d/ati2d.h |
---|
167,30 → 167,84 |
extern RHD_t rhd; |
typedef struct |
{ |
int xmin; |
int ymin; |
int xmax; |
int ymax; |
}clip_t, *PTRclip; |
typedef struct |
{ |
u32_t width; |
u32_t height; |
u32_t format; |
u32_t flags; |
u32_t pitch_offset; |
u32_t pitch; |
u32_t offset; |
void* raw; |
void* usermap; |
}pixmap_t; |
#define R5XX_DP_BRUSH_BKGD_CLR 0x1478 |
#define R5XX_DP_BRUSH_FRGD_CLR 0x147c |
#define R5XX_BRUSH_DATA0 0x1480 |
#define R5XX_BRUSH_DATA1 0x1484 |
#define PX_LOCK 1 |
# define RADEON_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0) |
# define RADEON_GMC_DST_PITCH_OFFSET_CNTL (1 << 1) |
# define RADEON_GMC_BRUSH_SOLID_COLOR (13 << 4) |
# define RADEON_GMC_BRUSH_NONE (15 << 4) |
# define RADEON_GMC_DST_16BPP (4 << 8) |
# define RADEON_GMC_DST_24BPP (5 << 8) |
# define RADEON_GMC_DST_32BPP (6 << 8) |
# define RADEON_GMC_DST_DATATYPE_SHIFT 8 |
# define RADEON_GMC_SRC_DATATYPE_COLOR (3 << 12) |
# define RADEON_DP_SRC_SOURCE_MEMORY (2 << 24) |
# define RADEON_DP_SRC_SOURCE_HOST_DATA (3 << 24) |
# define RADEON_GMC_CLR_CMP_CNTL_DIS (1 << 28) |
# define RADEON_GMC_WR_MSK_DIS (1 << 30) |
# define RADEON_ROP3_S 0x00cc0000 |
# define RADEON_ROP3_P 0x00f00000 |
#define RADEON_CP_PACKET0 0x00000000 |
#define RADEON_CP_PACKET1 0x40000000 |
#define RADEON_CP_PACKET2 0x80000000 |
#define RADEON_CP_PACKET3 0xC0000000 |
# define RADEON_CNTL_PAINT 0x00009100 |
# define RADEON_CNTL_BITBLT 0x00009200 |
# define RADEON_CNTL_TRANBLT 0x00009C00 |
# define RADEON_CNTL_PAINT_POLYLINE 0x00009500 |
# define RADEON_CNTL_PAINT_MULTI 0x00009A00 |
#define CP_PACKET0(reg, n) \ |
(RADEON_CP_PACKET0 | ((n) << 16) | ((reg) >> 2)) |
#define CP_PACKET1(reg0, reg1) \ |
(RADEON_CP_PACKET1 | (((reg1) >> 2) << 11) | ((reg0) >> 2)) |
#define CP_PACKET2() \ |
(RADEON_CP_PACKET2) |
#define CP_PACKET3( pkt, n ) \ |
(RADEON_CP_PACKET3 | (pkt) | ((n) << 16)) |
#define BEGIN_RING( n ) do { \ |
ring = rhd.ring_base; \ |
write = rhd.ring_wp; \ |
} while (0) |
#define ADVANCE_RING() |
#define OUT_RING( x ) do { \ |
ring[write++] = (x); \ |
} while (0) |
#define OUT_RING_REG(reg, val) \ |
do { \ |
OUT_RING(CP_PACKET0(reg, 0)); \ |
OUT_RING(val); \ |
} while (0) |
#define DRM_MEMORYBARRIER() __asm volatile("lock; addl $0,0(%%esp)" : : : "memory"); |
#define COMMIT_RING() do { \ |
rhd.ring_wp = write & 0x1FFF; \ |
/* Flush writes to ring */ \ |
DRM_MEMORYBARRIER(); \ |
/*GET_RING_HEAD( dev_priv ); */ \ |
OUTREG( RADEON_CP_RB_WPTR, rhd.ring_wp); \ |
/* read from PCI bus to ensure correct posting */ \ |
INREG( RADEON_CP_RB_RPTR ); \ |
} while (0) |
typedef struct { |
int token; /* id of the token */ |
const char * name; /* token name */ |
/programs/system/drivers/ati2d/r500.inc |
---|
389,9 → 389,9 |
scr_pixmap.height = rhd.displayHeight; |
scr_pixmap.format = PICT_a8r8g8b8; |
scr_pixmap.pitch = rhd.displayWidth * 4; |
scr_pixmap.offset = rhd.FbIntAddress; |
scr_pixmap.local = (void*)rhd.FbIntAddress; |
scr_pixmap.pitch_offset = rhd.dst_pitch_offset; |
scr_pixmap.raw = (void*)0; |
scr_pixmap.mapped = (void*)0; |
MASKREG(R5XX_GB_TILE_CONFIG, 0, R5XX_ENABLE_TILING); |