Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp270564lqr; Wed, 5 Jun 2024 05:50:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXL/wpALbweTRK2l5SSWKq0Fq/s/DNhKX6Kv2TmhL67KTFGsjI+k5Qa3e2cJAYzdow+FdgegTEABukkahMop9yfn/SxnSSpavpN6a5b9Q== X-Google-Smtp-Source: AGHT+IESMvkgk5QDq1PhWutwqIlmKfpep4YYRY5A9VaEUtIb5GayPua0bsMhn1YcVm6PTs23Yut+ X-Received: by 2002:a17:902:f68b:b0:1f6:6cd5:d003 with SMTP id d9443c01a7336-1f6a5a25c46mr30152245ad.37.1717591824205; Wed, 05 Jun 2024 05:50:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717591824; cv=pass; d=google.com; s=arc-20160816; b=Gki8lXXECwIZnzZiX4MUnNOo3uCzEJJxkm95OrXcdQPkfbhYQH3cd6I4v/qecdMpdc /Z32TS0cmqfppXPCM3cAZlwj6bAYSNFkWcLUlZikYpb+YeUY+HnhzmXq6L1TnOfDPvJU JA8Qu8OC++wbGpDlHZ1cpDgsl4j6vaI96SRm+mwTSgBw9/FX/mU9+MCJaV/OB4CC9sB3 umX3EXggFI6Cmy+IqJbfNjh/WHCuxilRSwgDx8O6Ifnlx4tqMTxeSYqwcytkFtFvjUKA PeD3FFwixGLW7egu+qhyk1vrgr5HaVRaLkvGteUrBxj9h1EtvqUR3C6bf/8PCILPDLO+ r1xg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=o2gaAe9kA1aIiJbek8VglWTv+a259gcyzawTTO7sjsE=; fh=JaEO10XxD5UcYNsD3evzvtK/aPwIV1oFQbhWNxT3jGE=; b=swExuSba3fvDEo8EyhJ6LK2eSKvGMQFQ52ogz40utYhWVIxzSyyGZHrDODjTACTlJg UrEtC5PW80fD2rWH44ZQhCoPUANATJkJ7LOzgNIpHAviWxAFzDjAUgJBe4IOVhbil2CC bXqI5v1wku9FcsVrScEh5NdvWWDdWXWrS6nmEzkUL/6iAgsZcQroAEyvYxW7uecSr9Wn xTCNpnatVrD6BzvVRuBshgSqK4w3i/7ZeQWQy8nsUHjDhB3ivLdbLaflcnv6l1DL1EdV WY+vsPP5wCkhXoYm2ZBwfoG0+xldv9OR8Q5Lr1RTmpFzIu9tZywL9IJCjvlV+NXzWuYu wmoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HM10dP1u; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202501-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202501-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f63233d3fcsi2974685ad.56.2024.06.05.05.50.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:50:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202501-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HM10dP1u; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202501-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202501-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 642E428798A for ; Wed, 5 Jun 2024 12:41:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D79F1C7D64; Wed, 5 Jun 2024 12:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HM10dP1u" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 381BE1C775D; Wed, 5 Jun 2024 12:04:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717589062; cv=none; b=h+xzrA288xCUgwVRTJ8g7PBqn5+Jog7xwPE4+ZCm0lbOTTZKjlHtHPOVSx50pPLf4r7ADx72hkIjqfKBt4kRjp7HscqDPLHrsZ0Y5fR/Pr+JAevafF+oYe86hgpu51Hn4g6jwZbU6zIkUVn31wvYQGMKPz+NSDZJvtG/o4R9UDg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717589062; c=relaxed/simple; bh=o6St3jZNvzDM0GfYHJVKJB9gAHK8ytdJPBLeqTaf4dY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=scxHIJEORwAosQSnzYc88bV+XzJNeO3516n2TFXeHboH+wIz4JLZWV0f25lEl6k8VGKmJIQnHHHf3OD/HElnMlQHEHzUHSLEU9fHJZjWPAl45f9Ao7lSD0r7rY34pNP6rdBFAHqTY7ovcWtTNR7OywHhxlQAst2QnY3uKeGvDk4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HM10dP1u; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89223C3277B; Wed, 5 Jun 2024 12:04:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717589062; bh=o6St3jZNvzDM0GfYHJVKJB9gAHK8ytdJPBLeqTaf4dY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HM10dP1uBxz2+2i44s0IE9lcOUwVdWiwWanDcCiAvB0tKjOUhRDHpkEPDO3bmVJzT lHQqgUr+jJT+iQBY0K3NMOin2F7hXzqHlseq+Worn0uzXxOtj/ZFcG3KWSAyld8ryE VOqkDXQq2ZBXSJLIV2xu1XaK+koB3f87aJ9gu3dcmaDXpLB3c8vJw27rV4eWb9fXEd lzEmOg7IBQSnrOl3hbnq4y4R1ySO/wlDJWYM1cvSsIUD737zmo798Vlv0W4Oojzgnw SyKyoFYH20NEOLiHCjX4uCJbKO05gXaXAVZAwcJS5d3C1OqKo7pU7+uZiXjVbzw2rj y/ypNpz/KV9VA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans de Goede , Gregor Riepl , Sasha Levin , corbet@lwn.net, ilpo.jarvinen@linux.intel.com, paulmck@kernel.org, tglx@linutronix.de, jpoimboe@kernel.org, bp@alien8.de, xiongwei.song@windriver.com, linux-doc@vger.kernel.org, linux-input@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 07/18] platform/x86: touchscreen_dmi: Add support for setting touchscreen properties from cmdline Date: Wed, 5 Jun 2024 08:03:46 -0400 Message-ID: <20240605120409.2967044-7-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605120409.2967044-1-sashal@kernel.org> References: <20240605120409.2967044-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.32 Content-Transfer-Encoding: 8bit From: Hans de Goede [ Upstream commit 0b178b02673998f5acca5a0365a8858ca45beedb ] On x86/ACPI platforms touchscreens mostly just work without needing any device/model specific configuration. But in some cases (mostly with Silead and Goodix touchscreens) it is still necessary to manually specify various touchscreen-properties on a per model basis. touchscreen_dmi is a special place for DMI quirks for this, but it can be challenging for users to figure out the right property values, especially for Silead touchscreens where non of these can be read back from the touchscreen-controller. ATM users can only test touchscreen properties by editing touchscreen_dmi.c and then building a completely new kernel which makes it unnecessary difficult for users to test and submit properties when necessary for their laptop / tablet model. Add support for specifying properties on the kernel commandline to allow users to easily figure out the right settings. See the added documentation in kernel-parameters.txt for the commandline syntax. Cc: Gregor Riepl Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20240523143601.47555-1-hdegoede@redhat.com Signed-off-by: Sasha Levin --- .../admin-guide/kernel-parameters.txt | 22 ++++++ drivers/platform/x86/touchscreen_dmi.c | 79 ++++++++++++++++++- 2 files changed, 98 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 66dfc348043d6..0aeb00732820a 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -1866,6 +1866,28 @@ Format: , + i2c_touchscreen_props= [HW,ACPI,X86] + Set device-properties for ACPI-enumerated I2C-attached + touchscreen, to e.g. fix coordinates of upside-down + mounted touchscreens. If you need this option please + submit a drivers/platform/x86/touchscreen_dmi.c patch + adding a DMI quirk for this. + + Format: + :=[:prop_name=val][:...] + Where is one of: + Omit "=" entirely Set a boolean device-property + Unsigned number Set a u32 device-property + Anything else Set a string device-property + + Examples (split over multiple lines): + i2c_touchscreen_props=GDIX1001:touchscreen-inverted-x: + touchscreen-inverted-y + + i2c_touchscreen_props=MSSL1680:touchscreen-size-x=1920: + touchscreen-size-y=1080:touchscreen-inverted-y: + firmware-name=gsl1680-vendor-model.fw:silead,home-button + i8042.debug [HW] Toggle i8042 debug mode i8042.unmask_kbd_data [HW] Enable printing of interrupt data from the KBD port diff --git a/drivers/platform/x86/touchscreen_dmi.c b/drivers/platform/x86/touchscreen_dmi.c index 630ed0515b1e9..dc244e17754e6 100644 --- a/drivers/platform/x86/touchscreen_dmi.c +++ b/drivers/platform/x86/touchscreen_dmi.c @@ -9,10 +9,13 @@ */ #include +#include #include #include #include #include +#include +#include #include #include #include @@ -1822,7 +1825,7 @@ const struct dmi_system_id touchscreen_dmi_table[] = { { } }; -static const struct ts_dmi_data *ts_data; +static struct ts_dmi_data *ts_data; static void ts_dmi_add_props(struct i2c_client *client) { @@ -1857,6 +1860,64 @@ static int ts_dmi_notifier_call(struct notifier_block *nb, return 0; } +#define MAX_CMDLINE_PROPS 16 + +static struct property_entry ts_cmdline_props[MAX_CMDLINE_PROPS + 1]; + +static struct ts_dmi_data ts_cmdline_data = { + .properties = ts_cmdline_props, +}; + +static int __init ts_parse_props(char *str) +{ + /* Save the original str to show it on syntax errors */ + char orig_str[256]; + char *name, *value; + u32 u32val; + int i, ret; + + strscpy(orig_str, str, sizeof(orig_str)); + + /* + * str is part of the static_command_line from init/main.c and poking + * holes in that by writing 0 to it is allowed, as is taking long + * lasting references to it. + */ + ts_cmdline_data.acpi_name = strsep(&str, ":"); + + for (i = 0; i < MAX_CMDLINE_PROPS; i++) { + name = strsep(&str, ":"); + if (!name || !name[0]) + break; + + /* Replace '=' with 0 and make value point past '=' or NULL */ + value = name; + strsep(&value, "="); + if (!value) { + ts_cmdline_props[i] = PROPERTY_ENTRY_BOOL(name); + } else if (isdigit(value[0])) { + ret = kstrtou32(value, 0, &u32val); + if (ret) + goto syntax_error; + + ts_cmdline_props[i] = PROPERTY_ENTRY_U32(name, u32val); + } else { + ts_cmdline_props[i] = PROPERTY_ENTRY_STRING(name, value); + } + } + + if (!i || str) + goto syntax_error; + + ts_data = &ts_cmdline_data; + return 1; + +syntax_error: + pr_err("Invalid '%s' value for 'i2c_touchscreen_props='\n", orig_str); + return 1; /* "i2c_touchscreen_props=" is still a known parameter */ +} +__setup("i2c_touchscreen_props=", ts_parse_props); + static struct notifier_block ts_dmi_notifier = { .notifier_call = ts_dmi_notifier_call, }; @@ -1864,13 +1925,25 @@ static struct notifier_block ts_dmi_notifier = { static int __init ts_dmi_init(void) { const struct dmi_system_id *dmi_id; + struct ts_dmi_data *ts_data_dmi; int error; dmi_id = dmi_first_match(touchscreen_dmi_table); - if (!dmi_id) + ts_data_dmi = dmi_id ? dmi_id->driver_data : NULL; + + if (ts_data) { + /* + * Kernel cmdline provided data takes precedence, copy over + * DMI efi_embedded_fw info if available. + */ + if (ts_data_dmi) + ts_data->embedded_fw = ts_data_dmi->embedded_fw; + } else if (ts_data_dmi) { + ts_data = ts_data_dmi; + } else { return 0; /* Not an error */ + } - ts_data = dmi_id->driver_data; /* Some dmi table entries only provide an efi_embedded_fw_desc */ if (!ts_data->properties) return 0; -- 2.43.0