Skip to content

Commit

Permalink
Add "cyclic" parameter to .buffer_enable() backend callback
Browse files Browse the repository at this point in the history
IIOD v0.x supports enqueueing cyclic blocks, but it needs to know about
it when the iio_buffer is opened through the "OPEN" command. As
iiod-client calls this command when the buffer is to be enabled, pass an
extra "cyclic" parameter to .buffer_enable(), always set to "false" for
now.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
  • Loading branch information
pcercuei committed Dec 14, 2023
1 parent 2819ff3 commit 9466de6
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ static int iio_buffer_set_enabled(const struct iio_buffer *buf, bool enabled)
{
const struct iio_backend_ops *ops = buf->dev->ctx->ops;
size_t sample_size, nb_samples = 0;
bool cyclic = false;

if (buf->block_size) {
sample_size = iio_device_get_sample_size(buf->dev, buf->mask);
nb_samples = buf->block_size / sample_size;
}

if (ops->enable_buffer)
return ops->enable_buffer(buf->pdata, nb_samples, enabled);
return ops->enable_buffer(buf->pdata, nb_samples, enabled, cyclic);

return -ENOSYS;
}
Expand Down
4 changes: 2 additions & 2 deletions iiod-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ void iiod_client_free_buffer(struct iiod_client_buffer_pdata *pdata)
}

int iiod_client_enable_buffer(struct iiod_client_buffer_pdata *pdata,
size_t nb_samples, bool enable)
size_t nb_samples, bool enable, bool cyclic)
{
struct iiod_client *client = pdata->client;
struct iiod_client_io *client_io;
Expand All @@ -1511,7 +1511,7 @@ int iiod_client_enable_buffer(struct iiod_client_buffer_pdata *pdata,
if (enable) {
client_io = iiod_client_open_with_mask(client, pdata->dev,
pdata->mask,
nb_samples, false);
nb_samples, cyclic);
err = iio_err(client_io);
pdata->io = err ? NULL : client_io;
} else {
Expand Down
2 changes: 1 addition & 1 deletion include/iio/iio-backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ struct iio_backend_ops {
struct iio_channels_mask *mask);
void (*free_buffer)(struct iio_buffer_pdata *pdata);
int (*enable_buffer)(struct iio_buffer_pdata *pdata,
size_t nb_samples, bool enable);
size_t nb_samples, bool enable, bool cyclic);
void (*cancel_buffer)(struct iio_buffer_pdata *pdata);

ssize_t (*readbuf)(struct iio_buffer_pdata *pdata,
Expand Down
2 changes: 1 addition & 1 deletion include/iio/iiod-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ iiod_client_create_buffer(struct iiod_client *client,
struct iio_channels_mask *mask);
__api void iiod_client_free_buffer(struct iiod_client_buffer_pdata *pdata);
__api int iiod_client_enable_buffer(struct iiod_client_buffer_pdata *pdata,
size_t nb_samples, bool enable);
size_t nb_samples, bool enable, bool cyclic);

__api struct iio_block_pdata *
iiod_client_create_block(struct iiod_client_buffer_pdata *pdata,
Expand Down
2 changes: 1 addition & 1 deletion local.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ static int local_do_enable_buffer(struct iio_buffer_pdata *pdata, bool enable)
}

static int local_enable_buffer(struct iio_buffer_pdata *pdata,
size_t nb_samples, bool enable)
size_t nb_samples, bool enable, bool cyclic)
{
int ret;

Expand Down
4 changes: 2 additions & 2 deletions network.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,9 +485,9 @@ void network_free_buffer(struct iio_buffer_pdata *pdata)
}

int network_enable_buffer(struct iio_buffer_pdata *pdata,
size_t block_size, bool enable)
size_t block_size, bool enable, bool cyclic)
{
return iiod_client_enable_buffer(pdata->pdata, block_size, enable);
return iiod_client_enable_buffer(pdata->pdata, block_size, enable, cyclic);
}

struct iio_block_pdata * network_create_block(struct iio_buffer_pdata *pdata,
Expand Down
4 changes: 2 additions & 2 deletions serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ static void serial_free_buffer(struct iio_buffer_pdata *buf)
}

static int serial_enable_buffer(struct iio_buffer_pdata *buf,
size_t nb_samples, bool enable)
size_t nb_samples, bool enable, bool cyclic)
{
return iiod_client_enable_buffer(buf->pdata, nb_samples, enable);
return iiod_client_enable_buffer(buf->pdata, nb_samples, enable, cyclic);
}

static ssize_t
Expand Down
4 changes: 2 additions & 2 deletions usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,9 @@ static void usb_free_buffer(struct iio_buffer_pdata *buf)
}

static int usb_enable_buffer(struct iio_buffer_pdata *pdata,
size_t nb_samples, bool enable)
size_t nb_samples, bool enable, bool cyclic)
{
return iiod_client_enable_buffer(pdata->pdata, nb_samples, enable);
return iiod_client_enable_buffer(pdata->pdata, nb_samples, enable, cyclic);
}

static struct iio_block_pdata *
Expand Down

0 comments on commit 9466de6

Please sign in to comment.