xref: /linux/Documentation/userspace-api/gpio/gpio-handle-get-line-values-ioctl.rst (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
116b2bb7fSKent Gibson.. SPDX-License-Identifier: GPL-2.0
216b2bb7fSKent Gibson
316b2bb7fSKent Gibson.. _GPIOHANDLE_GET_LINE_VALUES_IOCTL:
416b2bb7fSKent Gibson
516b2bb7fSKent Gibson********************************
616b2bb7fSKent GibsonGPIOHANDLE_GET_LINE_VALUES_IOCTL
716b2bb7fSKent Gibson********************************
816b2bb7fSKent Gibson.. warning::
916b2bb7fSKent Gibson    This ioctl is part of chardev_v1.rst and is obsoleted by
1016b2bb7fSKent Gibson    gpio-v2-line-get-values-ioctl.rst.
1116b2bb7fSKent Gibson
1216b2bb7fSKent GibsonName
1316b2bb7fSKent Gibson====
1416b2bb7fSKent Gibson
1516b2bb7fSKent GibsonGPIOHANDLE_GET_LINE_VALUES_IOCTL - Get the values of all requested lines.
1616b2bb7fSKent Gibson
1716b2bb7fSKent GibsonSynopsis
1816b2bb7fSKent Gibson========
1916b2bb7fSKent Gibson
2016b2bb7fSKent Gibson.. c:macro:: GPIOHANDLE_GET_LINE_VALUES_IOCTL
2116b2bb7fSKent Gibson
2216b2bb7fSKent Gibson``int ioctl(int handle_fd, GPIOHANDLE_GET_LINE_VALUES_IOCTL, struct gpiohandle_data *values)``
2316b2bb7fSKent Gibson
2416b2bb7fSKent GibsonArguments
2516b2bb7fSKent Gibson=========
2616b2bb7fSKent Gibson
2716b2bb7fSKent Gibson``handle_fd``
2816b2bb7fSKent Gibson    The file descriptor of the GPIO character device, as returned in the
2916b2bb7fSKent Gibson    :c:type:`request.fd<gpiohandle_request>` by gpio-get-linehandle-ioctl.rst.
3016b2bb7fSKent Gibson
3116b2bb7fSKent Gibson``values``
3216b2bb7fSKent Gibson    The :c:type:`line_values<gpiohandle_data>` to be populated.
3316b2bb7fSKent Gibson
3416b2bb7fSKent GibsonDescription
3516b2bb7fSKent Gibson===========
3616b2bb7fSKent Gibson
3716b2bb7fSKent GibsonGet the values of all requested lines.
3816b2bb7fSKent Gibson
39*5ca84d41SKent GibsonThe values returned are logical, indicating if the line is active or inactive.
40*5ca84d41SKent GibsonThe ``GPIOHANDLE_REQUEST_ACTIVE_LOW`` flag controls the mapping between physical
41*5ca84d41SKent Gibsonvalues (high/low) and logical values (active/inactive).
42*5ca84d41SKent GibsonIf ``GPIOHANDLE_REQUEST_ACTIVE_LOW`` is not set then high is active and
43*5ca84d41SKent Gibsonlow is inactive. If ``GPIOHANDLE_REQUEST_ACTIVE_LOW`` is set then low is active
44*5ca84d41SKent Gibsonand high is inactive.
45*5ca84d41SKent Gibson
4616b2bb7fSKent GibsonThe values of both input and output lines may be read.
4716b2bb7fSKent Gibson
4816b2bb7fSKent GibsonFor output lines, the value returned is driver and configuration dependent and
4916b2bb7fSKent Gibsonmay be either the output buffer (the last requested value set) or the input
5016b2bb7fSKent Gibsonbuffer (the actual level of the line), and depending on the hardware and
5116b2bb7fSKent Gibsonconfiguration these may differ.
5216b2bb7fSKent Gibson
5316b2bb7fSKent GibsonThis ioctl can also be used to read the line value for line events,
5416b2bb7fSKent Gibsonsubstituting the ``event_fd`` for the ``handle_fd``.  As there is only
5516b2bb7fSKent Gibsonone line requested in that case, only the one value is returned in ``values``.
5616b2bb7fSKent Gibson
5716b2bb7fSKent GibsonReturn Value
5816b2bb7fSKent Gibson============
5916b2bb7fSKent Gibson
6016b2bb7fSKent GibsonOn success 0 and ``values`` populated with the values read.
6116b2bb7fSKent Gibson
6216b2bb7fSKent GibsonOn error -1 and the ``errno`` variable is set appropriately.
6316b2bb7fSKent GibsonCommon error codes are described in error-codes.rst.
64