All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gerecke, Jason" <Jason.Gerecke@wacom.com>
To: Kenneth Albanowski <kenalba@google.com>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: "open list:HID CORE LAYER" <linux-input@vger.kernel.org>,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Jiri Kosina <jikos@kernel.org>,
	Peter Hutterer <peter.hutterer@who-t.net>,
	"Cheng, Ping" <Ping.Cheng@wacom.com>
Subject: Re: Supporting 64-bit Digitizer Serial Numbers?
Date: Thu, 8 Apr 2021 22:19:18 +0000	[thread overview]
Message-ID: <VI1PR07MB5821FB3E0E4B570C9B18FEC9ED749@VI1PR07MB5821.eurprd07.prod.outlook.com> (raw)
In-Reply-To: <CALvoSf63YbXdK8-yEUnnJqaGeZ4VF2A+8u4M9tpoSB7OHOxHXQ@mail.gmail.com>

First of all, my apologies for the likely-wonky email formatting. For some reason I'm missing messages from linux-input in my Gmail so I'm forced to reply from Outlook (which doesn't exactly make inline plain-text replies easy).

> > > My thought is to perform minimal modifications to allow hid-core to
> > > transfer reports up to 64-bits in size to hid-input, so that it can
> > > process this field and emit it to the power_supply integration, as well
> > > as through classic MSC_SERIAL (for the low 32 bits) and a new
> > > MSC_SERIAL2 (the upper bits) for applications which want it inline with
> > > stylus event data.
> >
> > The wacom driver already has this problem and handles it in a creative
> > way (as usual ;-P)
> > If I am not mistaken, it splits the 64 bits serial on 2 events as
> > well: MSC_SERIAL and ABS_MISC (Jason might correct me here).
> >
> > I am not saying this is what needs to be done, but just what some
> userspace tools already expect.
> 
> As Peter mentions, this seems separate, ABS_MISC being a sort of tool
> type identifier, quite different from the serial number. (They apparently
> get extracted from the same data report in the wacom formats, but the
> intention seems distinct.)
> 
> As far as I can see, the Wacom S/N (stuffed into MSC_SERIAL) is indeed
> always truncated to 32 bits; introducing MSC_SERIAL2 should be suitable
> for the wacom driver as well if they want to publish the high bits.

ABS_MISC and MSC_SERIAL are nominally the tool type and serial number fields. A given serial number may be re-used across tool types, however, and so the two fields must be combined to get a globally unique ID. It's not *quite* that simple though:

    * The ABS_MISC field is sometimes intentionally mangled for compatibility with an ancient wacom.ko bug
    * A 32-bit MSC_SERIAL is sometimes not quite large enough to store the nominal serial number
    * The way the values are assembled varies between devices (i.e. on some devices ABS_MISC is the high "n"-bits, on others it is the low "n"-bits, and "n" may vary).

I'd love to have a way for our driver to report an unmangled 64-bit unique ID which matches what you'd get on Windows and OSX, but I don't think MSC_SERIAL2 quite solves that problem for us. We could use it with devices which have MSC_SERIAL as the low 32 bits of the unique ID, but not those that have ABS_MISC as the low "n"-bits).

> > If changing MSC_SERIAL is deemed too risky for compatibility, then it's
> > easy to just leave MSC_SERIAL as-is, and put in a separate MSC_SERIAL1
> > (MSC_SERIAL0?) that has the pristine low bits -- just at a cost of yet
> > one more MSC_ field per report, and using up the last MSC_ bit before
> > we need to bump MSC_MAX.
> >
> > This approach doesn't affect Wacom evdev events at all, all of that
> > logic is separate from hid-input.
>
> There is a whole ecosystem for wacom, but we are pretty much in
> control of all the pieces. So I would prefer involving wacom from the
> beginning, and have a common representation to the user space.

Providing a separate MSC_SERIAL1 (or zero) in addition to MSC_SERIAL2 could be the solution to the problems above. Our driver can be taught how to assemble the 64-bit IDs and then split them into events for the high- and low-order bytes. We might want to consider using a different prefix than MSC_SERIAL if we go this route, however. It could be very confusing to understand how all three events do (and don't) relate to each other if their names are too similar.

Of course, it'd also be great if the input structs could fit 64-bit integers, but that's probably not possible (and also doesn't help with devices that want to report e.g. 128-bit numbers).

  reply	other threads:[~2021-04-08 22:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24 19:53 Supporting 64-bit Digitizer Serial Numbers? Kenneth Albanowski
2021-03-25  8:35 ` Benjamin Tissoires
2021-03-26  5:56   ` Peter Hutterer
2021-03-31 19:59   ` Kenneth Albanowski
2021-04-08 22:19     ` Gerecke, Jason [this message]
2021-04-08 23:32       ` Kenneth Albanowski

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=VI1PR07MB5821FB3E0E4B570C9B18FEC9ED749@VI1PR07MB5821.eurprd07.prod.outlook.com \
    --to=jason.gerecke@wacom.com \
    --cc=Ping.Cheng@wacom.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jikos@kernel.org \
    --cc=kenalba@google.com \
    --cc=linux-input@vger.kernel.org \
    --cc=peter.hutterer@who-t.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.