⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ude506.c

📁 S1D13506windml下的驱动程序,支持vxworks5.4 支持tornado2.0 windml2.0
💻 C
📖 第 1 页 / 共 4 页
字号:
    status = uglGenericClutSet( (UGL_UGI_DRIVER *)pDriver, startIndex, pColors, numColors );

    uglWriteByte( (UGL_UINT8 *) ( LUT_MODE_REG + pciBaseAddress ), 0x00 ); /* set LUT mode */

    if ( status == UGL_STATUS_OK )
    {
        uglWriteByte( (UGL_UINT8 *)( LUT_ADDRESS_REG + pciBaseAddress ), startIndex ); 

        for (i = 0; i < numColors; i++)
        {
            uglWriteByte( (UGL_UINT8 *)( LUT_DATA_REG + pciBaseAddress ), ( UGL_RGB_RED   ( pColors[i] ) ) );
            uglWriteByte( (UGL_UINT8 *)( LUT_DATA_REG + pciBaseAddress ), ( UGL_RGB_GREEN ( pColors[i] ) ) );
            uglWriteByte( (UGL_UINT8 *)( LUT_DATA_REG + pciBaseAddress ), ( UGL_RGB_BLUE  ( pColors[i] ) ) );
        }
    }

    return( status );
}





/*
 * uglEpson8BitFrameToFrameBitBlit - Both source and destination are in video memory.
 */
UGL_LOCAL void uglEpson8BitFrameToFrameBitBlit 
(
    UGL_UGI_DRIVER * pDriver, 
    UGL_UINT8      * pSourceData,
    UGL_RECT       * pSourceRect,
    UGL_ORD          sourceStride,
    UGL_UINT8      * pDestData, 
    UGL_RECT       * pDestRect,
    UGL_ORD          destStride
)
{
    UGL_GENERIC_DRIVER  * pGenDriver = (UGL_GENERIC_DRIVER *)pDriver;
    UGL_RASTER_OP         rasterOp = pGenDriver->gc->rasterOp;
    UGL_UINT16            overLapType = 0;
    UGL_UINT16            width;
    UGL_UINT16            height;
    UGL_UINT16            phase=0;
    UGL_UINT16            screenStride = pDriver->pMode->width * BYTES_PER_PIXEL;
    volatile UGL_UINT16 * bltAddress = (UGL_UINT16 *)(pciBaseAddress + 0x100000);
    UGL_UINT16          * sourceAddr = (UGL_UINT16 *)pSourceData; 
    UGL_UINT16          * destAddr   = (UGL_UINT16 *)pDestData;

    /* program the Source Address Register */
    phase = (UGL_UINT32)sourceAddr & 1;

    uglWriteByte( ( BITBLT_SRCE_ADDRESS_REG0 + pciBaseAddress ), phase ); 
    uglWriteByte( ( BITBLT_SRCE_ADDRESS_REG1 + pciBaseAddress ), 0 ); 
    uglWriteByte( ( BITBLT_SRCE_ADDRESS_REG2 + pciBaseAddress ), 0 ); 


    /* program the Destination Address Register */
    uglWriteByte( ( BITBLT_DEST_ADDRESS_REG0 + pciBaseAddress ), ( UGL_UINT32)destAddr         );
    uglWriteByte( ( BITBLT_DEST_ADDRESS_REG1 + pciBaseAddress ), ( (UGL_UINT32)destAddr) >> 8  ); 
    uglWriteByte( ( BITBLT_DEST_ADDRESS_REG2 + pciBaseAddress ), ( (UGL_UINT32)destAddr) >> 16 ); 

    /* program the Width and Height Register */
    height  = UGL_RECT_HEIGHT(*pDestRect); 
    width   = UGL_RECT_WIDTH(*pDestRect);

    uglWriteByte( ( BITBLT_WIDTH_REG0  + pciBaseAddress ), width  - 1  );
    uglWriteByte( ( BITBLT_WIDTH_REG1  + pciBaseAddress ), (width  - 1)>>8  );
    uglWriteByte( ( BITBLT_HEIGHT_REG0 + pciBaseAddress ), height - 1 );
    uglWriteByte( ( BITBLT_HEIGHT_REG1 + pciBaseAddress ), (height - 1)>>8 );

    /* program the Memory Address Offset Register */
    uglWriteByte( ( BITBLT_MEM_OFF0 + pciBaseAddress ), screenStride/2); 
    uglWriteByte( ( BITBLT_MEM_OFF1 + pciBaseAddress ), (screenStride/2)>>8);

    /* color depth select */
    uglWriteByte( ( BITBLT_CTRL1 + pciBaseAddress ), 0x00); // 8bpp

    /* move BitBLT */
    if (overLapType==0x2 || overLapType==0x3)
       uglWriteByte( ( BITBLT_OP + pciBaseAddress ), 0x03); //negative direction  
    else
       uglWriteByte( ( BITBLT_OP + pciBaseAddress ), 0x02); //positive direction  

    uglWriteByte( ( BITBLT_ROP + pciBaseAddress ),   0x0C ); //ROP

    // Wait for blt engine ready
    uglEpsonGpWait(pGenDriver);

    /* Engage the blt engine */
    uglWriteByte( ( BITBLT_CTRL0 + pciBaseAddress ), 0x80); 
}



