From patchwork Thu Jan 14 06:24:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 12018647 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 348C7C433E0 for ; Thu, 14 Jan 2021 06:25:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2738238E7 for ; Thu, 14 Jan 2021 06:25:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726172AbhANGY6 (ORCPT ); Thu, 14 Jan 2021 01:24:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726117AbhANGY6 (ORCPT ); Thu, 14 Jan 2021 01:24:58 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58400C061575; Wed, 13 Jan 2021 22:24:17 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id i7so3084000pgc.8; Wed, 13 Jan 2021 22:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=lcW4JpxXQprA1ci8TUjnK5K087ExJhs0k8B5yG40WMo=; b=PmYzb+mdGfQYIcz+8g9hf0jq3y+JlyxzXFMemzpQieJ6uEQ5htQEG58sA/2lG2EkW1 9mvVqdok+AQWMU7qg0HCiWPsSBRtD92F3dRmDrfwXdSyDnxGum8Vl7sKV+1NgnPzYEGF 1KGWFEYx8V6QEFmyFN61noG8CpC0THhwibGwlGVR7SVDxSSnfGb6IktfcFJT5POJ/pYc IF/ahMcK/YxLoNTVQEwWfLGPSy1dnKZQtVC+Z9nQL6t4CW9RUrBYqHzozHTbVf95rGCe XO/HLNICEMOX7t/o0HngIJgqeWXB/jHixzwiFt28RIUZm7fL0OcVM6nvfub6B49yK6qz zwBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=lcW4JpxXQprA1ci8TUjnK5K087ExJhs0k8B5yG40WMo=; b=q9EINQ7v6MeARWm7cqrGFIfraoYYNcxWNMm4INb34UftrFcsowB+fdXM0KyaXrzlR3 YECVOpMxmQRyVZ0WVmnPt0JpWc/PCysGUiZ7qpdkDVhaJumuEb6t7ToHm95g9eOHCnoY xityEesPv43AFr+1aKzn/3A1ozx4/ytTtiJVYE+Mm8NdP3N2LWsqCOdMuIdxQDZby6vS 7HN5AJe4h7JH+/ym/A+ZC2xq5cSGChrDUhcbaMdu/IDoTOBScvpJgsDXwFIfAND24Abz qzqXlLR6sl+DplPUh6FW/idbzwuSV7lRAVMRnV6r91jRapNbpa9zOjowSYqxDNTjkwb7 Oe0Q== X-Gm-Message-State: AOAM530bhE8636m+rwpCL/rST3sC+Grma4RXvNFFsYJ6Gg0Imn2OINeC A4nRJ4cHY62Rnr+5tx+WfmA= X-Google-Smtp-Source: ABdhPJxQLbET4Ld900+XwfK2j4nkJF52RA4Q3du1NL9nN0EH1WB2KhXsyboQ2Vh6Z7ghuyxBd8zucg== X-Received: by 2002:a63:1261:: with SMTP id 33mr5835343pgs.213.1610605456870; Wed, 13 Jan 2021 22:24:16 -0800 (PST) Received: from google.com ([2620:15c:202:201:a6ae:11ff:fe11:fcc3]) by smtp.gmail.com with ESMTPSA id ck20sm4404098pjb.20.2021.01.13.22.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jan 2021 22:24:15 -0800 (PST) Date: Wed, 13 Jan 2021 22:24:13 -0800 From: Dmitry Torokhov To: Jiri Kosina , Benjamin Tissoires Cc: Peter Hutterer , seobrien@chromium.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: hid-input: avoid splitting keyboard, system and consumer controls Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org A typical USB keyboard usually splits its keys into several reports: - one for the basic alphanumeric keys, modifier keys, F keys, six pack keys and keypad. This report's application is normally listed as GenericDesktop.Keyboard - a GenericDesktop.SystemControl report for the system control keys, such as power and sleep - Consumer.ConsumerControl report for multimedia (forward, rewind, play/pause, mute, etc) and other extended keys. - additional output, vendor specific, and feature reports Splitting each report into a separate input device is wasteful and even hurts userspace as it makes it harder to determine the true capabilities (set of available keys) of a keyboard, so let's adjust application matching to merge system control and consumer control reports with keyboard report, if one has already been processed. Signed-off-by: Dmitry Torokhov Acked-by: Peter Hutterer --- drivers/hid/hid-input.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index f797659cb9d9..df45d8d07dc2 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -1851,6 +1851,16 @@ static struct hid_input *hidinput_match_application(struct hid_report *report) list_for_each_entry(hidinput, &hid->inputs, list) { if (hidinput->application == report->application) return hidinput; + + /* + * Keep SystemControl and ConsumerControl applications together + * with the main keyboard, if present. + */ + if ((report->application == HID_GD_SYSTEM_CONTROL || + report->application == HID_CP_CONSUMER_CONTROL) && + hidinput->application == HID_GD_KEYBOARD) { + return hidinput; + } } return NULL;