aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/mouse/alps.c
diff options
context:
space:
mode:
authorKevin Cernekee <cernekee@gmail.com>2013-02-13 23:57:04 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2013-02-14 12:17:47 -0500
commit2e992cc030d8e4e42632bcc9e16605e629886778 (patch)
tree2aa52da87c087d58cc3cec915ccc27e8704002a2 /drivers/input/mouse/alps.c
parent99df65e705503a97a5fceb30317086a091b4052d (diff)
Input: ALPS - move alps_get_model() down below hw_init code
This will minimize the number of forward declarations needed when alps_get_model() starts assigning function pointers. Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Tested-by: Dave Turvene <dturvene@dahetral.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/mouse/alps.c')
-rw-r--r--drivers/input/mouse/alps.c186
1 files changed, 93 insertions, 93 deletions
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 33ee6e0b9752..c473549c33bd 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -998,99 +998,6 @@ static inline int alps_exit_command_mode(struct psmouse *psmouse)
998 return 0; 998 return 0;
999} 999}
1000 1000
1001static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version)
1002{
1003 struct ps2dev *ps2dev = &psmouse->ps2dev;
1004 static const unsigned char rates[] = { 0, 10, 20, 40, 60, 80, 100, 200 };
1005 unsigned char param[4];
1006 const struct alps_model_info *model = NULL;
1007 int i;
1008
1009 /*
1010 * First try "E6 report".
1011 * ALPS should return 0,0,10 or 0,0,100 if no buttons are pressed.
1012 * The bits 0-2 of the first byte will be 1s if some buttons are
1013 * pressed.
1014 */
1015 param[0] = 0;
1016 if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES) ||
1017 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
1018 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
1019 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11))
1020 return NULL;
1021
1022 param[0] = param[1] = param[2] = 0xff;
1023 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
1024 return NULL;
1025
1026 psmouse_dbg(psmouse, "E6 report: %2.2x %2.2x %2.2x",
1027 param[0], param[1], param[2]);
1028
1029 if ((param[0] & 0xf8) != 0 || param[1] != 0 ||
1030 (param[2] != 10 && param[2] != 100))
1031 return NULL;
1032
1033 /*
1034 * Now try "E7 report". Allowed responses are in
1035 * alps_model_data[].signature
1036 */
1037 param[0] = 0;
1038 if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES) ||
1039 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
1040 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
1041 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21))
1042 return NULL;
1043
1044 param[0] = param[1] = param[2] = 0xff;
1045 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
1046 return NULL;
1047
1048 psmouse_dbg(psmouse, "E7 report: %2.2x %2.2x %2.2x",
1049 param[0], param[1], param[2]);
1050
1051 if (version) {
1052 for (i = 0; i < ARRAY_SIZE(rates) && param[2] != rates[i]; i++)
1053 /* empty */;
1054 *version = (param[0] << 8) | (param[1] << 4) | i;
1055 }
1056
1057 for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) {
1058 if (!memcmp(param, alps_model_data[i].signature,
1059 sizeof(alps_model_data[i].signature))) {
1060 model = alps_model_data + i;
1061 break;
1062 }
1063 }
1064
1065 if (model && model->proto_version > ALPS_PROTO_V2) {
1066 /*
1067 * Need to check command mode response to identify
1068 * model
1069 */
1070 model = NULL;
1071 if (alps_enter_command_mode(psmouse, param)) {
1072 psmouse_warn(psmouse,
1073 "touchpad failed to enter command mode\n");
1074 } else {
1075 for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) {
1076 if (alps_model_data[i].proto_version > ALPS_PROTO_V2 &&
1077 alps_model_data[i].command_mode_resp == param[0]) {
1078 model = alps_model_data + i;
1079 break;
1080 }
1081 }
1082 alps_exit_command_mode(psmouse);
1083
1084 if (!model)
1085 psmouse_dbg(psmouse,
1086 "Unknown command mode response %2.2x\n",
1087 param[0]);
1088 }
1089 }
1090
1091 return model;
1092}
1093
1094/* 1001/*
1095 * For DualPoint devices select the device that should respond to 1002 * For DualPoint devices select the device that should respond to
1096 * subsequent commands. It looks like glidepad is behind stickpointer, 1003 * subsequent commands. It looks like glidepad is behind stickpointer,
@@ -1534,6 +1441,99 @@ static int alps_hw_init(struct psmouse *psmouse)
1534 return ret; 1441 return ret;
1535} 1442}
1536 1443
1444static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version)
1445{
1446 struct ps2dev *ps2dev = &psmouse->ps2dev;
1447 static const unsigned char rates[] = { 0, 10, 20, 40, 60, 80, 100, 200 };
1448 unsigned char param[4];
1449 const struct alps_model_info *model = NULL;
1450 int i;
1451
1452 /*
1453 * First try "E6 report".
1454 * ALPS should return 0,0,10 or 0,0,100 if no buttons are pressed.
1455 * The bits 0-2 of the first byte will be 1s if some buttons are
1456 * pressed.
1457 */
1458 param[0] = 0;
1459 if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES) ||
1460 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
1461 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
1462 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11))
1463 return NULL;
1464
1465 param[0] = param[1] = param[2] = 0xff;
1466 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
1467 return NULL;
1468
1469 psmouse_dbg(psmouse, "E6 report: %2.2x %2.2x %2.2x",
1470 param[0], param[1], param[2]);
1471
1472 if ((param[0] & 0xf8) != 0 || param[1] != 0 ||
1473 (param[2] != 10 && param[2] != 100))
1474 return NULL;
1475
1476 /*
1477 * Now try "E7 report". Allowed responses are in
1478 * alps_model_data[].signature
1479 */
1480 param[0] = 0;
1481 if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRES) ||
1482 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
1483 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
1484 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21))
1485 return NULL;
1486
1487 param[0] = param[1] = param[2] = 0xff;
1488 if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO))
1489 return NULL;
1490
1491 psmouse_dbg(psmouse, "E7 report: %2.2x %2.2x %2.2x",
1492 param[0], param[1], param[2]);
1493
1494 if (version) {
1495 for (i = 0; i < ARRAY_SIZE(rates) && param[2] != rates[i]; i++)
1496 /* empty */;
1497 *version = (param[0] << 8) | (param[1] << 4) | i;
1498 }
1499
1500 for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) {
1501 if (!memcmp(param, alps_model_data[i].signature,
1502 sizeof(alps_model_data[i].signature))) {
1503 model = alps_model_data + i;
1504 break;
1505 }
1506 }
1507
1508 if (model && model->proto_version > ALPS_PROTO_V2) {
1509 /*
1510 * Need to check command mode response to identify
1511 * model
1512 */
1513 model = NULL;
1514 if (alps_enter_command_mode(psmouse, param)) {
1515 psmouse_warn(psmouse,
1516 "touchpad failed to enter command mode\n");
1517 } else {
1518 for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) {
1519 if (alps_model_data[i].proto_version > ALPS_PROTO_V2 &&
1520 alps_model_data[i].command_mode_resp == param[0]) {
1521 model = alps_model_data + i;
1522 break;
1523 }
1524 }
1525 alps_exit_command_mode(psmouse);
1526
1527 if (!model)
1528 psmouse_dbg(psmouse,
1529 "Unknown command mode response %2.2x\n",
1530 param[0]);
1531 }
1532 }
1533
1534 return model;
1535}
1536
1537static int alps_reconnect(struct psmouse *psmouse) 1537static int alps_reconnect(struct psmouse *psmouse)
1538{ 1538{
1539 const struct alps_model_info *model; 1539 const struct alps_model_info *model;