From patchwork Wed May 19 07:59:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12318 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 4E6D4C31FF for ; Wed, 19 May 2021 07:59:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0D9B068922; Wed, 19 May 2021 09:59:56 +0200 (CEST) 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="Xr1YNuIE"; dkim-atps=neutral Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0A90668911 for ; Wed, 19 May 2021 09:59:54 +0200 (CEST) Received: by mail-pl1-x636.google.com with SMTP id t4so6561684plc.6 for ; Wed, 19 May 2021 00:59:53 -0700 (PDT) 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=ca7p7pwmIpKOHnXcAv//FM45O9IVcfFgEJGNcZtP60A=; b=Xr1YNuIEUV4IGFyro8BbVnhfRu+bYZ337eb+CMaP8G2kjyrK3QbOdWpWp59NJxIw4u mgvnxY85H42yfPfTRdjPisWg8KXiinPyNLx4/XCdCt0r2fRf/REptnwNeXIM86KJQ+GD dfrDysIRxBcJeGElMxwR9V9iODExET9sOXfkU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ca7p7pwmIpKOHnXcAv//FM45O9IVcfFgEJGNcZtP60A=; b=Yo8OXhpo/OtD6ozlUVSjWcAa1vxdLRq4Z6TN4Dp13K+cZkxFV5hGX/rEdkhh9pqxLJ A8liouOy1vG56/N7RbIng73EkskoSQlXhRJpc8QTnU9UmcsqFoWDx2HlyW8tta+DiU/r 6iM9JRPGIk2ZiJzx3Yi5sa2RyY2ksom4HKuTLwx+8HO0lIR+2s/sb/MgMHCtV3CRh+xc 7sA/eFsriKipb1Fz1beqt5/JYQgueava3JikwHPgJ51YotqUwwlujma3BfdD3YpFZfD3 f2JJ78/krgYlGHifYmn5q1Sdt14cnrrAqLolDMB+OGCZT2e7SHbk7w/CtoUqI5DCAfDY qJ0A== X-Gm-Message-State: AOAM533Ywaj6Wk7yHw3pdbrTPzQugHGPpT3uaOYsb7gdUkz1843NNaQC ClV70/VgyrTRZ0Ax/ipQo4q74DT3OwPmcQ== X-Google-Smtp-Source: ABdhPJzhq3ceDaJyuQWBlGNsQKQpRUD61Pw7l6JZ4N66LiBd9ZUiW+AIudIHEoUfa+ntQ1y8wYS/xg== X-Received: by 2002:a17:902:854a:b029:ef:3f99:91a7 with SMTP id d10-20020a170902854ab02900ef3f9991a7mr9628927plo.74.1621411192184; Wed, 19 May 2021 00:59:52 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:3948:91a2:b8ec:1976]) by smtp.gmail.com with ESMTPSA id 80sm1160847pfw.200.2021.05.19.00.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 00:59:51 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 19 May 2021 16:59:39 +0900 Message-Id: <20210519075941.1337388-4-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.751.gd2f1c929bd-goog In-Reply-To: <20210519075941.1337388-1-hiroh@chromium.org> References: <20210519075941.1337388-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 4/6] libcamera: CameraSensor: Enable retrieving supported test pattern modes 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 retrieving supported test pattern modes through CameraSensorInfo. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi --- include/libcamera/internal/camera_sensor.h | 7 +++++ src/libcamera/camera_sensor.cpp | 34 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 2a5c51a1..59d1188f 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -58,6 +58,10 @@ public: V4L2SubdeviceFormat getFormat(const std::vector &mbusCodes, const Size &size) const; int setFormat(V4L2SubdeviceFormat *format); + const std::vector &testPatternModes() const + { + return testPatternModes_; + } const ControlInfoMap &controls() const; ControlList getControls(const std::vector &ids); @@ -81,6 +85,8 @@ private: void initVimcDefaultProperties(); void initStaticProperties(); int initProperties(); + void initTestPatternModes( + const std::map &testPatternModeMap); const MediaEntity *entity_; std::unique_ptr subdev_; @@ -92,6 +98,7 @@ private: V4L2Subdevice::Formats formats_; std::vector mbusCodes_; std::vector sizes_; + std::vector testPatternModes_; Size pixelArraySize_; Rectangle activeArea_; diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index eb84d9eb..a6aed417 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -408,6 +408,32 @@ void CameraSensor::initVimcDefaultProperties() activeArea_ = Rectangle(pixelArraySize_); } +void CameraSensor::initTestPatternModes( + const std::map &testPatternModeMap) +{ + const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN); + if (v4l2TestPattern == controls().end()) { + LOG(CameraSensor, Debug) << "No static test pattern map for \'" + << model() << "\'"; + return; + } + + for (const ControlValue &value : v4l2TestPattern->second.values()) { + const int32_t index = value.get(); + + const auto it = testPatternModeMap.find(index); + if (it != testPatternModeMap.end()) { + LOG(CameraSensor, Debug) << "Test pattern mode (index=" + << index << ") ignored"; + continue; + } + + LOG(CameraSensor, Debug) << "Test pattern mode (index=" + << index << ") added"; + testPatternModes_.push_back(it->second); + } +} + void CameraSensor::initStaticProperties() { const CameraSensorProperties *props = CameraSensorProperties::get(model_); @@ -416,6 +442,8 @@ void CameraSensor::initStaticProperties() /* Register the properties retrieved from the sensor database. */ properties_.set(properties::UnitCellSize, props->unitCellSize); + + initTestPatternModes(props->testPatternModeMap); } int CameraSensor::initProperties() @@ -767,6 +795,12 @@ int CameraSensor::setControls(ControlList *ctrls) * \return The list of camera sensor properties */ +/** + * \fn CameraSensor::testPatternModes() + * \brief Retrieve all the supported test pattern modes of the camera sensor + * \return The list of test pattern modes. + */ + /** * \brief Assemble and return the camera sensor info * \param[out] info The camera sensor info