1 |
billie 09/09/02 20:49:58 |
2 |
|
3 |
Added: get_dvb_firmware-2009.07.06 |
4 |
Log: |
5 |
Version bump. |
6 |
(Portage version: 2.1.6.13/cvs/Linux i686) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 media-tv/linuxtv-dvb-firmware/files/get_dvb_firmware-2009.07.06 |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-tv/linuxtv-dvb-firmware/files/get_dvb_firmware-2009.07.06?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/media-tv/linuxtv-dvb-firmware/files/get_dvb_firmware-2009.07.06?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: get_dvb_firmware-2009.07.06 |
15 |
=================================================================== |
16 |
#!/usr/bin/perl |
17 |
# DVB firmware extractor |
18 |
# |
19 |
# (c) 2004 Andrew de Quincey |
20 |
# |
21 |
# This program is free software; you can redistribute it and/or modify |
22 |
# it under the terms of the GNU General Public License as published by |
23 |
# the Free Software Foundation; either version 2 of the License, or |
24 |
# (at your option) any later version. |
25 |
# |
26 |
# This program is distributed in the hope that it will be useful, |
27 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
28 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
29 |
# |
30 |
# GNU General Public License for more details. |
31 |
# |
32 |
# You should have received a copy of the GNU General Public License |
33 |
# along with this program; if not, write to the Free Software |
34 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
35 |
|
36 |
use File::Temp qw/ tempdir /; |
37 |
use IO::Handle; |
38 |
|
39 |
@components = ( "sp8870", "sp887x", "tda10045", "tda10046", |
40 |
"tda10046lifeview", "av7110", "dec2000t", "dec2540t", |
41 |
"dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004", |
42 |
"or51211", "or51132_qam", "or51132_vsb", "bluebird", |
43 |
"opera1", "cx231xx", "cx18", "cx23885", "pvrusb2", "mpc718" ); |
44 |
|
45 |
# Check args |
46 |
syntax() if (scalar(@ARGV) != 1); |
47 |
$cid = $ARGV[0]; |
48 |
|
49 |
# Do it! |
50 |
for ($i=0; $i < scalar(@components); $i++) { |
51 |
if ($cid eq $components[$i]) { |
52 |
$outfile = eval($cid); |
53 |
die $@ if $@; |
54 |
print STDERR <<EOF; |
55 |
Firmware(s) $outfile extracted successfully. |
56 |
Now copy it(they) to either /usr/lib/hotplug/firmware or /lib/firmware |
57 |
(depending on configuration of firmware hotplug). |
58 |
EOF |
59 |
exit(0); |
60 |
} |
61 |
} |
62 |
|
63 |
# If we get here, it wasn't found |
64 |
print STDERR "Unknown component \"$cid\"\n"; |
65 |
syntax(); |
66 |
|
67 |
|
68 |
|
69 |
|
70 |
# --------------------------------------------------------------- |
71 |
# Firmware-specific extraction subroutines |
72 |
|
73 |
sub sp8870 { |
74 |
my $sourcefile = "tt_Premium_217g.zip"; |
75 |
my $url = "http://2.download.softwarepatch.pl/1619edb0dcb493dd5337b94a1f79c3f6/$sourcefile"; |
76 |
my $hash = "53970ec17a538945a6d8cb608a7b3899"; |
77 |
my $outfile = "dvb-fe-sp8870.fw"; |
78 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
79 |
|
80 |
checkstandard(); |
81 |
|
82 |
wgetfile($sourcefile, $url); |
83 |
unzip($sourcefile, $tmpdir); |
84 |
verify("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $hash); |
85 |
copy("$tmpdir/software/OEM/HE/App/boot/SC_MAIN.MC", $outfile); |
86 |
|
87 |
$outfile; |
88 |
} |
89 |
|
90 |
sub sp887x { |
91 |
my $sourcefile = "Dvbt1.3.57.6.zip"; |
92 |
my $url = "http://www.avermedia.com/software/$sourcefile"; |
93 |
my $cabfile = "DVBT Net Ver1.3.57.6/disk1/data1.cab"; |
94 |
my $hash = "237938d53a7f834c05c42b894ca68ac3"; |
95 |
my $outfile = "dvb-fe-sp887x.fw"; |
96 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
97 |
|
98 |
checkstandard(); |
99 |
checkunshield(); |
100 |
|
101 |
wgetfile($sourcefile, $url); |
102 |
unzip($sourcefile, $tmpdir); |
103 |
unshield("$tmpdir/$cabfile", $tmpdir); |
104 |
verify("$tmpdir/ZEnglish/sc_main.mc", $hash); |
105 |
copy("$tmpdir/ZEnglish/sc_main.mc", $outfile); |
106 |
|
107 |
$outfile; |
108 |
} |
109 |
|
110 |
sub tda10045 { |
111 |
my $sourcefile = "tt_budget_217g.zip"; |
112 |
my $url = "http://www.technotrend.de/new/217g/$sourcefile"; |
113 |
my $hash = "2105fd5bf37842fbcdfa4bfd58f3594a"; |
114 |
my $outfile = "dvb-fe-tda10045.fw"; |
115 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
116 |
|
117 |
checkstandard(); |
118 |
|
119 |
wgetfile($sourcefile, $url); |
120 |
unzip($sourcefile, $tmpdir); |
121 |
extract("$tmpdir/software/OEM/PCI/App/ttlcdacc.dll", 0x37ef9, 30555, "$tmpdir/fwtmp"); |
122 |
verify("$tmpdir/fwtmp", $hash); |
123 |
copy("$tmpdir/fwtmp", $outfile); |
124 |
|
125 |
$outfile; |
126 |
} |
127 |
|
128 |
sub tda10046 { |
129 |
my $sourcefile = "TT_PCI_2.19h_28_11_2006.zip"; |
130 |
my $url = "http://www.tt-download.com/download/updates/219/$sourcefile"; |
131 |
my $hash = "6a7e1e2f2644b162ff0502367553c72d"; |
132 |
my $outfile = "dvb-fe-tda10046.fw"; |
133 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
134 |
|
135 |
checkstandard(); |
136 |
|
137 |
wgetfile($sourcefile, $url); |
138 |
unzip($sourcefile, $tmpdir); |
139 |
extract("$tmpdir/TT_PCI_2.19h_28_11_2006/software/OEM/PCI/App/ttlcdacc.dll", 0x65389, 24478, "$tmpdir/fwtmp"); |
140 |
verify("$tmpdir/fwtmp", $hash); |
141 |
copy("$tmpdir/fwtmp", $outfile); |
142 |
|
143 |
$outfile; |
144 |
} |
145 |
|
146 |
sub tda10046lifeview { |
147 |
my $sourcefile = "7%5Cdrv_2.11.02.zip"; |
148 |
my $url = "http://www.lifeview.hk/dbimages/document/$sourcefile"; |
149 |
my $hash = "1ea24dee4eea8fe971686981f34fd2e0"; |
150 |
my $outfile = "dvb-fe-tda10046.fw"; |
151 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
152 |
|
153 |
checkstandard(); |
154 |
|
155 |
wgetfile($sourcefile, $url); |
156 |
unzip($sourcefile, $tmpdir); |
157 |
extract("$tmpdir/LVHybrid.sys", 0x8b088, 24602, "$tmpdir/fwtmp"); |
158 |
verify("$tmpdir/fwtmp", $hash); |
159 |
copy("$tmpdir/fwtmp", $outfile); |
160 |
|
161 |
$outfile; |
162 |
} |
163 |
|
164 |
sub av7110 { |
165 |
my $sourcefile = "dvb-ttpci-01.fw-261d"; |
166 |
my $url = "http://www.linuxtv.org/downloads/firmware/$sourcefile"; |
167 |
my $hash = "603431b6259715a8e88f376a53b64e2f"; |
168 |
my $outfile = "dvb-ttpci-01.fw"; |
169 |
|
170 |
checkstandard(); |
171 |
|
172 |
wgetfile($sourcefile, $url); |
173 |
verify($sourcefile, $hash); |
174 |
copy($sourcefile, $outfile); |
175 |
|
176 |
$outfile; |
177 |
} |
178 |
|
179 |
sub dec2000t { |
180 |
my $sourcefile = "dec217g.exe"; |
181 |
my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; |
182 |
my $hash = "bd86f458cee4a8f0a8ce2d20c66215a9"; |
183 |
my $outfile = "dvb-ttusb-dec-2000t.fw"; |
184 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
185 |
|
186 |
checkstandard(); |
187 |
|
188 |
wgetfile($sourcefile, $url); |
189 |
unzip($sourcefile, $tmpdir); |
190 |
verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $hash); |
191 |
copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_T.bin", $outfile); |
192 |
|
193 |
$outfile; |
194 |
} |
195 |
|
196 |
sub dec2540t { |
197 |
my $sourcefile = "dec217g.exe"; |
198 |
my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; |
199 |
my $hash = "53e58f4f5b5c2930beee74a7681fed92"; |
200 |
my $outfile = "dvb-ttusb-dec-2540t.fw"; |
201 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
202 |
|
203 |
checkstandard(); |
204 |
|
205 |
wgetfile($sourcefile, $url); |
206 |
unzip($sourcefile, $tmpdir); |
207 |
verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $hash); |
208 |
copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_X.bin", $outfile); |
209 |
|
210 |
$outfile; |
211 |
} |
212 |
|
213 |
sub dec3000s { |
214 |
my $sourcefile = "dec217g.exe"; |
215 |
my $url = "http://hauppauge.lightpath.net/de/$sourcefile"; |
216 |
my $hash = "b013ececea83f4d6d8d2a29ac7c1b448"; |
217 |
my $outfile = "dvb-ttusb-dec-3000s.fw"; |
218 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
219 |
|
220 |
checkstandard(); |
221 |
|
222 |
wgetfile($sourcefile, $url); |
223 |
unzip($sourcefile, $tmpdir); |
224 |
verify("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $hash); |
225 |
copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $outfile); |
226 |
|
227 |
$outfile; |
228 |
} |
229 |
sub opera1{ |
230 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0); |
231 |
|
232 |
checkstandard(); |
233 |
my $fwfile1="dvb-usb-opera1-fpga-01.fw"; |
234 |
my $fwfile2="dvb-usb-opera-01.fw"; |
235 |
extract("2830SCap2.sys", 0x62e8, 55024, "$tmpdir/opera1-fpga.fw"); |
236 |
extract("2830SLoad2.sys",0x3178,0x3685-0x3178,"$tmpdir/fw1part1"); |
237 |
extract("2830SLoad2.sys",0x0980,0x3150-0x0980,"$tmpdir/fw1part2"); |
238 |
delzero("$tmpdir/fw1part1","$tmpdir/fw1part1-1"); |
239 |
delzero("$tmpdir/fw1part2","$tmpdir/fw1part2-1"); |
240 |
verify("$tmpdir/fw1part1-1","5e0909858fdf0b5b09ad48b9fe622e70"); |
241 |
verify("$tmpdir/fw1part2-1","d6e146f321427e931df2c6fcadac37a1"); |
242 |
verify("$tmpdir/opera1-fpga.fw","0f8133f5e9051f5f3c1928f7e5a1b07d"); |
243 |
|
244 |
my $RES1="\x01\x92\x7f\x00\x01\x00"; |
245 |
my $RES0="\x01\x92\x7f\x00\x00\x00"; |
246 |
my $DAT1="\x01\x00\xe6\x00\x01\x00"; |
247 |
my $DAT0="\x01\x00\xe6\x00\x00\x00"; |
248 |
open FW,">$tmpdir/opera.fw"; |
249 |
print FW "$RES1"; |
250 |
print FW "$DAT1"; |
251 |
print FW "$RES1"; |
252 |
print FW "$DAT1"; |
253 |
appendfile(FW,"$tmpdir/fw1part1-1"); |
254 |
print FW "$RES0"; |
255 |
print FW "$DAT0"; |
256 |
print FW "$RES1"; |
257 |
print FW "$DAT1"; |
258 |
appendfile(FW,"$tmpdir/fw1part2-1"); |
259 |
print FW "$RES1"; |
260 |
print FW "$DAT1"; |
261 |
print FW "$RES0"; |
262 |
print FW "$DAT0"; |
263 |
copy ("$tmpdir/opera1-fpga.fw",$fwfile1); |
264 |
copy ("$tmpdir/opera.fw",$fwfile2); |
265 |
|
266 |
$fwfile1.",".$fwfile2; |
267 |
} |
268 |
sub vp7041 { |
269 |
my $sourcefile = "TwinhanDTV2.608a.zip"; |
270 |
my $url = "http://www.twinhan.com/files/AW/Software/$sourcefile"; |
271 |
my $hash = "e88c9372d1f66609a3e7b072c53fbcfe"; |
272 |
my $outfile = "dvb-vp7041-2.422.fw"; |
273 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
274 |
|
275 |
checkstandard(); |
276 |
|
277 |
wgetfile($sourcefile, $url); |
278 |
unzip($sourcefile, $tmpdir); |
279 |
extract("$tmpdir/TwinhanDTV2.608a/Drivers/7041/WinXP/UDTTload.sys", 12503, 3036, "$tmpdir/fwtmp1"); |
280 |
extract("$tmpdir/TwinhanDTV2.608a/Drivers/7041/WinXP/UDTTload.sys", 2207, 10274, "$tmpdir/fwtmp2"); |
281 |
|
282 |
my $CMD = "\000\001\000\222\177\000"; |
283 |
my $PAD = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"; |
284 |
my ($FW); |
285 |
open $FW, ">$tmpdir/fwtmp3"; |
286 |
print $FW "$CMD\001$PAD"; |
287 |
print $FW "$CMD\001$PAD"; |
288 |
appendfile($FW, "$tmpdir/fwtmp1"); |
289 |
print $FW "$CMD\000$PAD"; |
290 |
print $FW "$CMD\001$PAD"; |
291 |
appendfile($FW, "$tmpdir/fwtmp2"); |
292 |
print $FW "$CMD\001$PAD"; |
293 |
print $FW "$CMD\000$PAD"; |
294 |
close($FW); |
295 |
|
296 |
verify("$tmpdir/fwtmp3", $hash); |
297 |
copy("$tmpdir/fwtmp3", $outfile); |
298 |
|
299 |
$outfile; |
300 |
} |
301 |
|
302 |
sub dibusb { |
303 |
my $url = "http://www.linuxtv.org/downloads/firmware/dvb-usb-dibusb-5.0.0.11.fw"; |
304 |
my $outfile = "dvb-dibusb-5.0.0.11.fw"; |
305 |
my $hash = "fa490295a527360ca16dcdf3224ca243"; |
306 |
|
307 |
checkstandard(); |
308 |
|
309 |
wgetfile($outfile, $url); |
310 |
verify($outfile,$hash); |
311 |
|
312 |
$outfile; |
313 |
} |
314 |
|
315 |
sub nxt2002 { |
316 |
my $sourcefile = "Technisat_DVB-PC_4_4_COMPACT.zip"; |
317 |
my $url = "http://www.bbti.us/download/windows/$sourcefile"; |
318 |
my $hash = "476befae8c7c1bb9648954060b1eec1f"; |
319 |
my $outfile = "dvb-fe-nxt2002.fw"; |
320 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
321 |
|
322 |
checkstandard(); |
323 |
|
324 |
wgetfile($sourcefile, $url); |
325 |
unzip($sourcefile, $tmpdir); |
326 |
verify("$tmpdir/SkyNET.sys", $hash); |
327 |
extract("$tmpdir/SkyNET.sys", 331624, 5908, $outfile); |
328 |
|
329 |
$outfile; |
330 |
} |
331 |
|
332 |
sub nxt2004 { |
333 |
my $sourcefile = "AVerTVHD_MCE_A180_Drv_v1.2.2.16.zip"; |
334 |
my $url = "http://www.avermedia-usa.com/support/Drivers/$sourcefile"; |
335 |
my $hash = "111cb885b1e009188346d72acfed024c"; |
336 |
my $outfile = "dvb-fe-nxt2004.fw"; |
337 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
338 |
|
339 |
checkstandard(); |
340 |
|
341 |
wgetfile($sourcefile, $url); |
342 |
unzip($sourcefile, $tmpdir); |
343 |
verify("$tmpdir/3xHybrid.sys", $hash); |
344 |
extract("$tmpdir/3xHybrid.sys", 465304, 9584, $outfile); |
345 |
|
346 |
$outfile; |
347 |
} |
348 |
|
349 |
sub or51211 { |
350 |
my $fwfile = "dvb-fe-or51211.fw"; |
351 |
my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
352 |
my $hash = "d830949c771a289505bf9eafc225d491"; |
353 |
|
354 |
checkstandard(); |
355 |
|
356 |
wgetfile($fwfile, $url); |
357 |
verify($fwfile, $hash); |
358 |
|
359 |
$fwfile; |
360 |
} |
361 |
|
362 |
sub cx231xx { |
363 |
my $fwfile = "v4l-cx231xx-avcore-01.fw"; |
364 |
my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
365 |
my $hash = "7d3bb956dc9df0eafded2b56ba57cc42"; |
366 |
|
367 |
checkstandard(); |
368 |
|
369 |
wgetfile($fwfile, $url); |
370 |
verify($fwfile, $hash); |
371 |
|
372 |
$fwfile; |
373 |
} |
374 |
|
375 |
sub cx18 { |
376 |
my $url = "http://linuxtv.org/downloads/firmware/"; |
377 |
|
378 |
my %files = ( |
379 |
'v4l-cx23418-apu.fw' => '588f081b562f5c653a3db1ad8f65939a', |
380 |
'v4l-cx23418-cpu.fw' => 'b6c7ed64bc44b1a6e0840adaeac39d79', |
381 |
'v4l-cx23418-dig.fw' => '95bc688d3e7599fd5800161e9971cc55', |
382 |
); |
383 |
|
384 |
checkstandard(); |
385 |
|
386 |
my $allfiles; |
387 |
foreach my $fwfile (keys %files) { |
388 |
wgetfile($fwfile, "$url/$fwfile"); |
389 |
verify($fwfile, $files{$fwfile}); |
390 |
$allfiles .= " $fwfile"; |
391 |
} |
392 |
|
393 |
$allfiles =~ s/^\s//; |
394 |
|
395 |
$allfiles; |
396 |
} |
397 |
|
398 |
sub mpc718 { |
399 |
my $archive = 'Yuan MPC718 TV Tuner Card 2.13.10.1016.zip'; |
400 |
my $url = "ftp://ftp.work.acer-euro.com/desktop/aspire_idea510/vista/Drivers/$archive"; |
401 |
my $fwfile = "dvb-cx18-mpc718-mt352.fw"; |
402 |
my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 1); |
403 |
|
404 |
checkstandard(); |
405 |
wgetfile($archive, $url); |
406 |
unzip($archive, $tmpdir); |
407 |
|
408 |
my $sourcefile = "$tmpdir/Yuan MPC718 TV Tuner Card 2.13.10.1016/mpc718_32bit/yuanrap.sys"; |
409 |
my $found = 0; |
410 |
|
411 |
open IN, '<', $sourcefile or die "Couldn't open $sourcefile to extract $fwfile data\n"; |
412 |
binmode IN; |
413 |
open OUT, '>', $fwfile; |
414 |
binmode OUT; |
415 |
{ |
416 |
# Block scope because we change the line terminator variable $/ |
417 |
my $prevlen = 0; |
418 |
my $currlen; |
419 |
|
420 |
# Buried in the data segment are 3 runs of almost identical |
421 |
# register-value pairs that end in 0x5d 0x01 which is a "TUNER GO" |
422 |
# command for the MT352. |
423 |
# Pull out the middle run (because it's easy) of register-value |
424 |
# pairs to make the "firmware" file. |
425 |
|
426 |
local $/ = "\x5d\x01"; # MT352 "TUNER GO" |
427 |
|
428 |
while (<IN>) { |
429 |
$currlen = length($_); |
430 |
if ($prevlen == $currlen && $currlen <= 64) { |
431 |
chop; chop; # Get rid of "TUNER GO" |
432 |
s/^\0\0//; # get rid of leading 00 00 if it's there |
433 |
printf OUT "$_"; |
434 |
$found = 1; |
435 |
last; |
436 |
} |
437 |
$prevlen = $currlen; |
438 |
} |
439 |
} |
440 |
close OUT; |
441 |
close IN; |
442 |
if (!$found) { |
443 |
unlink $fwfile; |
444 |
die "Couldn't find valid register-value sequence in $sourcefile for $fwfile\n"; |
445 |
} |
446 |
$fwfile; |
447 |
} |
448 |
|
449 |
sub cx23885 { |
450 |
my $url = "http://linuxtv.org/downloads/firmware/"; |
451 |
|
452 |
my %files = ( |
453 |
'v4l-cx23885-avcore-01.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb', |
454 |
'v4l-cx23885-enc.fw' => 'a9f8f5d901a7fb42f552e1ee6384f3bb', |
455 |
); |
456 |
|
457 |
checkstandard(); |
458 |
|
459 |
my $allfiles; |
460 |
foreach my $fwfile (keys %files) { |
461 |
wgetfile($fwfile, "$url/$fwfile"); |
462 |
verify($fwfile, $files{$fwfile}); |
463 |
$allfiles .= " $fwfile"; |
464 |
} |
465 |
|
466 |
$allfiles =~ s/^\s//; |
467 |
|
468 |
$allfiles; |
469 |
} |
470 |
|
471 |
sub pvrusb2 { |
472 |
my $url = "http://linuxtv.org/downloads/firmware/"; |
473 |
|
474 |
my %files = ( |
475 |
'v4l-cx25840.fw' => 'dadb79e9904fc8af96e8111d9cb59320', |
476 |
); |
477 |
|
478 |
checkstandard(); |
479 |
|
480 |
my $allfiles; |
481 |
foreach my $fwfile (keys %files) { |
482 |
wgetfile($fwfile, "$url/$fwfile"); |
483 |
verify($fwfile, $files{$fwfile}); |
484 |
$allfiles .= " $fwfile"; |
485 |
} |
486 |
|
487 |
$allfiles =~ s/^\s//; |
488 |
|
489 |
$allfiles; |
490 |
} |
491 |
|
492 |
sub or51132_qam { |
493 |
my $fwfile = "dvb-fe-or51132-qam.fw"; |
494 |
my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
495 |
my $hash = "7702e8938612de46ccadfe9b413cb3b5"; |
496 |
|
497 |
checkstandard(); |
498 |
|
499 |
wgetfile($fwfile, $url); |
500 |
verify($fwfile, $hash); |
501 |
|
502 |
$fwfile; |
503 |
} |
504 |
|
505 |
sub or51132_vsb { |
506 |
my $fwfile = "dvb-fe-or51132-vsb.fw"; |
507 |
my $url = "http://linuxtv.org/downloads/firmware/$fwfile"; |
508 |
my $hash = "c16208e02f36fc439a557ad4c613364a"; |
509 |
|
510 |
checkstandard(); |
511 |
|
512 |
wgetfile($fwfile, $url); |
513 |
verify($fwfile, $hash); |
514 |
|
515 |
$fwfile; |
516 |
} |
517 |
|
518 |
sub bluebird { |
519 |
my $url = "http://www.linuxtv.org/download/dvb/firmware/dvb-usb-bluebird-01.fw"; |
520 |
my $outfile = "dvb-usb-bluebird-01.fw"; |
521 |
my $hash = "658397cb9eba9101af9031302671f49d"; |
522 |
|
523 |
checkstandard(); |
524 |
|
525 |
wgetfile($outfile, $url); |
526 |
verify($outfile,$hash); |
527 |
|
528 |
$outfile; |
529 |
} |
530 |
|
531 |
# --------------------------------------------------------------- |
532 |
# Utilities |
533 |
|
534 |
sub checkstandard { |
535 |
if (system("which unzip > /dev/null 2>&1")) { |
536 |
die "This firmware requires the unzip command - see ftp://ftp.info-zip.org/pub/infozip/UnZip.html\n"; |
537 |
} |
538 |
if (system("which md5sum > /dev/null 2>&1")) { |
539 |
die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n"; |
540 |
} |
541 |
if (system("which wget > /dev/null 2>&1")) { |
542 |
die "This firmware requires the wget command - see http://wget.sunsite.dk/\n"; |
543 |
} |
544 |
} |
545 |
|
546 |
sub checkunshield { |
547 |
if (system("which unshield > /dev/null 2>&1")) { |
548 |
die "This firmware requires the unshield command - see http://sourceforge.net/projects/synce/\n"; |
549 |
} |
550 |
} |
551 |
|
552 |
sub wgetfile { |
553 |
my ($sourcefile, $url) = @_; |
554 |
|
555 |
if (! -f $sourcefile) { |
556 |
system("wget -O \"$sourcefile\" \"$url\"") and die "wget failed - unable to download firmware"; |
557 |
} |
558 |
} |
559 |
|
560 |
sub unzip { |
561 |
my ($sourcefile, $todir) = @_; |
562 |
|
563 |
$status = system("unzip -q -o -d \"$todir\" \"$sourcefile\" 2>/dev/null" ); |
564 |
if ((($status >> 8) > 2) || (($status & 0xff) != 0)) { |
565 |
die ("unzip failed - unable to extract firmware"); |
566 |
} |
567 |
} |
568 |
|
569 |
sub unshield { |
570 |
my ($sourcefile, $todir) = @_; |
571 |
|
572 |
system("unshield x -d \"$todir\" \"$sourcefile\" > /dev/null" ) and die ("unshield failed - unable to extract firmware"); |
573 |
} |
574 |
|
575 |
sub verify { |
576 |
my ($filename, $hash) = @_; |
577 |
my ($testhash); |
578 |
|
579 |
open(CMD, "md5sum \"$filename\"|"); |
580 |
$testhash = <CMD>; |
581 |
$testhash =~ /([a-zA-Z0-9]*)/; |
582 |
$testhash = $1; |
583 |
close CMD; |
584 |
die "Hash of extracted file does not match!\n" if ($testhash ne $hash); |
585 |
} |
586 |
|
587 |
sub copy { |
588 |
my ($from, $to) = @_; |
589 |
|
590 |
system("cp -f \"$from\" \"$to\"") and die ("cp failed"); |
591 |
} |
592 |
|
593 |
sub extract { |
594 |
my ($infile, $offset, $length, $outfile) = @_; |
595 |
my ($chunklength, $buf, $rcount); |
596 |
|
597 |
open INFILE, "<$infile"; |
598 |
open OUTFILE, ">$outfile"; |
599 |
sysseek(INFILE, $offset, SEEK_SET); |
600 |
while($length > 0) { |
601 |
# Calc chunk size |
602 |
$chunklength = 2048; |
603 |
$chunklength = $length if ($chunklength > $length); |
604 |
|
605 |
$rcount = sysread(INFILE, $buf, $chunklength); |
606 |
die "Ran out of data\n" if ($rcount != $chunklength); |
607 |
syswrite(OUTFILE, $buf); |
608 |
$length -= $rcount; |
609 |
} |
610 |
close INFILE; |
611 |
close OUTFILE; |
612 |
} |
613 |
|
614 |
sub appendfile { |
615 |
my ($FH, $infile) = @_; |
616 |
my ($buf); |
617 |
|
618 |
open INFILE, "<$infile"; |
619 |
while(1) { |
620 |
$rcount = sysread(INFILE, $buf, 2048); |
621 |
last if ($rcount == 0); |
622 |
print $FH $buf; |
623 |
} |
624 |
close(INFILE); |
625 |
} |
626 |
|
627 |
sub delzero{ |
628 |
my ($infile,$outfile) =@_; |
629 |
|
630 |
open INFILE,"<$infile"; |
631 |
open OUTFILE,">$outfile"; |
632 |
while (1){ |
633 |
$rcount=sysread(INFILE,$buf,22); |
634 |
$len=ord(substr($buf,0,1)); |
635 |
print OUTFILE substr($buf,0,1); |
636 |
print OUTFILE substr($buf,2,$len+3); |
637 |
last if ($rcount<1); |
638 |
printf OUTFILE "%c",0; |
639 |
#print $len." ".length($buf)."\n"; |
640 |
|
641 |
} |
642 |
close(INFILE); |
643 |
close(OUTFILE); |
644 |
} |
645 |
|
646 |
sub syntax() { |
647 |
print STDERR "syntax: get_dvb_firmware <component>\n"; |
648 |
print STDERR "Supported components:\n"; |
649 |
for($i=0; $i < scalar(@components); $i++) { |
650 |
print STDERR "\t" . $components[$i] . "\n"; |
651 |
} |
652 |
exit(1); |
653 |
} |