All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: [PATCH 2/9] vga_switcheroo: Use VGA_SWITCHEROO_UNKNOWN_ID instead of -1
Date: Fri, 28 Aug 2015 13:30:32 +0200	[thread overview]
Message-ID: <7acf5629ec156de3320dadb3f47415409466ee01.1444663039.git.lukas@wunner.de> (raw)
In-Reply-To: <cover.1444663039.git.lukas@wunner.de>

Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
 drivers/gpu/vga/vga_switcheroo.c | 17 +++++++++--------
 include/linux/vga_switcheroo.h   |  4 ++++
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index a7870d2..9896305 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -84,9 +84,9 @@
  * @fb_info: framebuffer to which console is remapped on switching
  * @pwr_state: current power state
  * @ops: client callbacks
- * @id: client identifier, see enum vga_switcheroo_client_id.
- * 	Determining the id requires the handler, so GPUs are initially
- * 	assigned -1 and later given their true id in vga_switcheroo_enable()
+ * @id: client identifier. Determining the id requires the handler,
+ * 	so gpus are initially assigned VGA_SWITCHEROO_UNKNOWN_ID
+ * 	and later given their true id in vga_switcheroo_enable()
  * @active: whether the outputs are currently switched to this client
  * @driver_power_control: whether power state is controlled by the driver's
  * 	runtime pm. If true, writing ON and OFF to the vga_switcheroo debugfs
@@ -145,7 +145,8 @@ struct vgasr_priv {
 
 #define ID_BIT_AUDIO		0x100
 #define client_is_audio(c)	((c)->id & ID_BIT_AUDIO)
-#define client_is_vga(c)	((c)->id == -1 || !client_is_audio(c))
+#define client_is_vga(c)	((c)->id == VGA_SWITCHEROO_UNKNOWN_ID || \
+				 !client_is_audio(c))
 #define client_id(c)		((c)->id & ~ID_BIT_AUDIO)
 
 static int vga_switcheroo_debugfs_init(struct vgasr_priv *priv);
