I followed Camera Development Guide to set sensor_mode, but failed to set by using V4L2 VIDIOC_S_CTRL
In my device tree, have two sensor modes (mode0 & mode1) configuration.
kernel/nvidia/include/media/tegra-v4l2-camera.h
#define TEGRA_CAMERA_CID_BASE (V4L2_CTRL_CLASS_CAMERA | 0x2000)
#define TEGRA_CAMERA_CID_VI_BYPASS_MODE (TEGRA_CAMERA_CID_BASE+100)
#define TEGRA_CAMERA_CID_SENSOR_MODE_ID (TEGRA_CAMERA_CID_BASE+8)
static void start_capturing(uint8_t cam_id)
{
unsigned int i;
enum v4l2_buf_type type;
struct v4l2_control camera_control;
//IO_METHOD_MMAP:
for (i = 0; i < n_buffers[cam_id]; ++i) {
struct v4l2_buffer buf;
CLEAR(buf);
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = i;
if (-1 == xioctl(fd[cam_id], VIDIOC_QBUF, &buf))
errno_exit("VIDIOC_QBUF");
}
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (-1 == xioctl(fd[cam_id], VIDIOC_STREAMON, &type))
errno_exit("VIDIOC_STREAMON");
memset(&camera_control,0,sizeof(camera_control));
camera_control.id=TEGRA_CAMERA_CID_VI_BYPASS_MODE;
camera_control.value=0;
if (-1 == xioctl(fd[cam_id],VIDIOC_S_CTRL,&camera_control)) {
printf("Failed to configure %d sensor bypass mode\n", cam_id);
errno_exit("VIDIOC_S_CTRL");
}
memset(&camera_control,0,sizeof(camera_control));
camera_control.id=TEGRA_CAMERA_CID_SENSOR_MODE_ID;
camera_control.value=1;
if (-1 == xioctl(fd[cam_id],VIDIOC_S_CTRL,&camera_control)) {
printf("Failed to configure %d sensor mode\n", cam_id);
errno_exit("VIDIOC_S_CTRL");
}
}
This results
Failed to configure 1 sensor mode
VIDIOC_S_CTRL error 22, Invalid argument
But, Able to configure with v4l2-ctl command line tool.
linux:~$ v4l2-ctl -d0 --set-ctrl sensor_mode=0
linux:~$ v4l2-ctl -d0 --get-ctrl sensor_mode
sensor_mode: 0
linux:~$ v4l2-ctl -d0 --set-ctrl sensor_mode=1
linux:~$ v4l2-ctl -d0 --get-ctrl sensor_mode
sensor_mode: 1
I’m unsure, what is missing in my configuration, can anyone spread light ?
Thanks