linux/drivers/platform/x86/acer-wmi.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 *  Acer WMI Laptop Extras
 *
 *  Copyright (C) 2007-2009	Carlos Corbacho <[email protected]>
 *
 *  Based on acer_acpi:
 *    Copyright (C) 2005-2007	E.M. Smith
 *    Copyright (C) 2007-2008	Carlos Corbacho <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/dmi.h>
#include <linux/backlight.h>
#include <linux/leds.h>
#include <linux/platform_device.h>
#include <linux/platform_profile.h>
#include <linux/acpi.h>
#include <linux/i8042.h>
#include <linux/rfkill.h>
#include <linux/workqueue.h>
#include <linux/debugfs.h>
#include <linux/slab.h>
#include <linux/input.h>
#include <linux/input/sparse-keymap.h>
#include <acpi/video.h>
#include <linux/hwmon.h>
#include <linux/bitfield.h>

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();

/*
 * Magic Number
 * Meaning is unknown - this number is required for writing to ACPI for AMW0
 * (it's also used in acerhk when directly accessing the BIOS)
 */
#define ACER_AMW0_WRITE

/*
 * Bit masks for the AMW0 interface
 */
#define ACER_AMW0_WIRELESS_MASK
#define ACER_AMW0_BLUETOOTH_MASK
#define ACER_AMW0_MAILLED_MASK

/*
 * Method IDs for WMID interface
 */
#define ACER_WMID_GET_WIRELESS_METHODID
#define ACER_WMID_GET_BLUETOOTH_METHODID
#define ACER_WMID_GET_BRIGHTNESS_METHODID
#define ACER_WMID_SET_WIRELESS_METHODID
#define ACER_WMID_SET_BLUETOOTH_METHODID
#define ACER_WMID_SET_BRIGHTNESS_METHODID
#define ACER_WMID_GET_THREEG_METHODID
#define ACER_WMID_SET_THREEG_METHODID

#define ACER_WMID_SET_GAMING_LED_METHODID
#define ACER_WMID_GET_GAMING_LED_METHODID
#define ACER_WMID_GET_GAMING_SYS_INFO_METHODID
#define ACER_WMID_SET_GAMING_FAN_BEHAVIOR
#define ACER_WMID_SET_GAMING_MISC_SETTING_METHODID

#define ACER_PREDATOR_V4_THERMAL_PROFILE_EC_OFFSET

#define ACER_PREDATOR_V4_FAN_SPEED_READ_BIT_MASK

/*
 * Acer ACPI method GUIDs
 */
#define AMW0_GUID1
#define AMW0_GUID2
#define WMID_GUID1
#define WMID_GUID2
#define WMID_GUID3
#define WMID_GUID4

/*
 * Acer ACPI event GUIDs
 */
#define ACERWMID_EVENT_GUID

MODULE_ALIAS();
MODULE_ALIAS();
MODULE_ALIAS();

enum acer_wmi_event_ids {};

enum acer_wmi_predator_v4_sys_info_command {};

static const struct key_entry acer_wmi_keymap[] __initconst =;

static struct input_dev *acer_wmi_input_dev;
static struct input_dev *acer_wmi_accel_dev;

struct event_return_value {} __packed;

/*
 * GUID3 Get Device Status device flags
 */
#define ACER_WMID3_GDS_WIRELESS
#define ACER_WMID3_GDS_THREEG
#define ACER_WMID3_GDS_WIMAX
#define ACER_WMID3_GDS_BLUETOOTH
#define ACER_WMID3_GDS_RFBTN

#define ACER_WMID3_GDS_TOUCHPAD

/* Hotkey Customized Setting and Acer Application Status.
 * Set Device Default Value and Report Acer Application Status.
 * When Acer Application starts, it will run this method to inform
 * BIOS/EC that Acer Application is on.
 * App Status
 *	Bit[0]: Launch Manager Status
 *	Bit[1]: ePM Status
 *	Bit[2]: Device Control Status
 *	Bit[3]: Acer Power Button Utility Status
 *	Bit[4]: RF Button Status
 *	Bit[5]: ODD PM Status
 *	Bit[6]: Device Default Value Control
 *	Bit[7]: Hall Sensor Application Status
 */
struct func_input_params {} __packed;

struct func_return_value {} __packed;

struct wmid3_gds_set_input_param {} __packed;

struct wmid3_gds_get_input_param {} __packed;

struct wmid3_gds_return_value {} __packed;

struct hotkey_function_type_aa {} __packed;

/*
 * Interface capability flags
 */
#define ACER_CAP_MAILLED
#define ACER_CAP_WIRELESS
#define ACER_CAP_BLUETOOTH
#define ACER_CAP_BRIGHTNESS
#define ACER_CAP_THREEG
#define ACER_CAP_SET_FUNCTION_MODE
#define ACER_CAP_KBD_DOCK
#define ACER_CAP_TURBO_OC
#define ACER_CAP_TURBO_LED
#define ACER_CAP_TURBO_FAN
#define ACER_CAP_PLATFORM_PROFILE
#define ACER_CAP_FAN_SPEED_READ

/*
 * Interface type flags
 */
