2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-08-31 06:15:15 +00:00

Move the eeprom decoding scripts to the i2c-tools package.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4489 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2007-06-27 10:10:34 +00:00
parent 4133206de9
commit d5cc9ae889
8 changed files with 2 additions and 2547 deletions

View File

@@ -110,8 +110,8 @@ MACHINE := $(shell uname -m)
# The subdirectories we need to build things in
SRCDIRS :=
SRCDIRS += kernel/include
SRCDIRS += lib prog/detect prog/dump prog/eeprom prog/pwm \
prog/sensors prog/xeon ${PROG_EXTRA:%=prog/%} etc
SRCDIRS += lib prog/detect prog/dump prog/pwm \
prog/sensors ${PROG_EXTRA:%=prog/%} etc
SRCDIRS += lib/test
# Some often-used commands with default options

View File

@@ -1,35 +0,0 @@
# Module.mk
# Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
#
# 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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA.
MODULE_DIR := prog/eeprom
PROGEEPROMDIR := $(MODULE_DIR)
PROGEEPROMTARGETS := $(MODULE_DIR)/ddcmon \
$(MODULE_DIR)/decode-dimms.pl \
$(MODULE_DIR)/decode-edid.pl \
$(MODULE_DIR)/decode-vaio.pl
REMOVEEEPROMBIN := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(BINDIR)/%,$(PROGEEPROMTARGETS))
install-prog-eeprom: $(PROGEEPROMTARGETS)
$(MKDIR) $(DESTDIR)$(BINDIR)
$(INSTALL) -m 755 $(PROGEEPROMTARGETS) $(DESTDIR)$(BINDIR)
user_install :: install-prog-eeprom
user_uninstall::
$(RM) $(REMOVEEEPROMBIN)

View File

