patch-v4l2uvc_c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. $OpenBSD: patch-v4l2uvc_c,v 1.3 2017/05/12 23:10:26 espie Exp $
  2. Index: v4l2uvc.c
  3. --- v4l2uvc.c.orig
  4. +++ v4l2uvc.c
  5. @@ -143,27 +143,17 @@ init_videoIn(struct vdIn *vd, char *device, int width,
  6. close(vd->fd);
  7. return -1;
  8. }
  9. -int enum_controls(int vd) //struct vdIn *vd)
  10. -{
  11. - struct v4l2_queryctrl queryctrl;
  12. - struct v4l2_querymenu querymenu;
  13. - struct v4l2_control control_s;
  14. - struct v4l2_input* getinput;
  15. - //Name of the device
  16. - getinput=(struct v4l2_input *) calloc(1, sizeof(struct v4l2_input));
  17. - memset(getinput, 0, sizeof(struct v4l2_input));
  18. - getinput->index=0;
  19. - ioctl(vd,VIDIOC_ENUMINPUT , getinput);
  20. - printf ("Available controls of device '%s' (Type 1=Integer 2=Boolean 3=Menu 4=Button)\n", getinput->name);
  21. -
  22. //subroutine to read menu items of controls with type 3
  23. - void enumerate_menu (void) {
  24. +
  25. +static void enumerate_menu (int vd, struct v4l2_queryctrl *queryctrl)
  26. +{
  27. + struct v4l2_querymenu querymenu;
  28. printf (" Menu items:\n");
  29. memset (&querymenu, 0, sizeof (querymenu));
  30. - querymenu.id = queryctrl.id;
  31. - for (querymenu.index = queryctrl.minimum;
  32. - querymenu.index <= queryctrl.maximum;
  33. + querymenu.id = queryctrl->id;
  34. + for (querymenu.index = queryctrl->minimum;
  35. + querymenu.index <= queryctrl->maximum;
  36. querymenu.index++) {
  37. if (0 == ioctl (vd, VIDIOC_QUERYMENU, &querymenu)) {
  38. printf (" index:%d name:%s\n", querymenu.index, querymenu.name);
  39. @@ -173,7 +163,23 @@ int enum_controls(int vd) //struct vdIn *vd)
  40. break;
  41. }
  42. }
  43. - }
  44. +}
  45. +
  46. +#define enumerate_menu() enumerate_menu(vd, &queryctrl)
  47. +
  48. +int enum_controls(int vd) //struct vdIn *vd)
  49. +{
  50. + struct v4l2_queryctrl queryctrl;
  51. + struct v4l2_control control_s;
  52. + struct v4l2_input* getinput;
  53. +
  54. + //Name of the device
  55. + getinput=(struct v4l2_input *) calloc(1, sizeof(struct v4l2_input));
  56. + memset(getinput, 0, sizeof(struct v4l2_input));
  57. + getinput->index=0;
  58. + ioctl(vd,VIDIOC_ENUMINPUT , getinput);
  59. + printf ("Available controls of device '%s' (Type 1=Integer 2=Boolean 3=Menu 4=Button)\n", getinput->name);
  60. +
  61. //predefined controls
  62. printf ("V4L2_CID_BASE (predefined controls):\n");