core: add bulk event requests
authorBartosz Golaszewski <bartekgola@gmail.com>
Thu, 13 Jul 2017 11:53:46 +0000 (13:53 +0200)
committerBartosz Golaszewski <bartekgola@gmail.com>
Thu, 13 Jul 2017 11:54:27 +0000 (13:54 +0200)
Add functions for requesting events for line bulk objects. Both with
and without additional flags.

Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
include/gpiod.h
src/lib/core.c

index 828f8245344151f21dd20d8fc396c385d6a72be2..fb0010664bfc9026ec982ccaa977887fdda0e2a6 100644 (file)
@@ -620,6 +620,33 @@ int gpiod_line_request_bulk_output(struct gpiod_line_bulk *bulk,
                                   const char *consumer,
                                   const int *default_vals) GPIOD_API;
 
+/**
+ * @brief Request rising edge event notifications on a set of lines.
+ * @param bulk Set of GPIO lines to request.
+ * @param consumer Name of the consumer.
+ * @return 0 if the operation succeeds, -1 on failure.
+ */
+int gpiod_line_request_bulk_rising_edge_events(struct gpiod_line_bulk *bulk,
+                                              const char *consumer) GPIOD_API;
+
+/**
+ * @brief Request falling edge event notifications on a set of lines.
+ * @param bulk Set of GPIO lines to request.
+ * @param consumer Name of the consumer.
+ * @return 0 if the operation succeeds, -1 on failure.
+ */
+int gpiod_line_request_bulk_falling_edge_events(struct gpiod_line_bulk *bulk,
+                                               const char *consumer) GPIOD_API;
+
+/**
+ * @brief Request all event type notifications on a set of lines.
+ * @param bulk Set of GPIO lines to request.
+ * @param consumer Name of the consumer.
+ * @return 0 if the operation succeeds, -1 on failure.
+ */
+int gpiod_line_request_bulk_both_edges_events(struct gpiod_line_bulk *bulk,
+                                             const char *consumer) GPIOD_API;
+
 /**
  * @brief Reserve a set of GPIO lines, set the direction to input.
  * @param bulk Set of GPIO lines to reserve.
@@ -643,6 +670,42 @@ int gpiod_line_request_bulk_output_flags(struct gpiod_line_bulk *bulk,
                                         const char *consumer, int flags,
                                         const int *default_vals) GPIOD_API;
 
+/**
+ * @brief Request rising edge event notifications on a set of lines.
+ * @param bulk Set of GPIO lines to request.
+ * @param consumer Name of the consumer.
+ * @param flags Additional request flags.
+ * @return 0 if the operation succeeds, -1 on failure.
+ */
+int gpiod_line_request_bulk_rising_edge_events_flags(
+                                       struct gpiod_line_bulk *bulk,
+                                       const char *consumer,
+                                       int flags) GPIOD_API;
+
+/**
+ * @brief Request falling edge event notifications on a set of lines.
+ * @param bulk Set of GPIO lines to request.
+ * @param consumer Name of the consumer.
+ * @param flags Additional request flags.
+ * @return 0 if the operation succeeds, -1 on failure.
+ */
+int gpiod_line_request_bulk_falling_edge_events_flags(
+                                       struct gpiod_line_bulk *bulk,
+                                       const char *consumer,
+                                       int flags) GPIOD_API;
+
+/**
+ * @brief Request all event type notifications on a set of lines.
+ * @param bulk Set of GPIO lines to request.
+ * @param consumer Name of the consumer.
+ * @param flags Additional request flags.
+ * @return 0 if the operation succeeds, -1 on failure.
+ */
+int gpiod_line_request_bulk_both_edges_events_flags(
+                                       struct gpiod_line_bulk *bulk,
+                                       const char *consumer,
+                                       int flags) GPIOD_API;
+
 /**
  * @brief Release a previously reserved line.
  * @param line GPIO line object.
index 96b0d2cc789620a0b542555e890ae0d88113c13d..4a2ef84f1c18123ce7042f205a0a77068b49dbb8 100644 (file)
@@ -690,6 +690,40 @@ int gpiod_line_request_bulk_output(struct gpiod_line_bulk *bulk,
        return gpiod_line_request_bulk(bulk, &config, default_vals);
 }
 
+static int line_event_request_type_bulk(struct gpiod_line_bulk *bulk,
+                                       const char *consumer,
+                                       int flags, int type)
+{
+       struct gpiod_line_request_config config = {
+               .consumer = consumer,
+               .request_type = type,
+               .flags = flags,
+       };
+
+       return gpiod_line_request_bulk(bulk, &config, 0);
+}
+
+int gpiod_line_request_bulk_rising_edge_events(struct gpiod_line_bulk *bulk,
+                                              const char *consumer)
+{
+       return line_event_request_type_bulk(bulk, consumer, 0,
+                                           GPIOD_REQUEST_EVENT_RISING_EDGE);
+}
+
+int gpiod_line_request_bulk_falling_edge_events(struct gpiod_line_bulk *bulk,
+                                               const char *consumer)
+{
+       return line_event_request_type_bulk(bulk, consumer, 0,
+                                           GPIOD_REQUEST_EVENT_FALLING_EDGE);
+}
+
+int gpiod_line_request_bulk_both_edges_events(struct gpiod_line_bulk *bulk,
+                                             const char *consumer)
+{
+       return line_event_request_type_bulk(bulk, consumer, 0,
+                                           GPIOD_REQUEST_EVENT_BOTH_EDGES);
+}
+
 int gpiod_line_request_bulk_input_flags(struct gpiod_line_bulk *bulk,
                                        const char *consumer, int flags)
 {
@@ -715,6 +749,30 @@ int gpiod_line_request_bulk_output_flags(struct gpiod_line_bulk *bulk,
        return gpiod_line_request_bulk(bulk, &config, default_vals);
 }
 
+int gpiod_line_request_bulk_rising_edge_events_flags(
+                                       struct gpiod_line_bulk *bulk,
+                                       const char *consumer, int flags)
+{
+       return line_event_request_type_bulk(bulk, consumer, flags,
+                                           GPIOD_REQUEST_EVENT_RISING_EDGE);
+}
+
+int gpiod_line_request_bulk_falling_edge_events_flags(
+                                       struct gpiod_line_bulk *bulk,
+                                       const char *consumer, int flags)
+{
+       return line_event_request_type_bulk(bulk, consumer, flags,
+                                           GPIOD_REQUEST_EVENT_FALLING_EDGE);
+}
+
+int gpiod_line_request_bulk_both_edges_events_flags(
+                                       struct gpiod_line_bulk *bulk,
+                                       const char *consumer, int flags)
+{
+       return line_event_request_type_bulk(bulk, consumer, flags,
+                                           GPIOD_REQUEST_EVENT_BOTH_EDGES);
+}
+
 void gpiod_line_release(struct gpiod_line *line)
 {
        struct gpiod_line_bulk bulk;