1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2011-2015 Synaptics Incorporated
4 * Copyright (c) 2011 Unixphere
7 #include <linux/kernel.h>
8 #include <linux/delay.h>
9 #include <linux/device.h>
10 #include <linux/input.h>
11 #include <linux/input/mt.h>
12 #include <linux/rmi.h>
13 #include <linux/slab.h>
15 #include "rmi_driver.h"
16 #include "rmi_2d_sensor.h"
18 #define F11_MAX_NUM_OF_FINGERS 10
19 #define F11_MAX_NUM_OF_TOUCH_SHAPES 16
21 #define FINGER_STATE_MASK 0x03
23 #define F11_CTRL_SENSOR_MAX_X_POS_OFFSET 6
24 #define F11_CTRL_SENSOR_MAX_Y_POS_OFFSET 8
26 #define DEFAULT_XY_MAX 9999
27 #define DEFAULT_MAX_ABS_MT_PRESSURE 255
28 #define DEFAULT_MAX_ABS_MT_TOUCH 15
29 #define DEFAULT_MAX_ABS_MT_ORIENTATION 1
30 #define DEFAULT_MIN_ABS_MT_TRACKING_ID 1
31 #define DEFAULT_MAX_ABS_MT_TRACKING_ID 10
33 /** A note about RMI4 F11 register structure.
36 * a given sensor are described by its query registers. The number of query
37 * registers and the layout of their contents are described by the F11 device
38 * queries as well as the sensor query information.
40 * Similarly, each sensor has control registers that govern its behavior. The
41 * size and layout of the control registers for a given sensor can be determined
42 * by parsing that sensors query registers.
44 * And in a likewise fashion, each sensor has data registers where it reports
45 * its touch data and other interesting stuff. The size and layout of a
46 * sensors data registers must be determined by parsing its query registers.
48 * The short story is that we need to read and parse a lot of query
49 * registers in order to determine the attributes of a sensor. Then
50 * we need to use that data to compute the size of the control and data
51 * registers for sensor.
53 * The end result is that we have a number of structs that aren't used to
54 * directly generate the input events, but their size, location and contents
55 * are critical to determining where the data we are interested in lives.
57 * At this time, the driver does not yet comprehend all possible F11
58 * configuration options, but it should be sufficient to cover 99% of RMI4 F11
59 * devices currently in the field.
62 /* maximum ABS_MT_POSITION displacement (in mm) */
66 * @rezero - writing this to the F11 command register will cause the sensor to
67 * calibrate to the current capacitive state.
69 #define RMI_F11_REZERO 0x01
71 #define RMI_F11_HAS_QUERY9 (1 << 3)
72 #define RMI_F11_HAS_QUERY11 (1 << 4)
73 #define RMI_F11_HAS_QUERY12 (1 << 5)
74 #define RMI_F11_HAS_QUERY27 (1 << 6)
75 #define RMI_F11_HAS_QUERY28 (1 << 7)
77 /** Defs for Query 1 */
79 #define RMI_F11_NR_FINGERS_MASK 0x07
80 #define RMI_F11_HAS_REL (1 << 3)
81 #define RMI_F11_HAS_ABS (1 << 4)
82 #define RMI_F11_HAS_GESTURES (1 << 5)
83 #define RMI_F11_HAS_SENSITIVITY_ADJ (1 << 6)
84 #define RMI_F11_CONFIGURABLE (1 << 7)
86 /** Defs for Query 2, 3, and 4. */
87 #define RMI_F11_NR_ELECTRODES_MASK 0x7F
89 /** Defs for Query 5 */
91 #define RMI_F11_ABS_DATA_SIZE_MASK 0x03
92 #define RMI_F11_HAS_ANCHORED_FINGER (1 << 2)
93 #define RMI_F11_HAS_ADJ_HYST (1 << 3)
94 #define RMI_F11_HAS_DRIBBLE (1 << 4)
95 #define RMI_F11_HAS_BENDING_CORRECTION (1 << 5)
96 #define RMI_F11_HAS_LARGE_OBJECT_SUPPRESSION (1 << 6)
97 #define RMI_F11_HAS_JITTER_FILTER (1 << 7)
99 /** Defs for Query 7 */
100 #define RMI_F11_HAS_SINGLE_TAP (1 << 0)
101 #define RMI_F11_HAS_TAP_AND_HOLD (1 << 1)
102 #define RMI_F11_HAS_DOUBLE_TAP (1 << 2)
103 #define RMI_F11_HAS_EARLY_TAP (1 << 3)
104 #define RMI_F11_HAS_FLICK (1 << 4)
105 #define RMI_F11_HAS_PRESS (1 << 5)
106 #define RMI_F11_HAS_PINCH (1 << 6)
107 #define RMI_F11_HAS_CHIRAL (1 << 7)
109 /** Defs for Query 8 */
110 #define RMI_F11_HAS_PALM_DET (1 << 0)
111 #define RMI_F11_HAS_ROTATE (1 << 1)
112 #define RMI_F11_HAS_TOUCH_SHAPES (1 << 2)
113 #define RMI_F11_HAS_SCROLL_ZONES (1 << 3)
114 #define RMI_F11_HAS_INDIVIDUAL_SCROLL_ZONES (1 << 4)
115 #define RMI_F11_HAS_MF_SCROLL (1 << 5)
116 #define RMI_F11_HAS_MF_EDGE_MOTION (1 << 6)
117 #define RMI_F11_HAS_MF_SCROLL_INERTIA (1 << 7)
119 /** Defs for Query 9. */
120 #define RMI_F11_HAS_PEN (1 << 0)
121 #define RMI_F11_HAS_PROXIMITY (1 << 1)
122 #define RMI_F11_HAS_PALM_DET_SENSITIVITY (1 << 2)
123 #define RMI_F11_HAS_SUPPRESS_ON_PALM_DETECT (1 << 3)
124 #define RMI_F11_HAS_TWO_PEN_THRESHOLDS (1 << 4)
125 #define RMI_F11_HAS_CONTACT_GEOMETRY (1 << 5)
126 #define RMI_F11_HAS_PEN_HOVER_DISCRIMINATION (1 << 6)
127 #define RMI_F11_HAS_PEN_FILTERS (1 << 7)
129 /** Defs for Query 10. */
130 #define RMI_F11_NR_TOUCH_SHAPES_MASK 0x1F
132 /** Defs for Query 11 */
134 #define RMI_F11_HAS_Z_TUNING (1 << 0)
135 #define RMI_F11_HAS_ALGORITHM_SELECTION (1 << 1)
136 #define RMI_F11_HAS_W_TUNING (1 << 2)
137 #define RMI_F11_HAS_PITCH_INFO (1 << 3)
138 #define RMI_F11_HAS_FINGER_SIZE (1 << 4)
139 #define RMI_F11_HAS_SEGMENTATION_AGGRESSIVENESS (1 << 5)
140 #define RMI_F11_HAS_XY_CLIP (1 << 6)
141 #define RMI_F11_HAS_DRUMMING_FILTER (1 << 7)
143 /** Defs for Query 12. */
145 #define RMI_F11_HAS_GAPLESS_FINGER (1 << 0)
146 #define RMI_F11_HAS_GAPLESS_FINGER_TUNING (1 << 1)
147 #define RMI_F11_HAS_8BIT_W (1 << 2)
148 #define RMI_F11_HAS_ADJUSTABLE_MAPPING (1 << 3)
149 #define RMI_F11_HAS_INFO2 (1 << 4)
150 #define RMI_F11_HAS_PHYSICAL_PROPS (1 << 5)
151 #define RMI_F11_HAS_FINGER_LIMIT (1 << 6)
152 #define RMI_F11_HAS_LINEAR_COEFF (1 << 7)
154 /** Defs for Query 13. */
156 #define RMI_F11_JITTER_WINDOW_MASK 0x1F
157 #define RMI_F11_JITTER_FILTER_MASK 0x60
158 #define RMI_F11_JITTER_FILTER_SHIFT 5
160 /** Defs for Query 14. */
161 #define RMI_F11_LIGHT_CONTROL_MASK 0x03
162 #define RMI_F11_IS_CLEAR (1 << 2)
163 #define RMI_F11_CLICKPAD_PROPS_MASK 0x18
164 #define RMI_F11_CLICKPAD_PROPS_SHIFT 3
165 #define RMI_F11_MOUSE_BUTTONS_MASK 0x60
166 #define RMI_F11_MOUSE_BUTTONS_SHIFT 5
167 #define RMI_F11_HAS_ADVANCED_GESTURES (1 << 7)
169 #define RMI_F11_QUERY_SIZE 4
170 #define RMI_F11_QUERY_GESTURE_SIZE 2
172 #define F11_LIGHT_CTL_NONE 0x00
173 #define F11_LUXPAD 0x01
174 #define F11_DUAL_MODE 0x02
176 #define F11_NOT_CLICKPAD 0x00
177 #define F11_HINGED_CLICKPAD 0x01
178 #define F11_UNIFORM_CLICKPAD 0x02
181 * Query registers 1 through 4 are always present.
183 * @nr_fingers - describes the maximum number of fingers the 2-D sensor
185 * @has_rel - the sensor supports relative motion reporting.
186 * @has_abs - the sensor supports absolute poition reporting.
187 * @has_gestures - the sensor supports gesture reporting.
188 * @has_sensitivity_adjust - the sensor supports a global sensitivity
190 * @configurable - the sensor supports various configuration options.
191 * @num_of_x_electrodes - the maximum number of electrodes the 2-D sensor
192 * supports on the X axis.
193 * @num_of_y_electrodes - the maximum number of electrodes the 2-D sensor
194 * supports on the Y axis.
195 * @max_electrodes - the total number of X and Y electrodes that may be
198 * Query 5 is present if the has_abs bit is set.
200 * @abs_data_size - describes the format of data reported by the absolute
201 * data source. Only one format (the kind used here) is supported at this
203 * @has_anchored_finger - then the sensor supports the high-precision second
204 * finger tracking provided by the manual tracking and motion sensitivity
206 * @has_adjust_hyst - the difference between the finger release threshold and
207 * the touch threshold.
208 * @has_dribble - the sensor supports the generation of dribble interrupts,
209 * which may be enabled or disabled with the dribble control bit.
210 * @has_bending_correction - Bending related data registers 28 and 36, and
211 * control register 52..57 are present.
212 * @has_large_object_suppression - control register 58 and data register 28
214 * @has_jitter_filter - query 13 and control 73..76 exist.
216 * Gesture information queries 7 and 8 are present if has_gestures bit is set.
218 * @has_single_tap - a basic single-tap gesture is supported.
219 * @has_tap_n_hold - tap-and-hold gesture is supported.
220 * @has_double_tap - double-tap gesture is supported.
221 * @has_early_tap - early tap is supported and reported as soon as the finger
222 * lifts for any tap event that could be interpreted as either a single tap
223 * or as the first tap of a double-tap or tap-and-hold gesture.
224 * @has_flick - flick detection is supported.
225 * @has_press - press gesture reporting is supported.
226 * @has_pinch - pinch gesture detection is supported.
227 * @has_palm_det - the 2-D sensor notifies the host whenever a large conductive
228 * object such as a palm or a cheek touches the 2-D sensor.
229 * @has_rotate - rotation gesture detection is supported.
230 * @has_touch_shapes - TouchShapes are supported. A TouchShape is a fixed
231 * rectangular area on the sensor that behaves like a capacitive button.
232 * @has_scroll_zones - scrolling areas near the sensor edges are supported.
233 * @has_individual_scroll_zones - if 1, then 4 scroll zones are supported;
234 * if 0, then only two are supported.
235 * @has_mf_scroll - the multifinger_scrolling bit will be set when
236 * more than one finger is involved in a scrolling action.
238 * Convenience for checking bytes in the gesture info registers. This is done
239 * often enough that we put it here to declutter the conditionals
241 * @query7_nonzero - true if none of the query 7 bits are set
242 * @query8_nonzero - true if none of the query 8 bits are set
244 * Query 9 is present if the has_query9 is set.
246 * @has_pen - detection of a stylus is supported and registers F11_2D_Ctrl20
247 * and F11_2D_Ctrl21 exist.
248 * @has_proximity - detection of fingers near the sensor is supported and
249 * registers F11_2D_Ctrl22 through F11_2D_Ctrl26 exist.
250 * @has_palm_det_sensitivity - the sensor supports the palm detect sensitivity
251 * feature and register F11_2D_Ctrl27 exists.
252 * @has_two_pen_thresholds - is has_pen is also set, then F11_2D_Ctrl35 exists.
253 * @has_contact_geometry - the sensor supports the use of contact geometry to
254 * map absolute X and Y target positions and registers F11_2D_Data18
255 * through F11_2D_Data27 exist.
257 * Touch shape info (query 10) is present if has_touch_shapes is set.
259 * @nr_touch_shapes - the total number of touch shapes supported.
261 * Query 11 is present if the has_query11 bit is set in query 0.
263 * @has_z_tuning - if set, the sensor supports Z tuning and registers
264 * F11_2D_Ctrl29 through F11_2D_Ctrl33 exist.
265 * @has_algorithm_selection - controls choice of noise suppression algorithm
266 * @has_w_tuning - the sensor supports Wx and Wy scaling and registers
267 * F11_2D_Ctrl36 through F11_2D_Ctrl39 exist.
268 * @has_pitch_info - the X and Y pitches of the sensor electrodes can be
269 * configured and registers F11_2D_Ctrl40 and F11_2D_Ctrl41 exist.
270 * @has_finger_size - the default finger width settings for the
271 * sensor can be configured and registers F11_2D_Ctrl42 through F11_2D_Ctrl44
273 * @has_segmentation_aggressiveness - the sensor’s ability to distinguish
274 * multiple objects close together can be configured and register F11_2D_Ctrl45
276 * @has_XY_clip - the inactive outside borders of the sensor can be
277 * configured and registers F11_2D_Ctrl46 through F11_2D_Ctrl49 exist.
278 * @has_drumming_filter - the sensor can be configured to distinguish
279 * between a fast flick and a quick drumming movement and registers
280 * F11_2D_Ctrl50 and F11_2D_Ctrl51 exist.
282 * Query 12 is present if hasQuery12 bit is set.
284 * @has_gapless_finger - control registers relating to gapless finger are
286 * @has_gapless_finger_tuning - additional control and data registers relating
287 * to gapless finger are present.
288 * @has_8bit_w - larger W value reporting is supported.
289 * @has_adjustable_mapping - TBD
290 * @has_info2 - the general info query14 is present
291 * @has_physical_props - additional queries describing the physical properties
292 * of the sensor are present.
293 * @has_finger_limit - indicates that F11 Ctrl 80 exists.
294 * @has_linear_coeff - indicates that F11 Ctrl 81 exists.
296 * Query 13 is present if Query 5's has_jitter_filter bit is set.
297 * @jitter_window_size - used by Design Studio 4.
298 * @jitter_filter_type - used by Design Studio 4.
300 * Query 14 is present if query 12's has_general_info2 flag is set.
302 * @light_control - Indicates what light/led control features are present, if
304 * @is_clear - if set, this is a clear sensor (indicating direct pointing
305 * application), otherwise it's opaque (indicating indirect pointing).
306 * @clickpad_props - specifies if this is a clickpad, and if so what sort of
308 * @mouse_buttons - specifies the number of mouse buttons present (if any).
309 * @has_advanced_gestures - advanced driver gestures are supported.
311 struct f11_2d_sensor_queries
{
317 bool has_sensitivity_adjust
;
331 bool has_anchored_finger
;
334 bool has_bending_correction
;
335 bool has_large_object_suppression
;
336 bool has_jitter_filter
;
355 bool has_touch_shapes
;
356 bool has_scroll_zones
;
357 bool has_individual_scroll_zones
;
359 bool has_mf_edge_motion
;
360 bool has_mf_scroll_inertia
;
367 bool has_palm_det_sensitivity
;
368 bool has_suppress_on_palm_detect
;
369 bool has_two_pen_thresholds
;
370 bool has_contact_geometry
;
371 bool has_pen_hover_discrimination
;
372 bool has_pen_filters
;
379 bool has_algorithm_selection
;
382 bool has_finger_size
;
383 bool has_segmentation_aggressiveness
;
385 bool has_drumming_filter
;
388 bool has_gapless_finger
;
389 bool has_gapless_finger_tuning
;
391 bool has_adjustable_mapping
;
393 bool has_physical_props
;
394 bool has_finger_limit
;
395 bool has_linear_coeff_2
;
398 u8 jitter_window_size
;
399 u8 jitter_filter_type
;
406 bool has_advanced_gestures
;
409 u16 x_sensor_size_mm
;
410 u16 y_sensor_size_mm
;
413 /* Defs for Ctrl0. */
414 #define RMI_F11_REPORT_MODE_MASK 0x07
415 #define RMI_F11_ABS_POS_FILT (1 << 3)
416 #define RMI_F11_REL_POS_FILT (1 << 4)
417 #define RMI_F11_REL_BALLISTICS (1 << 5)
418 #define RMI_F11_DRIBBLE (1 << 6)
419 #define RMI_F11_REPORT_BEYOND_CLIP (1 << 7)
421 /* Defs for Ctrl1. */
422 #define RMI_F11_PALM_DETECT_THRESH_MASK 0x0F
423 #define RMI_F11_MOTION_SENSITIVITY_MASK 0x30
424 #define RMI_F11_MANUAL_TRACKING (1 << 6)
425 #define RMI_F11_MANUAL_TRACKED_FINGER (1 << 7)
427 #define RMI_F11_DELTA_X_THRESHOLD 2
428 #define RMI_F11_DELTA_Y_THRESHOLD 3
430 #define RMI_F11_CTRL_REG_COUNT 12
433 u8 ctrl0_11
[RMI_F11_CTRL_REG_COUNT
];
434 u16 ctrl0_11_address
;
437 #define RMI_F11_ABS_BYTES 5
438 #define RMI_F11_REL_BYTES 2
440 /* Defs for Data 8 */
442 #define RMI_F11_SINGLE_TAP (1 << 0)
443 #define RMI_F11_TAP_AND_HOLD (1 << 1)
444 #define RMI_F11_DOUBLE_TAP (1 << 2)
445 #define RMI_F11_EARLY_TAP (1 << 3)
446 #define RMI_F11_FLICK (1 << 4)
447 #define RMI_F11_PRESS (1 << 5)
448 #define RMI_F11_PINCH (1 << 6)
450 /* Defs for Data 9 */
452 #define RMI_F11_PALM_DETECT (1 << 0)
453 #define RMI_F11_ROTATE (1 << 1)
454 #define RMI_F11_SHAPE (1 << 2)
455 #define RMI_F11_SCROLLZONE (1 << 3)
456 #define RMI_F11_GESTURE_FINGER_COUNT_MASK 0x70
458 /** Handy pointers into our data buffer.
460 * @f_state - start of finger state registers.
461 * @abs_pos - start of absolute position registers (if present).
462 * @rel_pos - start of relative data registers (if present).
463 * @gest_1 - gesture flags (if present).
464 * @gest_2 - gesture flags & finger count (if present).
465 * @pinch - pinch motion register (if present).
466 * @flick - flick distance X & Y, flick time (if present).
467 * @rotate - rotate motion and finger separation.
468 * @multi_scroll - chiral deltas for X and Y (if present).
469 * @scroll_zones - scroll deltas for 4 regions (if present).
485 /** Data pertaining to F11 in general. For per-sensor data, see struct
488 * @dev_query - F11 device specific query registers.
489 * @dev_controls - F11 device specific control registers.
490 * @dev_controls_mutex - lock for the control registers.
491 * @rezero_wait_ms - if nonzero, upon resume we will wait this many
492 * milliseconds before rezeroing the sensor(s). This is useful in systems with
493 * poor electrical behavior on resume, where the initial calibration of the
494 * sensor(s) coming out of sleep state may be bogus.
495 * @sensors - per sensor data structures.
504 struct f11_2d_ctrl dev_controls
;
505 struct mutex dev_controls_mutex
;
507 struct rmi_2d_sensor sensor
;
508 struct f11_2d_sensor_queries sens_query
;
509 struct f11_2d_data data
;
510 struct rmi_2d_sensor_platform_data sensor_pdata
;
511 unsigned long *abs_mask
;
512 unsigned long *rel_mask
;
515 enum f11_finger_state
{
516 F11_NO_FINGER
= 0x00,
518 F11_INACCURATE
= 0x02,
522 static void rmi_f11_rel_pos_report(struct f11_data
*f11
, u8 n_finger
)
524 struct rmi_2d_sensor
*sensor
= &f11
->sensor
;
525 struct f11_2d_data
*data
= &f11
->data
;
528 x
= data
->rel_pos
[n_finger
* RMI_F11_REL_BYTES
];
529 y
= data
->rel_pos
[n_finger
* RMI_F11_REL_BYTES
+ 1];
531 rmi_2d_sensor_rel_report(sensor
, x
, y
);
534 static void rmi_f11_abs_pos_process(struct f11_data
*f11
,
535 struct rmi_2d_sensor
*sensor
,
536 struct rmi_2d_sensor_abs_object
*obj
,
537 enum f11_finger_state finger_state
,
540 struct f11_2d_data
*data
= &f11
->data
;
541 u8
*pos_data
= &data
->abs_pos
[n_finger
* RMI_F11_ABS_BYTES
];
542 int tool_type
= MT_TOOL_FINGER
;
544 switch (finger_state
) {
546 obj
->type
= RMI_2D_OBJECT_FINGER
;
549 obj
->type
= RMI_2D_OBJECT_NONE
;
552 obj
->mt_tool
= tool_type
;
553 obj
->x
= (pos_data
[0] << 4) | (pos_data
[2] & 0x0F);
554 obj
->y
= (pos_data
[1] << 4) | (pos_data
[2] >> 4);
555 obj
->z
= pos_data
[4];
556 obj
->wx
= pos_data
[3] & 0x0f;
557 obj
->wy
= pos_data
[3] >> 4;
559 rmi_2d_sensor_abs_process(sensor
, obj
, n_finger
);
562 static inline u8
rmi_f11_parse_finger_state(const u8
*f_state
, u8 n_finger
)
564 return (f_state
[n_finger
/ 4] >> (2 * (n_finger
% 4))) &
568 static void rmi_f11_finger_handler(struct f11_data
*f11
,
569 struct rmi_2d_sensor
*sensor
, int size
)
571 const u8
*f_state
= f11
->data
.f_state
;
576 int abs_size
= sensor
->nbr_fingers
* RMI_F11_ABS_BYTES
;
578 if (sensor
->report_abs
) {
580 abs_fingers
= size
/ RMI_F11_ABS_BYTES
;
582 abs_fingers
= sensor
->nbr_fingers
;
584 for (i
= 0; i
< abs_fingers
; i
++) {
585 /* Possible of having 4 fingers per f_state register */
586 finger_state
= rmi_f11_parse_finger_state(f_state
, i
);
587 if (finger_state
== F11_RESERVED
) {
588 pr_err("Invalid finger state[%d]: 0x%02x", i
,
593 rmi_f11_abs_pos_process(f11
, sensor
, &sensor
->objs
[i
],
598 * the absolute part is made in 2 parts to allow the kernel
599 * tracking to take place.
601 if (sensor
->kernel_tracking
)
602 input_mt_assign_slots(sensor
->input
,
603 sensor
->tracking_slots
,
604 sensor
->tracking_pos
,
608 for (i
= 0; i
< abs_fingers
; i
++) {
609 finger_state
= rmi_f11_parse_finger_state(f_state
, i
);
610 if (finger_state
== F11_RESERVED
)
611 /* no need to send twice the error */
614 rmi_2d_sensor_abs_report(sensor
, &sensor
->objs
[i
], i
);
617 input_mt_sync_frame(sensor
->input
);
618 } else if (sensor
->report_rel
) {
619 if ((abs_size
+ sensor
->nbr_fingers
* RMI_F11_REL_BYTES
) > size
)
620 rel_fingers
= (size
- abs_size
) / RMI_F11_REL_BYTES
;
622 rel_fingers
= sensor
->nbr_fingers
;
624 for (i
= 0; i
< rel_fingers
; i
++)
625 rmi_f11_rel_pos_report(f11
, i
);
630 static int f11_2d_construct_data(struct f11_data
*f11
)
632 struct rmi_2d_sensor
*sensor
= &f11
->sensor
;
633 struct f11_2d_sensor_queries
*query
= &f11
->sens_query
;
634 struct f11_2d_data
*data
= &f11
->data
;
637 sensor
->nbr_fingers
= (query
->nr_fingers
== 5 ? 10 :
638 query
->nr_fingers
+ 1);
640 sensor
->pkt_size
= DIV_ROUND_UP(sensor
->nbr_fingers
, 4);
642 if (query
->has_abs
) {
643 sensor
->pkt_size
+= (sensor
->nbr_fingers
* 5);
644 sensor
->attn_size
= sensor
->pkt_size
;
648 sensor
->pkt_size
+= (sensor
->nbr_fingers
* 2);
650 /* Check if F11_2D_Query7 is non-zero */
651 if (query
->query7_nonzero
)
652 sensor
->pkt_size
+= sizeof(u8
);
654 /* Check if F11_2D_Query7 or F11_2D_Query8 is non-zero */
655 if (query
->query7_nonzero
|| query
->query8_nonzero
)
656 sensor
->pkt_size
+= sizeof(u8
);
658 if (query
->has_pinch
|| query
->has_flick
|| query
->has_rotate
) {
659 sensor
->pkt_size
+= 3;
660 if (!query
->has_flick
)
662 if (!query
->has_rotate
)
666 if (query
->has_touch_shapes
)
668 DIV_ROUND_UP(query
->nr_touch_shapes
+ 1, 8);
670 sensor
->data_pkt
= devm_kzalloc(&sensor
->fn
->dev
, sensor
->pkt_size
,
672 if (!sensor
->data_pkt
)
675 data
->f_state
= sensor
->data_pkt
;
676 i
= DIV_ROUND_UP(sensor
->nbr_fingers
, 4);
678 if (query
->has_abs
) {
679 data
->abs_pos
= &sensor
->data_pkt
[i
];
680 i
+= (sensor
->nbr_fingers
* RMI_F11_ABS_BYTES
);
683 if (query
->has_rel
) {
684 data
->rel_pos
= &sensor
->data_pkt
[i
];
685 i
+= (sensor
->nbr_fingers
* RMI_F11_REL_BYTES
);
688 if (query
->query7_nonzero
) {
689 data
->gest_1
= &sensor
->data_pkt
[i
];
693 if (query
->query7_nonzero
|| query
->query8_nonzero
) {
694 data
->gest_2
= &sensor
->data_pkt
[i
];
698 if (query
->has_pinch
) {
699 data
->pinch
= &sensor
->data_pkt
[i
];
703 if (query
->has_flick
) {
704 if (query
->has_pinch
) {
705 data
->flick
= data
->pinch
;
708 data
->flick
= &sensor
->data_pkt
[i
];
713 if (query
->has_rotate
) {
714 if (query
->has_flick
) {
715 data
->rotate
= data
->flick
+ 1;
717 data
->rotate
= &sensor
->data_pkt
[i
];
722 if (query
->has_touch_shapes
)
723 data
->shapes
= &sensor
->data_pkt
[i
];
728 static int f11_read_control_regs(struct rmi_function
*fn
,
729 struct f11_2d_ctrl
*ctrl
, u16 ctrl_base_addr
) {
730 struct rmi_device
*rmi_dev
= fn
->rmi_dev
;
733 ctrl
->ctrl0_11_address
= ctrl_base_addr
;
734 error
= rmi_read_block(rmi_dev
, ctrl_base_addr
, ctrl
->ctrl0_11
,
735 RMI_F11_CTRL_REG_COUNT
);
737 dev_err(&fn
->dev
, "Failed to read ctrl0, code: %d.\n", error
);
744 static int f11_write_control_regs(struct rmi_function
*fn
,
745 struct f11_2d_sensor_queries
*query
,
746 struct f11_2d_ctrl
*ctrl
,
749 struct rmi_device
*rmi_dev
= fn
->rmi_dev
;
752 error
= rmi_write_block(rmi_dev
, ctrl_base_addr
, ctrl
->ctrl0_11
,
753 RMI_F11_CTRL_REG_COUNT
);
760 static int rmi_f11_get_query_parameters(struct rmi_device
*rmi_dev
,
761 struct f11_data
*f11
,
762 struct f11_2d_sensor_queries
*sensor_query
,
767 u8 query_buf
[RMI_F11_QUERY_SIZE
];
768 bool has_query36
= false;
770 rc
= rmi_read_block(rmi_dev
, query_base_addr
, query_buf
,
775 sensor_query
->nr_fingers
= query_buf
[0] & RMI_F11_NR_FINGERS_MASK
;
776 sensor_query
->has_rel
= !!(query_buf
[0] & RMI_F11_HAS_REL
);
777 sensor_query
->has_abs
= !!(query_buf
[0] & RMI_F11_HAS_ABS
);
778 sensor_query
->has_gestures
= !!(query_buf
[0] & RMI_F11_HAS_GESTURES
);
779 sensor_query
->has_sensitivity_adjust
=
780 !!(query_buf
[0] & RMI_F11_HAS_SENSITIVITY_ADJ
);
781 sensor_query
->configurable
= !!(query_buf
[0] & RMI_F11_CONFIGURABLE
);
783 sensor_query
->nr_x_electrodes
=
784 query_buf
[1] & RMI_F11_NR_ELECTRODES_MASK
;
785 sensor_query
->nr_y_electrodes
=
786 query_buf
[2] & RMI_F11_NR_ELECTRODES_MASK
;
787 sensor_query
->max_electrodes
=
788 query_buf
[3] & RMI_F11_NR_ELECTRODES_MASK
;
790 query_size
= RMI_F11_QUERY_SIZE
;
792 if (sensor_query
->has_abs
) {
793 rc
= rmi_read(rmi_dev
, query_base_addr
+ query_size
, query_buf
);
797 sensor_query
->abs_data_size
=
798 query_buf
[0] & RMI_F11_ABS_DATA_SIZE_MASK
;
799 sensor_query
->has_anchored_finger
=
800 !!(query_buf
[0] & RMI_F11_HAS_ANCHORED_FINGER
);
801 sensor_query
->has_adj_hyst
=
802 !!(query_buf
[0] & RMI_F11_HAS_ADJ_HYST
);
803 sensor_query
->has_dribble
=
804 !!(query_buf
[0] & RMI_F11_HAS_DRIBBLE
);
805 sensor_query
->has_bending_correction
=
806 !!(query_buf
[0] & RMI_F11_HAS_BENDING_CORRECTION
);
807 sensor_query
->has_large_object_suppression
=
808 !!(query_buf
[0] & RMI_F11_HAS_LARGE_OBJECT_SUPPRESSION
);
809 sensor_query
->has_jitter_filter
=
810 !!(query_buf
[0] & RMI_F11_HAS_JITTER_FILTER
);
814 if (sensor_query
->has_rel
) {
815 rc
= rmi_read(rmi_dev
, query_base_addr
+ query_size
,
816 &sensor_query
->f11_2d_query6
);
822 if (sensor_query
->has_gestures
) {
823 rc
= rmi_read_block(rmi_dev
, query_base_addr
+ query_size
,
824 query_buf
, RMI_F11_QUERY_GESTURE_SIZE
);
828 sensor_query
->has_single_tap
=
829 !!(query_buf
[0] & RMI_F11_HAS_SINGLE_TAP
);
830 sensor_query
->has_tap_n_hold
=
831 !!(query_buf
[0] & RMI_F11_HAS_TAP_AND_HOLD
);
832 sensor_query
->has_double_tap
=
833 !!(query_buf
[0] & RMI_F11_HAS_DOUBLE_TAP
);
834 sensor_query
->has_early_tap
=
835 !!(query_buf
[0] & RMI_F11_HAS_EARLY_TAP
);
836 sensor_query
->has_flick
=
837 !!(query_buf
[0] & RMI_F11_HAS_FLICK
);
838 sensor_query
->has_press
=
839 !!(query_buf
[0] & RMI_F11_HAS_PRESS
);
840 sensor_query
->has_pinch
=
841 !!(query_buf
[0] & RMI_F11_HAS_PINCH
);
842 sensor_query
->has_chiral
=
843 !!(query_buf
[0] & RMI_F11_HAS_CHIRAL
);
846 sensor_query
->has_palm_det
=
847 !!(query_buf
[1] & RMI_F11_HAS_PALM_DET
);
848 sensor_query
->has_rotate
=
849 !!(query_buf
[1] & RMI_F11_HAS_ROTATE
);
850 sensor_query
->has_touch_shapes
=
851 !!(query_buf
[1] & RMI_F11_HAS_TOUCH_SHAPES
);
852 sensor_query
->has_scroll_zones
=
853 !!(query_buf
[1] & RMI_F11_HAS_SCROLL_ZONES
);
854 sensor_query
->has_individual_scroll_zones
=
855 !!(query_buf
[1] & RMI_F11_HAS_INDIVIDUAL_SCROLL_ZONES
);
856 sensor_query
->has_mf_scroll
=
857 !!(query_buf
[1] & RMI_F11_HAS_MF_SCROLL
);
858 sensor_query
->has_mf_edge_motion
=
859 !!(query_buf
[1] & RMI_F11_HAS_MF_EDGE_MOTION
);
860 sensor_query
->has_mf_scroll_inertia
=
861 !!(query_buf
[1] & RMI_F11_HAS_MF_SCROLL_INERTIA
);
863 sensor_query
->query7_nonzero
= !!(query_buf
[0]);
864 sensor_query
->query8_nonzero
= !!(query_buf
[1]);
869 if (f11
->has_query9
) {
870 rc
= rmi_read(rmi_dev
, query_base_addr
+ query_size
, query_buf
);
874 sensor_query
->has_pen
=
875 !!(query_buf
[0] & RMI_F11_HAS_PEN
);
876 sensor_query
->has_proximity
=
877 !!(query_buf
[0] & RMI_F11_HAS_PROXIMITY
);
878 sensor_query
->has_palm_det_sensitivity
=
879 !!(query_buf
[0] & RMI_F11_HAS_PALM_DET_SENSITIVITY
);
880 sensor_query
->has_suppress_on_palm_detect
=
881 !!(query_buf
[0] & RMI_F11_HAS_SUPPRESS_ON_PALM_DETECT
);
882 sensor_query
->has_two_pen_thresholds
=
883 !!(query_buf
[0] & RMI_F11_HAS_TWO_PEN_THRESHOLDS
);
884 sensor_query
->has_contact_geometry
=
885 !!(query_buf
[0] & RMI_F11_HAS_CONTACT_GEOMETRY
);
886 sensor_query
->has_pen_hover_discrimination
=
887 !!(query_buf
[0] & RMI_F11_HAS_PEN_HOVER_DISCRIMINATION
);
888 sensor_query
->has_pen_filters
=
889 !!(query_buf
[0] & RMI_F11_HAS_PEN_FILTERS
);
894 if (sensor_query
->has_touch_shapes
) {
895 rc
= rmi_read(rmi_dev
, query_base_addr
+ query_size
, query_buf
);
899 sensor_query
->nr_touch_shapes
= query_buf
[0] &
900 RMI_F11_NR_TOUCH_SHAPES_MASK
;
905 if (f11
->has_query11
) {
906 rc
= rmi_read(rmi_dev
, query_base_addr
+ query_size
, query_buf
);
910 sensor_query
->has_z_tuning
=
911 !!(query_buf
[0] & RMI_F11_HAS_Z_TUNING
);
912 sensor_query
->has_algorithm_selection
=
913 !!(query_buf
[0] & RMI_F11_HAS_ALGORITHM_SELECTION
);
914 sensor_query
->has_w_tuning
=
915 !!(query_buf
[0] & RMI_F11_HAS_W_TUNING
);
916 sensor_query
->has_pitch_info
=
917 !!(query_buf
[0] & RMI_F11_HAS_PITCH_INFO
);
918 sensor_query
->has_finger_size
=
919 !!(query_buf
[0] & RMI_F11_HAS_FINGER_SIZE
);
920 sensor_query
->has_segmentation_aggressiveness
=
922 RMI_F11_HAS_SEGMENTATION_AGGRESSIVENESS
);
923 sensor_query
->has_XY_clip
=
924 !!(query_buf
[0] & RMI_F11_HAS_XY_CLIP
);
925 sensor_query
->has_drumming_filter
=
926 !!(query_buf
[0] & RMI_F11_HAS_DRUMMING_FILTER
);
931 if (f11
->has_query12
) {
932 rc
= rmi_read(rmi_dev
, query_base_addr
+ query_size
, query_buf
);
936 sensor_query
->has_gapless_finger
=
937 !!(query_buf
[0] & RMI_F11_HAS_GAPLESS_FINGER
);
938 sensor_query
->has_gapless_finger_tuning
=
939 !!(query_buf
[0] & RMI_F11_HAS_GAPLESS_FINGER_TUNING
);
940 sensor_query
->has_8bit_w
=
941 !!(query_buf
[0] & RMI_F11_HAS_8BIT_W
);
942 sensor_query
->has_adjustable_mapping
=
943 !!(query_buf
[0] & RMI_F11_HAS_ADJUSTABLE_MAPPING
);
944 sensor_query
->has_info2
=
945 !!(query_buf
[0] & RMI_F11_HAS_INFO2
);
946 sensor_query
->has_physical_props
=
947 !!(query_buf
[0] & RMI_F11_HAS_PHYSICAL_PROPS
);
948 sensor_query
->has_finger_limit
=
949 !!(query_buf
[0] & RMI_F11_HAS_FINGER_LIMIT
);
950 sensor_query
->has_linear_coeff_2
=
951 !!(query_buf
[0] & RMI_F11_HAS_LINEAR_COEFF
);
956 if (sensor_query
->has_jitter_filter
) {
957 rc
= rmi_read(rmi_dev
, query_base_addr
+ query_size
, query_buf
);
961 sensor_query
->jitter_window_size
= query_buf
[0] &
962 RMI_F11_JITTER_WINDOW_MASK
;
963 sensor_query
->jitter_filter_type
= (query_buf
[0] &
964 RMI_F11_JITTER_FILTER_MASK
) >>
965 RMI_F11_JITTER_FILTER_SHIFT
;
970 if (sensor_query
->has_info2
) {
971 rc
= rmi_read(rmi_dev
, query_base_addr
+ query_size
, query_buf
);
975 sensor_query
->light_control
=
976 query_buf
[0] & RMI_F11_LIGHT_CONTROL_MASK
;
977 sensor_query
->is_clear
=
978 !!(query_buf
[0] & RMI_F11_IS_CLEAR
);
979 sensor_query
->clickpad_props
=
980 (query_buf
[0] & RMI_F11_CLICKPAD_PROPS_MASK
) >>
981 RMI_F11_CLICKPAD_PROPS_SHIFT
;
982 sensor_query
->mouse_buttons
=
983 (query_buf
[0] & RMI_F11_MOUSE_BUTTONS_MASK
) >>
984 RMI_F11_MOUSE_BUTTONS_SHIFT
;
985 sensor_query
->has_advanced_gestures
=
986 !!(query_buf
[0] & RMI_F11_HAS_ADVANCED_GESTURES
);
991 if (sensor_query
->has_physical_props
) {
992 rc
= rmi_read_block(rmi_dev
, query_base_addr
993 + query_size
, query_buf
, 4);
997 sensor_query
->x_sensor_size_mm
=
998 (query_buf
[0] | (query_buf
[1] << 8)) / 10;
999 sensor_query
->y_sensor_size_mm
=
1000 (query_buf
[2] | (query_buf
[3] << 8)) / 10;
1003 * query 15 - 18 contain the size of the sensor
1004 * and query 19 - 26 contain bezel dimensions
1009 if (f11
->has_query27
)
1012 if (f11
->has_query28
) {
1013 rc
= rmi_read(rmi_dev
, query_base_addr
+ query_size
,
1018 has_query36
= !!(query_buf
[0] & BIT(6));
1023 rc
= rmi_read(rmi_dev
, query_base_addr
+ query_size
,
1028 if (!!(query_buf
[0] & BIT(5)))
1029 f11
->has_acm
= true;
1035 static int rmi_f11_initialize(struct rmi_function
*fn
)
1037 struct rmi_device
*rmi_dev
= fn
->rmi_dev
;
1038 struct f11_data
*f11
;
1039 struct f11_2d_ctrl
*ctrl
;
1041 u16 query_base_addr
;
1042 u16 control_base_addr
;
1043 u16 max_x_pos
, max_y_pos
;
1045 const struct rmi_device_platform_data
*pdata
=
1046 rmi_get_platform_data(rmi_dev
);
1047 struct rmi_driver_data
*drvdata
= dev_get_drvdata(&rmi_dev
->dev
);
1048 struct rmi_2d_sensor
*sensor
;
1052 rmi_dbg(RMI_DEBUG_FN
, &fn
->dev
, "Initializing F11 values.\n");
1054 mask_size
= BITS_TO_LONGS(drvdata
->irq_count
) * sizeof(unsigned long);
1057 ** init instance data, fill in values and create any sysfs files
1059 f11
= devm_kzalloc(&fn
->dev
, sizeof(struct f11_data
) + mask_size
* 2,
1064 if (fn
->dev
.of_node
) {
1065 rc
= rmi_2d_sensor_of_probe(&fn
->dev
, &f11
->sensor_pdata
);
1069 f11
->sensor_pdata
= pdata
->sensor_pdata
;
1072 f11
->rezero_wait_ms
= f11
->sensor_pdata
.rezero_wait
;
1074 f11
->abs_mask
= (unsigned long *)((char *)f11
1075 + sizeof(struct f11_data
));
1076 f11
->rel_mask
= (unsigned long *)((char *)f11
1077 + sizeof(struct f11_data
) + mask_size
);
1079 set_bit(fn
->irq_pos
, f11
->abs_mask
);
1080 set_bit(fn
->irq_pos
+ 1, f11
->rel_mask
);
1082 query_base_addr
= fn
->fd
.query_base_addr
;
1083 control_base_addr
= fn
->fd
.control_base_addr
;
1085 rc
= rmi_read(rmi_dev
, query_base_addr
, &buf
);
1089 f11
->has_query9
= !!(buf
& RMI_F11_HAS_QUERY9
);
1090 f11
->has_query11
= !!(buf
& RMI_F11_HAS_QUERY11
);
1091 f11
->has_query12
= !!(buf
& RMI_F11_HAS_QUERY12
);
1092 f11
->has_query27
= !!(buf
& RMI_F11_HAS_QUERY27
);
1093 f11
->has_query28
= !!(buf
& RMI_F11_HAS_QUERY28
);
1095 query_offset
= (query_base_addr
+ 1);
1096 sensor
= &f11
->sensor
;
1099 rc
= rmi_f11_get_query_parameters(rmi_dev
, f11
,
1100 &f11
->sens_query
, query_offset
);
1105 rc
= f11_read_control_regs(fn
, &f11
->dev_controls
,
1109 "Failed to read F11 control params.\n");
1113 if (f11
->sens_query
.has_info2
) {
1114 if (f11
->sens_query
.is_clear
)
1115 f11
->sensor
.sensor_type
= rmi_sensor_touchscreen
;
1117 f11
->sensor
.sensor_type
= rmi_sensor_touchpad
;
1120 sensor
->report_abs
= f11
->sens_query
.has_abs
;
1122 sensor
->axis_align
=
1123 f11
->sensor_pdata
.axis_align
;
1125 sensor
->topbuttonpad
= f11
->sensor_pdata
.topbuttonpad
;
1126 sensor
->kernel_tracking
= f11
->sensor_pdata
.kernel_tracking
;
1127 sensor
->dmax
= f11
->sensor_pdata
.dmax
;
1128 sensor
->dribble
= f11
->sensor_pdata
.dribble
;
1129 sensor
->palm_detect
= f11
->sensor_pdata
.palm_detect
;
1131 if (f11
->sens_query
.has_physical_props
) {
1132 sensor
->x_mm
= f11
->sens_query
.x_sensor_size_mm
;
1133 sensor
->y_mm
= f11
->sens_query
.y_sensor_size_mm
;
1135 sensor
->x_mm
= f11
->sensor_pdata
.x_mm
;
1136 sensor
->y_mm
= f11
->sensor_pdata
.y_mm
;
1139 if (sensor
->sensor_type
== rmi_sensor_default
)
1140 sensor
->sensor_type
=
1141 f11
->sensor_pdata
.sensor_type
;
1143 sensor
->report_abs
= sensor
->report_abs
1144 && !(f11
->sensor_pdata
.disable_report_mask
1145 & RMI_F11_DISABLE_ABS_REPORT
);
1147 if (!sensor
->report_abs
)
1149 * If device doesn't have abs or if it has been disables
1150 * fallback to reporting rel data.
1152 sensor
->report_rel
= f11
->sens_query
.has_rel
;
1154 rc
= rmi_read_block(rmi_dev
,
1155 control_base_addr
+ F11_CTRL_SENSOR_MAX_X_POS_OFFSET
,
1156 (u8
*)&max_x_pos
, sizeof(max_x_pos
));
1160 rc
= rmi_read_block(rmi_dev
,
1161 control_base_addr
+ F11_CTRL_SENSOR_MAX_Y_POS_OFFSET
,
1162 (u8
*)&max_y_pos
, sizeof(max_y_pos
));
1166 sensor
->max_x
= max_x_pos
;
1167 sensor
->max_y
= max_y_pos
;
1169 rc
= f11_2d_construct_data(f11
);
1174 f11
->sensor
.attn_size
+= f11
->sensor
.nbr_fingers
* 2;
1176 /* allocate the in-kernel tracking buffers */
1177 sensor
->tracking_pos
= devm_kcalloc(&fn
->dev
,
1178 sensor
->nbr_fingers
, sizeof(struct input_mt_pos
),
1180 sensor
->tracking_slots
= devm_kcalloc(&fn
->dev
,
1181 sensor
->nbr_fingers
, sizeof(int), GFP_KERNEL
);
1182 sensor
->objs
= devm_kcalloc(&fn
->dev
,
1183 sensor
->nbr_fingers
,
1184 sizeof(struct rmi_2d_sensor_abs_object
),
1186 if (!sensor
->tracking_pos
|| !sensor
->tracking_slots
|| !sensor
->objs
)
1189 ctrl
= &f11
->dev_controls
;
1190 if (sensor
->axis_align
.delta_x_threshold
)
1191 ctrl
->ctrl0_11
[RMI_F11_DELTA_X_THRESHOLD
] =
1192 sensor
->axis_align
.delta_x_threshold
;
1194 if (sensor
->axis_align
.delta_y_threshold
)
1195 ctrl
->ctrl0_11
[RMI_F11_DELTA_Y_THRESHOLD
] =
1196 sensor
->axis_align
.delta_y_threshold
;
1198 if (f11
->sens_query
.has_dribble
) {
1199 switch (sensor
->dribble
) {
1200 case RMI_REG_STATE_OFF
:
1201 ctrl
->ctrl0_11
[0] &= ~BIT(6);
1203 case RMI_REG_STATE_ON
:
1204 ctrl
->ctrl0_11
[0] |= BIT(6);
1206 case RMI_REG_STATE_DEFAULT
:
1212 if (f11
->sens_query
.has_palm_det
) {
1213 switch (sensor
->palm_detect
) {
1214 case RMI_REG_STATE_OFF
:
1215 ctrl
->ctrl0_11
[11] &= ~BIT(0);
1217 case RMI_REG_STATE_ON
:
1218 ctrl
->ctrl0_11
[11] |= BIT(0);
1220 case RMI_REG_STATE_DEFAULT
:
1226 rc
= f11_write_control_regs(fn
, &f11
->sens_query
,
1227 &f11
->dev_controls
, fn
->fd
.control_base_addr
);
1229 dev_warn(&fn
->dev
, "Failed to write control registers\n");
1231 mutex_init(&f11
->dev_controls_mutex
);
1233 dev_set_drvdata(&fn
->dev
, f11
);
1238 static int rmi_f11_config(struct rmi_function
*fn
)
1240 struct f11_data
*f11
= dev_get_drvdata(&fn
->dev
);
1241 struct rmi_driver
*drv
= fn
->rmi_dev
->driver
;
1242 struct rmi_2d_sensor
*sensor
= &f11
->sensor
;
1245 if (!sensor
->report_abs
)
1246 drv
->clear_irq_bits(fn
->rmi_dev
, f11
->abs_mask
);
1248 drv
->set_irq_bits(fn
->rmi_dev
, f11
->abs_mask
);
1250 if (!sensor
->report_rel
)
1251 drv
->clear_irq_bits(fn
->rmi_dev
, f11
->rel_mask
);
1253 drv
->set_irq_bits(fn
->rmi_dev
, f11
->rel_mask
);
1255 rc
= f11_write_control_regs(fn
, &f11
->sens_query
,
1256 &f11
->dev_controls
, fn
->fd
.query_base_addr
);
1263 static irqreturn_t
rmi_f11_attention(int irq
, void *ctx
)
1265 struct rmi_function
*fn
= ctx
;
1266 struct rmi_device
*rmi_dev
= fn
->rmi_dev
;
1267 struct rmi_driver_data
*drvdata
= dev_get_drvdata(&rmi_dev
->dev
);
1268 struct f11_data
*f11
= dev_get_drvdata(&fn
->dev
);
1269 u16 data_base_addr
= fn
->fd
.data_base_addr
;
1271 int valid_bytes
= f11
->sensor
.pkt_size
;
1273 if (drvdata
->attn_data
.data
) {
1275 * The valid data in the attention report is less then
1276 * expected. Only process the complete fingers.
1278 if (f11
->sensor
.attn_size
> drvdata
->attn_data
.size
)
1279 valid_bytes
= drvdata
->attn_data
.size
;
1281 valid_bytes
= f11
->sensor
.attn_size
;
1282 memcpy(f11
->sensor
.data_pkt
, drvdata
->attn_data
.data
,
1284 drvdata
->attn_data
.data
+= valid_bytes
;
1285 drvdata
->attn_data
.size
-= valid_bytes
;
1287 error
= rmi_read_block(rmi_dev
,
1288 data_base_addr
, f11
->sensor
.data_pkt
,
1289 f11
->sensor
.pkt_size
);
1291 return IRQ_RETVAL(error
);
1294 rmi_f11_finger_handler(f11
, &f11
->sensor
, valid_bytes
);
1299 static int rmi_f11_resume(struct rmi_function
*fn
)
1301 struct f11_data
*f11
= dev_get_drvdata(&fn
->dev
);
1304 rmi_dbg(RMI_DEBUG_FN
, &fn
->dev
, "Resuming...\n");
1305 if (!f11
->rezero_wait_ms
)
1308 mdelay(f11
->rezero_wait_ms
);
1310 error
= rmi_write(fn
->rmi_dev
, fn
->fd
.command_base_addr
,
1314 "%s: failed to issue rezero command, error = %d.",
1322 static int rmi_f11_probe(struct rmi_function
*fn
)
1325 struct f11_data
*f11
;
1327 error
= rmi_f11_initialize(fn
);
1331 f11
= dev_get_drvdata(&fn
->dev
);
1332 error
= rmi_2d_sensor_configure_input(fn
, &f11
->sensor
);
1339 struct rmi_function_handler rmi_f11_handler
= {
1344 .probe
= rmi_f11_probe
,
1345 .config
= rmi_f11_config
,
1346 .attention
= rmi_f11_attention
,
1347 .resume
= rmi_f11_resume
,