parse_az6007.pl: Add a parser for FX2 requests
authorMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 24 Jul 2011 16:33:26 +0000 (13:33 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sun, 24 Jul 2011 16:35:34 +0000 (13:35 -0300)
AZ6007 uses Cypress cy7c68013a 8051-based microcontroller. Adds
a parser for it. The parser doesn't cover all registers, but it
shouldn't be hard to add more as things are guessed from logs
inspection.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
contrib/az6007/parse_az6007.pl

index a19d745..6febe31 100755 (executable)
@@ -59,6 +59,9 @@ sub add_hex_mark($)
        my $data = shift;
        my $out ="{";
 
+       return "NULL" if ($data eq "");
+       return "NULL due to $data " if ($data =~ /[Ee][Rr][Rr][Oo][Rr]/);
+
        # Check if the string has the correct syntax. If not, just return it as-is
        for (my $i = 0; $i++; $i < length($data)) {
                if ((($i + 1) % 3) == 0) {
@@ -2270,6 +2273,29 @@ sub i2c_decode($$$$$)
        return ($addr, $data, $write, $n);
 }
 
+# This is a guess map for the Cypress FX2 registers that are seen
+# at the device and/or at other devices with FX2. It is incomplete
+# and may be wrong. The names here don't match the az6007 driver yet,
+# but are useful for someone that is checking the logs to analyze
+# what's wrong there
+my %req_map = (
+       # FX2 Special registers defined at CY7 datasheets
+       0x80 => "FX2_IOA",
+       0x90 => "FX2_IOB",
+       0xa0 => "FX2_LOAD_FIRMWARE",
+       0xb0 => "FX2_IOD",
+       0xb5 => "FX2_OED",
+       0xc0 => "FX2_SCON1",            # Used to reset demod
+       0xd0 => "FX2_PSW",
+
+       # Other registers used at the driver
+       0xb7 => "AZ6007_IDENTIFY_STATE", # I suspect that this is a RAM read function
+       0xb9 => "AZ6007_I2C_RD",
+       0xbc => "AZ6007_POWER",
+       0xbd => "AZ6007_I2C_WRT",       # FX2 calls it as GPIFSGL-DATH
+       0xc5 => "AZ6007_RC_READ",
+       0xc7 => "AZ6007_TS_THROUGH",
+);
 
 ##############
 # Main program
@@ -2309,13 +2335,20 @@ while (<>) {
                }
                if ($show_other_reqs) {
                        printf "$timestamp " if ($show_timestamp);
+
+                       if (defined($req_map{$req})) {
+                               $req = sprintf "%s /* 0x%02x */", $req_map{$req}, $req;
+                       } else {
+                               $req = sprintf "0x%02x", $req;
+                       }
+
                        if ($reqtype > 0x80) {
-                               printf "Read   ";
+                               printf("az6007_usb_in_op(d, %s, %s, %s, &data, %s); /* %s */\n",
+                                       $req, $wvalue, $windex, $wlen, add_hex_mark($payload));
                        } else {
-                               printf "Write  ";
+                               printf("az6007_usb_out_op(d, %s, %s, %s, %s, %s);\n",
+                                       $req, $wvalue, $windex, add_hex_mark($payload), $wlen);
                        }
-                       printf("Reqtype: 0x%02x, Req 0x%02x, wValue: 0x%04x, wIndex 0x%04x, wlen %d: %s\n",
-                               $reqtype, $req, $wvalue, $windex, $wlen, $payload);
                }
                next;
        }