Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp35056pxb; Wed, 13 Jan 2021 22:27:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdkpzMWMxpmuXq/5FZ1Dg9tg/wCvP11HnToIvUe2KKXkElCyWmbNKBmCe8IXycT205aN8Q X-Received: by 2002:a05:6402:1102:: with SMTP id u2mr4669845edv.18.1610605638876; Wed, 13 Jan 2021 22:27:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610605638; cv=none; d=google.com; s=arc-20160816; b=YnEI+RXFp038yYNS+TKUYnOPKcG0z5hwS2hn4t4CksxXmIqNsPoVAG6yxJeXyDbhhM WR8cZ8F4erkcxTkU6i/Jb+RPdOBP4WHsDyXlT6jn+I0h5X4x5VTo2AjuLKto+rLyEOeg B+fzqU5SlQ6UL5q5ogbVKWwgbyxEDKZYsP7JWRxLInO3YU3Ki60GNpCYCzJ2OCYRBjTb jtV4qX4sALvw9R+fwbwCNVdR20qUP59pHxHnhsCTP6G4rzbbf+Uza2EJdocMbC+ggOy2 jID/zFq5hcFUUP0WHfuabNRdkDtXR14EvWsSe5q8BLa6WTyno9J9X8PFwVXVW8k+tw8i T0vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=lcW4JpxXQprA1ci8TUjnK5K087ExJhs0k8B5yG40WMo=; b=1CZDKRpFXYWzr8Tk2TE19b5eoOs2hRma7YI7epuSsbDb+JWx2X0ESaceQDRIALHAcj y6YUy1U+FTfqPBRXKvrm7oTIDzb+pTd6nI/QSDpy3NjwC+2v+Ls/s+JOnVyyN/6bCydA AJ6yy6drvgg6wY2P3dFuZ5ypyeZi1igoPcRg4tZAsJkAu4z+wxXEoL/TpEFWi7QaqzI3 qvEHgD/GBQ5sB4jRK04CwkPOvicDYvLjTgKvx7PgDsKbsjRqmu3UMnyBZ5XCPnz8uqqQ XT8uVajM94INodfKFQCMowyTId61LKn+3cuO6qiB+oabU99OJ6GATpEEJanzVzZuu8j6 6jOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PmYzb+md; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r11si1030572edo.565.2021.01.13.22.26.55; Wed, 13 Jan 2021 22:27:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PmYzb+md; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726700AbhANGY7 (ORCPT + 99 others); Thu, 14 Jan 2021 01:24:59 -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-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-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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; -- 2.30.0.284.gd98b1dd5eaa7-goog -- Dmitry