aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc
diff options
context:
space:
mode:
authorGeorge Spelvin <linux@horizon.com>2014-05-11 07:14:54 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-07-25 22:50:58 -0400
commit3f245b9cb44453b911499e702dc9301f0c4981d3 (patch)
tree057c300dccacc98c3dc8fd1435d153e013147bae /drivers/media/rc
parent8ecd5e32d8c8fc02d565aa0c1f3f997dea75f5de (diff)
[media] ati_remote: Shrink the ati_remote_tbl even more
Get rid of the unnecessary "type" and "value" fields. Signed-off-by: George Spelvin <linux@horizon.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r--drivers/media/rc/ati_remote.c69
1 files changed, 35 insertions, 34 deletions
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index 401a9f4d6198..a41986ca1310 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -279,43 +279,42 @@ struct ati_remote {
279 279
280/* "Kinds" of messages sent from the hardware to the driver. */ 280/* "Kinds" of messages sent from the hardware to the driver. */
281#define KIND_END 0 281#define KIND_END 0
282#define KIND_LITERAL 1 /* Simply pass to input system */ 282#define KIND_LITERAL 1 /* Simply pass to input system as EV_KEY */
283#define KIND_FILTERED 2 /* Add artificial key-up events, drop keyrepeats */ 283#define KIND_FILTERED 2 /* Add artificial key-up events, drop keyrepeats */
284#define KIND_ACCEL 3 /* Directional keypad - left, right, up, down.*/ 284#define KIND_ACCEL 3 /* Translate to EV_REL mouse-move events */
285 285
286/* Translation table from hardware messages to input events. */ 286/* Translation table from hardware messages to input events. */
287static const struct { 287static const struct {
288 unsigned char kind; 288 unsigned char kind;
289 unsigned char data; 289 unsigned char data; /* Raw key code from remote */
290 unsigned char type; 290 unsigned short code; /* Input layer translation */
291 unsigned short code;
292 signed char value;
293} ati_remote_tbl[] = { 291} ati_remote_tbl[] = {
294 /* Directional control pad axes. Code is xxyy */ 292 /* Directional control pad axes. Code is xxyy */
295 {KIND_ACCEL, 0x70, EV_REL, 0xff00, 0}, /* left */ 293 {KIND_ACCEL, 0x70, 0xff00}, /* left */
296 {KIND_ACCEL, 0x71, EV_REL, 0x0100, 0}, /* right */ 294 {KIND_ACCEL, 0x71, 0x0100}, /* right */
297 {KIND_ACCEL, 0x72, EV_REL, 0x00ff, 0}, /* up */ 295 {KIND_ACCEL, 0x72, 0x00ff}, /* up */
298 {KIND_ACCEL, 0x73, EV_REL, 0x0001, 0}, /* down */ 296 {KIND_ACCEL, 0x73, 0x0001}, /* down */
299 297
300 /* Directional control pad diagonals */ 298 /* Directional control pad diagonals */
301 {KIND_ACCEL, 0x74, EV_REL, 0xffff, 0}, /* left up */ 299 {KIND_ACCEL, 0x74, 0xffff}, /* left up */
302 {KIND_ACCEL, 0x75, EV_REL, 0x01ff, 0}, /* right up */ 300 {KIND_ACCEL, 0x75, 0x01ff}, /* right up */
303 {KIND_ACCEL, 0x77, EV_REL, 0xff01, 0}, /* left down */ 301 {KIND_ACCEL, 0x77, 0xff01}, /* left down */
304 {KIND_ACCEL, 0x76, EV_REL, 0x0101, 0}, /* right down */ 302 {KIND_ACCEL, 0x76, 0x0101}, /* right down */
305 303
306 /* "Mouse button" buttons */ 304 /* "Mouse button" buttons. The code below uses the fact that the
307 {KIND_LITERAL, 0x78, EV_KEY, BTN_LEFT, 1}, /* left btn down */ 305 * lsbit of the raw code is a down/up indicator. */
308 {KIND_LITERAL, 0x79, EV_KEY, BTN_LEFT, 0}, /* left btn up */ 306 {KIND_LITERAL, 0x78, BTN_LEFT}, /* left btn down */
309 {KIND_LITERAL, 0x7c, EV_KEY, BTN_RIGHT, 1},/* right btn down */ 307 {KIND_LITERAL, 0x79, BTN_LEFT}, /* left btn up */
310 {KIND_LITERAL, 0x7d, EV_KEY, BTN_RIGHT, 0},/* right btn up */ 308 {KIND_LITERAL, 0x7c, BTN_RIGHT},/* right btn down */
309 {KIND_LITERAL, 0x7d, BTN_RIGHT},/* right btn up */
311 310
312 /* Artificial "doubleclick" events are generated by the hardware. 311 /* Artificial "doubleclick" events are generated by the hardware.
313 * They are mapped to the "side" and "extra" mouse buttons here. */ 312 * They are mapped to the "side" and "extra" mouse buttons here. */
314 {KIND_FILTERED, 0x7a, EV_KEY, BTN_SIDE, 1}, /* left dblclick */ 313 {KIND_FILTERED, 0x7a, BTN_SIDE}, /* left dblclick */
315 {KIND_FILTERED, 0x7e, EV_KEY, BTN_EXTRA, 1},/* right dblclick */ 314 {KIND_FILTERED, 0x7e, BTN_EXTRA},/* right dblclick */
316 315
317 /* Non-mouse events are handled by rc-core */ 316 /* Non-mouse events are handled by rc-core */
318 {KIND_END, 0x00, EV_MAX + 1, 0, 0} 317 {KIND_END, 0x00, 0}
319}; 318};
320 319
321/* 320/*
@@ -563,9 +562,12 @@ static void ati_remote_input_report(struct urb *urb)
563 } 562 }
564 563
565 if (index >= 0 && ati_remote_tbl[index].kind == KIND_LITERAL) { 564 if (index >= 0 && ati_remote_tbl[index].kind == KIND_LITERAL) {
566 input_event(dev, ati_remote_tbl[index].type, 565 /*
567 ati_remote_tbl[index].code, 566 * The lsbit of the raw key code is a down/up flag.
568 ati_remote_tbl[index].value); 567 * Invert it to match the input layer's conventions.
568 */
569 input_event(dev, EV_KEY, ati_remote_tbl[index].code,
570 !(data[2] & 1));
569 input_sync(dev); 571 input_sync(dev);
570 572
571 ati_remote->old_jiffies = jiffies; 573 ati_remote->old_jiffies = jiffies;
@@ -586,9 +588,9 @@ static void ati_remote_input_report(struct urb *urb)
586 ati_remote->old_data = data[2]; 588 ati_remote->old_data = data[2];
587 ati_remote->old_jiffies = now; 589 ati_remote->old_jiffies = now;
588 590
589 /* Ensure we skip at least the 4 first duplicate events (generated 591 /* Ensure we skip at least the 4 first duplicate events
590 * by a single keypress), and continue skipping until repeat_delay 592 * (generated by a single keypress), and continue skipping
591 * msecs have passed 593 * until repeat_delay msecs have passed.
592 */ 594 */
593 if (ati_remote->repeat_count > 0 && 595 if (ati_remote->repeat_count > 0 &&
594 (ati_remote->repeat_count < 5 || 596 (ati_remote->repeat_count < 5 ||
@@ -624,10 +626,8 @@ static void ati_remote_input_report(struct urb *urb)
624 return; 626 return;
625 } 627 }
626 628
627 input_event(dev, ati_remote_tbl[index].type, 629 input_event(dev, EV_KEY, ati_remote_tbl[index].code, 1);
628 ati_remote_tbl[index].code, 1); 630 input_event(dev, EV_KEY, ati_remote_tbl[index].code, 0);
629 input_event(dev, ati_remote_tbl[index].type,
630 ati_remote_tbl[index].code, 0);
631 input_sync(dev); 631 input_sync(dev);
632 632
633 } else if (ati_remote_tbl[index].kind == KIND_ACCEL) { 633 } else if (ati_remote_tbl[index].kind == KIND_ACCEL) {
@@ -738,7 +738,8 @@ static void ati_remote_input_init(struct ati_remote *ati_remote)
738 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA); 738 BIT_MASK(BTN_RIGHT) | BIT_MASK(BTN_SIDE) | BIT_MASK(BTN_EXTRA);
739 idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); 739 idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
740 for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++) 740 for (i = 0; ati_remote_tbl[i].kind != KIND_END; i++)
741 if (ati_remote_tbl[i].type == EV_KEY) 741 if (ati_remote_tbl[i].kind == KIND_LITERAL ||
742 ati_remote_tbl[i].kind == KIND_FILTERED)
742 set_bit(ati_remote_tbl[i].code, idev->keybit); 743 set_bit(ati_remote_tbl[i].code, idev->keybit);
743 744
744 input_set_drvdata(idev, ati_remote); 745 input_set_drvdata(idev, ati_remote);