Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Marco Gittler and committed by
Mauro Carvalho Chehab
59800555 b31c33bd

+97 -8
+60 -1
Documentation/dvb/get_dvb_firmware
··· 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); ··· 210 209 copy("$tmpdir/software/OEM/STB/App/Boot/STB_PC_S.bin", $outfile); 211 210 212 211 $outfile; 212 + } 213 + sub opera1{ 214 + my $tmpdir = tempdir(DIR => "/tmp", CLEANUP => 0); 215 + 216 + checkstandard(); 217 + my $fwfile1="dvb-usb-opera1-fpga-01.fw"; 218 + my $fwfile2="dvb-usb-opera-01.fw"; 219 + extract("2830SCap2.sys", 0x62e8, 55024, "$tmpdir/opera1-fpga.fw"); 220 + extract("2830SLoad2.sys",0x3178,0x3685-0x3178,"$tmpdir/fw1part1"); 221 + extract("2830SLoad2.sys",0x0980,0x3150-0x0980,"$tmpdir/fw1part2"); 222 + delzero("$tmpdir/fw1part1","$tmpdir/fw1part1-1"); 223 + delzero("$tmpdir/fw1part2","$tmpdir/fw1part2-1"); 224 + verify("$tmpdir/fw1part1-1","5e0909858fdf0b5b09ad48b9fe622e70"); 225 + verify("$tmpdir/fw1part2-1","d6e146f321427e931df2c6fcadac37a1"); 226 + verify("$tmpdir/opera1-fpga.fw","0f8133f5e9051f5f3c1928f7e5a1b07d"); 227 + 228 + my $RES1="\x01\x92\x7f\x00\x01\x00"; 229 + my $RES0="\x01\x92\x7f\x00\x00\x00"; 230 + my $DAT1="\x01\x00\xe6\x00\x01\x00"; 231 + my $DAT0="\x01\x00\xe6\x00\x00\x00"; 232 + open FW,">$tmpdir/opera.fw"; 233 + print FW "$RES1"; 234 + print FW "$DAT1"; 235 + print FW "$RES1"; 236 + print FW "$DAT1"; 237 + appendfile(FW,"$tmpdir/fw1part1-1"); 238 + print FW "$RES0"; 239 + print FW "$DAT0"; 240 + print FW "$RES1"; 241 + print FW "$DAT1"; 242 + appendfile(FW,"$tmpdir/fw1part2-1"); 243 + print FW "$RES1"; 244 + print FW "$DAT1"; 245 + print FW "$RES0"; 246 + print FW "$DAT0"; 247 + copy ("$tmpdir/opera1-fpga.fw",$fwfile1); 248 + copy ("$tmpdir/opera.fw",$fwfile2); 249 + 250 + $fwfile1.",".$fwfile2; 213 251 } 214 252 215 253 sub vp7041 { ··· 478 438 print $FH $buf; 479 439 } 480 440 close(INFILE); 441 + } 442 + 443 + sub delzero{ 444 + my ($infile,$outfile) =@_; 445 + 446 + open INFILE,"<$infile"; 447 + open OUTFILE,">$outfile"; 448 + while (1){ 449 + $rcount=sysread(INFILE,$buf,22); 450 + $len=ord(substr($buf,0,1)); 451 + print OUTFILE substr($buf,0,1); 452 + print OUTFILE substr($buf,2,$len+3); 453 + last if ($rcount<1); 454 + printf OUTFILE "%c",0; 455 + #print $len." ".length($buf)."\n"; 456 + 457 + } 458 + close(INFILE); 459 + close(OUTFILE); 481 460 } 482 461 483 462 sub syntax() {
+27
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>
+10 -7
drivers/media/dvb/dvb-usb/opera1.c
··· 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) " ··· 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 ··· 541 538 542 539 if (udev->descriptor.idProduct == USB_PID_OPERA1_WARM && 543 540 udev->descriptor.idVendor == USB_VID_OPERA1 && 544 - opera1_xilinx_load_firmware(udev, "dvb-usb-opera1-fpga.fw") != 0 541 + opera1_xilinx_load_firmware(udev, "dvb-usb-opera1-fpga-01.fw") != 0 545 542 ) { 546 543 return -EINVAL; 547 544 }