mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 12:15:15 +07:00
1621633323
Based on 2 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 51 franklin street fifth floor boston ma 02110 1301 usa this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option [no]_[pad]_[ctrl] any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details you should have received a copy of the gnu general public license along with this program if not write to the free software foundation inc 51 franklin street fifth floor boston ma 02110 1301 usa extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 176 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Jilayne Lovejoy <opensource@jilayne.com> Reviewed-by: Steve Winslow <swinslow@gmail.com> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190519154040.652910950@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
101 lines
2.0 KiB
C
101 lines
2.0 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Airplane mode button for HP & Xiaomi laptops
|
|
*
|
|
* Copyright (C) 2014-2017 Alex Hung <alex.hung@canonical.com>
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/input.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/acpi.h>
|
|
#include <acpi/acpi_bus.h>
|
|
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_AUTHOR("Alex Hung");
|
|
MODULE_ALIAS("acpi*:HPQ6001:*");
|
|
MODULE_ALIAS("acpi*:WSTADEF:*");
|
|
|
|
static struct input_dev *hpwl_input_dev;
|
|
|
|
static const struct acpi_device_id hpwl_ids[] = {
|
|
{"HPQ6001", 0},
|
|
{"WSTADEF", 0},
|
|
{"", 0},
|
|
};
|
|
|
|
static int hp_wireless_input_setup(void)
|
|
{
|
|
int err;
|
|
|
|
hpwl_input_dev = input_allocate_device();
|
|
if (!hpwl_input_dev)
|
|
return -ENOMEM;
|
|
|
|
hpwl_input_dev->name = "HP Wireless hotkeys";
|
|
hpwl_input_dev->phys = "hpq6001/input0";
|
|
hpwl_input_dev->id.bustype = BUS_HOST;
|
|
hpwl_input_dev->evbit[0] = BIT(EV_KEY);
|
|
set_bit(KEY_RFKILL, hpwl_input_dev->keybit);
|
|
|
|
err = input_register_device(hpwl_input_dev);
|
|
if (err)
|
|
goto err_free_dev;
|
|
|
|
return 0;
|
|
|
|
err_free_dev:
|
|
input_free_device(hpwl_input_dev);
|
|
return err;
|
|
}
|
|
|
|
static void hp_wireless_input_destroy(void)
|
|
{
|
|
input_unregister_device(hpwl_input_dev);
|
|
}
|
|
|
|
static void hpwl_notify(struct acpi_device *acpi_dev, u32 event)
|
|
{
|
|
if (event != 0x80) {
|
|
pr_info("Received unknown event (0x%x)\n", event);
|
|
return;
|
|
}
|
|
|
|
input_report_key(hpwl_input_dev, KEY_RFKILL, 1);
|
|
input_sync(hpwl_input_dev);
|
|
input_report_key(hpwl_input_dev, KEY_RFKILL, 0);
|
|
input_sync(hpwl_input_dev);
|
|
}
|
|
|
|
static int hpwl_add(struct acpi_device *device)
|
|
{
|
|
int err;
|
|
|
|
err = hp_wireless_input_setup();
|
|
if (err)
|
|
pr_err("Failed to setup hp wireless hotkeys\n");
|
|
|
|
return err;
|
|
}
|
|
|
|
static int hpwl_remove(struct acpi_device *device)
|
|
{
|
|
hp_wireless_input_destroy();
|
|
return 0;
|
|
}
|
|
|
|
static struct acpi_driver hpwl_driver = {
|
|
.name = "hp-wireless",
|
|
.owner = THIS_MODULE,
|
|
.ids = hpwl_ids,
|
|
.ops = {
|
|
.add = hpwl_add,
|
|
.remove = hpwl_remove,
|
|
.notify = hpwl_notify,
|
|
},
|
|
};
|
|
|
|
module_acpi_driver(hpwl_driver);
|