📄 lq080v3dg01ini.c
字号:
/* LQ080V3DG01ini.c -- 16 bit driver initialization*/
#include <stdlib.h>
#include <string.h>
#include <ugl/ugl.h>
#include <ugl/uglmem.h>
#include <ugl/sysWindML.h>
#include <ugl/driver/graphics/MagicARM2410/LcdCtrl.h>
#include <ugl/driver/graphics/MagicARM2410/LQ080V3DG01.h>
UGL_MODE uglLQ16BitModes[] =
{
/* 640, 480, 16Bit Color */
{640, 480, 16, 60, UGL_MODE_FLAT_PANEL, UGL_MODE_DIRECT_COLOR},
};
UGL_INT32 numLQ16BitElements = NELEMENTS(uglLQ16BitModes);
/**************************************************************************
*
* uglLQ16BitModeSet
*
*/
UGL_STATUS uglLQ16BitModeSet
(
UGL_UGI_DRIVER * pDriver,
UGL_MODE * pMode
)
{
UGL_GENERIC_DRIVER * pGenDriver = (UGL_GENERIC_DRIVER *)pDriver;
UGL_LQ_DRIVER * pCTDriver = (UGL_LQ_DRIVER *)pDriver;
UGL_UINT32 videoMemSize;
void * videoMemAddress;
void * address;
UGL_UINT32 saveValue;
UGL_INT32 index;
UGL_BOOL allocate;
UGL_LQ_DDB *pDdb;
UGL_UINT8 byteValue;
int dsplySize;
void* dsplyBuffer;
/* First time through, pMode will be NULL */
if (pDriver->pMode == UGL_NULL)
{
allocate = UGL_TRUE;
}
else
allocate = UGL_FALSE;
index = uglGenericModeFind(uglLQ16BitModes, pMode, numLQ16BitElements);
if (index > -1)
{
pDriver->pMode = &uglLQ16BitModes[index];
}
else
return(UGL_STATUS_ERROR);
/* Disable Display */
/* Enaable Display */
#if 0
/* Frame buffer address is set up in udct16.c */
/* Get the frame buffer address */
UGL_CT_OUT_BYTE(0x3D6, 0x06);
UGL_CT_IN_BYTE(0x3D7, byteValue);
pGenDriver->fbAddress = (unsigned char *)(((UGL_UINT32)byteValue) << 24);
#ifdef UGL_BIG_ENDIAN
pGenDriver->fbAddress += 0x800000;
#endif
#endif
/* Create pageZero (mandatory) */
if(allocate == UGL_TRUE)
{
pDriver->pPageZero = (UGL_PAGE *)UGL_CALLOC(1, sizeof(UGL_PAGE));
pDdb = (UGL_LQ_DDB *)UGL_CALLOC(1, sizeof(UGL_LQ_DDB));
pDriver->pPageZero->pDdb = (UGL_DDB *)pDdb;
}
pDriver->pPageZero->pDdb->height = pDriver->pMode->height;
pDriver->pPageZero->pDdb->width = pDriver->pMode->width;
pDriver->pPageZero->pDdb->type = UGL_DDB_TYPE;
((UGL_GEN_DDB *)pDriver->pPageZero->pDdb)->stride = pDriver->pMode->width;
((UGL_GEN_DDB *)pDriver->pPageZero->pDdb)->colorDepth =
pDriver->pMode->colorDepth;
((UGL_LQ_DDB *)pDriver->pPageZero->pDdb)->vram = UGL_TRUE;
((UGL_GEN_DDB *)pDriver->pPageZero->pDdb)->image = pGenDriver->fbAddress;
pGenDriver->pVisiblePage = pDriver->pPageZero;
pGenDriver->pDrawPage = pDriver->pPageZero;
/*--------------------------------------------------------------------*/
#if 0
/* Determine the size of video memory */
dsplyBuffer = malloc (LCDFBSIZE);
memset(dsplyBuffer, 0, LCDFBSIZE);
if(dsplyBuffer == NULL)
{
printf("cacheDmaMalloc error !\n");
return(0);
}
*(volatile UGL_UINT32 *)pGenDriver->fbAddress = dsplyBuffer;
#endif
lcd_ctrl_init(pGenDriver->fbAddress);
pGenDriver->videoMemPoolId = UGL_NULL;
#if 0
/* Determine the size of video memory */
/* Assumes video memory wraps back to the beginning */
*(volatile UGL_UINT32 *)pGenDriver->fbAddress = 0xA5A5B4B4;
address = pGenDriver->fbAddress;
while(*(volatile UGL_UINT32 *)pGenDriver->fbAddress == 0xA5A5B4B4)
{
/* Increment by 1 meg each time. (assumes vram only comes
in 1 meg increments) */
address += 0x100000;
/* Save value just in case we have to write it back.... */
saveValue = *(volatile UGL_UINT32 *)address;
*(volatile UGL_UINT32 *)address = 0xAAAA5555;
if(*(volatile UGL_UINT32 *)address != 0xAAAA5555)
{
/* Must be a register of some kind, time to
exit. Write the value back to the register
and hope it doesn't have sticky bits that will
now be corrupt when we write it back. */
*(volatile UGL_UINT32 *)address = saveValue;
break;
}
}
/* Create a memory pool with the unused portion of video memory */
videoMemAddress = (void *) ((UGL_UINT32)pGenDriver->fbAddress +
pDriver->pMode->width * pDriver->pMode->height *
(pDriver->pMode->colorDepth / 8));
videoMemSize = (UGL_UINT32)address - (UGL_UINT32)pGenDriver->fbAddress;
if(videoMemSize > ((pDriver->pMode->width * pDriver->pMode->height) * 2))
{
pGenDriver->videoMemPoolId = uglMemPoolCreate(videoMemAddress,
videoMemSize -
((pDriver->pMode->width *
pDriver->pMode->height) *
(pDriver->pMode->colorDepth / 8)));
}
else
pGenDriver->videoMemPoolId = UGL_NULL;
#endif
/*--------------------------------------------------------------------*/
/* Make sure the graphics processor is ready to go*/
uglLQgpWait(pGenDriver);
/* Mark the graphics processor as not being busy */
pGenDriver->gpBusy = UGL_FALSE;
/* Clear the screen */
memset(pGenDriver->fbAddress, 0x0, pDriver->pMode->width *
pDriver->pMode->height * (pDriver->pMode->colorDepth / 8));
return(UGL_STATUS_OK);
}
/**************************************************************************
*
* uglCT16BitModeAvailGet
*
*/
UGL_STATUS uglLQ16BitModeAvailGet
(
UGL_UGI_DRIVER * pDriver,
UGL_UINT32 * pNumModes,
const UGL_MODE ** pModeArray
)
{
*pModeArray = uglLQ16BitModes;
*pNumModes = numLQ16BitElements;
return(UGL_STATUS_OK);
}
/**************************************************************************
*
* uglLQ16BitMultimediaInit
*
*/
UGL_LOCAL void uglLQ16BitMultimediaInit
(
UGL_UGI_DRIVER * pDriver
)
{
}
/***************************************************************************
* uglCTPageDrawSet - Set active drawing page.
*
* RETURNS: UGL_STATUS_OK or UGL_STATUS_ERROR
*
*/
UGL_STATUS uglLQPageDrawSet
(
UGL_UGI_DRIVER * pDriver,
UGL_PAGE * pPage
)
{
UGL_GENERIC_DRIVER *pGenDriver = (UGL_GENERIC_DRIVER *)pDriver;
pGenDriver->pDrawPage = pPage;
return(UGL_STATUS_OK);
}
/***************************************************************************
* uglCTPageVisibleSet - Set the active display page.
*
* RETURNS: UGL_STATUS_OK or UGL_STATUS_ERROR
*
*/
UGL_STATUS uglLQPageVisibleSet
(
UGL_UGI_DRIVER * pDriver,
UGL_PAGE * pPage
)
{
UGL_GENERIC_DRIVER *pGenDriver = (UGL_GENERIC_DRIVER *)pDriver;
UGL_UINT32 address;
volatile UGL_UINT8 value;
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);
/* reset software interrupt */
/* Set first two address registers */
/* Set final address register to flip page */
pGenDriver->pVisiblePage = pPage;
/* Wait until vertical retrace occurs before allowing drawing to continue */
return(UGL_STATUS_OK);
}
UGL_STATUS uglLQgpWait
(
UGL_GENERIC_DRIVER * pDriver
)
{
pDriver->gpBusy = UGL_FALSE;
return(UGL_STATUS_OK);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -