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

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (64 commits)
Input: tc3589x-keypad - add missing kerneldoc
Input: ucb1400-ts - switch to using dev_xxx() for diagnostic messages
Input: ucb1400_ts - convert to threaded IRQ
Input: ucb1400_ts - drop inline annotations
Input: usb1400_ts - add __devinit/__devexit section annotations
Input: ucb1400_ts - set driver owner
Input: ucb1400_ts - convert to use dev_pm_ops
Input: psmouse - make sure we do not use stale methods
Input: evdev - do not block waiting for an event if fd is nonblock
Input: evdev - if no events and non-block, return EAGAIN not 0
Input: evdev - only allow reading events if a full packet is present
Input: add driver for pixcir i2c touchscreens
Input: samsung-keypad - implement runtime power management support
Input: tegra-kbc - report wakeup key for some platforms
Input: tegra-kbc - add device tree bindings
Input: add driver for AUO In-Cell touchscreens using pixcir ICs
Input: mpu3050 - configure the sampling method
Input: mpu3050 - ensure we enable interrupts
Input: mpu3050 - add of_match table for device-tree probing
Input: sentelic - document the latest hardware
...

Fix up fairly trivial conflicts (device tree matching conflicting with
some independent cleanups) in drivers/input/keyboard/samsung-keypad.c

+5550 -1645
+9 -8
Documentation/ABI/testing/sysfs-driver-wacom
··· 15 15 Description: 16 16 Attribute group for control of the status LEDs and the OLEDs. 17 17 This attribute group is only available for Intuos 4 M, L, 18 - and XL (with LEDs and OLEDs) and Cintiq 21UX2 (LEDs only). 19 - Therefore its presence implicitly signifies the presence of 20 - said LEDs and OLEDs on the tablet device. 18 + and XL (with LEDs and OLEDs) and Cintiq 21UX2 and Cintiq 24HD 19 + (LEDs only). Therefore its presence implicitly signifies the 20 + presence of said LEDs and OLEDs on the tablet device. 21 21 22 22 What: /sys/bus/usb/devices/<busnum>-<devnum>:<cfg>.<intf>/wacom_led/status0_luminance 23 23 Date: August 2011 ··· 41 41 Contact: linux-input@vger.kernel.org 42 42 Description: 43 43 Writing to this file sets which one of the four (for Intuos 4) 44 - or of the right four (for Cintiq 21UX2) status LEDs is active (0..3). 45 - The other three LEDs on the same side are always inactive. 44 + or of the right four (for Cintiq 21UX2 and Cintiq 24HD) status 45 + LEDs is active (0..3). The other three LEDs on the same side are 46 + always inactive. 46 47 47 48 What: /sys/bus/usb/devices/<busnum>-<devnum>:<cfg>.<intf>/wacom_led/status_led1_select 48 49 Date: September 2011 49 50 Contact: linux-input@vger.kernel.org 50 51 Description: 51 - Writing to this file sets which one of the left four (for Cintiq 21UX2) 52 - status LEDs is active (0..3). The other three LEDs on the left are always 53 - inactive. 52 + Writing to this file sets which one of the left four (for Cintiq 21UX2 53 + and Cintiq 24HD) status LEDs is active (0..3). The other three LEDs on 54 + the left are always inactive. 54 55 55 56 What: /sys/bus/usb/devices/<busnum>-<devnum>:<cfg>.<intf>/wacom_led/buttons_luminance 56 57 Date: August 2011
+18
Documentation/devicetree/bindings/input/tegra-kbc.txt
··· 1 + * Tegra keyboard controller 2 + 3 + Required properties: 4 + - compatible: "nvidia,tegra20-kbc" 5 + 6 + Optional properties: 7 + - debounce-delay: delay in milliseconds per row scan for debouncing 8 + - repeat-delay: delay in milliseconds before repeat starts 9 + - ghost-filter: enable ghost filtering for this device 10 + - wakeup-source: configure keyboard as a wakeup source for suspend/resume 11 + 12 + Example: 13 + 14 + keyboard: keyboard { 15 + compatible = "nvidia,tegra20-kbc"; 16 + reg = <0x7000e200 0x100>; 17 + ghost-filter; 18 + };
+188
Documentation/input/alps.txt
··· 1 + ALPS Touchpad Protocol 2 + ---------------------- 3 + 4 + Introduction 5 + ------------ 6 + 7 + Currently the ALPS touchpad driver supports four protocol versions in use by 8 + ALPS touchpads, called versions 1, 2, 3, and 4. Information about the various 9 + protocol versions is contained in the following sections. 10 + 11 + Detection 12 + --------- 13 + 14 + All ALPS touchpads should respond to the "E6 report" command sequence: 15 + E8-E6-E6-E6-E9. An ALPS touchpad should respond with either 00-00-0A or 16 + 00-00-64. 17 + 18 + If the E6 report is successful, the touchpad model is identified using the "E7 19 + report" sequence: E8-E7-E7-E7-E9. The response is the model signature and is 20 + matched against known models in the alps_model_data_array. 21 + 22 + With protocol versions 3 and 4, the E7 report model signature is always 23 + 73-02-64. To differentiate between these versions, the response from the 24 + "Enter Command Mode" sequence must be inspected as described below. 25 + 26 + Command Mode 27 + ------------ 28 + 29 + Protocol versions 3 and 4 have a command mode that is used to read and write 30 + one-byte device registers in a 16-bit address space. The command sequence 31 + EC-EC-EC-E9 places the device in command mode, and the device will respond 32 + with 88-07 followed by a third byte. This third byte can be used to determine 33 + whether the devices uses the version 3 or 4 protocol. 34 + 35 + To exit command mode, PSMOUSE_CMD_SETSTREAM (EA) is sent to the touchpad. 36 + 37 + While in command mode, register addresses can be set by first sending a 38 + specific command, either EC for v3 devices or F5 for v4 devices. Then the 39 + address is sent one nibble at a time, where each nibble is encoded as a 40 + command with optional data. This enoding differs slightly between the v3 and 41 + v4 protocols. 42 + 43 + Once an address has been set, the addressed register can be read by sending 44 + PSMOUSE_CMD_GETINFO (E9). The first two bytes of the response contains the 45 + address of the register being read, and the third contains the value of the 46 + register. Registers are written by writing the value one nibble at a time 47 + using the same encoding used for addresses. 48 + 49 + Packet Format 50 + ------------- 51 + 52 + In the following tables, the following notation is used. 53 + 54 + CAPITALS = stick, miniscules = touchpad 55 + 56 + ?'s can have different meanings on different models, such as wheel rotation, 57 + extra buttons, stick buttons on a dualpoint, etc. 58 + 59 + PS/2 packet format 60 + ------------------ 61 + 62 + byte 0: 0 0 YSGN XSGN 1 M R L 63 + byte 1: X7 X6 X5 X4 X3 X2 X1 X0 64 + byte 2: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 65 + 66 + Note that the device never signals overflow condition. 67 + 68 + ALPS Absolute Mode - Protocol Verion 1 69 + -------------------------------------- 70 + 71 + byte 0: 1 0 0 0 1 x9 x8 x7 72 + byte 1: 0 x6 x5 x4 x3 x2 x1 x0 73 + byte 2: 0 ? ? l r ? fin ges 74 + byte 3: 0 ? ? ? ? y9 y8 y7 75 + byte 4: 0 y6 y5 y4 y3 y2 y1 y0 76 + byte 5: 0 z6 z5 z4 z3 z2 z1 z0 77 + 78 + ALPS Absolute Mode - Protocol Version 2 79 + --------------------------------------- 80 + 81 + byte 0: 1 ? ? ? 1 ? ? ? 82 + byte 1: 0 x6 x5 x4 x3 x2 x1 x0 83 + byte 2: 0 x10 x9 x8 x7 ? fin ges 84 + byte 3: 0 y9 y8 y7 1 M R L 85 + byte 4: 0 y6 y5 y4 y3 y2 y1 y0 86 + byte 5: 0 z6 z5 z4 z3 z2 z1 z0 87 + 88 + Dualpoint device -- interleaved packet format 89 + --------------------------------------------- 90 + 91 + byte 0: 1 1 0 0 1 1 1 1 92 + byte 1: 0 x6 x5 x4 x3 x2 x1 x0 93 + byte 2: 0 x10 x9 x8 x7 0 fin ges 94 + byte 3: 0 0 YSGN XSGN 1 1 1 1 95 + byte 4: X7 X6 X5 X4 X3 X2 X1 X0 96 + byte 5: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 97 + byte 6: 0 y9 y8 y7 1 m r l 98 + byte 7: 0 y6 y5 y4 y3 y2 y1 y0 99 + byte 8: 0 z6 z5 z4 z3 z2 z1 z0 100 + 101 + ALPS Absolute Mode - Protocol Version 3 102 + --------------------------------------- 103 + 104 + ALPS protocol version 3 has three different packet formats. The first two are 105 + associated with touchpad events, and the third is associatd with trackstick 106 + events. 107 + 108 + The first type is the touchpad position packet. 109 + 110 + byte 0: 1 ? x1 x0 1 1 1 1 111 + byte 1: 0 x10 x9 x8 x7 x6 x5 x4 112 + byte 2: 0 y10 y9 y8 y7 y6 y5 y4 113 + byte 3: 0 M R L 1 m r l 114 + byte 4: 0 mt x3 x2 y3 y2 y1 y0 115 + byte 5: 0 z6 z5 z4 z3 z2 z1 z0 116 + 117 + Note that for some devices the trackstick buttons are reported in this packet, 118 + and on others it is reported in the trackstick packets. 119 + 120 + The second packet type contains bitmaps representing the x and y axes. In the 121 + bitmaps a given bit is set if there is a finger covering that position on the 122 + given axis. Thus the bitmap packet can be used for low-resolution multi-touch 123 + data, although finger tracking is not possible. This packet also encodes the 124 + number of contacts (f1 and f0 in the table below). 125 + 126 + byte 0: 1 1 x1 x0 1 1 1 1 127 + byte 1: 0 x8 x7 x6 x5 x4 x3 x2 128 + byte 2: 0 y7 y6 y5 y4 y3 y2 y1 129 + byte 3: 0 y10 y9 y8 1 1 1 1 130 + byte 4: 0 x14 x13 x12 x11 x10 x9 y0 131 + byte 5: 0 1 ? ? ? ? f1 f0 132 + 133 + This packet only appears after a position packet with the mt bit set, and 134 + ususally only appears when there are two or more contacts (although 135 + ocassionally it's seen with only a single contact). 136 + 137 + The final v3 packet type is the trackstick packet. 138 + 139 + byte 0: 1 1 x7 y7 1 1 1 1 140 + byte 1: 0 x6 x5 x4 x3 x2 x1 x0 141 + byte 2: 0 y6 y5 y4 y3 y2 y1 y0 142 + byte 3: 0 1 0 0 1 0 0 0 143 + byte 4: 0 z4 z3 z2 z1 z0 ? ? 144 + byte 5: 0 0 1 1 1 1 1 1 145 + 146 + ALPS Absolute Mode - Protocol Version 4 147 + --------------------------------------- 148 + 149 + Protocol version 4 has an 8-byte packet format. 150 + 151 + byte 0: 1 ? x1 x0 1 1 1 1 152 + byte 1: 0 x10 x9 x8 x7 x6 x5 x4 153 + byte 2: 0 y10 y9 y8 y7 y6 y5 y4 154 + byte 3: 0 1 x3 x2 y3 y2 y1 y0 155 + byte 4: 0 ? ? ? 1 ? r l 156 + byte 5: 0 z6 z5 z4 z3 z2 z1 z0 157 + byte 6: bitmap data (described below) 158 + byte 7: bitmap data (described below) 159 + 160 + The last two bytes represent a partial bitmap packet, with 3 full packets 161 + required to construct a complete bitmap packet. Once assembled, the 6-byte 162 + bitmap packet has the following format: 163 + 164 + byte 0: 0 1 x7 x6 x5 x4 x3 x2 165 + byte 1: 0 x1 x0 y4 y3 y2 y1 y0 166 + byte 2: 0 0 ? x14 x13 x12 x11 x10 167 + byte 3: 0 x9 x8 y9 y8 y7 y6 y5 168 + byte 4: 0 0 0 0 0 0 0 0 169 + byte 5: 0 0 0 0 0 0 0 y10 170 + 171 + There are several things worth noting here. 172 + 173 + 1) In the bitmap data, bit 6 of byte 0 serves as a sync byte to 174 + identify the first fragment of a bitmap packet. 175 + 176 + 2) The bitmaps represent the same data as in the v3 bitmap packets, although 177 + the packet layout is different. 178 + 179 + 3) There doesn't seem to be a count of the contact points anywhere in the v4 180 + protocol packets. Deriving a count of contact points must be done by 181 + analyzing the bitmaps. 182 + 183 + 4) There is a 3 to 1 ratio of position packets to bitmap packets. Therefore 184 + MT position can only be updated for every third ST position update, and 185 + the count of contact points can only be updated every third packet as 186 + well. 187 + 188 + So far no v4 devices with tracksticks have been encountered.
+103
Documentation/input/gpio-tilt.txt
··· 1 + Driver for tilt-switches connected via GPIOs 2 + ============================================ 3 + 4 + Generic driver to read data from tilt switches connected via gpios. 5 + Orientation can be provided by one or more than one tilt switches, 6 + i.e. each tilt switch providing one axis, and the number of axes 7 + is also not limited. 8 + 9 + 10 + Data structures: 11 + ---------------- 12 + 13 + The array of struct gpio in the gpios field is used to list the gpios 14 + that represent the current tilt state. 15 + 16 + The array of struct gpio_tilt_axis describes the axes that are reported 17 + to the input system. The values set therein are used for the 18 + input_set_abs_params calls needed to init the axes. 19 + 20 + The array of struct gpio_tilt_state maps gpio states to the corresponding 21 + values to report. The gpio state is represented as a bitfield where the 22 + bit-index corresponds to the index of the gpio in the struct gpio array. 23 + In the same manner the values stored in the axes array correspond to 24 + the elements of the gpio_tilt_axis-array. 25 + 26 + 27 + Example: 28 + -------- 29 + 30 + Example configuration for a single TS1003 tilt switch that rotates around 31 + one axis in 4 steps and emitts the current tilt via two GPIOs. 32 + 33 + static int sg060_tilt_enable(struct device *dev) { 34 + /* code to enable the sensors */ 35 + }; 36 + 37 + static void sg060_tilt_disable(struct device *dev) { 38 + /* code to disable the sensors */ 39 + }; 40 + 41 + static struct gpio sg060_tilt_gpios[] = { 42 + { SG060_TILT_GPIO_SENSOR1, GPIOF_IN, "tilt_sensor1" }, 43 + { SG060_TILT_GPIO_SENSOR2, GPIOF_IN, "tilt_sensor2" }, 44 + }; 45 + 46 + static struct gpio_tilt_state sg060_tilt_states[] = { 47 + { 48 + .gpios = (0 << 1) | (0 << 0), 49 + .axes = (int[]) { 50 + 0, 51 + }, 52 + }, { 53 + .gpios = (0 << 1) | (1 << 0), 54 + .axes = (int[]) { 55 + 1, /* 90 degrees */ 56 + }, 57 + }, { 58 + .gpios = (1 << 1) | (1 << 0), 59 + .axes = (int[]) { 60 + 2, /* 180 degrees */ 61 + }, 62 + }, { 63 + .gpios = (1 << 1) | (0 << 0), 64 + .axes = (int[]) { 65 + 3, /* 270 degrees */ 66 + }, 67 + }, 68 + }; 69 + 70 + static struct gpio_tilt_axis sg060_tilt_axes[] = { 71 + { 72 + .axis = ABS_RY, 73 + .min = 0, 74 + .max = 3, 75 + .fuzz = 0, 76 + .flat = 0, 77 + }, 78 + }; 79 + 80 + static struct gpio_tilt_platform_data sg060_tilt_pdata= { 81 + .gpios = sg060_tilt_gpios, 82 + .nr_gpios = ARRAY_SIZE(sg060_tilt_gpios), 83 + 84 + .axes = sg060_tilt_axes, 85 + .nr_axes = ARRAY_SIZE(sg060_tilt_axes), 86 + 87 + .states = sg060_tilt_states, 88 + .nr_states = ARRAY_SIZE(sg060_tilt_states), 89 + 90 + .debounce_interval = 100, 91 + 92 + .poll_interval = 1000, 93 + .enable = sg060_tilt_enable, 94 + .disable = sg060_tilt_disable, 95 + }; 96 + 97 + static struct platform_device sg060_device_tilt = { 98 + .name = "gpio-tilt-polled", 99 + .id = -1, 100 + .dev = { 101 + .platform_data = &sg060_tilt_pdata, 102 + }, 103 + };
+333 -31
Documentation/input/sentelic.txt
··· 1 - Copyright (C) 2002-2010 Sentelic Corporation. 2 - Last update: Jan-13-2010 1 + Copyright (C) 2002-2011 Sentelic Corporation. 2 + Last update: Dec-07-2011 3 3 4 4 ============================================================================== 5 5 * Finger Sensing Pad Intellimouse Mode(scrolling wheel, 4th and 5th buttons) ··· 140 140 Byte 1: Bit7~Bit6 => 00, Normal data packet 141 141 => 01, Absolute coordination packet 142 142 => 10, Notify packet 143 + => 11, Normal data packet with on-pad click 143 144 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up. 144 145 When both fingers are up, the last two reports have zero valid 145 146 bit. ··· 165 164 Byte 1: Bit7~Bit6 => 00, Normal data packet 166 165 => 01, Absolute coordinates packet 167 166 => 10, Notify packet 167 + => 11, Normal data packet with on-pad click 168 168 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up. 169 169 When both fingers are up, the last two reports have zero valid 170 170 bit. ··· 190 188 Byte 1: Bit7~Bit6 => 00, Normal data packet 191 189 => 01, Absolute coordinates packet 192 190 => 10, Notify packet 191 + => 11, Normal data packet with on-pad click 193 192 Bit5 => 1 194 193 Bit4 => when in absolute coordinates mode (valid when EN_PKT_GO is 1): 195 194 0: left button is generated by the on-pad command ··· 208 205 Bit6 => scroll left button 209 206 Bit5 => scroll down button 210 207 Bit4 => scroll up button 211 - * Note that if gesture and additional buttoni (Bit4~Bit7) 208 + * Note that if gesture and additional button (Bit4~Bit7) 212 209 happen at the same time, the button information will not 213 210 be sent. 214 211 Bit3~Bit0 => Reserved ··· 230 227 Byte 1: Bit7~Bit6 => 00, Normal data packet 231 228 => 01, Absolute coordinates packet 232 229 => 10, Notify packet 230 + => 11, Normal data packet with on-pad click 233 231 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up. 234 232 When both fingers are up, the last two reports have zero valid 235 233 bit. ··· 257 253 Byte 1: Bit7~Bit6 => 00, Normal data packet 258 254 => 01, Absolute coordination packet 259 255 => 10, Notify packet 256 + => 11, Normal data packet with on-pad click 260 257 Bit5 => Valid bit, 0 means that the coordinate is invalid or finger up. 261 258 When both fingers are up, the last two reports have zero valid 262 259 bit. ··· 284 279 Byte 1: Bit7~Bit6 => 00, Normal data packet 285 280 => 01, Absolute coordination packet 286 281 => 10, Notify packet 282 + => 11, Normal data packet with on-pad click 287 283 Bit5 => 1 288 - Bit4 => when in absolute coordinate mode (valid when EN_PKT_GO is 1): 284 + Bit4 => when in absolute coordinates mode (valid when EN_PKT_GO is 1): 289 285 0: left button is generated by the on-pad command 290 286 1: left button is generated by the external button 291 287 Bit3 => 1 ··· 311 305 312 306 notify packet (valid bit == 1), abs pkt 1, abs pkt 2, abs pkt 1, 313 307 abs pkt 2, ..., notify packet (valid bit == 0) 308 + 309 + ============================================================================== 310 + * Absolute position for STL3888-Cx and STL3888-Dx. 311 + ============================================================================== 312 + Single Finger, Absolute Coordinate Mode (SFAC) 313 + Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 314 + BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------| 315 + 1 |0|1|0|P|1|M|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|B|F|X|X|Y|Y| 316 + |---------------| |---------------| |---------------| |---------------| 317 + 318 + Byte 1: Bit7~Bit6 => 00, Normal data packet 319 + => 01, Absolute coordinates packet 320 + => 10, Notify packet 321 + Bit5 => Coordinate mode(always 0 in SFAC mode): 322 + 0: single-finger absolute coordinates (SFAC) mode 323 + 1: multi-finger, multiple coordinates (MFMC) mode 324 + Bit4 => 0: The LEFT button is generated by on-pad command (OPC) 325 + 1: The LEFT button is generated by external button 326 + Default is 1 even if the LEFT button is not pressed. 327 + Bit3 => Always 1, as specified by PS/2 protocol. 328 + Bit2 => Middle Button, 1 is pressed, 0 is not pressed. 329 + Bit1 => Right Button, 1 is pressed, 0 is not pressed. 330 + Bit0 => Left Button, 1 is pressed, 0 is not pressed. 331 + Byte 2: X coordinate (xpos[9:2]) 332 + Byte 3: Y coordinate (ypos[9:2]) 333 + Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0]) 334 + Bit3~Bit2 => X coordinate (ypos[1:0]) 335 + Bit4 => 4th mouse button(forward one page) 336 + Bit5 => 5th mouse button(backward one page) 337 + Bit6 => scroll left button 338 + Bit7 => scroll right button 339 + 340 + Multi Finger, Multiple Coordinates Mode (MFMC): 341 + Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 342 + BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------| 343 + 1 |0|1|1|P|1|F|R|L| 2 |X|X|X|X|X|X|X|X| 3 |Y|Y|Y|Y|Y|Y|Y|Y| 4 |r|l|B|F|X|X|Y|Y| 344 + |---------------| |---------------| |---------------| |---------------| 345 + 346 + Byte 1: Bit7~Bit6 => 00, Normal data packet 347 + => 01, Absolute coordination packet 348 + => 10, Notify packet 349 + Bit5 => Coordinate mode (always 1 in MFMC mode): 350 + 0: single-finger absolute coordinates (SFAC) mode 351 + 1: multi-finger, multiple coordinates (MFMC) mode 352 + Bit4 => 0: The LEFT button is generated by on-pad command (OPC) 353 + 1: The LEFT button is generated by external button 354 + Default is 1 even if the LEFT button is not pressed. 355 + Bit3 => Always 1, as specified by PS/2 protocol. 356 + Bit2 => Finger index, 0 is the first finger, 1 is the second finger. 357 + If bit 1 and 0 are all 1 and bit 4 is 0, the middle external 358 + button is pressed. 359 + Bit1 => Right Button, 1 is pressed, 0 is not pressed. 360 + Bit0 => Left Button, 1 is pressed, 0 is not pressed. 361 + Byte 2: X coordinate (xpos[9:2]) 362 + Byte 3: Y coordinate (ypos[9:2]) 363 + Byte 4: Bit1~Bit0 => Y coordinate (xpos[1:0]) 364 + Bit3~Bit2 => X coordinate (ypos[1:0]) 365 + Bit4 => 4th mouse button(forward one page) 366 + Bit5 => 5th mouse button(backward one page) 367 + Bit6 => scroll left button 368 + Bit7 => scroll right button 369 + 370 + When one of the two fingers is up, the device will output four consecutive 371 + MFMC#0 report packets with zero X and Y to represent 1st finger is up or 372 + four consecutive MFMC#1 report packets with zero X and Y to represent that 373 + the 2nd finger is up. On the other hand, if both fingers are up, the device 374 + will output four consecutive single-finger, absolute coordinate(SFAC) packets 375 + with zero X and Y. 376 + 377 + Notify Packet for STL3888-Cx/Dx 378 + Bit 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 379 + BYTE |---------------|BYTE |---------------|BYTE|---------------|BYTE|---------------| 380 + 1 |1|0|0|P|1|M|R|L| 2 |C|C|C|C|C|C|C|C| 3 |0|0|F|F|0|0|0|i| 4 |r|l|u|d|0|0|0|0| 381 + |---------------| |---------------| |---------------| |---------------| 382 + 383 + Byte 1: Bit7~Bit6 => 00, Normal data packet 384 + => 01, Absolute coordinates packet 385 + => 10, Notify packet 386 + Bit5 => Always 0 387 + Bit4 => 0: The LEFT button is generated by on-pad command(OPC) 388 + 1: The LEFT button is generated by external button 389 + Default is 1 even if the LEFT button is not pressed. 390 + Bit3 => 1 391 + Bit2 => Middle Button, 1 is pressed, 0 is not pressed. 392 + Bit1 => Right Button, 1 is pressed, 0 is not pressed. 393 + Bit0 => Left Button, 1 is pressed, 0 is not pressed. 394 + Byte 2: Message type: 395 + 0xba => gesture information 396 + 0xc0 => one finger hold-rotating gesture 397 + Byte 3: The first parameter for the received message: 398 + 0xba => gesture ID (refer to the 'Gesture ID' section) 399 + 0xc0 => region ID 400 + Byte 4: The second parameter for the received message: 401 + 0xba => N/A 402 + 0xc0 => finger up/down information 403 + 404 + Sample sequence of Multi-finger, Multi-coordinates mode: 405 + 406 + notify packet (valid bit == 1), MFMC packet 1 (byte 1, bit 2 == 0), 407 + MFMC packet 2 (byte 1, bit 2 == 1), MFMC packet 1, MFMC packet 2, 408 + ..., notify packet (valid bit == 0) 409 + 410 + That is, when the device is in MFMC mode, the host will receive 411 + interleaved absolute coordinate packets for each finger. 314 412 315 413 ============================================================================== 316 414 * FSP Enable/Disable packet ··· 458 348 ============================================================================== 459 349 1. Identify FSP by reading device ID(0x00) and version(0x01) register 460 350 461 - 2. Determine number of buttons by reading status2 (0x0b) register 351 + 2a. For FSP version < STL3888 Cx, determine number of buttons by reading 352 + the 'test mode status' (0x20) register: 462 353 463 - buttons = reg[0x0b] & 0x30 354 + buttons = reg[0x20] & 0x30 464 355 465 356 if buttons == 0x30 or buttons == 0x20: 466 357 # two/four buttons ··· 476 365 Refer to 'Finger Sensing Pad PS/2 Mouse Intellimouse' 477 366 section A for packet parsing detail 478 367 368 + 2b. For FSP version >= STL3888 Cx: 369 + Refer to 'Finger Sensing Pad PS/2 Mouse Intellimouse' 370 + section A for packet parsing detail (ignore byte 4, bit ~ 7) 371 + 479 372 ============================================================================== 480 373 * Programming Sequence for Register Reading/Writing 481 374 ============================================================================== ··· 489 374 Following values needed to be inverted(the '~' operator in C) before being 490 375 sent to FSP: 491 376 492 - 0xe9, 0xee, 0xf2 and 0xff. 377 + 0xe8, 0xe9, 0xee, 0xf2, 0xf3 and 0xff. 493 378 494 379 Register swapping requirement: 495 380 ··· 530 415 531 416 8. send 0xe9(status request) PS/2 command to FSP; 532 417 533 - 9. the response read from FSP should be the requested register value. 418 + 9. the 4th byte of the response read from FSP should be the 419 + requested register value(?? indicates don't care byte): 420 + 421 + host: 0xe9 422 + 3888: 0xfa (??) (??) (val) 423 + 424 + * Note that since the Cx release, the hardware will return 1's 425 + complement of the register value at the 3rd byte of status request 426 + result: 427 + 428 + host: 0xe9 429 + 3888: 0xfa (??) (~val) (val) 534 430 535 431 Register writing sequence: 536 432 ··· 591 465 592 466 9. the register writing sequence is completed. 593 467 468 + * Note that since the Cx release, the hardware will return 1's 469 + complement of the register value at the 3rd byte of status request 470 + result. Host can optionally send another 0xe9 (status request) PS/2 471 + command to FSP at the end of register writing to verify that the 472 + register writing operation is successful (?? indicates don't care 473 + byte): 474 + 475 + host: 0xe9 476 + 3888: 0xfa (??) (~val) (val) 477 + 478 + ============================================================================== 479 + * Programming Sequence for Page Register Reading/Writing 480 + ============================================================================== 481 + 482 + In order to overcome the limitation of maximum number of registers 483 + supported, the hardware separates register into different groups called 484 + 'pages.' Each page is able to include up to 255 registers. 485 + 486 + The default page after power up is 0x82; therefore, if one has to get 487 + access to register 0x8301, one has to use following sequence to switch 488 + to page 0x83, then start reading/writing from/to offset 0x01 by using 489 + the register read/write sequence described in previous section. 490 + 491 + Page register reading sequence: 492 + 493 + 1. send 0xf3 PS/2 command to FSP; 494 + 495 + 2. send 0x66 PS/2 command to FSP; 496 + 497 + 3. send 0x88 PS/2 command to FSP; 498 + 499 + 4. send 0xf3 PS/2 command to FSP; 500 + 501 + 5. send 0x83 PS/2 command to FSP; 502 + 503 + 6. send 0x88 PS/2 command to FSP; 504 + 505 + 7. send 0xe9(status request) PS/2 command to FSP; 506 + 507 + 8. the response read from FSP should be the requested page value. 508 + 509 + Page register writing sequence: 510 + 511 + 1. send 0xf3 PS/2 command to FSP; 512 + 513 + 2. send 0x38 PS/2 command to FSP; 514 + 515 + 3. send 0x88 PS/2 command to FSP; 516 + 517 + 4. send 0xf3 PS/2 command to FSP; 518 + 519 + 5. if the page address being written is not required to be 520 + inverted(refer to the 'Register inversion requirement' section), 521 + goto step 6 522 + 523 + 5a. send 0x47 PS/2 command to FSP; 524 + 525 + 5b. send the inverted page address to FSP and goto step 9; 526 + 527 + 6. if the page address being written is not required to be 528 + swapped(refer to the 'Register swapping requirement' section), 529 + goto step 7 530 + 531 + 6a. send 0x44 PS/2 command to FSP; 532 + 533 + 6b. send the swapped page address to FSP and goto step 9; 534 + 535 + 7. send 0x33 PS/2 command to FSP; 536 + 537 + 8. send the page address to FSP; 538 + 539 + 9. the page register writing sequence is completed. 540 + 541 + ============================================================================== 542 + * Gesture ID 543 + ============================================================================== 544 + 545 + Unlike other devices which sends multiple fingers' coordinates to host, 546 + FSP processes multiple fingers' coordinates internally and convert them 547 + into a 8 bits integer, namely 'Gesture ID.' Following is a list of 548 + supported gesture IDs: 549 + 550 + ID Description 551 + 0x86 2 finger straight up 552 + 0x82 2 finger straight down 553 + 0x80 2 finger straight right 554 + 0x84 2 finger straight left 555 + 0x8f 2 finger zoom in 556 + 0x8b 2 finger zoom out 557 + 0xc0 2 finger curve, counter clockwise 558 + 0xc4 2 finger curve, clockwise 559 + 0x2e 3 finger straight up 560 + 0x2a 3 finger straight down 561 + 0x28 3 finger straight right 562 + 0x2c 3 finger straight left 563 + 0x38 palm 564 + 594 565 ============================================================================== 595 566 * Register Listing 596 567 ============================================================================== 597 568 569 + Registers are represented in 16 bits values. The higher 8 bits represent 570 + the page address and the lower 8 bits represent the relative offset within 571 + that particular page. Refer to the 'Programming Sequence for Page Register 572 + Reading/Writing' section for instructions on how to change current page 573 + address. 574 + 598 575 offset width default r/w name 599 - 0x00 bit7~bit0 0x01 RO device ID 576 + 0x8200 bit7~bit0 0x01 RO device ID 600 577 601 - 0x01 bit7~bit0 0xc0 RW version ID 578 + 0x8201 bit7~bit0 RW version ID 579 + 0xc1: STL3888 Ax 580 + 0xd0 ~ 0xd2: STL3888 Bx 581 + 0xe0 ~ 0xe1: STL3888 Cx 582 + 0xe2 ~ 0xe3: STL3888 Dx 602 583 603 - 0x02 bit7~bit0 0x01 RO vendor ID 584 + 0x8202 bit7~bit0 0x01 RO vendor ID 604 585 605 - 0x03 bit7~bit0 0x01 RO product ID 586 + 0x8203 bit7~bit0 0x01 RO product ID 606 587 607 - 0x04 bit3~bit0 0x01 RW revision ID 588 + 0x8204 bit3~bit0 0x01 RW revision ID 608 589 609 - 0x0b RO test mode status 1 610 - bit3 1 RO 0: rotate 180 degree, 1: no rotation 590 + 0x820b test mode status 1 591 + bit3 1 RO 0: rotate 180 degree 592 + 1: no rotation 593 + *only supported by H/W prior to Cx 611 594 612 - bit5~bit4 RO number of buttons 613 - 11 => 2, lbtn/rbtn 614 - 10 => 4, lbtn/rbtn/scru/scrd 615 - 01 => 6, lbtn/rbtn/scru/scrd/scrl/scrr 616 - 00 => 6, lbtn/rbtn/scru/scrd/fbtn/bbtn 595 + 0x820f register file page control 596 + bit2 0 RW 1: rotate 180 degree 597 + 0: no rotation 598 + *supported since Cx 617 599 618 - 0x0f RW register file page control 619 600 bit0 0 RW 1 to enable page 1 register files 601 + *only supported by H/W prior to Cx 620 602 621 - 0x10 RW system control 1 603 + 0x8210 RW system control 1 622 604 bit0 1 RW Reserved, must be 1 623 605 bit1 0 RW Reserved, must be 0 624 - bit4 1 RW Reserved, must be 0 625 - bit5 0 RW register clock gating enable 606 + bit4 0 RW Reserved, must be 0 607 + bit5 1 RW register clock gating enable 626 608 0: read only, 1: read/write enable 627 609 (Note that following registers does not require clock gating being 628 610 enabled prior to write: 05 06 07 08 09 0c 0f 10 11 12 16 17 18 23 2e 629 611 40 41 42 43. In addition to that, this bit must be 1 when gesture 630 612 mode is enabled) 631 613 632 - 0x31 RW on-pad command detection 614 + 0x8220 test mode status 615 + bit5~bit4 RO number of buttons 616 + 11 => 2, lbtn/rbtn 617 + 10 => 4, lbtn/rbtn/scru/scrd 618 + 01 => 6, lbtn/rbtn/scru/scrd/scrl/scrr 619 + 00 => 6, lbtn/rbtn/scru/scrd/fbtn/bbtn 620 + *only supported by H/W prior to Cx 621 + 622 + 0x8231 RW on-pad command detection 633 623 bit7 0 RW on-pad command left button down tag 634 624 enable 635 625 0: disable, 1: enable 626 + *only supported by H/W prior to Cx 636 627 637 - 0x34 RW on-pad command control 5 628 + 0x8234 RW on-pad command control 5 638 629 bit4~bit0 0x05 RW XLO in 0s/4/1, so 03h = 0010.1b = 2.5 639 630 (Note that position unit is in 0.5 scanline) 631 + *only supported by H/W prior to Cx 640 632 641 633 bit7 0 RW on-pad tap zone enable 642 634 0: disable, 1: enable 635 + *only supported by H/W prior to Cx 643 636 644 - 0x35 RW on-pad command control 6 637 + 0x8235 RW on-pad command control 6 645 638 bit4~bit0 0x1d RW XHI in 0s/4/1, so 19h = 1100.1b = 12.5 646 639 (Note that position unit is in 0.5 scanline) 640 + *only supported by H/W prior to Cx 647 641 648 - 0x36 RW on-pad command control 7 642 + 0x8236 RW on-pad command control 7 649 643 bit4~bit0 0x04 RW YLO in 0s/4/1, so 03h = 0010.1b = 2.5 650 644 (Note that position unit is in 0.5 scanline) 645 + *only supported by H/W prior to Cx 651 646 652 - 0x37 RW on-pad command control 8 647 + 0x8237 RW on-pad command control 8 653 648 bit4~bit0 0x13 RW YHI in 0s/4/1, so 11h = 1000.1b = 8.5 654 649 (Note that position unit is in 0.5 scanline) 650 + *only supported by H/W prior to Cx 655 651 656 - 0x40 RW system control 5 652 + 0x8240 RW system control 5 657 653 bit1 0 RW FSP Intellimouse mode enable 658 654 0: disable, 1: enable 655 + *only supported by H/W prior to Cx 659 656 660 657 bit2 0 RW movement + abs. coordinate mode enable 661 658 0: disable, 1: enable ··· 786 537 bit 1 is not set. However, the format is different from that of bit 1. 787 538 In addition, when bit 1 and bit 2 are set at the same time, bit 2 will 788 539 override bit 1.) 540 + *only supported by H/W prior to Cx 789 541 790 542 bit3 0 RW abs. coordinate only mode enable 791 543 0: disable, 1: enable ··· 794 544 bit 1 is not set. However, the format is different from that of bit 1. 795 545 In addition, when bit 1, bit 2 and bit 3 are set at the same time, 796 546 bit 3 will override bit 1 and 2.) 547 + *only supported by H/W prior to Cx 797 548 798 549 bit5 0 RW auto switch enable 799 550 0: disable, 1: enable 551 + *only supported by H/W prior to Cx 800 552 801 553 bit6 0 RW G0 abs. + notify packet format enable 802 554 0: disable, 1: enable ··· 806 554 bit 2 and 3. That is, if any of those bit is 1, host will receive 807 555 absolute coordinates; otherwise, host only receives packets with 808 556 relative coordinate.) 557 + *only supported by H/W prior to Cx 809 558 810 559 bit7 0 RW EN_PS2_F2: PS/2 gesture mode 2nd 811 560 finger packet enable 812 561 0: disable, 1: enable 562 + *only supported by H/W prior to Cx 813 563 814 - 0x43 RW on-pad control 564 + 0x8243 RW on-pad control 815 565 bit0 0 RW on-pad control enable 816 566 0: disable, 1: enable 817 567 (Note that if this bit is cleared, bit 3/5 will be ineffective) 568 + *only supported by H/W prior to Cx 818 569 819 570 bit3 0 RW on-pad fix vertical scrolling enable 820 571 0: disable, 1: enable 572 + *only supported by H/W prior to Cx 821 573 822 574 bit5 0 RW on-pad fix horizontal scrolling enable 823 575 0: disable, 1: enable 576 + *only supported by H/W prior to Cx 577 + 578 + 0x8290 RW software control register 1 579 + bit0 0 RW absolute coordination mode 580 + 0: disable, 1: enable 581 + *supported since Cx 582 + 583 + bit1 0 RW gesture ID output 584 + 0: disable, 1: enable 585 + *supported since Cx 586 + 587 + bit2 0 RW two fingers' coordinates output 588 + 0: disable, 1: enable 589 + *supported since Cx 590 + 591 + bit3 0 RW finger up one packet output 592 + 0: disable, 1: enable 593 + *supported since Cx 594 + 595 + bit4 0 RW absolute coordination continuous mode 596 + 0: disable, 1: enable 597 + *supported since Cx 598 + 599 + bit6~bit5 00 RW gesture group selection 600 + 00: basic 601 + 01: suite 602 + 10: suite pro 603 + 11: advanced 604 + *supported since Cx 605 + 606 + bit7 0 RW Bx packet output compatible mode 607 + 0: disable, 1: enable *supported since Cx 608 + *supported since Cx 609 + 610 + 611 + 0x833d RW on-pad command control 1 612 + bit7 1 RW on-pad command detection enable 613 + 0: disable, 1: enable 614 + *supported since Cx 615 + 616 + 0x833e RW on-pad command detection 617 + bit7 0 RW on-pad command left button down tag 618 + enable. Works only in H/W based PS/2 619 + data packet mode. 620 + 0: disable, 1: enable 621 + *supported since Cx
+1
arch/arm/mach-tegra/include/mach/kbc.h
··· 53 53 struct tegra_kbc_pin_cfg pin_cfg[KBC_MAX_GPIO]; 54 54 const struct matrix_keymap_data *keymap_data; 55 55 56 + u32 wakeup_key; 56 57 bool wakeup; 57 58 bool use_fn_map; 58 59 bool use_ghost_filter;
+1 -26
arch/arm/plat-samsung/include/plat/keypad.h
··· 13 13 #ifndef __PLAT_SAMSUNG_KEYPAD_H 14 14 #define __PLAT_SAMSUNG_KEYPAD_H 15 15 16 - #include <linux/input/matrix_keypad.h> 17 - 18 - #define SAMSUNG_MAX_ROWS 8 19 - #define SAMSUNG_MAX_COLS 8 20 - 21 - /** 22 - * struct samsung_keypad_platdata - Platform device data for Samsung Keypad. 23 - * @keymap_data: pointer to &matrix_keymap_data. 24 - * @rows: number of keypad row supported. 25 - * @cols: number of keypad col supported. 26 - * @no_autorepeat: disable key autorepeat. 27 - * @wakeup: controls whether the device should be set up as wakeup source. 28 - * @cfg_gpio: configure the GPIO. 29 - * 30 - * Initialisation data specific to either the machine or the platform 31 - * for the device driver to use or call-back when configuring gpio. 32 - */ 33 - struct samsung_keypad_platdata { 34 - const struct matrix_keymap_data *keymap_data; 35 - unsigned int rows; 36 - unsigned int cols; 37 - bool no_autorepeat; 38 - bool wakeup; 39 - 40 - void (*cfg_gpio)(unsigned int rows, unsigned int cols); 41 - }; 16 + #include <linux/input/samsung-keypad.h> 42 17 43 18 /** 44 19 * samsung_keypad_set_platdata - Set platform data for Samsung Keypad device.
+11 -9
drivers/input/evdev.c
··· 369 369 370 370 spin_lock_irq(&client->buffer_lock); 371 371 372 - have_event = client->head != client->tail; 372 + have_event = client->packet_head != client->tail; 373 373 if (have_event) { 374 374 *event = client->buffer[client->tail++]; 375 375 client->tail &= client->bufsize - 1; ··· 391 391 if (count < input_event_size()) 392 392 return -EINVAL; 393 393 394 - if (client->packet_head == client->tail && evdev->exist && 395 - (file->f_flags & O_NONBLOCK)) 396 - return -EAGAIN; 397 - 398 - retval = wait_event_interruptible(evdev->wait, 399 - client->packet_head != client->tail || !evdev->exist); 400 - if (retval) 401 - return retval; 394 + if (!(file->f_flags & O_NONBLOCK)) { 395 + retval = wait_event_interruptible(evdev->wait, 396 + client->packet_head != client->tail || 397 + !evdev->exist); 398 + if (retval) 399 + return retval; 400 + } 402 401 403 402 if (!evdev->exist) 404 403 return -ENODEV; ··· 410 411 411 412 retval += input_event_size(); 412 413 } 414 + 415 + if (retval == 0 && (file->f_flags & O_NONBLOCK)) 416 + return -EAGAIN; 413 417 414 418 return retval; 415 419 }
+5 -3
drivers/input/input-polldev.c
··· 84 84 { 85 85 struct input_polled_dev *polldev = dev_get_drvdata(dev); 86 86 struct input_dev *input = polldev->input; 87 - unsigned long interval; 87 + unsigned int interval; 88 + int err; 88 89 89 - if (strict_strtoul(buf, 0, &interval)) 90 - return -EINVAL; 90 + err = kstrtouint(buf, 0, &interval); 91 + if (err) 92 + return err; 91 93 92 94 if (interval < polldev->poll_interval_min) 93 95 return -EINVAL;
+19 -2
drivers/input/keyboard/Kconfig
··· 221 221 To compile this driver as a module, choose M here: the 222 222 module will be called tca6416_keypad. 223 223 224 + config KEYBOARD_TCA8418 225 + tristate "TCA8418 Keypad Support" 226 + depends on I2C 227 + help 228 + This driver implements basic keypad functionality 229 + for keys connected through TCA8418 keypad decoder. 230 + 231 + Say Y here if your device has keys connected to 232 + TCA8418 keypad decoder. 233 + 234 + If enabled the complete TCA8418 device will be managed through 235 + this driver. 236 + 237 + To compile this driver as a module, choose M here: the 238 + module will be called tca8418_keypad. 239 + 224 240 config KEYBOARD_MATRIX 225 241 tristate "GPIO driven matrix keypad support" 226 242 depends on GENERIC_GPIO ··· 441 425 442 426 config KEYBOARD_SAMSUNG 443 427 tristate "Samsung keypad support" 444 - depends on SAMSUNG_DEV_KEYPAD 428 + depends on HAVE_CLK 445 429 help 446 - Say Y here if you want to use the Samsung keypad. 430 + Say Y here if you want to use the keypad on your Samsung mobile 431 + device. 447 432 448 433 To compile this driver as a module, choose M here: the 449 434 module will be called samsung-keypad.
+1
drivers/input/keyboard/Makefile
··· 16 16 obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o 17 17 obj-$(CONFIG_KEYBOARD_GPIO_POLLED) += gpio_keys_polled.o 18 18 obj-$(CONFIG_KEYBOARD_TCA6416) += tca6416-keypad.o 19 + obj-$(CONFIG_KEYBOARD_TCA8418) += tca8418_keypad.o 19 20 obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o 20 21 obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o 21 22 obj-$(CONFIG_KEYBOARD_IMX) += imx_keypad.o
+1 -12
drivers/input/keyboard/adp5520-keys.c
··· 202 202 .probe = adp5520_keys_probe, 203 203 .remove = __devexit_p(adp5520_keys_remove), 204 204 }; 205 - 206 - static int __init adp5520_keys_init(void) 207 - { 208 - return platform_driver_register(&adp5520_keys_driver); 209 - } 210 - module_init(adp5520_keys_init); 211 - 212 - static void __exit adp5520_keys_exit(void) 213 - { 214 - platform_driver_unregister(&adp5520_keys_driver); 215 - } 216 - module_exit(adp5520_keys_exit); 205 + module_platform_driver(adp5520_keys_driver); 217 206 218 207 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 219 208 MODULE_DESCRIPTION("Keys ADP5520 Driver");
+1 -14
drivers/input/keyboard/amikbd.c
··· 259 259 .owner = THIS_MODULE, 260 260 }, 261 261 }; 262 - 263 - static int __init amikbd_init(void) 264 - { 265 - return platform_driver_probe(&amikbd_driver, amikbd_probe); 266 - } 267 - 268 - module_init(amikbd_init); 269 - 270 - static void __exit amikbd_exit(void) 271 - { 272 - platform_driver_unregister(&amikbd_driver); 273 - } 274 - 275 - module_exit(amikbd_exit); 262 + module_platform_driver(amikbd_driver); 276 263 277 264 MODULE_ALIAS("platform:amiga-keyboard");
+30 -10
drivers/input/keyboard/atkbd.c
··· 1305 1305 static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count) 1306 1306 { 1307 1307 struct input_dev *old_dev, *new_dev; 1308 - unsigned long value; 1308 + unsigned int value; 1309 1309 int err; 1310 1310 bool old_extra; 1311 1311 unsigned char old_set; ··· 1313 1313 if (!atkbd->write) 1314 1314 return -EIO; 1315 1315 1316 - if (strict_strtoul(buf, 10, &value) || value > 1) 1316 + err = kstrtouint(buf, 10, &value); 1317 + if (err) 1318 + return err; 1319 + 1320 + if (value > 1) 1317 1321 return -EINVAL; 1318 1322 1319 1323 if (atkbd->extra != value) { ··· 1393 1389 static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count) 1394 1390 { 1395 1391 struct input_dev *old_dev, *new_dev; 1396 - unsigned long value; 1392 + unsigned int value; 1397 1393 int err; 1398 1394 bool old_scroll; 1399 1395 1400 - if (strict_strtoul(buf, 10, &value) || value > 1) 1396 + err = kstrtouint(buf, 10, &value); 1397 + if (err) 1398 + return err; 1399 + 1400 + if (value > 1) 1401 1401 return -EINVAL; 1402 1402 1403 1403 if (atkbd->scroll != value) { ··· 1441 1433 static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) 1442 1434 { 1443 1435 struct input_dev *old_dev, *new_dev; 1444 - unsigned long value; 1436 + unsigned int value; 1445 1437 int err; 1446 1438 unsigned char old_set; 1447 1439 bool old_extra; ··· 1449 1441 if (!atkbd->write) 1450 1442 return -EIO; 1451 1443 1452 - if (strict_strtoul(buf, 10, &value) || (value != 2 && value != 3)) 1444 + err = kstrtouint(buf, 10, &value); 1445 + if (err) 1446 + return err; 1447 + 1448 + if (value != 2 && value != 3) 1453 1449 return -EINVAL; 1454 1450 1455 1451 if (atkbd->set != value) { ··· 1496 1484 static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count) 1497 1485 { 1498 1486 struct input_dev *old_dev, *new_dev; 1499 - unsigned long value; 1487 + unsigned int value; 1500 1488 int err; 1501 1489 bool old_softrepeat, old_softraw; 1502 1490 1503 1491 if (!atkbd->write) 1504 1492 return -EIO; 1505 1493 1506 - if (strict_strtoul(buf, 10, &value) || value > 1) 1494 + err = kstrtouint(buf, 10, &value); 1495 + if (err) 1496 + return err; 1497 + 1498 + if (value > 1) 1507 1499 return -EINVAL; 1508 1500 1509 1501 if (atkbd->softrepeat != value) { ··· 1550 1534 static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count) 1551 1535 { 1552 1536 struct input_dev *old_dev, *new_dev; 1553 - unsigned long value; 1537 + unsigned int value; 1554 1538 int err; 1555 1539 bool old_softraw; 1556 1540 1557 - if (strict_strtoul(buf, 10, &value) || value > 1) 1541 + err = kstrtouint(buf, 10, &value); 1542 + if (err) 1543 + return err; 1544 + 1545 + if (value > 1) 1558 1546 return -EINVAL; 1559 1547 1560 1548 if (atkbd->softraw != value) {
+2 -14
drivers/input/keyboard/bf54x-keys.c
··· 384 384 # define bfin_kpad_resume NULL 385 385 #endif 386 386 387 - struct platform_driver bfin_kpad_device_driver = { 387 + static struct platform_driver bfin_kpad_device_driver = { 388 388 .driver = { 389 389 .name = DRV_NAME, 390 390 .owner = THIS_MODULE, ··· 394 394 .suspend = bfin_kpad_suspend, 395 395 .resume = bfin_kpad_resume, 396 396 }; 397 - 398 - static int __init bfin_kpad_init(void) 399 - { 400 - return platform_driver_register(&bfin_kpad_device_driver); 401 - } 402 - 403 - static void __exit bfin_kpad_exit(void) 404 - { 405 - platform_driver_unregister(&bfin_kpad_device_driver); 406 - } 407 - 408 - module_init(bfin_kpad_init); 409 - module_exit(bfin_kpad_exit); 397 + module_platform_driver(bfin_kpad_device_driver); 410 398 411 399 MODULE_LICENSE("GPL"); 412 400 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
+1 -12
drivers/input/keyboard/davinci_keyscan.c
··· 328 328 }, 329 329 .remove = __devexit_p(davinci_ks_remove), 330 330 }; 331 - 332 - static int __init davinci_ks_init(void) 333 - { 334 - return platform_driver_probe(&davinci_ks_driver, davinci_ks_probe); 335 - } 336 - module_init(davinci_ks_init); 337 - 338 - static void __exit davinci_ks_exit(void) 339 - { 340 - platform_driver_unregister(&davinci_ks_driver); 341 - } 342 - module_exit(davinci_ks_exit); 331 + module_platform_driver(davinci_ks_driver); 343 332 344 333 MODULE_AUTHOR("Miguel Aguilar"); 345 334 MODULE_DESCRIPTION("Texas Instruments DaVinci Key Scan Driver");
+1 -13
drivers/input/keyboard/ep93xx_keypad.c
··· 390 390 .suspend = ep93xx_keypad_suspend, 391 391 .resume = ep93xx_keypad_resume, 392 392 }; 393 - 394 - static int __init ep93xx_keypad_init(void) 395 - { 396 - return platform_driver_register(&ep93xx_keypad_driver); 397 - } 398 - 399 - static void __exit ep93xx_keypad_exit(void) 400 - { 401 - platform_driver_unregister(&ep93xx_keypad_driver); 402 - } 403 - 404 - module_init(ep93xx_keypad_init); 405 - module_exit(ep93xx_keypad_exit); 393 + module_platform_driver(ep93xx_keypad_driver); 406 394 407 395 MODULE_LICENSE("GPL"); 408 396 MODULE_AUTHOR("H Hartley Sweeten <hsweeten@visionengravers.com>");
+1 -13
drivers/input/keyboard/gpio_keys_polled.c
··· 241 241 .owner = THIS_MODULE, 242 242 }, 243 243 }; 244 - 245 - static int __init gpio_keys_polled_init(void) 246 - { 247 - return platform_driver_register(&gpio_keys_polled_driver); 248 - } 249 - 250 - static void __exit gpio_keys_polled_exit(void) 251 - { 252 - platform_driver_unregister(&gpio_keys_polled_driver); 253 - } 254 - 255 - module_init(gpio_keys_polled_init); 256 - module_exit(gpio_keys_polled_exit); 244 + module_platform_driver(gpio_keys_polled_driver); 257 245 258 246 MODULE_LICENSE("GPL v2"); 259 247 MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
+1 -13
drivers/input/keyboard/imx_keypad.c
··· 619 619 .probe = imx_keypad_probe, 620 620 .remove = __devexit_p(imx_keypad_remove), 621 621 }; 622 - 623 - static int __init imx_keypad_init(void) 624 - { 625 - return platform_driver_register(&imx_keypad_driver); 626 - } 627 - 628 - static void __exit imx_keypad_exit(void) 629 - { 630 - platform_driver_unregister(&imx_keypad_driver); 631 - } 632 - 633 - module_init(imx_keypad_init); 634 - module_exit(imx_keypad_exit); 622 + module_platform_driver(imx_keypad_driver); 635 623 636 624 MODULE_AUTHOR("Alberto Panizzo <maramaopercheseimorto@gmail.com>"); 637 625 MODULE_DESCRIPTION("IMX Keypad Port Driver");
+1 -13
drivers/input/keyboard/jornada680_kbd.c
··· 260 260 .probe = jornada680kbd_probe, 261 261 .remove = __devexit_p(jornada680kbd_remove), 262 262 }; 263 - 264 - static int __init jornada680kbd_init(void) 265 - { 266 - return platform_driver_register(&jornada680kbd_driver); 267 - } 268 - 269 - static void __exit jornada680kbd_exit(void) 270 - { 271 - platform_driver_unregister(&jornada680kbd_driver); 272 - } 273 - 274 - module_init(jornada680kbd_init); 275 - module_exit(jornada680kbd_exit); 263 + module_platform_driver(jornada680kbd_driver); 276 264 277 265 MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson@gmail.com>"); 278 266 MODULE_DESCRIPTION("HP Jornada 620/660/680/690 Keyboard Driver");
+1 -13
drivers/input/keyboard/jornada720_kbd.c
··· 174 174 .probe = jornada720_kbd_probe, 175 175 .remove = __devexit_p(jornada720_kbd_remove), 176 176 }; 177 - 178 - static int __init jornada720_kbd_init(void) 179 - { 180 - return platform_driver_register(&jornada720_kbd_driver); 181 - } 182 - 183 - static void __exit jornada720_kbd_exit(void) 184 - { 185 - platform_driver_unregister(&jornada720_kbd_driver); 186 - } 187 - 188 - module_init(jornada720_kbd_init); 189 - module_exit(jornada720_kbd_exit); 177 + module_platform_driver(jornada720_kbd_driver);
+5 -6
drivers/input/keyboard/lm8323.c
··· 545 545 { 546 546 struct led_classdev *led_cdev = dev_get_drvdata(dev); 547 547 struct lm8323_pwm *pwm = cdev_to_pwm(led_cdev); 548 - int ret; 549 - unsigned long time; 548 + int ret, time; 550 549 551 - ret = strict_strtoul(buf, 10, &time); 550 + ret = kstrtoint(buf, 10, &time); 552 551 /* Numbers only, please. */ 553 552 if (ret) 554 - return -EINVAL; 553 + return ret; 555 554 556 555 pwm->fade_time = time; 557 556 ··· 612 613 { 613 614 struct lm8323_chip *lm = dev_get_drvdata(dev); 614 615 int ret; 615 - unsigned long i; 616 + unsigned int i; 616 617 617 - ret = strict_strtoul(buf, 10, &i); 618 + ret = kstrtouint(buf, 10, &i); 618 619 619 620 mutex_lock(&lm->lock); 620 621 lm->kp_enabled = !i;
+1 -13
drivers/input/keyboard/matrix_keypad.c
··· 496 496 #endif 497 497 }, 498 498 }; 499 - 500 - static int __init matrix_keypad_init(void) 501 - { 502 - return platform_driver_register(&matrix_keypad_driver); 503 - } 504 - 505 - static void __exit matrix_keypad_exit(void) 506 - { 507 - platform_driver_unregister(&matrix_keypad_driver); 508 - } 509 - 510 - module_init(matrix_keypad_init); 511 - module_exit(matrix_keypad_exit); 499 + module_platform_driver(matrix_keypad_driver); 512 500 513 501 MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); 514 502 MODULE_DESCRIPTION("GPIO Driven Matrix Keypad Driver");
+2 -13
drivers/input/keyboard/nomadik-ske-keypad.c
··· 379 379 }; 380 380 #endif 381 381 382 - struct platform_driver ske_keypad_driver = { 382 + static struct platform_driver ske_keypad_driver = { 383 383 .driver = { 384 384 .name = "nmk-ske-keypad", 385 385 .owner = THIS_MODULE, ··· 390 390 .probe = ske_keypad_probe, 391 391 .remove = __devexit_p(ske_keypad_remove), 392 392 }; 393 - 394 - static int __init ske_keypad_init(void) 395 - { 396 - return platform_driver_probe(&ske_keypad_driver, ske_keypad_probe); 397 - } 398 - module_init(ske_keypad_init); 399 - 400 - static void __exit ske_keypad_exit(void) 401 - { 402 - platform_driver_unregister(&ske_keypad_driver); 403 - } 404 - module_exit(ske_keypad_exit); 393 + module_platform_driver(ske_keypad_driver); 405 394 406 395 MODULE_LICENSE("GPL v2"); 407 396 MODULE_AUTHOR("Naveen Kumar <naveen.gaddipati@stericsson.com> / Sundar Iyer <sundar.iyer@stericsson.com>");
+1 -14
drivers/input/keyboard/omap-keypad.c
··· 473 473 .owner = THIS_MODULE, 474 474 }, 475 475 }; 476 - 477 - static int __init omap_kp_init(void) 478 - { 479 - printk(KERN_INFO "OMAP Keypad Driver\n"); 480 - return platform_driver_register(&omap_kp_driver); 481 - } 482 - 483 - static void __exit omap_kp_exit(void) 484 - { 485 - platform_driver_unregister(&omap_kp_driver); 486 - } 487 - 488 - module_init(omap_kp_init); 489 - module_exit(omap_kp_exit); 476 + module_platform_driver(omap_kp_driver); 490 477 491 478 MODULE_AUTHOR("Timo Teräs"); 492 479 MODULE_DESCRIPTION("OMAP Keypad Driver");
+1 -12
drivers/input/keyboard/omap4-keypad.c
··· 335 335 .owner = THIS_MODULE, 336 336 }, 337 337 }; 338 - 339 - static int __init omap4_keypad_init(void) 340 - { 341 - return platform_driver_register(&omap4_keypad_driver); 342 - } 343 - module_init(omap4_keypad_init); 344 - 345 - static void __exit omap4_keypad_exit(void) 346 - { 347 - platform_driver_unregister(&omap4_keypad_driver); 348 - } 349 - module_exit(omap4_keypad_exit); 338 + module_platform_driver(omap4_keypad_driver); 350 339 351 340 MODULE_AUTHOR("Texas Instruments"); 352 341 MODULE_DESCRIPTION("OMAP4 Keypad Driver");
+1 -12
drivers/input/keyboard/opencores-kbd.c
··· 163 163 .name = "opencores-kbd", 164 164 }, 165 165 }; 166 - 167 - static int __init opencores_kbd_init(void) 168 - { 169 - return platform_driver_register(&opencores_kbd_device_driver); 170 - } 171 - module_init(opencores_kbd_init); 172 - 173 - static void __exit opencores_kbd_exit(void) 174 - { 175 - platform_driver_unregister(&opencores_kbd_device_driver); 176 - } 177 - module_exit(opencores_kbd_exit); 166 + module_platform_driver(opencores_kbd_device_driver); 178 167 179 168 MODULE_LICENSE("GPL"); 180 169 MODULE_AUTHOR("Javier Herrero <jherrero@hvsistemas.es>");
+1 -12
drivers/input/keyboard/pmic8xxx-keypad.c
··· 780 780 .pm = &pm8xxx_kp_pm_ops, 781 781 }, 782 782 }; 783 - 784 - static int __init pmic8xxx_kp_init(void) 785 - { 786 - return platform_driver_register(&pmic8xxx_kp_driver); 787 - } 788 - module_init(pmic8xxx_kp_init); 789 - 790 - static void __exit pmic8xxx_kp_exit(void) 791 - { 792 - platform_driver_unregister(&pmic8xxx_kp_driver); 793 - } 794 - module_exit(pmic8xxx_kp_exit); 783 + module_platform_driver(pmic8xxx_kp_driver); 795 784 796 785 MODULE_LICENSE("GPL v2"); 797 786 MODULE_DESCRIPTION("PMIC8XXX keypad driver");
+1 -13
drivers/input/keyboard/pxa27x_keypad.c
··· 602 602 #endif 603 603 }, 604 604 }; 605 - 606 - static int __init pxa27x_keypad_init(void) 607 - { 608 - return platform_driver_register(&pxa27x_keypad_driver); 609 - } 610 - 611 - static void __exit pxa27x_keypad_exit(void) 612 - { 613 - platform_driver_unregister(&pxa27x_keypad_driver); 614 - } 615 - 616 - module_init(pxa27x_keypad_init); 617 - module_exit(pxa27x_keypad_exit); 605 + module_platform_driver(pxa27x_keypad_driver); 618 606 619 607 MODULE_DESCRIPTION("PXA27x Keypad Controller Driver"); 620 608 MODULE_LICENSE("GPL");
+1 -12
drivers/input/keyboard/pxa930_rotary.c
··· 195 195 .probe = pxa930_rotary_probe, 196 196 .remove = __devexit_p(pxa930_rotary_remove), 197 197 }; 198 - 199 - static int __init pxa930_rotary_init(void) 200 - { 201 - return platform_driver_register(&pxa930_rotary_driver); 202 - } 203 - module_init(pxa930_rotary_init); 204 - 205 - static void __exit pxa930_rotary_exit(void) 206 - { 207 - platform_driver_unregister(&pxa930_rotary_driver); 208 - } 209 - module_exit(pxa930_rotary_exit); 198 + module_platform_driver(pxa930_rotary_driver); 210 199 211 200 MODULE_LICENSE("GPL"); 212 201 MODULE_DESCRIPTION("Driver for PXA93x Enhanced Rotary Controller");
+82 -26
drivers/input/keyboard/samsung-keypad.c
··· 20 20 #include <linux/io.h> 21 21 #include <linux/module.h> 22 22 #include <linux/platform_device.h> 23 + #include <linux/pm.h> 24 + #include <linux/pm_runtime.h> 23 25 #include <linux/slab.h> 24 26 #include <linux/of.h> 25 27 #include <linux/of_gpio.h> 26 28 #include <linux/sched.h> 27 - #include <plat/keypad.h> 29 + #include <linux/input/samsung-keypad.h> 28 30 29 31 #define SAMSUNG_KEYIFCON 0x00 30 32 #define SAMSUNG_KEYIFSTSCLR 0x04 ··· 67 65 68 66 struct samsung_keypad { 69 67 struct input_dev *input_dev; 68 + struct platform_device *pdev; 70 69 struct clk *clk; 71 70 void __iomem *base; 72 71 wait_queue_head_t wait; 73 72 bool stopped; 73 + bool wake_enabled; 74 74 int irq; 75 75 enum samsung_keypad_type type; 76 76 unsigned int row_shift; ··· 159 155 unsigned int val; 160 156 bool key_down; 161 157 158 + pm_runtime_get_sync(&keypad->pdev->dev); 159 + 162 160 do { 163 161 val = readl(keypad->base + SAMSUNG_KEYIFSTSCLR); 164 162 /* Clear interrupt. */ ··· 175 169 176 170 } while (key_down && !keypad->stopped); 177 171 172 + pm_runtime_put_sync(&keypad->pdev->dev); 173 + 178 174 return IRQ_HANDLED; 179 175 } 180 176 181 177 static void samsung_keypad_start(struct samsung_keypad *keypad) 182 178 { 183 179 unsigned int val; 180 + 181 + pm_runtime_get_sync(&keypad->pdev->dev); 184 182 185 183 /* Tell IRQ thread that it may poll the device. */ 186 184 keypad->stopped = false; ··· 198 188 199 189 /* KEYIFCOL reg clear. */ 200 190 writel(0, keypad->base + SAMSUNG_KEYIFCOL); 191 + 192 + pm_runtime_put_sync(&keypad->pdev->dev); 201 193 } 202 194 203 195 static void samsung_keypad_stop(struct samsung_keypad *keypad) 204 196 { 205 197 unsigned int val; 198 + 199 + pm_runtime_get_sync(&keypad->pdev->dev); 206 200 207 201 /* Signal IRQ thread to stop polling and disable the handler. */ 208 202 keypad->stopped = true; ··· 228 214 * re-enable the handler. 229 215 */ 230 216 enable_irq(keypad->irq); 217 + 218 + pm_runtime_put_sync(&keypad->pdev->dev); 231 219 } 232 220 233 221 static int samsung_keypad_open(struct input_dev *input_dev) ··· 434 418 } 435 419 436 420 keypad->input_dev = input_dev; 421 + keypad->pdev = pdev; 437 422 keypad->row_shift = row_shift; 438 423 keypad->rows = pdata->rows; 439 424 keypad->cols = pdata->cols; 425 + keypad->stopped = true; 440 426 init_waitqueue_head(&keypad->wait); 441 427 442 428 if (pdev->dev.of_node) { ··· 485 467 goto err_put_clk; 486 468 } 487 469 470 + device_init_wakeup(&pdev->dev, pdata->wakeup); 471 + platform_set_drvdata(pdev, keypad); 472 + pm_runtime_enable(&pdev->dev); 473 + 488 474 error = input_register_device(keypad->input_dev); 489 475 if (error) 490 476 goto err_free_irq; 491 - 492 - device_init_wakeup(&pdev->dev, pdata->wakeup); 493 - platform_set_drvdata(pdev, keypad); 494 477 495 478 if (pdev->dev.of_node) { 496 479 devm_kfree(&pdev->dev, (void *)pdata->keymap_data->keymap); ··· 502 483 503 484 err_free_irq: 504 485 free_irq(keypad->irq, keypad); 486 + pm_runtime_disable(&pdev->dev); 487 + device_init_wakeup(&pdev->dev, 0); 488 + platform_set_drvdata(pdev, NULL); 505 489 err_put_clk: 506 490 clk_put(keypad->clk); 507 491 samsung_keypad_dt_gpio_free(keypad); ··· 521 499 { 522 500 struct samsung_keypad *keypad = platform_get_drvdata(pdev); 523 501 502 + pm_runtime_disable(&pdev->dev); 524 503 device_init_wakeup(&pdev->dev, 0); 525 504 platform_set_drvdata(pdev, NULL); 526 505 ··· 542 519 return 0; 543 520 } 544 521 545 - #ifdef CONFIG_PM 522 + #ifdef CONFIG_PM_RUNTIME 523 + static int samsung_keypad_runtime_suspend(struct device *dev) 524 + { 525 + struct platform_device *pdev = to_platform_device(dev); 526 + struct samsung_keypad *keypad = platform_get_drvdata(pdev); 527 + unsigned int val; 528 + int error; 529 + 530 + if (keypad->stopped) 531 + return 0; 532 + 533 + /* This may fail on some SoCs due to lack of controller support */ 534 + error = enable_irq_wake(keypad->irq); 535 + if (!error) 536 + keypad->wake_enabled = true; 537 + 538 + val = readl(keypad->base + SAMSUNG_KEYIFCON); 539 + val |= SAMSUNG_KEYIFCON_WAKEUPEN; 540 + writel(val, keypad->base + SAMSUNG_KEYIFCON); 541 + 542 + clk_disable(keypad->clk); 543 + 544 + return 0; 545 + } 546 + 547 + static int samsung_keypad_runtime_resume(struct device *dev) 548 + { 549 + struct platform_device *pdev = to_platform_device(dev); 550 + struct samsung_keypad *keypad = platform_get_drvdata(pdev); 551 + unsigned int val; 552 + 553 + if (keypad->stopped) 554 + return 0; 555 + 556 + clk_enable(keypad->clk); 557 + 558 + val = readl(keypad->base + SAMSUNG_KEYIFCON); 559 + val &= ~SAMSUNG_KEYIFCON_WAKEUPEN; 560 + writel(val, keypad->base + SAMSUNG_KEYIFCON); 561 + 562 + if (keypad->wake_enabled) 563 + disable_irq_wake(keypad->irq); 564 + 565 + return 0; 566 + } 567 + #endif 568 + 569 + #ifdef CONFIG_PM_SLEEP 546 570 static void samsung_keypad_toggle_wakeup(struct samsung_keypad *keypad, 547 571 bool enable) 548 572 { 549 - struct device *dev = keypad->input_dev->dev.parent; 550 573 unsigned int val; 551 574 552 575 clk_enable(keypad->clk); ··· 600 531 val = readl(keypad->base + SAMSUNG_KEYIFCON); 601 532 if (enable) { 602 533 val |= SAMSUNG_KEYIFCON_WAKEUPEN; 603 - if (device_may_wakeup(dev)) 534 + if (device_may_wakeup(&keypad->pdev->dev)) 604 535 enable_irq_wake(keypad->irq); 605 536 } else { 606 537 val &= ~SAMSUNG_KEYIFCON_WAKEUPEN; 607 - if (device_may_wakeup(dev)) 538 + if (device_may_wakeup(&keypad->pdev->dev)) 608 539 disable_irq_wake(keypad->irq); 609 540 } 610 541 writel(val, keypad->base + SAMSUNG_KEYIFCON); ··· 647 578 648 579 return 0; 649 580 } 581 + #endif 650 582 651 583 static const struct dev_pm_ops samsung_keypad_pm_ops = { 652 - .suspend = samsung_keypad_suspend, 653 - .resume = samsung_keypad_resume, 584 + SET_SYSTEM_SLEEP_PM_OPS(samsung_keypad_suspend, samsung_keypad_resume) 585 + SET_RUNTIME_PM_OPS(samsung_keypad_runtime_suspend, 586 + samsung_keypad_runtime_resume, NULL) 654 587 }; 655 - #endif 656 588 657 589 #ifdef CONFIG_OF 658 590 static const struct of_device_id samsung_keypad_dt_match[] = { ··· 685 615 .name = "samsung-keypad", 686 616 .owner = THIS_MODULE, 687 617 .of_match_table = samsung_keypad_dt_match, 688 - #ifdef CONFIG_PM 689 618 .pm = &samsung_keypad_pm_ops, 690 - #endif 691 619 }, 692 620 .id_table = samsung_keypad_driver_ids, 693 621 }; 694 - 695 - static int __init samsung_keypad_init(void) 696 - { 697 - return platform_driver_register(&samsung_keypad_driver); 698 - } 699 - module_init(samsung_keypad_init); 700 - 701 - static void __exit samsung_keypad_exit(void) 702 - { 703 - platform_driver_unregister(&samsung_keypad_driver); 704 - } 705 - module_exit(samsung_keypad_exit); 622 + module_platform_driver(samsung_keypad_driver); 706 623 707 624 MODULE_DESCRIPTION("Samsung keypad driver"); 708 625 MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>"); 709 626 MODULE_AUTHOR("Donghwa Lee <dh09.lee@samsung.com>"); 710 627 MODULE_LICENSE("GPL"); 711 - MODULE_ALIAS("platform:samsung-keypad");
+1 -13
drivers/input/keyboard/sh_keysc.c
··· 337 337 .pm = &sh_keysc_dev_pm_ops, 338 338 } 339 339 }; 340 - 341 - static int __init sh_keysc_init(void) 342 - { 343 - return platform_driver_register(&sh_keysc_device_driver); 344 - } 345 - 346 - static void __exit sh_keysc_exit(void) 347 - { 348 - platform_driver_unregister(&sh_keysc_device_driver); 349 - } 350 - 351 - module_init(sh_keysc_init); 352 - module_exit(sh_keysc_exit); 340 + module_platform_driver(sh_keysc_device_driver); 353 341 354 342 MODULE_AUTHOR("Magnus Damm"); 355 343 MODULE_DESCRIPTION("SuperH KEYSC Keypad Driver");
+1 -12
drivers/input/keyboard/spear-keyboard.c
··· 326 326 #endif 327 327 }, 328 328 }; 329 - 330 - static int __init spear_kbd_init(void) 331 - { 332 - return platform_driver_register(&spear_kbd_driver); 333 - } 334 - module_init(spear_kbd_init); 335 - 336 - static void __exit spear_kbd_exit(void) 337 - { 338 - platform_driver_unregister(&spear_kbd_driver); 339 - } 340 - module_exit(spear_kbd_exit); 329 + module_platform_driver(spear_kbd_driver); 341 330 342 331 MODULE_AUTHOR("Rajeev Kumar"); 343 332 MODULE_DESCRIPTION("SPEAr Keyboard Driver");
+1 -12
drivers/input/keyboard/stmpe-keypad.c
··· 368 368 .probe = stmpe_keypad_probe, 369 369 .remove = __devexit_p(stmpe_keypad_remove), 370 370 }; 371 - 372 - static int __init stmpe_keypad_init(void) 373 - { 374 - return platform_driver_register(&stmpe_keypad_driver); 375 - } 376 - module_init(stmpe_keypad_init); 377 - 378 - static void __exit stmpe_keypad_exit(void) 379 - { 380 - platform_driver_unregister(&stmpe_keypad_driver); 381 - } 382 - module_exit(stmpe_keypad_exit); 371 + module_platform_driver(stmpe_keypad_driver); 383 372 384 373 MODULE_LICENSE("GPL v2"); 385 374 MODULE_DESCRIPTION("STMPExxxx keypad driver");
+3 -12
drivers/input/keyboard/tc3589x-keypad.c
··· 74 74 75 75 /** 76 76 * struct tc_keypad - data structure used by keypad driver 77 + * @tc3589x: pointer to tc35893 77 78 * @input: pointer to input device object 78 79 * @board: keypad platform device 79 80 * @krow: number of rows 80 81 * @kcol: number of coloumns 81 82 * @keymap: matrix scan code table for keycodes 83 + * @keypad_stopped: holds keypad status 82 84 */ 83 85 struct tc_keypad { 84 86 struct tc3589x *tc3589x; ··· 455 453 .probe = tc3589x_keypad_probe, 456 454 .remove = __devexit_p(tc3589x_keypad_remove), 457 455 }; 458 - 459 - static int __init tc3589x_keypad_init(void) 460 - { 461 - return platform_driver_register(&tc3589x_keypad_driver); 462 - } 463 - module_init(tc3589x_keypad_init); 464 - 465 - static void __exit tc3589x_keypad_exit(void) 466 - { 467 - return platform_driver_unregister(&tc3589x_keypad_driver); 468 - } 469 - module_exit(tc3589x_keypad_exit); 456 + module_platform_driver(tc3589x_keypad_driver); 470 457 471 458 MODULE_LICENSE("GPL v2"); 472 459 MODULE_AUTHOR("Jayeeta Banerjee/Sundar Iyer");
+430
drivers/input/keyboard/tca8418_keypad.c
··· 1 + /* 2 + * Driver for TCA8418 I2C keyboard 3 + * 4 + * Copyright (C) 2011 Fuel7, Inc. All rights reserved. 5 + * 6 + * Author: Kyle Manna <kyle.manna@fuel7.com> 7 + * 8 + * This program is free software; you can redistribute it and/or 9 + * modify it under the terms of the GNU General Public 10 + * License v2 as published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 + * General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public 18 + * License along with this program; if not, write to the 19 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 + * Boston, MA 021110-1307, USA. 21 + * 22 + * If you can't comply with GPLv2, alternative licensing terms may be 23 + * arranged. Please contact Fuel7, Inc. (http://fuel7.com/) for proprietary 24 + * alternative licensing inquiries. 25 + */ 26 + 27 + #include <linux/types.h> 28 + #include <linux/module.h> 29 + #include <linux/init.h> 30 + #include <linux/delay.h> 31 + #include <linux/slab.h> 32 + #include <linux/interrupt.h> 33 + #include <linux/workqueue.h> 34 + #include <linux/gpio.h> 35 + #include <linux/i2c.h> 36 + #include <linux/input.h> 37 + #include <linux/input/tca8418_keypad.h> 38 + 39 + /* TCA8418 hardware limits */ 40 + #define TCA8418_MAX_ROWS 8 41 + #define TCA8418_MAX_COLS 10 42 + 43 + /* TCA8418 register offsets */ 44 + #define REG_CFG 0x01 45 + #define REG_INT_STAT 0x02 46 + #define REG_KEY_LCK_EC 0x03 47 + #define REG_KEY_EVENT_A 0x04 48 + #define REG_KEY_EVENT_B 0x05 49 + #define REG_KEY_EVENT_C 0x06 50 + #define REG_KEY_EVENT_D 0x07 51 + #define REG_KEY_EVENT_E 0x08 52 + #define REG_KEY_EVENT_F 0x09 53 + #define REG_KEY_EVENT_G 0x0A 54 + #define REG_KEY_EVENT_H 0x0B 55 + #define REG_KEY_EVENT_I 0x0C 56 + #define REG_KEY_EVENT_J 0x0D 57 + #define REG_KP_LCK_TIMER 0x0E 58 + #define REG_UNLOCK1 0x0F 59 + #define REG_UNLOCK2 0x10 60 + #define REG_GPIO_INT_STAT1 0x11 61 + #define REG_GPIO_INT_STAT2 0x12 62 + #define REG_GPIO_INT_STAT3 0x13 63 + #define REG_GPIO_DAT_STAT1 0x14 64 + #define REG_GPIO_DAT_STAT2 0x15 65 + #define REG_GPIO_DAT_STAT3 0x16 66 + #define REG_GPIO_DAT_OUT1 0x17 67 + #define REG_GPIO_DAT_OUT2 0x18 68 + #define REG_GPIO_DAT_OUT3 0x19 69 + #define REG_GPIO_INT_EN1 0x1A 70 + #define REG_GPIO_INT_EN2 0x1B 71 + #define REG_GPIO_INT_EN3 0x1C 72 + #define REG_KP_GPIO1 0x1D 73 + #define REG_KP_GPIO2 0x1E 74 + #define REG_KP_GPIO3 0x1F 75 + #define REG_GPI_EM1 0x20 76 + #define REG_GPI_EM2 0x21 77 + #define REG_GPI_EM3 0x22 78 + #define REG_GPIO_DIR1 0x23 79 + #define REG_GPIO_DIR2 0x24 80 + #define REG_GPIO_DIR3 0x25 81 + #define REG_GPIO_INT_LVL1 0x26 82 + #define REG_GPIO_INT_LVL2 0x27 83 + #define REG_GPIO_INT_LVL3 0x28 84 + #define REG_DEBOUNCE_DIS1 0x29 85 + #define REG_DEBOUNCE_DIS2 0x2A 86 + #define REG_DEBOUNCE_DIS3 0x2B 87 + #define REG_GPIO_PULL1 0x2C 88 + #define REG_GPIO_PULL2 0x2D 89 + #define REG_GPIO_PULL3 0x2E 90 + 91 + /* TCA8418 bit definitions */ 92 + #define CFG_AI BIT(7) 93 + #define CFG_GPI_E_CFG BIT(6) 94 + #define CFG_OVR_FLOW_M BIT(5) 95 + #define CFG_INT_CFG BIT(4) 96 + #define CFG_OVR_FLOW_IEN BIT(3) 97 + #define CFG_K_LCK_IEN BIT(2) 98 + #define CFG_GPI_IEN BIT(1) 99 + #define CFG_KE_IEN BIT(0) 100 + 101 + #define INT_STAT_CAD_INT BIT(4) 102 + #define INT_STAT_OVR_FLOW_INT BIT(3) 103 + #define INT_STAT_K_LCK_INT BIT(2) 104 + #define INT_STAT_GPI_INT BIT(1) 105 + #define INT_STAT_K_INT BIT(0) 106 + 107 + /* TCA8418 register masks */ 108 + #define KEY_LCK_EC_KEC 0x7 109 + #define KEY_EVENT_CODE 0x7f 110 + #define KEY_EVENT_VALUE 0x80 111 + 112 + 113 + static const struct i2c_device_id tca8418_id[] = { 114 + { TCA8418_NAME, 8418, }, 115 + { } 116 + }; 117 + MODULE_DEVICE_TABLE(i2c, tca8418_id); 118 + 119 + struct tca8418_keypad { 120 + unsigned int rows; 121 + unsigned int cols; 122 + unsigned int keypad_mask; /* Mask for keypad col/rol regs */ 123 + unsigned int irq; 124 + unsigned int row_shift; 125 + 126 + struct i2c_client *client; 127 + struct input_dev *input; 128 + 129 + /* Flexible array member, must be at end of struct */ 130 + unsigned short keymap[]; 131 + }; 132 + 133 + /* 134 + * Write a byte to the TCA8418 135 + */ 136 + static int tca8418_write_byte(struct tca8418_keypad *keypad_data, 137 + int reg, u8 val) 138 + { 139 + int error; 140 + 141 + error = i2c_smbus_write_byte_data(keypad_data->client, reg, val); 142 + if (error < 0) { 143 + dev_err(&keypad_data->client->dev, 144 + "%s failed, reg: %d, val: %d, error: %d\n", 145 + __func__, reg, val, error); 146 + return error; 147 + } 148 + 149 + return 0; 150 + } 151 + 152 + /* 153 + * Read a byte from the TCA8418 154 + */ 155 + static int tca8418_read_byte(struct tca8418_keypad *keypad_data, 156 + int reg, u8 *val) 157 + { 158 + int error; 159 + 160 + error = i2c_smbus_read_byte_data(keypad_data->client, reg); 161 + if (error < 0) { 162 + dev_err(&keypad_data->client->dev, 163 + "%s failed, reg: %d, error: %d\n", 164 + __func__, reg, error); 165 + return error; 166 + } 167 + 168 + *val = (u8)error; 169 + 170 + return 0; 171 + } 172 + 173 + static void tca8418_read_keypad(struct tca8418_keypad *keypad_data) 174 + { 175 + int error, col, row; 176 + u8 reg, state, code; 177 + 178 + /* Initial read of the key event FIFO */ 179 + error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, &reg); 180 + 181 + /* Assume that key code 0 signifies empty FIFO */ 182 + while (error >= 0 && reg > 0) { 183 + state = reg & KEY_EVENT_VALUE; 184 + code = reg & KEY_EVENT_CODE; 185 + 186 + row = code / TCA8418_MAX_COLS; 187 + col = code % TCA8418_MAX_COLS; 188 + 189 + row = (col) ? row : row - 1; 190 + col = (col) ? col - 1 : TCA8418_MAX_COLS - 1; 191 + 192 + code = MATRIX_SCAN_CODE(row, col, keypad_data->row_shift); 193 + input_event(keypad_data->input, EV_MSC, MSC_SCAN, code); 194 + input_report_key(keypad_data->input, 195 + keypad_data->keymap[code], state); 196 + 197 + /* Read for next loop */ 198 + error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, &reg); 199 + } 200 + 201 + if (error < 0) 202 + dev_err(&keypad_data->client->dev, 203 + "unable to read REG_KEY_EVENT_A\n"); 204 + 205 + input_sync(keypad_data->input); 206 + } 207 + 208 + /* 209 + * Threaded IRQ handler and this can (and will) sleep. 210 + */ 211 + static irqreturn_t tca8418_irq_handler(int irq, void *dev_id) 212 + { 213 + struct tca8418_keypad *keypad_data = dev_id; 214 + u8 reg; 215 + int error; 216 + 217 + error = tca8418_read_byte(keypad_data, REG_INT_STAT, &reg); 218 + if (error) { 219 + dev_err(&keypad_data->client->dev, 220 + "unable to read REG_INT_STAT\n"); 221 + goto exit; 222 + } 223 + 224 + if (reg & INT_STAT_OVR_FLOW_INT) 225 + dev_warn(&keypad_data->client->dev, "overflow occurred\n"); 226 + 227 + if (reg & INT_STAT_K_INT) 228 + tca8418_read_keypad(keypad_data); 229 + 230 + exit: 231 + /* Clear all interrupts, even IRQs we didn't check (GPI, CAD, LCK) */ 232 + reg = 0xff; 233 + error = tca8418_write_byte(keypad_data, REG_INT_STAT, reg); 234 + if (error) 235 + dev_err(&keypad_data->client->dev, 236 + "unable to clear REG_INT_STAT\n"); 237 + 238 + return IRQ_HANDLED; 239 + } 240 + 241 + /* 242 + * Configure the TCA8418 for keypad operation 243 + */ 244 + static int __devinit tca8418_configure(struct tca8418_keypad *keypad_data) 245 + { 246 + int reg, error; 247 + 248 + /* Write config register, if this fails assume device not present */ 249 + error = tca8418_write_byte(keypad_data, REG_CFG, 250 + CFG_INT_CFG | CFG_OVR_FLOW_IEN | CFG_KE_IEN); 251 + if (error < 0) 252 + return -ENODEV; 253 + 254 + 255 + /* Assemble a mask for row and column registers */ 256 + reg = ~(~0 << keypad_data->rows); 257 + reg += (~(~0 << keypad_data->cols)) << 8; 258 + keypad_data->keypad_mask = reg; 259 + 260 + /* Set registers to keypad mode */ 261 + error |= tca8418_write_byte(keypad_data, REG_KP_GPIO1, reg); 262 + error |= tca8418_write_byte(keypad_data, REG_KP_GPIO2, reg >> 8); 263 + error |= tca8418_write_byte(keypad_data, REG_KP_GPIO3, reg >> 16); 264 + 265 + /* Enable column debouncing */ 266 + error |= tca8418_write_byte(keypad_data, REG_DEBOUNCE_DIS1, reg); 267 + error |= tca8418_write_byte(keypad_data, REG_DEBOUNCE_DIS2, reg >> 8); 268 + error |= tca8418_write_byte(keypad_data, REG_DEBOUNCE_DIS3, reg >> 16); 269 + 270 + return error; 271 + } 272 + 273 + static int __devinit tca8418_keypad_probe(struct i2c_client *client, 274 + const struct i2c_device_id *id) 275 + { 276 + const struct tca8418_keypad_platform_data *pdata = 277 + client->dev.platform_data; 278 + struct tca8418_keypad *keypad_data; 279 + struct input_dev *input; 280 + int error, row_shift, max_keys; 281 + 282 + /* Copy the platform data */ 283 + if (!pdata) { 284 + dev_dbg(&client->dev, "no platform data\n"); 285 + return -EINVAL; 286 + } 287 + 288 + if (!pdata->keymap_data) { 289 + dev_err(&client->dev, "no keymap data defined\n"); 290 + return -EINVAL; 291 + } 292 + 293 + if (!pdata->rows || pdata->rows > TCA8418_MAX_ROWS) { 294 + dev_err(&client->dev, "invalid rows\n"); 295 + return -EINVAL; 296 + } 297 + 298 + if (!pdata->cols || pdata->cols > TCA8418_MAX_COLS) { 299 + dev_err(&client->dev, "invalid columns\n"); 300 + return -EINVAL; 301 + } 302 + 303 + /* Check i2c driver capabilities */ 304 + if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { 305 + dev_err(&client->dev, "%s adapter not supported\n", 306 + dev_driver_string(&client->adapter->dev)); 307 + return -ENODEV; 308 + } 309 + 310 + row_shift = get_count_order(pdata->cols); 311 + max_keys = pdata->rows << row_shift; 312 + 313 + /* Allocate memory for keypad_data, keymap and input device */ 314 + keypad_data = kzalloc(sizeof(*keypad_data) + 315 + max_keys * sizeof(keypad_data->keymap[0]), GFP_KERNEL); 316 + if (!keypad_data) 317 + return -ENOMEM; 318 + 319 + keypad_data->rows = pdata->rows; 320 + keypad_data->cols = pdata->cols; 321 + keypad_data->client = client; 322 + keypad_data->row_shift = row_shift; 323 + 324 + /* Initialize the chip or fail if chip isn't present */ 325 + error = tca8418_configure(keypad_data); 326 + if (error < 0) 327 + goto fail1; 328 + 329 + /* Configure input device */ 330 + input = input_allocate_device(); 331 + if (!input) { 332 + error = -ENOMEM; 333 + goto fail1; 334 + } 335 + keypad_data->input = input; 336 + 337 + input->name = client->name; 338 + input->dev.parent = &client->dev; 339 + 340 + input->id.bustype = BUS_I2C; 341 + input->id.vendor = 0x0001; 342 + input->id.product = 0x001; 343 + input->id.version = 0x0001; 344 + 345 + input->keycode = keypad_data->keymap; 346 + input->keycodesize = sizeof(keypad_data->keymap[0]); 347 + input->keycodemax = max_keys; 348 + 349 + __set_bit(EV_KEY, input->evbit); 350 + if (pdata->rep) 351 + __set_bit(EV_REP, input->evbit); 352 + 353 + input_set_capability(input, EV_MSC, MSC_SCAN); 354 + 355 + input_set_drvdata(input, keypad_data); 356 + 357 + matrix_keypad_build_keymap(pdata->keymap_data, row_shift, 358 + input->keycode, input->keybit); 359 + 360 + if (pdata->irq_is_gpio) 361 + client->irq = gpio_to_irq(client->irq); 362 + 363 + error = request_threaded_irq(client->irq, NULL, tca8418_irq_handler, 364 + IRQF_TRIGGER_FALLING, 365 + client->name, keypad_data); 366 + if (error) { 367 + dev_dbg(&client->dev, 368 + "Unable to claim irq %d; error %d\n", 369 + client->irq, error); 370 + goto fail2; 371 + } 372 + 373 + error = input_register_device(input); 374 + if (error) { 375 + dev_dbg(&client->dev, 376 + "Unable to register input device, error: %d\n", error); 377 + goto fail3; 378 + } 379 + 380 + i2c_set_clientdata(client, keypad_data); 381 + return 0; 382 + 383 + fail3: 384 + free_irq(client->irq, keypad_data); 385 + fail2: 386 + input_free_device(input); 387 + fail1: 388 + kfree(keypad_data); 389 + return error; 390 + } 391 + 392 + static int __devexit tca8418_keypad_remove(struct i2c_client *client) 393 + { 394 + struct tca8418_keypad *keypad_data = i2c_get_clientdata(client); 395 + 396 + free_irq(keypad_data->client->irq, keypad_data); 397 + 398 + input_unregister_device(keypad_data->input); 399 + 400 + kfree(keypad_data); 401 + 402 + return 0; 403 + } 404 + 405 + 406 + static struct i2c_driver tca8418_keypad_driver = { 407 + .driver = { 408 + .name = TCA8418_NAME, 409 + .owner = THIS_MODULE, 410 + }, 411 + .probe = tca8418_keypad_probe, 412 + .remove = __devexit_p(tca8418_keypad_remove), 413 + .id_table = tca8418_id, 414 + }; 415 + 416 + static int __init tca8418_keypad_init(void) 417 + { 418 + return i2c_add_driver(&tca8418_keypad_driver); 419 + } 420 + subsys_initcall(tca8418_keypad_init); 421 + 422 + static void __exit tca8418_keypad_exit(void) 423 + { 424 + i2c_del_driver(&tca8418_keypad_driver); 425 + } 426 + module_exit(tca8418_keypad_exit); 427 + 428 + MODULE_AUTHOR("Kyle Manna <kyle.manna@fuel7.com>"); 429 + MODULE_DESCRIPTION("Keypad driver for TCA8418"); 430 + MODULE_LICENSE("GPL");
+109 -23
drivers/input/keyboard/tegra-kbc.c
··· 26 26 #include <linux/delay.h> 27 27 #include <linux/io.h> 28 28 #include <linux/interrupt.h> 29 + #include <linux/of.h> 29 30 #include <linux/clk.h> 30 31 #include <linux/slab.h> 31 32 #include <mach/clk.h> ··· 53 52 /* KBC Interrupt Register */ 54 53 #define KBC_INT_0 0x4 55 54 #define KBC_INT_FIFO_CNT_INT_STATUS (1 << 2) 55 + #define KBC_INT_KEYPRESS_INT_STATUS (1 << 0) 56 56 57 57 #define KBC_ROW_CFG0_0 0x8 58 58 #define KBC_COL_CFG0_0 0x18 ··· 76 74 unsigned int cp_to_wkup_dly; 77 75 bool use_fn_map; 78 76 bool use_ghost_filter; 77 + bool keypress_caused_wake; 79 78 const struct tegra_kbc_platform_data *pdata; 80 79 unsigned short keycode[KBC_MAX_KEY * 2]; 81 80 unsigned short current_keys[KBC_MAX_KPENT]; 82 81 unsigned int num_pressed_keys; 82 + u32 wakeup_key; 83 83 struct timer_list timer; 84 84 struct clk *clk; 85 85 }; 86 86 87 - static const u32 tegra_kbc_default_keymap[] = { 87 + static const u32 tegra_kbc_default_keymap[] __devinitdata = { 88 88 KEY(0, 2, KEY_W), 89 89 KEY(0, 3, KEY_S), 90 90 KEY(0, 4, KEY_A), ··· 221 217 KEY(31, 4, KEY_HELP), 222 218 }; 223 219 224 - static const struct matrix_keymap_data tegra_kbc_default_keymap_data = { 220 + static const 221 + struct matrix_keymap_data tegra_kbc_default_keymap_data __devinitdata = { 225 222 .keymap = tegra_kbc_default_keymap, 226 223 .keymap_size = ARRAY_SIZE(tegra_kbc_default_keymap), 227 224 }; ··· 414 409 */ 415 410 tegra_kbc_set_fifo_interrupt(kbc, false); 416 411 mod_timer(&kbc->timer, jiffies + kbc->cp_dly_jiffies); 412 + } else if (val & KBC_INT_KEYPRESS_INT_STATUS) { 413 + /* We can be here only through system resume path */ 414 + kbc->keypress_caused_wake = true; 417 415 } 418 416 419 417 spin_unlock_irqrestore(&kbc->lock, flags); ··· 584 576 return true; 585 577 } 586 578 579 + #ifdef CONFIG_OF 580 + static struct tegra_kbc_platform_data * __devinit 581 + tegra_kbc_dt_parse_pdata(struct platform_device *pdev) 582 + { 583 + struct tegra_kbc_platform_data *pdata; 584 + struct device_node *np = pdev->dev.of_node; 585 + 586 + if (!np) 587 + return NULL; 588 + 589 + pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); 590 + if (!pdata) 591 + return NULL; 592 + 593 + if (!of_property_read_u32(np, "debounce-delay", &prop)) 594 + pdata->debounce_cnt = prop; 595 + 596 + if (!of_property_read_u32(np, "repeat-delay", &prop)) 597 + pdata->repeat_cnt = prop; 598 + 599 + if (of_find_property(np, "needs-ghost-filter", NULL)) 600 + pdata->use_ghost_filter = true; 601 + 602 + if (of_find_property(np, "wakeup-source", NULL)) 603 + pdata->wakeup = true; 604 + 605 + /* 606 + * All currently known keymaps with device tree support use the same 607 + * pin_cfg, so set it up here. 608 + */ 609 + for (i = 0; i < KBC_MAX_ROW; i++) { 610 + pdata->pin_cfg[i].num = i; 611 + pdata->pin_cfg[i].is_row = true; 612 + } 613 + 614 + for (i = 0; i < KBC_MAX_COL; i++) { 615 + pdata->pin_cfg[KBC_MAX_ROW + i].num = i; 616 + pdata->pin_cfg[KBC_MAX_ROW + i].is_row = false; 617 + } 618 + 619 + return pdata; 620 + } 621 + #else 622 + static inline struct tegra_kbc_platform_data *tegra_kbc_dt_parse_pdata( 623 + struct platform_device *pdev) 624 + { 625 + return NULL; 626 + } 627 + #endif 628 + 587 629 static int __devinit tegra_kbc_probe(struct platform_device *pdev) 588 630 { 589 631 const struct tegra_kbc_platform_data *pdata = pdev->dev.platform_data; ··· 648 590 unsigned int scan_time_rows; 649 591 650 592 if (!pdata) 593 + pdata = tegra_kbc_dt_parse_pdata(pdev); 594 + 595 + if (!pdata) 651 596 return -EINVAL; 652 597 653 - if (!tegra_kbc_check_pin_cfg(pdata, &pdev->dev, &num_rows)) 654 - return -EINVAL; 598 + if (!tegra_kbc_check_pin_cfg(pdata, &pdev->dev, &num_rows)) { 599 + err = -EINVAL; 600 + goto err_free_pdata; 601 + } 655 602 656 603 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 657 604 if (!res) { 658 605 dev_err(&pdev->dev, "failed to get I/O memory\n"); 659 - return -ENXIO; 606 + err = -ENXIO; 607 + goto err_free_pdata; 660 608 } 661 609 662 610 irq = platform_get_irq(pdev, 0); 663 611 if (irq < 0) { 664 612 dev_err(&pdev->dev, "failed to get keyboard IRQ\n"); 665 - return -ENXIO; 613 + err = -ENXIO; 614 + goto err_free_pdata; 666 615 } 667 616 668 617 kbc = kzalloc(sizeof(*kbc), GFP_KERNEL); ··· 739 674 keymap_data = pdata->keymap_data ?: &tegra_kbc_default_keymap_data; 740 675 matrix_keypad_build_keymap(keymap_data, KBC_ROW_SHIFT, 741 676 input_dev->keycode, input_dev->keybit); 677 + kbc->wakeup_key = pdata->wakeup_key; 742 678 743 - err = request_irq(kbc->irq, tegra_kbc_isr, IRQF_TRIGGER_HIGH, 744 - pdev->name, kbc); 679 + err = request_irq(kbc->irq, tegra_kbc_isr, 680 + IRQF_NO_SUSPEND | IRQF_TRIGGER_HIGH, pdev->name, kbc); 745 681 if (err) { 746 682 dev_err(&pdev->dev, "failed to request keyboard IRQ\n"); 747 683 goto err_put_clk; ··· 772 706 err_free_mem: 773 707 input_free_device(input_dev); 774 708 kfree(kbc); 709 + err_free_pdata: 710 + if (!pdev->dev.platform_data) 711 + kfree(pdata); 775 712 776 713 return err; 777 714 } ··· 784 715 struct tegra_kbc *kbc = platform_get_drvdata(pdev); 785 716 struct resource *res; 786 717 718 + platform_set_drvdata(pdev, NULL); 719 + 787 720 free_irq(kbc->irq, pdev); 788 721 clk_put(kbc->clk); 789 722 ··· 794 723 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 795 724 release_mem_region(res->start, resource_size(res)); 796 725 797 - kfree(kbc); 726 + /* 727 + * If we do not have platform data attached to the device we 728 + * allocated it ourselves and thus need to free it. 729 + */ 730 + if (!pdev->dev.platform_data) 731 + kfree(kbc->pdata); 798 732 799 - platform_set_drvdata(pdev, NULL); 733 + kfree(kbc); 800 734 801 735 return 0; 802 736 } ··· 830 754 tegra_kbc_setup_wakekeys(kbc, true); 831 755 msleep(30); 832 756 757 + kbc->keypress_caused_wake = false; 758 + enable_irq(kbc->irq); 833 759 enable_irq_wake(kbc->irq); 834 760 } else { 835 761 if (kbc->idev->users) ··· 858 780 859 781 tegra_kbc_set_fifo_interrupt(kbc, true); 860 782 861 - enable_irq(kbc->irq); 783 + if (kbc->keypress_caused_wake && kbc->wakeup_key) { 784 + /* 785 + * We can't report events directly from the ISR 786 + * because timekeeping is stopped when processing 787 + * wakeup request and we get a nasty warning when 788 + * we try to call do_gettimeofday() in evdev 789 + * handler. 790 + */ 791 + input_report_key(kbc->idev, kbc->wakeup_key, 1); 792 + input_sync(kbc->idev); 793 + input_report_key(kbc->idev, kbc->wakeup_key, 0); 794 + input_sync(kbc->idev); 795 + } 862 796 } else { 863 797 if (kbc->idev->users) 864 798 err = tegra_kbc_start(kbc); ··· 883 793 884 794 static SIMPLE_DEV_PM_OPS(tegra_kbc_pm_ops, tegra_kbc_suspend, tegra_kbc_resume); 885 795 796 + static const struct of_device_id tegra_kbc_of_match[] = { 797 + { .compatible = "nvidia,tegra20-kbc", }, 798 + { }, 799 + }; 800 + MODULE_DEVICE_TABLE(of, tegra_kbc_of_match); 801 + 886 802 static struct platform_driver tegra_kbc_driver = { 887 803 .probe = tegra_kbc_probe, 888 804 .remove = __devexit_p(tegra_kbc_remove), ··· 896 800 .name = "tegra-kbc", 897 801 .owner = THIS_MODULE, 898 802 .pm = &tegra_kbc_pm_ops, 803 + .of_match_table = tegra_kbc_of_match, 899 804 }, 900 805 }; 901 - 902 - static void __exit tegra_kbc_exit(void) 903 - { 904 - platform_driver_unregister(&tegra_kbc_driver); 905 - } 906 - module_exit(tegra_kbc_exit); 907 - 908 - static int __init tegra_kbc_init(void) 909 - { 910 - return platform_driver_register(&tegra_kbc_driver); 911 - } 912 - module_init(tegra_kbc_init); 806 + module_platform_driver(tegra_kbc_driver); 913 807 914 808 MODULE_LICENSE("GPL"); 915 809 MODULE_AUTHOR("Rakesh Iyer <riyer@nvidia.com>");
+1 -13
drivers/input/keyboard/tnetv107x-keypad.c
··· 322 322 .driver.name = "tnetv107x-keypad", 323 323 .driver.owner = THIS_MODULE, 324 324 }; 325 - 326 - static int __init keypad_init(void) 327 - { 328 - return platform_driver_register(&keypad_driver); 329 - } 330 - 331 - static void __exit keypad_exit(void) 332 - { 333 - platform_driver_unregister(&keypad_driver); 334 - } 335 - 336 - module_init(keypad_init); 337 - module_exit(keypad_exit); 325 + module_platform_driver(keypad_driver); 338 326 339 327 MODULE_AUTHOR("Cyril Chemparathy"); 340 328 MODULE_DESCRIPTION("TNETV107X Keypad Driver");
+1 -12
drivers/input/keyboard/twl4030_keypad.c
··· 460 460 .owner = THIS_MODULE, 461 461 }, 462 462 }; 463 - 464 - static int __init twl4030_kp_init(void) 465 - { 466 - return platform_driver_register(&twl4030_kp_driver); 467 - } 468 - module_init(twl4030_kp_init); 469 - 470 - static void __exit twl4030_kp_exit(void) 471 - { 472 - platform_driver_unregister(&twl4030_kp_driver); 473 - } 474 - module_exit(twl4030_kp_exit); 463 + module_platform_driver(twl4030_kp_driver); 475 464 476 465 MODULE_AUTHOR("Texas Instruments"); 477 466 MODULE_DESCRIPTION("TWL4030 Keypad Driver");
+1 -13
drivers/input/keyboard/w90p910_keypad.c
··· 262 262 .owner = THIS_MODULE, 263 263 }, 264 264 }; 265 - 266 - static int __init w90p910_keypad_init(void) 267 - { 268 - return platform_driver_register(&w90p910_keypad_driver); 269 - } 270 - 271 - static void __exit w90p910_keypad_exit(void) 272 - { 273 - platform_driver_unregister(&w90p910_keypad_driver); 274 - } 275 - 276 - module_init(w90p910_keypad_init); 277 - module_exit(w90p910_keypad_exit); 265 + module_platform_driver(w90p910_keypad_driver); 278 266 279 267 MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>"); 280 268 MODULE_DESCRIPTION("w90p910 keypad driver");
+1 -12
drivers/input/misc/88pm860x_onkey.c
··· 137 137 .probe = pm860x_onkey_probe, 138 138 .remove = __devexit_p(pm860x_onkey_remove), 139 139 }; 140 - 141 - static int __init pm860x_onkey_init(void) 142 - { 143 - return platform_driver_register(&pm860x_onkey_driver); 144 - } 145 - module_init(pm860x_onkey_init); 146 - 147 - static void __exit pm860x_onkey_exit(void) 148 - { 149 - platform_driver_unregister(&pm860x_onkey_driver); 150 - } 151 - module_exit(pm860x_onkey_exit); 140 + module_platform_driver(pm860x_onkey_driver); 152 141 153 142 MODULE_DESCRIPTION("Marvell 88PM860x ONKEY driver"); 154 143 MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
+25
drivers/input/misc/Kconfig
··· 179 179 To compile this driver as a module, choose M here: the module will 180 180 be called apanel. 181 181 182 + config INPUT_GP2A 183 + tristate "Sharp GP2AP002A00F I2C Proximity/Opto sensor driver" 184 + depends on I2C 185 + depends on GENERIC_GPIO 186 + help 187 + Say Y here if you have a Sharp GP2AP002A00F proximity/als combo-chip 188 + hooked to an I2C bus. 189 + 190 + To compile this driver as a module, choose M here: the 191 + module will be called gp2ap002a00f. 192 + 193 + config INPUT_GPIO_TILT_POLLED 194 + tristate "Polled GPIO tilt switch" 195 + depends on GENERIC_GPIO 196 + select INPUT_POLLDEV 197 + help 198 + This driver implements support for tilt switches connected 199 + to GPIO pins that are not capable of generating interrupts. 200 + 201 + The list of gpios to use and the mapping of their states 202 + to specific angles is done via platform data. 203 + 204 + To compile this driver as a module, choose M here: the 205 + module will be called gpio_tilt_polled. 206 + 182 207 config INPUT_IXP4XX_BEEPER 183 208 tristate "IXP4XX Beeper support" 184 209 depends on ARCH_IXP4XX
+2
drivers/input/misc/Makefile
··· 22 22 obj-$(CONFIG_INPUT_CMA3000_I2C) += cma3000_d0x_i2c.o 23 23 obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o 24 24 obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o 25 + obj-$(CONFIG_INPUT_GP2A) += gp2ap002a00f.o 26 + obj-$(CONFIG_INPUT_GPIO_TILT_POLLED) += gpio_tilt_polled.o 25 27 obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 26 28 obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o 27 29 obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o
+1 -12
drivers/input/misc/ab8500-ponkey.c
··· 139 139 .probe = ab8500_ponkey_probe, 140 140 .remove = __devexit_p(ab8500_ponkey_remove), 141 141 }; 142 - 143 - static int __init ab8500_ponkey_init(void) 144 - { 145 - return platform_driver_register(&ab8500_ponkey_driver); 146 - } 147 - module_init(ab8500_ponkey_init); 148 - 149 - static void __exit ab8500_ponkey_exit(void) 150 - { 151 - platform_driver_unregister(&ab8500_ponkey_driver); 152 - } 153 - module_exit(ab8500_ponkey_exit); 142 + module_platform_driver(ab8500_ponkey_driver); 154 143 155 144 MODULE_LICENSE("GPL v2"); 156 145 MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
-1
drivers/input/misc/adxl34x-spi.c
··· 122 122 static struct spi_driver adxl34x_driver = { 123 123 .driver = { 124 124 .name = "adxl34x", 125 - .bus = &spi_bus_type, 126 125 .owner = THIS_MODULE, 127 126 .pm = &adxl34x_spi_pm, 128 127 },
+8 -8
drivers/input/misc/adxl34x.c
··· 452 452 const char *buf, size_t count) 453 453 { 454 454 struct adxl34x *ac = dev_get_drvdata(dev); 455 - unsigned long val; 455 + unsigned int val; 456 456 int error; 457 457 458 - error = strict_strtoul(buf, 10, &val); 458 + error = kstrtouint(buf, 10, &val); 459 459 if (error) 460 460 return error; 461 461 ··· 541 541 const char *buf, size_t count) 542 542 { 543 543 struct adxl34x *ac = dev_get_drvdata(dev); 544 - unsigned long val; 544 + unsigned char val; 545 545 int error; 546 546 547 - error = strict_strtoul(buf, 10, &val); 547 + error = kstrtou8(buf, 10, &val); 548 548 if (error) 549 549 return error; 550 550 ··· 576 576 const char *buf, size_t count) 577 577 { 578 578 struct adxl34x *ac = dev_get_drvdata(dev); 579 - unsigned long val; 579 + unsigned int val; 580 580 int error; 581 581 582 - error = strict_strtoul(buf, 10, &val); 582 + error = kstrtouint(buf, 10, &val); 583 583 if (error) 584 584 return error; 585 585 ··· 623 623 const char *buf, size_t count) 624 624 { 625 625 struct adxl34x *ac = dev_get_drvdata(dev); 626 - unsigned long val; 626 + unsigned int val; 627 627 int error; 628 628 629 629 /* 630 630 * This allows basic ADXL register write access for debug purposes. 631 631 */ 632 - error = strict_strtoul(buf, 16, &val); 632 + error = kstrtouint(buf, 16, &val); 633 633 if (error) 634 634 return error; 635 635
+11 -8
drivers/input/misc/ati_remote2.c
··· 42 42 const struct kernel_param *kp, 43 43 unsigned int max) 44 44 { 45 - unsigned long mask; 45 + unsigned int mask; 46 46 int ret; 47 47 48 48 if (!val) 49 49 return -EINVAL; 50 50 51 - ret = strict_strtoul(val, 0, &mask); 51 + ret = kstrtouint(val, 0, &mask); 52 52 if (ret) 53 53 return ret; 54 54 ··· 720 720 struct usb_device *udev = to_usb_device(dev); 721 721 struct usb_interface *intf = usb_ifnum_to_if(udev, 0); 722 722 struct ati_remote2 *ar2 = usb_get_intfdata(intf); 723 - unsigned long mask; 723 + unsigned int mask; 724 724 int r; 725 725 726 - if (strict_strtoul(buf, 0, &mask)) 727 - return -EINVAL; 726 + r = kstrtouint(buf, 0, &mask); 727 + if (r) 728 + return r; 728 729 729 730 if (mask & ~ATI_REMOTE2_MAX_CHANNEL_MASK) 730 731 return -EINVAL; ··· 770 769 struct usb_device *udev = to_usb_device(dev); 771 770 struct usb_interface *intf = usb_ifnum_to_if(udev, 0); 772 771 struct ati_remote2 *ar2 = usb_get_intfdata(intf); 773 - unsigned long mask; 772 + unsigned int mask; 773 + int err; 774 774 775 - if (strict_strtoul(buf, 0, &mask)) 776 - return -EINVAL; 775 + err = kstrtouint(buf, 0, &mask); 776 + if (err) 777 + return err; 777 778 778 779 if (mask & ~ATI_REMOTE2_MAX_MODE_MASK) 779 780 return -EINVAL;
+1 -12
drivers/input/misc/bfin_rotary.c
··· 264 264 #endif 265 265 }, 266 266 }; 267 - 268 - static int __init bfin_rotary_init(void) 269 - { 270 - return platform_driver_register(&bfin_rotary_device_driver); 271 - } 272 - module_init(bfin_rotary_init); 273 - 274 - static void __exit bfin_rotary_exit(void) 275 - { 276 - platform_driver_unregister(&bfin_rotary_device_driver); 277 - } 278 - module_exit(bfin_rotary_exit); 267 + module_platform_driver(bfin_rotary_device_driver); 279 268 280 269 MODULE_LICENSE("GPL"); 281 270 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
+1 -13
drivers/input/misc/cobalt_btns.c
··· 163 163 .owner = THIS_MODULE, 164 164 }, 165 165 }; 166 - 167 - static int __init cobalt_buttons_init(void) 168 - { 169 - return platform_driver_register(&cobalt_buttons_driver); 170 - } 171 - 172 - static void __exit cobalt_buttons_exit(void) 173 - { 174 - platform_driver_unregister(&cobalt_buttons_driver); 175 - } 176 - 177 - module_init(cobalt_buttons_init); 178 - module_exit(cobalt_buttons_exit); 166 + module_platform_driver(cobalt_buttons_driver);
+1 -12
drivers/input/misc/dm355evm_keys.c
··· 267 267 .name = "dm355evm_keys", 268 268 }, 269 269 }; 270 - 271 - static int __init dm355evm_keys_init(void) 272 - { 273 - return platform_driver_register(&dm355evm_keys_driver); 274 - } 275 - module_init(dm355evm_keys_init); 276 - 277 - static void __exit dm355evm_keys_exit(void) 278 - { 279 - platform_driver_unregister(&dm355evm_keys_driver); 280 - } 281 - module_exit(dm355evm_keys_exit); 270 + module_platform_driver(dm355evm_keys_driver); 282 271 283 272 MODULE_LICENSE("GPL");
+299
drivers/input/misc/gp2ap002a00f.c
··· 1 + /* 2 + * Copyright (C) 2011 Sony Ericsson Mobile Communications Inc. 3 + * 4 + * Author: Courtney Cavin <courtney.cavin@sonyericsson.com> 5 + * Prepared for up-stream by: Oskar Andero <oskar.andero@sonyericsson.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify 8 + * it under the terms of the GNU General Public License version 2, as 9 + * published by the Free Software Foundation. 10 + */ 11 + 12 + #include <linux/i2c.h> 13 + #include <linux/irq.h> 14 + #include <linux/slab.h> 15 + #include <linux/input.h> 16 + #include <linux/module.h> 17 + #include <linux/interrupt.h> 18 + #include <linux/gpio.h> 19 + #include <linux/delay.h> 20 + #include <linux/input/gp2ap002a00f.h> 21 + 22 + struct gp2a_data { 23 + struct input_dev *input; 24 + const struct gp2a_platform_data *pdata; 25 + struct i2c_client *i2c_client; 26 + }; 27 + 28 + enum gp2a_addr { 29 + GP2A_ADDR_PROX = 0x0, 30 + GP2A_ADDR_GAIN = 0x1, 31 + GP2A_ADDR_HYS = 0x2, 32 + GP2A_ADDR_CYCLE = 0x3, 33 + GP2A_ADDR_OPMOD = 0x4, 34 + GP2A_ADDR_CON = 0x6 35 + }; 36 + 37 + enum gp2a_controls { 38 + /* Software Shutdown control: 0 = shutdown, 1 = normal operation */ 39 + GP2A_CTRL_SSD = 0x01 40 + }; 41 + 42 + static int gp2a_report(struct gp2a_data *dt) 43 + { 44 + int vo = gpio_get_value(dt->pdata->vout_gpio); 45 + 46 + input_report_switch(dt->input, SW_FRONT_PROXIMITY, !vo); 47 + input_sync(dt->input); 48 + 49 + return 0; 50 + } 51 + 52 + static irqreturn_t gp2a_irq(int irq, void *handle) 53 + { 54 + struct gp2a_data *dt = handle; 55 + 56 + gp2a_report(dt); 57 + 58 + return IRQ_HANDLED; 59 + } 60 + 61 + static int gp2a_enable(struct gp2a_data *dt) 62 + { 63 + return i2c_smbus_write_byte_data(dt->i2c_client, GP2A_ADDR_OPMOD, 64 + GP2A_CTRL_SSD); 65 + } 66 + 67 + static int gp2a_disable(struct gp2a_data *dt) 68 + { 69 + return i2c_smbus_write_byte_data(dt->i2c_client, GP2A_ADDR_OPMOD, 70 + 0x00); 71 + } 72 + 73 + static int gp2a_device_open(struct input_dev *dev) 74 + { 75 + struct gp2a_data *dt = input_get_drvdata(dev); 76 + int error; 77 + 78 + error = gp2a_enable(dt); 79 + if (error < 0) { 80 + dev_err(&dt->i2c_client->dev, 81 + "unable to activate, err %d\n", error); 82 + return error; 83 + } 84 + 85 + gp2a_report(dt); 86 + 87 + return 0; 88 + } 89 + 90 + static void gp2a_device_close(struct input_dev *dev) 91 + { 92 + struct gp2a_data *dt = input_get_drvdata(dev); 93 + int error; 94 + 95 + error = gp2a_disable(dt); 96 + if (error < 0) 97 + dev_err(&dt->i2c_client->dev, 98 + "unable to deactivate, err %d\n", error); 99 + } 100 + 101 + static int __devinit gp2a_initialize(struct gp2a_data *dt) 102 + { 103 + int error; 104 + 105 + error = i2c_smbus_write_byte_data(dt->i2c_client, GP2A_ADDR_GAIN, 106 + 0x08); 107 + if (error < 0) 108 + return error; 109 + 110 + error = i2c_smbus_write_byte_data(dt->i2c_client, GP2A_ADDR_HYS, 111 + 0xc2); 112 + if (error < 0) 113 + return error; 114 + 115 + error = i2c_smbus_write_byte_data(dt->i2c_client, GP2A_ADDR_CYCLE, 116 + 0x04); 117 + if (error < 0) 118 + return error; 119 + 120 + error = gp2a_disable(dt); 121 + 122 + return error; 123 + } 124 + 125 + static int __devinit gp2a_probe(struct i2c_client *client, 126 + const struct i2c_device_id *id) 127 + { 128 + const struct gp2a_platform_data *pdata = client->dev.platform_data; 129 + struct gp2a_data *dt; 130 + int error; 131 + 132 + if (!pdata) 133 + return -EINVAL; 134 + 135 + if (pdata->hw_setup) { 136 + error = pdata->hw_setup(client); 137 + if (error < 0) 138 + return error; 139 + } 140 + 141 + error = gpio_request_one(pdata->vout_gpio, GPIOF_IN, GP2A_I2C_NAME); 142 + if (error) 143 + goto err_hw_shutdown; 144 + 145 + dt = kzalloc(sizeof(struct gp2a_data), GFP_KERNEL); 146 + if (!dt) { 147 + error = -ENOMEM; 148 + goto err_free_gpio; 149 + } 150 + 151 + dt->pdata = pdata; 152 + dt->i2c_client = client; 153 + 154 + error = gp2a_initialize(dt); 155 + if (error < 0) 156 + goto err_free_mem; 157 + 158 + dt->input = input_allocate_device(); 159 + if (!dt->input) { 160 + error = -ENOMEM; 161 + goto err_free_mem; 162 + } 163 + 164 + input_set_drvdata(dt->input, dt); 165 + 166 + dt->input->open = gp2a_device_open; 167 + dt->input->close = gp2a_device_close; 168 + dt->input->name = GP2A_I2C_NAME; 169 + dt->input->id.bustype = BUS_I2C; 170 + dt->input->dev.parent = &client->dev; 171 + 172 + input_set_capability(dt->input, EV_SW, SW_FRONT_PROXIMITY); 173 + 174 + error = request_threaded_irq(client->irq, NULL, gp2a_irq, 175 + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | 176 + IRQF_ONESHOT, 177 + GP2A_I2C_NAME, dt); 178 + if (error) { 179 + dev_err(&client->dev, "irq request failed\n"); 180 + goto err_free_input_dev; 181 + } 182 + 183 + error = input_register_device(dt->input); 184 + if (error) { 185 + dev_err(&client->dev, "device registration failed\n"); 186 + goto err_free_irq; 187 + } 188 + 189 + device_init_wakeup(&client->dev, pdata->wakeup); 190 + i2c_set_clientdata(client, dt); 191 + 192 + return 0; 193 + 194 + err_free_irq: 195 + free_irq(client->irq, dt); 196 + err_free_input_dev: 197 + input_free_device(dt->input); 198 + err_free_mem: 199 + kfree(dt); 200 + err_free_gpio: 201 + gpio_free(pdata->vout_gpio); 202 + err_hw_shutdown: 203 + if (pdata->hw_shutdown) 204 + pdata->hw_shutdown(client); 205 + return error; 206 + } 207 + 208 + static int __devexit gp2a_remove(struct i2c_client *client) 209 + { 210 + struct gp2a_data *dt = i2c_get_clientdata(client); 211 + const struct gp2a_platform_data *pdata = dt->pdata; 212 + 213 + device_init_wakeup(&client->dev, false); 214 + 215 + free_irq(client->irq, dt); 216 + 217 + input_unregister_device(dt->input); 218 + kfree(dt); 219 + 220 + gpio_free(pdata->vout_gpio); 221 + 222 + if (pdata->hw_shutdown) 223 + pdata->hw_shutdown(client); 224 + 225 + return 0; 226 + } 227 + 228 + #ifdef CONFIG_PM_SLEEP 229 + static int gp2a_suspend(struct device *dev) 230 + { 231 + struct i2c_client *client = to_i2c_client(dev); 232 + struct gp2a_data *dt = i2c_get_clientdata(client); 233 + int retval = 0; 234 + 235 + if (device_may_wakeup(&client->dev)) { 236 + enable_irq_wake(client->irq); 237 + } else { 238 + mutex_lock(&dt->input->mutex); 239 + if (dt->input->users) 240 + retval = gp2a_disable(dt); 241 + mutex_unlock(&dt->input->mutex); 242 + } 243 + 244 + return retval; 245 + } 246 + 247 + static int gp2a_resume(struct device *dev) 248 + { 249 + struct i2c_client *client = to_i2c_client(dev); 250 + struct gp2a_data *dt = i2c_get_clientdata(client); 251 + int retval = 0; 252 + 253 + if (device_may_wakeup(&client->dev)) { 254 + disable_irq_wake(client->irq); 255 + } else { 256 + mutex_lock(&dt->input->mutex); 257 + if (dt->input->users) 258 + retval = gp2a_enable(dt); 259 + mutex_unlock(&dt->input->mutex); 260 + } 261 + 262 + return retval; 263 + } 264 + #endif 265 + 266 + static SIMPLE_DEV_PM_OPS(gp2a_pm, gp2a_suspend, gp2a_resume); 267 + 268 + static const struct i2c_device_id gp2a_i2c_id[] = { 269 + { GP2A_I2C_NAME, 0 }, 270 + { } 271 + }; 272 + 273 + static struct i2c_driver gp2a_i2c_driver = { 274 + .driver = { 275 + .name = GP2A_I2C_NAME, 276 + .owner = THIS_MODULE, 277 + .pm = &gp2a_pm, 278 + }, 279 + .probe = gp2a_probe, 280 + .remove = __devexit_p(gp2a_remove), 281 + .id_table = gp2a_i2c_id, 282 + }; 283 + 284 + static int __init gp2a_init(void) 285 + { 286 + return i2c_add_driver(&gp2a_i2c_driver); 287 + } 288 + 289 + static void __exit gp2a_exit(void) 290 + { 291 + i2c_del_driver(&gp2a_i2c_driver); 292 + } 293 + 294 + module_init(gp2a_init); 295 + module_exit(gp2a_exit); 296 + 297 + MODULE_AUTHOR("Courtney Cavin <courtney.cavin@sonyericsson.com>"); 298 + MODULE_DESCRIPTION("Sharp GP2AP002A00F I2C Proximity/Opto sensor driver"); 299 + MODULE_LICENSE("GPL v2");
+213
drivers/input/misc/gpio_tilt_polled.c
··· 1 + /* 2 + * Driver for tilt switches connected via GPIO lines 3 + * not capable of generating interrupts 4 + * 5 + * Copyright (C) 2011 Heiko Stuebner <heiko@sntech.de> 6 + * 7 + * based on: drivers/input/keyboard/gpio_keys_polled.c 8 + * 9 + * Copyright (C) 2007-2010 Gabor Juhos <juhosg@openwrt.org> 10 + * Copyright (C) 2010 Nuno Goncalves <nunojpg@gmail.com> 11 + * 12 + * This program is free software; you can redistribute it and/or modify 13 + * it under the terms of the GNU General Public License version 2 as 14 + * published by the Free Software Foundation. 15 + */ 16 + 17 + #include <linux/kernel.h> 18 + #include <linux/module.h> 19 + #include <linux/init.h> 20 + #include <linux/slab.h> 21 + #include <linux/input.h> 22 + #include <linux/input-polldev.h> 23 + #include <linux/ioport.h> 24 + #include <linux/platform_device.h> 25 + #include <linux/gpio.h> 26 + #include <linux/input/gpio_tilt.h> 27 + 28 + #define DRV_NAME "gpio-tilt-polled" 29 + 30 + struct gpio_tilt_polled_dev { 31 + struct input_polled_dev *poll_dev; 32 + struct device *dev; 33 + const struct gpio_tilt_platform_data *pdata; 34 + 35 + int last_state; 36 + 37 + int threshold; 38 + int count; 39 + }; 40 + 41 + static void gpio_tilt_polled_poll(struct input_polled_dev *dev) 42 + { 43 + struct gpio_tilt_polled_dev *tdev = dev->private; 44 + const struct gpio_tilt_platform_data *pdata = tdev->pdata; 45 + struct input_dev *input = dev->input; 46 + struct gpio_tilt_state *tilt_state = NULL; 47 + int state, i; 48 + 49 + if (tdev->count < tdev->threshold) { 50 + tdev->count++; 51 + } else { 52 + state = 0; 53 + for (i = 0; i < pdata->nr_gpios; i++) 54 + state |= (!!gpio_get_value(pdata->gpios[i].gpio) << i); 55 + 56 + if (state != tdev->last_state) { 57 + for (i = 0; i < pdata->nr_states; i++) 58 + if (pdata->states[i].gpios == state) 59 + tilt_state = &pdata->states[i]; 60 + 61 + if (tilt_state) { 62 + for (i = 0; i < pdata->nr_axes; i++) 63 + input_report_abs(input, 64 + pdata->axes[i].axis, 65 + tilt_state->axes[i]); 66 + 67 + input_sync(input); 68 + } 69 + 70 + tdev->count = 0; 71 + tdev->last_state = state; 72 + } 73 + } 74 + } 75 + 76 + static void gpio_tilt_polled_open(struct input_polled_dev *dev) 77 + { 78 + struct gpio_tilt_polled_dev *tdev = dev->private; 79 + const struct gpio_tilt_platform_data *pdata = tdev->pdata; 80 + 81 + if (pdata->enable) 82 + pdata->enable(tdev->dev); 83 + 84 + /* report initial state of the axes */ 85 + tdev->last_state = -1; 86 + tdev->count = tdev->threshold; 87 + gpio_tilt_polled_poll(tdev->poll_dev); 88 + } 89 + 90 + static void gpio_tilt_polled_close(struct input_polled_dev *dev) 91 + { 92 + struct gpio_tilt_polled_dev *tdev = dev->private; 93 + const struct gpio_tilt_platform_data *pdata = tdev->pdata; 94 + 95 + if (pdata->disable) 96 + pdata->disable(tdev->dev); 97 + } 98 + 99 + static int __devinit gpio_tilt_polled_probe(struct platform_device *pdev) 100 + { 101 + const struct gpio_tilt_platform_data *pdata = pdev->dev.platform_data; 102 + struct device *dev = &pdev->dev; 103 + struct gpio_tilt_polled_dev *tdev; 104 + struct input_polled_dev *poll_dev; 105 + struct input_dev *input; 106 + int error, i; 107 + 108 + if (!pdata || !pdata->poll_interval) 109 + return -EINVAL; 110 + 111 + tdev = kzalloc(sizeof(struct gpio_tilt_polled_dev), GFP_KERNEL); 112 + if (!tdev) { 113 + dev_err(dev, "no memory for private data\n"); 114 + return -ENOMEM; 115 + } 116 + 117 + error = gpio_request_array(pdata->gpios, pdata->nr_gpios); 118 + if (error) { 119 + dev_err(dev, 120 + "Could not request tilt GPIOs: %d\n", error); 121 + goto err_free_tdev; 122 + } 123 + 124 + poll_dev = input_allocate_polled_device(); 125 + if (!poll_dev) { 126 + dev_err(dev, "no memory for polled device\n"); 127 + error = -ENOMEM; 128 + goto err_free_gpios; 129 + } 130 + 131 + poll_dev->private = tdev; 132 + poll_dev->poll = gpio_tilt_polled_poll; 133 + poll_dev->poll_interval = pdata->poll_interval; 134 + poll_dev->open = gpio_tilt_polled_open; 135 + poll_dev->close = gpio_tilt_polled_close; 136 + 137 + input = poll_dev->input; 138 + 139 + input->name = pdev->name; 140 + input->phys = DRV_NAME"/input0"; 141 + input->dev.parent = &pdev->dev; 142 + 143 + input->id.bustype = BUS_HOST; 144 + input->id.vendor = 0x0001; 145 + input->id.product = 0x0001; 146 + input->id.version = 0x0100; 147 + 148 + __set_bit(EV_ABS, input->evbit); 149 + for (i = 0; i < pdata->nr_axes; i++) 150 + input_set_abs_params(input, pdata->axes[i].axis, 151 + pdata->axes[i].min, pdata->axes[i].max, 152 + pdata->axes[i].fuzz, pdata->axes[i].flat); 153 + 154 + tdev->threshold = DIV_ROUND_UP(pdata->debounce_interval, 155 + pdata->poll_interval); 156 + 157 + tdev->poll_dev = poll_dev; 158 + tdev->dev = dev; 159 + tdev->pdata = pdata; 160 + 161 + error = input_register_polled_device(poll_dev); 162 + if (error) { 163 + dev_err(dev, "unable to register polled device, err=%d\n", 164 + error); 165 + goto err_free_polldev; 166 + } 167 + 168 + platform_set_drvdata(pdev, tdev); 169 + 170 + return 0; 171 + 172 + err_free_polldev: 173 + input_free_polled_device(poll_dev); 174 + err_free_gpios: 175 + gpio_free_array(pdata->gpios, pdata->nr_gpios); 176 + err_free_tdev: 177 + kfree(tdev); 178 + 179 + return error; 180 + } 181 + 182 + static int __devexit gpio_tilt_polled_remove(struct platform_device *pdev) 183 + { 184 + struct gpio_tilt_polled_dev *tdev = platform_get_drvdata(pdev); 185 + const struct gpio_tilt_platform_data *pdata = tdev->pdata; 186 + 187 + platform_set_drvdata(pdev, NULL); 188 + 189 + input_unregister_polled_device(tdev->poll_dev); 190 + input_free_polled_device(tdev->poll_dev); 191 + 192 + gpio_free_array(pdata->gpios, pdata->nr_gpios); 193 + 194 + kfree(tdev); 195 + 196 + return 0; 197 + } 198 + 199 + static struct platform_driver gpio_tilt_polled_driver = { 200 + .probe = gpio_tilt_polled_probe, 201 + .remove = __devexit_p(gpio_tilt_polled_remove), 202 + .driver = { 203 + .name = DRV_NAME, 204 + .owner = THIS_MODULE, 205 + }, 206 + }; 207 + 208 + module_platform_driver(gpio_tilt_polled_driver); 209 + 210 + MODULE_LICENSE("GPL v2"); 211 + MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>"); 212 + MODULE_DESCRIPTION("Polled GPIO tilt driver"); 213 + MODULE_ALIAS("platform:" DRV_NAME);
+1 -12
drivers/input/misc/ixp4xx-beeper.c
··· 168 168 .remove = __devexit_p(ixp4xx_spkr_remove), 169 169 .shutdown = ixp4xx_spkr_shutdown, 170 170 }; 171 + module_platform_driver(ixp4xx_spkr_platform_driver); 171 172 172 - static int __init ixp4xx_spkr_init(void) 173 - { 174 - return platform_driver_register(&ixp4xx_spkr_platform_driver); 175 - } 176 - 177 - static void __exit ixp4xx_spkr_exit(void) 178 - { 179 - platform_driver_unregister(&ixp4xx_spkr_platform_driver); 180 - } 181 - 182 - module_init(ixp4xx_spkr_init); 183 - module_exit(ixp4xx_spkr_exit);
+1 -12
drivers/input/misc/max8925_onkey.c
··· 166 166 .probe = max8925_onkey_probe, 167 167 .remove = __devexit_p(max8925_onkey_remove), 168 168 }; 169 - 170 - static int __init max8925_onkey_init(void) 171 - { 172 - return platform_driver_register(&max8925_onkey_driver); 173 - } 174 - module_init(max8925_onkey_init); 175 - 176 - static void __exit max8925_onkey_exit(void) 177 - { 178 - platform_driver_unregister(&max8925_onkey_driver); 179 - } 180 - module_exit(max8925_onkey_exit); 169 + module_platform_driver(max8925_onkey_driver); 181 170 182 171 MODULE_DESCRIPTION("Maxim MAX8925 ONKEY driver"); 183 172 MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
+2 -12
drivers/input/misc/mc13783-pwrbutton.c
··· 255 255 return 0; 256 256 } 257 257 258 - struct platform_driver mc13783_pwrbutton_driver = { 258 + static struct platform_driver mc13783_pwrbutton_driver = { 259 259 .probe = mc13783_pwrbutton_probe, 260 260 .remove = __devexit_p(mc13783_pwrbutton_remove), 261 261 .driver = { ··· 264 264 }, 265 265 }; 266 266 267 - static int __init mc13783_pwrbutton_init(void) 268 - { 269 - return platform_driver_register(&mc13783_pwrbutton_driver); 270 - } 271 - module_init(mc13783_pwrbutton_init); 272 - 273 - static void __exit mc13783_pwrbutton_exit(void) 274 - { 275 - platform_driver_unregister(&mc13783_pwrbutton_driver); 276 - } 277 - module_exit(mc13783_pwrbutton_exit); 267 + module_platform_driver(mc13783_pwrbutton_driver); 278 268 279 269 MODULE_ALIAS("platform:mc13783-pwrbutton"); 280 270 MODULE_DESCRIPTION("MC13783 Power Button");
+122 -6
drivers/input/misc/mpu3050.c
··· 41 41 #include <linux/slab.h> 42 42 #include <linux/pm_runtime.h> 43 43 44 - #define MPU3050_CHIP_ID_REG 0x00 45 44 #define MPU3050_CHIP_ID 0x69 46 - #define MPU3050_XOUT_H 0x1D 47 - #define MPU3050_PWR_MGM 0x3E 48 - #define MPU3050_PWR_MGM_POS 6 49 - #define MPU3050_PWR_MGM_MASK 0x40 50 45 51 46 #define MPU3050_AUTO_DELAY 1000 52 47 53 48 #define MPU3050_MIN_VALUE -32768 54 49 #define MPU3050_MAX_VALUE 32767 50 + 51 + #define MPU3050_DEFAULT_POLL_INTERVAL 200 52 + #define MPU3050_DEFAULT_FS_RANGE 3 53 + 54 + /* Register map */ 55 + #define MPU3050_CHIP_ID_REG 0x00 56 + #define MPU3050_SMPLRT_DIV 0x15 57 + #define MPU3050_DLPF_FS_SYNC 0x16 58 + #define MPU3050_INT_CFG 0x17 59 + #define MPU3050_XOUT_H 0x1D 60 + #define MPU3050_PWR_MGM 0x3E 61 + #define MPU3050_PWR_MGM_POS 6 62 + 63 + /* Register bits */ 64 + 65 + /* DLPF_FS_SYNC */ 66 + #define MPU3050_EXT_SYNC_NONE 0x00 67 + #define MPU3050_EXT_SYNC_TEMP 0x20 68 + #define MPU3050_EXT_SYNC_GYROX 0x40 69 + #define MPU3050_EXT_SYNC_GYROY 0x60 70 + #define MPU3050_EXT_SYNC_GYROZ 0x80 71 + #define MPU3050_EXT_SYNC_ACCELX 0xA0 72 + #define MPU3050_EXT_SYNC_ACCELY 0xC0 73 + #define MPU3050_EXT_SYNC_ACCELZ 0xE0 74 + #define MPU3050_EXT_SYNC_MASK 0xE0 75 + #define MPU3050_FS_250DPS 0x00 76 + #define MPU3050_FS_500DPS 0x08 77 + #define MPU3050_FS_1000DPS 0x10 78 + #define MPU3050_FS_2000DPS 0x18 79 + #define MPU3050_FS_MASK 0x18 80 + #define MPU3050_DLPF_CFG_256HZ_NOLPF2 0x00 81 + #define MPU3050_DLPF_CFG_188HZ 0x01 82 + #define MPU3050_DLPF_CFG_98HZ 0x02 83 + #define MPU3050_DLPF_CFG_42HZ 0x03 84 + #define MPU3050_DLPF_CFG_20HZ 0x04 85 + #define MPU3050_DLPF_CFG_10HZ 0x05 86 + #define MPU3050_DLPF_CFG_5HZ 0x06 87 + #define MPU3050_DLPF_CFG_2100HZ_NOLPF 0x07 88 + #define MPU3050_DLPF_CFG_MASK 0x07 89 + /* INT_CFG */ 90 + #define MPU3050_RAW_RDY_EN 0x01 91 + #define MPU3050_MPU_RDY_EN 0x02 92 + #define MPU3050_LATCH_INT_EN 0x04 93 + /* PWR_MGM */ 94 + #define MPU3050_PWR_MGM_PLL_X 0x01 95 + #define MPU3050_PWR_MGM_PLL_Y 0x02 96 + #define MPU3050_PWR_MGM_PLL_Z 0x03 97 + #define MPU3050_PWR_MGM_CLKSEL 0x07 98 + #define MPU3050_PWR_MGM_STBY_ZG 0x08 99 + #define MPU3050_PWR_MGM_STBY_YG 0x10 100 + #define MPU3050_PWR_MGM_STBY_XG 0x20 101 + #define MPU3050_PWR_MGM_SLEEP 0x40 102 + #define MPU3050_PWR_MGM_RESET 0x80 103 + #define MPU3050_PWR_MGM_MASK 0x40 55 104 56 105 struct axis_data { 57 106 s16 x; ··· 197 148 static int mpu3050_input_open(struct input_dev *input) 198 149 { 199 150 struct mpu3050_sensor *sensor = input_get_drvdata(input); 151 + int error; 200 152 201 153 pm_runtime_get(sensor->dev); 154 + 155 + /* Enable interrupts */ 156 + error = i2c_smbus_write_byte_data(sensor->client, MPU3050_INT_CFG, 157 + MPU3050_LATCH_INT_EN | 158 + MPU3050_RAW_RDY_EN | 159 + MPU3050_MPU_RDY_EN); 160 + if (error < 0) { 161 + pm_runtime_put(sensor->dev); 162 + return error; 163 + } 202 164 203 165 return 0; 204 166 } ··· 249 189 input_sync(sensor->idev); 250 190 251 191 return IRQ_HANDLED; 192 + } 193 + 194 + /** 195 + * mpu3050_hw_init - initialize hardware 196 + * @sensor: the sensor 197 + * 198 + * Called during device probe; configures the sampling method. 199 + */ 200 + static int __devinit mpu3050_hw_init(struct mpu3050_sensor *sensor) 201 + { 202 + struct i2c_client *client = sensor->client; 203 + int ret; 204 + u8 reg; 205 + 206 + /* Reset */ 207 + ret = i2c_smbus_write_byte_data(client, MPU3050_PWR_MGM, 208 + MPU3050_PWR_MGM_RESET); 209 + if (ret < 0) 210 + return ret; 211 + 212 + ret = i2c_smbus_read_byte_data(client, MPU3050_PWR_MGM); 213 + if (ret < 0) 214 + return ret; 215 + 216 + ret &= ~MPU3050_PWR_MGM_CLKSEL; 217 + ret |= MPU3050_PWR_MGM_PLL_Z; 218 + ret = i2c_smbus_write_byte_data(client, MPU3050_PWR_MGM, ret); 219 + if (ret < 0) 220 + return ret; 221 + 222 + /* Output frequency divider. The poll interval */ 223 + ret = i2c_smbus_write_byte_data(client, MPU3050_SMPLRT_DIV, 224 + MPU3050_DEFAULT_POLL_INTERVAL - 1); 225 + if (ret < 0) 226 + return ret; 227 + 228 + /* Set low pass filter and full scale */ 229 + reg = MPU3050_DEFAULT_FS_RANGE; 230 + reg |= MPU3050_DLPF_CFG_42HZ << 3; 231 + reg |= MPU3050_EXT_SYNC_NONE << 5; 232 + ret = i2c_smbus_write_byte_data(client, MPU3050_DLPF_FS_SYNC, reg); 233 + if (ret < 0) 234 + return ret; 235 + 236 + return 0; 252 237 } 253 238 254 239 /** ··· 361 256 362 257 pm_runtime_set_active(&client->dev); 363 258 259 + error = mpu3050_hw_init(sensor); 260 + if (error) 261 + goto err_pm_set_suspended; 262 + 364 263 error = request_threaded_irq(client->irq, 365 264 NULL, mpu3050_interrupt_thread, 366 265 IRQF_TRIGGER_RISING, 367 - "mpu_int", sensor); 266 + "mpu3050", sensor); 368 267 if (error) { 369 268 dev_err(&client->dev, 370 269 "can't get IRQ %d, error %d\n", client->irq, error); ··· 457 348 }; 458 349 MODULE_DEVICE_TABLE(i2c, mpu3050_ids); 459 350 351 + static const struct of_device_id mpu3050_of_match[] = { 352 + { .compatible = "invn,mpu3050", }, 353 + { }, 354 + }; 355 + MODULE_DEVICE_TABLE(of, mpu3050_of_match); 356 + 460 357 static struct i2c_driver mpu3050_i2c_driver = { 461 358 .driver = { 462 359 .name = "mpu3050", 463 360 .owner = THIS_MODULE, 464 361 .pm = &mpu3050_pm, 362 + .of_match_table = mpu3050_of_match, 465 363 }, 466 364 .probe = mpu3050_probe, 467 365 .remove = __devexit_p(mpu3050_remove),
+1 -13
drivers/input/misc/pcap_keys.c
··· 125 125 .owner = THIS_MODULE, 126 126 } 127 127 }; 128 - 129 - static int __init pcap_keys_init(void) 130 - { 131 - return platform_driver_register(&pcap_keys_device_driver); 132 - }; 133 - 134 - static void __exit pcap_keys_exit(void) 135 - { 136 - platform_driver_unregister(&pcap_keys_device_driver); 137 - }; 138 - 139 - module_init(pcap_keys_init); 140 - module_exit(pcap_keys_exit); 128 + module_platform_driver(pcap_keys_device_driver); 141 129 142 130 MODULE_DESCRIPTION("Motorola PCAP2 input events driver"); 143 131 MODULE_AUTHOR("Ilya Petrov <ilya.muromec@gmail.com>");
+1 -12
drivers/input/misc/pcf50633-input.c
··· 113 113 .probe = pcf50633_input_probe, 114 114 .remove = __devexit_p(pcf50633_input_remove), 115 115 }; 116 - 117 - static int __init pcf50633_input_init(void) 118 - { 119 - return platform_driver_register(&pcf50633_input_driver); 120 - } 121 - module_init(pcf50633_input_init); 122 - 123 - static void __exit pcf50633_input_exit(void) 124 - { 125 - platform_driver_unregister(&pcf50633_input_driver); 126 - } 127 - module_exit(pcf50633_input_exit); 116 + module_platform_driver(pcf50633_input_driver); 128 117 129 118 MODULE_AUTHOR("Balaji Rao <balajirrao@openmoko.org>"); 130 119 MODULE_DESCRIPTION("PCF50633 input driver");
+1 -13
drivers/input/misc/pcspkr.c
··· 134 134 .remove = __devexit_p(pcspkr_remove), 135 135 .shutdown = pcspkr_shutdown, 136 136 }; 137 + module_platform_driver(pcspkr_platform_driver); 137 138 138 - 139 - static int __init pcspkr_init(void) 140 - { 141 - return platform_driver_register(&pcspkr_platform_driver); 142 - } 143 - 144 - static void __exit pcspkr_exit(void) 145 - { 146 - platform_driver_unregister(&pcspkr_platform_driver); 147 - } 148 - 149 - module_init(pcspkr_init); 150 - module_exit(pcspkr_exit);
+1 -12
drivers/input/misc/pm8xxx-vibrator.c
··· 277 277 .pm = &pm8xxx_vib_pm_ops, 278 278 }, 279 279 }; 280 - 281 - static int __init pm8xxx_vib_init(void) 282 - { 283 - return platform_driver_register(&pm8xxx_vib_driver); 284 - } 285 - module_init(pm8xxx_vib_init); 286 - 287 - static void __exit pm8xxx_vib_exit(void) 288 - { 289 - platform_driver_unregister(&pm8xxx_vib_driver); 290 - } 291 - module_exit(pm8xxx_vib_exit); 280 + module_platform_driver(pm8xxx_vib_driver); 292 281 293 282 MODULE_ALIAS("platform:pm8xxx_vib"); 294 283 MODULE_DESCRIPTION("PMIC8xxx vibrator driver based on ff-memless framework");
+1 -12
drivers/input/misc/pmic8xxx-pwrkey.c
··· 213 213 .pm = &pm8xxx_pwr_key_pm_ops, 214 214 }, 215 215 }; 216 - 217 - static int __init pmic8xxx_pwrkey_init(void) 218 - { 219 - return platform_driver_register(&pmic8xxx_pwrkey_driver); 220 - } 221 - module_init(pmic8xxx_pwrkey_init); 222 - 223 - static void __exit pmic8xxx_pwrkey_exit(void) 224 - { 225 - platform_driver_unregister(&pmic8xxx_pwrkey_driver); 226 - } 227 - module_exit(pmic8xxx_pwrkey_exit); 216 + module_platform_driver(pmic8xxx_pwrkey_driver); 228 217 229 218 MODULE_ALIAS("platform:pmic8xxx_pwrkey"); 230 219 MODULE_DESCRIPTION("PMIC8XXX Power Key driver");
+1 -12
drivers/input/misc/pwm-beeper.c
··· 180 180 .pm = PWM_BEEPER_PM_OPS, 181 181 }, 182 182 }; 183 - 184 - static int __init pwm_beeper_init(void) 185 - { 186 - return platform_driver_register(&pwm_beeper_driver); 187 - } 188 - module_init(pwm_beeper_init); 189 - 190 - static void __exit pwm_beeper_exit(void) 191 - { 192 - platform_driver_unregister(&pwm_beeper_driver); 193 - } 194 - module_exit(pwm_beeper_exit); 183 + module_platform_driver(pwm_beeper_driver); 195 184 196 185 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>"); 197 186 MODULE_DESCRIPTION("PWM beeper driver");
+1 -13
drivers/input/misc/rb532_button.c
··· 100 100 .owner = THIS_MODULE, 101 101 }, 102 102 }; 103 - 104 - static int __init rb532_button_init(void) 105 - { 106 - return platform_driver_register(&rb532_button_driver); 107 - } 108 - 109 - static void __exit rb532_button_exit(void) 110 - { 111 - platform_driver_unregister(&rb532_button_driver); 112 - } 113 - 114 - module_init(rb532_button_init); 115 - module_exit(rb532_button_exit); 103 + module_platform_driver(rb532_button_driver); 116 104 117 105 MODULE_AUTHOR("Phil Sutter <n0-1@freewrt.org>"); 118 106 MODULE_LICENSE("GPL");
+1 -13
drivers/input/misc/rotary_encoder.c
··· 284 284 .owner = THIS_MODULE, 285 285 } 286 286 }; 287 - 288 - static int __init rotary_encoder_init(void) 289 - { 290 - return platform_driver_register(&rotary_encoder_driver); 291 - } 292 - 293 - static void __exit rotary_encoder_exit(void) 294 - { 295 - platform_driver_unregister(&rotary_encoder_driver); 296 - } 297 - 298 - module_init(rotary_encoder_init); 299 - module_exit(rotary_encoder_exit); 287 + module_platform_driver(rotary_encoder_driver); 300 288 301 289 MODULE_ALIAS("platform:" DRV_NAME); 302 290 MODULE_DESCRIPTION("GPIO rotary encoder driver");
+1 -12
drivers/input/misc/sgi_btns.c
··· 164 164 .owner = THIS_MODULE, 165 165 }, 166 166 }; 167 - 168 - static int __init sgi_buttons_init(void) 169 - { 170 - return platform_driver_register(&sgi_buttons_driver); 171 - } 172 - 173 - static void __exit sgi_buttons_exit(void) 174 - { 175 - platform_driver_unregister(&sgi_buttons_driver); 176 - } 167 + module_platform_driver(sgi_buttons_driver); 177 168 178 169 MODULE_LICENSE("GPL"); 179 - module_init(sgi_buttons_init); 180 - module_exit(sgi_buttons_exit);
+2 -13
drivers/input/misc/twl4030-pwrbutton.c
··· 107 107 } 108 108 109 109 static struct platform_driver twl4030_pwrbutton_driver = { 110 + .probe = twl4030_pwrbutton_probe, 110 111 .remove = __exit_p(twl4030_pwrbutton_remove), 111 112 .driver = { 112 113 .name = "twl4030_pwrbutton", 113 114 .owner = THIS_MODULE, 114 115 }, 115 116 }; 116 - 117 - static int __init twl4030_pwrbutton_init(void) 118 - { 119 - return platform_driver_probe(&twl4030_pwrbutton_driver, 120 - twl4030_pwrbutton_probe); 121 - } 122 - module_init(twl4030_pwrbutton_init); 123 - 124 - static void __exit twl4030_pwrbutton_exit(void) 125 - { 126 - platform_driver_unregister(&twl4030_pwrbutton_driver); 127 - } 128 - module_exit(twl4030_pwrbutton_exit); 117 + module_platform_driver(twl4030_pwrbutton_driver); 129 118 130 119 MODULE_ALIAS("platform:twl4030_pwrbutton"); 131 120 MODULE_DESCRIPTION("Triton2 Power Button");
+1 -13
drivers/input/misc/twl4030-vibra.c
··· 278 278 #endif 279 279 }, 280 280 }; 281 - 282 - static int __init twl4030_vibra_init(void) 283 - { 284 - return platform_driver_register(&twl4030_vibra_driver); 285 - } 286 - module_init(twl4030_vibra_init); 287 - 288 - static void __exit twl4030_vibra_exit(void) 289 - { 290 - platform_driver_unregister(&twl4030_vibra_driver); 291 - } 292 - module_exit(twl4030_vibra_exit); 281 + module_platform_driver(twl4030_vibra_driver); 293 282 294 283 MODULE_ALIAS("platform:twl4030-vibra"); 295 - 296 284 MODULE_DESCRIPTION("TWL4030 Vibra driver"); 297 285 MODULE_LICENSE("GPL"); 298 286 MODULE_AUTHOR("Nokia Corporation");
+1 -12
drivers/input/misc/twl6040-vibra.c
··· 410 410 .pm = &twl6040_vibra_pm_ops, 411 411 }, 412 412 }; 413 - 414 - static int __init twl6040_vibra_init(void) 415 - { 416 - return platform_driver_register(&twl6040_vibra_driver); 417 - } 418 - module_init(twl6040_vibra_init); 419 - 420 - static void __exit twl6040_vibra_exit(void) 421 - { 422 - platform_driver_unregister(&twl6040_vibra_driver); 423 - } 424 - module_exit(twl6040_vibra_exit); 413 + module_platform_driver(twl6040_vibra_driver); 425 414 426 415 MODULE_ALIAS("platform:twl6040-vibra"); 427 416 MODULE_DESCRIPTION("TWL6040 Vibra driver");
+1 -12
drivers/input/misc/wm831x-on.c
··· 145 145 .owner = THIS_MODULE, 146 146 }, 147 147 }; 148 - 149 - static int __init wm831x_on_init(void) 150 - { 151 - return platform_driver_register(&wm831x_on_driver); 152 - } 153 - module_init(wm831x_on_init); 154 - 155 - static void __exit wm831x_on_exit(void) 156 - { 157 - platform_driver_unregister(&wm831x_on_driver); 158 - } 159 - module_exit(wm831x_on_exit); 148 + module_platform_driver(wm831x_on_driver); 160 149 161 150 MODULE_ALIAS("platform:wm831x-on"); 162 151 MODULE_DESCRIPTION("WM831x ON pin");
+955 -81
drivers/input/mouse/alps.c
··· 17 17 18 18 #include <linux/slab.h> 19 19 #include <linux/input.h> 20 + #include <linux/input/mt.h> 20 21 #include <linux/serio.h> 21 22 #include <linux/libps2.h> 22 23 23 24 #include "psmouse.h" 24 25 #include "alps.h" 25 26 26 - #define ALPS_OLDPROTO 0x01 /* old style input */ 27 + /* 28 + * Definitions for ALPS version 3 and 4 command mode protocol 29 + */ 30 + #define ALPS_V3_X_MAX 2000 31 + #define ALPS_V3_Y_MAX 1400 32 + 33 + #define ALPS_BITMAP_X_BITS 15 34 + #define ALPS_BITMAP_Y_BITS 11 35 + 36 + #define ALPS_CMD_NIBBLE_10 0x01f2 37 + 38 + static const struct alps_nibble_commands alps_v3_nibble_commands[] = { 39 + { PSMOUSE_CMD_SETPOLL, 0x00 }, /* 0 */ 40 + { PSMOUSE_CMD_RESET_DIS, 0x00 }, /* 1 */ 41 + { PSMOUSE_CMD_SETSCALE21, 0x00 }, /* 2 */ 42 + { PSMOUSE_CMD_SETRATE, 0x0a }, /* 3 */ 43 + { PSMOUSE_CMD_SETRATE, 0x14 }, /* 4 */ 44 + { PSMOUSE_CMD_SETRATE, 0x28 }, /* 5 */ 45 + { PSMOUSE_CMD_SETRATE, 0x3c }, /* 6 */ 46 + { PSMOUSE_CMD_SETRATE, 0x50 }, /* 7 */ 47 + { PSMOUSE_CMD_SETRATE, 0x64 }, /* 8 */ 48 + { PSMOUSE_CMD_SETRATE, 0xc8 }, /* 9 */ 49 + { ALPS_CMD_NIBBLE_10, 0x00 }, /* a */ 50 + { PSMOUSE_CMD_SETRES, 0x00 }, /* b */ 51 + { PSMOUSE_CMD_SETRES, 0x01 }, /* c */ 52 + { PSMOUSE_CMD_SETRES, 0x02 }, /* d */ 53 + { PSMOUSE_CMD_SETRES, 0x03 }, /* e */ 54 + { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */ 55 + }; 56 + 57 + static const struct alps_nibble_commands alps_v4_nibble_commands[] = { 58 + { PSMOUSE_CMD_ENABLE, 0x00 }, /* 0 */ 59 + { PSMOUSE_CMD_RESET_DIS, 0x00 }, /* 1 */ 60 + { PSMOUSE_CMD_SETSCALE21, 0x00 }, /* 2 */ 61 + { PSMOUSE_CMD_SETRATE, 0x0a }, /* 3 */ 62 + { PSMOUSE_CMD_SETRATE, 0x14 }, /* 4 */ 63 + { PSMOUSE_CMD_SETRATE, 0x28 }, /* 5 */ 64 + { PSMOUSE_CMD_SETRATE, 0x3c }, /* 6 */ 65 + { PSMOUSE_CMD_SETRATE, 0x50 }, /* 7 */ 66 + { PSMOUSE_CMD_SETRATE, 0x64 }, /* 8 */ 67 + { PSMOUSE_CMD_SETRATE, 0xc8 }, /* 9 */ 68 + { ALPS_CMD_NIBBLE_10, 0x00 }, /* a */ 69 + { PSMOUSE_CMD_SETRES, 0x00 }, /* b */ 70 + { PSMOUSE_CMD_SETRES, 0x01 }, /* c */ 71 + { PSMOUSE_CMD_SETRES, 0x02 }, /* d */ 72 + { PSMOUSE_CMD_SETRES, 0x03 }, /* e */ 73 + { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */ 74 + }; 75 + 76 + 27 77 #define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */ 28 78 #define ALPS_PASS 0x04 /* device has a pass-through port */ 29 79 ··· 85 35 6-byte ALPS packet */ 86 36 87 37 static const struct alps_model_info alps_model_data[] = { 88 - { { 0x32, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */ 89 - { { 0x33, 0x02, 0x0a }, 0x88, 0xf8, ALPS_OLDPROTO }, /* UMAX-530T */ 90 - { { 0x53, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, 91 - { { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, 92 - { { 0x60, 0x03, 0xc8 }, 0xf8, 0xf8, 0 }, /* HP ze1115 */ 93 - { { 0x63, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, 94 - { { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, 95 - { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */ 96 - { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */ 97 - { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */ 98 - { { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 }, 99 - { { 0x63, 0x03, 0xc8 }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D800 */ 100 - { { 0x73, 0x00, 0x0a }, 0xf8, 0xf8, ALPS_DUALPOINT }, /* ThinkPad R61 8918-5QG */ 101 - { { 0x73, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, 102 - { { 0x73, 0x02, 0x14 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */ 103 - { { 0x20, 0x02, 0x0e }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ 104 - { { 0x22, 0x02, 0x0a }, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, 105 - { { 0x22, 0x02, 0x14 }, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ 38 + { { 0x32, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Toshiba Salellite Pro M10 */ 39 + { { 0x33, 0x02, 0x0a }, 0x00, ALPS_PROTO_V1, 0x88, 0xf8, 0 }, /* UMAX-530T */ 40 + { { 0x53, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, 41 + { { 0x53, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, 42 + { { 0x60, 0x03, 0xc8 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, /* HP ze1115 */ 43 + { { 0x63, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, 44 + { { 0x63, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, 45 + { { 0x63, 0x02, 0x28 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */ 46 + { { 0x63, 0x02, 0x3c }, 0x00, ALPS_PROTO_V2, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */ 47 + { { 0x63, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */ 48 + { { 0x63, 0x02, 0x64 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, 49 + { { 0x63, 0x03, 0xc8 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D800 */ 50 + { { 0x73, 0x00, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_DUALPOINT }, /* ThinkPad R61 8918-5QG */ 51 + { { 0x73, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, 0 }, 52 + { { 0x73, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Ahtec Laptop */ 53 + { { 0x20, 0x02, 0x0e }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, /* XXX */ 54 + { { 0x22, 0x02, 0x0a }, 0x00, ALPS_PROTO_V2, 0xf8, 0xf8, ALPS_PASS | ALPS_DUALPOINT }, 55 + { { 0x22, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, ALPS_PASS | ALPS_DUALPOINT }, /* Dell Latitude D600 */ 106 56 /* Dell Latitude E5500, E6400, E6500, Precision M4400 */ 107 - { { 0x62, 0x02, 0x14 }, 0xcf, 0xcf, 57 + { { 0x62, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, 108 58 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, 109 - { { 0x73, 0x02, 0x50 }, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */ 110 - { { 0x52, 0x01, 0x14 }, 0xff, 0xff, 111 - ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */ 59 + { { 0x73, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */ 60 + { { 0x52, 0x01, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, 61 + ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */ 62 + { { 0x73, 0x02, 0x64 }, 0x9b, ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT }, 63 + { { 0x73, 0x02, 0x64 }, 0x9d, ALPS_PROTO_V3, 0x8f, 0x8f, ALPS_DUALPOINT }, 64 + { { 0x73, 0x02, 0x64 }, 0x8a, ALPS_PROTO_V4, 0x8f, 0x8f, 0 }, 112 65 }; 113 66 114 67 /* ··· 120 67 * isn't valid per PS/2 spec. 121 68 */ 122 69 123 - /* 124 - * PS/2 packet format 125 - * 126 - * byte 0: 0 0 YSGN XSGN 1 M R L 127 - * byte 1: X7 X6 X5 X4 X3 X2 X1 X0 128 - * byte 2: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 129 - * 130 - * Note that the device never signals overflow condition. 131 - * 132 - * ALPS absolute Mode - new format 133 - * 134 - * byte 0: 1 ? ? ? 1 ? ? ? 135 - * byte 1: 0 x6 x5 x4 x3 x2 x1 x0 136 - * byte 2: 0 x10 x9 x8 x7 ? fin ges 137 - * byte 3: 0 y9 y8 y7 1 M R L 138 - * byte 4: 0 y6 y5 y4 y3 y2 y1 y0 139 - * byte 5: 0 z6 z5 z4 z3 z2 z1 z0 140 - * 141 - * Dualpoint device -- interleaved packet format 142 - * 143 - * byte 0: 1 1 0 0 1 1 1 1 144 - * byte 1: 0 x6 x5 x4 x3 x2 x1 x0 145 - * byte 2: 0 x10 x9 x8 x7 0 fin ges 146 - * byte 3: 0 0 YSGN XSGN 1 1 1 1 147 - * byte 4: X7 X6 X5 X4 X3 X2 X1 X0 148 - * byte 5: Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 149 - * byte 6: 0 y9 y8 y7 1 m r l 150 - * byte 7: 0 y6 y5 y4 y3 y2 y1 y0 151 - * byte 8: 0 z6 z5 z4 z3 z2 z1 z0 152 - * 153 - * CAPITALS = stick, miniscules = touchpad 154 - * 155 - * ?'s can have different meanings on different models, 156 - * such as wheel rotation, extra buttons, stick buttons 157 - * on a dualpoint, etc. 158 - */ 70 + /* Packet formats are described in Documentation/input/alps.txt */ 159 71 160 72 static bool alps_is_valid_first_byte(const struct alps_model_info *model, 161 73 unsigned char data) ··· 155 137 input_sync(dev2); 156 138 } 157 139 158 - static void alps_process_packet(struct psmouse *psmouse) 140 + static void alps_process_packet_v1_v2(struct psmouse *psmouse) 159 141 { 160 142 struct alps_data *priv = psmouse->private; 161 143 const struct alps_model_info *model = priv->i; ··· 165 147 int x, y, z, ges, fin, left, right, middle; 166 148 int back = 0, forward = 0; 167 149 168 - if (model->flags & ALPS_OLDPROTO) { 150 + if (model->proto_version == ALPS_PROTO_V1) { 169 151 left = packet[2] & 0x10; 170 152 right = packet[2] & 0x08; 171 153 middle = 0; ··· 255 237 } 256 238 257 239 input_sync(dev); 240 + } 241 + 242 + /* 243 + * Process bitmap data from v3 and v4 protocols. Returns the number of 244 + * fingers detected. A return value of 0 means at least one of the 245 + * bitmaps was empty. 246 + * 247 + * The bitmaps don't have enough data to track fingers, so this function 248 + * only generates points representing a bounding box of all contacts. 249 + * These points are returned in x1, y1, x2, and y2 when the return value 250 + * is greater than 0. 251 + */ 252 + static int alps_process_bitmap(unsigned int x_map, unsigned int y_map, 253 + int *x1, int *y1, int *x2, int *y2) 254 + { 255 + struct alps_bitmap_point { 256 + int start_bit; 257 + int num_bits; 258 + }; 259 + 260 + int fingers_x = 0, fingers_y = 0, fingers; 261 + int i, bit, prev_bit; 262 + struct alps_bitmap_point x_low = {0,}, x_high = {0,}; 263 + struct alps_bitmap_point y_low = {0,}, y_high = {0,}; 264 + struct alps_bitmap_point *point; 265 + 266 + if (!x_map || !y_map) 267 + return 0; 268 + 269 + *x1 = *y1 = *x2 = *y2 = 0; 270 + 271 + prev_bit = 0; 272 + point = &x_low; 273 + for (i = 0; x_map != 0; i++, x_map >>= 1) { 274 + bit = x_map & 1; 275 + if (bit) { 276 + if (!prev_bit) { 277 + point->start_bit = i; 278 + fingers_x++; 279 + } 280 + point->num_bits++; 281 + } else { 282 + if (prev_bit) 283 + point = &x_high; 284 + else 285 + point->num_bits = 0; 286 + } 287 + prev_bit = bit; 288 + } 289 + 290 + /* 291 + * y bitmap is reversed for what we need (lower positions are in 292 + * higher bits), so we process from the top end. 293 + */ 294 + y_map = y_map << (sizeof(y_map) * BITS_PER_BYTE - ALPS_BITMAP_Y_BITS); 295 + prev_bit = 0; 296 + point = &y_low; 297 + for (i = 0; y_map != 0; i++, y_map <<= 1) { 298 + bit = y_map & (1 << (sizeof(y_map) * BITS_PER_BYTE - 1)); 299 + if (bit) { 300 + if (!prev_bit) { 301 + point->start_bit = i; 302 + fingers_y++; 303 + } 304 + point->num_bits++; 305 + } else { 306 + if (prev_bit) 307 + point = &y_high; 308 + else 309 + point->num_bits = 0; 310 + } 311 + prev_bit = bit; 312 + } 313 + 314 + /* 315 + * Fingers can overlap, so we use the maximum count of fingers 316 + * on either axis as the finger count. 317 + */ 318 + fingers = max(fingers_x, fingers_y); 319 + 320 + /* 321 + * If total fingers is > 1 but either axis reports only a single 322 + * contact, we have overlapping or adjacent fingers. For the 323 + * purposes of creating a bounding box, divide the single contact 324 + * (roughly) equally between the two points. 325 + */ 326 + if (fingers > 1) { 327 + if (fingers_x == 1) { 328 + i = x_low.num_bits / 2; 329 + x_low.num_bits = x_low.num_bits - i; 330 + x_high.start_bit = x_low.start_bit + i; 331 + x_high.num_bits = max(i, 1); 332 + } else if (fingers_y == 1) { 333 + i = y_low.num_bits / 2; 334 + y_low.num_bits = y_low.num_bits - i; 335 + y_high.start_bit = y_low.start_bit + i; 336 + y_high.num_bits = max(i, 1); 337 + } 338 + } 339 + 340 + *x1 = (ALPS_V3_X_MAX * (2 * x_low.start_bit + x_low.num_bits - 1)) / 341 + (2 * (ALPS_BITMAP_X_BITS - 1)); 342 + *y1 = (ALPS_V3_Y_MAX * (2 * y_low.start_bit + y_low.num_bits - 1)) / 343 + (2 * (ALPS_BITMAP_Y_BITS - 1)); 344 + 345 + if (fingers > 1) { 346 + *x2 = (ALPS_V3_X_MAX * (2 * x_high.start_bit + x_high.num_bits - 1)) / 347 + (2 * (ALPS_BITMAP_X_BITS - 1)); 348 + *y2 = (ALPS_V3_Y_MAX * (2 * y_high.start_bit + y_high.num_bits - 1)) / 349 + (2 * (ALPS_BITMAP_Y_BITS - 1)); 350 + } 351 + 352 + return fingers; 353 + } 354 + 355 + static void alps_set_slot(struct input_dev *dev, int slot, bool active, 356 + int x, int y) 357 + { 358 + input_mt_slot(dev, slot); 359 + input_mt_report_slot_state(dev, MT_TOOL_FINGER, active); 360 + if (active) { 361 + input_report_abs(dev, ABS_MT_POSITION_X, x); 362 + input_report_abs(dev, ABS_MT_POSITION_Y, y); 363 + } 364 + } 365 + 366 + static void alps_report_semi_mt_data(struct input_dev *dev, int num_fingers, 367 + int x1, int y1, int x2, int y2) 368 + { 369 + alps_set_slot(dev, 0, num_fingers != 0, x1, y1); 370 + alps_set_slot(dev, 1, num_fingers == 2, x2, y2); 371 + } 372 + 373 + static void alps_process_trackstick_packet_v3(struct psmouse *psmouse) 374 + { 375 + struct alps_data *priv = psmouse->private; 376 + unsigned char *packet = psmouse->packet; 377 + struct input_dev *dev = priv->dev2; 378 + int x, y, z, left, right, middle; 379 + 380 + /* Sanity check packet */ 381 + if (!(packet[0] & 0x40)) { 382 + psmouse_dbg(psmouse, "Bad trackstick packet, discarding\n"); 383 + return; 384 + } 385 + 386 + /* 387 + * There's a special packet that seems to indicate the end 388 + * of a stream of trackstick data. Filter these out. 389 + */ 390 + if (packet[1] == 0x7f && packet[2] == 0x7f && packet[4] == 0x7f) 391 + return; 392 + 393 + x = (s8)(((packet[0] & 0x20) << 2) | (packet[1] & 0x7f)); 394 + y = (s8)(((packet[0] & 0x10) << 3) | (packet[2] & 0x7f)); 395 + z = (packet[4] & 0x7c) >> 2; 396 + 397 + /* 398 + * The x and y values tend to be quite large, and when used 399 + * alone the trackstick is difficult to use. Scale them down 400 + * to compensate. 401 + */ 402 + x /= 8; 403 + y /= 8; 404 + 405 + input_report_rel(dev, REL_X, x); 406 + input_report_rel(dev, REL_Y, -y); 407 + 408 + /* 409 + * Most ALPS models report the trackstick buttons in the touchpad 410 + * packets, but a few report them here. No reliable way has been 411 + * found to differentiate between the models upfront, so we enable 412 + * the quirk in response to seeing a button press in the trackstick 413 + * packet. 414 + */ 415 + left = packet[3] & 0x01; 416 + right = packet[3] & 0x02; 417 + middle = packet[3] & 0x04; 418 + 419 + if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) && 420 + (left || right || middle)) 421 + priv->quirks |= ALPS_QUIRK_TRACKSTICK_BUTTONS; 422 + 423 + if (priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS) { 424 + input_report_key(dev, BTN_LEFT, left); 425 + input_report_key(dev, BTN_RIGHT, right); 426 + input_report_key(dev, BTN_MIDDLE, middle); 427 + } 428 + 429 + input_sync(dev); 430 + return; 431 + } 432 + 433 + static void alps_process_touchpad_packet_v3(struct psmouse *psmouse) 434 + { 435 + struct alps_data *priv = psmouse->private; 436 + unsigned char *packet = psmouse->packet; 437 + struct input_dev *dev = psmouse->dev; 438 + struct input_dev *dev2 = priv->dev2; 439 + int x, y, z; 440 + int left, right, middle; 441 + int x1 = 0, y1 = 0, x2 = 0, y2 = 0; 442 + int fingers = 0, bmap_fingers; 443 + unsigned int x_bitmap, y_bitmap; 444 + 445 + /* 446 + * There's no single feature of touchpad position and bitmap packets 447 + * that can be used to distinguish between them. We rely on the fact 448 + * that a bitmap packet should always follow a position packet with 449 + * bit 6 of packet[4] set. 450 + */ 451 + if (priv->multi_packet) { 452 + /* 453 + * Sometimes a position packet will indicate a multi-packet 454 + * sequence, but then what follows is another position 455 + * packet. Check for this, and when it happens process the 456 + * position packet as usual. 457 + */ 458 + if (packet[0] & 0x40) { 459 + fingers = (packet[5] & 0x3) + 1; 460 + x_bitmap = ((packet[4] & 0x7e) << 8) | 461 + ((packet[1] & 0x7f) << 2) | 462 + ((packet[0] & 0x30) >> 4); 463 + y_bitmap = ((packet[3] & 0x70) << 4) | 464 + ((packet[2] & 0x7f) << 1) | 465 + (packet[4] & 0x01); 466 + 467 + bmap_fingers = alps_process_bitmap(x_bitmap, y_bitmap, 468 + &x1, &y1, &x2, &y2); 469 + 470 + /* 471 + * We shouldn't report more than one finger if 472 + * we don't have two coordinates. 473 + */ 474 + if (fingers > 1 && bmap_fingers < 2) 475 + fingers = bmap_fingers; 476 + 477 + /* Now process position packet */ 478 + packet = priv->multi_data; 479 + } else { 480 + priv->multi_packet = 0; 481 + } 482 + } 483 + 484 + /* 485 + * Bit 6 of byte 0 is not usually set in position packets. The only 486 + * times it seems to be set is in situations where the data is 487 + * suspect anyway, e.g. a palm resting flat on the touchpad. Given 488 + * this combined with the fact that this bit is useful for filtering 489 + * out misidentified bitmap packets, we reject anything with this 490 + * bit set. 491 + */ 492 + if (packet[0] & 0x40) 493 + return; 494 + 495 + if (!priv->multi_packet && (packet[4] & 0x40)) { 496 + priv->multi_packet = 1; 497 + memcpy(priv->multi_data, packet, sizeof(priv->multi_data)); 498 + return; 499 + } 500 + 501 + priv->multi_packet = 0; 502 + 503 + left = packet[3] & 0x01; 504 + right = packet[3] & 0x02; 505 + middle = packet[3] & 0x04; 506 + 507 + x = ((packet[1] & 0x7f) << 4) | ((packet[4] & 0x30) >> 2) | 508 + ((packet[0] & 0x30) >> 4); 509 + y = ((packet[2] & 0x7f) << 4) | (packet[4] & 0x0f); 510 + z = packet[5] & 0x7f; 511 + 512 + /* 513 + * Sometimes the hardware sends a single packet with z = 0 514 + * in the middle of a stream. Real releases generate packets 515 + * with x, y, and z all zero, so these seem to be flukes. 516 + * Ignore them. 517 + */ 518 + if (x && y && !z) 519 + return; 520 + 521 + /* 522 + * If we don't have MT data or the bitmaps were empty, we have 523 + * to rely on ST data. 524 + */ 525 + if (!fingers) { 526 + x1 = x; 527 + y1 = y; 528 + fingers = z > 0 ? 1 : 0; 529 + } 530 + 531 + if (z >= 64) 532 + input_report_key(dev, BTN_TOUCH, 1); 533 + else 534 + input_report_key(dev, BTN_TOUCH, 0); 535 + 536 + alps_report_semi_mt_data(dev, fingers, x1, y1, x2, y2); 537 + 538 + input_report_key(dev, BTN_TOOL_FINGER, fingers == 1); 539 + input_report_key(dev, BTN_TOOL_DOUBLETAP, fingers == 2); 540 + input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3); 541 + input_report_key(dev, BTN_TOOL_QUADTAP, fingers == 4); 542 + 543 + input_report_key(dev, BTN_LEFT, left); 544 + input_report_key(dev, BTN_RIGHT, right); 545 + input_report_key(dev, BTN_MIDDLE, middle); 546 + 547 + if (z > 0) { 548 + input_report_abs(dev, ABS_X, x); 549 + input_report_abs(dev, ABS_Y, y); 550 + } 551 + input_report_abs(dev, ABS_PRESSURE, z); 552 + 553 + input_sync(dev); 554 + 555 + if (!(priv->quirks & ALPS_QUIRK_TRACKSTICK_BUTTONS)) { 556 + left = packet[3] & 0x10; 557 + right = packet[3] & 0x20; 558 + middle = packet[3] & 0x40; 559 + 560 + input_report_key(dev2, BTN_LEFT, left); 561 + input_report_key(dev2, BTN_RIGHT, right); 562 + input_report_key(dev2, BTN_MIDDLE, middle); 563 + input_sync(dev2); 564 + } 565 + } 566 + 567 + static void alps_process_packet_v3(struct psmouse *psmouse) 568 + { 569 + unsigned char *packet = psmouse->packet; 570 + 571 + /* 572 + * v3 protocol packets come in three types, two representing 573 + * touchpad data and one representing trackstick data. 574 + * Trackstick packets seem to be distinguished by always 575 + * having 0x3f in the last byte. This value has never been 576 + * observed in the last byte of either of the other types 577 + * of packets. 578 + */ 579 + if (packet[5] == 0x3f) { 580 + alps_process_trackstick_packet_v3(psmouse); 581 + return; 582 + } 583 + 584 + alps_process_touchpad_packet_v3(psmouse); 585 + } 586 + 587 + static void alps_process_packet_v4(struct psmouse *psmouse) 588 + { 589 + unsigned char *packet = psmouse->packet; 590 + struct input_dev *dev = psmouse->dev; 591 + int x, y, z; 592 + int left, right; 593 + 594 + left = packet[4] & 0x01; 595 + right = packet[4] & 0x02; 596 + 597 + x = ((packet[1] & 0x7f) << 4) | ((packet[3] & 0x30) >> 2) | 598 + ((packet[0] & 0x30) >> 4); 599 + y = ((packet[2] & 0x7f) << 4) | (packet[3] & 0x0f); 600 + z = packet[5] & 0x7f; 601 + 602 + if (z >= 64) 603 + input_report_key(dev, BTN_TOUCH, 1); 604 + else 605 + input_report_key(dev, BTN_TOUCH, 0); 606 + 607 + if (z > 0) { 608 + input_report_abs(dev, ABS_X, x); 609 + input_report_abs(dev, ABS_Y, y); 610 + } 611 + input_report_abs(dev, ABS_PRESSURE, z); 612 + 613 + input_report_key(dev, BTN_TOOL_FINGER, z > 0); 614 + input_report_key(dev, BTN_LEFT, left); 615 + input_report_key(dev, BTN_RIGHT, right); 616 + 617 + input_sync(dev); 618 + } 619 + 620 + static void alps_process_packet(struct psmouse *psmouse) 621 + { 622 + struct alps_data *priv = psmouse->private; 623 + const struct alps_model_info *model = priv->i; 624 + 625 + switch (model->proto_version) { 626 + case ALPS_PROTO_V1: 627 + case ALPS_PROTO_V2: 628 + alps_process_packet_v1_v2(psmouse); 629 + break; 630 + case ALPS_PROTO_V3: 631 + alps_process_packet_v3(psmouse); 632 + break; 633 + case ALPS_PROTO_V4: 634 + alps_process_packet_v4(psmouse); 635 + break; 636 + } 258 637 } 259 638 260 639 static void alps_report_bare_ps2_packet(struct psmouse *psmouse, ··· 759 344 760 345 serio_pause_rx(psmouse->ps2dev.serio); 761 346 762 - if (psmouse->pktcnt == 6) { 347 + if (psmouse->pktcnt == psmouse->pktsize) { 763 348 764 349 /* 765 350 * We did not any more data in reasonable amount of time. ··· 810 395 return PSMOUSE_BAD_DATA; 811 396 } 812 397 813 - /* Bytes 2 - 6 should have 0 in the highest bit */ 814 - if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= 6 && 398 + /* Bytes 2 - pktsize should have 0 in the highest bit */ 399 + if (psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize && 815 400 (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) { 816 401 psmouse_dbg(psmouse, "refusing packet[%i] = %x\n", 817 402 psmouse->pktcnt - 1, ··· 819 404 return PSMOUSE_BAD_DATA; 820 405 } 821 406 822 - if (psmouse->pktcnt == 6) { 407 + if (psmouse->pktcnt == psmouse->pktsize) { 823 408 alps_process_packet(psmouse); 824 409 return PSMOUSE_FULL_PACKET; 825 410 } ··· 827 412 return PSMOUSE_GOOD_DATA; 828 413 } 829 414 415 + static int alps_command_mode_send_nibble(struct psmouse *psmouse, int nibble) 416 + { 417 + struct ps2dev *ps2dev = &psmouse->ps2dev; 418 + struct alps_data *priv = psmouse->private; 419 + int command; 420 + unsigned char *param; 421 + unsigned char dummy[4]; 422 + 423 + BUG_ON(nibble > 0xf); 424 + 425 + command = priv->nibble_commands[nibble].command; 426 + param = (command & 0x0f00) ? 427 + dummy : (unsigned char *)&priv->nibble_commands[nibble].data; 428 + 429 + if (ps2_command(ps2dev, param, command)) 430 + return -1; 431 + 432 + return 0; 433 + } 434 + 435 + static int alps_command_mode_set_addr(struct psmouse *psmouse, int addr) 436 + { 437 + struct ps2dev *ps2dev = &psmouse->ps2dev; 438 + struct alps_data *priv = psmouse->private; 439 + int i, nibble; 440 + 441 + if (ps2_command(ps2dev, NULL, priv->addr_command)) 442 + return -1; 443 + 444 + for (i = 12; i >= 0; i -= 4) { 445 + nibble = (addr >> i) & 0xf; 446 + if (alps_command_mode_send_nibble(psmouse, nibble)) 447 + return -1; 448 + } 449 + 450 + return 0; 451 + } 452 + 453 + static int __alps_command_mode_read_reg(struct psmouse *psmouse, int addr) 454 + { 455 + struct ps2dev *ps2dev = &psmouse->ps2dev; 456 + unsigned char param[4]; 457 + 458 + if (ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) 459 + return -1; 460 + 461 + /* 462 + * The address being read is returned in the first two bytes 463 + * of the result. Check that this address matches the expected 464 + * address. 465 + */ 466 + if (addr != ((param[0] << 8) | param[1])) 467 + return -1; 468 + 469 + return param[2]; 470 + } 471 + 472 + static int alps_command_mode_read_reg(struct psmouse *psmouse, int addr) 473 + { 474 + if (alps_command_mode_set_addr(psmouse, addr)) 475 + return -1; 476 + return __alps_command_mode_read_reg(psmouse, addr); 477 + } 478 + 479 + static int __alps_command_mode_write_reg(struct psmouse *psmouse, u8 value) 480 + { 481 + if (alps_command_mode_send_nibble(psmouse, (value >> 4) & 0xf)) 482 + return -1; 483 + if (alps_command_mode_send_nibble(psmouse, value & 0xf)) 484 + return -1; 485 + return 0; 486 + } 487 + 488 + static int alps_command_mode_write_reg(struct psmouse *psmouse, int addr, 489 + u8 value) 490 + { 491 + if (alps_command_mode_set_addr(psmouse, addr)) 492 + return -1; 493 + return __alps_command_mode_write_reg(psmouse, value); 494 + } 495 + 496 + static int alps_enter_command_mode(struct psmouse *psmouse, 497 + unsigned char *resp) 498 + { 499 + unsigned char param[4]; 500 + struct ps2dev *ps2dev = &psmouse->ps2dev; 501 + 502 + if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) || 503 + ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) || 504 + ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) || 505 + ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { 506 + psmouse_err(psmouse, "failed to enter command mode\n"); 507 + return -1; 508 + } 509 + 510 + if (param[0] != 0x88 && param[1] != 0x07) { 511 + psmouse_dbg(psmouse, 512 + "unknown response while entering command mode: %2.2x %2.2x %2.2x\n", 513 + param[0], param[1], param[2]); 514 + return -1; 515 + } 516 + 517 + if (resp) 518 + *resp = param[2]; 519 + return 0; 520 + } 521 + 522 + static inline int alps_exit_command_mode(struct psmouse *psmouse) 523 + { 524 + struct ps2dev *ps2dev = &psmouse->ps2dev; 525 + if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSTREAM)) 526 + return -1; 527 + return 0; 528 + } 529 + 830 530 static const struct alps_model_info *alps_get_model(struct psmouse *psmouse, int *version) 831 531 { 832 532 struct ps2dev *ps2dev = &psmouse->ps2dev; 833 533 static const unsigned char rates[] = { 0, 10, 20, 40, 60, 80, 100, 200 }; 834 534 unsigned char param[4]; 535 + const struct alps_model_info *model = NULL; 835 536 int i; 836 537 837 538 /* ··· 995 464 *version = (param[0] << 8) | (param[1] << 4) | i; 996 465 } 997 466 998 - for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) 467 + for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) { 999 468 if (!memcmp(param, alps_model_data[i].signature, 1000 - sizeof(alps_model_data[i].signature))) 1001 - return alps_model_data + i; 469 + sizeof(alps_model_data[i].signature))) { 470 + model = alps_model_data + i; 471 + break; 472 + } 473 + } 1002 474 1003 - return NULL; 475 + if (model && model->proto_version > ALPS_PROTO_V2) { 476 + /* 477 + * Need to check command mode response to identify 478 + * model 479 + */ 480 + model = NULL; 481 + if (alps_enter_command_mode(psmouse, param)) { 482 + psmouse_warn(psmouse, 483 + "touchpad failed to enter command mode\n"); 484 + } else { 485 + for (i = 0; i < ARRAY_SIZE(alps_model_data); i++) { 486 + if (alps_model_data[i].proto_version > ALPS_PROTO_V2 && 487 + alps_model_data[i].command_mode_resp == param[0]) { 488 + model = alps_model_data + i; 489 + break; 490 + } 491 + } 492 + alps_exit_command_mode(psmouse); 493 + 494 + if (!model) 495 + psmouse_dbg(psmouse, 496 + "Unknown command mode response %2.2x\n", 497 + param[0]); 498 + } 499 + } 500 + 501 + return model; 1004 502 } 1005 503 1006 504 /* ··· 1037 477 * subsequent commands. It looks like glidepad is behind stickpointer, 1038 478 * I'd thought it would be other way around... 1039 479 */ 1040 - static int alps_passthrough_mode(struct psmouse *psmouse, bool enable) 480 + static int alps_passthrough_mode_v2(struct psmouse *psmouse, bool enable) 1041 481 { 1042 482 struct ps2dev *ps2dev = &psmouse->ps2dev; 1043 483 int cmd = enable ? PSMOUSE_CMD_SETSCALE21 : PSMOUSE_CMD_SETSCALE11; ··· 1054 494 return 0; 1055 495 } 1056 496 1057 - static int alps_absolute_mode(struct psmouse *psmouse) 497 + static int alps_absolute_mode_v1_v2(struct psmouse *psmouse) 1058 498 { 1059 499 struct ps2dev *ps2dev = &psmouse->ps2dev; 1060 500 ··· 1125 565 static int alps_poll(struct psmouse *psmouse) 1126 566 { 1127 567 struct alps_data *priv = psmouse->private; 1128 - unsigned char buf[6]; 568 + unsigned char buf[sizeof(psmouse->packet)]; 1129 569 bool poll_failed; 1130 570 1131 571 if (priv->i->flags & ALPS_PASS) 1132 - alps_passthrough_mode(psmouse, true); 572 + alps_passthrough_mode_v2(psmouse, true); 1133 573 1134 574 poll_failed = ps2_command(&psmouse->ps2dev, buf, 1135 575 PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)) < 0; 1136 576 1137 577 if (priv->i->flags & ALPS_PASS) 1138 - alps_passthrough_mode(psmouse, false); 578 + alps_passthrough_mode_v2(psmouse, false); 1139 579 1140 580 if (poll_failed || (buf[0] & priv->i->mask0) != priv->i->byte0) 1141 581 return -1; ··· 1152 592 return 0; 1153 593 } 1154 594 1155 - static int alps_hw_init(struct psmouse *psmouse) 595 + static int alps_hw_init_v1_v2(struct psmouse *psmouse) 1156 596 { 1157 597 struct alps_data *priv = psmouse->private; 1158 598 const struct alps_model_info *model = priv->i; 1159 599 1160 600 if ((model->flags & ALPS_PASS) && 1161 - alps_passthrough_mode(psmouse, true)) { 601 + alps_passthrough_mode_v2(psmouse, true)) { 1162 602 return -1; 1163 603 } 1164 604 ··· 1167 607 return -1; 1168 608 } 1169 609 1170 - if (alps_absolute_mode(psmouse)) { 610 + if (alps_absolute_mode_v1_v2(psmouse)) { 1171 611 psmouse_err(psmouse, "Failed to enable absolute mode\n"); 1172 612 return -1; 1173 613 } 1174 614 1175 615 if ((model->flags & ALPS_PASS) && 1176 - alps_passthrough_mode(psmouse, false)) { 616 + alps_passthrough_mode_v2(psmouse, false)) { 1177 617 return -1; 1178 618 } 1179 619 ··· 1184 624 } 1185 625 1186 626 return 0; 627 + } 628 + 629 + /* 630 + * Enable or disable passthrough mode to the trackstick. Must be in 631 + * command mode when calling this function. 632 + */ 633 + static int alps_passthrough_mode_v3(struct psmouse *psmouse, bool enable) 634 + { 635 + int reg_val; 636 + 637 + reg_val = alps_command_mode_read_reg(psmouse, 0x0008); 638 + if (reg_val == -1) 639 + return -1; 640 + 641 + if (enable) 642 + reg_val |= 0x01; 643 + else 644 + reg_val &= ~0x01; 645 + 646 + if (__alps_command_mode_write_reg(psmouse, reg_val)) 647 + return -1; 648 + 649 + return 0; 650 + } 651 + 652 + /* Must be in command mode when calling this function */ 653 + static int alps_absolute_mode_v3(struct psmouse *psmouse) 654 + { 655 + int reg_val; 656 + 657 + reg_val = alps_command_mode_read_reg(psmouse, 0x0004); 658 + if (reg_val == -1) 659 + return -1; 660 + 661 + reg_val |= 0x06; 662 + if (__alps_command_mode_write_reg(psmouse, reg_val)) 663 + return -1; 664 + 665 + return 0; 666 + } 667 + 668 + static int alps_hw_init_v3(struct psmouse *psmouse) 669 + { 670 + struct alps_data *priv = psmouse->private; 671 + struct ps2dev *ps2dev = &psmouse->ps2dev; 672 + int reg_val; 673 + unsigned char param[4]; 674 + 675 + priv->nibble_commands = alps_v3_nibble_commands; 676 + priv->addr_command = PSMOUSE_CMD_RESET_WRAP; 677 + 678 + if (alps_enter_command_mode(psmouse, NULL)) 679 + goto error; 680 + 681 + /* Check for trackstick */ 682 + reg_val = alps_command_mode_read_reg(psmouse, 0x0008); 683 + if (reg_val == -1) 684 + goto error; 685 + if (reg_val & 0x80) { 686 + if (alps_passthrough_mode_v3(psmouse, true)) 687 + goto error; 688 + if (alps_exit_command_mode(psmouse)) 689 + goto error; 690 + 691 + /* 692 + * E7 report for the trackstick 693 + * 694 + * There have been reports of failures to seem to trace back 695 + * to the above trackstick check failing. When these occur 696 + * this E7 report fails, so when that happens we continue 697 + * with the assumption that there isn't a trackstick after 698 + * all. 699 + */ 700 + param[0] = 0x64; 701 + if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || 702 + ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || 703 + ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || 704 + ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { 705 + psmouse_warn(psmouse, "trackstick E7 report failed\n"); 706 + } else { 707 + psmouse_dbg(psmouse, 708 + "trackstick E7 report: %2.2x %2.2x %2.2x\n", 709 + param[0], param[1], param[2]); 710 + 711 + /* 712 + * Not sure what this does, but it is absolutely 713 + * essential. Without it, the touchpad does not 714 + * work at all and the trackstick just emits normal 715 + * PS/2 packets. 716 + */ 717 + if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || 718 + ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || 719 + ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || 720 + alps_command_mode_send_nibble(psmouse, 0x9) || 721 + alps_command_mode_send_nibble(psmouse, 0x4)) { 722 + psmouse_err(psmouse, 723 + "Error sending magic E6 sequence\n"); 724 + goto error_passthrough; 725 + } 726 + } 727 + 728 + if (alps_enter_command_mode(psmouse, NULL)) 729 + goto error_passthrough; 730 + if (alps_passthrough_mode_v3(psmouse, false)) 731 + goto error; 732 + } 733 + 734 + if (alps_absolute_mode_v3(psmouse)) { 735 + psmouse_err(psmouse, "Failed to enter absolute mode\n"); 736 + goto error; 737 + } 738 + 739 + reg_val = alps_command_mode_read_reg(psmouse, 0x0006); 740 + if (reg_val == -1) 741 + goto error; 742 + if (__alps_command_mode_write_reg(psmouse, reg_val | 0x01)) 743 + goto error; 744 + 745 + reg_val = alps_command_mode_read_reg(psmouse, 0x0007); 746 + if (reg_val == -1) 747 + goto error; 748 + if (__alps_command_mode_write_reg(psmouse, reg_val | 0x01)) 749 + goto error; 750 + 751 + if (alps_command_mode_read_reg(psmouse, 0x0144) == -1) 752 + goto error; 753 + if (__alps_command_mode_write_reg(psmouse, 0x04)) 754 + goto error; 755 + 756 + if (alps_command_mode_read_reg(psmouse, 0x0159) == -1) 757 + goto error; 758 + if (__alps_command_mode_write_reg(psmouse, 0x03)) 759 + goto error; 760 + 761 + if (alps_command_mode_read_reg(psmouse, 0x0163) == -1) 762 + goto error; 763 + if (alps_command_mode_write_reg(psmouse, 0x0163, 0x03)) 764 + goto error; 765 + 766 + if (alps_command_mode_read_reg(psmouse, 0x0162) == -1) 767 + goto error; 768 + if (alps_command_mode_write_reg(psmouse, 0x0162, 0x04)) 769 + goto error; 770 + 771 + /* 772 + * This ensures the trackstick packets are in the format 773 + * supported by this driver. If bit 1 isn't set the packet 774 + * format is different. 775 + */ 776 + if (alps_command_mode_write_reg(psmouse, 0x0008, 0x82)) 777 + goto error; 778 + 779 + alps_exit_command_mode(psmouse); 780 + 781 + /* Set rate and enable data reporting */ 782 + param[0] = 0x64; 783 + if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE) || 784 + ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) { 785 + psmouse_err(psmouse, "Failed to enable data reporting\n"); 786 + return -1; 787 + } 788 + 789 + return 0; 790 + 791 + error_passthrough: 792 + /* Something failed while in passthrough mode, so try to get out */ 793 + if (!alps_enter_command_mode(psmouse, NULL)) 794 + alps_passthrough_mode_v3(psmouse, false); 795 + error: 796 + /* 797 + * Leaving the touchpad in command mode will essentially render 798 + * it unusable until the machine reboots, so exit it here just 799 + * to be safe 800 + */ 801 + alps_exit_command_mode(psmouse); 802 + return -1; 803 + } 804 + 805 + /* Must be in command mode when calling this function */ 806 + static int alps_absolute_mode_v4(struct psmouse *psmouse) 807 + { 808 + int reg_val; 809 + 810 + reg_val = alps_command_mode_read_reg(psmouse, 0x0004); 811 + if (reg_val == -1) 812 + return -1; 813 + 814 + reg_val |= 0x02; 815 + if (__alps_command_mode_write_reg(psmouse, reg_val)) 816 + return -1; 817 + 818 + return 0; 819 + } 820 + 821 + static int alps_hw_init_v4(struct psmouse *psmouse) 822 + { 823 + struct alps_data *priv = psmouse->private; 824 + struct ps2dev *ps2dev = &psmouse->ps2dev; 825 + unsigned char param[4]; 826 + 827 + priv->nibble_commands = alps_v4_nibble_commands; 828 + priv->addr_command = PSMOUSE_CMD_DISABLE; 829 + 830 + if (alps_enter_command_mode(psmouse, NULL)) 831 + goto error; 832 + 833 + if (alps_absolute_mode_v4(psmouse)) { 834 + psmouse_err(psmouse, "Failed to enter absolute mode\n"); 835 + goto error; 836 + } 837 + 838 + if (alps_command_mode_write_reg(psmouse, 0x0007, 0x8c)) 839 + goto error; 840 + 841 + if (alps_command_mode_write_reg(psmouse, 0x0149, 0x03)) 842 + goto error; 843 + 844 + if (alps_command_mode_write_reg(psmouse, 0x0160, 0x03)) 845 + goto error; 846 + 847 + if (alps_command_mode_write_reg(psmouse, 0x017f, 0x15)) 848 + goto error; 849 + 850 + if (alps_command_mode_write_reg(psmouse, 0x0151, 0x01)) 851 + goto error; 852 + 853 + if (alps_command_mode_write_reg(psmouse, 0x0168, 0x03)) 854 + goto error; 855 + 856 + if (alps_command_mode_write_reg(psmouse, 0x014a, 0x03)) 857 + goto error; 858 + 859 + if (alps_command_mode_write_reg(psmouse, 0x0161, 0x03)) 860 + goto error; 861 + 862 + alps_exit_command_mode(psmouse); 863 + 864 + /* 865 + * This sequence changes the output from a 9-byte to an 866 + * 8-byte format. All the same data seems to be present, 867 + * just in a more compact format. 868 + */ 869 + param[0] = 0xc8; 870 + param[1] = 0x64; 871 + param[2] = 0x50; 872 + if (ps2_command(ps2dev, &param[0], PSMOUSE_CMD_SETRATE) || 873 + ps2_command(ps2dev, &param[1], PSMOUSE_CMD_SETRATE) || 874 + ps2_command(ps2dev, &param[2], PSMOUSE_CMD_SETRATE) || 875 + ps2_command(ps2dev, param, PSMOUSE_CMD_GETID)) 876 + return -1; 877 + 878 + /* Set rate and enable data reporting */ 879 + param[0] = 0x64; 880 + if (ps2_command(ps2dev, param, PSMOUSE_CMD_SETRATE) || 881 + ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE)) { 882 + psmouse_err(psmouse, "Failed to enable data reporting\n"); 883 + return -1; 884 + } 885 + 886 + return 0; 887 + 888 + error: 889 + /* 890 + * Leaving the touchpad in command mode will essentially render 891 + * it unusable until the machine reboots, so exit it here just 892 + * to be safe 893 + */ 894 + alps_exit_command_mode(psmouse); 895 + return -1; 896 + } 897 + 898 + static int alps_hw_init(struct psmouse *psmouse) 899 + { 900 + struct alps_data *priv = psmouse->private; 901 + const struct alps_model_info *model = priv->i; 902 + int ret = -1; 903 + 904 + switch (model->proto_version) { 905 + case ALPS_PROTO_V1: 906 + case ALPS_PROTO_V2: 907 + ret = alps_hw_init_v1_v2(psmouse); 908 + break; 909 + case ALPS_PROTO_V3: 910 + ret = alps_hw_init_v3(psmouse); 911 + break; 912 + case ALPS_PROTO_V4: 913 + ret = alps_hw_init_v4(psmouse); 914 + break; 915 + } 916 + 917 + return ret; 1187 918 } 1188 919 1189 920 static int alps_reconnect(struct psmouse *psmouse) ··· 1517 666 1518 667 psmouse->private = priv; 1519 668 669 + psmouse_reset(psmouse); 670 + 1520 671 model = alps_get_model(psmouse, &version); 1521 672 if (!model) 1522 673 goto init_fail; ··· 1546 693 BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT); 1547 694 1548 695 dev1->evbit[BIT_WORD(EV_ABS)] |= BIT_MASK(EV_ABS); 1549 - input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0); 1550 - input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0); 696 + 697 + switch (model->proto_version) { 698 + case ALPS_PROTO_V1: 699 + case ALPS_PROTO_V2: 700 + input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0); 701 + input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0); 702 + break; 703 + case ALPS_PROTO_V3: 704 + set_bit(INPUT_PROP_SEMI_MT, dev1->propbit); 705 + input_mt_init_slots(dev1, 2); 706 + input_set_abs_params(dev1, ABS_MT_POSITION_X, 0, ALPS_V3_X_MAX, 0, 0); 707 + input_set_abs_params(dev1, ABS_MT_POSITION_Y, 0, ALPS_V3_Y_MAX, 0, 0); 708 + 709 + set_bit(BTN_TOOL_DOUBLETAP, dev1->keybit); 710 + set_bit(BTN_TOOL_TRIPLETAP, dev1->keybit); 711 + set_bit(BTN_TOOL_QUADTAP, dev1->keybit); 712 + /* fall through */ 713 + case ALPS_PROTO_V4: 714 + input_set_abs_params(dev1, ABS_X, 0, ALPS_V3_X_MAX, 0, 0); 715 + input_set_abs_params(dev1, ABS_Y, 0, ALPS_V3_Y_MAX, 0, 0); 716 + break; 717 + } 718 + 1551 719 input_set_abs_params(dev1, ABS_PRESSURE, 0, 127, 0, 0); 1552 720 1553 721 if (model->flags & ALPS_WHEEL) { ··· 1611 737 psmouse->poll = alps_poll; 1612 738 psmouse->disconnect = alps_disconnect; 1613 739 psmouse->reconnect = alps_reconnect; 1614 - psmouse->pktsize = 6; 740 + psmouse->pktsize = model->proto_version == ALPS_PROTO_V4 ? 8 : 6; 1615 741 1616 742 /* We are having trouble resyncing ALPS touchpads so disable it for now */ 1617 743 psmouse->resync_time = 0;
+19
drivers/input/mouse/alps.h
··· 12 12 #ifndef _ALPS_H 13 13 #define _ALPS_H 14 14 15 + #define ALPS_PROTO_V1 0 16 + #define ALPS_PROTO_V2 1 17 + #define ALPS_PROTO_V3 2 18 + #define ALPS_PROTO_V4 3 19 + 15 20 struct alps_model_info { 16 21 unsigned char signature[3]; 22 + unsigned char command_mode_resp; /* v3/v4 only */ 23 + unsigned char proto_version; 17 24 unsigned char byte0, mask0; 18 25 unsigned char flags; 26 + }; 27 + 28 + struct alps_nibble_commands { 29 + int command; 30 + unsigned char data; 19 31 }; 20 32 21 33 struct alps_data { 22 34 struct input_dev *dev2; /* Relative device */ 23 35 char phys[32]; /* Phys */ 24 36 const struct alps_model_info *i;/* Info */ 37 + const struct alps_nibble_commands *nibble_commands; 38 + int addr_command; /* Command to set register address */ 25 39 int prev_fin; /* Finger bit from previous packet */ 40 + int multi_packet; /* Multi-packet data in progress */ 41 + unsigned char multi_data[6]; /* Saved multi-packet data */ 42 + u8 quirks; 26 43 struct timer_list timer; 27 44 }; 45 + 46 + #define ALPS_QUIRK_TRACKSTICK_BUTTONS 1 /* trakcstick buttons in trackstick packet */ 28 47 29 48 #ifdef CONFIG_MOUSE_PS2_ALPS 30 49 int alps_detect(struct psmouse *psmouse, bool set_properties);
+2 -14
drivers/input/mouse/amimouse.c
··· 140 140 } 141 141 142 142 static struct platform_driver amimouse_driver = { 143 + .probe = amimouse_probe, 143 144 .remove = __exit_p(amimouse_remove), 144 145 .driver = { 145 146 .name = "amiga-mouse", 146 147 .owner = THIS_MODULE, 147 148 }, 148 149 }; 149 - 150 - static int __init amimouse_init(void) 151 - { 152 - return platform_driver_probe(&amimouse_driver, amimouse_probe); 153 - } 154 - 155 - module_init(amimouse_init); 156 - 157 - static void __exit amimouse_exit(void) 158 - { 159 - platform_driver_unregister(&amimouse_driver); 160 - } 161 - 162 - module_exit(amimouse_exit); 150 + module_platform_driver(amimouse_driver); 163 151 164 152 MODULE_ALIAS("platform:amiga-mouse");
+67 -13
drivers/input/mouse/elantech.c
··· 43 43 } 44 44 45 45 /* 46 + * V3 and later support this fast command 47 + */ 48 + static int elantech_send_cmd(struct psmouse *psmouse, unsigned char c, 49 + unsigned char *param) 50 + { 51 + struct ps2dev *ps2dev = &psmouse->ps2dev; 52 + 53 + if (ps2_command(ps2dev, NULL, ETP_PS2_CUSTOM_COMMAND) || 54 + ps2_command(ps2dev, NULL, c) || 55 + ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) { 56 + psmouse_err(psmouse, "%s query 0x%02x failed.\n", __func__, c); 57 + return -1; 58 + } 59 + 60 + return 0; 61 + } 62 + 63 + /* 46 64 * A retrying version of ps2_command 47 65 */ 48 66 static int elantech_ps2_command(struct psmouse *psmouse, ··· 881 863 i = (etd->fw_version > 0x020800 && 882 864 etd->fw_version < 0x020900) ? 1 : 2; 883 865 884 - if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 866 + if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 885 867 return -1; 886 868 887 869 fixed_dpi = param[1] & 0x10; 888 870 889 871 if (((etd->fw_version >> 16) == 0x14) && fixed_dpi) { 890 - if (synaptics_send_cmd(psmouse, ETP_SAMPLE_QUERY, param)) 872 + if (etd->send_cmd(psmouse, ETP_SAMPLE_QUERY, param)) 891 873 return -1; 892 874 893 875 *x_max = (etd->capabilities[1] - i) * param[1] / 2; ··· 906 888 break; 907 889 908 890 case 3: 909 - if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 891 + if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 910 892 return -1; 911 893 912 894 *x_max = (0x0f & param[0]) << 8 | param[1]; ··· 914 896 break; 915 897 916 898 case 4: 917 - if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 899 + if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 918 900 return -1; 919 901 920 902 *x_max = (0x0f & param[0]) << 8 | param[1]; ··· 931 913 } 932 914 933 915 /* 916 + * (value from firmware) * 10 + 790 = dpi 917 + * we also have to convert dpi to dots/mm (*10/254 to avoid floating point) 918 + */ 919 + static unsigned int elantech_convert_res(unsigned int val) 920 + { 921 + return (val * 10 + 790) * 10 / 254; 922 + } 923 + 924 + static int elantech_get_resolution_v4(struct psmouse *psmouse, 925 + unsigned int *x_res, 926 + unsigned int *y_res) 927 + { 928 + unsigned char param[3]; 929 + 930 + if (elantech_send_cmd(psmouse, ETP_RESOLUTION_QUERY, param)) 931 + return -1; 932 + 933 + *x_res = elantech_convert_res(param[1] & 0x0f); 934 + *y_res = elantech_convert_res((param[1] & 0xf0) >> 4); 935 + 936 + return 0; 937 + } 938 + 939 + /* 934 940 * Set the appropriate event bits for the input subsystem 935 941 */ 936 942 static int elantech_set_input_params(struct psmouse *psmouse) ··· 962 920 struct input_dev *dev = psmouse->dev; 963 921 struct elantech_data *etd = psmouse->private; 964 922 unsigned int x_min = 0, y_min = 0, x_max = 0, y_max = 0, width = 0; 923 + unsigned int x_res = 0, y_res = 0; 965 924 966 925 if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width)) 967 926 return -1; ··· 1010 967 break; 1011 968 1012 969 case 4: 970 + if (elantech_get_resolution_v4(psmouse, &x_res, &y_res)) { 971 + /* 972 + * if query failed, print a warning and leave the values 973 + * zero to resemble synaptics.c behavior. 974 + */ 975 + psmouse_warn(psmouse, "couldn't query resolution data.\n"); 976 + } 977 + 1013 978 __set_bit(BTN_TOOL_QUADTAP, dev->keybit); 1014 979 /* For X to recognize me as touchpad. */ 1015 980 input_set_abs_params(dev, ABS_X, x_min, x_max, 0, 0); 1016 981 input_set_abs_params(dev, ABS_Y, y_min, y_max, 0, 0); 982 + input_abs_set_res(dev, ABS_X, x_res); 983 + input_abs_set_res(dev, ABS_Y, y_res); 1017 984 /* 1018 985 * range of pressure and width is the same as v2, 1019 986 * report ABS_PRESSURE, ABS_TOOL_WIDTH for compatibility. ··· 1036 983 input_mt_init_slots(dev, ETP_MAX_FINGERS); 1037 984 input_set_abs_params(dev, ABS_MT_POSITION_X, x_min, x_max, 0, 0); 1038 985 input_set_abs_params(dev, ABS_MT_POSITION_Y, y_min, y_max, 0, 0); 986 + input_abs_set_res(dev, ABS_MT_POSITION_X, x_res); 987 + input_abs_set_res(dev, ABS_MT_POSITION_Y, y_res); 1039 988 input_set_abs_params(dev, ABS_MT_PRESSURE, ETP_PMIN_V2, 1040 989 ETP_PMAX_V2, 0, 0); 1041 990 /* ··· 1086 1031 struct elantech_data *etd = psmouse->private; 1087 1032 struct elantech_attr_data *attr = data; 1088 1033 unsigned char *reg = (unsigned char *) etd + attr->field_offset; 1089 - unsigned long value; 1034 + unsigned char value; 1090 1035 int err; 1091 1036 1092 - err = strict_strtoul(buf, 16, &value); 1037 + err = kstrtou8(buf, 16, &value); 1093 1038 if (err) 1094 1039 return err; 1095 - 1096 - if (value > 0xff) 1097 - return -EINVAL; 1098 1040 1099 1041 /* Do we need to preserve some bits for version 2 hardware too? */ 1100 1042 if (etd->hw_version == 1) { ··· 1285 1233 } 1286 1234 } 1287 1235 1288 - /* 1289 - * Turn on packet checking by default. 1290 - */ 1236 + /* decide which send_cmd we're gonna use early */ 1237 + etd->send_cmd = etd->hw_version >= 3 ? elantech_send_cmd : 1238 + synaptics_send_cmd; 1239 + 1240 + /* Turn on packet checking by default */ 1291 1241 etd->paritycheck = 1; 1292 1242 1293 1243 /* ··· 1345 1291 "assuming hardware version %d (with firmware version 0x%02x%02x%02x)\n", 1346 1292 etd->hw_version, param[0], param[1], param[2]); 1347 1293 1348 - if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY, 1294 + if (etd->send_cmd(psmouse, ETP_CAPABILITIES_QUERY, 1349 1295 etd->capabilities)) { 1350 1296 psmouse_err(psmouse, "failed to query capabilities.\n"); 1351 1297 goto init_fail;
+2
drivers/input/mouse/elantech.h
··· 20 20 #define ETP_FW_VERSION_QUERY 0x01 21 21 #define ETP_CAPABILITIES_QUERY 0x02 22 22 #define ETP_SAMPLE_QUERY 0x03 23 + #define ETP_RESOLUTION_QUERY 0x04 23 24 24 25 /* 25 26 * Command values for register reading or writing ··· 136 135 unsigned int width; 137 136 struct finger_pos mt[ETP_MAX_FINGERS]; 138 137 unsigned char parity[256]; 138 + int (*send_cmd)(struct psmouse *psmouse, unsigned char c, unsigned char *param); 139 139 }; 140 140 141 141 #ifdef CONFIG_MOUSE_PS2_ELANTECH
+1 -12
drivers/input/mouse/gpio_mouse.c
··· 178 178 .owner = THIS_MODULE, 179 179 } 180 180 }; 181 - 182 - static int __init gpio_mouse_init(void) 183 - { 184 - return platform_driver_register(&gpio_mouse_device_driver); 185 - } 186 - module_init(gpio_mouse_init); 187 - 188 - static void __exit gpio_mouse_exit(void) 189 - { 190 - platform_driver_unregister(&gpio_mouse_device_driver); 191 - } 192 - module_exit(gpio_mouse_exit); 181 + module_platform_driver(gpio_mouse_device_driver); 193 182 194 183 MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>"); 195 184 MODULE_DESCRIPTION("GPIO mouse driver");
+12 -6
drivers/input/mouse/hgpk.c
··· 789 789 const char *buf, size_t count) 790 790 { 791 791 struct hgpk_data *priv = psmouse->private; 792 - unsigned long value; 792 + unsigned int value; 793 793 int err; 794 794 795 - err = strict_strtoul(buf, 10, &value); 796 - if (err || value > 1) 795 + err = kstrtouint(buf, 10, &value); 796 + if (err) 797 + return err; 798 + 799 + if (value > 1) 797 800 return -EINVAL; 798 801 799 802 if (value != priv->powered) { ··· 884 881 const char *buf, size_t count) 885 882 { 886 883 struct hgpk_data *priv = psmouse->private; 887 - unsigned long value; 884 + unsigned int value; 888 885 int err; 889 886 890 - err = strict_strtoul(buf, 10, &value); 891 - if (err || value != 1) 887 + err = kstrtouint(buf, 10, &value); 888 + if (err) 889 + return err; 890 + 891 + if (value != 1) 892 892 return -EINVAL; 893 893 894 894 /*
+7 -2
drivers/input/mouse/logips2pp.c
··· 155 155 static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data, 156 156 const char *buf, size_t count) 157 157 { 158 - unsigned long value; 158 + unsigned int value; 159 + int err; 159 160 160 - if (strict_strtoul(buf, 10, &value) || value > 1) 161 + err = kstrtouint(buf, 10, &value); 162 + if (err) 163 + return err; 164 + 165 + if (value > 1) 161 166 return -EINVAL; 162 167 163 168 ps2pp_set_smartscroll(psmouse, value);
+147 -82
drivers/input/mouse/psmouse-base.c
··· 127 127 * relevant events to the input module once full packet has arrived. 128 128 */ 129 129 130 - static psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse) 130 + psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse) 131 131 { 132 132 struct input_dev *dev = psmouse->dev; 133 133 unsigned char *packet = psmouse->packet; ··· 418 418 return 0; 419 419 } 420 420 421 + /* 422 + * Here we set the mouse resolution. 423 + */ 424 + 425 + void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution) 426 + { 427 + static const unsigned char params[] = { 0, 1, 2, 2, 3 }; 428 + unsigned char p; 429 + 430 + if (resolution == 0 || resolution > 200) 431 + resolution = 200; 432 + 433 + p = params[resolution / 50]; 434 + ps2_command(&psmouse->ps2dev, &p, PSMOUSE_CMD_SETRES); 435 + psmouse->resolution = 25 << p; 436 + } 437 + 438 + /* 439 + * Here we set the mouse report rate. 440 + */ 441 + 442 + static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate) 443 + { 444 + static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 }; 445 + unsigned char r; 446 + int i = 0; 447 + 448 + while (rates[i] > rate) i++; 449 + r = rates[i]; 450 + ps2_command(&psmouse->ps2dev, &r, PSMOUSE_CMD_SETRATE); 451 + psmouse->rate = r; 452 + } 453 + 454 + /* 455 + * psmouse_poll() - default poll handler. Everyone except for ALPS uses it. 456 + */ 457 + 458 + static int psmouse_poll(struct psmouse *psmouse) 459 + { 460 + return ps2_command(&psmouse->ps2dev, psmouse->packet, 461 + PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)); 462 + } 463 + 421 464 422 465 /* 423 466 * Genius NetMouse magic init. ··· 646 603 } 647 604 648 605 /* 606 + * Apply default settings to the psmouse structure. Most of them will 607 + * be overridden by individual protocol initialization routines. 608 + */ 609 + 610 + static void psmouse_apply_defaults(struct psmouse *psmouse) 611 + { 612 + struct input_dev *input_dev = psmouse->dev; 613 + 614 + memset(input_dev->evbit, 0, sizeof(input_dev->evbit)); 615 + memset(input_dev->keybit, 0, sizeof(input_dev->keybit)); 616 + memset(input_dev->relbit, 0, sizeof(input_dev->relbit)); 617 + memset(input_dev->absbit, 0, sizeof(input_dev->absbit)); 618 + memset(input_dev->mscbit, 0, sizeof(input_dev->mscbit)); 619 + 620 + __set_bit(EV_KEY, input_dev->evbit); 621 + __set_bit(EV_REL, input_dev->evbit); 622 + 623 + __set_bit(BTN_LEFT, input_dev->keybit); 624 + __set_bit(BTN_RIGHT, input_dev->keybit); 625 + 626 + __set_bit(REL_X, input_dev->relbit); 627 + __set_bit(REL_Y, input_dev->relbit); 628 + 629 + psmouse->set_rate = psmouse_set_rate; 630 + psmouse->set_resolution = psmouse_set_resolution; 631 + psmouse->poll = psmouse_poll; 632 + psmouse->protocol_handler = psmouse_process_byte; 633 + psmouse->pktsize = 3; 634 + psmouse->reconnect = NULL; 635 + psmouse->disconnect = NULL; 636 + psmouse->cleanup = NULL; 637 + psmouse->pt_activate = NULL; 638 + psmouse->pt_deactivate = NULL; 639 + } 640 + 641 + /* 642 + * Apply default settings to the psmouse structure and call specified 643 + * protocol detection or initialization routine. 644 + */ 645 + static int psmouse_do_detect(int (*detect)(struct psmouse *psmouse, 646 + bool set_properties), 647 + struct psmouse *psmouse, bool set_properties) 648 + { 649 + if (set_properties) 650 + psmouse_apply_defaults(psmouse); 651 + 652 + return detect(psmouse, set_properties); 653 + } 654 + 655 + /* 649 656 * psmouse_extensions() probes for any extensions to the basic PS/2 protocol 650 657 * the mouse may have. 651 658 */ ··· 709 616 * We always check for lifebook because it does not disturb mouse 710 617 * (it only checks DMI information). 711 618 */ 712 - if (lifebook_detect(psmouse, set_properties) == 0) { 619 + if (psmouse_do_detect(lifebook_detect, psmouse, set_properties) == 0) { 713 620 if (max_proto > PSMOUSE_IMEX) { 714 621 if (!set_properties || lifebook_init(psmouse) == 0) 715 622 return PSMOUSE_LIFEBOOK; ··· 721 628 * upsets the thinkingmouse). 722 629 */ 723 630 724 - if (max_proto > PSMOUSE_IMEX && thinking_detect(psmouse, set_properties) == 0) 631 + if (max_proto > PSMOUSE_IMEX && 632 + psmouse_do_detect(thinking_detect, psmouse, set_properties) == 0) { 725 633 return PSMOUSE_THINKPS; 634 + } 726 635 727 636 /* 728 637 * Try Synaptics TouchPad. Note that probing is done even if Synaptics protocol 729 638 * support is disabled in config - we need to know if it is synaptics so we 730 639 * can reset it properly after probing for intellimouse. 731 640 */ 732 - if (max_proto > PSMOUSE_PS2 && synaptics_detect(psmouse, set_properties) == 0) { 641 + if (max_proto > PSMOUSE_PS2 && 642 + psmouse_do_detect(synaptics_detect, psmouse, set_properties) == 0) { 733 643 synaptics_hardware = true; 734 644 735 645 if (max_proto > PSMOUSE_IMEX) { ··· 763 667 */ 764 668 if (max_proto > PSMOUSE_IMEX) { 765 669 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); 766 - if (alps_detect(psmouse, set_properties) == 0) { 670 + if (psmouse_do_detect(alps_detect, 671 + psmouse, set_properties) == 0) { 767 672 if (!set_properties || alps_init(psmouse) == 0) 768 673 return PSMOUSE_ALPS; 769 674 /* ··· 778 681 * Try OLPC HGPK touchpad. 779 682 */ 780 683 if (max_proto > PSMOUSE_IMEX && 781 - hgpk_detect(psmouse, set_properties) == 0) { 684 + psmouse_do_detect(hgpk_detect, psmouse, set_properties) == 0) { 782 685 if (!set_properties || hgpk_init(psmouse) == 0) 783 686 return PSMOUSE_HGPK; 784 687 /* ··· 791 694 * Try Elantech touchpad. 792 695 */ 793 696 if (max_proto > PSMOUSE_IMEX && 794 - elantech_detect(psmouse, set_properties) == 0) { 697 + psmouse_do_detect(elantech_detect, psmouse, set_properties) == 0) { 795 698 if (!set_properties || elantech_init(psmouse) == 0) 796 699 return PSMOUSE_ELANTECH; 797 700 /* ··· 800 703 max_proto = PSMOUSE_IMEX; 801 704 } 802 705 803 - 804 706 if (max_proto > PSMOUSE_IMEX) { 805 - if (genius_detect(psmouse, set_properties) == 0) 707 + if (psmouse_do_detect(genius_detect, 708 + psmouse, set_properties) == 0) 806 709 return PSMOUSE_GENPS; 807 710 808 - if (ps2pp_init(psmouse, set_properties) == 0) 711 + if (psmouse_do_detect(ps2pp_init, 712 + psmouse, set_properties) == 0) 809 713 return PSMOUSE_PS2PP; 810 714 811 - if (trackpoint_detect(psmouse, set_properties) == 0) 715 + if (psmouse_do_detect(trackpoint_detect, 716 + psmouse, set_properties) == 0) 812 717 return PSMOUSE_TRACKPOINT; 813 718 814 - if (touchkit_ps2_detect(psmouse, set_properties) == 0) 719 + if (psmouse_do_detect(touchkit_ps2_detect, 720 + psmouse, set_properties) == 0) 815 721 return PSMOUSE_TOUCHKIT_PS2; 816 722 } 817 723 ··· 823 723 * Trackpoint devices (causing TP_READ_ID command to time out). 824 724 */ 825 725 if (max_proto > PSMOUSE_IMEX) { 826 - if (fsp_detect(psmouse, set_properties) == 0) { 726 + if (psmouse_do_detect(fsp_detect, 727 + psmouse, set_properties) == 0) { 827 728 if (!set_properties || fsp_init(psmouse) == 0) 828 729 return PSMOUSE_FSP; 829 730 /* ··· 842 741 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_RESET_DIS); 843 742 psmouse_reset(psmouse); 844 743 845 - if (max_proto >= PSMOUSE_IMEX && im_explorer_detect(psmouse, set_properties) == 0) 744 + if (max_proto >= PSMOUSE_IMEX && 745 + psmouse_do_detect(im_explorer_detect, 746 + psmouse, set_properties) == 0) { 846 747 return PSMOUSE_IMEX; 748 + } 847 749 848 - if (max_proto >= PSMOUSE_IMPS && intellimouse_detect(psmouse, set_properties) == 0) 750 + if (max_proto >= PSMOUSE_IMPS && 751 + psmouse_do_detect(intellimouse_detect, 752 + psmouse, set_properties) == 0) { 849 753 return PSMOUSE_IMPS; 754 + } 850 755 851 756 /* 852 757 * Okay, all failed, we have a standard mouse here. The number of the buttons 853 758 * is still a question, though. We assume 3. 854 759 */ 855 - ps2bare_detect(psmouse, set_properties); 760 + psmouse_do_detect(ps2bare_detect, psmouse, set_properties); 856 761 857 762 if (synaptics_hardware) { 858 763 /* ··· 925 818 .alias = "synaptics", 926 819 .detect = synaptics_detect, 927 820 .init = synaptics_init, 821 + }, 822 + { 823 + .type = PSMOUSE_SYNAPTICS_RELATIVE, 824 + .name = "SynRelPS/2", 825 + .alias = "synaptics-relative", 826 + .detect = synaptics_detect, 827 + .init = synaptics_init_relative, 928 828 }, 929 829 #endif 930 830 #ifdef CONFIG_MOUSE_PS2_ALPS ··· 1072 958 } 1073 959 1074 960 /* 1075 - * Here we set the mouse resolution. 1076 - */ 1077 - 1078 - void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution) 1079 - { 1080 - static const unsigned char params[] = { 0, 1, 2, 2, 3 }; 1081 - unsigned char p; 1082 - 1083 - if (resolution == 0 || resolution > 200) 1084 - resolution = 200; 1085 - 1086 - p = params[resolution / 50]; 1087 - ps2_command(&psmouse->ps2dev, &p, PSMOUSE_CMD_SETRES); 1088 - psmouse->resolution = 25 << p; 1089 - } 1090 - 1091 - /* 1092 - * Here we set the mouse report rate. 1093 - */ 1094 - 1095 - static void psmouse_set_rate(struct psmouse *psmouse, unsigned int rate) 1096 - { 1097 - static const unsigned char rates[] = { 200, 100, 80, 60, 40, 20, 10, 0 }; 1098 - unsigned char r; 1099 - int i = 0; 1100 - 1101 - while (rates[i] > rate) i++; 1102 - r = rates[i]; 1103 - ps2_command(&psmouse->ps2dev, &r, PSMOUSE_CMD_SETRATE); 1104 - psmouse->rate = r; 1105 - } 1106 - 1107 - /* 1108 961 * psmouse_initialize() initializes the mouse to a sane state. 1109 962 */ 1110 963 ··· 1114 1033 psmouse->ps2dev.serio->phys); 1115 1034 1116 1035 psmouse_set_state(psmouse, PSMOUSE_CMD_MODE); 1117 - } 1118 - 1119 - /* 1120 - * psmouse_poll() - default poll handler. Everyone except for ALPS uses it. 1121 - */ 1122 - 1123 - static int psmouse_poll(struct psmouse *psmouse) 1124 - { 1125 - return ps2_command(&psmouse->ps2dev, psmouse->packet, 1126 - PSMOUSE_CMD_POLL | (psmouse->pktsize << 8)); 1127 1036 } 1128 1037 1129 1038 ··· 1316 1245 1317 1246 input_dev->dev.parent = &psmouse->ps2dev.serio->dev; 1318 1247 1319 - input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 1320 - input_dev->keybit[BIT_WORD(BTN_MOUSE)] = 1321 - BIT_MASK(BTN_LEFT) | BIT_MASK(BTN_RIGHT); 1322 - input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); 1323 - 1324 - psmouse->set_rate = psmouse_set_rate; 1325 - psmouse->set_resolution = psmouse_set_resolution; 1326 - psmouse->poll = psmouse_poll; 1327 - psmouse->protocol_handler = psmouse_process_byte; 1328 - psmouse->pktsize = 3; 1329 - 1330 1248 if (proto && (proto->detect || proto->init)) { 1249 + psmouse_apply_defaults(psmouse); 1250 + 1331 1251 if (proto->detect && proto->detect(psmouse, true) < 0) 1332 1252 return -1; 1333 1253 ··· 1620 1558 static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count) 1621 1559 { 1622 1560 unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset); 1623 - unsigned long value; 1561 + unsigned int value; 1562 + int err; 1624 1563 1625 - if (strict_strtoul(buf, 10, &value)) 1626 - return -EINVAL; 1627 - 1628 - if ((unsigned int)value != value) 1629 - return -EINVAL; 1564 + err = kstrtouint(buf, 10, &value); 1565 + if (err) 1566 + return err; 1630 1567 1631 1568 *field = value; 1632 1569 ··· 1732 1671 1733 1672 static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1734 1673 { 1735 - unsigned long value; 1674 + unsigned int value; 1675 + int err; 1736 1676 1737 - if (strict_strtoul(buf, 10, &value)) 1738 - return -EINVAL; 1677 + err = kstrtouint(buf, 10, &value); 1678 + if (err) 1679 + return err; 1739 1680 1740 1681 psmouse->set_rate(psmouse, value); 1741 1682 return count; ··· 1745 1682 1746 1683 static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count) 1747 1684 { 1748 - unsigned long value; 1685 + unsigned int value; 1686 + int err; 1749 1687 1750 - if (strict_strtoul(buf, 10, &value)) 1751 - return -EINVAL; 1688 + err = kstrtouint(buf, 10, &value); 1689 + if (err) 1690 + return err; 1752 1691 1753 1692 psmouse->set_resolution(psmouse, value); 1754 1693 return count;
+3
drivers/input/mouse/psmouse.h
··· 8 8 #define PSMOUSE_CMD_SETSTREAM 0x00ea 9 9 #define PSMOUSE_CMD_SETPOLL 0x00f0 10 10 #define PSMOUSE_CMD_POLL 0x00eb /* caller sets number of bytes to receive */ 11 + #define PSMOUSE_CMD_RESET_WRAP 0x00ec 11 12 #define PSMOUSE_CMD_GETID 0x02f2 12 13 #define PSMOUSE_CMD_SETRATE 0x10f3 13 14 #define PSMOUSE_CMD_ENABLE 0x00f4 ··· 94 93 PSMOUSE_HGPK, 95 94 PSMOUSE_ELANTECH, 96 95 PSMOUSE_FSP, 96 + PSMOUSE_SYNAPTICS_RELATIVE, 97 97 PSMOUSE_AUTO /* This one should always be last */ 98 98 }; 99 99 ··· 104 102 int psmouse_reset(struct psmouse *psmouse); 105 103 void psmouse_set_state(struct psmouse *psmouse, enum psmouse_state new_state); 106 104 void psmouse_set_resolution(struct psmouse *psmouse, unsigned int resolution); 105 + psmouse_ret_t psmouse_process_byte(struct psmouse *psmouse); 107 106 108 107 struct psmouse_attribute { 109 108 struct device_attribute dattr;
+1 -13
drivers/input/mouse/pxa930_trkball.c
··· 250 250 .probe = pxa930_trkball_probe, 251 251 .remove = __devexit_p(pxa930_trkball_remove), 252 252 }; 253 - 254 - static int __init pxa930_trkball_init(void) 255 - { 256 - return platform_driver_register(&pxa930_trkball_driver); 257 - } 258 - 259 - static void __exit pxa930_trkball_exit(void) 260 - { 261 - platform_driver_unregister(&pxa930_trkball_driver); 262 - } 263 - 264 - module_init(pxa930_trkball_init); 265 - module_exit(pxa930_trkball_exit); 253 + module_platform_driver(pxa930_trkball_driver); 266 254 267 255 MODULE_AUTHOR("Yong Yao <yaoyong@marvell.com>"); 268 256 MODULE_DESCRIPTION("PXA930 Trackball Mouse Driver");
+32 -11
drivers/input/mouse/sentelic.c
··· 408 408 static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data, 409 409 const char *buf, size_t count) 410 410 { 411 - unsigned long reg, val; 411 + int reg, val; 412 412 char *rest; 413 413 ssize_t retval; 414 414 ··· 416 416 if (rest == buf || *rest != ' ' || reg > 0xff) 417 417 return -EINVAL; 418 418 419 - if (strict_strtoul(rest + 1, 16, &val) || val > 0xff) 419 + retval = kstrtoint(rest + 1, 16, &val); 420 + if (retval) 421 + return retval; 422 + 423 + if (val > 0xff) 420 424 return -EINVAL; 421 425 422 426 if (fsp_reg_write_enable(psmouse, true)) ··· 452 448 const char *buf, size_t count) 453 449 { 454 450 struct fsp_data *pad = psmouse->private; 455 - unsigned long reg; 456 - int val; 451 + int reg, val, err; 457 452 458 - if (strict_strtoul(buf, 16, &reg) || reg > 0xff) 453 + err = kstrtoint(buf, 16, &reg); 454 + if (err) 455 + return err; 456 + 457 + if (reg > 0xff) 459 458 return -EINVAL; 460 459 461 460 if (fsp_reg_read(psmouse, reg, &val)) ··· 487 480 static ssize_t fsp_attr_set_pagereg(struct psmouse *psmouse, void *data, 488 481 const char *buf, size_t count) 489 482 { 490 - unsigned long val; 483 + int val, err; 491 484 492 - if (strict_strtoul(buf, 16, &val) || val > 0xff) 485 + err = kstrtoint(buf, 16, &val); 486 + if (err) 487 + return err; 488 + 489 + if (val > 0xff) 493 490 return -EINVAL; 494 491 495 492 if (fsp_page_reg_write(psmouse, val)) ··· 516 505 static ssize_t fsp_attr_set_vscroll(struct psmouse *psmouse, void *data, 517 506 const char *buf, size_t count) 518 507 { 519 - unsigned long val; 508 + unsigned int val; 509 + int err; 520 510 521 - if (strict_strtoul(buf, 10, &val) || val > 1) 511 + err = kstrtouint(buf, 10, &val); 512 + if (err) 513 + return err; 514 + 515 + if (val > 1) 522 516 return -EINVAL; 523 517 524 518 fsp_onpad_vscr(psmouse, val); ··· 545 529 static ssize_t fsp_attr_set_hscroll(struct psmouse *psmouse, void *data, 546 530 const char *buf, size_t count) 547 531 { 548 - unsigned long val; 532 + unsigned int val; 533 + int err; 549 534 550 - if (strict_strtoul(buf, 10, &val) || val > 1) 535 + err = kstrtouint(buf, 10, &val); 536 + if (err) 537 + return err; 538 + 539 + if (val > 1) 551 540 return -EINVAL; 552 541 553 542 fsp_onpad_hscr(psmouse, val);
+142 -55
drivers/input/mouse/synaptics.c
··· 269 269 return 0; 270 270 } 271 271 272 - static int synaptics_set_absolute_mode(struct psmouse *psmouse) 272 + static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) 273 + { 274 + static unsigned char param = 0xc8; 275 + struct synaptics_data *priv = psmouse->private; 276 + 277 + if (!SYN_CAP_ADV_GESTURE(priv->ext_cap_0c)) 278 + return 0; 279 + 280 + if (psmouse_sliced_command(psmouse, SYN_QUE_MODEL)) 281 + return -1; 282 + 283 + if (ps2_command(&psmouse->ps2dev, &param, PSMOUSE_CMD_SETRATE)) 284 + return -1; 285 + 286 + /* Advanced gesture mode also sends multi finger data */ 287 + priv->capabilities |= BIT(1); 288 + 289 + return 0; 290 + } 291 + 292 + static int synaptics_set_mode(struct psmouse *psmouse) 273 293 { 274 294 struct synaptics_data *priv = psmouse->private; 275 295 276 - priv->mode = SYN_BIT_ABSOLUTE_MODE; 277 - if (SYN_ID_MAJOR(priv->identity) >= 4) 296 + priv->mode = 0; 297 + if (priv->absolute_mode) 298 + priv->mode |= SYN_BIT_ABSOLUTE_MODE; 299 + if (priv->disable_gesture) 278 300 priv->mode |= SYN_BIT_DISABLE_GESTURE; 301 + if (psmouse->rate >= 80) 302 + priv->mode |= SYN_BIT_HIGH_RATE; 279 303 if (SYN_CAP_EXTENDED(priv->capabilities)) 280 304 priv->mode |= SYN_BIT_W_MODE; 281 305 282 306 if (synaptics_mode_cmd(psmouse, priv->mode)) 283 307 return -1; 308 + 309 + if (priv->absolute_mode && 310 + synaptics_set_advanced_gesture_mode(psmouse)) { 311 + psmouse_err(psmouse, "Advanced gesture mode init failed.\n"); 312 + return -1; 313 + } 284 314 285 315 return 0; 286 316 } ··· 328 298 } 329 299 330 300 synaptics_mode_cmd(psmouse, priv->mode); 331 - } 332 - 333 - static int synaptics_set_advanced_gesture_mode(struct psmouse *psmouse) 334 - { 335 - static unsigned char param = 0xc8; 336 - struct synaptics_data *priv = psmouse->private; 337 - 338 - if (!(SYN_CAP_ADV_GESTURE(priv->ext_cap_0c) || 339 - SYN_CAP_IMAGE_SENSOR(priv->ext_cap_0c))) 340 - return 0; 341 - 342 - if (psmouse_sliced_command(psmouse, SYN_QUE_MODEL)) 343 - return -1; 344 - if (ps2_command(&psmouse->ps2dev, &param, PSMOUSE_CMD_SETRATE)) 345 - return -1; 346 - 347 - /* Advanced gesture mode also sends multi finger data */ 348 - priv->capabilities |= BIT(1); 349 - 350 - return 0; 351 301 } 352 302 353 303 /***************************************************************************** ··· 1153 1143 { 1154 1144 int i; 1155 1145 1146 + /* Things that apply to both modes */ 1156 1147 __set_bit(INPUT_PROP_POINTER, dev->propbit); 1148 + __set_bit(EV_KEY, dev->evbit); 1149 + __set_bit(BTN_LEFT, dev->keybit); 1150 + __set_bit(BTN_RIGHT, dev->keybit); 1157 1151 1152 + if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) 1153 + __set_bit(BTN_MIDDLE, dev->keybit); 1154 + 1155 + if (!priv->absolute_mode) { 1156 + /* Relative mode */ 1157 + __set_bit(EV_REL, dev->evbit); 1158 + __set_bit(REL_X, dev->relbit); 1159 + __set_bit(REL_Y, dev->relbit); 1160 + return; 1161 + } 1162 + 1163 + /* Absolute mode */ 1158 1164 __set_bit(EV_ABS, dev->evbit); 1159 1165 set_abs_position_params(dev, priv, ABS_X, ABS_Y); 1160 1166 input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); ··· 1196 1170 if (SYN_CAP_PALMDETECT(priv->capabilities)) 1197 1171 input_set_abs_params(dev, ABS_TOOL_WIDTH, 0, 15, 0, 0); 1198 1172 1199 - __set_bit(EV_KEY, dev->evbit); 1200 1173 __set_bit(BTN_TOUCH, dev->keybit); 1201 1174 __set_bit(BTN_TOOL_FINGER, dev->keybit); 1202 - __set_bit(BTN_LEFT, dev->keybit); 1203 - __set_bit(BTN_RIGHT, dev->keybit); 1204 1175 1205 1176 if (SYN_CAP_MULTIFINGER(priv->capabilities)) { 1206 1177 __set_bit(BTN_TOOL_DOUBLETAP, dev->keybit); 1207 1178 __set_bit(BTN_TOOL_TRIPLETAP, dev->keybit); 1208 1179 } 1209 - 1210 - if (SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) 1211 - __set_bit(BTN_MIDDLE, dev->keybit); 1212 1180 1213 1181 if (SYN_CAP_FOUR_BUTTON(priv->capabilities) || 1214 1182 SYN_CAP_MIDDLE_BUTTON(priv->capabilities)) { ··· 1225 1205 } 1226 1206 } 1227 1207 1208 + static ssize_t synaptics_show_disable_gesture(struct psmouse *psmouse, 1209 + void *data, char *buf) 1210 + { 1211 + struct synaptics_data *priv = psmouse->private; 1212 + 1213 + return sprintf(buf, "%c\n", priv->disable_gesture ? '1' : '0'); 1214 + } 1215 + 1216 + static ssize_t synaptics_set_disable_gesture(struct psmouse *psmouse, 1217 + void *data, const char *buf, 1218 + size_t len) 1219 + { 1220 + struct synaptics_data *priv = psmouse->private; 1221 + unsigned int value; 1222 + int err; 1223 + 1224 + err = kstrtouint(buf, 10, &value); 1225 + if (err) 1226 + return err; 1227 + 1228 + if (value > 1) 1229 + return -EINVAL; 1230 + 1231 + if (value == priv->disable_gesture) 1232 + return len; 1233 + 1234 + priv->disable_gesture = value; 1235 + if (value) 1236 + priv->mode |= SYN_BIT_DISABLE_GESTURE; 1237 + else 1238 + priv->mode &= ~SYN_BIT_DISABLE_GESTURE; 1239 + 1240 + if (synaptics_mode_cmd(psmouse, priv->mode)) 1241 + return -EIO; 1242 + 1243 + return len; 1244 + } 1245 + 1246 + PSMOUSE_DEFINE_ATTR(disable_gesture, S_IWUSR | S_IRUGO, NULL, 1247 + synaptics_show_disable_gesture, 1248 + synaptics_set_disable_gesture); 1249 + 1228 1250 static void synaptics_disconnect(struct psmouse *psmouse) 1229 1251 { 1252 + struct synaptics_data *priv = psmouse->private; 1253 + 1254 + if (!priv->absolute_mode && SYN_ID_DISGEST_SUPPORTED(priv->identity)) 1255 + device_remove_file(&psmouse->ps2dev.serio->dev, 1256 + &psmouse_attr_disable_gesture.dattr); 1257 + 1230 1258 synaptics_reset(psmouse); 1231 - kfree(psmouse->private); 1259 + kfree(priv); 1232 1260 psmouse->private = NULL; 1233 1261 } 1234 1262 ··· 1313 1245 return -1; 1314 1246 } 1315 1247 1316 - if (synaptics_set_absolute_mode(psmouse)) { 1248 + if (synaptics_set_mode(psmouse)) { 1317 1249 psmouse_err(psmouse, "Unable to initialize device.\n"); 1318 - return -1; 1319 - } 1320 - 1321 - if (synaptics_set_advanced_gesture_mode(psmouse)) { 1322 - psmouse_err(psmouse, 1323 - "Advanced gesture mode reconnect failed.\n"); 1324 1250 return -1; 1325 1251 } 1326 1252 ··· 1394 1332 broken_olpc_ec = dmi_check_system(olpc_dmi_table); 1395 1333 } 1396 1334 1397 - int synaptics_init(struct psmouse *psmouse) 1335 + static int __synaptics_init(struct psmouse *psmouse, bool absolute_mode) 1398 1336 { 1399 1337 struct synaptics_data *priv; 1338 + int err = -1; 1400 1339 1401 1340 /* 1402 - * The OLPC XO has issues with Synaptics' absolute mode; similarly to 1403 - * the HGPK, it quickly degrades and the hardware becomes jumpy and 1404 - * overly sensitive. Not only that, but the constant packet spew 1405 - * (even at a lowered 40pps rate) overloads the EC such that key 1406 - * presses on the keyboard are missed. Given all of that, don't 1407 - * even attempt to use Synaptics mode. Relative mode seems to work 1408 - * just fine. 1341 + * The OLPC XO has issues with Synaptics' absolute mode; the constant 1342 + * packet spew overloads the EC such that key presses on the keyboard 1343 + * are missed. Given that, don't even attempt to use Absolute mode. 1344 + * Relative mode seems to work just fine. 1409 1345 */ 1410 - if (broken_olpc_ec) { 1346 + if (absolute_mode && broken_olpc_ec) { 1411 1347 psmouse_info(psmouse, 1412 1348 "OLPC XO detected, not enabling Synaptics protocol.\n"); 1413 1349 return -ENODEV; ··· 1422 1362 goto init_fail; 1423 1363 } 1424 1364 1425 - if (synaptics_set_absolute_mode(psmouse)) { 1426 - psmouse_err(psmouse, "Unable to initialize device.\n"); 1427 - goto init_fail; 1428 - } 1365 + priv->absolute_mode = absolute_mode; 1366 + if (SYN_ID_DISGEST_SUPPORTED(priv->identity)) 1367 + priv->disable_gesture = true; 1429 1368 1430 - if (synaptics_set_advanced_gesture_mode(psmouse)) { 1431 - psmouse_err(psmouse, "Advanced gesture mode init failed.\n"); 1369 + if (synaptics_set_mode(psmouse)) { 1370 + psmouse_err(psmouse, "Unable to initialize device.\n"); 1432 1371 goto init_fail; 1433 1372 } 1434 1373 ··· 1452 1393 psmouse->model = ((priv->model_id & 0x00ff0000) >> 8) | 1453 1394 (priv->model_id & 0x000000ff); 1454 1395 1455 - psmouse->protocol_handler = synaptics_process_byte; 1396 + if (absolute_mode) { 1397 + psmouse->protocol_handler = synaptics_process_byte; 1398 + psmouse->pktsize = 6; 1399 + } else { 1400 + /* Relative mode follows standard PS/2 mouse protocol */ 1401 + psmouse->protocol_handler = psmouse_process_byte; 1402 + psmouse->pktsize = 3; 1403 + } 1404 + 1456 1405 psmouse->set_rate = synaptics_set_rate; 1457 1406 psmouse->disconnect = synaptics_disconnect; 1458 1407 psmouse->reconnect = synaptics_reconnect; 1459 1408 psmouse->cleanup = synaptics_reset; 1460 - psmouse->pktsize = 6; 1461 1409 /* Synaptics can usually stay in sync without extra help */ 1462 1410 psmouse->resync_time = 0; 1463 1411 ··· 1483 1417 psmouse->rate = 40; 1484 1418 } 1485 1419 1420 + if (!priv->absolute_mode && SYN_ID_DISGEST_SUPPORTED(priv->identity)) { 1421 + err = device_create_file(&psmouse->ps2dev.serio->dev, 1422 + &psmouse_attr_disable_gesture.dattr); 1423 + if (err) { 1424 + psmouse_err(psmouse, 1425 + "Failed to create disable_gesture attribute (%d)", 1426 + err); 1427 + goto init_fail; 1428 + } 1429 + } 1430 + 1486 1431 return 0; 1487 1432 1488 1433 init_fail: 1489 1434 kfree(priv); 1490 - return -1; 1435 + return err; 1436 + } 1437 + 1438 + int synaptics_init(struct psmouse *psmouse) 1439 + { 1440 + return __synaptics_init(psmouse, true); 1441 + } 1442 + 1443 + int synaptics_init_relative(struct psmouse *psmouse) 1444 + { 1445 + return __synaptics_init(psmouse, false); 1491 1446 } 1492 1447 1493 1448 bool synaptics_supported(void)
+5
drivers/input/mouse/synaptics.h
··· 100 100 #define SYN_ID_MINOR(i) (((i) >> 16) & 0xff) 101 101 #define SYN_ID_FULL(i) ((SYN_ID_MAJOR(i) << 8) | SYN_ID_MINOR(i)) 102 102 #define SYN_ID_IS_SYNAPTICS(i) ((((i) >> 8) & 0xff) == 0x47) 103 + #define SYN_ID_DISGEST_SUPPORTED(i) (SYN_ID_MAJOR(i) >= 4) 103 104 104 105 /* synaptics special commands */ 105 106 #define SYN_PS_SET_MODE2 0x14 ··· 160 159 unsigned char mode; /* current mode byte */ 161 160 int scroll; 162 161 162 + bool absolute_mode; /* run in Absolute mode */ 163 + bool disable_gesture; /* disable gestures */ 164 + 163 165 struct serio *pt_port; /* Pass-through serio port */ 164 166 165 167 struct synaptics_mt_state mt_state; /* Current mt finger state */ ··· 179 175 void synaptics_module_init(void); 180 176 int synaptics_detect(struct psmouse *psmouse, bool set_properties); 181 177 int synaptics_init(struct psmouse *psmouse); 178 + int synaptics_init_relative(struct psmouse *psmouse); 182 179 void synaptics_reset(struct psmouse *psmouse); 183 180 bool synaptics_supported(void); 184 181
+12 -5
drivers/input/mouse/trackpoint.c
··· 89 89 struct trackpoint_data *tp = psmouse->private; 90 90 struct trackpoint_attr_data *attr = data; 91 91 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 92 - unsigned long value; 92 + unsigned char value; 93 + int err; 93 94 94 - if (strict_strtoul(buf, 10, &value) || value > 255) 95 - return -EINVAL; 95 + err = kstrtou8(buf, 10, &value); 96 + if (err) 97 + return err; 96 98 97 99 *field = value; 98 100 trackpoint_write(&psmouse->ps2dev, attr->command, value); ··· 117 115 struct trackpoint_data *tp = psmouse->private; 118 116 struct trackpoint_attr_data *attr = data; 119 117 unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset); 120 - unsigned long value; 118 + unsigned int value; 119 + int err; 121 120 122 - if (strict_strtoul(buf, 10, &value) || value > 1) 121 + err = kstrtouint(buf, 10, &value); 122 + if (err) 123 + return err; 124 + 125 + if (value > 1) 123 126 return -EINVAL; 124 127 125 128 if (attr->inverted)
+1 -12
drivers/input/serio/altera_ps2.c
··· 196 196 .of_match_table = altera_ps2_match, 197 197 }, 198 198 }; 199 - 200 - static int __init altera_ps2_init(void) 201 - { 202 - return platform_driver_register(&altera_ps2_driver); 203 - } 204 - module_init(altera_ps2_init); 205 - 206 - static void __exit altera_ps2_exit(void) 207 - { 208 - platform_driver_unregister(&altera_ps2_driver); 209 - } 210 - module_exit(altera_ps2_exit); 199 + module_platform_driver(altera_ps2_driver); 211 200 212 201 MODULE_DESCRIPTION("Altera University Program PS2 controller driver"); 213 202 MODULE_AUTHOR("Thomas Chou <thomas@wytron.com.tw>");
+1 -13
drivers/input/serio/at32psif.c
··· 358 358 .suspend = psif_suspend, 359 359 .resume = psif_resume, 360 360 }; 361 - 362 - static int __init psif_init(void) 363 - { 364 - return platform_driver_probe(&psif_driver, psif_probe); 365 - } 366 - 367 - static void __exit psif_exit(void) 368 - { 369 - platform_driver_unregister(&psif_driver); 370 - } 371 - 372 - module_init(psif_init); 373 - module_exit(psif_exit); 361 + module_platform_driver(psif_driver); 374 362 375 363 MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>"); 376 364 MODULE_DESCRIPTION("Atmel AVR32 PSIF PS/2 driver");
+15 -8
drivers/input/serio/i8042.c
··· 991 991 * Reset the controller and reset CRT to the original value set by BIOS. 992 992 */ 993 993 994 - static void i8042_controller_reset(void) 994 + static void i8042_controller_reset(bool force_reset) 995 995 { 996 996 i8042_flush(); 997 997 ··· 1016 1016 * Reset the controller if requested. 1017 1017 */ 1018 1018 1019 - if (i8042_reset) 1019 + if (i8042_reset || force_reset) 1020 1020 i8042_controller_selftest(); 1021 1021 1022 1022 /* ··· 1139 1139 * upsetting it. 1140 1140 */ 1141 1141 1142 - static int i8042_pm_reset(struct device *dev) 1142 + static int i8042_pm_suspend(struct device *dev) 1143 1143 { 1144 - i8042_controller_reset(); 1144 + i8042_controller_reset(true); 1145 1145 1146 1146 return 0; 1147 1147 } ··· 1163 1163 return 0; 1164 1164 } 1165 1165 1166 + static int i8042_pm_reset(struct device *dev) 1167 + { 1168 + i8042_controller_reset(false); 1169 + 1170 + return 0; 1171 + } 1172 + 1166 1173 static int i8042_pm_restore(struct device *dev) 1167 1174 { 1168 1175 return i8042_controller_resume(false); 1169 1176 } 1170 1177 1171 1178 static const struct dev_pm_ops i8042_pm_ops = { 1172 - .suspend = i8042_pm_reset, 1179 + .suspend = i8042_pm_suspend, 1173 1180 .resume = i8042_pm_resume, 1174 1181 .thaw = i8042_pm_thaw, 1175 1182 .poweroff = i8042_pm_reset, ··· 1192 1185 1193 1186 static void i8042_shutdown(struct platform_device *dev) 1194 1187 { 1195 - i8042_controller_reset(); 1188 + i8042_controller_reset(false); 1196 1189 } 1197 1190 1198 1191 static int __init i8042_create_kbd_port(void) ··· 1431 1424 out_fail: 1432 1425 i8042_free_aux_ports(); /* in case KBD failed but AUX not */ 1433 1426 i8042_free_irqs(); 1434 - i8042_controller_reset(); 1427 + i8042_controller_reset(false); 1435 1428 i8042_platform_device = NULL; 1436 1429 1437 1430 return error; ··· 1441 1434 { 1442 1435 i8042_unregister_ports(); 1443 1436 i8042_free_irqs(); 1444 - i8042_controller_reset(); 1437 + i8042_controller_reset(false); 1445 1438 i8042_platform_device = NULL; 1446 1439 1447 1440 return 0;
+1 -13
drivers/input/serio/rpckbd.c
··· 143 143 .owner = THIS_MODULE, 144 144 }, 145 145 }; 146 - 147 - static int __init rpckbd_init(void) 148 - { 149 - return platform_driver_register(&rpckbd_driver); 150 - } 151 - 152 - static void __exit rpckbd_exit(void) 153 - { 154 - platform_driver_unregister(&rpckbd_driver); 155 - } 156 - 157 - module_init(rpckbd_init); 158 - module_exit(rpckbd_exit); 146 + module_platform_driver(rpckbd_driver);
+1 -13
drivers/input/serio/xilinx_ps2.c
··· 369 369 .probe = xps2_of_probe, 370 370 .remove = __devexit_p(xps2_of_remove), 371 371 }; 372 - 373 - static int __init xps2_init(void) 374 - { 375 - return platform_driver_register(&xps2_of_driver); 376 - } 377 - 378 - static void __exit xps2_cleanup(void) 379 - { 380 - platform_driver_unregister(&xps2_of_driver); 381 - } 382 - 383 - module_init(xps2_init); 384 - module_exit(xps2_cleanup); 372 + module_platform_driver(xps2_of_driver); 385 373 386 374 MODULE_AUTHOR("Xilinx, Inc."); 387 375 MODULE_DESCRIPTION("Xilinx XPS PS/2 driver");
+19 -15
drivers/input/tablet/aiptek.c
··· 1198 1198 store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1199 1199 { 1200 1200 struct aiptek *aiptek = dev_get_drvdata(dev); 1201 - long x; 1201 + int x; 1202 1202 1203 - if (strict_strtol(buf, 10, &x)) { 1203 + if (kstrtoint(buf, 10, &x)) { 1204 1204 size_t len = buf[count - 1] == '\n' ? count - 1 : count; 1205 1205 1206 1206 if (strncmp(buf, "disable", len)) ··· 1240 1240 store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1241 1241 { 1242 1242 struct aiptek *aiptek = dev_get_drvdata(dev); 1243 - long y; 1243 + int y; 1244 1244 1245 - if (strict_strtol(buf, 10, &y)) { 1245 + if (kstrtoint(buf, 10, &y)) { 1246 1246 size_t len = buf[count - 1] == '\n' ? count - 1 : count; 1247 1247 1248 1248 if (strncmp(buf, "disable", len)) ··· 1277 1277 store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1278 1278 { 1279 1279 struct aiptek *aiptek = dev_get_drvdata(dev); 1280 - long j; 1280 + int err, j; 1281 1281 1282 - if (strict_strtol(buf, 10, &j)) 1283 - return -EINVAL; 1282 + err = kstrtoint(buf, 10, &j); 1283 + if (err) 1284 + return err; 1284 1285 1285 - aiptek->newSetting.jitterDelay = (int)j; 1286 + aiptek->newSetting.jitterDelay = j; 1286 1287 return count; 1287 1288 } 1288 1289 ··· 1307 1306 store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1308 1307 { 1309 1308 struct aiptek *aiptek = dev_get_drvdata(dev); 1310 - long d; 1309 + int err, d; 1311 1310 1312 - if (strict_strtol(buf, 10, &d)) 1313 - return -EINVAL; 1311 + err = kstrtoint(buf, 10, &d); 1312 + if (err) 1313 + return err; 1314 1314 1315 - aiptek->newSetting.programmableDelay = (int)d; 1315 + aiptek->newSetting.programmableDelay = d; 1316 1316 return count; 1317 1317 } 1318 1318 ··· 1559 1557 store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1560 1558 { 1561 1559 struct aiptek *aiptek = dev_get_drvdata(dev); 1562 - long w; 1560 + int err, w; 1563 1561 1564 - if (strict_strtol(buf, 10, &w)) return -EINVAL; 1562 + err = kstrtoint(buf, 10, &w); 1563 + if (err) 1564 + return err; 1565 1565 1566 - aiptek->newSetting.wheel = (int)w; 1566 + aiptek->newSetting.wheel = w; 1567 1567 return count; 1568 1568 } 1569 1569
+91 -10
drivers/input/tablet/wacom_sys.c
··· 28 28 #define HID_USAGE_Y_TILT 0x3e 29 29 #define HID_USAGE_FINGER 0x22 30 30 #define HID_USAGE_STYLUS 0x20 31 - #define HID_COLLECTION 0xc0 31 + #define HID_COLLECTION 0xa1 32 + #define HID_COLLECTION_LOGICAL 0x02 33 + #define HID_COLLECTION_END 0xc0 32 34 33 35 enum { 34 36 WCM_UNDEFINED = 0, ··· 68 66 do { 69 67 retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), 70 68 USB_REQ_GET_REPORT, 71 - USB_TYPE_CLASS | USB_RECIP_INTERFACE, 69 + USB_DIR_IN | USB_TYPE_CLASS | 70 + USB_RECIP_INTERFACE, 72 71 (type << 8) + id, 73 72 intf->altsetting[0].desc.bInterfaceNumber, 74 73 buf, size, 100); ··· 167 164 usb_autopm_put_interface(wacom->intf); 168 165 } 169 166 170 - static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc, 167 + static int wacom_parse_logical_collection(unsigned char *report, 168 + struct wacom_features *features) 169 + { 170 + int length = 0; 171 + 172 + if (features->type == BAMBOO_PT) { 173 + 174 + /* Logical collection is only used by 3rd gen Bamboo Touch */ 175 + features->pktlen = WACOM_PKGLEN_BBTOUCH3; 176 + features->device_type = BTN_TOOL_DOUBLETAP; 177 + 178 + /* 179 + * Stylus and Touch have same active area 180 + * so compute physical size based on stylus 181 + * data before its overwritten. 182 + */ 183 + features->x_phy = 184 + (features->x_max * features->x_resolution) / 100; 185 + features->y_phy = 186 + (features->y_max * features->y_resolution) / 100; 187 + 188 + features->x_max = features->y_max = 189 + get_unaligned_le16(&report[10]); 190 + 191 + length = 11; 192 + } 193 + return length; 194 + } 195 + 196 + /* 197 + * Interface Descriptor of wacom devices can be incomplete and 198 + * inconsistent so wacom_features table is used to store stylus 199 + * device's packet lengths, various maximum values, and tablet 200 + * resolution based on product ID's. 201 + * 202 + * For devices that contain 2 interfaces, wacom_features table is 203 + * inaccurate for the touch interface. Since the Interface Descriptor 204 + * for touch interfaces has pretty complete data, this function exists 205 + * to query tablet for this missing information instead of hard coding in 206 + * an additional table. 207 + * 208 + * A typical Interface Descriptor for a stylus will contain a 209 + * boot mouse application collection that is not of interest and this 210 + * function will ignore it. 211 + * 212 + * It also contains a digitizer application collection that also is not 213 + * of interest since any information it contains would be duplicate 214 + * of what is in wacom_features. Usually it defines a report of an array 215 + * of bytes that could be used as max length of the stylus packet returned. 216 + * If it happens to define a Digitizer-Stylus Physical Collection then 217 + * the X and Y logical values contain valid data but it is ignored. 218 + * 219 + * A typical Interface Descriptor for a touch interface will contain a 220 + * Digitizer-Finger Physical Collection which will define both logical 221 + * X/Y maximum as well as the physical size of tablet. Since touch 222 + * interfaces haven't supported pressure or distance, this is enough 223 + * information to override invalid values in the wacom_features table. 224 + * 225 + * 3rd gen Bamboo Touch no longer define a Digitizer-Finger Pysical 226 + * Collection. Instead they define a Logical Collection with a single 227 + * Logical Maximum for both X and Y. 228 + */ 229 + static int wacom_parse_hid(struct usb_interface *intf, 230 + struct hid_descriptor *hid_desc, 171 231 struct wacom_features *features) 172 232 { 173 233 struct usb_device *dev = interface_to_usbdev(intf); ··· 310 244 /* penabled only accepts exact bytes of data */ 311 245 if (features->type == TABLETPC2FG) 312 246 features->pktlen = WACOM_PKGLEN_GRAPHIRE; 313 - if (features->type == BAMBOO_PT) 314 - features->pktlen = WACOM_PKGLEN_BBFUN; 315 247 features->device_type = BTN_TOOL_PEN; 316 248 features->x_max = 317 249 get_unaligned_le16(&report[i + 3]); ··· 351 287 /* penabled only accepts exact bytes of data */ 352 288 if (features->type == TABLETPC2FG) 353 289 features->pktlen = WACOM_PKGLEN_GRAPHIRE; 354 - if (features->type == BAMBOO_PT) 355 - features->pktlen = WACOM_PKGLEN_BBFUN; 356 290 features->device_type = BTN_TOOL_PEN; 357 291 features->y_max = 358 292 get_unaligned_le16(&report[i + 3]); ··· 364 302 i++; 365 303 break; 366 304 305 + /* 306 + * Requiring Stylus Usage will ignore boot mouse 307 + * X/Y values and some cases of invalid Digitizer X/Y 308 + * values commonly reported. 309 + */ 367 310 case HID_USAGE_STYLUS: 368 311 pen = 1; 369 312 i++; ··· 376 309 } 377 310 break; 378 311 379 - case HID_COLLECTION: 312 + case HID_COLLECTION_END: 380 313 /* reset UsagePage and Finger */ 381 314 finger = usage = 0; 315 + break; 316 + 317 + case HID_COLLECTION: 318 + i++; 319 + switch (report[i]) { 320 + case HID_COLLECTION_LOGICAL: 321 + i += wacom_parse_logical_collection(&report[i], 322 + features); 323 + break; 324 + } 382 325 break; 383 326 } 384 327 } ··· 425 348 WAC_HID_FEATURE_REPORT, 426 349 report_id, rep_data, 4, 1); 427 350 } while ((error < 0 || rep_data[1] != 4) && limit++ < WAC_MSG_RETRIES); 428 - } else if (features->type != TABLETPC) { 351 + } else if (features->type != TABLETPC && 352 + features->device_type == BTN_TOOL_PEN) { 429 353 do { 430 354 rep_data[0] = 2; 431 355 rep_data[1] = 2; ··· 563 485 if (!buf) 564 486 return -ENOMEM; 565 487 566 - if (wacom->wacom_wac.features.type == WACOM_21UX2) 488 + if (wacom->wacom_wac.features.type == WACOM_21UX2 || 489 + wacom->wacom_wac.features.type == WACOM_24HD) 567 490 led = (wacom->led.select[1] << 4) | 0x40; 568 491 569 492 led |= wacom->led.select[0] | 0x4; ··· 783 704 &intuos4_led_attr_group); 784 705 break; 785 706 707 + case WACOM_24HD: 786 708 case WACOM_21UX2: 787 709 wacom->led.select[0] = 0; 788 710 wacom->led.select[1] = 0; ··· 818 738 &intuos4_led_attr_group); 819 739 break; 820 740 741 + case WACOM_24HD: 821 742 case WACOM_21UX2: 822 743 sysfs_remove_group(&wacom->intf->dev.kobj, 823 744 &cintiq_led_attr_group);
+176 -11
drivers/input/tablet/wacom_wac.c
··· 452 452 if ((data[1] & 0xb8) == 0xa0) { 453 453 t = (data[6] << 2) | ((data[7] >> 6) & 3); 454 454 if ((features->type >= INTUOS4S && features->type <= INTUOS4L) || 455 - features->type == WACOM_21UX2) { 455 + features->type == WACOM_21UX2 || features->type == WACOM_24HD) { 456 456 t = (t << 1) | (data[1] & 1); 457 457 } 458 458 input_report_abs(input, ABS_PRESSURE, t); ··· 513 513 input_report_key(input, BTN_8, (data[3] & 0x80)); 514 514 } 515 515 if (data[1] | (data[2] & 0x01) | data[3]) { 516 + input_report_key(input, wacom->tool[1], 1); 517 + input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); 518 + } else { 519 + input_report_key(input, wacom->tool[1], 0); 520 + input_report_abs(input, ABS_MISC, 0); 521 + } 522 + } else if (features->type == WACOM_24HD) { 523 + input_report_key(input, BTN_0, (data[6] & 0x01)); 524 + input_report_key(input, BTN_1, (data[6] & 0x02)); 525 + input_report_key(input, BTN_2, (data[6] & 0x04)); 526 + input_report_key(input, BTN_3, (data[6] & 0x08)); 527 + input_report_key(input, BTN_4, (data[6] & 0x10)); 528 + input_report_key(input, BTN_5, (data[6] & 0x20)); 529 + input_report_key(input, BTN_6, (data[6] & 0x40)); 530 + input_report_key(input, BTN_7, (data[6] & 0x80)); 531 + input_report_key(input, BTN_8, (data[8] & 0x01)); 532 + input_report_key(input, BTN_9, (data[8] & 0x02)); 533 + input_report_key(input, BTN_A, (data[8] & 0x04)); 534 + input_report_key(input, BTN_B, (data[8] & 0x08)); 535 + input_report_key(input, BTN_C, (data[8] & 0x10)); 536 + input_report_key(input, BTN_X, (data[8] & 0x20)); 537 + input_report_key(input, BTN_Y, (data[8] & 0x40)); 538 + input_report_key(input, BTN_Z, (data[8] & 0x80)); 539 + 540 + /* 541 + * Three "buttons" are available on the 24HD which are 542 + * physically implemented as a touchstrip. Each button 543 + * is approximately 3 bits wide with a 2 bit spacing. 544 + * The raw touchstrip bits are stored at: 545 + * ((data[3] & 0x1f) << 8) | data[4]) 546 + */ 547 + input_report_key(input, KEY_PROG1, data[4] & 0x07); 548 + input_report_key(input, KEY_PROG2, data[4] & 0xE0); 549 + input_report_key(input, KEY_PROG3, data[3] & 0x1C); 550 + 551 + if (data[1] & 0x80) { 552 + input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f)); 553 + } else { 554 + /* Out of proximity, clear wheel value. */ 555 + input_report_abs(input, ABS_WHEEL, 0); 556 + } 557 + 558 + if (data[2] & 0x80) { 559 + input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f)); 560 + } else { 561 + /* Out of proximity, clear second wheel value. */ 562 + input_report_abs(input, ABS_THROTTLE, 0); 563 + } 564 + 565 + if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | data[8]) { 516 566 input_report_key(input, wacom->tool[1], 1); 517 567 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID); 518 568 } else { ··· 849 799 unsigned char *data = wacom->data; 850 800 int i; 851 801 802 + if (data[0] != 0x02) 803 + return 0; 804 + 852 805 for (i = 0; i < 2; i++) { 853 806 int offset = (data[1] & 0x80) ? (8 * i) : (9 * i); 854 807 bool touch = data[offset + 3] & 0x80; ··· 890 837 return 0; 891 838 } 892 839 840 + static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) 841 + { 842 + struct input_dev *input = wacom->input; 843 + int slot_id = data[0] - 2; /* data[0] is between 2 and 17 */ 844 + bool touch = data[1] & 0x80; 845 + 846 + touch = touch && !wacom->shared->stylus_in_proximity; 847 + 848 + input_mt_slot(input, slot_id); 849 + input_mt_report_slot_state(input, MT_TOOL_FINGER, touch); 850 + 851 + if (touch) { 852 + int x = (data[2] << 4) | (data[4] >> 4); 853 + int y = (data[3] << 4) | (data[4] & 0x0f); 854 + int w = data[6]; 855 + 856 + input_report_abs(input, ABS_MT_POSITION_X, x); 857 + input_report_abs(input, ABS_MT_POSITION_Y, y); 858 + input_report_abs(input, ABS_MT_TOUCH_MAJOR, w); 859 + } 860 + } 861 + 862 + static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data) 863 + { 864 + struct input_dev *input = wacom->input; 865 + 866 + input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0); 867 + input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0); 868 + input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0); 869 + input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0); 870 + } 871 + 872 + static int wacom_bpt3_touch(struct wacom_wac *wacom) 873 + { 874 + struct input_dev *input = wacom->input; 875 + unsigned char *data = wacom->data; 876 + int count = data[1] & 0x03; 877 + int i; 878 + 879 + if (data[0] != 0x02) 880 + return 0; 881 + 882 + /* data has up to 7 fixed sized 8-byte messages starting at data[2] */ 883 + for (i = 0; i < count; i++) { 884 + int offset = (8 * i) + 2; 885 + int msg_id = data[offset]; 886 + 887 + if (msg_id >= 2 && msg_id <= 17) 888 + wacom_bpt3_touch_msg(wacom, data + offset); 889 + else if (msg_id == 128) 890 + wacom_bpt3_button_msg(wacom, data + offset); 891 + 892 + } 893 + 894 + input_mt_report_pointer_emulation(input, true); 895 + 896 + input_sync(input); 897 + 898 + return 0; 899 + } 900 + 893 901 static int wacom_bpt_pen(struct wacom_wac *wacom) 894 902 { 895 903 struct input_dev *input = wacom->input; 896 904 unsigned char *data = wacom->data; 897 905 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0; 898 906 899 - /* 900 - * Similar to Graphire protocol, data[1] & 0x20 is proximity and 901 - * data[1] & 0x18 is tool ID. 0x30 is safety check to ignore 902 - * 2 unused tool ID's. 903 - */ 904 - prox = (data[1] & 0x30) == 0x30; 907 + if (data[0] != 0x02) 908 + return 0; 909 + 910 + prox = (data[1] & 0x20) == 0x20; 905 911 906 912 /* 907 913 * All reports shared between PEN and RUBBER tool must be ··· 1024 912 { 1025 913 if (len == WACOM_PKGLEN_BBTOUCH) 1026 914 return wacom_bpt_touch(wacom); 1027 - else if (len == WACOM_PKGLEN_BBFUN) 915 + else if (len == WACOM_PKGLEN_BBTOUCH3) 916 + return wacom_bpt3_touch(wacom); 917 + else if (len == WACOM_PKGLEN_BBFUN || len == WACOM_PKGLEN_BBPEN) 1028 918 return wacom_bpt_pen(wacom); 1029 919 1030 920 return 0; ··· 1069 955 case CINTIQ: 1070 956 case WACOM_BEE: 1071 957 case WACOM_21UX2: 958 + case WACOM_24HD: 1072 959 sync = wacom_intuos_irq(wacom_wac); 1073 960 break; 1074 961 ··· 1146 1031 features->type == BAMBOO_PT) 1147 1032 features->quirks |= WACOM_QUIRK_MULTI_INPUT; 1148 1033 1149 - /* quirks for bamboo touch */ 1034 + /* quirk for bamboo touch with 2 low res touches */ 1150 1035 if (features->type == BAMBOO_PT && 1151 - features->device_type == BTN_TOOL_DOUBLETAP) { 1036 + features->pktlen == WACOM_PKGLEN_BBTOUCH) { 1152 1037 features->x_max <<= 5; 1153 1038 features->y_max <<= 5; 1154 1039 features->x_fuzz <<= 5; ··· 1223 1108 __set_bit(BTN_STYLUS2, input_dev->keybit); 1224 1109 1225 1110 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 1111 + break; 1112 + 1113 + case WACOM_24HD: 1114 + __set_bit(BTN_A, input_dev->keybit); 1115 + __set_bit(BTN_B, input_dev->keybit); 1116 + __set_bit(BTN_C, input_dev->keybit); 1117 + __set_bit(BTN_X, input_dev->keybit); 1118 + __set_bit(BTN_Y, input_dev->keybit); 1119 + __set_bit(BTN_Z, input_dev->keybit); 1120 + 1121 + for (i = 0; i < 10; i++) 1122 + __set_bit(BTN_0 + i, input_dev->keybit); 1123 + 1124 + __set_bit(KEY_PROG1, input_dev->keybit); 1125 + __set_bit(KEY_PROG2, input_dev->keybit); 1126 + __set_bit(KEY_PROG3, input_dev->keybit); 1127 + 1128 + input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 1129 + input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0); 1130 + wacom_setup_cintiq(wacom_wac); 1226 1131 break; 1227 1132 1228 1133 case WACOM_21UX2: ··· 1375 1240 __set_bit(BTN_TOOL_FINGER, input_dev->keybit); 1376 1241 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); 1377 1242 1378 - input_mt_init_slots(input_dev, 2); 1243 + if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { 1244 + __set_bit(BTN_TOOL_TRIPLETAP, 1245 + input_dev->keybit); 1246 + __set_bit(BTN_TOOL_QUADTAP, 1247 + input_dev->keybit); 1248 + 1249 + input_mt_init_slots(input_dev, 16); 1250 + 1251 + input_set_abs_params(input_dev, 1252 + ABS_MT_TOUCH_MAJOR, 1253 + 0, 255, 0, 0); 1254 + } else { 1255 + input_mt_init_slots(input_dev, 2); 1256 + } 1257 + 1379 1258 input_set_abs_params(input_dev, ABS_MT_POSITION_X, 1380 1259 0, features->x_max, 1381 1260 features->x_fuzz, 0); ··· 1574 1425 static const struct wacom_features wacom_features_0xBC = 1575 1426 { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40840, 25400, 2047, 1576 1427 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 1428 + static const struct wacom_features wacom_features_0xF4 = 1429 + { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047, 1430 + 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 1577 1431 static const struct wacom_features wacom_features_0x3F = 1578 1432 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 1579 1433 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; ··· 1661 1509 static struct wacom_features wacom_features_0xDB = 1662 1510 { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023, 1663 1511 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1512 + static const struct wacom_features wacom_features_0xDD = 1513 + { "Wacom Bamboo Connect", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023, 1514 + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1515 + static const struct wacom_features wacom_features_0xDE = 1516 + { "Wacom Bamboo 16FG 4x5", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023, 1517 + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1518 + static const struct wacom_features wacom_features_0xDF = 1519 + { "Wacom Bamboo 16FG 6x8", WACOM_PKGLEN_BBPEN, 21648, 13700, 1023, 1520 + 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; 1664 1521 static const struct wacom_features wacom_features_0x6004 = 1665 1522 { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255, 1666 1523 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES }; ··· 1765 1604 { USB_DEVICE_WACOM(0xD8) }, 1766 1605 { USB_DEVICE_WACOM(0xDA) }, 1767 1606 { USB_DEVICE_WACOM(0xDB) }, 1607 + { USB_DEVICE_WACOM(0xDD) }, 1608 + { USB_DEVICE_WACOM(0xDE) }, 1609 + { USB_DEVICE_WACOM(0xDF) }, 1768 1610 { USB_DEVICE_WACOM(0xF0) }, 1769 1611 { USB_DEVICE_WACOM(0xCC) }, 1770 1612 { USB_DEVICE_WACOM(0x90) }, ··· 1780 1616 { USB_DEVICE_WACOM(0xE6) }, 1781 1617 { USB_DEVICE_WACOM(0xEC) }, 1782 1618 { USB_DEVICE_WACOM(0x47) }, 1619 + { USB_DEVICE_WACOM(0xF4) }, 1783 1620 { USB_DEVICE_LENOVO(0x6004) }, 1784 1621 { } 1785 1622 };
+4 -1
drivers/input/tablet/wacom_wac.h
··· 12 12 #include <linux/types.h> 13 13 14 14 /* maximum packet length for USB devices */ 15 - #define WACOM_PKGLEN_MAX 32 15 + #define WACOM_PKGLEN_MAX 64 16 16 17 17 /* packet length for individual models */ 18 18 #define WACOM_PKGLEN_PENPRTN 7 ··· 22 22 #define WACOM_PKGLEN_TPC1FG 5 23 23 #define WACOM_PKGLEN_TPC2FG 14 24 24 #define WACOM_PKGLEN_BBTOUCH 20 25 + #define WACOM_PKGLEN_BBTOUCH3 64 26 + #define WACOM_PKGLEN_BBPEN 10 25 27 26 28 /* device IDs */ 27 29 #define STYLUS_DEVICE_ID 0x02 ··· 59 57 INTUOS4S, 60 58 INTUOS4, 61 59 INTUOS4L, 60 + WACOM_24HD, 62 61 WACOM_21UX2, 63 62 CINTIQ, 64 63 WACOM_BEE,
+1 -12
drivers/input/touchscreen/88pm860x-ts.c
··· 217 217 .probe = pm860x_touch_probe, 218 218 .remove = __devexit_p(pm860x_touch_remove), 219 219 }; 220 - 221 - static int __init pm860x_touch_init(void) 222 - { 223 - return platform_driver_register(&pm860x_touch_driver); 224 - } 225 - module_init(pm860x_touch_init); 226 - 227 - static void __exit pm860x_touch_exit(void) 228 - { 229 - platform_driver_unregister(&pm860x_touch_driver); 230 - } 231 - module_exit(pm860x_touch_exit); 220 + module_platform_driver(pm860x_touch_driver); 232 221 233 222 MODULE_DESCRIPTION("Touchscreen driver for Marvell Semiconductor 88PM860x"); 234 223 MODULE_AUTHOR("Haojian Zhuang <haojian.zhuang@marvell.com>");
+41
drivers/input/touchscreen/Kconfig
··· 98 98 To compile this driver as a module, choose M here: the 99 99 module will be called atmel_mxt_ts. 100 100 101 + config TOUCHSCREEN_AUO_PIXCIR 102 + tristate "AUO in-cell touchscreen using Pixcir ICs" 103 + depends on I2C 104 + depends on GPIOLIB 105 + help 106 + Say Y here if you have a AUO display with in-cell touchscreen 107 + using Pixcir ICs. 108 + 109 + If unsure, say N. 110 + 111 + To compile this driver as a module, choose M here: the 112 + module will be called auo-pixcir-ts. 113 + 101 114 config TOUCHSCREEN_BITSY 102 115 tristate "Compaq iPAQ H3600 (Bitsy) touchscreen" 103 116 depends on SA1100_BITSY ··· 189 176 190 177 To compile this driver as a module, choose M here: the 191 178 module will be called eeti_ts. 179 + 180 + config TOUCHSCREEN_EGALAX 181 + tristate "EETI eGalax multi-touch panel support" 182 + depends on I2C 183 + help 184 + Say Y here to enable support for I2C connected EETI 185 + eGalax multi-touch panels. 186 + 187 + To compile this driver as a module, choose M here: the 188 + module will be called egalax_ts. 192 189 193 190 config TOUCHSCREEN_FUJITSU 194 191 tristate "Fujitsu serial touchscreen" ··· 458 435 To compile this driver as a module, choose M here: the 459 436 module will be called ucb1400_ts. 460 437 438 + config TOUCHSCREEN_PIXCIR 439 + tristate "PIXCIR I2C touchscreens" 440 + depends on I2C 441 + help 442 + Say Y here if you have a pixcir i2c touchscreen 443 + controller. 444 + 445 + If unsure, say N. 446 + 447 + To compile this driver as a module, choose M here: the 448 + module will be called pixcir_i2c_ts. 449 + 461 450 config TOUCHSCREEN_WM831X 462 451 tristate "Support for WM831x touchscreen controllers" 463 452 depends on MFD_WM831X ··· 576 541 - GoTop Super_Q2/GogoPen/PenPower tablets 577 542 - JASTEC USB Touch Controller/DigiTech DTR-02U 578 543 - Zytronic controllers 544 + - Elo TouchSystems 2700 IntelliTouch 579 545 580 546 Have a look at <http://linux.chapter7.ch/touchkit/> for 581 547 a usage description and the required user-space stuff. ··· 654 618 config TOUCHSCREEN_USB_JASTEC 655 619 default y 656 620 bool "JASTEC/DigiTech DTR-02U USB touch controller device support" if EXPERT 621 + depends on TOUCHSCREEN_USB_COMPOSITE 622 + 623 + config TOUCHSCREEN_USB_ELO 624 + default y 625 + bool "Elo TouchSystems 2700 IntelliTouch controller device support" if EXPERT 657 626 depends on TOUCHSCREEN_USB_COMPOSITE 658 627 659 628 config TOUCHSCREEN_USB_E2I
+3
drivers/input/touchscreen/Makefile
··· 14 14 obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o 15 15 obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o 16 16 obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o 17 + obj-$(CONFIG_TOUCHSCREEN_AUO_PIXCIR) += auo-pixcir-ts.o 17 18 obj-$(CONFIG_TOUCHSCREEN_BITSY) += h3600_ts_input.o 18 19 obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o 19 20 obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o ··· 24 23 obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o 25 24 obj-$(CONFIG_TOUCHSCREEN_EETI) += eeti_ts.o 26 25 obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o 26 + obj-$(CONFIG_TOUCHSCREEN_EGALAX) += egalax_ts.o 27 27 obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o 28 28 obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o 29 29 obj-$(CONFIG_TOUCHSCREEN_INTEL_MID) += intel-mid-touch.o ··· 41 39 obj-$(CONFIG_TOUCHSCREEN_USB_COMPOSITE) += usbtouchscreen.o 42 40 obj-$(CONFIG_TOUCHSCREEN_PCAP) += pcap_ts.o 43 41 obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o 42 + obj-$(CONFIG_TOUCHSCREEN_PIXCIR) += pixcir_i2c_ts.o 44 43 obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o 45 44 obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o 46 45 obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o
+8 -9
drivers/input/touchscreen/ad7877.c
··· 488 488 const char *buf, size_t count) 489 489 { 490 490 struct ad7877 *ts = dev_get_drvdata(dev); 491 - unsigned long val; 491 + unsigned int val; 492 492 int error; 493 493 494 - error = strict_strtoul(buf, 10, &val); 494 + error = kstrtouint(buf, 10, &val); 495 495 if (error) 496 496 return error; 497 497 ··· 518 518 const char *buf, size_t count) 519 519 { 520 520 struct ad7877 *ts = dev_get_drvdata(dev); 521 - unsigned long val; 521 + unsigned int val; 522 522 int error; 523 523 524 - error = strict_strtoul(buf, 10, &val); 524 + error = kstrtouint(buf, 10, &val); 525 525 if (error) 526 526 return error; 527 527 ··· 548 548 const char *buf, size_t count) 549 549 { 550 550 struct ad7877 *ts = dev_get_drvdata(dev); 551 - unsigned long val; 551 + unsigned int val; 552 552 int error; 553 553 554 - error = strict_strtoul(buf, 10, &val); 554 + error = kstrtouint(buf, 10, &val); 555 555 if (error) 556 556 return error; 557 557 ··· 579 579 const char *buf, size_t count) 580 580 { 581 581 struct ad7877 *ts = dev_get_drvdata(dev); 582 - unsigned long val; 582 + unsigned int val; 583 583 int error; 584 584 585 - error = strict_strtoul(buf, 10, &val); 585 + error = kstrtouint(buf, 10, &val); 586 586 if (error) 587 587 return error; 588 588 ··· 853 853 static struct spi_driver ad7877_driver = { 854 854 .driver = { 855 855 .name = "ad7877", 856 - .bus = &spi_bus_type, 857 856 .owner = THIS_MODULE, 858 857 .pm = &ad7877_pm, 859 858 },
+3 -28
drivers/input/touchscreen/ad7879-i2c.c
··· 16 16 17 17 #define AD7879_DEVID 0x79 /* AD7879-1/AD7889-1 */ 18 18 19 - #ifdef CONFIG_PM_SLEEP 20 - static int ad7879_i2c_suspend(struct device *dev) 21 - { 22 - struct i2c_client *client = to_i2c_client(dev); 23 - struct ad7879 *ts = i2c_get_clientdata(client); 24 - 25 - ad7879_suspend(ts); 26 - 27 - return 0; 28 - } 29 - 30 - static int ad7879_i2c_resume(struct device *dev) 31 - { 32 - struct i2c_client *client = to_i2c_client(dev); 33 - struct ad7879 *ts = i2c_get_clientdata(client); 34 - 35 - ad7879_resume(ts); 36 - 37 - return 0; 38 - } 39 - #endif 40 - 41 - static SIMPLE_DEV_PM_OPS(ad7879_i2c_pm, ad7879_i2c_suspend, ad7879_i2c_resume); 42 - 43 19 /* All registers are word-sized. 44 20 * AD7879 uses a high-byte first convention. 45 21 */ ··· 23 47 { 24 48 struct i2c_client *client = to_i2c_client(dev); 25 49 26 - return swab16(i2c_smbus_read_word_data(client, reg)); 50 + return i2c_smbus_read_word_swapped(client, reg); 27 51 } 28 52 29 53 static int ad7879_i2c_multi_read(struct device *dev, ··· 44 68 { 45 69 struct i2c_client *client = to_i2c_client(dev); 46 70 47 - return i2c_smbus_write_word_data(client, reg, swab16(val)); 71 + return i2c_smbus_write_word_swapped(client, reg, val); 48 72 } 49 73 50 74 static const struct ad7879_bus_ops ad7879_i2c_bus_ops = { ··· 95 119 .driver = { 96 120 .name = "ad7879", 97 121 .owner = THIS_MODULE, 98 - .pm = &ad7879_i2c_pm, 122 + .pm = &ad7879_pm_ops, 99 123 }, 100 124 .probe = ad7879_i2c_probe, 101 125 .remove = __devexit_p(ad7879_i2c_remove), ··· 117 141 MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); 118 142 MODULE_DESCRIPTION("AD7879(-1) touchscreen I2C bus driver"); 119 143 MODULE_LICENSE("GPL"); 120 - MODULE_ALIAS("i2c:ad7879");
+1 -26
drivers/input/touchscreen/ad7879-spi.c
··· 22 22 #define AD7879_WRITECMD(reg) (AD7879_CMD(reg)) 23 23 #define AD7879_READCMD(reg) (AD7879_CMD(reg) | AD7879_CMD_READ) 24 24 25 - #ifdef CONFIG_PM_SLEEP 26 - static int ad7879_spi_suspend(struct device *dev) 27 - { 28 - struct spi_device *spi = to_spi_device(dev); 29 - struct ad7879 *ts = spi_get_drvdata(spi); 30 - 31 - ad7879_suspend(ts); 32 - 33 - return 0; 34 - } 35 - 36 - static int ad7879_spi_resume(struct device *dev) 37 - { 38 - struct spi_device *spi = to_spi_device(dev); 39 - struct ad7879 *ts = spi_get_drvdata(spi); 40 - 41 - ad7879_resume(ts); 42 - 43 - return 0; 44 - } 45 - #endif 46 - 47 - static SIMPLE_DEV_PM_OPS(ad7879_spi_pm, ad7879_spi_suspend, ad7879_spi_resume); 48 - 49 25 /* 50 26 * ad7879_read/write are only used for initial setup and for sysfs controls. 51 27 * The main traffic is done in ad7879_collect(). ··· 150 174 static struct spi_driver ad7879_spi_driver = { 151 175 .driver = { 152 176 .name = "ad7879", 153 - .bus = &spi_bus_type, 154 177 .owner = THIS_MODULE, 155 - .pm = &ad7879_spi_pm, 178 + .pm = &ad7879_pm_ops, 156 179 }, 157 180 .probe = ad7879_spi_probe, 158 181 .remove = __devexit_p(ad7879_spi_remove),
+18 -7
drivers/input/touchscreen/ad7879.c
··· 281 281 __ad7879_disable(ts); 282 282 } 283 283 284 - void ad7879_suspend(struct ad7879 *ts) 284 + #ifdef CONFIG_PM_SLEEP 285 + static int ad7879_suspend(struct device *dev) 285 286 { 287 + struct ad7879 *ts = dev_get_drvdata(dev); 288 + 286 289 mutex_lock(&ts->input->mutex); 287 290 288 291 if (!ts->suspended && !ts->disabled && ts->input->users) ··· 294 291 ts->suspended = true; 295 292 296 293 mutex_unlock(&ts->input->mutex); 297 - } 298 - EXPORT_SYMBOL(ad7879_suspend); 299 294 300 - void ad7879_resume(struct ad7879 *ts) 295 + return 0; 296 + } 297 + 298 + static int ad7879_resume(struct device *dev) 301 299 { 300 + struct ad7879 *ts = dev_get_drvdata(dev); 301 + 302 302 mutex_lock(&ts->input->mutex); 303 303 304 304 if (ts->suspended && !ts->disabled && ts->input->users) ··· 310 304 ts->suspended = false; 311 305 312 306 mutex_unlock(&ts->input->mutex); 307 + 308 + return 0; 313 309 } 314 - EXPORT_SYMBOL(ad7879_resume); 310 + #endif 311 + 312 + SIMPLE_DEV_PM_OPS(ad7879_pm_ops, ad7879_suspend, ad7879_resume); 313 + EXPORT_SYMBOL(ad7879_pm_ops); 315 314 316 315 static void ad7879_toggle(struct ad7879 *ts, bool disable) 317 316 { ··· 351 340 const char *buf, size_t count) 352 341 { 353 342 struct ad7879 *ts = dev_get_drvdata(dev); 354 - unsigned long val; 343 + unsigned int val; 355 344 int error; 356 345 357 - error = strict_strtoul(buf, 10, &val); 346 + error = kstrtouint(buf, 10, &val); 358 347 if (error) 359 348 return error; 360 349
+2 -2
drivers/input/touchscreen/ad7879.h
··· 21 21 int (*write)(struct device *dev, u8 reg, u16 val); 22 22 }; 23 23 24 - void ad7879_suspend(struct ad7879 *); 25 - void ad7879_resume(struct ad7879 *); 24 + extern const struct dev_pm_ops ad7879_pm_ops; 25 + 26 26 struct ad7879 *ad7879_probe(struct device *dev, u8 devid, unsigned irq, 27 27 const struct ad7879_bus_ops *bops); 28 28 void ad7879_remove(struct ad7879 *);
+5 -4
drivers/input/touchscreen/ads7846.c
··· 602 602 const char *buf, size_t count) 603 603 { 604 604 struct ads7846 *ts = dev_get_drvdata(dev); 605 - unsigned long i; 605 + unsigned int i; 606 + int err; 606 607 607 - if (strict_strtoul(buf, 10, &i)) 608 - return -EINVAL; 608 + err = kstrtouint(buf, 10, &i); 609 + if (err) 610 + return err; 609 611 610 612 if (i) 611 613 ads7846_disable(ts); ··· 1426 1424 static struct spi_driver ads7846_driver = { 1427 1425 .driver = { 1428 1426 .name = "ads7846", 1429 - .bus = &spi_bus_type, 1430 1427 .owner = THIS_MODULE, 1431 1428 .pm = &ads7846_pm, 1432 1429 },
+1 -12
drivers/input/touchscreen/atmel-wm97xx.c
··· 429 429 .suspend = atmel_wm97xx_suspend, 430 430 .resume = atmel_wm97xx_resume, 431 431 }; 432 - 433 - static int __init atmel_wm97xx_init(void) 434 - { 435 - return platform_driver_probe(&atmel_wm97xx_driver, atmel_wm97xx_probe); 436 - } 437 - module_init(atmel_wm97xx_init); 438 - 439 - static void __exit atmel_wm97xx_exit(void) 440 - { 441 - platform_driver_unregister(&atmel_wm97xx_driver); 442 - } 443 - module_exit(atmel_wm97xx_exit); 432 + module_platform_driver(atmel_wm97xx_driver); 444 433 445 434 MODULE_AUTHOR("Hans-Christian Egtvedt <egtvedt@samfundet.no>"); 446 435 MODULE_DESCRIPTION("wm97xx continuous touch driver for Atmel AT91 and AVR32");
+1 -14
drivers/input/touchscreen/atmel_tsadcc.c
··· 351 351 .name = "atmel_tsadcc", 352 352 }, 353 353 }; 354 - 355 - static int __init atmel_tsadcc_init(void) 356 - { 357 - return platform_driver_register(&atmel_tsadcc_driver); 358 - } 359 - 360 - static void __exit atmel_tsadcc_exit(void) 361 - { 362 - platform_driver_unregister(&atmel_tsadcc_driver); 363 - } 364 - 365 - module_init(atmel_tsadcc_init); 366 - module_exit(atmel_tsadcc_exit); 367 - 354 + module_platform_driver(atmel_tsadcc_driver); 368 355 369 356 MODULE_LICENSE("GPL"); 370 357 MODULE_DESCRIPTION("Atmel TouchScreen Driver");
+652
drivers/input/touchscreen/auo-pixcir-ts.c
··· 1 + /* 2 + * Driver for AUO in-cell touchscreens 3 + * 4 + * Copyright (c) 2011 Heiko Stuebner <heiko@sntech.de> 5 + * 6 + * loosely based on auo_touch.c from Dell Streak vendor-kernel 7 + * 8 + * Copyright (c) 2008 QUALCOMM Incorporated. 9 + * Copyright (c) 2008 QUALCOMM USA, INC. 10 + * 11 + * 12 + * This software is licensed under the terms of the GNU General Public 13 + * License version 2, as published by the Free Software Foundation, and 14 + * may be copied, distributed, and modified under those terms. 15 + * 16 + * This program is distributed in the hope that it will be useful, 17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 + * GNU General Public License for more details. 20 + * 21 + */ 22 + 23 + #include <linux/kernel.h> 24 + #include <linux/module.h> 25 + #include <linux/interrupt.h> 26 + #include <linux/slab.h> 27 + #include <linux/input.h> 28 + #include <linux/jiffies.h> 29 + #include <linux/i2c.h> 30 + #include <linux/mutex.h> 31 + #include <linux/delay.h> 32 + #include <linux/gpio.h> 33 + #include <linux/input/auo-pixcir-ts.h> 34 + 35 + /* 36 + * Coordinate calculation: 37 + * X1 = X1_LSB + X1_MSB*256 38 + * Y1 = Y1_LSB + Y1_MSB*256 39 + * X2 = X2_LSB + X2_MSB*256 40 + * Y2 = Y2_LSB + Y2_MSB*256 41 + */ 42 + #define AUO_PIXCIR_REG_X1_LSB 0x00 43 + #define AUO_PIXCIR_REG_X1_MSB 0x01 44 + #define AUO_PIXCIR_REG_Y1_LSB 0x02 45 + #define AUO_PIXCIR_REG_Y1_MSB 0x03 46 + #define AUO_PIXCIR_REG_X2_LSB 0x04 47 + #define AUO_PIXCIR_REG_X2_MSB 0x05 48 + #define AUO_PIXCIR_REG_Y2_LSB 0x06 49 + #define AUO_PIXCIR_REG_Y2_MSB 0x07 50 + 51 + #define AUO_PIXCIR_REG_STRENGTH 0x0d 52 + #define AUO_PIXCIR_REG_STRENGTH_X1_LSB 0x0e 53 + #define AUO_PIXCIR_REG_STRENGTH_X1_MSB 0x0f 54 + 55 + #define AUO_PIXCIR_REG_RAW_DATA_X 0x2b 56 + #define AUO_PIXCIR_REG_RAW_DATA_Y 0x4f 57 + 58 + #define AUO_PIXCIR_REG_X_SENSITIVITY 0x6f 59 + #define AUO_PIXCIR_REG_Y_SENSITIVITY 0x70 60 + #define AUO_PIXCIR_REG_INT_SETTING 0x71 61 + #define AUO_PIXCIR_REG_INT_WIDTH 0x72 62 + #define AUO_PIXCIR_REG_POWER_MODE 0x73 63 + 64 + #define AUO_PIXCIR_REG_VERSION 0x77 65 + #define AUO_PIXCIR_REG_CALIBRATE 0x78 66 + 67 + #define AUO_PIXCIR_REG_TOUCHAREA_X1 0x1e 68 + #define AUO_PIXCIR_REG_TOUCHAREA_Y1 0x1f 69 + #define AUO_PIXCIR_REG_TOUCHAREA_X2 0x20 70 + #define AUO_PIXCIR_REG_TOUCHAREA_Y2 0x21 71 + 72 + #define AUO_PIXCIR_REG_EEPROM_CALIB_X 0x42 73 + #define AUO_PIXCIR_REG_EEPROM_CALIB_Y 0xad 74 + 75 + #define AUO_PIXCIR_INT_TPNUM_MASK 0xe0 76 + #define AUO_PIXCIR_INT_TPNUM_SHIFT 5 77 + #define AUO_PIXCIR_INT_RELEASE (1 << 4) 78 + #define AUO_PIXCIR_INT_ENABLE (1 << 3) 79 + #define AUO_PIXCIR_INT_POL_HIGH (1 << 2) 80 + #define AUO_PIXCIR_INT_MODE_MASK 0x03 81 + 82 + /* 83 + * Power modes: 84 + * active: scan speed 60Hz 85 + * sleep: scan speed 10Hz can be auto-activated, wakeup on 1st touch 86 + * deep sleep: scan speed 1Hz can only be entered or left manually. 87 + */ 88 + #define AUO_PIXCIR_POWER_ACTIVE 0x00 89 + #define AUO_PIXCIR_POWER_SLEEP 0x01 90 + #define AUO_PIXCIR_POWER_DEEP_SLEEP 0x02 91 + #define AUO_PIXCIR_POWER_MASK 0x03 92 + 93 + #define AUO_PIXCIR_POWER_ALLOW_SLEEP (1 << 2) 94 + #define AUO_PIXCIR_POWER_IDLE_TIME(ms) ((ms & 0xf) << 4) 95 + 96 + #define AUO_PIXCIR_CALIBRATE 0x03 97 + 98 + #define AUO_PIXCIR_EEPROM_CALIB_X_LEN 62 99 + #define AUO_PIXCIR_EEPROM_CALIB_Y_LEN 36 100 + 101 + #define AUO_PIXCIR_RAW_DATA_X_LEN 18 102 + #define AUO_PIXCIR_RAW_DATA_Y_LEN 11 103 + 104 + #define AUO_PIXCIR_STRENGTH_ENABLE (1 << 0) 105 + 106 + /* Touchscreen absolute values */ 107 + #define AUO_PIXCIR_REPORT_POINTS 2 108 + #define AUO_PIXCIR_MAX_AREA 0xff 109 + #define AUO_PIXCIR_PENUP_TIMEOUT_MS 10 110 + 111 + struct auo_pixcir_ts { 112 + struct i2c_client *client; 113 + struct input_dev *input; 114 + char phys[32]; 115 + 116 + /* special handling for touch_indicate interupt mode */ 117 + bool touch_ind_mode; 118 + 119 + wait_queue_head_t wait; 120 + bool stopped; 121 + }; 122 + 123 + struct auo_point_t { 124 + int coord_x; 125 + int coord_y; 126 + int area_major; 127 + int area_minor; 128 + int orientation; 129 + }; 130 + 131 + static int auo_pixcir_collect_data(struct auo_pixcir_ts *ts, 132 + struct auo_point_t *point) 133 + { 134 + struct i2c_client *client = ts->client; 135 + const struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data; 136 + uint8_t raw_coord[8]; 137 + uint8_t raw_area[4]; 138 + int i, ret; 139 + 140 + /* touch coordinates */ 141 + ret = i2c_smbus_read_i2c_block_data(client, AUO_PIXCIR_REG_X1_LSB, 142 + 8, raw_coord); 143 + if (ret < 0) { 144 + dev_err(&client->dev, "failed to read coordinate, %d\n", ret); 145 + return ret; 146 + } 147 + 148 + /* touch area */ 149 + ret = i2c_smbus_read_i2c_block_data(client, AUO_PIXCIR_REG_TOUCHAREA_X1, 150 + 4, raw_area); 151 + if (ret < 0) { 152 + dev_err(&client->dev, "could not read touch area, %d\n", ret); 153 + return ret; 154 + } 155 + 156 + for (i = 0; i < AUO_PIXCIR_REPORT_POINTS; i++) { 157 + point[i].coord_x = 158 + raw_coord[4 * i + 1] << 8 | raw_coord[4 * i]; 159 + point[i].coord_y = 160 + raw_coord[4 * i + 3] << 8 | raw_coord[4 * i + 2]; 161 + 162 + if (point[i].coord_x > pdata->x_max || 163 + point[i].coord_y > pdata->y_max) { 164 + dev_warn(&client->dev, "coordinates (%d,%d) invalid\n", 165 + point[i].coord_x, point[i].coord_y); 166 + point[i].coord_x = point[i].coord_y = 0; 167 + } 168 + 169 + /* determine touch major, minor and orientation */ 170 + point[i].area_major = max(raw_area[2 * i], raw_area[2 * i + 1]); 171 + point[i].area_minor = min(raw_area[2 * i], raw_area[2 * i + 1]); 172 + point[i].orientation = raw_area[2 * i] > raw_area[2 * i + 1]; 173 + } 174 + 175 + return 0; 176 + } 177 + 178 + static irqreturn_t auo_pixcir_interrupt(int irq, void *dev_id) 179 + { 180 + struct auo_pixcir_ts *ts = dev_id; 181 + struct i2c_client *client = ts->client; 182 + const struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data; 183 + struct auo_point_t point[AUO_PIXCIR_REPORT_POINTS]; 184 + int i; 185 + int ret; 186 + int fingers = 0; 187 + int abs = -1; 188 + 189 + while (!ts->stopped) { 190 + 191 + /* check for up event in touch touch_ind_mode */ 192 + if (ts->touch_ind_mode) { 193 + if (gpio_get_value(pdata->gpio_int) == 0) { 194 + input_mt_sync(ts->input); 195 + input_report_key(ts->input, BTN_TOUCH, 0); 196 + input_sync(ts->input); 197 + break; 198 + } 199 + } 200 + 201 + ret = auo_pixcir_collect_data(ts, point); 202 + if (ret < 0) { 203 + /* we want to loop only in touch_ind_mode */ 204 + if (!ts->touch_ind_mode) 205 + break; 206 + 207 + wait_event_timeout(ts->wait, ts->stopped, 208 + msecs_to_jiffies(AUO_PIXCIR_PENUP_TIMEOUT_MS)); 209 + continue; 210 + } 211 + 212 + for (i = 0; i < AUO_PIXCIR_REPORT_POINTS; i++) { 213 + if (point[i].coord_x > 0 || point[i].coord_y > 0) { 214 + input_report_abs(ts->input, ABS_MT_POSITION_X, 215 + point[i].coord_x); 216 + input_report_abs(ts->input, ABS_MT_POSITION_Y, 217 + point[i].coord_y); 218 + input_report_abs(ts->input, ABS_MT_TOUCH_MAJOR, 219 + point[i].area_major); 220 + input_report_abs(ts->input, ABS_MT_TOUCH_MINOR, 221 + point[i].area_minor); 222 + input_report_abs(ts->input, ABS_MT_ORIENTATION, 223 + point[i].orientation); 224 + input_mt_sync(ts->input); 225 + 226 + /* use first finger as source for singletouch */ 227 + if (fingers == 0) 228 + abs = i; 229 + 230 + /* number of touch points could also be queried 231 + * via i2c but would require an additional call 232 + */ 233 + fingers++; 234 + } 235 + } 236 + 237 + input_report_key(ts->input, BTN_TOUCH, fingers > 0); 238 + 239 + if (abs > -1) { 240 + input_report_abs(ts->input, ABS_X, point[abs].coord_x); 241 + input_report_abs(ts->input, ABS_Y, point[abs].coord_y); 242 + } 243 + 244 + input_sync(ts->input); 245 + 246 + /* we want to loop only in touch_ind_mode */ 247 + if (!ts->touch_ind_mode) 248 + break; 249 + 250 + wait_event_timeout(ts->wait, ts->stopped, 251 + msecs_to_jiffies(AUO_PIXCIR_PENUP_TIMEOUT_MS)); 252 + } 253 + 254 + return IRQ_HANDLED; 255 + } 256 + 257 + /* 258 + * Set the power mode of the device. 259 + * Valid modes are 260 + * - AUO_PIXCIR_POWER_ACTIVE 261 + * - AUO_PIXCIR_POWER_SLEEP - automatically left on first touch 262 + * - AUO_PIXCIR_POWER_DEEP_SLEEP 263 + */ 264 + static int auo_pixcir_power_mode(struct auo_pixcir_ts *ts, int mode) 265 + { 266 + struct i2c_client *client = ts->client; 267 + int ret; 268 + 269 + ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_POWER_MODE); 270 + if (ret < 0) { 271 + dev_err(&client->dev, "unable to read reg %Xh, %d\n", 272 + AUO_PIXCIR_REG_POWER_MODE, ret); 273 + return ret; 274 + } 275 + 276 + ret &= ~AUO_PIXCIR_POWER_MASK; 277 + ret |= mode; 278 + 279 + ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_POWER_MODE, ret); 280 + if (ret) { 281 + dev_err(&client->dev, "unable to write reg %Xh, %d\n", 282 + AUO_PIXCIR_REG_POWER_MODE, ret); 283 + return ret; 284 + } 285 + 286 + return 0; 287 + } 288 + 289 + static __devinit int auo_pixcir_int_config(struct auo_pixcir_ts *ts, 290 + int int_setting) 291 + { 292 + struct i2c_client *client = ts->client; 293 + struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data; 294 + int ret; 295 + 296 + ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING); 297 + if (ret < 0) { 298 + dev_err(&client->dev, "unable to read reg %Xh, %d\n", 299 + AUO_PIXCIR_REG_INT_SETTING, ret); 300 + return ret; 301 + } 302 + 303 + ret &= ~AUO_PIXCIR_INT_MODE_MASK; 304 + ret |= int_setting; 305 + ret |= AUO_PIXCIR_INT_POL_HIGH; /* always use high for interrupts */ 306 + 307 + ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_INT_SETTING, 308 + ret); 309 + if (ret < 0) { 310 + dev_err(&client->dev, "unable to write reg %Xh, %d\n", 311 + AUO_PIXCIR_REG_INT_SETTING, ret); 312 + return ret; 313 + } 314 + 315 + ts->touch_ind_mode = pdata->int_setting == AUO_PIXCIR_INT_TOUCH_IND; 316 + 317 + return 0; 318 + } 319 + 320 + /* control the generation of interrupts on the device side */ 321 + static int auo_pixcir_int_toggle(struct auo_pixcir_ts *ts, bool enable) 322 + { 323 + struct i2c_client *client = ts->client; 324 + int ret; 325 + 326 + ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_INT_SETTING); 327 + if (ret < 0) { 328 + dev_err(&client->dev, "unable to read reg %Xh, %d\n", 329 + AUO_PIXCIR_REG_INT_SETTING, ret); 330 + return ret; 331 + } 332 + 333 + if (enable) 334 + ret |= AUO_PIXCIR_INT_ENABLE; 335 + else 336 + ret &= ~AUO_PIXCIR_INT_ENABLE; 337 + 338 + ret = i2c_smbus_write_byte_data(client, AUO_PIXCIR_REG_INT_SETTING, 339 + ret); 340 + if (ret < 0) { 341 + dev_err(&client->dev, "unable to write reg %Xh, %d\n", 342 + AUO_PIXCIR_REG_INT_SETTING, ret); 343 + return ret; 344 + } 345 + 346 + return 0; 347 + } 348 + 349 + static int auo_pixcir_start(struct auo_pixcir_ts *ts) 350 + { 351 + struct i2c_client *client = ts->client; 352 + int ret; 353 + 354 + ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_ACTIVE); 355 + if (ret < 0) { 356 + dev_err(&client->dev, "could not set power mode, %d\n", 357 + ret); 358 + return ret; 359 + } 360 + 361 + ts->stopped = false; 362 + mb(); 363 + enable_irq(client->irq); 364 + 365 + ret = auo_pixcir_int_toggle(ts, 1); 366 + if (ret < 0) { 367 + dev_err(&client->dev, "could not enable interrupt, %d\n", 368 + ret); 369 + disable_irq(client->irq); 370 + return ret; 371 + } 372 + 373 + return 0; 374 + } 375 + 376 + static int auo_pixcir_stop(struct auo_pixcir_ts *ts) 377 + { 378 + struct i2c_client *client = ts->client; 379 + int ret; 380 + 381 + ret = auo_pixcir_int_toggle(ts, 0); 382 + if (ret < 0) { 383 + dev_err(&client->dev, "could not disable interrupt, %d\n", 384 + ret); 385 + return ret; 386 + } 387 + 388 + /* disable receiving of interrupts */ 389 + disable_irq(client->irq); 390 + ts->stopped = true; 391 + mb(); 392 + wake_up(&ts->wait); 393 + 394 + return auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_DEEP_SLEEP); 395 + } 396 + 397 + static int auo_pixcir_input_open(struct input_dev *dev) 398 + { 399 + struct auo_pixcir_ts *ts = input_get_drvdata(dev); 400 + int ret; 401 + 402 + ret = auo_pixcir_start(ts); 403 + if (ret) 404 + return ret; 405 + 406 + return 0; 407 + } 408 + 409 + static void auo_pixcir_input_close(struct input_dev *dev) 410 + { 411 + struct auo_pixcir_ts *ts = input_get_drvdata(dev); 412 + 413 + auo_pixcir_stop(ts); 414 + 415 + return; 416 + } 417 + 418 + #ifdef CONFIG_PM_SLEEP 419 + static int auo_pixcir_suspend(struct device *dev) 420 + { 421 + struct i2c_client *client = to_i2c_client(dev); 422 + struct auo_pixcir_ts *ts = i2c_get_clientdata(client); 423 + struct input_dev *input = ts->input; 424 + int ret = 0; 425 + 426 + mutex_lock(&input->mutex); 427 + 428 + /* when configured as wakeup source, device should always wake system 429 + * therefore start device if necessary 430 + */ 431 + if (device_may_wakeup(&client->dev)) { 432 + /* need to start device if not open, to be wakeup source */ 433 + if (!input->users) { 434 + ret = auo_pixcir_start(ts); 435 + if (ret) 436 + goto unlock; 437 + } 438 + 439 + enable_irq_wake(client->irq); 440 + ret = auo_pixcir_power_mode(ts, AUO_PIXCIR_POWER_SLEEP); 441 + } else if (input->users) { 442 + ret = auo_pixcir_stop(ts); 443 + } 444 + 445 + unlock: 446 + mutex_unlock(&input->mutex); 447 + 448 + return ret; 449 + } 450 + 451 + static int auo_pixcir_resume(struct device *dev) 452 + { 453 + struct i2c_client *client = to_i2c_client(dev); 454 + struct auo_pixcir_ts *ts = i2c_get_clientdata(client); 455 + struct input_dev *input = ts->input; 456 + int ret = 0; 457 + 458 + mutex_lock(&input->mutex); 459 + 460 + if (device_may_wakeup(&client->dev)) { 461 + disable_irq_wake(client->irq); 462 + 463 + /* need to stop device if it was not open on suspend */ 464 + if (!input->users) { 465 + ret = auo_pixcir_stop(ts); 466 + if (ret) 467 + goto unlock; 468 + } 469 + 470 + /* device wakes automatically from SLEEP */ 471 + } else if (input->users) { 472 + ret = auo_pixcir_start(ts); 473 + } 474 + 475 + unlock: 476 + mutex_unlock(&input->mutex); 477 + 478 + return ret; 479 + } 480 + #endif 481 + 482 + static SIMPLE_DEV_PM_OPS(auo_pixcir_pm_ops, auo_pixcir_suspend, 483 + auo_pixcir_resume); 484 + 485 + static int __devinit auo_pixcir_probe(struct i2c_client *client, 486 + const struct i2c_device_id *id) 487 + { 488 + const struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data; 489 + struct auo_pixcir_ts *ts; 490 + struct input_dev *input_dev; 491 + int ret; 492 + 493 + if (!pdata) 494 + return -EINVAL; 495 + 496 + ts = kzalloc(sizeof(struct auo_pixcir_ts), GFP_KERNEL); 497 + if (!ts) 498 + return -ENOMEM; 499 + 500 + ret = gpio_request(pdata->gpio_int, "auo_pixcir_ts_int"); 501 + if (ret) { 502 + dev_err(&client->dev, "request of gpio %d failed, %d\n", 503 + pdata->gpio_int, ret); 504 + goto err_gpio_int; 505 + } 506 + 507 + if (pdata->init_hw) 508 + pdata->init_hw(client); 509 + 510 + ts->client = client; 511 + ts->touch_ind_mode = 0; 512 + init_waitqueue_head(&ts->wait); 513 + 514 + snprintf(ts->phys, sizeof(ts->phys), 515 + "%s/input0", dev_name(&client->dev)); 516 + 517 + input_dev = input_allocate_device(); 518 + if (!input_dev) { 519 + dev_err(&client->dev, "could not allocate input device\n"); 520 + goto err_input_alloc; 521 + } 522 + 523 + ts->input = input_dev; 524 + 525 + input_dev->name = "AUO-Pixcir touchscreen"; 526 + input_dev->phys = ts->phys; 527 + input_dev->id.bustype = BUS_I2C; 528 + input_dev->dev.parent = &client->dev; 529 + 530 + input_dev->open = auo_pixcir_input_open; 531 + input_dev->close = auo_pixcir_input_close; 532 + 533 + __set_bit(EV_ABS, input_dev->evbit); 534 + __set_bit(EV_KEY, input_dev->evbit); 535 + 536 + __set_bit(BTN_TOUCH, input_dev->keybit); 537 + 538 + /* For single touch */ 539 + input_set_abs_params(input_dev, ABS_X, 0, pdata->x_max, 0, 0); 540 + input_set_abs_params(input_dev, ABS_Y, 0, pdata->y_max, 0, 0); 541 + 542 + /* For multi touch */ 543 + input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0, 544 + pdata->x_max, 0, 0); 545 + input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0, 546 + pdata->y_max, 0, 0); 547 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, 548 + AUO_PIXCIR_MAX_AREA, 0, 0); 549 + input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, 550 + AUO_PIXCIR_MAX_AREA, 0, 0); 551 + input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); 552 + 553 + ret = i2c_smbus_read_byte_data(client, AUO_PIXCIR_REG_VERSION); 554 + if (ret < 0) 555 + goto err_fw_vers; 556 + dev_info(&client->dev, "firmware version 0x%X\n", ret); 557 + 558 + ret = auo_pixcir_int_config(ts, pdata->int_setting); 559 + if (ret) 560 + goto err_fw_vers; 561 + 562 + input_set_drvdata(ts->input, ts); 563 + ts->stopped = true; 564 + 565 + ret = request_threaded_irq(client->irq, NULL, auo_pixcir_interrupt, 566 + IRQF_TRIGGER_RISING | IRQF_ONESHOT, 567 + input_dev->name, ts); 568 + if (ret) { 569 + dev_err(&client->dev, "irq %d requested failed\n", client->irq); 570 + goto err_fw_vers; 571 + } 572 + 573 + /* stop device and put it into deep sleep until it is opened */ 574 + ret = auo_pixcir_stop(ts); 575 + if (ret < 0) 576 + goto err_input_register; 577 + 578 + ret = input_register_device(input_dev); 579 + if (ret) { 580 + dev_err(&client->dev, "could not register input device\n"); 581 + goto err_input_register; 582 + } 583 + 584 + i2c_set_clientdata(client, ts); 585 + 586 + return 0; 587 + 588 + err_input_register: 589 + free_irq(client->irq, ts); 590 + err_fw_vers: 591 + input_free_device(input_dev); 592 + err_input_alloc: 593 + if (pdata->exit_hw) 594 + pdata->exit_hw(client); 595 + gpio_free(pdata->gpio_int); 596 + err_gpio_int: 597 + kfree(ts); 598 + 599 + return ret; 600 + } 601 + 602 + static int __devexit auo_pixcir_remove(struct i2c_client *client) 603 + { 604 + struct auo_pixcir_ts *ts = i2c_get_clientdata(client); 605 + const struct auo_pixcir_ts_platdata *pdata = client->dev.platform_data; 606 + 607 + free_irq(client->irq, ts); 608 + 609 + input_unregister_device(ts->input); 610 + 611 + if (pdata->exit_hw) 612 + pdata->exit_hw(client); 613 + 614 + gpio_free(pdata->gpio_int); 615 + 616 + kfree(ts); 617 + 618 + return 0; 619 + } 620 + 621 + static const struct i2c_device_id auo_pixcir_idtable[] = { 622 + { "auo_pixcir_ts", 0 }, 623 + { } 624 + }; 625 + MODULE_DEVICE_TABLE(i2c, auo_pixcir_idtable); 626 + 627 + static struct i2c_driver auo_pixcir_driver = { 628 + .driver = { 629 + .owner = THIS_MODULE, 630 + .name = "auo_pixcir_ts", 631 + .pm = &auo_pixcir_pm_ops, 632 + }, 633 + .probe = auo_pixcir_probe, 634 + .remove = __devexit_p(auo_pixcir_remove), 635 + .id_table = auo_pixcir_idtable, 636 + }; 637 + 638 + static int __init auo_pixcir_init(void) 639 + { 640 + return i2c_add_driver(&auo_pixcir_driver); 641 + } 642 + module_init(auo_pixcir_init); 643 + 644 + static void __exit auo_pixcir_exit(void) 645 + { 646 + i2c_del_driver(&auo_pixcir_driver); 647 + } 648 + module_exit(auo_pixcir_exit); 649 + 650 + MODULE_DESCRIPTION("AUO-PIXCIR touchscreen driver"); 651 + MODULE_LICENSE("GPL v2"); 652 + MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
+1 -12
drivers/input/touchscreen/da9034-ts.c
··· 379 379 .probe = da9034_touch_probe, 380 380 .remove = __devexit_p(da9034_touch_remove), 381 381 }; 382 - 383 - static int __init da9034_touch_init(void) 384 - { 385 - return platform_driver_register(&da9034_touch_driver); 386 - } 387 - module_init(da9034_touch_init); 388 - 389 - static void __exit da9034_touch_exit(void) 390 - { 391 - platform_driver_unregister(&da9034_touch_driver); 392 - } 393 - module_exit(da9034_touch_exit); 382 + module_platform_driver(da9034_touch_driver); 394 383 395 384 MODULE_DESCRIPTION("Touchscreen driver for Dialog Semiconductor DA9034"); 396 385 MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>, Bin Yang <bin.yang@marvell.com>");
+303
drivers/input/touchscreen/egalax_ts.c
··· 1 + /* 2 + * Driver for EETI eGalax Multiple Touch Controller 3 + * 4 + * Copyright (C) 2011 Freescale Semiconductor, Inc. 5 + * 6 + * based on max11801_ts.c 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + */ 12 + 13 + /* EETI eGalax serial touch screen controller is a I2C based multiple 14 + * touch screen controller, it supports 5 point multiple touch. */ 15 + 16 + /* TODO: 17 + - auto idle mode support 18 + */ 19 + 20 + #include <linux/module.h> 21 + #include <linux/init.h> 22 + #include <linux/i2c.h> 23 + #include <linux/interrupt.h> 24 + #include <linux/input.h> 25 + #include <linux/irq.h> 26 + #include <linux/gpio.h> 27 + #include <linux/delay.h> 28 + #include <linux/slab.h> 29 + #include <linux/bitops.h> 30 + #include <linux/input/mt.h> 31 + 32 + /* 33 + * Mouse Mode: some panel may configure the controller to mouse mode, 34 + * which can only report one point at a given time. 35 + * This driver will ignore events in this mode. 36 + */ 37 + #define REPORT_MODE_MOUSE 0x1 38 + /* 39 + * Vendor Mode: this mode is used to transfer some vendor specific 40 + * messages. 41 + * This driver will ignore events in this mode. 42 + */ 43 + #define REPORT_MODE_VENDOR 0x3 44 + /* Multiple Touch Mode */ 45 + #define REPORT_MODE_MTTOUCH 0x4 46 + 47 + #define MAX_SUPPORT_POINTS 5 48 + 49 + #define EVENT_VALID_OFFSET 7 50 + #define EVENT_VALID_MASK (0x1 << EVENT_VALID_OFFSET) 51 + #define EVENT_ID_OFFSET 2 52 + #define EVENT_ID_MASK (0xf << EVENT_ID_OFFSET) 53 + #define EVENT_IN_RANGE (0x1 << 1) 54 + #define EVENT_DOWN_UP (0X1 << 0) 55 + 56 + #define MAX_I2C_DATA_LEN 10 57 + 58 + #define EGALAX_MAX_X 32760 59 + #define EGALAX_MAX_Y 32760 60 + #define EGALAX_MAX_TRIES 100 61 + 62 + struct egalax_ts { 63 + struct i2c_client *client; 64 + struct input_dev *input_dev; 65 + }; 66 + 67 + static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id) 68 + { 69 + struct egalax_ts *ts = dev_id; 70 + struct input_dev *input_dev = ts->input_dev; 71 + struct i2c_client *client = ts->client; 72 + u8 buf[MAX_I2C_DATA_LEN]; 73 + int id, ret, x, y, z; 74 + int tries = 0; 75 + bool down, valid; 76 + u8 state; 77 + 78 + do { 79 + ret = i2c_master_recv(client, buf, MAX_I2C_DATA_LEN); 80 + } while (ret == -EAGAIN && tries++ < EGALAX_MAX_TRIES); 81 + 82 + if (ret < 0) 83 + return IRQ_HANDLED; 84 + 85 + if (buf[0] != REPORT_MODE_MTTOUCH) { 86 + /* ignore mouse events and vendor events */ 87 + return IRQ_HANDLED; 88 + } 89 + 90 + state = buf[1]; 91 + x = (buf[3] << 8) | buf[2]; 92 + y = (buf[5] << 8) | buf[4]; 93 + z = (buf[7] << 8) | buf[6]; 94 + 95 + valid = state & EVENT_VALID_MASK; 96 + id = (state & EVENT_ID_MASK) >> EVENT_ID_OFFSET; 97 + down = state & EVENT_DOWN_UP; 98 + 99 + if (!valid || id > MAX_SUPPORT_POINTS) { 100 + dev_dbg(&client->dev, "point invalid\n"); 101 + return IRQ_HANDLED; 102 + } 103 + 104 + input_mt_slot(input_dev, id); 105 + input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down); 106 + 107 + dev_dbg(&client->dev, "%s id:%d x:%d y:%d z:%d", 108 + down ? "down" : "up", id, x, y, z); 109 + 110 + if (down) { 111 + input_report_abs(input_dev, ABS_MT_POSITION_X, x); 112 + input_report_abs(input_dev, ABS_MT_POSITION_Y, y); 113 + input_report_abs(input_dev, ABS_MT_PRESSURE, z); 114 + } 115 + 116 + input_mt_report_pointer_emulation(input_dev, true); 117 + input_sync(input_dev); 118 + 119 + return IRQ_HANDLED; 120 + } 121 + 122 + /* wake up controller by an falling edge of interrupt gpio. */ 123 + static int egalax_wake_up_device(struct i2c_client *client) 124 + { 125 + int gpio = irq_to_gpio(client->irq); 126 + int ret; 127 + 128 + ret = gpio_request(gpio, "egalax_irq"); 129 + if (ret < 0) { 130 + dev_err(&client->dev, 131 + "request gpio failed, cannot wake up controller: %d\n", 132 + ret); 133 + return ret; 134 + } 135 + 136 + /* wake up controller via an falling edge on IRQ gpio. */ 137 + gpio_direction_output(gpio, 0); 138 + gpio_set_value(gpio, 1); 139 + 140 + /* controller should be waken up, return irq. */ 141 + gpio_direction_input(gpio); 142 + gpio_free(gpio); 143 + 144 + return 0; 145 + } 146 + 147 + static int __devinit egalax_firmware_version(struct i2c_client *client) 148 + { 149 + static const u8 cmd[MAX_I2C_DATA_LEN] = { 0x03, 0x03, 0xa, 0x01, 0x41 }; 150 + int ret; 151 + 152 + ret = i2c_master_send(client, cmd, MAX_I2C_DATA_LEN); 153 + if (ret < 0) 154 + return ret; 155 + 156 + return 0; 157 + } 158 + 159 + static int __devinit egalax_ts_probe(struct i2c_client *client, 160 + const struct i2c_device_id *id) 161 + { 162 + struct egalax_ts *ts; 163 + struct input_dev *input_dev; 164 + int ret; 165 + int error; 166 + 167 + ts = kzalloc(sizeof(struct egalax_ts), GFP_KERNEL); 168 + if (!ts) { 169 + dev_err(&client->dev, "Failed to allocate memory\n"); 170 + return -ENOMEM; 171 + } 172 + 173 + input_dev = input_allocate_device(); 174 + if (!input_dev) { 175 + dev_err(&client->dev, "Failed to allocate memory\n"); 176 + error = -ENOMEM; 177 + goto err_free_ts; 178 + } 179 + 180 + ts->client = client; 181 + ts->input_dev = input_dev; 182 + 183 + /* controller may be in sleep, wake it up. */ 184 + egalax_wake_up_device(client); 185 + 186 + ret = egalax_firmware_version(client); 187 + if (ret < 0) { 188 + dev_err(&client->dev, "Failed to read firmware version\n"); 189 + error = -EIO; 190 + goto err_free_dev; 191 + } 192 + 193 + input_dev->name = "EETI eGalax Touch Screen"; 194 + input_dev->id.bustype = BUS_I2C; 195 + input_dev->dev.parent = &client->dev; 196 + 197 + __set_bit(EV_ABS, input_dev->evbit); 198 + __set_bit(EV_KEY, input_dev->evbit); 199 + __set_bit(BTN_TOUCH, input_dev->keybit); 200 + 201 + input_set_abs_params(input_dev, ABS_X, 0, EGALAX_MAX_X, 0, 0); 202 + input_set_abs_params(input_dev, ABS_Y, 0, EGALAX_MAX_Y, 0, 0); 203 + input_set_abs_params(input_dev, 204 + ABS_MT_POSITION_X, 0, EGALAX_MAX_X, 0, 0); 205 + input_set_abs_params(input_dev, 206 + ABS_MT_POSITION_X, 0, EGALAX_MAX_Y, 0, 0); 207 + input_mt_init_slots(input_dev, MAX_SUPPORT_POINTS); 208 + 209 + input_set_drvdata(input_dev, ts); 210 + 211 + error = request_threaded_irq(client->irq, NULL, egalax_ts_interrupt, 212 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 213 + "egalax_ts", ts); 214 + if (error < 0) { 215 + dev_err(&client->dev, "Failed to register interrupt\n"); 216 + goto err_free_dev; 217 + } 218 + 219 + error = input_register_device(ts->input_dev); 220 + if (error) 221 + goto err_free_irq; 222 + 223 + i2c_set_clientdata(client, ts); 224 + return 0; 225 + 226 + err_free_irq: 227 + free_irq(client->irq, ts); 228 + err_free_dev: 229 + input_free_device(input_dev); 230 + err_free_ts: 231 + kfree(ts); 232 + 233 + return error; 234 + } 235 + 236 + static __devexit int egalax_ts_remove(struct i2c_client *client) 237 + { 238 + struct egalax_ts *ts = i2c_get_clientdata(client); 239 + 240 + free_irq(client->irq, ts); 241 + 242 + input_unregister_device(ts->input_dev); 243 + kfree(ts); 244 + 245 + return 0; 246 + } 247 + 248 + static const struct i2c_device_id egalax_ts_id[] = { 249 + { "egalax_ts", 0 }, 250 + { } 251 + }; 252 + MODULE_DEVICE_TABLE(i2c, egalax_ts_id); 253 + 254 + #ifdef CONFIG_PM_SLEEP 255 + static int egalax_ts_suspend(struct device *dev) 256 + { 257 + static const u8 suspend_cmd[MAX_I2C_DATA_LEN] = { 258 + 0x3, 0x6, 0xa, 0x3, 0x36, 0x3f, 0x2, 0, 0, 0 259 + }; 260 + struct i2c_client *client = to_i2c_client(dev); 261 + int ret; 262 + 263 + ret = i2c_master_send(client, suspend_cmd, MAX_I2C_DATA_LEN); 264 + return ret > 0 ? 0 : ret; 265 + } 266 + 267 + static int egalax_ts_resume(struct device *dev) 268 + { 269 + struct i2c_client *client = to_i2c_client(dev); 270 + 271 + return egalax_wake_up_device(client); 272 + } 273 + #endif 274 + 275 + static SIMPLE_DEV_PM_OPS(egalax_ts_pm_ops, egalax_ts_suspend, egalax_ts_resume); 276 + 277 + static struct i2c_driver egalax_ts_driver = { 278 + .driver = { 279 + .name = "egalax_ts", 280 + .owner = THIS_MODULE, 281 + .pm = &egalax_ts_pm_ops, 282 + }, 283 + .id_table = egalax_ts_id, 284 + .probe = egalax_ts_probe, 285 + .remove = __devexit_p(egalax_ts_remove), 286 + }; 287 + 288 + static int __init egalax_ts_init(void) 289 + { 290 + return i2c_add_driver(&egalax_ts_driver); 291 + } 292 + 293 + static void __exit egalax_ts_exit(void) 294 + { 295 + i2c_del_driver(&egalax_ts_driver); 296 + } 297 + 298 + module_init(egalax_ts_init); 299 + module_exit(egalax_ts_exit); 300 + 301 + MODULE_AUTHOR("Freescale Semiconductor, Inc."); 302 + MODULE_DESCRIPTION("Touchscreen driver for EETI eGalax touch controller"); 303 + MODULE_LICENSE("GPL");
+1 -6
drivers/input/touchscreen/htcpen.c
··· 47 47 module_param(invert_y, bool, 0644); 48 48 MODULE_PARM_DESC(invert_y, "If set, Y axis is inverted"); 49 49 50 - static struct pnp_device_id pnp_ids[] = { 51 - { .id = "PNP0cc0" }, 52 - { .id = "" } 53 - }; 54 - MODULE_DEVICE_TABLE(pnp, pnp_ids); 55 - 56 50 static irqreturn_t htcpen_interrupt(int irq, void *handle) 57 51 { 58 52 struct input_dev *htcpen_dev = handle; ··· 231 237 }, 232 238 { } 233 239 }; 240 + MODULE_DEVICE_TABLE(dmi, htcshift_dmi_table); 234 241 235 242 static int __init htcpen_isa_init(void) 236 243 {
+1 -12
drivers/input/touchscreen/intel-mid-touch.c
··· 664 664 .probe = mrstouch_probe, 665 665 .remove = __devexit_p(mrstouch_remove), 666 666 }; 667 - 668 - static int __init mrstouch_init(void) 669 - { 670 - return platform_driver_register(&mrstouch_driver); 671 - } 672 - module_init(mrstouch_init); 673 - 674 - static void __exit mrstouch_exit(void) 675 - { 676 - platform_driver_unregister(&mrstouch_driver); 677 - } 678 - module_exit(mrstouch_exit); 667 + module_platform_driver(mrstouch_driver); 679 668 680 669 MODULE_AUTHOR("Sreedhara Murthy. D.S, sreedhara.ds@intel.com"); 681 670 MODULE_DESCRIPTION("Intel Moorestown Resistive Touch Screen Driver");
+1 -13
drivers/input/touchscreen/jornada720_ts.c
··· 172 172 .owner = THIS_MODULE, 173 173 }, 174 174 }; 175 - 176 - static int __init jornada720_ts_init(void) 177 - { 178 - return platform_driver_register(&jornada720_ts_driver); 179 - } 180 - 181 - static void __exit jornada720_ts_exit(void) 182 - { 183 - platform_driver_unregister(&jornada720_ts_driver); 184 - } 185 - 186 - module_init(jornada720_ts_init); 187 - module_exit(jornada720_ts_exit); 175 + module_platform_driver(jornada720_ts_driver);
+1 -12
drivers/input/touchscreen/lpc32xx_ts.c
··· 392 392 .pm = LPC32XX_TS_PM_OPS, 393 393 }, 394 394 }; 395 - 396 - static int __init lpc32xx_ts_init(void) 397 - { 398 - return platform_driver_register(&lpc32xx_ts_driver); 399 - } 400 - module_init(lpc32xx_ts_init); 401 - 402 - static void __exit lpc32xx_ts_exit(void) 403 - { 404 - platform_driver_unregister(&lpc32xx_ts_driver); 405 - } 406 - module_exit(lpc32xx_ts_exit); 395 + module_platform_driver(lpc32xx_ts_driver); 407 396 408 397 MODULE_AUTHOR("Kevin Wells <kevin.wells@nxp.com"); 409 398 MODULE_DESCRIPTION("LPC32XX TSC Driver");
+1 -13
drivers/input/touchscreen/mainstone-wm97xx.c
··· 302 302 .name = "wm97xx-touch", 303 303 }, 304 304 }; 305 - 306 - static int __init mainstone_wm97xx_init(void) 307 - { 308 - return platform_driver_register(&mainstone_wm97xx_driver); 309 - } 310 - 311 - static void __exit mainstone_wm97xx_exit(void) 312 - { 313 - platform_driver_unregister(&mainstone_wm97xx_driver); 314 - } 315 - 316 - module_init(mainstone_wm97xx_init); 317 - module_exit(mainstone_wm97xx_exit); 305 + module_platform_driver(mainstone_wm97xx_driver); 318 306 319 307 /* Module information */ 320 308 MODULE_AUTHOR("Liam Girdwood <lrg@slimlogic.co.uk>");
+1 -12
drivers/input/touchscreen/mc13783_ts.c
··· 240 240 .name = MC13783_TS_NAME, 241 241 }, 242 242 }; 243 - 244 - static int __init mc13783_ts_init(void) 245 - { 246 - return platform_driver_probe(&mc13783_ts_driver, &mc13783_ts_probe); 247 - } 248 - module_init(mc13783_ts_init); 249 - 250 - static void __exit mc13783_ts_exit(void) 251 - { 252 - platform_driver_unregister(&mc13783_ts_driver); 253 - } 254 - module_exit(mc13783_ts_exit); 243 + module_platform_driver(mc13783_ts_driver); 255 244 256 245 MODULE_DESCRIPTION("MC13783 input touchscreen driver"); 257 246 MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
+46 -71
drivers/input/touchscreen/migor_ts.c
··· 36 36 struct migor_ts_priv { 37 37 struct i2c_client *client; 38 38 struct input_dev *input; 39 - struct delayed_work work; 40 39 int irq; 41 40 }; 42 41 ··· 43 44 0x01, 0x06, 0x07, }; 44 45 static const u_int8_t migor_ts_dis_seq[17] = { }; 45 46 46 - static void migor_ts_poscheck(struct work_struct *work) 47 + static irqreturn_t migor_ts_isr(int irq, void *dev_id) 47 48 { 48 - struct migor_ts_priv *priv = container_of(work, 49 - struct migor_ts_priv, 50 - work.work); 49 + struct migor_ts_priv *priv = dev_id; 51 50 unsigned short xpos, ypos; 52 51 unsigned char event; 53 52 u_int8_t buf[16]; 53 + 54 + /* 55 + * The touch screen controller chip is hooked up to the CPU 56 + * using I2C and a single interrupt line. The interrupt line 57 + * is pulled low whenever someone taps the screen. To deassert 58 + * the interrupt line we need to acknowledge the interrupt by 59 + * communicating with the controller over the slow i2c bus. 60 + * 61 + * Since I2C bus controller may sleep we are using threaded 62 + * IRQ here. 63 + */ 54 64 55 65 memset(buf, 0, sizeof(buf)); 56 66 ··· 80 72 xpos = ((buf[11] & 0x03) << 8 | buf[10]); 81 73 event = buf[12]; 82 74 83 - if (event == EVENT_PENDOWN || event == EVENT_REPEAT) { 75 + switch (event) { 76 + case EVENT_PENDOWN: 77 + case EVENT_REPEAT: 84 78 input_report_key(priv->input, BTN_TOUCH, 1); 85 79 input_report_abs(priv->input, ABS_X, ypos); /*X-Y swap*/ 86 80 input_report_abs(priv->input, ABS_Y, xpos); 87 81 input_sync(priv->input); 88 - } else if (event == EVENT_PENUP) { 82 + break; 83 + 84 + case EVENT_PENUP: 89 85 input_report_key(priv->input, BTN_TOUCH, 0); 90 86 input_sync(priv->input); 87 + break; 91 88 } 89 + 92 90 out: 93 - enable_irq(priv->irq); 94 - } 95 - 96 - static irqreturn_t migor_ts_isr(int irq, void *dev_id) 97 - { 98 - struct migor_ts_priv *priv = dev_id; 99 - 100 - /* the touch screen controller chip is hooked up to the cpu 101 - * using i2c and a single interrupt line. the interrupt line 102 - * is pulled low whenever someone taps the screen. to deassert 103 - * the interrupt line we need to acknowledge the interrupt by 104 - * communicating with the controller over the slow i2c bus. 105 - * 106 - * we can't acknowledge from interrupt context since the i2c 107 - * bus controller may sleep, so we just disable the interrupt 108 - * here and handle the acknowledge using delayed work. 109 - */ 110 - 111 - disable_irq_nosync(irq); 112 - schedule_delayed_work(&priv->work, HZ / 20); 113 - 114 91 return IRQ_HANDLED; 115 92 } 116 - 117 93 118 94 static int migor_ts_open(struct input_dev *dev) 119 95 { ··· 123 131 124 132 disable_irq(priv->irq); 125 133 126 - /* cancel pending work and wait for migor_ts_poscheck() to finish */ 127 - if (cancel_delayed_work_sync(&priv->work)) { 128 - /* 129 - * if migor_ts_poscheck was canceled we need to enable IRQ 130 - * here to balance disable done in migor_ts_isr. 131 - */ 132 - enable_irq(priv->irq); 133 - } 134 - 135 134 /* disable controller */ 136 135 i2c_master_send(client, migor_ts_dis_seq, sizeof(migor_ts_dis_seq)); 137 136 ··· 137 154 int error; 138 155 139 156 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 140 - if (!priv) { 141 - dev_err(&client->dev, "failed to allocate driver data\n"); 142 - error = -ENOMEM; 143 - goto err0; 144 - } 145 - 146 - dev_set_drvdata(&client->dev, priv); 147 - 148 157 input = input_allocate_device(); 149 - if (!input) { 150 - dev_err(&client->dev, "Failed to allocate input device.\n"); 158 + if (!priv || !input) { 159 + dev_err(&client->dev, "failed to allocate memory\n"); 151 160 error = -ENOMEM; 152 - goto err1; 161 + goto err_free_mem; 153 162 } 163 + 164 + priv->client = client; 165 + priv->input = input; 166 + priv->irq = client->irq; 154 167 155 168 input->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); 156 - input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 169 + 170 + __set_bit(BTN_TOUCH, input->keybit); 157 171 158 172 input_set_abs_params(input, ABS_X, 95, 955, 0, 0); 159 173 input_set_abs_params(input, ABS_Y, 85, 935, 0, 0); ··· 164 184 165 185 input_set_drvdata(input, priv); 166 186 167 - priv->client = client; 168 - priv->input = input; 169 - INIT_DELAYED_WORK(&priv->work, migor_ts_poscheck); 170 - priv->irq = client->irq; 187 + error = request_threaded_irq(priv->irq, NULL, migor_ts_isr, 188 + IRQF_TRIGGER_LOW | IRQF_ONESHOT, 189 + client->name, priv); 190 + if (error) { 191 + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); 192 + goto err_free_mem; 193 + } 171 194 172 195 error = input_register_device(input); 173 196 if (error) 174 - goto err1; 197 + goto err_free_irq; 175 198 176 - error = request_irq(priv->irq, migor_ts_isr, IRQF_TRIGGER_LOW, 177 - client->name, priv); 178 - if (error) { 179 - dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); 180 - goto err2; 181 - } 182 - 199 + i2c_set_clientdata(client, priv); 183 200 device_init_wakeup(&client->dev, 1); 201 + 184 202 return 0; 185 203 186 - err2: 187 - input_unregister_device(input); 188 - input = NULL; /* so we dont try to free it below */ 189 - err1: 204 + err_free_irq: 205 + free_irq(priv->irq, priv); 206 + err_free_mem: 190 207 input_free_device(input); 191 208 kfree(priv); 192 - err0: 193 - dev_set_drvdata(&client->dev, NULL); 194 209 return error; 195 210 } 196 211 197 212 static int migor_ts_remove(struct i2c_client *client) 198 213 { 199 - struct migor_ts_priv *priv = dev_get_drvdata(&client->dev); 214 + struct migor_ts_priv *priv = i2c_get_clientdata(client); 200 215 201 216 free_irq(priv->irq, priv); 202 217 input_unregister_device(priv->input); ··· 205 230 static int migor_ts_suspend(struct device *dev) 206 231 { 207 232 struct i2c_client *client = to_i2c_client(dev); 208 - struct migor_ts_priv *priv = dev_get_drvdata(&client->dev); 233 + struct migor_ts_priv *priv = i2c_get_clientdata(client); 209 234 210 235 if (device_may_wakeup(&client->dev)) 211 236 enable_irq_wake(priv->irq); ··· 216 241 static int migor_ts_resume(struct device *dev) 217 242 { 218 243 struct i2c_client *client = to_i2c_client(dev); 219 - struct migor_ts_priv *priv = dev_get_drvdata(&client->dev); 244 + struct migor_ts_priv *priv = i2c_get_clientdata(client); 220 245 221 246 if (device_may_wakeup(&client->dev)) 222 247 disable_irq_wake(priv->irq);
+1 -13
drivers/input/touchscreen/pcap_ts.c
··· 252 252 .pm = PCAP_TS_PM_OPS, 253 253 }, 254 254 }; 255 - 256 - static int __init pcap_ts_init(void) 257 - { 258 - return platform_driver_register(&pcap_ts_driver); 259 - } 260 - 261 - static void __exit pcap_ts_exit(void) 262 - { 263 - platform_driver_unregister(&pcap_ts_driver); 264 - } 265 - 266 - module_init(pcap_ts_init); 267 - module_exit(pcap_ts_exit); 255 + module_platform_driver(pcap_ts_driver); 268 256 269 257 MODULE_DESCRIPTION("Motorola PCAP2 touchscreen driver"); 270 258 MODULE_AUTHOR("Daniel Ribeiro / Harald Welte");
+239
drivers/input/touchscreen/pixcir_i2c_ts.c
··· 1 + /* 2 + * Driver for Pixcir I2C touchscreen controllers. 3 + * 4 + * Copyright (C) 2010-2011 Pixcir, Inc. 5 + * 6 + * This software is licensed under the terms of the GNU General Public 7 + * License version 2, as published by the Free Software Foundation, and 8 + * may be copied, distributed, and modified under those terms. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public 16 + * License along with this library; if not, write to the Free Software 17 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 + */ 19 + 20 + #include <linux/delay.h> 21 + #include <linux/module.h> 22 + #include <linux/interrupt.h> 23 + #include <linux/slab.h> 24 + #include <linux/i2c.h> 25 + #include <linux/input.h> 26 + #include <linux/input/pixcir_ts.h> 27 + 28 + struct pixcir_i2c_ts_data { 29 + struct i2c_client *client; 30 + struct input_dev *input; 31 + const struct pixcir_ts_platform_data *chip; 32 + bool exiting; 33 + }; 34 + 35 + static void pixcir_ts_poscheck(struct pixcir_i2c_ts_data *data) 36 + { 37 + struct pixcir_i2c_ts_data *tsdata = data; 38 + u8 rdbuf[10], wrbuf[1] = { 0 }; 39 + u8 touch; 40 + int ret; 41 + 42 + ret = i2c_master_send(tsdata->client, wrbuf, sizeof(wrbuf)); 43 + if (ret != sizeof(wrbuf)) { 44 + dev_err(&tsdata->client->dev, 45 + "%s: i2c_master_send failed(), ret=%d\n", 46 + __func__, ret); 47 + return; 48 + } 49 + 50 + ret = i2c_master_recv(tsdata->client, rdbuf, sizeof(rdbuf)); 51 + if (ret != sizeof(rdbuf)) { 52 + dev_err(&tsdata->client->dev, 53 + "%s: i2c_master_recv failed(), ret=%d\n", 54 + __func__, ret); 55 + return; 56 + } 57 + 58 + touch = rdbuf[0]; 59 + if (touch) { 60 + u16 posx1 = (rdbuf[3] << 8) | rdbuf[2]; 61 + u16 posy1 = (rdbuf[5] << 8) | rdbuf[4]; 62 + u16 posx2 = (rdbuf[7] << 8) | rdbuf[6]; 63 + u16 posy2 = (rdbuf[9] << 8) | rdbuf[8]; 64 + 65 + input_report_key(tsdata->input, BTN_TOUCH, 1); 66 + input_report_abs(tsdata->input, ABS_X, posx1); 67 + input_report_abs(tsdata->input, ABS_Y, posy1); 68 + 69 + input_report_abs(tsdata->input, ABS_MT_POSITION_X, posx1); 70 + input_report_abs(tsdata->input, ABS_MT_POSITION_Y, posy1); 71 + input_mt_sync(tsdata->input); 72 + 73 + if (touch == 2) { 74 + input_report_abs(tsdata->input, 75 + ABS_MT_POSITION_X, posx2); 76 + input_report_abs(tsdata->input, 77 + ABS_MT_POSITION_Y, posy2); 78 + input_mt_sync(tsdata->input); 79 + } 80 + } else { 81 + input_report_key(tsdata->input, BTN_TOUCH, 0); 82 + } 83 + 84 + input_sync(tsdata->input); 85 + } 86 + 87 + static irqreturn_t pixcir_ts_isr(int irq, void *dev_id) 88 + { 89 + struct pixcir_i2c_ts_data *tsdata = dev_id; 90 + 91 + while (!tsdata->exiting) { 92 + pixcir_ts_poscheck(tsdata); 93 + 94 + if (tsdata->chip->attb_read_val()) 95 + break; 96 + 97 + msleep(20); 98 + } 99 + 100 + return IRQ_HANDLED; 101 + } 102 + 103 + #ifdef CONFIG_PM_SLEEP 104 + static int pixcir_i2c_ts_suspend(struct device *dev) 105 + { 106 + struct i2c_client *client = to_i2c_client(dev); 107 + 108 + if (device_may_wakeup(&client->dev)) 109 + enable_irq_wake(client->irq); 110 + 111 + return 0; 112 + } 113 + 114 + static int pixcir_i2c_ts_resume(struct device *dev) 115 + { 116 + struct i2c_client *client = to_i2c_client(dev); 117 + 118 + if (device_may_wakeup(&client->dev)) 119 + disable_irq_wake(client->irq); 120 + 121 + return 0; 122 + } 123 + #endif 124 + 125 + static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops, 126 + pixcir_i2c_ts_suspend, pixcir_i2c_ts_resume); 127 + 128 + static int __devinit pixcir_i2c_ts_probe(struct i2c_client *client, 129 + const struct i2c_device_id *id) 130 + { 131 + const struct pixcir_ts_platform_data *pdata = client->dev.platform_data; 132 + struct pixcir_i2c_ts_data *tsdata; 133 + struct input_dev *input; 134 + int error; 135 + 136 + if (!pdata) { 137 + dev_err(&client->dev, "platform data not defined\n"); 138 + return -EINVAL; 139 + } 140 + 141 + tsdata = kzalloc(sizeof(*tsdata), GFP_KERNEL); 142 + input = input_allocate_device(); 143 + if (!tsdata || !input) { 144 + dev_err(&client->dev, "Failed to allocate driver data!\n"); 145 + error = -ENOMEM; 146 + goto err_free_mem; 147 + } 148 + 149 + tsdata->client = client; 150 + tsdata->input = input; 151 + tsdata->chip = pdata; 152 + 153 + input->name = client->name; 154 + input->id.bustype = BUS_I2C; 155 + input->dev.parent = &client->dev; 156 + 157 + __set_bit(EV_KEY, input->evbit); 158 + __set_bit(EV_ABS, input->evbit); 159 + __set_bit(BTN_TOUCH, input->keybit); 160 + input_set_abs_params(input, ABS_X, 0, pdata->x_max, 0, 0); 161 + input_set_abs_params(input, ABS_Y, 0, pdata->y_max, 0, 0); 162 + input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0); 163 + input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0); 164 + 165 + input_set_drvdata(input, tsdata); 166 + 167 + error = request_threaded_irq(client->irq, NULL, pixcir_ts_isr, 168 + IRQF_TRIGGER_FALLING, 169 + client->name, tsdata); 170 + if (error) { 171 + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); 172 + goto err_free_mem; 173 + } 174 + 175 + error = input_register_device(input); 176 + if (error) 177 + goto err_free_irq; 178 + 179 + i2c_set_clientdata(client, tsdata); 180 + device_init_wakeup(&client->dev, 1); 181 + 182 + return 0; 183 + 184 + err_free_irq: 185 + free_irq(client->irq, tsdata); 186 + err_free_mem: 187 + input_free_device(input); 188 + kfree(tsdata); 189 + return error; 190 + } 191 + 192 + static int __devexit pixcir_i2c_ts_remove(struct i2c_client *client) 193 + { 194 + struct pixcir_i2c_ts_data *tsdata = i2c_get_clientdata(client); 195 + 196 + device_init_wakeup(&client->dev, 0); 197 + 198 + tsdata->exiting = true; 199 + mb(); 200 + free_irq(client->irq, tsdata); 201 + 202 + input_unregister_device(tsdata->input); 203 + kfree(tsdata); 204 + 205 + return 0; 206 + } 207 + 208 + static const struct i2c_device_id pixcir_i2c_ts_id[] = { 209 + { "pixcir_ts", 0 }, 210 + { } 211 + }; 212 + MODULE_DEVICE_TABLE(i2c, pixcir_i2c_ts_id); 213 + 214 + static struct i2c_driver pixcir_i2c_ts_driver = { 215 + .driver = { 216 + .owner = THIS_MODULE, 217 + .name = "pixcir_ts", 218 + .pm = &pixcir_dev_pm_ops, 219 + }, 220 + .probe = pixcir_i2c_ts_probe, 221 + .remove = __devexit_p(pixcir_i2c_ts_remove), 222 + .id_table = pixcir_i2c_ts_id, 223 + }; 224 + 225 + static int __init pixcir_i2c_ts_init(void) 226 + { 227 + return i2c_add_driver(&pixcir_i2c_ts_driver); 228 + } 229 + module_init(pixcir_i2c_ts_init); 230 + 231 + static void __exit pixcir_i2c_ts_exit(void) 232 + { 233 + i2c_del_driver(&pixcir_i2c_ts_driver); 234 + } 235 + module_exit(pixcir_i2c_ts_exit); 236 + 237 + MODULE_AUTHOR("Jianchun Bian <jcbian@pixcir.com.cn>, Dequan Meng <dqmeng@pixcir.com.cn>"); 238 + MODULE_DESCRIPTION("Pixcir I2C Touchscreen Driver"); 239 + MODULE_LICENSE("GPL");
+1 -13
drivers/input/touchscreen/s3c2410_ts.c
··· 432 432 .probe = s3c2410ts_probe, 433 433 .remove = __devexit_p(s3c2410ts_remove), 434 434 }; 435 - 436 - static int __init s3c2410ts_init(void) 437 - { 438 - return platform_driver_register(&s3c_ts_driver); 439 - } 440 - 441 - static void __exit s3c2410ts_exit(void) 442 - { 443 - platform_driver_unregister(&s3c_ts_driver); 444 - } 445 - 446 - module_init(s3c2410ts_init); 447 - module_exit(s3c2410ts_exit); 435 + module_platform_driver(s3c_ts_driver); 448 436 449 437 MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>, " 450 438 "Ben Dooks <ben@simtec.co.uk>, "
+1 -14
drivers/input/touchscreen/stmpe-ts.c
··· 379 379 .probe = stmpe_input_probe, 380 380 .remove = __devexit_p(stmpe_ts_remove), 381 381 }; 382 - 383 - static int __init stmpe_ts_init(void) 384 - { 385 - return platform_driver_register(&stmpe_ts_driver); 386 - } 387 - 388 - module_init(stmpe_ts_init); 389 - 390 - static void __exit stmpe_ts_exit(void) 391 - { 392 - platform_driver_unregister(&stmpe_ts_driver); 393 - } 394 - 395 - module_exit(stmpe_ts_exit); 382 + module_platform_driver(stmpe_ts_driver); 396 383 397 384 MODULE_AUTHOR("Luotao Fu <l.fu@pengutronix.de>"); 398 385 MODULE_DESCRIPTION("STMPEXXX touchscreen driver");
+1 -13
drivers/input/touchscreen/tnetv107x-ts.c
··· 378 378 .driver.name = "tnetv107x-ts", 379 379 .driver.owner = THIS_MODULE, 380 380 }; 381 - 382 - static int __init tsc_init(void) 383 - { 384 - return platform_driver_register(&tsc_driver); 385 - } 386 - 387 - static void __exit tsc_exit(void) 388 - { 389 - platform_driver_unregister(&tsc_driver); 390 - } 391 - 392 - module_init(tsc_init); 393 - module_exit(tsc_exit); 381 + module_platform_driver(tsc_driver); 394 382 395 383 MODULE_AUTHOR("Cyril Chemparathy"); 396 384 MODULE_DESCRIPTION("TNETV107X Touchscreen Driver");
+1 -12
drivers/input/touchscreen/tps6507x-ts.c
··· 371 371 .probe = tps6507x_ts_probe, 372 372 .remove = __devexit_p(tps6507x_ts_remove), 373 373 }; 374 - 375 - static int __init tps6507x_ts_init(void) 376 - { 377 - return platform_driver_register(&tps6507x_ts_driver); 378 - } 379 - module_init(tps6507x_ts_init); 380 - 381 - static void __exit tps6507x_ts_exit(void) 382 - { 383 - platform_driver_unregister(&tps6507x_ts_driver); 384 - } 385 - module_exit(tps6507x_ts_exit); 374 + module_platform_driver(tps6507x_ts_driver); 386 375 387 376 MODULE_AUTHOR("Todd Fischer <todd.fischer@ridgerun.com>"); 388 377 MODULE_DESCRIPTION("TPS6507x - TouchScreen driver");
+133 -152
drivers/input/touchscreen/ucb1400_ts.c
··· 20 20 21 21 #include <linux/module.h> 22 22 #include <linux/init.h> 23 - #include <linux/completion.h> 24 23 #include <linux/delay.h> 24 + #include <linux/sched.h> 25 + #include <linux/wait.h> 25 26 #include <linux/input.h> 26 27 #include <linux/device.h> 27 28 #include <linux/interrupt.h> 28 - #include <linux/suspend.h> 29 - #include <linux/kthread.h> 30 - #include <linux/freezer.h> 31 29 #include <linux/ucb1400.h> 30 + 31 + #define UCB1400_TS_POLL_PERIOD 10 /* ms */ 32 32 33 33 static int adcsync; 34 34 static int ts_delay = 55; /* us */ 35 35 static int ts_delay_pressure; /* us */ 36 36 37 37 /* Switch to interrupt mode. */ 38 - static inline void ucb1400_ts_mode_int(struct snd_ac97 *ac97) 38 + static void ucb1400_ts_mode_int(struct ucb1400_ts *ucb) 39 39 { 40 - ucb1400_reg_write(ac97, UCB_TS_CR, 40 + ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 41 41 UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW | 42 42 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND | 43 43 UCB_TS_CR_MODE_INT); ··· 47 47 * Switch to pressure mode, and read pressure. We don't need to wait 48 48 * here, since both plates are being driven. 49 49 */ 50 - static inline unsigned int ucb1400_ts_read_pressure(struct ucb1400_ts *ucb) 50 + static unsigned int ucb1400_ts_read_pressure(struct ucb1400_ts *ucb) 51 51 { 52 52 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 53 53 UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW | 54 54 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND | 55 55 UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); 56 + 56 57 udelay(ts_delay_pressure); 58 + 57 59 return ucb1400_adc_read(ucb->ac97, UCB_ADC_INP_TSPY, adcsync); 58 60 } 59 61 ··· 65 63 * gives a faster response time. Even so, we need to wait about 55us 66 64 * for things to stabilise. 67 65 */ 68 - static inline unsigned int ucb1400_ts_read_xpos(struct ucb1400_ts *ucb) 66 + static unsigned int ucb1400_ts_read_xpos(struct ucb1400_ts *ucb) 69 67 { 70 68 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 71 69 UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | ··· 88 86 * gives a faster response time. Even so, we need to wait about 55us 89 87 * for things to stabilise. 90 88 */ 91 - static inline unsigned int ucb1400_ts_read_ypos(struct ucb1400_ts *ucb) 89 + static int ucb1400_ts_read_ypos(struct ucb1400_ts *ucb) 92 90 { 93 91 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 94 92 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | ··· 109 107 * Switch to X plate resistance mode. Set MX to ground, PX to 110 108 * supply. Measure current. 111 109 */ 112 - static inline unsigned int ucb1400_ts_read_xres(struct ucb1400_ts *ucb) 110 + static unsigned int ucb1400_ts_read_xres(struct ucb1400_ts *ucb) 113 111 { 114 112 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 115 113 UCB_TS_CR_TSMX_GND | UCB_TS_CR_TSPX_POW | ··· 121 119 * Switch to Y plate resistance mode. Set MY to ground, PY to 122 120 * supply. Measure current. 123 121 */ 124 - static inline unsigned int ucb1400_ts_read_yres(struct ucb1400_ts *ucb) 122 + static unsigned int ucb1400_ts_read_yres(struct ucb1400_ts *ucb) 125 123 { 126 124 ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 127 125 UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | ··· 129 127 return ucb1400_adc_read(ucb->ac97, 0, adcsync); 130 128 } 131 129 132 - static inline int ucb1400_ts_pen_up(struct snd_ac97 *ac97) 130 + static int ucb1400_ts_pen_up(struct ucb1400_ts *ucb) 133 131 { 134 - unsigned short val = ucb1400_reg_read(ac97, UCB_TS_CR); 132 + unsigned short val = ucb1400_reg_read(ucb->ac97, UCB_TS_CR); 135 133 136 134 return val & (UCB_TS_CR_TSPX_LOW | UCB_TS_CR_TSMX_LOW); 137 135 } 138 136 139 - static inline void ucb1400_ts_irq_enable(struct snd_ac97 *ac97) 137 + static void ucb1400_ts_irq_enable(struct ucb1400_ts *ucb) 140 138 { 141 - ucb1400_reg_write(ac97, UCB_IE_CLEAR, UCB_IE_TSPX); 142 - ucb1400_reg_write(ac97, UCB_IE_CLEAR, 0); 143 - ucb1400_reg_write(ac97, UCB_IE_FAL, UCB_IE_TSPX); 139 + ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, UCB_IE_TSPX); 140 + ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); 141 + ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, UCB_IE_TSPX); 144 142 } 145 143 146 - static inline void ucb1400_ts_irq_disable(struct snd_ac97 *ac97) 144 + static void ucb1400_ts_irq_disable(struct ucb1400_ts *ucb) 147 145 { 148 - ucb1400_reg_write(ac97, UCB_IE_FAL, 0); 146 + ucb1400_reg_write(ucb->ac97, UCB_IE_FAL, 0); 149 147 } 150 148 151 - static void ucb1400_ts_evt_add(struct input_dev *idev, u16 pressure, u16 x, u16 y) 149 + static void ucb1400_ts_report_event(struct input_dev *idev, u16 pressure, u16 x, u16 y) 152 150 { 153 151 input_report_abs(idev, ABS_X, x); 154 152 input_report_abs(idev, ABS_Y, y); ··· 164 162 input_sync(idev); 165 163 } 166 164 167 - static void ucb1400_handle_pending_irq(struct ucb1400_ts *ucb) 165 + static void ucb1400_clear_pending_irq(struct ucb1400_ts *ucb) 168 166 { 169 167 unsigned int isr; 170 168 ··· 173 171 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); 174 172 175 173 if (isr & UCB_IE_TSPX) 176 - ucb1400_ts_irq_disable(ucb->ac97); 174 + ucb1400_ts_irq_disable(ucb); 177 175 else 178 - dev_dbg(&ucb->ts_idev->dev, "ucb1400: unexpected IE_STATUS = %#x\n", isr); 179 - enable_irq(ucb->irq); 176 + dev_dbg(&ucb->ts_idev->dev, 177 + "ucb1400: unexpected IE_STATUS = %#x\n", isr); 180 178 } 181 179 182 - static int ucb1400_ts_thread(void *_ucb) 180 + /* 181 + * A restriction with interrupts exists when using the ucb1400, as 182 + * the codec read/write routines may sleep while waiting for codec 183 + * access completion and uses semaphores for access control to the 184 + * AC97 bus. Therefore the driver is forced to use threaded interrupt 185 + * handler. 186 + */ 187 + static irqreturn_t ucb1400_irq(int irqnr, void *devid) 183 188 { 184 - struct ucb1400_ts *ucb = _ucb; 185 - struct task_struct *tsk = current; 186 - int valid = 0; 187 - struct sched_param param = { .sched_priority = 1 }; 189 + struct ucb1400_ts *ucb = devid; 190 + unsigned int x, y, p; 191 + bool penup; 188 192 189 - sched_setscheduler(tsk, SCHED_FIFO, &param); 193 + if (unlikely(irqnr != ucb->irq)) 194 + return IRQ_NONE; 190 195 191 - set_freezable(); 192 - while (!kthread_should_stop()) { 193 - unsigned int x, y, p; 194 - long timeout; 196 + ucb1400_clear_pending_irq(ucb); 195 197 196 - ucb->ts_restart = 0; 198 + /* Start with a small delay before checking pendown state */ 199 + msleep(UCB1400_TS_POLL_PERIOD); 197 200 198 - if (ucb->irq_pending) { 199 - ucb->irq_pending = 0; 200 - ucb1400_handle_pending_irq(ucb); 201 - } 201 + while (!ucb->stopped && !(penup = ucb1400_ts_pen_up(ucb))) { 202 202 203 203 ucb1400_adc_enable(ucb->ac97); 204 204 x = ucb1400_ts_read_xpos(ucb); ··· 208 204 p = ucb1400_ts_read_pressure(ucb); 209 205 ucb1400_adc_disable(ucb->ac97); 210 206 211 - /* Switch back to interrupt mode. */ 212 - ucb1400_ts_mode_int(ucb->ac97); 207 + ucb1400_ts_report_event(ucb->ts_idev, p, x, y); 213 208 214 - msleep(10); 215 - 216 - if (ucb1400_ts_pen_up(ucb->ac97)) { 217 - ucb1400_ts_irq_enable(ucb->ac97); 218 - 219 - /* 220 - * If we spat out a valid sample set last time, 221 - * spit out a "pen off" sample here. 222 - */ 223 - if (valid) { 224 - ucb1400_ts_event_release(ucb->ts_idev); 225 - valid = 0; 226 - } 227 - 228 - timeout = MAX_SCHEDULE_TIMEOUT; 229 - } else { 230 - valid = 1; 231 - ucb1400_ts_evt_add(ucb->ts_idev, p, x, y); 232 - timeout = msecs_to_jiffies(10); 233 - } 234 - 235 - wait_event_freezable_timeout(ucb->ts_wait, 236 - ucb->irq_pending || ucb->ts_restart || 237 - kthread_should_stop(), timeout); 209 + wait_event_timeout(ucb->ts_wait, ucb->stopped, 210 + msecs_to_jiffies(UCB1400_TS_POLL_PERIOD)); 238 211 } 239 212 240 - /* Send the "pen off" if we are stopping with the pen still active */ 241 - if (valid) 242 - ucb1400_ts_event_release(ucb->ts_idev); 213 + ucb1400_ts_event_release(ucb->ts_idev); 243 214 244 - ucb->ts_task = NULL; 245 - return 0; 215 + if (!ucb->stopped) { 216 + /* Switch back to interrupt mode. */ 217 + ucb1400_ts_mode_int(ucb); 218 + ucb1400_ts_irq_enable(ucb); 219 + } 220 + 221 + return IRQ_HANDLED; 246 222 } 247 223 248 - /* 249 - * A restriction with interrupts exists when using the ucb1400, as 250 - * the codec read/write routines may sleep while waiting for codec 251 - * access completion and uses semaphores for access control to the 252 - * AC97 bus. A complete codec read cycle could take anywhere from 253 - * 60 to 100uSec so we *definitely* don't want to spin inside the 254 - * interrupt handler waiting for codec access. So, we handle the 255 - * interrupt by scheduling a RT kernel thread to run in process 256 - * context instead of interrupt context. 257 - */ 258 - static irqreturn_t ucb1400_hard_irq(int irqnr, void *devid) 224 + static void ucb1400_ts_stop(struct ucb1400_ts *ucb) 259 225 { 260 - struct ucb1400_ts *ucb = devid; 226 + /* Signal IRQ thread to stop polling and disable the handler. */ 227 + ucb->stopped = true; 228 + mb(); 229 + wake_up(&ucb->ts_wait); 230 + disable_irq(ucb->irq); 261 231 262 - if (irqnr == ucb->irq) { 263 - disable_irq_nosync(ucb->irq); 264 - ucb->irq_pending = 1; 265 - wake_up(&ucb->ts_wait); 266 - return IRQ_HANDLED; 267 - } 268 - return IRQ_NONE; 232 + ucb1400_ts_irq_disable(ucb); 233 + ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 0); 234 + } 235 + 236 + /* Must be called with ts->lock held */ 237 + static void ucb1400_ts_start(struct ucb1400_ts *ucb) 238 + { 239 + /* Tell IRQ thread that it may poll the device. */ 240 + ucb->stopped = false; 241 + mb(); 242 + 243 + ucb1400_ts_mode_int(ucb); 244 + ucb1400_ts_irq_enable(ucb); 245 + 246 + enable_irq(ucb->irq); 269 247 } 270 248 271 249 static int ucb1400_ts_open(struct input_dev *idev) 272 250 { 273 251 struct ucb1400_ts *ucb = input_get_drvdata(idev); 274 - int ret = 0; 275 252 276 - BUG_ON(ucb->ts_task); 253 + ucb1400_ts_start(ucb); 277 254 278 - ucb->ts_task = kthread_run(ucb1400_ts_thread, ucb, "UCB1400_ts"); 279 - if (IS_ERR(ucb->ts_task)) { 280 - ret = PTR_ERR(ucb->ts_task); 281 - ucb->ts_task = NULL; 282 - } 283 - 284 - return ret; 255 + return 0; 285 256 } 286 257 287 258 static void ucb1400_ts_close(struct input_dev *idev) 288 259 { 289 260 struct ucb1400_ts *ucb = input_get_drvdata(idev); 290 261 291 - if (ucb->ts_task) 292 - kthread_stop(ucb->ts_task); 293 - 294 - ucb1400_ts_irq_disable(ucb->ac97); 295 - ucb1400_reg_write(ucb->ac97, UCB_TS_CR, 0); 262 + ucb1400_ts_stop(ucb); 296 263 } 297 264 298 265 #ifndef NO_IRQ ··· 274 299 * Try to probe our interrupt, rather than relying on lots of 275 300 * hard-coded machine dependencies. 276 301 */ 277 - static int ucb1400_ts_detect_irq(struct ucb1400_ts *ucb) 302 + static int __devinit ucb1400_ts_detect_irq(struct ucb1400_ts *ucb, 303 + struct platform_device *pdev) 278 304 { 279 305 unsigned long mask, timeout; 280 306 ··· 297 321 UCB_ADC_DAT_VALID)) { 298 322 cpu_relax(); 299 323 if (time_after(jiffies, timeout)) { 300 - printk(KERN_ERR "ucb1400: timed out in IRQ probe\n"); 324 + dev_err(&pdev->dev, "timed out in IRQ probe\n"); 301 325 probe_irq_off(mask); 302 326 return -ENODEV; 303 327 } ··· 318 342 return 0; 319 343 } 320 344 321 - static int ucb1400_ts_probe(struct platform_device *dev) 345 + static int __devinit ucb1400_ts_probe(struct platform_device *pdev) 322 346 { 347 + struct ucb1400_ts *ucb = pdev->dev.platform_data; 323 348 int error, x_res, y_res; 324 349 u16 fcsr; 325 - struct ucb1400_ts *ucb = dev->dev.platform_data; 326 350 327 351 ucb->ts_idev = input_allocate_device(); 328 352 if (!ucb->ts_idev) { ··· 332 356 333 357 /* Only in case the IRQ line wasn't supplied, try detecting it */ 334 358 if (ucb->irq < 0) { 335 - error = ucb1400_ts_detect_irq(ucb); 359 + error = ucb1400_ts_detect_irq(ucb, pdev); 336 360 if (error) { 337 - printk(KERN_ERR "UCB1400: IRQ probe failed\n"); 361 + dev_err(&pdev->dev, "IRQ probe failed\n"); 338 362 goto err_free_devs; 339 363 } 340 364 } 365 + dev_dbg(&pdev->dev, "found IRQ %d\n", ucb->irq); 341 366 342 367 init_waitqueue_head(&ucb->ts_wait); 343 368 344 - error = request_irq(ucb->irq, ucb1400_hard_irq, IRQF_TRIGGER_RISING, 345 - "UCB1400", ucb); 346 - if (error) { 347 - printk(KERN_ERR "ucb1400: unable to grab irq%d: %d\n", 348 - ucb->irq, error); 349 - goto err_free_devs; 350 - } 351 - printk(KERN_DEBUG "UCB1400: found IRQ %d\n", ucb->irq); 352 - 353 369 input_set_drvdata(ucb->ts_idev, ucb); 354 370 355 - ucb->ts_idev->dev.parent = &dev->dev; 371 + ucb->ts_idev->dev.parent = &pdev->dev; 356 372 ucb->ts_idev->name = "UCB1400 touchscreen interface"; 357 373 ucb->ts_idev->id.vendor = ucb1400_reg_read(ucb->ac97, 358 374 AC97_VENDOR_ID1); ··· 366 398 x_res = ucb1400_ts_read_xres(ucb); 367 399 y_res = ucb1400_ts_read_yres(ucb); 368 400 ucb1400_adc_disable(ucb->ac97); 369 - printk(KERN_DEBUG "UCB1400: x/y = %d/%d\n", x_res, y_res); 401 + dev_dbg(&pdev->dev, "x/y = %d/%d\n", x_res, y_res); 370 402 371 403 input_set_abs_params(ucb->ts_idev, ABS_X, 0, x_res, 0, 0); 372 404 input_set_abs_params(ucb->ts_idev, ABS_Y, 0, y_res, 0, 0); 373 405 input_set_abs_params(ucb->ts_idev, ABS_PRESSURE, 0, 0, 0, 0); 406 + 407 + ucb1400_ts_stop(ucb); 408 + 409 + error = request_threaded_irq(ucb->irq, NULL, ucb1400_irq, 410 + IRQF_TRIGGER_RISING | IRQF_ONESHOT, 411 + "UCB1400", ucb); 412 + if (error) { 413 + dev_err(&pdev->dev, 414 + "unable to grab irq%d: %d\n", ucb->irq, error); 415 + goto err_free_devs; 416 + } 374 417 375 418 error = input_register_device(ucb->ts_idev); 376 419 if (error) ··· 395 416 input_free_device(ucb->ts_idev); 396 417 err: 397 418 return error; 398 - 399 419 } 400 420 401 - static int ucb1400_ts_remove(struct platform_device *dev) 421 + static int __devexit ucb1400_ts_remove(struct platform_device *pdev) 402 422 { 403 - struct ucb1400_ts *ucb = dev->dev.platform_data; 423 + struct ucb1400_ts *ucb = pdev->dev.platform_data; 404 424 405 425 free_irq(ucb->irq, ucb); 406 426 input_unregister_device(ucb->ts_idev); 427 + 407 428 return 0; 408 429 } 409 430 410 - #ifdef CONFIG_PM 411 - static int ucb1400_ts_resume(struct platform_device *dev) 431 + #ifdef CONFIG_PM_SLEEP 432 + static int ucb1400_ts_suspend(struct device *dev) 412 433 { 413 - struct ucb1400_ts *ucb = dev->dev.platform_data; 434 + struct ucb1400_ts *ucb = dev->platform_data; 435 + struct input_dev *idev = ucb->ts_idev; 414 436 415 - if (ucb->ts_task) { 416 - /* 417 - * Restart the TS thread to ensure the 418 - * TS interrupt mode is set up again 419 - * after sleep. 420 - */ 421 - ucb->ts_restart = 1; 422 - wake_up(&ucb->ts_wait); 423 - } 437 + mutex_lock(&idev->mutex); 438 + 439 + if (idev->users) 440 + ucb1400_ts_start(ucb); 441 + 442 + mutex_unlock(&idev->mutex); 424 443 return 0; 425 444 } 426 - #else 427 - #define ucb1400_ts_resume NULL 445 + 446 + static int ucb1400_ts_resume(struct device *dev) 447 + { 448 + struct ucb1400_ts *ucb = dev->platform_data; 449 + struct input_dev *idev = ucb->ts_idev; 450 + 451 + mutex_lock(&idev->mutex); 452 + 453 + if (idev->users) 454 + ucb1400_ts_stop(ucb); 455 + 456 + mutex_unlock(&idev->mutex); 457 + return 0; 458 + } 428 459 #endif 460 + 461 + static SIMPLE_DEV_PM_OPS(ucb1400_ts_pm_ops, 462 + ucb1400_ts_suspend, ucb1400_ts_resume); 429 463 430 464 static struct platform_driver ucb1400_ts_driver = { 431 465 .probe = ucb1400_ts_probe, 432 - .remove = ucb1400_ts_remove, 433 - .resume = ucb1400_ts_resume, 466 + .remove = __devexit_p(ucb1400_ts_remove), 434 467 .driver = { 435 468 .name = "ucb1400_ts", 469 + .owner = THIS_MODULE, 470 + .pm = &ucb1400_ts_pm_ops, 436 471 }, 437 472 }; 438 - 439 - static int __init ucb1400_ts_init(void) 440 - { 441 - return platform_driver_register(&ucb1400_ts_driver); 442 - } 443 - 444 - static void __exit ucb1400_ts_exit(void) 445 - { 446 - platform_driver_unregister(&ucb1400_ts_driver); 447 - } 473 + module_platform_driver(ucb1400_ts_driver); 448 474 449 475 module_param(adcsync, bool, 0444); 450 476 MODULE_PARM_DESC(adcsync, "Synchronize touch readings with ADCSYNC pin."); ··· 462 478 MODULE_PARM_DESC(ts_delay_pressure, 463 479 "delay between panel setup and pressure read." 464 480 " Default = 0us."); 465 - 466 - module_init(ucb1400_ts_init); 467 - module_exit(ucb1400_ts_exit); 468 481 469 482 MODULE_DESCRIPTION("Philips UCB1400 touchscreen driver"); 470 483 MODULE_LICENSE("GPL");
+36
drivers/input/touchscreen/usbtouchscreen.c
··· 16 16 * - JASTEC USB touch controller/DigiTech DTR-02U 17 17 * - Zytronic capacitive touchscreen 18 18 * - NEXIO/iNexio 19 + * - Elo TouchSystems 2700 IntelliTouch 19 20 * 20 21 * Copyright (C) 2004-2007 by Daniel Ritz <daniel.ritz@gmx.ch> 21 22 * Copyright (C) by Todd E. Johnson (mtouchusb.c) ··· 139 138 DEVTYPE_ZYTRONIC, 140 139 DEVTYPE_TC45USB, 141 140 DEVTYPE_NEXIO, 141 + DEVTYPE_ELO, 142 142 }; 143 143 144 144 #define USB_DEVICE_HID_CLASS(vend, prod) \ ··· 239 237 .driver_info = DEVTYPE_NEXIO}, 240 238 {USB_DEVICE_AND_INTERFACE_INFO(0x1870, 0x0001, 0x0a, 0x00, 0x00), 241 239 .driver_info = DEVTYPE_NEXIO}, 240 + #endif 241 + 242 + #ifdef CONFIG_TOUCHSCREEN_USB_ELO 243 + {USB_DEVICE(0x04e7, 0x0020), .driver_info = DEVTYPE_ELO}, 242 244 #endif 243 245 244 246 {} ··· 951 945 952 946 953 947 /***************************************************************************** 948 + * ELO part 949 + */ 950 + 951 + #ifdef CONFIG_TOUCHSCREEN_USB_ELO 952 + 953 + static int elo_read_data(struct usbtouch_usb *dev, unsigned char *pkt) 954 + { 955 + dev->x = (pkt[3] << 8) | pkt[2]; 956 + dev->y = (pkt[5] << 8) | pkt[4]; 957 + dev->touch = pkt[6] > 0; 958 + dev->press = pkt[6]; 959 + 960 + return 1; 961 + } 962 + #endif 963 + 964 + 965 + /***************************************************************************** 954 966 * the different device descriptors 955 967 */ 956 968 #ifdef MULTI_PACKET ··· 977 953 #endif 978 954 979 955 static struct usbtouch_device_info usbtouch_dev_info[] = { 956 + #ifdef CONFIG_TOUCHSCREEN_USB_ELO 957 + [DEVTYPE_ELO] = { 958 + .min_xc = 0x0, 959 + .max_xc = 0x0fff, 960 + .min_yc = 0x0, 961 + .max_yc = 0x0fff, 962 + .max_press = 0xff, 963 + .rept_size = 8, 964 + .read_data = elo_read_data, 965 + }, 966 + #endif 967 + 980 968 #ifdef CONFIG_TOUCHSCREEN_USB_EGALAX 981 969 [DEVTYPE_EGALAX] = { 982 970 .min_xc = 0x0,
+1 -13
drivers/input/touchscreen/w90p910_ts.c
··· 331 331 .owner = THIS_MODULE, 332 332 }, 333 333 }; 334 - 335 - static int __init w90x900ts_init(void) 336 - { 337 - return platform_driver_register(&w90x900ts_driver); 338 - } 339 - 340 - static void __exit w90x900ts_exit(void) 341 - { 342 - platform_driver_unregister(&w90x900ts_driver); 343 - } 344 - 345 - module_init(w90x900ts_init); 346 - module_exit(w90x900ts_exit); 334 + module_platform_driver(w90x900ts_driver); 347 335 348 336 MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>"); 349 337 MODULE_DESCRIPTION("w90p910 touch screen driver!");
+1 -12
drivers/input/touchscreen/wm831x-ts.c
··· 401 401 .probe = wm831x_ts_probe, 402 402 .remove = __devexit_p(wm831x_ts_remove), 403 403 }; 404 - 405 - static int __init wm831x_ts_init(void) 406 - { 407 - return platform_driver_register(&wm831x_ts_driver); 408 - } 409 - module_init(wm831x_ts_init); 410 - 411 - static void __exit wm831x_ts_exit(void) 412 - { 413 - platform_driver_unregister(&wm831x_ts_driver); 414 - } 415 - module_exit(wm831x_ts_exit); 404 + module_platform_driver(wm831x_ts_driver); 416 405 417 406 /* Module information */ 418 407 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
+1 -13
drivers/input/touchscreen/zylonite-wm97xx.c
··· 224 224 .name = "wm97xx-touch", 225 225 }, 226 226 }; 227 - 228 - static int __init zylonite_wm97xx_init(void) 229 - { 230 - return platform_driver_register(&zylonite_wm97xx_driver); 231 - } 232 - 233 - static void __exit zylonite_wm97xx_exit(void) 234 - { 235 - platform_driver_unregister(&zylonite_wm97xx_driver); 236 - } 237 - 238 - module_init(zylonite_wm97xx_init); 239 - module_exit(zylonite_wm97xx_exit); 227 + module_platform_driver(zylonite_wm97xx_driver); 240 228 241 229 /* Module information */ 242 230 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
+56
include/linux/input/auo-pixcir-ts.h
··· 1 + /* 2 + * Driver for AUO in-cell touchscreens 3 + * 4 + * Copyright (c) 2011 Heiko Stuebner <heiko@sntech.de> 5 + * 6 + * based on auo_touch.h from Dell Streak kernel 7 + * 8 + * Copyright (c) 2008 QUALCOMM Incorporated. 9 + * Copyright (c) 2008 QUALCOMM USA, INC. 10 + * 11 + * 12 + * This software is licensed under the terms of the GNU General Public 13 + * License version 2, as published by the Free Software Foundation, and 14 + * may be copied, distributed, and modified under those terms. 15 + * 16 + * This program is distributed in the hope that it will be useful, 17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 + * GNU General Public License for more details. 20 + * 21 + */ 22 + 23 + #ifndef __AUO_PIXCIR_TS_H__ 24 + #define __AUO_PIXCIR_TS_H__ 25 + 26 + /* 27 + * Interrupt modes: 28 + * periodical: interrupt is asserted periodicaly 29 + * compare coordinates: interrupt is asserted when coordinates change 30 + * indicate touch: interrupt is asserted during touch 31 + */ 32 + #define AUO_PIXCIR_INT_PERIODICAL 0x00 33 + #define AUO_PIXCIR_INT_COMP_COORD 0x01 34 + #define AUO_PIXCIR_INT_TOUCH_IND 0x02 35 + 36 + /* 37 + * @gpio_int interrupt gpio 38 + * @int_setting one of AUO_PIXCIR_INT_* 39 + * @init_hw hardwarespecific init 40 + * @exit_hw hardwarespecific shutdown 41 + * @x_max x-resolution 42 + * @y_max y-resolution 43 + */ 44 + struct auo_pixcir_ts_platdata { 45 + int gpio_int; 46 + 47 + int int_setting; 48 + 49 + void (*init_hw)(struct i2c_client *); 50 + void (*exit_hw)(struct i2c_client *); 51 + 52 + unsigned int x_max; 53 + unsigned int y_max; 54 + }; 55 + 56 + #endif
+22
include/linux/input/gp2ap002a00f.h
··· 1 + #ifndef _GP2AP002A00F_H_ 2 + #define _GP2AP002A00F_H_ 3 + 4 + #include <linux/i2c.h> 5 + 6 + #define GP2A_I2C_NAME "gp2ap002a00f" 7 + 8 + /** 9 + * struct gp2a_platform_data - Sharp gp2ap002a00f proximity platform data 10 + * @vout_gpio: The gpio connected to the object detected pin (VOUT) 11 + * @wakeup: Set to true if the proximity can wake the device from suspend 12 + * @hw_setup: Callback for setting up hardware such as gpios and vregs 13 + * @hw_shutdown: Callback for properly shutting down hardware 14 + */ 15 + struct gp2a_platform_data { 16 + int vout_gpio; 17 + bool wakeup; 18 + int (*hw_setup)(struct i2c_client *client); 19 + int (*hw_shutdown)(struct i2c_client *client); 20 + }; 21 + 22 + #endif
+73
include/linux/input/gpio_tilt.h
··· 1 + #ifndef _INPUT_GPIO_TILT_H 2 + #define _INPUT_GPIO_TILT_H 3 + 4 + /** 5 + * struct gpio_tilt_axis - Axis used by the tilt switch 6 + * @axis: Constant describing the axis, e.g. ABS_X 7 + * @min: minimum value for abs_param 8 + * @max: maximum value for abs_param 9 + * @fuzz: fuzz value for abs_param 10 + * @flat: flat value for abs_param 11 + */ 12 + struct gpio_tilt_axis { 13 + int axis; 14 + int min; 15 + int max; 16 + int fuzz; 17 + int flat; 18 + }; 19 + 20 + /** 21 + * struct gpio_tilt_state - state description 22 + * @gpios: bitfield of gpio target-states for the value 23 + * @axes: array containing the axes settings for the gpio state 24 + * The array indizes must correspond to the axes defined 25 + * in platform_data 26 + * 27 + * This structure describes a supported axis settings 28 + * and the necessary gpio-state which represent it. 29 + * 30 + * The n-th bit in the bitfield describes the state of the n-th GPIO 31 + * from the gpios-array defined in gpio_regulator_config below. 32 + */ 33 + struct gpio_tilt_state { 34 + int gpios; 35 + int *axes; 36 + }; 37 + 38 + /** 39 + * struct gpio_tilt_platform_data 40 + * @gpios: Array containing the gpios determining the tilt state 41 + * @nr_gpios: Number of gpios 42 + * @axes: Array of gpio_tilt_axis descriptions 43 + * @nr_axes: Number of axes 44 + * @states: Array of gpio_tilt_state entries describing 45 + * the gpio state for specific tilts 46 + * @nr_states: Number of states available 47 + * @debounce_interval: debounce ticks interval in msecs 48 + * @poll_interval: polling interval in msecs - for polling driver only 49 + * @enable: callback to enable the tilt switch 50 + * @disable: callback to disable the tilt switch 51 + * 52 + * This structure contains gpio-tilt-switch configuration 53 + * information that must be passed by platform code to the 54 + * gpio-tilt input driver. 55 + */ 56 + struct gpio_tilt_platform_data { 57 + struct gpio *gpios; 58 + int nr_gpios; 59 + 60 + struct gpio_tilt_axis *axes; 61 + int nr_axes; 62 + 63 + struct gpio_tilt_state *states; 64 + int nr_states; 65 + 66 + int debounce_interval; 67 + 68 + unsigned int poll_interval; 69 + int (*enable)(struct device *dev); 70 + void (*disable)(struct device *dev); 71 + }; 72 + 73 + #endif
+10
include/linux/input/pixcir_ts.h
··· 1 + #ifndef _PIXCIR_I2C_TS_H 2 + #define _PIXCIR_I2C_TS_H 3 + 4 + struct pixcir_ts_platform_data { 5 + int (*attb_read_val)(void); 6 + int x_max; 7 + int y_max; 8 + }; 9 + 10 + #endif
+43
include/linux/input/samsung-keypad.h
··· 1 + /* 2 + * Samsung Keypad platform data definitions 3 + * 4 + * Copyright (C) 2010 Samsung Electronics Co.Ltd 5 + * Author: Joonyoung Shim <jy0922.shim@samsung.com> 6 + * 7 + * This program is free software; you can redistribute it and/or modify it 8 + * under the terms of the GNU General Public License as published by the 9 + * Free Software Foundation; either version 2 of the License, or (at your 10 + * option) any later version. 11 + */ 12 + 13 + #ifndef __SAMSUNG_KEYPAD_H 14 + #define __SAMSUNG_KEYPAD_H 15 + 16 + #include <linux/input/matrix_keypad.h> 17 + 18 + #define SAMSUNG_MAX_ROWS 8 19 + #define SAMSUNG_MAX_COLS 8 20 + 21 + /** 22 + * struct samsung_keypad_platdata - Platform device data for Samsung Keypad. 23 + * @keymap_data: pointer to &matrix_keymap_data. 24 + * @rows: number of keypad row supported. 25 + * @cols: number of keypad col supported. 26 + * @no_autorepeat: disable key autorepeat. 27 + * @wakeup: controls whether the device should be set up as wakeup source. 28 + * @cfg_gpio: configure the GPIO. 29 + * 30 + * Initialisation data specific to either the machine or the platform 31 + * for the device driver to use or call-back when configuring gpio. 32 + */ 33 + struct samsung_keypad_platdata { 34 + const struct matrix_keymap_data *keymap_data; 35 + unsigned int rows; 36 + unsigned int cols; 37 + bool no_autorepeat; 38 + bool wakeup; 39 + 40 + void (*cfg_gpio)(unsigned int rows, unsigned int cols); 41 + }; 42 + 43 + #endif /* __SAMSUNG_KEYPAD_H */
+44
include/linux/input/tca8418_keypad.h
··· 1 + /* 2 + * TCA8418 keypad platform support 3 + * 4 + * Copyright (C) 2011 Fuel7, Inc. All rights reserved. 5 + * 6 + * Author: Kyle Manna <kyle.manna@fuel7.com> 7 + * 8 + * This program is free software; you can redistribute it and/or 9 + * modify it under the terms of the GNU General Public 10 + * License v2 as published by the Free Software Foundation. 11 + * 12 + * This program is distributed in the hope that it will be useful, 13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 + * General Public License for more details. 16 + * 17 + * You should have received a copy of the GNU General Public 18 + * License along with this program; if not, write to the 19 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 + * Boston, MA 021110-1307, USA. 21 + * 22 + * If you can't comply with GPLv2, alternative licensing terms may be 23 + * arranged. Please contact Fuel7, Inc. (http://fuel7.com/) for proprietary 24 + * alternative licensing inquiries. 25 + */ 26 + 27 + #ifndef _TCA8418_KEYPAD_H 28 + #define _TCA8418_KEYPAD_H 29 + 30 + #include <linux/types.h> 31 + #include <linux/input/matrix_keypad.h> 32 + 33 + #define TCA8418_I2C_ADDR 0x34 34 + #define TCA8418_NAME "tca8418_keypad" 35 + 36 + struct tca8418_keypad_platform_data { 37 + const struct matrix_keymap_data *keymap_data; 38 + unsigned rows; 39 + unsigned cols; 40 + bool rep; 41 + bool irq_is_gpio; 42 + }; 43 + 44 + #endif
+2 -4
include/linux/ucb1400.h
··· 96 96 97 97 struct ucb1400_ts { 98 98 struct input_dev *ts_idev; 99 - struct task_struct *ts_task; 100 99 int id; 101 - wait_queue_head_t ts_wait; 102 - unsigned int ts_restart:1; 103 100 int irq; 104 - unsigned int irq_pending; /* not bit field shared */ 105 101 struct snd_ac97 *ac97; 102 + wait_queue_head_t ts_wait; 103 + bool stopped; 106 104 }; 107 105 108 106 struct ucb1400 {