Lines Matching full:client
74 * register as a client so that vga_switcheroo can take care of the correct
77 * client (on the discrete GPU). The code is mostly prepared to support
81 * active client in vga_switcheroo parlance. The GPU not in use is the
82 * inactive client. When the inactive client's DRM driver is loaded,
86 * a client may alternatively request that the DDC lines are temporarily
93 * struct vga_switcheroo_client - registered client
94 * @pdev: client pci device
98 * @ops: client callbacks
99 * @id: client identifier. Determining the id requires the handler,
102 * @active: whether the outputs are currently switched to this client
106 * @list: client list
107 * @vga_dev: pci device, indicate which GPU is bound to current audio client
109 * Registered client. A client can be either a GPU or an audio device on a GPU.
135 * @delayed_client_id: client to which a delayed switch is pending
144 * @old_ddc_owner: client to which DDC lines will be switched back on unlock
189 struct vga_switcheroo_client *client; in vga_switcheroo_enable() local
195 list_for_each_entry(client, &vgasr_priv.clients, list) { in vga_switcheroo_enable()
196 if (!client_is_vga(client) || in vga_switcheroo_enable()
197 client_id(client) != VGA_SWITCHEROO_UNKNOWN_ID) in vga_switcheroo_enable()
200 ret = vgasr_priv.handler->get_client_id(client->pdev); in vga_switcheroo_enable()
204 client->id = ret; in vga_switcheroo_enable()
207 list_for_each_entry(client, &vgasr_priv.clients, list) { in vga_switcheroo_enable()
208 if (!client_is_audio(client) || in vga_switcheroo_enable()
209 client_id(client) != VGA_SWITCHEROO_UNKNOWN_ID) in vga_switcheroo_enable()
212 ret = vgasr_priv.handler->get_client_id(client->vga_dev); in vga_switcheroo_enable()
216 client->id = ret | ID_BIT_AUDIO; in vga_switcheroo_enable()
217 if (client->ops->gpu_bound) in vga_switcheroo_enable()
218 client->ops->gpu_bound(client->pdev, ret); in vga_switcheroo_enable()
298 struct vga_switcheroo_client *client; in register_client() local
300 client = kzalloc(sizeof(*client), GFP_KERNEL); in register_client()
301 if (!client) in register_client()
304 client->pwr_state = VGA_SWITCHEROO_ON; in register_client()
305 client->pdev = pdev; in register_client()
306 client->ops = ops; in register_client()
307 client->id = id; in register_client()
308 client->active = active; in register_client()
309 client->driver_power_control = driver_power_control; in register_client()
310 client->vga_dev = vga_dev; in register_client()
313 list_add_tail(&client->list, &vgasr_priv.clients); in register_client()
314 if (client_is_vga(client)) in register_client()
326 * vga_switcheroo_register_client - register vga client
327 * @pdev: client pci device
328 * @ops: client callbacks
332 * Register vga client (GPU). Enable vga_switcheroo if another GPU and a
333 * handler have already registered. The power state of the client is assumed
350 * vga_switcheroo_register_audio_client - register audio client
351 * @pdev: client pci device
352 * @ops: client callbacks
353 * @vga_dev: pci device which is bound to current audio client
355 * Register audio client (audio device on a GPU). The client is assumed
360 * client id error.
370 * handler are registered. Get audio client id from bound GPU client in vga_switcheroo_register_audio_client()
396 struct vga_switcheroo_client *client; in find_client_from_pci() local
398 list_for_each_entry(client, head, list) in find_client_from_pci()
399 if (client->pdev == pdev) in find_client_from_pci()
400 return client; in find_client_from_pci()
408 struct vga_switcheroo_client *client; in find_client_from_id() local
410 list_for_each_entry(client, head, list) in find_client_from_id()
411 if (client->id == client_id) in find_client_from_id()
412 return client; in find_client_from_id()
419 struct vga_switcheroo_client *client; in find_active_client() local
421 list_for_each_entry(client, head, list) in find_active_client()
422 if (client->active) in find_active_client()
423 return client; in find_active_client()
428 * vga_switcheroo_client_probe_defer() - whether to defer probing a given client
429 * @pdev: client pci device
432 * client. Drivers shall invoke this early on in their ->probe callback
434 * register the client ere thou hast called this.
455 vga_switcheroo_pwr_state(struct vga_switcheroo_client *client) in vga_switcheroo_pwr_state() argument
457 if (client->driver_power_control) in vga_switcheroo_pwr_state()
458 if (pm_runtime_enabled(&client->pdev->dev) && in vga_switcheroo_pwr_state()
459 pm_runtime_active(&client->pdev->dev)) in vga_switcheroo_pwr_state()
464 return client->pwr_state; in vga_switcheroo_pwr_state()
468 * vga_switcheroo_get_client_state() - obtain power state of a given client
469 * @pdev: client pci device
471 * Obtain power state of a given client as seen from vga_switcheroo.
478 struct vga_switcheroo_client *client; in vga_switcheroo_get_client_state() local
482 client = find_client_from_pci(&vgasr_priv.clients, pdev); in vga_switcheroo_get_client_state()
483 if (!client) in vga_switcheroo_get_client_state()
486 ret = vga_switcheroo_pwr_state(client); in vga_switcheroo_get_client_state()
493 * vga_switcheroo_unregister_client() - unregister client
494 * @pdev: client pci device
496 * Unregister client. Disable vga_switcheroo if this is a vga client (GPU).
500 struct vga_switcheroo_client *client; in vga_switcheroo_unregister_client() local
503 client = find_client_from_pci(&vgasr_priv.clients, pdev); in vga_switcheroo_unregister_client()
504 if (client) { in vga_switcheroo_unregister_client()
505 if (client_is_vga(client)) in vga_switcheroo_unregister_client()
507 list_del(&client->list); in vga_switcheroo_unregister_client()
508 kfree(client); in vga_switcheroo_unregister_client()
520 * vga_switcheroo_client_fb_set() - set framebuffer of a given client
521 * @pdev: client pci device
524 * Set framebuffer of a given client. The console will be remapped to this
530 struct vga_switcheroo_client *client; in vga_switcheroo_client_fb_set() local
533 client = find_client_from_pci(&vgasr_priv.clients, pdev); in vga_switcheroo_client_fb_set()
534 if (client) in vga_switcheroo_client_fb_set()
535 client->fb_info = info; in vga_switcheroo_client_fb_set()
541 * vga_switcheroo_lock_ddc() - temporarily switch DDC lines to a given client
542 * @pdev: client pci device
544 * Temporarily switch DDC lines to the client identified by @pdev
546 * This allows the inactive client to probe EDID. The DDC lines must
577 * @pdev: client pci device
583 * Return: Previous DDC owner on success (i.e. the client identifier of @pdev)
624 * have opened device files of the GPUs or the audio client. If the
630 * closed the device files of the GPUs and the audio client.
648 struct vga_switcheroo_client *client; in vga_switcheroo_show() local
652 list_for_each_entry(client, &vgasr_priv.clients, list) { in vga_switcheroo_show()
654 client_id(client) == VGA_SWITCHEROO_DIS ? "DIS" : in vga_switcheroo_show()
656 client_is_vga(client) ? "" : "-Audio", in vga_switcheroo_show()
657 client->active ? '+' : ' ', in vga_switcheroo_show()
658 client->driver_power_control ? "Dyn" : "", in vga_switcheroo_show()
659 vga_switcheroo_pwr_state(client) ? "Pwr" : "Off", in vga_switcheroo_show()
660 pci_name(client->pdev)); in vga_switcheroo_show()
672 static int vga_switchon(struct vga_switcheroo_client *client) in vga_switchon() argument
674 if (client->driver_power_control) in vga_switchon()
677 vgasr_priv.handler->power_state(client->id, VGA_SWITCHEROO_ON); in vga_switchon()
679 client->ops->set_gpu_state(client->pdev, VGA_SWITCHEROO_ON); in vga_switchon()
680 client->pwr_state = VGA_SWITCHEROO_ON; in vga_switchon()
684 static int vga_switchoff(struct vga_switcheroo_client *client) in vga_switchoff() argument
686 if (client->driver_power_control) in vga_switchoff()
689 client->ops->set_gpu_state(client->pdev, VGA_SWITCHEROO_OFF); in vga_switchoff()
691 vgasr_priv.handler->power_state(client->id, VGA_SWITCHEROO_OFF); in vga_switchoff()
692 client->pwr_state = VGA_SWITCHEROO_OFF; in vga_switchoff()
699 struct vga_switcheroo_client *client; in set_audio_state() local
701 client = find_client_from_id(&vgasr_priv.clients, id | ID_BIT_AUDIO); in set_audio_state()
702 if (client) in set_audio_state()
703 client->ops->set_gpu_state(client->pdev, state); in set_audio_state()
763 struct vga_switcheroo_client *client; in check_can_switch() local
765 list_for_each_entry(client, &vgasr_priv.clients, list) { in check_can_switch()
766 if (!client->ops->can_switch(client->pdev)) { in check_can_switch()
767 pr_err("client %x refused switch\n", client->id); in check_can_switch()
783 struct vga_switcheroo_client *client = NULL; in vga_switcheroo_debugfs_write() local
800 list_for_each_entry(client, &vgasr_priv.clients, list) { in vga_switcheroo_debugfs_write()
801 if (client->active || client_is_audio(client)) in vga_switcheroo_debugfs_write()
803 if (client->driver_power_control) in vga_switcheroo_debugfs_write()
805 set_audio_state(client->id, VGA_SWITCHEROO_OFF); in vga_switcheroo_debugfs_write()
806 if (client->pwr_state == VGA_SWITCHEROO_ON) in vga_switcheroo_debugfs_write()
807 vga_switchoff(client); in vga_switcheroo_debugfs_write()
813 list_for_each_entry(client, &vgasr_priv.clients, list) { in vga_switcheroo_debugfs_write()
814 if (client->active || client_is_audio(client)) in vga_switcheroo_debugfs_write()
816 if (client->driver_power_control) in vga_switcheroo_debugfs_write()
818 if (client->pwr_state == VGA_SWITCHEROO_OFF) in vga_switcheroo_debugfs_write()
819 vga_switchon(client); in vga_switcheroo_debugfs_write()
820 set_audio_state(client->id, VGA_SWITCHEROO_ON); in vga_switcheroo_debugfs_write()
853 client = find_client_from_id(&vgasr_priv.clients, client_id); in vga_switcheroo_debugfs_write()
854 if (!client) in vga_switcheroo_debugfs_write()
866 if (client->active) in vga_switcheroo_debugfs_write()
876 ret = vga_switchto_stage1(client); in vga_switcheroo_debugfs_write()
880 ret = vga_switchto_stage2(client); in vga_switcheroo_debugfs_write()
885 pr_info("setting delayed switch to client %d\n", client->id); in vga_switcheroo_debugfs_write()
889 ret = vga_switchto_stage1(client); in vga_switcheroo_debugfs_write()
931 * Return: 0 on success. -EINVAL if no delayed switch is pending, if the client
937 struct vga_switcheroo_client *client; in vga_switcheroo_process_delayed_switch() local
948 client = find_client_from_id(&vgasr_priv.clients, in vga_switcheroo_process_delayed_switch()
950 if (!client || !check_can_switch()) in vga_switcheroo_process_delayed_switch()
953 ret = vga_switchto_stage2(client); in vga_switcheroo_process_delayed_switch()
997 struct vga_switcheroo_client *client; in vga_switcheroo_power_switch() local
1002 client = find_client_from_pci(&vgasr_priv.clients, pdev); in vga_switcheroo_power_switch()
1003 if (!client) in vga_switcheroo_power_switch()
1006 if (!client->driver_power_control) in vga_switcheroo_power_switch()
1009 vgasr_priv.handler->power_state(client->id, state); in vga_switcheroo_power_switch()
1046 * @dev: vga client device