Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. void set_brightness(int fd, int p)
  2. {
  3. struct v4l2_queryctrl queryctrl;
  4. struct v4l2_control control;
  5.  
  6. int s = ((255*p)/100);
  7.  
  8. memset (&queryctrl, 0, sizeof (queryctrl));
  9. queryctrl.id = V4L2_CID_BRIGHTNESS;
  10.  
  11. if (-1 == ioctl (fd, VIDIOC_QUERYCTRL, &queryctrl)) {
  12. if (errno != EINVAL) {
  13. perror ("VIDIOC_QUERYCTRL");
  14. return;
  15. } else {
  16. printf ("V4L2_CID_BRIGHTNESS is not supported\n");
  17. }
  18. } else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
  19. printf ("V4L2_CID_BRIGHTNESS is not supported\n");
  20. } else {
  21. memset (&control, 0, sizeof (control));
  22. control.id = V4L2_CID_BRIGHTNESS;
  23. control.value = (queryctrl.minimum + (s * queryctrl.step));
  24.  
  25. if (-1 == ioctl (fd, VIDIOC_S_CTRL, &control)) {
  26. perror ("VIDIOC_S_CTRL");
  27. return;
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement