Documentation/userspace-api/gpio/gpio-lineevent-data-read.rst

Source file repositories/reference/linux-study-clean/Documentation/userspace-api/gpio/gpio-lineevent-data-read.rst

File Facts

System
Linux kernel
Corpus path
Documentation/userspace-api/gpio/gpio-lineevent-data-read.rst
Extension
.rst
Size
3084 bytes
Lines
90
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

.. SPDX-License-Identifier: GPL-2.0

.. _GPIO_LINEEVENT_DATA_READ:

************************
GPIO_LINEEVENT_DATA_READ
************************

.. warning::
    This ioctl is part of chardev_v1.rst and is obsoleted by
    gpio-v2-line-event-read.rst.

Name
====

GPIO_LINEEVENT_DATA_READ - Read edge detection events from a line event.

Synopsis
========

``int read(int event_fd, void *buf, size_t count)``

Arguments
=========

``event_fd``
    The file descriptor of the GPIO character device, as returned in the
    :c:type:`request.fd<gpioevent_request>` by gpio-get-lineevent-ioctl.rst.

``buf``
    The buffer to contain the :c:type:`events<gpioevent_data>`.

``count``
    The number of bytes available in ``buf``, which must be at
    least the size of a :c:type:`gpioevent_data`.

Description
===========

Read edge detection events for a line from a line event.

Edge detection must be enabled for the input line using either
``GPIOEVENT_REQUEST_RISING_EDGE`` or ``GPIOEVENT_REQUEST_FALLING_EDGE``, or
both. Edge events are then generated whenever edge interrupts are detected on
the input line.

Edges are defined in terms of changes to the logical line value, so an inactive
to active transition is a rising edge.  If ``GPIOHANDLE_REQUEST_ACTIVE_LOW`` is
set then logical polarity is the opposite of physical polarity, and
``GPIOEVENT_REQUEST_RISING_EDGE`` then corresponds to a falling physical edge.

The kernel captures and timestamps edge events as close as possible to their
occurrence and stores them in a buffer from where they can be read by
userspace at its convenience using `read()`.

The source of the clock for :c:type:`event.timestamp<gpioevent_data>` is
``CLOCK_MONOTONIC``, except for kernels earlier than Linux 5.7 when it was
``CLOCK_REALTIME``.  There is no indication in the :c:type:`gpioevent_data`
as to which clock source is used, it must be determined from either the kernel
version or sanity checks on the timestamp itself.

Events read from the buffer are always in the same order that they were
detected by the kernel.

The size of the kernel event buffer is fixed at 16 events.

The buffer may overflow if bursts of events occur quicker than they are read
by userspace. If an overflow occurs then the most recent event is discarded.
Overflow cannot be detected from userspace.

Annotation

Implementation Notes