aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/firesat/firesat-rc.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-rc.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-rc.c')
-rw-r--r--drivers/media/dvb/firesat/firesat-rc.c147
1 files changed, 119 insertions, 28 deletions
diff --git a/drivers/media/dvb/firesat/firesat-rc.c b/drivers/media/dvb/firesat/firesat-rc.c
index e300b81008af..d3e08f9fe9f7 100644
--- a/drivers/media/dvb/firesat/firesat-rc.c
+++ b/drivers/media/dvb/firesat/firesat-rc.c
@@ -1,9 +1,26 @@
1#include "firesat.h" 1/*
2#include "firesat-rc.h" 2 * FireDTV driver (formerly known as FireSAT)
3 *
4 * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
10 */
3 11
12#include <linux/bitops.h>
4#include <linux/input.h> 13#include <linux/input.h>
14#include <linux/kernel.h>
15#include <linux/types.h>
16
17#include "firesat-rc.h"
18
19/* fixed table with older keycodes, geared towards MythTV */
20const static u16 oldtable[] = {
21
22 /* code from device: 0x4501...0x451f */
5 23
6static u16 firesat_irtable[] = {
7 KEY_ESC, 24 KEY_ESC,
8 KEY_F9, 25 KEY_F9,
9 KEY_1, 26 KEY_1,
@@ -35,50 +52,124 @@ static u16 firesat_irtable[] = {
35 KEY_RIGHT, 52 KEY_RIGHT,
36 KEY_P, 53 KEY_P,
37 KEY_M, 54 KEY_M,
55
56 /* code from device: 0x4540...0x4542 */
57
38 KEY_R, 58 KEY_R,
39 KEY_V, 59 KEY_V,
40 KEY_C, 60 KEY_C,
41 0
42}; 61};
43 62
44static struct input_dev firesat_idev; 63/* user-modifiable table for a remote as sold in 2008 */
64static u16 keytable[] = {
65
66 /* code from device: 0x0300...0x031f */
67
68 [0x00] = KEY_POWER,
69 [0x01] = KEY_SLEEP,
70 [0x02] = KEY_STOP,
71 [0x03] = KEY_OK,
72 [0x04] = KEY_RIGHT,
73 [0x05] = KEY_1,
74 [0x06] = KEY_2,
75 [0x07] = KEY_3,
76 [0x08] = KEY_LEFT,
77 [0x09] = KEY_4,
78 [0x0a] = KEY_5,
79 [0x0b] = KEY_6,
80 [0x0c] = KEY_UP,
81 [0x0d] = KEY_7,
82 [0x0e] = KEY_8,
83 [0x0f] = KEY_9,
84 [0x10] = KEY_DOWN,
85 [0x11] = KEY_TITLE, /* "OSD" - fixme */
86 [0x12] = KEY_0,
87 [0x13] = KEY_F20, /* "16:9" - fixme */
88 [0x14] = KEY_SCREEN, /* "FULL" - fixme */
89 [0x15] = KEY_MUTE,
90 [0x16] = KEY_SUBTITLE,
91 [0x17] = KEY_RECORD,
92 [0x18] = KEY_TEXT,
93 [0x19] = KEY_AUDIO,
94 [0x1a] = KEY_RED,
95 [0x1b] = KEY_PREVIOUS,
96 [0x1c] = KEY_REWIND,
97 [0x1d] = KEY_PLAYPAUSE,
98 [0x1e] = KEY_NEXT,
99 [0x1f] = KEY_VOLUMEUP,
100
101 /* code from device: 0x0340...0x0354 */
102
103 [0x20] = KEY_CHANNELUP,
104 [0x21] = KEY_F21, /* "4:3" - fixme */
105 [0x22] = KEY_TV,
106 [0x23] = KEY_DVD,
107 [0x24] = KEY_VCR,
108 [0x25] = KEY_AUX,
109 [0x26] = KEY_GREEN,
110 [0x27] = KEY_YELLOW,
111 [0x28] = KEY_BLUE,
112 [0x29] = KEY_CHANNEL, /* "CH.LIST" */
113 [0x2a] = KEY_VENDOR, /* "CI" - fixme */
114 [0x2b] = KEY_VOLUMEDOWN,
115 [0x2c] = KEY_CHANNELDOWN,
116 [0x2d] = KEY_LAST,
117 [0x2e] = KEY_INFO,
118 [0x2f] = KEY_FORWARD,
119 [0x30] = KEY_LIST,
120 [0x31] = KEY_FAVORITES,
121 [0x32] = KEY_MENU,
122 [0x33] = KEY_EPG,
123 [0x34] = KEY_EXIT,
124};
125
126static struct input_dev *idev;
45 127
46int firesat_register_rc(void) 128int firesat_register_rc(void)
47{ 129{
48 int index; 130 int i, err;
131
132 idev = input_allocate_device();
133 if (!idev)
134 return -ENOMEM;
49 135
50 memset(&firesat_idev, 0, sizeof(firesat_idev)); 136 idev->name = "FireDTV remote control";
137 idev->evbit[0] = BIT_MASK(EV_KEY);
138 idev->keycode = keytable;
139 idev->keycodesize = sizeof(keytable[0]);
140 idev->keycodemax = ARRAY_SIZE(keytable);
51 141
52 firesat_idev.evbit[0] = BIT(EV_KEY); 142 for (i = 0; i < ARRAY_SIZE(keytable); i++)
143 set_bit(keytable[i], idev->keybit);
53 144
54 for (index = 0; firesat_irtable[index] != 0; index++) 145 err = input_register_device(idev);
55 set_bit(firesat_irtable[index], firesat_idev.keybit); 146 if (err)
147 input_free_device(idev);
56 148
57 return input_register_device(&firesat_idev); 149 return err;
58} 150}
59 151
60int firesat_unregister_rc(void) 152void firesat_unregister_rc(void)
61{ 153{
62 input_unregister_device(&firesat_idev); 154 input_unregister_device(idev);
63 return 0;
64} 155}
65 156
66int firesat_got_remotecontrolcode(u16 code) 157void firesat_handle_rc(unsigned int code)
67{ 158{
68 u16 keycode; 159 if (code >= 0x0300 && code <= 0x031f)
69 160 code = keytable[code - 0x0300];
70 if (code > 0x4500 && code < 0x4520) 161 else if (code >= 0x0340 && code <= 0x0354)
71 keycode = firesat_irtable[code - 0x4501]; 162 code = keytable[code - 0x0320];
72 else if (code > 0x453f && code < 0x4543) 163 else if (code >= 0x4501 && code <= 0x451f)
73 keycode = firesat_irtable[code - 0x4521]; 164 code = oldtable[code - 0x4501];
165 else if (code >= 0x4540 && code <= 0x4542)
166 code = oldtable[code - 0x4521];
74 else { 167 else {
75 printk(KERN_DEBUG "%s: invalid key code 0x%04x\n", __func__, 168 printk(KERN_DEBUG "firedtv: invalid key code 0x%04x "
76 code); 169 "from remote control\n", code);
77 return -EINVAL; 170 return;
78 } 171 }
79 172
80 input_report_key(&firesat_idev, keycode, 1); 173 input_report_key(idev, code, 1);
81 input_report_key(&firesat_idev, keycode, 0); 174 input_report_key(idev, code, 0);
82
83 return 0;
84} 175}