Touchscreen calibration matrix changes

Peter Hutterer peter.hutterer at who-t.net
Wed Apr 6 04:58:08 UTC 2022


On Wed, Apr 06, 2022 at 06:02:22AM +0300, Teemu K wrote:
> On Tue, Apr 5, 2022 at 5:21 PM Pekka Paalanen <ppaalanen at gmail.com> wrote:
> >
> > On Tue, 29 Mar 2022 15:31:59 +0300
> > Teemu K <maillinglists18 at gmail.com> wrote:
> >
> > > Hi,
> > >
> > > I'm trying to get touch calibration working on Wayland/Weston for
> > > resistive touch. I can get the calibration points and calculate
> > > calibration matrix values, but when I call
> > > libinput_device_config_calibration_set_matrix and then read it back it
> > > would seem that the matrix is changed, but the actual touchscreen does
> > > not indicate so. Ie. if I calibrate the touch clearly wrong it still
> > > behaves like it would have been calibrated perfectly.
> >
> > Hi,
> >
> > what exactly do you mean by "when I call
> > libinput_device_config_calibration_set_matrix", what is "I" there?
> By "I" I mean the application.
> 
> > > If I set the same values to udev rule like this:
> > > ATTRS{name}=="tsc2007", ENV{LIBINPUT_CALIBRATION_MATRIX}="1.29342,
> > > -0.0223598, -0.135092, -0.0272545, -1.11435, 1.04368"
> > >
> > > They get taken in use and I can read those values as default values
> > > with libinput_device_config_calibration_get_default_matrix - function.
> >
> > That's right.
> >
> > > Is there something else that needs to be done to get the updated
> > > matrix taken in use or is there known issue with Wayland/Weston given
> > > that it is quite old version Wayland 1.17.0/Weston 6.0.1.
> > > Unfortunately I'm stuck with those versions for now.
> >
> > I'm not sure what problem you have. The udev rule works, right?
> Yeah, but the problem was replacing those defaults with the calibrated
> values with that ibinput_device_config_calibration_set_matrix -
> function.
> 
> > Or do you mean updating the calibration matrix while Weston is already
> > running?
> >
> > Did you write a new program that simply calls
> > libinput_device_config_calibration_set_matrix() and then expect Weston
> > to pick that up when you run it?
> Weston is already running and I'm trying to set a new matrix in use
> for Weston. Is that not what the
> ibinput_device_config_calibration_set_matrix - function is meant for?
> 
> > If so, then libinput just does not work that way. There is no persistent
> > configuration in libinput, and any setting you make is local in the
> > in-memory libinput data structure. The udev rules are the persistent
> > configuration. That's why e.g. calibration_helper option exists in
> > weston.ini, so that you could have your own way of storing the
> > calibration in udev rules.
> This is not the issue. I'm very well aware that there is no persistent
> storage in libinput and I'm not trying to use it as such. I'm trying
> to set a new matrix when Weston is already running.

The issue here is less whether libinput has persistent storage, the issue is
that you do not have access to the libinput context that the compositor uses.
https://wayland.freedesktop.org/libinput/doc/latest/faqs.html#can-i-write-a-program-to-make-libinput-do-foo

The only way around this is to use compositor-provided knobs that *the
compositor* then converts into libinput configuration calls. Like the weston
touch protocol that you have found now.

Cheers,
  Peter

> 
> But I ended up copying the implementation from weston-touch-calibrator
> as you mentioned instead and it worked so this issue is solved.
> 
> Thanks.
> 
> -TeemuK
> 
> > It looks like clients/touch-calibrator.c existed already in Weston
> > 6.0.0. It's a ready-made calibration tool that computes
> > LIBINPUT_CALIBRATION_MATRIX values, and uploads those to Weston. You
> > need weston.ini option touchscreen_calibrator=true to make it work, and
> > the calibration_helper option to save the calibration persistent. These
> > are described in the weston.ini man page, and there is an example
> > script at
> > https://gitlab.freedesktop.org/wayland/weston/-/blob/main/doc/scripts/calibration-helper.bash
> >
> > The option touchscreen_calibrator=true exposes a Wayland extension that
> > allows both getting raw touch coordinates and uploading a new
> > calibration matrix to Weston. This is the only way to update the matrix
> > without restarting Weston.
> >
> >
> > Thanks,
> > pq


More information about the wayland-devel mailing list