From patchwork Thu Jun 10 08:25:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12548 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 8296ABD78E for ; Thu, 10 Jun 2021 08:25:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 458D468939; Thu, 10 Jun 2021 10:25:53 +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="LCeEBi6c"; dkim-atps=neutral Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA36E68935 for ; Thu, 10 Jun 2021 10:25:51 +0200 (CEST) Received: by mail-pg1-x52d.google.com with SMTP id y11so13856038pgp.11 for ; Thu, 10 Jun 2021 01:25:51 -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=LCeEBi6c2jhhWVy5qCkNDb5KobY9t6hZhyU2F2AJnmQcBPEKf5DKqZR560AqVhQNW0 CJPBUes7Lc/6dcgX0JiL1YhSSNMoBI3CSq4lxWRZyPvm2owM/Xjj9yYI/h/uhcHLInps dfVT92wyw/3QrleS6CqVspzqmI5sJ297pOP74= 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=tdhfQfKLwSXaKBzQJw5fzuE9B+6yj4y8i7Tv73ANSxOpMSH/zXSrcb2J5M8GnYZEwq jK1/JTk4omHxk2b853q5PLP+sxLcuZA6Umv+QVljZ9BYShnv1MzMZb2Z3AF/n1+ikBdF XbroVgOxVBz/J5iYwPUqSzo0RwebWDSoZOwHlqFFM0Z338W1rhtw67L+5kRQQzoZqZxW WeFXhm3hGb/hVXv4wvKeNtb0AH6Bkw1V9hPFK5tG4byfpENPmBBXGfcjZixy2S9R6Bua E3wwfVO9pYvtiZQSEiJfwiye62tKqzzg5IKnHMzA/Mc7skP+yTYvZ4WNW2TaE3QEMY6z 7yPg== X-Gm-Message-State: AOAM533+6dWk9/3pgFdmZ8F/w8bY199VLQHDlF/3QrHDGh9/gap7fk9r 6yG7JzQRsBKMU56keqscDBESohnpsTnUmQ== X-Google-Smtp-Source: ABdhPJx1Glb6NzJ4+eGOAL+2DEl1hcLbjp4oGYv9yS0bkxKvHlFa+b5W7dlBHxmGV1cEWrZM09yp8A== X-Received: by 2002:a63:ec03:: with SMTP id j3mr3825560pgh.272.1623313550371; Thu, 10 Jun 2021 01:25:50 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:98e0:b356:1c8a:25d4]) by smtp.gmail.com with ESMTPSA id x3sm2087011pgx.8.2021.06.10.01.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Jun 2021 01:25:49 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 10 Jun 2021 17:25:37 +0900 Message-Id: <20210610082539.529739-4-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.rc1.229.g3e70b5a671-goog In-Reply-To: <20210610082539.529739-1-hiroh@chromium.org> References: <20210610082539.529739-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 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