Re: v4l2 control querying

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi Ronald,

I would do this.

struct v4l2_queryctrl c;

for (c.index = V4L2_CID_BASE; c.index < V4L2_CID_LASTP1; c.index++) {
  if (ioctl (fd, VIDIOC_QUERYCTRL, &c) == 0) {
    if (c.flags & V4L2_CTRL_FLAG_DISABLED)
      continue;
    printf ("Control %s supported\n", c.name);
  } else if (errno != EINVAL) {
    perror ("VIDIOC_QUERYCTRL");
    exit (EXIT_FAILURE);
  }
}

for (c.index = V4L2_CID_PRIVATE_BASE;; c.index++) {
  if (ioctl (fd, VIDIOC_QUERYCTRL, &c) == 0) {
    if (c.flags & V4L2_CTRL_FLAG_DISABLED)
      continue;
    printf ("Control %s supported\n", c.name);
  } else {
    if (errno == EINVAL) 
      break;
    perror ("VIDIOC_QUERYCTRL");
    exit (EXIT_FAILURE);
  }
}

The idea of V4L2_CTRL_FLAG_DISABLED in the old api was exactly that
drivers will not support all predefined controls and may disable some
only after probing the hardware. IMO returning EINVAL would suffice. The
other flag V4L2_CTRL_FLAG_GRABBED is the equivalent of EBUSY when
attempting to change the control, i.e. a GUI can render the control in a
disabled state. It's never been used AFAIK.

Michael





[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux