For more information, see documentation/FB/modedb.txt.
CVT: coordinated video timings
From the VESA (TM) Website:
"The purpose of CVT is to provide a method for generating a consistent
And coordinated set of standard formats, display refresh rates, and
Timing specifications for computer display products, both those
Employing CRTS, and those using other display technologies.
Intention of CVT is to give both source and display manufacturers
Common set of tools to enable new timings to be developed in
Consistent manner that ensures greater compatibility ."
CVT introduces new naming rules as follows:
<Pix> m <A> [-R]
PIX = Total number of pixels, in MB (xres x yres)
M = always exist
A = appearance ratio (3-4: 3; 4-5: 4; 9-16: 9; A-16: 10)
-R = CED blanking
Example of CVT:. 48m3-r-800x600 with reduced blanking
Note that the standard CVT timing has the following restrictions:
-The appearance ratio must be 3, 4, 9, and a listed above.
-The acceptable update rate is 50, 60, 70, and 85Hz.
-The flushing rate must be 60Hz for reduced blingking.
35 struct fb_cvt_data {
36 u32 xres;/* x resolution */
37 u32 yres;/* Y Resolution */
38 u32 refresh;/* refresh speed */
39 u32 f_refresh;/* refresh frequent, if non-interlace refresh equal to f_refresh, otherwise f_refresh is twice of refresh */
40 u32 pixclock;
41 u32 hperiod;
42 u32 hblank;/* horizontal invisibility */
43 u32 hfreq;
44 u32 htotal;/* contains active_pixels and hblank, total number of times of a scan row */
45 u32 vtotal;/* The total number of times for a single game, including valid data v_margin VBI data */
46 u32 vsync;/* vertical sync timing, according to the aspect ratio table */
47 u32 hsync;/* horizontal sync */
48 u32 h_front_porch;/* preparation before the row's valid data, hblank/2 + h_margin-hsync */
49 u32 h_back_porch;/* The part after the row's valid data, hblank/2 + h_margin */
50 u32 v_front_porch;/* vertical leading, Vertial total number minus v_sync v_back_porch one data field */
51 u32 v_back_porch;/* vertical suffix v_margin + 3 */
52 u32 h_margin;/* in CVT, left_margin is the same as right_margin, collectively referred to as h_margin */
53 u32 v_margin;/* in CVT, top margin is the same as bottom margin, and the value is v_margin = the number of rows x 1.8% */
54 u32 interlace;/* 1 Non-interlace, 2 interlaced */
55 u32 aspect_ratio;/* width and height resolution ratio */
56 u32 active_pixels;/* number of pixels per row of the same walking package, which includes left right margin, but does not include hblank */
57 u32 flags;
58 u32 status;
59 };
72/* returns hperiod * 1000 */
73 static u32 fb_cvt_hperiod (struct fb_cvt_data * CVT)
74 {
75 u32 num = 1000000000/CVT-> f_refresh;
76 u32 den;
77
78 If (CVT-> flags & fb_cvt_flag_reduced_blank ){
79 num-= fb_cvt_rb_min_vblank * 1000;
80 den = 2 * (CVT-> yres/CVT-> interlace + 2 * CVT-> v_margin );
81} else {
82 num-= fb_cvt_min_vsync_bp * 1000;
83 den = 2 * (CVT-> yres/CVT-> interlace + CVT-> v_margin * 2
84 + fb_cvt_min_vporch + CVT-> interlace/2 );
85}
86
87 return 2 * (Num/DEN );
88}
This function calculates the number of shards required for scanning each line.
75 num the time required for each frame, measured in picosecond * 1000. The reason why picosecond is not used here is that picosecond is too small to be expressed.
172 static u32 fb_cvt_pixclock (struct fb_cvt_data * CVT)
173 {
174 u32 pixclock;
175
176 If (CVT-> flags & fb_cvt_flag_reduced_blank)
177 pixclock = (CVT-> f_refresh * CVT-> vtotal * CVT-> htotal)/1000;
178 else
179 pixclock = (CVT-> htotal * 1000000)/CVT-> hperiod;
180
181 pixclock/= 250;
182 pixclock * = 250;
183 pixclock * = 1000;
184
185 return pixclock;
186}
Clock screen rate. For example, if the flushing rate is 60, vtotal = 1024, htotal = 1024, and the screen flushing rate is reduced blank, the clock screen rate is 60 MHz.
Pixelclock is directly proportional to the flushing rate width and height.
188 static u32 fb_cvt_aspect_ratio (struct fb_cvt_data * CVT)
189 {
190 u32 xres = CVT-> xres;
191 u32 yres = CVT-> yres;
192 u32 aspect =-1;
193
194 If (xres = (yres * 4)/3 &&! (Yres * 4) % 3 ))
195 aspect = 0;
196 else if (xres = (yres * 16)/9 &&! (Yres * 16) % 9 ))
197 aspect = 1;
198 else if (xres = (yres * 16)/10 &&! (Yres * 16) % 10 ))
199 aspect = 2;
200 else if (xres = (yres * 5)/4 &&! (Yres * 5) % 4 ))
201 aspect = 3;
202 else if (xres = (yres * 15)/9 &&! (Yres * 15) % 9 ))
203 aspect = 4;
204 else {
205 printk (kern_info "fbcvt: Aspect Ratio not CVT"
206 "Standard \ n ");
207 aspect = 7;
208 CVT-> Status = 1;
209}
210
211 return aspect;
212}
Calculate Aspect Ratio Based on CVT-> xres and CVT-> yres
270 static void fb_cvt_convert_to_mode (struct fb_cvt_data * CVT,
271 struct fb_videomode * Mode)
272 {
273 mode-> refresh = CVT-> f_refresh;
274 mode-> pixclock = khz2picos (CVT-> pixclock/1000 );
275 mode-> left_margin = CVT-> h_back_porch;
276 mode-> right_margin = CVT-> h_front_porch;
277 mode-> hsync_len = CVT-> hsync;
278 mode-> upper_margin = CVT-> v_back_porch;
279 mode-> lower_margin = CVT-> v_front_porch;
280 mode-> vsync_len = CVT-> vsync;
281
282 mode-> Sync & = ~ (Fb_sync_hor_high_act | fb_sync_vert_high_act );
283
284 If (CVT-> flags & fb_cvt_flag_reduced_blank)
285 mode-> sync | = fb_sync_hor_high_act;
286 else
287 mode-> sync | = fb_sync_vert_high_act;
288}
CVT itself is a representation of videomode. This function converts CVT representation to video mode.
From this conversion, we can see the differences between the two representations on some definitions.
1110 struct fb_videomode {
1111 const char * Name;/* optional */
1112 u32 refresh;/* optional update rate */
1113 u32 xres;/* x resolution */
1114 u32 yres;/* Y Resolution */
1115 u32 pixclock;/* time required for a pixel-like Pico second */
1116 u32 left_margin;
1117 u3right_margin;
1118 u3upper_margin;
1119 u32 lower_margin;
1120 u32 hsync_len;/* horizontal synchronization length, in pixels */
1121 u32 vsync_len;/* vertical synchronization length, in pixels */
1122 u32 sync;
1123 u32 vmode;
1124 u32 flag;
1125 };