forked from analogdevicesinc/libiio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iio-backend.h
91 lines (74 loc) · 2.77 KB
/
iio-backend.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* libiio - Library for interfacing industrial I/O (IIO) devices
*
* Copyright (C) 2020 Analog Devices, Inc.
*/
#ifndef __IIO_BACKEND_H__
#define __IIO_BACKEND_H__
#include <stdbool.h>
struct iio_device;
struct iio_context;
enum iio_backend_api_ver {
IIO_BACKEND_API_V1 = 1,
};
enum iio_attr_type {
IIO_ATTR_TYPE_DEVICE = 0,
IIO_ATTR_TYPE_DEBUG,
IIO_ATTR_TYPE_BUFFER,
};
struct iio_backend_ops {
struct iio_context * (*clone)(const struct iio_context *ctx);
ssize_t (*read)(const struct iio_device *dev, void *dst, size_t len,
uint32_t *mask, size_t words);
ssize_t (*write)(const struct iio_device *dev,
const void *src, size_t len);
int (*open)(const struct iio_device *dev,
size_t samples_count, bool cyclic);
int (*close)(const struct iio_device *dev);
int (*get_fd)(const struct iio_device *dev);
int (*set_blocking_mode)(const struct iio_device *dev, bool blocking);
void (*cancel)(const struct iio_device *dev);
int (*set_kernel_buffers_count)(const struct iio_device *dev,
unsigned int nb_blocks);
ssize_t (*get_buffer)(const struct iio_device *dev,
void **addr_ptr, size_t bytes_used,
uint32_t *mask, size_t words);
ssize_t (*read_device_attr)(const struct iio_device *dev,
const char *attr, char *dst, size_t len, enum iio_attr_type);
ssize_t (*write_device_attr)(const struct iio_device *dev,
const char *attr, const char *src,
size_t len, enum iio_attr_type);
ssize_t (*read_channel_attr)(const struct iio_channel *chn,
const char *attr, char *dst, size_t len);
ssize_t (*write_channel_attr)(const struct iio_channel *chn,
const char *attr, const char *src, size_t len);
int (*get_trigger)(const struct iio_device *dev,
const struct iio_device **trigger);
int (*set_trigger)(const struct iio_device *dev,
const struct iio_device *trigger);
void (*shutdown)(struct iio_context *ctx);
char * (*get_description)(const struct iio_context *ctx);
int (*get_version)(const struct iio_context *ctx, unsigned int *major,
unsigned int *minor, char git_tag[8]);
int (*set_timeout)(struct iio_context *ctx, unsigned int timeout);
};
/**
* struct iio_backend - IIO backend object (API version 1)
* @api_version API version for interfacing with libiio core library
* @name Name of this backend
* @uri_prefix URI prefix for this backend
* @ops Reference to backend ops
* @sizeof_context_pdata Size of private data for the IIO contexts generated by this backend
*/
struct iio_backend {
unsigned int api_version;
const char *name;
const char *uri_prefix;
const struct iio_backend_ops *ops;
unsigned int sizeof_context_pdata;
};
struct iio_context * iio_context_create_from_backend(
const struct iio_backend *backend,
const char *description);
#endif /* __IIO_BACKEND_H__ */