libmediatext library
cover libmediatext library
Hi,
This is a tiny library for parsing text-based media link, V4L2 sub-device format (and selection) configurations as well as controls with limited types.
This is hardly ready as such but what's there should work.
Signature · 2 lines
Regards, Sakari
RFC 1/2 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().
--- utils/media-ctl/libmediactl.c | 28 ++++++++++++++++++++++++---- utils/media-ctl/mediactl.h | 14 ++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-)
utils/media-ctl/libmediactl.c +24 -4
@@ -770,10 +770,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;
@@ -810,7 +810,27 @@ 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) +return NULL ; + *endp = end;if (*end !=':' ) {media_dbg (media,"Expected ':'\n" , *end);
utils/media-ctl/mediactl.h +14 -0
@@ -368,6 +368,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
Signature · 1 line
2.1.0.231.g7484e3b
RFC 2/2 mediatext: Add library
In reply to Sakari Ailuslibmediatext is a helper library for converting configurations (Media controller links, V4L2 controls and V4L2 sub-device media bus formats and selections) from text-based form into IOCTLs.
libmediatext depends on libv4l2subdev and libmediactl.
--- libmediatext.pc.in | 10 ++ utils/media-ctl/Makefile.am | 10 +- utils/media-ctl/libmediatext.pc.in | 10 ++ utils/media-ctl/mediatext-test.c | 65 ++++++++++++ utils/media-ctl/mediatext.c | 210 +++++++++++++++++++++++++++++++++++++ utils/media-ctl/mediatext.h | 29 +++++ 6 files changed, 332 insertions(+), 2 deletions(-) create mode 100644 libmediatext.pc.in create mode 100644 utils/media-ctl/libmediatext.pc.in create mode 100644 utils/media-ctl/mediatext-test.c create mode 100644 utils/media-ctl/mediatext.c create mode 100644 utils/media-ctl/mediatext.h
libmediatext.pc.in new file +10 -0
@@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libmediatext +Description: Media controller and V4L2 text-based configuration library +Version: @PACKAGE_VERSION@ +Cflags: -I${includedir} +Libs: -L${libdir} -lmediatext
utils/media-ctl/Makefile.am +8 -2
@@ -1,4 +1,4 @@ -noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la +noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la libmediatext.la libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h libmediactl_la_CFLAGS = -static $(LIBUDEV_CFLAGS)
@@ -9,9 +9,15 @@ libv4l2subdev_la_LIBADD = libmediactl.la libv4l2subdev_la_CFLAGS = -static libv4l2subdev_la_LDFLAGS = -static +libmediatext_la_SOURCES = mediatext.c +libmediatext_la_CFLAGS = -static $(LIBUDEV_CFLAGS) +libmediatext_la_LDFLAGS = -static $(LIBUDEV_LIBS) + mediactl_includedir=$(includedir)/mediactl noinst_HEADERS = mediactl.h v4l2subdev.h -bin_PROGRAMS = media-ctl +bin_PROGRAMS = media-ctl mediatext-test media_ctl_SOURCES = media-ctl.c options.c options.h tools.h media_ctl_LDADD = libmediactl.la libv4l2subdev.la +mediatext_test_SOURCES = mediatext-test.c +mediatext_test_LDADD = libmediatext.la libmediactl.la libv4l2subdev.la
utils/media-ctl/libmediatext.pc.in new file +10 -0
@@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libmediatext +Description: Media controller and V4L2 text-based configuration library +Version: @PACKAGE_VERSION@ +Cflags: -I${includedir} +Libs: -L${libdir} -lmediatext
utils/media-ctl/mediatext-test.c new file +65 -0
65 lines not on this page · raw message
utils/media-ctl/mediatext.c new file +210 -0
210 lines not on this page · raw message
utils/media-ctl/mediatext.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Media controller text-based configuration library +* +* Copyright (C) 2013 Intel Corporation +* +* Contact: Sakari Ailus <[email protected]> +* +* This program 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 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 Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __MEDIATEXT_H__ +#define __MEDIATEXT_H__ + +struct media_device ; + +int mediatext_parse (struct media_device *device,char *string); + +#endif /* __MEDIATEXT_H__ */
Signature · 1 line
2.1.0.231.g7484e3b
Hi Sakari,
Quoted 5 lines · Sakari Ailus
Hi,
This is a tiny library for parsing text-based media link, V4L2 sub-device format (and selection) configurations as well as controls with limited types.
Hmm, we also have:
[PATCH/RFC v2 1/4] Add a media device configuration file parser.
How do these 2 relate ?
Regards,
Hans
Hi Hans,
Quoted 9 lines · Hans de Goede
Hi Sakari,
Quoted 5 lines · Sakari Ailus
Hi,
This is a tiny library for parsing text-based media link, V4L2 sub-device format (and selection) configurations as well as controls with limited types.
Quoted 5 lines
Hmm, we also have:
[PATCH/RFC v2 1/4] Add a media device configuration file parser.
How do these 2 relate ?
Jacek is working on a Samsung Exynos libv4l2 plugin, a part of which is not specific to that plugin itself, and thus should be elsewhere (libmediactl, for instance). I didn't know about that effort, and having written something close to that in the past but without finishing it, I posted mine here as well.
The common subset of functionality is limited to parsing text based link configurations. Most of that is really implemented in libmediactl.
Signature · 4 lines
Kind regards, Sakari Ailus [email protected]
Hi,
Quoted 14 lines · Sakari Ailus
Hi Hans,
Quoted 11 lines · Hans de Goede
Hi Sakari,
Quoted 5 lines · Sakari Ailus
Hi,
This is a tiny library for parsing text-based media link, V4L2 sub-device format (and selection) configurations as well as controls with limited types.
Hmm, we also have:
Quoted 7 lines
Quoted 3 lines
[PATCH/RFC v2 1/4] Add a media device configuration file parser.
How do these 2 relate ?
Jacek is working on a Samsung Exynos libv4l2 plugin, a part of which is not specific to that plugin itself, and thus should be elsewhere (libmediactl, for instance). I didn't know about that effort, and having written something close to that in the past but without finishing it, I posted mine here as well.
The common subset of functionality is limited to parsing text based link configurations. Most of that is really implemented in libmediactl.
Hmm, I guess we need to sort this out then before merging Jacek's plugin.
Jacek, have you looked into using (and if necessary extending) libmediactl inside your plugin ?
Regards,
Hans
Hi Hans, Sakari,
Quoted 21 lines · Hans de Goede
Hi,
Quoted 18 lines · Sakari Ailus
Hi Hans,
Quoted 14 lines · Hans de Goede
Hi Sakari,
Quoted 5 lines · Sakari Ailus
Hi,
This is a tiny library for parsing text-based media link, V4L2 sub-device format (and selection) configurations as well as controls with limited types.
Hmm, we also have:
[PATCH/RFC v2 1/4] Add a media device configuration file parser.
How do these 2 relate ?
Quoted 8 lines
Quoted 3 lines
Jacek is working on a Samsung Exynos libv4l2 plugin, a part of which is not specific to that plugin itself, and thus should be elsewhere (libmediactl, for instance). I didn't know about that effort, and having written something close to that in the past but without finishing it, I posted mine here as well.
The common subset of functionality is limited to parsing text based link configurations. Most of that is really implemented in libmediactl.
Hmm, I guess we need to sort this out then before merging Jacek's plugin.
Jacek, have you looked into using (and if necessary extending) libmediactl inside your plugin ?
Not yet, temporarily I had to switch to different task, but I will look into libmediactl soon to figure out how to use its API in my plugin and what parts of my code could be added to it.
Best Regards,
Jacek Anaszewski
Hi,
Quoted 28 lines · Jacek Anaszewski
Hi Hans, Sakari,
Quoted 25 lines · Hans de Goede
Hi,
Quoted 21 lines · Sakari Ailus
Hi Hans,
Quoted 9 lines · Hans de Goede
Hi Sakari,
Quoted 5 lines · Sakari Ailus
Hi,
This is a tiny library for parsing text-based media link, V4L2 sub-device format (and selection) configurations as well as controls with limited types.
Quoted 5 lines
Hmm, we also have:
[PATCH/RFC v2 1/4] Add a media device configuration file parser.
How do these 2 relate ?
Jacek is working on a Samsung Exynos libv4l2 plugin, a part of which is not specific to that plugin itself, and thus should be elsewhere (libmediactl, for instance). I didn't know about that effort, and having written something close to that in the past but without finishing it, I posted mine here as well.
The common subset of functionality is limited to parsing text based link configurations. Most of that is really implemented in libmediactl.
Quoted 8 lines
Quoted 4 lines
Hmm, I guess we need to sort this out then before merging Jacek's plugin.
Jacek, have you looked into using (and if necessary extending) libmediactl inside your plugin ?
Not yet, temporarily I had to switch to different task, but I will look into libmediactl soon to figure out how to use its API in my plugin and what parts of my code could be added to it.
Great, I think it is best to wait with merging your plugin to this is sorted out. Once that is sorted out I think we should be able to merge it relatively quickly.
Maybe we should merge libmediactl into v4l-utils then ? Rather then v4l-utils growing an external dependency on it. Sakari ?
Regards,
Hans
Hi Hans,
Quoted 2 lines · Hans de Goede
Maybe we should merge libmediactl into v4l-utils then ? Rather then v4l-utils growing an external dependency on it. Sakari ?
libmediactl is already a part of v4l-utils, but it's under utils rather than lib directory. Cc Laurent.
Signature · 4 lines
Kind regards, Sakari Ailus [email protected]
Quoted 8 lines · On Thursday 23 October 2014 12:40:12 Sakari Ailus wrote:
Hi Hans,
Quoted 2 lines · Hans de Goede
Maybe we should merge libmediactl into v4l-utils then ? Rather then v4l-utils growing an external dependency on it. Sakari ?
libmediactl is already a part of v4l-utils, but it's under utils rather than lib directory. Cc Laurent.
I'm fine with moving the libraries to lib, but I'm still not 100% sure the ABI can be considered stable.
Signature · 3 lines
Regards, Laurent Pinchart
Hi,
Quoted 9 lines · Laurent Pinchart
Quoted 8 lines · On Thursday 23 October 2014 12:40:12 Sakari Ailus wrote:
Hi Hans,
Quoted 2 lines · Hans de Goede
Maybe we should merge libmediactl into v4l-utils then ? Rather then v4l-utils growing an external dependency on it. Sakari ?
libmediactl is already a part of v4l-utils, but it's under utils rather than lib directory. Cc Laurent.
Ah.
Quoted 2 lines
I'm fine with moving the libraries to lib, but I'm still not 100% sure the ABI can be considered stable.
As long as the ABI is not stable lets keep it in utils and statically link it into the plugin Jacek is working on for now.
Regards,
Hans