2 * Copyright (c) 2010 Red Hat Inc.
3 * Author : Dave Airlie <airlied@redhat.com>
7 * vga_switcheroo.h - Support for laptop with dual GPU using one set of outputs
10 #ifndef _LINUX_VGA_SWITCHEROO_H_
11 #define _LINUX_VGA_SWITCHEROO_H_
17 enum vga_switcheroo_state {
20 /* below are referred only from vga_switcheroo_get_client_state() */
22 VGA_SWITCHEROO_NOT_FOUND,
25 enum vga_switcheroo_client_id {
28 VGA_SWITCHEROO_MAX_CLIENTS,
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);
36 int (*get_client_id)(struct pci_dev *pdev);
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);
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,
48 const struct vga_switcheroo_client_ops *ops,
49 bool driver_power_control);
50 int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
51 const struct vga_switcheroo_client_ops *ops,
54 void vga_switcheroo_client_fb_set(struct pci_dev *dev,
55 struct fb_info *info);
57 int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler);
58 void vga_switcheroo_unregister_handler(void);
60 int vga_switcheroo_process_delayed_switch(void);
62 int vga_switcheroo_get_client_state(struct pci_dev *dev);
64 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
66 int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
67 int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
70 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
71 static inline int vga_switcheroo_register_client(struct pci_dev *dev,
72 const struct vga_switcheroo_client_ops *ops, bool driver_power_control) { return 0; }
73 static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {}
74 static inline int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler) { return 0; }
75 static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
76 const struct vga_switcheroo_client_ops *ops,
77 int id, bool active) { return 0; }
78 static inline void vga_switcheroo_unregister_handler(void) {}
79 static inline int vga_switcheroo_process_delayed_switch(void) { return 0; }
80 static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return VGA_SWITCHEROO_ON; }
82 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
84 static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
85 static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
88 #endif /* _LINUX_VGA_SWITCHEROO_H_ */