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

core: Better handling of missing camera dev nodes #579

Merged
merged 1 commit into from
Oct 9, 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
15 changes: 11 additions & 4 deletions core/libcamera_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ enum class Platform

Platform get_platform()
{
bool unknown = false;
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;
continue;

v4l2_capability caps;
unsigned long request = VIDIOC_QUERYCAP;
Expand All @@ -51,17 +52,23 @@ Platform get_platform()
close(fd);

if (ret)
return Platform::UNKNOWN;
continue;

// We are not concerned with UVC devices for now.
if (!strncmp((char *)caps.driver, "uvcvideo", sizeof(caps.card)))
continue;

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;
else
unknown = true;
}

return Platform::UNKNOWN;
return unknown ? Platform::UNKNOWN : Platform::MISSING;
}

static libcamera::PixelFormat mode_to_pixel_format(Mode const &mode)
Expand Down Expand Up @@ -122,7 +129,7 @@ LibcameraApp::LibcameraApp(std::unique_ptr<Options> opts)
}
else if (platform == Platform::UNKNOWN)
{
fprintf(stderr, "ERROR: libcamera-apps currently only supports the Raspberry Pi platform.\n"
fprintf(stderr, "ERROR: libcamera-apps currently only supports the Raspberry Pi platforms.\n"
"Contributions for other platforms are welcome at https://github.com/raspberrypi/libcamera-apps.\n");
exit(-1);
}
Expand Down