blob: b483abd344934f9cb9827d112883bfdf8e861d2b [file] [log] [blame]
Dave Airlie6a9ee8a2010-02-01 15:38:10 +10001/*
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ğlayand3decf32012-06-14 15:02:35 +030010#ifndef _LINUX_VGA_SWITCHEROO_H_
11#define _LINUX_VGA_SWITCHEROO_H_
12
Dave Airlie6a9ee8a2010-02-01 15:38:10 +100013#include <linux/fb.h>
14
Randy Dunlapf8fee8f2012-06-15 12:46:17 -070015struct pci_dev;
16
Dave Airlie6a9ee8a2010-02-01 15:38:10 +100017enum vga_switcheroo_state {
18 VGA_SWITCHEROO_OFF,
19 VGA_SWITCHEROO_ON,
Takashi Iwaic8e9cf72012-06-07 12:15:15 +020020 /* below are referred only from vga_switcheroo_get_client_state() */
21 VGA_SWITCHEROO_INIT,
22 VGA_SWITCHEROO_NOT_FOUND,
Dave Airlie6a9ee8a2010-02-01 15:38:10 +100023};
24
25enum vga_switcheroo_client_id {
26 VGA_SWITCHEROO_IGD,
27 VGA_SWITCHEROO_DIS,
28 VGA_SWITCHEROO_MAX_CLIENTS,
29};
30
31struct 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 Iwai26ec6852012-05-11 07:51:17 +020039struct 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 Airlie6a9ee8a2010-02-01 15:38:10 +100044
45#if defined(CONFIG_VGA_SWITCHEROO)
46void vga_switcheroo_unregister_client(struct pci_dev *dev);
47int vga_switcheroo_register_client(struct pci_dev *dev,
Dave Airlie0d697042012-09-10 12:28:36 +100048 const struct vga_switcheroo_client_ops *ops,
49 bool driver_power_control);
Takashi Iwai3e9e63d2012-04-26 14:29:48 +020050int vga_switcheroo_register_audio_client(struct pci_dev *pdev,
51 const struct vga_switcheroo_client_ops *ops,
52 int id, bool active);
Dave Airlie6a9ee8a2010-02-01 15:38:10 +100053
54void vga_switcheroo_client_fb_set(struct pci_dev *dev,
55 struct fb_info *info);
56
57int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler);
58void vga_switcheroo_unregister_handler(void);
59
60int vga_switcheroo_process_delayed_switch(void);
61
Takashi Iwaic8e9cf72012-06-07 12:15:15 +020062int vga_switcheroo_get_client_state(struct pci_dev *dev);
63
Dave Airlie0d697042012-09-10 12:28:36 +100064void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
65
66int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
Alex Deucher766a53d2014-09-12 17:51:29 -040067void vga_switcheroo_fini_domain_pm_ops(struct device *dev);
Dave Airlie0d697042012-09-10 12:28:36 +100068int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
Dave Airlie6a9ee8a2010-02-01 15:38:10 +100069#else
70
71static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
72static inline int vga_switcheroo_register_client(struct pci_dev *dev,
Dave Airlie0d697042012-09-10 12:28:36 +100073 const struct vga_switcheroo_client_ops *ops, bool driver_power_control) { return 0; }
Dave Airlie6a9ee8a2010-02-01 15:38:10 +100074static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {}
75static inline int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler) { return 0; }
Takashi Iwai3e9e63d2012-04-26 14:29:48 +020076static 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 Airlie6a9ee8a2010-02-01 15:38:10 +100079static inline void vga_switcheroo_unregister_handler(void) {}
80static inline int vga_switcheroo_process_delayed_switch(void) { return 0; }
Takashi Iwai505cff02012-06-08 12:49:17 +020081static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return VGA_SWITCHEROO_ON; }
Takashi Iwaic8e9cf72012-06-07 12:15:15 +020082
Dave Airlie0d697042012-09-10 12:28:36 +100083static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
84
85static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
Alex Deucher766a53d2014-09-12 17:51:29 -040086static inline void vga_switcheroo_fini_domain_pm_ops(struct device *dev) {}
Dave Airlie0d697042012-09-10 12:28:36 +100087static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
Dave Airlie6a9ee8a2010-02-01 15:38:10 +100088
89#endif
Ozan Çağlayand3decf32012-06-14 15:02:35 +030090#endif /* _LINUX_VGA_SWITCHEROO_H_ */