Skip to contentSkip to conversation

iio: temperature: mlx90632: Interface to change object ambient temperature

PATCH Superseded Crt Mori 2 participants 2 messages Sep 4, 2020

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Crt Mori

author maintainer
#0 lore raw

PATCH 1/1 iio: temperature: mlx90632: Interface to change object ambient temperature

Since object temperature might be different than the sensor temperature the infra red sensors should provide an interface to inject ambient temperature. This was in past done via write to ambient temperature interface (in_temp_ambient_raw), but I think most people did not know about it. This solution introduces a new iio type of the CALIBAMBIENT which is hopefully more descriptive and more explicit about the purpose and capabilities of the sensors.

---
 drivers/iio/industrialio-core.c    |  2 ++
 drivers/iio/temperature/mlx90632.c | 10 ++++++++--
 include/linux/iio/types.h          |  1 +
 3 files changed, 11 insertions(+), 2 deletions(-)
drivers/iio/industrialio-core.c +2 -0
index 606d5e61c575..754597f087d1 100644
@@ -165,6 +165,8 @@ static const char * const iio_chan_info_postfix[] = {
 	[IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity",
 	[IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio",
 	[IIO_CHAN_INFO_THERMOCOUPLE_TYPE] = "thermocouple_type",
+	[IIO_CHAN_INFO_CALIBAMBIENT] = "calibambient",
+
 };
 
 #if defined(CONFIG_DEBUG_FS)
drivers/iio/temperature/mlx90632.c +8 -2
index 94bca2b2866a..67bf9f000122 100644
@@ -761,7 +761,9 @@ static int mlx90632_read_raw(struct iio_dev *indio_dev,
 			*val2 = data->emissivity * 1000;
 		}
 		return IIO_VAL_INT_PLUS_MICRO;
-
+	case IIO_CHAN_INFO_CALIBAMBIENT:
+		*val = data->object_ambient_temperature;
+		return IIO_VAL_INT;
 	default:
 		return -EINVAL;
 	}
@@ -781,6 +783,9 @@ static int mlx90632_write_raw(struct iio_dev *indio_dev,
 			return -EINVAL;
 		data->emissivity = val * 1000 + val2 / 1000;
 		return 0;
+	case IIO_CHAN_INFO_CALIBAMBIENT:
+		data->object_ambient_temperature = val;
+		return 0;
 	default:
 		return -EINVAL;
 	}
@@ -798,7 +803,8 @@ static const struct iio_chan_spec mlx90632_channels[] = {
 		.modified = 1,
 		.channel2 = IIO_MOD_TEMP_OBJECT,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
-			BIT(IIO_CHAN_INFO_CALIBEMISSIVITY),
+			BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) |
+			BIT(IIO_CHAN_INFO_CALIBAMBIENT),
 	},
 };
 
include/linux/iio/types.h +1 -0
index e6fd3645963c..1e3ed6f55bca 100644
@@ -59,6 +59,7 @@ enum iio_chan_info_enum {
 	IIO_CHAN_INFO_CALIBEMISSIVITY,
 	IIO_CHAN_INFO_OVERSAMPLING_RATIO,
 	IIO_CHAN_INFO_THERMOCOUPLE_TYPE,
+	IIO_CHAN_INFO_CALIBAMBIENT,
 };
 
 #endif /* _IIO_TYPES_H_ */
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Crt Mori

Since object temperature might be different than the sensor temperature the infra red sensors should provide an interface to inject ambient

infrared

Quoted 5 lines

temperature. This was in past done via write to ambient temperature interface (in_temp_ambient_raw), but I think most people did not know about it. This solution introduces a new iio type of the CALIBAMBIENT which is hopefully more descriptive and more explicit about the purpose and capabilities of the sensors.

After addressing above and below, FWIW,

