libiio  1.0
Library for interfacing with IIO devices
 All Files Functions Groups
local.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * libiio - Library for interfacing industrial I/O (IIO) devices
4  *
5  * Copyright (C) 2022 Analog Devices, Inc.
6  * Author: Paul Cercueil <paul.cercueil@analog.com>
7  */
8 #ifndef __IIO_LOCAL_H
9 #define __IIO_LOCAL_H
10 
11 #include <stdbool.h>
12 #include <stddef.h>
13 #include <stdint.h>
14 
15 struct iio_buffer_impl_pdata;
16 struct iio_block_impl_pdata;
17 struct iio_device;
18 struct timespec;
19 
20 struct iio_buffer_pdata {
21  const struct iio_device *dev;
22  struct iio_buffer_impl_pdata *pdata;
23  int fd, cancel_fd;
24  unsigned int idx;
25  bool dmabuf_supported;
26  bool mmap_supported;
27  size_t size;
28 };
29 
30 struct iio_block_pdata {
31  struct iio_buffer_pdata *buf;
32  struct iio_block_impl_pdata *pdata;
33  size_t size;
34  void *data;
35  bool dequeued;
36 };
37 
38 int ioctl_nointr(int fd, unsigned long request, void *data);
39 
40 int buffer_check_ready(struct iio_buffer_pdata *pdata, int fd,
41  short events, struct timespec *start);
42 
43 struct iio_block_pdata *
44 local_create_dmabuf(struct iio_buffer_pdata *pdata, size_t size, void **data);
45 void local_free_dmabuf(struct iio_block_pdata *pdata);
46 
47 int local_enqueue_dmabuf(struct iio_block_pdata *pdata,
48  size_t bytes_used, bool cyclic);
49 int local_dequeue_dmabuf(struct iio_block_pdata *pdata, bool nonblock);
50 
51 struct iio_block_pdata *
52 local_create_mmap_block(struct iio_buffer_pdata *pdata,
53  size_t size, void **data);
54 void local_free_mmap_block(struct iio_block_pdata *pdata);
55 
56 int local_enqueue_mmap_block(struct iio_block_pdata *pdata,
57  size_t bytes_used, bool cyclic);
58 int local_dequeue_mmap_block(struct iio_block_pdata *pdata, bool nonblock);
59 
60 struct iio_buffer_impl_pdata * local_alloc_mmap_buffer_impl(void);
61 
62 #endif /* __IIO_LOCAL_H */