Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3626549pxa; Sun, 9 Aug 2020 06:30:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyG0rIrp5sjHU0PlpAGF4wleaxmat64Gu06/TWTEPuk9n1F8/54ztMfRC/EbKrkqtZZg1xh X-Received: by 2002:a17:906:6146:: with SMTP id p6mr18171747ejl.211.1596979802475; Sun, 09 Aug 2020 06:30:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596979802; cv=none; d=google.com; s=arc-20160816; b=vmoubgziAyrjg0bGlt7T+DkKHEO0T2hhbL31qCWk50jw5eACb6oW1Csqz34SsS/Nso QRCinKoFXv2onD7rihPob6jwJZTyEIbrPhdIAb6sEbYVlBjuCvekapPd8Wqnypxvg2c0 umV2ROBTQ00AfuMXIPVXkQARGi5Vz9mMD0cjC1v4AD+ErvDeotWDPP1pU0SUuqocRN3c G77aiXnRaVO0DLxoiyTYXif6iI7sY1A1R9t4ToUCpF2682t528wafYTdP/rTu1qAjI1a cp1waSQTM8+3E/zZp4CGJEWku9lkBq+hYe4tsnFV9pDa5LFRV8ZuItOIuMilWRPJyLnD PRaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HaME3Z5uLAfT5ND31CqQyrNIC7MORGaQXez8ygNaWV4=; b=UiWbUAnLBKNp/PF98gvOhxiR8A/hTpnXMkYjt0kAznORXYGAzqWe3I3mmLNYjmcKXZ 8zs4IqUaGuaMTCObMKCiHk7x5aUegn0B5wPkvHBvZQEhvCqB1RQOOeXKI/ygLB3ZDptI tRFBNgvAHbR647P6pC4y9vLi0OEHxeVq149qlQ8iso8UB0iOgkrFNixGMvwj8pBiPlsX 6ieSKdwI4Yi0k544ATdUKeb6E2p6MpTAUkQdjWnF6QZHOaDrpKW1CxqBwDqg3ZkinRmF nUVOqqMWfp1ATFg6zt3NelYrQ7sKsPhjtlRl+04JNjDtzO1KJ5cJkKrVE93Q74O9iqp0 xCkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NLzytDvk; 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 u19si2149760edd.284.2020.08.09.06.29.40; Sun, 09 Aug 2020 06:30:02 -0700 (PDT) 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=NLzytDvk; 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 S1726705AbgHIN2M (ORCPT + 99 others); Sun, 9 Aug 2020 09:28:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbgHIN2L (ORCPT ); Sun, 9 Aug 2020 09:28:11 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CB25C061756; Sun, 9 Aug 2020 06:28:11 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id x6so3439068pgx.12; Sun, 09 Aug 2020 06:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HaME3Z5uLAfT5ND31CqQyrNIC7MORGaQXez8ygNaWV4=; b=NLzytDvk7e3IFdRRH9He4ucBUq/gJBsZ5qjPWWibdb1MfGRPca7DJwH9ty7kw4aEZf 5ZZjc8vnKRKM8fTrJ3SFD1cPd7SZ4W5GIelKI3FxDDVk0Kbk0pz7LaiS8EzkRc5eIokf wkZ9ikNhpN1shIszAo5UOVmya2/V3cbNiWTdh5hgIwernkWWpNUUPyJS1mwQu5tC8Bn1 S3FPZn4EKO5lDS3bCb3gNDf5ZYuncSahFN6QEoGn0ww73bwcAPDrYsoARC31Kr2ycGkS oRZ7UfU1pG2FZh10vAX9Rk0YWYUTZdNBPUmdc7G9o71SUA5JMLHRqZHRXAgyzpcw0KmA qM+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HaME3Z5uLAfT5ND31CqQyrNIC7MORGaQXez8ygNaWV4=; b=C1/sRleAaBXyxJg6SNgMG4VH3u60wdLZmyfHP5kcthGqL2Iqs0SW7y2VMeD0DCXIRx XJM9vYmVZR5zIC1KdYLqxu2GhvVIJw9aOFv3urm8K8RmYjoKbreQJtGLUL1IQoywHkBH 9ySQZFjoQSQRpTWuKciTvImTLvcBznH/r3H7+NOHnMfq3D7QVTZcfb7+3Qs+UPZVURRw gy+1BThQLou1/SAE4Hdi58uTY1HL2IsGe+FEu53miU22adqfb+iB0NXSp9zqdK8BzCmx yhxlc62oT5XSh5CeLCBN7N3WH4NPC29bja0E+3Y1Uwk/weJqafFaN/gv2OsZDZiqJT58 mJKA== X-Gm-Message-State: AOAM530f1Z7PXbkDgXHfK6OZE7wMVydISjsZ2F27TRrhjv7u7XOiMpJc Tje4eL9ObJ/d2lGGl6K80MSb/hCh X-Received: by 2002:aa7:8a4d:: with SMTP id n13mr23175412pfa.143.1596979690802; Sun, 09 Aug 2020 06:28:10 -0700 (PDT) Received: from sol.lan (106-69-185-93.dyn.iinet.net.au. [106.69.185.93]) by smtp.gmail.com with ESMTPSA id j10sm9127414pff.171.2020.08.09.06.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Aug 2020 06:28:10 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, linus.walleij@linaro.org Cc: Kent Gibson Subject: [PATCH v3 18/18] tools: gpio: add debounce support to gpio-event-mon Date: Sun, 9 Aug 2020 21:25:29 +0800 Message-Id: <20200809132529.264312-19-warthog618@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200809132529.264312-1-warthog618@gmail.com> References: <20200809132529.264312-1-warthog618@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support for debouncing monitored lines to gpio-event-mon. Signed-off-by: Kent Gibson --- tools/gpio/gpio-event-mon.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c index e50bb107ea3a..bd5ea3cc6e85 100644 --- a/tools/gpio/gpio-event-mon.c +++ b/tools/gpio/gpio-event-mon.c @@ -148,11 +148,12 @@ void print_usage(void) " -s Set line as open source\n" " -r Listen for rising edges\n" " -f Listen for falling edges\n" + " -b Debounce the line with period n microseconds\n" " [-c ] Do loops (optional, infinite loop if not stated)\n" " -? This helptext\n" "\n" "Example:\n" - "gpio-event-mon -n gpiochip0 -o 4 -r -f\n" + "gpio-event-mon -n gpiochip0 -o 4 -r -f -b 10000\n" ); } @@ -167,11 +168,12 @@ int main(int argc, char **argv) unsigned int num_lines = 0; unsigned int loops = 0; struct gpio_v2_line_config config; - int c; + int c, attr, i; + unsigned long debounce_period = 0; memset(&config, 0, sizeof(config)); config.flags = GPIO_V2_LINE_FLAG_INPUT; - while ((c = getopt(argc, argv, "c:n:o:dsrf?")) != -1) { + while ((c = getopt(argc, argv, "c:n:o:b:dsrf?")) != -1) { switch (c) { case 'c': loops = strtoul(optarg, NULL, 10); @@ -187,6 +189,9 @@ int main(int argc, char **argv) lines[num_lines] = strtoul(optarg, NULL, 10); num_lines++; break; + case 'b': + debounce_period = strtoul(optarg, NULL, 10); + break; case 'd': config.flags |= GPIO_V2_LINE_FLAG_OPEN_DRAIN; break; @@ -205,6 +210,15 @@ int main(int argc, char **argv) } } + if (debounce_period) { + attr = config.num_attrs; + config.num_attrs++; + for (i = 0; i < num_lines; i++) + gpiotools_set_bit(&config.attrs[attr].mask, i); + config.attrs[attr].attr.id = GPIO_V2_LINE_ATTR_ID_DEBOUNCE; + config.attrs[attr].attr.debounce_period = debounce_period; + } + if (!device_name || num_lines == 0) { print_usage(); return -1; -- 2.28.0