From 05d1949848c04ae112df363e7597dca4ac9c4160 Mon Sep 17 00:00:00 2001 From: Stelian Pop Date: Wed, 9 Feb 2005 17:48:07 -0800 Subject: [PATCH] [PATCH] sonypi: add fan and temperature status/control 1. FAN Status/Control: you can now get the fan status (running or not) and also set the fan speed (for <5 seconds only). The problem is that there is an auto regulator that kicks in within about 5 seconds after that to restart the fan if it is above a threshold temperature (39 Degree C in my Vaio). It is useful just to get the fan status (primarily). It also appears that you can change the speed by increasing the values (much like the LCD control) - there are effectively only about 6 speeds (it seems - not sure, but from what I've played with on my Vaio). 2. Temperature: you can get the current temperature (same as reported by ACPI). This is primarily useful for APM users (since ACPI already gives this). I have used this to detect when the fan comes on in my Vaio (39 Degree C). From: Narayanan R S Signed-off-by: Stelian Pop Signed-off-by: Linus Torvalds --- drivers/char/sonypi.c | 32 ++++++++++++++++++++++++++++++++ include/linux/sonypi.h | 11 ++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index f65fc358d417..f97a8a9751a0 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c @@ -3,6 +3,8 @@ * * Copyright (C) 2001-2005 Stelian Pop * + * Copyright (C) 2005 Narayanan R S + * * Copyright (C) 2001-2002 Alcôve * * Copyright (C) 2001 Michael Ashley @@ -126,6 +128,10 @@ MODULE_PARM_DESC(useinput, #define SONYPI_BAT2_MAXTK 0xb8 #define SONYPI_BAT2_FULL 0xba +/* FAN0 information (reverse engineered from ACPI tables) */ +#define SONYPI_FAN0_STATUS 0x93 +#define SONYPI_TEMP_STATUS 0xC1 + /* ioports used for brightness and type2 events */ #define SONYPI_DATA_IOPORT 0x62 #define SONYPI_CST_IOPORT 0x66 @@ -1009,6 +1015,32 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp, } sonypi_setbluetoothpower(val8); break; + /* FAN Controls */ + case SONYPI_IOCGFAN: + if (sonypi_ec_read(SONYPI_FAN0_STATUS, &val8)) { + ret = -EIO; + break; + } + if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) + ret = -EFAULT; + break; + case SONYPI_IOCSFAN: + if (copy_from_user(&val8, (u8 *)arg, sizeof(val8))) { + ret = -EFAULT; + break; + } + if (sonypi_ec_write(SONYPI_FAN0_STATUS, val8)) + ret = -EIO; + break; + /* GET Temperature (useful under APM) */ + case SONYPI_IOCGTEMP: + if (sonypi_ec_read(SONYPI_TEMP_STATUS, &val8)) { + ret = -EIO; + break; + } + if (copy_to_user((u8 *)arg, &val8, sizeof(val8))) + ret = -EFAULT; + break; default: ret = -EINVAL; } diff --git a/include/linux/sonypi.h b/include/linux/sonypi.h index 388d573e12a6..768cbba617d0 100644 --- a/include/linux/sonypi.h +++ b/include/linux/sonypi.h @@ -1,8 +1,10 @@ /* * Sony Programmable I/O Control Device driver for VAIO * - * Copyright (C) 2001-2004 Stelian Pop + * Copyright (C) 2001-2005 Stelian Pop * + * Copyright (C) 2005 Narayanan R S + * Copyright (C) 2001-2002 Alcôve * * Copyright (C) 2001 Michael Ashley @@ -118,6 +120,13 @@ #define SONYPI_IOCGBLUE _IOR('v', 8, __u8) #define SONYPI_IOCSBLUE _IOW('v', 9, __u8) +/* get/set fan state on/off */ +#define SONYPI_IOCGFAN _IOR('v', 10, __u8) +#define SONYPI_IOCSFAN _IOW('v', 11, __u8) + +/* get temperature (C) */ +#define SONYPI_IOCGTEMP _IOR('v', 12, __u8) + #ifdef __KERNEL__ /* used only for communication between v4l and sonypi */ -- 2.39.5