diff options
author | Antonino A. Daplas <adaplas@gmail.com> | 2005-09-09 16:09:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-09 17:03:39 -0400 |
commit | 96fe6a2109db29cd15b90a093c16e6cb4b19371a (patch) | |
tree | bd3c424f3f43e6b5a2ba6c235c7c25b3ba197f4c | |
parent | 5251bffc9b4ca699993c79166adf02faf1bbc043 (diff) |
[PATCH] fbdev: Add VESA Coordinated Video Timings (CVT) support
The Coordinated Video Timings (CVT) is the latest standard approved by VESA
concerning video timings generation. It addresses the limitation of GTF which
is designed mainly for CRT displays. CRT's have a high blanking requirement
(as much as 25% of the horizontal frame length) which artificially increases
the pixelclock. Digital displays, on the other hand, needs to conserve the
pixelclock as much as possible. The GTF also does not take into account the
different aspect ratios in its calculation.
The new function added is fb_find_mode_cvt(). It is called by fb_find_mode()
if it recognizes a mode option string formatted for CVT. The format is:
<xres>x<yres>[M][R][-<bpp>][<at-sign><refresh>][i][m]
The 'M' tells the function to calculate using CVT. On it's own, it will
compute a timing for CRT displays at 60Hz. If the 'R' is specified, 'reduced
blanking' computation will be used, best for flatpanels. The 'i' and the 'm'
is for 'interlaced mode' and 'with margins' respectively.
To determine if CVT was used, check for dmesg for something like this:
CVT Mode - <pix>M<n>[-R], ie: .480M3-R (800x600 reduced blanking)
where: pix - product of xres and yres, in MB
M - is a CVT mode
n - the aspect ratio (3 - 4:3; 4 - 5:4; 9 - 16:9, 15:9; A - 16:10)
-R - reduced blanking
Signed-off-by: Antonino Daplas <adaplas@pol.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | Documentation/fb/modedb.txt | 73 | ||||
-rw-r--r-- | drivers/video/Makefile | 3 | ||||
-rw-r--r-- | drivers/video/fbcvt.c | 380 | ||||
-rw-r--r-- | drivers/video/fbmem.c | 12 | ||||
-rw-r--r-- | drivers/video/modedb.c | 62 | ||||
-rw-r--r-- | include/linux/fb.h | 1 |
6 files changed, 519 insertions, 12 deletions
diff --git a/Documentation/fb/modedb.txt b/Documentation/fb/modedb.txt index e04458b319d5..4fcdb4cf4cca 100644 --- a/Documentation/fb/modedb.txt +++ b/Documentation/fb/modedb.txt | |||
@@ -20,12 +20,83 @@ in a video= option, fbmem considers that to be a global video mode option. | |||
20 | 20 | ||
21 | Valid mode specifiers (mode_option argument): | 21 | Valid mode specifiers (mode_option argument): |
22 | 22 | ||
23 | <xres>x<yres>[-<bpp>][@<refresh>] | 23 | <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m] |
24 | <name>[-<bpp>][@<refresh>] | 24 | <name>[-<bpp>][@<refresh>] |
25 | 25 | ||
26 | with <xres>, <yres>, <bpp> and <refresh> decimal numbers and <name> a string. | 26 | with <xres>, <yres>, <bpp> and <refresh> decimal numbers and <name> a string. |
27 | Things between square brackets are optional. | 27 | Things between square brackets are optional. |
28 | 28 | ||
29 | If 'M' is specified in the mode_option argument (after <yres> and before | ||
30 | <bpp> and <refresh>, if specified) the timings will be calculated using | ||
31 | VESA(TM) Coordinated Video Timings instead of looking up the mode from a table. | ||
32 | If 'R' is specified, do a 'reduced blanking' calculation for digital displays. | ||
33 | If 'i' is specified, calculate for an interlaced mode. And if 'm' is | ||
34 | specified, add margins to the calculation (1.8% of xres rounded down to 8 | ||
35 | pixels and 1.8% of yres). | ||
36 | |||
37 | Sample usage: 1024x768M@60m - CVT timing with margins | ||
38 | |||
39 | ***** oOo ***** oOo ***** oOo ***** oOo ***** oOo ***** oOo ***** oOo ***** | ||
40 | |||
41 | What is the VESA(TM) Coordinated Video Timings (CVT)? | ||
42 | |||
43 | From the VESA(TM) Website: | ||
44 | |||
45 | "The purpose of CVT is to provide a method for generating a consistent | ||
46 | and coordinated set of standard formats, display refresh rates, and | ||
47 | timing specifications for computer display products, both those | ||
48 | employing CRTs, and those using other display technologies. The | ||
49 | intention of CVT is to give both source and display manufacturers a | ||
50 | common set of tools to enable new timings to be developed in a | ||
51 | consistent manner that ensures greater compatibility." | ||
52 | |||
53 | This is the third standard approved by VESA(TM) concerning video timings. The | ||
54 | first was the Discrete Video Timings (DVT) which is a collection of | ||
55 | pre-defined modes approved by VESA(TM). The second is the Generalized Timing | ||
56 | Formula (GTF) which is an algorithm to calculate the timings, given the | ||
57 | pixelclock, the horizontal sync frequency, or the vertical refresh rate. | ||
58 | |||
59 | The GTF is limited by the fact that it is designed mainly for CRT displays. | ||
60 | It artificially increases the pixelclock because of its high blanking | ||
61 | requirement. This is inappropriate for digital display interface with its high | ||
62 | data rate which requires that it conserves the pixelclock as much as possible. | ||
63 | Also, GTF does not take into account the aspect ratio of the display. | ||
64 | |||
65 | The CVT addresses these limitations. If used with CRT's, the formula used | ||
66 | is a derivation of GTF with a few modifications. If used with digital | ||
67 | displays, the "reduced blanking" calculation can be used. | ||
68 | |||
69 | From the framebuffer subsystem perspective, new formats need not be added | ||
70 | to the global mode database whenever a new mode is released by display | ||
71 | manufacturers. Specifying for CVT will work for most, if not all, relatively | ||
72 | new CRT displays and probably with most flatpanels, if 'reduced blanking' | ||
73 | calculation is specified. (The CVT compatibility of the display can be | ||
74 | determined from its EDID. The version 1.3 of the EDID has extra 128-byte | ||
75 | blocks where additional timing information is placed. As of this time, there | ||
76 | is no support yet in the layer to parse this additional blocks.) | ||
77 | |||
78 | CVT also introduced a new naming convention (should be seen from dmesg output): | ||
79 | |||
80 | <pix>M<a>[-R] | ||
81 | |||
82 | where: pix = total amount of pixels in MB (xres x yres) | ||
83 | M = always present | ||
84 | a = aspect ratio (3 - 4:3; 4 - 5:4; 9 - 15:9, 16:9; A - 16:10) | ||
85 | -R = reduced blanking | ||
86 | |||
87 | example: .48M3-R - 800x600 with reduced blanking | ||
88 | |||
89 | Note: VESA(TM) has restrictions on what is a standard CVT timing: | ||
90 | |||
91 | - aspect ratio can only be one of the above values | ||
92 | - acceptable refresh rates are 50, 60, 70 or 85 Hz only | ||
93 | - if reduced blanking, the refresh rate must be at 60Hz | ||
94 | |||
95 | If one of the above are not satisfied, the kernel will print a warning but the | ||
96 | timings will still be calculated. | ||
97 | |||
98 | ***** oOo ***** oOo ***** oOo ***** oOo ***** oOo ***** oOo ***** oOo ***** | ||
99 | |||
29 | To find a suitable video mode, you just call | 100 | To find a suitable video mode, you just call |
30 | 101 | ||
31 | int __init fb_find_mode(struct fb_var_screeninfo *var, | 102 | int __init fb_find_mode(struct fb_var_screeninfo *var, |
diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 8478d217aaf0..4e7d8d27b913 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile | |||
@@ -9,7 +9,8 @@ obj-$(CONFIG_LOGO) += logo/ | |||
9 | obj-$(CONFIG_SYSFS) += backlight/ | 9 | obj-$(CONFIG_SYSFS) += backlight/ |
10 | 10 | ||
11 | obj-$(CONFIG_FB) += fb.o | 11 | obj-$(CONFIG_FB) += fb.o |
12 | fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o modedb.o | 12 | fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o \ |
13 | modedb.o fbcvt.o | ||
13 | fb-objs := $(fb-y) | 14 | fb-objs := $(fb-y) |
14 | 15 | ||
15 | obj-$(CONFIG_FB_CFB_FILLRECT) += cfbfillrect.o | 16 | obj-$(CONFIG_FB_CFB_FILLRECT) += cfbfillrect.o |
diff --git a/drivers/video/fbcvt.c b/drivers/video/fbcvt.c new file mode 100644 index 000000000000..cfa61b512de0 --- /dev/null +++ b/drivers/video/fbcvt.c | |||
@@ -0,0 +1,380 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/fbcvt.c - VESA(TM) Coordinated Video Timings | ||
3 | * | ||
4 | * Copyright (C) 2005 Antonino Daplas <adaplas@pol.net> | ||
5 | * | ||
6 | * Based from the VESA(TM) Coordinated Video Timing Generator by | ||
7 | * Graham Loveridge April 9, 2003 available at | ||
8 | * http://www.vesa.org/public/CVT/CVTd6r1.xls | ||
9 | * | ||
10 | * This file is subject to the terms and conditions of the GNU General Public | ||
11 | * License. See the file COPYING in the main directory of this archive | ||
12 | * for more details. | ||
13 | * | ||
14 | */ | ||
15 | #include <linux/fb.h> | ||
16 | |||
17 | #define FB_CVT_CELLSIZE 8 | ||
18 | #define FB_CVT_GTF_C 40 | ||
19 | #define FB_CVT_GTF_J 20 | ||
20 | #define FB_CVT_GTF_K 128 | ||
21 | #define FB_CVT_GTF_M 600 | ||
22 | #define FB_CVT_MIN_VSYNC_BP 550 | ||
23 | #define FB_CVT_MIN_VPORCH 3 | ||
24 | #define FB_CVT_MIN_BPORCH 6 | ||
25 | |||
26 | #define FB_CVT_RB_MIN_VBLANK 460 | ||
27 | #define FB_CVT_RB_HBLANK 160 | ||
28 | #define FB_CVT_RB_V_FPORCH 3 | ||
29 | |||
30 | #define FB_CVT_FLAG_REDUCED_BLANK 1 | ||
31 | #define FB_CVT_FLAG_MARGINS 2 | ||
32 | #define FB_CVT_FLAG_INTERLACED 4 | ||
33 | |||
34 | struct fb_cvt_data { | ||
35 | u32 xres; | ||
36 | u32 yres; | ||
37 | u32 refresh; | ||
38 | u32 f_refresh; | ||
39 | u32 pixclock; | ||
40 | u32 hperiod; | ||
41 | u32 hblank; | ||
42 | u32 hfreq; | ||
43 | u32 htotal; | ||
44 | u32 vtotal; | ||
45 | u32 vsync; | ||
46 | u32 hsync; | ||
47 | u32 h_front_porch; | ||
48 | u32 h_back_porch; | ||
49 | u32 v_front_porch; | ||
50 | u32 v_back_porch; | ||
51 | u32 h_margin; | ||
52 | u32 v_margin; | ||
53 | u32 interlace; | ||
54 | u32 aspect_ratio; | ||
55 | u32 active_pixels; | ||
56 | u32 flags; | ||
57 | u32 status; | ||
58 | }; | ||
59 | |||
60 | static int fb_cvt_vbi_tab[] = { | ||
61 | 4, /* 4:3 */ | ||
62 | 5, /* 16:9 */ | ||
63 | 6, /* 16:10 */ | ||
64 | 7, /* 5:4 */ | ||
65 | 7, /* 15:9 */ | ||
66 | 8, /* reserved */ | ||
67 | 9, /* reserved */ | ||
68 | 10 /* custom */ | ||
69 | }; | ||
70 | |||
71 | /* returns hperiod * 1000 */ | ||
72 | static u32 fb_cvt_hperiod(struct fb_cvt_data *cvt) | ||
73 | { | ||
74 | u32 num = 1000000000/cvt->f_refresh; | ||
75 | u32 den; | ||
76 | |||
77 | if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) { | ||
78 | num -= FB_CVT_RB_MIN_VBLANK * 1000; | ||
79 | den = 2 * (cvt->yres/cvt->interlace + 2 * cvt->v_margin); | ||
80 | } else { | ||
81 | num -= FB_CVT_MIN_VSYNC_BP * 1000; | ||
82 | den = 2 * (cvt->yres/cvt->interlace + cvt->v_margin * 2 | ||
83 | + FB_CVT_MIN_VPORCH + cvt->interlace/2); | ||
84 | } | ||
85 | |||
86 | return 2 * (num/den); | ||
87 | } | ||
88 | |||
89 | /* returns ideal duty cycle * 1000 */ | ||
90 | static u32 fb_cvt_ideal_duty_cycle(struct fb_cvt_data *cvt) | ||
91 | { | ||
92 | u32 c_prime = (FB_CVT_GTF_C - FB_CVT_GTF_J) * | ||
93 | (FB_CVT_GTF_K) + 256 * FB_CVT_GTF_J; | ||
94 | u32 m_prime = (FB_CVT_GTF_K * FB_CVT_GTF_M); | ||
95 | u32 h_period_est = cvt->hperiod; | ||
96 | |||
97 | return (1000 * c_prime - ((m_prime * h_period_est)/1000))/256; | ||
98 | } | ||
99 | |||
100 | static u32 fb_cvt_hblank(struct fb_cvt_data *cvt) | ||
101 | { | ||
102 | u32 hblank = 0; | ||
103 | |||
104 | if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) | ||
105 | hblank = FB_CVT_RB_HBLANK; | ||
106 | else { | ||
107 | u32 ideal_duty_cycle = fb_cvt_ideal_duty_cycle(cvt); | ||
108 | u32 active_pixels = cvt->active_pixels; | ||
109 | |||
110 | if (ideal_duty_cycle < 20000) | ||
111 | hblank = (active_pixels * 20000)/ | ||
112 | (100000 - 20000); | ||
113 | else { | ||
114 | hblank = (active_pixels * ideal_duty_cycle)/ | ||
115 | (100000 - ideal_duty_cycle); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | hblank &= ~((2 * FB_CVT_CELLSIZE) - 1); | ||
120 | |||
121 | return hblank; | ||
122 | } | ||
123 | |||
124 | static u32 fb_cvt_hsync(struct fb_cvt_data *cvt) | ||
125 | { | ||
126 | u32 hsync; | ||
127 | |||
128 | if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) | ||
129 | hsync = 32; | ||
130 | else | ||
131 | hsync = (FB_CVT_CELLSIZE * cvt->htotal)/100; | ||
132 | |||
133 | hsync &= ~(FB_CVT_CELLSIZE - 1); | ||
134 | return hsync; | ||
135 | } | ||
136 | |||
137 | static u32 fb_cvt_vbi_lines(struct fb_cvt_data *cvt) | ||
138 | { | ||
139 | u32 vbi_lines, min_vbi_lines, act_vbi_lines; | ||
140 | |||
141 | if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) { | ||
142 | vbi_lines = (1000 * FB_CVT_RB_MIN_VBLANK)/cvt->hperiod + 1; | ||
143 | min_vbi_lines = FB_CVT_RB_V_FPORCH + cvt->vsync + | ||
144 | FB_CVT_MIN_BPORCH; | ||
145 | |||
146 | } else { | ||
147 | vbi_lines = (FB_CVT_MIN_VSYNC_BP * 1000)/cvt->hperiod + 1 + | ||
148 | FB_CVT_MIN_VPORCH; | ||
149 | min_vbi_lines = cvt->vsync + FB_CVT_MIN_BPORCH + | ||
150 | FB_CVT_MIN_VPORCH; | ||
151 | } | ||
152 | |||
153 | if (vbi_lines < min_vbi_lines) | ||
154 | act_vbi_lines = min_vbi_lines; | ||
155 | else | ||
156 | act_vbi_lines = vbi_lines; | ||
157 | |||
158 | return act_vbi_lines; | ||
159 | } | ||
160 | |||
161 | static u32 fb_cvt_vtotal(struct fb_cvt_data *cvt) | ||
162 | { | ||
163 | u32 vtotal = cvt->yres/cvt->interlace; | ||
164 | |||
165 | vtotal += 2 * cvt->v_margin + cvt->interlace/2 + fb_cvt_vbi_lines(cvt); | ||
166 | vtotal |= cvt->interlace/2; | ||
167 | |||
168 | return vtotal; | ||
169 | } | ||
170 | |||
171 | static u32 fb_cvt_pixclock(struct fb_cvt_data *cvt) | ||
172 | { | ||
173 | u32 pixclock; | ||
174 | |||
175 | if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) | ||
176 | pixclock = (cvt->f_refresh * cvt->vtotal * cvt->htotal)/1000; | ||
177 | else | ||
178 | pixclock = (cvt->htotal * 1000000)/cvt->hperiod; | ||
179 | |||
180 | pixclock /= 250; | ||
181 | pixclock *= 250; | ||
182 | pixclock *= 1000; | ||
183 | |||
184 | return pixclock; | ||
185 | } | ||
186 | |||
187 | static u32 fb_cvt_aspect_ratio(struct fb_cvt_data *cvt) | ||
188 | { | ||
189 | u32 xres = cvt->xres; | ||
190 | u32 yres = cvt->yres; | ||
191 | u32 aspect = -1; | ||
192 | |||
193 | if (xres == (yres * 4)/3 && !((yres * 4) % 3)) | ||
194 | aspect = 0; | ||
195 | else if (xres == (yres * 16)/9 && !((yres * 16) % 9)) | ||
196 | aspect = 1; | ||
197 | else if (xres == (yres * 16)/10 && !((yres * 16) % 10)) | ||
198 | aspect = 2; | ||
199 | else if (xres == (yres * 5)/4 && !((yres * 5) % 4)) | ||
200 | aspect = 3; | ||
201 | else if (xres == (yres * 15)/9 && !((yres * 15) % 9)) | ||
202 | aspect = 4; | ||
203 | else { | ||
204 | printk(KERN_INFO "fbcvt: Aspect ratio not CVT " | ||
205 | "standard\n"); | ||
206 | aspect = 7; | ||
207 | cvt->status = 1; | ||
208 | } | ||
209 | |||
210 | return aspect; | ||
211 | } | ||
212 | |||
213 | static void fb_cvt_print_name(struct fb_cvt_data *cvt) | ||
214 | { | ||
215 | u32 pixcount, pixcount_mod; | ||
216 | int cnt = 255, offset = 0, read = 0; | ||
217 | u8 *buf = kmalloc(256, GFP_KERNEL); | ||
218 | |||
219 | if (!buf) | ||
220 | return; | ||
221 | |||
222 | memset(buf, 0, 256); | ||
223 | pixcount = (cvt->xres * (cvt->yres/cvt->interlace))/1000000; | ||
224 | pixcount_mod = (cvt->xres * (cvt->yres/cvt->interlace)) % 1000000; | ||
225 | pixcount_mod /= 1000; | ||
226 | |||
227 | read = snprintf(buf+offset, cnt, "fbcvt: %dx%d@%d: CVT Name - ", | ||
228 | cvt->xres, cvt->yres, cvt->refresh); | ||
229 | offset += read; | ||
230 | cnt -= read; | ||
231 | |||
232 | if (cvt->status) | ||
233 | snprintf(buf+offset, cnt, "Not a CVT standard - %d.%03d Mega " | ||
234 | "Pixel Image\n", pixcount, pixcount_mod); | ||
235 | else { | ||
236 | if (pixcount) { | ||
237 | read = snprintf(buf+offset, cnt, "%d", pixcount); | ||
238 | cnt -= read; | ||
239 | offset += read; | ||
240 | } | ||
241 | |||
242 | read = snprintf(buf+offset, cnt, ".%03dM", pixcount_mod); | ||
243 | cnt -= read; | ||
244 | offset += read; | ||
245 | |||
246 | if (cvt->aspect_ratio == 0) | ||
247 | read = snprintf(buf+offset, cnt, "3"); | ||
248 | else if (cvt->aspect_ratio == 3) | ||
249 | read = snprintf(buf+offset, cnt, "4"); | ||
250 | else if (cvt->aspect_ratio == 1 || cvt->aspect_ratio == 4) | ||
251 | read = snprintf(buf+offset, cnt, "9"); | ||
252 | else if (cvt->aspect_ratio == 2) | ||
253 | read = snprintf(buf+offset, cnt, "A"); | ||
254 | else | ||
255 | read = 0; | ||
256 | cnt -= read; | ||
257 | offset += read; | ||
258 | |||
259 | if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) { | ||
260 | read = snprintf(buf+offset, cnt, "-R"); | ||
261 | cnt -= read; | ||
262 | offset += read; | ||
263 | } | ||
264 | } | ||
265 | |||
266 | printk(KERN_INFO "%s\n", buf); | ||
267 | kfree(buf); | ||
268 | } | ||
269 | |||
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_front_porch; | ||
276 | mode->right_margin = cvt->h_back_porch; | ||
277 | mode->hsync_len = cvt->hsync; | ||
278 | mode->upper_margin = cvt->v_front_porch; | ||
279 | mode->lower_margin = cvt->v_back_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 | } | ||
289 | |||
290 | /* | ||
291 | * fb_find_mode_cvt - calculate mode using VESA(TM) CVT | ||
292 | * @mode: pointer to fb_videomode; xres, yres, refresh and vmode must be | ||
293 | * pre-filled with the desired values | ||
294 | * @margins: add margin to calculation (1.8% of xres and yres) | ||
295 | * @rb: compute with reduced blanking (for flatpanels) | ||
296 | * | ||
297 | * RETURNS: | ||
298 | * 0 for success | ||
299 | * @mode is filled with computed values. If interlaced, the refresh field | ||
300 | * will be filled with the field rate (2x the frame rate) | ||
301 | * | ||
302 | * DESCRIPTION: | ||
303 | * Computes video timings using VESA(TM) Coordinated Video Timings | ||
304 | */ | ||
305 | int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb) | ||
306 | { | ||
307 | struct fb_cvt_data cvt; | ||
308 | |||
309 | memset(&cvt, 0, sizeof(cvt)); | ||
310 | |||
311 | if (margins) | ||
312 | cvt.flags |= FB_CVT_FLAG_MARGINS; | ||
313 | |||
314 | if (rb) | ||
315 | cvt.flags |= FB_CVT_FLAG_REDUCED_BLANK; | ||
316 | |||
317 | if (mode->vmode & FB_VMODE_INTERLACED) | ||
318 | cvt.flags |= FB_CVT_FLAG_INTERLACED; | ||
319 | |||
320 | cvt.xres = mode->xres; | ||
321 | cvt.yres = mode->yres; | ||
322 | cvt.refresh = mode->refresh; | ||
323 | cvt.f_refresh = cvt.refresh; | ||
324 | cvt.interlace = 1; | ||
325 | |||
326 | if (!cvt.xres || !cvt.yres || !cvt.refresh) { | ||
327 | printk(KERN_INFO "fbcvt: Invalid input parameters\n"); | ||
328 | return 1; | ||
329 | } | ||
330 | |||
331 | if (!(cvt.refresh == 50 || cvt.refresh == 60 || cvt.refresh == 70 || | ||
332 | cvt.refresh == 85)) { | ||
333 | printk(KERN_INFO "fbcvt: Refresh rate not CVT " | ||
334 | "standard\n"); | ||
335 | cvt.status = 1; | ||
336 | } | ||
337 | |||
338 | cvt.xres &= ~(FB_CVT_CELLSIZE - 1); | ||
339 | |||
340 | if (cvt.flags & FB_CVT_FLAG_INTERLACED) { | ||
341 | cvt.interlace = 2; | ||
342 | cvt.f_refresh *= 2; | ||
343 | } | ||
344 | |||
345 | if (cvt.flags & FB_CVT_FLAG_REDUCED_BLANK) { | ||
346 | if (cvt.refresh != 60) { | ||
347 | printk(KERN_INFO "fbcvt: 60Hz refresh rate " | ||
348 | "advised for reduced blanking\n"); | ||
349 | cvt.status = 1; | ||
350 | } | ||
351 | } | ||
352 | |||
353 | if (cvt.flags & FB_CVT_FLAG_MARGINS) { | ||
354 | cvt.h_margin = (cvt.xres * 18)/1000; | ||
355 | cvt.h_margin &= ~(FB_CVT_CELLSIZE - 1); | ||
356 | cvt.v_margin = ((cvt.yres/cvt.interlace)* 18)/1000; | ||
357 | } | ||
358 | |||
359 | cvt.aspect_ratio = fb_cvt_aspect_ratio(&cvt); | ||
360 | cvt.active_pixels = cvt.xres + 2 * cvt.h_margin; | ||
361 | cvt.hperiod = fb_cvt_hperiod(&cvt); | ||
362 | cvt.vsync = fb_cvt_vbi_tab[cvt.aspect_ratio]; | ||
363 | cvt.vtotal = fb_cvt_vtotal(&cvt); | ||
364 | cvt.hblank = fb_cvt_hblank(&cvt); | ||
365 | cvt.htotal = cvt.active_pixels + cvt.hblank; | ||
366 | cvt.hsync = fb_cvt_hsync(&cvt); | ||
367 | cvt.pixclock = fb_cvt_pixclock(&cvt); | ||
368 | cvt.hfreq = cvt.pixclock/cvt.htotal; | ||
369 | cvt.h_back_porch = cvt.hblank/2 + cvt.h_margin; | ||
370 | cvt.h_front_porch = cvt.hblank - cvt.hsync - cvt.h_back_porch + | ||
371 | 2 * cvt.h_margin; | ||
372 | cvt.v_back_porch = 3 + cvt.v_margin; | ||
373 | cvt.v_front_porch = cvt.vtotal - cvt.yres/cvt.interlace - | ||
374 | cvt.v_back_porch - cvt.vsync; | ||
375 | fb_cvt_print_name(&cvt); | ||
376 | fb_cvt_convert_to_mode(&cvt, mode); | ||
377 | |||
378 | return 0; | ||
379 | } | ||
380 | EXPORT_SYMBOL(fb_find_mode_cvt); | ||
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index a815f5e2fcb5..71b55070bdb9 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -1029,6 +1029,7 @@ register_framebuffer(struct fb_info *fb_info) | |||
1029 | { | 1029 | { |
1030 | int i; | 1030 | int i; |
1031 | struct fb_event event; | 1031 | struct fb_event event; |
1032 | struct fb_videomode mode; | ||
1032 | 1033 | ||
1033 | if (num_registered_fb == FB_MAX) | 1034 | if (num_registered_fb == FB_MAX) |
1034 | return -ENXIO; | 1035 | return -ENXIO; |
@@ -1059,16 +1060,11 @@ register_framebuffer(struct fb_info *fb_info) | |||
1059 | } | 1060 | } |
1060 | fb_info->pixmap.offset = 0; | 1061 | fb_info->pixmap.offset = 0; |
1061 | 1062 | ||
1062 | if (!fb_info->modelist.prev || | 1063 | if (!fb_info->modelist.prev || !fb_info->modelist.next) |
1063 | !fb_info->modelist.next || | ||
1064 | list_empty(&fb_info->modelist)) { | ||
1065 | struct fb_videomode mode; | ||
1066 | |||
1067 | INIT_LIST_HEAD(&fb_info->modelist); | 1064 | INIT_LIST_HEAD(&fb_info->modelist); |
1068 | fb_var_to_videomode(&mode, &fb_info->var); | ||
1069 | fb_add_videomode(&mode, &fb_info->modelist); | ||
1070 | } | ||
1071 | 1065 | ||
1066 | fb_var_to_videomode(&mode, &fb_info->var); | ||
1067 | fb_add_videomode(&mode, &fb_info->modelist); | ||
1072 | registered_fb[i] = fb_info; | 1068 | registered_fb[i] = fb_info; |
1073 | 1069 | ||
1074 | devfs_mk_cdev(MKDEV(FB_MAJOR, i), | 1070 | devfs_mk_cdev(MKDEV(FB_MAJOR, i), |
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c index 3edc9f49344b..47516c44a390 100644 --- a/drivers/video/modedb.c +++ b/drivers/video/modedb.c | |||
@@ -456,12 +456,22 @@ static int fb_try_mode(struct fb_var_screeninfo *var, struct fb_info *info, | |||
456 | * | 456 | * |
457 | * Valid mode specifiers for @mode_option: | 457 | * Valid mode specifiers for @mode_option: |
458 | * | 458 | * |
459 | * <xres>x<yres>[-<bpp>][@<refresh>] or | 459 | * <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m] or |
460 | * <name>[-<bpp>][@<refresh>] | 460 | * <name>[-<bpp>][@<refresh>] |
461 | * | 461 | * |
462 | * with <xres>, <yres>, <bpp> and <refresh> decimal numbers and | 462 | * with <xres>, <yres>, <bpp> and <refresh> decimal numbers and |
463 | * <name> a string. | 463 | * <name> a string. |
464 | * | 464 | * |
465 | * If 'M' is present after yres (and before refresh/bpp if present), | ||
466 | * the function will compute the timings using VESA(tm) Coordinated | ||
467 | * Video Timings (CVT). If 'R' is present after 'M', will compute with | ||
468 | * reduced blanking (for flatpanels). If 'i' is present, compute | ||
469 | * interlaced mode. If 'm' is present, add margins equal to 1.8% | ||
470 | * of xres rounded down to 8 pixels, and 1.8% of yres. The char | ||
471 | * 'i' and 'm' must be after 'M' and 'R'. Example: | ||
472 | * | ||
473 | * 1024x768MR-8@60m - Reduced blank with margins at 60Hz. | ||
474 | * | ||
465 | * NOTE: The passed struct @var is _not_ cleared! This allows you | 475 | * NOTE: The passed struct @var is _not_ cleared! This allows you |
466 | * to supply values for e.g. the grayscale and accel_flags fields. | 476 | * to supply values for e.g. the grayscale and accel_flags fields. |
467 | * | 477 | * |
@@ -495,7 +505,7 @@ int fb_find_mode(struct fb_var_screeninfo *var, | |||
495 | unsigned int namelen = strlen(name); | 505 | unsigned int namelen = strlen(name); |
496 | int res_specified = 0, bpp_specified = 0, refresh_specified = 0; | 506 | int res_specified = 0, bpp_specified = 0, refresh_specified = 0; |
497 | unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0; | 507 | unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0; |
498 | int yres_specified = 0; | 508 | int yres_specified = 0, cvt = 0, rb = 0, interlace = 0, margins = 0; |
499 | u32 best, diff; | 509 | u32 best, diff; |
500 | 510 | ||
501 | for (i = namelen-1; i >= 0; i--) { | 511 | for (i = namelen-1; i >= 0; i--) { |
@@ -506,6 +516,8 @@ int fb_find_mode(struct fb_var_screeninfo *var, | |||
506 | !yres_specified) { | 516 | !yres_specified) { |
507 | refresh = my_atoi(&name[i+1]); | 517 | refresh = my_atoi(&name[i+1]); |
508 | refresh_specified = 1; | 518 | refresh_specified = 1; |
519 | if (cvt || rb) | ||
520 | cvt = 0; | ||
509 | } else | 521 | } else |
510 | goto done; | 522 | goto done; |
511 | break; | 523 | break; |
@@ -514,6 +526,8 @@ int fb_find_mode(struct fb_var_screeninfo *var, | |||
514 | if (!bpp_specified && !yres_specified) { | 526 | if (!bpp_specified && !yres_specified) { |
515 | bpp = my_atoi(&name[i+1]); | 527 | bpp = my_atoi(&name[i+1]); |
516 | bpp_specified = 1; | 528 | bpp_specified = 1; |
529 | if (cvt || rb) | ||
530 | cvt = 0; | ||
517 | } else | 531 | } else |
518 | goto done; | 532 | goto done; |
519 | break; | 533 | break; |
@@ -526,6 +540,22 @@ int fb_find_mode(struct fb_var_screeninfo *var, | |||
526 | break; | 540 | break; |
527 | case '0'...'9': | 541 | case '0'...'9': |
528 | break; | 542 | break; |
543 | case 'M': | ||
544 | if (!yres_specified) | ||
545 | cvt = 1; | ||
546 | break; | ||
547 | case 'R': | ||
548 | if (!cvt) | ||
549 | rb = 1; | ||
550 | break; | ||
551 | case 'm': | ||
552 | if (!cvt) | ||
553 | margins = 1; | ||
554 | break; | ||
555 | case 'i': | ||
556 | if (!cvt) | ||
557 | interlace = 1; | ||
558 | break; | ||
529 | default: | 559 | default: |
530 | goto done; | 560 | goto done; |
531 | } | 561 | } |
@@ -535,6 +565,34 @@ int fb_find_mode(struct fb_var_screeninfo *var, | |||
535 | res_specified = 1; | 565 | res_specified = 1; |
536 | } | 566 | } |
537 | done: | 567 | done: |
568 | if (cvt) { | ||
569 | struct fb_videomode cvt_mode; | ||
570 | int ret; | ||
571 | |||
572 | DPRINTK("CVT mode %dx%d@%dHz%s%s%s\n", xres, yres, | ||
573 | (refresh) ? refresh : 60, (rb) ? " reduced blanking" : | ||
574 | "", (margins) ? " with margins" : "", (interlace) ? | ||
575 | " interlaced" : ""); | ||
576 | |||
577 | cvt_mode.xres = xres; | ||
578 | cvt_mode.yres = yres; | ||
579 | cvt_mode.refresh = (refresh) ? refresh : 60; | ||
580 | |||
581 | if (interlace) | ||
582 | cvt_mode.vmode |= FB_VMODE_INTERLACED; | ||
583 | else | ||
584 | cvt_mode.vmode &= ~FB_VMODE_INTERLACED; | ||
585 | |||
586 | ret = fb_find_mode_cvt(&cvt_mode, margins, rb); | ||
587 | |||
588 | if (!ret && !fb_try_mode(var, info, &cvt_mode, bpp)) { | ||
589 | DPRINTK("modedb CVT: CVT mode ok\n"); | ||
590 | return 1; | ||
591 | } | ||
592 | |||
593 | DPRINTK("CVT mode invalid, getting mode from database\n"); | ||
594 | } | ||
595 | |||
538 | DPRINTK("Trying specified video mode%s %ix%i\n", | 596 | DPRINTK("Trying specified video mode%s %ix%i\n", |
539 | refresh_specified ? "" : " (ignoring refresh rate)", xres, yres); | 597 | refresh_specified ? "" : " (ignoring refresh rate)", xres, yres); |
540 | 598 | ||
diff --git a/include/linux/fb.h b/include/linux/fb.h index 34814a0b2378..9a4f035e9fdc 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h | |||
@@ -866,6 +866,7 @@ extern const unsigned char *fb_firmware_edid(struct device *device); | |||
866 | extern void fb_edid_to_monspecs(unsigned char *edid, | 866 | extern void fb_edid_to_monspecs(unsigned char *edid, |
867 | struct fb_monspecs *specs); | 867 | struct fb_monspecs *specs); |
868 | extern void fb_destroy_modedb(struct fb_videomode *modedb); | 868 | extern void fb_destroy_modedb(struct fb_videomode *modedb); |
869 | extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb); | ||
869 | 870 | ||
870 | /* drivers/video/modedb.c */ | 871 | /* drivers/video/modedb.c */ |
871 | #define VESA_MODEDB_SIZE 34 | 872 | #define VESA_MODEDB_SIZE 34 |