Skip to content

Commit 5b4cd21

Browse files
committed
local: Add support for setting watermark
Add support for setting the watermark value, if the driver supports it. The watermark value represents the number of samples that will be read in one burst from the hardware. Since we read data at the granularity of iio_buffer blocks, it makes sense to use the highest watermark value up to the buffer's size. If the value is too high, the driver will automatically adjust it to the maximum watermark value possible. Fixes #780. Signed-off-by: Paul Cercueil <[email protected]>
1 parent 87699e7 commit 5b4cd21

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

local.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ static const char * const device_attrs_blacklist[] = {
104104
static const char * const buffer_attrs_reserved[] = {
105105
"length",
106106
"enable",
107+
"watermark",
107108
};
108109

109110
static int ioctl_nointr(int fd, unsigned long request, void *data)
@@ -923,6 +924,15 @@ static int local_open(const struct iio_device *dev,
923924
if (ret < 0)
924925
return ret;
925926

927+
/*
928+
* Set watermark to the buffer size; the driver will adjust to its
929+
* maximum if it's too high without issueing an error.
930+
*/
931+
ret = local_write_dev_attr(dev, "buffer/watermark",
932+
buf, strlen(buf) + 1, false);
933+
if (ret < 0 && ret != -ENOENT)
934+
return ret;
935+
926936
pdata->cancel_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
927937
if (pdata->cancel_fd == -1)
928938
return -errno;

0 commit comments

Comments
 (0)