summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/xlnx-events.h43
-rw-r--r--include/xlnx-list.h99
-rw-r--r--include/xlnx-plugin.h93
-rw-r--r--include/xlnx-tools.h70
-rw-r--r--include/xlnx-video.h129
5 files changed, 434 insertions, 0 deletions
diff --git a/include/xlnx-events.h b/include/xlnx-events.h
new file mode 100644
index 0000000..ebf575d
--- /dev/null
+++ b/include/xlnx-events.h
@@ -0,0 +1,43 @@
+/*
+ * Xilinx Video Library - select()-based generic event loop
+ *
+ * Copyright (C) 2014-2016 Ideas on board Oy
+ *
+ * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __XLNX_EVENTS_H__
+#define __XLNX_EVENTS_H__
+
+/**
+ * \file
+ * \brief select()-based event loop implementation
+ *
+ * This event loop is a sample event handling operations implementation. It
+ * registers event handler operations with the library context and implements an
+ * infinite event loop based on the select() function to wait for events on
+ * file descriptors.
+ */
+
+struct xlnx_video;
+
+int xlnx_events_init(struct xlnx_video *xv);
+void xlnx_events_fini(struct xlnx_video *xv);
+bool xlnx_events_loop(struct xlnx_video *xv);
+void xlnx_events_stop(struct xlnx_video *xv);
+
+#endif /* __XLNX_EVENTS_H__ */
diff --git a/include/xlnx-list.h b/include/xlnx-list.h
new file mode 100644
index 0000000..f23ab24
--- /dev/null
+++ b/include/xlnx-list.h
@@ -0,0 +1,99 @@
+/*
+ * Xilinx Video Library - Double linked lists
+ *
+ * Copyright (C) 2014-2016 Ideas on board Oy
+ *
+ * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef __XLNX_LIST_H__
+#define __XLNX_LIST_H__
+
+#include <stddef.h>
+
+struct list_entry {
+ struct list_entry *prev;
+ struct list_entry *next;
+};
+
+static inline void list_init(struct list_entry *list)
+{
+ list->next = list;
+ list->prev = list;
+}
+
+static inline int list_empty(struct list_entry *list)
+{
+ return list->next == list;
+}
+
+static inline void list_append(struct list_entry *entry, struct list_entry *list)
+{
+ entry->next = list;
+ entry->prev = list->prev;
+ list->prev->next = entry;
+ list->prev = entry;
+}
+
+static inline void list_prepend(struct list_entry *entry, struct list_entry *list)
+{
+ entry->next = list->next;
+ entry->prev = list;
+ list->next->prev = entry;
+ list->next = entry;
+}
+
+static inline void list_insert_after(struct list_entry *entry, struct list_entry *after)
+{
+ list_prepend(entry, after);
+}
+
+static inline void list_insert_before(struct list_entry *entry, struct list_entry *before)
+{
+ list_append(entry, before);
+}
+
+static inline void list_remove(struct list_entry *entry)
+{
+ entry->prev->next = entry->next;
+ entry->next->prev = entry->prev;
+}
+
+#define list_entry(entry, type, member) \
+ (type *)((char *)(entry) - offsetof(type, member))
+
+#define list_first_entry(list, type, member) \
+ list_entry((list)->next, type, member)
+
+#define list_last_entry(list, type, member) \
+ list_entry((list)->prev, type, member)
+
+#define list_for_each(entry, list) \
+ for (entry = (list)->next; entry != (list); entry = entry->next)
+
+#define list_for_each_entry(entry, list, member) \
+ for (entry = list_entry((list)->next, typeof(*entry), member); \
+ &entry->member != (list); \
+ entry = list_entry(entry->member.next, typeof(*entry), member))
+
+#define list_for_each_safe(entry, __next, list) \
+ for (entry = (list)->next, __next = entry->next; entry != (list); \
+ entry = __next, __next = entry->next)
+
+#define list_for_each_entry_safe(entry, __next, list, member) \
+ for (entry = list_entry((list)->next, typeof(*entry), member), \
+ __next = list_entry(entry->member.next, typeof(*entry), member); \
+ &entry->member != (list); \
+ entry = __next, __next = list_entry(entry->member.next, typeof(*entry), member))
+
+#endif /* __XLNX_LIST_H__ */
diff --git a/include/xlnx-plugin.h b/include/xlnx-plugin.h
new file mode 100644
index 0000000..ff39fed
--- /dev/null
+++ b/include/xlnx-plugin.h
@@ -0,0 +1,93 @@
+/*
+ * Xilinx Video Library - Plugin API
+ *
+ * Copyright (C) 2014-2016 Ideas on board Oy
+ *
+ * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef __XLNX_PLUGIN_H__
+#define __XLNX_PLUGIN_H__
+
+/**
+ * \file
+ * \brief Library plugin support
+ *
+ * To be discovered by the Xilinx video library, plugins must export a plugin
+ * operations structure with a well-defined symbol name. Plugins should use the
+ * EXPORT_XLNX_VIDEO_PLUGIN() macro to declare the strucure and initialize its
+ * members with function pointers.
+ *
+ * \code{.c}
+ * EXPORT_XLNX_VIDEO_PLUGIN(myplugin) = {
+ * .info = myplugin_info,
+ * .scan = myplugin_scan,
+ * }
+ * \endcode
+ */
+
+#include <xlnx-video.h>
+
+struct media_device;
+struct xlnx_video_compoment;
+
+/**
+ * \brief Type of video component supported by the plugin
+ */
+enum xlnx_video_plugin_type {
+ /**
+ * Hardware video component, handled automatically when the plugin is
+ * loaded or the component discovered.
+ */
+ XLNX_VIDEO_PLUGIN_TYPE_HARDWARE,
+ /**
+ * Software video component, instantiated manually.
+ */
+ XLNX_VIDEO_PLUGIN_TYPE_SOFTWARE,
+};
+
+/**
+ * \brief Plugin information
+ */
+struct xlnx_video_plugin_info {
+ /** Plugin name */
+ const char *name;
+ /** Plugin type, one of XLNX_VIDEO_PLUGIN_TYPE_* */
+ enum xlnx_video_plugin_type type;
+};
+
+/**
+ * \brief Xilinx video plugin operations
+ */
+struct xlnx_video_plugin_ops {
+ /**
+ * Query plugin information. The returned structure must be valid for
+ * the lifetime of the plugin.
+ */
+ const struct xlnx_video_plugin_info *(*info)(void);
+ struct xlnx_video_component *(*scan)(struct xlnx_video *xv,
+ struct media_device *mdev);
+ struct xlnx_video_component *(*create_component)(struct xlnx_video *xv);
+ void (*destroy_component)(struct xlnx_video *xv,
+ struct xlnx_video_compoment *xvcomp);
+ /** Reserved fields for ABI compatibility, must be set to NULL. */
+ void (*reserved[10])(void);
+};
+
+/** \cond IGNORE */
+#define XLNX_VIDEO_PLUGIN_SYMBOL __xlnx_video_plugin
+#define EXPORT_XLNX_VIDEO_PLUGIN(name) \
+const struct xlnx_video_plugin_ops XLNX_VIDEO_PLUGIN_SYMBOL
+/** \endcond */
+
+#endif /* __XLNX_PLUGIN_H__ */
diff --git a/include/xlnx-tools.h b/include/xlnx-tools.h
new file mode 100644
index 0000000..799d915
--- /dev/null
+++ b/include/xlnx-tools.h
@@ -0,0 +1,70 @@
+/*
+ * Xilinx Video Library - Tools
+ *
+ * Copyright (C) 2014-2016 Ideas on board Oy
+ *
+ * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef __XLNX_TOOLS_H__
+#define __XLNX_TOOLS_H__
+
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
+#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
+
+#define min(a, b) ({ \
+ typeof(a) __a = (a); \
+ typeof(b) __b = (b); \
+ __a < __b ? __a : __b; \
+})
+
+#define min_t(type, a, b) ({ \
+ type __a = (a); \
+ type __b = (b); \
+ __a < __b ? __a : __b; \
+})
+
+#define max(a, b) ({ \
+ typeof(a) __a = (a); \
+ typeof(b) __b = (b); \
+ __a > __b ? __a : __b; \
+})
+
+#define max_t(type, a, b) ({ \
+ type __a = (a); \
+ type __b = (b); \
+ __a > __b ? __a : __b; \
+})
+
+#define clamp(val, min, max) ({ \
+ typeof(val) __val = (val); \
+ typeof(min) __min = (min); \
+ typeof(max) __max = (max); \
+ __val = __val < __min ? __min : __val; \
+ __val > __max ? __max : __val; \
+})
+
+#define clamp_t(type, val, min, max) ({ \
+ type __val = (val); \
+ type __min = (min); \
+ type __max = (max); \
+ __val = __val < __min ? __min : __val; \
+ __val > __max ? __max : __val; \
+})
+
+#define div_round_up(num, denom) (((num) + (denom) - 1) / (denom))
+
+#define container_of(ptr, type, member) \
+ (type *)((char *)(ptr) - offsetof(type, member))
+
+#endif /* __XLNX_TOOLS_H__ */
diff --git a/include/xlnx-video.h b/include/xlnx-video.h
new file mode 100644
index 0000000..eaebb80
--- /dev/null
+++ b/include/xlnx-video.h
@@ -0,0 +1,129 @@
+/*
+ * Xilinx Video Library
+ *
+ * Copyright (C) 2014-2016 Ideas on board Oy
+ *
+ * Contact: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef __XLNX_VIDEO_H__
+#define __XLNX_VIDEO_H__
+
+/**
+ * \file
+ * \brief Xilinx Video Library
+ */
+
+struct xlnx_video;
+struct xlnx_video_component;
+struct xlnx_video_pipeline;
+
+struct xlnx_video *xlnx_video_create(void);
+int xlnx_video_setup(struct xlnx_video *xv);
+void xlnx_video_destroy(struct xlnx_video *xv);
+
+/**
+ * \brief Library log level
+ *
+ * Only messages with a log level lower than or equal to the library context
+ * log level are logged, all other messages are dropped silently.
+ *
+ * \sa xlnx_log_set_level()
+ */
+enum xlnx_log_level {
+ /** Don't log any message */
+ XLNX_LOG_NONE = 0,
+ /** Log error messages */
+ XLNX_LOG_ERROR = 1,
+ /** Log warning messages */
+ XLNX_LOG_WARNING = 2,
+ /** Log informational messages */
+ XLNX_LOG_INFO = 3,
+ /** Log debug messages */
+ XLNX_LOG_DEBUG = 4,
+};
+
+void xlnx_video_set_log_level(struct xlnx_video *xv, enum xlnx_log_level level);
+
+/**
+ * \brief Event handler operations
+ *
+ * The library requires a set of event handling operations whose implementation
+ * can vary between applications depending on their architecture. To avoid
+ * restricting applications to a particular programming model, those operations
+ * are not implemented by the library directly but must be provided by
+ * applications in the form of callback functions.
+ *
+ * The xlnx_video_event_operations structure contains callback function
+ * pointers for all event handling operations. Applications must supply an
+ * implementation for each operation.
+ *
+ * All event handling operations are called by the library with the handler
+ * parameter set to the event handler passed to the
+ * xlnx_video_set_event_handler() function.
+ */
+struct xlnx_video_event_operations {
+ /**
+ * \param handler event handler private data
+ * \param fd the file descriptor number
+ * \param events the types of events to watch for
+ * \param callback callback event handler
+ * \param priv private token passed to the callback event handler
+ *
+ * Start watching the file descriptor \a fd for events of type
+ * \a events, and call the \a callback function with the priv parameter
+ * set to \a priv when such an event is detected.
+ */
+ void (*watch)(void *handler, int fd, int events,
+ void(*callback)(void *priv), void *priv);
+ /**
+ * \param handler event handler private data
+ * \param fd the file descriptor number
+ *
+ * Stop watching the file descriptor \a fd for events.
+ */
+ void (*unwatch)(void *handler, int fd);
+};
+
+void xlnx_video_set_event_handler(struct xlnx_video *xv,
+ const struct xlnx_video_event_operations *ops,
+ void *handler);
+void *xlnx_video_get_event_handler_data(struct xlnx_video *xv);
+
+int xlnx_video_plugin_load_directory(struct xlnx_video *xv, const char *path);
+
+/**
+ * \brief Video component type
+ */
+enum xlnx_video_component_type {
+ /** Video capture component (input) */
+ XLNX_VIDEO_COMPONENT_CAPTURE = 1 << 0,
+ /** Video processing component (memory to memory) */
+ XLNX_VIDEO_COMPONENT_PROCESS = 1 << 1,
+ /** Video display component (output) */
+ XLNX_VIDEO_COMPONENT_DISPLAY = 1 << 2,
+ /** Any component type */
+ XLNX_VIDEO_COMPONENT_ANY = XLNX_VIDEO_COMPONENT_CAPTURE
+ | XLNX_VIDEO_COMPONENT_PROCESS
+ | XLNX_VIDEO_COMPONENT_DISPLAY,
+};
+
+int xlnx_video_component_enumerate(struct xlnx_video *xv);
+int xlnx_video_component_list(struct xlnx_video *xv,
+ enum xlnx_video_component_type type,
+ struct xlnx_video_component ***components);
+const char *xlnx_video_component_name(const struct xlnx_video_component *xvcomp);
+enum xlnx_video_component_type
+xlnx_video_component_type(const struct xlnx_video_component *xvcomp);
+
+#endif