iio: core: introduce dB scle: IIO_VAL_INT_PLUS_MICRO_DB
Subsystems (3)
[email protected]
maintainerPATCH 1/3 iio: core: introduce dB scle: IIO_VAL_INT_PLUS_MICRO_DB
From: Michael Hennerich <[email protected]>
--- drivers/iio/industrialio-core.c | 19 +++++++++++++------ include/linux/iio/types.h | 1 + 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/iio/industrialio-core.c +13 -6
@@ -295,26 +295,33 @@ static ssize_t iio_read_channel_info(struct device *dev,struct iio_dev *indio_dev =dev_get_drvdata (dev);struct iio_dev_attr *this_attr =to_iio_dev_attr (attr);int val, val2; +bool scale_db = false;int ret = indio_dev->info->read_raw (indio_dev, this_attr->c, &val, &val2, this_attr->address);if (ret <0 )return ret; -if (ret ==IIO_VAL_INT ) +switch (ret) { +case IIO_VAL_INT :return sprintf (buf,"%d\n" , val); -else if (ret ==IIO_VAL_INT_PLUS_MICRO ) { +case IIO_VAL_INT_PLUS_MICRO_DB : + scale_db = true; +case IIO_VAL_INT_PLUS_MICRO :if (val2 <0 ) -return sprintf (buf,"-%d.%06u\n" , val, -val2); +return sprintf (buf,"-%d.%06u%s\n" , val, -val2, + scale_db ?" dB" :"" );else -return sprintf (buf,"%d.%06u\n" , val, val2); - }else if (ret ==IIO_VAL_INT_PLUS_NANO ) { +return sprintf (buf,"%d.%06u%s\n" , val, val2, + scale_db ?" dB" :"" ); +case IIO_VAL_INT_PLUS_NANO :if (val2 <0 )return sprintf (buf,"-%d.%09u\n" , val, -val2);else return sprintf (buf,"%d.%09u\n" , val, val2); - }else +default :return 0 ; + } } static ssize_t iio_write_channel_info(struct device *dev,
include/linux/iio/types.h +1 -0
@@ -50,5 +50,6 @@ enum iio_modifier {#define IIO_VAL_INT 1#define IIO_VAL_INT_PLUS_MICRO 2#define IIO_VAL_INT_PLUS_NANO 3 +#define IIO_VAL_INT_PLUS_MICRO_DB 4#endif /* _IIO_TYPES_H_ */
--
1.7.0.4
[email protected]
maintainerPATCH 2/3 iio: core: introduce IIO_CHAN_INFO_HARDWAREGAIN
From: Michael Hennerich <[email protected]>
--- Documentation/ABI/testing/sysfs-bus-iio | 7 +++++++ drivers/iio/industrialio-core.c | 1 + include/linux/iio/iio.h | 5 +++++ 3 files changed, 13 insertions(+), 0 deletions(-)
Documentation/ABI/testing/sysfs-bus-iio +7 -0
@@ -280,6 +280,13 @@ Description: If a discrete set of scale values are available, they are listed in this attribute. +What /sys/bus/iio/devices/iio:deviceX/out_voltageY_hardwaregain +KernelVersion: 2.6.35 +Contact: [email protected] +Description: + Hardware applied gain factor. If shared across all channels, + <type>_hardwaregain is used. + What: /sys/.../in_accel_filter_low_pass_3db_frequency What: /sys/.../in_magn_filter_low_pass_3db_frequency What: /sys/.../in_anglvel_filter_low_pass_3db_frequency
drivers/iio/industrialio-core.c +1 -0
@@ -91,6 +91,7 @@ static const char * const iio_chan_info_postfix[] = { [IIO_CHAN_INFO_SAMP_FREQ] = "sampling_frequency", [IIO_CHAN_INFO_FREQUENCY] = "frequency", [IIO_CHAN_INFO_PHASE] = "phase", + [IIO_CHAN_INFO_HARDWAREGAIN] = "hardwaregain", }; const struct iio_chan_spec
include/linux/iio/iio.h +5 -0
@@ -34,6 +34,7 @@ enum iio_chan_info_enum {IIO_CHAN_INFO_SAMP_FREQ ,IIO_CHAN_INFO_FREQUENCY ,IIO_CHAN_INFO_PHASE , + IIO_CHAN_INFO_HARDWAREGAIN, };#define IIO_CHAN_INFO_SHARED_BIT (type) BIT(type*2)
@@ -95,6 +96,10 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_PHASE)#define IIO_CHAN_INFO_PHASE_SHARED_BIT \ IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_PHASE) +#define IIO_CHAN_INFO_HARDWAREGAIN_SEPARATE_BIT \ + IIO_CHAN_INFO_SEPARATE_BIT(IIO_CHAN_INFO_HARDWAREGAIN) +#define IIO_CHAN_INFO_HARDWAREGAIN_SHARED_BIT \ + IIO_CHAN_INFO_SHARED_BIT(IIO_CHAN_INFO_HARDWAREGAIN)enum iio_endian {IIO_CPU ,
--
1.7.0.4
[email protected]
maintainerPATCH 3/3 iio: amplifiers: New driver for AD8366 Dual-Digital Variable Gain Amplifier
In reply to [email protected]From: Michael Hennerich <[email protected]>
Changes since V1:
Apply review feedback:
Introduce and use IIO_CHAN_INFO_HARDWAREGAIN Introduce and use Use IIO_VAL_INT_PLUS_MICRO_DB
Modify out of staging include paths.
Convert to new iio core API naming.
Changes since V2:
more sanity checking in write_raw
--- drivers/iio/Kconfig | 2 + drivers/iio/Makefile | 2 + drivers/iio/amplifiers/Kconfig | 17 +++ drivers/iio/amplifiers/Makefile | 5 + drivers/iio/amplifiers/ad8366.c | 222 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 248 insertions(+), 0 deletions(-) create mode 100644 drivers/iio/amplifiers/Kconfig create mode 100644 drivers/iio/amplifiers/Makefile create mode 100644 drivers/iio/amplifiers/ad8366.c
drivers/iio/Kconfig +2 -0
@@ -48,4 +48,6 @@ config IIO_CONSUMERS_PER_TRIGGER This value controls the maximum number of consumers that a given trigger may handle. Default is 2. +source "drivers/iio/amplifiers/Kconfig" + endif # IIO
drivers/iio/Makefile +2 -0
@@ -8,3 +8,5 @@ industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o obj-$(CONFIG_IIO_KFIFO_BUF) += kfifo_buf.o + +obj-y += amplifiers/
drivers/iio/amplifiers/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# +# Gain Amplifiers, etc. +# +menu "Amplifiers" + +config AD8366 + tristate "Analog Devices AD8366 VGA" + depends on SPI + select BITREVERSE + help + Say yes here to build support for Analog Devices AD8366 + SPI Dual-Digital Variable Gain Amplifier (VGA). + + To compile this driver as a module, choose M here: the + module will be called ad8366. + +endmenu
drivers/iio/amplifiers/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile iio/amplifiers +# + +obj-$(CONFIG_AD8366) += ad8366.o
drivers/iio/amplifiers/ad8366.c new file +222 -0
222 lines not on this page · raw message
--
1.7.0.4
Re: [PATCH 3/3] iio: amplifiers: New driver for AD8366 Dual-Digital Variable Gain Amplifier
Quoted 15 lines · On Fri, May 11, 2012 at 11:36:54AM +0200, [email protected] wrote:
From: Michael Hennerich <[email protected]>
Changes since V1:
Apply review feedback:
Introduce and useIIO_CHAN_INFO_HARDWAREGAINIntroduce and use UseIIO_VAL_INT_PLUS_MICRO_DBModify out of staging include paths.
Convert to new iio core API naming.Changes since V2:
more sanity checking in
write_raw
Quoted 8 lines
Signed-off-by Michael Hennerich <[email protected]>Acked-by Jonathan Cameron<[email protected]>--- drivers/iio/Kconfig | 2 + drivers/iio/Makefile | 2 + drivers/iio/amplifiers/Kconfig | 17 +++ drivers/iio/amplifiers/Makefile | 5 + drivers/iio/amplifiers/ad8366.c | 222 +++++++++++++++++++++++++++++++++++++++
Woah, the first "real" iio driver? Congrats!
greg k-h