From patchwork Fri May 28 03:05:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12466 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 9D7CDC3207 for ; Fri, 28 May 2021 03:05:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5CB3268933; Fri, 28 May 2021 05:05:46 +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="n65a2hhU"; dkim-atps=neutral Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0564868929 for ; Fri, 28 May 2021 05:05:43 +0200 (CEST) Received: by mail-pg1-x531.google.com with SMTP id i5so1519963pgm.0 for ; Thu, 27 May 2021 20:05:42 -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=L7UhLYlZoGGrSQ1X2nz/Pg5KvfexOUFGt+cI8mulf+w=; b=n65a2hhUPQmec+LMBb5av2t5r8GLQMUO12/3xrFYRRNaIHaf2k0ZBErN6HXoy+XmMj 6L0cKhVVHMxBTbSuk5O6DNZrLhdxrpAFMLSukp/hsuV7kXzgTyGLET68A7YWJISQL67U CVDDgq4yPQ+5YuRS20YevOPFWxTL3dh1EjT0w= 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=L7UhLYlZoGGrSQ1X2nz/Pg5KvfexOUFGt+cI8mulf+w=; b=obLiQ/tEvGv1fhUrUFOOcYwLlpStn+gaZUmLIn0iZHbk5vEP7wc9oJ+eamZGZxsju9 c3Mj9czHycp6J802/l71xwjnC/ty8sEQ9I54Yx+jNGMIHhTr5dBRgrytFNhJb2o/jfIL EaChTnwetYNxFDPn5q+WjwSH5nFq/Fmk2gF5CyqhHTitwtHimsNxF4pia4u99dHIXgOj idrcmbZPG/oICxlX84pZ+Jxfc5paP9mLGOGVrG15BrdqWeN/rCHCc+8OHOOXQVpQkSgr IdXFVk7tfnVb3xgcqRh0g77gPv5hXph/deX9Bzg0BUPGtDk2umDL4P+OHTPKffPqZmVC Wg0Q== X-Gm-Message-State: AOAM533tSV/5WzOWGp6YRPt3s0EE9/0wNPbMDeps+BuVKRSlRZ7RZTbA sRL49sEVwufDmsfQti4u3DqnK9foftuoFg== X-Google-Smtp-Source: ABdhPJwFhRBNeAswO3LoIYStLkcINQYF4bCGLR1El/53OP39Lm68hOfSgX+HqeGeYmTMV4PpnGYjUA== X-Received: by 2002:a63:b64:: with SMTP id a36mr6758171pgl.437.1622171141361; Thu, 27 May 2021 20:05:41 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:caec:ab3b:ea16:3d01]) by smtp.gmail.com with ESMTPSA id l20sm2892051pjq.38.2021.05.27.20.05.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 20:05:40 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 28 May 2021 12:05:29 +0900 Message-Id: <20210528030531.189492-4-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog In-Reply-To: <20210528030531.189492-1-hiroh@chromium.org> References: <20210528030531.189492-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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 Reviewed-by: Laurent Pinchart --- include/libcamera/internal/camera_sensor.h | 7 +++++ src/libcamera/camera_sensor.cpp | 32 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index cf6c1c1e..dcde647d 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -39,6 +39,10 @@ public: const std::vector &mbusCodes() const { return mbusCodes_; } const std::vector &sizes() const { return sizes_; } Size resolution() const; + const std::vector &testPatternModes() const + { + return testPatternModes_; + } V4L2SubdeviceFormat getFormat(const std::vector &mbusCodes, const Size &size) const; @@ -66,6 +70,8 @@ private: void initVimcDefaultProperties(); void initStaticProperties(); int initProperties(); + void initTestPatternModes( + const std::map &testPatternModeMap); const MediaEntity *entity_; std::unique_ptr subdev_; @@ -77,6 +83,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 0fb8a258..44dd5988 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -297,6 +297,30 @@ 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 << " ignored"; + continue; + } + + testPatternModes_.push_back(it->second); + } +} + void CameraSensor::initStaticProperties() { const CameraSensorProperties *props = CameraSensorProperties::get(model_); @@ -305,6 +329,8 @@ void CameraSensor::initStaticProperties() /* Register the properties retrieved from the sensor database. */ properties_.set(properties::UnitCellSize, props->unitCellSize); + + initTestPatternModes(props->testPatternModeMap); } int CameraSensor::initProperties() @@ -469,6 +495,12 @@ Size CameraSensor::resolution() const return std::min(sizes_.back(), activeArea_.size()); } +/** + * \fn CameraSensor::testPatternModes() + * \brief Retrieve all the supported test pattern modes of the camera sensor + * \return The list of test pattern modes + */ + /** * \brief Retrieve the best sensor format for a desired output * \param[in] mbusCodes The list of acceptable media bus codes