diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2010-03-07 13:04:59 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-22 03:53:12 -0400 |
commit | 503c3d829eaf48837dd5bff5d97ad66369bb955a (patch) | |
tree | 9c14ed9561c5ffca07909e53d5ae0e52cdf5f99e /include | |
parent | a5ccc48a7c48610e7f92fa599406738d69195d51 (diff) |
[media] media: Entity use count
Due to the wide differences between drivers regarding power management
needs, the media controller does not implement power management.
However, the media_entity structure includes a use_count field that
media drivers can use to track the number of users of every entity for
power management needs.
The use_count field is owned by media drivers and must not be touched by
entity drivers. Access to the field must be protected by the media
device graph_mutex lock.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/media/media-device.h | 4 | ||||
-rw-r--r-- | include/media/media-entity.h | 9 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/media/media-device.h b/include/media/media-device.h index a8390fe87e83..5d2bff4fc9e0 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <linux/device.h> | 26 | #include <linux/device.h> |
27 | #include <linux/list.h> | 27 | #include <linux/list.h> |
28 | #include <linux/mutex.h> | ||
28 | #include <linux/spinlock.h> | 29 | #include <linux/spinlock.h> |
29 | 30 | ||
30 | #include <media/media-devnode.h> | 31 | #include <media/media-devnode.h> |
@@ -42,6 +43,7 @@ | |||
42 | * @entity_id: ID of the next entity to be registered | 43 | * @entity_id: ID of the next entity to be registered |
43 | * @entities: List of registered entities | 44 | * @entities: List of registered entities |
44 | * @lock: Entities list lock | 45 | * @lock: Entities list lock |
46 | * @graph_mutex: Entities graph operation lock | ||
45 | * | 47 | * |
46 | * This structure represents an abstract high-level media device. It allows easy | 48 | * This structure represents an abstract high-level media device. It allows easy |
47 | * access to entities and provides basic media device-level support. The | 49 | * access to entities and provides basic media device-level support. The |
@@ -69,6 +71,8 @@ struct media_device { | |||
69 | 71 | ||
70 | /* Protects the entities list */ | 72 | /* Protects the entities list */ |
71 | spinlock_t lock; | 73 | spinlock_t lock; |
74 | /* Serializes graph operations. */ | ||
75 | struct mutex graph_mutex; | ||
72 | }; | 76 | }; |
73 | 77 | ||
74 | /* media_devnode to media_device */ | 78 | /* media_devnode to media_device */ |
diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 28f61f6ee549..a9b31d98e3c6 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h | |||
@@ -81,6 +81,12 @@ struct media_entity { | |||
81 | struct media_pad *pads; /* Pads array (num_pads elements) */ | 81 | struct media_pad *pads; /* Pads array (num_pads elements) */ |
82 | struct media_link *links; /* Links array (max_links elements)*/ | 82 | struct media_link *links; /* Links array (max_links elements)*/ |
83 | 83 | ||
84 | /* Reference counts must never be negative, but are signed integers on | ||
85 | * purpose: a simple WARN_ON(<0) check can be used to detect reference | ||
86 | * count bugs that would make them negative. | ||
87 | */ | ||
88 | int use_count; /* Use count for the entity. */ | ||
89 | |||
84 | union { | 90 | union { |
85 | /* Node specifications */ | 91 | /* Node specifications */ |
86 | struct { | 92 | struct { |
@@ -129,6 +135,9 @@ void media_entity_cleanup(struct media_entity *entity); | |||
129 | int media_entity_create_link(struct media_entity *source, u16 source_pad, | 135 | int media_entity_create_link(struct media_entity *source, u16 source_pad, |
130 | struct media_entity *sink, u16 sink_pad, u32 flags); | 136 | struct media_entity *sink, u16 sink_pad, u32 flags); |
131 | 137 | ||
138 | struct media_entity *media_entity_get(struct media_entity *entity); | ||
139 | void media_entity_put(struct media_entity *entity); | ||
140 | |||
132 | void media_entity_graph_walk_start(struct media_entity_graph *graph, | 141 | void media_entity_graph_walk_start(struct media_entity_graph *graph, |
133 | struct media_entity *entity); | 142 | struct media_entity *entity); |
134 | struct media_entity * | 143 | struct media_entity * |