enum interface_flags {};

#define ACER_DEFAULT_WIRELESS
#define ACER_DEFAULT_BLUETOOTH
#define ACER_DEFAULT_MAILLED
#define ACER_DEFAULT_THREEG

static int max_brightness =;

static int mailled =;
static int brightness =;
static int threeg =;
static int force_series;
static int force_caps =;
static bool ec_raw_mode;
static bool has_type_aa;
static u16 commun_func_bitmap;
static u8 commun_fn_key_number;
static bool cycle_gaming_thermal_profile =;
static bool predator_v4;

module_param(mailled, int, 0444);
module_param(brightness, int, 0444);
module_param(threeg, int, 0444);
module_param(force_series, int, 0444);
module_param(force_caps, int, 0444);
module_param(ec_raw_mode, bool, 0444);
module_param(cycle_gaming_thermal_profile, bool, 0644);
module_param(predator_v4, bool, 0444);
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();
MODULE_PARM_DESC();

struct acer_data {};

struct acer_debug {};

static struct rfkill *wireless_rfkill;
static struct rfkill *bluetooth_rfkill;
static struct rfkill *threeg_rfkill;
static bool rfkill_inited;

/* Each low-level interface must define at least some of the following */
struct wmi_interface {};

/* The static interface pointer, points to the currently detected interface */
static struct wmi_interface *interface;

/*
 * Embedded Controller quirks
 * Some laptops require us to directly access the EC to either enable or query
 * features that are not available through WMI.
 */

struct quirk_entry {};

static struct quirk_entry *quirks;

static void __init set_quirks(void)
{}

static int __init dmi_matched(const struct dmi_system_id *dmi)
{}

static int __init set_force_caps(const struct dmi_system_id *dmi)
{}

static struct quirk_entry quirk_unknown =;

static struct quirk_entry quirk_acer_aspire_1520 =;

static struct quirk_entry quirk_acer_travelmate_2490 =;

static struct quirk_entry quirk_acer_predator_ph315_53 =;

static struct quirk_entry quirk_acer_predator_v4 =;

/* This AMW0 laptop has no bluetooth */
static struct quirk_entry quirk_medion_md_98300 =;

static struct quirk_entry quirk_fujitsu_amilo_li_1718 =;

static struct quirk_entry quirk_lenovo_ideapad_s205 =;

/* The Aspire One has a dummy ACPI-WMI interface - disable it */
static const struct dmi_system_id acer_blacklist[] __initconst =;

static const struct dmi_system_id amw0_whitelist[] __initconst =;

/*
 * This quirk table is only for Acer/Gateway/Packard Bell family
 * that those machines are supported by acer-wmi driver.
 */
static const struct dmi_system_id acer_quirks[] __initconst =;

/*
 * This quirk list is for those non-acer machines that have AMW0_GUID1
 * but supported by acer-wmi in past days. Keeping this quirk list here
 * is only for backward compatible. Please do not add new machine to
 * here anymore. Those non-acer machines should be supported by
 * appropriate wmi drivers.
 */
static const struct dmi_system_id non_acer_quirks[] __initconst =;

static struct platform_profile_handler platform_profile_handler;
static bool platform_profile_support;

/*
 * The profile used before turbo mode. This variable is needed for
 * returning from turbo mode when the mode key is in toggle mode.
 */
static int last_non_turbo_profile;

enum acer_predator_v4_thermal_profile_ec {};

enum acer_predator_v4_thermal_profile_wmi {};

/* Find which quirks are needed for a particular vendor/ model pair */
static void __init find_quirks(void)
{}

/*
 * General interface convenience methods
 */

static bool has_cap(u32 cap)
{}

/*
 * AMW0 (V1) interface
 */
struct wmab_args {};

struct wmab_ret {};

static acpi_status wmab_execute(struct wmab_args *regbuf,
struct acpi_buffer *result)
{}

static acpi_status AMW0_get_u32(u32 *value, u32 cap)
{}

static acpi_status AMW0_set_u32(u32 value, u32 cap)
{}

static acpi_status __init AMW0_find_mailled(void)
{}

static const struct acpi_device_id norfkill_ids[] __initconst =;

static int __init AMW0_set_cap_acpi_check_device(void)
{}

static acpi_status __init AMW0_set_capabilities(void)
{}

static struct wmi_interface AMW0_interface =;

static struct wmi_interface AMW0_V2_interface =;

/*
 * New interface (The WMID interface)
 */
static acpi_status
WMI_execute_u32(u32 method_id, u32 in, u32 *out)
{}

static acpi_status WMID_get_u32(u32 *value, u32 cap)
{}

static acpi_status WMID_set_u32(u32 value, u32 cap)
{}

static acpi_status wmid3_get_device_status(u32 *value, u16 device)
{}

static acpi_status wmid_v2_get_u32(u32 *value, u32 cap)
{}

static acpi_status wmid3_set_device_status(u32 value, u16 device)
{}

static acpi_status wmid_v2_set_u32(u32 value, u32 cap)
{}

static void __init type_aa_dmi_decode(const struct dmi_header *header, void *d)
{}

static acpi_status __init WMID_set_capabilities(void)
{}

