Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 228831
b: refs/heads/master
c: 66b37c6
h: refs/heads/master
i:
  228829: ae3bdd4
  228827: dfacb0b
  228823: 2fb44ed
  228815: 5ed290d
  228799: e48b784
v: v3
  • Loading branch information
Dave Airlie committed Jan 5, 2011
1 parent bfd0728 commit 8b077f3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5bcf719b7db0f9366cedaf102b081f99b1c325ae
refs/heads/master: 66b37c6777c4686f121fe4a83176e535a7f4b1af
45 changes: 34 additions & 11 deletions trunk/drivers/gpu/vga/vga_switcheroo.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ static int vga_switchoff(struct vga_switcheroo_client *client)
return 0;
}

static int vga_switchto(struct vga_switcheroo_client *new_client)
/* stage one happens before delay */
static int vga_switchto_stage1(struct vga_switcheroo_client *new_client)
{
int ret;
int i;
Expand All @@ -239,10 +240,28 @@ static int vga_switchto(struct vga_switcheroo_client *new_client)
vga_switchon(new_client);

/* swap shadow resource to denote boot VGA device has changed so X starts on new device */
active->active = false;

active->pdev->resource[PCI_ROM_RESOURCE].flags &= ~IORESOURCE_ROM_SHADOW;
new_client->pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
return 0;
}

/* post delay */
static int vga_switchto_stage2(struct vga_switcheroo_client *new_client)
{
int ret;
int i;
struct vga_switcheroo_client *active = NULL;

for (i = 0; i < VGA_SWITCHEROO_MAX_CLIENTS; i++) {
if (vgasr_priv.clients[i].active == true) {
active = &vgasr_priv.clients[i];
break;
}
}
if (!active)
return 0;

active->active = false;

if (new_client->fb_info) {
struct fb_event event;
Expand Down Expand Up @@ -368,18 +387,22 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,

if (can_switch == true) {
pdev_name = pci_name(client->pdev);
ret = vga_switchto(client);
ret = vga_switchto_stage1(client);
if (ret)
printk(KERN_ERR "vga_switcheroo: switching failed stage 1 %d\n", ret);

ret = vga_switchto_stage2(client);
if (ret)
printk(KERN_ERR "vga_switcheroo: switching failed %d\n", ret);
printk(KERN_ERR "vga_switcheroo: switching failed stage 2 %d\n", ret);

} else {
printk(KERN_INFO "vga_switcheroo: setting delayed switch to client %d\n", client->id);
vgasr_priv.delayed_switch_active = true;
vgasr_priv.delayed_client_id = client_id;

/* we should at least power up the card to
make the switch faster */
if (client->pwr_state == VGA_SWITCHEROO_OFF)
vga_switchon(client);
ret = vga_switchto_stage1(client);
if (ret)
printk(KERN_ERR "vga_switcheroo: delayed switching stage 1 failed %d\n", ret);
}

out:
Expand Down Expand Up @@ -461,9 +484,9 @@ int vga_switcheroo_process_delayed_switch(void)
goto err;

pdev_name = pci_name(client->pdev);
ret = vga_switchto(client);
ret = vga_switchto_stage2(client);
if (ret)
printk(KERN_ERR "vga_switcheroo: delayed switching failed %d\n", ret);
printk(KERN_ERR "vga_switcheroo: delayed switching failed stage 2 %d\n", ret);

vgasr_priv.delayed_switch_active = false;
err = 0;
Expand Down

0 comments on commit 8b077f3

Please sign in to comment.