Fork me on GitHub

11/19/2011

[DISP] pixel clock, hsync, vsync 觀念

接觸 display driver 開發一陣子,經常遇到一些似懂非懂得名詞,假日的時候 google 一下,解決心中的疑惑

主要參考幾篇網路文章:
1. http://www.linuxjournal.com/article/1089
2. http://www.epanorama.net/documents/pc/vga_timing.html
3. http://kezeodsnx.pixnet.net/blog/post/24116781-display-%E7%9B%B8%E9%97%9C%E5%8E%9F%E7%90%86 (有關 pixel clock)

以下是擷取第一個網路資料的內容,簡單介紹 display 顯示畫面的原理:

TVs and monitors display the picture by scanning lines across the screen. As in a book, the first line starts at the top left of the screen and goes to the top right. Each successive line starts slightly below the previous line. This continues until the screen is full. The lines don't have to be full; the picture is formed by altering the intensity of the electron beam as it scans the lines.

To perform this scan, the TV has two deflection units: one scans from left to right, and the other scans (much more slowly) from top to bottom. Not unexpectedly, these units are called thehorizontal and vertical deflection units. You may also encounter the terms line and frame deflection. (可以把畫面形成想像成一個傳統的打字機,每打完一行,就要從尾端在移動到起始位置)

The electron beam can move at only a finite speed. When the electron beam reaches the right hand side of the screen, it needs to be deflected back again. This part of the scan is called thehorizontal retrace, and it is not used for displaying picture data. The actual time that the hardware requires for the retrace varies, but it is in the order of 5% to 10% of the total line scan time. Similarly, when the vertical deflection reaches the bottom of the screen, it performs a vertical retrace, which is also not used for display.

It's not enough to just deflect, of course; somehow you need to ensure that the scanning is synchronized with the incoming signal, so that the scan is at the top of the screen when the picture information for the top of the screen arrives. You've all seen what happens when this doesn't happen; the picture runs up and down the screen (incorrect vertical synchronization) or tears away from the left of the screen (incorrect horizontal synchronization). Synchronization is achieved by including synchronization pulses in the horizontal and vertical retrace periods. To ensure that they are recognized as synchronization pulses, they have different voltage levels from the picture data. (sync 訊號是為了確保 signal source 跟顯示出來的東西可以保持同步,否則可能會有跳frame或是tearing的現象發生)

As if that wasn't enough, the video amplifier, the part of the TV which alters the intensity of the spot as it travels across the screen, needs time to ensure that the retrace is invisible, so there are brief pauses between the end of the line and the start of the sync pulse, and again between the end of the sync pulse and the beginning of the data. This process is called blanking, and the delays are called the front porch (before the sync pulse) and theback porch (after the sync pulse). (porch 的概念就是,當顯示在做 retrace 的時候並不會 show pixel,就像採煞車一樣把 intensity 降低,這需要時間 "back porch",等到移動到定位了,要開始催油門到一定的 intensity,這也需要時間 "front porch"。

用第二篇資料的圖示會更清楚:

Horizonal Timing

Horizonal Dots         640     640     640        
Vertical Scan Lines    350     400     480
Horiz. Sync Polarity   POS     NEG     NEG
A (us)                 31.77   31.77   31.77     Scanline time
B (us)                 3.77    3.77    3.77      Sync pulse lenght 
C (us)                 1.89    1.89    1.89      Back porch
D (us)                 25.17   25.17   25.17     Active video time
E (us)                 0.94    0.94    0.94      Front porch
         ______________________          ________
________|        VIDEO         |________| VIDEO (next line)
    |-C-|----------D-----------|-E-|
__   ______________________________   ___________
  |_|                              |_|
  |B|
  |---------------A----------------|

Vertical Timing

Horizonal Dots         640     640     640
Vertical Scan Lines    350     400     480
Vert. Sync Polarity    NEG     POS     NEG      
Vertical Frequency     70Hz    70Hz    60Hz
O (ms)                 14.27   14.27   16.68     Total frame time
P (ms)                 0.06    0.06    0.06      Sync length
Q (ms)                 1.88    1.08    1.02      Back porch
R (ms)                 11.13   12.72   15.25     Active video time
S (ms)                 1.2     0.41    0.35      Front porch
         ______________________          ________
________|        VIDEO         |________|  VIDEO (next frame)
    |-Q-|----------R-----------|-S-|
__   ______________________________   ___________
  |_|                              |_|
  |P|
  |---------------O----------------|


...