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

📄 dbglcd.c

📁 windows mobile 6.13 dnldr下载源码
💻 C
📖 第 1 页 / 共 3 页
字号:

#if 1
    /*Set CLCDC LCDUPBASE register*/

    pLocalClcdcReg->LCDUPBASE_R = SYS_LCD_CLCDC_BASE_ADDRESS	/*EDC_LCD_SLAVE*/;

    //DEBUGMSG(CLCDC_DEBUG ,(TEXT("pLocalClcdcReg->LCDUPBASE_R = 0x%lx!\r\n"),pLocalClcdcReg->LCDUPBASE_R));
#endif
    /*Set CLCDC LCDINTRENABLE register*/
    pLocalClcdcReg->LCDIMSC_R = 0;

    /*Set CLCDC LCDCONTROL register*/
    //pLocalClcdcReg->LCDCONTROL_R = VAL_CLCDC_CONTROL;   // not enable CLCDC here
    pLocalClcdcReg->LCDCONTROL_R = 0x82d;
	//OALMSG(1, ("clcdc: CONTROL 0x%x", pLocalClcdcReg->LCDCONTROL_R));

    return CLCDC_SUCCESS;
}

static INT32 ClcdcSwitch(P_DISPLAY_T pLcdReg, UINT32 ulClcdcOpFlag)
{
    DISPLAY_T * const pLocalLcdReg    = pLcdReg;
    CLCDC_REG * pLocalClcdcReg      = (P_CLCDC_REG)NULL;

    if (NULL == pLocalLcdReg)
    {
        //DEBUGMSG(CLCDC_DEBUG ,(TEXT("clcdcSwitch: NULL pointer: pLocalLcdReg!\r\n")));
        return CLCDC_FAILURE;
    }

    pLocalClcdcReg = pLocalLcdReg->pClcdcReg;

    if (NULL == pLocalClcdcReg)
    {
    	//DEBUGMSG(CLCDC_DEBUG ,(TEXT("clcdcSwitch: NULL pointer: pLocalClcdcReg!\r\n")));
        return CLCDC_FAILURE;
    }

    switch(ulClcdcOpFlag)
    {
        case(LCDCONTROL_DISABLE_CLCDC):
        {
            LCD_BIT_SET(pLocalClcdcReg->LCDCONTROL_R, LCDControlLcdEn, LCDCONTROL_DISABLE_CLCDC);
            break;
        }
        case(LCDCONTROL_ENABLE_CLCDC):
        {
            LCD_BIT_SET(pLocalClcdcReg->LCDCONTROL_R, LCDControlLcdEn, LCDCONTROL_ENABLE_CLCDC);
            break;
        }
        default:
        {
            //DEBUGMSG(CLCDC_DEBUG ,(TEXT("clcdcSwitch: ulClcdcOpFlag invalid!\r\n")));
            return CLCDC_FAILURE;
        }
    }

    return CLCDC_SUCCESS;
}

#define EDC_BASE_REG	0x20001000

void EdcInit(DWORD width, DWORD height, DWORD bpp)
{
	OUTREG32(EDC_BASE_REG+EDC_DEBUG, CLFP_SEL | CLFP_INV);
	OUTREG32(EDC_BASE_REG+EDC_GRP_LN_OFFSET, width * bpp >> 3);
	OUTREG32(EDC_BASE_REG+EDC_GRP_XY, 0);
	OUTREG32(EDC_BASE_REG+EDC_GRP_SIZE, (((width - 1) << GRP_SIZE_HRZ_SHIFT) & GRP_SIZE_HRZ_MASK) |
                        (((height - 1) << GRP_SIZE_VRT_SHIFT) & GRP_SIZE_VRT_MASK));
	OUTREG32(EDC_BASE_REG+EDC_GRP_ADDR, SYS_LCD_CLCDC_BASE_ADDRESS);
	OUTREG32(EDC_BASE_REG+EDC_DISP_SIZE, (((DWORD)(width - 1) << DISP_SIZE_HRZ_SHIFT) & DISP_SIZE_HRZ_MASK) |
           				 (((DWORD)(height - 1) << DISP_SIZE_VRT_SHIFT) & DISP_SIZE_VRT_MASK));
	OUTREG32(EDC_BASE_REG+EDC_DISP_CTL, DISP_EN | DISP_ENDIAN_LITTLE | DISP_RGB | DISP_PIX_FMT_RGB666);	
	OUTREG32(EDC_BASE_REG+EDC_GRP_CTL, GRP_EN | GRP_ROT_0 | GRP_RGBIN_RGB565);
}

