Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4528272pxu; Wed, 9 Dec 2020 21:28:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQjyi4+y8tZ+CE6lLGJ5CMi0WeetQTwFpMLey3M9ZgFSQ+eOXN73i87tqbxjN2SxQdlfVA X-Received: by 2002:a17:906:38c3:: with SMTP id r3mr4955521ejd.193.1607578116123; Wed, 09 Dec 2020 21:28:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607578116; cv=none; d=google.com; s=arc-20160816; b=hEj85IEgQerMumGK5xQP5iJlgr2TiG3QXtQZof/SJYB2l4jElFpcUIGIGm/rxiXUue xFc3+uzsanaxjqcHJVEmu+hJuUKXZFC56s7TZfbCS6SawEz8nXAr5TfJlSJwhGUa91IR 8Vtgz8sWIql2cJdn+CiBZYGfKZhjyc4fmmVbhbLnomfyTWXa5hm7bui9V/9yFMqf9bVw snjbsXLua/+1tSxBtjHocxDMFwIKQ8tTjn4vytB7INN74vIFmVPnrB74ksXubIwDY0QX pcofXjh76WGhd8jeJaFcjRSdFixuLFVNmi0oNrS/S2ITBq1/wePMFMpMGnh2h8c9KAIy 8HLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=RllWjXmt24+TR71iaZkso9VeRpDv2hfIa/LswWV4QMM=; b=ICb22HTK+y+3ENakwJNtTh7H227OOw2/CNIQijAHEgZWmj8g4IcwJ+PkS4lYvZ2Wht sa3PJNEQYBdhYB6MpkGPYGw3tvHj2rL06QzA/qTkRFsqL88C88/ZtpHetqXcQjjA4+i/ jnxWGkxllQh5Fx6myJ4tUVusjgO1m2UgxZvi941sC04lBmGqe6vvP3kSZAn7+3rT7pyb bSBt7oVM3Z2AhtcKAc4uf5oux72kAgyoKlpAcKg1KO9WrQPq3IxHhcDyMGNoyMESx4V2 shxZxxXDC9bCN8SdhWX0e+Yiftd0xKIty3K1WYZxqWhp7c3FpXq2+aT75uQrF3JayWTb lNQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="pybgsXa/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce16si2085086edb.238.2020.12.09.21.28.00; Wed, 09 Dec 2020 21:28:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="pybgsXa/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728336AbgLIXJz (ORCPT + 99 others); Wed, 9 Dec 2020 18:09:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727028AbgLIXJz (ORCPT ); Wed, 9 Dec 2020 18:09:55 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA5F9C0613CF; Wed, 9 Dec 2020 15:09:14 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id w5so1581909pgj.3; Wed, 09 Dec 2020 15:09:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=RllWjXmt24+TR71iaZkso9VeRpDv2hfIa/LswWV4QMM=; b=pybgsXa/SwpSGRNtfyTJe/9ribuitvtHQM7OfiXiNg/Y5qSmkr0bvRuRDj6tQ38nS7 sQsq/G762XhtkbL1+KRDGUWB166ZYkK558C0XpcJPS+RIiwmDcmaDCr/zi1pZehugIWe xblZ+CYMo4Ky2cYGWhj8j/gZRL9WDZFiKKMxv+m1V9oqsp/qlnbt/WkBdghGGkJBlhkt eChO7aT3bloG4FmioJxVtYOBg/d8xVppPQosGydLwvWZqRhLXhMy0mGxEH+hKCxUHuoc 6Pt/2xCQ3QCrrHq1PzpDrWqTPguLQHsTKw2RfIahLbOJeUdwQxCRjJWL2BRKqzhpvE3H /s8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=RllWjXmt24+TR71iaZkso9VeRpDv2hfIa/LswWV4QMM=; b=GqyJX3Nx7B/1wmUxppT3+GppYAk9DKYhmHBoXjG6vO8fnzbQG5dPXYg3N/lCEUOTMx Z+agvUjp+M3Fl4x75vAE2+B23tHH7uBwQpu5qffjUhhSNiMXaBe8lWmC8e6txSqM739N 14GEyZsZMaSr7J0cSYumL4VV/s0NwFzRV2N0U9k/P0prs2I10TLTPJ8fDsvSYzAC8Mm5 F23w1+zD9/YYGj8b4+KJqHicmbbfIDxpKr8TtMrK3NGTSYKuuK37RP5Je5lAQ/upKacA fbnQ8ht3KuPWqyX/X19JcSVcCwBSOKabPklbJL3Ev7Hu5XNrDtCu1j4mPyz288dTwIWC agLw== X-Gm-Message-State: AOAM532h0y2PF7MK/UcEgP+wOMkLBlot2KnJpnaS6aa5K3V2+IlqjrRA 3p38UiG+pzFOggviQoV/0TLOFWv3EAY= X-Received: by 2002:a05:6a00:acc:b029:198:2ba6:c0f6 with SMTP id c12-20020a056a000accb02901982ba6c0f6mr4226061pfl.53.1607555354006; Wed, 09 Dec 2020 15:09:14 -0800 (PST) Received: from google.com ([2620:15c:202:201:a6ae:11ff:fe11:fcc3]) by smtp.gmail.com with ESMTPSA id r15sm3589246pgn.26.2020.12.09.15.09.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Dec 2020 15:09:12 -0800 (PST) Date: Wed, 9 Dec 2020 15:09:10 -0800 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Marco Felsch , Andy Shevchenko , Philipp Zabel , Simon Budig , linux-kernel@vger.kernel.org Subject: [PATCH] Input: edt-ft5x06 - consolidate handling of number of electrodes Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of using special-casing retrieval of number of X/Y electrodes based on the firmware, let's select default values and mark registers as non-existent on firmwares that do not support this operation. Also mark "report rate" register as non-existent for generic firmwares as having it set to 0 does not make sense. Signed-off-by: Dmitry Torokhov --- drivers/input/touchscreen/edt-ft5x06.c | 43 ++++++++++---------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 6ff81d48da86..2eefbc2485bc 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -69,6 +69,9 @@ #define EDT_RAW_DATA_RETRIES 100 #define EDT_RAW_DATA_DELAY 1000 /* usec */ +#define EDT_DEFAULT_NUM_X 1024 +#define EDT_DEFAULT_NUM_Y 1024 + enum edt_pmode { EDT_PMODE_NOT_SUPPORTED, EDT_PMODE_HIBERNATE, @@ -977,8 +980,7 @@ static void edt_ft5x06_ts_get_defaults(struct device *dev, } } -static void -edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) +static void edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) { struct edt_reg_addr *reg_addr = &tsdata->reg_addr; @@ -997,21 +999,17 @@ edt_ft5x06_ts_get_parameters(struct edt_ft5x06_ts_data *tsdata) if (reg_addr->reg_report_rate != NO_REGISTER) tsdata->report_rate = edt_ft5x06_register_read(tsdata, reg_addr->reg_report_rate); - if (tsdata->version == EDT_M06 || - tsdata->version == EDT_M09 || - tsdata->version == EDT_M12) { + tsdata->num_x = EDT_DEFAULT_NUM_X; + if (reg_addr->reg_num_x != NO_REGISTER) tsdata->num_x = edt_ft5x06_register_read(tsdata, reg_addr->reg_num_x); + tsdata->num_y = EDT_DEFAULT_NUM_Y; + if (reg_addr->reg_num_y != NO_REGISTER) tsdata->num_y = edt_ft5x06_register_read(tsdata, reg_addr->reg_num_y); - } else { - tsdata->num_x = -1; - tsdata->num_y = -1; - } } -static void -edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) +static void edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) { struct edt_reg_addr *reg_addr = &tsdata->reg_addr; @@ -1041,22 +1039,25 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) case EV_FT: reg_addr->reg_threshold = EV_REGISTER_THRESHOLD; + reg_addr->reg_report_rate = NO_REGISTER; reg_addr->reg_gain = EV_REGISTER_GAIN; reg_addr->reg_offset = NO_REGISTER; reg_addr->reg_offset_x = EV_REGISTER_OFFSET_X; reg_addr->reg_offset_y = EV_REGISTER_OFFSET_Y; reg_addr->reg_num_x = NO_REGISTER; reg_addr->reg_num_y = NO_REGISTER; - reg_addr->reg_report_rate = NO_REGISTER; break; case GENERIC_FT: /* this is a guesswork */ reg_addr->reg_threshold = M09_REGISTER_THRESHOLD; + reg_addr->reg_report_rate = NO_REGISTER; reg_addr->reg_gain = M09_REGISTER_GAIN; reg_addr->reg_offset = M09_REGISTER_OFFSET; reg_addr->reg_offset_x = NO_REGISTER; reg_addr->reg_offset_y = NO_REGISTER; + reg_addr->reg_num_x = NO_REGISTER; + reg_addr->reg_num_y = NO_REGISTER; break; } } @@ -1195,20 +1196,10 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, input->id.bustype = BUS_I2C; input->dev.parent = &client->dev; - if (tsdata->version == EDT_M06 || - tsdata->version == EDT_M09 || - tsdata->version == EDT_M12) { - input_set_abs_params(input, ABS_MT_POSITION_X, - 0, tsdata->num_x * 64 - 1, 0, 0); - input_set_abs_params(input, ABS_MT_POSITION_Y, - 0, tsdata->num_y * 64 - 1, 0, 0); - } else { - /* Unknown maximum values. Specify via devicetree */ - input_set_abs_params(input, ABS_MT_POSITION_X, - 0, 65535, 0, 0); - input_set_abs_params(input, ABS_MT_POSITION_Y, - 0, 65535, 0, 0); - } + input_set_abs_params(input, ABS_MT_POSITION_X, + 0, tsdata->num_x * 64 - 1, 0, 0); + input_set_abs_params(input, ABS_MT_POSITION_Y, + 0, tsdata->num_y * 64 - 1, 0, 0); touchscreen_parse_properties(input, true, &tsdata->prop); -- 2.29.2.576.ga3fc446d84-goog -- Dmitry