V4L/DVB (9534): cx88: Add support for Prof 6200 DVB-S PCI card
[linux-2.6.git] / Documentation / video4linux / extract_xc3028.pl
1 #!/usr/bin/perl
2
3 # Copyright (c) Mauro Carvalho Chehab <mchehab@infradead.org>
4 # Released under GPLv2
5 #
6 # In order to use, you need to:
7 #       1) Download the windows driver with something like:
8 #               wget http://www.steventoth.net/linux/xc5000/HVR-12x0-14x0-17x0_1_25_25271_WHQL.zip
9 #       2) Extract the file hcw85bda.sys from the zip into the current dir:
10 #               unzip -j HVR-12x0-14x0-17x0_1_25_25271_WHQL.zip Driver85/hcw85bda.sys
11 #       3) run the script:
12 #               ./extract_xc3028.pl
13 #       4) copy the generated file:
14 #               cp xc3028-v27.fw /lib/firmware
15
16 #use strict;
17 use IO::Handle;
18
19 my $debug=0;
20
21 sub verify ($$)
22 {
23         my ($filename, $hash) = @_;
24         my ($testhash);
25
26         if (system("which md5sum > /dev/null 2>&1")) {
27                 die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n";
28         }
29
30         open(CMD, "md5sum ".$filename."|");
31         $testhash = <CMD>;
32         $testhash =~ /([a-zA-Z0-9]*)/;
33         $testhash = $1;
34         close CMD;
35                 die "Hash of extracted file does not match (found $testhash, expected $hash!\n" if ($testhash ne $hash);
36 }
37
38 sub get_hunk ($$)
39 {
40         my ($offset, $length) = @_;
41         my ($chunklength, $buf, $rcount, $out);
42
43         sysseek(INFILE, $offset, SEEK_SET);
44         while ($length > 0) {
45         # Calc chunk size
46                 $chunklength = 2048;
47                 $chunklength = $length if ($chunklength > $length);
48
49                 $rcount = sysread(INFILE, $buf, $chunklength);
50                 die "Ran out of data\n" if ($rcount != $chunklength);
51                 $out .= $buf;
52                 $length -= $rcount;
53         }
54         return $out;
55 }
56
57 sub write_le16($)
58 {
59         my $val = shift;
60         my $msb = ($val >> 8) &0xff;
61         my $lsb = $val & 0xff;
62
63         syswrite(OUTFILE, chr($lsb).chr($msb));
64 }
65
66 sub write_le32($)
67 {
68         my $val = shift;
69         my $l3 = ($val >> 24) & 0xff;
70         my $l2 = ($val >> 16) & 0xff;
71         my $l1 = ($val >> 8)  & 0xff;
72         my $l0 = $val         & 0xff;
73
74         syswrite(OUTFILE, chr($l0).chr($l1).chr($l2).chr($l3));
75 }
76
77 sub write_le64($$)
78 {
79         my $msb_val = shift;
80         my $lsb_val = shift;
81         my $l7 = ($msb_val >> 24) & 0xff;
82         my $l6 = ($msb_val >> 16) & 0xff;
83         my $l5 = ($msb_val >> 8)  & 0xff;
84         my $l4 = $msb_val         & 0xff;
85
86         my $l3 = ($lsb_val >> 24) & 0xff;
87         my $l2 = ($lsb_val >> 16) & 0xff;
88         my $l1 = ($lsb_val >> 8)  & 0xff;
89         my $l0 = $lsb_val         & 0xff;
90
91         syswrite(OUTFILE,
92                  chr($l0).chr($l1).chr($l2).chr($l3).
93                  chr($l4).chr($l5).chr($l6).chr($l7));
94 }
95
96 sub write_hunk($$)
97 {
98         my ($offset, $length) = @_;
99         my $out = get_hunk($offset, $length);
100
101         printf "(len %d) ",$length if ($debug);
102
103         for (my $i=0;$i<$length;$i++) {
104                 printf "%02x ",ord(substr($out,$i,1)) if ($debug);
105         }
106         printf "\n" if ($debug);
107
108         syswrite(OUTFILE, $out);
109 }
110
111 sub write_hunk_fix_endian($$)
112 {
113         my ($offset, $length) = @_;
114         my $out = get_hunk($offset, $length);
115
116         printf "(len_fix %d) ",$length if ($debug);
117
118         for (my $i=0;$i<$length;$i++) {
119                 printf "%02x ",ord(substr($out,$i,1)) if ($debug);
120         }
121         printf "\n" if ($debug);
122
123         my $i=0;
124         while ($i<$length) {
125                 my $size = ord(substr($out,$i,1))*256+ord(substr($out,$i+1,1));
126                 syswrite(OUTFILE, substr($out,$i+1,1));
127                 syswrite(OUTFILE, substr($out,$i,1));
128                 $i+=2;
129                 if ($size>0 && $size <0x8000) {
130                         for (my $j=0;$j<$size;$j++) {
131                                 syswrite(OUTFILE, substr($out,$j+$i,1));
132                         }
133                         $i+=$size;
134                 }
135         }
136 }
137
138 sub main_firmware($$$$)
139 {
140         my $out;
141         my $j=0;
142         my $outfile = shift;
143         my $name    = shift;
144         my $version = shift;
145         my $nr_desc = shift;
146
147         for ($j = length($name); $j <32; $j++) {
148                 $name = $name.chr(0);
149 }
150
151         open OUTFILE, ">$outfile";
152         syswrite(OUTFILE, $name);
153         write_le16($version);
154         write_le16($nr_desc);
155
156         #
157         # Firmware 0, type: BASE FW   F8MHZ (0x00000003), id: (0000000000000000), size: 8718
158         #
159
160         write_le32(0x00000003);                 # Type
161         write_le64(0x00000000, 0x00000000);     # ID
162         write_le32(8718);                       # Size
163         write_hunk_fix_endian(813432, 8718);
164
165         #
166         # Firmware 1, type: BASE FW   F8MHZ MTS (0x00000007), id: (0000000000000000), size: 8712
167         #
168
169         write_le32(0x00000007);                 # Type
170         write_le64(0x00000000, 0x00000000);     # ID
171         write_le32(8712);                       # Size
172         write_hunk_fix_endian(822152, 8712);
173
174         #
175         # Firmware 2, type: BASE FW   FM (0x00000401), id: (0000000000000000), size: 8562
176         #
177
178         write_le32(0x00000401);                 # Type
179         write_le64(0x00000000, 0x00000000);     # ID
180         write_le32(8562);                       # Size
181         write_hunk_fix_endian(830872, 8562);
182
183         #
184         # Firmware 3, type: BASE FW   FM INPUT1 (0x00000c01), id: (0000000000000000), size: 8576
185         #
186
187         write_le32(0x00000c01);                 # Type
188         write_le64(0x00000000, 0x00000000);     # ID
189         write_le32(8576);                       # Size
190         write_hunk_fix_endian(839440, 8576);
191
192         #
193         # Firmware 4, type: BASE FW   (0x00000001), id: (0000000000000000), size: 8706
194         #
195
196         write_le32(0x00000001);                 # Type
197         write_le64(0x00000000, 0x00000000);     # ID
198         write_le32(8706);                       # Size
199         write_hunk_fix_endian(848024, 8706);
200
201         #
202         # Firmware 5, type: BASE FW   MTS (0x00000005), id: (0000000000000000), size: 8682
203         #
204
205         write_le32(0x00000005);                 # Type
206         write_le64(0x00000000, 0x00000000);     # ID
207         write_le32(8682);                       # Size
208         write_hunk_fix_endian(856736, 8682);
209
210         #
211         # Firmware 6, type: STD FW    (0x00000000), id: PAL/BG A2/A (0000000100000007), size: 161
212         #
213
214         write_le32(0x00000000);                 # Type
215         write_le64(0x00000001, 0x00000007);     # ID
216         write_le32(161);                        # Size
217         write_hunk_fix_endian(865424, 161);
218
219         #
220         # Firmware 7, type: STD FW    MTS (0x00000004), id: PAL/BG A2/A (0000000100000007), size: 169
221         #
222
223         write_le32(0x00000004);                 # Type
224         write_le64(0x00000001, 0x00000007);     # ID
225         write_le32(169);                        # Size
226         write_hunk_fix_endian(865592, 169);
227
228         #
229         # Firmware 8, type: STD FW    (0x00000000), id: PAL/BG A2/B (0000000200000007), size: 161
230         #
231
232         write_le32(0x00000000);                 # Type
233         write_le64(0x00000002, 0x00000007);     # ID
234         write_le32(161);                        # Size
235         write_hunk_fix_endian(865424, 161);
236
237         #
238         # Firmware 9, type: STD FW    MTS (0x00000004), id: PAL/BG A2/B (0000000200000007), size: 169
239         #
240
241         write_le32(0x00000004);                 # Type
242         write_le64(0x00000002, 0x00000007);     # ID
243         write_le32(169);                        # Size
244         write_hunk_fix_endian(865592, 169);
245
246         #
247         # Firmware 10, type: STD FW    (0x00000000), id: PAL/BG NICAM/A (0000000400000007), size: 161
248         #
249
250         write_le32(0x00000000);                 # Type
251         write_le64(0x00000004, 0x00000007);     # ID
252         write_le32(161);                        # Size
253         write_hunk_fix_endian(866112, 161);
254
255         #
256         # Firmware 11, type: STD FW    MTS (0x00000004), id: PAL/BG NICAM/A (0000000400000007), size: 169
257         #
258
259         write_le32(0x00000004);                 # Type
260         write_le64(0x00000004, 0x00000007);     # ID
261         write_le32(169);                        # Size
262         write_hunk_fix_endian(866280, 169);
263
264         #
265         # Firmware 12, type: STD FW    (0x00000000), id: PAL/BG NICAM/B (0000000800000007), size: 161
266         #
267
268         write_le32(0x00000000);                 # Type
269         write_le64(0x00000008, 0x00000007);     # ID
270         write_le32(161);                        # Size
271         write_hunk_fix_endian(866112, 161);
272
273         #
274         # Firmware 13, type: STD FW    MTS (0x00000004), id: PAL/BG NICAM/B (0000000800000007), size: 169
275         #
276
277         write_le32(0x00000004);                 # Type
278         write_le64(0x00000008, 0x00000007);     # ID
279         write_le32(169);                        # Size
280         write_hunk_fix_endian(866280, 169);
281
282         #
283         # Firmware 14, type: STD FW    (0x00000000), id: PAL/DK A2 (00000003000000e0), size: 161
284         #
285
286         write_le32(0x00000000);                 # Type
287         write_le64(0x00000003, 0x000000e0);     # ID
288         write_le32(161);                        # Size
289         write_hunk_fix_endian(866800, 161);
290
291         #
292         # Firmware 15, type: STD FW    MTS (0x00000004), id: PAL/DK A2 (00000003000000e0), size: 169
293         #
294
295         write_le32(0x00000004);                 # Type
296         write_le64(0x00000003, 0x000000e0);     # ID
297         write_le32(169);                        # Size
298         write_hunk_fix_endian(866968, 169);
299
300         #
301         # Firmware 16, type: STD FW    (0x00000000), id: PAL/DK NICAM (0000000c000000e0), size: 161
302         #
303
304         write_le32(0x00000000);                 # Type
305         write_le64(0x0000000c, 0x000000e0);     # ID
306         write_le32(161);                        # Size
307         write_hunk_fix_endian(867144, 161);
308
309         #
310         # Firmware 17, type: STD FW    MTS (0x00000004), id: PAL/DK NICAM (0000000c000000e0), size: 169
311         #
312
313         write_le32(0x00000004);                 # Type
314         write_le64(0x0000000c, 0x000000e0);     # ID
315         write_le32(169);                        # Size
316         write_hunk_fix_endian(867312, 169);
317
318         #
319         # Firmware 18, type: STD FW    (0x00000000), id: SECAM/K1 (0000000000200000), size: 161
320         #
321
322         write_le32(0x00000000);                 # Type
323         write_le64(0x00000000, 0x00200000);     # ID
324         write_le32(161);                        # Size
325         write_hunk_fix_endian(867488, 161);
326
327         #
328         # Firmware 19, type: STD FW    MTS (0x00000004), id: SECAM/K1 (0000000000200000), size: 169
329         #
330
331         write_le32(0x00000004);                 # Type
332         write_le64(0x00000000, 0x00200000);     # ID
333         write_le32(169);                        # Size
334         write_hunk_fix_endian(867656, 169);
335
336         #
337         # Firmware 20, type: STD FW    (0x00000000), id: SECAM/K3 (0000000004000000), size: 161
338         #
339
340         write_le32(0x00000000);                 # Type
341         write_le64(0x00000000, 0x04000000);     # ID
342         write_le32(161);                        # Size
343         write_hunk_fix_endian(867832, 161);
344
345         #
346         # Firmware 21, type: STD FW    MTS (0x00000004), id: SECAM/K3 (0000000004000000), size: 169
347         #
348
349         write_le32(0x00000004);                 # Type
350         write_le64(0x00000000, 0x04000000);     # ID
351         write_le32(169);                        # Size
352         write_hunk_fix_endian(868000, 169);
353
354         #
355         # Firmware 22, type: STD FW    D2633 DTV6 ATSC (0x00010030), id: (0000000000000000), size: 149
356         #
357
358         write_le32(0x00010030);                 # Type
359         write_le64(0x00000000, 0x00000000);     # ID
360         write_le32(149);                        # Size
361         write_hunk_fix_endian(868176, 149);
362
363         #
364         # Firmware 23, type: STD FW    D2620 DTV6 QAM (0x00000068), id: (0000000000000000), size: 149
365         #
366
367         write_le32(0x00000068);                 # Type
368         write_le64(0x00000000, 0x00000000);     # ID
369         write_le32(149);                        # Size
370         write_hunk_fix_endian(868336, 149);
371
372         #
373         # Firmware 24, type: STD FW    D2633 DTV6 QAM (0x00000070), id: (0000000000000000), size: 149
374         #
375
376         write_le32(0x00000070);                 # Type
377         write_le64(0x00000000, 0x00000000);     # ID
378         write_le32(149);                        # Size
379         write_hunk_fix_endian(868488, 149);
380
381         #
382         # Firmware 25, type: STD FW    D2620 DTV7 (0x00000088), id: (0000000000000000), size: 149
383         #
384
385         write_le32(0x00000088);                 # Type
386         write_le64(0x00000000, 0x00000000);     # ID
387         write_le32(149);                        # Size
388         write_hunk_fix_endian(868648, 149);
389
390         #
391         # Firmware 26, type: STD FW    D2633 DTV7 (0x00000090), id: (0000000000000000), size: 149
392         #
393
394         write_le32(0x00000090);                 # Type
395         write_le64(0x00000000, 0x00000000);     # ID
396         write_le32(149);                        # Size
397         write_hunk_fix_endian(868800, 149);
398
399         #
400         # Firmware 27, type: STD FW    D2620 DTV78 (0x00000108), id: (0000000000000000), size: 149
401         #
402
403         write_le32(0x00000108);                 # Type
404         write_le64(0x00000000, 0x00000000);     # ID
405         write_le32(149);                        # Size
406         write_hunk_fix_endian(868960, 149);
407
408         #
409         # Firmware 28, type: STD FW    D2633 DTV78 (0x00000110), id: (0000000000000000), size: 149
410         #
411
412         write_le32(0x00000110);                 # Type
413         write_le64(0x00000000, 0x00000000);     # ID
414         write_le32(149);                        # Size
415         write_hunk_fix_endian(869112, 149);
416
417         #
418         # Firmware 29, type: STD FW    D2620 DTV8 (0x00000208), id: (0000000000000000), size: 149
419         #
420
421         write_le32(0x00000208);                 # Type
422         write_le64(0x00000000, 0x00000000);     # ID
423         write_le32(149);                        # Size
424         write_hunk_fix_endian(868648, 149);
425
426         #
427         # Firmware 30, type: STD FW    D2633 DTV8 (0x00000210), id: (0000000000000000), size: 149
428         #
429
430         write_le32(0x00000210);                 # Type
431         write_le64(0x00000000, 0x00000000);     # ID
432         write_le32(149);                        # Size
433         write_hunk_fix_endian(868800, 149);
434
435         #
436         # Firmware 31, type: STD FW    FM (0x00000400), id: (0000000000000000), size: 135
437         #
438
439         write_le32(0x00000400);                 # Type
440         write_le64(0x00000000, 0x00000000);     # ID
441         write_le32(135);                        # Size
442         write_hunk_fix_endian(869584, 135);
443
444         #
445         # Firmware 32, type: STD FW    (0x00000000), id: PAL/I (0000000000000010), size: 161
446         #
447
448         write_le32(0x00000000);                 # Type
449         write_le64(0x00000000, 0x00000010);     # ID
450         write_le32(161);                        # Size
451         write_hunk_fix_endian(869728, 161);
452
453         #
454         # Firmware 33, type: STD FW    MTS (0x00000004), id: PAL/I (0000000000000010), size: 169
455         #
456
457         write_le32(0x00000004);                 # Type
458         write_le64(0x00000000, 0x00000010);     # ID
459         write_le32(169);                        # Size
460         write_hunk_fix_endian(869896, 169);
461
462         #
463         # Firmware 34, type: STD FW    (0x00000000), id: SECAM/L AM (0000001000400000), size: 169
464         #
465
466         write_le32(0x00000000);                 # Type
467         write_le64(0x00000010, 0x00400000);     # ID
468         write_le32(169);                        # Size
469         write_hunk_fix_endian(870072, 169);
470
471         #
472         # Firmware 35, type: STD FW    (0x00000000), id: SECAM/L NICAM (0000000c00400000), size: 161
473         #
474
475         write_le32(0x00000000);                 # Type
476         write_le64(0x0000000c, 0x00400000);     # ID
477         write_le32(161);                        # Size
478         write_hunk_fix_endian(870248, 161);
479
480         #
481         # Firmware 36, type: STD FW    (0x00000000), id: SECAM/Lc (0000000000800000), size: 161
482         #
483
484         write_le32(0x00000000);                 # Type
485         write_le64(0x00000000, 0x00800000);     # ID
486         write_le32(161);                        # Size
487         write_hunk_fix_endian(870416, 161);
488
489         #
490         # Firmware 37, type: STD FW    (0x00000000), id: NTSC/M Kr (0000000000008000), size: 161
491         #
492
493         write_le32(0x00000000);                 # Type
494         write_le64(0x00000000, 0x00008000);     # ID
495         write_le32(161);                        # Size
496         write_hunk_fix_endian(870584, 161);
497
498         #
499         # Firmware 38, type: STD FW    LCD (0x00001000), id: NTSC/M Kr (0000000000008000), size: 161
500         #
501
502         write_le32(0x00001000);                 # Type
503         write_le64(0x00000000, 0x00008000);     # ID
504         write_le32(161);                        # Size
505         write_hunk_fix_endian(870752, 161);
506
507         #
508         # Firmware 39, type: STD FW    LCD NOGD (0x00003000), id: NTSC/M Kr (0000000000008000), size: 161
509         #
510
511         write_le32(0x00003000);                 # Type
512         write_le64(0x00000000, 0x00008000);     # ID
513         write_le32(161);                        # Size
514         write_hunk_fix_endian(870920, 161);
515
516         #
517         # Firmware 40, type: STD FW    MTS (0x00000004), id: NTSC/M Kr (0000000000008000), size: 169
518         #
519
520         write_le32(0x00000004);                 # Type
521         write_le64(0x00000000, 0x00008000);     # ID
522         write_le32(169);                        # Size
523         write_hunk_fix_endian(871088, 169);
524
525         #
526         # Firmware 41, type: STD FW    (0x00000000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
527         #
528
529         write_le32(0x00000000);                 # Type
530         write_le64(0x00000000, 0x0000b700);     # ID
531         write_le32(161);                        # Size
532         write_hunk_fix_endian(871264, 161);
533
534         #
535         # Firmware 42, type: STD FW    LCD (0x00001000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
536         #
537
538         write_le32(0x00001000);                 # Type
539         write_le64(0x00000000, 0x0000b700);     # ID
540         write_le32(161);                        # Size
541         write_hunk_fix_endian(871432, 161);
542
543         #
544         # Firmware 43, type: STD FW    LCD NOGD (0x00003000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
545         #
546
547         write_le32(0x00003000);                 # Type
548         write_le64(0x00000000, 0x0000b700);     # ID
549         write_le32(161);                        # Size
550         write_hunk_fix_endian(871600, 161);
551
552         #
553         # Firmware 44, type: STD FW    (0x00000000), id: NTSC/M Jp (0000000000002000), size: 161
554         #
555
556         write_le32(0x00000000);                 # Type
557         write_le64(0x00000000, 0x00002000);     # ID
558         write_le32(161);                        # Size
559         write_hunk_fix_endian(871264, 161);
560
561         #
562         # Firmware 45, type: STD FW    MTS (0x00000004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
563         #
564
565         write_le32(0x00000004);                 # Type
566         write_le64(0x00000000, 0x0000b700);     # ID
567         write_le32(169);                        # Size
568         write_hunk_fix_endian(871936, 169);
569
570         #
571         # Firmware 46, type: STD FW    MTS LCD (0x00001004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
572         #
573
574         write_le32(0x00001004);                 # Type
575         write_le64(0x00000000, 0x0000b700);     # ID
576         write_le32(169);                        # Size
577         write_hunk_fix_endian(872112, 169);
578
579         #
580         # Firmware 47, type: STD FW    MTS LCD NOGD (0x00003004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
581         #
582
583         write_le32(0x00003004);                 # Type
584         write_le64(0x00000000, 0x0000b700);     # ID
585         write_le32(169);                        # Size
586         write_hunk_fix_endian(872288, 169);
587
588         #
589         # Firmware 48, type: SCODE FW  HAS IF (0x60000000), IF = 3.28 MHz id: (0000000000000000), size: 192
590         #
591
592         write_le32(0x60000000);                 # Type
593         write_le64(0x00000000, 0x00000000);     # ID
594         write_le16(3280);                       # IF
595         write_le32(192);                        # Size
596         write_hunk(811896, 192);
597
598         #
599         # Firmware 49, type: SCODE FW  HAS IF (0x60000000), IF = 3.30 MHz id: (0000000000000000), size: 192
600         #
601
602         write_le32(0x60000000);                 # Type
603         write_le64(0x00000000, 0x00000000);     # ID
604         write_le16(3300);                       # IF
605         write_le32(192);                        # Size
606         write_hunk(813048, 192);
607
608         #
609         # Firmware 50, type: SCODE FW  HAS IF (0x60000000), IF = 3.44 MHz id: (0000000000000000), size: 192
610         #
611
612         write_le32(0x60000000);                 # Type
613         write_le64(0x00000000, 0x00000000);     # ID
614         write_le16(3440);                       # IF
615         write_le32(192);                        # Size
616         write_hunk(812280, 192);
617
618         #
619         # Firmware 51, type: SCODE FW  HAS IF (0x60000000), IF = 3.46 MHz id: (0000000000000000), size: 192
620         #
621
622         write_le32(0x60000000);                 # Type
623         write_le64(0x00000000, 0x00000000);     # ID
624         write_le16(3460);                       # IF
625         write_le32(192);                        # Size
626         write_hunk(812472, 192);
627
628         #
629         # Firmware 52, type: SCODE FW  DTV6 ATSC OREN36 HAS IF (0x60210020), IF = 3.80 MHz id: (0000000000000000), size: 192
630         #
631
632         write_le32(0x60210020);                 # Type
633         write_le64(0x00000000, 0x00000000);     # ID
634         write_le16(3800);                       # IF
635         write_le32(192);                        # Size
636         write_hunk(809784, 192);
637
638         #
639         # Firmware 53, type: SCODE FW  HAS IF (0x60000000), IF = 4.00 MHz id: (0000000000000000), size: 192
640         #
641
642         write_le32(0x60000000);                 # Type
643         write_le64(0x00000000, 0x00000000);     # ID
644         write_le16(4000);                       # IF
645         write_le32(192);                        # Size
646         write_hunk(812088, 192);
647
648         #
649         # Firmware 54, type: SCODE FW  DTV6 ATSC TOYOTA388 HAS IF (0x60410020), IF = 4.08 MHz id: (0000000000000000), size: 192
650         #
651
652         write_le32(0x60410020);                 # Type
653         write_le64(0x00000000, 0x00000000);     # ID
654         write_le16(4080);                       # IF
655         write_le32(192);                        # Size
656         write_hunk(809976, 192);
657
658         #
659         # Firmware 55, type: SCODE FW  HAS IF (0x60000000), IF = 4.20 MHz id: (0000000000000000), size: 192
660         #
661
662         write_le32(0x60000000);                 # Type
663         write_le64(0x00000000, 0x00000000);     # ID
664         write_le16(4200);                       # IF
665         write_le32(192);                        # Size
666         write_hunk(811704, 192);
667
668         #
669         # Firmware 56, type: SCODE FW  MONO HAS IF (0x60008000), IF = 4.32 MHz id: NTSC/M Kr (0000000000008000), size: 192
670         #
671
672         write_le32(0x60008000);                 # Type
673         write_le64(0x00000000, 0x00008000);     # ID
674         write_le16(4320);                       # IF
675         write_le32(192);                        # Size
676         write_hunk(808056, 192);
677
678         #
679         # Firmware 57, type: SCODE FW  HAS IF (0x60000000), IF = 4.45 MHz id: (0000000000000000), size: 192
680         #
681
682         write_le32(0x60000000);                 # Type
683         write_le64(0x00000000, 0x00000000);     # ID
684         write_le16(4450);                       # IF
685         write_le32(192);                        # Size
686         write_hunk(812664, 192);
687
688         #
689         # Firmware 58, type: SCODE FW  MTS LCD NOGD MONO IF HAS IF (0x6002b004), IF = 4.50 MHz id: NTSC PAL/M PAL/N (000000000000b700), size: 192
690         #
691
692         write_le32(0x6002b004);                 # Type
693         write_le64(0x00000000, 0x0000b700);     # ID
694         write_le16(4500);                       # IF
695         write_le32(192);                        # Size
696         write_hunk(807672, 192);
697
698         #
699         # Firmware 59, type: SCODE FW  LCD NOGD IF HAS IF (0x60023000), IF = 4.60 MHz id: NTSC/M Kr (0000000000008000), size: 192
700         #
701
702         write_le32(0x60023000);                 # Type
703         write_le64(0x00000000, 0x00008000);     # ID
704         write_le16(4600);                       # IF
705         write_le32(192);                        # Size
706         write_hunk(807864, 192);
707
708         #
709         # Firmware 60, type: SCODE FW  DTV6 QAM DTV7 DTV78 DTV8 ZARLINK456 HAS IF (0x620003e0), IF = 4.76 MHz id: (0000000000000000), size: 192
710         #
711
712         write_le32(0x620003e0);                 # Type
713         write_le64(0x00000000, 0x00000000);     # ID
714         write_le16(4760);                       # IF
715         write_le32(192);                        # Size
716         write_hunk(807288, 192);
717
718         #
719         # Firmware 61, type: SCODE FW  HAS IF (0x60000000), IF = 4.94 MHz id: (0000000000000000), size: 192
720         #
721
722         write_le32(0x60000000);                 # Type
723         write_le64(0x00000000, 0x00000000);     # ID
724         write_le16(4940);                       # IF
725         write_le32(192);                        # Size
726         write_hunk(811512, 192);
727
728         #
729         # Firmware 62, type: SCODE FW  HAS IF (0x60000000), IF = 5.26 MHz id: (0000000000000000), size: 192
730         #
731
732         write_le32(0x60000000);                 # Type
733         write_le64(0x00000000, 0x00000000);     # ID
734         write_le16(5260);                       # IF
735         write_le32(192);                        # Size
736         write_hunk(810552, 192);
737
738         #
739         # Firmware 63, type: SCODE FW  MONO HAS IF (0x60008000), IF = 5.32 MHz id: PAL/BG A2 NICAM (0000000f00000007), size: 192
740         #
741
742         write_le32(0x60008000);                 # Type
743         write_le64(0x0000000f, 0x00000007);     # ID
744         write_le16(5320);                       # IF
745         write_le32(192);                        # Size
746         write_hunk(810744, 192);
747
748         #
749         # Firmware 64, type: SCODE FW  DTV7 DTV78 DTV8 DIBCOM52 CHINA HAS IF (0x65000380), IF = 5.40 MHz id: (0000000000000000), size: 192
750         #
751
752         write_le32(0x65000380);                 # Type
753         write_le64(0x00000000, 0x00000000);     # ID
754         write_le16(5400);                       # IF
755         write_le32(192);                        # Size
756         write_hunk(807096, 192);
757
758         #
759         # Firmware 65, type: SCODE FW  DTV6 ATSC OREN538 HAS IF (0x60110020), IF = 5.58 MHz id: (0000000000000000), size: 192
760         #
761
762         write_le32(0x60110020);                 # Type
763         write_le64(0x00000000, 0x00000000);     # ID
764         write_le16(5580);                       # IF
765         write_le32(192);                        # Size
766         write_hunk(809592, 192);
767
768         #
769         # Firmware 66, type: SCODE FW  HAS IF (0x60000000), IF = 5.64 MHz id: PAL/BG A2 (0000000300000007), size: 192
770         #
771
772         write_le32(0x60000000);                 # Type
773         write_le64(0x00000003, 0x00000007);     # ID
774         write_le16(5640);                       # IF
775         write_le32(192);                        # Size
776         write_hunk(808440, 192);
777
778         #
779         # Firmware 67, type: SCODE FW  HAS IF (0x60000000), IF = 5.74 MHz id: PAL/BG NICAM (0000000c00000007), size: 192
780         #
781
782         write_le32(0x60000000);                 # Type
783         write_le64(0x0000000c, 0x00000007);     # ID
784         write_le16(5740);                       # IF
785         write_le32(192);                        # Size
786         write_hunk(808632, 192);
787
788         #
789         # Firmware 68, type: SCODE FW  HAS IF (0x60000000), IF = 5.90 MHz id: (0000000000000000), size: 192
790         #
791
792         write_le32(0x60000000);                 # Type
793         write_le64(0x00000000, 0x00000000);     # ID
794         write_le16(5900);                       # IF
795         write_le32(192);                        # Size
796         write_hunk(810360, 192);
797
798         #
799         # Firmware 69, type: SCODE FW  MONO HAS IF (0x60008000), IF = 6.00 MHz id: PAL/DK PAL/I SECAM/K3 SECAM/L SECAM/Lc NICAM (0000000c04c000f0), size: 192
800         #
801
802         write_le32(0x60008000);                 # Type
803         write_le64(0x0000000c, 0x04c000f0);     # ID
804         write_le16(6000);                       # IF
805         write_le32(192);                        # Size
806         write_hunk(808824, 192);
807
808         #
809         # Firmware 70, type: SCODE FW  DTV6 QAM ATSC LG60 F6MHZ HAS IF (0x68050060), IF = 6.20 MHz id: (0000000000000000), size: 192
810         #
811
812         write_le32(0x68050060);                 # Type
813         write_le64(0x00000000, 0x00000000);     # ID
814         write_le16(6200);                       # IF
815         write_le32(192);                        # Size
816         write_hunk(809400, 192);
817
818         #
819         # Firmware 71, type: SCODE FW  HAS IF (0x60000000), IF = 6.24 MHz id: PAL/I (0000000000000010), size: 192
820         #
821
822         write_le32(0x60000000);                 # Type
823         write_le64(0x00000000, 0x00000010);     # ID
824         write_le16(6240);                       # IF
825         write_le32(192);                        # Size
826         write_hunk(808248, 192);
827
828         #
829         # Firmware 72, type: SCODE FW  MONO HAS IF (0x60008000), IF = 6.32 MHz id: SECAM/K1 (0000000000200000), size: 192
830         #
831
832         write_le32(0x60008000);                 # Type
833         write_le64(0x00000000, 0x00200000);     # ID
834         write_le16(6320);                       # IF
835         write_le32(192);                        # Size
836         write_hunk(811320, 192);
837
838         #
839         # Firmware 73, type: SCODE FW  HAS IF (0x60000000), IF = 6.34 MHz id: SECAM/K1 (0000000000200000), size: 192
840         #
841
842         write_le32(0x60000000);                 # Type
843         write_le64(0x00000000, 0x00200000);     # ID
844         write_le16(6340);                       # IF
845         write_le32(192);                        # Size
846         write_hunk(809208, 192);
847
848         #
849         # Firmware 74, type: SCODE FW  MONO HAS IF (0x60008000), IF = 6.50 MHz id: PAL/DK SECAM/K3 SECAM/L NICAM (0000000c044000e0), size: 192
850         #
851
852         write_le32(0x60008000);                 # Type
853         write_le64(0x0000000c, 0x044000e0);     # ID
854         write_le16(6500);                       # IF
855         write_le32(192);                        # Size
856         write_hunk(811128, 192);
857
858         #
859         # Firmware 75, type: SCODE FW  DTV6 ATSC ATI638 HAS IF (0x60090020), IF = 6.58 MHz id: (0000000000000000), size: 192
860         #
861
862         write_le32(0x60090020);                 # Type
863         write_le64(0x00000000, 0x00000000);     # ID
864         write_le16(6580);                       # IF
865         write_le32(192);                        # Size
866         write_hunk(807480, 192);
867
868         #
869         # Firmware 76, type: SCODE FW  HAS IF (0x60000000), IF = 6.60 MHz id: PAL/DK A2 (00000003000000e0), size: 192
870         #
871
872         write_le32(0x60000000);                 # Type
873         write_le64(0x00000003, 0x000000e0);     # ID
874         write_le16(6600);                       # IF
875         write_le32(192);                        # Size
876         write_hunk(809016, 192);
877
878         #
879         # Firmware 77, type: SCODE FW  MONO HAS IF (0x60008000), IF = 6.68 MHz id: PAL/DK A2 (00000003000000e0), size: 192
880         #
881
882         write_le32(0x60008000);                 # Type
883         write_le64(0x00000003, 0x000000e0);     # ID
884         write_le16(6680);                       # IF
885         write_le32(192);                        # Size
886         write_hunk(810936, 192);
887
888         #
889         # Firmware 78, type: SCODE FW  DTV6 ATSC TOYOTA794 HAS IF (0x60810020), IF = 8.14 MHz id: (0000000000000000), size: 192
890         #
891
892         write_le32(0x60810020);                 # Type
893         write_le64(0x00000000, 0x00000000);     # ID
894         write_le16(8140);                       # IF
895         write_le32(192);                        # Size
896         write_hunk(810168, 192);
897
898         #
899         # Firmware 79, type: SCODE FW  HAS IF (0x60000000), IF = 8.20 MHz id: (0000000000000000), size: 192
900         #
901
902         write_le32(0x60000000);                 # Type
903         write_le64(0x00000000, 0x00000000);     # ID
904         write_le16(8200);                       # IF
905         write_le32(192);                        # Size
906         write_hunk(812856, 192);
907 }
908
909 sub extract_firmware {
910         my $sourcefile = "hcw85bda.sys";
911         my $hash = "0e44dbf63bb0169d57446aec21881ff2";
912         my $outfile = "xc3028-v27.fw";
913         my $name = "xc2028 firmware";
914         my $version = 519;
915         my $nr_desc = 80;
916         my $out;
917
918         verify($sourcefile, $hash);
919
920         open INFILE, "<$sourcefile";
921         main_firmware($outfile, $name, $version, $nr_desc);
922         close INFILE;
923 }
924
925 extract_firmware;
926 printf "Firmwares generated.\n";