diff options
author | Jordan Crouse <jordan.crouse@amd.com> | 2007-03-08 18:06:11 -0700 |
---|---|---|
committer | Jordan Crouse <jordan.crouse@amd.com> | 2007-03-08 18:06:54 -0700 |
commit | 2d7689990c19fd74d5fad11bcf6317a7874a6057 (patch) | |
tree | 8e51f7a7c8304d4c16529c429ec334fd15ff42d5 /src | |
parent | b959509bb37e6ef269088ecbe92f49c7dc971fb6 (diff) |
Fix a couple of scary bugs - including one that seemed to be causing
corruption.
Diffstat (limited to 'src')
-rw-r--r-- | src/amd_lx_cursor.c | 127 | ||||
-rw-r--r-- | src/amd_lx_driver.c | 16 | ||||
-rw-r--r-- | src/amd_lx_exa.c | 131 |
3 files changed, 78 insertions, 196 deletions
diff --git a/src/amd_lx_cursor.c b/src/amd_lx_cursor.c index 61f3d5d..e385484 100644 --- a/src/amd_lx_cursor.c +++ b/src/amd_lx_cursor.c @@ -23,13 +23,6 @@ * software without specific prior written permission. * */ -/* - * File Contents: Xfree cursor implementation routines for geode HWcursor - * init.setting cursor color,image etc. are done here. - * - * Project: Geode Xfree Frame buffer device driver. - * */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -53,21 +46,6 @@ extern void LXSetVideoPosition(int x, int y, int width, int height, short src_w, short src_h, short drw_w, short drw_h, int id, int offset, ScrnInfoPtr pScrn); -/*---------------------------------------------------------------------------- -* LXHWCursorInit. - * - * Description :This function sets the cursor information by probing the - * hardware. - * - * Parameters. - * pScrn :Screeen pointer structure. - * - * Returns :TRUE on success and FALSE on Failure - * - * Comments :Geode supports the hardware_cursor,no need to enable SW - * cursor. - *---------------------------------------------------------------------------- - */ Bool LXHWCursorInit(ScreenPtr pScrn) { @@ -86,55 +64,23 @@ LXHWCursorInit(ScreenPtr pScrn) infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST | HARDWARE_CURSOR_TRUECOLOR_AT_8BPP | HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED; - /* cursor info ptr is intiallized with the values obtained from - * * durnago calls - */ + infoPtr->SetCursorColors = LXSetCursorColors; infoPtr->SetCursorPosition = LXSetCursorPosition; infoPtr->LoadCursorImage = LXLoadCursorImage; infoPtr->HideCursor = LXHideCursor; infoPtr->ShowCursor = LXShowCursor; infoPtr->UseHWCursor = LXUseHWCursor; + return (xf86InitCursor(pScrn, infoPtr)); } -/*---------------------------------------------------------------------------- - * LXSetCursorColors. - * - * Description :This function sets the cursor foreground and background - * colors - * Parameters: - * pScrn: Screeen pointer structure. - * bg: Specifies the color value of cursor background color. - * fg: Specifies the color value of cursor foreground color. - * - * Returns: none. - * - * Comments: The integer color value passed by this function is - * converted into * RGB value by the gfx_set_color routines. - *---------------------------------------------------------------------------- - */ static void LXSetCursorColors(ScrnInfoPtr pScrni, int bg, int fg) { vg_set_mono_cursor_colors(bg, fg); } -/*---------------------------------------------------------------------------- - * LXSetCursorPosition. - * - * Description :This function sets the cursor co -ordinates and enable the - * cursor. - * - * Parameters: - * pScrn: Screeen pointer structure. - * x: Specifies the x-cordinates of the cursor. - * y: Specifies the y co-ordinate of the cursor. - * - * Returns: none. - * - *---------------------------------------------------------------------------- - */ static void LXSetCursorPosition(ScrnInfoPtr pScrni, int x, int y) { @@ -154,19 +100,19 @@ LXSetCursorPosition(ScrnInfoPtr pScrni, int x, int y) newX = savex; newY = savey; hsx= 31; hsy = 31; break; - + case RR_Rotate_90: newX = savey; newY = pScrni->pScreen->width - savex; hsx= 31; hsy = 0; break; - + case RR_Rotate_180: newX = pScrni->pScreen->width - savex; - newY = pScrni->pScreen->height - savey; + newY = pScrni->pScreen->height - savey; hsx = 0; hsy = 0; break; - + case RR_Rotate_270: newX = pScrni->pScreen->height - savey; newY = savex; @@ -177,30 +123,16 @@ LXSetCursorPosition(ScrnInfoPtr pScrni, int x, int y) newX -= pScrni->frameX0; newY -= pScrni->frameY0; - { + { VG_PANNING_COORDINATES panning; vg_set_cursor_position(newX + hsx, newY + hsy, &panning); } - + vg_set_cursor_enable(1); /* FIXME: Adjust for video panning? */ } -/*---------------------------------------------------------------------------- - * LXLoadCursorImage - * - * Description: This function loads the 32x32 cursor pattern.The shape - * and color is set by AND and XOR masking of arrays of 32 - * DWORD. - * Parameters: - * pScrn: Screeen pointer structure. - * src: Specifies cursor data. - * - * Returns: none - * - *---------------------------------------------------------------------------- - */ void LXLoadCursorImage(ScrnInfoPtr pScrni, unsigned char *src) { @@ -259,61 +191,18 @@ LXLoadCursorImage(ScrnInfoPtr pScrni, unsigned char *src) vg_set_mono_cursor_shape32(pGeode->CursorStartOffset,&andMask[0],&xorMask[0],31,31); } -/*---------------------------------------------------------------------------- - * LXHideCursor. - * - * Description: This function will disable the cursor. - * - * Parameters: - * pScrn: Handles to the Screeen pointer structure. - * - * Returns: none. - * - * Comments: _set_cursor enable function is hardcoded to disable - * the cursor. - *---------------------------------------------------------------------------- - */ void LXHideCursor(ScrnInfoPtr pScrni) { vg_set_cursor_enable(0); } -/*---------------------------------------------------------------------------- - * LXShowCursor - * - * Description :This function will enable the cursor. - * - * Parameters: - * pScrn :Handles to the Screeen pointer structure. - * - * Returns :none - * - * Comments :gfx_set_cursor enable function is hardcoded to enable the - * cursor - *---------------------------------------------------------------------------- - */ void LXShowCursor(ScrnInfoPtr pScrni) { vg_set_cursor_enable(1); } -/*---------------------------------------------------------------------------- - * LXUseHwCursor. - * - * Description :This function will sets the hardware cursor flag in - * pscreen structure. - * - * Parameters. - * pScrn :Handles to the Screeen pointer structure. - * - * Returns :none - * - * Comments :none - * - *---------------------------------------------------------------------------- - */ static Bool LXUseHWCursor(ScreenPtr pScrn, CursorPtr pCurs) { diff --git a/src/amd_lx_driver.c b/src/amd_lx_driver.c index d8cfaa7..a7b352a 100644 --- a/src/amd_lx_driver.c +++ b/src/amd_lx_driver.c @@ -299,7 +299,7 @@ LXAllocateMemory(ScreenPtr pScrn, ScrnInfoPtr pScrni, int rotate) fboffset += size; fbavail -= size; - + pGeode->Compression = TRUE; } else { xf86DrvMsg(pScrni->scrnIndex, X_ERROR, @@ -325,11 +325,13 @@ LXAllocateMemory(ScreenPtr pScrn, ScrnInfoPtr pScrni, int rotate) /* Try to set up some EXA scratch memory for blending */ + pGeode->exaBfrOffset = 0; + if (!pGeode->NoAccel) { if (pGeode->exaBfrSz > 0 && pGeode->exaBfrSz <= fbavail) { pGeode->exaBfrOffset = fboffset; - fboffset += pGeode->exaBfrOffset; - fbavail -= pGeode->exaBfrOffset; + fboffset += pGeode->exaBfrSz; + fbavail -= pGeode->exaBfrSz; } } @@ -981,17 +983,17 @@ LXCloseScreen(int scrnIndex, ScreenPtr pScrn) LXUnmapMem(pScrni); if (pGeode->useVGA) - vgaHWUnmapMem(pScrn); + vgaHWUnmapMem(pScrni); - Scrni->PointerMoved = pGeode->PointerMoved; + pScrni->PointerMoved = pGeode->PointerMoved; pScrn->CloseScreen = pGeode->CloseScreen; - + if (pScrn->CloseScreen) return (*pScrn->CloseScreen)(scrnIndex, pScrn); return TRUE; } - + static Bool LXEnterGraphics(ScreenPtr pScrn, ScrnInfoPtr pScrni) { diff --git a/src/amd_lx_exa.c b/src/amd_lx_exa.c index de3c5dd..107f0ea 100644 --- a/src/amd_lx_exa.c +++ b/src/amd_lx_exa.c @@ -76,7 +76,7 @@ static struct { int op; int repeat; - unsigned int fourBpp; + unsigned int fourBpp; unsigned int bufferOffset; struct exa_format_t *srcFormat; struct exa_format_t *dstFormat; @@ -471,9 +471,14 @@ static Bool lx_check_composite(int op, PicturePtr pSrc, PicturePtr pMsk, /* Check that the operation is supported */ - if (op > PictOpAdd) + if (op > PictOpAdd) return FALSE; + if (usesPasses(op)) { + if (pGeode->exaBfrOffset == 0 || !pMsk) + return FALSE; + } + /* Check that the filter matches what we support */ switch(pSrc->filter) { @@ -490,20 +495,15 @@ static Bool lx_check_composite(int op, PicturePtr pSrc, PicturePtr pMsk, /* We don't handle transforms */ - if (pSrc->transform) - return FALSE; - - /* We only support single pass operations at this point */ - - if (pMsk && usesPasses(op)) + if (pSrc->transform) return FALSE; /* XXX - I don't understand PICT_a8 enough - so I'm punting */ - + if (pSrc->format == PICT_a8 || pDst->format == PICT_a8) return FALSE; - + return TRUE; } @@ -539,7 +539,7 @@ static Bool lx_prepare_composite(int op, PicturePtr pSrc, PicturePtr pMsk, ErrorF("EXA: Dest needs alpha bits\n"); return FALSE; } - + /* FIXME: See a way around this! */ if (srcFmt->alphabits == 0 && dstFmt->alphabits != 0) @@ -593,12 +593,12 @@ static Bool lx_prepare_composite(int op, PicturePtr pSrc, PicturePtr pMsk, /* If the direction is reversed, then remember the source */ - if (direction == 1) + if (direction == 1) exaScratch.srcPixmap = pxSrc; /* Extract the source color to use */ - if (direction == 0) + if (direction == 0) srcColor = lx_get_source_color(pSrc, 0, 0, pDst->format); else srcColor = lx_get_source_color(pDst, 0, 0, pSrc->format); @@ -607,7 +607,7 @@ static Bool lx_prepare_composite(int op, PicturePtr pSrc, PicturePtr pMsk, gp_declare_blt (0); gp_set_solid_source (srcColor); - gp_write_parameters(); + gp_write_parameters(); } else { if (usesPasses(op)) @@ -618,7 +618,7 @@ static Bool lx_prepare_composite(int op, PicturePtr pSrc, PicturePtr pMsk, exaScratch.srcOffset = exaGetPixmapOffset(pxSrc); exaScratch.srcPitch = exaGetPixmapPitch(pxSrc); exaScratch.srcBpp = (pxSrc->drawable.bitsPerPixel + 7) / 8; - + exaScratch.srcWidth = pSrc->pDrawable->width; exaScratch.srcHeight = pSrc->pDrawable->height; } @@ -651,37 +651,24 @@ int lx_get_bpp_from_format(int format) { return 0; } -int lx_get_alpha_one(int format) -{ - switch(format) { - case CIMGP_SOURCE_FMT_8_8_8_8: - case CIMGP_SOURCE_FMT_32BPP_BGR: - return 0xFF << 16; - - case CIMGP_SOURCE_FMT_4_4_4_4: - return 0xF << 12; - - case CIMGP_SOURCE_FMT_1_5_5_5: - case CIMGP_SOURCE_FMT_15BPP_BGR: - return 1 << 15; - } - - return 0; -} - +/* BGR needs to be set in the source for it to take - so adjust the source + * to enable BGR if the two formats are different, and disable it if they + * are the same + */ + static lx_set_source_format(int srcFormat, int dstFormat) { - /* If BGR is set in the destination, then move the BGR bit to the source */ - /* If they are both BGR, then don't set the bit */ - - if (!(srcFormat & 0x10) && (dstFormat & 0x10)) + if (!(srcFormat & 0x10) && (dstFormat & 0x10)) gp_set_source_format(srcFormat | 0x10); else if ((srcFormat & 0x10) && (dstFormat & 0x10)) gp_set_source_format(srcFormat & ~0x10); else gp_set_source_format(srcFormat); } - + +/* Note - this is the preferred onepass method. The other will remain + * ifdefed out until such time that we are sure its not needed + */ #if 1 @@ -703,7 +690,7 @@ lx_composite_onepass(PixmapPtr pxDst, unsigned long dstOffset, gp_set_strides(exaGetPixmapPitch(pxDst), exaScratch.srcPitch); lx_set_source_format(exaScratch.srcFormat->fmt, exaScratch.dstFormat->fmt); - + gp_set_alpha_operation(opPtr->operation, opPtr->type, opPtr->channel, apply, 0); @@ -780,7 +767,7 @@ lx_composite_convert(PixmapPtr pxDst, unsigned long dstOffset, gp_set_strides(exaGetPixmapPitch(pxDst), exaGetPixmapPitch(pxDst)); gp_screen_to_screen_blt(exaScratch.bufferOffset, dstOffset, width, height, 0); - + /* Step 2 - Do the original blend */ lx_composite_onepass(pxDst, exaScratch.bufferOffset, srcOffset, width, height); @@ -810,7 +797,13 @@ lx_composite_multipass(PixmapPtr pxDst, unsigned long dstOffset, unsigned long s int sbpp = lx_get_bpp_from_format(exaScratch.srcFormat->fmt); int apply; - /* Copy the destination to the scratch buffer, and convert it to the source format */ + /* Wait until the GP is idle - this will ensure that the scratch buffer + * isn't occupied */ + + gp_wait_until_idle(); + + /* Copy the destination to the scratch buffer, and convert it to the + * source format */ gp_declare_blt(0); @@ -818,13 +811,15 @@ lx_composite_multipass(PixmapPtr pxDst, unsigned long dstOffset, unsigned long s gp_set_source_format(exaScratch.dstFormat->fmt); gp_set_raster_operation(0xCC); gp_set_strides(exaScratch.srcPitch, exaGetPixmapPitch(pxDst)); - gp_screen_to_screen_convert(exaScratch.bufferOffset, dstOffset, width, height, 0); + gp_screen_to_screen_convert(exaScratch.bufferOffset, dstOffset, + width, height, 0); /* Do the first blend from the source to the scratch buffer */ - gp_declare_blt(0); + gp_declare_blt(CIMGP_BLTFLAGS_HAZARD); gp_set_bpp(sbpp); gp_set_source_format(exaScratch.srcFormat->fmt); + gp_set_strides(exaScratch.srcPitch, exaScratch.srcPitch); opPtr = &lx_alpha_ops[exaScratch.op * 2]; @@ -834,7 +829,6 @@ lx_composite_multipass(PixmapPtr pxDst, unsigned long dstOffset, unsigned long s gp_set_alpha_operation(opPtr->operation, opPtr->type, opPtr->channel, apply, 0); - gp_set_strides(exaScratch.srcPitch, exaScratch.srcPitch); gp_screen_to_screen_blt(exaScratch.bufferOffset, srcOffset, width, height, 0); /* Finally, do the second blend back to the destination */ @@ -844,22 +838,21 @@ lx_composite_multipass(PixmapPtr pxDst, unsigned long dstOffset, unsigned long s apply = (exaScratch.dstFormat->alphabits == 0) ? CIMGP_APPLY_BLEND_TO_RGB : CIMGP_APPLY_BLEND_TO_ALL; - gp_declare_blt(0); + gp_declare_blt(CIMGP_BLTFLAGS_HAZARD); gp_set_bpp(lx_get_bpp_from_format(exaScratch.dstFormat->fmt)); - /* The only way to kick BGR is to set it in the source */ - lx_set_source_format(exaScratch.srcFormat->fmt, exaScratch.dstFormat->fmt); gp_set_alpha_operation(opPtr->operation, opPtr->type, opPtr->channel, apply, 0); - gp_screen_to_screen_convert(dstOffset, exaScratch.bufferOffset, width, height, 0); + gp_screen_to_screen_convert(dstOffset, exaScratch.bufferOffset, + width, height, 0); } static void -lx_do_composite_mask(PixmapPtr pxDst, unsigned long dstOffset, unsigned int maskOffset, - int width, int height) +lx_do_composite_mask(PixmapPtr pxDst, unsigned long dstOffset, + unsigned int maskOffset, int width, int height) { GeodeRec *pGeode = GEODEPTR_FROM_PIXMAP(pxDst); unsigned char *data = pGeode->FBBase + maskOffset; @@ -878,15 +871,12 @@ lx_do_composite_mask(PixmapPtr pxDst, unsigned long dstOffset, unsigned int mask (exaGetPixmapPitch((px)) * (y)) + \ ((((px)->drawable.bitsPerPixel + 7) / 8) * (x)) ) - static void lx_do_composite(PixmapPtr pxDst, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int width, int height) { struct blend_ops_t *opPtr = &lx_alpha_ops[exaScratch.op * 2]; - unsigned int dstBpp = (pxDst->drawable.bitsPerPixel + 7) / 8; - unsigned int dstPitch = exaGetPixmapPitch(pxDst); unsigned int dstOffset, srcOffset; unsigned int opX = dstX; @@ -894,38 +884,39 @@ lx_do_composite(PixmapPtr pxDst, int srcX, int srcY, int maskX, unsigned int opWidth = width; unsigned int opHeight = height; - if (exaScratch.type == COMP_TYPE_MASK) - srcOffset = exaScratch.srcOffset + (maskY * exaScratch.srcPitch) + + if (exaScratch.type == COMP_TYPE_MASK) + srcOffset = exaScratch.srcOffset + (maskY * exaScratch.srcPitch) + (maskX * exaScratch.srcBpp); else - srcOffset = exaScratch.srcOffset + (srcY * exaScratch.srcPitch) + + srcOffset = exaScratch.srcOffset + (srcY * exaScratch.srcPitch) + (srcX * exaScratch.srcBpp); - + /* Adjust the width / height of the operation the size of the source */ - + if (exaScratch.srcWidth < width) opWidth = exaScratch.srcWidth; - + if (exaScratch.srcHeight < height) opHeight = exaScratch.srcHeight; - + while(1) { - dstOffset = GetPixmapOffset(pxDst, dstX, dstY); - + dstOffset = GetPixmapOffset(pxDst, opX, opY); + switch(exaScratch.type) { case COMP_TYPE_MASK: { int direction = (opPtr->channel == CIMGP_CHANNEL_A_SOURCE) ? 0 : 1; - + if (direction == 1) { dstOffset = GetPixmapOffset(exaScratch.srcPixmap, dstX,dstY); - lx_do_composite_mask(exaScratch.srcPixmap, dstOffset, srcOffset, opWidth, opHeight); + lx_do_composite_mask(exaScratch.srcPixmap, dstOffset, srcOffset, + opWidth, opHeight); } else { lx_do_composite_mask(pxDst, dstOffset, srcOffset, opWidth, opHeight); } } break; - + case COMP_TYPE_ONEPASS: lx_composite_onepass(pxDst, dstOffset, srcOffset, opWidth, opHeight); break; @@ -937,21 +928,21 @@ lx_do_composite(PixmapPtr pxDst, int srcX, int srcY, int maskX, if (!exaScratch.repeat) break; - + opX += opWidth; - + if (opX >= dstX + width) { opX = dstX; opY += opHeight; - + if (opY >= dstY + height) break; } - + opWidth = ((dstX + width) - opX) > exaScratch.srcWidth ? exaScratch.srcWidth : (dstX + width) - opX; opHeight = ((dstY + height) - opY) > exaScratch.srcHeight ? - exaScratch.srcHeight : (dstY + height) - opY; + exaScratch.srcHeight : (dstY + height) - opY; } } |