linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Jacek Anaszewski <j.anaszewski@samsung.com>, linux-media@vger.kernel.org
Cc: laurent.pinchart@ideasonboard.com, gjasny@googlemail.com,
	hdegoede@redhat.com, hverkuil@xs4all.nl
Subject: Re: [PATCH 05/15] mediactl: Add media device graph helpers
Date: Mon, 15 Feb 2016 14:02:02 +0200	[thread overview]
Message-ID: <56C1BE3A.2090603@linux.intel.com> (raw)
In-Reply-To: <1453133860-21571-6-git-send-email-j.anaszewski@samsung.com>

Hi Jacek,

Jacek Anaszewski wrote:
> Add new graph helpers useful for video pipeline discovering.
> 
> Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
> Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
>  utils/media-ctl/libmediactl.c |   48 +++++++++++++++++++++++++++++++++++++++++
>  utils/media-ctl/mediactl.h    |   36 +++++++++++++++++++++++++++++++
>  2 files changed, 84 insertions(+)
> 
> diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c
> index 61b5f50..0be1845 100644
> --- a/utils/media-ctl/libmediactl.c
> +++ b/utils/media-ctl/libmediactl.c
> @@ -35,6 +35,7 @@
>  #include <unistd.h>
>  
>  #include <linux/media.h>
> +#include <linux/kdev_t.h>
>  #include <linux/videodev2.h>
>  
>  #include "mediactl.h"
> @@ -87,6 +88,29 @@ struct media_entity *media_get_entity_by_name(struct media_device *media,
>  	return NULL;
>  }
>  
> +struct media_entity *media_get_entity_by_devname(struct media_device *media,
> +						 const char *devname,
> +						 size_t length)
> +{
> +	unsigned int i;
> +
> +	/* A match is impossible if the entity devname is longer than the
> +	 * maximum size we can get from the kernel.
> +	 */
> +	if (length >= FIELD_SIZEOF(struct media_entity, devname))
> +		return NULL;
> +
> +	for (i = 0; i < media->entities_count; ++i) {
> +		struct media_entity *entity = &media->entities[i];
> +
> +		if (strncmp(entity->devname, devname, length) == 0 &&
> +		    entity->devname[length] == '\0')
> +			return entity;
> +	}
> +
> +	return NULL;
> +}

Just out of curiosity: where do you need this? I.e. why do you need to
translate a device name to an entity?

> +
>  struct media_entity *media_get_entity_by_id(struct media_device *media,
>  					    __u32 id)
>  {
> @@ -145,6 +169,11 @@ const char *media_entity_get_devname(struct media_entity *entity)
>  	return entity->devname[0] ? entity->devname : NULL;
>  }
>  
> +const char *media_entity_get_name(struct media_entity *entity)
> +{
> +	return entity->info.name;
> +}

You should instead use media_get_info()->name . If you have an entity,
the return value will be valid.

