Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3811904imm; Mon, 2 Jul 2018 06:06:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKLlfknVCgpzpytATHrreVb6qkRItUD8m/vLXd40rdLqbraGNisR0Ow8MfLvcQdi4AP0ziC X-Received: by 2002:a17:902:6193:: with SMTP id u19-v6mr25622883plj.133.1530536787427; Mon, 02 Jul 2018 06:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530536787; cv=none; d=google.com; s=arc-20160816; b=ZthBWeXX4feunHJ1gpIyYAc+mj+DvMSjYasg94KQy0QGYyztIEyC0cF+WjseQ816yZ AkSrRgwnAgNv8cWT7n4X4PlOBOpkaByF8SL9/ofdh5/CBO1LoIFyBa9NDvnhnzwfpZJl ikVJSpPMRHoAtDytoUI03D8VhVVKDuhqbz/f/0RjlS061eUtb7eV7/ZaWVkVRThVAtvC 3yKFMgwAIXrnZqC8wS1xPyHWhcnHysv7nIhbB1WdsrczjOUVPMAi81TF1vJa1usI7buK 5goJ6iLedmiKkv7uAiwEP0wfPi4slIbZnpwi3D3abV1Ii319W2HJ20W4Q9n8Nx5ho2nk 60xg== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=05uMVlOyvsuy9vYND1S6loVK9K7IDLgmK4cnGx5NeVU=; b=uQJNcGdCEPoCLCMBnMPtmVBMT2gTLwWMszSZbTNsnZ0Z4jT9M6NBt2C6Cm776zn/4G EJ7kcbjG2Z1CYY66TrVSQBgimdDlw7f/K5sR356l2KxVITlCgXSPaykO4uRqAjN8IAOH 9Z5W+F2DHsy7oN8HdNDe5V7UoyBkY2Vh26wq7ZP/wZO5B+03awaXLtYoM1PS6BGzd3UL MkBxehlDg7BWWuOc+pO871n8ZysbqGeZVtXpE013Lh4S8NAZlHcfm6HhgpWnWgoAZpZA vcWqJKErdI8JWHA+FJT8BBj+jXQBWOVDKWwl0PoT3LC6Ca+skxEJDlHq0TGjqGSFjY4H kARQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5-v6si15931249plt.178.2018.07.02.06.06.12; Mon, 02 Jul 2018 06:06:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752458AbeGBNEL (ORCPT + 99 others); Mon, 2 Jul 2018 09:04:11 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:39226 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752042AbeGBNEK (ORCPT ); Mon, 2 Jul 2018 09:04:10 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 8C08559B41C90; Mon, 2 Jul 2018 21:04:05 +0800 (CST) Received: from localhost (10.202.226.43) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.382.0; Mon, 2 Jul 2018 21:04:02 +0800 Date: Mon, 2 Jul 2018 14:03:52 +0100 From: Jonathan Cameron To: David Lechner CC: Lars-Peter Clausen , , Jonathan Cameron , Hartmut Knaack , "Peter Meerwald-Stadler" , , "William Breathitt Gray" Subject: Re: [PATCH] iio: add channel type for frequency Message-ID: <20180702140352.00002c6c@huawei.com> In-Reply-To: <74c98fdc-b498-c593-e0b1-6aeb7057398a@lechnology.com> References: <20180701025953.3561-1-david@lechnology.com> <308015e8-d203-c4d1-ba80-3c2adf4b377a@metafoo.de> <74c98fdc-b498-c593-e0b1-6aeb7057398a@lechnology.com> Organization: Huawei X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.226.43] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 1 Jul 2018 17:24:34 -0500 David Lechner wrote: > On 07/01/2018 02:18 AM, Lars-Peter Clausen wrote: > > On 07/01/2018 04:59 AM, David Lechner wrote: > >> This adds a new type for frequency to the IIO channel type enumeration. > >> > >> Units are in Hz. > >> > > > > Documentation? > > I take it that you mean Documentation/ABI/testing/sysfs-bus-iio? Or > somewhere else too? Yes. > > > > > We already have the altvoltage channel type with the frequency attribute. > > Difficult to say if there are any overlaps without documentation on how this > > new attribute is supposed to be used. > > I'm basically trying to implement a quadrature encoder in iio. I want to be > able to use it in-kernel to get a rotational speed value for a motor. Have you seen the counters subsystem work that is pretty much ready to merge? https://lkml.org/lkml/2018/6/21/659 > > The motors (and encoder wheels) are hot-swapable, so we don't know how many > counts from the quadrature encoder equals one rotation because it depends on > which motor is being used. So using IIO_ANGL_VEL doesn't work for this case. Hmm. This always ugly when we have hotswappable external devices. Ideal is to describe them with device tree or similar none the less as this stuff isn't really something userspace should have to figure out. > > It seems to me that the proper generic unit for "speed" from the quadrature > encoder would be counts per second, hence the suggestion of a frequency unit. It is probably not that clear cut, as what is it frequency of? All depends on what mode the quadrature counter is working in x4 or x1 for simplest options. > I'm not sure if voltage frequency works here since a "count" on a quadrature > encoder is derived from two different voltage signals (and may vary depending > on how the encoder determines what one count it). > > Also, unrelated to my quadrature encoder project, I was thinking that > frequency counters would use this unit as well (although the voltage alt > makes more sense for this case). > > There are also sound sensors that measure frequency that could use this unit. I have not fundamental issue with having a frequency channel, but only if we have a clear cut use case. I suspect the right option here is to look at what extensions are needed to William's counter subsystem instead of in IIO (which frankly failed to stretch far enough to support counters well). Jonathan > > > > >> Signed-off-by: David Lechner > >> --- > >> drivers/iio/industrialio-core.c | 1 + > >> include/uapi/linux/iio/types.h | 1 + > >> tools/iio/iio_event_monitor.c | 1 + > >> 3 files changed, 3 insertions(+) > >> > >> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c > >> index 19bdf3d2962a..f3c2c9e4b997 100644 > >> --- a/drivers/iio/industrialio-core.c > >> +++ b/drivers/iio/industrialio-core.c > >> @@ -85,6 +85,7 @@ static const char * const iio_chan_type_name_spec[] = { > >> [IIO_COUNT] = "count", > >> [IIO_INDEX] = "index", > >> [IIO_GRAVITY] = "gravity", > >> + [IIO_FREQUENCY] = "frequency", > >> }; > >> > >> static const char * const iio_modifier_names[] = { > >> diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h > >> index 4213cdf88e3c..9fee86e2046f 100644 > >> --- a/include/uapi/linux/iio/types.h > >> +++ b/include/uapi/linux/iio/types.h > >> @@ -44,6 +44,7 @@ enum iio_chan_type { > >> IIO_COUNT, > >> IIO_INDEX, > >> IIO_GRAVITY, > >> + IIO_FREQUENCY, > >> }; > >> > >> enum iio_modifier { > >> diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c > >> index b61245e1181d..c3ef20057d52 100644 > >> --- a/tools/iio/iio_event_monitor.c > >> +++ b/tools/iio/iio_event_monitor.c > >> @@ -58,6 +58,7 @@ static const char * const iio_chan_type_name_spec[] = { > >> [IIO_PH] = "ph", > >> [IIO_UVINDEX] = "uvindex", > >> [IIO_GRAVITY] = "gravity", > >> + [IIO_FREQUENCY] = "frequency", > >> }; > >> > >> static const char * const iio_ev_type_text[] = { > >> > > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html