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 /Documentation/video4linux | |
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 'Documentation/video4linux')
-rw-r--r-- | Documentation/video4linux/v4l2-framework.txt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index 062708169def..77d96f4e3f50 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt | |||
@@ -268,6 +268,26 @@ A sub-device driver initializes the v4l2_subdev struct using: | |||
268 | Afterwards you need to initialize subdev->name with a unique name and set the | 268 | Afterwards you need to initialize subdev->name with a unique name and set the |
269 | module owner. This is done for you if you use the i2c helper functions. | 269 | module owner. This is done for you if you use the i2c helper functions. |
270 | 270 | ||
271 | If integration with the media framework is needed, you must initialize the | ||
272 | media_entity struct embedded in the v4l2_subdev struct (entity field) by | ||
273 | calling media_entity_init(): | ||
274 | |||
275 | struct media_pad *pads = &my_sd->pads; | ||
276 | int err; | ||
277 | |||
278 | err = media_entity_init(&sd->entity, npads, pads, 0); | ||
279 | |||
280 | The pads array must have been previously initialized. There is no need to | ||
281 | manually set the struct media_entity type and name fields, but the revision | ||
282 | field must be initialized if needed. | ||
283 | |||
284 | A reference to the entity will be automatically acquired/released when the | ||
285 | subdev device node (if any) is opened/closed. | ||
286 | |||
287 | Don't forget to cleanup the media entity before the sub-device is destroyed: | ||
288 | |||
289 | media_entity_cleanup(&sd->entity); | ||
290 | |||
271 | A device (bridge) driver needs to register the v4l2_subdev with the | 291 | A device (bridge) driver needs to register the v4l2_subdev with the |
272 | v4l2_device: | 292 | v4l2_device: |
273 | 293 | ||
@@ -277,6 +297,9 @@ This can fail if the subdev module disappeared before it could be registered. | |||
277 | After this function was called successfully the subdev->dev field points to | 297 | After this function was called successfully the subdev->dev field points to |
278 | the v4l2_device. | 298 | the v4l2_device. |
279 | 299 | ||
300 | If the v4l2_device parent device has a non-NULL mdev field, the sub-device | ||
301 | entity will be automatically registered with the media device. | ||
302 | |||
280 | You can unregister a sub-device using: | 303 | You can unregister a sub-device using: |
281 | 304 | ||
282 | v4l2_device_unregister_subdev(sd); | 305 | v4l2_device_unregister_subdev(sd); |