summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c94
1 files changed, 53 insertions, 41 deletions
diff --git a/src/main.c b/src/main.c
index b0e2277..6f980b4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -171,7 +171,6 @@ static const char *media_pad_type_to_string(unsigned flag)
static void media_print_topology_dot(struct media_device *media)
{
- struct media_entity *entities = media_get_entities(media);
unsigned int nents = media_get_entities_count(media);
unsigned int i, j;
@@ -179,34 +178,41 @@ static void media_print_topology_dot(struct media_device *media)
printf("\trankdir=TB\n");
for (i = 0; i < nents; ++i) {
- struct media_entity *entity = &entities[i];
+ 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);
unsigned int npads;
switch (media_entity_type(entity)) {
case MEDIA_ENT_T_DEVNODE:
printf("\tn%08x [label=\"%s\\n%s\", shape=box, style=filled, "
"fillcolor=yellow]\n",
- entity->info.id, entity->info.name, entity->devname);
+ info->id, info->name, devname);
break;
case MEDIA_ENT_T_V4L2_SUBDEV:
- printf("\tn%08x [label=\"{{", entity->info.id);
+ printf("\tn%08x [label=\"{{", info->id);
- for (j = 0, npads = 0; j < entity->info.pads; ++j) {
- if (!(entity->pads[j].flags & MEDIA_PAD_FL_SINK))
+ for (j = 0, npads = 0; j < info->pads; ++j) {
+ const struct media_pad *pad = media_entity_get_pad(entity, j);
+
+ if (!(pad->flags & MEDIA_PAD_FL_SINK))
continue;
printf("%s<port%u> %u", npads ? " | " : "", j, j);
npads++;
}
- printf("} | %s", entity->info.name);
- if (entity->devname)
- printf("\\n%s", entity->devname);
+ printf("} | %s", info->name);
+ if (devname)
+ printf("\\n%s", devname);
printf(" | {");
- for (j = 0, npads = 0; j < entity->info.pads; ++j) {
- if (!(entity->pads[j].flags & MEDIA_PAD_FL_SOURCE))
+ for (j = 0, npads = 0; j < info->pads; ++j) {
+ const struct media_pad *pad = media_entity_get_pad(entity, j);
+
+ if (!(pad->flags & MEDIA_PAD_FL_SOURCE))
continue;
printf("%s<port%u> %u", npads ? " | " : "", j, j);
@@ -220,19 +226,21 @@ static void media_print_topology_dot(struct media_device *media)
continue;
}
- for (j = 0; j < entity->num_links; j++) {
- struct media_link *link = &entity->links[j];
+ for (j = 0; j < num_links; j++) {
+ const struct media_link *link = media_entity_get_link(entity, j);
+ const struct media_pad *source = link->source;
+ const struct media_pad *sink = link->sink;
- if (link->source->entity != entity)
+ if (source->entity != entity)
continue;
- printf("\tn%08x", link->source->entity->info.id);
- if (media_entity_type(link->source->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
- printf(":port%u", link->source->index);
+ printf("\tn%08x", media_entity_get_info(source->entity)->id);
+ if (media_entity_type(source->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
+ printf(":port%u", source->index);
printf(" -> ");
- printf("n%08x", link->sink->entity->info.id);
- if (media_entity_type(link->sink->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
- printf(":port%u", link->sink->index);
+ printf("n%08x", media_entity_get_info(sink->entity)->id);
+ if (media_entity_type(sink->entity) == MEDIA_ENT_T_V4L2_SUBDEV)
+ printf(":port%u", sink->index);
if (link->flags & MEDIA_LNK_FL_IMMUTABLE)
printf(" [style=bold]");
@@ -256,7 +264,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;
@@ -264,40 +271,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;
@@ -383,7 +395,7 @@ int main(int argc, char **argv)
goto out;
}
- printf("%s\n", entity->devname);
+ printf("%s\n", media_entity_get_devname(entity));
}
if (media_opts.pad) {