[PATCH 05/11] vga_switcheroo: Allow handlers to indicate that they can handle PM

Matthew Garrett matthew.garrett at nebula.com
Sun Jun 1 09:38:37 PDT 2014


Most switcheroo setups attach power management to one of the GPUs. This is
not always the case, so provide a mechanism for handlers to declare that
they can change the power state of GPUs and permit drivers to obtain this
information.

Signed-off-by: Matthew Garrett <matthew.garrett at nebula.com>
---
 drivers/gpu/vga/vga_switcheroo.c | 8 ++++++++
 include/linux/vga_switcheroo.h   | 5 +++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index 1a80b93..c5e97d4 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -825,6 +825,14 @@ struct edid *vga_switcheroo_get_edid(struct pci_dev *pdev)
 }
 EXPORT_SYMBOL(vga_switcheroo_get_edid);
 
+bool vga_switcheroo_handler_pm(void) {
+	if (!vgasr_priv.handler)
+		return false;
+
+	return vgasr_priv.handler->handler_pm;
+}
+EXPORT_SYMBOL(vga_switcheroo_handler_pm);
+
 static int __init vga_switcheroo_setup(char *str)
 {
 	if (!strcmp(str, "IGD"))
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
index 07b07fc..4bba934 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -36,6 +36,7 @@ struct vga_switcheroo_handler {
 			   enum vga_switcheroo_state state);
 	int (*init)(void);
 	int (*get_client_id)(struct pci_dev *pdev);
+	bool handler_pm;
 };
 
 struct vga_switcheroo_client_ops {
@@ -76,6 +77,8 @@ u8 *vga_switcheroo_get_dpcd(struct pci_dev *pdev);
 int vga_switcheroo_set_edid(struct edid *edid);
 struct edid *vga_switcheroo_get_edid(struct pci_dev *pdev);
 
+bool vga_switcheroo_handler_pm(void);
+
 #else
 
 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
@@ -101,5 +104,7 @@ static inline u8 *vga_switcheroo_get_dpcd(struct pci_dev *pdev) { return NULL };
 static inline int vga_switcheroo_set_edid(struct edid *edid) { return 0 };
 static inline struct edid *vga_switcheroo_get_edid(struct pci_dev *pdev) { return NULL };
 
+static inline bool vga_switcheroo_handler_pm(void) { return false; };
+
 #endif
 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
-- 
1.8.5.3



More information about the dri-devel mailing list