aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2015-04-06 16:10:30 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2015-04-06 16:37:32 -0400
commitb6d2d3289f84e9c7449dff04fb959e29207acd80 (patch)
tree509c2f7359dec6c3cfadec6196baab452ca576ce /drivers/input/touchscreen
parentb23157dc74272ac8ebffd1a566e3e822dbc3e65f (diff)
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: Sjoerd Simons <sjoerd.simons@collabora.co.uk> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r--drivers/input/touchscreen/atmel_mxt_ts.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 1b3b845d92f4..2875ddf37289 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1822,15 +1822,37 @@ static int mxt_read_t100_config(struct mxt_data *data)
1822static int mxt_input_open(struct input_dev *dev); 1822static int mxt_input_open(struct input_dev *dev);
1823static void mxt_input_close(struct input_dev *dev); 1823static void mxt_input_close(struct input_dev *dev);
1824 1824
1825static void mxt_set_up_as_touchpad(struct input_dev *input_dev,
1826 struct mxt_data *data)
1827{
1828 const struct mxt_platform_data *pdata = data->pdata;
1829 int i;
1830
1831 input_dev->name = "Atmel maXTouch Touchpad";
1832
1833 __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
1834
1835 input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM);
1836 input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM);
1837 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
1838 MXT_PIXELS_PER_MM);
1839 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
1840 MXT_PIXELS_PER_MM);
1841
1842 for (i = 0; i < pdata->t19_num_keys; i++)
1843 if (pdata->t19_keymap[i] != KEY_RESERVED)
1844 input_set_capability(input_dev, EV_KEY,
1845 pdata->t19_keymap[i]);
1846}
1847
1825static int mxt_initialize_input_device(struct mxt_data *data) 1848static int mxt_initialize_input_device(struct mxt_data *data)
1826{ 1849{
1827 struct device *dev = &data->client->dev;
1828 const struct mxt_platform_data *pdata = data->pdata; 1850 const struct mxt_platform_data *pdata = data->pdata;
1851 struct device *dev = &data->client->dev;
1829 struct input_dev *input_dev; 1852 struct input_dev *input_dev;
1830 int error; 1853 int error;
1831 unsigned int num_mt_slots; 1854 unsigned int num_mt_slots;
1832 unsigned int mt_flags = 0; 1855 unsigned int mt_flags = 0;
1833 int i;
1834 1856
1835 switch (data->multitouch) { 1857 switch (data->multitouch) {
1836 case MXT_TOUCH_MULTI_T9: 1858 case MXT_TOUCH_MULTI_T9:
@@ -1867,26 +1889,6 @@ static int mxt_initialize_input_device(struct mxt_data *data)
1867 1889
1868 input_set_capability(input_dev, EV_KEY, BTN_TOUCH); 1890 input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
1869 1891
1870 if (pdata->t19_num_keys) {
1871 __set_bit(INPUT_PROP_BUTTONPAD, input_dev->propbit);
1872
1873 for (i = 0; i < pdata->t19_num_keys; i++)
1874 if (pdata->t19_keymap[i] != KEY_RESERVED)
1875 input_set_capability(input_dev, EV_KEY,
1876 pdata->t19_keymap[i]);
1877
1878 mt_flags |= INPUT_MT_POINTER;
1879
1880 input_abs_set_res(input_dev, ABS_X, MXT_PIXELS_PER_MM);
1881 input_abs_set_res(input_dev, ABS_Y, MXT_PIXELS_PER_MM);
1882 input_abs_set_res(input_dev, ABS_MT_POSITION_X,
1883 MXT_PIXELS_PER_MM);
1884 input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
1885 MXT_PIXELS_PER_MM);
1886
1887 input_dev->name = "Atmel maXTouch Touchpad";
1888 }
1889
1890 /* For single touch */ 1892 /* For single touch */
1891 input_set_abs_params(input_dev, ABS_X, 0, data->max_x, 0, 0); 1893 input_set_abs_params(input_dev, ABS_X, 0, data->max_x, 0, 0);
1892 input_set_abs_params(input_dev, ABS_Y, 0, data->max_y, 0, 0); 1894 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 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0); 1899 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0);
1898 } 1900 }
1899 1901
1902 /* If device has buttons we assume it is a touchpad */
1903 if (pdata->t19_num_keys) {
1904 mxt_set_up_as_touchpad(input_dev, data);
1905 mt_flags |= INPUT_MT_POINTER;
1906 }
1907
1900 /* For multi touch */ 1908 /* For multi touch */
1901 error = input_mt_init_slots(input_dev, num_mt_slots, mt_flags); 1909 error = input_mt_init_slots(input_dev, num_mt_slots, mt_flags);
1902 if (error) { 1910 if (error) {