public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
To: lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	Henning Schild
	<henning-wy63DpzWjhr4ajHJ1XSv27NAH6kLmebB@public.gmane.org>,
	Henrique de Moraes Holschuh
	<hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>,
	linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: ACPI: thinkpad-acpi: export to sysfs the state of the radio slider switch
Date: Sat, 14 Jul 2007 11:11:55 -0300	[thread overview]
Message-ID: <11844223332374-git-send-email-hmh@hmh.eng.br> (raw)
In-Reply-To: <11844223322928-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>

Some ThinkPad models, notably the T60 and X60, have a slider switch to
enable and disable the radios.  The switch has the capability of
force-disabling the radios in hardware on most models, and it is supposed
to affect all radios (WLAN, WWAN, BlueTooth).

Export the switch state as a sysfs attribute, on ThinkPads where it is
available.

Thanks to Henning Schild for asking for this feature, and for tracking down
the EC register that holds the radio switch state.

Signed-off-by: Henrique de Moraes Holschuh <hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
Cc: Henning Schild <henning-wy63DpzWjhr4ajHJ1XSv27NAH6kLmebB@public.gmane.org>
---
 Documentation/thinkpad-acpi.txt |    6 ++++++
 drivers/misc/thinkpad_acpi.c    |   38 ++++++++++++++++++++++++++++++++++++--
 drivers/misc/thinkpad_acpi.h    |    1 +
 3 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index 142a14f..fe26e50 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -227,6 +227,12 @@ sysfs notes:
 		supported hot keys, except those which are handled by
 		the firmware.  Echo it to hotkey_mask above, to use.
 
+	hotkey_radio_sw:
+		if the ThinkPad has a hardware radio switch, this
+		attribute will read 0 if the switch is in the "radios
+		disabled" postition, and 1 if the switch is in the
+		"radios enabled" position.
+
 
 Bluetooth
 ---------
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 8c08868..3cf37bb 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -733,6 +733,13 @@ static u32 hotkey_reserved_mask = 0x00778000;
 
 static struct attribute_set *hotkey_dev_attributes;
 
