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

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * HP WMI hotkeys
 *
 * Copyright (C) 2008 Red Hat <[email protected]>
 * Copyright (C) 2010, 2011 Anssi Hannula <[email protected]>
 *
 * Portions based on wistron_btns.c:
 * Copyright (C) 2005 Miloslav Trmac <[email protected]>
 * Copyright (C) 2005 Bernhard Rosenkraenzer <[email protected]>
 * Copyright (C) 2005 Dmitry Torokhov <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/input.h>
#include <linux/input/sparse-keymap.h>
#include <linux/platform_device.h>
#include <linux/platform_profile.h>
#include <linux/hwmon.h>
#include <linux/acpi.h>
#include <linux/mutex.h>
#include <linux/cleanup.h>
#include <linux/power_supply.h>
#include <linux/rfkill.h>
#include <linux/string.h>
#include <linux/dmi.h>

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

MODULE_ALIAS();
MODULE_ALIAS();

#define HPWMI_EVENT_GUID
#define HPWMI_BIOS_GUID

#define HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET
#define HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET
#define HP_OMEN_EC_THERMAL_PROFILE_OFFSET

#define ACPI_AC_CLASS

#define zero_if_sup(tmp)

/* DMI board names of devices that should use the omen specific path for
 * thermal profiles.
 * This was obtained by taking a look in the windows omen command center
 * app and parsing a json file that they use to figure out what capabilities
 * the device should have.
 * A device is considered an omen if the DisplayName in that list contains
 * "OMEN", and it can use the thermal profile stuff if the "Feature" array
 * contains "PerformanceControl".
 */
static const char * const omen_thermal_profile_boards[] =;

/* DMI Board names of Omen laptops that are specifically set to be thermal
 * profile version 0 by the Omen Command Center app, regardless of what
 * the get system design information WMI call returns
 */
static const char * const omen_thermal_profile_force_v0_boards[] =;

/* DMI board names of Omen laptops that have a thermal profile timer which will
 * cause the embedded controller to set the thermal profile back to
 * "balanced" when reaching zero.
 */
static const char * const omen_timed_thermal_profile_boards[] =;

/* DMI Board names of Victus laptops */
static const char * const victus_thermal_profile_boards[] =;

enum hp_wmi_radio {};

enum hp_wmi_event_ids {};

/*
 * struct bios_args buffer is dynamically allocated.  New WMI command types
 * were introduced that exceeds 128-byte data size.  Changes to handle
 * the data size allocation scheme were kept in hp_wmi_perform_qurey function.
 */
struct bios_args {};

enum hp_wmi_commandtype {};

enum hp_wmi_gm_commandtype {};

enum hp_wmi_command {};

enum hp_wmi_hardware_mask {};

struct bios_return {};

enum hp_return_value {};

enum hp_wireless2_bits {};

enum hp_thermal_profile_omen_v0 {};

enum hp_thermal_profile_omen_v1 {};

enum hp_thermal_profile_omen_flags {};

enum hp_thermal_profile_victus {};

enum hp_thermal_profile {};

#define IS_HWBLOCKED(x)
#define IS_SWBLOCKED(x)

struct bios_rfkill2_device_state {};

/* 7 devices fit into the 128 byte buffer */
#define HPWMI_MAX_RFKILL2_DEVICES

struct bios_rfkill2_state {};

static const struct key_entry hp_wmi_keymap[] =;

/*
 * Mutex for the active_platform_profile variable,
 * see omen_powersource_event.
 */
static DEFINE_MUTEX(active_platform_profile_lock);

static struct input_dev *hp_wmi_input_dev;
static struct input_dev *camera_shutter_input_dev;
static struct platform_device *hp_wmi_platform_dev;
static struct platform_profile_handler platform_profile_handler;
static struct notifier_block platform_power_source_nb;
static enum platform_profile_option active_platform_profile;
static bool platform_profile_support;
static bool zero_insize_support;

static struct rfkill *wifi_rfkill;
static struct rfkill *bluetooth_rfkill;
static struct rfkill *wwan_rfkill;

struct rfkill2_device {};

static int rfkill2_count;
static struct rfkill2_device rfkill2[HPWMI_MAX_RFKILL2_DEVICES];

/*
 * Chassis Types values were obtained from SMBIOS reference
 * specification version 3.00. A complete list of system enclosures
 * and chassis types is available on Table 17.
 */
static const char * const tablet_chassis_types[] =;

#define DEVICE_MODE_TABLET

/* map output size to the corresponding WMI method id */
static inline int encode_outsize_for_pvsz(int outsize)
{}

/*
 * hp_wmi_perform_query
 *
 * query:	The commandtype (enum hp_wmi_commandtype)
 * write:	The command (enum hp_wmi_command)
 * buffer:	Buffer used as input and/or output
 * insize:	Size of input buffer
 * outsize:	Size of output buffer
 *
 * returns zero on success
 *         an HP WMI query specific error code (which is positive)
 *         -EINVAL if the query was not successful at all
 *         -EINVAL if the output buffer size exceeds buffersize
 *
 * Note: The buffersize must at least be the maximum of the input and output
 *       size. E.g. Battery info query is defined to have 1 byte input
 *       and 128 byte output. The caller would do:
 *       buffer = kzalloc(128, GFP_KERNEL);
 *       ret = hp_wmi_perform_query(HPWMI_BATTERY_QUERY, HPWMI_READ, buffer, 1, 128)
 */
