From patchwork Sat Oct 30 16:36:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chun-Yi Lee X-Patchwork-Id: 292112 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9UGZWeK027721 for ; Sat, 30 Oct 2010 16:37:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754821Ab0J3Qhs (ORCPT ); Sat, 30 Oct 2010 12:37:48 -0400 Received: from mail-ww0-f42.google.com ([74.125.82.42]:34263 "EHLO mail-ww0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754813Ab0J3Qhr (ORCPT ); Sat, 30 Oct 2010 12:37:47 -0400 Received: by wwi18 with SMTP id 18so5239241wwi.1 for ; Sat, 30 Oct 2010 09:37:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=8f4wgyUzcj21HdzDppCxAC2INlAGjs8jBHzMuhu0EPE=; b=fJVTh20pjTgYRqaaFx00k6Ctv29+OnOyJB2ZR1RUURFYVmPkQ0KTSUVlyTYyir6Duz XSbuxi8xqUtOF7xlVD5BSdLd89nMLZ30sdnxZJJK2dgMkVadyp67Vr7/zV2B61rxVBSn TJNX1E/C912i16++rlbsfIclWvMStjdfVuDEM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=Xm4EUtiIQF8224NTzaREKn7liCuo1sy2NDHDop8FBsrHX6pJsUtM8PP95OwnUvLGiV sy6dN1qC6qG1OtZ+6mrLbg28lSxnirwNe2xIL1JJEdg8muXfRImZN18/d2ym1O+JvYOL HZoOxCAYDdo0ytRVfe24sLP3PEfFypl0OujTI= Received: by 10.216.165.16 with SMTP id d16mr13494246wel.0.1288456665555; Sat, 30 Oct 2010 09:37:45 -0700 (PDT) Received: from localhost.localdomain (124-11-22-254.dynamic.tfn.net.tw [124.11.22.254]) by mx.google.com with ESMTPS id x15sm2491487weq.31.2010.10.30.09.37.40 (version=SSLv3 cipher=RC4-MD5); Sat, 30 Oct 2010 09:37:44 -0700 (PDT) From: "Lee, Chun-Yi" To: platform-driver-x86@vger.kernel.org Cc: linux-input@vger.kernel.org, carlos@strangeworlds.co.uk, corentin.chary@gmail.com, dmitry.torokhov@gmail.com, tiwai@novell.com, trenn@novell.com, mjg59@srcf.ucam.org, jbenc@suse.cz, "Lee, Chun-Yi" Subject: [PATCH 3/4] Add 3G rfkill sysfs file Date: Sun, 31 Oct 2010 00:36:32 +0800 Message-Id: <1288456593-6868-3-git-send-email-jlee@novell.com> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1288456593-6868-2-git-send-email-jlee@novell.com> References: <1288456593-6868-1-git-send-email-jlee@novell.com> <1288456593-6868-2-git-send-email-jlee@novell.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sat, 30 Oct 2010 16:37:48 +0000 (UTC) diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 0b870d3..9656464 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -136,6 +136,24 @@ struct lm_return_value { } __attribute__((packed)); /* + * GUID3 Get Device Status device flags + */ +#define ACER_WMID3_GDS_THREEG (1<<6) /* 3G */ + +struct wmid3_gds_input_param { /* Get Device Status input parameter */ + u8 function_num; /* Function Number */ + u8 hotkey_number; /* Hotkey Number */ + u16 devices; /* Get Device */ +} __attribute__((packed)); + +struct wmid3_gds_return_value { /* Get Device Status return value*/ + u8 error_code; /* Error Code */ + u8 ec_return_value; /* EC Return Value */ + u16 devices; /* Current Device Status */ + u32 reserved; +} __attribute__((packed)); + +/* * Interface capability flags */ #define ACER_CAP_MAILLED (1<<0) @@ -192,6 +210,7 @@ struct acer_debug { static struct rfkill *wireless_rfkill; static struct rfkill *bluetooth_rfkill; +static struct rfkill *threeg_rfkill; /* Each low-level interface must define at least some of the following */ struct wmi_interface { @@ -1000,6 +1019,54 @@ static void acer_backlight_exit(void) backlight_device_unregister(acer_backlight_device); } +static acpi_status wmid3_get_device_status(u32 *value, u16 device) +{ + struct wmid3_gds_return_value return_value; + acpi_status status; + union acpi_object *obj; + struct wmid3_gds_input_param params = { + .function_num = 0x1, + .hotkey_number = 0x01, + .devices = device, + }; + struct acpi_buffer input = { + sizeof(struct wmid3_gds_input_param), + ¶ms + }; + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; + + status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &input, &output); + if (ACPI_FAILURE(status)) + return status; + + obj = output.pointer; + + if (!obj) + return -EINVAL; + else if (obj->type != ACPI_TYPE_BUFFER) { + kfree(obj); + return -EINVAL; + } + if (obj->buffer.length != 8) { + printk(ACER_WARNING "Unknown buffer length %d\n", + obj->buffer.length); + kfree(obj); + return -EINVAL; + } + + return_value = *((struct wmid3_gds_return_value *)obj->buffer.pointer); + kfree(obj); + + if (return_value.error_code || return_value.ec_return_value) + printk(ACER_WARNING "Get Device Status failed: " + "0x%x - 0x%x\n", return_value.error_code, + return_value.ec_return_value); + else + *value = !!(return_value.devices & device); + + return status; +} + /* * Rfkill devices */ @@ -1020,6 +1087,13 @@ static void acer_rfkill_update(struct work_struct *ignored) rfkill_set_sw_state(bluetooth_rfkill, !state); } + if (has_cap(ACER_CAP_THREEG) && wmi_has_guid(WMID_GUID3)) { + status = wmid3_get_device_status(&state, + ACER_WMID3_GDS_THREEG); + if (ACPI_SUCCESS(status)) + rfkill_set_sw_state(threeg_rfkill, !state); + } + schedule_delayed_work(&acer_rfkill_work, round_jiffies_relative(HZ)); } @@ -1076,6 +1150,19 @@ static int acer_rfkill_init(struct device *dev) } } + if (has_cap(ACER_CAP_THREEG)) { + threeg_rfkill = acer_rfkill_register(dev, + RFKILL_TYPE_WWAN, "acer-threeg", + ACER_CAP_THREEG); + if (IS_ERR(threeg_rfkill)) { + rfkill_unregister(wireless_rfkill); + rfkill_destroy(wireless_rfkill); + rfkill_unregister(bluetooth_rfkill); + rfkill_destroy(bluetooth_rfkill); + return PTR_ERR(threeg_rfkill); + } + } + schedule_delayed_work(&acer_rfkill_work, round_jiffies_relative(HZ)); return 0; @@ -1092,6 +1179,11 @@ static void acer_rfkill_exit(void) rfkill_unregister(bluetooth_rfkill); rfkill_destroy(bluetooth_rfkill); } + + if (has_cap(ACER_CAP_THREEG)) { + rfkill_unregister(threeg_rfkill); + rfkill_destroy(threeg_rfkill); + } return; } @@ -1102,7 +1194,12 @@ static ssize_t show_bool_threeg(struct device *dev, struct device_attribute *attr, char *buf) { u32 result; \ - acpi_status status = get_u32(&result, ACER_CAP_THREEG); + acpi_status status; + if (wmi_has_guid(WMID_GUID3)) + status = wmid3_get_device_status(&result, + ACER_WMID3_GDS_THREEG); + else + status = get_u32(&result, ACER_CAP_THREEG); if (ACPI_SUCCESS(status)) return sprintf(buf, "%u\n", result); return sprintf(buf, "Read error\n");