summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Boettcher <devnull@localhost>2004-12-29 20:27:55 +0000
committerPatrick Boettcher <devnull@localhost>2004-12-29 20:27:55 +0000
commitbfca54e0f0214c6c63dc8abdfe32b78a5d519285 (patch)
treef151fdfa1f0237e323a4fb20bbe9375a60870c5c
parent30205db98dfe86e6793fe1eb27acda2072264062 (diff)
downloadmediapointer-dvb-s2-bfca54e0f0214c6c63dc8abdfe32b78a5d519285.tar.gz
mediapointer-dvb-s2-bfca54e0f0214c6c63dc8abdfe32b78a5d519285.tar.bz2
init state added, clean init and exit of every part
-rw-r--r--linux/drivers/media/dvb/dibusb/dvb-dibusb-core.c11
-rw-r--r--linux/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c8
-rw-r--r--linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c51
-rw-r--r--linux/drivers/media/dvb/dibusb/dvb-dibusb-remote.c12
-rw-r--r--linux/drivers/media/dvb/dibusb/dvb-dibusb-usb.c26
-rw-r--r--linux/drivers/media/dvb/dibusb/dvb-dibusb.h14
6 files changed, 78 insertions, 44 deletions
diff --git a/linux/drivers/media/dvb/dibusb/dvb-dibusb-core.c b/linux/drivers/media/dvb/dibusb/dvb-dibusb-core.c
index 57614918a..776f725fb 100644
--- a/linux/drivers/media/dvb/dibusb/dvb-dibusb-core.c
+++ b/linux/drivers/media/dvb/dibusb/dvb-dibusb-core.c
@@ -71,7 +71,7 @@ static struct dibusb_device_parameter dibusb_dev_parm[3] = {
.usb_cpu_csreg = 0x7f92,
.num_urbs = 3,
- .urb_buf_size = 188*21,
+ .urb_buf_size = 4096,
.default_size = 188*21,
.firmware_bug = 1,
@@ -302,11 +302,14 @@ MODULE_DEVICE_TABLE (usb, dibusb_table);
static int dibusb_exit(struct usb_dibusb *dib)
{
+ deb_info("init_state before exiting everything: %x\n",dib->init_state);
dibusb_remote_exit(dib);
dibusb_fe_exit(dib);
dibusb_i2c_exit(dib);
dibusb_dvb_exit(dib);
- dibusb_usb_exit(dib);
+ dibusb_urb_exit(dib);
+ deb_info("init_state should be zero now: %x\n",dib->init_state);
+ dib->init_state = DIBUSB_STATE_INIT;
kfree(dib);
return 0;
}
@@ -316,12 +319,14 @@ static int dibusb_init(struct usb_dibusb *dib)
int ret = 0;
sema_init(&dib->usb_sem, 1);
sema_init(&dib->i2c_sem, 1);
+
+ dib->init_state = DIBUSB_STATE_INIT;
dibusb_hw_wakeup(dib);
dibusb_set_streaming_mode(dib,0);
dibusb_streaming(dib,0);
- if ((ret = dibusb_usb_init(dib)) ||
+ if ((ret = dibusb_urb_init(dib)) ||
(ret = dibusb_dvb_init(dib)) ||
(ret = dibusb_i2c_init(dib))) {
dibusb_exit(dib);
diff --git a/linux/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c b/linux/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c
index b6e1fab9c..3b82ac072 100644
--- a/linux/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c
+++ b/linux/drivers/media/dvb/dibusb/dvb-dibusb-dvb.c
@@ -46,11 +46,11 @@ void dibusb_urb_complete(struct urb *urb, struct pt_regs *ptregs)
* contain valid TS packets, at least for USB1.1
*
* if (urb->actual_length == dib->dibdev->parm->default_size && dib->dvb_is_ready) */
- if (dib->dvb_is_ready)
+ if (dib->init_state & DIBUSB_STATE_DVB)
dvb_dmx_swfilter(&dib->demux, (u8*) urb->transfer_buffer,urb->actual_length);
else
deb_ts("URB dropped because of the "
- "actual_length or !dvb_is_ready (%d).\n",dib->dvb_is_ready);
+ "actual_length or !dvb_is_ready (%d).\n",dib->init_state & DIBUSB_STATE_DVB);
} else
deb_ts("URB dropped because of feedcount.\n");
@@ -190,13 +190,13 @@ err_dmx:
err:
return ret;
success:
- dib->dvb_is_ready = 1;
+ dib->init_state |= DIBUSB_STATE_DVB;
return 0;
}
int dibusb_dvb_exit(struct usb_dibusb *dib)
{
- dib->dvb_is_ready = 0;
+ dib->init_state &= ~DIBUSB_STATE_DVB;
deb_info("unregistering DVB part\n");
dvb_net_release(&dib->dvb_net);
dib->demux.dmx.close(&dib->demux.dmx);
diff --git a/linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c b/linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c
index dc60a6a92..1d5cecd6b 100644
--- a/linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c
+++ b/linux/drivers/media/dvb/dibusb/dvb-dibusb-fe-i2c.c
@@ -82,28 +82,29 @@ int dibusb_fe_init(struct usb_dibusb* dib)
struct dib3000_config demod_cfg;
int i;
- for (i = 0; i < sizeof(dib->dibdev->parm->demod_i2c_addrs) / sizeof(unsigned char) &&
- dib->dibdev->parm->demod_i2c_addrs[i] != 0; i++) {
-
- demod_cfg.demod_address = dib->dibdev->parm->demod_i2c_addrs[i];
- demod_cfg.pll_addr = dib->dibdev->parm->pll_addr;
- demod_cfg.pll_set = dib->dibdev->parm->pll_set;
- demod_cfg.pll_init = NULL;
-
- switch (dib->dibdev->parm->type) {
- case DIBUSB1_1:
- case DIBUSB1_1_AN2235:
- dib->fe = dib3000mb_attach(&demod_cfg,&dib->i2c_adap,&dib->xfer_ops);
- break;
- case DIBUSB2_0:
- dib->fe = dib3000mc_attach(&demod_cfg,&dib->i2c_adap,&dib->xfer_ops);
- break;
- }
- if (dib->fe != NULL) {
- info("found demodulator at i2c address 0x%x",demod_cfg.demod_address);
- break;
+ if (dib->init_state & DIBUSB_STATE_I2C)
+ for (i = 0; i < sizeof(dib->dibdev->parm->demod_i2c_addrs) / sizeof(unsigned char) &&
+ dib->dibdev->parm->demod_i2c_addrs[i] != 0; i++) {
+
+ demod_cfg.demod_address = dib->dibdev->parm->demod_i2c_addrs[i];
+ demod_cfg.pll_addr = dib->dibdev->parm->pll_addr;
+ demod_cfg.pll_set = dib->dibdev->parm->pll_set;
+ demod_cfg.pll_init = NULL;
+
+ switch (dib->dibdev->parm->type) {
+ case DIBUSB1_1:
+ case DIBUSB1_1_AN2235:
+ dib->fe = dib3000mb_attach(&demod_cfg,&dib->i2c_adap,&dib->xfer_ops);
+ break;
+ case DIBUSB2_0:
+ dib->fe = dib3000mc_attach(&demod_cfg,&dib->i2c_adap,&dib->xfer_ops);
+ break;
+ }
+ if (dib->fe != NULL) {
+ info("found demodulator at i2c address 0x%x",demod_cfg.demod_address);
+ break;
+ }
}
- }
if (dib->fe == NULL) {
err("A frontend driver was not found for device '%s'.",
@@ -148,13 +149,17 @@ int dibusb_i2c_init(struct usb_dibusb *dib)
if ((ret = i2c_add_adapter(&dib->i2c_adap)) < 0)
err("could not add i2c adapter");
-
+
+ dib->init_state |= DIBUSB_STATE_I2C;
+
return ret;
}
int dibusb_i2c_exit(struct usb_dibusb *dib)
{
- i2c_del_adapter(&dib->i2c_adap);
+ if (dib->init_state & DIBUSB_STATE_I2C)
+ i2c_del_adapter(&dib->i2c_adap);
+ dib->init_state &= ~DIBUSB_STATE_I2C;
return 0;
}
diff --git a/linux/drivers/media/dvb/dibusb/dvb-dibusb-remote.c b/linux/drivers/media/dvb/dibusb/dvb-dibusb-remote.c
index fc670c499..82931c0c9 100644
--- a/linux/drivers/media/dvb/dibusb/dvb-dibusb-remote.c
+++ b/linux/drivers/media/dvb/dibusb/dvb-dibusb-remote.c
@@ -173,13 +173,19 @@ int dibusb_remote_init(struct usb_dibusb *dib)
info("schedule remote query interval to %d msecs.",rc_query_interval);
schedule_delayed_work(&dib->rc_query_work,msecs_to_jiffies(rc_query_interval));
+
+ dib->init_state |= DIBUSB_STATE_REMOTE;
+
return 0;
}
int dibusb_remote_exit(struct usb_dibusb *dib)
{
- cancel_delayed_work(&dib->rc_query_work);
- flush_scheduled_work();
- input_unregister_device(&dib->rc_input_dev);
+ if (dib->init_state & DIBUSB_STATE_REMOTE) {
+ cancel_delayed_work(&dib->rc_query_work);
+ flush_scheduled_work();
+ input_unregister_device(&dib->rc_input_dev);
+ }
+ dib->init_state &= ~DIBUSB_STATE_REMOTE;
return 0;
}
diff --git a/linux/drivers/media/dvb/dibusb/dvb-dibusb-usb.c b/linux/drivers/media/dvb/dibusb/dvb-dibusb-usb.c
index 2c97a18dc..4f07b5063 100644
--- a/linux/drivers/media/dvb/dibusb/dvb-dibusb-usb.c
+++ b/linux/drivers/media/dvb/dibusb/dvb-dibusb-usb.c
@@ -132,7 +132,7 @@ int dibusb_streaming(struct usb_dibusb *dib,int onoff)
return dibusb_ioctl_cmd(dib,DIBUSB_IOCTL_CMD_DISABLE_STREAM,NULL,0);
}
-int dibusb_usb_init(struct usb_dibusb *dib)
+int dibusb_urb_init(struct usb_dibusb *dib)
{
int ret,i,bufsize;
@@ -150,6 +150,8 @@ int dibusb_usb_init(struct usb_dibusb *dib)
return -ENOMEM;
memset(dib->urb_list,0,dib->dibdev->parm->num_urbs*sizeof(struct urb *));
+ dib->init_state |= DIBUSB_STATE_URB_LIST;
+
bufsize = dib->dibdev->parm->num_urbs*dib->dibdev->parm->urb_buf_size;
deb_info("allocate %d bytes as buffersize for all URBs\n",bufsize);
/* allocate the actual buffer for the URBs */
@@ -159,6 +161,8 @@ int dibusb_usb_init(struct usb_dibusb *dib)
}
deb_info("allocation complete\n");
memset(dib->buffer,0,bufsize);
+
+ dib->init_state |= DIBUSB_STATE_URB_BUF;
/* allocate and submit the URBs */
for (i = 0; i < dib->dibdev->parm->num_urbs; i++) {
@@ -166,7 +170,7 @@ int dibusb_usb_init(struct usb_dibusb *dib)
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],
@@ -182,14 +186,15 @@ int dibusb_usb_init(struct usb_dibusb *dib)
err("could not submit buffer urb no. %d\n",i);
return ret;
}
+ dib->init_state |= DIBUSB_STATE_URB_SUBMIT;
}
return 0;
}
-int dibusb_usb_exit(struct usb_dibusb *dib)
+int dibusb_urb_exit(struct usb_dibusb *dib)
{
int i;
- if (dib->urb_list != NULL) {
+ if (dib->init_state & DIBUSB_STATE_URB_LIST) {
for (i = 0; i < dib->dibdev->parm->num_urbs; i++) {
if (dib->urb_list[i] != NULL) {
deb_info("killing URB no. %d.\n",i);
@@ -208,10 +213,15 @@ int dibusb_usb_exit(struct usb_dibusb *dib)
}
/* free the urb array */
kfree(dib->urb_list);
+ dib->init_state &= ~DIBUSB_STATE_URB_SUBMIT;
+ dib->init_state &= ~DIBUSB_STATE_URB_LIST;
}
-
- pci_free_consistent(NULL,
- dib->dibdev->parm->urb_buf_size*dib->dibdev->parm->num_urbs,dib->buffer,
- dib->dma_handle);
+
+ if (dib->init_state & DIBUSB_STATE_URB_BUF)
+ pci_free_consistent(NULL,
+ dib->dibdev->parm->urb_buf_size*dib->dibdev->parm->num_urbs,
+ dib->buffer,dib->dma_handle);
+
+ dib->init_state &= ~DIBUSB_STATE_URB_BUF;
return 0;
}
diff --git a/linux/drivers/media/dvb/dibusb/dvb-dibusb.h b/linux/drivers/media/dvb/dibusb/dvb-dibusb.h
index bac7d0921..4e5acaf2b 100644
--- a/linux/drivers/media/dvb/dibusb/dvb-dibusb.h
+++ b/linux/drivers/media/dvb/dibusb/dvb-dibusb.h
@@ -108,6 +108,15 @@ struct usb_dibusb {
struct dibusb_device * dibdev;
+#define DIBUSB_STATE_INIT 0x000
+#define DIBUSB_STATE_URB_LIST 0x001
+#define DIBUSB_STATE_URB_BUF 0x002
+#define DIBUSB_STATE_URB_SUBMIT 0x004
+#define DIBUSB_STATE_DVB 0x008
+#define DIBUSB_STATE_I2C 0x010
+#define DIBUSB_STATE_REMOTE 0x020
+ int init_state;
+
int feedcount;
int pid_parse;
struct dib3000_xfer_ops xfer_ops;
@@ -124,7 +133,6 @@ struct usb_dibusb {
struct semaphore i2c_sem;
/* dvb */
- int dvb_is_ready;
struct dvb_adapter *adapter;
struct dmxdev dmxdev;
struct dvb_demux demux;
@@ -165,8 +173,8 @@ int dibusb_hw_wakeup(struct usb_dibusb *dib);
int dibusb_set_streaming_mode(struct usb_dibusb *dib,u8 mode);
int dibusb_streaming(struct usb_dibusb *dib,int onoff);
-int dibusb_usb_init(struct usb_dibusb *dib);
-int dibusb_usb_exit(struct usb_dibusb *dib);
+int dibusb_urb_init(struct usb_dibusb *dib);
+int dibusb_urb_exit(struct usb_dibusb *dib);
/* i2c and transfer stuff */
#define DIBUSB_I2C_TIMEOUT HZ*5