| 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 | /* SPDX-FileCopyrightText: 2021 Bartosz Golaszewski <[email protected]> */ |
| 3 | |
| 4 | #ifndef __LIBGPIOD_GPIOD_INTERNAL_H__ |
| 5 | #define __LIBGPIOD_GPIOD_INTERNAL_H__ |
| 6 | |
| 7 | #include <gpiod.h> |
| 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
| 10 | |
| 11 | #include "uapi/gpio.h" |
| 12 | |
| 13 | /* For internal library use only. */ |
| 14 | |
| 15 | #define GPIOD_API __attribute__((visibility("default"))) |
| 16 | #define GPIOD_BIT(nr) (1UL << (nr)) |
| 17 | |
| 18 | bool gpiod_check_gpiochip_device(const char *path, bool set_errno); |
| 19 | |
| 20 | struct gpiod_chip_info * |
| 21 | gpiod_chip_info_from_uapi(struct gpiochip_info *uapi_info); |
| 22 | struct gpiod_line_info * |
| 23 | gpiod_line_info_from_uapi(struct gpio_v2_line_info *uapi_info); |
| 24 | void gpiod_request_config_to_uapi(struct gpiod_request_config *config, |
| 25 | struct gpio_v2_line_request *uapi_req); |
| 26 | int gpiod_line_config_to_uapi(struct gpiod_line_config *config, |
| 27 | struct gpio_v2_line_request *uapi_cfg); |
| 28 | struct gpiod_line_request * |
| 29 | gpiod_line_request_from_uapi(struct gpio_v2_line_request *uapi_req, |
| 30 | const char *chip_name); |
| 31 | int gpiod_edge_event_buffer_read_fd(int fd, |
| 32 | struct gpiod_edge_event_buffer *buffer, |
| 33 | size_t max_events); |
| 34 | struct gpiod_info_event * |
| 35 | gpiod_info_event_from_uapi(struct gpio_v2_line_info_changed *uapi_evt); |
| 36 | struct gpiod_info_event *gpiod_info_event_read_fd(int fd); |
| 37 | |
| 38 | int gpiod_poll_fd(int fd, int64_t timeout); |
| 39 | int gpiod_set_output_value(enum gpiod_line_value in, |
| 40 | enum gpiod_line_value *out); |
| 41 | int gpiod_ioctl(int fd, unsigned long request, void *arg); |
| 42 | |
| 43 | void gpiod_line_mask_zero(uint64_t *mask); |
| 44 | bool gpiod_line_mask_test_bit(const uint64_t *mask, unsigned int nr); |
| 45 | void gpiod_line_mask_set_bit(uint64_t *mask, unsigned int nr); |
| 46 | void gpiod_line_mask_assign_bit(uint64_t *mask, unsigned int nr, bool value); |
| 47 | |
| 48 | #endif /* __LIBGPIOD_GPIOD_INTERNAL_H__ */ |