]> git.openfabrics.org - ~shefty/rdma-dev.git/blobdiff - drivers/video/via/viafbdev.c
Minimal support for viafb suspend/resume
[~shefty/rdma-dev.git] / drivers / video / via / viafbdev.c
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;