From patchwork Tue Oct 25 12:29:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13019127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA97EC04A95 for ; Tue, 25 Oct 2022 12:29:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231639AbiJYM3p (ORCPT ); Tue, 25 Oct 2022 08:29:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231690AbiJYM3m (ORCPT ); Tue, 25 Oct 2022 08:29:42 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F5B911E47D for ; Tue, 25 Oct 2022 05:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666700981; 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=sLJrbmQYx5qLz4I3isFLP0Xs6urszSZp3lm0OAOGEMM=; b=YObccfA1eMN+aUSkU3N3v3zKbmLkiI/PKA+Tz6c503/CyXwlpiK1Pg3F8Kc60in2lXQ3KO pRduhlaQ5aE1GkkPTmd6I2ltcWNgx1TzX/JFSyqeeOzhFMezGehM9SGLd5TpOWy8xrF9HI M0dDedTybdrjR4FVSOkI4LMfV3vlx60= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628-aSIO7qHeMNaz47rHxs0K9g-1; Tue, 25 Oct 2022 08:29:35 -0400 X-MC-Unique: aSIO7qHeMNaz47rHxs0K9g-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F07EE3817989; Tue, 25 Oct 2022 12:29:33 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id F001B4A9255; Tue, 25 Oct 2022 12:29:32 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , Bastien Nocera , linux-input@vger.kernel.org Subject: [PATCH 1/4] Input: goodix - Try resetting the controller when no config is set Date: Tue, 25 Oct 2022 14:29:27 +0200 Message-Id: <20221025122930.421377-2-hdegoede@redhat.com> In-Reply-To: <20221025122930.421377-1-hdegoede@redhat.com> References: <20221025122930.421377-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On ACPI systems (irq_pin_access_method == IRQ_PIN_ACCESS_ACPI_*) the driver does not reset the controller at probe time, because sometimes the system firmware loads a config and resetting might loose this config. On the Nanote UMPC-01 device OTOH the config is in flash of the controller, the controller needs a reset to load this; and the system firmware does not reset the controller on a cold boot. To fix the Nanote UMPC-01 touchscreen not working on a cold boot, try resetting the controller and then re-reading the config when encountering a config with 0 width/height/max_touch_num value and the controller has not already been reset by goodix_ts_probe(). This should be safe to do in general because normally we should never encounter a config with 0 width/height/max_touch_num. Doing this in general not only avoids the need for a DMI quirk, but also might help other systems. Signed-off-by: Hans de Goede Reviewed-by: Bastien Nocera --- drivers/input/touchscreen/goodix.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index a33cc7950cf5..c281e49826c2 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -1158,6 +1158,7 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) input_set_abs_params(ts->input_dev, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); input_set_abs_params(ts->input_dev, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); +retry_read_config: /* Read configuration and apply touchscreen parameters */ goodix_read_config(ts); @@ -1165,6 +1166,16 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) touchscreen_parse_properties(ts->input_dev, true, &ts->prop); if (!ts->prop.max_x || !ts->prop.max_y || !ts->max_touch_num) { + if (!ts->reset_controller_at_probe && + ts->irq_pin_access_method != IRQ_PIN_ACCESS_NONE) { + dev_info(&ts->client->dev, "Config not set, resetting controller\n"); + /* Retry after a controller reset */ + ts->reset_controller_at_probe = true; + error = goodix_reset(ts); + if (error) + return error; + goto retry_read_config; + } dev_err(&ts->client->dev, "Invalid config (%d, %d, %d), using defaults\n", ts->prop.max_x, ts->prop.max_y, ts->max_touch_num); From patchwork Tue Oct 25 12:29:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13019126 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C589ECDFA1 for ; Tue, 25 Oct 2022 12:29:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231504AbiJYM3o (ORCPT ); Tue, 25 Oct 2022 08:29:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231608AbiJYM3m (ORCPT ); Tue, 25 Oct 2022 08:29:42 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EAE8D0189 for ; Tue, 25 Oct 2022 05:29:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666700980; 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=+jnErqmUXM69KiUVhn9cZxuyE5Zs8gY1PaHqvMhsIwk=; b=EJHGGAbTwXWWxjIF1JxtmCmMIEaJZva1Idsdn5XLMxzIzMkzcq97GlowQ3IrZezVCDn8nf /0hEO/277hBll9hwJvpKXYpvMsg291L5duDuzEZ9GfkfE/5tJtkhP8VVGMyIEgZcM7Cz9/ OspBIjeyRKJ5vL8S3WM2mmK+QLK+io8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-O8GDVJWQPQCAyCNCVwxsgg-1; Tue, 25 Oct 2022 08:29:37 -0400 X-MC-Unique: O8GDVJWQPQCAyCNCVwxsgg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 636923C32C60; Tue, 25 Oct 2022 12:29:35 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 519184A9254; Tue, 25 Oct 2022 12:29:34 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , Bastien Nocera , linux-input@vger.kernel.org Subject: [PATCH 2/4] Input: touchscreen - Extend touchscreen_parse_properties() to allow overriding settings with a module option Date: Tue, 25 Oct 2022 14:29:28 +0200 Message-Id: <20221025122930.421377-3-hdegoede@redhat.com> In-Reply-To: <20221025122930.421377-1-hdegoede@redhat.com> References: <20221025122930.421377-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org 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. This is handled by drivers/platform/x86/touchscreen_dmi.c which contains a large list of per-model touchscreen properties which it attaches to the (i2c)device before the touchscreen driver's probe() method gets called. This means that ATM changing these settings requires recompiling the kernel. This makes figuring out what settings/properties a specific touchscreen needs very hard for normal users to do. Add a new, optional, settings_override string argument to touchscreen_parse_properties(), which takes a list of ; separated property-name=value pairs, e.g. : "touchscreen-size-x=1665;touchscreen-size-y=1140;touchscreen-swapped-x-y". This new argument can be used by drivers to implement a module option which allows users to easily specify alternative settings for testing. The 2 new touchscreen_property_read_u32() and touchscreen_property_read_bool() helpers are also exported so that drivers can use these to add settings-override support to the code for driver-specific properties. Signed-off-by: Hans de Goede --- Changes in v2: - Instead of patching all drivers rename touchscreen_parse_properties() to touchscreen_parse_properties_with_override() and add a static inline wrapper which passes NULL. --- drivers/input/touchscreen.c | 103 ++++++++++++++++++++++++++---- include/linux/input/touchscreen.h | 19 +++++- 2 files changed, 109 insertions(+), 13 deletions(-) diff --git a/drivers/input/touchscreen.c b/drivers/input/touchscreen.c index 4620e20d0190..3b9505d5468d 100644 --- a/drivers/input/touchscreen.c +++ b/drivers/input/touchscreen.c @@ -12,15 +12,80 @@ #include #include +static int touchscreen_get_prop_from_settings_string(const char *settings, + const char *propname, + bool is_boolean, + u32 *val_ret) +{ + char *begin, *end; + u32 val; + + if (!settings) + return -ENOENT; + + begin = strstr(settings, propname); + if (!begin) + return -ENOENT; + + /* begin must be either the begin of settings, or be preceded by a ';' */ + if (begin != settings && begin[-1] != ';') + return -EINVAL; + + end = begin + strlen(propname); + if (*end != '=') { + if (is_boolean && (*end == '\0' || *end == ';')) { + *val_ret = true; + return 0; + } + return -EINVAL; + } + + val = simple_strtoul(end + 1, &end, 0); + if (*end != '\0' && *end != ';') + return -EINVAL; + + *val_ret = val; + return 0; +} + +int touchscreen_property_read_u32(struct device *dev, const char *propname, + const char *settings, u32 *val) +{ + int error; + + error = device_property_read_u32(dev, propname, val); + + if (touchscreen_get_prop_from_settings_string(settings, propname, + false, val) == 0) + error = 0; + + return error; +} +EXPORT_SYMBOL(touchscreen_property_read_u32); + +bool touchscreen_property_read_bool(struct device *dev, const char *propname, + const char *settings) +{ + u32 val; + + val = device_property_read_bool(dev, propname); + + touchscreen_get_prop_from_settings_string(settings, propname, true, &val); + + return val; +} +EXPORT_SYMBOL(touchscreen_property_read_bool); + static bool touchscreen_get_prop_u32(struct device *dev, const char *property, + const char *settings, unsigned int default_value, unsigned int *value) { u32 val; int error; - error = device_property_read_u32(dev, property, &val); + error = touchscreen_property_read_u32(dev, property, settings, &val); if (error) { *value = default_value; return false; @@ -50,20 +115,28 @@ static void touchscreen_set_params(struct input_dev *dev, } /** - * touchscreen_parse_properties - parse common touchscreen properties + * touchscreen_parse_properties_with_settings - parse common touchscreen properties * @input: input device that should be parsed * @multitouch: specifies whether parsed properties should be applied to * single-touch or multi-touch axes * @prop: pointer to a struct touchscreen_properties into which to store * axis swap and invert info for use with touchscreen_report_x_y(); * or %NULL + * @settings: string with ; separated name=value pairs overriding + * the device-properties or %NULL. * * This function parses common properties for touchscreens and sets up the * input device accordingly. The function keeps previously set up default * values if no value is specified. + * + * Callers can optional specify a settings string overriding the + * device-properties, this can be used to implement a module option which + * allows users to easily specify alternative settings for testing. */ -void touchscreen_parse_properties(struct input_dev *input, bool multitouch, - struct touchscreen_properties *prop) +void touchscreen_parse_properties_with_settings(struct input_dev *input, + bool multitouch, + struct touchscreen_properties *prop, + const char *settings) { struct device *dev = input->dev.parent; struct input_absinfo *absinfo; @@ -79,26 +152,32 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, axis_y = multitouch ? ABS_MT_POSITION_Y : ABS_Y; data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-x", + settings, input_abs_get_min(input, axis_x), &minimum); data_present |= touchscreen_get_prop_u32(dev, "touchscreen-size-x", + settings, input_abs_get_max(input, axis_x) + 1, &maximum); data_present |= touchscreen_get_prop_u32(dev, "touchscreen-fuzz-x", + settings, input_abs_get_fuzz(input, axis_x), &fuzz); if (data_present) touchscreen_set_params(input, axis_x, minimum, maximum - 1, fuzz); data_present = touchscreen_get_prop_u32(dev, "touchscreen-min-y", + settings, input_abs_get_min(input, axis_y), &minimum); data_present |= touchscreen_get_prop_u32(dev, "touchscreen-size-y", + settings, input_abs_get_max(input, axis_y) + 1, &maximum); data_present |= touchscreen_get_prop_u32(dev, "touchscreen-fuzz-y", + settings, input_abs_get_fuzz(input, axis_y), &fuzz); if (data_present) @@ -107,10 +186,12 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, axis = multitouch ? ABS_MT_PRESSURE : ABS_PRESSURE; data_present = touchscreen_get_prop_u32(dev, "touchscreen-max-pressure", + settings, input_abs_get_max(input, axis), &maximum); data_present |= touchscreen_get_prop_u32(dev, "touchscreen-fuzz-pressure", + settings, input_abs_get_fuzz(input, axis), &fuzz); if (data_present) @@ -122,28 +203,28 @@ void touchscreen_parse_properties(struct input_dev *input, bool multitouch, prop->max_x = input_abs_get_max(input, axis_x); prop->max_y = input_abs_get_max(input, axis_y); - prop->invert_x = - device_property_read_bool(dev, "touchscreen-inverted-x"); + prop->invert_x = touchscreen_property_read_bool(dev, "touchscreen-inverted-x", + settings); if (prop->invert_x) { absinfo = &input->absinfo[axis_x]; absinfo->maximum -= absinfo->minimum; absinfo->minimum = 0; } - prop->invert_y = - device_property_read_bool(dev, "touchscreen-inverted-y"); + prop->invert_y = touchscreen_property_read_bool(dev, "touchscreen-inverted-y", + settings); if (prop->invert_y) { absinfo = &input->absinfo[axis_y]; absinfo->maximum -= absinfo->minimum; absinfo->minimum = 0; } - prop->swap_x_y = - device_property_read_bool(dev, "touchscreen-swapped-x-y"); + prop->swap_x_y = touchscreen_property_read_bool(dev, "touchscreen-swapped-x-y", + settings); if (prop->swap_x_y) swap(input->absinfo[axis_x], input->absinfo[axis_y]); } -EXPORT_SYMBOL(touchscreen_parse_properties); +EXPORT_SYMBOL(touchscreen_parse_properties_with_settings); static void touchscreen_apply_prop_to_x_y(const struct touchscreen_properties *prop, diff --git a/include/linux/input/touchscreen.h b/include/linux/input/touchscreen.h index fe66e2b58f62..0023c6e368ba 100644 --- a/include/linux/input/touchscreen.h +++ b/include/linux/input/touchscreen.h @@ -17,8 +17,23 @@ struct touchscreen_properties { bool swap_x_y; }; -void touchscreen_parse_properties(struct input_dev *input, bool multitouch, - struct touchscreen_properties *prop); +void touchscreen_parse_properties_with_settings(struct input_dev *input, + bool multitouch, + struct touchscreen_properties *prop, + const char *settings); + +static inline void touchscreen_parse_properties(struct input_dev *input, + bool multitouch, + struct touchscreen_properties *prop) +{ + touchscreen_parse_properties_with_settings(input, multitouch, prop, NULL); +} + +int touchscreen_property_read_u32(struct device *dev, const char *propname, + const char *settings, u32 *val); + +bool touchscreen_property_read_bool(struct device *dev, const char *propname, + const char *settings); void touchscreen_set_mt_pos(struct input_mt_pos *pos, const struct touchscreen_properties *prop, From patchwork Tue Oct 25 12:29:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13019129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB1A6C38A2D for ; Tue, 25 Oct 2022 12:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231634AbiJYM37 (ORCPT ); Tue, 25 Oct 2022 08:29:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbiJYM34 (ORCPT ); Tue, 25 Oct 2022 08:29:56 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5CE9123465 for ; Tue, 25 Oct 2022 05:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666700988; 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=9aY1AM9EwjVo2Ka5wLTjYHSLvfEu/q0IQzHcuBDD0Js=; b=W1GIFyT1FV+nz9CuMxuyy4moPJrfOwUzUK5lwohHCIgRAoQDOPJH78lp3XvHFVj+VzgrU8 1CrxbVoFre0up0lYU2mh/pivAoeK0VuCKMMSEQOPnt5SxHHs/P1P8FuZWbeM5jOoNsdf7d OGcTi7IhNe3jGPoteDY3CuN0NfD81ts= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-634-xuHp0-6xPw6ngTpk2MhxiQ-1; Tue, 25 Oct 2022 08:29:37 -0400 X-MC-Unique: xuHp0-6xPw6ngTpk2MhxiQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D19512A59541; Tue, 25 Oct 2022 12:29:36 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7ABF4A9254; Tue, 25 Oct 2022 12:29:35 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , Bastien Nocera , linux-input@vger.kernel.org Subject: [PATCH 3/4] Input: silead - Add a settings module-parameter Date: Tue, 25 Oct 2022 14:29:29 +0200 Message-Id: <20221025122930.421377-4-hdegoede@redhat.com> In-Reply-To: <20221025122930.421377-1-hdegoede@redhat.com> References: <20221025122930.421377-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add a settings module-parameter which can be allowed to specify/override various device-properties. Unlike most other touchscreen controllers Silead touchscreens don't tell us the ranges of the reported x and y coordinates and Silead touchscreens also often need to have their axis inverted and/or swapped to match the display coordinates. Being able to specify the necessary properties through a module parameter, allows users of new device-models to help us with bringing up support for new devices without them needing to do a local kernel-build just to modify these settings. Signed-off-by: Hans de Goede --- drivers/input/touchscreen/silead.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c index 3eef8c01090f..3a3115702a13 100644 --- a/drivers/input/touchscreen/silead.c +++ b/drivers/input/touchscreen/silead.c @@ -58,6 +58,10 @@ #define SILEAD_MAX_FINGERS 10 +static char *settings; +module_param(settings, charp, 0444); +MODULE_PARM_DESC(settings, "Override touchscreen settings using a ; separated key=value list, e.g. \"touchscreen-size-x=1665;touchscreen-size-y=1140;touchscreen-swapped-x-y\""); + enum silead_ts_power { SILEAD_POWER_ON = 1, SILEAD_POWER_OFF = 0 @@ -133,14 +137,15 @@ static int silead_ts_request_input_dev(struct silead_ts_data *data) input_set_abs_params(data->input, ABS_MT_POSITION_X, 0, 4095, 0, 0); input_set_abs_params(data->input, ABS_MT_POSITION_Y, 0, 4095, 0, 0); - touchscreen_parse_properties(data->input, true, &data->prop); + touchscreen_parse_properties_with_settings(data->input, true, + &data->prop, settings); silead_apply_efi_fw_min_max(data); input_mt_init_slots(data->input, data->max_fingers, INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED | INPUT_MT_TRACK); - if (device_property_read_bool(dev, "silead,home-button")) + if (touchscreen_property_read_bool(dev, "silead,home-button", settings)) input_set_capability(data->input, EV_KEY, KEY_LEFTMETA); data->input->name = SILEAD_TS_NAME; @@ -173,7 +178,8 @@ static int silead_ts_request_pen_input_dev(struct silead_ts_data *data) input_set_capability(data->pen_input, EV_KEY, BTN_TOUCH); input_set_capability(data->pen_input, EV_KEY, BTN_TOOL_PEN); set_bit(INPUT_PROP_DIRECT, data->pen_input->propbit); - touchscreen_parse_properties(data->pen_input, false, &data->prop); + touchscreen_parse_properties_with_settings(data->pen_input, false, + &data->prop, settings); input_abs_set_res(data->pen_input, ABS_X, data->pen_x_res); input_abs_set_res(data->pen_input, ABS_Y, data->pen_y_res); @@ -523,8 +529,8 @@ static int silead_ts_setup(struct i2c_client *client) * this. */ - if (device_property_read_bool(&client->dev, - "silead,stuck-controller-bug")) { + if (touchscreen_property_read_bool(&client->dev, "silead,stuck-controller-bug", + settings)) { pm_runtime_set_active(&client->dev); pm_runtime_enable(&client->dev); pm_runtime_allow(&client->dev); @@ -591,8 +597,8 @@ static void silead_ts_read_props(struct i2c_client *client) const char *str; int error; - error = device_property_read_u32(dev, "silead,max-fingers", - &data->max_fingers); + error = touchscreen_property_read_u32(dev, "silead,max-fingers", settings, + &data->max_fingers); if (error) { dev_dbg(dev, "Max fingers read error %d\n", error); data->max_fingers = 5; /* Most devices handle up-to 5 fingers */ @@ -605,9 +611,9 @@ static void silead_ts_read_props(struct i2c_client *client) else dev_dbg(dev, "Firmware file name read error. Using default."); - data->pen_supported = device_property_read_bool(dev, "silead,pen-supported"); - device_property_read_u32(dev, "silead,pen-resolution-x", &data->pen_x_res); - device_property_read_u32(dev, "silead,pen-resolution-y", &data->pen_y_res); + data->pen_supported = touchscreen_property_read_bool(dev, "silead,pen-supported", settings); + touchscreen_property_read_u32(dev, "silead,pen-resolution-x", settings, &data->pen_x_res); + touchscreen_property_read_u32(dev, "silead,pen-resolution-y", settings, &data->pen_y_res); } #ifdef CONFIG_ACPI From patchwork Tue Oct 25 12:29:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13019128 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02122C38A2D for ; Tue, 25 Oct 2022 12:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231656AbiJYM3q (ORCPT ); Tue, 25 Oct 2022 08:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231696AbiJYM3n (ORCPT ); Tue, 25 Oct 2022 08:29:43 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E17311F484 for ; Tue, 25 Oct 2022 05:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666700981; 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=0OGoyHtqnmD9ACt9x2y6qnsRK8WGuXI56KZ+SPguV7A=; b=BCz1T3F3Kmk6XXbo42I92f58Z45kZPAydKS4GZ4zf3ZvZ1JUHRyvKuIxHXgVWtlkX+N3y1 z6O/KueYpZm0pmOLeXyRS3AtPzzOKoC4CmjS1OdEG3xVxMbwvioUAknRPAvnnGCuA5aS1x PCt8zdwpehbJuEi/tp3I8UNahal6CCY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-382-O9Rv6JDRNr2cozZVblRTWg-1; Tue, 25 Oct 2022 08:29:38 -0400 X-MC-Unique: O9Rv6JDRNr2cozZVblRTWg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CAB1C823F65; Tue, 25 Oct 2022 12:29:37 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.195.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 196BD492CA4; Tue, 25 Oct 2022 12:29:36 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , Bastien Nocera , linux-input@vger.kernel.org Subject: [PATCH 4/4] Input: goodix - Add a settings module-parameter Date: Tue, 25 Oct 2022 14:29:30 +0200 Message-Id: <20221025122930.421377-5-hdegoede@redhat.com> In-Reply-To: <20221025122930.421377-1-hdegoede@redhat.com> References: <20221025122930.421377-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Add a settings module-parameter which can be allowed to specify/override various device-properties. Usuually Goodix touchscreens on x86 devices (where there is no devicetree to specify the properties) just work. But in some cases the touchscreen is mounted 90 or 180 degrees rotated vs the display, requiring setting the touchscreen-x/y-inverted or touchscreen-swapped-x-y properties. Being able to specify the necessary properties through a module parameter, allows users of new device-models to help us with bringing up support for new devices without them needing to do a local kernel-build just to modify these settings. Reviewed-by: Bastien Nocera Signed-off-by: Hans de Goede --- drivers/input/touchscreen/goodix.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index c281e49826c2..36873f053f63 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -53,6 +53,10 @@ #define ACPI_GPIO_SUPPORT #endif +static char *settings; +module_param(settings, charp, 0444); +MODULE_PARM_DESC(settings, "Override touchscreen settings using a ; separated key=value list, e.g. \"touchscreen-fuzz-x=5;touchscreen-fuzz-y=5;touchscreen-swapped-x-y\""); + struct goodix_chip_id { const char *id; const struct goodix_chip_data *data; @@ -1163,7 +1167,8 @@ static int goodix_configure_dev(struct goodix_ts_data *ts) goodix_read_config(ts); /* Try overriding touchscreen parameters via device properties */ - touchscreen_parse_properties(ts->input_dev, true, &ts->prop); + touchscreen_parse_properties_with_settings(ts->input_dev, true, + &ts->prop, settings); if (!ts->prop.max_x || !ts->prop.max_y || !ts->max_touch_num) { if (!ts->reset_controller_at_probe &&