From patchwork Thu Oct 8 16:15:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leann Ogasawara X-Patchwork-Id: 35468 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 305E9B7B70 for ; Fri, 9 Oct 2009 03:15:42 +1100 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.60) (envelope-from ) id 1MvveR-0005jB-1R; Thu, 08 Oct 2009 17:15:35 +0100 Received: from adelie.canonical.com ([91.189.90.139]) by chlorine.canonical.com with esmtp (Exim 4.60) (envelope-from ) id 1MvveK-0005gV-Un for kernel-team@lists.ubuntu.com; Thu, 08 Oct 2009 17:15:29 +0100 Received: from hutte.canonical.com ([91.189.90.181]) by adelie.canonical.com with esmtp (Exim 4.69 #1 (Debian)) id 1MvveJ-0007bY-Tz for ; Thu, 08 Oct 2009 17:15:28 +0100 Received: from c-76-105-148-120.hsd1.or.comcast.net ([76.105.148.120] helo=[192.168.1.2]) by hutte.canonical.com with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1MvveJ-00077g-FL for kernel-team@lists.ubuntu.com; Thu, 08 Oct 2009 17:15:27 +0100 Subject: Re: [PATCH 2/2] [Karmic] UBUNTU: [Upstream] dell-laptop: Trigger rfkill updates on wifi toggle switch press From: Leann Ogasawara To: kernel-team In-Reply-To: <1255018355.2422.520.camel@emiko> References: <1255018355.2422.520.camel@emiko> Date: Thu, 08 Oct 2009 09:15:24 -0700 Message-Id: <1255018524.2422.524.camel@emiko> Mime-Version: 1.0 X-Mailer: Evolution 2.28.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.8 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com >From 172cd5723ce3730796ff331736ee37c76455b7a9 Mon Sep 17 00:00:00 2001 From: Leann Ogasawara Date: Tue, 6 Oct 2009 10:51:54 -0700 Subject: [PATCH 2/2] UBUNTU: [Upstream] [PATCH] dell-laptop: Trigger rfkill updates on wifi toggle switch press OriginalLocation: http://patchwork.kernel.org/patch/38439/ BugLink: http://bugs.launchpad.net/bugs/430809 Dell hardware sends the rfkill hardware killswitch event via the keyboard controller, even if it's a physical toggle switch on the side of the machine. Add support for catching the input event and updating the rfkill state, allowing userspace to receive notifications that the change has occurred. Signed-off-by: Matthew Garrett Signed-off-by: Leann Ogasawara --- drivers/platform/x86/dell-laptop.c | 100 ++++++++++++++++++++++++++++++++++++ 1 files changed, 100 insertions(+), 0 deletions(-) diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index 5a2a519..b6080cc 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "../../firmware/dcdbas.h" #define BRIGHTNESS_TOKEN 0x7d @@ -210,6 +211,16 @@ static const struct rfkill_ops dell_rfkill_ops = { .query = dell_rfkill_query, }; +static void dell_rfkill_update(void) +{ + if (wifi_rfkill) + dell_rfkill_query(wifi_rfkill, (void *)1); + if (bluetooth_rfkill) + dell_rfkill_query(bluetooth_rfkill, (void *)2); + if (wwan_rfkill) + dell_rfkill_query(wwan_rfkill, (void *)3); +} + static int dell_setup_rfkill(void) { struct calling_interface_buffer buffer; @@ -314,6 +325,90 @@ static struct backlight_ops dell_ops = { .update_status = dell_send_intensity, }; +static const struct input_device_id dell_input_ids[] = { + { + .bustype = 0x11, + .vendor = 0x01, + .product = 0x01, + .version = 0xab41, + .flags = INPUT_DEVICE_ID_MATCH_BUS | + INPUT_DEVICE_ID_MATCH_VENDOR | + INPUT_DEVICE_ID_MATCH_PRODUCT | + INPUT_DEVICE_ID_MATCH_VERSION + }, + { }, +}; + +static bool dell_input_filter(struct input_handle *handle, unsigned int type, + unsigned int code, int value) +{ + if (type == EV_KEY && code == KEY_WLAN && value == 1) { + dell_rfkill_update(); + return 1; + } + + return 0; +} + +static void dell_input_event(struct input_handle *handle, unsigned int type, + unsigned int code, int value) +{ +} + +static int dell_input_connect(struct input_handler *handler, + struct input_dev *dev, + const struct input_device_id *id) +{ + struct input_handle *handle; + int error; + + handle = kzalloc(sizeof(struct input_handle), GFP_KERNEL); + if (!handle) + return -ENOMEM; + + handle->dev = dev; + handle->handler = handler; + handle->name = "dell-laptop"; + + error = input_register_handle(handle); + if (error) + goto err_free_handle; + + error = input_open_device(handle); + if (error) + goto err_unregister_handle; + + error = input_filter_device(handle); + if (error) + goto err_close_handle; + + return 0; + +err_close_handle: + input_close_device(handle); +err_unregister_handle: + input_unregister_handle(handle); +err_free_handle: + kfree(handle); + return error; +} + +static void dell_input_disconnect(struct input_handle *handle) +{ + input_close_device(handle); + input_unregister_handle(handle); + kfree(handle); +} + +static struct input_handler dell_input_handler = { + .name = "dell-laptop", + .filter = dell_input_filter, + .event = dell_input_event, + .connect = dell_input_connect, + .disconnect = dell_input_disconnect, + .id_table = dell_input_ids, +}; + static int __init dell_init(void) { struct calling_interface_buffer buffer; @@ -337,6 +432,10 @@ static int __init dell_init(void) goto out; } + if (input_register_handler(&dell_input_handler)) + printk(KERN_INFO + "dell-laptop: Could not register input filter\n"); + #ifdef CONFIG_ACPI /* In the event of an ACPI backlight being available, don't * register the platform controller. @@ -392,6 +491,7 @@ static void __exit dell_exit(void) rfkill_unregister(bluetooth_rfkill); if (wwan_rfkill) rfkill_unregister(wwan_rfkill); + input_unregister_handler(&dell_input_handler); } module_init(dell_init);