/*
 *  uglEpson8BitMemoryToFrameColorBitBlit - Source in system memory, destination in video memory. 
 */
UGL_LOCAL void uglEpson8BitMemoryToFrameColorBitBlit 
(
    UGL_UGI_DRIVER * pDriver, 
    UGL_UINT8      * pSourceData,
    UGL_RECT       * pSourceRect,
    UGL_ORD          sourceStride,
    UGL_UINT8      * pDestData, 
    UGL_RECT       * pDestRect,
    UGL_ORD          destStride
)
{
    UGL_UINT16            width;
    UGL_UINT16            height;
    UGL_UINT16            screenStride = pDriver->pMode->width * BYTES_PER_PIXEL;
    UGL_UINT16            nWords, byte100, nTotalWords, nFIFO, phase=0, j;
    UGL_GENERIC_DRIVER  * pGenDriver = (UGL_GENERIC_DRIVER *)pDriver;
    UGL_UINT16          * w16;
    volatile UGL_UINT16 * bltAddress = (UGL_UINT16 *)(pciBaseAddress + 0x100000);
    UGL_UINT16          * sourceAddr = (UGL_UINT16 *)pSourceData; 
    UGL_UINT16          * destAddr   = (UGL_UINT16 *)pDestData;

    uglWriteByte( ( BITBLT_DEST_ADDRESS_REG0 + pciBaseAddress ),   (UGL_UINT32) destAddr         );
    uglWriteByte( ( BITBLT_DEST_ADDRESS_REG1 + pciBaseAddress ), ( (UGL_UINT32) destAddr ) >> 8  ); 
    uglWriteByte( ( BITBLT_DEST_ADDRESS_REG2 + pciBaseAddress ), ( (UGL_UINT32) destAddr ) >> 16 ); 

    phase = (UGL_UINT32)sourceAddr & 1;

    uglWriteByte( ( BITBLT_SRCE_ADDRESS_REG0 + pciBaseAddress ), phase ); 
    uglWriteByte( ( BITBLT_SRCE_ADDRESS_REG1 + pciBaseAddress ), 0 ); 
    uglWriteByte( ( BITBLT_SRCE_ADDRESS_REG2 + pciBaseAddress ), 0 ); 
		
    /* program the Destination Width and Height Register */
    height  = UGL_RECT_HEIGHT(*pDestRect); 
    width   = UGL_RECT_WIDTH(*pDestRect);

    uglWriteByte( ( BITBLT_WIDTH_REG0  + pciBaseAddress ),  width  - 1       );
    uglWriteByte( ( BITBLT_WIDTH_REG1  + pciBaseAddress ), (width  - 1) >> 8 );
    uglWriteByte( ( BITBLT_HEIGHT_REG0 + pciBaseAddress ),  height - 1       );
    uglWriteByte( ( BITBLT_HEIGHT_REG1 + pciBaseAddress ), (height - 1) >> 8 );

    uglWriteByte( ( BITBLT_MEM_OFF0 + pciBaseAddress ),  screenStride/2    ); 
    uglWriteByte( ( BITBLT_MEM_OFF1 + pciBaseAddress ), (screenStride/2)>>8);

    uglWriteByte( ( BITBLT_CTRL1 + pciBaseAddress ), 0x00 ); // 8bpp
    uglWriteByte( ( BITBLT_OP    + pciBaseAddress ), 0x00 ); // write BLT 
    uglWriteByte( ( BITBLT_ROP   + pciBaseAddress ), 0x0C ); // ROP

    nWords = phase + ((width-phase)*BYTES_PER_PIXEL + 1)/2;

    nTotalWords = nWords * height;

    // Wait for blt engine ready
    uglEpsonGpWait(pGenDriver);

    // Engage the blt engine
    uglWriteByte( ( BITBLT_CTRL0 + pciBaseAddress ), 0x80); 

    // Word aligned 
    w16 = (UGL_UINT16 *)( ((UGL_UINT32)sourceAddr & 0xFFFFFFFE) );

    while (nTotalWords > 0)
    {
          // read the FIFO status
          uglReadByte( ( BITBLT_CTRL0 + pciBaseAddress ), byte100);

          if ((byte100 & 0x70) == 0x0)	
	          nFIFO = 16;
          else if ((byte100 & 0x70) == 0x40) 
	          nFIFO = 8;
          else if ((byte100 & 0x70) == 0x60) 
		  nFIFO = 1;
          else if ((byte100 & 0x70) == 0x70)
                  nFIFO = 0;

          for (j = 0; j < nFIFO && nWords > 0; j++, nWords--, nTotalWords--)
              *bltAddress = *w16++;

          if ( nWords == 0 )
          {
          nWords = phase + ((width-phase)*BYTES_PER_PIXEL + 1)/2;
          w16 = w16 + (sourceStride - width)/2;
          }
    }
}



