u_uvc.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. /*
  24. * Control descriptors array pointers for full-/high-speed and
  25. * super-speed. They point by default to the uvc_fs_control_cls and
  26. * uvc_ss_control_cls arrays respectively. Legacy gadgets must
  27. * override them in their gadget bind callback.
  28. */
  29. const struct uvc_descriptor_header * const *fs_control;
  30. const struct uvc_descriptor_header * const *ss_control;
  31. /*
  32. * Streaming descriptors array pointers for full-speed, high-speed and
  33. * super-speed. They will point to the uvc_[fhs]s_streaming_cls arrays
  34. * for configfs-based gadgets. Legacy gadgets must initialize them in
  35. * their gadget bind callback.
  36. */
  37. const struct uvc_descriptor_header * const *fs_streaming;
  38. const struct uvc_descriptor_header * const *hs_streaming;
  39. const struct uvc_descriptor_header * const *ss_streaming;
  40. /* Default control descriptors for configfs-based gadgets. */
  41. struct uvc_camera_terminal_descriptor uvc_camera_terminal;
  42. struct uvc_processing_unit_descriptor uvc_processing;
  43. struct uvc_output_terminal_descriptor uvc_output_terminal;
  44. struct uvc_color_matching_descriptor uvc_color_matching;
  45. /*
  46. * Control descriptors pointers arrays for full-/high-speed and
  47. * super-speed. The first element is a configurable control header
  48. * descriptor, the other elements point to the fixed default control
  49. * descriptors. Used by configfs only, must not be touched by legacy
  50. * gadgets.
  51. */
  52. struct uvc_descriptor_header *uvc_fs_control_cls[5];
  53. struct uvc_descriptor_header *uvc_ss_control_cls[5];
  54. /*
  55. * Streaming descriptors for full-speed, high-speed and super-speed.
  56. * Used by configfs only, must not be touched by legacy gadgets. The
  57. * arrays are allocated at runtime as the number of descriptors isn't
  58. * known in advance.
  59. */
  60. struct uvc_descriptor_header **uvc_fs_streaming_cls;
  61. struct uvc_descriptor_header **uvc_hs_streaming_cls;
  62. struct uvc_descriptor_header **uvc_ss_streaming_cls;
  63. /*
  64. * Read/write access to configfs attributes is handled by configfs.
  65. *
  66. * This lock protects the descriptors from concurrent access by
  67. * read/write and symlink creation/removal.
  68. */
  69. struct mutex lock;
  70. int refcnt;
  71. };
  72. #endif /* U_UVC_H */