Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcercuei/9187ad1ac71a6eed8c6e to your computer and use it in GitHub Desktop.
Save pcercuei/9187ad1ac71a6eed8c6e to your computer and use it in GitHub Desktop.
From 745887e8484999b89d3983e89e0d53444485736a Mon Sep 17 00:00:00 2001
From: Paul Cercueil <paul.cercueil@analog.com>
Date: Wed, 16 Dec 2015 14:51:05 +0100
Subject: [PATCH] Add support for channels sharing the same index
Signed-off-by: Paul Cercueil <paul.cercueil@analog.com>
---
buffer.c | 8 +++++++-
device.c | 2 ++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/buffer.c b/buffer.c
index 82ab6c5..4e61f1e 100644
--- a/buffer.c
+++ b/buffer.c
@@ -234,7 +234,9 @@ ssize_t iio_buffer_foreach_sample(struct iio_buffer *buffer,
processed += ret;
}
- ptr += length;
+ if (i == dev->nb_channels - 1 || dev->channels[
+ i + 1]->index != chn->index)
+ ptr += length;
}
}
return processed;
@@ -267,6 +269,10 @@ void * iio_buffer_first(const struct iio_buffer *buffer,
if (!TEST_BIT(buffer->mask, cur->index))
continue;
+ /* Two channels with the same index use the same samples */
+ if (i > 0 && cur->index == buffer->dev->channels[i - 1]->index)
+ continue;
+
if (ptr % len)
ptr += len - (ptr % len);
ptr += len;
diff --git a/device.c b/device.c
index 53d5832..6f83eb4 100644
--- a/device.c
+++ b/device.c
@@ -449,6 +449,8 @@ ssize_t iio_device_get_sample_size_mask(const struct iio_device *dev,
break;
if (!TEST_BIT(mask, chn->index))
continue;
+ if (i > 0 && chn->index == dev->channels[i - 1]->index)
+ continue;
if (size % length)
size += 2 * length - (size % length);
--
2.6.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment