From patchwork Wed Oct 7 12:21:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin Cooper X-Patchwork-Id: 7344871 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D451FBEEA4 for ; Wed, 7 Oct 2015 12:24:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CFD1B2072B for ; Wed, 7 Oct 2015 12:24:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB6D9205CB for ; Wed, 7 Oct 2015 12:24:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752190AbbJGMYl (ORCPT ); Wed, 7 Oct 2015 08:24:41 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:33660 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751641AbbJGMWM (ORCPT ); Wed, 7 Oct 2015 08:22:12 -0400 Received: by oiev17 with SMTP id v17so844788oie.0; Wed, 07 Oct 2015 05:22:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:subject:date:message-id:in-reply-to:references; bh=ROueoI3kgF2LhLp7KOOZVg4xe3L66F48uXaycqLr7oo=; b=m12X+XPS1g0Bch7w2JveZBhJ4LPFKcxyEctUV5J8vStdAZyWX6GroYXr5P2/U/qDBK +Y3/aCzAcEFuloDeIUGLLJXJ8j9Z+TAMvpCHKpc5mC0v/9Yx6WhegCu6ut7gnO8IOXff Ux37ApoiJ/03ZgV/Tyvvnw/6DA7/kELZlgTkDyJEvdl9eSm1SKXzNdU7ok/Ww+Hq74Mq Jf+Xx3eTx8V4DuSxeXhtDI+fTI7ZVQ+6XN0ejhAFvMGJUw3lP5gCsNOb2fH/JOHQl8uA WgXZb1oYlgTdArchvdTYWlRfZUgyYepLZq9mHjjW4B32aPVDnzVOZd62Ofm452k+V4Ud wEvg== X-Received: by 10.202.0.206 with SMTP id 197mr422615oia.76.1444220531642; Wed, 07 Oct 2015 05:22:11 -0700 (PDT) Received: from localhost.localdomain (pool-71-97-41-79.dllstx.fios.verizon.net. [71.97.41.79]) by smtp.gmail.com with ESMTPSA id k5sm16407235oev.16.2015.10.07.05.22.11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Oct 2015 05:22:11 -0700 (PDT) From: fcooper@ti.com To: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, fcooper@ti.com, maxime.ripard@free-electrons.com, LW@KARO-electronics.de, jg1.han@samsung.com, asaf.vertz@tandemg.com Subject: [RFC 2/4] Input: edt-ft5x06 - Add support for different max support points Date: Wed, 7 Oct 2015 07:21:39 -0500 Message-Id: <1444220501-23623-3-git-send-email-fcooper@ti.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1444220501-23623-1-git-send-email-fcooper@ti.com> References: <1444220501-23623-1-git-send-email-fcooper@ti.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Franklin S Cooper Jr Update the code so that the maximum supported points aren't hard coded but can be changed. Set the maximum support points based on the data passed along side the compatible field. Signed-off-by: Franklin S Cooper Jr --- drivers/input/touchscreen/edt-ft5x06.c | 56 ++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c index 1e0ed6e..8031152 100644 --- a/drivers/input/touchscreen/edt-ft5x06.c +++ b/drivers/input/touchscreen/edt-ft5x06.c @@ -38,8 +38,7 @@ #include #include #include - -#define MAX_SUPPORT_POINTS 5 +#include #define WORK_REGISTER_THRESHOLD 0x00 #define WORK_REGISTER_REPORT_RATE 0x08 @@ -105,6 +104,7 @@ struct edt_ft5x06_ts_data { int gain; int offset; int report_rate; + int max_support_points; char name[EDT_NAME_LEN]; @@ -112,6 +112,10 @@ struct edt_ft5x06_ts_data { enum edt_ver version; }; +struct edt_i2c_chip_data { + int max_support_points; +}; + static int edt_ft5x06_ts_readwrite(struct i2c_client *client, u16 wr_len, u8 *wr_buf, u16 rd_len, u8 *rd_buf) @@ -180,14 +184,14 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) tplen = 4; /* data comes in so called frames */ /* how many bytes to listen for */ - datalen = tplen * MAX_SUPPORT_POINTS + offset + 1; + datalen = tplen * tsdata->max_support_points + offset + 1; break; case M09: cmd = 0x02; offset = 1; tplen = 6; - datalen = tplen * MAX_SUPPORT_POINTS - cmd + 1; + datalen = tplen * tsdata->max_support_points - cmd + 1; break; default: @@ -219,7 +223,7 @@ static irqreturn_t edt_ft5x06_ts_isr(int irq, void *dev_id) goto out; } - for (i = 0; i < MAX_SUPPORT_POINTS; i++) { + for (i = 0; i < tsdata->max_support_points; i++) { u8 *buf = &rdbuf[i * tplen + offset]; bool down; @@ -872,6 +876,32 @@ edt_ft5x06_ts_set_regs(struct edt_ft5x06_ts_data *tsdata) } } +#ifdef CONFIG_OF + +static const struct of_device_id edt_ft5x06_of_match[]; + +static void edt_ft5x06_ts_set_max_support_points(struct device *dev, + struct edt_ft5x06_ts_data *tsdata) +{ + struct edt_i2c_chip_data *chip_data; + const struct of_device_id *match; + + match = of_match_device(of_match_ptr(edt_ft5x06_of_match), dev); + + if (match) { + chip_data = (struct edt_i2c_chip_data *)match->data; + tsdata->max_support_points = chip_data->max_support_points; + } else { + tsdata->max_support_points = 5; + } +} +#else +static void edt_ft5x06_ts_set_max_support_points(struct device *dev, + struct edt_ft5x06_ts_data *tsdata) +{ +} +#endif + static int edt_ft5x06_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -889,6 +919,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, return -ENOMEM; } + edt_ft5x06_ts_set_max_support_points(&client->dev, tsdata); + tsdata->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(tsdata->reset_gpio)) { @@ -954,7 +986,8 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client, touchscreen_parse_properties(input, true); - error = input_mt_init_slots(input, MAX_SUPPORT_POINTS, INPUT_MT_DIRECT); + error = input_mt_init_slots(input, tsdata->max_support_points, + INPUT_MT_DIRECT); if (error) { dev_err(&client->dev, "Unable to init MT slots.\n"); return error; @@ -1039,10 +1072,15 @@ static const struct i2c_device_id edt_ft5x06_ts_id[] = { MODULE_DEVICE_TABLE(i2c, edt_ft5x06_ts_id); #ifdef CONFIG_OF + +static const struct edt_i2c_chip_data edt_ft5x06_data = { + .max_support_points = 5, +}; + static const struct of_device_id edt_ft5x06_of_match[] = { - { .compatible = "edt,edt-ft5206", }, - { .compatible = "edt,edt-ft5306", }, - { .compatible = "edt,edt-ft5406", }, + { .compatible = "edt,edt-ft5206", .data = &edt_ft5x06_data}, + { .compatible = "edt,edt-ft5306", .data = &edt_ft5x06_data}, + { .compatible = "edt,edt-ft5406", .data = &edt_ft5x06_data}, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, edt_ft5x06_of_match);