/*****************************************************
 * Function: MapAddress
 * Description: map physical address into GWES address space.
 * Calls: 
 * Called by: 
 * Table Access: list the table you will use. 
 * Table Update: list the table which you will update.
 * Input: NONE
 * Output: NONE
 * Return: NONE
 * Others: NONE
 ****************************************************/

BOOL MapAddress(void)
{

    PHYSICAL_ADDRESS RegPA;

#ifdef UNDER_CE
    /* map CLCDC reg space */
    RegPA.QuadPart = SYS_CLCDC_BASE_ADDRESS;
    if (NULL == (g_display.pClcdcReg = (P_CLCDC_REG)MmMapIoSpace(RegPA, 0x10000/*sizeof(CLCDC_REG)*/, FALSE)))
    {
        RETAILMSG(1, (TEXT("m_pCLCDCREG is not mapped.\n\r")));
        return FALSE;
    }
    //DEBUGMSG(1 ,(TEXT("m_pSSPREG = 0x%lx!\r\n"), (UINT32)g_display.pClcdcReg ));
    
    RegPA.QuadPart = SYS_LCD_FRAMEBUFFER_BASE_ADDRESS;
    if (NULL == (g_display.m_pSramBuffer = (P_CLCDC_REG)MmMapIoSpace(RegPA, HISI_EDC_SRAM_SIZE, FALSE)))
    {
        RETAILMSG(1, (TEXT("m_pCLCDCREG is not mapped.\n\r")));
        return FALSE;
    }
    //DEBUGMSG(1 ,(TEXT("m_pSSPREG = 0x%lx!\r\n"), (UINT32)g_display.pClcdcReg ));

#else
    g_display.pClcdcReg = (P_CLCDC_REG)SYS_CLCDC_BASE_ADDRESS;
    g_display.ulFrameBufferVirtualAddr = SYS_LCD_FRAMEBUFFER_BASE_ADDRESS;
#endif

    return TRUE;  
}

void UnMapAddress(void)
{
#ifdef UNDER_CE
    if (g_display.pClcdcReg)
    {
        MmUnmapIoSpace((PVOID)g_display.pClcdcReg, 0x10000);
        g_display.pClcdcReg = NULL;
    }
 
    if (g_display.ulFrameBufferVirtualAddr )
    {
        (void)VirtualFree((PVOID)g_display.ulFrameBufferVirtualAddr , 0, MEM_RELEASE);
        g_display.ulFrameBufferVirtualAddr  = NULL;
    }
#endif
}

#endif

#ifdef __cplusplus
}
#endif /* __cplusplus */


/*****************************************************
 *  Interface function Definition
 ****************************************************/
/*****************************************************
 * Function: DrvEnableDriver
 * Description: LCD Initialize Functions Definition,
 *              it is entry function
 * Calls: 
 * Called by: HisiDisp::SetPrimarySurface
 * Table Access: list the table you will use. 
 * Table Update: list the table which you will update.
 * Input: 
 * Output: NONE
 * Return: 
 * Others: NONE
 ****************************************************/
BOOL BltRect(RECT rc, DWORD stride, VOID *pBuffer)
{
    volatile USHORT *pFrame = (USHORT *)(g_display.ulFrameBufferVirtualAddr);
    DWORD screenWidth = g_display.width;
    USHORT *pData = (USHORT*)pBuffer;
    LONG xs, ys, xt, yt;

    // Convert stride from bytes to words
    stride /= sizeof(USHORT);
    for (yt = rc.top, ys = 0; yt < rc.bottom; yt++, ys++)
    {
    	for (xt = rc.left, xs = 0; xt < rc.right; xt++, xs++)
        {
        	pFrame[yt * screenWidth + xt] = pData[ys * stride + xs];
        }
    }
    return TRUE;
}

