[PATCH weston v2 02/12] libinput: move calibration printing into do_set_calibration()

Pekka Paalanen ppaalanen at gmail.com
Mon Apr 30 13:03:24 UTC 2018


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Move calibration printing here and call do_set_calibration() from
evdev_device_set_calibration() so that all matrix setting paths print
the same way.

Print the matrix values in a matrix style to help readability, and
mention the input device.

v2:
- use 'cal' instead of 'calb' as variable name

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
v1 Tested-by: Matt Hoosier <matt.hoosier at gmail.com>
---
 libweston/libinput-device.c | 51 +++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 27 deletions(-)

diff --git a/libweston/libinput-device.c b/libweston/libinput-device.c
index 63f50319..1fc01335 100644
--- a/libweston/libinput-device.c
+++ b/libweston/libinput-device.c
@@ -346,10 +346,17 @@ do_set_calibration(struct evdev_device *evdev_device,
 {
 	enum libinput_config_status status;
 
+	weston_log("input device %s: applying calibration:\n",
+		   libinput_device_get_sysname(evdev_device->device));
+	weston_log_continue(STAMP_SPACE "  %f %f %f\n",
+			    cal->m[0], cal->m[1], cal->m[2]);
+	weston_log_continue(STAMP_SPACE "  %f %f %f\n",
+			    cal->m[3], cal->m[4], cal->m[5]);
+
 	status = libinput_device_config_calibration_set_matrix(evdev_device->device,
 							       cal->m);
 	if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
-		weston_log("Failed to apply calibration.\n");
+		weston_log("Error: Failed to apply calibration.\n");
 }
 
 static void
@@ -559,8 +566,7 @@ evdev_device_set_calibration(struct evdev_device *device)
 	const char *sysname = libinput_device_get_sysname(device->device);
 	const char *calibration_values;
 	uint32_t width, height;
-	float calibration[6];
-	enum libinput_config_status status;
+	struct weston_touch_device_matrix calibration;
 
 	if (!libinput_device_config_calibration_has_matrix(device->device))
 		return;
@@ -570,7 +576,7 @@ evdev_device_set_calibration(struct evdev_device *device)
 	 * output to load a calibration. */
 	if (libinput_device_config_calibration_get_default_matrix(
 							  device->device,
-							  calibration) != 0)
+							  calibration.m) != 0)
 		return;
 
 	/* touch_set_calibration() has updated the values, do not load old
@@ -614,35 +620,26 @@ evdev_device_set_calibration(struct evdev_device *device)
 
 	if (!calibration_values || sscanf(calibration_values,
 					  "%f %f %f %f %f %f",
-					  &calibration[0],
-					  &calibration[1],
-					  &calibration[2],
-					  &calibration[3],
-					  &calibration[4],
-					  &calibration[5]) != 6)
+					  &calibration.m[0],
+					  &calibration.m[1],
+					  &calibration.m[2],
+					  &calibration.m[3],
+					  &calibration.m[4],
+					  &calibration.m[5]) != 6)
 		goto out;
 
-	weston_log("Applying calibration: %f %f %f %f %f %f "
-		   "(normalized %f %f)\n",
-		    calibration[0],
-		    calibration[1],
-		    calibration[2],
-		    calibration[3],
-		    calibration[4],
-		    calibration[5],
-		    calibration[2] / width,
-		    calibration[5] / height);
-
 	/* normalize to a format libinput can use. There is a chance of
 	   this being wrong if the width/height don't match the device
 	   width/height but I'm not sure how to fix that */
-	calibration[2] /= width;
-	calibration[5] /= height;
+	calibration.m[2] /= width;
+	calibration.m[5] /= height;
 
-	status = libinput_device_config_calibration_set_matrix(device->device,
-							       calibration);
-	if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
-		weston_log("Failed to apply calibration.\n");
+	do_set_calibration(device, &calibration);
+
+	weston_log_continue(STAMP_SPACE "  raw translation %f %f for output %s\n",
+		   calibration.m[2] * width,
+		   calibration.m[5] * height,
+		   device->output->name);
 
 out:
 	if (udev_device)
-- 
2.16.1



More information about the wayland-devel mailing list