Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Hans de Goede and committed by
Dmitry Torokhov
f3f33c67 9634c152

+50
+48
drivers/input/mouse/alps.c
··· 1792 1792 return -1; 1793 1793 } 1794 1794 1795 + static int alps_get_v3_v7_resolution(struct psmouse *psmouse, int reg_pitch) 1796 + { 1797 + int reg, x_pitch, y_pitch, x_electrode, y_electrode, x_phys, y_phys; 1798 + struct alps_data *priv = psmouse->private; 1799 + 1800 + reg = alps_command_mode_read_reg(psmouse, reg_pitch); 1801 + if (reg < 0) 1802 + return reg; 1803 + 1804 + x_pitch = (char)(reg << 4) >> 4; /* sign extend lower 4 bits */ 1805 + x_pitch = 50 + 2 * x_pitch; /* In 0.1 mm units */ 1806 + 1807 + y_pitch = (char)reg >> 4; /* sign extend upper 4 bits */ 1808 + y_pitch = 36 + 2 * y_pitch; /* In 0.1 mm units */ 1809 + 1810 + reg = alps_command_mode_read_reg(psmouse, reg_pitch + 1); 1811 + if (reg < 0) 1812 + return reg; 1813 + 1814 + x_electrode = (char)(reg << 4) >> 4; /* sign extend lower 4 bits */ 1815 + x_electrode = 17 + x_electrode; 1816 + 1817 + y_electrode = (char)reg >> 4; /* sign extend upper 4 bits */ 1818 + y_electrode = 13 + y_electrode; 1819 + 1820 + x_phys = x_pitch * (x_electrode - 1); /* In 0.1 mm units */ 1821 + y_phys = y_pitch * (y_electrode - 1); /* In 0.1 mm units */ 1822 + 1823 + priv->x_res = priv->x_max * 10 / x_phys; /* units / mm */ 1824 + priv->y_res = priv->y_max * 10 / y_phys; /* units / mm */ 1825 + 1826 + psmouse_dbg(psmouse, 1827 + "pitch %dx%d num-electrodes %dx%d physical size %dx%d mm res %dx%d\n", 1828 + x_pitch, y_pitch, x_electrode, y_electrode, 1829 + x_phys / 10, y_phys / 10, priv->x_res, priv->y_res); 1830 + 1831 + return 0; 1832 + } 1833 + 1795 1834 static int alps_hw_init_rushmore_v3(struct psmouse *psmouse) 1796 1835 { 1797 1836 struct alps_data *priv = psmouse->private; ··· 1849 1810 if (alps_enter_command_mode(psmouse) || 1850 1811 alps_command_mode_read_reg(psmouse, 0xc2d9) == -1 || 1851 1812 alps_command_mode_write_reg(psmouse, 0xc2cb, 0x00)) 1813 + goto error; 1814 + 1815 + if (alps_get_v3_v7_resolution(psmouse, 0xc2da)) 1852 1816 goto error; 1853 1817 1854 1818 reg_val = alps_command_mode_read_reg(psmouse, 0xc2c6); ··· 2037 1995 2038 1996 if (alps_enter_command_mode(psmouse) || 2039 1997 alps_command_mode_read_reg(psmouse, 0xc2d9) == -1) 1998 + goto error; 1999 + 2000 + if (alps_get_v3_v7_resolution(psmouse, 0xc397)) 2040 2001 goto error; 2041 2002 2042 2003 if (alps_command_mode_write_reg(psmouse, 0xc2c9, 0x64)) ··· 2274 2229 { 2275 2230 input_set_abs_params(dev1, ABS_MT_POSITION_X, 0, priv->x_max, 0, 0); 2276 2231 input_set_abs_params(dev1, ABS_MT_POSITION_Y, 0, priv->y_max, 0, 0); 2232 + 2233 + input_abs_set_res(dev1, ABS_MT_POSITION_X, priv->x_res); 2234 + input_abs_set_res(dev1, ABS_MT_POSITION_Y, priv->y_res); 2277 2235 2278 2236 input_mt_init_slots(dev1, MAX_TOUCHES, INPUT_MT_POINTER | 2279 2237 INPUT_MT_DROP_UNUSED | INPUT_MT_TRACK | INPUT_MT_SEMI_MT);
+2
drivers/input/mouse/alps.h
··· 174 174 int y_max; 175 175 int x_bits; 176 176 int y_bits; 177 + unsigned int x_res; 178 + unsigned int y_res; 177 179 178 180 int (*hw_init)(struct psmouse *psmouse); 179 181 void (*process_packet)(struct psmouse *psmouse);