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", |
Mauro Carvalho Chehab | f65a95b | 2009-03-23 12:35:03 -0300 | [diff] [blame] | 28 | "opera1", "cx231xx", "cx18", "cx23885", "pvrusb2" ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
| 30 | # Check args |
| 31 | syntax() if (scalar(@ARGV) != 1); |
| 32 | $cid = $ARGV[0]; |
| 33 | |
| 34 | # Do it! |
| 35 | for ($i=0; $i < scalar(@components); $i++) { |
| 36 | if ($cid eq $components[$i]) { |
| 37 | $outfile = eval($cid); |
| 38 | die $@ if $@; |
Ville Skytt\ä | 12e66f6 | 2006-01-09 15:25:38 -0200 | [diff] [blame] | 39 | print STDERR <<EOF; |
Mauro Carvalho Chehab | b888c5d | 2009-03-23 10:57:15 -0300 | [diff] [blame] | 40 | Firmware(s) $outfile extracted successfully. |
| 41 | Now copy it(they) to either /usr/lib/hotplug/firmware or /lib/firmware |
Ville Skytt\ä | 12e66f6 | 2006-01-09 15:25:38 -0200 | [diff] [blame] | 42 | (depending on configuration of firmware hotplug). |
| 43 | EOF |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | exit(0); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | # If we get here, it wasn't found |
| 49 | print STDERR "Unknown component \"$cid\"\n"; |
| 50 | syntax(); |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | # --------------------------------------------------------------- |
| 56 | # Firmware-specific extraction subroutines |
| 57 | |
| 58 | sub sp8870 { |
| 59 | my $sourcefile = "tt_Premium_217g.zip"; |
Michael Krufky | 302170a | 2007-06-15 19:14:52 -0300 | [diff] [blame] | 60 | my $url = "http://www.softwarepatch.pl/9999ccd06a4813cb827dbb0005071c71/$sourcefile"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | my $hash = "53970ec17a538945a6d8cb608a7b3899"; |
| 62 | my $outfile = "dvb-fe-sp8870.fw"; |
| 63 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 64 | |
| 65 | checkstandard(); |
| 66 | |
| 67 | wgetfile($sourcefile, $url); |
| 68 | unzip($sourcefile, $tmpdir); |
| 69 | verify("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $hash); |
| 70 | copy("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $outfile); |
| 71 | |
| 72 | $outfile; |
| 73 | } |
| 74 | |
| 75 | sub sp887x { |
| 76 | my $sourcefile = "Dvbt1.3.57.6.zip"; |
| 77 | my $url = "http://www.avermedia.com/software/$sourcefile"; |
| 78 | my $cabfile = "DVBT Net Ver1.3.57.6/disk1/data1.cab"; |
| 79 | my $hash = "237938d53a7f834c05c42b894ca68ac3"; |
| 80 | my $outfile = "dvb-fe-sp887x.fw"; |
| 81 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 82 | |
| 83 | checkstandard(); |
| 84 | checkunshield(); |
| 85 | |
| 86 | wgetfile($sourcefile, $url); |
| 87 | unzip($sourcefile, $tmpdir); |
| 88 | unshield("$tmpdir/$cabfile", $tmpdir); |
| 89 | verify("$tmpdir/ZEnglish/sc_main.mc", $hash); |
| 90 | copy("$tmpdir/ZEnglish/sc_main.mc", $outfile); |
| 91 | |
| 92 | $outfile; |
| 93 | } |
| 94 | |
| 95 | sub tda10045 { |
| 96 | my $sourcefile = "tt_budget_217g.zip"; |
| 97 | my $url = "http://www.technotrend.de/new/217g/$sourcefile"; |
| 98 | my $hash = "2105fd5bf37842fbcdfa4bfd58f3594a"; |
| 99 | my $outfile = "dvb-fe-tda10045.fw"; |
| 100 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 101 | |
| 102 | checkstandard(); |
| 103 | |
| 104 | wgetfile($sourcefile, $url); |
| 105 | unzip($sourcefile, $tmpdir); |
| 106 | extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x37ef9, 30555, "$tmpdir/fwtmp"); |
| 107 | verify("$tmpdir/fwtmp", $hash); |
| 108 | copy("$tmpdir/fwtmp", $outfile); |
| 109 | |
| 110 | $outfile; |
| 111 | } |
| 112 | |
| 113 | sub tda10046 { |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 114 | my $sourcefile = "TT_PCI_2.19h_28_11_2006.zip"; |
Joseba Goitia Gandiaga | d852d53 | 2009-04-09 18:29:16 -0300 | [diff] [blame^] | 115 | my $url = "http://www.tt-download.com/download/updates/219/$sourcefile"; |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 116 | my $hash = "6a7e1e2f2644b162ff0502367553c72d"; |
| 117 | my $outfile = "dvb-fe-tda10046.fw"; |
| 118 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 120 | checkstandard(); |
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 | wgetfile($sourcefile, $url); |
| 123 | unzip($sourcefile, $tmpdir); |
| 124 | extract("$tmpdir/TT_PCI_2.19h_28_11_2006/software/OEM/PCI/App/ttlcdacc.dll", 0x65389, 24478, "$tmpdir/fwtmp"); |
| 125 | verify("$tmpdir/fwtmp", $hash); |
| 126 | copy("$tmpdir/fwtmp", $outfile); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
Andreas Arens | c545d6a | 2007-08-15 17:37:16 -0300 | [diff] [blame] | 128 | $outfile; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 131 | sub tda10046lifeview { |
Joseba Goitia Gandiaga | d852d53 | 2009-04-09 18:29:16 -0300 | [diff] [blame^] | 132 | my $sourcefile = "7%5Cdrv_2.11.02.zip"; |
| 133 | my $url = "http://www.lifeview.hk/dbimages/document/$sourcefile"; |
Giampiero Giancipoli | 3d8466e | 2006-02-07 06:49:09 -0200 | [diff] [blame] | 134 | my $hash = "1ea24dee4eea8fe971686981f34fd2e0"; |
| 135 | my $outfile = "dvb-fe-tda10046.fw"; |
| 136 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 137 | |
| 138 | checkstandard(); |
| 139 | |
| 140 | wgetfile($sourcefile, $url); |
| 141 | unzip($sourcefile, $tmpdir); |
| 142 | extract("$tmpdir/LVHybrid.sys", 0x8b088, 24602, "$tmpdir/fwtmp"); |
| 143 | verify("$tmpdir/fwtmp", $hash); |
| 144 | copy("$tmpdir/fwtmp", $outfile); |
| 145 | |
| 146 | $outfile; |
| 147 | } |
| 148 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | sub av7110 { |
| 150 | my $sourcefile = "dvb-ttpci-01.fw-261d"; |
| 151 | my $url = "http://www.linuxtv.org/downloads/firmware/$sourcefile"; |
| 152 | my $hash = "603431b6259715a8e88f376a53b64e2f"; |
| 153 | my $outfile = "dvb-ttpci-01.fw"; |
| 154 | |
| 155 | checkstandard(); |
| 156 | |
| 157 | wgetfile($sourcefile, $url); |
| 158 | verify($sourcefile, $hash); |
| 159 | copy($sourcefile, $outfile); |
| 160 | |
| 161 | $outfile; |
| 162 | } |
| 163 | |
| 164 | sub dec2000t { |
| 165 | my $sourcefile = "dec217g.exe"; |
| 166 | my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; |
| 167 | my $hash = "bd86f458cee4a8f0a8ce2d20c66215a9"; |
| 168 | my $outfile = "dvb-ttusb-dec-2000t.fw"; |
| 169 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 170 | |
| 171 | checkstandard(); |
| 172 | |
| 173 | wgetfile($sourcefile, $url); |
| 174 | unzip($sourcefile, $tmpdir); |
| 175 | verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $hash); |
| 176 | copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $outfile); |
| 177 | |
| 178 | $outfile; |
| 179 | } |
| 180 | |
| 181 | sub dec2540t { |
| 182 | my $sourcefile = "dec217g.exe"; |
| 183 | my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; |
| 184 | my $hash = "53e58f4f5b5c2930beee74a7681fed92"; |
| 185 | my $outfile = "dvb-ttusb-dec-2540t.fw"; |
| 186 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 187 | |
| 188 | checkstandard(); |
| 189 | |
| 190 | wgetfile($sourcefile, $url); |
| 191 | unzip($sourcefile, $tmpdir); |
| 192 | verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $hash); |
| 193 | copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $outfile); |
| 194 | |
| 195 | $outfile; |
| 196 | } |
| 197 | |
| 198 | sub dec3000s { |
| 199 | my $sourcefile = "dec217g.exe"; |
| 200 | my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; |
| 201 | my $hash = "b013ececea83f4d6d8d2a29ac7c1b448"; |
| 202 | my $outfile = "dvb-ttusb-dec-3000s.fw"; |
| 203 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 204 | |
| 205 | checkstandard(); |
| 206 | |
| 207 | wgetfile($sourcefile, $url); |
| 208 | unzip($sourcefile, $tmpdir); |
| 209 | verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $hash); |
| 210 | copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $outfile); |
| 211 | |
| 212 | $outfile; |
| 213 | } |
Marco Gittler | 5980055 | 2007-07-04 19:18:34 -0300 | [diff] [blame] | 214 | sub opera1{ |
| 215 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0); |
| 216 | |
| 217 | checkstandard(); |
| 218 | my $fwfile1="dvb-usb-opera1-fpga-01.fw"; |
| 219 | my $fwfile2="dvb-usb-opera-01.fw"; |
| 220 | extract("2830SCap2.sys", 0x62e8, 55024, "$tmpdir/opera1-fpga.fw"); |
| 221 | extract("2830SLoad2.sys",0x3178,0x3685-0x3178,"$tmpdir/fw1part1"); |
| 222 | extract("2830SLoad2.sys",0x0980,0x3150-0x0980,"$tmpdir/fw1part2"); |
| 223 | delzero("$tmpdir/fw1part1","$tmpdir/fw1part1-1"); |
| 224 | delzero("$tmpdir/fw1part2","$tmpdir/fw1part2-1"); |
| 225 | verify("$tmpdir/fw1part1-1","5e0909858fdf0b5b09ad48b9fe622e70"); |
| 226 | verify("$tmpdir/fw1part2-1","d6e146f321427e931df2c6fcadac37a1"); |
| 227 | verify("$tmpdir/opera1-fpga.fw","0f8133f5e9051f5f3c1928f7e5a1b07d"); |
| 228 | |
| 229 | my $RES1="\x01\x92\x7f\x00\x01\x00"; |
| 230 | my $RES0="\x01\x92\x7f\x00\x00\x00"; |
| 231 | my $DAT1="\x01\x00\xe6\x00\x01\x00"; |
| 232 | my $DAT0="\x01\x00\xe6\x00\x00\x00"; |
| 233 | open FW,">$tmpdir/opera.fw"; |
| 234 | print FW "$RES1"; |
| 235 | print FW "$DAT1"; |
| 236 | print FW "$RES1"; |
| 237 | print FW "$DAT1"; |
| 238 | appendfile(FW,"$tmpdir/fw1part1-1"); |
| 239 | print FW "$RES0"; |
| 240 | print FW "$DAT0"; |
| 241 | print FW "$RES1"; |
| 242 | print FW "$DAT1"; |
| 243 | appendfile(FW,"$tmpdir/fw1part2-1"); |
| 244 | print FW "$RES1"; |
| 245 | print FW "$DAT1"; |
| 246 | print FW "$RES0"; |
| 247 | print FW "$DAT0"; |
| 248 | copy ("$tmpdir/opera1-fpga.fw",$fwfile1); |
| 249 | copy ("$tmpdir/opera.fw",$fwfile2); |
| 250 | |
| 251 | $fwfile1.",".$fwfile2; |
| 252 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | |
| 254 | sub vp7041 { |
| 255 | my $sourcefile = "2.422.zip"; |
| 256 | my $url = "http://www.twinhan.com/files/driver/USB-Ter/$sourcefile"; |
| 257 | my $hash = "e88c9372d1f66609a3e7b072c53fbcfe"; |
| 258 | my $outfile = "dvb-vp7041-2.422.fw"; |
| 259 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 260 | |
| 261 | checkstandard(); |
| 262 | |
| 263 | wgetfile($sourcefile, $url); |
| 264 | unzip($sourcefile, $tmpdir); |
| 265 | extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 12503, 3036, "$tmpdir/fwtmp1"); |
| 266 | extract("$tmpdir/VisionDTV/Drivers/Win2K&XP/UDTTload.sys", 2207, 10274, "$tmpdir/fwtmp2"); |
| 267 | |
| 268 | my $CMD = "\000\001\000\222\177\000"; |
| 269 | my $PAD = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"; |
| 270 | my ($FW); |
| 271 | open $FW, ">$tmpdir/fwtmp3"; |
| 272 | print $FW "$CMD\001$PAD"; |
| 273 | print $FW "$CMD\001$PAD"; |
| 274 | appendfile($FW, "$tmpdir/fwtmp1"); |
| 275 | print $FW "$CMD\000$PAD"; |
| 276 | print $FW "$CMD\001$PAD"; |
| 277 | appendfile($FW, "$tmpdir/fwtmp2"); |
| 278 | print $FW "$CMD\001$PAD"; |
| 279 | print $FW "$CMD\000$PAD"; |
| 280 | close($FW); |
| 281 | |
| 282 | verify("$tmpdir/fwtmp3", $hash); |
| 283 | copy("$tmpdir/fwtmp3", $outfile); |
| 284 | |
| 285 | $outfile; |
| 286 | } |
| 287 | |
| 288 | sub dibusb { |
Adrian Bunk | d7f2baa | 2006-03-22 00:43:59 +0100 | [diff] [blame] | 289 | 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] | 290 | my $outfile = "dvb-dibusb-5.0.0.11.fw"; |
| 291 | my $hash = "fa490295a527360ca16dcdf3224ca243"; |
| 292 | |
| 293 | checkstandard(); |
| 294 | |
| 295 | wgetfile($outfile, $url); |
| 296 | verify($outfile,$hash); |
| 297 | |
| 298 | $outfile; |
| 299 | } |
| 300 | |
| 301 | sub nxt2002 { |
Michael Krufky | ba5f0a4 | 2006-04-23 01:55:38 -0300 | [diff] [blame] | 302 | my $sourcefile = "Technisat_DVB-PC_4_4_COMPACT.zip"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | my $url = "http://www.bbti.us/download/windows/$sourcefile"; |
Michael Krufky | ba5f0a4 | 2006-04-23 01:55:38 -0300 | [diff] [blame] | 304 | my $hash = "476befae8c7c1bb9648954060b1eec1f"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | my $outfile = "dvb-fe-nxt2002.fw"; |
| 306 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 307 | |
| 308 | checkstandard(); |
Michael Krufky | 50c25ff | 2006-01-09 15:25:34 -0200 | [diff] [blame] | 309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | wgetfile($sourcefile, $url); |
| 311 | unzip($sourcefile, $tmpdir); |
Michael Krufky | ba5f0a4 | 2006-04-23 01:55:38 -0300 | [diff] [blame] | 312 | verify("$tmpdir/SkyNET.sys", $hash); |
| 313 | extract("$tmpdir/SkyNET.sys", 331624, 5908, $outfile); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | |
| 315 | $outfile; |
| 316 | } |
| 317 | |
Kirk Lapray | 04a4592 | 2005-11-08 21:35:46 -0800 | [diff] [blame] | 318 | sub nxt2004 { |
| 319 | my $sourcefile = "AVerTVHD_MCE_A180_Drv_v1.2.2.16.zip"; |
| 320 | my $url = "http://www.aver.com/support/Drivers/$sourcefile"; |
| 321 | my $hash = "111cb885b1e009188346d72acfed024c"; |
| 322 | my $outfile = "dvb-fe-nxt2004.fw"; |
| 323 | my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
| 324 | |
| 325 | checkstandard(); |
| 326 | |
| 327 | wgetfile($sourcefile, $url); |
| 328 | unzip($sourcefile, $tmpdir); |
| 329 | verify("$tmpdir/3xHybrid.sys", $hash); |
| 330 | extract("$tmpdir/3xHybrid.sys", 465304, 9584, $outfile); |
| 331 | |
| 332 | $outfile; |
| 333 | } |
| 334 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | sub or51211 { |
| 336 | my $fwfile = "dvb-fe-or51211.fw"; |
| 337 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 338 | my $hash = "d830949c771a289505bf9eafc225d491"; |
| 339 | |
| 340 | checkstandard(); |
| 341 | |
| 342 | wgetfile($fwfile, $url); |
| 343 | verify($fwfile, $hash); |
| 344 | |
| 345 | $fwfile; |
| 346 | } |
| 347 | |
Mauro Carvalho Chehab | 06e9509 | 2009-03-19 12:10:00 -0300 | [diff] [blame] | 348 | sub cx231xx { |
| 349 | my $fwfile = "v4l-cx231xx-avcore-01.fw"; |
| 350 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 351 | my $hash = "7d3bb956dc9df0eafded2b56ba57cc42"; |
| 352 | |
| 353 | checkstandard(); |
| 354 | |
| 355 | wgetfile($fwfile, $url); |
| 356 | verify($fwfile, $hash); |
| 357 | |
| 358 | $fwfile; |
| 359 | } |
| 360 | |
Mauro Carvalho Chehab | b888c5d | 2009-03-23 10:57:15 -0300 | [diff] [blame] | 361 | sub cx18 { |
| 362 | my $url = "http://linuxtv.org/downloads/firmware/"; |
| 363 | |
| 364 | my %files = ( |
| 365 | 'v4l-cx23418-apu.fw' => '588f081b562f5c653a3db1ad8f65939a', |
| 366 | 'v4l-cx23418-cpu.fw' => 'b6c7ed64bc44b1a6e0840adaeac39d79', |
| 367 | 'v4l-cx23418-dig.fw' => '95bc688d3e7599fd5800161e9971cc55', |
| 368 | ); |
| 369 | |
| 370 | checkstandard(); |
| 371 | |
| 372 | my $allfiles; |
| 373 | foreach my $fwfile (keys %files) { |
| 374 | wgetfile($fwfile, "$url/$fwfile"); |
| 375 | verify($fwfile, $files{$fwfile}); |
| 376 | $allfiles .= " $fwfile"; |
| 377 | } |
| 378 | |
| 379 | $allfiles =~ s/^\s//; |
| 380 | |
| 381 | $allfiles; |
| 382 | } |
| 383 | |
Mauro Carvalho Chehab | 5297e6f | 2009-03-23 11:46:19 -0300 | [diff] [blame] | 384 | sub cx23885 { |
| 385 | my $url = "http://linuxtv.org/downloads/firmware/"; |
| 386 | |
| 387 | my %files = ( |
| 388 | 'v4l-cx23885-avcore-01.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb', |
| 389 | 'v4l-cx23885-enc.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb', |
Mauro Carvalho Chehab | f65a95b | 2009-03-23 12:35:03 -0300 | [diff] [blame] | 390 | ); |
| 391 | |
| 392 | checkstandard(); |
| 393 | |
| 394 | my $allfiles; |
| 395 | foreach my $fwfile (keys %files) { |
| 396 | wgetfile($fwfile, "$url/$fwfile"); |
| 397 | verify($fwfile, $files{$fwfile}); |
| 398 | $allfiles .= " $fwfile"; |
| 399 | } |
| 400 | |
| 401 | $allfiles =~ s/^\s//; |
| 402 | |
| 403 | $allfiles; |
| 404 | } |
| 405 | |
| 406 | sub pvrusb2 { |
| 407 | my $url = "http://linuxtv.org/downloads/firmware/"; |
| 408 | |
| 409 | my %files = ( |
Mauro Carvalho Chehab | 5297e6f | 2009-03-23 11:46:19 -0300 | [diff] [blame] | 410 | 'v4l-cx25840.fw' => 'dadb79e9904fc8af96e8111d9cb59320', |
| 411 | ); |
| 412 | |
| 413 | checkstandard(); |
| 414 | |
| 415 | my $allfiles; |
| 416 | foreach my $fwfile (keys %files) { |
| 417 | wgetfile($fwfile, "$url/$fwfile"); |
| 418 | verify($fwfile, $files{$fwfile}); |
| 419 | $allfiles .= " $fwfile"; |
| 420 | } |
| 421 | |
| 422 | $allfiles =~ s/^\s//; |
| 423 | |
| 424 | $allfiles; |
| 425 | } |
| 426 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | sub or51132_qam { |
| 428 | my $fwfile = "dvb-fe-or51132-qam.fw"; |
| 429 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 430 | my $hash = "7702e8938612de46ccadfe9b413cb3b5"; |
| 431 | |
| 432 | checkstandard(); |
| 433 | |
| 434 | wgetfile($fwfile, $url); |
| 435 | verify($fwfile, $hash); |
| 436 | |
| 437 | $fwfile; |
| 438 | } |
| 439 | |
| 440 | sub or51132_vsb { |
| 441 | my $fwfile = "dvb-fe-or51132-vsb.fw"; |
| 442 | my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
| 443 | my $hash = "c16208e02f36fc439a557ad4c613364a"; |
| 444 | |
| 445 | checkstandard(); |
| 446 | |
| 447 | wgetfile($fwfile, $url); |
| 448 | verify($fwfile, $hash); |
| 449 | |
| 450 | $fwfile; |
| 451 | } |
| 452 | |
Michael Krufky | d8e6acf | 2006-01-09 15:32:42 -0200 | [diff] [blame] | 453 | sub bluebird { |
Michael Krufky | cec4183 | 2006-01-09 18:21:40 -0200 | [diff] [blame] | 454 | 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] | 455 | my $outfile = "dvb-usb-bluebird-01.fw"; |
| 456 | my $hash = "658397cb9eba9101af9031302671f49d"; |
| 457 | |
| 458 | checkstandard(); |
| 459 | |
| 460 | wgetfile($outfile, $url); |
| 461 | verify($outfile,$hash); |
| 462 | |
| 463 | $outfile; |
| 464 | } |
| 465 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | # --------------------------------------------------------------- |
| 467 | # Utilities |
| 468 | |
| 469 | sub checkstandard { |
| 470 | if (system("which unzip > /dev/null 2>&1")) { |
| 471 | die "This firmware requires the unzip command - see ftp://ftp.info-zip.org/pub/infozip/UnZip.html\n"; |
| 472 | } |
| 473 | if (system("which md5sum > /dev/null 2>&1")) { |
| 474 | die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n"; |
| 475 | } |
| 476 | if (system("which wget > /dev/null 2>&1")) { |
| 477 | die "This firmware requires the wget command - see http://wget.sunsite.dk/\n"; |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | sub checkunshield { |
| 482 | if (system("which unshield > /dev/null 2>&1")) { |
| 483 | die "This firmware requires the unshield command - see http://sourceforge.net/projects/synce/\n"; |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | sub wgetfile { |
| 488 | my ($sourcefile, $url) = @_; |
| 489 | |
| 490 | if (! -f $sourcefile) { |
| 491 | system("wget -O \"$sourcefile\" \"$url\"") and die "wget failed - unable to download firmware"; |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | sub unzip { |
| 496 | my ($sourcefile, $todir) = @_; |
| 497 | |
| 498 | $status = system("unzip -q -o -d \"$todir\" \"$sourcefile\" 2>/dev/null" ); |
| 499 | if ((($status >> 8) > 2) || (($status & 0xff) != 0)) { |
| 500 | die ("unzip failed - unable to extract firmware"); |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | sub unshield { |
| 505 | my ($sourcefile, $todir) = @_; |
| 506 | |
| 507 | system("unshield x -d \"$todir\" \"$sourcefile\" > /dev/null" ) and die ("unshield failed - unable to extract firmware"); |
| 508 | } |
| 509 | |
| 510 | sub verify { |
| 511 | my ($filename, $hash) = @_; |
| 512 | my ($testhash); |
| 513 | |
| 514 | open(CMD, "md5sum \"$filename\"|"); |
| 515 | $testhash = <CMD>; |
| 516 | $testhash =~ /([a-zA-Z0-9]*)/; |
| 517 | $testhash = $1; |
| 518 | close CMD; |
| 519 | die "Hash of extracted file does not match!\n" if ($testhash ne $hash); |
| 520 | } |
| 521 | |
| 522 | sub copy { |
| 523 | my ($from, $to) = @_; |
| 524 | |
| 525 | system("cp -f \"$from\" \"$to\"") and die ("cp failed"); |
| 526 | } |
| 527 | |
| 528 | sub extract { |
| 529 | my ($infile, $offset, $length, $outfile) = @_; |
| 530 | my ($chunklength, $buf, $rcount); |
| 531 | |
| 532 | open INFILE, "<$infile"; |
| 533 | open OUTFILE, ">$outfile"; |
| 534 | sysseek(INFILE, $offset, SEEK_SET); |
| 535 | while($length > 0) { |
| 536 | # Calc chunk size |
| 537 | $chunklength = 2048; |
| 538 | $chunklength = $length if ($chunklength > $length); |
| 539 | |
| 540 | $rcount = sysread(INFILE, $buf, $chunklength); |
| 541 | die "Ran out of data\n" if ($rcount != $chunklength); |
| 542 | syswrite(OUTFILE, $buf); |
| 543 | $length -= $rcount; |
| 544 | } |
| 545 | close INFILE; |
| 546 | close OUTFILE; |
| 547 | } |
| 548 | |
| 549 | sub appendfile { |
| 550 | my ($FH, $infile) = @_; |
| 551 | my ($buf); |
| 552 | |
| 553 | open INFILE, "<$infile"; |
| 554 | while(1) { |
| 555 | $rcount = sysread(INFILE, $buf, 2048); |
| 556 | last if ($rcount == 0); |
| 557 | print $FH $buf; |
| 558 | } |
| 559 | close(INFILE); |
| 560 | } |
| 561 | |
Marco Gittler | 5980055 | 2007-07-04 19:18:34 -0300 | [diff] [blame] | 562 | sub delzero{ |
| 563 | my ($infile,$outfile) =@_; |
| 564 | |
| 565 | open INFILE,"<$infile"; |
| 566 | open OUTFILE,">$outfile"; |
| 567 | while (1){ |
| 568 | $rcount=sysread(INFILE,$buf,22); |
| 569 | $len=ord(substr($buf,0,1)); |
| 570 | print OUTFILE substr($buf,0,1); |
| 571 | print OUTFILE substr($buf,2,$len+3); |
| 572 | last if ($rcount<1); |
| 573 | printf OUTFILE "%c",0; |
| 574 | #print $len." ".length($buf)."\n"; |
| 575 | |
| 576 | } |
| 577 | close(INFILE); |
| 578 | close(OUTFILE); |
| 579 | } |
| 580 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | sub syntax() { |
| 582 | print STDERR "syntax: get_dvb_firmware <component>\n"; |
| 583 | print STDERR "Supported components:\n"; |
| 584 | for($i=0; $i < scalar(@components); $i++) { |
| 585 | print STDERR "\t" . $components[$i] . "\n"; |
| 586 | } |
| 587 | exit(1); |
| 588 | } |