linux/Documentation/dvb/get_dvb_firmware
<<
>>
Prefs
   1#!/usr/bin/perl
   2#     DVB firmware extractor
   3#
   4#     (c) 2004 Andrew de Quincey
   5#
   6#     This program is free software; you can redistribute it and/or modify
   7#       it under the terms of the GNU General Public License as published by
   8#       the Free Software Foundation; either version 2 of the License, or
   9#       (at your option) any later version.
  10#
  11#     This program is distributed in the hope that it will be useful,
  12#       but WITHOUT ANY WARRANTY; without even the implied warranty of
  13#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14#
  15#     GNU General Public License for more details.
  16#
  17#     You should have received a copy of the GNU General Public License
  18#       along with this program; if not, write to the Free Software
  19#       Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20
  21use File::Temp qw/ tempdir /;
  22use IO::Handle;
  23
  24@components = ( "sp8870", "sp887x", "tda10045", "tda10046",
  25                "tda10046lifeview", "av7110", "dec2000t", "dec2540t",
  26                "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004",
  27                "or51211", "or51132_qam", "or51132_vsb", "bluebird",
  28                "opera1", "cx231xx", "cx18", "cx23885", "pvrusb2", "mpc718",
  29                "af9015", "ngene", "az6027", "lme2510_lg", "lme2510c_s7395",
  30                "lme2510c_s7395_old", "drxk", "drxk_terratec_h5",
  31                "drxk_hauppauge_hvr930c", "tda10071", "it9135", "it9137",
  32                "drxk_pctv", "drxk_terratec_htc_stick", "sms1xxx_hcw");
  33
  34# Check args
  35syntax() if (scalar(@ARGV) != 1);
  36$cid = $ARGV[0];
  37
  38# Do it!
  39for ($i=0; $i < scalar(@components); $i++) {
  40    if ($cid eq $components[$i]) {
  41        $outfile = eval($cid);
  42        die $@ if $@;
  43        print STDERR <<EOF;
  44Firmware(s) $outfile extracted successfully.
  45Now copy it(them) to either /usr/lib/hotplug/firmware or /lib/firmware
  46(depending on configuration of firmware hotplug).
  47EOF
  48        exit(0);
  49    }
  50}
  51
  52# If we get here, it wasn't found
  53print STDERR "Unknown component \"$cid\"\n";
  54syntax();
  55
  56
  57
  58
  59# ---------------------------------------------------------------
  60# Firmware-specific extraction subroutines
  61
  62sub sp8870 {
  63    my $sourcefile = "tt_Premium_217g.zip";
  64    my $url = "http://www.softwarepatch.pl/9999ccd06a4813cb827dbb0005071c71/$sourcefile";
  65    my $hash = "53970ec17a538945a6d8cb608a7b3899";
  66    my $outfile = "dvb-fe-sp8870.fw";
  67    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
  68
  69    checkstandard();
  70
  71    wgetfile($sourcefile, $url);
  72    unzip($sourcefile, $tmpdir);
  73    verify("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $hash);
  74    copy("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $outfile);
  75
  76    $outfile;
  77}
  78
  79sub sp887x {
  80    my $sourcefile = "Dvbt1.3.57.6.zip";
  81    my $url = "http://www.avermedia.com/software/$sourcefile";
  82    my $cabfile = "DVBT Net  Ver1.3.57.6/disk1/data1.cab";
  83    my $hash = "237938d53a7f834c05c42b894ca68ac3";
  84    my $outfile = "dvb-fe-sp887x.fw";
  85    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
  86
  87    checkstandard();
  88    checkunshield();
  89
  90    wgetfile($sourcefile, $url);
  91    unzip($sourcefile, $tmpdir);
  92    unshield("$tmpdir/$cabfile", $tmpdir);
  93    verify("$tmpdir/ZEnglish/sc_main.mc", $hash);
  94    copy("$tmpdir/ZEnglish/sc_main.mc", $outfile);
  95
  96    $outfile;
  97}
  98
  99sub tda10045 {
 100    my $sourcefile = "tt_budget_217g.zip";
 101    my $url = "http://www.technotrend.de/new/217g/$sourcefile";
 102    my $hash = "2105fd5bf37842fbcdfa4bfd58f3594a";
 103    my $outfile = "dvb-fe-tda10045.fw";
 104    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 105
 106    checkstandard();
 107
 108    wgetfile($sourcefile, $url);
 109    unzip($sourcefile, $tmpdir);
 110    extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x37ef9, 30555, "$tmpdir/fwtmp");
 111    verify("$tmpdir/fwtmp", $hash);
 112    copy("$tmpdir/fwtmp", $outfile);
 113
 114    $outfile;
 115}
 116
 117sub tda10046 {
 118        my $sourcefile = "TT_PCI_2.19h_28_11_2006.zip";
 119        my $url = "http://technotrend.com.ua/download/software/219/$sourcefile";
 120        my $hash = "6a7e1e2f2644b162ff0502367553c72d";
 121        my $outfile = "dvb-fe-tda10046.fw";
 122        my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 123
 124        checkstandard();
 125
 126        wgetfile($sourcefile, $url);
 127        unzip($sourcefile, $tmpdir);
 128        extract("$tmpdir/TT_PCI_2.19h_28_11_2006/software/OEM/PCI/App/ttlcdacc.dll", 0x65389, 24478, "$tmpdir/fwtmp");
 129        verify("$tmpdir/fwtmp", $hash);
 130        copy("$tmpdir/fwtmp", $outfile);
 131
 132        $outfile;
 133}
 134
 135sub tda10046lifeview {
 136    my $sourcefile = "7%5Cdrv_2.11.02.zip";
 137    my $url = "http://www.lifeview.hk/dbimages/document/$sourcefile";
 138    my $hash = "1ea24dee4eea8fe971686981f34fd2e0";
 139    my $outfile = "dvb-fe-tda10046.fw";
 140    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 141
 142    checkstandard();
 143
 144    wgetfile($sourcefile, $url);
 145    unzip($sourcefile, $tmpdir);
 146    extract("$tmpdir/LVHybrid.sys", 0x8b088, 24602, "$tmpdir/fwtmp");
 147    verify("$tmpdir/fwtmp", $hash);
 148    copy("$tmpdir/fwtmp", $outfile);
 149
 150    $outfile;
 151}
 152
 153sub av7110 {
 154    my $sourcefile = "dvb-ttpci-01.fw-261d";
 155    my $url = "http://www.linuxtv.org/downloads/firmware/$sourcefile";
 156    my $hash = "603431b6259715a8e88f376a53b64e2f";
 157    my $outfile = "dvb-ttpci-01.fw";
 158
 159    checkstandard();
 160
 161    wgetfile($sourcefile, $url);
 162    verify($sourcefile, $hash);
 163    copy($sourcefile, $outfile);
 164
 165    $outfile;
 166}
 167
 168sub dec2000t {
 169    my $sourcefile = "dec217g.exe";
 170    my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
 171    my $hash = "bd86f458cee4a8f0a8ce2d20c66215a9";
 172    my $outfile = "dvb-ttusb-dec-2000t.fw";
 173    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 174
 175    checkstandard();
 176
 177    wgetfile($sourcefile, $url);
 178    unzip($sourcefile, $tmpdir);
 179    verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $hash);
 180    copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $outfile);
 181
 182    $outfile;
 183}
 184
 185sub dec2540t {
 186    my $sourcefile = "dec217g.exe";
 187    my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
 188    my $hash = "53e58f4f5b5c2930beee74a7681fed92";
 189    my $outfile = "dvb-ttusb-dec-2540t.fw";
 190    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 191
 192    checkstandard();
 193
 194    wgetfile($sourcefile, $url);
 195    unzip($sourcefile, $tmpdir);
 196    verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $hash);
 197    copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $outfile);
 198
 199    $outfile;
 200}
 201
 202sub dec3000s {
 203    my $sourcefile = "dec217g.exe";
 204    my $url = "http://hauppauge.lightpath.net/de/$sourcefile";
 205    my $hash = "b013ececea83f4d6d8d2a29ac7c1b448";
 206    my $outfile = "dvb-ttusb-dec-3000s.fw";
 207    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 208
 209    checkstandard();
 210
 211    wgetfile($sourcefile, $url);
 212    unzip($sourcefile, $tmpdir);
 213    verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $hash);
 214    copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $outfile);
 215
 216    $outfile;
 217}
 218sub opera1{
 219        my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0);
 220
 221        checkstandard();
 222        my $fwfile1="dvb-usb-opera1-fpga-01.fw";
 223        my $fwfile2="dvb-usb-opera-01.fw";
 224        extract("2830SCap2.sys", 0x62e8, 55024, "$tmpdir/opera1-fpga.fw");
 225        extract("2830SLoad2.sys",0x3178,0x3685-0x3178,"$tmpdir/fw1part1");
 226        extract("2830SLoad2.sys",0x0980,0x3150-0x0980,"$tmpdir/fw1part2");
 227        delzero("$tmpdir/fw1part1","$tmpdir/fw1part1-1");
 228        delzero("$tmpdir/fw1part2","$tmpdir/fw1part2-1");
 229        verify("$tmpdir/fw1part1-1","5e0909858fdf0b5b09ad48b9fe622e70");
 230        verify("$tmpdir/fw1part2-1","d6e146f321427e931df2c6fcadac37a1");
 231        verify("$tmpdir/opera1-fpga.fw","0f8133f5e9051f5f3c1928f7e5a1b07d");
 232
 233        my $RES1="\x01\x92\x7f\x00\x01\x00";
 234        my $RES0="\x01\x92\x7f\x00\x00\x00";
 235        my $DAT1="\x01\x00\xe6\x00\x01\x00";
 236        my $DAT0="\x01\x00\xe6\x00\x00\x00";
 237        open FW,">$tmpdir/opera.fw";
 238        print FW "$RES1";
 239        print FW "$DAT1";
 240        print FW "$RES1";
 241        print FW "$DAT1";
 242        appendfile(FW,"$tmpdir/fw1part1-1");
 243        print FW "$RES0";
 244        print FW "$DAT0";
 245        print FW "$RES1";
 246        print FW "$DAT1";
 247        appendfile(FW,"$tmpdir/fw1part2-1");
 248        print FW "$RES1";
 249        print FW "$DAT1";
 250        print FW "$RES0";
 251        print FW "$DAT0";
 252        copy ("$tmpdir/opera1-fpga.fw",$fwfile1);
 253        copy ("$tmpdir/opera.fw",$fwfile2);
 254
 255        $fwfile1.",".$fwfile2;
 256}
 257
 258sub vp7041 {
 259    my $sourcefile = "2.422.zip";
 260    my $url = "http://www.twinhan.com/files/driver/USB-Ter/$sourcefile";
 261    my $hash = "e88c9372d1f66609a3e7b072c53fbcfe";
 262    my $outfile = "dvb-vp7041-2.422.fw";
 263    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 264
 265    checkstandard();
 266
 267    wgetfile($sourcefile, $url);
 268    unzip($sourcefile, $tmpdir);
 269    extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 12503, 3036, "$tmpdir/fwtmp1");
 270    extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 2207, 10274, "$tmpdir/fwtmp2");
 271
 272    my $CMD = "\000\001\000\222\177\000";
 273    my $PAD = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000";
 274    my ($FW);
 275    open $FW, ">$tmpdir/fwtmp3";
 276    print $FW "$CMD\001$PAD";
 277    print $FW "$CMD\001$PAD";
 278    appendfile($FW, "$tmpdir/fwtmp1");
 279    print $FW "$CMD\000$PAD";
 280    print $FW "$CMD\001$PAD";
 281    appendfile($FW, "$tmpdir/fwtmp2");
 282    print $FW "$CMD\001$PAD";
 283    print $FW "$CMD\000$PAD";
 284    close($FW);
 285
 286    verify("$tmpdir/fwtmp3", $hash);
 287    copy("$tmpdir/fwtmp3", $outfile);
 288
 289    $outfile;
 290}
 291
 292sub dibusb {
 293        my $url = "http://www.linuxtv.org/downloads/firmware/dvb-usb-dibusb-5.0.0.11.fw";
 294        my $outfile = "dvb-dibusb-5.0.0.11.fw";
 295        my $hash = "fa490295a527360ca16dcdf3224ca243";
 296
 297        checkstandard();
 298
 299        wgetfile($outfile, $url);
 300        verify($outfile,$hash);
 301
 302        $outfile;
 303}
 304
 305sub nxt2002 {
 306    my $sourcefile = "Technisat_DVB-PC_4_4_COMPACT.zip";
 307    my $url = "http://www.bbti.us/download/windows/$sourcefile";
 308    my $hash = "476befae8c7c1bb9648954060b1eec1f";
 309    my $outfile = "dvb-fe-nxt2002.fw";
 310    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 311
 312    checkstandard();
 313
 314    wgetfile($sourcefile, $url);
 315    unzip($sourcefile, $tmpdir);
 316    verify("$tmpdir/SkyNET.sys", $hash);
 317    extract("$tmpdir/SkyNET.sys", 331624, 5908, $outfile);
 318
 319    $outfile;
 320}
 321
 322sub nxt2004 {
 323    my $sourcefile = "AVerTVHD_MCE_A180_Drv_v1.2.2.16.zip";
 324    my $url = "http://www.avermedia-usa.com/support/Drivers/$sourcefile";
 325    my $hash = "111cb885b1e009188346d72acfed024c";
 326    my $outfile = "dvb-fe-nxt2004.fw";
 327    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 328
 329    checkstandard();
 330
 331    wgetfile($sourcefile, $url);
 332    unzip($sourcefile, $tmpdir);
 333    verify("$tmpdir/3xHybrid.sys", $hash);
 334    extract("$tmpdir/3xHybrid.sys", 465304, 9584, $outfile);
 335
 336    $outfile;
 337}
 338
 339sub or51211 {
 340    my $fwfile = "dvb-fe-or51211.fw";
 341    my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
 342    my $hash = "d830949c771a289505bf9eafc225d491";
 343
 344    checkstandard();
 345
 346    wgetfile($fwfile, $url);
 347    verify($fwfile, $hash);
 348
 349    $fwfile;
 350}
 351
 352sub cx231xx {
 353    my $fwfile = "v4l-cx231xx-avcore-01.fw";
 354    my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
 355    my $hash = "7d3bb956dc9df0eafded2b56ba57cc42";
 356
 357    checkstandard();
 358
 359    wgetfile($fwfile, $url);
 360    verify($fwfile, $hash);
 361
 362    $fwfile;
 363}
 364
 365sub cx18 {
 366    my $url = "http://linuxtv.org/downloads/firmware/";
 367
 368    my %files = (
 369        'v4l-cx23418-apu.fw' => '588f081b562f5c653a3db1ad8f65939a',
 370        'v4l-cx23418-cpu.fw' => 'b6c7ed64bc44b1a6e0840adaeac39d79',
 371        'v4l-cx23418-dig.fw' => '95bc688d3e7599fd5800161e9971cc55',
 372    );
 373
 374    checkstandard();
 375
 376    my $allfiles;
 377    foreach my $fwfile (keys %files) {
 378        wgetfile($fwfile, "$url/$fwfile");
 379        verify($fwfile, $files{$fwfile});
 380        $allfiles .= " $fwfile";
 381    }
 382
 383    $allfiles =~ s/^\s//;
 384
 385    $allfiles;
 386}
 387
 388sub mpc718 {
 389    my $archive = 'Yuan MPC718 TV Tuner Card 2.13.10.1016.zip';
 390    my $url = "ftp://ftp.work.acer-euro.com/desktop/aspire_idea510/vista/Drivers/$archive";
 391    my $fwfile = "dvb-cx18-mpc718-mt352.fw";
 392    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 393
 394    checkstandard();
 395    wgetfile($archive, $url);
 396    unzip($archive, $tmpdir);
 397
 398    my $sourcefile = "$tmpdir/Yuan MPC718 TV Tuner Card 2.13.10.1016/mpc718_32bit/yuanrap.sys";
 399    my $found = 0;
 400
 401    open IN, '<', $sourcefile or die "Couldn't open $sourcefile to extract $fwfile data\n";
 402    binmode IN;
 403    open OUT, '>', $fwfile;
 404    binmode OUT;
 405    {
 406        # Block scope because we change the line terminator variable $/
 407        my $prevlen = 0;
 408        my $currlen;
 409
 410        # Buried in the data segment are 3 runs of almost identical
 411        # register-value pairs that end in 0x5d 0x01 which is a "TUNER GO"
 412        # command for the MT352.
 413        # Pull out the middle run (because it's easy) of register-value
 414        # pairs to make the "firmware" file.
 415
 416        local $/ = "\x5d\x01"; # MT352 "TUNER GO"
 417
 418        while (<IN>) {
 419            $currlen = length($_);
 420            if ($prevlen == $currlen && $currlen <= 64) {
 421                chop; chop; # Get rid of "TUNER GO"
 422                s/^\0\0//;  # get rid of leading 00 00 if it's there
 423                printf OUT "$_";
 424                $found = 1;
 425                last;
 426            }
 427            $prevlen = $currlen;
 428        }
 429    }
 430    close OUT;
 431    close IN;
 432    if (!$found) {
 433        unlink $fwfile;
 434        die "Couldn't find valid register-value sequence in $sourcefile for $fwfile\n";
 435    }
 436    $fwfile;
 437}
 438
 439sub cx23885 {
 440    my $url = "http://linuxtv.org/downloads/firmware/";
 441
 442    my %files = (
 443        'v4l-cx23885-avcore-01.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb',
 444        'v4l-cx23885-enc.fw'       => 'a9f8f5d901a7fb42f552e1ee6384f3bb',
 445    );
 446
 447    checkstandard();
 448
 449    my $allfiles;
 450    foreach my $fwfile (keys %files) {
 451        wgetfile($fwfile, "$url/$fwfile");
 452        verify($fwfile, $files{$fwfile});
 453        $allfiles .= " $fwfile";
 454    }
 455
 456    $allfiles =~ s/^\s//;
 457
 458    $allfiles;
 459}
 460
 461sub pvrusb2 {
 462    my $url = "http://linuxtv.org/downloads/firmware/";
 463
 464    my %files = (
 465        'v4l-cx25840.fw'           => 'dadb79e9904fc8af96e8111d9cb59320',
 466    );
 467
 468    checkstandard();
 469
 470    my $allfiles;
 471    foreach my $fwfile (keys %files) {
 472        wgetfile($fwfile, "$url/$fwfile");
 473        verify($fwfile, $files{$fwfile});
 474        $allfiles .= " $fwfile";
 475    }
 476
 477    $allfiles =~ s/^\s//;
 478
 479    $allfiles;
 480}
 481
 482sub or51132_qam {
 483    my $fwfile = "dvb-fe-or51132-qam.fw";
 484    my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
 485    my $hash = "7702e8938612de46ccadfe9b413cb3b5";
 486
 487    checkstandard();
 488
 489    wgetfile($fwfile, $url);
 490    verify($fwfile, $hash);
 491
 492    $fwfile;
 493}
 494
 495sub or51132_vsb {
 496    my $fwfile = "dvb-fe-or51132-vsb.fw";
 497    my $url = "http://linuxtv.org/downloads/firmware/$fwfile";
 498    my $hash = "c16208e02f36fc439a557ad4c613364a";
 499
 500    checkstandard();
 501
 502    wgetfile($fwfile, $url);
 503    verify($fwfile, $hash);
 504
 505    $fwfile;
 506}
 507
 508sub bluebird {
 509        my $url = "http://www.linuxtv.org/download/dvb/firmware/dvb-usb-bluebird-01.fw";
 510        my $outfile = "dvb-usb-bluebird-01.fw";
 511        my $hash = "658397cb9eba9101af9031302671f49d";
 512
 513        checkstandard();
 514
 515        wgetfile($outfile, $url);
 516        verify($outfile,$hash);
 517
 518        $outfile;
 519}
 520
 521sub af9015 {
 522        my $sourcefile = "download.ashx?file=57";
 523        my $url = "http://www.ite.com.tw/EN/Services/$sourcefile";
 524        my $hash = "e3f08935158038d385ad382442f4bb2d";
 525        my $outfile = "dvb-usb-af9015.fw";
 526        my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 527        my $fwoffset = 0x25690;
 528        my $fwlength = 18725;
 529        my ($chunklength, $buf, $rcount);
 530
 531        checkstandard();
 532
 533        wgetfile($sourcefile, $url);
 534        unzip($sourcefile, $tmpdir);
 535        verify("$tmpdir/Driver/Files/AF15BDA.sys", $hash);
 536
 537        open INFILE, '<', "$tmpdir/Driver/Files/AF15BDA.sys";
 538        open OUTFILE, '>', $outfile;
 539
 540        sysseek(INFILE, $fwoffset, SEEK_SET);
 541        while($fwlength > 0) {
 542                $chunklength = 55;
 543                $chunklength = $fwlength if ($chunklength > $fwlength);
 544                $rcount = sysread(INFILE, $buf, $chunklength);
 545                die "Ran out of data\n" if ($rcount != $chunklength);
 546                syswrite(OUTFILE, $buf);
 547                sysread(INFILE, $buf, 8);
 548                $fwlength -= $rcount + 8;
 549        }
 550
 551        close OUTFILE;
 552        close INFILE;
 553}
 554
 555sub ngene {
 556    my $url = "http://www.digitaldevices.de/download/";
 557    my $file1 = "ngene_15.fw";
 558    my $hash1 = "d798d5a757121174f0dbc5f2833c0c85";
 559    my $file2 = "ngene_17.fw";
 560    my $hash2 = "26b687136e127b8ac24b81e0eeafc20b";
 561    my $url2 = "http://l4m-daten.de/downloads/firmware/dvb-s2/linux/all/";
 562    my $file3 = "ngene_18.fw";
 563    my $hash3 = "ebce3ea769a53e3e0b0197c3b3f127e3";
 564
 565    checkstandard();
 566
 567    wgetfile($file1, $url . $file1);
 568    verify($file1, $hash1);
 569
 570    wgetfile($file2, $url . $file2);
 571    verify($file2, $hash2);
 572
 573    wgetfile($file3, $url2 . $file3);
 574    verify($file3, $hash3);
 575
 576    "$file1, $file2, $file3";
 577}
 578
 579sub az6027{
 580    my $firmware = "dvb-usb-az6027-03.fw";
 581    my $url = "http://linux.terratec.de/files/TERRATEC_S7/$firmware";
 582
 583    wgetfile($firmware, $url);
 584
 585    $firmware;
 586}
 587
 588sub lme2510_lg {
 589    my $sourcefile = "LMEBDA_DVBS.sys";
 590    my $hash = "fc6017ad01e79890a97ec53bea157ed2";
 591    my $outfile = "dvb-usb-lme2510-lg.fw";
 592    my $hasho = "caa065d5fdbd2c09ad57b399bbf55cad";
 593
 594    checkstandard();
 595
 596    verify($sourcefile, $hash);
 597    extract($sourcefile, 4168, 3841, $outfile);
 598    verify($outfile, $hasho);
 599    $outfile;
 600}
 601
 602sub lme2510c_s7395 {
 603    my $sourcefile = "US2A0D.sys";
 604    my $hash = "b0155a8083fb822a3bd47bc360e74601";
 605    my $outfile = "dvb-usb-lme2510c-s7395.fw";
 606    my $hasho = "3a3cf1aeebd17b6ddc04cebe131e94cf";
 607
 608    checkstandard();
 609
 610    verify($sourcefile, $hash);
 611    extract($sourcefile, 37248, 3720, $outfile);
 612    verify($outfile, $hasho);
 613    $outfile;
 614}
 615
 616sub lme2510c_s7395_old {
 617    my $sourcefile = "LMEBDA_DVBS7395C.sys";
 618    my $hash = "7572ae0eb9cdf91baabd7c0ba9e09b31";
 619    my $outfile = "dvb-usb-lme2510c-s7395.fw";
 620    my $hasho = "90430c5b435eb5c6f88fd44a9d950674";
 621
 622    checkstandard();
 623
 624    verify($sourcefile, $hash);
 625    extract($sourcefile, 4208, 3881, $outfile);
 626    verify($outfile, $hasho);
 627    $outfile;
 628}
 629
 630sub drxk {
 631    my $url = "http://l4m-daten.de/files/";
 632    my $zipfile = "DDTuner.zip";
 633    my $hash = "f5a37b9a20a3534997997c0b1382a3e5";
 634    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 635    my $drvfile = "DDTuner.sys";
 636    my $fwfile = "drxk_a3.mc";
 637
 638    checkstandard();
 639
 640    wgetfile($zipfile, $url . $zipfile);
 641    verify($zipfile, $hash);
 642    unzip($zipfile, $tmpdir);
 643    extract("$tmpdir/$drvfile", 0x14dd8, 15634, "$fwfile");
 644
 645    "$fwfile"
 646}
 647
 648sub drxk_hauppauge_hvr930c {
 649    my $url = "http://www.wintvcd.co.uk/drivers/";
 650    my $zipfile = "HVR-9x0_5_10_325_28153_SIGNED.zip";
 651    my $hash = "83ab82e7e9480ec8bf1ae0155ca63c88";
 652    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 653    my $drvfile = "HVR-900/emOEM.sys";
 654    my $fwfile = "dvb-usb-hauppauge-hvr930c-drxk.fw";
 655
 656    checkstandard();
 657
 658    wgetfile($zipfile, $url . $zipfile);
 659    verify($zipfile, $hash);
 660    unzip($zipfile, $tmpdir);
 661    extract("$tmpdir/$drvfile", 0x117b0, 42692, "$fwfile");
 662
 663    "$fwfile"
 664}
 665
 666sub drxk_terratec_h5 {
 667    my $url = "http://www.linuxtv.org/downloads/firmware/";
 668    my $hash = "19000dada8e2741162ccc50cc91fa7f1";
 669    my $fwfile = "dvb-usb-terratec-h5-drxk.fw";
 670
 671    checkstandard();
 672
 673    wgetfile($fwfile, $url . $fwfile);
 674    verify($fwfile, $hash);
 675
 676    "$fwfile"
 677}
 678
 679sub drxk_terratec_htc_stick {
 680    my $url = "http://ftp.terratec.de/Receiver/Cinergy_HTC_Stick/Updates/";
 681    my $zipfile = "Cinergy_HTC_Stick_Drv_5.09.1202.00_XP_Vista_7.exe";
 682    my $hash = "6722a2442a05423b781721fbc069ed5e";
 683    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0);
 684    my $drvfile = "Cinergy HTC Stick/BDA Driver 5.09.1202.00/Windows 32 Bit/emOEM.sys";
 685    my $fwfile = "dvb-usb-terratec-htc-stick-drxk.fw";
 686
 687    checkstandard();
 688
 689    wgetfile($zipfile, $url . $zipfile);
 690    verify($zipfile, $hash);
 691    unzip($zipfile, $tmpdir);
 692    extract("$tmpdir/$drvfile", 0x4e5c0, 42692, "$fwfile");
 693
 694    "$fwfile"
 695}
 696
 697sub it9135 {
 698        my $sourcefile = "dvb-usb-it9135.zip";
 699        my $url = "http://www.ite.com.tw/uploads/firmware/v3.6.0.0/$sourcefile";
 700        my $hash = "1e55f6c8833f1d0ae067c2bb2953e6a9";
 701        my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0);
 702        my $outfile = "dvb-usb-it9135.fw";
 703        my $fwfile1 = "dvb-usb-it9135-01.fw";
 704        my $fwfile2 = "dvb-usb-it9135-02.fw";
 705
 706        checkstandard();
 707
 708        wgetfile($sourcefile, $url);
 709        unzip($sourcefile, $tmpdir);
 710        verify("$tmpdir/$outfile", $hash);
 711        extract("$tmpdir/$outfile", 64, 8128, "$fwfile1");
 712        extract("$tmpdir/$outfile", 12866, 5817, "$fwfile2");
 713
 714        "$fwfile1 $fwfile2"
 715}
 716
 717sub it9137 {
 718    my $url = "http://kworld.server261.com/kworld/CD/ITE_TiVme/V1.00/";
 719    my $zipfile = "Driver_V10.323.1.0412.100412.zip";
 720    my $hash = "79b597dc648698ed6820845c0c9d0d37";
 721    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0);
 722    my $drvfile = "Driver_V10.323.1.0412.100412/Data/x86/IT9135BDA.sys";
 723    my $fwfile = "dvb-usb-it9137-01.fw";
 724
 725    checkstandard();
 726
 727    wgetfile($zipfile, $url . $zipfile);
 728    verify($zipfile, $hash);
 729    unzip($zipfile, $tmpdir);
 730    extract("$tmpdir/$drvfile", 69632, 5731, "$fwfile");
 731
 732    "$fwfile"
 733}
 734
 735sub tda10071 {
 736    my $sourcefile = "PCTV_460e_reference.zip";
 737    my $url = "ftp://ftp.pctvsystems.com/TV/driver/PCTV%2070e%2080e%20100e%20320e%20330e%20800e/";
 738    my $hash = "4403de903bf2593464c8d74bbc200a57";
 739    my $fwfile = "dvb-fe-tda10071.fw";
 740    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 741
 742    checkstandard();
 743
 744    wgetfile($sourcefile, $url . $sourcefile);
 745    verify($sourcefile, $hash);
 746    unzip($sourcefile, $tmpdir);
 747    extract("$tmpdir/PCTV\ 70e\ 80e\ 100e\ 320e\ 330e\ 800e/32\ bit/emOEM.sys", 0x67d38, 40504, $fwfile);
 748
 749    "$fwfile";
 750}
 751
 752sub drxk_pctv {
 753    my $sourcefile = "PCTV_460e_reference.zip";
 754    my $url = "ftp://ftp.pctvsystems.com/TV/driver/PCTV%2070e%2080e%20100e%20320e%20330e%20800e/";
 755    my $hash = "4403de903bf2593464c8d74bbc200a57";
 756    my $fwfile = "dvb-demod-drxk-pctv.fw";
 757    my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1);
 758
 759    checkstandard();
 760
 761    wgetfile($sourcefile, $url . $sourcefile);
 762    verify($sourcefile, $hash);
 763    unzip($sourcefile, $tmpdir);
 764    extract("$tmpdir/PCTV\ 70e\ 80e\ 100e\ 320e\ 330e\ 800e/32\ bit/emOEM.sys", 0x72b80, 42692, $fwfile);
 765
 766    "$fwfile";
 767}
 768
 769sub sms1xxx_hcw {
 770    my $url = "http://steventoth.net/linux/sms1xxx/";
 771    my %files = (
 772        'sms1xxx-hcw-55xxx-dvbt-01.fw'  => "afb6f9fb9a71d64392e8564ef9577e5a",
 773        'sms1xxx-hcw-55xxx-dvbt-02.fw'  => "b44807098ba26e52cbedeadc052ba58f",
 774        'sms1xxx-hcw-55xxx-isdbt-02.fw' => "dae934eeea85225acbd63ce6cfe1c9e4",
 775    );
 776
 777    checkstandard();
 778
 779    my $allfiles;
 780    foreach my $fwfile (keys %files) {
 781        wgetfile($fwfile, "$url/$fwfile");
 782        verify($fwfile, $files{$fwfile});
 783        $allfiles .= " $fwfile";
 784    }
 785
 786    $allfiles =~ s/^\s//;
 787
 788    $allfiles;
 789}
 790
 791# ---------------------------------------------------------------
 792# Utilities
 793
 794sub checkstandard {
 795    if (system("which unzip > /dev/null 2>&1")) {
 796        die "This firmware requires the unzip command - see ftp://ftp.info-zip.org/pub/infozip/UnZip.html\n";
 797    }
 798    if (system("which md5sum > /dev/null 2>&1")) {
 799        die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n";
 800    }
 801    if (system("which wget > /dev/null 2>&1")) {
 802        die "This firmware requires the wget command - see http://wget.sunsite.dk/\n";
 803    }
 804}
 805
 806sub checkunshield {
 807    if (system("which unshield > /dev/null 2>&1")) {
 808        die "This firmware requires the unshield command - see http://sourceforge.net/projects/synce/\n";
 809    }
 810}
 811
 812sub wgetfile {
 813    my ($sourcefile, $url) = @_;
 814
 815    if (! -f $sourcefile) {
 816        system("wget -O \"$sourcefile\" \"$url\"") and die "wget failed - unable to download firmware";
 817    }
 818}
 819
 820sub unzip {
 821    my ($sourcefile, $todir) = @_;
 822
 823    $status = system("unzip -q -o -d \"$todir\" \"$sourcefile\" 2>/dev/null" );
 824    if ((($status >> 8) > 2) || (($status & 0xff) != 0)) {
 825        die ("unzip failed - unable to extract firmware");
 826    }
 827}
 828
 829sub unshield {
 830    my ($sourcefile, $todir) = @_;
 831
 832    system("unshield x -d \"$todir\" \"$sourcefile\" > /dev/null" ) and die ("unshield failed - unable to extract firmware");
 833}
 834
 835sub verify {
 836    my ($filename, $hash) = @_;
 837    my ($testhash);
 838
 839    open(CMD, "md5sum \"$filename\"|");
 840    $testhash = <CMD>;
 841    $testhash =~ /([a-zA-Z0-9]*)/;
 842    $testhash = $1;
 843    close CMD;
 844    die "Hash of extracted file does not match!\n" if ($testhash ne $hash);
 845}
 846
 847sub copy {
 848    my ($from, $to) = @_;
 849
 850    system("cp -f \"$from\" \"$to\"") and die ("cp failed");
 851}
 852
 853sub extract {
 854    my ($infile, $offset, $length, $outfile) = @_;
 855    my ($chunklength, $buf, $rcount);
 856
 857    open INFILE, "<$infile";
 858    open OUTFILE, ">$outfile";
 859    sysseek(INFILE, $offset, SEEK_SET);
 860    while($length > 0) {
 861        # Calc chunk size
 862        $chunklength = 2048;
 863        $chunklength = $length if ($chunklength > $length);
 864
 865        $rcount = sysread(INFILE, $buf, $chunklength);
 866        die "Ran out of data\n" if ($rcount != $chunklength);
 867        syswrite(OUTFILE, $buf);
 868        $length -= $rcount;
 869    }
 870    close INFILE;
 871    close OUTFILE;
 872}
 873
 874sub appendfile {
 875    my ($FH, $infile) = @_;
 876    my ($buf);
 877
 878    open INFILE, "<$infile";
 879    while(1) {
 880        $rcount = sysread(INFILE, $buf, 2048);
 881        last if ($rcount == 0);
 882        print $FH $buf;
 883    }
 884    close(INFILE);
 885}
 886
 887sub delzero{
 888        my ($infile,$outfile) =@_;
 889
 890        open INFILE,"<$infile";
 891        open OUTFILE,">$outfile";
 892        while (1){
 893                $rcount=sysread(INFILE,$buf,22);
 894                $len=ord(substr($buf,0,1));
 895                print OUTFILE substr($buf,0,1);
 896                print OUTFILE substr($buf,2,$len+3);
 897        last if ($rcount<1);
 898        printf OUTFILE "%c",0;
 899#print $len." ".length($buf)."\n";
 900
 901        }
 902        close(INFILE);
 903        close(OUTFILE);
 904}
 905
 906sub syntax() {
 907    print STDERR "syntax: get_dvb_firmware <component>\n";
 908    print STDERR "Supported components:\n";
 909    @components = sort @components;
 910    for($i=0; $i < scalar(@components); $i++) {
 911        print STDERR "\t" . $components[$i] . "\n";
 912    }
 913    exit(1);
 914}
 915
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.