u_uvc.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * u_uvc.h
  4. *
  5. * Utility definitions for the uvc function
  6. *
  7. * Copyright (c) 2013-2014 Samsung Electronics Co., Ltd.
  8. * http://www.samsung.com
  9. *
  10. * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
  11. */
  12. #ifndef U_UVC_H
  13. #define U_UVC_H
  14. #include <linux/mutex.h>
  15. #include <linux/usb/composite.h>
  16. #include <linux/usb/video.h>
  17. #define fi_to_f_uvc_opts(f) container_of(f, struct f_uvc_opts, func_inst)
  18. struct f_uvc_opts {
  19. struct usb_function_instance func_inst;
  20. unsigned int streaming_interval;
  21. unsigned int streaming_maxpacket;
  22. unsigned int streaming_maxburst;
  23. unsigned int control_interface;
  24. unsigned int streaming_interface;
  25. /*
  26. * Control descriptors array pointers for full-/high-speed and
  27. * super-speed. They point by default to the uvc_fs_control_cls and
  28. * uvc_ss_control_cls arrays respectively. Legacy gadgets must
  29. * override them in their gadget bind callback.
  30. */
  31. const struct uvc_descriptor_header * const *fs_control;
  32. const struct uvc_descriptor_header * const *ss_control;
  33. /*
  34. * Streaming descriptors array pointers for full-speed, high-speed and
  35. * super-speed. They will point to the uvc_[fhs]s_streaming_cls arrays
  36. * for configfs-based gadgets. Legacy gadgets must initialize them in
  37. * their gadget bind callback.
  38. */
  39. const struct uvc_descriptor_header * const *fs_streaming;
  40. const struct uvc_descriptor_header * const *hs_streaming;
  41. const struct uvc_descriptor_header * const *ss_streaming;
  42. /* Default control descriptors for configfs-based gadgets. */
  43. struct uvc_camera_terminal_descriptor uvc_camera_terminal;
  44. struct uvc_processing_unit_descriptor uvc_processing;
  45. struct uvc_output_terminal_descriptor uvc_output_terminal;
  46. struct uvc_color_matching_descriptor uvc_color_matching;
  47. /*
  48. * Control descriptors pointers arrays for full-/high-speed and
  49. * super-speed. The first element is a configurable control header
  50. * descriptor, the other elements point to the fixed default control
  51. * descriptors. Used by configfs only, must not be touched by legacy
  52. * gadgets.
  53. */
  54. struct uvc_descriptor_header *uvc_fs_control_cls[5];
  55. struct uvc_descriptor_header *uvc_ss_control_cls[5];
  56. /*
  57. * Streaming descriptors for full-speed, high-speed and super-speed.
  58. * Used by configfs only, must not be touched by legacy gadgets. The
  59. * arrays are allocated at runtime as the number of descriptors isn't
  60. * known in advance.
  61. */
  62. struct uvc_descriptor_header **uvc_fs_streaming_cls;
  63. struct uvc_descriptor_header **uvc_hs_streaming_cls;
  64. struct uvc_descriptor_header **uvc_ss_streaming_cls;
  65. /*
  66. * Read/write access to configfs attributes is handled by configfs.
  67. *
  68. * This lock protects the descriptors from concurrent access by
  69. * read/write and symlink creation/removal.
  70. */
  71. struct mutex lock;
  72. int refcnt;
  73. };
  74. #endif /* U_UVC_H */