| 1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 |
/* |
| 3 |
* This code gives functions to avoid code duplication while interacting with |
| 4 |
* the TUXEDO NB04 wmi interfaces. |
| 5 |
* |
| 6 |
* Copyright (C) 2024-2025 Werner Sembach <[email protected]> |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef TUXEDO_NB04_WMI_UTIL_H |
| 10 |
#define TUXEDO_NB04_WMI_UTIL_H |
| 11 |
|
| 12 |
#include <linux/wmi.h> |
| 13 |
|
| 14 |
#define TUX_GET_DEVICE_STATUS_DEVICE_ID_TOUCHPAD 1 |
| 15 |
#define TUX_GET_DEVICE_STATUS_DEVICE_ID_KEYBOARD 2 |
| 16 |
#define TUX_GET_DEVICE_STATUS_DEVICE_ID_APP_PAGES 3 |
| 17 |
|
| 18 |
#define TUX_GET_DEVICE_STATUS_KBL_TYPE_NONE 0 |
| 19 |
#define TUX_GET_DEVICE_STATUS_KBL_TYPE_PER_KEY 1 |
| 20 |
#define TUX_GET_DEVICE_STATUS_KBL_TYPE_FOUR_ZONE 2 |
| 21 |
#define TUX_GET_DEVICE_STATUS_KBL_TYPE_WHITE_ONLY 3 |
| 22 |
|
| 23 |
#define TUX_GET_DEVICE_STATUS_KEYBOARD_LAYOUT_ANSII 0 |
| 24 |
#define TUX_GET_DEVICE_STATUS_KEYBOARD_LAYOUT_ISO 1 |
| 25 |
|
| 26 |
#define TUX_GET_DEVICE_STATUS_COLOR_ID_RED 1 |
| 27 |
#define TUX_GET_DEVICE_STATUS_COLOR_ID_GREEN 2 |
| 28 |
#define TUX_GET_DEVICE_STATUS_COLOR_ID_YELLOW 3 |
| 29 |
#define TUX_GET_DEVICE_STATUS_COLOR_ID_BLUE 4 |
| 30 |
#define TUX_GET_DEVICE_STATUS_COLOR_ID_PURPLE 5 |
| 31 |
#define TUX_GET_DEVICE_STATUS_COLOR_ID_INDIGO 6 |
| 32 |
#define TUX_GET_DEVICE_STATUS_COLOR_ID_WHITE 7 |
| 33 |
|
| 34 |
#define TUX_GET_DEVICE_STATUS_APP_PAGES_DASHBOARD BIT(0) |
| 35 |
#define TUX_GET_DEVICE_STATUS_APP_PAGES_SYSTEMINFOS BIT(1) |
| 36 |
#define TUX_GET_DEVICE_STATUS_APP_PAGES_KBL BIT(2) |
| 37 |
#define TUX_GET_DEVICE_STATUS_APP_PAGES_HOTKEYS BIT(3) |
| 38 |
|
| 39 |
union tux_wmi_xx_8in_80out_in_t { |
| 40 |
u8 raw[8]; |
| 41 |
struct __packed { |
| 42 |
u8 device_type; |
| 43 |
u8 reserved[7]; |
| 44 |
} get_device_status_in; |
| 45 |
}; |
| 46 |
|
| 47 |
union tux_wmi_xx_8in_80out_out_t { |
| 48 |
u8 raw[80]; |
| 49 |
struct __packed { |
| 50 |
u16 return_status; |
| 51 |
u8 device_enabled; |
| 52 |
u8 kbl_type; |
| 53 |
u8 kbl_side_bar_supported; |
| 54 |
u8 keyboard_physical_layout; |
| 55 |
u8 app_pages; |
| 56 |
u8 per_key_kbl_default_color; |
| 57 |
u8 four_zone_kbl_default_color_1; |
| 58 |
u8 four_zone_kbl_default_color_2; |
| 59 |
u8 four_zone_kbl_default_color_3; |
| 60 |
u8 four_zone_kbl_default_color_4; |
| 61 |
u8 light_bar_kbl_default_color; |
| 62 |
u8 reserved_0[1]; |
| 63 |
u16 dedicated_gpu_id; |
| 64 |
u8 reserved_1[64]; |
| 65 |
} get_device_status_out; |
| 66 |
}; |
| 67 |
|
| 68 |
enum tux_wmi_xx_8in_80out_methods { |
| 69 |
TUX_GET_DEVICE_STATUS = 2, |
| 70 |
}; |
| 71 |
|
| 72 |
#define TUX_KBL_SET_MULTIPLE_KEYS_LIGHTING_SETTINGS_COUNT_MAX 120 |
| 73 |
|
| 74 |
union tux_wmi_xx_496in_80out_in_t { |
| 75 |
u8 raw[496]; |
| 76 |
struct __packed { |
| 77 |
u8 reserved[15]; |
| 78 |
u8 rgb_configs_cnt; |
| 79 |
struct tux_kbl_set_multiple_keys_in_rgb_config_t { |
| 80 |
u8 key_id; |
| 81 |
u8 red; |
| 82 |
u8 green; |
| 83 |
u8 blue; |
| 84 |
} rgb_configs[TUX_KBL_SET_MULTIPLE_KEYS_LIGHTING_SETTINGS_COUNT_MAX]; |
| 85 |
} kbl_set_multiple_keys_in; |
| 86 |
}; |
| 87 |
|
| 88 |
union tux_wmi_xx_496in_80out_out_t { |
| 89 |
u8 raw[80]; |
| 90 |
struct __packed { |
| 91 |
u8 return_value; |
| 92 |
u8 reserved[79]; |
| 93 |
} kbl_set_multiple_keys_out; |
| 94 |
}; |
| 95 |
|
| 96 |
enum tux_wmi_xx_496in_80out_methods { |
| 97 |
TUX_KBL_SET_MULTIPLE_KEYS = 6, |
| 98 |
}; |
| 99 |
|
| 100 |
int tux_wmi_xx_8in_80out(struct wmi_device *wdev, |
| 101 |
enum tux_wmi_xx_8in_80out_methods method, |
| 102 |
union tux_wmi_xx_8in_80out_in_t *in, |
| 103 |
union tux_wmi_xx_8in_80out_out_t *out); |
| 104 |
int tux_wmi_xx_496in_80out(struct wmi_device *wdev, |
| 105 |
enum tux_wmi_xx_496in_80out_methods method, |
| 106 |
union tux_wmi_xx_496in_80out_in_t *in, |
| 107 |
union tux_wmi_xx_496in_80out_out_t *out); |
| 108 |
|
| 109 |
#endif |