From patchwork Thu Sep 27 14:57:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1514681 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 0949D40B2A for ; Thu, 27 Sep 2012 14:56:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754006Ab2I0O4s (ORCPT ); Thu, 27 Sep 2012 10:56:48 -0400 Received: from perceval.ideasonboard.com ([95.142.166.194]:50894 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753585Ab2I0O4s (ORCPT ); Thu, 27 Sep 2012 10:56:48 -0400 Received: from avalon.ideasonboard.com (unknown [91.178.154.29]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E8AA935A88 for ; Thu, 27 Sep 2012 16:56:46 +0200 (CEST) From: Laurent Pinchart To: linux-media@vger.kernel.org Subject: [PATCH] uvcvideo: Mark first output terminal as default video node Date: Thu, 27 Sep 2012 16:57:25 +0200 Message-Id: <1348757845-24503-1-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.8.6 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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 --- drivers/media/usb/uvc/uvc_driver.c | 2 ++ drivers/media/usb/uvc/uvc_entity.c | 2 ++ drivers/media/usb/uvc/uvcvideo.h | 5 +++++ 3 files changed, 9 insertions(+), 0 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 22f14d2..5dbefa6 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -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; diff --git a/drivers/media/usb/uvc/uvc_entity.c b/drivers/media/usb/uvc/uvc_entity.c index 29e2399..dc56a59 100644 --- a/drivers/media/usb/uvc/uvc_entity.c +++ b/drivers/media/usb/uvc/uvc_entity.c @@ -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; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index acf6bf2..2aa2eea 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -225,10 +225,15 @@ 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];