iio: light: fix scale in veml6030
Subsystems (3)
Javier Carrasco
maintainerv2 cover iio: light: fix scale in veml6030
This series follows a similar approach as recently used for the veml3235 by using iio-gts to manage the scale as stated in the ABI. In its current form, the driver exposes the hardware gain instead of the multiplier for the raw value to obtain a value in lux.
Although this driver and the veml3235 have many similarities, there are two main differences in this series compared to the one used to fix the other driver:
- The veml6030 has fractional gains, which are not supported by the iio-gts helpers. My first attempt was adding support for them, but that made the whole iio-gts implementation more complex, cumbersome, and the risk of affecting existing clients was not negligible. Instead, a x8 factor has been used for the hardware gain to present the minimum value (x0.125) as x1, keeping linearity. The scales iio-gts generates are therefore right without any extra conversion, and they match the values provided in the different datasheets.
- This driver included a processed value for the ambient light, maybe because the scale did not follow the ABI and the conversion was not direct. To avoid breaking userspace, the functionality has been kept, but of course using the fixed scales. In order to ease the calculations, iio_gts_get_total_gain() has been exported to avoid working directly with the scale in NANO, that would require 64-bit operations.
To ease the usage of the iio-gts selectors, patches to support regfields and caching has been included.
This issue has been present since the original implementation, and it affects all devices it supports.
This series has been tested with a veml7700 (same gains as veml6030) and a veml6035 with positive results.
---
Changes in v2:
- Rename SEL_GAIN to indicate they are in MILLI.
- Split first patch (regfields and chaching).
- Use regfield structs in chip struct instead of function pointer.
- Use total gain to derive scale, avoiding 64-bit divisions.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Javier Carrasco (4):
iio: light: veml6030: extend regmap to support regfields
iio: light: veml6030: extend regmap to support caching
iio: gts-helper: export iio_gts_get_total_gain()
iio: light: veml6030: fix scale to conform to ABI
drivers/iio/industrialio-gts-helper.c | 3 +- drivers/iio/light/Kconfig | 1 + drivers/iio/light/veml6030.c | 608 +++++++++++++++++----------------- include/linux/iio/iio-gts-helper.h | 1 + 4 files changed, 299 insertions(+), 314 deletions(-)
---
base-commit: 577a66e2e634f712384c57a98f504c44ea4b47da
change-id: 20241231-veml6030-scale-8142f387e7e6
Best regards,
Signature · 1 line
Javier Carrasco <[email protected]>
Javier Carrasco
maintainerPATCH v2 1/4 iio: light: veml6030: extend regmap to support regfields
Add support for regfields as well to simplify register operations, taking into account the different fields for the veml6030/veml7700 and veml6035.
--- drivers/iio/light/veml6030.c | 95 ++++++++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 25 deletions(-)
drivers/iio/light/veml6030.c +70 -25
@@ -59,18 +59,31 @@#define VEML6035_INT_CHAN BIT(3)#define VEML6035_CHAN_EN BIT(2) +/* Regfields */ +#define VEML6030_GAIN_RF REG_FIELD(VEML6030_REG_ALS_CONF, 11, 12) +#define VEML6030_IT_RF REG_FIELD(VEML6030_REG_ALS_CONF, 6, 9) + +#define VEML6035_GAIN_RF REG_FIELD(VEML6030_REG_ALS_CONF, 10, 12) +enum veml6030_scan {VEML6030_SCAN_ALS ,VEML6030_SCAN_WH ,VEML6030_SCAN_TIMESTAMP , }; +struct veml6030_rf { +struct regmap_field *it; +struct regmap_field *gain; +}; +struct veml603x_chip {const char *name;const int (*scale_vals)[][2 ];const int num_scale_vals;const struct iio_chan_spec *channels;const int num_channels; +const struct reg_field gain_rf; +const struct reg_field it_rf;int (*hw_init)(struct iio_dev *indio_dev,struct device *dev);int (*set_info)(struct iio_dev *indio_dev);int (*set_als_gain)(struct iio_dev *indio_dev,int val,int val2);
@@ -91,6 +104,7 @@ struct veml603x_chip {struct veml6030_data {struct i2c_client *client;struct regmap *regmap; +struct veml6030_rf rf;int cur_resolution;int cur_gain;int cur_integration_time;
@@ -330,17 +344,17 @@ static const struct regmap_config veml6030_regmap_config = {static int veml6030_get_intgrn_tm (struct iio_dev *indio_dev,int *val,int *val2) { -int ret, reg; +int it_idx, ret;struct veml6030_data *data =iio_priv (indio_dev); - ret =regmap_read (data->regmap,VEML6030_REG_ALS_CONF , ®); + ret =regmap_field_read (data->rf.it, &it_idx);if (ret) {dev_err (&data->client->dev,"can't read als conf register %d\n" , ret);return ret; } -switch ((reg >>6 ) &0xF ) { +switch (it_idx) {case 0 : *val2 =100000 ;break ;
@@ -405,8 +419,7 @@ static int veml6030_set_intgrn_tm(struct iio_dev *indio_dev,return -EINVAL ; } - ret =regmap_update_bits (data->regmap,VEML6030_REG_ALS_CONF , -VEML6030_ALS_IT , new_int_time); + ret =regmap_field_write (data->rf.it, new_int_time);if (ret) {dev_err (&data->client->dev,"can't update als integration time %d\n" , ret);
@@ -510,23 +523,22 @@ static int veml6030_set_als_gain(struct iio_dev *indio_dev,struct veml6030_data *data =iio_priv (indio_dev);if (val ==0 && val2 ==125000 ) { - new_gain =0x1000 ;/* 0x02 << 11 */ + new_gain =0x01 ; gain_idx =3 ; }else if (val ==0 && val2 ==250000 ) { - new_gain =0x1800 ; + new_gain =0x11 ; gain_idx =2 ; }else if (val ==1 && val2 ==0 ) { new_gain =0x00 ; gain_idx =1 ; }else if (val ==2 && val2 ==0 ) { - new_gain =0x800 ; + new_gain =0x01 ; gain_idx =0 ; }else {return -EINVAL ; } - ret =regmap_update_bits (data->regmap,VEML6030_REG_ALS_CONF , -VEML6030_ALS_GAIN , new_gain); + ret =regmap_field_write (data->rf.gain, new_gain);if (ret) {dev_err (&data->client->dev,"can't set als gain %d\n" , ret);
@@ -544,30 +556,31 @@ static int veml6035_set_als_gain(struct iio_dev *indio_dev, int val, int val2)struct veml6030_data *data =iio_priv (indio_dev);if (val ==0 && val2 ==125000 ) { - new_gain =VEML6035_SENS ; + new_gain =FIELD_GET (VEML6035_GAIN_M ,VEML6035_SENS ); gain_idx =5 ; }else if (val ==0 && val2 ==250000 ) { - new_gain =VEML6035_SENS |VEML6035_GAIN ; + new_gain =FIELD_GET (VEML6035_GAIN_M ,VEML6035_SENS | +VEML6035_GAIN ); gain_idx =4 ; }else if (val ==0 && val2 ==500000 ) { - new_gain =VEML6035_SENS |VEML6035_GAIN | -VEML6035_DG ; + new_gain =FIELD_GET (VEML6035_GAIN_M ,VEML6035_SENS | +VEML6035_GAIN |VEML6035_DG ); gain_idx =3 ; }else if (val ==1 && val2 ==0 ) { new_gain =0x0000 ; gain_idx =2 ; }else if (val ==2 && val2 ==0 ) { - new_gain =VEML6035_GAIN ; + new_gain =FIELD_GET (VEML6035_GAIN_M ,VEML6035_GAIN ); gain_idx =1 ; }else if (val ==4 && val2 ==0 ) { - new_gain =VEML6035_GAIN |VEML6035_DG ; + new_gain =FIELD_GET (VEML6035_GAIN_M ,VEML6035_GAIN | +VEML6035_DG ); gain_idx =0 ; }else {return -EINVAL ; } - ret =regmap_update_bits (data->regmap,VEML6030_REG_ALS_CONF , -VEML6035_GAIN_M , new_gain); + ret =regmap_field_write (data->rf.gain, new_gain);if (ret) {dev_err (&data->client->dev,"can't set als gain %d\n" , ret);return ret;
@@ -581,17 +594,17 @@ static int veml6035_set_als_gain(struct iio_dev *indio_dev, int val, int val2)static int veml6030_get_als_gain (struct iio_dev *indio_dev,int *val,int *val2) { -int ret, reg; +int gain, ret;struct veml6030_data *data =iio_priv (indio_dev); - ret =regmap_read (data->regmap,VEML6030_REG_ALS_CONF , ®); + ret =regmap_field_read (data->rf.gain, &gain);if (ret) {dev_err (&data->client->dev,"can't read als conf register %d\n" , ret);return ret; } -switch ((reg >>11 ) &0x03 ) { +switch (gain) {case 0 : *val =1 ; *val2 =0 ;
@@ -617,17 +630,17 @@ static int veml6030_get_als_gain(struct iio_dev *indio_dev,static int veml6035_get_als_gain (struct iio_dev *indio_dev,int *val,int *val2) { -int ret, reg; +int gain, ret;struct veml6030_data *data =iio_priv (indio_dev); - ret =regmap_read (data->regmap,VEML6030_REG_ALS_CONF , ®); + ret =regmap_field_read (data->rf.gain, &gain);if (ret) {dev_err (&data->client->dev, -"can't read als conf register %d\n" , ret); +"can't read als conf register %d\n" , ret);return ret; } -switch (FIELD_GET (VEML6035_GAIN_M , reg)) { +switch (gain) {case 0 : *val =1 ; *val2 =0 ;
@@ -990,6 +1003,27 @@ static int veml7700_set_info(struct iio_dev *indio_dev)return 0 ; } +static int veml6030_regfield_init (struct iio_dev *indio_dev) +{ +struct veml6030_data *data =iio_priv (indio_dev); +struct regmap *regmap = data->regmap; +struct device *dev = &data->client->dev; +struct regmap_field *rm_field; +struct veml6030_rf *rf = &data->rf; + + rm_field =devm_regmap_field_alloc (dev, regmap, data->chip->it_rf); +if (IS_ERR (rm_field)) +return PTR_ERR (rm_field); + rf->it = rm_field; + + rm_field =devm_regmap_field_alloc (dev, regmap, data->chip->gain_rf); +if (IS_ERR (rm_field)) +return PTR_ERR (rm_field); + rf->gain = rm_field; + +return 0 ; +} +/* * Set ALS gain to 1/8, integration time to 100 ms, PSM to mode 2, * persistence to 1 x integration time and the threshold
@@ -1143,6 +1177,11 @@ static int veml6030_probe(struct i2c_client *client)if (ret <0 )return ret; + ret =veml6030_regfield_init (indio_dev); +if (ret) +return dev_err_probe (&client->dev, ret, +"failed to init regfields\n" ); + ret = data->chip->hw_init (indio_dev, &client->dev);if (ret <0 )return ret;
@@ -1191,6 +1230,8 @@ static const struct veml603x_chip veml6030_chip = { .num_scale_vals = ARRAY_SIZE(veml6030_scale_vals), .channels = veml6030_channels, .num_channels = ARRAY_SIZE(veml6030_channels), + .gain_rf = VEML6030_GAIN_RF, + .it_rf = VEML6030_IT_RF, .hw_init = veml6030_hw_init, .set_info = veml6030_set_info, .set_als_gain = veml6030_set_als_gain,
@@ -1203,6 +1244,8 @@ static const struct veml603x_chip veml6035_chip = { .num_scale_vals = ARRAY_SIZE(veml6035_scale_vals), .channels = veml6030_channels, .num_channels = ARRAY_SIZE(veml6030_channels), + .gain_rf = VEML6035_GAIN_RF, + .it_rf = VEML6030_IT_RF, .hw_init = veml6035_hw_init, .set_info = veml6030_set_info, .set_als_gain = veml6035_set_als_gain,
@@ -1215,6 +1258,8 @@ static const struct veml603x_chip veml7700_chip = { .num_scale_vals = ARRAY_SIZE(veml6030_scale_vals), .channels = veml7700_channels, .num_channels = ARRAY_SIZE(veml7700_channels), + .gain_rf = VEML6030_GAIN_RF, + .it_rf = VEML6030_IT_RF, .hw_init = veml6030_hw_init, .set_info = veml7700_set_info, .set_als_gain = veml6030_set_als_gain,
Signature · 1 line
2.43.0
Javier Carrasco
maintainerPATCH v2 2/4 iio: light: veml6030: extend regmap to support caching
In reply to Javier CarrascoThe configuration registers are not volatile and are not affected by read operations (i.e. not precious), making them suitable to be cached in order to reduce the number of accesses to the device.
Add support for caching (RBTREE type).
--- drivers/iio/light/veml6030.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/iio/light/veml6030.c +31 -0
@@ -333,12 +333,43 @@ static const struct iio_chan_spec veml7700_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(VEML6030_SCAN_TIMESTAMP), }; +static const struct regmap_range veml6030_readable_ranges[] = { +regmap_reg_range (VEML6030_REG_ALS_CONF ,VEML6030_REG_ALS_INT ), +}; + +static const struct regmap_access_table veml6030_readable_table = { + .yes_ranges = veml6030_readable_ranges, + .n_yes_ranges =ARRAY_SIZE (veml6030_readable_ranges), +}; + +static const struct regmap_range veml6030_writable_ranges[] = { +regmap_reg_range (VEML6030_REG_ALS_CONF ,VEML6030_REG_ALS_PSM ), +}; + +static const struct regmap_access_table veml6030_writable_table = { + .yes_ranges = veml6030_writable_ranges, + .n_yes_ranges =ARRAY_SIZE (veml6030_writable_ranges), +}; + +static const struct regmap_range veml6030_volatile_ranges[] = { +regmap_reg_range (VEML6030_REG_ALS_DATA ,VEML6030_REG_WH_DATA ), +}; + +static const struct regmap_access_table veml6030_volatile_table = { + .yes_ranges = veml6030_volatile_ranges, + .n_yes_ranges =ARRAY_SIZE (veml6030_volatile_ranges), +}; +static const struct regmap_config veml6030_regmap_config = { .name ="veml6030_regmap" , .reg_bits =8 , .val_bits =16 , .max_register =VEML6030_REG_ALS_INT , .val_format_endian =REGMAP_ENDIAN_LITTLE , + .rd_table = &veml6030_readable_table, + .wr_table = &veml6030_writable_table, + .volatile_table = &veml6030_volatile_table, + .cache_type =REGCACHE_RBTREE , }; static int veml6030_get_intgrn_tm(struct iio_dev *indio_dev,
Signature · 1 line
2.43.0
Javier Carrasco
maintainerPATCH v2 3/4 iio: gts-helper: export iio_gts_get_total_gain()
In reply to Javier CarrascoExport this function in preparation for the fix in veml6030.c, where the total gain can be used to ease the calculation of the processed value of the IIO_LIGHT channel compared to acquiring the scale in NANO.
--- drivers/iio/industrialio-gts-helper.c | 3 ++- include/linux/iio/iio-gts-helper.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/iio/industrialio-gts-helper.c +2 -1
@@ -950,7 +950,7 @@ int iio_gts_find_gain_time_sel_for_scale(struct iio_gts *gts, int scale_int, }EXPORT_SYMBOL_NS_GPL (iio_gts_find_gain_time_sel_for_scale,"IIO_GTS_HELPER" ); -static int iio_gts_get_total_gain (struct iio_gts *gts,int gain,int time) +int iio_gts_get_total_gain (struct iio_gts *gts,int gain,int time) {const struct iio_itime_sel_mul *itime;
@@ -966,6 +966,7 @@ static int iio_gts_get_total_gain(struct iio_gts *gts, int gain, int time)return gain * itime->mul; } +EXPORT_SYMBOL_NS_GPL (iio_gts_get_total_gain,"IIO_GTS_HELPER" );static int iio_gts_get_scale_linear (struct iio_gts *gts,int gain,int time,u64 *scale)
include/linux/iio/iio-gts-helper.h +1 -0
@@ -208,5 +208,6 @@ int iio_gts_all_avail_scales(struct iio_gts *gts, const int **vals, int *type, int *length);int iio_gts_avail_scales_for_time (struct iio_gts *gts,int time,const int **vals,int *type,int *length); +int iio_gts_get_total_gain (struct iio_gts *gts,int gain,int time);#endif
Signature · 1 line
2.43.0
Matti Vaittinen
maintainerRe: [PATCH v2 3/4] iio: gts-helper: export iio_gts_get_total_gain()
Quoted 6 lines · Javier Carrasco
Export this function in preparation for the fix in
veml6030.c, where the total gain can be used to ease the calculation of the processed value of theIIO_LIGHTchannel compared to acquiring the scale in NANO.Suggested-by Matti Vaittinen <[email protected]>Signed-off-by Javier Carrasco <[email protected]>
Hi Javier,
This is fine but could you please go the extra mile and add a doc to the function? I'd like to have kerneldoc for all exported functions.
Quoted 38 lines
--- drivers/iio/industrialio-gts-helper.c | 3 ++- include/linux/iio/iio-gts-helper.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)drivers/iio/industrialio-gts-helper.c +2
-1@@ -950,7 +950,7 @@ int iio_gts_find_gain_time_sel_for_scale(struct iio_gts *gts, int scale_int, }EXPORT_SYMBOL_NS_GPL (iio_gts_find_gain_time_sel_for_scale,"IIO_GTS_HELPER" ); -static int iio_gts_get_total_gain (struct iio_gts *gts,int gain,int time) +int iio_gts_get_total_gain (struct iio_gts *gts,int gain,int time) {const struct iio_itime_sel_mul *itime;@@ -966,6 +966,7 @@ static int iio_gts_get_total_gain(struct iio_gts *gts, int gain, int time)return gain * itime->mul; } +EXPORT_SYMBOL_NS_GPL (iio_gts_get_total_gain,"IIO_GTS_HELPER" );static int iio_gts_get_scale_linear (struct iio_gts *gts,int gain,int time,u64 *scale)include/linux/iio/iio-gts-helper.h +1
-0@@ -208,5 +208,6 @@ int iio_gts_all_avail_scales(struct iio_gts *gts, const int **vals, int *type, int *length);int iio_gts_avail_scales_for_time (struct iio_gts *gts,int time,const int **vals,int *type,int *length); +int iio_gts_get_total_gain (struct iio_gts *gts,int gain,int time);#endif
Javier Carrasco
maintainerRe: [PATCH v2 3/4] iio: gts-helper: export iio_gts_get_total_gain()
Quoted 5 lines · Matti Vaittinen
Quoted 4 lines · Javier Carrasco
Export this function in preparation for the fix in
veml6030.c, where the total gain can be used to ease the calculation of the processed value of theIIO_LIGHTchannel compared to acquiring the scale in NANO.
Quoted 8 lines
Quoted 2 lines
Suggested-by Matti Vaittinen <[email protected]>Signed-off-by Javier Carrasco <[email protected]>Hi Javier,
This is fine but could you please go the extra mile and add a doc to the function? I'd like to have kerneldoc for all exported functions.
Hi Matti,
Sure, I will add that for v3.
Thanks for your feedback and best regards,
Javier Carrasco
Javier Carrasco
maintainerPATCH v2 4/4 iio: light: veml6030: fix scale to conform to ABI
In reply to Javier CarrascoThe current scale is not ABI-compliant as it is just the sensor gain instead of the value that acts as a multiplier to be applied to the raw value (there is no offset).
Use the iio-gts helpers to obtain the proper scale values according to the gain and integration time to match the resolution tables from the datasheet and drop dedicated variables to store the current values of the integration time, gain and resolution. When at it, use 'scale' instead of 'gain' consistently for the get/set functions to avoid misunderstandings.
--- drivers/iio/light/Kconfig | 1 + drivers/iio/light/veml6030.c | 528 ++++++++++++++++++------------------------- 2 files changed, 218 insertions(+), 311 deletions(-)
drivers/iio/light/Kconfig +1 -0
@@ -683,6 +683,7 @@ config VEML6030 select REGMAP_I2C select IIO_BUFFER select IIO_TRIGGERED_BUFFER + select IIO_GTS_HELPER depends on I2C help Say Y here if you want to build a driver for the Vishay VEML6030
drivers/iio/light/veml6030.c +217 -311
731 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v2 4/4] iio: light: veml6030: fix scale to conform to ABI
Quoted 11 lines · Javier Carrasco
The current scale is not ABI-compliant as it is just the sensor gain instead of the value that acts as a multiplier to be applied to the raw value (there is no offset).
Use the iio-gts helpers to obtain the proper scale values according to the gain and integration time to match the resolution tables from the datasheet and drop dedicated variables to store the current values of the integration time, gain and resolution. When at it, use 'scale' instead of 'gain' consistently for the get/set functions to avoid misunderstandings.
Quoted 2 lines
Fixes 7b779f573c48 ("iio: light: add driver for veml6030 ambient light sensor")Signed-off-by Javier Carrasco <[email protected]>
Hi Javier,
Sorry for the delay - been a bit busy lately. I didn't do a thorough review but the total_gain (and rest of the GTS) usage looked good to me :)
Jonathan Cameron
maintainerQuoted 29 lines · On Sun, 19 Jan 2025 18:31:57 +0100 Javier Carrasco…
This series follows a similar approach as recently used for the veml3235 by using iio-gts to manage the scale as stated in the ABI. In its current form, the driver exposes the hardware gain instead of the multiplier for the raw value to obtain a value in lux.
Although this driver and the veml3235 have many similarities, there are two main differences in this series compared to the one used to fix the other driver:
- The veml6030 has fractional gains, which are not supported by the iio-gts helpers. My first attempt was adding support for them, but that made the whole iio-gts implementation more complex, cumbersome, and the risk of affecting existing clients was not negligible. Instead, a x8 factor has been used for the hardware gain to present the minimum value (x0.125) as x1, keeping linearity. The scales iio-gts generates are therefore right without any extra conversion, and they match the values provided in the different datasheets.
- This driver included a processed value for the ambient light, maybe because the scale did not follow the ABI and the conversion was not direct. To avoid breaking userspace, the functionality has been kept, but of course using the fixed scales. In order to ease the calculations,
iio_gts_get_total_gain()has been exported to avoid working directly with the scale in NANO, that would require 64-bit operations.To ease the usage of the iio-gts selectors, patches to support regfields and caching has been included.
Quoted 7 lines
This issue has been present since the original implementation, and it affects all devices it supports.
This series has been tested with a veml7700 (same gains as veml6030) and a veml6035 with positive results.
Signed-off-by Javier Carrasco <[email protected]>
Whilst we might consider a backport eventually. This is a huge patch to do that with. Hence I'll take this the slow way for next merge window.
For now I've applied patches 1 and 2 in the interest of nibbling away at what we will need to see again ;)
Jonathan
Quoted 25 lines
---
Changes in v2:
- RenameSEL_GAINto indicate they are in MILLI.
- Split first patch (regfields and chaching).
- Use regfield structs in chip struct instead of function pointer.
- Use total gain to derive scale, avoiding 64-bit divisions.
- Link to v1: https://lore.kernel.org/r/[email protected]---
Javier Carrasco (4):
iio: light: veml6030: extend regmap to support regfields
iio: light: veml6030: extend regmap to support caching
iio: gts-helper: exportiio_gts_get_total_gain()
iio: light: veml6030: fix scale to conform to ABIdrivers/iio/industrialio-gts-helper.c | 3 +- drivers/iio/light/Kconfig | 1 + drivers/iio/light/veml6030.c | 608 +++++++++++++++++----------------- include/linux/iio/iio-gts-helper.h | 1 + 4 files changed, 299 insertions(+), 314 deletions(-)---
base-commit:577a66e2e634f712384c57a98f504c44ea4b47da
change-id: 20241231-veml6030-scale-8142f387e7e6Best regards,
Javier Carrasco
maintainerQuoted 38 lines · Jonathan Cameron
Quoted 35 lines · On Sun, 19 Jan 2025 18:31:57 +0100 Javier Carrasco…
This series follows a similar approach as recently used for the veml3235 by using iio-gts to manage the scale as stated in the ABI. In its current form, the driver exposes the hardware gain instead of the multiplier for the raw value to obtain a value in lux.
Although this driver and the veml3235 have many similarities, there are two main differences in this series compared to the one used to fix the other driver:
- The veml6030 has fractional gains, which are not supported by the iio-gts helpers. My first attempt was adding support for them, but that made the whole iio-gts implementation more complex, cumbersome, and the risk of affecting existing clients was not negligible. Instead, a x8 factor has been used for the hardware gain to present the minimum value (x0.125) as x1, keeping linearity. The scales iio-gts generates are therefore right without any extra conversion, and they match the values provided in the different datasheets.
- This driver included a processed value for the ambient light, maybe because the scale did not follow the ABI and the conversion was not direct. To avoid breaking userspace, the functionality has been kept, but of course using the fixed scales. In order to ease the calculations,
iio_gts_get_total_gain()has been exported to avoid working directly with the scale in NANO, that would require 64-bit operations.To ease the usage of the iio-gts selectors, patches to support regfields and caching has been included.
This issue has been present since the original implementation, and it affects all devices it supports.
This series has been tested with a veml7700 (same gains as veml6030) and a veml6035 with positive results.
Quoted 9 lines
Quoted 1 line
Signed-off-by Javier Carrasco <[email protected]>Whilst we might consider a backport eventually. This is a huge patch to do that with. Hence I'll take this the slow way for next merge window.
For now I've applied patches 1 and 2 in the interest of nibbling away at what we will need to see again ;)
Jonathan
Thanks, Jonathan.
Could you please tell me where you applied them, so I
can rebase onto that branch? I did not find them in linux-next/master, iio/testing or iio/togreg. Or should they show up in one of those within the next hours/days?
Best regards,
Javier Carrasco.