Commit 59800555f79a52394c3c29e19e448b4635daf14c

Authored by Marco Gittler
Committed by Mauro Carvalho Chehab
1 parent b31c33bd8b

V4L/DVB (5829): Firmware extract and loading for opera dvb-usb update

Better way of creating and loading the firmware used.
Update for get_dvb_firmware script to extract the files for opera usb-box
Help file for creating the firmware added

Signed-off-by: Marco Gittler <g.marco@freenet.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

Showing 3 changed files with 97 additions and 8 deletions Side-by-side Diff

Documentation/dvb/get_dvb_firmware
... ... @@ -24,7 +24,8 @@
24 24 @components = ( "sp8870", "sp887x", "tda10045", "tda10046",
25 25 "tda10046lifeview", "av7110", "dec2000t", "dec2540t",
26 26 "dec3000s", "vp7041", "dibusb", "nxt2002", "nxt2004",
27   - "or51211", "or51132_qam", "or51132_vsb", "bluebird");
  27 + "or51211", "or51132_qam", "or51132_vsb", "bluebird",
  28 + "opera1");
28 29  
29 30 # Check args
30 31 syntax() if (scalar(@ARGV) != 1);
31 32  
... ... @@ -210,7 +211,46 @@
210 211  
211 212 $outfile;
212 213 }
  214 +sub opera1{
  215 + my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0);
213 216  
  217 + checkstandard();
  218 + my $fwfile1="dvb-usb-opera1-fpga-01.fw";
  219 + my $fwfile2="dvb-usb-opera-01.fw";
  220 + extract("2830SCap2.sys", 0x62e8, 55024, "$tmpdir/opera1-fpga.fw");
  221 + extract("2830SLoad2.sys",0x3178,0x3685-0x3178,"$tmpdir/fw1part1");
  222 + extract("2830SLoad2.sys",0x0980,0x3150-0x0980,"$tmpdir/fw1part2");
  223 + delzero("$tmpdir/fw1part1","$tmpdir/fw1part1-1");
  224 + delzero("$tmpdir/fw1part2","$tmpdir/fw1part2-1");
  225 + verify("$tmpdir/fw1part1-1","5e0909858fdf0b5b09ad48b9fe622e70");
  226 + verify("$tmpdir/fw1part2-1","d6e146f321427e931df2c6fcadac37a1");
  227 + verify("$tmpdir/opera1-fpga.fw","0f8133f5e9051f5f3c1928f7e5a1b07d");
  228 +
  229 + my $RES1="\x01\x92\x7f\x00\x01\x00";
  230 + my $RES0="\x01\x92\x7f\x00\x00\x00";
  231 + my $DAT1="\x01\x00\xe6\x00\x01\x00";
  232 + my $DAT0="\x01\x00\xe6\x00\x00\x00";
  233 + open FW,">$tmpdir/opera.fw";
  234 + print FW "$RES1";
  235 + print FW "$DAT1";
  236 + print FW "$RES1";
  237 + print FW "$DAT1";
  238 + appendfile(FW,"$tmpdir/fw1part1-1");
  239 + print FW "$RES0";
  240 + print FW "$DAT0";
  241 + print FW "$RES1";
  242 + print FW "$DAT1";
  243 + appendfile(FW,"$tmpdir/fw1part2-1");
  244 + print FW "$RES1";
  245 + print FW "$DAT1";
  246 + print FW "$RES0";
  247 + print FW "$DAT0";
  248 + copy ("$tmpdir/opera1-fpga.fw",$fwfile1);
  249 + copy ("$tmpdir/opera.fw",$fwfile2);
  250 +
  251 + $fwfile1.",".$fwfile2;
  252 +}
  253 +
