summaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/dell/alienware-wmi.h
blob: 68d4242211aef8874f981c162af20505314047d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Alienware WMI special features driver
 *
 * Copyright (C) 2014 Dell Inc <Dell.Client.Kernel@dell.com>
 * Copyright (C) 2024 Kurt Borja <kuurtb@gmail.com>
 */

#ifndef _ALIENWARE_WMI_H_
#define _ALIENWARE_WMI_H_

#include <linux/leds.h>
#include <linux/platform_device.h>
#include <linux/wmi.h>

#define LEGACY_CONTROL_GUID		"A90597CE-A997-11DA-B012-B622A1EF5492"
#define LEGACY_POWER_CONTROL_GUID	"A80593CE-A997-11DA-B012-B622A1EF5492"
#define WMAX_CONTROL_GUID		"A70591CE-A997-11DA-B012-B622A1EF5492"

enum INTERFACE_FLAGS {
	LEGACY,
	WMAX,
};

enum LEGACY_CONTROL_STATES {
	LEGACY_RUNNING = 1,
	LEGACY_BOOTING = 0,
	LEGACY_SUSPEND = 3,
};

enum WMAX_CONTROL_STATES {
	WMAX_RUNNING = 0xFF,
	WMAX_BOOTING = 0,
	WMAX_SUSPEND = 3,
};

struct alienfx_quirks {
	u8 num_zones;
	bool hdmi_mux;
	bool amplifier;
	bool deepslp;
};

struct color_platform {
	u8 blue;
	u8 green;
	u8 red;
} __packed;

struct alienfx_priv {
	struct platform_device *pdev;
	struct led_classdev global_led;
	struct color_platform colors[4];
	u8 global_brightness;
	u8 lighting_control_state;
};

struct alienfx_ops {
	int (*upd_led)(struct alienfx_priv *priv, struct wmi_device *wdev,
		       u8 location);
	int (*upd_brightness)(struct alienfx_priv *priv, struct wmi_device *wdev,
			      u8 brightness);
};

struct alienfx_platdata {
	struct wmi_device *wdev;
	struct alienfx_ops ops;
};

extern u8 alienware_interface;
extern struct alienfx_quirks *alienfx;

int alienware_wmi_command(struct wmi_device *wdev, u32 method_id,
			  void *in_args, size_t in_size, u32 *out_data);

int alienware_alienfx_setup(struct alienfx_platdata *pdata);

#if IS_ENABLED(CONFIG_ALIENWARE_WMI_LEGACY)
int __init alienware_legacy_wmi_init(void);
void __exit alienware_legacy_wmi_exit(void);
#else
static inline int alienware_legacy_wmi_init(void)
{
	return -ENODEV;
}

static inline void alienware_legacy_wmi_exit(void)
{
}
#endif

#if IS_ENABLED(CONFIG_ALIENWARE_WMI_WMAX)
extern const struct attribute_group wmax_hdmi_attribute_group;
extern const struct attribute_group wmax_amplifier_attribute_group;
extern const struct attribute_group wmax_deepsleep_attribute_group;

#define WMAX_DEV_GROUPS		&wmax_hdmi_attribute_group,		\
				&wmax_amplifier_attribute_group,	\
				&wmax_deepsleep_attribute_group,

int __init alienware_wmax_wmi_init(void);
void __exit alienware_wmax_wmi_exit(void);
#else
#define WMAX_DEV_GROUPS

static inline int alienware_wmax_wmi_init(void)
{
	return -ENODEV;
}


static inline void alienware_wmax_wmi_exit(void)
{
}
#endif

#endif