From e50ee3e947995fe99a5206fac225aff3edbe0163 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Wed, 15 Oct 2008 10:31:44 +0000 Subject: [PATCH] draw border git-svn-id: svn://kolibrios.org@878 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/system/drivers/ati2d/accel_2d.h | 1 + programs/system/drivers/ati2d/accel_2d.inc | 49 +++++++++++++++++++--- programs/system/drivers/ati2d/ati2d.c | 7 +++- programs/system/drivers/ati2d/r500.inc | 21 ++++------ programs/system/drivers/ati2d/syscall.h | 30 +++++++++++++ 5 files changed, 89 insertions(+), 19 deletions(-) diff --git a/programs/system/drivers/ati2d/accel_2d.h b/programs/system/drivers/ati2d/accel_2d.h index 398e6cdeb1..b2f9dfc3da 100644 --- a/programs/system/drivers/ati2d/accel_2d.h +++ b/programs/system/drivers/ati2d/accel_2d.h @@ -95,6 +95,7 @@ typedef struct }; }; color_t color; + color_t border; }draw_t; typedef struct diff --git a/programs/system/drivers/ati2d/accel_2d.inc b/programs/system/drivers/ati2d/accel_2d.inc index a2772aea9e..2c5ffcb235 100644 --- a/programs/system/drivers/ati2d/accel_2d.inc +++ b/programs/system/drivers/ati2d/accel_2d.inc @@ -70,7 +70,7 @@ int Line(draw_t *draw) int DrawRect(draw_t* draw) { - int x0, y0, x1, y1; + int x0, y0, x1, y1, xend, yend; local_pixmap_t *dstpixmap; clip_t dst_clip; @@ -80,8 +80,8 @@ int DrawRect(draw_t* draw) x0 = draw->x0; y0 = draw->y0; - x1 = x0+draw->w-1; - y1 = y0+draw->h-1; + x1 = xend = x0 + draw->w - 1; + y1 = yend = y0 + draw->h - 1; dst_clip.xmin = 0; dst_clip.ymin = 0; @@ -98,8 +98,8 @@ int DrawRect(draw_t* draw) u32_t ifl; int w, h; - w = x1-x0+1; - h = y1-y0+1; + w = x1 - x0 + 1; + h = y1 - y0 + 1; ifl = safe_cli(); @@ -119,8 +119,45 @@ int DrawRect(draw_t* draw) OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->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,(draw->y0<<16)|draw->x0); + OUTREG(R5XX_DST_Y_X,(y0<<16)|x0); OUTREG(R5XX_DST_WIDTH_HEIGHT,(w<<16)|h); + + if( draw->color != draw->border) + { + OUTREG(R5XX_DP_BRUSH_FRGD_CLR, draw->border); + + if( y0 == draw->y0) + { + 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 == draw->x0) + { + 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_MULTI, 4)); diff --git a/programs/system/drivers/ati2d/ati2d.c b/programs/system/drivers/ati2d/ati2d.c index 789f0faf4a..63b4f83766 100644 --- a/programs/system/drivers/ati2d/ati2d.c +++ b/programs/system/drivers/ati2d/ati2d.c @@ -35,6 +35,11 @@ u32_t __stdcall drvEntry(int action) printf("Can't open /rd/1/drivers/ati2d.log\nExit\n"); return 0; } + if( GetScreenBpp() != 32) + { + printf("32 bpp dispaly mode required !\nExit\t"); + return 0; + } if((rhdPtr=FindPciDevice())==NULL) { @@ -106,7 +111,7 @@ int _stdcall srv_2d(ioctl_t *io) break; case PX_DRAW_RECT: - if(io->inp_size==6) + if(io->inp_size==7) return DrawRect((draw_t*)inp); break; diff --git a/programs/system/drivers/ati2d/r500.inc b/programs/system/drivers/ati2d/r500.inc index f1730cd76a..0cf1aeed23 100644 --- a/programs/system/drivers/ati2d/r500.inc +++ b/programs/system/drivers/ati2d/r500.inc @@ -351,14 +351,14 @@ static void load_microcode() void R5xx2DInit() { u32_t base; + int screensize; + int screenpitch; -#ifdef R300_TEST - rhd.displayWidth = 1024; - rhd.displayHeight = 768; -#else - rhd.displayWidth = INREG(D1GRPH_X_END); - rhd.displayHeight = INREG(D1GRPH_Y_END); -#endif + screensize = GetScreenSize(); + screenpitch = GetScreenPitch(); + + rhd.displayWidth = screensize >> 16; + rhd.displayHeight = screensize & 0xFFFF; rhd.__xmin = 0; rhd.__ymin = 0; @@ -379,7 +379,7 @@ void R5xx2DInit() dbgprintf("gui_control %x \n", rhd.gui_control); rhd.surface_cntl = 0; - rhd.dst_pitch_offset = (((rhd.displayWidth * 4) / 64) << 22) | + rhd.dst_pitch_offset = ((screenpitch / 64) << 22) | ((rhd.FbIntAddress + rhd.FbScanoutStart) >> 10); dbgprintf("dst_pitch_offset %x \n", rhd.dst_pitch_offset); @@ -388,7 +388,7 @@ void R5xx2DInit() scr_pixmap.width = rhd.displayWidth; scr_pixmap.height = rhd.displayHeight; scr_pixmap.format = PICT_a8r8g8b8; - scr_pixmap.pitch = rhd.displayWidth * 4; + scr_pixmap.pitch = screenpitch; scr_pixmap.local = (void*)rhd.FbIntAddress; scr_pixmap.pitch_offset = rhd.dst_pitch_offset; scr_pixmap.mapped = (void*)0; @@ -437,9 +437,6 @@ void R5xx2DInit() OUTREG(RADEON_CP_CSQ_CNTL, RADEON_CSQ_PRIBM_INDBM); // run - - // OUTREG(D1CUR_SIZE, (31<<16)|31); - // OUTREG(D1CUR_CONTROL, 0x300); } diff --git a/programs/system/drivers/ati2d/syscall.h b/programs/system/drivers/ati2d/syscall.h index 2ed4c61506..1838adfa5e 100644 --- a/programs/system/drivers/ati2d/syscall.h +++ b/programs/system/drivers/ati2d/syscall.h @@ -71,6 +71,36 @@ int dbgprintf(const char* format, ...); /////////////////////////////////////////////////////////////////////////////// +extern inline int GetScreenSize() +{ + int retval; + + asm("int $0x40" + :"=a"(retval) + :"a"(61), "b"(1)); + return retval; +} + +extern inline int GetScreenBpp() +{ + int retval; + + asm("int $0x40" + :"=a"(retval) + :"a"(61), "b"(2)); + return retval; +} + +extern inline int GetScreenPitch() +{ + int retval; + + asm("int $0x40" + :"=a"(retval) + :"a"(61), "b"(3)); + return retval; +} + extern inline u32_t GetPgAddr(void *mem) { u32_t retval;