public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Tony Vroon <tony@linx.net>
To: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Ivo van Doorn <ivdoorn@gmail.com>,
	linux-acpi@vger.kernel.org, jwoithe@physics.adelaide.edu.au,
	Peter Gruber <nokos@gmx.net>
Subject: Re: Fuijtsu Lifebook RFKILL support
Date: Fri, 12 Dec 2008 01:50:02 +0000	[thread overview]
Message-ID: <1229046602.4030.13.camel@localhost> (raw)
In-Reply-To: <20081211194734.GA18132@khazad-dum.debian.net>


[-- Attachment #1.1: Type: text/plain, Size: 1321 bytes --]

On Thu, 2008-12-11 at 17:47 -0200, Henrique de Moraes Holschuh wrote:
> I don't think so if you mean Gnome knowing what to do with EV_SW
> SW_RFKILL_ALL.  That is not a report that radios got rfkilled, but rather a
> COMMAND to rfkill all radios.

Right, so are we talking across purposes here?
I want to report radio status to userland so NetworkManager can stop
helplessly flailing around asking me for a WPA2 password in a loop if I
kill the radios.
What I have is an event-driven report that includes radio killswitch
status, HARD_BLOCKED or UNBLOCKED in rfkill terminology. There is no
SOFT_BLOCKED as I have no ability to turn individual radios on/off in
software.

Should I be creating individual Bluetooth/WLAN/WWAN rfkills that flip
between HARD_BLOCKED & UNBLOCKED with force status and return failure
for a radio state change attempt?

But perhaps code talks, let me just attach what I have right now. Both
for the rfkill guys to see what information I get and when and for the
fujitsu-laptop users & devs to confirm that this works on other
Lifebooks then just the S6420.
Testers please run with debugging on and report both BTNI and whether
you get proper event response like so:
FUJ02B1: acpi_fujitsu_hotkey_notify: radios: [killed], lid: [open],
docked: [no]

Regards,
Tony V.

[-- Attachment #1.2: fujitsu-func-interface.diff --]
[-- Type: text/x-patch, Size: 5881 bytes --]

--- linux-2.6/drivers/misc/fujitsu-laptop.c.orig	2008-12-09 15:19:19.000000000 +0000
+++ linux-2.6/drivers/misc/fujitsu-laptop.c	2008-12-12 01:20:07.000000000 +0000
@@ -3,6 +3,7 @@
 /*
   Copyright (C) 2007,2008 Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
   Copyright (C) 2008 Peter Gruber <nokos@gmx.net>
+  Copyright (C) 2008 Tony Vroon <tony@linx.net>
   Based on earlier work:
     Copyright (C) 2003 Shane Spencer <shane@bogomip.com>
     Adrian Yee <brewt-fujitsu@brewt.org>
@@ -66,7 +67,7 @@
 #include <linux/video_output.h>
 #include <linux/platform_device.h>
 
-#define FUJITSU_DRIVER_VERSION "0.4.3"
+#define FUJITSU_DRIVER_VERSION "0.5.0"
 
 #define FUJITSU_LCD_N_LEVELS 8
 
@@ -83,6 +84,12 @@
 #define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS     0x86
 #define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS     0x87
 
+/* FUNC interface - command values */
+#define FUNC_RFKILL	0x1000
+#define FUNC_LEDS	0x1001
+#define FUNC_BUTTONS	0x1002
+#define FUNC_BACKLIGHT  0x1004
+
 /* Hotkey details */
 #define KEY1_CODE	0x410	/* codes for the keys in the GIRB register */
 #define KEY2_CODE	0x411
@@ -145,8 +152,7 @@
 	struct platform_device *pf_device;
 	struct kfifo *fifo;
 	spinlock_t fifo_lock;
-
-	unsigned int irb;	/* info about the pressed buttons */
+	int rfkill_state;
 };
 
 static struct fujitsu_hotkey_t *fujitsu_hotkey;
@@ -160,6 +166,54 @@
 
 static void acpi_fujitsu_notify(acpi_handle handle, u32 event, void *data);
 
+/* Fujitsu ACPI interface function */
+
+static int call_fujex_func(int cmd, int arg0, int arg1, int arg2)
+{
+	acpi_status status = AE_OK;
+	union acpi_object params[4] = {
+	{ .type = ACPI_TYPE_INTEGER },
+	{ .type = ACPI_TYPE_INTEGER },
+	{ .type = ACPI_TYPE_INTEGER },
+	{ .type = ACPI_TYPE_INTEGER }
+	};
+	struct acpi_object_list arg_list = { 4, &params[0] };
+	struct acpi_buffer output;
+	union acpi_object out_obj;
+	acpi_handle handle = NULL;
+
+	status = acpi_get_handle(fujitsu_hotkey->acpi_handle, "FUNC", &handle);
+	if (ACPI_FAILURE(status)) {
+		vdbg_printk(FUJLAPTOP_DBG_ERROR, "FUNC interface is not present\n");
+		return -ENODEV;
+	}
+
+	params[0].integer.value = cmd;
+	params[1].integer.value = arg0;
+	params[2].integer.value = arg1;
+	params[3].integer.value = arg2;
+
+	output.length = sizeof(out_obj);
+	output.pointer = &out_obj;
+
+	status = acpi_evaluate_object(handle, NULL, &arg_list, &output);
+	if (ACPI_FAILURE(status)) {
+		vdbg_printk(FUJLAPTOP_DBG_WARN, "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) call failed\n",
+				cmd, arg0, arg1, arg2);
+		return -ENODEV;
+	}
+
+	if (out_obj.type != ACPI_TYPE_INTEGER) {
+		vdbg_printk(FUJLAPTOP_DBG_WARN, "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) did not return an integer\n",
+				cmd, arg0, arg1, arg2);
+		return -ENODEV;
+	}
+
+	vdbg_printk(FUJLAPTOP_DBG_TRACE, "FUNC 0x%x (args 0x%x, 0x%x, 0x%x) returned 0x%x\n", cmd, arg0, arg1,
+				arg2, (int)out_obj.integer.value);
+	return out_obj.integer.value;
+}
+
 /* Hardware access for LCD brightness control */
 
 static int set_lcd_level(int level)
@@ -382,26 +436,6 @@
 	return count;
 }
 
