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

📄 ude506.c

📁 S1D13506windml下的驱动程序,支持vxworks5.4 支持tornado2.0 windml2.0
💻 C
📖 第 1 页 / 共 3 页
字号:
    uglWriteByte( ( BITBLT_CTRL0 + pciBaseAddress ), 0x80); 
}



/*
 *  uglEpson16BitMemoryToFrameColorBitBlit - Source in system memory, destination in video memory. 
 */
UGL_LOCAL void uglEpson16BitMemoryToFrameColorBitBlit 
(
    UGL_UGI_DRIVER * pDriver, 
    UGL_UINT16     * pSourceData,
    UGL_RECT       * pSourceRect,
    UGL_ORD          sourceStride,
    UGL_UINT16     * 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 ), 0x01 ); // 16bpp
    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;  
          }
    }
}



/*
 *  uglEpson16BitBitmapBlt - Hardware BitBLT.
 */
UGL_STATUS uglEpson16BitBitmapBlt
(
    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;
            int xStart, xEnd, xIncrement;
            int yStart, yEnd, yIncrement;
            register int x, y;
            UGL_UINT16 * pSourceData;
            UGL_UINT16 * pDestData;
            int sourceStride, sourceFirstPixelIndex;
            int destStride, destFirstPixelIndex;

            /* Set up source image address and stride */

            if (UGL_DISPLAY_ID == (UGL_DDB_ID)pSrcDdb)
                pSrcDdb = (UGL_GEN_DDB *)pDriver->pDrawPage->pDdb;
            pSourceData = (UGL_UINT16 *)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_UINT16 *)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 */

                xStart = 0;
                xEnd = UGL_RECT_WIDTH(destRect);
                xIncrement = 1;
                }
            else
                {
                /* Same DDB and source left of destination */

                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_UINT16 *)pSourceData + sourceFirstPixelIndex;
            pDestData = (UGL_UINT16 *)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
               )
               uglEpson16BitFrameToFrameBitBlit( devId, pSourceData, &srcRect,
                                                sourceStride, pDestData, &destRect,
                                                destStride);

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

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

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

        if ( destDdbId != UGL_DEFAULT_ID )
             break;

        } while ( uglClipListGet (gc, &clipRect, &pRegionRect) == UGL_STATUS_OK );

    return (UGL_STATUS_OK);
}




/*
 *  uglEpsonPageDrawSet - Set active drawing page.
 */
UGL_STATUS uglEpsonPageDrawSet
(
    UGL_UGI_DRIVER * pDriver,
    UGL_PAGE       * pPage
)
{

    UGL_GENERIC_DRIVER * pGenDriver = (UGL_GENERIC_DRIVER *)pDriver;

    pGenDriver->pDrawPage = pPage;

    return(UGL_STATUS_OK);
}



/*
 *  uglEpsonPageDrawGet - Get the active drawing page.
 */
UGL_STATUS uglEpsonPageDrawGet
(
    UGL_UGI_DRIVER *  pDriver,
    UGL_PAGE       ** pPage
)
{
    UGL_GENERIC_DRIVER * pGenDriver = (UGL_GENERIC_DRIVER *) pDriver;

    *pPage = pGenDriver->pDrawPage;

    return( UGL_STATUS_OK );
}



/*
 *  uglEpsonPageVisibleSet - Set the active display page.
 */
UGL_STATUS uglEpsonPageVisibleSet
(
    UGL_UGI_DRIVER * pDriver,
    UGL_PAGE       * pPage
)
{
    UGL_GENERIC_DRIVER * pGenDriver = (UGL_GENERIC_DRIVER *) pDriver;
    UGL_UINT32           address;

    address = (UGL_UINT32) ((UGL_GEN_DDB *) pPage->pDdb)->image - 
	      (UGL_UINT32) pGenDriver->fbAddress;

    address >>= 2;

    /* Make sure the Accelerator is not doing anything */
    if ( pGenDriver->gpBusy == UGL_TRUE )
	 if ( UGL_STATUS_OK != (*pGenDriver->gpWait) (pGenDriver) )
	      return( UGL_STATUS_ERROR );

    pGenDriver->pVisiblePage = pPage;

    return( UGL_STATUS_OK );
}



/*
 *  uglEpsonSetRegs - Initialize registers.
 */
UGL_LOCAL void uglEpsonSetRegs(void)
{
   UGL_UINT16 i = 0;

   /* set register data to target display device */ 
   while( epsonModeTable[0].InitEpsonRegs[i][0] != 0xFFFF )
   {
       uglWriteByte( (UGL_UINT8 *) ( epsonModeTable[0].InitEpsonRegs[i][0] + pciBaseAddress ),
                     epsonModeTable[0].InitEpsonRegs[i][1] );
       i++;
   } 

   /* prevent showing garbage on display, clear the screen */
   uglWriteByte( (UGL_UINT8 *) (LUT_MODE_REG + pciBaseAddress ), 0x0); 
   uglWriteByte( (UGL_UINT8 *) ( LUT_ADDRESS_REG + pciBaseAddress ), 0x0 );

   for (i = 0; i < 256; ++i)
   {
       uglWriteByte( (UGL_UINT8 *) ( LUT_DATA_REG + pciBaseAddress ), 0x0 );
       uglWriteByte( (UGL_UINT8 *) ( LUT_DATA_REG + pciBaseAddress ), 0x0 );
       uglWriteByte( (UGL_UINT8 *) ( LUT_DATA_REG + pciBaseAddress ), 0x0 );
   } 
}




/*
* uglEpson16BitModeSet
*/
UGL_STATUS uglEpson16BitModeSet
(
    UGL_UGI_DRIVER * pDriver, 
    UGL_MODE       * pMode
)
{
    UGL_GENERIC_DRIVER * pGenDriver = (UGL_GENERIC_DRIVER *)pDriver;
    UGL_INT32            index;
    UGL_BOOL             allocate;

⌨️ 快捷键说明

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