@@ -1,566 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2004-2005 Jean Delvare <khali@linux-fr.org>
#
# Parts inspired from decode-edid.pl.
# Copyright (C) 2003-2004 Jean Delvare <khali@linux-fr.org>
#
# Parts inspired from the ddcmon driver and sensors' print_ddcmon function.
# Copyright (C) 1998-2004 The LM Sensors Group
#
# Parts inspired from the fbmon driver (Linux 2.6.10).
# Copyright (C) 2002 James Simmons <jsimmons@users.sf.net>
#
# 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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Version 1.0 2005-01-04 Jean Delvare <khali@linux-fr.org>
#
# This script is a replacement for the now deprecated ddcmon kernel driver.
# Instead of having a dedicated driver, it is better to reuse the standard
# eeprom driver and implement the EDID-specific code in user-space.
#
# EDID (Extended Display Identification Data) is a VESA standard which
# allows storing (on manufacturer's side) and retrieving (on user's side)
# of configuration information about displays, such as manufacturer,
# serial number, physical dimensions and allowed horizontal and vertical
# refresh rates.
#
# Syntax: ddcmon [bus [address]]
# Address can be given in decimal or hexadecimal (with a 0x prefix).
# If no address is given, default is 0x50.
# Bus number must be given in decimal. If no bus number is given,
# try them all.
use strict;
use Fcntl qw(:DEFAULT :seek);
use vars qw(@standard_scales);
@standard_scales = ([1, 1], [3, 4], [4, 5], [16, 9]);
# Make sure the eeprom module is loaded.
# For non-modular kernels, we can't help.
if (-r '/proc/modules')
{
my $found = 0;
open(MODULES, '/proc/modules');
while (!$found && defined ($_ = <MODULES>))
{
$found++ if m/^eeprom\s+/;
}
close(MODULES);
unless ($found)
{
print STDERR
"This script required the eeprom module to be loaded.\n";
exit 1;
}
}
# Only used for sysfs
sub rawread
{
my $filename = shift;
my $length = shift;
my $offset = shift || 0;
my $bytes = '';
sysopen(FH, $filename, O_RDONLY)
or die "Can't open $filename";
if ($offset)
{
sysseek(FH, $offset, SEEK_SET)
or die "Can't seek in $filename";
}
$offset = 0;
while ($length)
{
my $r = sysread(FH, $bytes, $length, $offset);
die "Can't read $filename"
unless defined($r);
die "Unexpected EOF in $filename"
unless $r;
$offset += $r;
$length -= $r;
}
close(FH);
return $bytes;
}
sub get_edid_sysfs
{
my ($bus, $addr) = @_;
my @bytes = unpack("C*", rawread("/sys/bus/i2c/devices/$bus-00$addr/eeprom", 128));
return \@bytes;
}
sub get_edid_procfs
{
my ($bus, $addr) = @_;
my @bytes;
for (my $i = 0 ; $i < 0x80; $i += 0x10)
{
my $filename = sprintf("/proc/sys/dev/sensors/eeprom-i2c-\%s-\%s/\%02x",
$bus, $addr, $i);
open(EEDATA, $filename)
or die "Can't read $filename";
push @bytes, split(/\s+/, <EEDATA>);
close(EEDATA);
}
return \@bytes;
}
sub print_line
{
my $label = shift;
my $pattern = shift;
printf("\%-24s$pattern\n", $label.':', @_);
}
sub extract_byte
{
my ($bytes, $offset) = @_;
return $bytes->[$offset];
}
sub extract_word
{
my ($bytes, $offset) = @_;
return ($bytes->[$offset]
| ($bytes->[$offset+1] << 8));
}
sub extract_manufacturer
{
my ($bytes, $offset) = @_;
my $i = ($bytes->[$offset+1] | ($bytes->[$offset] << 8));
return sprintf('%c%c%c',
(($i >> 10) & 0x1f) + ord('A') - 1,
(($i >> 5) & 0x1f) + ord('A') - 1,
($i & 0x1f) + ord('A') - 1);
}
sub extract_sesquiword
{
my ($bytes, $offset) = @_;
return ($bytes->[$offset]
| ($bytes->[$offset+1] << 8)
| ($bytes->[$offset+2] << 16));
}
sub extract_dword
{
my ($bytes, $offset) = @_;
return ($bytes->[$offset]
| ($bytes->[$offset+1] << 8)
| ($bytes->[$offset+2] << 16)
| ($bytes->[$offset+3] << 24));
}
sub extract_display_input
{
my ($bytes, $offset) = @_;
my @voltage = ('0.700V/0.300V', '0.714V/0.286V',
'1.000V/0.400V', '0.700V/0.000V');
return 'Digital'
if ($bytes->[$offset] & 0x80);
return 'Analog ('.$voltage[($bytes->[$offset] & 0x60) >> 5].')';
}
sub extract_dpms
{
my ($bytes, $offset) = @_;
my @supported;
push @supported, 'Active Off' if ($bytes->[$offset] & 0x20);
push @supported, 'Suspend' if ($bytes->[$offset] & 0x40);
push @supported, 'Standby' if ($bytes->[$offset] & 0x80);
return join(', ', @supported)
if (@supported);
return 'None supported';
}
sub extract_color_mode
{
my ($bytes, $offset) = @_;
my @mode = ('Monochrome', 'RGB Multicolor', 'Non-RGB Multicolor');
return $mode[($bytes->[$offset] >> 3) & 0x03];
}
sub good_signature
{
my $bytes = shift;
return $bytes->[0] == 0x00
&& $bytes->[1] == 0xff
&& $bytes->[2] == 0xff
&& $bytes->[3] == 0xff
&& $bytes->[4] == 0xff
&& $bytes->[5] == 0xff
&& $bytes->[6] == 0xff
&& $bytes->[7] == 0x00;
}
sub verify_checksum
{
my $bytes = shift;
my $cs;
for (my $i = 0, $cs = 0; $i < 0x80; $i++)
{
$cs += $bytes->[$i];
}
return (($cs & 0xff) == 0 ? 'OK' : 'Not OK');
}
sub add_timing
{
my ($timings, $new) = @_;
my $mode = sprintf('%ux%u@%u%s', $new->[0], $new->[1],
$new->[2], defined ($new->[3]) &&
$new->[3] eq 'interlaced' ? 'i' : '');
$timings->{$mode} = $new;
}
sub add_standard_timing
{
my ($timings, $byte0, $byte1) = @_;
# Unused slot
return if ($byte0 == $byte1)
&& ($byte0 == 0x01 || $byte0 == 0x00 || $byte0 == 0x20);
my $width = ($byte0 + 31) * 8;
my $height = $width * $standard_scales[$byte1 >> 6]->[0]
/ $standard_scales[$byte1 >> 6]->[1];
my $refresh = 60 + ($byte1 & 0x3f);
add_timing($timings, [$width, $height, $refresh]);
}
sub sort_timings
{
# First order by width
return -1 if $a->[0] < $b->[0];
return 1 if $a->[0] > $b->[0];
# Second by height
return -1 if $a->[1] < $b->[1];
return 1 if $a->[1] > $b->[1];
# Third by frequency
# Interlaced modes count for half their frequency
my $freq_a = $a->[2];
my $freq_b = $b->[2];
$freq_a /= 2 if defined $a->[3] && $a->[3] eq 'interlaced';
$freq_b /= 2 if defined $b->[3] && $b->[3] eq 'interlaced';
return -1 if $freq_a < $freq_b;
return 1 if $freq_a > $freq_b;
return 0;
}
sub print_timings
{
my ($bytes, $timings) = @_;
# Established Timings
my @established =
(
[720, 400, 70],
[720, 400, 88],
[640, 480, 60],
[640, 480, 67],
[640, 480, 72],
[640, 480, 75],
[800, 600, 56],
[800, 600, 60],
[800, 600, 72],
[800, 600, 75],
[832, 624, 75],
[1024, 768, 87, 'interlaced'],
[1024, 768, 60],
[1024, 768, 70],
[1024, 768, 75],
[1280, 1024, 75],
undef, undef, undef,
[1152, 870, 75],
);
my $temp = extract_sesquiword($bytes, 0x23);
for (my $i = 0; $i < 24; $i++)
{
next unless defined($established[$i]);
add_timing($timings, $established[$i])
if ($temp & (1 << $i));
}
# Standard Timings
for (my $i = 0x26; $i < 0x36; $i += 2)
{
add_standard_timing($timings, $bytes->[$i], $bytes->[$i+1]);
}
foreach my $v (sort sort_timings values(%{$timings}))
{
print_line("Timing", '%ux%u @ %u Hz%s',
$v->[0], $v->[1], $v->[2],
defined($v->[3]) ? ' ('.$v->[3].')' : '');
}
}
sub extract_string
{
my ($bytes, $offset) = @_;
my $string = '';
for (my $i = 5; $i < 18; $i++)
{
last if $bytes->[$offset+$i] == 0x0a
|| $bytes->[$offset+$i] == 0x00;
$string .= chr($bytes->[$offset+$i])
if ($bytes->[$offset+$i] >= 32
&& $bytes->[$offset+$i] < 127);
}
$string =~ s/\s+$//;
return $string;
}
# Some blocks contain different information:
# 0x00, 0x00, 0x00, 0xfa: Additional standard timings block
# 0x00, 0x00, 0x00, 0xfc: Monitor block
# 0x00, 0x00, 0x00, 0xfd: Limits block
# 0x00, 0x00, 0x00, 0xfe: Ascii block
# 0x00, 0x00, 0x00, 0xff: Serial block
# Return a reference to a hash containing all information.
sub extract_detailed_timings
{
my ($bytes) = @_;
my %info = ('timings' => {});
for (my $offset = 0x36; $offset < 0x7e; $offset += 18)
{
if ($bytes->[$offset] == 0x00
&& $bytes->[$offset+1] == 0x00
&& $bytes->[$offset+2] == 0x00
&& $bytes->[$offset+4] == 0x00)
{
if ($bytes->[$offset+3] == 0xfa)
{
for (my $i = $offset + 5; $i < $offset + 17; $i += 2)
{
add_standard_timing($info{'timings'},
$bytes->[$i],
$bytes->[$i+1]);
}
}
elsif ($bytes->[$offset+3] == 0xfc)
{
$info{'monitor'} .= extract_string($bytes, $offset);
}
elsif ($bytes->[$offset+3] == 0xfd)
{
$info{'limits'}{'vsync_min'} = $bytes->[$offset+5];
$info{'limits'}{'vsync_max'} = $bytes->[$offset+6];
$info{'limits'}{'hsync_min'} = $bytes->[$offset+7];
$info{'limits'}{'hsync_max'} = $bytes->[$offset+8];
$info{'limits'}{'clock_max'} = $bytes->[$offset+9];
}
elsif ($bytes->[$offset+3] == 0xfe)
{
$info{'ascii'} .= extract_string($bytes, $offset);
}
elsif ($bytes->[$offset+3] == 0xff)
{
$info{'serial'} .= extract_string($bytes, $offset);
}
next;
}
# Detailed Timing
my $width = $bytes->[$offset+2] + (($bytes->[$offset+4] & 0xf0) << 4);
my $height = $bytes->[$offset+5] + (($bytes->[$offset+7] & 0xf0) << 4);
my $clock = extract_word($bytes, $offset) * 10000;
my $hblank = $bytes->[$offset+3] + (($bytes->[$offset+4] & 0x0f) << 8);
my $vblank = $bytes->[$offset+6] + (($bytes->[$offset+7] & 0x0f) << 8);
my $area = ($width + $hblank) * ($height + $vblank);
next unless $area; # Should not happen, but...
my $refresh = ($clock + $area / 2) / $area; # Proper rounding
add_timing($info{'timings'}, [$width, $height, $refresh]);
}
return \%info;
}
sub print_edid
{
my ($bus, $address) = @_;
my $bytes;
if (-r "/sys/bus/i2c/devices/$bus-00$address/eeprom")
{
$bytes = get_edid_sysfs($bus, $address);
}
elsif (-r "/proc/sys/dev/sensors/eeprom-i2c-$bus-$address/00")
{
$bytes = get_edid_procfs($bus, $address);
}
return 1 unless defined $bytes;
return 2 unless good_signature($bytes);
print_line('Checksum', '%s', verify_checksum($bytes));
my $edid_version = extract_byte($bytes, 0x12);
my $edid_revision = extract_byte($bytes, 0x13);
print_line('EDID Version', '%u.%u', $edid_version,
$edid_revision);
if ($edid_version > 1 || $edid_revision > 2)
{
$standard_scales[0][0] = 16;
$standard_scales[0][1] = 10;
}
else
{
$standard_scales[0][0] = 1;
$standard_scales[0][1] = 1;
}
my $info = extract_detailed_timings($bytes);
print_line('Manufacturer ID', '%s', extract_manufacturer($bytes, 0x08));
print_line('Model Number', '0x%04X', extract_word($bytes, 0x0A));
print_line('Model Name', '%s', $info->{'monitor'})
if defined $info->{'monitor'};
if ($info->{'serial'})
{
print_line('Serial Number', '%s', $info->{'serial'})
}
elsif ((my $temp = extract_dword($bytes, 0x0C)))
{
print_line('Serial Number', '%u', $temp)
}
print_line('Manufacture Time', '%u-W%02u',
1990 + extract_byte($bytes, 0x11),
extract_byte($bytes, 0x10));
print_line('Display Input', '%s', extract_display_input($bytes, 0x14));
print_line('Monitor Size (cm)', '%ux%u', extract_byte($bytes, 0x15),
extract_byte($bytes, 0x16));
print_line('Gamma Factor', '%.2f',
1 + extract_byte($bytes, 0x17) / 100.0);
print_line('DPMS Modes', '%s', extract_dpms($bytes, 0x18));
print_line('Color Mode', '%s', extract_color_mode($bytes, 0x18))
if (($bytes->[0x18] & 0x18) != 0x18);
print_line('Additional Info', '%s', $info->{'ascii'})
if $info->{'ascii'};
if (defined($info->{'limits'}))
{
print_line('Vertical Sync (Hz)', '%u-%u',
$info->{'limits'}{'vsync_min'},
$info->{'limits'}{'vsync_max'});
print_line('Horizontal Sync (kHz)', '%u-%u',
$info->{'limits'}{'hsync_min'},
$info->{'limits'}{'hsync_max'});
print_line('Max Pixel Clock (MHz)', '%u',
$info->{'limits'}{'clock_max'} * 10)
unless $info->{'limits'}{'clock_max'} == 0xff;
}
print_timings($bytes, $info->{'timings'});
print("\n");
return 0;
}
# Get the address. Default to 0x50 if not given.
my $address;
if (defined($ARGV[1]))
{
$address = $ARGV[1];
# Convert to decimal, whatever the value.
$address = oct $address if $address =~ m/^0/;
# Convert to an hexadecimal string.
$address = sprintf '%02x', $address;
}
else
{
$address = '50';
}
if (defined($ARGV[0]))
{
my $error = print_edid($ARGV[0], $address);
if ($error == 1)
{
print STDERR
"No EEPROM found at 0x$address on bus $ARGV[0].\n";
exit 1;
}
elsif ($error == 2)
{
print STDERR
"EEPROM found at 0x$address on bus $ARGV[0], but is not an EDID EEPROM.\n";
exit 1;
}
}
# If no bus is given, try them all.
else
{
my $total = 0;
for (my $i = 0; $i < 16; $i++)
{
$total++ unless print_edid($i, $address);
}
unless ($total)
{
print STDERR
"No EDID EEPROM found.\n";
exit 1;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,224 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2003-2006 Jean Delvare <khali@linux-fr.org>
#
# 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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Version 0.1 2003-07-17 Jean Delvare <khali@linux-fr.org>
# Version 0.2 2003-07-22 Jean Delvare <khali@linux-fr.org>
# Use print instead of syswrite.
# Version 0.3 2003-08-24 Jean Delvare <khali@linux-fr.org>
# Fix data block length (128 bytes instead of 256).
# Version 1.0 2004-02-08 Jean Delvare <khali@linux-fr.org>
# Added support for Linux 2.5/2.6 (i.e. sysfs).
# Version 1.1 2006-09-01 Jean Delvare <khali@linux-fr.org>
# Append /usr/sbin or /usr/local/sbin to $PATH if needed.
#
# EEPROM data decoding for EDID. EDID (Extended Display Identification
# Data) is a VESA standard which allows storing (on manufacturer's side)
# and retrieving (on user's side) of configuration information about
# displays, such as manufacturer, serial number, physical dimensions and
# allowed horizontal and vertical refresh rates.
#
# Using the LM Sensors modules and tools, you have two possibilities to
# make use of these data:
# 1* Use the ddcmon driver and run sensors.
# 2* Use the eeprom driver and run this script.
# Both solutions will return a different kind of information. The first
# method will report user-interesting information, such as the model number
# or the year of manufacturing. The second method will report video-card-
# interesting information, such as video modes and refresh rates.
#
# Note that this script does almost nothing by itself. It simply converts
# what it finds in /proc to binary data to feed the parse-edid program.
# The parse-edid program was written by John Fremlin and is available at
# the following address:
# http://john.fremlin.de/programs/linux/read-edid/
use strict;
use Fcntl qw(:DEFAULT :seek);
use vars qw($bus $address);
use constant PROCFS => 1;
use constant SYSFS => 2;
# parse-edid will typically be installed in /usr/sbin or /usr/local/sbin
# even though regular users can run it
$ENV{PATH} .= ':/usr/local/sbin'
if $ENV{PATH} !~ m,(^|:)/usr/local/sbin/?(:|$),
&& -x '/usr/local/sbin/parse-edid';
$ENV{PATH} .= ':/usr/sbin'
if $ENV{PATH} !~ m,(^|:)/usr/sbin/?(:|$),
&& -x '/usr/sbin/parse-edid';
sub edid_valid_procfs
{
my ($bus, $addr) = @_;
open EEDATA, "/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/00";
my $line = <EEDATA>;
close EEDATA;
return 1
if $line =~ m/^0 255 255 255 255 255 255 0 /;
return 0;
}
# Only used for sysfs
sub rawread
{
my ($filename, $length, $offset) = @_;
my $bytes = '';
sysopen(FH, $filename, O_RDONLY)
or die "Can't open $filename";
if ($offset)
{
sysseek(FH, $offset, SEEK_SET)
or die "Can't seek in $filename";
}
$offset = 0;
while ($length)
{
my $r = sysread(FH, $bytes, $length, $offset);
die "Can't read $filename"
unless defined($r);
die "Unexpected EOF in $filename"
unless $r;
$offset += $r;
$length -= $r;
}
close(FH);
return $bytes;
}
sub edid_valid_sysfs
{
my ($bus, $addr) = @_;
my $bytes = rawread("/sys/bus/i2c/devices/$bus-00$addr/eeprom", 8, 0);
return 1
if $bytes eq "\x00\xFF\xFF\xFF\xFF\xFF\xFF\x00";
return 0;
}
sub bus_detect
{
my $max = shift;
for (my $i=0; $i<$max; $i++)
{
if (-r "/proc/sys/dev/sensors/eeprom-i2c-$i-50/00")
{
if (edid_valid_procfs($i, '50'))
{
print STDERR
"decode-edid: using bus $i (autodetected)\n";
return $i;
}
}
elsif (-r "/sys/bus/i2c/devices/$i-0050/eeprom")
{
if (edid_valid_sysfs($i, '50'))
{
print STDERR
"decode-edid: using bus $i (autodetected)\n";
return $i;
}
}
}
return; # default
}
sub edid_decode
{
my ($bus, $addr, $mode) = @_;
# Make sure it is an EDID EEPROM.
unless (($mode == PROCFS && edid_valid_procfs ($bus, $addr))
|| ($mode == SYSFS && edid_valid_sysfs ($bus, $addr)))
{
print STDERR
"decode-edid: not an EDID EEPROM at $bus-$addr\n";
return;
}
$SIG{__WARN__} = sub { };
open PIPE, "| parse-edid"
or die "Can't open parse-edid. Please install read-edid.\n";
delete $SIG{__WARN__};
binmode PIPE;
if ($mode == PROCFS)
{
for (my $i=0; $i<=0x70; $i+=0x10)
{
my $file = sprintf '%02x', $i;
my $output = '';
open EEDATA, "/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/$file"
or die "Can't read /proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/$file";
while(<EEDATA>)
{
foreach my $item (split)
{
$output .= pack "C", $item;
}
}
close EEDATA;
print PIPE $output;
}
}
elsif ($mode == SYSFS)
{
print PIPE rawread("/sys/bus/i2c/devices/$bus-00$address/eeprom", 128, 0);
}
close PIPE;
}
# Get the address. Default to 0x50 if not given.
$address = $ARGV[1] || 0x50;
# Convert to decimal, whatever the value.
$address = oct $address if $address =~ m/^0/;
# Convert to an hexadecimal string.
$address = sprintf '%02x', $address;
# Get the bus. Try to autodetect if not given.
$bus = $ARGV[0] if defined $ARGV[0];
$bus = bus_detect(8) unless defined $bus;
if(defined $bus)
{
print STDERR
"decode-edid: decode-edid version 1.1\n";
if (-r "/proc/sys/dev/sensors/eeprom-i2c-$bus-$address")
{
edid_decode ($bus, $address, PROCFS);
exit 0;
}
elsif (-r "/sys/bus/i2c/devices/$bus-00$address")
{
edid_decode ($bus, $address, SYSFS);
exit 0;
}
}
print STDERR
"EDID EEPROM not found. Please make sure that the eeprom module is loaded.\n";
print STDERR
"Maybe your EDID EEPROM is on another bus. Try \"decode-edid ".($bus+1)."\".\n"
if defined $bus;

View File

@@ -1,240 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2002-2006 Jean Delvare <khali@linux-fr.org>
#
# 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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Version 0.1 2002-02-06 Jean Delvare <khali@linux-fr.org>
# Version 0.2 2002-02-16 Jean Delvare <khali@linux-fr.org>
# Fixed to work with the new, simplified /proc interface names of the eeprom
# driver (lm_sensors 2.6.3 and greater).
# Shifted data display by 4 columns left.
# Version 0.3 2002-02-17 Jean Delvare <khali@linux-fr.org>
# Added UUID field at 0x10 (added decode_uuid).
# Merged decode_string and decode_string32.
# Added unknown field at 0x20.
# Moved header and footer to BEGIN and END, respectively.
# Reformated history to match those of the other decode scripts.
# Deleted decode_char (made useless by decode_string).
# Reordered field display, changed some labels.
# Added old /proc interface check.
# Version 1.0 2002-11-15 Jean Delvare <khali@linux-fr.org>
# Gave the label "OEM Data" to the field at 0x20.
# Gave the label "Timestamp" to the field at 0xE0.
# Renamed "Model Number" to "Model Name".
# Added some documentation.
# Version 1.1 2004-01-17 Jean Delvare <khali@linux-fr.org>
# Added support for Linux 2.5/2.6 (i.e. sysfs).
# Version 1.2 2004-11-28 Jean Delvare <khali@linux-fr.org>
# Support bus number 0 to 4 instead of only 0.
# Version 1.3 2005-01-18 Jean Delvare <khali@linux-fr.org>
# Revision might be a Service Tag.
# Version 1.4 2006-09-20 Jean Delvare <khali@linux-fr.org>
# Detect and skip false positives (e.g. EDID EEPROMs).
#
# EEPROM data decoding for Sony Vaio laptops.
#
# Two assumptions: lm_sensors-2.6.3 or greater installed,
# and Perl is at /usr/bin/perl
#
# Please note that this is a guess-only work. Sony support refused to help
# me, so if someone can provide information, please contact me.
# My knowledge is summarized on this page:
# http://khali.linux-fr.org/vaio/eeprom.html
#
# It seems that if present, the EEPROM is always at 0x57.
#
# Models tested so far:
# PCG-F403 : No EEPROM
# PCG-F707 : No EEPROM
# PCG-GR114EK : OK
# PCG-GR114SK : OK
# PCG-GR214EP : OK
# PCG-GRX316G : OK
# PCG-GRX570 : OK
# PCG-GRX600K : OK
# PCG-U1 : OK
# PCG-Z600LEK : No EEPROM
# PCG-Z600NE : No EEPROM
# VGN-S260 : OK
# VGN-S4M/S : OK
# Any feedback appreciated anyway.
#
# Thanks to Werner Heuser, Carsten Blume, Christian Gennerat, Joe Wreschnig,
# Xavier Roche, Sebastien Lefevre, Lars Heer, Steve Dobson, Kent Hunt and
# others for their precious help.
use strict;
use Fcntl qw(:DEFAULT :seek);
use vars qw($sysfs $found);
sub print_item
{
my ($label,$value) = @_;
printf("\%16s : \%s\n",$label,$value);
}
# Abstract reads so that other functions don't have to care wether
# we need to use procfs or sysfs
sub read_eeprom_bytes
{
my ($bus, $addr, $offset, $length) = @_;
my $filename;
if ($sysfs)
{
$filename = "/sys/bus/i2c/devices/$bus-00$addr/eeprom";
sysopen(FH, $filename, O_RDONLY)
or die "Can't open $filename";
sysseek(FH, $offset, SEEK_SET)
or die "Can't seek in $filename";
my ($r, $bytes);
$bytes = '';
$offset = 0;
while($length)
{
$r = sysread(FH, $bytes, $length, $offset);
die "Can't read $filename"
unless defined($r);
die "Unexpected EOF in $filename"
unless $r;
$offset += $r;
$length -= $r;
}
close(FH);
return $bytes;
}
else
{
my $base = $offset & 0xf0;
$offset -= $base;
my $values = '';
my $remains = $length + $offset;
# Get all lines in a single string
while ($remains > 0)
{
$filename = "/proc/sys/dev/sensors/eeprom-i2c-$bus-$addr/"
. sprintf('%02x', $base);
open(FH, $filename)
or die "Can't open $filename";
$values .= <FH>;
close(FH);
$remains -= 16;
$base += 16;
}
# Store the useful part in an array
my @bytes = split(/[ \n]/, $values);
@bytes = @bytes[$offset..$offset+$length-1];
# Back to a binary string
return pack('C*', @bytes);
}
}
sub decode_string
{
my ($bus, $addr, $offset, $length) = @_;
my $string = read_eeprom_bytes($bus, $addr, $offset, $length);
$string =~ s/\x00.*$//;
return($string);
}
sub decode_uuid
{
my ($bus,$addr,$base) = @_;
my @bytes = unpack('C16', read_eeprom_bytes($bus, $addr, $base, 16));
my $string='';
for(my $i=0;$i<16;$i++)
{
$string.=sprintf('%02x',shift(@bytes));
if(($i==3)||($i==5)||($i==7)||($i==9))
{
$string.='-';
}
}
return($string);
}
sub vaio_decode
{
my ($bus,$addr) = @_;
my $name = decode_string($bus, $addr, 128, 32);
# Simple heuristic to skip false positives
return 0 unless $name =~ m/^[A-Z-]{4}/;
print_item('Machine Name', $name);
print_item('Serial Number', decode_string($bus, $addr, 192, 32));
print_item('UUID', decode_uuid($bus, $addr, 16));
my $revision = decode_string($bus, $addr, 160, 10);
print_item(length($revision) > 2 ? 'Service Tag' : 'Revision',
$revision);
print_item('Model Name', 'PCG-'.decode_string($bus, $addr, 170, 4));
print_item('OEM Data', decode_string($bus, $addr, 32, 16));
print_item('Timestamp', decode_string($bus, $addr, 224, 32));
return 1;
}
BEGIN
{
print("Sony Vaio EEPROM Decoder\n");
print("Copyright (C) 2002-2006 Jean Delvare\n");
print("Version 1.4\n\n");
}
END
{
print("\n");
}
for (my $i = 0, $found=0; $i <= 4 && !$found; $i++)
{
if (-r "/sys/bus/i2c/devices/$i-0057/eeprom")
{
$sysfs = 1;
$found += vaio_decode($i, '57');
}
elsif (-r "/proc/sys/dev/sensors/eeprom-i2c-$i-57")
{
if (-r "/proc/sys/dev/sensors/eeprom-i2c-$i-57/data0-15")
{
print("Deprecated old interface found. Please upgrade to lm_sensors 2.6.3 or greater.");
exit;
}
else
{
$sysfs = 0;
$found += vaio_decode($i, '57');
}
}
}
if (!$found)
{
print("Vaio EEPROM not found. Please make sure that the eeprom module is loaded.\n");
print("If you believe this is an error, please contact me <khali\@linux-fr.org>\n");
print("so that we may see how to fix the problem.\n");
}

View File

@@ -1,32 +0,0 @@
# Module.mk
# Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
#
# 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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA.
MODULE_DIR := prog/xeon
PROGXEONDIR := $(MODULE_DIR)
PROGXEONTARGETS := $(MODULE_DIR)/decode-xeon.pl
REMOVEXEONBIN := $(patsubst $(MODULE_DIR)/%,$(DESTDIR)$(BINDIR)/%,$(PROGXEONTARGETS))
install-prog-xeon: $(PROGXEONTARGETS)
$(MKDIR) $(DESTDIR)$(BINDIR)
$(INSTALL) -m 755 $(PROGXEONTARGETS) $(DESTDIR)$(BINDIR)
user_install :: install-prog-xeon
user_uninstall::
$(RM) $(REMOVEXEONBIN)

View File

@@ -1,197 +0,0 @@
#!/usr/bin/perl
#
# Copyright 1998, 1999 Philip Edelbrock <phil@netroedge.com>
# and Mark Studebaker <mdsxyz123@yahoo.com>
#
# Version 0.1
#
#
# ID ROM data decoding for Xeon processors.
# Each Xeon processor contains two memories:
# - A scratch EEPROM at an even location 0x50, 52, 54, or 56;
# - An ID ROM at an odd location 0x51, 53, 55, or 57.
# This program decodes the ID ROM's only.
# The scratch EEPROMs have no prescribed format.
# If the output of this program makes no sense for a particular device,
# it is probably decoding a DIMM Serial Presence Detect (SPD) EEPROM.
# See ../eeprom/decode-dimms.pl to decode those devices.
#
#
# Two assumptions: lm_sensors-2.3.1 or greater installed,
# and Perl is at /usr/bin/perl
#
# To do:
# Calculate and check checksums for each section
# Decode flags in byte 0x7B (cartridge feature flags)
#
# References:
# "Pentium II Xeon Processor at 400 and 450 MHz" Data Sheet
# Intel
#
#
#
print "Xeon Processor Information ROM Decoder\n";
print "Written by Philip Edelbrock and Mark Studebaker. Copyright 1998, 1999.\n";
print "Version 2.6.3\n\n";
$dimm_count=0;
$_=`ls /proc/sys/dev/sensors/`;
@dimm_list=split();
for $i ( 0 .. $#dimm_list ) {
$_=$dimm_list[$i];
if ((/^eeprom-/) && (/-51$/ || /-53$/ || /-55$/ || /-57$/)) {
$dimm_count=$dimm_count + 1;
print "\nDecoding Xeon ROM: /proc/sys/dev/sensors/$dimm_list[$i]\n";
if (/^[^-]+-[^-]+-[^-]+-([^-]+)$/) {
$dimm_num=($1 - 49) / 2;
print "Guessing Xeon is number $dimm_num\n";
}
# Decode first 16 bytes
print "\t\t----=== Xeon ROM Header Data ===----\n";
$_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/00`;
@bytes=split(" ");
printf("\tData Format Revision: \t\t\t\t0x%.4X\n", $bytes[0]);
print "\tTotal number of bytes in EEPROM:\t\t";
print ($bytes[1] << 4) + $bytes[2];
print "\n";
printf("\tProcessor Data Address:\t\t\t\t0x%.2X\n", $bytes[3]);
printf("\tProcessor Core Data Address:\t\t\t0x%.2X\n", $bytes[4]);
printf("\tL2 Cache Data Address:\t\t\t\t0x%.2X\n", $bytes[5]);
printf("\tSEC Cartridge Data Address:\t\t\t0x%.2X\n", $bytes[6]);
printf("\tPart Number Data Address:\t\t\t0x%.2X\n", $bytes[7]);
printf("\tThermal Reference Data Address:\t\t\t0x%.2X\n", $bytes[8]);
printf("\tFeature Data Address:\t\t\t\t0x%.2X\n", $bytes[9]);
printf("\tOther Data Address:\t\t\t\t0x%.2X\n", $bytes[10]);
print "\t\t----=== Xeon ROM Processor Data ===----\n";
# Decode next 16 bytes
$_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/10`;
@bbytes=split(" ");
print "\tS-spec/QDF Number:\t\t\t\t\"";
print pack("cccccc",$bytes[14],$bytes[15],$bbytes[0],
$bbytes[1],$bbytes[2],$bbytes[3]);
print "\"\n";
$tmp = $bbytes[4] & 0xC0 >> 6;
printf("\tSample / Production:\t\t\t\t0x%.2X", $tmp);
if($tmp) {
print " (Production)\n";
} else {
print " (Sample)\n";
}
print "\t\t----=== Xeon ROM Core Data ===----\n";
printf("\tProcessor Core Type:\t\t\t\t0x%.2X\n",
($bbytes[6] & 0xC0) >> 6);
printf("\tProcessor Core Family:\t\t\t\t0x%.2X\n",
($bbytes[6] & 0x3C) >> 2);
printf("\tProcessor Core Model:\t\t\t\t0x%.2X\n",
(($bbytes[6] & 0x03) << 2) + (($bbytes[7] & 0xC0) >> 6));
printf("\tProcessor Core Stepping:\t\t\t0x%.2X\n",
($bbytes[7] & 0x30) >> 4);
print "\tMaximum Core Frequency (Mhz):\t\t\t";
print ($bbytes[13] << 4) + $bbytes[14];
print "\n";
# Decode next 16 bytes (32-47)
$_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/20`;
@bytes=split(" ");
print "\tCore Voltage ID (mV):\t\t\t\t";
print ($bbytes[15] << 4) + $bytes[0];
print "\n";
print "\tCore Voltage Tolerance, High (mV):\t\t";
print $bytes[1];
print "\n";
print "\tCore Voltage Tolerance, Low (mV):\t\t";
print $bytes[2];
print "\n";
print "\t\t----=== Xeon ROM L2 Cache Data ===----\n";
print "\tL2 Cache Size (KB):\t\t\t\t";
print ($bytes[9] << 4) + $bytes[10];
print "\n";
printf("\tNumber of SRAM Components:\t\t\t%d\n",
($bytes[11] & 0xF0) >> 4);
print "\tL2 Cache Voltage ID (mV):\t\t\t";
print ($bytes[12] << 4) + $bytes[13];
print "\n";
print "\tL2 Cache Voltage Tolerance, High (mV):\t\t";
print $bytes[14];
print "\n";
print "\tL2 Cache Voltage Tolerance, Low (mV):\t\t";
print $bytes[15];
print "\n";
# Decode next 16 bytes (48-63)
$_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/30`;
@bytes=split(" ");
printf("\tCache/Tag Stepping ID:\t\t\t\t0x%.2X\n",
($bytes[0] & 0xF0) >> 4);
print "\t\t----=== Xeon ROM Cartridge Data ===----\n";
print "\tCartridge Revision:\t\t\t\t\"";
print pack("cccc",$bytes[2],$bytes[3],$bytes[4],$bytes[5]);
print "\"\n";
printf("\tSubstrate Rev. Software ID:\t\t\t0x%.2X\n",
($bbytes[6] & 0xC0) >> 6);
print "\t\t----=== Xeon ROM Part Number Data ===----\n";
print "\tProcessor Part Number:\t\t\t\t\"";
print pack("ccccccc",$bytes[8],$bytes[9],$bytes[10],
$bytes[11],$bytes[12],$bytes[13],$bytes[14]);
print "\"\n";
$byte15=$byte[15];
# Decode next 16 bytes (64-79)
$_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/40`;
@bytes=split(" ");
print "\tProcessor BOM ID:\t\t\t\t\"";
print pack("cccccccccccccc",$byte15,$bytes[0],$bytes[1],
$bytes[2],$bytes[3],$bytes[4],$bytes[5],$bytes[6],
$bytes[7],$bytes[8],$bytes[9],$bytes[10],$bytes[11],
$bytes[12]);
print "\"\n";
# Decode next 16 bytes (80-95)
$_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/50`;
@bbytes=split(" ");
printf("\tProcessor Electronic Signature: \t\t0x%.2X%.2X%.2X%.2X%.2X%.2X%.2X%.2X\n",
$bytes[13],$bytes[14],$bytes[15],$bbytes[0],
$bbytes[1],$bbytes[2],$bbytes[3],$bbytes[4]);
# Decode next 16 bytes (96-111)
# Not used...
# Decode next 16 bytes (112-127)
$_=`cat /proc/sys/dev/sensors/$dimm_list[$i]/70`;
@bytes=split(" ");
print "\t\t----=== Xeon Thermal Reference Data ===----\n";
printf("\tThermal Reference Byte: \t\t\t0x%.2X\n", $bytes[0]);
print "\t\t----=== Xeon ROM Feature Data ===----\n";
printf("\tProcessor Core Feature Flags: \t\t\t0x%.2X%.2X%.2X%.2X\n",
$bytes[4],$bytes[5],$bytes[6],$bytes[7]);
printf("\tCartridge Feature Flags: \t\t\t0x%.2X%.2X%.2X%.2X\n",
$bytes[8],$bytes[9],$bytes[10],$bytes[11]);
printf("\tNumber of Devices in TAP Chain:\t\t\t%d\n",
($bytes[12] & 0xF0) >> 4);
}
}
print "\n\nNumber of Xeon ROMs detected and decoded: $dimm_count\n";