mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-17 17:35:06 +03:00
libcamera: v4l2_device: Create device from entity name
Add a static method to V4L2Device class to create a V4L2Device instance from a media entity name. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
5b9b3c38a1
commit
69c97ec042
2 changed files with 26 additions and 0 deletions
|
@ -22,6 +22,7 @@ namespace libcamera {
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class BufferPool;
|
class BufferPool;
|
||||||
class EventNotifier;
|
class EventNotifier;
|
||||||
|
class MediaDevice;
|
||||||
class MediaEntity;
|
class MediaEntity;
|
||||||
|
|
||||||
struct V4L2Capability final : v4l2_capability {
|
struct V4L2Capability final : v4l2_capability {
|
||||||
|
@ -136,6 +137,9 @@ public:
|
||||||
int streamOn();
|
int streamOn();
|
||||||
int streamOff();
|
int streamOff();
|
||||||
|
|
||||||
|
static V4L2Device *fromEntityName(const MediaDevice *media,
|
||||||
|
const std::string &entity);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string logPrefix() const;
|
std::string logPrefix() const;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <libcamera/event_notifier.h>
|
#include <libcamera/event_notifier.h>
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "media_device.h"
|
||||||
#include "media_object.h"
|
#include "media_object.h"
|
||||||
#include "v4l2_device.h"
|
#include "v4l2_device.h"
|
||||||
|
|
||||||
|
@ -928,4 +929,25 @@ int V4L2Device::streamOff()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Create a new video device instance from \a entity in media device
|
||||||
|
* \a media
|
||||||
|
* \param[in] media The media device where the entity is registered
|
||||||
|
* \param[in] entity The media entity name
|
||||||
|
*
|
||||||
|
* Releasing memory of the newly created instance is responsibility of the
|
||||||
|
* caller of this function.
|
||||||
|
*
|
||||||
|
* \return A newly created V4L2Device on success, nullptr otherwise
|
||||||
|
*/
|
||||||
|
V4L2Device *V4L2Device::fromEntityName(const MediaDevice *media,
|
||||||
|
const std::string &entity)
|
||||||
|
{
|
||||||
|
MediaEntity *mediaEntity = media->getEntityByName(entity);
|
||||||
|
if (!mediaEntity)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return new V4L2Device(mediaEntity);
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace libcamera */
|
} /* namespace libcamera */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue