Commit c8e9cf7b authored by Takashi Iwai's avatar Takashi Iwai

vga_switcheroo: Add a helper function to get the client state

Add vga_switcheroo_get_client_state() to get the current state of the
client.  This is necessary to determine the proper initial state of
audio clients in HD-audio driver.
Acked-by: default avatarDave Airlie <airlied@redhat.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 8260ef07
...@@ -190,6 +190,19 @@ find_active_client(struct list_head *head) ...@@ -190,6 +190,19 @@ find_active_client(struct list_head *head)
return NULL; return NULL;
} }
int vga_switcheroo_get_client_state(struct pci_dev *pdev)
{
struct vga_switcheroo_client *client;
client = find_client_from_pci(&vgasr_priv.clients, pdev);
if (!client)
return VGA_SWITCHEROO_NOT_FOUND;
if (!vgasr_priv.active)
return VGA_SWITCHEROO_INIT;
return client->pwr_state;
}
EXPORT_SYMBOL(vga_switcheroo_get_client_state);
void vga_switcheroo_unregister_client(struct pci_dev *pdev) void vga_switcheroo_unregister_client(struct pci_dev *pdev)
{ {
struct vga_switcheroo_client *client; struct vga_switcheroo_client *client;
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
enum vga_switcheroo_state { enum vga_switcheroo_state {
VGA_SWITCHEROO_OFF, VGA_SWITCHEROO_OFF,
VGA_SWITCHEROO_ON, VGA_SWITCHEROO_ON,
/* below are referred only from vga_switcheroo_get_client_state() */
VGA_SWITCHEROO_INIT,
VGA_SWITCHEROO_NOT_FOUND,
}; };
enum vga_switcheroo_client_id { enum vga_switcheroo_client_id {
...@@ -50,6 +53,8 @@ void vga_switcheroo_unregister_handler(void); ...@@ -50,6 +53,8 @@ void vga_switcheroo_unregister_handler(void);
int vga_switcheroo_process_delayed_switch(void); int vga_switcheroo_process_delayed_switch(void);
int vga_switcheroo_get_client_state(struct pci_dev *dev);
#else #else
static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {} static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
...@@ -62,5 +67,7 @@ static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev, ...@@ -62,5 +67,7 @@ static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
int id, bool active) { return 0; } int id, bool active) { return 0; }
static inline void vga_switcheroo_unregister_handler(void) {} static inline void vga_switcheroo_unregister_handler(void) {}
static inline int vga_switcheroo_process_delayed_switch(void) { return 0; } static inline int vga_switcheroo_process_delayed_switch(void) { return 0; }
static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return VGA_SWITCHEROO_CLIENT_ON; }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment