Jetpack R28.1 unable to set camera parameters via IOCTL

Whenever I try to set any writable camera parameter, the kernel driver ends up in “g_volatile_ctrl()” instead of “s_ctrl()” function and fails with “INVALID ARGUMENT”. What am I doing wrong here?

Excerpts from a test program as follows:


cam_fd = open(“/dev/v4l-subdev0”, O_RDWR);

if (cam_fd < 0)
{
  printf("Unable to open video0 device, errno = %x\n", errno);
  exit(-1);
}

 err = pffc_ctrl_do_ioctl(cam_fd, V4L2_CID_SATURATION, val);

static int pffc_ctrl_do_ioctl(int fd, uint32_t id, uint32_t val)
{
struct v4l2_control control;

// Validate device handle
if (fd < 0)
  return(-1);

// Run IOCTL
memset(&control, 0, sizeof (control));
control.id = id;
control.value = val;

if (-1 == ioctl(fd, VIDIOC_S_CTRL, &control))
{
  perror("VIDIOC_S_CTRL");
  printf("do-ioctl ID %x, val = %x\n", id, val);
  return(-1);
}
return(0);

}

You should open video# instead of sub node.

I tried that as well “/dev/video0”, got same results. Using the subdev directly was my latest try. I end up in the g_volatile_ctrl function on all sets. I can run “v4l2-ctl --all” and I see all the controls I’ve defined. So I pulled v4l-utils source & looked at their code. It appears I’m doing everything correctly, so not sure why I always end up in g_volatile_ctrl() function. I’ve got my set_ctrl() function instrumented with printk(), going to try v4l2-ctl --set-ctrl & see what happens next.

It’s now working with both v4l2-ctl --set-ctrl and the user-space app I wrote. I did switch back to “/dev/video0”, so I guess something else I fixed in the ctrl-handler init code must have been the problem. Thanks!