Commit a558ea42 authored by Mario Limonciello's avatar Mario Limonciello Committed by Hans de Goede
Browse files

platform/x86: Rename hp-wireless to wireless-hotkey



This driver was originally intended to support some HP laptops, but
later support was added for Xioami and AMD laptops.

Rename it to make it clear that it supports a larger variety of
systems.

Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Link: https://lore.kernel.org/r/20210519174405.30155-1-mario.limonciello@amd.com


Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 7dc4a18d
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -415,16 +415,17 @@ config HP_ACCEL
	  To compile this driver as a module, choose M here: the module will
	  To compile this driver as a module, choose M here: the module will
	  be called hp_accel.
	  be called hp_accel.


config HP_WIRELESS
config WIRELESS_HOTKEY
	tristate "HP wireless button"
	tristate "Wireless hotkey button"
	depends on ACPI
	depends on ACPI
	depends on INPUT
	depends on INPUT
	help
	help
	 This driver provides supports for new HP wireless button for Windows 8.
	 This driver provides supports for the wireless buttons found on some AMD,
	 HP, & Xioami laptops.
	 On such systems the driver should load automatically (via ACPI alias).
	 On such systems the driver should load automatically (via ACPI alias).


	 To compile this driver as a module, choose M here: the module will
	 To compile this driver as a module, choose M here: the module will
	 be called hp-wireless.
	 be called wireless-hotkey.


config HP_WMI
config HP_WMI
	tristate "HP WMI extras"
	tristate "HP WMI extras"
+1 −1
Original line number Original line Diff line number Diff line
@@ -52,7 +52,6 @@ obj-$(CONFIG_GPD_POCKET_FAN) += gpd-pocket-fan.o


# Hewlett Packard
# Hewlett Packard
obj-$(CONFIG_HP_ACCEL)		+= hp_accel.o
obj-$(CONFIG_HP_ACCEL)		+= hp_accel.o
obj-$(CONFIG_HP_WIRELESS)	+= hp-wireless.o
obj-$(CONFIG_HP_WMI)		+= hp-wmi.o
obj-$(CONFIG_HP_WMI)		+= hp-wmi.o
obj-$(CONFIG_TC1100_WMI)	+= tc1100-wmi.o
obj-$(CONFIG_TC1100_WMI)	+= tc1100-wmi.o


@@ -115,6 +114,7 @@ obj-$(CONFIG_TOPSTAR_LAPTOP) += topstar-laptop.o
obj-$(CONFIG_I2C_MULTI_INSTANTIATE)	+= i2c-multi-instantiate.o
obj-$(CONFIG_I2C_MULTI_INSTANTIATE)	+= i2c-multi-instantiate.o
obj-$(CONFIG_MLX_PLATFORM)		+= mlx-platform.o
obj-$(CONFIG_MLX_PLATFORM)		+= mlx-platform.o
obj-$(CONFIG_TOUCHSCREEN_DMI)		+= touchscreen_dmi.o
obj-$(CONFIG_TOUCHSCREEN_DMI)		+= touchscreen_dmi.o
obj-$(CONFIG_WIRELESS_HOTKEY)		+= wireless-hotkey.o


# Intel uncore drivers
# Intel uncore drivers
obj-$(CONFIG_INTEL_IPS)				+= intel_ips.o
obj-$(CONFIG_INTEL_IPS)				+= intel_ips.o
+103 −0
Original line number Original line Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-or-later
// SPDX-License-Identifier: GPL-2.0-or-later
/*
/*
 *  Airplane mode button for HP & Xiaomi laptops
 *  Airplane mode button for AMD, HP & Xiaomi laptops
 *
 *
 *  Copyright (C) 2014-2017 Alex Hung <alex.hung@canonical.com>
 *  Copyright (C) 2014-2017 Alex Hung <alex.hung@canonical.com>
 *  Copyright (C) 2021 Advanced Micro Devices
 */
 */


#include <linux/kernel.h>
#include <linux/kernel.h>
@@ -19,84 +20,84 @@ MODULE_ALIAS("acpi*:HPQ6001:*");
MODULE_ALIAS("acpi*:WSTADEF:*");
MODULE_ALIAS("acpi*:WSTADEF:*");
MODULE_ALIAS("acpi*:AMDI0051:*");
MODULE_ALIAS("acpi*:AMDI0051:*");


