From patchwork Thu Oct 20 19:59:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Franklin Cooper X-Patchwork-Id: 9387497 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 009E760487 for ; Thu, 20 Oct 2016 20:00:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF9312957F for ; Thu, 20 Oct 2016 20:00:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFE9D29B5F; Thu, 20 Oct 2016 20:00:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 480AA2957F for ; Thu, 20 Oct 2016 20:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938295AbcJTUAX (ORCPT ); Thu, 20 Oct 2016 16:00:23 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:43940 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936553AbcJTUAN (ORCPT ); Thu, 20 Oct 2016 16:00:13 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id u9KJxukV018331; Thu, 20 Oct 2016 14:59:56 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9KJxuUT018629; Thu, 20 Oct 2016 14:59:56 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Thu, 20 Oct 2016 14:59:55 -0500 Received: from dbdmail01.india.ti.com (dbdmail01.india.ti.com [172.24.162.206]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id u9KJxsbd022607; Thu, 20 Oct 2016 14:59:55 -0500 Received: from udb0273011.am.dhcp.ti.com (udb0273011.am.dhcp.ti.com [128.247.83.33]) by dbdmail01.india.ti.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id u9KJxfb0011145; Fri, 21 Oct 2016 01:29:50 +0530 From: Franklin S Cooper Jr To: , , , , , , , , , , CC: Franklin S Cooper Jr Subject: [PATCH 2/4] Input: goodix - Allow tweaking of configuration file dynamically Date: Thu, 20 Oct 2016 14:59:15 -0500 Message-ID: <20161020195917.20051-3-fcooper@ti.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161020195917.20051-1-fcooper@ti.com> References: <20161020195917.20051-1-fcooper@ti.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some goodix touchscreen controllers don't have the correct configuration firmware for the display panel it is attached to. Therefore, settings such as touchscreen x and y size may need to be passed in via DT and have the panel reprogrammed for the updated touchscreen resolution. This patchset adds support for reading the current configuration firmware on the panel and allowing it to be modified and rewritten back to the device. Currently this function is unused but later patches will make use of it. Signed-off-by: Franklin S Cooper Jr --- drivers/input/touchscreen/goodix.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c index a43c8ca..01e12f8 100644 --- a/drivers/input/touchscreen/goodix.c +++ b/drivers/input/touchscreen/goodix.c @@ -478,6 +478,34 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts) return 0; } +static void goodix_tweak_config(struct goodix_ts_data *ts) +{ + u8 config[GOODIX_CONFIG_MAX_LENGTH]; + int error; + int raw_cfg_len; + u8 check_sum = 0; + + raw_cfg_len = ts->cfg_len - 2; + + error = goodix_i2c_read(ts->client, GOODIX_REG_CONFIG_DATA, + config, ts->cfg_len); + if (error) { + dev_warn(&ts->client->dev, + "Error reading config (%d), avoid tweaking config\n", + error); + return; + } + + check_sum = goodix_calculate_checksum(ts->cfg_len, config); + + config[raw_cfg_len] = check_sum; + config[raw_cfg_len + 1] = 1; + + error = goodix_send_cfg(ts, ts->cfg_len, config); + if (error) + dev_warn(&ts->client->dev, + "Error writing config (%d)\n", error); +} /** * goodix_read_config - Read the embedded configuration of the panel *