From 636b48e43db57442fd631a7c5592e34da74f191d Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Fri, 7 Oct 2011 18:38:03 +0300 Subject: 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 Acked-by: Laurent Pinchart --- src/mediactl.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) (limited to 'src/mediactl.h') 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 -- cgit v1.2.3