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", |
| 26 | "dec3000s", "vp7041", "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", |
Mauro Carvalho Chehab | 8b9456a | 2011-07-11 14:33:51 -0300 | [diff] [blame] | 30 | "lme2510c_s7395_old", "drxk", "drxk_terratec_h5"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | # Check args |
| 33 | syntax() if (scalar(@ARGV) != 1); |
| 34 | $cid = $ARGV[0]; |
| 35 | |
| 36 | # Do it! |
| 37 | for ($i=0; $i < scalar(@components); $i++) { |
| 38 | if ($cid eq $components[$i]) { |
| 39 | $outfile = eval($cid); |
| 40 | die $@ if $@; |
Ville Skytt\ä | 12e66f6 | 2006-01-09 15:25:38 -0200 | [diff] [blame] | 41 | print STDERR <<EOF; |
Mauro Carvalho Chehab | b888c5d | 2009-03-23 10:57:15 -0300 | [diff] [blame] | 42 | Firmware(s) $outfile extracted successfully. |
Oliver Endriss | 87147ff | 2010-02-05 07:57:58 -0300 | [diff] [blame] | 43 | 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] | 44 | (depending on configuration of firmware hotplug). |
| 45 | EOF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | exit(0); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | # If we get here, it wasn't found |
| 51 | print STDERR "Unknown component \"$cid\"\n"; |
| 52 | syntax(); |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | # --------------------------------------------------------------- |
| 58 | # Firmware-specific extraction subroutines |
| 59 | |
| 60 | sub sp8870 { |
| 61 | my $sourcefile = "tt_Premium_217g.zip"; |
Michael Krufky | 302170a | 2007-06-15 19:14:52 -0300 | [diff] [blame] | 62 | my $url = "http://www.softwarepatch.pl/9999ccd06a4813cb827dbb0005071c71/$sourcefile"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | my $hash = "53970ec17a538945a6d8cb608a7b3899"; |
| 64 | my $outfile = "dvb-fe-sp8870.fw"; |
| 65 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 66 | |
| 67 | checkstandard(); |
| 68 | |
| 69 | wgetfile($sourcefile, $url); |
| 70 | unzip($sourcefile, $tmpdir); |
| 71 | verify("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $hash); |
| 72 | copy("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $outfile); |
| 73 | |
| 74 | $outfile; |
| 75 | } |
| 76 | |
| 77 | sub sp887x { |
| 78 | my $sourcefile = "Dvbt1.3.57.6.zip"; |
| 79 | my $url = "http://www.avermedia.com/software/$sourcefile"; |
| 80 | my $cabfile = "DVBT Net Ver1.3.57.6/disk1/data1.cab"; |
| 81 | my $hash = "237938d53a7f834c05c42b894ca68ac3"; |
| 82 | my $outfile = "dvb-fe-sp887x.fw"; |
| 83 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 84 | |
| 85 | checkstandard(); |
| 86 | checkunshield(); |
| 87 | |
| 88 | wgetfile($sourcefile, $url); |
| 89 | unzip($sourcefile, $tmpdir); |
| 90 | unshield("$tmpdir/$cabfile", $tmpdir); |
| 91 | verify("$tmpdir/ZEnglish/sc_main.mc", $hash); |
| 92 | copy("$tmpdir/ZEnglish/sc_main.mc", $outfile); |
| 93 | |
| 94 | $outfile; |
| 95 | } |
| 96 | |
| 97 | sub tda10045 { |
| 98 | my $sourcefile = "tt_budget_217g.zip"; |
| 99 | my $url = "http://www.technotrend.de/new/217g/$sourcefile"; |
| 100 | my $hash = "2105fd5bf37842fbcdfa4bfd58f3594a"; |
| 101 | my $outfile = "dvb-fe-tda10045.fw"; |
| 102 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 103 | |
| 104 | checkstandard(); |
| 105 | |
| 106 | wgetfile($sourcefile, $url); |
| 107 | unzip($sourcefile, $tmpdir); |
| 108 | extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x37ef9, 30555, "$tmpdir/fwtmp"); |
| 109 | verify("$tmpdir/fwtmp", $hash); |
| 110 | copy("$tmpdir/fwtmp", $outfile); |
| 111 | |
| 112 | $outfile; |
| 113 | } |
| 114 | |
| 115 | sub tda10046 { |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 116 | my $sourcefile = "TT_PCI_2.19h_28_11_2006.zip"; |
Joseba Goitia Gandiaga | d852d53 | 2009-04-09 18:29:16 -0300 | [diff] [blame] | 117 | my $url = "http://www.tt-download.com/download/updates/219/$sourcefile"; |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 118 | my $hash = "6a7e1e2f2644b162ff0502367553c72d"; |
| 119 | my $outfile = "dvb-fe-tda10046.fw"; |
| 120 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 122 | checkstandard(); |
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 | wgetfile($sourcefile, $url); |
| 125 | unzip($sourcefile, $tmpdir); |
| 126 | extract("$tmpdir/TT_PCI_2.19h_28_11_2006/software/OEM/PCI/App/ttlcdacc.dll", 0x65389, 24478, "$tmpdir/fwtmp"); |
| 127 | verify("$tmpdir/fwtmp", $hash); |
| 128 | copy("$tmpdir/fwtmp", $outfile); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 130 | $outfile; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 133 | sub tda10046lifeview { |
Joseba Goitia Gandiaga | d852d53 | 2009-04-09 18:29:16 -0300 | [diff] [blame] | 134 | my $sourcefile = "7%5Cdrv_2.11.02.zip"; |
| 135 | my $url = "http://www.lifeview.hk/dbimages/document/$sourcefile"; |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 136 | my $hash = "1ea24dee4eea8fe971686981f34fd2e0"; |
| 137 | my $outfile = "dvb-fe-tda10046.fw"; |
| 138 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 139 | |
| 140 | checkstandard(); |
| 141 | |
| 142 | wgetfile($sourcefile, $url); |
| 143 | unzip($sourcefile, $tmpdir); |
| 144 | extract("$tmpdir/LVHybrid.sys", 0x8b088, 24602, "$tmpdir/fwtmp"); |
| 145 | verify("$tmpdir/fwtmp", $hash); |
| 146 | copy("$tmpdir/fwtmp", $outfile); |
| 147 | |
| 148 | $outfile; |
| 149 | } |
| 150 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | sub av7110 { |
| 152 | my $sourcefile = "dvb-ttpci-01.fw-261d"; |
| 153 | my $url = "http://www.linuxtv.org/downloads/firmware/$sourcefile"; |
| 154 | my $hash = "603431b6259715a8e88f376a53b64e2f"; |
| 155 | my $outfile = "dvb-ttpci-01.fw"; |
| 156 | |
| 157 | checkstandard(); |
| 158 | |
| 159 | wgetfile($sourcefile, $url); |
| 160 | verify($sourcefile, $hash); |
| 161 | copy($sourcefile, $outfile); |
| 162 | |
| 163 | $outfile; |
| 164 | } |
| 165 | |
| 166 | sub dec2000t { |
| 167 | my $sourcefile = "dec217g.exe"; |
| 168 | my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; |
| 169 | my $hash = "bd86f458cee4a8f0a8ce2d20c66215a9"; |
| 170 | my $outfile = "dvb-ttusb-dec-2000t.fw"; |
| 171 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 172 | |
| 173 | checkstandard(); |
| 174 | |
| 175 | wgetfile($sourcefile, $url); |
| 176 | unzip($sourcefile, $tmpdir); |
| 177 | verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $hash); |
| 178 | copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $outfile); |
| 179 | |
| 180 | $outfile; |
| 181 | } |
| 182 | |
| 183 | sub dec2540t { |
| 184 | my $sourcefile = "dec217g.exe"; |
| 185 | my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; |
| 186 | my $hash = "53e58f4f5b5c2930beee74a7681fed92"; |
| 187 | my $outfile = "dvb-ttusb-dec-2540t.fw"; |
| 188 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 189 | |
| 190 | checkstandard(); |
| 191 | |
| 192 | wgetfile($sourcefile, $url); |
| 193 | unzip($sourcefile, $tmpdir); |
| 194 | verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $hash); |
| 195 | copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $outfile); |
| 196 | |
| 197 | $outfile; |
| 198 | } |
| 199 | |
| 200 | sub dec3000s { |
| 201 | my $sourcefile = "dec217g.exe"; |
| 202 | my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; |
| 203 | my $hash = "b013ececea83f4d6d8d2a29ac7c1b448"; |
| 204 | my $outfile = "dvb-ttusb-dec-3000s.fw"; |
| 205 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 206 | |
| 207 | checkstandard(); |
| 208 | |
| 209 | wgetfile($sourcefile, $url); |
| 210 | unzip($sourcefile, $tmpdir); |
| 211 | verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $hash); |
| 212 | copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $outfile); |
| 213 | |
| 214 | $outfile; |
| 215 | } |
Marco Gittler | 5980055 | 2007-07-04 19:18:34 -0300 | [diff] [blame] | 216 | sub opera1{ |
| 217 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0); |
| 218 | |
| 219 | checkstandard(); |
| 220 | my $fwfile1="dvb-usb-opera1-fpga-01.fw"; |
| 221 | my $fwfile2="dvb-usb-opera-01.fw"; |
| 222 | extract("2830SCap2.sys", 0x62e8, 55024, "$tmpdir/opera1-fpga.fw"); |
| 223 | extract("2830SLoad2.sys",0x3178,0x3685-0x3178,"$tmpdir/fw1part1"); |
| 224 | extract("2830SLoad2.sys",0x0980,0x3150-0x0980,"$tmpdir/fw1part2"); |
| 225 | delzero("$tmpdir/fw1part1","$tmpdir/fw1part1-1"); |
| 226 | delzero("$tmpdir/fw1part2","$tmpdir/fw1part2-1"); |
| 227 | verify("$tmpdir/fw1part1-1","5e0909858fdf0b5b09ad48b9fe622e70"); |
| 228 | verify("$tmpdir/fw1part2-1","d6e146f321427e931df2c6fcadac37a1"); |
| 229 | verify("$tmpdir/opera1-fpga.fw","0f8133f5e9051f5f3c1928f7e5a1b07d"); |
| 230 | |
| 231 | my $RES1="\x01\x92\x7f\x00\x01\x00"; |
| 232 | my $RES0="\x01\x92\x7f\x00\x00\x00"; |
| 233 | my $DAT1="\x01\x00\xe6\x00\x01\x00"; |
| 234 | my $DAT0="\x01\x00\xe6\x00\x00\x00"; |
| 235 | open FW,">$tmpdir/opera.fw"; |
| 236 | print FW "$RES1"; |
| 237 | print FW "$DAT1"; |
| 238 | print FW "$RES1"; |
| 239 | print FW "$DAT1"; |
| 240 | appendfile(FW,"$tmpdir/fw1part1-1"); |
| 241 | print FW "$RES0"; |
| 242 | print FW "$DAT0"; |
| 243 | print FW "$RES1"; |
| 244 | print FW "$DAT1"; |
| 245 | appendfile(FW,"$tmpdir/fw1part2-1"); |
| 246 | print FW "$RES1"; |
| 247 | print FW "$DAT1"; |
| 248 | print FW "$RES0"; |
| 249 | print FW "$DAT0"; |
| 250 | copy ("$tmpdir/opera1-fpga.fw",$fwfile1); |
| 251 | copy ("$tmpdir/opera.fw",$fwfile2); |
| 252 | |
| 253 | $fwfile1.",".$fwfile2; |
| 254 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | |
| 256 | sub vp7041 { |
| 257 | my $sourcefile = "2.422.zip"; |
| 258 | my $url = "http://www.twinhan.com/files/driver/USB-Ter/$sourcefile"; |
| 259 | my $hash = "e88c9372d1f66609a3e7b072c53fbcfe"; |
| 260 | my $outfile = "dvb-vp7041-2.422.fw"; |
| 261 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 262 | |
| 263 | checkstandard(); |
| 264 | |
| 265 | wgetfile($sourcefile, $url); |
| 266 | unzip($sourcefile, $tmpdir); |
| 267 | extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 12503, 3036, "$tmpdir/fwtmp1"); |
| 268 | extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 2207, 10274, "$tmpdir/fwtmp2"); |
| 269 | |
| 270 | my $CMD = "\000\001\000\222\177\000"; |
| 271 | my $PAD = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"; |
| 272 | my ($FW); |
| 273 | open $FW, ">$tmpdir/fwtmp3"; |
| 274 | print $FW "$CMD\001$PAD"; |
| 275 | print $FW "$CMD\001$PAD"; |
| 276 | appendfile($FW, "$tmpdir/fwtmp1"); |
| 277 | print $FW "$CMD\000$PAD"; |
| 278 | print $FW "$CMD\001$PAD"; |
| 279 | appendfile($FW, "$tmpdir/fwtmp2"); |
| 280 | print $FW "$CMD\001$PAD"; |
| 281 | print $FW "$CMD\000$PAD"; |
| 282 | close($FW); |
| 283 | |
| 284 | verify("$tmpdir/fwtmp3", $hash); |
| 285 | copy("$tmpdir/fwtmp3", $outfile); |
| 286 | |
| 287 | $outfile; |
| 288 | } |
| 289 | |
| 290 | sub dibusb { |
Adrian Bunk | d7f2baa | 2006-03-22 00:43:59 +0100 | [diff] [blame] | 291 | 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] | 292 | my $outfile = "dvb-dibusb-5.0.0.11.fw"; |
| 293 | my $hash = "fa490295a527360ca16dcdf3224ca243"; |
| 294 | |
| 295 | checkstandard(); |
| 296 | |
| 297 | wgetfile($outfile, $url); |
| 298 | verify($outfile,$hash); |
| 299 | |
| 300 | $outfile; |
| 301 | } |
| 302 | |
| 303 | sub nxt2002 { |
Michael Krufky | ba5f0a4 | 2006-04-23 01:55:38 -0300 | [diff] [blame] | 304 | my $sourcefile = "Technisat_DVB-PC_4_4_COMPACT.zip"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | my $url = "http://www.bbti.us/download/windows/$sourcefile"; |
Michael Krufky | ba5f0a4 | 2006-04-23 01:55:38 -0300 | [diff] [blame] | 306 | my $hash = "476befae8c7c1bb9648954060b1eec1f"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | my $outfile = "dvb-fe-nxt2002.fw"; |
| 308 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 309 | |
| 310 | checkstandard(); |
Michael Krufky | 50c25ff | 2006-01-09 15:25:34 -0200 | [diff] [blame] | 311 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | wgetfile($sourcefile, $url); |
| 313 | unzip($sourcefile, $tmpdir); |
Michael Krufky | ba5f0a4 | 2006-04-23 01:55:38 -0300 | [diff] [blame] | 314 | verify("$tmpdir/SkyNET.sys", $hash); |
| 315 | extract("$tmpdir/SkyNET.sys", 331624, 5908, $outfile); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | |
| 317 | $outfile; |
| 318 | } |
| 319 | |
Kirk Lapray | 04a4592 | 2005-11-08 21:35:46 -0800 | [diff] [blame] | 320 | sub nxt2004 { |
| 321 | my $sourcefile = "AVerTVHD_MCE_A180_Drv_v1.2.2.16.zip"; |
Jan Ceuleers | f6a061b | 2009-06-11 16:20:23 -0300 | [diff] [blame] | 322 | my $url = "http://www.avermedia-usa.com/support/Drivers/$sourcefile"; |
Kirk Lapray | 04a4592 | 2005-11-08 21:35:46 -0800 | [diff] [blame] | 323 | my $hash = "111cb885b1e009188346d72acfed024c"; |
| 324 | my $outfile = "dvb-fe-nxt2004.fw"; |
| 325 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 326 | |
| 327 | checkstandard(); |
| 328 | |
| 329 | wgetfile($sourcefile, $url); |
| 330 | unzip($sourcefile, $tmpdir); |
| 331 | verify("$tmpdir/3xHybrid.sys", $hash); |
| 332 | extract("$tmpdir/3xHybrid.sys", 465304, 9584, $outfile); |
| 333 | |
| 334 | $outfile; |
| 335 | } |
| 336 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | sub or51211 { |
| 338 | my $fwfile = "dvb-fe-or51211.fw"; |
| 339 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 340 | my $hash = "d830949c771a289505bf9eafc225d491"; |
| 341 | |
| 342 | checkstandard(); |
| 343 | |
| 344 | wgetfile($fwfile, $url); |
| 345 | verify($fwfile, $hash); |
| 346 | |
| 347 | $fwfile; |
| 348 | } |
| 349 | |
Mauro Carvalho Chehab | 06e9509 | 2009-03-19 12:10:00 -0300 | [diff] [blame] | 350 | sub cx231xx { |
| 351 | my $fwfile = "v4l-cx231xx-avcore-01.fw"; |
| 352 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 353 | my $hash = "7d3bb956dc9df0eafded2b56ba57cc42"; |
| 354 | |
| 355 | checkstandard(); |
| 356 | |
| 357 | wgetfile($fwfile, $url); |
| 358 | verify($fwfile, $hash); |
| 359 | |
| 360 | $fwfile; |
| 361 | } |
| 362 | |
Mauro Carvalho Chehab | b888c5d | 2009-03-23 10:57:15 -0300 | [diff] [blame] | 363 | sub cx18 { |
| 364 | my $url = "http://linuxtv.org/downloads/firmware/"; |
| 365 | |
| 366 | my %files = ( |
| 367 | 'v4l-cx23418-apu.fw' => '588f081b562f5c653a3db1ad8f65939a', |
| 368 | 'v4l-cx23418-cpu.fw' => 'b6c7ed64bc44b1a6e0840adaeac39d79', |
| 369 | 'v4l-cx23418-dig.fw' => '95bc688d3e7599fd5800161e9971cc55', |
| 370 | ); |
| 371 | |
| 372 | checkstandard(); |
| 373 | |
| 374 | my $allfiles; |
| 375 | foreach my $fwfile (keys %files) { |
| 376 | wgetfile($fwfile, "$url/$fwfile"); |
| 377 | verify($fwfile, $files{$fwfile}); |
| 378 | $allfiles .= " $fwfile"; |
| 379 | } |
| 380 | |
| 381 | $allfiles =~ s/^\s//; |
| 382 | |
| 383 | $allfiles; |
| 384 | } |
| 385 | |
Andy Walls | 9f38a92 | 2009-07-03 11:33:17 -0300 | [diff] [blame] | 386 | sub mpc718 { |
| 387 | my $archive = 'Yuan MPC718 TV Tuner Card 2.13.10.1016.zip'; |
| 388 | my $url = "ftp://ftp.work.acer-euro.com/desktop/aspire_idea510/vista/Drivers/$archive"; |
| 389 | my $fwfile = "dvb-cx18-mpc718-mt352.fw"; |
| 390 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 391 | |
| 392 | checkstandard(); |
| 393 | wgetfile($archive, $url); |
| 394 | unzip($archive, $tmpdir); |
| 395 | |
| 396 | my $sourcefile = "$tmpdir/Yuan MPC718 TV Tuner Card 2.13.10.1016/mpc718_32bit/yuanrap.sys"; |
| 397 | my $found = 0; |
| 398 | |
| 399 | open IN, '<', $sourcefile or die "Couldn't open $sourcefile to extract $fwfile data\n"; |
| 400 | binmode IN; |
| 401 | open OUT, '>', $fwfile; |
| 402 | binmode OUT; |
| 403 | { |
| 404 | # Block scope because we change the line terminator variable $/ |
| 405 | my $prevlen = 0; |
| 406 | my $currlen; |
| 407 | |
| 408 | # Buried in the data segment are 3 runs of almost identical |
| 409 | # register-value pairs that end in 0x5d 0x01 which is a "TUNER GO" |
| 410 | # command for the MT352. |
| 411 | # Pull out the middle run (because it's easy) of register-value |
| 412 | # pairs to make the "firmware" file. |
| 413 | |
| 414 | local $/ = "\x5d\x01"; # MT352 "TUNER GO" |
| 415 | |
| 416 | while (<IN>) { |
| 417 | $currlen = length($_); |
Andy Walls | 0a68434 | 2009-07-05 16:22:45 -0300 | [diff] [blame] | 418 | if ($prevlen == $currlen && $currlen <= 64) { |
Andy Walls | 9f38a92 | 2009-07-03 11:33:17 -0300 | [diff] [blame] | 419 | chop; chop; # Get rid of "TUNER GO" |
| 420 | s/^\0\0//; # get rid of leading 00 00 if it's there |
| 421 | printf OUT "$_"; |
| 422 | $found = 1; |
| 423 | last; |
| 424 | } |
Andy Walls | 0a68434 | 2009-07-05 16:22:45 -0300 | [diff] [blame] | 425 | $prevlen = $currlen; |
Andy Walls | 9f38a92 | 2009-07-03 11:33:17 -0300 | [diff] [blame] | 426 | } |
| 427 | } |
| 428 | close OUT; |
| 429 | close IN; |
| 430 | if (!$found) { |
| 431 | unlink $fwfile; |
| 432 | die "Couldn't find valid register-value sequence in $sourcefile for $fwfile\n"; |
| 433 | } |
| 434 | $fwfile; |
| 435 | } |
| 436 | |
Mauro Carvalho Chehab | 5297e6f | 2009-03-23 11:46:19 -0300 | [diff] [blame] | 437 | sub cx23885 { |
| 438 | my $url = "http://linuxtv.org/downloads/firmware/"; |
| 439 | |
| 440 | my %files = ( |
| 441 | 'v4l-cx23885-avcore-01.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb', |
| 442 | 'v4l-cx23885-enc.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb', |
Mauro Carvalho Chehab | f65a95b | 2009-03-23 12:35:03 -0300 | [diff] [blame] | 443 | ); |
| 444 | |
| 445 | checkstandard(); |
| 446 | |
| 447 | my $allfiles; |
| 448 | foreach my $fwfile (keys %files) { |
| 449 | wgetfile($fwfile, "$url/$fwfile"); |
| 450 | verify($fwfile, $files{$fwfile}); |
| 451 | $allfiles .= " $fwfile"; |
| 452 | } |
| 453 | |
| 454 | $allfiles =~ s/^\s//; |
| 455 | |
| 456 | $allfiles; |
| 457 | } |
| 458 | |
| 459 | sub pvrusb2 { |
| 460 | my $url = "http://linuxtv.org/downloads/firmware/"; |
| 461 | |
| 462 | my %files = ( |
Mauro Carvalho Chehab | 5297e6f | 2009-03-23 11:46:19 -0300 | [diff] [blame] | 463 | 'v4l-cx25840.fw' => 'dadb79e9904fc8af96e8111d9cb59320', |
| 464 | ); |
| 465 | |
| 466 | checkstandard(); |
| 467 | |
| 468 | my $allfiles; |
| 469 | foreach my $fwfile (keys %files) { |
| 470 | wgetfile($fwfile, "$url/$fwfile"); |
| 471 | verify($fwfile, $files{$fwfile}); |
| 472 | $allfiles .= " $fwfile"; |
| 473 | } |
| 474 | |
| 475 | $allfiles =~ s/^\s//; |
| 476 | |
| 477 | $allfiles; |
| 478 | } |
| 479 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | sub or51132_qam { |
| 481 | my $fwfile = "dvb-fe-or51132-qam.fw"; |
| 482 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 483 | my $hash = "7702e8938612de46ccadfe9b413cb3b5"; |
| 484 | |
| 485 | checkstandard(); |
| 486 | |
| 487 | wgetfile($fwfile, $url); |
| 488 | verify($fwfile, $hash); |
| 489 | |
| 490 | $fwfile; |
| 491 | } |
| 492 | |
| 493 | sub or51132_vsb { |
| 494 | my $fwfile = "dvb-fe-or51132-vsb.fw"; |
| 495 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 496 | my $hash = "c16208e02f36fc439a557ad4c613364a"; |
| 497 | |
| 498 | checkstandard(); |
| 499 | |
| 500 | wgetfile($fwfile, $url); |
| 501 | verify($fwfile, $hash); |
| 502 | |
| 503 | $fwfile; |
| 504 | } |
| 505 | |
Michael Krufky | d8e6acf | 2006-01-09 15:32:42 -0200 | [diff] [blame] | 506 | sub bluebird { |
Michael Krufky | cec4183 | 2006-01-09 18:21:40 -0200 | [diff] [blame] | 507 | 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] | 508 | my $outfile = "dvb-usb-bluebird-01.fw"; |
| 509 | my $hash = "658397cb9eba9101af9031302671f49d"; |
| 510 | |
| 511 | checkstandard(); |
| 512 | |
| 513 | wgetfile($outfile, $url); |
| 514 | verify($outfile,$hash); |
| 515 | |
| 516 | $outfile; |
| 517 | } |
| 518 | |
Antti Palosaari | 9254078 | 2009-09-12 09:43:25 -0300 | [diff] [blame] | 519 | sub af9015 { |
| 520 | my $sourcefile = "download.ashx?file=57"; |
| 521 | my $url = "http://www.ite.com.tw/EN/Services/$sourcefile"; |
Antti Palosaari | 4e9f567 | 2010-05-14 15:24:28 -0300 | [diff] [blame] | 522 | my $hash = "e3f08935158038d385ad382442f4bb2d"; |
Antti Palosaari | 9254078 | 2009-09-12 09:43:25 -0300 | [diff] [blame] | 523 | my $outfile = "dvb-usb-af9015.fw"; |
| 524 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
Antti Palosaari | 4e9f567 | 2010-05-14 15:24:28 -0300 | [diff] [blame] | 525 | my $fwoffset = 0x25690; |
| 526 | my $fwlength = 18725; |
Antti Palosaari | 9254078 | 2009-09-12 09:43:25 -0300 | [diff] [blame] | 527 | my ($chunklength, $buf, $rcount); |
| 528 | |
| 529 | checkstandard(); |
| 530 | |
| 531 | wgetfile($sourcefile, $url); |
| 532 | unzip($sourcefile, $tmpdir); |
| 533 | verify("$tmpdir/Driver/Files/AF15BDA.sys", $hash); |
| 534 | |
| 535 | open INFILE, '<', "$tmpdir/Driver/Files/AF15BDA.sys"; |
| 536 | open OUTFILE, '>', $outfile; |
| 537 | |
| 538 | sysseek(INFILE, $fwoffset, SEEK_SET); |
| 539 | while($fwlength > 0) { |
| 540 | $chunklength = 55; |
| 541 | $chunklength = $fwlength if ($chunklength > $fwlength); |
| 542 | $rcount = sysread(INFILE, $buf, $chunklength); |
| 543 | die "Ran out of data\n" if ($rcount != $chunklength); |
| 544 | syswrite(OUTFILE, $buf); |
| 545 | sysread(INFILE, $buf, 8); |
| 546 | $fwlength -= $rcount + 8; |
| 547 | } |
| 548 | |
| 549 | close OUTFILE; |
| 550 | close INFILE; |
| 551 | } |
| 552 | |
Oliver Endriss | e7e41d3 | 2010-02-05 07:52:44 -0300 | [diff] [blame] | 553 | sub ngene { |
| 554 | my $url = "http://www.digitaldevices.de/download/"; |
| 555 | my $file1 = "ngene_15.fw"; |
| 556 | my $hash1 = "d798d5a757121174f0dbc5f2833c0c85"; |
| 557 | my $file2 = "ngene_17.fw"; |
| 558 | my $hash2 = "26b687136e127b8ac24b81e0eeafc20b"; |
Oliver Endriss | f33de4a | 2011-01-10 06:36:19 -0300 | [diff] [blame] | 559 | my $url2 = "http://l4m-daten.de/downloads/firmware/dvb-s2/linux/all/"; |
| 560 | my $file3 = "ngene_18.fw"; |
| 561 | my $hash3 = "ebce3ea769a53e3e0b0197c3b3f127e3"; |
Oliver Endriss | e7e41d3 | 2010-02-05 07:52:44 -0300 | [diff] [blame] | 562 | |
| 563 | checkstandard(); |
| 564 | |
| 565 | wgetfile($file1, $url . $file1); |
| 566 | verify($file1, $hash1); |
| 567 | |
| 568 | wgetfile($file2, $url . $file2); |
| 569 | verify($file2, $hash2); |
| 570 | |
Oliver Endriss | f33de4a | 2011-01-10 06:36:19 -0300 | [diff] [blame] | 571 | wgetfile($file3, $url2 . $file3); |
| 572 | verify($file3, $hash3); |
| 573 | |
| 574 | "$file1, $file2, $file3"; |
Oliver Endriss | e7e41d3 | 2010-02-05 07:52:44 -0300 | [diff] [blame] | 575 | } |
| 576 | |
Renzo Dani | 89d328d | 2010-07-06 07:23:33 -0300 | [diff] [blame] | 577 | sub az6027{ |
| 578 | my $file = "AZ6027_Linux_Driver.tar.gz"; |
| 579 | my $url = "http://linux.terratec.de/files/$file"; |
| 580 | my $firmware = "dvb-usb-az6027-03.fw"; |
| 581 | |
| 582 | wgetfile($file, $url); |
| 583 | |
| 584 | #untar |
| 585 | if( system("tar xzvf $file $firmware")){ |
| 586 | die "failed to untar firmware"; |
| 587 | } |
| 588 | if( system("rm $file")){ |
| 589 | die ("unable to remove unnecessary files"); |
| 590 | } |
| 591 | |
| 592 | $firmware; |
| 593 | } |
Malcolm Priestley | d2f918b | 2010-09-02 17:29:30 -0300 | [diff] [blame] | 594 | |
| 595 | sub lme2510_lg { |
| 596 | my $sourcefile = "LMEBDA_DVBS.sys"; |
| 597 | my $hash = "fc6017ad01e79890a97ec53bea157ed2"; |
| 598 | my $outfile = "dvb-usb-lme2510-lg.fw"; |
| 599 | my $hasho = "caa065d5fdbd2c09ad57b399bbf55cad"; |
| 600 | |
| 601 | checkstandard(); |
| 602 | |
| 603 | verify($sourcefile, $hash); |
| 604 | extract($sourcefile, 4168, 3841, $outfile); |
| 605 | verify($outfile, $hasho); |
| 606 | $outfile; |
| 607 | } |
| 608 | |
| 609 | sub lme2510c_s7395 { |
| 610 | my $sourcefile = "US2A0D.sys"; |
| 611 | my $hash = "b0155a8083fb822a3bd47bc360e74601"; |
| 612 | my $outfile = "dvb-usb-lme2510c-s7395.fw"; |
| 613 | my $hasho = "3a3cf1aeebd17b6ddc04cebe131e94cf"; |
| 614 | |
| 615 | checkstandard(); |
| 616 | |
| 617 | verify($sourcefile, $hash); |
| 618 | extract($sourcefile, 37248, 3720, $outfile); |
| 619 | verify($outfile, $hasho); |
| 620 | $outfile; |
| 621 | } |
| 622 | |
| 623 | sub lme2510c_s7395_old { |
| 624 | my $sourcefile = "LMEBDA_DVBS7395C.sys"; |
| 625 | my $hash = "7572ae0eb9cdf91baabd7c0ba9e09b31"; |
| 626 | my $outfile = "dvb-usb-lme2510c-s7395.fw"; |
| 627 | my $hasho = "90430c5b435eb5c6f88fd44a9d950674"; |
| 628 | |
| 629 | checkstandard(); |
| 630 | |
| 631 | verify($sourcefile, $hash); |
| 632 | extract($sourcefile, 4208, 3881, $outfile); |
| 633 | verify($outfile, $hasho); |
| 634 | $outfile; |
| 635 | } |
| 636 | |
Oliver Endriss | f9004df | 2011-07-03 13:53:50 -0300 | [diff] [blame] | 637 | sub drxk { |
| 638 | my $url = "http://l4m-daten.de/files/"; |
| 639 | my $zipfile = "DDTuner.zip"; |
| 640 | my $hash = "f5a37b9a20a3534997997c0b1382a3e5"; |
| 641 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 642 | my $drvfile = "DDTuner.sys"; |
| 643 | my $fwfile = "drxk_a3.mc"; |
| 644 | |
| 645 | checkstandard(); |
| 646 | |
| 647 | wgetfile($zipfile, $url . $zipfile); |
| 648 | verify($zipfile, $hash); |
| 649 | unzip($zipfile, $tmpdir); |
| 650 | extract("$tmpdir/$drvfile", 0x14dd8, 15634, "$fwfile"); |
| 651 | |
| 652 | "$fwfile" |
| 653 | } |
| 654 | |
Mauro Carvalho Chehab | 8b9456a | 2011-07-11 14:33:51 -0300 | [diff] [blame] | 655 | sub drxk_terratec_h5 { |
| 656 | my $url = "http://www.linuxtv.org/downloads/firmware/"; |
| 657 | my $hash = "19000dada8e2741162ccc50cc91fa7f1"; |
| 658 | my $fwfile = "dvb-usb-terratec-h5-drxk.fw"; |
| 659 | |
| 660 | checkstandard(); |
| 661 | |
| 662 | wgetfile($fwfile, $url . $fwfile); |
| 663 | verify($fwfile, $hash); |
| 664 | |
| 665 | "$fwfile" |
| 666 | } |
| 667 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | # --------------------------------------------------------------- |
| 669 | # Utilities |
| 670 | |
| 671 | sub checkstandard { |
| 672 | if (system("which unzip > /dev/null 2>&1")) { |
| 673 | die "This firmware requires the unzip command - see ftp://ftp.info-zip.org/pub/infozip/UnZip.html\n"; |
| 674 | } |
| 675 | if (system("which md5sum > /dev/null 2>&1")) { |
| 676 | die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n"; |
| 677 | } |
| 678 | if (system("which wget > /dev/null 2>&1")) { |
| 679 | die "This firmware requires the wget command - see http://wget.sunsite.dk/\n"; |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | sub checkunshield { |
| 684 | if (system("which unshield > /dev/null 2>&1")) { |
| 685 | die "This firmware requires the unshield command - see http://sourceforge.net/projects/synce/\n"; |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | sub wgetfile { |
| 690 | my ($sourcefile, $url) = @_; |
| 691 | |
| 692 | if (! -f $sourcefile) { |
| 693 | system("wget -O \"$sourcefile\" \"$url\"") and die "wget failed - unable to download firmware"; |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | sub unzip { |
| 698 | my ($sourcefile, $todir) = @_; |
| 699 | |
| 700 | $status = system("unzip -q -o -d \"$todir\" \"$sourcefile\" 2>/dev/null" ); |
| 701 | if ((($status >> 8) > 2) || (($status & 0xff) != 0)) { |
| 702 | die ("unzip failed - unable to extract firmware"); |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | sub unshield { |
| 707 | my ($sourcefile, $todir) = @_; |
| 708 | |
| 709 | system("unshield x -d \"$todir\" \"$sourcefile\" > /dev/null" ) and die ("unshield failed - unable to extract firmware"); |
| 710 | } |
| 711 | |
| 712 | sub verify { |
| 713 | my ($filename, $hash) = @_; |
| 714 | my ($testhash); |
| 715 | |
| 716 | open(CMD, "md5sum \"$filename\"|"); |
| 717 | $testhash = <CMD>; |
| 718 | $testhash =~ /([a-zA-Z0-9]*)/; |
| 719 | $testhash = $1; |
| 720 | close CMD; |
| 721 | die "Hash of extracted file does not match!\n" if ($testhash ne $hash); |
| 722 | } |
| 723 | |
| 724 | sub copy { |
| 725 | my ($from, $to) = @_; |
| 726 | |
| 727 | system("cp -f \"$from\" \"$to\"") and die ("cp failed"); |
| 728 | } |
| 729 | |
| 730 | sub extract { |
| 731 | my ($infile, $offset, $length, $outfile) = @_; |
| 732 | my ($chunklength, $buf, $rcount); |
| 733 | |
| 734 | open INFILE, "<$infile"; |
| 735 | open OUTFILE, ">$outfile"; |
| 736 | sysseek(INFILE, $offset, SEEK_SET); |
| 737 | while($length > 0) { |
| 738 | # Calc chunk size |
| 739 | $chunklength = 2048; |
| 740 | $chunklength = $length if ($chunklength > $length); |
| 741 | |
| 742 | $rcount = sysread(INFILE, $buf, $chunklength); |
| 743 | die "Ran out of data\n" if ($rcount != $chunklength); |
| 744 | syswrite(OUTFILE, $buf); |
| 745 | $length -= $rcount; |
| 746 | } |
| 747 | close INFILE; |
| 748 | close OUTFILE; |
| 749 | } |
| 750 | |
| 751 | sub appendfile { |
| 752 | my ($FH, $infile) = @_; |
| 753 | my ($buf); |
| 754 | |
| 755 | open INFILE, "<$infile"; |
| 756 | while(1) { |
| 757 | $rcount = sysread(INFILE, $buf, 2048); |
| 758 | last if ($rcount == 0); |
| 759 | print $FH $buf; |
| 760 | } |
| 761 | close(INFILE); |
| 762 | } |
| 763 | |
Marco Gittler | 5980055 | 2007-07-04 19:18:34 -0300 | [diff] [blame] | 764 | sub delzero{ |
| 765 | my ($infile,$outfile) =@_; |
| 766 | |
| 767 | open INFILE,"<$infile"; |
| 768 | open OUTFILE,">$outfile"; |
| 769 | while (1){ |
| 770 | $rcount=sysread(INFILE,$buf,22); |
| 771 | $len=ord(substr($buf,0,1)); |
| 772 | print OUTFILE substr($buf,0,1); |
| 773 | print OUTFILE substr($buf,2,$len+3); |
| 774 | last if ($rcount<1); |
| 775 | printf OUTFILE "%c",0; |
| 776 | #print $len." ".length($buf)."\n"; |
| 777 | |
| 778 | } |
| 779 | close(INFILE); |
| 780 | close(OUTFILE); |
| 781 | } |
| 782 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 783 | sub syntax() { |
| 784 | print STDERR "syntax: get_dvb_firmware <component>\n"; |
| 785 | print STDERR "Supported components:\n"; |
Oliver Endriss | 87147ff | 2010-02-05 07:57:58 -0300 | [diff] [blame] | 786 | @components = sort @components; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | for($i=0; $i < scalar(@components); $i++) { |
| 788 | print STDERR "\t" . $components[$i] . "\n"; |
| 789 | } |
| 790 | exit(1); |
| 791 | } |