@@ -18,6 +18,7 @@
#include <libcamera/base/class.h>
#include <libcamera/base/log.h>
+#include <libcamera/base/regex.h>
#include <libcamera/color_space.h>
#include <libcamera/geometry.h>
@@ -163,6 +164,8 @@ public:
static std::unique_ptr<V4L2Subdevice>
fromEntityName(const MediaDevice *media, const std::string &entity);
+ static std::unique_ptr<V4L2Subdevice>
+ fromEntityName(const MediaDevice *media, const std::regex &entity);
protected:
std::string logPrefix() const override;
@@ -1748,7 +1748,6 @@ const std::string &V4L2Subdevice::model()
* \a media
* \param[in] media The media device where the entity is registered
* \param[in] entity The media entity name
- *
* \return A newly created V4L2Subdevice on success, nullptr otherwise
*/
std::unique_ptr<V4L2Subdevice>
@@ -1762,6 +1761,24 @@ V4L2Subdevice::fromEntityName(const MediaDevice *media,
return std::make_unique<V4L2Subdevice>(mediaEntity);
}
+/**
+ * \brief Create a new video subdevice instance from an entity in media device
+ * \a media
+ * \param[in] media The media device where the entity is registered
+ * \param[in] entity A regex that will match the media entity's name
+ * \return A newly created V4L2Subdevice on success, nullptr otherwise
+ */
+std::unique_ptr<V4L2Subdevice>
+V4L2Subdevice::fromEntityName(const MediaDevice *media,
+ const std::regex &entity)
+{
+ MediaEntity *mediaEntity = media->getEntityByName(entity);
+ if (!mediaEntity)
+ return nullptr;
+
+ return std::make_unique<V4L2Subdevice>(mediaEntity);
+}
+
std::string V4L2Subdevice::logPrefix() const
{
return "'" + entity_->name() + "'";