Skip to content

Commit 6f2701b

Browse files
rydbergdtor
authored andcommitted
Input: bcm5974 - report ABS_MT events
Make bcm5974 report raw multi-touch (MT) data in the form of ABS_MT events. [dtor@mail.ru: get rid of module option, always report all events] Signed-off-by: Henrik Rydberg <rydberg@euromail.se> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
1 parent 861a644 commit 6f2701b

1 file changed

Lines changed: 43 additions & 1 deletion

File tree

‎drivers/input/mouse/bcm5974.c‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ struct tp_finger {
139139
/* trackpad finger data size, empirically at least ten fingers */
140140
#define SIZEOF_FINGER sizeof(struct tp_finger)
141141
#define SIZEOF_ALL_FINGERS (16 * SIZEOF_FINGER)
142+
#define MAX_FINGER_ORIENTATION 16384
142143

143144
/* device-specific parameters */
144145
struct bcm5974_param {
@@ -284,6 +285,26 @@ static void setup_events_to_report(struct input_dev *input_dev,
284285
input_set_abs_params(input_dev, ABS_Y,
285286
0, cfg->y.dim, cfg->y.fuzz, 0);
286287

288+
/* finger touch area */
289+
input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
290+
cfg->w.devmin, cfg->w.devmax, 0, 0);
291+
input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
292+
cfg->w.devmin, cfg->w.devmax, 0, 0);
293+
/* finger approach area */
294+
input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR,
295+
cfg->w.devmin, cfg->w.devmax, 0, 0);
296+
input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR,
297+
cfg->w.devmin, cfg->w.devmax, 0, 0);
298+
/* finger orientation */
299+
input_set_abs_params(input_dev, ABS_MT_ORIENTATION,
300+
-MAX_FINGER_ORIENTATION,
301+
MAX_FINGER_ORIENTATION, 0, 0);
302+
/* finger position */
303+
input_set_abs_params(input_dev, ABS_MT_POSITION_X,
304+
cfg->x.devmin, cfg->x.devmax, 0, 0);
305+
input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
306+
cfg->y.devmin, cfg->y.devmax, 0, 0);
307+
287308
__set_bit(EV_KEY, input_dev->evbit);
288309
__set_bit(BTN_TOUCH, input_dev->keybit);
289310
__set_bit(BTN_TOOL_FINGER, input_dev->keybit);
@@ -310,13 +331,29 @@ static int report_bt_state(struct bcm5974 *dev, int size)
310331
return 0;
311332
}
312333

334+
static void report_finger_data(struct input_dev *input,
335+
const struct bcm5974_config *cfg,
336+
const struct tp_finger *f)
337+
{
338+
input_report_abs(input, ABS_MT_TOUCH_MAJOR, raw2int(f->force_major));
339+
input_report_abs(input, ABS_MT_TOUCH_MINOR, raw2int(f->force_minor));
340+
input_report_abs(input, ABS_MT_WIDTH_MAJOR, raw2int(f->size_major));
341+
input_report_abs(input, ABS_MT_WIDTH_MINOR, raw2int(f->size_minor));
342+
input_report_abs(input, ABS_MT_ORIENTATION,
343+
MAX_FINGER_ORIENTATION - raw2int(f->orientation));
344+
input_report_abs(input, ABS_MT_POSITION_X, raw2int(f->abs_x));
345+
input_report_abs(input, ABS_MT_POSITION_Y,
346+
cfg->y.devmin + cfg->y.devmax - raw2int(f->abs_y));
347+
input_mt_sync(input);
348+
}
349+
313350
/* report trackpad data as logical trackpad state */
314351
static int report_tp_state(struct bcm5974 *dev, int size)
315352
{
316353
const struct bcm5974_config *c = &dev->cfg;
317354
const struct tp_finger *f;
318355
struct input_dev *input = dev->input;
319-
int raw_p, raw_w, raw_x, raw_y, raw_n;
356+
int raw_p, raw_w, raw_x, raw_y, raw_n, i;
320357
int ptest, origin, ibt = 0, nmin = 0, nmax = 0;
321358
int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0;
322359

@@ -329,6 +366,11 @@ static int report_tp_state(struct bcm5974 *dev, int size)
329366

330367
/* always track the first finger; when detached, start over */
331368
if (raw_n) {
369+
370+
/* report raw trackpad data */
371+
for (i = 0; i < raw_n; i++)
372+
report_finger_data(input, c, &f[i]);
373+
332374
raw_p = raw2int(f->force_major);
333375
raw_w = raw2int(f->size_major);
334376
raw_x = raw2int(f->abs_x);

0 commit comments

Comments
 (0)