Lines Matching refs:vgasr_priv
149 struct vgasr_priv { struct
170 static void vga_switcheroo_debugfs_init(struct vgasr_priv *priv); argument
171 static void vga_switcheroo_debugfs_fini(struct vgasr_priv *priv);
174 static struct vgasr_priv vgasr_priv = { variable
175 .clients = LIST_HEAD_INIT(vgasr_priv.clients),
176 .mux_hw_lock = __MUTEX_INITIALIZER(vgasr_priv.mux_hw_lock),
182 return !vgasr_priv.active && in vga_switcheroo_ready()
183 vgasr_priv.registered_clients == 2 && vgasr_priv.handler; in vga_switcheroo_ready()
192 if (vgasr_priv.handler->init) in vga_switcheroo_enable()
193 vgasr_priv.handler->init(); in vga_switcheroo_enable()
195 list_for_each_entry(client, &vgasr_priv.clients, list) { in vga_switcheroo_enable()
200 ret = vgasr_priv.handler->get_client_id(client->pdev); in vga_switcheroo_enable()
207 list_for_each_entry(client, &vgasr_priv.clients, list) { in vga_switcheroo_enable()
212 ret = vgasr_priv.handler->get_client_id(client->vga_dev); in vga_switcheroo_enable()
221 vga_switcheroo_debugfs_init(&vgasr_priv); in vga_switcheroo_enable()
222 vgasr_priv.active = true; in vga_switcheroo_enable()
240 if (vgasr_priv.handler) { in vga_switcheroo_register_handler()
245 vgasr_priv.handler = handler; in vga_switcheroo_register_handler()
246 vgasr_priv.handler_flags = handler_flags; in vga_switcheroo_register_handler()
264 mutex_lock(&vgasr_priv.mux_hw_lock); in vga_switcheroo_unregister_handler()
265 vgasr_priv.handler_flags = 0; in vga_switcheroo_unregister_handler()
266 vgasr_priv.handler = NULL; in vga_switcheroo_unregister_handler()
267 if (vgasr_priv.active) { in vga_switcheroo_unregister_handler()
269 vga_switcheroo_debugfs_fini(&vgasr_priv); in vga_switcheroo_unregister_handler()
270 vgasr_priv.active = false; in vga_switcheroo_unregister_handler()
272 mutex_unlock(&vgasr_priv.mux_hw_lock); in vga_switcheroo_unregister_handler()
287 return vgasr_priv.handler_flags; in vga_switcheroo_handler_flags()
313 list_add_tail(&client->list, &vgasr_priv.clients); in register_client()
315 vgasr_priv.registered_clients++; in register_client()
376 if (vgasr_priv.active) { in vga_switcheroo_register_audio_client()
377 id = vgasr_priv.handler->get_client_id(vga_dev); in vga_switcheroo_register_audio_client()
446 !vgasr_priv.handler_flags) in vga_switcheroo_client_probe_defer()
482 client = find_client_from_pci(&vgasr_priv.clients, pdev); in vga_switcheroo_get_client_state()
503 client = find_client_from_pci(&vgasr_priv.clients, pdev); in vga_switcheroo_unregister_client()
506 vgasr_priv.registered_clients--; in vga_switcheroo_unregister_client()
510 if (vgasr_priv.active && vgasr_priv.registered_clients < 2) { in vga_switcheroo_unregister_client()
512 vga_switcheroo_debugfs_fini(&vgasr_priv); in vga_switcheroo_unregister_client()
513 vgasr_priv.active = false; in vga_switcheroo_unregister_client()
533 client = find_client_from_pci(&vgasr_priv.clients, pdev); in vga_switcheroo_client_fb_set()
563 mutex_lock(&vgasr_priv.mux_hw_lock); in vga_switcheroo_lock_ddc()
564 if (!vgasr_priv.handler || !vgasr_priv.handler->switch_ddc) { in vga_switcheroo_lock_ddc()
565 vgasr_priv.old_ddc_owner = -ENODEV; in vga_switcheroo_lock_ddc()
569 id = vgasr_priv.handler->get_client_id(pdev); in vga_switcheroo_lock_ddc()
570 vgasr_priv.old_ddc_owner = vgasr_priv.handler->switch_ddc(id); in vga_switcheroo_lock_ddc()
571 return vgasr_priv.old_ddc_owner; in vga_switcheroo_lock_ddc()
594 int ret = vgasr_priv.old_ddc_owner; in vga_switcheroo_unlock_ddc()
596 if (WARN_ON_ONCE(!mutex_is_locked(&vgasr_priv.mux_hw_lock))) in vga_switcheroo_unlock_ddc()
599 if (vgasr_priv.old_ddc_owner >= 0) { in vga_switcheroo_unlock_ddc()
600 id = vgasr_priv.handler->get_client_id(pdev); in vga_switcheroo_unlock_ddc()
601 if (vgasr_priv.old_ddc_owner != id) in vga_switcheroo_unlock_ddc()
602 ret = vgasr_priv.handler->switch_ddc( in vga_switcheroo_unlock_ddc()
603 vgasr_priv.old_ddc_owner); in vga_switcheroo_unlock_ddc()
605 mutex_unlock(&vgasr_priv.mux_hw_lock); in vga_switcheroo_unlock_ddc()
652 list_for_each_entry(client, &vgasr_priv.clients, list) { in vga_switcheroo_show()
676 if (vgasr_priv.handler->power_state) in vga_switchon()
677 vgasr_priv.handler->power_state(client->id, VGA_SWITCHEROO_ON); in vga_switchon()
690 if (vgasr_priv.handler->power_state) in vga_switchoff()
691 vgasr_priv.handler->power_state(client->id, VGA_SWITCHEROO_OFF); in vga_switchoff()
701 client = find_client_from_id(&vgasr_priv.clients, id | ID_BIT_AUDIO); in set_audio_state()
711 active = find_active_client(&vgasr_priv.clients); in vga_switchto_stage1()
728 active = find_active_client(&vgasr_priv.clients); in vga_switchto_stage2()
741 mutex_lock(&vgasr_priv.mux_hw_lock); in vga_switchto_stage2()
742 ret = vgasr_priv.handler->switchto(new_client->id); in vga_switchto_stage2()
743 mutex_unlock(&vgasr_priv.mux_hw_lock); in vga_switchto_stage2()
765 list_for_each_entry(client, &vgasr_priv.clients, list) { in check_can_switch()
793 if (!vgasr_priv.active) { in vga_switcheroo_debugfs_write()
800 list_for_each_entry(client, &vgasr_priv.clients, list) { in vga_switcheroo_debugfs_write()
813 list_for_each_entry(client, &vgasr_priv.clients, list) { in vga_switcheroo_debugfs_write()
853 client = find_client_from_id(&vgasr_priv.clients, client_id); in vga_switcheroo_debugfs_write()
857 vgasr_priv.delayed_switch_active = false; in vga_switcheroo_debugfs_write()
860 mutex_lock(&vgasr_priv.mux_hw_lock); in vga_switcheroo_debugfs_write()
861 ret = vgasr_priv.handler->switchto(client_id); in vga_switcheroo_debugfs_write()
862 mutex_unlock(&vgasr_priv.mux_hw_lock); in vga_switcheroo_debugfs_write()
886 vgasr_priv.delayed_switch_active = true; in vga_switcheroo_debugfs_write()
887 vgasr_priv.delayed_client_id = client_id; in vga_switcheroo_debugfs_write()
908 static void vga_switcheroo_debugfs_fini(struct vgasr_priv *priv) in vga_switcheroo_debugfs_fini()
914 static void vga_switcheroo_debugfs_init(struct vgasr_priv *priv) in vga_switcheroo_debugfs_init()
943 if (!vgasr_priv.delayed_switch_active) in vga_switcheroo_process_delayed_switch()
947 vgasr_priv.delayed_client_id); in vga_switcheroo_process_delayed_switch()
949 client = find_client_from_id(&vgasr_priv.clients, in vga_switcheroo_process_delayed_switch()
950 vgasr_priv.delayed_client_id); in vga_switcheroo_process_delayed_switch()
958 vgasr_priv.delayed_switch_active = false; in vga_switcheroo_process_delayed_switch()
1000 if (!vgasr_priv.handler->power_state) in vga_switcheroo_power_switch()
1003 client = find_client_from_pci(&vgasr_priv.clients, pdev); in vga_switcheroo_power_switch()
1010 vgasr_priv.handler->power_state(client->id, state); in vga_switcheroo_power_switch()
1023 if (vgasr_priv.handler->switchto) { in vga_switcheroo_runtime_suspend()
1024 mutex_lock(&vgasr_priv.mux_hw_lock); in vga_switcheroo_runtime_suspend()
1025 vgasr_priv.handler->switchto(VGA_SWITCHEROO_IGD); in vga_switcheroo_runtime_suspend()
1026 mutex_unlock(&vgasr_priv.mux_hw_lock); in vga_switcheroo_runtime_suspend()