@@ -173,7 +174,7 @@ static void vga_switcheroo_enable(void)
 		vgasr_priv.handler->init();
 
 	list_for_each_entry(client, &vgasr_priv.clients, list) {
-		if (client->id != -1)
+		if (client->id != VGA_SWITCHEROO_UNKNOWN_ID)
 			continue;
 		ret = vgasr_priv.handler->get_client_id(client->pdev);
 		if (ret < 0)
@@ -277,7 +278,7 @@ int vga_switcheroo_register_client(struct pci_dev *pdev,
 				   const struct vga_switcheroo_client_ops *ops,
 				   bool driver_power_control)
 {
-	return register_client(pdev, ops, -1,
+	return register_client(pdev, ops, VGA_SWITCHEROO_UNKNOWN_ID,
 			       pdev == vga_default_device(),
 			       driver_power_control);
 }
@@ -583,7 +584,7 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
 	int ret;
 	bool delay = false, can_switch;
 	bool just_mux = false;
-	int client_id = -1;
+	int client_id = VGA_SWITCHEROO_UNKNOWN_ID;
 	struct vga_switcheroo_client *client = NULL;
 
 	if (cnt > 63)
@@ -652,7 +653,7 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
 		client_id = VGA_SWITCHEROO_DIS;
 	}
 
-	if (client_id == -1)
+	if (client_id == VGA_SWITCHEROO_UNKNOWN_ID)
 		goto out;
 	client = find_client_from_id(&vgasr_priv.clients, client_id);
 	if (!client)
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
index e636617..88909a8 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -59,6 +59,9 @@ enum vga_switcheroo_state {
 
 /**
  * enum vga_switcheroo_client_id - client identifier
+ * @VGA_SWITCHEROO_UNKNOWN_ID: initial identifier assigned to vga clients.
+ * 	Determining the id requires the handler, so GPUs are given their
+ * 	true id in a delayed fashion in vga_switcheroo_enable()
  * @VGA_SWITCHEROO_IGD: integrated graphics device
  * @VGA_SWITCHEROO_DIS: discrete graphics device
  * @VGA_SWITCHEROO_MAX_CLIENTS: currently no more than two GPUs are supported
@@ -66,6 +69,7 @@ enum vga_switcheroo_state {
  * Client identifier. Audio clients use the same identifier & 0x100.
  */
 enum vga_switcheroo_client_id {
+	VGA_SWITCHEROO_UNKNOWN_ID = -1,
 	VGA_SWITCHEROO_IGD,
 	VGA_SWITCHEROO_DIS,
 	VGA_SWITCHEROO_MAX_CLIENTS,
-- 
1.8.5.2 (Apple Git-48)

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

  parent reply	other threads:[~2015-10-12 15:41 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-04  9:52 [PATCH v3 0/6] Enable gpu switching on the MacBook Pro Lukas Wunner
2015-08-14 16:50 ` [PATCH v3 1/6] vga_switcheroo: Add support for switching only the DDC Lukas Wunner
2015-08-14 16:18   ` [PATCH v3 2/6] apple-gmux: Add switch_ddc support Lukas Wunner
2015-08-14 16:28     ` [PATCH v3 3/6] drm/edid: Switch DDC when reading the EDID Lukas Wunner
2015-09-11 10:40       ` [PATCH v3 4/6] drm/i915: " Lukas Wunner
2015-05-09 15:20         ` [PATCH v3 5/6] drm/nouveau: " Lukas Wunner
2015-09-12  7:44           ` [PATCH v3 6/6] drm/radeon: " Lukas Wunner
2015-10-08  3:14             ` Alex Deucher
2015-10-08 14:53               ` Lukas Wunner
2015-10-12 18:59                 ` Alex Deucher
2015-10-06  7:27   ` [PATCH v3 1/6] vga_switcheroo: Add support for switching only the DDC Daniel Vetter
2015-10-06 10:10     ` Lukas Wunner
2015-10-06 11:10       ` Daniel Vetter
2015-10-06 18:27         ` Lukas Wunner
2015-10-07  7:52           ` Daniel Vetter
2015-10-12 15:17             ` [PATCH 0/9] vga_switcheroo cleanup Lukas Wunner
2015-08-28  9:56               ` [PATCH 1/9] vga_switcheroo: Use enum vga_switcheroo_state instead of int Lukas Wunner
2015-10-12 16:09                 ` Alex Deucher
2015-08-28 10:54               ` [PATCH 3/9] vga_switcheroo: Use enum vga_switcheroo_client_id " Lukas Wunner
2015-10-12 16:10                 ` Alex Deucher
2015-08-28 11:30               ` Lukas Wunner [this message]
2015-10-12 16:09                 ` [PATCH 2/9] vga_switcheroo: Use VGA_SWITCHEROO_UNKNOWN_ID instead of -1 Alex Deucher
2015-10-13  7:28                   ` Daniel Vetter
2015-10-15 18:14                     ` Lukas Wunner
2015-10-16 14:25                       ` Daniel Vetter
2015-09-04 18:49               ` [PATCH 4/9] ALSA: hda - Spell vga_switcheroo consistently Lukas Wunner
2015-10-12  8:57               ` [PATCH 5/9] drm/i915: Drop unnecessary #include <linux/vga_switcheroo.h> Lukas Wunner
2015-10-13  7:25                 ` Daniel Vetter
2015-10-13  7:26                 ` Jani Nikula
2015-10-12  9:15               ` [PATCH 6/9] drm/radeon: " Lukas Wunner
2015-10-12  9:44               ` [PATCH 8/9] drm/radeon: Fix kernel-doc copy/paste snafu Lukas Wunner
2015-10-12 16:02                 ` Alex Deucher
2015-10-12 16:36                   ` Lukas Wunner
2015-10-12  9:54               ` [PATCH 7/9] drm/amdgpu: Drop unnecessary #include <linux/vga_switcheroo.h> Lukas Wunner
2015-10-12 16:27                 ` Alex Deucher
2015-10-12 10:00               ` [PATCH 9/9] drm/amdgpu: Fix kernel-doc copy/paste snafu Lukas Wunner
2015-10-12 16:03                 ` Alex Deucher
     [not found]           ` <20151006182744.GA15532-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2015-10-12 17:14             ` [PATCH v4 0/6] Enable gpu switching on the MacBook Pro Lukas Wunner
     [not found]               ` <cover.1444670070.git.lukas-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2015-05-09 15:20                 ` [PATCH v4 5/6] drm/nouveau: Switch DDC when reading the EDID Lukas Wunner
2015-08-14 16:18               ` [PATCH v4 2/6] apple-gmux: Add switch_ddc support Lukas Wunner
2015-10-12 21:07                 ` Alex Deucher
2015-10-12 21:10                   ` Alex Deucher
2015-10-13  7:32                     ` Daniel Vetter
2015-10-29 14:58                     ` Lukas Wunner
2015-10-15  4:51                 ` Darren Hart
2015-10-15  6:27                   ` Daniel Vetter
2015-08-14 16:28               ` [PATCH v4 3/6] drm/edid: Switch DDC when reading the EDID Lukas Wunner
2015-08-14 16:50               ` [PATCH v4 1/6] vga_switcheroo: Add support for switching only the DDC Lukas Wunner
2015-09-11 10:40               ` [PATCH v4 4/6] drm/i915: Switch DDC when reading the EDID Lukas Wunner
2015-09-12  7:44               ` [PATCH v4 6/6] drm/radeon: " Lukas Wunner
2015-10-05 13:23 ` [PATCH v3 0/6] Enable gpu switching on the MacBook Pro Lukas Wunner
     [not found]   ` <20151005132349.GA15130-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2015-10-05 14:15     ` Evan Foss
2015-10-05 15:17       ` [Nouveau] " Lukas Wunner
     [not found]         ` <20151005151704.GA15177-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2015-10-05 15:23           ` Evan Foss
2015-10-05 15:31             ` [Nouveau] " Lukas Wunner
     [not found]       ` <CAM2RGhT5x9GoNU4xPwzoEoiWKqVrC2pwp3ydFgaXFwtsYiBa7A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-05 15:20         ` Pierre Moreau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7acf5629ec156de3320dadb3f47415409466ee01.1444663039.git.lukas@wunner.de \
    --to=lukas@wunner.de \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.