libgpiod  1.6.2
Enumerations | Functions

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

Collaboration diagram for Line info:

Enumerations

enum  { GPIOD_LINE_DIRECTION_INPUT = 1, GPIOD_LINE_DIRECTION_OUTPUT }
 Possible direction settings. More...
 
enum  { GPIOD_LINE_ACTIVE_STATE_HIGH = 1, GPIOD_LINE_ACTIVE_STATE_LOW }
 Possible active state settings. More...
 
enum  { GPIOD_LINE_BIAS_AS_IS = 1, GPIOD_LINE_BIAS_DISABLE, GPIOD_LINE_BIAS_PULL_UP, GPIOD_LINE_BIAS_PULL_DOWN }
 Possible internal bias settings. More...
 

Functions

unsigned int gpiod_line_offset (struct gpiod_line *line) GPIOD_API
 Read the GPIO line offset. More...
 
const char * gpiod_line_name (struct gpiod_line *line) GPIOD_API
 Read the GPIO line name. More...
 
const char * gpiod_line_consumer (struct gpiod_line *line) GPIOD_API
 Read the GPIO line consumer name. More...
 
int gpiod_line_direction (struct gpiod_line *line) GPIOD_API
 Read the GPIO line direction setting. More...
 
int gpiod_line_active_state (struct gpiod_line *line) GPIOD_API
 Read the GPIO line active state setting. More...
 
int gpiod_line_bias (struct gpiod_line *line) GPIOD_API
 Read the GPIO line bias setting. More...
 
bool gpiod_line_is_used (struct gpiod_line *line) GPIOD_API
 Check if the line is currently in use. More...
 
bool gpiod_line_is_open_drain (struct gpiod_line *line) GPIOD_API
 Check if the line is an open-drain GPIO. More...
 
bool gpiod_line_is_open_source (struct gpiod_line *line) GPIOD_API
 Check if the line is an open-source GPIO. More...
 
int gpiod_line_update (struct gpiod_line *line) GPIOD_API
 Re-read the line info. More...
 
bool gpiod_line_needs_update (struct gpiod_line *line) GPIOD_API GPIOD_DEPRECATED
 Check if the line info needs to be updated. More...
 

Detailed Description

Definitions and functions for retrieving kernel information about both requested and free lines.

Enumeration Type Documentation

◆ anonymous enum

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

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

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.

Function Documentation

◆ gpiod_line_active_state()

int gpiod_line_active_state ( struct gpiod_line *  line)

Read the GPIO line active state setting.

Parameters
lineGPIO line object.
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
lineGPIO line object.
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
lineGPIO line object.
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
lineGPIO line object.
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
lineGPIO line object.
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
lineGPIO line object.
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
lineGPIO line object.
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
lineGPIO line object.
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)

Check if the line info needs to be updated.

Parameters
lineGPIO line object.
Returns
Always returns false.
Deprecated:
This mechanism no longer exists in the library and this function does nothing.

References GPIOD_LINE_REQUEST_DIRECTION_AS_IS, GPIOD_LINE_REQUEST_DIRECTION_INPUT, GPIOD_LINE_REQUEST_DIRECTION_OUTPUT, GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES, GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE, and GPIOD_LINE_REQUEST_EVENT_RISING_EDGE.

◆ gpiod_line_offset()

unsigned int gpiod_line_offset ( struct gpiod_line *  line)

Read the GPIO line offset.

Parameters
lineGPIO line object.
Returns
Line offset.

◆ gpiod_line_update()

int gpiod_line_update ( struct gpiod_line *  line)

Re-read the line info.

Parameters
lineGPIO line object.
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.