[PATCH] libcamera: Add open() and close() in CameraLens

Harvey Yang chenghaoyang at chromium.org
Thu Oct 17 09:39:47 CEST 2024


From: Han-Lin Chen <hanlinchen at chromium.org>

This allows pipeline handlers to save some power when a camera is close.

Signed-off-by: Han-Lin Chen <hanlinchen at chromium.org>
Co-developed-by: Harvey Yang <chenghaoyang at chromium.org>
Signed-off-by: Harvey Yang <chenghaoyang at chromium.org>
---
 include/libcamera/internal/camera_lens.h |  4 ++++
 src/libcamera/camera_lens.cpp            | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h
index 5a4b993bb..095056791 100644
--- a/include/libcamera/internal/camera_lens.h
+++ b/include/libcamera/internal/camera_lens.h
@@ -26,6 +26,10 @@ public:
 	~CameraLens();
 
 	int init();
+
+	int open();
+	void close();
+
 	int setFocusPosition(int32_t position);
 
 	const std::string &model() const { return model_; }
diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp
index ccc2a6a65..039f5ad2a 100644
--- a/src/libcamera/camera_lens.cpp
+++ b/src/libcamera/camera_lens.cpp
@@ -76,6 +76,23 @@ int CameraLens::init()
 	return 0;
 }
 
+/**
+ * \brief Open the subdev
+ * \return 0 on success or a negative error code otherwise
+ */
+int CameraLens::open()
+{
+	return subdev_->open();
+}
+
+/**
+ * \brief Close the subdev
+ */
+void CameraLens::close()
+{
+	subdev_->close();
+}
+
 /**
  * \brief This function sets the focal point of the lens to a specific position.
  * \param[in] position The focal point of the lens
-- 
2.47.0.rc1.288.g06298d1525-goog



More information about the libcamera-devel mailing list