-/* Hardware access for hotkey device */
-
-static int get_irb(void)
-{
-	unsigned long long state = 0;
-	acpi_status status = AE_OK;
-
-	vdbg_printk(FUJLAPTOP_DBG_TRACE, "Get irb\n");
-
-	status =
-	    acpi_evaluate_integer(fujitsu_hotkey->acpi_handle, "GIRB", NULL,
-				  &state);
-	if (status < 0)
-		return status;
-
-	fujitsu_hotkey->irb = state;
-
-	return fujitsu_hotkey->irb;
-}
-
 static ssize_t
 ignore_store(struct device *dev,
 	     struct device_attribute *attr, const char *buf, size_t count)
@@ -771,7 +805,8 @@
 	input->id.bustype = BUS_HOST;
 	input->id.product = 0x06;
 	input->dev.parent = &device->dev;
-	input->evbit[0] = BIT(EV_KEY);
+
+	set_bit(EV_KEY, input->evbit);
 	set_bit(fujitsu->keycode1, input->keybit);
 	set_bit(fujitsu->keycode2, input->keybit);
 	set_bit(fujitsu->keycode3, input->keybit);
@@ -804,9 +839,17 @@
 	}
 
 	i = 0;			/* Discard hotkey ringbuffer */
-	while (get_irb() != 0 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) ;
+	while (call_fujex_func(FUNC_BUTTONS,0x01,0x0,0x0) != 0 && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) ;
 	vdbg_printk(FUJLAPTOP_DBG_INFO, "Discarded %i ringbuffer entries\n", i);
 
+	/* Sync RFKILL state */
+	fujitsu_hotkey->rfkill_state = 
+		call_fujex_func(FUNC_RFKILL,0x04,0x0,0x0);
+
+	/* Suspect this is a keymap of the application panel, print it */
+	vdbg_printk(FUJLAPTOP_DBG_INFO, "BTNI: [0x%x]",
+		call_fujex_func(FUNC_BUTTONS,0x0,0x0,0x0));
+
 	return result;
 
 end:
