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

📄 ude506ind8.c

📁 atmel9200 vxworks bsp
💻 C
📖 第 1 页 / 共 3 页
字号:
/* ude506Ind8.c - Epson graphics driver for 8 bit pseudo color *//* Copyright 2000 - 2001 Wind River Systems, Inc. All Rights Reserved *//* Copyright (c) 2000, 2001 Epson Research and Development, Inc. All Rights Reserved *//*modification history--------------------01h,20sep02,gav  Fix to SPR #8172701g,12aug02,msr  Added support for sorted regions (SPR #75481).01f,01aug02,rfm  Removed Epson software cursor01e,06jun02,gav  Port to HAL API01d,13mar02,jlb  Fixed compile warnings01c,04jan02,jlb  Disable bitblt acceleration  01b,27nov01,jlb  Enable BSP API support01a,10nov01,jlb  written - based on work from Epson Research and Development, Inc.*//* DESCRIPTION This device driver, based on work from Epson, implements an 8 bit pseudo color device driver for the Epson S13506. *//* This file has configurable options, so include the config file */#include <ugl/driver/graphics/epson/s13506Cfg.h>/* Other includes */#include <string.h>#include <ugl/driver/graphics/common/udcHwAbsLayer.h>#include <drv/pci/pciConfigLib.h>#include <ugl/ext/common/uglext.h>#include <ugl/driver/ext/jpeg/udgenjpg.h>#include <ugl/uglugi.h>#include <ugl/uglmem.h>#include <ugl/driver/graphics/generic/udgen8.h>/* Acclerated bitmaps are not fully working */#undef EPSON_ACCEL_BITMAP/* Mode configurations */UGL_LOCAL ModeTable epsonModeTable[] ={   /* modexxx.dat files are generated  by 13506cfg.exe */   /* 13506cfg.exe is available at www.erd.epson.com   */   #include "mode640x480x60.dat"   #include "mode800x600x60.dat"};UGL_LOCAL UINT32 pciBaseAddress;/* Forward declarations */UGL_LOCAL UGL_STATUS      uglEpson8BitDevDestroy   ( UGL_DEVICE_ID devId );UGL_LOCAL UGL_STATUS      uglEpson8BitInfo         ( UGL_DEVICE_ID devId, UGL_INFO_REQ infoRequest,                                            void *info );UGL_LOCAL UGL_STATUS      uglEpson8BitModeAvailGet ( UGL_UGI_DRIVER * pDriver, 				           UGL_UINT32  * pNumModes, 				           const UGL_MODE ** pModeArray );UGL_LOCAL UGL_STATUS      uglEpson8BitModeSet      ( UGL_UGI_DRIVER * pDriver, UGL_MODE * pMode );UGL_LOCAL UGL_STATUS      uglEpson8BitClutSet      ( UGL_DEVICE_ID pDriver, UGL_ORD startIndex,                                            UGL_ARGB * pColors, UGL_SIZE numColors );UGL_LOCAL UGL_STATUS      uglEpson8BitClutGet      ( UGL_DEVICE_ID pDriver, UGL_ORD startIndex,                                            UGL_ARGB * pColors, UGL_SIZE numColors );UGL_LOCAL UGL_STATUS      uglEpsonGpWait           ( UGL_GENERIC_DRIVER * pDriver );UGL_LOCAL UGL_STATUS      uglEpsonCreateModes      ( UGL_UGI_DRIVER * pDriver);#ifdef EPSON_ACCEL_BITMAPUGL_LOCAL UGL_DDB_ID      uglEpson8BitBitmapCreate ( UGL_DEVICE_ID devId, UGL_DIB  * pDib,                                            UGL_DIB_CREATE_MODE createMode,                                           UGL_UINT32 initValue, UGL_MEM_POOL_ID poolId );UGL_LOCAL UGL_STATUS      uglEpson8BitBitmapBlt    ( UGL_DEVICE_ID devId, UGL_DDB_ID srcDdbId,                                           UGL_RECT * pSourceRect, UGL_DDB_ID destDdbId,                                           UGL_POINT * pDestPoint );#endif /* EPSON_ACCEL_BITMAP *//******************************************************************************* uglEpson13506_8BitDevCreate - create the Epson 13506 driver for 8 Bit *           * This routine creates a WindML graphics device for the Epson 13506 when * operated in the 8 bit pseudo color mode.   ** RETURNS: created device control structure when device was successfully*   created; otherwise UGL_NULL** ERRNO: N/A** SEE ALSO: uglEpson13506_8BitDevCreateDestroy()*/UGL_UGI_DRIVER * uglEpson13506_8BitDevCreate    (    UGL_UINT32      instance,    UGL_UINT32      notUsed0,	        /* intLevel */    UGL_UINT32      notUsed1		/* intVector */    )    {    UGL_EPSON_DRIVER   * pEpsonDriver;    UGL_GENERIC_DRIVER * pGenDriver;    UGL_UGI_DRIVER     * pDriver = UGL_NULL;    UINT32 virtAdrs;    int size = 0;    int arg;    pEpsonDriver = (UGL_EPSON_DRIVER   *)uglSharedMemAlloc(sizeof(UGL_EPSON_DRIVER),UGL_MEM_CLEAR);    if (UGL_NULL != pEpsonDriver)        {        pGenDriver = (UGL_GENERIC_DRIVER *)pEpsonDriver;        pDriver    = (UGL_UGI_DRIVER *)pGenDriver;        if ((pGenDriver->pWmlDevice = uglGraphicsDevOpen(VENDOR_PCI_EPSON, DEVICE_ID_EPSON_13XXX, 0)) == UGL_NULL)	        {            uglSharedMemFree((char *)pEpsonDriver);            return (UGL_NULL);	        }        /* Save the base addrewss */       /* pciBaseAddress =  (UINT32)pGenDriver->pWmlDevice->pPhysBaseAdrs0; */        pciBaseAddress = 0x30000000 ; /* bank2 */        /* Enable I/O and memory cycles */        arg = WINDML_IO_ENABLE | WINDML_MEM_ENABLE;    uglGraphicsDevControl(pGenDriver->pWmlDevice,WINDML_ACCESS_MODE_SET, &arg, sizeof(int));   /* if (uglGraphicsDevAccessCheck (pGenDriver->pWmlDevice,                               WINDML_DEVICE_BASE_ADRS_0,                                 &size, UGL_GRAPHICS_NAME) == UGL_STATUS_ERROR)         {        uglSharedMemFree((char *)pEpsonDriver);        return (UGL_NULL);        } */    /* Map physical memory to virtual */    uglGraphicsDevMap (pGenDriver->pWmlDevice,                        (UINT32) pGenDriver->pWmlDevice->pPhysBaseAdrs0,                        size, &virtAdrs); 	/* Initialize the driver (mandatory) */        uglUgiDevInit(pDriver);	/* Set Standard Driver API Functions */#ifdef EPSON_ACCEL_BITMAP        pDriver->bitmapCreate             = uglEpson8BitBitmapCreate;#else        pDriver->bitmapCreate             = uglGeneric8BitBitmapCreate;#endif /* EPSON_ACCEL_BITMAP */	pDriver->modeSet	          = uglEpson8BitModeSet;	pDriver->clutSet	          = uglEpson8BitClutSet;	pDriver->clutGet                  = uglEpson8BitClutGet;	pDriver->info                     = uglEpson8BitInfo; 	pDriver->modeAvailGet             = uglEpson8BitModeAvailGet;        pDriver->destroy                  = uglEpson8BitDevDestroy;	pDriver->cursorHide               = uglGenericCursorHide;	pDriver->cursorMove               = uglGenericCursorMove;	pDriver->cursorShow               = uglGenericCursorShow;        pDriver->bitmapDestroy	          = uglGeneric8BitBitmapDestroy;        pDriver->bitmapBlt                = uglGeneric8BitBitmapBlt;        pDriver->bitmapRead	          = uglGeneric8BitBitmapRead;        pDriver->bitmapWrite	          = uglGeneric8BitBitmapWrite;        pDriver->bitmapStretchBlt         = uglGeneric8BitBitmapStretchBlt;        pDriver->monoBitmapBlt            = uglGeneric8BitMonoBitmapBlt;        pDriver->monoBitmapCreate         = uglGeneric8BitMonoBitmapCreate;        pDriver->monoBitmapDestroy        = uglGeneric8BitMonoBitmapDestroy;        pDriver->monoBitmapRead           = uglGeneric8BitMonoBitmapRead;        pDriver->monoBitmapWrite          = uglGeneric8BitMonoBitmapWrite;        pDriver->monoBitmapStretchBlt	  = uglGeneric8BitMonoBitmapStretchBlt;        pDriver->transBitmapBlt           = uglGeneric8BitTransBitmapBlt;        pDriver->transBitmapCreate        = uglGenericTransBitmapCreate;        pDriver->transBitmapDestroy       = uglGenericTransBitmapDestroy;        pDriver->transBitmapRead	  = uglGenericTransBitmapRead;        pDriver->transBitmapWrite	  = uglGenericTransBitmapWrite;        pDriver->transBitmapStretchBlt	  = uglGenericTransBitmapStretchBlt;	pDriver->transBitmapCreateFromDdb = uglGenericTransBitmapCreateFromDdb;	pDriver->colorAlloc               = uglGenericColorAllocIndexed;	pDriver->colorFree                = uglGenericColorFreeIndexed;	pDriver->colorConvert             = uglGeneric8BitColorConvert;	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                 = uglGeneric8BitPixelGet;        pDriver->pixelSet                 = uglGeneric8BitPixelSet;	pDriver->polygon                  = uglGenericPolygon;	pDriver->rectangle                = uglGenericRectangle;	pDriver->memPoolCreate            = uglGenericMemPoolCreate;	pDriver->memPoolDestroy           = uglGenericMemPoolDestroy;#ifdef INCLUDE_UGL_DOUBLE_BUFFERING	pDriver->pageCopy                 = uglEpsonPageCopy;	pDriver->pageCreate               = uglEpsonPageCreate;        pDriver->pageDestroy              = uglEpsonPageDestroy;	pDriver->pageDrawGet              = uglEpsonPageDrawGet;	pDriver->pageDrawSet              = uglEpsonPageDrawSet;	pDriver->pageVisibleGet           = uglEpsonPageVisibleGet;	pDriver->pageVisibleSet           = uglEpsonPageVisibleSet;#endif /* INCLUDE_UGL_DOUBLE_BUFFERING */	/* Set Generic Driver Functions */        pGenDriver->bresenhamLine         = uglGeneric8BitBresenhamLine;        pGenDriver->fbPixelGet            = uglGeneric8BitFbPixelGet;        pGenDriver->fbPixelSet            = uglGeneric8BitFbPixelSet; 	pGenDriver->fill                  = uglGenericFill;	pGenDriver->hLine	          = uglGeneric8BitHLine;	pGenDriver->rectFill              = uglGenericRectFill;	pGenDriver->vLine                 = uglGeneric8BitVLine;	pGenDriver->gpWait                = uglEpsonGpWait;        uglGenericClutCreate (pGenDriver, 256);        uglEpsonCreateModes(pDriver);        }    return (pDriver);    }/******************************************************************************* uglEpson8BitDevDestroy - shut down the Epson device driver** This routine shuts down the Epson driver.  It is called, via the * UGI device structure, by the 2D layer when the last UGL application * terminates.** RETURNS: UGL_STATUS_OK when device was successfully shut down;*       otherwise UGL_STATUS_ERROR** ERRNO: N/A** SEE ALSO: uglEpson8BitDevDestroy()**/UGL_LOCAL UGL_STATUS uglEpson8BitDevDestroy    (    UGL_UGI_DRIVER * pDriver    )    {    UGL_GENERIC_DRIVER * pGenDriver = (UGL_GENERIC_DRIVER *)pDriver;    UGL_EPSON_DRIVER   * pEpsonDriver = (UGL_EPSON_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 );	uglGenericClutDestroy( pGenDriver );	/* Deinitialize the driver (mandatory) */	uglUgiDevDeinit(pDriver);	UGL_FREE(pDriver->pPageZero->pDdb);	UGL_FREE(pDriver->pPageZero);        uglGraphicsDevClose(pGenDriver->pWmlDevice);        /* Free the driver */        UGL_FREE (pEpsonDriver->pModes);        uglSharedMemFree((char *)pDriver);	return (UGL_STATUS_OK);        }    return ( UGL_STATUS_ERROR );    }/******************************************************************************* uglEpson8BitInfo - Epson device driver info control** This routine provides information setting/getting for the Epson device* driver. The request specified by <infoRequest> is performed.  ** RETURNS: UGL_STATUS_OK when requested function was completed*   satisfactory; otherwise UGL_STATUS_ERROR** ERRNO: N/A***/UGL_LOCAL UGL_STATUS uglEpson8BitInfo    (    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       = pDriver->pMode->width;	    fbInfo->height      = pDriver->pMode->height;	    fbInfo->fbAddrs     = pGenDriver->fbAddress;	    fbInfo->dsMemAmount = 0;	    fbInfo->flags       = 0;	    }	    break;	case UGL_COLOR_INFO_REQ:	    {	    UGL_COLOR_INFO * colorInfo = (UGL_COLOR_INFO *)info;	    colorInfo->cmodel          = UGL_CMODEL_INDEXED;	    colorInfo->cspace          = UGL_CSPACE_RGB;	    colorInfo->depth           = pDriver->pMode->colorDepth;	    colorInfo->clutSize        = CLUT_SIZE;	    colorInfo->flags           = UGL_CLUT_WRITE;	    }	    break;	case UGL_MODE_INFO_REQ:	    {	    UGL_MODE_INFO * modeInfo = (UGL_MODE_INFO *)info;            modeInfo->width = pDriver->pMode->width;            modeInfo->height = pDriver->pMode->height;            modeInfo->colorDepth = pDriver->pMode->colorDepth;            modeInfo->clutSize = 256;            modeInfo->colorModel = UGL_INDEXED_8;            modeInfo->colorFormat = 0;            modeInfo->fbAddress = pGenDriver->fbAddress;            modeInfo->displayMemAvail = 0;            modeInfo->flags = 0;	    }	    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 - Epson device driver graphics processor wait** Wait for the graphics processor to become idle  ** RETURNS: UGL_STATUS_OK when requested function was completed*   satisfactory; otherwise UGL_STATUS_ERROR**/UGL_LOCAL 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 );    }/******************************************************************************* uglEpson8BitClutGet - get the color lookup table entry** Obtain an entry in the clut  ***/UGL_LOCAL UGL_STATUS uglEpson8BitClutGet    (    UGL_DEVICE_ID   pDriver,     UGL_ORD         startIndex,    UGL_ARGB      * pColors,    UGL_SIZE        numColors    )

⌨️ 快捷键说明

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