Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 21 | use File::Temp qw/ tempdir /; |
| 22 | use IO::Handle; |
| 23 | |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 24 | @components = ( "sp8870", "sp887x", "tda10045", "tda10046", |
| 25 | "tda10046lifeview", "av7110", "dec2000t", "dec2540t", |
Antonio Ospite | f6b70ec | 2012-12-10 17:37:16 -0300 | [diff] [blame] | 26 | "dec3000s", "vp7041", "vp7049", "dibusb", "nxt2002", "nxt2004", |
Marco Gittler | 5980055 | 2007-07-04 19:18:34 -0300 | [diff] [blame] | 27 | "or51211", "or51132_qam", "or51132_vsb", "bluebird", |
Antti Palosaari | 9254078 | 2009-09-12 09:43:25 -0300 | [diff] [blame] | 28 | "opera1", "cx231xx", "cx18", "cx23885", "pvrusb2", "mpc718", |
Malcolm Priestley | d2f918b | 2010-09-02 17:29:30 -0300 | [diff] [blame] | 29 | "af9015", "ngene", "az6027", "lme2510_lg", "lme2510c_s7395", |
Eddi De Pieri | 6fd7dba | 2011-11-21 06:43:52 -0300 | [diff] [blame] | 30 | "lme2510c_s7395_old", "drxk", "drxk_terratec_h5", |
Malcolm Priestley | 7a016b0 | 2014-02-13 18:32:19 -0300 | [diff] [blame] | 31 | "drxk_hauppauge_hvr930c", "tda10071", "it9135", "drxk_pctv", |
| 32 | "drxk_terratec_htc_stick", "sms1xxx_hcw"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | |
| 34 | # Check args |
| 35 | syntax() if (scalar(@ARGV) != 1); |
| 36 | $cid = $ARGV[0]; |
| 37 | |
| 38 | # Do it! |
| 39 | for ($i=0; $i < scalar(@components); $i++) { |
| 40 | if ($cid eq $components[$i]) { |
| 41 | $outfile = eval($cid); |
| 42 | die $@ if $@; |
Ville Skytt\ä | 12e66f6 | 2006-01-09 15:25:38 -0200 | [diff] [blame] | 43 | print STDERR <<EOF; |
Mauro Carvalho Chehab | b888c5d | 2009-03-23 10:57:15 -0300 | [diff] [blame] | 44 | Firmware(s) $outfile extracted successfully. |
Oliver Endriss | 87147ff | 2010-02-05 07:57:58 -0300 | [diff] [blame] | 45 | Now copy it(them) to either /usr/lib/hotplug/firmware or /lib/firmware |
Ville Skytt\ä | 12e66f6 | 2006-01-09 15:25:38 -0200 | [diff] [blame] | 46 | (depending on configuration of firmware hotplug). |
| 47 | EOF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | exit(0); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | # If we get here, it wasn't found |
| 53 | print STDERR "Unknown component \"$cid\"\n"; |
| 54 | syntax(); |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | # --------------------------------------------------------------- |
| 60 | # Firmware-specific extraction subroutines |
| 61 | |
| 62 | sub sp8870 { |
| 63 | my $sourcefile = "tt_Premium_217g.zip"; |
Michael Krufky | 302170a | 2007-06-15 19:14:52 -0300 | [diff] [blame] | 64 | my $url = "http://www.softwarepatch.pl/9999ccd06a4813cb827dbb0005071c71/$sourcefile"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 79 | sub 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 | |
| 99 | sub 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 | |
| 117 | sub tda10046 { |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 118 | my $sourcefile = "TT_PCI_2.19h_28_11_2006.zip"; |
Mauro Carvalho Chehab | 25ec43d | 2012-09-28 16:16:00 -0300 | [diff] [blame] | 119 | my $url = "http://technotrend.com.ua/download/software/219/$sourcefile"; |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 120 | my $hash = "6a7e1e2f2644b162ff0502367553c72d"; |
| 121 | my $outfile = "dvb-fe-tda10046.fw"; |
| 122 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 124 | checkstandard(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 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); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 132 | $outfile; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | } |
| 134 | |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 135 | sub tda10046lifeview { |
Joseba Goitia Gandiaga | d852d53 | 2009-04-09 18:29:16 -0300 | [diff] [blame] | 136 | my $sourcefile = "7%5Cdrv_2.11.02.zip"; |
| 137 | my $url = "http://www.lifeview.hk/dbimages/document/$sourcefile"; |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | sub 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 | |
| 168 | sub 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 | |
| 185 | sub 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 | |
| 202 | sub 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 | } |
Marco Gittler | 5980055 | 2007-07-04 19:18:34 -0300 | [diff] [blame] | 218 | sub 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 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | |
| 258 | sub 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 | |
Antonio Ospite | f6b70ec | 2012-12-10 17:37:16 -0300 | [diff] [blame] | 292 | sub vp7049 { |
| 293 | my $fwfile = "dvb-usb-vp7049-0.95.fw"; |
| 294 | my $url = "http://ao2.it/sites/default/files/blog/2012/11/06/linux-support-digicom-digitune-s-vp7049-udtt7049/$fwfile"; |
| 295 | my $hash = "5609fd295168aea88b25ff43a6f79c36"; |
| 296 | |
| 297 | checkstandard(); |
| 298 | |
| 299 | wgetfile($fwfile, $url); |
| 300 | verify($fwfile, $hash); |
| 301 | |
| 302 | $fwfile; |
| 303 | } |
| 304 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | sub dibusb { |
Adrian Bunk | d7f2baa | 2006-03-22 00:43:59 +0100 | [diff] [blame] | 306 | my $url = "http://www.linuxtv.org/downloads/firmware/dvb-usb-dibusb-5.0.0.11.fw"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | my $outfile = "dvb-dibusb-5.0.0.11.fw"; |
| 308 | my $hash = "fa490295a527360ca16dcdf3224ca243"; |
| 309 | |
| 310 | checkstandard(); |
| 311 | |
| 312 | wgetfile($outfile, $url); |
| 313 | verify($outfile,$hash); |
| 314 | |
| 315 | $outfile; |
| 316 | } |
| 317 | |
| 318 | sub nxt2002 { |
Michael Krufky | ba5f0a4 | 2006-04-23 01:55:38 -0300 | [diff] [blame] | 319 | my $sourcefile = "Technisat_DVB-PC_4_4_COMPACT.zip"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | my $url = "http://www.bbti.us/download/windows/$sourcefile"; |
Michael Krufky | ba5f0a4 | 2006-04-23 01:55:38 -0300 | [diff] [blame] | 321 | my $hash = "476befae8c7c1bb9648954060b1eec1f"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | my $outfile = "dvb-fe-nxt2002.fw"; |
| 323 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 324 | |
| 325 | checkstandard(); |
Michael Krufky | 50c25ff | 2006-01-09 15:25:34 -0200 | [diff] [blame] | 326 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | wgetfile($sourcefile, $url); |
| 328 | unzip($sourcefile, $tmpdir); |
Michael Krufky | ba5f0a4 | 2006-04-23 01:55:38 -0300 | [diff] [blame] | 329 | verify("$tmpdir/SkyNET.sys", $hash); |
| 330 | extract("$tmpdir/SkyNET.sys", 331624, 5908, $outfile); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | |
| 332 | $outfile; |
| 333 | } |
| 334 | |
Kirk Lapray | 04a4592 | 2005-11-08 21:35:46 -0800 | [diff] [blame] | 335 | sub nxt2004 { |
| 336 | my $sourcefile = "AVerTVHD_MCE_A180_Drv_v1.2.2.16.zip"; |
Jan Ceuleers | f6a061b | 2009-06-11 16:20:23 -0300 | [diff] [blame] | 337 | my $url = "http://www.avermedia-usa.com/support/Drivers/$sourcefile"; |
Kirk Lapray | 04a4592 | 2005-11-08 21:35:46 -0800 | [diff] [blame] | 338 | my $hash = "111cb885b1e009188346d72acfed024c"; |
| 339 | my $outfile = "dvb-fe-nxt2004.fw"; |
| 340 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 341 | |
| 342 | checkstandard(); |
| 343 | |
| 344 | wgetfile($sourcefile, $url); |
| 345 | unzip($sourcefile, $tmpdir); |
| 346 | verify("$tmpdir/3xHybrid.sys", $hash); |
| 347 | extract("$tmpdir/3xHybrid.sys", 465304, 9584, $outfile); |
| 348 | |
| 349 | $outfile; |
| 350 | } |
| 351 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | sub or51211 { |
| 353 | my $fwfile = "dvb-fe-or51211.fw"; |
| 354 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 355 | my $hash = "d830949c771a289505bf9eafc225d491"; |
| 356 | |
| 357 | checkstandard(); |
| 358 | |
| 359 | wgetfile($fwfile, $url); |
| 360 | verify($fwfile, $hash); |
| 361 | |
| 362 | $fwfile; |
| 363 | } |
| 364 | |
Mauro Carvalho Chehab | 06e9509 | 2009-03-19 12:10:00 -0300 | [diff] [blame] | 365 | sub cx231xx { |
| 366 | my $fwfile = "v4l-cx231xx-avcore-01.fw"; |
| 367 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 368 | my $hash = "7d3bb956dc9df0eafded2b56ba57cc42"; |
| 369 | |
| 370 | checkstandard(); |
| 371 | |
| 372 | wgetfile($fwfile, $url); |
| 373 | verify($fwfile, $hash); |
| 374 | |
| 375 | $fwfile; |
| 376 | } |
| 377 | |
Mauro Carvalho Chehab | b888c5d | 2009-03-23 10:57:15 -0300 | [diff] [blame] | 378 | sub cx18 { |
| 379 | my $url = "http://linuxtv.org/downloads/firmware/"; |
| 380 | |
| 381 | my %files = ( |
| 382 | 'v4l-cx23418-apu.fw' => '588f081b562f5c653a3db1ad8f65939a', |
| 383 | 'v4l-cx23418-cpu.fw' => 'b6c7ed64bc44b1a6e0840adaeac39d79', |
| 384 | 'v4l-cx23418-dig.fw' => '95bc688d3e7599fd5800161e9971cc55', |
| 385 | ); |
| 386 | |
| 387 | checkstandard(); |
| 388 | |
| 389 | my $allfiles; |
| 390 | foreach my $fwfile (keys %files) { |
| 391 | wgetfile($fwfile, "$url/$fwfile"); |
| 392 | verify($fwfile, $files{$fwfile}); |
| 393 | $allfiles .= " $fwfile"; |
| 394 | } |
| 395 | |
| 396 | $allfiles =~ s/^\s//; |
| 397 | |
| 398 | $allfiles; |
| 399 | } |
| 400 | |
Andy Walls | 9f38a92 | 2009-07-03 11:33:17 -0300 | [diff] [blame] | 401 | sub mpc718 { |
| 402 | my $archive = 'Yuan MPC718 TV Tuner Card 2.13.10.1016.zip'; |
| 403 | my $url = "ftp://ftp.work.acer-euro.com/desktop/aspire_idea510/vista/Drivers/$archive"; |
| 404 | my $fwfile = "dvb-cx18-mpc718-mt352.fw"; |
| 405 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 406 | |
| 407 | checkstandard(); |
| 408 | wgetfile($archive, $url); |
| 409 | unzip($archive, $tmpdir); |
| 410 | |
| 411 | my $sourcefile = "$tmpdir/Yuan MPC718 TV Tuner Card 2.13.10.1016/mpc718_32bit/yuanrap.sys"; |
| 412 | my $found = 0; |
| 413 | |
| 414 | open IN, '<', $sourcefile or die "Couldn't open $sourcefile to extract $fwfile data\n"; |
| 415 | binmode IN; |
| 416 | open OUT, '>', $fwfile; |
| 417 | binmode OUT; |
| 418 | { |
| 419 | # Block scope because we change the line terminator variable $/ |
| 420 | my $prevlen = 0; |
| 421 | my $currlen; |
| 422 | |
| 423 | # Buried in the data segment are 3 runs of almost identical |
| 424 | # register-value pairs that end in 0x5d 0x01 which is a "TUNER GO" |
| 425 | # command for the MT352. |
| 426 | # Pull out the middle run (because it's easy) of register-value |
| 427 | # pairs to make the "firmware" file. |
| 428 | |
| 429 | local $/ = "\x5d\x01"; # MT352 "TUNER GO" |
| 430 | |
| 431 | while (<IN>) { |
| 432 | $currlen = length($_); |
Andy Walls | 0a68434 | 2009-07-05 16:22:45 -0300 | [diff] [blame] | 433 | if ($prevlen == $currlen && $currlen <= 64) { |
Andy Walls | 9f38a92 | 2009-07-03 11:33:17 -0300 | [diff] [blame] | 434 | chop; chop; # Get rid of "TUNER GO" |
| 435 | s/^\0\0//; # get rid of leading 00 00 if it's there |
| 436 | printf OUT "$_"; |
| 437 | $found = 1; |
| 438 | last; |
| 439 | } |
Andy Walls | 0a68434 | 2009-07-05 16:22:45 -0300 | [diff] [blame] | 440 | $prevlen = $currlen; |
Andy Walls | 9f38a92 | 2009-07-03 11:33:17 -0300 | [diff] [blame] | 441 | } |
| 442 | } |
| 443 | close OUT; |
| 444 | close IN; |
| 445 | if (!$found) { |
| 446 | unlink $fwfile; |
| 447 | die "Couldn't find valid register-value sequence in $sourcefile for $fwfile\n"; |
| 448 | } |
| 449 | $fwfile; |
| 450 | } |
| 451 | |
Mauro Carvalho Chehab | 5297e6f | 2009-03-23 11:46:19 -0300 | [diff] [blame] | 452 | sub cx23885 { |
| 453 | my $url = "http://linuxtv.org/downloads/firmware/"; |
| 454 | |
| 455 | my %files = ( |
| 456 | 'v4l-cx23885-avcore-01.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb', |
| 457 | 'v4l-cx23885-enc.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb', |
Mauro Carvalho Chehab | f65a95b | 2009-03-23 12:35:03 -0300 | [diff] [blame] | 458 | ); |
| 459 | |
| 460 | checkstandard(); |
| 461 | |
| 462 | my $allfiles; |
| 463 | foreach my $fwfile (keys %files) { |
| 464 | wgetfile($fwfile, "$url/$fwfile"); |
| 465 | verify($fwfile, $files{$fwfile}); |
| 466 | $allfiles .= " $fwfile"; |
| 467 | } |
| 468 | |
| 469 | $allfiles =~ s/^\s//; |
| 470 | |
| 471 | $allfiles; |
| 472 | } |
| 473 | |
| 474 | sub pvrusb2 { |
| 475 | my $url = "http://linuxtv.org/downloads/firmware/"; |
| 476 | |
| 477 | my %files = ( |
Mauro Carvalho Chehab | 5297e6f | 2009-03-23 11:46:19 -0300 | [diff] [blame] | 478 | 'v4l-cx25840.fw' => 'dadb79e9904fc8af96e8111d9cb59320', |
| 479 | ); |
| 480 | |
| 481 | checkstandard(); |
| 482 | |
| 483 | my $allfiles; |
| 484 | foreach my $fwfile (keys %files) { |
| 485 | wgetfile($fwfile, "$url/$fwfile"); |
| 486 | verify($fwfile, $files{$fwfile}); |
| 487 | $allfiles .= " $fwfile"; |
| 488 | } |
| 489 | |
| 490 | $allfiles =~ s/^\s//; |
| 491 | |
| 492 | $allfiles; |
| 493 | } |
| 494 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | sub or51132_qam { |
| 496 | my $fwfile = "dvb-fe-or51132-qam.fw"; |
| 497 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 498 | my $hash = "7702e8938612de46ccadfe9b413cb3b5"; |
| 499 | |
| 500 | checkstandard(); |
| 501 | |
| 502 | wgetfile($fwfile, $url); |
| 503 | verify($fwfile, $hash); |
| 504 | |
| 505 | $fwfile; |
| 506 | } |
| 507 | |
| 508 | sub or51132_vsb { |
| 509 | my $fwfile = "dvb-fe-or51132-vsb.fw"; |
| 510 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 511 | my $hash = "c16208e02f36fc439a557ad4c613364a"; |
| 512 | |
| 513 | checkstandard(); |
| 514 | |
| 515 | wgetfile($fwfile, $url); |
| 516 | verify($fwfile, $hash); |
| 517 | |
| 518 | $fwfile; |
| 519 | } |
| 520 | |
Michael Krufky | d8e6acf | 2006-01-09 15:32:42 -0200 | [diff] [blame] | 521 | sub bluebird { |
Michael Krufky | cec4183 | 2006-01-09 18:21:40 -0200 | [diff] [blame] | 522 | my $url = "http://www.linuxtv.org/download/dvb/firmware/dvb-usb-bluebird-01.fw"; |
Michael Krufky | d8e6acf | 2006-01-09 15:32:42 -0200 | [diff] [blame] | 523 | my $outfile = "dvb-usb-bluebird-01.fw"; |
| 524 | my $hash = "658397cb9eba9101af9031302671f49d"; |
| 525 | |
| 526 | checkstandard(); |
| 527 | |
| 528 | wgetfile($outfile, $url); |
| 529 | verify($outfile,$hash); |
| 530 | |
| 531 | $outfile; |
| 532 | } |
| 533 | |
Antti Palosaari | 9254078 | 2009-09-12 09:43:25 -0300 | [diff] [blame] | 534 | sub af9015 { |
| 535 | my $sourcefile = "download.ashx?file=57"; |
| 536 | my $url = "http://www.ite.com.tw/EN/Services/$sourcefile"; |
Antti Palosaari | 4e9f567 | 2010-05-14 15:24:28 -0300 | [diff] [blame] | 537 | my $hash = "e3f08935158038d385ad382442f4bb2d"; |
Antti Palosaari | 9254078 | 2009-09-12 09:43:25 -0300 | [diff] [blame] | 538 | my $outfile = "dvb-usb-af9015.fw"; |
| 539 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
Antti Palosaari | 4e9f567 | 2010-05-14 15:24:28 -0300 | [diff] [blame] | 540 | my $fwoffset = 0x25690; |
| 541 | my $fwlength = 18725; |
Antti Palosaari | 9254078 | 2009-09-12 09:43:25 -0300 | [diff] [blame] | 542 | my ($chunklength, $buf, $rcount); |
| 543 | |
| 544 | checkstandard(); |
| 545 | |
| 546 | wgetfile($sourcefile, $url); |
| 547 | unzip($sourcefile, $tmpdir); |
| 548 | verify("$tmpdir/Driver/Files/AF15BDA.sys", $hash); |
| 549 | |
| 550 | open INFILE, '<', "$tmpdir/Driver/Files/AF15BDA.sys"; |
| 551 | open OUTFILE, '>', $outfile; |
| 552 | |
| 553 | sysseek(INFILE, $fwoffset, SEEK_SET); |
| 554 | while($fwlength > 0) { |
| 555 | $chunklength = 55; |
| 556 | $chunklength = $fwlength if ($chunklength > $fwlength); |
| 557 | $rcount = sysread(INFILE, $buf, $chunklength); |
| 558 | die "Ran out of data\n" if ($rcount != $chunklength); |
| 559 | syswrite(OUTFILE, $buf); |
| 560 | sysread(INFILE, $buf, 8); |
| 561 | $fwlength -= $rcount + 8; |
| 562 | } |
| 563 | |
| 564 | close OUTFILE; |
| 565 | close INFILE; |
| 566 | } |
| 567 | |
Oliver Endriss | e7e41d3 | 2010-02-05 07:52:44 -0300 | [diff] [blame] | 568 | sub ngene { |
| 569 | my $url = "http://www.digitaldevices.de/download/"; |
| 570 | my $file1 = "ngene_15.fw"; |
| 571 | my $hash1 = "d798d5a757121174f0dbc5f2833c0c85"; |
| 572 | my $file2 = "ngene_17.fw"; |
| 573 | my $hash2 = "26b687136e127b8ac24b81e0eeafc20b"; |
Oliver Endriss | f33de4a | 2011-01-10 06:36:19 -0300 | [diff] [blame] | 574 | my $url2 = "http://l4m-daten.de/downloads/firmware/dvb-s2/linux/all/"; |
| 575 | my $file3 = "ngene_18.fw"; |
| 576 | my $hash3 = "ebce3ea769a53e3e0b0197c3b3f127e3"; |
Oliver Endriss | e7e41d3 | 2010-02-05 07:52:44 -0300 | [diff] [blame] | 577 | |
| 578 | checkstandard(); |
| 579 | |
| 580 | wgetfile($file1, $url . $file1); |
| 581 | verify($file1, $hash1); |
| 582 | |
| 583 | wgetfile($file2, $url . $file2); |
| 584 | verify($file2, $hash2); |
| 585 | |
Oliver Endriss | f33de4a | 2011-01-10 06:36:19 -0300 | [diff] [blame] | 586 | wgetfile($file3, $url2 . $file3); |
| 587 | verify($file3, $hash3); |
| 588 | |
| 589 | "$file1, $file2, $file3"; |
Oliver Endriss | e7e41d3 | 2010-02-05 07:52:44 -0300 | [diff] [blame] | 590 | } |
| 591 | |
Renzo Dani | 89d328d | 2010-07-06 07:23:33 -0300 | [diff] [blame] | 592 | sub az6027{ |
Renzo Dani | 89d328d | 2010-07-06 07:23:33 -0300 | [diff] [blame] | 593 | my $firmware = "dvb-usb-az6027-03.fw"; |
Renzo Dani | 873c07d | 2011-10-09 06:43:50 -0300 | [diff] [blame] | 594 | my $url = "http://linux.terratec.de/files/TERRATEC_S7/$firmware"; |
Renzo Dani | 89d328d | 2010-07-06 07:23:33 -0300 | [diff] [blame] | 595 | |
Renzo Dani | 873c07d | 2011-10-09 06:43:50 -0300 | [diff] [blame] | 596 | wgetfile($firmware, $url); |
Renzo Dani | 89d328d | 2010-07-06 07:23:33 -0300 | [diff] [blame] | 597 | |
| 598 | $firmware; |
| 599 | } |
Malcolm Priestley | d2f918b | 2010-09-02 17:29:30 -0300 | [diff] [blame] | 600 | |
| 601 | sub lme2510_lg { |
| 602 | my $sourcefile = "LMEBDA_DVBS.sys"; |
| 603 | my $hash = "fc6017ad01e79890a97ec53bea157ed2"; |
| 604 | my $outfile = "dvb-usb-lme2510-lg.fw"; |
| 605 | my $hasho = "caa065d5fdbd2c09ad57b399bbf55cad"; |
| 606 | |
| 607 | checkstandard(); |
| 608 | |
| 609 | verify($sourcefile, $hash); |
| 610 | extract($sourcefile, 4168, 3841, $outfile); |
| 611 | verify($outfile, $hasho); |
| 612 | $outfile; |
| 613 | } |
| 614 | |
| 615 | sub lme2510c_s7395 { |
| 616 | my $sourcefile = "US2A0D.sys"; |
| 617 | my $hash = "b0155a8083fb822a3bd47bc360e74601"; |
| 618 | my $outfile = "dvb-usb-lme2510c-s7395.fw"; |
| 619 | my $hasho = "3a3cf1aeebd17b6ddc04cebe131e94cf"; |
| 620 | |
| 621 | checkstandard(); |
| 622 | |
| 623 | verify($sourcefile, $hash); |
| 624 | extract($sourcefile, 37248, 3720, $outfile); |
| 625 | verify($outfile, $hasho); |
| 626 | $outfile; |
| 627 | } |
| 628 | |
| 629 | sub lme2510c_s7395_old { |
| 630 | my $sourcefile = "LMEBDA_DVBS7395C.sys"; |
| 631 | my $hash = "7572ae0eb9cdf91baabd7c0ba9e09b31"; |
| 632 | my $outfile = "dvb-usb-lme2510c-s7395.fw"; |
| 633 | my $hasho = "90430c5b435eb5c6f88fd44a9d950674"; |
| 634 | |
| 635 | checkstandard(); |
| 636 | |
| 637 | verify($sourcefile, $hash); |
| 638 | extract($sourcefile, 4208, 3881, $outfile); |
| 639 | verify($outfile, $hasho); |
| 640 | $outfile; |
| 641 | } |
| 642 | |
Oliver Endriss | f9004df | 2011-07-03 13:53:50 -0300 | [diff] [blame] | 643 | sub drxk { |
| 644 | my $url = "http://l4m-daten.de/files/"; |
| 645 | my $zipfile = "DDTuner.zip"; |
| 646 | my $hash = "f5a37b9a20a3534997997c0b1382a3e5"; |
| 647 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 648 | my $drvfile = "DDTuner.sys"; |
| 649 | my $fwfile = "drxk_a3.mc"; |
| 650 | |
| 651 | checkstandard(); |
| 652 | |
| 653 | wgetfile($zipfile, $url . $zipfile); |
| 654 | verify($zipfile, $hash); |
| 655 | unzip($zipfile, $tmpdir); |
| 656 | extract("$tmpdir/$drvfile", 0x14dd8, 15634, "$fwfile"); |
| 657 | |
| 658 | "$fwfile" |
| 659 | } |
| 660 | |
Eddi De Pieri | 6fd7dba | 2011-11-21 06:43:52 -0300 | [diff] [blame] | 661 | sub drxk_hauppauge_hvr930c { |
| 662 | my $url = "http://www.wintvcd.co.uk/drivers/"; |
| 663 | my $zipfile = "HVR-9x0_5_10_325_28153_SIGNED.zip"; |
| 664 | my $hash = "83ab82e7e9480ec8bf1ae0155ca63c88"; |
| 665 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 666 | my $drvfile = "HVR-900/emOEM.sys"; |
| 667 | my $fwfile = "dvb-usb-hauppauge-hvr930c-drxk.fw"; |
| 668 | |
| 669 | checkstandard(); |
| 670 | |
| 671 | wgetfile($zipfile, $url . $zipfile); |
| 672 | verify($zipfile, $hash); |
| 673 | unzip($zipfile, $tmpdir); |
| 674 | extract("$tmpdir/$drvfile", 0x117b0, 42692, "$fwfile"); |
| 675 | |
| 676 | "$fwfile" |
| 677 | } |
| 678 | |
Mauro Carvalho Chehab | 8b9456a | 2011-07-11 14:33:51 -0300 | [diff] [blame] | 679 | sub drxk_terratec_h5 { |
| 680 | my $url = "http://www.linuxtv.org/downloads/firmware/"; |
| 681 | my $hash = "19000dada8e2741162ccc50cc91fa7f1"; |
| 682 | my $fwfile = "dvb-usb-terratec-h5-drxk.fw"; |
| 683 | |
| 684 | checkstandard(); |
| 685 | |
| 686 | wgetfile($fwfile, $url . $fwfile); |
| 687 | verify($fwfile, $hash); |
| 688 | |
| 689 | "$fwfile" |
| 690 | } |
| 691 | |
Martin Blumenstingl | 7bdc0fb | 2012-06-12 18:19:26 -0300 | [diff] [blame] | 692 | sub drxk_terratec_htc_stick { |
Martin Blumenstingl | 8cd7085 | 2013-01-01 08:54:26 -0300 | [diff] [blame] | 693 | my $url = "http://ftp.terratec.de/Receiver/Cinergy_HTC_Stick/Updates/History/"; |
Martin Blumenstingl | 7bdc0fb | 2012-06-12 18:19:26 -0300 | [diff] [blame] | 694 | my $zipfile = "Cinergy_HTC_Stick_Drv_5.09.1202.00_XP_Vista_7.exe"; |
| 695 | my $hash = "6722a2442a05423b781721fbc069ed5e"; |
| 696 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0); |
| 697 | my $drvfile = "Cinergy HTC Stick/BDA Driver 5.09.1202.00/Windows 32 Bit/emOEM.sys"; |
| 698 | my $fwfile = "dvb-usb-terratec-htc-stick-drxk.fw"; |
| 699 | |
| 700 | checkstandard(); |
| 701 | |
| 702 | wgetfile($zipfile, $url . $zipfile); |
| 703 | verify($zipfile, $hash); |
| 704 | unzip($zipfile, $tmpdir); |
| 705 | extract("$tmpdir/$drvfile", 0x4e5c0, 42692, "$fwfile"); |
| 706 | |
| 707 | "$fwfile" |
| 708 | } |
| 709 | |
Benjamin Larsson | 3188d54 | 2011-07-27 08:43:38 -0300 | [diff] [blame] | 710 | sub it9135 { |
Malcolm Priestley | 7330f7c | 2011-11-30 17:17:43 -0300 | [diff] [blame] | 711 | my $sourcefile = "dvb-usb-it9135.zip"; |
| 712 | my $url = "http://www.ite.com.tw/uploads/firmware/v3.6.0.0/$sourcefile"; |
| 713 | my $hash = "1e55f6c8833f1d0ae067c2bb2953e6a9"; |
| 714 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0); |
| 715 | my $outfile = "dvb-usb-it9135.fw"; |
| 716 | my $fwfile1 = "dvb-usb-it9135-01.fw"; |
| 717 | my $fwfile2 = "dvb-usb-it9135-02.fw"; |
| 718 | |
| 719 | checkstandard(); |
| 720 | |
| 721 | wgetfile($sourcefile, $url); |
| 722 | unzip($sourcefile, $tmpdir); |
| 723 | verify("$tmpdir/$outfile", $hash); |
| 724 | extract("$tmpdir/$outfile", 64, 8128, "$fwfile1"); |
| 725 | extract("$tmpdir/$outfile", 12866, 5817, "$fwfile2"); |
| 726 | |
| 727 | "$fwfile1 $fwfile2" |
| 728 | } |
| 729 | |
Antti Palosaari | 465301b1 | 2011-08-01 23:34:58 -0300 | [diff] [blame] | 730 | sub tda10071 { |
Antti Palosaari | ead2095 | 2011-08-02 11:35:06 -0300 | [diff] [blame] | 731 | my $sourcefile = "PCTV_460e_reference.zip"; |
Antti Palosaari | 465301b1 | 2011-08-01 23:34:58 -0300 | [diff] [blame] | 732 | my $url = "ftp://ftp.pctvsystems.com/TV/driver/PCTV%2070e%2080e%20100e%20320e%20330e%20800e/"; |
| 733 | my $hash = "4403de903bf2593464c8d74bbc200a57"; |
| 734 | my $fwfile = "dvb-fe-tda10071.fw"; |
| 735 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
Benjamin Larsson | 3188d54 | 2011-07-27 08:43:38 -0300 | [diff] [blame] | 736 | |
Antti Palosaari | 465301b1 | 2011-08-01 23:34:58 -0300 | [diff] [blame] | 737 | checkstandard(); |
| 738 | |
| 739 | wgetfile($sourcefile, $url . $sourcefile); |
| 740 | verify($sourcefile, $hash); |
| 741 | unzip($sourcefile, $tmpdir); |
| 742 | extract("$tmpdir/PCTV\ 70e\ 80e\ 100e\ 320e\ 330e\ 800e/32\ bit/emOEM.sys", 0x67d38, 40504, $fwfile); |
| 743 | |
| 744 | "$fwfile"; |
| 745 | } |
Benjamin Larsson | 3188d54 | 2011-07-27 08:43:38 -0300 | [diff] [blame] | 746 | |
Antti Palosaari | 662f960 | 2012-03-19 11:48:18 -0300 | [diff] [blame] | 747 | sub drxk_pctv { |
| 748 | my $sourcefile = "PCTV_460e_reference.zip"; |
| 749 | my $url = "ftp://ftp.pctvsystems.com/TV/driver/PCTV%2070e%2080e%20100e%20320e%20330e%20800e/"; |
| 750 | my $hash = "4403de903bf2593464c8d74bbc200a57"; |
| 751 | my $fwfile = "dvb-demod-drxk-pctv.fw"; |
| 752 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 753 | |
| 754 | checkstandard(); |
| 755 | |
| 756 | wgetfile($sourcefile, $url . $sourcefile); |
| 757 | verify($sourcefile, $hash); |
| 758 | unzip($sourcefile, $tmpdir); |
| 759 | extract("$tmpdir/PCTV\ 70e\ 80e\ 100e\ 320e\ 330e\ 800e/32\ bit/emOEM.sys", 0x72b80, 42692, $fwfile); |
| 760 | |
| 761 | "$fwfile"; |
| 762 | } |
| 763 | |
Mauro Carvalho Chehab | f244e6c | 2012-07-05 22:35:55 -0300 | [diff] [blame] | 764 | sub sms1xxx_hcw { |
| 765 | my $url = "http://steventoth.net/linux/sms1xxx/"; |
| 766 | my %files = ( |
| 767 | 'sms1xxx-hcw-55xxx-dvbt-01.fw' => "afb6f9fb9a71d64392e8564ef9577e5a", |
| 768 | 'sms1xxx-hcw-55xxx-dvbt-02.fw' => "b44807098ba26e52cbedeadc052ba58f", |
| 769 | 'sms1xxx-hcw-55xxx-isdbt-02.fw' => "dae934eeea85225acbd63ce6cfe1c9e4", |
| 770 | ); |
| 771 | |
| 772 | checkstandard(); |
| 773 | |
| 774 | my $allfiles; |
| 775 | foreach my $fwfile (keys %files) { |
| 776 | wgetfile($fwfile, "$url/$fwfile"); |
| 777 | verify($fwfile, $files{$fwfile}); |
| 778 | $allfiles .= " $fwfile"; |
| 779 | } |
| 780 | |
| 781 | $allfiles =~ s/^\s//; |
| 782 | |
| 783 | $allfiles; |
| 784 | } |
| 785 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | # --------------------------------------------------------------- |
| 787 | # Utilities |
| 788 | |
| 789 | sub checkstandard { |
| 790 | if (system("which unzip > /dev/null 2>&1")) { |
| 791 | die "This firmware requires the unzip command - see ftp://ftp.info-zip.org/pub/infozip/UnZip.html\n"; |
| 792 | } |
| 793 | if (system("which md5sum > /dev/null 2>&1")) { |
| 794 | die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n"; |
| 795 | } |
| 796 | if (system("which wget > /dev/null 2>&1")) { |
| 797 | die "This firmware requires the wget command - see http://wget.sunsite.dk/\n"; |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | sub checkunshield { |
| 802 | if (system("which unshield > /dev/null 2>&1")) { |
| 803 | die "This firmware requires the unshield command - see http://sourceforge.net/projects/synce/\n"; |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | sub wgetfile { |
| 808 | my ($sourcefile, $url) = @_; |
| 809 | |
| 810 | if (! -f $sourcefile) { |
| 811 | system("wget -O \"$sourcefile\" \"$url\"") and die "wget failed - unable to download firmware"; |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | sub unzip { |
| 816 | my ($sourcefile, $todir) = @_; |
| 817 | |
| 818 | $status = system("unzip -q -o -d \"$todir\" \"$sourcefile\" 2>/dev/null" ); |
| 819 | if ((($status >> 8) > 2) || (($status & 0xff) != 0)) { |
| 820 | die ("unzip failed - unable to extract firmware"); |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | sub unshield { |
| 825 | my ($sourcefile, $todir) = @_; |
| 826 | |
| 827 | system("unshield x -d \"$todir\" \"$sourcefile\" > /dev/null" ) and die ("unshield failed - unable to extract firmware"); |
| 828 | } |
| 829 | |
| 830 | sub verify { |
| 831 | my ($filename, $hash) = @_; |
| 832 | my ($testhash); |
| 833 | |
| 834 | open(CMD, "md5sum \"$filename\"|"); |
| 835 | $testhash = <CMD>; |
| 836 | $testhash =~ /([a-zA-Z0-9]*)/; |
| 837 | $testhash = $1; |
| 838 | close CMD; |
| 839 | die "Hash of extracted file does not match!\n" if ($testhash ne $hash); |
| 840 | } |
| 841 | |
| 842 | sub copy { |
| 843 | my ($from, $to) = @_; |
| 844 | |
| 845 | system("cp -f \"$from\" \"$to\"") and die ("cp failed"); |
| 846 | } |
| 847 | |
| 848 | sub extract { |
| 849 | my ($infile, $offset, $length, $outfile) = @_; |
| 850 | my ($chunklength, $buf, $rcount); |
| 851 | |
| 852 | open INFILE, "<$infile"; |
| 853 | open OUTFILE, ">$outfile"; |
| 854 | sysseek(INFILE, $offset, SEEK_SET); |
| 855 | while($length > 0) { |
| 856 | # Calc chunk size |
| 857 | $chunklength = 2048; |
| 858 | $chunklength = $length if ($chunklength > $length); |
| 859 | |
| 860 | $rcount = sysread(INFILE, $buf, $chunklength); |
| 861 | die "Ran out of data\n" if ($rcount != $chunklength); |
| 862 | syswrite(OUTFILE, $buf); |
| 863 | $length -= $rcount; |
| 864 | } |
| 865 | close INFILE; |
| 866 | close OUTFILE; |
| 867 | } |
| 868 | |
| 869 | sub appendfile { |
| 870 | my ($FH, $infile) = @_; |
| 871 | my ($buf); |
| 872 | |
| 873 | open INFILE, "<$infile"; |
| 874 | while(1) { |
| 875 | $rcount = sysread(INFILE, $buf, 2048); |
| 876 | last if ($rcount == 0); |
| 877 | print $FH $buf; |
| 878 | } |
| 879 | close(INFILE); |
| 880 | } |
| 881 | |
Marco Gittler | 5980055 | 2007-07-04 19:18:34 -0300 | [diff] [blame] | 882 | sub delzero{ |
| 883 | my ($infile,$outfile) =@_; |
| 884 | |
| 885 | open INFILE,"<$infile"; |
| 886 | open OUTFILE,">$outfile"; |
| 887 | while (1){ |
| 888 | $rcount=sysread(INFILE,$buf,22); |
| 889 | $len=ord(substr($buf,0,1)); |
| 890 | print OUTFILE substr($buf,0,1); |
| 891 | print OUTFILE substr($buf,2,$len+3); |
| 892 | last if ($rcount<1); |
| 893 | printf OUTFILE "%c",0; |
| 894 | #print $len." ".length($buf)."\n"; |
| 895 | |
| 896 | } |
| 897 | close(INFILE); |
| 898 | close(OUTFILE); |
| 899 | } |
| 900 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | sub syntax() { |
| 902 | print STDERR "syntax: get_dvb_firmware <component>\n"; |
| 903 | print STDERR "Supported components:\n"; |
Oliver Endriss | 87147ff | 2010-02-05 07:57:58 -0300 | [diff] [blame] | 904 | @components = sort @components; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | for($i=0; $i < scalar(@components); $i++) { |
| 906 | print STDERR "\t" . $components[$i] . "\n"; |
| 907 | } |
| 908 | exit(1); |
| 909 | } |