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]); > +} > > ... > - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/