aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/firesat/firesat_dvb.c
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2008-08-25 18:17:30 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2009-02-24 08:51:26 -0500
commit612262a53352af839a14b3395975a3440c95080a (patch)
treec31efac0f840ac633a48e0fd07fdd95029d25c17 /drivers/media/dvb/firesat/firesat_dvb.c
parent81c67b7f82769292a86b802590be5879413f9278 (diff)
firesat: copyrights, rename to firedtv, API conversions, fix remote control input
Combination of the following changes: Tue, 26 Aug 2008 00:17:30 +0200 (CEST) firedtv: fix remote control input and update the scancode-to-keycode mapping to a current model. Per default, various media key keycodes are emitted which closely match what is printed on the remote. Userland can modify the mapping by means of evdev ioctls. (Not tested.) The old scancode-to-keycode mapping is left in the driver but cannot be modified by ioctls. This preserves status quo for old remotes. Tue, 26 Aug 2008 00:11:28 +0200 (CEST) firedtv: replace tasklet by workqueue job Non-atomic context is a lot nicer to work with. Sun, 24 Aug 2008 23:30:00 +0200 (CEST) firedtv: move some code back to ieee1394 core Partially reverts "ieee1394: remove unused code" of Linux 2.6.25. Sun, 24 Aug 2008 23:29:30 +0200 (CEST) firedtv: replace semaphore by mutex firesat->avc_sem and ->demux_sem have been used exactly like a mutex. The only exception is the schedule_remotecontrol tasklet which did a down_trylock in atomic context. This is not possible with mutex_trylock; however the whole remote control related code is non-functional anyway at the moment. This should be fixed eventually, probably by turning the tasklet into a worqueue job. Convert everything else from semaphore to mutex. Also rewrite a few of the affected functions to unlock the mutex at a single exit point, instead of in several branches. Sun, 24 Aug 2008 23:28:45 +0200 (CEST) firedtv: some header cleanups Unify #ifndef/#define/#endif guards against multiple inclusion. Drop extern keyword from function declarations. Remove #include's into header files where struct declarations suffice. Remove unused ohci1394 interface and related unused ieee1394 interfaces. Add a few missing #include's and remove a few apparently obsolete ones. Sort them alphabetically. Sun, 24 Aug 2008 23:27:45 +0200 (CEST) firedtv: nicer registration message and some initialization fixes Print the correct name in dvb_register_adapter(). While we are at it, replace two switch cascades by one for loop, remove a superfluous member of struct firesat and of two unused arguments of AVCIdentifySubunit(), and fix bogus kfree's in firesat_dvbdev_init(). Tue, 26 Aug 2008 14:24:17 +0200 (CEST) firesat: rename to firedtv Suggested by Andreas Monitzer. Besides DVB-S/-S2 receivers, the driver also supports DVB-C and DVB-T receivers, hence the previous project name is too narrow now. Not yet done: Rename source directory, files, types, variables... Sun, 24 Aug 2008 23:26:23 +0200 (CEST) firesat: add missing copyright notes Reported by Andreas Monitzer and Christian Dolzer. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/media/dvb/firesat/firesat_dvb.c')
-rw-r--r--drivers/media/dvb/firesat/firesat_dvb.c147
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
34DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 26DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
35 27
36static struct firesat_channel *firesat_channel_allocate(struct firesat *firesat) 28static 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
59static int firesat_channel_collect(struct firesat *firesat, int *pidc, u16 pid[]) 47static 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[]
77static int firesat_channel_release(struct firesat *firesat, 65static 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
226int firesat_dvbdev_init(struct firesat *firesat, 209int 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*/;