From patchwork Sun Apr 2 20:09:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2850 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 3AB4A3F330 for ; Sun, 2 Apr 2023 22:10:27 +0200 (CEST) Received: by mail-ed1-f72.google.com with SMTP id k14-20020a508ace000000b005024a8cef5csf27156427edk.22 for ; Sun, 02 Apr 2023 13:10:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1680466227; cv=pass; d=google.com; s=arc-20160816; b=itsMcNLV3fcTqRv3t4wzVSCqa/+/Hxi14DdqdnGmo4/se0oYw4bd7VY5OCgbeSw9QR l/EqGrvKig5yhtTrIgTV8wqnTTztpGGvww2EnMRvbl3H7zxtvZ7zzSAetl2N7y/dvTaA IAeojWId6Zs1c3/s4gbfARMY9OaVfViE5yK7XE9fBs6/5gNCS+aoAvjB4Tt7Ae3sJ7ld YpeQKzNrH8iwC7hClYiWBnWySWoUezTlZ5wgv2tGL8dEZqyTGN7F9kw5Y6SFBLffy9zH GF8cD5znHazsLk9b4ASuBDK+zH5EQZwkzhQ79WPq1ssyruBipeRCkMo4ot0oXnVs+WiT 9PqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=ZdIN97FOGaeK9g7TRdA4p2V5boMt7VyLB2a5XDPpxy0=; b=nqosn+CUWHlrV63ziwSTssz083nGSpRBJr7G+paqadaIFEWHLOkTFs3IBzTpKm3zxN O7RLVjHdUsMrY1wuJbeU/ttyJpY/8yi68Fu0JKiVxDCBBF78cucsVW6JZU/YEXkZzpZV QnYkwQruvJ4DDJfFyn8N/hTVPBGOHDyZQzbAH75Fb90sq5E9Hxuv/GSCY6M0xYiFtdWY IlKpi1QiaaStmn+RmlR5sON5XWXh9U3pYregHK7iHA9lSOS5aTMBbhvYloMEDazSlUI1 j11B3oMbeT5agOYTAYyDAseAJrENqMEr7mQyTe/JOu9fGcNWOiHdTauAfC9cAsuMC7C2 MnmA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KemN7IfE; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680466227; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZdIN97FOGaeK9g7TRdA4p2V5boMt7VyLB2a5XDPpxy0=; b=OAPZlBg0llUN9KfxuQdR9m/XxPnkWua6XTchjenQ9HZriq+4PcQwynFEcCgq1F56pd 999MLZKJlKVIlhrNlheHzl6WWRBzLXPvn8BHzHmAG7DgyYrvkkMkiaHdtYDA0fQBdcdX 3bsWLOabZPHmbbPOBJieO+EO0mjI8PO4WXCyM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680466227; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZdIN97FOGaeK9g7TRdA4p2V5boMt7VyLB2a5XDPpxy0=; b=A6Wl5MCzgX3TWTYzrkIkcWZoE+RPh/u8N/ielhJdSfxblGuKLQzBHrnL+EfXwwz6kP zh1wKbmWQVsXXZ7jJjSpS7BkdesYhcdXZ8WDwI/w0AY2knkVCXIir56DcKlSs3nJYqEJ i28+Ksyf/HigRL6qSZU/AB3Lj6W/ybjtcpInT2QAqLh2fZ/SqcA41/jJm+2IB2GrUSl6 vKxGyWdoyLuzY/TFQfzZCmNzXbjO5ZCaBdqrRnSpf8uUrAXPQF6O9tEzrI4Btm95gjUi ngFzHUV9NIKrBtb51LM4br5vZgtq3r63rWnY6LlOiDqEZxVtVhlYus5/d9CJIlYjrSB9 gv3Q== X-Gm-Message-State: AAQBX9fDVhQYqU2SRWeK/FOZMfoDvXSiMKNQT6ZWse8vzKDOKUyhn7V7 zKGppt53bDyrDg4+vKUwuQzA0sUe X-Google-Smtp-Source: AKy350Z8Wn2ue9nxfK8VQvCKV+QXduoe+HS6iqkiNnPv6vu7jxEAT7PWaNct+r7cW21n7yQqHitPwg== X-Received: by 2002:a17:906:da81:b0:93f:82cb:fe44 with SMTP id xh1-20020a170906da8100b0093f82cbfe44mr15867729ejb.11.1680466227120; Sun, 02 Apr 2023 13:10:27 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:1b02:b0:934:1f7e:b3c0 with SMTP id mp2-20020a1709071b0200b009341f7eb3c0ls4642356ejc.2.-pod-prod-gmail; Sun, 02 Apr 2023 13:10:26 -0700 (PDT) X-Received: by 2002:a17:907:9d1a:b0:8a5:8620:575 with SMTP id kt26-20020a1709079d1a00b008a586200575mr33230165ejc.3.1680466225300; Sun, 02 Apr 2023 13:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680466225; cv=none; d=google.com; s=arc-20160816; b=P39Iz18WE3/P7CT9Gu4sbIYN8NV2ZIlDw2SlnmTZlpq4uhZTAewW2m62eHjBnnrrkm Ck52/dDTgWcINguJ4v91X4dq+9LigwLfvqMd7oO0FjtGzwmzRD/POHudvTv3l+XEVmD5 NW5DuuP2khmOV8DGlwdUUAB06qUn1wkTehaAXiTmIYndkIC8GsQBsypilHCbBWxGQq9V DGq9vaO0ic0rjijmzfQlnFK2ZsPmWeC52SLEYspB+xC8DhO4lSt14CLl0AEqrV9/ZeG0 hB6ma8swinPHaBfoC4D4sXlAMt30WtpU+5Dv+4QfVb2UCX0Vd0JF/zb0DGPkAu1+aqOl 8Q9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=YKRIdGHuZOd/fQcotLl6knbHASupHjbM4BeF84H3jy8=; b=aM/YDeUc60uGc3aFUZuVGx+LqUjThGw2RhXzpyXaBEApgxSQbQCd/m+xe8MrGD7G+/ o36PflXVl67whOG0YLlbLO9sm8rGSdFp4Dkb2ERtNgZ+rjWq0jmdCO1a13kDOXdrRku+ uaXd+eqnNLgBCciN4tq+T7D6vzNODGXFI1r/a38fSVJB2um+fqEi4WTthBZEoUEa8zJq S8+0FRu3vqdwd3QA38cgzUYKp0lVcLNcsso3xMhU63ASmIm5XoBG6sbgqz7W8FsJA2o9 6pW2bISn1NesW1XWCx5g2WZEjMjT8OYQOuIMXsnAHNRG0DP0xrR7hQSCfgog14Y+PA6t /jHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KemN7IfE; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id hq33-20020a1709073f2100b008b17aa9ce7fsor4047292ejc.99.2023.04.02.13.10.25 for (Google Transport Security); Sun, 02 Apr 2023 13:10:25 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:906:4796:b0:93f:3084:d6f with SMTP id cw22-20020a170906479600b0093f30840d6fmr34022998ejc.18.1680466224998; Sun, 02 Apr 2023 13:10:24 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-95-248-31-153.retail.telecomitalia.it. [95.248.31.153]) by smtp.gmail.com with ESMTPSA id gl18-20020a170906e0d200b00924d38bbdc0sm3553127ejb.105.2023.04.02.13.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 13:10:24 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, Dario Binacchi , Dmitry Torokhov , Jonathan Cameron , Oliver Graute , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Wolfram Sang , linux-input@vger.kernel.org Subject: [PATCH 9/9] Input: edt-ft5x06: Calculate points data length only once Date: Sun, 2 Apr 2023 22:09:51 +0200 Message-Id: <20230402200951.1032513-10-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> References: <20230402200951.1032513-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KemN7IfE; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , It is pointless and expensive to calculate data in the interrupt that depends on the type of touchscreen, which is detected on the driver probe and cannot then be changed. So calculate the size of the data buffer on the driver probe, as well as the data retrieval command, and then use them in the ISR. Signed-off-by: Dario Binacchi --- drivers/input/touchscreen/edt-ft5x06.c | 56 +++++++++++++------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index fdb32e3591be..24ab9e9f5b21 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -135,6 +135,10 @@ struct edt_ft5x06_ts_data { int offset_y; int report_rate; int max_support_points; + int point_len; + u8 tdata_cmd; + int tdata_len; + int tdata_offset; char name[EDT_NAME_LEN]; char fw_version[EDT_NAME_LEN]; @@ -296,38 +300,13 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) { struct edt_ft5x06_ts_data *tsdata = dev_id; struct device *dev = &tsdata->client->dev; - u8 cmd; u8 rdbuf[63]; int i, type, x, y, id; - int offset, tplen, datalen, crclen; int error; - switch (tsdata->version) { - case EDT_M06: - cmd = 0xf9; /* tell the controller to send touch data */ - offset = 5; /* where the actual touch data starts */ - tplen = 4; /* data comes in so called frames */ - crclen = 1; /* length of the crc data */ - break; - - case EDT_M09: - case EDT_M12: - case EV_FT: - case GENERIC_FT: - cmd = 0x0; - offset = 3; - tplen = 6; - crclen = 0; - break; - - default: - goto out; - } - memset(rdbuf, 0, sizeof(rdbuf)); - datalen = tplen * tsdata->max_support_points + offset + crclen; - - error = regmap_bulk_read(tsdata->regmap, cmd, rdbuf, datalen); + error = regmap_bulk_read(tsdata->regmap, tsdata->tdata_cmd, rdbuf, + tsdata->tdata_len); if (error) { dev_err_ratelimited(dev, "Unable to fetch data, error: %d\n", error); @@ -335,7 +314,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) } for (i = 0; i < tsdata->max_support_points; i++) { - u8 *buf = &rdbuf[i * tplen + offset]; + u8 *buf = &rdbuf[i * tsdata->point_len + tsdata->tdata_offset]; type = buf[0] >> 6; /* ignore Reserved events */ @@ -1071,6 +1050,26 @@ static void edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) } } +static void edt_ft5x06_ts_set_tdata_parameters(struct edt_ft5x06_ts_data *tsdata) +{ + int crclen; + + if (tsdata->version == EDT_M06) { + tsdata->tdata_cmd = 0xf9; + tsdata->tdata_offset = 5; + tsdata->point_len = 4; + crclen = 1; + } else { + tsdata->tdata_cmd = 0x0; + tsdata->tdata_offset = 3; + tsdata->point_len = 6; + crclen = 0; + } + + tsdata->tdata_len = tsdata->point_len * tsdata->max_support_points + + tsdata->tdata_offset + crclen; +} + static void edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) { struct edt_reg_addr *reg_addr = &tsdata->reg_addr; @@ -1274,6 +1273,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client) */ regmap_read(tsdata->regmap, 0x00, &val); + edt_ft5x06_ts_set_tdata_parameters(tsdata); edt_ft5x06_ts_set_regs(tsdata); edt_ft5x06_ts_get_defaults(&client->dev, tsdata); edt_ft5x06_ts_get_parameters(tsdata);