Commit f3f33c67 authored by Hans de Goede's avatar Hans de Goede Committed by Dmitry Torokhov

Input: alps - Rushmore and v7 resolution support

Add support for querying the physical size from the touchpad for Rushmore
and v7 touchpads, and use that to tell userspace the device resolution.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 9634c152
...@@ -1792,6 +1792,45 @@ static int alps_hw_init_v3(struct psmouse *psmouse) ...@@ -1792,6 +1792,45 @@ static int alps_hw_init_v3(struct psmouse *psmouse)
return -1; return -1;
} }
static int alps_get_v3_v7_resolution(struct psmouse *psmouse, int reg_pitch)
{
int reg, x_pitch, y_pitch, x_electrode, y_electrode, x_phys, y_phys;
struct alps_data *priv = psmouse->private;
reg = alps_command_mode_read_reg(psmouse, reg_pitch);
if (reg < 0)
return reg;
x_pitch = (char)(reg << 4) >> 4; /* sign extend lower 4 bits */
x_pitch = 50 + 2 * x_pitch; /* In 0.1 mm units */
y_pitch = (char)reg >> 4; /* sign extend upper 4 bits */
y_pitch = 36 + 2 * y_pitch; /* In 0.1 mm units */
reg = alps_command_mode_read_reg(psmouse, reg_pitch + 1);
if (reg < 0)
return reg;
x_electrode = (char)(reg << 4) >> 4; /* sign extend lower 4 bits */
x_electrode = 17 + x_electrode;
y_electrode = (char)reg >> 4; /* sign extend upper 4 bits */
y_electrode = 13 + y_electrode;
x_phys = x_pitch * (x_electrode - 1); /* In 0.1 mm units */
y_phys = y_pitch * (y_electrode - 1); /* In 0.1 mm units */
priv->x_res = priv->x_max * 10 / x_phys; /* units / mm */
priv->y_res = priv->y_max * 10 / y_phys; /* units / mm */
psmouse_dbg(psmouse,
"pitch %dx%d num-electrodes %dx%d physical size %dx%d mm res %dx%d\n",
x_pitch, y_pitch, x_electrode, y_electrode,
x_phys / 10, y_phys / 10, priv->x_res, priv->y_res);
return 0;
}
static int alps_hw_init_rushmore_v3(struct psmouse *psmouse) static int alps_hw_init_rushmore_v3(struct psmouse *psmouse)
{ {
struct alps_data *priv = psmouse->private; struct alps_data *priv = psmouse->private;
...@@ -1812,6 +1851,9 @@ static int alps_hw_init_rushmore_v3(struct psmouse *psmouse) ...@@ -1812,6 +1851,9 @@ static int alps_hw_init_rushmore_v3(struct psmouse *psmouse)
alps_command_mode_write_reg(psmouse, 0xc2cb, 0x00)) alps_command_mode_write_reg(psmouse, 0xc2cb, 0x00))
goto error; goto error;
if (alps_get_v3_v7_resolution(psmouse, 0xc2da))
goto error;
reg_val = alps_command_mode_read_reg(psmouse, 0xc2c6); reg_val = alps_command_mode_read_reg(psmouse, 0xc2c6);
if (reg_val == -1) if (reg_val == -1)
goto error; goto error;
...@@ -1997,6 +2039,9 @@ static int alps_hw_init_v7(struct psmouse *psmouse) ...@@ -1997,6 +2039,9 @@ static int alps_hw_init_v7(struct psmouse *psmouse)
alps_command_mode_read_reg(psmouse, 0xc2d9) == -1) alps_command_mode_read_reg(psmouse, 0xc2d9) == -1)
goto error; goto error;
if (alps_get_v3_v7_resolution(psmouse, 0xc397))
goto error;
if (alps_command_mode_write_reg(psmouse, 0xc2c9, 0x64)) if (alps_command_mode_write_reg(psmouse, 0xc2c9, 0x64))
goto error; goto error;
...@@ -2230,6 +2275,9 @@ static void alps_set_abs_params_mt(struct alps_data *priv, ...@@ -2230,6 +2275,9 @@ static void alps_set_abs_params_mt(struct alps_data *priv,
input_set_abs_params(dev1, ABS_MT_POSITION_X, 0, priv->x_max, 0, 0); input_set_abs_params(dev1, ABS_MT_POSITION_X, 0, priv->x_max, 0, 0);
input_set_abs_params(dev1, ABS_MT_POSITION_Y, 0, priv->y_max, 0, 0); input_set_abs_params(dev1, ABS_MT_POSITION_Y, 0, priv->y_max, 0, 0);
input_abs_set_res(dev1, ABS_MT_POSITION_X, priv->x_res);
input_abs_set_res(dev1, ABS_MT_POSITION_Y, priv->y_res);
input_mt_init_slots(dev1, MAX_TOUCHES, INPUT_MT_POINTER | input_mt_init_slots(dev1, MAX_TOUCHES, INPUT_MT_POINTER |
INPUT_MT_DROP_UNUSED | INPUT_MT_TRACK | INPUT_MT_SEMI_MT); INPUT_MT_DROP_UNUSED | INPUT_MT_TRACK | INPUT_MT_SEMI_MT);
......
...@@ -174,6 +174,8 @@ struct alps_data { ...@@ -174,6 +174,8 @@ struct alps_data {
int y_max; int y_max;
int x_bits; int x_bits;
int y_bits; int y_bits;
unsigned int x_res;
unsigned int y_res;
int (*hw_init)(struct psmouse *psmouse); int (*hw_init)(struct psmouse *psmouse);
void (*process_packet)(struct psmouse *psmouse); void (*process_packet)(struct psmouse *psmouse);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment