diff options
author | Paul Mackerras <paulus@samba.org> | 2007-05-07 23:37:51 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-05-07 23:37:51 -0400 |
commit | 02bbc0f09c90cefdb2837605c96a66c5ce4ba2e1 (patch) | |
tree | 04ef573cd4de095c500c9fc3477f4278c0b36300 /drivers/video | |
parent | 7487a2245b8841c77ba9db406cf99a483b9334e9 (diff) | |
parent | 5b94f675f57e4ff16c8fda09088d7480a84dcd91 (diff) |
Merge branch 'linux-2.6'
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/Kconfig | 39 | ||||
-rw-r--r-- | drivers/video/Makefile | 5 | ||||
-rw-r--r-- | drivers/video/atafb.c | 2801 | ||||
-rw-r--r-- | drivers/video/atafb.h | 36 | ||||
-rw-r--r-- | drivers/video/atafb_iplan2p2.c | 293 | ||||
-rw-r--r-- | drivers/video/atafb_iplan2p4.c | 308 | ||||
-rw-r--r-- | drivers/video/atafb_iplan2p8.c | 345 | ||||
-rw-r--r-- | drivers/video/atafb_mfb.c | 112 | ||||
-rw-r--r-- | drivers/video/atafb_utils.h | 400 | ||||
-rw-r--r-- | drivers/video/aty/radeon_i2c.c | 1 | ||||
-rw-r--r-- | drivers/video/console/vgacon.c | 3 | ||||
-rw-r--r-- | drivers/video/g364fb.c | 1 | ||||
-rw-r--r-- | drivers/video/intelfb/intelfb_i2c.c | 3 | ||||
-rw-r--r-- | drivers/video/matrox/i2c-matroxfb.c | 2 | ||||
-rw-r--r-- | drivers/video/platinumfb.c | 1 | ||||
-rw-r--r-- | drivers/video/ps3fb.c | 116 | ||||
-rw-r--r-- | drivers/video/pxafb.c | 4 | ||||
-rw-r--r-- | drivers/video/stifb.c | 1 | ||||
-rw-r--r-- | drivers/video/sunxvr2500.c | 277 | ||||
-rw-r--r-- | drivers/video/sunxvr500.c | 443 | ||||
-rw-r--r-- | drivers/video/valkyriefb.c | 1 |
21 files changed, 3819 insertions, 1373 deletions
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index b1cb72c3780f..344c37595305 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -191,7 +191,7 @@ config FB_ARMCLCD | |||
191 | 191 | ||
192 | If you want to compile this as a module (=code which can be | 192 | If you want to compile this as a module (=code which can be |
193 | inserted into and removed from the running kernel), say M | 193 | inserted into and removed from the running kernel), say M |
194 | here and read <file:Documentation/modules.txt>. The module | 194 | here and read <file:Documentation/kbuild/modules.txt>. The module |
195 | will be called amba-clcd. | 195 | will be called amba-clcd. |
196 | 196 | ||
197 | choice | 197 | choice |
@@ -389,7 +389,10 @@ config FB_ARC | |||
389 | 389 | ||
390 | config FB_ATARI | 390 | config FB_ATARI |
391 | bool "Atari native chipset support" | 391 | bool "Atari native chipset support" |
392 | depends on (FB = y) && ATARI && BROKEN | 392 | depends on (FB = y) && ATARI |
393 | select FB_CFB_FILLRECT | ||
394 | select FB_CFB_COPYAREA | ||
395 | select FB_CFB_IMAGEBLIT | ||
393 | help | 396 | help |
394 | This is the frame buffer device driver for the builtin graphics | 397 | This is the frame buffer device driver for the builtin graphics |
395 | chipset found in Ataris. | 398 | chipset found in Ataris. |
@@ -1380,6 +1383,32 @@ config FB_LEO | |||
1380 | This is the frame buffer device driver for the SBUS-based Sun ZX | 1383 | This is the frame buffer device driver for the SBUS-based Sun ZX |
1381 | (leo) frame buffer cards. | 1384 | (leo) frame buffer cards. |
1382 | 1385 | ||
1386 | config FB_XVR500 | ||
1387 | bool "Sun XVR-500 3DLABS Wildcat support" | ||
1388 | depends on FB && PCI && SPARC64 | ||
1389 | select FB_CFB_FILLRECT | ||
1390 | select FB_CFB_COPYAREA | ||
1391 | select FB_CFB_IMAGEBLIT | ||
1392 | help | ||
1393 | This is the framebuffer device for the Sun XVR-500 and similar | ||
1394 | graphics cards based upon the 3DLABS Wildcat chipset. The driver | ||
1395 | only works on sparc64 systems where the system firwmare has | ||
1396 | mostly initialized the card already. It is treated as a | ||
1397 | completely dumb framebuffer device. | ||
1398 | |||
1399 | config FB_XVR2500 | ||
1400 | bool "Sun XVR-2500 3DLABS Wildcat support" | ||
1401 | depends on FB && PCI && SPARC64 | ||
1402 | select FB_CFB_FILLRECT | ||
1403 | select FB_CFB_COPYAREA | ||
1404 | select FB_CFB_IMAGEBLIT | ||
1405 | help | ||
1406 | This is the framebuffer device for the Sun XVR-2500 and similar | ||
1407 | graphics cards based upon the 3DLABS Wildcat chipset. The driver | ||
1408 | only works on sparc64 systems where the system firwmare has | ||
1409 | mostly initialized the card already. It is treated as a | ||
1410 | completely dumb framebuffer device. | ||
1411 | |||
1383 | config FB_PCI | 1412 | config FB_PCI |
1384 | bool "PCI framebuffers" | 1413 | bool "PCI framebuffers" |
1385 | depends on (FB = y) && PCI && SPARC | 1414 | depends on (FB = y) && PCI && SPARC |
@@ -1491,7 +1520,7 @@ config FB_PXA | |||
1491 | This driver is also available as a module ( = code which can be | 1520 | This driver is also available as a module ( = code which can be |
1492 | inserted and removed from the running kernel whenever you want). The | 1521 | inserted and removed from the running kernel whenever you want). The |
1493 | module will be called pxafb. If you want to compile it as a module, | 1522 | module will be called pxafb. If you want to compile it as a module, |
1494 | say M here and read <file:Documentation/modules.txt>. | 1523 | say M here and read <file:Documentation/kbuild/modules.txt>. |
1495 | 1524 | ||
1496 | If unsure, say N. | 1525 | If unsure, say N. |
1497 | 1526 | ||
@@ -1544,7 +1573,7 @@ config FB_W100 | |||
1544 | This driver is also available as a module ( = code which can be | 1573 | This driver is also available as a module ( = code which can be |
1545 | inserted and removed from the running kernel whenever you want). The | 1574 | inserted and removed from the running kernel whenever you want). The |
1546 | module will be called w100fb. If you want to compile it as a module, | 1575 | module will be called w100fb. If you want to compile it as a module, |
1547 | say M here and read <file:Documentation/modules.txt>. | 1576 | say M here and read <file:Documentation/kbuild/modules.txt>. |
1548 | 1577 | ||
1549 | If unsure, say N. | 1578 | If unsure, say N. |
1550 | 1579 | ||
@@ -1561,7 +1590,7 @@ config FB_S3C2410 | |||
1561 | This driver is also available as a module ( = code which can be | 1590 | This driver is also available as a module ( = code which can be |
1562 | inserted and removed from the running kernel whenever you want). The | 1591 | inserted and removed from the running kernel whenever you want). The |
1563 | module will be called s3c2410fb. If you want to compile it as a module, | 1592 | module will be called s3c2410fb. If you want to compile it as a module, |
1564 | say M here and read <file:Documentation/modules.txt>. | 1593 | say M here and read <file:Documentation/kbuild/modules.txt>. |
1565 | 1594 | ||
1566 | If unsure, say N. | 1595 | If unsure, say N. |
1567 | config FB_S3C2410_DEBUG | 1596 | config FB_S3C2410_DEBUG |
diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 760305c8a841..558473d040d6 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile | |||
@@ -63,9 +63,12 @@ obj-$(CONFIG_FB_TCX) += tcx.o sbuslib.o | |||
63 | obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o | 63 | obj-$(CONFIG_FB_LEO) += leo.o sbuslib.o |
64 | obj-$(CONFIG_FB_SGIVW) += sgivwfb.o | 64 | obj-$(CONFIG_FB_SGIVW) += sgivwfb.o |
65 | obj-$(CONFIG_FB_ACORN) += acornfb.o | 65 | obj-$(CONFIG_FB_ACORN) += acornfb.o |
66 | obj-$(CONFIG_FB_ATARI) += atafb.o | 66 | obj-$(CONFIG_FB_ATARI) += atafb.o c2p.o atafb_mfb.o \ |
67 | atafb_iplan2p2.o atafb_iplan2p4.o atafb_iplan2p8.o | ||
67 | obj-$(CONFIG_FB_MAC) += macfb.o | 68 | obj-$(CONFIG_FB_MAC) += macfb.o |
68 | obj-$(CONFIG_FB_HGA) += hgafb.o | 69 | obj-$(CONFIG_FB_HGA) += hgafb.o |
70 | obj-$(CONFIG_FB_XVR500) += sunxvr500.o | ||
71 | obj-$(CONFIG_FB_XVR2500) += sunxvr2500.o | ||
69 | obj-$(CONFIG_FB_IGA) += igafb.o | 72 | obj-$(CONFIG_FB_IGA) += igafb.o |
70 | obj-$(CONFIG_FB_APOLLO) += dnfb.o | 73 | obj-$(CONFIG_FB_APOLLO) += dnfb.o |
71 | obj-$(CONFIG_FB_Q40) += q40fb.o | 74 | obj-$(CONFIG_FB_Q40) += q40fb.o |
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c index bffe2b946344..0038a0541c7e 100644 --- a/drivers/video/atafb.c +++ b/drivers/video/atafb.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * linux/drivers/video/atafb.c -- Atari builtin chipset frame buffer device | 2 | * linux/drivers/video/atafb.c -- Atari builtin chipset frame buffer device |
3 | * | 3 | * |
4 | * Copyright (C) 1994 Martin Schaller & Roman Hodek | 4 | * Copyright (C) 1994 Martin Schaller & Roman Hodek |
5 | * | 5 | * |
6 | * This file is subject to the terms and conditions of the GNU General Public | 6 | * This file is subject to the terms and conditions of the GNU General Public |
7 | * License. See the file COPYING in the main directory of this archive | 7 | * License. See the file COPYING in the main directory of this archive |
8 | * for more details. | 8 | * for more details. |
@@ -70,14 +70,8 @@ | |||
70 | #include <linux/fb.h> | 70 | #include <linux/fb.h> |
71 | #include <asm/atarikb.h> | 71 | #include <asm/atarikb.h> |
72 | 72 | ||
73 | #include <video/fbcon.h> | 73 | #include "c2p.h" |
74 | #include <video/fbcon-cfb8.h> | 74 | #include "atafb.h" |
75 | #include <video/fbcon-cfb16.h> | ||
76 | #include <video/fbcon-iplan2p2.h> | ||
77 | #include <video/fbcon-iplan2p4.h> | ||
78 | #include <video/fbcon-iplan2p8.h> | ||
79 | #include <video/fbcon-mfb.h> | ||
80 | |||
81 | 75 | ||
82 | #define SWITCH_ACIA 0x01 /* modes for switch on OverScan */ | 76 | #define SWITCH_ACIA 0x01 /* modes for switch on OverScan */ |
83 | #define SWITCH_SND6 0x40 | 77 | #define SWITCH_SND6 0x40 |
@@ -87,22 +81,48 @@ | |||
87 | 81 | ||
88 | #define up(x, r) (((x) + (r) - 1) & ~((r)-1)) | 82 | #define up(x, r) (((x) + (r) - 1) & ~((r)-1)) |
89 | 83 | ||
84 | /* | ||
85 | * Interface to the world | ||
86 | */ | ||
87 | |||
88 | static int atafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info); | ||
89 | static int atafb_set_par(struct fb_info *info); | ||
90 | static int atafb_setcolreg(unsigned int regno, unsigned int red, unsigned int green, | ||
91 | unsigned int blue, unsigned int transp, | ||
92 | struct fb_info *info); | ||
93 | static int atafb_blank(int blank, struct fb_info *info); | ||
94 | static int atafb_pan_display(struct fb_var_screeninfo *var, | ||
95 | struct fb_info *info); | ||
96 | static void atafb_fillrect(struct fb_info *info, | ||
97 | const struct fb_fillrect *rect); | ||
98 | static void atafb_copyarea(struct fb_info *info, | ||
99 | const struct fb_copyarea *region); | ||
100 | static void atafb_imageblit(struct fb_info *info, const struct fb_image *image); | ||
101 | static int atafb_ioctl(struct fb_info *info, unsigned int cmd, | ||
102 | unsigned long arg); | ||
103 | |||
90 | 104 | ||
91 | static int default_par=0; /* default resolution (0=none) */ | 105 | static int default_par; /* default resolution (0=none) */ |
92 | 106 | ||
93 | static unsigned long default_mem_req=0; | 107 | static unsigned long default_mem_req; |
94 | 108 | ||
95 | static int hwscroll=-1; | 109 | static int hwscroll = -1; |
96 | 110 | ||
97 | static int use_hwscroll = 1; | 111 | static int use_hwscroll = 1; |
98 | 112 | ||
99 | static int sttt_xres=640,st_yres=400,tt_yres=480; | 113 | static int sttt_xres = 640, st_yres = 400, tt_yres = 480; |
100 | static int sttt_xres_virtual=640,sttt_yres_virtual=400; | 114 | static int sttt_xres_virtual = 640, sttt_yres_virtual = 400; |
101 | static int ovsc_offset=0, ovsc_addlen=0; | 115 | static int ovsc_offset, ovsc_addlen; |
116 | |||
117 | /* | ||
118 | * Hardware parameters for current mode | ||
119 | */ | ||
102 | 120 | ||
103 | static struct atafb_par { | 121 | static struct atafb_par { |
104 | void *screen_base; | 122 | void *screen_base; |
105 | int yres_virtual; | 123 | int yres_virtual; |
124 | u_long next_line; | ||
125 | u_long next_plane; | ||
106 | #if defined ATAFB_TT || defined ATAFB_STE | 126 | #if defined ATAFB_TT || defined ATAFB_STE |
107 | union { | 127 | union { |
108 | struct { | 128 | struct { |
@@ -138,7 +158,7 @@ static struct atafb_par { | |||
138 | /* Don't calculate an own resolution, and thus don't change the one found when | 158 | /* Don't calculate an own resolution, and thus don't change the one found when |
139 | * booting (currently used for the Falcon to keep settings for internal video | 159 | * booting (currently used for the Falcon to keep settings for internal video |
140 | * hardware extensions (e.g. ScreenBlaster) */ | 160 | * hardware extensions (e.g. ScreenBlaster) */ |
141 | static int DontCalcRes = 0; | 161 | static int DontCalcRes = 0; |
142 | 162 | ||
143 | #ifdef ATAFB_FALCON | 163 | #ifdef ATAFB_FALCON |
144 | #define HHT hw.falcon.hht | 164 | #define HHT hw.falcon.hht |
@@ -163,83 +183,84 @@ static int DontCalcRes = 0; | |||
163 | #define VMO_PREMASK 0x0c | 183 | #define VMO_PREMASK 0x0c |
164 | #endif | 184 | #endif |
165 | 185 | ||
166 | static struct fb_info fb_info; | 186 | static struct fb_info fb_info = { |
187 | .fix = { | ||
188 | .id = "Atari ", | ||
189 | .visual = FB_VISUAL_PSEUDOCOLOR, | ||
190 | .accel = FB_ACCEL_NONE, | ||
191 | } | ||
192 | }; | ||
167 | 193 | ||
168 | static void *screen_base; /* base address of screen */ | 194 | static void *screen_base; /* base address of screen */ |
169 | static void *real_screen_base; /* (only for Overscan) */ | 195 | static void *real_screen_base; /* (only for Overscan) */ |
170 | 196 | ||
171 | static int screen_len; | 197 | static int screen_len; |
172 | 198 | ||
173 | static int current_par_valid=0; | 199 | static int current_par_valid; |
174 | 200 | ||
175 | static int mono_moni=0; | 201 | static int mono_moni; |
176 | |||
177 | static struct display disp; | ||
178 | 202 | ||
179 | 203 | ||
180 | #ifdef ATAFB_EXT | 204 | #ifdef ATAFB_EXT |
181 | /* external video handling */ | ||
182 | 205 | ||
183 | static unsigned external_xres; | 206 | /* external video handling */ |
184 | static unsigned external_xres_virtual; | 207 | static unsigned int external_xres; |
185 | static unsigned external_yres; | 208 | static unsigned int external_xres_virtual; |
186 | /* not needed - atafb will never support panning/hardwarescroll with external | 209 | static unsigned int external_yres; |
187 | * static unsigned external_yres_virtual; | ||
188 | */ | ||
189 | 210 | ||
190 | static unsigned external_depth; | 211 | /* |
191 | static int external_pmode; | 212 | * not needed - atafb will never support panning/hardwarescroll with external |
192 | static void *external_addr = 0; | 213 | * static unsigned int external_yres_virtual; |
193 | static unsigned long external_len; | 214 | */ |
194 | static unsigned long external_vgaiobase = 0; | 215 | static unsigned int external_depth; |
195 | static unsigned int external_bitspercol = 6; | 216 | static int external_pmode; |
196 | 217 | static void *external_addr; | |
197 | /* | 218 | static unsigned long external_len; |
198 | JOE <joe@amber.dinoco.de>: | 219 | static unsigned long external_vgaiobase; |
199 | added card type for external driver, is only needed for | 220 | static unsigned int external_bitspercol = 6; |
200 | colormap handling. | ||
201 | */ | ||
202 | 221 | ||
222 | /* | ||
223 | * JOE <joe@amber.dinoco.de>: | ||
224 | * added card type for external driver, is only needed for | ||
225 | * colormap handling. | ||
226 | */ | ||
203 | enum cardtype { IS_VGA, IS_MV300 }; | 227 | enum cardtype { IS_VGA, IS_MV300 }; |
204 | static enum cardtype external_card_type = IS_VGA; | 228 | static enum cardtype external_card_type = IS_VGA; |
205 | 229 | ||
206 | /* | 230 | /* |
207 | The MV300 mixes the color registers. So we need an array of munged | 231 | * The MV300 mixes the color registers. So we need an array of munged |
208 | indices in order to access the correct reg. | 232 | * indices in order to access the correct reg. |
209 | */ | 233 | */ |
210 | static int MV300_reg_1bit[2]={0,1}; | 234 | static int MV300_reg_1bit[2] = { |
211 | static int MV300_reg_4bit[16]={ | 235 | 0, 1 |
212 | 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 }; | 236 | }; |
213 | static int MV300_reg_8bit[256]={ | 237 | static int MV300_reg_4bit[16] = { |
214 | 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, | 238 | 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 |
215 | 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, | 239 | }; |
216 | 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, | 240 | static int MV300_reg_8bit[256] = { |
217 | 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, | 241 | 0, 128, 64, 192, 32, 160, 96, 224, 16, 144, 80, 208, 48, 176, 112, 240, |
218 | 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, | 242 | 8, 136, 72, 200, 40, 168, 104, 232, 24, 152, 88, 216, 56, 184, 120, 248, |
219 | 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, | 243 | 4, 132, 68, 196, 36, 164, 100, 228, 20, 148, 84, 212, 52, 180, 116, 244, |
220 | 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, | 244 | 12, 140, 76, 204, 44, 172, 108, 236, 28, 156, 92, 220, 60, 188, 124, 252, |
221 | 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, | 245 | 2, 130, 66, 194, 34, 162, 98, 226, 18, 146, 82, 210, 50, 178, 114, 242, |
222 | 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, | 246 | 10, 138, 74, 202, 42, 170, 106, 234, 26, 154, 90, 218, 58, 186, 122, 250, |
223 | 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, | 247 | 6, 134, 70, 198, 38, 166, 102, 230, 22, 150, 86, 214, 54, 182, 118, 246, |
224 | 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, | 248 | 14, 142, 78, 206, 46, 174, 110, 238, 30, 158, 94, 222, 62, 190, 126, 254, |
225 | 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, | 249 | 1, 129, 65, 193, 33, 161, 97, 225, 17, 145, 81, 209, 49, 177, 113, 241, |
226 | 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, | 250 | 9, 137, 73, 201, 41, 169, 105, 233, 25, 153, 89, 217, 57, 185, 121, 249, |
227 | 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, | 251 | 5, 133, 69, 197, 37, 165, 101, 229, 21, 149, 85, 213, 53, 181, 117, 245, |
228 | 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, | 252 | 13, 141, 77, 205, 45, 173, 109, 237, 29, 157, 93, 221, 61, 189, 125, 253, |
229 | 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 }; | 253 | 3, 131, 67, 195, 35, 163, 99, 227, 19, 147, 83, 211, 51, 179, 115, 243, |
254 | 11, 139, 75, 203, 43, 171, 107, 235, 27, 155, 91, 219, 59, 187, 123, 251, | ||
255 | 7, 135, 71, 199, 39, 167, 103, 231, 23, 151, 87, 215, 55, 183, 119, 247, | ||
256 | 15, 143, 79, 207, 47, 175, 111, 239, 31, 159, 95, 223, 63, 191, 127, 255 | ||
257 | }; | ||
230 | 258 | ||
231 | static int *MV300_reg = MV300_reg_8bit; | 259 | static int *MV300_reg = MV300_reg_8bit; |
232 | |||
233 | /* | ||
234 | And on the MV300 it's difficult to read out the hardware palette. So we | ||
235 | just keep track of the set colors in our own array here, and use that! | ||
236 | */ | ||
237 | |||
238 | static struct { unsigned char red,green,blue,pad; } ext_color[256]; | ||
239 | #endif /* ATAFB_EXT */ | 260 | #endif /* ATAFB_EXT */ |
240 | 261 | ||
241 | 262 | ||
242 | static int inverse=0; | 263 | static int inverse; |
243 | 264 | ||
244 | extern int fontheight_8x8; | 265 | extern int fontheight_8x8; |
245 | extern int fontwidth_8x8; | 266 | extern int fontwidth_8x8; |
@@ -249,96 +270,154 @@ extern int fontheight_8x16; | |||
249 | extern int fontwidth_8x16; | 270 | extern int fontwidth_8x16; |
250 | extern unsigned char fontdata_8x16[]; | 271 | extern unsigned char fontdata_8x16[]; |
251 | 272 | ||
273 | /* | ||
274 | * struct fb_ops { | ||
275 | * * open/release and usage marking | ||
276 | * struct module *owner; | ||
277 | * int (*fb_open)(struct fb_info *info, int user); | ||
278 | * int (*fb_release)(struct fb_info *info, int user); | ||
279 | * | ||
280 | * * For framebuffers with strange non linear layouts or that do not | ||
281 | * * work with normal memory mapped access | ||
282 | * ssize_t (*fb_read)(struct file *file, char __user *buf, size_t count, loff_t *ppos); | ||
283 | * ssize_t (*fb_write)(struct file *file, const char __user *buf, size_t count, loff_t *ppos); | ||
284 | * | ||
285 | * * checks var and eventually tweaks it to something supported, | ||
286 | * * DOES NOT MODIFY PAR * | ||
287 | * int (*fb_check_var)(struct fb_var_screeninfo *var, struct fb_info *info); | ||
288 | * | ||
289 | * * set the video mode according to info->var * | ||
290 | * int (*fb_set_par)(struct fb_info *info); | ||
291 | * | ||
292 | * * set color register * | ||
293 | * int (*fb_setcolreg)(unsigned int regno, unsigned int red, unsigned int green, | ||
294 | * unsigned int blue, unsigned int transp, struct fb_info *info); | ||
295 | * | ||
296 | * * set color registers in batch * | ||
297 | * int (*fb_setcmap)(struct fb_cmap *cmap, struct fb_info *info); | ||
298 | * | ||
299 | * * blank display * | ||
300 | * int (*fb_blank)(int blank, struct fb_info *info); | ||
301 | * | ||
302 | * * pan display * | ||
303 | * int (*fb_pan_display)(struct fb_var_screeninfo *var, struct fb_info *info); | ||
304 | * | ||
305 | * *** The meat of the drawing engine *** | ||
306 | * * Draws a rectangle * | ||
307 | * void (*fb_fillrect) (struct fb_info *info, const struct fb_fillrect *rect); | ||
308 | * * Copy data from area to another * | ||
309 | * void (*fb_copyarea) (struct fb_info *info, const struct fb_copyarea *region); | ||
310 | * * Draws a image to the display * | ||
311 | * void (*fb_imageblit) (struct fb_info *info, const struct fb_image *image); | ||
312 | * | ||
313 | * * Draws cursor * | ||
314 | * int (*fb_cursor) (struct fb_info *info, struct fb_cursor *cursor); | ||
315 | * | ||
316 | * * Rotates the display * | ||
317 | * void (*fb_rotate)(struct fb_info *info, int angle); | ||
318 | * | ||
319 | * * wait for blit idle, optional * | ||
320 | * int (*fb_sync)(struct fb_info *info); | ||
321 | * | ||
322 | * * perform fb specific ioctl (optional) * | ||
323 | * int (*fb_ioctl)(struct fb_info *info, unsigned int cmd, | ||
324 | * unsigned long arg); | ||
325 | * | ||
326 | * * Handle 32bit compat ioctl (optional) * | ||
327 | * int (*fb_compat_ioctl)(struct fb_info *info, unsigned int cmd, | ||
328 | * unsigned long arg); | ||
329 | * | ||
330 | * * perform fb specific mmap * | ||
331 | * int (*fb_mmap)(struct fb_info *info, struct vm_area_struct *vma); | ||
332 | * | ||
333 | * * save current hardware state * | ||
334 | * void (*fb_save_state)(struct fb_info *info); | ||
335 | * | ||
336 | * * restore saved state * | ||
337 | * void (*fb_restore_state)(struct fb_info *info); | ||
338 | * } ; | ||
339 | */ | ||
340 | |||
341 | |||
252 | /* ++roman: This structure abstracts from the underlying hardware (ST(e), | 342 | /* ++roman: This structure abstracts from the underlying hardware (ST(e), |
253 | * TT, or Falcon. | 343 | * TT, or Falcon. |
254 | * | 344 | * |
255 | * int (*detect)( void ) | 345 | * int (*detect)(void) |
256 | * This function should detect the current video mode settings and | 346 | * This function should detect the current video mode settings and |
257 | * store them in atafb_predefined[0] for later reference by the | 347 | * store them in atafb_predefined[0] for later reference by the |
258 | * user. Return the index+1 of an equivalent predefined mode or 0 | 348 | * user. Return the index+1 of an equivalent predefined mode or 0 |
259 | * if there is no such. | 349 | * if there is no such. |
260 | * | 350 | * |
261 | * int (*encode_fix)( struct fb_fix_screeninfo *fix, | 351 | * int (*encode_fix)(struct fb_fix_screeninfo *fix, |
262 | * struct atafb_par *par ) | 352 | * struct atafb_par *par) |
263 | * This function should fill in the 'fix' structure based on the | 353 | * This function should fill in the 'fix' structure based on the |
264 | * values in the 'par' structure. | 354 | * values in the 'par' structure. |
265 | * | 355 | * !!! Obsolete, perhaps !!! |
266 | * int (*decode_var)( struct fb_var_screeninfo *var, | 356 | * |
267 | * struct atafb_par *par ) | 357 | * int (*decode_var)(struct fb_var_screeninfo *var, |
358 | * struct atafb_par *par) | ||
268 | * Get the video params out of 'var'. If a value doesn't fit, round | 359 | * Get the video params out of 'var'. If a value doesn't fit, round |
269 | * it up, if it's too big, return EINVAL. | 360 | * it up, if it's too big, return EINVAL. |
270 | * Round up in the following order: bits_per_pixel, xres, yres, | 361 | * Round up in the following order: bits_per_pixel, xres, yres, |
271 | * xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, | 362 | * xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, |
272 | * horizontal timing, vertical timing. | 363 | * horizontal timing, vertical timing. |
273 | * | 364 | * |
274 | * int (*encode_var)( struct fb_var_screeninfo *var, | 365 | * int (*encode_var)(struct fb_var_screeninfo *var, |
275 | * struct atafb_par *par ); | 366 | * struct atafb_par *par); |
276 | * Fill the 'var' structure based on the values in 'par' and maybe | 367 | * Fill the 'var' structure based on the values in 'par' and maybe |
277 | * other values read out of the hardware. | 368 | * other values read out of the hardware. |
278 | * | 369 | * |
279 | * void (*get_par)( struct atafb_par *par ) | 370 | * void (*get_par)(struct atafb_par *par) |
280 | * Fill the hardware's 'par' structure. | 371 | * Fill the hardware's 'par' structure. |
281 | * | 372 | * !!! Used only by detect() !!! |
282 | * void (*set_par)( struct atafb_par *par ) | 373 | * |
374 | * void (*set_par)(struct atafb_par *par) | ||
283 | * Set the hardware according to 'par'. | 375 | * Set the hardware according to 'par'. |
284 | * | ||
285 | * int (*getcolreg)( unsigned regno, unsigned *red, | ||
286 | * unsigned *green, unsigned *blue, | ||
287 | * unsigned *transp, struct fb_info *info ) | ||
288 | * Read a single color register and split it into | ||
289 | * colors/transparent. Return != 0 for invalid regno. | ||
290 | * | 376 | * |
291 | * void (*set_screen_base)(void *s_base) | 377 | * void (*set_screen_base)(void *s_base) |
292 | * Set the base address of the displayed frame buffer. Only called | 378 | * Set the base address of the displayed frame buffer. Only called |
293 | * if yres_virtual > yres or xres_virtual > xres. | 379 | * if yres_virtual > yres or xres_virtual > xres. |
294 | * | 380 | * |
295 | * int (*blank)( int blank_mode ) | 381 | * int (*blank)(int blank_mode) |
296 | * Blank the screen if blank_mode!=0, else unblank. If blank==NULL then | 382 | * Blank the screen if blank_mode != 0, else unblank. If blank == NULL then |
297 | * the caller blanks by setting the CLUT to all black. Return 0 if blanking | 383 | * the caller blanks by setting the CLUT to all black. Return 0 if blanking |
298 | * succeeded, !=0 if un-/blanking failed due to e.g. a video mode which | 384 | * succeeded, !=0 if un-/blanking failed due to e.g. a video mode which |
299 | * doesn't support it. Implements VESA suspend and powerdown modes on | 385 | * doesn't support it. Implements VESA suspend and powerdown modes on |
300 | * hardware that supports disabling hsync/vsync: | 386 | * hardware that supports disabling hsync/vsync: |
301 | * blank_mode==2: suspend vsync, 3:suspend hsync, 4: powerdown. | 387 | * blank_mode == 2: suspend vsync, 3:suspend hsync, 4: powerdown. |
302 | */ | 388 | */ |
303 | 389 | ||
304 | static struct fb_hwswitch { | 390 | static struct fb_hwswitch { |
305 | int (*detect)( void ); | 391 | int (*detect)(void); |
306 | int (*encode_fix)( struct fb_fix_screeninfo *fix, | 392 | int (*encode_fix)(struct fb_fix_screeninfo *fix, |
307 | struct atafb_par *par ); | 393 | struct atafb_par *par); |
308 | int (*decode_var)( struct fb_var_screeninfo *var, | 394 | int (*decode_var)(struct fb_var_screeninfo *var, |
309 | struct atafb_par *par ); | 395 | struct atafb_par *par); |
310 | int (*encode_var)( struct fb_var_screeninfo *var, | 396 | int (*encode_var)(struct fb_var_screeninfo *var, |
311 | struct atafb_par *par ); | 397 | struct atafb_par *par); |
312 | void (*get_par)( struct atafb_par *par ); | 398 | void (*get_par)(struct atafb_par *par); |
313 | void (*set_par)( struct atafb_par *par ); | 399 | void (*set_par)(struct atafb_par *par); |
314 | int (*getcolreg)( unsigned regno, unsigned *red, | ||
315 | unsigned *green, unsigned *blue, | ||
316 | unsigned *transp, struct fb_info *info ); | ||
317 | void (*set_screen_base)(void *s_base); | 400 | void (*set_screen_base)(void *s_base); |
318 | int (*blank)( int blank_mode ); | 401 | int (*blank)(int blank_mode); |
319 | int (*pan_display)( struct fb_var_screeninfo *var, | 402 | int (*pan_display)(struct fb_var_screeninfo *var, |
320 | struct atafb_par *par); | 403 | struct fb_info *info); |
321 | } *fbhw; | 404 | } *fbhw; |
322 | 405 | ||
323 | static char *autodetect_names[] = {"autodetect", NULL}; | 406 | static char *autodetect_names[] = { "autodetect", NULL }; |
324 | static char *stlow_names[] = {"stlow", NULL}; | 407 | static char *stlow_names[] = { "stlow", NULL }; |
325 | static char *stmid_names[] = {"stmid", "default5", NULL}; | 408 | static char *stmid_names[] = { "stmid", "default5", NULL }; |
326 | static char *sthigh_names[] = {"sthigh", "default4", NULL}; | 409 | static char *sthigh_names[] = { "sthigh", "default4", NULL }; |
327 | static char *ttlow_names[] = {"ttlow", NULL}; | 410 | static char *ttlow_names[] = { "ttlow", NULL }; |
328 | static char *ttmid_names[]= {"ttmid", "default1", NULL}; | 411 | static char *ttmid_names[] = { "ttmid", "default1", NULL }; |
329 | static char *tthigh_names[]= {"tthigh", "default2", NULL}; | 412 | static char *tthigh_names[] = { "tthigh", "default2", NULL }; |
330 | static char *vga2_names[] = {"vga2", NULL}; | 413 | static char *vga2_names[] = { "vga2", NULL }; |
331 | static char *vga4_names[] = {"vga4", NULL}; | 414 | static char *vga4_names[] = { "vga4", NULL }; |
332 | static char *vga16_names[] = {"vga16", "default3", NULL}; | 415 | static char *vga16_names[] = { "vga16", "default3", NULL }; |
333 | static char *vga256_names[] = {"vga256", NULL}; | 416 | static char *vga256_names[] = { "vga256", NULL }; |
334 | static char *falh2_names[] = {"falh2", NULL}; | 417 | static char *falh2_names[] = { "falh2", NULL }; |
335 | static char *falh16_names[] = {"falh16", NULL}; | 418 | static char *falh16_names[] = { "falh16", NULL }; |
336 | 419 | ||
337 | static char **fb_var_names[] = { | 420 | static char **fb_var_names[] = { |
338 | /* Writing the name arrays directly in this array (via "(char *[]){...}") | ||
339 | * crashes gcc 2.5.8 (sigsegv) if the inner array | ||
340 | * contains more than two items. I've also seen that all elements | ||
341 | * were identical to the last (my cross-gcc) :-(*/ | ||
342 | autodetect_names, | 421 | autodetect_names, |
343 | stlow_names, | 422 | stlow_names, |
344 | stmid_names, | 423 | stmid_names, |
@@ -353,18 +432,17 @@ static char **fb_var_names[] = { | |||
353 | falh2_names, | 432 | falh2_names, |
354 | falh16_names, | 433 | falh16_names, |
355 | NULL | 434 | NULL |
356 | /* ,NULL */ /* this causes a sigsegv on my gcc-2.5.8 */ | ||
357 | }; | 435 | }; |
358 | 436 | ||
359 | static struct fb_var_screeninfo atafb_predefined[] = { | 437 | static struct fb_var_screeninfo atafb_predefined[] = { |
360 | /* | 438 | /* |
361 | * yres_virtual==0 means use hw-scrolling if possible, else yres | 439 | * yres_virtual == 0 means use hw-scrolling if possible, else yres |
362 | */ | 440 | */ |
363 | { /* autodetect */ | 441 | { /* autodetect */ |
364 | 0, 0, 0, 0, 0, 0, 0, 0, /* xres-grayscale */ | 442 | 0, 0, 0, 0, 0, 0, 0, 0, /* xres-grayscale */ |
365 | {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, /* red green blue tran*/ | 443 | {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, /* red green blue tran*/ |
366 | 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, | 444 | 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, |
367 | { /* st low */ | 445 | { /* st low */ |
368 | 320, 200, 320, 0, 0, 0, 4, 0, | 446 | 320, 200, 320, 0, 0, 0, 4, 0, |
369 | {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, | 447 | {0, 4, 0}, {0, 4, 0}, {0, 4, 0}, {0, 0, 0}, |
370 | 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, | 448 | 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, |
@@ -414,27 +492,100 @@ static struct fb_var_screeninfo atafb_predefined[] = { | |||
414 | 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, | 492 | 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0 }, |
415 | }; | 493 | }; |
416 | 494 | ||
417 | static int num_atafb_predefined=ARRAY_SIZE(atafb_predefined); | 495 | static int num_atafb_predefined = ARRAY_SIZE(atafb_predefined); |
418 | 496 | ||
497 | static struct fb_videomode atafb_modedb[] __initdata = { | ||
498 | /* | ||
499 | * Atari Video Modes | ||
500 | * | ||
501 | * If you change these, make sure to update DEFMODE_* as well! | ||
502 | */ | ||
419 | 503 | ||
420 | static int | 504 | /* |
421 | get_video_mode(char *vname) | 505 | * ST/TT Video Modes |
506 | */ | ||
507 | |||
508 | { | ||
509 | /* 320x200, 15 kHz, 60 Hz (ST low) */ | ||
510 | "st-low", 60, 320, 200, 32000, 32, 16, 31, 14, 96, 4, | ||
511 | 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP | ||
512 | }, { | ||
513 | /* 640x200, 15 kHz, 60 Hz (ST medium) */ | ||
514 | "st-mid", 60, 640, 200, 32000, 32, 16, 31, 14, 96, 4, | ||
515 | 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP | ||
516 | }, { | ||
517 | /* 640x400, 30.25 kHz, 63.5 Hz (ST high) */ | ||
518 | "st-high", 63, 640, 400, 32000, 128, 0, 40, 14, 128, 4, | ||
519 | 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP | ||
520 | }, { | ||
521 | /* 320x480, 15 kHz, 60 Hz (TT low) */ | ||
522 | "tt-low", 60, 320, 480, 31041, 120, 100, 8, 16, 140, 30, | ||
523 | 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP | ||
524 | }, { | ||
525 | /* 640x480, 29 kHz, 57 Hz (TT medium) */ | ||
526 | "tt-mid", 60, 640, 480, 31041, 120, 100, 8, 16, 140, 30, | ||
527 | 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP | ||
528 | }, { | ||
529 | /* 1280x960, 29 kHz, 60 Hz (TT high) */ | ||
530 | "tt-high", 57, 640, 960, 31041, 120, 100, 8, 16, 140, 30, | ||
531 | 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP | ||
532 | }, | ||
533 | |||
534 | /* | ||
535 | * VGA Video Modes | ||
536 | */ | ||
537 | |||
538 | { | ||
539 | /* 640x480, 31 kHz, 60 Hz (VGA) */ | ||
540 | "vga", 63.5, 640, 480, 32000, 18, 42, 31, 11, 96, 3, | ||
541 | 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP | ||
542 | }, { | ||
543 | /* 640x400, 31 kHz, 70 Hz (VGA) */ | ||
544 | "vga70", 70, 640, 400, 32000, 18, 42, 31, 11, 96, 3, | ||
545 | FB_SYNC_VERT_HIGH_ACT | FB_SYNC_COMP_HIGH_ACT, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP | ||
546 | }, | ||
547 | |||
548 | /* | ||
549 | * Falcon HiRes Video Modes | ||
550 | */ | ||
551 | |||
552 | { | ||
553 | /* 896x608, 31 kHz, 60 Hz (Falcon High) */ | ||
554 | "falh", 60, 896, 608, 32000, 18, 42, 31, 1, 96,3, | ||
555 | 0, FB_VMODE_NONINTERLACED | FB_VMODE_YWRAP | ||
556 | }, | ||
557 | }; | ||
558 | |||
559 | #define NUM_TOTAL_MODES ARRAY_SIZE(atafb_modedb) | ||
560 | |||
561 | static char *mode_option __initdata = NULL; | ||
562 | |||
563 | /* default modes */ | ||
564 | |||
565 | #define DEFMODE_TT 5 /* "tt-high" for TT */ | ||
566 | #define DEFMODE_F30 7 /* "vga70" for Falcon */ | ||
567 | #define DEFMODE_STE 2 /* "st-high" for ST/E */ | ||
568 | #define DEFMODE_EXT 6 /* "vga" for external */ | ||
569 | |||
570 | |||
571 | static int get_video_mode(char *vname) | ||
422 | { | 572 | { |
423 | char ***name_list; | 573 | char ***name_list; |
424 | char **name; | 574 | char **name; |
425 | int i; | 575 | int i; |
426 | name_list=fb_var_names; | 576 | |
427 | for (i = 0 ; i < num_atafb_predefined ; i++) { | 577 | name_list = fb_var_names; |
428 | name=*(name_list++); | 578 | for (i = 0; i < num_atafb_predefined; i++) { |
429 | if (! name || ! *name) | 579 | name = *name_list++; |
430 | break; | 580 | if (!name || !*name) |
431 | while (*name) { | 581 | break; |
432 | if (! strcmp(vname, *name)) | 582 | while (*name) { |
433 | return i+1; | 583 | if (!strcmp(vname, *name)) |
434 | name++; | 584 | return i + 1; |
585 | name++; | ||
586 | } | ||
435 | } | 587 | } |
436 | } | 588 | return 0; |
437 | return 0; | ||
438 | } | 589 | } |
439 | 590 | ||
440 | 591 | ||
@@ -443,93 +594,84 @@ get_video_mode(char *vname) | |||
443 | 594 | ||
444 | #ifdef ATAFB_TT | 595 | #ifdef ATAFB_TT |
445 | 596 | ||
446 | static int tt_encode_fix( struct fb_fix_screeninfo *fix, | 597 | static int tt_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par) |
447 | struct atafb_par *par ) | ||
448 | |||
449 | { | 598 | { |
450 | int mode; | 599 | int mode; |
451 | 600 | ||
452 | strcpy(fix->id,"Atari Builtin"); | 601 | strcpy(fix->id, "Atari Builtin"); |
453 | fix->smem_start = (unsigned long)real_screen_base; | 602 | fix->smem_start = (unsigned long)real_screen_base; |
454 | fix->smem_len = screen_len; | 603 | fix->smem_len = screen_len; |
455 | fix->type=FB_TYPE_INTERLEAVED_PLANES; | 604 | fix->type = FB_TYPE_INTERLEAVED_PLANES; |
456 | fix->type_aux=2; | 605 | fix->type_aux = 2; |
457 | fix->visual=FB_VISUAL_PSEUDOCOLOR; | 606 | fix->visual = FB_VISUAL_PSEUDOCOLOR; |
458 | mode = par->hw.tt.mode & TT_SHIFTER_MODEMASK; | 607 | mode = par->hw.tt.mode & TT_SHIFTER_MODEMASK; |
459 | if (mode == TT_SHIFTER_TTHIGH || mode == TT_SHIFTER_STHIGH) { | 608 | if (mode == TT_SHIFTER_TTHIGH || mode == TT_SHIFTER_STHIGH) { |
460 | fix->type=FB_TYPE_PACKED_PIXELS; | 609 | fix->type = FB_TYPE_PACKED_PIXELS; |
461 | fix->type_aux=0; | 610 | fix->type_aux = 0; |
462 | if (mode == TT_SHIFTER_TTHIGH) | 611 | if (mode == TT_SHIFTER_TTHIGH) |
463 | fix->visual=FB_VISUAL_MONO01; | 612 | fix->visual = FB_VISUAL_MONO01; |
464 | } | 613 | } |
465 | fix->xpanstep=0; | 614 | fix->xpanstep = 0; |
466 | fix->ypanstep=1; | 615 | fix->ypanstep = 1; |
467 | fix->ywrapstep=0; | 616 | fix->ywrapstep = 0; |
468 | fix->line_length = 0; | 617 | fix->line_length = 0; |
469 | fix->accel = FB_ACCEL_ATARIBLITT; | 618 | fix->accel = FB_ACCEL_ATARIBLITT; |
470 | return 0; | 619 | return 0; |
471 | } | 620 | } |
472 | 621 | ||
473 | 622 | static int tt_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par) | |
474 | static int tt_decode_var( struct fb_var_screeninfo *var, | ||
475 | struct atafb_par *par ) | ||
476 | { | 623 | { |
477 | int xres=var->xres; | 624 | int xres = var->xres; |
478 | int yres=var->yres; | 625 | int yres = var->yres; |
479 | int bpp=var->bits_per_pixel; | 626 | int bpp = var->bits_per_pixel; |
480 | int linelen; | 627 | int linelen; |
481 | int yres_virtual = var->yres_virtual; | 628 | int yres_virtual = var->yres_virtual; |
482 | 629 | ||
483 | if (mono_moni) { | 630 | if (mono_moni) { |
484 | if (bpp > 1 || xres > sttt_xres*2 || yres >tt_yres*2) | 631 | if (bpp > 1 || xres > sttt_xres * 2 || yres > tt_yres * 2) |
485 | return -EINVAL; | 632 | return -EINVAL; |
486 | par->hw.tt.mode=TT_SHIFTER_TTHIGH; | 633 | par->hw.tt.mode = TT_SHIFTER_TTHIGH; |
487 | xres=sttt_xres*2; | 634 | xres = sttt_xres * 2; |
488 | yres=tt_yres*2; | 635 | yres = tt_yres * 2; |
489 | bpp=1; | 636 | bpp = 1; |
490 | } else { | 637 | } else { |
491 | if (bpp > 8 || xres > sttt_xres || yres > tt_yres) | 638 | if (bpp > 8 || xres > sttt_xres || yres > tt_yres) |
492 | return -EINVAL; | 639 | return -EINVAL; |
493 | if (bpp > 4) { | 640 | if (bpp > 4) { |
494 | if (xres > sttt_xres/2 || yres > tt_yres) | 641 | if (xres > sttt_xres / 2 || yres > tt_yres) |
495 | return -EINVAL; | 642 | return -EINVAL; |
496 | par->hw.tt.mode=TT_SHIFTER_TTLOW; | 643 | par->hw.tt.mode = TT_SHIFTER_TTLOW; |
497 | xres=sttt_xres/2; | 644 | xres = sttt_xres / 2; |
498 | yres=tt_yres; | 645 | yres = tt_yres; |
499 | bpp=8; | 646 | bpp = 8; |
500 | } | 647 | } else if (bpp > 2) { |
501 | else if (bpp > 2) { | ||
502 | if (xres > sttt_xres || yres > tt_yres) | 648 | if (xres > sttt_xres || yres > tt_yres) |
503 | return -EINVAL; | 649 | return -EINVAL; |
504 | if (xres > sttt_xres/2 || yres > st_yres/2) { | 650 | if (xres > sttt_xres / 2 || yres > st_yres / 2) { |
505 | par->hw.tt.mode=TT_SHIFTER_TTMID; | 651 | par->hw.tt.mode = TT_SHIFTER_TTMID; |
506 | xres=sttt_xres; | 652 | xres = sttt_xres; |
507 | yres=tt_yres; | 653 | yres = tt_yres; |
508 | bpp=4; | 654 | bpp = 4; |
509 | } | 655 | } else { |
510 | else { | 656 | par->hw.tt.mode = TT_SHIFTER_STLOW; |
511 | par->hw.tt.mode=TT_SHIFTER_STLOW; | 657 | xres = sttt_xres / 2; |
512 | xres=sttt_xres/2; | 658 | yres = st_yres / 2; |
513 | yres=st_yres/2; | 659 | bpp = 4; |
514 | bpp=4; | ||
515 | } | 660 | } |
516 | } | 661 | } else if (bpp > 1) { |
517 | else if (bpp > 1) { | 662 | if (xres > sttt_xres || yres > st_yres / 2) |
518 | if (xres > sttt_xres || yres > st_yres/2) | ||
519 | return -EINVAL; | 663 | return -EINVAL; |
520 | par->hw.tt.mode=TT_SHIFTER_STMID; | 664 | par->hw.tt.mode = TT_SHIFTER_STMID; |
521 | xres=sttt_xres; | 665 | xres = sttt_xres; |
522 | yres=st_yres/2; | 666 | yres = st_yres / 2; |
523 | bpp=2; | 667 | bpp = 2; |
524 | } | 668 | } else if (var->xres > sttt_xres || var->yres > st_yres) { |
525 | else if (var->xres > sttt_xres || var->yres > st_yres) { | ||
526 | return -EINVAL; | 669 | return -EINVAL; |
527 | } | 670 | } else { |
528 | else { | 671 | par->hw.tt.mode = TT_SHIFTER_STHIGH; |
529 | par->hw.tt.mode=TT_SHIFTER_STHIGH; | 672 | xres = sttt_xres; |
530 | xres=sttt_xres; | 673 | yres = st_yres; |
531 | yres=st_yres; | 674 | bpp = 1; |
532 | bpp=1; | ||
533 | } | 675 | } |
534 | } | 676 | } |
535 | if (yres_virtual <= 0) | 677 | if (yres_virtual <= 0) |
@@ -537,10 +679,10 @@ static int tt_decode_var( struct fb_var_screeninfo *var, | |||
537 | else if (yres_virtual < yres) | 679 | else if (yres_virtual < yres) |
538 | yres_virtual = yres; | 680 | yres_virtual = yres; |
539 | if (var->sync & FB_SYNC_EXT) | 681 | if (var->sync & FB_SYNC_EXT) |
540 | par->hw.tt.sync=0; | 682 | par->hw.tt.sync = 0; |
541 | else | 683 | else |
542 | par->hw.tt.sync=1; | 684 | par->hw.tt.sync = 1; |
543 | linelen=xres*bpp/8; | 685 | linelen = xres * bpp / 8; |
544 | if (yres_virtual * linelen > screen_len && screen_len) | 686 | if (yres_virtual * linelen > screen_len && screen_len) |
545 | return -EINVAL; | 687 | return -EINVAL; |
546 | if (yres * linelen > screen_len && screen_len) | 688 | if (yres * linelen > screen_len && screen_len) |
@@ -552,154 +694,123 @@ static int tt_decode_var( struct fb_var_screeninfo *var, | |||
552 | return 0; | 694 | return 0; |
553 | } | 695 | } |
554 | 696 | ||
555 | static int tt_encode_var( struct fb_var_screeninfo *var, | 697 | static int tt_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par) |
556 | struct atafb_par *par ) | ||
557 | { | 698 | { |
558 | int linelen; | 699 | int linelen; |
559 | memset(var, 0, sizeof(struct fb_var_screeninfo)); | 700 | memset(var, 0, sizeof(struct fb_var_screeninfo)); |
560 | var->red.offset=0; | 701 | var->red.offset = 0; |
561 | var->red.length=4; | 702 | var->red.length = 4; |
562 | var->red.msb_right=0; | 703 | var->red.msb_right = 0; |
563 | var->grayscale=0; | 704 | var->grayscale = 0; |
564 | 705 | ||
565 | var->pixclock=31041; | 706 | var->pixclock = 31041; |
566 | var->left_margin=120; /* these may be incorrect */ | 707 | var->left_margin = 120; /* these may be incorrect */ |
567 | var->right_margin=100; | 708 | var->right_margin = 100; |
568 | var->upper_margin=8; | 709 | var->upper_margin = 8; |
569 | var->lower_margin=16; | 710 | var->lower_margin = 16; |
570 | var->hsync_len=140; | 711 | var->hsync_len = 140; |
571 | var->vsync_len=30; | 712 | var->vsync_len = 30; |
572 | 713 | ||
573 | var->height=-1; | 714 | var->height = -1; |
574 | var->width=-1; | 715 | var->width = -1; |
575 | 716 | ||
576 | if (par->hw.tt.sync & 1) | 717 | if (par->hw.tt.sync & 1) |
577 | var->sync=0; | 718 | var->sync = 0; |
578 | else | 719 | else |
579 | var->sync=FB_SYNC_EXT; | 720 | var->sync = FB_SYNC_EXT; |
580 | 721 | ||
581 | switch (par->hw.tt.mode & TT_SHIFTER_MODEMASK) { | 722 | switch (par->hw.tt.mode & TT_SHIFTER_MODEMASK) { |
582 | case TT_SHIFTER_STLOW: | 723 | case TT_SHIFTER_STLOW: |
583 | var->xres=sttt_xres/2; | 724 | var->xres = sttt_xres / 2; |
584 | var->xres_virtual=sttt_xres_virtual/2; | 725 | var->xres_virtual = sttt_xres_virtual / 2; |
585 | var->yres=st_yres/2; | 726 | var->yres = st_yres / 2; |
586 | var->bits_per_pixel=4; | 727 | var->bits_per_pixel = 4; |
587 | break; | 728 | break; |
588 | case TT_SHIFTER_STMID: | 729 | case TT_SHIFTER_STMID: |
589 | var->xres=sttt_xres; | 730 | var->xres = sttt_xres; |
590 | var->xres_virtual=sttt_xres_virtual; | 731 | var->xres_virtual = sttt_xres_virtual; |
591 | var->yres=st_yres/2; | 732 | var->yres = st_yres / 2; |
592 | var->bits_per_pixel=2; | 733 | var->bits_per_pixel = 2; |
593 | break; | 734 | break; |
594 | case TT_SHIFTER_STHIGH: | 735 | case TT_SHIFTER_STHIGH: |
595 | var->xres=sttt_xres; | 736 | var->xres = sttt_xres; |
596 | var->xres_virtual=sttt_xres_virtual; | 737 | var->xres_virtual = sttt_xres_virtual; |
597 | var->yres=st_yres; | 738 | var->yres = st_yres; |
598 | var->bits_per_pixel=1; | 739 | var->bits_per_pixel = 1; |
599 | break; | 740 | break; |
600 | case TT_SHIFTER_TTLOW: | 741 | case TT_SHIFTER_TTLOW: |
601 | var->xres=sttt_xres/2; | 742 | var->xres = sttt_xres / 2; |
602 | var->xres_virtual=sttt_xres_virtual/2; | 743 | var->xres_virtual = sttt_xres_virtual / 2; |
603 | var->yres=tt_yres; | 744 | var->yres = tt_yres; |
604 | var->bits_per_pixel=8; | 745 | var->bits_per_pixel = 8; |
605 | break; | 746 | break; |
606 | case TT_SHIFTER_TTMID: | 747 | case TT_SHIFTER_TTMID: |
607 | var->xres=sttt_xres; | 748 | var->xres = sttt_xres; |
608 | var->xres_virtual=sttt_xres_virtual; | 749 | var->xres_virtual = sttt_xres_virtual; |
609 | var->yres=tt_yres; | 750 | var->yres = tt_yres; |
610 | var->bits_per_pixel=4; | 751 | var->bits_per_pixel = 4; |
611 | break; | 752 | break; |
612 | case TT_SHIFTER_TTHIGH: | 753 | case TT_SHIFTER_TTHIGH: |
613 | var->red.length=0; | 754 | var->red.length = 0; |
614 | var->xres=sttt_xres*2; | 755 | var->xres = sttt_xres * 2; |
615 | var->xres_virtual=sttt_xres_virtual*2; | 756 | var->xres_virtual = sttt_xres_virtual * 2; |
616 | var->yres=tt_yres*2; | 757 | var->yres = tt_yres * 2; |
617 | var->bits_per_pixel=1; | 758 | var->bits_per_pixel = 1; |
618 | break; | 759 | break; |
619 | } | 760 | } |
620 | var->blue=var->green=var->red; | 761 | var->blue = var->green = var->red; |
621 | var->transp.offset=0; | 762 | var->transp.offset = 0; |
622 | var->transp.length=0; | 763 | var->transp.length = 0; |
623 | var->transp.msb_right=0; | 764 | var->transp.msb_right = 0; |
624 | linelen=var->xres_virtual * var->bits_per_pixel / 8; | 765 | linelen = var->xres_virtual * var->bits_per_pixel / 8; |
625 | if (! use_hwscroll) | 766 | if (!use_hwscroll) |
626 | var->yres_virtual=var->yres; | 767 | var->yres_virtual = var->yres; |
627 | else if (screen_len) { | 768 | else if (screen_len) { |
628 | if (par->yres_virtual) | 769 | if (par->yres_virtual) |
629 | var->yres_virtual = par->yres_virtual; | 770 | var->yres_virtual = par->yres_virtual; |
630 | else | 771 | else |
631 | /* yres_virtual==0 means use maximum */ | 772 | /* yres_virtual == 0 means use maximum */ |
632 | var->yres_virtual = screen_len / linelen; | 773 | var->yres_virtual = screen_len / linelen; |
633 | } else { | 774 | } else { |
634 | if (hwscroll < 0) | 775 | if (hwscroll < 0) |
635 | var->yres_virtual = 2 * var->yres; | 776 | var->yres_virtual = 2 * var->yres; |
636 | else | 777 | else |
637 | var->yres_virtual=var->yres+hwscroll * 16; | 778 | var->yres_virtual = var->yres + hwscroll * 16; |
638 | } | 779 | } |
639 | var->xoffset=0; | 780 | var->xoffset = 0; |
640 | if (screen_base) | 781 | if (screen_base) |
641 | var->yoffset=(par->screen_base - screen_base)/linelen; | 782 | var->yoffset = (par->screen_base - screen_base) / linelen; |
642 | else | 783 | else |
643 | var->yoffset=0; | 784 | var->yoffset = 0; |
644 | var->nonstd=0; | 785 | var->nonstd = 0; |
645 | var->activate=0; | 786 | var->activate = 0; |
646 | var->vmode=FB_VMODE_NONINTERLACED; | 787 | var->vmode = FB_VMODE_NONINTERLACED; |
647 | return 0; | 788 | return 0; |
648 | } | 789 | } |
649 | 790 | ||
650 | 791 | static void tt_get_par(struct atafb_par *par) | |
651 | static void tt_get_par( struct atafb_par *par ) | ||
652 | { | 792 | { |
653 | unsigned long addr; | 793 | unsigned long addr; |
654 | par->hw.tt.mode=shifter_tt.tt_shiftmode; | 794 | par->hw.tt.mode = shifter_tt.tt_shiftmode; |
655 | par->hw.tt.sync=shifter.syncmode; | 795 | par->hw.tt.sync = shifter.syncmode; |
656 | addr = ((shifter.bas_hi & 0xff) << 16) | | 796 | addr = ((shifter.bas_hi & 0xff) << 16) | |
657 | ((shifter.bas_md & 0xff) << 8) | | 797 | ((shifter.bas_md & 0xff) << 8) | |
658 | ((shifter.bas_lo & 0xff)); | 798 | ((shifter.bas_lo & 0xff)); |
659 | par->screen_base = phys_to_virt(addr); | 799 | par->screen_base = phys_to_virt(addr); |
660 | } | 800 | } |
661 | 801 | ||
662 | static void tt_set_par( struct atafb_par *par ) | 802 | static void tt_set_par(struct atafb_par *par) |
663 | { | 803 | { |
664 | shifter_tt.tt_shiftmode=par->hw.tt.mode; | 804 | shifter_tt.tt_shiftmode = par->hw.tt.mode; |
665 | shifter.syncmode=par->hw.tt.sync; | 805 | shifter.syncmode = par->hw.tt.sync; |
666 | /* only set screen_base if really necessary */ | 806 | /* only set screen_base if really necessary */ |
667 | if (current_par.screen_base != par->screen_base) | 807 | if (current_par.screen_base != par->screen_base) |
668 | fbhw->set_screen_base(par->screen_base); | 808 | fbhw->set_screen_base(par->screen_base); |
669 | } | 809 | } |
670 | 810 | ||
671 | 811 | static int tt_setcolreg(unsigned int regno, unsigned int red, | |
672 | static int tt_getcolreg(unsigned regno, unsigned *red, | 812 | unsigned int green, unsigned int blue, |
673 | unsigned *green, unsigned *blue, | 813 | unsigned int transp, struct fb_info *info) |
674 | unsigned *transp, struct fb_info *info) | ||
675 | { | ||
676 | int t, col; | ||
677 | |||
678 | if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH) | ||
679 | regno += 254; | ||
680 | if (regno > 255) | ||
681 | return 1; | ||
682 | t = tt_palette[regno]; | ||
683 | col = t & 15; | ||
684 | col |= col << 4; | ||
685 | col |= col << 8; | ||
686 | *blue = col; | ||
687 | col = (t >> 4) & 15; | ||
688 | col |= col << 4; | ||
689 | col |= col << 8; | ||
690 | *green = col; | ||
691 | col = (t >> 8) & 15; | ||
692 | col |= col << 4; | ||
693 | col |= col << 8; | ||
694 | *red = col; | ||
695 | *transp = 0; | ||
696 | return 0; | ||
697 | } | ||
698 | |||
699 | |||
700 | static int tt_setcolreg(unsigned regno, unsigned red, | ||
701 | unsigned green, unsigned blue, | ||
702 | unsigned transp, struct fb_info *info) | ||
703 | { | 814 | { |
704 | if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH) | 815 | if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == TT_SHIFTER_STHIGH) |
705 | regno += 254; | 816 | regno += 254; |
@@ -708,15 +819,14 @@ static int tt_setcolreg(unsigned regno, unsigned red, | |||
708 | tt_palette[regno] = (((red >> 12) << 8) | ((green >> 12) << 4) | | 819 | tt_palette[regno] = (((red >> 12) << 8) | ((green >> 12) << 4) | |
709 | (blue >> 12)); | 820 | (blue >> 12)); |
710 | if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == | 821 | if ((shifter_tt.tt_shiftmode & TT_SHIFTER_MODEMASK) == |
711 | TT_SHIFTER_STHIGH && regno == 254) | 822 | TT_SHIFTER_STHIGH && regno == 254) |
712 | tt_palette[0] = 0; | 823 | tt_palette[0] = 0; |
713 | return 0; | 824 | return 0; |
714 | } | 825 | } |
715 | 826 | ||
716 | 827 | static int tt_detect(void) | |
717 | static int tt_detect( void ) | 828 | { |
718 | 829 | struct atafb_par par; | |
719 | { struct atafb_par par; | ||
720 | 830 | ||
721 | /* Determine the connected monitor: The DMA sound must be | 831 | /* Determine the connected monitor: The DMA sound must be |
722 | * disabled before reading the MFP GPIP, because the Sound | 832 | * disabled before reading the MFP GPIP, because the Sound |
@@ -726,9 +836,9 @@ static int tt_detect( void ) | |||
726 | * announced that the Eagle is TT compatible, but only the PCM is | 836 | * announced that the Eagle is TT compatible, but only the PCM is |
727 | * missing... | 837 | * missing... |
728 | */ | 838 | */ |
729 | if (ATARIHW_PRESENT(PCM_8BIT)) { | 839 | if (ATARIHW_PRESENT(PCM_8BIT)) { |
730 | tt_dmasnd.ctrl = DMASND_CTRL_OFF; | 840 | tt_dmasnd.ctrl = DMASND_CTRL_OFF; |
731 | udelay(20); /* wait a while for things to settle down */ | 841 | udelay(20); /* wait a while for things to settle down */ |
732 | } | 842 | } |
733 | mono_moni = (mfp.par_dt_reg & 0x80) == 0; | 843 | mono_moni = (mfp.par_dt_reg & 0x80) == 0; |
734 | 844 | ||
@@ -755,19 +865,24 @@ static struct pixel_clock { | |||
755 | unsigned long f; /* f/[Hz] */ | 865 | unsigned long f; /* f/[Hz] */ |
756 | unsigned long t; /* t/[ps] (=1/f) */ | 866 | unsigned long t; /* t/[ps] (=1/f) */ |
757 | int right, hsync, left; /* standard timing in clock cycles, not pixel */ | 867 | int right, hsync, left; /* standard timing in clock cycles, not pixel */ |
758 | /* hsync initialized in falcon_detect() */ | 868 | /* hsync initialized in falcon_detect() */ |
759 | int sync_mask; /* or-mask for hw.falcon.sync to set this clock */ | 869 | int sync_mask; /* or-mask for hw.falcon.sync to set this clock */ |
760 | int control_mask; /* ditto, for hw.falcon.vid_control */ | 870 | int control_mask; /* ditto, for hw.falcon.vid_control */ |
761 | } | 871 | } f25 = { |
762 | f25 = {25175000, 39721, 18, 0, 42, 0x0, VCO_CLOCK25}, | 872 | 25175000, 39721, 18, 0, 42, 0x0, VCO_CLOCK25 |
763 | f32 = {32000000, 31250, 18, 0, 42, 0x0, 0}, | 873 | }, f32 = { |
764 | fext = { 0, 0, 18, 0, 42, 0x1, 0}; | 874 | 32000000, 31250, 18, 0, 42, 0x0, 0 |
875 | }, fext = { | ||
876 | 0, 0, 18, 0, 42, 0x1, 0 | ||
877 | }; | ||
765 | 878 | ||
766 | /* VIDEL-prescale values [mon_type][pixel_length from VCO] */ | 879 | /* VIDEL-prescale values [mon_type][pixel_length from VCO] */ |
767 | static int vdl_prescale[4][3] = {{4,2,1}, {4,2,1}, {4,2,2}, {4,2,1}}; | 880 | static int vdl_prescale[4][3] = { |
881 | { 4,2,1 }, { 4,2,1 }, { 4,2,2 }, { 4,2,1 } | ||
882 | }; | ||
768 | 883 | ||
769 | /* Default hsync timing [mon_type] in picoseconds */ | 884 | /* Default hsync timing [mon_type] in picoseconds */ |
770 | static long h_syncs[4] = {3000000, 4875000, 4000000, 4875000}; | 885 | static long h_syncs[4] = { 3000000, 4875000, 4000000, 4875000 }; |
771 | 886 | ||
772 | #ifdef FBCON_HAS_CFB16 | 887 | #ifdef FBCON_HAS_CFB16 |
773 | static u16 fbcon_cfb16_cmap[16]; | 888 | static u16 fbcon_cfb16_cmap[16]; |
@@ -775,12 +890,12 @@ static u16 fbcon_cfb16_cmap[16]; | |||
775 | 890 | ||
776 | static inline int hxx_prescale(struct falcon_hw *hw) | 891 | static inline int hxx_prescale(struct falcon_hw *hw) |
777 | { | 892 | { |
778 | return hw->ste_mode ? 16 : | 893 | return hw->ste_mode ? 16 |
779 | vdl_prescale[mon_type][hw->vid_mode >> 2 & 0x3]; | 894 | : vdl_prescale[mon_type][hw->vid_mode >> 2 & 0x3]; |
780 | } | 895 | } |
781 | 896 | ||
782 | static int falcon_encode_fix( struct fb_fix_screeninfo *fix, | 897 | static int falcon_encode_fix(struct fb_fix_screeninfo *fix, |
783 | struct atafb_par *par ) | 898 | struct atafb_par *par) |
784 | { | 899 | { |
785 | strcpy(fix->id, "Atari Builtin"); | 900 | strcpy(fix->id, "Atari Builtin"); |
786 | fix->smem_start = (unsigned long)real_screen_base; | 901 | fix->smem_start = (unsigned long)real_screen_base; |
@@ -796,8 +911,7 @@ static int falcon_encode_fix( struct fb_fix_screeninfo *fix, | |||
796 | fix->type_aux = 0; | 911 | fix->type_aux = 0; |
797 | /* no smooth scrolling with longword aligned video mem */ | 912 | /* no smooth scrolling with longword aligned video mem */ |
798 | fix->xpanstep = 32; | 913 | fix->xpanstep = 32; |
799 | } | 914 | } else if (par->hw.falcon.f_shift & 0x100) { |
800 | else if (par->hw.falcon.f_shift & 0x100) { | ||
801 | fix->type = FB_TYPE_PACKED_PIXELS; | 915 | fix->type = FB_TYPE_PACKED_PIXELS; |
802 | fix->type_aux = 0; | 916 | fix->type_aux = 0; |
803 | /* Is this ok or should it be DIRECTCOLOR? */ | 917 | /* Is this ok or should it be DIRECTCOLOR? */ |
@@ -809,9 +923,8 @@ static int falcon_encode_fix( struct fb_fix_screeninfo *fix, | |||
809 | return 0; | 923 | return 0; |
810 | } | 924 | } |
811 | 925 | ||
812 | 926 | static int falcon_decode_var(struct fb_var_screeninfo *var, | |
813 | static int falcon_decode_var( struct fb_var_screeninfo *var, | 927 | struct atafb_par *par) |
814 | struct atafb_par *par ) | ||
815 | { | 928 | { |
816 | int bpp = var->bits_per_pixel; | 929 | int bpp = var->bits_per_pixel; |
817 | int xres = var->xres; | 930 | int xres = var->xres; |
@@ -823,17 +936,19 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
823 | int linelen; | 936 | int linelen; |
824 | int interlace = 0, doubleline = 0; | 937 | int interlace = 0, doubleline = 0; |
825 | struct pixel_clock *pclock; | 938 | struct pixel_clock *pclock; |
826 | int plen; /* width of pixel in clock cycles */ | 939 | int plen; /* width of pixel in clock cycles */ |
827 | int xstretch; | 940 | int xstretch; |
828 | int prescale; | 941 | int prescale; |
829 | int longoffset = 0; | 942 | int longoffset = 0; |
830 | int hfreq, vfreq; | 943 | int hfreq, vfreq; |
944 | int hdb_off, hde_off, base_off; | ||
945 | int gstart, gend1, gend2, align; | ||
831 | 946 | ||
832 | /* | 947 | /* |
833 | Get the video params out of 'var'. If a value doesn't fit, round | 948 | Get the video params out of 'var'. If a value doesn't fit, round |
834 | it up, if it's too big, return EINVAL. | 949 | it up, if it's too big, return EINVAL. |
835 | Round up in the following order: bits_per_pixel, xres, yres, | 950 | Round up in the following order: bits_per_pixel, xres, yres, |
836 | xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, | 951 | xres_virtual, yres_virtual, xoffset, yoffset, grayscale, bitfields, |
837 | horizontal timing, vertical timing. | 952 | horizontal timing, vertical timing. |
838 | 953 | ||
839 | There is a maximum of screen resolution determined by pixelclock | 954 | There is a maximum of screen resolution determined by pixelclock |
@@ -843,11 +958,11 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
843 | Frequency range for multisync monitors is given via command line. | 958 | Frequency range for multisync monitors is given via command line. |
844 | For TV and SM124 both frequencies are fixed. | 959 | For TV and SM124 both frequencies are fixed. |
845 | 960 | ||
846 | X % 16 == 0 to fit 8x?? font (except 1 bitplane modes must use X%32==0) | 961 | X % 16 == 0 to fit 8x?? font (except 1 bitplane modes must use X%32 == 0) |
847 | Y % 16 == 0 to fit 8x16 font | 962 | Y % 16 == 0 to fit 8x16 font |
848 | Y % 8 == 0 if Y<400 | 963 | Y % 8 == 0 if Y<400 |
849 | 964 | ||
850 | Currently interlace and doubleline mode in var are ignored. | 965 | Currently interlace and doubleline mode in var are ignored. |
851 | On SM124 and TV only the standard resolutions can be used. | 966 | On SM124 and TV only the standard resolutions can be used. |
852 | */ | 967 | */ |
853 | 968 | ||
@@ -855,43 +970,38 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
855 | if (!xres || !yres || !bpp) | 970 | if (!xres || !yres || !bpp) |
856 | return -EINVAL; | 971 | return -EINVAL; |
857 | 972 | ||
858 | if (mon_type == F_MON_SM && bpp != 1) { | 973 | if (mon_type == F_MON_SM && bpp != 1) |
859 | return -EINVAL; | 974 | return -EINVAL; |
860 | } | 975 | |
861 | else if (bpp <= 1) { | 976 | if (bpp <= 1) { |
862 | bpp = 1; | 977 | bpp = 1; |
863 | par->hw.falcon.f_shift = 0x400; | 978 | par->hw.falcon.f_shift = 0x400; |
864 | par->hw.falcon.st_shift = 0x200; | 979 | par->hw.falcon.st_shift = 0x200; |
865 | } | 980 | } else if (bpp <= 2) { |
866 | else if (bpp <= 2) { | ||
867 | bpp = 2; | 981 | bpp = 2; |
868 | par->hw.falcon.f_shift = 0x000; | 982 | par->hw.falcon.f_shift = 0x000; |
869 | par->hw.falcon.st_shift = 0x100; | 983 | par->hw.falcon.st_shift = 0x100; |
870 | } | 984 | } else if (bpp <= 4) { |
871 | else if (bpp <= 4) { | ||
872 | bpp = 4; | 985 | bpp = 4; |
873 | par->hw.falcon.f_shift = 0x000; | 986 | par->hw.falcon.f_shift = 0x000; |
874 | par->hw.falcon.st_shift = 0x000; | 987 | par->hw.falcon.st_shift = 0x000; |
875 | } | 988 | } else if (bpp <= 8) { |
876 | else if (bpp <= 8) { | ||
877 | bpp = 8; | 989 | bpp = 8; |
878 | par->hw.falcon.f_shift = 0x010; | 990 | par->hw.falcon.f_shift = 0x010; |
879 | } | 991 | } else if (bpp <= 16) { |
880 | else if (bpp <= 16) { | 992 | bpp = 16; /* packed pixel mode */ |
881 | bpp = 16; /* packed pixel mode */ | 993 | par->hw.falcon.f_shift = 0x100; /* hicolor, no overlay */ |
882 | par->hw.falcon.f_shift = 0x100; /* hicolor, no overlay */ | 994 | } else |
883 | } | ||
884 | else | ||
885 | return -EINVAL; | 995 | return -EINVAL; |
886 | par->hw.falcon.bpp = bpp; | 996 | par->hw.falcon.bpp = bpp; |
887 | 997 | ||
888 | if (mon_type == F_MON_SM || DontCalcRes) { | 998 | if (mon_type == F_MON_SM || DontCalcRes) { |
889 | /* Skip all calculations. VGA/TV/SC1224 only supported. */ | 999 | /* Skip all calculations. VGA/TV/SC1224 only supported. */ |
890 | struct fb_var_screeninfo *myvar = &atafb_predefined[0]; | 1000 | struct fb_var_screeninfo *myvar = &atafb_predefined[0]; |
891 | 1001 | ||
892 | if (bpp > myvar->bits_per_pixel || | 1002 | if (bpp > myvar->bits_per_pixel || |
893 | var->xres > myvar->xres || | 1003 | var->xres > myvar->xres || |
894 | var->yres > myvar->yres) | 1004 | var->yres > myvar->yres) |
895 | return -EINVAL; | 1005 | return -EINVAL; |
896 | fbhw->get_par(par); /* Current par will be new par */ | 1006 | fbhw->get_par(par); /* Current par will be new par */ |
897 | goto set_screen_base; /* Don't forget this */ | 1007 | goto set_screen_base; /* Don't forget this */ |
@@ -910,8 +1020,8 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
910 | yres = 400; | 1020 | yres = 400; |
911 | 1021 | ||
912 | /* 2 planes must use STE compatibility mode */ | 1022 | /* 2 planes must use STE compatibility mode */ |
913 | par->hw.falcon.ste_mode = bpp==2; | 1023 | par->hw.falcon.ste_mode = bpp == 2; |
914 | par->hw.falcon.mono = bpp==1; | 1024 | par->hw.falcon.mono = bpp == 1; |
915 | 1025 | ||
916 | /* Total and visible scanline length must be a multiple of one longword, | 1026 | /* Total and visible scanline length must be a multiple of one longword, |
917 | * this and the console fontwidth yields the alignment for xres and | 1027 | * this and the console fontwidth yields the alignment for xres and |
@@ -967,8 +1077,7 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
967 | left_margin = hsync_len = 128 / plen; | 1077 | left_margin = hsync_len = 128 / plen; |
968 | right_margin = 0; | 1078 | right_margin = 0; |
969 | /* TODO set all margins */ | 1079 | /* TODO set all margins */ |
970 | } | 1080 | } else |
971 | else | ||
972 | #endif | 1081 | #endif |
973 | if (mon_type == F_MON_SC || mon_type == F_MON_TV) { | 1082 | if (mon_type == F_MON_SC || mon_type == F_MON_TV) { |
974 | plen = 2 * xstretch; | 1083 | plen = 2 * xstretch; |
@@ -1002,26 +1111,24 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1002 | vsync_len *= 2; | 1111 | vsync_len *= 2; |
1003 | } | 1112 | } |
1004 | } | 1113 | } |
1005 | } | 1114 | } else { /* F_MON_VGA */ |
1006 | else | ||
1007 | { /* F_MON_VGA */ | ||
1008 | if (bpp == 16) | 1115 | if (bpp == 16) |
1009 | xstretch = 2; /* Double pixel width only for hicolor */ | 1116 | xstretch = 2; /* Double pixel width only for hicolor */ |
1010 | /* Default values are used for vert./hor. timing if no pixelclock given. */ | 1117 | /* Default values are used for vert./hor. timing if no pixelclock given. */ |
1011 | if (var->pixclock == 0) { | 1118 | if (var->pixclock == 0) { |
1012 | int linesize; | 1119 | int linesize; |
1013 | 1120 | ||
1014 | /* Choose master pixelclock depending on hor. timing */ | 1121 | /* Choose master pixelclock depending on hor. timing */ |
1015 | plen = 1 * xstretch; | 1122 | plen = 1 * xstretch; |
1016 | if ((plen * xres + f25.right+f25.hsync+f25.left) * | 1123 | if ((plen * xres + f25.right + f25.hsync + f25.left) * |
1017 | fb_info.monspecs.hfmin < f25.f) | 1124 | fb_info.monspecs.hfmin < f25.f) |
1018 | pclock = &f25; | 1125 | pclock = &f25; |
1019 | else if ((plen * xres + f32.right+f32.hsync+f32.left) * | 1126 | else if ((plen * xres + f32.right + f32.hsync + |
1020 | fb_info.monspecs.hfmin < f32.f) | 1127 | f32.left) * fb_info.monspecs.hfmin < f32.f) |
1021 | pclock = &f32; | 1128 | pclock = &f32; |
1022 | else if ((plen * xres + fext.right+fext.hsync+fext.left) * | 1129 | else if ((plen * xres + fext.right + fext.hsync + |
1023 | fb_info.monspecs.hfmin < fext.f | 1130 | fext.left) * fb_info.monspecs.hfmin < fext.f && |
1024 | && fext.f) | 1131 | fext.f) |
1025 | pclock = &fext; | 1132 | pclock = &fext; |
1026 | else | 1133 | else |
1027 | return -EINVAL; | 1134 | return -EINVAL; |
@@ -1033,22 +1140,24 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1033 | upper_margin = 31; | 1140 | upper_margin = 31; |
1034 | lower_margin = 11; | 1141 | lower_margin = 11; |
1035 | vsync_len = 3; | 1142 | vsync_len = 3; |
1036 | } | 1143 | } else { |
1037 | else { | ||
1038 | /* Choose largest pixelclock <= wanted clock */ | 1144 | /* Choose largest pixelclock <= wanted clock */ |
1039 | int i; | 1145 | int i; |
1040 | unsigned long pcl = ULONG_MAX; | 1146 | unsigned long pcl = ULONG_MAX; |
1041 | pclock = 0; | 1147 | pclock = 0; |
1042 | for (i=1; i <= 4; i *= 2) { | 1148 | for (i = 1; i <= 4; i *= 2) { |
1043 | if (f25.t*i >= var->pixclock && f25.t*i < pcl) { | 1149 | if (f25.t * i >= var->pixclock && |
1150 | f25.t * i < pcl) { | ||
1044 | pcl = f25.t * i; | 1151 | pcl = f25.t * i; |
1045 | pclock = &f25; | 1152 | pclock = &f25; |
1046 | } | 1153 | } |
1047 | if (f32.t*i >= var->pixclock && f32.t*i < pcl) { | 1154 | if (f32.t * i >= var->pixclock && |
1155 | f32.t * i < pcl) { | ||
1048 | pcl = f32.t * i; | 1156 | pcl = f32.t * i; |
1049 | pclock = &f32; | 1157 | pclock = &f32; |
1050 | } | 1158 | } |
1051 | if (fext.t && fext.t*i >= var->pixclock && fext.t*i < pcl) { | 1159 | if (fext.t && fext.t * i >= var->pixclock && |
1160 | fext.t * i < pcl) { | ||
1052 | pcl = fext.t * i; | 1161 | pcl = fext.t * i; |
1053 | pclock = &fext; | 1162 | pclock = &fext; |
1054 | } | 1163 | } |
@@ -1070,8 +1179,7 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1070 | upper_margin = (upper_margin + 1) / 2; | 1179 | upper_margin = (upper_margin + 1) / 2; |
1071 | lower_margin = (lower_margin + 1) / 2; | 1180 | lower_margin = (lower_margin + 1) / 2; |
1072 | vsync_len = (vsync_len + 1) / 2; | 1181 | vsync_len = (vsync_len + 1) / 2; |
1073 | } | 1182 | } else if (var->vmode & FB_VMODE_DOUBLE) { |
1074 | else if (var->vmode & FB_VMODE_DOUBLE) { | ||
1075 | /* External unit is [double lines per frame] */ | 1183 | /* External unit is [double lines per frame] */ |
1076 | upper_margin *= 2; | 1184 | upper_margin *= 2; |
1077 | lower_margin *= 2; | 1185 | lower_margin *= 2; |
@@ -1079,7 +1187,7 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1079 | } | 1187 | } |
1080 | } | 1188 | } |
1081 | if (pclock == &fext) | 1189 | if (pclock == &fext) |
1082 | longoffset = 1; /* VIDEL doesn't synchronize on short offset */ | 1190 | longoffset = 1; /* VIDEL doesn't synchronize on short offset */ |
1083 | } | 1191 | } |
1084 | /* Is video bus bandwidth (32MB/s) too low for this resolution? */ | 1192 | /* Is video bus bandwidth (32MB/s) too low for this resolution? */ |
1085 | /* this is definitely wrong if bus clock != 32MHz */ | 1193 | /* this is definitely wrong if bus clock != 32MHz */ |
@@ -1098,7 +1206,7 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1098 | * between interlace and non-interlace without messing around | 1206 | * between interlace and non-interlace without messing around |
1099 | * with these. | 1207 | * with these. |
1100 | */ | 1208 | */ |
1101 | again: | 1209 | again: |
1102 | /* Set base_offset 128 and video bus width */ | 1210 | /* Set base_offset 128 and video bus width */ |
1103 | par->hw.falcon.vid_control = mon_type | f030_bus_width; | 1211 | par->hw.falcon.vid_control = mon_type | f030_bus_width; |
1104 | if (!longoffset) | 1212 | if (!longoffset) |
@@ -1112,37 +1220,34 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1112 | /* External or internal clock */ | 1220 | /* External or internal clock */ |
1113 | par->hw.falcon.sync = pclock->sync_mask | 0x2; | 1221 | par->hw.falcon.sync = pclock->sync_mask | 0x2; |
1114 | /* Pixellength and prescale */ | 1222 | /* Pixellength and prescale */ |
1115 | par->hw.falcon.vid_mode = (2/plen) << 2; | 1223 | par->hw.falcon.vid_mode = (2 / plen) << 2; |
1116 | if (doubleline) | 1224 | if (doubleline) |
1117 | par->hw.falcon.vid_mode |= VMO_DOUBLE; | 1225 | par->hw.falcon.vid_mode |= VMO_DOUBLE; |
1118 | if (interlace) | 1226 | if (interlace) |
1119 | par->hw.falcon.vid_mode |= VMO_INTER; | 1227 | par->hw.falcon.vid_mode |= VMO_INTER; |
1120 | 1228 | ||
1121 | /********************* | 1229 | /********************* |
1122 | Horizontal timing: unit = [master clock cycles] | 1230 | * Horizontal timing: unit = [master clock cycles] |
1123 | unit of hxx-registers: [master clock cycles * prescale] | 1231 | * unit of hxx-registers: [master clock cycles * prescale] |
1124 | Hxx-registers are 9 bit wide | 1232 | * Hxx-registers are 9 bit wide |
1125 | 1233 | * | |
1126 | 1 line = ((hht + 2) * 2 * prescale) clock cycles | 1234 | * 1 line = ((hht + 2) * 2 * prescale) clock cycles |
1127 | 1235 | * | |
1128 | graphic output = hdb & 0x200 ? | 1236 | * graphic output = hdb & 0x200 ? |
1129 | ((hht+2)*2 - hdb + hde) * prescale - hdboff + hdeoff: | 1237 | * ((hht + 2) * 2 - hdb + hde) * prescale - hdboff + hdeoff: |
1130 | ( hht + 2 - hdb + hde) * prescale - hdboff + hdeoff | 1238 | * (hht + 2 - hdb + hde) * prescale - hdboff + hdeoff |
1131 | (this must be a multiple of plen*128/bpp, on VGA pixels | 1239 | * (this must be a multiple of plen*128/bpp, on VGA pixels |
1132 | to the right may be cut off with a bigger right margin) | 1240 | * to the right may be cut off with a bigger right margin) |
1133 | 1241 | * | |
1134 | start of graphics relative to start of 1st halfline = hdb & 0x200 ? | 1242 | * start of graphics relative to start of 1st halfline = hdb & 0x200 ? |
1135 | (hdb - hht - 2) * prescale + hdboff : | 1243 | * (hdb - hht - 2) * prescale + hdboff : |
1136 | hdb * prescale + hdboff | 1244 | * hdb * prescale + hdboff |
1137 | 1245 | * | |
1138 | end of graphics relative to start of 1st halfline = | 1246 | * end of graphics relative to start of 1st halfline = |
1139 | (hde + hht + 2) * prescale + hdeoff | 1247 | * (hde + hht + 2) * prescale + hdeoff |
1140 | *********************/ | 1248 | *********************/ |
1141 | /* Calculate VIDEL registers */ | 1249 | /* Calculate VIDEL registers */ |
1142 | { | 1250 | { |
1143 | int hdb_off, hde_off, base_off; | ||
1144 | int gstart, gend1, gend2, align; | ||
1145 | |||
1146 | prescale = hxx_prescale(&par->hw.falcon); | 1251 | prescale = hxx_prescale(&par->hw.falcon); |
1147 | base_off = par->hw.falcon.vid_control & VCO_SHORTOFFS ? 64 : 128; | 1252 | base_off = par->hw.falcon.vid_control & VCO_SHORTOFFS ? 64 : 128; |
1148 | 1253 | ||
@@ -1154,8 +1259,7 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1154 | align = 1; | 1259 | align = 1; |
1155 | hde_off = 0; | 1260 | hde_off = 0; |
1156 | hdb_off = (base_off + 16 * plen) + prescale; | 1261 | hdb_off = (base_off + 16 * plen) + prescale; |
1157 | } | 1262 | } else { |
1158 | else { | ||
1159 | align = 128 / bpp; | 1263 | align = 128 / bpp; |
1160 | hde_off = ((128 / bpp + 2) * plen); | 1264 | hde_off = ((128 / bpp + 2) * plen); |
1161 | if (par->hw.falcon.ste_mode) | 1265 | if (par->hw.falcon.ste_mode) |
@@ -1164,23 +1268,24 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1164 | hdb_off = (base_off + (128 / bpp + 18) * plen) + prescale; | 1268 | hdb_off = (base_off + (128 / bpp + 18) * plen) + prescale; |
1165 | } | 1269 | } |
1166 | 1270 | ||
1167 | gstart = (prescale/2 + plen * left_margin) / prescale; | 1271 | gstart = (prescale / 2 + plen * left_margin) / prescale; |
1168 | /* gend1 is for hde (gend-gstart multiple of align), shifter's xres */ | 1272 | /* gend1 is for hde (gend-gstart multiple of align), shifter's xres */ |
1169 | gend1 = gstart + ((xres + align-1) / align)*align * plen / prescale; | 1273 | gend1 = gstart + ((xres + align - 1) / align) * align * plen / prescale; |
1170 | /* gend2 is for hbb, visible xres (rest to gend1 is cut off by hblank) */ | 1274 | /* gend2 is for hbb, visible xres (rest to gend1 is cut off by hblank) */ |
1171 | gend2 = gstart + xres * plen / prescale; | 1275 | gend2 = gstart + xres * plen / prescale; |
1172 | par->HHT = plen * (left_margin + xres + right_margin) / | 1276 | par->HHT = plen * (left_margin + xres + right_margin) / |
1173 | (2 * prescale) - 2; | 1277 | (2 * prescale) - 2; |
1174 | /* par->HHT = (gend2 + plen * right_margin / prescale) / 2 - 2;*/ | 1278 | /* par->HHT = (gend2 + plen * right_margin / prescale) / 2 - 2;*/ |
1175 | 1279 | ||
1176 | par->HDB = gstart - hdb_off/prescale; | 1280 | par->HDB = gstart - hdb_off / prescale; |
1177 | par->HBE = gstart; | 1281 | par->HBE = gstart; |
1178 | if (par->HDB < 0) par->HDB += par->HHT + 2 + 0x200; | 1282 | if (par->HDB < 0) |
1179 | par->HDE = gend1 - par->HHT - 2 - hde_off/prescale; | 1283 | par->HDB += par->HHT + 2 + 0x200; |
1284 | par->HDE = gend1 - par->HHT - 2 - hde_off / prescale; | ||
1180 | par->HBB = gend2 - par->HHT - 2; | 1285 | par->HBB = gend2 - par->HHT - 2; |
1181 | #if 0 | 1286 | #if 0 |
1182 | /* One more Videl constraint: data fetch of two lines must not overlap */ | 1287 | /* One more Videl constraint: data fetch of two lines must not overlap */ |
1183 | if ((par->HDB & 0x200) && (par->HDB & ~0x200) - par->HDE <= 5) { | 1288 | if ((par->HDB & 0x200) && (par->HDB & ~0x200) - par->HDE <= 5) { |
1184 | /* if this happens increase margins, decrease hfreq. */ | 1289 | /* if this happens increase margins, decrease hfreq. */ |
1185 | } | 1290 | } |
1186 | #endif | 1291 | #endif |
@@ -1189,11 +1294,11 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1189 | par->HSS = par->HHT + 2 - plen * hsync_len / prescale; | 1294 | par->HSS = par->HHT + 2 - plen * hsync_len / prescale; |
1190 | if (par->HSS < par->HBB) | 1295 | if (par->HSS < par->HBB) |
1191 | par->HSS = par->HBB; | 1296 | par->HSS = par->HBB; |
1192 | } | 1297 | } |
1193 | 1298 | ||
1194 | /* check hor. frequency */ | 1299 | /* check hor. frequency */ |
1195 | hfreq = pclock->f / ((par->HHT+2)*prescale*2); | 1300 | hfreq = pclock->f / ((par->HHT + 2) * prescale * 2); |
1196 | if (hfreq > fb_info.monspecs.hfmax && mon_type!=F_MON_VGA) { | 1301 | if (hfreq > fb_info.monspecs.hfmax && mon_type != F_MON_VGA) { |
1197 | /* ++guenther: ^^^^^^^^^^^^^^^^^^^ can't remember why I did this */ | 1302 | /* ++guenther: ^^^^^^^^^^^^^^^^^^^ can't remember why I did this */ |
1198 | /* Too high -> enlarge margin */ | 1303 | /* Too high -> enlarge margin */ |
1199 | left_margin += 1; | 1304 | left_margin += 1; |
@@ -1213,12 +1318,14 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1213 | par->VBE = (upper_margin * 2 + 1); /* must begin on odd halfline */ | 1318 | par->VBE = (upper_margin * 2 + 1); /* must begin on odd halfline */ |
1214 | par->VDB = par->VBE; | 1319 | par->VDB = par->VBE; |
1215 | par->VDE = yres; | 1320 | par->VDE = yres; |
1216 | if (!interlace) par->VDE <<= 1; | 1321 | if (!interlace) |
1217 | if (doubleline) par->VDE <<= 1; /* VDE now half lines per (half-)frame */ | 1322 | par->VDE <<= 1; |
1323 | if (doubleline) | ||
1324 | par->VDE <<= 1; /* VDE now half lines per (half-)frame */ | ||
1218 | par->VDE += par->VDB; | 1325 | par->VDE += par->VDB; |
1219 | par->VBB = par->VDE; | 1326 | par->VBB = par->VDE; |
1220 | par->VFT = par->VBB + (lower_margin * 2 - 1) - 1; | 1327 | par->VFT = par->VBB + (lower_margin * 2 - 1) - 1; |
1221 | par->VSS = par->VFT+1 - (vsync_len * 2 - 1); | 1328 | par->VSS = par->VFT + 1 - (vsync_len * 2 - 1); |
1222 | /* vbb,vss,vft must be even in interlace mode */ | 1329 | /* vbb,vss,vft must be even in interlace mode */ |
1223 | if (interlace) { | 1330 | if (interlace) { |
1224 | par->VBB++; | 1331 | par->VBB++; |
@@ -1229,55 +1336,53 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1229 | /* V-frequency check, hope I didn't create any loop here. */ | 1336 | /* V-frequency check, hope I didn't create any loop here. */ |
1230 | /* Interlace and doubleline are mutually exclusive. */ | 1337 | /* Interlace and doubleline are mutually exclusive. */ |
1231 | vfreq = (hfreq * 2) / (par->VFT + 1); | 1338 | vfreq = (hfreq * 2) / (par->VFT + 1); |
1232 | if (vfreq > fb_info.monspecs.vfmax && !doubleline && !interlace) { | 1339 | if (vfreq > fb_info.monspecs.vfmax && !doubleline && !interlace) { |
1233 | /* Too high -> try again with doubleline */ | 1340 | /* Too high -> try again with doubleline */ |
1234 | doubleline = 1; | 1341 | doubleline = 1; |
1235 | goto again; | 1342 | goto again; |
1236 | } | 1343 | } else if (vfreq < fb_info.monspecs.vfmin && !interlace && !doubleline) { |
1237 | else if (vfreq < fb_info.monspecs.vfmin && !interlace && !doubleline) { | ||
1238 | /* Too low -> try again with interlace */ | 1344 | /* Too low -> try again with interlace */ |
1239 | interlace = 1; | 1345 | interlace = 1; |
1240 | goto again; | 1346 | goto again; |
1241 | } | 1347 | } else if (vfreq < fb_info.monspecs.vfmin && doubleline) { |
1242 | else if (vfreq < fb_info.monspecs.vfmin && doubleline) { | ||
1243 | /* Doubleline too low -> clear doubleline and enlarge margins */ | 1348 | /* Doubleline too low -> clear doubleline and enlarge margins */ |
1244 | int lines; | 1349 | int lines; |
1245 | doubleline = 0; | 1350 | doubleline = 0; |
1246 | for (lines=0; | 1351 | for (lines = 0; |
1247 | (hfreq*2)/(par->VFT+1+4*lines-2*yres)>fb_info.monspecs.vfmax; | 1352 | (hfreq * 2) / (par->VFT + 1 + 4 * lines - 2 * yres) > |
1353 | fb_info.monspecs.vfmax; | ||
1248 | lines++) | 1354 | lines++) |
1249 | ; | 1355 | ; |
1250 | upper_margin += lines; | 1356 | upper_margin += lines; |
1251 | lower_margin += lines; | 1357 | lower_margin += lines; |
1252 | goto again; | 1358 | goto again; |
1253 | } | 1359 | } else if (vfreq > fb_info.monspecs.vfmax && doubleline) { |
1254 | else if (vfreq > fb_info.monspecs.vfmax && doubleline) { | ||
1255 | /* Doubleline too high -> enlarge margins */ | 1360 | /* Doubleline too high -> enlarge margins */ |
1256 | int lines; | 1361 | int lines; |
1257 | for (lines=0; | 1362 | for (lines = 0; |
1258 | (hfreq*2)/(par->VFT+1+4*lines)>fb_info.monspecs.vfmax; | 1363 | (hfreq * 2) / (par->VFT + 1 + 4 * lines) > |
1259 | lines+=2) | 1364 | fb_info.monspecs.vfmax; |
1365 | lines += 2) | ||
1260 | ; | 1366 | ; |
1261 | upper_margin += lines; | 1367 | upper_margin += lines; |
1262 | lower_margin += lines; | 1368 | lower_margin += lines; |
1263 | goto again; | 1369 | goto again; |
1264 | } | 1370 | } else if (vfreq > fb_info.monspecs.vfmax && interlace) { |
1265 | else if (vfreq > fb_info.monspecs.vfmax && interlace) { | ||
1266 | /* Interlace, too high -> enlarge margins */ | 1371 | /* Interlace, too high -> enlarge margins */ |
1267 | int lines; | 1372 | int lines; |
1268 | for (lines=0; | 1373 | for (lines = 0; |
1269 | (hfreq*2)/(par->VFT+1+4*lines)>fb_info.monspecs.vfmax; | 1374 | (hfreq * 2) / (par->VFT + 1 + 4 * lines) > |
1375 | fb_info.monspecs.vfmax; | ||
1270 | lines++) | 1376 | lines++) |
1271 | ; | 1377 | ; |
1272 | upper_margin += lines; | 1378 | upper_margin += lines; |
1273 | lower_margin += lines; | 1379 | lower_margin += lines; |
1274 | goto again; | 1380 | goto again; |
1275 | } | 1381 | } else if (vfreq < fb_info.monspecs.vfmin || |
1276 | else if (vfreq < fb_info.monspecs.vfmin || | 1382 | vfreq > fb_info.monspecs.vfmax) |
1277 | vfreq > fb_info.monspecs.vfmax) | ||
1278 | return -EINVAL; | 1383 | return -EINVAL; |
1279 | 1384 | ||
1280 | set_screen_base: | 1385 | set_screen_base: |
1281 | linelen = xres_virtual * bpp / 8; | 1386 | linelen = xres_virtual * bpp / 8; |
1282 | if (yres_virtual * linelen > screen_len && screen_len) | 1387 | if (yres_virtual * linelen > screen_len && screen_len) |
1283 | return -EINVAL; | 1388 | return -EINVAL; |
@@ -1289,11 +1394,20 @@ static int falcon_decode_var( struct fb_var_screeninfo *var, | |||
1289 | par->screen_base = screen_base + var->yoffset * linelen; | 1394 | par->screen_base = screen_base + var->yoffset * linelen; |
1290 | par->hw.falcon.xoffset = 0; | 1395 | par->hw.falcon.xoffset = 0; |
1291 | 1396 | ||
1397 | // FIXME!!! sort of works, no crash | ||
1398 | //par->next_line = linelen; | ||
1399 | //par->next_plane = yres_virtual * linelen; | ||
1400 | par->next_line = linelen; | ||
1401 | par->next_plane = 2; | ||
1402 | // crashes | ||
1403 | //par->next_plane = linelen; | ||
1404 | //par->next_line = yres_virtual * linelen; | ||
1405 | |||
1292 | return 0; | 1406 | return 0; |
1293 | } | 1407 | } |
1294 | 1408 | ||
1295 | static int falcon_encode_var( struct fb_var_screeninfo *var, | 1409 | static int falcon_encode_var(struct fb_var_screeninfo *var, |
1296 | struct atafb_par *par ) | 1410 | struct atafb_par *par) |
1297 | { | 1411 | { |
1298 | /* !!! only for VGA !!! */ | 1412 | /* !!! only for VGA !!! */ |
1299 | int linelen; | 1413 | int linelen; |
@@ -1306,10 +1420,10 @@ static int falcon_encode_var( struct fb_var_screeninfo *var, | |||
1306 | var->pixclock = hw->sync & 0x1 ? fext.t : | 1420 | var->pixclock = hw->sync & 0x1 ? fext.t : |
1307 | hw->vid_control & VCO_CLOCK25 ? f25.t : f32.t; | 1421 | hw->vid_control & VCO_CLOCK25 ? f25.t : f32.t; |
1308 | 1422 | ||
1309 | var->height=-1; | 1423 | var->height = -1; |
1310 | var->width=-1; | 1424 | var->width = -1; |
1311 | 1425 | ||
1312 | var->sync=0; | 1426 | var->sync = 0; |
1313 | if (hw->vid_control & VCO_HSYPOS) | 1427 | if (hw->vid_control & VCO_HSYPOS) |
1314 | var->sync |= FB_SYNC_HOR_HIGH_ACT; | 1428 | var->sync |= FB_SYNC_HOR_HIGH_ACT; |
1315 | if (hw->vid_control & VCO_VSYPOS) | 1429 | if (hw->vid_control & VCO_VSYPOS) |
@@ -1320,7 +1434,7 @@ static int falcon_encode_var( struct fb_var_screeninfo *var, | |||
1320 | var->vmode |= FB_VMODE_INTERLACED; | 1434 | var->vmode |= FB_VMODE_INTERLACED; |
1321 | if (hw->vid_mode & VMO_DOUBLE) | 1435 | if (hw->vid_mode & VMO_DOUBLE) |
1322 | var->vmode |= FB_VMODE_DOUBLE; | 1436 | var->vmode |= FB_VMODE_DOUBLE; |
1323 | 1437 | ||
1324 | /* visible y resolution: | 1438 | /* visible y resolution: |
1325 | * Graphics display starts at line VDB and ends at line | 1439 | * Graphics display starts at line VDB and ends at line |
1326 | * VDE. If interlace mode off unit of VC-registers is | 1440 | * VDE. If interlace mode off unit of VC-registers is |
@@ -1332,14 +1446,15 @@ static int falcon_encode_var( struct fb_var_screeninfo *var, | |||
1332 | if (var->vmode & FB_VMODE_DOUBLE) | 1446 | if (var->vmode & FB_VMODE_DOUBLE) |
1333 | var->yres >>= 1; | 1447 | var->yres >>= 1; |
1334 | 1448 | ||
1335 | /* to get bpp, we must examine f_shift and st_shift. | 1449 | /* |
1450 | * to get bpp, we must examine f_shift and st_shift. | ||
1336 | * f_shift is valid if any of bits no. 10, 8 or 4 | 1451 | * f_shift is valid if any of bits no. 10, 8 or 4 |
1337 | * is set. Priority in f_shift is: 10 ">" 8 ">" 4, i.e. | 1452 | * is set. Priority in f_shift is: 10 ">" 8 ">" 4, i.e. |
1338 | * if bit 10 set then bit 8 and bit 4 don't care... | 1453 | * if bit 10 set then bit 8 and bit 4 don't care... |
1339 | * If all these bits are 0 get display depth from st_shift | 1454 | * If all these bits are 0 get display depth from st_shift |
1340 | * (as for ST and STE) | 1455 | * (as for ST and STE) |
1341 | */ | 1456 | */ |
1342 | if (hw->f_shift & 0x400) /* 2 colors */ | 1457 | if (hw->f_shift & 0x400) /* 2 colors */ |
1343 | var->bits_per_pixel = 1; | 1458 | var->bits_per_pixel = 1; |
1344 | else if (hw->f_shift & 0x100) /* hicolor */ | 1459 | else if (hw->f_shift & 0x100) /* hicolor */ |
1345 | var->bits_per_pixel = 16; | 1460 | var->bits_per_pixel = 16; |
@@ -1349,7 +1464,7 @@ static int falcon_encode_var( struct fb_var_screeninfo *var, | |||
1349 | var->bits_per_pixel = 4; | 1464 | var->bits_per_pixel = 4; |
1350 | else if (hw->st_shift == 0x100) | 1465 | else if (hw->st_shift == 0x100) |
1351 | var->bits_per_pixel = 2; | 1466 | var->bits_per_pixel = 2; |
1352 | else /* if (hw->st_shift == 0x200) */ | 1467 | else /* if (hw->st_shift == 0x200) */ |
1353 | var->bits_per_pixel = 1; | 1468 | var->bits_per_pixel = 1; |
1354 | 1469 | ||
1355 | var->xres = hw->line_width * 16 / var->bits_per_pixel; | 1470 | var->xres = hw->line_width * 16 / var->bits_per_pixel; |
@@ -1358,42 +1473,42 @@ static int falcon_encode_var( struct fb_var_screeninfo *var, | |||
1358 | var->xres_virtual += 16; | 1473 | var->xres_virtual += 16; |
1359 | 1474 | ||
1360 | if (var->bits_per_pixel == 16) { | 1475 | if (var->bits_per_pixel == 16) { |
1361 | var->red.offset=11; | 1476 | var->red.offset = 11; |
1362 | var->red.length=5; | 1477 | var->red.length = 5; |
1363 | var->red.msb_right=0; | 1478 | var->red.msb_right = 0; |
1364 | var->green.offset=5; | 1479 | var->green.offset = 5; |
1365 | var->green.length=6; | 1480 | var->green.length = 6; |
1366 | var->green.msb_right=0; | 1481 | var->green.msb_right = 0; |
1367 | var->blue.offset=0; | 1482 | var->blue.offset = 0; |
1368 | var->blue.length=5; | 1483 | var->blue.length = 5; |
1369 | var->blue.msb_right=0; | 1484 | var->blue.msb_right = 0; |
1370 | } | 1485 | } else { |
1371 | else { | 1486 | var->red.offset = 0; |
1372 | var->red.offset=0; | ||
1373 | var->red.length = hw->ste_mode ? 4 : 6; | 1487 | var->red.length = hw->ste_mode ? 4 : 6; |
1374 | var->red.msb_right=0; | 1488 | if (var->red.length > var->bits_per_pixel) |
1375 | var->grayscale=0; | 1489 | var->red.length = var->bits_per_pixel; |
1376 | var->blue=var->green=var->red; | 1490 | var->red.msb_right = 0; |
1491 | var->grayscale = 0; | ||
1492 | var->blue = var->green = var->red; | ||
1377 | } | 1493 | } |
1378 | var->transp.offset=0; | 1494 | var->transp.offset = 0; |
1379 | var->transp.length=0; | 1495 | var->transp.length = 0; |
1380 | var->transp.msb_right=0; | 1496 | var->transp.msb_right = 0; |
1381 | 1497 | ||
1382 | linelen = var->xres_virtual * var->bits_per_pixel / 8; | 1498 | linelen = var->xres_virtual * var->bits_per_pixel / 8; |
1383 | if (screen_len) { | 1499 | if (screen_len) { |
1384 | if (par->yres_virtual) | 1500 | if (par->yres_virtual) |
1385 | var->yres_virtual = par->yres_virtual; | 1501 | var->yres_virtual = par->yres_virtual; |
1386 | else | 1502 | else |
1387 | /* yres_virtual==0 means use maximum */ | 1503 | /* yres_virtual == 0 means use maximum */ |
1388 | var->yres_virtual = screen_len / linelen; | 1504 | var->yres_virtual = screen_len / linelen; |
1389 | } | 1505 | } else { |
1390 | else { | ||
1391 | if (hwscroll < 0) | 1506 | if (hwscroll < 0) |
1392 | var->yres_virtual = 2 * var->yres; | 1507 | var->yres_virtual = 2 * var->yres; |
1393 | else | 1508 | else |
1394 | var->yres_virtual=var->yres+hwscroll * 16; | 1509 | var->yres_virtual = var->yres + hwscroll * 16; |
1395 | } | 1510 | } |
1396 | var->xoffset=0; /* TODO change this */ | 1511 | var->xoffset = 0; /* TODO change this */ |
1397 | 1512 | ||
1398 | /* hdX-offsets */ | 1513 | /* hdX-offsets */ |
1399 | prescale = hxx_prescale(hw); | 1514 | prescale = hxx_prescale(hw); |
@@ -1402,8 +1517,7 @@ static int falcon_encode_var( struct fb_var_screeninfo *var, | |||
1402 | if (hw->f_shift & 0x100) { | 1517 | if (hw->f_shift & 0x100) { |
1403 | hde_off = 0; | 1518 | hde_off = 0; |
1404 | hdb_off = (base_off + 16 * plen) + prescale; | 1519 | hdb_off = (base_off + 16 * plen) + prescale; |
1405 | } | 1520 | } else { |
1406 | else { | ||
1407 | hde_off = ((128 / var->bits_per_pixel + 2) * plen); | 1521 | hde_off = ((128 / var->bits_per_pixel + 2) * plen); |
1408 | if (hw->ste_mode) | 1522 | if (hw->ste_mode) |
1409 | hdb_off = (64 + base_off + (128 / var->bits_per_pixel + 2) * plen) | 1523 | hdb_off = (64 + base_off + (128 / var->bits_per_pixel + 2) * plen) |
@@ -1415,8 +1529,8 @@ static int falcon_encode_var( struct fb_var_screeninfo *var, | |||
1415 | 1529 | ||
1416 | /* Right margin includes hsync */ | 1530 | /* Right margin includes hsync */ |
1417 | var->left_margin = hdb_off + prescale * ((hw->hdb & 0x1ff) - | 1531 | var->left_margin = hdb_off + prescale * ((hw->hdb & 0x1ff) - |
1418 | (hw->hdb & 0x200 ? 2+hw->hht : 0)); | 1532 | (hw->hdb & 0x200 ? 2 + hw->hht : 0)); |
1419 | if (hw->ste_mode || mon_type!=F_MON_VGA) | 1533 | if (hw->ste_mode || mon_type != F_MON_VGA) |
1420 | var->right_margin = prescale * (hw->hht + 2 - hw->hde) - hde_off; | 1534 | var->right_margin = prescale * (hw->hht + 2 - hw->hde) - hde_off; |
1421 | else | 1535 | else |
1422 | /* can't use this in ste_mode, because hbb is +1 off */ | 1536 | /* can't use this in ste_mode, because hbb is +1 off */ |
@@ -1424,15 +1538,14 @@ static int falcon_encode_var( struct fb_var_screeninfo *var, | |||
1424 | var->hsync_len = prescale * (hw->hht + 2 - hw->hss); | 1538 | var->hsync_len = prescale * (hw->hht + 2 - hw->hss); |
1425 | 1539 | ||
1426 | /* Lower margin includes vsync */ | 1540 | /* Lower margin includes vsync */ |
1427 | var->upper_margin = hw->vdb / 2 ; /* round down to full lines */ | 1541 | var->upper_margin = hw->vdb / 2; /* round down to full lines */ |
1428 | var->lower_margin = (hw->vft+1 - hw->vde + 1) / 2; /* round up */ | 1542 | var->lower_margin = (hw->vft + 1 - hw->vde + 1) / 2; /* round up */ |
1429 | var->vsync_len = (hw->vft+1 - hw->vss + 1) / 2; /* round up */ | 1543 | var->vsync_len = (hw->vft + 1 - hw->vss + 1) / 2; /* round up */ |
1430 | if (var->vmode & FB_VMODE_INTERLACED) { | 1544 | if (var->vmode & FB_VMODE_INTERLACED) { |
1431 | var->upper_margin *= 2; | 1545 | var->upper_margin *= 2; |
1432 | var->lower_margin *= 2; | 1546 | var->lower_margin *= 2; |
1433 | var->vsync_len *= 2; | 1547 | var->vsync_len *= 2; |
1434 | } | 1548 | } else if (var->vmode & FB_VMODE_DOUBLE) { |
1435 | else if (var->vmode & FB_VMODE_DOUBLE) { | ||
1436 | var->upper_margin = (var->upper_margin + 1) / 2; | 1549 | var->upper_margin = (var->upper_margin + 1) / 2; |
1437 | var->lower_margin = (var->lower_margin + 1) / 2; | 1550 | var->lower_margin = (var->lower_margin + 1) / 2; |
1438 | var->vsync_len = (var->vsync_len + 1) / 2; | 1551 | var->vsync_len = (var->vsync_len + 1) / 2; |
@@ -1447,20 +1560,19 @@ static int falcon_encode_var( struct fb_var_screeninfo *var, | |||
1447 | var->lower_margin -= var->vsync_len; | 1560 | var->lower_margin -= var->vsync_len; |
1448 | 1561 | ||
1449 | if (screen_base) | 1562 | if (screen_base) |
1450 | var->yoffset=(par->screen_base - screen_base)/linelen; | 1563 | var->yoffset = (par->screen_base - screen_base) / linelen; |
1451 | else | 1564 | else |
1452 | var->yoffset=0; | 1565 | var->yoffset = 0; |
1453 | var->nonstd=0; /* what is this for? */ | 1566 | var->nonstd = 0; /* what is this for? */ |
1454 | var->activate=0; | 1567 | var->activate = 0; |
1455 | return 0; | 1568 | return 0; |
1456 | } | 1569 | } |
1457 | 1570 | ||
1458 | 1571 | static int f_change_mode; | |
1459 | static int f_change_mode = 0; | ||
1460 | static struct falcon_hw f_new_mode; | 1572 | static struct falcon_hw f_new_mode; |
1461 | static int f_pan_display = 0; | 1573 | static int f_pan_display; |
1462 | 1574 | ||
1463 | static void falcon_get_par( struct atafb_par *par ) | 1575 | static void falcon_get_par(struct atafb_par *par) |
1464 | { | 1576 | { |
1465 | unsigned long addr; | 1577 | unsigned long addr; |
1466 | struct falcon_hw *hw = &par->hw.falcon; | 1578 | struct falcon_hw *hw = &par->hw.falcon; |
@@ -1492,12 +1604,12 @@ static void falcon_get_par( struct atafb_par *par ) | |||
1492 | par->screen_base = phys_to_virt(addr); | 1604 | par->screen_base = phys_to_virt(addr); |
1493 | 1605 | ||
1494 | /* derived parameters */ | 1606 | /* derived parameters */ |
1495 | hw->ste_mode = (hw->f_shift & 0x510)==0 && hw->st_shift==0x100; | 1607 | hw->ste_mode = (hw->f_shift & 0x510) == 0 && hw->st_shift == 0x100; |
1496 | hw->mono = (hw->f_shift & 0x400) || | 1608 | hw->mono = (hw->f_shift & 0x400) || |
1497 | ((hw->f_shift & 0x510)==0 && hw->st_shift==0x200); | 1609 | ((hw->f_shift & 0x510) == 0 && hw->st_shift == 0x200); |
1498 | } | 1610 | } |
1499 | 1611 | ||
1500 | static void falcon_set_par( struct atafb_par *par ) | 1612 | static void falcon_set_par(struct atafb_par *par) |
1501 | { | 1613 | { |
1502 | f_change_mode = 0; | 1614 | f_change_mode = 0; |
1503 | 1615 | ||
@@ -1519,8 +1631,7 @@ static void falcon_set_par( struct atafb_par *par ) | |||
1519 | f_change_mode = 1; | 1631 | f_change_mode = 1; |
1520 | } | 1632 | } |
1521 | 1633 | ||
1522 | 1634 | static irqreturn_t falcon_vbl_switcher(int irq, void *dummy) | |
1523 | static irqreturn_t falcon_vbl_switcher( int irq, void *dummy ) | ||
1524 | { | 1635 | { |
1525 | struct falcon_hw *hw = &f_new_mode; | 1636 | struct falcon_hw *hw = &f_new_mode; |
1526 | 1637 | ||
@@ -1529,11 +1640,10 @@ static irqreturn_t falcon_vbl_switcher( int irq, void *dummy ) | |||
1529 | 1640 | ||
1530 | if (hw->sync & 0x1) { | 1641 | if (hw->sync & 0x1) { |
1531 | /* Enable external pixelclock. This code only for ScreenWonder */ | 1642 | /* Enable external pixelclock. This code only for ScreenWonder */ |
1532 | *(volatile unsigned short*)0xffff9202 = 0xffbf; | 1643 | *(volatile unsigned short *)0xffff9202 = 0xffbf; |
1533 | } | 1644 | } else { |
1534 | else { | ||
1535 | /* Turn off external clocks. Read sets all output bits to 1. */ | 1645 | /* Turn off external clocks. Read sets all output bits to 1. */ |
1536 | *(volatile unsigned short*)0xffff9202; | 1646 | *(volatile unsigned short *)0xffff9202; |
1537 | } | 1647 | } |
1538 | shifter.syncmode = hw->sync; | 1648 | shifter.syncmode = hw->sync; |
1539 | 1649 | ||
@@ -1550,15 +1660,14 @@ static irqreturn_t falcon_vbl_switcher( int irq, void *dummy ) | |||
1550 | videl.vde = hw->vde; | 1660 | videl.vde = hw->vde; |
1551 | videl.vss = hw->vss; | 1661 | videl.vss = hw->vss; |
1552 | 1662 | ||
1553 | videl.f_shift = 0; /* write enables Falcon palette, 0: 4 planes */ | 1663 | videl.f_shift = 0; /* write enables Falcon palette, 0: 4 planes */ |
1554 | if (hw->ste_mode) { | 1664 | if (hw->ste_mode) { |
1555 | videl.st_shift = hw->st_shift; /* write enables STE palette */ | 1665 | videl.st_shift = hw->st_shift; /* write enables STE palette */ |
1556 | } | 1666 | } else { |
1557 | else { | ||
1558 | /* IMPORTANT: | 1667 | /* IMPORTANT: |
1559 | * set st_shift 0, so we can tell the screen-depth if f_shift==0. | 1668 | * set st_shift 0, so we can tell the screen-depth if f_shift == 0. |
1560 | * Writing 0 to f_shift enables 4 plane Falcon mode but | 1669 | * Writing 0 to f_shift enables 4 plane Falcon mode but |
1561 | * doesn't set st_shift. st_shift!=0 (!=4planes) is impossible | 1670 | * doesn't set st_shift. st_shift != 0 (!= 4planes) is impossible |
1562 | * with Falcon palette. | 1671 | * with Falcon palette. |
1563 | */ | 1672 | */ |
1564 | videl.st_shift = 0; | 1673 | videl.st_shift = 0; |
@@ -1580,12 +1689,13 @@ static irqreturn_t falcon_vbl_switcher( int irq, void *dummy ) | |||
1580 | return IRQ_HANDLED; | 1689 | return IRQ_HANDLED; |
1581 | } | 1690 | } |
1582 | 1691 | ||
1583 | 1692 | static int falcon_pan_display(struct fb_var_screeninfo *var, | |
1584 | static int falcon_pan_display( struct fb_var_screeninfo *var, | 1693 | struct fb_info *info) |
1585 | struct atafb_par *par ) | ||
1586 | { | 1694 | { |
1695 | struct atafb_par *par = (struct atafb_par *)info->par; | ||
1696 | |||
1587 | int xoffset; | 1697 | int xoffset; |
1588 | int bpp = fb_display[fb_info.currcon].var.bits_per_pixel; | 1698 | int bpp = info->var.bits_per_pixel; |
1589 | 1699 | ||
1590 | if (bpp == 1) | 1700 | if (bpp == 1) |
1591 | var->xoffset = up(var->xoffset, 32); | 1701 | var->xoffset = up(var->xoffset, 32); |
@@ -1596,45 +1706,24 @@ static int falcon_pan_display( struct fb_var_screeninfo *var, | |||
1596 | var->xoffset = up(var->xoffset, 2); | 1706 | var->xoffset = up(var->xoffset, 2); |
1597 | } | 1707 | } |
1598 | par->hw.falcon.line_offset = bpp * | 1708 | par->hw.falcon.line_offset = bpp * |
1599 | (fb_display[fb_info.currcon].var.xres_virtual - fb_display[fb_info.currcon].var.xres) / 16; | 1709 | (info->var.xres_virtual - info->var.xres) / 16; |
1600 | if (par->hw.falcon.xoffset) | 1710 | if (par->hw.falcon.xoffset) |
1601 | par->hw.falcon.line_offset -= bpp; | 1711 | par->hw.falcon.line_offset -= bpp; |
1602 | xoffset = var->xoffset - par->hw.falcon.xoffset; | 1712 | xoffset = var->xoffset - par->hw.falcon.xoffset; |
1603 | 1713 | ||
1604 | par->screen_base = screen_base + | 1714 | par->screen_base = screen_base + |
1605 | (var->yoffset * fb_display[fb_info.currcon].var.xres_virtual + xoffset) * bpp / 8; | 1715 | (var->yoffset * info->var.xres_virtual + xoffset) * bpp / 8; |
1606 | if (fbhw->set_screen_base) | 1716 | if (fbhw->set_screen_base) |
1607 | fbhw->set_screen_base (par->screen_base); | 1717 | fbhw->set_screen_base(par->screen_base); |
1608 | else | 1718 | else |
1609 | return -EINVAL; /* shouldn't happen */ | 1719 | return -EINVAL; /* shouldn't happen */ |
1610 | f_pan_display = 1; | 1720 | f_pan_display = 1; |
1611 | return 0; | 1721 | return 0; |
1612 | } | 1722 | } |
1613 | 1723 | ||
1614 | 1724 | static int falcon_setcolreg(unsigned int regno, unsigned int red, | |
1615 | static int falcon_getcolreg( unsigned regno, unsigned *red, | 1725 | unsigned int green, unsigned int blue, |
1616 | unsigned *green, unsigned *blue, | 1726 | unsigned int transp, struct fb_info *info) |
1617 | unsigned *transp, struct fb_info *info ) | ||
1618 | { unsigned long col; | ||
1619 | |||
1620 | if (regno > 255) | ||
1621 | return 1; | ||
1622 | /* This works in STE-mode (with 4bit/color) since f030_col-registers | ||
1623 | * hold up to 6bit/color. | ||
1624 | * Even with hicolor r/g/b=5/6/5 bit! | ||
1625 | */ | ||
1626 | col = f030_col[regno]; | ||
1627 | *red = (col >> 16) & 0xff00; | ||
1628 | *green = (col >> 8) & 0xff00; | ||
1629 | *blue = (col << 8) & 0xff00; | ||
1630 | *transp = 0; | ||
1631 | return 0; | ||
1632 | } | ||
1633 | |||
1634 | |||
1635 | static int falcon_setcolreg( unsigned regno, unsigned red, | ||
1636 | unsigned green, unsigned blue, | ||
1637 | unsigned transp, struct fb_info *info ) | ||
1638 | { | 1727 | { |
1639 | if (regno > 255) | 1728 | if (regno > 255) |
1640 | return 1; | 1729 | return 1; |
@@ -1655,13 +1744,12 @@ static int falcon_setcolreg( unsigned regno, unsigned red, | |||
1655 | return 0; | 1744 | return 0; |
1656 | } | 1745 | } |
1657 | 1746 | ||
1658 | 1747 | static int falcon_blank(int blank_mode) | |
1659 | static int falcon_blank( int blank_mode ) | ||
1660 | { | 1748 | { |
1661 | /* ++guenther: we can switch off graphics by changing VDB and VDE, | 1749 | /* ++guenther: we can switch off graphics by changing VDB and VDE, |
1662 | * so VIDEL doesn't hog the bus while saving. | 1750 | * so VIDEL doesn't hog the bus while saving. |
1663 | * (this may affect usleep()). | 1751 | * (this may affect usleep()). |
1664 | */ | 1752 | */ |
1665 | int vdb, vss, hbe, hss; | 1753 | int vdb, vss, hbe, hss; |
1666 | 1754 | ||
1667 | if (mon_type == F_MON_SM) /* this doesn't work on SM124 */ | 1755 | if (mon_type == F_MON_SM) /* this doesn't work on SM124 */ |
@@ -1694,14 +1782,13 @@ static int falcon_blank( int blank_mode ) | |||
1694 | return 0; | 1782 | return 0; |
1695 | } | 1783 | } |
1696 | 1784 | ||
1697 | 1785 | static int falcon_detect(void) | |
1698 | static int falcon_detect( void ) | ||
1699 | { | 1786 | { |
1700 | struct atafb_par par; | 1787 | struct atafb_par par; |
1701 | unsigned char fhw; | 1788 | unsigned char fhw; |
1702 | 1789 | ||
1703 | /* Determine connected monitor and set monitor parameters */ | 1790 | /* Determine connected monitor and set monitor parameters */ |
1704 | fhw = *(unsigned char*)0xffff8006; | 1791 | fhw = *(unsigned char *)0xffff8006; |
1705 | mon_type = fhw >> 6 & 0x3; | 1792 | mon_type = fhw >> 6 & 0x3; |
1706 | /* bit 1 of fhw: 1=32 bit ram bus, 0=16 bit */ | 1793 | /* bit 1 of fhw: 1=32 bit ram bus, 0=16 bit */ |
1707 | f030_bus_width = fhw << 6 & 0x80; | 1794 | f030_bus_width = fhw << 6 & 0x80; |
@@ -1715,7 +1802,7 @@ static int falcon_detect( void ) | |||
1715 | case F_MON_SC: | 1802 | case F_MON_SC: |
1716 | case F_MON_TV: | 1803 | case F_MON_TV: |
1717 | /* PAL...NTSC */ | 1804 | /* PAL...NTSC */ |
1718 | fb_info.monspecs.vfmin = 49; /* not 50, since TOS defaults to 49.9x Hz */ | 1805 | fb_info.monspecs.vfmin = 49; /* not 50, since TOS defaults to 49.9x Hz */ |
1719 | fb_info.monspecs.vfmax = 60; | 1806 | fb_info.monspecs.vfmax = 60; |
1720 | fb_info.monspecs.hfmin = 15620; | 1807 | fb_info.monspecs.hfmin = 15620; |
1721 | fb_info.monspecs.hfmax = 15755; | 1808 | fb_info.monspecs.hfmax = 15755; |
@@ -1740,13 +1827,12 @@ static int falcon_detect( void ) | |||
1740 | 1827 | ||
1741 | #ifdef ATAFB_STE | 1828 | #ifdef ATAFB_STE |
1742 | 1829 | ||
1743 | static int stste_encode_fix( struct fb_fix_screeninfo *fix, | 1830 | static int stste_encode_fix(struct fb_fix_screeninfo *fix, |
1744 | struct atafb_par *par ) | 1831 | struct atafb_par *par) |
1745 | |||
1746 | { | 1832 | { |
1747 | int mode; | 1833 | int mode; |
1748 | 1834 | ||
1749 | strcpy(fix->id,"Atari Builtin"); | 1835 | strcpy(fix->id, "Atari Builtin"); |
1750 | fix->smem_start = (unsigned long)real_screen_base; | 1836 | fix->smem_start = (unsigned long)real_screen_base; |
1751 | fix->smem_len = screen_len; | 1837 | fix->smem_len = screen_len; |
1752 | fix->type = FB_TYPE_INTERLEAVED_PLANES; | 1838 | fix->type = FB_TYPE_INTERLEAVED_PLANES; |
@@ -1771,43 +1857,40 @@ static int stste_encode_fix( struct fb_fix_screeninfo *fix, | |||
1771 | return 0; | 1857 | return 0; |
1772 | } | 1858 | } |
1773 | 1859 | ||
1774 | 1860 | static int stste_decode_var(struct fb_var_screeninfo *var, | |
1775 | static int stste_decode_var( struct fb_var_screeninfo *var, | 1861 | struct atafb_par *par) |
1776 | struct atafb_par *par ) | ||
1777 | { | 1862 | { |
1778 | int xres=var->xres; | 1863 | int xres = var->xres; |
1779 | int yres=var->yres; | 1864 | int yres = var->yres; |
1780 | int bpp=var->bits_per_pixel; | 1865 | int bpp = var->bits_per_pixel; |
1781 | int linelen; | 1866 | int linelen; |
1782 | int yres_virtual = var->yres_virtual; | 1867 | int yres_virtual = var->yres_virtual; |
1783 | 1868 | ||
1784 | if (mono_moni) { | 1869 | if (mono_moni) { |
1785 | if (bpp > 1 || xres > sttt_xres || yres > st_yres) | 1870 | if (bpp > 1 || xres > sttt_xres || yres > st_yres) |
1786 | return -EINVAL; | 1871 | return -EINVAL; |
1787 | par->hw.st.mode=ST_HIGH; | 1872 | par->hw.st.mode = ST_HIGH; |
1788 | xres=sttt_xres; | 1873 | xres = sttt_xres; |
1789 | yres=st_yres; | 1874 | yres = st_yres; |
1790 | bpp=1; | 1875 | bpp = 1; |
1791 | } else { | 1876 | } else { |
1792 | if (bpp > 4 || xres > sttt_xres || yres > st_yres) | 1877 | if (bpp > 4 || xres > sttt_xres || yres > st_yres) |
1793 | return -EINVAL; | 1878 | return -EINVAL; |
1794 | if (bpp > 2) { | 1879 | if (bpp > 2) { |
1795 | if (xres > sttt_xres/2 || yres > st_yres/2) | 1880 | if (xres > sttt_xres / 2 || yres > st_yres / 2) |
1796 | return -EINVAL; | 1881 | return -EINVAL; |
1797 | par->hw.st.mode=ST_LOW; | 1882 | par->hw.st.mode = ST_LOW; |
1798 | xres=sttt_xres/2; | 1883 | xres = sttt_xres / 2; |
1799 | yres=st_yres/2; | 1884 | yres = st_yres / 2; |
1800 | bpp=4; | 1885 | bpp = 4; |
1801 | } | 1886 | } else if (bpp > 1) { |
1802 | else if (bpp > 1) { | 1887 | if (xres > sttt_xres || yres > st_yres / 2) |
1803 | if (xres > sttt_xres || yres > st_yres/2) | ||
1804 | return -EINVAL; | 1888 | return -EINVAL; |
1805 | par->hw.st.mode=ST_MID; | 1889 | par->hw.st.mode = ST_MID; |
1806 | xres=sttt_xres; | 1890 | xres = sttt_xres; |
1807 | yres=st_yres/2; | 1891 | yres = st_yres / 2; |
1808 | bpp=2; | 1892 | bpp = 2; |
1809 | } | 1893 | } else |
1810 | else | ||
1811 | return -EINVAL; | 1894 | return -EINVAL; |
1812 | } | 1895 | } |
1813 | if (yres_virtual <= 0) | 1896 | if (yres_virtual <= 0) |
@@ -1815,10 +1898,10 @@ static int stste_decode_var( struct fb_var_screeninfo *var, | |||
1815 | else if (yres_virtual < yres) | 1898 | else if (yres_virtual < yres) |
1816 | yres_virtual = yres; | 1899 | yres_virtual = yres; |
1817 | if (var->sync & FB_SYNC_EXT) | 1900 | if (var->sync & FB_SYNC_EXT) |
1818 | par->hw.st.sync=(par->hw.st.sync & ~1) | 1; | 1901 | par->hw.st.sync = (par->hw.st.sync & ~1) | 1; |
1819 | else | 1902 | else |
1820 | par->hw.st.sync=(par->hw.st.sync & ~1); | 1903 | par->hw.st.sync = (par->hw.st.sync & ~1); |
1821 | linelen=xres*bpp/8; | 1904 | linelen = xres * bpp / 8; |
1822 | if (yres_virtual * linelen > screen_len && screen_len) | 1905 | if (yres_virtual * linelen > screen_len && screen_len) |
1823 | return -EINVAL; | 1906 | return -EINVAL; |
1824 | if (yres * linelen > screen_len && screen_len) | 1907 | if (yres * linelen > screen_len && screen_len) |
@@ -1826,93 +1909,91 @@ static int stste_decode_var( struct fb_var_screeninfo *var, | |||
1826 | if (var->yoffset + yres > yres_virtual && yres_virtual) | 1909 | if (var->yoffset + yres > yres_virtual && yres_virtual) |
1827 | return -EINVAL; | 1910 | return -EINVAL; |
1828 | par->yres_virtual = yres_virtual; | 1911 | par->yres_virtual = yres_virtual; |
1829 | par->screen_base=screen_base+ var->yoffset*linelen; | 1912 | par->screen_base = screen_base + var->yoffset * linelen; |
1830 | return 0; | 1913 | return 0; |
1831 | } | 1914 | } |
1832 | 1915 | ||
1833 | static int stste_encode_var( struct fb_var_screeninfo *var, | 1916 | static int stste_encode_var(struct fb_var_screeninfo *var, |
1834 | struct atafb_par *par ) | 1917 | struct atafb_par *par) |
1835 | { | 1918 | { |
1836 | int linelen; | 1919 | int linelen; |
1837 | memset(var, 0, sizeof(struct fb_var_screeninfo)); | 1920 | memset(var, 0, sizeof(struct fb_var_screeninfo)); |
1838 | var->red.offset=0; | 1921 | var->red.offset = 0; |
1839 | var->red.length = ATARIHW_PRESENT(EXTD_SHIFTER) ? 4 : 3; | 1922 | var->red.length = ATARIHW_PRESENT(EXTD_SHIFTER) ? 4 : 3; |
1840 | var->red.msb_right=0; | 1923 | var->red.msb_right = 0; |
1841 | var->grayscale=0; | 1924 | var->grayscale = 0; |
1842 | 1925 | ||
1843 | var->pixclock=31041; | 1926 | var->pixclock = 31041; |
1844 | var->left_margin=120; /* these are incorrect */ | 1927 | var->left_margin = 120; /* these are incorrect */ |
1845 | var->right_margin=100; | 1928 | var->right_margin = 100; |
1846 | var->upper_margin=8; | 1929 | var->upper_margin = 8; |
1847 | var->lower_margin=16; | 1930 | var->lower_margin = 16; |
1848 | var->hsync_len=140; | 1931 | var->hsync_len = 140; |
1849 | var->vsync_len=30; | 1932 | var->vsync_len = 30; |
1850 | 1933 | ||
1851 | var->height=-1; | 1934 | var->height = -1; |
1852 | var->width=-1; | 1935 | var->width = -1; |
1853 | 1936 | ||
1854 | if (!(par->hw.st.sync & 1)) | 1937 | if (!(par->hw.st.sync & 1)) |
1855 | var->sync=0; | 1938 | var->sync = 0; |
1856 | else | 1939 | else |
1857 | var->sync=FB_SYNC_EXT; | 1940 | var->sync = FB_SYNC_EXT; |
1858 | 1941 | ||
1859 | switch (par->hw.st.mode & 3) { | 1942 | switch (par->hw.st.mode & 3) { |
1860 | case ST_LOW: | 1943 | case ST_LOW: |
1861 | var->xres=sttt_xres/2; | 1944 | var->xres = sttt_xres / 2; |
1862 | var->yres=st_yres/2; | 1945 | var->yres = st_yres / 2; |
1863 | var->bits_per_pixel=4; | 1946 | var->bits_per_pixel = 4; |
1864 | break; | 1947 | break; |
1865 | case ST_MID: | 1948 | case ST_MID: |
1866 | var->xres=sttt_xres; | 1949 | var->xres = sttt_xres; |
1867 | var->yres=st_yres/2; | 1950 | var->yres = st_yres / 2; |
1868 | var->bits_per_pixel=2; | 1951 | var->bits_per_pixel = 2; |
1869 | break; | 1952 | break; |
1870 | case ST_HIGH: | 1953 | case ST_HIGH: |
1871 | var->xres=sttt_xres; | 1954 | var->xres = sttt_xres; |
1872 | var->yres=st_yres; | 1955 | var->yres = st_yres; |
1873 | var->bits_per_pixel=1; | 1956 | var->bits_per_pixel = 1; |
1874 | break; | 1957 | break; |
1875 | } | 1958 | } |
1876 | var->blue=var->green=var->red; | 1959 | var->blue = var->green = var->red; |
1877 | var->transp.offset=0; | 1960 | var->transp.offset = 0; |
1878 | var->transp.length=0; | 1961 | var->transp.length = 0; |
1879 | var->transp.msb_right=0; | 1962 | var->transp.msb_right = 0; |
1880 | var->xres_virtual=sttt_xres_virtual; | 1963 | var->xres_virtual = sttt_xres_virtual; |
1881 | linelen=var->xres_virtual * var->bits_per_pixel / 8; | 1964 | linelen = var->xres_virtual * var->bits_per_pixel / 8; |
1882 | ovsc_addlen=linelen*(sttt_yres_virtual - st_yres); | 1965 | ovsc_addlen = linelen * (sttt_yres_virtual - st_yres); |
1883 | 1966 | ||
1884 | if (! use_hwscroll) | 1967 | if (!use_hwscroll) |
1885 | var->yres_virtual=var->yres; | 1968 | var->yres_virtual = var->yres; |
1886 | else if (screen_len) { | 1969 | else if (screen_len) { |
1887 | if (par->yres_virtual) | 1970 | if (par->yres_virtual) |
1888 | var->yres_virtual = par->yres_virtual; | 1971 | var->yres_virtual = par->yres_virtual; |
1889 | else | 1972 | else |
1890 | /* yres_virtual==0 means use maximum */ | 1973 | /* yres_virtual == 0 means use maximum */ |
1891 | var->yres_virtual = screen_len / linelen; | 1974 | var->yres_virtual = screen_len / linelen; |
1892 | } | 1975 | } else { |
1893 | else { | ||
1894 | if (hwscroll < 0) | 1976 | if (hwscroll < 0) |
1895 | var->yres_virtual = 2 * var->yres; | 1977 | var->yres_virtual = 2 * var->yres; |
1896 | else | 1978 | else |
1897 | var->yres_virtual=var->yres+hwscroll * 16; | 1979 | var->yres_virtual = var->yres + hwscroll * 16; |
1898 | } | 1980 | } |
1899 | var->xoffset=0; | 1981 | var->xoffset = 0; |
1900 | if (screen_base) | 1982 | if (screen_base) |
1901 | var->yoffset=(par->screen_base - screen_base)/linelen; | 1983 | var->yoffset = (par->screen_base - screen_base) / linelen; |
1902 | else | 1984 | else |
1903 | var->yoffset=0; | 1985 | var->yoffset = 0; |
1904 | var->nonstd=0; | 1986 | var->nonstd = 0; |
1905 | var->activate=0; | 1987 | var->activate = 0; |
1906 | var->vmode=FB_VMODE_NONINTERLACED; | 1988 | var->vmode = FB_VMODE_NONINTERLACED; |
1907 | return 0; | 1989 | return 0; |
1908 | } | 1990 | } |
1909 | 1991 | ||
1910 | 1992 | static void stste_get_par(struct atafb_par *par) | |
1911 | static void stste_get_par( struct atafb_par *par ) | ||
1912 | { | 1993 | { |
1913 | unsigned long addr; | 1994 | unsigned long addr; |
1914 | par->hw.st.mode=shifter_tt.st_shiftmode; | 1995 | par->hw.st.mode = shifter_tt.st_shiftmode; |
1915 | par->hw.st.sync=shifter.syncmode; | 1996 | par->hw.st.sync = shifter.syncmode; |
1916 | addr = ((shifter.bas_hi & 0xff) << 16) | | 1997 | addr = ((shifter.bas_hi & 0xff) << 16) | |
1917 | ((shifter.bas_md & 0xff) << 8); | 1998 | ((shifter.bas_md & 0xff) << 8); |
1918 | if (ATARIHW_PRESENT(EXTD_SHIFTER)) | 1999 | if (ATARIHW_PRESENT(EXTD_SHIFTER)) |
@@ -1920,55 +2001,18 @@ static void stste_get_par( struct atafb_par *par ) | |||
1920 | par->screen_base = phys_to_virt(addr); | 2001 | par->screen_base = phys_to_virt(addr); |
1921 | } | 2002 | } |
1922 | 2003 | ||
1923 | static void stste_set_par( struct atafb_par *par ) | 2004 | static void stste_set_par(struct atafb_par *par) |
1924 | { | 2005 | { |
1925 | shifter_tt.st_shiftmode=par->hw.st.mode; | 2006 | shifter_tt.st_shiftmode = par->hw.st.mode; |
1926 | shifter.syncmode=par->hw.st.sync; | 2007 | shifter.syncmode = par->hw.st.sync; |
1927 | /* only set screen_base if really necessary */ | 2008 | /* only set screen_base if really necessary */ |
1928 | if (current_par.screen_base != par->screen_base) | 2009 | if (current_par.screen_base != par->screen_base) |
1929 | fbhw->set_screen_base(par->screen_base); | 2010 | fbhw->set_screen_base(par->screen_base); |
1930 | } | 2011 | } |
1931 | 2012 | ||
1932 | 2013 | static int stste_setcolreg(unsigned int regno, unsigned int red, | |
1933 | static int stste_getcolreg(unsigned regno, unsigned *red, | 2014 | unsigned int green, unsigned int blue, |
1934 | unsigned *green, unsigned *blue, | 2015 | unsigned int transp, struct fb_info *info) |
1935 | unsigned *transp, struct fb_info *info) | ||
1936 | { | ||
1937 | unsigned col, t; | ||
1938 | |||
1939 | if (regno > 15) | ||
1940 | return 1; | ||
1941 | col = shifter_tt.color_reg[regno]; | ||
1942 | if (ATARIHW_PRESENT(EXTD_SHIFTER)) { | ||
1943 | t = ((col >> 7) & 0xe) | ((col >> 11) & 1); | ||
1944 | t |= t << 4; | ||
1945 | *red = t | (t << 8); | ||
1946 | t = ((col >> 3) & 0xe) | ((col >> 7) & 1); | ||
1947 | t |= t << 4; | ||
1948 | *green = t | (t << 8); | ||
1949 | t = ((col << 1) & 0xe) | ((col >> 3) & 1); | ||
1950 | t |= t << 4; | ||
1951 | *blue = t | (t << 8); | ||
1952 | } | ||
1953 | else { | ||
1954 | t = (col >> 7) & 0xe; | ||
1955 | t |= t << 4; | ||
1956 | *red = t | (t << 8); | ||
1957 | t = (col >> 3) & 0xe; | ||
1958 | t |= t << 4; | ||
1959 | *green = t | (t << 8); | ||
1960 | t = (col << 1) & 0xe; | ||
1961 | t |= t << 4; | ||
1962 | *blue = t | (t << 8); | ||
1963 | } | ||
1964 | *transp = 0; | ||
1965 | return 0; | ||
1966 | } | ||
1967 | |||
1968 | |||
1969 | static int stste_setcolreg(unsigned regno, unsigned red, | ||
1970 | unsigned green, unsigned blue, | ||
1971 | unsigned transp, struct fb_info *info) | ||
1972 | { | 2016 | { |
1973 | if (regno > 15) | 2017 | if (regno > 15) |
1974 | return 1; | 2018 | return 1; |
@@ -1988,10 +2032,9 @@ static int stste_setcolreg(unsigned regno, unsigned red, | |||
1988 | return 0; | 2032 | return 0; |
1989 | } | 2033 | } |
1990 | 2034 | ||
1991 | 2035 | static int stste_detect(void) | |
1992 | static int stste_detect( void ) | 2036 | { |
1993 | 2037 | struct atafb_par par; | |
1994 | { struct atafb_par par; | ||
1995 | 2038 | ||
1996 | /* Determine the connected monitor: The DMA sound must be | 2039 | /* Determine the connected monitor: The DMA sound must be |
1997 | * disabled before reading the MFP GPIP, because the Sound | 2040 | * disabled before reading the MFP GPIP, because the Sound |
@@ -1999,7 +2042,7 @@ static int stste_detect( void ) | |||
1999 | */ | 2042 | */ |
2000 | if (ATARIHW_PRESENT(PCM_8BIT)) { | 2043 | if (ATARIHW_PRESENT(PCM_8BIT)) { |
2001 | tt_dmasnd.ctrl = DMASND_CTRL_OFF; | 2044 | tt_dmasnd.ctrl = DMASND_CTRL_OFF; |
2002 | udelay(20); /* wait a while for things to settle down */ | 2045 | udelay(20); /* wait a while for things to settle down */ |
2003 | } | 2046 | } |
2004 | mono_moni = (mfp.par_dt_reg & 0x80) == 0; | 2047 | mono_moni = (mfp.par_dt_reg & 0x80) == 0; |
2005 | 2048 | ||
@@ -2014,12 +2057,12 @@ static int stste_detect( void ) | |||
2014 | static void stste_set_screen_base(void *s_base) | 2057 | static void stste_set_screen_base(void *s_base) |
2015 | { | 2058 | { |
2016 | unsigned long addr; | 2059 | unsigned long addr; |
2017 | addr= virt_to_phys(s_base); | 2060 | addr = virt_to_phys(s_base); |
2018 | /* Setup Screen Memory */ | 2061 | /* Setup Screen Memory */ |
2019 | shifter.bas_hi=(unsigned char) ((addr & 0xff0000) >> 16); | 2062 | shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16); |
2020 | shifter.bas_md=(unsigned char) ((addr & 0x00ff00) >> 8); | 2063 | shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8); |
2021 | if (ATARIHW_PRESENT(EXTD_SHIFTER)) | 2064 | if (ATARIHW_PRESENT(EXTD_SHIFTER)) |
2022 | shifter.bas_lo=(unsigned char) (addr & 0x0000ff); | 2065 | shifter.bas_lo = (unsigned char)(addr & 0x0000ff); |
2023 | } | 2066 | } |
2024 | 2067 | ||
2025 | #endif /* ATAFB_STE */ | 2068 | #endif /* ATAFB_STE */ |
@@ -2045,51 +2088,49 @@ static void stste_set_screen_base(void *s_base) | |||
2045 | /* SWITCH_ACIA may be used for Falcon (ScreenBlaster III internal!) */ | 2088 | /* SWITCH_ACIA may be used for Falcon (ScreenBlaster III internal!) */ |
2046 | static void st_ovsc_switch(void) | 2089 | static void st_ovsc_switch(void) |
2047 | { | 2090 | { |
2048 | unsigned long flags; | 2091 | unsigned long flags; |
2049 | register unsigned char old, new; | 2092 | register unsigned char old, new; |
2050 | 2093 | ||
2051 | if (!(atari_switches & ATARI_SWITCH_OVSC_MASK)) | 2094 | if (!(atari_switches & ATARI_SWITCH_OVSC_MASK)) |
2052 | return; | 2095 | return; |
2053 | local_irq_save(flags); | 2096 | local_irq_save(flags); |
2054 | 2097 | ||
2055 | mfp.tim_ct_b = 0x10; | 2098 | mfp.tim_ct_b = 0x10; |
2056 | mfp.active_edge |= 8; | 2099 | mfp.active_edge |= 8; |
2057 | mfp.tim_ct_b = 0; | 2100 | mfp.tim_ct_b = 0; |
2058 | mfp.tim_dt_b = 0xf0; | 2101 | mfp.tim_dt_b = 0xf0; |
2059 | mfp.tim_ct_b = 8; | 2102 | mfp.tim_ct_b = 8; |
2060 | while (mfp.tim_dt_b > 1) /* TOS does it this way, don't ask why */ | 2103 | while (mfp.tim_dt_b > 1) /* TOS does it this way, don't ask why */ |
2061 | ; | 2104 | ; |
2062 | new = mfp.tim_dt_b; | ||
2063 | do { | ||
2064 | udelay(LINE_DELAY); | ||
2065 | old = new; | ||
2066 | new = mfp.tim_dt_b; | 2105 | new = mfp.tim_dt_b; |
2067 | } while (old != new); | 2106 | do { |
2068 | mfp.tim_ct_b = 0x10; | 2107 | udelay(LINE_DELAY); |
2069 | udelay(SYNC_DELAY); | 2108 | old = new; |
2070 | 2109 | new = mfp.tim_dt_b; | |
2071 | if (atari_switches & ATARI_SWITCH_OVSC_IKBD) | 2110 | } while (old != new); |
2072 | acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID | ACIA_RIE; | 2111 | mfp.tim_ct_b = 0x10; |
2073 | if (atari_switches & ATARI_SWITCH_OVSC_MIDI) | 2112 | udelay(SYNC_DELAY); |
2074 | acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID; | 2113 | |
2075 | if (atari_switches & (ATARI_SWITCH_OVSC_SND6|ATARI_SWITCH_OVSC_SND7)) { | 2114 | if (atari_switches & ATARI_SWITCH_OVSC_IKBD) |
2076 | sound_ym.rd_data_reg_sel = 14; | 2115 | acia.key_ctrl = ACIA_DIV64 | ACIA_D8N1S | ACIA_RHTID | ACIA_RIE; |
2077 | sound_ym.wd_data = sound_ym.rd_data_reg_sel | | 2116 | if (atari_switches & ATARI_SWITCH_OVSC_MIDI) |
2078 | ((atari_switches&ATARI_SWITCH_OVSC_SND6) ? 0x40:0) | | 2117 | acia.mid_ctrl = ACIA_DIV16 | ACIA_D8N1S | ACIA_RHTID; |
2079 | ((atari_switches&ATARI_SWITCH_OVSC_SND7) ? 0x80:0); | 2118 | if (atari_switches & (ATARI_SWITCH_OVSC_SND6|ATARI_SWITCH_OVSC_SND7)) { |
2080 | } | 2119 | sound_ym.rd_data_reg_sel = 14; |
2081 | local_irq_restore(flags); | 2120 | sound_ym.wd_data = sound_ym.rd_data_reg_sel | |
2121 | ((atari_switches & ATARI_SWITCH_OVSC_SND6) ? 0x40:0) | | ||
2122 | ((atari_switches & ATARI_SWITCH_OVSC_SND7) ? 0x80:0); | ||
2123 | } | ||
2124 | local_irq_restore(flags); | ||
2082 | } | 2125 | } |
2083 | 2126 | ||
2084 | /* ------------------- External Video ---------------------- */ | 2127 | /* ------------------- External Video ---------------------- */ |
2085 | 2128 | ||
2086 | #ifdef ATAFB_EXT | 2129 | #ifdef ATAFB_EXT |
2087 | 2130 | ||
2088 | static int ext_encode_fix( struct fb_fix_screeninfo *fix, | 2131 | static int ext_encode_fix(struct fb_fix_screeninfo *fix, struct atafb_par *par) |
2089 | struct atafb_par *par ) | ||
2090 | |||
2091 | { | 2132 | { |
2092 | strcpy(fix->id,"Unknown Extern"); | 2133 | strcpy(fix->id, "Unknown Extern"); |
2093 | fix->smem_start = (unsigned long)external_addr; | 2134 | fix->smem_start = (unsigned long)external_addr; |
2094 | fix->smem_len = PAGE_ALIGN(external_len); | 2135 | fix->smem_len = PAGE_ALIGN(external_len); |
2095 | if (external_depth == 1) { | 2136 | if (external_depth == 1) { |
@@ -2099,31 +2140,29 @@ static int ext_encode_fix( struct fb_fix_screeninfo *fix, | |||
2099 | fix->visual = | 2140 | fix->visual = |
2100 | (external_pmode == FB_TYPE_INTERLEAVED_PLANES || | 2141 | (external_pmode == FB_TYPE_INTERLEAVED_PLANES || |
2101 | external_pmode == FB_TYPE_PACKED_PIXELS) ? | 2142 | external_pmode == FB_TYPE_PACKED_PIXELS) ? |
2102 | FB_VISUAL_MONO10 : | 2143 | FB_VISUAL_MONO10 : FB_VISUAL_MONO01; |
2103 | FB_VISUAL_MONO01; | 2144 | } else { |
2104 | } | ||
2105 | else { | ||
2106 | /* Use STATIC if we don't know how to access color registers */ | 2145 | /* Use STATIC if we don't know how to access color registers */ |
2107 | int visual = external_vgaiobase ? | 2146 | int visual = external_vgaiobase ? |
2108 | FB_VISUAL_PSEUDOCOLOR : | 2147 | FB_VISUAL_PSEUDOCOLOR : |
2109 | FB_VISUAL_STATIC_PSEUDOCOLOR; | 2148 | FB_VISUAL_STATIC_PSEUDOCOLOR; |
2110 | switch (external_pmode) { | 2149 | switch (external_pmode) { |
2111 | case -1: /* truecolor */ | 2150 | case -1: /* truecolor */ |
2112 | fix->type=FB_TYPE_PACKED_PIXELS; | 2151 | fix->type = FB_TYPE_PACKED_PIXELS; |
2113 | fix->visual=FB_VISUAL_TRUECOLOR; | 2152 | fix->visual = FB_VISUAL_TRUECOLOR; |
2114 | break; | 2153 | break; |
2115 | case FB_TYPE_PACKED_PIXELS: | 2154 | case FB_TYPE_PACKED_PIXELS: |
2116 | fix->type=FB_TYPE_PACKED_PIXELS; | 2155 | fix->type = FB_TYPE_PACKED_PIXELS; |
2117 | fix->visual=visual; | 2156 | fix->visual = visual; |
2118 | break; | 2157 | break; |
2119 | case FB_TYPE_PLANES: | 2158 | case FB_TYPE_PLANES: |
2120 | fix->type=FB_TYPE_PLANES; | 2159 | fix->type = FB_TYPE_PLANES; |
2121 | fix->visual=visual; | 2160 | fix->visual = visual; |
2122 | break; | 2161 | break; |
2123 | case FB_TYPE_INTERLEAVED_PLANES: | 2162 | case FB_TYPE_INTERLEAVED_PLANES: |
2124 | fix->type=FB_TYPE_INTERLEAVED_PLANES; | 2163 | fix->type = FB_TYPE_INTERLEAVED_PLANES; |
2125 | fix->type_aux=2; | 2164 | fix->type_aux = 2; |
2126 | fix->visual=visual; | 2165 | fix->visual = visual; |
2127 | break; | 2166 | break; |
2128 | } | 2167 | } |
2129 | } | 2168 | } |
@@ -2134,137 +2173,112 @@ static int ext_encode_fix( struct fb_fix_screeninfo *fix, | |||
2134 | return 0; | 2173 | return 0; |
2135 | } | 2174 | } |
2136 | 2175 | ||
2137 | 2176 | static int ext_decode_var(struct fb_var_screeninfo *var, struct atafb_par *par) | |
2138 | static int ext_decode_var( struct fb_var_screeninfo *var, | ||
2139 | struct atafb_par *par ) | ||
2140 | { | 2177 | { |
2141 | struct fb_var_screeninfo *myvar = &atafb_predefined[0]; | 2178 | struct fb_var_screeninfo *myvar = &atafb_predefined[0]; |
2142 | 2179 | ||
2143 | if (var->bits_per_pixel > myvar->bits_per_pixel || | 2180 | if (var->bits_per_pixel > myvar->bits_per_pixel || |
2144 | var->xres > myvar->xres || | 2181 | var->xres > myvar->xres || |
2145 | var->xres_virtual > myvar->xres_virtual || | 2182 | var->xres_virtual > myvar->xres_virtual || |
2146 | var->yres > myvar->yres || | 2183 | var->yres > myvar->yres || |
2147 | var->xoffset > 0 || | 2184 | var->xoffset > 0 || |
2148 | var->yoffset > 0) | 2185 | var->yoffset > 0) |
2149 | return -EINVAL; | 2186 | return -EINVAL; |
2150 | return 0; | 2187 | return 0; |
2151 | } | 2188 | } |
2152 | 2189 | ||
2153 | 2190 | static int ext_encode_var(struct fb_var_screeninfo *var, struct atafb_par *par) | |
2154 | static int ext_encode_var( struct fb_var_screeninfo *var, | ||
2155 | struct atafb_par *par ) | ||
2156 | { | 2191 | { |
2157 | memset(var, 0, sizeof(struct fb_var_screeninfo)); | 2192 | memset(var, 0, sizeof(struct fb_var_screeninfo)); |
2158 | var->red.offset=0; | 2193 | var->red.offset = 0; |
2159 | var->red.length=(external_pmode == -1) ? external_depth/3 : | 2194 | var->red.length = (external_pmode == -1) ? external_depth / 3 : |
2160 | (external_vgaiobase ? external_bitspercol : 0); | 2195 | (external_vgaiobase ? external_bitspercol : 0); |
2161 | var->red.msb_right=0; | 2196 | var->red.msb_right = 0; |
2162 | var->grayscale=0; | 2197 | var->grayscale = 0; |
2163 | 2198 | ||
2164 | var->pixclock=31041; | 2199 | var->pixclock = 31041; |
2165 | var->left_margin=120; /* these are surely incorrect */ | 2200 | var->left_margin = 120; /* these are surely incorrect */ |
2166 | var->right_margin=100; | 2201 | var->right_margin = 100; |
2167 | var->upper_margin=8; | 2202 | var->upper_margin = 8; |
2168 | var->lower_margin=16; | 2203 | var->lower_margin = 16; |
2169 | var->hsync_len=140; | 2204 | var->hsync_len = 140; |
2170 | var->vsync_len=30; | 2205 | var->vsync_len = 30; |
2171 | 2206 | ||
2172 | var->height=-1; | 2207 | var->height = -1; |
2173 | var->width=-1; | 2208 | var->width = -1; |
2174 | 2209 | ||
2175 | var->sync=0; | 2210 | var->sync = 0; |
2176 | 2211 | ||
2177 | var->xres = external_xres; | 2212 | var->xres = external_xres; |
2178 | var->yres = external_yres; | 2213 | var->yres = external_yres; |
2179 | var->xres_virtual = external_xres_virtual; | 2214 | var->xres_virtual = external_xres_virtual; |
2180 | var->bits_per_pixel = external_depth; | 2215 | var->bits_per_pixel = external_depth; |
2181 | 2216 | ||
2182 | var->blue=var->green=var->red; | 2217 | var->blue = var->green = var->red; |
2183 | var->transp.offset=0; | 2218 | var->transp.offset = 0; |
2184 | var->transp.length=0; | 2219 | var->transp.length = 0; |
2185 | var->transp.msb_right=0; | 2220 | var->transp.msb_right = 0; |
2186 | var->yres_virtual=var->yres; | 2221 | var->yres_virtual = var->yres; |
2187 | var->xoffset=0; | 2222 | var->xoffset = 0; |
2188 | var->yoffset=0; | 2223 | var->yoffset = 0; |
2189 | var->nonstd=0; | 2224 | var->nonstd = 0; |
2190 | var->activate=0; | 2225 | var->activate = 0; |
2191 | var->vmode=FB_VMODE_NONINTERLACED; | 2226 | var->vmode = FB_VMODE_NONINTERLACED; |
2192 | return 0; | 2227 | return 0; |
2193 | } | 2228 | } |
2194 | 2229 | ||
2195 | 2230 | static void ext_get_par(struct atafb_par *par) | |
2196 | static void ext_get_par( struct atafb_par *par ) | ||
2197 | { | 2231 | { |
2198 | par->screen_base = external_addr; | 2232 | par->screen_base = external_addr; |
2199 | } | 2233 | } |
2200 | 2234 | ||
2201 | static void ext_set_par( struct atafb_par *par ) | 2235 | static void ext_set_par(struct atafb_par *par) |
2202 | { | 2236 | { |
2203 | } | 2237 | } |
2204 | 2238 | ||
2205 | #define OUTB(port,val) \ | 2239 | #define OUTB(port,val) \ |
2206 | *((unsigned volatile char *) ((port)+external_vgaiobase))=(val) | 2240 | *((unsigned volatile char *) ((port)+external_vgaiobase)) = (val) |
2207 | #define INB(port) \ | 2241 | #define INB(port) \ |
2208 | (*((unsigned volatile char *) ((port)+external_vgaiobase))) | 2242 | (*((unsigned volatile char *) ((port)+external_vgaiobase))) |
2209 | #define DACDelay \ | 2243 | #define DACDelay \ |
2210 | do { \ | 2244 | do { \ |
2211 | unsigned char tmp=INB(0x3da); \ | 2245 | unsigned char tmp = INB(0x3da); \ |
2212 | tmp=INB(0x3da); \ | 2246 | tmp = INB(0x3da); \ |
2213 | } while (0) | 2247 | } while (0) |
2214 | 2248 | ||
2215 | static int ext_getcolreg( unsigned regno, unsigned *red, | 2249 | static int ext_setcolreg(unsigned int regno, unsigned int red, |
2216 | unsigned *green, unsigned *blue, | 2250 | unsigned int green, unsigned int blue, |
2217 | unsigned *transp, struct fb_info *info ) | 2251 | unsigned int transp, struct fb_info *info) |
2218 | { | 2252 | { |
2219 | if (! external_vgaiobase) | 2253 | unsigned char colmask = (1 << external_bitspercol) - 1; |
2254 | |||
2255 | if (!external_vgaiobase) | ||
2220 | return 1; | 2256 | return 1; |
2221 | 2257 | ||
2222 | *red = ext_color[regno].red; | 2258 | switch (external_card_type) { |
2223 | *green = ext_color[regno].green; | 2259 | case IS_VGA: |
2224 | *blue = ext_color[regno].blue; | 2260 | OUTB(0x3c8, regno); |
2225 | *transp=0; | 2261 | DACDelay; |
2226 | return 0; | 2262 | OUTB(0x3c9, red & colmask); |
2227 | } | 2263 | DACDelay; |
2228 | 2264 | OUTB(0x3c9, green & colmask); | |
2229 | static int ext_setcolreg( unsigned regno, unsigned red, | 2265 | DACDelay; |
2230 | unsigned green, unsigned blue, | 2266 | OUTB(0x3c9, blue & colmask); |
2231 | unsigned transp, struct fb_info *info ) | 2267 | DACDelay; |
2268 | return 0; | ||
2232 | 2269 | ||
2233 | { unsigned char colmask = (1 << external_bitspercol) - 1; | 2270 | case IS_MV300: |
2271 | OUTB((MV300_reg[regno] << 2) + 1, red); | ||
2272 | OUTB((MV300_reg[regno] << 2) + 1, green); | ||
2273 | OUTB((MV300_reg[regno] << 2) + 1, blue); | ||
2274 | return 0; | ||
2234 | 2275 | ||
2235 | if (! external_vgaiobase) | 2276 | default: |
2236 | return 1; | 2277 | return 1; |
2237 | 2278 | } | |
2238 | ext_color[regno].red = red; | ||
2239 | ext_color[regno].green = green; | ||
2240 | ext_color[regno].blue = blue; | ||
2241 | |||
2242 | switch (external_card_type) { | ||
2243 | case IS_VGA: | ||
2244 | OUTB(0x3c8, regno); | ||
2245 | DACDelay; | ||
2246 | OUTB(0x3c9, red & colmask); | ||
2247 | DACDelay; | ||
2248 | OUTB(0x3c9, green & colmask); | ||
2249 | DACDelay; | ||
2250 | OUTB(0x3c9, blue & colmask); | ||
2251 | DACDelay; | ||
2252 | return 0; | ||
2253 | |||
2254 | case IS_MV300: | ||
2255 | OUTB((MV300_reg[regno] << 2)+1, red); | ||
2256 | OUTB((MV300_reg[regno] << 2)+1, green); | ||
2257 | OUTB((MV300_reg[regno] << 2)+1, blue); | ||
2258 | return 0; | ||
2259 | |||
2260 | default: | ||
2261 | return 1; | ||
2262 | } | ||
2263 | } | 2279 | } |
2264 | |||
2265 | |||
2266 | static int ext_detect( void ) | ||
2267 | 2280 | ||
2281 | static int ext_detect(void) | ||
2268 | { | 2282 | { |
2269 | struct fb_var_screeninfo *myvar = &atafb_predefined[0]; | 2283 | struct fb_var_screeninfo *myvar = &atafb_predefined[0]; |
2270 | struct atafb_par dummy_par; | 2284 | struct atafb_par dummy_par; |
@@ -2284,213 +2298,182 @@ static int ext_detect( void ) | |||
2284 | static void set_screen_base(void *s_base) | 2298 | static void set_screen_base(void *s_base) |
2285 | { | 2299 | { |
2286 | unsigned long addr; | 2300 | unsigned long addr; |
2287 | addr= virt_to_phys(s_base); | 2301 | |
2302 | addr = virt_to_phys(s_base); | ||
2288 | /* Setup Screen Memory */ | 2303 | /* Setup Screen Memory */ |
2289 | shifter.bas_hi=(unsigned char) ((addr & 0xff0000) >> 16); | 2304 | shifter.bas_hi = (unsigned char)((addr & 0xff0000) >> 16); |
2290 | shifter.bas_md=(unsigned char) ((addr & 0x00ff00) >> 8); | 2305 | shifter.bas_md = (unsigned char)((addr & 0x00ff00) >> 8); |
2291 | shifter.bas_lo=(unsigned char) (addr & 0x0000ff); | 2306 | shifter.bas_lo = (unsigned char)(addr & 0x0000ff); |
2292 | } | 2307 | } |
2293 | 2308 | ||
2294 | 2309 | static int pan_display(struct fb_var_screeninfo *var, struct fb_info *info) | |
2295 | static int pan_display( struct fb_var_screeninfo *var, | ||
2296 | struct atafb_par *par ) | ||
2297 | { | 2310 | { |
2311 | struct atafb_par *par = (struct atafb_par *)info->par; | ||
2312 | |||
2298 | if (!fbhw->set_screen_base || | 2313 | if (!fbhw->set_screen_base || |
2299 | (!ATARIHW_PRESENT(EXTD_SHIFTER) && var->xoffset)) | 2314 | (!ATARIHW_PRESENT(EXTD_SHIFTER) && var->xoffset)) |
2300 | return -EINVAL; | 2315 | return -EINVAL; |
2301 | var->xoffset = up(var->xoffset, 16); | 2316 | var->xoffset = up(var->xoffset, 16); |
2302 | par->screen_base = screen_base + | 2317 | par->screen_base = screen_base + |
2303 | (var->yoffset * fb_display[fb_info.currcon].var.xres_virtual + var->xoffset) | 2318 | (var->yoffset * info->var.xres_virtual + var->xoffset) |
2304 | * fb_display[fb_info.currcon].var.bits_per_pixel / 8; | 2319 | * info->var.bits_per_pixel / 8; |
2305 | fbhw->set_screen_base (par->screen_base); | 2320 | fbhw->set_screen_base(par->screen_base); |
2306 | return 0; | 2321 | return 0; |
2307 | } | 2322 | } |
2308 | 2323 | ||
2309 | |||
2310 | /* ------------ Interfaces to hardware functions ------------ */ | 2324 | /* ------------ Interfaces to hardware functions ------------ */ |
2311 | 2325 | ||
2312 | |||
2313 | #ifdef ATAFB_TT | 2326 | #ifdef ATAFB_TT |
2314 | static struct fb_hwswitch tt_switch = { | 2327 | static struct fb_hwswitch tt_switch = { |
2315 | tt_detect, tt_encode_fix, tt_decode_var, tt_encode_var, | 2328 | .detect = tt_detect, |
2316 | tt_get_par, tt_set_par, tt_getcolreg, | 2329 | .encode_fix = tt_encode_fix, |
2317 | set_screen_base, NULL, pan_display | 2330 | .decode_var = tt_decode_var, |
2331 | .encode_var = tt_encode_var, | ||
2332 | .get_par = tt_get_par, | ||
2333 | .set_par = tt_set_par, | ||
2334 | .set_screen_base = set_screen_base, | ||
2335 | .pan_display = pan_display, | ||
2318 | }; | 2336 | }; |
2319 | #endif | 2337 | #endif |
2320 | 2338 | ||
2321 | #ifdef ATAFB_FALCON | 2339 | #ifdef ATAFB_FALCON |
2322 | static struct fb_hwswitch falcon_switch = { | 2340 | static struct fb_hwswitch falcon_switch = { |
2323 | falcon_detect, falcon_encode_fix, falcon_decode_var, falcon_encode_var, | 2341 | .detect = falcon_detect, |
2324 | falcon_get_par, falcon_set_par, falcon_getcolreg, | 2342 | .encode_fix = falcon_encode_fix, |
2325 | set_screen_base, falcon_blank, falcon_pan_display | 2343 | .decode_var = falcon_decode_var, |
2344 | .encode_var = falcon_encode_var, | ||
2345 | .get_par = falcon_get_par, | ||
2346 | .set_par = falcon_set_par, | ||
2347 | .set_screen_base = set_screen_base, | ||
2348 | .blank = falcon_blank, | ||
2349 | .pan_display = falcon_pan_display, | ||
2326 | }; | 2350 | }; |
2327 | #endif | 2351 | #endif |
2328 | 2352 | ||
2329 | #ifdef ATAFB_STE | 2353 | #ifdef ATAFB_STE |
2330 | static struct fb_hwswitch st_switch = { | 2354 | static struct fb_hwswitch st_switch = { |
2331 | stste_detect, stste_encode_fix, stste_decode_var, stste_encode_var, | 2355 | .detect = stste_detect, |
2332 | stste_get_par, stste_set_par, stste_getcolreg, | 2356 | .encode_fix = stste_encode_fix, |
2333 | stste_set_screen_base, NULL, pan_display | 2357 | .decode_var = stste_decode_var, |
2358 | .encode_var = stste_encode_var, | ||
2359 | .get_par = stste_get_par, | ||
2360 | .set_par = stste_set_par, | ||
2361 | .set_screen_base = stste_set_screen_base, | ||
2362 | .pan_display = pan_display | ||
2334 | }; | 2363 | }; |
2335 | #endif | 2364 | #endif |
2336 | 2365 | ||
2337 | #ifdef ATAFB_EXT | 2366 | #ifdef ATAFB_EXT |
2338 | static struct fb_hwswitch ext_switch = { | 2367 | static struct fb_hwswitch ext_switch = { |
2339 | ext_detect, ext_encode_fix, ext_decode_var, ext_encode_var, | 2368 | .detect = ext_detect, |
2340 | ext_get_par, ext_set_par, ext_getcolreg, NULL, NULL, NULL | 2369 | .encode_fix = ext_encode_fix, |
2370 | .decode_var = ext_decode_var, | ||
2371 | .encode_var = ext_encode_var, | ||
2372 | .get_par = ext_get_par, | ||
2373 | .set_par = ext_set_par, | ||
2341 | }; | 2374 | }; |
2342 | #endif | 2375 | #endif |
2343 | 2376 | ||
2344 | 2377 | static void ata_get_par(struct atafb_par *par) | |
2345 | |||
2346 | static void atafb_get_par( struct atafb_par *par ) | ||
2347 | { | 2378 | { |
2348 | if (current_par_valid) { | 2379 | if (current_par_valid) |
2349 | *par=current_par; | 2380 | *par = current_par; |
2350 | } | ||
2351 | else | 2381 | else |
2352 | fbhw->get_par(par); | 2382 | fbhw->get_par(par); |
2353 | } | 2383 | } |
2354 | 2384 | ||
2355 | 2385 | static void ata_set_par(struct atafb_par *par) | |
2356 | static void atafb_set_par( struct atafb_par *par ) | ||
2357 | { | 2386 | { |
2358 | fbhw->set_par(par); | 2387 | fbhw->set_par(par); |
2359 | current_par=*par; | 2388 | current_par = *par; |
2360 | current_par_valid=1; | 2389 | current_par_valid = 1; |
2361 | } | 2390 | } |
2362 | 2391 | ||
2363 | 2392 | ||
2364 | |||
2365 | /* =========================================================== */ | 2393 | /* =========================================================== */ |
2366 | /* ============== Hardware Independent Functions ============= */ | 2394 | /* ============== Hardware Independent Functions ============= */ |
2367 | /* =========================================================== */ | 2395 | /* =========================================================== */ |
2368 | 2396 | ||
2369 | |||
2370 | /* used for hardware scrolling */ | 2397 | /* used for hardware scrolling */ |
2371 | 2398 | ||
2372 | static int | 2399 | static int do_fb_set_var(struct fb_var_screeninfo *var, int isactive) |
2373 | fb_update_var(int con, struct fb_info *info) | ||
2374 | { | ||
2375 | int off=fb_display[con].var.yoffset*fb_display[con].var.xres_virtual* | ||
2376 | fb_display[con].var.bits_per_pixel>>3; | ||
2377 | |||
2378 | current_par.screen_base=screen_base + off; | ||
2379 | |||
2380 | if (fbhw->set_screen_base) | ||
2381 | fbhw->set_screen_base(current_par.screen_base); | ||
2382 | return 0; | ||
2383 | } | ||
2384 | |||
2385 | static int | ||
2386 | do_fb_set_var(struct fb_var_screeninfo *var, int isactive) | ||
2387 | { | 2400 | { |
2388 | int err,activate; | 2401 | int err, activate; |
2389 | struct atafb_par par; | 2402 | struct atafb_par par; |
2390 | if ((err=fbhw->decode_var(var, &par))) | 2403 | |
2404 | err = fbhw->decode_var(var, &par); | ||
2405 | if (err) | ||
2391 | return err; | 2406 | return err; |
2392 | activate=var->activate; | 2407 | activate = var->activate; |
2393 | if (((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) && isactive) | 2408 | if (((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) && isactive) |
2394 | atafb_set_par(&par); | 2409 | ata_set_par(&par); |
2395 | fbhw->encode_var(var, &par); | 2410 | fbhw->encode_var(var, &par); |
2396 | var->activate=activate; | 2411 | var->activate = activate; |
2397 | return 0; | 2412 | return 0; |
2398 | } | 2413 | } |
2399 | 2414 | ||
2400 | static int | 2415 | static int atafb_get_fix(struct fb_fix_screeninfo *fix, struct fb_info *info) |
2401 | atafb_get_fix(struct fb_fix_screeninfo *fix, int con, struct fb_info *info) | ||
2402 | { | 2416 | { |
2403 | struct atafb_par par; | 2417 | struct atafb_par par; |
2404 | if (con == -1) | 2418 | int err; |
2405 | atafb_get_par(&par); | 2419 | // Get fix directly (case con == -1 before)?? |
2406 | else { | 2420 | err = fbhw->decode_var(&info->var, &par); |
2407 | int err; | 2421 | if (err) |
2408 | if ((err=fbhw->decode_var(&fb_display[con].var,&par))) | 2422 | return err; |
2409 | return err; | ||
2410 | } | ||
2411 | memset(fix, 0, sizeof(struct fb_fix_screeninfo)); | 2423 | memset(fix, 0, sizeof(struct fb_fix_screeninfo)); |
2412 | return fbhw->encode_fix(fix, &par); | 2424 | return fbhw->encode_fix(fix, &par); |
2413 | } | 2425 | } |
2414 | 2426 | ||
2415 | static int | 2427 | static int atafb_get_var(struct fb_var_screeninfo *var, struct fb_info *info) |
2416 | atafb_get_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) | ||
2417 | { | 2428 | { |
2418 | struct atafb_par par; | 2429 | struct atafb_par par; |
2419 | if (con == -1) { | 2430 | |
2420 | atafb_get_par(&par); | 2431 | ata_get_par(&par); |
2421 | fbhw->encode_var(var, &par); | 2432 | fbhw->encode_var(var, &par); |
2422 | } | 2433 | |
2423 | else | ||
2424 | *var=fb_display[con].var; | ||
2425 | return 0; | 2434 | return 0; |
2426 | } | 2435 | } |
2427 | 2436 | ||
2428 | static void | 2437 | // No longer called by fbcon! |
2429 | atafb_set_disp(int con, struct fb_info *info) | 2438 | // Still called by set_var internally |
2439 | |||
2440 | static void atafb_set_disp(struct fb_info *info) | ||
2430 | { | 2441 | { |
2431 | struct fb_fix_screeninfo fix; | 2442 | atafb_get_var(&info->var, info); |
2432 | struct fb_var_screeninfo var; | 2443 | atafb_get_fix(&info->fix, info); |
2433 | struct display *display; | ||
2434 | 2444 | ||
2435 | if (con >= 0) | 2445 | info->screen_base = (void *)info->fix.smem_start; |
2436 | display = &fb_display[con]; | 2446 | |
2437 | else | 2447 | switch (info->fix.type) { |
2438 | display = &disp; /* used during initialization */ | 2448 | case FB_TYPE_INTERLEAVED_PLANES: |
2439 | 2449 | switch (info->var.bits_per_pixel) { | |
2440 | atafb_get_fix(&fix, con, info); | 2450 | case 2: |
2441 | atafb_get_var(&var, con, info); | 2451 | // display->dispsw = &fbcon_iplan2p2; |
2442 | if (con == -1) | ||
2443 | con=0; | ||
2444 | info->screen_base = (void *)fix.smem_start; | ||
2445 | display->visual = fix.visual; | ||
2446 | display->type = fix.type; | ||
2447 | display->type_aux = fix.type_aux; | ||
2448 | display->ypanstep = fix.ypanstep; | ||
2449 | display->ywrapstep = fix.ywrapstep; | ||
2450 | display->line_length = fix.line_length; | ||
2451 | if (fix.visual != FB_VISUAL_PSEUDOCOLOR && | ||
2452 | fix.visual != FB_VISUAL_DIRECTCOLOR) | ||
2453 | display->can_soft_blank = 0; | ||
2454 | else | ||
2455 | display->can_soft_blank = 1; | ||
2456 | display->inverse = | ||
2457 | (fix.visual == FB_VISUAL_MONO01 ? !inverse : inverse); | ||
2458 | switch (fix.type) { | ||
2459 | case FB_TYPE_INTERLEAVED_PLANES: | ||
2460 | switch (var.bits_per_pixel) { | ||
2461 | #ifdef FBCON_HAS_IPLAN2P2 | ||
2462 | case 2: | ||
2463 | display->dispsw = &fbcon_iplan2p2; | ||
2464 | break; | 2452 | break; |
2465 | #endif | 2453 | case 4: |
2466 | #ifdef FBCON_HAS_IPLAN2P4 | 2454 | // display->dispsw = &fbcon_iplan2p4; |
2467 | case 4: | ||
2468 | display->dispsw = &fbcon_iplan2p4; | ||
2469 | break; | 2455 | break; |
2470 | #endif | 2456 | case 8: |
2471 | #ifdef FBCON_HAS_IPLAN2P8 | 2457 | // display->dispsw = &fbcon_iplan2p8; |
2472 | case 8: | ||
2473 | display->dispsw = &fbcon_iplan2p8; | ||
2474 | break; | 2458 | break; |
2475 | #endif | ||
2476 | } | 2459 | } |
2477 | break; | 2460 | break; |
2478 | case FB_TYPE_PACKED_PIXELS: | 2461 | case FB_TYPE_PACKED_PIXELS: |
2479 | switch (var.bits_per_pixel) { | 2462 | switch (info->var.bits_per_pixel) { |
2480 | #ifdef FBCON_HAS_MFB | 2463 | #ifdef FBCON_HAS_MFB |
2481 | case 1: | 2464 | case 1: |
2482 | display->dispsw = &fbcon_mfb; | 2465 | // display->dispsw = &fbcon_mfb; |
2483 | break; | 2466 | break; |
2484 | #endif | 2467 | #endif |
2485 | #ifdef FBCON_HAS_CFB8 | 2468 | #ifdef FBCON_HAS_CFB8 |
2486 | case 8: | 2469 | case 8: |
2487 | display->dispsw = &fbcon_cfb8; | 2470 | // display->dispsw = &fbcon_cfb8; |
2488 | break; | 2471 | break; |
2489 | #endif | 2472 | #endif |
2490 | #ifdef FBCON_HAS_CFB16 | 2473 | #ifdef FBCON_HAS_CFB16 |
2491 | case 16: | 2474 | case 16: |
2492 | display->dispsw = &fbcon_cfb16; | 2475 | // display->dispsw = &fbcon_cfb16; |
2493 | display->dispsw_data = fbcon_cfb16_cmap; | 2476 | // display->dispsw_data = fbcon_cfb16_cmap; |
2494 | break; | 2477 | break; |
2495 | #endif | 2478 | #endif |
2496 | } | 2479 | } |
@@ -2498,74 +2481,203 @@ atafb_set_disp(int con, struct fb_info *info) | |||
2498 | } | 2481 | } |
2499 | } | 2482 | } |
2500 | 2483 | ||
2484 | static int atafb_setcolreg(u_int regno, u_int red, u_int green, u_int blue, | ||
2485 | u_int transp, struct fb_info *info) | ||
2486 | { | ||
2487 | red >>= 8; | ||
2488 | green >>= 8; | ||
2489 | blue >>= 8; | ||
2490 | |||
2491 | return info->fbops->fb_setcolreg(regno, red, green, blue, transp, info); | ||
2492 | } | ||
2493 | |||
2501 | static int | 2494 | static int |
2502 | atafb_set_var(struct fb_var_screeninfo *var, int con, struct fb_info *info) | 2495 | atafb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) |
2503 | { | 2496 | { |
2504 | int err,oldxres,oldyres,oldbpp,oldxres_virtual, | 2497 | int xoffset = var->xoffset; |
2505 | oldyres_virtual,oldyoffset; | 2498 | int yoffset = var->yoffset; |
2506 | if ((err=do_fb_set_var(var, con==info->currcon))) | 2499 | int err; |
2507 | return err; | 2500 | |
2508 | if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) { | 2501 | if (var->vmode & FB_VMODE_YWRAP) { |
2509 | oldxres=fb_display[con].var.xres; | 2502 | if (yoffset < 0 || yoffset >= info->var.yres_virtual || xoffset) |
2510 | oldyres=fb_display[con].var.yres; | 2503 | return -EINVAL; |
2511 | oldxres_virtual=fb_display[con].var.xres_virtual; | 2504 | } else { |
2512 | oldyres_virtual=fb_display[con].var.yres_virtual; | 2505 | if (xoffset + info->var.xres > info->var.xres_virtual || |
2513 | oldbpp=fb_display[con].var.bits_per_pixel; | 2506 | yoffset + info->var.yres > info->var.yres_virtual) |
2514 | oldyoffset=fb_display[con].var.yoffset; | 2507 | return -EINVAL; |
2515 | fb_display[con].var=*var; | ||
2516 | if (oldxres != var->xres || oldyres != var->yres | ||
2517 | || oldxres_virtual != var->xres_virtual | ||
2518 | || oldyres_virtual != var->yres_virtual | ||
2519 | || oldbpp != var->bits_per_pixel | ||
2520 | || oldyoffset != var->yoffset) { | ||
2521 | atafb_set_disp(con, info); | ||
2522 | (*fb_info.changevar)(con); | ||
2523 | fb_alloc_cmap(&fb_display[con].cmap, 0, 0); | ||
2524 | do_install_cmap(con, info); | ||
2525 | } | ||
2526 | } | 2508 | } |
2527 | var->activate=0; | 2509 | |
2510 | if (fbhw->pan_display) { | ||
2511 | err = fbhw->pan_display(var, info); | ||
2512 | if (err) | ||
2513 | return err; | ||
2514 | } else | ||
2515 | return -EINVAL; | ||
2516 | |||
2517 | info->var.xoffset = xoffset; | ||
2518 | info->var.yoffset = yoffset; | ||
2519 | |||
2520 | if (var->vmode & FB_VMODE_YWRAP) | ||
2521 | info->var.vmode |= FB_VMODE_YWRAP; | ||
2522 | else | ||
2523 | info->var.vmode &= ~FB_VMODE_YWRAP; | ||
2524 | |||
2528 | return 0; | 2525 | return 0; |
2529 | } | 2526 | } |
2530 | 2527 | ||
2528 | /* | ||
2529 | * generic drawing routines; imageblit needs updating for image depth > 1 | ||
2530 | */ | ||
2531 | 2531 | ||
2532 | #if BITS_PER_LONG == 32 | ||
2533 | #define BYTES_PER_LONG 4 | ||
2534 | #define SHIFT_PER_LONG 5 | ||
2535 | #elif BITS_PER_LONG == 64 | ||
2536 | #define BYTES_PER_LONG 8 | ||
2537 | #define SHIFT_PER_LONG 6 | ||
2538 | #else | ||
2539 | #define Please update me | ||
2540 | #endif | ||
2532 | 2541 | ||
2533 | static int | 2542 | |
2534 | atafb_get_cmap(struct fb_cmap *cmap, int kspc, int con, struct fb_info *info) | 2543 | static void atafb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) |
2535 | { | 2544 | { |
2536 | if (con == info->currcon) /* current console ? */ | 2545 | struct atafb_par *par = (struct atafb_par *)info->par; |
2537 | return fb_get_cmap(cmap, kspc, fbhw->getcolreg, info); | 2546 | int x2, y2; |
2547 | u32 width, height; | ||
2548 | |||
2549 | if (!rect->width || !rect->height) | ||
2550 | return; | ||
2551 | |||
2552 | /* | ||
2553 | * We could use hardware clipping but on many cards you get around | ||
2554 | * hardware clipping by writing to framebuffer directly. | ||
2555 | * */ | ||
2556 | x2 = rect->dx + rect->width; | ||
2557 | y2 = rect->dy + rect->height; | ||
2558 | x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; | ||
2559 | y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; | ||
2560 | width = x2 - rect->dx; | ||
2561 | height = y2 - rect->dy; | ||
2562 | |||
2563 | if (info->var.bits_per_pixel == 1) | ||
2564 | atafb_mfb_fillrect(info, par->next_line, rect->color, | ||
2565 | rect->dy, rect->dx, height, width); | ||
2566 | else if (info->var.bits_per_pixel == 2) | ||
2567 | atafb_iplan2p2_fillrect(info, par->next_line, rect->color, | ||
2568 | rect->dy, rect->dx, height, width); | ||
2569 | else if (info->var.bits_per_pixel == 4) | ||
2570 | atafb_iplan2p4_fillrect(info, par->next_line, rect->color, | ||
2571 | rect->dy, rect->dx, height, width); | ||
2538 | else | 2572 | else |
2539 | if (fb_display[con].cmap.len) /* non default colormap ? */ | 2573 | atafb_iplan2p8_fillrect(info, par->next_line, rect->color, |
2540 | fb_copy_cmap(&fb_display[con].cmap, cmap, kspc ? 0 : 2); | 2574 | rect->dy, rect->dx, height, width); |
2541 | else | 2575 | |
2542 | fb_copy_cmap(fb_default_cmap(1<<fb_display[con].var.bits_per_pixel), | 2576 | return; |
2543 | cmap, kspc ? 0 : 2); | ||
2544 | return 0; | ||
2545 | } | 2577 | } |
2546 | 2578 | ||
2547 | static int | 2579 | static void atafb_copyarea(struct fb_info *info, const struct fb_copyarea *area) |
2548 | atafb_pan_display(struct fb_var_screeninfo *var, int con, struct fb_info *info) | ||
2549 | { | 2580 | { |
2550 | int xoffset = var->xoffset; | 2581 | struct atafb_par *par = (struct atafb_par *)info->par; |
2551 | int yoffset = var->yoffset; | 2582 | int x2, y2; |
2552 | int err; | 2583 | u32 dx, dy, sx, sy, width, height; |
2584 | int rev_copy = 0; | ||
2585 | |||
2586 | /* clip the destination */ | ||
2587 | x2 = area->dx + area->width; | ||
2588 | y2 = area->dy + area->height; | ||
2589 | dx = area->dx > 0 ? area->dx : 0; | ||
2590 | dy = area->dy > 0 ? area->dy : 0; | ||
2591 | x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; | ||
2592 | y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; | ||
2593 | width = x2 - dx; | ||
2594 | height = y2 - dy; | ||
2595 | |||
2596 | /* update sx,sy */ | ||
2597 | sx = area->sx + (dx - area->dx); | ||
2598 | sy = area->sy + (dy - area->dy); | ||
2599 | |||
2600 | /* the source must be completely inside the virtual screen */ | ||
2601 | if (sx < 0 || sy < 0 || (sx + width) > info->var.xres_virtual || | ||
2602 | (sy + height) > info->var.yres_virtual) | ||
2603 | return; | ||
2553 | 2604 | ||
2554 | if ( xoffset < 0 || xoffset + fb_display[con].var.xres > fb_display[con].var.xres_virtual | 2605 | if (dy > sy || (dy == sy && dx > sx)) { |
2555 | || yoffset < 0 || yoffset + fb_display[con].var.yres > fb_display[con].var.yres_virtual) | 2606 | dy += height; |
2556 | return -EINVAL; | 2607 | sy += height; |
2608 | rev_copy = 1; | ||
2609 | } | ||
2610 | |||
2611 | if (info->var.bits_per_pixel == 1) | ||
2612 | atafb_mfb_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); | ||
2613 | else if (info->var.bits_per_pixel == 2) | ||
2614 | atafb_iplan2p2_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); | ||
2615 | else if (info->var.bits_per_pixel == 4) | ||
2616 | atafb_iplan2p4_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); | ||
2617 | else | ||
2618 | atafb_iplan2p8_copyarea(info, par->next_line, sy, sx, dy, dx, height, width); | ||
2557 | 2619 | ||
2558 | if (con == info->currcon) { | 2620 | return; |
2559 | if (fbhw->pan_display) { | 2621 | } |
2560 | if ((err = fbhw->pan_display(var, ¤t_par))) | 2622 | |
2561 | return err; | 2623 | static void atafb_imageblit(struct fb_info *info, const struct fb_image *image) |
2624 | { | ||
2625 | struct atafb_par *par = (struct atafb_par *)info->par; | ||
2626 | int x2, y2; | ||
2627 | unsigned long *dst; | ||
2628 | int dst_idx; | ||
2629 | const char *src; | ||
2630 | u32 dx, dy, width, height, pitch; | ||
2631 | |||
2632 | /* | ||
2633 | * We could use hardware clipping but on many cards you get around | ||
2634 | * hardware clipping by writing to framebuffer directly like we are | ||
2635 | * doing here. | ||
2636 | */ | ||
2637 | x2 = image->dx + image->width; | ||
2638 | y2 = image->dy + image->height; | ||
2639 | dx = image->dx; | ||
2640 | dy = image->dy; | ||
2641 | x2 = x2 < info->var.xres_virtual ? x2 : info->var.xres_virtual; | ||
2642 | y2 = y2 < info->var.yres_virtual ? y2 : info->var.yres_virtual; | ||
2643 | width = x2 - dx; | ||
2644 | height = y2 - dy; | ||
2645 | |||
2646 | if (image->depth == 1) { | ||
2647 | // used for font data | ||
2648 | dst = (unsigned long *) | ||
2649 | ((unsigned long)info->screen_base & ~(BYTES_PER_LONG - 1)); | ||
2650 | dst_idx = ((unsigned long)info->screen_base & (BYTES_PER_LONG - 1)) * 8; | ||
2651 | dst_idx += dy * par->next_line * 8 + dx; | ||
2652 | src = image->data; | ||
2653 | pitch = (image->width + 7) / 8; | ||
2654 | while (height--) { | ||
2655 | |||
2656 | if (info->var.bits_per_pixel == 1) | ||
2657 | atafb_mfb_linefill(info, par->next_line, | ||
2658 | dy, dx, width, src, | ||
2659 | image->bg_color, image->fg_color); | ||
2660 | else if (info->var.bits_per_pixel == 2) | ||
2661 | atafb_iplan2p2_linefill(info, par->next_line, | ||
2662 | dy, dx, width, src, | ||
2663 | image->bg_color, image->fg_color); | ||
2664 | else if (info->var.bits_per_pixel == 4) | ||
2665 | atafb_iplan2p4_linefill(info, par->next_line, | ||
2666 | dy, dx, width, src, | ||
2667 | image->bg_color, image->fg_color); | ||
2668 | else | ||
2669 | atafb_iplan2p8_linefill(info, par->next_line, | ||
2670 | dy, dx, width, src, | ||
2671 | image->bg_color, image->fg_color); | ||
2672 | dy++; | ||
2673 | src += pitch; | ||
2562 | } | 2674 | } |
2563 | else | 2675 | } else { |
2564 | return -EINVAL; | 2676 | // only used for logo; broken |
2677 | c2p(info->screen_base, image->data, dx, dy, width, height, | ||
2678 | par->next_line, par->next_plane, image->width, | ||
2679 | info->var.bits_per_pixel); | ||
2565 | } | 2680 | } |
2566 | fb_display[con].var.xoffset = var->xoffset; | ||
2567 | fb_display[con].var.yoffset = var->yoffset; | ||
2568 | return 0; | ||
2569 | } | 2681 | } |
2570 | 2682 | ||
2571 | static int | 2683 | static int |
@@ -2584,7 +2696,7 @@ atafb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) | |||
2584 | if (copy_from_user((void *)¤t_par, (void *)arg, | 2696 | if (copy_from_user((void *)¤t_par, (void *)arg, |
2585 | sizeof(struct atafb_par))) | 2697 | sizeof(struct atafb_par))) |
2586 | return -EFAULT; | 2698 | return -EFAULT; |
2587 | atafb_set_par(¤t_par); | 2699 | ata_set_par(¤t_par); |
2588 | return 0; | 2700 | return 0; |
2589 | #endif | 2701 | #endif |
2590 | } | 2702 | } |
@@ -2598,42 +2710,82 @@ atafb_ioctl(struct fb_info *info, unsigned int cmd, unsigned long arg) | |||
2598 | * 3 = suspend hsync | 2710 | * 3 = suspend hsync |
2599 | * 4 = off | 2711 | * 4 = off |
2600 | */ | 2712 | */ |
2601 | static int | 2713 | static int atafb_blank(int blank, struct fb_info *info) |
2602 | atafb_blank(int blank, struct fb_info *info) | ||
2603 | { | 2714 | { |
2604 | unsigned short black[16]; | 2715 | unsigned short black[16]; |
2605 | struct fb_cmap cmap; | 2716 | struct fb_cmap cmap; |
2606 | if (fbhw->blank && !fbhw->blank(blank)) | 2717 | if (fbhw->blank && !fbhw->blank(blank)) |
2607 | return 1; | 2718 | return 1; |
2608 | if (blank) { | 2719 | if (blank) { |
2609 | memset(black, 0, 16*sizeof(unsigned short)); | 2720 | memset(black, 0, 16 * sizeof(unsigned short)); |
2610 | cmap.red=black; | 2721 | cmap.red = black; |
2611 | cmap.green=black; | 2722 | cmap.green = black; |
2612 | cmap.blue=black; | 2723 | cmap.blue = black; |
2613 | cmap.transp=NULL; | 2724 | cmap.transp = NULL; |
2614 | cmap.start=0; | 2725 | cmap.start = 0; |
2615 | cmap.len=16; | 2726 | cmap.len = 16; |
2616 | fb_set_cmap(&cmap, 1, info); | 2727 | fb_set_cmap(&cmap, info); |
2617 | } | 2728 | } |
2729 | #if 0 | ||
2618 | else | 2730 | else |
2619 | do_install_cmap(info->currcon, info); | 2731 | do_install_cmap(info); |
2732 | #endif | ||
2733 | return 0; | ||
2734 | } | ||
2735 | |||
2736 | /* | ||
2737 | * New fbcon interface ... | ||
2738 | */ | ||
2739 | |||
2740 | /* check var by decoding var into hw par, rounding if necessary, | ||
2741 | * then encoding hw par back into new, validated var */ | ||
2742 | static int atafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) | ||
2743 | { | ||
2744 | int err; | ||
2745 | struct atafb_par par; | ||
2746 | |||
2747 | /* Validate wanted screen parameters */ | ||
2748 | // if ((err = ata_decode_var(var, &par))) | ||
2749 | err = fbhw->decode_var(var, &par); | ||
2750 | if (err) | ||
2751 | return err; | ||
2752 | |||
2753 | /* Encode (possibly rounded) screen parameters */ | ||
2754 | fbhw->encode_var(var, &par); | ||
2755 | return 0; | ||
2756 | } | ||
2757 | |||
2758 | /* actually set hw par by decoding var, then setting hardware from | ||
2759 | * hw par just decoded */ | ||
2760 | static int atafb_set_par(struct fb_info *info) | ||
2761 | { | ||
2762 | struct atafb_par *par = (struct atafb_par *)info->par; | ||
2763 | |||
2764 | /* Decode wanted screen parameters */ | ||
2765 | fbhw->decode_var(&info->var, par); | ||
2766 | fbhw->encode_fix(&info->fix, par); | ||
2767 | |||
2768 | /* Set new videomode */ | ||
2769 | ata_set_par(par); | ||
2770 | |||
2620 | return 0; | 2771 | return 0; |
2621 | } | 2772 | } |
2622 | 2773 | ||
2774 | |||
2623 | static struct fb_ops atafb_ops = { | 2775 | static struct fb_ops atafb_ops = { |
2624 | .owner = THIS_MODULE, | 2776 | .owner = THIS_MODULE, |
2625 | .fb_get_fix = atafb_get_fix, | 2777 | .fb_check_var = atafb_check_var, |
2626 | .fb_get_var = atafb_get_var, | 2778 | .fb_set_par = atafb_set_par, |
2627 | .fb_set_var = atafb_set_var, | 2779 | .fb_setcolreg = atafb_setcolreg, |
2628 | .fb_get_cmap = atafb_get_cmap, | ||
2629 | .fb_set_cmap = gen_set_cmap, | ||
2630 | .fb_pan_display =atafb_pan_display, | ||
2631 | .fb_blank = atafb_blank, | 2780 | .fb_blank = atafb_blank, |
2781 | .fb_pan_display = atafb_pan_display, | ||
2782 | .fb_fillrect = atafb_fillrect, | ||
2783 | .fb_copyarea = atafb_copyarea, | ||
2784 | .fb_imageblit = atafb_imageblit, | ||
2632 | .fb_ioctl = atafb_ioctl, | 2785 | .fb_ioctl = atafb_ioctl, |
2633 | }; | 2786 | }; |
2634 | 2787 | ||
2635 | static void | 2788 | static void check_default_par(int detected_mode) |
2636 | check_default_par( int detected_mode ) | ||
2637 | { | 2789 | { |
2638 | char default_name[10]; | 2790 | char default_name[10]; |
2639 | int i; | 2791 | int i; |
@@ -2642,199 +2794,41 @@ check_default_par( int detected_mode ) | |||
2642 | 2794 | ||
2643 | /* First try the user supplied mode */ | 2795 | /* First try the user supplied mode */ |
2644 | if (default_par) { | 2796 | if (default_par) { |
2645 | var=atafb_predefined[default_par-1]; | 2797 | var = atafb_predefined[default_par - 1]; |
2646 | var.activate = FB_ACTIVATE_TEST; | 2798 | var.activate = FB_ACTIVATE_TEST; |
2647 | if (do_fb_set_var(&var,1)) | 2799 | if (do_fb_set_var(&var, 1)) |
2648 | default_par=0; /* failed */ | 2800 | default_par = 0; /* failed */ |
2649 | } | 2801 | } |
2650 | /* Next is the autodetected one */ | 2802 | /* Next is the autodetected one */ |
2651 | if (! default_par) { | 2803 | if (!default_par) { |
2652 | var=atafb_predefined[detected_mode-1]; /* autodetect */ | 2804 | var = atafb_predefined[detected_mode - 1]; /* autodetect */ |
2653 | var.activate = FB_ACTIVATE_TEST; | 2805 | var.activate = FB_ACTIVATE_TEST; |
2654 | if (!do_fb_set_var(&var,1)) | 2806 | if (!do_fb_set_var(&var, 1)) |
2655 | default_par=detected_mode; | 2807 | default_par = detected_mode; |
2656 | } | 2808 | } |
2657 | /* If that also failed, try some default modes... */ | 2809 | /* If that also failed, try some default modes... */ |
2658 | if (! default_par) { | 2810 | if (!default_par) { |
2659 | /* try default1, default2... */ | 2811 | /* try default1, default2... */ |
2660 | for (i=1 ; i < 10 ; i++) { | 2812 | for (i = 1; i < 10; i++) { |
2661 | sprintf(default_name,"default%d",i); | 2813 | sprintf(default_name,"default%d", i); |
2662 | default_par=get_video_mode(default_name); | 2814 | default_par = get_video_mode(default_name); |
2663 | if (! default_par) | 2815 | if (!default_par) |
2664 | panic("can't set default video mode"); | 2816 | panic("can't set default video mode"); |
2665 | var=atafb_predefined[default_par-1]; | 2817 | var = atafb_predefined[default_par - 1]; |
2666 | var.activate = FB_ACTIVATE_TEST; | 2818 | var.activate = FB_ACTIVATE_TEST; |
2667 | if (! do_fb_set_var(&var,1)) | 2819 | if (!do_fb_set_var(&var,1)) |
2668 | break; /* ok */ | 2820 | break; /* ok */ |
2669 | } | 2821 | } |
2670 | } | 2822 | } |
2671 | min_mem=var.xres_virtual * var.yres_virtual * var.bits_per_pixel/8; | 2823 | min_mem = var.xres_virtual * var.yres_virtual * var.bits_per_pixel / 8; |
2672 | if (default_mem_req < min_mem) | 2824 | if (default_mem_req < min_mem) |
2673 | default_mem_req=min_mem; | 2825 | default_mem_req = min_mem; |
2674 | } | ||
2675 | |||
2676 | static int | ||
2677 | atafb_switch(int con, struct fb_info *info) | ||
2678 | { | ||
2679 | /* Do we have to save the colormap ? */ | ||
2680 | if (fb_display[info->currcon].cmap.len) | ||
2681 | fb_get_cmap(&fb_display[info->currcon].cmap, 1, fbhw->getcolreg, | ||
2682 | info); | ||
2683 | do_fb_set_var(&fb_display[con].var,1); | ||
2684 | info->currcon=con; | ||
2685 | /* Install new colormap */ | ||
2686 | do_install_cmap(con, info); | ||
2687 | return 0; | ||
2688 | } | ||
2689 | |||
2690 | int __init atafb_init(void) | ||
2691 | { | ||
2692 | int pad; | ||
2693 | int detected_mode; | ||
2694 | unsigned long mem_req; | ||
2695 | |||
2696 | if (!MACH_IS_ATARI) | ||
2697 | return -ENXIO; | ||
2698 | |||
2699 | do { | ||
2700 | #ifdef ATAFB_EXT | ||
2701 | if (external_addr) { | ||
2702 | fbhw = &ext_switch; | ||
2703 | atafb_ops.fb_setcolreg = &ext_setcolreg; | ||
2704 | break; | ||
2705 | } | ||
2706 | #endif | ||
2707 | #ifdef ATAFB_TT | ||
2708 | if (ATARIHW_PRESENT(TT_SHIFTER)) { | ||
2709 | fbhw = &tt_switch; | ||
2710 | atafb_ops.fb_setcolreg = &tt_setcolreg; | ||
2711 | break; | ||
2712 | } | ||
2713 | #endif | ||
2714 | #ifdef ATAFB_FALCON | ||
2715 | if (ATARIHW_PRESENT(VIDEL_SHIFTER)) { | ||
2716 | fbhw = &falcon_switch; | ||
2717 | atafb_ops.fb_setcolreg = &falcon_setcolreg; | ||
2718 | request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO, | ||
2719 | "framebuffer/modeswitch", falcon_vbl_switcher); | ||
2720 | break; | ||
2721 | } | ||
2722 | #endif | ||
2723 | #ifdef ATAFB_STE | ||
2724 | if (ATARIHW_PRESENT(STND_SHIFTER) || | ||
2725 | ATARIHW_PRESENT(EXTD_SHIFTER)) { | ||
2726 | fbhw = &st_switch; | ||
2727 | atafb_ops.fb_setcolreg = &stste_setcolreg; | ||
2728 | break; | ||
2729 | } | ||
2730 | fbhw = &st_switch; | ||
2731 | atafb_ops.fb_setcolreg = &stste_setcolreg; | ||
2732 | printk("Cannot determine video hardware; defaulting to ST(e)\n"); | ||
2733 | #else /* ATAFB_STE */ | ||
2734 | /* no default driver included */ | ||
2735 | /* Nobody will ever see this message :-) */ | ||
2736 | panic("Cannot initialize video hardware"); | ||
2737 | #endif | ||
2738 | } while (0); | ||
2739 | |||
2740 | /* Multisync monitor capabilities */ | ||
2741 | /* Atari-TOS defaults if no boot option present */ | ||
2742 | if (fb_info.monspecs.hfmin == 0) { | ||
2743 | fb_info.monspecs.hfmin = 31000; | ||
2744 | fb_info.monspecs.hfmax = 32000; | ||
2745 | fb_info.monspecs.vfmin = 58; | ||
2746 | fb_info.monspecs.vfmax = 62; | ||
2747 | } | ||
2748 | |||
2749 | detected_mode = fbhw->detect(); | ||
2750 | check_default_par(detected_mode); | ||
2751 | #ifdef ATAFB_EXT | ||
2752 | if (!external_addr) { | ||
2753 | #endif /* ATAFB_EXT */ | ||
2754 | mem_req = default_mem_req + ovsc_offset + ovsc_addlen; | ||
2755 | mem_req = PAGE_ALIGN(mem_req) + PAGE_SIZE; | ||
2756 | screen_base = atari_stram_alloc(mem_req, "atafb"); | ||
2757 | if (!screen_base) | ||
2758 | panic("Cannot allocate screen memory"); | ||
2759 | memset(screen_base, 0, mem_req); | ||
2760 | pad = -(unsigned long)screen_base & (PAGE_SIZE-1); | ||
2761 | screen_base+=pad; | ||
2762 | real_screen_base=screen_base+ovsc_offset; | ||
2763 | screen_len = (mem_req - pad - ovsc_offset) & PAGE_MASK; | ||
2764 | st_ovsc_switch(); | ||
2765 | if (CPU_IS_040_OR_060) { | ||
2766 | /* On a '040+, the cache mode of video RAM must be set to | ||
2767 | * write-through also for internal video hardware! */ | ||
2768 | cache_push(virt_to_phys(screen_base), screen_len); | ||
2769 | kernel_set_cachemode(screen_base, screen_len, | ||
2770 | IOMAP_WRITETHROUGH); | ||
2771 | } | ||
2772 | #ifdef ATAFB_EXT | ||
2773 | } | ||
2774 | else { | ||
2775 | /* Map the video memory (physical address given) to somewhere | ||
2776 | * in the kernel address space. | ||
2777 | */ | ||
2778 | external_addr = | ||
2779 | ioremap_writethrough((unsigned long)external_addr, | ||
2780 | external_len); | ||
2781 | if (external_vgaiobase) | ||
2782 | external_vgaiobase = | ||
2783 | (unsigned long)ioremap(external_vgaiobase, 0x10000); | ||
2784 | screen_base = | ||
2785 | real_screen_base = external_addr; | ||
2786 | screen_len = external_len & PAGE_MASK; | ||
2787 | memset (screen_base, 0, external_len); | ||
2788 | } | ||
2789 | #endif /* ATAFB_EXT */ | ||
2790 | |||
2791 | strcpy(fb_info.modename, "Atari Builtin "); | ||
2792 | fb_info.changevar = NULL; | ||
2793 | fb_info.fbops = &atafb_ops; | ||
2794 | fb_info.disp = &disp; | ||
2795 | fb_info.currcon = -1; | ||
2796 | fb_info.switch_con = &atafb_switch; | ||
2797 | fb_info.updatevar = &fb_update_var; | ||
2798 | fb_info.flags = FBINFO_FLAG_DEFAULT; | ||
2799 | do_fb_set_var(&atafb_predefined[default_par-1], 1); | ||
2800 | strcat(fb_info.modename, fb_var_names[default_par-1][0]); | ||
2801 | |||
2802 | atafb_get_var(&disp.var, -1, &fb_info); | ||
2803 | atafb_set_disp(-1, &fb_info); | ||
2804 | do_install_cmap(0, &fb_info); | ||
2805 | |||
2806 | if (register_framebuffer(&fb_info) < 0) { | ||
2807 | #ifdef ATAFB_EXT | ||
2808 | if (external_addr) { | ||
2809 | iounmap(external_addr); | ||
2810 | external_addr = NULL; | ||
2811 | } | ||
2812 | if (external_vgaiobase) { | ||
2813 | iounmap((void*)external_vgaiobase); | ||
2814 | external_vgaiobase = 0; | ||
2815 | } | ||
2816 | #endif | ||
2817 | return -EINVAL; | ||
2818 | } | ||
2819 | |||
2820 | printk("Determined %dx%d, depth %d\n", | ||
2821 | disp.var.xres, disp.var.yres, disp.var.bits_per_pixel); | ||
2822 | if ((disp.var.xres != disp.var.xres_virtual) || | ||
2823 | (disp.var.yres != disp.var.yres_virtual)) | ||
2824 | printk(" virtual %dx%d\n", | ||
2825 | disp.var.xres_virtual, disp.var.yres_virtual); | ||
2826 | printk("fb%d: %s frame buffer device, using %dK of video memory\n", | ||
2827 | fb_info.node, fb_info.modename, screen_len>>10); | ||
2828 | |||
2829 | /* TODO: This driver cannot be unloaded yet */ | ||
2830 | return 0; | ||
2831 | } | 2826 | } |
2832 | 2827 | ||
2833 | |||
2834 | #ifdef ATAFB_EXT | 2828 | #ifdef ATAFB_EXT |
2835 | static void __init atafb_setup_ext(char *spec) | 2829 | static void __init atafb_setup_ext(char *spec) |
2836 | { | 2830 | { |
2837 | int xres, xres_virtual, yres, depth, planes; | 2831 | int xres, xres_virtual, yres, depth, planes; |
2838 | unsigned long addr, len; | 2832 | unsigned long addr, len; |
2839 | char *p; | 2833 | char *p; |
2840 | 2834 | ||
@@ -2848,27 +2842,31 @@ static void __init atafb_setup_ext(char *spec) | |||
2848 | * | 2842 | * |
2849 | * Even xres_virtual is available, we neither support panning nor hw-scrolling! | 2843 | * Even xres_virtual is available, we neither support panning nor hw-scrolling! |
2850 | */ | 2844 | */ |
2851 | if (!(p = strsep(&spec, ";")) || !*p) | 2845 | p = strsep(&spec, ";"); |
2852 | return; | 2846 | if (!p || !*p) |
2847 | return; | ||
2853 | xres_virtual = xres = simple_strtoul(p, NULL, 10); | 2848 | xres_virtual = xres = simple_strtoul(p, NULL, 10); |
2854 | if (xres <= 0) | 2849 | if (xres <= 0) |
2855 | return; | 2850 | return; |
2856 | 2851 | ||
2857 | if (!(p = strsep(&spec, ";")) || !*p) | 2852 | p = strsep(&spec, ";"); |
2858 | return; | 2853 | if (!p || !*p) |
2854 | return; | ||
2859 | yres = simple_strtoul(p, NULL, 10); | 2855 | yres = simple_strtoul(p, NULL, 10); |
2860 | if (yres <= 0) | 2856 | if (yres <= 0) |
2861 | return; | 2857 | return; |
2862 | 2858 | ||
2863 | if (!(p = strsep(&spec, ";")) || !*p) | 2859 | p = strsep(&spec, ";"); |
2864 | return; | 2860 | if (!p || !*p) |
2861 | return; | ||
2865 | depth = simple_strtoul(p, NULL, 10); | 2862 | depth = simple_strtoul(p, NULL, 10); |
2866 | if (depth != 1 && depth != 2 && depth != 4 && depth != 8 && | 2863 | if (depth != 1 && depth != 2 && depth != 4 && depth != 8 && |
2867 | depth != 16 && depth != 24) | 2864 | depth != 16 && depth != 24) |
2868 | return; | 2865 | return; |
2869 | 2866 | ||
2870 | if (!(p = strsep(&spec, ";")) || !*p) | 2867 | p = strsep(&spec, ";"); |
2871 | return; | 2868 | if (!p || !*p) |
2869 | return; | ||
2872 | if (*p == 'i') | 2870 | if (*p == 'i') |
2873 | planes = FB_TYPE_INTERLEAVED_PLANES; | 2871 | planes = FB_TYPE_INTERLEAVED_PLANES; |
2874 | else if (*p == 'p') | 2872 | else if (*p == 'p') |
@@ -2876,25 +2874,27 @@ static void __init atafb_setup_ext(char *spec) | |||
2876 | else if (*p == 'n') | 2874 | else if (*p == 'n') |
2877 | planes = FB_TYPE_PLANES; | 2875 | planes = FB_TYPE_PLANES; |
2878 | else if (*p == 't') | 2876 | else if (*p == 't') |
2879 | planes = -1; /* true color */ | 2877 | planes = -1; /* true color */ |
2880 | else | 2878 | else |
2881 | return; | 2879 | return; |
2882 | 2880 | ||
2883 | 2881 | p = strsep(&spec, ";"); | |
2884 | if (!(p = strsep(&spec, ";")) || !*p) | 2882 | if (!p || !*p) |
2885 | return; | 2883 | return; |
2886 | addr = simple_strtoul(p, NULL, 0); | 2884 | addr = simple_strtoul(p, NULL, 0); |
2887 | 2885 | ||
2888 | if (!(p = strsep(&spec, ";")) || !*p) | 2886 | p = strsep(&spec, ";"); |
2889 | len = xres*yres*depth/8; | 2887 | if (!p || !*p) |
2888 | len = xres * yres * depth / 8; | ||
2890 | else | 2889 | else |
2891 | len = simple_strtoul(p, NULL, 0); | 2890 | len = simple_strtoul(p, NULL, 0); |
2892 | 2891 | ||
2893 | if ((p = strsep(&spec, ";")) && *p) { | 2892 | p = strsep(&spec, ";"); |
2894 | external_vgaiobase=simple_strtoul(p, NULL, 0); | 2893 | if (p && *p) |
2895 | } | 2894 | external_vgaiobase = simple_strtoul(p, NULL, 0); |
2896 | 2895 | ||
2897 | if ((p = strsep(&spec, ";")) && *p) { | 2896 | p = strsep(&spec, ";"); |
2897 | if (p && *p) { | ||
2898 | external_bitspercol = simple_strtoul(p, NULL, 0); | 2898 | external_bitspercol = simple_strtoul(p, NULL, 0); |
2899 | if (external_bitspercol > 8) | 2899 | if (external_bitspercol > 8) |
2900 | external_bitspercol = 8; | 2900 | external_bitspercol = 8; |
@@ -2902,59 +2902,61 @@ static void __init atafb_setup_ext(char *spec) | |||
2902 | external_bitspercol = 1; | 2902 | external_bitspercol = 1; |
2903 | } | 2903 | } |
2904 | 2904 | ||
2905 | if ((p = strsep(&spec, ";")) && *p) { | 2905 | p = strsep(&spec, ";"); |
2906 | if (p && *p) { | ||
2906 | if (!strcmp(p, "vga")) | 2907 | if (!strcmp(p, "vga")) |
2907 | external_card_type = IS_VGA; | 2908 | external_card_type = IS_VGA; |
2908 | if (!strcmp(p, "mv300")) | 2909 | if (!strcmp(p, "mv300")) |
2909 | external_card_type = IS_MV300; | 2910 | external_card_type = IS_MV300; |
2910 | } | 2911 | } |
2911 | 2912 | ||
2912 | if ((p = strsep(&spec, ";")) && *p) { | 2913 | p = strsep(&spec, ";"); |
2914 | if (p && *p) { | ||
2913 | xres_virtual = simple_strtoul(p, NULL, 10); | 2915 | xres_virtual = simple_strtoul(p, NULL, 10); |
2914 | if (xres_virtual < xres) | 2916 | if (xres_virtual < xres) |
2915 | xres_virtual = xres; | 2917 | xres_virtual = xres; |
2916 | if (xres_virtual*yres*depth/8 > len) | 2918 | if (xres_virtual * yres * depth / 8 > len) |
2917 | len=xres_virtual*yres*depth/8; | 2919 | len = xres_virtual * yres * depth / 8; |
2918 | } | 2920 | } |
2919 | 2921 | ||
2920 | external_xres = xres; | 2922 | external_xres = xres; |
2921 | external_xres_virtual = xres_virtual; | 2923 | external_xres_virtual = xres_virtual; |
2922 | external_yres = yres; | 2924 | external_yres = yres; |
2923 | external_depth = depth; | 2925 | external_depth = depth; |
2924 | external_pmode = planes; | 2926 | external_pmode = planes; |
2925 | external_addr = (void *)addr; | 2927 | external_addr = (void *)addr; |
2926 | external_len = len; | 2928 | external_len = len; |
2927 | 2929 | ||
2928 | if (external_card_type == IS_MV300) | 2930 | if (external_card_type == IS_MV300) { |
2929 | switch (external_depth) { | 2931 | switch (external_depth) { |
2930 | case 1: | 2932 | case 1: |
2931 | MV300_reg = MV300_reg_1bit; | 2933 | MV300_reg = MV300_reg_1bit; |
2932 | break; | 2934 | break; |
2933 | case 4: | 2935 | case 4: |
2934 | MV300_reg = MV300_reg_4bit; | 2936 | MV300_reg = MV300_reg_4bit; |
2935 | break; | 2937 | break; |
2936 | case 8: | 2938 | case 8: |
2937 | MV300_reg = MV300_reg_8bit; | 2939 | MV300_reg = MV300_reg_8bit; |
2938 | break; | 2940 | break; |
2939 | } | 2941 | } |
2942 | } | ||
2940 | } | 2943 | } |
2941 | #endif /* ATAFB_EXT */ | 2944 | #endif /* ATAFB_EXT */ |
2942 | 2945 | ||
2943 | |||
2944 | static void __init atafb_setup_int(char *spec) | 2946 | static void __init atafb_setup_int(char *spec) |
2945 | { | 2947 | { |
2946 | /* Format to config extended internal video hardware like OverScan: | 2948 | /* Format to config extended internal video hardware like OverScan: |
2947 | "internal:<xres>;<yres>;<xres_max>;<yres_max>;<offset>" | 2949 | * "internal:<xres>;<yres>;<xres_max>;<yres_max>;<offset>" |
2948 | Explanation: | 2950 | * Explanation: |
2949 | <xres>: x-resolution | 2951 | * <xres>: x-resolution |
2950 | <yres>: y-resolution | 2952 | * <yres>: y-resolution |
2951 | The following are only needed if you have an overscan which | 2953 | * The following are only needed if you have an overscan which |
2952 | needs a black border: | 2954 | * needs a black border: |
2953 | <xres_max>: max. length of a line in pixels your OverScan hardware would allow | 2955 | * <xres_max>: max. length of a line in pixels your OverScan hardware would allow |
2954 | <yres_max>: max. number of lines your OverScan hardware would allow | 2956 | * <yres_max>: max. number of lines your OverScan hardware would allow |
2955 | <offset>: Offset from physical beginning to visible beginning | 2957 | * <offset>: Offset from physical beginning to visible beginning |
2956 | of screen in bytes | 2958 | * of screen in bytes |
2957 | */ | 2959 | */ |
2958 | int xres; | 2960 | int xres; |
2959 | char *p; | 2961 | char *p; |
2960 | 2962 | ||
@@ -2963,23 +2965,19 @@ static void __init atafb_setup_int(char *spec) | |||
2963 | xres = simple_strtoul(p, NULL, 10); | 2965 | xres = simple_strtoul(p, NULL, 10); |
2964 | if (!(p = strsep(&spec, ";")) || !*p) | 2966 | if (!(p = strsep(&spec, ";")) || !*p) |
2965 | return; | 2967 | return; |
2966 | sttt_xres=xres; | 2968 | sttt_xres = xres; |
2967 | tt_yres=st_yres=simple_strtoul(p, NULL, 10); | 2969 | tt_yres = st_yres = simple_strtoul(p, NULL, 10); |
2968 | if ((p=strsep(&spec, ";")) && *p) { | 2970 | if ((p = strsep(&spec, ";")) && *p) |
2969 | sttt_xres_virtual=simple_strtoul(p, NULL, 10); | 2971 | sttt_xres_virtual = simple_strtoul(p, NULL, 10); |
2970 | } | 2972 | if ((p = strsep(&spec, ";")) && *p) |
2971 | if ((p=strsep(&spec, ";")) && *p) { | 2973 | sttt_yres_virtual = simple_strtoul(p, NULL, 0); |
2972 | sttt_yres_virtual=simple_strtoul(p, NULL, 0); | 2974 | if ((p = strsep(&spec, ";")) && *p) |
2973 | } | 2975 | ovsc_offset = simple_strtoul(p, NULL, 0); |
2974 | if ((p=strsep(&spec, ";")) && *p) { | ||
2975 | ovsc_offset=simple_strtoul(p, NULL, 0); | ||
2976 | } | ||
2977 | 2976 | ||
2978 | if (ovsc_offset || (sttt_yres_virtual != st_yres)) | 2977 | if (ovsc_offset || (sttt_yres_virtual != st_yres)) |
2979 | use_hwscroll=0; | 2978 | use_hwscroll = 0; |
2980 | } | 2979 | } |
2981 | 2980 | ||
2982 | |||
2983 | #ifdef ATAFB_FALCON | 2981 | #ifdef ATAFB_FALCON |
2984 | static void __init atafb_setup_mcap(char *spec) | 2982 | static void __init atafb_setup_mcap(char *spec) |
2985 | { | 2983 | { |
@@ -3018,7 +3016,6 @@ static void __init atafb_setup_mcap(char *spec) | |||
3018 | } | 3016 | } |
3019 | #endif /* ATAFB_FALCON */ | 3017 | #endif /* ATAFB_FALCON */ |
3020 | 3018 | ||
3021 | |||
3022 | static void __init atafb_setup_user(char *spec) | 3019 | static void __init atafb_setup_user(char *spec) |
3023 | { | 3020 | { |
3024 | /* Format of user defined video mode is: <xres>;<yres>;<depth> | 3021 | /* Format of user defined video mode is: <xres>;<yres>;<depth> |
@@ -3026,81 +3023,257 @@ static void __init atafb_setup_user(char *spec) | |||
3026 | char *p; | 3023 | char *p; |
3027 | int xres, yres, depth, temp; | 3024 | int xres, yres, depth, temp; |
3028 | 3025 | ||
3029 | if (!(p = strsep(&spec, ";")) || !*p) | 3026 | p = strsep(&spec, ";"); |
3027 | if (!p || !*p) | ||
3030 | return; | 3028 | return; |
3031 | xres = simple_strtoul(p, NULL, 10); | 3029 | xres = simple_strtoul(p, NULL, 10); |
3032 | if (!(p = strsep(&spec, ";")) || !*p) | 3030 | p = strsep(&spec, ";"); |
3031 | if (!p || !*p) | ||
3033 | return; | 3032 | return; |
3034 | yres = simple_strtoul(p, NULL, 10); | 3033 | yres = simple_strtoul(p, NULL, 10); |
3035 | if (!(p = strsep(&spec, "")) || !*p) | 3034 | p = strsep(&spec, ""); |
3035 | if (!p || !*p) | ||
3036 | return; | 3036 | return; |
3037 | depth = simple_strtoul(p, NULL, 10); | 3037 | depth = simple_strtoul(p, NULL, 10); |
3038 | if ((temp=get_video_mode("user0"))) { | 3038 | temp = get_video_mode("user0"); |
3039 | default_par=temp; | 3039 | if (temp) { |
3040 | atafb_predefined[default_par-1].xres = xres; | 3040 | default_par = temp; |
3041 | atafb_predefined[default_par-1].yres = yres; | 3041 | atafb_predefined[default_par - 1].xres = xres; |
3042 | atafb_predefined[default_par-1].bits_per_pixel = depth; | 3042 | atafb_predefined[default_par - 1].yres = yres; |
3043 | atafb_predefined[default_par - 1].bits_per_pixel = depth; | ||
3043 | } | 3044 | } |
3044 | } | 3045 | } |
3045 | 3046 | ||
3046 | int __init atafb_setup( char *options ) | 3047 | int __init atafb_setup(char *options) |
3047 | { | 3048 | { |
3048 | char *this_opt; | 3049 | char *this_opt; |
3049 | int temp; | 3050 | int temp; |
3050 | |||
3051 | fb_info.fontname[0] = '\0'; | ||
3052 | 3051 | ||
3053 | if (!options || !*options) | 3052 | if (!options || !*options) |
3054 | return 0; | 3053 | return 0; |
3055 | 3054 | ||
3056 | while ((this_opt = strsep(&options, ",")) != NULL) { | 3055 | while ((this_opt = strsep(&options, ",")) != NULL) { |
3057 | if (!*this_opt) continue; | 3056 | if (!*this_opt) |
3058 | if ((temp=get_video_mode(this_opt))) | 3057 | continue; |
3059 | default_par=temp; | 3058 | if ((temp = get_video_mode(this_opt))) { |
3060 | else if (! strcmp(this_opt, "inverse")) | 3059 | default_par = temp; |
3061 | inverse=1; | 3060 | mode_option = this_opt; |
3062 | else if (!strncmp(this_opt, "font:", 5)) | 3061 | } else if (!strcmp(this_opt, "inverse")) |
3063 | strcpy(fb_info.fontname, this_opt+5); | 3062 | inverse = 1; |
3064 | else if (! strncmp(this_opt, "hwscroll_",9)) { | 3063 | else if (!strncmp(this_opt, "hwscroll_", 9)) { |
3065 | hwscroll=simple_strtoul(this_opt+9, NULL, 10); | 3064 | hwscroll = simple_strtoul(this_opt + 9, NULL, 10); |
3066 | if (hwscroll < 0) | 3065 | if (hwscroll < 0) |
3067 | hwscroll = 0; | 3066 | hwscroll = 0; |
3068 | if (hwscroll > 200) | 3067 | if (hwscroll > 200) |
3069 | hwscroll = 200; | 3068 | hwscroll = 200; |
3070 | } | 3069 | } |
3071 | #ifdef ATAFB_EXT | 3070 | #ifdef ATAFB_EXT |
3072 | else if (!strcmp(this_opt,"mv300")) { | 3071 | else if (!strcmp(this_opt, "mv300")) { |
3073 | external_bitspercol = 8; | 3072 | external_bitspercol = 8; |
3074 | external_card_type = IS_MV300; | 3073 | external_card_type = IS_MV300; |
3074 | } else if (!strncmp(this_opt, "external:", 9)) | ||
3075 | atafb_setup_ext(this_opt + 9); | ||
3076 | #endif | ||
3077 | else if (!strncmp(this_opt, "internal:", 9)) | ||
3078 | atafb_setup_int(this_opt + 9); | ||
3079 | #ifdef ATAFB_FALCON | ||
3080 | else if (!strncmp(this_opt, "eclock:", 7)) { | ||
3081 | fext.f = simple_strtoul(this_opt + 7, NULL, 10); | ||
3082 | /* external pixelclock in kHz --> ps */ | ||
3083 | fext.t = 1000000000 / fext.f; | ||
3084 | fext.f *= 1000; | ||
3085 | } else if (!strncmp(this_opt, "monitorcap:", 11)) | ||
3086 | atafb_setup_mcap(this_opt + 11); | ||
3087 | #endif | ||
3088 | else if (!strcmp(this_opt, "keep")) | ||
3089 | DontCalcRes = 1; | ||
3090 | else if (!strncmp(this_opt, "R", 1)) | ||
3091 | atafb_setup_user(this_opt + 1); | ||
3075 | } | 3092 | } |
3076 | else if (!strncmp(this_opt,"external:",9)) | 3093 | return 0; |
3077 | atafb_setup_ext(this_opt+9); | 3094 | } |
3095 | |||
3096 | int __init atafb_init(void) | ||
3097 | { | ||
3098 | int pad; | ||
3099 | int detected_mode; | ||
3100 | unsigned int defmode = 0; | ||
3101 | unsigned long mem_req; | ||
3102 | |||
3103 | #ifndef MODULE | ||
3104 | char *option = NULL; | ||
3105 | |||
3106 | if (fb_get_options("atafb", &option)) | ||
3107 | return -ENODEV; | ||
3108 | atafb_setup(option); | ||
3109 | #endif | ||
3110 | printk("atafb_init: start\n"); | ||
3111 | |||
3112 | if (!MACH_IS_ATARI) | ||
3113 | return -ENXIO; | ||
3114 | |||
3115 | do { | ||
3116 | #ifdef ATAFB_EXT | ||
3117 | if (external_addr) { | ||
3118 | printk("atafb_init: initializing external hw\n"); | ||
3119 | fbhw = &ext_switch; | ||
3120 | atafb_ops.fb_setcolreg = &ext_setcolreg; | ||
3121 | defmode = DEFMODE_EXT; | ||
3122 | break; | ||
3123 | } | ||
3124 | #endif | ||
3125 | #ifdef ATAFB_TT | ||
3126 | if (ATARIHW_PRESENT(TT_SHIFTER)) { | ||
3127 | printk("atafb_init: initializing TT hw\n"); | ||
3128 | fbhw = &tt_switch; | ||
3129 | atafb_ops.fb_setcolreg = &tt_setcolreg; | ||
3130 | defmode = DEFMODE_TT; | ||
3131 | break; | ||
3132 | } | ||
3078 | #endif | 3133 | #endif |
3079 | else if (!strncmp(this_opt,"internal:",9)) | ||
3080 | atafb_setup_int(this_opt+9); | ||
3081 | #ifdef ATAFB_FALCON | 3134 | #ifdef ATAFB_FALCON |
3082 | else if (!strncmp(this_opt, "eclock:", 7)) { | 3135 | if (ATARIHW_PRESENT(VIDEL_SHIFTER)) { |
3083 | fext.f = simple_strtoul(this_opt+7, NULL, 10); | 3136 | printk("atafb_init: initializing Falcon hw\n"); |
3084 | /* external pixelclock in kHz --> ps */ | 3137 | fbhw = &falcon_switch; |
3085 | fext.t = 1000000000/fext.f; | 3138 | atafb_ops.fb_setcolreg = &falcon_setcolreg; |
3086 | fext.f *= 1000; | 3139 | request_irq(IRQ_AUTO_4, falcon_vbl_switcher, IRQ_TYPE_PRIO, |
3140 | "framebuffer/modeswitch", falcon_vbl_switcher); | ||
3141 | defmode = DEFMODE_F30; | ||
3142 | break; | ||
3143 | } | ||
3144 | #endif | ||
3145 | #ifdef ATAFB_STE | ||
3146 | if (ATARIHW_PRESENT(STND_SHIFTER) || | ||
3147 | ATARIHW_PRESENT(EXTD_SHIFTER)) { | ||
3148 | printk("atafb_init: initializing ST/E hw\n"); | ||
3149 | fbhw = &st_switch; | ||
3150 | atafb_ops.fb_setcolreg = &stste_setcolreg; | ||
3151 | defmode = DEFMODE_STE; | ||
3152 | break; | ||
3153 | } | ||
3154 | fbhw = &st_switch; | ||
3155 | atafb_ops.fb_setcolreg = &stste_setcolreg; | ||
3156 | printk("Cannot determine video hardware; defaulting to ST(e)\n"); | ||
3157 | #else /* ATAFB_STE */ | ||
3158 | /* no default driver included */ | ||
3159 | /* Nobody will ever see this message :-) */ | ||
3160 | panic("Cannot initialize video hardware"); | ||
3161 | #endif | ||
3162 | } while (0); | ||
3163 | |||
3164 | /* Multisync monitor capabilities */ | ||
3165 | /* Atari-TOS defaults if no boot option present */ | ||
3166 | if (fb_info.monspecs.hfmin == 0) { | ||
3167 | fb_info.monspecs.hfmin = 31000; | ||
3168 | fb_info.monspecs.hfmax = 32000; | ||
3169 | fb_info.monspecs.vfmin = 58; | ||
3170 | fb_info.monspecs.vfmax = 62; | ||
3087 | } | 3171 | } |
3088 | else if (!strncmp(this_opt, "monitorcap:", 11)) | 3172 | |
3089 | atafb_setup_mcap(this_opt+11); | 3173 | detected_mode = fbhw->detect(); |
3174 | check_default_par(detected_mode); | ||
3175 | #ifdef ATAFB_EXT | ||
3176 | if (!external_addr) { | ||
3177 | #endif /* ATAFB_EXT */ | ||
3178 | mem_req = default_mem_req + ovsc_offset + ovsc_addlen; | ||
3179 | mem_req = PAGE_ALIGN(mem_req) + PAGE_SIZE; | ||
3180 | screen_base = atari_stram_alloc(mem_req, "atafb"); | ||
3181 | if (!screen_base) | ||
3182 | panic("Cannot allocate screen memory"); | ||
3183 | memset(screen_base, 0, mem_req); | ||
3184 | pad = -(unsigned long)screen_base & (PAGE_SIZE - 1); | ||
3185 | screen_base += pad; | ||
3186 | real_screen_base = screen_base + ovsc_offset; | ||
3187 | screen_len = (mem_req - pad - ovsc_offset) & PAGE_MASK; | ||
3188 | st_ovsc_switch(); | ||
3189 | if (CPU_IS_040_OR_060) { | ||
3190 | /* On a '040+, the cache mode of video RAM must be set to | ||
3191 | * write-through also for internal video hardware! */ | ||
3192 | cache_push(virt_to_phys(screen_base), screen_len); | ||
3193 | kernel_set_cachemode(screen_base, screen_len, | ||
3194 | IOMAP_WRITETHROUGH); | ||
3195 | } | ||
3196 | printk("atafb: screen_base %p real_screen_base %p screen_len %d\n", | ||
3197 | screen_base, real_screen_base, screen_len); | ||
3198 | #ifdef ATAFB_EXT | ||
3199 | } else { | ||
3200 | /* Map the video memory (physical address given) to somewhere | ||
3201 | * in the kernel address space. | ||
3202 | */ | ||
3203 | external_addr = ioremap_writethrough((unsigned long)external_addr, | ||
3204 | external_len); | ||
3205 | if (external_vgaiobase) | ||
3206 | external_vgaiobase = | ||
3207 | (unsigned long)ioremap(external_vgaiobase, 0x10000); | ||
3208 | screen_base = | ||
3209 | real_screen_base = external_addr; | ||
3210 | screen_len = external_len & PAGE_MASK; | ||
3211 | memset (screen_base, 0, external_len); | ||
3212 | } | ||
3213 | #endif /* ATAFB_EXT */ | ||
3214 | |||
3215 | // strcpy(fb_info.mode->name, "Atari Builtin "); | ||
3216 | fb_info.fbops = &atafb_ops; | ||
3217 | // try to set default (detected; requested) var | ||
3218 | do_fb_set_var(&atafb_predefined[default_par - 1], 1); | ||
3219 | // reads hw state into current par, which may not be sane yet | ||
3220 | ata_get_par(¤t_par); | ||
3221 | fb_info.par = ¤t_par; | ||
3222 | // tries to read from HW which may not be initialized yet | ||
3223 | // so set sane var first, then call atafb_set_par | ||
3224 | atafb_get_var(&fb_info.var, &fb_info); | ||
3225 | fb_info.flags = FBINFO_FLAG_DEFAULT; | ||
3226 | |||
3227 | if (!fb_find_mode(&fb_info.var, &fb_info, mode_option, atafb_modedb, | ||
3228 | NUM_TOTAL_MODES, &atafb_modedb[defmode], | ||
3229 | fb_info.var.bits_per_pixel)) { | ||
3230 | return -EINVAL; | ||
3231 | } | ||
3232 | |||
3233 | atafb_set_disp(&fb_info); | ||
3234 | |||
3235 | fb_alloc_cmap(&(fb_info.cmap), 1 << fb_info.var.bits_per_pixel, 0); | ||
3236 | |||
3237 | |||
3238 | printk("Determined %dx%d, depth %d\n", | ||
3239 | fb_info.var.xres, fb_info.var.yres, fb_info.var.bits_per_pixel); | ||
3240 | if ((fb_info.var.xres != fb_info.var.xres_virtual) || | ||
3241 | (fb_info.var.yres != fb_info.var.yres_virtual)) | ||
3242 | printk(" virtual %dx%d\n", fb_info.var.xres_virtual, | ||
3243 | fb_info.var.yres_virtual); | ||
3244 | |||
3245 | if (register_framebuffer(&fb_info) < 0) { | ||
3246 | #ifdef ATAFB_EXT | ||
3247 | if (external_addr) { | ||
3248 | iounmap(external_addr); | ||
3249 | external_addr = NULL; | ||
3250 | } | ||
3251 | if (external_vgaiobase) { | ||
3252 | iounmap((void*)external_vgaiobase); | ||
3253 | external_vgaiobase = 0; | ||
3254 | } | ||
3090 | #endif | 3255 | #endif |
3091 | else if (!strcmp(this_opt, "keep")) | 3256 | return -EINVAL; |
3092 | DontCalcRes = 1; | 3257 | } |
3093 | else if (!strncmp(this_opt, "R", 1)) | 3258 | |
3094 | atafb_setup_user(this_opt+1); | 3259 | // FIXME: mode needs setting! |
3095 | } | 3260 | //printk("fb%d: %s frame buffer device, using %dK of video memory\n", |
3096 | return 0; | 3261 | // fb_info.node, fb_info.mode->name, screen_len>>10); |
3262 | printk("fb%d: frame buffer device, using %dK of video memory\n", | ||
3263 | fb_info.node, screen_len >> 10); | ||
3264 | |||
3265 | /* TODO: This driver cannot be unloaded yet */ | ||
3266 | return 0; | ||
3097 | } | 3267 | } |
3098 | 3268 | ||
3269 | module_init(atafb_init); | ||
3270 | |||
3099 | #ifdef MODULE | 3271 | #ifdef MODULE |
3100 | MODULE_LICENSE("GPL"); | 3272 | MODULE_LICENSE("GPL"); |
3101 | 3273 | ||
3102 | int init_module(void) | 3274 | int cleanup_module(void) |
3103 | { | 3275 | { |
3104 | return atafb_init(); | 3276 | unregister_framebuffer(&fb_info); |
3277 | return atafb_deinit(); | ||
3105 | } | 3278 | } |
3106 | #endif /* MODULE */ | 3279 | #endif /* MODULE */ |
diff --git a/drivers/video/atafb.h b/drivers/video/atafb.h new file mode 100644 index 000000000000..014e05906cb1 --- /dev/null +++ b/drivers/video/atafb.h | |||
@@ -0,0 +1,36 @@ | |||
1 | #ifndef _VIDEO_ATAFB_H | ||
2 | #define _VIDEO_ATAFB_H | ||
3 | |||
4 | void atafb_mfb_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy, | ||
5 | int dx, int height, int width); | ||
6 | void atafb_mfb_fillrect(struct fb_info *info, u_long next_line, u32 color, | ||
7 | int sy, int sx, int height, int width); | ||
8 | void atafb_mfb_linefill(struct fb_info *info, u_long next_line, | ||
9 | int dy, int dx, u32 width, | ||
10 | const u8 *data, u32 bgcolor, u32 fgcolor); | ||
11 | |||
12 | void atafb_iplan2p2_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy, | ||
13 | int dx, int height, int width); | ||
14 | void atafb_iplan2p2_fillrect(struct fb_info *info, u_long next_line, u32 color, | ||
15 | int sy, int sx, int height, int width); | ||
16 | void atafb_iplan2p2_linefill(struct fb_info *info, u_long next_line, | ||
17 | int dy, int dx, u32 width, | ||
18 | const u8 *data, u32 bgcolor, u32 fgcolor); | ||
19 | |||
20 | void atafb_iplan2p4_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy, | ||
21 | int dx, int height, int width); | ||
22 | void atafb_iplan2p4_fillrect(struct fb_info *info, u_long next_line, u32 color, | ||
23 | int sy, int sx, int height, int width); | ||
24 | void atafb_iplan2p4_linefill(struct fb_info *info, u_long next_line, | ||
25 | int dy, int dx, u32 width, | ||
26 | const u8 *data, u32 bgcolor, u32 fgcolor); | ||
27 | |||
28 | void atafb_iplan2p8_copyarea(struct fb_info *info, u_long next_line, int sy, int sx, int dy, | ||
29 | int dx, int height, int width); | ||
30 | void atafb_iplan2p8_fillrect(struct fb_info *info, u_long next_line, u32 color, | ||
31 | int sy, int sx, int height, int width); | ||
32 | void atafb_iplan2p8_linefill(struct fb_info *info, u_long next_line, | ||
33 | int dy, int dx, u32 width, | ||
34 | const u8 *data, u32 bgcolor, u32 fgcolor); | ||
35 | |||
36 | #endif /* _VIDEO_ATAFB_H */ | ||
diff --git a/drivers/video/atafb_iplan2p2.c b/drivers/video/atafb_iplan2p2.c new file mode 100644 index 000000000000..8cc9c50379d0 --- /dev/null +++ b/drivers/video/atafb_iplan2p2.c | |||
@@ -0,0 +1,293 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/iplan2p2.c -- Low level frame buffer operations for | ||
3 | * interleaved bitplanes à la Atari (2 | ||
4 | * planes, 2 bytes interleave) | ||
5 | * | ||
6 | * Created 5 Apr 1997 by Geert Uytterhoeven | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file COPYING in the main directory of this archive for | ||
10 | * more details. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/string.h> | ||
15 | #include <linux/fb.h> | ||
16 | |||
17 | #include <asm/setup.h> | ||
18 | |||
19 | #include "atafb.h" | ||
20 | |||
21 | #define BPL 2 | ||
22 | #include "atafb_utils.h" | ||
23 | |||
24 | void atafb_iplan2p2_copyarea(struct fb_info *info, u_long next_line, | ||
25 | int sy, int sx, int dy, int dx, | ||
26 | int height, int width) | ||
27 | { | ||
28 | /* bmove() has to distinguish two major cases: If both, source and | ||
29 | * destination, start at even addresses or both are at odd | ||
30 | * addresses, just the first odd and last even column (if present) | ||
31 | * require special treatment (memmove_col()). The rest between | ||
32 | * then can be copied by normal operations, because all adjacent | ||
33 | * bytes are affected and are to be stored in the same order. | ||
34 | * The pathological case is when the move should go from an odd | ||
35 | * address to an even or vice versa. Since the bytes in the plane | ||
36 | * words must be assembled in new order, it seems wisest to make | ||
37 | * all movements by memmove_col(). | ||
38 | */ | ||
39 | |||
40 | u8 *src, *dst; | ||
41 | u32 *s, *d; | ||
42 | int w, l , i, j; | ||
43 | u_int colsize; | ||
44 | u_int upwards = (dy < sy) || (dy == sy && dx < sx); | ||
45 | |||
46 | colsize = height; | ||
47 | if (!((sx ^ dx) & 15)) { | ||
48 | /* odd->odd or even->even */ | ||
49 | |||
50 | if (upwards) { | ||
51 | src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); | ||
52 | dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); | ||
53 | if (sx & 15) { | ||
54 | memmove32_col(dst, src, 0xff00ff, height, next_line - BPL * 2); | ||
55 | src += BPL * 2; | ||
56 | dst += BPL * 2; | ||
57 | width -= 8; | ||
58 | } | ||
59 | w = width >> 4; | ||
60 | if (w) { | ||
61 | s = (u32 *)src; | ||
62 | d = (u32 *)dst; | ||
63 | w *= BPL / 2; | ||
64 | l = next_line - w * 4; | ||
65 | for (j = height; j > 0; j--) { | ||
66 | for (i = w; i > 0; i--) | ||
67 | *d++ = *s++; | ||
68 | s = (u32 *)((u8 *)s + l); | ||
69 | d = (u32 *)((u8 *)d + l); | ||
70 | } | ||
71 | } | ||
72 | if (width & 15) | ||
73 | memmove32_col(dst + width / (8 / BPL), src + width / (8 / BPL), | ||
74 | 0xff00ff00, height, next_line - BPL * 2); | ||
75 | } else { | ||
76 | src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); | ||
77 | dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); | ||
78 | |||
79 | if ((sx + width) & 15) { | ||
80 | src -= BPL * 2; | ||
81 | dst -= BPL * 2; | ||
82 | memmove32_col(dst, src, 0xff00ff00, colsize, -next_line - BPL * 2); | ||
83 | width -= 8; | ||
84 | } | ||
85 | w = width >> 4; | ||
86 | if (w) { | ||
87 | s = (u32 *)src; | ||
88 | d = (u32 *)dst; | ||
89 | w *= BPL / 2; | ||
90 | l = next_line - w * 4; | ||
91 | for (j = height; j > 0; j--) { | ||
92 | for (i = w; i > 0; i--) | ||
93 | *--d = *--s; | ||
94 | s = (u32 *)((u8 *)s - l); | ||
95 | d = (u32 *)((u8 *)d - l); | ||
96 | } | ||
97 | } | ||
98 | if (sx & 15) | ||
99 | memmove32_col(dst - (width - 16) / (8 / BPL), | ||
100 | src - (width - 16) / (8 / BPL), | ||
101 | 0xff00ff, colsize, -next_line - BPL * 2); | ||
102 | } | ||
103 | } else { | ||
104 | /* odd->even or even->odd */ | ||
105 | if (upwards) { | ||
106 | u32 *src32, *dst32; | ||
107 | u32 pval[4], v, v1, mask; | ||
108 | int i, j, w, f; | ||
109 | |||
110 | src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); | ||
111 | dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); | ||
112 | |||
113 | mask = 0xff00ff00; | ||
114 | f = 0; | ||
115 | w = width; | ||
116 | if (sx & 15) { | ||
117 | f = 1; | ||
118 | w += 8; | ||
119 | } | ||
120 | if ((sx + width) & 15) | ||
121 | f |= 2; | ||
122 | w >>= 4; | ||
123 | for (i = height; i; i--) { | ||
124 | src32 = (u32 *)src; | ||
125 | dst32 = (u32 *)dst; | ||
126 | |||
127 | if (f & 1) { | ||
128 | pval[0] = (*src32++ << 8) & mask; | ||
129 | } else { | ||
130 | pval[0] = dst32[0] & mask; | ||
131 | } | ||
132 | |||
133 | for (j = w; j > 0; j--) { | ||
134 | v = *src32++; | ||
135 | v1 = v & mask; | ||
136 | *dst32++ = pval[0] | (v1 >> 8); | ||
137 | pval[0] = (v ^ v1) << 8; | ||
138 | } | ||
139 | |||
140 | if (f & 2) { | ||
141 | dst32[0] = (dst32[0] & mask) | pval[0]; | ||
142 | } | ||
143 | |||
144 | src += next_line; | ||
145 | dst += next_line; | ||
146 | } | ||
147 | } else { | ||
148 | u32 *src32, *dst32; | ||
149 | u32 pval[4], v, v1, mask; | ||
150 | int i, j, w, f; | ||
151 | |||
152 | src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); | ||
153 | dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); | ||
154 | |||
155 | mask = 0xff00ff; | ||
156 | f = 0; | ||
157 | w = width; | ||
158 | if ((dx + width) & 15) | ||
159 | f = 1; | ||
160 | if (sx & 15) { | ||
161 | f |= 2; | ||
162 | w += 8; | ||
163 | } | ||
164 | w >>= 4; | ||
165 | for (i = height; i; i--) { | ||
166 | src32 = (u32 *)src; | ||
167 | dst32 = (u32 *)dst; | ||
168 | |||
169 | if (f & 1) { | ||
170 | pval[0] = dst32[-1] & mask; | ||
171 | } else { | ||
172 | pval[0] = (*--src32 >> 8) & mask; | ||
173 | } | ||
174 | |||
175 | for (j = w; j > 0; j--) { | ||
176 | v = *--src32; | ||
177 | v1 = v & mask; | ||
178 | *--dst32 = pval[0] | (v1 << 8); | ||
179 | pval[0] = (v ^ v1) >> 8; | ||
180 | } | ||
181 | |||
182 | if (!(f & 2)) { | ||
183 | dst32[-1] = (dst32[-1] & mask) | pval[0]; | ||
184 | } | ||
185 | |||
186 | src -= next_line; | ||
187 | dst -= next_line; | ||
188 | } | ||
189 | } | ||
190 | } | ||
191 | } | ||
192 | |||
193 | void atafb_iplan2p2_fillrect(struct fb_info *info, u_long next_line, u32 color, | ||
194 | int sy, int sx, int height, int width) | ||
195 | { | ||
196 | u32 *dest; | ||
197 | int rows, i; | ||
198 | u32 cval[4]; | ||
199 | |||
200 | dest = (u32 *)(info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL)); | ||
201 | if (sx & 15) { | ||
202 | u8 *dest8 = (u8 *)dest + 1; | ||
203 | |||
204 | expand8_col2mask(color, cval); | ||
205 | |||
206 | for (i = height; i; i--) { | ||
207 | fill8_col(dest8, cval); | ||
208 | dest8 += next_line; | ||
209 | } | ||
210 | dest += BPL / 2; | ||
211 | width -= 8; | ||
212 | } | ||
213 | |||
214 | expand16_col2mask(color, cval); | ||
215 | rows = width >> 4; | ||
216 | if (rows) { | ||
217 | u32 *d = dest; | ||
218 | u32 off = next_line - rows * BPL * 2; | ||
219 | for (i = height; i; i--) { | ||
220 | d = fill16_col(d, rows, cval); | ||
221 | d = (u32 *)((long)d + off); | ||
222 | } | ||
223 | dest += rows * BPL / 2; | ||
224 | width &= 15; | ||
225 | } | ||
226 | |||
227 | if (width) { | ||
228 | u8 *dest8 = (u8 *)dest; | ||
229 | |||
230 | expand8_col2mask(color, cval); | ||
231 | |||
232 | for (i = height; i; i--) { | ||
233 | fill8_col(dest8, cval); | ||
234 | dest8 += next_line; | ||
235 | } | ||
236 | } | ||
237 | } | ||
238 | |||
239 | void atafb_iplan2p2_linefill(struct fb_info *info, u_long next_line, | ||
240 | int dy, int dx, u32 width, | ||
241 | const u8 *data, u32 bgcolor, u32 fgcolor) | ||
242 | { | ||
243 | u32 *dest; | ||
244 | const u16 *data16; | ||
245 | int rows; | ||
246 | u32 fgm[4], bgm[4], m; | ||
247 | |||
248 | dest = (u32 *)(info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL)); | ||
249 | if (dx & 15) { | ||
250 | fill8_2col((u8 *)dest + 1, fgcolor, bgcolor, *data++); | ||
251 | dest += BPL / 2; | ||
252 | width -= 8; | ||
253 | } | ||
254 | |||
255 | if (width >= 16) { | ||
256 | data16 = (const u16 *)data; | ||
257 | expand16_2col2mask(fgcolor, bgcolor, fgm, bgm); | ||
258 | |||
259 | for (rows = width / 16; rows; rows--) { | ||
260 | u16 d = *data16++; | ||
261 | m = d | ((u32)d << 16); | ||
262 | *dest++ = (m & fgm[0]) ^ bgm[0]; | ||
263 | } | ||
264 | |||
265 | data = (const u8 *)data16; | ||
266 | width &= 15; | ||
267 | } | ||
268 | |||
269 | if (width) | ||
270 | fill8_2col((u8 *)dest, fgcolor, bgcolor, *data); | ||
271 | } | ||
272 | |||
273 | #ifdef MODULE | ||
274 | MODULE_LICENSE("GPL"); | ||
275 | |||
276 | int init_module(void) | ||
277 | { | ||
278 | return 0; | ||
279 | } | ||
280 | |||
281 | void cleanup_module(void) | ||
282 | { | ||
283 | } | ||
284 | #endif /* MODULE */ | ||
285 | |||
286 | |||
287 | /* | ||
288 | * Visible symbols for modules | ||
289 | */ | ||
290 | |||
291 | EXPORT_SYMBOL(atafb_iplan2p2_copyarea); | ||
292 | EXPORT_SYMBOL(atafb_iplan2p2_fillrect); | ||
293 | EXPORT_SYMBOL(atafb_iplan2p2_linefill); | ||
diff --git a/drivers/video/atafb_iplan2p4.c b/drivers/video/atafb_iplan2p4.c new file mode 100644 index 000000000000..bee0d89463f7 --- /dev/null +++ b/drivers/video/atafb_iplan2p4.c | |||
@@ -0,0 +1,308 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/iplan2p4.c -- Low level frame buffer operations for | ||
3 | * interleaved bitplanes à la Atari (4 | ||
4 | * planes, 2 bytes interleave) | ||
5 | * | ||
6 | * Created 5 Apr 1997 by Geert Uytterhoeven | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file COPYING in the main directory of this archive for | ||
10 | * more details. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/string.h> | ||
15 | #include <linux/fb.h> | ||
16 | |||
17 | #include <asm/setup.h> | ||
18 | |||
19 | #include "atafb.h" | ||
20 | |||
21 | #define BPL 4 | ||
22 | #include "atafb_utils.h" | ||
23 | |||
24 | void atafb_iplan2p4_copyarea(struct fb_info *info, u_long next_line, | ||
25 | int sy, int sx, int dy, int dx, | ||
26 | int height, int width) | ||
27 | { | ||
28 | /* bmove() has to distinguish two major cases: If both, source and | ||
29 | * destination, start at even addresses or both are at odd | ||
30 | * addresses, just the first odd and last even column (if present) | ||
31 | * require special treatment (memmove_col()). The rest between | ||
32 | * then can be copied by normal operations, because all adjacent | ||
33 | * bytes are affected and are to be stored in the same order. | ||
34 | * The pathological case is when the move should go from an odd | ||
35 | * address to an even or vice versa. Since the bytes in the plane | ||
36 | * words must be assembled in new order, it seems wisest to make | ||
37 | * all movements by memmove_col(). | ||
38 | */ | ||
39 | |||
40 | u8 *src, *dst; | ||
41 | u32 *s, *d; | ||
42 | int w, l , i, j; | ||
43 | u_int colsize; | ||
44 | u_int upwards = (dy < sy) || (dy == sy && dx < sx); | ||
45 | |||
46 | colsize = height; | ||
47 | if (!((sx ^ dx) & 15)) { | ||
48 | /* odd->odd or even->even */ | ||
49 | |||
50 | if (upwards) { | ||
51 | src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); | ||
52 | dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); | ||
53 | if (sx & 15) { | ||
54 | memmove32_col(dst, src, 0xff00ff, height, next_line - BPL * 2); | ||
55 | src += BPL * 2; | ||
56 | dst += BPL * 2; | ||
57 | width -= 8; | ||
58 | } | ||
59 | w = width >> 4; | ||
60 | if (w) { | ||
61 | s = (u32 *)src; | ||
62 | d = (u32 *)dst; | ||
63 | w *= BPL / 2; | ||
64 | l = next_line - w * 4; | ||
65 | for (j = height; j > 0; j--) { | ||
66 | for (i = w; i > 0; i--) | ||
67 | *d++ = *s++; | ||
68 | s = (u32 *)((u8 *)s + l); | ||
69 | d = (u32 *)((u8 *)d + l); | ||
70 | } | ||
71 | } | ||
72 | if (width & 15) | ||
73 | memmove32_col(dst + width / (8 / BPL), src + width / (8 / BPL), | ||
74 | 0xff00ff00, height, next_line - BPL * 2); | ||
75 | } else { | ||
76 | src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); | ||
77 | dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); | ||
78 | |||
79 | if ((sx + width) & 15) { | ||
80 | src -= BPL * 2; | ||
81 | dst -= BPL * 2; | ||
82 | memmove32_col(dst, src, 0xff00ff00, colsize, -next_line - BPL * 2); | ||
83 | width -= 8; | ||
84 | } | ||
85 | w = width >> 4; | ||
86 | if (w) { | ||
87 | s = (u32 *)src; | ||
88 | d = (u32 *)dst; | ||
89 | w *= BPL / 2; | ||
90 | l = next_line - w * 4; | ||
91 | for (j = height; j > 0; j--) { | ||
92 | for (i = w; i > 0; i--) | ||
93 | *--d = *--s; | ||
94 | s = (u32 *)((u8 *)s - l); | ||
95 | d = (u32 *)((u8 *)d - l); | ||
96 | } | ||
97 | } | ||
98 | if (sx & 15) | ||
99 | memmove32_col(dst - (width - 16) / (8 / BPL), | ||
100 | src - (width - 16) / (8 / BPL), | ||
101 | 0xff00ff, colsize, -next_line - BPL * 2); | ||
102 | } | ||
103 | } else { | ||
104 | /* odd->even or even->odd */ | ||
105 | if (upwards) { | ||
106 | u32 *src32, *dst32; | ||
107 | u32 pval[4], v, v1, mask; | ||
108 | int i, j, w, f; | ||
109 | |||
110 | src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); | ||
111 | dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); | ||
112 | |||
113 | mask = 0xff00ff00; | ||
114 | f = 0; | ||
115 | w = width; | ||
116 | if (sx & 15) { | ||
117 | f = 1; | ||
118 | w += 8; | ||
119 | } | ||
120 | if ((sx + width) & 15) | ||
121 | f |= 2; | ||
122 | w >>= 4; | ||
123 | for (i = height; i; i--) { | ||
124 | src32 = (u32 *)src; | ||
125 | dst32 = (u32 *)dst; | ||
126 | |||
127 | if (f & 1) { | ||
128 | pval[0] = (*src32++ << 8) & mask; | ||
129 | pval[1] = (*src32++ << 8) & mask; | ||
130 | } else { | ||
131 | pval[0] = dst32[0] & mask; | ||
132 | pval[1] = dst32[1] & mask; | ||
133 | } | ||
134 | |||
135 | for (j = w; j > 0; j--) { | ||
136 | v = *src32++; | ||
137 | v1 = v & mask; | ||
138 | *dst32++ = pval[0] | (v1 >> 8); | ||
139 | pval[0] = (v ^ v1) << 8; | ||
140 | v = *src32++; | ||
141 | v1 = v & mask; | ||
142 | *dst32++ = pval[1] | (v1 >> 8); | ||
143 | pval[1] = (v ^ v1) << 8; | ||
144 | } | ||
145 | |||
146 | if (f & 2) { | ||
147 | dst32[0] = (dst32[0] & mask) | pval[0]; | ||
148 | dst32[1] = (dst32[1] & mask) | pval[1]; | ||
149 | } | ||
150 | |||
151 | src += next_line; | ||
152 | dst += next_line; | ||
153 | } | ||
154 | } else { | ||
155 | u32 *src32, *dst32; | ||
156 | u32 pval[4], v, v1, mask; | ||
157 | int i, j, w, f; | ||
158 | |||
159 | src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); | ||
160 | dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); | ||
161 | |||
162 | mask = 0xff00ff; | ||
163 | f = 0; | ||
164 | w = width; | ||
165 | if ((dx + width) & 15) | ||
166 | f = 1; | ||
167 | if (sx & 15) { | ||
168 | f |= 2; | ||
169 | w += 8; | ||
170 | } | ||
171 | w >>= 4; | ||
172 | for (i = height; i; i--) { | ||
173 | src32 = (u32 *)src; | ||
174 | dst32 = (u32 *)dst; | ||
175 | |||
176 | if (f & 1) { | ||
177 | pval[0] = dst32[-1] & mask; | ||
178 | pval[1] = dst32[-2] & mask; | ||
179 | } else { | ||
180 | pval[0] = (*--src32 >> 8) & mask; | ||
181 | pval[1] = (*--src32 >> 8) & mask; | ||
182 | } | ||
183 | |||
184 | for (j = w; j > 0; j--) { | ||
185 | v = *--src32; | ||
186 | v1 = v & mask; | ||
187 | *--dst32 = pval[0] | (v1 << 8); | ||
188 | pval[0] = (v ^ v1) >> 8; | ||
189 | v = *--src32; | ||
190 | v1 = v & mask; | ||
191 | *--dst32 = pval[1] | (v1 << 8); | ||
192 | pval[1] = (v ^ v1) >> 8; | ||
193 | } | ||
194 | |||
195 | if (!(f & 2)) { | ||
196 | dst32[-1] = (dst32[-1] & mask) | pval[0]; | ||
197 | dst32[-2] = (dst32[-2] & mask) | pval[1]; | ||
198 | } | ||
199 | |||
200 | src -= next_line; | ||
201 | dst -= next_line; | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | } | ||
206 | |||
207 | void atafb_iplan2p4_fillrect(struct fb_info *info, u_long next_line, u32 color, | ||
208 | int sy, int sx, int height, int width) | ||
209 | { | ||
210 | u32 *dest; | ||
211 | int rows, i; | ||
212 | u32 cval[4]; | ||
213 | |||
214 | dest = (u32 *)(info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL)); | ||
215 | if (sx & 15) { | ||
216 | u8 *dest8 = (u8 *)dest + 1; | ||
217 | |||
218 | expand8_col2mask(color, cval); | ||
219 | |||
220 | for (i = height; i; i--) { | ||
221 | fill8_col(dest8, cval); | ||
222 | dest8 += next_line; | ||
223 | } | ||
224 | dest += BPL / 2; | ||
225 | width -= 8; | ||
226 | } | ||
227 | |||
228 | expand16_col2mask(color, cval); | ||
229 | rows = width >> 4; | ||
230 | if (rows) { | ||
231 | u32 *d = dest; | ||
232 | u32 off = next_line - rows * BPL * 2; | ||
233 | for (i = height; i; i--) { | ||
234 | d = fill16_col(d, rows, cval); | ||
235 | d = (u32 *)((long)d + off); | ||
236 | } | ||
237 | dest += rows * BPL / 2; | ||
238 | width &= 15; | ||
239 | } | ||
240 | |||
241 | if (width) { | ||
242 | u8 *dest8 = (u8 *)dest; | ||
243 | |||
244 | expand8_col2mask(color, cval); | ||
245 | |||
246 | for (i = height; i; i--) { | ||
247 | fill8_col(dest8, cval); | ||
248 | dest8 += next_line; | ||
249 | } | ||
250 | } | ||
251 | } | ||
252 | |||
253 | void atafb_iplan2p4_linefill(struct fb_info *info, u_long next_line, | ||
254 | int dy, int dx, u32 width, | ||
255 | const u8 *data, u32 bgcolor, u32 fgcolor) | ||
256 | { | ||
257 | u32 *dest; | ||
258 | const u16 *data16; | ||
259 | int rows; | ||
260 | u32 fgm[4], bgm[4], m; | ||
261 | |||
262 | dest = (u32 *)(info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL)); | ||
263 | if (dx & 15) { | ||
264 | fill8_2col((u8 *)dest + 1, fgcolor, bgcolor, *data++); | ||
265 | dest += BPL / 2; | ||
266 | width -= 8; | ||
267 | } | ||
268 | |||
269 | if (width >= 16) { | ||
270 | data16 = (const u16 *)data; | ||
271 | expand16_2col2mask(fgcolor, bgcolor, fgm, bgm); | ||
272 | |||
273 | for (rows = width / 16; rows; rows--) { | ||
274 | u16 d = *data16++; | ||
275 | m = d | ((u32)d << 16); | ||
276 | *dest++ = (m & fgm[0]) ^ bgm[0]; | ||
277 | *dest++ = (m & fgm[1]) ^ bgm[1]; | ||
278 | } | ||
279 | |||
280 | data = (const u8 *)data16; | ||
281 | width &= 15; | ||
282 | } | ||
283 | |||
284 | if (width) | ||
285 | fill8_2col((u8 *)dest, fgcolor, bgcolor, *data); | ||
286 | } | ||
287 | |||
288 | #ifdef MODULE | ||
289 | MODULE_LICENSE("GPL"); | ||
290 | |||
291 | int init_module(void) | ||
292 | { | ||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | void cleanup_module(void) | ||
297 | { | ||
298 | } | ||
299 | #endif /* MODULE */ | ||
300 | |||
301 | |||
302 | /* | ||
303 | * Visible symbols for modules | ||
304 | */ | ||
305 | |||
306 | EXPORT_SYMBOL(atafb_iplan2p4_copyarea); | ||
307 | EXPORT_SYMBOL(atafb_iplan2p4_fillrect); | ||
308 | EXPORT_SYMBOL(atafb_iplan2p4_linefill); | ||
diff --git a/drivers/video/atafb_iplan2p8.c b/drivers/video/atafb_iplan2p8.c new file mode 100644 index 000000000000..356fb52ce443 --- /dev/null +++ b/drivers/video/atafb_iplan2p8.c | |||
@@ -0,0 +1,345 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/iplan2p8.c -- Low level frame buffer operations for | ||
3 | * interleaved bitplanes à la Atari (8 | ||
4 | * planes, 2 bytes interleave) | ||
5 | * | ||
6 | * Created 5 Apr 1997 by Geert Uytterhoeven | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file COPYING in the main directory of this archive for | ||
10 | * more details. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/string.h> | ||
15 | #include <linux/fb.h> | ||
16 | |||
17 | #include <asm/setup.h> | ||
18 | |||
19 | #include "atafb.h" | ||
20 | |||
21 | #define BPL 8 | ||
22 | #include "atafb_utils.h" | ||
23 | |||
24 | |||
25 | /* Copies a 8 plane column from 's', height 'h', to 'd'. */ | ||
26 | |||
27 | /* This expands a 8 bit color into two longs for two movepl (8 plane) | ||
28 | * operations. | ||
29 | */ | ||
30 | |||
31 | void atafb_iplan2p8_copyarea(struct fb_info *info, u_long next_line, | ||
32 | int sy, int sx, int dy, int dx, | ||
33 | int height, int width) | ||
34 | { | ||
35 | /* bmove() has to distinguish two major cases: If both, source and | ||
36 | * destination, start at even addresses or both are at odd | ||
37 | * addresses, just the first odd and last even column (if present) | ||
38 | * require special treatment (memmove_col()). The rest between | ||
39 | * then can be copied by normal operations, because all adjacent | ||
40 | * bytes are affected and are to be stored in the same order. | ||
41 | * The pathological case is when the move should go from an odd | ||
42 | * address to an even or vice versa. Since the bytes in the plane | ||
43 | * words must be assembled in new order, it seems wisest to make | ||
44 | * all movements by memmove_col(). | ||
45 | */ | ||
46 | |||
47 | u8 *src, *dst; | ||
48 | u32 *s, *d; | ||
49 | int w, l , i, j; | ||
50 | u_int colsize; | ||
51 | u_int upwards = (dy < sy) || (dy == sy && dx < sx); | ||
52 | |||
53 | colsize = height; | ||
54 | if (!((sx ^ dx) & 15)) { | ||
55 | /* odd->odd or even->even */ | ||
56 | |||
57 | if (upwards) { | ||
58 | src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); | ||
59 | dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); | ||
60 | if (sx & 15) { | ||
61 | memmove32_col(dst, src, 0xff00ff, height, next_line - BPL * 2); | ||
62 | src += BPL * 2; | ||
63 | dst += BPL * 2; | ||
64 | width -= 8; | ||
65 | } | ||
66 | w = width >> 4; | ||
67 | if (w) { | ||
68 | s = (u32 *)src; | ||
69 | d = (u32 *)dst; | ||
70 | w *= BPL / 2; | ||
71 | l = next_line - w * 4; | ||
72 | for (j = height; j > 0; j--) { | ||
73 | for (i = w; i > 0; i--) | ||
74 | *d++ = *s++; | ||
75 | s = (u32 *)((u8 *)s + l); | ||
76 | d = (u32 *)((u8 *)d + l); | ||
77 | } | ||
78 | } | ||
79 | if (width & 15) | ||
80 | memmove32_col(dst + width / (8 / BPL), src + width / (8 / BPL), | ||
81 | 0xff00ff00, height, next_line - BPL * 2); | ||
82 | } else { | ||
83 | src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); | ||
84 | dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); | ||
85 | |||
86 | if ((sx + width) & 15) { | ||
87 | src -= BPL * 2; | ||
88 | dst -= BPL * 2; | ||
89 | memmove32_col(dst, src, 0xff00ff00, colsize, -next_line - BPL * 2); | ||
90 | width -= 8; | ||
91 | } | ||
92 | w = width >> 4; | ||
93 | if (w) { | ||
94 | s = (u32 *)src; | ||
95 | d = (u32 *)dst; | ||
96 | w *= BPL / 2; | ||
97 | l = next_line - w * 4; | ||
98 | for (j = height; j > 0; j--) { | ||
99 | for (i = w; i > 0; i--) | ||
100 | *--d = *--s; | ||
101 | s = (u32 *)((u8 *)s - l); | ||
102 | d = (u32 *)((u8 *)d - l); | ||
103 | } | ||
104 | } | ||
105 | if (sx & 15) | ||
106 | memmove32_col(dst - (width - 16) / (8 / BPL), | ||
107 | src - (width - 16) / (8 / BPL), | ||
108 | 0xff00ff, colsize, -next_line - BPL * 2); | ||
109 | } | ||
110 | } else { | ||
111 | /* odd->even or even->odd */ | ||
112 | if (upwards) { | ||
113 | u32 *src32, *dst32; | ||
114 | u32 pval[4], v, v1, mask; | ||
115 | int i, j, w, f; | ||
116 | |||
117 | src = (u8 *)info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL); | ||
118 | dst = (u8 *)info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL); | ||
119 | |||
120 | mask = 0xff00ff00; | ||
121 | f = 0; | ||
122 | w = width; | ||
123 | if (sx & 15) { | ||
124 | f = 1; | ||
125 | w += 8; | ||
126 | } | ||
127 | if ((sx + width) & 15) | ||
128 | f |= 2; | ||
129 | w >>= 4; | ||
130 | for (i = height; i; i--) { | ||
131 | src32 = (u32 *)src; | ||
132 | dst32 = (u32 *)dst; | ||
133 | |||
134 | if (f & 1) { | ||
135 | pval[0] = (*src32++ << 8) & mask; | ||
136 | pval[1] = (*src32++ << 8) & mask; | ||
137 | pval[2] = (*src32++ << 8) & mask; | ||
138 | pval[3] = (*src32++ << 8) & mask; | ||
139 | } else { | ||
140 | pval[0] = dst32[0] & mask; | ||
141 | pval[1] = dst32[1] & mask; | ||
142 | pval[2] = dst32[2] & mask; | ||
143 | pval[3] = dst32[3] & mask; | ||
144 | } | ||
145 | |||
146 | for (j = w; j > 0; j--) { | ||
147 | v = *src32++; | ||
148 | v1 = v & mask; | ||
149 | *dst32++ = pval[0] | (v1 >> 8); | ||
150 | pval[0] = (v ^ v1) << 8; | ||
151 | v = *src32++; | ||
152 | v1 = v & mask; | ||
153 | *dst32++ = pval[1] | (v1 >> 8); | ||
154 | pval[1] = (v ^ v1) << 8; | ||
155 | v = *src32++; | ||
156 | v1 = v & mask; | ||
157 | *dst32++ = pval[2] | (v1 >> 8); | ||
158 | pval[2] = (v ^ v1) << 8; | ||
159 | v = *src32++; | ||
160 | v1 = v & mask; | ||
161 | *dst32++ = pval[3] | (v1 >> 8); | ||
162 | pval[3] = (v ^ v1) << 8; | ||
163 | } | ||
164 | |||
165 | if (f & 2) { | ||
166 | dst32[0] = (dst32[0] & mask) | pval[0]; | ||
167 | dst32[1] = (dst32[1] & mask) | pval[1]; | ||
168 | dst32[2] = (dst32[2] & mask) | pval[2]; | ||
169 | dst32[3] = (dst32[3] & mask) | pval[3]; | ||
170 | } | ||
171 | |||
172 | src += next_line; | ||
173 | dst += next_line; | ||
174 | } | ||
175 | } else { | ||
176 | u32 *src32, *dst32; | ||
177 | u32 pval[4], v, v1, mask; | ||
178 | int i, j, w, f; | ||
179 | |||
180 | src = (u8 *)info->screen_base + (sy - 1) * next_line + ((sx + width + 8) & ~15) / (8 / BPL); | ||
181 | dst = (u8 *)info->screen_base + (dy - 1) * next_line + ((dx + width + 8) & ~15) / (8 / BPL); | ||
182 | |||
183 | mask = 0xff00ff; | ||
184 | f = 0; | ||
185 | w = width; | ||
186 | if ((dx + width) & 15) | ||
187 | f = 1; | ||
188 | if (sx & 15) { | ||
189 | f |= 2; | ||
190 | w += 8; | ||
191 | } | ||
192 | w >>= 4; | ||
193 | for (i = height; i; i--) { | ||
194 | src32 = (u32 *)src; | ||
195 | dst32 = (u32 *)dst; | ||
196 | |||
197 | if (f & 1) { | ||
198 | pval[0] = dst32[-1] & mask; | ||
199 | pval[1] = dst32[-2] & mask; | ||
200 | pval[2] = dst32[-3] & mask; | ||
201 | pval[3] = dst32[-4] & mask; | ||
202 | } else { | ||
203 | pval[0] = (*--src32 >> 8) & mask; | ||
204 | pval[1] = (*--src32 >> 8) & mask; | ||
205 | pval[2] = (*--src32 >> 8) & mask; | ||
206 | pval[3] = (*--src32 >> 8) & mask; | ||
207 | } | ||
208 | |||
209 | for (j = w; j > 0; j--) { | ||
210 | v = *--src32; | ||
211 | v1 = v & mask; | ||
212 | *--dst32 = pval[0] | (v1 << 8); | ||
213 | pval[0] = (v ^ v1) >> 8; | ||
214 | v = *--src32; | ||
215 | v1 = v & mask; | ||
216 | *--dst32 = pval[1] | (v1 << 8); | ||
217 | pval[1] = (v ^ v1) >> 8; | ||
218 | v = *--src32; | ||
219 | v1 = v & mask; | ||
220 | *--dst32 = pval[2] | (v1 << 8); | ||
221 | pval[2] = (v ^ v1) >> 8; | ||
222 | v = *--src32; | ||
223 | v1 = v & mask; | ||
224 | *--dst32 = pval[3] | (v1 << 8); | ||
225 | pval[3] = (v ^ v1) >> 8; | ||
226 | } | ||
227 | |||
228 | if (!(f & 2)) { | ||
229 | dst32[-1] = (dst32[-1] & mask) | pval[0]; | ||
230 | dst32[-2] = (dst32[-2] & mask) | pval[1]; | ||
231 | dst32[-3] = (dst32[-3] & mask) | pval[2]; | ||
232 | dst32[-4] = (dst32[-4] & mask) | pval[3]; | ||
233 | } | ||
234 | |||
235 | src -= next_line; | ||
236 | dst -= next_line; | ||
237 | } | ||
238 | } | ||
239 | } | ||
240 | } | ||
241 | |||
242 | void atafb_iplan2p8_fillrect(struct fb_info *info, u_long next_line, u32 color, | ||
243 | int sy, int sx, int height, int width) | ||
244 | { | ||
245 | u32 *dest; | ||
246 | int rows, i; | ||
247 | u32 cval[4]; | ||
248 | |||
249 | dest = (u32 *)(info->screen_base + sy * next_line + (sx & ~15) / (8 / BPL)); | ||
250 | if (sx & 15) { | ||
251 | u8 *dest8 = (u8 *)dest + 1; | ||
252 | |||
253 | expand8_col2mask(color, cval); | ||
254 | |||
255 | for (i = height; i; i--) { | ||
256 | fill8_col(dest8, cval); | ||
257 | dest8 += next_line; | ||
258 | } | ||
259 | dest += BPL / 2; | ||
260 | width -= 8; | ||
261 | } | ||
262 | |||
263 | expand16_col2mask(color, cval); | ||
264 | rows = width >> 4; | ||
265 | if (rows) { | ||
266 | u32 *d = dest; | ||
267 | u32 off = next_line - rows * BPL * 2; | ||
268 | for (i = height; i; i--) { | ||
269 | d = fill16_col(d, rows, cval); | ||
270 | d = (u32 *)((long)d + off); | ||
271 | } | ||
272 | dest += rows * BPL / 2; | ||
273 | width &= 15; | ||
274 | } | ||
275 | |||
276 | if (width) { | ||
277 | u8 *dest8 = (u8 *)dest; | ||
278 | |||
279 | expand8_col2mask(color, cval); | ||
280 | |||
281 | for (i = height; i; i--) { | ||
282 | fill8_col(dest8, cval); | ||
283 | dest8 += next_line; | ||
284 | } | ||
285 | } | ||
286 | } | ||
287 | |||
288 | void atafb_iplan2p8_linefill(struct fb_info *info, u_long next_line, | ||
289 | int dy, int dx, u32 width, | ||
290 | const u8 *data, u32 bgcolor, u32 fgcolor) | ||
291 | { | ||
292 | u32 *dest; | ||
293 | const u16 *data16; | ||
294 | int rows; | ||
295 | u32 fgm[4], bgm[4], m; | ||
296 | |||
297 | dest = (u32 *)(info->screen_base + dy * next_line + (dx & ~15) / (8 / BPL)); | ||
298 | if (dx & 15) { | ||
299 | fill8_2col((u8 *)dest + 1, fgcolor, bgcolor, *data++); | ||
300 | dest += BPL / 2; | ||
301 | width -= 8; | ||
302 | } | ||
303 | |||
304 | if (width >= 16) { | ||
305 | data16 = (const u16 *)data; | ||
306 | expand16_2col2mask(fgcolor, bgcolor, fgm, bgm); | ||
307 | |||
308 | for (rows = width / 16; rows; rows--) { | ||
309 | u16 d = *data16++; | ||
310 | m = d | ((u32)d << 16); | ||
311 | *dest++ = (m & fgm[0]) ^ bgm[0]; | ||
312 | *dest++ = (m & fgm[1]) ^ bgm[1]; | ||
313 | *dest++ = (m & fgm[2]) ^ bgm[2]; | ||
314 | *dest++ = (m & fgm[3]) ^ bgm[3]; | ||
315 | } | ||
316 | |||
317 | data = (const u8 *)data16; | ||
318 | width &= 15; | ||
319 | } | ||
320 | |||
321 | if (width) | ||
322 | fill8_2col((u8 *)dest, fgcolor, bgcolor, *data); | ||
323 | } | ||
324 | |||
325 | #ifdef MODULE | ||
326 | MODULE_LICENSE("GPL"); | ||
327 | |||
328 | int init_module(void) | ||
329 | { | ||
330 | return 0; | ||
331 | } | ||
332 | |||
333 | void cleanup_module(void) | ||
334 | { | ||
335 | } | ||
336 | #endif /* MODULE */ | ||
337 | |||
338 | |||
339 | /* | ||
340 | * Visible symbols for modules | ||
341 | */ | ||
342 | |||
343 | EXPORT_SYMBOL(atafb_iplan2p8_copyarea); | ||
344 | EXPORT_SYMBOL(atafb_iplan2p8_fillrect); | ||
345 | EXPORT_SYMBOL(atafb_iplan2p8_linefill); | ||
diff --git a/drivers/video/atafb_mfb.c b/drivers/video/atafb_mfb.c new file mode 100644 index 000000000000..6a352d62eecf --- /dev/null +++ b/drivers/video/atafb_mfb.c | |||
@@ -0,0 +1,112 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/mfb.c -- Low level frame buffer operations for | ||
3 | * monochrome | ||
4 | * | ||
5 | * Created 5 Apr 1997 by Geert Uytterhoeven | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General Public | ||
8 | * License. See the file COPYING in the main directory of this archive for | ||
9 | * more details. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/string.h> | ||
14 | #include <linux/fb.h> | ||
15 | |||
16 | #include "atafb.h" | ||
17 | #include "atafb_utils.h" | ||
18 | |||
19 | |||
20 | /* | ||
21 | * Monochrome | ||
22 | */ | ||
23 | |||
24 | void atafb_mfb_copyarea(struct fb_info *info, u_long next_line, | ||
25 | int sy, int sx, int dy, int dx, | ||
26 | int height, int width) | ||
27 | { | ||
28 | u8 *src, *dest; | ||
29 | u_int rows; | ||
30 | |||
31 | if (sx == 0 && dx == 0 && width == next_line) { | ||
32 | src = (u8 *)info->screen_base + sy * (width >> 3); | ||
33 | dest = (u8 *)info->screen_base + dy * (width >> 3); | ||
34 | fb_memmove(dest, src, height * (width >> 3)); | ||
35 | } else if (dy <= sy) { | ||
36 | src = (u8 *)info->screen_base + sy * next_line + (sx >> 3); | ||
37 | dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3); | ||
38 | for (rows = height; rows--;) { | ||
39 | fb_memmove(dest, src, width >> 3); | ||
40 | src += next_line; | ||
41 | dest += next_line; | ||
42 | } | ||
43 | } else { | ||
44 | src = (u8 *)info->screen_base + (sy + height - 1) * next_line + (sx >> 3); | ||
45 | dest = (u8 *)info->screen_base + (dy + height - 1) * next_line + (dx >> 3); | ||
46 | for (rows = height; rows--;) { | ||
47 | fb_memmove(dest, src, width >> 3); | ||
48 | src -= next_line; | ||
49 | dest -= next_line; | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | |||
54 | void atafb_mfb_fillrect(struct fb_info *info, u_long next_line, u32 color, | ||
55 | int sy, int sx, int height, int width) | ||
56 | { | ||
57 | u8 *dest; | ||
58 | u_int rows; | ||
59 | |||
60 | dest = (u8 *)info->screen_base + sy * next_line + (sx >> 3); | ||
61 | |||
62 | if (sx == 0 && width == next_line) { | ||
63 | if (color) | ||
64 | fb_memset255(dest, height * (width >> 3)); | ||
65 | else | ||
66 | fb_memclear(dest, height * (width >> 3)); | ||
67 | } else { | ||
68 | for (rows = height; rows--; dest += next_line) { | ||
69 | if (color) | ||
70 | fb_memset255(dest, width >> 3); | ||
71 | else | ||
72 | fb_memclear_small(dest, width >> 3); | ||
73 | } | ||
74 | } | ||
75 | } | ||
76 | |||
77 | void atafb_mfb_linefill(struct fb_info *info, u_long next_line, | ||
78 | int dy, int dx, u32 width, | ||
79 | const u8 *data, u32 bgcolor, u32 fgcolor) | ||
80 | { | ||
81 | u8 *dest; | ||
82 | u_int rows; | ||
83 | |||
84 | dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3); | ||
85 | |||
86 | for (rows = width / 8; rows--; /* check margins */ ) { | ||
87 | // use fast_memmove or fb_memmove | ||
88 | *dest++ = *data++; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | #ifdef MODULE | ||
93 | MODULE_LICENSE("GPL"); | ||
94 | |||
95 | int init_module(void) | ||
96 | { | ||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | void cleanup_module(void) | ||
101 | { | ||
102 | } | ||
103 | #endif /* MODULE */ | ||
104 | |||
105 | |||
106 | /* | ||
107 | * Visible symbols for modules | ||
108 | */ | ||
109 | |||
110 | EXPORT_SYMBOL(atafb_mfb_copyarea); | ||
111 | EXPORT_SYMBOL(atafb_mfb_fillrect); | ||
112 | EXPORT_SYMBOL(atafb_mfb_linefill); | ||
diff --git a/drivers/video/atafb_utils.h b/drivers/video/atafb_utils.h new file mode 100644 index 000000000000..ac9e19dc5057 --- /dev/null +++ b/drivers/video/atafb_utils.h | |||
@@ -0,0 +1,400 @@ | |||
1 | #ifndef _VIDEO_ATAFB_UTILS_H | ||
2 | #define _VIDEO_ATAFB_UTILS_H | ||
3 | |||
4 | /* ================================================================= */ | ||
5 | /* Utility Assembler Functions */ | ||
6 | /* ================================================================= */ | ||
7 | |||
8 | /* ====================================================================== */ | ||
9 | |||
10 | /* Those of a delicate disposition might like to skip the next couple of | ||
11 | * pages. | ||
12 | * | ||
13 | * These functions are drop in replacements for memmove and | ||
14 | * memset(_, 0, _). However their five instances add at least a kilobyte | ||
15 | * to the object file. You have been warned. | ||
16 | * | ||
17 | * Not a great fan of assembler for the sake of it, but I think | ||
18 | * that these routines are at least 10 times faster than their C | ||
19 | * equivalents for large blits, and that's important to the lowest level of | ||
20 | * a graphics driver. Question is whether some scheme with the blitter | ||
21 | * would be faster. I suspect not for simple text system - not much | ||
22 | * asynchrony. | ||
23 | * | ||
24 | * Code is very simple, just gruesome expansion. Basic strategy is to | ||
25 | * increase data moved/cleared at each step to 16 bytes to reduce | ||
26 | * instruction per data move overhead. movem might be faster still | ||
27 | * For more than 15 bytes, we try to align the write direction on a | ||
28 | * longword boundary to get maximum speed. This is even more gruesome. | ||
29 | * Unaligned read/write used requires 68020+ - think this is a problem? | ||
30 | * | ||
31 | * Sorry! | ||
32 | */ | ||
33 | |||
34 | |||
35 | /* ++roman: I've optimized Robert's original versions in some minor | ||
36 | * aspects, e.g. moveq instead of movel, let gcc choose the registers, | ||
37 | * use movem in some places... | ||
38 | * For other modes than 1 plane, lots of more such assembler functions | ||
39 | * were needed (e.g. the ones using movep or expanding color values). | ||
40 | */ | ||
41 | |||
42 | /* ++andreas: more optimizations: | ||
43 | subl #65536,d0 replaced by clrw d0; subql #1,d0 for dbcc | ||
44 | addal is faster than addaw | ||
45 | movep is rather expensive compared to ordinary move's | ||
46 | some functions rewritten in C for clarity, no speed loss */ | ||
47 | |||
48 | static inline void *fb_memclear_small(void *s, size_t count) | ||
49 | { | ||
50 | if (!count) | ||
51 | return 0; | ||
52 | |||
53 | asm volatile ("\n" | ||
54 | " lsr.l #1,%1 ; jcc 1f ; move.b %2,-(%0)\n" | ||
55 | "1: lsr.l #1,%1 ; jcc 1f ; move.w %2,-(%0)\n" | ||
56 | "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0)\n" | ||
57 | "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0) ; move.l %2,-(%0)\n" | ||
58 | "1:" | ||
59 | : "=a" (s), "=d" (count) | ||
60 | : "d" (0), "0" ((char *)s + count), "1" (count)); | ||
61 | asm volatile ("\n" | ||
62 | " subq.l #1,%1\n" | ||
63 | " jcs 3f\n" | ||
64 | " move.l %2,%%d4; move.l %2,%%d5; move.l %2,%%d6\n" | ||
65 | "2: movem.l %2/%%d4/%%d5/%%d6,-(%0)\n" | ||
66 | " dbra %1,2b\n" | ||
67 | "3:" | ||
68 | : "=a" (s), "=d" (count) | ||
69 | : "d" (0), "0" (s), "1" (count) | ||
70 | : "d4", "d5", "d6" | ||
71 | ); | ||
72 | |||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | |||
77 | static inline void *fb_memclear(void *s, size_t count) | ||
78 | { | ||
79 | if (!count) | ||
80 | return 0; | ||
81 | |||
82 | if (count < 16) { | ||
83 | asm volatile ("\n" | ||
84 | " lsr.l #1,%1 ; jcc 1f ; clr.b (%0)+\n" | ||
85 | "1: lsr.l #1,%1 ; jcc 1f ; clr.w (%0)+\n" | ||
86 | "1: lsr.l #1,%1 ; jcc 1f ; clr.l (%0)+\n" | ||
87 | "1: lsr.l #1,%1 ; jcc 1f ; clr.l (%0)+ ; clr.l (%0)+\n" | ||
88 | "1:" | ||
89 | : "=a" (s), "=d" (count) | ||
90 | : "0" (s), "1" (count)); | ||
91 | } else { | ||
92 | long tmp; | ||
93 | asm volatile ("\n" | ||
94 | " move.l %1,%2\n" | ||
95 | " lsr.l #1,%2 ; jcc 1f ; clr.b (%0)+ ; subq.w #1,%1\n" | ||
96 | " lsr.l #1,%2 ; jcs 2f\n" /* %0 increased=>bit 2 switched*/ | ||
97 | " clr.w (%0)+ ; subq.w #2,%1 ; jra 2f\n" | ||
98 | "1: lsr.l #1,%2 ; jcc 2f\n" | ||
99 | " clr.w (%0)+ ; subq.w #2,%1\n" | ||
100 | "2: move.w %1,%2; lsr.l #2,%1 ; jeq 6f\n" | ||
101 | " lsr.l #1,%1 ; jcc 3f ; clr.l (%0)+\n" | ||
102 | "3: lsr.l #1,%1 ; jcc 4f ; clr.l (%0)+ ; clr.l (%0)+\n" | ||
103 | "4: subq.l #1,%1 ; jcs 6f\n" | ||
104 | "5: clr.l (%0)+; clr.l (%0)+ ; clr.l (%0)+ ; clr.l (%0)+\n" | ||
105 | " dbra %1,5b ; clr.w %1; subq.l #1,%1; jcc 5b\n" | ||
106 | "6: move.w %2,%1; btst #1,%1 ; jeq 7f ; clr.w (%0)+\n" | ||
107 | "7: btst #0,%1 ; jeq 8f ; clr.b (%0)+\n" | ||
108 | "8:" | ||
109 | : "=a" (s), "=d" (count), "=d" (tmp) | ||
110 | : "0" (s), "1" (count)); | ||
111 | } | ||
112 | |||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | |||
117 | static inline void *fb_memset255(void *s, size_t count) | ||
118 | { | ||
119 | if (!count) | ||
120 | return 0; | ||
121 | |||
122 | asm volatile ("\n" | ||
123 | " lsr.l #1,%1 ; jcc 1f ; move.b %2,-(%0)\n" | ||
124 | "1: lsr.l #1,%1 ; jcc 1f ; move.w %2,-(%0)\n" | ||
125 | "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0)\n" | ||
126 | "1: lsr.l #1,%1 ; jcc 1f ; move.l %2,-(%0) ; move.l %2,-(%0)\n" | ||
127 | "1:" | ||
128 | : "=a" (s), "=d" (count) | ||
129 | : "d" (-1), "0" ((char *)s+count), "1" (count)); | ||
130 | asm volatile ("\n" | ||
131 | " subq.l #1,%1 ; jcs 3f\n" | ||
132 | " move.l %2,%%d4; move.l %2,%%d5; move.l %2,%%d6\n" | ||
133 | "2: movem.l %2/%%d4/%%d5/%%d6,-(%0)\n" | ||
134 | " dbra %1,2b\n" | ||
135 | "3:" | ||
136 | : "=a" (s), "=d" (count) | ||
137 | : "d" (-1), "0" (s), "1" (count) | ||
138 | : "d4", "d5", "d6"); | ||
139 | |||
140 | return 0; | ||
141 | } | ||
142 | |||
143 | |||
144 | static inline void *fb_memmove(void *d, const void *s, size_t count) | ||
145 | { | ||
146 | if (d < s) { | ||
147 | if (count < 16) { | ||
148 | asm volatile ("\n" | ||
149 | " lsr.l #1,%2 ; jcc 1f ; move.b (%1)+,(%0)+\n" | ||
150 | "1: lsr.l #1,%2 ; jcc 1f ; move.w (%1)+,(%0)+\n" | ||
151 | "1: lsr.l #1,%2 ; jcc 1f ; move.l (%1)+,(%0)+\n" | ||
152 | "1: lsr.l #1,%2 ; jcc 1f ; move.l (%1)+,(%0)+ ; move.l (%1)+,(%0)+\n" | ||
153 | "1:" | ||
154 | : "=a" (d), "=a" (s), "=d" (count) | ||
155 | : "0" (d), "1" (s), "2" (count)); | ||
156 | } else { | ||
157 | long tmp; | ||
158 | asm volatile ("\n" | ||
159 | " move.l %0,%3\n" | ||
160 | " lsr.l #1,%3 ; jcc 1f ; move.b (%1)+,(%0)+ ; subqw #1,%2\n" | ||
161 | " lsr.l #1,%3 ; jcs 2f\n" /* %0 increased=>bit 2 switched*/ | ||
162 | " move.w (%1)+,(%0)+ ; subqw #2,%2 ; jra 2f\n" | ||
163 | "1: lsr.l #1,%3 ; jcc 2f\n" | ||
164 | " move.w (%1)+,(%0)+ ; subqw #2,%2\n" | ||
165 | "2: move.w %2,%-; lsr.l #2,%2 ; jeq 6f\n" | ||
166 | " lsr.l #1,%2 ; jcc 3f ; move.l (%1)+,(%0)+\n" | ||
167 | "3: lsr.l #1,%2 ; jcc 4f ; move.l (%1)+,(%0)+ ; move.l (%1)+,(%0)+\n" | ||
168 | "4: subq.l #1,%2 ; jcs 6f\n" | ||
169 | "5: move.l (%1)+,(%0)+; move.l (%1)+,(%0)+\n" | ||
170 | " move.l (%1)+,(%0)+; move.l (%1)+,(%0)+\n" | ||
171 | " dbra %2,5b ; clr.w %2; subq.l #1,%2; jcc 5b\n" | ||
172 | "6: move.w %+,%2; btst #1,%2 ; jeq 7f ; move.w (%1)+,(%0)+\n" | ||
173 | "7: btst #0,%2 ; jeq 8f ; move.b (%1)+,(%0)+\n" | ||
174 | "8:" | ||
175 | : "=a" (d), "=a" (s), "=d" (count), "=d" (tmp) | ||
176 | : "0" (d), "1" (s), "2" (count)); | ||
177 | } | ||
178 | } else { | ||
179 | if (count < 16) { | ||
180 | asm volatile ("\n" | ||
181 | " lsr.l #1,%2 ; jcc 1f ; move.b -(%1),-(%0)\n" | ||
182 | "1: lsr.l #1,%2 ; jcc 1f ; move.w -(%1),-(%0)\n" | ||
183 | "1: lsr.l #1,%2 ; jcc 1f ; move.l -(%1),-(%0)\n" | ||
184 | "1: lsr.l #1,%2 ; jcc 1f ; move.l -(%1),-(%0) ; move.l -(%1),-(%0)\n" | ||
185 | "1:" | ||
186 | : "=a" (d), "=a" (s), "=d" (count) | ||
187 | : "0" ((char *) d + count), "1" ((char *) s + count), "2" (count)); | ||
188 | } else { | ||
189 | long tmp; | ||
190 | |||
191 | asm volatile ("\n" | ||
192 | " move.l %0,%3\n" | ||
193 | " lsr.l #1,%3 ; jcc 1f ; move.b -(%1),-(%0) ; subqw #1,%2\n" | ||
194 | " lsr.l #1,%3 ; jcs 2f\n" /* %0 increased=>bit 2 switched*/ | ||
195 | " move.w -(%1),-(%0) ; subqw #2,%2 ; jra 2f\n" | ||
196 | "1: lsr.l #1,%3 ; jcc 2f\n" | ||
197 | " move.w -(%1),-(%0) ; subqw #2,%2\n" | ||
198 | "2: move.w %2,%-; lsr.l #2,%2 ; jeq 6f\n" | ||
199 | " lsr.l #1,%2 ; jcc 3f ; move.l -(%1),-(%0)\n" | ||
200 | "3: lsr.l #1,%2 ; jcc 4f ; move.l -(%1),-(%0) ; move.l -(%1),-(%0)\n" | ||
201 | "4: subq.l #1,%2 ; jcs 6f\n" | ||
202 | "5: move.l -(%1),-(%0); move.l -(%1),-(%0)\n" | ||
203 | " move.l -(%1),-(%0); move.l -(%1),-(%0)\n" | ||
204 | " dbra %2,5b ; clr.w %2; subq.l #1,%2; jcc 5b\n" | ||
205 | "6: move.w %+,%2; btst #1,%2 ; jeq 7f ; move.w -(%1),-(%0)\n" | ||
206 | "7: btst #0,%2 ; jeq 8f ; move.b -(%1),-(%0)\n" | ||
207 | "8:" | ||
208 | : "=a" (d), "=a" (s), "=d" (count), "=d" (tmp) | ||
209 | : "0" ((char *) d + count), "1" ((char *) s + count), "2" (count)); | ||
210 | } | ||
211 | } | ||
212 | |||
213 | return 0; | ||
214 | } | ||
215 | |||
216 | |||
217 | /* ++andreas: Simple and fast version of memmove, assumes size is | ||
218 | divisible by 16, suitable for moving the whole screen bitplane */ | ||
219 | static inline void fast_memmove(char *dst, const char *src, size_t size) | ||
220 | { | ||
221 | if (!size) | ||
222 | return; | ||
223 | if (dst < src) | ||
224 | asm volatile ("\n" | ||
225 | "1: movem.l (%0)+,%%d0/%%d1/%%a0/%%a1\n" | ||
226 | " movem.l %%d0/%%d1/%%a0/%%a1,%1@\n" | ||
227 | " addq.l #8,%1; addq.l #8,%1\n" | ||
228 | " dbra %2,1b\n" | ||
229 | " clr.w %2; subq.l #1,%2\n" | ||
230 | " jcc 1b" | ||
231 | : "=a" (src), "=a" (dst), "=d" (size) | ||
232 | : "0" (src), "1" (dst), "2" (size / 16 - 1) | ||
233 | : "d0", "d1", "a0", "a1", "memory"); | ||
234 | else | ||
235 | asm volatile ("\n" | ||
236 | "1: subq.l #8,%0; subq.l #8,%0\n" | ||
237 | " movem.l %0@,%%d0/%%d1/%%a0/%%a1\n" | ||
238 | " movem.l %%d0/%%d1/%%a0/%%a1,-(%1)\n" | ||
239 | " dbra %2,1b\n" | ||
240 | " clr.w %2; subq.l #1,%2\n" | ||
241 | " jcc 1b" | ||
242 | : "=a" (src), "=a" (dst), "=d" (size) | ||
243 | : "0" (src + size), "1" (dst + size), "2" (size / 16 - 1) | ||
244 | : "d0", "d1", "a0", "a1", "memory"); | ||
245 | } | ||
246 | |||
247 | #ifdef BPL | ||
248 | |||
249 | /* | ||
250 | * This expands a up to 8 bit color into two longs | ||
251 | * for movel operations. | ||
252 | */ | ||
253 | static const u32 four2long[] = { | ||
254 | 0x00000000, 0x000000ff, 0x0000ff00, 0x0000ffff, | ||
255 | 0x00ff0000, 0x00ff00ff, 0x00ffff00, 0x00ffffff, | ||
256 | 0xff000000, 0xff0000ff, 0xff00ff00, 0xff00ffff, | ||
257 | 0xffff0000, 0xffff00ff, 0xffffff00, 0xffffffff, | ||
258 | }; | ||
259 | |||
260 | static inline void expand8_col2mask(u8 c, u32 m[]) | ||
261 | { | ||
262 | m[0] = four2long[c & 15]; | ||
263 | #if BPL > 4 | ||
264 | m[1] = four2long[c >> 4]; | ||
265 | #endif | ||
266 | } | ||
267 | |||
268 | static inline void expand8_2col2mask(u8 fg, u8 bg, u32 fgm[], u32 bgm[]) | ||
269 | { | ||
270 | fgm[0] = four2long[fg & 15] ^ (bgm[0] = four2long[bg & 15]); | ||
271 | #if BPL > 4 | ||
272 | fgm[1] = four2long[fg >> 4] ^ (bgm[1] = four2long[bg >> 4]); | ||
273 | #endif | ||
274 | } | ||
275 | |||
276 | /* | ||
277 | * set an 8bit value to a color | ||
278 | */ | ||
279 | static inline void fill8_col(u8 *dst, u32 m[]) | ||
280 | { | ||
281 | u32 tmp = m[0]; | ||
282 | dst[0] = tmp; | ||
283 | dst[2] = (tmp >>= 8); | ||
284 | #if BPL > 2 | ||
285 | dst[4] = (tmp >>= 8); | ||
286 | dst[6] = tmp >> 8; | ||
287 | #endif | ||
288 | #if BPL > 4 | ||
289 | tmp = m[1]; | ||
290 | dst[8] = tmp; | ||
291 | dst[10] = (tmp >>= 8); | ||
292 | dst[12] = (tmp >>= 8); | ||
293 | dst[14] = tmp >> 8; | ||
294 | #endif | ||
295 | } | ||
296 | |||
297 | /* | ||
298 | * set an 8bit value according to foreground/background color | ||
299 | */ | ||
300 | static inline void fill8_2col(u8 *dst, u8 fg, u8 bg, u32 mask) | ||
301 | { | ||
302 | u32 fgm[2], bgm[2], tmp; | ||
303 | |||
304 | expand8_2col2mask(fg, bg, fgm, bgm); | ||
305 | |||
306 | mask |= mask << 8; | ||
307 | #if BPL > 2 | ||
308 | mask |= mask << 16; | ||
309 | #endif | ||
310 | tmp = (mask & fgm[0]) ^ bgm[0]; | ||
311 | dst[0] = tmp; | ||
312 | dst[2] = (tmp >>= 8); | ||
313 | #if BPL > 2 | ||
314 | dst[4] = (tmp >>= 8); | ||
315 | dst[6] = tmp >> 8; | ||
316 | #endif | ||
317 | #if BPL > 4 | ||
318 | tmp = (mask & fgm[1]) ^ bgm[1]; | ||
319 | dst[8] = tmp; | ||
320 | dst[10] = (tmp >>= 8); | ||
321 | dst[12] = (tmp >>= 8); | ||
322 | dst[14] = tmp >> 8; | ||
323 | #endif | ||
324 | } | ||
325 | |||
326 | static const u32 two2word[] = { | ||
327 | 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff | ||
328 | }; | ||
329 | |||
330 | static inline void expand16_col2mask(u8 c, u32 m[]) | ||
331 | { | ||
332 | m[0] = two2word[c & 3]; | ||
333 | #if BPL > 2 | ||
334 | m[1] = two2word[(c >> 2) & 3]; | ||
335 | #endif | ||
336 | #if BPL > 4 | ||
337 | m[2] = two2word[(c >> 4) & 3]; | ||
338 | m[3] = two2word[c >> 6]; | ||
339 | #endif | ||
340 | } | ||
341 | |||
342 | static inline void expand16_2col2mask(u8 fg, u8 bg, u32 fgm[], u32 bgm[]) | ||
343 | { | ||
344 | bgm[0] = two2word[bg & 3]; | ||
345 | fgm[0] = two2word[fg & 3] ^ bgm[0]; | ||
346 | #if BPL > 2 | ||
347 | bgm[1] = two2word[(bg >> 2) & 3]; | ||
348 | fgm[1] = two2word[(fg >> 2) & 3] ^ bgm[1]; | ||
349 | #endif | ||
350 | #if BPL > 4 | ||
351 | bgm[2] = two2word[(bg >> 4) & 3]; | ||
352 | fgm[2] = two2word[(fg >> 4) & 3] ^ bgm[2]; | ||
353 | bgm[3] = two2word[bg >> 6]; | ||
354 | fgm[3] = two2word[fg >> 6] ^ bgm[3]; | ||
355 | #endif | ||
356 | } | ||
357 | |||
358 | static inline u32 *fill16_col(u32 *dst, int rows, u32 m[]) | ||
359 | { | ||
360 | while (rows) { | ||
361 | *dst++ = m[0]; | ||
362 | #if BPL > 2 | ||
363 | *dst++ = m[1]; | ||
364 | #endif | ||
365 | #if BPL > 4 | ||
366 | *dst++ = m[2]; | ||
367 | *dst++ = m[3]; | ||
368 | #endif | ||
369 | rows--; | ||
370 | } | ||
371 | return dst; | ||
372 | } | ||
373 | |||
374 | static inline void memmove32_col(void *dst, void *src, u32 mask, u32 h, u32 bytes) | ||
375 | { | ||
376 | u32 *s, *d, v; | ||
377 | |||
378 | s = src; | ||
379 | d = dst; | ||
380 | do { | ||
381 | v = (*s++ & mask) | (*d & ~mask); | ||
382 | *d++ = v; | ||
383 | #if BPL > 2 | ||
384 | v = (*s++ & mask) | (*d & ~mask); | ||
385 | *d++ = v; | ||
386 | #endif | ||
387 | #if BPL > 4 | ||
388 | v = (*s++ & mask) | (*d & ~mask); | ||
389 | *d++ = v; | ||
390 | v = (*s++ & mask) | (*d & ~mask); | ||
391 | *d++ = v; | ||
392 | #endif | ||
393 | d = (u32 *)((u8 *)d + bytes); | ||
394 | s = (u32 *)((u8 *)s + bytes); | ||
395 | } while (--h); | ||
396 | } | ||
397 | |||
398 | #endif | ||
399 | |||
400 | #endif /* _VIDEO_ATAFB_UTILS_H */ | ||
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c index 508479920705..7db9de681716 100644 --- a/drivers/video/aty/radeon_i2c.c +++ b/drivers/video/aty/radeon_i2c.c | |||
@@ -1,7 +1,6 @@ | |||
1 | #include <linux/module.h> | 1 | #include <linux/module.h> |
2 | #include <linux/kernel.h> | 2 | #include <linux/kernel.h> |
3 | #include <linux/delay.h> | 3 | #include <linux/delay.h> |
4 | #include <linux/pci.h> | ||
5 | #include <linux/fb.h> | 4 | #include <linux/fb.h> |
6 | 5 | ||
7 | 6 | ||
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 91a20785108a..3e67c34df9a5 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c | |||
@@ -371,7 +371,8 @@ static const char *vgacon_startup(void) | |||
371 | } | 371 | } |
372 | 372 | ||
373 | /* VGA16 modes are not handled by VGACON */ | 373 | /* VGA16 modes are not handled by VGACON */ |
374 | if ((ORIG_VIDEO_MODE == 0x0D) || /* 320x200/4 */ | 374 | if ((ORIG_VIDEO_MODE == 0x00) || /* SCREEN_INFO not initialized */ |
375 | (ORIG_VIDEO_MODE == 0x0D) || /* 320x200/4 */ | ||
375 | (ORIG_VIDEO_MODE == 0x0E) || /* 640x200/4 */ | 376 | (ORIG_VIDEO_MODE == 0x0E) || /* 640x200/4 */ |
376 | (ORIG_VIDEO_MODE == 0x10) || /* 640x350/4 */ | 377 | (ORIG_VIDEO_MODE == 0x10) || /* 640x350/4 */ |
377 | (ORIG_VIDEO_MODE == 0x12) || /* 640x480/4 */ | 378 | (ORIG_VIDEO_MODE == 0x12) || /* 640x480/4 */ |
diff --git a/drivers/video/g364fb.c b/drivers/video/g364fb.c index ca93a75f2997..b7655c05da53 100644 --- a/drivers/video/g364fb.c +++ b/drivers/video/g364fb.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
27 | #include <linux/fb.h> | 27 | #include <linux/fb.h> |
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/pci.h> | ||
30 | #include <asm/io.h> | 29 | #include <asm/io.h> |
31 | #include <asm/jazz.h> | 30 | #include <asm/jazz.h> |
32 | 31 | ||
diff --git a/drivers/video/intelfb/intelfb_i2c.c b/drivers/video/intelfb/intelfb_i2c.c index f4ede5f6b588..61e4c8759b23 100644 --- a/drivers/video/intelfb/intelfb_i2c.c +++ b/drivers/video/intelfb/intelfb_i2c.c | |||
@@ -104,7 +104,8 @@ static int intelfb_setup_i2c_bus(struct intelfb_info *dinfo, | |||
104 | 104 | ||
105 | chan->dinfo = dinfo; | 105 | chan->dinfo = dinfo; |
106 | chan->reg = reg; | 106 | chan->reg = reg; |
107 | snprintf(chan->adapter.name, I2C_NAME_SIZE, "intelfb %s", name); | 107 | snprintf(chan->adapter.name, sizeof(chan->adapter.name), |
108 | "intelfb %s", name); | ||
108 | chan->adapter.owner = THIS_MODULE; | 109 | chan->adapter.owner = THIS_MODULE; |
109 | chan->adapter.id = I2C_HW_B_INTELFB; | 110 | chan->adapter.id = I2C_HW_B_INTELFB; |
110 | chan->adapter.algo_data = &chan->algo; | 111 | chan->adapter.algo_data = &chan->algo; |
diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c index 5ec718a5fe22..4baab7be58de 100644 --- a/drivers/video/matrox/i2c-matroxfb.c +++ b/drivers/video/matrox/i2c-matroxfb.c | |||
@@ -111,7 +111,7 @@ static int i2c_bus_reg(struct i2c_bit_adapter* b, struct matrox_fb_info* minfo, | |||
111 | b->mask.data = data; | 111 | b->mask.data = data; |
112 | b->mask.clock = clock; | 112 | b->mask.clock = clock; |
113 | b->adapter = matrox_i2c_adapter_template; | 113 | b->adapter = matrox_i2c_adapter_template; |
114 | snprintf(b->adapter.name, I2C_NAME_SIZE, name, | 114 | snprintf(b->adapter.name, sizeof(b->adapter.name), name, |
115 | minfo->fbcon.node); | 115 | minfo->fbcon.node); |
116 | i2c_set_adapdata(&b->adapter, b); | 116 | i2c_set_adapdata(&b->adapter, b); |
117 | b->adapter.algo_data = &b->bac; | 117 | b->adapter.algo_data = &b->bac; |
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c index 233871655824..e64f8b5d0056 100644 --- a/drivers/video/platinumfb.c +++ b/drivers/video/platinumfb.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
29 | #include <linux/fb.h> | 29 | #include <linux/fb.h> |
30 | #include <linux/init.h> | 30 | #include <linux/init.h> |
31 | #include <linux/pci.h> | ||
32 | #include <linux/nvram.h> | 31 | #include <linux/nvram.h> |
33 | #include <asm/io.h> | 32 | #include <asm/io.h> |
34 | #include <asm/prom.h> | 33 | #include <asm/prom.h> |
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c index a9ca4986645c..9756a728b74f 100644 --- a/drivers/video/ps3fb.c +++ b/drivers/video/ps3fb.c | |||
@@ -32,6 +32,8 @@ | |||
32 | #include <linux/ioctl.h> | 32 | #include <linux/ioctl.h> |
33 | #include <linux/notifier.h> | 33 | #include <linux/notifier.h> |
34 | #include <linux/reboot.h> | 34 | #include <linux/reboot.h> |
35 | #include <linux/kthread.h> | ||
36 | #include <linux/freezer.h> | ||
35 | 37 | ||
36 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
37 | #include <linux/fb.h> | 39 | #include <linux/fb.h> |
@@ -45,7 +47,7 @@ | |||
45 | #include <asm/ps3.h> | 47 | #include <asm/ps3.h> |
46 | 48 | ||
47 | #ifdef PS3FB_DEBUG | 49 | #ifdef PS3FB_DEBUG |
48 | #define DPRINTK(fmt, args...) printk("%s: " fmt, __FUNCTION__ , ##args) | 50 | #define DPRINTK(fmt, args...) printk("%s: " fmt, __func__ , ##args) |
49 | #else | 51 | #else |
50 | #define DPRINTK(fmt, args...) | 52 | #define DPRINTK(fmt, args...) |
51 | #endif | 53 | #endif |
@@ -129,7 +131,6 @@ struct ps3fb_priv { | |||
129 | u64 context_handle, memory_handle; | 131 | u64 context_handle, memory_handle; |
130 | void *xdr_ea; | 132 | void *xdr_ea; |
131 | struct gpu_driver_info *dinfo; | 133 | struct gpu_driver_info *dinfo; |
132 | struct semaphore sem; | ||
133 | u32 res_index; | 134 | u32 res_index; |
134 | 135 | ||
135 | u64 vblank_count; /* frame count */ | 136 | u64 vblank_count; /* frame count */ |
@@ -139,6 +140,8 @@ struct ps3fb_priv { | |||
139 | atomic_t ext_flip; /* on/off flip with vsync */ | 140 | atomic_t ext_flip; /* on/off flip with vsync */ |
140 | atomic_t f_count; /* fb_open count */ | 141 | atomic_t f_count; /* fb_open count */ |
141 | int is_blanked; | 142 | int is_blanked; |
143 | int is_kicked; | ||
144 | struct task_struct *task; | ||
142 | }; | 145 | }; |
143 | static struct ps3fb_priv ps3fb; | 146 | static struct ps3fb_priv ps3fb; |
144 | 147 | ||
@@ -294,10 +297,10 @@ static const struct fb_videomode ps3fb_modedb[] = { | |||
294 | #define VP_OFF(i) (WIDTH(i) * Y_OFF(i) * BPP + X_OFF(i) * BPP) | 297 | #define VP_OFF(i) (WIDTH(i) * Y_OFF(i) * BPP + X_OFF(i) * BPP) |
295 | #define FB_OFF(i) (GPU_OFFSET - VP_OFF(i) % GPU_OFFSET) | 298 | #define FB_OFF(i) (GPU_OFFSET - VP_OFF(i) % GPU_OFFSET) |
296 | 299 | ||
297 | static int ps3fb_mode = 0; | 300 | static int ps3fb_mode; |
298 | module_param(ps3fb_mode, bool, 0); | 301 | module_param(ps3fb_mode, bool, 0); |
299 | 302 | ||
300 | static char *mode_option __initdata = NULL; | 303 | static char *mode_option __initdata; |
301 | 304 | ||
302 | 305 | ||
303 | static int ps3fb_get_res_table(u32 xres, u32 yres) | 306 | static int ps3fb_get_res_table(u32 xres, u32 yres) |
@@ -393,7 +396,7 @@ static int ps3fb_sync(u32 frame) | |||
393 | 396 | ||
394 | if (frame > ps3fb.num_frames - 1) { | 397 | if (frame > ps3fb.num_frames - 1) { |
395 | printk(KERN_WARNING "%s: invalid frame number (%u)\n", | 398 | printk(KERN_WARNING "%s: invalid frame number (%u)\n", |
396 | __FUNCTION__, frame); | 399 | __func__, frame); |
397 | return -EINVAL; | 400 | return -EINVAL; |
398 | } | 401 | } |
399 | offset = xres * yres * BPP * frame; | 402 | offset = xres * yres * BPP * frame; |
@@ -406,23 +409,26 @@ static int ps3fb_sync(u32 frame) | |||
406 | (xres << 16) | yres, | 409 | (xres << 16) | yres, |
407 | xres * BPP); /* line_length */ | 410 | xres * BPP); /* line_length */ |
408 | if (status) | 411 | if (status) |
409 | printk(KERN_ERR "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n", | 412 | printk(KERN_ERR |
410 | __FUNCTION__, status); | 413 | "%s: lv1_gpu_context_attribute FB_BLIT failed: %d\n", |
414 | __func__, status); | ||
411 | #ifdef HEAD_A | 415 | #ifdef HEAD_A |
412 | status = lv1_gpu_context_attribute(ps3fb.context_handle, | 416 | status = lv1_gpu_context_attribute(ps3fb.context_handle, |
413 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, | 417 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, |
414 | 0, offset, 0, 0); | 418 | 0, offset, 0, 0); |
415 | if (status) | 419 | if (status) |
416 | printk(KERN_ERR "%s: lv1_gpu_context_attribute FLIP failed: %d\n", | 420 | printk(KERN_ERR |
417 | __FUNCTION__, status); | 421 | "%s: lv1_gpu_context_attribute FLIP failed: %d\n", |
422 | __func__, status); | ||
418 | #endif | 423 | #endif |
419 | #ifdef HEAD_B | 424 | #ifdef HEAD_B |
420 | status = lv1_gpu_context_attribute(ps3fb.context_handle, | 425 | status = lv1_gpu_context_attribute(ps3fb.context_handle, |
421 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, | 426 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_FLIP, |
422 | 1, offset, 0, 0); | 427 | 1, offset, 0, 0); |
423 | if (status) | 428 | if (status) |
424 | printk(KERN_ERR "%s: lv1_gpu_context_attribute FLIP failed: %d\n", | 429 | printk(KERN_ERR |
425 | __FUNCTION__, status); | 430 | "%s: lv1_gpu_context_attribute FLIP failed: %d\n", |
431 | __func__, status); | ||
426 | #endif | 432 | #endif |
427 | return 0; | 433 | return 0; |
428 | } | 434 | } |
@@ -631,7 +637,7 @@ static int ps3fb_blank(int blank, struct fb_info *info) | |||
631 | { | 637 | { |
632 | int retval; | 638 | int retval; |
633 | 639 | ||
634 | DPRINTK("%s: blank:%d\n", __FUNCTION__, blank); | 640 | DPRINTK("%s: blank:%d\n", __func__, blank); |
635 | switch (blank) { | 641 | switch (blank) { |
636 | case FB_BLANK_POWERDOWN: | 642 | case FB_BLANK_POWERDOWN: |
637 | case FB_BLANK_HSYNC_SUSPEND: | 643 | case FB_BLANK_HSYNC_SUSPEND: |
@@ -677,13 +683,10 @@ EXPORT_SYMBOL_GPL(ps3fb_wait_for_vsync); | |||
677 | 683 | ||
678 | void ps3fb_flip_ctl(int on) | 684 | void ps3fb_flip_ctl(int on) |
679 | { | 685 | { |
680 | if (on) { | 686 | if (on) |
681 | if (atomic_read(&ps3fb.ext_flip) > 0) { | 687 | atomic_dec_if_positive(&ps3fb.ext_flip); |
682 | atomic_dec(&ps3fb.ext_flip); | 688 | else |
683 | } | ||
684 | } else { | ||
685 | atomic_inc(&ps3fb.ext_flip); | 689 | atomic_inc(&ps3fb.ext_flip); |
686 | } | ||
687 | } | 690 | } |
688 | 691 | ||
689 | EXPORT_SYMBOL_GPL(ps3fb_flip_ctl); | 692 | EXPORT_SYMBOL_GPL(ps3fb_flip_ctl); |
@@ -732,6 +735,11 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd, | |||
732 | if (copy_from_user(&val, argp, sizeof(val))) | 735 | if (copy_from_user(&val, argp, sizeof(val))) |
733 | break; | 736 | break; |
734 | 737 | ||
738 | if (!(val & PS3AV_MODE_MASK)) { | ||
739 | u32 id = ps3av_get_auto_mode(0); | ||
740 | if (id > 0) | ||
741 | val = (val & ~PS3AV_MODE_MASK) | id; | ||
742 | } | ||
735 | DPRINTK("PS3FB_IOCTL_SETMODE:%x\n", val); | 743 | DPRINTK("PS3FB_IOCTL_SETMODE:%x\n", val); |
736 | retval = -EINVAL; | 744 | retval = -EINVAL; |
737 | old_mode = ps3fb_mode; | 745 | old_mode = ps3fb_mode; |
@@ -783,8 +791,7 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd, | |||
783 | 791 | ||
784 | case PS3FB_IOCTL_OFF: | 792 | case PS3FB_IOCTL_OFF: |
785 | DPRINTK("PS3FB_IOCTL_OFF:\n"); | 793 | DPRINTK("PS3FB_IOCTL_OFF:\n"); |
786 | if (atomic_read(&ps3fb.ext_flip) > 0) | 794 | atomic_dec_if_positive(&ps3fb.ext_flip); |
787 | atomic_dec(&ps3fb.ext_flip); | ||
788 | retval = 0; | 795 | retval = 0; |
789 | break; | 796 | break; |
790 | 797 | ||
@@ -805,11 +812,14 @@ static int ps3fb_ioctl(struct fb_info *info, unsigned int cmd, | |||
805 | 812 | ||
806 | static int ps3fbd(void *arg) | 813 | static int ps3fbd(void *arg) |
807 | { | 814 | { |
808 | daemonize("ps3fbd"); | 815 | while (!kthread_should_stop()) { |
809 | for (;;) { | 816 | try_to_freeze(); |
810 | down(&ps3fb.sem); | 817 | set_current_state(TASK_INTERRUPTIBLE); |
811 | if (atomic_read(&ps3fb.ext_flip) == 0) | 818 | if (ps3fb.is_kicked) { |
819 | ps3fb.is_kicked = 0; | ||
812 | ps3fb_sync(0); /* single buffer */ | 820 | ps3fb_sync(0); /* single buffer */ |
821 | } | ||
822 | schedule(); | ||
813 | } | 823 | } |
814 | return 0; | 824 | return 0; |
815 | } | 825 | } |
@@ -823,15 +833,18 @@ static irqreturn_t ps3fb_vsync_interrupt(int irq, void *ptr) | |||
823 | status = lv1_gpu_context_intr(ps3fb.context_handle, &v1); | 833 | status = lv1_gpu_context_intr(ps3fb.context_handle, &v1); |
824 | if (status) { | 834 | if (status) { |
825 | printk(KERN_ERR "%s: lv1_gpu_context_intr failed: %d\n", | 835 | printk(KERN_ERR "%s: lv1_gpu_context_intr failed: %d\n", |
826 | __FUNCTION__, status); | 836 | __func__, status); |
827 | return IRQ_NONE; | 837 | return IRQ_NONE; |
828 | } | 838 | } |
829 | 839 | ||
830 | if (v1 & (1 << GPU_INTR_STATUS_VSYNC_1)) { | 840 | if (v1 & (1 << GPU_INTR_STATUS_VSYNC_1)) { |
831 | /* VSYNC */ | 841 | /* VSYNC */ |
832 | ps3fb.vblank_count = head->vblank_count; | 842 | ps3fb.vblank_count = head->vblank_count; |
833 | if (!ps3fb.is_blanked) | 843 | if (ps3fb.task && !ps3fb.is_blanked && |
834 | up(&ps3fb.sem); | 844 | !atomic_read(&ps3fb.ext_flip)) { |
845 | ps3fb.is_kicked = 1; | ||
846 | wake_up_process(ps3fb.task); | ||
847 | } | ||
835 | wake_up_interruptible(&ps3fb.wait_vsync); | 848 | wake_up_interruptible(&ps3fb.wait_vsync); |
836 | } | 849 | } |
837 | 850 | ||
@@ -879,7 +892,7 @@ static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, void *dev) | |||
879 | dinfo->nvcore_frequency/1000000, dinfo->memory_frequency/1000000); | 892 | dinfo->nvcore_frequency/1000000, dinfo->memory_frequency/1000000); |
880 | 893 | ||
881 | if (dinfo->version_driver != GPU_DRIVER_INFO_VERSION) { | 894 | if (dinfo->version_driver != GPU_DRIVER_INFO_VERSION) { |
882 | printk(KERN_ERR "%s: version_driver err:%x\n", __FUNCTION__, | 895 | printk(KERN_ERR "%s: version_driver err:%x\n", __func__, |
883 | dinfo->version_driver); | 896 | dinfo->version_driver); |
884 | return -EINVAL; | 897 | return -EINVAL; |
885 | } | 898 | } |
@@ -888,7 +901,7 @@ static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, void *dev) | |||
888 | error = ps3_irq_plug_setup(PS3_BINDING_CPU_ANY, dinfo->irq.irq_outlet, | 901 | error = ps3_irq_plug_setup(PS3_BINDING_CPU_ANY, dinfo->irq.irq_outlet, |
889 | &ps3fb.irq_no); | 902 | &ps3fb.irq_no); |
890 | if (error) { | 903 | if (error) { |
891 | printk(KERN_ERR "%s: ps3_alloc_irq failed %d\n", __FUNCTION__, | 904 | printk(KERN_ERR "%s: ps3_alloc_irq failed %d\n", __func__, |
892 | error); | 905 | error); |
893 | return error; | 906 | return error; |
894 | } | 907 | } |
@@ -896,7 +909,7 @@ static int ps3fb_vsync_settings(struct gpu_driver_info *dinfo, void *dev) | |||
896 | error = request_irq(ps3fb.irq_no, ps3fb_vsync_interrupt, IRQF_DISABLED, | 909 | error = request_irq(ps3fb.irq_no, ps3fb_vsync_interrupt, IRQF_DISABLED, |
897 | "ps3fb vsync", ps3fb.dev); | 910 | "ps3fb vsync", ps3fb.dev); |
898 | if (error) { | 911 | if (error) { |
899 | printk(KERN_ERR "%s: request_irq failed %d\n", __FUNCTION__, | 912 | printk(KERN_ERR "%s: request_irq failed %d\n", __func__, |
900 | error); | 913 | error); |
901 | ps3_irq_plug_destroy(ps3fb.irq_no); | 914 | ps3_irq_plug_destroy(ps3fb.irq_no); |
902 | return error; | 915 | return error; |
@@ -915,7 +928,7 @@ static int ps3fb_xdr_settings(u64 xdr_lpar) | |||
915 | xdr_lpar, ps3fb_videomemory.size, 0); | 928 | xdr_lpar, ps3fb_videomemory.size, 0); |
916 | if (status) { | 929 | if (status) { |
917 | printk(KERN_ERR "%s: lv1_gpu_context_iomap failed: %d\n", | 930 | printk(KERN_ERR "%s: lv1_gpu_context_iomap failed: %d\n", |
918 | __FUNCTION__, status); | 931 | __func__, status); |
919 | return -ENXIO; | 932 | return -ENXIO; |
920 | } | 933 | } |
921 | DPRINTK("video:%p xdr_ea:%p ioif:%lx lpar:%lx phys:%lx size:%lx\n", | 934 | DPRINTK("video:%p xdr_ea:%p ioif:%lx lpar:%lx phys:%lx size:%lx\n", |
@@ -927,8 +940,9 @@ static int ps3fb_xdr_settings(u64 xdr_lpar) | |||
927 | xdr_lpar, ps3fb_videomemory.size, | 940 | xdr_lpar, ps3fb_videomemory.size, |
928 | GPU_IOIF, 0); | 941 | GPU_IOIF, 0); |
929 | if (status) { | 942 | if (status) { |
930 | printk(KERN_ERR "%s: lv1_gpu_context_attribute FB_SETUP failed: %d\n", | 943 | printk(KERN_ERR |
931 | __FUNCTION__, status); | 944 | "%s: lv1_gpu_context_attribute FB_SETUP failed: %d\n", |
945 | __func__, status); | ||
932 | return -ENXIO; | 946 | return -ENXIO; |
933 | } | 947 | } |
934 | return 0; | 948 | return 0; |
@@ -968,13 +982,14 @@ static int __init ps3fb_probe(struct platform_device *dev) | |||
968 | u64 xdr_lpar; | 982 | u64 xdr_lpar; |
969 | int status; | 983 | int status; |
970 | unsigned long offset; | 984 | unsigned long offset; |
985 | struct task_struct *task; | ||
971 | 986 | ||
972 | /* get gpu context handle */ | 987 | /* get gpu context handle */ |
973 | status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0, | 988 | status = lv1_gpu_memory_allocate(DDR_SIZE, 0, 0, 0, 0, |
974 | &ps3fb.memory_handle, &ddr_lpar); | 989 | &ps3fb.memory_handle, &ddr_lpar); |
975 | if (status) { | 990 | if (status) { |
976 | printk(KERN_ERR "%s: lv1_gpu_memory_allocate failed: %d\n", | 991 | printk(KERN_ERR "%s: lv1_gpu_memory_allocate failed: %d\n", |
977 | __FUNCTION__, status); | 992 | __func__, status); |
978 | goto err; | 993 | goto err; |
979 | } | 994 | } |
980 | DPRINTK("ddr:lpar:0x%lx\n", ddr_lpar); | 995 | DPRINTK("ddr:lpar:0x%lx\n", ddr_lpar); |
@@ -985,14 +1000,14 @@ static int __init ps3fb_probe(struct platform_device *dev) | |||
985 | &lpar_reports, &lpar_reports_size); | 1000 | &lpar_reports, &lpar_reports_size); |
986 | if (status) { | 1001 | if (status) { |
987 | printk(KERN_ERR "%s: lv1_gpu_context_attribute failed: %d\n", | 1002 | printk(KERN_ERR "%s: lv1_gpu_context_attribute failed: %d\n", |
988 | __FUNCTION__, status); | 1003 | __func__, status); |
989 | goto err_gpu_memory_free; | 1004 | goto err_gpu_memory_free; |
990 | } | 1005 | } |
991 | 1006 | ||
992 | /* vsync interrupt */ | 1007 | /* vsync interrupt */ |
993 | ps3fb.dinfo = ioremap(lpar_driver_info, 128 * 1024); | 1008 | ps3fb.dinfo = ioremap(lpar_driver_info, 128 * 1024); |
994 | if (!ps3fb.dinfo) { | 1009 | if (!ps3fb.dinfo) { |
995 | printk(KERN_ERR "%s: ioremap failed\n", __FUNCTION__); | 1010 | printk(KERN_ERR "%s: ioremap failed\n", __func__); |
996 | goto err_gpu_context_free; | 1011 | goto err_gpu_context_free; |
997 | } | 1012 | } |
998 | 1013 | ||
@@ -1050,9 +1065,18 @@ static int __init ps3fb_probe(struct platform_device *dev) | |||
1050 | "fb%d: PS3 frame buffer device, using %ld KiB of video memory\n", | 1065 | "fb%d: PS3 frame buffer device, using %ld KiB of video memory\n", |
1051 | info->node, ps3fb_videomemory.size >> 10); | 1066 | info->node, ps3fb_videomemory.size >> 10); |
1052 | 1067 | ||
1053 | kernel_thread(ps3fbd, info, CLONE_KERNEL); | 1068 | task = kthread_run(ps3fbd, info, "ps3fbd"); |
1069 | if (IS_ERR(task)) { | ||
1070 | retval = PTR_ERR(task); | ||
1071 | goto err_unregister_framebuffer; | ||
1072 | } | ||
1073 | |||
1074 | ps3fb.task = task; | ||
1075 | |||
1054 | return 0; | 1076 | return 0; |
1055 | 1077 | ||
1078 | err_unregister_framebuffer: | ||
1079 | unregister_framebuffer(info); | ||
1056 | err_fb_dealloc: | 1080 | err_fb_dealloc: |
1057 | fb_dealloc_cmap(&info->cmap); | 1081 | fb_dealloc_cmap(&info->cmap); |
1058 | err_framebuffer_release: | 1082 | err_framebuffer_release: |
@@ -1083,6 +1107,11 @@ void ps3fb_cleanup(void) | |||
1083 | { | 1107 | { |
1084 | int status; | 1108 | int status; |
1085 | 1109 | ||
1110 | if (ps3fb.task) { | ||
1111 | struct task_struct *task = ps3fb.task; | ||
1112 | ps3fb.task = NULL; | ||
1113 | kthread_stop(task); | ||
1114 | } | ||
1086 | if (ps3fb.irq_no) { | 1115 | if (ps3fb.irq_no) { |
1087 | free_irq(ps3fb.irq_no, ps3fb.dev); | 1116 | free_irq(ps3fb.irq_no, ps3fb.dev); |
1088 | ps3_irq_plug_destroy(ps3fb.irq_no); | 1117 | ps3_irq_plug_destroy(ps3fb.irq_no); |
@@ -1137,8 +1166,9 @@ int ps3fb_set_sync(void) | |||
1137 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, | 1166 | L1GPU_CONTEXT_ATTRIBUTE_DISPLAY_SYNC, |
1138 | 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | 1167 | 0, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); |
1139 | if (status) { | 1168 | if (status) { |
1140 | printk(KERN_ERR "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: %d\n", | 1169 | printk(KERN_ERR |
1141 | __FUNCTION__, status); | 1170 | "%s: lv1_gpu_context_attribute DISPLAY_SYNC failed: %d\n", |
1171 | __func__, status); | ||
1142 | return -1; | 1172 | return -1; |
1143 | } | 1173 | } |
1144 | #endif | 1174 | #endif |
@@ -1148,8 +1178,9 @@ int ps3fb_set_sync(void) | |||
1148 | 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); | 1178 | 1, L1GPU_DISPLAY_SYNC_VSYNC, 0, 0); |
1149 | 1179 | ||
1150 | if (status) { | 1180 | if (status) { |
1151 | printk(KERN_ERR "%s: lv1_gpu_context_attribute DISPLAY_MODE failed: %d\n", | 1181 | printk(KERN_ERR |
1152 | __FUNCTION__, status); | 1182 | "%s: lv1_gpu_context_attribute DISPLAY_MODE failed: %d\n", |
1183 | __func__, status); | ||
1153 | return -1; | 1184 | return -1; |
1154 | } | 1185 | } |
1155 | #endif | 1186 | #endif |
@@ -1174,7 +1205,7 @@ static int __init ps3fb_init(void) | |||
1174 | 1205 | ||
1175 | error = ps3av_dev_open(); | 1206 | error = ps3av_dev_open(); |
1176 | if (error) { | 1207 | if (error) { |
1177 | printk(KERN_ERR "%s: ps3av_dev_open failed\n", __FUNCTION__); | 1208 | printk(KERN_ERR "%s: ps3av_dev_open failed\n", __func__); |
1178 | goto err; | 1209 | goto err; |
1179 | } | 1210 | } |
1180 | 1211 | ||
@@ -1195,7 +1226,6 @@ static int __init ps3fb_init(void) | |||
1195 | 1226 | ||
1196 | atomic_set(&ps3fb.f_count, -1); /* fbcon opens ps3fb */ | 1227 | atomic_set(&ps3fb.f_count, -1); /* fbcon opens ps3fb */ |
1197 | atomic_set(&ps3fb.ext_flip, 0); /* for flip with vsync */ | 1228 | atomic_set(&ps3fb.ext_flip, 0); /* for flip with vsync */ |
1198 | init_MUTEX(&ps3fb.sem); | ||
1199 | init_waitqueue_head(&ps3fb.wait_vsync); | 1229 | init_waitqueue_head(&ps3fb.wait_vsync); |
1200 | ps3fb.num_frames = 1; | 1230 | ps3fb.num_frames = 1; |
1201 | 1231 | ||
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c index b4947c810706..0b195f33f84f 100644 --- a/drivers/video/pxafb.c +++ b/drivers/video/pxafb.c | |||
@@ -803,7 +803,7 @@ static void pxafb_enable_controller(struct pxafb_info *fbi) | |||
803 | pr_debug("reg_lccr3 0x%08x\n", (unsigned int) fbi->reg_lccr3); | 803 | pr_debug("reg_lccr3 0x%08x\n", (unsigned int) fbi->reg_lccr3); |
804 | 804 | ||
805 | /* enable LCD controller clock */ | 805 | /* enable LCD controller clock */ |
806 | pxa_set_cken(CKEN16_LCD, 1); | 806 | pxa_set_cken(CKEN_LCD, 1); |
807 | 807 | ||
808 | /* Sequence from 11.7.10 */ | 808 | /* Sequence from 11.7.10 */ |
809 | LCCR3 = fbi->reg_lccr3; | 809 | LCCR3 = fbi->reg_lccr3; |
@@ -840,7 +840,7 @@ static void pxafb_disable_controller(struct pxafb_info *fbi) | |||
840 | remove_wait_queue(&fbi->ctrlr_wait, &wait); | 840 | remove_wait_queue(&fbi->ctrlr_wait, &wait); |
841 | 841 | ||
842 | /* disable LCD controller clock */ | 842 | /* disable LCD controller clock */ |
843 | pxa_set_cken(CKEN16_LCD, 0); | 843 | pxa_set_cken(CKEN_LCD, 0); |
844 | } | 844 | } |
845 | 845 | ||
846 | /* | 846 | /* |
diff --git a/drivers/video/stifb.c b/drivers/video/stifb.c index 69f3b264a22e..c97709ecbad0 100644 --- a/drivers/video/stifb.c +++ b/drivers/video/stifb.c | |||
@@ -64,7 +64,6 @@ | |||
64 | #include <linux/fb.h> | 64 | #include <linux/fb.h> |
65 | #include <linux/init.h> | 65 | #include <linux/init.h> |
66 | #include <linux/ioport.h> | 66 | #include <linux/ioport.h> |
67 | #include <linux/pci.h> | ||
68 | 67 | ||
69 | #include <asm/grfioctl.h> /* for HP-UX compatibility */ | 68 | #include <asm/grfioctl.h> /* for HP-UX compatibility */ |
70 | #include <asm/uaccess.h> | 69 | #include <asm/uaccess.h> |
diff --git a/drivers/video/sunxvr2500.c b/drivers/video/sunxvr2500.c new file mode 100644 index 000000000000..4316c7fe8e21 --- /dev/null +++ b/drivers/video/sunxvr2500.c | |||
@@ -0,0 +1,277 @@ | |||
1 | /* s3d.c: Sun 3DLABS XVR-2500 et al. driver for sparc64 systems | ||
2 | * | ||
3 | * Copyright (C) 2007 David S. Miller (davem@davemloft.net) | ||
4 | */ | ||
5 | |||
6 | #include <linux/module.h> | ||
7 | #include <linux/kernel.h> | ||
8 | #include <linux/slab.h> | ||
9 | #include <linux/fb.h> | ||
10 | #include <linux/pci.h> | ||
11 | #include <linux/init.h> | ||
12 | |||
13 | #include <asm/io.h> | ||
14 | #include <asm/prom.h> | ||
15 | #include <asm/of_device.h> | ||
16 | |||
17 | struct s3d_info { | ||
18 | struct fb_info *info; | ||
19 | struct pci_dev *pdev; | ||
20 | |||
21 | char __iomem *fb_base; | ||
22 | unsigned long fb_base_phys; | ||
23 | |||
24 | struct device_node *of_node; | ||
25 | |||
26 | unsigned int width; | ||
27 | unsigned int height; | ||
28 | unsigned int depth; | ||
29 | unsigned int fb_size; | ||
30 | |||
31 | u32 pseudo_palette[256]; | ||
32 | }; | ||
33 | |||
34 | static int __devinit s3d_get_props(struct s3d_info *sp) | ||
35 | { | ||
36 | sp->width = of_getintprop_default(sp->of_node, "width", 0); | ||
37 | sp->height = of_getintprop_default(sp->of_node, "height", 0); | ||
38 | sp->depth = of_getintprop_default(sp->of_node, "depth", 8); | ||
39 | |||
40 | if (!sp->width || !sp->height) { | ||
41 | printk(KERN_ERR "s3d: Critical properties missing for %s\n", | ||
42 | pci_name(sp->pdev)); | ||
43 | return -EINVAL; | ||
44 | } | ||
45 | |||
46 | return 0; | ||
47 | } | ||
48 | |||
49 | static int s3d_setcolreg(unsigned regno, | ||
50 | unsigned red, unsigned green, unsigned blue, | ||
51 | unsigned transp, struct fb_info *info) | ||
52 | { | ||
53 | u32 value; | ||
54 | |||
55 | if (regno >= 256) | ||
56 | return 1; | ||
57 | |||
58 | red >>= 8; | ||
59 | green >>= 8; | ||
60 | blue >>= 8; | ||
61 | |||
62 | value = (blue << 24) | (green << 16) | (red << 8); | ||
63 | ((u32 *)info->pseudo_palette)[regno] = value; | ||
64 | |||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | static struct fb_ops s3d_ops = { | ||
69 | .owner = THIS_MODULE, | ||
70 | .fb_setcolreg = s3d_setcolreg, | ||
71 | .fb_fillrect = cfb_fillrect, | ||
72 | .fb_copyarea = cfb_copyarea, | ||
73 | .fb_imageblit = cfb_imageblit, | ||
74 | }; | ||
75 | |||
76 | static int __devinit s3d_set_fbinfo(struct s3d_info *sp) | ||
77 | { | ||
78 | struct fb_info *info = sp->info; | ||
79 | struct fb_var_screeninfo *var = &info->var; | ||
80 | |||
81 | info->flags = FBINFO_DEFAULT; | ||
82 | info->fbops = &s3d_ops; | ||
83 | info->screen_base = sp->fb_base; | ||
84 | info->screen_size = sp->fb_size; | ||
85 | |||
86 | info->pseudo_palette = sp->pseudo_palette; | ||
87 | |||
88 | /* Fill fix common fields */ | ||
89 | strlcpy(info->fix.id, "s3d", sizeof(info->fix.id)); | ||
90 | info->fix.smem_start = sp->fb_base_phys; | ||
91 | info->fix.smem_len = sp->fb_size; | ||
92 | info->fix.type = FB_TYPE_PACKED_PIXELS; | ||
93 | if (sp->depth == 32 || sp->depth == 24) | ||
94 | info->fix.visual = FB_VISUAL_TRUECOLOR; | ||
95 | else | ||
96 | info->fix.visual = FB_VISUAL_PSEUDOCOLOR; | ||
97 | |||
98 | var->xres = sp->width; | ||
99 | var->yres = sp->height; | ||
100 | var->xres_virtual = var->xres; | ||
101 | var->yres_virtual = var->yres; | ||
102 | var->bits_per_pixel = sp->depth; | ||
103 | |||
104 | var->red.offset = 8; | ||
105 | var->red.length = 8; | ||
106 | var->green.offset = 16; | ||
107 | var->green.length = 8; | ||
108 | var->blue.offset = 24; | ||
109 | var->blue.length = 8; | ||
110 | var->transp.offset = 0; | ||
111 | var->transp.length = 0; | ||
112 | |||
113 | if (fb_alloc_cmap(&info->cmap, 256, 0)) { | ||
114 | printk(KERN_ERR "s3d: Cannot allocate color map.\n"); | ||
115 | return -ENOMEM; | ||
116 | } | ||
117 | |||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | static int __devinit s3d_pci_register(struct pci_dev *pdev, | ||
122 | const struct pci_device_id *ent) | ||
123 | { | ||
124 | struct fb_info *info; | ||
125 | struct s3d_info *sp; | ||
126 | int err; | ||
127 | |||
128 | err = pci_enable_device(pdev); | ||
129 | if (err < 0) { | ||
130 | printk(KERN_ERR "s3d: Cannot enable PCI device %s\n", | ||
131 | pci_name(pdev)); | ||
132 | goto err_out; | ||
133 | } | ||
134 | |||
135 | info = framebuffer_alloc(sizeof(struct s3d_info), &pdev->dev); | ||
136 | if (!info) { | ||
137 | printk(KERN_ERR "s3d: Cannot allocate fb_info\n"); | ||
138 | err = -ENOMEM; | ||
139 | goto err_disable; | ||
140 | } | ||
141 | |||
142 | sp = info->par; | ||
143 | sp->info = info; | ||
144 | sp->pdev = pdev; | ||
145 | sp->of_node = pci_device_to_OF_node(pdev); | ||
146 | if (!sp->of_node) { | ||
147 | printk(KERN_ERR "s3d: Cannot find OF node of %s\n", | ||
148 | pci_name(pdev)); | ||
149 | err = -ENODEV; | ||
150 | goto err_release_fb; | ||
151 | } | ||
152 | |||
153 | sp->fb_base_phys = pci_resource_start (pdev, 1); | ||
154 | |||
155 | err = pci_request_region(pdev, 1, "s3d framebuffer"); | ||
156 | if (err < 0) { | ||
157 | printk("s3d: Cannot request region 1 for %s\n", | ||
158 | pci_name(pdev)); | ||
159 | goto err_release_fb; | ||
160 | } | ||
161 | |||
162 | err = s3d_get_props(sp); | ||
163 | if (err) | ||
164 | goto err_release_pci; | ||
165 | |||
166 | /* XXX 'linebytes' is often wrong, it is equal to the width | ||
167 | * XXX with depth of 32 on my XVR-2500 which is clearly not | ||
168 | * XXX right. So we don't try to use it. | ||
169 | */ | ||
170 | switch (sp->depth) { | ||
171 | case 8: | ||
172 | info->fix.line_length = sp->width; | ||
173 | break; | ||
174 | case 16: | ||
175 | info->fix.line_length = sp->width * 2; | ||
176 | break; | ||
177 | case 24: | ||
178 | info->fix.line_length = sp->width * 3; | ||
179 | break; | ||
180 | case 32: | ||
181 | info->fix.line_length = sp->width * 4; | ||
182 | break; | ||
183 | } | ||
184 | sp->fb_size = info->fix.line_length * sp->height; | ||
185 | |||
186 | sp->fb_base = ioremap(sp->fb_base_phys, sp->fb_size); | ||
187 | if (!sp->fb_base) | ||
188 | goto err_release_pci; | ||
189 | |||
190 | err = s3d_set_fbinfo(sp); | ||
191 | if (err) | ||
192 | goto err_unmap_fb; | ||
193 | |||
194 | pci_set_drvdata(pdev, info); | ||
195 | |||
196 | printk("s3d: Found device at %s\n", pci_name(pdev)); | ||
197 | |||
198 | err = register_framebuffer(info); | ||
199 | if (err < 0) { | ||
200 | printk(KERN_ERR "s3d: Could not register framebuffer %s\n", | ||
201 | pci_name(pdev)); | ||
202 | goto err_unmap_fb; | ||
203 | } | ||
204 | |||
205 | return 0; | ||
206 | |||
207 | err_unmap_fb: | ||
208 | iounmap(sp->fb_base); | ||
209 | |||
210 | err_release_pci: | ||
211 | pci_release_region(pdev, 1); | ||
212 | |||
213 | err_release_fb: | ||
214 | framebuffer_release(info); | ||
215 | |||
216 | err_disable: | ||
217 | pci_disable_device(pdev); | ||
218 | |||
219 | err_out: | ||
220 | return err; | ||
221 | } | ||
222 | |||
223 | static void __devexit s3d_pci_unregister(struct pci_dev *pdev) | ||
224 | { | ||
225 | struct fb_info *info = pci_get_drvdata(pdev); | ||
226 | struct s3d_info *sp = info->par; | ||
227 | |||
228 | unregister_framebuffer(info); | ||
229 | |||
230 | iounmap(sp->fb_base); | ||
231 | |||
232 | pci_release_region(pdev, 1); | ||
233 | |||
234 | framebuffer_release(info); | ||
235 | |||
236 | pci_disable_device(pdev); | ||
237 | } | ||
238 | |||
239 | static struct pci_device_id s3d_pci_table[] = { | ||
240 | { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x002c), }, | ||
241 | { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x002d), }, | ||
242 | { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x002e), }, | ||
243 | { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x002f), }, | ||
244 | { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x0030), }, | ||
245 | { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x0031), }, | ||
246 | { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x0032), }, | ||
247 | { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x0033), }, | ||
248 | { 0, } | ||
249 | }; | ||
250 | |||
251 | static struct pci_driver s3d_driver = { | ||
252 | .name = "s3d", | ||
253 | .id_table = s3d_pci_table, | ||
254 | .probe = s3d_pci_register, | ||
255 | .remove = __devexit_p(s3d_pci_unregister), | ||
256 | }; | ||
257 | |||
258 | static int __init s3d_init(void) | ||
259 | { | ||
260 | if (fb_get_options("s3d", NULL)) | ||
261 | return -ENODEV; | ||
262 | |||
263 | return pci_register_driver(&s3d_driver); | ||
264 | } | ||
265 | |||
266 | static void __exit s3d_exit(void) | ||
267 | { | ||
268 | pci_unregister_driver(&s3d_driver); | ||
269 | } | ||
270 | |||
271 | module_init(s3d_init); | ||
272 | module_exit(s3d_exit); | ||
273 | |||
274 | MODULE_DESCRIPTION("framebuffer driver for Sun XVR-2500 graphics"); | ||
275 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); | ||
276 | MODULE_VERSION("1.0"); | ||
277 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/sunxvr500.c b/drivers/video/sunxvr500.c new file mode 100644 index 000000000000..08880a62bfa3 --- /dev/null +++ b/drivers/video/sunxvr500.c | |||
@@ -0,0 +1,443 @@ | |||
1 | /* sunxvr500.c: Sun 3DLABS XVR-500 Expert3D driver for sparc64 systems | ||
2 | * | ||
3 | * Copyright (C) 2007 David S. Miller (davem@davemloft.net) | ||
4 | */ | ||
5 | |||
6 | #include <linux/module.h> | ||
7 | #include <linux/kernel.h> | ||
8 | #include <linux/slab.h> | ||
9 | #include <linux/fb.h> | ||
10 | #include <linux/pci.h> | ||
11 | #include <linux/init.h> | ||
12 | |||
13 | #include <asm/io.h> | ||
14 | #include <asm/prom.h> | ||
15 | #include <asm/of_device.h> | ||
16 | |||
17 | /* XXX This device has a 'dev-comm' property which aparently is | ||
18 | * XXX a pointer into the openfirmware's address space which is | ||
19 | * XXX a shared area the kernel driver can use to keep OBP | ||
20 | * XXX informed about the current resolution setting. The idea | ||
21 | * XXX is that the kernel can change resolutions, and as long | ||
22 | * XXX as the values in the 'dev-comm' area are accurate then | ||
23 | * XXX OBP can still render text properly to the console. | ||
24 | * XXX | ||
25 | * XXX I'm still working out the layout of this and whether there | ||
26 | * XXX are any signatures we need to look for etc. | ||
27 | */ | ||
28 | struct e3d_info { | ||
29 | struct fb_info *info; | ||
30 | struct pci_dev *pdev; | ||
31 | |||
32 | spinlock_t lock; | ||
33 | |||
34 | char __iomem *fb_base; | ||
35 | unsigned long fb_base_phys; | ||
36 | |||
37 | unsigned long fb8_buf_diff; | ||
38 | unsigned long regs_base_phys; | ||
39 | |||
40 | void __iomem *ramdac; | ||
41 | |||
42 | struct device_node *of_node; | ||
43 | |||
44 | unsigned int width; | ||
45 | unsigned int height; | ||
46 | unsigned int depth; | ||
47 | unsigned int fb_size; | ||
48 | |||
49 | u32 fb_base_reg; | ||
50 | u32 fb8_0_off; | ||
51 | u32 fb8_1_off; | ||
52 | |||
53 | u32 pseudo_palette[256]; | ||
54 | }; | ||
55 | |||
56 | static int __devinit e3d_get_props(struct e3d_info *ep) | ||
57 | { | ||
58 | ep->width = of_getintprop_default(ep->of_node, "width", 0); | ||
59 | ep->height = of_getintprop_default(ep->of_node, "height", 0); | ||
60 | ep->depth = of_getintprop_default(ep->of_node, "depth", 8); | ||
61 | |||
62 | if (!ep->width || !ep->height) { | ||
63 | printk(KERN_ERR "e3d: Critical properties missing for %s\n", | ||
64 | pci_name(ep->pdev)); | ||
65 | return -EINVAL; | ||
66 | } | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | /* My XVR-500 comes up, at 1280x768 and a FB base register value of | ||
72 | * 0x04000000, the following video layout register values: | ||
73 | * | ||
74 | * RAMDAC_VID_WH 0x03ff04ff | ||
75 | * RAMDAC_VID_CFG 0x1a0b0088 | ||
76 | * RAMDAC_VID_32FB_0 0x04000000 | ||
77 | * RAMDAC_VID_32FB_1 0x04800000 | ||
78 | * RAMDAC_VID_8FB_0 0x05000000 | ||
79 | * RAMDAC_VID_8FB_1 0x05200000 | ||
80 | * RAMDAC_VID_XXXFB 0x05400000 | ||
81 | * RAMDAC_VID_YYYFB 0x05c00000 | ||
82 | * RAMDAC_VID_ZZZFB 0x05e00000 | ||
83 | */ | ||
84 | /* Video layout registers */ | ||
85 | #define RAMDAC_VID_WH 0x00000070UL /* (height-1)<<16 | (width-1) */ | ||
86 | #define RAMDAC_VID_CFG 0x00000074UL /* 0x1a000088|(linesz_log2<<16) */ | ||
87 | #define RAMDAC_VID_32FB_0 0x00000078UL /* PCI base 32bpp FB buffer 0 */ | ||
88 | #define RAMDAC_VID_32FB_1 0x0000007cUL /* PCI base 32bpp FB buffer 1 */ | ||
89 | #define RAMDAC_VID_8FB_0 0x00000080UL /* PCI base 8bpp FB buffer 0 */ | ||
90 | #define RAMDAC_VID_8FB_1 0x00000084UL /* PCI base 8bpp FB buffer 1 */ | ||
91 | #define RAMDAC_VID_XXXFB 0x00000088UL /* PCI base of XXX FB */ | ||
92 | #define RAMDAC_VID_YYYFB 0x0000008cUL /* PCI base of YYY FB */ | ||
93 | #define RAMDAC_VID_ZZZFB 0x00000090UL /* PCI base of ZZZ FB */ | ||
94 | |||
95 | /* CLUT registers */ | ||
96 | #define RAMDAC_INDEX 0x000000bcUL | ||
97 | #define RAMDAC_DATA 0x000000c0UL | ||
98 | |||
99 | static void e3d_clut_write(struct e3d_info *ep, int index, u32 val) | ||
100 | { | ||
101 | void __iomem *ramdac = ep->ramdac; | ||
102 | unsigned long flags; | ||
103 | |||
104 | spin_lock_irqsave(&ep->lock, flags); | ||
105 | |||
106 | writel(index, ramdac + RAMDAC_INDEX); | ||
107 | writel(val, ramdac + RAMDAC_DATA); | ||
108 | |||
109 | spin_unlock_irqrestore(&ep->lock, flags); | ||
110 | } | ||
111 | |||
112 | static int e3d_setcolreg(unsigned regno, | ||
113 | unsigned red, unsigned green, unsigned blue, | ||
114 | unsigned transp, struct fb_info *info) | ||
115 | { | ||
116 | struct e3d_info *ep = info->par; | ||
117 | u32 red_8, green_8, blue_8; | ||
118 | u32 red_10, green_10, blue_10; | ||
119 | u32 value; | ||
120 | |||
121 | if (regno >= 256) | ||
122 | return 1; | ||
123 | |||
124 | red_8 = red >> 8; | ||
125 | green_8 = green >> 8; | ||
126 | blue_8 = blue >> 8; | ||
127 | |||
128 | value = (blue_8 << 24) | (green_8 << 16) | (red_8 << 8); | ||
129 | ((u32 *)info->pseudo_palette)[regno] = value; | ||
130 | |||
131 | |||
132 | red_10 = red >> 6; | ||
133 | green_10 = green >> 6; | ||
134 | blue_10 = blue >> 6; | ||
135 | |||
136 | value = (blue_10 << 20) | (green_10 << 10) | (red_10 << 0); | ||
137 | e3d_clut_write(ep, regno, value); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | /* XXX This is a bit of a hack. I can't figure out exactly how the | ||
143 | * XXX two 8bpp areas of the framebuffer work. I imagine there is | ||
144 | * XXX a WID attribute somewhere else in the framebuffer which tells | ||
145 | * XXX the ramdac which of the two 8bpp framebuffer regions to take | ||
146 | * XXX the pixel from. So, for now, render into both regions to make | ||
147 | * XXX sure the pixel shows up. | ||
148 | */ | ||
149 | static void e3d_imageblit(struct fb_info *info, const struct fb_image *image) | ||
150 | { | ||
151 | struct e3d_info *ep = info->par; | ||
152 | unsigned long flags; | ||
153 | |||
154 | spin_lock_irqsave(&ep->lock, flags); | ||
155 | cfb_imageblit(info, image); | ||
156 | info->screen_base += ep->fb8_buf_diff; | ||
157 | cfb_imageblit(info, image); | ||
158 | info->screen_base -= ep->fb8_buf_diff; | ||
159 | spin_unlock_irqrestore(&ep->lock, flags); | ||
160 | } | ||
161 | |||
162 | static void e3d_fillrect(struct fb_info *info, const struct fb_fillrect *rect) | ||
163 | { | ||
164 | struct e3d_info *ep = info->par; | ||
165 | unsigned long flags; | ||
166 | |||
167 | spin_lock_irqsave(&ep->lock, flags); | ||
168 | cfb_fillrect(info, rect); | ||
169 | info->screen_base += ep->fb8_buf_diff; | ||
170 | cfb_fillrect(info, rect); | ||
171 | info->screen_base -= ep->fb8_buf_diff; | ||
172 | spin_unlock_irqrestore(&ep->lock, flags); | ||
173 | } | ||
174 | |||
175 | static void e3d_copyarea(struct fb_info *info, const struct fb_copyarea *area) | ||
176 | { | ||
177 | struct e3d_info *ep = info->par; | ||
178 | unsigned long flags; | ||
179 | |||
180 | spin_lock_irqsave(&ep->lock, flags); | ||
181 | cfb_copyarea(info, area); | ||
182 | info->screen_base += ep->fb8_buf_diff; | ||
183 | cfb_copyarea(info, area); | ||
184 | info->screen_base -= ep->fb8_buf_diff; | ||
185 | spin_unlock_irqrestore(&ep->lock, flags); | ||
186 | } | ||
187 | |||
188 | static struct fb_ops e3d_ops = { | ||
189 | .owner = THIS_MODULE, | ||
190 | .fb_setcolreg = e3d_setcolreg, | ||
191 | .fb_fillrect = e3d_fillrect, | ||
192 | .fb_copyarea = e3d_copyarea, | ||
193 | .fb_imageblit = e3d_imageblit, | ||
194 | }; | ||
195 | |||
196 | static int __devinit e3d_set_fbinfo(struct e3d_info *ep) | ||
197 | { | ||
198 | struct fb_info *info = ep->info; | ||
199 | struct fb_var_screeninfo *var = &info->var; | ||
200 | |||
201 | info->flags = FBINFO_DEFAULT; | ||
202 | info->fbops = &e3d_ops; | ||
203 | info->screen_base = ep->fb_base; | ||
204 | info->screen_size = ep->fb_size; | ||
205 | |||
206 | info->pseudo_palette = ep->pseudo_palette; | ||
207 | |||
208 | /* Fill fix common fields */ | ||
209 | strlcpy(info->fix.id, "e3d", sizeof(info->fix.id)); | ||
210 | info->fix.smem_start = ep->fb_base_phys; | ||
211 | info->fix.smem_len = ep->fb_size; | ||
212 | info->fix.type = FB_TYPE_PACKED_PIXELS; | ||
213 | if (ep->depth == 32 || ep->depth == 24) | ||
214 | info->fix.visual = FB_VISUAL_TRUECOLOR; | ||
215 | else | ||
216 | info->fix.visual = FB_VISUAL_PSEUDOCOLOR; | ||
217 | |||
218 | var->xres = ep->width; | ||
219 | var->yres = ep->height; | ||
220 | var->xres_virtual = var->xres; | ||
221 | var->yres_virtual = var->yres; | ||
222 | var->bits_per_pixel = ep->depth; | ||
223 | |||
224 | var->red.offset = 8; | ||
225 | var->red.length = 8; | ||
226 | var->green.offset = 16; | ||
227 | var->green.length = 8; | ||
228 | var->blue.offset = 24; | ||
229 | var->blue.length = 8; | ||
230 | var->transp.offset = 0; | ||
231 | var->transp.length = 0; | ||
232 | |||
233 | if (fb_alloc_cmap(&info->cmap, 256, 0)) { | ||
234 | printk(KERN_ERR "e3d: Cannot allocate color map.\n"); | ||
235 | return -ENOMEM; | ||
236 | } | ||
237 | |||
238 | return 0; | ||
239 | } | ||
240 | |||
241 | static int __devinit e3d_pci_register(struct pci_dev *pdev, | ||
242 | const struct pci_device_id *ent) | ||
243 | { | ||
244 | struct fb_info *info; | ||
245 | struct e3d_info *ep; | ||
246 | unsigned int line_length; | ||
247 | int err; | ||
248 | |||
249 | err = pci_enable_device(pdev); | ||
250 | if (err < 0) { | ||
251 | printk(KERN_ERR "e3d: Cannot enable PCI device %s\n", | ||
252 | pci_name(pdev)); | ||
253 | goto err_out; | ||
254 | } | ||
255 | |||
256 | info = framebuffer_alloc(sizeof(struct e3d_info), &pdev->dev); | ||
257 | if (!info) { | ||
258 | printk(KERN_ERR "e3d: Cannot allocate fb_info\n"); | ||
259 | err = -ENOMEM; | ||
260 | goto err_disable; | ||
261 | } | ||
262 | |||
263 | ep = info->par; | ||
264 | ep->info = info; | ||
265 | ep->pdev = pdev; | ||
266 | spin_lock_init(&ep->lock); | ||
267 | ep->of_node = pci_device_to_OF_node(pdev); | ||
268 | if (!ep->of_node) { | ||
269 | printk(KERN_ERR "e3d: Cannot find OF node of %s\n", | ||
270 | pci_name(pdev)); | ||
271 | err = -ENODEV; | ||
272 | goto err_release_fb; | ||
273 | } | ||
274 | |||
275 | /* Read the PCI base register of the frame buffer, which we | ||
276 | * need in order to interpret the RAMDAC_VID_*FB* values in | ||
277 | * the ramdac correctly. | ||
278 | */ | ||
279 | pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, | ||
280 | &ep->fb_base_reg); | ||
281 | ep->fb_base_reg &= PCI_BASE_ADDRESS_MEM_MASK; | ||
282 | |||
283 | ep->regs_base_phys = pci_resource_start (pdev, 1); | ||
284 | err = pci_request_region(pdev, 1, "e3d regs"); | ||
285 | if (err < 0) { | ||
286 | printk("e3d: Cannot request region 1 for %s\n", | ||
287 | pci_name(pdev)); | ||
288 | goto err_release_fb; | ||
289 | } | ||
290 | ep->ramdac = ioremap(ep->regs_base_phys + 0x8000, 0x1000); | ||
291 | if (!ep->ramdac) | ||
292 | goto err_release_pci1; | ||
293 | |||
294 | ep->fb8_0_off = readl(ep->ramdac + RAMDAC_VID_8FB_0); | ||
295 | ep->fb8_0_off -= ep->fb_base_reg; | ||
296 | |||
297 | ep->fb8_1_off = readl(ep->ramdac + RAMDAC_VID_8FB_1); | ||
298 | ep->fb8_1_off -= ep->fb_base_reg; | ||
299 | |||
300 | ep->fb8_buf_diff = ep->fb8_1_off - ep->fb8_0_off; | ||
301 | |||
302 | ep->fb_base_phys = pci_resource_start (pdev, 0); | ||
303 | ep->fb_base_phys += ep->fb8_0_off; | ||
304 | |||
305 | err = pci_request_region(pdev, 0, "e3d framebuffer"); | ||
306 | if (err < 0) { | ||
307 | printk("e3d: Cannot request region 0 for %s\n", | ||
308 | pci_name(pdev)); | ||
309 | goto err_unmap_ramdac; | ||
310 | } | ||
311 | |||
312 | err = e3d_get_props(ep); | ||
313 | if (err) | ||
314 | goto err_release_pci0; | ||
315 | |||
316 | line_length = (readl(ep->ramdac + RAMDAC_VID_CFG) >> 16) & 0xff; | ||
317 | line_length = 1 << line_length; | ||
318 | |||
319 | switch (ep->depth) { | ||
320 | case 8: | ||
321 | info->fix.line_length = line_length; | ||
322 | break; | ||
323 | case 16: | ||
324 | info->fix.line_length = line_length * 2; | ||
325 | break; | ||
326 | case 24: | ||
327 | info->fix.line_length = line_length * 3; | ||
328 | break; | ||
329 | case 32: | ||
330 | info->fix.line_length = line_length * 4; | ||
331 | break; | ||
332 | } | ||
333 | ep->fb_size = info->fix.line_length * ep->height; | ||
334 | |||
335 | ep->fb_base = ioremap(ep->fb_base_phys, ep->fb_size); | ||
336 | if (!ep->fb_base) | ||
337 | goto err_release_pci0; | ||
338 | |||
339 | err = e3d_set_fbinfo(ep); | ||
340 | if (err) | ||
341 | goto err_unmap_fb; | ||
342 | |||
343 | pci_set_drvdata(pdev, info); | ||
344 | |||
345 | printk("e3d: Found device at %s\n", pci_name(pdev)); | ||
346 | |||
347 | err = register_framebuffer(info); | ||
348 | if (err < 0) { | ||
349 | printk(KERN_ERR "e3d: Could not register framebuffer %s\n", | ||
350 | pci_name(pdev)); | ||
351 | goto err_unmap_fb; | ||
352 | } | ||
353 | |||
354 | return 0; | ||
355 | |||
356 | err_unmap_fb: | ||
357 | iounmap(ep->fb_base); | ||
358 | |||
359 | err_release_pci0: | ||
360 | pci_release_region(pdev, 0); | ||
361 | |||
362 | err_unmap_ramdac: | ||
363 | iounmap(ep->ramdac); | ||
364 | |||
365 | err_release_pci1: | ||
366 | pci_release_region(pdev, 1); | ||
367 | |||
368 | err_release_fb: | ||
369 | framebuffer_release(info); | ||
370 | |||
371 | err_disable: | ||
372 | pci_disable_device(pdev); | ||
373 | |||
374 | err_out: | ||
375 | return err; | ||
376 | } | ||
377 | |||
378 | static void __devexit e3d_pci_unregister(struct pci_dev *pdev) | ||
379 | { | ||
380 | struct fb_info *info = pci_get_drvdata(pdev); | ||
381 | struct e3d_info *ep = info->par; | ||
382 | |||
383 | unregister_framebuffer(info); | ||
384 | |||
385 | iounmap(ep->ramdac); | ||
386 | iounmap(ep->fb_base); | ||
387 | |||
388 | pci_release_region(pdev, 0); | ||
389 | pci_release_region(pdev, 1); | ||
390 | |||
391 | framebuffer_release(info); | ||
392 | |||
393 | pci_disable_device(pdev); | ||
394 | } | ||
395 | |||
396 | static struct pci_device_id e3d_pci_table[] = { | ||
397 | { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x7a0), }, | ||
398 | { PCI_DEVICE(PCI_VENDOR_ID_3DLABS, 0x7a2), }, | ||
399 | { .vendor = PCI_VENDOR_ID_3DLABS, | ||
400 | .device = PCI_ANY_ID, | ||
401 | .subvendor = PCI_VENDOR_ID_3DLABS, | ||
402 | .subdevice = 0x0108, | ||
403 | }, | ||
404 | { .vendor = PCI_VENDOR_ID_3DLABS, | ||
405 | .device = PCI_ANY_ID, | ||
406 | .subvendor = PCI_VENDOR_ID_3DLABS, | ||
407 | .subdevice = 0x0140, | ||
408 | }, | ||
409 | { .vendor = PCI_VENDOR_ID_3DLABS, | ||
410 | .device = PCI_ANY_ID, | ||
411 | .subvendor = PCI_VENDOR_ID_3DLABS, | ||
412 | .subdevice = 0x1024, | ||
413 | }, | ||
414 | { 0, } | ||
415 | }; | ||
416 | |||
417 | static struct pci_driver e3d_driver = { | ||
418 | .name = "e3d", | ||
419 | .id_table = e3d_pci_table, | ||
420 | .probe = e3d_pci_register, | ||
421 | .remove = __devexit_p(e3d_pci_unregister), | ||
422 | }; | ||
423 | |||
424 | static int __init e3d_init(void) | ||
425 | { | ||
426 | if (fb_get_options("e3d", NULL)) | ||
427 | return -ENODEV; | ||
428 | |||
429 | return pci_register_driver(&e3d_driver); | ||
430 | } | ||
431 | |||
432 | static void __exit e3d_exit(void) | ||
433 | { | ||
434 | pci_unregister_driver(&e3d_driver); | ||
435 | } | ||
436 | |||
437 | module_init(e3d_init); | ||
438 | module_exit(e3d_exit); | ||
439 | |||
440 | MODULE_DESCRIPTION("framebuffer driver for Sun XVR-500 graphics"); | ||
441 | MODULE_AUTHOR("David S. Miller <davem@davemloft.net>"); | ||
442 | MODULE_VERSION("1.0"); | ||
443 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/valkyriefb.c b/drivers/video/valkyriefb.c index 06fc19a61192..ad66f070acb8 100644 --- a/drivers/video/valkyriefb.c +++ b/drivers/video/valkyriefb.c | |||
@@ -51,7 +51,6 @@ | |||
51 | #include <linux/fb.h> | 51 | #include <linux/fb.h> |
52 | #include <linux/selection.h> | 52 | #include <linux/selection.h> |
53 | #include <linux/init.h> | 53 | #include <linux/init.h> |
54 | #include <linux/pci.h> | ||
55 | #include <linux/nvram.h> | 54 | #include <linux/nvram.h> |
56 | #include <linux/adb.h> | 55 | #include <linux/adb.h> |
57 | #include <linux/cuda.h> | 56 | #include <linux/cuda.h> |