]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] sonypi: add fan and temperature status/control
authorStelian Pop <stelian@popies.net>
Thu, 10 Feb 2005 01:48:07 +0000 (17:48 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 10 Feb 2005 01:48:07 +0000 (17:48 -0800)
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 <nars@kadamba.org>
Signed-off-by: Stelian Pop <stelian@popies.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/char/sonypi.c
include/linux/sonypi.h

index f65fc358d41785ce71aca41b464002aacf2a3c1d..f97a8a9751a0d2da245e023013f3813a8966f72d 100644 (file)
@@ -3,6 +3,8 @@
  *
  * Copyright (C) 2001-2005 Stelian Pop <stelian@popies.net>
  *
+ * Copyright (C) 2005 Narayanan R S <nars@kadamba.org>
+ *
  * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
  *
  * Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au>
@@ -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;
        }
index 388d573e12a6a7af017a6695635d867d1c69a705..768cbba617d02533388270a1a0e1795752d15cb6 100644 (file)
@@ -1,8 +1,10 @@
 /*
  * Sony Programmable I/O Control Device driver for VAIO
  *
- * Copyright (C) 2001-2004 Stelian Pop <stelian@popies.net>
+ * Copyright (C) 2001-2005 Stelian Pop <stelian@popies.net>
  *
+ * Copyright (C) 2005 Narayanan R S <nars@kadamba.org>
+
  * Copyright (C) 2001-2002 Alcôve <www.alcove.com>
  *
  * Copyright (C) 2001 Michael Ashley <m.ashley@unsw.edu.au>
 #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 */