[PATCH 1/2] vga_switcheroo: add mux switched interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Dave Airlie <airlied@xxxxxxxxxx>

this tells the drivers when the mux is switch to/from it, can be used
to report outputs as disconnected to userspace etc.

Signed-off-by: Dave Airlie <airlied@xxxxxxxxxx>
---
 drivers/gpu/vga/vga_switcheroo.c | 19 +++++++++++++++++++
 include/linux/vga_switcheroo.h   |  1 +
 2 files changed, 20 insertions(+)

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index fa60add..2362175 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -93,6 +93,9 @@ static void vga_switcheroo_enable(void)
 			return;
 
 		client->id = ret;
+
+		if (client->ops->mux_switched)
+			client->ops->mux_switched(client->pdev, client->active ? VGA_SWITCHEROO_ON : VGA_SWITCHEROO_OFF);
 	}
 	vga_switcheroo_debugfs_init(&vgasr_priv);
 	vgasr_priv.active = true;
@@ -345,6 +348,13 @@ static int vga_switchto_stage2(struct vga_switcheroo_client *new_client)
 	if (ret)
 		return ret;
 
+	/* call mux switched callbacks */
+	if (active->ops->mux_switched)
+		active->ops->mux_switched(active->pdev, VGA_SWITCHEROO_OFF);
+
+	if (new_client->ops->mux_switched)
+		new_client->ops->mux_switched(new_client->pdev, VGA_SWITCHEROO_ON);
+
 	if (new_client->ops->reprobe)
 		new_client->ops->reprobe(new_client->pdev);
 
@@ -452,7 +462,16 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
 	vgasr_priv.delayed_switch_active = false;
 
 	if (just_mux) {
+		struct vga_switcheroo_client *active;
+		active = find_active_client(&vgasr_priv.clients);
+		if (!active)
+			return 0;
 		ret = vgasr_priv.handler->switchto(client_id);
+
+		if (active->ops->mux_switched)
+			active->ops->mux_switched(active->pdev, VGA_SWITCHEROO_OFF);
+		if (client->ops->mux_switched)
+			client->ops->mux_switched(client->pdev, VGA_SWITCHEROO_ON);
 		goto out;
 	}
 
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
index ddb419c..6275719 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -40,6 +40,7 @@ struct vga_switcheroo_client_ops {
 	void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state);
 	void (*reprobe)(struct pci_dev *dev);
 	bool (*can_switch)(struct pci_dev *dev);
+	void (*mux_switched)(struct pci_dev *dev, enum vga_switcheroo_state);
 };
 
 #if defined(CONFIG_VGA_SWITCHEROO)
-- 
1.8.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux