diff options
-rw-r--r-- | drivers/gpu/vga/vga_switcheroo.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c index faa57e546138..c7771466595f 100644 --- a/drivers/gpu/vga/vga_switcheroo.c +++ b/drivers/gpu/vga/vga_switcheroo.c | |||
@@ -169,7 +169,8 @@ int vga_switcheroo_register_client(struct pci_dev *pdev, | |||
169 | bool driver_power_control) | 169 | bool driver_power_control) |
170 | { | 170 | { |
171 | return register_client(pdev, ops, -1, | 171 | return register_client(pdev, ops, -1, |
172 | pdev == vga_default_device(), driver_power_control); | 172 | pdev == vga_default_device(), |
173 | driver_power_control); | ||
173 | } | 174 | } |
174 | EXPORT_SYMBOL(vga_switcheroo_register_client); | 175 | EXPORT_SYMBOL(vga_switcheroo_register_client); |
175 | 176 | ||
@@ -185,6 +186,7 @@ static struct vga_switcheroo_client * | |||
185 | find_client_from_pci(struct list_head *head, struct pci_dev *pdev) | 186 | find_client_from_pci(struct list_head *head, struct pci_dev *pdev) |
186 | { | 187 | { |
187 | struct vga_switcheroo_client *client; | 188 | struct vga_switcheroo_client *client; |
189 | |||
188 | list_for_each_entry(client, head, list) | 190 | list_for_each_entry(client, head, list) |
189 | if (client->pdev == pdev) | 191 | if (client->pdev == pdev) |
190 | return client; | 192 | return client; |
@@ -195,6 +197,7 @@ static struct vga_switcheroo_client * | |||
195 | find_client_from_id(struct list_head *head, int client_id) | 197 | find_client_from_id(struct list_head *head, int client_id) |
196 | { | 198 | { |
197 | struct vga_switcheroo_client *client; | 199 | struct vga_switcheroo_client *client; |
200 | |||
198 | list_for_each_entry(client, head, list) | 201 | list_for_each_entry(client, head, list) |
199 | if (client->id == client_id) | 202 | if (client->id == client_id) |
200 | return client; | 203 | return client; |
@@ -205,6 +208,7 @@ static struct vga_switcheroo_client * | |||
205 | find_active_client(struct list_head *head) | 208 | find_active_client(struct list_head *head) |
206 | { | 209 | { |
207 | struct vga_switcheroo_client *client; | 210 | struct vga_switcheroo_client *client; |
211 | |||
208 | list_for_each_entry(client, head, list) | 212 | list_for_each_entry(client, head, list) |
209 | if (client->active && client_is_vga(client)) | 213 | if (client->active && client_is_vga(client)) |
210 | return client; | 214 | return client; |
@@ -262,10 +266,12 @@ static int vga_switcheroo_show(struct seq_file *m, void *v) | |||
262 | { | 266 | { |
263 | struct vga_switcheroo_client *client; | 267 | struct vga_switcheroo_client *client; |
264 | int i = 0; | 268 | int i = 0; |
269 | |||
265 | mutex_lock(&vgasr_mutex); | 270 | mutex_lock(&vgasr_mutex); |
266 | list_for_each_entry(client, &vgasr_priv.clients, list) { | 271 | list_for_each_entry(client, &vgasr_priv.clients, list) { |
267 | seq_printf(m, "%d:%s%s:%c:%s%s:%s\n", i, | 272 | seq_printf(m, "%d:%s%s:%c:%s%s:%s\n", i, |
268 | client_id(client) == VGA_SWITCHEROO_DIS ? "DIS" : "IGD", | 273 | client_id(client) == VGA_SWITCHEROO_DIS ? "DIS" : |
274 | "IGD", | ||
269 | client_is_vga(client) ? "" : "-Audio", | 275 | client_is_vga(client) ? "" : "-Audio", |
270 | client->active ? '+' : ' ', | 276 | client->active ? '+' : ' ', |
271 | client->driver_power_control ? "Dyn" : "", | 277 | client->driver_power_control ? "Dyn" : "", |
@@ -349,6 +355,7 @@ static int vga_switchto_stage2(struct vga_switcheroo_client *new_client) | |||
349 | 355 | ||
350 | if (new_client->fb_info) { | 356 | if (new_client->fb_info) { |
351 | struct fb_event event; | 357 | struct fb_event event; |
358 | |||
352 | console_lock(); | 359 | console_lock(); |
353 | event.info = new_client->fb_info; | 360 | event.info = new_client->fb_info; |
354 | fb_notifier_call_chain(FB_EVENT_REMAP_ALL_CONSOLE, &event); | 361 | fb_notifier_call_chain(FB_EVENT_REMAP_ALL_CONSOLE, &event); |
@@ -543,7 +550,8 @@ static int vga_switcheroo_debugfs_init(struct vgasr_priv *priv) | |||
543 | } | 550 | } |
544 | 551 | ||
545 | priv->switch_file = debugfs_create_file("switch", 0644, | 552 | priv->switch_file = debugfs_create_file("switch", 0644, |
546 | priv->debugfs_root, NULL, &vga_switcheroo_debugfs_fops); | 553 | priv->debugfs_root, NULL, |
554 | &vga_switcheroo_debugfs_fops); | ||
547 | if (!priv->switch_file) { | 555 | if (!priv->switch_file) { |
548 | pr_err("cannot create %s/vgaswitcheroo/switch\n", mp); | 556 | pr_err("cannot create %s/vgaswitcheroo/switch\n", mp); |
549 | goto fail; | 557 | goto fail; |
@@ -584,7 +592,8 @@ err: | |||
584 | } | 592 | } |
585 | EXPORT_SYMBOL(vga_switcheroo_process_delayed_switch); | 593 | EXPORT_SYMBOL(vga_switcheroo_process_delayed_switch); |
586 | 594 | ||
587 | static void vga_switcheroo_power_switch(struct pci_dev *pdev, enum vga_switcheroo_state state) | 595 | static void vga_switcheroo_power_switch(struct pci_dev *pdev, |
596 | enum vga_switcheroo_state state) | ||
588 | { | 597 | { |
589 | struct vga_switcheroo_client *client; | 598 | struct vga_switcheroo_client *client; |
590 | 599 | ||
@@ -603,7 +612,8 @@ static void vga_switcheroo_power_switch(struct pci_dev *pdev, enum vga_switchero | |||
603 | 612 | ||
604 | /* force a PCI device to a certain state - mainly to turn off audio clients */ | 613 | /* force a PCI device to a certain state - mainly to turn off audio clients */ |
605 | 614 | ||
606 | void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) | 615 | void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, |
616 | enum vga_switcheroo_state dynamic) | ||
607 | { | 617 | { |
608 | struct vga_switcheroo_client *client; | 618 | struct vga_switcheroo_client *client; |
609 | 619 | ||
@@ -649,7 +659,8 @@ static int vga_switcheroo_runtime_resume(struct device *dev) | |||
649 | 659 | ||
650 | /* this version is for the case where the power switch is separate | 660 | /* this version is for the case where the power switch is separate |
651 | to the device being powered down. */ | 661 | to the device being powered down. */ |
652 | int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) | 662 | int vga_switcheroo_init_domain_pm_ops(struct device *dev, |
663 | struct dev_pm_domain *domain) | ||
653 | { | 664 | { |
654 | /* copy over all the bus versions */ | 665 | /* copy over all the bus versions */ |
655 | if (dev->bus && dev->bus->pm) { | 666 | if (dev->bus && dev->bus->pm) { |
@@ -680,7 +691,8 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev) | |||
680 | /* we need to check if we have to switch back on the video | 691 | /* we need to check if we have to switch back on the video |
681 | device so the audio device can come back */ | 692 | device so the audio device can come back */ |
682 | list_for_each_entry(client, &vgasr_priv.clients, list) { | 693 | list_for_each_entry(client, &vgasr_priv.clients, list) { |
683 | if (PCI_SLOT(client->pdev->devfn) == PCI_SLOT(pdev->devfn) && client_is_vga(client)) { | 694 | if (PCI_SLOT(client->pdev->devfn) == PCI_SLOT(pdev->devfn) && |
695 | client_is_vga(client)) { | ||
684 | found = client; | 696 | found = client; |
685 | ret = pm_runtime_get_sync(&client->pdev->dev); | 697 | ret = pm_runtime_get_sync(&client->pdev->dev); |
686 | if (ret) { | 698 | if (ret) { |
@@ -700,12 +712,15 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev) | |||
700 | return ret; | 712 | return ret; |
701 | } | 713 | } |
702 | 714 | ||
703 | int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) | 715 | int |
716 | vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, | ||
717 | struct dev_pm_domain *domain) | ||
704 | { | 718 | { |
705 | /* copy over all the bus versions */ | 719 | /* copy over all the bus versions */ |
706 | if (dev->bus && dev->bus->pm) { | 720 | if (dev->bus && dev->bus->pm) { |
707 | domain->ops = *dev->bus->pm; | 721 | domain->ops = *dev->bus->pm; |
708 | domain->ops.runtime_resume = vga_switcheroo_runtime_resume_hdmi_audio; | 722 | domain->ops.runtime_resume = |
723 | vga_switcheroo_runtime_resume_hdmi_audio; | ||
709 | 724 | ||
710 | dev->pm_domain = domain; | 725 | dev->pm_domain = domain; |
711 | return 0; | 726 | return 0; |