From patchwork Mon Jun 7 01:14:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12497 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 CC742C320B for ; Mon, 7 Jun 2021 01:14:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 88F336892E; Mon, 7 Jun 2021 03:14:16 +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="fa5fgOa7"; dkim-atps=neutral Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BE42268926 for ; Mon, 7 Jun 2021 03:14:13 +0200 (CEST) Received: by mail-pg1-x529.google.com with SMTP id 6so12570891pgk.5 for ; Sun, 06 Jun 2021 18:14:13 -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=9K5PveEwZBbwwCEIhfIir0TSqZrkTwudduhTEgwn/MQ=; b=fa5fgOa7KHxQ1wgyMgKnAKT9O8tLHBGVLI8rZkoZjx6j7wx3B3zXfxoOCSYTu1de2J xFtF8ZVTCH8+wSR4+xw86P0I4CcG/a0hsCHIw5E/MLB5xap0orNJoDv9MY4mXJJUuC6n xkzXYIcH/btC1y4RTWCayCvJB6s966GCAqr4U= 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=9K5PveEwZBbwwCEIhfIir0TSqZrkTwudduhTEgwn/MQ=; b=QFsr2FyxmJqAJk0S8ZxBifaUPhXu4TIdw2QSiwDs0g7SRkzm0eYRCiMT5LOlP8K5Y8 3riKh7y4K4b3ZVyEW1ZPziqmOzNAsEXmFc8TDYke46zYq2lapz8zEVbAF6EbNuRTwTCw YKr9TRwCPb1GoSk1Bg7hHlI5GmFw+uC6T4ivKwg13Tgsg65AviZoWsM0mvKg1yQmMAxV g3AQAOb8wNk03BVjKsxflPNJhahmKX2F75IKxAER19Y4VooNibLfGa6VGJ7BJtPX+XQN YZ3fTPTWJxoCWfMoEL+cMYsa41xSX5Y2IDIFglXEc6lW7iDGKOTXSORpLdLJvfrJoKNF /FEQ== X-Gm-Message-State: AOAM531ywTzHZAGg9qBNmbtzEmjHFn7ChcBoY3IDY4lwuk7sPqIilDHn hTxM3754vTkndFwzL+OZX7QDr8zFoSmBJm4+ X-Google-Smtp-Source: ABdhPJxJqj+AaOP8r4T499LtOJnmYYcYcDzzScuZ30bt+wmif7kpX1ugP0gtOm6+CQOetA/dXSig4Q== X-Received: by 2002:aa7:8e5a:0:b029:2e9:10d3:376f with SMTP id d26-20020aa78e5a0000b02902e910d3376fmr15039237pfr.19.1623028452238; Sun, 06 Jun 2021 18:14:12 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:6eb1:2d91:79ee:2043]) by smtp.gmail.com with ESMTPSA id h12sm7303655pgn.54.2021.06.06.18.14.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Jun 2021 18:14:11 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 7 Jun 2021 10:14:00 +0900 Message-Id: <20210607011402.55331-4-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog In-Reply-To: <20210607011402.55331-1-hiroh@chromium.org> References: <20210607011402.55331-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v7 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 | 34 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index cf6c1c1e..e133ebf4 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; @@ -65,6 +69,8 @@ private: int validateSensorDriver(); void initVimcDefaultProperties(); void initStaticProperties(); + void initTestPatternModes( + const std::map &testPatternModeMap); int initProperties(); const MediaEntity *entity_; @@ -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..3e135353 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -305,6 +305,32 @@ void CameraSensor::initStaticProperties() /* Register the properties retrieved from the sensor database. */ properties_.set(properties::UnitCellSize, props->unitCellSize); + + initTestPatternModes(props->testPatternModes); +} + +void CameraSensor::initTestPatternModes( + const std::map &testPatternModes) +{ + 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 = testPatternModes.find(index); + if (it == testPatternModes.end()) { + LOG(CameraSensor, Debug) + << "Test pattern mode " << index << " ignored"; + continue; + } + + testPatternModes_.push_back(it->second); + } } int CameraSensor::initProperties() @@ -469,6 +495,14 @@ 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 + * The test pattern mode values correspond to the controls::TestPattern control. + * + * \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