linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ryan Hendrickson <ryan.hendrickson@alum.mit.edu>
To: linux-input@vger.kernel.org
Cc: Henrik Rydberg <rydberg@bitmath.org>
Subject: [PATCH] bcm5974: report ABS_MT_PRESSURE
Date: Fri, 1 Dec 2017 12:13:22 -0500 (EST)	[thread overview]
Message-ID: <alpine.LNX.2.21.1712011208150.14154@adam> (raw)

[-- Attachment #1: Type: text/plain, Size: 2648 bytes --]

Report ABS_MT_PRESSURE in the bcm5974 driver with the same data used for
ABS_PRESSURE.

Some touchpad improvements in recent versions of libinput, such as
pressure-based palm detection, will only work if ABS_MT_PRESSURE is
reported.

Signed-off-by: Ryan Hendrickson <ryan.hendrickson@alum.mit.edu>

---

Please treat all of this with an extra grain of salt; this is my first real
foray into both evdev/libinput internals and kernel development. That said,
I have been running this patch on my daily-use MacBookPro5,1 for several
months, so I have reason to believe it's stable. It might not be the
‘right’ way to do this though; I mostly just copied the corresponding code
for ABS_PRESSURE, which from this[1] blog post I've inferred should have
the same values and range.

[1]: http://who-t.blogspot.com/2016/09/understanding-evdev.html

Patch was originally submitted as bug 197909[2], which can be closed if
this is accepted.

[2]: https://bugzilla.kernel.org/show_bug.cgi?id=197909

--- linux-4.13/drivers/input/mouse/bcm5974.c.orig	2017-12-01 11:36:35.258890243 -0500
+++ linux-4.13/drivers/input/mouse/bcm5974.c	2017-12-01 11:48:55.187342210 -0500
@@ -548,6 +548,8 @@ static void setup_events_to_report(struc
  	set_abs(input_dev, ABS_MT_POSITION_X, &cfg->x);
  	set_abs(input_dev, ABS_MT_POSITION_Y, &cfg->y);

+	set_abs(input_dev, ABS_MT_PRESSURE, &cfg->p);
+
  	__set_bit(EV_KEY, input_dev->evbit);
  	__set_bit(BTN_LEFT, input_dev->keybit);

@@ -575,10 +577,14 @@ static int report_bt_state(struct bcm597
  	return 0;
  }

-static void report_finger_data(struct input_dev *input, int slot,
+static void report_finger_data(struct input_dev *input,
+			       const struct bcm5974_config *cfg,
+			       int slot,
  			       const struct input_mt_pos *pos,
  			       const struct tp_finger *f)
  {
+	int abs_p;
+
  	input_mt_slot(input, slot);
  	input_mt_report_slot_state(input, MT_TOOL_FINGER, true);

@@ -594,6 +600,9 @@ static void report_finger_data(struct in
  			 MAX_FINGER_ORIENTATION - raw2int(f->orientation));
  	input_report_abs(input, ABS_MT_POSITION_X, pos->x);
  	input_report_abs(input, ABS_MT_POSITION_Y, pos->y);
+
+	abs_p = clamp_val(256 * raw2int(f->touch_major) / cfg->p.max, 0, 255);
+	input_report_abs(input, ABS_MT_PRESSURE, abs_p);
  }

  static void report_synaptics_data(struct input_dev *input,
@@ -640,7 +649,7 @@ static int report_tp_state(struct bcm597
  	input_mt_assign_slots(input, dev->slots, dev->pos, n, 0);

  	for (i = 0; i < n; i++)
-		report_finger_data(input, dev->slots[i],
+		report_finger_data(input, c, dev->slots[i],
  				   &dev->pos[i], dev->index[i]);

  	input_mt_sync_frame(input);

             reply	other threads:[~2017-12-01 17:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01 17:13 Ryan Hendrickson [this message]
2017-12-15  1:37 ` [PATCH] bcm5974: report ABS_MT_PRESSURE Ryan Hendrickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.21.1712011208150.14154@adam \
    --to=ryan.hendrickson@alum.mit.edu \
    --cc=linux-input@vger.kernel.org \
    --cc=rydberg@bitmath.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).