]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
Minimal support for viafb suspend/resume
authorDeepak Saxena <dsaxena@laptop.org>
Thu, 8 Apr 2010 17:15:41 +0000 (11:15 -0600)
committerFlorian Tobias Schandinat <FlorianSchandinat@gmx.de>
Sun, 24 Oct 2010 13:04:46 +0000 (13:04 +0000)
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>
drivers/video/via/via-core.c
drivers/video/via/viafbdev.c
drivers/video/via/viafbdev.h

index 69101ab9f7c9e8a38f46ee0086aab453a6ec8b5a..9b487a6a8d0875c1d8cdf6d222e8685ebd0f3e59 100644 (file)
@@ -644,6 +644,10 @@ static struct pci_driver via_driver = {
        .id_table       = via_pci_table,
        .probe          = via_pci_probe,
        .remove         = __devexit_p(via_pci_remove),
+#ifdef CONFIG_PM
+       .suspend        = viafb_suspend,
+       .resume         = viafb_resume,
+#endif
 };
 
 static int __init via_core_init(void)
index 7cc057d7ef5e530ab50697641e999fc78bfa07d4..596235b5a5f0ee195884482b9790ffaea9da7f94 100644 (file)
@@ -1669,6 +1669,52 @@ static int parse_mode(const char *str, u32 *xres, u32 *yres)
 }
 
 
+#ifdef CONFIG_PM
+int viafb_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+       if (state.event == PM_EVENT_SUSPEND) {
+               acquire_console_sem();
+
+               memcpy_fromio(viaparinfo->shared->saved_regs,
+                             viaparinfo->shared->vdev->engine_mmio + 0x100,
+                             0xff * sizeof(u32));
+
+               fb_set_suspend(viafbinfo, 1);
+
+               viafb_sync(viafbinfo);
+
+               pci_save_state(pdev);
+               pci_disable_device(pdev);
+               pci_set_power_state(pdev, pci_choose_state(pdev, state));
+               release_console_sem();
+       }
+
+       return 0;
+}
+
+int viafb_resume(struct pci_dev *pdev)
+{
+       acquire_console_sem();
+       pci_set_power_state(pdev, PCI_D0);
+       pci_restore_state(pdev);
+       if (pci_enable_device(pdev))
+               goto fail;
+       pci_set_master(pdev);
+
+       memcpy_toio(viaparinfo->shared->vdev->engine_mmio + 0x100,
+                   viaparinfo->shared->saved_regs,
+                   0x100 * sizeof(u32));
+
+       fb_set_suspend(viafbinfo, 0);
+
+fail:
+       release_console_sem();
+       return 0;
+}
+
+#endif
+
+
 int __devinit via_fb_pci_probe(struct viafb_dev *vdev)
 {
        u32 default_xres, default_yres;
index d66f963e930e3d2791e004b120b6a98b8b5dec92..29a8c6c769ec7943dc3d145d775d2e8a65fa103f 100644 (file)
@@ -62,6 +62,9 @@ struct viafb_shared {
                u8 dst_bpp, u32 dst_addr, u32 dst_pitch, u32 dst_x, u32 dst_y,
                u32 *src_mem, u32 src_addr, u32 src_pitch, u32 src_x, u32 src_y,
                u32 fg_color, u32 bg_color, u8 fill_rop);
+
+       /* For suspend/resume */
+       u32 saved_regs[0x100];
 };
 
 struct viafb_par {
@@ -108,4 +111,6 @@ void via_fb_pci_remove(struct pci_dev *pdev);
 /* Temporary */
 int viafb_init(void);
 void viafb_exit(void);
+int viafb_suspend(struct pci_dev *pdev, pm_message_t state);
+int viafb_resume(struct pci_dev *pdev);
 #endif /* __VIAFBDEV_H__ */