From patchwork Tue Nov 14 12:42:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Niestroj X-Patchwork-Id: 10057509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D5E3A601D3 for ; Tue, 14 Nov 2017 12:42:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3BAB29746 for ; Tue, 14 Nov 2017 12:42:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D888929756; Tue, 14 Nov 2017 12:42:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8247229746 for ; Tue, 14 Nov 2017 12:42:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753476AbdKNMmd (ORCPT ); Tue, 14 Nov 2017 07:42:33 -0500 Received: from smtp.megiteam.pl ([31.186.83.105]:49891 "EHLO smtp.megiteam.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752704AbdKNMmd (ORCPT ); Tue, 14 Nov 2017 07:42:33 -0500 Received: from [95.143.241.142] (helo=localhost.localdomain) by smtp.megiteam.pl with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1eEaXt-0007IE-OV; Tue, 14 Nov 2017 13:42:30 +0100 From: Marcin Niestroj To: Dmitry Torokhov Cc: Bastien Nocera , Antonio Ospite , linux-input@vger.kernel.org, Marcin Niestroj Subject: [PATCH v2 2/3] Input: goodix - fix simultaneous axes inversion and swap Date: Tue, 14 Nov 2017 13:42:16 +0100 Message-Id: <20171114124217.2863-3-m.niestroj@grinn-global.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171114124217.2863-1-m.niestroj@grinn-global.com> References: <20171114124217.2863-1-m.niestroj@grinn-global.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP goodix_ts_data structure contains abs_x_max and abs_y_max members, which contain already swapped maximum ranges. That causes reporting touch events with invalid position (out of range values). Take into account that abs_x_max and abs_y_max are already swapped in goodix_ts_report_touch(), so position for inverted axes will be calculated correctly. Signed-off-by: Marcin Niestroj Fixes: ad48cf5e9597 ("Input: goodix - add axis swapping and axis inversion support") --- Changes v1 -> v2: patch splitted off from patch 3 (suggested by Bastien) drivers/input/touchscreen/goodix.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index 7896097ca69b..dc832890f6d3 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -296,12 +296,18 @@ static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data) int input_w = get_unaligned_le16(&coor_data[5]); /* 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) + if (!ts->swapped_x_y) { + if (ts->inverted_x) + input_x = ts->abs_x_max - input_x; + if (ts->inverted_y) + input_y = ts->abs_y_max - input_y; + } else { + if (ts->inverted_x) + input_x = ts->abs_y_max - input_x; + if (ts->inverted_y) + input_y = ts->abs_x_max - input_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);