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

📄 ude506.c

📁 S1D13506windml下的驱动程序,支持vxworks5.4 支持tornado2.0 windml2.0
💻 C
📖 第 1 页 / 共 3 页
字号:
/***************************************************************************
 *                                                                         * 
 *  UDE506.C -- S1D13506 16 bpp WindML display driver.                     * 
 *  Copyright (c) 2000, 2001 Epson Research and Development, Inc.          *
 *  All Rights Reserved                                                    *
 *                                                                         *
 *  THIS SOURCE CODE IS FOR TEST ONLY.                                     *
 *                                                                         *
 ***************************************************************************/

/* includes */
#include "udepson.h"


/*
 * uglEpson16BitDevCreate
 */
UGL_UGI_DRIVER * uglEpson16BitDevCreate
(
    UGL_ORD    instance,
    UGL_UINT32 notUsed0,	/* intLevel */
    UGL_UINT32 notUsed1		/* intVector */
)
{
    UGL_EPSON_DRIVER   * pEpsonDriver;
    UGL_GENERIC_DRIVER * pGenDriver;
    UGL_UGI_DRIVER     * pDriver = UGL_NULL;
    UGL_STATUS           status  = UGL_STATUS_ERROR;
    UGL_UINT16           pciBus;
    UGL_UINT16           pciDevice;
    UGL_UINT16           pciFunc;

    pEpsonDriver = (UGL_EPSON_DRIVER   *)UGL_CALLOC(1, sizeof(UGL_EPSON_DRIVER ));

    if (UGL_NULL != pEpsonDriver)
    {

	/* Determine if chip is supported and present */
	if ( pciFindDevice ( UGL_EPSON_PCI_VENDOR_ID, UGL_EPSON_PCI_DEV_ID, 
			     instance, &pciBus, &pciDevice, &pciFunc) == OK 
           )
	{
	    pEpsonDriver->chipType = UGL_EPSON_PCI_DEV_ID;
	    pEpsonDriver->pciBus = pciBus;
	    pEpsonDriver->pciDevice = pciDevice;
	    pEpsonDriver->pciFunc = pciFunc;
	    pEpsonDriver->busType = UGL_EPSON_PCI;

	    status = UGL_STATUS_OK;
	}
	else
	{
	    status = UGL_STATUS_ERROR;
	}

	if ( status == UGL_STATUS_ERROR )
        {
	    UGL_FREE( pEpsonDriver );
	    return( UGL_NULL );
        }


	pGenDriver = (UGL_GENERIC_DRIVER *) pEpsonDriver;
        pDriver    = (UGL_UGI_DRIVER *)     pGenDriver;


	/* Initialize the driver (mandatory) */
        uglUgiDevInit(pDriver);
        uglEpson16BitModeSet( pDriver, pDevModes );

	/* Set Standard Driver API Functions */
        pDriver->bitmapCreate		= uglGeneric16BitBitmapCreate;
	pDriver->modeSet	          = uglEpson16BitModeSet;
	pDriver->info                     = uglEpson16BitInfo;
 	pDriver->modeAvailGet             = uglEpson16BitModeAvailGet;
        pDriver->destroy                  = uglEpson16BitDevDestroy;
	pDriver->cursorShow               = uglEpsonCursorShow;
	pDriver->cursorHide               = uglEpsonCursorHide;
	pDriver->cursorMove               = uglEpsonCursorMove;
        if ( ((UGL_UINT32)pEpsonModeTable->Flags) & mfHWBLT )
        pDriver->bitmapBlt                = uglEpson16BitBitmapBlt;
        else
        pDriver->bitmapBlt                = uglGeneric16BitBitmapBlt;
        pDriver->bitmapDestroy	          = uglGeneric16BitBitmapDestroy;
        pDriver->bitmapRead	          = uglGeneric16BitBitmapRead;
        pDriver->bitmapWrite	          = uglGeneric16BitBitmapWrite;
        pDriver->bitmapStretchBlt         = uglGeneric16BitBitmapStretchBlt;
        pDriver->monoBitmapBlt            = uglGeneric16BitMonoBitmapBlt;
        pDriver->monoBitmapCreate         = uglGeneric16BitMonoBitmapCreate;
        pDriver->monoBitmapDestroy        = uglGeneric16BitMonoBitmapDestroy;
        pDriver->monoBitmapRead           = uglGeneric16BitMonoBitmapRead;
        pDriver->monoBitmapWrite          = uglGeneric16BitMonoBitmapWrite;
        pDriver->monoBitmapStretchBlt     = uglGeneric16BitMonoBitmapStretchBlt;
        pDriver->transBitmapBlt           = uglGeneric16BitTransBitmapBlt;
        pDriver->transBitmapCreate        = uglGenericTransBitmapCreate;
        pDriver->transBitmapDestroy       = uglGenericTransBitmapDestroy;
        pDriver->transBitmapRead	  = uglGenericTransBitmapRead;
        pDriver->transBitmapWrite	  = uglGenericTransBitmapWrite;
        pDriver->transBitmapStretchBlt    = uglGenericTransBitmapStretchBlt;
	pDriver->transBitmapCreateFromDdb = uglGenericTransBitmapCreateFromDdb;
	pDriver->colorAlloc		  = uglGenericColorAllocDirect;
	pDriver->colorFree		  = UGL_NULL;
        pDriver->clutSet		  = UGL_NULL;
	pDriver->clutGet		  = UGL_NULL;
	pDriver->colorConvert             = uglGeneric16BitColorConvert;
	pDriver->cursorBitmapCreate       = uglGenericCursorBitmapCreate;
	pDriver->cursorBitmapDestroy      = uglGenericCursorBitmapDestroy;
	pDriver->cursorInit               = uglGenericCursorInit;
	pDriver->cursorDeinit             = uglGenericCursorDeinit;
	pDriver->cursorImageGet           = uglGenericCursorImageGet;
	pDriver->cursorImageSet           = uglGenericCursorImageSet;
	pDriver->cursorPositionGet        = uglGenericCursorPositionGet;
	pDriver->cursorOff                = uglGenericCursorOff;
	pDriver->cursorOn                 = uglGenericCursorOn;
	pDriver->ellipse                  = uglGenericEllipse;
	pDriver->gcCopy                   = uglGenericGcCopy;
	pDriver->gcCreate                 = uglGenericGcCreate;
	pDriver->gcDestroy                = uglGenericGcDestroy;
	pDriver->gcSet                    = uglGenericGcSet;
	pDriver->line                     = uglGenericLine;
        pDriver->pixelGet                 = uglGeneric16BitPixelGet;
        pDriver->pixelSet                 = uglGeneric16BitPixelSet;
	pDriver->polygon                  = uglGenericPolygon;
	pDriver->rectangle                = uglGenericRectangle;
	pDriver->memPoolCreate            = uglGenericMemPoolCreate;
	pDriver->memPoolDestroy           = uglGenericMemPoolDestroy;
#ifdef INCLUDE_UGL_DOUBLE_BUFFERING
	pDriver->pageCopy                 = uglGenericPageCopy;
	pDriver->pageCreate               = uglGenericPageCreate;
        pDriver->pageDestroy              = uglGenericPageDestroy;
	pDriver->pageDrawGet              = uglGenericPageDrawGet;
	pDriver->pageDrawSet              = uglEpsonPageDrawSet;
	pDriver->pageVisibleGet           = uglGenericPageVisibleGet;
	pDriver->pageVisibleSet           = uglGenericPageVisibleSet;
#endif /* INCLUDE_UGL_DOUBLE_BUFFERING */

	/* Set Generic Driver Functions */
        pGenDriver->bresenhamLine         = uglGeneric16BitBresenhamLine;
        pGenDriver->fbPixelGet            = uglGeneric16BitFbPixelGet;
        pGenDriver->fbPixelSet            = uglGeneric16BitFbPixelSet;
 	pGenDriver->fill                  = uglGenericFill;
	pGenDriver->hLine	          = uglGeneric16BitHLine;
	pGenDriver->rectFill              = uglGenericRectFill;
	pGenDriver->vLine                 = uglGeneric16BitVLine;
	pGenDriver->gpWait                = uglEpsonGpWait;
    }

    uglEpsonDisplayBuildNum(szVersion);

    return (pDriver);
}



