From patchwork Tue Jul 18 12:30:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Waqar Hameed X-Patchwork-Id: 121986 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1714660vqt; Tue, 18 Jul 2023 05:43:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlGcGdXryK94vg/WPJvTdCfx2gGKvrrAzieF2Q0wjwVaMeF3yZCxXas5x4l8/cAzQs+R7vlA X-Received: by 2002:a17:906:ae12:b0:98e:37fe:691b with SMTP id le18-20020a170906ae1200b0098e37fe691bmr11942537ejb.34.1689684233642; Tue, 18 Jul 2023 05:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689684233; cv=none; d=google.com; s=arc-20160816; b=A8Auv+eQDLqFRizvZyVJrm8mFJ3BJAijzw6sfVDgOpXmYePQmP2vFWeKWoqFQZl4C8 K7WJ7oICRes1Gi5DhNZbXbKfQBalriPUidFgd0NHm1e1V6wUEMdWWBcOnFf8QLho4f0E c9atHgH/Ht0BnzQl2aZn+IHofbVugv2qlcCYMmPjEYnSUNZEilvje9zFHwemoUuNVnwk RxyR+rHR+KrJiuUr5s51Q6OvGfuZWWpGyYrDcR6oFhoXbymyU7Z/DAcfCi2wWzoiUdTV BpnssFdpl9cT8tIXtgXuC2FPTeiKuzPy8p0N8ZT3ogzhGX5mFEWIexRl1QxnIL7gplzZ C61A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to:subject :cc:to:from:user-agent:references:dkim-signature; bh=rwAJJHUO0JnZisxLO3+eFKnrpeHeVsnZgdBx2AOpPlA=; fh=ftIB+k+CYHfLUAU/a4e0Loa51Tj4ciVRtUnwPKg5ZEw=; b=LhbALzJxDf9yn2F+X1YOtS+Q/mHixnCGpkh9BGX10YQwA4mRQ4HaCZLaBUVX9rNX2d yzgCLPh6vN00UPM2diZA1sxZKzv5DI16rckT6AtDdNecPg8Kpz/QixcycxJfgb8zguH9 coFIR5xVfT3taH4NGkJhaibolv7YnPAAyYV/maKv2wg8RsQLfYVDpjW3KhbR5ZglMy6t KAbzNZse8jTDR1GfWWikX1jjBpOL75yEUb+CifiuXnbmK+fggAVW9QuJUcmOVjmFSz3M etmV06lu7ZdFaFByD0bLqDliQdLi03/jGhy/nM1g7SqnwMXbj4wcQoINsxNjjKI6kjlS NYAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=MjrTQvkD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt11-20020a170906f20b00b0098885a736easi1128172ejb.54.2023.07.18.05.43.30; Tue, 18 Jul 2023 05:43:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=MjrTQvkD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbjGRMci (ORCPT + 99 others); Tue, 18 Jul 2023 08:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231631AbjGRMcb (ORCPT ); Tue, 18 Jul 2023 08:32:31 -0400 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EA6E10FF; Tue, 18 Jul 2023 05:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1689683546; x=1721219546; h=references:from:to:cc:subject:in-reply-to:date: message-id:mime-version; bh=rwAJJHUO0JnZisxLO3+eFKnrpeHeVsnZgdBx2AOpPlA=; b=MjrTQvkD33PS4M6OrF6HVYT/YT9HlO/hHp6bQ+h951tqn+xBiv+uj0ln 4mNjd0+091VnuzIMupuYYLf7CyjFWM5ViK9TuePeitTMW7zz2P996Tuts TXmlaHbv4LyBp2vX0D9SEqXzUj/iC/CUMVgyl346ve8Ox4CHRc/AAnF9c Nym+KXT6kfaUed7SkqM4fD1B8XoVB/m93Imczl184DbXQOos4b/5kToox 4b/Cbw4JwNf33O0YKdxPqaJLcDFNaJTR7mE9bIeUzui5Wi7m+apdgN8ni wrDqnkev9cfeMAqRneFRqH4BLbfM2TqnTglW73S2XcQWyv3jHOpm5CBeO w==; References: User-agent: a.out From: Waqar Hameed To: Jonathan Cameron , Lars-Peter Clausen CC: , , Subject: [PATCH v3 2/3] iio: Add event enums for running period and count In-Reply-To: Date: Tue, 18 Jul 2023 14:30:11 +0200 Message-ID: MIME-Version: 1.0 X-Originating-IP: [10.0.5.60] X-ClientProxiedBy: se-mail02w.axis.com (10.20.40.8) To se-mail01w.axis.com (10.20.40.7) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771762334998133641 X-GMAIL-MSGID: 1771762334998133641 There are devices (such as Murata IRS-D200 PIR proximity sensor) that check the data signal with a running period. I.e. for a specified time, they count the number of conditions that have occurred, and then signal if that is more than a specified amount. `IIO_EV_INFO_PERIOD` resets when the condition no longer is true and is therefore not suitable for these devices. Add a new `iio_event_info` `IIO_EV_INFO_RUNNING_PERIOD` that can be used as a running period. Also add a new `IIO_EV_INFO_RUNNING_COUNT` that can be used to specify the number of conditions that must occur during this running period. Signed-off-by: Waqar Hameed --- Documentation/ABI/testing/sysfs-bus-iio | 16 ++++++++++++++++ drivers/iio/industrialio-event.c | 2 ++ include/linux/iio/types.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 7140e8e7313f..a2854dc9a839 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -2163,3 +2163,19 @@ Contact: linux-iio@vger.kernel.org Description: An example format is 16-bytes, 2-digits-per-byte, HEX-string representing the sensor unique ID number. + +What: /sys/.../events/in_proximity_thresh_either_runningperiod +KernelVersion: 6.6 +Contact: linux-iio@vger.kernel.org +Description: + A running period of time (in seconds) for which + in_proximity_thresh_either_runningcount amount of conditions + must occur before an event is generated. If direction is not + specified then this period applies to both directions. + +What: /sys/.../events/in_proximity_thresh_either_runningcount +KernelVersion: 6.6 +Contact: linux-iio@vger.kernel.org +Description: + Number of conditions that must occur, during a running + period, before an event is generated. diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index f77ce49d4c36..19f7a91157ee 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -252,6 +252,8 @@ static const char * const iio_ev_info_text[] = { [IIO_EV_INFO_TIMEOUT] = "timeout", [IIO_EV_INFO_RESET_TIMEOUT] = "reset_timeout", [IIO_EV_INFO_TAP2_MIN_DELAY] = "tap2_min_delay", + [IIO_EV_INFO_RUNNING_PERIOD] = "runningperiod", + [IIO_EV_INFO_RUNNING_COUNT] = "runningcount", }; static enum iio_event_direction iio_ev_attr_dir(struct iio_dev_attr *attr) diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h index 82faa98c719a..117bde7d6ad7 100644 --- a/include/linux/iio/types.h +++ b/include/linux/iio/types.h @@ -19,6 +19,8 @@ enum iio_event_info { IIO_EV_INFO_TIMEOUT, IIO_EV_INFO_RESET_TIMEOUT, IIO_EV_INFO_TAP2_MIN_DELAY, + IIO_EV_INFO_RUNNING_PERIOD, + IIO_EV_INFO_RUNNING_COUNT, }; #define IIO_VAL_INT 1