From patchwork Tue Jun 22 02:36:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12672 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 04ECCC321B for ; Tue, 22 Jun 2021 02:37:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 77A2F6893A; Tue, 22 Jun 2021 04:37:03 +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="d8OqXYYT"; 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 814A668931 for ; Tue, 22 Jun 2021 04:37:01 +0200 (CEST) Received: by mail-pg1-x52d.google.com with SMTP id h4so4333929pgp.5 for ; Mon, 21 Jun 2021 19:37:01 -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:mime-version :content-transfer-encoding; bh=Zz7WzGYUO2IB6wWWddKhE1Rv1w/g7DqXt0ZLxY9iGXE=; b=d8OqXYYTsRnNgJDB/4pdmW2MrlF0SbjGExax+FzNpe1xpbIkR6djtkhs/1Nm0AGD2p MQGwDu2WbEVUEvs/iiL/WcVBZMWKc/3wZGlDFiRgTl7n1iiB125llizrfF9N0N+fqjkV kqUFhTJfHyQeouvtjggxQOvBUMTsOAXU/Q5YY= 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:mime-version :content-transfer-encoding; bh=Zz7WzGYUO2IB6wWWddKhE1Rv1w/g7DqXt0ZLxY9iGXE=; b=UGF7LKI3vAshTKCk34944XcbE8MqYWeZ1an08XLAmrwRGvtNPXXCMgTQqVQFS5HbMs PBD1/kFAyVdavCcvDys/dfuyGwFSvoasDF1ipBa3867rh6eQ2Hj9QnR21ty/yHh6vnwg xdslPBPHqqMozROHtrqslFJtPsUQ+L9WtFIHLxcfQB5Gcd0a9oI22s0PS8vHe3RdJByg vpC39hIjW0GQVOwR4sxjp2t4iHrTzgzWnyVUoIbGVX8UmNZN5sM3FCelhPnqs53inDMh sku98X16cRIViptp3p67kb1ZPLU49H7dlNcCYgluHi0JPWjjeHDNPgw/WqsulUmkQnhg Ct1A== X-Gm-Message-State: AOAM530CSGDNQZyCHl8JYJyk3T4TkfEC0dgfpBseVqvRGdlvvwKDyUFp Lqs9RIkAIo5bA4Vhe08vVg5PYFU8zfuHQg== X-Google-Smtp-Source: ABdhPJzV8Q5erra/3Wz73Qi2qEwUmlyxO2f3IDkEBg0+TXdZyH0b/kdDt6rgcWVUcla+PkIzVzyCCg== X-Received: by 2002:a63:4815:: with SMTP id v21mr1477813pga.213.1624329419456; Mon, 21 Jun 2021 19:36:59 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:a025:f98b:b63b:e6b2]) by smtp.gmail.com with ESMTPSA id o7sm18947145pgs.45.2021.06.21.19.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 19:36:59 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Jun 2021 11:36:50 +0900 Message-Id: <20210622023654.969162-1-hiroh@chromium.org> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 1/5] libcamera: camera_sensor: Reverse the key and value of test pattern mode map 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" The key and value of the test pattern mode are originally the index of v4l2 control and the corresponding test pattern mode control value. This key and value are useful in the initialization for reporting available test pattern modes. However, the map of the reversed key and value is much more useful in applying a requested test pattern mode. Reverses the key and value of the map as the initialization is one time but the test pattern mode request will be multiple times. Signed-off-by: Hirokazu Honda Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/libcamera/camera_sensor.cpp | 8 +++++-- src/libcamera/camera_sensor_properties.cpp | 28 +++++++++++----------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 3e135353..70bbd97a 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -319,11 +319,15 @@ void CameraSensor::initTestPatternModes( return; } + std::map indexToTestPatternMode; + for (const auto& it : testPatternModes) + indexToTestPatternMode[it.second] = it.first; + for (const ControlValue &value : v4l2TestPattern->second.values()) { const int32_t index = value.get(); - const auto it = testPatternModes.find(index); - if (it == testPatternModes.end()) { + const auto it = indexToTestPatternMode.find(index); + if (it == indexToTestPatternMode.end()) { LOG(CameraSensor, Debug) << "Test pattern mode " << index << " ignored"; continue; diff --git a/src/libcamera/camera_sensor_properties.cpp b/src/libcamera/camera_sensor_properties.cpp index f660743a..d0b2ae0e 100644 --- a/src/libcamera/camera_sensor_properties.cpp +++ b/src/libcamera/camera_sensor_properties.cpp @@ -38,9 +38,9 @@ LOG_DEFINE_CATEGORY(CameraSensorProperties) * \brief The physical size of a pixel, including pixel edges, in nanometers. * * \var CameraSensorProperties::testPatternModes - * \brief Map that associates the indexes of the sensor test pattern modes as - * returned by V4L2_CID_TEST_PATTERN with the corresponding TestPattern - * control value + * \brief Map that associates the TestPattern control value with the indexes of + * the corresponding sensor test pattern modes as returned by + * V4L2_CID_TEST_PATTERN. */ /** @@ -55,11 +55,11 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { "imx219", { .unitCellSize = { 1120, 1120 }, .testPatternModes = { - { 0, controls::draft::TestPatternModeOff }, - { 1, controls::draft::TestPatternModeColorBars }, - { 2, controls::draft::TestPatternModeSolidColor }, - { 3, controls::draft::TestPatternModeColorBarsFadeToGray }, - { 4, controls::draft::TestPatternModePn9 }, + { controls::draft::TestPatternModeOff, 0 }, + { controls::draft::TestPatternModeColorBars, 1 }, + { controls::draft::TestPatternModeSolidColor, 2 }, + { controls::draft::TestPatternModeColorBarsFadeToGray, 3 }, + { controls::draft::TestPatternModePn9, 4 }, }, } }, { "imx258", { @@ -70,22 +70,22 @@ const CameraSensorProperties *CameraSensorProperties::get(const std::string &sen { "ov5670", { .unitCellSize = { 1120, 1120 }, .testPatternModes = { - { 0, controls::draft::TestPatternModeOff }, - { 1, controls::draft::TestPatternModeColorBars }, + { controls::draft::TestPatternModeOff, 0 }, + { controls::draft::TestPatternModeColorBars, 1 }, }, } }, { "ov13858", { .unitCellSize = { 1120, 1120 }, .testPatternModes = { - { 0, controls::draft::TestPatternModeOff }, - { 1, controls::draft::TestPatternModeColorBars }, + { controls::draft::TestPatternModeOff, 0 }, + { controls::draft::TestPatternModeColorBars, 1 }, }, } }, { "ov5693", { .unitCellSize = { 1400, 1400 }, .testPatternModes = { - { 0, controls::draft::TestPatternModeOff }, - { 2, controls::draft::TestPatternModeColorBars }, + { controls::draft::TestPatternModeOff, 0 }, + { controls::draft::TestPatternModeColorBars, 2 }, /* * No corresponding test pattern mode for * 1: "Random data" and 3: "Colour Bars with