Re: [PATCH] Fujitsu application panel driver
Hi Stephen, On Oct 23, 2007 2:55 PM, Stephen Hemminger [EMAIL PROTECTED] wrote: +static void mail_led_set(struct led_classdev *led, +enum led_brightness value) +{ + struct apanel *ap = container_of(led, struct apanel, mail_led); + if (value) + ap-led_bits |= 0x8000; + else + ap-led_bits = ~0x8000; + ap-led_bits = value; + schedule_work(ap-led_work); +} I was just about to apply the driver (and I folded in the other 4 patches you sent to me) but then I noticed the code above. It looks like the conditional does not have any effect, ap-led_bits will be overwritten with the raw value anyway. Please advise. Thank you. -- Dmitry
Re: [PATCH] Fujitsu application panel driver
Am Montag 19 November 2007 18:26:32 schrieben Sie: On Mon, 19 Nov 2007 13:50:30 +0100 Robert Gerlach [EMAIL PROTECTED] wrote: Am Montag 19 November 2007 05:43:07 schrieb Stephen Hemminger: On Sun, 18 Nov 2007 23:36:58 +0100 Robert Gerlach [EMAIL PROTECTED] wrote: Am Dienstag 23 Oktober 2007 21:55:55 schrieb Stephen Hemminger: +MODULE_ALIAS(dmi:*:svnFUJITSU:pnLifeBook*:pvr*:rvnFUJITSU:*); +MODULE_ALIAS(dmi:*:svnFUJITSU:pnLifebook*:pvr*:rvnFUJITSU:*); Please make sure that this module is not autoload on Lifebook tablets (T series and P1[56]10). It works fine, but only supports a subset of features (4 of 7 buttons and no display orientation for my T4010). I would rather get those tablets working (with help). Rather than trying to enumerate all the possible DMI values of the full range of different laptops. I've played with apanel some month ago. I've never found the keys and the switch over the I2C bus. So I was starting my own module (fsc_btns) to play with the IO range announced by ACPI. There I found it all. But my module doesn't work on all Lifebooks (S7110 for example; has no such ACPI device). If the device doesn't have the buttons, then the probe routine won't find them and it should just exit and unload itself. Now it may be too noisy right now and it might not detect properly, if so, that is where the bug is. Sorry, bad writing. What I want to say, apanel loads fine and works for the 4 keys. Apanel and fsc_btns works side by side too and (in this case) keys reported twice, that's the bug. For my T4010, apanel found 2 devices, devno 1 and 6 both with method=4 chip=4 slave=25. The working keys are scrolldown (reported as prog2), scrollup (prog1), display rotation (www) and Fn (mail). If I find a way to make the other keys work, I will happily add it. Currently I have no idea. By the way, input-kbd segv for apanel on my box. This fixed it for me: --- orig/apanel.c 2007-11-19 20:41:58.0 +0100 +++ apanel.c2007-11-19 20:44:54.0 +0100 @@ -274,8 +274,8 @@ idev-phys = apanel/input0; idev-id.bustype = BUS_HOST; idev-dev.parent = ap-client.dev; - idev-getkeycode = apanel_getkeycode; - idev-setkeycode = apanel_setkeycode; + idev-keycode = ap-keymap; + idev-keycodesize = sizeof(ap-keymap[0]); set_bit(EV_KEY, idev-evbit); Robert
Re: [PATCH] Fujitsu application panel driver
Hi Stephen, On Tuesday 23 October 2007 15:55, Stephen Hemminger wrote: + +static int apanel_setkeycode(struct input_dev *idev, int scancode, int keycode) +{ + struct apanel *ap = idev-private; + + if (keycode 0 || keycode KEY_MAX) + return -EINVAL; + + if (scancode 0 || scancode = MAX_PANEL_KEYS) + return -EINVAL; scancode = idev-keycodemax is prbably better here - we don't want to allow setting keycode for unsupported buttons. + + clear_bit(ap-keymap[scancode], idev-keybit); This will not work if one has same code assigned to 2 buttons. Pretty degenerate case, I know... + ap-keymap[scancode] = keycode; + set_bit(keycode, idev-keybit); + return 0; +} -- Dmitry
Re: [PATCH] Fujitsu application panel driver
On Tue, 23 Oct 2007 12:55:55 -0700 Stephen Hemminger [EMAIL PROTECTED] wrote: This driver supports the application buttons on some Fujitsu Lifebook laptops. It is based on the earlier apanel driver done by Jochen Eisenger, but with many changes. The original driver used ioctl's and a separate user space program (see http://apanel.sourceforge.net). This driver hooks into the input subsystem so that the normal keys act as expected without a daemon. In addition to buttons, the Mail Led is handled via LEDs class device. The driver now supports redefinable keymaps and no longer has to have a DMI table for all Fujitsu laptops. I thought about mixing this driver should be integrated into the Fujitsu laptop extras driver that handles backlight, but rejected the idea because it wasn't clear if all the Fujitsu laptops supported both. ... + +/* Magic constants in BIOS that tell about buttons */ +enum apanel_devid { + APANEL_DEV_NONE = 0, + APANEL_DEV_APPBTN = 1, + APANEL_DEV_CDBTN = 2, + APANEL_DEV_LCD= 3, + APANEL_DEV_LED= 4, + APANEL_DEV_MAX, +}; APANEL_DEV_MAX == 5. +enum apanel_chip { + CHIP_NONE= 0, + CHIP_OZ992C = 1, + CHIP_OZ163T = 2, + CHIP_OZ711M3 = 4, +}; + +/* Result of BIOS snooping/probing -- what features are supported */ +static enum apanel_chip device_chip[APANEL_DEV_MAX]; + +/* names for APANEL_XXX */ +static const char *device_names[APANEL_DEV_MAX] __initdata = { We just wasted sizeof(char *)? + [APANEL_DEV_APPBTN] = Application Buttons, + [APANEL_DEV_LCD]= LCD, + [APANEL_DEV_LED]= LED, + [APANEL_DEV_CDBTN] = CD Buttons, +}; + + +/* Poll for key changes + * + * Read Application keys via SMI + * A (0x4), B (0x8), Internet (0x2), Email (0x1). + * + * CD keys: + * Forward (0x100), Rewind (0x200), Stop (0x400), Pause (0x800) + */ +static void apanel_poll(struct input_polled_dev *ipdev) +{ + struct apanel *ap = ipdev-private; + struct input_dev *idev = ipdev-input; + u8 cmd = device_chip[APANEL_DEV_APPBTN] == CHIP_OZ992C ? 0 : 8; + s32 data; + int i; + + data = i2c_smbus_read_word_data(ap-client, cmd); + if (data 0) + return; /* ignore errors (due to ACPI??) */ + + /* write back to clear latch */ + i2c_smbus_write_word_data(ap-client, cmd, 0); + + if (!data) + return; + + dev_dbg(ipdev-input-dev, APANEL : data %#x\n, data); + for (i = 0; i ipdev-input-keycodemax; i++) + if (1ul i data) You made me google for the c precedence table. + report_key(idev, ap-keymap[i]); +} ...
[PATCH] Fujitsu application panel driver
This driver supports the application buttons on some Fujitsu Lifebook laptops. It is based on the earlier apanel driver done by Jochen Eisenger, but with many changes. The original driver used ioctl's and a separate user space program (see http://apanel.sourceforge.net). This driver hooks into the input subsystem so that the normal keys act as expected without a daemon. In addition to buttons, the Mail Led is handled via LEDs class device. The driver now supports redefinable keymaps and no longer has to have a DMI table for all Fujitsu laptops. I thought about mixing this driver should be integrated into the Fujitsu laptop extras driver that handles backlight, but rejected the idea because it wasn't clear if all the Fujitsu laptops supported both. Signed-off-by: Stephen Hemminger [EMAIL PROTECTED] --- drivers/input/misc/Kconfig | 14 + drivers/input/misc/Makefile |1 drivers/input/misc/apanel.c | 407 3 files changed, 422 insertions(+) --- a/drivers/input/misc/Kconfig2007-10-23 11:19:10.0 -0700 +++ b/drivers/input/misc/Kconfig2007-10-23 11:19:48.0 -0700 @@ -40,6 +40,20 @@ config INPUT_M68K_BEEP tristate M68k Beeper support depends on M68K +config INPUT_APANEL + tristate Fujitsu Lifebook Application Panel buttons + depends on X86 + select I2C_I801 + select INPUT_POLLDEV + select CHECK_SIGNATURE + help +Say Y here for support of the Application Panel buttons, used on +Fujitsu Lifebook. These are attached to the mainboard through +an SMBus interface managed by the I2C Intel ICH (i801) driver. + +To compile this driver as a module, choose M here: the module will +be called apanel. + config INPUT_IXP4XX_BEEPER tristate IXP4XX Beeper support depends on ARCH_IXP4XX --- a/drivers/input/misc/Makefile 2007-10-23 11:19:10.0 -0700 +++ b/drivers/input/misc/Makefile 2007-10-23 11:19:48.0 -0700 @@ -18,3 +18,4 @@ obj-$(CONFIG_INPUT_POWERMATE) += powerm obj-$(CONFIG_INPUT_YEALINK)+= yealink.o obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o obj-$(CONFIG_INPUT_UINPUT) += uinput.o +obj-$(CONFIG_INPUT_APANEL) += apanel.o --- /dev/null 1970-01-01 00:00:00.0 + +++ b/drivers/input/misc/apanel.c 2007-10-23 12:47:55.0 -0700 @@ -0,0 +1,407 @@ +/* + * Fujitsu Lifebook Application Panel button drive + * + * Copyright (C) 2007 Stephen Hemminger [EMAIL PROTECTED] + * Copyright (C) 2001-2003 Jochen Eisinger [EMAIL PROTECTED] + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published by + * the Free Software Foundation. + * + * Many Fujitsu Lifebook laptops have a small panel of buttons that are + * accessible via the i2c/smbus interface. This driver polls those + * buttons and generates input events. + * + * For more details see: + * http://apanel.sourceforge.net/tech.php + */ + +#include linux/kernel.h +#include linux/module.h +#include linux/ioport.h +#include linux/io.h +#include linux/module.h +#include linux/input-polldev.h +#include linux/i2c.h +#include linux/workqueue.h +#include linux/leds.h + +#define APANEL_NAMEFujitsu Application Panel +#define APANEL_VERSION 1.3 +#define APANEL apanel + +/* How often we poll keys - msecs */ +#define POLL_INTERVAL_DEFAULT 1000 + +/* Magic constants in BIOS that tell about buttons */ +enum apanel_devid { + APANEL_DEV_NONE = 0, + APANEL_DEV_APPBTN = 1, + APANEL_DEV_CDBTN = 2, + APANEL_DEV_LCD= 3, + APANEL_DEV_LED= 4, + APANEL_DEV_MAX, +}; + +enum apanel_chip { + CHIP_NONE= 0, + CHIP_OZ992C = 1, + CHIP_OZ163T = 2, + CHIP_OZ711M3 = 4, +}; + +/* Result of BIOS snooping/probing -- what features are supported */ +static enum apanel_chip device_chip[APANEL_DEV_MAX]; + +/* names for APANEL_XXX */ +static const char *device_names[APANEL_DEV_MAX] __initdata = { + [APANEL_DEV_APPBTN] = Application Buttons, + [APANEL_DEV_LCD]= LCD, + [APANEL_DEV_LED]= LED, + [APANEL_DEV_CDBTN] = CD Buttons, +}; + +#define MAX_PANEL_KEYS 12 + +struct apanel { + struct input_polled_dev *ipdev; + struct i2c_client client; + unsigned keymap[MAX_PANEL_KEYS]; + u16nkeys; + u16led_bits; + struct work_struct led_work; + struct led_classdev mail_led; +}; + + +static int apanel_probe(struct i2c_adapter *, int, int); + +/* for now, we only support one address */ +static unsigned short normal_i2c[] = {0, I2C_CLIENT_END}; +static unsigned short ignore = I2C_CLIENT_END; +static struct i2c_client_address_data addr_data = { + .normal_i2c = normal_i2c, + .probe = ignore, + .ignore = ignore, +}; + +static void