Debian Codegraph @

bindings/glib/gpiod-glib/line-request.h

raw symbols SCIP
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /* SPDX-FileCopyrightText: 2023-2024 Bartosz Golaszewski <[email protected]> */
3
4 #ifndef __GPIODGLIB_LINE_REQUEST_H__
5 #define __GPIODGLIB_LINE_REQUEST_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 G_BEGIN_DECLS
15
16 G_DECLARE_FINAL_TYPE(GpiodglibLineRequest, gpiodglib_line_request,
17 GPIODGLIB, LINE_REQUEST, GObject);
18
19 #define GPIODGLIB_LINE_REQUEST_TYPE (gpiodglib_line_request_get_type())
20 #define GPIODGLIB_LINE_REQUEST_OBJ(obj) \
21 (G_TYPE_CHECK_INSTANCE_CAST((obj), GPIODGLIB_LINE_REQUEST_TYPE, \
22 GpiodglibLineRequest))
23
24 /**
25 * gpiodglib_line_request_release:
26 * @self: #GpiodglibLineRequest to manipulate.
27 *
28 * Release the requested lines and free all associated resources.
29 */
30 void gpiodglib_line_request_release(GpiodglibLineRequest *self);
31
32 /**
33 * gpiodglib_line_request_is_released:
34 * @self: #GpiodglibLineRequest to manipulate.
35 *
36 * Check if this request was released.
37 *
38 * Returns: TRUE if this request was released and is no longer valid, FALSE
39 * otherwise.
40 */
41 gboolean gpiodglib_line_request_is_released(GpiodglibLineRequest *self);
42
43 /**
44 * gpiodglib_line_request_dup_chip_name:
45 * @self: #GpiodglibLineRequest to manipulate.
46 *
47 * Get the name of the chip this request was made on.
48 *
49 * Returns: Name the GPIO chip device. The string is a copy and must be freed
50 * by the caller using g_free().
51 */
52 gchar * G_GNUC_WARN_UNUSED_RESULT
53 gpiodglib_line_request_dup_chip_name(GpiodglibLineRequest *self);
54
55 /**
56 * gpiodglib_line_request_get_requested_offsets:
57 * @self: #GpiodglibLineRequest to manipulate.
58 *
59 * Get the offsets of the lines in the request.
60 *
61 * Returns: (transfer full) (element-type GArray): Array containing the
62 * requested offsets.
63 */
64 GArray *
65 gpiodglib_line_request_get_requested_offsets(GpiodglibLineRequest *self);
66
67 /**
68 * gpiodglib_line_request_reconfigure_lines:
69 * @self: #GpiodglibLineRequest to manipulate.
70 * @config: New line config to apply.
71 * @err: Return location for error or NULL.
72 *
73 * Update the configuration of lines associated with a line request.
74 *
75 * The new line configuration completely replaces the old. Any requested lines
76 * without overrides are configured to the requested defaults. Any configured
77 * overrides for lines that have not been requested are silently ignored.
78 *
79 * Returns: TRUE on success, FALSE on failure.
80 */
81 gboolean gpiodglib_line_request_reconfigure_lines(GpiodglibLineRequest *self,
82 GpiodglibLineConfig *config,
83 GError **err);
84
85 /**
86 * gpiodglib_line_request_get_value:
87 * @self: #GpiodglibLineRequest to manipulate.
88 * @offset: The offset of the line of which the value should be read.
89 * @value: Return location for the value.
90 * @err: Return location for error or NULL.
91 *
92 * Get the value of a single requested line.
93 *
94 * Returns: TRUE on success, FALSE on failure.
95 */
96 gboolean
97 gpiodglib_line_request_get_value(GpiodglibLineRequest *self, guint offset,
98 GpiodglibLineValue *value, GError **err);
99
100 /**
101 * gpiodglib_line_request_get_values_subset:
102 * @self: #GpiodglibLineRequest to manipulate.
103 * @offsets: (element-type GArray): Array of offsets identifying the subset of
104 * requested lines from which to read values.
105 * @values: (element-type GArray): Array in which the values will be stored.
106 * Can be NULL in which case a new array will be created and its location
107 * stored here.
108 * @err: Return location for error or NULL.
109 *
110 * Get the values of a subset of requested lines.
111 *
112 * Returns: TRUE on success, FALSE on failure.
113 */
114 gboolean gpiodglib_line_request_get_values_subset(GpiodglibLineRequest *self,
115 const GArray *offsets,
116 GArray **values,
117 GError **err);
118
119 /**
120 * gpiodglib_line_request_get_values:
121 * @self: #GpiodglibLineRequest to manipulate.
122 * @values: (element-type GArray): Array in which the values will be stored.
123 * Can be NULL in which case a new array will be created and its location
124 * stored here.
125 * @err: Return location for error or NULL.
126 *
127 * Get the values of all requested lines.
128 *
129 * Returns: TRUE on success, FALSE on failure.
130 */
131 gboolean gpiodglib_line_request_get_values(GpiodglibLineRequest *self,
132 GArray **values, GError **err);
133
134 /**
135 * gpiodglib_line_request_set_value:
136 * @self: #GpiodglibLineRequest to manipulate.
137 * @offset: The offset of the line for which the value should be set.
138 * @value: Value to set.
139 * @err: Return location for error or NULL.
140 *
141 * Set the value of a single requested line.
142 *
143 * Returns: TRUE on success, FALSE on failure.
144 */
145 gboolean
146 gpiodglib_line_request_set_value(GpiodglibLineRequest *self, guint offset,
147 GpiodglibLineValue value, GError **err);
148
149 /**
150 * gpiodglib_line_request_set_values_subset:
151 * @self: #GpiodglibLineRequest to manipulate.
152 * @offsets: (element-type GArray): Array of offsets identifying the requested
153 * lines for which to set values.
154 * @values: (element-type GArray): Array in which the values will be stored.
155 * Can be NULL in which case a new array will be created and its location
156 * stored here.
157 * @err: Return location for error or NULL.
158 *
159 * Set the values of a subset of requested lines.
160 *
161 * Returns: TRUE on success, FALSE on failure.
162 */
163 gboolean gpiodglib_line_request_set_values_subset(GpiodglibLineRequest *self,
164 const GArray *offsets,
165 const GArray *values,
166 GError **err);
167
168 /**
169 * gpiodglib_line_request_set_values:
170 * @self: #GpiodglibLineRequest to manipulate.
171 * @values: (element-type GArray): Array containing the values to set. Must be
172 * sized to contain the number of values equal to the number of requested lines.
173 * Each value is associated with the line identified by the corresponding entry
174 * in the offset array filled by @gpiodglib_line_request_get_requested_offsets.
175 * @err: Return location for error or NULL.
176 *
177 * Set the values of all lines associated with a request.
178 *
179 * Returns: TRUE on success, FALSE on failure.
180 */
181 gboolean gpiodglib_line_request_set_values(GpiodglibLineRequest *self,
182 GArray *values, GError **err);
183
184 G_END_DECLS
185
186 #endif /* __GPIODGLIB_LINE_REQUEST_H__ */