aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/dvb-usb-init.c
diff options
context:
space:
mode:
authorPatrick Boettcher <pb@linuxtv.org>2006-09-30 05:53:48 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-10-03 14:10:54 -0400
commit4d43e13f723e12734257277cc38497fab1efc605 (patch)
tree7debc4f9b7997f7d768dcf387210436b532198f4 /drivers/media/dvb/dvb-usb/dvb-usb-init.c
parent8ccb3dcd1f8e80e8702642e1de26541b52f6bb7c (diff)
V4L/DVB (4643): Multi-input patch for DVB-USB device
This patch is the first commit of the Multiple Input Patch for the DVB-USB frame work. It changes the DVB-USB-device to be able to have more than one streaming input (e.g. multiple DVB-T sources) on one device. This is a necessary feature for the upcoming DiB7700 driven devices. Signed-off-by: Patrick Boettcher <pb@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/dvb-usb/dvb-usb-init.c')
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c156
1 files changed, 113 insertions, 43 deletions
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index a1705ecb9a54..6babdcd4c1ab 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * dvb-usb-init.c 4 * dvb-usb-init.c
5 * 5 *
6 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 6 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free 9 * under the terms of the GNU General Public License as published by the Free
@@ -16,21 +16,105 @@
16/* debug */ 16/* debug */
17int dvb_usb_debug; 17int dvb_usb_debug;
18module_param_named(debug,dvb_usb_debug, int, 0644); 18module_param_named(debug,dvb_usb_debug, int, 0644);
19MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64 (or-able))." DVB_USB_DEBUG_STATUS); 19MODULE_PARM_DESC(debug, "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64,mem=128,uxfer=256 (or-able))." DVB_USB_DEBUG_STATUS);
20 20
21int dvb_usb_disable_rc_polling; 21int dvb_usb_disable_rc_polling;
22module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644); 22module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644);
23MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0)."); 23MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0).");
24 24
25static int dvb_usb_force_pid_filter_usage;
26module_param_named(force_pid_filter_usage, dvb_usb_force_pid_filter_usage, int, 0444);
27MODULE_PARM_DESC(disable_rc_polling, "force all dvb-usb-devices to use a PID filter, if any (default: 0).");
28
29static int dvb_usb_adapter_init(struct dvb_usb_device *d)
30{
31 struct dvb_usb_adapter *adap;
32 int ret,n;
33
34 for (n = 0; n < d->props.num_adapters; n++) {
35 adap = &d->adapter[n];
36 adap->dev = d;
37 adap->id = n;
38
39 memcpy(&adap->props, &d->props.adapter[n], sizeof(struct dvb_usb_adapter_properties));
40
41/* speed - when running at FULL speed we need a HW PID filter */
42 if (d->udev->speed == USB_SPEED_FULL && !(adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER)) {
43 err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)");
44 return -ENODEV;
45 }
46
47 if ((d->udev->speed == USB_SPEED_FULL && adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) ||
48 (adap->props.caps & DVB_USB_ADAP_NEED_PID_FILTERING)) {
49 info("will use the device's hardware PID filter (table count: %d).",adap->props.pid_filter_count);
50 adap->pid_filtering = 1;
51 adap->max_feed_count = adap->props.pid_filter_count;
52 } else {
53 info("will pass the complete MPEG2 transport stream to the software demuxer.");
54 adap->pid_filtering = 0;
55 adap->max_feed_count = 255;
56 }
57
58 if (!adap->pid_filtering &&
59 dvb_usb_force_pid_filter_usage &&
60 adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) {
61 info("pid filter enabled by module option.");
62 adap->pid_filtering = 1;
63 adap->max_feed_count = adap->props.pid_filter_count;
64 }
65
66 if (adap->props.size_of_priv > 0) {
67 adap->priv = kzalloc(adap->props.size_of_priv,GFP_KERNEL);
68 if (adap->priv == NULL) {
69 err("no memory for priv for adapter %d.",n);
70 return -ENOMEM;
71 }
72 }
73
74 if ((ret = dvb_usb_adapter_stream_init(adap)) ||
75 (ret = dvb_usb_adapter_dvb_init(adap)) ||
76 (ret = dvb_usb_adapter_frontend_init(adap))) {
77 return ret;
78 }
79
80 d->num_adapters_initialized++;
81 d->state |= DVB_USB_STATE_DVB;
82 }
83
84 /*
85 * when reloading the driver w/o replugging the device
86 * sometimes a timeout occures, this helps
87 */
88 if (d->props.generic_bulk_ctrl_endpoint != 0) {
89 usb_clear_halt(d->udev,usb_sndbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint));
90 usb_clear_halt(d->udev,usb_rcvbulkpipe(d->udev,d->props.generic_bulk_ctrl_endpoint));
91 }
92
93 return 0;
94}
95
96static int dvb_usb_adapter_exit(struct dvb_usb_device *d)
97{
98 int n;
99 for (n = 0; n < d->num_adapters_initialized; n++) {
100 dvb_usb_adapter_frontend_exit(&d->adapter[n]);
101 dvb_usb_adapter_dvb_exit(&d->adapter[n]);
102 dvb_usb_adapter_stream_exit(&d->adapter[n]);
103 kfree(d->adapter[n].priv);
104 }
105 d->num_adapters_initialized = 0;
106 d->state &= ~DVB_USB_STATE_DVB;
107 return 0;
108}
109
110
25/* general initialization functions */ 111/* general initialization functions */
26static int dvb_usb_exit(struct dvb_usb_device *d) 112static int dvb_usb_exit(struct dvb_usb_device *d)
27{ 113{
28 deb_info("state before exiting everything: %x\n",d->state); 114 deb_info("state before exiting everything: %x\n",d->state);
29 dvb_usb_remote_exit(d); 115 dvb_usb_remote_exit(d);
30 dvb_usb_fe_exit(d); 116 dvb_usb_adapter_exit(d);
31 dvb_usb_i2c_exit(d); 117 dvb_usb_i2c_exit(d);
32 dvb_usb_dvb_exit(d);
33 dvb_usb_urb_exit(d);
34 deb_info("state should be zero now: %x\n",d->state); 118 deb_info("state should be zero now: %x\n",d->state);
35 d->state = DVB_USB_STATE_INIT; 119 d->state = DVB_USB_STATE_INIT;
36 kfree(d->priv); 120 kfree(d->priv);
@@ -47,32 +131,19 @@ static int dvb_usb_init(struct dvb_usb_device *d)
47 131
48 d->state = DVB_USB_STATE_INIT; 132 d->state = DVB_USB_STATE_INIT;
49 133
50/* check the capabilities and set appropriate variables */ 134 if (d->props.size_of_priv > 0) {
51 135 d->priv = kzalloc(d->props.size_of_priv,GFP_KERNEL);
52/* speed - when running at FULL speed we need a HW PID filter */ 136 if (d->priv == NULL) {
53 if (d->udev->speed == USB_SPEED_FULL && !(d->props.caps & DVB_USB_HAS_PID_FILTER)) { 137 err("no memory for priv in 'struct dvb_usb_device'");
54 err("This USB2.0 device cannot be run on a USB1.1 port. (it lacks a hardware PID filter)"); 138 return -ENOMEM;
55 return -ENODEV;
56 } 139 }
57
58 if ((d->udev->speed == USB_SPEED_FULL && d->props.caps & DVB_USB_HAS_PID_FILTER) ||
59 (d->props.caps & DVB_USB_NEED_PID_FILTERING)) {
60 info("will use the device's hardware PID filter (table count: %d).",d->props.pid_filter_count);
61 d->pid_filtering = 1;
62 d->max_feed_count = d->props.pid_filter_count;
63 } else {
64 info("will pass the complete MPEG2 transport stream to the software demuxer.");
65 d->pid_filtering = 0;
66 d->max_feed_count = 255;
67 } 140 }
68 141
69 if (d->props.power_ctrl) 142/* check the capabilities and set appropriate variables */
70 d->props.power_ctrl(d,1); 143 dvb_usb_device_power_ctrl(d, 1);
71 144
72 if ((ret = dvb_usb_urb_init(d)) || 145 if ((ret = dvb_usb_i2c_init(d)) ||
73 (ret = dvb_usb_dvb_init(d)) || 146 (ret = dvb_usb_adapter_init(d))) {
74 (ret = dvb_usb_i2c_init(d)) ||
75 (ret = dvb_usb_fe_init(d))) {
76 dvb_usb_exit(d); 147 dvb_usb_exit(d);
77 return ret; 148 return ret;
78 } 149 }
@@ -80,14 +151,13 @@ static int dvb_usb_init(struct dvb_usb_device *d)
80 if ((ret = dvb_usb_remote_init(d))) 151 if ((ret = dvb_usb_remote_init(d)))
81 err("could not initialize remote control."); 152 err("could not initialize remote control.");
82 153
83 if (d->props.power_ctrl) 154 dvb_usb_device_power_ctrl(d, 0);
84 d->props.power_ctrl(d,0);
85 155
86 return 0; 156 return 0;
87} 157}
88 158
89/* determine the name and the state of the just found USB device */ 159/* determine the name and the state of the just found USB device */
90static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device *udev,struct dvb_usb_properties *props, int *cold) 160static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device *udev,struct dvb_usb_device_properties *props, int *cold)
91{ 161{
92 int i,j; 162 int i,j;
93 struct dvb_usb_device_description *desc = NULL; 163 struct dvb_usb_device_description *desc = NULL;
@@ -125,11 +195,20 @@ static struct dvb_usb_device_description * dvb_usb_find_device(struct usb_device
125 return desc; 195 return desc;
126} 196}
127 197
198int dvb_usb_device_power_ctrl(struct dvb_usb_device *d, int onoff)
199{
200 if (d->powered == !onoff) {
201 d->powered = onoff;
202 if (d->props.power_ctrl)
203 return d->props.power_ctrl(d, onoff);
204 }
205 return 0;
206}
207
128/* 208/*
129 * USB 209 * USB
130 */ 210 */
131 211int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_device_properties
132int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties
133 *props, struct module *owner,struct dvb_usb_device **du) 212 *props, struct module *owner,struct dvb_usb_device **du)
134{ 213{
135 struct usb_device *udev = interface_to_usbdev(intf); 214 struct usb_device *udev = interface_to_usbdev(intf);
@@ -161,19 +240,10 @@ int dvb_usb_device_init(struct usb_interface *intf, struct dvb_usb_properties
161 } 240 }
162 241
163 d->udev = udev; 242 d->udev = udev;
164 memcpy(&d->props,props,sizeof(struct dvb_usb_properties)); 243 memcpy(&d->props,props,sizeof(struct dvb_usb_device_properties));
165 d->desc = desc; 244 d->desc = desc;
166 d->owner = owner; 245 d->owner = owner;
167 246
168 if (d->props.size_of_priv > 0) {
169 d->priv = kzalloc(d->props.size_of_priv,GFP_KERNEL);
170 if (d->priv == NULL) {
171 err("no memory for priv in 'struct dvb_usb_device'");
172 kfree(d);
173 return -ENOMEM;
174 }
175 }
176
177 usb_set_intfdata(intf, d); 247 usb_set_intfdata(intf, d);
178 248
179 if (du != NULL) 249 if (du != NULL)
@@ -204,7 +274,7 @@ void dvb_usb_device_exit(struct usb_interface *intf)
204} 274}
205EXPORT_SYMBOL(dvb_usb_device_exit); 275EXPORT_SYMBOL(dvb_usb_device_exit);
206 276
207MODULE_VERSION("0.3"); 277MODULE_VERSION("1.0");
208MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>"); 278MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
209MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices"); 279MODULE_DESCRIPTION("A library module containing commonly used USB and DVB function USB DVB devices");
210MODULE_LICENSE("GPL"); 280MODULE_LICENSE("GPL");