diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2009-12-09 06:40:08 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-22 03:53:20 -0400 |
commit | 61f5db549dde43fb91a8b337f3a4096e4076c2d9 (patch) | |
tree | 0c28bb9dd1aab1b3fc8ce61036677a7790316421 /drivers/media/video/v4l2-device.c | |
parent | 2c0ab67be1b4197a4effac89bb0604832e38be8d (diff) |
[media] v4l: Make v4l2_subdev inherit from media_entity
V4L2 subdevices are media entities. As such they need to inherit from
(include) the media_entity structure.
When registering/unregistering the subdevice, the media entity is
automatically registered/unregistered. The entity is acquired on device
open and released on device close.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/v4l2-device.c')
-rw-r--r-- | drivers/media/video/v4l2-device.c | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c index cfbd8a38991d..a1afda352d08 100644 --- a/drivers/media/video/v4l2-device.c +++ b/drivers/media/video/v4l2-device.c | |||
@@ -118,8 +118,11 @@ void v4l2_device_unregister(struct v4l2_device *v4l2_dev) | |||
118 | EXPORT_SYMBOL_GPL(v4l2_device_unregister); | 118 | EXPORT_SYMBOL_GPL(v4l2_device_unregister); |
119 | 119 | ||
120 | int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, | 120 | int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, |
121 | struct v4l2_subdev *sd) | 121 | struct v4l2_subdev *sd) |
122 | { | 122 | { |
123 | #if defined(CONFIG_MEDIA_CONTROLLER) | ||
124 | struct media_entity *entity = &sd->entity; | ||
125 | #endif | ||
123 | int err; | 126 | int err; |
124 | 127 | ||
125 | /* Check for valid input */ | 128 | /* Check for valid input */ |
@@ -147,6 +150,19 @@ int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, | |||
147 | return err; | 150 | return err; |
148 | } | 151 | } |
149 | 152 | ||
153 | #if defined(CONFIG_MEDIA_CONTROLLER) | ||
154 | /* Register the entity. */ | ||
155 | if (v4l2_dev->mdev) { | ||
156 | err = media_device_register_entity(v4l2_dev->mdev, entity); | ||
157 | if (err < 0) { | ||
158 | if (sd->internal_ops && sd->internal_ops->unregistered) | ||
159 | sd->internal_ops->unregistered(sd); | ||
160 | module_put(sd->owner); | ||
161 | return err; | ||
162 | } | ||
163 | } | ||
164 | #endif | ||
165 | |||
150 | spin_lock(&v4l2_dev->lock); | 166 | spin_lock(&v4l2_dev->lock); |
151 | list_add_tail(&sd->list, &v4l2_dev->subdevs); | 167 | list_add_tail(&sd->list, &v4l2_dev->subdevs); |
152 | spin_unlock(&v4l2_dev->lock); | 168 | spin_unlock(&v4l2_dev->lock); |
@@ -177,25 +193,37 @@ int v4l2_device_register_subdev_nodes(struct v4l2_device *v4l2_dev) | |||
177 | sd->owner); | 193 | sd->owner); |
178 | if (err < 0) | 194 | if (err < 0) |
179 | return err; | 195 | return err; |
196 | #if defined(CONFIG_MEDIA_CONTROLLER) | ||
197 | sd->entity.v4l.major = VIDEO_MAJOR; | ||
198 | sd->entity.v4l.minor = vdev->minor; | ||
199 | #endif | ||
180 | } | 200 | } |
181 | |||
182 | return 0; | 201 | return 0; |
183 | } | 202 | } |
184 | EXPORT_SYMBOL_GPL(v4l2_device_register_subdev_nodes); | 203 | EXPORT_SYMBOL_GPL(v4l2_device_register_subdev_nodes); |
185 | 204 | ||
186 | void v4l2_device_unregister_subdev(struct v4l2_subdev *sd) | 205 | void v4l2_device_unregister_subdev(struct v4l2_subdev *sd) |
187 | { | 206 | { |
207 | struct v4l2_device *v4l2_dev; | ||
208 | |||
188 | /* return if it isn't registered */ | 209 | /* return if it isn't registered */ |
189 | if (sd == NULL || sd->v4l2_dev == NULL) | 210 | if (sd == NULL || sd->v4l2_dev == NULL) |
190 | return; | 211 | return; |
191 | 212 | ||
192 | spin_lock(&sd->v4l2_dev->lock); | 213 | v4l2_dev = sd->v4l2_dev; |
214 | |||
215 | spin_lock(&v4l2_dev->lock); | ||
193 | list_del(&sd->list); | 216 | list_del(&sd->list); |
194 | spin_unlock(&sd->v4l2_dev->lock); | 217 | spin_unlock(&v4l2_dev->lock); |
218 | |||
195 | if (sd->internal_ops && sd->internal_ops->unregistered) | 219 | if (sd->internal_ops && sd->internal_ops->unregistered) |
196 | sd->internal_ops->unregistered(sd); | 220 | sd->internal_ops->unregistered(sd); |
197 | sd->v4l2_dev = NULL; | 221 | sd->v4l2_dev = NULL; |
198 | 222 | ||
223 | #if defined(CONFIG_MEDIA_CONTROLLER) | ||
224 | if (v4l2_dev->mdev) | ||
225 | media_device_unregister_entity(&sd->entity); | ||
226 | #endif | ||
199 | video_unregister_device(&sd->devnode); | 227 | video_unregister_device(&sd->devnode); |
200 | module_put(sd->owner); | 228 | module_put(sd->owner); |
201 | } | 229 | } |