libgpiod  1.6.2
Data Structures | Enumerations | Functions

Interface for requesting GPIO lines from userspace for both values and events. More...

Collaboration diagram for Line requests:

Data Structures

struct  gpiod_line_request_config
 Structure holding configuration of a line request. More...
 

Enumerations

enum  {
  GPIOD_LINE_REQUEST_DIRECTION_AS_IS = 1, GPIOD_LINE_REQUEST_DIRECTION_INPUT, GPIOD_LINE_REQUEST_DIRECTION_OUTPUT, GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE,
  GPIOD_LINE_REQUEST_EVENT_RISING_EDGE, GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES
}
 Available types of requests. More...
 
enum  {
  GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN = GPIOD_BIT(0), GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE = GPIOD_BIT(1), GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW = GPIOD_BIT(2), GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE = GPIOD_BIT(3),
  GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN = GPIOD_BIT(4), GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP = GPIOD_BIT(5)
}
 Miscellaneous GPIO request flags. More...
 

Functions

int gpiod_line_request (struct gpiod_line *line, const struct gpiod_line_request_config *config, int default_val) GPIOD_API
 Reserve a single line. More...
 
int gpiod_line_request_input (struct gpiod_line *line, const char *consumer) GPIOD_API
 Reserve a single line, set the direction to input. More...
 
int gpiod_line_request_output (struct gpiod_line *line, const char *consumer, int default_val) GPIOD_API
 Reserve a single line, set the direction to output. More...
 
int gpiod_line_request_rising_edge_events (struct gpiod_line *line, const char *consumer) GPIOD_API
 Request rising edge event notifications on a single line. More...
 
int gpiod_line_request_falling_edge_events (struct gpiod_line *line, const char *consumer) GPIOD_API
 Request falling edge event notifications on a single line. More...
 
int gpiod_line_request_both_edges_events (struct gpiod_line *line, const char *consumer) GPIOD_API
 Request all event type notifications on a single line. More...
 
int gpiod_line_request_input_flags (struct gpiod_line *line, const char *consumer, int flags) GPIOD_API
 Reserve a single line, set the direction to input. More...
 
int gpiod_line_request_output_flags (struct gpiod_line *line, const char *consumer, int flags, int default_val) GPIOD_API
 Reserve a single line, set the direction to output. More...
 
int gpiod_line_request_rising_edge_events_flags (struct gpiod_line *line, const char *consumer, int flags) GPIOD_API
 Request rising edge event notifications on a single line. More...
 
int gpiod_line_request_falling_edge_events_flags (struct gpiod_line *line, const char *consumer, int flags) GPIOD_API
 Request falling edge event notifications on a single line. More...
 
int gpiod_line_request_both_edges_events_flags (struct gpiod_line *line, const char *consumer, int flags) GPIOD_API
 Request all event type notifications on a single line. More...
 
int gpiod_line_request_bulk (struct gpiod_line_bulk *bulk, const struct gpiod_line_request_config *config, const int *default_vals) GPIOD_API
 Reserve a set of GPIO lines. More...
 
int gpiod_line_request_bulk_input (struct gpiod_line_bulk *bulk, const char *consumer) GPIOD_API
 Reserve a set of GPIO lines, set the direction to input. More...
 
int gpiod_line_request_bulk_output (struct gpiod_line_bulk *bulk, const char *consumer, const int *default_vals) GPIOD_API
 Reserve a set of GPIO lines, set the direction to output. More...
 
int gpiod_line_request_bulk_rising_edge_events (struct gpiod_line_bulk *bulk, const char *consumer) GPIOD_API
 Request rising edge event notifications on a set of lines. More...
 
int gpiod_line_request_bulk_falling_edge_events (struct gpiod_line_bulk *bulk, const char *consumer) GPIOD_API
 Request falling edge event notifications on a set of lines. More...
 
int gpiod_line_request_bulk_both_edges_events (struct gpiod_line_bulk *bulk, const char *consumer) GPIOD_API
 Request all event type notifications on a set of lines. More...
 
