diff options
-rw-r--r-- | drivers/gpu/vga/vga_switcheroo.c | 13 | ||||
-rw-r--r-- | include/linux/vga_switcheroo.h | 7 |
2 files changed, 20 insertions, 0 deletions
diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c index 38f9534ac513..eb4f64f0a565 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; |
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h index b455c7c212eb..b176342ca031 100644 --- a/include/linux/vga_switcheroo.h +++ b/include/linux/vga_switcheroo.h | |||
@@ -12,6 +12,9 @@ | |||
12 | enum vga_switcheroo_state { | 12 | enum vga_switcheroo_state { |
13 | VGA_SWITCHEROO_OFF, | 13 | VGA_SWITCHEROO_OFF, |
14 | VGA_SWITCHEROO_ON, | 14 | VGA_SWITCHEROO_ON, |
15 | /* below are referred only from vga_switcheroo_get_client_state() */ | ||
16 | VGA_SWITCHEROO_INIT, | ||
17 | VGA_SWITCHEROO_NOT_FOUND, | ||
15 | }; | 18 | }; |
16 | 19 | ||
17 | enum vga_switcheroo_client_id { | 20 | enum vga_switcheroo_client_id { |
@@ -50,6 +53,8 @@ void vga_switcheroo_unregister_handler(void); | |||
50 | 53 | ||
51 | int vga_switcheroo_process_delayed_switch(void); | 54 | int vga_switcheroo_process_delayed_switch(void); |
52 | 55 | ||
56 | int vga_switcheroo_get_client_state(struct pci_dev *dev); | ||
57 | |||
53 | #else | 58 | #else |
54 | 59 | ||
55 | static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {} | 60 | 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 | int id, bool active) { return 0; } | 67 | int id, bool active) { return 0; } |
63 | static inline void vga_switcheroo_unregister_handler(void) {} | 68 | static inline void vga_switcheroo_unregister_handler(void) {} |
64 | static inline int vga_switcheroo_process_delayed_switch(void) { return 0; } | 69 | static inline int vga_switcheroo_process_delayed_switch(void) { return 0; } |
70 | static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return VGA_SWITCHEROO_CLIENT_ON; } | ||
71 | |||
65 | 72 | ||
66 | #endif | 73 | #endif |