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 | |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 10 | #include <linux/fb.h> |
| 11 | |
| 12 | enum vga_switcheroo_state { |
| 13 | VGA_SWITCHEROO_OFF, |
| 14 | VGA_SWITCHEROO_ON, |
Takashi Iwai | c8e9cf7 | 2012-06-07 12:15:15 +0200 | [diff] [blame] | 15 | /* below are referred only from vga_switcheroo_get_client_state() */ |
| 16 | VGA_SWITCHEROO_INIT, |
| 17 | VGA_SWITCHEROO_NOT_FOUND, |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 18 | }; |
| 19 | |
| 20 | enum vga_switcheroo_client_id { |
| 21 | VGA_SWITCHEROO_IGD, |
| 22 | VGA_SWITCHEROO_DIS, |
| 23 | VGA_SWITCHEROO_MAX_CLIENTS, |
| 24 | }; |
| 25 | |
| 26 | struct vga_switcheroo_handler { |
| 27 | int (*switchto)(enum vga_switcheroo_client_id id); |
| 28 | int (*power_state)(enum vga_switcheroo_client_id id, |
| 29 | enum vga_switcheroo_state state); |
| 30 | int (*init)(void); |
| 31 | int (*get_client_id)(struct pci_dev *pdev); |
| 32 | }; |
| 33 | |
Takashi Iwai | 26ec685 | 2012-05-11 07:51:17 +0200 | [diff] [blame] | 34 | struct vga_switcheroo_client_ops { |
| 35 | void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state); |
| 36 | void (*reprobe)(struct pci_dev *dev); |
| 37 | bool (*can_switch)(struct pci_dev *dev); |
| 38 | }; |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 39 | |
| 40 | #if defined(CONFIG_VGA_SWITCHEROO) |
| 41 | void vga_switcheroo_unregister_client(struct pci_dev *dev); |
| 42 | int vga_switcheroo_register_client(struct pci_dev *dev, |
Takashi Iwai | 26ec685 | 2012-05-11 07:51:17 +0200 | [diff] [blame] | 43 | const struct vga_switcheroo_client_ops *ops); |
Takashi Iwai | 3e9e63d | 2012-04-26 14:29:48 +0200 | [diff] [blame] | 44 | int vga_switcheroo_register_audio_client(struct pci_dev *pdev, |
| 45 | const struct vga_switcheroo_client_ops *ops, |
| 46 | int id, bool active); |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 47 | |
| 48 | void vga_switcheroo_client_fb_set(struct pci_dev *dev, |
| 49 | struct fb_info *info); |
| 50 | |
| 51 | int vga_switcheroo_register_handler(struct vga_switcheroo_handler *handler); |
| 52 | void vga_switcheroo_unregister_handler(void); |
| 53 | |
| 54 | int vga_switcheroo_process_delayed_switch(void); |
| 55 | |
Takashi Iwai | c8e9cf7 | 2012-06-07 12:15:15 +0200 | [diff] [blame] | 56 | int vga_switcheroo_get_client_state(struct pci_dev *dev); |
| 57 | |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 58 | #else |
| 59 | |
| 60 | static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {} |
| 61 | static inline int vga_switcheroo_register_client(struct pci_dev *dev, |
Takashi Iwai | 26ec685 | 2012-05-11 07:51:17 +0200 | [diff] [blame] | 62 | const struct vga_switcheroo_client_ops *ops) { return 0; } |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 63 | static inline void vga_switcheroo_client_fb_set(struct pci_dev *dev, struct fb_info *info) {} |
| 64 | 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] | 65 | static inline int vga_switcheroo_register_audio_client(struct pci_dev *pdev, |
| 66 | const struct vga_switcheroo_client_ops *ops, |
| 67 | int id, bool active) { return 0; } |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 68 | static inline void vga_switcheroo_unregister_handler(void) {} |
| 69 | static inline int vga_switcheroo_process_delayed_switch(void) { return 0; } |
Takashi Iwai | 505cff0 | 2012-06-08 12:49:17 +0200 | [diff] [blame^] | 70 | 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] | 71 | |
Dave Airlie | 6a9ee8a | 2010-02-01 15:38:10 +1000 | [diff] [blame] | 72 | |
| 73 | #endif |