summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mediactl-priv.h7
-rw-r--r--src/mediactl.c32
-rw-r--r--src/mediactl.h19
3 files changed, 58 insertions, 0 deletions
diff --git a/src/mediactl-priv.h b/src/mediactl-priv.h
index 37e60aa..4644165 100644
--- a/src/mediactl-priv.h
+++ b/src/mediactl-priv.h
@@ -49,6 +49,13 @@ struct media_device {
void (*debug_handler)(void *, ...);
void *debug_priv;
+
+ struct {
+ struct media_entity *v4l;
+ struct media_entity *fb;
+ struct media_entity *alsa;
+ struct media_entity *dvb;
+ } def;
};
#define media_dbg(media, ...) \
diff --git a/src/mediactl.c b/src/mediactl.c
index dd5bd57..4da334a 100644
--- a/src/mediactl.c
+++ b/src/mediactl.c
@@ -145,6 +145,21 @@ const char *media_entity_get_devname(struct media_entity *entity)
return entity->devname[0] ? entity->devname : NULL;
}
+struct media_entity *media_get_default_entity(struct media_device *media,
+ unsigned int type)
+{
+ switch (type) {
+ case MEDIA_ENT_T_DEVNODE_V4L:
+ return media->def.v4l;
+ case MEDIA_ENT_T_DEVNODE_FB:
+ return media->def.fb;
+ case MEDIA_ENT_T_DEVNODE_ALSA:
+ return media->def.alsa;
+ case MEDIA_ENT_T_DEVNODE_DVB:
+ return media->def.dvb;
+ }
+}
+
const struct media_device_info *media_get_info(struct media_device *media)
{
return &media->info;
@@ -519,6 +534,23 @@ static int media_enum_entities(struct media_device *media)
media->entities_count++;
+ if (entity->info.flags & MEDIA_ENT_FL_DEFAULT) {
+ switch (entity->info.type) {
+ case MEDIA_ENT_T_DEVNODE_V4L:
+ media->def.v4l = entity;
+ break;
+ case MEDIA_ENT_T_DEVNODE_FB:
+ media->def.fb = entity;
+ break;
+ case MEDIA_ENT_T_DEVNODE_ALSA:
+ media->def.alsa = entity;
+ break;
+ case MEDIA_ENT_T_DEVNODE_DVB:
+ media->def.dvb = entity;
+ break;
+ }
+ }
+
/* Find the corresponding device name. */
if (media_entity_type(entity) != MEDIA_ENT_T_DEVNODE &&
media_entity_type(entity) != MEDIA_ENT_T_V4L2_SUBDEV)
diff --git a/src/mediactl.h b/src/mediactl.h
index e2c93b8..b74be0b 100644
--- a/src/mediactl.h
+++ b/src/mediactl.h
@@ -244,6 +244,25 @@ unsigned int media_get_entities_count(struct media_device *media);
struct media_entity *media_get_entity(struct media_device *media, unsigned int index);
/**
+ * @brief Get the default entity for a given type
+ * @param media - media device.
+ * @param type - entity type.
+ *
+ * This function returns the default entity of the requested type. @a type must
+ * be one of
+ *
+ * MEDIA_ENT_T_DEVNODE_V4L
+ * MEDIA_ENT_T_DEVNODE_FB
+ * MEDIA_ENT_T_DEVNODE_ALSA
+ * MEDIA_ENT_T_DEVNODE_DVB
+ *
+ * @return A pointer to the default entity for the type if it exists, or NULL
+ * otherwise.
+ */
+struct media_entity *media_get_default_entity(struct media_device *media,
+ unsigned int type);
+
+/**
* @brief Get the media device information
* @param media - media device.
*