diff options
author | Antonino A. Daplas <adaplas@gmail.com> | 2007-05-08 03:38:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:29 -0400 |
commit | 22d832edcace45b26ced76efef6c863449e4e060 (patch) | |
tree | 155190ea0e8d4b1504c754d272518cd9da147771 /drivers/video/savage | |
parent | f7829158bce2c8180bf7a1cb922cad812d3a2788 (diff) |
savagefb: VGA state save and restore
Allow the saving and restoration of VGA text mode. The state is saved on the
first open and restored on the last close. Because of the VGA registers are
linearly mapped to the MMIO space, MMIO access is used which is not limited to
X86 platforms nor to the primary display device.
An echo 0 > /sys/class/vtconsole/vtcon1/bind will convert the display from
graphics to text mode.
Signed-off-by: Antonino Daplas <adaplas@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/savage')
-rw-r--r-- | drivers/video/savage/savagefb.h | 10 | ||||
-rw-r--r-- | drivers/video/savage/savagefb_driver.c | 39 |
2 files changed, 47 insertions, 2 deletions
diff --git a/drivers/video/savage/savagefb.h b/drivers/video/savage/savagefb.h index e648a6c0f6d9..8bfdfc3c5234 100644 --- a/drivers/video/savage/savagefb.h +++ b/drivers/video/savage/savagefb.h | |||
@@ -15,6 +15,8 @@ | |||
15 | #include <linux/i2c.h> | 15 | #include <linux/i2c.h> |
16 | #include <linux/i2c-id.h> | 16 | #include <linux/i2c-id.h> |
17 | #include <linux/i2c-algo-bit.h> | 17 | #include <linux/i2c-algo-bit.h> |
18 | #include <linux/mutex.h> | ||
19 | #include <video/vga.h> | ||
18 | #include "../edid.h" | 20 | #include "../edid.h" |
19 | 21 | ||
20 | #ifdef SAVAGEFB_DEBUG | 22 | #ifdef SAVAGEFB_DEBUG |
@@ -189,8 +191,12 @@ struct savagefb_par { | |||
189 | struct savagefb_i2c_chan chan; | 191 | struct savagefb_i2c_chan chan; |
190 | struct savage_reg state; | 192 | struct savage_reg state; |
191 | struct savage_reg save; | 193 | struct savage_reg save; |
194 | struct savage_reg initial; | ||
195 | struct vgastate vgastate; | ||
196 | struct mutex open_lock; | ||
192 | unsigned char *edid; | 197 | unsigned char *edid; |
193 | u32 pseudo_palette[16]; | 198 | u32 pseudo_palette[16]; |
199 | u32 open_count; | ||
194 | int paletteEnabled; | 200 | int paletteEnabled; |
195 | int pm_state; | 201 | int pm_state; |
196 | int display_type; | 202 | int display_type; |
@@ -203,7 +209,7 @@ struct savagefb_par { | |||
203 | int clock[4]; | 209 | int clock[4]; |
204 | int MCLK, REFCLK, LCDclk; | 210 | int MCLK, REFCLK, LCDclk; |
205 | struct { | 211 | struct { |
206 | u8 __iomem *vbase; | 212 | void __iomem *vbase; |
207 | u32 pbase; | 213 | u32 pbase; |
208 | u32 len; | 214 | u32 len; |
209 | #ifdef CONFIG_MTRR | 215 | #ifdef CONFIG_MTRR |
@@ -212,7 +218,7 @@ struct savagefb_par { | |||
212 | } video; | 218 | } video; |
213 | 219 | ||
214 | struct { | 220 | struct { |
215 | volatile u8 __iomem *vbase; | 221 | void __iomem *vbase; |
216 | u32 pbase; | 222 | u32 pbase; |
217 | u32 len; | 223 | u32 len; |
218 | } mmio; | 224 | } mmio; |
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c index 0166ec2ccf32..3d7507ad55f6 100644 --- a/drivers/video/savage/savagefb_driver.c +++ b/drivers/video/savage/savagefb_driver.c | |||
@@ -1623,8 +1623,46 @@ static void savagefb_restore_state(struct fb_info *info) | |||
1623 | savagefb_blank(FB_BLANK_UNBLANK, info); | 1623 | savagefb_blank(FB_BLANK_UNBLANK, info); |
1624 | } | 1624 | } |
1625 | 1625 | ||
1626 | static int savagefb_open(struct fb_info *info, int user) | ||
1627 | { | ||
1628 | struct savagefb_par *par = info->par; | ||
1629 | |||
1630 | mutex_lock(&par->open_lock); | ||
1631 | |||
1632 | if (!par->open_count) { | ||
1633 | memset(&par->vgastate, 0, sizeof(par->vgastate)); | ||
1634 | par->vgastate.flags = VGA_SAVE_CMAP | VGA_SAVE_FONTS | | ||
1635 | VGA_SAVE_MODE; | ||
1636 | par->vgastate.vgabase = par->mmio.vbase + 0x8000; | ||
1637 | save_vga(&par->vgastate); | ||
1638 | savage_get_default_par(par, &par->initial); | ||
1639 | } | ||
1640 | |||
1641 | par->open_count++; | ||
1642 | mutex_unlock(&par->open_lock); | ||
1643 | return 0; | ||
1644 | } | ||
1645 | |||
1646 | static int savagefb_release(struct fb_info *info, int user) | ||
1647 | { | ||
1648 | struct savagefb_par *par = info->par; | ||
1649 | |||
1650 | mutex_lock(&par->open_lock); | ||
1651 | |||
1652 | if (par->open_count == 1) { | ||
1653 | savage_set_default_par(par, &par->initial); | ||
1654 | restore_vga(&par->vgastate); | ||
1655 | } | ||
1656 | |||
1657 | par->open_count--; | ||
1658 | mutex_unlock(&par->open_lock); | ||
1659 | return 0; | ||
1660 | } | ||
1661 | |||
1626 | static struct fb_ops savagefb_ops = { | 1662 | static struct fb_ops savagefb_ops = { |
1627 | .owner = THIS_MODULE, | 1663 | .owner = THIS_MODULE, |
1664 | .fb_open = savagefb_open, | ||
1665 | .fb_release = savagefb_release, | ||
1628 | .fb_check_var = savagefb_check_var, | 1666 | .fb_check_var = savagefb_check_var, |
1629 | .fb_set_par = savagefb_set_par, | 1667 | .fb_set_par = savagefb_set_par, |
1630 | .fb_setcolreg = savagefb_setcolreg, | 1668 | .fb_setcolreg = savagefb_setcolreg, |
@@ -2173,6 +2211,7 @@ static int __devinit savagefb_probe(struct pci_dev* dev, | |||
2173 | if (!info) | 2211 | if (!info) |
2174 | return -ENOMEM; | 2212 | return -ENOMEM; |
2175 | par = info->par; | 2213 | par = info->par; |
2214 | mutex_init(&par->open_lock); | ||
2176 | err = pci_enable_device(dev); | 2215 | err = pci_enable_device(dev); |
2177 | if (err) | 2216 | if (err) |
2178 | goto failed_enable; | 2217 | goto failed_enable; |