int gpiod_line_request_bulk_input_flags (struct gpiod_line_bulk *bulk, const char *consumer, int flags) GPIOD_API
 Reserve a set of GPIO lines, set the direction to input. More...
 
int gpiod_line_request_bulk_output_flags (struct gpiod_line_bulk *bulk, const char *consumer, int flags, const int *default_vals) GPIOD_API
 Reserve a set of GPIO lines, set the direction to output. More...
 
int gpiod_line_request_bulk_rising_edge_events_flags (struct gpiod_line_bulk *bulk, const char *consumer, int flags) GPIOD_API
 Request rising edge event notifications on a set of lines. More...
 
int gpiod_line_request_bulk_falling_edge_events_flags (struct gpiod_line_bulk *bulk, const char *consumer, int flags) GPIOD_API
 Request falling edge event notifications on a set of lines. More...
 
int gpiod_line_request_bulk_both_edges_events_flags (struct gpiod_line_bulk *bulk, const char *consumer, int flags) GPIOD_API
 Request all event type notifications on a set of lines. More...
 
void gpiod_line_release (struct gpiod_line *line) GPIOD_API
 Release a previously reserved line. More...
 
void gpiod_line_release_bulk (struct gpiod_line_bulk *bulk) GPIOD_API
 Release a set of previously reserved lines. More...
 
bool gpiod_line_is_requested (struct gpiod_line *line) GPIOD_API
 Check if the calling user has ownership of this line. More...
 
bool gpiod_line_is_free (struct gpiod_line *line) GPIOD_API
 Check if the calling user has neither requested ownership of this line nor configured any event notifications. More...
 

Detailed Description

Interface for requesting GPIO lines from userspace for both values and events.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Available types of requests.

Enumerator
GPIOD_LINE_REQUEST_DIRECTION_AS_IS 

Request the line(s), but don't change current direction.

GPIOD_LINE_REQUEST_DIRECTION_INPUT 

Request the line(s) for reading the GPIO line state.

GPIOD_LINE_REQUEST_DIRECTION_OUTPUT 

Request the line(s) for setting the GPIO line state.

GPIOD_LINE_REQUEST_EVENT_FALLING_EDGE 

Only watch falling edge events.

GPIOD_LINE_REQUEST_EVENT_RISING_EDGE 

Only watch rising edge events.

GPIOD_LINE_REQUEST_EVENT_BOTH_EDGES 

Monitor both types of events.

Definition at line 972 of file gpiod.h.

◆ anonymous enum

anonymous enum

Miscellaneous GPIO request flags.

Enumerator
GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN 

The line is an open-drain port.

GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE 

The line is an open-source port.

GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW 

The active state of the line is low (high is the default).

GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE 

The line has neither either pull-up nor pull-down resistor.

GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN 

The line has pull-down resistor enabled.

GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP 

The line has pull-up resistor enabled.

Definition at line 990 of file gpiod.h.

Function Documentation

◆ gpiod_line_is_free()

bool gpiod_line_is_free ( struct gpiod_line *  line)

Check if the calling user has neither requested ownership of this line nor configured any event notifications.

Parameters
lineGPIO line object.
Returns
True if given line is free, false otherwise.

◆ gpiod_line_is_requested()

bool gpiod_line_is_requested ( struct gpiod_line *  line)

Check if the calling user has ownership of this line.

Parameters
lineGPIO line object.
Returns
True if given line was requested, false otherwise.

◆ gpiod_line_release()

void gpiod_line_release ( struct gpiod_line *  line)

Release a previously reserved line.

Parameters
lineGPIO line object.

◆ gpiod_line_release_bulk()

void gpiod_line_release_bulk ( struct gpiod_line_bulk bulk)

Release a set of previously reserved lines.

Parameters
bulkSet of GPIO lines to release.

If the lines were not previously requested together, the behavior is undefined.

