Patch Detail
Show a patch.
GET /api/1.1/patches/15346/?format=api
{ "id": 15346, "url": "https://patchwork.libcamera.org/api/1.1/patches/15346/?format=api", "web_url": "https://patchwork.libcamera.org/patch/15346/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20220209071917.559993-3-hanlinchen@chromium.org>", "date": "2022-02-09T07:19:10", "name": "[libcamera-devel,2/9] libcamera: Add options() and setOptions() operations to Camera", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "24ee7b1b8a0f6f815f019fe109f415ef0f839ed3", "submitter": { "id": 98, "url": "https://patchwork.libcamera.org/api/1.1/people/98/?format=api", "name": "Hanlin Chen", "email": "hanlinchen@chromium.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/15346/mbox/", "series": [ { "id": 2923, "url": "https://patchwork.libcamera.org/api/1.1/series/2923/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2923", "date": "2022-02-09T07:19:08", "name": "Introduce Pipeline configuration preference for IPU3", "version": 1, "mbox": "https://patchwork.libcamera.org/series/2923/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/15346/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/15346/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C8353C3262\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 9 Feb 2022 07:19:34 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 32390610EF;\n\tWed, 9 Feb 2022 08:19:31 +0100 (CET)", "from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com\n\t[IPv6:2607:f8b0:4864:20::62a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ED3DA60E66\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 9 Feb 2022 08:19:29 +0100 (CET)", "by mail-pl1-x62a.google.com with SMTP id x3so1479000pll.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 08 Feb 2022 23:19:29 -0800 (PST)", "from localhost ([2401:fa00:1:10:a5cf:9a43:1c6d:824])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tn22sm18873823pfu.77.2022.02.08.23.19.27\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tTue, 08 Feb 2022 23:19:28 -0800 (PST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"RC/v7GzU\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=26FibggvqYPF43PLWR4Cxku84PjjPkOG3Xu8PZWi+7Q=;\n\tb=RC/v7GzUm4/FhiQhjjzwH7i+cc/xop0+t7cQkDYk4NxUJh/X2km/T3wjvcDstmPpiR\n\tpCrXLaGvPdIitVGn3VzZhuYl/09BCCamw/KVXsLxH7A971G8PyGIbaxL/XhYPoy7MirA\n\tyYZNcrLPtDDl4y+UsvoKKJSbWOxOe+BSTLiuI=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=26FibggvqYPF43PLWR4Cxku84PjjPkOG3Xu8PZWi+7Q=;\n\tb=sGKzCiQ2IPdcyHgxU/4MYrWQSvPZu0d46bE3Bn7sx2RzyHcpfz4yrQoluxQI1gR81b\n\tIfD/ePdnlRVYktXQ+wq3p1OtZLHKe8zM/97piirHkeW3ZwNzS1b04EfINcVQdKrTe313\n\tTzS+Yhby49l8adEXeE9MOJPI7kczPNncH8fGZU4iQypkt/x1kW/e/UNQvSFd1FajtyVO\n\tgtEzgj+MH/0+wsKyHWVGEZHFd+43Wa8PcqnjWVTF9+SXfsk4C5elVO6y4vfwtGe1p9hY\n\tr5sdb6mEBwQn6KBLBxgyed4zCzs0v8tsLk9Ygf+Aw5QeTnAdnt96cnp2JFDB/bJhHNNK\n\t9PJA==", "X-Gm-Message-State": "AOAM532S1cY9W07C706/hFjhEWDmo1JHgGo5cYXL7KDGJSNOJpHG7rc9\n\tUQ2aMW8XokkOC6RExnfpw31biRRZgCix4Q==", "X-Google-Smtp-Source": "ABdhPJyyBucaJsgWM99vyP2VEd+Etg1CUNup3Hxfoixt6z3MAY0Ki4lViR5cxvD9atu+vS/uj+1nEA==", "X-Received": "by 2002:a17:902:e80c:: with SMTP id\n\tu12mr1125550plg.159.1644391168337; \n\tTue, 08 Feb 2022 23:19:28 -0800 (PST)", "From": "Han-Lin Chen <hanlinchen@chromium.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 9 Feb 2022 15:19:10 +0800", "Message-Id": "<20220209071917.559993-3-hanlinchen@chromium.org>", "X-Mailer": "git-send-email 2.35.0.263.gb82422642f-goog", "In-Reply-To": "<20220209071917.559993-1-hanlinchen@chromium.org>", "References": "<20220209071917.559993-1-hanlinchen@chromium.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/9] libcamera: Add options() and\n\tsetOptions() operations to Camera", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add options() and setOptions() operations to Camera. Both operations\ntakes a camera instance and reads or writes the options to it. Because\nan option might change the supported characteristics of a camera module,\nit could only be set before configuring.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n---\n include/libcamera/camera.h | 3 +\n include/libcamera/internal/camera.h | 2 +\n include/libcamera/internal/pipeline_handler.h | 2 +\n src/libcamera/camera.cpp | 59 +++++++++++++++++++\n src/libcamera/pipeline_handler.cpp | 26 ++++++++\n 5 files changed, 92 insertions(+)", "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex 5bb06584..1bb80a6d 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -98,9 +98,12 @@ public:\n \tSignal<Request *> requestCompleted;\n \tSignal<> disconnected;\n \n+\tint setOptions(const ControlList *options = nullptr);\n+\n \tint acquire();\n \tint release();\n \n+\tconst ControlInfoMap &options() const;\n \tconst ControlInfoMap &controls() const;\n \tconst ControlList &properties() const;\n \ndiff --git a/include/libcamera/internal/camera.h b/include/libcamera/internal/camera.h\nindex 597426a6..c3cb1865 100644\n--- a/include/libcamera/internal/camera.h\n+++ b/include/libcamera/internal/camera.h\n@@ -34,6 +34,8 @@ public:\n \tPipelineHandler *pipe() { return pipe_.get(); }\n \n \tstd::list<Request *> queuedRequests_;\n+\n+\tControlInfoMap optionInfo_;\n \tControlInfoMap controlInfo_;\n \tControlList properties_;\n \ndiff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex c3e4c258..184e4b9a 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -45,6 +45,8 @@ public:\n \tMediaDevice *acquireMediaDevice(DeviceEnumerator *enumerator,\n \t\t\t\t\tconst DeviceMatch &dm);\n \n+\tvirtual int setOptions(Camera *camera, const ControlList *options);\n+\n \tbool lock();\n \tvoid unlock();\n \ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex bb856d60..9e95e6cc 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -480,6 +480,16 @@ Camera::Private::~Private()\n * well, when implementing official support for control info updates.\n */\n \n+/**\n+ * \\var Camera::Private::optionInfo_\n+ * \\brief The set of options supported by the camera\n+ *\n+ * The optionInfo_ information shall be initialised by the pipeline handler when\n+ * creating the camera.\n+ *\n+ * This member was meant to stay constant after the camera is created.\n+ */\n+\n /**\n * \\var Camera::Private::properties_\n * \\brief The list of properties supported by the camera\n@@ -802,6 +812,40 @@ int Camera::exportFrameBuffers(Stream *stream,\n \t\t\t\t buffers);\n }\n \n+/**\n+ * \\brief Set Options for a camera.\n+ * \\param[in] options Options to be applied before configuring a camera\n+ *\n+ * Prior to configuring a camera, it's optional to set options to a camera to\n+ * change its characteristics or internal behaviors. The supported options are\n+ * depended on the platform. The caller should iterate supported Options by\n+ * options() before setting them.\n+ *\n+ * Options might change the internal behavior of configure() and capturing\n+ * images, and thus the function can only be called before configure().\n+ * It's encouraged to re-check the results of controls(), properties() and\n+ * generateConfiguration() after setting options to a camera.\n+ *\n+ * \\context This function shall be synchronized by the caller with other\n+ * functions that affect the camera state.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ * \\retval -EACCES The camera is not in a state where it can set options\n+ * \\retval -EINVAL The options is not valid\n+ */\n+int Camera::setOptions(const ControlList *options)\n+{\n+\tPrivate *const d = _d();\n+\n+\tint ret = d->isAccessAllowed(Private::CameraAvailable,\n+\t\t\t\t Private::CameraAcquired);\n+\tif (ret < 0)\n+\t\treturn -EACCES;\n+\n+\treturn d->pipe_->invokeMethod(&PipelineHandler::setOptions,\n+\t\t\t\t ConnectionTypeBlocking, this, options);\n+}\n+\n /**\n * \\brief Acquire the camera device for exclusive access\n *\n@@ -894,6 +938,21 @@ const ControlInfoMap &Camera::controls() const\n \treturn _d()->controlInfo_;\n }\n \n+/**\n+ * \\brief Retrieve the list of options supported by the camera\n+ *\n+ * The list of options supported by the camera and their associated\n+ * constraints remain constant through the lifetime of the Camera object.\n+ *\n+ * \\context This function is \\threadsafe.\n+ *\n+ * \\return A ControlInfoMap listing the options supported by the camera\n+ */\n+const ControlInfoMap &Camera::options() const\n+{\n+\treturn _d()->optionInfo_;\n+}\n+\n /**\n * \\brief Retrieve the list of properties of the camera\n *\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 7ebd76ad..1f2a6d7e 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -142,6 +142,32 @@ MediaDevice *PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator,\n \treturn media.get();\n }\n \n+/**\n+ * \\fn PipelineHandler::setOptions()\n+ * \\brief Set options for camera\n+ * \\param[in] camera The camera to set options\n+ * \\param[in] options Options to be applied to the Camera\n+ *\n+ * Set options to the camera. The supported options are different for each\n+ * pipeline handler. The intended caller of the this function could iterate\n+ * options supported by the camera with Camera::options().\n+ *\n+ * The intended caller of this function is the Camera class which will in turn\n+ * be called from the application to indicate that a set of options should be\n+ * applied. The user should check supported options with Camera::options()\n+ * before setting them.\n+ *\n+ * \\context This function is called from the CameraManager thread.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int PipelineHandler::setOptions([[maybe_unused]] Camera *camera,\n+\t\t\t\t[[maybe_unused]] const ControlList *options)\n+{\n+\t/* The default implementation which supported no options. */\n+\treturn -EINVAL;\n+}\n+\n /**\n * \\brief Lock all media devices acquired by the pipeline\n *\n", "prefixes": [ "libcamera-devel", "2/9" ] }