diff options
author | Chris Larson <kergoth@openedhand.com> | 2006-10-16 16:14:33 +0000 |
---|---|---|
committer | Chris Larson <kergoth@openedhand.com> | 2006-10-16 16:14:33 +0000 |
commit | 53592b948dd587111795c4b8880d480b389e1682 (patch) | |
tree | 8531718b88f70c4c75c056bbe349ad5b26cba1a0 | |
parent | 573776731208f6e1105495761240a6a0b0954997 (diff) | |
download | poky-53592b948dd587111795c4b8880d480b389e1682.tar.gz |
Add vesafb-tng patch to linux-openzaurus.
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@801 311d38ba-8fff-0310-9ca6-ca027cbcb966
3 files changed, 3096 insertions, 3 deletions
diff --git a/meta/packages/linux/linux-openzaurus-2.6.17/defconfig-qemux86 b/meta/packages/linux/linux-openzaurus-2.6.17/defconfig-qemux86 index 1a58023f84..b9910758c5 100644 --- a/meta/packages/linux/linux-openzaurus-2.6.17/defconfig-qemux86 +++ b/meta/packages/linux/linux-openzaurus-2.6.17/defconfig-qemux86 | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Automatically generated make config: don't edit | 2 | # Automatically generated make config: don't edit |
3 | # Linux kernel version: 2.6.17 | 3 | # Linux kernel version: 2.6.17 |
4 | # Wed Aug 23 11:24:17 2006 | 4 | # Mon Oct 16 19:42:42 2006 |
5 | # | 5 | # |
6 | CONFIG_X86_32=y | 6 | CONFIG_X86_32=y |
7 | CONFIG_SEMAPHORE_SLEEPERS=y | 7 | CONFIG_SEMAPHORE_SLEEPERS=y |
@@ -990,7 +990,7 @@ CONFIG_FB_CFB_COPYAREA=y | |||
990 | CONFIG_FB_CFB_IMAGEBLIT=y | 990 | CONFIG_FB_CFB_IMAGEBLIT=y |
991 | # CONFIG_FB_MACMODES is not set | 991 | # CONFIG_FB_MACMODES is not set |
992 | CONFIG_FB_FIRMWARE_EDID=y | 992 | CONFIG_FB_FIRMWARE_EDID=y |
993 | # CONFIG_FB_MODE_HELPERS is not set | 993 | CONFIG_FB_MODE_HELPERS=y |
994 | # CONFIG_FB_TILEBLITTING is not set | 994 | # CONFIG_FB_TILEBLITTING is not set |
995 | # CONFIG_FB_CIRRUS is not set | 995 | # CONFIG_FB_CIRRUS is not set |
996 | # CONFIG_FB_PM2 is not set | 996 | # CONFIG_FB_PM2 is not set |
@@ -1000,6 +1000,9 @@ CONFIG_FB_FIRMWARE_EDID=y | |||
1000 | # CONFIG_FB_IMSTT is not set | 1000 | # CONFIG_FB_IMSTT is not set |
1001 | CONFIG_FB_VGA16=y | 1001 | CONFIG_FB_VGA16=y |
1002 | CONFIG_FB_VESA=y | 1002 | CONFIG_FB_VESA=y |
1003 | # CONFIG_FB_VESA_STD is not set | ||
1004 | CONFIG_FB_VESA_TNG=y | ||
1005 | CONFIG_FB_VESA_DEFAULT_MODE="640x480-32@60" | ||
1003 | CONFIG_VIDEO_SELECT=y | 1006 | CONFIG_VIDEO_SELECT=y |
1004 | # CONFIG_FB_HGA is not set | 1007 | # CONFIG_FB_HGA is not set |
1005 | # CONFIG_FB_S1D13XXX is not set | 1008 | # CONFIG_FB_S1D13XXX is not set |
diff --git a/meta/packages/linux/linux-openzaurus-2.6.17/vesafb-tng-1.0-rc2-git-20060629.patch b/meta/packages/linux/linux-openzaurus-2.6.17/vesafb-tng-1.0-rc2-git-20060629.patch new file mode 100644 index 0000000000..188ce6094e --- /dev/null +++ b/meta/packages/linux/linux-openzaurus-2.6.17/vesafb-tng-1.0-rc2-git-20060629.patch | |||
@@ -0,0 +1,3089 @@ | |||
1 | # Patch generated against a6047eef1c465c38aacfbdab193161b3f0cd144 | ||
2 | --- | ||
3 | # Documentation/fb/vesafb.txt | 250 ++++-- | ||
4 | # arch/i386/boot/video.S | 12 | ||
5 | # drivers/video/Kconfig | 56 + | ||
6 | # drivers/video/Makefile | 6 | ||
7 | # drivers/video/fbmem.c | 1 | ||
8 | # drivers/video/modedb.c | 1 | ||
9 | # drivers/video/vesafb-thread.c | 727 +++++++++++++++++++ | ||
10 | # drivers/video/vesafb-tng.c | 1598 ++++++++++++++++++++++++++++++++++++++++++ | ||
11 | # include/linux/sched.h | 2 | ||
12 | # include/video/vesa.h | 150 +++ | ||
13 | # kernel/fork.c | 35 | ||
14 | # mm/memory.c | 1 | ||
15 | # mm/mmap.c | 1 | ||
16 | # 13 files changed, 2748 insertions(+), 92 deletions(-) | ||
17 | # | ||
18 | --- linux-2.6.17.orig/Documentation/fb/vesafb.txt | ||
19 | +++ linux-2.6.17/Documentation/fb/vesafb.txt | ||
20 | @@ -2,16 +2,18 @@ | ||
21 | What is vesafb? | ||
22 | =============== | ||
23 | |||
24 | -This is a generic driver for a graphic framebuffer on intel boxes. | ||
25 | +Vesafb is a generic framebuffer driver for x86 and x86_64 boxes. | ||
26 | |||
27 | -The idea is simple: Turn on graphics mode at boot time with the help | ||
28 | -of the BIOS, and use this as framebuffer device /dev/fb0, like the m68k | ||
29 | -(and other) ports do. | ||
30 | +VESA BIOS Extensions Version 2.0 are required, because we need access to | ||
31 | +a linear frame buffer. VBE 3.0 is required if you want to use modes with a | ||
32 | +higher (than the standard 60 Hz) refresh rate. | ||
33 | |||
34 | -This means we decide at boot time whenever we want to run in text or | ||
35 | -graphics mode. Switching mode later on (in protected mode) is | ||
36 | -impossible; BIOS calls work in real mode only. VESA BIOS Extensions | ||
37 | -Version 2.0 are required, because we need a linear frame buffer. | ||
38 | +The VESA framebuffer driver comes in two flavors - the standard 'vesafb' | ||
39 | +and 'vesafb-tng'. Vesafb-tng is available only on 32-bit x86 due to the | ||
40 | +technology it uses (vm86). Vesafb-tng has more features than vesafb | ||
41 | +(adjusting the refresh rate on VBE 3.0 compliant boards, switching the | ||
42 | +video mode without rebooting, selecting a mode by providing its | ||
43 | +modedb name, and more). | ||
44 | |||
45 | Advantages: | ||
46 | |||
47 | @@ -29,26 +31,35 @@ Disadvantages: | ||
48 | How to use it? | ||
49 | ============== | ||
50 | |||
51 | -Switching modes is done using the vga=... boot parameter. Read | ||
52 | -Documentation/svga.txt for details. | ||
53 | +If you are running a 32-bit x86 system and you decide to use vesafb-tng, | ||
54 | +you can either compile the driver into the kernel or use it as a module. | ||
55 | +The graphics mode you want to use is in both cases specified using the | ||
56 | +standard modedb format. | ||
57 | |||
58 | -You should compile in both vgacon (for text mode) and vesafb (for | ||
59 | -graphics mode). Which of them takes over the console depends on | ||
60 | -whenever the specified mode is text or graphics. | ||
61 | +If your system doesn't support vm86 calls, things get a little more tricky. | ||
62 | +Since on such systems you can't do BIOS calls from protected mode in which | ||
63 | +kernel runs, you have to decide at boot time whenever you want to run in text | ||
64 | +or in graphics mode. Switching mode later on is impossible. Switching modes | ||
65 | +is done using the vga=... boot parameter. Read Documentation/svga.txt for | ||
66 | +details. Below is a more detailed description of what to do on systems using | ||
67 | +the standard vesafb driver. | ||
68 | |||
69 | -The graphic modes are NOT in the list which you get if you boot with | ||
70 | -vga=ask and hit return. The mode you wish to use is derived from the | ||
71 | -VESA mode number. Here are those VESA mode numbers: | ||
72 | +You should compile in both vgacon (for text mode) and vesafb (for graphics | ||
73 | +mode). Which of them takes over the console depends on whenever the | ||
74 | +specified mode is text or graphics. | ||
75 | + | ||
76 | +The graphic modes are NOT in the list which you get if you boot with vga=ask | ||
77 | +and hit return. The mode you wish to use is derived from the VESA mode number. | ||
78 | +Here are those VESA mode numbers: | ||
79 | |||
80 | | 640x480 800x600 1024x768 1280x1024 | ||
81 | ----+------------------------------------- | ||
82 | -256 | 0x101 0x103 0x105 0x107 | ||
83 | -32k | 0x110 0x113 0x116 0x119 | ||
84 | -64k | 0x111 0x114 0x117 0x11A | ||
85 | -16M | 0x112 0x115 0x118 0x11B | ||
86 | +256 | 0x101 0x103 0x105 0x107 | ||
87 | +32k | 0x110 0x113 0x116 0x119 | ||
88 | +64k | 0x111 0x114 0x117 0x11A | ||
89 | +16M | 0x112 0x115 0x118 0x11B | ||
90 | |||
91 | -The video mode number of the Linux kernel is the VESA mode number plus | ||
92 | -0x200. | ||
93 | +The video mode number of the Linux kernel is the VESA mode number plus 0x200. | ||
94 | |||
95 | Linux_kernel_mode_number = VESA_mode_number + 0x200 | ||
96 | |||
97 | @@ -56,15 +67,15 @@ So the table for the Kernel mode numbers | ||
98 | |||
99 | | 640x480 800x600 1024x768 1280x1024 | ||
100 | ----+------------------------------------- | ||
101 | -256 | 0x301 0x303 0x305 0x307 | ||
102 | -32k | 0x310 0x313 0x316 0x319 | ||
103 | -64k | 0x311 0x314 0x317 0x31A | ||
104 | -16M | 0x312 0x315 0x318 0x31B | ||
105 | +256 | 0x301 0x303 0x305 0x307 | ||
106 | +32k | 0x310 0x313 0x316 0x319 | ||
107 | +64k | 0x311 0x314 0x317 0x31A | ||
108 | +16M | 0x312 0x315 0x318 0x31B | ||
109 | |||
110 | -To enable one of those modes you have to specify "vga=ask" in the | ||
111 | -lilo.conf file and rerun LILO. Then you can type in the desired | ||
112 | -mode at the "vga=ask" prompt. For example if you like to use | ||
113 | -1024x768x256 colors you have to say "305" at this prompt. | ||
114 | +To enable one of those modes you have to specify "vga=ask" in the lilo.conf | ||
115 | +file and rerun LILO. Then you can type in the desired mode at the "vga=ask" | ||
116 | +prompt. For example if you like to use 1024x768x256 colors you have to say | ||
117 | +"305" at this prompt. | ||
118 | |||
119 | If this does not work, this might be because your BIOS does not support | ||
120 | linear framebuffers or because it does not support this mode at all. | ||
121 | @@ -72,11 +83,12 @@ Even if your board does, it might be the | ||
122 | Extensions v2.0 are required, 1.2 is NOT sufficient. You will get a | ||
123 | "bad mode number" message if something goes wrong. | ||
124 | |||
125 | -1. Note: LILO cannot handle hex, for booting directly with | ||
126 | +1. Note: LILO cannot handle hex, for booting directly with | ||
127 | "vga=mode-number" you have to transform the numbers to decimal. | ||
128 | 2. Note: Some newer versions of LILO appear to work with those hex values, | ||
129 | if you set the 0x in front of the numbers. | ||
130 | |||
131 | + | ||
132 | X11 | ||
133 | === | ||
134 | |||
135 | @@ -84,98 +96,164 @@ XF68_FBDev should work just fine, but it | ||
136 | another (accelerated) X-Server like XF86_SVGA might or might not work. | ||
137 | It depends on X-Server and graphics board. | ||
138 | |||
139 | -The X-Server must restore the video mode correctly, else you end up | ||
140 | +The X-Server must restore the video mode correctly, or else you end up | ||
141 | with a broken console (and vesafb cannot do anything about this). | ||
142 | +With vesafb-tng chances are that the console will be restored properly | ||
143 | +even if the X server messes up the video mode. | ||
144 | |||
145 | |||
146 | Refresh rates | ||
147 | ============= | ||
148 | |||
149 | -There is no way to change the vesafb video mode and/or timings after | ||
150 | -booting linux. If you are not happy with the 60 Hz refresh rate, you | ||
151 | -have these options: | ||
152 | +With VBE 3.0 compatible BIOSes and vesafb-tng it is possible to change | ||
153 | +the refresh rate either at boot time (by specifying the @<rr> part of | ||
154 | +the mode name) or later, using the fbset utility. | ||
155 | |||
156 | - * configure and load the DOS-Tools for your the graphics board (if | ||
157 | - available) and boot linux with loadlin. | ||
158 | - * use a native driver (matroxfb/atyfb) instead if vesafb. If none | ||
159 | +If you want to use the default BIOS refresh rate while switching modes | ||
160 | +on a running system, set pixclock to 0. | ||
161 | + | ||
162 | +With VBE 2.0 there is no way to change the mode timings after booting | ||
163 | +Linux. If you are not happy with the 60 Hz refresh rate, you have | ||
164 | +the following options: | ||
165 | + | ||
166 | + * Configure and load the DOS tools for your the graphics board (if | ||
167 | + available) and boot Linux with loadlin. | ||
168 | + * Use a native driver (matroxfb/atyfb) instead of vesafb. If none | ||
169 | is available, write a new one! | ||
170 | - * VBE 3.0 might work too. I have neither a gfx board with VBE 3.0 | ||
171 | - support nor the specs, so I have not checked this yet. | ||
172 | + * Use a BIOS editor to change the default refresh rate (such an | ||
173 | + editor does exist at least for ATI Radeon BIOSes). | ||
174 | + * If you're running a non-vm86 and VBE 3.0 compatible system, you can | ||
175 | + use a kernel patch (vesafb-rrc) to hard-code some mode timings in | ||
176 | + the kernel and use these while setting the video mode at boot time. | ||
177 | + | ||
178 | +Note that there are some boards (nVidia 59**, 57** and newer models) | ||
179 | +claiming that their Video BIOS is VBE 3.0 compliant, while ignoring the | ||
180 | +CRTC values provided by software such as vesafb-tng. You'll not be able | ||
181 | +to adjust the refresh rate if you're using one of these boards. | ||
182 | |||
183 | |||
184 | Configuration | ||
185 | ============= | ||
186 | |||
187 | -The VESA BIOS provides protected mode interface for changing | ||
188 | -some parameters. vesafb can use it for palette changes and | ||
189 | -to pan the display. It is turned off by default because it | ||
190 | -seems not to work with some BIOS versions, but there are options | ||
191 | -to turn it on. | ||
192 | +The VESA BIOS provides protected mode interface for changing some parameters. | ||
193 | +vesafb can use it for palette changes and to pan the display. It is turned | ||
194 | +off by default because it seems not to work with some BIOS versions, but | ||
195 | +there are options to turn it on. | ||
196 | |||
197 | -You can pass options to vesafb using "video=vesafb:option" on | ||
198 | -the kernel command line. Multiple options should be separated | ||
199 | -by comma, like this: "video=vesafb:ypan,invers" | ||
200 | +You can pass options to vesafb using "video=vesafb:option" on the kernel | ||
201 | +command line. Multiple options should be separated by a comma, like this: | ||
202 | +"video=vesafb:ypan,1024x768-32@85" | ||
203 | |||
204 | -Accepted options: | ||
205 | +Note that vesafb-tng still uses the "video=vesafb:option" format of the | ||
206 | +kernel command line video parameter. "video=vesafb-tng:xxx" is incorrect. | ||
207 | |||
208 | -invers no comment... | ||
209 | +Accepted options (both vesafb and vesafb-tng): | ||
210 | |||
211 | -ypan enable display panning using the VESA protected mode | ||
212 | - interface. The visible screen is just a window of the | ||
213 | - video memory, console scrolling is done by changing the | ||
214 | - start of the window. | ||
215 | - pro: * scrolling (fullscreen) is fast, because there is | ||
216 | - no need to copy around data. | ||
217 | - * You'll get scrollback (the Shift-PgUp thing), | ||
218 | - the video memory can be used as scrollback buffer | ||
219 | - kontra: * scrolling only parts of the screen causes some | ||
220 | - ugly flicker effects (boot logo flickers for | ||
221 | - example). | ||
222 | +ypan Enable display panning using the VESA protected mode interface | ||
223 | + The visible screen is just a window of the video memory, | ||
224 | + console scrolling is done by changing the start of the window. | ||
225 | + pro: * scrolling (fullscreen) is fast, because there is | ||
226 | + no need to copy around data. | ||
227 | + * you'll get scrollback (the Shift-PgUp thing), | ||
228 | + the video memory can be used as scrollback buffer | ||
229 | + con: * scrolling only parts of the screen causes some | ||
230 | + ugly flicker effects (boot logo flickers for | ||
231 | + example). | ||
232 | |||
233 | -ywrap Same as ypan, but assumes your gfx board can wrap-around | ||
234 | - the video memory (i.e. starts reading from top if it | ||
235 | - reaches the end of video memory). Faster than ypan. | ||
236 | +ywrap Same as ypan, but assumes your gfx board can wrap-around the video | ||
237 | + memory (i.e. starts reading from top if it reaches the end of | ||
238 | + video memory). Faster than ypan. | ||
239 | |||
240 | -redraw scroll by redrawing the affected part of the screen, this | ||
241 | - is the safe (and slow) default. | ||
242 | +redraw Scroll by redrawing the affected part of the screen, this is the | ||
243 | + safe (and slow) default. | ||
244 | |||
245 | +vgapal Use the standard VGA registers for palette changes. | ||
246 | |||
247 | -vgapal Use the standard vga registers for palette changes. | ||
248 | - This is the default. | ||
249 | -pmipal Use the protected mode interface for palette changes. | ||
250 | +pmipal Use the protected mode interface for palette changes. | ||
251 | + This is the default is the protected mode interface is available. | ||
252 | |||
253 | -mtrr:n setup memory type range registers for the vesafb framebuffer | ||
254 | - where n: | ||
255 | - 0 - disabled (equivalent to nomtrr) (default) | ||
256 | - 1 - uncachable | ||
257 | - 2 - write-back | ||
258 | - 3 - write-combining | ||
259 | - 4 - write-through | ||
260 | +mtrr:n Setup memory type range registers for the vesafb framebuffer | ||
261 | + where n: | ||
262 | + 0 - disabled (equivalent to nomtrr) (default) | ||
263 | + 1 - uncachable | ||
264 | + 2 - write-back | ||
265 | + 3 - write-combining | ||
266 | + 4 - write-through | ||
267 | |||
268 | - If you see the following in dmesg, choose the type that matches the | ||
269 | - old one. In this example, use "mtrr:2". | ||
270 | + If you see the following in dmesg, choose the type that matches | ||
271 | + the old one. In this example, use "mtrr:2". | ||
272 | ... | ||
273 | mtrr: type mismatch for e0000000,8000000 old: write-back new: write-combining | ||
274 | ... | ||
275 | |||
276 | -nomtrr disable mtrr | ||
277 | +nomtrr Do not use memory type range registers for vesafb. | ||
278 | |||
279 | vremap:n | ||
280 | remap 'n' MiB of video RAM. If 0 or not specified, remap memory | ||
281 | - according to video mode. (2.5.66 patch/idea by Antonino Daplas | ||
282 | - reversed to give override possibility (allocate more fb memory | ||
283 | - than the kernel would) to 2.4 by tmb@iki.fi) | ||
284 | + according to video mode. (2.5.66 patch/idea by Antonino Daplas | ||
285 | + reversed to give override possibility (allocate more fb memory | ||
286 | + than the kernel would) to 2.4 by tmb@iki.fi) | ||
287 | |||
288 | vtotal:n | ||
289 | if the video BIOS of your card incorrectly determines the total | ||
290 | amount of video RAM, use this option to override the BIOS (in MiB). | ||
291 | |||
292 | -Have fun! | ||
293 | +Options accepted only by vesafb-tng: | ||
294 | |||
295 | - Gerd | ||
296 | +<mode> The mode you want to set, in the standard modedb format. Refer to | ||
297 | + modedb.txt for a detailed description. If you specify a mode that is | ||
298 | + not supported by your board's BIOS, vesafb-tng will attempt to set a | ||
299 | + similar mode. The list of supported modes can be found in | ||
300 | + /proc/fbx/modes, where x is the framebuffer number (usually 0). | ||
301 | + When vesafb-tng is compiled as a module, the mode string should be | ||
302 | + provided as a value of the parameter 'mode'. | ||
303 | + | ||
304 | +vbemode:x | ||
305 | + Force the use of VBE mode x. The mode will only be set if it's | ||
306 | + found in the VBE-provided list of supported modes. | ||
307 | + NOTE: The mode number 'x' should be specified in VESA mode number | ||
308 | + notation, not the Linux kernel one (eg. 257 instead of 769). | ||
309 | + HINT: If you use this option because normal <mode> parameter does | ||
310 | + not work for you and you use a X server, you'll probably want to | ||
311 | + set the 'nocrtc' option to ensure that the video mode is properly | ||
312 | + restored after console <-> X switches. | ||
313 | + | ||
314 | +nocrtc Do not use CRTC timings while setting the video mode. This option | ||
315 | + makes sence only with VBE 3.0 compliant systems. Use it if you have | ||
316 | + problems with modes set in the standard way. Note that using this | ||
317 | + option means that any refresh rate adjustments will be ignored | ||
318 | + and the refresh rate will stay at your BIOS default (60 Hz). | ||
319 | + | ||
320 | +noedid Do not try to fetch and use EDID-provided modes. | ||
321 | + | ||
322 | +noblank Disable hardware blanking. | ||
323 | + | ||
324 | +gtf Force the use of VESA's GTF (Generalized Timing Formula). Specifying | ||
325 | + this will cause vesafb to skip its internal modedb and EDID-modedb | ||
326 | + and jump straight to the GTF part of the code (normally used only if | ||
327 | + everything else failed). This can be useful if you want to get as | ||
328 | + much as possible from your graphics board but your BIOS doesn't | ||
329 | + support modes with the refresh rates you require. Note that you may | ||
330 | + need to specify the maxhf, maxvf and maxclk parameters if they are not | ||
331 | + provided by the EDID block. | ||
332 | + | ||
333 | +Additionally, the following parameters may be provided. They all override the | ||
334 | +EDID-provided values and BIOS defaults. Refer to your monitor's specs to get | ||
335 | +the correct values for maxhf, maxvf and maxclk for your hardware. | ||
336 | + | ||
337 | +maxhf:n Maximum horizontal frequency (in kHz). | ||
338 | +maxvf:n Maximum vertical frequency (in Hz). | ||
339 | +maxclk:n Maximum pixel clock (in MHz). | ||
340 | + | ||
341 | +Have fun! | ||
342 | |||
343 | -- | ||
344 | +Original document for the vesafb driver by | ||
345 | Gerd Knorr <kraxel@goldbach.in-berlin.de> | ||
346 | |||
347 | -Minor (mostly typo) changes | ||
348 | -by Nico Schmoigl <schmoigl@rumms.uni-mannheim.de> | ||
349 | +Minor (mostly typo) changes by | ||
350 | +Nico Schmoigl <schmoigl@rumms.uni-mannheim.de> | ||
351 | + | ||
352 | +Extended documentation for vm86, VBE 3.0 and vesafb-tng by | ||
353 | +Michal Januszewski <spock@gentoo.org> | ||
354 | + | ||
355 | --- linux-2.6.17.orig/arch/i386/boot/video.S | ||
356 | +++ linux-2.6.17/arch/i386/boot/video.S | ||
357 | @@ -165,10 +165,12 @@ basret: ret | ||
358 | # parameters in the default 80x25 mode -- these are set directly, | ||
359 | # because some very obscure BIOSes supply insane values. | ||
360 | mode_params: | ||
361 | +#ifdef CONFIG_FB_VESA_STD | ||
362 | #ifdef CONFIG_VIDEO_SELECT | ||
363 | cmpb $0, graphic_mode | ||
364 | jnz mopar_gr | ||
365 | #endif | ||
366 | +#endif | ||
367 | movb $0x03, %ah # Read cursor position | ||
368 | xorb %bh, %bh | ||
369 | int $0x10 | ||
370 | @@ -201,6 +203,7 @@ mopar2: movb %al, %fs:(PARAM_VIDEO_LINES | ||
371 | ret | ||
372 | |||
373 | #ifdef CONFIG_VIDEO_SELECT | ||
374 | +#ifdef CONFIG_FB_VESA_STD | ||
375 | # Fetching of VESA frame buffer parameters | ||
376 | mopar_gr: | ||
377 | leaw modelist+1024, %di | ||
378 | @@ -283,6 +286,7 @@ dac_done: | ||
379 | movw %es, %fs:(PARAM_VESAPM_SEG) | ||
380 | movw %di, %fs:(PARAM_VESAPM_OFF) | ||
381 | no_pm: ret | ||
382 | +#endif | ||
383 | |||
384 | # The video mode menu | ||
385 | mode_menu: | ||
386 | @@ -497,10 +501,12 @@ mode_set: | ||
387 | |||
388 | cmpb $VIDEO_FIRST_V7>>8, %ah | ||
389 | jz setv7 | ||
390 | - | ||
391 | + | ||
392 | +#ifdef CONFIG_FB_VESA_STD | ||
393 | cmpb $VIDEO_FIRST_VESA>>8, %ah | ||
394 | jnc check_vesa | ||
395 | - | ||
396 | +#endif | ||
397 | + | ||
398 | orb %ah, %ah | ||
399 | jz setmenu | ||
400 | |||
401 | @@ -572,6 +578,7 @@ setr1: lodsw | ||
402 | movw -4(%si), %ax # Fetch mode ID | ||
403 | jmp _m_s | ||
404 | |||
405 | +#ifdef CONFIG_FB_VESA_STD | ||
406 | check_vesa: | ||
407 | leaw modelist+1024, %di | ||
408 | subb $VIDEO_FIRST_VESA>>8, %bh | ||
409 | @@ -605,6 +612,7 @@ check_vesa: | ||
410 | ret | ||
411 | |||
412 | _setbad: jmp setbad # Ugly... | ||
413 | +#endif | ||
414 | |||
415 | # Recalculate vertical display end registers -- this fixes various | ||
416 | # inconsistencies of extended modes on many adapters. Called when | ||
417 | --- linux-2.6.17.orig/drivers/video/Kconfig | ||
418 | +++ linux-2.6.17/drivers/video/Kconfig | ||
419 | @@ -472,8 +472,22 @@ config FB_TGA | ||
420 | cards. Say Y if you have one of those. | ||
421 | |||
422 | config FB_VESA | ||
423 | - bool "VESA VGA graphics support" | ||
424 | - depends on (FB = y) && X86 | ||
425 | + tristate "VESA VGA graphics support" | ||
426 | + depends on (FB = y) && (X86 || X86_64) | ||
427 | + help | ||
428 | + This is the frame buffer device driver for generic VESA 2.0 | ||
429 | + compliant graphic cards. The older VESA 1.2 cards are not supported. | ||
430 | + You will get a boot time penguin logo at no additional cost. Please | ||
431 | + read <file:Documentation/fb/vesafb.txt>. If unsure, say Y. | ||
432 | + | ||
433 | +choice | ||
434 | + prompt "VESA driver type" | ||
435 | + depends on FB_VESA | ||
436 | + default FB_VESA_STD if X86_64 | ||
437 | + default FB_VESA_TNG if X86 | ||
438 | + | ||
439 | +config FB_VESA_STD | ||
440 | + bool "vesafb" | ||
441 | select FB_CFB_FILLRECT | ||
442 | select FB_CFB_COPYAREA | ||
443 | select FB_CFB_IMAGEBLIT | ||
444 | @@ -481,7 +495,43 @@ config FB_VESA | ||
445 | This is the frame buffer device driver for generic VESA 2.0 | ||
446 | compliant graphic cards. The older VESA 1.2 cards are not supported. | ||
447 | You will get a boot time penguin logo at no additional cost. Please | ||
448 | - read <file:Documentation/fb/vesafb.txt>. If unsure, say Y. | ||
449 | + read <file:Documentation/fb/vesafb.txt>. Choose this driver if you | ||
450 | + are experiencing problems with vesafb-tng or if you own a 64-bit system. | ||
451 | + | ||
452 | + Note that this driver cannot be compiled as a module. | ||
453 | + | ||
454 | +config FB_VESA_TNG | ||
455 | + bool "vesafb-tng" | ||
456 | + depends on !X86_64 | ||
457 | + select FB_MODE_HELPERS | ||
458 | + select FB_CFB_FILLRECT | ||
459 | + select FB_CFB_COPYAREA | ||
460 | + select FB_CFB_IMAGEBLIT | ||
461 | + help | ||
462 | + This is the frame buffer device driver for generic VESA 2.0 | ||
463 | + compliant graphic cards. It is capable of taking advantage of | ||
464 | + VBE 3.0 features. With this driver you will be able to adjust | ||
465 | + the refresh rate (VBE 3.0 compliant boards only) and change | ||
466 | + the graphic mode on-the-fly. | ||
467 | + | ||
468 | + You will also get a boot time penguin logo at no additional cost. Please | ||
469 | + read <file:Documentation/fb/vesafb.txt>. | ||
470 | + | ||
471 | +endchoice | ||
472 | + | ||
473 | +config FB_VESA_DEFAULT_MODE | ||
474 | + string "VESA default mode" | ||
475 | + depends on FB_VESA_TNG | ||
476 | + default "640x480@60" | ||
477 | + help | ||
478 | + This option is used to determine the default mode vesafb is | ||
479 | + supposed to switch to in case no mode is provided as a kernel | ||
480 | + command line parameter. | ||
481 | + | ||
482 | +config VIDEO_SELECT | ||
483 | + bool | ||
484 | + depends on FB_VESA | ||
485 | + default y | ||
486 | |||
487 | config VIDEO_SELECT | ||
488 | bool | ||
489 | --- linux-2.6.17.orig/drivers/video/Makefile | ||
490 | +++ linux-2.6.17/drivers/video/Makefile | ||
491 | @@ -97,7 +97,11 @@ obj-$(CONFIG_FB_IMX) += imx | ||
492 | obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o | ||
493 | |||
494 | # Platform or fallback drivers go here | ||
495 | -obj-$(CONFIG_FB_VESA) += vesafb.o | ||
496 | +ifeq ($(CONFIG_FB_VESA_STD),y) | ||
497 | + obj-y += vesafb.o | ||
498 | +else | ||
499 | + obj-$(CONFIG_FB_VESA) += vesafb-thread.o vesafb-tng.o | ||
500 | +endif | ||
501 | obj-$(CONFIG_FB_VGA16) += vga16fb.o vgastate.o | ||
502 | obj-$(CONFIG_FB_OF) += offb.o | ||
503 | |||
504 | --- linux-2.6.17.orig/drivers/video/fbmem.c | ||
505 | +++ linux-2.6.17/drivers/video/fbmem.c | ||
506 | @@ -1438,6 +1438,7 @@ fbmem_init(void) | ||
507 | printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class)); | ||
508 | fb_class = NULL; | ||
509 | } | ||
510 | + | ||
511 | return 0; | ||
512 | } | ||
513 | |||
514 | --- linux-2.6.17.orig/drivers/video/modedb.c | ||
515 | +++ linux-2.6.17/drivers/video/modedb.c | ||
516 | @@ -671,6 +671,7 @@ void fb_var_to_videomode(struct fb_video | ||
517 | { | ||
518 | u32 pixclock, hfreq, htotal, vtotal; | ||
519 | |||
520 | + mode->refresh = 0; | ||
521 | mode->name = NULL; | ||
522 | mode->xres = var->xres; | ||
523 | mode->yres = var->yres; | ||
524 | --- /dev/null | ||
525 | +++ linux-2.6.17/drivers/video/vesafb-thread.c | ||
526 | @@ -0,0 +1,727 @@ | ||
527 | +/* | ||
528 | + * Framebuffer driver for VBE 2.0+ compliant graphic boards. | ||
529 | + * Kernel thread and vm86 routines. | ||
530 | + * | ||
531 | + * (c) 2004-2006 Michal Januszewski <spock@gentoo.org> | ||
532 | + * | ||
533 | + */ | ||
534 | + | ||
535 | +#include <linux/config.h> | ||
536 | +#include <linux/slab.h> | ||
537 | +#include <linux/workqueue.h> | ||
538 | +#include <linux/completion.h> | ||
539 | +#include <linux/module.h> | ||
540 | +#include <linux/kernel.h> | ||
541 | +#include <linux/errno.h> | ||
542 | +#include <linux/mm.h> | ||
543 | +#include <linux/delay.h> | ||
544 | +#include <linux/signal.h> | ||
545 | +#include <linux/suspend.h> | ||
546 | +#include <linux/unistd.h> | ||
547 | +#include <video/vesa.h> | ||
548 | +#include <video/edid.h> | ||
549 | +#include <asm/mman.h> | ||
550 | +#include <asm/page.h> | ||
551 | +#include <asm/vm86.h> | ||
552 | +#include <asm/thread_info.h> | ||
553 | +#include <asm/uaccess.h> | ||
554 | +#include <asm/mmu_context.h> | ||
555 | +#include "edid.h" | ||
556 | + | ||
557 | +#ifdef MODULE | ||
558 | +int errno; | ||
559 | +#endif | ||
560 | + | ||
561 | +static DECLARE_COMPLETION(vesafb_th_completion); | ||
562 | +static DECLARE_MUTEX(vesafb_task_list_sem); | ||
563 | +static LIST_HEAD(vesafb_task_list); | ||
564 | +static DECLARE_WAIT_QUEUE_HEAD(vesafb_wait); | ||
565 | + | ||
566 | +static struct vm86_struct vm86; | ||
567 | +static int vesafb_pid = 0; | ||
568 | + | ||
569 | +_syscall3(int,ioperm,unsigned long, a, unsigned long, b, unsigned long, c); | ||
570 | +_syscall1(int,vm86old,struct vm86_struct __user*, v86); | ||
571 | + | ||
572 | +#define DEFAULT_VM86_FLAGS (IF_MASK | IOPL_MASK) | ||
573 | +#define VM86_PUSHW(x) \ | ||
574 | +do { \ | ||
575 | + vm86.regs.esp -= 2; \ | ||
576 | + *(u16*)(STACK_ADDR + vm86.regs.esp) = x; \ | ||
577 | +} while(0); | ||
578 | + | ||
579 | +/* Stack, the return code and buffers will be put into | ||
580 | + * one contiguous memory chunk: | ||
581 | + * | ||
582 | + * [ STACK | RET_CODE | BUFFER ] | ||
583 | + * | ||
584 | + * Some video BIOSes (sis6326) try to store data somewhere | ||
585 | + * in 0x7000-0x7fff, so we zeromap more memory to be safe. | ||
586 | + */ | ||
587 | +#define IVTBDA_SIZE PAGE_SIZE | ||
588 | +#define RET_CODE_SIZE 0x0010 | ||
589 | +#define STACK_SIZE 0x0500 | ||
590 | +#define BUFFER_SIZE 0x10000 | ||
591 | + | ||
592 | +/* The amount of memory that will be allocated should be a multiple | ||
593 | + * of PAGE_SIZE. */ | ||
594 | +#define __MEM_SIZE (RET_CODE_SIZE + STACK_SIZE + BUFFER_SIZE) | ||
595 | +#define REAL_MEM_SIZE (((__MEM_SIZE / PAGE_SIZE) + 1) * PAGE_SIZE) | ||
596 | + | ||
597 | +#define IVTBDA_ADDR 0x00000 | ||
598 | +#define STACK_ADDR (IVTBDA_ADDR + IVTBDA_SIZE) | ||
599 | +#define RET_CODE_ADDR (STACK_ADDR + STACK_SIZE) | ||
600 | +#define BUF_ADDR (RET_CODE_ADDR + RET_CODE_SIZE) | ||
601 | + | ||
602 | +#define FLAG_D (1 << 10) | ||
603 | + | ||
604 | +/* Segment prefix opcodes */ | ||
605 | +enum { | ||
606 | + P_CS = 0x2e, | ||
607 | + P_SS = 0x36, | ||
608 | + P_DS = 0x3e, | ||
609 | + P_ES = 0x26, | ||
610 | + P_FS = 0x64, | ||
611 | + P_GS = 0x65 | ||
612 | +}; | ||
613 | + | ||
614 | +/* Emulated vm86 ins instruction */ | ||
615 | +static void vm86_ins(int size) | ||
616 | +{ | ||
617 | + u32 edx, edi; | ||
618 | + edx = vm86.regs.edx & 0xffff; | ||
619 | + edi = (vm86.regs.edi & 0xffff) + (u32)(vm86.regs.es << 4); | ||
620 | + | ||
621 | + if (vm86.regs.eflags & FLAG_D) | ||
622 | + asm volatile ("std\n"); | ||
623 | + else | ||
624 | + asm volatile ("cld\n"); | ||
625 | + | ||
626 | + switch (size) { | ||
627 | + case 4: | ||
628 | + asm volatile ("insl\n" : "=D" (edi) : "d" (edx), "0" (edi)); | ||
629 | + break; | ||
630 | + case 2: | ||
631 | + asm volatile ("insw\n" : "=D" (edi) : "d" (edx), "0" (edi)); | ||
632 | + break; | ||
633 | + case 1: | ||
634 | + asm volatile ("insb\n" : "=D" (edi) : "d" (edx), "0" (edi)); | ||
635 | + break; | ||
636 | + } | ||
637 | + | ||
638 | + if (vm86.regs.eflags & FLAG_D) | ||
639 | + asm volatile ("cld\n"); | ||
640 | + | ||
641 | + edi -= (u32)(vm86.regs.es << 4); | ||
642 | + | ||
643 | + vm86.regs.edi &= 0xffff0000; | ||
644 | + vm86.regs.edi |= edi & 0xffff; | ||
645 | +} | ||
646 | + | ||
647 | +static void vm86_rep_ins(int size) | ||
648 | +{ | ||
649 | + u16 cx = vm86.regs.ecx; | ||
650 | + while (cx--) | ||
651 | + vm86_ins(size); | ||
652 | + | ||
653 | + vm86.regs.ecx &= 0xffff0000; | ||
654 | +} | ||
655 | + | ||
656 | +/* Emulated vm86 outs instruction */ | ||
657 | +static void vm86_outs(int size, int segment) | ||
658 | +{ | ||
659 | + u32 edx, esi, base; | ||
660 | + | ||
661 | + edx = vm86.regs.edx & 0xffff; | ||
662 | + esi = vm86.regs.esi & 0xffff; | ||
663 | + | ||
664 | + switch (segment) { | ||
665 | + case P_CS: base = vm86.regs.cs; break; | ||
666 | + case P_SS: base = vm86.regs.ss; break; | ||
667 | + case P_ES: base = vm86.regs.es; break; | ||
668 | + case P_FS: base = vm86.regs.fs; break; | ||
669 | + case P_GS: base = vm86.regs.gs; break; | ||
670 | + default: base = vm86.regs.ds; break; | ||
671 | + } | ||
672 | + | ||
673 | + esi += base << 4; | ||
674 | + | ||
675 | + if (vm86.regs.eflags & FLAG_D) | ||
676 | + asm volatile ("std\n"); | ||
677 | + else | ||
678 | + asm volatile ("cld\n"); | ||
679 | + | ||
680 | + switch (size) { | ||
681 | + case 4: | ||
682 | + asm volatile ("outsl\n" : "=S" (esi) : "d" (edx), "0" (esi)); | ||
683 | + break; | ||
684 | + case 2: | ||
685 | + asm volatile ("outsw\n" : "=S" (esi) : "d" (edx), "0" (esi)); | ||
686 | + break; | ||
687 | + case 1: | ||
688 | + asm volatile ("outsb\n" : "=S" (esi) : "d" (edx), "0" (esi)); | ||
689 | + break; | ||
690 | + } | ||
691 | + | ||
692 | + if (vm86.regs.eflags & FLAG_D) | ||
693 | + asm volatile ("cld"); | ||
694 | + | ||
695 | + esi -= base << 4; | ||
696 | + vm86.regs.esi &= 0xffff0000; | ||
697 | + vm86.regs.esi |= (esi & 0xffff); | ||
698 | +} | ||
699 | + | ||
700 | +static void vm86_rep_outs(int size, int segment) | ||
701 | +{ | ||
702 | + u16 cx = vm86.regs.ecx; | ||
703 | + while (cx--) | ||
704 | + vm86_outs(size, segment); | ||
705 | + | ||
706 | + vm86.regs.ecx &= 0xffff0000; | ||
707 | +} | ||
708 | + | ||
709 | +static int vm86_do_unknown(void) | ||
710 | +{ | ||
711 | + u8 data32 = 0, segment = P_DS, rep = 0; | ||
712 | + u8 *instr; | ||
713 | + int ret = 0, i = 0; | ||
714 | + | ||
715 | + instr = (u8*)((vm86.regs.cs << 4) + vm86.regs.eip); | ||
716 | + | ||
717 | + while (1) { | ||
718 | + switch(instr[i]) { | ||
719 | + case 0x66: /* operand size prefix */ | ||
720 | + data32 = 1 - data32; | ||
721 | + i++; | ||
722 | + break; | ||
723 | + case 0xf2: /* repnz */ | ||
724 | + case 0xf3: /* rep */ | ||
725 | + rep = 1; | ||
726 | + i++; | ||
727 | + break; | ||
728 | + case P_CS: /* segment prefix */ | ||
729 | + case P_SS: | ||
730 | + case P_DS: | ||
731 | + case P_ES: | ||
732 | + case P_FS: | ||
733 | + case P_GS: | ||
734 | + segment = instr[i]; | ||
735 | + i++; | ||
736 | + break; | ||
737 | + case 0xf0: /* LOCK - ignored */ | ||
738 | + case 0x67: /* address size prefix - ignored */ | ||
739 | + i++; | ||
740 | + break; | ||
741 | + case 0x6c: /* insb */ | ||
742 | + if (rep) | ||
743 | + vm86_rep_ins(1); | ||
744 | + else | ||
745 | + vm86_ins(1); | ||
746 | + i++; | ||
747 | + goto out; | ||
748 | + case 0x6d: /* insw / insd */ | ||
749 | + if (rep) { | ||
750 | + if (data32) | ||
751 | + vm86_rep_ins(4); | ||
752 | + else | ||
753 | + vm86_rep_ins(2); | ||
754 | + } else { | ||
755 | + if (data32) | ||
756 | + vm86_ins(4); | ||
757 | + else | ||
758 | + vm86_ins(2); | ||
759 | + } | ||
760 | + i++; | ||
761 | + goto out; | ||
762 | + case 0x6e: /* outsb */ | ||
763 | + if (rep) | ||
764 | + vm86_rep_outs(1, segment); | ||
765 | + else | ||
766 | + vm86_outs(1, segment); | ||
767 | + i++; | ||
768 | + goto out; | ||
769 | + case 0x6f: /* outsw / outsd */ | ||
770 | + if (rep) { | ||
771 | + if (data32) | ||
772 | + vm86_rep_outs(4, segment); | ||
773 | + else | ||
774 | + vm86_rep_outs(2, segment); | ||
775 | + } else { | ||
776 | + if (data32) | ||
777 | + vm86_outs(4, segment); | ||
778 | + else | ||
779 | + vm86_outs(2, segment); | ||
780 | + } | ||
781 | + i++; | ||
782 | + goto out; | ||
783 | + case 0xe4: /* inb xx */ | ||
784 | + asm volatile ( | ||
785 | + "inb %w1, %b0" | ||
786 | + : "=a" (vm86.regs.eax) | ||
787 | + : "d" (instr[i+1]), "0" (vm86.regs.eax)); | ||
788 | + i += 2; | ||
789 | + goto out; | ||
790 | + case 0xe5: /* inw xx / ind xx */ | ||
791 | + if (data32) { | ||
792 | + asm volatile ( | ||
793 | + "inl %w1, %0" | ||
794 | + : "=a" (vm86.regs.eax) | ||
795 | + : "d" (instr[i+1]), | ||
796 | + "0" (vm86.regs.eax)); | ||
797 | + } else { | ||
798 | + asm volatile ( | ||
799 | + "inw %w1, %w0" | ||
800 | + : "=a" (vm86.regs.eax) | ||
801 | + : "d" (instr[i+1]), | ||
802 | + "0" (vm86.regs.eax)); | ||
803 | + } | ||
804 | + i += 2; | ||
805 | + goto out; | ||
806 | + | ||
807 | + case 0xec: /* inb dx */ | ||
808 | + asm volatile ( | ||
809 | + "inb %w1, %b0" | ||
810 | + : "=a" (vm86.regs.eax) | ||
811 | + : "d" (vm86.regs.edx), "0" (vm86.regs.eax)); | ||
812 | + i++; | ||
813 | + goto out; | ||
814 | + case 0xed: /* inw dx / ind dx */ | ||
815 | + if (data32) { | ||
816 | + asm volatile ( | ||
817 | + "inl %w1, %0" | ||
818 | + : "=a" (vm86.regs.eax) | ||
819 | + : "d" (vm86.regs.edx)); | ||
820 | + } else { | ||
821 | + asm volatile ( | ||
822 | + "inw %w1, %w0" | ||
823 | + : "=a" (vm86.regs.eax) | ||
824 | + : "d" (vm86.regs.edx)); | ||
825 | + } | ||
826 | + i++; | ||
827 | + goto out; | ||
828 | + case 0xe6: /* outb xx */ | ||
829 | + asm volatile ( | ||
830 | + "outb %b0, %w1" | ||
831 | + : /* no return value */ | ||
832 | + : "a" (vm86.regs.eax), "d" (instr[i+1])); | ||
833 | + i += 2; | ||
834 | + goto out; | ||
835 | + case 0xe7: /* outw xx / outd xx */ | ||
836 | + if (data32) { | ||
837 | + asm volatile ( | ||
838 | + "outl %0, %w1" | ||
839 | + : /* no return value */ | ||
840 | + : "a" (vm86.regs.eax), | ||
841 | + "d" (instr[i+1])); | ||
842 | + } else { | ||
843 | + asm volatile ( | ||
844 | + "outw %w0, %w1" | ||
845 | + : /* no return value */ | ||
846 | + : "a" (vm86.regs.eax), | ||
847 | + "d" (instr[i+1])); | ||
848 | + } | ||
849 | + i += 2; | ||
850 | + goto out; | ||
851 | + case 0xee: /* outb dx */ | ||
852 | + asm volatile ( | ||
853 | + "outb %b0, %w1" | ||
854 | + : /* no return value */ | ||
855 | + : "a" (vm86.regs.eax), "d" (vm86.regs.edx)); | ||
856 | + i++; | ||
857 | + goto out; | ||
858 | + case 0xef: /* outw dx / outd dx */ | ||
859 | + if (data32) { | ||
860 | + asm volatile ( | ||
861 | + "outl %0, %w1" | ||
862 | + : /* no return value */ | ||
863 | + : "a" (vm86.regs.eax), | ||
864 | + "d" (vm86.regs.edx)); | ||
865 | + } else { | ||
866 | + asm volatile ( | ||
867 | + "outw %w0, %w1" | ||
868 | + : /* no return value */ | ||
869 | + : "a" (vm86.regs.eax), | ||
870 | + "d" (vm86.regs.edx)); | ||
871 | + } | ||
872 | + i++; | ||
873 | + goto out; | ||
874 | + default: | ||
875 | + printk(KERN_ERR "vesafb: BUG, opcode 0x%x emulation " | ||
876 | + "not supported (EIP: 0x%lx)\n", | ||
877 | + instr[i], (u32)(vm86.regs.cs << 4) + | ||
878 | + vm86.regs.eip); | ||
879 | + ret = 1; | ||
880 | + goto out; | ||
881 | + } | ||
882 | + } | ||
883 | +out: vm86.regs.eip += i; | ||
884 | + return ret; | ||
885 | +} | ||
886 | + | ||
887 | +void vesafb_do_vm86(struct vm86_regs *regs) | ||
888 | +{ | ||
889 | + unsigned int ret; | ||
890 | + u8 *retcode = (void*)RET_CODE_ADDR; | ||
891 | + | ||
892 | + memset(&vm86,0,sizeof(vm86)); | ||
893 | + memcpy(&vm86.regs, regs, sizeof(struct vm86_regs)); | ||
894 | + | ||
895 | + /* The return code */ | ||
896 | + retcode[0] = 0xcd; /* int opcode */ | ||
897 | + retcode[1] = 0xff; /* int number (255) */ | ||
898 | + | ||
899 | + /* We use int 0xff to get back to protected mode */ | ||
900 | + memset(&vm86.int_revectored, 0, sizeof(vm86.int_revectored)); | ||
901 | + ((unsigned char *)&vm86.int_revectored)[0xff / 8] |= (1 << (0xff % 8)); | ||
902 | + | ||
903 | + /* | ||
904 | + * We want to call int 0x10, so we set: | ||
905 | + * CS = 0x42 = 0x10 * 4 + 2 | ||
906 | + * IP = 0x40 = 0x10 * 4 | ||
907 | + * and SS:ESP. It's up to the caller to set the rest of the registers. | ||
908 | + */ | ||
909 | + vm86.regs.eflags = DEFAULT_VM86_FLAGS; | ||
910 | + vm86.regs.cs = *(unsigned short *)0x42; | ||
911 | + vm86.regs.eip = *(unsigned short *)0x40; | ||
912 | + vm86.regs.ss = (STACK_ADDR >> 4); | ||
913 | + vm86.regs.esp = ((STACK_ADDR & 0x0000f) + STACK_SIZE); | ||
914 | + | ||
915 | + /* These will be fetched off the stack when we come to an iret in the | ||
916 | + * int's 0x10 code. */ | ||
917 | + VM86_PUSHW(DEFAULT_VM86_FLAGS); | ||
918 | + VM86_PUSHW((RET_CODE_ADDR >> 4)); /* return code segment */ | ||
919 | + VM86_PUSHW((RET_CODE_ADDR & 0x0000f)); /* return code offset */ | ||
920 | + | ||
921 | + while(1) { | ||
922 | + ret = vm86old(&vm86); | ||
923 | + | ||
924 | + if (VM86_TYPE(ret) == VM86_INTx) { | ||
925 | + int vint = VM86_ARG(ret); | ||
926 | + | ||
927 | + /* If exit from vm86 was caused by int 0xff, then | ||
928 | + * we're done.. */ | ||
929 | + if (vint == 0xff) | ||
930 | + goto out; | ||
931 | + | ||
932 | + /* .. otherwise, we have to call the int handler | ||
933 | + * manually */ | ||
934 | + VM86_PUSHW(vm86.regs.eflags); | ||
935 | + VM86_PUSHW(vm86.regs.cs); | ||
936 | + VM86_PUSHW(vm86.regs.eip); | ||
937 | + | ||
938 | + vm86.regs.cs = *(u16 *)((vint << 2) + 2); | ||
939 | + vm86.regs.eip = *(u16 *)(vint << 2); | ||
940 | + vm86.regs.eflags &= ~(VIF_MASK | TF_MASK); | ||
941 | + } else if (VM86_TYPE(ret) == VM86_UNKNOWN) { | ||
942 | + if (vm86_do_unknown()) | ||
943 | + goto out; | ||
944 | + } else { | ||
945 | + printk(KERN_ERR "vesafb: BUG, returned from " | ||
946 | + "vm86 with %x (EIP: 0x%lx)\n", | ||
947 | + ret, (u32)(vm86.regs.cs << 4) + | ||
948 | + vm86.regs.eip); | ||
949 | + goto out; | ||
950 | + } | ||
951 | + } | ||
952 | + | ||
953 | +out: /* copy the registers' state back to the caller's struct */ | ||
954 | + memcpy(regs, &vm86.regs, sizeof(struct vm86_regs)); | ||
955 | +} | ||
956 | + | ||
957 | +static int vesafb_remap_pfn_range(unsigned long start, unsigned long end, | ||
958 | + unsigned long pgoff, unsigned long prot, | ||
959 | + int type) | ||
960 | +{ | ||
961 | + struct vm_area_struct *vma; | ||
962 | + struct mm_struct *mm = current->mm; | ||
963 | + int ret = 0; | ||
964 | + | ||
965 | + vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); | ||
966 | + if (!vma) | ||
967 | + return -ENOMEM; | ||
968 | + memset(vma, 0, sizeof(*vma)); | ||
969 | + down_write(&mm->mmap_sem); | ||
970 | + vma->vm_mm = mm; | ||
971 | + vma->vm_start = start; | ||
972 | + vma->vm_end = end; | ||
973 | + vma->vm_flags = VM_READ | VM_WRITE | VM_EXEC; | ||
974 | + vma->vm_flags |= mm->def_flags; | ||
975 | + vma->vm_page_prot.pgprot = prot; | ||
976 | + vma->vm_pgoff = pgoff; | ||
977 | + | ||
978 | + if ((ret = insert_vm_struct(mm, vma))) { | ||
979 | + up_write(&mm->mmap_sem); | ||
980 | + kmem_cache_free(vm_area_cachep, vma); | ||
981 | + return ret; | ||
982 | + } | ||
983 | + | ||
984 | + if (type) { | ||
985 | + ret = zeromap_page_range(vma, | ||
986 | + vma->vm_start, | ||
987 | + vma->vm_end - vma->vm_start, | ||
988 | + vma->vm_page_prot); | ||
989 | + } else { | ||
990 | + vma->vm_flags |= VM_SHARED; | ||
991 | + ret = remap_pfn_range(vma, | ||
992 | + vma->vm_start, | ||
993 | + vma->vm_pgoff, | ||
994 | + vma->vm_end - vma->vm_start, | ||
995 | + vma->vm_page_prot); | ||
996 | + } | ||
997 | + up_write(&mm->mmap_sem); | ||
998 | + return ret; | ||
999 | +} | ||
1000 | + | ||
1001 | +static inline int vesafb_init_mem(void) | ||
1002 | +{ | ||
1003 | + int ret = 0; | ||
1004 | + | ||
1005 | + /* The memory chunks we're remapping here should be multiples | ||
1006 | + * of PAGE_SIZE. */ | ||
1007 | + ret += vesafb_remap_pfn_range(0x00000, IVTBDA_SIZE, 0, | ||
1008 | + PROT_READ | PROT_EXEC | PROT_WRITE, 0); | ||
1009 | + ret += vesafb_remap_pfn_range(IVTBDA_SIZE, REAL_MEM_SIZE, 0, | ||
1010 | + PROT_READ | PROT_EXEC | PROT_WRITE, 1); | ||
1011 | + ret += vesafb_remap_pfn_range(0x9f000, 0x100000, | ||
1012 | + 0x9f000 >> PAGE_SHIFT, | ||
1013 | + PROT_READ | PROT_EXEC | PROT_WRITE, 0); | ||
1014 | + if (ret) | ||
1015 | + printk(KERN_ERR "vesafb thread: memory remapping failed\n"); | ||
1016 | + | ||
1017 | + return ret; | ||
1018 | +} | ||
1019 | + | ||
1020 | +#define vesafb_get_string(str) \ | ||
1021 | +{ \ | ||
1022 | + /* The address is in the form ssssoooo, where oooo = offset, \ | ||
1023 | + * ssss = segment */ \ | ||
1024 | + addr = ((p_vbe(tsk->buf)->str & 0xffff0000) >> 12) + \ | ||
1025 | + (p_vbe(tsk->buf)->str & 0x0000ffff); \ | ||
1026 | + \ | ||
1027 | + /* The data is in ROM which is shared between processes, so we \ | ||
1028 | + * just translate the real mode address into one visible from \ | ||
1029 | + * kernel space */ \ | ||
1030 | + if (addr >= 0xa0000) { \ | ||
1031 | + p_vbe(tsk->buf)->str = (u32) __va(addr); \ | ||
1032 | + \ | ||
1033 | + /* The data is in the buffer, we just have to convert the \ | ||
1034 | + * address so that it points into the buffer user provided. */ \ | ||
1035 | + } else if (addr > BUF_ADDR && addr < BUF_ADDR + \ | ||
1036 | + sizeof(struct vesafb_vbe_ib)) { \ | ||
1037 | + addr -= BUF_ADDR; \ | ||
1038 | + p_vbe(tsk->buf)->str = (u32) (tsk->buf + addr); \ | ||
1039 | + \ | ||
1040 | + /* This should never happen: someone was insane enough to put \ | ||
1041 | + * the data somewhere in RAM.. */ \ | ||
1042 | + } else { \ | ||
1043 | + p_vbe(tsk->buf)->str = (u32) ""; \ | ||
1044 | + } \ | ||
1045 | +} | ||
1046 | + | ||
1047 | +void vesafb_handle_getvbeib(struct vesafb_task *tsk) | ||
1048 | +{ | ||
1049 | + int addr, res; | ||
1050 | + | ||
1051 | + tsk->regs.es = (BUF_ADDR >> 4); | ||
1052 | + tsk->regs.edi = (BUF_ADDR & 0x000f); | ||
1053 | + strncpy(p_vbe(BUF_ADDR)->vbe_signature, "VBE2", 4); | ||
1054 | + | ||
1055 | + vesafb_do_vm86(&tsk->regs); | ||
1056 | + memcpy(tsk->buf, (void*)(BUF_ADDR), sizeof(struct vesafb_vbe_ib)); | ||
1057 | + | ||
1058 | + /* The OEM fields were not defined prior to VBE 2.0 */ | ||
1059 | + if (p_vbe(tsk->buf)->vbe_version >= 0x200) { | ||
1060 | + vesafb_get_string(oem_string_ptr); | ||
1061 | + vesafb_get_string(oem_vendor_name_ptr); | ||
1062 | + vesafb_get_string(oem_product_name_ptr); | ||
1063 | + vesafb_get_string(oem_product_rev_ptr); | ||
1064 | + } | ||
1065 | + | ||
1066 | + /* This is basically the same as vesafb_get_string() */ | ||
1067 | + addr = ((p_vbe(tsk->buf)->mode_list_ptr & 0xffff0000) >> 12) + | ||
1068 | + (p_vbe(tsk->buf)->mode_list_ptr & 0x0000ffff); | ||
1069 | + | ||
1070 | + if (addr >= 0xa0000) { | ||
1071 | + p_vbe(tsk->buf)->mode_list_ptr = (u32) __va(addr); | ||
1072 | + } else if (addr > BUF_ADDR && addr < BUF_ADDR + | ||
1073 | + sizeof(struct vesafb_vbe_ib)) { | ||
1074 | + addr -= BUF_ADDR; | ||
1075 | + p_vbe(tsk->buf)->mode_list_ptr = (u32) (tsk->buf + addr); | ||
1076 | + } else { | ||
1077 | + res = 0; | ||
1078 | + printk(KERN_WARNING "vesafb: warning, copying modelist " | ||
1079 | + "from somewhere in RAM!\n"); | ||
1080 | + while (*(u16*)(addr+res) != 0xffff && | ||
1081 | + res < (sizeof(p_vbe(tsk->buf)->reserved) - 2)) { | ||
1082 | + *(u16*) ((u32)&(p_vbe(tsk->buf)->reserved) + res) = | ||
1083 | + *(u16*)(addr+res); | ||
1084 | + res += 2; | ||
1085 | + } | ||
1086 | + *(u16*) ((u32)&(p_vbe(tsk->buf)->reserved) + res) = 0xffff; | ||
1087 | + } | ||
1088 | +} | ||
1089 | + | ||
1090 | +int vesafb_handle_tasks(void) | ||
1091 | +{ | ||
1092 | + struct vesafb_task *tsk; | ||
1093 | + struct list_head *curr, *next; | ||
1094 | + int ret = 0; | ||
1095 | + | ||
1096 | + down(&vesafb_task_list_sem); | ||
1097 | + list_for_each_safe(curr, next, &vesafb_task_list) { | ||
1098 | + tsk = list_entry(curr, struct vesafb_task, node); | ||
1099 | + | ||
1100 | + if (tsk->flags & TF_EXIT) { | ||
1101 | + ret = 1; | ||
1102 | + goto task_done; | ||
1103 | + } | ||
1104 | + if (tsk->flags & TF_GETVBEIB) { | ||
1105 | + vesafb_handle_getvbeib(tsk); | ||
1106 | + goto task_done; | ||
1107 | + } | ||
1108 | + /* Do we need to store a pointer to the buffer in ES:EDI? */ | ||
1109 | + if (tsk->flags & TF_BUF_DI) { | ||
1110 | + tsk->regs.es = (BUF_ADDR >> 4); | ||
1111 | + tsk->regs.edi = (BUF_ADDR & 0x000f); | ||
1112 | + } | ||
1113 | + /* Sometimes the pointer has to be in ES:EBX. */ | ||
1114 | + if (tsk->flags & TF_BUF_BX) { | ||
1115 | + tsk->regs.es = (BUF_ADDR >> 4); | ||
1116 | + tsk->regs.ebx = (BUF_ADDR & 0x000f); | ||
1117 | + } | ||
1118 | + if (tsk->flags & (TF_BUF_DI | TF_BUF_BX)) | ||
1119 | + memcpy((void*)BUF_ADDR, tsk->buf, tsk->buf_len); | ||
1120 | + | ||
1121 | + vesafb_do_vm86(&tsk->regs); | ||
1122 | + | ||
1123 | + if (tsk->flags & TF_RETURN_BUF) | ||
1124 | + memcpy(tsk->buf, (void*)BUF_ADDR, tsk->buf_len); | ||
1125 | + | ||
1126 | +task_done: list_del(curr); | ||
1127 | + complete(&tsk->done); | ||
1128 | + } | ||
1129 | + | ||
1130 | + /* If we're going to kill this thread, don't allow any elements | ||
1131 | + * to be added to the task list. */ | ||
1132 | + if (!ret) | ||
1133 | + up(&vesafb_task_list_sem); | ||
1134 | + | ||
1135 | + return ret; | ||
1136 | +} | ||
1137 | + | ||
1138 | +/* | ||
1139 | + * This 'hybrid' thread serves as a backend for vesafb-tng, handling all vm86 | ||
1140 | + * calls. It is started as a kernel thread. It then creates its own mm struct, | ||
1141 | + * thus separating itself from any userspace processes. At this moment, it | ||
1142 | + * stops being a kernel thread (kernel threads have mm = NULL) and becomes | ||
1143 | + * a 'hybrid' thread -- one that has full access to kernel space, yet runs | ||
1144 | + * with its own address space. | ||
1145 | + * | ||
1146 | + * This is necessary because in order to make vm86 calls some parts of the | ||
1147 | + * first 1MB of RAM have to be setup to mimic the real mode. These are: | ||
1148 | + * - interrupt vector table [0x00000-0x003ff] | ||
1149 | + * - BIOS data area [0x00400-0x004ff] | ||
1150 | + * - Extended BIOS data area [0x9fc00-0x9ffff] | ||
1151 | + * - the video RAM [0xa0000-0xbffff] | ||
1152 | + * - video BIOS [0xc0000-0xcffff] | ||
1153 | + * - motherboard BIOS [0xf0000-0xfffff] | ||
1154 | + */ | ||
1155 | +int vesafb_thread(void *unused) | ||
1156 | +{ | ||
1157 | + int err = 0; | ||
1158 | + | ||
1159 | + set_fs(KERNEL_DS); | ||
1160 | + daemonize("vesafb"); | ||
1161 | + | ||
1162 | + if (set_new_mm()) { | ||
1163 | + err = -ENOMEM; | ||
1164 | + goto thr_end; | ||
1165 | + } | ||
1166 | + if (vesafb_init_mem()) { | ||
1167 | + err = -ENOMEM; | ||
1168 | + goto thr_end; | ||
1169 | + } | ||
1170 | + | ||
1171 | + DPRINTK("started vesafb thread\n"); | ||
1172 | + | ||
1173 | + /* Having an IO bitmap makes things faster as we avoid GPFs | ||
1174 | + * when running vm86 code. We can live if it fails, though, | ||
1175 | + * so don't bother checking for errors. */ | ||
1176 | + ioperm(0,1024,1); | ||
1177 | + set_user_nice(current, -10); | ||
1178 | + | ||
1179 | + complete(&vesafb_th_completion); | ||
1180 | + | ||
1181 | + while (1) { | ||
1182 | + if (vesafb_handle_tasks()) | ||
1183 | + break; | ||
1184 | + wait_event_interruptible(vesafb_wait, | ||
1185 | + !list_empty(&vesafb_task_list)); | ||
1186 | + try_to_freeze(); | ||
1187 | + } | ||
1188 | + | ||
1189 | +out: DPRINTK("exiting the vesafb thread\n"); | ||
1190 | + vesafb_pid = -1; | ||
1191 | + | ||
1192 | + /* Now that all callers know this thread is no longer running | ||
1193 | + * (pid < 0), allow them to continue. */ | ||
1194 | + up(&vesafb_task_list_sem); | ||
1195 | + return err; | ||
1196 | +thr_end: | ||
1197 | + down(&vesafb_task_list_sem); | ||
1198 | + complete(&vesafb_th_completion); | ||
1199 | + goto out; | ||
1200 | +} | ||
1201 | + | ||
1202 | +int vesafb_queue_task(struct vesafb_task *tsk) | ||
1203 | +{ | ||
1204 | + down(&vesafb_task_list_sem); | ||
1205 | + if (vesafb_pid < 0) | ||
1206 | + return -1; | ||
1207 | + list_add_tail(&tsk->node, &vesafb_task_list); | ||
1208 | + up(&vesafb_task_list_sem); | ||
1209 | + wake_up(&vesafb_wait); | ||
1210 | + return 0; | ||
1211 | +} | ||
1212 | + | ||
1213 | +int vesafb_wait_for_thread(void) | ||
1214 | +{ | ||
1215 | + /* PID 0 means that the thread is still initializing. */ | ||
1216 | + if (vesafb_pid < 0) | ||
1217 | + return -1; | ||
1218 | + wait_for_completion(&vesafb_th_completion); | ||
1219 | + return 0; | ||
1220 | +} | ||
1221 | + | ||
1222 | +int __init vesafb_init_thread(void) | ||
1223 | +{ | ||
1224 | + vesafb_pid = kernel_thread(vesafb_thread,NULL,0); | ||
1225 | + return 0; | ||
1226 | +} | ||
1227 | + | ||
1228 | +#ifdef MODULE | ||
1229 | +void __exit vesafb_kill_thread(void) | ||
1230 | +{ | ||
1231 | + struct vesafb_task *tsk; | ||
1232 | + if (vesafb_pid <= 0) | ||
1233 | + return; | ||
1234 | + | ||
1235 | + vesafb_create_task(tsk); | ||
1236 | + if (!tsk) | ||
1237 | + return; | ||
1238 | + tsk->flags |= TF_EXIT; | ||
1239 | + vesafb_queue_task(tsk); | ||
1240 | + vesafb_wait_for_task(tsk); | ||
1241 | + kfree(tsk); | ||
1242 | + return; | ||
1243 | +} | ||
1244 | +module_exit(vesafb_kill_thread); | ||
1245 | +#endif | ||
1246 | +module_init(vesafb_init_thread); | ||
1247 | + | ||
1248 | +EXPORT_SYMBOL_GPL(vesafb_queue_task); | ||
1249 | +EXPORT_SYMBOL_GPL(vesafb_wait_for_thread); | ||
1250 | + | ||
1251 | +MODULE_LICENSE("GPL"); | ||
1252 | +MODULE_AUTHOR("Michal Januszewski"); | ||
1253 | + | ||
1254 | --- /dev/null | ||
1255 | +++ linux-2.6.17/drivers/video/vesafb-tng.c | ||
1256 | @@ -0,0 +1,1598 @@ | ||
1257 | +/* | ||
1258 | + * Framebuffer driver for VBE 2.0+ compliant graphic boards | ||
1259 | + * | ||
1260 | + * (c) 2004-2006 Michal Januszewski <spock@gentoo.org> | ||
1261 | + * Based upon vesafb code by Gerd Knorr <kraxel@goldbach.in-berlin.de> | ||
1262 | + * | ||
1263 | + */ | ||
1264 | + | ||
1265 | +#include <linux/module.h> | ||
1266 | +#include <linux/kernel.h> | ||
1267 | +#include <linux/errno.h> | ||
1268 | +#include <linux/string.h> | ||
1269 | +#include <linux/mm.h> | ||
1270 | +#include <linux/tty.h> | ||
1271 | +#include <linux/delay.h> | ||
1272 | +#include <linux/fb.h> | ||
1273 | +#include <linux/ioport.h> | ||
1274 | +#include <linux/init.h> | ||
1275 | +#include <linux/proc_fs.h> | ||
1276 | +#include <linux/completion.h> | ||
1277 | +#include <linux/platform_device.h> | ||
1278 | +#include <video/edid.h> | ||
1279 | +#include <video/vesa.h> | ||
1280 | +#include <video/vga.h> | ||
1281 | +#include <asm/io.h> | ||
1282 | +#include <asm/mtrr.h> | ||
1283 | +#include <asm/page.h> | ||
1284 | +#include <asm/pgtable.h> | ||
1285 | +#include "edid.h" | ||
1286 | + | ||
1287 | +#define dac_reg (0x3c8) | ||
1288 | +#define dac_val (0x3c9) | ||
1289 | + | ||
1290 | +#define VESAFB_NEED_EXACT_RES 1 | ||
1291 | +#define VESAFB_NEED_EXACT_DEPTH 2 | ||
1292 | + | ||
1293 | +/* --------------------------------------------------------------------- */ | ||
1294 | + | ||
1295 | +static struct fb_var_screeninfo vesafb_defined __initdata = { | ||
1296 | + .activate = FB_ACTIVATE_NOW, | ||
1297 | + .height = 0, | ||
1298 | + .width = 0, | ||
1299 | + .right_margin = 32, | ||
1300 | + .upper_margin = 16, | ||
1301 | + .lower_margin = 4, | ||
1302 | + .vsync_len = 4, | ||
1303 | + .vmode = FB_VMODE_NONINTERLACED, | ||
1304 | +}; | ||
1305 | + | ||
1306 | +static struct fb_fix_screeninfo vesafb_fix __initdata = { | ||
1307 | + .id = "VESA VGA", | ||
1308 | + .type = FB_TYPE_PACKED_PIXELS, | ||
1309 | + .accel = FB_ACCEL_NONE, | ||
1310 | +}; | ||
1311 | + | ||
1312 | +static int mtrr = 0; /* disable mtrr by default */ | ||
1313 | +static int blank = 1; /* enable blanking by default */ | ||
1314 | +static int ypan = 0; /* 0 - nothing, 1 - ypan, 2 - ywrap */ | ||
1315 | +static int pmi_setpal = 1; /* pmi for palette changes */ | ||
1316 | +static u16 *pmi_base = NULL; /* protected mode interface location */ | ||
1317 | +static void (*pmi_start)(void) = NULL; | ||
1318 | +static void (*pmi_pal)(void) = NULL; | ||
1319 | +static struct vesafb_vbe_ib vbe_ib; | ||
1320 | +static struct vesafb_mode_ib *vbe_modes; | ||
1321 | +static int vbe_modes_cnt = 0; | ||
1322 | +static struct fb_info *vesafb_info = NULL; | ||
1323 | +static int nocrtc = 0; /* ignore CRTC settings */ | ||
1324 | +static int noedid __initdata = 0; /* don't try DDC transfers */ | ||
1325 | +static int vram_remap __initdata = 0; /* set amount of memory to be used */ | ||
1326 | +static int vram_total __initdata = 0; /* set total amount of memory */ | ||
1327 | +static u16 maxclk __initdata = 0; /* maximum pixel clock */ | ||
1328 | +static u16 maxvf __initdata = 0; /* maximum vertical frequency */ | ||
1329 | +static u16 maxhf __initdata = 0; /* maximum horizontal frequency */ | ||
1330 | +static int gtf __initdata = 0; /* forces use of the GTF */ | ||
1331 | +static char *mode_option __initdata = NULL; | ||
1332 | +static u16 vbemode __initdata = 0; | ||
1333 | + | ||
1334 | +/* --------------------------------------------------------------------- */ | ||
1335 | + | ||
1336 | +static int vesafb_find_vbe_mode(int xres, int yres, int depth, | ||
1337 | + unsigned char flags) | ||
1338 | +{ | ||
1339 | + int i, match = -1, h = 0, d = 0x7fffffff; | ||
1340 | + | ||
1341 | + for (i = 0; i < vbe_modes_cnt; i++) { | ||
1342 | + h = abs(vbe_modes[i].x_res - xres) + | ||
1343 | + abs(vbe_modes[i].y_res - yres) + | ||
1344 | + abs(depth - vbe_modes[i].depth); | ||
1345 | + if (h == 0) | ||
1346 | + return i; | ||
1347 | + if (h < d || (h == d && vbe_modes[i].depth > depth)) { | ||
1348 | + d = h; | ||
1349 | + match = i; | ||
1350 | + } | ||
1351 | + } | ||
1352 | + i = 1; | ||
1353 | + | ||
1354 | + if (flags & VESAFB_NEED_EXACT_DEPTH && vbe_modes[match].depth != depth) | ||
1355 | + i = 0; | ||
1356 | + if (flags & VESAFB_NEED_EXACT_RES && d > 24) | ||
1357 | + i = 0; | ||
1358 | + if (i != 0) | ||
1359 | + return match; | ||
1360 | + else | ||
1361 | + return -1; | ||
1362 | +} | ||
1363 | + | ||
1364 | +static int vesafb_pan_display(struct fb_var_screeninfo *var, | ||
1365 | + struct fb_info *info) | ||
1366 | +{ | ||
1367 | + int offset; | ||
1368 | + | ||
1369 | + offset = (var->yoffset * info->fix.line_length + var->xoffset) / 4; | ||
1370 | + | ||
1371 | + /* It turns out it's not the best idea to do panning via vm86, | ||
1372 | + * so we only allow it if we have a PMI. */ | ||
1373 | + if (pmi_start) { | ||
1374 | + __asm__ __volatile__( | ||
1375 | + "call *(%%edi)" | ||
1376 | + : /* no return value */ | ||
1377 | + : "a" (0x4f07), /* EAX */ | ||
1378 | + "b" (0), /* EBX */ | ||
1379 | + "c" (offset), /* ECX */ | ||
1380 | + "d" (offset >> 16), /* EDX */ | ||
1381 | + "D" (&pmi_start)); /* EDI */ | ||
1382 | + } | ||
1383 | + return 0; | ||
1384 | +} | ||
1385 | + | ||
1386 | +static int vesafb_blank(int blank, struct fb_info *info) | ||
1387 | +{ | ||
1388 | + struct vesafb_task *tsk; | ||
1389 | + int err = 1; | ||
1390 | + | ||
1391 | + if (vbe_ib.capabilities & VBE_CAP_VGACOMPAT) { | ||
1392 | + int loop = 10000; | ||
1393 | + u8 seq = 0, crtc17 = 0; | ||
1394 | + | ||
1395 | + if (blank == FB_BLANK_POWERDOWN) { | ||
1396 | + seq = 0x20; | ||
1397 | + crtc17 = 0x00; | ||
1398 | + err = 0; | ||
1399 | + } else { | ||
1400 | + seq = 0x00; | ||
1401 | + crtc17 = 0x80; | ||
1402 | + err = (blank == FB_BLANK_UNBLANK) ? 0 : -EINVAL; | ||
1403 | + } | ||
1404 | + | ||
1405 | + vga_wseq(NULL, 0x00, 0x01); | ||
1406 | + seq |= vga_rseq(NULL, 0x01) & ~0x20; | ||
1407 | + vga_wseq(NULL, 0x00, seq); | ||
1408 | + | ||
1409 | + crtc17 |= vga_rcrt(NULL, 0x17) & ~0x80; | ||
1410 | + while (loop--); | ||
1411 | + vga_wcrt(NULL, 0x17, crtc17); | ||
1412 | + vga_wseq(NULL, 0x00, 0x03); | ||
1413 | + } else { | ||
1414 | + vesafb_create_task (tsk); | ||
1415 | + if (!tsk) | ||
1416 | + return -ENOMEM; | ||
1417 | + tsk->regs.eax = 0x4f10; | ||
1418 | + switch (blank) { | ||
1419 | + case FB_BLANK_UNBLANK: | ||
1420 | + tsk->regs.ebx = 0x0001; | ||
1421 | + break; | ||
1422 | + case FB_BLANK_NORMAL: | ||
1423 | + tsk->regs.ebx = 0x0101; /* standby */ | ||
1424 | + break; | ||
1425 | + case FB_BLANK_POWERDOWN: | ||
1426 | + tsk->regs.ebx = 0x0401; /* powerdown */ | ||
1427 | + break; | ||
1428 | + default: | ||
1429 | + goto out; | ||
1430 | + } | ||
1431 | + tsk->flags = TF_CALL; | ||
1432 | + if (!vesafb_queue_task (tsk)) | ||
1433 | + vesafb_wait_for_task(tsk); | ||
1434 | + | ||
1435 | + if ((tsk->regs.eax & 0xffff) == 0x004f) | ||
1436 | + err = 0; | ||
1437 | +out: kfree(tsk); | ||
1438 | + } | ||
1439 | + return err; | ||
1440 | +} | ||
1441 | + | ||
1442 | +static int vesafb_setpalette(struct vesafb_pal_entry *entries, int count, | ||
1443 | + int start, struct fb_info *info) | ||
1444 | +{ | ||
1445 | + struct vesafb_task *tsk; | ||
1446 | + int i = ((struct vesafb_par*)info->par)->mode_idx; | ||
1447 | + int ret = 0; | ||
1448 | + | ||
1449 | + /* We support palette modifications for 8 bpp modes only, so | ||
1450 | + * there can never be more than 256 entries. */ | ||
1451 | + if (start + count > 256) | ||
1452 | + return -EINVAL; | ||
1453 | + | ||
1454 | + /* Use VGA registers if mode is VGA-compatible. */ | ||
1455 | + if (i >= 0 && i < vbe_modes_cnt && | ||
1456 | + vbe_modes[i].mode_attr & VBE_MODE_VGACOMPAT) { | ||
1457 | + for (i = 0; i < count; i++) { | ||
1458 | + outb_p(start + i, dac_reg); | ||
1459 | + outb_p(entries[i].red, dac_val); | ||
1460 | + outb_p(entries[i].green, dac_val); | ||
1461 | + outb_p(entries[i].blue, dac_val); | ||
1462 | + } | ||
1463 | + } else if (pmi_setpal) { | ||
1464 | + __asm__ __volatile__( | ||
1465 | + "call *(%%esi)" | ||
1466 | + : /* no return value */ | ||
1467 | + : "a" (0x4f09), /* EAX */ | ||
1468 | + "b" (0), /* EBX */ | ||
1469 | + "c" (count), /* ECX */ | ||
1470 | + "d" (start), /* EDX */ | ||
1471 | + "D" (entries), /* EDI */ | ||
1472 | + "S" (&pmi_pal)); /* ESI */ | ||
1473 | + } else { | ||
1474 | + vesafb_create_task (tsk); | ||
1475 | + if (!tsk) | ||
1476 | + return -ENOMEM; | ||
1477 | + tsk->regs.eax = 0x4f09; | ||
1478 | + tsk->regs.ebx = 0x0; | ||
1479 | + tsk->regs.ecx = count; | ||
1480 | + tsk->regs.edx = start; | ||
1481 | + tsk->buf = entries; | ||
1482 | + tsk->buf_len = sizeof(struct vesafb_pal_entry) * count; | ||
1483 | + tsk->flags = TF_CALL | TF_BUF_DI; | ||
1484 | + | ||
1485 | + if (!vesafb_queue_task (tsk)) | ||
1486 | + vesafb_wait_for_task(tsk); | ||
1487 | + if ((tsk->regs.eax & 0xffff) != 0x004f) | ||
1488 | + ret = 1; | ||
1489 | + kfree(tsk); | ||
1490 | + } | ||
1491 | + return ret; | ||
1492 | +} | ||
1493 | + | ||
1494 | +static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green, | ||
1495 | + unsigned blue, unsigned transp, | ||
1496 | + struct fb_info *info) | ||
1497 | +{ | ||
1498 | + struct vesafb_pal_entry entry; | ||
1499 | + int shift = 16 - info->var.green.length; | ||
1500 | + int ret = 0; | ||
1501 | + | ||
1502 | + if (regno >= info->cmap.len) | ||
1503 | + return -EINVAL; | ||
1504 | + | ||
1505 | + if (info->var.bits_per_pixel == 8) { | ||
1506 | + entry.red = red >> shift; | ||
1507 | + entry.green = green >> shift; | ||
1508 | + entry.blue = blue >> shift; | ||
1509 | + entry.pad = 0; | ||
1510 | + | ||
1511 | + ret = vesafb_setpalette(&entry, 1, regno, info); | ||
1512 | + } else if (regno < 16) { | ||
1513 | + switch (info->var.bits_per_pixel) { | ||
1514 | + case 16: | ||
1515 | + if (info->var.red.offset == 10) { | ||
1516 | + /* 1:5:5:5 */ | ||
1517 | + ((u32*) (info->pseudo_palette))[regno] = | ||
1518 | + ((red & 0xf800) >> 1) | | ||
1519 | + ((green & 0xf800) >> 6) | | ||
1520 | + ((blue & 0xf800) >> 11); | ||
1521 | + } else { | ||
1522 | + /* 0:5:6:5 */ | ||
1523 | + ((u32*) (info->pseudo_palette))[regno] = | ||
1524 | + ((red & 0xf800) ) | | ||
1525 | + ((green & 0xfc00) >> 5) | | ||
1526 | + ((blue & 0xf800) >> 11); | ||
1527 | + } | ||
1528 | + break; | ||
1529 | + | ||
1530 | + case 24: | ||
1531 | + case 32: | ||
1532 | + red >>= 8; | ||
1533 | + green >>= 8; | ||
1534 | + blue >>= 8; | ||
1535 | + ((u32 *)(info->pseudo_palette))[regno] = | ||
1536 | + (red << info->var.red.offset) | | ||
1537 | + (green << info->var.green.offset) | | ||
1538 | + (blue << info->var.blue.offset); | ||
1539 | + break; | ||
1540 | + } | ||
1541 | + } | ||
1542 | + return ret; | ||
1543 | +} | ||
1544 | + | ||
1545 | +static int vesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info) | ||
1546 | +{ | ||
1547 | + struct vesafb_pal_entry *entries; | ||
1548 | + int shift = 16 - info->var.green.length; | ||
1549 | + int i, ret = 0; | ||
1550 | + | ||
1551 | + if (info->var.bits_per_pixel == 8) { | ||
1552 | + if (cmap->start + cmap->len > info->cmap.start + | ||
1553 | + info->cmap.len || cmap->start < info->cmap.start) | ||
1554 | + return -EINVAL; | ||
1555 | + | ||
1556 | + entries = vmalloc(sizeof(struct vesafb_pal_entry) * cmap->len); | ||
1557 | + if (!entries) | ||
1558 | + return -ENOMEM; | ||
1559 | + for (i = 0; i < cmap->len; i++) { | ||
1560 | + entries[i].red = cmap->red[i] >> shift; | ||
1561 | + entries[i].green = cmap->green[i] >> shift; | ||
1562 | + entries[i].blue = cmap->blue[i] >> shift; | ||
1563 | + entries[i].pad = 0; | ||
1564 | + } | ||
1565 | + ret = vesafb_setpalette(entries, cmap->len, cmap->start, info); | ||
1566 | + vfree(entries); | ||
1567 | + } else { | ||
1568 | + /* For modes with bpp > 8, we only set the pseudo palette in | ||
1569 | + * the fb_info struct. We rely on vesafb_setcolreg to do all | ||
1570 | + * sanity checking. */ | ||
1571 | + for (i = 0; i < cmap->len; i++) { | ||
1572 | + ret += vesafb_setcolreg(cmap->start + i, cmap->red[i], | ||
1573 | + cmap->green[i], cmap->blue[i], | ||
1574 | + 0, info); | ||
1575 | + } | ||
1576 | + } | ||
1577 | + return ret; | ||
1578 | +} | ||
1579 | + | ||
1580 | +static int vesafb_set_par(struct fb_info *info) | ||
1581 | +{ | ||
1582 | + struct vesafb_par *par = (struct vesafb_par *) info->par; | ||
1583 | + struct vesafb_task *tsk; | ||
1584 | + struct vesafb_crtc_ib *crtc = NULL; | ||
1585 | + struct vesafb_mode_ib *mode = NULL; | ||
1586 | + int i, err = 0, depth = info->var.bits_per_pixel; | ||
1587 | + | ||
1588 | + if (depth > 8 && depth != 32) | ||
1589 | + depth = info->var.red.length + info->var.green.length + | ||
1590 | + info->var.blue.length; | ||
1591 | + | ||
1592 | + i = vesafb_find_vbe_mode(info->var.xres, info->var.yres, depth, | ||
1593 | + VESAFB_NEED_EXACT_RES | | ||
1594 | + VESAFB_NEED_EXACT_DEPTH); | ||
1595 | + if (i >= 0) | ||
1596 | + mode = &vbe_modes[i]; | ||
1597 | + else | ||
1598 | + return -EINVAL; | ||
1599 | + | ||
1600 | + vesafb_create_task (tsk); | ||
1601 | + if (!tsk) | ||
1602 | + return -ENOMEM; | ||
1603 | + tsk->regs.eax = 0x4f02; | ||
1604 | + tsk->regs.ebx = mode->mode_id | 0x4000; /* use LFB */ | ||
1605 | + tsk->flags = TF_CALL; | ||
1606 | + | ||
1607 | + if (vbe_ib.vbe_version >= 0x0300 && !nocrtc && | ||
1608 | + info->var.pixclock != 0) { | ||
1609 | + tsk->regs.ebx |= 0x0800; /* use CRTC data */ | ||
1610 | + tsk->flags |= TF_BUF_DI; | ||
1611 | + crtc = kmalloc(sizeof(struct vesafb_crtc_ib), GFP_KERNEL); | ||
1612 | + if (!crtc) { | ||
1613 | + err = -ENOMEM; | ||
1614 | + goto out; | ||
1615 | + } | ||
1616 | + crtc->horiz_start = info->var.xres + info->var.right_margin; | ||
1617 | + crtc->horiz_end = crtc->horiz_start + info->var.hsync_len; | ||
1618 | + crtc->horiz_total = crtc->horiz_end + info->var.left_margin; | ||
1619 | + | ||
1620 | + crtc->vert_start = info->var.yres + info->var.lower_margin; | ||
1621 | + crtc->vert_end = crtc->vert_start + info->var.vsync_len; | ||
1622 | + crtc->vert_total = crtc->vert_end + info->var.upper_margin; | ||
1623 | + | ||
1624 | + crtc->pixel_clock = PICOS2KHZ(info->var.pixclock) * 1000; | ||
1625 | + crtc->refresh_rate = (u16)(100 * (crtc->pixel_clock / | ||
1626 | + (crtc->vert_total * crtc->horiz_total))); | ||
1627 | + crtc->flags = 0; | ||
1628 | + | ||
1629 | + if (info->var.vmode & FB_VMODE_DOUBLE) | ||
1630 | + crtc->flags |= 0x1; | ||
1631 | + if (info->var.vmode & FB_VMODE_INTERLACED) | ||
1632 | + crtc->flags |= 0x2; | ||
1633 | + if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT)) | ||
1634 | + crtc->flags |= 0x4; | ||
1635 | + if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT)) | ||
1636 | + crtc->flags |= 0x8; | ||
1637 | + memcpy(&par->crtc, crtc, sizeof(struct vesafb_crtc_ib)); | ||
1638 | + } else | ||
1639 | + memset(&par->crtc, 0, sizeof(struct vesafb_crtc_ib)); | ||
1640 | + | ||
1641 | + tsk->buf = (void*)crtc; | ||
1642 | + tsk->buf_len = sizeof(struct vesafb_crtc_ib); | ||
1643 | + | ||
1644 | + if (vesafb_queue_task (tsk)) { | ||
1645 | + err = -EINVAL; | ||
1646 | + goto out; | ||
1647 | + } | ||
1648 | + vesafb_wait_for_task(tsk); | ||
1649 | + | ||
1650 | + if ((tsk->regs.eax & 0xffff) != 0x004f) { | ||
1651 | + printk(KERN_ERR "vesafb: mode switch failed (eax: 0x%lx)\n", | ||
1652 | + tsk->regs.eax); | ||
1653 | + err = -EINVAL; | ||
1654 | + goto out; | ||
1655 | + } | ||
1656 | + par->mode_idx = i; | ||
1657 | + | ||
1658 | + /* For 8bpp modes, always try to set the DAC to 8 bits. */ | ||
1659 | + if (vbe_ib.capabilities & VBE_CAP_CAN_SWITCH_DAC && | ||
1660 | + mode->bits_per_pixel <= 8) { | ||
1661 | + vesafb_reset_task(tsk); | ||
1662 | + tsk->flags = TF_CALL; | ||
1663 | + tsk->regs.eax = 0x4f08; | ||
1664 | + tsk->regs.ebx = 0x0800; | ||
1665 | + | ||
1666 | + if (!vesafb_queue_task (tsk)) | ||
1667 | + vesafb_wait_for_task(tsk); | ||
1668 | + | ||
1669 | + if ((tsk->regs.eax & 0xffff) != 0x004f || | ||
1670 | + ((tsk->regs.ebx & 0xff00) >> 8) != 8) { | ||
1671 | + /* We've failed to set the DAC palette format - | ||
1672 | + * time to correct var. */ | ||
1673 | + info->var.red.length = 6; | ||
1674 | + info->var.green.length = 6; | ||
1675 | + info->var.blue.length = 6; | ||
1676 | + } | ||
1677 | + } | ||
1678 | + | ||
1679 | + info->fix.visual = (info->var.bits_per_pixel == 8) ? | ||
1680 | + FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; | ||
1681 | + info->fix.line_length = mode->bytes_per_scan_line; | ||
1682 | + | ||
1683 | + DPRINTK("set new mode %dx%d-%d (0x%x)\n", | ||
1684 | + info->var.xres, info->var.yres, info->var.bits_per_pixel, | ||
1685 | + mode->mode_id); | ||
1686 | + | ||
1687 | +out: if (crtc != NULL) | ||
1688 | + kfree(crtc); | ||
1689 | + kfree(tsk); | ||
1690 | + | ||
1691 | + return err; | ||
1692 | +} | ||
1693 | + | ||
1694 | +static void vesafb_setup_var(struct fb_var_screeninfo *var, struct fb_info *info, | ||
1695 | + struct vesafb_mode_ib *mode) | ||
1696 | +{ | ||
1697 | + var->xres = mode->x_res; | ||
1698 | + var->yres = mode->y_res; | ||
1699 | + var->xres_virtual = mode->x_res; | ||
1700 | + var->yres_virtual = (ypan) ? | ||
1701 | + info->fix.smem_len / mode->bytes_per_scan_line : | ||
1702 | + mode->y_res; | ||
1703 | + var->xoffset = 0; | ||
1704 | + var->yoffset = 0; | ||
1705 | + var->bits_per_pixel = mode->bits_per_pixel; | ||
1706 | + | ||
1707 | + if (var->bits_per_pixel == 15) | ||
1708 | + var->bits_per_pixel = 16; | ||
1709 | + | ||
1710 | + if (var->bits_per_pixel > 8) { | ||
1711 | + var->red.offset = mode->red_off; | ||
1712 | + var->red.length = mode->red_len; | ||
1713 | + var->green.offset = mode->green_off; | ||
1714 | + var->green.length = mode->green_len; | ||
1715 | + var->blue.offset = mode->blue_off; | ||
1716 | + var->blue.length = mode->blue_len; | ||
1717 | + var->transp.offset = mode->rsvd_off; | ||
1718 | + var->transp.length = mode->rsvd_len; | ||
1719 | + | ||
1720 | + DPRINTK("directcolor: size=%d:%d:%d:%d, shift=%d:%d:%d:%d\n", | ||
1721 | + mode->rsvd_len, | ||
1722 | + mode->red_len, | ||
1723 | + mode->green_len, | ||
1724 | + mode->blue_len, | ||
1725 | + mode->rsvd_off, | ||
1726 | + mode->red_off, | ||
1727 | + mode->green_off, | ||
1728 | + mode->blue_off); | ||
1729 | + } else { | ||
1730 | + var->red.offset = 0; | ||
1731 | + var->green.offset = 0; | ||
1732 | + var->blue.offset = 0; | ||
1733 | + var->transp.offset = 0; | ||
1734 | + | ||
1735 | + /* We're assuming that we can switch the DAC to 8 bits. If | ||
1736 | + * this proves to be incorrect, we'll update the fields | ||
1737 | + * later in set_par(). */ | ||
1738 | + if (vbe_ib.capabilities & VBE_CAP_CAN_SWITCH_DAC) { | ||
1739 | + var->red.length = 8; | ||
1740 | + var->green.length = 8; | ||
1741 | + var->blue.length = 8; | ||
1742 | + var->transp.length = 0; | ||
1743 | + } else { | ||
1744 | + var->red.length = 6; | ||
1745 | + var->green.length = 6; | ||
1746 | + var->blue.length = 6; | ||
1747 | + var->transp.length = 0; | ||
1748 | + } | ||
1749 | + } | ||
1750 | +} | ||
1751 | + | ||
1752 | +static void inline vesafb_check_limits(struct fb_var_screeninfo *var, | ||
1753 | + struct fb_info *info) | ||
1754 | +{ | ||
1755 | + struct fb_videomode *mode; | ||
1756 | + | ||
1757 | + if (!var->pixclock) | ||
1758 | + return; | ||
1759 | + if (vbe_ib.vbe_version < 0x0300) { | ||
1760 | + fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, var, info); | ||
1761 | + return; | ||
1762 | + } | ||
1763 | + if (!fb_validate_mode(var, info)) | ||
1764 | + return; | ||
1765 | + mode = fb_find_best_mode(var, &info->modelist); | ||
1766 | + if (mode) { | ||
1767 | + DPRINTK("find_best_mode: %d %d @ %d (vmode: %d)\n", | ||
1768 | + mode->xres, mode->yres, mode->refresh, mode->vmode); | ||
1769 | + if (mode->xres == var->xres && mode->yres == var->yres && | ||
1770 | + !(mode->vmode & (FB_VMODE_INTERLACED | FB_VMODE_DOUBLE))) { | ||
1771 | + fb_videomode_to_var(var, mode); | ||
1772 | + return; | ||
1773 | + } | ||
1774 | + } | ||
1775 | + if (info->monspecs.gtf && !fb_get_mode(FB_MAXTIMINGS, 0, var, info)) | ||
1776 | + return; | ||
1777 | + /* Use default refresh rate */ | ||
1778 | + var->pixclock = 0; | ||
1779 | +} | ||
1780 | + | ||
1781 | +static int vesafb_check_var(struct fb_var_screeninfo *var, | ||
1782 | + struct fb_info *info) | ||
1783 | +{ | ||
1784 | + int match = -1; | ||
1785 | + int depth = var->red.length + var->green.length + var->blue.length; | ||
1786 | + | ||
1787 | + /* Various apps will use bits_per_pixel to set the color depth, | ||
1788 | + * which is theoretically incorrect, but which we'll try to handle | ||
1789 | + * here. */ | ||
1790 | + if (depth == 0 || abs(depth - var->bits_per_pixel) >= 8) | ||
1791 | + depth = var->bits_per_pixel; | ||
1792 | + match = vesafb_find_vbe_mode(var->xres, var->yres, depth, | ||
1793 | + VESAFB_NEED_EXACT_RES); | ||
1794 | + | ||
1795 | + if (match == -1) { | ||
1796 | + DPRINTK("vesafb: mode %dx%d-%d not found\n", var->xres, | ||
1797 | + var->yres, depth); | ||
1798 | + return -EINVAL; | ||
1799 | + } | ||
1800 | + | ||
1801 | + vesafb_setup_var(var, info, &vbe_modes[match]); | ||
1802 | + DPRINTK("found mode 0x%x (%dx%d-%dbpp)\n", | ||
1803 | + vbe_modes[match].mode_id, vbe_modes[match].x_res, | ||
1804 | + vbe_modes[match].y_res, vbe_modes[match].depth); | ||
1805 | + | ||
1806 | + /* Check whether we have remapped enough memory for this mode. */ | ||
1807 | + if (var->yres * vbe_modes[match].bytes_per_scan_line > | ||
1808 | + info->fix.smem_len) { | ||
1809 | + return -EINVAL; | ||
1810 | + } | ||
1811 | + | ||
1812 | + if ((var->vmode & FB_VMODE_DOUBLE) && | ||
1813 | + !(vbe_modes[match].mode_attr & 0x100)) | ||
1814 | + var->vmode &= ~FB_VMODE_DOUBLE; | ||
1815 | + if ((var->vmode & FB_VMODE_INTERLACED) && | ||
1816 | + !(vbe_modes[match].mode_attr & 0x200)) | ||
1817 | + var->vmode &= ~FB_VMODE_INTERLACED; | ||
1818 | + vesafb_check_limits(var, info); | ||
1819 | + return 0; | ||
1820 | +} | ||
1821 | + | ||
1822 | +static int vesafb_open(struct fb_info *info, int user) | ||
1823 | +{ | ||
1824 | + struct vesafb_task *tsk = NULL; | ||
1825 | + struct vesafb_par *par = info->par; | ||
1826 | + int cnt = atomic_read(&par->ref_count); | ||
1827 | + | ||
1828 | + if (!cnt) { | ||
1829 | + vesafb_create_task(tsk); | ||
1830 | + if (!tsk) | ||
1831 | + goto out; | ||
1832 | + | ||
1833 | + /* Get the VBE state buffer size. We want all available | ||
1834 | + * hardware state data (CL = 0x0f). */ | ||
1835 | + tsk->regs.eax = 0x4f04; | ||
1836 | + tsk->regs.ecx = 0x000f; | ||
1837 | + tsk->regs.edx = 0x0000; | ||
1838 | + tsk->flags = TF_CALL; | ||
1839 | + | ||
1840 | + if (vesafb_queue_task(tsk)) | ||
1841 | + goto out; | ||
1842 | + | ||
1843 | + vesafb_wait_for_task(tsk); | ||
1844 | + | ||
1845 | + if ((tsk->regs.eax & 0xffff) != 0x004f) { | ||
1846 | + printk(KERN_WARNING "vesafb: VBE state buffer size " | ||
1847 | + "cannot be determined (eax: 0x%lx)\n", | ||
1848 | + tsk->regs.eax); | ||
1849 | + goto out; | ||
1850 | + } | ||
1851 | + | ||
1852 | + par->vbe_state_size = 64 * (tsk->regs.ebx & 0xffff); | ||
1853 | + par->vbe_state = kzalloc(par->vbe_state_size, GFP_KERNEL); | ||
1854 | + if (!par->vbe_state) | ||
1855 | + goto out; | ||
1856 | + | ||
1857 | + vesafb_reset_task(tsk); | ||
1858 | + tsk->regs.eax = 0x4f04; | ||
1859 | + tsk->regs.ecx = 0x000f; | ||
1860 | + tsk->regs.edx = 0x0001; | ||
1861 | + tsk->flags = TF_CALL | TF_BUF_BX | TF_RETURN_BUF; | ||
1862 | + tsk->buf = (void*)(par->vbe_state); | ||
1863 | + tsk->buf_len = par->vbe_state_size; | ||
1864 | + | ||
1865 | + if (vesafb_queue_task(tsk)) | ||
1866 | + goto getstate_failed; | ||
1867 | + vesafb_wait_for_task(tsk); | ||
1868 | + | ||
1869 | + if ((tsk->regs.eax & 0xffff) != 0x004f) { | ||
1870 | + printk(KERN_WARNING "vesafb: VBE get state call " | ||
1871 | + "failed (eax: 0x%lx)\n", tsk->regs.eax); | ||
1872 | + goto getstate_failed; | ||
1873 | + } | ||
1874 | + } | ||
1875 | +out: | ||
1876 | + atomic_inc(&par->ref_count); | ||
1877 | + if (tsk) | ||
1878 | + kfree(tsk); | ||
1879 | + return 0; | ||
1880 | + | ||
1881 | +getstate_failed: | ||
1882 | + kfree(par->vbe_state); | ||
1883 | + par->vbe_state = NULL; | ||
1884 | + par->vbe_state_size = 0; | ||
1885 | + goto out; | ||
1886 | +} | ||
1887 | + | ||
1888 | +static int vesafb_release(struct fb_info *info, int user) | ||
1889 | +{ | ||
1890 | + struct vesafb_task *tsk = NULL; | ||
1891 | + struct vesafb_par *par = info->par; | ||
1892 | + int cnt = atomic_read(&par->ref_count); | ||
1893 | + | ||
1894 | + if (!cnt) | ||
1895 | + return -EINVAL; | ||
1896 | + | ||
1897 | + if (cnt == 1 && par->vbe_state && par->vbe_state_size) { | ||
1898 | + vesafb_create_task(tsk); | ||
1899 | + if (!tsk) | ||
1900 | + goto out; | ||
1901 | + | ||
1902 | + tsk->regs.eax = 0x0003; | ||
1903 | + tsk->regs.ebx = 0x0000; | ||
1904 | + tsk->flags = TF_CALL; | ||
1905 | + | ||
1906 | + if (vesafb_queue_task(tsk)) | ||
1907 | + goto out; | ||
1908 | + | ||
1909 | + vesafb_wait_for_task(tsk); | ||
1910 | + | ||
1911 | + vesafb_reset_task(tsk); | ||
1912 | + tsk->regs.eax = 0x4f04; | ||
1913 | + tsk->regs.ecx = 0x000f; | ||
1914 | + tsk->regs.edx = 0x0002; | ||
1915 | + tsk->buf = (void*)(par->vbe_state); | ||
1916 | + tsk->buf_len = par->vbe_state_size; | ||
1917 | + tsk->flags = TF_CALL | TF_BUF_BX; | ||
1918 | + | ||
1919 | + if (vesafb_queue_task(tsk)) | ||
1920 | + goto out; | ||
1921 | + | ||
1922 | + vesafb_wait_for_task(tsk); | ||
1923 | + | ||
1924 | + if ((tsk->regs.eax & 0xffff) != 0x004f) | ||
1925 | + printk(KERN_WARNING "vesafb: VBE state restore call " | ||
1926 | + "failed (eax: 0x%lx)\n", | ||
1927 | + tsk->regs.eax); | ||
1928 | + } | ||
1929 | +out: | ||
1930 | + atomic_dec(&par->ref_count); | ||
1931 | + if (tsk) | ||
1932 | + kfree(tsk); | ||
1933 | + return 0; | ||
1934 | +} | ||
1935 | + | ||
1936 | +static int __init vesafb_probe(struct platform_device *device); | ||
1937 | + | ||
1938 | +static struct fb_ops vesafb_ops = { | ||
1939 | + .owner = THIS_MODULE, | ||
1940 | + .fb_open = vesafb_open, | ||
1941 | + .fb_release = vesafb_release, | ||
1942 | + .fb_setcolreg = vesafb_setcolreg, | ||
1943 | + .fb_setcmap = vesafb_setcmap, | ||
1944 | + .fb_pan_display = vesafb_pan_display, | ||
1945 | + .fb_blank = vesafb_blank, | ||
1946 | + .fb_fillrect = cfb_fillrect, | ||
1947 | + .fb_copyarea = cfb_copyarea, | ||
1948 | + .fb_imageblit = cfb_imageblit, | ||
1949 | + .fb_check_var = vesafb_check_var, | ||
1950 | + .fb_set_par = vesafb_set_par | ||
1951 | +}; | ||
1952 | + | ||
1953 | +static struct platform_driver vesafb_driver = { | ||
1954 | + .probe = vesafb_probe, | ||
1955 | + .driver = { | ||
1956 | + .name = "vesafb", | ||
1957 | + }, | ||
1958 | +}; | ||
1959 | + | ||
1960 | +static struct platform_device *vesafb_device; | ||
1961 | + | ||
1962 | +#ifndef MODULE | ||
1963 | +int __init vesafb_setup(char *options) | ||
1964 | +{ | ||
1965 | + char *this_opt; | ||
1966 | + | ||
1967 | + if (!options || !*options) | ||
1968 | + return 0; | ||
1969 | + | ||
1970 | + DPRINTK("options %s\n",options); | ||
1971 | + | ||
1972 | + while ((this_opt = strsep(&options, ",")) != NULL) { | ||
1973 | + if (!*this_opt) continue; | ||
1974 | + | ||
1975 | + DPRINTK("this_opt: %s\n",this_opt); | ||
1976 | + | ||
1977 | + if (! strcmp(this_opt, "redraw")) | ||
1978 | + ypan=0; | ||
1979 | + else if (! strcmp(this_opt, "ypan")) | ||
1980 | + ypan=1; | ||
1981 | + else if (! strcmp(this_opt, "ywrap")) | ||
1982 | + ypan=2; | ||
1983 | + else if (! strcmp(this_opt, "vgapal")) | ||
1984 | + pmi_setpal=0; | ||
1985 | + else if (! strcmp(this_opt, "pmipal")) | ||
1986 | + pmi_setpal=1; | ||
1987 | + else if (! strncmp(this_opt, "mtrr:", 5)) | ||
1988 | + mtrr = simple_strtoul(this_opt+5, NULL, 0); | ||
1989 | + else if (! strcmp(this_opt, "nomtrr")) | ||
1990 | + mtrr=0; | ||
1991 | + else if (! strcmp(this_opt, "nocrtc")) | ||
1992 | + nocrtc=1; | ||
1993 | + else if (! strcmp(this_opt, "noedid")) | ||
1994 | + noedid=1; | ||
1995 | + else if (! strcmp(this_opt, "noblank")) | ||
1996 | + blank=0; | ||
1997 | + else if (! strcmp(this_opt, "gtf")) | ||
1998 | + gtf=1; | ||
1999 | + else if (! strncmp(this_opt, "vtotal:", 7)) | ||
2000 | + vram_total = simple_strtoul(this_opt + 7, NULL, 0); | ||
2001 | + else if (! strncmp(this_opt, "vremap:", 7)) | ||
2002 | + vram_remap = simple_strtoul(this_opt + 7, NULL, 0); | ||
2003 | + else if (! strncmp(this_opt, "maxhf:", 6)) | ||
2004 | + maxhf = simple_strtoul(this_opt + 6, NULL, 0); | ||
2005 | + else if (! strncmp(this_opt, "maxvf:", 6)) | ||
2006 | + maxvf = simple_strtoul(this_opt + 6, NULL, 0); | ||
2007 | + else if (! strncmp(this_opt, "maxclk:", 7)) | ||
2008 | + maxclk = simple_strtoul(this_opt + 7, NULL, 0); | ||
2009 | + else if (! strncmp(this_opt, "vbemode:", 8)) | ||
2010 | + vbemode = simple_strtoul(this_opt + 8, NULL,0); | ||
2011 | + else if (this_opt[0] >= '0' && this_opt[0] <= '9') { | ||
2012 | + DPRINTK("mode_option: %s\n",this_opt); | ||
2013 | + mode_option = this_opt; | ||
2014 | + } else { | ||
2015 | + printk(KERN_WARNING | ||
2016 | + "vesafb: unrecognized option %s\n", this_opt); | ||
2017 | + } | ||
2018 | + } | ||
2019 | + | ||
2020 | + return 0; | ||
2021 | +} | ||
2022 | +#endif /* !MODULE */ | ||
2023 | + | ||
2024 | +static int vesafb_read_proc_modes(char *buf, char **start, off_t offset, | ||
2025 | + int len, int *eof, void *private) | ||
2026 | +{ | ||
2027 | + int clen = 0, i; | ||
2028 | + | ||
2029 | + for (i = 0; i < vbe_modes_cnt; i++) { | ||
2030 | + clen += sprintf(buf + clen, "%dx%d-%d\n", vbe_modes[i].x_res, | ||
2031 | + vbe_modes[i].y_res, vbe_modes[i].depth); | ||
2032 | + } | ||
2033 | + *start = buf + offset; | ||
2034 | + | ||
2035 | + if (clen > offset) { | ||
2036 | + clen -= offset; | ||
2037 | + } else { | ||
2038 | + clen = 0; | ||
2039 | + } | ||
2040 | + return clen; | ||
2041 | +} | ||
2042 | + | ||
2043 | +static int vesafb_read_proc_vbe_info(char *buf, char **start, off_t offset, | ||
2044 | + int len, int *eof, void *private) | ||
2045 | +{ | ||
2046 | + int clen = 0; | ||
2047 | + | ||
2048 | + clen += sprintf(buf + clen, "Version: %d.%d\n", | ||
2049 | + ((vbe_ib.vbe_version & 0xff00) >> 8), | ||
2050 | + vbe_ib.vbe_version & 0xff); | ||
2051 | + clen += sprintf(buf + clen, "Vendor: %s\n", | ||
2052 | + (char*)vbe_ib.oem_vendor_name_ptr); | ||
2053 | + clen += sprintf(buf + clen, "Product: %s\n", | ||
2054 | + (char*)vbe_ib.oem_product_name_ptr); | ||
2055 | + clen += sprintf(buf + clen, "OEM rev: %s\n", | ||
2056 | + (char*)vbe_ib.oem_product_rev_ptr); | ||
2057 | + clen += sprintf(buf + clen, "OEM string: %s\n", | ||
2058 | + (char*)vbe_ib.oem_string_ptr); | ||
2059 | + | ||
2060 | + *start = buf + offset; | ||
2061 | + | ||
2062 | + if (clen > offset) { | ||
2063 | + clen -= offset; | ||
2064 | + } else { | ||
2065 | + clen = 0; | ||
2066 | + } | ||
2067 | + return clen; | ||
2068 | +} | ||
2069 | + | ||
2070 | +static int __init inline vesafb_vbe_getinfo(struct vesafb_task *tsk) | ||
2071 | +{ | ||
2072 | + tsk->regs.eax = 0x4f00; | ||
2073 | + tsk->flags = TF_CALL | TF_GETVBEIB; | ||
2074 | + tsk->buf = &vbe_ib; | ||
2075 | + tsk->buf_len = sizeof(vbe_ib); | ||
2076 | + if (vesafb_queue_task (tsk)) | ||
2077 | + return -EINVAL; | ||
2078 | + vesafb_wait_for_task(tsk); | ||
2079 | + | ||
2080 | + if (vbe_ib.vbe_version < 0x0200) { | ||
2081 | + printk(KERN_ERR "vesafb: Sorry, pre-VBE 2.0 cards are " | ||
2082 | + "not supported.\n"); | ||
2083 | + return -EINVAL; | ||
2084 | + } | ||
2085 | + | ||
2086 | + if ((tsk->regs.eax & 0xffff) != 0x004f) { | ||
2087 | + printk(KERN_ERR "vesafb: Getting mode info block failed " | ||
2088 | + "(eax=0x%x)\n", (u32)tsk->regs.eax); | ||
2089 | + return -EINVAL; | ||
2090 | + } | ||
2091 | + | ||
2092 | + printk(KERN_INFO "vesafb: %s, %s, %s (OEM: %s)\n", | ||
2093 | + (char*)vbe_ib.oem_vendor_name_ptr, | ||
2094 | + (char*)vbe_ib.oem_product_name_ptr, | ||
2095 | + (char*)vbe_ib.oem_product_rev_ptr, | ||
2096 | + (char*)vbe_ib.oem_string_ptr); | ||
2097 | + | ||
2098 | + printk(KERN_INFO "vesafb: VBE version: %d.%d\n", | ||
2099 | + ((vbe_ib.vbe_version & 0xff00) >> 8), | ||
2100 | + vbe_ib.vbe_version & 0xff); | ||
2101 | + return 0; | ||
2102 | +} | ||
2103 | + | ||
2104 | +static int __init inline vesafb_vbe_getmodes(struct vesafb_task *tsk) | ||
2105 | +{ | ||
2106 | + u16 *mode = 0; | ||
2107 | + int off = 0; | ||
2108 | + | ||
2109 | + /* Count available modes. */ | ||
2110 | + mode = (u16*)vbe_ib.mode_list_ptr; | ||
2111 | + while (*mode != 0xffff) { | ||
2112 | + vbe_modes_cnt++; | ||
2113 | + mode++; | ||
2114 | + } | ||
2115 | + | ||
2116 | + vbe_modes = kmalloc(sizeof(struct vesafb_mode_ib)* | ||
2117 | + vbe_modes_cnt, GFP_KERNEL); | ||
2118 | + if (!vbe_modes) | ||
2119 | + return -ENOMEM; | ||
2120 | + | ||
2121 | + /* Get mode info for all available modes. */ | ||
2122 | + mode = (u16*)vbe_ib.mode_list_ptr; | ||
2123 | + | ||
2124 | + while (*mode != 0xffff) { | ||
2125 | + struct vesafb_mode_ib *mib; | ||
2126 | + | ||
2127 | + vesafb_reset_task(tsk); | ||
2128 | + tsk->regs.eax = 0x4f01; | ||
2129 | + tsk->regs.ecx = (u32) *mode; | ||
2130 | + tsk->flags = TF_CALL | TF_RETURN_BUF | TF_BUF_DI; | ||
2131 | + tsk->buf = vbe_modes+off; | ||
2132 | + tsk->buf_len = sizeof(struct vesafb_mode_ib); | ||
2133 | + if (vesafb_queue_task(tsk)) | ||
2134 | + return -EINVAL; | ||
2135 | + vesafb_wait_for_task(tsk); | ||
2136 | + mib = p_mode(tsk->buf); | ||
2137 | + mib->mode_id = *mode; | ||
2138 | + | ||
2139 | + /* We only want modes that are supported with the currennt | ||
2140 | + * hardware configuration (D0), color (D3), graphics (D4) | ||
2141 | + * and that have support for the LFB (D7). */ | ||
2142 | + if ((mib->mode_attr & 0x99) == 0x99 && | ||
2143 | + mib->bits_per_pixel >= 8) { | ||
2144 | + off++; | ||
2145 | + } else { | ||
2146 | + vbe_modes_cnt--; | ||
2147 | + } | ||
2148 | + mode++; | ||
2149 | + mib->depth = mib->red_len + mib->green_len + mib->blue_len; | ||
2150 | + /* Handle 8bpp modes and modes with broken color component | ||
2151 | + * lengths. */ | ||
2152 | + if (mib->depth == 0 || | ||
2153 | + (mib->depth == 24 && mib->bits_per_pixel == 32)) | ||
2154 | + mib->depth = mib->bits_per_pixel; | ||
2155 | + } | ||
2156 | + | ||
2157 | + return 0; | ||
2158 | +} | ||
2159 | + | ||
2160 | +static int __init inline vesafb_vbe_getpmi(struct vesafb_task *tsk) | ||
2161 | +{ | ||
2162 | + int i; | ||
2163 | + | ||
2164 | + vesafb_reset_task(tsk); | ||
2165 | + tsk->regs.eax = 0x4f0a; | ||
2166 | + tsk->regs.ebx = 0x0; | ||
2167 | + tsk->flags = TF_CALL; | ||
2168 | + if (vesafb_queue_task(tsk)) | ||
2169 | + return -EINVAL; | ||
2170 | + vesafb_wait_for_task(tsk); | ||
2171 | + | ||
2172 | + if ((tsk->regs.eax & 0xffff) != 0x004f || tsk->regs.es < 0xc000) { | ||
2173 | + pmi_setpal = ypan = 0; | ||
2174 | + } else { | ||
2175 | + pmi_base = (u16*)phys_to_virt(((u32)tsk->regs.es << 4) + | ||
2176 | + tsk->regs.edi); | ||
2177 | + pmi_start = (void*)((char*)pmi_base + pmi_base[1]); | ||
2178 | + pmi_pal = (void*)((char*)pmi_base + pmi_base[2]); | ||
2179 | + printk(KERN_INFO "vesafb: protected mode interface info at " | ||
2180 | + "%04x:%04x\n", | ||
2181 | + (u16)tsk->regs.es, (u16)tsk->regs.edi); | ||
2182 | + printk(KERN_INFO "vesafb: pmi: set display start = %p, " | ||
2183 | + "set palette = %p\n", pmi_start, pmi_pal); | ||
2184 | + | ||
2185 | + if (pmi_base[3]) { | ||
2186 | + printk(KERN_INFO "vesafb: pmi: ports = "); | ||
2187 | + for (i = pmi_base[3]/2; pmi_base[i] != 0xffff; i++) | ||
2188 | + printk("%x ",pmi_base[i]); | ||
2189 | + printk("\n"); | ||
2190 | + | ||
2191 | + /* | ||
2192 | + * memory areas not supported (yet?) | ||
2193 | + * | ||
2194 | + * Rules are: we have to set up a descriptor for the | ||
2195 | + * requested memory area and pass it in the ES register | ||
2196 | + * to the BIOS function. | ||
2197 | + */ | ||
2198 | + if (pmi_base[i] != 0xffff) { | ||
2199 | + printk(KERN_INFO "vesafb: can't handle memory " | ||
2200 | + "requests, pmi disabled\n"); | ||
2201 | + ypan = pmi_setpal = 0; | ||
2202 | + } | ||
2203 | + } | ||
2204 | + } | ||
2205 | + return 0; | ||
2206 | +} | ||
2207 | + | ||
2208 | +static int __init inline vesafb_vbe_getedid(struct vesafb_task *tsk, | ||
2209 | + struct fb_info *info) | ||
2210 | +{ | ||
2211 | + int res = 0; | ||
2212 | + | ||
2213 | + if (noedid || vbe_ib.vbe_version < 0x0300) | ||
2214 | + return -EINVAL; | ||
2215 | + | ||
2216 | + vesafb_reset_task(tsk); | ||
2217 | + tsk->regs.eax = 0x4f15; | ||
2218 | + tsk->regs.ebx = 0; | ||
2219 | + tsk->regs.ecx = 0; | ||
2220 | + if (vesafb_queue_task(tsk)) | ||
2221 | + return -EINVAL; | ||
2222 | + vesafb_wait_for_task(tsk); | ||
2223 | + | ||
2224 | + if ((tsk->regs.eax & 0xffff) != 0x004f) | ||
2225 | + return -EINVAL; | ||
2226 | + | ||
2227 | + if ((tsk->regs.ebx & 0x3) == 3) { | ||
2228 | + printk(KERN_INFO "vesafb: VBIOS/hardware supports both " | ||
2229 | + "DDC1 and DDC2 transfers\n"); | ||
2230 | + } else if ((tsk->regs.ebx & 0x3) == 2) { | ||
2231 | + printk(KERN_INFO "vesafb: VBIOS/hardware supports DDC2 " | ||
2232 | + "transfers\n"); | ||
2233 | + } else if ((tsk->regs.ebx & 0x3) == 1) { | ||
2234 | + printk(KERN_INFO "vesafb: VBIOS/hardware supports DDC1 " | ||
2235 | + "transfers\n"); | ||
2236 | + } else { | ||
2237 | + printk(KERN_INFO "vesafb: VBIOS/hardware doesn't support " | ||
2238 | + "DDC transfers\n"); | ||
2239 | + return -EINVAL; | ||
2240 | + } | ||
2241 | + | ||
2242 | + vesafb_reset_task(tsk); | ||
2243 | + tsk->regs.eax = 0x4f15; | ||
2244 | + tsk->regs.ebx = 1; | ||
2245 | + tsk->regs.ecx = tsk->regs.edx = 0; | ||
2246 | + tsk->flags = TF_CALL | TF_RETURN_BUF | TF_BUF_DI; | ||
2247 | + tsk->buf = kmalloc(EDID_LENGTH, GFP_KERNEL); | ||
2248 | + tsk->buf_len = EDID_LENGTH; | ||
2249 | + | ||
2250 | + if (vesafb_queue_task(tsk)) { | ||
2251 | + res = -EINVAL; | ||
2252 | + goto out; | ||
2253 | + } | ||
2254 | + vesafb_wait_for_task(tsk); | ||
2255 | + | ||
2256 | + if ((tsk->regs.eax & 0xffff) == 0x004f) { | ||
2257 | + fb_edid_to_monspecs(tsk->buf, &info->monspecs); | ||
2258 | + fb_videomode_to_modelist(info->monspecs.modedb, | ||
2259 | + info->monspecs.modedb_len, &info->modelist); | ||
2260 | + if (info->monspecs.vfmax && info->monspecs.hfmax) { | ||
2261 | + /* If the maximum pixel clock wasn't specified in | ||
2262 | + * the EDID block, set it to 300 MHz. */ | ||
2263 | + if (info->monspecs.dclkmax == 0) | ||
2264 | + info->monspecs.dclkmax = 300 * 1000000; | ||
2265 | + info->monspecs.gtf = 1; | ||
2266 | + } else { | ||
2267 | + res = -EINVAL; | ||
2268 | + } | ||
2269 | + } | ||
2270 | + | ||
2271 | +out: kfree(tsk->buf); | ||
2272 | + return res; | ||
2273 | +} | ||
2274 | + | ||
2275 | +static void __init inline vesafb_vbe_getmonspecs(struct vesafb_task *tsk, | ||
2276 | + struct fb_info *info) | ||
2277 | +{ | ||
2278 | + struct fb_var_screeninfo var; | ||
2279 | + int i; | ||
2280 | + memset(&info->monspecs, 0, sizeof(struct fb_monspecs)); | ||
2281 | + | ||
2282 | + /* If we didn't get all necessary data from the EDID block, | ||
2283 | + * mark it as incompatible with the GTF. */ | ||
2284 | + if (vesafb_vbe_getedid(tsk, info)) | ||
2285 | + info->monspecs.gtf = 0; | ||
2286 | + | ||
2287 | + /* Kernel command line overrides. */ | ||
2288 | + if (maxclk) | ||
2289 | + info->monspecs.dclkmax = maxclk * 1000000; | ||
2290 | + if (maxvf) | ||
2291 | + info->monspecs.vfmax = maxvf; | ||
2292 | + if (maxhf) | ||
2293 | + info->monspecs.hfmax = maxhf * 1000; | ||
2294 | + | ||
2295 | + /* In case DDC transfers are not supported the user can provide | ||
2296 | + * monitor limits manually. Lower limits are set to "safe" values. */ | ||
2297 | + if (info->monspecs.gtf == 0 && maxclk && maxvf && maxhf) { | ||
2298 | + info->monspecs.dclkmin = 0; | ||
2299 | + info->monspecs.vfmin = 60; | ||
2300 | + info->monspecs.hfmin = 29000; | ||
2301 | + info->monspecs.gtf = 1; | ||
2302 | + } | ||
2303 | + | ||
2304 | + if (info->monspecs.gtf) { | ||
2305 | + printk(KERN_INFO | ||
2306 | + "vesafb: monitor limits: vf = %d Hz, hf = %d kHz, " | ||
2307 | + "clk = %d MHz\n", info->monspecs.vfmax, | ||
2308 | + (int)(info->monspecs.hfmax / 1000), | ||
2309 | + (int)(info->monspecs.dclkmax / 1000000)); | ||
2310 | + /* Add valid VESA video modes to our modelist. */ | ||
2311 | + for (i = 0; i < VESA_MODEDB_SIZE; i++) { | ||
2312 | + fb_videomode_to_var(&var, (struct fb_videomode *) | ||
2313 | + &vesa_modes[i]); | ||
2314 | + if (!fb_validate_mode(&var, info)) | ||
2315 | + fb_add_videomode((struct fb_videomode *) | ||
2316 | + &vesa_modes[i], | ||
2317 | + &info->modelist); | ||
2318 | + } | ||
2319 | + } else { | ||
2320 | + /* Add all VESA video modes to our modelist. */ | ||
2321 | + fb_videomode_to_modelist((struct fb_videomode *)vesa_modes, | ||
2322 | + VESA_MODEDB_SIZE, &info->modelist); | ||
2323 | + printk(KERN_INFO "vesafb: no monitor limits have been set\n"); | ||
2324 | + } | ||
2325 | + return; | ||
2326 | +} | ||
2327 | + | ||
2328 | +static int __init inline vesafb_vbe_init(struct fb_info *info) | ||
2329 | +{ | ||
2330 | + struct vesafb_task *tsk; | ||
2331 | + int res = 0; | ||
2332 | + | ||
2333 | + vesafb_create_task(tsk); | ||
2334 | + if (!tsk) | ||
2335 | + return -EINVAL; | ||
2336 | + if ((res = vesafb_vbe_getinfo(tsk)) != 0) | ||
2337 | + goto out; | ||
2338 | + if ((res = vesafb_vbe_getmodes(tsk)) != 0) | ||
2339 | + goto out; | ||
2340 | + if (pmi_setpal || ypan) | ||
2341 | + vesafb_vbe_getpmi(tsk); | ||
2342 | + | ||
2343 | + INIT_LIST_HEAD(&info->modelist); | ||
2344 | + vesafb_vbe_getmonspecs(tsk, info); | ||
2345 | + | ||
2346 | +out: kfree(tsk); | ||
2347 | + return res; | ||
2348 | +} | ||
2349 | + | ||
2350 | +static int __init decode_mode(u32 *xres, u32 *yres, u32 *bpp, u32 *refresh) | ||
2351 | +{ | ||
2352 | + int len = strlen(mode_option), i, err = 0; | ||
2353 | + u8 res_specified = 0, bpp_specified = 0, refresh_specified = 0, | ||
2354 | + yres_specified = 0; | ||
2355 | + | ||
2356 | + for (i = len-1; i >= 0; i--) { | ||
2357 | + switch (mode_option[i]) { | ||
2358 | + case '@': | ||
2359 | + len = i; | ||
2360 | + if (!refresh_specified && !bpp_specified && | ||
2361 | + !yres_specified) { | ||
2362 | + *refresh = simple_strtoul(&mode_option[i+1], | ||
2363 | + NULL, 0); | ||
2364 | + refresh_specified = 1; | ||
2365 | + } else | ||
2366 | + goto out; | ||
2367 | + break; | ||
2368 | + case '-': | ||
2369 | + len = i; | ||
2370 | + if (!bpp_specified && !yres_specified) { | ||
2371 | + *bpp = simple_strtoul(&mode_option[i+1], | ||
2372 | + NULL, 0); | ||
2373 | + bpp_specified = 1; | ||
2374 | + } else | ||
2375 | + goto out; | ||
2376 | + break; | ||
2377 | + case 'x': | ||
2378 | + if (!yres_specified) { | ||
2379 | + *yres = simple_strtoul(&mode_option[i+1], | ||
2380 | + NULL, 0); | ||
2381 | + yres_specified = 1; | ||
2382 | + } else | ||
2383 | + goto out; | ||
2384 | + break; | ||
2385 | + case '0'...'9': | ||
2386 | + break; | ||
2387 | + default: | ||
2388 | + goto out; | ||
2389 | + } | ||
2390 | + } | ||
2391 | + | ||
2392 | + if (i < 0 && yres_specified) { | ||
2393 | + *xres = simple_strtoul(mode_option, NULL, 0); | ||
2394 | + res_specified = 1; | ||
2395 | + } | ||
2396 | + | ||
2397 | +out: if (!res_specified || !yres_specified) { | ||
2398 | + printk(KERN_ERR "vesafb: invalid resolution, " | ||
2399 | + "%s not specified\n", | ||
2400 | + (!res_specified) ? "width" : "height"); | ||
2401 | + err = -EINVAL; | ||
2402 | + } | ||
2403 | + | ||
2404 | + return err; | ||
2405 | +} | ||
2406 | + | ||
2407 | +static int __init vesafb_init_set_mode(struct fb_info *info) | ||
2408 | +{ | ||
2409 | + struct fb_videomode *fbmode; | ||
2410 | + struct fb_videomode mode; | ||
2411 | + int i, modeid, refresh = 0; | ||
2412 | + u8 refresh_specified = 0; | ||
2413 | + | ||
2414 | + if (!mode_option) | ||
2415 | + mode_option = CONFIG_FB_VESA_DEFAULT_MODE; | ||
2416 | + | ||
2417 | + if (vbemode > 0) { | ||
2418 | + for (i = 0; i < vbe_modes_cnt; i++) { | ||
2419 | + if (vbe_modes[i].mode_id == vbemode) { | ||
2420 | + info->var.vmode = FB_VMODE_NONINTERLACED; | ||
2421 | + info->var.sync = FB_SYNC_VERT_HIGH_ACT; | ||
2422 | + vesafb_setup_var(&info->var, info, | ||
2423 | + &vbe_modes[i]); | ||
2424 | + fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, | ||
2425 | + 60, &info->var, info); | ||
2426 | + /* With pixclock set to 0, the default BIOS | ||
2427 | + * timings will be used in set_par(). */ | ||
2428 | + info->var.pixclock = 0; | ||
2429 | + modeid = i; | ||
2430 | + goto out; | ||
2431 | + } | ||
2432 | + } | ||
2433 | + printk(KERN_INFO "specified VBE mode %d not found\n", | ||
2434 | + vbemode); | ||
2435 | + vbemode = 0; | ||
2436 | + } | ||
2437 | + | ||
2438 | + /* Decode the mode specified on the kernel command line. We save | ||
2439 | + * the depth into bits_per_pixel, which is wrong, but will work | ||
2440 | + * anyway. */ | ||
2441 | + if (decode_mode(&info->var.xres, &info->var.yres, | ||
2442 | + &info->var.bits_per_pixel, &refresh)) | ||
2443 | + return -EINVAL; | ||
2444 | + if (refresh) | ||
2445 | + refresh_specified = 1; | ||
2446 | + else | ||
2447 | + refresh = 60; | ||
2448 | + | ||
2449 | + /* Look for a matching VBE mode. We can live if an exact match | ||
2450 | + * cannot be found. */ | ||
2451 | + modeid = vesafb_find_vbe_mode(info->var.xres, info->var.yres, | ||
2452 | + info->var.bits_per_pixel, 0); | ||
2453 | + | ||
2454 | + if (modeid == -1) { | ||
2455 | + return -EINVAL; | ||
2456 | + } else { | ||
2457 | + info->var.vmode = FB_VMODE_NONINTERLACED; | ||
2458 | + info->var.sync = FB_SYNC_VERT_HIGH_ACT; | ||
2459 | + vesafb_setup_var(&info->var, info, &vbe_modes[modeid]); | ||
2460 | + } | ||
2461 | + if (vbe_ib.vbe_version < 0x0300) { | ||
2462 | + fb_get_mode(FB_VSYNCTIMINGS | FB_IGNOREMON, 60, | ||
2463 | + &info->var, info); | ||
2464 | + goto out; | ||
2465 | + } | ||
2466 | + if (!gtf) { | ||
2467 | + struct fb_videomode tmode; | ||
2468 | + | ||
2469 | + if (refresh_specified) { | ||
2470 | + fb_var_to_videomode(&tmode, &info->var); | ||
2471 | + tmode.refresh = refresh; | ||
2472 | + fbmode = fb_find_nearest_mode(&tmode, | ||
2473 | + &info->modelist); | ||
2474 | + } else | ||
2475 | + fbmode = fb_find_best_mode(&info->var, | ||
2476 | + &info->modelist); | ||
2477 | + | ||
2478 | + if (fbmode->xres == info->var.xres && | ||
2479 | + fbmode->yres == info->var.yres && | ||
2480 | + !(fbmode->vmode & (FB_VMODE_INTERLACED | FB_VMODE_DOUBLE)) | ||
2481 | + && (!refresh_specified || | ||
2482 | + abs(refresh - fbmode->refresh) <= 5)) { | ||
2483 | + fb_videomode_to_var(&info->var, fbmode); | ||
2484 | + return modeid; | ||
2485 | + } | ||
2486 | + } | ||
2487 | + i = FB_MAXTIMINGS; | ||
2488 | + if (!info->monspecs.gtf) | ||
2489 | + i = FB_IGNOREMON | FB_VSYNCTIMINGS; | ||
2490 | + else if (refresh_specified) | ||
2491 | + i = FB_VSYNCTIMINGS; | ||
2492 | + if (!fb_get_mode(i, refresh, &info->var, info)) | ||
2493 | + goto out; | ||
2494 | + if (info->monspecs.gtf && | ||
2495 | + !fb_get_mode(FB_MAXTIMINGS, 0, &info->var, info)) | ||
2496 | + goto out; | ||
2497 | + /* Use default refresh rate */ | ||
2498 | + printk(KERN_WARNING "vesafb: using default BIOS refresh rate\n"); | ||
2499 | + info->var.pixclock = 0; | ||
2500 | + | ||
2501 | +out: | ||
2502 | + fb_var_to_videomode(&mode, &info->var); | ||
2503 | + fb_add_videomode(&mode, &info->modelist); | ||
2504 | + return modeid; | ||
2505 | +} | ||
2506 | + | ||
2507 | +static int __init vesafb_probe(struct platform_device *dev) | ||
2508 | +{ | ||
2509 | + char entry[16]; | ||
2510 | + struct fb_info *info; | ||
2511 | + struct vesafb_mode_ib *mode = NULL; | ||
2512 | + int err = 0, i, h; | ||
2513 | + unsigned int size_vmode; | ||
2514 | + unsigned int size_remap; | ||
2515 | + unsigned int size_total; | ||
2516 | + | ||
2517 | + vesafb_info = info = framebuffer_alloc(sizeof(struct vesafb_par) + | ||
2518 | + sizeof(u32) * 256, &dev->dev); | ||
2519 | + if (!info) | ||
2520 | + return -ENOMEM; | ||
2521 | + | ||
2522 | + if (vesafb_wait_for_thread()) { | ||
2523 | + printk(KERN_ERR "vesafb: vesafb thread not running\n"); | ||
2524 | + framebuffer_release(info); | ||
2525 | + return -EINVAL; | ||
2526 | + } | ||
2527 | + | ||
2528 | + if (vesafb_vbe_init(info)) { | ||
2529 | + printk(KERN_ERR "vesafb: vbe_init failed\n"); | ||
2530 | + err = -EINVAL; | ||
2531 | + goto out; | ||
2532 | + } | ||
2533 | + | ||
2534 | + vesafb_fix.ypanstep = ypan ? 1 : 0; | ||
2535 | + vesafb_fix.ywrapstep = (ypan>1) ? 1 : 0; | ||
2536 | + | ||
2537 | + info->pseudo_palette = ((u8*)info->par + sizeof(struct vesafb_par)); | ||
2538 | + info->fbops = &vesafb_ops; | ||
2539 | + info->var = vesafb_defined; | ||
2540 | + info->fix = vesafb_fix; | ||
2541 | + | ||
2542 | + if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { | ||
2543 | + err = -ENXIO; | ||
2544 | + goto out; | ||
2545 | + } | ||
2546 | + | ||
2547 | + i = vesafb_init_set_mode(info); | ||
2548 | + if (i < 0) { | ||
2549 | + err = -EINVAL; | ||
2550 | + goto out_cmap; | ||
2551 | + } else | ||
2552 | + mode = &vbe_modes[i]; | ||
2553 | + | ||
2554 | + /* Disable blanking if the user requested so. */ | ||
2555 | + if (!blank) { | ||
2556 | + info->fbops->fb_blank = NULL; | ||
2557 | + } | ||
2558 | + | ||
2559 | + /* Find out how much IO memory is required for the mode with | ||
2560 | + * the highest resolution. */ | ||
2561 | + size_remap = 0; | ||
2562 | + for (i = 0; i < vbe_modes_cnt; i++) { | ||
2563 | + h = vbe_modes[i].bytes_per_scan_line * vbe_modes[i].y_res; | ||
2564 | + if (h > size_remap) | ||
2565 | + size_remap = h; | ||
2566 | + } | ||
2567 | + size_remap *= 2; | ||
2568 | + | ||
2569 | + /* size_vmode -- that is the amount of memory needed for the | ||
2570 | + * used video mode, i.e. the minimum amount of | ||
2571 | + * memory we need. */ | ||
2572 | + if (mode != NULL) { | ||
2573 | + size_vmode = info->var.yres * mode->bytes_per_scan_line; | ||
2574 | + } else { | ||
2575 | + size_vmode = info->var.yres * info->var.xres * | ||
2576 | + ((info->var.bits_per_pixel + 7) >> 3); | ||
2577 | + } | ||
2578 | + | ||
2579 | + /* size_total -- all video memory we have. Used for mtrr | ||
2580 | + * entries, ressource allocation and bounds | ||
2581 | + * checking. */ | ||
2582 | + size_total = vbe_ib.total_memory * 65536; | ||
2583 | + if (vram_total) | ||
2584 | + size_total = vram_total * 1024 * 1024; | ||
2585 | + if (size_total < size_vmode) | ||
2586 | + size_total = size_vmode; | ||
2587 | + ((struct vesafb_par*)(info->par))->mem_total = size_total; | ||
2588 | + | ||
2589 | + /* size_remap -- the amount of video memory we are going to | ||
2590 | + * use for vesafb. With modern cards it is no | ||
2591 | + * option to simply use size_total as th | ||
2592 | + * wastes plenty of kernel address space. */ | ||
2593 | + if (vram_remap) | ||
2594 | + size_remap = vram_remap * 1024 * 1024; | ||
2595 | + if (size_remap < size_vmode) | ||
2596 | + size_remap = size_vmode; | ||
2597 | + if (size_remap > size_total) | ||
2598 | + size_remap = size_total; | ||
2599 | + | ||
2600 | + info->fix.smem_len = size_remap; | ||
2601 | + info->fix.smem_start = mode->phys_base_ptr; | ||
2602 | + | ||
2603 | + /* We have to set it here, because when setup_var() was called, | ||
2604 | + * smem_len wasn't defined yet. */ | ||
2605 | + info->var.yres_virtual = info->fix.smem_len / | ||
2606 | + mode->bytes_per_scan_line; | ||
2607 | + | ||
2608 | + if (ypan && info->var.yres_virtual > info->var.yres) { | ||
2609 | + printk(KERN_INFO "vesafb: scrolling: %s " | ||
2610 | + "using protected mode interface, " | ||
2611 | + "yres_virtual=%d\n", | ||
2612 | + (ypan > 1) ? "ywrap" : "ypan",info->var.yres_virtual); | ||
2613 | + } else { | ||
2614 | + printk(KERN_INFO "vesafb: scrolling: redraw\n"); | ||
2615 | + info->var.yres_virtual = info->var.yres; | ||
2616 | + ypan = 0; | ||
2617 | + } | ||
2618 | + | ||
2619 | + info->flags = FBINFO_FLAG_DEFAULT | | ||
2620 | + (ypan) ? FBINFO_HWACCEL_YPAN : 0; | ||
2621 | + | ||
2622 | + if (!ypan) | ||
2623 | + info->fbops->fb_pan_display = NULL; | ||
2624 | + | ||
2625 | + if (!request_mem_region(info->fix.smem_start, size_total, "vesafb")) { | ||
2626 | + printk(KERN_WARNING "vesafb: cannot reserve video memory at " | ||
2627 | + "0x%lx\n", info->fix.smem_start); | ||
2628 | + /* We cannot make this fatal. Sometimes this comes from magic | ||
2629 | + spaces our resource handlers simply don't know about. */ | ||
2630 | + } | ||
2631 | + | ||
2632 | + info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); | ||
2633 | + | ||
2634 | + if (!info->screen_base) { | ||
2635 | + printk(KERN_ERR | ||
2636 | + "vesafb: abort, cannot ioremap video memory " | ||
2637 | + "0x%x @ 0x%lx\n", | ||
2638 | + info->fix.smem_len, info->fix.smem_start); | ||
2639 | + err = -EIO; | ||
2640 | + goto out_mem; | ||
2641 | + } | ||
2642 | + | ||
2643 | + /* Request failure does not faze us, as vgacon probably has this | ||
2644 | + region already (FIXME) */ | ||
2645 | + request_region(0x3c0, 32, "vesafb"); | ||
2646 | + | ||
2647 | +#ifdef CONFIG_MTRR | ||
2648 | + if (mtrr && !(info->fix.smem_start & (PAGE_SIZE - 1))) { | ||
2649 | + int temp_size = size_total; | ||
2650 | + unsigned int type = 0; | ||
2651 | + | ||
2652 | + switch (mtrr) { | ||
2653 | + case 1: | ||
2654 | + type = MTRR_TYPE_UNCACHABLE; | ||
2655 | + break; | ||
2656 | + case 2: | ||
2657 | + type = MTRR_TYPE_WRBACK; | ||
2658 | + break; | ||
2659 | + case 3: | ||
2660 | + type = MTRR_TYPE_WRCOMB; | ||
2661 | + break; | ||
2662 | + case 4: | ||
2663 | + type = MTRR_TYPE_WRTHROUGH; | ||
2664 | + break; | ||
2665 | + default: | ||
2666 | + type = 0; | ||
2667 | + break; | ||
2668 | + } | ||
2669 | + | ||
2670 | + if (type) { | ||
2671 | + int rc; | ||
2672 | + | ||
2673 | + /* Find the largest power-of-two */ | ||
2674 | + while (temp_size & (temp_size - 1)) | ||
2675 | + temp_size &= (temp_size - 1); | ||
2676 | + | ||
2677 | + /* Try and find a power of two to add */ | ||
2678 | + do { | ||
2679 | + rc = mtrr_add(info->fix.smem_start, | ||
2680 | + temp_size, type, 1); | ||
2681 | + temp_size >>= 1; | ||
2682 | + } while (temp_size >= PAGE_SIZE && rc == -EINVAL); | ||
2683 | + } | ||
2684 | + } | ||
2685 | +#endif /* CONFIG_MTRR */ | ||
2686 | + | ||
2687 | + if (register_framebuffer(info) < 0) { | ||
2688 | + printk(KERN_ERR | ||
2689 | + "vesafb: failed to register framebuffer device\n"); | ||
2690 | + err = -EINVAL; | ||
2691 | + goto out_mem; | ||
2692 | + } | ||
2693 | + | ||
2694 | + printk(KERN_INFO "vesafb: framebuffer at 0x%lx, mapped to 0x%p, " | ||
2695 | + "using %dk, total %dk\n", info->fix.smem_start, | ||
2696 | + info->screen_base, size_remap/1024, size_total/1024); | ||
2697 | + printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, | ||
2698 | + info->fix.id); | ||
2699 | + | ||
2700 | + sprintf(entry, "fb%d", info->node); | ||
2701 | + proc_mkdir(entry, 0); | ||
2702 | + | ||
2703 | + sprintf(entry, "fb%d/modes", info->node); | ||
2704 | + create_proc_read_entry(entry, 0, 0, vesafb_read_proc_modes, NULL); | ||
2705 | + | ||
2706 | + sprintf(entry, "fb%d/vbe_info", info->node); | ||
2707 | + create_proc_read_entry(entry, 0, 0, vesafb_read_proc_vbe_info, NULL); | ||
2708 | + return 0; | ||
2709 | + | ||
2710 | +out_mem: | ||
2711 | + release_mem_region(info->fix.smem_start, size_total); | ||
2712 | + if (!list_empty(&info->modelist)) | ||
2713 | + fb_destroy_modelist(&info->modelist); | ||
2714 | + fb_destroy_modedb(info->monspecs.modedb); | ||
2715 | +out_cmap: | ||
2716 | + fb_dealloc_cmap(&info->cmap); | ||
2717 | +out: | ||
2718 | + framebuffer_release(info); | ||
2719 | + vesafb_info = NULL; | ||
2720 | + kfree(vbe_modes); | ||
2721 | + vbe_modes = NULL; | ||
2722 | + return err; | ||
2723 | +} | ||
2724 | + | ||
2725 | +int __init vesafb_init(void) | ||
2726 | +{ | ||
2727 | + int ret; | ||
2728 | +#ifndef MODULE | ||
2729 | + char *option = NULL; | ||
2730 | + | ||
2731 | + if (fb_get_options("vesafb", &option)) | ||
2732 | + return -ENODEV; | ||
2733 | + vesafb_setup(option); | ||
2734 | +#endif | ||
2735 | + ret = platform_driver_register(&vesafb_driver); | ||
2736 | + | ||
2737 | + if (!ret) { | ||
2738 | + vesafb_device = platform_device_alloc("vesafb", 0); | ||
2739 | + | ||
2740 | + if (vesafb_device) | ||
2741 | + ret = platform_device_add(vesafb_device); | ||
2742 | + else | ||
2743 | + ret = -ENOMEM; | ||
2744 | + | ||
2745 | + if (ret) { | ||
2746 | + platform_device_put(vesafb_device); | ||
2747 | + platform_driver_unregister(&vesafb_driver); | ||
2748 | + } | ||
2749 | + } | ||
2750 | + return ret; | ||
2751 | +} | ||
2752 | + | ||
2753 | +module_init(vesafb_init); | ||
2754 | + | ||
2755 | +#ifdef MODULE | ||
2756 | +void __exit vesafb_exit(void) | ||
2757 | +{ | ||
2758 | + char entry[16]; | ||
2759 | + | ||
2760 | + if (vesafb_info) | ||
2761 | + unregister_framebuffer(vesafb_info); | ||
2762 | + | ||
2763 | + platform_device_unregister(vesafb_device); | ||
2764 | + platform_driver_unregister(&vesafb_driver); | ||
2765 | + | ||
2766 | + if (vesafb_info) { | ||
2767 | + struct vesafb_par *par = (struct vesafb_par*)vesafb_info->par; | ||
2768 | + | ||
2769 | + sprintf(entry, "fb%d/modes", vesafb_info->node); | ||
2770 | + remove_proc_entry(entry, NULL); | ||
2771 | + | ||
2772 | + sprintf(entry, "fb%d/vbe_info", vesafb_info->node); | ||
2773 | + remove_proc_entry(entry, NULL); | ||
2774 | + | ||
2775 | + sprintf(entry, "fb%d", vesafb_info->node); | ||
2776 | + remove_proc_entry(entry, NULL); | ||
2777 | + | ||
2778 | + iounmap(vesafb_info->screen_base); | ||
2779 | + release_mem_region(vesafb_info->fix.smem_start, | ||
2780 | + par->mem_total); | ||
2781 | + fb_dealloc_cmap(&vesafb_info->cmap); | ||
2782 | + if (!list_empty(&vesafb_info->modelist)) | ||
2783 | + fb_destroy_modelist(&vesafb_info->modelist); | ||
2784 | + fb_destroy_modedb(vesafb_info->monspecs.modedb); | ||
2785 | + framebuffer_release(vesafb_info); | ||
2786 | + } | ||
2787 | + | ||
2788 | + if (vbe_modes != NULL) | ||
2789 | + kfree(vbe_modes); | ||
2790 | +} | ||
2791 | + | ||
2792 | +module_exit(vesafb_exit); | ||
2793 | + | ||
2794 | +static inline int param_get_scroll(char *buffer, struct kernel_param *kp) | ||
2795 | +{ | ||
2796 | + return 0; | ||
2797 | +} | ||
2798 | +static inline int param_set_scroll(const char *val, struct kernel_param *kp) | ||
2799 | +{ | ||
2800 | + ypan = 0; | ||
2801 | + | ||
2802 | + if (! strcmp(val, "redraw")) | ||
2803 | + ypan = 0; | ||
2804 | + else if (! strcmp(val, "ypan")) | ||
2805 | + ypan = 1; | ||
2806 | + else if (! strcmp(val, "ywrap")) | ||
2807 | + ypan = 2; | ||
2808 | + | ||
2809 | + return 0; | ||
2810 | +} | ||
2811 | + | ||
2812 | +#define param_check_scroll(name, p) __param_check(name, p, void); | ||
2813 | + | ||
2814 | +module_param_named(scroll, ypan, scroll, 0); | ||
2815 | +MODULE_PARM_DESC(scroll,"Scrolling mode, set to 'redraw', 'ypan' or 'ywrap'"); | ||
2816 | +module_param_named(vgapal, pmi_setpal, invbool, 0); | ||
2817 | +MODULE_PARM_DESC(vgapal,"bool: set palette using VGA registers"); | ||
2818 | +module_param_named(pmipal, pmi_setpal, bool, 0); | ||
2819 | +MODULE_PARM_DESC(pmipal,"bool: set palette using PMI calls"); | ||
2820 | +module_param_named(nomtrr, mtrr, invbool, 0); | ||
2821 | +MODULE_PARM_DESC(nomtrr,"bool: disable use of MTRR registers"); | ||
2822 | +module_param(blank, bool, 1); | ||
2823 | +MODULE_PARM_DESC(blank,"bool: enable hardware blanking"); | ||
2824 | +module_param(nocrtc, bool, 0); | ||
2825 | +MODULE_PARM_DESC(nocrtc,"bool: ignore CRTC timings when setting modes"); | ||
2826 | +module_param(noedid, bool, 0); | ||
2827 | +MODULE_PARM_DESC(noedid,"bool: ignore EDID-provided monitor limits " | ||
2828 | + "when setting modes"); | ||
2829 | +module_param(gtf, bool, 0); | ||
2830 | +MODULE_PARM_DESC(gtf,"bool: force use of VESA GTF to calculate mode timings"); | ||
2831 | +module_param(vram_remap, uint, 0); | ||
2832 | +MODULE_PARM_DESC(vram_remap,"Set amount of video memory to be used [MiB]"); | ||
2833 | +module_param(vram_total, uint, 0); | ||
2834 | +MODULE_PARM_DESC(vram_total,"Set total amount of video memoery [MiB]"); | ||
2835 | +module_param(maxclk, ushort, 0); | ||
2836 | +MODULE_PARM_DESC(maxclk,"Maximum pixelclock [MHz], overrides EDID data"); | ||
2837 | +module_param(maxhf, ushort, 0); | ||
2838 | +MODULE_PARM_DESC(maxhf,"Maximum horizontal frequency [kHz], " | ||
2839 | + "overrides EDID data"); | ||
2840 | +module_param(maxvf, ushort, 0); | ||
2841 | +MODULE_PARM_DESC(maxvf,"Maximum vertical frequency [Hz], " | ||
2842 | + "overrides EDID data"); | ||
2843 | +module_param_named(mode, mode_option, charp, 0); | ||
2844 | +MODULE_PARM_DESC(mode, "Specify resolution as " | ||
2845 | + "\"<xres>x<yres>[-<bpp>][@<refresh>]\""); | ||
2846 | +module_param(vbemode, ushort, 0); | ||
2847 | +MODULE_PARM_DESC(vbemode,"VBE mode number to set, overrides 'mode' setting"); | ||
2848 | + | ||
2849 | +#endif /* MODULE */ | ||
2850 | + | ||
2851 | +MODULE_LICENSE("GPL"); | ||
2852 | +MODULE_AUTHOR("Michal Januszewski"); | ||
2853 | +MODULE_DESCRIPTION("Framebuffer driver for VBE2.0+ compliant graphics boards"); | ||
2854 | + | ||
2855 | --- linux-2.6.17.orig/include/linux/sched.h | ||
2856 | +++ linux-2.6.17/include/linux/sched.h | ||
2857 | @@ -1159,6 +1159,8 @@ extern void mmput(struct mm_struct *); | ||
2858 | extern struct mm_struct *get_task_mm(struct task_struct *task); | ||
2859 | /* Remove the current tasks stale references to the old mm_struct */ | ||
2860 | extern void mm_release(struct task_struct *, struct mm_struct *); | ||
2861 | +/* Create a new mm for a kernel thread */ | ||
2862 | +extern int set_new_mm(void); | ||
2863 | |||
2864 | extern int copy_thread(int, unsigned long, unsigned long, unsigned long, struct task_struct *, struct pt_regs *); | ||
2865 | extern void flush_thread(void); | ||
2866 | --- /dev/null | ||
2867 | +++ linux-2.6.17/include/video/vesa.h | ||
2868 | @@ -0,0 +1,150 @@ | ||
2869 | +#if 0 | ||
2870 | +#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , \ | ||
2871 | + ## args) | ||
2872 | +#else | ||
2873 | +#define DPRINTK(fmt, args...) | ||
2874 | +#endif | ||
2875 | + | ||
2876 | +#define p_crtc(arg) ((struct vesafb_crtc_ib*)(arg)) | ||
2877 | +#define p_vbe(arg) ((struct vesafb_vbe_ib*)(arg)) | ||
2878 | +#define p_mode(arg) ((struct vesafb_mode_ib*)(arg)) | ||
2879 | + | ||
2880 | +struct vesafb_task { | ||
2881 | + u8 flags; | ||
2882 | + void *buf; | ||
2883 | + int buf_len; | ||
2884 | + struct vm86_regs regs; | ||
2885 | + struct list_head node; | ||
2886 | + struct completion done; | ||
2887 | +}; | ||
2888 | + | ||
2889 | +/* Vesafb task flags and masks */ | ||
2890 | +#define TF_CALL 0x00 | ||
2891 | +#define TF_EXIT 0x01 | ||
2892 | +#define TF_GETVBEIB 0x02 | ||
2893 | +#define TF_BUF_DI 0x04 | ||
2894 | +#define TF_BUF_BX 0x08 | ||
2895 | +#define TF_RETURN_BUF 0x10 | ||
2896 | + | ||
2897 | +/* Macros and functions for manipulating vesafb tasks */ | ||
2898 | +#define vesafb_create_task(task) \ | ||
2899 | +do { \ | ||
2900 | + task = kmalloc(sizeof(struct vesafb_task), GFP_ATOMIC); \ | ||
2901 | + if (task) \ | ||
2902 | + memset(task, 0, sizeof(struct vesafb_task)); \ | ||
2903 | + init_completion(&task->done); \ | ||
2904 | +} while (0) | ||
2905 | + | ||
2906 | +#define vesafb_wait_for_task(task) wait_for_completion(&task->done); | ||
2907 | +#define vesafb_reset_task(task) init_completion(&task->done); | ||
2908 | +int vesafb_queue_task(struct vesafb_task *task); | ||
2909 | + | ||
2910 | +/* Functions for controlling the vesafb thread */ | ||
2911 | +int vesafb_wait_for_thread(void); | ||
2912 | + | ||
2913 | +#define VBE_CAP_CAN_SWITCH_DAC 0x01 | ||
2914 | +#define VBE_CAP_VGACOMPAT 0x02 | ||
2915 | + | ||
2916 | +/* This struct is 512 bytes long */ | ||
2917 | +struct vesafb_vbe_ib { | ||
2918 | + char vbe_signature[4]; | ||
2919 | + u16 vbe_version; | ||
2920 | + u32 oem_string_ptr; | ||
2921 | + u32 capabilities; | ||
2922 | + u32 mode_list_ptr; | ||
2923 | + u16 total_memory; | ||
2924 | + u16 oem_software_rev; | ||
2925 | + u32 oem_vendor_name_ptr; | ||
2926 | + u32 oem_product_name_ptr; | ||
2927 | + u32 oem_product_rev_ptr; | ||
2928 | + u8 reserved[222]; | ||
2929 | + char oem_data[256]; | ||
2930 | +} __attribute__ ((packed)); | ||
2931 | + | ||
2932 | +struct vesafb_crtc_ib { | ||
2933 | + u16 horiz_total; | ||
2934 | + u16 horiz_start; | ||
2935 | + u16 horiz_end; | ||
2936 | + u16 vert_total; | ||
2937 | + u16 vert_start; | ||
2938 | + u16 vert_end; | ||
2939 | + u8 flags; | ||
2940 | + u32 pixel_clock; | ||
2941 | + u16 refresh_rate; | ||
2942 | + u8 reserved[40]; | ||
2943 | +} __attribute__ ((packed)); | ||
2944 | + | ||
2945 | +#define VBE_MODE_VGACOMPAT 0x20 | ||
2946 | + | ||
2947 | +struct vesafb_mode_ib { | ||
2948 | + /* for all VBE revisions */ | ||
2949 | + u16 mode_attr; | ||
2950 | + u8 winA_attr; | ||
2951 | + u8 winB_attr; | ||
2952 | + u16 win_granularity; | ||
2953 | + u16 win_size; | ||
2954 | + u16 winA_seg; | ||
2955 | + u16 winB_seg; | ||
2956 | + u32 win_func_ptr; | ||
2957 | + u16 bytes_per_scan_line; | ||
2958 | + | ||
2959 | + /* for VBE 1.2+ */ | ||
2960 | + u16 x_res; | ||
2961 | + u16 y_res; | ||
2962 | + u8 x_char_size; | ||
2963 | + u8 y_char_size; | ||
2964 | + u8 planes; | ||
2965 | + u8 bits_per_pixel; | ||
2966 | + u8 banks; | ||
2967 | + u8 memory_model; | ||
2968 | + u8 bank_size; | ||
2969 | + u8 image_pages; | ||
2970 | + u8 reserved1; | ||
2971 | + | ||
2972 | + /* Direct color fields for direct/6 and YUV/7 memory models. */ | ||
2973 | + /* Offsets are bit positions of lsb in the mask. */ | ||
2974 | + u8 red_len; | ||
2975 | + u8 red_off; | ||
2976 | + u8 green_len; | ||
2977 | + u8 green_off; | ||
2978 | + u8 blue_len; | ||
2979 | + u8 blue_off; | ||
2980 | + u8 rsvd_len; | ||
2981 | + u8 rsvd_off; | ||
2982 | + u8 direct_color_info; /* direct color mode attributes */ | ||
2983 | + | ||
2984 | + /* for VBE 2.0+ */ | ||
2985 | + u32 phys_base_ptr; | ||
2986 | + u8 reserved2[6]; | ||
2987 | + | ||
2988 | + /* for VBE 3.0+ */ | ||
2989 | + u16 lin_bytes_per_scan_line; | ||
2990 | + u8 bnk_image_pages; | ||
2991 | + u8 lin_image_pages; | ||
2992 | + u8 lin_red_len; | ||
2993 | + u8 lin_red_off; | ||
2994 | + u8 lin_green_len; | ||
2995 | + u8 lin_green_off; | ||
2996 | + u8 lin_blue_len; | ||
2997 | + u8 lin_blue_off; | ||
2998 | + u8 lin_rsvd_len; | ||
2999 | + u8 lin_rsvd_off; | ||
3000 | + u32 max_pixel_clock; | ||
3001 | + u16 mode_id; | ||
3002 | + u8 depth; | ||
3003 | +} __attribute__ ((packed)); | ||
3004 | + | ||
3005 | +struct vesafb_pal_entry { | ||
3006 | + u_char blue, green, red, pad; | ||
3007 | +} __attribute__ ((packed)); | ||
3008 | + | ||
3009 | +struct vesafb_par { | ||
3010 | + u8 *vbe_state; | ||
3011 | + int vbe_state_size; | ||
3012 | + atomic_t ref_count; | ||
3013 | + | ||
3014 | + u32 mem_total; | ||
3015 | + int mode_idx; | ||
3016 | + struct vesafb_crtc_ib crtc; | ||
3017 | +}; | ||
3018 | + | ||
3019 | --- linux-2.6.17.orig/kernel/fork.c | ||
3020 | +++ linux-2.6.17/kernel/fork.c | ||
3021 | @@ -97,6 +97,7 @@ kmem_cache_t *fs_cachep; | ||
3022 | |||
3023 | /* SLAB cache for vm_area_struct structures */ | ||
3024 | kmem_cache_t *vm_area_cachep; | ||
3025 | +EXPORT_SYMBOL_GPL(vm_area_cachep); | ||
3026 | |||
3027 | /* SLAB cache for mm_struct structures (tsk->mm) */ | ||
3028 | static kmem_cache_t *mm_cachep; | ||
3029 | @@ -383,6 +384,40 @@ void mmput(struct mm_struct *mm) | ||
3030 | EXPORT_SYMBOL_GPL(mmput); | ||
3031 | |||
3032 | /** | ||
3033 | + * set_new_mm - allocate, init and activate a new mm for a kernel thread | ||
3034 | + */ | ||
3035 | +int set_new_mm(void) | ||
3036 | +{ | ||
3037 | + struct mm_struct *mm; | ||
3038 | + struct task_struct *tsk = current; | ||
3039 | + struct mm_struct *active_mm; | ||
3040 | + | ||
3041 | + mm = mm_alloc(); | ||
3042 | + if (!mm) | ||
3043 | + goto fail_nomem; | ||
3044 | + if (init_new_context(current,mm)) | ||
3045 | + goto fail_nocontext; | ||
3046 | + | ||
3047 | + task_lock(tsk); | ||
3048 | + tsk->flags |= PF_BORROWED_MM; | ||
3049 | + active_mm = tsk->active_mm; | ||
3050 | + current->mm = mm; | ||
3051 | + current->active_mm = mm; | ||
3052 | + activate_mm(active_mm, mm); | ||
3053 | + task_unlock(current); | ||
3054 | + | ||
3055 | + /* Drop the previous active_mm */ | ||
3056 | + mmdrop(active_mm); | ||
3057 | + return 0; | ||
3058 | + | ||
3059 | +fail_nocontext: | ||
3060 | + mmdrop(mm); | ||
3061 | +fail_nomem: | ||
3062 | + return -EINVAL; | ||
3063 | +} | ||
3064 | +EXPORT_SYMBOL_GPL(set_new_mm); | ||
3065 | + | ||
3066 | +/** | ||
3067 | * get_task_mm - acquire a reference to the task's mm | ||
3068 | * | ||
3069 | * Returns %NULL if the task has no mm. Checks PF_BORROWED_MM (meaning | ||
3070 | --- linux-2.6.17.orig/mm/memory.c | ||
3071 | +++ linux-2.6.17/mm/memory.c | ||
3072 | @@ -1162,6 +1162,7 @@ int zeromap_page_range(struct vm_area_st | ||
3073 | } while (pgd++, addr = next, addr != end); | ||
3074 | return err; | ||
3075 | } | ||
3076 | +EXPORT_SYMBOL_GPL(zeromap_page_range); | ||
3077 | |||
3078 | pte_t * fastcall get_locked_pte(struct mm_struct *mm, unsigned long addr, spinlock_t **ptl) | ||
3079 | { | ||
3080 | --- linux-2.6.17.orig/mm/mmap.c | ||
3081 | +++ linux-2.6.17/mm/mmap.c | ||
3082 | @@ -1996,6 +1996,7 @@ int insert_vm_struct(struct mm_struct * | ||
3083 | vma_link(mm, vma, prev, rb_link, rb_parent); | ||
3084 | return 0; | ||
3085 | } | ||
3086 | +EXPORT_SYMBOL_GPL(insert_vm_struct); | ||
3087 | |||
3088 | /* | ||
3089 | * Copy the vma structure to a new location in the same mm, | ||
diff --git a/meta/packages/linux/linux-openzaurus_2.6.17.bb b/meta/packages/linux/linux-openzaurus_2.6.17.bb index f5460ae54f..80d7a72541 100644 --- a/meta/packages/linux/linux-openzaurus_2.6.17.bb +++ b/meta/packages/linux/linux-openzaurus_2.6.17.bb | |||
@@ -1,6 +1,6 @@ | |||
1 | require linux-openzaurus.inc | 1 | require linux-openzaurus.inc |
2 | 2 | ||
3 | PR = "r27" | 3 | PR = "r28" |
4 | 4 | ||
5 | # Handy URLs | 5 | # Handy URLs |
6 | # git://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git \ | 6 | # git://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git \ |
@@ -63,6 +63,7 @@ SRC_URI = "http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.17.tar.bz2 \ | |||
63 | file://connectplus-remove-ide-HACK.patch;patch=1;status=hack \ | 63 | file://connectplus-remove-ide-HACK.patch;patch=1;status=hack \ |
64 | file://orinoco-remove-all-which-are-in-hostap-HACK.patch;patch=1;status=unmergable-hack \ | 64 | file://orinoco-remove-all-which-are-in-hostap-HACK.patch;patch=1;status=unmergable-hack \ |
65 | file://squashfs3.0-2.6.15.patch;patch=1;status=external \ | 65 | file://squashfs3.0-2.6.15.patch;patch=1;status=external \ |
66 | file://vesafb-tng-1.0-rc2-git-20060629.patch;patch=1;status=external \ | ||
66 | file://defconfig-c7x0 \ | 67 | file://defconfig-c7x0 \ |
67 | file://defconfig-ipaq-pxa270 \ | 68 | file://defconfig-ipaq-pxa270 \ |
68 | file://defconfig-collie \ | 69 | file://defconfig-collie \ |