Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1926742ybz; Sat, 2 May 2020 10:59:19 -0700 (PDT) X-Google-Smtp-Source: APiQypI5cCO7nEf8RqzrRFwqGBZsFUH7EK4hV1xJ6MPMiuMIaZL5leIOA22d40GG5zh3s+vmXwD/ X-Received: by 2002:a17:906:5608:: with SMTP id f8mr8629437ejq.190.1588442359086; Sat, 02 May 2020 10:59:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588442359; cv=none; d=google.com; s=arc-20160816; b=QLf2o6Lq2KNrQ8tj3iwaXbYtFzoj3BeWjRvg6qOfcLKhw5Dp5nwtIL+n0omhEHir9N ZVU4WV8HV334QwZcLas4OpSi02bYNvILE61AgxKyPN6x0ovToa+BEH1FKOEy/6pHbPXQ Qgz0FC+x+b2zX99Sgk3pnnjxWhc8j7PEUH05KkQ8kDQcxGC0iZBO6eTvmgIjW4zrqGtL MZNh/JBSzSZBUtCsCrh2gZM5t/ppG/MTT4dqhcpbQyDe5EwM6j3DJ+TcRfAMEnJqRI6r veIR5icIhE2pMzPV/QYGx8TNfovHzJATtBMd85y98xIcshljxSEyj69flLjHqcqeQBmR UNXw== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ECwzm/tKADfFU3t1/Funjh1xc1zKxJZ8j7ZsedPIr+w=; b=mlgTHPx4clJESnRwej1LAho3hKKpEVM07gr8DzD5ngbkuPe51+0GzCDav8dQ/g97dz kRdkIBw8AalfSJqrT6IJerLjrrTqbgX3IFJILraXAldmYug+zPSMMJR0OIJYVTpL3O+2 j1GDfHYZ9CaJXCqr98Ha9D5V2Vy1yBN/LFIweJKmAWHCugMwudalrwAinoHpVp8mAGb8 gbEfzTVg69USTxfPIeeX+3hsF3YETbiXJoWxmo1EbO/AiFXIAH4gm3Kt8/CyVsk5sqs4 mkfee24HjIvLmFF9lRjC1zZmbtinPwIjNHO8OT9jmP/z6QIehlCdjwnztA/dDf/ZAcsA 7pJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MiEddyPC; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si4082717ejc.284.2020.05.02.10.58.31; Sat, 02 May 2020 10:59:19 -0700 (PDT) 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=@kernel.org header.s=default header.b=MiEddyPC; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728328AbgEBR4U (ORCPT + 99 others); Sat, 2 May 2020 13:56:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:46860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728266AbgEBR4U (ORCPT ); Sat, 2 May 2020 13:56:20 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC5DB2075B; Sat, 2 May 2020 17:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588442179; bh=Pyti/oXfxkkEpTlk5s7TE6yHsZRFMYA9AHGC30Lb498=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=MiEddyPCAtLTlxuDcubVgInzAEFFsHVAHPZPu/p+l56T1dNxwRmAHYtbBmCYfu9Gf 3YxZRiagCdB8m1kCD/GgnuHiqWzq/RlwOFw+2bcF+cHC6EOcUGFoY5SEwq9ysTaHk3 im/59ryejSfqE5hmVOADG140OyukQDJuCEAgKtaE= Date: Sat, 2 May 2020 18:56:15 +0100 From: Jonathan Cameron To: Gwendal Grignou Cc: Enric Balletbo i Serra , Benson Leung , Guenter Roeck , linux-kernel , linux-iio Subject: Re: [PATCH 2/2] iio: cros_ec_light: Add support for RGB sensor Message-ID: <20200502185615.74db5af1@archlinux> In-Reply-To: References: <20200423000230.82750-1-gwendal@chromium.org> <20200423000230.82750-3-gwendal@chromium.org> <20200425183101.531b49be@archlinux> X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 30 Apr 2020 14:07:03 -0700 Gwendal Grignou wrote: > On Sat, Apr 25, 2020 at 10:31 AM Jonathan Cameron wrote: > > > > On Wed, 22 Apr 2020 17:02:30 -0700 > > Gwendal Grignou wrote: > > > > > Add support for color sensors behind EC like TCS3400. > > > The color data can be presented in Red Green Blue color space (RGB) or > > > the CIE 1931 XYZ color space (XYZ). > > > In XYZ mode, the sensor is configured for auto calibrating its channels > > > and is the "normal" mode. > > > The driver tells the EC to switch between the 2 modes by using the > > > calibration command. > > > When the sensor is in calibration mode, only clear and RGB channels are > > > available. In normal mode, only clear and XYZ are. > > > When RGB channels are enabled, the sensor switches to calibration mode > > > when the buffer is enabled. > > > > > > When reading trhough sysfs command, set calibration mode and then read > > > the channel(s). A command will be issue for each read, so the channels > > > may come from different sensor sample. > > > When using the buffer, after setting the mask, when the buffer is > > > enabled, the calibration will be set based on the channel mask. > > > > > > libiio tools can be used to gather sensor information: > > > iio_readdev -s 10 cros-ec-light \ > > > illuminance_clear illuminance_x illuminance_y illuminance_z > > Illuminance is not defined for color channels. It's units are LUX which > > is only defined wrt to a model of the human eye's response to > > 'brightness' (kind of). > Looking at "Calculating Color Temperature and Illuminance " from AMS > [https://ams.com/documents/20143/80162/TCS34xx_AN000517_1-00.pdf/1efe49f7-4f92-ba88-ca7c-5121691daff7] > page 5, equation 2, the illuminance (Y) is a derived from the vector > (X, Y, Z) with coefficient applied. Doesn't it mean > in_illumincance_[X,Y,Z,R,G,B,clear ...]_raw have all the same unit, > lux? Unfortunately not. Lux is only defined as brightness as measured with a very specific sensitivity profile across the bands. It has no meaning as a unit for the various elements added up to get to it. (somewhere good old dimensional analysis breaks down) Fun corner case of units :) I have seen data sheets that get this wrong btw. It's a complex mess because RGB channels are not separable either. They all have overlapping frequency sensitivities. Generally the sensors are designed to have some linear combination of curves that is close to the curve used for illuminance as they want to match human eye view of what bright is. If you can provide enough info to the driver to do the calculation that would be ideal as then we could provide a standard measure of brightness to userspace. Jonathan