| 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 | /* SPDX-FileCopyrightText: 2023-2024 Bartosz Golaszewski <[email protected]> */ |
| 3 | |
| 4 | #ifndef __GPIODGLIB_LINE_CONFIG_H__ |
| 5 | #define __GPIODGLIB_LINE_CONFIG_H__ |
| 6 | |
| 7 | #if !defined(__INSIDE_GPIOD_GLIB_H__) && !defined(GPIODGLIB_COMPILATION) |
| 8 | #error "Only <gpiod-glib.h> can be included directly." |
| 9 | #endif |
| 10 | |
| 11 | #include <glib.h> |
| 12 | #include <glib-object.h> |
| 13 | |
| 14 | #include "line-settings.h" |
| 15 | |
| 16 | G_BEGIN_DECLS |
| 17 | |
| 18 | G_DECLARE_FINAL_TYPE(GpiodglibLineConfig, gpiodglib_line_config, |
| 19 | GPIODGLIB, LINE_CONFIG, GObject); |
| 20 | |
| 21 | #define GPIODGLIB_LINE_CONFIG_TYPE (gpiodglib_line_config_get_type()) |
| 22 | #define GPIODGLIB_LINE_CONFIG_OBJ(obj) \ |
| 23 | (G_TYPE_CHECK_INSTANCE_CAST((obj), GPIODGLIB_LINE_CONFIG_TYPE, \ |
| 24 | GpiodglibLineConfig)) |
| 25 | |
| 26 | /** |
| 27 | * gpiodglib_line_config_new: |
| 28 | * |
| 29 | * Create a new #GpiodglibLineConfig. |
| 30 | * |
| 31 | * Returns: (transfer full): Empty #GpiodglibLineConfig. |
| 32 | */ |
| 33 | GpiodglibLineConfig *gpiodglib_line_config_new(void); |
| 34 | |
| 35 | /** |
| 36 | * gpiodglib_line_config_reset: |
| 37 | * @self: #GpiodglibLineConfig to manipulate. |
| 38 | * |
| 39 | * Reset the line config object. |
| 40 | */ |
| 41 | void gpiodglib_line_config_reset(GpiodglibLineConfig *self); |
| 42 | |
| 43 | /** |
| 44 | * gpiodglib_line_config_add_line_settings: |
| 45 | * @self: #GpiodglibLineConfig to manipulate. |
| 46 | * @offsets: (element-type GArray): GArray of offsets for which to apply the |
| 47 | * settings. |
| 48 | * @settings: #GpiodglibLineSettings to apply. |
| 49 | * @err: Return location for error or NULL. |
| 50 | * |
| 51 | * Add line settings for a set of offsets. |
| 52 | * |
| 53 | * Returns: TRUE on success, FALSE on failure. |
| 54 | */ |
| 55 | gboolean |
| 56 | gpiodglib_line_config_add_line_settings(GpiodglibLineConfig *self, |
| 57 | const GArray *offsets, |
| 58 | GpiodglibLineSettings *settings, |
| 59 | GError **err); |
| 60 | |
| 61 | /** |
| 62 | * gpiodglib_line_config_get_line_settings: |
| 63 | * @self: #GpiodglibLineConfig to manipulate. |
| 64 | * @offset: Offset for which to get line settings. |
| 65 | * |
| 66 | * Get line settings for offset. |
| 67 | * |
| 68 | * Returns: (transfer full): New reference to a #GpiodglibLineSettings. |
| 69 | */ |
| 70 | GpiodglibLineSettings * |
| 71 | gpiodglib_line_config_get_line_settings(GpiodglibLineConfig *self, |
| 72 | guint offset); |
| 73 | |
| 74 | /** |
| 75 | * gpiodglib_line_config_set_output_values: |
| 76 | * @self: #GpiodglibLineConfig to manipulate. |
| 77 | * @values: (element-type GArray): GArray containing the output values. |
| 78 | * @err: Return location for error or NULL. |
| 79 | * |
| 80 | * @brief Set output values for a number of lines. |
| 81 | * |
| 82 | * Returns: TRUE on success, FALSE on error. |
| 83 | */ |
| 84 | gboolean gpiodglib_line_config_set_output_values(GpiodglibLineConfig *self, |
| 85 | const GArray *values, |
| 86 | GError **err); |
| 87 | |
| 88 | /** |
| 89 | * gpiodglib_line_config_get_configured_offsets: |
| 90 | * @self: #GpiodglibLineConfig to manipulate. |
| 91 | * |
| 92 | * Get configured offsets. |
| 93 | * |
| 94 | * Returns: (transfer full) (element-type GArray): GArray containing the |
| 95 | * offsets for which configuration has been set. |
| 96 | */ |
| 97 | GArray *gpiodglib_line_config_get_configured_offsets(GpiodglibLineConfig *self); |
| 98 | |
| 99 | G_END_DECLS |
| 100 | |
| 101 | #endif /* __GPIODGLIB_LINE_CONFIG_H__ */ |