This commit is contained in:
Jeremy Soller 2017-12-28 12:47:12 -07:00
parent a5e9fc20c0
commit 4c070de0c8
7 changed files with 51 additions and 72 deletions

2
dmi.c
View File

@ -38,7 +38,7 @@ static int __init s76_dmi_matched(const struct dmi_system_id *id)
} }
static struct dmi_system_id s76_dmi_table[] __initdata = { static struct dmi_system_id s76_dmi_table[] __initdata = {
DMI_TABLE("bonw13", kb_full_color_ops), DMI_TABLE("bonw13", kb_full_color_with_extra_ops),
{} {}
}; };

2
fan.c
View File

@ -19,6 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
//#define EXPERIMENTAL
#if S76_HAS_HWMON #if S76_HAS_HWMON
struct s76_hwmon { struct s76_hwmon {
struct device *dev; struct device *dev;

42
input.c
View File

@ -55,12 +55,23 @@ MODULE_PARM_DESC(poll_freq, "Set polling frequency");
static struct task_struct *s76_input_polling_task; static struct task_struct *s76_input_polling_task;
static void s76_input_airplane_key(void) {
mutex_lock(&s76_input_report_mutex);
input_report_key(s76_input_device, AIRPLANE_KEY, 1);
input_sync(s76_input_device);
input_report_key(s76_input_device, AIRPLANE_KEY, 0);
input_sync(s76_input_device);
mutex_unlock(&s76_input_report_mutex);
}
static int s76_input_polling_thread(void *data) { static int s76_input_polling_thread(void *data) {
S76_INFO("Polling thread started (PID: %i), polling at %i Hz\n", S76_INFO("Polling thread started (PID: %i), polling at %i Hz\n",
current->pid, param_poll_freq); current->pid, param_poll_freq);
while (!kthread_should_stop()) { while (!kthread_should_stop()) {
u8 byte; u8 byte;
ec_read(0xDB, &byte); ec_read(0xDB, &byte);
@ -69,22 +80,9 @@ static int s76_input_polling_thread(void *data) {
S76_INFO("Airplane-Mode Hotkey pressed (EC)\n"); S76_INFO("Airplane-Mode Hotkey pressed (EC)\n");
mutex_lock(&s76_input_report_mutex); s76_input_airplane_key();
input_report_key(s76_input_device, AIRPLANE_KEY, 1);
input_sync(s76_input_device);
input_report_key(s76_input_device, AIRPLANE_KEY, 0);
input_sync(s76_input_device);
S76_INFO("Led status: %d",
airplane_led_get(&airplane_led));
airplane_led_set(&airplane_led,
(airplane_led_get(&airplane_led) ? 0 : 1));
mutex_unlock(&s76_input_report_mutex);
} }
msleep_interruptible(1000 / param_poll_freq); msleep_interruptible(1000 / param_poll_freq);
} }
@ -93,7 +91,7 @@ static int s76_input_polling_thread(void *data) {
return 0; return 0;
} }
static void airplane_wmi(void) { static void s76_input_airplane_wmi(void) {
S76_INFO("Airplane-Mode Hotkey pressed (WMI)\n"); S76_INFO("Airplane-Mode Hotkey pressed (WMI)\n");
if (s76_input_polling_task) { if (s76_input_polling_task) {
@ -102,15 +100,7 @@ static void airplane_wmi(void) {
s76_input_polling_task = NULL; s76_input_polling_task = NULL;
} }
mutex_lock(&s76_input_report_mutex); s76_input_airplane_key();
input_report_key(s76_input_device, AIRPLANE_KEY, 1);
input_sync(s76_input_device);
input_report_key(s76_input_device, AIRPLANE_KEY, 0);
input_sync(s76_input_device);
mutex_unlock(&s76_input_report_mutex);
} }
static int s76_input_open(struct input_dev *dev) static int s76_input_open(struct input_dev *dev)

1
kb.c
View File

@ -93,7 +93,6 @@ module_param_array_named(kb_color, param_kb_color, kb_color,
&param_kb_color_num, S_IRUSR); &param_kb_color_num, S_IRUSR);
MODULE_PARM_DESC(kb_color, "Set the color(s) of the keyboard (sections)"); MODULE_PARM_DESC(kb_color, "Set the color(s) of the keyboard (sections)");
static int param_set_kb_brightness(const char *val, static int param_set_kb_brightness(const char *val,
const struct kernel_param *kp) const struct kernel_param *kp)
{ {

16
led.c
View File

@ -19,10 +19,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
static bool param_led_invert;
module_param_named(led_invert, param_led_invert, bool, 0);
MODULE_PARM_DESC(led_invert, "Invert airplane mode LED state.");
static struct workqueue_struct *led_workqueue; static struct workqueue_struct *led_workqueue;
static struct _led_work { static struct _led_work {
@ -39,10 +35,7 @@ static void airplane_led_update(struct work_struct *work)
ec_read(0xD9, &byte); ec_read(0xD9, &byte);
if (param_led_invert) ec_write(0xD9, w->wk ? byte & ~0x40 : byte | 0x40);
ec_write(0xD9, w->wk ? byte & ~0x40 : byte | 0x40);
else
ec_write(0xD9, w->wk ? byte | 0x40 : byte & ~0x40);
/* wmbb 0x6C 1 (?) */ /* wmbb 0x6C 1 (?) */
} }
@ -53,10 +46,7 @@ static enum led_brightness airplane_led_get(struct led_classdev *led_cdev)
ec_read(0xD9, &byte); ec_read(0xD9, &byte);
if (param_led_invert) return byte & 0x40 ? LED_OFF : LED_FULL;
return byte & 0x40 ? LED_OFF : LED_FULL;
else
return byte & 0x40 ? LED_FULL : LED_OFF;
} }
/* must not sleep */ /* must not sleep */
@ -79,8 +69,6 @@ static struct led_classdev airplane_led = {
static int __init s76_led_init(void) static int __init s76_led_init(void)
{ {
int err; int err;
param_led_invert = TRUE;
led_workqueue = create_singlethread_workqueue("led_workqueue"); led_workqueue = create_singlethread_workqueue("led_workqueue");
if (unlikely(!led_workqueue)) if (unlikely(!led_workqueue))

View File

@ -26,8 +26,6 @@
#define S76_DRIVER_NAME KBUILD_MODNAME #define S76_DRIVER_NAME KBUILD_MODNAME
#define pr_fmt(fmt) S76_DRIVER_NAME ": " fmt #define pr_fmt(fmt) S76_DRIVER_NAME ": " fmt
//#define EXPERIMENTAL
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/dmi.h> #include <linux/dmi.h>
@ -53,7 +51,6 @@
__func__, __LINE__, ##__VA_ARGS__) __func__, __LINE__, ##__VA_ARGS__)
#define S76_EVENT_GUID "ABBC0F6B-8EA1-11D1-00A0-C90629100000" #define S76_EVENT_GUID "ABBC0F6B-8EA1-11D1-00A0-C90629100000"
#define S76_EMAIL_GUID "ABBC0F6C-8EA1-11D1-00A0-C90629100000"
#define S76_GET_GUID "ABBC0F6D-8EA1-11D1-00A0-C90629100000" #define S76_GET_GUID "ABBC0F6D-8EA1-11D1-00A0-C90629100000"
#define S76_HAS_HWMON (defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))) #define S76_HAS_HWMON (defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE)))
@ -139,32 +136,35 @@ static int __init s76_init(void)
platform_create_bundle(&s76_platform_driver, platform_create_bundle(&s76_platform_driver,
s76_wmi_probe, NULL, 0, NULL, 0); s76_wmi_probe, NULL, 0, NULL, 0);
if (unlikely(IS_ERR(s76_platform_device))) if (unlikely(IS_ERR(s76_platform_device))) {
return PTR_ERR(s76_platform_device); return PTR_ERR(s76_platform_device);
}
// err = s76_input_init(); err = s76_input_init();
// if (unlikely(err)) if (unlikely(err)) {
// S76_ERROR("Could not register input device\n"); S76_ERROR("Could not register input device\n");
}
err = s76_led_init(); err = s76_led_init();
if (unlikely(err)) if (unlikely(err)) {
S76_ERROR("Could not register LED device\n"); S76_ERROR("Could not register LED device\n");
}
if (device_create_file(&s76_platform_device->dev,
&dev_attr_kb_brightness) != 0) if (device_create_file(&s76_platform_device->dev, &dev_attr_kb_brightness) != 0) {
S76_ERROR("Sysfs attribute creation failed for brightness\n"); S76_ERROR("Sysfs attribute creation failed for brightness\n");
}
if (device_create_file(&s76_platform_device->dev,
&dev_attr_kb_state) != 0) if (device_create_file(&s76_platform_device->dev, &dev_attr_kb_state) != 0) {
S76_ERROR("Sysfs attribute creation failed for state\n"); S76_ERROR("Sysfs attribute creation failed for state\n");
}
if (device_create_file(&s76_platform_device->dev,
&dev_attr_kb_mode) != 0) if (device_create_file(&s76_platform_device->dev, &dev_attr_kb_mode) != 0) {
S76_ERROR("Sysfs attribute creation failed for mode\n"); S76_ERROR("Sysfs attribute creation failed for mode\n");
}
if (device_create_file(&s76_platform_device->dev,
&dev_attr_kb_color) != 0) if (device_create_file(&s76_platform_device->dev, &dev_attr_kb_color) != 0) {
S76_ERROR("Sysfs attribute creation failed for color\n"); S76_ERROR("Sysfs attribute creation failed for color\n");
}
#ifdef S76_HAS_HWMON #ifdef S76_HAS_HWMON
s76_hwmon_init(&s76_platform_device->dev); s76_hwmon_init(&s76_platform_device->dev);
@ -175,17 +175,17 @@ static int __init s76_init(void)
static void __exit s76_exit(void) static void __exit s76_exit(void)
{ {
s76_led_exit(); #ifdef S76_HAS_HWMON
// s76_input_exit(); s76_hwmon_fini(&s76_platform_device->dev);
#endif
#ifdef S76_HAS_HWMON
s76_hwmon_fini(&s76_platform_device->dev);
#endif
device_remove_file(&s76_platform_device->dev,
&dev_attr_kb_brightness);
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_state);
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_mode);
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_color); device_remove_file(&s76_platform_device->dev, &dev_attr_kb_color);
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_mode);
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_state);
device_remove_file(&s76_platform_device->dev, &dev_attr_kb_brightness);
s76_led_exit();
s76_input_exit();
platform_device_unregister(s76_platform_device); platform_device_unregister(s76_platform_device);
platform_driver_unregister(&s76_platform_driver); platform_driver_unregister(&s76_platform_driver);

2
wmi.c
View File

@ -34,7 +34,7 @@ static void s76_wmi_notify(u32 value, void *context)
switch (event) { switch (event) {
case 0xF4: case 0xF4:
airplane_wmi(); s76_input_airplane_wmi();
break; break;
default: default:
kb_wmi(event); kb_wmi(event);