Commit 3d95fd6ad8d3cf582a70ed65660017114b6e4065
Committed by
Dmitry Torokhov
1 parent
b56b92a9a1
Exists in
master
and in
6 other branches
Input: elantech - add resolution query support for v4 hardware
It turns out that v4's firmware provides a command so we can query the resolution. Let's use it. Signed-off-by: JJ Ding <jj_ding@emc.com.tw> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Showing 2 changed files with 38 additions and 0 deletions Side-by-side Diff
drivers/input/mouse/elantech.c
... | ... | @@ -931,6 +931,30 @@ |
931 | 931 | } |
932 | 932 | |
933 | 933 | /* |
934 | + * (value from firmware) * 10 + 790 = dpi | |
935 | + * we also have to convert dpi to dots/mm (*10/254 to avoid floating point) | |
936 | + */ | |
937 | +static unsigned int elantech_convert_res(unsigned int val) | |
938 | +{ | |
939 | + return (val * 10 + 790) * 10 / 254; | |
940 | +} | |
941 | + | |
942 | +static int elantech_get_resolution_v4(struct psmouse *psmouse, | |
943 | + unsigned int *x_res, | |
944 | + unsigned int *y_res) | |
945 | +{ | |
946 | + unsigned char param[3]; | |
947 | + | |
948 | + if (elantech_send_cmd(psmouse, ETP_RESOLUTION_QUERY, param)) | |
949 | + return -1; | |
950 | + | |
951 | + *x_res = elantech_convert_res(param[1] & 0x0f); | |
952 | + *y_res = elantech_convert_res((param[1] & 0xf0) >> 4); | |
953 | + | |
954 | + return 0; | |
955 | +} | |
956 | + | |
957 | +/* | |
934 | 958 | * Set the appropriate event bits for the input subsystem |
935 | 959 | */ |
936 | 960 | static int elantech_set_input_params(struct psmouse *psmouse) |
... | ... | @@ -938,6 +962,7 @@ |
938 | 962 | struct input_dev *dev = psmouse->dev; |
939 | 963 | struct elantech_data *etd = psmouse->private; |
940 | 964 | unsigned int x_min = 0, y_min = 0, x_max = 0, y_max = 0, width = 0; |
965 | + unsigned int x_res = 0, y_res = 0; | |
941 | 966 | |
942 | 967 | if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width)) |
943 | 968 | return -1; |
944 | 969 | |
... | ... | @@ -985,10 +1010,20 @@ |
985 | 1010 | break; |
986 | 1011 | |
987 | 1012 | case 4: |
1013 | + if (elantech_get_resolution_v4(psmouse, &x_res, &y_res)) { | |
1014 | + /* | |
1015 | + * if query failed, print a warning and leave the values | |
1016 | + * zero to resemble synaptics.c behavior. | |
1017 | + */ | |
1018 | + psmouse_warn(psmouse, "couldn't query resolution data.\n"); | |
1019 | + } | |
1020 | + | |
988 | 1021 | __set_bit(BTN_TOOL_QUADTAP, dev->keybit); |
989 | 1022 | /* For X to recognize me as touchpad. */ |
990 | 1023 | input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); |
991 | 1024 | input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0); |
1025 | + input_abs_set_res(dev, ABS_X, x_res); | |
1026 | + input_abs_set_res(dev, ABS_Y, y_res); | |
992 | 1027 | /* |
993 | 1028 | * range of pressure and width is the same as v2, |
994 | 1029 | * report ABS_PRESSURE, ABS_TOOL_WIDTH for compatibility. |
... | ... | @@ -1001,6 +1036,8 @@ |
1001 | 1036 | input_mt_init_slots(dev, ETP_MAX_FINGERS); |
1002 | 1037 | input_set_abs_params(dev, ABS_MT_POSITION_X, x_min, x_max, 0, 0); |
1003 | 1038 | input_set_abs_params(dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0); |
1039 | + input_abs_set_res(dev, ABS_MT_POSITION_X, x_res); | |
1040 | + input_abs_set_res(dev, ABS_MT_POSITION_Y, y_res); | |
1004 | 1041 | input_set_abs_params(dev, ABS_MT_PRESSURE, ETP_PMIN_V2, |
1005 | 1042 | ETP_PMAX_V2, 0, 0); |
1006 | 1043 | /* |
drivers/input/mouse/elantech.h