Mdr
Sinon oui en hexa, en ce moment 0X33 = 51°C
#!/usr/bin/perl -w
# Copyright (C) 2007 Michael Kurz michi.kurz (at) googlemail.com
# Copyright (C) 2007 Petr Tomasek tomasek (#) etf,cuni,cz
# Copyright (C) 2007 Carlos Corbacho cathectic (at) gmail.com
#
# Version 0.6.1 (2007-11-08)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require 5.004;
use strict;
use Fcntl;
use POSIX;
use File::Basename;
sub initialize_ioports
{
sysopen (IOPORTS, "/dev/port", O_RDWR)
or die "/dev/port: $!
";
binmode IOPORTS;
}
sub close_ioports
{
close (IOPORTS)
or print "Warning: $!
";
}
sub inb
{
my ($res,$nrchars);
sysseek IOPORTS, $_[0], 0 or return -1;
$nrchars = sysread IOPORTS, $res, 1;
return -1 if not defined $nrchars or $nrchars != 1;
$res = unpack "C",$res ;
return $res;
}
# $_[0]: value to write
# $_[1]: port to write
# Returns: -1 on failure, 0 on success.
sub outb
{
if ($_[0] > 0xff)
{
my ($package, $filename, $line, $sub) = caller(1);
print "
*** Called outb with value=$_[1] from line $line
",
"*** (in $sub). PLEASE REPORT!
",
"*** Terminating.
";
exit(-1);
}
my $towrite = pack "C", $_[0];
sysseek IOPORTS, $_[1], 0 or return -1;
my $nrchars = syswrite IOPORTS, $towrite, 1;
return -1 if not defined $nrchars or $nrchars != 1;
return 0;
}
sub wait_write
{
my $i = 0;
while ((inb($_[0]) & 0x02) && ($i < 10000)) {
sleep(0.01);
$i++;
}
return -($i == 10000);
}
sub wait_read
{
my $i = 0;
while (!(inb($_[0]) & 0x01) && ($i < 10000)) {
sleep(0.01);
$i++;
}
return -($i == 10000);
}
sub wait_write_ec
{
wait_write(0x66);
}
sub wait_read_ec
{
wait_read(0x66);
}
sub send_ec
{
if (!wait_write_ec()) { outb($_[0], 0x66); }
if (!wait_write_ec()) { outb($_[1], 0x62); }
}
sub write_ec
{
if (!wait_write_ec()) { outb(0x81, 0x66 ); }
if (!wait_write_ec()) { outb($_[0], 0x62); }
if (!wait_write_ec()) { outb($_[1], 0x62); }
}
sub read_ec
{
if (!wait_write_ec()) { outb(0x80, 0x66 ); }
if (!wait_write_ec()) { outb($_[0], 0x62); }
if (!wait_read_ec()) { inb(0x62); }
}
sub write_kc
{
if (!wait_write(0x64)) { outb($_[0], 0x64); }
if (!wait_write(0x64)) { outb($_[1], 0x60); }
}
sub print_regs
{
initialize_ioports();
my @arr = ("00","10","20","30","40","50","60","70","80","90","A0","B0","C0","D0","E0","F0", "");
my $i = 0;
my $t = 0;
print "
00 01 02 03 04 05 06 07 | 08 09 0A 0B 0C 0D 0E 0F
";
print " __ __ __ __ __ __ __ __ | __ __ __ __ __ __ __ __
";
print "00 | ";
for ($i = 0; $i < 256; $i++)
{
$t = read_ec($i);
print $t;
print " ";
if ((($i + 1) % 8) == 0){
if ((($i + 1) % 16) == 0) {
if ($i != 255) { print "
$arr[(($i-(($i + 1) % 16)) / 16) + 1] | "; }
} else {
print "| ";
}
}
}
print "
";
close_ioports();
}
sub write_temp
{
initialize_ioports();
write_ec($_[0],$_[1]);
close_ioports();
}
sub testnum
{
my $i;
for ($i = 0; $i<256;$i++) {
if ($_[0] eq "$i") { return 1 };
}
return 0;
}
my $ii;
if (!$ARGV[0]){
print "wrong arguments!
";
print "usage:
";
print "'acer_ec regs' dumps all ec registers
";
print "'acer_ec ledon' switch on 'mail LED' (WMID)
";
print "'acer_ec ledoff' switch off 'mail LED' (WMID)
";
print "'acer_ec getled' get 'mail LED' status (WMID)
";
print "'acer_ec getled2' get 'mail LED' status(AMW0)
";
print "'acer_ec getwireless' get 'wireless' status (AMW0)
";
print "'acer_ec gettouch' is the touchpad disabled?
";
print "'acer_ec setfanthresh <temp>' set temperature threshhold to <temp>, DANGEROUS!
";
print "'acer_ec getfanthresh' get temperature threshhold
";
print "'acer_ec <temp-number> <temperature>' for setting a temperature
";
print "where <temp-number> is from 0-7, and <temperture> is from 0-255
";
print "'acer_ec ?= <reg>' Query register's value
";
print "'acer_ec := <reg> <val>' Set register's value
";
print "'acer_ec +f <reg> <val>' Or register's value with val (to set flags)
";
print "'acer_ec -f <reg> <val>' And register's value with ~val (to clear flags)
";
print "'forcekc' Try all possible values on writeable RAM of keyboard controller
";
print "'kcw <cmd> <val>' Write a command and a value to the keyboard controller
";
} elsif ($ARGV[0] eq "regs") {
print_regs();
} elsif ($ARGV[0] eq "getled") {
# TM2490 only (WMID)
initialize_ioports();
if (read_ec(0x9f)&0x01) {
print "Mail LED on
";
} else {
print "Mail LED off
"; }
close_ioports();
} elsif ($ARGV[0] eq "getled2") {
# Aspire 5020 only (AMW0)
initialize_ioports();
if (read_ec(0x0A)&0x80) {
print "Mail LED on
";
} else {
print "Mail LED off
"; }
close_ioports();
} elsif ($ARGV[0] eq "getwireless") {
# Aspire 5020 only (AMW0)
initialize_ioports();
if (read_ec(0x0A)&0x4) {
print "Wireless on
";
} else {
print "Wireless off
"; }
close_ioports();
} elsif ($ARGV[0] eq "gettouch") {
# TM2490 only - needs testing
initialize_ioports();
if (read_ec(0x9e)&0x08) {
print "touchpad disabled
";
} else {
print "touchpad enabled
"; }
close_ioports();
} elsif ($ARGV[0] eq "?=") {
initialize_ioports();
my $r = hex($ARGV[1]);
printf("REG[0x%02x] == 0x%02x
", $r, read_ec($r));
close_ioports();
} elsif ($ARGV[0] eq ":=") {
initialize_ioports();
my $r = hex($ARGV[1]);
my $f = hex($ARGV[2]);
my $val = read_ec($r);
printf("REG[0x%02x] == 0x%02x
", $r, $val);
printf("REG[0x%02x] := 0x%02x
", $r, $f);
write_ec( $r, $f);
printf("REG[0x%02x] == 0x%02x
", $r, read_ec($r));
close_ioports();
} elsif ($ARGV[0] eq "+f") {
initialize_ioports();
my $r = hex($ARGV[1]);
my $f = hex($ARGV[2]);
my $val = read_ec($r);
printf("REG[0x%02x] == 0x%02x
", $r, $val);
printf("REG[0x%02x] := 0x%02x
", $r, $val | $f);
write_ec( $r, $val | $f);
printf("REG[0x%02x] == 0x%02x
", $r, read_ec($r));
close_ioports();
} elsif ($ARGV[0] eq "-f") {
initialize_ioports();
my $r = hex($ARGV[1]);
my $f = hex($ARGV[2]);
my $val = read_ec($r);
printf("REG[0x%02x] == 0x%02x
", $r, $val);
printf("REG[0x%02x] := 0x%02x
", $r, $val & ~$f);
write_ec( $r, $val & ~$f);
printf("REG[0x%02x] == 0x%02x
", $r, read_ec($r));
close_ioports();
} elsif ($ARGV[0] eq "ledon") {
# TM2490 only - needs testing
initialize_ioports();
if (!wait_write(0x64)) { outb(0x59, 0x64); }
if (!wait_write(0x64)) { outb(0x92, 0x60); }
close_ioports();
} elsif ($ARGV[0] eq "ledoff") {
# TM2490 only - needs testing
initialize_ioports();
if (!wait_write(0x64)) { outb(0x59, 0x64); }
if (!wait_write(0x64)) { outb(0x93, 0x60); }
close_ioports();
} elsif ($ARGV[0] eq "getfanthresh") {
initialize_ioports();
$ii=read_ec(0xa9);
close_ioports();
print "Temperature threshhold: $ii (celsius)
";
} elsif (($ARGV[0] eq "setfanthresh") && testnum($ARGV[1])) {
write_temp(0xA9,$ARGV[1]);
} elsif ($ARGV[0] eq "setbright") {
# Aspire 5020 only (AMW0)
if ($ARGV[1] >= 0 && $ARGV[1] <= 15) {
write_temp(0x83, $ARGV[1]);
} else {
print "second argument must be a number between 0 and 15
";
}
} elsif ($ARGV[0] eq "forcekc") {
# Be smart - we only send the commands for writing to keyboard RAM
initialize_ioports();
my ($kbdata, $cont, $kbreg);
for ($kbreg = 0x40; $kbreg <= 0x5f; $kbreg++) {
for ($kbdata = 0; $kbdata < 256; $kbdata++) {
write_kc($kbreg, $kbdata);
print sprintf("%0#4x", $kbreg), ", ", sprintf("%0#4x", $kbdata), "
";
print "Continue? y/n: ";
$cont = <STDIN>;
if ($cont eq "n") {
last;
}
}
}
close_ioports();
} elsif ($ARGV[0] eq "kcw") {
initialize_ioports();
write_kc($ARGV[1], $ARGV[2]);
close_ioports();
} else {
print "wrong arguments!
";
}
#!/bin/bash
#
# acerfand - Rudimentary automatic fan control for noisy Acer Aspire One models
#
# Author Rachel Greenham
#
# version 0.01
LOGGER=$(which logger)
if [ ! -x $LOGGER ] ; then
LOGGER="/usr/bin/logger"
fi
if [ ! -x $LOGGER ] ; then
echo "Warning, logger can't be found. Will log to stdout"
unset LOGGER
fi
LOGLEVEL="info"
log() {
if [ ! -z "$LOGGER" ] ; then
$LOGGER -p daemon.$LOGLEVEL -t acerfand "$@"
else
echo "$@"
fi
}
info() {
LOGLEVEL="info"
log "$@"
}
notice() {
LOGLEVEL="notice"
# log "$@"
}
err() {
LOGLEVEL="err"
log "$@"
}
if pgrep acerfand | grep -v $$ > /dev/null; then
info "acerfand already running"
exit 0
fi
ME=$(readlink -f $0)
ACEREC=$(which acer_ec.pl)
if [ -z $ACEREC ] ; then
ACEREC=$(dirname $ME)/acer_ec.pl
fi
if [ ! -r $ACEREC ] ; then
err "acer_ec.pl can't be found"
exit 1
fi
INTERVAL=5
FANOFF=60
FANAUTO=70
if [ -r "/etc/acerfand.conf" ] ; then
source "/etc/acerfand.conf"
fi
R_FAN=55
R_TEMP=58
FAN_CMD_OFF=af
FAN_CMD_AUTO=00
FAN_STATE_UNRECOGNIZED=0
FAN_STATE_AUTO=1
FAN_STATE_OFF=2
FAN_STATE_NAMES=("Unrecognized" "Auto" "Off")
FAN_STATE_CMDS=("$FAN_CMD_OFF" "$FAN_CMD_AUTO" "$FAN_CMD_OFF")
acer_ec() {
perl $ACEREC $@
}
getTemp() {
TEMP=$[$(acer_ec ?= $R_TEMP | cut -f 3 -d' ')]
notice "temp: $TEMP"
}
getRawFanState() {
RAW_FAN_STATE=$(acer_ec ?= $R_FAN | cut -f 3 -d' ')
}
getFanState() {
FAN_STATE=$FAN_STATE_UNRECOGNIZED
getRawFanState
if [ "$RAW_FAN_STATE" == "0xaf" ]; then
FAN_STATE=$FAN_STATE_OFF
else
let A="$RAW_FAN_STATE & 0x10" || true
if [ "$A == 0" ] ; then
# ASSUMPTION: All values with nybble 1==0 denote auto
FAN_STATE=$FAN_STATE_AUTO
fi
fi
notice "read fan state ${FAN_STATE_NAMES[$FAN_STATE]}"
}
setFan() {
info "Set fan ${FAN_STATE_NAMES[$1]}"
acer_ec := $R_FAN ${FAN_STATE_CMDS[$1]} > /dev/null
}
govern() {
trap "info exiting;setFan $FAN_STATE_AUTO; exit" INT TERM EXIT
info "Starting to govern acer fan speed. Interval: $INTERVAL, fan-off: $FANOFF, fan-auto: $FANAUTO"
while true; do
getTemp
getFanState
case "$FAN_STATE" in
$FAN_STATE_AUTO)
if [ "$TEMP" -le "$FANOFF" ] ; then
setFan $FAN_STATE_OFF
fi
;;
$FAN_STATE_OFF)
if [ "$TEMP" -ge "$FANAUTO" ] ; then
setFan $FAN_STATE_AUTO
fi
;;
*)
# weird state. Let's turn it off,
# then decide next time around
setFan $FAN_STATE_OFF
;;
esac
sleep $INTERVAL
done
}
set -e
govern &
Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 7 invités
.: Nous contacter :: Flux RSS :: Données personnelles :. |