+static int hotkey_get_wlsw(int *status)
+{
+	if (!acpi_evalf(hkey_handle, status, "WLSW", "d"))
+		return -EIO;
+	return 0;
+}
+
 /* sysfs hotkey enable ------------------------------------------------- */
 static ssize_t hotkey_enable_show(struct device *dev,
 			   struct device_attribute *attr,
@@ -853,6 +860,22 @@ static struct device_attribute dev_attr_hotkey_recommended_mask =
 	__ATTR(hotkey_recommended_mask, S_IRUGO,
 		hotkey_recommended_mask_show, NULL);
 
+/* sysfs hotkey radio_sw ----------------------------------------------- */
+static ssize_t hotkey_radio_sw_show(struct device *dev,
+			   struct device_attribute *attr,
+			   char *buf)
+{
+	int res, s;
+	res = hotkey_get_wlsw(&s);
+	if (res < 0)
+		return res;
+
+	return snprintf(buf, PAGE_SIZE, "%d\n", !!s);
+}
+
+static struct device_attribute dev_attr_hotkey_radio_sw =
+	__ATTR(hotkey_radio_sw, S_IRUGO, hotkey_radio_sw_show, NULL);
+
 /* --------------------------------------------------------------------- */
 
 static struct attribute *hotkey_mask_attributes[] = {
@@ -866,6 +889,7 @@ static struct attribute *hotkey_mask_attributes[] = {
 static int __init hotkey_init(struct ibm_init_struct *iibm)
 {
 	int res;
+	int status;
 
 	vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n");
 
@@ -879,7 +903,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 		str_supported(tp_features.hotkey));
 
 	if (tp_features.hotkey) {
-		hotkey_dev_attributes = create_attr_set(6, NULL);
+		hotkey_dev_attributes = create_attr_set(7, NULL);
 		if (!hotkey_dev_attributes)
 			return -ENOMEM;
 		res = add_to_attr_set(hotkey_dev_attributes,
@@ -908,11 +932,21 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
 				hotkey_mask_attributes,
 				ARRAY_SIZE(hotkey_mask_attributes));
 		}
+
+		/* Not all thinkpads have a hardware radio switch */
+		if (!res && acpi_evalf(hkey_handle, &status, "WLSW", "qd")) {
+			tp_features.hotkey_wlsw = 1;
+			printk(IBM_INFO
+				"radio switch found; radios are %s\n",
+				enabled(status, 0));
+			res = add_to_attr_set(hotkey_dev_attributes,
+					&dev_attr_hotkey_radio_sw.attr);
+		}
+
 		if (!res)
 			res = register_attr_set_with_sysfs(
 					hotkey_dev_attributes,
 					&tpacpi_pdev->dev.kobj);
-
 		if (res)
 			return res;
 	}
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index e1a64f0..78ea4c8 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -228,6 +228,7 @@ static struct {
 	u16 bluetooth:1;
 	u16 hotkey:1;
 	u16 hotkey_mask:1;
+	u16 hotkey_wlsw:1;
 	u16 light:1;
 	u16 light_status:1;
 	u16 wan:1;
-- 
1.5.2.1


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

  parent reply	other threads:[~2007-07-14 14:11 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-14 14:11 [GIT PULL] thinkpad-acpi queue for 2.6.23 (v2) Henrique de Moraes Holschuh
     [not found] ` <11844223322928-git-send-email-hmh-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>
2007-07-14 14:11   ` ACPI: thinkpad-acpi: add DMI-based modalias Henrique de Moraes Holschuh
2007-07-14 14:11   ` ACPI: thinkpad-acpi: remove all uneeded initializers Henrique de Moraes Holschuh
2007-07-14 14:11   ` ACPI: thinkpad-acpi: update information on T43 thermal sensor 0xc1 Henrique de Moraes Holschuh
2007-07-14 14:11   ` ACPI: thinkpad-acpi: export hotkey maximum masks Henrique de Moraes Holschuh
2007-07-14 14:11   ` Henrique de Moraes Holschuh [this message]
2007-07-14 14:11   ` ACPI: thinkpad-acpi: checkpoint sysfs interface version due to hotkey Henrique de Moraes Holschuh
2007-07-14 14:11   ` ACPI: thinkpad-acpi: register input device Henrique de Moraes Holschuh
2007-07-14 14:11   ` ACPI: thinkpad-acpi: add input device support to hotkey subdriver Henrique de Moraes Holschuh
2007-07-14 22:31     ` Matthew Garrett
     [not found]       ` <20070714223144.GA25782-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>
2007-07-15 18:12         ` Henrique de Moraes Holschuh
     [not found]           ` <20070715181233.GG14134-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2007-07-15 18:45             ` Matthew Garrett
     [not found]               ` <20070715184519.GD3235-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>
2007-07-15 20:03                 ` Henrique de Moraes Holschuh
2007-07-15 20:12                   ` [ibm-acpi-devel] " Matthew Garrett
2007-07-15 20:59                     ` Henrique de Moraes Holschuh
2007-07-15 21:04                       ` Matthew Garrett
2007-07-15 21:54                         ` Henrique de Moraes Holschuh
     [not found]                           ` <20070715215453.GJ19066-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2007-07-15 22:45                             ` Matthew Garrett
2007-07-16  2:47                               ` [ibm-acpi-devel] " Henrique de Moraes Holschuh
2007-07-16 15:46                           ` Dmitry Torokhov
2007-07-16 15:51                             ` Matthew Garrett
2007-07-16 18:19                               ` Henrique de Moraes Holschuh
2007-07-16 18:37                                 ` Matthew Garrett
2007-07-14 14:12   ` ACPI: thinkpad-acpi: add power-management handler capability Henrique de Moraes Holschuh
2007-07-14 14:12   ` ACPI: thinkpad-acpi: export EV_SW SW_RADIO events Henrique de Moraes Holschuh
2007-07-14 14:12   ` ACPI: thinkpad-acpi: checkpoint sysfs interface version due to input layer Henrique de Moraes Holschuh
2007-07-14 14:12   ` ACPI: thinkpad-acpi: rename pci HID constant Henrique de Moraes Holschuh
2007-07-14 22:37     ` Matthew Garrett
     [not found]       ` <20070714223713.GC25782-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>
2007-07-15 18:02         ` Henrique de Moraes Holschuh
2007-07-15 18:34           ` Matthew Garrett
2007-07-15 21:18             ` Henrique de Moraes Holschuh
2007-07-15 21:23               ` Matthew Garrett
2007-07-14 14:12   ` pci-ids: add Lenovo PCI vendor ID Henrique de Moraes Holschuh
2007-07-15 11:52     ` Jeff Garzik
2007-07-15 21:22       ` Henrique de Moraes Holschuh
2007-07-14 14:12   ` ACPI: thinkpad-acpi: store ThinkPad model information Henrique de Moraes Holschuh
2007-07-14 14:12   ` ACPI: thinkpad-acpi: allow use of CMOS NVRAM for brightness control Henrique de Moraes Holschuh
2007-07-14 14:12   ` ACPI: thinkpad-acpi: react to Lenovo ThinkPad differences in hot key Henrique de Moraes Holschuh
2007-07-14 22:39     ` Matthew Garrett
     [not found]       ` <20070714223932.GD25782-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>
2007-07-15 17:59         ` Henrique de Moraes Holschuh
2007-07-15 18:31           ` Matthew Garrett
     [not found]             ` <20070715183150.GA3235-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>
2007-07-15 20:17               ` Henrique de Moraes Holschuh
     [not found]                 ` <20070715201712.GD19066-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2007-07-15 20:24                   ` Matthew Garrett
2007-07-14 14:12   ` ACPI: thinkpad-acpi: make sure DSDT TMPx readings don't return +128 Henrique de Moraes Holschuh
2007-07-14 14:12   ` ACPI: thinkpad-acpi: make EC-based thermal readings non-experimental Henrique de Moraes Holschuh
2007-07-14 14:12   ` ACPI: thinkpad-acpi: bump up version to 0.15 Henrique de Moraes Holschuh
2007-07-14 14:58   ` [GIT PULL] thinkpad-acpi queue for 2.6.23 (v2) Henrique de Moraes Holschuh
2007-07-14 14:11 ` ACPI: thinkpad-acpi: enable more hotkeys Henrique de Moraes Holschuh
2007-07-14 14:11 ` ACPI: thinkpad-acpi: update CMOS commands documentation Henrique de Moraes Holschuh
2007-07-14 14:12 ` ACPI: thinkpad-acpi: make the input event mode the default Henrique de Moraes Holschuh
2007-07-14 22:33   ` Matthew Garrett
2007-07-15 18:05     ` Henrique de Moraes Holschuh
     [not found]       ` <20070715180529.GF14134-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2007-07-15 18:38         ` Matthew Garrett
2007-07-15 20:09           ` [ibm-acpi-devel] " Henrique de Moraes Holschuh
2007-07-15 20:13             ` Matthew Garrett
2007-07-15 21:14               ` Henrique de Moraes Holschuh
     [not found]                 ` <20070715211421.GG19066-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2007-07-15 21:19                   ` Matthew Garrett
     [not found]                     ` <20070715211953.GA6527-1xO5oi07KQx4cg9Nei1l7Q@public.gmane.org>
2007-07-15 22:08                       ` Henrique de Moraes Holschuh
     [not found]                         ` <20070715220801.GK19066-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2007-07-15 22:49                           ` Matthew Garrett
2007-07-16  0:12                             ` [ibm-acpi-devel] " Henrique de Moraes Holschuh
     [not found]                               ` <20070716001239.GA31604-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2007-07-16  0:24                                 ` Matthew Garrett
2007-07-16  3:02                                   ` [ibm-acpi-devel] " Henrique de Moraes Holschuh
     [not found]                                     ` <20070716030254.GD31604-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2007-07-16 15:27                                       ` Dmitry Torokhov
2007-07-16 18:21                                         ` [ibm-acpi-devel] " Henrique de Moraes Holschuh
2007-07-14 14:12 ` ACPI: thinkpad_acpi: use bool for boolean parameters Henrique de Moraes Holschuh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11844223332374-git-send-email-hmh@hmh.eng.br \
    --to=hmh-n3tv7giv+o9fyo9q7ep/yw@public.gmane.org \
    --cc=henning-wy63DpzWjhr4ajHJ1XSv27NAH6kLmebB@public.gmane.org \
    --cc=ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=lenb-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=linux-acpi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox