aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorThierry MERLE <thierry.merle@free.fr>2008-09-18 23:24:51 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-12 07:37:14 -0400
commit7f9876785276ac7f8606f8bf53a3dae4c10b8adb (patch)
treefac5a2389014dc037098963321cb0a591e3fb3c0 /drivers/media/dvb
parent986bd1e58b18c09b753f797df19251804bfe3e84 (diff)
V4L/DVB (9108): cinergyT2: add remote key repeat feature
Implement key repeat feature for the cinergyT2 remote controller. Signed-off-by: Thierry MERLE <thierry.merle@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/dvb-usb/cinergyT2-core.c52
1 files changed, 45 insertions, 7 deletions
diff --git a/drivers/media/dvb/dvb-usb/cinergyT2-core.c b/drivers/media/dvb/dvb-usb/cinergyT2-core.c
index 25863033c480..3ac9f74e9fbf 100644
--- a/drivers/media/dvb/dvb-usb/cinergyT2-core.c
+++ b/drivers/media/dvb/dvb-usb/cinergyT2-core.c
@@ -40,6 +40,9 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info, xfer=2, rc=4 "
40 40
41DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 41DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
42 42
43struct cinergyt2_state {
44 u8 rc_counter;
45};
43 46
44/* We are missing a release hook with usb_device data */ 47/* We are missing a release hook with usb_device data */
45struct dvb_usb_device *cinergyt2_usb_device; 48struct dvb_usb_device *cinergyt2_usb_device;
@@ -122,22 +125,57 @@ static struct dvb_usb_rc_key cinergyt2_rc_keys[] = {
122 { 0x04, 0x5c, KEY_NEXT } 125 { 0x04, 0x5c, KEY_NEXT }
123}; 126};
124 127
128/* Number of keypresses to ignore before detect repeating */
129#define RC_REPEAT_DELAY 3
130
131static int repeatable_keys[] = {
132 KEY_UP,
133 KEY_DOWN,
134 KEY_LEFT,
135 KEY_RIGHT,
136 KEY_VOLUMEUP,
137 KEY_VOLUMEDOWN,
138 KEY_CHANNELUP,
139 KEY_CHANNELDOWN
140};
141
125static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 142static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
126{ 143{
144 struct cinergyt2_state *st = d->priv;
127 u8 key[5] = {0, 0, 0, 0, 0}, cmd = CINERGYT2_EP1_GET_RC_EVENTS; 145 u8 key[5] = {0, 0, 0, 0, 0}, cmd = CINERGYT2_EP1_GET_RC_EVENTS;
146 int i;
147
128 *state = REMOTE_NO_KEY_PRESSED; 148 *state = REMOTE_NO_KEY_PRESSED;
129 149
130 dvb_usb_generic_rw(d, &cmd, 1, key, sizeof(key), 0); 150 dvb_usb_generic_rw(d, &cmd, 1, key, sizeof(key), 0);
131 if (key[4] == 0xff) 151 if (key[4] == 0xff) {
152 /* key repeat */
153 st->rc_counter++;
154 if (st->rc_counter > RC_REPEAT_DELAY) {
155 for (i = 0; i < ARRAY_SIZE(repeatable_keys); i++) {
156 if (d->last_event == repeatable_keys[i]) {
157 *state = REMOTE_KEY_REPEAT;
158 *event = d->last_event;
159 deb_rc("repeat key, event %x\n",
160 *event);
161 return 0;
162 }
163 }
164 deb_rc("repeated key (non repeatable)\n");
165 }
132 return 0; 166 return 0;
167 }
133 168
134 /* hack to pass checksum on the custom field (is set to 0xeb) */ 169 /* hack to pass checksum on the custom field */
135 key[2] = ~0x04; 170 key[2] = ~key[1];
136 dvb_usb_nec_rc_key_to_event(d, key, event, state); 171 dvb_usb_nec_rc_key_to_event(d, key, event, state);
137 if (key[0] != 0) 172 if (key[0] != 0) {
138 deb_info("key: %x %x %x %x %x\n", 173 if (*event != d->last_event)
139 key[0], key[1], key[2], key[3], key[4]); 174 st->rc_counter = 0;
140 175
176 deb_rc("key: %x %x %x %x %x\n",
177 key[0], key[1], key[2], key[3], key[4]);
178 }
141 return 0; 179 return 0;
142} 180}
143 181
@@ -157,7 +195,7 @@ static struct usb_device_id cinergyt2_usb_table[] = {
157MODULE_DEVICE_TABLE(usb, cinergyt2_usb_table); 195MODULE_DEVICE_TABLE(usb, cinergyt2_usb_table);
158 196
159static struct dvb_usb_device_properties cinergyt2_properties = { 197static struct dvb_usb_device_properties cinergyt2_properties = {
160 198 .size_of_priv = sizeof(struct cinergyt2_state),
161 .num_adapters = 1, 199 .num_adapters = 1,
162 .adapter = { 200 .adapter = {
163 { 201 {