Quoted 13 lines
---
 drivers/iio/industrialio-core.c    |  2 ++
 drivers/iio/temperature/mlx90632.c | 10 ++++++++--
 include/linux/iio/types.h          |  1 +
 3 files changed, 11 insertions(+), 2 deletions(-)
drivers/iio/industrialio-core.c +0 -0
index 606d5e61c575..754597f087d1 100644

drivers/iio/industrialio-core.c static const char * const iio_chan_info_postfix[] = { · line 170

Quoted 6 lines
drivers/iio/industrialio-core.c +2 -0
@@ -165,6 +165,8 @@ static const char * const iio_chan_info_postfix[] = {
        [IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity",
        [IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio",
        [IIO_CHAN_INFO_THERMOCOUPLE_TYPE] = "thermocouple_type",
+       [IIO_CHAN_INFO_CALIBAMBIENT] = "calibambient",
 
+

Unrelated.

drivers/iio/temperature/mlx90632.c static int mlx90632_read_raw(struct iio_dev *indio_dev, · line 765

Quoted 13 lines
drivers/iio/industrialio-core.c +0 -0
 };
 

#if defined(CONFIG_DEBUG_FS)

drivers/iio/temperature/mlx90632.c +0 -1
index 94bca2b2866a..67bf9f000122 100644
@@ -761,7 +761,9 @@ static int mlx90632_read_raw(struct iio_dev *indio_dev,
                        *val2 = data->emissivity * 1000;
                }
                return IIO_VAL_INT_PLUS_MICRO;
 
-

Unrelated...

drivers/iio/temperature/mlx90632.c static int mlx90632_read_raw(struct iio_dev *indio_dev, · line 766

Quoted 3 lines
drivers/iio/temperature/mlx90632.c +3 -0
+       case IIO_CHAN_INFO_CALIBAMBIENT:
+               *val = data->object_ambient_temperature;
+               return IIO_VAL_INT;

...and thus missed the blank line here.

Quoted 14 lines
drivers/iio/temperature/mlx90632.c +0 -0
        default:
                return -EINVAL;
        }
drivers/iio/temperature/mlx90632.c +3 -0
@@ -781,6 +783,9 @@ static int mlx90632_write_raw(struct iio_dev *indio_dev,
                        return -EINVAL;
                data->emissivity = val * 1000 + val2 / 1000;
                return 0;
+       case IIO_CHAN_INFO_CALIBAMBIENT:
+               data->object_ambient_temperature = val;
+               return 0;
        default:
                return -EINVAL;
        }

drivers/iio/temperature/mlx90632.c static const struct iio_chan_spec mlx90632_channels[] = { · line 809

Quoted 8 lines
drivers/iio/temperature/mlx90632.c +2 -1
@@ -798,7 +803,8 @@ static const struct iio_chan_spec mlx90632_channels[] = {
                .modified = 1,
                .channel2 = IIO_MOD_TEMP_OBJECT,
                .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) |
 
-                       BIT(IIO_CHAN_INFO_CALIBEMISSIVITY),
+                       BIT(IIO_CHAN_INFO_CALIBEMISSIVITY) |
 
+                       BIT(IIO_CHAN_INFO_CALIBAMBIENT),

You can squeeze it in between to reduce churn in this change.

Quoted 18 lines
drivers/iio/temperature/mlx90632.c +0 -0
        },

};

include/linux/iio/types.h +1 -1
index e6fd3645963c..1e3ed6f55bca 100644
@@ -59,6 +59,7 @@ enum iio_chan_info_enum {
        IIO_CHAN_INFO_CALIBEMISSIVITY,
        IIO_CHAN_INFO_OVERSAMPLING_RATIO,
        IIO_CHAN_INFO_THERMOCOUPLE_TYPE,
+       IIO_CHAN_INFO_CALIBAMBIENT,
 };
 
 #endif /* _IIO_TYPES_H_ */
--

2.25.1

Signature · 2 lines
With Best Regards,
Andy Shevchenko