aboutsummaryrefslogtreecommitdiffstats
path: root/utils/common/media-info.cpp
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2018-11-26 11:46:17 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2018-11-26 11:49:31 +0100
commitb68732cb0cc3cecce42275eae5458780a9e5d19e (patch)
tree58f78a81ec0960e5dfc81503f6aba3a448dc6c09 /utils/common/media-info.cpp
parentcdc046863805b3a3082890ce91f71538e0dbf88c (diff)
media-info: add bus_info arg to mi_get_media_fd()
Some drivers might have multiple media devices, and in that case you have to select the right one based on the bus_info. Currently this is only the case for the vivid driver if it creates multiple instances. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'utils/common/media-info.cpp')
-rw-r--r--utils/common/media-info.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/utils/common/media-info.cpp b/utils/common/media-info.cpp
index 8eacfe06..c1b78684 100644
--- a/utils/common/media-info.cpp
+++ b/utils/common/media-info.cpp
@@ -199,7 +199,7 @@ std::string mi_get_devpath_from_dev_t(dev_t dev)
return devpath;
}
-int mi_get_media_fd(int fd)
+int mi_get_media_fd(int fd, const char *bus_info)
{
int media_fd = -1;
dev_t dev;
@@ -220,10 +220,18 @@ int mi_get_media_fd(int fd)
media_path[0] = 0;
while ((ep = readdir(dp))) {
if (!memcmp(ep->d_name, "media", 5) && isdigit(ep->d_name[5])) {
+ struct media_device_info mdinfo;
std::string devname("/dev/");
devname += ep->d_name;
media_fd = open(devname.c_str(), O_RDWR);
+
+ if (bus_info &&
+ (ioctl(media_fd, MEDIA_IOC_DEVICE_INFO, &mdinfo) ||
+ strcmp(mdinfo.bus_info, bus_info))) {
+ close(media_fd);
+ continue;
+ }
break;
}
}

Privacy Policy