static struct input_dev *hpwl_input_dev;
static struct input_dev *wl_input_dev;


static const struct acpi_device_id hpwl_ids[] = {
static const struct acpi_device_id wl_ids[] = {
	{"HPQ6001", 0},
	{"HPQ6001", 0},
	{"WSTADEF", 0},
	{"WSTADEF", 0},
	{"AMDI0051", 0},
	{"AMDI0051", 0},
	{"", 0},
	{"", 0},
};
};


static int hp_wireless_input_setup(void)
static int wireless_input_setup(void)
{
{
	int err;
	int err;


	hpwl_input_dev = input_allocate_device();
	wl_input_dev = input_allocate_device();
	if (!hpwl_input_dev)
	if (!wl_input_dev)
		return -ENOMEM;
		return -ENOMEM;


	hpwl_input_dev->name = "HP Wireless hotkeys";
	wl_input_dev->name = "Wireless hotkeys";
	hpwl_input_dev->phys = "hpq6001/input0";
	wl_input_dev->phys = "hpq6001/input0";
	hpwl_input_dev->id.bustype = BUS_HOST;
	wl_input_dev->id.bustype = BUS_HOST;
	hpwl_input_dev->evbit[0] = BIT(EV_KEY);
	wl_input_dev->evbit[0] = BIT(EV_KEY);
	set_bit(KEY_RFKILL, hpwl_input_dev->keybit);
	set_bit(KEY_RFKILL, wl_input_dev->keybit);


	err = input_register_device(hpwl_input_dev);
	err = input_register_device(wl_input_dev);
	if (err)
	if (err)
		goto err_free_dev;
		goto err_free_dev;


	return 0;
	return 0;


err_free_dev:
err_free_dev:
	input_free_device(hpwl_input_dev);
	input_free_device(wl_input_dev);
	return err;
	return err;
}
}


static void hp_wireless_input_destroy(void)
static void wireless_input_destroy(void)
{
{
	input_unregister_device(hpwl_input_dev);
	input_unregister_device(wl_input_dev);
}
}


static void hpwl_notify(struct acpi_device *acpi_dev, u32 event)
static void wl_notify(struct acpi_device *acpi_dev, u32 event)
{
{
	if (event != 0x80) {
	if (event != 0x80) {
		pr_info("Received unknown event (0x%x)\n", event);
		pr_info("Received unknown event (0x%x)\n", event);
		return;
		return;
	}
	}


	input_report_key(hpwl_input_dev, KEY_RFKILL, 1);
	input_report_key(wl_input_dev, KEY_RFKILL, 1);
	input_sync(hpwl_input_dev);
	input_sync(wl_input_dev);
	input_report_key(hpwl_input_dev, KEY_RFKILL, 0);
	input_report_key(wl_input_dev, KEY_RFKILL, 0);
	input_sync(hpwl_input_dev);
	input_sync(wl_input_dev);
}
}


static int hpwl_add(struct acpi_device *device)
static int wl_add(struct acpi_device *device)
{
{
	int err;
	int err;


	err = hp_wireless_input_setup();
	err = wireless_input_setup();
	if (err)
	if (err)
		pr_err("Failed to setup hp wireless hotkeys\n");
		pr_err("Failed to setup hp wireless hotkeys\n");


	return err;
	return err;
}
}


static int hpwl_remove(struct acpi_device *device)
static int wl_remove(struct acpi_device *device)
{
{
	hp_wireless_input_destroy();
	wireless_input_destroy();
	return 0;
	return 0;
}
}


static struct acpi_driver hpwl_driver = {
static struct acpi_driver wl_driver = {
	.name	= "hp-wireless",
	.name	= "wireless-hotkey",
	.owner	= THIS_MODULE,
	.owner	= THIS_MODULE,
	.ids	= hpwl_ids,
	.ids	= wl_ids,
	.ops	= {
	.ops	= {
		.add	= hpwl_add,
		.add	= wl_add,
		.remove	= hpwl_remove,
		.remove	= wl_remove,
		.notify	= hpwl_notify,
		.notify	= wl_notify,
	},
	},
};
};


module_acpi_driver(hpwl_driver);
module_acpi_driver(wl_driver);