#define	LCD_BIT_PER_FRAME	(PANEL_DISPLAY_WIDTH*PANEL_DISPLAY_HEIGHT*2)
USHORT	*g_LCDTmpBuf = NULL;


BOOL
InitDisplay(
    DWORD width,
    DWORD height,
    DWORD bpp,
    DWORD orientation
    )
{
#ifdef HISI3610_CHIP
	RECT rc = {0, 0, PANEL_DISPLAY_WIDTH, PANEL_DISPLAY_HEIGHT};

	InitLcdSPI();
	// SPI CS2 select LCD
	SETREG32(HISI3610_SYSCTRL_SCPERCTRL5, 0x1000);		
	
    // Clear
    memset(&g_display, 0, sizeof(g_display));

     // We support only 16 bpp...
    if (bpp != 16)
    {
        //DEBUGMSG(TRUE, (TEXT("ERROR: InitDisplay: Display doesn't support %d bpp\r\n"), bpp));
        return  FALSE;
   }

   if (width != LCM_DISPLAY_WIDTH ||height != LCM_DISPLAY_HEIGHT)
   {
        //DEBUGMSG(TRUE, (TEXT("ERROR: InitDisplay: There isn't mode with width=%d height=%d bpp=%d\r\n"), width, height, bpp));
        return  FALSE;
   }

    g_display.width  = width;
    g_display.height  = height;
    g_display.stride = (g_display.width * bpp) >> 3;
 
    g_display.ulFrameBufferSize          = ((g_display.stride) * (1/*g_display.width */* g_display.height));
    if(FALSE == MapAddress())
    {
        UnMapAddress();
    }

	// set lcm clock div
	SETBITVALUE32(HISI3610_SYSCTRL_SCPERCTRL1, 0x1F<<13, 0x9<<13);

    (void)ClcdcInit(&g_display);
    LCD_DELAY(10);

    /*Enable CLCDC*/
    (void)ClcdcSwitch(&g_display, LCDCONTROL_ENABLE_CLCDC);
    //DEBUGMSG(CLCDC_DEBUG ,(TEXT("do lcmInit!\r\n")));    

	//Edc_Init(width, height, bpp);

    /*Initialize LCM*/
	// Open LCD power
	InitHi6421SPI();
	WriteHi6421Register(0x0d, 0x80, 0x00);	// LDO8 Output

    //DEBUGMSG(CLCDC_DEBUG ,(TEXT("Init LCD!\r\n")));			
	
    (void)LcdReset();

    (void)LcmInit();  

    BacklightTurnOnOff(TRUE);

    //DEBUGMSG(CLCDC_DEBUG ,(TEXT("do FrameBufferUpdate! show logo\r\n")));
    g_LCDTmpBuf = (USHORT *)MemAlloc(LCD_BIT_PER_FRAME);
	if(NULL == g_LCDTmpBuf)
	{
		return FALSE;
	}

	// set write to lcd
    memset(g_LCDTmpBuf, 0xFF, LCD_BIT_PER_FRAME*sizeof(USHORT));

	BltRect(rc, 480, g_LCDTmpBuf);

    return  TRUE;
#else
	return FALSE;
#endif

}



BOOL
DeinitDisplay(
    )
{
#ifdef HISI3610_CHIP
	//DEBUGMSG(TRUE, (TEXT(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!DeinitDisplay")));
	BacklightTurnOnOff(FALSE);
    LcmPowerOff();
    ClcdcSwitch(&g_display, LCDCONTROL_DISABLE_CLCDC);
    UnMapAddress();
#endif
    return FALSE;

}

//------------------------------------------------------------------------------


#define FONT_CHARACTERS	256
#define TEXT_CHAR_WIDTH	5

/**** settings of Text value ****/
static const UINT8 gddiTextFont[FONT_CHARACTERS][TEXT_CHAR_WIDTH] =
{
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x00 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x01 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x02 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x03 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x04 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x05 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x06 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x07 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x08 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x09 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x0a */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x0b */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x0c */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x0d */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x0e */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x0f */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x10 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x11 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x12 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x13 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x14 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x15 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x16 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x17 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x18 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x19 */
	{0x00,0x00,0x00,0x00,0x00},	   /*              0x1a */

⌨️ 快捷键说明

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