I am trying to control MINISASTOCSI camera by IOCTL and VIDIOC_* on MCIMX8M-EVK.
(Reference : i.MX Linux Reference Manual Rev.LF.5.15.52_2.1.0 - 6.5.2.1 V4L2 Capture IOCTLs)
Finally, I need to control camera exposure, gain, white balance and so on.
I tried ioctl and VIDIOC_* on imx-image-multimedia, but only VIDIOC_QUERYCAP is succeed and others (e.q. VIDIOC_G_FMT) is failed. (Invalid argument error)
I have already verified image stream from MINISASTOCSI by "gst-launch-1.0 v4l2src ! autovideosink".
Could you tell me where the below VIDIOC_G_FMT code is wrong ?
#include <linux/videodev2.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main(){
/* Open /dev/video0 */
int fd = open("/dev/video0", O_RDWR, 0);
if (fd < 0) {
printf("Failed to open /dev/video0.\n");
return -1;
}
/* IOCTL + VIDIOC_QUERYCAP */
struct v4l2_capability cap;
int ret = ioctl(fd, VIDIOC_QUERYCAP, &cap);
if (ret < 0) {
perror("ioctl(VIDIOC_QUERYCAP)");
printf("Failed : ioctl VIDIOC_QUERYCAP.\n");
return -1;
}
close(fd);
return 1;
}
#include <linux/videodev2.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main(){
/* Open /dev/video0 */
int fd = open("/dev/video0", O_RDWR, 0);
if (fd < 0) {
printf("Failed to open /dev/video0.\n");
return -1;
}
/* IOCTL + VIDIOC_G_FMT */
struct v4l2_format fmt = {0};
int ret = ioctl(fd, VIDIOC_G_FMT, &fmt);
if (ret < 0) {
perror("ioctl(VIDIOC_G_FMT)");
printf("Failed : ioctl VIDIOC_G_FMT.\n");
return -1;
}
close(fd);
return 1;
}