Commit b6d2d328 authored by Sjoerd Simons's avatar Sjoerd Simons Committed by Dmitry Torokhov

Input: atmel_mxt_ts - split out touchpad initialisation logic

If the "linux,gpio-keymap" DT property is defined, the T19 keys are
configured and the device is setup as a touchpad rather than a touchscreen.
The logic is part of the input device initialization routine but it can be
factored out to its own function to simplify the former.
Signed-off-by: default avatarSjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: default avatarJavier Martinez Canillas <javier.martinez@collabora.co.uk>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent b23157dc
...@@ -1822,15 +1822,37 @@ static int mxt_read_t100_config(struct mxt_data *data) ...@@ -1822,15 +1822,37 @@ static int mxt_read_t100_config(struct mxt_data *data)
static int mxt_input_open(struct input_dev *dev); static int mxt_input_open(struct input_dev *dev);
static void mxt_input_close(struct input_dev *dev); static void mxt_input_close(struct input_dev *dev);
static void mxt_set_up_as_touchpad(struct input_dev *input_dev,
struct mxt_data *data)
{
const struct mxt_platform_data *pdata = data->pdata;
int i;
input_dev->name = "Atmel maXTouch Touchpad";
__set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM);
input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM);
input_abs_set_res(input_dev, ABS_MT_POSITION_X,
MXT_PIXELS_PER_MM);
input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
MXT_PIXELS_PER_MM);
for (i = 0; i < pdata->t19_num_keys; i++)
if (pdata->t19_keymap[i] != KEY_RESERVED)
input_set_capability(input_dev, EV_KEY,
pdata->t19_keymap[i]);
}
static int mxt_initialize_input_device(struct mxt_data *data) static int mxt_initialize_input_device(struct mxt_data *data)
{ {
struct device *dev = &data->client->dev;
const struct mxt_platform_data *pdata = data->pdata; const struct mxt_platform_data *pdata = data->pdata;
struct device *dev = &data->client->dev;
struct input_dev *input_dev; struct input_dev *input_dev;
int error; int error;
unsigned int num_mt_slots; unsigned int num_mt_slots;
unsigned int mt_flags = 0; unsigned int mt_flags = 0;
int i;
switch (data->multitouch) { switch (data->multitouch) {
case MXT_TOUCH_MULTI_T9: case MXT_TOUCH_MULTI_T9:
...@@ -1867,26 +1889,6 @@ static int mxt_initialize_input_device(struct mxt_data *data) ...@@ -1867,26 +1889,6 @@ static int mxt_initialize_input_device(struct mxt_data *data)
input_set_capability(input_dev, EV_KEY, BTN_TOUCH); input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
if (pdata->t19_num_keys) {
__set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
for (i = 0; i < pdata->t19_num_keys; i++)
if (pdata->t19_keymap[i] != KEY_RESERVED)
input_set_capability(input_dev, EV_KEY,
pdata->t19_keymap[i]);
mt_flags |= INPUT_MT_POINTER;
input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM);
input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM);
input_abs_set_res(input_dev, ABS_MT_POSITION_X,
MXT_PIXELS_PER_MM);
input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
MXT_PIXELS_PER_MM);
input_dev->name = "Atmel maXTouch Touchpad";
}
/* For single touch */ /* For single touch */
input_set_abs_params(input_dev, ABS_X, 0, data->max_x, 0, 0); input_set_abs_params(input_dev, ABS_X, 0, data->max_x, 0, 0);
input_set_abs_params(input_dev, ABS_Y, 0, data->max_y, 0, 0); input_set_abs_params(input_dev, ABS_Y, 0, data->max_y, 0, 0);
...@@ -1897,6 +1899,12 @@ static int mxt_initialize_input_device(struct mxt_data *data) ...@@ -1897,6 +1899,12 @@ static int mxt_initialize_input_device(struct mxt_data *data)
input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0); input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0);
} }
/* If device has buttons we assume it is a touchpad */
if (pdata->t19_num_keys) {
mxt_set_up_as_touchpad(input_dev, data);
mt_flags |= INPUT_MT_POINTER;
}
/* For multi touch */ /* For multi touch */
error = input_mt_init_slots(input_dev, num_mt_slots, mt_flags); error = input_mt_init_slots(input_dev, num_mt_slots, mt_flags);
if (error) { if (error) {
......
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