IOCTL VIDIOC_* Error

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IOCTL VIDIOC_* Error

894 Views
ttoymst
Contributor II

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 ?

  • VIDIOC_QUERYCAP

 

 

 

#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;
}

 

 

 

 

  • VIDIOC_G_FMT

 

 

 

#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;
}

 

 

 

Tags (1)
0 Kudos
5 Replies

868 Views
joanxie
NXP TechSupport
NXP TechSupport

what imx8m board do you use? imx8mq or imx8mm, imx8mp? let me remind, v4l2-ctl isn't fully compatible OV5640 driver, and development team wouldn't support this, they suggest customer to use gstreamer instead

0 Kudos

851 Views
ttoymst
Contributor II

Thanks for the reply.

Could you please read my question post again?

(I wrote about the imx board I use, and I am not using v4l-ctrl.)

 

What will I do to control exposure and gain of MINISASTOCSI?

0 Kudos

839 Views
joanxie
NXP TechSupport
NXP TechSupport

firstly, many customers treated imx8m series board as imx8m-evk, that's why I double confirmed this from you, secondly, nxp bsp support v4l-ctrl commands, if you need debug your own code, this isn't our support scope, anyway, for v4l2 ioctrl simple code, maybe you can refer to this

//set format

struct v4l2_format fmt;
memset(&fmt, 0, sizeof(fmt));
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.width = VIDEO_WIDTH;
fmt.fmt.pix.height = VIDEO_HEIGHT;
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
ret = ioctl(fd, VIDIOC_S_FMT, &fmt);
if (ret < 0) {
printf("VIDIOC_S_FMT failed (%d)\n", ret);
return ret;
}

//get format
ret = ioctl(fd, VIDIOC_G_FMT, &fmt);
if (ret < 0) {
printf("VIDIOC_G_FMT failed (%d)\n", ret);
return ret;
}

0 Kudos

833 Views
ttoymst
Contributor II

Thanks for the reply.

I understand the intent of your confirmation about board and chip.

Regarding support scope, am I correct in my understanding that v4l2-ctl does not support to control camera exposure, gain and so on in the default BSP and therefore NXP cannot support to control them?

0 Kudos

816 Views
joanxie
NXP TechSupport
NXP TechSupport

as I known, current bsp couldn't support this as default, only support v4l2 ctrl to capture data from mipi csi

0 Kudos