Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp75391pxa; Thu, 13 Aug 2020 20:08:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVaQp2fZB0V1jN3caEkEBheWfMRsqARrt1LWCQIWj2CM/v0zufsSAlGYeBFI4Teka/MNan X-Received: by 2002:a50:ec95:: with SMTP id e21mr376253edr.250.1597374523977; Thu, 13 Aug 2020 20:08:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597374523; cv=none; d=google.com; s=arc-20160816; b=BTZUglFDl/uy7927QNjaPmzDzpaV373aQuB8OxI9ZLC5JaUwHu1kP13wTJ+LimWD+d mqZgoHDuQkvTNCmXyWJ2C7WLYYKS5wpIo6cCdOI6K9+CF8uKfKlnVUOZ/yv2Pig2PwrF XZpeAmd1nYqz6gv6tf0qoVcnlIbzm5VBFOaTe/YfG4PSlGl3csv1/ZyDN6p2PFyPcFi4 2DZjqVkIRbrCgn1H3txOeD8PGE2ArWuUScYXrVLDaLKgp4I5ftNxTj/HQUspGiFuJjxd 2D8D+4HShE25HWsFcj2YjVZqd9GNkO6c2KFrIKt8atlknhYQEJEzWtuXkmX2f9cyg54+ XQig== 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=ftu/WfLMc4M0fgPO+cmF+PVQv1PUf6gXld5uCYiowsBzDVigCov9uRAkYpugY6o6qo NY42NF9C/04uJyyaXJoYwjpdAchoOit3HP5Y50kyB71otsJjGuXUEL4zEal0g0PDl55m /ksiktE1UUqDlYlVPMKbBMzrS8+DoJhTxI/rfntVkLVxI6NstV95EACLsp/BRnpOnq6u nu/jfVEQXj7QRstdrjLOM+LqgvGjMqIxzskwnouTyltWCq7HnJ9lljBAVhJYn7o54+26 thpzYSBs5sLo+xk1IL9mWSTeNjOBXMLWb+1anllokpDKhv6fEa3OtBRMAMB23WI0uDz9 Q4nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jLR45Gl2; 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 r7si4344012ejo.640.2020.08.13.20.08.21; Thu, 13 Aug 2020 20:08:43 -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=jLR45Gl2; 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 S1727012AbgHNDGM (ORCPT + 99 others); Thu, 13 Aug 2020 23:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgHNDGL (ORCPT ); Thu, 13 Aug 2020 23:06:11 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53AB0C061757; Thu, 13 Aug 2020 20:06:11 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id u128so3863477pfb.6; Thu, 13 Aug 2020 20:06: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=jLR45Gl2DA2rRti+GMEvcjlEkZd1G7TuZhTfwWhzE3Btu5YqhkcgLUPpyCGdLywjPa H8IDLJsaUlE2XRq3ZIWT8rWakHVFkOPn0PLs9w96njhg44kwwDJgM9zaN6tar1oRBdlW ocoPeppftFJ1v3pzC7J89x8POwTNDrlCHoxdgJW+OzM+ctn3TgnGRZeCZWW5xIt6q7O8 5CyQ/U4dwcAKCHiMhFOdGssaU4sErtGYKjva1d3Q3TkspQgsQ7L186yhXL0hOLhtOLdT DHqcU5nF1ZjQeRZS6f62yIAFqi7UhMmaIg0G0YFo0fa8qhGiOuLoJuiTlCIOavEX7NFh P09Q== 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=rv6U0CDrEgmPK9bm+XDYriq9kMT9+ZhbFToXlgxjit4JL8cOPfs9lIcGjf3oVZKqcz hcyBpx/3YgRQqwvm3C3Rqdn7thP6/uakHNcKL+RHOIb6HHADekZ2eJLsgepV/FOohcD8 mDFsj5u4Xd3GMjy1a/Pry6+OqUUL3RxrHlSd7eOw/13ncK6/YqNvN5FiwmNhzHg7Gj6/ gFpa0nNwB5dtGow9MB/vbUIKv73DWx3gqy0Lk9DyGF7zQLdSa3UXxlMqt4u/zyGnLX0D dGocfBR1L0pxROQ1wsrO6uwZiyqkibXjfJ4ciSx9P0dft3l6DcUmWoKuuH/MTVuUElW5 MQIw== X-Gm-Message-State: AOAM533mWDxVv/fZbhRYPETGVxlPVdaswmO2ErgJgT3h29MKkCBnROqD IBH7BxSwzjuFVCnNpxg/VpJnrKpf X-Received: by 2002:a63:2324:: with SMTP id j36mr437494pgj.221.1597374370373; Thu, 13 Aug 2020 20:06:10 -0700 (PDT) Received: from sol.lan (106-69-161-64.dyn.iinet.net.au. [106.69.161.64]) by smtp.gmail.com with ESMTPSA id z3sm6522231pgk.49.2020.08.13.20.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2020 20:06:09 -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 v4 20/20] tools: gpio: add debounce support to gpio-event-mon Date: Fri, 14 Aug 2020 11:02:57 +0800 Message-Id: <20200814030257.135463-21-warthog618@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200814030257.135463-1-warthog618@gmail.com> References: <20200814030257.135463-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