[libcamera-devel,RFC,1/6] libcamera: camera: Add tryValidate() to CameraConfiguration
diff mbox series

Message ID 20210204100541.657503-2-hiroh@chromium.org
State New
Headers show
Series
  • Support stream mapping in Android HAL adaptation layer
Related show

Commit Message

Hirokazu Honda Feb. 4, 2021, 10:05 a.m. UTC
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 <hiroh@chromium.org>
---
 include/libcamera/camera.h |  1 +
 src/libcamera/camera.cpp   | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)

--
2.30.0.365.g02bc693789-goog

Patch
diff mbox series

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<std::pair<StreamConfiguration, Status>> &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<std::pair<StreamConfiguration, Status>> &config) const
+{
+	for (auto &c : config) {
+		c.second = Invalid;
+	}
+	return false;
+}
+
 /**
  * \fn CameraConfiguration::validate()
  * \brief Validate and possibly adjust the camera configuration