From patchwork Wed Nov 10 07:22:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14508 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 2FE9DBF415 for ; Wed, 10 Nov 2021 07:22:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7E0CB6034E; Wed, 10 Nov 2021 08:22:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="e2unmHV2"; dkim-atps=neutral Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 737C460234 for ; Wed, 10 Nov 2021 08:22:15 +0100 (CET) Received: by mail-pf1-x434.google.com with SMTP id n85so1834177pfd.10 for ; Tue, 09 Nov 2021 23:22:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YE5KQnJ22RaCNYBTSjV2YzUxCwMlx+/X3tplBUGoB4Y=; b=e2unmHV2WyHoZ1gFGot7hqPZ9uNE6t7SgZXyn6Eu7QOHwwWb6MDTIlMty2NDM85TPI P+oS1v8NyzXKqggqzdEc1YDbT+s2J/SdMesp/WiR5r40Lc+zOD4q5CxIpJv2D5ySWWZB MsgrQrnLZA2vFgnt1/KB/0F3YuxCEv4eTKjRI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=YE5KQnJ22RaCNYBTSjV2YzUxCwMlx+/X3tplBUGoB4Y=; b=eUCf4tTyUV5yN0X9FUXqTtAYWNrj6oDmCWn+EhRKDkTiV3vVrabM0PMBvm/R2hA7Y3 WRCiijqfZvutXUU1e+U1eeb8n6Hdj3tnG+DnKkkbd9R0g/DyeQPKgrEHysCHS7/ACY6z oaps3fKrFx8fMAjCt6ngeGIDPzs8yGTWLEPDSH9Fo1IT1OA/5h4SGM7etlM/modoLTyM 20UdqcHA0WdaMyNI08UQmEvGI0YKNwp5tbH0+Z5+tHeks0KpP3lpNWGfMP6Z+O3Mcir1 GyLgc5AjSItR3sblr2wpJKejBFOIPzxxJ5cgoW6TZgZSCjowMedvuWw1uRMefMV6XEE4 x/yg== X-Gm-Message-State: AOAM531Lc6kt4z2hmV/BqZK/AKL6X+nL2lZrSCIk2pU6aTxplNQFavCA aYOHUYlQPVpobh+EU5o2Q1LsYxp8PUaSuQ== X-Google-Smtp-Source: ABdhPJzUW/czDsdIFq80cqaTiSqCHBZsvsN215MH40kIpBlQEOQ8MYlbcnxjaiIur7Buq7GRNFiKiQ== X-Received: by 2002:a63:ab48:: with SMTP id k8mr10426839pgp.307.1636528933156; Tue, 09 Nov 2021 23:22:13 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:4a73:e1bd:9b3f:4903]) by smtp.gmail.com with ESMTPSA id r1sm5073669pjm.23.2021.11.09.23.22.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 23:22:12 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Nov 2021 16:22:04 +0900 Message-Id: <20211110072207.3273703-1-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc0.344.g81b53c2807-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 1/4] lc-compliance: Build with gtest in subprojects 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" libgtest-dev is provided as a static library at least Debian 10. The compiler and linker to create the static library might be different from ones used for libcamera. This causes a problem upon linking. This puts gtest code to subprojects, builds the code and link it for lc-compliance. However, libgtest is locally built as a library on ChromeOS and thus the used compiler and linker are the same as one used for libcamera. We don't do these on ChromeOS build environment. Signed-off-by: Hirokazu Honda Tested-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain --- README.rst | 2 +- src/lc-compliance/meson.build | 16 ++++++++++++++-- subprojects/.gitignore | 4 +++- subprojects/gtest.wrap | 14 ++++++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 subprojects/gtest.wrap diff --git a/README.rst b/README.rst index 8af5f118..c48b4dba 100644 --- a/README.rst +++ b/README.rst @@ -99,7 +99,7 @@ for android: [optional] libexif-dev libjpeg-dev libyaml-dev for lc-compliance: [optional] - libevent-dev libgtest-dev + libevent-dev Using GStreamer plugin ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/lc-compliance/meson.build b/src/lc-compliance/meson.build index aa5852f6..8c43ef12 100644 --- a/src/lc-compliance/meson.build +++ b/src/lc-compliance/meson.build @@ -1,15 +1,27 @@ # SPDX-License-Identifier: CC0-1.0 libevent = dependency('libevent_pthreads', required : get_option('lc-compliance')) -libgtest = dependency('gtest', required : get_option('lc-compliance')) -if not (libevent.found() and libgtest.found()) +if not libevent.found() lc_compliance_enabled = false subdir_done() endif lc_compliance_enabled = true +if get_option('android_platform') == 'cros' + libgtest = dependency('gtest', required : get_option('lc-compliance')) + + if not libgtest.found() + lc_compliance_enabled = false + subdir_done() + endif + +else + libgtest_sp = subproject('gtest') + libgtest = libgtest_sp.get_variable('gtest_dep') +endif + lc_compliance_sources = files([ '../cam/event_loop.cpp', '../cam/options.cpp', diff --git a/subprojects/.gitignore b/subprojects/.gitignore index 410b8bd6..391fde2c 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -1 +1,3 @@ -/libyuv \ No newline at end of file +/googletest-release* +/libyuv +/packagecache \ No newline at end of file diff --git a/subprojects/gtest.wrap b/subprojects/gtest.wrap new file mode 100644 index 00000000..40128b35 --- /dev/null +++ b/subprojects/gtest.wrap @@ -0,0 +1,14 @@ +[wrap-file] +directory = googletest-release-1.11.0 +source_url = https://github.com/google/googletest/archive/release-1.11.0.zip +source_filename = gtest-1.11.0.zip +source_hash = 353571c2440176ded91c2de6d6cd88ddd41401d14692ec1f99e35d013feda55a +patch_filename = gtest_1.11.0-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.11.0-1/get_patch +patch_hash = d38c39184384608b08419be52aed1d0f9d9d1b5ed71c0c35e51cccbdddab7084 + +[provide] +gtest = gtest_dep +gtest_main = gtest_main_dep +gmock = gmock_dep +gmock_main = gmock_main_dep From patchwork Wed Nov 10 07:22:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14509 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 2E530BF415 for ; Wed, 10 Nov 2021 07:22:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DC42C6032C; Wed, 10 Nov 2021 08:22:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="QqNbtIhL"; dkim-atps=neutral Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F395A60345 for ; Wed, 10 Nov 2021 08:22:16 +0100 (CET) Received: by mail-pj1-x102a.google.com with SMTP id j5-20020a17090a318500b001a6c749e697so1240873pjb.1 for ; Tue, 09 Nov 2021 23:22:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8zv8+6CeG3JlrqiA2HdTIX0u11iqVcSsHDAfnyGUIBU=; b=QqNbtIhLMCFSqJfbUqGzVlayg1iEoG93xqYWmHqXRsDBk+9NJqL3Mg8y2Fy+MBUczF N/uuc8KfjdvsDILLUX0ts/H823l4KFFd2NNnAigmCWRfR1G4eAvCAdsyXVFQDD47geVr tR5GIDueDJ5JZH1mg8b7W7YzjlrOVYPchOQnI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8zv8+6CeG3JlrqiA2HdTIX0u11iqVcSsHDAfnyGUIBU=; b=VvqvxEdSjkIzlEqFrPO/OQxZQOaoF5PH08ucJ43Fq4NmAV/g0Zpby7mAEooD4EF+J9 ByLtVeZmNxTZPUGWLCCbEVnmsefZST6NR9dyAEnI84GMfF0kUESU9GrgWaE5Uz47CEm9 RZZfwkk4bOTM/Klu9r8XXGoqW5OowEBMJzW+jtkhumrN/GcIHe+BslVLn2g15vg3r5mU /W4SaXxwquKxLKEqYNYknV2D+6JEBItVKA54n30LV5257F/giftalP74AgoA861/bVtI dd4i5Fgx/0g/nGY7pD73to43OZkgbDGixQiWkapo0Hq8K29BbMSiXvmPZDAwf7d+gxox 3b/Q== X-Gm-Message-State: AOAM5315aAG9H1lK+A5mlUeGjHeQZ62auYOzsHgCfwjSg4W+L2S30+j3 v6hqaXL0reTq988k3zbH82DKo1N6A+WpOw== X-Google-Smtp-Source: ABdhPJy/oSy0At3+ablvesQW/C+L8puH/p4lVJ0kItpduEQHZT3bghLTLXw+tJ3GV4ftdZdzH6EaLQ== X-Received: by 2002:a17:90a:d192:: with SMTP id fu18mr14860682pjb.177.1636528935019; Tue, 09 Nov 2021 23:22:15 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:4a73:e1bd:9b3f:4903]) by smtp.gmail.com with ESMTPSA id r1sm5073669pjm.23.2021.11.09.23.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 23:22:14 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Nov 2021 16:22:05 +0900 Message-Id: <20211110072207.3273703-2-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc0.344.g81b53c2807-goog In-Reply-To: <20211110072207.3273703-1-hiroh@chromium.org> References: <20211110072207.3273703-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 2/4] libcamera: camera_sensor: Reference test pattern modes by enum type 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" The CameraSensor stores TestPatternModes as an int32_t. This prevents the compiler from verifying the usage against the defined enum types. Fix references to the TestPatternMode to store the value as the TestPatternModeEnum type which is defined by the control generator. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/internal/camera_sensor.h | 10 +++++++--- include/libcamera/internal/camera_sensor_properties.h | 3 ++- src/libcamera/camera_sensor.cpp | 4 ++-- src/libcamera/pipeline/ipu3/ipu3.cpp | 7 ++++--- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index d25a1165..edef2220 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -14,8 +14,10 @@ #include #include +#include #include #include + #include #include "libcamera/internal/formats.h" @@ -40,7 +42,8 @@ public: const std::vector &mbusCodes() const { return mbusCodes_; } const std::vector sizes(unsigned int mbusCode) const; Size resolution() const; - const std::vector &testPatternModes() const + const std::vector + &testPatternModes() const { return testPatternModes_; } @@ -71,7 +74,8 @@ private: void initVimcDefaultProperties(); void initStaticProperties(); void initTestPatternModes( - const std::map &testPatternModeMap); + const std::map + &testPatternModeMap); int initProperties(); const MediaEntity *entity_; @@ -84,7 +88,7 @@ private: V4L2Subdevice::Formats formats_; std::vector mbusCodes_; std::vector sizes_; - std::vector testPatternModes_; + std::vector testPatternModes_; Size pixelArraySize_; Rectangle activeArea_; diff --git a/include/libcamera/internal/camera_sensor_properties.h b/include/libcamera/internal/camera_sensor_properties.h index 67c77920..5c7e5e87 100644 --- a/include/libcamera/internal/camera_sensor_properties.h +++ b/include/libcamera/internal/camera_sensor_properties.h @@ -10,6 +10,7 @@ #include #include +#include #include namespace libcamera { @@ -18,7 +19,7 @@ struct CameraSensorProperties { static const CameraSensorProperties *get(const std::string &sensor); Size unitCellSize; - std::map testPatternModes; + std::map testPatternModes; }; } /* namespace libcamera */ diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 9fdb8c09..f0aa9f24 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -311,7 +311,7 @@ void CameraSensor::initStaticProperties() } void CameraSensor::initTestPatternModes( - const std::map &testPatternModes) + const std::map &testPatternModes) { const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN); if (v4l2TestPattern == controls().end()) { @@ -327,7 +327,7 @@ void CameraSensor::initTestPatternModes( * control index is supported in the below for loop that creates the * list of supported test patterns. */ - std::map indexToTestPatternMode; + std::map indexToTestPatternMode; for (const auto &it : testPatternModes) indexToTestPatternMode[it.second] = it.first; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index eb714aa6..63cb7f11 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -981,13 +981,14 @@ int PipelineHandlerIPU3::updateControls(IPU3CameraData *data) return ret; ControlInfoMap::Map controls = IPU3Controls; - const std::vector &testPatternModes = sensor->testPatternModes(); + const std::vector + &testPatternModes = sensor->testPatternModes(); if (!testPatternModes.empty()) { std::vector values; values.reserve(testPatternModes.size()); - for (int32_t pattern : testPatternModes) - values.emplace_back(pattern); + for (auto pattern : testPatternModes) + values.emplace_back(static_cast(pattern)); controls[&controls::draft::TestPatternMode] = ControlInfo(values); } From patchwork Wed Nov 10 07:22:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14510 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 9D735BF415 for ; Wed, 10 Nov 2021 07:22:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 546B460362; Wed, 10 Nov 2021 08:22:20 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Ct0yArhi"; dkim-atps=neutral Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA27A60362 for ; Wed, 10 Nov 2021 08:22:18 +0100 (CET) Received: by mail-pl1-x633.google.com with SMTP id y1so2225955plk.10 for ; Tue, 09 Nov 2021 23:22:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OoDCjuxpFNiBepFgfoMLjFldIJiE4G+lwYGfxB/7O5c=; b=Ct0yArhinlKRAFmtRC1C/YLy1HEEFIscAWlrHCLLZrI40mHMAh/LSoT4Qn1/Ia1SZu ohRQfkNhAtvVX8MEdZCzcfpK6/gyWxaao55+d9IjYah2BgZFdnT+9pdpgPNeoFbArf3l YM6StjcbLStQnP79hJTMXF8jwXoY+vdutxBAY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OoDCjuxpFNiBepFgfoMLjFldIJiE4G+lwYGfxB/7O5c=; b=tIGD0TJUW0OJF+CRW9YqTp6mSHHNscrPgN5IhBB6vvr6vkfLfqGeR8v5rjs5HMlgCk hGbEejc72gQIX/10MYuvtkXaaLMa+h36fZuL6b2RNif8eqfyidwRKixj4JIy6YqsaDNp GJYlM6r9faNiVfqvrr9I9yBIuV7wubBRSe5NFNL0NMRMriWrstzaOFkjO8GKKZqvUM0K TUfy/2xdl6IyHKIFnGiaH7QK3rvTanFmN6uU7V9GHZneqXjzx0tiy+a5KjDdqWgEs1En G9dwBA0gIcYjmv8nLyfJ6db9nwpt+djDZNfzeM4qMQmu4FRZZ4htpkVujegq4m3vp4E5 z7DQ== X-Gm-Message-State: AOAM530225DyKCfetD1a+rN/BoIvLdUMcicK0fktZ/Jnli/+8uug2odL VKurXiRl9Dg4Ct79nef7LO7cy2p+oz64Mw== X-Google-Smtp-Source: ABdhPJzybb1LJLaGyJzcbcLYkad6bbEVoglJJ0Llurq/hoawU/eGmdaQ0KMM0ggLdnDg/RoopQGzFw== X-Received: by 2002:a17:90a:e60b:: with SMTP id j11mr14304023pjy.52.1636528936969; Tue, 09 Nov 2021 23:22:16 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:4a73:e1bd:9b3f:4903]) by smtp.gmail.com with ESMTPSA id r1sm5073669pjm.23.2021.11.09.23.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 23:22:16 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Nov 2021 16:22:06 +0900 Message-Id: <20211110072207.3273703-3-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc0.344.g81b53c2807-goog In-Reply-To: <20211110072207.3273703-1-hiroh@chromium.org> References: <20211110072207.3273703-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 3/4] libcamera: camera_sensor: Enable to set a test pattern mode 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" This adds a function to set a camera sensor driver a test pattern mode. Signed-off-by: Hirokazu Honda Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/internal/camera_sensor.h | 8 +++ src/libcamera/camera_sensor.cpp | 64 +++++++++++++++++++--- src/libcamera/control_ids.yaml | 5 ++ 3 files changed, 70 insertions(+), 7 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index edef2220..60ce0c45 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -27,6 +27,9 @@ namespace libcamera { class BayerFormat; class MediaEntity; +class Request; + +struct CameraSensorProperties; class CameraSensor : protected Loggable { @@ -78,10 +81,14 @@ private: &testPatternModeMap); int initProperties(); + int setTestPatternMode(controls::draft::TestPatternModeEnum testPatternMode); + const MediaEntity *entity_; std::unique_ptr subdev_; unsigned int pad_; + const CameraSensorProperties *staticProps_; + std::string model_; std::string id_; @@ -89,6 +96,7 @@ private: std::vector mbusCodes_; std::vector sizes_; std::vector testPatternModes_; + controls::draft::TestPatternModeEnum testPatternMode_; Size pixelArraySize_; Rectangle activeArea_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index f0aa9f24..cfb9bc17 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -17,6 +17,7 @@ #include #include +#include #include @@ -54,8 +55,9 @@ LOG_DEFINE_CATEGORY(CameraSensor) * Once constructed the instance must be initialized with init(). */ CameraSensor::CameraSensor(const MediaEntity *entity) - : entity_(entity), pad_(UINT_MAX), bayerFormat_(nullptr), - properties_(properties::properties) + : entity_(entity), pad_(UINT_MAX), staticProps_(nullptr), + testPatternMode_(controls::draft::TestPatternModeUnset), + bayerFormat_(nullptr), properties_(properties::properties) { } @@ -161,6 +163,10 @@ int CameraSensor::init() if (ret) return ret; + ret = setTestPatternMode(controls::draft::TestPatternModeOff); + if (ret) + return ret; + return 0; } @@ -300,14 +306,14 @@ void CameraSensor::initVimcDefaultProperties() void CameraSensor::initStaticProperties() { - const CameraSensorProperties *props = CameraSensorProperties::get(model_); - if (!props) + staticProps_ = CameraSensorProperties::get(model_); + if (!staticProps_) return; /* Register the properties retrieved from the sensor database. */ - properties_.set(properties::UnitCellSize, props->unitCellSize); + properties_.set(properties::UnitCellSize, staticProps_->unitCellSize); - initTestPatternModes(props->testPatternModes); + initTestPatternModes(staticProps_->testPatternModes); } void CameraSensor::initTestPatternModes( @@ -315,7 +321,15 @@ void CameraSensor::initTestPatternModes( { const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN); if (v4l2TestPattern == controls().end()) { - LOG(CameraSensor, Debug) << "No static test pattern map for \'" + LOG(CameraSensor, Debug) + << "V4L2_CID_TEST_PATTERN is not supported"; + return; + } + + if (testPatternModes.empty()) { + // The camera sensor supports test patterns but we don't know + // how to map them so this should be fixed. + LOG(CameraSensor, Error) << "No static test pattern map for \'" << model() << "\'"; return; } @@ -531,6 +545,42 @@ Size CameraSensor::resolution() const * \return The list of test pattern modes */ +/** + * \brief Set the test pattern mode for the camera sensor + * \param[in] testPatternMode Test pattern mode control value to set the camera + * sensor + * + * \return 0 on success or a negative error code otherwise + */ +int CameraSensor::setTestPatternMode(controls::draft::TestPatternModeEnum testPatternMode) +{ + if (testPatternMode_ == testPatternMode) + return 0; + + if (!staticProps_ || testPatternModes_.empty()) + return 0; + + auto it = std::find(testPatternModes_.begin(), testPatternModes_.end(), + testPatternMode); + if (it == testPatternModes_.end()) { + LOG(CameraSensor, Error) << "Unsupported test pattern mode " + << testPatternMode; + return -EINVAL; + } + + int32_t index = staticProps_->testPatternModes.at(testPatternMode); + ControlList ctrls{ controls() }; + ctrls.set(V4L2_CID_TEST_PATTERN, index); + + int ret = setControls(&ctrls); + if (ret) + return ret; + + testPatternMode_ = testPatternMode; + + return 0; +} + /** * \brief Retrieve the best sensor format for a desired output * \param[in] mbusCodes The list of acceptable media bus codes diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index 9d4638ae..083bac7b 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -639,6 +639,11 @@ controls: Control to select the test pattern mode. Currently identical to ANDROID_SENSOR_TEST_PATTERN_MODE. enum: + - name: TestPatternModeUnset + value: -1 + description: | + No test pattern is set. Returned frames by the camera device are + undefined. - name: TestPatternModeOff value: 0 description: | From patchwork Wed Nov 10 07:22:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14511 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 437B8BF415 for ; Wed, 10 Nov 2021 07:22:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EECBE60371; Wed, 10 Nov 2021 08:22:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="MygaKImK"; dkim-atps=neutral Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 747656036C for ; Wed, 10 Nov 2021 08:22:20 +0100 (CET) Received: by mail-pj1-x102a.google.com with SMTP id x7so774659pjn.0 for ; Tue, 09 Nov 2021 23:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r7f2fGj+mUTwvthsJCh3urmoJouWjESIr9jPyXgtAyw=; b=MygaKImKmaHcPWC/42xcrbv1lFt1dMF9cOefhkBQlUWuwRJQNY0Q4d1mWEjpMKr/Pq GEWgevON3lUwexlkNGwqNf7tdtQBl/z5HNLJYSurFB19oSLM28rC8hpXsXly4FfLJN4Z YfUjKO+E9Uo0mn/cSi1q7Z/+zDosTb5t+89LQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r7f2fGj+mUTwvthsJCh3urmoJouWjESIr9jPyXgtAyw=; b=S6a2QkHEsMB0BqzdFUg2tT7hYNGSdjKB1Vj87mJ0+pbq8hVNgTlAWuLNH35H+PoVON /dsgrH0hFH7Dd82Rs1J0AC1ITQYEynKnlGYSEEe+OUocpHi2kIVxYBr8mayY+aF88qUu oZaCl+ZYQSI8XejdR1PU2Pi40dSvfS8Cs7DtIGl/KLtn3zneG1Ro8QBTy3x+9fta6oCT Lvxn9m7wlAdrj1yfLBZRq8QnfB0yPDWp2Es2kpZ406Z/mQf7Mng5uJAN8t1jd1FG5dZI NTD371d0B8oYEHXvl9rBmSCZoTTDld83qwSTZtSnljIix+ZOWA1z0dSQGk0DHvtLZFeo E4FQ== X-Gm-Message-State: AOAM532FRPhDhQ/OnoBlBGZU/W/dZ9c67g9A/aRhPD+VQX+t89r7E+Hv z/xuPmTXYk1BkmipgsnvGgm+PNxOmTiVJg== X-Google-Smtp-Source: ABdhPJzMMgP5jt3VyflccDSV12XFxvneFeNBB8abU8JEtYZd8Jg5iZHhanYjl1MmDQhhtv9SZQEPqg== X-Received: by 2002:a17:90a:1913:: with SMTP id 19mr14565776pjg.174.1636528938796; Tue, 09 Nov 2021 23:22:18 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:4a73:e1bd:9b3f:4903]) by smtp.gmail.com with ESMTPSA id r1sm5073669pjm.23.2021.11.09.23.22.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 23:22:18 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 10 Nov 2021 16:22:07 +0900 Message-Id: <20211110072207.3273703-4-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc0.344.g81b53c2807-goog In-Reply-To: <20211110072207.3273703-1-hiroh@chromium.org> References: <20211110072207.3273703-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 4/4] libcamera: pipeline: ipu3: Apply the requested test pattern mode 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" This enables ipu3 pipeline handler to apply the test pattern mode per frame. Signed-off-by: Hirokazu Honda Reviewed-by: Jean-Michel Hautbois --- include/libcamera/internal/camera_sensor.h | 1 + src/libcamera/camera_sensor.cpp | 34 ++++++++++++++++++++++ src/libcamera/pipeline/ipu3/ipu3.cpp | 29 ++++++++++++++++-- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 60ce0c45..ed782476 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -58,6 +58,7 @@ public: const ControlInfoMap &controls() const; ControlList getControls(const std::vector &ids); int setControls(ControlList *ctrls); + int applyRequestControls(Request *request); V4L2Subdevice *device() { return subdev_.get(); } diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index cfb9bc17..a20f3d95 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -755,6 +755,40 @@ int CameraSensor::setControls(ControlList *ctrls) return subdev_->setControls(ctrls); } +/** + * \brief Apply controls associated with Request + * \param[in] request Request that may contain contorls to be applied + * + * Some controls have to be applied for a capture associated with Request. + * This picks up such controls and set the driver them. + * + * \return 0 on success or an error code otherwise + */ +int32_t CameraSensor::applyRequestControls(Request *request) +{ + /* Assumes applying the test pattern mode affects immediately. */ + if (request->controls().contains(controls::draft::TestPatternMode)) { + const int32_t testPatternMode = request->controls().get( + controls::draft::TestPatternMode); + + LOG(CameraSensor, Debug) << "Apply test pattern mode: " + << testPatternMode; + + int ret = setTestPatternMode( + static_cast(testPatternMode)); + if (ret) { + LOG(CameraSensor, Error) + << "Failed to set test pattern mode: " << ret; + return ret; + } + + request->metadata().set(controls::draft::TestPatternMode, + testPatternMode); + } + + return 0; +} + /** * \fn CameraSensor::device() * \brief Retrieve the camera sensor device diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 63cb7f11..f4137f2d 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -59,6 +59,7 @@ public: void statBufferReady(FrameBuffer *buffer); void queuePendingRequests(); void cancelPendingRequests(); + void frameStart(uint32_t sequence); CIO2Device cio2_; ImgUDevice *imgu_; @@ -77,7 +78,10 @@ public: std::unique_ptr ipa_; + /* Requests before queueing cio2 device. */ std::queue pendingRequests_; + /* Requests queued in cio2 device and before passing imgu device. */ + std::queue processingRequests_; ControlInfoMap ipaControls_; @@ -802,6 +806,7 @@ void PipelineHandlerIPU3::stop(Camera *camera) ret |= data->imgu_->stop(); ret |= data->cio2_.stop(); + if (ret) LOG(IPU3, Warning) << "Failed to stop camera " << camera->id(); @@ -822,6 +827,8 @@ void IPU3CameraData::cancelPendingRequests() pipe()->completeRequest(request); pendingRequests_.pop(); } + + processingRequests_ = {}; } void IPU3CameraData::queuePendingRequests() @@ -852,6 +859,8 @@ void IPU3CameraData::queuePendingRequests() info->rawBuffer = rawBuffer; + processingRequests_.push(request); + ipa::ipu3::IPU3Event ev; ev.op = ipa::ipu3::EventProcessControls; ev.frame = info->id; @@ -1131,8 +1140,8 @@ int PipelineHandlerIPU3::registerCameras() data->delayedCtrls_ = std::make_unique(cio2->sensor()->device(), params); - data->cio2_.frameStart().connect(data->delayedCtrls_.get(), - &DelayedControls::applyControls); + data->cio2_.frameStart().connect(data.get(), + &IPU3CameraData::frameStart); /* Convert the sensor rotation to a transformation */ int32_t rotation = 0; @@ -1423,6 +1432,22 @@ void IPU3CameraData::statBufferReady(FrameBuffer *buffer) ipa_->processEvent(ev); } +void IPU3CameraData::frameStart(uint32_t sequence) +{ + if (!processingRequests_.empty()) { + /* Handle controls which are to be set ready for the next frame to start. */ + Request *request = processingRequests_.front(); + processingRequests_.pop(); + + int ret = cio2_.sensor()->applyRequestControls(request); + if (ret) + LOG(IPU3, Error) << "Failed applying controls: " << ret; + } + + /* Controls that don't affect immediately are applied in delayedCtrls. */ + delayedCtrls_->applyControls(sequence); +} + REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3) } /* namespace libcamera */