libgpiod  2.0.1
Functions
Line info

Functions for retrieving kernel information about both requested and free lines. More...

Functions

void gpiod_line_info_free (struct gpiod_line_info *info)
 Free a line info object and release all associated resources. More...
 
struct gpiod_line_infogpiod_line_info_copy (struct gpiod_line_info *info)
 Copy a line info object. More...
 
unsigned int gpiod_line_info_get_offset (struct gpiod_line_info *info)
 Get the offset of the line. More...
 
const char * gpiod_line_info_get_name (struct gpiod_line_info *info)
 Get the name of the line. More...
 
bool gpiod_line_info_is_used (struct gpiod_line_info *info)
 Check if the line is in use. More...
 
const char * gpiod_line_info_get_consumer (struct gpiod_line_info *info)
 Get the name of the consumer of the line. More...
 
enum gpiod_line_direction gpiod_line_info_get_direction (struct gpiod_line_info *info)
 Get the direction setting of the line. More...
 
enum gpiod_line_edge gpiod_line_info_get_edge_detection (struct gpiod_line_info *info)
 Get the edge detection setting of the line. More...
 
enum gpiod_line_bias gpiod_line_info_get_bias (struct gpiod_line_info *info)
 Get the bias setting of the line. More...
 
enum gpiod_line_drive gpiod_line_info_get_drive (struct gpiod_line_info *info)
 Get the drive setting of the line. More...
 
bool gpiod_line_info_is_active_low (struct gpiod_line_info *info)
 Check if the logical value of the line is inverted compared to the physical. More...
 
bool gpiod_line_info_is_debounced (struct gpiod_line_info *info)
 Check if the line is debounced (either by hardware or by the kernel software debouncer). More...
 
unsigned long gpiod_line_info_get_debounce_period_us (struct gpiod_line_info *info)
 Get the debounce period of the line, in microseconds. More...
 
enum gpiod_line_clock gpiod_line_info_get_event_clock (struct gpiod_line_info *info)
 Get the event clock setting used for edge event timestamps for the line. More...
 

Detailed Description

Functions for retrieving kernel information about both requested and free lines.

Line info object contains an immutable snapshot of a line's status.

The line info contains all the publicly available information about a line, which does not include the line value. The line must be requested to access the line value.

Some accessor methods return pointers. Those pointers refer to internal fields. The lifetimes of those fields are tied to the lifetime of the containing line info object. Such pointers remain valid until gpiod_line_info_free is called on the containing line info object. They must not be freed by the caller.

Function Documentation

◆ gpiod_line_info_copy()

struct gpiod_line_info* gpiod_line_info_copy ( struct gpiod_line_info info)

Copy a line info object.

Parameters
infoLine info to copy.
Returns
Copy of the line info or NULL on error. The returned object must be freed by the caller using :gpiod_line_info_free.

◆ gpiod_line_info_free()

void gpiod_line_info_free ( struct gpiod_line_info info)

Free a line info object and release all associated resources.

Parameters
infoGPIO line info object to free.

◆ gpiod_line_info_get_bias()

enum gpiod_line_bias gpiod_line_info_get_bias ( struct gpiod_line_info info)

Get the bias setting of the line.

Parameters
infoGPIO line object.
Returns
Returns GPIOD_LINE_BIAS_PULL_UP, GPIOD_LINE_BIAS_PULL_DOWN, GPIOD_LINE_BIAS_DISABLED or GPIOD_LINE_BIAS_UNKNOWN.

◆ gpiod_line_info_get_consumer()

const char* gpiod_line_info_get_consumer ( struct gpiod_line_info info)

Get the name of the consumer of the line.

Parameters
infoGPIO line info object.
Returns
Name of the GPIO consumer as it is represented in the kernel. This function returns a valid pointer to a null-terminated string or NULL if the consumer name is not set. The string lifetime is tied to the line info object so the pointer must not be freed.

◆ gpiod_line_info_get_debounce_period_us()

unsigned long gpiod_line_info_get_debounce_period_us ( struct gpiod_line_info info)

Get the debounce period of the line, in microseconds.

Parameters
infoGPIO line info object.
Returns
Debounce period in microseconds. 0 if the line is not debounced.

◆ gpiod_line_info_get_direction()

enum gpiod_line_direction gpiod_line_info_get_direction ( struct gpiod_line_info info)

Get the direction setting of the line.

Parameters
infoGPIO line info object.
Returns
Returns GPIOD_LINE_DIRECTION_INPUT or GPIOD_LINE_DIRECTION_OUTPUT.

◆ gpiod_line_info_get_drive()

enum gpiod_line_drive gpiod_line_info_get_drive ( struct gpiod_line_info info)

Get the drive setting of the line.

Parameters
infoGPIO line info object.
Returns
Returns GPIOD_LINE_DRIVE_PUSH_PULL, GPIOD_LINE_DRIVE_OPEN_DRAIN or GPIOD_LINE_DRIVE_OPEN_SOURCE.

◆ gpiod_line_info_get_edge_detection()

enum gpiod_line_edge gpiod_line_info_get_edge_detection ( struct gpiod_line_info info)

Get the edge detection setting of the line.

Parameters
infoGPIO line info object.
Returns
Returns GPIOD_LINE_EDGE_NONE, GPIOD_LINE_EDGE_RISING, GPIOD_LINE_EDGE_FALLING or GPIOD_LINE_EDGE_BOTH.

◆ gpiod_line_info_get_event_clock()

enum gpiod_line_clock gpiod_line_info_get_event_clock ( struct gpiod_line_info info)

Get the event clock setting used for edge event timestamps for the line.

Parameters
infoGPIO line info object.
Returns
Returns GPIOD_LINE_CLOCK_MONOTONIC, GPIOD_LINE_CLOCK_HTE or GPIOD_LINE_CLOCK_REALTIME.

◆ gpiod_line_info_get_name()

const char* gpiod_line_info_get_name ( struct gpiod_line_info info)

Get the name of the line.

Parameters
infoGPIO line info object.
Returns
Name of the GPIO line as it is represented in the kernel. This function returns a valid pointer to a null-terminated string or NULL if the line is unnamed. The string lifetime is tied to the line info object so the pointer must not be freed.

◆ gpiod_line_info_get_offset()

unsigned int gpiod_line_info_get_offset ( struct gpiod_line_info info)

Get the offset of the line.

Parameters
infoGPIO line info object.
Returns
Offset of the line within the parent chip.

The offset uniquely identifies the line on the chip. The combination of the chip and offset uniquely identifies the line within the system.

◆ gpiod_line_info_is_active_low()

bool gpiod_line_info_is_active_low ( struct gpiod_line_info info)

Check if the logical value of the line is inverted compared to the physical.

Parameters
infoGPIO line object.
Returns
True if the line is "active-low", false otherwise.

◆ gpiod_line_info_is_debounced()

bool gpiod_line_info_is_debounced ( struct gpiod_line_info info)

Check if the line is debounced (either by hardware or by the kernel software debouncer).

Parameters
infoGPIO line info object.
Returns
True if the line is debounced, false otherwise.

◆ gpiod_line_info_is_used()

bool gpiod_line_info_is_used ( struct gpiod_line_info info)

Check if the line is in use.

Parameters
infoGPIO line object.
Returns
True if the line is in use, false otherwise.

The exact reason a line is busy cannot be determined from user space. It may have been requested by another process or hogged by the kernel. It only matters that the line is used and can't be requested until released by the existing consumer.