summaryrefslogtreecommitdiff
path: root/src/mediactl.h
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.fi>2011-10-07 18:38:07 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2011-10-08 13:32:17 +0200
commit2738635d82da5f010bae6a60472a6306df949ea5 (patch)
tree97ce4c08c0ab6dcc7abd7f78bd2e5965e15c63a3 /src/mediactl.h
parent879982243998d6ebf7e7ac4e79b2cfc7371aeda2 (diff)
Add debugging handler
Add debugging handler to media_device that may be used to redirect all debug formatting to user-supplied function. fprintf will do, and that's what media-ctl test program will use. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/mediactl.h')
-rw-r--r--src/mediactl.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mediactl.h b/src/mediactl.h
index fbd7813..b5b5965 100644
--- a/src/mediactl.h
+++ b/src/mediactl.h
@@ -54,9 +54,50 @@ struct media_device {
int fd;
struct media_entity *entities;
unsigned int entities_count;
+ void (*debug_handler)(void *, ...);
+ void *debug_priv;
__u32 padding[6];
};
+#define media_dbg(media, ...) \
+ (media)->debug_handler((media)->debug_priv, __VA_ARGS__)
+
+/**
+ * @brief Set a handler for debug messages.
+ * @param media - device instance.
+ * @param debug_handler - debug message handler
+ * @param debug_priv - first argument to debug message handler
+ *
+ * Set a handler for debug messages that will be called whenever
+ * debugging information is to be printed. The handler expects an
+ * fprintf-like function.
+ */
+void media_debug_set_handler(
+ struct media_device *media, void (*debug_handler)(void *, ...),
+ void *debug_priv);
+
+/**
+ * @brief Open a media device with debugging enabled.
+ * @param name - name (including path) of the device node.
+ * @param verbose - whether to print verbose information on the standard output.
+ * @param debug_handler - debug message handler
+ * @param debug_priv - first argument to debug message handler
+ *
+ * Open the media device referenced by @a name and enumerate entities, pads and
+ * links.
+ *
+ * Calling media_open_debug() instead of media_open() is equivalent to
+ * media_open() and media_debug_set_handler() except that debugging is
+ * also enabled during media_open().
+ *
+ * @return A pointer to a newly allocated media_device structure instance on
+ * success and NULL on failure. The returned pointer must be freed with
+ * media_close when the device isn't needed anymore.
+ */
+struct media_device *media_open_debug(
+ const char *name, int verbose, void (*debug_handler)(void *, ...),
+ void *debug_priv);
+
/**
* @brief Open a media device.
* @param name - name (including path) of the device node.