/*
 *  uglEpsonDisplayBuildNum - show build number 
 */
UGL_LOCAL void uglEpsonDisplayBuildNum ( const char * szVersion )
{
    UGL_EPSON_BUILD   epsonBuild;
    char            * version;
    char              temp[5];

    epsonBuild.first_num   = 1;

    strncpy ( temp, szVersion+11, 5); 

    if ( ( version = (char *) strrchr(temp, '$')) != NULL )
    {
       version[0] = 0; 
       strncpy ( epsonBuild.second_num, temp, 5); 
    }

   printf( "\nEPSON S1D13506 16BPP WindML 2.0 Display Driver: Build %d.%d%s \n",epsonBuild.first_num, 
             buildNum, epsonBuild.second_num);
}



/*
 *  uglEpson16BitDevDestroy - Destroy instances of display drivers.
 */
UGL_STATUS uglEpson16BitDevDestroy
(
    UGL_UGI_DRIVER * pDriver
)
{
    UGL_GENERIC_DRIVER * pGenDriver = (UGL_GENERIC_DRIVER *)pDriver;

    if ( pDriver )
    {
	/* Clear the screen */
	memset( pGenDriver->fbAddress, 0x0, pDriver->pMode->width * 
	        pDriver->pMode->height * (pDriver->pMode->colorDepth / 8) );
	/* Delete any extensions */
	uglGenExtAllDelete( pDriver );

	/* Deinitialize the driver (mandatory) */
	uglUgiDevDeinit(pDriver);
	UGL_FREE(pDriver->pPageZero->pDdb);
	UGL_FREE(pDriver->pPageZero);

	/* Free the driver */
	UGL_FREE(pDriver);

	return (UGL_STATUS_OK);
    }

    return ( UGL_STATUS_ERROR );

}



