Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2045931rdf; Mon, 6 Nov 2023 03:14:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IEG+domvzKjcDRcNpgHzbS6em9lrU/00uDsjK2M1aWCuwf6PNVhB8wA6d3ZIZ9mOnbGmuCZ X-Received: by 2002:a05:6a21:7784:b0:181:731:89b7 with SMTP id bd4-20020a056a21778400b00181073189b7mr9581365pzc.41.1699269261564; Mon, 06 Nov 2023 03:14:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699269261; cv=none; d=google.com; s=arc-20160816; b=mxMN6swOGJWOrLCeSb/HHIpLnxq8X3iFeYHSeBu6vegSnJJzKvm2qFmqJGGU2dtUyR hfZonyTJMFd+fNUjItxt5cYKX9mczVtAdGft2pyfOEVAWCY2Mxr/KkzUiS35s+Cd8rim fXaIlGMl7nzLqbEDfIrBDNza+jj/Y9rxbpjaTEGLMTjxDK5DCbLe30yHSex+5CzaR+Q0 9T5NELViVRXoXHfDA+lOGAeS+9EaTaLo/4OcXhnPmEM9CfKx9Dy9Y64dW0ivS+Q3lB0F 5AiddzhIcpmchD4dQ1glT2pr+vrjF5qJKEcdUkGXLkfdX/xoCcGHGejHBzj37vDx0Ybe DncA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ASYeqWLZxxjIVgy6EHS2K8zIoZqIg2f0Sad0tW1q4EM=; fh=fiUwKbHF4iENAMGk7dJxiT85dhQZ5POxApgFyBDhOl0=; b=O2i2XFGn2u9O7sXetVPJRfUJOwSHJgPVX1m7yLxXOqiymPIDq6Y43E+IYgKXz5F3CM XP+1DPoyvHXfoGJ4Pk7JDaDSbIsbLkq5hncCZRTsn5/Uwn/yA+IzJEwKcSOpp+Q7nC49 cUmv2yLc7wnrUURcaNBA6cLLEyY8uGnZLM7MgRimXEENLgBvtzcOwEpTqoZ+Om8p3rnr eLkAmT+DYenZtSkjaACe5BbGfIp/lEyG6nj/+tvswU3DGz5Yq2BeQVnz2e6yx+idFZki hzQ/Go/TxfQ7HpMwCgAA5uyhZJ0j5fgvQ08oLgnIi0UaojJeUV4ctjT0l6E4ObEJeknN df8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M0f8UiyC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id cm21-20020a056a020a1500b005655bf61e32si8534425pgb.23.2023.11.06.03.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 03:14:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M0f8UiyC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D77ED808EEC3; Mon, 6 Nov 2023 03:14:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230522AbjKFLOF (ORCPT + 99 others); Mon, 6 Nov 2023 06:14:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230155AbjKFLOE (ORCPT ); Mon, 6 Nov 2023 06:14:04 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D723798; Mon, 6 Nov 2023 03:14:01 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F952C433C8; Mon, 6 Nov 2023 11:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699269241; bh=3rFOHrsFOQYq+raXX3AQ97EcKFDbUZXhJyj0nxmUet8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=M0f8UiyCntVadWOwOWAEI2Yz0mZtXoSOrbRWAqk0fbr7inHullOT1DiNpwz83cqsU fTSa2Uf1EcZV4ZcihO5dJf17tk/9LerZ0H1LuiM8pJbJBoJFmKyaiGEQ1BUJjPYWnr uOtBmRi9wtTZSf+HfWKQvezMTDReOO1f8InVtDvfDdzRk/zmhbM+8yGCeZyEcLP8kD zX6TSwm5m49x/m2WYaMb9XOR4HmDpXJyCL0FFVlYxLGblu+KPhi25UyfUC78m4HSbT tgz/z1N2M25PGBaZJGgNb10wnmUEVUlAxujMheydJrxdyy4aI1YsfACCUCLJPXDSVP ypIicqxm3dyKA== Date: Mon, 6 Nov 2023 11:13:55 +0000 From: Jonathan Cameron To: Subhajit Ghosh Cc: Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matti Vaittinen , Andy Shevchenko , Paul Gazzillo , Matt Ranostay , Stefan Windfeldt-Prytz , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] iio: light: Add support for APDS9306 Light Sensor Message-ID: <20231106111355.2f8dfaa1@jic23-huawei> In-Reply-To: <2974aa13-796c-49ef-bef7-fd7f3f9b7f49@tweaklogic.com> References: <20231027074545.6055-1-subhajit.ghosh@tweaklogic.com> <20231027074545.6055-3-subhajit.ghosh@tweaklogic.com> <20231028162025.4259f1cc@jic23-huawei> <2974aa13-796c-49ef-bef7-fd7f3f9b7f49@tweaklogic.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 06 Nov 2023 03:14:19 -0800 (PST) On Tue, 31 Oct 2023 19:08:08 +1030 Subhajit Ghosh wrote: > > > >> +static struct iio_event_spec apds9306_event_spec_als[] = { > >> + { > >> + .type = IIO_EV_TYPE_THRESH, > >> + .dir = IIO_EV_DIR_RISING, > >> + .mask_shared_by_all = BIT(IIO_EV_INFO_VALUE), > >> + }, { > >> + .type = IIO_EV_TYPE_THRESH, > >> + .dir = IIO_EV_DIR_FALLING, > >> + .mask_shared_by_all = BIT(IIO_EV_INFO_VALUE), > >> + }, { > >> + .type = IIO_EV_TYPE_THRESH, > >> + .mask_shared_by_all = BIT(IIO_EV_INFO_PERIOD), > >> + }, { > >> + .type = IIO_EV_TYPE_THRESH_ADAPTIVE, > >> + .mask_shared_by_all = BIT(IIO_EV_INFO_VALUE) | > >> + BIT(IIO_EV_INFO_ENABLE), > >> + }, { > >> + .type = IIO_EV_TYPE_THRESH, > >> + .mask_separate = BIT(IIO_EV_INFO_ENABLE), > > This matches an entry above for type. Don't have separate entries. > >> + }, > >> +}; > >> + > >> +static struct iio_event_spec apds9306_event_spec_clear[] = { > >> + { > >> + .type = IIO_EV_TYPE_THRESH, > >> + .mask_separate = BIT(IIO_EV_INFO_ENABLE), > >> + }, > >> +}; > >> + > >> +#define APDS9306_CHANNEL(_type) \ > >> + .type = _type, \ > >> + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_INT_TIME) | \ > >> + BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ), \ > >> + .info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_INT_TIME) | \ > >> + BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_SAMP_FREQ), \ > > > > Scale on the intensity channel is interesting... What are the units? > > There tend not to be any well defined units for intensity (as opposed > > to illuminance). There may be gain on the signal, but it won't be in untils > > that map directly to a scale userspace should apply. This is one of the > > rare reasons for using the HARDWARE_GAIN element of the ABI. > > > > A tricky corner however as relationship between raw value and hardwaregain > > is not tightly defined (as it can be really weird!) > Hi Jonathan, > > Thank you for taking time for reviewing and clearing all my tiny doubts and > queries especially for the dt and versioning part. Much appreciated. > > In the above case, should I not expose scale for the "clear" channel? Rather, > how should I expose the "clear" channel to userspace? What is the scale? What units to you get after applying it? I suspect it's not well defined. Not sure what we've done in similar cases in the past. Perhaps have a look at those. There may be precedence for still using scale. I'm about to jump on a long haul flight (delayed - sigh) so don't have time to look myself! Jonathan > > Regards, > Subhajit Ghosh > > > > >> + > >> +static struct iio_chan_spec apds9306_channels_without_events[] = { > >> + { > >> + APDS9306_CHANNEL(IIO_LIGHT) > >> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > >> + }, { > >> + APDS9306_CHANNEL(IIO_INTENSITY) > >> + .channel2 = IIO_MOD_LIGHT_CLEAR, > >> + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), > >> + .modified = 1, > >> + }, > >> +}; > > > >