/*
 *  uglEpson8BitBitmapBlt - Hardware BitBLT.
 */
UGL_STATUS uglEpson8BitBitmapBlt
(
    UGL_UGI_DRIVER * devId,
    UGL_DDB_ID       srcDdbId,
    UGL_RECT       * pSourceRect,
    UGL_DDB_ID       destDdbId,
    UGL_POINT      * pDestPoint
)
{

    UGL_GENERIC_DRIVER * pDriver = (UGL_GENERIC_DRIVER *)devId;
    UGL_GC_ID            gc      = pDriver->gc;
    UGL_RECT             clipRect;
    const UGL_RECT     * pRegionRect = UGL_NULL;

    if (srcDdbId == UGL_DEFAULT_ID)
        UGL_RECT_MOVE (*pSourceRect, gc->viewPort.left, gc->viewPort.top);

    if (destDdbId == UGL_DEFAULT_ID)
    {
        if (uglClipListGet (gc, &clipRect, &pRegionRect) != UGL_STATUS_OK)
            return (UGL_STATUS_OK);

        UGL_POINT_MOVE (*pDestPoint, gc->viewPort.left, gc->viewPort.top);
    }

    do
    {
        UGL_GEN_DDB *pSrcDdb  = (UGL_GEN_DDB *)srcDdbId;
        UGL_GEN_DDB *pDstDdb  = (UGL_GEN_DDB *)destDdbId;
        UGL_RECT     srcRect  = *pSourceRect;
        UGL_POINT    dstPoint = *pDestPoint;

        /* Clip the source/destination points */
        if ( UGL_TRUE == uglGenericClipDdbToDdb ( devId, &clipRect,
                                                  ( UGL_BMAP_ID * )&pSrcDdb, 
                                                  &srcRect, 
                                                  ( UGL_BMAP_ID * )&pDstDdb, 
                                                  &dstPoint 
                                                ) 
            )
        {
            UGL_RECT      destRect;

            UGL_UINT8    *pSourceData;
            UGL_UINT8    *pDestData = UGL_NULL;
            UGL_ORD       sourceStride;
            UGL_ORD       destStride;
            int           sourceFirstPixelIndex;
            int           destFirstPixelIndex;
            int           xStart, xEnd, xIncrement;
            int           yStart, yEnd, yIncrement;
            register int  x, y;

            /* Set up source image address and stride */

            if (UGL_DISPLAY_ID == (UGL_DDB_ID)pSrcDdb)
                pSrcDdb = (UGL_GEN_DDB *)pDriver->pDrawPage->pDdb;

            pSourceData = (UGL_UINT8 *)pSrcDdb->image;
            sourceStride = pSrcDdb->stride;

            /* Set up destination image address and stride */
            if (UGL_DISPLAY_ID == (UGL_DDB_ID)pDstDdb)
                pDstDdb = (UGL_GEN_DDB *)pDriver->pDrawPage->pDdb;

            pDestData = (UGL_UINT8 *)pDstDdb->image;
            destStride = pDstDdb->stride;

            /* Compute the destination rectangle */
            destRect.left = dstPoint.x;
            destRect.top  = dstPoint.y;

            UGL_RECT_SIZE_TO (destRect, UGL_RECT_WIDTH(srcRect), 
                              UGL_RECT_HEIGHT(srcRect));

            sourceFirstPixelIndex = (srcRect.top * sourceStride) + 
                                     srcRect.left;

            destFirstPixelIndex   = (destRect.top * destStride) + destRect.left;

            /* Set up to handle overlapping */
            if (pSrcDdb != pDstDdb || srcRect.top != destRect.top ||
                srcRect.left >= destRect.left || 
                srcRect.left + sourceStride < destRect.left)
            {
                /* Different DDBs or source right of destination or source and
		destination don't overlap */
                xStart = 0;
                xEnd = UGL_RECT_WIDTH(destRect);
                xIncrement = 1;
            }
            else
            {
                /* Same DDB and source left of destination and overlapping*/
                xStart = UGL_RECT_WIDTH(destRect) - 1;
                xEnd = -1;
                xIncrement = -1;
            }

            if (pSrcDdb != pDstDdb || srcRect.top >= destRect.top)
            {
                /* Different DDBs or source below destination */
                yStart = srcRect.top;
                yEnd = srcRect.bottom + 1;
                yIncrement = 1;
            }
            else
            {
                /* Same DDB and source above destination */
                yStart = srcRect.bottom;
                yEnd = srcRect.top - 1;
                yIncrement = -1;
                sourceFirstPixelIndex += sourceStride *
                                         (UGL_RECT_HEIGHT(destRect) - 1);
                sourceStride = -sourceStride;
                destFirstPixelIndex += destStride *
                                       (UGL_RECT_HEIGHT(destRect) - 1);
                destStride = -destStride;
            }

            pSourceData = (UGL_UINT8 *)pSourceData + sourceFirstPixelIndex;
            pDestData = (UGL_UINT8 *)pDestData + destFirstPixelIndex;

            /* wait for graphics processor */
	    if ( pDriver->gpBusy == UGL_TRUE )
	       if ( UGL_STATUS_OK != (*pDriver->gpWait) (pDriver) )
		  return( UGL_STATUS_ERROR );

	    if ( pDriver->gpBusy == UGL_TRUE)
               if ( UGL_STATUS_OK != (*pDriver->gpWait) (pDriver) )
		  return(UGL_STATUS_ERROR );

            if ( UGL_DISPLAY_ID == (UGL_DDB *)pSrcDdb && 
		 UGL_DISPLAY_ID == (UGL_DDB *)pDstDdb
               )
               uglEpson8BitFrameToFrameBitBlit( devId, pSourceData, &srcRect,
                                                sourceStride, pDestData, &destRect,
                                                destStride);

	    else if ( ( ( UGL_EPSON_DDB * ) pSrcDdb )->vram == UGL_TRUE &&
		      ( ( UGL_EPSON_DDB * ) pDstDdb )->vram == UGL_TRUE 
                    )
                    uglEpson8BitFrameToFrameBitBlit( devId, pSourceData, &srcRect,
                                                     sourceStride, pDestData, &destRect,
                                                     destStride );

	    else if ( ( ( UGL_EPSON_DDB *)pSrcDdb)->vram == UGL_TRUE &&
		      UGL_DISPLAY_ID == (UGL_DDB *)pDstDdb
                    )
                    uglEpson8BitFrameToFrameBitBlit( devId, pSourceData, &srcRect,
                                                     sourceStride, pDestData, &destRect,
                                                     destStride );

	    else if ( ( ( UGL_EPSON_DDB *)pDstDdb )->vram == UGL_TRUE &&
		      UGL_DISPLAY_ID == (UGL_DDB *)pSrcDdb
                    )
                    uglEpson8BitFrameToFrameBitBlit(devId, pSourceData, &srcRect,
                                             sourceStride, pDestData, &destRect,
                                             destStride);
	    else
                    uglEpson8BitMemoryToFrameColorBitBlit( devId, pSourceData, 
                                                           &srcRect, sourceStride, 
                                                           pDestData, &destRect, 
                                                           destStride
                                                         );
            }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -