From patchwork Thu May 6 07:54:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12203 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 3F537BDE7F for ; Thu, 6 May 2021 07:55:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 03EFD6891A; Thu, 6 May 2021 09:55:06 +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="Ilmu2rLk"; dkim-atps=neutral Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 083DC68909 for ; Thu, 6 May 2021 09:55:04 +0200 (CEST) Received: by mail-pl1-x631.google.com with SMTP id e2so2963928plh.8 for ; Thu, 06 May 2021 00:55:03 -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=Nnxe3t/m2aQ4jveD/IHf+jGScVBJRRDKzf8zxTd2kDs=; b=Ilmu2rLkjHDIXUntkC/LGsUU+2KzTdL8vVyX2/PWmaXqF5DxtL6d4guO0rjkNRBzzp Gm6VcdTsw2h2FFqPpYEK7Icwf9dUjpnTjhdkKuGqZOqjFhNcJmBwuPlM4b6cg38clGaN 7O00piwp7gXw88MbnzqwpH5ASrRarYc6UbiNw= 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=Nnxe3t/m2aQ4jveD/IHf+jGScVBJRRDKzf8zxTd2kDs=; b=TOaCxy2+/F5TjUZ1xLwkX57pYAEZDLWJ42eidjmC1rR/e1jxqnlMr0ahE5mFgR2tF2 hS5eHdnkpzHB5Bq2DeVqc5G2HqunU1E4bDM4DzBiLyQxLwGsLn6fGBLMH0O7EqH0Hcxd k19v8xmicJB9W9AOMecyGRb0CxWZfwJLc8ZaE2413nDGIX/EFj+mPekcawxmovSLyr25 Exld0qN/PjhztzkNWn13yyPDcaAyEOULTVhXLHw/FhunQKabNpgEuelVHbgPofJZ/J9o nNhsItgyMbNyW0GTYIV8c3LR72N04Ac5yceuU9V9p2HNtR3KQowzkv4oVpADOe04+Ljq qSGw== X-Gm-Message-State: AOAM533XD6//XxK4Tc2NNcRrNshR3ABxv73QCSHJxLSZxoCh+bA7nLm1 0VPw4oKVZufHvLZ8GymHdyJtCdUwvwlsRw== X-Google-Smtp-Source: ABdhPJy53gPvbfGJhsPbWH1pGxLJDyGGhDCljoNxcaqo1GsGYJ8p40E0ICKLFK6Jm5ZlzbN1K3MY1A== X-Received: by 2002:a17:902:778d:b029:ee:f821:f56d with SMTP id o13-20020a170902778db02900eef821f56dmr3285525pll.79.1620287701793; Thu, 06 May 2021 00:55:01 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:ede4:ae0e:d4a4:c0d3]) by smtp.gmail.com with ESMTPSA id f201sm1355546pfa.133.2021.05.06.00.55.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 May 2021 00:55:01 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 6 May 2021 16:54:47 +0900 Message-Id: <20210506075449.1761752-5-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog In-Reply-To: <20210506075449.1761752-1-hiroh@chromium.org> References: <20210506075449.1761752-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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 --- include/libcamera/internal/camera_sensor.h | 5 ++++ src/libcamera/camera_sensor.cpp | 28 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 3fa3a419..115e266d 100644 --- a/include/libcamera/internal/camera_sensor.h +++ b/include/libcamera/internal/camera_sensor.h @@ -38,6 +38,8 @@ struct CameraSensorInfo { uint32_t minFrameLength; uint32_t maxFrameLength; + + std::vector testPatternModes; }; class CameraSensor : protected Loggable @@ -79,6 +81,8 @@ private: void initVimcDefaultProperties(); void initStaticProperties(); int initProperties(); + void initTestPatternModes( + const std::map &testPatternModeMap); const MediaEntity *entity_; std::unique_ptr subdev_; @@ -90,6 +94,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 1db263cf..eedd2f89 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()