Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2073391pxb; Sun, 10 Jan 2021 23:16:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBhxlA4X5yNOWrjGEORGU4XwF9pXQZmZsrXg5ofIWzfWXvJ/I/Nwv/WxhjcipfnOI/EJtl X-Received: by 2002:aa7:dd05:: with SMTP id i5mr13178422edv.223.1610349368231; Sun, 10 Jan 2021 23:16:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610349368; cv=none; d=google.com; s=arc-20160816; b=Ps86Lp/QbD5thBH7GCc37JjsDYkj5/VTPewbt3o8cEky2MqlIs9FItDxxtegaonUId 3UA5i8xgifXjEc34kDVEkq+nz25Cs3RCSVTYdAaNC40S7h7/jV2fud9nDPco8bR5jVo5 KsXYBqnx4Dgiq7QYXJDBsiqxJn/wwrU7PBpT5W53EHC9JMmkXsNLr04qnfMsiiVJdsPP bQbGjbh1OstNBo8j24IE1A8pPmOnIisNigWm0CGtzxgVl1oGytQ2PT/2dxaXxWp2/TJE 3o83tRRGbiqRI5WNc3Vzw38oRmahnumLwmeREDoQhyNALmA0kMfKLq2JhxuFovs5+JUc UP9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PYIUlaTfC+qHfMej4twucGScSCQDmWbCEShoQb2dW8E=; b=pympryCEUzj8mBXLOQZrnoweKQmB5O2JawnxNGQ7qMjTQlbYWihzjealtIs/6rG8F9 0hvsT3QBo2UiBph/LVseOpcqv2LtQRyZgM+tFYarnEvRLZo3rDdTSQZvNf8xfTx9NoTy gOwNourfps39Tj/jX0W5DlmspPIv5mNDH7H91r0IkbAU9xdjvGxq2xUy2hXmCjVk6NUH fys2HuZ634U6rGzNeskOemSi2bbr82YRKhp/dWyr02WsJa/h00FXhCjGh+iNwzjDLnah xelKZ74m5Mls9/aoAyOywEPEDF8v1XYRcsr+H0R/4Wfgzf1gHHyLtiSmLcxPohHgkbZv HoWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SE8xprRJ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k26si6120484ejc.545.2021.01.10.23.15.44; Sun, 10 Jan 2021 23:16:08 -0800 (PST) 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=@google.com header.s=20161025 header.b=SE8xprRJ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727417AbhAKGph (ORCPT + 99 others); Mon, 11 Jan 2021 01:45:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725536AbhAKGpg (ORCPT ); Mon, 11 Jan 2021 01:45:36 -0500 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A95ADC061786 for ; Sun, 10 Jan 2021 22:44:56 -0800 (PST) Received: by mail-pj1-x102c.google.com with SMTP id n3so7796060pjm.1 for ; Sun, 10 Jan 2021 22:44:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=PYIUlaTfC+qHfMej4twucGScSCQDmWbCEShoQb2dW8E=; b=SE8xprRJJp7ffnAN2XwtmMwNkjg0oTQfgcxyaAWnVaZUZrU4GG3WjpwwCx4rwly22e zrkIkta05MipEf8DDLMk+Xz+8omYJs4uGUhm/LlRVuVEkiVgD6ZgEtqgEn9ko1YoST91 jVhCYSKUG06h1gjlBICdBBnYutTmpm3h5xuSM6jRr15t39I61POVg5fXrOTiry+1DIjX tMpgMZe3F5C2SIReJUnbsc4841SkFc+ub51ku13h1iCQcNzeshIBpXRq0rFbkRTJ8i+J wbw6hUqa7rviY13EmlN7qiDw1YFV7ZrPS9Wvfe0pIVKM26piJhCPoSgunjl2XtU06I8f OPmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=PYIUlaTfC+qHfMej4twucGScSCQDmWbCEShoQb2dW8E=; b=OBta3+k49pT9rtyCkMUltgetDpDZxjya+6ebZA2XmbkGp2BOWueRT9RrROzKEGaWnl m/SIDrE/LGln0ahlLvrpPG6l8karoJOhbYmqRUKpwt2x0dORgTn5Cjk1lq3czBJFjcls IvOjNHZ6r9jxTo6l2xgAqYJL2/iJFEDjEL1e61cfX1C2Xcr0N8+HtMFgd7JOUVSvq6i5 qtE1To7vS8KUVWN06GhwcEpuMXVCKCu2rIxIK9Hrpp6GtRP30CilTSdYNEawzGt5XORo 0t3RwyI5rlJiNpcyqMin65hu/H/S8vnMU2tYYXndoZW2z1y2W82Ro3/IsIbx8PiJP3Ck joTg== X-Gm-Message-State: AOAM533cgyRNjprWYcW5sxxjdsC1J2sGbVoo1rHyPHuPPuUPo//MMNJu 1KObXLotFGuxnGsA2N+s8xCNkn1YInEEt7tQoarCBw== X-Received: by 2002:a17:902:eb03:b029:db:c0d6:5845 with SMTP id l3-20020a170902eb03b02900dbc0d65845mr18211576plb.76.1610347495820; Sun, 10 Jan 2021 22:44:55 -0800 (PST) MIME-Version: 1.0 References: <20210106161233.GA44413@e120937-lin> <20210106212353.951807-1-jbhayana@google.com> <20210109190133.61051fab@archlinux> In-Reply-To: <20210109190133.61051fab@archlinux> From: Jyoti Bhayana Date: Sun, 10 Jan 2021 22:44:44 -0800 Message-ID: Subject: Re: Reply to [RFC PATCH v2 0/1] Adding support for IIO SCMI based sensors To: Jonathan Cameron Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Mauro Carvalho Chehab , "David S. Miller" , Rob Herring , Lukas Bulwahn , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, Cristian Marussi , Sudeep Holla , Enrico Granata , Mikhail Golubev , Igor Skalkin , Peter Hilber , Ankit Arora Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jonathan, In section 4.7.2.5.1 of the specification, the following exponent is the scale value uint32 axis_attributes_high Bits[15:11] Exponent: The power-of-10 multiplier in two=E2=80=99s-complemen= t format that is applied to the sensor unit specified by the SensorType field. and the resolution is uint32 axis_resolution Bits[31:27] Exponent: The power-of-10 multiplier in two=E2=80=99s-complemen= t format that is applied to the Res field. Bits[26:0] Res: The resolution of the sensor axis. From code in scmi_protocol.h /** * scmi_sensor_axis_info - describes one sensor axes * @id: The axes ID. * @type: Axes type. Chosen amongst one of @enum scmi_sensor_class. * @scale: Power-of-10 multiplier applied to the axis unit. * @name: NULL-terminated string representing axes name as advertised by * SCMI platform. * @extended_attrs: Flag to indicate the presence of additional extended * attributes for this axes. * @resolution: Extended attribute representing the resolution of the axes. * Set to 0 if not reported by this axes. * @exponent: Extended attribute representing the power-of-10 multiplier th= at * is applied to the resolution field. Set to 0 if not reported by * this axes. * @attrs: Extended attributes representing minimum and maximum values * measurable by this axes. Set to 0 if not reported by this sensor. */ struct scmi_sensor_axis_info { unsigned int id; unsigned int type; int scale; //This is the scale used for min/max range char name[SCMI_MAX_STR_SIZE]; bool extended_attrs; unsigned int resolution; int exponent; // This is the scale used in resolution struct scmi_range_attrs attrs; }; The scale above is the Power-of-10 multiplier which is applied to the min = range and the max range value but the resolution is equal to resolution and multiplied by Power-of-10 multiplier of exponent in the above struct. So as can be seen above the value of the power of 10 multiplier used for min/max range can be different than the value of the power of 10 multiplier used for the resolution. Hence, if I have to use IIO_AVAIL_RANGE to specify min/max range and as wel= l as resolution, then I have to use the float format with the scale applied. If there is another way which you know of and prefer, please let me know. Thanks, Jyoti Thanks, Jyoti On Sat, Jan 9, 2021 at 11:01 AM Jonathan Cameron wrote: > > On Wed, 6 Jan 2021 21:23:53 +0000 > Jyoti Bhayana wrote: > > > Hi Jonathan, > > > > Instead of adding IIO_VAL_INT_H32_L32, I am thinking of adding IIO_VAL_= FRACTIONAL_LONG > > or IIO_VAL_FRACTIONAL_64 as the scale/exponent used for min/max range c= an be different > > than the one used in resolution according to specification. > > That's somewhat 'odd'. Given min/max are inherently values the sensor is= supposed to > be able to return why give them different resolutions? Can you point me = at a specific > section of the spec? The axis_min_range_low etc fields don't seem to hav= e units specified > but I assumed they were in sensor units and so same scale factors? > > > > > I am planning to use read_avail for IIO_CHAN_INFO_PROCESSED using IIO_A= VAIL_RANGE > > and this new IIO_VAL_FRACTIONAL_64 for min range,max range and resoluti= on. > > Instead of two values used in IIO_VAL_FRACTIONAL, IIO_VAL_FRACTIONAL_64= will use 4 values > > val_high,val_low,and val2_high and val2_low. > > I'm not keen on the changing that internal kernel interface unless we abs= olutely > have to. read_avail() is called from consumer drivers and they won't kno= w anything > about this new variant. > > > > > Let me know if that is an acceptable solution. > > Hmm. It isn't a standard use of the ABI given the value in the buffer is = (I assume) > raw (needs scale applied). However, it isn't excluded by the ABI docs. = Whether > a standard userspace is going to expect it is not clear to me. > > I don't want to end up in a position where we end up with available being= generally > added for processed when what most people care about is what the value ra= nge they > might get from a polled read is (rather than via a buffer). > > So I'm not that keen on this solution but if we can find a way to avoid i= t. > > Jonathan > > > > > > > > Thanks, > > Jyoti > > >