Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp212630pxk; Wed, 9 Sep 2020 03:32:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyxav7fFQ06W8mq+K/Ynf8jhZd/o3tWu8BqEtivMfaKxeEC8sO5y7OfIqraWWdx1akVCTd X-Received: by 2002:a17:906:f8d2:: with SMTP id lh18mr3095090ejb.44.1599647523854; Wed, 09 Sep 2020 03:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599647523; cv=none; d=google.com; s=arc-20160816; b=XSBIG/UY38J94zNJwmi/p0ncXBsCYaMxtGfxlLXn0lS4Ebg8DzPBfO2Xmo7ZHX1uih a5leXgZi71O6ztr8SAirgYyhHE7Bhbnigq9W3Uu/tZMvdo2y1KI42fqD6j/piKQEySXY zav3GliHcbQKv1FDNeWbRvCQ8r3s99NUdXH/jXvcTtqTam10pPa5TBVyNEMW1pEeF+U+ VUZLPSqee4EHEd/Gcu+lCakuEmNXP9pp1lkReDbC3HrXXWOfIsR5Lwxgy8c1PPM8kVwO N+6dpnNtyTUsmICaItQCV+nK4JcN4If6GofcY5ZYTxnvv+uFNLAhC7HqeRIyz6wZoUDI 4Cgw== 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=guz0Clw4AqA2jVh9p7sknFN8CKJPf7cwJi8xj4B3zAnE5XuWpydxGtQTntkX6Df6dx RWw1W+90DkRNoGpMj1H7S6o9mRW9ItzDa9vB/nM/1dVbbayUSsoWB67IpLWhEMu/sbGW sQMKvBlMEn2zoufNFuxAzBaWft+u/m9JW+uIbHJ9CJ7Akasrsd0pNpVvhiyZxfl9GAeN jnh4S1UVKeVoQZ7ViIANl1xN6joH9W3bB8AzdvUMyCw/nCDFmzlSDPEYmSyV3nFF1HXx fSuJAJ81PQ01OoW0DRl5EPBUgzgA4Rz+T+zOrDusOtbFFRdAZY4DNbDo1c4I/QEuXF6z B8Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=D0dROmJK; 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 b4si1148570edt.521.2020.09.09.03.31.41; Wed, 09 Sep 2020 03:32:03 -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=D0dROmJK; 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 S1729521AbgIIK3y (ORCPT + 99 others); Wed, 9 Sep 2020 06:29:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729942AbgIIK3B (ORCPT ); Wed, 9 Sep 2020 06:29:01 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 150CDC061573; Wed, 9 Sep 2020 03:29:01 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id b124so1735466pfg.13; Wed, 09 Sep 2020 03:29:01 -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=D0dROmJK5JNEWz6XnpG2UxU0Czt7CjrQi0W9ag56hfNt7ttM6fI42P45oQp/k7RqYw fIac3kaSh3MmEhrajc8Wag+D4jwn+Bzl39wgrsQMLNldOHJCywIYsKh2uH1Q+guTrXDK LR5jIJa2sgzAzhJd15uHb4tlLWIm8osAqbBknGmeFYEqFKetlJbsuJ3VQDTwf9RqMD9y ajjn6hMbYVvubSesTtuLaNxQTLWzg3YFii/lX4WcT5l8qVqfFkKcd1BNhRqeBo20jQ/k TZ1MsNC3zy/vb3dlCSZpIWNnq6aLiq5gESV2dMqVTKojm91W3SjJYB/yW0Vb7V+obozS fs9Q== 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=UsIbHLfM+Y4OtIknZqSNjp3j9+qwlqYr3UoG3KTgVFXGOb1yHYfPJ9N/xyyRBBkXAi M1SqXkId0FEGWhBJPakQg/UCuHqnES33cSwANK0HBDSvpKmHh5RSHTiQ3X9dx+D4uyXT wfQLD5l3Qtc62q1MF4MySU8zrJQG1bn6LXVwPZpNkPSfwr0U8sH2ru32RVSG4k1A+FsH C9Lrimdm2pfRoULqC4ATsWPewm0VjY165Ty9khY7LvLFgLKpA8D5FRAndEY/bYkPVk7q Lv+qriM6C+xWQ842esTaGrCAGwW20tGgQFum3Y8JUhpEJWWBv2lDCsCcEMoA743Qo5ph 1BNw== X-Gm-Message-State: AOAM532gcNNVF8hELxSm4Tz5tYTs/dUVG55I8ljjV9uqix8j6SeNufdL Aw6aqG5QIFUqHzDqWDucKUfeCHKAKo4= X-Received: by 2002:a17:902:fe97:b029:d0:cbe1:e745 with SMTP id x23-20020a170902fe97b02900d0cbe1e745mr338180plm.32.1599647340193; Wed, 09 Sep 2020 03:29:00 -0700 (PDT) Received: from sol.lan (106-69-184-100.dyn.iinet.net.au. [106.69.184.100]) by smtp.gmail.com with ESMTPSA id c7sm2338168pfj.100.2020.09.09.03.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Sep 2020 03:28:59 -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 v8 20/20] tools: gpio: add debounce support to gpio-event-mon Date: Wed, 9 Sep 2020 18:26:40 +0800 Message-Id: <20200909102640.1657622-21-warthog618@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909102640.1657622-1-warthog618@gmail.com> References: <20200909102640.1657622-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