Parcourir la source

Find interface entity by type

Martijn Braam il y a 4 ans
Parent
commit
3cc9c9b867
3 fichiers modifiés avec 13 ajouts et 1 suppressions
  1. 11 0
      device.c
  2. 1 0
      device.h
  3. 1 1
      io_pipeline.c

+ 11 - 0
device.c

@@ -176,6 +176,17 @@ const struct media_v2_entity *mp_device_find_entity(const MPDevice *device, cons
     return NULL;
 }
 
+const struct media_v2_entity *mp_device_find_entity_type(const MPDevice *device, const uint32_t type)
+{
+    // Find the entity from the entity type
+    for (uint32_t i = 0; i < device->num_entities; ++i) {
+        if (device->entities[i].function == type) {
+            return &device->entities[i];
+        }
+    }
+    return NULL;
+}
+
 const struct media_device_info *mp_device_get_info(const MPDevice *device)
 {
     return &device->info;

+ 1 - 0
device.h

@@ -18,6 +18,7 @@ bool mp_device_setup_link(MPDevice *device, uint32_t source_pad_id, uint32_t sin
 
 const struct media_device_info *mp_device_get_info(const MPDevice *device);
 const struct media_v2_entity *mp_device_find_entity(const MPDevice *device, const char *driver_name);
+const struct media_v2_entity *mp_device_find_entity_type(const MPDevice *device, const uint32_t type);
 const struct media_v2_entity *mp_device_get_entity(const MPDevice *device, uint32_t id);
 const struct media_v2_entity *mp_device_get_entities(const MPDevice *device);
 size_t mp_device_get_num_entities(const MPDevice *device);

+ 1 - 1
io_pipeline.c

@@ -116,7 +116,7 @@ static void setup_camera(MPDeviceList **device_list, const struct mp_camera_conf
             exit(EXIT_FAILURE);
         }
 
-        const struct media_v2_entity *entity = mp_device_find_entity(info->device, info->media_dev_name);
+        const struct media_v2_entity *entity = mp_device_find_entity_type(info->device, MEDIA_ENT_F_IO_V4L);
         if (!entity) {
             g_printerr("Could not find device video entity\n");
             exit(EXIT_FAILURE);