Find interface entity by type

This commit is contained in:
Martijn Braam 2020-11-28 18:57:11 +01:00
parent 26f0d561cd
commit 3cc9c9b867
3 changed files with 13 additions and 1 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);