Merge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelv...
[safe/jmp/linux-2.6] / Documentation / dvb / get_dvb_firmware
index 815a578..14b7b5a 100644 (file)
@@ -25,7 +25,8 @@ use IO::Handle;
                "tda10046lifeview", "av7110", "dec2000t", "dec2540t",
                "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004",
                "or51211", "or51132_qam", "or51132_vsb", "bluebird",
-               "opera1", "cx231xx", "cx18", "cx23885", "pvrusb2" );
+               "opera1", "cx231xx", "cx18", "cx23885", "pvrusb2", "mpc718",
+               "af9015");
 
 # Check args
 syntax() if (scalar(@ARGV) != 1);
@@ -317,7 +318,7 @@ sub nxt2002 {
 
 sub nxt2004 {
     my $sourcefile = "AVerTVHD_MCE_A180_Drv_v1.2.2.16.zip";
-    my $url = "http://www.aver.com/support/Drivers/$sourcefile";
+    my $url = "http://www.avermedia-usa.com/support/Drivers/$sourcefile";
     my $hash = "111cb885b1e009188346d72acfed024c";
     my $outfile = "dvb-fe-nxt2004.fw";
     my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
@@ -381,6 +382,57 @@ sub cx18 {
     $allfiles;
 }
 
+sub mpc718 {
+    my $archive = 'Yuan MPC718 TV Tuner Card 2.13.10.1016.zip';
+    my $url = "ftp://ftp.work.acer-euro.com/desktop/aspire_idea510/vista/Drivers/$archive";
+    my $fwfile = "dvb-cx18-mpc718-mt352.fw";
+    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
+
+    checkstandard();
+    wgetfile($archive, $url);
+    unzip($archive, $tmpdir);
+
+    my $sourcefile = "$tmpdir/Yuan MPC718 TV Tuner Card 2.13.10.1016/mpc718_32bit/yuanrap.sys";
+    my $found = 0;
+
+    open IN, '<', $sourcefile or die "Couldn't open $sourcefile to extract $fwfile data\n";
+    binmode IN;
+    open OUT, '>', $fwfile;
+    binmode OUT;
+    {
+       # Block scope because we change the line terminator variable $/
+       my $prevlen = 0;
+       my $currlen;
+
+       # Buried in the data segment are 3 runs of almost identical
+       # register-value pairs that end in 0x5d 0x01 which is a "TUNER GO"
+       # command for the MT352.
+       # Pull out the middle run (because it's easy) of register-value
+       # pairs to make the "firmware" file.
+
+       local $/ = "\x5d\x01"; # MT352 "TUNER GO"
+
+       while (<IN>) {
+           $currlen = length($_);
+           if ($prevlen == $currlen && $currlen <= 64) {
+               chop; chop; # Get rid of "TUNER GO"
+               s/^\0\0//;  # get rid of leading 00 00 if it's there
+               printf OUT "$_";
+               $found = 1;
+               last;
+           }
+           $prevlen = $currlen;
+       }
+    }
+    close OUT;
+    close IN;
+    if (!$found) {
+       unlink $fwfile;
+       die "Couldn't find valid register-value sequence in $sourcefile for $fwfile\n";
+    }
+    $fwfile;
+}
+
 sub cx23885 {
     my $url = "http://linuxtv.org/downloads/firmware/";
 
@@ -463,6 +515,40 @@ sub bluebird {
        $outfile;
 }
 
+sub af9015 {
+       my $sourcefile = "download.ashx?file=57";
+       my $url = "http://www.ite.com.tw/EN/Services/$sourcefile";
+       my $hash = "ff5b096ed47c080870eacdab2de33ad6";
+       my $outfile = "dvb-usb-af9015.fw";
+       my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
+       my $fwoffset = 0x22708;
+       my $fwlength = 18225;
+       my ($chunklength, $buf, $rcount);
+
+       checkstandard();
+
+       wgetfile($sourcefile, $url);
+       unzip($sourcefile, $tmpdir);
+       verify("$tmpdir/Driver/Files/AF15BDA.sys", $hash);
+
+       open INFILE, '<', "$tmpdir/Driver/Files/AF15BDA.sys";
+       open OUTFILE, '>', $outfile;
+
+       sysseek(INFILE, $fwoffset, SEEK_SET);
+       while($fwlength > 0) {
+               $chunklength = 55;
+               $chunklength = $fwlength if ($chunklength > $fwlength);
+               $rcount = sysread(INFILE, $buf, $chunklength);
+               die "Ran out of data\n" if ($rcount != $chunklength);
+               syswrite(OUTFILE, $buf);
+               sysread(INFILE, $buf, 8);
+               $fwlength -= $rcount + 8;
+       }
+
+       close OUTFILE;
+       close INFILE;
+}
+
 # ---------------------------------------------------------------
 # Utilities