18c2ecf20Sopenharmony_ci#!/usr/bin/env perl 28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-or-later 38c2ecf20Sopenharmony_ci# DVB firmware extractor 48c2ecf20Sopenharmony_ci# 58c2ecf20Sopenharmony_ci# (c) 2004 Andrew de Quincey 68c2ecf20Sopenharmony_ci# 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ciuse File::Temp qw/ tempdir /; 98c2ecf20Sopenharmony_ciuse IO::Handle; 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci@components = ( "sp8870", "sp887x", "tda10045", "tda10046", 128c2ecf20Sopenharmony_ci "tda10046lifeview", "av7110", "dec2000t", "dec2540t", 138c2ecf20Sopenharmony_ci "dec3000s", "vp7041", "vp7049", "dibusb", "nxt2002", "nxt2004", 148c2ecf20Sopenharmony_ci "or51211", "or51132_qam", "or51132_vsb", "bluebird", 158c2ecf20Sopenharmony_ci "opera1", "cx231xx", "cx18", "cx23885", "pvrusb2", "mpc718", 168c2ecf20Sopenharmony_ci "af9015", "ngene", "az6027", "lme2510_lg", "lme2510c_s7395", 178c2ecf20Sopenharmony_ci "lme2510c_s7395_old", "drxk", "drxk_terratec_h5", 188c2ecf20Sopenharmony_ci "drxk_hauppauge_hvr930c", "tda10071", "it9135", "drxk_pctv", 198c2ecf20Sopenharmony_ci "drxk_terratec_htc_stick", "sms1xxx_hcw", "si2165"); 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci# Check args 228c2ecf20Sopenharmony_cisyntax() if (scalar(@ARGV) != 1); 238c2ecf20Sopenharmony_ci$cid = $ARGV[0]; 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci# Do it! 268c2ecf20Sopenharmony_cifor ($i=0; $i < scalar(@components); $i++) { 278c2ecf20Sopenharmony_ci if ($cid eq $components[$i]) { 288c2ecf20Sopenharmony_ci $outfile = eval($cid); 298c2ecf20Sopenharmony_ci die $@ if $@; 308c2ecf20Sopenharmony_ci print STDERR <<EOF; 318c2ecf20Sopenharmony_ciFirmware(s) $outfile extracted successfully. 328c2ecf20Sopenharmony_ciNow copy it(them) to either /usr/lib/hotplug/firmware or /lib/firmware 338c2ecf20Sopenharmony_ci(depending on configuration of firmware hotplug). 348c2ecf20Sopenharmony_ciEOF 358c2ecf20Sopenharmony_ci exit(0); 368c2ecf20Sopenharmony_ci } 378c2ecf20Sopenharmony_ci} 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci# If we get here, it wasn't found 408c2ecf20Sopenharmony_ciprint STDERR "Unknown component \"$cid\"\n"; 418c2ecf20Sopenharmony_cisyntax(); 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci# --------------------------------------------------------------- 478c2ecf20Sopenharmony_ci# Firmware-specific extraction subroutines 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cisub sp8870 { 508c2ecf20Sopenharmony_ci my $sourcefile = "tt_Premium_217g.zip"; 518c2ecf20Sopenharmony_ci my $url = "http://www.softwarepatch.pl/9999ccd06a4813cb827dbb0005071c71/$sourcefile"; 528c2ecf20Sopenharmony_ci my $hash = "53970ec17a538945a6d8cb608a7b3899"; 538c2ecf20Sopenharmony_ci my $outfile = "dvb-fe-sp8870.fw"; 548c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci checkstandard(); 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 598c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 608c2ecf20Sopenharmony_ci verify("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $hash); 618c2ecf20Sopenharmony_ci copy("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $outfile); 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci $outfile; 648c2ecf20Sopenharmony_ci} 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cisub sp887x { 678c2ecf20Sopenharmony_ci my $sourcefile = "Dvbt1.3.57.6.zip"; 688c2ecf20Sopenharmony_ci my $url = "http://www.avermedia.com/software/$sourcefile"; 698c2ecf20Sopenharmony_ci my $cabfile = "DVBT Net Ver1.3.57.6/disk1/data1.cab"; 708c2ecf20Sopenharmony_ci my $hash = "237938d53a7f834c05c42b894ca68ac3"; 718c2ecf20Sopenharmony_ci my $outfile = "dvb-fe-sp887x.fw"; 728c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci checkstandard(); 758c2ecf20Sopenharmony_ci checkunshield(); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 788c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 798c2ecf20Sopenharmony_ci unshield("$tmpdir/$cabfile", $tmpdir); 808c2ecf20Sopenharmony_ci verify("$tmpdir/ZEnglish/sc_main.mc", $hash); 818c2ecf20Sopenharmony_ci copy("$tmpdir/ZEnglish/sc_main.mc", $outfile); 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci $outfile; 848c2ecf20Sopenharmony_ci} 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cisub tda10045 { 878c2ecf20Sopenharmony_ci my $sourcefile = "tt_budget_217g.zip"; 888c2ecf20Sopenharmony_ci my $url = "http://www.technotrend.de/new/217g/$sourcefile"; 898c2ecf20Sopenharmony_ci my $hash = "2105fd5bf37842fbcdfa4bfd58f3594a"; 908c2ecf20Sopenharmony_ci my $outfile = "dvb-fe-tda10045.fw"; 918c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci checkstandard(); 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 968c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 978c2ecf20Sopenharmony_ci extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x37ef9, 30555, "$tmpdir/fwtmp"); 988c2ecf20Sopenharmony_ci verify("$tmpdir/fwtmp", $hash); 998c2ecf20Sopenharmony_ci copy("$tmpdir/fwtmp", $outfile); 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci $outfile; 1028c2ecf20Sopenharmony_ci} 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cisub tda10046 { 1058c2ecf20Sopenharmony_ci my $sourcefile = "TT_PCI_2.19h_28_11_2006.zip"; 1068c2ecf20Sopenharmony_ci my $url = "http://technotrend.com.ua/download/software/219/$sourcefile"; 1078c2ecf20Sopenharmony_ci my $hash = "6a7e1e2f2644b162ff0502367553c72d"; 1088c2ecf20Sopenharmony_ci my $outfile = "dvb-fe-tda10046.fw"; 1098c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci checkstandard(); 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 1148c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 1158c2ecf20Sopenharmony_ci extract("$tmpdir/TT_PCI_2.19h_28_11_2006/software/OEM/PCI/App/ttlcdacc.dll", 0x65389, 24478, "$tmpdir/fwtmp"); 1168c2ecf20Sopenharmony_ci verify("$tmpdir/fwtmp", $hash); 1178c2ecf20Sopenharmony_ci copy("$tmpdir/fwtmp", $outfile); 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci $outfile; 1208c2ecf20Sopenharmony_ci} 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cisub tda10046lifeview { 1238c2ecf20Sopenharmony_ci my $sourcefile = "7%5Cdrv_2.11.02.zip"; 1248c2ecf20Sopenharmony_ci my $url = "http://www.lifeview.hk/dbimages/document/$sourcefile"; 1258c2ecf20Sopenharmony_ci my $hash = "1ea24dee4eea8fe971686981f34fd2e0"; 1268c2ecf20Sopenharmony_ci my $outfile = "dvb-fe-tda10046.fw"; 1278c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ci checkstandard(); 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 1328c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 1338c2ecf20Sopenharmony_ci extract("$tmpdir/LVHybrid.sys", 0x8b088, 24602, "$tmpdir/fwtmp"); 1348c2ecf20Sopenharmony_ci verify("$tmpdir/fwtmp", $hash); 1358c2ecf20Sopenharmony_ci copy("$tmpdir/fwtmp", $outfile); 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci $outfile; 1388c2ecf20Sopenharmony_ci} 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_cisub av7110 { 1418c2ecf20Sopenharmony_ci my $sourcefile = "dvb-ttpci-01.fw-261d"; 1428c2ecf20Sopenharmony_ci my $url = "https://linuxtv.org/downloads/firmware/$sourcefile"; 1438c2ecf20Sopenharmony_ci my $hash = "603431b6259715a8e88f376a53b64e2f"; 1448c2ecf20Sopenharmony_ci my $outfile = "dvb-ttpci-01.fw"; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci checkstandard(); 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 1498c2ecf20Sopenharmony_ci verify($sourcefile, $hash); 1508c2ecf20Sopenharmony_ci copy($sourcefile, $outfile); 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci $outfile; 1538c2ecf20Sopenharmony_ci} 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_cisub dec2000t { 1568c2ecf20Sopenharmony_ci my $sourcefile = "dec217g.exe"; 1578c2ecf20Sopenharmony_ci my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; 1588c2ecf20Sopenharmony_ci my $hash = "bd86f458cee4a8f0a8ce2d20c66215a9"; 1598c2ecf20Sopenharmony_ci my $outfile = "dvb-ttusb-dec-2000t.fw"; 1608c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci checkstandard(); 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 1658c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 1668c2ecf20Sopenharmony_ci verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $hash); 1678c2ecf20Sopenharmony_ci copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $outfile); 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci $outfile; 1708c2ecf20Sopenharmony_ci} 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_cisub dec2540t { 1738c2ecf20Sopenharmony_ci my $sourcefile = "dec217g.exe"; 1748c2ecf20Sopenharmony_ci my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; 1758c2ecf20Sopenharmony_ci my $hash = "53e58f4f5b5c2930beee74a7681fed92"; 1768c2ecf20Sopenharmony_ci my $outfile = "dvb-ttusb-dec-2540t.fw"; 1778c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci checkstandard(); 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 1828c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 1838c2ecf20Sopenharmony_ci verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $hash); 1848c2ecf20Sopenharmony_ci copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $outfile); 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci $outfile; 1878c2ecf20Sopenharmony_ci} 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_cisub dec3000s { 1908c2ecf20Sopenharmony_ci my $sourcefile = "dec217g.exe"; 1918c2ecf20Sopenharmony_ci my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; 1928c2ecf20Sopenharmony_ci my $hash = "b013ececea83f4d6d8d2a29ac7c1b448"; 1938c2ecf20Sopenharmony_ci my $outfile = "dvb-ttusb-dec-3000s.fw"; 1948c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci checkstandard(); 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 1998c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 2008c2ecf20Sopenharmony_ci verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $hash); 2018c2ecf20Sopenharmony_ci copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $outfile); 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci $outfile; 2048c2ecf20Sopenharmony_ci} 2058c2ecf20Sopenharmony_cisub opera1{ 2068c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0); 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci checkstandard(); 2098c2ecf20Sopenharmony_ci my $fwfile1="dvb-usb-opera1-fpga-01.fw"; 2108c2ecf20Sopenharmony_ci my $fwfile2="dvb-usb-opera-01.fw"; 2118c2ecf20Sopenharmony_ci extract("2830SCap2.sys", 0x62e8, 55024, "$tmpdir/opera1-fpga.fw"); 2128c2ecf20Sopenharmony_ci extract("2830SLoad2.sys",0x3178,0x3685-0x3178,"$tmpdir/fw1part1"); 2138c2ecf20Sopenharmony_ci extract("2830SLoad2.sys",0x0980,0x3150-0x0980,"$tmpdir/fw1part2"); 2148c2ecf20Sopenharmony_ci delzero("$tmpdir/fw1part1","$tmpdir/fw1part1-1"); 2158c2ecf20Sopenharmony_ci delzero("$tmpdir/fw1part2","$tmpdir/fw1part2-1"); 2168c2ecf20Sopenharmony_ci verify("$tmpdir/fw1part1-1","5e0909858fdf0b5b09ad48b9fe622e70"); 2178c2ecf20Sopenharmony_ci verify("$tmpdir/fw1part2-1","d6e146f321427e931df2c6fcadac37a1"); 2188c2ecf20Sopenharmony_ci verify("$tmpdir/opera1-fpga.fw","0f8133f5e9051f5f3c1928f7e5a1b07d"); 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci my $RES1="\x01\x92\x7f\x00\x01\x00"; 2218c2ecf20Sopenharmony_ci my $RES0="\x01\x92\x7f\x00\x00\x00"; 2228c2ecf20Sopenharmony_ci my $DAT1="\x01\x00\xe6\x00\x01\x00"; 2238c2ecf20Sopenharmony_ci my $DAT0="\x01\x00\xe6\x00\x00\x00"; 2248c2ecf20Sopenharmony_ci open FW,">$tmpdir/opera.fw"; 2258c2ecf20Sopenharmony_ci print FW "$RES1"; 2268c2ecf20Sopenharmony_ci print FW "$DAT1"; 2278c2ecf20Sopenharmony_ci print FW "$RES1"; 2288c2ecf20Sopenharmony_ci print FW "$DAT1"; 2298c2ecf20Sopenharmony_ci appendfile(FW,"$tmpdir/fw1part1-1"); 2308c2ecf20Sopenharmony_ci print FW "$RES0"; 2318c2ecf20Sopenharmony_ci print FW "$DAT0"; 2328c2ecf20Sopenharmony_ci print FW "$RES1"; 2338c2ecf20Sopenharmony_ci print FW "$DAT1"; 2348c2ecf20Sopenharmony_ci appendfile(FW,"$tmpdir/fw1part2-1"); 2358c2ecf20Sopenharmony_ci print FW "$RES1"; 2368c2ecf20Sopenharmony_ci print FW "$DAT1"; 2378c2ecf20Sopenharmony_ci print FW "$RES0"; 2388c2ecf20Sopenharmony_ci print FW "$DAT0"; 2398c2ecf20Sopenharmony_ci copy ("$tmpdir/opera1-fpga.fw",$fwfile1); 2408c2ecf20Sopenharmony_ci copy ("$tmpdir/opera.fw",$fwfile2); 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci $fwfile1.",".$fwfile2; 2438c2ecf20Sopenharmony_ci} 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_cisub vp7041 { 2468c2ecf20Sopenharmony_ci my $sourcefile = "2.422.zip"; 2478c2ecf20Sopenharmony_ci my $url = "http://www.twinhan.com/files/driver/USB-Ter/$sourcefile"; 2488c2ecf20Sopenharmony_ci my $hash = "e88c9372d1f66609a3e7b072c53fbcfe"; 2498c2ecf20Sopenharmony_ci my $outfile = "dvb-vp7041-2.422.fw"; 2508c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci checkstandard(); 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 2558c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 2568c2ecf20Sopenharmony_ci extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 12503, 3036, "$tmpdir/fwtmp1"); 2578c2ecf20Sopenharmony_ci extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 2207, 10274, "$tmpdir/fwtmp2"); 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci my $CMD = "\000\001\000\222\177\000"; 2608c2ecf20Sopenharmony_ci my $PAD = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"; 2618c2ecf20Sopenharmony_ci my ($FW); 2628c2ecf20Sopenharmony_ci open $FW, ">$tmpdir/fwtmp3"; 2638c2ecf20Sopenharmony_ci print $FW "$CMD\001$PAD"; 2648c2ecf20Sopenharmony_ci print $FW "$CMD\001$PAD"; 2658c2ecf20Sopenharmony_ci appendfile($FW, "$tmpdir/fwtmp1"); 2668c2ecf20Sopenharmony_ci print $FW "$CMD\000$PAD"; 2678c2ecf20Sopenharmony_ci print $FW "$CMD\001$PAD"; 2688c2ecf20Sopenharmony_ci appendfile($FW, "$tmpdir/fwtmp2"); 2698c2ecf20Sopenharmony_ci print $FW "$CMD\001$PAD"; 2708c2ecf20Sopenharmony_ci print $FW "$CMD\000$PAD"; 2718c2ecf20Sopenharmony_ci close($FW); 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci verify("$tmpdir/fwtmp3", $hash); 2748c2ecf20Sopenharmony_ci copy("$tmpdir/fwtmp3", $outfile); 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci $outfile; 2778c2ecf20Sopenharmony_ci} 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_cisub vp7049 { 2808c2ecf20Sopenharmony_ci my $fwfile = "dvb-usb-vp7049-0.95.fw"; 2818c2ecf20Sopenharmony_ci my $url = "http://ao2.it/sites/default/files/blog/2012/11/06/linux-support-digicom-digitune-s-vp7049-udtt7049/$fwfile"; 2828c2ecf20Sopenharmony_ci my $hash = "5609fd295168aea88b25ff43a6f79c36"; 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci checkstandard(); 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci wgetfile($fwfile, $url); 2878c2ecf20Sopenharmony_ci verify($fwfile, $hash); 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci $fwfile; 2908c2ecf20Sopenharmony_ci} 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_cisub dibusb { 2938c2ecf20Sopenharmony_ci my $url = "https://linuxtv.org/downloads/firmware/dvb-usb-dibusb-5.0.0.11.fw"; 2948c2ecf20Sopenharmony_ci my $outfile = "dvb-dibusb-5.0.0.11.fw"; 2958c2ecf20Sopenharmony_ci my $hash = "fa490295a527360ca16dcdf3224ca243"; 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci checkstandard(); 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci wgetfile($outfile, $url); 3008c2ecf20Sopenharmony_ci verify($outfile,$hash); 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci $outfile; 3038c2ecf20Sopenharmony_ci} 3048c2ecf20Sopenharmony_ci 3058c2ecf20Sopenharmony_cisub nxt2002 { 3068c2ecf20Sopenharmony_ci my $sourcefile = "Technisat_DVB-PC_4_4_COMPACT.zip"; 3078c2ecf20Sopenharmony_ci my $url = "http://www.bbti.us/download/windows/$sourcefile"; 3088c2ecf20Sopenharmony_ci my $hash = "476befae8c7c1bb9648954060b1eec1f"; 3098c2ecf20Sopenharmony_ci my $outfile = "dvb-fe-nxt2002.fw"; 3108c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci checkstandard(); 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 3158c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 3168c2ecf20Sopenharmony_ci verify("$tmpdir/SkyNET.sys", $hash); 3178c2ecf20Sopenharmony_ci extract("$tmpdir/SkyNET.sys", 331624, 5908, $outfile); 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci $outfile; 3208c2ecf20Sopenharmony_ci} 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_cisub nxt2004 { 3238c2ecf20Sopenharmony_ci my $sourcefile = "AVerTVHD_MCE_A180_Drv_v1.2.2.16.zip"; 3248c2ecf20Sopenharmony_ci my $url = "http://www.avermedia-usa.com/support/Drivers/$sourcefile"; 3258c2ecf20Sopenharmony_ci my $hash = "111cb885b1e009188346d72acfed024c"; 3268c2ecf20Sopenharmony_ci my $outfile = "dvb-fe-nxt2004.fw"; 3278c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_ci checkstandard(); 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 3328c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 3338c2ecf20Sopenharmony_ci verify("$tmpdir/3xHybrid.sys", $hash); 3348c2ecf20Sopenharmony_ci extract("$tmpdir/3xHybrid.sys", 465304, 9584, $outfile); 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci $outfile; 3378c2ecf20Sopenharmony_ci} 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_cisub or51211 { 3408c2ecf20Sopenharmony_ci my $fwfile = "dvb-fe-or51211.fw"; 3418c2ecf20Sopenharmony_ci my $url = "https://linuxtv.org/downloads/firmware/$fwfile"; 3428c2ecf20Sopenharmony_ci my $hash = "d830949c771a289505bf9eafc225d491"; 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci checkstandard(); 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci wgetfile($fwfile, $url); 3478c2ecf20Sopenharmony_ci verify($fwfile, $hash); 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci $fwfile; 3508c2ecf20Sopenharmony_ci} 3518c2ecf20Sopenharmony_ci 3528c2ecf20Sopenharmony_cisub cx231xx { 3538c2ecf20Sopenharmony_ci my $fwfile = "v4l-cx231xx-avcore-01.fw"; 3548c2ecf20Sopenharmony_ci my $url = "https://linuxtv.org/downloads/firmware/$fwfile"; 3558c2ecf20Sopenharmony_ci my $hash = "7d3bb956dc9df0eafded2b56ba57cc42"; 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci checkstandard(); 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_ci wgetfile($fwfile, $url); 3608c2ecf20Sopenharmony_ci verify($fwfile, $hash); 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_ci $fwfile; 3638c2ecf20Sopenharmony_ci} 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_cisub cx18 { 3668c2ecf20Sopenharmony_ci my $url = "https://linuxtv.org/downloads/firmware/"; 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci my %files = ( 3698c2ecf20Sopenharmony_ci 'v4l-cx23418-apu.fw' => '588f081b562f5c653a3db1ad8f65939a', 3708c2ecf20Sopenharmony_ci 'v4l-cx23418-cpu.fw' => 'b6c7ed64bc44b1a6e0840adaeac39d79', 3718c2ecf20Sopenharmony_ci 'v4l-cx23418-dig.fw' => '95bc688d3e7599fd5800161e9971cc55', 3728c2ecf20Sopenharmony_ci ); 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci checkstandard(); 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci my $allfiles; 3778c2ecf20Sopenharmony_ci foreach my $fwfile (keys %files) { 3788c2ecf20Sopenharmony_ci wgetfile($fwfile, "$url/$fwfile"); 3798c2ecf20Sopenharmony_ci verify($fwfile, $files{$fwfile}); 3808c2ecf20Sopenharmony_ci $allfiles .= " $fwfile"; 3818c2ecf20Sopenharmony_ci } 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ci $allfiles =~ s/^\s//; 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci $allfiles; 3868c2ecf20Sopenharmony_ci} 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_cisub mpc718 { 3898c2ecf20Sopenharmony_ci my $archive = 'Yuan MPC718 TV Tuner Card 2.13.10.1016.zip'; 3908c2ecf20Sopenharmony_ci my $url = "ftp://ftp.work.acer-euro.com/desktop/aspire_idea510/vista/Drivers/$archive"; 3918c2ecf20Sopenharmony_ci my $fwfile = "dvb-cx18-mpc718-mt352.fw"; 3928c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci checkstandard(); 3958c2ecf20Sopenharmony_ci wgetfile($archive, $url); 3968c2ecf20Sopenharmony_ci unzip($archive, $tmpdir); 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ci my $sourcefile = "$tmpdir/Yuan MPC718 TV Tuner Card 2.13.10.1016/mpc718_32bit/yuanrap.sys"; 3998c2ecf20Sopenharmony_ci my $found = 0; 4008c2ecf20Sopenharmony_ci 4018c2ecf20Sopenharmony_ci open IN, '<', $sourcefile or die "Couldn't open $sourcefile to extract $fwfile data\n"; 4028c2ecf20Sopenharmony_ci binmode IN; 4038c2ecf20Sopenharmony_ci open OUT, '>', $fwfile; 4048c2ecf20Sopenharmony_ci binmode OUT; 4058c2ecf20Sopenharmony_ci { 4068c2ecf20Sopenharmony_ci # Block scope because we change the line terminator variable $/ 4078c2ecf20Sopenharmony_ci my $prevlen = 0; 4088c2ecf20Sopenharmony_ci my $currlen; 4098c2ecf20Sopenharmony_ci 4108c2ecf20Sopenharmony_ci # Buried in the data segment are 3 runs of almost identical 4118c2ecf20Sopenharmony_ci # register-value pairs that end in 0x5d 0x01 which is a "TUNER GO" 4128c2ecf20Sopenharmony_ci # command for the MT352. 4138c2ecf20Sopenharmony_ci # Pull out the middle run (because it's easy) of register-value 4148c2ecf20Sopenharmony_ci # pairs to make the "firmware" file. 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_ci local $/ = "\x5d\x01"; # MT352 "TUNER GO" 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci while (<IN>) { 4198c2ecf20Sopenharmony_ci $currlen = length($_); 4208c2ecf20Sopenharmony_ci if ($prevlen == $currlen && $currlen <= 64) { 4218c2ecf20Sopenharmony_ci chop; chop; # Get rid of "TUNER GO" 4228c2ecf20Sopenharmony_ci s/^\0\0//; # get rid of leading 00 00 if it's there 4238c2ecf20Sopenharmony_ci printf OUT "$_"; 4248c2ecf20Sopenharmony_ci $found = 1; 4258c2ecf20Sopenharmony_ci last; 4268c2ecf20Sopenharmony_ci } 4278c2ecf20Sopenharmony_ci $prevlen = $currlen; 4288c2ecf20Sopenharmony_ci } 4298c2ecf20Sopenharmony_ci } 4308c2ecf20Sopenharmony_ci close OUT; 4318c2ecf20Sopenharmony_ci close IN; 4328c2ecf20Sopenharmony_ci if (!$found) { 4338c2ecf20Sopenharmony_ci unlink $fwfile; 4348c2ecf20Sopenharmony_ci die "Couldn't find valid register-value sequence in $sourcefile for $fwfile\n"; 4358c2ecf20Sopenharmony_ci } 4368c2ecf20Sopenharmony_ci $fwfile; 4378c2ecf20Sopenharmony_ci} 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_cisub cx23885 { 4408c2ecf20Sopenharmony_ci my $url = "https://linuxtv.org/downloads/firmware/"; 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_ci my %files = ( 4438c2ecf20Sopenharmony_ci 'v4l-cx23885-avcore-01.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb', 4448c2ecf20Sopenharmony_ci 'v4l-cx23885-enc.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb', 4458c2ecf20Sopenharmony_ci ); 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci checkstandard(); 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci my $allfiles; 4508c2ecf20Sopenharmony_ci foreach my $fwfile (keys %files) { 4518c2ecf20Sopenharmony_ci wgetfile($fwfile, "$url/$fwfile"); 4528c2ecf20Sopenharmony_ci verify($fwfile, $files{$fwfile}); 4538c2ecf20Sopenharmony_ci $allfiles .= " $fwfile"; 4548c2ecf20Sopenharmony_ci } 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_ci $allfiles =~ s/^\s//; 4578c2ecf20Sopenharmony_ci 4588c2ecf20Sopenharmony_ci $allfiles; 4598c2ecf20Sopenharmony_ci} 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_cisub pvrusb2 { 4628c2ecf20Sopenharmony_ci my $url = "https://linuxtv.org/downloads/firmware/"; 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci my %files = ( 4658c2ecf20Sopenharmony_ci 'v4l-cx25840.fw' => 'dadb79e9904fc8af96e8111d9cb59320', 4668c2ecf20Sopenharmony_ci ); 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_ci checkstandard(); 4698c2ecf20Sopenharmony_ci 4708c2ecf20Sopenharmony_ci my $allfiles; 4718c2ecf20Sopenharmony_ci foreach my $fwfile (keys %files) { 4728c2ecf20Sopenharmony_ci wgetfile($fwfile, "$url/$fwfile"); 4738c2ecf20Sopenharmony_ci verify($fwfile, $files{$fwfile}); 4748c2ecf20Sopenharmony_ci $allfiles .= " $fwfile"; 4758c2ecf20Sopenharmony_ci } 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_ci $allfiles =~ s/^\s//; 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_ci $allfiles; 4808c2ecf20Sopenharmony_ci} 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_cisub or51132_qam { 4838c2ecf20Sopenharmony_ci my $fwfile = "dvb-fe-or51132-qam.fw"; 4848c2ecf20Sopenharmony_ci my $url = "https://linuxtv.org/downloads/firmware/$fwfile"; 4858c2ecf20Sopenharmony_ci my $hash = "7702e8938612de46ccadfe9b413cb3b5"; 4868c2ecf20Sopenharmony_ci 4878c2ecf20Sopenharmony_ci checkstandard(); 4888c2ecf20Sopenharmony_ci 4898c2ecf20Sopenharmony_ci wgetfile($fwfile, $url); 4908c2ecf20Sopenharmony_ci verify($fwfile, $hash); 4918c2ecf20Sopenharmony_ci 4928c2ecf20Sopenharmony_ci $fwfile; 4938c2ecf20Sopenharmony_ci} 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_cisub or51132_vsb { 4968c2ecf20Sopenharmony_ci my $fwfile = "dvb-fe-or51132-vsb.fw"; 4978c2ecf20Sopenharmony_ci my $url = "https://linuxtv.org/downloads/firmware/$fwfile"; 4988c2ecf20Sopenharmony_ci my $hash = "c16208e02f36fc439a557ad4c613364a"; 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_ci checkstandard(); 5018c2ecf20Sopenharmony_ci 5028c2ecf20Sopenharmony_ci wgetfile($fwfile, $url); 5038c2ecf20Sopenharmony_ci verify($fwfile, $hash); 5048c2ecf20Sopenharmony_ci 5058c2ecf20Sopenharmony_ci $fwfile; 5068c2ecf20Sopenharmony_ci} 5078c2ecf20Sopenharmony_ci 5088c2ecf20Sopenharmony_cisub bluebird { 5098c2ecf20Sopenharmony_ci my $url = "https://linuxtv.org/download/dvb/firmware/dvb-usb-bluebird-01.fw"; 5108c2ecf20Sopenharmony_ci my $outfile = "dvb-usb-bluebird-01.fw"; 5118c2ecf20Sopenharmony_ci my $hash = "658397cb9eba9101af9031302671f49d"; 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_ci checkstandard(); 5148c2ecf20Sopenharmony_ci 5158c2ecf20Sopenharmony_ci wgetfile($outfile, $url); 5168c2ecf20Sopenharmony_ci verify($outfile,$hash); 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ci $outfile; 5198c2ecf20Sopenharmony_ci} 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_cisub af9015 { 5228c2ecf20Sopenharmony_ci my $sourcefile = "download.ashx?file=57"; 5238c2ecf20Sopenharmony_ci my $url = "http://www.ite.com.tw/EN/Services/$sourcefile"; 5248c2ecf20Sopenharmony_ci my $hash = "e3f08935158038d385ad382442f4bb2d"; 5258c2ecf20Sopenharmony_ci my $outfile = "dvb-usb-af9015.fw"; 5268c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 5278c2ecf20Sopenharmony_ci my $fwoffset = 0x25690; 5288c2ecf20Sopenharmony_ci my $fwlength = 18725; 5298c2ecf20Sopenharmony_ci my ($chunklength, $buf, $rcount); 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_ci checkstandard(); 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url); 5348c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 5358c2ecf20Sopenharmony_ci verify("$tmpdir/Driver/Files/AF15BDA.sys", $hash); 5368c2ecf20Sopenharmony_ci 5378c2ecf20Sopenharmony_ci open INFILE, '<', "$tmpdir/Driver/Files/AF15BDA.sys"; 5388c2ecf20Sopenharmony_ci open OUTFILE, '>', $outfile; 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci sysseek(INFILE, $fwoffset, SEEK_SET); 5418c2ecf20Sopenharmony_ci while($fwlength > 0) { 5428c2ecf20Sopenharmony_ci $chunklength = 55; 5438c2ecf20Sopenharmony_ci $chunklength = $fwlength if ($chunklength > $fwlength); 5448c2ecf20Sopenharmony_ci $rcount = sysread(INFILE, $buf, $chunklength); 5458c2ecf20Sopenharmony_ci die "Ran out of data\n" if ($rcount != $chunklength); 5468c2ecf20Sopenharmony_ci syswrite(OUTFILE, $buf); 5478c2ecf20Sopenharmony_ci sysread(INFILE, $buf, 8); 5488c2ecf20Sopenharmony_ci $fwlength -= $rcount + 8; 5498c2ecf20Sopenharmony_ci } 5508c2ecf20Sopenharmony_ci 5518c2ecf20Sopenharmony_ci close OUTFILE; 5528c2ecf20Sopenharmony_ci close INFILE; 5538c2ecf20Sopenharmony_ci} 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_cisub ngene { 5568c2ecf20Sopenharmony_ci my $url = "http://www.digitaldevices.de/download/"; 5578c2ecf20Sopenharmony_ci my $file1 = "ngene_15.fw"; 5588c2ecf20Sopenharmony_ci my $hash1 = "d798d5a757121174f0dbc5f2833c0c85"; 5598c2ecf20Sopenharmony_ci my $file2 = "ngene_17.fw"; 5608c2ecf20Sopenharmony_ci my $hash2 = "26b687136e127b8ac24b81e0eeafc20b"; 5618c2ecf20Sopenharmony_ci my $url2 = "http://l4m-daten.de/downloads/firmware/dvb-s2/linux/all/"; 5628c2ecf20Sopenharmony_ci my $file3 = "ngene_18.fw"; 5638c2ecf20Sopenharmony_ci my $hash3 = "ebce3ea769a53e3e0b0197c3b3f127e3"; 5648c2ecf20Sopenharmony_ci 5658c2ecf20Sopenharmony_ci checkstandard(); 5668c2ecf20Sopenharmony_ci 5678c2ecf20Sopenharmony_ci wgetfile($file1, $url . $file1); 5688c2ecf20Sopenharmony_ci verify($file1, $hash1); 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_ci wgetfile($file2, $url . $file2); 5718c2ecf20Sopenharmony_ci verify($file2, $hash2); 5728c2ecf20Sopenharmony_ci 5738c2ecf20Sopenharmony_ci wgetfile($file3, $url2 . $file3); 5748c2ecf20Sopenharmony_ci verify($file3, $hash3); 5758c2ecf20Sopenharmony_ci 5768c2ecf20Sopenharmony_ci "$file1, $file2, $file3"; 5778c2ecf20Sopenharmony_ci} 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_cisub az6027{ 5808c2ecf20Sopenharmony_ci my $firmware = "dvb-usb-az6027-03.fw"; 5818c2ecf20Sopenharmony_ci my $url = "http://linux.terratec.de/files/TERRATEC_S7/$firmware"; 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ci wgetfile($firmware, $url); 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_ci $firmware; 5868c2ecf20Sopenharmony_ci} 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_cisub lme2510_lg { 5898c2ecf20Sopenharmony_ci my $sourcefile = "LMEBDA_DVBS.sys"; 5908c2ecf20Sopenharmony_ci my $hash = "fc6017ad01e79890a97ec53bea157ed2"; 5918c2ecf20Sopenharmony_ci my $outfile = "dvb-usb-lme2510-lg.fw"; 5928c2ecf20Sopenharmony_ci my $hasho = "caa065d5fdbd2c09ad57b399bbf55cad"; 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci checkstandard(); 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci verify($sourcefile, $hash); 5978c2ecf20Sopenharmony_ci extract($sourcefile, 4168, 3841, $outfile); 5988c2ecf20Sopenharmony_ci verify($outfile, $hasho); 5998c2ecf20Sopenharmony_ci $outfile; 6008c2ecf20Sopenharmony_ci} 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_cisub lme2510c_s7395 { 6038c2ecf20Sopenharmony_ci my $sourcefile = "US2A0D.sys"; 6048c2ecf20Sopenharmony_ci my $hash = "b0155a8083fb822a3bd47bc360e74601"; 6058c2ecf20Sopenharmony_ci my $outfile = "dvb-usb-lme2510c-s7395.fw"; 6068c2ecf20Sopenharmony_ci my $hasho = "3a3cf1aeebd17b6ddc04cebe131e94cf"; 6078c2ecf20Sopenharmony_ci 6088c2ecf20Sopenharmony_ci checkstandard(); 6098c2ecf20Sopenharmony_ci 6108c2ecf20Sopenharmony_ci verify($sourcefile, $hash); 6118c2ecf20Sopenharmony_ci extract($sourcefile, 37248, 3720, $outfile); 6128c2ecf20Sopenharmony_ci verify($outfile, $hasho); 6138c2ecf20Sopenharmony_ci $outfile; 6148c2ecf20Sopenharmony_ci} 6158c2ecf20Sopenharmony_ci 6168c2ecf20Sopenharmony_cisub lme2510c_s7395_old { 6178c2ecf20Sopenharmony_ci my $sourcefile = "LMEBDA_DVBS7395C.sys"; 6188c2ecf20Sopenharmony_ci my $hash = "7572ae0eb9cdf91baabd7c0ba9e09b31"; 6198c2ecf20Sopenharmony_ci my $outfile = "dvb-usb-lme2510c-s7395.fw"; 6208c2ecf20Sopenharmony_ci my $hasho = "90430c5b435eb5c6f88fd44a9d950674"; 6218c2ecf20Sopenharmony_ci 6228c2ecf20Sopenharmony_ci checkstandard(); 6238c2ecf20Sopenharmony_ci 6248c2ecf20Sopenharmony_ci verify($sourcefile, $hash); 6258c2ecf20Sopenharmony_ci extract($sourcefile, 4208, 3881, $outfile); 6268c2ecf20Sopenharmony_ci verify($outfile, $hasho); 6278c2ecf20Sopenharmony_ci $outfile; 6288c2ecf20Sopenharmony_ci} 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_cisub drxk { 6318c2ecf20Sopenharmony_ci my $url = "http://l4m-daten.de/files/"; 6328c2ecf20Sopenharmony_ci my $zipfile = "DDTuner.zip"; 6338c2ecf20Sopenharmony_ci my $hash = "f5a37b9a20a3534997997c0b1382a3e5"; 6348c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 6358c2ecf20Sopenharmony_ci my $drvfile = "DDTuner.sys"; 6368c2ecf20Sopenharmony_ci my $fwfile = "drxk_a3.mc"; 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ci checkstandard(); 6398c2ecf20Sopenharmony_ci 6408c2ecf20Sopenharmony_ci wgetfile($zipfile, $url . $zipfile); 6418c2ecf20Sopenharmony_ci verify($zipfile, $hash); 6428c2ecf20Sopenharmony_ci unzip($zipfile, $tmpdir); 6438c2ecf20Sopenharmony_ci extract("$tmpdir/$drvfile", 0x14dd8, 15634, "$fwfile"); 6448c2ecf20Sopenharmony_ci 6458c2ecf20Sopenharmony_ci "$fwfile" 6468c2ecf20Sopenharmony_ci} 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_cisub drxk_hauppauge_hvr930c { 6498c2ecf20Sopenharmony_ci my $url = "http://www.wintvcd.co.uk/drivers/"; 6508c2ecf20Sopenharmony_ci my $zipfile = "HVR-9x0_5_10_325_28153_SIGNED.zip"; 6518c2ecf20Sopenharmony_ci my $hash = "83ab82e7e9480ec8bf1ae0155ca63c88"; 6528c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 6538c2ecf20Sopenharmony_ci my $drvfile = "HVR-900/emOEM.sys"; 6548c2ecf20Sopenharmony_ci my $fwfile = "dvb-usb-hauppauge-hvr930c-drxk.fw"; 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ci checkstandard(); 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_ci wgetfile($zipfile, $url . $zipfile); 6598c2ecf20Sopenharmony_ci verify($zipfile, $hash); 6608c2ecf20Sopenharmony_ci unzip($zipfile, $tmpdir); 6618c2ecf20Sopenharmony_ci extract("$tmpdir/$drvfile", 0x117b0, 42692, "$fwfile"); 6628c2ecf20Sopenharmony_ci 6638c2ecf20Sopenharmony_ci "$fwfile" 6648c2ecf20Sopenharmony_ci} 6658c2ecf20Sopenharmony_ci 6668c2ecf20Sopenharmony_cisub drxk_terratec_h5 { 6678c2ecf20Sopenharmony_ci my $url = "https://linuxtv.org/downloads/firmware/"; 6688c2ecf20Sopenharmony_ci my $hash = "19000dada8e2741162ccc50cc91fa7f1"; 6698c2ecf20Sopenharmony_ci my $fwfile = "dvb-usb-terratec-h5-drxk.fw"; 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_ci checkstandard(); 6728c2ecf20Sopenharmony_ci 6738c2ecf20Sopenharmony_ci wgetfile($fwfile, $url . $fwfile); 6748c2ecf20Sopenharmony_ci verify($fwfile, $hash); 6758c2ecf20Sopenharmony_ci 6768c2ecf20Sopenharmony_ci "$fwfile" 6778c2ecf20Sopenharmony_ci} 6788c2ecf20Sopenharmony_ci 6798c2ecf20Sopenharmony_cisub drxk_terratec_htc_stick { 6808c2ecf20Sopenharmony_ci my $url = "http://ftp.terratec.de/Receiver/Cinergy_HTC_Stick/Updates/History/"; 6818c2ecf20Sopenharmony_ci my $zipfile = "Cinergy_HTC_Stick_Drv_5.09.1202.00_XP_Vista_7.exe"; 6828c2ecf20Sopenharmony_ci my $hash = "6722a2442a05423b781721fbc069ed5e"; 6838c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0); 6848c2ecf20Sopenharmony_ci my $drvfile = "Cinergy HTC Stick/BDA Driver 5.09.1202.00/Windows 32 Bit/emOEM.sys"; 6858c2ecf20Sopenharmony_ci my $fwfile = "dvb-usb-terratec-htc-stick-drxk.fw"; 6868c2ecf20Sopenharmony_ci 6878c2ecf20Sopenharmony_ci checkstandard(); 6888c2ecf20Sopenharmony_ci 6898c2ecf20Sopenharmony_ci wgetfile($zipfile, $url . $zipfile); 6908c2ecf20Sopenharmony_ci verify($zipfile, $hash); 6918c2ecf20Sopenharmony_ci unzip($zipfile, $tmpdir); 6928c2ecf20Sopenharmony_ci extract("$tmpdir/$drvfile", 0x4e5c0, 42692, "$fwfile"); 6938c2ecf20Sopenharmony_ci 6948c2ecf20Sopenharmony_ci "$fwfile" 6958c2ecf20Sopenharmony_ci} 6968c2ecf20Sopenharmony_ci 6978c2ecf20Sopenharmony_cisub it9135 { 6988c2ecf20Sopenharmony_ci my $url = "http://www.ite.com.tw/uploads/firmware/v3.25.0.0/"; 6998c2ecf20Sopenharmony_ci my $file1 = "dvb-usb-it9135-01.zip"; 7008c2ecf20Sopenharmony_ci my $fwfile1 = "dvb-usb-it9135-01.fw"; 7018c2ecf20Sopenharmony_ci my $hash1 = "02fcf11174eda84745dae7e61c5ff9ba"; 7028c2ecf20Sopenharmony_ci my $file2 = "dvb-usb-it9135-02.zip"; 7038c2ecf20Sopenharmony_ci my $fwfile2 = "dvb-usb-it9135-02.fw"; 7048c2ecf20Sopenharmony_ci my $hash2 = "d5e1437dc24358578e07999475d4cac9"; 7058c2ecf20Sopenharmony_ci 7068c2ecf20Sopenharmony_ci checkstandard(); 7078c2ecf20Sopenharmony_ci 7088c2ecf20Sopenharmony_ci wgetfile($file1, $url . $file1); 7098c2ecf20Sopenharmony_ci unzip($file1, ""); 7108c2ecf20Sopenharmony_ci verify("$fwfile1", $hash1); 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci wgetfile($file2, $url . $file2); 7138c2ecf20Sopenharmony_ci unzip($file2, ""); 7148c2ecf20Sopenharmony_ci verify("$fwfile2", $hash2); 7158c2ecf20Sopenharmony_ci 7168c2ecf20Sopenharmony_ci "$file1 $file2" 7178c2ecf20Sopenharmony_ci} 7188c2ecf20Sopenharmony_ci 7198c2ecf20Sopenharmony_cisub tda10071 { 7208c2ecf20Sopenharmony_ci my $sourcefile = "PCTV_460e_reference.zip"; 7218c2ecf20Sopenharmony_ci my $url = "ftp://ftp.pctvsystems.com/TV/driver/PCTV%2070e%2080e%20100e%20320e%20330e%20800e/"; 7228c2ecf20Sopenharmony_ci my $hash = "4403de903bf2593464c8d74bbc200a57"; 7238c2ecf20Sopenharmony_ci my $fwfile = "dvb-fe-tda10071.fw"; 7248c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_ci checkstandard(); 7278c2ecf20Sopenharmony_ci 7288c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url . $sourcefile); 7298c2ecf20Sopenharmony_ci verify($sourcefile, $hash); 7308c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 7318c2ecf20Sopenharmony_ci extract("$tmpdir/PCTV\ 70e\ 80e\ 100e\ 320e\ 330e\ 800e/32\ bit/emOEM.sys", 0x67d38, 40504, $fwfile); 7328c2ecf20Sopenharmony_ci 7338c2ecf20Sopenharmony_ci "$fwfile"; 7348c2ecf20Sopenharmony_ci} 7358c2ecf20Sopenharmony_ci 7368c2ecf20Sopenharmony_cisub drxk_pctv { 7378c2ecf20Sopenharmony_ci my $sourcefile = "PCTV_460e_reference.zip"; 7388c2ecf20Sopenharmony_ci my $url = "ftp://ftp.pctvsystems.com/TV/driver/PCTV%2070e%2080e%20100e%20320e%20330e%20800e/"; 7398c2ecf20Sopenharmony_ci my $hash = "4403de903bf2593464c8d74bbc200a57"; 7408c2ecf20Sopenharmony_ci my $fwfile = "dvb-demod-drxk-pctv.fw"; 7418c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_ci checkstandard(); 7448c2ecf20Sopenharmony_ci 7458c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url . $sourcefile); 7468c2ecf20Sopenharmony_ci verify($sourcefile, $hash); 7478c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 7488c2ecf20Sopenharmony_ci extract("$tmpdir/PCTV\ 70e\ 80e\ 100e\ 320e\ 330e\ 800e/32\ bit/emOEM.sys", 0x72b80, 42692, $fwfile); 7498c2ecf20Sopenharmony_ci 7508c2ecf20Sopenharmony_ci "$fwfile"; 7518c2ecf20Sopenharmony_ci} 7528c2ecf20Sopenharmony_ci 7538c2ecf20Sopenharmony_cisub sms1xxx_hcw { 7548c2ecf20Sopenharmony_ci my $url = "http://steventoth.net/linux/sms1xxx/"; 7558c2ecf20Sopenharmony_ci my %files = ( 7568c2ecf20Sopenharmony_ci 'sms1xxx-hcw-55xxx-dvbt-01.fw' => "afb6f9fb9a71d64392e8564ef9577e5a", 7578c2ecf20Sopenharmony_ci 'sms1xxx-hcw-55xxx-dvbt-02.fw' => "b44807098ba26e52cbedeadc052ba58f", 7588c2ecf20Sopenharmony_ci 'sms1xxx-hcw-55xxx-isdbt-02.fw' => "dae934eeea85225acbd63ce6cfe1c9e4", 7598c2ecf20Sopenharmony_ci ); 7608c2ecf20Sopenharmony_ci 7618c2ecf20Sopenharmony_ci checkstandard(); 7628c2ecf20Sopenharmony_ci 7638c2ecf20Sopenharmony_ci my $allfiles; 7648c2ecf20Sopenharmony_ci foreach my $fwfile (keys %files) { 7658c2ecf20Sopenharmony_ci wgetfile($fwfile, "$url/$fwfile"); 7668c2ecf20Sopenharmony_ci verify($fwfile, $files{$fwfile}); 7678c2ecf20Sopenharmony_ci $allfiles .= " $fwfile"; 7688c2ecf20Sopenharmony_ci } 7698c2ecf20Sopenharmony_ci 7708c2ecf20Sopenharmony_ci $allfiles =~ s/^\s//; 7718c2ecf20Sopenharmony_ci 7728c2ecf20Sopenharmony_ci $allfiles; 7738c2ecf20Sopenharmony_ci} 7748c2ecf20Sopenharmony_ci 7758c2ecf20Sopenharmony_cisub si2165 { 7768c2ecf20Sopenharmony_ci my $sourcefile = "model_111xxx_122xxx_driver_6_0_119_31191_WHQL.zip"; 7778c2ecf20Sopenharmony_ci my $url = "http://www.hauppauge.de/files/drivers/"; 7788c2ecf20Sopenharmony_ci my $hash = "76633e7c76b0edee47c3ba18ded99336"; 7798c2ecf20Sopenharmony_ci my $fwfile = "dvb-demod-si2165.fw"; 7808c2ecf20Sopenharmony_ci my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); 7818c2ecf20Sopenharmony_ci 7828c2ecf20Sopenharmony_ci checkstandard(); 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci wgetfile($sourcefile, $url . $sourcefile); 7858c2ecf20Sopenharmony_ci verify($sourcefile, $hash); 7868c2ecf20Sopenharmony_ci unzip($sourcefile, $tmpdir); 7878c2ecf20Sopenharmony_ci extract("$tmpdir/Driver10/Hcw10bda.sys", 0x80788, 0x81E08-0x80788, "$tmpdir/fw1"); 7888c2ecf20Sopenharmony_ci 7898c2ecf20Sopenharmony_ci delzero("$tmpdir/fw1","$tmpdir/fw1-1"); 7908c2ecf20Sopenharmony_ci #verify("$tmpdir/fw1","5e0909858fdf0b5b09ad48b9fe622e70"); 7918c2ecf20Sopenharmony_ci 7928c2ecf20Sopenharmony_ci my $CRC="\x0A\xCC"; 7938c2ecf20Sopenharmony_ci my $BLOCKS_MAIN="\x27"; 7948c2ecf20Sopenharmony_ci open FW,">$fwfile"; 7958c2ecf20Sopenharmony_ci print FW "\x01\x00"; # just a version id for the driver itself 7968c2ecf20Sopenharmony_ci print FW "\x9A"; # fw version 7978c2ecf20Sopenharmony_ci print FW "\x00"; # padding 7988c2ecf20Sopenharmony_ci print FW "$BLOCKS_MAIN"; # number of blocks of main part 7998c2ecf20Sopenharmony_ci print FW "\x00"; # padding 8008c2ecf20Sopenharmony_ci print FW "$CRC"; # 16bit crc value of main part 8018c2ecf20Sopenharmony_ci appendfile(FW,"$tmpdir/fw1"); 8028c2ecf20Sopenharmony_ci 8038c2ecf20Sopenharmony_ci "$fwfile"; 8048c2ecf20Sopenharmony_ci} 8058c2ecf20Sopenharmony_ci 8068c2ecf20Sopenharmony_ci# --------------------------------------------------------------- 8078c2ecf20Sopenharmony_ci# Utilities 8088c2ecf20Sopenharmony_ci 8098c2ecf20Sopenharmony_cisub checkstandard { 8108c2ecf20Sopenharmony_ci if (system("which unzip > /dev/null 2>&1")) { 8118c2ecf20Sopenharmony_ci die "This firmware requires the unzip command - see ftp://ftp.info-zip.org/pub/infozip/UnZip.html\n"; 8128c2ecf20Sopenharmony_ci } 8138c2ecf20Sopenharmony_ci if (system("which md5sum > /dev/null 2>&1")) { 8148c2ecf20Sopenharmony_ci die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n"; 8158c2ecf20Sopenharmony_ci } 8168c2ecf20Sopenharmony_ci if (system("which wget > /dev/null 2>&1")) { 8178c2ecf20Sopenharmony_ci die "This firmware requires the wget command - see http://wget.sunsite.dk/\n"; 8188c2ecf20Sopenharmony_ci } 8198c2ecf20Sopenharmony_ci} 8208c2ecf20Sopenharmony_ci 8218c2ecf20Sopenharmony_cisub checkunshield { 8228c2ecf20Sopenharmony_ci if (system("which unshield > /dev/null 2>&1")) { 8238c2ecf20Sopenharmony_ci die "This firmware requires the unshield command - see http://sourceforge.net/projects/synce/\n"; 8248c2ecf20Sopenharmony_ci } 8258c2ecf20Sopenharmony_ci} 8268c2ecf20Sopenharmony_ci 8278c2ecf20Sopenharmony_cisub wgetfile { 8288c2ecf20Sopenharmony_ci my ($sourcefile, $url) = @_; 8298c2ecf20Sopenharmony_ci 8308c2ecf20Sopenharmony_ci if (! -f $sourcefile) { 8318c2ecf20Sopenharmony_ci system("wget -O \"$sourcefile\" \"$url\"") and die "wget failed - unable to download firmware"; 8328c2ecf20Sopenharmony_ci } 8338c2ecf20Sopenharmony_ci} 8348c2ecf20Sopenharmony_ci 8358c2ecf20Sopenharmony_cisub unzip { 8368c2ecf20Sopenharmony_ci my ($sourcefile, $todir) = @_; 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci $status = system("unzip -q -o -d \"$todir\" \"$sourcefile\" 2>/dev/null" ); 8398c2ecf20Sopenharmony_ci if ((($status >> 8) > 2) || (($status & 0xff) != 0)) { 8408c2ecf20Sopenharmony_ci die ("unzip failed - unable to extract firmware"); 8418c2ecf20Sopenharmony_ci } 8428c2ecf20Sopenharmony_ci} 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_cisub unshield { 8458c2ecf20Sopenharmony_ci my ($sourcefile, $todir) = @_; 8468c2ecf20Sopenharmony_ci 8478c2ecf20Sopenharmony_ci system("unshield x -d \"$todir\" \"$sourcefile\" > /dev/null" ) and die ("unshield failed - unable to extract firmware"); 8488c2ecf20Sopenharmony_ci} 8498c2ecf20Sopenharmony_ci 8508c2ecf20Sopenharmony_cisub verify { 8518c2ecf20Sopenharmony_ci my ($filename, $hash) = @_; 8528c2ecf20Sopenharmony_ci my ($testhash); 8538c2ecf20Sopenharmony_ci 8548c2ecf20Sopenharmony_ci open(CMD, "md5sum \"$filename\"|"); 8558c2ecf20Sopenharmony_ci $testhash = <CMD>; 8568c2ecf20Sopenharmony_ci $testhash =~ /([a-zA-Z0-9]*)/; 8578c2ecf20Sopenharmony_ci $testhash = $1; 8588c2ecf20Sopenharmony_ci close CMD; 8598c2ecf20Sopenharmony_ci die "Hash of extracted file does not match!\n" if ($testhash ne $hash); 8608c2ecf20Sopenharmony_ci} 8618c2ecf20Sopenharmony_ci 8628c2ecf20Sopenharmony_cisub copy { 8638c2ecf20Sopenharmony_ci my ($from, $to) = @_; 8648c2ecf20Sopenharmony_ci 8658c2ecf20Sopenharmony_ci system("cp -f \"$from\" \"$to\"") and die ("cp failed"); 8668c2ecf20Sopenharmony_ci} 8678c2ecf20Sopenharmony_ci 8688c2ecf20Sopenharmony_cisub extract { 8698c2ecf20Sopenharmony_ci my ($infile, $offset, $length, $outfile) = @_; 8708c2ecf20Sopenharmony_ci my ($chunklength, $buf, $rcount); 8718c2ecf20Sopenharmony_ci 8728c2ecf20Sopenharmony_ci open INFILE, "<$infile"; 8738c2ecf20Sopenharmony_ci open OUTFILE, ">$outfile"; 8748c2ecf20Sopenharmony_ci sysseek(INFILE, $offset, SEEK_SET); 8758c2ecf20Sopenharmony_ci while($length > 0) { 8768c2ecf20Sopenharmony_ci # Calc chunk size 8778c2ecf20Sopenharmony_ci $chunklength = 2048; 8788c2ecf20Sopenharmony_ci $chunklength = $length if ($chunklength > $length); 8798c2ecf20Sopenharmony_ci 8808c2ecf20Sopenharmony_ci $rcount = sysread(INFILE, $buf, $chunklength); 8818c2ecf20Sopenharmony_ci die "Ran out of data\n" if ($rcount != $chunklength); 8828c2ecf20Sopenharmony_ci syswrite(OUTFILE, $buf); 8838c2ecf20Sopenharmony_ci $length -= $rcount; 8848c2ecf20Sopenharmony_ci } 8858c2ecf20Sopenharmony_ci close INFILE; 8868c2ecf20Sopenharmony_ci close OUTFILE; 8878c2ecf20Sopenharmony_ci} 8888c2ecf20Sopenharmony_ci 8898c2ecf20Sopenharmony_cisub appendfile { 8908c2ecf20Sopenharmony_ci my ($FH, $infile) = @_; 8918c2ecf20Sopenharmony_ci my ($buf); 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_ci open INFILE, "<$infile"; 8948c2ecf20Sopenharmony_ci while(1) { 8958c2ecf20Sopenharmony_ci $rcount = sysread(INFILE, $buf, 2048); 8968c2ecf20Sopenharmony_ci last if ($rcount == 0); 8978c2ecf20Sopenharmony_ci print $FH $buf; 8988c2ecf20Sopenharmony_ci } 8998c2ecf20Sopenharmony_ci close(INFILE); 9008c2ecf20Sopenharmony_ci} 9018c2ecf20Sopenharmony_ci 9028c2ecf20Sopenharmony_cisub delzero{ 9038c2ecf20Sopenharmony_ci my ($infile,$outfile) =@_; 9048c2ecf20Sopenharmony_ci 9058c2ecf20Sopenharmony_ci open INFILE,"<$infile"; 9068c2ecf20Sopenharmony_ci open OUTFILE,">$outfile"; 9078c2ecf20Sopenharmony_ci while (1){ 9088c2ecf20Sopenharmony_ci $rcount=sysread(INFILE,$buf,22); 9098c2ecf20Sopenharmony_ci $len=ord(substr($buf,0,1)); 9108c2ecf20Sopenharmony_ci print OUTFILE substr($buf,0,1); 9118c2ecf20Sopenharmony_ci print OUTFILE substr($buf,2,$len+3); 9128c2ecf20Sopenharmony_ci last if ($rcount<1); 9138c2ecf20Sopenharmony_ci printf OUTFILE "%c",0; 9148c2ecf20Sopenharmony_ci#print $len." ".length($buf)."\n"; 9158c2ecf20Sopenharmony_ci 9168c2ecf20Sopenharmony_ci } 9178c2ecf20Sopenharmony_ci close(INFILE); 9188c2ecf20Sopenharmony_ci close(OUTFILE); 9198c2ecf20Sopenharmony_ci} 9208c2ecf20Sopenharmony_ci 9218c2ecf20Sopenharmony_cisub syntax() { 9228c2ecf20Sopenharmony_ci print STDERR "syntax: get_dvb_firmware <component>\n"; 9238c2ecf20Sopenharmony_ci print STDERR "Supported components:\n"; 9248c2ecf20Sopenharmony_ci @components = sort @components; 9258c2ecf20Sopenharmony_ci for($i=0; $i < scalar(@components); $i++) { 9268c2ecf20Sopenharmony_ci print STDERR "\t" . $components[$i] . "\n"; 9278c2ecf20Sopenharmony_ci } 9288c2ecf20Sopenharmony_ci exit(1); 9298c2ecf20Sopenharmony_ci} 930