S3C6410LCD控制器

S3C6410     LCD 控制器


1、LCD的種類。 LCD(Liquid Crystal Display),即液晶顯示器,是一種採用了液晶控制透光度技術來實現的彩色的顯示器。LCD有多種類型,如STN、TFT、LTPS TFT、OLED等。

  • STN(Super Twisted Nematic,超扭曲向列)
  • TFT(Thin Film Transistor,薄膜晶體管)
  • LTPS(Low Temperature Polycrystalline Silicon,低溫多晶硅)由TFT衍生的新一代技術產品,可以獲得更高的分辨率和更豐富的色彩。
  • OLED(Organic Light Emitting Diode,有機發光二極管)

2、LCD的接口

CPU或顯卡發出的圖像數據是TTL信號。LCD本身接收的也是TTL信號。由於TTL信號在高速率的長距離傳輸時性能不佳,抗干擾能力也比較差,後來又提出了多種接口,比如LVDS,TDMS,DVI,和DEP等。他們實際上只是將CPU或顯卡發出的TTL信號編碼成各種信號以便傳輸,在LCD那邊將接收到的信號經行解碼得到TTL信號。

TFT LCD的TTL信號 有24跟數據線,對應像素值中的每一位。
  • VSYNC: 垂直同步信號
  • HSYNC: 水平同步信號
  • HCLK: 像素時鐘信號
  • VD[0:23]: 數據信號
  • LEND: 行結束信號(這個不是必須的)
  • PWREN: 電源開關信號

3、S3C6410 LCD控制器

結構框圖:

                                     

DISPLAY controller supports 4 types of display device. 

  • One type is the conventional RGB-interface, which uses RGB data, Vertical/horizontal sync, data valid signal and data sync clock. 
  • The Second type is I80 Interface which uses address, data, chip select, read/write control and register/status indicating signal. In this type of LCD driver it has a frame buffer and has the function of self-refresh, therefore DISPLAY controller updates one still image by writing only one time to the LCD. 
  • The Third type is ITU-R BT.601 interface. ITU-R BT.601 interface uses YUV data, Vertical/horizontal sync, optional Field signal, data valid signal and data sync clock.
  • The fourth type is FIFO interface with TV Encoder.

4、顯示數據的組織格式

    對於屏幕上的一整幅圖像,它的數據格式是如何組織的呢?無論是CRT顯示器還是LCD顯示器,他們都有相同的概念。

    一副圖像被稱爲一幀,每幀有多行組成,每行由多個像素組成,每個像素的顏色使用若干位的數據來表示。對於單色顯示器,每個像素使用1位來表示,稱爲1BPP;對於256色顯示器,每個像素使用8位來表示,稱爲8BPP;

    顯示器從屏幕的左上方開始,一行一行地取出每個像素的數據並顯示出來,當顯示到一行的最右邊時,跳到下一行的最左邊開始顯示下一行;當顯示完所有行後,跳到左上方開始下一幀。顯示器沿着“Z”字行的路線經行掃描,使用HSYNC,VSYNC信號來控制掃描路線的跳轉,HSYNC表示“是跳到最左邊的時候了”,VSYNC表示“是跳到最上邊的時候了”。

    注:在工作中的顯示器上,可以在四周看見黑色的邊框。上方的黑框是因爲當發出 VSYNC信號時,需要經過若干行之後第一行數據纔有效;下方的黑框是因爲現實完所有行的數據時,顯示器還沒有掃描到最下邊,這是數據已經無效;左邊的黑框是因爲當發出HSYNC信號時,需要經過若干像素之後第一列數據纔有效;右邊的黑框是因爲現實完一行的數據時,顯示器還沒掃描到最右邊,這時數據已經無效。

                                                              

                        有效數據的行數、列數,它與VSYNC,HSYNC信號之間的距離等 都是可以設置的,這有顯卡來完成。

    

    5、LCD控制器的操作


                                                         

    時序圖中各信號的時間參考都可以在LCD控制寄存器中設置,VCLK作爲時序圖的基準信號,它的頻率可以如下計算:


    將VSYNC、HSYNC、VCLK等信號的時間參數設置好之後,並將幀內存地址告訴LCD控制器,它既可自動地發起DMA傳輸從幀內存中得到圖像數據,最終在上述信號的控制下出現在數據總線上。


The following registers are used to configure DISPLAY controller:
1. MOFPCON: SEL_BYPASS[3] value @ 0x7410800C must be set as ‘0’(normal mode) instead of ‘1’(by-pass mode).


