aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2021-10-08 19:23:11 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2021-10-08 19:23:11 +0200
commit493af03f3c576fad69c050d33215d1f4fc0d532d (patch)
tree47e9bfce69b0f346d75f852c6aa1e9b63de2b6ba
parentfb4f059c875c9f9859cc5bce36c8170fc24f375d (diff)
v4l2-compliance: check entity function for codecs
Codec devices must have entity function MEDIA_ENT_F_PROC_VIDEO_ENCODER or _DECODER. Check this. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/common/media-info.cpp19
-rw-r--r--utils/common/media-info.h7
-rw-r--r--utils/v4l2-compliance/v4l2-compliance.cpp2
-rw-r--r--utils/v4l2-compliance/v4l2-compliance.h1
-rw-r--r--utils/v4l2-compliance/v4l2-test-codecs.cpp4
5 files changed, 25 insertions, 8 deletions
diff --git a/utils/common/media-info.cpp b/utils/common/media-info.cpp
index 410e18cd..07841ddf 100644
--- a/utils/common/media-info.cpp
+++ b/utils/common/media-info.cpp
@@ -428,7 +428,8 @@ std::string mi_linkflags2s(__u32 flags)
}
static __u32 read_topology(int media_fd, __u32 major, __u32 minor,
- __u32 media_version, bool *is_invalid)
+ __u32 media_version, bool *is_invalid,
+ __u32 *function)
{
media_v2_topology topology;
unsigned i, j;
@@ -457,6 +458,8 @@ static __u32 read_topology(int media_fd, __u32 major, __u32 minor,
major, minor);
if (is_invalid)
*is_invalid = true;
+ if (function)
+ *function = MEDIA_ENT_F_UNKNOWN;
return MEDIA_ENT_F_UNKNOWN;
}
const media_v2_interface &iface = v2_ifaces[i];
@@ -563,15 +566,18 @@ static __u32 read_topology(int media_fd, __u32 major, __u32 minor,
remote_ent_id);
return ent.id;
}
- printf("\t Link 0x%08x: %s remote pad 0x%x of entity '%s': %s\n",
+ printf("\t Link 0x%08x: %s remote pad 0x%x of entity '%s' (%s): %s\n",
link.id, is_sink ? "from" : "to", remote_pad,
- remote_ent->name, mi_linkflags2s(link.flags).c_str());
+ remote_ent->name, mi_entfunction2s(remote_ent->function).c_str(),
+ mi_linkflags2s(link.flags).c_str());
+ if (function && !*function)
+ *function = remote_ent->function;
}
}
return ent.id;
}
-__u32 mi_media_info_for_fd(int media_fd, int fd, bool *is_invalid)
+__u32 mi_media_info_for_fd(int media_fd, int fd, bool *is_invalid, __u32 *function)
{
struct media_device_info mdinfo;
struct stat sb;
@@ -580,6 +586,9 @@ __u32 mi_media_info_for_fd(int media_fd, int fd, bool *is_invalid)
if (is_invalid)
*is_invalid = false;
+ if (function)
+ *function = MEDIA_ENT_F_UNKNOWN;
+
if (ioctl(media_fd, MEDIA_IOC_DEVICE_INFO, &mdinfo))
return 0;
@@ -611,7 +620,7 @@ __u32 mi_media_info_for_fd(int media_fd, int fd, bool *is_invalid)
}
ent_id = read_topology(media_fd, major(sb.st_rdev), minor(sb.st_rdev),
- mdinfo.media_version, is_invalid);
+ mdinfo.media_version, is_invalid, function);
if (ent_id)
return ent_id;
diff --git a/utils/common/media-info.h b/utils/common/media-info.h
index b72754e3..a862b70b 100644
--- a/utils/common/media-info.h
+++ b/utils/common/media-info.h
@@ -76,15 +76,18 @@ std::string mi_linkflags2s(__u32 flags);
/*
* Show media controller information media_fd and (if >= 0) the
- * corresponsing entity/interface information for the fd.
+ * corresponding entity/interface information for the fd.
*
* If is_invalid != NULL, then set it to true if errors are detected
* in the media information.
*
+ * If function != NULL, then set it to the function of the entity to
+ * which the interface is connected.
+ *
* Return 0 if the driver doesn't support MEDIA_IOC_G_TOPOLOGY.
* Return MEDIA_ENT_F_UNKNOWN if it does support this but there were
* errors reading the topology. Otherwise return the entity ID of fd.
*/
-__u32 mi_media_info_for_fd(int media_fd, int fd, bool *is_invalid = NULL);
+__u32 mi_media_info_for_fd(int media_fd, int fd, bool *is_invalid = NULL, __u32 *function = NULL);
#endif
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index 89923191..798c4221 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -1056,7 +1056,7 @@ void testNode(struct node &node, struct node &node_m2m_cap, struct node &expbuf_
if (node.is_media())
mi_media_info_for_fd(node.g_fd(), -1, &is_invalid);
else if (media_fd >= 0)
- ent_id = mi_media_info_for_fd(media_fd, node.g_fd(), &is_invalid);
+ ent_id = mi_media_info_for_fd(media_fd, node.g_fd(), &is_invalid, &node.function);
if (ent_id != MEDIA_ENT_F_UNKNOWN) {
memset(&node.entity, 0, sizeof(node.entity));
diff --git a/utils/v4l2-compliance/v4l2-compliance.h b/utils/v4l2-compliance/v4l2-compliance.h
index 7ae7b988..419d1498 100644
--- a/utils/v4l2-compliance/v4l2-compliance.h
+++ b/utils/v4l2-compliance/v4l2-compliance.h
@@ -133,6 +133,7 @@ struct base_node {
__u32 media_version;
std::string media_bus_info;
media_entity_desc entity;
+ __u32 function;
media_pad_desc *pads;
media_link_desc *links;
media_v2_topology *topology;
diff --git a/utils/v4l2-compliance/v4l2-test-codecs.cpp b/utils/v4l2-compliance/v4l2-test-codecs.cpp
index e218f65f..22175eef 100644
--- a/utils/v4l2-compliance/v4l2-test-codecs.cpp
+++ b/utils/v4l2-compliance/v4l2-test-codecs.cpp
@@ -31,6 +31,8 @@ int testEncoder(struct node *node)
bool is_encoder = node->codec_mask & (STATEFUL_ENCODER | JPEG_ENCODER);
int ret;
+ if (IS_ENCODER(node))
+ fail_on_test(node->function != MEDIA_ENT_F_PROC_VIDEO_ENCODER);
memset(&cmd, 0xff, sizeof(cmd));
memset(&cmd.raw, 0, sizeof(cmd.raw));
ret = doioctl(node, VIDIOC_ENCODER_CMD, &cmd);
@@ -98,6 +100,8 @@ int testDecoder(struct node *node)
bool is_decoder = node->codec_mask & (STATEFUL_DECODER | JPEG_DECODER);
int ret;
+ if (IS_DECODER(node))
+ fail_on_test(node->function != MEDIA_ENT_F_PROC_VIDEO_DECODER);
memset(&cmd, 0xff, sizeof(cmd));
memset(&cmd.raw, 0, sizeof(cmd.raw));
ret = doioctl(node, VIDIOC_DECODER_CMD, &cmd);

Privacy Policy