diff options
author | Sakari Ailus <sakari.ailus@iki.fi> | 2011-10-07 18:38:03 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2011-10-08 13:30:11 +0200 |
commit | 636b48e43db57442fd631a7c5592e34da74f191d (patch) | |
tree | a0b06b78f7f9d3b762fbec3e884498630fcd7a2b /src/mediactl.h | |
parent | 9a5f1e0365265310545abdd43da7d28a44fd43a6 (diff) |
Move link parsing from main.c to media.c, making it part of libmediactl
This makes it possible to benefit from the link parsing code anywhere the
library is being used.
dprintf macro will later be replaced with proper debug support.
Also fix a case where -1 was returned on error and the user was expected to
check the value of errno. Negative error codes are now returned
consistently.
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.h | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/src/mediactl.h b/src/mediactl.h index b53b9cc..937b918 100644 --- a/src/mediactl.h +++ b/src/mediactl.h @@ -140,7 +140,9 @@ struct media_entity *media_get_entity_by_id(struct media_device *media, * * Only the MEDIA_LINK_FLAG_ENABLED flag is writable. * - * @return 0 on success, or a negative error code on failure. + * @return 0 on success, -1 on failure: + * -ENOENT: link not found + * - other error codes returned by MEDIA_IOC_SETUP_LINK */ int media_setup_link(struct media_device *media, struct media_pad *source, struct media_pad *sink, @@ -157,4 +159,57 @@ int media_setup_link(struct media_device *media, */ int media_reset_links(struct media_device *media); +/** + * @brief Parse string to a pad on the media device. + * @param media - media device. + * @param p - input string + * @param endp - pointer to string where parsing ended + * + * Parse NULL terminated string describing a pad and return its struct + * media_pad instance. + * + * @return Pointer to struct media_pad on success, NULL on failure. + */ +struct media_pad *media_parse_pad(struct media_device *media, + const char *p, char **endp); + +/** + * @brief Parse string to a link on the media device. + * @param media - media device. + * @param p - input string + * @param endp - pointer to p where parsing ended + * + * Parse NULL terminated string p describing a link and return its struct + * media_link instance. + * + * @return Pointer to struct media_link on success, NULL on failure. + */ +struct media_link *media_parse_link(struct media_device *media, + const char *p, char **endp); + +/** + * @brief Parse string to a link on the media device and set it up. + * @param media - media device. + * @param p - input string + * + * Parse NULL terminated string p describing a link and its configuration + * and configure the link. + * + * @return 0 on success, or a negative error code on failure. + */ +int media_parse_setup_link(struct media_device *media, + const char *p, char **endp); + +/** + * @brief Parse string to link(s) on the media device and set it up. + * @param media - media device. + * @param p - input string + * + * Parse NULL terminated string p describing link(s) separated by + * commas (,) and configure the link(s). + * + * @return 0 on success, or a negative error code on failure. + */ +int media_parse_setup_links(struct media_device *media, const char *p); + #endif |