/*
 *  uglEpson16BitInfo - Retrieve information about the graphics stack and drivers.
 */
UGL_STATUS uglEpson16BitInfo
(
    UGL_UGI_DRIVER * pDriver,
    UGL_INFO_REQ     infoRequest,
    void           * info
)
{
    UGL_GENERIC_DRIVER *pGenDriver = (UGL_GENERIC_DRIVER *) pDriver;

    if ( pDriver->pMode == UGL_NULL ) return( UGL_STATUS_ERROR );

    switch (infoRequest)
    {
	case UGL_FB_INFO_REQ:
	{
	    UGL_FB_INFO *fbInfo = (UGL_FB_INFO *)info;
	    fbInfo->width       = pEpsonModeTable->Width;
	    fbInfo->height      = pEpsonModeTable->Height;
	    fbInfo->fbAddrs     = pGenDriver->fbAddress;
	    fbInfo->dsMemAmount = 0;
	    fbInfo->flags       = UGL_FB_PAGING_ENABLED;
	}
	break;

	case UGL_COLOR_INFO_REQ:
	{
	    UGL_COLOR_INFO *colorInfo = (UGL_COLOR_INFO *)info;
	    colorInfo->cmodel         = UGL_CMODEL_DIRECT;
	    colorInfo->cspace         = UGL_CSPACE_RGB;
	    colorInfo->depth          = pEpsonModeTable->Bpp;
	    colorInfo->clutSize       = 0;
	    colorInfo->flags          = 0;
	}
	break;

	case UGL_MODE_INFO_REQ:
	    {
	    UGL_MODE_INFO * modeInfo = (UGL_MODE_INFO *)info;
            modeInfo->width = pEpsonModeTable->Width;
            modeInfo->height = pEpsonModeTable->Height;
            modeInfo->colorDepth = pEpsonModeTable->Bpp;
            modeInfo->clutSize = 0;
            modeInfo->colorModel = UGL_DIRECT;
            modeInfo->colorFormat = UGL_RGB565;
            modeInfo->fbAddress = pGenDriver->fbAddress;
            modeInfo->displayMemAvail = 0;
	    modeInfo->flags = UGL_MODE_PAGING_ENABLED;
	    }
	    break;

	case UGL_EXT_INFO_REQ:
	    {

            #ifdef INCLUDE_UGL_JPEG
	    UGL_EXT_INFO * extInfo = (UGL_EXT_INFO *)info;
	    int version;
	    if (strcmp(extInfo->name, UGL_EXT_JPEG_NAME) == 0)
		{
		extInfo->pExt = (void *)uglGenJpegInit (
			       pDriver, &version);
		extInfo->version = version;
		}
	    else
            #endif /* INCLUDE_UGL_JPEG */

		return (UGL_STATUS_ERROR);
	    }
	    break;

	default:
	    return( UGL_STATUS_ERROR );
    }

    return( UGL_STATUS_OK );
}



/*
 *  uglEpsonGpWait - Wait for BitBLT to complete.
 */
UGL_STATUS uglEpsonGpWait
(
    UGL_GENERIC_DRIVER * pDriver
)
{
    UGL_UINT8  regData = 0;

    while (1)
    {
      regData = *(volatile unsigned short *) ( BITBLT_CTRL0 + pciBaseAddress );

      if ( 0 == (regData & 0x80) )
         break;
    }

    pDriver->gpBusy = UGL_FALSE;

    return( UGL_STATUS_OK );
}



/*
 * uglEpson16BitFrameToFrameBitBlit - Both source and destination are in video memory.
 */
UGL_LOCAL void uglEpson16BitFrameToFrameBitBlit 
(
    UGL_UGI_DRIVER * pDriver, 
    UGL_UINT16     * pSourceData,
    UGL_RECT       * pSourceRect,
    UGL_ORD          sourceStride,
    UGL_UINT16     * 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(*pSourceRect); 
    width  = UGL_RECT_WIDTH(*pSourceRect);

    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 ), 0x01); //16bpp

    /* 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 */

⌨️ 快捷键说明

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