Skip to contentSkip to conversation

Add scan demux unit and use it in max1363

PATCH In review Jonathan Cameron 4 participants 12 messages Dec 5, 2011 – Dec 7, 2011

Subsystems (3)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

v3 cover Add scan demux unit and use it in max1363

Hi Greg,

The v3 here is just to indicate a tiny change suggested by Lars-Peter from the version that has been out for review on linux-iio. (Using ALIGN instead of hand rolling in one case in patch 4). Anyhow, not worth putting out for another review as Lars-Peter has tested and acked without it anyway.

Technically Lars-Peter only acked patches 4 and 5 but they are the important ones (the others being trivial or tied up with the max1363 driver which is one of mine..)

This set introduces the an optional demultiplexer into the path of data form devices to buffers. It is a necessary step on the path to in kernel push interfaces (trigger driven ones). Also rather useful on it's own as shown by the max1363 patches and some uses Lars-Peter has made of it in another series.

Anyhow fair bit more to come so time to send these on to you!

Thanks,

Jonathan

v2 text:
Hi All,

New version of this series. Two changes as per Lars-Peter's suggestions. ALIGN macro usage in patch 4 and one of the two for each bit set suggestions. The second is subtly different as it is finding bits after a certain point rather than from the start.

As explained in patch 5 discussion, I personally feel that the demux should occur prior to the buffer and avoiding the extra copy should be done by allowing buffers to provide callbacks for reserving (plus getting access to) space and
notifying that they are done filling it. Either way, now
is not the time to do this change. Too much else going on!

v1 text:
The last patch technically is a simple bug fix, but included here as it came up during testing of this series.

The 'interesting' bits are the rewrite of iio_sw_buffer_preenable. I'd like people with drivers currently using that function to test and see what I have broken. We should also be able to drop a number of cases in specific drivers in favour of this version.

The demux unit is designed to offer a straight path with little or no overhead if the client (here still the IIO buffer) needs all the data and to only get in the way when a subset of the active scan mask is requested.

I may well have messed this up so please please test this set.

Jonathan Cameron (7):
staging:iio:find iio channel from scan index util function staging:iio:buffer add a cache of the timestamp scan index. staging:iio: add hook to allow core to perform scan related config. staging:iio: make iio_sw_buffer_preenable much more general. staging:iio: add demux optionally to path from device to buffer staging:iio:adc:max1363 use new demuxing support. staging:iio:adc:max1363 correctly set channels as big endian.

 drivers/staging/iio/adc/max1363.h         |   11 ++-
 drivers/staging/iio/adc/max1363_core.c    |   18 ++-
 drivers/staging/iio/adc/max1363_ring.c    |   51 ++-----
 drivers/staging/iio/buffer.h              |   16 ++
 drivers/staging/iio/iio.h                 |   13 ++-
 drivers/staging/iio/industrialio-buffer.c |  212 +++++++++++++++++++++++++----
 drivers/staging/iio/industrialio-core.c   |   11 ++
 7 files changed, 259 insertions(+), 73 deletions(-)
Signature · 1 line
1.7.7.4
author maintainer
#1 lore raw

PATCH v3 1/7 staging:iio:find iio channel from scan index util function

From: Jonathan Cameron <[email protected]>

Useful for getting to the channel based on scan mask alone.

---
 drivers/staging/iio/iio.h               |    8 ++++++++
 drivers/staging/iio/industrialio-core.c |   11 +++++++++++
 2 files changed, 19 insertions(+), 0 deletions(-)
drivers/staging/iio/iio.h +8 -0
index 4aed915..95d6318 100644
@@ -323,6 +323,14 @@ struct iio_dev {
 };
 
 /**
+ * iio_find_channel_from_si() - get channel from its scan index
+ * @indio_dev:		device
+ * @si:			scan index to match
+ */
+const struct iio_chan_spec
+*iio_find_channel_from_si(struct iio_dev *indio_dev, int si);
+
+/**
  * iio_device_register() - register a device with the IIO subsystem
  * @indio_dev:		Device structure filled by the device driver
  **/
