From patchwork Sun Apr 21 15:44:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637379 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 680E9199B4 for ; Sun, 21 Apr 2024 15:45:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714336; cv=none; b=OiWcTjCQq+vvuX0b2fAhSF8Aw4e/lXIV6l2ECH+hpNv5+e9dczwaY/XBRjpO9S2escPCK+FOxW5Wi3plUbAGjglC+GmyFUOpkGjq8eH4whFgaCI0+D06FGBEuFDAGJ2GsHLqvfdnVNJGgWDYK9GZ6Acs3d4EHwvEBTo6/wFEprw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714336; c=relaxed/simple; bh=qNOJKbc7cCGDmwTuhfuZEUQsSkSMa+lJhr5eWUU23UM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eRYn9RAIkSf0GYaStVNRTF5uxXnnfEM5KrUfgiZ4sY78E6iMqVGLLc2BUaagwE0gHTK165AcWm0xDvqMPDIhbMHUWAd2daSzP3mstnKtquIVIsrtUrmq6cA++amEvvMf9RfZs2KPUxMioMB7ItTAblHb+IzMKP8pW6RhDljPlV4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=R6K6cpF4; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="R6K6cpF4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eRJS14jEMEAweraoFLSRpvMpzEv8JeJAQvdnoLpFW1s=; b=R6K6cpF4F8e4cXQv2zXwsxYMdn4h603NEZTm7x5uBUQuNfQ7IQPyrRWHkjopb59rTLaST3 avMk9CQkvZz0rv5/uFqYK07budzMWi3F15/PsSOLgSqw477hDYxj4KLQ48ASKymzXxKPOE 2AqmTcUY/NogLCQ5uflHVMQpHjyYV6g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-515-wZAaQ7gWOX2PKFlUyAavVw-1; Sun, 21 Apr 2024 11:45:29 -0400 X-MC-Unique: wZAaQ7gWOX2PKFlUyAavVw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 90D1389A245; Sun, 21 Apr 2024 15:45:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7632740357A7; Sun, 21 Apr 2024 15:45:27 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 01/24] platform/x86: thinkpad_acpi: Take hotkey_mutex during hotkey_exit() Date: Sun, 21 Apr 2024 17:44:57 +0200 Message-ID: <20240421154520.37089-2-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 hotkey_exit() already takes the mutex around the hotkey_poll_stop_sync() call, but not around the other calls. commit 38831eaf7d4c ("platform/x86: thinkpad_acpi: use lockdep annotations") has added lockdep_assert_held() checks to various hotkey functions. These lockdep_assert_held() checks fail causing WARN() backtraces in dmesg due to missing locking in hotkey_exit(), fix this. Fixes: 38831eaf7d4c ("platform/x86: thinkpad_acpi: use lockdep annotations") Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 771aaa7ae4cf..ba4df8f68c2a 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3044,10 +3044,9 @@ static void tpacpi_send_radiosw_update(void) static void hotkey_exit(void) { -#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL mutex_lock(&hotkey_mutex); +#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL hotkey_poll_stop_sync(); - mutex_unlock(&hotkey_mutex); #endif dbg_printk(TPACPI_DBG_EXIT | TPACPI_DBG_HKEY, "restoring original HKEY status and mask\n"); @@ -3057,6 +3056,8 @@ static void hotkey_exit(void) hotkey_mask_set(hotkey_orig_mask)) | hotkey_status_set(false)) != 0) pr_err("failed to restore hot key mask to BIOS defaults\n"); + + mutex_unlock(&hotkey_mutex); } static void __init hotkey_unmap(const unsigned int scancode) From patchwork Sun Apr 21 15:44:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637377 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E10DB199B9 for ; Sun, 21 Apr 2024 15:45:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714334; cv=none; b=Ny9I9RE1upQk397qG8AJkQBc/VVBqkoxdAGh3gdnw2t9gMqvzxtRPH669swB/6XJXOsVa1F4EmGth9g83k1mfB83GpKUhstfW+HiIznq/x0tCLCEYcEdK+J32Kyg5q7fZfyG7scOVK28EY2bHIh28/YgVRVj5tG1gcBMHMS8Uco= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714334; c=relaxed/simple; bh=mJpJndZ7d3srPJo88KLoRi1BUjgD1MJIP3y9scC85o0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s6Y8MkuVsmkOZYTBlm1Efz85wEsBQqWVJhv//KUVRPxRcWzu8jvMU8KkHFh5INQViOwMS2Ktt5XYgjjdiIPP49AOKl59GTy2/Ph9kIHo2NcUbl3AlRXaG9v4hQ1133Ob7ilcRyli7n4En6sddWlL69U0Wx3qLiaNi+hdTFXoO3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OTZZlzLS; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OTZZlzLS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714331; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y0qVnVFKBsiWn5Z0p4LeyRwTEWmnuB5byJIXi0jc0Ds=; b=OTZZlzLSIe4aJ0utGCEfMidaOiCZwdWn9S0O/aE0owX7K/PqUCQenFYTJ0Jg7pkC6zKrPa CeOm19x6TjOq8MJYSQhQfkGRncSPqKHam+ZGRI5S5mrKpIfbPPLttSEkzBd4RSpKsUk8+2 3TK6oSrZDO0AIDyStgy/yRNkxcJV0SI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-1PIY9vrMNl6LJfm_H9e29w-1; Sun, 21 Apr 2024 11:45:30 -0400 X-MC-Unique: 1PIY9vrMNl6LJfm_H9e29w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D94153C00098; Sun, 21 Apr 2024 15:45:29 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id BEDBC402482D; Sun, 21 Apr 2024 15:45:28 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 02/24] platform/x86: thinkpad_acpi: Provide hotkey_poll_stop_sync() dummy Date: Sun, 21 Apr 2024 17:44:58 +0200 Message-ID: <20240421154520.37089-3-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Provide a hotkey_poll_stop_sync() dummy implementation when CONFIG_THINKPAD_ACPI_HOTKEY_POLL, so that the #ifdef-ery around hotkey_poll_stop_sync() can be removed from hotkey_exit(). Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index ba4df8f68c2a..fc5681808c3b 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -2575,6 +2575,9 @@ static void hotkey_poll_setup_safe(const bool __unused) { } +static void hotkey_poll_stop_sync(void) +{ +} #endif /* CONFIG_THINKPAD_ACPI_HOTKEY_POLL */ static int hotkey_inputdev_open(struct input_dev *dev) @@ -3045,9 +3048,7 @@ static void tpacpi_send_radiosw_update(void) static void hotkey_exit(void) { mutex_lock(&hotkey_mutex); -#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL hotkey_poll_stop_sync(); -#endif dbg_printk(TPACPI_DBG_EXIT | TPACPI_DBG_HKEY, "restoring original HKEY status and mask\n"); /* yes, there is a bitwise or below, we want the From patchwork Sun Apr 21 15:44:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637384 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4583C17BA2 for ; Sun, 21 Apr 2024 15:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714344; cv=none; b=hWujksxIJNZ8WI5wCQFvqrgWDuizZ19c0dMyC05R/4DJs9/KGChyukweLsK3N/Etj0v1nc2tq4kdfm7+7SYrCzGH9p4P4Z+aggEaUZgyVhoNiXg+6Oea117C6bnIBo2h5Mag4XSW54hyD6kQzI33AiI2FDYskBz/OzkNr1dKzyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714344; c=relaxed/simple; bh=8c4dQWJTMNm8tij1yVZNP3a3xbcM+4p2UVOulti9tKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qs4xA1EXOaXqFHT58DjRoKWXRFJyn3p+ofPMR9dCllnU5QmDFQ2KCNid/3neiGuQE+xR4VFK9sMgCnlM3gdzfoMiPHjS4Ecj30qqE269BD/w9SdfvDx/16udGbPqRncNOCG7FTMWvjuDr6YwZHBEZISloK/Qtu3ZgY3wdqN7rBc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=i6Yyu72p; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i6Yyu72p" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OsjauILosSwsdrban+b3pKebhm2tdkEwIbD6csXmSwY=; b=i6Yyu72paswUC7HqJowds6j4Xsk9Gkz+KbgOrvG+imB65z+etF9EEDTzusdOi4XVFuFYMt Mk+Qex8+kPqgjc4RNFHfDammG08m1QAeK4f9l56+6o/N1yUFMqYelPAdkPSrcdeZIGmNuZ LYOEpD+SYix4RNMKNC2GrjtGpd5hAV8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-96-_lPldDwnN8-4IWetk47L4Q-1; Sun, 21 Apr 2024 11:45:32 -0400 X-MC-Unique: _lPldDwnN8-4IWetk47L4Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2CCE789A245; Sun, 21 Apr 2024 15:45:31 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12BF040357A7; Sun, 21 Apr 2024 15:45:29 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 03/24] platform/x86: thinkpad_acpi: Drop setting send_/ignore_acpi_ev defaults twice Date: Sun, 21 Apr 2024 17:44:59 +0200 Message-ID: <20240421154520.37089-4-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 send_acpi_ev, ignore_acpi_ev are already initialized to true resp. false by hotkey_notify() before calling the various helpers. Drop the needless re-initialization from the helpers. Signed-off-by: Hans de Goede Reviewed-by: Ilpo Järvinen --- drivers/platform/x86/thinkpad_acpi.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index fc5681808c3b..007223fded30 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3754,14 +3754,12 @@ static bool hotkey_notify_extended_hotkey(const u32 hkey) return false; } +/* 0x1000-0x1FFF: key presses */ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev, bool *ignore_acpi_ev) { - /* 0x1000-0x1FFF: key presses */ unsigned int scancode = hkey & 0xfff; - *send_acpi_ev = true; - *ignore_acpi_ev = false; /* * Original events are in the 0x10XX range, the adaptive keyboard @@ -3794,14 +3792,11 @@ static bool hotkey_notify_hotkey(const u32 hkey, return false; } +/* 0x2000-0x2FFF: Wakeup reason */ static bool hotkey_notify_wakeup(const u32 hkey, bool *send_acpi_ev, bool *ignore_acpi_ev) { - /* 0x2000-0x2FFF: Wakeup reason */ - *send_acpi_ev = true; - *ignore_acpi_ev = false; - switch (hkey) { case TP_HKEY_EV_WKUP_S3_UNDOCK: /* suspend, undock */ case TP_HKEY_EV_WKUP_S4_UNDOCK: /* hibernation, undock */ @@ -3834,14 +3829,11 @@ static bool hotkey_notify_wakeup(const u32 hkey, return true; } +/* 0x4000-0x4FFF: dock-related events */ static bool hotkey_notify_dockevent(const u32 hkey, bool *send_acpi_ev, bool *ignore_acpi_ev) { - /* 0x4000-0x4FFF: dock-related events */ - *send_acpi_ev = true; - *ignore_acpi_ev = false; - switch (hkey) { case TP_HKEY_EV_UNDOCK_ACK: /* ACPI undock operation completed after wakeup */ @@ -3879,14 +3871,11 @@ static bool hotkey_notify_dockevent(const u32 hkey, } } +/* 0x5000-0x5FFF: human interface helpers */ static bool hotkey_notify_usrevent(const u32 hkey, bool *send_acpi_ev, bool *ignore_acpi_ev) { - /* 0x5000-0x5FFF: human interface helpers */ - *send_acpi_ev = true; - *ignore_acpi_ev = false; - switch (hkey) { case TP_HKEY_EV_PEN_INSERTED: /* X61t: tablet pen inserted into bay */ case TP_HKEY_EV_PEN_REMOVED: /* X61t: tablet pen removed from bay */ @@ -3914,14 +3903,11 @@ static bool hotkey_notify_usrevent(const u32 hkey, static void thermal_dump_all_sensors(void); static void palmsensor_refresh(void); +/* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */ static bool hotkey_notify_6xxx(const u32 hkey, bool *send_acpi_ev, bool *ignore_acpi_ev) { - /* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */ - *send_acpi_ev = true; - *ignore_acpi_ev = false; - switch (hkey) { case TP_HKEY_EV_THM_TABLE_CHANGED: pr_debug("EC reports: Thermal Table has changed\n"); From patchwork Sun Apr 21 15:45:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637380 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 22D3917BA2 for ; Sun, 21 Apr 2024 15:45:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714340; cv=none; b=i1qc3i4pvNHg6K0w79FPsKzdwv7bRqRT4KXxR5DywJLJbMFkJuwPCNO8J2xTwwEAc4ypA2D3381XR8AUiIakPCyxBA8Dip4J06yzYITSH8J8Fc5Vh9SptmFzDe2CsSgsi6qBTZcoKbD5igNR4IvpSBM/Vv2585BOHPDA+xz3Xj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714340; c=relaxed/simple; bh=1Tn5sh1ZJJRmS1HwlGfr2a7zeR6zKF+kqoxAHqgw+DM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RFEwH4zQLfgAU8Sn2EcHiEqIn3WZC4hQ4B6Z79SaUx52SwLndvu3NgtqtgpNiWc8SmExWQetClc7ISD2dbxXDemhD2eZG9DyIz6+MGH3FfglKSOL6VJK2XDs95famOGN9o22QRACloA8jgzfjfUZrvogkxt8gsGD5UocgGIFKjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Pe3NCHJJ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Pe3NCHJJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jjRWtrTCZPjO/R9YCvR5OjpGKpxB8NsBR5wh8az0r/A=; b=Pe3NCHJJluQlV3LIxwqrbTB27eZtK2+9uR6XB5W9GRi9WjpN1J/gWW6iR+sS2Gl1viQQOl M3SGHIEBJcQU6zt2qoLBLHkueWXvwebh4nw6EkygITZmbuNhV4vE3SUnoaOzbNkPTFcFY1 fJoY2av+DCg/vlhfUFqnttfxGDY5QhM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-223-PInweQSbMRaqrTV1Ztzfow-1; Sun, 21 Apr 2024 11:45:33 -0400 X-MC-Unique: PInweQSbMRaqrTV1Ztzfow-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7577A29AA3B7; Sun, 21 Apr 2024 15:45:32 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AF7F402482D; Sun, 21 Apr 2024 15:45:31 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 04/24] platform/x86: thinkpad_acpi: Drop ignore_acpi_ev Date: Sun, 21 Apr 2024 17:45:00 +0200 Message-ID: <20240421154520.37089-5-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Setting ignore_acpi_ev to true has the same result as setting send_acpi_ev to false, so there is no need to have both. Drop ignore_acpi_ev. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 56 +++++++++------------------- 1 file changed, 17 insertions(+), 39 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 007223fded30..bb6b880a5b50 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3755,9 +3755,7 @@ static bool hotkey_notify_extended_hotkey(const u32 hkey) } /* 0x1000-0x1FFF: key presses */ -static bool hotkey_notify_hotkey(const u32 hkey, - bool *send_acpi_ev, - bool *ignore_acpi_ev) +static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) { unsigned int scancode = hkey & 0xfff; @@ -3772,12 +3770,10 @@ static bool hotkey_notify_hotkey(const u32 hkey, scancode <= TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) { /* HKEY event 0x1001 is scancode 0x00 */ scancode--; - if (!(hotkey_source_mask & (1 << scancode))) { + if (!(hotkey_source_mask & (1 << scancode))) tpacpi_input_send_key_masked(scancode); - *send_acpi_ev = false; - } else { - *ignore_acpi_ev = true; - } + + *send_acpi_ev = false; return true; } break; @@ -3793,21 +3789,19 @@ static bool hotkey_notify_hotkey(const u32 hkey, } /* 0x2000-0x2FFF: Wakeup reason */ -static bool hotkey_notify_wakeup(const u32 hkey, - bool *send_acpi_ev, - bool *ignore_acpi_ev) +static bool hotkey_notify_wakeup(const u32 hkey, bool *send_acpi_ev) { switch (hkey) { case TP_HKEY_EV_WKUP_S3_UNDOCK: /* suspend, undock */ case TP_HKEY_EV_WKUP_S4_UNDOCK: /* hibernation, undock */ hotkey_wakeup_reason = TP_ACPI_WAKEUP_UNDOCK; - *ignore_acpi_ev = true; + *send_acpi_ev = false; break; case TP_HKEY_EV_WKUP_S3_BAYEJ: /* suspend, bay eject */ case TP_HKEY_EV_WKUP_S4_BAYEJ: /* hibernation, bay eject */ hotkey_wakeup_reason = TP_ACPI_WAKEUP_BAYEJ; - *ignore_acpi_ev = true; + *send_acpi_ev = false; break; case TP_HKEY_EV_WKUP_S3_BATLOW: /* Battery on critical low level/S3 */ @@ -3830,9 +3824,7 @@ static bool hotkey_notify_wakeup(const u32 hkey, } /* 0x4000-0x4FFF: dock-related events */ -static bool hotkey_notify_dockevent(const u32 hkey, - bool *send_acpi_ev, - bool *ignore_acpi_ev) +static bool hotkey_notify_dockevent(const u32 hkey, bool *send_acpi_ev) { switch (hkey) { case TP_HKEY_EV_UNDOCK_ACK: @@ -3863,7 +3855,6 @@ static bool hotkey_notify_dockevent(const u32 hkey, case TP_HKEY_EV_KBD_COVER_ATTACH: case TP_HKEY_EV_KBD_COVER_DETACH: *send_acpi_ev = false; - *ignore_acpi_ev = true; return true; default: @@ -3872,9 +3863,7 @@ static bool hotkey_notify_dockevent(const u32 hkey, } /* 0x5000-0x5FFF: human interface helpers */ -static bool hotkey_notify_usrevent(const u32 hkey, - bool *send_acpi_ev, - bool *ignore_acpi_ev) +static bool hotkey_notify_usrevent(const u32 hkey, bool *send_acpi_ev) { switch (hkey) { case TP_HKEY_EV_PEN_INSERTED: /* X61t: tablet pen inserted into bay */ @@ -3892,7 +3881,7 @@ static bool hotkey_notify_usrevent(const u32 hkey, case TP_HKEY_EV_LID_OPEN: /* Lid opened */ case TP_HKEY_EV_BRGHT_CHANGED: /* brightness changed */ /* do not propagate these events */ - *ignore_acpi_ev = true; + *send_acpi_ev = false; return true; default: @@ -3904,9 +3893,7 @@ static void thermal_dump_all_sensors(void); static void palmsensor_refresh(void); /* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */ -static bool hotkey_notify_6xxx(const u32 hkey, - bool *send_acpi_ev, - bool *ignore_acpi_ev) +static bool hotkey_notify_6xxx(const u32 hkey, bool *send_acpi_ev) { switch (hkey) { case TP_HKEY_EV_THM_TABLE_CHANGED: @@ -3953,14 +3940,12 @@ static bool hotkey_notify_6xxx(const u32 hkey, /* key press events, we just ignore them as long as the EC * is still reporting them in the normal keyboard stream */ *send_acpi_ev = false; - *ignore_acpi_ev = true; return true; case TP_HKEY_EV_KEY_FN_ESC: /* Get the media key status to force the status LED to update */ acpi_evalf(hkey_handle, NULL, "GMKS", "v"); *send_acpi_ev = false; - *ignore_acpi_ev = true; return true; case TP_HKEY_EV_TABLET_CHANGED: @@ -3988,7 +3973,6 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) { u32 hkey; bool send_acpi_ev; - bool ignore_acpi_ev; bool known_ev; if (event != 0x80) { @@ -4013,18 +3997,15 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) } send_acpi_ev = true; - ignore_acpi_ev = false; switch (hkey >> 12) { case 1: /* 0x1000-0x1FFF: key presses */ - known_ev = hotkey_notify_hotkey(hkey, &send_acpi_ev, - &ignore_acpi_ev); + known_ev = hotkey_notify_hotkey(hkey, &send_acpi_ev); break; case 2: /* 0x2000-0x2FFF: Wakeup reason */ - known_ev = hotkey_notify_wakeup(hkey, &send_acpi_ev, - &ignore_acpi_ev); + known_ev = hotkey_notify_wakeup(hkey, &send_acpi_ev); break; case 3: /* 0x3000-0x3FFF: bay-related wakeups */ @@ -4045,19 +4026,16 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) break; case 4: /* 0x4000-0x4FFF: dock-related events */ - known_ev = hotkey_notify_dockevent(hkey, &send_acpi_ev, - &ignore_acpi_ev); + known_ev = hotkey_notify_dockevent(hkey, &send_acpi_ev); break; case 5: /* 0x5000-0x5FFF: human interface helpers */ - known_ev = hotkey_notify_usrevent(hkey, &send_acpi_ev, - &ignore_acpi_ev); + known_ev = hotkey_notify_usrevent(hkey, &send_acpi_ev); break; case 6: /* 0x6000-0x6FFF: thermal alarms/notices and * keyboard events */ - known_ev = hotkey_notify_6xxx(hkey, &send_acpi_ev, - &ignore_acpi_ev); + known_ev = hotkey_notify_6xxx(hkey, &send_acpi_ev); break; case 7: /* 0x7000-0x7FFF: misc */ @@ -4079,7 +4057,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) } /* netlink events */ - if (!ignore_acpi_ev && send_acpi_ev) { + if (send_acpi_ev) { acpi_bus_generate_netlink_event( ibm->acpi->device->pnp.device_class, dev_name(&ibm->acpi->device->dev), From patchwork Sun Apr 21 15:45:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637381 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C82EF18E1A for ; Sun, 21 Apr 2024 15:45:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714341; cv=none; b=r+kOy5Z3RP0cfTsZXB/4vegblIDzdIdpvP6uATLh687hPonyVNuCUS4Rjz28EvqYnxvhn9jlqQ10C/uaZ9bd4RNoPou6PVDx5BG/XRUsKmm/Y2+Jck9N0BK5HeOz6Fjds2xuaEvcC24Q6Xt7n7sbsE5vv8hD9hi4WziVsv25blQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714341; c=relaxed/simple; bh=TkFpx/E+SLpE00CJjAfW/uSe9U45Jf/HZ8EPUMyCABY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RmP9DIKGr0RxoCNi/xZeyEQJk3mWmowK+qbLPRUDCJlklJZu1hOAgMDExnDmrFtaLvZ2j5OgGOcKAbA94kd7t2C24+t1ptyQ7qDmA1eAt9f9l5Ab2Q1Bjmak3+1TUMnZltfUFFSqum4M4UFFl1dhl4cQx+xXro41+ZU5UKgBCpU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EWf7zO3t; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EWf7zO3t" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714338; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u89WmVZu4h1RAqubz6Eju1GLAK55/YNjt0KJ98OXdqI=; b=EWf7zO3tpPdZrX5Ix5L0X9jL+REevZx5J0b0yaKY5zOzzLgYgf4Gf5YwsB6UOBE5o4Ec4b g6/xCINCorEYk7zNxpakylo9kql34Sef3Bb6PlhgC7WlsaWPjraL15wIzHmvSUd2HJcL9A YwYI7+8NDyhjoxMOs19MsMHTcAu7tj0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-176-F_Vq_frZPK6AORc1TLUhNA-1; Sun, 21 Apr 2024 11:45:34 -0400 X-MC-Unique: F_Vq_frZPK6AORc1TLUhNA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BEFCE802E4D; Sun, 21 Apr 2024 15:45:33 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id A340840357A7; Sun, 21 Apr 2024 15:45:32 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 05/24] platform/x86: thinkpad_acpi: Use tpacpi_input_send_key() in adaptive kbd code Date: Sun, 21 Apr 2024 17:45:01 +0200 Message-ID: <20240421154520.37089-6-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Use tpacpi_input_send_key() in adaptive_keyboard_hotkey_notify_hotkey() instead of re-implementing it there. Note this change will also result in a behavioral change, key presses on the adaptive keyboard will now also send a EV_MSC event with the scancode, just like all other hotkey presses already do. This is not a bug but a feature. Signed-off-by: Hans de Goede Reviewed-by: Ilpo Järvinen --- drivers/platform/x86/thinkpad_acpi.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index bb6b880a5b50..126e39367924 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3670,7 +3670,6 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode) { int current_mode = 0; int new_mode = 0; - int keycode; switch (scancode) { case DFR_CHANGE_ROW: @@ -3711,19 +3710,8 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode) scancode); return false; } - keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY + - TP_ACPI_HOTKEYSCAN_ADAPTIVE_START]; - if (keycode != KEY_RESERVED) { - mutex_lock(&tpacpi_inputdev_send_mutex); - - input_report_key(tpacpi_inputdev, keycode, 1); - input_sync(tpacpi_inputdev); - - input_report_key(tpacpi_inputdev, keycode, 0); - input_sync(tpacpi_inputdev); - - mutex_unlock(&tpacpi_inputdev_send_mutex); - } + tpacpi_input_send_key(scancode - FIRST_ADAPTIVE_KEY + + TP_ACPI_HOTKEYSCAN_ADAPTIVE_START); return true; } } From patchwork Sun Apr 21 15:45:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637382 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D02118EB8 for ; Sun, 21 Apr 2024 15:45:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714342; cv=none; b=M7JBG7Up+ZF7oc3QAyPY1nRWswXV5bX4v3llOUUhkJzwD996oce49dYgxzh/tu6YD+JkrZP8YTiUZlGrqOK4OApYqobmRfDQgmJYQeguAtxM7ndJGSDxzp8yEaZmOpUohorh+Kekg2eXwyyyZDmZUz7JZ4wDX9bmY4C2pWLOI8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714342; c=relaxed/simple; bh=SyHhK1saqpcNj8FTCDBm233IzncGE/zVNhoTtKtmZMA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=erTRbo3z2SLyWgPtpEG5hgwm0TDayRjE4HTzIWfHqW40nh9gyRlizq3bg4Lfuv1dpcmA8LeUsw+Es+R+6nBovche0B1pmiUOAFtVYS8eFMr816d0pcUsx8djlgT69s13LTOv7gIqUrm7DPo6RBmf3jw/pwvTGYRx7Rj3fMI5KWI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DtgvC4Hv; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DtgvC4Hv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VZ4oCeSkIKJC5UYrrhtJnVfsl+bjEGeW/Opacs8DRbY=; b=DtgvC4Hv5TgmCky3/8KpA2xvXC7ISjD3fnOslgKSE3TsQVBXA/MTtPX7u4QRSb07GsmAHH fmwVB00fKsaB/u31AsovcDwqbXvdMl/T5qjMXtpaJojsGkRlZlJvlgr7m9zdcfkqP/Fv/W O6+HqfiQq6VhgxiuNczntqdhWbTTHps= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-656-MahySxMqOdWXzYI54JDYtA-1; Sun, 21 Apr 2024 11:45:35 -0400 X-MC-Unique: MahySxMqOdWXzYI54JDYtA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13C0689A240; Sun, 21 Apr 2024 15:45:35 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED5C0402482D; Sun, 21 Apr 2024 15:45:33 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 06/24] platform/x86: thinkpad_acpi: Do hkey to scancode translation later Date: Sun, 21 Apr 2024 17:45:02 +0200 Message-ID: <20240421154520.37089-7-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Modify hotkey_notify_hotkey() and it helpers to mostly directly operate on hkey codes (TP_HKEY_EV_* returned by "MHKP") instead of on the 0 - TPACPI_HOTKEY_MAP_LEN scancodes used for scancode -> keycode translation. Keeping things in the hkey format as long a possible is a bit cleaner and this patch prepares things for moving to sparse-keymaps. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 71 ++++++++++++++-------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 126e39367924..c009885c8820 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -157,15 +157,30 @@ enum { /* HKEY events */ enum tpacpi_hkey_event_t { - /* Hotkey-related */ - TP_HKEY_EV_HOTKEY_BASE = 0x1001, /* first hotkey (FN+F1) */ + /* Original hotkeys */ + TP_HKEY_EV_ORIG_KEY_START = 0x1001, /* First hotkey (FN+F1) */ TP_HKEY_EV_BRGHT_UP = 0x1010, /* Brightness up */ TP_HKEY_EV_BRGHT_DOWN = 0x1011, /* Brightness down */ TP_HKEY_EV_KBD_LIGHT = 0x1012, /* Thinklight/kbd backlight */ TP_HKEY_EV_VOL_UP = 0x1015, /* Volume up or unmute */ TP_HKEY_EV_VOL_DOWN = 0x1016, /* Volume down or unmute */ TP_HKEY_EV_VOL_MUTE = 0x1017, /* Mixer output mute */ + TP_HKEY_EV_ORIG_KEY_END = 0x1020, /* Last original hotkey code */ + + /* Adaptive keyboard (2014 X1 Carbon) */ + TP_HKEY_EV_DFR_CHANGE_ROW = 0x1101, /* Change adaptive kbd Fn row mode */ + TP_HKEY_EV_DFR_S_QUICKVIEW_ROW = 0x1102, /* Set adap. kbd Fn row to function mode */ + TP_HKEY_EV_ADAPTIVE_KEY_START = 0x1103, /* First hotkey code on adaptive kbd */ + TP_HKEY_EV_ADAPTIVE_KEY_END = 0x1116, /* Last hotkey code on adaptive kbd */ + + /* Extended hotkey events in 2017+ models */ + TP_HKEY_EV_EXTENDED_KEY_START = 0x1300, /* First extended hotkey code */ TP_HKEY_EV_PRIVACYGUARD_TOGGLE = 0x130f, /* Toggle priv.guard on/off */ + TP_HKEY_EV_EXTENDED_KEY_END = 0x1319, /* Last extended hotkey code using + * hkey -> scancode translation for + * compat. Later codes are entered + * directly in the sparse-keymap. + */ TP_HKEY_EV_AMT_TOGGLE = 0x131a, /* Toggle AMT on/off */ TP_HKEY_EV_PROFILE_TOGGLE = 0x131f, /* Toggle platform profile */ @@ -1752,7 +1767,7 @@ enum { /* hot key scan codes (derived from ACPI DSDT) */ TP_ACPI_HOTKEYSCAN_UNK8, /* Adaptive keyboard keycodes */ - TP_ACPI_HOTKEYSCAN_ADAPTIVE_START, + TP_ACPI_HOTKEYSCAN_ADAPTIVE_START, /* 32 / 0x20 */ TP_ACPI_HOTKEYSCAN_MUTE2 = TP_ACPI_HOTKEYSCAN_ADAPTIVE_START, TP_ACPI_HOTKEYSCAN_BRIGHTNESS_ZERO, TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL, @@ -1775,7 +1790,7 @@ enum { /* hot key scan codes (derived from ACPI DSDT) */ TP_ACPI_HOTKEYSCAN_ROTATE_DISPLAY, /* Lenovo extended keymap, starting at 0x1300 */ - TP_ACPI_HOTKEYSCAN_EXTENDED_START, + TP_ACPI_HOTKEYSCAN_EXTENDED_START, /* 52 / 0x34 */ /* first new observed key (star, favorites) is 0x1311 */ TP_ACPI_HOTKEYSCAN_STAR = 69, TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL2, @@ -3612,10 +3627,6 @@ static const int adaptive_keyboard_modes[] = { FUNCTION_MODE }; -#define DFR_CHANGE_ROW 0x101 -#define DFR_SHOW_QUICKVIEW_ROW 0x102 -#define FIRST_ADAPTIVE_KEY 0x103 - /* press Fn key a while second, it will switch to Function Mode. Then * release Fn key, previous mode be restored. */ @@ -3666,13 +3677,13 @@ static int adaptive_keyboard_get_next_mode(int mode) return adaptive_keyboard_modes[i]; } -static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode) +static bool adaptive_keyboard_hotkey_notify_hotkey(const u32 hkey) { int current_mode = 0; int new_mode = 0; - switch (scancode) { - case DFR_CHANGE_ROW: + switch (hkey) { + case TP_HKEY_EV_DFR_CHANGE_ROW: if (adaptive_keyboard_mode_is_saved) { new_mode = adaptive_keyboard_prev_mode; adaptive_keyboard_mode_is_saved = false; @@ -3689,7 +3700,7 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode) return true; - case DFR_SHOW_QUICKVIEW_ROW: + case TP_HKEY_EV_DFR_S_QUICKVIEW_ROW: current_mode = adaptive_keyboard_get_mode(); if (current_mode < 0) return false; @@ -3702,15 +3713,12 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode) return true; default: - if (scancode < FIRST_ADAPTIVE_KEY || - scancode >= FIRST_ADAPTIVE_KEY + - TP_ACPI_HOTKEYSCAN_EXTENDED_START - - TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) { - pr_info("Unhandled adaptive keyboard key: 0x%x\n", - scancode); + if (hkey < TP_HKEY_EV_ADAPTIVE_KEY_START || + hkey > TP_HKEY_EV_ADAPTIVE_KEY_END) { + pr_info("Unhandled adaptive keyboard key: 0x%x\n", hkey); return false; } - tpacpi_input_send_key(scancode - FIRST_ADAPTIVE_KEY + + tpacpi_input_send_key(hkey - TP_HKEY_EV_ADAPTIVE_KEY_START + TP_ACPI_HOTKEYSCAN_ADAPTIVE_START); return true; } @@ -3718,8 +3726,6 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(unsigned int scancode) static bool hotkey_notify_extended_hotkey(const u32 hkey) { - unsigned int scancode; - switch (hkey) { case TP_HKEY_EV_PRIVACYGUARD_TOGGLE: case TP_HKEY_EV_AMT_TOGGLE: @@ -3728,13 +3734,10 @@ static bool hotkey_notify_extended_hotkey(const u32 hkey) return true; } - /* Extended keycodes start at 0x300 and our offset into the map - * TP_ACPI_HOTKEYSCAN_EXTENDED_START. The calculated scancode - * will be positive, but might not be in the correct range. - */ - scancode = (hkey & 0xfff) - (0x300 - TP_ACPI_HOTKEYSCAN_EXTENDED_START); - if (scancode >= TP_ACPI_HOTKEYSCAN_EXTENDED_START && - scancode < TPACPI_HOTKEY_MAP_LEN) { + if (hkey >= TP_HKEY_EV_EXTENDED_KEY_START && + hkey <= TP_HKEY_EV_EXTENDED_KEY_END) { + unsigned int scancode = hkey - TP_HKEY_EV_EXTENDED_KEY_START + + TP_ACPI_HOTKEYSCAN_EXTENDED_START; tpacpi_input_send_key(scancode); return true; } @@ -3745,7 +3748,7 @@ static bool hotkey_notify_extended_hotkey(const u32 hkey) /* 0x1000-0x1FFF: key presses */ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) { - unsigned int scancode = hkey & 0xfff; + unsigned int scancode = hkey - TP_HKEY_EV_ORIG_KEY_START; /* * Original events are in the 0x10XX range, the adaptive keyboard @@ -3754,10 +3757,8 @@ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) */ switch ((hkey >> 8) & 0xf) { case 0: - if (scancode > 0 && - scancode <= TP_ACPI_HOTKEYSCAN_ADAPTIVE_START) { - /* HKEY event 0x1001 is scancode 0x00 */ - scancode--; + if (hkey >= TP_HKEY_EV_ORIG_KEY_START && + hkey <= TP_HKEY_EV_ORIG_KEY_END) { if (!(hotkey_source_mask & (1 << scancode))) tpacpi_input_send_key_masked(scancode); @@ -3767,7 +3768,7 @@ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) break; case 1: - return adaptive_keyboard_hotkey_notify_hotkey(scancode); + return adaptive_keyboard_hotkey_notify_hotkey(hkey); case 3: return hotkey_notify_extended_hotkey(hkey); @@ -11150,7 +11151,7 @@ static void tpacpi_driver_event(const unsigned int hkey_event) static void hotkey_driver_event(const unsigned int scancode) { - tpacpi_driver_event(TP_HKEY_EV_HOTKEY_BASE + scancode); + tpacpi_driver_event(TP_HKEY_EV_ORIG_KEY_START + scancode); } /* --------------------------------------------------------------------- */ From patchwork Sun Apr 21 15:45:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637383 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 458073D66 for ; Sun, 21 Apr 2024 15:45:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714342; cv=none; b=Vkbstft4kE5n5yGCFlZ3kg4EBQheJWzDXyOYioUiMV9ouI0U2lLXJaTwMLgov5SEwIJrvIZuZ3fowJbyQytP7nRNzCw2ggL9qdE7ojHVHl7vVgCDYFmCrMK8SN49IXjEzW0ZsMyM/lrxxoXHRpTka1OUqO2enXcAUJOjThC3h/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714342; c=relaxed/simple; bh=nrx7tzZtMQ8lY4Vh0wEzhi5M/T34DmhMxsxfxtFbzRA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rURTKwiZ29D0FlGN4711QdhbvpvIJ6dikbWbCOgnTXUs6BDVcPOkg+9SMlhj0y2h4pmLPV0JaiGFUjxs39SjmIJiCA7Ey6pNCagfE48twU1brS3zBhArNnQWgV4/M/oGLw6RCkexlwIj7Q5/sxztFEBnnB3mY4r56++cF2Jaxco= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=g3/w8/Bn; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="g3/w8/Bn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fuG5/FiMeJxxWLVKewZftLA5M7sA1AJN6R27AAxM6lk=; b=g3/w8/BnRmgHDZXiJedDcQRX/LHtBRE0weGUtOklHWeGK2StSHE8pAmH2xaLTBLqx9kXpj nQi3vVQ+Nh865fjqsws7sfK1dueNFfrA6mDIpf4Tc1JBNb0elYPhZ0GlEN9S2Jfqxz54bL 8i8iSNEUrh0VIn3TsF+frXoCTElYJPw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-GNHxUrG_MAWYizY2M7oFFw-1; Sun, 21 Apr 2024 11:45:36 -0400 X-MC-Unique: GNHxUrG_MAWYizY2M7oFFw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E0E01011351; Sun, 21 Apr 2024 15:45:36 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4265D40357A7; Sun, 21 Apr 2024 15:45:35 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 07/24] platform/x86: thinkpad_acpi: Make tpacpi_driver_event() return if it handled the event Date: Sun, 21 Apr 2024 17:45:03 +0200 Message-ID: <20240421154520.37089-8-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 tpacpi_driver_event() already only responds to hkey events which it knows about. Make it return a bool and return true when it has handled the event. This avoids the need to list TP_HKEY_EV_foo values to which it responds both in its caller and in the function itself. Instead callers can now call it unconditionally and check the return value. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 115 ++++++++++++++------------- 1 file changed, 61 insertions(+), 54 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index c009885c8820..0bbc462d604c 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -1918,7 +1918,7 @@ static u32 hotkey_acpi_mask; /* events enabled in firmware */ static u16 *hotkey_keycode_map; -static void tpacpi_driver_event(const unsigned int hkey_event); +static bool tpacpi_driver_event(const unsigned int hkey_event); static void hotkey_driver_event(const unsigned int scancode); static void hotkey_poll_setup(const bool may_warn); @@ -3726,13 +3726,8 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(const u32 hkey) static bool hotkey_notify_extended_hotkey(const u32 hkey) { - switch (hkey) { - case TP_HKEY_EV_PRIVACYGUARD_TOGGLE: - case TP_HKEY_EV_AMT_TOGGLE: - case TP_HKEY_EV_PROFILE_TOGGLE: - tpacpi_driver_event(hkey); + if (tpacpi_driver_event(hkey)) return true; - } if (hkey >= TP_HKEY_EV_EXTENDED_KEY_START && hkey <= TP_HKEY_EV_EXTENDED_KEY_END) { @@ -11081,72 +11076,84 @@ static struct platform_driver tpacpi_hwmon_pdriver = { * HKEY event callout for other subdrivers go here * (yes, it is ugly, but it is quick, safe, and gets the job done */ -static void tpacpi_driver_event(const unsigned int hkey_event) +static bool tpacpi_driver_event(const unsigned int hkey_event) { - if (ibm_backlight_device) { - switch (hkey_event) { - case TP_HKEY_EV_BRGHT_UP: - case TP_HKEY_EV_BRGHT_DOWN: + switch (hkey_event) { + case TP_HKEY_EV_BRGHT_UP: + case TP_HKEY_EV_BRGHT_DOWN: + if (ibm_backlight_device) tpacpi_brightness_notify_change(); - } - } - if (alsa_card) { - switch (hkey_event) { - case TP_HKEY_EV_VOL_UP: - case TP_HKEY_EV_VOL_DOWN: - case TP_HKEY_EV_VOL_MUTE: - volume_alsa_notify_change(); - } - } - if (tp_features.kbdlight && hkey_event == TP_HKEY_EV_KBD_LIGHT) { - enum led_brightness brightness; - - mutex_lock(&kbdlight_mutex); - /* - * Check the brightness actually changed, setting the brightness - * through kbdlight_set_level() also triggers this event. + * Key press events are suppressed by default hotkey_user_mask + * and should still be reported if explicitly requested. */ - brightness = kbdlight_sysfs_get(NULL); - if (kbdlight_brightness != brightness) { - kbdlight_brightness = brightness; - led_classdev_notify_brightness_hw_changed( - &tpacpi_led_kbdlight.led_classdev, brightness); + return false; + case TP_HKEY_EV_VOL_UP: + case TP_HKEY_EV_VOL_DOWN: + case TP_HKEY_EV_VOL_MUTE: + if (alsa_card) + volume_alsa_notify_change(); + + /* Key events are suppressed by default hotkey_user_mask */ + return false; + case TP_HKEY_EV_KBD_LIGHT: + if (tp_features.kbdlight) { + enum led_brightness brightness; + + mutex_lock(&kbdlight_mutex); + + /* + * Check the brightness actually changed, setting the brightness + * through kbdlight_set_level() also triggers this event. + */ + brightness = kbdlight_sysfs_get(NULL); + if (kbdlight_brightness != brightness) { + kbdlight_brightness = brightness; + led_classdev_notify_brightness_hw_changed( + &tpacpi_led_kbdlight.led_classdev, brightness); + } + + mutex_unlock(&kbdlight_mutex); } - - mutex_unlock(&kbdlight_mutex); - } - - if (hkey_event == TP_HKEY_EV_THM_CSM_COMPLETED) { + /* Key events are suppressed by default hotkey_user_mask */ + return false; + case TP_HKEY_EV_THM_CSM_COMPLETED: lapsensor_refresh(); /* If we are already accessing DYTC then skip dytc update */ if (!atomic_add_unless(&dytc_ignore_event, -1, 0)) dytc_profile_refresh(); - } - if (lcdshadow_dev && hkey_event == TP_HKEY_EV_PRIVACYGUARD_TOGGLE) { - enum drm_privacy_screen_status old_hw_state; - bool changed; + return true; + case TP_HKEY_EV_PRIVACYGUARD_TOGGLE: + if (lcdshadow_dev) { + enum drm_privacy_screen_status old_hw_state; + bool changed; - mutex_lock(&lcdshadow_dev->lock); - old_hw_state = lcdshadow_dev->hw_state; - lcdshadow_get_hw_state(lcdshadow_dev); - changed = lcdshadow_dev->hw_state != old_hw_state; - mutex_unlock(&lcdshadow_dev->lock); + mutex_lock(&lcdshadow_dev->lock); + old_hw_state = lcdshadow_dev->hw_state; + lcdshadow_get_hw_state(lcdshadow_dev); + changed = lcdshadow_dev->hw_state != old_hw_state; + mutex_unlock(&lcdshadow_dev->lock); - if (changed) - drm_privacy_screen_call_notifier_chain(lcdshadow_dev); - } - if (hkey_event == TP_HKEY_EV_AMT_TOGGLE) { + if (changed) + drm_privacy_screen_call_notifier_chain(lcdshadow_dev); + } + return true; + case TP_HKEY_EV_AMT_TOGGLE: /* If we're enabling AMT we need to force balanced mode */ if (!dytc_amt_active) /* This will also set AMT mode enabled */ dytc_profile_set(NULL, PLATFORM_PROFILE_BALANCED); else dytc_control_amt(!dytc_amt_active); - } - if (hkey_event == TP_HKEY_EV_PROFILE_TOGGLE) + + return true; + case TP_HKEY_EV_PROFILE_TOGGLE: platform_profile_cycle(); + return true; + } + + return false; } static void hotkey_driver_event(const unsigned int scancode) From patchwork Sun Apr 21 15:45:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637385 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A57AB3D66 for ; Sun, 21 Apr 2024 15:45:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714345; cv=none; b=KZMSAqST9aBoP+asurw845icWXFj8Zy83r1XmNDuw30lvUDT+HJauB2WwLphepZSWGz+eNGMefEcLNMtF8/OBlrSTDkfWmPjgAmXH4vcA4OFRGpnkOa1T7b6jd1XTT9ErQqDUcDWHjH5M8FjHsbA03QAKP4c80OC6CTt0+yUVjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714345; c=relaxed/simple; bh=Z9+F9O+UwMCfrqxqw4D2NxHQBHhmHYAPyjzL4/VoU3I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QD7IuT9qp473t8+SfXnlgP6QowHa/i/c7qgQnnHknfZttB4O31lyOSmKvQGvT/vY406dszC8l12a/cfDrpLDwfmdpYIV2jX+JJATUCLLcJ3yCAu8/xBYo0joWG4w4508Kco8YH0PVRkOHcKAxdP13Rw8oyDcLPXf1XLQ0GbPPM4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IXdEEBn1; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IXdEEBn1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+dNVfH4aGVacLkbXT0WRWWwSuiiGQo9z/8wu7tgvq18=; b=IXdEEBn1e/CLWtG9TQxGwb8j/uLPbvK6/1cEVPmVLTfAKa8lw4I1i0L79NPk61VsL8+Bi5 50stJEPNdAnE06c99BGhNfwSVXVcqdJB5GXbKSLr5gZ71/s+qM9tXSUP0/JlLOhCcHLU47 pBWc3uq633kVZ4rkqsOP9D1RJQKopCA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-Smf0iJuyOPqSaf_2W2UNjg-1; Sun, 21 Apr 2024 11:45:38 -0400 X-MC-Unique: Smf0iJuyOPqSaf_2W2UNjg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A69F91011324; Sun, 21 Apr 2024 15:45:37 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BC4C402482D; Sun, 21 Apr 2024 15:45:36 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 08/24] platform/x86: thinkpad_acpi: Move adaptive kbd event handling to tpacpi_driver_event() Date: Sun, 21 Apr 2024 17:45:04 +0200 Message-ID: <20240421154520.37089-9-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Factor out the adaptive kbd non hotkey event handling into adaptive_keyboard_change_row() and adaptive_keyboard_s_quickview_row() helpers and move the handling of TP_HKEY_EV_DFR_CHANGE_ROW and TP_HKEY_EV_DFR_S_QUICKVIEW_ROW to tpacpi_driver_event(). This groups all the handling of hotkey events which do not emit a key press event together in tpacpi_driver_event(). This is a preparation patch for moving to sparse-keymaps. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 85 +++++++++++++++------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 0bbc462d604c..e8d30f4af126 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3677,51 +3677,50 @@ static int adaptive_keyboard_get_next_mode(int mode) return adaptive_keyboard_modes[i]; } +static void adaptive_keyboard_change_row(void) +{ + int mode; + + if (adaptive_keyboard_mode_is_saved) { + mode = adaptive_keyboard_prev_mode; + adaptive_keyboard_mode_is_saved = false; + } else { + mode = adaptive_keyboard_get_mode(); + if (mode < 0) + return; + mode = adaptive_keyboard_get_next_mode(mode); + } + + adaptive_keyboard_set_mode(mode); +} + +static void adaptive_keyboard_s_quickview_row(void) +{ + int mode = adaptive_keyboard_get_mode(); + + if (mode < 0) + return; + + adaptive_keyboard_prev_mode = mode; + adaptive_keyboard_mode_is_saved = true; + + adaptive_keyboard_set_mode(FUNCTION_MODE); +} + static bool adaptive_keyboard_hotkey_notify_hotkey(const u32 hkey) { - int current_mode = 0; - int new_mode = 0; - - switch (hkey) { - case TP_HKEY_EV_DFR_CHANGE_ROW: - if (adaptive_keyboard_mode_is_saved) { - new_mode = adaptive_keyboard_prev_mode; - adaptive_keyboard_mode_is_saved = false; - } else { - current_mode = adaptive_keyboard_get_mode(); - if (current_mode < 0) - return false; - new_mode = adaptive_keyboard_get_next_mode( - current_mode); - } - - if (adaptive_keyboard_set_mode(new_mode) < 0) - return false; - + if (tpacpi_driver_event(hkey)) return true; - case TP_HKEY_EV_DFR_S_QUICKVIEW_ROW: - current_mode = adaptive_keyboard_get_mode(); - if (current_mode < 0) - return false; - - adaptive_keyboard_prev_mode = current_mode; - adaptive_keyboard_mode_is_saved = true; - - if (adaptive_keyboard_set_mode (FUNCTION_MODE) < 0) - return false; - return true; - - default: - if (hkey < TP_HKEY_EV_ADAPTIVE_KEY_START || - hkey > TP_HKEY_EV_ADAPTIVE_KEY_END) { - pr_info("Unhandled adaptive keyboard key: 0x%x\n", hkey); - return false; - } - tpacpi_input_send_key(hkey - TP_HKEY_EV_ADAPTIVE_KEY_START + - TP_ACPI_HOTKEYSCAN_ADAPTIVE_START); - return true; + if (hkey < TP_HKEY_EV_ADAPTIVE_KEY_START || + hkey > TP_HKEY_EV_ADAPTIVE_KEY_END) { + pr_info("Unhandled adaptive keyboard key: 0x%x\n", hkey); + return false; } + + tpacpi_input_send_key(hkey - TP_HKEY_EV_ADAPTIVE_KEY_START + + TP_ACPI_HOTKEYSCAN_ADAPTIVE_START); + return true; } static bool hotkey_notify_extended_hotkey(const u32 hkey) @@ -11117,6 +11116,12 @@ static bool tpacpi_driver_event(const unsigned int hkey_event) } /* Key events are suppressed by default hotkey_user_mask */ return false; + case TP_HKEY_EV_DFR_CHANGE_ROW: + adaptive_keyboard_change_row(); + return true; + case TP_HKEY_EV_DFR_S_QUICKVIEW_ROW: + adaptive_keyboard_s_quickview_row(); + return true; case TP_HKEY_EV_THM_CSM_COMPLETED: lapsensor_refresh(); /* If we are already accessing DYTC then skip dytc update */ From patchwork Sun Apr 21 15:45:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637386 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AD8B3D66 for ; Sun, 21 Apr 2024 15:45:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714346; cv=none; b=oc/yL0Gk3ys6i/Tmie6OzT1sUwFekUpYfn0Ml0yghlOSOdQ4bF1jciS4Rzs829IwZtuPpS0yrVG1f5hgC/EhKQhpH74RqopNQfzpiF1HFS6MNULOECHLMJ7lBj7QQuJAG4m1dsE5EFVyhouQLAwIAKwRGg/YXjgSHGzlNvtfjW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714346; c=relaxed/simple; bh=TT0Hb4ckh71B/QhiAmSAbRxTPO7eteHfRuonPx48xTo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rdd0wDJR7GLTfw9A5mU614pmUSe/gbQdOw1yRH5cMUiyadhSH1XfYDkLixtYz86GzXx1gGrsqpB4XXVt+EwOnscFE5zHRSjSz2gOYte+F1gQR5cUj1SmydRyvG6bdaVdZ3iwUsZtmRyWZ5uyeZgr9mu2VI7AveE96ZeCa6X58RQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=OnPPoZMZ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="OnPPoZMZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714344; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fH73mViXUfNxIV1pRapEZgtBfnl/WLLZGPX+GWvZVdI=; b=OnPPoZMZD/UsdScopmzbOeBvqhdEvBeOP2hV8K1BLLtqCAomlLwMFFhjmG8pCx0eRShS0x qssmVOtEMoDnwpUwKX71fkHNnO1/h1iXZDxg+ESspKidnsuyLMmwhjLkRuPhNTVDTZgz6x +lwg0p+USPgy57rtcfNILZghhodYJ+o= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-537-JtxrlvIkPDeICssB1M6jwQ-1; Sun, 21 Apr 2024 11:45:39 -0400 X-MC-Unique: JtxrlvIkPDeICssB1M6jwQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EFA338884A0; Sun, 21 Apr 2024 15:45:38 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4EB640357A7; Sun, 21 Apr 2024 15:45:37 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 09/24] platform/x86: thinkpad_acpi: Move special original hotkeys handling out of switch-case Date: Sun, 21 Apr 2024 17:45:05 +0200 Message-ID: <20240421154520.37089-10-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Move the special handling (send_acpi_ev = false, hotkey_source_mask check) for original hotkeys out of the switch-case in hotkey_notify_hotkey(). This is a preparation patch for further refactoring. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index e8d30f4af126..f7dacd2c338a 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3744,6 +3744,15 @@ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) { unsigned int scancode = hkey - TP_HKEY_EV_ORIG_KEY_START; + /* Never send ACPI netlink events for original hotkeys (hkey: 0x1001 - 0x1020) */ + if (hkey >= TP_HKEY_EV_ORIG_KEY_START && hkey <= TP_HKEY_EV_ORIG_KEY_END) { + *send_acpi_ev = false; + + /* Original hotkeys may be polled from NVRAM instead */ + if (hotkey_source_mask & (1 << scancode)) + return true; + } + /* * Original events are in the 0x10XX range, the adaptive keyboard * found in 2014 X1 Carbon emits events are of 0x11XX. In 2017 @@ -3753,10 +3762,7 @@ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) case 0: if (hkey >= TP_HKEY_EV_ORIG_KEY_START && hkey <= TP_HKEY_EV_ORIG_KEY_END) { - if (!(hotkey_source_mask & (1 << scancode))) - tpacpi_input_send_key_masked(scancode); - - *send_acpi_ev = false; + tpacpi_input_send_key_masked(scancode); return true; } break; From patchwork Sun Apr 21 15:45:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637388 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 443261A291 for ; Sun, 21 Apr 2024 15:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714349; cv=none; b=hndv9sush6nty3cNdcrj9S0YZB3vgvxev+zvKKwElK8kbPHreaUWoSahC+l1/DJzAFey6r0978575WTOKrjblvLqNbjhDlV65NVoE9Y8FGrU9IUAw1IzYCmJ/ZTbs7Boi9+MBLrJ9TSbHRGBEtzmvK0XSI/J/bHeeYbN6VNu7z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714349; c=relaxed/simple; bh=xGsp+6v7rISNeq/7B3ff5tExliWnZ6NHgJ62fLPtOAQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QEU+FdlieAU3zty+DXWbFZFyqiyXDq7Oe+FHX+sDU35ZDA6Xzvz+DgupmSzPa5SOCc0qCxwWqnn1KERDVpd+enjSznlrkzwT9G9EIvJ+mACbrl+m1kkP4J6PgKwZiLnQr8X41rrJzVsc/rBeMmWQmPGebtyvOBYmWkXhN1lH+Ec= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VNQW/l0H; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VNQW/l0H" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pPEuP85JM+Hqh/Twef4FmVCYuO56o0XSHWMtS119Q+Y=; b=VNQW/l0H8v55E0/MeYYqajugr1vO7WfrH/OGsUNZTMnKS40QYcAyJWe/oBUDMnoId/KNcd iRJrGoyKQMS1UfpVKqdgs7q0+vyCo6nXWA1ZT/qQ7F7UjTx9ns43Z4k/bqXIwoY9ub7x7P r3s3NvyDdyTj/T9EO5wShaX5TDVI5I4= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-454-ypLHZJADMGmUOsRfqt_8sA-1; Sun, 21 Apr 2024 11:45:40 -0400 X-MC-Unique: ypLHZJADMGmUOsRfqt_8sA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 459AA380450C; Sun, 21 Apr 2024 15:45:40 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A1B640829C3; Sun, 21 Apr 2024 15:45:39 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 10/24] platform/x86: thinkpad_acpi: Move hotkey_user_mask check to tpacpi_input_send_key() Date: Sun, 21 Apr 2024 17:45:06 +0200 Message-ID: <20240421154520.37089-11-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Move hotkey_user_mask check to tpacpi_input_send_key(), this is a preparation patch for further refactoring. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index f7dacd2c338a..3a5c4dca5c1b 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -2256,6 +2256,10 @@ static void tpacpi_input_send_key(const unsigned int scancode) { const unsigned int keycode = hotkey_keycode_map[scancode]; + if (scancode < TP_ACPI_HOTKEYSCAN_ADAPTIVE_START && + !(hotkey_user_mask & (1 << scancode))) + return; + if (keycode != KEY_RESERVED) { mutex_lock(&tpacpi_inputdev_send_mutex); @@ -2275,8 +2279,7 @@ static void tpacpi_input_send_key(const unsigned int scancode) static void tpacpi_input_send_key_masked(const unsigned int scancode) { hotkey_driver_event(scancode); - if (hotkey_user_mask & (1 << scancode)) - tpacpi_input_send_key(scancode); + tpacpi_input_send_key(scancode); } #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL From patchwork Sun Apr 21 15:45:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637387 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6AFD199B8 for ; Sun, 21 Apr 2024 15:45:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714348; cv=none; b=tiROZMN/bAp/ip7WzWuIDYHLFbJtTue5GIHocMvRF2u3Nbcs8etGJmxsMd9JxfDyrKFZQEgWCj1TE1nKHvieHhvbAdboIrtkseCUW2fu80xFa/W4+02bYxsw7IHEJYpJGy+XxkvrEC52JPQvig5S8BfmM1c64g+XffzO97DHECk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714348; c=relaxed/simple; bh=spr4HE+7sdqYqr10HLcPCsH7aU8Wo6uDhtSFLDrq9zk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lh3r2nq+fauAx0jUPfr6ZyJgTaTi8EE4OPZ++Id4FqmwTPWfooMSnHlXDkGL22jRZr0LFJ68AFZ2JpEY+gFoN1gsP7Rli0jImr8WKAlowXAa6f2HmjodJYsbx+6vvOrIUbAnSoRMO0X3KwTh7Yr58QsCeiIwp2skjeJAPXWh50M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=L0PXRFzz; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="L0PXRFzz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=86SulCLqVPYVAss5wTbv7h50nFisEK/xSBhkR+RzgcU=; b=L0PXRFzz2x2HMHn7bNYd8XAI6rPd6nCaAP8Slj8qL45X32kWE8IhH0RKzo3p+Z2jmTUX+e QlcY9AqstjH2gb84GfkUpJvKibNyQqsf+NdxDZSMsIoWmuJ67Fyh1onhZgBWQ2qeszH3mr 3oqkht8s2BFDnLp6LN71xN97VkCSSEU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-iTnqqejcOBSDMktzwhkLLQ-1; Sun, 21 Apr 2024 11:45:42 -0400 X-MC-Unique: iTnqqejcOBSDMktzwhkLLQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8D68C18065AE; Sun, 21 Apr 2024 15:45:41 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7388A40357A7; Sun, 21 Apr 2024 15:45:40 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 11/24] platform/x86: thinkpad_acpi: Always call tpacpi_driver_event() for hotkeys Date: Sun, 21 Apr 2024 17:45:07 +0200 Message-ID: <20240421154520.37089-12-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Call tpacpi_driver_event() at the top of hotkey_notify_hotkey() for all (orig / adaptive / extended) hotkey types, rather then having the orig code path call tpacpi_input_send_key_masked() which calls it through hotkey_driver_event() and having the adaptive / extended helpers call it separately. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 3a5c4dca5c1b..acd2c7e0dea6 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3712,9 +3712,6 @@ static void adaptive_keyboard_s_quickview_row(void) static bool adaptive_keyboard_hotkey_notify_hotkey(const u32 hkey) { - if (tpacpi_driver_event(hkey)) - return true; - if (hkey < TP_HKEY_EV_ADAPTIVE_KEY_START || hkey > TP_HKEY_EV_ADAPTIVE_KEY_END) { pr_info("Unhandled adaptive keyboard key: 0x%x\n", hkey); @@ -3728,9 +3725,6 @@ static bool adaptive_keyboard_hotkey_notify_hotkey(const u32 hkey) static bool hotkey_notify_extended_hotkey(const u32 hkey) { - if (tpacpi_driver_event(hkey)) - return true; - if (hkey >= TP_HKEY_EV_EXTENDED_KEY_START && hkey <= TP_HKEY_EV_EXTENDED_KEY_END) { unsigned int scancode = hkey - TP_HKEY_EV_EXTENDED_KEY_START + @@ -3756,6 +3750,9 @@ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) return true; } + if (tpacpi_driver_event(hkey)) + return true; + /* * Original events are in the 0x10XX range, the adaptive keyboard * found in 2014 X1 Carbon emits events are of 0x11XX. In 2017 @@ -3765,7 +3762,7 @@ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) case 0: if (hkey >= TP_HKEY_EV_ORIG_KEY_START && hkey <= TP_HKEY_EV_ORIG_KEY_END) { - tpacpi_input_send_key_masked(scancode); + tpacpi_input_send_key(scancode); return true; } break; From patchwork Sun Apr 21 15:45:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637389 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E0AE199B4 for ; Sun, 21 Apr 2024 15:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714350; cv=none; b=CppzXI+7DYR+furGa4iOF9BTl0QI3l2tzbfANvzLhaPmgtU3ZPlC+RGZ8PI0GaMdFv8o8TtK5LPFMR3PWLqYNiSj3z4DFvLxvKrUS3f0Ppe32A1RqPoISsU45oURtG4LYN9OdxHCXq25sok2aAMakCwO26zN8tRZLuLXVCPgnfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714350; c=relaxed/simple; bh=jnxNRvMNvB1IhioXsTqOs1RIocpKJpM/cSzgnMro+7w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d8DO/RAU7sH0M46WKMr7cN1OPyDPsIiBJkZfA4SBaeA4jN20NcS0J0e3RwuUBlnq2869uVd0ek5y6amXM0PTX0atz/XCWVxfFl9AL8ixcMIncEKVZ7kZz0sHCg4kbyerc9knvWxsqenwmIlPAlus0zChYLCkPUntvjRw5HqL/jM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=D22NAxzR; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="D22NAxzR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nVcjbji+h5OBgnB/rtWKpMSYXx8CV8D3blVjNswdio0=; b=D22NAxzRhOaxbHTM6IMB50xcWNmh8YRzgLaYSaq7q6PSDAuG4n8ihpX1LhbOy2FsUIjfJK fK9fQ1ea6RM6irYQwMxyUOXThPB+1PPDACBse260twSGbpAAFrD+5IXB6flBVkUFEiKy4W KyylGP3UPsj/XQY2kC3fWtQ4p7ebsvY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-330-bHlngMirO_at-MFuatKELQ-1; Sun, 21 Apr 2024 11:45:43 -0400 X-MC-Unique: bHlngMirO_at-MFuatKELQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D6F7D80B935; Sun, 21 Apr 2024 15:45:42 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC51F40829C3; Sun, 21 Apr 2024 15:45:41 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 12/24] platform/x86: thinkpad_acpi: Drop tpacpi_input_send_key_masked() and hotkey_driver_event() Date: Sun, 21 Apr 2024 17:45:08 +0200 Message-ID: <20240421154520.37089-13-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Both are only 1 / 2 lines and both only have 1 caller fold the contents into tpacpi_hotkey_send_key() which is their single caller. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index acd2c7e0dea6..bc87c78ab0f2 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -1919,7 +1919,6 @@ static u32 hotkey_acpi_mask; /* events enabled in firmware */ static u16 *hotkey_keycode_map; static bool tpacpi_driver_event(const unsigned int hkey_event); -static void hotkey_driver_event(const unsigned int scancode); static void hotkey_poll_setup(const bool may_warn); /* HKEY.MHKG() return bits */ @@ -2275,20 +2274,14 @@ static void tpacpi_input_send_key(const unsigned int scancode) } } -/* Do NOT call without validating scancode first */ -static void tpacpi_input_send_key_masked(const unsigned int scancode) -{ - hotkey_driver_event(scancode); - tpacpi_input_send_key(scancode); -} - #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL static struct tp_acpi_drv_struct ibm_hotkey_acpidriver; /* Do NOT call without validating scancode first */ static void tpacpi_hotkey_send_key(unsigned int scancode) { - tpacpi_input_send_key_masked(scancode); + tpacpi_driver_event(TP_HKEY_EV_ORIG_KEY_START + scancode); + tpacpi_input_send_key(scancode); } static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m) @@ -11167,11 +11160,6 @@ static bool tpacpi_driver_event(const unsigned int hkey_event) return false; } -static void hotkey_driver_event(const unsigned int scancode) -{ - tpacpi_driver_event(TP_HKEY_EV_ORIG_KEY_START + scancode); -} - /* --------------------------------------------------------------------- */ /* /proc support */ From patchwork Sun Apr 21 15:45:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637391 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B15A199B8 for ; Sun, 21 Apr 2024 15:45:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714352; cv=none; b=m8akocHyDD9IsSYl/haWR6yXNGM9ntzPqbkGJsonKmrBs2VFya5Hg5zXpSk9BgOm6ggHHomTj7pz+/HYS5/zEY3V0g/0ZNCDoSVLOuy0/QZqEo+OakotF90+ktgp0Yn6bA+5iOrybq2f++1nQP9MEUDWLbfqccT6lbeb9a2HlEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714352; c=relaxed/simple; bh=UURe6vFaGRIFZ+7mZOf4I+tspzFwBA52Cthu/2SFxVE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h1MsOO3VWR2hUj/qvBpYN0Ts2fzcYdvcxHdPkhFVxnBpOtDfaa/L2PuYwWDwp18JQkH4u0zOJLbvutl53qZBh+IRWI1/JupvdWpztOnE1MucsVYZ6iYdNmtBVJ4t912cxM+WEBOT5eL4V5FJwa3UT9JK2ymIot3u+gms8geHW/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=I4YqYAVR; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="I4YqYAVR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XT/UaZY9kAT8L+fR7Nv16pmVtbMQiia4PE42AxXnaNE=; b=I4YqYAVROEJepGoZnbrD7TURjn1GUxGvoRr0fI8Tmxn2pjmf4Jd+yHZc+j/0J+EL+Ic2e1 c2hfmO9za8GyeCirmB8sw/0KqlzYqDLnVE5KEeVD9Mx97iBd3RvicSagbaCl4jKHk61E3U qNjJawSUIBj5UZ1gTpGa/hNr+qBH1bE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-01pyaDsWOuu62uO7CtZOjA-1; Sun, 21 Apr 2024 11:45:44 -0400 X-MC-Unique: 01pyaDsWOuu62uO7CtZOjA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2A67D810602; Sun, 21 Apr 2024 15:45:44 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10ED2402482D; Sun, 21 Apr 2024 15:45:42 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 13/24] platform/x86: thinkpad_acpi: Move hkey > scancode mapping to tpacpi_input_send_key() Date: Sun, 21 Apr 2024 17:45:09 +0200 Message-ID: <20240421154520.37089-14-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Move the mapping of hkey events to scancodes to tpacpi_input_send_key(), this results in a nice cleanup and prepares things for adding sparse-keymap support. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 81 +++++++++------------------- 1 file changed, 24 insertions(+), 57 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index bc87c78ab0f2..633701c218f2 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -2250,15 +2250,28 @@ static void tpacpi_input_send_tabletsw(void) } } -/* Do NOT call without validating scancode first */ -static void tpacpi_input_send_key(const unsigned int scancode) +static bool tpacpi_input_send_key(const u32 hkey) { - const unsigned int keycode = hotkey_keycode_map[scancode]; + unsigned int keycode, scancode; - if (scancode < TP_ACPI_HOTKEYSCAN_ADAPTIVE_START && - !(hotkey_user_mask & (1 << scancode))) - return; + if (hkey >= TP_HKEY_EV_ORIG_KEY_START && + hkey <= TP_HKEY_EV_ORIG_KEY_END) { + scancode = hkey - TP_HKEY_EV_ORIG_KEY_START; + if (!(hotkey_user_mask & (1 << scancode))) + return true; /* Not reported but still a known code */ + } else if (hkey >= TP_HKEY_EV_ADAPTIVE_KEY_START && + hkey <= TP_HKEY_EV_ADAPTIVE_KEY_END) { + scancode = hkey - TP_HKEY_EV_ADAPTIVE_KEY_START + + TP_ACPI_HOTKEYSCAN_ADAPTIVE_START; + } else if (hkey >= TP_HKEY_EV_EXTENDED_KEY_START && + hkey <= TP_HKEY_EV_EXTENDED_KEY_END) { + scancode = hkey - TP_HKEY_EV_EXTENDED_KEY_START + + TP_ACPI_HOTKEYSCAN_EXTENDED_START; + } else { + return false; + } + keycode = hotkey_keycode_map[scancode]; if (keycode != KEY_RESERVED) { mutex_lock(&tpacpi_inputdev_send_mutex); @@ -2272,6 +2285,8 @@ static void tpacpi_input_send_key(const unsigned int scancode) mutex_unlock(&tpacpi_inputdev_send_mutex); } + + return true; } #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL @@ -2281,7 +2296,7 @@ static struct tp_acpi_drv_struct ibm_hotkey_acpidriver; static void tpacpi_hotkey_send_key(unsigned int scancode) { tpacpi_driver_event(TP_HKEY_EV_ORIG_KEY_START + scancode); - tpacpi_input_send_key(scancode); + tpacpi_input_send_key(TP_HKEY_EV_ORIG_KEY_START + scancode); } static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m) @@ -3703,42 +3718,15 @@ static void adaptive_keyboard_s_quickview_row(void) adaptive_keyboard_set_mode(FUNCTION_MODE); } -static bool adaptive_keyboard_hotkey_notify_hotkey(const u32 hkey) -{ - if (hkey < TP_HKEY_EV_ADAPTIVE_KEY_START || - hkey > TP_HKEY_EV_ADAPTIVE_KEY_END) { - pr_info("Unhandled adaptive keyboard key: 0x%x\n", hkey); - return false; - } - - tpacpi_input_send_key(hkey - TP_HKEY_EV_ADAPTIVE_KEY_START + - TP_ACPI_HOTKEYSCAN_ADAPTIVE_START); - return true; -} - -static bool hotkey_notify_extended_hotkey(const u32 hkey) -{ - if (hkey >= TP_HKEY_EV_EXTENDED_KEY_START && - hkey <= TP_HKEY_EV_EXTENDED_KEY_END) { - unsigned int scancode = hkey - TP_HKEY_EV_EXTENDED_KEY_START + - TP_ACPI_HOTKEYSCAN_EXTENDED_START; - tpacpi_input_send_key(scancode); - return true; - } - - return false; -} - /* 0x1000-0x1FFF: key presses */ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) { - unsigned int scancode = hkey - TP_HKEY_EV_ORIG_KEY_START; - /* Never send ACPI netlink events for original hotkeys (hkey: 0x1001 - 0x1020) */ if (hkey >= TP_HKEY_EV_ORIG_KEY_START && hkey <= TP_HKEY_EV_ORIG_KEY_END) { *send_acpi_ev = false; /* Original hotkeys may be polled from NVRAM instead */ + unsigned int scancode = hkey - TP_HKEY_EV_ORIG_KEY_START; if (hotkey_source_mask & (1 << scancode)) return true; } @@ -3746,28 +3734,7 @@ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) if (tpacpi_driver_event(hkey)) return true; - /* - * Original events are in the 0x10XX range, the adaptive keyboard - * found in 2014 X1 Carbon emits events are of 0x11XX. In 2017 - * models, additional keys are emitted through 0x13XX. - */ - switch ((hkey >> 8) & 0xf) { - case 0: - if (hkey >= TP_HKEY_EV_ORIG_KEY_START && - hkey <= TP_HKEY_EV_ORIG_KEY_END) { - tpacpi_input_send_key(scancode); - return true; - } - break; - - case 1: - return adaptive_keyboard_hotkey_notify_hotkey(hkey); - - case 3: - return hotkey_notify_extended_hotkey(hkey); - } - - return false; + return tpacpi_input_send_key(hkey); } /* 0x2000-0x2FFF: Wakeup reason */ From patchwork Sun Apr 21 15:45:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637390 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5ECA31A291 for ; Sun, 21 Apr 2024 15:45:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714351; cv=none; b=KydTcFI2hAVAY3B94O1TLnrOUaP6hze9/HaAScNDB5Wi/WG6M3lMwFsfCtyK2kuXMSq0xffdG8d8Vhd02CnSUFMtFovGSeMOMCe9BFf7wd+N767nEMWb75u8CXnSBrcBXBWglOj4k9xABnJFABHRa2+1kP6F/LNhrGOE5yjbPe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714351; c=relaxed/simple; bh=ZlpV2laXevVtynTlfQZkNYFBQpY5rpUlsCTRMiNlrWY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eu6q+0mRahIeQgmErXIDUoWxD9qtPi7T6RWHjfGThPnmWCZQ5pO9+aKP2T1Voufsi4AfV5LinelPwjMZPoSWB07Ycn/kGTsGepl5HEeLi4cqvU9IkClhs/Qv1TkX8zec8L18mknEDLrD9GVbXy3cpAoW6BCCLFSUNmbFOq3hgZ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=QPYLJuCY; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QPYLJuCY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SuKvjF97wP5SiRRXeVZ80DuORnYCtp3wHlgNR1jQFUU=; b=QPYLJuCYVAz3IirW07z4D0q72mme7vcdfdW9mLFeW/Cq/nAKa4AJQcX1Rup8jCSSZeUpOc Q7g67Fi5TCH5lgV0+/mCbwff0VSoWcdDr97WGc0WMVwtTfT6SpcM9L8J1aKtkhKO1tSd8+ FYY68WYqXZBztbh85vO4QL8VNmWoaH0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-FFgOUaYBN0C6ORxIJMRPkw-1; Sun, 21 Apr 2024 11:45:46 -0400 X-MC-Unique: FFgOUaYBN0C6ORxIJMRPkw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 778E9802E4D; Sun, 21 Apr 2024 15:45:45 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 582D640829C3; Sun, 21 Apr 2024 15:45:44 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 14/24] platform/x86: thinkpad_acpi: Move tpacpi_driver_event() call to tpacpi_input_send_key() Date: Sun, 21 Apr 2024 17:45:10 +0200 Message-ID: <20240421154520.37089-15-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 All callers of tpacpi_input_send_key() first call tpacpi_driver_event(), move the tpacpi_driver_event() inside tpacpi_input_send_key() to avoid code duplication. For the original hotkey codes 0x1001 - 0x1020 tpacpi_driver_event() never returns true. So the added "return true;" inside tpacpi_input_send_key() never happens when called from tpacpi_hotkey_send_key() so behavior does not change. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 633701c218f2..bed66dd54920 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -2254,6 +2254,9 @@ static bool tpacpi_input_send_key(const u32 hkey) { unsigned int keycode, scancode; + if (tpacpi_driver_event(hkey)) + return true; + if (hkey >= TP_HKEY_EV_ORIG_KEY_START && hkey <= TP_HKEY_EV_ORIG_KEY_END) { scancode = hkey - TP_HKEY_EV_ORIG_KEY_START; @@ -2295,7 +2298,6 @@ static struct tp_acpi_drv_struct ibm_hotkey_acpidriver; /* Do NOT call without validating scancode first */ static void tpacpi_hotkey_send_key(unsigned int scancode) { - tpacpi_driver_event(TP_HKEY_EV_ORIG_KEY_START + scancode); tpacpi_input_send_key(TP_HKEY_EV_ORIG_KEY_START + scancode); } @@ -3731,9 +3733,6 @@ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) return true; } - if (tpacpi_driver_event(hkey)) - return true; - return tpacpi_input_send_key(hkey); } From patchwork Sun Apr 21 15:45:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637392 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D6ED1A291 for ; Sun, 21 Apr 2024 15:45:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714353; cv=none; b=FUgqyg5WYl6HPXC6d5RjNTvwh85zXnTa11HhgcETeigCH97F5gN7jDyH4RUMq+FNEH5ngORRQnxlBmseYLLKMQKiEbWKG4g5/l8p1hA6Bc9GLbxZYqA8Lk2IQ07mdJFP7EDbMC5Me/xilWS6FOuGyoQtnYFoH7wyZOTuxdWGPmM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714353; c=relaxed/simple; bh=xW9u38v3xE8rIvZBaKCKV2rsDD6U526TyIO1haSO5VU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BcKOcBIytt+rcXmFoNBovJJWy6POidLQzGv6XC8v0P4lk6+sItJoxHgLOOQulQFUkfYdlMmfdi0DPF13k6A5zEXxfNAqJvfAf2tgSF7mju7+O8jJvvf1ZWvrPu5s5p2vXLNkPR0JFzQbcz3h7DSm5JCmeMPPLoRGp2NRPX+Asp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BWcoqbne; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BWcoqbne" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JnjSJbh0o4jsaf81yyRkEYAvrQAXrb/x4V/CWBpqLI0=; b=BWcoqbneu37dBzuND96fEc5DPXfGfTkZTH44OfE/ktO8SZLusNnH3I0KYU/CEqtVi9EXyO 6OGNUjpTHia9DbSkRSPpXTcHzxGzDQ3GrtwsNGmkli2954i700FeFgmen0tKWIShii6tY1 raEMTsccX2uBc1CUZSW6VfwleVAfIls= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-444-odOOxaiiMc6hHRR_gXLnPA-1; Sun, 21 Apr 2024 11:45:47 -0400 X-MC-Unique: odOOxaiiMc6hHRR_gXLnPA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BFED71C0515F; Sun, 21 Apr 2024 15:45:46 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5DCA402482D; Sun, 21 Apr 2024 15:45:45 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 15/24] platform/x86: thinkpad_acpi: Do not send ACPI netlink events for unknown hotkeys Date: Sun, 21 Apr 2024 17:45:11 +0200 Message-ID: <20240421154520.37089-16-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Do not send ACPI netlink events for unknown hotkeys, to avoid userspace starting to rely on them. Instead these should be added to the keymap to send evdev events. This should not cause a behavior change for existing laptop models since all currently known 0x1xxx events have a mapping. In hindsight the ACPI netlink events should have been suppressed for the adaptive keyboard and extended hotkeys events too. But the kernel has been sending ACPI netlink events for those for a long time now, so we cannot just stop sending them without potentially causing issues for existing users who may depend on these. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index bed66dd54920..ace615752c93 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -2250,7 +2250,7 @@ static void tpacpi_input_send_tabletsw(void) } } -static bool tpacpi_input_send_key(const u32 hkey) +static bool tpacpi_input_send_key(const u32 hkey, bool *send_acpi_ev) { unsigned int keycode, scancode; @@ -2271,6 +2271,14 @@ static bool tpacpi_input_send_key(const u32 hkey) scancode = hkey - TP_HKEY_EV_EXTENDED_KEY_START + TP_ACPI_HOTKEYSCAN_EXTENDED_START; } else { + /* + * Do not send ACPI netlink events for unknown hotkeys, to + * avoid userspace starting to rely on them. Instead these + * should be added to the keymap to send evdev events. + */ + if (send_acpi_ev) + *send_acpi_ev = false; + return false; } @@ -2298,7 +2306,7 @@ static struct tp_acpi_drv_struct ibm_hotkey_acpidriver; /* Do NOT call without validating scancode first */ static void tpacpi_hotkey_send_key(unsigned int scancode) { - tpacpi_input_send_key(TP_HKEY_EV_ORIG_KEY_START + scancode); + tpacpi_input_send_key(TP_HKEY_EV_ORIG_KEY_START + scancode, NULL); } static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m) @@ -3733,7 +3741,7 @@ static bool hotkey_notify_hotkey(const u32 hkey, bool *send_acpi_ev) return true; } - return tpacpi_input_send_key(hkey); + return tpacpi_input_send_key(hkey, send_acpi_ev); } /* 0x2000-0x2FFF: Wakeup reason */ From patchwork Sun Apr 21 15:45:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637394 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 157CC1BC20 for ; Sun, 21 Apr 2024 15:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714356; cv=none; b=GHfLNmNvhRumoYT5UQFgl4eXks0YysbIhaBNmbyGXUpp7PdfK1fvR1LeelcdYA4JNXuy4KeVpLsVIiZS76gM8gdxthYcomfJXrkWl6O4DNaKmG9pPlHpCKPTnxQybBQRBp0PGh49KOeg9TXS880aQYhHFhUl4zNIYXIobMPUUck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714356; c=relaxed/simple; bh=xDm4SEcWtRc7SYttDwC/8ka9pTZbNh+a7e3oRr55W54=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lDWXprHrXH8VsCIw3j0pmLDQ5w6mdrrdrVbte5MI4R0tealMzen76Z+w4XImF0uZHvmhj4cCccbg3NaM65TqEu+Q5e+BmC/I6RTbceIYu4U5HlZnQNK56wlArwKwBnpyqJyqrWXb3MnV/DZjiQoryHPTyhuM3ghJ2h3d3WNgIpU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Zd4OB0eh; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zd4OB0eh" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714354; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=soMQvIDFn2hV9rOkbrtpr5VaPlC0qyFAQ0wlLL8jG5c=; b=Zd4OB0ehnbFEbyJpAX5/hUxDwU5zm4i/rCPWMyhhyjIixnVDl1X5cYrzuk/y99F7jwAuxA Udal09aBzILeeubgQXxhvyavwGk0R/IDdfRBbQfhvEGZJLWFu0GfuDunhtRtJAMRgV4W61 WaHEHafYZsNg81CuvrPzEXAUERRlSQY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-496-mBwWsH7oNdavdXxNiC5P5w-1; Sun, 21 Apr 2024 11:45:48 -0400 X-MC-Unique: mBwWsH7oNdavdXxNiC5P5w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1604989A248; Sun, 21 Apr 2024 15:45:48 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE81240357A7; Sun, 21 Apr 2024 15:45:46 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 16/24] platform/x86: thinkpad_acpi: Change hotkey_reserved_mask initialization Date: Sun, 21 Apr 2024 17:45:12 +0200 Message-ID: <20240421154520.37089-17-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Change the hotkey_reserved_mask initialization to hardcode the list of reserved keys. There are only a few reserved keys and the code to iterate over the keymap will be removed when moving to sparse-keymaps. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index ace615752c93..30219ba43208 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3545,6 +3545,19 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY, "using keymap number %lu\n", keymap_id); + /* Keys which should be reserved on both IBM and Lenovo models */ + hotkey_reserved_mask = TP_ACPI_HKEY_KBD_LIGHT_MASK | + TP_ACPI_HKEY_VOLUP_MASK | + TP_ACPI_HKEY_VOLDWN_MASK | + TP_ACPI_HKEY_MUTE_MASK; + /* + * Reserve brightness up/down unconditionally on IBM models, on Lenovo + * models these are disabled based on acpi_video_get_backlight_type(). + */ + if (keymap_id == TPACPI_KEYMAP_IBM_GENERIC) + hotkey_reserved_mask |= TP_ACPI_HKEY_BRGHTUP_MASK | + TP_ACPI_HKEY_BRGHTDWN_MASK; + hotkey_keycode_map = kmemdup(&tpacpi_keymaps[keymap_id], TPACPI_HOTKEY_MAP_SIZE, GFP_KERNEL); if (!hotkey_keycode_map) { @@ -3560,9 +3573,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) if (hotkey_keycode_map[i] != KEY_RESERVED) { input_set_capability(tpacpi_inputdev, EV_KEY, hotkey_keycode_map[i]); - } else { - if (i < sizeof(hotkey_reserved_mask)*8) - hotkey_reserved_mask |= 1 << i; } } @@ -3587,9 +3597,8 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) /* Disable brightness up/down on Lenovo thinkpads when * ACPI is handling them, otherwise it is plain impossible * for userspace to do something even remotely sane */ - hotkey_reserved_mask |= - (1 << TP_ACPI_HOTKEYSCAN_FNHOME) - | (1 << TP_ACPI_HOTKEYSCAN_FNEND); + hotkey_reserved_mask |= TP_ACPI_HKEY_BRGHTUP_MASK | + TP_ACPI_HKEY_BRGHTDWN_MASK; hotkey_unmap(TP_ACPI_HOTKEYSCAN_FNHOME); hotkey_unmap(TP_ACPI_HOTKEYSCAN_FNEND); } From patchwork Sun Apr 21 15:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637393 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CBE61B95B for ; Sun, 21 Apr 2024 15:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714355; cv=none; b=Zgz/f55dBnGPGTX9Mj/e3IlFEaRzNH5JV7zVkPY0uthVE/2LIlKpd2z2vnlM28mqNss/GGDuuVLPDwcYlbeir3PTrpJkfhLpk2DIkAeHNsdwi9X3dwsoSwNiGFKnYnRj9J28ULY40YvK4UbmqAiB5usEJcuAk7KC1M8Yzh2tEPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714355; c=relaxed/simple; bh=NLIzfqTNVxORCa5xj6KGjjN8O8hVDSqmlrT/Ewslf2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dxepg8ei9uGbJMEQaK9M4Jd1rd3VCTC6cEPzrGCEFf1d9jtGGjuZAG+E+KiwcCzLyYjUKtRttGP1KV406nBGZVXme+uPoBxxxuq+h5OBjunDkZlBOic6UtCWNHV/4Hk2uwX1g/voHxhFDgwcqhhnzAZLYc/pwPEbqhxmXS+ZGc0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=FNndmzrt; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FNndmzrt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uJu5U2rYPpaHTQ7q0KTXMZY1pF1nfHsUq1/3p+/ppH4=; b=FNndmzrtwEcxkZhLKDg7AYTJCNUgv5HqiqesO1vV8sGZa/AQK8maZjRZOu1pV8qqzoASQm TAOOKQ8+uf4wLS9aaOHWEEGhmZoxlwFBDjJpkDkPmPztxdyOEyEaq4WRMe4WU3OpA8ZwAA oTy2xBIXblgg8Y6DiAMT6kSZwnOZULg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-266-9npPsJJAPkGpf5ZVscnDJw-1; Sun, 21 Apr 2024 11:45:49 -0400 X-MC-Unique: 9npPsJJAPkGpf5ZVscnDJw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5EAE780B935; Sun, 21 Apr 2024 15:45:49 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4427E40C122D; Sun, 21 Apr 2024 15:45:48 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 17/24] platform/x86: thinkpad_acpi: Use correct keycodes for volume and brightness keys Date: Sun, 21 Apr 2024 17:45:13 +0200 Message-ID: <20240421154520.37089-18-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Change the default keymap to report the correct keycodes for the volume and brightness keys. Reporting key events for these is already filtered out by the hotkey_reserved_mask which masks these keys out of hotkey_user_mask at initialization time, so there is no need to also map them to KEY_RESERVED. This avoids users, who want these to be reported, having to also remap the keycodes on top of overriding hotkey_user_mask to report these and Linux userspace has already been overridding the KEY_RESERVED mappings with the correct keycodes through udev/hwdb/60-keyboard.hwdb for years now. Also drop hotkey_unmap() it was only used to dynamically map the brightness keys to KEY_RESERVED and after removing that it has no remaining users. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 45 +++++++++++++--------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 30219ba43208..5db46220d400 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3097,15 +3097,6 @@ static void hotkey_exit(void) mutex_unlock(&hotkey_mutex); } -static void __init hotkey_unmap(const unsigned int scancode) -{ - if (hotkey_keycode_map[scancode] != KEY_RESERVED) { - clear_bit(hotkey_keycode_map[scancode], - tpacpi_inputdev->keybit); - hotkey_keycode_map[scancode] = KEY_RESERVED; - } -} - /* * HKEY quirks: * TPACPI_HK_Q_INIMASK: Supports FN+F3,FN+F4,FN+F12 @@ -3224,22 +3215,28 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) KEY_UNKNOWN, /* 0x0D: FN+INSERT */ KEY_UNKNOWN, /* 0x0E: FN+DELETE */ - /* brightness: firmware always reacts to them */ - KEY_RESERVED, /* 0x0F: FN+HOME (brightness up) */ - KEY_RESERVED, /* 0x10: FN+END (brightness down) */ + /* brightness: firmware always reacts to them. + * Suppressed by default through hotkey_reserved_mask. + */ + KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */ + KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */ - /* Thinklight: firmware always react to it */ - KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ + /* Thinklight: firmware always react to it. + * Suppressed by default through hotkey_reserved_mask. + */ + KEY_KBDILLUMTOGGLE, /* 0x11: FN+PGUP (thinklight toggle) */ KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ /* Volume: firmware always react to it and reprograms * the built-in *extra* mixer. Never map it to control - * another mixer by default. */ - KEY_RESERVED, /* 0x14: VOLUME UP */ - KEY_RESERVED, /* 0x15: VOLUME DOWN */ - KEY_RESERVED, /* 0x16: MUTE */ + * another mixer by default. + * Suppressed by default through hotkey_reserved_mask. + */ + KEY_VOLUMEUP, /* 0x14: VOLUME UP */ + KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */ + KEY_MUTE, /* 0x16: MUTE */ KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ @@ -3282,7 +3279,8 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */ KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */ - KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */ + /* Suppressed by default through hotkey_reserved_mask. */ + KEY_KBDILLUMTOGGLE, /* 0x11: FN+PGUP (thinklight toggle) */ KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ @@ -3297,10 +3295,11 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) * change unless you get test reports from all Lenovo * models. May cause the BIOS to interfere with the * HDA mixer. + * Suppressed by default through hotkey_reserved_mask. */ - KEY_RESERVED, /* 0x14: VOLUME UP */ - KEY_RESERVED, /* 0x15: VOLUME DOWN */ - KEY_RESERVED, /* 0x16: MUTE */ + KEY_VOLUMEUP, /* 0x14: VOLUME UP */ + KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */ + KEY_MUTE, /* 0x16: MUTE */ KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ @@ -3599,8 +3598,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) * for userspace to do something even remotely sane */ hotkey_reserved_mask |= TP_ACPI_HKEY_BRGHTUP_MASK | TP_ACPI_HKEY_BRGHTDWN_MASK; - hotkey_unmap(TP_ACPI_HOTKEYSCAN_FNHOME); - hotkey_unmap(TP_ACPI_HOTKEYSCAN_FNEND); } #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL From patchwork Sun Apr 21 15:45:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637395 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B77D41A28C for ; Sun, 21 Apr 2024 15:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714357; cv=none; b=dAxWrkQXdFlpBqKsUC3Nb5fY91CvYGKN+9wXH7FD2/XOe4nPw4CTOajfXb5N1Zyl6rzCk7CU+OlPC5FIFYwQUvg4Eo409MCKL5jh971HL8h3dItKJAh0dB/WQ+50Z6pWvAHrDhAyJK0tNRAziLuXHOUZ6/rCLnBj4OXTd5FjRjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714357; c=relaxed/simple; bh=8C0/uFdrfdo1QFddVqoHTfioLEjFZVQN+bhB9kVEL7s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BPXH39Qu8b3AHTcxsksKY9KV4TAV46iPYrFp53F9RNiF8OR2dhw9eb4JAX+JCca9R3KwnFlU8TLnF3gIqPEW8KIT7EgiInxeaEB40QHFi7kA4J7pm9qdNcPM7A2P2MhrqQNLmeTUi9uLA/eAGUUoPp0ulazvNsLZa0BY1p1CJU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=GCg0SmPB; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GCg0SmPB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714354; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R6QrbtZCHBRTks1Xbnahfy+zyxyziZb4NRLnWdsoqbM=; b=GCg0SmPBtJZXLJjgFFq3X0nK1M0skHOBCAFxEwWU4RfGnp6NV7TF2d4tPmS7l1YyRMITi5 U6s+B9PKNxmD4u0/uPpsqf3l6+xeaFfIh8HQESkprcQYIOihZKJJqNTxR/cBV1lfpZGvXD 1BLA1Estlj3e3pzSsjibPTxDo42bBtQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-102-M3aZLmX3PQKXRNHEPER4bg-1; Sun, 21 Apr 2024 11:45:51 -0400 X-MC-Unique: M3aZLmX3PQKXRNHEPER4bg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A67693C00098; Sun, 21 Apr 2024 15:45:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C465407F3D4; Sun, 21 Apr 2024 15:45:49 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 18/24] platform/x86: thinkpad_acpi: Drop KEY_RESERVED special handling Date: Sun, 21 Apr 2024 17:45:14 +0200 Message-ID: <20240421154520.37089-19-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 The input core already filters out EV_KEY events for KEY_RESERVED, remove the check for this in tpacpi_input_send_key() and rely on the input core filtering instead. Also change tpacpi_input_send_key() to only report the scancode once instead of reporting it on both press and release. Together these 2 changes make tpacpi_input_send_key() behave the same as sparse_keymap_report_event(). The goal of this patch is to have a separate commit with the slightly different behavior from sparse_keymap_report_event() before switching over to using the sparse-keymap helpers. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 5db46220d400..f70f87b216cb 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -2283,19 +2283,17 @@ static bool tpacpi_input_send_key(const u32 hkey, bool *send_acpi_ev) } keycode = hotkey_keycode_map[scancode]; - if (keycode != KEY_RESERVED) { - mutex_lock(&tpacpi_inputdev_send_mutex); - input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN, scancode); - input_report_key(tpacpi_inputdev, keycode, 1); - input_sync(tpacpi_inputdev); + mutex_lock(&tpacpi_inputdev_send_mutex); - input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN, scancode); - input_report_key(tpacpi_inputdev, keycode, 0); - input_sync(tpacpi_inputdev); + input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN, scancode); + input_report_key(tpacpi_inputdev, keycode, 1); + input_sync(tpacpi_inputdev); - mutex_unlock(&tpacpi_inputdev_send_mutex); - } + input_report_key(tpacpi_inputdev, keycode, 0); + input_sync(tpacpi_inputdev); + + mutex_unlock(&tpacpi_inputdev_send_mutex); return true; } From patchwork Sun Apr 21 15:45:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637397 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3C0F1A28C for ; Sun, 21 Apr 2024 15:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714360; cv=none; b=mUp3yGzgZEtY095VKwJPnuLcLzDx/yn2d5vCD9qtioB+KwJ9N/8abwmwdhmI2A+FF52RNGbjGD7mY2TYPyykxtuTof5ksLgO5JlPOjx/tffAHZp2kHd0dBMXaSWv77AjLMos6th7QMceGt7pldhsNURbMoZggyIL14Ji7HZREZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714360; c=relaxed/simple; bh=T0rC+xE5njdW39EvWR30QEPUw3nxwaQKdIJCUxRXggE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=To0An5W/+zOu6EjZerB57u2Ehet+ZCdSB0FGmqqN7hZTGvkisa97YVl/FFrkDQqxvc3E3EQVvYuDvDVLgDCG0OiObB1+t718hSEOuN/O5KTT0z4XfHpnIIi0FjK5EYal6xs3XBulE70rCIGKU4xpjOOgrxBoNFTO7ZanHHz9z0M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Evs8dYcs; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Evs8dYcs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714357; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FVVtGhLVVo3ntW7ST0rP9/5Cyn0TO07ZgiD+VXFDqls=; b=Evs8dYcs2ZVta0MFKDkrHCrVjqx5ObACAcwCArwUvZe4prQ4cWFYIkkBHDhrCwnoPswQMe RWUvCg7NSuYu22uZFBzhlume1rvPRTB4Fs8/cUigms2SLs7x8942m8fYs26EqNKtSHKIAS w6T2YDFhyBWE8duS+GOWHFC2kUn9SWA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-225-lthpUTH6PJGAuKJoXgScNw-1; Sun, 21 Apr 2024 11:45:52 -0400 X-MC-Unique: lthpUTH6PJGAuKJoXgScNw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 15EDC1011324; Sun, 21 Apr 2024 15:45:52 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id D54AF40829C3; Sun, 21 Apr 2024 15:45:50 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 19/24] platform/x86: thinkpad_acpi: Switch to using sparse-keymap helpers Date: Sun, 21 Apr 2024 17:45:15 +0200 Message-ID: <20240421154520.37089-20-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Switch the hotkey keymap handling over to the sparse-keymap helpers, there should be no functional changes from this. Note all the mappings to KEY_UNKNOWN are removed since that is the default behavior of sparse_keymap_report_event() for unknown scancodes. Also drop the big comment about making changes to the keymaps since the contents of that comment are mostly obsolete. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 400 ++++++++++----------------- 1 file changed, 141 insertions(+), 259 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index f70f87b216cb..5e34f70c21a4 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -1759,12 +1760,12 @@ enum { /* hot key scan codes (derived from ACPI DSDT) */ TP_ACPI_HOTKEYSCAN_THINKPAD, TP_ACPI_HOTKEYSCAN_UNK1, TP_ACPI_HOTKEYSCAN_UNK2, - TP_ACPI_HOTKEYSCAN_UNK3, + TP_ACPI_HOTKEYSCAN_MICMUTE, TP_ACPI_HOTKEYSCAN_UNK4, - TP_ACPI_HOTKEYSCAN_UNK5, - TP_ACPI_HOTKEYSCAN_UNK6, - TP_ACPI_HOTKEYSCAN_UNK7, - TP_ACPI_HOTKEYSCAN_UNK8, + TP_ACPI_HOTKEYSCAN_CONFIG, + TP_ACPI_HOTKEYSCAN_SEARCH, + TP_ACPI_HOTKEYSCAN_SCALE, + TP_ACPI_HOTKEYSCAN_FILE, /* Adaptive keyboard keycodes */ TP_ACPI_HOTKEYSCAN_ADAPTIVE_START, /* 32 / 0x20 */ @@ -1779,7 +1780,7 @@ enum { /* hot key scan codes (derived from ACPI DSDT) */ TP_ACPI_HOTKEYSCAN_UNK11, TP_ACPI_HOTKEYSCAN_UNK12, TP_ACPI_HOTKEYSCAN_UNK13, - TP_ACPI_HOTKEYSCAN_CONFIG, + TP_ACPI_HOTKEYSCAN_CONFIG2, TP_ACPI_HOTKEYSCAN_NEW_TAB, TP_ACPI_HOTKEYSCAN_RELOAD, TP_ACPI_HOTKEYSCAN_BACK, @@ -1801,9 +1802,6 @@ enum { /* hot key scan codes (derived from ACPI DSDT) */ TP_ACPI_HOTKEYSCAN_NOTIFICATION_CENTER, TP_ACPI_HOTKEYSCAN_PICKUP_PHONE, TP_ACPI_HOTKEYSCAN_HANGUP_PHONE, - - /* Hotkey keymap size */ - TPACPI_HOTKEY_MAP_LEN }; enum { /* Keys/events available through NVRAM polling */ @@ -1916,8 +1914,6 @@ static u32 hotkey_driver_mask; /* events needed by the driver */ static u32 hotkey_user_mask; /* events visible to userspace */ static u32 hotkey_acpi_mask; /* events enabled in firmware */ -static u16 *hotkey_keycode_map; - static bool tpacpi_driver_event(const unsigned int hkey_event); static void hotkey_poll_setup(const bool may_warn); @@ -2252,11 +2248,24 @@ static void tpacpi_input_send_tabletsw(void) static bool tpacpi_input_send_key(const u32 hkey, bool *send_acpi_ev) { - unsigned int keycode, scancode; + bool known_ev; + u32 scancode; if (tpacpi_driver_event(hkey)) return true; + /* + * Before the conversion to using the sparse-keymap helpers the driver used to + * map the hkey event codes to 0x00 - 0x4d scancodes so that a straight scancode + * indexed array could be used to map scancodes to keycodes: + * + * 0x1001 - 0x1020 -> 0x00 - 0x1f (Original ThinkPad events) + * 0x1103 - 0x1116 -> 0x20 - 0x33 (Adaptive keyboard, 2014 X1 Carbon) + * 0x1300 - 0x1319 -> 0x34 - 0x4d (Additional keys send in 2017+ models) + * + * The sparse-keymap tables still use these scancodes for these ranges to + * preserve userspace API compatibility (e.g. hwdb keymappings). + */ if (hkey >= TP_HKEY_EV_ORIG_KEY_START && hkey <= TP_HKEY_EV_ORIG_KEY_END) { scancode = hkey - TP_HKEY_EV_ORIG_KEY_START; @@ -2279,23 +2288,14 @@ static bool tpacpi_input_send_key(const u32 hkey, bool *send_acpi_ev) if (send_acpi_ev) *send_acpi_ev = false; - return false; + scancode = hkey; } - keycode = hotkey_keycode_map[scancode]; - mutex_lock(&tpacpi_inputdev_send_mutex); - - input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN, scancode); - input_report_key(tpacpi_inputdev, keycode, 1); - input_sync(tpacpi_inputdev); - - input_report_key(tpacpi_inputdev, keycode, 0); - input_sync(tpacpi_inputdev); - + known_ev = sparse_keymap_report_event(tpacpi_inputdev, scancode, 1, true); mutex_unlock(&tpacpi_inputdev_send_mutex); - return true; + return known_ev; } #ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL @@ -3124,9 +3124,6 @@ static const struct tpacpi_quirk tpacpi_hotkey_qtable[] __initconst = { TPACPI_Q_IBM('1', 'D', TPACPI_HK_Q_INIMASK), /* X22, X23, X24 */ }; -typedef u16 tpacpi_keymap_entry_t; -typedef tpacpi_keymap_entry_t tpacpi_keymap_t[TPACPI_HOTKEY_MAP_LEN]; - static int hotkey_init_tablet_mode(void) { int in_tablet_mode = 0, res; @@ -3163,217 +3160,120 @@ static int hotkey_init_tablet_mode(void) return in_tablet_mode; } +static const struct key_entry keymap_ibm[] __initconst = { + /* Original hotkey mappings translated scancodes 0x00 - 0x1f */ + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF1, { KEY_FN_F1 } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF2, { KEY_BATTERY } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF3, { KEY_COFFEE } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF4, { KEY_SLEEP } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF5, { KEY_WLAN } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF6, { KEY_FN_F6 } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF7, { KEY_SWITCHVIDEOMODE } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF8, { KEY_FN_F8 } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF9, { KEY_FN_F9 } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF10, { KEY_FN_F10 } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF11, { KEY_FN_F11 } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF12, { KEY_SUSPEND } }, + /* Brightness: firmware always reacts, suppressed through hotkey_reserved_mask. */ + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNHOME, { KEY_BRIGHTNESSUP } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNEND, { KEY_BRIGHTNESSDOWN } }, + /* Thinklight: firmware always reacts, suppressed through hotkey_reserved_mask. */ + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNPAGEUP, { KEY_KBDILLUMTOGGLE } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNSPACE, { KEY_ZOOM } }, + /* Volume: firmware always reacts and reprograms the built-in *extra* mixer. + * Suppressed by default through hotkey_reserved_mask. + */ + { KE_KEY, TP_ACPI_HOTKEYSCAN_VOLUMEUP, { KEY_VOLUMEUP } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_VOLUMEDOWN, { KEY_VOLUMEDOWN } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_MUTE, { KEY_MUTE } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_THINKPAD, { KEY_VENDOR } }, + { KE_END } +}; + +static const struct key_entry keymap_lenovo[] __initconst = { + /* Original hotkey mappings translated scancodes 0x00 - 0x1f */ + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF1, { KEY_FN_F1 } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF2, { KEY_COFFEE } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF3, { KEY_BATTERY } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF4, { KEY_SLEEP } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF5, { KEY_WLAN } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF6, { KEY_CAMERA, } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF7, { KEY_SWITCHVIDEOMODE } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF8, { KEY_FN_F8 } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF9, { KEY_FN_F9 } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF10, { KEY_FN_F10 } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF11, { KEY_FN_F11 } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNF12, { KEY_SUSPEND } }, + /* These should be enabled --only-- when ACPI video is disabled and + * are handled in a special way by the init code. + */ + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNHOME, { KEY_BRIGHTNESSUP } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNEND, { KEY_BRIGHTNESSDOWN } }, + /* Suppressed by default through hotkey_reserved_mask. */ + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNPAGEUP, { KEY_KBDILLUMTOGGLE } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FNSPACE, { KEY_ZOOM } }, + /* Volume: z60/z61, T60 (BIOS version?): firmware always reacts and + * reprograms the built-in *extra* mixer. + * T60?, T61, R60?, R61: firmware and EC tries to send these over + * the regular keyboard (not through tpacpi). There are still weird bugs + * re. MUTE. May cause the BIOS to interfere with the HDA mixer. + * Suppressed by default through hotkey_reserved_mask. + */ + { KE_KEY, TP_ACPI_HOTKEYSCAN_VOLUMEUP, { KEY_VOLUMEUP } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_VOLUMEDOWN, { KEY_VOLUMEDOWN } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_MUTE, { KEY_MUTE } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_THINKPAD, { KEY_VENDOR } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_MICMUTE, { KEY_MICMUTE } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_CONFIG, { KEY_CONFIG } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_SEARCH, { KEY_SEARCH } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_SCALE, { KEY_SCALE } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_FILE, { KEY_FILE } }, + /* Adaptive keyboard mappings for Carbon X1 2014 translated scancodes 0x20 - 0x33 */ + { KE_KEY, TP_ACPI_HOTKEYSCAN_MUTE2, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_BRIGHTNESS_ZERO, { KEY_BRIGHTNESS_MIN } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_CLOUD, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_UNK9, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_VOICE, { KEY_VOICECOMMAND } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_UNK10, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_GESTURES, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_UNK11, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_UNK12, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_UNK13, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_CONFIG2, { KEY_CONFIG } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_NEW_TAB, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_RELOAD, { KEY_REFRESH } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_BACK, { KEY_BACK } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_MIC_DOWN, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_MIC_UP, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_MIC_CANCELLATION, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_CAMERA_MODE, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_ROTATE_DISPLAY, { KEY_RESERVED } }, + /* Extended hotkeys mappings translated scancodes 0x34 - 0x4d */ + { KE_KEY, TP_ACPI_HOTKEYSCAN_STAR, { KEY_BOOKMARKS } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL2, { KEY_SELECTIVE_SCREENSHOT } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_CALCULATOR, { KEY_CALC } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_BLUETOOTH, { KEY_BLUETOOTH } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_KEYBOARD, { KEY_KEYBOARD } }, + /* Used by "Lenovo Quick Clean" */ + { KE_KEY, TP_ACPI_HOTKEYSCAN_FN_RIGHT_SHIFT, { KEY_FN_RIGHT_SHIFT } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_NOTIFICATION_CENTER, { KEY_NOTIFICATION_CENTER } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_PICKUP_PHONE, { KEY_PICKUP_PHONE } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_HANGUP_PHONE, { KEY_HANGUP_PHONE } }, + /* All mapping below are for raw untranslated hkey event codes mapped directly + * after switching to sparse keymap support. The mappings above use translated + * scancodes to preserve uAPI compatibility, see tpacpi_input_send_key(). + */ + { KE_END } +}; + static int __init hotkey_init(struct ibm_init_struct *iibm) { - /* Requirements for changing the default keymaps: - * - * 1. Many of the keys are mapped to KEY_RESERVED for very - * good reasons. Do not change them unless you have deep - * knowledge on the IBM and Lenovo ThinkPad firmware for - * the various ThinkPad models. The driver behaves - * differently for KEY_RESERVED: such keys have their - * hot key mask *unset* in mask_recommended, and also - * in the initial hot key mask programmed into the - * firmware at driver load time, which means the firm- - * ware may react very differently if you change them to - * something else; - * - * 2. You must be subscribed to the linux-thinkpad and - * ibm-acpi-devel mailing lists, and you should read the - * list archives since 2007 if you want to change the - * keymaps. This requirement exists so that you will - * know the past history of problems with the thinkpad- - * acpi driver keymaps, and also that you will be - * listening to any bug reports; - * - * 3. Do not send thinkpad-acpi specific patches directly to - * for merging, *ever*. Send them to the linux-acpi - * mailinglist for comments. Merging is to be done only - * through acpi-test and the ACPI maintainer. - * - * If the above is too much to ask, don't change the keymap. - * Ask the thinkpad-acpi maintainer to do it, instead. - */ - enum keymap_index { TPACPI_KEYMAP_IBM_GENERIC = 0, TPACPI_KEYMAP_LENOVO_GENERIC, }; - static const tpacpi_keymap_t tpacpi_keymaps[] __initconst = { - /* Generic keymap for IBM ThinkPads */ - [TPACPI_KEYMAP_IBM_GENERIC] = { - /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */ - KEY_FN_F1, KEY_BATTERY, KEY_COFFEE, KEY_SLEEP, - KEY_WLAN, KEY_FN_F6, KEY_SWITCHVIDEOMODE, KEY_FN_F8, - KEY_FN_F9, KEY_FN_F10, KEY_FN_F11, KEY_SUSPEND, - - /* Scan codes 0x0C to 0x1F: Other ACPI HKEY hot keys */ - KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */ - KEY_UNKNOWN, /* 0x0D: FN+INSERT */ - KEY_UNKNOWN, /* 0x0E: FN+DELETE */ - - /* brightness: firmware always reacts to them. - * Suppressed by default through hotkey_reserved_mask. - */ - KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */ - KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */ - - /* Thinklight: firmware always react to it. - * Suppressed by default through hotkey_reserved_mask. - */ - KEY_KBDILLUMTOGGLE, /* 0x11: FN+PGUP (thinklight toggle) */ - - KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ - KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ - - /* Volume: firmware always react to it and reprograms - * the built-in *extra* mixer. Never map it to control - * another mixer by default. - * Suppressed by default through hotkey_reserved_mask. - */ - KEY_VOLUMEUP, /* 0x14: VOLUME UP */ - KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */ - KEY_MUTE, /* 0x16: MUTE */ - - KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ - - /* (assignments unknown, please report if found) */ - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - - /* No assignments, only used for Adaptive keyboards. */ - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - - /* No assignment, used for newer Lenovo models */ - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN - - }, - - /* Generic keymap for Lenovo ThinkPads */ - [TPACPI_KEYMAP_LENOVO_GENERIC] = { - /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */ - KEY_FN_F1, KEY_COFFEE, KEY_BATTERY, KEY_SLEEP, - KEY_WLAN, KEY_CAMERA, KEY_SWITCHVIDEOMODE, KEY_FN_F8, - KEY_FN_F9, KEY_FN_F10, KEY_FN_F11, KEY_SUSPEND, - - /* Scan codes 0x0C to 0x1F: Other ACPI HKEY hot keys */ - KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */ - KEY_UNKNOWN, /* 0x0D: FN+INSERT */ - KEY_UNKNOWN, /* 0x0E: FN+DELETE */ - - /* These should be enabled --only-- when ACPI video - * is disabled (i.e. in "vendor" mode), and are handled - * in a special way by the init code */ - KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */ - KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */ - - /* Suppressed by default through hotkey_reserved_mask. */ - KEY_KBDILLUMTOGGLE, /* 0x11: FN+PGUP (thinklight toggle) */ - - KEY_UNKNOWN, /* 0x12: FN+PGDOWN */ - KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */ - - /* Volume: z60/z61, T60 (BIOS version?): firmware always - * react to it and reprograms the built-in *extra* mixer. - * Never map it to control another mixer by default. - * - * T60?, T61, R60?, R61: firmware and EC tries to send - * these over the regular keyboard, so these are no-ops, - * but there are still weird bugs re. MUTE, so do not - * change unless you get test reports from all Lenovo - * models. May cause the BIOS to interfere with the - * HDA mixer. - * Suppressed by default through hotkey_reserved_mask. - */ - KEY_VOLUMEUP, /* 0x14: VOLUME UP */ - KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */ - KEY_MUTE, /* 0x16: MUTE */ - - KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */ - - /* (assignments unknown, please report if found) */ - KEY_UNKNOWN, KEY_UNKNOWN, - - /* - * The mic mute button only sends 0x1a. It does not - * automatically mute the mic or change the mute light. - */ - KEY_MICMUTE, /* 0x1a: Mic mute (since ?400 or so) */ - - /* (assignments unknown, please report if found) */ - KEY_UNKNOWN, - - /* Extra keys in use since the X240 / T440 / T540 */ - KEY_CONFIG, KEY_SEARCH, KEY_SCALE, KEY_FILE, - - /* - * These are the adaptive keyboard keycodes for Carbon X1 2014. - * The first item in this list is the Mute button which is - * emitted with 0x103 through - * adaptive_keyboard_hotkey_notify_hotkey() when the sound - * symbol is held. - * We'll need to offset those by 0x20. - */ - KEY_RESERVED, /* Mute held, 0x103 */ - KEY_BRIGHTNESS_MIN, /* Backlight off */ - KEY_RESERVED, /* Clipping tool */ - KEY_RESERVED, /* Cloud */ - KEY_RESERVED, - KEY_VOICECOMMAND, /* Voice */ - KEY_RESERVED, - KEY_RESERVED, /* Gestures */ - KEY_RESERVED, - KEY_RESERVED, - KEY_RESERVED, - KEY_CONFIG, /* Settings */ - KEY_RESERVED, /* New tab */ - KEY_REFRESH, /* Reload */ - KEY_BACK, /* Back */ - KEY_RESERVED, /* Microphone down */ - KEY_RESERVED, /* Microphone up */ - KEY_RESERVED, /* Microphone cancellation */ - KEY_RESERVED, /* Camera mode */ - KEY_RESERVED, /* Rotate display, 0x116 */ - - /* - * These are found in 2017 models (e.g. T470s, X270). - * The lowest known value is 0x311, which according to - * the manual should launch a user defined favorite - * application. - * - * The offset for these is TP_ACPI_HOTKEYSCAN_EXTENDED_START, - * corresponding to 0x34. - */ - - /* (assignments unknown, please report if found) */ - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, - KEY_UNKNOWN, - - KEY_BOOKMARKS, /* Favorite app, 0x311 */ - KEY_SELECTIVE_SCREENSHOT, /* Clipping tool */ - KEY_CALC, /* Calculator (above numpad, P52) */ - KEY_BLUETOOTH, /* Bluetooth */ - KEY_KEYBOARD, /* Keyboard, 0x315 */ - KEY_FN_RIGHT_SHIFT, /* Fn + right Shift */ - KEY_NOTIFICATION_CENTER, /* Notification Center */ - KEY_PICKUP_PHONE, /* Answer incoming call */ - KEY_HANGUP_PHONE, /* Decline incoming call */ - }, - }; - static const struct tpacpi_quirk tpacpi_keymap_qtable[] __initconst = { /* Generic maps (fallback) */ { @@ -3388,17 +3288,11 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) }, }; -#define TPACPI_HOTKEY_MAP_SIZE sizeof(tpacpi_keymap_t) -#define TPACPI_HOTKEY_MAP_TYPESIZE sizeof(tpacpi_keymap_entry_t) - - int res, i; - int status; - int hkeyv; + unsigned long keymap_id, quirks; + const struct key_entry *keymap; bool radiosw_state = false; bool tabletsw_state = false; - - unsigned long quirks; - unsigned long keymap_id; + int hkeyv, res, status; vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY, "initializing hotkey subdriver\n"); @@ -3538,7 +3432,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) /* Set up key map */ keymap_id = tpacpi_check_quirks(tpacpi_keymap_qtable, ARRAY_SIZE(tpacpi_keymap_qtable)); - BUG_ON(keymap_id >= ARRAY_SIZE(tpacpi_keymaps)); dbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_HKEY, "using keymap number %lu\n", keymap_id); @@ -3551,27 +3444,17 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) * Reserve brightness up/down unconditionally on IBM models, on Lenovo * models these are disabled based on acpi_video_get_backlight_type(). */ - if (keymap_id == TPACPI_KEYMAP_IBM_GENERIC) + if (keymap_id == TPACPI_KEYMAP_IBM_GENERIC) { hotkey_reserved_mask |= TP_ACPI_HKEY_BRGHTUP_MASK | TP_ACPI_HKEY_BRGHTDWN_MASK; - - hotkey_keycode_map = kmemdup(&tpacpi_keymaps[keymap_id], - TPACPI_HOTKEY_MAP_SIZE, GFP_KERNEL); - if (!hotkey_keycode_map) { - pr_err("failed to allocate memory for key map\n"); - return -ENOMEM; + keymap = keymap_ibm; + } else { + keymap = keymap_lenovo; } - input_set_capability(tpacpi_inputdev, EV_MSC, MSC_SCAN); - tpacpi_inputdev->keycodesize = TPACPI_HOTKEY_MAP_TYPESIZE; - tpacpi_inputdev->keycodemax = TPACPI_HOTKEY_MAP_LEN; - tpacpi_inputdev->keycode = hotkey_keycode_map; - for (i = 0; i < TPACPI_HOTKEY_MAP_LEN; i++) { - if (hotkey_keycode_map[i] != KEY_RESERVED) { - input_set_capability(tpacpi_inputdev, EV_KEY, - hotkey_keycode_map[i]); - } - } + res = sparse_keymap_setup(tpacpi_inputdev, keymap, NULL); + if (res) + return res; if (tp_features.hotkey_wlsw) { input_set_capability(tpacpi_inputdev, EV_SW, SW_RFKILL_ALL); @@ -11738,7 +11621,6 @@ static void thinkpad_acpi_module_exit(void) input_unregister_device(tpacpi_inputdev); else input_free_device(tpacpi_inputdev); - kfree(hotkey_keycode_map); } if (tpacpi_sensors_pdev) From patchwork Sun Apr 21 15:45:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637396 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67A091B5B1 for ; Sun, 21 Apr 2024 15:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714358; cv=none; b=qFijggTMi20iY5qLzT6OdJR4Ochxvaxb2C4WMG/dIJ2KMPKjv5HhF7F97QThilc/iXsBy7rEbLoeFcZO34bw1ud5EAVBWA5qiUemvs8jzU+GLMsOJbl//hTuvIbcorVcGyiqQc55XDgaUg6IWgAAPKclsJ4IwrhlYT0NhprzJeQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714358; c=relaxed/simple; bh=TbT+L44GuIdHBouGGtSCReysnxAwvX6rRc1stQsm9Dk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cgzzBSY4hMdA1FUwaiv1mQdRSS2dR35gerFBPD89iRQiUYT20EU8unIS3QZpYzhxibKJTT9SA3nRYJ2LLqUZfyXIj0iKvRz1pMD4mYAAjkNAWKXKCx2alVza8o7ETOi6ocIOhDILNixpVSzBdYJ4q4yykabVo4D/231U7u+o5Jc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SKcxL0G2; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SKcxL0G2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714356; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vvdv18IJGOuumFikPskbXJYsileD8TWgYyzZkZDzd08=; b=SKcxL0G2T+0x4XaL0KdJGyIMtLtZX5PTrSmb5x0JfCCxD63yNvgRiBOdhXZO551gtoXFB3 +C2C7kixqAyHdy6Et8jSTSW7My6fEHjYRdshsWk95EmA9gJNFarMwfLFM7FTcHoM8x9Wz5 ho+6yzzYP7y8e7FRupRQ19aS4XrzucM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-269-3Ig_eV2VOv6zmer-9rB3Yw-1; Sun, 21 Apr 2024 11:45:53 -0400 X-MC-Unique: 3Ig_eV2VOv6zmer-9rB3Yw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5F7A0802E4D; Sun, 21 Apr 2024 15:45:53 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44718402482D; Sun, 21 Apr 2024 15:45:52 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 20/24] platform/x86: thinkpad_acpi: Add mappings for adaptive kbd clipping-tool and cloud keys Date: Sun, 21 Apr 2024 17:45:16 +0200 Message-ID: <20240421154520.37089-21-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 The X1 carbon 2014 / 2nd gen's adaptive keyboard top row's "Home" mode, which is 1 of the 2 modes Linux supports, has clipping-tool and cloud buttons which so far are not mapped. I assume these were left as KEY_RESERVED because no suitable KEY_FOO codes were available when support was added. In the mean time we have gotten KEY_SELECTIVE_SCREENSHOT and this has been used for the clipping-tool function under Fn + PrtSc on more traditional ThinkPad keyboards already. Finding a KEY_FOO code for the cloud key is harder looking at the symbol it seems to refer to cloud-storage which made me think of file syncing, or file transfer which has let me to pick KEY_XFER for this. Note this is based on looking at a picture of the adaptive top row in Home mode and has not been tested on an actual adaptive keyboard. Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 5e34f70c21a4..fc60857b39ec 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3231,8 +3231,8 @@ static const struct key_entry keymap_lenovo[] __initconst = { /* Adaptive keyboard mappings for Carbon X1 2014 translated scancodes 0x20 - 0x33 */ { KE_KEY, TP_ACPI_HOTKEYSCAN_MUTE2, { KEY_RESERVED } }, { KE_KEY, TP_ACPI_HOTKEYSCAN_BRIGHTNESS_ZERO, { KEY_BRIGHTNESS_MIN } }, - { KE_KEY, TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL, { KEY_RESERVED } }, - { KE_KEY, TP_ACPI_HOTKEYSCAN_CLOUD, { KEY_RESERVED } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_CLIPPING_TOOL, { KEY_SELECTIVE_SCREENSHOT } }, + { KE_KEY, TP_ACPI_HOTKEYSCAN_CLOUD, { KEY_XFER } }, { KE_KEY, TP_ACPI_HOTKEYSCAN_UNK9, { KEY_RESERVED } }, { KE_KEY, TP_ACPI_HOTKEYSCAN_VOICE, { KEY_VOICECOMMAND } }, { KE_KEY, TP_ACPI_HOTKEYSCAN_UNK10, { KEY_RESERVED } }, From patchwork Sun Apr 21 15:45:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637398 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63D5C1B5B1 for ; Sun, 21 Apr 2024 15:45:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714360; cv=none; b=VqFd4/0lJ+oWgutQU8vzYlivw0I8CAWg4r2Pqfc3cmE1rhI3gu9oB7DdiZa8e0HxHRFOAhV4waVnTEuaCZUyWBHzuii5M09BVminOK64FkswtrjiEBDxPQOd/zfFF9ucTJtWBTJjY3GayWol+aq8ARNbUVxMh/mlfnAnAeT+bTY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714360; c=relaxed/simple; bh=VIM0j5LN8mL2vMrEQJGAo+Rvo5VCIap/f4g7t71+jPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k/uTKQAgTdc+Tvm0B5ZB80JXcEi+uTrdnl38Edk4fnAI5aGV9Im5aIJ+hnLtJgf0JFDbzEcyJ+KHookh3z2+dBy4g6NUjndKxrlo8ubCV9jjbwQe4OTvFBGgjFAFzWMGG4p/8oRK0cpa4+/qs0wxb7Sg9grPQBEBUnkxHz3qVek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Z+sGdgIU; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Z+sGdgIU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714358; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E+mzqNt5w3qnJcmko8jwwdLwE5oPIFcZ7M11zY2tmRU=; b=Z+sGdgIUuOnqVJyzOKkYaIpX2+WYV4qAZ7jC+7WzIfboVbuY88KUzsaa3qh/Ac7L48pzX9 cxIb73sY4UheK4vku8YXBoDgSAe8stLOC/7wWAzNPQlFy4LpUtG3ME7ksWMZmTt1qPpFI+ /57IVnG/jBLNPVSHHjm0x0js/5uR5Rw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-HS1oUmW_NnubOSSC2Rz-dA-1; Sun, 21 Apr 2024 11:45:55 -0400 X-MC-Unique: HS1oUmW_NnubOSSC2Rz-dA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AB1203C00098; Sun, 21 Apr 2024 15:45:54 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D76A40357A7; Sun, 21 Apr 2024 15:45:53 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 21/24] platform/x86: thinkpad_acpi: Simplify known_ev handling Date: Sun, 21 Apr 2024 17:45:17 +0200 Message-ID: <20240421154520.37089-22-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 From: Mark Pearson Modify how known_ev event is handled in preparation for adding new hkey event range. Signed-off-by: Mark Pearson Link: https://lore.kernel.org/r/20240417173124.9953-1-mpearson-lenovo@squebb.ca Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index fc60857b39ec..cd54a2455ac8 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3840,6 +3840,7 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) } send_acpi_ev = true; + known_ev = false; switch (hkey >> 12) { case 1: @@ -3863,8 +3864,6 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) /* FIXME: kick libata if SATA link offline */ known_ev = true; break; - default: - known_ev = false; } break; case 4: @@ -3887,11 +3886,8 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) tpacpi_send_radiosw_update(); send_acpi_ev = 0; known_ev = true; - break; } - fallthrough; /* to default */ - default: - known_ev = false; + break; } if (!known_ev) { pr_notice("unhandled HKEY event 0x%04x\n", hkey); From patchwork Sun Apr 21 15:45:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637399 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4B761A28C for ; Sun, 21 Apr 2024 15:46:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714362; cv=none; b=dFje6pfTNnbBOl2HNVb+ru6Zul+E3Izh1z4loIgi/JtIE1WUVvgPJV2guDtsqF6xJNHOpAZsK6EL0boNUbCpqvViFRclEu81HMME9S+AQuI7JmF5PMPgx90rBS6SUHVCsalajwnpYkL7okCDx3BdAm0AlZ+5mVJM3XJxVYwhGLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714362; c=relaxed/simple; bh=g39fENwJNYWMOhGDqxTFCNhBKRALQVUI3rmQfBpk70A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NQGSIA2xlxHZ3FHhg1vlhjw5+ezRn0K1ZtYGGTgAiBXauBFqtlBes7atnzr/3L127yVzfTHct1kRlBPzw1hFYvJMo4mfdggvLSbrdho2vbA0jvDDZ8o4W8ah6IJyAvVVouoN97ytTafM9A1+cV+qKwgw+wVS1N7RLpyt07cvUhA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=T4/8tRlO; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="T4/8tRlO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jio3xgKs+JhEZrHYiPoxVJB0d6MUvPH04p9TEhRA2Fs=; b=T4/8tRlOgS/lxilrr5hEgEHUDi3H42Obz0LD7xQDv+JnqG7Hc2fuErzlbI4hecRoFlba1V VoZhjFLPNOGgcRr0n6aN9LcPjaWVXa5C3/7Bk+49EVFJ2uE9o9QLFlapOyfjnpwy83Plro uwfU5uqtMgYFX1siMZl0q5wXohuetII= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-412-C88mgSIfPUOYKxpaOdhFRQ-1; Sun, 21 Apr 2024 11:45:56 -0400 X-MC-Unique: C88mgSIfPUOYKxpaOdhFRQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 015B429AA3B5; Sun, 21 Apr 2024 15:45:56 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB399402482D; Sun, 21 Apr 2024 15:45:54 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 22/24] platform/x86: thinkpad_acpi: Support for trackpoint doubletap Date: Sun, 21 Apr 2024 17:45:18 +0200 Message-ID: <20240421154520.37089-23-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 From: Mark Pearson Lenovo trackpoints are adding the ability to generate a doubletap event. This handles the doubletap event and sends the KEY_PROG4 event to userspace. Despite the driver itself not using KEY_PROG1 - KEY_PROG3 this still uses KEY_PROG4 because of some keys being remapped to KEY_PROG1 - KEY_PROG3 by default by the upstream udev hwdb containing: evdev:name:ThinkPad Extra Buttons:dmi:bvn*:bvr*:bd*:svnLENOVO*:pn*:* ... KEYBOARD_KEY_17=prog1 KEYBOARD_KEY_1a=f20 # Microphone mute button KEYBOARD_KEY_45=bookmarks KEYBOARD_KEY_46=prog2 # Fn + PrtSc, on Windows: Snipping tool KEYBOARD_KEY_4a=prog3 # Fn + Right shift, on Windows: No idea Signed-off-by: Mark Pearson Signed-off-by: Vishnu Sankar Link: https://lore.kernel.org/r/20240417173124.9953-2-mpearson-lenovo@squebb.ca [hdegoede@redhat.com: Adjust for switch to sparse-keymap keymaps] Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index cd54a2455ac8..c7e2e85944ac 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -248,6 +248,9 @@ enum tpacpi_hkey_event_t { /* Misc */ TP_HKEY_EV_RFKILL_CHANGED = 0x7000, /* rfkill switch changed */ + + /* Misc2 */ + TP_HKEY_EV_TRACK_DOUBLETAP = 0x8036, /* trackpoint doubletap */ }; /**************************************************************************** @@ -3264,6 +3267,7 @@ static const struct key_entry keymap_lenovo[] __initconst = { * after switching to sparse keymap support. The mappings above use translated * scancodes to preserve uAPI compatibility, see tpacpi_input_send_key(). */ + { KE_KEY, TP_HKEY_EV_TRACK_DOUBLETAP /* 0x8036 */, { KEY_PROG4 } }, { KE_END } }; @@ -3812,6 +3816,17 @@ static bool hotkey_notify_6xxx(const u32 hkey, bool *send_acpi_ev) return true; } +static bool hotkey_notify_8xxx(const u32 hkey, bool *send_acpi_ev) +{ + switch (hkey) { + case TP_HKEY_EV_TRACK_DOUBLETAP: + tpacpi_input_send_key(hkey, send_acpi_ev); + return true; + default: + return false; + } +} + static void hotkey_notify(struct ibm_struct *ibm, u32 event) { u32 hkey; @@ -3888,6 +3903,10 @@ static void hotkey_notify(struct ibm_struct *ibm, u32 event) known_ev = true; } break; + case 8: + /* 0x8000-0x8FFF: misc2 */ + known_ev = hotkey_notify_8xxx(hkey, &send_acpi_ev); + break; } if (!known_ev) { pr_notice("unhandled HKEY event 0x%04x\n", hkey); From patchwork Sun Apr 21 15:45:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ED828199A1 for ; Sun, 21 Apr 2024 15:46:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714363; cv=none; b=OzGaE05lTAj2uAeQyHZFVQww1Pj+usybpCyooAalMiK0IgGZ5opkZAlvv89kkAuma18gKiLhpuvIQP+fVCo7IVPSA2BY98DAi2qdb7EWFvZ1nUpJYq70D1k4p5wlJ+hcx/CYFMyD71N2QL7bM0x+0DzjQ2gwQFA9c67gfXujwIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714363; c=relaxed/simple; bh=dSEgQicAAc6t3cBRmtO+WtH1qRt3MmmkqDW5Qo/UWsY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZXdcuvxRJ6Be4eBj4qeDXInSLmgDF8SThjzOY93c0+E9jbtqMIj+VNjpSsnuaZlH2/pry7H0hJhD3TxmiW2rhmrKyXwoDPhM51RLUdmgVG6ahyVdPO7IkVWlV8YiIF4DfUwB5BSHcU8RcxZZzDGrmGBUy8k/zD1XA1G0k6x1U4k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dF1jMWSm; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dF1jMWSm" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5P5nAO5mvtZwpJTxykNv5ld4bvZLl95VO3pQEZ7YRTM=; b=dF1jMWSm+EKTL3j2jK49KDqTKF/sNHatkcetJkjnOGDz9BhXpRFv8TzXidvJG/+2FPQnct Xa4pqh88GXtwogOTX835MEF0ciW+cdcj9r5z/DenfJgDCv2CCZNOblpLOwsEZcK8rJmqGc 5lUuCJU0NN1KfT5uGHPB9AqbYcC6E9w= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-c0ZC8L_2PyODu4NRyXPxzA-1; Sun, 21 Apr 2024 11:45:57 -0400 X-MC-Unique: c0ZC8L_2PyODu4NRyXPxzA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4B6638884A0; Sun, 21 Apr 2024 15:45:57 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F9E840357A7; Sun, 21 Apr 2024 15:45:56 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 23/24] platform/x86: thinkpad_acpi: Support for system debug info hotkey Date: Sun, 21 Apr 2024 17:45:19 +0200 Message-ID: <20240421154520.37089-24-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 From: Mark Pearson New Lenovo platforms are adding the Fn + N key to generate system debug details that support can use for collecting important details on any customer cases for Windows. Add the infrastructure so we can do the same on Linux by sending a KEY_VENDOR keycode to userspace. Signed-off-by: Mark Pearson Signed-off-by: Nitin Joshi Link: https://lore.kernel.org/r/20240417173124.9953-3-mpearson-lenovo@squebb.ca [hdegoede@redhat.com: Adjust for switch to sparse-keymap keymaps] Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index c7e2e85944ac..dd8873d61126 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -3267,6 +3267,7 @@ static const struct key_entry keymap_lenovo[] __initconst = { * after switching to sparse keymap support. The mappings above use translated * scancodes to preserve uAPI compatibility, see tpacpi_input_send_key(). */ + { KE_KEY, 0x131d, { KEY_VENDOR } }, /* System debug info, similar to old ThinkPad key */ { KE_KEY, TP_HKEY_EV_TRACK_DOUBLETAP /* 0x8036 */, { KEY_PROG4 } }, { KE_END } }; From patchwork Sun Apr 21 15:45:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13637401 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B28C41B27D for ; Sun, 21 Apr 2024 15:46:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714367; cv=none; b=YJhftPbNV/hQDUxgc3SS7bc2H6yqWG/+xiD6I90LpeOcqXVJZ2BClK4+oyy52rT8M8dJJtsmA0o/8CWSOHkTUvZtVLRXSehpevqrWPqAfxpdoNcNX59/sZu2INDhMKYXr5lSx6XgT6mdiMo1cwtj0ACZ/1u9w9PfquW2Ge3R2w4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713714367; c=relaxed/simple; bh=jroP9Ku8ETzPW2yG2BEuYQJSjEKWqFL97XlgLq5MvMI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NA+jnAafxgu8Kj1aDMncdf3M7JLtGWRBto8gbHmxKPxoQxMhlH4HjfIhR1ob37PRYXUQv8GdCBNGrzemrJl/HIVVGr1NCegvsKMfD0Kqov+QPr55arIptUTV6Zwr/1HqjSBj6P1IzKfjwW/ntt1hUA5Q0W0Q+xcZP2QKb4Aaz6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Nd1c00+T; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Nd1c00+T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713714364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YgKLEB9YqmegmBVYCh43Fl0YyweTGlVQeoVCCWEddIs=; b=Nd1c00+T6SCacI30FFIddA0UaDfPEK2HuL4a/UCmzBordS74Gm6dyaiQJ+bQf4i2jAy86T ItCMkzVeqTKni+fawTGHBrwSMaelitwuKVh1QXOtf7s4gJQMY5QSxK5iuBjsEvb8dLNs8z 4SQGbXGLwe6cMPToqXRN1Y8T6E/rs7g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-4zSIIjlWPwypbuIDASdiMg-1; Sun, 21 Apr 2024 11:45:59 -0400 X-MC-Unique: 4zSIIjlWPwypbuIDASdiMg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 928651005D7C; Sun, 21 Apr 2024 15:45:58 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79796407F3D5; Sun, 21 Apr 2024 15:45:57 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko , Mark Pearson , Henrique de Moraes Holschuh Cc: Hans de Goede , Vishnu Sankar , Nitin Joshi , ibm-acpi-devel@lists.sourceforge.net, platform-driver-x86@vger.kernel.org Subject: [PATCH 24/24] platform/x86: thinkpad_acpi: Support hotkey to disable trackpoint doubletap Date: Sun, 21 Apr 2024 17:45:20 +0200 Message-ID: <20240421154520.37089-25-hdegoede@redhat.com> In-Reply-To: <20240421154520.37089-1-hdegoede@redhat.com> References: <20240421154520.37089-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 From: Mark Pearson The hotkey combination Fn + G can be used to disable the trackpoint doubletap feature on Windows. Add matching functionality for Linux. Signed-off-by: Mark Pearson Signed-off-by: Vishnu Sankar Link: https://lore.kernel.org/r/20240417173124.9953-4-mpearson-lenovo@squebb.ca [hdegoede@redhat.com: Adjust for switch to sparse-keymap keymaps] [hdegoede@redhat.com: Do not log unknown event msg for doubletap when disabled] Signed-off-by: Hans de Goede --- drivers/platform/x86/thinkpad_acpi.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index dd8873d61126..7b9d48271d7d 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -183,6 +183,7 @@ enum tpacpi_hkey_event_t { * directly in the sparse-keymap. */ TP_HKEY_EV_AMT_TOGGLE = 0x131a, /* Toggle AMT on/off */ + TP_HKEY_EV_DOUBLETAP_TOGGLE = 0x131c, /* Toggle trackpoint doubletap on/off */ TP_HKEY_EV_PROFILE_TOGGLE = 0x131f, /* Toggle platform profile */ /* Reasons for waking up from S3/S4 */ @@ -372,6 +373,7 @@ static struct { u32 hotkey_poll_active:1; u32 has_adaptive_kbd:1; u32 kbd_lang:1; + u32 trackpoint_doubletap:1; struct quirk_entry *quirks; } tp_features; @@ -3523,6 +3525,9 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) hotkey_poll_setup_safe(true); + /* Enable doubletap by default */ + tp_features.trackpoint_doubletap = 1; + return 0; } @@ -3821,7 +3826,9 @@ static bool hotkey_notify_8xxx(const u32 hkey, bool *send_acpi_ev) { switch (hkey) { case TP_HKEY_EV_TRACK_DOUBLETAP: - tpacpi_input_send_key(hkey, send_acpi_ev); + if (tp_features.trackpoint_doubletap) + tpacpi_input_send_key(hkey, send_acpi_ev); + return true; default: return false; @@ -11028,6 +11035,9 @@ static bool tpacpi_driver_event(const unsigned int hkey_event) else dytc_control_amt(!dytc_amt_active); + return true; + case TP_HKEY_EV_DOUBLETAP_TOGGLE: + tp_features.trackpoint_doubletap = !tp_features.trackpoint_doubletap; return true; case TP_HKEY_EV_PROFILE_TOGGLE: platform_profile_cycle();