aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/firesat/firesat-rc.c
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2008-11-02 07:45:00 -0500
committerStefan Richter <stefanr@s5r6.in-berlin.de>2009-02-24 08:51:28 -0500
commit8ae83cdf3297d7da301af36bdb6ff45bd331c6d0 (patch)
tree0363a01f1b3655507bdaf7e1f55af6a3ee9d26b7 /drivers/media/dvb/firesat/firesat-rc.c
parent00fc3072e484c1c6fdbd9c3b1851f866000a6cb9 (diff)
firedtv: cleanups and minor fixes
Combination of the following changes: Sun, 2 Nov 2008 13:45:00 +0100 (CET) firedtv: increase FCP frame length for DVB-S2 tune QSPK The last three bytes didn't go out to the wire. Effect of the fix not yet tested. Sun, 2 Nov 2008 13:45:00 +0100 (CET) firedtv: replace mdelay by msleep These functions can sleep (and in fact sleep for the duration of a whole FCP transaction). Hence msleep is more appropriate here. Sun, 2 Nov 2008 13:45:00 +0100 (CET) firedtv: trivial reorganization in avc_api Reduce nesting level by factoring code out of avc_tuner_dsd() into helper functions. Sun, 2 Nov 2008 13:45:00 +0100 (CET) firedtv: trivial cleanups in avc_api Use dev_err(), no CamelCase function names, adjust comment style, put #if 0 around unused code and add FIXME comments, standardize on lower-case hexadecimal constants, use ALIGN() for some frame length calculations, make a local function static... The code which writes FCP command frames and reads FCP response frames is not yet brought into canonical kernel coding style because this involves changes of typedefs (on-the-wire bitfields). Sun, 2 Nov 2008 13:45:00 +0100 (CET) firedtv: don't retry oPCR updates endlessly In the theoretical case that the target node wasn't handling the lock transactions as expected or there was continued interference by other initiating nodes, these functions wouldn't return for ages. Sun, 2 Nov 2008 13:45:00 +0100 (CET) firedtv: remove bitfield typedefs from cmp, fix for big endian CPUs Use macros/ inline functions/ standard byte order accessors to read and write oPCR register values (big endian bitfields, on-the-wire data). The new code may not be the ultimate optimum, but it doesn't occur in a hot path. This fixes the CMP code for big endian CPUs. So far I tested it only on a little endian CPU though. For now, include <asm/byteorder.h> instead of <linux/byteorder.h> because drivers/ieee1394/*.h also include the former. I will fix this in drivers/ieee1394 and firedtv later. Sun, 2 Nov 2008 13:45:00 +0100 (CET) firedtv: trivial cleanups in cmp Reduce nesting level by means of early exit and goto. Remove obsolete includes, use dev_err(), no CamelCase function names... Sun, 2 Nov 2008 13:45:00 +0100 (CET) firedtv: trivial cleanups in firesat-ci Whitespace, variable names, comment style... Also, use dvb_generic_open() and dvb_generic_release() directly as our hooks in struct file_operations because firedtv's wrappers merely called these generic functions. Sun, 2 Nov 2008 13:45:00 +0100 (CET) firedtv: remove CA debug code This looks like it is not necessary to have available for endusers who cannot patch kernels for bug reporting and tests of fixes. Sun, 2 Nov 2008 13:45:00 +0100 (CET) firedtv: remove AV/C debug code This looks like it is not necessary to have available for endusers who cannot patch kernels for bug reporting and tests of fixes. Sun, 2 Nov 2008 13:45:00 +0100 (CET) firedtv: remove various debug code Most of this was already commented out. And that which wasn't is not relevant in normal use. Mon, 29 Sep 2008 19:22:48 +0200 (CEST) firedtv: register input device as child of a FireWire device Instead of one virtual input device which exists for the whole lifetime of the driver and receives events from all connected FireDTVs, register one input device for each firedtv device. These input devices will show up as children of the respective firedtv devices in the sysfs hierarchy. However, the implementation falls short because of a bug in userspace: Udev's path_id script gets stuck with 100% CPU utilization, maybe because of an assumption about the maximum ieee1394 device hierarchy depth. To avoid this bug, we use the fw-host device instead of the proper unit_directory device as parent of the input device. There is hope that the port to the new firewire stack won't be inhibited by this userspace bug because there are no fw-host devices there. Mon, 29 Sep 2008 19:21:52 +0200 (CEST) firedtv: fix string comparison and a few sparse warnings Sparse found a bug: while ((kv_buf + kv_len - 1) == '\0') should have been while (kv_buf[kv_len - 1] == '\0') We fix it by a better implementation without a temporary copy. Also fix sparse warnings of 0 instead of NULL and signedness mismatches. Mon, 29 Sep 2008 19:21:20 +0200 (CEST) firedtv: remove unused struct members and redefine an int as a bool. Mon, 29 Sep 2008 19:20:36 +0200 (CEST) firedtv: fix initialization of dvb_frontend.ops There was a NULL pointer reference if no dvb_frontend_info was found. Also, don't directly assign struct typed values to struct typed variables. Instead write out assignments to individual strcut members. This reduces module size by about 1 kB. Mon, 29 Sep 2008 19:19:41 +0200 (CEST) firedtv: remove unused dual subunit code from initialization No FireDTVs with more than one subunit exists, hence simplify the initialization for the special case of one subunit. The driver was able to check for more than one subunit but was broken for more than two subunits. While we are at it, add several missing cleanups after failure, and include a few dynamically allocated structures diretly into struct firesat instead of allocating them separately. Mon, 29 Sep 2008 19:19:08 +0200 (CEST) firedtv: add vendor_id and version to driver match table Now that nodemgr was enhanced to match against the root directory's vendor ID if there isn't one in the unit directory, use this to prevent firedtv to be bound to wrong devices by accident. Also add the AV/C software version ID to the match flags for completeness; specifier ID and software only make sense as a pair. Mon, 29 Sep 2008 19:18:30 +0200 (CEST) firedtv: use hpsb_node_read(), _write(), _lock() because they are simpler and treat the node generation more correctly. While we are at it, clean up and simplify surrounding code. 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.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/drivers/media/dvb/firesat/firesat-rc.c b/drivers/media/dvb/firesat/firesat-rc.c
index d3e08f9fe9f7..5f9de142ee3e 100644
--- a/drivers/media/dvb/firesat/firesat-rc.c
+++ b/drivers/media/dvb/firesat/firesat-rc.c
@@ -12,9 +12,11 @@
12#include <linux/bitops.h> 12#include <linux/bitops.h>
13#include <linux/input.h> 13#include <linux/input.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/string.h>
15#include <linux/types.h> 16#include <linux/types.h>
16 17
17#include "firesat-rc.h" 18#include "firesat-rc.h"
19#include "firesat.h"
18 20
19/* fixed table with older keycodes, geared towards MythTV */ 21/* fixed table with older keycodes, geared towards MythTV */
20const static u16 oldtable[] = { 22const static u16 oldtable[] = {
@@ -61,7 +63,7 @@ const static u16 oldtable[] = {
61}; 63};
62 64
63/* user-modifiable table for a remote as sold in 2008 */ 65/* user-modifiable table for a remote as sold in 2008 */
64static u16 keytable[] = { 66const static u16 keytable[] = {
65 67
66 /* code from device: 0x0300...0x031f */ 68 /* code from device: 0x0300...0x031f */
67 69
@@ -123,19 +125,24 @@ static u16 keytable[] = {
123 [0x34] = KEY_EXIT, 125 [0x34] = KEY_EXIT,
124}; 126};
125 127
126static struct input_dev *idev; 128int firesat_register_rc(struct firesat *firesat, struct device *dev)
127
128int firesat_register_rc(void)
129{ 129{
130 struct input_dev *idev;
130 int i, err; 131 int i, err;
131 132
132 idev = input_allocate_device(); 133 idev = input_allocate_device();
133 if (!idev) 134 if (!idev)
134 return -ENOMEM; 135 return -ENOMEM;
135 136
137 firesat->remote_ctrl_dev = idev;
136 idev->name = "FireDTV remote control"; 138 idev->name = "FireDTV remote control";
139 idev->dev.parent = dev;
137 idev->evbit[0] = BIT_MASK(EV_KEY); 140 idev->evbit[0] = BIT_MASK(EV_KEY);
138 idev->keycode = keytable; 141 idev->keycode = kmemdup(keytable, sizeof(keytable), GFP_KERNEL);
142 if (!idev->keycode) {
143 err = -ENOMEM;
144 goto fail;
145 }
139 idev->keycodesize = sizeof(keytable[0]); 146 idev->keycodesize = sizeof(keytable[0]);
140 idev->keycodemax = ARRAY_SIZE(keytable); 147 idev->keycodemax = ARRAY_SIZE(keytable);
141 148
@@ -144,22 +151,31 @@ int firesat_register_rc(void)
144 151
145 err = input_register_device(idev); 152 err = input_register_device(idev);
146 if (err) 153 if (err)
147 input_free_device(idev); 154 goto fail_free_keymap;
148 155
156 return 0;
157
158fail_free_keymap:
159 kfree(idev->keycode);
160fail:
161 input_free_device(idev);
149 return err; 162 return err;
150} 163}
151 164
152void firesat_unregister_rc(void) 165void firesat_unregister_rc(struct firesat *firesat)
153{ 166{
154 input_unregister_device(idev); 167 kfree(firesat->remote_ctrl_dev->keycode);
168 input_unregister_device(firesat->remote_ctrl_dev);
155} 169}
156 170
157void firesat_handle_rc(unsigned int code) 171void firesat_handle_rc(struct firesat *firesat, unsigned int code)
158{ 172{
173 u16 *keycode = firesat->remote_ctrl_dev->keycode;
174
159 if (code >= 0x0300 && code <= 0x031f) 175 if (code >= 0x0300 && code <= 0x031f)
160 code = keytable[code - 0x0300]; 176 code = keycode[code - 0x0300];
161 else if (code >= 0x0340 && code <= 0x0354) 177 else if (code >= 0x0340 && code <= 0x0354)
162 code = keytable[code - 0x0320]; 178 code = keycode[code - 0x0320];
163 else if (code >= 0x4501 && code <= 0x451f) 179 else if (code >= 0x4501 && code <= 0x451f)
164 code = oldtable[code - 0x4501]; 180 code = oldtable[code - 0x4501];
165 else if (code >= 0x4540 && code <= 0x4542) 181 else if (code >= 0x4540 && code <= 0x4542)
@@ -170,6 +186,6 @@ void firesat_handle_rc(unsigned int code)
170 return; 186 return;
171 } 187 }
172 188
173 input_report_key(idev, code, 1); 189 input_report_key(firesat->remote_ctrl_dev, code, 1);
174 input_report_key(idev, code, 0); 190 input_report_key(firesat->remote_ctrl_dev, code, 0);
175} 191}