History

iio: core: Add new DMABUF interface infrastructure

Add the necessary infrastructure to the IIO core to support a new optional DMABUF based interface. With this new interface, DMABUF objects (externally created) can be attached to a IIO buffer, and subsequently used for data transfer. A userspace application can then use this interface to share DMABUF objects between several interfaces, allowing it to transfer data in a zero-copy fashion, for instance between IIO and the USB stack. The userspace application can also memory-map the DMABUF objects, and access the sample data directly. The advantage of doing this vs. the read() interface is that it avoids an extra copy of the data between the kernel and userspace. This is particularly userful for high-speed devices which produce several megabytes or even gigabytes of data per second. As part of the interface, 3 new IOCTLs have been added: IIO_BUFFER_DMABUF_ATTACH_IOCTL(int fd): Attach the DMABUF object identified by the given file descriptor to the buffer. IIO_BUFFER_DMABUF_DETACH_IOCTL(int fd): Detach the DMABUF object identified by the given file descriptor from the buffer. Note that closing the IIO buffer's file descriptor will automatically detach all previously attached DMABUF objects. IIO_BUFFER_DMABUF_ENQUEUE_IOCTL(struct iio_dmabuf *): Request a data transfer to/from the given DMABUF object. Its file descriptor, as well as the transfer size and flags are provided in the "iio_dmabuf" structure. These three IOCTLs have to be performed on the IIO buffer's file descriptor, obtained using the IIO_BUFFER_GET_FD_IOCTL() ioctl.

Paul Cercueil committed 2 years ago

Commit 3e26d9f1 parent da5a6fa4 files · +515 −0Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/linux/iio/buffer.h+22−0
@@ -5,6 +5,28 @@ · 4 unmodified lines
5#ifndef _UAPI_IIO_BUFFER_H_5#ifndef _UAPI_IIO_BUFFER_H_
6#define _UAPI_IIO_BUFFER_H_6#define _UAPI_IIO_BUFFER_H_
7 7
8#include <linux/types.h>
9
10/* Flags for iio_dmabuf.flags */
11#define IIO_BUFFER_DMABUF_CYCLIC (1 << 0)
12#define IIO_BUFFER_DMABUF_SUPPORTED_FLAGS 0x00000001
13
14/**
15 * struct iio_dmabuf - Descriptor for a single IIO DMABUF object
16 * @fd: file descriptor of the DMABUF object
17 * @flags: one or more IIO_BUFFER_DMABUF_* flags
18 * @bytes_used: number of bytes used in this DMABUF for the data transfer.
19 * Should generally be set to the DMABUF's size.
20 */
21struct iio_dmabuf {
22 __u32 fd;
23 __u32 flags;
24 __u64 bytes_used;
25};
26
8#define IIO_BUFFER_GET_FD_IOCTL _IOWR('i', 0x91, int)27#define IIO_BUFFER_GET_FD_IOCTL _IOWR('i', 0x91, int)
28#define IIO_BUFFER_DMABUF_ATTACH_IOCTL _IOW('i', 0x92, int)
29#define IIO_BUFFER_DMABUF_DETACH_IOCTL _IOW('i', 0x93, int)
30#define IIO_BUFFER_DMABUF_ENQUEUE_IOCTL _IOW('i', 0x94, struct iio_dmabuf)
9 31
10#endif /* _UAPI_IIO_BUFFER_H_ */32#endif /* _UAPI_IIO_BUFFER_H_ */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t