diff options
author | Patrick Boettcher <devnull@localhost> | 2005-01-07 11:49:57 +0000 |
---|---|---|
committer | Patrick Boettcher <devnull@localhost> | 2005-01-07 11:49:57 +0000 |
commit | 9e82b4398f27a1204dd4d936bc80cd5aeff7c909 (patch) | |
tree | 0162be8d0184bf98ca527785846e3885f49d2218 /linux/drivers/media/dvb/dibusb | |
parent | 56d193de59c49154de25605be5d16575d31db04e (diff) | |
download | mediapointer-dvb-s2-9e82b4398f27a1204dd4d936bc80cd5aeff7c909.tar.gz mediapointer-dvb-s2-9e82b4398f27a1204dd4d936bc80cd5aeff7c909.tar.bz2 |
dibusb internal refactoring step 2/3
Diffstat (limited to 'linux/drivers/media/dvb/dibusb')
-rw-r--r-- | linux/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c | 16 | ||||
-rw-r--r-- | linux/drivers/media/dvb/dibusb/dvb-dibusb-firmware.c | 28 | ||||
-rw-r--r-- | linux/drivers/media/dvb/dibusb/dvb-dibusb-usb.c | 30 | ||||
-rw-r--r-- | linux/drivers/media/dvb/dibusb/dvb-dibusb.h | 138 |
4 files changed, 122 insertions, 90 deletions
diff --git a/linux/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c b/linux/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c index 97747cc4e..2683f4559 100644 --- a/linux/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c +++ b/linux/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c @@ -65,16 +65,14 @@ static int dibusb_ctrl_feed(struct usb_dibusb *dib, int pid, int onoff) * stop feed before setting a new pid and firmware_bug * or if there will be no pid anymore */ - if ((dib->dibdev->parm->firmware_bug && dib->feedcount) || newfeedcount == 0) { +// if ((dib->dibdev->parm->firmware_bug && dib->feedcount) || + if (newfeedcount == 0) { deb_ts("stop feeding\n"); if (dib->xfer_ops.fifo_ctrl != NULL) { if (dib->xfer_ops.fifo_ctrl(dib->fe,0)) { err("error while inhibiting fifo."); return -ENODEV; } - } else { - err("fifo_ctrl is not set."); - return -ENODEV; } } @@ -86,9 +84,6 @@ static int dibusb_ctrl_feed(struct usb_dibusb *dib, int pid, int onoff) err("no free pid in list."); return -ENODEV; } - } else { - err("no pid ctrl callback."); - return -ENODEV; } } @@ -98,8 +93,8 @@ static int dibusb_ctrl_feed(struct usb_dibusb *dib, int pid, int onoff) * reception. */ - if ((dib->dibdev->parm->firmware_bug || dib->feedcount == onoff) && - dib->feedcount > 0) { +// if ((dib->dibdev->parm->firmware_bug || dib->feedcount == onoff) && + if (dib->feedcount > 0) { deb_ts("controlling pid parser\n"); if (dib->xfer_ops.pid_parse != NULL) { @@ -114,9 +109,6 @@ static int dibusb_ctrl_feed(struct usb_dibusb *dib, int pid, int onoff) err("error while enabling fifo."); return -ENODEV; } - } else { - err("fifo_ctrl is not set."); - return -ENODEV; } dibusb_streaming(dib,1); } diff --git a/linux/drivers/media/dvb/dibusb/dvb-dibusb-firmware.c b/linux/drivers/media/dvb/dibusb/dvb-dibusb-firmware.c index a6585e87e..972548a0c 100644 --- a/linux/drivers/media/dvb/dibusb/dvb-dibusb-firmware.c +++ b/linux/drivers/media/dvb/dibusb/dvb-dibusb-firmware.c @@ -22,30 +22,20 @@ static int dibusb_writemem(struct usb_device *udev,u16 addr,u8 *data, u8 len) 0xa0, USB_TYPE_VENDOR, addr, 0x00, data, len, 5*HZ); } -int dibusb_loadfirmware(struct usb_device *udev, struct dibusb_device *dibdev) +int dibusb_loadfirmware(struct usb_device *udev, struct dibusb_usb_device *dibdev) { const struct firmware *fw = NULL; - const char **fws; u16 addr; u8 *b,*p; int ret = 0,i; - fws = dibdev->parm->fw_filenames; - - for (i = 0; i < sizeof(fws)/sizeof(const char*); i++) { - if ((ret = request_firmware(&fw, fws[i], &udev->dev)) == 0) { - info("using firmware file (%s).",fws[i]); - break; - } - deb_info("tried to find '%s' firmware - unsuccessful. (%d)\n", - fws[i],ret); + if ((ret = request_firmware(&fw, dibdev->dev_cl->firmware, &udev->dev)) != 0) { + err("did not find a valid firmware file. (%s) " + "Please see linux/Documentation/dvb/ for more details on firmware-problems.", + dibdev->dev_cl->firmware); + return ret; } - - if (fw == NULL) { - err("did not find a valid firmware file. " - "Please see linux/Documentation/dvb/ for more details on firmware-problems."); - return -EINVAL; - } + p = kmalloc(fw->size,GFP_KERNEL); if (p != NULL) { u8 reset; @@ -58,7 +48,7 @@ int dibusb_loadfirmware(struct usb_device *udev, struct dibusb_device *dibdev) /* stop the CPU */ reset = 1; - if ((ret = dibusb_writemem(udev,dibdev->parm->usb_cpu_csreg,&reset,1)) != 1) + if ((ret = dibusb_writemem(udev,dibdev->dev_cl->usb_ctrl->cpu_cs_register,&reset,1)) != 1) err("could not stop the USB controller CPU."); for(i = 0; p[i+3] == 0 && i < fw->size; ) { b = (u8 *) &p[i]; @@ -80,7 +70,7 @@ int dibusb_loadfirmware(struct usb_device *udev, struct dibusb_device *dibdev) ret = 0; /* restart the CPU */ reset = 0; - if (ret || dibusb_writemem(udev,dibdev->parm->usb_cpu_csreg,&reset,1) != 1) { + if (ret || dibusb_writemem(udev,dibdev->dev_cl->usb_ctrl->cpu_cs_register,&reset,1) != 1) { err("could not restart the USB controller CPU."); ret = -EINVAL; } diff --git a/linux/drivers/media/dvb/dibusb/dvb-dibusb-usb.c b/linux/drivers/media/dvb/dibusb/dvb-dibusb-usb.c index 4f07b5063..2cd57eb1c 100644 --- a/linux/drivers/media/dvb/dibusb/dvb-dibusb-usb.c +++ b/linux/drivers/media/dvb/dibusb/dvb-dibusb-usb.c @@ -27,14 +27,14 @@ int dibusb_readwrite_usb(struct usb_dibusb *dib, u8 *wbuf, u16 wlen, u8 *rbuf, if (dib->feedcount && wbuf[0] == DIBUSB_REQ_I2C_WRITE && - dib->dibdev->parm->type == DIBUSB1_1) + dib->dibdev->dev_cl->id == DIBUSB1_1) deb_err("BUG: writing to i2c, while TS-streaming destroys the stream." "(%x reg: %x %x)\n", wbuf[0],wbuf[2],wbuf[3]); debug_dump(wbuf,wlen); ret = usb_bulk_msg(dib->udev,usb_sndbulkpipe(dib->udev, - dib->dibdev->parm->cmd_pipe), wbuf,wlen,&actlen, + dib->dibdev->dev_cl->pipe_cmd), wbuf,wlen,&actlen, DIBUSB_I2C_TIMEOUT); if (ret) @@ -45,7 +45,7 @@ int dibusb_readwrite_usb(struct usb_dibusb *dib, u8 *wbuf, u16 wlen, u8 *rbuf, /* an answer is expected, and no error before */ if (!ret && rbuf && rlen) { ret = usb_bulk_msg(dib->udev,usb_rcvbulkpipe(dib->udev, - dib->dibdev->parm->result_pipe),rbuf,rlen,&actlen, + dib->dibdev->dev_cl->pipe_cmd),rbuf,rlen,&actlen, DIBUSB_I2C_TIMEOUT); if (ret) @@ -140,19 +140,19 @@ int dibusb_urb_init(struct usb_dibusb *dib) * when reloading the driver w/o replugging the device * a timeout occures, this helps */ - usb_clear_halt(dib->udev,usb_sndbulkpipe(dib->udev,dib->dibdev->parm->cmd_pipe)); - usb_clear_halt(dib->udev,usb_rcvbulkpipe(dib->udev,dib->dibdev->parm->result_pipe)); - usb_clear_halt(dib->udev,usb_rcvbulkpipe(dib->udev,dib->dibdev->parm->data_pipe)); + usb_clear_halt(dib->udev,usb_sndbulkpipe(dib->udev,dib->dibdev->dev_cl->pipe_cmd)); + usb_clear_halt(dib->udev,usb_rcvbulkpipe(dib->udev,dib->dibdev->dev_cl->pipe_cmd)); + usb_clear_halt(dib->udev,usb_rcvbulkpipe(dib->udev,dib->dibdev->dev_cl->pipe_data)); /* allocate the array for the data transfer URBs */ - dib->urb_list = kmalloc(dib->dibdev->parm->num_urbs*sizeof(struct urb *),GFP_KERNEL); + dib->urb_list = kmalloc(dib->dibdev->dev_cl->urb_count*sizeof(struct urb *),GFP_KERNEL); if (dib->urb_list == NULL) return -ENOMEM; - memset(dib->urb_list,0,dib->dibdev->parm->num_urbs*sizeof(struct urb *)); + memset(dib->urb_list,0,dib->dibdev->dev_cl->urb_count*sizeof(struct urb *)); dib->init_state |= DIBUSB_STATE_URB_LIST; - bufsize = dib->dibdev->parm->num_urbs*dib->dibdev->parm->urb_buf_size; + bufsize = dib->dibdev->dev_cl->urb_count*dib->dibdev->dev_cl->urb_buffer_size; deb_info("allocate %d bytes as buffersize for all URBs\n",bufsize); /* allocate the actual buffer for the URBs */ if ((dib->buffer = pci_alloc_consistent(NULL,bufsize,&dib->dma_handle)) == NULL) { @@ -165,16 +165,16 @@ int dibusb_urb_init(struct usb_dibusb *dib) dib->init_state |= DIBUSB_STATE_URB_BUF; /* allocate and submit the URBs */ - for (i = 0; i < dib->dibdev->parm->num_urbs; i++) { + for (i = 0; i < dib->dibdev->dev_cl->urb_count; i++) { if (!(dib->urb_list[i] = usb_alloc_urb(0,GFP_ATOMIC))) { return -ENOMEM; } deb_info("submitting URB no. %d\n",i); usb_fill_bulk_urb( dib->urb_list[i], dib->udev, - usb_rcvbulkpipe(dib->udev,dib->dibdev->parm->data_pipe), - &dib->buffer[i*dib->dibdev->parm->urb_buf_size], - dib->dibdev->parm->urb_buf_size, + usb_rcvbulkpipe(dib->udev,dib->dibdev->dev_cl->pipe_data), + &dib->buffer[i*dib->dibdev->dev_cl->urb_buffer_size], + dib->dibdev->dev_cl->urb_buffer_size, dibusb_urb_complete, dib); dib->urb_list[i]->transfer_flags = 0; @@ -195,7 +195,7 @@ int dibusb_urb_exit(struct usb_dibusb *dib) { int i; if (dib->init_state & DIBUSB_STATE_URB_LIST) { - for (i = 0; i < dib->dibdev->parm->num_urbs; i++) { + for (i = 0; i < dib->dibdev->dev_cl->urb_count; i++) { if (dib->urb_list[i] != NULL) { deb_info("killing URB no. %d.\n",i); @@ -219,7 +219,7 @@ int dibusb_urb_exit(struct usb_dibusb *dib) if (dib->init_state & DIBUSB_STATE_URB_BUF) pci_free_consistent(NULL, - dib->dibdev->parm->urb_buf_size*dib->dibdev->parm->num_urbs, + dib->dibdev->dev_cl->urb_buffer_size*dib->dibdev->dev_cl->urb_count, dib->buffer,dib->dma_handle); dib->init_state &= ~DIBUSB_STATE_URB_BUF; diff --git a/linux/drivers/media/dvb/dibusb/dvb-dibusb.h b/linux/drivers/media/dvb/dibusb/dvb-dibusb.h index 4e5acaf2b..9b54f5d4c 100644 --- a/linux/drivers/media/dvb/dibusb/dvb-dibusb.h +++ b/linux/drivers/media/dvb/dibusb/dvb-dibusb.h @@ -22,6 +22,7 @@ #include "dmxdev.h" #include "dib3000.h" +#include "mt352.h" /* debug */ #ifdef CONFIG_DVB_DIBCOM_DEBUG @@ -42,6 +43,11 @@ extern int debug; #define debug_dump(b,l) #endif +/* Version information */ +#define DRIVER_VERSION "0.3" +#define DRIVER_DESC "Driver for DiBcom based USB Budget DVB-T device" +#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de" + /* module parameters - declared in -core.c */ extern int pid_parse; extern int rc_query_interval; @@ -58,55 +64,60 @@ extern int rc_query_interval; #define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg) #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg) -/* Version information */ -#define DRIVER_VERSION "0.1" -#define DRIVER_DESC "Driver for DiBcom based USB Budget DVB-T device" -#define DRIVER_AUTHOR "Patrick Boettcher, patrick.boettcher@desy.de" +struct dibusb_usb_controller { + const char *name; /* name of the usb controller */ + u16 cpu_cs_register; /* needs to be restarted, when the firmware has been downloaded. */ +}; typedef enum { DIBUSB1_1 = 0, - DIBUSB2_0, DIBUSB1_1_AN2235, -} dibusb_type; - -/* struct for holding properties of the different dibusb device models */ -struct dibusb_device_parameter { - dibusb_type type; - const char **fw_filenames; - const char *usb_controller; - u16 usb_cpu_csreg; + DIBUSB2_0, + UMT2_0, +} dibusb_class_t; + +#define DIBUSB_POSSIBLE_I2C_ADDR_NUM 4 +struct dibusb_frontend_tuner_combi { + int (*pll_set) (struct dvb_frontend *,struct dvb_frontend_parameters *, u8 + pll_buf[5]); /* pll_set function callback */ + unsigned char pll_addr; /* tuner i2c address */ + unsigned char demod_i2c_addrs[DIBUSB_POSSIBLE_I2C_ADDR_NUM]; /* list of possible i2c addresses of the demod */ +}; + +struct dibusb_device_class { + dibusb_class_t id; + const struct dibusb_usb_controller *usb_ctrl; /* usb controller */ + + const char *firmware; /* valid firmware filenames */ + + int pipe_cmd; /* command pipe (read/write) */ + int pipe_data; /* data pipe */ + + int urb_count; /* number of data URBs to be submitted */ + int urb_buffer_size; /* the size of the buffer for each URB */ + +// struct dibusb_frontend_tuner_combi *fe_tuner; /* appropriate frontend and tuner combination */ - int num_urbs; - int urb_buf_size; - int default_size; - int firmware_bug; - - int cmd_pipe; - int result_pipe; - int data_pipe; - - int (*pll_set) (struct dvb_frontend *,struct dvb_frontend_parameters *); - unsigned char pll_addr; - unsigned char demod_i2c_addrs[4]; + int (*pll_set) (struct dvb_frontend *,struct dvb_frontend_parameters *); + u8 pll_addr; /* tuner i2c address */ + u8 demod_i2c_addrs[DIBUSB_POSSIBLE_I2C_ADDR_NUM]; /* list of possible i2c addresses of the demod */ }; -/* - * for each warm/cold product id a name is stored, this is just beautification, - * it could easily done by an PID-array, but then the real names of the devices - * would get lost. - */ -struct dibusb_device { - const char *name; - u16 cold_product_id; - u16 warm_product_id; - struct dibusb_device_parameter *parm; +#define DIBUSB_ID_MAX_NUM 15 +struct dibusb_usb_device { + const char *name; /* real name of the box */ + struct dibusb_device_class *dev_cl; /* which dibusb_device_class is this device part of */ + + struct usb_device_id *cold_ids[DIBUSB_ID_MAX_NUM]; /* list of USB ids when this device is at pre firmware state */ + struct usb_device_id *warm_ids[DIBUSB_ID_MAX_NUM]; /* list of USB ids when this device is at post firmware state */ }; + struct usb_dibusb { /* usb */ struct usb_device * udev; - struct dibusb_device * dibdev; + struct dibusb_usb_device * dibdev; #define DIBUSB_STATE_INIT 0x000 #define DIBUSB_STATE_URB_LIST 0x001 @@ -148,7 +159,7 @@ struct usb_dibusb { /* commonly used functions in the separated files */ /* dvb-dibusb-firmware.c */ -int dibusb_loadfirmware(struct usb_device *udev, struct dibusb_device *dibdev); +int dibusb_loadfirmware(struct usb_device *udev, struct dibusb_usb_device *dibdev); /* dvb-dibusb-remote.c */ int dibusb_remote_exit(struct usb_dibusb *dib); @@ -179,31 +190,70 @@ int dibusb_urb_exit(struct usb_dibusb *dib); /* i2c and transfer stuff */ #define DIBUSB_I2C_TIMEOUT HZ*5 -/* - * types of first byte of each buffer send to USB, applying for - * USB1.1 and USB2.0 +/* + * protocol of all dibusb related devices + */ + +/* + * bulk msg to/from endpoint 0x01 + * + * general structure: + * request_byte parameter_bytes */ #define DIBUSB_REQ_START_READ 0x00 #define DIBUSB_REQ_START_DEMOD 0x01 + +/* + * i2c read + * bulk write: 0x02 (i2c_addr & 0x01) register_bytes length_word + * bulk read: byte_buffer (length_word bytes) + */ #define DIBUSB_REQ_I2C_READ 0x02 + +/* + * i2c write + * bulk write: 0x03 i2c_addr register_bytes value_bytes + */ #define DIBUSB_REQ_I2C_WRITE 0x03 -/* prefix for reading the current RC key */ +/* + * polling the value of the remote control + * bulk write: 0x04 + * bulk read: byte_buffer (5 bytes) + * + * first byte of byte_buffer shows the status (0x00, 0x01, 0x02) + */ #define DIBUSB_REQ_POLL_REMOTE 0x04 #define DIBUSB_RC_NEC_EMPTY 0x00 #define DIBUSB_RC_NEC_KEY_PRESSED 0x01 #define DIBUSB_RC_NEC_KEY_REPEATED 0x02 -/* 0x05 0xXX */ +/* streaming mode: + * bulk write: 0x05 mode_byte + * + * mode_byte is mostly 0x00 + */ #define DIBUSB_REQ_SET_STREAMING_MODE 0x05 /* interrupt the internal read loop, when blocking */ #define DIBUSB_REQ_INTR_READ 0x06 -/* IO control - * 0x07 <cmd 1 byte> <param 32 bytes> +/* io control + * 0x07 cmd_byte param_bytes + * + * param_bytes can be up to 32 bytes + * + * cmd_byte function parameter name + * 0x00 power mode + * 0x00 sleep + * 0x01 wakeup + * + * 0x01 enable streaming + * 0x02 disable streaming + * + * */ #define DIBUSB_REQ_SET_IOCTL 0x07 |