From patchwork Thu Feb 4 10:05:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11139 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 45123BD162 for ; Thu, 4 Feb 2021 10:05:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 13CCD6142A; Thu, 4 Feb 2021 11:05:53 +0100 (CET) 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="Hj9vuvtL"; dkim-atps=neutral Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 288B061402 for ; Thu, 4 Feb 2021 11:05:51 +0100 (CET) Received: by mail-pj1-x1035.google.com with SMTP id s24so1410042pjp.5 for ; Thu, 04 Feb 2021 02:05:51 -0800 (PST) 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=c3N37gVuGh2sjzISx2yb690NFKzleVus8ZFnC08+rkU=; b=Hj9vuvtLXgqP0Rv+Jd62DahTfGNdjUNdcsOVpIubyeD7JlwCe+xbO+DCmX8sq2Bejp ahNShZqgkLIQuN/5zYmHzMdR3G43gkUHsdjJYbw5lAKXD9sSQypRjTAOqeF2R85gGUb2 4MaG9PdifeB/2a2uZj4zU9xfn3HzmOkDRS9VU= 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=c3N37gVuGh2sjzISx2yb690NFKzleVus8ZFnC08+rkU=; b=ehUr9Q2fvHzbI7UGj6WQqTq8Ij1g+DIwqmu8src8Zm8dBjPzvh3EvxIgDuEjOW5cHo kzU6vB69GRPPAxLnYGEKQz8EkStPk5Z5zvWf4VkSC/YD1Pt4BOsuTEpigpa19yVxr+fF Q+dKDtXnynBDiUmsbjgwTs6xuJkbw3SGOcsOKqQ1t6zu1wnQnRdShsmmoeTvRuEA/iYg y04cUXQ/RKXBdpO0fzUKqvXJW3NsetbZxmgwyE2RA8+JScZWWhtKey3EYJbbjmo4PRUc 6NKEfHtODZWPw4xI90fnqeoXI+U04PHbjtDC6WSRDLi+2ZnAUTsJVKALLnCPC+0XPo7W Ykxw== X-Gm-Message-State: AOAM533QE8c+aHvISHJxpsm841Rzpa24b4a+RP94CiOMKbELfPTn4TG/ 4Kf3NsH94Bk86Q3KlyIdcR/D0c0JIQwCzvEV X-Google-Smtp-Source: ABdhPJz5Er5I3t6Oscrq7DymUBU2iIb5R1wZH1F6ut4r+zzc0Oal5QcEtwMKJ2BY2Ij5GGaPcOVriw== X-Received: by 2002:a17:90a:2f83:: with SMTP id t3mr7809433pjd.128.1612433149634; Thu, 04 Feb 2021 02:05:49 -0800 (PST) Received: from hiroh.c.googlers.com.com (128.141.236.35.bc.googleusercontent.com. [35.236.141.128]) by smtp.gmail.com with ESMTPSA id j9sm5808418pgb.47.2021.02.04.02.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 02:05:48 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 4 Feb 2021 10:05:36 +0000 Message-Id: <20210204100541.657503-2-hiroh@chromium.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210204100541.657503-1-hiroh@chromium.org> References: <20210204100541.657503-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 1/6] libcamera: camera: Add tryValidate() to CameraConfiguration 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: hanlinchen@chromium.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This adds tryValidate() to CameraConfiguration. The function doesn't change CameraConfiguration status. It dry-runs validate() with passed configurations, so that a caller can know acceptable configurations. Signed-off-by: Hirokazu Honda --- include/libcamera/camera.h | 1 + src/libcamera/camera.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) -- 2.30.0.365.g02bc693789-goog diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index f94f8599..ac3c7f5a 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -43,6 +43,7 @@ public: void addConfiguration(const StreamConfiguration &cfg); virtual Status validate() = 0; + virtual bool tryValidate(std::vector> &config) const; StreamConfiguration &at(unsigned int index); const StreamConfiguration &at(unsigned int index) const; diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp index c9c79b91..6c4ae727 100644 --- a/src/libcamera/camera.cpp +++ b/src/libcamera/camera.cpp @@ -171,6 +171,28 @@ void CameraConfiguration::addConfiguration(const StreamConfiguration &cfg) config_.push_back(cfg); } +/** + * \fn CameraConfiguration::tryValidate() + * \brief construct configurations from config, which can be produced + * simultaneously w/o adjust. + * + * This method modifies config to satisfy + * 1.) config[i].second is Invalid or + * 2.) config[i].second is either Valid or Adjust and the config[i].first can be + * accepted by a native camera. validate() returns Valid or Adjust with the + * configurations. + * + * \todo: Remove this tryValidate() in this base class. + */ +bool CameraConfiguration::tryValidate( + std::vector> &config) const +{ + for (auto &c : config) { + c.second = Invalid; + } + return false; +} + /** * \fn CameraConfiguration::validate() * \brief Validate and possibly adjust the camera configuration