[media] v4l: Make video_device inherit from media_entity

V4L2 devices are media entities. As such they need to inherit from
(include) the media_entity structure.

When registering/unregistering the device, 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>
This commit is contained in:
Laurent Pinchart 2009-12-09 08:40:10 -03:00 committed by Mauro Carvalho Chehab
parent 95db3a60e0
commit 2c0ab67be1
3 changed files with 87 additions and 7 deletions

View file

@ -16,6 +16,8 @@
#include <linux/mutex.h>
#include <linux/videodev2.h>
#include <media/media-entity.h>
#define VIDEO_MAJOR 81
#define VFL_TYPE_GRABBER 0
@ -55,6 +57,9 @@ struct v4l2_file_operations {
struct video_device
{
#if defined(CONFIG_MEDIA_CONTROLLER)
struct media_entity entity;
#endif
/* device ops */
const struct v4l2_file_operations *fops;
@ -100,6 +105,8 @@ struct video_device
struct mutex *lock;
};
#define media_entity_to_video_device(entity) \
container_of(entity, struct video_device, entity)
/* dev to video-device */
#define to_video_device(cd) container_of(cd, struct video_device, dev)