summaryrefslogtreecommitdiff
path: root/drivers/media/video/uvc/uvc_entity.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2010-01-21 14:56:19 +0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-05-26 02:51:09 +0400
commit8a65a9485832f90e18e2f7069b75a4181e2840c0 (patch)
tree151551e14937c7b1a2d28e738eed3ee154486497 /drivers/media/video/uvc/uvc_entity.c
parent4ffc2d89f38a7fbb3b24adb7fb066a159c351c11 (diff)
downloadlinux-8a65a9485832f90e18e2f7069b75a4181e2840c0.tar.xz
[media] uvcvideo: Connect video devices to media entities
The video devices associated to USB streaming terminals must be connected to their associated terminal's media entity instead of being standalone entities. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/uvc/uvc_entity.c')
-rw-r--r--drivers/media/video/uvc/uvc_entity.c40
1 files changed, 32 insertions, 8 deletions
diff --git a/drivers/media/video/uvc/uvc_entity.c b/drivers/media/video/uvc/uvc_entity.c
index 8e8e7efb4608..ede7852bb1df 100644
--- a/drivers/media/video/uvc/uvc_entity.c
+++ b/drivers/media/video/uvc/uvc_entity.c
@@ -33,6 +33,9 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain,
int ret;
for (i = 0; i < entity->num_pads; ++i) {
+ struct media_entity *source;
+ struct media_entity *sink;
+
if (!(entity->pads[i].flags & MEDIA_PAD_FL_SINK))
continue;
@@ -40,14 +43,23 @@ static int uvc_mc_register_entity(struct uvc_video_chain *chain,
if (remote == NULL)
return -EINVAL;
+ source = (UVC_ENTITY_TYPE(remote) == UVC_TT_STREAMING)
+ ? &remote->vdev->entity : &remote->subdev.entity;
+ sink = (UVC_ENTITY_TYPE(entity) == UVC_TT_STREAMING)
+ ? &entity->vdev->entity : &entity->subdev.entity;
+
remote_pad = remote->num_pads - 1;
- ret = media_entity_create_link(&remote->subdev.entity,
- remote_pad, &entity->subdev.entity, i, flags);
+ ret = media_entity_create_link(source, remote_pad,
+ sink, i, flags);
if (ret < 0)
return ret;
}
- return v4l2_device_register_subdev(&chain->dev->vdev, &entity->subdev);
+ if (UVC_ENTITY_TYPE(entity) != UVC_TT_STREAMING)
+ ret = v4l2_device_register_subdev(&chain->dev->vdev,
+ &entity->subdev);
+
+ return ret;
}
static struct v4l2_subdev_ops uvc_subdev_ops = {
@@ -55,16 +67,28 @@ static struct v4l2_subdev_ops uvc_subdev_ops = {
void uvc_mc_cleanup_entity(struct uvc_entity *entity)
{
- media_entity_cleanup(&entity->subdev.entity);
+ if (UVC_ENTITY_TYPE(entity) != UVC_TT_STREAMING)
+ media_entity_cleanup(&entity->subdev.entity);
+ else if (entity->vdev != NULL)
+ media_entity_cleanup(&entity->vdev->entity);
}
static int uvc_mc_init_entity(struct uvc_entity *entity)
{
- v4l2_subdev_init(&entity->subdev, &uvc_subdev_ops);
- strlcpy(entity->subdev.name, entity->name, sizeof(entity->subdev.name));
+ int ret;
+
+ if (UVC_ENTITY_TYPE(entity) != UVC_TT_STREAMING) {
+ v4l2_subdev_init(&entity->subdev, &uvc_subdev_ops);
+ strlcpy(entity->subdev.name, entity->name,
+ sizeof(entity->subdev.name));
+
+ ret = media_entity_init(&entity->subdev.entity,
+ entity->num_pads, entity->pads, 0);
+ } else
+ ret = media_entity_init(&entity->vdev->entity,
+ entity->num_pads, entity->pads, 0);
- return media_entity_init(&entity->subdev.entity, entity->num_pads,
- entity->pads, 0);
+ return ret;
}
int uvc_mc_register_entities(struct uvc_video_chain *chain)