From patchwork Tue Jan 29 04:23:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NOGUCHI Hiroshi X-Patchwork-Id: 10785371 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61CF2139A for ; Tue, 29 Jan 2019 04:24:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45CFB2ABC7 for ; Tue, 29 Jan 2019 04:24:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39C212AC00; Tue, 29 Jan 2019 04:24:56 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 1A8462ABC7 for ; Tue, 29 Jan 2019 04:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726843AbfA2EYy (ORCPT ); Mon, 28 Jan 2019 23:24:54 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:35302 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbfA2EYy (ORCPT ); Mon, 28 Jan 2019 23:24:54 -0500 Received: by mail-pf1-f194.google.com with SMTP id z9so9070057pfi.2 for ; Mon, 28 Jan 2019 20:24:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ORFLQywu5qdfKsoBgiSFegnZKNHLiiri0ZqZHGy5cXk=; b=N21o6jsrWNWz0eorZUCfTsk7E2arHl3uaxZlQZNb9Hrix4drVNhdQJFd3hTnCmMkMA 9I2LHCey8mm4XSla5KpulLl1+A96DrqYhb0qwZ0sRtLXi4cPsANU3nQAHl4NZltGOXSi gLab6W7DxiJGBuX/HV6UDz5VFVs94YAa1v8CDFxC9yaavhovFOwEUUhSqTdX2IwtgSxj +prNN1CNqTfw33BntsuVBu8CiF2xiUJNCM/klLNIHqakNuL2oO9PByO/TYfaUVL3HHua OnAzpXJcZ4r4zvY18r+newh83EhlKFXI4h4WB/+VTf0VDPom0Om9A0p5h/BMSVQN4jMc fFbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ORFLQywu5qdfKsoBgiSFegnZKNHLiiri0ZqZHGy5cXk=; b=qcaE8gM7bLnoNvQDdBXX9DDUMEutL8IhKfML7jRzM4aC1tKuW7YBbhTL21TaGQoXZq pYgq1mK0XzslpakVGYCMTF8eoAdOryW7YdOqFb0DhazcWqGoiQRizR1rwQy/N7RZsl+i 0mmBrCmYOhWyk5K5dlZVm1AAtbHoD1weDPQRUr1Bv3jFycjTYIbODYxcsSIJZByv4b7t xwCupC2Yv2QvMfNNcLLPt78OJEi6tERDiqVmK88I+J3d1Axj6vBMWdNGyJrQo5rswz6p P9TFMpsFBVkSGohUu4Grw0YMjBnI4qltX+eAtaqyUiRAz7cQhhyK5fbbgQNlnLambptk zxbw== X-Gm-Message-State: AJcUukdyACH5Uyh3BGrrCmUcQMBZtYFCAZsbbNmaabYnMVAbEzSYU8sD cZPJoaUwybMYg6xrAQnIcknZVRlF X-Google-Smtp-Source: ALg8bN4BCpDiMdOczPQDka0hfHgnWwz/r8+pttCRyhxV5C81tRRK8pUYr/MQ4Oc2Iuu7aZJn92x12A== X-Received: by 2002:a62:b80a:: with SMTP id p10mr24480082pfe.32.1548735892943; Mon, 28 Jan 2019 20:24:52 -0800 (PST) Received: from localhost.localdomain (32.236.69.115.shared.user.transix.jp. [115.69.236.32]) by smtp.gmail.com with ESMTPSA id r130sm52192650pfr.48.2019.01.28.20.24.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Jan 2019 20:24:52 -0800 (PST) From: NOGUCHI Hiroshi To: Jiri Kosina Cc: Benjamin Tissoires , linux-input@vger.kernel.org, NOGUCHI Hiroshi Subject: [PATCH 1/3] HID: hid-asus Transbook T90CHI support Date: Tue, 29 Jan 2019 13:23:20 +0900 Message-Id: <20190129042322.13168-1-drvlabo@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 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 add Transbook T90CHI support into hid-asus. T90CHI returns same BT vendor/product values as T100CHI, so identifies T90CHI by name. Signed-off-by: NOGUCHI Hiroshi --- drivers/hid/hid-asus.c | 54 +++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index 951bb17ae8b2..c7b4638cdeb1 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -71,6 +71,7 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad"); #define QUIRK_T100CHI BIT(7) #define QUIRK_G752_KEYBOARD BIT(8) #define QUIRK_T101HA_DOCK BIT(9) +#define QUIRK_T90CHI BIT(10) #define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \ QUIRK_NO_INIT_REPORTS | \ @@ -500,7 +501,7 @@ static int asus_input_mapping(struct hid_device *hdev, * This avoids a bunch of non-functional hid_input devices getting * created because of the T100CHI using HID_QUIRK_MULTI_INPUT. */ - if (drvdata->quirks & QUIRK_T100CHI) { + if (drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) { if (field->application == (HID_UP_GENDESK | 0x0080) || usage->hid == (HID_UP_GENDEVCTRLS | 0x0024) || usage->hid == (HID_UP_GENDEVCTRLS | 0x0025) || @@ -660,6 +661,11 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id) drvdata->quirks = id->driver_data; + if (strstr(hdev->name, "T90CHI")) { + drvdata->quirks &= ~QUIRK_T100CHI; + drvdata->quirks |= QUIRK_T90CHI; + } + if (drvdata->quirks & QUIRK_IS_MULTITOUCH) drvdata->tp = &asus_i2c_tp; @@ -769,28 +775,44 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc, hid_info(hdev, "Fixing up Asus T100 keyb report descriptor\n"); rdesc[74] &= ~HID_MAIN_ITEM_CONSTANT; } - /* For the T100CHI keyboard dock */ - if (drvdata->quirks & QUIRK_T100CHI && - *rsize == 403 && rdesc[388] == 0x09 && rdesc[389] == 0x76) { + /* For the T100CHI/T90CHI keyboard dock */ + if (drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) { + int rsize_orig; + int offs; + + if (drvdata->quirks & QUIRK_T100CHI) { + rsize_orig = 403; + offs = 388; + } else { + rsize_orig = 306; + offs = 291; + } + /* * Change Usage (76h) to Usage Minimum (00h), Usage Maximum * (FFh) and clear the flags in the Input() byte. * Note the descriptor has a bogus 0 byte at the end so we * only need 1 extra byte. */ - *rsize = 404; - rdesc = kmemdup(rdesc, *rsize, GFP_KERNEL); - if (!rdesc) - return NULL; - - hid_info(hdev, "Fixing up T100CHI keyb report descriptor\n"); - memmove(rdesc + 392, rdesc + 390, 12); - rdesc[388] = 0x19; - rdesc[389] = 0x00; - rdesc[390] = 0x29; - rdesc[391] = 0xff; - rdesc[402] = 0x00; + if (*rsize == rsize_orig && + rdesc[offs] == 0x09 && rdesc[offs + 1] == 0x76) { + *rsize = rsize_orig + 1; + rdesc = kmemdup(rdesc, *rsize, GFP_KERNEL); + if (!rdesc) + return NULL; + + hid_info(hdev, "Fixing up %s keyb report descriptor\n", + drvdata->quirks & QUIRK_T100CHI ? + "T100CHI" : "T90CHI"); + memmove(rdesc + offs + 4, rdesc + offs + 2, 12); + rdesc[offs] = 0x19; + rdesc[offs + 1] = 0x00; + rdesc[offs + 2] = 0x29; + rdesc[offs + 3] = 0xff; + rdesc[offs + 14] = 0x00; + } } + if (drvdata->quirks & QUIRK_G752_KEYBOARD && *rsize == 75 && rdesc[61] == 0x15 && rdesc[62] == 0x00) { /* report is missing usage mninum and maximum */