From patchwork Mon Aug 14 11:28:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabrielle George X-Patchwork-Id: 18938 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 C1ADEC3257 for ; Mon, 14 Aug 2023 11:29:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2892D628DF; Mon, 14 Aug 2023 13:28:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1692012539; bh=tITfKvnBlkEJdz07jEYOKbwfWNQmea4GTx911uz2yNk=; 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=MH8i+rlnnFvRzS6N0+nVKdM0bQNNVuhbnPIo6ULGvsayj5currCVaBMRRV6LKSUCL SgYXs+naI8RbJqQgNftbj7YCrtZzpMu3WZu2DXLg96bNLKT8WHSt8cgifWSqZES+lg BP0UbTLnuQqYiolPloXh8ypJCbenixpSELH7A50WBqbMSYLgw1NYxY/h6AtZgHzcVi 8c9x+wP70lrT4/hFpq62mZPJ7hGwiQXWse8+XAJSA57Xu5ktF+3VfbcNYLvw7YrDxk sy+S1ihhTHFFnaX1+j2MoI9BaZBftjDJpaCL2AXyeEE0o92mCb7tLNVaeWUF7x/CXx ZY9ykFYPN2Hyg== Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3A82B61E0B for ; Mon, 14 Aug 2023 13:28:54 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hyfKpH92"; dkim-atps=neutral Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6bd045336c6so3840193a34.2 for ; Mon, 14 Aug 2023 04:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692012532; x=1692617332; 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=qhmizX4FuLCSyb8453O84uUId5fqc6MvHIneCkyAl7Q=; b=hyfKpH92reKEo+zItwGxcONaR33ya1fu7VheiyzswFIYdsEu3XR7YB3tieIoD6y/mw nk7qfJvLDjzUbNRGAClGcflIz2oZe/6Olog8gTR7s/rhvLSXz4k72bsWUpE+Gcrc2eQk ySYTH3gbsnfNoo+QLzsfgDPf+stSoBiOoe99txHMip0FmUKfU8rnITViudTg8C+q2SkA 0/ng6x3wxHR1X2SBdAcmtDacuuYDds9uT+BGOvMuWC4qSIdHo78MNXR7U6Z0ynhWvW4N ecN0RvtCLYo+3R1oG08L+hT4dlYZErLGEHbqKnwU79gMJRAkcg+QrTJ/j/BuTfDiqcdX P8Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692012532; x=1692617332; 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=qhmizX4FuLCSyb8453O84uUId5fqc6MvHIneCkyAl7Q=; b=g5zOofQRKcFBaYdgZj54soktxBizvnEeSFcSEMu3upX3PBgDHDxnu4YTD8/jOd3M9j jx5On6ifkSnPLlwkKmsZ9Z4g2+cFj3M2KD++UUE0ET9kcenCo9k5qEKombv+WhXC+9KU VyslsivzkPjWH4qTBw1Hwdm7m2LyiqE+EFB/ZsloxBPDwzEf9eDPrC84xBLQWeP0mHTz s4jAR1B65E40nvYMUmmH1BSML6cLwJRUtrXhzqjYgA3Pbz4z13kRUMm+nj4CtmijNjve hOKkHi/ugpLUiJkvuqTGTfgUUbnLRIHJUYi7shtAwtoV1RwxEjk8ksEmt4S/EMJVnuGD kTLg== X-Gm-Message-State: AOJu0YwsqpRL/IckF+rgJv0jG2AfHW7WpTGcnEj9ohH3ybxqYn57mj4j Bxl9M4qq3f/dk+O/CNuQW9len2mrNZ0ynA== X-Google-Smtp-Source: AGHT+IGpqZZfiso8ESWgGoUb+YfXoZXAqy9f6NhCjcaWCrMxwMWO2/dxriTaJ4Eb7tIHfhMU6YnLmQ== X-Received: by 2002:a9d:7dd6:0:b0:6b9:9288:613c with SMTP id k22-20020a9d7dd6000000b006b99288613cmr8539153otn.13.1692012532772; Mon, 14 Aug 2023 04:28:52 -0700 (PDT) Received: from localhost.localdomain (97-115-76-16.ptld.qwest.net. [97.115.76.16]) by smtp.gmail.com with ESMTPSA id c3-20020a9d6c83000000b006b92509e76esm4163817otr.32.2023.08.14.04.28.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Aug 2023 04:28:52 -0700 (PDT) To: libcamera-devel@lists.libcamera.org, kieran.bingham@ideasonboard.com, vedantparanjape160201@gmail.com, gabbymg94@gmail.com Date: Mon, 14 Aug 2023 04:28:45 -0700 Message-Id: <20230814112849.176943-2-gabbymg94@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230814112849.176943-1-gabbymg94@gmail.com> References: <20230814112849.176943-1-gabbymg94@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 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 | 36 +++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 38f48a5d..4470d8a2 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,37 @@ 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()) { + LOG(UVC, Error) << "Could not find a metadata video device."; + return -ENODEV; + } + + /* configure the metadata node */ + metadata_ = std::make_unique(*metadata); + ret = metadata_->open(); + if (ret) + return ret; + + if (!(metadata_->caps().isMeta())) { + /* if the caps do not have the metadata attribute + * (shouldn't happen) */ + metadata_ = NULL; + return -EINVAL; + } + return 0; +} + int UVCCameraData::init(MediaDevice *media) { int ret; @@ -512,7 +546,7 @@ int UVCCameraData::init(MediaDevice *media) controlInfo_ = ControlInfoMap(std::move(ctrls), controls::controls); - return 0; + return initMetadata(media); } bool UVCCameraData::generateId()