===================================================================

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 <[EMAIL PROTECTED]>
Signed-off-by: Stelian Pop <[EMAIL PROTECTED]>

===================================================================

 drivers/char/sonypi.c  |   32 ++++++++++++++++++++++++++++++++
 include/linux/sonypi.h |   11 ++++++++++-
 2 files changed, 42 insertions(+), 1 deletion(-)

===================================================================

Index: include/linux/sonypi.h
===================================================================
--- a/include/linux/sonypi.h    (revision 26830)
+++ b/include/linux/sonypi.h    (revision 26831)
@@ -1,8 +1,10 @@
 /*
  * Sony Programmable I/O Control Device driver for VAIO
  *
- * Copyright (C) 2001-2004 Stelian Pop <[EMAIL PROTECTED]>
+ * Copyright (C) 2001-2005 Stelian Pop <[EMAIL PROTECTED]>
  *
+ * Copyright (C) 2005 Narayanan R S <[EMAIL PROTECTED]>
+
  * Copyright (C) 2001-2002 Alc�ve <www.alcove.com>
  *
  * Copyright (C) 2001 Michael Ashley <[EMAIL PROTECTED]>
@@ -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 */
Index: drivers/char/sonypi.c
===================================================================
--- a/drivers/char/sonypi.c     (revision 26830)
+++ b/drivers/char/sonypi.c     (revision 26831)
@@ -3,6 +3,8 @@
  *
  * Copyright (C) 2001-2005 Stelian Pop <[EMAIL PROTECTED]>
  *
+ * Copyright (C) 2005 Narayanan R S <[EMAIL PROTECTED]>
+ *
  * Copyright (C) 2001-2002 Alc�ve <www.alcove.com>
  *
  * Copyright (C) 2001 Michael Ashley <[EMAIL PROTECTED]>
@@ -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 inod
                }
                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;
        }
-- 
Stelian Pop <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to