Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2010 Red Hat Inc. |
| 3 | * Author : Dave Airlie <airlied@redhat.com> |
| 4 | * |
| 5 | * Licensed under GPLv2 |
| 6 | * |
| 7 | * vga_switcheroo.h - Support for laptop with dual GPU using one set of outputs |
| 8 | */ |
| 9 | |
Ozan Çağlayan | d3decf3 | 2012-06-14 15:02:35 +0300 | [diff] [blame] | 10 | #ifndef _LINUX_VGA_SWITCHEROO_H_ |
| 11 | #define _LINUX_VGA_SWITCHEROO_H_ |
| 12 | |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 13 | #include <linux/fb.h> |
| 14 | |
Randy Dunlap | f8fee8f | 2012-06-15 12:46:17 -0700 | [diff] [blame] | 15 | struct pci_dev; |
| 16 | |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 17 | enum vga_switcheroo_state { |
| 18 | VGA_SWITCHEROO_OFF, |
| 19 | VGA_SWITCHEROO_ON, |
Takashi Iwai | c8e9cf7 | 2012-06-07 12:15:15 +0200 | [diff] [blame] | 20 | /* below are referred only from vga_switcheroo_get_client_state() */ |
| 21 | VGA_SWITCHEROO_INIT, |
| 22 | VGA_SWITCHEROO_NOT_FOUND, |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | enum vga_switcheroo_client_id { |
| 26 | VGA_SWITCHEROO_IGD, |
| 27 | VGA_SWITCHEROO_DIS, |
| 28 | VGA_SWITCHEROO_MAX_CLIENTS, |
| 29 | }; |
| 30 | |
| 31 | struct vga_switcheroo_handler { |
| 32 | int (*switchto)(enum vga_switcheroo_client_id id); |
| 33 | int (*power_state)(enum vga_switcheroo_client_id id, |
| 34 | enum vga_switcheroo_state state); |
| 35 | int (*init)(void); |
| 36 | int (*get_client_id)(struct pci_dev *pdev); |
| 37 | }; |
| 38 | |
Takashi Iwai | 26ec685 | 2012-05-11 07:51:17 +0200 | [diff] [blame] | 39 | struct vga_switcheroo_client_ops { |
| 40 | void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state); |
| 41 | void (*reprobe)(struct pci_dev *dev); |
| 42 | bool (*can_switch)(struct pci_dev *dev); |
| 43 | }; |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 44 | |
| 45 | #if defined(CONFIG_VGA_SWITCHEROO) |
| 46 | void vga_switcheroo_unregister_client(struct pci_dev *dev); |
| 47 | int vga_switcheroo_register_client(struct pci_dev *dev, |
Dave Airlie | 0d69704 | 2012-09-10 12:28:36 +1000 | [diff] [blame] | 48 | const struct vga_switcheroo_client_ops *ops, |
| 49 | bool driver_power_control); |
Takashi Iwai | 3e9e63d | 2012-04-26 14:29:48 +0200 | [diff] [blame] | 50 | int vga_switcheroo_register_audio_client(struct pci_dev *pdev, |
| 51 | const struct vga_switcheroo_client_ops *ops, |
| 52 | int id, bool active); |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 53 | |
| 54 | void vga_switcheroo_client_fb_set(struct pci_dev *dev, |
| 55 | struct fb_info *info); |
| 56 | |
| 57 | int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler); |
| 58 | void vga_switcheroo_unregister_handler(void); |
| 59 | |
| 60 | int vga_switcheroo_process_delayed_switch(void); |
| 61 | |
Takashi Iwai | c8e9cf7 | 2012-06-07 12:15:15 +0200 | [diff] [blame] | 62 | int vga_switcheroo_get_client_state(struct pci_dev *dev); |
| 63 | |
Dave Airlie | 0d69704 | 2012-09-10 12:28:36 +1000 | [diff] [blame] | 64 | void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic); |
| 65 | |
| 66 | int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain); |
Alex Deucher | 766a53d | 2014-09-12 17:51:29 -0400 | [diff] [blame] | 67 | void vga_switcheroo_fini_domain_pm_ops(struct device *dev); |
Dave Airlie | 0d69704 | 2012-09-10 12:28:36 +1000 | [diff] [blame] | 68 | int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain); |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 69 | #else |
| 70 | |
| 71 | static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {} |
| 72 | static inline int vga_switcheroo_register_client(struct pci_dev *dev, |
Dave Airlie | 0d69704 | 2012-09-10 12:28:36 +1000 | [diff] [blame] | 73 | const struct vga_switcheroo_client_ops *ops, bool driver_power_control) { return 0; } |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 74 | static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {} |
| 75 | static inline int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler) { return 0; } |
Takashi Iwai | 3e9e63d | 2012-04-26 14:29:48 +0200 | [diff] [blame] | 76 | static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev, |
| 77 | const struct vga_switcheroo_client_ops *ops, |
| 78 | int id, bool active) { return 0; } |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 79 | static inline void vga_switcheroo_unregister_handler(void) {} |
| 80 | static inline int vga_switcheroo_process_delayed_switch(void) { return 0; } |
Takashi Iwai | 505cff0 | 2012-06-08 12:49:17 +0200 | [diff] [blame] | 81 | static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return VGA_SWITCHEROO_ON; } |
Takashi Iwai | c8e9cf7 | 2012-06-07 12:15:15 +0200 | [diff] [blame] | 82 | |
Dave Airlie | 0d69704 | 2012-09-10 12:28:36 +1000 | [diff] [blame] | 83 | static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {} |
| 84 | |
| 85 | static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; } |
Alex Deucher | 766a53d | 2014-09-12 17:51:29 -0400 | [diff] [blame] | 86 | static inline void vga_switcheroo_fini_domain_pm_ops(struct device *dev) {} |
Dave Airlie | 0d69704 | 2012-09-10 12:28:36 +1000 | [diff] [blame] | 87 | static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; } |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 88 | |
| 89 | #endif |
Ozan Çağlayan | d3decf3 | 2012-06-14 15:02:35 +0300 | [diff] [blame] | 90 | #endif /* _LINUX_VGA_SWITCHEROO_H_ */ |