[libcamera-devel,05/10] libcamera: media_device: Add disconnected signal

Message ID 20190124101651.9993-6-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • Hotplug support and object lifetime management
Related show

Commit Message

Laurent Pinchart Jan. 24, 2019, 10:16 a.m. UTC
The signal is emitted when the hardware device corresponding to the
media device is unplugged. This will trigger the full unplug handling
chain.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/include/media_device.h |  4 ++++
 src/libcamera/media_device.cpp       | 10 ++++++++++
 2 files changed, 14 insertions(+)

Comments

Niklas Söderlund Jan. 24, 2019, 5:01 p.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2019-01-24 12:16:46 +0200, Laurent Pinchart wrote:
> The signal is emitted when the hardware device corresponding to the
> media device is unplugged. This will trigger the full unplug handling
> chain.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/libcamera/include/media_device.h |  4 ++++
>  src/libcamera/media_device.cpp       | 10 ++++++++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
> index 8a7b9489faa9..27a2b46a4392 100644
> --- a/src/libcamera/include/media_device.h
> +++ b/src/libcamera/include/media_device.h
> @@ -14,6 +14,8 @@
>  
>  #include <linux/media.h>
>  
> +#include <libcamera/signal.h>
> +
>  #include "media_object.h"
>  
>  namespace libcamera {
> @@ -48,6 +50,8 @@ public:
>  	MediaLink *link(const MediaPad *source, const MediaPad *sink);
>  	int disableLinks();
>  
> +	Signal<MediaDevice *> disconnected;
> +
>  private:
>  	std::string driver_;
>  	std::string deviceNode_;
> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
> index 51e5088ebdd9..be81bd8c4c23 100644
> --- a/src/libcamera/media_device.cpp
> +++ b/src/libcamera/media_device.cpp
> @@ -427,6 +427,16 @@ int MediaDevice::disableLinks()
>  	return 0;
>  }
>  
> +/**
> + * \var MediaDevice::disconnected
> + * \brief Signal emitted when the media device is disconnected from the system
> + *
> + * This signal is emitted when the device enumerator detects that the media
> + * device has been removed from the system. For hot-pluggable devices this is
> + * usually caused by physical device disconnection, but can also result from
> + * driver unloading for most devices. The media device is passed as a parameter.
> + */
> +
>  /**
>   * \var MediaDevice::objects_
>   * \brief Global map of media objects (entities, pads, links) keyed by their
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
index 8a7b9489faa9..27a2b46a4392 100644
--- a/src/libcamera/include/media_device.h
+++ b/src/libcamera/include/media_device.h
@@ -14,6 +14,8 @@ 
 
 #include <linux/media.h>
 
+#include <libcamera/signal.h>
+
 #include "media_object.h"
 
 namespace libcamera {
@@ -48,6 +50,8 @@  public:
 	MediaLink *link(const MediaPad *source, const MediaPad *sink);
 	int disableLinks();
 
+	Signal<MediaDevice *> disconnected;
+
 private:
 	std::string driver_;
 	std::string deviceNode_;
diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
index 51e5088ebdd9..be81bd8c4c23 100644
--- a/src/libcamera/media_device.cpp
+++ b/src/libcamera/media_device.cpp
@@ -427,6 +427,16 @@  int MediaDevice::disableLinks()
 	return 0;
 }
 
+/**
+ * \var MediaDevice::disconnected
+ * \brief Signal emitted when the media device is disconnected from the system
+ *
+ * This signal is emitted when the device enumerator detects that the media
+ * device has been removed from the system. For hot-pluggable devices this is
+ * usually caused by physical device disconnection, but can also result from
+ * driver unloading for most devices. The media device is passed as a parameter.
+ */
+
 /**
  * \var MediaDevice::objects_
  * \brief Global map of media objects (entities, pads, links) keyed by their