static struct wmi_interface wmid_interface =;

static struct wmi_interface wmid_v2_interface =;

/*
 * WMID Gaming interface
 */

static acpi_status
WMI_gaming_execute_u64(u32 method_id, u64 in, u64 *out)
{}

static acpi_status WMID_gaming_set_u64(u64 value, u32 cap)
{}

static acpi_status WMID_gaming_get_u64(u64 *value, u32 cap)
{}

static void WMID_gaming_set_fan_mode(u8 fan_mode)
{}

/*
 * Generic Device (interface-independent)
 */

static acpi_status get_u32(u32 *value, u32 cap)
{}

static acpi_status set_u32(u32 value, u32 cap)
{}

static void __init acer_commandline_init(void)
{}

/*
 * LED device (Mail LED only, no other LEDs known yet)
 */
static void mail_led_set(struct led_classdev *led_cdev,
enum led_brightness value)
{}

static struct led_classdev mail_led =;

static int acer_led_init(struct device *dev)
{}

static void acer_led_exit(void)
{}

/*
 * Backlight device
 */
static struct backlight_device *acer_backlight_device;

static int read_brightness(struct backlight_device *bd)
{}

static int update_bl_status(struct backlight_device *bd)
{}

static const struct backlight_ops acer_bl_ops =;

static int acer_backlight_init(struct device *dev)
{}

static void acer_backlight_exit(void)
{}

/*
 * Accelerometer device
 */
static acpi_handle gsensor_handle;

static int acer_gsensor_init(void)
{}

static int acer_gsensor_open(struct input_dev *input)
{}

static int acer_gsensor_event(void)
{}

static int acer_get_fan_speed(int fan)
{}

/*
 *  Predator series turbo button
 */
static int acer_toggle_turbo(void)
{}

static int
acer_predator_v4_platform_profile_get(struct platform_profile_handler *pprof,
				      enum platform_profile_option *profile)
{}

static int
acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof,
				      enum platform_profile_option profile)
{}

static int acer_platform_profile_setup(void)
{}

static int acer_thermal_profile_change(void)
{}

/*
 * Switch series keyboard dock status
 */
static int acer_kbd_dock_state_to_sw_tablet_mode(u8 kbd_dock_state)
{}

static void acer_kbd_dock_get_initial_state(void)
{}

static void acer_kbd_dock_event(const struct event_return_value *event)
{}

/*
 * Rfkill devices
 */
static void acer_rfkill_update(struct work_struct *ignored);
static DECLARE_DELAYED_WORK(acer_rfkill_work, acer_rfkill_update);
static void acer_rfkill_update(struct work_struct *ignored)
{}

static int acer_rfkill_set(void *data, bool blocked)
{}

static const struct rfkill_ops acer_rfkill_ops =;

static struct rfkill *acer_rfkill_register(struct device *dev,
					   enum rfkill_type type,
					   char *name, u32 cap)
{}

static int acer_rfkill_init(struct device *dev)
{}

static void acer_rfkill_exit(void)
{}

static void acer_wmi_notify(union acpi_object *obj, void *context)
{}

static acpi_status __init
wmid3_set_function_mode(struct func_input_params *params,
			struct func_return_value *return_value)
{}

static int __init acer_wmi_enable_ec_raw(void)
{}

static int __init acer_wmi_enable_lm(void)
{}

static int __init acer_wmi_enable_rf_button(void)
{}

static int __init acer_wmi_accel_setup(void)
{}

static int __init acer_wmi_input_setup(void)
{}

static void acer_wmi_input_destroy(void)
{}

/*
 * debugfs functions
 */
static u32 get_wmid_devices(void)
{}

static int acer_wmi_hwmon_init(void);

/*
 * Platform device
 */
static int acer_platform_probe(struct platform_device *device)
{}

static void acer_platform_remove(struct platform_device *device)
{}

#ifdef CONFIG_PM_SLEEP
static int acer_suspend(struct device *dev)
{}

static int acer_resume(struct device *dev)
{}
#else
#define acer_suspend
#define acer_resume
#endif

static SIMPLE_DEV_PM_OPS(acer_pm, acer_suspend, acer_resume);

static void acer_platform_shutdown(struct platform_device *device)
{}

static struct platform_driver acer_platform_driver =;

static struct platform_device *acer_platform_device;

static void remove_debugfs(void)
{}

static void __init create_debugfs(void)
{}

static umode_t acer_wmi_hwmon_is_visible(const void *data,
					 enum hwmon_sensor_types type, u32 attr,
					 int channel)
{}

static int acer_wmi_hwmon_read(struct device *dev, enum hwmon_sensor_types type,
			       u32 attr, int channel, long *val)
{}

static const struct hwmon_channel_info *const acer_wmi_hwmon_info[] =;

static const struct hwmon_ops acer_wmi_hwmon_ops =;

static const struct hwmon_chip_info acer_wmi_hwmon_chip_info =;

static int acer_wmi_hwmon_init(void)
{}

static int __init acer_wmi_init(void)
{}

static void __exit acer_wmi_exit(void)
{}

module_init();
module_exit(acer_wmi_exit);