aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc
diff options
context:
space:
mode:
authorGeorge Spelvin <linux@horizon.com>2014-05-11 07:14:18 -0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-07-25 22:48:41 -0400
commit8ecd5e32d8c8fc02d565aa0c1f3f997dea75f5de (patch)
tree66475a661f5a1f6d382120ab4b2b586e2a752f82 /drivers/media/rc
parentf95589cc41ff973bd5d6aecc6205b048bdb95ed7 (diff)
[media] ati_remote: Generalize KIND_ACCEL to accept diagonals
Rather than having special code cases for diagonal mouse movements, extend the general purpose code used for the cardinal directions to handle arbitrary (x,y) deltas. The deltas themselves are stored in translation table's "code" field; this is also progress toward the goal of eliminating the "value" element entirely. 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.c71
1 files changed, 23 insertions, 48 deletions
diff --git a/drivers/media/rc/ati_remote.c b/drivers/media/rc/ati_remote.c
index 658171fe99e5..401a9f4d6198 100644
--- a/drivers/media/rc/ati_remote.c
+++ b/drivers/media/rc/ati_remote.c
@@ -281,11 +281,7 @@ struct ati_remote {
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 */
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_LU 3 /* Directional keypad diagonals - left up, */ 284#define KIND_ACCEL 3 /* Directional keypad - left, right, up, down.*/
285#define KIND_RU 4 /* right up, */
286#define KIND_LD 5 /* left down, */
287#define KIND_RD 6 /* right down */
288#define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/
289 285
290/* Translation table from hardware messages to input events. */ 286/* Translation table from hardware messages to input events. */
291static const struct { 287static const struct {
@@ -295,16 +291,17 @@ static const struct {
295 unsigned short code; 291 unsigned short code;
296 signed char value; 292 signed char value;
297} ati_remote_tbl[] = { 293} ati_remote_tbl[] = {
298 /* Directional control pad axes */ 294 /* Directional control pad axes. Code is xxyy */
299 {KIND_ACCEL, 0x70, EV_REL, REL_X, -1}, /* left */ 295 {KIND_ACCEL, 0x70, EV_REL, 0xff00, 0}, /* left */
300 {KIND_ACCEL, 0x71, EV_REL, REL_X, 1}, /* right */ 296 {KIND_ACCEL, 0x71, EV_REL, 0x0100, 0}, /* right */
301 {KIND_ACCEL, 0x72, EV_REL, REL_Y, -1}, /* up */ 297 {KIND_ACCEL, 0x72, EV_REL, 0x00ff, 0}, /* up */
302 {KIND_ACCEL, 0x73, EV_REL, REL_Y, 1}, /* down */ 298 {KIND_ACCEL, 0x73, EV_REL, 0x0001, 0}, /* down */
299
303 /* Directional control pad diagonals */ 300 /* Directional control pad diagonals */
304 {KIND_LU, 0x74, EV_REL, 0, 0}, /* left up */ 301 {KIND_ACCEL, 0x74, EV_REL, 0xffff, 0}, /* left up */
305 {KIND_RU, 0x75, EV_REL, 0, 0}, /* right up */ 302 {KIND_ACCEL, 0x75, EV_REL, 0x01ff, 0}, /* right up */
306 {KIND_LD, 0x77, EV_REL, 0, 0}, /* left down */ 303 {KIND_ACCEL, 0x77, EV_REL, 0xff01, 0}, /* left down */
307 {KIND_RD, 0x76, EV_REL, 0, 0}, /* right down */ 304 {KIND_ACCEL, 0x76, EV_REL, 0x0101, 0}, /* right down */
308 305
309 /* "Mouse button" buttons */ 306 /* "Mouse button" buttons */
310 {KIND_LITERAL, 0x78, EV_KEY, BTN_LEFT, 1}, /* left btn down */ 307 {KIND_LITERAL, 0x78, EV_KEY, BTN_LEFT, 1}, /* left btn down */
@@ -493,7 +490,6 @@ static void ati_remote_input_report(struct urb *urb)
493 unsigned char *data= ati_remote->inbuf; 490 unsigned char *data= ati_remote->inbuf;
494 struct input_dev *dev = ati_remote->idev; 491 struct input_dev *dev = ati_remote->idev;
495 int index = -1; 492 int index = -1;
496 int acc;
497 int remote_num; 493 int remote_num;
498 unsigned char scancode; 494 unsigned char scancode;
499 u32 wheel_keycode = KEY_RESERVED; 495 u32 wheel_keycode = KEY_RESERVED;
@@ -573,10 +569,8 @@ static void ati_remote_input_report(struct urb *urb)
573 input_sync(dev); 569 input_sync(dev);
574 570
575 ati_remote->old_jiffies = jiffies; 571 ati_remote->old_jiffies = jiffies;
576 return;
577 }
578 572
579 if (index < 0 || ati_remote_tbl[index].kind == KIND_FILTERED) { 573 } else if (index < 0 || ati_remote_tbl[index].kind == KIND_FILTERED) {
580 unsigned long now = jiffies; 574 unsigned long now = jiffies;
581 575
582 /* Filter duplicate events which happen "too close" together. */ 576 /* Filter duplicate events which happen "too close" together. */
@@ -636,46 +630,27 @@ static void ati_remote_input_report(struct urb *urb)
636 ati_remote_tbl[index].code, 0); 630 ati_remote_tbl[index].code, 0);
637 input_sync(dev); 631 input_sync(dev);
638 632
639 } else { 633 } else if (ati_remote_tbl[index].kind == KIND_ACCEL) {
634 signed char dx = ati_remote_tbl[index].code >> 8;
635 signed char dy = ati_remote_tbl[index].code & 255;
640 636
641 /* 637 /*
642 * Other event kinds are from the directional control pad, and 638 * Other event kinds are from the directional control pad, and
643 * have an acceleration factor applied to them. Without this 639 * have an acceleration factor applied to them. Without this
644 * acceleration, the control pad is mostly unusable. 640 * acceleration, the control pad is mostly unusable.
645 */ 641 */
646 acc = ati_remote_compute_accel(ati_remote); 642 int acc = ati_remote_compute_accel(ati_remote);
647 643 if (dx)
648 switch (ati_remote_tbl[index].kind) { 644 input_report_rel(dev, REL_X, dx * acc);
649 case KIND_ACCEL: 645 if (dy)
650 input_event(dev, ati_remote_tbl[index].type, 646 input_report_rel(dev, REL_Y, dy * acc);
651 ati_remote_tbl[index].code,
652 ati_remote_tbl[index].value * acc);
653 break;
654 case KIND_LU:
655 input_report_rel(dev, REL_X, -acc);
656 input_report_rel(dev, REL_Y, -acc);
657 break;
658 case KIND_RU:
659 input_report_rel(dev, REL_X, acc);
660 input_report_rel(dev, REL_Y, -acc);
661 break;
662 case KIND_LD:
663 input_report_rel(dev, REL_X, -acc);
664 input_report_rel(dev, REL_Y, acc);
665 break;
666 case KIND_RD:
667 input_report_rel(dev, REL_X, acc);
668 input_report_rel(dev, REL_Y, acc);
669 break;
670 default:
671 dev_dbg(&ati_remote->interface->dev,
672 "ati_remote kind=%d\n",
673 ati_remote_tbl[index].kind);
674 }
675 input_sync(dev); 647 input_sync(dev);
676 648
677 ati_remote->old_jiffies = jiffies; 649 ati_remote->old_jiffies = jiffies;
678 ati_remote->old_data = data[2]; 650 ati_remote->old_data = data[2];
651 } else {
652 dev_dbg(&ati_remote->interface->dev, "ati_remote kind=%d\n",
653 ati_remote_tbl[index].kind);
679 } 654 }
680} 655}
681 656