From patchwork Mon Aug 21 13:10:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabrielle George X-Patchwork-Id: 18944 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1ADC4C3261 for ; Mon, 21 Aug 2023 13:10:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9E228627E4; Mon, 21 Aug 2023 15:10:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1692623445; bh=V7dvhyL1dJls6TnTqwFfnwsQqRVVoRsc/vzZXaJCdJk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ykCMcihxYJkslOM4Bwsvt149Ik/+u9iwoGliAhsyMf9MebE85LkdyT4VsIC5vPIGs QFAjyrXddSUaZ5KtSMZZNRflIgtpFeGlO8SPIaIxyCxWyKN9eTM1x2WtN+DeEsnqW+ Lc9lUF1rcxX6Z6kUrm7wQQCPehhXkwtBxOJiW+eMap9zI2UcBz72MsGXjmArc1xtgo QjoNaIydUwozyfwcd24kAAJdU3tQkRrgxU97b/qIZ7131WUD2LYq6X9KS0k2d7KEOU S+ji3iyN3/EDefCJ3ucdY+UIsadexAykFY/yDEn///9hOWssX2c/As6+Wx3S/FQAt+ 54b9EuFP+RjrA== Received: from mail-oa1-x36.google.com (mail-oa1-x36.google.com [IPv6:2001:4860:4864:20::36]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E360661E09 for ; Mon, 21 Aug 2023 15:10:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pp6zpTOF"; dkim-atps=neutral Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-1c0fff40ec6so2037825fac.2 for ; Mon, 21 Aug 2023 06:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692623442; x=1693228242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=OmfY6WyS9NxuJh3gBonJnWAumuZMXL/N1xt6mkK1am8=; b=pp6zpTOFzscdasJLhGkGfBjKxZ5OdtUbhlrc3fCv0gBfRvUzLwB/yiHvR/UHxNBP8O mMYR1KiD5T+Y1N0reKNO1YTCvw6Mwaz/Tln/GD95yz0X3Ju+LW2iU8BLPmpJxb4BFhuH RFx/9hks5hKqOugt/oW+Lv7g4Ce+kzbmfis+R0gG69VUpGLAeImA22xnAakbzVQ+Xm6k 43PnqJHGJriPsA+U547KgmMeW9ZYuPTZsNtWsOchPJ4KIUJVGgc6eIMfcn7VTvDzJm1b AnB3KzMN+Pke+w1P2Tq13A1GK05/qxVcd+SSQDskopBzT+CGDWFAUXFOXSx3TTGV3x2X rx+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692623442; x=1693228242; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OmfY6WyS9NxuJh3gBonJnWAumuZMXL/N1xt6mkK1am8=; b=k1UxmMFJVbCXj6DpmHG7ZWwmws1PzZvP0yJdvr/9gbVy0kHbWSDlfzo/9It78abQm+ 13qUkJt/tyV/K8hAa/UjUW6WdN9f2yfwHHE5w9LHNEhX20eVWdxXRSCu+eTZ7sZkLV2l 5LYCaGA+auWCp1D2QB/uFUFWmVDAmG2emfsQ0oAM0CJI3arjrHw80uTToRmdNsO6a2Ku ta4/At0YuhWSVgXjsb4oJpWSjuZx9smdACBZ7HdZdoP0wAswVFdNJwQsORmrGOkbQdr/ 85H4YtqBsBrzrYe9F/TRn3isKW1ugaezUHc5NY0JHZ1OiBFUzXqdQqNRivMFjKKiAcvO sB0g== X-Gm-Message-State: AOJu0YwWXhssVM5xAf4Wt0y8B456pa/RyC0aSAJlTCPa4HOlKnw480is pMZkClbsEuYs7vQsyyG8DSoYDSw8zDY= X-Google-Smtp-Source: AGHT+IGc8asc16gReMOCbrjMICJSWpupZ7LniilQ52PK0Y6byGaNy7xPTfdjoZgB9YNZPaZ/yGvobQ== X-Received: by 2002:a05:6870:e313:b0:1b0:222f:9cda with SMTP id z19-20020a056870e31300b001b0222f9cdamr8864169oad.0.1692623442403; Mon, 21 Aug 2023 06:10:42 -0700 (PDT) Received: from localhost.localdomain (97-115-76-16.ptld.qwest.net. [97.115.76.16]) by smtp.gmail.com with ESMTPSA id ci1-20020a056871c48100b001bb51450d85sm4160283oac.4.2023.08.21.06.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Aug 2023 06:10:42 -0700 (PDT) To: libcamera-devel@lists.libcamera.org, kieran.bingham@ideasonboard.com, vedantparanjape160201@gmail.com, gabbymg94@gmail.com Date: Mon, 21 Aug 2023 06:10:35 -0700 Message-Id: <20230821131039.127370-2-gabbymg94@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230821131039.127370-1-gabbymg94@gmail.com> References: <20230821131039.127370-1-gabbymg94@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 1/5] libcamera: pipeline: uvcvideo: Add UVC metadata node X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Gabby George via libcamera-devel From: Gabrielle George Reply-To: Gabby George Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Identify and open the UVC metadata's video node. This will give us access to metadata associated with the video stream of the uvc camera. The user will not have access to this video node and will not need to manage its data in any way. Signed-off-by: Gabby George --- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 38f48a5d..dbe0cc8c 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -49,10 +49,13 @@ public: const std::string &id() const { return id_; } std::unique_ptr video_; + std::unique_ptr metadata_; Stream stream_; std::map> formats_; private: + int initMetadata(MediaDevice *media); + bool generateId(); std::string id_; @@ -411,6 +414,39 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator) return true; } +int UVCCameraData::initMetadata(MediaDevice *media) +{ + int ret; + + const std::vector &entities = media->entities(); + std::string dev_node_name = video_->deviceNode(); + auto metadata = std::find_if(entities.begin(), entities.end(), + [&dev_node_name](MediaEntity *e) { + return e->type() == MediaEntity::Type::V4L2VideoDevice + && !(e->flags() & MEDIA_ENT_FL_DEFAULT); + }); + + if (metadata == entities.end()) { + return -ENODEV; + } + + /* configure the metadata node */ + metadata_ = std::make_unique(*metadata); + ret = metadata_->open(); + if (ret) + return ret; + + if (!(metadata_->caps().isMeta())) { + /* + * UVC Devices are usually only anticipated to expose two + * devices, so we assume the non-default device is the metadata + * device node + */ + return -EINVAL; + } + return 0; +} + int UVCCameraData::init(MediaDevice *media) { int ret; @@ -512,6 +548,12 @@ int UVCCameraData::init(MediaDevice *media) controlInfo_ = ControlInfoMap(std::move(ctrls), controls::controls); + ret = initMetadata(media); + if (ret) { + metadata_ = nullptr; + LOG(UVC, Error) << "Could not find a metadata video device."; + } + return 0; }