[linux-dvb] pctv452e driver first try

Roland Mieslinger rmie at gmx.de
Sat Sep 23 20:12:22 CEST 2006


> Hi,
> 
> Here is the first version of my pctv452e driver,
> which does not more than setting FE Power and DiSEqC :-(
> Still under construction....
>
> The attached patch is an update to 
> mp-stb0899 tree snapshot version 2dcc2689f994
Thanks for that.

> Question about the dvb-usb framework:
> where may I put a one-time initialization which has to be done before any 
> other stuff? I didnt find some kind of init() function in dvb_usb_properties
I used the "load firmware" interface for that (don't know if it is intended for stuff
like that).

The following sample works, but didn't free all allocated memory in case
of a failure:

#define INIT_PCTV452E  0x01

static int pctv452e_load_firmware(struct usb_device *d, const struct
firmware *fw) {

  u8 *ptr, *buf;
  int bufferpos, actlen, ret;

  deb_info("starting download (fw->size=%d).\n", fw->size);

  ptr = fw->data;
  buf = kmalloc(512, GFP_KERNEL | GFP_DMA);
  bufferpos=0;

  while(bufferpos<fw->size) {
    u8 buflen=ptr[0];
    memcpy(buf, ++ptr, buflen);
    if( (ret=usb_bulk_msg(d, usb_sndbulkpipe(d, INIT_PCTV452E), buf,
buflen, &actlen, 5000)) ) {
      err("bulk message failed: %d (%d/%d)",ret,buflen,actlen);
      return ret;
    }
    ptr += buflen;
    bufferpos += buflen+1;
  }

  kfree(buf);
  deb_info("finished download (%d, %d)\n", fw->size, bufferpos);
  return 0;
}

static struct dvb_usb_properties pctv452e_properties = {
....
  .usb_ctrl = DEVICE_SPECIFIC,
  .download_firmware = pctv452e_load_firmware,
  .firmware = "dvb-usb-pctv452e.fw",
....
}

You can find the "firmware" attached. It's basically what I have snooped
when windows is initializing the device. So the name is maybe
misleading.  

The file format is very simple. You can think as blocks of bulk messages
with block length in bytes as the first byte of each block.

Roland
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dvb-usb-pctv452e.fw
Type: application/octet-stream
Size: 11318 bytes
Desc: not available
Url : http://www.linuxtv.org/pipermail/linux-dvb/attachments/20060923/30ae5077/dvb-usb-pctv452e-0001.obj


More information about the linux-dvb mailing list