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

[PATCH] sonypi driver update

This patch adds some new events to the sonypi driver (Fn key
pressed alone, jogdial turned fast or very fast) and cleanups
the code a little bit.

Thanks to Christian Gennerat for this contribution.
parent 0fca8365
/* /*
* 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 Stelian Pop <stelian.pop@fr.alcove.com>, Alcve
...@@ -542,7 +542,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp, ...@@ -542,7 +542,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
down(&sonypi_device.lock); down(&sonypi_device.lock);
switch (cmd) { switch (cmd) {
case SONYPI_IOCGBRT: case SONYPI_IOCGBRT:
val8 = sonypi_ecrget(0x96); val8 = sonypi_ecrget(SONYPI_LCD_LIGHT);
if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) { if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
...@@ -553,38 +553,38 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp, ...@@ -553,38 +553,38 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
} }
sonypi_ecrset(0x96, val8); sonypi_ecrset(SONYPI_LCD_LIGHT, val8);
break; break;
case SONYPI_IOCGBAT1CAP: case SONYPI_IOCGBAT1CAP:
val16 = sonypi_ecrget16(0xb2); val16 = sonypi_ecrget16(SONYPI_BAT1_FULL);
if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) { if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
} }
break; break;
case SONYPI_IOCGBAT1REM: case SONYPI_IOCGBAT1REM:
val16 = sonypi_ecrget16(0xa2); val16 = sonypi_ecrget16(SONYPI_BAT1_LEFT);
if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) { if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
} }
break; break;
case SONYPI_IOCGBAT2CAP: case SONYPI_IOCGBAT2CAP:
val16 = sonypi_ecrget16(0xba); val16 = sonypi_ecrget16(SONYPI_BAT2_FULL);
if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) { if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
} }
break; break;
case SONYPI_IOCGBAT2REM: case SONYPI_IOCGBAT2REM:
val16 = sonypi_ecrget16(0xaa); val16 = sonypi_ecrget16(SONYPI_BAT2_LEFT);
if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) { if (copy_to_user((u16 *)arg, &val16, sizeof(val16))) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
} }
break; break;
case SONYPI_IOCGBATFLAGS: case SONYPI_IOCGBATFLAGS:
val8 = sonypi_ecrget(0x81) & 0x07; val8 = sonypi_ecrget(SONYPI_BAT_FLAGS) & 0x07;
if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) { if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) {
ret = -EFAULT; ret = -EFAULT;
goto out; goto out;
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#define SONYPI_DRIVER_MAJORVERSION 1 #define SONYPI_DRIVER_MAJORVERSION 1
#define SONYPI_DRIVER_MINORVERSION 13 #define SONYPI_DRIVER_MINORVERSION 14
#include <linux/types.h> #include <linux/types.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -54,6 +54,20 @@ ...@@ -54,6 +54,20 @@
#define SONYPI_SHIB 0x9d #define SONYPI_SHIB 0x9d
#define SONYPI_TYPE2_REGION_SIZE 0x20 #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 */ /* ioports used for brightness and type2 events */
#define SONYPI_DATA_IOPORT 0x62 #define SONYPI_DATA_IOPORT 0x62
#define SONYPI_CST_IOPORT 0x66 #define SONYPI_CST_IOPORT 0x66
...@@ -156,6 +170,14 @@ static struct sonypi_event sonypi_joggerev[] = { ...@@ -156,6 +170,14 @@ static struct sonypi_event sonypi_joggerev[] = {
{ 0x01, SONYPI_EVENT_JOGDIAL_DOWN }, { 0x01, SONYPI_EVENT_JOGDIAL_DOWN },
{ 0x5f, SONYPI_EVENT_JOGDIAL_UP_PRESSED }, { 0x5f, SONYPI_EVENT_JOGDIAL_UP_PRESSED },
{ 0x41, SONYPI_EVENT_JOGDIAL_DOWN_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 }, { 0x40, SONYPI_EVENT_JOGDIAL_PRESSED },
{ 0x00, SONYPI_EVENT_JOGDIAL_RELEASED }, { 0x00, SONYPI_EVENT_JOGDIAL_RELEASED },
{ 0x00, 0x00 } { 0x00, 0x00 }
...@@ -192,6 +214,7 @@ static struct sonypi_event sonypi_fnkeyev[] = { ...@@ -192,6 +214,7 @@ static struct sonypi_event sonypi_fnkeyev[] = {
{ 0x33, SONYPI_EVENT_FNKEY_F }, { 0x33, SONYPI_EVENT_FNKEY_F },
{ 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 },
{ 0x00, 0x00 } { 0x00, 0x00 }
}; };
...@@ -214,6 +237,7 @@ static struct sonypi_event sonypi_blueev[] = { ...@@ -214,6 +237,7 @@ static struct sonypi_event sonypi_blueev[] = {
/* 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 },
{ 0x3b, SONYPI_EVENT_HELP_PRESSED },
{ 0x00, 0x00 } { 0x00, 0x00 }
}; };
...@@ -258,7 +282,7 @@ struct sonypi_device { ...@@ -258,7 +282,7 @@ struct sonypi_device {
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__); \
} }
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
...@@ -75,6 +75,16 @@ ...@@ -75,6 +75,16 @@
#define SONYPI_EVENT_LID_OPENED 37 #define SONYPI_EVENT_LID_OPENED 37
#define SONYPI_EVENT_BLUETOOTH_ON 38 #define SONYPI_EVENT_BLUETOOTH_ON 38
#define SONYPI_EVENT_BLUETOOTH_OFF 39 #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
/* 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