v4l2-udev.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. Copyright (C) 2014 by Leonhard Oelke <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. #include <inttypes.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /**
  20. * Initialize udev system to watch for device events
  21. *
  22. * @return monitor object, or NULL on error
  23. */
  24. void *v4l2_init_udev(void);
  25. /**
  26. * Unref the udev system
  27. *
  28. * This will also remove any registered callbacks if there are any
  29. *
  30. * @param monitor monitor object
  31. */
  32. void v4l2_unref_udev(void *monitor);
  33. /**
  34. * Callback when a device was added.
  35. *
  36. * @param dev device node of the device that was added
  37. * @param userdata pointer to userdata specified when registered
  38. */
  39. typedef void (*v4l2_device_added_cb)(const char *dev, void *userdata);
  40. /**
  41. * Callback when a device was removed.
  42. *
  43. * @param dev device node of the device that was removed
  44. * @param userdata pointer to userdata specified when registered
  45. */
  46. typedef void (*v4l2_device_removed_cb)(const char *dev, void *userdata);
  47. /**
  48. * Register the device added callback
  49. *
  50. * @param monitor monitor object
  51. * @param cb the function that should be called
  52. * @param userdata pointer to userdata that should be passed to the callback
  53. */
  54. void v4l2_set_device_added_callback(void *monitor, v4l2_device_added_cb cb,
  55. void *userdata);
  56. /**
  57. * Register the device remove callback
  58. *
  59. * @param monitor monitor object
  60. * @param cb the function that should be called
  61. * @param userdata pointer to userdata that should be passed to the callback
  62. */
  63. void v4l2_set_device_removed_callback(void *monitor, v4l2_device_removed_cb cb,
  64. void *userdata);
  65. #ifdef __cplusplus
  66. }
  67. #endif