diff options
Diffstat (limited to 'drivers/media/dvb/firesat/firesat_dvb.c')
-rw-r--r-- | drivers/media/dvb/firesat/firesat_dvb.c | 147 |
1 files changed, 45 insertions, 102 deletions
diff --git a/drivers/media/dvb/firesat/firesat_dvb.c b/drivers/media/dvb/firesat/firesat_dvb.c index 9e87402289a6..e944cee19f0a 100644 --- a/drivers/media/dvb/firesat/firesat_dvb.c +++ b/drivers/media/dvb/firesat/firesat_dvb.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * FireSAT DVB driver | 2 | * FireDTV driver (formerly known as FireSAT) |
3 | * | 3 | * |
4 | * Copyright (c) ? | 4 | * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com> |
5 | * Copyright (c) 2008 Henrik Kurelid <henrik@kurelid.se> | 5 | * Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU General Public License as | 8 | * modify it under the terms of the GNU General Public License as |
@@ -10,64 +10,52 @@ | |||
10 | * the License, or (at your option) any later version. | 10 | * the License, or (at your option) any later version. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/slab.h> | ||
15 | #include <linux/wait.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/time.h> | ||
19 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
20 | #include <linux/interrupt.h> | 14 | #include <linux/kernel.h> |
21 | #include <ieee1394_hotplug.h> | 15 | #include <linux/mutex.h> |
22 | #include <nodemgr.h> | 16 | #include <linux/types.h> |
23 | #include <highlevel.h> | 17 | |
24 | #include <ohci1394.h> | 18 | #include <dvb_demux.h> |
25 | #include <hosts.h> | 19 | #include <dvb_frontend.h> |
26 | #include <dvbdev.h> | 20 | #include <dvbdev.h> |
27 | 21 | ||
28 | #include "firesat.h" | ||
29 | #include "avc_api.h" | 22 | #include "avc_api.h" |
30 | #include "cmp.h" | 23 | #include "firesat.h" |
31 | #include "firesat-rc.h" | ||
32 | #include "firesat-ci.h" | 24 | #include "firesat-ci.h" |
33 | 25 | ||
34 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | 26 | DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); |
35 | 27 | ||
36 | static struct firesat_channel *firesat_channel_allocate(struct firesat *firesat) | 28 | static struct firesat_channel *firesat_channel_allocate(struct firesat *firesat) |
37 | { | 29 | { |
30 | struct firesat_channel *c = NULL; | ||
38 | int k; | 31 | int k; |
39 | 32 | ||
40 | //printk(KERN_INFO "%s\n", __func__); | 33 | if (mutex_lock_interruptible(&firesat->demux_mutex)) |
41 | |||
42 | if (down_interruptible(&firesat->demux_sem)) | ||
43 | return NULL; | 34 | return NULL; |
44 | 35 | ||
45 | for (k = 0; k < 16; k++) { | 36 | for (k = 0; k < 16; k++) |
46 | //printk(KERN_INFO "%s: channel %d: active = %d, pid = 0x%x\n",__func__,k,firesat->channel[k].active,firesat->channel[k].pid); | ||
47 | |||
48 | if (firesat->channel[k].active == 0) { | 37 | if (firesat->channel[k].active == 0) { |
49 | firesat->channel[k].active = 1; | 38 | firesat->channel[k].active = 1; |
50 | up(&firesat->demux_sem); | 39 | c = &firesat->channel[k]; |
51 | return &firesat->channel[k]; | 40 | break; |
52 | } | 41 | } |
53 | } | ||
54 | 42 | ||
55 | up(&firesat->demux_sem); | 43 | mutex_unlock(&firesat->demux_mutex); |
56 | return NULL; // no more channels available | 44 | return c; |
57 | } | 45 | } |
58 | 46 | ||
59 | static int firesat_channel_collect(struct firesat *firesat, int *pidc, u16 pid[]) | 47 | static int firesat_channel_collect(struct firesat *firesat, int *pidc, u16 pid[]) |
60 | { | 48 | { |
61 | int k, l = 0; | 49 | int k, l = 0; |
62 | 50 | ||
63 | if (down_interruptible(&firesat->demux_sem)) | 51 | if (mutex_lock_interruptible(&firesat->demux_mutex)) |
64 | return -EINTR; | 52 | return -EINTR; |
65 | 53 | ||
66 | for (k = 0; k < 16; k++) | 54 | for (k = 0; k < 16; k++) |
67 | if (firesat->channel[k].active == 1) | 55 | if (firesat->channel[k].active == 1) |
68 | pid[l++] = firesat->channel[k].pid; | 56 | pid[l++] = firesat->channel[k].pid; |
69 | 57 | ||
70 | up(&firesat->demux_sem); | 58 | mutex_unlock(&firesat->demux_mutex); |
71 | 59 | ||
72 | *pidc = l; | 60 | *pidc = l; |
73 | 61 | ||
@@ -77,12 +65,12 @@ static int firesat_channel_collect(struct firesat *firesat, int *pidc, u16 pid[] | |||
77 | static int firesat_channel_release(struct firesat *firesat, | 65 | static int firesat_channel_release(struct firesat *firesat, |
78 | struct firesat_channel *channel) | 66 | struct firesat_channel *channel) |
79 | { | 67 | { |
80 | if (down_interruptible(&firesat->demux_sem)) | 68 | if (mutex_lock_interruptible(&firesat->demux_mutex)) |
81 | return -EINTR; | 69 | return -EINTR; |
82 | 70 | ||
83 | channel->active = 0; | 71 | channel->active = 0; |
84 | 72 | ||
85 | up(&firesat->demux_sem); | 73 | mutex_unlock(&firesat->demux_mutex); |
86 | return 0; | 74 | return 0; |
87 | } | 75 | } |
88 | 76 | ||
@@ -172,7 +160,8 @@ int firesat_stop_feed(struct dvb_demux_feed *dvbdmxfeed) | |||
172 | { | 160 | { |
173 | struct dvb_demux *demux = dvbdmxfeed->demux; | 161 | struct dvb_demux *demux = dvbdmxfeed->demux; |
174 | struct firesat *firesat = (struct firesat*)demux->priv; | 162 | struct firesat *firesat = (struct firesat*)demux->priv; |
175 | int k, l = 0; | 163 | struct firesat_channel *c = dvbdmxfeed->priv; |
164 | int k, l; | ||
176 | u16 pids[16]; | 165 | u16 pids[16]; |
177 | 166 | ||
178 | //printk(KERN_INFO "%s (pid %u)\n", __func__, dvbdmxfeed->pid); | 167 | //printk(KERN_INFO "%s (pid %u)\n", __func__, dvbdmxfeed->pid); |
@@ -197,30 +186,24 @@ int firesat_stop_feed(struct dvb_demux_feed *dvbdmxfeed) | |||
197 | return 0; | 186 | return 0; |
198 | } | 187 | } |
199 | 188 | ||
200 | if (down_interruptible(&firesat->demux_sem)) | 189 | if (mutex_lock_interruptible(&firesat->demux_mutex)) |
201 | return -EINTR; | 190 | return -EINTR; |
202 | 191 | ||
203 | 192 | /* list except channel to be removed */ | |
204 | // list except channel to be removed | 193 | for (k = 0, l = 0; k < 16; k++) |
205 | for (k = 0; k < 16; k++) | ||
206 | if (firesat->channel[k].active == 1) { | 194 | if (firesat->channel[k].active == 1) { |
207 | if (&firesat->channel[k] != | 195 | if (&firesat->channel[k] != c) |
208 | (struct firesat_channel *)dvbdmxfeed->priv) | ||
209 | pids[l++] = firesat->channel[k].pid; | 196 | pids[l++] = firesat->channel[k].pid; |
210 | else | 197 | else |
211 | firesat->channel[k].active = 0; | 198 | firesat->channel[k].active = 0; |
212 | } | 199 | } |
213 | 200 | ||
214 | if ((k = AVCTuner_SetPIDs(firesat, l, pids))) { | 201 | k = AVCTuner_SetPIDs(firesat, l, pids); |
215 | up(&firesat->demux_sem); | 202 | if (!k) |
216 | return k; | 203 | c->active = 0; |
217 | } | ||
218 | 204 | ||
219 | ((struct firesat_channel *)dvbdmxfeed->priv)->active = 0; | 205 | mutex_unlock(&firesat->demux_mutex); |
220 | 206 | return k; | |
221 | up(&firesat->demux_sem); | ||
222 | |||
223 | return 0; | ||
224 | } | 207 | } |
225 | 208 | ||
226 | int firesat_dvbdev_init(struct firesat *firesat, | 209 | int firesat_dvbdev_init(struct firesat *firesat, |
@@ -229,60 +212,20 @@ int firesat_dvbdev_init(struct firesat *firesat, | |||
229 | { | 212 | { |
230 | int result; | 213 | int result; |
231 | 214 | ||
232 | #if 0 | 215 | firesat->adapter = kmalloc(sizeof(*firesat->adapter), GFP_KERNEL); |
233 | switch (firesat->type) { | 216 | if (!firesat->adapter) { |
234 | case FireSAT_DVB_S: | 217 | printk(KERN_ERR "firedtv: couldn't allocate memory\n"); |
235 | firesat->model_name = "FireSAT DVB-S"; | 218 | return -ENOMEM; |
236 | firesat->frontend_info = &firesat_S_frontend_info; | 219 | } |
237 | break; | ||
238 | case FireSAT_DVB_C: | ||
239 | firesat->model_name = "FireSAT DVB-C"; | ||
240 | firesat->frontend_info = &firesat_C_frontend_info; | ||
241 | break; | ||
242 | case FireSAT_DVB_T: | ||
243 | firesat->model_name = "FireSAT DVB-T"; | ||
244 | firesat->frontend_info = &firesat_T_frontend_info; | ||
245 | break; | ||
246 | default: | ||
247 | printk("%s: unknown model type 0x%x on subunit %d!\n", | ||
248 | __func__, firesat->type,subunit); | ||
249 | firesat->model_name = "Unknown"; | ||
250 | firesat->frontend_info = NULL; | ||
251 | } | ||
252 | #endif | ||
253 | /* // ------- CRAP ----------- | ||
254 | if (!firesat->frontend_info) { | ||
255 | spin_lock_irqsave(&firesat_list_lock, flags); | ||
256 | list_del(&firesat->list); | ||
257 | spin_unlock_irqrestore(&firesat_list_lock, flags); | ||
258 | kfree(firesat); | ||
259 | continue; | ||
260 | } | ||
261 | */ | ||
262 | //initialising firesat->adapter before calling dvb_register_adapter | ||
263 | if (!(firesat->adapter = kmalloc(sizeof (struct dvb_adapter), GFP_KERNEL))) { | ||
264 | printk("%s: couldn't allocate memory.\n", __func__); | ||
265 | kfree(firesat->adapter); | ||
266 | kfree(firesat); | ||
267 | return -ENOMEM; | ||
268 | } | ||
269 | |||
270 | if ((result = DVB_REGISTER_ADAPTER(firesat->adapter, | ||
271 | firesat->model_name, | ||
272 | THIS_MODULE, | ||
273 | dev, adapter_nr)) < 0) { | ||
274 | |||
275 | printk("%s: dvb_register_adapter failed: error %d\n", __func__, result); | ||
276 | #if 0 | ||
277 | /* ### cleanup */ | ||
278 | spin_lock_irqsave(&firesat_list_lock, flags); | ||
279 | list_del(&firesat->list); | ||
280 | spin_unlock_irqrestore(&firesat_list_lock, flags); | ||
281 | #endif | ||
282 | kfree(firesat); | ||
283 | 220 | ||
284 | return result; | 221 | result = DVB_REGISTER_ADAPTER(firesat->adapter, |
285 | } | 222 | firedtv_model_names[firesat->type], |
223 | THIS_MODULE, dev, adapter_nr); | ||
224 | if (result < 0) { | ||
225 | printk(KERN_ERR "firedtv: dvb_register_adapter failed\n"); | ||
226 | kfree(firesat->adapter); | ||
227 | return result; | ||
228 | } | ||
286 | 229 | ||
287 | memset(&firesat->demux, 0, sizeof(struct dvb_demux)); | 230 | memset(&firesat->demux, 0, sizeof(struct dvb_demux)); |
288 | firesat->demux.dmx.capabilities = 0/*DMX_TS_FILTERING | DMX_SECTION_FILTERING*/; | 231 | firesat->demux.dmx.capabilities = 0/*DMX_TS_FILTERING | DMX_SECTION_FILTERING*/; |