Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void set_brightness(int fd, int p)
- {
- struct v4l2_queryctrl queryctrl;
- struct v4l2_control control;
- int s = ((255*p)/100);
- memset (&queryctrl, 0, sizeof (queryctrl));
- queryctrl.id = V4L2_CID_BRIGHTNESS;
- if (-1 == ioctl (fd, VIDIOC_QUERYCTRL, &queryctrl)) {
- if (errno != EINVAL) {
- perror ("VIDIOC_QUERYCTRL");
- return;
- } else {
- printf ("V4L2_CID_BRIGHTNESS is not supported\n");
- }
- } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
- printf ("V4L2_CID_BRIGHTNESS is not supported\n");
- } else {
- memset (&control, 0, sizeof (control));
- control.id = V4L2_CID_BRIGHTNESS;
- control.value = (queryctrl.minimum + (s * queryctrl.step));
- if (-1 == ioctl (fd, VIDIOC_S_CTRL, &control)) {
- perror ("VIDIOC_S_CTRL");
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement