/********************************************************************************
*
* Project Name : S3C6410 Validation
*
* Copyright 2006 by Samsung Electronics, Inc.
* All rights reserved.
*
* Project Description :
* This software is only for verifying functions of the S3C6410.
* Anybody can use this software without our permission.
*
*--------------------------------------------------------------------------------
*
* File Name : lcd.c
*
* File Description :
*
* Author : Yoh-Han Lee
* Dept. : AP Development Team
* Created Date : 2006/12/27
* Version : 0.2
*
* History
* - Created (Y.H.Lee, 2006/12/27)
* - Release Ver 0.1 (Y.H.Lee, 2007/03/29)
* - Release Ver 0.2 (Y.H.Lee, 2007/06/07)
********************************************************************************/
#include <config.h>
#include <common.h>
#include "lcd.h"
#include "s3c6410.h"
#include "intc.h"
LCDC oLcdc;
u8 bIsRev = 0;
u8 bIsAllWin =0;
LCD_WINDOW eBgWin, eFgWin;
CSPACE eBgBpp;
CSPACE eFgBpp, eFgArgbBpp;
u32 uFrameCount;
u32 uCount;
u32 uLcdFbAddr = LCD_FRAMEBUFFER_ST;
// ITUIFCON0
#define EQUAL_HSYNC (0<<24)
#define DELAYED_VSYNC (1<<24)
#define CYCLE_DELAY_VSYNC(n) (((n)&0xFF)<<16)
#define I656CLK_NORMAL (0<<8)
#define I656CLK_INVERT (1<<8)
#define I601HREF_NORMAL (0<<6)
#define I601HREF_INVERT (1<<6)
#define I601VSYNC_NORMAL (0<<5)
#define I601VSYNC_INVERT (1<<5)
#define I601HSYNC_NORMAL (0<<4)
#define I601HSYNC_INVERT (1<<4)
#define I601FIELD_NORMAL (0<<3)
#define I601FIELD_INVERT (1<<3)
#define I601CLK_NORMAL (0<<2)
#define I601CLK_INVERT (1<<2)
///////////////////////////////////////////////////////////////////
void LCD_SimpleBasicDisp(void)
{
u32 uHSz, uVSz;
uHSz=480;
uVSz=272;
LCD_SetPort();
LCD_InitLDI((CPUIF_LDI)LCD_CPUIF_CS);
LCD_InitBase2((CLK_SRC)SRC_DOUT_MPLL, PNR_Parallel_RGB, CPU_16BIT);
LCD_InitWin(RGB16, uHSz, uVSz, 0, 0, uHSz, uVSz, 0, 0, LCD_FRAMEBUFFER_ST, WIN0, false);
LCD_SetWinOnOff(1, WIN0);
LCD_GetFrmSz(&uHSz, &uVSz, WIN0);
//load_image 16bpp_565.bin LCD_FRAMEBUFFER_ST
//LCD_InitFB(LCD_FRAMEBUFFER_ST, uHSz, uVSz, RGB16);
LCD_Start();
printf("\nIf you want to stop display, press any key\n");
getc();
LCD_SetAllWinOnOff(0);
LCD_Stop();
}
//-----------------------------------------------------------
// Function Name : LCD_SetPort
//
// Function Desctiption :
//
// Input :
//
// Output :
//
// Version :
//------------------------------------------------------------
void LCD_SetPort (void)
{
unsigned int value;
///////////////////////////////////////////////////////////////////////////////
MOFPCON_REG=0; //Must be '0' for Normal-path instead of By-pass
///////////////////////////////////////////////////////////////////////////////
//SPCON,RGBIF
value = (*(volatile unsigned *)SPCON);
value &= ~0x3;
value |= 1;
(*(volatile unsigned *)SPCON)=value;
//LCD Port
GPICON_REG=0xaaaaaaaa;
GPJCON_REG=0xaaaaaaaa;
//Back-light
value = GPFCON_REG;
value &= ~(0x3<<28);
value |= 1<<28;
GPFCON_REG=value;
GPFDAT_REG|=1<<14;
value = GPECON_REG;
value &= ~0x3;
value |= 1;
GPECON_REG=value;
GPEDAT_REG |=1;
#if 0
//use lcd control backlight?
value = GPFCON_REG;
value &= ~(0x3<<30);
value |= 1<<30;
GPFCON_REG=value;
GPFDAT_REG|=1<<15;
#endif
//Need reset ldi?
value = GPNCON_REG;
value &= ~(0x3<<10);
value |= 1<<10;
GPNCON_REG=value;
GPNDAT_REG&=~(1<<5);
GPNDAT_REG|=1<<5;
}
//------------------------------------------------------------
void LCD_InitLDI(CPUIF_LDI eLdiMode)
{
LCD_InitLTP700WV_RGB();
}
void LCD_InitDISPC(CSPACE eBpp, u32 uFbAddr, LCD_WINDOW eWin, u8 bIsDoubleBuf)
{
LCD_InitBase();
LCD_InitWin(eBpp, oLcdc.m_uLcdHSz, oLcdc.m_uLcdVSz, 0, 0, oLcdc.m_uLcdHSz, oLcdc.m_uLcdVSz,
0, 0, uFbAddr, eWin, bIsDoubleBuf);
}
void LCD_InitDISPC1(u32 uHSize, u32 uVSize, CSPACE eBpp, u32 uFbAddr, LCD_WINDOW eWin, u8 bIsDoubleBuf)
{
LCD_InitBase1(uHSize, uVSize);
LCD_InitWin(eBpp, oLcdc.m_uLcdHSz, oLcdc.m_uLcdVSz, 0, 0, oLcdc.m_uLcdHSz, oLcdc.m_uLcdVSz,
0, 0, uFbAddr, eWin, bIsDoubleBuf);
}
//------------------------------------------------------------
void LCD_GetFrmSz(u32* uFrmHSz, u32* uFrmVSz, LCD_WINDOW eWin)
{
*uFrmHSz = oLcdc.m_uFrmHSz[eWin];
*uFrmVSz = oLcdc.m_uFrmVSz[eWin];
}
//------------------------------------------------------------
void LCD_Start(void)
{
u32 uLcdCon;
uLcdCon=Inp32(LCD_BASE+rVIDCON0);
uLcdCon |= 0x3<<0;
LcdcOutp32(rVIDCON0, uLcdCon);
}
//-----------------------------------------------------------
void LCD_Stop(void)
{
u32 uLcdCon;
uLcdCon=Inp32(LCD_BASE+rVIDCON0);
uLcdCon &= ~(0x3<<0);
LcdcOutp32(rVIDCON0, uLcdCon);
}
void LCD_PerFrameOff(void)
{
u32 uLcdCon;
uLcdCon=Inp32(LCD_BASE+rVIDCON0);
uLcdCon &= ~(0x1<<0);
LcdcOutp32(rVIDCON0, uLcdCon);
}
//------------------------------------------------------------
void LCD_InitBase(void)
{
u32 uLcdCon;
u32 uILcdIntCon;
u32 uClkVal, uClkDir;
u32 uVidconReg;
u32 i;
LCD_WINDOW eWin;
CLK_SRC eVClkSrc;
oLcdc.m_bIsAutoBuf = false;
oLcdc.m_uScanMode = 0; // progressive mode
oLcdc.m_bIsLocalCalled[0] = false;
oLcdc.m_bIsLocalCalled[1] = false;
oLcdc.m_bIsLocalCalled[2] = false;
#if (LCD_CLOCK_SOURCE == LCLK_HCLK)
printf("LCD Clock Source: HCLK\n");
oLcdc.m_uVideoClockSource = CLKSEL_F_HCLK;
eVClkSrc = SRC_HCLK;
#elif (LCD_CLOCK_SOURCE == LCLK_MOUT_EPLL)
printf("LCD Clock Source: EPLL OUT\n");
oLcdc.m_uVideoClockSource = CLKSEL_F_SYSCON;
eVClkSrc = SRC_MOUT_EPLL;
#elif (LCD_CLOCK_SOURCE == LCLK_DOUT_MPLL)
printf("LCD Clock Source: MPLL OUT\n");
oLcdc.m_uVideoClockSource = CLKSEL_F_SYSCON;
eVClkSrc = SRC_DOUT_MPLL;
#elif (LCD_CLOCK_SOURCE == LCLK_FIN_EPLL)
printf("LCD Clock Source: FIN\n");
oLcdc.m_uVideoClockSource = CLKSEL_F_SYSCON;
eVClkSrc = SRC_FIN_EPLL;
#elif (LCD_CLOCK_SOURCE == LCLK_27M)
printf("LCD Clock Source: 27M\n");
oLcdc.m_uVideoClockSource = CLKSEL_F_EXTCLK;
eVClkSrc = SRC_27M;
#endif
#if (LCD_MODULE_TYPE ==LTE480WV_RGB)
oLcdc.m_uLcdHSz = 480;
oLcdc.m_uLcdVSz = 272;
oLcdc.m_uVidOutFormat = VIDOUT_RGBIF;
oLcdc.m_uDitherMode = RDITHPOS_8BIT|GDITHPOS_8BIT|BDITHPOS_8BIT;
oLcdc.m_uDitherMode &= ~DITHERING_ENABLE;
LcdcOutp32(rVIDCON1, IHSYNC_INVERT | IVSYNC_INVERT |IVDEN_NORMAL);
LcdcOutp32(rVIDTCON0, VBPDE(VBPD_LTP700WV) | VBPD(VBPD_LTP700WV) | VFPD(VFPD_LTP700WV) | VSPW(VSPW_LTP700WV));
LcdcOutp32(rVIDTCON1, VFPDE(VFPD_LTP700WV) | HBPD(HBPD_LTP700WV) | HFPD(HFPD_LTP700WV) | HSPW(HSPW_LTP700WV));
LcdcOutp32(rVIDTCON2, LINEVAL(oLcdc.m_uLcdVSz-1) | HOZVAL(oLcdc.m_uLcdHSz-1));
LcdcOutp32(rDITHMODE, oLcdc.m_uDitherMode); // Fixed Dithering Matrix
#else
printf("LCD_MODULE_TYPE ERROR\n");
Assert(0); // Not yet implemented.
#endif
LCD_Stop();
//Check up LCD to turn off
while (1)
{
uLcdCon=Inp32(LCD_BASE+rVIDCON0);
if( (uLcdCon&0x03) == 0 ) // checking whether disable the video output and the Display control signal or not.
break;
}
LCD_GetClkValAndClkDir(oLcdc.m_uLcdHSz, oLcdc.m_uLcdVSz, &uClkVal, &uClkDir, eVClkSrc);
uVidconReg =
PROGRESSIVE | oLcdc.m_uVidOutFormat | SUB_16_MODE | MAIN_16_MODE | PNRMODE_RGB_P | CLKVALUP_ALWAYS |
CLKVAL_F(uClkVal) | VCLKEN_DISABLE | CLKDIR_F(uClkDir) | oLcdc.m_uVideoClockSource|
ENVID_DISABLE | ENVID_F_DISABLE;
LcdcOutp32(rVIDCON0, uVidconReg);
uILcdIntCon =Inp32(LCD_BASE+rVIDINTCON0);
LcdcOutp32(rVIDINTCON0, uILcdIntCon | FRAMESEL0_BACK | FRAMESEL1_NONE | INTFRMEN_DISABLE |
FIFOSEL_WIN0 | FIFOLEVEL_25 | INTFIFOEN_DISABLE | INTEN_DISABLE);
LCD_SetAllWinOnOff(0); // Turn all windows off
LCD_SetAllWinColorMapOnOff(0); // Turn all windows color map off
LCD_SetAllWinColorKeyOnO