Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp1399025lqh; Mon, 6 May 2024 06:46:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXnU7UttTQ/qbA6064q0NhJdcLo46uguxE9kUHwRf1FPgW91STEbr0GKSSxabefYmmnzzv7je61ftlimzVW0d8BUNkfAoZ4CkFo5uLrzQ== X-Google-Smtp-Source: AGHT+IHLTEBr/Ndgr1SPd3rLIhd6OvghyarAifIKezoG1smQicSEcavreSIv4Apgt9VT1nzmMi1/ X-Received: by 2002:a05:620a:568e:b0:792:9e07:de73 with SMTP id wg14-20020a05620a568e00b007929e07de73mr1734811qkn.47.1715003198126; Mon, 06 May 2024 06:46:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715003198; cv=pass; d=google.com; s=arc-20160816; b=k/OKHY1H3mw93Wg7kKf1gsh7l0Of88iJWRrOKhJzffvjToxFLJOd+NDFGEGw9X/Uf8 RitE3EmotgjY9V97x2My3whgn+p/iSV7wR7exIZtpgL39G+JagEI+S1xO1W4kwBtgXcu uWQiQ5TMAnDsP+nOVto+aZIw6zp+wmnZwQjAwPqd1H1r5uaBhYrmXAQn3iEMLodUat6C 1Gz1GJQ4vifJ2iyXS+lvvBiOaeDDqZbV3q6JtdsiIJbY2bJLCx81/TL7hj7c7zyz/Ic6 haTJwQcn0A2snXchlX4jDD/mZSZmpuvhLO4ya7NXWAf5MmtOyVEeS8QuAnZ5yHeUruH+ ZEkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=dqg79VqYTA3ma988rafgPlAMHNMLyphdtVDRs25CV4s=; fh=QnycA4+uWeAVCYL7h6b0z9A/3SxbadAdGKOuCLGMjWY=; b=0+3WGCU3KS0V16CAWTDYU7Bz5fu7Hx3y0LvOQX5lssMtIjOB4t4EXDceG8FWSe++FN c2XzdoQ6l3EhuLza8ljcat7bJKcmEEmX/nMFBCh/1EDAbWAZlRVBxkzO7ITQM9HR+nlh vUHT5j7Yz/eUd90b2TeoNYC3L0nKhgTbCKggcXecy7bXYVzezZQW+g/tOO/a16C3fMPM SuUaZnabJq61/rUDXN666yfFq3BzTLWMy0PLCUKo4g+2vTdWu9KX4xWrY4x7FShScWNu zFy/VchSyt8LCV+OHzr1rx2kaRW34nupWLwNEVs3HrLUB/bqhwTIn12cU78hz5wLlBuU 0IFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JuIm0fZ0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169924-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169924-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id pa15-20020a05620a830f00b0079158f66be8si9052014qkn.372.2024.05.06.06.46.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 06:46:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-169924-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JuIm0fZ0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-169924-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-169924-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D57261C21048 for ; Mon, 6 May 2024 13:46:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9408880020; Mon, 6 May 2024 13:46:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JuIm0fZ0" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0DA27BAE7; Mon, 6 May 2024 13:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715003191; cv=none; b=RGiOs07D1ejRi9tjE0DiodPwomHmUgwyjPHiJoAg55jMqLI8LRKmiXnwgN9tqsxxOOtpF8MtP2HbqgurhDN73kLVFUSh20B0s5BfaTrXP2yuAG0AbqsypPJhBHllEys6XDf4i4UQ3AEyneMHpQa0jSoDKEeBcDUaj4nkMr2a5/s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715003191; c=relaxed/simple; bh=aESUy15wVYlJIj9vHepc1l3+tvAKYbDk97F0MtsZ6dk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ms58mh7spdz0MC/6HcqWOiAsOgEbLJR3Wjn4yu5YFU5nnodx3jsV1wiz+JGUhhhR/7ec/ZpkdF1BlcciELcg1k8u2CWvYxUhMKsM69iGugukG7i9XdJaBd3BajbDQ0ORIOVmbD2YRGBsEamBkkWV/KntqnwL9kh190DGtTeyDpg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JuIm0fZ0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7D55C116B1; Mon, 6 May 2024 13:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715003191; bh=aESUy15wVYlJIj9vHepc1l3+tvAKYbDk97F0MtsZ6dk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JuIm0fZ0nXElSVYXr8rO4iw6hhRoGATQjZMfP033Bd4k6RDcQAkFUXOfAlOMf5jp6 tUo2PmBR+NjehyLKu4TPq7VuxCKOlpFCb+myJ7UZZRKYxhunaF1bCjBDhZDEsGA2cv WN27Pyo20yVVAM5m2AacrZTA2wU9Pr0iyEH3h0oo/HWiac7taH+/qaYLko3Ga7MAWs oRP1IiKTb7PlwswNZlVbiSNh0D3ytUmE47n0n9Fe1LuI0lWilnqar+thwm4GYGS68o 5HIfd0ySi3dQfZPXJBZ0o7aOdDzBvLFZw7aaw5O1jJ3BDLFSXiAOngxton0jAa7Ceg 902onoWDjYhrA== Date: Mon, 6 May 2024 14:46:16 +0100 From: Jonathan Cameron To: Nuno =?UTF-8?B?U8Oh?= Cc: Julien Stephan , Lars-Peter Clausen , Michael Hennerich , Nuno =?UTF-8?B?U8Oh?= , David Lechner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Liam Girdwood , Mark Brown , kernel test robot , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RFC v6 10/10] iio: adc: ad7380: add support for resolution boost Message-ID: <20240506144616.0b90664b@jic23-huawei> In-Reply-To: References: <20240501-adding-new-ad738x-driver-v6-0-3c0741154728@baylibre.com> <20240501-adding-new-ad738x-driver-v6-10-3c0741154728@baylibre.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 06 May 2024 10:55:46 +0200 Nuno S=C3=A1 wrote: > On Wed, 2024-05-01 at 16:55 +0200, Julien Stephan wrote: > > ad738x chips are able to use an additional 2 bits of resolution when > > using oversampling. The 14-bits chips can have up to 16 bits of > > resolution and the 16-bits chips can have up to 18 bits of resolution. > >=20 > > In order to dynamically allow to enable/disable the resolution boost > > feature, we have to set iio realbits/storagebits to the maximum per chi= ps. > > This means that for iio, data will always be on the higher resolution > > available, and to cope with that we adjust the iio scale and iio offset > > depending on the resolution boost status. > >=20 > > The available scales can be displayed using the regular _scale_available > > attributes and can be set by writing the regular _scale attribute. > > The available scales depend on the oversampling status. > >=20 > > Signed-off-by: Julien Stephan > >=20 > > --- > >=20 > > In order to support the resolution boost (additional 2 bits of resoluti= on) > > we need to set realbits/storagebits to the maximum value i.e : > > =C2=A0 - realbits =3D 16 + 2 =3D 18, and storagebits =3D 32 for 16-bits= chips > > =C2=A0 - realbits =3D 14 + 2 =3D 16, and storagebits =3D 16 for 14-bits= chips > >=20 > > For 14-bits chips this does not have a major impact, but this > > has the drawback of forcing 16-bits chip users to always use 32-bits > > words in buffers even if they are not using oversampling and resolution > > boost. Is there a better way of implementing this? For example > > implementing dynamic scan_type? > > =20 >=20 > Yeah, I don't think it's that bad in this case. But maybe dynamic scan ty= pes is > something we may need at some point yes (or IOW that I would like to see = supported > :)). We do some ADCs (eg: ad4630) where we use questionably use FW proper= ties to set > a specific operating mode exactly because we have a different data layout= (scan > elements) depending on the mode. Yeah. Fixed scan modes were somewhat of a bad design decision a long time b= ack. However, the big advantage is that it got people to think hard about whethe= r it is worth supporting low precision modes. For slow devices it very rarely is and forcing people to make a decision and the advantage we never supported low precision on those parts. Having said that there are good reasons for dynamic resolution changing (the main one being the storage case you have here) so I'd be happy to see some patches adding it. It might be easier than I've always thought to bolt on. This and inkernel event consumers have been the two significant features where I keep expecting it to happen, but every time people decide they real= ly don't care enough to make them work :( > =20 > > Another issue is the location of the timestamps. I understood the need > > for ts to be consistent between chips, but right now I do not have a > > better solution.. I was thinking of maybe adding the timestamps at the > > beginning? That would imply to change the iio_chan_spec struct and maybe > > add a iio_push_to_buffers_with_timestamp_first() wrapper function? Is > > that an option? You have lost me on this one. Why does the timestamp need to be in a consi= stent location? We have lots of drivers where it moves about between different chips they support, or indeed what channels are currently turned on. I haven't actually looked at the latest code yet, so maybe it will become obvious! Jonathan