From patchwork Tue Apr 13 07:50:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11903 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 2166DBD224 for ; Tue, 13 Apr 2021 07:50:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D2E3C68804; Tue, 13 Apr 2021 09:50:34 +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="YNujL2sQ"; dkim-atps=neutral Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9D3C1687FF for ; Tue, 13 Apr 2021 09:50:32 +0200 (CEST) Received: by mail-pf1-x42f.google.com with SMTP id i190so10887614pfc.12 for ; Tue, 13 Apr 2021 00:50: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=3hSgGx1cbP3KI7myLORs12z6yfh34QoYFMukHPMp0PY=; b=YNujL2sQmmGBC0adVaUlrH05ckirDBFSaXifh+OoKJYXK4ihXwBfbqI2N0grsSbTTM uz+6ROuaox7FWjDsQxgGKFofqUiF0YFlFSERT49ty5a1qOt8Wr/kpoUDCwL9+WKDMEW5 oNAI6Jl6Y6nSPnc6SRP4JFVB7MbKMYMvNcAPM= 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=3hSgGx1cbP3KI7myLORs12z6yfh34QoYFMukHPMp0PY=; b=fBJP2Onla/+4HLeQedKjNBaFvuAXUJ9qVY8V7Cs1o61gWgEWYxWSPC26/33ahnkDOr Cb17Vk3SyQnqrRBOW/+xsQfNoxdZgBKCBj9+RC/BCfWTuTlAYxbpHLbEajkpH4Atan1r COePXrT48B7jjtHyQcp3fmDpknAAvyCtmhTQESWbW/XSl8L6buQsWF3/NBzPNbAEJ1b0 7bnRwLtCVwh81NQZxSfp6tYNOWa3y81xhub6kJ/u6kjfjZef62wdz4Qa5fXd5g898W5l hPsrkVTGFIg5jHL0HE39t0anxuVRjPV7hT+dwVCg/BDK/k4kmrSq/7+fjxJf4ip9ort1 dy2w== X-Gm-Message-State: AOAM530Gd9ZzJo/Y3cBAzzD3FYL0zmWaXfyweS1YcsbCQCoOqS10Quae ozrSUZbzAcK6jg1SQEdgES8lM380pIUmJw== X-Google-Smtp-Source: ABdhPJwZV1H38Sfga37Y3UM9Ne4GuqgxVC9cf2Q9Lld/h7Vi8JnhMNulAPVyCb8Rvt6z0Fwq2OgBjg== X-Received: by 2002:a62:1591:0:b029:251:27c2:c185 with SMTP id 139-20020a6215910000b029025127c2c185mr926071pfv.33.1618300230730; Tue, 13 Apr 2021 00:50:30 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:84f5:7981:dfbe:8f02]) by smtp.gmail.com with ESMTPSA id n25sm11525125pff.154.2021.04.13.00.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 00:50:30 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 13 Apr 2021 16:50:12 +0900 Message-Id: <20210413075013.3069213-5-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.295.g9ea45b61b8-goog In-Reply-To: <20210413075013.3069213-1-hiroh@chromium.org> References: <20210413075013.3069213-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 4/5] libcamera: CameraSensor: Attach available 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: , Cc: jmondi@jacopo.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This add available test pattern modes to libcamera to CameraSensorInfo. Signed-off-by: Hirokazu Honda --- include/libcamera/internal/camera_sensor.h | 2 ++ src/libcamera/camera_sensor.cpp | 38 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h index 3fa3a419..75b884db 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 availableTestPatternModes; }; class CameraSensor : protected Loggable diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index c012385f..81d6af44 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -840,6 +840,44 @@ int CameraSensor::sensorInfo(CameraSensorInfo *info) const info->minFrameLength = info->outputSize.height + vblank.min().get(); info->maxFrameLength = info->outputSize.height + vblank.max().get(); + const SensorInfo *staticInfo = SensorDatabase::get(model_); + if (!staticInfo) { + LOG(CameraSensor, Warning) + << "No static properties available for '" << model_ << "'"; + LOG(CameraSensor, Warning) + << "Please consider updating the sensor database"; + return -EINVAL; + } + + const auto &v4l2TestPattern = controls().find(V4L2_CID_TEST_PATTERN); + if (v4l2TestPattern == controls().end()) { + LOG(CameraSensor, Error) << "No static test pattern map for \'" + << model() << "\'"; + return 0; + } + + for (const ControlValue &value : v4l2TestPattern->second.values()) { + const ControlMenu &menu = value.get(); + ASSERT(menu.isName); + + int32_t matchedTestPattern = -1; + for (const auto &[name, testPattern] : staticInfo->testPatternModeMap) { + if (strcmp(menu.name, name) == 0) { + matchedTestPattern = testPattern; + break; + } + } + + if (matchedTestPattern != -1) { + LOG(CameraSensor, Debug) << "Test pattern mode named \'" + << menu.name << "\' added"; + info->availableTestPatternModes.push_back(matchedTestPattern); + } else { + LOG(CameraSensor, Debug) << "Test pattern mode named \'" + << menu.name << "\' ignored"; + } + } + return 0; }