From 448ddbbbb5b71730762b51de281d8c41ad6342e5 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 5 Mar 2014 18:29:02 +0100 Subject: Update to the latest libmediactl API --- main.c | 44 ++++++++++++++++++++++++-------------------- media-enumerate.c | 19 ++++++++----------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/main.c b/main.c index 2fc63d0..73726e0 100644 --- a/main.c +++ b/main.c @@ -166,7 +166,6 @@ static void media_print_topology_text(struct media_device *media) { MEDIA_LNK_FL_DYNAMIC, "DYNAMIC" }, }; - struct media_entity *entities = media_get_entities(media); unsigned int nents = media_get_entities_count(media); unsigned int i, j, k; unsigned int padding; @@ -174,40 +173,45 @@ static void media_print_topology_text(struct media_device *media) printf("Device topology\n"); for (i = 0; i < nents; ++i) { - struct media_entity *entity = &entities[i]; - - padding = printf("- entity %u: ", entity->info.id); - printf("%s (%u pad%s, %u link%s)\n", entity->info.name, - entity->info.pads, entity->info.pads > 1 ? "s" : "", - entity->num_links, entity->num_links > 1 ? "s" : ""); + struct media_entity *entity = media_get_entity(media, i); + const struct media_entity_desc *info = media_entity_get_info(entity); + const char *devname = media_entity_get_devname(entity); + unsigned int num_links = media_entity_get_links_count(entity); + + padding = printf("- entity %u: ", info->id); + printf("%s (%u pad%s, %u link%s)\n", info->name, + info->pads, info->pads > 1 ? "s" : "", + num_links, num_links > 1 ? "s" : ""); printf("%*ctype %s subtype %s flags %x\n", padding, ' ', - media_entity_type_to_string(entity->info.type), - media_entity_subtype_to_string(entity->info.type), - entity->info.flags); - if (entity->devname[0]) - printf("%*cdevice node name %s\n", padding, ' ', entity->devname); + media_entity_type_to_string(info->type), + media_entity_subtype_to_string(info->type), + info->flags); + if (devname) + printf("%*cdevice node name %s\n", padding, ' ', devname); - for (j = 0; j < entity->info.pads; j++) { - struct media_pad *pad = &entity->pads[j]; + for (j = 0; j < info->pads; j++) { + const struct media_pad *pad = media_entity_get_pad(entity, j); printf("\tpad%u: %s\n", j, media_pad_type_to_string(pad->flags)); if (media_entity_type(entity) == MEDIA_ENT_T_V4L2_SUBDEV) v4l2_subdev_print_format(entity, j, V4L2_SUBDEV_FORMAT_ACTIVE); - for (k = 0; k < entity->num_links; k++) { - struct media_link *link = &entity->links[k]; - struct media_pad *source = link->source; - struct media_pad *sink = link->sink; + for (k = 0; k < num_links; k++) { + const struct media_link *link = media_entity_get_link(entity, k); + const struct media_pad *source = link->source; + const struct media_pad *sink = link->sink; bool first = true; unsigned int i; if (source->entity == entity && source->index == j) printf("\t\t-> \"%s\":%u [", - sink->entity->info.name, sink->index); + media_entity_get_info(sink->entity)->name, + sink->index); else if (sink->entity == entity && sink->index == j) printf("\t\t<- \"%s\":%u [", - source->entity->info.name, source->index); + media_entity_get_info(source->entity)->name, + source->index); else continue; diff --git a/media-enumerate.c b/media-enumerate.c index 1c3ab38..c0e9eef 100644 --- a/media-enumerate.c +++ b/media-enumerate.c @@ -439,22 +439,20 @@ static int media_enumerate_match_one_video(struct media_enumerate *media_enum, * media device. */ for (i = 0; i < media_enum->devices_count; ++i) { - struct media_entity *entities; unsigned int nents; media = media_enum->devices[i]; - entities = media_get_entities(media); nents = media_get_entities_count(media); for (j = 0; j < nents; ++j) { - struct media_entity *entity = &entities[j]; + struct media_entity *entity = media_get_entity(media, j); + const struct media_entity_desc *info = media_entity_get_info(entity); dev_t dev; - if (entity->info.type != MEDIA_ENT_T_DEVNODE_V4L) + if (info->type != MEDIA_ENT_T_DEVNODE_V4L) continue; - dev = makedev(entity->info.v4l.major, - entity->info.v4l.minor); + dev = makedev(info->v4l.major, info->v4l.minor); if (dev == devnum) return 0; } @@ -531,23 +529,22 @@ static int media_enumerate_match_one_audio(struct media_enumerate *media_enum, return -EINVAL; for (i = 0; i < media_enum->devices_count; ++i) { - struct media_entity *entities; unsigned int nents; media = media_enum->devices[i]; - entities = media_get_entities(media); nents = media_get_entities_count(media); if (!strcmp(media_enum->syspaths[i], syspath)) parent = media; for (j = 0; j < nents; ++j) { - struct media_entity *entity = &entities[j]; + struct media_entity *entity = media_get_entity(media, j); + const struct media_entity_desc *info = media_entity_get_info(entity); - if (entity->info.type != MEDIA_ENT_T_DEVNODE_ALSA) + if (info->type != MEDIA_ENT_T_DEVNODE_ALSA) continue; - if (entity->info.alsa.card == card) + if (info->alsa.card == card) return 0; } } -- cgit v1.2.3