cam_sync.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #ifndef __UAPI_CAM_SYNC_H__
  2. #define __UAPI_CAM_SYNC_H__
  3. #include <linux/videodev2.h>
  4. #include <linux/types.h>
  5. #include <linux/ioctl.h>
  6. #include <linux/media.h>
  7. #define CAM_SYNC_DEVICE_NAME "cam_sync_device"
  8. /* V4L event which user space will subscribe to */
  9. #define CAM_SYNC_V4L_EVENT (V4L2_EVENT_PRIVATE_START + 0)
  10. /* Specific event ids to get notified in user space */
  11. #define CAM_SYNC_V4L_EVENT_ID_CB_TRIG 0
  12. /* Size of opaque payload sent to kernel for safekeeping until signal time */
  13. #define CAM_SYNC_USER_PAYLOAD_SIZE 2
  14. /* Device type for sync device needed for device discovery */
  15. #define CAM_SYNC_DEVICE_TYPE (MEDIA_ENT_F_OLD_BASE)
  16. #define CAM_SYNC_GET_PAYLOAD_PTR(ev, type) \
  17. (type *)((char *)ev.u.data + sizeof(struct cam_sync_ev_header))
  18. #define CAM_SYNC_GET_HEADER_PTR(ev) \
  19. ((struct cam_sync_ev_header *)ev.u.data)
  20. #define CAM_SYNC_STATE_INVALID 0
  21. #define CAM_SYNC_STATE_ACTIVE 1
  22. #define CAM_SYNC_STATE_SIGNALED_SUCCESS 2
  23. #define CAM_SYNC_STATE_SIGNALED_ERROR 3
  24. /**
  25. * struct cam_sync_ev_header - Event header for sync event notification
  26. *
  27. * @sync_obj: Sync object
  28. * @status: Status of the object
  29. */
  30. struct cam_sync_ev_header {
  31. int32_t sync_obj;
  32. int32_t status;
  33. };
  34. /**
  35. * struct cam_sync_info - Sync object creation information
  36. *
  37. * @name: Optional string representation of the sync object
  38. * @sync_obj: Sync object returned after creation in kernel
  39. */
  40. struct cam_sync_info {
  41. char name[64];
  42. int32_t sync_obj;
  43. };
  44. /**
  45. * struct cam_sync_signal - Sync object signaling struct
  46. *
  47. * @sync_obj: Sync object to be signaled
  48. * @sync_state: State of the sync object to which it should be signaled
  49. */
  50. struct cam_sync_signal {
  51. int32_t sync_obj;
  52. uint32_t sync_state;
  53. };
  54. /**
  55. * struct cam_sync_merge - Merge information for sync objects
  56. *
  57. * @sync_objs: Pointer to sync objects
  58. * @num_objs: Number of objects in the array
  59. * @merged: Merged sync object
  60. */
  61. struct cam_sync_merge {
  62. __u64 sync_objs;
  63. uint32_t num_objs;
  64. int32_t merged;
  65. };
  66. /**
  67. * struct cam_sync_userpayload_info - Payload info from user space
  68. *
  69. * @sync_obj: Sync object for which payload has to be registered for
  70. * @reserved: Reserved
  71. * @payload: Pointer to user payload
  72. */
  73. struct cam_sync_userpayload_info {
  74. int32_t sync_obj;
  75. uint32_t reserved;
  76. __u64 payload[CAM_SYNC_USER_PAYLOAD_SIZE];
  77. };
  78. /**
  79. * struct cam_sync_wait - Sync object wait information
  80. *
  81. * @sync_obj: Sync object to wait on
  82. * @reserved: Reserved
  83. * @timeout_ms: Timeout in milliseconds
  84. */
  85. struct cam_sync_wait {
  86. int32_t sync_obj;
  87. uint32_t reserved;
  88. uint64_t timeout_ms;
  89. };
  90. /**
  91. * struct cam_private_ioctl_arg - Sync driver ioctl argument
  92. *
  93. * @id: IOCTL command id
  94. * @size: Size of command payload
  95. * @result: Result of command execution
  96. * @reserved: Reserved
  97. * @ioctl_ptr: Pointer to user data
  98. */
  99. struct cam_private_ioctl_arg {
  100. __u32 id;
  101. __u32 size;
  102. __u32 result;
  103. __u32 reserved;
  104. __user __u64 ioctl_ptr;
  105. };
  106. #define CAM_PRIVATE_IOCTL_CMD \
  107. _IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_private_ioctl_arg)
  108. #define CAM_SYNC_CREATE 0
  109. #define CAM_SYNC_DESTROY 1
  110. #define CAM_SYNC_SIGNAL 2
  111. #define CAM_SYNC_MERGE 3
  112. #define CAM_SYNC_REGISTER_PAYLOAD 4
  113. #define CAM_SYNC_DEREGISTER_PAYLOAD 5
  114. #define CAM_SYNC_WAIT 6
  115. #endif /* __UAPI_CAM_SYNC_H__ */