| 1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 |
/* |
| 3 |
* Alienware WMI special features driver |
| 4 |
* |
| 5 |
* Copyright (C) 2014 Dell Inc <[email protected]> |
| 6 |
* Copyright (C) 2024 Kurt Borja <[email protected]> |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef _ALIENWARE_WMI_H_ |
| 10 |
#define _ALIENWARE_WMI_H_ |
| 11 |
|
| 12 |
#include <linux/leds.h> |
| 13 |
#include <linux/platform_device.h> |
| 14 |
#include <linux/wmi.h> |
| 15 |
|
| 16 |
#define LEGACY_CONTROL_GUID "A90597CE-A997-11DA-B012-B622A1EF5492" |
| 17 |
#define LEGACY_POWER_CONTROL_GUID "A80593CE-A997-11DA-B012-B622A1EF5492" |
| 18 |
#define WMAX_CONTROL_GUID "A70591CE-A997-11DA-B012-B622A1EF5492" |
| 19 |
|
| 20 |
enum INTERFACE_FLAGS { |
| 21 |
LEGACY, |
| 22 |
WMAX, |
| 23 |
}; |
| 24 |
|
| 25 |
enum LEGACY_CONTROL_STATES { |
| 26 |
LEGACY_RUNNING = 1, |
| 27 |
LEGACY_BOOTING = 0, |
| 28 |
LEGACY_SUSPEND = 3, |
| 29 |
}; |
| 30 |
|
| 31 |
enum WMAX_CONTROL_STATES { |
| 32 |
WMAX_RUNNING = 0xFF, |
| 33 |
WMAX_BOOTING = 0, |
| 34 |
WMAX_SUSPEND = 3, |
| 35 |
}; |
| 36 |
|
| 37 |
struct alienfx_quirks { |
| 38 |
u8 num_zones; |
| 39 |
bool hdmi_mux; |
| 40 |
bool amplifier; |
| 41 |
bool deepslp; |
| 42 |
}; |
| 43 |
|
| 44 |
struct color_platform { |
| 45 |
u8 blue; |
| 46 |
u8 green; |
| 47 |
u8 red; |
| 48 |
} __packed; |
| 49 |
|
| 50 |
struct alienfx_priv { |
| 51 |
struct platform_device *pdev; |
| 52 |
struct led_classdev global_led; |
| 53 |
struct color_platform colors[4]; |
| 54 |
u8 global_brightness; |
| 55 |
u8 lighting_control_state; |
| 56 |
}; |
| 57 |
|
| 58 |
struct alienfx_ops { |
| 59 |
int (*upd_led)(struct alienfx_priv *priv, struct wmi_device *wdev, |
| 60 |
u8 location); |
| 61 |
int (*upd_brightness)(struct alienfx_priv *priv, struct wmi_device *wdev, |
| 62 |
u8 brightness); |
| 63 |
}; |
| 64 |
|
| 65 |
struct alienfx_platdata { |
| 66 |
struct wmi_device *wdev; |
| 67 |
struct alienfx_ops ops; |
| 68 |
}; |
| 69 |
|
| 70 |
extern u8 alienware_interface; |
| 71 |
extern struct alienfx_quirks *alienfx; |
| 72 |
|
| 73 |
int alienware_wmi_command(struct wmi_device *wdev, u32 method_id, |
| 74 |
void *in_args, size_t in_size, u32 *out_data); |
| 75 |
|
| 76 |
int alienware_alienfx_setup(struct alienfx_platdata *pdata); |
| 77 |
|
| 78 |
#if IS_ENABLED(CONFIG_ALIENWARE_WMI_LEGACY) |
| 79 |
int __init alienware_legacy_wmi_init(void); |
| 80 |
void __exit alienware_legacy_wmi_exit(void); |
| 81 |
#else |
| 82 |
static inline int alienware_legacy_wmi_init(void) |
| 83 |
{ |
| 84 |
return -ENODEV; |
| 85 |
} |
| 86 |
|
| 87 |
static inline void alienware_legacy_wmi_exit(void) |
| 88 |
{ |
| 89 |
} |
| 90 |
#endif |
| 91 |
|
| 92 |
#if IS_ENABLED(CONFIG_ALIENWARE_WMI_WMAX) |
| 93 |
extern const struct attribute_group wmax_hdmi_attribute_group; |
| 94 |
extern const struct attribute_group wmax_amplifier_attribute_group; |
| 95 |
extern const struct attribute_group wmax_deepsleep_attribute_group; |
| 96 |
|
| 97 |
#define WMAX_DEV_GROUPS &wmax_hdmi_attribute_group, \ |
| 98 |
&wmax_amplifier_attribute_group, \ |
| 99 |
&wmax_deepsleep_attribute_group, |
| 100 |
|
| 101 |
int __init alienware_wmax_wmi_init(void); |
| 102 |
void __exit alienware_wmax_wmi_exit(void); |
| 103 |
#else |
| 104 |
#define WMAX_DEV_GROUPS |
| 105 |
|
| 106 |
static inline int alienware_wmax_wmi_init(void) |
| 107 |
{ |
| 108 |
return -ENODEV; |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
static inline void alienware_wmax_wmi_exit(void) |
| 113 |
{ |
| 114 |
} |
| 115 |
#endif |
| 116 |
|
| 117 |
#endif |