diff options
Diffstat (limited to 'drivers/gpu/vga/vga_switcheroo.c')
-rw-r--r-- | drivers/gpu/vga/vga_switcheroo.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c index 38f9534ac513..5b3c7d135dc9 100644 --- a/drivers/gpu/vga/vga_switcheroo.c +++ b/drivers/gpu/vga/vga_switcheroo.c | |||
@@ -190,6 +190,19 @@ find_active_client(struct list_head *head) | |||
190 | return NULL; | 190 | return NULL; |
191 | } | 191 | } |
192 | 192 | ||
193 | int vga_switcheroo_get_client_state(struct pci_dev *pdev) | ||
194 | { | ||
195 | struct vga_switcheroo_client *client; | ||
196 | |||
197 | client = find_client_from_pci(&vgasr_priv.clients, pdev); | ||
198 | if (!client) | ||
199 | return VGA_SWITCHEROO_NOT_FOUND; | ||
200 | if (!vgasr_priv.active) | ||
201 | return VGA_SWITCHEROO_INIT; | ||
202 | return client->pwr_state; | ||
203 | } | ||
204 | EXPORT_SYMBOL(vga_switcheroo_get_client_state); | ||
205 | |||
193 | void vga_switcheroo_unregister_client(struct pci_dev *pdev) | 206 | void vga_switcheroo_unregister_client(struct pci_dev *pdev) |
194 | { | 207 | { |
195 | struct vga_switcheroo_client *client; | 208 | struct vga_switcheroo_client *client; |
@@ -291,8 +304,6 @@ static int vga_switchto_stage1(struct vga_switcheroo_client *new_client) | |||
291 | vga_switchon(new_client); | 304 | vga_switchon(new_client); |
292 | 305 | ||
293 | vga_set_default_device(new_client->pdev); | 306 | vga_set_default_device(new_client->pdev); |
294 | set_audio_state(new_client->id, VGA_SWITCHEROO_ON); | ||
295 | |||
296 | return 0; | 307 | return 0; |
297 | } | 308 | } |
298 | 309 | ||
@@ -308,6 +319,8 @@ static int vga_switchto_stage2(struct vga_switcheroo_client *new_client) | |||
308 | 319 | ||
309 | active->active = false; | 320 | active->active = false; |
310 | 321 | ||
322 | set_audio_state(active->id, VGA_SWITCHEROO_OFF); | ||
323 | |||
311 | if (new_client->fb_info) { | 324 | if (new_client->fb_info) { |
312 | struct fb_event event; | 325 | struct fb_event event; |
313 | event.info = new_client->fb_info; | 326 | event.info = new_client->fb_info; |
@@ -321,11 +334,11 @@ static int vga_switchto_stage2(struct vga_switcheroo_client *new_client) | |||
321 | if (new_client->ops->reprobe) | 334 | if (new_client->ops->reprobe) |
322 | new_client->ops->reprobe(new_client->pdev); | 335 | new_client->ops->reprobe(new_client->pdev); |
323 | 336 | ||
324 | set_audio_state(active->id, VGA_SWITCHEROO_OFF); | ||
325 | |||
326 | if (active->pwr_state == VGA_SWITCHEROO_ON) | 337 | if (active->pwr_state == VGA_SWITCHEROO_ON) |
327 | vga_switchoff(active); | 338 | vga_switchoff(active); |
328 | 339 | ||
340 | set_audio_state(new_client->id, VGA_SWITCHEROO_ON); | ||
341 | |||
329 | new_client->active = true; | 342 | new_client->active = true; |
330 | return 0; | 343 | return 0; |
331 | } | 344 | } |
@@ -371,8 +384,9 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf, | |||
371 | /* pwr off the device not in use */ | 384 | /* pwr off the device not in use */ |
372 | if (strncmp(usercmd, "OFF", 3) == 0) { | 385 | if (strncmp(usercmd, "OFF", 3) == 0) { |
373 | list_for_each_entry(client, &vgasr_priv.clients, list) { | 386 | list_for_each_entry(client, &vgasr_priv.clients, list) { |
374 | if (client->active) | 387 | if (client->active || client_is_audio(client)) |
375 | continue; | 388 | continue; |
389 | set_audio_state(client->id, VGA_SWITCHEROO_OFF); | ||
376 | if (client->pwr_state == VGA_SWITCHEROO_ON) | 390 | if (client->pwr_state == VGA_SWITCHEROO_ON) |
377 | vga_switchoff(client); | 391 | vga_switchoff(client); |
378 | } | 392 | } |
@@ -381,10 +395,11 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf, | |||
381 | /* pwr on the device not in use */ | 395 | /* pwr on the device not in use */ |
382 | if (strncmp(usercmd, "ON", 2) == 0) { | 396 | if (strncmp(usercmd, "ON", 2) == 0) { |
383 | list_for_each_entry(client, &vgasr_priv.clients, list) { | 397 | list_for_each_entry(client, &vgasr_priv.clients, list) { |
384 | if (client->active) | 398 | if (client->active || client_is_audio(client)) |
385 | continue; | 399 | continue; |
386 | if (client->pwr_state == VGA_SWITCHEROO_OFF) | 400 | if (client->pwr_state == VGA_SWITCHEROO_OFF) |
387 | vga_switchon(client); | 401 | vga_switchon(client); |
402 | set_audio_state(client->id, VGA_SWITCHEROO_ON); | ||
388 | } | 403 | } |
389 | goto out; | 404 | goto out; |
390 | } | 405 | } |