All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
To: Sakari Ailus <sakari.ailus@iki.fi>
Cc: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com,
	javier@osg.samsung.com, hverkuil@xs4all.nl,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Subject: Re: [PATCH 02/19] media: Introduce internal index for media entities
Date: Wed, 28 Oct 2015 09:20:20 +0900	[thread overview]
Message-ID: <20151028092020.33a1e509@concha.lan> (raw)
In-Reply-To: <1445900510-1398-3-git-send-email-sakari.ailus@iki.fi>

Em Tue, 27 Oct 2015 01:01:33 +0200
Sakari Ailus <sakari.ailus@iki.fi> escreveu:

> From: Sakari Ailus <sakari.ailus@linux.intel.com>
> 
> The internal index can be used internally by the framework in order to keep
> track of entities for a purpose or another. The internal index is constant
> while it's registered to a media device, but the same index may be re-used
> once the entity having that index is unregistered.

Reviewed-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/media/media-device.c | 17 +++++++++++++++++
>  include/media/media-device.h |  4 ++++
>  include/media/media-entity.h |  3 +++
>  3 files changed, 24 insertions(+)
> 
> diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
> index c181758..ebb84cb 100644
> --- a/drivers/media/media-device.c
> +++ b/drivers/media/media-device.c
> @@ -22,6 +22,7 @@
>  
>  #include <linux/compat.h>
>  #include <linux/export.h>
> +#include <linux/idr.h>
>  #include <linux/ioctl.h>
>  #include <linux/media.h>
>  #include <linux/types.h>
> @@ -546,6 +547,7 @@ void media_device_init(struct media_device *mdev)
>  	INIT_LIST_HEAD(&mdev->links);
>  	spin_lock_init(&mdev->lock);
>  	mutex_init(&mdev->graph_mutex);
> +	ida_init(&mdev->entity_internal_idx);
>  
>  	dev_dbg(mdev->dev, "Media device initialized\n");
>  }
> @@ -558,6 +560,8 @@ EXPORT_SYMBOL_GPL(media_device_init);
>   */
>  void media_device_cleanup(struct media_device *mdev)
>  {
> +	ida_destroy(&mdev->entity_internal_idx);
> +	mdev->entity_internal_idx_max = 0;
>  	mutex_destroy(&mdev->graph_mutex);
>  }
>  EXPORT_SYMBOL_GPL(media_device_cleanup);
> @@ -658,6 +662,17 @@ int __must_check media_device_register_entity(struct media_device *mdev,
>  	INIT_LIST_HEAD(&entity->links);
>  
>  	spin_lock(&mdev->lock);
> +
> +	entity->internal_idx = ida_simple_get(&mdev->entity_internal_idx, 1, 0,
> +					      GFP_KERNEL);
> +	if (entity->internal_idx < 0) {
> +		spin_unlock(&mdev->lock);
> +		return entity->internal_idx;
> +	}
> +
> +	mdev->entity_internal_idx_max =
> +		max(mdev->entity_internal_idx_max, entity->internal_idx);
> +
>  	/* Initialize media_gobj embedded at the entity */
>  	media_gobj_init(mdev, MEDIA_GRAPH_ENTITY, &entity->graph_obj);
>  
> @@ -690,6 +705,8 @@ void media_device_unregister_entity(struct media_entity *entity)
>  
>  	spin_lock(&mdev->lock);
>  
> +	ida_simple_remove(&mdev->entity_internal_idx, entity->internal_idx);
> +
>  	/* Remove interface links with this entity on it */
>  	list_for_each_entry_safe(link, tmp, &mdev->links, graph_obj.list) {
>  		if (media_type(link->gobj1) == MEDIA_GRAPH_ENTITY
> diff --git a/include/media/media-device.h b/include/media/media-device.h
> index a2c7570..c0e1764 100644
> --- a/include/media/media-device.h
> +++ b/include/media/media-device.h
> @@ -30,6 +30,7 @@
>  #include <media/media-devnode.h>
>  #include <media/media-entity.h>
>  
> +struct ida;
>  struct device;
>  
>  /**
> @@ -47,6 +48,7 @@ struct device;
>   * @pad_id:	Unique ID used on the last pad registered
>   * @link_id:	Unique ID used on the last link registered
>   * @intf_devnode_id: Unique ID used on the last interface devnode registered
> + * @entity_internal_idx: Allocated internal entity indices
>   * @entities:	List of registered entities
>   * @interfaces:	List of registered interfaces
>   * @pads:	List of registered pads
> @@ -82,6 +84,8 @@ struct media_device {
>  	u32 pad_id;
>  	u32 link_id;
>  	u32 intf_devnode_id;
> +	struct ida entity_internal_idx;
> +	int entity_internal_idx_max;
>  
>  	struct list_head entities;
>  	struct list_head interfaces;
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index eebdd24..d3d3a39 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -159,6 +159,8 @@ struct media_entity_operations {
>   * @num_pads:	Number of sink and source pads.
>   * @num_links:	Number of existing links, both enabled and disabled.
>   * @num_backlinks: Number of backlinks
> + * @internal_idx: An unique internal entity specific number. The numbers are
> + *		re-used if entities are unregistered or registered again.
>   * @pads:	Pads array with the size defined by @num_pads.
>   * @links:	Linked list for the data links.
>   * @ops:	Entity operations.
> @@ -187,6 +189,7 @@ struct media_entity {
>  	u16 num_pads;
>  	u16 num_links;
>  	u16 num_backlinks;
> +	int internal_idx;
>  
>  	struct media_pad *pads;
>  	struct list_head links;


-- 

Cheers,
Mauro

  reply	other threads:[~2015-10-28  0:20 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-26 23:01 [PATCH 00/19] Unrestricted media entity ID range support Sakari Ailus
2015-10-26 23:01 ` [PATCH 01/19] media: Enforce single entity->pipe in a pipeline Sakari Ailus
2015-10-28  0:18   ` Mauro Carvalho Chehab
2015-10-26 23:01 ` [PATCH 02/19] media: Introduce internal index for media entities Sakari Ailus
2015-10-28  0:20   ` Mauro Carvalho Chehab [this message]
2015-10-26 23:01 ` [PATCH 03/19] media: Add an API to manage entity enumerations Sakari Ailus
2015-10-28  2:09   ` Mauro Carvalho Chehab
2015-11-03 22:21     ` Sakari Ailus
2015-10-26 23:01 ` [PATCH 04/19] media: Move struct media_entity_graph definition up Sakari Ailus
2015-10-28  0:36   ` Mauro Carvalho Chehab
2015-11-03 22:22     ` Sakari Ailus
2015-11-29 13:07       ` Sakari Ailus
2015-10-26 23:01 ` [PATCH 05/19] media: Move media graph state for streamon/off to the pipeline Sakari Ailus
2015-10-28  0:38   ` Mauro Carvalho Chehab
2015-11-03 22:23     ` Sakari Ailus
2015-10-26 23:01 ` [PATCH 06/19] media: Amend media graph walk API by init and cleanup functions Sakari Ailus
2015-10-28  2:09   ` Mauro Carvalho Chehab
2015-10-26 23:01 ` [PATCH 07/19] media: Use the new media_entity_graph_walk_start() Sakari Ailus
2015-10-28  0:43   ` Mauro Carvalho Chehab
2015-11-03 22:42     ` Sakari Ailus
2015-10-26 23:01 ` [PATCH 08/19] v4l: omap3isp: Use the new media_entity_graph_walk_start() interface Sakari Ailus
2015-10-26 23:01 ` [PATCH 09/19] v4l: exynos4-is: " Sakari Ailus
2015-10-26 23:01 ` [PATCH 10/19] v4l: xilinx: " Sakari Ailus
2015-10-26 23:01 ` [PATCH 11/19] v4l: vsp1: " Sakari Ailus
2015-10-26 23:01 ` [PATCH 12/19] media: Use entity enums in graph walk Sakari Ailus
2015-10-28  0:48   ` Mauro Carvalho Chehab
2015-10-26 23:01 ` [PATCH 13/19] media: Keep using the same graph walk object for a given pipeline Sakari Ailus
2015-10-28  0:51   ` Mauro Carvalho Chehab
2015-10-26 23:01 ` [PATCH 14/19] v4l: omap3isp: Use media entity enumeration API Sakari Ailus
2015-10-28  1:30   ` Mauro Carvalho Chehab
2015-11-03 22:44     ` Sakari Ailus
2015-10-26 23:01 ` [PATCH 15/19] v4l: vsp1: " Sakari Ailus
2015-10-28  1:33   ` Mauro Carvalho Chehab
2015-10-26 23:01 ` [PATCH 16/19] staging: omap4iss: Fix sub-device power management code Sakari Ailus
2015-10-28  1:59   ` Mauro Carvalho Chehab
2015-10-26 23:01 ` [PATCH 17/19] staging: v4l: omap4iss: Use media entity enum API Sakari Ailus
2015-10-28  2:01   ` Mauro Carvalho Chehab
2015-10-26 23:01 ` [PATCH 18/19] staging: v4l: omap4iss: Use the new media_entity_graph_walk_start() interface Sakari Ailus
2015-10-28  2:08   ` Mauro Carvalho Chehab
2015-10-26 23:01 ` [PATCH 19/19] media: Rename MEDIA_ENTITY_ENUM_MAX_ID as MEDIA_ENTITY_ENUM_STACK_ALLOC Sakari Ailus
2015-10-28  2:10   ` Mauro Carvalho Chehab

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=20151028092020.33a1e509@concha.lan \
    --to=mchehab@osg.samsung.com \
    --cc=hverkuil@xs4all.nl \
    --cc=javier@osg.samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@iki.fi \
    --cc=sakari.ailus@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.