2. SPCON: LCD_SEL[1:0] value @ 0x7F0081A0 must be set as ‘00’ to use Host I/F Style or as ‘01’ to use RGB I/F Style

3. VIDCON0(Video control 0 register): configure Video output format and display enable/disable.

4. VIDCON1(Video control 1 register): RGB I/F control signal.

5. I80IFCONx: i80-system I/F control signal.

6. ITUIFCON0 : ITU (BT.601) Interface Control

7. VIDTCONx(Video time control 0 register): configure Video output Timing and determine the size of display.

8. WINCONx(Window control 0 register): each window format setting

9. VIDOSDxA, VIDOSDxB(Video Window 0’s position control register): Window position setting

10. VIDOSDxC(Video Window 0’s size control register): alpha value setting

11. VIDWxxADDx(Window 2’s buffer start address register): source image address setting

12. WxKEYCONx(Color key control register): Color key value register

13. WINxMAP(Window color control): window color control

14. WPALCON(Window Palette control register): Palette controls register

15. WxPDATAxx: Window Palette Data of the each Index.


#include "common.h"
#include "regs.h"

/*定義三個初始化函數
	1.初始化GPI和GPJ爲LCD作用
	2.初始化window0
		每個液晶屏支持五層的window*/
void gpio_init(void);
void common_init(void);
void window0_init(void);	

void lcd_init(void)
{
	gpio_init();
	common_init();
	window0_init();	
}

void gpio_init(void)
{
	GPICON = 0xaaaaaaaa;
	GPJCON = 0xaaaaaa;
	/*給LCD上電,把背光燈打開*/
	/*參考S3C6410手冊和母版電路圖*/
	GPFCON &= ~(3 << 28);
	GPFCON |= 1 << 28;
	GPFDAT |= 1 << 14;
	GPECON &= ~(0xf);
	GPECON |= 1;
	GPEDAT |= 1;
}

void common_init(void)
{
	/*配置方法參考S3C6410手冊P491*/
	MIFPCON &= ~(1 << 3);
	SPCON &= ~3;
	SPCON |= 1;

	/*配置發送數據時鐘,並打開DISPLAYC,參考S3C6410手冊P495*/
	VIDCON0 = (14 << 6) | (1 << 4) | (3 << 0);
	
	/*配置時鐘是否翻轉,參考S3C6410手冊P495*/
	/*參考S3C6410手冊P485*/
	/*參考日立LCD手冊P14*/
	/* HSYNC高電平有效, VSYNC高電平有效, */
	VIDCON1 = (1 << 6) | (1 << 5);
	
	/*配置時序,參考S3C6410手冊P497和P485,日立LCD手冊P14*/
	VIDTCON0 = (1 << 16) | (1 << 8) | (9 << 0);
	VIDTCON1 = (1 << 16) | (1 << 8) | (40 << 0);
	
	/*配置LCD的分辨率大小,參考S3C6410手冊P498*/
	VIDTCON2 = (271 << 11) | (479);
}

void window0_init(void)
{
#ifdef BPP565
	/*注意:這兩個寄存器與圖片格式相關*/
	/*配置輸出數據格式和傳送方法以並使能數據發送*/
	/*參考S3C6410手冊P499*/
	WINCON0 = (1 << 16) | (5 << 2) | (1 << 0);

	/*設置一屏的數據量,參考S3C6410手冊P506*/
	VIDOSD0C = (480 * 272) >> 1;
#else
	WINCON0 = (0xb << 2) | (1 << 0);
	VIDOSD0C = 480 * 272;
#endif
	/*設置LCD的最大和最小座標,參考S3C6410手冊P506*/
	VIDOSD0A = 0;
	VIDOSD0B = (479 << 11) | (271 << 0);

	/*設置frambuf的首地址*/
	VIDW00ADD0B0 = FRAM_BUFF;
}

/*畫點函數:
 	在LCD上畫一個點其實就是在這個座標對應的frambuf內存空間中
	寫入一個合適的值,x代表橫座標,y代表列座標,後三個參數代表
	RGB三原色,可根據需要進行配置*/
void draw_point(int x, int y, int red, int green, int blue)
{
	/*注意:
 		565格式和888格式的區別:
			一個word的空間可以存放兩個565格式的像素點數據
			一個word的空間可以存放一個888格式的像素點數據*/
#ifdef BPP565
	short *buf = (void *)FRAM_BUFF;
	*(buf + y * 480 + x) = (red << 11) | (green << 5) | (blue << 0);
#else
	int *buf = (void *)FRAM_BUFF;
	*(buf + y * 480 + x) = (red << 16) | (green << 8) | (blue << 0);
#endif
}





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章