Definitions and functions for retrieving kernel information about both requested and free lines.
More...
Definitions and functions for retrieving kernel information about both requested and free lines.
◆ anonymous enum
Possible direction settings.
Enumerator |
---|
GPIOD_LINE_DIRECTION_INPUT | Direction is input - we're reading the state of a GPIO line.
|
GPIOD_LINE_DIRECTION_OUTPUT | Direction is output - we're driving the GPIO line.
|
Definition at line 824 of file gpiod.h.
◆ anonymous enum
Possible active state settings.
Enumerator |
---|
GPIOD_LINE_ACTIVE_STATE_HIGH | The active state of a GPIO is active-high.
|
GPIOD_LINE_ACTIVE_STATE_LOW | The active state of a GPIO is active-low.
|
Definition at line 834 of file gpiod.h.
◆ anonymous enum
Possible internal bias settings.
Enumerator |
---|
GPIOD_LINE_BIAS_AS_IS | The internal bias state is unknown.
|
GPIOD_LINE_BIAS_DISABLE | The internal bias is disabled.
|
GPIOD_LINE_BIAS_PULL_UP | The internal pull-up bias is enabled.
|
GPIOD_LINE_BIAS_PULL_DOWN | The internal pull-down bias is enabled.
|
Definition at line 844 of file gpiod.h.
◆ gpiod_line_active_state()
int gpiod_line_active_state |
( |
struct gpiod_line * |
line | ) |
|
Read the GPIO line active state setting.
- Parameters
-
- Returns
- Returns GPIOD_LINE_ACTIVE_STATE_HIGH or GPIOD_LINE_ACTIVE_STATE_LOW.
◆ gpiod_line_bias()
int gpiod_line_bias |
( |
struct gpiod_line * |
line | ) |
|
Read the GPIO line bias setting.
- Parameters
-
- Returns
- Returns GPIOD_LINE_BIAS_PULL_UP, GPIOD_LINE_BIAS_PULL_DOWN, GPIOD_LINE_BIAS_DISABLE or GPIOD_LINE_BIAS_AS_IS.
◆ gpiod_line_consumer()
const char* gpiod_line_consumer |
( |
struct gpiod_line * |
line | ) |
|
Read the GPIO line consumer name.
- Parameters
-
- Returns
- Name of the GPIO consumer name as it is represented in the kernel. This routine returns a pointer to a null-terminated string or NULL if the line is not used.
◆ gpiod_line_direction()
int gpiod_line_direction |
( |
struct gpiod_line * |
line | ) |
|
Read the GPIO line direction setting.
- Parameters
-
- Returns
- Returns GPIOD_LINE_DIRECTION_INPUT or GPIOD_LINE_DIRECTION_OUTPUT.
◆ gpiod_line_is_open_drain()
bool gpiod_line_is_open_drain |
( |
struct gpiod_line * |
line | ) |
|
Check if the line is an open-drain GPIO.
- Parameters
-
- Returns
- True if the line is an open-drain GPIO, false otherwise.
◆ gpiod_line_is_open_source()
bool gpiod_line_is_open_source |
( |
struct gpiod_line * |
line | ) |
|
Check if the line is an open-source GPIO.
- Parameters
-
- Returns
- True if the line is an open-source GPIO, false otherwise.
◆ gpiod_line_is_used()
bool gpiod_line_is_used |
( |
struct gpiod_line * |
line | ) |
|
Check if the line is currently in use.
- Parameters
-
- Returns
- True if the line is in use, false otherwise.
The user space can't know exactly why a line is busy. It may have been requested by another process or hogged by the kernel. It only matters that the line is used and we can't request it.
◆ gpiod_line_name()
const char* gpiod_line_name |
( |
struct gpiod_line * |
line | ) |
|
Read the GPIO line name.
- Parameters
-
- Returns
- Name of the GPIO line as it is represented in the kernel. This routine returns a pointer to a null-terminated string or NULL if the line is unnamed.
◆ gpiod_line_needs_update()
bool gpiod_line_needs_update |
( |
struct gpiod_line * |
line | ) |
|
◆ gpiod_line_offset()
unsigned int gpiod_line_offset |
( |
struct gpiod_line * |
line | ) |
|
Read the GPIO line offset.
- Parameters
-
- Returns
- Line offset.
◆ gpiod_line_update()
int gpiod_line_update |
( |
struct gpiod_line * |
line | ) |
|
Re-read the line info.
- Parameters
-
- Returns
- 0 if the operation succeeds. In case of an error this routine returns -1 and sets the last error number.
The line info is initially retrieved from the kernel by gpiod_chip_get_line() and is later re-read after every successful request. Users can use this function to manually re-read the line info when needed.
We currently have no mechanism provided by the kernel for keeping the line info synchronized and for the sake of speed and simplicity of this low-level library we don't want to re-read the line info automatically everytime a property is retrieved. Any daemon using this library must track the state of lines on its own and call this routine if needed.
The state of requested lines is kept synchronized (or rather cannot be changed by external agents while the ownership of the line is taken) so there's no need to call this function in that case.