aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-10-03 16:21:39 (GMT)
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-03 16:21:39 (GMT)
commit62ba492f2b96cede817c1a9430abdd2eeeed7b0d (patch)
tree484eacc96e632c4f8de05704cb89fab4ed007878
parent595aa990f561c826f229c23ce7aa324d3d739f78 (diff)
parse_saa7134.pl: add logic to detect transactions without STOP
Read operations with sub-addresses are done by a write to the write address, plus a read. Between the write and read, there's no stop. For example, a read from eeprom, starting at eeprom address 0 will be displayed as: write_i2c_addr(0x50, 1, { 0x00}); /* INCOMPLETE */ read_i2c_addr(0x50, 23) /* 0xde, 0x17, 0x36, 0xb1, 0x54, 0x20, 0x1c, 0x00, 0x43, 0x43, 0xa9, 0x1c, 0x55, 0xd2, 0xb2, 0x92, 0xff, 0xff, 0xff, 0xff, 0xff, 0x20, 0xff */; Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rwxr-xr-xcontrib/saa7134/parse_saa7134.pl63
1 files changed, 38 insertions, 25 deletions
diff --git a/contrib/saa7134/parse_saa7134.pl b/contrib/saa7134/parse_saa7134.pl
index 05fe634..78f78fa 100755
--- a/contrib/saa7134/parse_saa7134.pl
+++ b/contrib/saa7134/parse_saa7134.pl
@@ -166,6 +166,39 @@ my $write = 0;
my $direction;
my @buf;
+sub flush_i2c_transaction($$)
+{
+ my $direction = shift;
+ my $is_complete = shift;
+
+ my $size = scalar(@buf);
+
+ if ($direction == 0) {
+ my $v = shift @buf;
+ printf("write_i2c_addr(0x%02x, %d, { 0x%02x",
+ $addr, $size, $v);
+ while (scalar(@buf)) {
+ my $v = shift @buf;
+ printf(", 0x%02x", $v);
+ }
+ printf("});");
+ } else {
+ my $size = scalar(@buf);
+ my $v = shift @buf;
+ printf("read_i2c_addr(0x%02x, %d) /* 0x%02x",
+ $addr, $size, $v);
+ while (scalar(@buf)) {
+ my $v = shift @buf;
+ printf(", 0x%02x", $v);
+ }
+ printf(" */;");
+ }
+ @buf = ();
+ $addr = -1;
+
+ printf (" /* INCOMPLETE */") if (!$is_complete);
+ printf "\n";
+}
sub parse_i2c($$$$$)
{
my $time = shift;
@@ -205,6 +238,8 @@ sub parse_i2c($$$$$)
$val >>= 8;
if (($attr eq "START") && ($optype eq "write")) {
+ flush_i2c_transaction(0, 0) if (scalar(@buf) && $addr >= 0);
+
$direction = $val & 1;
$addr = $val >> 1;
}
@@ -216,19 +251,8 @@ sub parse_i2c($$$$$)
push @buf, $val;
} elsif ($attr eq "STOP" && $addr >= 0) {
push @buf, $val;
- my $size = scalar(@buf);
- if ($direction == 0) {
- my $v = shift @buf;
- printf("write_i2c_addr(0x%02x, %d, { 0x%02x",
- $addr, $size, $v);
- while (scalar(@buf)) {
- my $v = shift @buf;
- printf(", 0x%02x", $v);
- }
- printf("});\n");
- }
- @buf = ();
- $addr = -1;
+
+ flush_i2c_transaction(0, 1);
}
} elsif ($direction == 1) {
if ($optype eq "write") {
@@ -241,18 +265,7 @@ sub parse_i2c($$$$$)
if ($attr eq "CONTINUE") {
push @buf, $val;
} elsif ($attr eq "STOP" && $addr >= 0) {
- push @buf, $val;
- my $size = scalar(@buf);
- my $v = shift @buf;
- printf("read_i2c_addr(0x%02x, %d) /* 0x%02x",
- $addr, $size, $v);
- while (scalar(@buf)) {
- my $v = shift @buf;
- printf(", 0x%02x", $v);
- }
- printf(" */;\n");
- @buf = ();
- $addr = -1;
+ flush_i2c_transaction(1, 1);
}
}
}

Privacy Policy