Back to home page

LXR

 
 

    


0001 #!/usr/bin/perl
0002 
0003 # Copyright (c) Mauro Carvalho Chehab <mchehab@infradead.org>
0004 # Released under GPLv2
0005 #
0006 # In order to use, you need to:
0007 #   1) Download the windows driver with something like:
0008 #   Version 2.4
0009 #       wget http://www.twinhan.com/files/AW/BDA T/20080303_V1.0.6.7.zip
0010 #       or wget http://www.stefanringel.de/pub/20080303_V1.0.6.7.zip
0011 #   Version 2.7
0012 #       wget http://www.steventoth.net/linux/xc5000/HVR-12x0-14x0-17x0_1_25_25271_WHQL.zip
0013 #   2) Extract the files from the zip into the current dir:
0014 #       unzip -j 20080303_V1.0.6.7.zip 20080303_v1.0.6.7/UDXTTM6000.sys
0015 #       unzip -j HVR-12x0-14x0-17x0_1_25_25271_WHQL.zip Driver85/hcw85bda.sys
0016 #   3) run the script:
0017 #       ./extract_xc3028.pl
0018 #   4) copy the generated files:
0019 #       cp xc3028-v24.fw /lib/firmware
0020 #       cp xc3028-v27.fw /lib/firmware
0021 
0022 #use strict;
0023 use IO::Handle;
0024 
0025 my $debug=0;
0026 
0027 sub verify ($$)
0028 {
0029     my ($filename, $hash) = @_;
0030     my ($testhash);
0031 
0032     if (system("which md5sum > /dev/null 2>&1")) {
0033         die "This firmware requires the md5sum command - see http://www.gnu.org/software/coreutils/\n";
0034     }
0035 
0036     open(CMD, "md5sum ".$filename."|");
0037     $testhash = <CMD>;
0038     $testhash =~ /([a-zA-Z0-9]*)/;
0039     $testhash = $1;
0040     close CMD;
0041         die "Hash of extracted file does not match (found $testhash, expected $hash!\n" if ($testhash ne $hash);
0042 }
0043 
0044 sub get_hunk ($$)
0045 {
0046     my ($offset, $length) = @_;
0047     my ($chunklength, $buf, $rcount, $out);
0048 
0049     sysseek(INFILE, $offset, SEEK_SET);
0050     while ($length > 0) {
0051     # Calc chunk size
0052         $chunklength = 2048;
0053         $chunklength = $length if ($chunklength > $length);
0054 
0055         $rcount = sysread(INFILE, $buf, $chunklength);
0056         die "Ran out of data\n" if ($rcount != $chunklength);
0057         $out .= $buf;
0058         $length -= $rcount;
0059     }
0060     return $out;
0061 }
0062 
0063 sub write_le16($)
0064 {
0065     my $val = shift;
0066     my $msb = ($val >> 8) &0xff;
0067     my $lsb = $val & 0xff;
0068 
0069     syswrite(OUTFILE, chr($lsb).chr($msb));
0070 }
0071 
0072 sub write_le32($)
0073 {
0074     my $val = shift;
0075     my $l3 = ($val >> 24) & 0xff;
0076     my $l2 = ($val >> 16) & 0xff;
0077     my $l1 = ($val >> 8)  & 0xff;
0078     my $l0 = $val         & 0xff;
0079 
0080     syswrite(OUTFILE, chr($l0).chr($l1).chr($l2).chr($l3));
0081 }
0082 
0083 sub write_le64($$)
0084 {
0085     my $msb_val = shift;
0086     my $lsb_val = shift;
0087     my $l7 = ($msb_val >> 24) & 0xff;
0088     my $l6 = ($msb_val >> 16) & 0xff;
0089     my $l5 = ($msb_val >> 8)  & 0xff;
0090     my $l4 = $msb_val         & 0xff;
0091 
0092     my $l3 = ($lsb_val >> 24) & 0xff;
0093     my $l2 = ($lsb_val >> 16) & 0xff;
0094     my $l1 = ($lsb_val >> 8)  & 0xff;
0095     my $l0 = $lsb_val         & 0xff;
0096 
0097     syswrite(OUTFILE,
0098          chr($l0).chr($l1).chr($l2).chr($l3).
0099          chr($l4).chr($l5).chr($l6).chr($l7));
0100 }
0101 
0102 sub write_hunk($$)
0103 {
0104     my ($offset, $length) = @_;
0105     my $out = get_hunk($offset, $length);
0106 
0107     printf "(len %d) ",$length if ($debug);
0108 
0109     for (my $i=0;$i<$length;$i++) {
0110         printf "%02x ",ord(substr($out,$i,1)) if ($debug);
0111     }
0112     printf "\n" if ($debug);
0113 
0114     syswrite(OUTFILE, $out);
0115 }
0116 
0117 sub write_hunk_fix_endian($$)
0118 {
0119     my ($offset, $length) = @_;
0120     my $out = get_hunk($offset, $length);
0121 
0122     printf "(len_fix %d) ",$length if ($debug);
0123 
0124     for (my $i=0;$i<$length;$i++) {
0125         printf "%02x ",ord(substr($out,$i,1)) if ($debug);
0126     }
0127     printf "\n" if ($debug);
0128 
0129     my $i=0;
0130     while ($i<$length) {
0131         my $size = ord(substr($out,$i,1))*256+ord(substr($out,$i+1,1));
0132         syswrite(OUTFILE, substr($out,$i+1,1));
0133         syswrite(OUTFILE, substr($out,$i,1));
0134         $i+=2;
0135         if ($size>0 && $size <0x8000) {
0136             for (my $j=0;$j<$size;$j++) {
0137                 syswrite(OUTFILE, substr($out,$j+$i,1));
0138             }
0139             $i+=$size;
0140         }
0141     }
0142 }
0143 
0144 sub main_firmware_24($$$$)
0145 {
0146     my $out;
0147     my $j=0;
0148     my $outfile = shift;
0149     my $name    = shift;
0150     my $version = shift;
0151     my $nr_desc = shift;
0152 
0153     for ($j = length($name); $j <32; $j++) {
0154         $name = $name.chr(0);
0155     }
0156 
0157     open OUTFILE, ">$outfile";
0158     syswrite(OUTFILE, $name);
0159     write_le16($version);
0160     write_le16($nr_desc);
0161 
0162     #
0163     # Firmware 0, type: BASE FW   F8MHZ (0x00000003), id: (0000000000000000), size: 6635
0164     #
0165 
0166     write_le32(0x00000003);         # Type
0167     write_le64(0x00000000, 0x00000000); # ID
0168     write_le32(6635);           # Size
0169     write_hunk_fix_endian(257752, 6635);
0170 
0171     #
0172     # Firmware 1, type: BASE FW   F8MHZ MTS (0x00000007), id: (0000000000000000), size: 6635
0173     #
0174 
0175     write_le32(0x00000007);         # Type
0176     write_le64(0x00000000, 0x00000000); # ID
0177     write_le32(6635);           # Size
0178     write_hunk_fix_endian(264392, 6635);
0179 
0180     #
0181     # Firmware 2, type: BASE FW   FM (0x00000401), id: (0000000000000000), size: 6525
0182     #
0183 
0184     write_le32(0x00000401);         # Type
0185     write_le64(0x00000000, 0x00000000); # ID
0186     write_le32(6525);           # Size
0187     write_hunk_fix_endian(271040, 6525);
0188 
0189     #
0190     # Firmware 3, type: BASE FW   FM INPUT1 (0x00000c01), id: (0000000000000000), size: 6539
0191     #
0192 
0193     write_le32(0x00000c01);         # Type
0194     write_le64(0x00000000, 0x00000000); # ID
0195     write_le32(6539);           # Size
0196     write_hunk_fix_endian(277568, 6539);
0197 
0198     #
0199     # Firmware 4, type: BASE FW   (0x00000001), id: (0000000000000000), size: 6633
0200     #
0201 
0202     write_le32(0x00000001);         # Type
0203     write_le64(0x00000000, 0x00000000); # ID
0204     write_le32(6633);           # Size
0205     write_hunk_fix_endian(284120, 6633);
0206 
0207     #
0208     # Firmware 5, type: BASE FW   MTS (0x00000005), id: (0000000000000000), size: 6617
0209     #
0210 
0211     write_le32(0x00000005);         # Type
0212     write_le64(0x00000000, 0x00000000); # ID
0213     write_le32(6617);           # Size
0214     write_hunk_fix_endian(290760, 6617);
0215 
0216     #
0217     # Firmware 6, type: STD FW    (0x00000000), id: PAL/BG A2/A (0000000100000007), size: 161
0218     #
0219 
0220     write_le32(0x00000000);         # Type
0221     write_le64(0x00000001, 0x00000007); # ID
0222     write_le32(161);            # Size
0223     write_hunk_fix_endian(297384, 161);
0224 
0225     #
0226     # Firmware 7, type: STD FW    MTS (0x00000004), id: PAL/BG A2/A (0000000100000007), size: 169
0227     #
0228 
0229     write_le32(0x00000004);         # Type
0230     write_le64(0x00000001, 0x00000007); # ID
0231     write_le32(169);            # Size
0232     write_hunk_fix_endian(297552, 169);
0233 
0234     #
0235     # Firmware 8, type: STD FW    (0x00000000), id: PAL/BG A2/B (0000000200000007), size: 161
0236     #
0237 
0238     write_le32(0x00000000);         # Type
0239     write_le64(0x00000002, 0x00000007); # ID
0240     write_le32(161);            # Size
0241     write_hunk_fix_endian(297728, 161);
0242 
0243     #
0244     # Firmware 9, type: STD FW    MTS (0x00000004), id: PAL/BG A2/B (0000000200000007), size: 169
0245     #
0246 
0247     write_le32(0x00000004);         # Type
0248     write_le64(0x00000002, 0x00000007); # ID
0249     write_le32(169);            # Size
0250     write_hunk_fix_endian(297896, 169);
0251 
0252     #
0253     # Firmware 10, type: STD FW    (0x00000000), id: PAL/BG NICAM/A (0000000400000007), size: 161
0254     #
0255 
0256     write_le32(0x00000000);         # Type
0257     write_le64(0x00000004, 0x00000007); # ID
0258     write_le32(161);            # Size
0259     write_hunk_fix_endian(298072, 161);
0260 
0261     #
0262     # Firmware 11, type: STD FW    MTS (0x00000004), id: PAL/BG NICAM/A (0000000400000007), size: 169
0263     #
0264 
0265     write_le32(0x00000004);         # Type
0266     write_le64(0x00000004, 0x00000007); # ID
0267     write_le32(169);            # Size
0268     write_hunk_fix_endian(298240, 169);
0269 
0270     #
0271     # Firmware 12, type: STD FW    (0x00000000), id: PAL/BG NICAM/B (0000000800000007), size: 161
0272     #
0273 
0274     write_le32(0x00000000);         # Type
0275     write_le64(0x00000008, 0x00000007); # ID
0276     write_le32(161);            # Size
0277     write_hunk_fix_endian(298416, 161);
0278 
0279     #
0280     # Firmware 13, type: STD FW    MTS (0x00000004), id: PAL/BG NICAM/B (0000000800000007), size: 169
0281     #
0282 
0283     write_le32(0x00000004);         # Type
0284     write_le64(0x00000008, 0x00000007); # ID
0285     write_le32(169);            # Size
0286     write_hunk_fix_endian(298584, 169);
0287 
0288     #
0289     # Firmware 14, type: STD FW    (0x00000000), id: PAL/DK A2 (00000003000000e0), size: 161
0290     #
0291 
0292     write_le32(0x00000000);         # Type
0293     write_le64(0x00000003, 0x000000e0); # ID
0294     write_le32(161);            # Size
0295     write_hunk_fix_endian(298760, 161);
0296 
0297     #
0298     # Firmware 15, type: STD FW    MTS (0x00000004), id: PAL/DK A2 (00000003000000e0), size: 169
0299     #
0300 
0301     write_le32(0x00000004);         # Type
0302     write_le64(0x00000003, 0x000000e0); # ID
0303     write_le32(169);            # Size
0304     write_hunk_fix_endian(298928, 169);
0305 
0306     #
0307     # Firmware 16, type: STD FW    (0x00000000), id: PAL/DK NICAM (0000000c000000e0), size: 161
0308     #
0309 
0310     write_le32(0x00000000);         # Type
0311     write_le64(0x0000000c, 0x000000e0); # ID
0312     write_le32(161);            # Size
0313     write_hunk_fix_endian(299104, 161);
0314 
0315     #
0316     # Firmware 17, type: STD FW    MTS (0x00000004), id: PAL/DK NICAM (0000000c000000e0), size: 169
0317     #
0318 
0319     write_le32(0x00000004);         # Type
0320     write_le64(0x0000000c, 0x000000e0); # ID
0321     write_le32(169);            # Size
0322     write_hunk_fix_endian(299272, 169);
0323 
0324     #
0325     # Firmware 18, type: STD FW    (0x00000000), id: SECAM/K1 (0000000000200000), size: 161
0326     #
0327 
0328     write_le32(0x00000000);         # Type
0329     write_le64(0x00000000, 0x00200000); # ID
0330     write_le32(161);            # Size
0331     write_hunk_fix_endian(299448, 161);
0332 
0333     #
0334     # Firmware 19, type: STD FW    MTS (0x00000004), id: SECAM/K1 (0000000000200000), size: 169
0335     #
0336 
0337     write_le32(0x00000004);         # Type
0338     write_le64(0x00000000, 0x00200000); # ID
0339     write_le32(169);            # Size
0340     write_hunk_fix_endian(299616, 169);
0341 
0342     #
0343     # Firmware 20, type: STD FW    (0x00000000), id: SECAM/K3 (0000000004000000), size: 161
0344     #
0345 
0346     write_le32(0x00000000);         # Type
0347     write_le64(0x00000000, 0x04000000); # ID
0348     write_le32(161);            # Size
0349     write_hunk_fix_endian(299792, 161);
0350 
0351     #
0352     # Firmware 21, type: STD FW    MTS (0x00000004), id: SECAM/K3 (0000000004000000), size: 169
0353     #
0354 
0355     write_le32(0x00000004);         # Type
0356     write_le64(0x00000000, 0x04000000); # ID
0357     write_le32(169);            # Size
0358     write_hunk_fix_endian(299960, 169);
0359 
0360     #
0361     # Firmware 22, type: STD FW    D2633 DTV6 ATSC (0x00010030), id: (0000000000000000), size: 149
0362     #
0363 
0364     write_le32(0x00010030);         # Type
0365     write_le64(0x00000000, 0x00000000); # ID
0366     write_le32(149);            # Size
0367     write_hunk_fix_endian(300136, 149);
0368 
0369     #
0370     # Firmware 23, type: STD FW    D2620 DTV6 QAM (0x00000068), id: (0000000000000000), size: 149
0371     #
0372 
0373     write_le32(0x00000068);         # Type
0374     write_le64(0x00000000, 0x00000000); # ID
0375     write_le32(149);            # Size
0376     write_hunk_fix_endian(300296, 149);
0377 
0378     #
0379     # Firmware 24, type: STD FW    D2633 DTV6 QAM (0x00000070), id: (0000000000000000), size: 149
0380     #
0381 
0382     write_le32(0x00000070);         # Type
0383     write_le64(0x00000000, 0x00000000); # ID
0384     write_le32(149);            # Size
0385     write_hunk_fix_endian(300448, 149);
0386 
0387     #
0388     # Firmware 25, type: STD FW    D2620 DTV7 (0x00000088), id: (0000000000000000), size: 149
0389     #
0390 
0391     write_le32(0x00000088);         # Type
0392     write_le64(0x00000000, 0x00000000); # ID
0393     write_le32(149);            # Size
0394     write_hunk_fix_endian(300608, 149);
0395 
0396     #
0397     # Firmware 26, type: STD FW    D2633 DTV7 (0x00000090), id: (0000000000000000), size: 149
0398     #
0399 
0400     write_le32(0x00000090);         # Type
0401     write_le64(0x00000000, 0x00000000); # ID
0402     write_le32(149);            # Size
0403     write_hunk_fix_endian(300760, 149);
0404 
0405     #
0406     # Firmware 27, type: STD FW    D2620 DTV78 (0x00000108), id: (0000000000000000), size: 149
0407     #
0408 
0409     write_le32(0x00000108);         # Type
0410     write_le64(0x00000000, 0x00000000); # ID
0411     write_le32(149);            # Size
0412     write_hunk_fix_endian(300920, 149);
0413 
0414     #
0415     # Firmware 28, type: STD FW    D2633 DTV78 (0x00000110), id: (0000000000000000), size: 149
0416     #
0417 
0418     write_le32(0x00000110);         # Type
0419     write_le64(0x00000000, 0x00000000); # ID
0420     write_le32(149);            # Size
0421     write_hunk_fix_endian(301072, 149);
0422 
0423     #
0424     # Firmware 29, type: STD FW    D2620 DTV8 (0x00000208), id: (0000000000000000), size: 149
0425     #
0426 
0427     write_le32(0x00000208);         # Type
0428     write_le64(0x00000000, 0x00000000); # ID
0429     write_le32(149);            # Size
0430     write_hunk_fix_endian(301232, 149);
0431 
0432     #
0433     # Firmware 30, type: STD FW    D2633 DTV8 (0x00000210), id: (0000000000000000), size: 149
0434     #
0435 
0436     write_le32(0x00000210);         # Type
0437     write_le64(0x00000000, 0x00000000); # ID
0438     write_le32(149);            # Size
0439     write_hunk_fix_endian(301384, 149);
0440 
0441     #
0442     # Firmware 31, type: STD FW    FM (0x00000400), id: (0000000000000000), size: 135
0443     #
0444 
0445     write_le32(0x00000400);         # Type
0446     write_le64(0x00000000, 0x00000000); # ID
0447     write_le32(135);            # Size
0448     write_hunk_fix_endian(301554, 135);
0449 
0450     #
0451     # Firmware 32, type: STD FW    (0x00000000), id: PAL/I (0000000000000010), size: 161
0452     #
0453 
0454     write_le32(0x00000000);         # Type
0455     write_le64(0x00000000, 0x00000010); # ID
0456     write_le32(161);            # Size
0457     write_hunk_fix_endian(301688, 161);
0458 
0459     #
0460     # Firmware 33, type: STD FW    MTS (0x00000004), id: PAL/I (0000000000000010), size: 169
0461     #
0462 
0463     write_le32(0x00000004);         # Type
0464     write_le64(0x00000000, 0x00000010); # ID
0465     write_le32(169);            # Size
0466     write_hunk_fix_endian(301856, 169);
0467 
0468     #
0469     # Firmware 34, type: STD FW    (0x00000000), id: SECAM/L AM (0000001000400000), size: 169
0470     #
0471 
0472     #
0473     # Firmware 35, type: STD FW    (0x00000000), id: SECAM/L NICAM (0000000c00400000), size: 161
0474     #
0475 
0476     write_le32(0x00000000);         # Type
0477     write_le64(0x0000000c, 0x00400000); # ID
0478     write_le32(161);            # Size
0479     write_hunk_fix_endian(302032, 161);
0480 
0481     #
0482     # Firmware 36, type: STD FW    (0x00000000), id: SECAM/Lc (0000000000800000), size: 161
0483     #
0484 
0485     write_le32(0x00000000);         # Type
0486     write_le64(0x00000000, 0x00800000); # ID
0487     write_le32(161);            # Size
0488     write_hunk_fix_endian(302200, 161);
0489 
0490     #
0491     # Firmware 37, type: STD FW    (0x00000000), id: NTSC/M Kr (0000000000008000), size: 161
0492     #
0493 
0494     write_le32(0x00000000);         # Type
0495     write_le64(0x00000000, 0x00008000); # ID
0496     write_le32(161);            # Size
0497     write_hunk_fix_endian(302368, 161);
0498 
0499     #
0500     # Firmware 38, type: STD FW    LCD (0x00001000), id: NTSC/M Kr (0000000000008000), size: 161
0501     #
0502 
0503     write_le32(0x00001000);         # Type
0504     write_le64(0x00000000, 0x00008000); # ID
0505     write_le32(161);            # Size
0506     write_hunk_fix_endian(302536, 161);
0507 
0508     #
0509     # Firmware 39, type: STD FW    LCD NOGD (0x00003000), id: NTSC/M Kr (0000000000008000), size: 161
0510     #
0511 
0512     write_le32(0x00003000);         # Type
0513     write_le64(0x00000000, 0x00008000); # ID
0514     write_le32(161);            # Size
0515     write_hunk_fix_endian(302704, 161);
0516 
0517     #
0518     # Firmware 40, type: STD FW    MTS (0x00000004), id: NTSC/M Kr (0000000000008000), size: 169
0519     #
0520 
0521     write_le32(0x00000004);         # Type
0522     write_le64(0x00000000, 0x00008000); # ID
0523     write_le32(169);            # Size
0524     write_hunk_fix_endian(302872, 169);
0525 
0526     #
0527     # Firmware 41, type: STD FW    (0x00000000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
0528     #
0529 
0530     write_le32(0x00000000);         # Type
0531     write_le64(0x00000000, 0x0000b700); # ID
0532     write_le32(161);            # Size
0533     write_hunk_fix_endian(303048, 161);
0534 
0535     #
0536     # Firmware 42, type: STD FW    LCD (0x00001000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
0537     #
0538 
0539     write_le32(0x00001000);         # Type
0540     write_le64(0x00000000, 0x0000b700); # ID
0541     write_le32(161);            # Size
0542     write_hunk_fix_endian(303216, 161);
0543 
0544     #
0545     # Firmware 43, type: STD FW    LCD NOGD (0x00003000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
0546     #
0547 
0548     write_le32(0x00003000);         # Type
0549     write_le64(0x00000000, 0x0000b700); # ID
0550     write_le32(161);            # Size
0551     write_hunk_fix_endian(303384, 161);
0552 
0553     #
0554     # Firmware 44, type: STD FW    (0x00000000), id: NTSC/M Jp (0000000000002000), size: 161
0555     #
0556 
0557     write_le32(0x00000000);         # Type
0558     write_le64(0x00000000, 0x00002000); # ID
0559     write_le32(161);            # Size
0560     write_hunk_fix_endian(303552, 161);
0561 
0562     #
0563     # Firmware 45, type: STD FW    MTS (0x00000004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
0564     #
0565 
0566     write_le32(0x00000004);         # Type
0567     write_le64(0x00000000, 0x0000b700); # ID
0568     write_le32(169);            # Size
0569     write_hunk_fix_endian(303720, 169);
0570 
0571     #
0572     # Firmware 46, type: STD FW    MTS LCD (0x00001004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
0573     #
0574 
0575     write_le32(0x00001004);         # Type
0576     write_le64(0x00000000, 0x0000b700); # ID
0577     write_le32(169);            # Size
0578     write_hunk_fix_endian(303896, 169);
0579 
0580     #
0581     # Firmware 47, type: STD FW    MTS LCD NOGD (0x00003004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
0582     #
0583 
0584     write_le32(0x00003004);         # Type
0585     write_le64(0x00000000, 0x0000b700); # ID
0586     write_le32(169);            # Size
0587     write_hunk_fix_endian(304072, 169);
0588 
0589     #
0590     # Firmware 48, type: SCODE FW  HAS IF (0x60000000), IF = 3.28 MHz id: (0000000000000000), size: 192
0591     #
0592 
0593     write_le32(0x60000000);         # Type
0594     write_le64(0x00000000, 0x00000000); # ID
0595     write_le16(3280);           # IF
0596     write_le32(192);            # Size
0597     write_hunk(309048, 192);
0598 
0599     #
0600     # Firmware 49, type: SCODE FW  HAS IF (0x60000000), IF = 3.30 MHz id: (0000000000000000), size: 192
0601     #
0602 
0603 #   write_le32(0x60000000);         # Type
0604 #   write_le64(0x00000000, 0x00000000); # ID
0605 #   write_le16(3300);           # IF
0606 #   write_le32(192);            # Size
0607 #   write_hunk(304440, 192);
0608 
0609     #
0610     # Firmware 50, type: SCODE FW  HAS IF (0x60000000), IF = 3.44 MHz id: (0000000000000000), size: 192
0611     #
0612 
0613     write_le32(0x60000000);         # Type
0614     write_le64(0x00000000, 0x00000000); # ID
0615     write_le16(3440);           # IF
0616     write_le32(192);            # Size
0617     write_hunk(309432, 192);
0618 
0619     #
0620     # Firmware 51, type: SCODE FW  HAS IF (0x60000000), IF = 3.46 MHz id: (0000000000000000), size: 192
0621     #
0622 
0623     write_le32(0x60000000);         # Type
0624     write_le64(0x00000000, 0x00000000); # ID
0625     write_le16(3460);           # IF
0626     write_le32(192);            # Size
0627     write_hunk(309624, 192);
0628 
0629     #
0630     # Firmware 52, type: SCODE FW  DTV6 ATSC OREN36 HAS IF (0x60210020), IF = 3.80 MHz id: (0000000000000000), size: 192
0631     #
0632 
0633     write_le32(0x60210020);         # Type
0634     write_le64(0x00000000, 0x00000000); # ID
0635     write_le16(3800);           # IF
0636     write_le32(192);            # Size
0637     write_hunk(306936, 192);
0638 
0639     #
0640     # Firmware 53, type: SCODE FW  HAS IF (0x60000000), IF = 4.00 MHz id: (0000000000000000), size: 192
0641     #
0642 
0643     write_le32(0x60000000);         # Type
0644     write_le64(0x00000000, 0x00000000); # ID
0645     write_le16(4000);           # IF
0646     write_le32(192);            # Size
0647     write_hunk(309240, 192);
0648 
0649     #
0650     # Firmware 54, type: SCODE FW  DTV6 ATSC TOYOTA388 HAS IF (0x60410020), IF = 4.08 MHz id: (0000000000000000), size: 192
0651     #
0652 
0653     write_le32(0x60410020);         # Type
0654     write_le64(0x00000000, 0x00000000); # ID
0655     write_le16(4080);           # IF
0656     write_le32(192);            # Size
0657     write_hunk(307128, 192);
0658 
0659     #
0660     # Firmware 55, type: SCODE FW  HAS IF (0x60000000), IF = 4.20 MHz id: (0000000000000000), size: 192
0661     #
0662 
0663     write_le32(0x60000000);         # Type
0664     write_le64(0x00000000, 0x00000000); # ID
0665     write_le16(4200);           # IF
0666     write_le32(192);            # Size
0667     write_hunk(308856, 192);
0668 
0669     #
0670     # Firmware 56, type: SCODE FW  MONO HAS IF (0x60008000), IF = 4.32 MHz id: NTSC/M Kr (0000000000008000), size: 192
0671     #
0672 
0673     write_le32(0x60008000);         # Type
0674     write_le64(0x00000000, 0x00008000); # ID
0675     write_le16(4320);           # IF
0676     write_le32(192);            # Size
0677     write_hunk(305208, 192);
0678 
0679     #
0680     # Firmware 57, type: SCODE FW  HAS IF (0x60000000), IF = 4.45 MHz id: (0000000000000000), size: 192
0681     #
0682 
0683     write_le32(0x60000000);         # Type
0684     write_le64(0x00000000, 0x00000000); # ID
0685     write_le16(4450);           # IF
0686     write_le32(192);            # Size
0687     write_hunk(309816, 192);
0688 
0689     #
0690     # 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
0691     #
0692 
0693     write_le32(0x6002b004);         # Type
0694     write_le64(0x00000000, 0x0000b700); # ID
0695     write_le16(4500);           # IF
0696     write_le32(192);            # Size
0697     write_hunk(304824, 192);
0698 
0699     #
0700     # Firmware 59, type: SCODE FW  LCD NOGD IF HAS IF (0x60023000), IF = 4.60 MHz id: NTSC/M Kr (0000000000008000), size: 192
0701     #
0702 
0703     write_le32(0x60023000);         # Type
0704     write_le64(0x00000000, 0x00008000); # ID
0705     write_le16(4600);           # IF
0706     write_le32(192);            # Size
0707     write_hunk(305016, 192);
0708 
0709     #
0710     # Firmware 60, type: SCODE FW  DTV6 QAM DTV7 DTV78 DTV8 ZARLINK456 HAS IF (0x620003e0), IF = 4.76 MHz id: (0000000000000000), size: 192
0711     #
0712 
0713     write_le32(0x620003e0);         # Type
0714     write_le64(0x00000000, 0x00000000); # ID
0715     write_le16(4760);           # IF
0716     write_le32(192);            # Size
0717     write_hunk(304440, 192);
0718 
0719     #
0720     # Firmware 61, type: SCODE FW  HAS IF (0x60000000), IF = 4.94 MHz id: (0000000000000000), size: 192
0721     #
0722 
0723     write_le32(0x60000000);         # Type
0724     write_le64(0x00000000, 0x00000000); # ID
0725     write_le16(4940);           # IF
0726     write_le32(192);            # Size
0727     write_hunk(308664, 192);
0728 
0729     #
0730     # Firmware 62, type: SCODE FW  HAS IF (0x60000000), IF = 5.26 MHz id: (0000000000000000), size: 192
0731     #
0732 
0733     write_le32(0x60000000);         # Type
0734     write_le64(0x00000000, 0x00000000); # ID
0735     write_le16(5260);           # IF
0736     write_le32(192);            # Size
0737     write_hunk(307704, 192);
0738 
0739     #
0740     # Firmware 63, type: SCODE FW  MONO HAS IF (0x60008000), IF = 5.32 MHz id: PAL/BG A2 NICAM (0000000f00000007), size: 192
0741     #
0742 
0743     write_le32(0x60008000);         # Type
0744     write_le64(0x0000000f, 0x00000007); # ID
0745     write_le16(5320);           # IF
0746     write_le32(192);            # Size
0747     write_hunk(307896, 192);
0748 
0749     #
0750     # Firmware 64, type: SCODE FW  DTV7 DTV78 DTV8 DIBCOM52 CHINA HAS IF (0x65000380), IF = 5.40 MHz id: (0000000000000000), size: 192
0751     #
0752 
0753     write_le32(0x65000380);         # Type
0754     write_le64(0x00000000, 0x00000000); # ID
0755     write_le16(5400);           # IF
0756     write_le32(192);            # Size
0757     write_hunk(304248, 192);
0758 
0759     #
0760     # Firmware 65, type: SCODE FW  DTV6 ATSC OREN538 HAS IF (0x60110020), IF = 5.58 MHz id: (0000000000000000), size: 192
0761     #
0762 
0763     write_le32(0x60110020);         # Type
0764     write_le64(0x00000000, 0x00000000); # ID
0765     write_le16(5580);           # IF
0766     write_le32(192);            # Size
0767     write_hunk(306744, 192);
0768 
0769     #
0770     # Firmware 66, type: SCODE FW  HAS IF (0x60000000), IF = 5.64 MHz id: PAL/BG A2 (0000000300000007), size: 192
0771     #
0772 
0773     write_le32(0x60000000);         # Type
0774     write_le64(0x00000003, 0x00000007); # ID
0775     write_le16(5640);           # IF
0776     write_le32(192);            # Size
0777     write_hunk(305592, 192);
0778 
0779     #
0780     # Firmware 67, type: SCODE FW  HAS IF (0x60000000), IF = 5.74 MHz id: PAL/BG NICAM (0000000c00000007), size: 192
0781     #
0782 
0783     write_le32(0x60000000);         # Type
0784     write_le64(0x0000000c, 0x00000007); # ID
0785     write_le16(5740);           # IF
0786     write_le32(192);            # Size
0787     write_hunk(305784, 192);
0788 
0789     #
0790     # Firmware 68, type: SCODE FW  HAS IF (0x60000000), IF = 5.90 MHz id: (0000000000000000), size: 192
0791     #
0792 
0793     write_le32(0x60000000);         # Type
0794     write_le64(0x00000000, 0x00000000); # ID
0795     write_le16(5900);           # IF
0796     write_le32(192);            # Size
0797     write_hunk(307512, 192);
0798 
0799     #
0800     # 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
0801     #
0802 
0803     write_le32(0x60008000);         # Type
0804     write_le64(0x0000000c, 0x04c000f0); # ID
0805     write_le16(6000);           # IF
0806     write_le32(192);            # Size
0807     write_hunk(305576, 192);
0808 
0809     #
0810     # Firmware 70, type: SCODE FW  DTV6 QAM ATSC LG60 F6MHZ HAS IF (0x68050060), IF = 6.20 MHz id: (0000000000000000), size: 192
0811     #
0812 
0813     write_le32(0x68050060);         # Type
0814     write_le64(0x00000000, 0x00000000); # ID
0815     write_le16(6200);           # IF
0816     write_le32(192);            # Size
0817     write_hunk(306552, 192);
0818 
0819     #
0820     # Firmware 71, type: SCODE FW  HAS IF (0x60000000), IF = 6.24 MHz id: PAL/I (0000000000000010), size: 192
0821     #
0822 
0823     write_le32(0x60000000);         # Type
0824     write_le64(0x00000000, 0x00000010); # ID
0825     write_le16(6240);           # IF
0826     write_le32(192);            # Size
0827     write_hunk(305400, 192);
0828 
0829     #
0830     # Firmware 72, type: SCODE FW  MONO HAS IF (0x60008000), IF = 6.32 MHz id: SECAM/K1 (0000000000200000), size: 192
0831     #
0832 
0833     write_le32(0x60008000);         # Type
0834     write_le64(0x00000000, 0x00200000); # ID
0835     write_le16(6320);           # IF
0836     write_le32(192);            # Size
0837     write_hunk(308472, 192);
0838 
0839     #
0840     # Firmware 73, type: SCODE FW  HAS IF (0x60000000), IF = 6.34 MHz id: SECAM/K1 (0000000000200000), size: 192
0841     #
0842 
0843     write_le32(0x60000000);         # Type
0844     write_le64(0x00000000, 0x00200000); # ID
0845     write_le16(6340);           # IF
0846     write_le32(192);            # Size
0847     write_hunk(306360, 192);
0848 
0849     #
0850     # Firmware 74, type: SCODE FW  MONO HAS IF (0x60008000), IF = 6.50 MHz id: PAL/DK SECAM/K3 SECAM/L NICAM (0000000c044000e0), size: 192
0851     #
0852 
0853     write_le32(0x60008000);         # Type
0854     write_le64(0x0000000c, 0x044000e0); # ID
0855     write_le16(6500);           # IF
0856     write_le32(192);            # Size
0857     write_hunk(308280, 192);
0858 
0859     #
0860     # Firmware 75, type: SCODE FW  DTV6 ATSC ATI638 HAS IF (0x60090020), IF = 6.58 MHz id: (0000000000000000), size: 192
0861     #
0862 
0863     write_le32(0x60090020);         # Type
0864     write_le64(0x00000000, 0x00000000); # ID
0865     write_le16(6580);           # IF
0866     write_le32(192);            # Size
0867     write_hunk(304632, 192);
0868 
0869     #
0870     # Firmware 76, type: SCODE FW  HAS IF (0x60000000), IF = 6.60 MHz id: PAL/DK A2 (00000003000000e0), size: 192
0871     #
0872 
0873     write_le32(0x60000000);         # Type
0874     write_le64(0x00000003, 0x000000e0); # ID
0875     write_le16(6600);           # IF
0876     write_le32(192);            # Size
0877     write_hunk(306168, 192);
0878 
0879     #
0880     # Firmware 77, type: SCODE FW  MONO HAS IF (0x60008000), IF = 6.68 MHz id: PAL/DK A2 (00000003000000e0), size: 192
0881     #
0882 
0883     write_le32(0x60008000);         # Type
0884     write_le64(0x00000003, 0x000000e0); # ID
0885     write_le16(6680);           # IF
0886     write_le32(192);            # Size
0887     write_hunk(308088, 192);
0888 
0889     #
0890     # Firmware 78, type: SCODE FW  DTV6 ATSC TOYOTA794 HAS IF (0x60810020), IF = 8.14 MHz id: (0000000000000000), size: 192
0891     #
0892 
0893     write_le32(0x60810020);         # Type
0894     write_le64(0x00000000, 0x00000000); # ID
0895     write_le16(8140);           # IF
0896     write_le32(192);            # Size
0897     write_hunk(307320, 192);
0898 
0899     #
0900     # Firmware 79, type: SCODE FW  HAS IF (0x60000000), IF = 8.20 MHz id: (0000000000000000), size: 192
0901     #
0902 
0903 #   write_le32(0x60000000);         # Type
0904 #   write_le64(0x00000000, 0x00000000); # ID
0905 #   write_le16(8200);           # IF
0906 #   write_le32(192);            # Size
0907 #   write_hunk(308088, 192);
0908 }
0909 
0910 sub main_firmware_27($$$$)
0911 {
0912     my $out;
0913     my $j=0;
0914     my $outfile = shift;
0915     my $name    = shift;
0916     my $version = shift;
0917     my $nr_desc = shift;
0918 
0919     for ($j = length($name); $j <32; $j++) {
0920         $name = $name.chr(0);
0921     }
0922 
0923     open OUTFILE, ">$outfile";
0924     syswrite(OUTFILE, $name);
0925     write_le16($version);
0926     write_le16($nr_desc);
0927 
0928     #
0929     # Firmware 0, type: BASE FW   F8MHZ (0x00000003), id: (0000000000000000), size: 8718
0930     #
0931 
0932     write_le32(0x00000003);         # Type
0933     write_le64(0x00000000, 0x00000000); # ID
0934     write_le32(8718);           # Size
0935     write_hunk_fix_endian(813432, 8718);
0936 
0937     #
0938     # Firmware 1, type: BASE FW   F8MHZ MTS (0x00000007), id: (0000000000000000), size: 8712
0939     #
0940 
0941     write_le32(0x00000007);         # Type
0942     write_le64(0x00000000, 0x00000000); # ID
0943     write_le32(8712);           # Size
0944     write_hunk_fix_endian(822152, 8712);
0945 
0946     #
0947     # Firmware 2, type: BASE FW   FM (0x00000401), id: (0000000000000000), size: 8562
0948     #
0949 
0950     write_le32(0x00000401);         # Type
0951     write_le64(0x00000000, 0x00000000); # ID
0952     write_le32(8562);           # Size
0953     write_hunk_fix_endian(830872, 8562);
0954 
0955     #
0956     # Firmware 3, type: BASE FW   FM INPUT1 (0x00000c01), id: (0000000000000000), size: 8576
0957     #
0958 
0959     write_le32(0x00000c01);         # Type
0960     write_le64(0x00000000, 0x00000000); # ID
0961     write_le32(8576);           # Size
0962     write_hunk_fix_endian(839440, 8576);
0963 
0964     #
0965     # Firmware 4, type: BASE FW   (0x00000001), id: (0000000000000000), size: 8706
0966     #
0967 
0968     write_le32(0x00000001);         # Type
0969     write_le64(0x00000000, 0x00000000); # ID
0970     write_le32(8706);           # Size
0971     write_hunk_fix_endian(848024, 8706);
0972 
0973     #
0974     # Firmware 5, type: BASE FW   MTS (0x00000005), id: (0000000000000000), size: 8682
0975     #
0976 
0977     write_le32(0x00000005);         # Type
0978     write_le64(0x00000000, 0x00000000); # ID
0979     write_le32(8682);           # Size
0980     write_hunk_fix_endian(856736, 8682);
0981 
0982     #
0983     # Firmware 6, type: STD FW    (0x00000000), id: PAL/BG A2/A (0000000100000007), size: 161
0984     #
0985 
0986     write_le32(0x00000000);         # Type
0987     write_le64(0x00000001, 0x00000007); # ID
0988     write_le32(161);            # Size
0989     write_hunk_fix_endian(865424, 161);
0990 
0991     #
0992     # Firmware 7, type: STD FW    MTS (0x00000004), id: PAL/BG A2/A (0000000100000007), size: 169
0993     #
0994 
0995     write_le32(0x00000004);         # Type
0996     write_le64(0x00000001, 0x00000007); # ID
0997     write_le32(169);            # Size
0998     write_hunk_fix_endian(865592, 169);
0999 
1000     #
1001     # Firmware 8, type: STD FW    (0x00000000), id: PAL/BG A2/B (0000000200000007), size: 161
1002     #
1003 
1004     write_le32(0x00000000);         # Type
1005     write_le64(0x00000002, 0x00000007); # ID
1006     write_le32(161);            # Size
1007     write_hunk_fix_endian(865424, 161);
1008 
1009     #
1010     # Firmware 9, type: STD FW    MTS (0x00000004), id: PAL/BG A2/B (0000000200000007), size: 169
1011     #
1012 
1013     write_le32(0x00000004);         # Type
1014     write_le64(0x00000002, 0x00000007); # ID
1015     write_le32(169);            # Size
1016     write_hunk_fix_endian(865592, 169);
1017 
1018     #
1019     # Firmware 10, type: STD FW    (0x00000000), id: PAL/BG NICAM/A (0000000400000007), size: 161
1020     #
1021 
1022     write_le32(0x00000000);         # Type
1023     write_le64(0x00000004, 0x00000007); # ID
1024     write_le32(161);            # Size
1025     write_hunk_fix_endian(866112, 161);
1026 
1027     #
1028     # Firmware 11, type: STD FW    MTS (0x00000004), id: PAL/BG NICAM/A (0000000400000007), size: 169
1029     #
1030 
1031     write_le32(0x00000004);         # Type
1032     write_le64(0x00000004, 0x00000007); # ID
1033     write_le32(169);            # Size
1034     write_hunk_fix_endian(866280, 169);
1035 
1036     #
1037     # Firmware 12, type: STD FW    (0x00000000), id: PAL/BG NICAM/B (0000000800000007), size: 161
1038     #
1039 
1040     write_le32(0x00000000);         # Type
1041     write_le64(0x00000008, 0x00000007); # ID
1042     write_le32(161);            # Size
1043     write_hunk_fix_endian(866112, 161);
1044 
1045     #
1046     # Firmware 13, type: STD FW    MTS (0x00000004), id: PAL/BG NICAM/B (0000000800000007), size: 169
1047     #
1048 
1049     write_le32(0x00000004);         # Type
1050     write_le64(0x00000008, 0x00000007); # ID
1051     write_le32(169);            # Size
1052     write_hunk_fix_endian(866280, 169);
1053 
1054     #
1055     # Firmware 14, type: STD FW    (0x00000000), id: PAL/DK A2 (00000003000000e0), size: 161
1056     #
1057 
1058     write_le32(0x00000000);         # Type
1059     write_le64(0x00000003, 0x000000e0); # ID
1060     write_le32(161);            # Size
1061     write_hunk_fix_endian(866800, 161);
1062 
1063     #
1064     # Firmware 15, type: STD FW    MTS (0x00000004), id: PAL/DK A2 (00000003000000e0), size: 169
1065     #
1066 
1067     write_le32(0x00000004);         # Type
1068     write_le64(0x00000003, 0x000000e0); # ID
1069     write_le32(169);            # Size
1070     write_hunk_fix_endian(866968, 169);
1071 
1072     #
1073     # Firmware 16, type: STD FW    (0x00000000), id: PAL/DK NICAM (0000000c000000e0), size: 161
1074     #
1075 
1076     write_le32(0x00000000);         # Type
1077     write_le64(0x0000000c, 0x000000e0); # ID
1078     write_le32(161);            # Size
1079     write_hunk_fix_endian(867144, 161);
1080 
1081     #
1082     # Firmware 17, type: STD FW    MTS (0x00000004), id: PAL/DK NICAM (0000000c000000e0), size: 169
1083     #
1084 
1085     write_le32(0x00000004);         # Type
1086     write_le64(0x0000000c, 0x000000e0); # ID
1087     write_le32(169);            # Size
1088     write_hunk_fix_endian(867312, 169);
1089 
1090     #
1091     # Firmware 18, type: STD FW    (0x00000000), id: SECAM/K1 (0000000000200000), size: 161
1092     #
1093 
1094     write_le32(0x00000000);         # Type
1095     write_le64(0x00000000, 0x00200000); # ID
1096     write_le32(161);            # Size
1097     write_hunk_fix_endian(867488, 161);
1098 
1099     #
1100     # Firmware 19, type: STD FW    MTS (0x00000004), id: SECAM/K1 (0000000000200000), size: 169
1101     #
1102 
1103     write_le32(0x00000004);         # Type
1104     write_le64(0x00000000, 0x00200000); # ID
1105     write_le32(169);            # Size
1106     write_hunk_fix_endian(867656, 169);
1107 
1108     #
1109     # Firmware 20, type: STD FW    (0x00000000), id: SECAM/K3 (0000000004000000), size: 161
1110     #
1111 
1112     write_le32(0x00000000);         # Type
1113     write_le64(0x00000000, 0x04000000); # ID
1114     write_le32(161);            # Size
1115     write_hunk_fix_endian(867832, 161);
1116 
1117     #
1118     # Firmware 21, type: STD FW    MTS (0x00000004), id: SECAM/K3 (0000000004000000), size: 169
1119     #
1120 
1121     write_le32(0x00000004);         # Type
1122     write_le64(0x00000000, 0x04000000); # ID
1123     write_le32(169);            # Size
1124     write_hunk_fix_endian(868000, 169);
1125 
1126     #
1127     # Firmware 22, type: STD FW    D2633 DTV6 ATSC (0x00010030), id: (0000000000000000), size: 149
1128     #
1129 
1130     write_le32(0x00010030);         # Type
1131     write_le64(0x00000000, 0x00000000); # ID
1132     write_le32(149);            # Size
1133     write_hunk_fix_endian(868176, 149);
1134 
1135     #
1136     # Firmware 23, type: STD FW    D2620 DTV6 QAM (0x00000068), id: (0000000000000000), size: 149
1137     #
1138 
1139     write_le32(0x00000068);         # Type
1140     write_le64(0x00000000, 0x00000000); # ID
1141     write_le32(149);            # Size
1142     write_hunk_fix_endian(868336, 149);
1143 
1144     #
1145     # Firmware 24, type: STD FW    D2633 DTV6 QAM (0x00000070), id: (0000000000000000), size: 149
1146     #
1147 
1148     write_le32(0x00000070);         # Type
1149     write_le64(0x00000000, 0x00000000); # ID
1150     write_le32(149);            # Size
1151     write_hunk_fix_endian(868488, 149);
1152 
1153     #
1154     # Firmware 25, type: STD FW    D2620 DTV7 (0x00000088), id: (0000000000000000), size: 149
1155     #
1156 
1157     write_le32(0x00000088);         # Type
1158     write_le64(0x00000000, 0x00000000); # ID
1159     write_le32(149);            # Size
1160     write_hunk_fix_endian(868648, 149);
1161 
1162     #
1163     # Firmware 26, type: STD FW    D2633 DTV7 (0x00000090), id: (0000000000000000), size: 149
1164     #
1165 
1166     write_le32(0x00000090);         # Type
1167     write_le64(0x00000000, 0x00000000); # ID
1168     write_le32(149);            # Size
1169     write_hunk_fix_endian(868800, 149);
1170 
1171     #
1172     # Firmware 27, type: STD FW    D2620 DTV78 (0x00000108), id: (0000000000000000), size: 149
1173     #
1174 
1175     write_le32(0x00000108);         # Type
1176     write_le64(0x00000000, 0x00000000); # ID
1177     write_le32(149);            # Size
1178     write_hunk_fix_endian(868960, 149);
1179 
1180     #
1181     # Firmware 28, type: STD FW    D2633 DTV78 (0x00000110), id: (0000000000000000), size: 149
1182     #
1183 
1184     write_le32(0x00000110);         # Type
1185     write_le64(0x00000000, 0x00000000); # ID
1186     write_le32(149);            # Size
1187     write_hunk_fix_endian(869112, 149);
1188 
1189     #
1190     # Firmware 29, type: STD FW    D2620 DTV8 (0x00000208), id: (0000000000000000), size: 149
1191     #
1192 
1193     write_le32(0x00000208);         # Type
1194     write_le64(0x00000000, 0x00000000); # ID
1195     write_le32(149);            # Size
1196     write_hunk_fix_endian(868648, 149);
1197 
1198     #
1199     # Firmware 30, type: STD FW    D2633 DTV8 (0x00000210), id: (0000000000000000), size: 149
1200     #
1201 
1202     write_le32(0x00000210);         # Type
1203     write_le64(0x00000000, 0x00000000); # ID
1204     write_le32(149);            # Size
1205     write_hunk_fix_endian(868800, 149);
1206 
1207     #
1208     # Firmware 31, type: STD FW    FM (0x00000400), id: (0000000000000000), size: 135
1209     #
1210 
1211     write_le32(0x00000400);         # Type
1212     write_le64(0x00000000, 0x00000000); # ID
1213     write_le32(135);            # Size
1214     write_hunk_fix_endian(869584, 135);
1215 
1216     #
1217     # Firmware 32, type: STD FW    (0x00000000), id: PAL/I (0000000000000010), size: 161
1218     #
1219 
1220     write_le32(0x00000000);         # Type
1221     write_le64(0x00000000, 0x00000010); # ID
1222     write_le32(161);            # Size
1223     write_hunk_fix_endian(869728, 161);
1224 
1225     #
1226     # Firmware 33, type: STD FW    MTS (0x00000004), id: PAL/I (0000000000000010), size: 169
1227     #
1228 
1229     write_le32(0x00000004);         # Type
1230     write_le64(0x00000000, 0x00000010); # ID
1231     write_le32(169);            # Size
1232     write_hunk_fix_endian(869896, 169);
1233 
1234     #
1235     # Firmware 34, type: STD FW    (0x00000000), id: SECAM/L AM (0000001000400000), size: 169
1236     #
1237 
1238     write_le32(0x00000000);         # Type
1239     write_le64(0x00000010, 0x00400000); # ID
1240     write_le32(169);            # Size
1241     write_hunk_fix_endian(870072, 169);
1242 
1243     #
1244     # Firmware 35, type: STD FW    (0x00000000), id: SECAM/L NICAM (0000000c00400000), size: 161
1245     #
1246 
1247     write_le32(0x00000000);         # Type
1248     write_le64(0x0000000c, 0x00400000); # ID
1249     write_le32(161);            # Size
1250     write_hunk_fix_endian(870248, 161);
1251 
1252     #
1253     # Firmware 36, type: STD FW    (0x00000000), id: SECAM/Lc (0000000000800000), size: 161
1254     #
1255 
1256     write_le32(0x00000000);         # Type
1257     write_le64(0x00000000, 0x00800000); # ID
1258     write_le32(161);            # Size
1259     write_hunk_fix_endian(870416, 161);
1260 
1261     #
1262     # Firmware 37, type: STD FW    (0x00000000), id: NTSC/M Kr (0000000000008000), size: 161
1263     #
1264 
1265     write_le32(0x00000000);         # Type
1266     write_le64(0x00000000, 0x00008000); # ID
1267     write_le32(161);            # Size
1268     write_hunk_fix_endian(870584, 161);
1269 
1270     #
1271     # Firmware 38, type: STD FW    LCD (0x00001000), id: NTSC/M Kr (0000000000008000), size: 161
1272     #
1273 
1274     write_le32(0x00001000);         # Type
1275     write_le64(0x00000000, 0x00008000); # ID
1276     write_le32(161);            # Size
1277     write_hunk_fix_endian(870752, 161);
1278 
1279     #
1280     # Firmware 39, type: STD FW    LCD NOGD (0x00003000), id: NTSC/M Kr (0000000000008000), size: 161
1281     #
1282 
1283     write_le32(0x00003000);         # Type
1284     write_le64(0x00000000, 0x00008000); # ID
1285     write_le32(161);            # Size
1286     write_hunk_fix_endian(870920, 161);
1287 
1288     #
1289     # Firmware 40, type: STD FW    MTS (0x00000004), id: NTSC/M Kr (0000000000008000), size: 169
1290     #
1291 
1292     write_le32(0x00000004);         # Type
1293     write_le64(0x00000000, 0x00008000); # ID
1294     write_le32(169);            # Size
1295     write_hunk_fix_endian(871088, 169);
1296 
1297     #
1298     # Firmware 41, type: STD FW    (0x00000000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
1299     #
1300 
1301     write_le32(0x00000000);         # Type
1302     write_le64(0x00000000, 0x0000b700); # ID
1303     write_le32(161);            # Size
1304     write_hunk_fix_endian(871264, 161);
1305 
1306     #
1307     # Firmware 42, type: STD FW    LCD (0x00001000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
1308     #
1309 
1310     write_le32(0x00001000);         # Type
1311     write_le64(0x00000000, 0x0000b700); # ID
1312     write_le32(161);            # Size
1313     write_hunk_fix_endian(871432, 161);
1314 
1315     #
1316     # Firmware 43, type: STD FW    LCD NOGD (0x00003000), id: NTSC PAL/M PAL/N (000000000000b700), size: 161
1317     #
1318 
1319     write_le32(0x00003000);         # Type
1320     write_le64(0x00000000, 0x0000b700); # ID
1321     write_le32(161);            # Size
1322     write_hunk_fix_endian(871600, 161);
1323 
1324     #
1325     # Firmware 44, type: STD FW    (0x00000000), id: NTSC/M Jp (0000000000002000), size: 161
1326     #
1327 
1328     write_le32(0x00000000);         # Type
1329     write_le64(0x00000000, 0x00002000); # ID
1330     write_le32(161);            # Size
1331     write_hunk_fix_endian(871264, 161);
1332 
1333     #
1334     # Firmware 45, type: STD FW    MTS (0x00000004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
1335     #
1336 
1337     write_le32(0x00000004);         # Type
1338     write_le64(0x00000000, 0x0000b700); # ID
1339     write_le32(169);            # Size
1340     write_hunk_fix_endian(871936, 169);
1341 
1342     #
1343     # Firmware 46, type: STD FW    MTS LCD (0x00001004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
1344     #
1345 
1346     write_le32(0x00001004);         # Type
1347     write_le64(0x00000000, 0x0000b700); # ID
1348     write_le32(169);            # Size
1349     write_hunk_fix_endian(872112, 169);
1350 
1351     #
1352     # Firmware 47, type: STD FW    MTS LCD NOGD (0x00003004), id: NTSC PAL/M PAL/N (000000000000b700), size: 169
1353     #
1354 
1355     write_le32(0x00003004);         # Type
1356     write_le64(0x00000000, 0x0000b700); # ID
1357     write_le32(169);            # Size
1358     write_hunk_fix_endian(872288, 169);
1359 
1360     #
1361     # Firmware 48, type: SCODE FW  HAS IF (0x60000000), IF = 3.28 MHz id: (0000000000000000), size: 192
1362     #
1363 
1364     write_le32(0x60000000);         # Type
1365     write_le64(0x00000000, 0x00000000); # ID
1366     write_le16(3280);           # IF
1367     write_le32(192);            # Size
1368     write_hunk(811896, 192);
1369 
1370     #
1371     # Firmware 49, type: SCODE FW  HAS IF (0x60000000), IF = 3.30 MHz id: (0000000000000000), size: 192
1372     #
1373 
1374     write_le32(0x60000000);         # Type
1375     write_le64(0x00000000, 0x00000000); # ID
1376     write_le16(3300);           # IF
1377     write_le32(192);            # Size
1378     write_hunk(813048, 192);
1379 
1380     #
1381     # Firmware 50, type: SCODE FW  HAS IF (0x60000000), IF = 3.44 MHz id: (0000000000000000), size: 192
1382     #
1383 
1384     write_le32(0x60000000);         # Type
1385     write_le64(0x00000000, 0x00000000); # ID
1386     write_le16(3440);           # IF
1387     write_le32(192);            # Size
1388     write_hunk(812280, 192);
1389 
1390     #
1391     # Firmware 51, type: SCODE FW  HAS IF (0x60000000), IF = 3.46 MHz id: (0000000000000000), size: 192
1392     #
1393 
1394     write_le32(0x60000000);         # Type
1395     write_le64(0x00000000, 0x00000000); # ID
1396     write_le16(3460);           # IF
1397     write_le32(192);            # Size
1398     write_hunk(812472, 192);
1399 
1400     #
1401     # Firmware 52, type: SCODE FW  DTV6 ATSC OREN36 HAS IF (0x60210020), IF = 3.80 MHz id: (0000000000000000), size: 192
1402     #
1403 
1404     write_le32(0x60210020);         # Type
1405     write_le64(0x00000000, 0x00000000); # ID
1406     write_le16(3800);           # IF
1407     write_le32(192);            # Size
1408     write_hunk(809784, 192);
1409 
1410     #
1411     # Firmware 53, type: SCODE FW  HAS IF (0x60000000), IF = 4.00 MHz id: (0000000000000000), size: 192
1412     #
1413 
1414     write_le32(0x60000000);         # Type
1415     write_le64(0x00000000, 0x00000000); # ID
1416     write_le16(4000);           # IF
1417     write_le32(192);            # Size
1418     write_hunk(812088, 192);
1419 
1420     #
1421     # Firmware 54, type: SCODE FW  DTV6 ATSC TOYOTA388 HAS IF (0x60410020), IF = 4.08 MHz id: (0000000000000000), size: 192
1422     #
1423 
1424     write_le32(0x60410020);         # Type
1425     write_le64(0x00000000, 0x00000000); # ID
1426     write_le16(4080);           # IF
1427     write_le32(192);            # Size
1428     write_hunk(809976, 192);
1429 
1430     #
1431     # Firmware 55, type: SCODE FW  HAS IF (0x60000000), IF = 4.20 MHz id: (0000000000000000), size: 192
1432     #
1433 
1434     write_le32(0x60000000);         # Type
1435     write_le64(0x00000000, 0x00000000); # ID
1436     write_le16(4200);           # IF
1437     write_le32(192);            # Size
1438     write_hunk(811704, 192);
1439 
1440     #
1441     # Firmware 56, type: SCODE FW  MONO HAS IF (0x60008000), IF = 4.32 MHz id: NTSC/M Kr (0000000000008000), size: 192
1442     #
1443 
1444     write_le32(0x60008000);         # Type
1445     write_le64(0x00000000, 0x00008000); # ID
1446     write_le16(4320);           # IF
1447     write_le32(192);            # Size
1448     write_hunk(808056, 192);
1449 
1450     #
1451     # Firmware 57, type: SCODE FW  HAS IF (0x60000000), IF = 4.45 MHz id: (0000000000000000), size: 192
1452     #
1453 
1454     write_le32(0x60000000);         # Type
1455     write_le64(0x00000000, 0x00000000); # ID
1456     write_le16(4450);           # IF
1457     write_le32(192);            # Size
1458     write_hunk(812664, 192);
1459 
1460     #
1461     # 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
1462     #
1463 
1464     write_le32(0x6002b004);         # Type
1465     write_le64(0x00000000, 0x0000b700); # ID
1466     write_le16(4500);           # IF
1467     write_le32(192);            # Size
1468     write_hunk(807672, 192);
1469 
1470     #
1471     # Firmware 59, type: SCODE FW  LCD NOGD IF HAS IF (0x60023000), IF = 4.60 MHz id: NTSC/M Kr (0000000000008000), size: 192
1472     #
1473 
1474     write_le32(0x60023000);         # Type
1475     write_le64(0x00000000, 0x00008000); # ID
1476     write_le16(4600);           # IF
1477     write_le32(192);            # Size
1478     write_hunk(807864, 192);
1479 
1480     #
1481     # Firmware 60, type: SCODE FW  DTV6 QAM DTV7 DTV78 DTV8 ZARLINK456 HAS IF (0x620003e0), IF = 4.76 MHz id: (0000000000000000), size: 192
1482     #
1483 
1484     write_le32(0x620003e0);         # Type
1485     write_le64(0x00000000, 0x00000000); # ID
1486     write_le16(4760);           # IF
1487     write_le32(192);            # Size
1488     write_hunk(807288, 192);
1489 
1490     #
1491     # Firmware 61, type: SCODE FW  HAS IF (0x60000000), IF = 4.94 MHz id: (0000000000000000), size: 192
1492     #
1493 
1494     write_le32(0x60000000);         # Type
1495     write_le64(0x00000000, 0x00000000); # ID
1496     write_le16(4940);           # IF
1497     write_le32(192);            # Size
1498     write_hunk(811512, 192);
1499 
1500     #
1501     # Firmware 62, type: SCODE FW  HAS IF (0x60000000), IF = 5.26 MHz id: (0000000000000000), size: 192
1502     #
1503 
1504     write_le32(0x60000000);         # Type
1505     write_le64(0x00000000, 0x00000000); # ID
1506     write_le16(5260);           # IF
1507     write_le32(192);            # Size
1508     write_hunk(810552, 192);
1509 
1510     #
1511     # Firmware 63, type: SCODE FW  MONO HAS IF (0x60008000), IF = 5.32 MHz id: PAL/BG A2 NICAM (0000000f00000007), size: 192
1512     #
1513 
1514     write_le32(0x60008000);         # Type
1515     write_le64(0x0000000f, 0x00000007); # ID
1516     write_le16(5320);           # IF
1517     write_le32(192);            # Size
1518     write_hunk(810744, 192);
1519 
1520     #
1521     # Firmware 64, type: SCODE FW  DTV7 DTV78 DTV8 DIBCOM52 CHINA HAS IF (0x65000380), IF = 5.40 MHz id: (0000000000000000), size: 192
1522     #
1523 
1524     write_le32(0x65000380);         # Type
1525     write_le64(0x00000000, 0x00000000); # ID
1526     write_le16(5400);           # IF
1527     write_le32(192);            # Size
1528     write_hunk(807096, 192);
1529 
1530     #
1531     # Firmware 65, type: SCODE FW  DTV6 ATSC OREN538 HAS IF (0x60110020), IF = 5.58 MHz id: (0000000000000000), size: 192
1532     #
1533 
1534     write_le32(0x60110020);         # Type
1535     write_le64(0x00000000, 0x00000000); # ID
1536     write_le16(5580);           # IF
1537     write_le32(192);            # Size
1538     write_hunk(809592, 192);
1539 
1540     #
1541     # Firmware 66, type: SCODE FW  HAS IF (0x60000000), IF = 5.64 MHz id: PAL/BG A2 (0000000300000007), size: 192
1542     #
1543 
1544     write_le32(0x60000000);         # Type
1545     write_le64(0x00000003, 0x00000007); # ID
1546     write_le16(5640);           # IF
1547     write_le32(192);            # Size
1548     write_hunk(808440, 192);
1549 
1550     #
1551     # Firmware 67, type: SCODE FW  HAS IF (0x60000000), IF = 5.74 MHz id: PAL/BG NICAM (0000000c00000007), size: 192
1552     #
1553 
1554     write_le32(0x60000000);         # Type
1555     write_le64(0x0000000c, 0x00000007); # ID
1556     write_le16(5740);           # IF
1557     write_le32(192);            # Size
1558     write_hunk(808632, 192);
1559 
1560     #
1561     # Firmware 68, type: SCODE FW  HAS IF (0x60000000), IF = 5.90 MHz id: (0000000000000000), size: 192
1562     #
1563 
1564     write_le32(0x60000000);         # Type
1565     write_le64(0x00000000, 0x00000000); # ID
1566     write_le16(5900);           # IF
1567     write_le32(192);            # Size
1568     write_hunk(810360, 192);
1569 
1570     #
1571     # 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
1572     #
1573 
1574     write_le32(0x60008000);         # Type
1575     write_le64(0x0000000c, 0x04c000f0); # ID
1576     write_le16(6000);           # IF
1577     write_le32(192);            # Size
1578     write_hunk(808824, 192);
1579 
1580     #
1581     # Firmware 70, type: SCODE FW  DTV6 QAM ATSC LG60 F6MHZ HAS IF (0x68050060), IF = 6.20 MHz id: (0000000000000000), size: 192
1582     #
1583 
1584     write_le32(0x68050060);         # Type
1585     write_le64(0x00000000, 0x00000000); # ID
1586     write_le16(6200);           # IF
1587     write_le32(192);            # Size
1588     write_hunk(809400, 192);
1589 
1590     #
1591     # Firmware 71, type: SCODE FW  HAS IF (0x60000000), IF = 6.24 MHz id: PAL/I (0000000000000010), size: 192
1592     #
1593 
1594     write_le32(0x60000000);         # Type
1595     write_le64(0x00000000, 0x00000010); # ID
1596     write_le16(6240);           # IF
1597     write_le32(192);            # Size
1598     write_hunk(808248, 192);
1599 
1600     #
1601     # Firmware 72, type: SCODE FW  MONO HAS IF (0x60008000), IF = 6.32 MHz id: SECAM/K1 (0000000000200000), size: 192
1602     #
1603 
1604     write_le32(0x60008000);         # Type
1605     write_le64(0x00000000, 0x00200000); # ID
1606     write_le16(6320);           # IF
1607     write_le32(192);            # Size
1608     write_hunk(811320, 192);
1609 
1610     #
1611     # Firmware 73, type: SCODE FW  HAS IF (0x60000000), IF = 6.34 MHz id: SECAM/K1 (0000000000200000), size: 192
1612     #
1613 
1614     write_le32(0x60000000);         # Type
1615     write_le64(0x00000000, 0x00200000); # ID
1616     write_le16(6340);           # IF
1617     write_le32(192);            # Size
1618     write_hunk(809208, 192);
1619 
1620     #
1621     # Firmware 74, type: SCODE FW  MONO HAS IF (0x60008000), IF = 6.50 MHz id: PAL/DK SECAM/K3 SECAM/L NICAM (0000000c044000e0), size: 192
1622     #
1623 
1624     write_le32(0x60008000);         # Type
1625     write_le64(0x0000000c, 0x044000e0); # ID
1626     write_le16(6500);           # IF
1627     write_le32(192);            # Size
1628     write_hunk(811128, 192);
1629 
1630     #
1631     # Firmware 75, type: SCODE FW  DTV6 ATSC ATI638 HAS IF (0x60090020), IF = 6.58 MHz id: (0000000000000000), size: 192
1632     #
1633 
1634     write_le32(0x60090020);         # Type
1635     write_le64(0x00000000, 0x00000000); # ID
1636     write_le16(6580);           # IF
1637     write_le32(192);            # Size
1638     write_hunk(807480, 192);
1639 
1640     #
1641     # Firmware 76, type: SCODE FW  HAS IF (0x60000000), IF = 6.60 MHz id: PAL/DK A2 (00000003000000e0), size: 192
1642     #
1643 
1644     write_le32(0x60000000);         # Type
1645     write_le64(0x00000003, 0x000000e0); # ID
1646     write_le16(6600);           # IF
1647     write_le32(192);            # Size
1648     write_hunk(809016, 192);
1649 
1650     #
1651     # Firmware 77, type: SCODE FW  MONO HAS IF (0x60008000), IF = 6.68 MHz id: PAL/DK A2 (00000003000000e0), size: 192
1652     #
1653 
1654     write_le32(0x60008000);         # Type
1655     write_le64(0x00000003, 0x000000e0); # ID
1656     write_le16(6680);           # IF
1657     write_le32(192);            # Size
1658     write_hunk(810936, 192);
1659 
1660     #
1661     # Firmware 78, type: SCODE FW  DTV6 ATSC TOYOTA794 HAS IF (0x60810020), IF = 8.14 MHz id: (0000000000000000), size: 192
1662     #
1663 
1664     write_le32(0x60810020);         # Type
1665     write_le64(0x00000000, 0x00000000); # ID
1666     write_le16(8140);           # IF
1667     write_le32(192);            # Size
1668     write_hunk(810168, 192);
1669 
1670     #
1671     # Firmware 79, type: SCODE FW  HAS IF (0x60000000), IF = 8.20 MHz id: (0000000000000000), size: 192
1672     #
1673 
1674     write_le32(0x60000000);         # Type
1675     write_le64(0x00000000, 0x00000000); # ID
1676     write_le16(8200);           # IF
1677     write_le32(192);            # Size
1678     write_hunk(812856, 192);
1679 }
1680 
1681 
1682 sub extract_firmware {
1683     my $sourcefile_24 = "UDXTTM6000.sys";
1684     my $hash_24 = "cb9deb5508a5e150af2880f5b0066d78";
1685     my $outfile_24 = "xc3028-v24.fw";
1686     my $name_24 = "xc2028 firmware";
1687     my $version_24 = 516;
1688     my $nr_desc_24 = 77;
1689     my $out;
1690 
1691     my $sourcefile_27 = "hcw85bda.sys";
1692     my $hash_27 = "0e44dbf63bb0169d57446aec21881ff2";
1693     my $outfile_27 = "xc3028-v27.fw";
1694     my $name_27 = "xc2028 firmware";
1695     my $version_27 = 519;
1696     my $nr_desc_27 = 80;
1697     my $out;
1698 
1699     if (-e $sourcefile_24) {
1700         verify($sourcefile_24, $hash_24);
1701 
1702         open INFILE, "<$sourcefile_24";
1703         main_firmware_24($outfile_24, $name_24, $version_24, $nr_desc_24);
1704         close INFILE;
1705     }
1706 
1707     if (-e $sourcefile_27) {
1708         verify($sourcefile_27, $hash_27);
1709 
1710         open INFILE, "<$sourcefile_27";
1711         main_firmware_27($outfile_27, $name_27, $version_27, $nr_desc_27);
1712         close INFILE;
1713     }
1714 }
1715 
1716 extract_firmware;
1717 printf "Firmwares generated.\n";