@@ -848,16 +891,25 @@
 	struct input_dev *input;
 	int keycode, keycode_r;
 	unsigned int irb = 1;
-	int i, status;
+	int i, status, rfkill_new;
 
 	input = fujitsu_hotkey->input;
 
-	vdbg_printk(FUJLAPTOP_DBG_TRACE, "Hotkey event\n");
+	rfkill_new = call_fujex_func(FUNC_RFKILL,0x04,0x0,0x0);
+	if (fujitsu_hotkey->rfkill_state != rfkill_new) {
+		vdbg_printk(FUJLAPTOP_DBG_INFO,
+			"radios: [%s], lid: [%s], docked: [%s]\n",
+			(rfkill_new & 0x20) ? "on" : "killed",
+			(rfkill_new & 0x100) ? "open" : "closed",
+			(rfkill_new & 0x200) ? "yes" : "no");
+	}
+
+	fujitsu_hotkey->rfkill_state = rfkill_new;
 
 	switch (event) {
 	case ACPI_FUJITSU_NOTIFY_CODE1:
 		i = 0;
-		while ((irb = get_irb()) != 0
+		while ((irb = call_fujex_func(FUNC_BUTTONS,0x01,0x0,0x0)) != 0
 		       && (i++) < MAX_HOTKEY_RINGBUFFER_SIZE) {
 			vdbg_printk(FUJLAPTOP_DBG_TRACE, "GIRB result [%x]\n",
 				    irb);
@@ -1108,7 +1160,7 @@
 MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
 #endif
 
-MODULE_AUTHOR("Jonathan Woithe, Peter Gruber");
+MODULE_AUTHOR("Jonathan Woithe, Peter Gruber, Tony Vroon");
 MODULE_DESCRIPTION("Fujitsu laptop extras support");
 MODULE_VERSION(FUJITSU_DRIVER_VERSION);
 MODULE_LICENSE("GPL");

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2008-12-12  1:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-11  1:05 Fuijtsu Lifebook RFKILL support Tony Vroon
2008-12-11  1:20 ` Jonathan Woithe
2008-12-11  1:31   ` Tony Vroon
2008-12-11  1:44     ` Jonathan Woithe
2008-12-11 16:52 ` Henrique de Moraes Holschuh
2008-12-11 17:33   ` Tony Vroon
2008-12-11 19:47     ` Henrique de Moraes Holschuh
2008-12-12  1:50       ` Tony Vroon [this message]
2008-12-12 19:53         ` Henrique de Moraes Holschuh
2008-12-12 20:33           ` Len Brown
2008-12-13 12:47             ` Tony Vroon
2008-12-13 13:28               ` Henrique de Moraes Holschuh
2008-12-13 17:57                 ` Matthew Garrett
2008-12-13 20:55                   ` Tony Vroon
2008-12-13 21:24                     ` Matthew Garrett
2008-12-14  3:13                   ` Henrique de Moraes Holschuh
2008-12-14 17:05                 ` Dan Williams
2008-12-15 11:53                   ` Henrique de Moraes Holschuh
     [not found]                     ` <20081215115336.GD17648-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2008-12-15 15:19                       ` Dan Williams
2008-12-15 17:14                         ` Tony Vroon
2008-12-15 17:59                           ` Dan Williams
2008-12-16 13:50                             ` Tony Vroon
2008-12-16 15:23                               ` Dan Williams
2008-12-15 23:42                           ` Jonathan Woithe
2008-12-15 23:48                             ` Tony Vroon
2008-12-16  0:02                               ` Jonathan Woithe

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=1229046602.4030.13.camel@localhost \
    --to=tony@linx.net \
    --cc=hmh@hmh.eng.br \
    --cc=ivdoorn@gmail.com \
    --cc=jwoithe@physics.adelaide.edu.au \
    --cc=linux-acpi@vger.kernel.org \
    --cc=nokos@gmx.net \
    /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