u_uvc.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 <andrzejtp2010@gmail.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. char function_name[32];
  26. unsigned int last_unit_id;
  27. bool enable_interrupt_ep;
  28. /*
  29. * Control descriptors array pointers for full-/high-speed and
  30. * super-speed. They point by default to the uvc_fs_control_cls and
  31. * uvc_ss_control_cls arrays respectively. Legacy gadgets must
  32. * override them in their gadget bind callback.
  33. */
  34. const struct uvc_descriptor_header * const *fs_control;
  35. const struct uvc_descriptor_header * const *ss_control;
  36. /*
  37. * Streaming descriptors array pointers for full-speed, high-speed and
  38. * super-speed. They will point to the uvc_[fhs]s_streaming_cls arrays
  39. * for configfs-based gadgets. Legacy gadgets must initialize them in
  40. * their gadget bind callback.
  41. */
  42. const struct uvc_descriptor_header * const *fs_streaming;
  43. const struct uvc_descriptor_header * const *hs_streaming;
  44. const struct uvc_descriptor_header * const *ss_streaming;
  45. /* Default control descriptors for configfs-based gadgets. */
  46. struct uvc_camera_terminal_descriptor uvc_camera_terminal;
  47. struct uvc_processing_unit_descriptor uvc_processing;
  48. struct uvc_output_terminal_descriptor uvc_output_terminal;
  49. /*
  50. * Control descriptors pointers arrays for full-/high-speed and
  51. * super-speed. The first element is a configurable control header
  52. * descriptor, the other elements point to the fixed default control
  53. * descriptors. Used by configfs only, must not be touched by legacy
  54. * gadgets.
  55. */
  56. struct uvc_descriptor_header *uvc_fs_control_cls[5];
  57. struct uvc_descriptor_header *uvc_ss_control_cls[5];
  58. /*
  59. * Control descriptors for extension units. There could be any number
  60. * of these, including none at all.
  61. */
  62. struct list_head extension_units;
  63. /*
  64. * Streaming descriptors for full-speed, high-speed and super-speed.
  65. * Used by configfs only, must not be touched by legacy gadgets. The
  66. * arrays are allocated at runtime as the number of descriptors isn't
  67. * known in advance.
  68. */
  69. struct uvc_descriptor_header **uvc_fs_streaming_cls;
  70. struct uvc_descriptor_header **uvc_hs_streaming_cls;
  71. struct uvc_descriptor_header **uvc_ss_streaming_cls;
  72. /*
  73. * Indexes into the function's string descriptors allowing users to set
  74. * custom descriptions rather than the hard-coded defaults.
  75. */
  76. u8 iad_index;
  77. u8 vs0_index;
  78. u8 vs1_index;
  79. /*
  80. * Read/write access to configfs attributes is handled by configfs.
  81. *
  82. * This lock protects the descriptors from concurrent access by
  83. * read/write and symlink creation/removal.
  84. */
  85. struct mutex lock;
  86. int refcnt;
  87. /*
  88. * Only for legacy gadget. Shall be NULL for configfs-composed gadgets,
  89. * which is guaranteed by alloc_inst implementation of f_uvc doing kzalloc.
  90. */
  91. struct uvcg_streaming_header *header;
  92. };
  93. #endif /* U_UVC_H */