Skip to content

Commit

Permalink
core: Better handling of missing camera dev nodes
Browse files Browse the repository at this point in the history
Preserve the historical behaviour where if a camera dev node is missing,
we report it as "no camera available" instead of an unknown platform.

Signed-off-by: Naushir Patuck <[email protected]>
  • Loading branch information
naushir committed Oct 9, 2023
1 parent c0617eb commit f72e641
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions core/libcamera_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Platform get_platform()
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,7 +51,11 @@ 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;
Expand All @@ -61,7 +65,7 @@ Platform get_platform()
return Platform::LEGACY;
}

return Platform::UNKNOWN;
return Platform::MISSING;
}

static libcamera::PixelFormat mode_to_pixel_format(Mode const &mode)
Expand Down Expand Up @@ -122,7 +126,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

0 comments on commit f72e641

Please sign in to comment.