Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check several /dev/video nodes in order to find the platform #578

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions core/libcamera_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,30 @@ enum class Platform

Platform get_platform()
{
int fd = open("/dev/video0", O_RDWR, 0);
if (fd < 0)
return Platform::MISSING;
for (unsigned int device_num = 0; device_num < 5; device_num++)
{
char device_name[16];
snprintf(device_name, sizeof(device_name), "/dev/video%u", device_num);
int fd = open(device_name, O_RDWR, 0);
if (fd < 0)
return Platform::UNKNOWN;

v4l2_capability caps;
unsigned long request = VIDIOC_QUERYCAP;
v4l2_capability caps;
unsigned long request = VIDIOC_QUERYCAP;

int ret = ioctl(fd, request, &caps);
close(fd);
int ret = ioctl(fd, request, &caps);
close(fd);

if (ret)
return Platform::UNKNOWN;

if (!strncmp((char *)caps.card, "unicam", sizeof(caps.card)))
return Platform::VC4;
else if (!strncmp((char *)caps.card, "rp1-cfe", sizeof(caps.card)))
return Platform::PISP;
else if (!strncmp((char *)caps.card, "bm2835 mmal", sizeof(caps.card)))
return Platform::LEGACY;
if (ret)
return Platform::UNKNOWN;

if (!strncmp((char *)caps.card, "unicam", sizeof(caps.card)))
return Platform::VC4;
else if (!strncmp((char *)caps.card, "rp1-cfe", sizeof(caps.card)))
return Platform::PISP;
else if (!strncmp((char *)caps.card, "bm2835 mmal", sizeof(caps.card)))
return Platform::LEGACY;
}

return Platform::UNKNOWN;
}
Expand Down