drivers/staging/iio/industrialio-core.c +11 -0
index d8cd9e3..dbd1ce1 100644
@@ -89,6 +89,17 @@ static const char * const iio_chan_info_postfix[] = {
 	= "filter_low_pass_3db_frequency",
 };
 
+const struct iio_chan_spec
+*iio_find_channel_from_si(struct iio_dev *indio_dev, int si)
+{
+	int i;
+
+	for (i = 0; i < indio_dev->num_channels; i++)
+		if (indio_dev->channels[i].scan_index == si)
+			return &indio_dev->channels[i];
+	return NULL;
+}
+
 /**
  * struct iio_detected_event_list - list element for events that have occurred
  * @list:		linked list header
Signature · 1 line
1.7.7.4
author maintainer
#2 lore raw

PATCH v3 2/7 staging:iio:buffer add a cache of the timestamp scan index.

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Basically avoids looking it up lots of times.

---
 drivers/staging/iio/buffer.h              |    1 +
 drivers/staging/iio/industrialio-buffer.c |    3 +++
 2 files changed, 4 insertions(+), 0 deletions(-)
drivers/staging/iio/buffer.h +1 -0
index 9de581e..4b8f619 100644
@@ -106,6 +106,7 @@ struct iio_buffer {
 	int					scan_count;
 	long					*scan_mask;
 	bool					scan_timestamp;
+	unsigned				scan_index_timestamp;
 	const struct iio_buffer_access_funcs	*access;
 	const struct iio_buffer_setup_ops		*setup_ops;
 	struct list_head			scan_el_dev_attr_list;
drivers/staging/iio/industrialio-buffer.c +3 -0
index 8c55980..b2cf3e3 100644
@@ -313,6 +313,9 @@ int iio_buffer_register(struct iio_dev *indio_dev,
 			if (ret < 0)
 				goto error_cleanup_dynamic;
 			attrcount += ret;
+			if (channels[i].type == IIO_TIMESTAMP)
+				buffer->scan_index_timestamp =
+					channels[i].scan_index;
 		}
 		if (indio_dev->masklength && buffer->scan_mask == NULL) {
 			buffer->scan_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
Signature · 1 line
1.7.7.4
author maintainer
#3 lore raw

PATCH v3 3/7 staging:iio: add hook to allow core to perform scan related config.

In reply to Jonathan Cameron
---
 drivers/staging/iio/iio.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/staging/iio/iio.h +2 -1
index 95d6318..4fb8f2f 100644
@@ -262,7 +262,8 @@ struct iio_info {
 				 int val);
 	int (*validate_trigger)(struct iio_dev *indio_dev,
 				struct iio_trigger *trig);
-
+	int (*update_scan_mode)(struct iio_dev *indio_dev,
+				const unsigned long *scan_mask);
 };
 
 /**
Signature · 1 line
1.7.7.4
author maintainer
#4 lore raw

PATCH v3 4/7 staging:iio: make iio_sw_buffer_preenable much more general.

In reply to Jonathan Cameron

Also introduces active_scan_mask storage to tell the core what is really being currently captured from the device (different from what is desired as often has bonus channels).

---
 drivers/staging/iio/iio.h                 |    2 +
 drivers/staging/iio/industrialio-buffer.c |   63 +++++++++++++++++------------
 2 files changed, 39 insertions(+), 26 deletions(-)
drivers/staging/iio/iio.h +2 -0
index 4fb8f2f..c225542 100644
@@ -280,6 +280,7 @@ struct iio_info {
  * @available_scan_masks: [DRIVER] optional array of allowed bitmasks
  * @masklength:		[INTERN] the length of the mask established from
  *			channels
+ * @active_scan_mask:	[INTERN] union of all scan masks requested by buffers
  * @trig:		[INTERN] current device trigger (buffer modes)
  * @pollfunc:		[DRIVER] function run on trigger being received
  * @channels:		[DRIVER] channel specification structure table
@@ -307,6 +308,7 @@ struct iio_dev {
 
 	unsigned long			*available_scan_masks;
 	unsigned			masklength;
+	unsigned long			*active_scan_mask;
 	struct iio_trigger		*trig;
 	struct iio_poll_func		*pollfunc;
 
drivers/staging/iio/industrialio-buffer.c +37 -26

75 lines not on this page · raw message

Signature · 1 line
1.7.7.4
author maintainer
#5 lore raw

PATCH v3 5/7 staging:iio: add demux optionally to path from device to buffer

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

This gives you only what you ask for which is handy for some devices with weird scan combinations.

Routes all data flow through a core utility function. That and this demuxing support will be needed to do demuxing to multiple destinations in kernel.

---
 drivers/staging/iio/buffer.h              |   15 +++
 drivers/staging/iio/industrialio-buffer.c |  146 ++++++++++++++++++++++++++++-
 2 files changed, 157 insertions(+), 4 deletions(-)
drivers/staging/iio/buffer.h +15 -0
index 4b8f619..5282441 100644
@@ -95,6 +95,8 @@ struct iio_buffer_setup_ops {
  * @access:		[DRIVER] buffer access functions associated with the
  *			implementation.
  * @flags:		[INTERN] file ops related flags including busy flag.
+ * @demux_list:		[INTERN] list of operations required to demux the scan.
+ * @demux_bounce:	[INTERN] buffer for doing gather from incoming scan.
  **/
 struct iio_buffer {
 	struct iio_dev				*indio_dev;
@@ -115,6 +117,8 @@ struct iio_buffer {
 	bool					stufftoread;
 	unsigned long				flags;
 	const struct attribute_group *attrs;
+	struct list_head			demux_list;
+	unsigned char				*demux_bounce;
 };
 
 /**
@@ -153,6 +157,17 @@ int iio_scan_mask_set(struct iio_buffer *buffer, int bit);
 	container_of(d, struct iio_buffer, dev)
 
 /**
+ * iio_push_to_buffer() - push to a registered buffer.
+ * @buffer:		IIO buffer structure for device
+ * @scan:		Full scan.
+ * @timestamp:
+ */
+int iio_push_to_buffer(struct iio_buffer *buffer, unsigned char *data,
+		       s64 timestamp);
+
+int iio_update_demux(struct iio_dev *indio_dev);
+
+/**
  * iio_buffer_register() - register the buffer with IIO core
  * @indio_dev: device with the buffer to be registered
  **/
drivers/staging/iio/industrialio-buffer.c +142 -4

167 lines not on this page · raw message

Signature · 1 line
1.7.7.4
author maintainer
#6 lore raw

PATCH v3 7/7 staging:iio:adc:max1363 correctly set channels as big endian.

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Also, the differential channels should always have been signed.

---
 drivers/staging/iio/adc/max1363_core.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
drivers/staging/iio/adc/max1363_core.c +12 -2
index 7e078fc..9febd1b 100644
@@ -298,7 +298,12 @@ static const enum max1363_modes max1363_mode_list[] = {
 		.channel = num,						\
 		.address = addr,					\
 		.info_mask = MAX1363_INFO_MASK,				\
-		.scan_type = IIO_ST('u', bits, (bits > 8) ? 16 : 8, 0), \
+		.scan_type = {						\
+			.sign = 'u',					\
+			.realbits = bits,				\
+			.storagebits = (bits > 8) ? 16 : 8,		\
+			.endianness = IIO_BE,				\
+		},							\
 		.scan_index = si,					\
 		.event_mask = evmask,					\
 	}
@@ -313,7 +318,12 @@ static const enum max1363_modes max1363_mode_list[] = {
 		.channel2 = num2,					\
 		.address = addr,					\
 		.info_mask = MAX1363_INFO_MASK,				\
-		.scan_type = IIO_ST('u', bits, (bits > 8) ? 16 : 8, 0), \
+		.scan_type = {						\
+			.sign = 's',					\
+			.realbits = bits,				\
+			.storagebits = (bits > 8) ? 16 : 8,		\
+			.endianness = IIO_BE,				\
+		},							\
 		.scan_index = si,					\
 		.event_mask = evmask,					\
 	}
Signature · 1 line
1.7.7.4
#7 lore raw
In reply to Jonathan Cameron

Hi Jonathan,

I can't seem to find a proper way to apply this patchset. On what patchset is it based ?

I'm still here with what seems to be a rather old version of your tree (3413ec), but it is still the head of your git tree on kernel.org.

Thanks,
Maxime

Quoted 74 lines · Jonathan Cameron

Hi Greg,

The v3 here is just to indicate a tiny change suggested by Lars-Peter from the version that has been out for review on linux-iio. (Using ALIGN instead of hand rolling in one case in patch 4). Anyhow, not worth putting out for another review as Lars-Peter has tested and acked without it anyway.

Technically Lars-Peter only acked patches 4 and 5 but they are the important ones (the others being trivial or tied up with the max1363 driver which is one of mine..)

This set introduces the an optional demultiplexer into the path of data form devices to buffers. It is a necessary step on the path to in kernel push interfaces (trigger driven ones). Also rather useful on it's own as shown by the max1363 patches and some uses Lars-Peter has made of it in another series.

Anyhow fair bit more to come so time to send these on to you!

Thanks,

Jonathan

v2 text:
Hi All,

New version of this series. Two changes as per Lars-Peter's suggestions. ALIGN macro usage in patch 4 and one of the two for each bit set suggestions. The second is subtly different as it is finding bits after a certain point rather than from the start.

As explained in patch 5 discussion, I personally feel that the demux should occur prior to the buffer and avoiding the extra copy should be done by allowing buffers to provide callbacks for reserving (plus getting access to) space and
notifying that they are done filling it. Either way, now
is not the time to do this change. Too much else going on!

v1 text:
The last patch technically is a simple bug fix, but included here as it came up during testing of this series.

The 'interesting' bits are the rewrite of iio_sw_buffer_preenable. I'd like people with drivers currently using that function to test and see what I have broken. We should also be able to drop a number of cases in specific drivers in favour of this version.

The demux unit is designed to offer a straight path with little or no overhead if the client (here still the IIO buffer) needs all the data and to only get in the way when a subset of the active scan mask is requested.

I may well have messed this up so please please test this set.

Jonathan Cameron (7):
staging:iio:find iio channel from scan index util function staging:iio:buffer add a cache of the timestamp scan index. staging:iio: add hook to allow core to perform scan related config. staging:iio: make iio_sw_buffer_preenable much more general. staging:iio: add demux optionally to path from device to buffer staging:iio:adc:max1363 use new demuxing support. staging:iio:adc:max1363 correctly set channels as big endian.

 drivers/staging/iio/adc/max1363.h         |   11 ++-
 drivers/staging/iio/adc/max1363_core.c    |   18 ++-
 drivers/staging/iio/adc/max1363_ring.c    |   51 ++-----
 drivers/staging/iio/buffer.h              |   16 ++
 drivers/staging/iio/iio.h                 |   13 ++-
 drivers/staging/iio/industrialio-buffer.c |  212 +++++++++++++++++++++++++----
 drivers/staging/iio/industrialio-core.c   |   11 ++
 7 files changed, 259 insertions(+), 73 deletions(-)
Signature · 4 lines
Maxime Ripard, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#8 lore raw
Quoted 10 lines · Maxime Ripard

Hi Jonathan,

I can't seem to find a proper way to apply this patchset. On what patchset is it based ?

I'm still here with what seems to be a rather old version of your tree (3413ec), but it is still the head of your git tree on kernel.org.

Thanks,
Maxime

It should apply to staging/staging-next

Quoted 78 lines · Jonathan Cameron
Quoted 74 lines

Hi Greg,

The v3 here is just to indicate a tiny change suggested by Lars-Peter from the version that has been out for review on linux-iio. (Using ALIGN instead of hand rolling in one case in patch 4). Anyhow, not worth putting out for another review as Lars-Peter has tested and acked without it anyway.

Technically Lars-Peter only acked patches 4 and 5 but they are the important ones (the others being trivial or tied up with the max1363 driver which is one of mine..)

This set introduces the an optional demultiplexer into the path of data form devices to buffers. It is a necessary step on the path to in kernel push interfaces (trigger driven ones). Also rather useful on it's own as shown by the max1363 patches and some uses Lars-Peter has made of it in another series.

Anyhow fair bit more to come so time to send these on to you!

Thanks,

Jonathan

v2 text:
Hi All,

New version of this series. Two changes as per Lars-Peter's suggestions. ALIGN macro usage in patch 4 and one of the two for each bit set suggestions. The second is subtly different as it is finding bits after a certain point rather than from the start.

As explained in patch 5 discussion, I personally feel that the demux should occur prior to the buffer and avoiding the extra copy should be done by allowing buffers to provide callbacks for reserving (plus getting access to) space and
notifying that they are done filling it. Either way, now
is not the time to do this change. Too much else going on!

v1 text:
The last patch technically is a simple bug fix, but included here as it came up during testing of this series.

The 'interesting' bits are the rewrite of iio_sw_buffer_preenable. I'd like people with drivers currently using that function to test and see what I have broken. We should also be able to drop a number of cases in specific drivers in favour of this version.

The demux unit is designed to offer a straight path with little or no overhead if the client (here still the IIO buffer) needs all the data and to only get in the way when a subset of the active scan mask is requested.

I may well have messed this up so please please test this set.

Jonathan Cameron (7):
staging:iio:find iio channel from scan index util function staging:iio:buffer add a cache of the timestamp scan index. staging:iio: add hook to allow core to perform scan related config. staging:iio: make iio_sw_buffer_preenable much more general. staging:iio: add demux optionally to path from device to buffer staging:iio:adc:max1363 use new demuxing support. staging:iio:adc:max1363 correctly set channels as big endian.

 drivers/staging/iio/adc/max1363.h         |   11 ++-
 drivers/staging/iio/adc/max1363_core.c    |   18 ++-
 drivers/staging/iio/adc/max1363_ring.c    |   51 ++-----
 drivers/staging/iio/buffer.h              |   16 ++
 drivers/staging/iio/iio.h                 |   13 ++-
 drivers/staging/iio/industrialio-buffer.c |  212 +++++++++++++++++++++++++----
 drivers/staging/iio/industrialio-core.c   |   11 ++
 7 files changed, 259 insertions(+), 73 deletions(-)
#9 lore raw
Quoted 6 lines · Lars-Peter Clausen
Quoted 5 lines · Maxime Ripard

Hi Jonathan,

I can't seem to find a proper way to apply this patchset. On what patchset is it based ?

Quoted 8 lines
Quoted 1 line

I'm still here with what seems to be a rather old version of your

tree

Quoted 4 lines

(3413ec), but it is still the head of your git tree on kernel.org.

Thanks,
Maxime

It should apply to staging/staging-next

Sorry. This is all queued up locally. I just forgot to push last night! LarsPeter is also correct as my master branch is just staging-next plus stuff that has gone to Greg.

Quoted 92 lines
Quoted 43 lines · Jonathan Cameron
Quoted 40 lines

Hi Greg,

The v3 here is just to indicate a tiny change suggested by Lars-Peter from the version that has been out for review on linux-iio. (Using ALIGN instead of hand rolling in one case in patch 4). Anyhow, not worth putting out for another review as Lars-Peter has tested and acked without it anyway.

Technically Lars-Peter only acked patches 4 and 5 but they are the important ones (the others being trivial or tied up with the max1363 driver which is one of mine..)

This set introduces the an optional demultiplexer into the path of data form devices to buffers. It is a necessary step on the path to in kernel push interfaces (trigger driven ones). Also rather useful on it's own as shown by the max1363 patches and some uses Lars-Peter has made of it in another series.

Anyhow fair bit more to come so time to send these on to you!

Thanks,

Jonathan

v2 text:
Hi All,

New version of this series. Two changes as per Lars-Peter's suggestions. ALIGN macro usage in patch 4 and one of the two for each bit set suggestions. The second is subtly different as it is finding bits after a certain point rather than from the start.

As explained in patch 5 discussion, I personally feel that the demux should occur prior to the buffer and avoiding the extra copy should be done by allowing buffers to provide callbacks for reserving (plus getting access to) space and
notifying that they are done filling it. Either way, now
is not the time to do this change. Too much else going on!

Quoted 5 lines
Quoted 5 lines

v1 text:
The last patch technically is a simple bug fix, but included here as it came up during testing of this series.

The 'interesting' bits are the rewrite of iio_sw_buffer_preenable.

I'd like

Quoted 1 line
Quoted 1 line

people with drivers currently using that function to test and see

what

Quoted 1 line
Quoted 1 line

I have broken. We should also be able to drop a number of cases in

specific

Quoted 3 lines
Quoted 3 lines

drivers in favour of this version.

The demux unit is designed to offer a straight path with little or

no

Quoted 1 line
Quoted 1 line

overhead if the client (here still the IIO buffer) needs all the

data and to

Quoted 1 line
Quoted 1 line

only get in the way when a subset of the active scan mask is

requested.

Quoted 8 lines
Quoted 8 lines

I may well have messed this up so please please test this set.

Jonathan Cameron (7):
staging:iio:find iio channel from scan index util function staging:iio:buffer add a cache of the timestamp scan index. staging:iio: add hook to allow core to perform scan related

config.

Quoted 11 lines
Quoted 11 lines

staging:iio: make iio_sw_buffer_preenable much more general. staging:iio: add demux optionally to path from device to buffer staging:iio:adc:max1363 use new demuxing support. staging:iio:adc:max1363 correctly set channels as big endian.

 drivers/staging/iio/adc/max1363.h         |   11 ++-
 drivers/staging/iio/adc/max1363_core.c    |   18 ++-
 drivers/staging/iio/adc/max1363_ring.c    |   51 ++-----
 drivers/staging/iio/buffer.h              |   16 ++
 drivers/staging/iio/iio.h                 |   13 ++-
 drivers/staging/iio/industrialio-buffer.c |  212

+++++++++++++++++++++++++----

Quoted 5 lines
Quoted 3 lines
 drivers/staging/iio/industrialio-core.c   |   11 ++
 7 files changed, 259 insertions(+), 73 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
Sent from my Android phone 
with K-9 Mail. Please excuse my brevity.
author maintainer
#10 lore raw
Quoted 11 lines · Jonathan Cameron
Quoted 7 lines · Lars-Peter Clausen
Quoted 6 lines · Maxime Ripard

Hi Jonathan,

I can't seem to find a proper way to apply this patchset. On what patchset is it based ?

I'm still here with what seems to be a rather old version of your

Quoted 8 lines
Quoted 7 lines

tree

Quoted 4 lines

(3413ec), but it is still the head of your git tree on kernel.org.

Thanks,
Maxime

It should apply to staging/staging-next

Sorry. This is all queued up locally. I just forgot to push last night! LarsPeter is also correct as my master branch is just staging-next plus stuff that has gone to Greg.

I have just pushed the master branch to kernel.org.

I have also pushed inkern-staging but the two extra patches in there need a fair bit more cleaning up. However, if anyone with a need for an inkernel push interface (e.g. input client for iio device) wants to test what is there, I'd certainly welcome any feedback.

Jonathan

#11 lore raw
Quoted 13 lines · Jonathan Cameron
Quoted 12 lines · Jonathan Cameron
Quoted 8 lines · Lars-Peter Clausen
Quoted 6 lines · Maxime Ripard

Hi Jonathan,

I can't seem to find a proper way to apply this patchset. On what patchset is it based ?

I'm still here with what seems to be a rather old version of your

tree

Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

(3413ec), but it is still the head of your git tree on kernel.org.

Thanks,
Maxime

It should apply to staging/staging-next

Sorry. This is all queued up locally. I just forgot to push last night! LarsPeter is also correct as my master branch is just staging-next plus stuff that has gone to Greg.

I have just pushed the master branch to kernel.org.

Great, thanks ! :)

Maxime

Signature · 4 lines
Maxime Ripard, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com