From patchwork Fri Sep 18 07:59:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 28317 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 6B770C3356 for ; Fri, 18 Sep 2026 08:07:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B147068726; Fri, 18 Sep 2026 10:07:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="TE2y5t2X"; dkim-atps=neutral Received: from mail-wr2-x10.google.com (mail-wr2-x10.google.com [IPv6:2a00:1450:4864:30::10]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6663A68716 for ; Fri, 18 Sep 2026 10:07:43 +0200 (CEST) Received: by mail-wr2-x10.google.com with SMTP id ffacd0b85a97d-4843af75de5so45613f8f.3 for ; Fri, 18 Sep 2026 01:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1789718863; x=1790323663; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=G8Rujl4eHFMq0pxRHkPtyNcbpkOHl2MFCUZ4OoW5xoo=; b=TE2y5t2XX1kxYwV272NTxh4XRSRfCVYgHb9u3KmvPsh4gMqfitbiYSmhx61I8khmRP vebuoNd/L1Bntm+a4EC+Cv6tytL+OvpYd/UA/zWpyC8IQjpte36JxfJXQZFWEnKotMWA qR4Cc5fyKe8tHHeH3CX4pWQjWfwOA/ytzndDyDc48jlgyOzwhjlRhm5CadCEz7zjRzdE 1xItTVWwAnGTM9Uys+UD3TIgqn8kXULxITLxc4gnKLaT/3+loYt+lBc2CK2nf4ZHw7ZV C26KxRXjWjt22LpUod5pS1ZkVWEpAwWrz8VbyjN+hdgLs3H1E7u9VJy3AG0BgNGXwtLj QYxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789718863; x=1790323663; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=G8Rujl4eHFMq0pxRHkPtyNcbpkOHl2MFCUZ4OoW5xoo=; b=tpfbDktQbn/zrAfl8Yd2+FBQfGAcuViuinJkpfom5/7i5B7YNEwgvWsqzqvxdy1qgw dJGi1TG4K7sVjRQhf6SzoTM/YkHSrlJpQtFP706TmozzSvwCSVeXf/dUSPn2MhXUvAeq YLQ78aeef/iNbjGx7O59awYLE5lAQ0v3s2NhzcRHtGuF0/ELVfKrifpFjOjQqd4px0Vh PdZl3MGza40PGhdY+Lx0PSgCpkDK5TJkBYfWCR9Ps1it42hfYuiBppCTPWApNvTfV11A jlbnbj3wDdWE9Jv3zYsltfZyp7LZGRkE5rIqTrAOgaNKzvGMH+BQzFMn7WDRoJaDjUuK sStg== X-Gm-Message-State: AFuF++m7ac7V0pzYyoIDoTjhcpKl74t5i2nDJXXfBU5P7MX1j7zeSJ6g ZeJ2g3DFtlrsDARbUCY+37xS1Kqaso0ICqx6Fni1u5c1u9mjHAwF4SMuyT4Dam0myjEWYldqA4m Ev1eMtjk= X-Gm-Gg: AYBFou0YOcexE0hkNpEu/zqnVsV4LhNJ1shUmH+4rs2bhLtKa6NF4Wbsha7VTgKn+rC gxTNbenfrj3VDLSLUWuKL/NTU5iDlR6Qb9dzKIrm7W0Rq3bhHFAr2xlntsFDjjX3l7i+VpUQZLa HKvlJ4qhdma0vLIjHodue8dfJeMp53d4wDXLZnYoC0pU39DPKAW/pjhYEH6P1GzO+FBSPPUDbvS Som6p5mhIEo2JJiP6FOoADcyt/N4WZkU8D/9GWEl8VQlYrccqA/5JvdTjIBKhZkQwEch1DzbwKe 5597SU+6OIwKKxOhxenfs8YfcPz1hNUQTmD2gNGDc+2DDCl3SgYaEqBCgW3uYwcA4hSa4K838dc GLzgdgRo4uC1bI5sVfo0kf5g6rtBogA8L8Ps/iamoKj0vaBMioyXqPV6zRe/XBdsi+7NU7AGGf2 Ab+KokpAJPyzBRBZ9IWzP7w/0B36jujTvT258JHMLVkwob6LhEkS3hLOCatse0cD57/qM7pMfIk FkuygKdpV07vXCi3w3ldlPYjHl0ORqGKasr0G9mC+adoat5PmacEaSrP1PVxvxPTcFtj/MNmLs5 5qQhmTwS/rCUfKCZKOLjYd+NUgFp0z1QJzNcx/JylIlb5o1T1NIBroIqtIXeajk9IK0P6wcdd7S sX/jj8iEXzeRw3miYkHOfVZ4fLxuVP01E+ZI= X-Received: by 2002:a05:6000:2dc2:b0:487:ae2:4d0e with SMTP id ffacd0b85a97d-4871faa0f16mr1203784f8f.5.1789718862827; Fri, 18 Sep 2026 01:07:42 -0700 (PDT) Received: from naush-dell.pitowers.org ([2a00:1098:3142:1f:45e3:df8b:2b18:6253]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-487203f077fsm1742230f8f.26.2026.09.18.01.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 01:07:42 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck Subject: [RFC PATCH v1 05/20] libcamera: Add the CameraDescriptor class Date: Fri, 18 Sep 2026 08:59:43 +0100 Message-ID: <20260918080734.1228227-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260918080734.1228227-1-naush@raspberrypi.com> References: <20260918080734.1228227-1-naush@raspberrypi.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a CameraDescriptor class that describes a camera discovered during device enumeration, before any camera initialisation has taken place. It exposes the camera ID, guaranteed to be identical to the corresponding Camera::id(), and the subset of camera properties known at enumeration time. The private data records the producing pipeline handler factory, the required media devices and the sensor entity name, which will later allow the camera manager to initialise the camera from its descriptor. Signed-off-by: Naushir Patuck --- include/libcamera/camera_descriptor.h | 34 +++++ .../libcamera/internal/camera_descriptor.h | 37 +++++ include/libcamera/internal/meson.build | 1 + include/libcamera/meson.build | 1 + src/libcamera/camera_descriptor.cpp | 141 ++++++++++++++++++ src/libcamera/meson.build | 1 + 6 files changed, 215 insertions(+) create mode 100644 include/libcamera/camera_descriptor.h create mode 100644 include/libcamera/internal/camera_descriptor.h create mode 100644 src/libcamera/camera_descriptor.cpp diff --git a/include/libcamera/camera_descriptor.h b/include/libcamera/camera_descriptor.h new file mode 100644 index 000000000000..8da4b316fd42 --- /dev/null +++ b/include/libcamera/camera_descriptor.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026, Raspberry Pi Ltd + * + */ + +#pragma once + +#include +#include + +#include + +#include + +namespace libcamera { + +class CameraDescriptor final : public Extensible +{ + LIBCAMERA_DECLARE_PRIVATE() + +public: + static std::shared_ptr create(std::unique_ptr d); + + const std::string &id() const; + const ControlList &properties() const; + +private: + LIBCAMERA_DISABLE_COPY(CameraDescriptor) + + CameraDescriptor(std::unique_ptr d); +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/internal/camera_descriptor.h b/include/libcamera/internal/camera_descriptor.h new file mode 100644 index 000000000000..7c1bf52aec12 --- /dev/null +++ b/include/libcamera/internal/camera_descriptor.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026, Raspberry Pi Ltd + * + */ + +#pragma once + +#include +#include +#include + +#include + +#include +#include + +namespace libcamera { + +class MediaDevice; +class PipelineHandlerFactoryBase; + +class CameraDescriptor::Private : public Extensible::Private +{ + LIBCAMERA_DECLARE_PUBLIC(CameraDescriptor) + +public: + Private(); + + const PipelineHandlerFactoryBase *factory_; + std::vector> mediaDevices_; + std::string entityName_; + std::string id_; + ControlList properties_; +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index fd375134a5c4..b5a144e9e539 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -7,6 +7,7 @@ libcamera_internal_headers = files([ 'byte_stream_buffer.h', 'camera.h', 'camera_controls.h', + 'camera_descriptor.h', 'camera_lens.h', 'camera_manager.h', 'camera_sensor.h', diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 30ea76f9470a..91c76a10781a 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -4,6 +4,7 @@ libcamera_include_dir = 'libcamera' / 'libcamera' libcamera_public_headers = files([ 'camera.h', + 'camera_descriptor.h', 'camera_manager.h', 'color_space.h', 'controls.h', diff --git a/src/libcamera/camera_descriptor.cpp b/src/libcamera/camera_descriptor.cpp new file mode 100644 index 000000000000..b63f4c5fc330 --- /dev/null +++ b/src/libcamera/camera_descriptor.cpp @@ -0,0 +1,141 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2026, Raspberry Pi Ltd + * + */ + +#include "libcamera/internal/camera_descriptor.h" + +#include + +#include +#include + +/** + * \file libcamera/camera_descriptor.h + * \brief Describing cameras ahead of initialisation + */ + +namespace libcamera { + +/** + * \class CameraDescriptor + * \brief Describe a camera known to the system but not yet initialised + * + * A CameraDescriptor represents a camera discovered during device enumeration, + * before any camera initialisation has taken place. Descriptors are produced by + * CameraManager::enumerate() without acquiring any device, and carry the + * information about a camera that is available at enumeration time. + * + * The descriptor holds the camera identifier, guaranteed to be identical to + * the Camera::id() of the corresponding Camera instance, and a list of + * properties known at enumeration time. A descriptor can be passed to + * CameraManager::initialize() to create the corresponding fully initialised + * Camera. + */ + +#ifndef __DOXYGEN_PUBLIC__ +/** + * \class CameraDescriptor::Private + * \brief Base class for camera descriptor private data + */ + +/** + * \brief Construct a CameraDescriptor::Private instance + */ +CameraDescriptor::Private::Private() + : factory_(nullptr), properties_(properties::properties) +{ +} + +/** + * \var CameraDescriptor::Private::factory_ + * \brief The factory of the pipeline handler that produced this descriptor + * + * This is set by the camera manager when it collects the descriptors reported + * by a pipeline handler, and is used to create a pipeline handler for the + * camera when the descriptor is initialised. + */ + +/** + * \var CameraDescriptor::Private::mediaDevices_ + * \brief The media devices the camera is part of + * + * The media devices needed to initialise the camera. The first entry is the + * media device that identifies the camera's pipeline instance, and is used to + * route the camera to a live pipeline handler holding it. + */ + +/** + * \var CameraDescriptor::Private::entityName_ + * \brief The name of the camera's main media entity + * + * The entity that identifies the camera within its media device, for instance + * the camera sensor for a CSI receiver or the default video node for a USB + * camera. + */ + +/** + * \var CameraDescriptor::Private::id_ + * \brief The camera identifier + * \sa CameraDescriptor::id() + */ + +/** + * \var CameraDescriptor::Private::properties_ + * \brief The properties of the camera known at enumeration time + * \sa CameraDescriptor::properties() + */ +#endif /* __DOXYGEN_PUBLIC__ */ + +/** + * \brief Create a camera descriptor instance + * \param[in] d Camera descriptor private data + * + * The caller is responsible for populating the private data before creating + * the descriptor. + * + * \return A shared pointer to the newly created camera descriptor object + */ +std::shared_ptr +CameraDescriptor::create(std::unique_ptr d) +{ + return std::shared_ptr(new CameraDescriptor(std::move(d))); +} + +/** + * \brief Retrieve the ID of the camera + * + * The camera ID is identical to the Camera::id() of the Camera instance + * created by initialising this descriptor. It is guaranteed to be unique and + * stable so the same camera will have the same ID across both unplug/replug and + * boot cycles. + * + * \return ID of the camera + */ +const std::string &CameraDescriptor::id() const +{ + return _d()->id_; +} + +/** + * \brief Retrieve the properties of the camera known at enumeration time + * + * Camera properties are metadata that describe the camera. Only the subset of + * properties that can be determined at enumeration time (without initialising + * the camera) is reported here. The complete property list is available from + * Camera::properties() once the camera has been initialised. + * + * \return The list of camera properties known at enumeration time + */ +const ControlList &CameraDescriptor::properties() const +{ + return _d()->properties_; +} + +CameraDescriptor::CameraDescriptor(std::unique_ptr d) + : Extensible(std::move(d)) +{ +} + +} /* namespace libcamera */ diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 17c1b2cb3479..ba51f5ee47b3 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -2,6 +2,7 @@ libcamera_public_sources = files([ 'camera.cpp', + 'camera_descriptor.cpp', 'camera_manager.cpp', 'color_space.cpp', 'controls.cpp',