aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/dvb-usb/dvb-usb-dvb.c')
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-dvb.c170
1 files changed, 83 insertions, 87 deletions
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
index fe6208ada903..4561a672da92 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-dvb.c
@@ -1,6 +1,6 @@
1/* dvb-usb-dvb.c is part of the DVB USB library. 1/* dvb-usb-dvb.c is part of the DVB USB library.
2 * 2 *
3 * Copyright (C) 2004-5 Patrick Boettcher (patrick.boettcher@desy.de) 3 * Copyright (C) 2004-6 Patrick Boettcher (patrick.boettcher@desy.de)
4 * see dvb-usb-init.c for copyright information. 4 * see dvb-usb-init.c for copyright information.
5 * 5 *
6 * This file contains functions for initializing and handling the 6 * This file contains functions for initializing and handling the
@@ -8,55 +8,55 @@
8 */ 8 */
9#include "dvb-usb-common.h" 9#include "dvb-usb-common.h"
10 10
11/* does the complete input transfer handling */
11static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) 12static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
12{ 13{
13 struct dvb_usb_device *d = dvbdmxfeed->demux->priv; 14 struct dvb_usb_adapter *adap = dvbdmxfeed->demux->priv;
14 int newfeedcount,ret; 15 int newfeedcount,ret;
15 16
16 if (d == NULL) 17 if (adap == NULL)
17 return -ENODEV; 18 return -ENODEV;
18 19
19 newfeedcount = d->feedcount + (onoff ? 1 : -1); 20 newfeedcount = adap->feedcount + (onoff ? 1 : -1);
20 21
21 /* 22 /* stop feed before setting a new pid if there will be no pid anymore */
22 * stop feed before setting a new pid if there will be no pid anymore
23 */
24 if (newfeedcount == 0) { 23 if (newfeedcount == 0) {
25 deb_ts("stop feeding\n"); 24 deb_ts("stop feeding\n");
26 dvb_usb_urb_kill(d); 25 usb_urb_kill(&adap->stream);
27 26
28 if (d->props.streaming_ctrl != NULL) 27 if (adap->props.streaming_ctrl != NULL)
29 if ((ret = d->props.streaming_ctrl(d,0))) 28 if ((ret = adap->props.streaming_ctrl(adap,0)))
30 err("error while stopping stream."); 29 err("error while stopping stream.");
31
32 } 30 }
33 31
34 d->feedcount = newfeedcount; 32 adap->feedcount = newfeedcount;
35 33
36 /* activate the pid on the device specific pid_filter */ 34 /* activate the pid on the device specific pid_filter */
37 deb_ts("setting pid: %5d %04x at index %d '%s'\n",dvbdmxfeed->pid,dvbdmxfeed->pid,dvbdmxfeed->index,onoff ? "on" : "off"); 35 deb_ts("setting pid (%s): %5d %04x at index %d '%s'\n",adap->pid_filtering ?
38 if (d->props.caps & DVB_USB_HAS_PID_FILTER && 36 "yes" : "no", dvbdmxfeed->pid,dvbdmxfeed->pid,dvbdmxfeed->index,onoff ?
39 d->pid_filtering && 37 "on" : "off");
40 d->props.pid_filter != NULL) 38 if (adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER &&
41 d->props.pid_filter(d,dvbdmxfeed->index,dvbdmxfeed->pid,onoff); 39 adap->pid_filtering &&
40 adap->props.pid_filter != NULL)
41 adap->props.pid_filter(adap, dvbdmxfeed->index, dvbdmxfeed->pid,onoff);
42 42
43 /* start the feed if this was the first feed and there is still a feed 43 /* start the feed if this was the first feed and there is still a feed
44 * for reception. 44 * for reception.
45 */ 45 */
46 if (d->feedcount == onoff && d->feedcount > 0) { 46 if (adap->feedcount == onoff && adap->feedcount > 0) {
47 deb_ts("submitting all URBs\n"); 47 deb_ts("submitting all URBs\n");
48 dvb_usb_urb_submit(d); 48 usb_urb_submit(&adap->stream);
49 49
50 deb_ts("controlling pid parser\n"); 50 deb_ts("controlling pid parser\n");
51 if (d->props.caps & DVB_USB_HAS_PID_FILTER && 51 if (adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER &&
52 d->props.caps & DVB_USB_PID_FILTER_CAN_BE_TURNED_OFF && 52 adap->props.caps & DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF &&
53 d->props.pid_filter_ctrl != NULL) 53 adap->props.pid_filter_ctrl != NULL)
54 if (d->props.pid_filter_ctrl(d,d->pid_filtering) < 0) 54 if (adap->props.pid_filter_ctrl(adap,adap->pid_filtering) < 0)
55 err("could not handle pid_parser"); 55 err("could not handle pid_parser");
56 56
57 deb_ts("start feeding\n"); 57 deb_ts("start feeding\n");
58 if (d->props.streaming_ctrl != NULL) 58 if (adap->props.streaming_ctrl != NULL)
59 if (d->props.streaming_ctrl(d,1)) { 59 if (adap->props.streaming_ctrl(adap,1)) {
60 err("error while enabling fifo."); 60 err("error while enabling fifo.");
61 return -ENODEV; 61 return -ENODEV;
62 } 62 }
@@ -77,134 +77,130 @@ static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
77 return dvb_usb_ctrl_feed(dvbdmxfeed,0); 77 return dvb_usb_ctrl_feed(dvbdmxfeed,0);
78} 78}
79 79
80int dvb_usb_dvb_init(struct dvb_usb_device *d) 80int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap)
81{ 81{
82 int ret; 82 int ret;
83 83
84 if ((ret = dvb_register_adapter(&d->dvb_adap, d->desc->name, 84 if ((ret = dvb_register_adapter(&adap->dvb_adap, adap->dev->desc->name,
85 d->owner, &d->udev->dev)) < 0) { 85 adap->dev->owner, &adap->dev->udev->dev)) < 0) {
86 deb_info("dvb_register_adapter failed: error %d", ret); 86 deb_info("dvb_register_adapter failed: error %d", ret);
87 goto err; 87 goto err;
88 } 88 }
89 d->dvb_adap.priv = d; 89 adap->dvb_adap.priv = adap;
90 90
91 if (d->props.read_mac_address) { 91 if (adap->dev->props.read_mac_address) {
92 if (d->props.read_mac_address(d,d->dvb_adap.proposed_mac) == 0) 92 if (adap->dev->props.read_mac_address(adap->dev,adap->dvb_adap.proposed_mac) == 0)
93 info("MAC address: %02x:%02x:%02x:%02x:%02x:%02x",d->dvb_adap.proposed_mac[0], 93 info("MAC address: %02x:%02x:%02x:%02x:%02x:%02x",adap->dvb_adap.proposed_mac[0],
94 d->dvb_adap.proposed_mac[1],d->dvb_adap.proposed_mac[2], 94 adap->dvb_adap.proposed_mac[1], adap->dvb_adap.proposed_mac[2],
95 d->dvb_adap.proposed_mac[3],d->dvb_adap.proposed_mac[4], 95 adap->dvb_adap.proposed_mac[3], adap->dvb_adap.proposed_mac[4],
96 d->dvb_adap.proposed_mac[5]); 96 adap->dvb_adap.proposed_mac[5]);
97 else 97 else
98 err("MAC address reading failed."); 98 err("MAC address reading failed.");
99 } 99 }
100 100
101 101
102 d->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING; 102 adap->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING;
103 d->demux.priv = d; 103 adap->demux.priv = adap;
104 104
105 d->demux.feednum = d->demux.filternum = d->max_feed_count; 105 adap->demux.feednum = adap->demux.filternum = adap->max_feed_count;
106 d->demux.start_feed = dvb_usb_start_feed; 106 adap->demux.start_feed = dvb_usb_start_feed;
107 d->demux.stop_feed = dvb_usb_stop_feed; 107 adap->demux.stop_feed = dvb_usb_stop_feed;
108 d->demux.write_to_decoder = NULL; 108 adap->demux.write_to_decoder = NULL;
109 if ((ret = dvb_dmx_init(&d->demux)) < 0) { 109 if ((ret = dvb_dmx_init(&adap->demux)) < 0) {
110 err("dvb_dmx_init failed: error %d",ret); 110 err("dvb_dmx_init failed: error %d",ret);
111 goto err_dmx; 111 goto err_dmx;
112 } 112 }
113 113
114 d->dmxdev.filternum = d->demux.filternum; 114 adap->dmxdev.filternum = adap->demux.filternum;
115 d->dmxdev.demux = &d->demux.dmx; 115 adap->dmxdev.demux = &adap->demux.dmx;
116 d->dmxdev.capabilities = 0; 116 adap->dmxdev.capabilities = 0;
117 if ((ret = dvb_dmxdev_init(&d->dmxdev, &d->dvb_adap)) < 0) { 117 if ((ret = dvb_dmxdev_init(&adap->dmxdev, &adap->dvb_adap)) < 0) {
118 err("dvb_dmxdev_init failed: error %d",ret); 118 err("dvb_dmxdev_init failed: error %d",ret);
119 goto err_dmx_dev; 119 goto err_dmx_dev;
120 } 120 }
121 121
122 dvb_net_init(&d->dvb_adap, &d->dvb_net, &d->demux.dmx); 122 dvb_net_init(&adap->dvb_adap, &adap->dvb_net, &adap->demux.dmx);
123 123
124 d->state |= DVB_USB_STATE_DVB; 124 adap->state |= DVB_USB_ADAP_STATE_DVB;
125 return 0; 125 return 0;
126 126
127err_dmx_dev: 127err_dmx_dev:
128 dvb_dmx_release(&d->demux); 128 dvb_dmx_release(&adap->demux);
129err_dmx: 129err_dmx:
130 dvb_unregister_adapter(&d->dvb_adap); 130 dvb_unregister_adapter(&adap->dvb_adap);
131err: 131err:
132 return ret; 132 return ret;
133} 133}
134 134
135int dvb_usb_dvb_exit(struct dvb_usb_device *d) 135int dvb_usb_adapter_dvb_exit(struct dvb_usb_adapter *adap)
136{ 136{
137 if (d->state & DVB_USB_STATE_DVB) { 137 if (adap->state & DVB_USB_ADAP_STATE_DVB) {
138 deb_info("unregistering DVB part\n"); 138 deb_info("unregistering DVB part\n");
139 dvb_net_release(&d->dvb_net); 139 dvb_net_release(&adap->dvb_net);
140 d->demux.dmx.close(&d->demux.dmx); 140 adap->demux.dmx.close(&adap->demux.dmx);
141 dvb_dmxdev_release(&d->dmxdev); 141 dvb_dmxdev_release(&adap->dmxdev);
142 dvb_dmx_release(&d->demux); 142 dvb_dmx_release(&adap->demux);
143 dvb_unregister_adapter(&d->dvb_adap); 143 dvb_unregister_adapter(&adap->dvb_adap);
144 d->state &= ~DVB_USB_STATE_DVB; 144 adap->state &= ~DVB_USB_ADAP_STATE_DVB;
145 } 145 }
146 return 0; 146 return 0;
147} 147}
148 148
149static int dvb_usb_fe_wakeup(struct dvb_frontend *fe) 149static int dvb_usb_fe_wakeup(struct dvb_frontend *fe)
150{ 150{
151 struct dvb_usb_device *d = fe->dvb->priv; 151 struct dvb_usb_adapter *adap = fe->dvb->priv;
152 152
153 if (d->props.power_ctrl) 153 dvb_usb_device_power_ctrl(adap->dev, 1);
154 d->props.power_ctrl(d,1);
155 154
156 if (d->fe_init) 155 if (adap->fe_init)
157 d->fe_init(fe); 156 adap->fe_init(fe);
158 157
159 return 0; 158 return 0;
160} 159}
161 160
162static int dvb_usb_fe_sleep(struct dvb_frontend *fe) 161static int dvb_usb_fe_sleep(struct dvb_frontend *fe)
163{ 162{
164 struct dvb_usb_device *d = fe->dvb->priv; 163 struct dvb_usb_adapter *adap = fe->dvb->priv;
165 164
166 if (d->fe_sleep) 165 if (adap->fe_sleep)
167 d->fe_sleep(fe); 166 adap->fe_sleep(fe);
168 167
169 if (d->props.power_ctrl) 168 return dvb_usb_device_power_ctrl(adap->dev, 0);
170 d->props.power_ctrl(d,0);
171
172 return 0;
173} 169}
174 170
175int dvb_usb_fe_init(struct dvb_usb_device* d) 171int dvb_usb_adapter_frontend_init(struct dvb_usb_adapter *adap)
176{ 172{
177 if (d->props.frontend_attach == NULL) { 173 if (adap->props.frontend_attach == NULL) {
178 err("strange: '%s' doesn't want to attach a frontend.",d->desc->name); 174 err("strange: '%s' #%d doesn't want to attach a frontend.",adap->dev->desc->name, adap->id);
179 return 0; 175 return 0;
180 } 176 }
181 177
182 /* re-assign sleep and wakeup functions */ 178 /* re-assign sleep and wakeup functions */
183 if (d->props.frontend_attach(d) == 0 && d->fe != NULL) { 179 if (adap->props.frontend_attach(adap) == 0 && adap->fe != NULL) {
184 d->fe_init = d->fe->ops.init; d->fe->ops.init = dvb_usb_fe_wakeup; 180 adap->fe_init = adap->fe->ops.init; adap->fe->ops.init = dvb_usb_fe_wakeup;
185 d->fe_sleep = d->fe->ops.sleep; d->fe->ops.sleep = dvb_usb_fe_sleep; 181 adap->fe_sleep = adap->fe->ops.sleep; adap->fe->ops.sleep = dvb_usb_fe_sleep;
186 182
187 if (dvb_register_frontend(&d->dvb_adap, d->fe)) { 183 if (dvb_register_frontend(&adap->dvb_adap, adap->fe)) {
188 err("Frontend registration failed."); 184 err("Frontend registration failed.");
189 dvb_frontend_detach(d->fe); 185 dvb_frontend_detach(adap->fe);
190 d->fe = NULL; 186 adap->fe = NULL;
191 return -ENODEV; 187 return -ENODEV;
192 } 188 }
193 189
194 /* only attach the tuner if the demod is there */ 190 /* only attach the tuner if the demod is there */
195 if (d->props.tuner_attach != NULL) 191 if (adap->props.tuner_attach != NULL)
196 d->props.tuner_attach(d); 192 adap->props.tuner_attach(adap);
197 } else 193 } else
198 err("no frontend was attached by '%s'",d->desc->name); 194 err("no frontend was attached by '%s'",adap->dev->desc->name);
199 195
200 return 0; 196 return 0;
201} 197}
202 198
203int dvb_usb_fe_exit(struct dvb_usb_device *d) 199int dvb_usb_adapter_frontend_exit(struct dvb_usb_adapter *adap)
204{ 200{
205 if (d->fe != NULL) { 201 if (adap->fe != NULL) {
206 dvb_unregister_frontend(d->fe); 202 dvb_unregister_frontend(adap->fe);
207 dvb_frontend_detach(d->fe); 203 dvb_frontend_detach(adap->fe);
208 } 204 }
209 return 0; 205 return 0;
210} 206}