> +
>  struct media_entity *media_get_default_entity(struct media_device *media,
>  					      unsigned int type)
>  {
> @@ -177,6 +206,25 @@ const struct media_entity_desc *media_entity_get_info(struct media_entity *entit
>  	return &entity->info;
>  }
>  
> +int media_get_backlinks_by_entity(struct media_entity *entity,

How about calling this media_entity_get_backlinks()?

> +				struct media_link **backlinks,
> +				int *num_backlinks)

unsigned int.

> +{
> +	int num_bklinks = 0, i;

Same here.

> +
> +	if (entity == NULL || backlinks == NULL || num_backlinks == NULL)
> +		return -EINVAL;
> +
> +	for (i = 0; i < entity->num_links; ++i)
> +		if ((entity->links[i].flags & MEDIA_LNK_FL_ENABLED) &&
> +		    (entity->links[i].sink->entity == entity))
> +			backlinks[num_bklinks++] = &entity->links[i];
> +
> +	*num_backlinks = num_bklinks;
> +
> +	return 0;
> +}
> +
>  /* -----------------------------------------------------------------------------
>   * Open/close
>   */
> diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h
> index 3faee71..9db40a8 100644
> --- a/utils/media-ctl/mediactl.h
> +++ b/utils/media-ctl/mediactl.h
> @@ -231,6 +231,15 @@ const struct media_link *media_entity_get_link(struct media_entity *entity,
>  const char *media_entity_get_devname(struct media_entity *entity);
>  
>  /**
> + * @brief Get the name for an entity
> + * @param entity - media entity.
> + *
> + * This function returns the name of the entity.
> + *
> + * @return A pointer to the string with entity name
> + */
> +const char *media_entity_get_name(struct media_entity *entity);
> +
>   * @brief Get the type of an entity.
>   * @param entity - the entity.
>   *
> @@ -255,6 +264,19 @@ struct media_entity *media_get_entity_by_name(struct media_device *media,
>  	const char *name, size_t length);
>  
>  /**
> + * @brief Find an entity by the corresponding device node name.
> + * @param media - media device.
> + * @param devname - device node name.
> + * @param length - size of @a devname.
> + *
> + * Search for an entity with a device node name equal to @a devname.
> + *
> + * @return A pointer to the entity if found, or NULL otherwise.
> + */
> +struct media_entity *media_get_entity_by_devname(struct media_device *media,
> +	const char *devname, size_t length);
> +
> +/**
>   * @brief Find an entity by its ID.
>   * @param media - media device.
>   * @param id - entity ID.
> @@ -434,4 +456,18 @@ int media_parse_setup_link(struct media_device *media,
>   */
>  int media_parse_setup_links(struct media_device *media, const char *p);
>  
> +/**
> + * @brief Get entity's enabled backlinks
> + * @param entity - media entity.
> + * @param backlinks - array of pointers to matching backlinks.
> + * @param num_backlinks - number of matching backlinks.
> + *
> + * Get links that are connected to the entity sink pads.
> + *
> + * @return 0 on success, or a negative error code on failure.
> + */
> +int media_get_backlinks_by_entity(struct media_entity *entity,
> +				struct media_link **backlinks,
> +				int *num_backlinks);
> +
>  #endif
> 


-- 
Kind regards,

Sakari Ailus
sakari.ailus@linux.intel.com

  reply	other threads:[~2016-02-15 12:02 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-18 16:17 [PATCH 00/15] Add a plugin for Exynos4 camera Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 01/15] mediactl: Introduce v4l2_subdev structure Jacek Anaszewski
2016-02-12 12:42   ` Sakari Ailus
2016-02-18 14:15     ` Jacek Anaszewski
2016-03-20 23:39       ` Sakari Ailus
2016-03-22  9:26         ` Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 02/15] mediactl: Add support for v4l2-ctrl-redir config Jacek Anaszewski
2016-02-15 10:58   ` Sakari Ailus
2016-02-15 11:39     ` Jacek Anaszewski
2016-02-15 12:22       ` Sakari Ailus
2016-01-18 16:17 ` [PATCH 03/15] mediactl: Separate entity and pad parsing Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 04/15] mediatext: Add library Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 05/15] mediactl: Add media device graph helpers Jacek Anaszewski
2016-02-15 12:02   ` Sakari Ailus [this message]
2016-02-15 12:45     ` Jacek Anaszewski
2016-02-15 14:14       ` Sakari Ailus
2016-02-15 14:57         ` Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 06/15] mediactl: Add media_device creation helpers Jacek Anaszewski
2016-02-15 14:30   ` Sakari Ailus
2016-01-18 16:17 ` [PATCH 07/15] mediactl: libv4l2subdev: add VYUY8_2X8 mbus code Jacek Anaszewski
2016-02-15 15:55   ` Sakari Ailus
2016-01-18 16:17 ` [PATCH 08/15] mediactl: Add support for media device pipelines Jacek Anaszewski
2016-02-15 16:53   ` Sakari Ailus
2016-02-16  9:19     ` Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 09/15] mediactl: libv4l2subdev: Add colorspace logging Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 10/15] mediactl: libv4l2subdev: add support for comparing mbus formats Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 11/15] mediactl: libv4l2subdev: add support for setting pipeline format Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 12/15] mediactl: libv4l2subdev: add get_pipeline_entity_by_cid function Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 13/15] mediactl: Add media device ioctl API Jacek Anaszewski
2016-02-15 12:41   ` Sakari Ailus
2016-02-15 13:06     ` Jacek Anaszewski
2016-02-18 12:09       ` Sakari Ailus
2016-02-18 13:14         ` Jacek Anaszewski
2016-03-21  0:07           ` Sakari Ailus
2016-03-22  9:36             ` Jacek Anaszewski
2016-03-23 16:24               ` Sakari Ailus
2016-03-24 15:55                 ` Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 14/15] mediactl: libv4l2subdev: Enable opening/closing pipelines Jacek Anaszewski
2016-01-18 16:17 ` [PATCH 15/15] Add a libv4l plugin for Exynos4 camera Jacek Anaszewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56C1BE3A.2090603@linux.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=gjasny@googlemail.com \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil@xs4all.nl \
    --cc=j.anaszewski@samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).