Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760665AbbKUNbs (ORCPT ); Sat, 21 Nov 2015 08:31:48 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:50689 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760433AbbKUNbp (ORCPT ); Sat, 21 Nov 2015 08:31:45 -0500 From: Karsten Merker To: Bastien Nocera , Dmitry Torokhov , Irina Tirdea , Aleksei Mamlin , linux-input@vger.kernel.org, Ian Campbell Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chen-Yu Tsai , Karsten Merker Subject: [PATCH V4 1/3] Input: goodix - add axis swapping and axis inversion support Date: Sat, 21 Nov 2015 14:30:20 +0100 Message-Id: <1448112622-2062-2-git-send-email-merker@debian.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1448112622-2062-1-git-send-email-merker@debian.org> References: <1448112622-2062-1-git-send-email-merker@debian.org> X-Provags-ID: V03:K0:7z6i9GVswXXdwU/ps1S3VjK0KoAZKohsQKPnCOqitMfIQBFH7bg uGSlPlMCYoUMU+uiKyNnr2rNPENMIxI1pDXi8dtKVeH8fJ1cz3okEJ8iM7mPvlAIoXsvWwu fhsy3pb7IzI3XYw5DGIVj+qHqYPwc5eYoD8kvFaS4touVZth7SXugz/1fzyEH+RN+dpLvyG Jw+LlkS+5+ul9FkqlJCig== X-UI-Out-Filterresults: notjunk:1;V01:K0:910m0z1JVz0=:K9AzcC2q3+5jXuM8C0oZZt ytR7x8hPLyKtbO6m14xJqFEWs744M3pYtihkCzKFncV8Q2n01bSD8jfjoDJqyejgxBlMlKbkO 5vzfOv/ll+fJwqS+tuUA0Qdbj81RzvfACP+jXyZK4CyQxuFQRgaDGcLtyFDgcSf6bGuoLbx6E 4sQYLxJt1cKSkCk04TDRF1v/qqYduQE/wSibeUmGPcuZwMurzSPvY2JuS67sTqX5uCzMUDdWv XJIrYJbIr15Ov0mjhADjPYP1LlsaGOGk8CiLrIYueA7SW6zT2fQdHlSRLPjxUmS9xkMxzpaWQ JnaVCYUFB1B9SasrsFtSkPhu2DJbsbjSIg7FvhwyvMhteGp27IXPg5Ei3aqHGLG5gYeZ685XD dP50wRlX2xz8TJc14o3OKuPvf1CRBk+rjWQQFoGxFkoZKXX4tzzFkrihavRZcjex/ntzOV9i6 AC/Am1B3A5YDOlx68qbZEi8tk450OKUUylMSAD0H8uqPSzA2BGRGW7XG5lxVWvPVTsyYXlexO 4zeN2j2NLD0Y1tf4oRDcinhvMZ91PQr70tRBNklSPMmMg+0gDz41xpOD+q7+TB4YfMQzP66DS yXU92BMyzjDSb3ZzBb6tyq3I0fTV8jH/IeBk2N6llXtszBkxIPAowISn6RpfKVGEeeNON4uaF Jv9/aFUtByNVnzaTMNA7z2CdohcRO1G75Q0lYMJlMQHz0oY1nc/oW9/yjZyGZgqRiAeI= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3813 Lines: 105 Implement support for the following device-tree and ACPI 5.1 DSD properties in the goodix touchscreen driver: - touchscreen-inverted-x: X axis is inverted (boolean) - touchscreen-inverted-y: Y axis is inverted (boolean) - touchscreen-swapped-x-y: X and Y axis are swapped (boolean) These are necessary on tablets which have a display in portrait format while the touchscreen is in landscape format, such as e.g. the MSI Primo 81. Signed-off-by: Karsten Merker Tested-by: Bastien Nocera Tested-by: Irina Tirdea (with ACPI DSD properties) Tested-by: Aleksei Mamlin (with device-tree properties) --- drivers/input/touchscreen/goodix.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index a793b8c..6985d72 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -2,6 +2,7 @@ * Driver for Goodix Touchscreens * * Copyright (c) 2014 Red Hat Inc. + * Copyright (c) 2015 K. Merker * * This code is based on gt9xx.c authored by andrew@goodix.com: * @@ -53,6 +54,9 @@ struct goodix_ts_data { atomic_t open_count; /* Protects power management calls and access to suspended flag */ struct mutex mutex; + bool swapped_x_y; + bool inverted_x; + bool inverted_y; }; #define GOODIX_GPIO_INT_NAME "irq" @@ -268,6 +272,14 @@ static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data) input_y = ts->abs_y_max - input_y; } + /* Inversions have to happen before axis swapping */ + if (ts->inverted_x) + input_x = ts->abs_x_max - input_x; + if (ts->inverted_y) + input_y = ts->abs_y_max - input_y; + if (ts->swapped_x_y) + swap(input_x, input_y); + input_mt_slot(ts->input_dev, id); input_mt_report_slot_state(ts->input_dev, MT_TOOL_FINGER, true); input_report_abs(ts->input_dev, ABS_MT_POSITION_X, input_x); @@ -673,6 +685,8 @@ static void goodix_read_config(struct goodix_ts_data *ts) error); ts->abs_x_max = GOODIX_MAX_WIDTH; ts->abs_y_max = GOODIX_MAX_HEIGHT; + if (ts->swapped_x_y) + swap(ts->abs_x_max, ts->abs_y_max); ts->int_trigger_type = GOODIX_INT_TRIGGER; ts->max_touch_num = GOODIX_MAX_CONTACTS; return; @@ -680,6 +694,8 @@ static void goodix_read_config(struct goodix_ts_data *ts) ts->abs_x_max = get_unaligned_le16(&config[RESOLUTION_LOC]); ts->abs_y_max = get_unaligned_le16(&config[RESOLUTION_LOC + 2]); + if (ts->swapped_x_y) + swap(ts->abs_x_max, ts->abs_y_max); ts->int_trigger_type = config[TRIGGER_LOC] & 0x03; ts->max_touch_num = config[MAX_CONTACTS_LOC] & 0x0f; if (!ts->abs_x_max || !ts->abs_y_max || !ts->max_touch_num) { @@ -687,6 +703,8 @@ static void goodix_read_config(struct goodix_ts_data *ts) "Invalid config, using defaults\n"); ts->abs_x_max = GOODIX_MAX_WIDTH; ts->abs_y_max = GOODIX_MAX_HEIGHT; + if (ts->swapped_x_y) + swap(ts->abs_x_max, ts->abs_y_max); ts->max_touch_num = GOODIX_MAX_CONTACTS; } @@ -812,6 +830,13 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) { int error; + ts->swapped_x_y = device_property_read_bool(&ts->client->dev, + "touchscreen-swapped-x-y"); + ts->inverted_x = device_property_read_bool(&ts->client->dev, + "touchscreen-inverted-x"); + ts->inverted_y = device_property_read_bool(&ts->client->dev, + "touchscreen-inverted-y"); + goodix_read_config(ts); error = goodix_request_input_dev(ts); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/