Difference between revisions of "Talk:Patch for controlling fan speed"

From ThinkWiki
Jump to: navigation, search
(Patch for 2.6.14 with gkrellm compatibility)
Line 16: Line 16:
  
 
As in "works for me on a T43p", use with caution at your own risk. And thanks to thinker for the original patch, very nice work.
 
As in "works for me on a T43p", use with caution at your own risk. And thanks to thinker for the original patch, very nice work.
<pre>
 
--- drivers/acpi/ibm_acpi.c.orig        2005-11-01 19:47:44.262270250 +0100
 
+++ drivers/acpi/ibm_acpi.c    2005-11-01 20:16:16.081252250 +0100
 
@@ -1465,6 +1465,7 @@
 
{
 
        int len = 0;
 
        int s;
 
+      char status_read = 0;
 
        u8 lo, hi, status;
 
  
        if (gfan_handle) {
+
(See article for the actual patch)
@@ -1477,9 +1478,11 @@
 
                /* all except 570, 600e/x, 770e, 770x */
 
                if (!acpi_ec_read(fan_status_offset, &status))
 
                        len += sprintf(p + len, "status:\t\tunreadable\n");
 
-              else
 
+              else {
 
                        len += sprintf(p + len, "status:\t\t%s\n",
 
-                                      enabled(status, 7));
 
+                                    status ? "enabled" : "disabled");
 
+                      status_read = 1;
 
+              }
 
  
                if (!acpi_ec_read(fan_rpm_offset, &lo) ||
+
--[[User:Spiney|Spiney]]
                    !acpi_ec_read(fan_rpm_offset + 1, &hi))
 
@@ -1487,6 +1490,14 @@
 
                else
 
                        len += sprintf(p + len, "speed:\t\t%d\n",
 
                                      (hi << 8) + lo);
 
+              if (status_read) {
 
+                      if (status & 0x40)
 
+                              len += sprintf(p + len, "level:\t\tdisengaged\n");
 
+                      else if (status & 0x80)
 
+                              len += sprintf(p + len, "level:\t\tauto\n");
 
+                      else
 
+                              len += sprintf(p + len, "level:\t\t%d\n", status);
 
+              }
 
        }
 
  
        if (sfan_handle)
+
Looks excellent, why not add it to the article page? Also, care to provide a license (preferably public domain like my patch) so the kernel guys can handle it? Speaking of which, the kernel people seem to like their patches generated via "diff -up vanilla-kernel-2.6.14 patched-kernel-2.6.14".
@@ -1495,7 +1506,10 @@
 
                              " (<level> is 0-7)\n");
 
        if (!gfan_handle)
 
                /* all except 570, 600e/x, 770e, 770x */
 
-              len += sprintf(p + len, "commands:\tenable, disable\n");
 
+              len += sprintf(p + len,
 
+                            "commands:\tenable, disable, level <level>\n"
 
+                            "        \t(<level> is 0-7, auto "
 
+                            "or disengaged)\n");
 
        if (fans_handle)
 
                /* X31, X40 */
 
                len += sprintf(p + len, "commands:\tspeed <speed>"
 
@@ -1516,7 +1530,8 @@
 
                        /* 570, 770x-JL */
 
                        if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", level))
 
                                return -EIO;
 
-              } else if (!gfan_handle && strlencmp(cmd, "enable") == 0) {
 
+              } else if (!gfan_handle && ( (strlencmp(cmd, "enable") == 0) ||
 
+                              (strlencmp(cmd, "level auto") == 0) ) ) {
 
                        /* all except 570, 600e/x, 770e, 770x */
 
                        if (!acpi_ec_write(fan_status_offset, 0x80))
 
                                return -EIO;
 
@@ -1524,6 +1539,17 @@
 
                        /* all except 570, 600e/x, 770e, 770x */
 
                        if (!acpi_ec_write(fan_status_offset, 0x00))
 
                                return -EIO;
 
+              } else if (!gfan_handle &&
 
+                          strlencmp(cmd, "level disengaged") == 0) {
 
+                      /* all except 570, 600e/x, 770e, 770x */
 
+                      if (!acpi_ec_write(fan_status_offset, 0x40))
 
+                              return -EIO;
 
+              } else if (!gfan_handle &&
 
+                  sscanf(cmd, "level %d", &level) == 1 &&
 
+                  level >=0 && level <= 7) {
 
+                      /* all except 570, 600e/x, 770e, 770x */
 
+                      if (!acpi_ec_write(fan_status_offset, level))
 
+                              return -EIO;
 
                } else if (fans_handle &&
 
                          sscanf(cmd, "speed %d", &speed) == 1 &&
 
                          speed >= 0 && speed <= 65535) {
 
</pre>
 
  
--Spiney
+
--[[User:Thinker|Thinker]] 22:04, 1 Nov 2005 (CET)
  
Looks excellent, why not add it to the article page? Also, care to provide a license (preferably public domain like my patch) so the kernel guys can handle it? Speaking of which, the kernel people seem to like their patches generated via "diff -up vanilla-kernel-2.6.14 patched-kernel-2.6.14".
+
Done, using the -p option for diff and "borrowing" your sentence for licensing purposes.
  
--[[User:Thinker|Thinker]] 22:04, 1 Nov 2005 (CET)
+
--[[User:Spiney|Spiney]]
 
----
 
----

Revision as of 09:16, 2 November 2005

I can confirm that it works on Thinkpad T43 here. However after applying the patch, the fan speed monitor of gkrellm 2.2.7 cannot read value correctly. Maybe we gkrellm is reading the second line for speed but instead find the line for level, so it got confused? Would it be possible to interchange the lines so that speed still appears in the second line and level appears in the third instead? I'm no coder, just a suggestion to improve the patch. --Jiang


I'd say it's a bug in gkrellm. It should parse the line header rather than relying on line numbers. But feel free to change (and test) the patch if you wish.

--Thinker 05:14, 26 Oct 2005 (CEST)


patch to keep gkrell working against 2.6.14

As in "works for me on a T43p", use with caution at your own risk. And thanks to thinker for the original patch, very nice work.

(See article for the actual patch)

--Spiney

Looks excellent, why not add it to the article page? Also, care to provide a license (preferably public domain like my patch) so the kernel guys can handle it? Speaking of which, the kernel people seem to like their patches generated via "diff -up vanilla-kernel-2.6.14 patched-kernel-2.6.14".

--Thinker 22:04, 1 Nov 2005 (CET)

Done, using the -p option for diff and "borrowing" your sentence for licensing purposes.

--Spiney