summaryrefslogtreecommitdiff
path: root/src/libcamera/camera.cpp
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2019-01-22 16:58:40 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-01-24 22:24:15 +0200
commit124aaffde0b25d847442876beb16600d448d9feb (patch)
treeb8c940e77dba880331d6645181eea8660f03dd29 /src/libcamera/camera.cpp
parent9d29af143b6b91dfe34c7a302c12a077561438c5 (diff)
libcamera: camera: Add disconnection notification
As camera object have the potential to outlive the hardware they represent, there is a need to inform the camera that the underlying device has been disconnected, and in turn to notify applications. Implement a disconnection notification mechanism that can be used by pipeline handlers to notify the camera of disconnection. The camera then block all new API calls and emit the disconnected signal. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/libcamera/camera.cpp')
-rw-r--r--src/libcamera/camera.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 3a531c7e..9cec2892 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -34,6 +34,8 @@
namespace libcamera {
+LOG_DECLARE_CATEGORY(Camera)
+
/**
* \class Camera
* \brief Camera device
@@ -87,6 +89,18 @@ const std::string &Camera::name() const
return name_;
}
+/**
+ * \var Camera::disconnected
+ * \brief Signal emitted when the camera is disconnected from the system
+ *
+ * This signal is emitted when libcamera detects that the cameera has been
+ * removed from the system. For hot-pluggable devices this is usually caused by
+ * physical device disconnection. The media device is passed as a parameter.
+ *
+ * As soon as this signal is emitted the camera instance will refuse all new
+ * application API calls by returning errors immediately.
+ */
+
Camera::Camera(PipelineHandler *pipe, const std::string &name)
: pipe_(pipe->shared_from_this()), name_(name)
{
@@ -96,4 +110,21 @@ Camera::~Camera()
{
}
+/**
+ * \brief Notify camera disconnection
+ *
+ * This method is used to notify the camera instance that the underlying
+ * hardware has been unplugged. In response to the disconnection the camera
+ * instance notifies the application by emitting the #disconnected signal, and
+ * ensures that all new calls to the application-facing Camera API return an
+ * error immediately.
+ */
+void Camera::disconnect()
+{
+ LOG(Camera, Debug) << "Disconnecting camera " << name_;
+
+ /** \todo Block API calls when they will be implemented. */
+ disconnected.emit(this);
+}
+
} /* namespace libcamera */