◆ gpiod_line_request()

int gpiod_line_request ( struct gpiod_line *  line,
const struct gpiod_line_request_config config,
int  default_val 
)

Reserve a single line.

Parameters
lineGPIO line object.
configRequest options.
default_valInitial line value - only relevant if we're setting the direction to output.
Returns
0 if the line was properly reserved. In case of an error this routine returns -1 and sets the last error number.

If this routine succeeds, the caller takes ownership of the GPIO line until it's released.

◆ gpiod_line_request_both_edges_events()

int gpiod_line_request_both_edges_events ( struct gpiod_line *  line,
const char *  consumer 
)

Request all event type notifications on a single line.

Parameters
lineGPIO line object.
consumerName of the consumer.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_request_both_edges_events_flags()

int gpiod_line_request_both_edges_events_flags ( struct gpiod_line *  line,
const char *  consumer,
int  flags 
)

Request all event type notifications on a single line.

Parameters
lineGPIO line object.
consumerName of the consumer.
flagsAdditional request flags.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_request_bulk()

int gpiod_line_request_bulk ( struct gpiod_line_bulk bulk,
const struct gpiod_line_request_config config,
const int *  default_vals 
)

Reserve a set of GPIO lines.

Parameters
bulkSet of GPIO lines to reserve.
configRequest options.
default_valsInitial line values - only relevant if we're setting the direction to output.
Returns
0 if the all lines were properly requested. In case of an error this routine returns -1 and sets the last error number.

If this routine succeeds, the caller takes ownership of the GPIO lines until they're released. All the requested lines must be prodivided by the same gpiochip.

◆ gpiod_line_request_bulk_both_edges_events()

int gpiod_line_request_bulk_both_edges_events ( struct gpiod_line_bulk bulk,
const char *  consumer 
)

Request all event type notifications on a set of lines.

Parameters
bulkSet of GPIO lines to request.
consumerName of the consumer.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_request_bulk_both_edges_events_flags()

int gpiod_line_request_bulk_both_edges_events_flags ( struct gpiod_line_bulk bulk,
const char *  consumer,
int  flags 
)

Request all event type notifications on a set of lines.

Parameters
bulkSet of GPIO lines to request.
consumerName of the consumer.
flagsAdditional request flags.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_request_bulk_falling_edge_events()

int gpiod_line_request_bulk_falling_edge_events ( struct gpiod_line_bulk bulk,
const char *  consumer 
)

Request falling edge event notifications on a set of lines.

Parameters
bulkSet of GPIO lines to request.
consumerName of the consumer.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_request_bulk_falling_edge_events_flags()

int gpiod_line_request_bulk_falling_edge_events_flags ( struct gpiod_line_bulk bulk,
const char *  consumer,
int  flags 
)

Request falling edge event notifications on a set of lines.

Parameters
bulkSet of GPIO lines to request.
consumerName of the consumer.
flagsAdditional request flags.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_request_bulk_input()

int gpiod_line_request_bulk_input ( struct gpiod_line_bulk bulk,
const char *  consumer 
)

Reserve a set of GPIO lines, set the direction to input.

Parameters
bulkSet of GPIO lines to reserve.
consumerName of the consumer.
Returns
0 if the lines were properly reserved, -1 on failure.

◆ gpiod_line_request_bulk_input_flags()

int gpiod_line_request_bulk_input_flags ( struct gpiod_line_bulk bulk,
const char *  consumer,
int  flags 
)

Reserve a set of GPIO lines, set the direction to input.

Parameters
bulkSet of GPIO lines to reserve.
consumerName of the consumer.
flagsAdditional request flags.
Returns
0 if the lines were properly reserved, -1 on failure.

◆ gpiod_line_request_bulk_output()

int gpiod_line_request_bulk_output ( struct gpiod_line_bulk bulk,
const char *  consumer,
const int *  default_vals 
)

Reserve a set of GPIO lines, set the direction to output.

