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

raspicam: Check system is running legacy camera stack #713

Merged
merged 1 commit into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions host_applications/linux/apps/raspicam/RaspiHelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <unistd.h>
#include <stdint.h>

#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>

#include "interface/vcos/vcos.h"
#include "interface/mmal/mmal.h"
Expand Down Expand Up @@ -294,3 +297,25 @@ uint64_t get_microseconds64()

return us;
}


/*
* If we are configured to use /dev/video0 as unicam (e.g. for libcamera) then
* these legacy camera apps can't work. Fail immediately with an obvious message.
*/
void check_camera_stack()
{
int fd = open("/dev/video0", O_RDWR, 0);
if (fd < 0)
return;

struct v4l2_capability caps;
int ret = ioctl(fd, VIDIOC_QUERYCAP, &caps);
close(fd);

if (ret < 0 || strcmp((char *)caps.driver, "unicam"))
return;

fprintf(stderr, "ERROR: the system should be configured for the legacy camera stack\n");
exit(-1);
}
1 change: 1 addition & 0 deletions host_applications/linux/apps/raspicam/RaspiHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ void default_signal_handler(int signal_number);
int mmal_status_to_int(MMAL_STATUS_T status);
void print_app_details(FILE *fd);
uint64_t get_microseconds64();
void check_camera_stack();

#endif
2 changes: 2 additions & 0 deletions host_applications/linux/apps/raspicam/RaspiStill.c
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,8 @@ int main(int argc, const char **argv)
MMAL_PORT_T *encoder_input_port = NULL;
MMAL_PORT_T *encoder_output_port = NULL;

check_camera_stack();

bcm_host_init();

// Register our application with the logging system
Expand Down
2 changes: 2 additions & 0 deletions host_applications/linux/apps/raspicam/RaspiStillYUV.c
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,8 @@ int main(int argc, const char **argv)
MMAL_PORT_T *preview_input_port = NULL;
FILE *output_file = NULL;

check_camera_stack();

bcm_host_init();

// Register our application with the logging system
Expand Down
2 changes: 2 additions & 0 deletions host_applications/linux/apps/raspicam/RaspiVid.c
Original file line number Diff line number Diff line change
Expand Up @@ -2408,6 +2408,8 @@ int main(int argc, const char **argv)
MMAL_PORT_T *splitter_output_port = NULL;
MMAL_PORT_T *splitter_preview_port = NULL;

check_camera_stack();

bcm_host_init();

// Register our application with the logging system
Expand Down
2 changes: 2 additions & 0 deletions host_applications/linux/apps/raspicam/RaspiVidYUV.c
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,8 @@ int main(int argc, const char **argv)
MMAL_PORT_T *camera_still_port = NULL;
MMAL_PORT_T *preview_input_port = NULL;

check_camera_stack();

bcm_host_init();

// Register our application with the logging system
Expand Down