From patchwork Tue Apr 24 08:04:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 10358897 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 B17136038F for ; Tue, 24 Apr 2018 08:05:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A380728D1E for ; Tue, 24 Apr 2018 08:05:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97B7028D2F; Tue, 24 Apr 2018 08:05:36 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 2EF3028D1E for ; Tue, 24 Apr 2018 08:05:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756072AbeDXIFe (ORCPT ); Tue, 24 Apr 2018 04:05:34 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49470 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932739AbeDXIEt (ORCPT ); Tue, 24 Apr 2018 04:04:49 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 30A7781A88D8; Tue, 24 Apr 2018 08:04:49 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-117-207.ams2.redhat.com [10.36.117.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id B30DA215CDC8; Tue, 24 Apr 2018 08:04:47 +0000 (UTC) From: Benjamin Tissoires To: Jiri Kosina Cc: Dmitry Torokhov , Peter Hutterer , Mario.Limonciello@dell.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires Subject: [PATCH v2 4/6] HID: multitouch: make use of HID_QUIRK_INPUT_PER_APP Date: Tue, 24 Apr 2018 10:04:35 +0200 Message-Id: <20180424080437.21367-5-benjamin.tissoires@redhat.com> In-Reply-To: <20180424080437.21367-1-benjamin.tissoires@redhat.com> References: <20180424080437.21367-1-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 24 Apr 2018 08:04:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 24 Apr 2018 08:04:49 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'benjamin.tissoires@redhat.com' RCPT:'' 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 We now have HID_QUIRK_INPUT_PER_APPLICATION that splits the devices into several devices. This helps us as we can now rely on hid-input to set the names for us. Also, this helps removing some magical numbers '0' when calling .input_configured(). The only thing to take care of is that the field .report in struct hid_input is now null. We need to iterate over the full list of reports attached to a hid_input. This is required for some Advanced Silicon touchscreen to correctly apply the HID_QUIRK_INPUT_PER_APPLICATION as they have 2 reports associated with the hidinput node. One contains the Input data, the other one contains the Output data. Signed-off-by: Benjamin Tissoires --- drivers/hid/hid-multitouch.c | 72 ++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index dad2fbb0e3f8..43784d31a1a3 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -1274,54 +1274,48 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) struct mt_device *td = hid_get_drvdata(hdev); char *name; const char *suffix = NULL; - struct hid_field *field = hi->report->field[0]; + unsigned int application = 0; + struct hid_report *report; int ret; - if (hi->report->id == td->mt_report_id) { - ret = mt_touch_input_configured(hdev, hi); - if (ret) - return ret; + list_for_each_entry(report, &hi->reports, hidinput_list) { + application = report->application; + if (report->id == td->mt_report_id) { + ret = mt_touch_input_configured(hdev, hi); + if (ret) + return ret; + } + + /* + * some egalax touchscreens have "application == DG_TOUCHSCREEN" + * for the stylus. Check this first, and then rely on + * the application field. + */ + if (report->field[0]->physical == HID_DG_STYLUS) { + suffix = "Pen"; + /* force BTN_STYLUS to allow tablet matching in udev */ + __set_bit(BTN_STYLUS, hi->input->keybit); + } } - /* - * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN" - * for the stylus. Check this first, and then rely on the application - * field. - */ - if (hi->report->field[0]->physical == HID_DG_STYLUS) { - suffix = "Pen"; - /* force BTN_STYLUS to allow tablet matching in udev */ - __set_bit(BTN_STYLUS, hi->input->keybit); - } else { - switch (field->application) { + if (!suffix) { + switch (application) { case HID_GD_KEYBOARD: - suffix = "Keyboard"; - break; case HID_GD_KEYPAD: - suffix = "Keypad"; - break; case HID_GD_MOUSE: - suffix = "Mouse"; - break; - case HID_DG_STYLUS: - suffix = "Pen"; - /* force BTN_STYLUS to allow tablet matching in udev */ - __set_bit(BTN_STYLUS, hi->input->keybit); - break; - case HID_DG_TOUCHSCREEN: - /* we do not set suffix = "Touchscreen" */ - break; case HID_DG_TOUCHPAD: - suffix = "Touchpad"; - break; case HID_GD_SYSTEM_CONTROL: - suffix = "System Control"; - break; case HID_CP_CONSUMER_CONTROL: - suffix = "Consumer Control"; - break; case HID_GD_WIRELESS_RADIO_CTLS: - suffix = "Wireless Radio Control"; + /* already handled by hid core */ + break; + case HID_DG_TOUCHSCREEN: + /* we do not set suffix = "Touchscreen" */ + hi->input->name = hdev->name; + break; + case HID_DG_STYLUS: + /* force BTN_STYLUS to allow tablet matching in udev */ + __set_bit(BTN_STYLUS, hi->input->keybit); break; case HID_VD_ASUS_CUSTOM_MEDIA_KEYS: suffix = "Custom Media Keys"; @@ -1459,10 +1453,10 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id) /* * This allows the driver to handle different input sensors - * that emits events through different reports on the same HID + * that emits events through different applications on the same HID * device. */ - hdev->quirks |= HID_QUIRK_MULTI_INPUT; + hdev->quirks |= HID_QUIRK_INPUT_PER_APP; timer_setup(&td->release_timer, mt_expired_timeout, 0);