Commit 21c5ba8c authored by Lukas Wunner's avatar Lukas Wunner Committed by Daniel Vetter

vga_switcheroo: Use VGA_SWITCHEROO_UNKNOWN_ID instead of -1

Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 203d027d
...@@ -84,9 +84,9 @@ ...@@ -84,9 +84,9 @@
* @fb_info: framebuffer to which console is remapped on switching * @fb_info: framebuffer to which console is remapped on switching
* @pwr_state: current power state * @pwr_state: current power state
* @ops: client callbacks * @ops: client callbacks
* @id: client identifier, see enum vga_switcheroo_client_id. * @id: client identifier. Determining the id requires the handler,
* Determining the id requires the handler, so GPUs are initially * so gpus are initially assigned VGA_SWITCHEROO_UNKNOWN_ID
* assigned -1 and later given their true id in vga_switcheroo_enable() * and later given their true id in vga_switcheroo_enable()
* @active: whether the outputs are currently switched to this client * @active: whether the outputs are currently switched to this client
* @driver_power_control: whether power state is controlled by the driver's * @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 * runtime pm. If true, writing ON and OFF to the vga_switcheroo debugfs
...@@ -145,7 +145,8 @@ struct vgasr_priv { ...@@ -145,7 +145,8 @@ struct vgasr_priv {
#define ID_BIT_AUDIO 0x100 #define ID_BIT_AUDIO 0x100
#define client_is_audio(c) ((c)->id & ID_BIT_AUDIO) #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) #define client_id(c) ((c)->id & ~ID_BIT_AUDIO)
static int vga_switcheroo_debugfs_init(struct vgasr_priv *priv); static int vga_switcheroo_debugfs_init(struct vgasr_priv *priv);
...@@ -173,7 +174,7 @@ static void vga_switcheroo_enable(void) ...@@ -173,7 +174,7 @@ static void vga_switcheroo_enable(void)
vgasr_priv.handler->init(); vgasr_priv.handler->init();
list_for_each_entry(client, &vgasr_priv.clients, list) { list_for_each_entry(client, &vgasr_priv.clients, list) {
if (client->id != -1) if (client->id != VGA_SWITCHEROO_UNKNOWN_ID)
continue; continue;
ret = vgasr_priv.handler->get_client_id(client->pdev); ret = vgasr_priv.handler->get_client_id(client->pdev);
if (ret < 0) if (ret < 0)
...@@ -277,7 +278,7 @@ int vga_switcheroo_register_client(struct pci_dev *pdev, ...@@ -277,7 +278,7 @@ int vga_switcheroo_register_client(struct pci_dev *pdev,
const struct vga_switcheroo_client_ops *ops, const struct vga_switcheroo_client_ops *ops,
bool driver_power_control) bool driver_power_control)
{ {
return register_client(pdev, ops, -1, return register_client(pdev, ops, VGA_SWITCHEROO_UNKNOWN_ID,
pdev == vga_default_device(), pdev == vga_default_device(),
driver_power_control); driver_power_control);
} }
...@@ -583,7 +584,7 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf, ...@@ -583,7 +584,7 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
int ret; int ret;
bool delay = false, can_switch; bool delay = false, can_switch;
bool just_mux = false; bool just_mux = false;
int client_id = -1; int client_id = VGA_SWITCHEROO_UNKNOWN_ID;
struct vga_switcheroo_client *client = NULL; struct vga_switcheroo_client *client = NULL;
if (cnt > 63) if (cnt > 63)
...@@ -652,7 +653,7 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf, ...@@ -652,7 +653,7 @@ vga_switcheroo_debugfs_write(struct file *filp, const char __user *ubuf,
client_id = VGA_SWITCHEROO_DIS; client_id = VGA_SWITCHEROO_DIS;
} }
if (client_id == -1) if (client_id == VGA_SWITCHEROO_UNKNOWN_ID)
goto out; goto out;
client = find_client_from_id(&vgasr_priv.clients, client_id); client = find_client_from_id(&vgasr_priv.clients, client_id);
if (!client) if (!client)
......
...@@ -59,6 +59,9 @@ enum vga_switcheroo_state { ...@@ -59,6 +59,9 @@ enum vga_switcheroo_state {
/** /**
* enum vga_switcheroo_client_id - client identifier * 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_IGD: integrated graphics device
* @VGA_SWITCHEROO_DIS: discrete graphics device * @VGA_SWITCHEROO_DIS: discrete graphics device
* @VGA_SWITCHEROO_MAX_CLIENTS: currently no more than two GPUs are supported * @VGA_SWITCHEROO_MAX_CLIENTS: currently no more than two GPUs are supported
...@@ -66,6 +69,7 @@ enum vga_switcheroo_state { ...@@ -66,6 +69,7 @@ enum vga_switcheroo_state {
* Client identifier. Audio clients use the same identifier & 0x100. * Client identifier. Audio clients use the same identifier & 0x100.
*/ */
enum vga_switcheroo_client_id { enum vga_switcheroo_client_id {
VGA_SWITCHEROO_UNKNOWN_ID = -1,
VGA_SWITCHEROO_IGD, VGA_SWITCHEROO_IGD,
VGA_SWITCHEROO_DIS, VGA_SWITCHEROO_DIS,
VGA_SWITCHEROO_MAX_CLIENTS, VGA_SWITCHEROO_MAX_CLIENTS,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment