Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1917837lql; Wed, 13 Mar 2024 11:47:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXP82NwS+SwQp4AaiSEKzohOQNJrvEBJ5A2aq3Ck3WsbNDYObOj8u2d+15hmn+1WxQtC0uq+Nna3an11hJHo9C7oQvQxZbxsb70i3+ftw== X-Google-Smtp-Source: AGHT+IFZZqGBF76wp6Gb5zdCvCrh3QmYERedzQ7H7U0Tr4WM5V9J0xTW/4Wtebq387jV62n376zD X-Received: by 2002:a05:620a:9c4:b0:788:4a6e:edec with SMTP id y4-20020a05620a09c400b007884a6eedecmr1095629qky.32.1710355653830; Wed, 13 Mar 2024 11:47:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710355653; cv=pass; d=google.com; s=arc-20160816; b=XgCwIUCB9QFToTPx9pR7WekwRrhlD1ZkB6elkU1vPIO6yzwuPN1nB/oKSYaCaT7zLp bbIo7C/m5WMkfEoC/o0y/jxfm34xNF21P98JYiy6pfJ3+6kVsUeVCZMKdzbRUq2ygV2e /uG+ng3lKnprd1eWL6MSNtfFQLp/5n1j7erllXW6+/1JkR5dSmEooujn+eHCKN8fq5bN 1bbSNOLi/FzXWfetRJt0SuWPp3utgS+Ip0Crb2/JEJ9us0zuiAO/IgiJxxQ+Wa4B6MhH ZSp/5Omzsz3AceMR4eSaPapctcUCm/8akBMpdNkRN0R+kE/OJtAWAWV8QVoDl8Z96oW7 jcGA== 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 :date:subject:cc:to:from:dkim-signature; bh=gdi90LxAyqPq+F4TfJtl0rFJuWs6klQUvdsruwMjWcE=; fh=ZB7DvrbNd+RgLKn183vb1HI20YwI/xumNoJrVFoYSmI=; b=WJ6/KAYGzmZnSgnUhvXw5eE58yvJEfM42404Air7xXX2q0XM0WV0r/1x6SvKE7ytOs 7D0FOrmMCcBopzc0UHNROn1Alv3ryMVoh5BkpWXYpy3FabLCabnkq3w/Z+BSYLnZP4Gi +xi4UKQTcKLe3YS53+tgAmJXlxB7vcnuQG6a2UzO4AP2e1Y62muQYgT/xOO+93kljXGy 0uG0BSI1EJa9gea1OKzpbdQUU4dmTKuY4D5+LqjNEG/qaonNVMzStu6DIICxy0M5nBFa l56XnZD+0B0JTnrGo70WsjKLaq8DsunXwsG6KKkrB8BYuOKkNGiPO1BidAcgy7sQrV4X ybsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XqtvRuDt; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-102285-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102285-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a26-20020a05620a103a00b00788401feb66si3421773qkk.397.2024.03.13.11.47.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 11:47:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102285-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=@gmail.com header.s=20230601 header.b=XqtvRuDt; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-102285-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102285-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 32E2D1C26AC5 for ; Wed, 13 Mar 2024 18:45:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 925C4130AE3; Wed, 13 Mar 2024 17:40:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XqtvRuDt" Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1FF512FF69; Wed, 13 Mar 2024 17:40:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710351623; cv=none; b=iisuRhKoV7BZFHsFyKcBIfSjOekf681ILbqqr2rfDomBwhS8ObKODqvCM58K//fP0h33SZqF2ITOKBNPJR4JgNX4LOvW6Je4DTHoxsUjgbO31gGZbPiPIJI9vwFjS3gBVzQM0rs8rLoO96CrLxQL7qupw+VEfTlqHZl5GH4MO+Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710351623; c=relaxed/simple; bh=zN8xCu1gH5zHdheG29PSsKuC/jtm9T0XpojF7b5SZ3g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GTgOrPqBo58vnj0noOGVukHgjwWwfocguyv2uxn0X9PilOjh8Z1MbwyY6XcvgtwKcz2678+B7fhC+X2B2bmERDQsx9QmzOVjV1VTdblYLYoA0S7nZJvvcFPCdEFJ6z31z46XGLlsdKb+YI3/aViHhbLM4CjUTnZrOkOKdHa4GPw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XqtvRuDt; arc=none smtp.client-ip=209.85.208.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-56838e00367so136774a12.0; Wed, 13 Mar 2024 10:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710351620; x=1710956420; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gdi90LxAyqPq+F4TfJtl0rFJuWs6klQUvdsruwMjWcE=; b=XqtvRuDtlrkjQcV6UBEjgtKYVQ5hwEePbNuzNRt6Za9GneqA+ZywPJCkfwPmnbH0Rn MDFL++6ruDdR0i8gc0iPfTAuP7Wivp+aQyjq7teBhptSvyr/dFWoRxWl1FetkswWpAB/ 978FlDoWoG/kWOpvABYSt822vnMW68uX0aM+tQRh1c/dZtxMrmiXDDzn2T5EPzKt7Zv0 Jot1VtcmZvlUi+XyYYSLZssEBphLqXFmM4z79hKZVXciN0zPhUPtamIv4h6mh6Uarn+W 6z5anA8EM78aJq/p4SL2hps3bBWxmahZZue08NRyazFw/1WO4N98cBKPxU1/Rc7/z3V/ zq2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710351620; x=1710956420; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gdi90LxAyqPq+F4TfJtl0rFJuWs6klQUvdsruwMjWcE=; b=YLLVwqnJW2Q0z9PZ+CP3sVtQwtOk/P9es79bfDgORW21xxzGh9mU9+q1uV9kBnv9ah FDNKCU+aFuYwxULOkVqe9AJ29EFJeSMsQsTVMJJfWkcPzf8LNIIHiJ8oPh94S9JtTLFO b+HgUetGFrwlo4ewdzN1OqfTPcFN8Vr/HToVqprx30BWkjtDUiuJstFOxbI6+2Ms3qdR r56ob33XceSsbRxDOUDFlTD0ytisLVyoskT4yIRLHkAo9yAvrlzMEtYvyspTRRnu+8gE rR6V4kUMKUudg/QkOeOoR+8ke10WBmlm5UFbab9auph8/WskC81g74HrZKR3wOGiqKUK RqHg== X-Forwarded-Encrypted: i=1; AJvYcCUtEPqOSMXZPGNJAtos7H+5vVNuzk9XjxUsfBnRkibM8HaoP/pw/oBzD3XC0O2r3FSHNw2d2ADxmhOzN1+mZUQPjiS9iCSADiKHQUWB8y8QG9fl1gI5FI1GEDWXzXw2DE6rHh2PqMKL X-Gm-Message-State: AOJu0YyamvN+3mRZzfTBX1KocfzLd2lzAcTUrSbQQchweoLqUwc3E71j /KwroxS1d+Ga4nxqHbXtrmBWksZ7b9wqb7FVaaIzOB/btPycOLqC X-Received: by 2002:a17:907:d50c:b0:a46:3ce4:5aef with SMTP id wb12-20020a170907d50c00b00a463ce45aefmr5219842ejc.57.1710351619935; Wed, 13 Mar 2024 10:40:19 -0700 (PDT) Received: from localhost.localdomain ([2a04:ee41:82:7577:fa35:157e:1a40:3463]) by smtp.gmail.com with ESMTPSA id m17-20020a1709061ed100b00a449076d0dbsm5028215ejj.53.2024.03.13.10.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 10:40:19 -0700 (PDT) From: Vasileios Amoiridis To: jic23@kernel.org Cc: lars@metafoo.de, andriy.shevchenko@linux.intel.com, ang.iglesiasg@gmail.com, mazziesaccount@gmail.com, ak@it-klinger.de, petre.rodan@subdimension.ro, linus.walleij@linaro.org, phil@raspberrypi.com, 579lpy@gmail.com, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Vasileios Amoiridis Subject: [PATCH v3 3/6] iio: pressure: add SCALE and RAW values for channels Date: Wed, 13 Mar 2024 18:40:04 +0100 Message-Id: <20240313174007.1934983-4-vassilisamir@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240313174007.1934983-1-vassilisamir@gmail.com> References: <20240313174007.1934983-1-vassilisamir@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add extra IIO_CHAN_INFO_SCALE and IIO_CHAN_INFO_RAW in order to be able to calculate the processed value with standard userspace IIO tools. Can be used for triggered buffers as well. Signed-off-by: Vasileios Amoiridis --- drivers/iio/pressure/bmp280-core.c | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/iio/pressure/bmp280-core.c b/drivers/iio/pressure/bmp280-core.c index dfd845acfa22..6d7734f867bc 100644 --- a/drivers/iio/pressure/bmp280-core.c +++ b/drivers/iio/pressure/bmp280-core.c @@ -138,16 +138,22 @@ static const struct iio_chan_spec bmp280_channels[] = { { .type = IIO_PRESSURE, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), }, { .type = IIO_TEMP, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), }, { .type = IIO_HUMIDITYRELATIVE, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), }, }; @@ -156,6 +162,8 @@ static const struct iio_chan_spec bmp380_channels[] = { { .type = IIO_PRESSURE, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), @@ -163,6 +171,8 @@ static const struct iio_chan_spec bmp380_channels[] = { { .type = IIO_TEMP, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), @@ -170,6 +180,8 @@ static const struct iio_chan_spec bmp380_channels[] = { { .type = IIO_HUMIDITYRELATIVE, .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), @@ -485,6 +497,52 @@ static int bmp280_read_raw(struct iio_dev *indio_dev, break; } break; + case IIO_CHAN_INFO_RAW: + switch (chan->type) { + case IIO_HUMIDITYRELATIVE: + *val = data->chip_info->read_humid(data); + ret = IIO_VAL_INT; + break; + case IIO_PRESSURE: + *val = data->chip_info->read_press(data); + ret = IIO_VAL_INT; + break; + case IIO_TEMP: + *val = data->chip_info->read_temp(data); + ret = IIO_VAL_INT; + break; + default: + ret = -EINVAL; + break; + } + break; + case IIO_CHAN_INFO_SCALE: + switch (chan->type) { + case IIO_HUMIDITYRELATIVE: + *val = data->chip_info->humid_coeffs[0]; + *val2 = data->chip_info->humid_coeffs[1]; + ret = IIO_VAL_FRACTIONAL; + break; + case IIO_PRESSURE: + *val = data->chip_info->press_coeffs[0]; + *val2 = data->chip_info->press_coeffs[1]; + ret = IIO_VAL_FRACTIONAL; + break; + case IIO_TEMP: + *val = data->chip_info->temp_coeffs[0]; + *val2 = data->chip_info->temp_coeffs[1]; + + if (!strcmp(indio_dev->name, "bmp580")) + ret = IIO_VAL_FRACTIONAL_LOG2; + else + ret = IIO_VAL_FRACTIONAL; + + break; + default: + ret = -EINVAL; + break; + } + break; case IIO_CHAN_INFO_OVERSAMPLING_RATIO: switch (chan->type) { case IIO_HUMIDITYRELATIVE: -- 2.25.1