diff options
author | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-11-17 12:04:30 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-11-17 12:04:30 -0200 |
commit | 28aac1389f1803e4060af3a68a17b6ba35ade1b2 (patch) | |
tree | 1adac1874ef5148b9cab55a362994b7a6f510253 | |
parent | c96937f831d4dcc4c7d1dd6696fd34535528ee75 (diff) |
parse_af9035.pl: add support for standard I2C commands
Adds the last remaining piece needed for the Kernel driver:
I2C read/write.
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rwxr-xr-x | contrib/af9035/parse_af9035.pl | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/contrib/af9035/parse_af9035.pl b/contrib/af9035/parse_af9035.pl index 07553151..9e2e9753 100755 --- a/contrib/af9035/parse_af9035.pl +++ b/contrib/af9035/parse_af9035.pl @@ -132,6 +132,45 @@ sub print_send_recv($$$$$$) @ctrl_bytes = @old; } + if (scalar(@ctrl_bytes) >= 3 && ($ctrl_cmd =~ /CMD_I2C_(RD|WR)/)) { + my @old = @ctrl_bytes; + my $addr = (shift @ctrl_bytes) >> 1; + my $len = shift @ctrl_bytes; + my $rlen = shift @ctrl_bytes; + my $msb_raddr = shift @ctrl_bytes; + my $lsb_raddr = shift @ctrl_bytes; + + if ($rlen == 2) { + unshift(@ctrl_bytes, $lsb_raddr); + unshift(@ctrl_bytes, $msb_raddr); + } elsif ($rlen == 1) { + unshift(@ctrl_bytes, $lsb_raddr); + } + + if (!scalar(@ctrl_bytes) && ($ctrl_cmd eq "CMD_I2C_RD")) { + my @b = split(/ /, $payload); + my $comment = "\t/* read: $payload */"; + + printf "i2c_master_recv(client, 0x%02x >> 1, &buf, %d);%s\n", $addr, scalar(@b), $comment if (!$hide_i2c_rd); + return; + } elsif ($ctrl_cmd eq "CMD_I2C_WR") { + my $comment = "\t/* $payload */" if ($payload =~ /ERROR/); + + my $ctrl_pay; + for (my $i = 0; $i < scalar(@ctrl_bytes); $i++) { + if ($i == 0) { + $ctrl_pay .= sprintf "0x%02x", $ctrl_bytes[$i]; + } else { + $ctrl_pay .= sprintf ", 0x%02x", $ctrl_bytes[$i]; + } + } + + printf "i2c_master_send(client, 0x%02x >> 1, { %s }, %d);%s\n", $addr, $ctrl_pay, scalar(@ctrl_bytes), $comment if (!$hide_i2c_wr); + return; + } + @ctrl_bytes = @old; + } + if (scalar(@ctrl_bytes) >= 6 && ($ctrl_cmd eq "CMD_MEM_WR" || $ctrl_cmd eq "CMD_MEM_RD")) { my $wlen; |