diff options
author | Deepak Saxena <dsaxena@laptop.org> | 2010-04-08 13:15:41 -0400 |
---|---|---|
committer | Florian Tobias Schandinat <FlorianSchandinat@gmx.de> | 2010-10-24 09:04:46 -0400 |
commit | 3fd9b6cc38028ea64e9a39c6af9d5ad928594be6 (patch) | |
tree | c61d7bbb85d98cc78bd5e8011de8a52bac9e698f /drivers/video/via | |
parent | efd4f6398dc92b5bf392670df862f42a19f34cf2 (diff) |
Minimal support for viafb suspend/resume
This patch adds minimal support for suspend/resume of the
VIA framebuffer device. It requires a version of OFW
that restores the video mode.
This patch is OLPC-specific as the proper upstream solution
is to move the VIA video path to using the kernel modesetting
infrastructure and doing a proper save/restore in the kernel.
[jc: extensive changes for 2.6.34 merge]
Signed-off-by: Deepak Saxena <dsaxena@laptop.org>
[fts: viafb_driver moved from viafbdev.c to via-core.c]
Signed-off-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Acked-by: Jonathan Corbet <corbet@lwn.net>
Cc: Joseph Chan <JosephChan@via.com.tw>
Diffstat (limited to 'drivers/video/via')
-rw-r--r-- | drivers/video/via/via-core.c | 4 | ||||
-rw-r--r-- | drivers/video/via/viafbdev.c | 46 | ||||
-rw-r--r-- | drivers/video/via/viafbdev.h | 5 |
3 files changed, 55 insertions, 0 deletions
diff --git a/drivers/video/via/via-core.c b/drivers/video/via/via-core.c index 69101ab9f7c9..9b487a6a8d08 100644 --- a/drivers/video/via/via-core.c +++ b/drivers/video/via/via-core.c | |||
@@ -644,6 +644,10 @@ static struct pci_driver via_driver = { | |||
644 | .id_table = via_pci_table, | 644 | .id_table = via_pci_table, |
645 | .probe = via_pci_probe, | 645 | .probe = via_pci_probe, |
646 | .remove = __devexit_p(via_pci_remove), | 646 | .remove = __devexit_p(via_pci_remove), |
647 | #ifdef CONFIG_PM | ||
648 | .suspend = viafb_suspend, | ||
649 | .resume = viafb_resume, | ||
650 | #endif | ||
647 | }; | 651 | }; |
648 | 652 | ||
649 | static int __init via_core_init(void) | 653 | static int __init via_core_init(void) |
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c index 7cc057d7ef5e..596235b5a5f0 100644 --- a/drivers/video/via/viafbdev.c +++ b/drivers/video/via/viafbdev.c | |||
@@ -1669,6 +1669,52 @@ static int parse_mode(const char *str, u32 *xres, u32 *yres) | |||
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | 1671 | ||
1672 | #ifdef CONFIG_PM | ||
1673 | int viafb_suspend(struct pci_dev *pdev, pm_message_t state) | ||
1674 | { | ||
1675 | if (state.event == PM_EVENT_SUSPEND) { | ||
1676 | acquire_console_sem(); | ||
1677 | |||
1678 | memcpy_fromio(viaparinfo->shared->saved_regs, | ||
1679 | viaparinfo->shared->vdev->engine_mmio + 0x100, | ||
1680 | 0xff * sizeof(u32)); | ||
1681 | |||
1682 | fb_set_suspend(viafbinfo, 1); | ||
1683 | |||
1684 | viafb_sync(viafbinfo); | ||
1685 | |||
1686 | pci_save_state(pdev); | ||
1687 | pci_disable_device(pdev); | ||
1688 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); | ||
1689 | release_console_sem(); | ||
1690 | } | ||
1691 | |||
1692 | return 0; | ||
1693 | } | ||
1694 | |||
1695 | int viafb_resume(struct pci_dev *pdev) | ||
1696 | { | ||
1697 | acquire_console_sem(); | ||
1698 | pci_set_power_state(pdev, PCI_D0); | ||
1699 | pci_restore_state(pdev); | ||
1700 | if (pci_enable_device(pdev)) | ||
1701 | goto fail; | ||
1702 | pci_set_master(pdev); | ||
1703 | |||
1704 | memcpy_toio(viaparinfo->shared->vdev->engine_mmio + 0x100, | ||
1705 | viaparinfo->shared->saved_regs, | ||
1706 | 0x100 * sizeof(u32)); | ||
1707 | |||
1708 | fb_set_suspend(viafbinfo, 0); | ||
1709 | |||
1710 | fail: | ||
1711 | release_console_sem(); | ||
1712 | return 0; | ||
1713 | } | ||
1714 | |||
1715 | #endif | ||
1716 | |||
1717 | |||
1672 | int __devinit via_fb_pci_probe(struct viafb_dev *vdev) | 1718 | int __devinit via_fb_pci_probe(struct viafb_dev *vdev) |
1673 | { | 1719 | { |
1674 | u32 default_xres, default_yres; | 1720 | u32 default_xres, default_yres; |
diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h index d66f963e930e..29a8c6c769ec 100644 --- a/drivers/video/via/viafbdev.h +++ b/drivers/video/via/viafbdev.h | |||
@@ -62,6 +62,9 @@ struct viafb_shared { | |||
62 | u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y, | 62 | u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y, |
63 | u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y, | 63 | u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y, |
64 | u32 fg_color, u32 bg_color, u8 fill_rop); | 64 | u32 fg_color, u32 bg_color, u8 fill_rop); |
65 | |||
66 | /* For suspend/resume */ | ||
67 | u32 saved_regs[0x100]; | ||
65 | }; | 68 | }; |
66 | 69 | ||
67 | struct viafb_par { | 70 | struct viafb_par { |
@@ -108,4 +111,6 @@ void via_fb_pci_remove(struct pci_dev *pdev); | |||
108 | /* Temporary */ | 111 | /* Temporary */ |
109 | int viafb_init(void); | 112 | int viafb_init(void); |
110 | void viafb_exit(void); | 113 | void viafb_exit(void); |
114 | int viafb_suspend(struct pci_dev *pdev, pm_message_t state); | ||
115 | int viafb_resume(struct pci_dev *pdev); | ||
111 | #endif /* __VIAFBDEV_H__ */ | 116 | #endif /* __VIAFBDEV_H__ */ |