[media] uvcvideo: Mark first output terminal as default video node
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 3 Aug 2012 07:35:10 +0000 (04:35 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 28 Nov 2012 12:30:00 +0000 (10:30 -0200)
The MEDIA_ENT_FL_DEFAULT identifies entities that are considered as
default for their group and type. For video nodes, it identifies the
node that application should use by default.
UVC devices don't report which output terminal should be considered as
the default, use the first one. Most devices have a single output
terminal anyway.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/usb/uvc/uvc_driver.c
drivers/media/usb/uvc/uvc_entity.c
drivers/media/usb/uvc/uvcvideo.h

index 22f14d286fbbe625384334516febbab4e077c996..5dbefa68b1d20f0e0ca14fd725b99aafb9410fcd 100644 (file)
@@ -1564,6 +1564,8 @@ static int uvc_scan_device(struct uvc_device *dev)
                chain->dev = dev;
                v4l2_prio_init(&chain->prio);
 
+               term->flags |= UVC_ENTITY_FLAG_DEFAULT;
+
                if (uvc_scan_chain(chain, term) < 0) {
                        kfree(chain);
                        continue;
index 29e239911d0e28a6d7a688ab5907781ffa1b41d0..dc56a59ecadc4b5dc2185a9717256eec96ba17c0 100644 (file)
@@ -93,6 +93,8 @@ static int uvc_mc_init_entity(struct uvc_entity *entity)
        } else if (entity->vdev != NULL) {
                ret = media_entity_init(&entity->vdev->entity,
                                        entity->num_pads, entity->pads, 0);
+               if (entity->flags & UVC_ENTITY_FLAG_DEFAULT)
+                       entity->vdev->entity.flags |= MEDIA_ENT_FL_DEFAULT;
        } else
                ret = 0;
 
index 006ae274d22ef14155c98c11bf8ac2a335cb2024..af505fdd9b3f73d581665f660cf622921bea64c2 100644 (file)
@@ -225,10 +225,14 @@ struct uvc_format_desc {
  * always be accessed with the UVC_ENTITY_* macros and never directly.
  */
 
+#define UVC_ENTITY_FLAG_DEFAULT                (1 << 0)
+
 struct uvc_entity {
        struct list_head list;          /* Entity as part of a UVC device. */
        struct list_head chain;         /* Entity as part of a video device
                                         * chain. */
+       unsigned int flags;
+
        __u8 id;
        __u16 type;
        char name[64];