i can use v4l2-ctl to set/get some param for my sensor,like
v4l2-ctl --set-ctrl=gain=400
but ioctl not work
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>
#include <memory.h>
int main(void)
{
int fd = open("/dev/video0", O_RDWR);
if(fd < 0)
{
perror("open dev error");
return -1;
}
struct v4l2_format vfmt;
memset(&vfmt,0,sizeof(vfmt));
vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
vfmt.fmt.pix.width = 1920;
vfmt.fmt.pix.height = 1080;
vfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGRBG12;
int ret = ioctl(fd, VIDIOC_S_FMT, &vfmt);
if(ret < 0) {
printf("set camera frame format error \n");
return -1;
}
struct v4l2_control ctrl;
ctrl.id = V4L2_CID_GAIN;
ret = ioctl(fd, VIDIOC_G_CTRL,&ctrl);
if(ret < 0) {
perror(" Get gain value failed ");
return -1;
} else {
printf(" get gain = %d \n",ctrl.value);
}
close(fd);
return 0;
}
$ ./main
Get gain value failed : Invalid argument