From patchwork Wed Apr 28 07:36:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12128 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 60A80BDE44 for ; Wed, 28 Apr 2021 07:36:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19B8A688C2; Wed, 28 Apr 2021 09:36:36 +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="XnN+XEDX"; dkim-atps=neutral Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3245E688C7 for ; Wed, 28 Apr 2021 09:36:32 +0200 (CEST) Received: by mail-pj1-x102f.google.com with SMTP id k3-20020a17090ad083b0290155b934a295so2181670pju.2 for ; Wed, 28 Apr 2021 00:36:32 -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=4SL2EcLkX9gZT8o1MSisScpd/e0VL4ERGSUlnE+efPs=; b=XnN+XEDX7ctn8yiPZ+6hBfHIDmz1CGOQKbgGzEcVZkgMYzGddp+RjKusxXY6x+BVuD MK+y3E+wM6DPK795LrghneoHY8xnq0iyjAh9YOx6ZEm9AaUnzL0y6VEJHqVLLIdhjIlf nDr1140/Quie8+wgP048IlubtYjBBG+JzGmrA= 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=4SL2EcLkX9gZT8o1MSisScpd/e0VL4ERGSUlnE+efPs=; b=DUTaY9x8sMh9wrnzknCHpGZhXd6Lsq8FM0+wTpjJTUmpfIxC7MVj/UnrXgKNH+Psk6 QSjAv6tITMiXmzpDn7Y/NnMA5xU3zXJDy4S6qDZiULlIXt7w9HLTGIINk8fZ7VF7hZhK W1xxc8dCWTNWJNSSOUezCBPGdqj0ebcl1klMuJ6k41cjpT6UDk4CPmGq2IvMJttU1r6Y lLLXj4FpRlb7USJFJP4X1iZ9kWnMdswoA449I4COsqVtWfZ+gKsS2je4sXgvNM7zrPu8 cT5lodoTWpLzXGScIE6OY7UFxzAkgbGFlkdl52nw59Pab+VDOa5pBPg3OtvcSn0ut21C w7bg== X-Gm-Message-State: AOAM530oirXob8WTeCgRN+ecdDnlNGuoIBm5E4HrT/HzmbnKLbx3k8mI LwicTXyu+L5WwHZPSuwqziMsHnhDkSCg2A== X-Google-Smtp-Source: ABdhPJxC3VYL7v+CQO456NYpwem7fXvgRRUIxC6gS0nq3U7lRmgOZzvgCfqTItyVpun1n0yYBvseAg== X-Received: by 2002:a17:90b:4ac1:: with SMTP id mh1mr2535892pjb.95.1619595390460; Wed, 28 Apr 2021 00:36:30 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:489:a5f4:117:7d51]) by smtp.gmail.com with ESMTPSA id m11sm1661265pgs.4.2021.04.28.00.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:36:30 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Apr 2021 16:36:15 +0900 Message-Id: <20210428073617.373422-6-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210428073617.373422-1-hiroh@chromium.org> References: <20210428073617.373422-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/7] 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 | 40 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 3fa3a419..eec37a54 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 850c94b3..a5c0fff7 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -411,6 +411,42 @@ 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; + } + + const std::vector &indices = v4l2TestPattern->second.values(); + const std::vector &names = v4l2TestPattern->second.extraValues(); + if (indices.size() != names.size()) { + LOG(CameraSensor, Error) + << "The number of indices and names are different" + << ", indices.size()=" << indices.size() + << ", names.size()=" << names.size(); + return; + } + + for (const ControlValue &value : names) { + const std::string &name = value.get(); + + const auto it = testPatternModeMap.find(name); + if (it != testPatternModeMap.end()) { + LOG(CameraSensor, Debug) << "Test pattern mode named \'" + << name << "\' ignored"; + continue; + } + + LOG(CameraSensor, Debug) << "Test pattern mode named \'" + << name << "\' added"; + testPatternModes_.push_back(it->second); + } +} + void CameraSensor::initStaticProperties() { const SensorInfo *info = SensorDatabase::get(model_); @@ -424,6 +460,8 @@ void CameraSensor::initStaticProperties() /* Register the properties retrieved from the sensor database. */ properties_.set(properties::UnitCellSize, info->unitCellSize); + + initTestPatternModes(info->testPatternModeMap); } int CameraSensor::initProperties() @@ -840,6 +878,8 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const info->minFrameLength = info->outputSize.height + vblank.min().get(); info->maxFrameLength = info->outputSize.height + vblank.max().get(); + info->testPatternModes = testPatternModes_; + return 0; }