214 254 sub vp7041 {
215 255 my $sourcefile = "2.422.zip";
216 256 my $url = "http://www.twinhan.com/files/driver/USB-Ter/$sourcefile";
... ... @@ -438,6 +478,25 @@
438 478 print $FH $buf;
439 479 }
440 480 close(INFILE);
  481 +}
  482 +
  483 +sub delzero{
  484 + my ($infile,$outfile) =@_;
  485 +
  486 + open INFILE,"<$infile";
  487 + open OUTFILE,">$outfile";
  488 + while (1){
  489 + $rcount=sysread(INFILE,$buf,22);
  490 + $len=ord(substr($buf,0,1));
  491 + print OUTFILE substr($buf,0,1);
  492 + print OUTFILE substr($buf,2,$len+3);
  493 + last if ($rcount<1);
  494 + printf OUTFILE "%c",0;
  495 +#print $len." ".length($buf)."\n";
  496 +
  497 + }
  498 + close(INFILE);
  499 + close(OUTFILE);
441 500 }
442 501  
443 502 sub syntax() {
Documentation/dvb/opera-firmware.txt
  1 +To extract the firmware for the Opera DVB-S1 USB-Box
  2 +you need to copy the files:
  3 +
  4 +2830SCap2.sys
  5 +2830SLoad2.sys
  6 +
  7 +from the windriver disk into this directory.
  8 +
  9 +Then run
  10 +
  11 +./get_dvb_firware opera1
  12 +
  13 +and after that you have 2 files:
  14 +
  15 +dvb-usb-opera-01.fw
  16 +dvb-usb-opera1-fpga-01.fw
  17 +
  18 +in here.
  19 +
  20 +Copy them into /lib/firmware/ .
  21 +
  22 +After that the driver can load the firmware
  23 +(if you have enabled firmware loading
  24 +in kernel config and have hotplug running).
  25 +
  26 +
  27 +Marco Gittler <g.marco@freenet.de>
drivers/media/dvb/dvb-usb/opera1.c
... ... @@ -435,9 +435,9 @@
435 435 {
436 436 const struct firmware *fw = NULL;
437 437 u8 *b, *p;
438   - int ret = 0, i;
  438 + int ret = 0, i,fpgasize=40;
439 439 u8 testval;
440   - info("start downloading fpga firmware");
  440 + info("start downloading fpga firmware %s",filename);
441 441  
442 442 if ((ret = request_firmware(&fw, filename, &dev->dev)) != 0) {
443 443 err("did not find the firmware file. (%s) "
444 444  
445 445  
... ... @@ -454,17 +454,20 @@
454 454 /* clear fpga ? */
455 455 opera1_xilinx_rw(dev, 0xbc, 0xaa, &fpga_command, 1,
456 456 OPERA_WRITE_MSG);
457   - for (i = 0; p[i] != 0 && i < fw->size;) {
  457 + for (i = 0; i < fw->size;) {
  458 + if ( (fw->size - i) <fpgasize){
  459 + fpgasize=fw->size-i;
  460 + }
458 461 b = (u8 *) p + i;
459 462 if (opera1_xilinx_rw
460   - (dev, OPERA_WRITE_FX2, 0x0, b + 1, b[0],
461   - OPERA_WRITE_MSG) != b[0]
  463 + (dev, OPERA_WRITE_FX2, 0x0, b , fpgasize,
  464 + OPERA_WRITE_MSG) != fpgasize
462 465 ) {
463 466 err("error while transferring firmware");
464 467 ret = -EINVAL;
465 468 break;
466 469 }
467   - i = i + 1 + b[0];
  470 + i = i + fpgasize;
468 471 }
469 472 /* restart the CPU */
470 473 if (ret || opera1_xilinx_rw
... ... @@ -538,7 +541,7 @@
538 541  
539 542 if (udev->descriptor.idProduct == USB_PID_OPERA1_WARM &&
540 543 udev->descriptor.idVendor == USB_VID_OPERA1 &&
541   - opera1_xilinx_load_firmware(udev, "dvb-usb-opera1-fpga.fw") != 0
  544 + opera1_xilinx_load_firmware(udev, "dvb-usb-opera1-fpga-01.fw") != 0
542 545 ) {
543 546 return -EINVAL;
544 547 }