Commit eaac83e4 authored by Stelian Pop's avatar Stelian Pop Committed by Linus Torvalds

[PATCH] sonypi driver update

The most important changes are:
	* add suspend/resume support to the sonypi driver (not
	  based on driverfs however) (Florian Lohoff);
	* add "Zoom" and "Thumbphrase" buttons (Francois Gurin);
	* add camera and lid events for C1XE (Kunihiko IMAI);
	* add a mask parameter letting the user choose what kind
	  of events he wants;
	* use ACPI ec_read/ec_write when available in order to
	  play nice when latest ACPI is enabled;
	* several source cleanups.
parent d29cb98f
Sony Programmable I/O Control Device Driver Readme Sony Programmable I/O Control Device Driver Readme
-------------------------------------------------- --------------------------------------------------
Copyright (C) 2001 Stelian Pop <stelian.pop@fr.alcove.com>, Alcôve Copyright (C) 2001-2002 Stelian Pop <stelian@popies.net>
Copyright (C) 2001-2002 Alcôve <www.alcove.com>
Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au> Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au>
Copyright (C) 2001 Junichi Morita <jun1m@mars.dti.ne.jp> Copyright (C) 2001 Junichi Morita <jun1m@mars.dti.ne.jp>
Copyright (C) 2000 Takaya Kinjo <t-kinjo@tc4.so-net.ne.jp> Copyright (C) 2000 Takaya Kinjo <t-kinjo@tc4.so-net.ne.jp>
...@@ -15,14 +16,14 @@ generate, like: ...@@ -15,14 +16,14 @@ generate, like:
- capture button events (only on Vaio Picturebook series) - capture button events (only on Vaio Picturebook series)
- Fn keys - Fn keys
- bluetooth button (only on C1VR model) - bluetooth button (only on C1VR model)
- back button (PCG-GR7/K model) - programmable keys, back, help, zoom, thumbphrase buttons, etc.
- lid open/close events (Z600NE model) (when available)
Those events (see linux/sonypi.h) can be polled using the character device node Those events (see linux/sonypi.h) can be polled using the character device node
/dev/sonypi (major 10, minor auto allocated or specified as a option). /dev/sonypi (major 10, minor auto allocated or specified as a option).
A simple daemon which translates the jogdial movements into mouse wheel events A simple daemon which translates the jogdial movements into mouse wheel events
can be downloaded at: <http://www.alcove-labs.org/en/software/sonypi/> can be downloaded at: <http://popies.net/sonypi/>
This driver supports also some ioctl commands for setting the LCD screen This driver supports also some ioctl commands for setting the LCD screen
brightness and querying the batteries charge information (some more brightness and querying the batteries charge information (some more
...@@ -43,7 +44,7 @@ Several options can be passed to the sonypi driver, either by adding them ...@@ -43,7 +44,7 @@ Several options can be passed to the sonypi driver, either by adding them
to /etc/modules.conf file, when the driver is compiled as a module or by to /etc/modules.conf file, when the driver is compiled as a module or by
adding the following to the kernel command line (in your bootloader): adding the following to the kernel command line (in your bootloader):
sonypi=minor[,verbose[,fnkeyinit[,camera[,compat[,nojogdial]]]]] sonypi=minor[,verbose[,fnkeyinit[,camera[,compat[,mask]]]]]
where: where:
...@@ -64,15 +65,36 @@ where: ...@@ -64,15 +65,36 @@ where:
with it and it shouldn't be required anyway if with it and it shouldn't be required anyway if
ACPI is already enabled). ACPI is already enabled).
verbose: print unknown events from the sonypi device verbose: set to 1 to print unknown events received from the
sonypi device.
set to 2 to print all events received from the
sonypi device.
compat: uses some compatibility code for enabling the sonypi compat: uses some compatibility code for enabling the sonypi
events. If the driver worked for you in the past events. If the driver worked for you in the past
(prior to version 1.5) and does not work anymore, (prior to version 1.5) and does not work anymore,
add this option and report to the author. add this option and report to the author.
nojogdial: gives more accurate PKEY events on those Vaio models mask: event mask telling the driver what events will be
which don't have a jogdial (like the FX series). 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
SONYPI_MEYE_MASK 0x0400
Module use: Module use:
----------- -----------
......
This diff is collapsed.
/* /*
* Sony Programmable I/O Control Device driver for VAIO * Sony Programmable I/O Control Device driver for VAIO
* *
* Copyright (C) 2001 Stelian Pop <stelian.pop@fr.alcove.com>, Alcve * Copyright (C) 2001-2002 Stelian Pop <stelian@popies.net>
*
* Copyright (C) 2001-2002 Alcve <www.alcove.com>
* *
* Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au> * Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au>
* *
...@@ -35,10 +37,16 @@ ...@@ -35,10 +37,16 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#define SONYPI_DRIVER_MAJORVERSION 1 #define SONYPI_DRIVER_MAJORVERSION 1
#define SONYPI_DRIVER_MINORVERSION 14 #define SONYPI_DRIVER_MINORVERSION 15
#define SONYPI_DEVICE_MODEL_TYPE1 1
#define SONYPI_DEVICE_MODEL_TYPE2 2
#include <linux/config.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/pm.h>
#include <linux/acpi.h>
#include "linux/sonypi.h" #include "linux/sonypi.h"
/* type1 models use those */ /* type1 models use those */
...@@ -145,25 +153,23 @@ static struct sonypi_irq_list sonypi_type2_irq_list[] = { ...@@ -145,25 +153,23 @@ static struct sonypi_irq_list sonypi_type2_irq_list[] = {
#define SONYPI_CAMERA_REVISION 8 #define SONYPI_CAMERA_REVISION 8
#define SONYPI_CAMERA_ROMVERSION 9 #define SONYPI_CAMERA_ROMVERSION 9
/* key press event data (ioport2) */ /* Event masks */
#define SONYPI_TYPE1_JOGGER_EV 0x10 #define SONYPI_JOGGER_MASK 0x00000001
#define SONYPI_TYPE2_JOGGER_EV 0x08 #define SONYPI_CAPTURE_MASK 0x00000002
#define SONYPI_TYPE1_CAPTURE_EV 0x60 #define SONYPI_FNKEY_MASK 0x00000004
#define SONYPI_TYPE2_CAPTURE_EV 0x08 #define SONYPI_BLUETOOTH_MASK 0x00000008
#define SONYPI_TYPE1_FNKEY_EV 0x20 #define SONYPI_PKEY_MASK 0x00000010
#define SONYPI_TYPE2_FNKEY_EV 0x08 #define SONYPI_BACK_MASK 0x00000020
#define SONYPI_TYPE1_BLUETOOTH_EV 0x30 #define SONYPI_HELP_MASK 0x00000040
#define SONYPI_TYPE2_BLUETOOTH_EV 0x08 #define SONYPI_LID_MASK 0x00000080
#define SONYPI_TYPE1_PKEY_EV 0x40 #define SONYPI_ZOOM_MASK 0x00000100
#define SONYPI_TYPE2_PKEY_EV 0x08 #define SONYPI_THUMBPHRASE_MASK 0x00000200
#define SONYPI_BACK_EV 0x08 #define SONYPI_MEYE_MASK 0x00000400
#define SONYPI_LID_EV 0x38
struct sonypi_event { struct sonypi_event {
u8 data; u8 data;
u8 event; u8 event;
}; };
/* The set of possible jogger events */ /* The set of possible jogger events */
static struct sonypi_event sonypi_joggerev[] = { static struct sonypi_event sonypi_joggerev[] = {
{ 0x1f, SONYPI_EVENT_JOGDIAL_UP }, { 0x1f, SONYPI_EVENT_JOGDIAL_UP },
...@@ -180,7 +186,7 @@ static struct sonypi_event sonypi_joggerev[] = { ...@@ -180,7 +186,7 @@ static struct sonypi_event sonypi_joggerev[] = {
{ 0x43, SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED }, { 0x43, SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED },
{ 0x40, SONYPI_EVENT_JOGDIAL_PRESSED }, { 0x40, SONYPI_EVENT_JOGDIAL_PRESSED },
{ 0x00, SONYPI_EVENT_JOGDIAL_RELEASED }, { 0x00, SONYPI_EVENT_JOGDIAL_RELEASED },
{ 0x00, 0x00 } { 0, 0 }
}; };
/* The set of possible capture button events */ /* The set of possible capture button events */
...@@ -189,7 +195,7 @@ static struct sonypi_event sonypi_captureev[] = { ...@@ -189,7 +195,7 @@ static struct sonypi_event sonypi_captureev[] = {
{ 0x07, SONYPI_EVENT_CAPTURE_PRESSED }, { 0x07, SONYPI_EVENT_CAPTURE_PRESSED },
{ 0x01, SONYPI_EVENT_CAPTURE_PARTIALRELEASED }, { 0x01, SONYPI_EVENT_CAPTURE_PARTIALRELEASED },
{ 0x00, SONYPI_EVENT_CAPTURE_RELEASED }, { 0x00, SONYPI_EVENT_CAPTURE_RELEASED },
{ 0x00, 0x00 } { 0, 0 }
}; };
/* The set of possible fnkeys events */ /* The set of possible fnkeys events */
...@@ -215,7 +221,7 @@ static struct sonypi_event sonypi_fnkeyev[] = { ...@@ -215,7 +221,7 @@ static struct sonypi_event sonypi_fnkeyev[] = {
{ 0x34, SONYPI_EVENT_FNKEY_S }, { 0x34, SONYPI_EVENT_FNKEY_S },
{ 0x35, SONYPI_EVENT_FNKEY_B }, { 0x35, SONYPI_EVENT_FNKEY_B },
{ 0x36, SONYPI_EVENT_FNKEY_ONLY }, { 0x36, SONYPI_EVENT_FNKEY_ONLY },
{ 0x00, 0x00 } { 0, 0 }
}; };
/* The set of possible program key events */ /* The set of possible program key events */
...@@ -223,7 +229,7 @@ static struct sonypi_event sonypi_pkeyev[] = { ...@@ -223,7 +229,7 @@ static struct sonypi_event sonypi_pkeyev[] = {
{ 0x01, SONYPI_EVENT_PKEY_P1 }, { 0x01, SONYPI_EVENT_PKEY_P1 },
{ 0x02, SONYPI_EVENT_PKEY_P2 }, { 0x02, SONYPI_EVENT_PKEY_P2 },
{ 0x04, SONYPI_EVENT_PKEY_P3 }, { 0x04, SONYPI_EVENT_PKEY_P3 },
{ 0x00, 0x00 } { 0, 0 }
}; };
/* The set of possible bluetooth events */ /* The set of possible bluetooth events */
...@@ -231,21 +237,74 @@ static struct sonypi_event sonypi_blueev[] = { ...@@ -231,21 +237,74 @@ static struct sonypi_event sonypi_blueev[] = {
{ 0x55, SONYPI_EVENT_BLUETOOTH_PRESSED }, { 0x55, SONYPI_EVENT_BLUETOOTH_PRESSED },
{ 0x59, SONYPI_EVENT_BLUETOOTH_ON }, { 0x59, SONYPI_EVENT_BLUETOOTH_ON },
{ 0x5a, SONYPI_EVENT_BLUETOOTH_OFF }, { 0x5a, SONYPI_EVENT_BLUETOOTH_OFF },
{ 0x00, 0x00 } { 0, 0 }
}; };
/* The set of possible back button events */ /* The set of possible back button events */
static struct sonypi_event sonypi_backev[] = { static struct sonypi_event sonypi_backev[] = {
{ 0x20, SONYPI_EVENT_BACK_PRESSED }, { 0x20, SONYPI_EVENT_BACK_PRESSED },
{ 0, 0 }
};
/* The set of possible help button events */
static struct sonypi_event sonypi_helpev[] = {
{ 0x3b, SONYPI_EVENT_HELP_PRESSED }, { 0x3b, SONYPI_EVENT_HELP_PRESSED },
{ 0x00, 0x00 } { 0, 0 }
}; };
/* The set of possible lid events */ /* The set of possible lid events */
static struct sonypi_event sonypi_lidev[] = { static struct sonypi_event sonypi_lidev[] = {
{ 0x51, SONYPI_EVENT_LID_CLOSED }, { 0x51, SONYPI_EVENT_LID_CLOSED },
{ 0x50, SONYPI_EVENT_LID_OPENED }, { 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 }
};
/* The set of possible motioneye camera events */
static struct sonypi_event sonypi_meyeev[] = {
{ 0x00, SONYPI_EVENT_MEYE_FACE },
{ 0x01, SONYPI_EVENT_MEYE_OPPOSITE },
{ 0, 0 }
};
struct sonypi_eventtypes {
int model;
u8 data;
unsigned long mask;
struct sonypi_event * events;
} sonypi_eventtypes[] = {
{ SONYPI_DEVICE_MODEL_TYPE1, 0x70, SONYPI_MEYE_MASK, sonypi_meyeev },
{ SONYPI_DEVICE_MODEL_TYPE1, 0x30, SONYPI_LID_MASK, sonypi_lidev },
{ SONYPI_DEVICE_MODEL_TYPE1, 0x60, SONYPI_CAPTURE_MASK, sonypi_captureev },
{ SONYPI_DEVICE_MODEL_TYPE1, 0x10, SONYPI_JOGGER_MASK, sonypi_joggerev },
{ 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, 0x38, SONYPI_LID_MASK, sonypi_lidev },
{ 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, 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 #define SONYPI_BUF_SIZE 128
...@@ -259,9 +318,6 @@ struct sonypi_queue { ...@@ -259,9 +318,6 @@ struct sonypi_queue {
unsigned char buf[SONYPI_BUF_SIZE]; unsigned char buf[SONYPI_BUF_SIZE];
}; };
#define SONYPI_DEVICE_MODEL_TYPE1 1
#define SONYPI_DEVICE_MODEL_TYPE2 2
struct sonypi_device { struct sonypi_device {
struct pci_dev *dev; struct pci_dev *dev;
u16 irq; u16 irq;
...@@ -275,16 +331,47 @@ struct sonypi_device { ...@@ -275,16 +331,47 @@ struct sonypi_device {
struct sonypi_queue queue; struct sonypi_queue queue;
int open_count; int open_count;
int model; int model;
#if CONFIG_PM
struct pm_dev *pm;
#endif
}; };
#define wait_on_command(quiet, command) { \ #define ITERATIONS_LONG 10000
unsigned int n = 10000; \ #define ITERATIONS_SHORT 10
#define wait_on_command(quiet, command, iterations) { \
unsigned int n = iterations; \
while (--n && (command)) \ while (--n && (command)) \
udelay(1); \ udelay(1); \
if (!n && (verbose || !quiet)) \ if (!n && (verbose || !quiet)) \
printk(KERN_WARNING "sonypi command failed at %s : %s (line %d)\n", __FILE__, __FUNCTION__, __LINE__); \ printk(KERN_WARNING "sonypi command failed at %s : %s (line %d)\n", __FILE__, __FUNCTION__, __LINE__); \
} }
#if !defined(CONFIG_ACPI)
extern int verbose;
static inline int ec_write(u8 addr, u8 value) {
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, ITERATIONS_LONG);
outb_p(addr, SONYPI_DATA_IOPORT);
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, ITERATIONS_LONG);
return 0;
}
static inline int ec_read(u8 addr, u8 *value) {
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, ITERATIONS_LONG);
outb_p(addr, SONYPI_DATA_IOPORT);
wait_on_command(0, inb_p(SONYPI_CST_IOPORT) & 2, ITERATIONS_LONG);
*value = inb_p(SONYPI_DATA_IOPORT);
return 0;
}
#endif /* !CONFIG_ACPI */
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _SONYPI_PRIV_H_ */ #endif /* _SONYPI_PRIV_H_ */
/* /*
* Sony Programmable I/O Control Device driver for VAIO * Sony Programmable I/O Control Device driver for VAIO
* *
* Copyright (C) 2001 Stelian Pop <stelian.pop@fr.alcove.com>, Alcve * Copyright (C) 2001-2002 Stelian Pop <stelian@popies.net>
*
* Copyright (C) 2001-2002 Alcve <www.alcove.com>
* *
* Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au> * Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au>
* *
...@@ -85,6 +87,10 @@ ...@@ -85,6 +87,10 @@
#define SONYPI_EVENT_JOGDIAL_VFAST_UP 47 #define SONYPI_EVENT_JOGDIAL_VFAST_UP 47
#define SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED 48 #define SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED 48
#define SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED 49 #define SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED 49
#define SONYPI_EVENT_ZOOM_PRESSED 50
#define SONYPI_EVENT_THUMBPHRASE_PRESSED 51
#define SONYPI_EVENT_MEYE_FACE 52
#define SONYPI_EVENT_MEYE_OPPOSITE 53
/* get/set brightness */ /* get/set brightness */
#define SONYPI_IOCGBRT _IOR('v', 0, __u8) #define SONYPI_IOCGBRT _IOR('v', 0, __u8)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment