aboutsummaryrefslogtreecommitdiffstats
path: root/utils/common/media-info.cpp
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2018-12-13 14:34:27 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2018-12-13 14:34:27 +0100
commit0d4d3f598d4a1f81ca3d56c033c6ae9ec864dbef (patch)
tree55b543d38056040a05cb4189bc9a8b9105c027fa /utils/common/media-info.cpp
parent4662614de0872a620c2ec7c6daf956e45300f49b (diff)
Add property compliance supportprops2
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'utils/common/media-info.cpp')
-rw-r--r--utils/common/media-info.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/utils/common/media-info.cpp b/utils/common/media-info.cpp
index 033821ed..a3e6c873 100644
--- a/utils/common/media-info.cpp
+++ b/utils/common/media-info.cpp
@@ -412,6 +412,35 @@ std::string mi_linkflags2s(__u32 flags)
}
}
+static void show_props(const media_v2_prop *props, unsigned num_props,
+ const media_v2_prop &prop, std::string prefix)
+{
+ for (unsigned i = 0; i < num_props; i++) {
+ if (props[i].owner_id != prop.id)
+ continue;
+
+ printf("%sProperty 0x%08x '%s'", prefix.c_str(), props[i].id, props[i].name);
+ switch (props[i].type) {
+ case MEDIA_PROP_TYPE_U64:
+ printf(": 0x%016llx %llu\n", media_prop2u64(props + i),
+ media_prop2u64(props + i));
+ break;
+ case MEDIA_PROP_TYPE_S64:
+ printf(": 0x%016llx %lld\n", media_prop2s64(props + i),
+ media_prop2s64(props + i));
+ break;
+ case MEDIA_PROP_TYPE_STRING:
+ printf(": '%s'\n", media_prop2string(props + i));
+ break;
+ case MEDIA_PROP_TYPE_GROUP:
+ printf(" {\n");
+ show_props(props, num_props, props[i], prefix + "\t");
+ printf("%s}\n", prefix.c_str());
+ break;
+ }
+ }
+}
+
static __u32 read_topology(int media_fd, __u32 major, __u32 minor,
__u32 media_version, bool *is_invalid)
{
@@ -426,11 +455,15 @@ static __u32 read_topology(int media_fd, __u32 major, __u32 minor,
media_v2_interface v2_ifaces[topology.num_interfaces];
media_v2_pad v2_pads[topology.num_pads];
media_v2_link v2_links[topology.num_links];
+ __u8 props[topology.num_props * sizeof(media_v2_prop) +
+ topology.props_payload_size];
+ media_v2_prop *v2_props = (media_v2_prop *)props;
topology.ptr_entities = (__u64)v2_ents;
topology.ptr_interfaces = (__u64)v2_ifaces;
topology.ptr_pads = (__u64)v2_pads;
topology.ptr_links = (__u64)v2_links;
+ topology.ptr_props = (__u64)v2_props;
if (ioctl(media_fd, MEDIA_IOC_G_TOPOLOGY, &topology))
return 0;
for (i = 0; i < topology.num_interfaces; i++)
@@ -553,6 +586,49 @@ static __u32 read_topology(int media_fd, __u32 major, __u32 minor,
remote_ent->name, mi_linkflags2s(link.flags).c_str());
}
}
+
+ for (i = 0; i < topology.num_props; i++) {
+ media_v2_prop &prop = v2_props[i];
+ media_v2_entity *ent_ptr = NULL;
+ media_v2_pad *pad_ptr = NULL;
+
+ if (prop.owner_id == ent.id) {
+ ent_ptr = &ent;
+ } else {
+ for (unsigned j = 0; j < topology.num_pads; j++) {
+ if (prop.owner_id == v2_pads[j].id) {
+ pad_ptr = &v2_pads[j];
+ break;
+ }
+ }
+ if (pad_ptr && pad_ptr->entity_id != ent.id)
+ pad_ptr = NULL;
+ }
+ if (!ent_ptr && !pad_ptr)
+ continue;
+
+ printf("\tProperty 0x%08x '%s'", prop.id, prop.name);
+ if (pad_ptr)
+ printf(" (pad 0x%08x)", prop.owner_id);
+ switch (prop.type) {
+ case MEDIA_PROP_TYPE_U64:
+ printf(": 0x%016llx %llu\n", media_prop2u64(&prop),
+ media_prop2u64(&prop));
+ break;
+ case MEDIA_PROP_TYPE_S64:
+ printf(": 0x%016llx %lld\n", media_prop2s64(&prop),
+ media_prop2s64(&prop));
+ break;
+ case MEDIA_PROP_TYPE_STRING:
+ printf(": '%s'\n", media_prop2string(&prop));
+ break;
+ case MEDIA_PROP_TYPE_GROUP:
+ printf(" {\n");
+ show_props(v2_props, topology.num_props, prop, "\t\t");
+ printf("\t}\n");
+ break;
+ }
+ }
return ent.id;
}

Privacy Policy