static int hp_wmi_perform_query(int query, enum hp_wmi_command command,
				void *buffer, int insize, int outsize)
{}

static int hp_wmi_get_fan_speed(int fan)
{}

static int hp_wmi_read_int(int query)
{}

static int hp_wmi_get_dock_state(void)
{}

static int hp_wmi_get_tablet_mode(void)
{}

static int omen_thermal_profile_set(int mode)
{}

static bool is_omen_thermal_profile(void)
{}

static int omen_get_thermal_policy_version(void)
{}

static int omen_thermal_profile_get(void)
{}

static int hp_wmi_fan_speed_max_set(int enabled)
{}

static int hp_wmi_fan_speed_max_get(void)
{}

static int __init hp_wmi_bios_2008_later(void)
{}

static int __init hp_wmi_bios_2009_later(void)
{}

static int __init hp_wmi_enable_hotkeys(void)
{}

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

static const struct rfkill_ops hp_wmi_rfkill_ops =;

static bool hp_wmi_get_sw_state(enum hp_wmi_radio r)
{}

static bool hp_wmi_get_hw_state(enum hp_wmi_radio r)
{}

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

static const struct rfkill_ops hp_wmi_rfkill2_ops =;

static int hp_wmi_rfkill2_refresh(void)
{}

static ssize_t display_show(struct device *dev, struct device_attribute *attr,
			    char *buf)
{}

static ssize_t hddtemp_show(struct device *dev, struct device_attribute *attr,
			    char *buf)
{}

static ssize_t als_show(struct device *dev, struct device_attribute *attr,
			char *buf)
{}

static ssize_t dock_show(struct device *dev, struct device_attribute *attr,
			 char *buf)
{}

static ssize_t tablet_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}

static ssize_t postcode_show(struct device *dev, struct device_attribute *attr,
			     char *buf)
{}

static ssize_t als_store(struct device *dev, struct device_attribute *attr,
			 const char *buf, size_t count)
{}

static ssize_t postcode_store(struct device *dev, struct device_attribute *attr,
			      const char *buf, size_t count)
{}

static int camera_shutter_input_setup(void)
{}

static DEVICE_ATTR_RO(display);
static DEVICE_ATTR_RO(hddtemp);
static DEVICE_ATTR_RW(als);
static DEVICE_ATTR_RO(dock);
static DEVICE_ATTR_RO(tablet);
static DEVICE_ATTR_RW(postcode);

static struct attribute *hp_wmi_attrs[] =;
ATTRIBUTE_GROUPS();

static void hp_wmi_notify(u32 value, void *context)
{}

static int __init hp_wmi_input_setup(void)
{}

static void hp_wmi_input_destroy(void)
{}

static int __init hp_wmi_rfkill_setup(struct platform_device *device)
{}

static int __init hp_wmi_rfkill2_setup(struct platform_device *device)
{}

static int platform_profile_omen_get_ec(enum platform_profile_option *profile)
{}

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

static bool has_omen_thermal_profile_ec_timer(void)
{}

inline int omen_thermal_profile_ec_flags_set(enum hp_thermal_profile_omen_flags flags)
{}

inline int omen_thermal_profile_ec_timer_set(u8 value)
{}

static int platform_profile_omen_set_ec(enum platform_profile_option profile)
{}

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

static int thermal_profile_get(void)
{}

static int thermal_profile_set(int thermal_profile)
{}

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

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

static bool is_victus_thermal_profile(void)
{}

static int platform_profile_victus_get_ec(enum platform_profile_option *profile)
{}

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

static int platform_profile_victus_set_ec(enum platform_profile_option profile)
{}

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

static int omen_powersource_event(struct notifier_block *nb,
				  unsigned long value,
				  void *data)
{}

static int omen_register_powersource_event_handler(void)
{}

static inline void omen_unregister_powersource_event_handler(void)
{}

static int thermal_profile_setup(void)
{}

static int hp_wmi_hwmon_init(void);

static int __init hp_wmi_bios_setup(struct platform_device *device)
{}

static void __exit hp_wmi_bios_remove(struct platform_device *device)
{}

static int hp_wmi_resume_handler(struct device *device)
{}

static const struct dev_pm_ops hp_wmi_pm_ops =;

/*
 * hp_wmi_bios_remove() lives in .exit.text. For drivers registered via
 * module_platform_driver_probe() this is ok because they cannot get unbound at
 * runtime. So mark the driver struct with __refdata to prevent modpost
 * triggering a section mismatch warning.
 */
static struct platform_driver hp_wmi_driver __refdata =;

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

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

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

static const struct hwmon_channel_info * const info[] =;

static const struct hwmon_ops ops =;

static const struct hwmon_chip_info chip_info =;

static int hp_wmi_hwmon_init(void)
{}

static int __init hp_wmi_init(void)
{}
module_init();

static void __exit hp_wmi_exit(void)
{}
module_exit(hp_wmi_exit);