#include #include #include #include #include #include #include #include int main(void) { int fd; pid_t pid; struct v4l2_format fmt2 = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE }; fd = open("/dev/video0", O_RDONLY); if (fd == -1) { perror("open 1"); return 1; } if (syscall(SYS_ioctl, fd, VIDIOC_G_FMT, &fmt2)) { perror("G_FMT 1"); return 1; } if (syscall(SYS_ioctl, fd, VIDIOC_TRY_FMT, &fmt2)) { perror("TRY_FMT 1"); return 1; } if (syscall(SYS_ioctl, fd, VIDIOC_S_FMT, &fmt2)) { perror("S_FMT 1"); return 1; } /* pid = fork(); if (pid == -1) { perror("fork"); return 1; } if (!pid) { close(fd); } else */ { close(fd); fd = open("/dev/video0", O_RDONLY); if (fd == -1) { perror("open 2"); return 1; } if (syscall(SYS_ioctl, fd, VIDIOC_G_FMT, &fmt2)) { perror("G_FMT 2"); return 1; } if (syscall(SYS_ioctl, fd, VIDIOC_TRY_FMT, &fmt2)) { perror("TRY_FMT 2"); return 1; } if (syscall(SYS_ioctl, fd, VIDIOC_S_FMT, &fmt2)) { perror("S_FMT 2"); return 1; } } return 0; }