diff -Nur linux-2.4.19.vanilla/Documentation/sonypi.txt linux-2.4.19/Documentation/sonypi.txt --- linux-2.4.19.vanilla/Documentation/sonypi.txt Sat Aug 3 02:39:42 2002 +++ linux-2.4.19/Documentation/sonypi.txt Tue Nov 12 12:25:03 2002 @@ -1,6 +1,7 @@ Sony Programmable I/O Control Device Driver Readme -------------------------------------------------- - Copyright (C) 2001 Stelian Pop , Alcôve + Copyright (C) 2001-2002 Stelian Pop + Copyright (C) 2001-2002 Alcôve Copyright (C) 2001 Michael Ashley Copyright (C) 2001 Junichi Morita Copyright (C) 2000 Takaya Kinjo @@ -22,7 +23,7 @@ /dev/sonypi (major 10, minor auto allocated or specified as a option). A simple daemon which translates the jogdial movements into mouse wheel events -can be downloaded at: +can be downloaded at: This driver supports also some ioctl commands for setting the LCD screen brightness and querying the batteries charge information (some more @@ -71,8 +72,25 @@ (prior to version 1.5) and does not work anymore, add this option and report to the author. - nojogdial: gives more accurate PKEY events on those Vaio models - which don't have a jogdial (like the FX series). + mask: event mask telling the driver what events will be + reported to the user. This parameter is required for some + Vaio models where the hardware reuses values used in + other Vaio models (like the FX series who does not + have a jogdial but reuses the jogdial events for + programmable keys events). The default event mask is + set to 0xffffffff, meaning that all possible events will be + tried. You can use the following bits to construct + your own event mask (from drivers/char/sonypi.h): + SONYPI_JOGGER_MASK 0x0001 + SONYPI_CAPTURE_MASK 0x0002 + SONYPI_FNKEY_MASK 0x0004 + SONYPI_BLUETOOTH_MASK 0x0008 + SONYPI_PKEY_MASK 0x0010 + SONYPI_BACK_MASK 0x0020 + SONYPI_HELP_MASK 0x0040 + SONYPI_LID_MASK 0x0080 + SONYPI_ZOOM_MASK 0x0100 + SONYPI_THUMBPHRASE_MASK 0x0200 Module use: ----------- diff -Nur linux-2.4.19.vanilla/drivers/char/sonypi.c linux-2.4.19/drivers/char/sonypi.c --- linux-2.4.19.vanilla/drivers/char/sonypi.c Sat Aug 3 02:39:43 2002 +++ linux-2.4.19/drivers/char/sonypi.c Tue Nov 12 12:25:31 2002 @@ -1,7 +1,9 @@ -/* +/* * Sony Programmable I/O Control Device driver for VAIO * - * Copyright (C) 2001 Stelian Pop , Alcôve + * Copyright (C) 2001-2002 Stelian Pop + * + * Copyright (C) 2001-2002 Alcôve * * Copyright (C) 2001 Michael Ashley * @@ -50,7 +52,7 @@ static int fnkeyinit; /* = 0 */ static int camera; /* = 0 */ static int compat; /* = 0 */ -static int nojogdial; /* = 0 */ +static unsigned long mask = 0xffffffff; /* Inits the queue */ static inline void sonypi_initq(void) { @@ -112,22 +114,22 @@ static void sonypi_ecrset(u8 addr, u8 value) { - wait_on_command(1, inb_p(SONYPI_CST_IOPORT) & 3); + wait_on_command(1, inb_p(SONYPI_CST_IOPORT) & 3, ITERATIONS_LONG); outb_p(0x81, SONYPI_CST_IOPORT); - wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2); + wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG); outb_p(addr, SONYPI_DATA_IOPORT); - wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2); + wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG); outb_p(value, SONYPI_DATA_IOPORT); - wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2); + wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG); } static u8 sonypi_ecrget(u8 addr) { - wait_on_command(1, inb_p(SONYPI_CST_IOPORT) & 3); + wait_on_command(1, inb_p(SONYPI_CST_IOPORT) & 3, ITERATIONS_LONG); outb_p(0x80, SONYPI_CST_IOPORT); - wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2); + wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG); outb_p(addr, SONYPI_DATA_IOPORT); - wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2); + wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG); return inb_p(SONYPI_DATA_IOPORT); } @@ -187,7 +189,7 @@ static u8 sonypi_call1(u8 dev) { u8 v1, v2; - wait_on_command(0, inb_p(sonypi_device.ioport2) & 2); + wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG); outb(dev, sonypi_device.ioport2); v1 = inb_p(sonypi_device.ioport2); v2 = inb_p(sonypi_device.ioport1); @@ -197,9 +199,9 @@ static u8 sonypi_call2(u8 dev, u8 fn) { u8 v1; - wait_on_command(0, inb_p(sonypi_device.ioport2) & 2); + wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG); outb(dev, sonypi_device.ioport2); - wait_on_command(0, inb_p(sonypi_device.ioport2) & 2); + wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG); outb(fn, sonypi_device.ioport1); v1 = inb_p(sonypi_device.ioport1); return v1; @@ -208,11 +210,11 @@ static u8 sonypi_call3(u8 dev, u8 fn, u8 v) { u8 v1; - wait_on_command(0, inb_p(sonypi_device.ioport2) & 2); + wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG); outb(dev, sonypi_device.ioport2); - wait_on_command(0, inb_p(sonypi_device.ioport2) & 2); + wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG); outb(fn, sonypi_device.ioport1); - wait_on_command(0, inb_p(sonypi_device.ioport2) & 2); + wait_on_command(0, inb_p(sonypi_device.ioport2) & 2, ITERATIONS_LONG); outb(v, sonypi_device.ioport1); v1 = inb_p(sonypi_device.ioport1); return v1; @@ -234,7 +236,7 @@ /* Set brightness, hue etc */ static void sonypi_set(u8 fn, u8 v) { - wait_on_command(0, sonypi_call3(0x90, fn, v)); + wait_on_command(0, sonypi_call3(0x90, fn, v), ITERATIONS_SHORT); } /* Tests if the camera is ready */ @@ -308,79 +310,28 @@ /* Interrupt handler: some event is available */ void sonypi_irq(int irq, void *dev_id, struct pt_regs *regs) { u8 v1, v2, event = 0; - int i; - u8 sonypi_jogger_ev, sonypi_fnkey_ev; - u8 sonypi_capture_ev, sonypi_bluetooth_ev; - u8 sonypi_pkey_ev; - - if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) { - sonypi_jogger_ev = SONYPI_TYPE2_JOGGER_EV; - sonypi_fnkey_ev = SONYPI_TYPE2_FNKEY_EV; - sonypi_capture_ev = SONYPI_TYPE2_CAPTURE_EV; - sonypi_bluetooth_ev = SONYPI_TYPE2_BLUETOOTH_EV; - sonypi_pkey_ev = nojogdial ? SONYPI_TYPE2_PKEY_EV - : SONYPI_TYPE1_PKEY_EV; - } - else { - sonypi_jogger_ev = SONYPI_TYPE1_JOGGER_EV; - sonypi_fnkey_ev = SONYPI_TYPE1_FNKEY_EV; - sonypi_capture_ev = SONYPI_TYPE1_CAPTURE_EV; - sonypi_bluetooth_ev = SONYPI_TYPE1_BLUETOOTH_EV; - sonypi_pkey_ev = SONYPI_TYPE1_PKEY_EV; - } + int i, j; v1 = inb_p(sonypi_device.ioport1); + if (!v1) + return; v2 = inb_p(sonypi_device.ioport2); - if ((v2 & sonypi_pkey_ev) == sonypi_pkey_ev) { - for (i = 0; sonypi_pkeyev[i].event; i++) - if (sonypi_pkeyev[i].data == v1) { - event = sonypi_pkeyev[i].event; - goto found; - } - } - if ((v2 & sonypi_jogger_ev) == sonypi_jogger_ev) { - for (i = 0; sonypi_joggerev[i].event; i++) - if (sonypi_joggerev[i].data == v1) { - event = sonypi_joggerev[i].event; - goto found; - } - } - if ((v2 & sonypi_capture_ev) == sonypi_capture_ev) { - for (i = 0; sonypi_captureev[i].event; i++) - if (sonypi_captureev[i].data == v1) { - event = sonypi_captureev[i].event; - goto found; - } - } - if ((v2 & sonypi_fnkey_ev) == sonypi_fnkey_ev) { - for (i = 0; sonypi_fnkeyev[i].event; i++) - if (sonypi_fnkeyev[i].data == v1) { - event = sonypi_fnkeyev[i].event; - goto found; - } - } - if ((v2 & sonypi_bluetooth_ev) == sonypi_bluetooth_ev) { - for (i = 0; sonypi_blueev[i].event; i++) - if (sonypi_blueev[i].data == v1) { - event = sonypi_blueev[i].event; - goto found; - } - } - if ((v2 & SONYPI_BACK_EV) == SONYPI_BACK_EV) { - for (i = 0; sonypi_backev[i].event; i++) - if (sonypi_backev[i].data == v1) { - event = sonypi_backev[i].event; - goto found; - } - } - if ((v2 & SONYPI_LID_EV) == SONYPI_LID_EV) { - for (i = 0; sonypi_lidev[i].event; i++) - if (sonypi_lidev[i].data == v1) { - event = sonypi_lidev[i].event; + for (i = 0; sonypi_eventtypes[i].model; i++) { + if (sonypi_device.model != sonypi_eventtypes[i].model) + continue; + if ((v2 & sonypi_eventtypes[i].data) != sonypi_eventtypes[i].data) + continue; + if (! (mask & sonypi_eventtypes[i].mask)) + continue; + for (j = 0; sonypi_eventtypes[i].events[j].data; j++) { + if (v1 == sonypi_eventtypes[i].events[j].data) { + event = sonypi_eventtypes[i].events[j].event; goto found; } + } } + if (verbose) printk(KERN_WARNING "sonypi: unknown event port1=0x%02x,port2=0x%02x\n",v1,v2); @@ -542,7 +493,7 @@ down(&sonypi_device.lock); switch (cmd) { case SONYPI_IOCGBRT: - val8 = sonypi_ecrget(0x96); + val8 = sonypi_ecrget(SONYPI_LCD_LIGHT); if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) { ret = -EFAULT; goto out; @@ -553,38 +504,38 @@ ret = -EFAULT; goto out; } - sonypi_ecrset(0x96, val8); + sonypi_ecrset(SONYPI_LCD_LIGHT, val8); break; case SONYPI_IOCGBAT1CAP: - val16 = sonypi_ecrget16(0xb2); + val16 = sonypi_ecrget16(SONYPI_BAT1_FULL); if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) { ret = -EFAULT; goto out; } break; case SONYPI_IOCGBAT1REM: - val16 = sonypi_ecrget16(0xa2); + val16 = sonypi_ecrget16(SONYPI_BAT1_LEFT); if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) { ret = -EFAULT; goto out; } break; case SONYPI_IOCGBAT2CAP: - val16 = sonypi_ecrget16(0xba); + val16 = sonypi_ecrget16(SONYPI_BAT2_FULL); if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) { ret = -EFAULT; goto out; } break; case SONYPI_IOCGBAT2REM: - val16 = sonypi_ecrget16(0xaa); + val16 = sonypi_ecrget16(SONYPI_BAT2_LEFT); if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) { ret = -EFAULT; goto out; } break; case SONYPI_IOCGBATFLAGS: - val8 = sonypi_ecrget(0x81) & 0x07; + val8 = sonypi_ecrget(SONYPI_BAT_FLAGS) & 0x07; if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) { ret = -EFAULT; goto out; @@ -613,19 +564,64 @@ } static struct file_operations sonypi_misc_fops = { - owner: THIS_MODULE, - read: sonypi_misc_read, - poll: sonypi_misc_poll, - open: sonypi_misc_open, - release: sonypi_misc_release, - fasync: sonypi_misc_fasync, - ioctl: sonypi_misc_ioctl, + .owner = THIS_MODULE, + .read = sonypi_misc_read, + .poll = sonypi_misc_poll, + .open = sonypi_misc_open, + .release = sonypi_misc_release, + .fasync = sonypi_misc_fasync, + .ioctl = sonypi_misc_ioctl, }; struct miscdevice sonypi_misc_device = { -1, "sonypi", &sonypi_misc_fops }; +#if CONFIG_PM +static int sonypi_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data) { + static int old_camera_power; + + switch (rqst) { + case PM_SUSPEND: + sonypi_call2(0x81, 0); /* make sure we don't get any more events */ + if (camera) { + old_camera_power = sonypi_device.camera_power; + sonypi_camera_off(); + } + if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) + sonypi_type2_dis(); + else + sonypi_type1_dis(); +#if !defined(CONFIG_ACPI) + /* disable ACPI mode */ + if (fnkeyinit) + outb(0xf1, 0xb2); +#endif + break; + case PM_RESUME: +#if !defined(CONFIG_ACPI) + /* Enable ACPI mode to get Fn key events */ + if (fnkeyinit) + outb(0xf0, 0xb2); +#endif + if (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE2) + sonypi_type2_srs(); + else + sonypi_type1_srs(); + sonypi_call1(0x82); + sonypi_call2(0x81, 0xff); + if (compat) + sonypi_call1(0x92); + else + sonypi_call1(0x82); + if (camera && old_camera_power) + sonypi_camera_on(); + break; + } + return 0; +} +#endif + static int __devinit sonypi_probe(struct pci_dev *pcidev) { int i, ret; struct sonypi_ioport_list *ioport_list; @@ -717,14 +713,14 @@ SONYPI_DRIVER_MINORVERSION); printk(KERN_INFO "sonypi: detected %s model, " "verbose = %s, fnkeyinit = %s, camera = %s, " - "compat = %s, nojogdial = %s\n", + "compat = %s, mask = 0x%08lx\n", (sonypi_device.model == SONYPI_DEVICE_MODEL_TYPE1) ? "type1" : "type2", verbose ? "on" : "off", fnkeyinit ? "on" : "off", camera ? "on" : "off", compat ? "on" : "off", - nojogdial ? "on" : "off"); + mask); printk(KERN_INFO "sonypi: enabled at irq=%d, port1=0x%x, port2=0x%x\n", sonypi_device.irq, sonypi_device.ioport1, sonypi_device.ioport2); @@ -732,6 +728,10 @@ printk(KERN_INFO "sonypi: device allocated minor is %d\n", sonypi_misc_device.minor); +#if CONFIG_PM + sonypi_device.pm = pm_register(PM_PCI_DEV, 0, sonypi_pm_callback); +#endif + return 0; out3: @@ -743,6 +743,11 @@ } static void __devexit sonypi_remove(void) { + +#if CONFIG_PM + pm_unregister(sonypi_device.pm); +#endif + sonypi_call2(0x81, 0); /* make sure we don't get any more events */ if (camera) sonypi_camera_off(); @@ -800,7 +805,7 @@ compat = ints[5]; if (ints[0] == 5) goto out; - nojogdial = ints[6]; + mask = ints[6]; out: return 1; } @@ -812,7 +817,7 @@ module_init(sonypi_init_module); module_exit(sonypi_cleanup_module); -MODULE_AUTHOR("Stelian Pop "); +MODULE_AUTHOR("Stelian Pop "); MODULE_DESCRIPTION("Sony Programmable I/O Control Device driver"); MODULE_LICENSE("GPL"); @@ -827,7 +832,7 @@ MODULE_PARM_DESC(camera, "set this if you have a MotionEye camera (PictureBook series)"); MODULE_PARM(compat,"i"); MODULE_PARM_DESC(compat, "set this if you want to enable backward compatibility mode"); -MODULE_PARM(nojogdial, "i"); -MODULE_PARM_DESC(nojogdial, "set this if you have a Vaio without a jogdial (like the fx series)"); +MODULE_PARM(mask, "i"); +MODULE_PARM_DESC(mask, "set this to the mask of event you want to enable (see doc)"); EXPORT_SYMBOL(sonypi_camera_command); diff -Nur linux-2.4.19.vanilla/drivers/char/sonypi.h linux-2.4.19/drivers/char/sonypi.h --- linux-2.4.19.vanilla/drivers/char/sonypi.h Sat Aug 3 02:39:43 2002 +++ linux-2.4.19/drivers/char/sonypi.h Tue Nov 12 12:25:29 2002 @@ -1,7 +1,9 @@ /* * Sony Programmable I/O Control Device driver for VAIO * - * Copyright (C) 2001 Stelian Pop , Alcôve + * Copyright (C) 2001-2002 Stelian Pop + * + * Copyright (C) 2001-2002 Alcôve * * Copyright (C) 2001 Michael Ashley * @@ -35,10 +37,14 @@ #ifdef __KERNEL__ #define SONYPI_DRIVER_MAJORVERSION 1 -#define SONYPI_DRIVER_MINORVERSION 13 +#define SONYPI_DRIVER_MINORVERSION 15 + +#define SONYPI_DEVICE_MODEL_TYPE1 1 +#define SONYPI_DEVICE_MODEL_TYPE2 2 #include #include +#include #include "linux/sonypi.h" /* type1 models use those */ @@ -54,6 +60,20 @@ #define SONYPI_SHIB 0x9d #define SONYPI_TYPE2_REGION_SIZE 0x20 +/* battery / brightness addresses */ +#define SONYPI_BAT_FLAGS 0x81 +#define SONYPI_LCD_LIGHT 0x96 +#define SONYPI_BAT1_PCTRM 0xa0 +#define SONYPI_BAT1_LEFT 0xa2 +#define SONYPI_BAT1_MAXRT 0xa4 +#define SONYPI_BAT2_PCTRM 0xa8 +#define SONYPI_BAT2_LEFT 0xaa +#define SONYPI_BAT2_MAXRT 0xac +#define SONYPI_BAT1_MAXTK 0xb0 +#define SONYPI_BAT1_FULL 0xb2 +#define SONYPI_BAT2_MAXTK 0xb8 +#define SONYPI_BAT2_FULL 0xba + /* ioports used for brightness and type2 events */ #define SONYPI_DATA_IOPORT 0x62 #define SONYPI_CST_IOPORT 0x66 @@ -131,43 +151,45 @@ #define SONYPI_CAMERA_REVISION 8 #define SONYPI_CAMERA_ROMVERSION 9 -/* key press event data (ioport2) */ -#define SONYPI_TYPE1_JOGGER_EV 0x10 -#define SONYPI_TYPE2_JOGGER_EV 0x08 -#define SONYPI_TYPE1_CAPTURE_EV 0x60 -#define SONYPI_TYPE2_CAPTURE_EV 0x08 -#define SONYPI_TYPE1_FNKEY_EV 0x20 -#define SONYPI_TYPE2_FNKEY_EV 0x08 -#define SONYPI_TYPE1_BLUETOOTH_EV 0x30 -#define SONYPI_TYPE2_BLUETOOTH_EV 0x08 -#define SONYPI_TYPE1_PKEY_EV 0x40 -#define SONYPI_TYPE2_PKEY_EV 0x08 -#define SONYPI_BACK_EV 0x08 -#define SONYPI_LID_EV 0x38 +/* Event masks */ +#define SONYPI_JOGGER_MASK 0x00000001 +#define SONYPI_CAPTURE_MASK 0x00000002 +#define SONYPI_FNKEY_MASK 0x00000004 +#define SONYPI_BLUETOOTH_MASK 0x00000008 +#define SONYPI_PKEY_MASK 0x00000010 +#define SONYPI_BACK_MASK 0x00000020 +#define SONYPI_HELP_MASK 0x00000040 +#define SONYPI_LID_MASK 0x00000080 +#define SONYPI_ZOOM_MASK 0x00000100 +#define SONYPI_THUMBPHRASE_MASK 0x00000200 struct sonypi_event { u8 data; u8 event; }; - /* The set of possible jogger events */ static struct sonypi_event sonypi_joggerev[] = { { 0x1f, SONYPI_EVENT_JOGDIAL_UP }, { 0x01, SONYPI_EVENT_JOGDIAL_DOWN }, { 0x5f, SONYPI_EVENT_JOGDIAL_UP_PRESSED }, { 0x41, SONYPI_EVENT_JOGDIAL_DOWN_PRESSED }, + { 0x1e, SONYPI_EVENT_JOGDIAL_FAST_UP }, + { 0x02, SONYPI_EVENT_JOGDIAL_FAST_DOWN }, + { 0x5e, SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED }, + { 0x42, SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED }, + { 0x1d, SONYPI_EVENT_JOGDIAL_VFAST_UP }, + { 0x03, SONYPI_EVENT_JOGDIAL_VFAST_DOWN }, + { 0x5d, SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED }, + { 0x43, SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED }, { 0x40, SONYPI_EVENT_JOGDIAL_PRESSED }, - { 0x00, SONYPI_EVENT_JOGDIAL_RELEASED }, - { 0x00, 0x00 } + { 0, 0 } }; /* The set of possible capture button events */ static struct sonypi_event sonypi_captureev[] = { { 0x05, SONYPI_EVENT_CAPTURE_PARTIALPRESSED }, { 0x07, SONYPI_EVENT_CAPTURE_PRESSED }, - { 0x01, SONYPI_EVENT_CAPTURE_PARTIALRELEASED }, - { 0x00, SONYPI_EVENT_CAPTURE_RELEASED }, - { 0x00, 0x00 } + { 0, 0 } }; /* The set of possible fnkeys events */ @@ -192,7 +214,8 @@ { 0x33, SONYPI_EVENT_FNKEY_F }, { 0x34, SONYPI_EVENT_FNKEY_S }, { 0x35, SONYPI_EVENT_FNKEY_B }, - { 0x00, 0x00 } + { 0x36, SONYPI_EVENT_FNKEY_ONLY }, + { 0, 0 } }; /* The set of possible program key events */ @@ -200,7 +223,7 @@ { 0x01, SONYPI_EVENT_PKEY_P1 }, { 0x02, SONYPI_EVENT_PKEY_P2 }, { 0x04, SONYPI_EVENT_PKEY_P3 }, - { 0x00, 0x00 } + { 0, 0 } }; /* The set of possible bluetooth events */ @@ -208,20 +231,65 @@ { 0x55, SONYPI_EVENT_BLUETOOTH_PRESSED }, { 0x59, SONYPI_EVENT_BLUETOOTH_ON }, { 0x5a, SONYPI_EVENT_BLUETOOTH_OFF }, - { 0x00, 0x00 } + { 0, 0 } }; /* The set of possible back button events */ static struct sonypi_event sonypi_backev[] = { { 0x20, SONYPI_EVENT_BACK_PRESSED }, - { 0x00, 0x00 } + { 0, 0 } +}; + +/* The set of possible help button events */ +static struct sonypi_event sonypi_helpev[] = { + { 0x3b, SONYPI_EVENT_HELP_PRESSED }, + { 0, 0 } }; + /* The set of possible lid events */ static struct sonypi_event sonypi_lidev[] = { { 0x51, SONYPI_EVENT_LID_CLOSED }, { 0x50, SONYPI_EVENT_LID_OPENED }, - { 0x00, 0x00 } + { 0, 0 } +}; + +/* The set of possible zoom events */ +static struct sonypi_event sonypi_zoomev[] = { + { 0x3a, SONYPI_EVENT_ZOOM_PRESSED }, + { 0, 0 } +}; + +/* The set of possible thumbphrase events */ +static struct sonypi_event sonypi_thumbphraseev[] = { + { 0x3a, SONYPI_EVENT_THUMBPHRASE_PRESSED }, + { 0, 0 } +}; + +struct sonypi_eventtypes { + int model; + u8 data; + unsigned long mask; + struct sonypi_event * events; +} sonypi_eventtypes[] = { + { SONYPI_DEVICE_MODEL_TYPE1, 0x10, SONYPI_JOGGER_MASK, sonypi_joggerev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x60, SONYPI_CAPTURE_MASK, sonypi_captureev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x20, SONYPI_FNKEY_MASK, sonypi_fnkeyev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_BLUETOOTH_MASK, sonypi_blueev }, + { SONYPI_DEVICE_MODEL_TYPE1, 0x40, SONYPI_PKEY_MASK, sonypi_pkeyev }, + + { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_JOGGER_MASK, sonypi_joggerev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_CAPTURE_MASK, sonypi_captureev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_FNKEY_MASK, sonypi_fnkeyev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_BLUETOOTH_MASK, sonypi_blueev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_PKEY_MASK, sonypi_pkeyev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_BACK_MASK, sonypi_backev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_HELP_MASK, sonypi_helpev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x38, SONYPI_LID_MASK, sonypi_lidev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_ZOOM_MASK, sonypi_zoomev }, + { SONYPI_DEVICE_MODEL_TYPE2, 0x08, SONYPI_THUMBPHRASE_MASK, sonypi_thumbphraseev }, + + { 0, 0, 0, 0 } }; #define SONYPI_BUF_SIZE 128 @@ -235,9 +303,6 @@ unsigned char buf[SONYPI_BUF_SIZE]; }; -#define SONYPI_DEVICE_MODEL_TYPE1 1 -#define SONYPI_DEVICE_MODEL_TYPE2 2 - struct sonypi_device { struct pci_dev *dev; u16 irq; @@ -251,14 +316,20 @@ struct sonypi_queue queue; int open_count; int model; +#if CONFIG_PM + struct pm_dev *pm; +#endif }; -#define wait_on_command(quiet, command) { \ - unsigned int n = 10000; \ +#define ITERATIONS_LONG 10000 +#define ITERATIONS_SHORT 10 + +#define wait_on_command(quiet, command, iterations) { \ + unsigned int n = iterations; \ while (--n && (command)) \ udelay(1); \ if (!n && (verbose || !quiet)) \ - printk(KERN_WARNING "sonypi command failed at " __FILE__ " : " __FUNCTION__ "(line %d)\n", __LINE__); \ + printk(KERN_WARNING "sonypi command failed at %s : %s (line %d)\n", __FILE__, __FUNCTION__, __LINE__); \ } #endif /* __KERNEL__ */ diff -Nur linux-2.4.19.vanilla/include/linux/sonypi.h linux-2.4.19/include/linux/sonypi.h --- linux-2.4.19.vanilla/include/linux/sonypi.h Mon Feb 25 20:38:13 2002 +++ linux-2.4.19/include/linux/sonypi.h Tue Nov 12 12:25:12 2002 @@ -1,7 +1,9 @@ /* * Sony Programmable I/O Control Device driver for VAIO * - * Copyright (C) 2001 Stelian Pop , Alcôve + * Copyright (C) 2001-2002 Stelian Pop + * + * Copyright (C) 2001-2002 Alcôve * * Copyright (C) 2001 Michael Ashley * @@ -41,11 +43,11 @@ #define SONYPI_EVENT_JOGDIAL_DOWN_PRESSED 3 #define SONYPI_EVENT_JOGDIAL_UP_PRESSED 4 #define SONYPI_EVENT_JOGDIAL_PRESSED 5 -#define SONYPI_EVENT_JOGDIAL_RELEASED 6 +#define SONYPI_EVENT_JOGDIAL_RELEASED 6 /* obsolete */ #define SONYPI_EVENT_CAPTURE_PRESSED 7 -#define SONYPI_EVENT_CAPTURE_RELEASED 8 +#define SONYPI_EVENT_CAPTURE_RELEASED 8 /* obsolete */ #define SONYPI_EVENT_CAPTURE_PARTIALPRESSED 9 -#define SONYPI_EVENT_CAPTURE_PARTIALRELEASED 10 +#define SONYPI_EVENT_CAPTURE_PARTIALRELEASED 10 /* obsolete */ #define SONYPI_EVENT_FNKEY_ESC 11 #define SONYPI_EVENT_FNKEY_F1 12 #define SONYPI_EVENT_FNKEY_F2 13 @@ -75,6 +77,18 @@ #define SONYPI_EVENT_LID_OPENED 37 #define SONYPI_EVENT_BLUETOOTH_ON 38 #define SONYPI_EVENT_BLUETOOTH_OFF 39 +#define SONYPI_EVENT_HELP_PRESSED 40 +#define SONYPI_EVENT_FNKEY_ONLY 41 +#define SONYPI_EVENT_JOGDIAL_FAST_DOWN 42 +#define SONYPI_EVENT_JOGDIAL_FAST_UP 43 +#define SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED 44 +#define SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED 45 +#define SONYPI_EVENT_JOGDIAL_VFAST_DOWN 46 +#define SONYPI_EVENT_JOGDIAL_VFAST_UP 47 +#define SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED 48 +#define SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED 49 +#define SONYPI_EVENT_ZOOM_PRESSED 50 +#define SONYPI_EVENT_THUMBPHRASE_PRESSED 51 /* get/set brightness */ #define SONYPI_IOCGBRT _IOR('v', 0, __u8)