Parameters
bulkSet of GPIO lines to reserve.
consumerName of the consumer.
default_valsInitial line values.
Returns
0 if the lines were properly reserved, -1 on failure.

◆ gpiod_line_request_bulk_output_flags()

int gpiod_line_request_bulk_output_flags ( struct gpiod_line_bulk bulk,
const char *  consumer,
int  flags,
const int *  default_vals 
)

Reserve a set of GPIO lines, set the direction to output.

Parameters
bulkSet of GPIO lines to reserve.
consumerName of the consumer.
flagsAdditional request flags.
default_valsInitial line values.
Returns
0 if the lines were properly reserved, -1 on failure.

◆ gpiod_line_request_bulk_rising_edge_events()

int gpiod_line_request_bulk_rising_edge_events ( struct gpiod_line_bulk bulk,
const char *  consumer 
)

Request rising edge event notifications on a set of lines.

Parameters
bulkSet of GPIO lines to request.
consumerName of the consumer.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_request_bulk_rising_edge_events_flags()

int gpiod_line_request_bulk_rising_edge_events_flags ( struct gpiod_line_bulk bulk,
const char *  consumer,
int  flags 
)

Request rising edge event notifications on a set of lines.

Parameters
bulkSet of GPIO lines to request.
consumerName of the consumer.
flagsAdditional request flags.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_request_falling_edge_events()

int gpiod_line_request_falling_edge_events ( struct gpiod_line *  line,
const char *  consumer 
)

Request falling edge event notifications on a single line.

Parameters
lineGPIO line object.
consumerName of the consumer.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_request_falling_edge_events_flags()

int gpiod_line_request_falling_edge_events_flags ( struct gpiod_line *  line,
const char *  consumer,
int  flags 
)

Request falling edge event notifications on a single line.

Parameters
lineGPIO line object.
consumerName of the consumer.
flagsAdditional request flags.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_request_input()

int gpiod_line_request_input ( struct gpiod_line *  line,
const char *  consumer 
)

Reserve a single line, set the direction to input.

Parameters
lineGPIO line object.
consumerName of the consumer.
Returns
0 if the line was properly reserved, -1 on failure.

◆ gpiod_line_request_input_flags()

int gpiod_line_request_input_flags ( struct gpiod_line *  line,
const char *  consumer,
int  flags 
)

Reserve a single line, set the direction to input.

Parameters
lineGPIO line object.
consumerName of the consumer.
flagsAdditional request flags.
Returns
0 if the line was properly reserved, -1 on failure.

◆ gpiod_line_request_output()

int gpiod_line_request_output ( struct gpiod_line *  line,
const char *  consumer,
int  default_val 
)

Reserve a single line, set the direction to output.

Parameters
lineGPIO line object.
consumerName of the consumer.
default_valInitial line value.
Returns
0 if the line was properly reserved, -1 on failure.

◆ gpiod_line_request_output_flags()

int gpiod_line_request_output_flags ( struct gpiod_line *  line,
const char *  consumer,
int  flags,
int  default_val 
)

Reserve a single line, set the direction to output.

Parameters
lineGPIO line object.
consumerName of the consumer.
flagsAdditional request flags.
default_valInitial line value.
Returns
0 if the line was properly reserved, -1 on failure.

◆ gpiod_line_request_rising_edge_events()

int gpiod_line_request_rising_edge_events ( struct gpiod_line *  line,
const char *  consumer 
)

Request rising edge event notifications on a single line.

Parameters
lineGPIO line object.
consumerName of the consumer.
Returns
0 if the operation succeeds, -1 on failure.

◆ gpiod_line_request_rising_edge_events_flags()

int gpiod_line_request_rising_edge_events_flags ( struct gpiod_line *  line,
const char *  consumer,
int  flags 
)

Request rising edge event notifications on a single line.

Parameters
lineGPIO line object.
consumerName of the consumer.
flagsAdditional request flags.
Returns
0 if the operation succeeds, -1 on failure.