GPIO line information
- group line_info
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.
Functions
-
void gpiod_line_info_free(struct gpiod_line_info *info)
Free a line info object and release all associated resources.
- Parameters:
info – GPIO line info object to free.
-
struct gpiod_line_info *gpiod_line_info_copy(struct gpiod_line_info *info)
Copy a line info object.
- Parameters:
info – Line 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.
-
unsigned int gpiod_line_info_get_offset(struct gpiod_line_info *info)
Get the offset of the line.
The offset uniquely identifies the line on the chip. The combination of the chip and offset uniquely identifies the line within the system.
- Parameters:
info – GPIO line info object.
- Returns:
Offset of the line within the parent chip.
-
const char *gpiod_line_info_get_name(struct gpiod_line_info *info)
Get the name of the line.
- Parameters:
info – GPIO 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.
-
bool gpiod_line_info_is_used(struct gpiod_line_info *info)
Check if the line is in use.
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.
- Parameters:
info – GPIO line object.
- Returns:
True if the line is in use, false otherwise.
-
const char *gpiod_line_info_get_consumer(struct gpiod_line_info *info)
Get the name of the consumer of the line.
- Parameters:
info – GPIO 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.
-
enum gpiod_line_direction gpiod_line_info_get_direction(struct gpiod_line_info *info)
Get the direction setting of the line.
- Parameters:
info – GPIO line info object.
- Returns:
Returns GPIOD_LINE_DIRECTION_INPUT or GPIOD_LINE_DIRECTION_OUTPUT.
-
enum gpiod_line_edge gpiod_line_info_get_edge_detection(struct gpiod_line_info *info)
Get the edge detection setting of the line.
- Parameters:
info – GPIO line info object.
- Returns:
Returns GPIOD_LINE_EDGE_NONE, GPIOD_LINE_EDGE_RISING, GPIOD_LINE_EDGE_FALLING or GPIOD_LINE_EDGE_BOTH.
-
enum gpiod_line_bias gpiod_line_info_get_bias(struct gpiod_line_info *info)
Get the bias setting of the line.
- Parameters:
info – GPIO line object.
- Returns:
Returns GPIOD_LINE_BIAS_PULL_UP, GPIOD_LINE_BIAS_PULL_DOWN, GPIOD_LINE_BIAS_DISABLED or GPIOD_LINE_BIAS_UNKNOWN.
-
enum gpiod_line_drive gpiod_line_info_get_drive(struct gpiod_line_info *info)
Get the drive setting of the line.
- Parameters:
info – GPIO line info object.
- Returns:
Returns GPIOD_LINE_DRIVE_PUSH_PULL, GPIOD_LINE_DRIVE_OPEN_DRAIN or GPIOD_LINE_DRIVE_OPEN_SOURCE.
-
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:
info – GPIO line object.
- Returns:
True if the line is “active-low”, false otherwise.
-
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:
info – GPIO line info object.
- Returns:
True if the line is debounced, false otherwise.
-
unsigned long gpiod_line_info_get_debounce_period_us(struct gpiod_line_info *info)
Get the debounce period of the line, in microseconds.
- Parameters:
info – GPIO line info object.
- Returns:
Debounce period in microseconds. 0 if the line is not debounced.
-
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:
info – GPIO line info object.
- Returns:
Returns GPIOD_LINE_CLOCK_MONOTONIC, GPIOD_LINE_CLOCK_HTE or GPIOD_LINE_CLOCK_REALTIME.
-
void gpiod_line_info_free(struct gpiod_line_info *info)