From patchwork Wed Mar 25 13:33:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 11457835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D414139A for ; Wed, 25 Mar 2020 13:36:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 66E782076A for ; Wed, 25 Mar 2020 13:36:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727950AbgCYNgJ (ORCPT ); Wed, 25 Mar 2020 09:36:09 -0400 Received: from esa3.mentor.iphmx.com ([68.232.137.180]:53226 "EHLO esa3.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727544AbgCYNgI (ORCPT ); Wed, 25 Mar 2020 09:36:08 -0400 IronPort-SDR: /z5pA4r/pg2NS3AF4zaz10hMWqAfS5vqDvQQlxsfJ+7gaG4+VM1SBmzS8ZbO75fSzjrMfbKcpm tNPWqRE1R2bPhnwdQnjyFsRFpj02O5K3Vafo/BvDFDvfb1ilFb61RHTof3Bgys/zuVnikNxog2 veSKKnoqEYBF/XbQ+fZV5Xk3Bgn1nUxX/kFQzjMP7CAungETBgaehn0aKo8T0s4oYUv+T2DMvv UBUiDCWz8wm4bHy3crT4YcwWu+7s9VkOZSUNq3cFkr0lgM/aO4diLoUMYc+L0YTkOy2ecUJobR pnw= X-IronPort-AV: E=Sophos;i="5.72,304,1580803200"; d="scan'208";a="47099757" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 25 Mar 2020 05:35:56 -0800 IronPort-SDR: Z3uc42m8b8mGimkxQj08t8SFPCT2N/JR8MYjvPdQKOICx31m/XJkCDas3JHklnqsvjiGEohV/o 8Av6V6VT2nfalhdwZtB5eZlelSfVwrk74UnuAYsc3QQow2BcbOTHw6Wr3f+fuhCP29AftHKciX iEix/e47tMEk1sC/qjNx+h8CZRluTF/5CHtle2a9PWZbxRHWEO+90TmQ2Y3O/Z0bwZAAKMhWKB ZtjIpI5Dp/GoAwOQx2omZYyXVay+0yBsX/STYM/WQiyTShJuhnGPpGts2+pQVrWKReQC3MiJlq dEE= From: Jiada Wang To: , , , , , CC: , , , , Subject: [PATCH v9 34/55] Input: atmel_mxt_ts - implement debug output for messages Date: Wed, 25 Mar 2020 06:33:13 -0700 Message-ID: <20200325133334.19346-35-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200325133334.19346-1-jiada_wang@mentor.com> References: <20200325133334.19346-1-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: Nick Dyer Add a debug switch which causes all messages from the touch controller to be dumped to the dmesg log with a set prefix "MXT MSG:". This is used by Atmel user-space utilities to debug touch operation. Enabling this output does impact touch performance. Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit 3c3fcfdd4889dfeb1c80ae8cd94a622c6342b06a) [gdavis: Forward port and fix conflicts.] Signed-off-by: George G. Davis [jiada: Rename mxt_debug_enable_store to debug_enable_store Rename mxt_debug_enable_show to debug_enable_show Replace DEVICE_ATTR with DEVICE_ATTR_RW] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 46 ++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index b1f54bf207b8..656d956f9c93 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -335,6 +335,7 @@ struct mxt_data { u8 t100_aux_ampl; u8 t100_aux_area; u8 t100_aux_vect; + bool debug_enabled; u8 max_reportid; u32 config_crc; u32 info_crc; @@ -460,8 +461,11 @@ static bool mxt_object_readable(unsigned int type) static void mxt_dump_message(struct mxt_data *data, u8 *message) { - dev_dbg(&data->client->dev, "message: %*ph\n", - data->T5_msg_size, message); + /* debug message with prefix 'MXT MSG:' used by + * Atmel user-space utilities to debug touch operation + */ + dev_dbg(&data->client->dev, "MXT MSG: %*ph\n", + data->T5_msg_size, message); } static int mxt_wait_for_completion(struct mxt_data *data, @@ -1211,6 +1215,7 @@ static void mxt_proc_t93_messages(struct mxt_data *data, u8 *msg) static int mxt_proc_message(struct mxt_data *data, u8 *message) { u8 report_id = message[0]; + bool dump = data->debug_enabled; if (report_id == MXT_RPTID_NOMSG) return 0; @@ -1245,9 +1250,12 @@ static int mxt_proc_message(struct mxt_data *data, u8 *message) } else if (report_id == data->T93_reportid) { mxt_proc_t93_messages(data, message); } else { - mxt_dump_message(data, message); + dump = true; } + if (dump) + mxt_dump_message(data, message); + return 1; } @@ -3519,6 +3527,36 @@ static ssize_t update_cfg_store(struct device *dev, return ret; } +static ssize_t debug_enable_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct mxt_data *data = dev_get_drvdata(dev); + char c; + + c = data->debug_enabled ? '1' : '0'; + return scnprintf(buf, PAGE_SIZE, "%c\n", c); +} + +static ssize_t debug_enable_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct mxt_data *data = dev_get_drvdata(dev); + u8 i; + ssize_t ret; + + if (kstrtou8(buf, 0, &i) == 0 && i < 2) { + data->debug_enabled = (i == 1); + + dev_dbg(dev, "%s\n", i ? "debug enabled" : "debug disabled"); + ret = count; + } else { + dev_dbg(dev, "debug_enabled write error\n"); + ret = -EINVAL; + } + + return ret; +} + static DEVICE_ATTR_WO(update_fw); static struct attribute *mxt_fw_attrs[] = { @@ -3535,6 +3573,7 @@ static DEVICE_ATTR_RO(hw_version); static DEVICE_ATTR(object, S_IRUGO, mxt_object_show, NULL); static DEVICE_ATTR_WO(update_cfg); static DEVICE_ATTR_RO(config_crc); +static DEVICE_ATTR_RW(debug_enable); static struct attribute *mxt_attrs[] = { &dev_attr_fw_version.attr, @@ -3542,6 +3581,7 @@ static struct attribute *mxt_attrs[] = { &dev_attr_object.attr, &dev_attr_update_cfg.attr, &dev_attr_config_crc.attr, + &dev_attr_debug_enable.attr, NULL };