diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2013-11-28 15:25:10 +0200 |
---|---|---|
committer | Sakari Ailus <sakari.ailus@linux.intel.com> | 2016-05-26 15:30:51 +0300 |
commit | e9d550239795c45561f062a43c228ef89c68353e (patch) | |
tree | 6200eafd86ce31d8d4c341c1bbadba8be8f575d8 | |
parent | dad4a1cc932dfc235078d7d04b7c271eb25ca5b7 (diff) |
mediactl: Separate entity and pad parsing
Sometimes it's useful to be able to parse the entity independent of the pad.
Separate entity parsing into media_parse_entity().
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | utils/media-ctl/libmediactl.c | 29 | ||||
-rw-r--r-- | utils/media-ctl/mediactl.h | 14 |
2 files changed, 39 insertions, 4 deletions
diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index 78caa7ca..498dfd1c 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -781,10 +781,10 @@ int media_device_add_entity(struct media_device *media, return 0; } -struct media_pad *media_parse_pad(struct media_device *media, - const char *p, char **endp) +struct media_entity *media_parse_entity(struct media_device *media, + const char *p, char **endp) { - unsigned int entity_id, pad; + unsigned int entity_id; struct media_entity *entity; char *end; @@ -827,7 +827,28 @@ struct media_pad *media_parse_pad(struct media_device *media, return NULL; } } - for (; isspace(*end); ++end); + for (p = end; isspace(*p); ++p); + + *endp = (char *)p; + + return entity; +} + +struct media_pad *media_parse_pad(struct media_device *media, + const char *p, char **endp) +{ + unsigned int pad; + struct media_entity *entity; + char *end; + + if (endp == NULL) + endp = &end; + + entity = media_parse_entity(media, p, &end); + if (!entity) { + *endp = end; + return NULL; + } if (*end != ':') { media_dbg(media, "Expected ':'\n", *end); diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h index b5a92f59..af360518 100644 --- a/utils/media-ctl/mediactl.h +++ b/utils/media-ctl/mediactl.h @@ -367,6 +367,20 @@ int media_setup_link(struct media_device *media, int media_reset_links(struct media_device *media); /** + * @brief Parse string to an entity 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 an entity and return its + * struct media_entity instance. + * + * @return Pointer to struct media_entity on success, NULL on failure. + */ +struct media_entity *media_parse_entity(struct media_device *media, + const char *p, char **endp); + +/** * @brief Parse string to a pad on the media device. * @param media - media device. * @param p - input string |