cam_sync_util.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __CAM_SYNC_UTIL_H__
  6. #define __CAM_SYNC_UTIL_H__
  7. #include "cam_sync_private.h"
  8. #include "cam_debug_util.h"
  9. extern struct sync_device *sync_dev;
  10. /**
  11. * @brief: Finds an empty row in the sync table and sets its corresponding bit
  12. * in the bit array
  13. *
  14. * @param sync_dev : Pointer to the sync device instance
  15. * @param idx : Pointer to an long containing the index found in the bit
  16. * array
  17. *
  18. * @return Status of operation. Negative in case of error. Zero otherwise.
  19. */
  20. int cam_sync_util_find_and_set_empty_row(struct sync_device *sync_dev,
  21. long *idx);
  22. /**
  23. * @brief: Function to initialize an empty row in the sync table. This should be
  24. * called only for individual sync objects.
  25. *
  26. * @param table : Pointer to the sync objects table
  27. * @param idx : Index of row to initialize
  28. * @param name : Optional string representation of the sync object. Should be
  29. * 63 characters or less
  30. * @param type : type of row to be initialized
  31. * @return Status of operation. Negative in case of error. Zero otherwise.
  32. */
  33. int cam_sync_init_row(struct sync_table_row *table,
  34. uint32_t idx, const char *name, uint32_t type);
  35. /**
  36. * @brief: Function to uninitialize a row in the sync table
  37. *
  38. * @param table : Pointer to the sync objects table
  39. * @param idx : Index of row to initialize
  40. *
  41. * @return Status of operation. Negative in case of error. Zero otherwise.
  42. */
  43. int cam_sync_deinit_object(struct sync_table_row *table, uint32_t idx);
  44. /**
  45. * @brief: Function to initialize a row in the sync table when the object is a
  46. * group object, also known as a merged sync object
  47. *
  48. * @param table : Pointer to the sync objects table
  49. * @param idx : Index of row to initialize
  50. * @param sync_objs : Array of sync objects which will merged
  51. * or grouped together
  52. * @param num_objs : Number of sync objects in the array
  53. *
  54. * @return Status of operation. Negative in case of error. Zero otherwise.
  55. */
  56. int cam_sync_init_group_object(struct sync_table_row *table,
  57. uint32_t idx,
  58. uint32_t *sync_objs,
  59. uint32_t num_objs);
  60. int cam_sync_deinit_object(struct sync_table_row *table, uint32_t idx);
  61. /**
  62. * @brief: Function to dispatch a kernel callback for a sync callback
  63. *
  64. * @param cb_dispatch_work : Pointer to the work_struct that needs to be
  65. * dispatched
  66. *
  67. * @return None
  68. */
  69. void cam_sync_util_cb_dispatch(struct work_struct *cb_dispatch_work);
  70. /**
  71. * @brief: Function to dispatch callbacks for a signaled sync object
  72. *
  73. * @sync_obj : Sync object that is signaled
  74. * @status : Status of the signaled object
  75. * @evt_param : Event paramaeter
  76. *
  77. * @return None
  78. */
  79. void cam_sync_util_dispatch_signaled_cb(int32_t sync_obj,
  80. uint32_t status, uint32_t evt_param);
  81. /**
  82. * @brief: Function to send V4L event to user space
  83. * @param id : V4L event id to send
  84. * @param sync_obj : Sync obj for which event needs to be sent
  85. * @param status : Status of the event
  86. * @payload : Payload that needs to be sent to user space
  87. * @len : Length of the payload
  88. * @evt_param : Event Paramenter
  89. *
  90. * @return None
  91. */
  92. void cam_sync_util_send_v4l2_event(uint32_t id,
  93. uint32_t sync_obj,
  94. int status,
  95. void *payload,
  96. int len,
  97. uint32_t evt_param);
  98. /**
  99. * @brief: Function which gets the next state of the sync object based on the
  100. * current state and the new state
  101. *
  102. * @param current_state : Current state of the sync object
  103. * @param new_state : New state of the sync object
  104. *
  105. * @return Next state of the sync object
  106. */
  107. int cam_sync_util_update_parent_state(struct sync_table_row *parent_row,
  108. int new_state);
  109. /**
  110. * @brief: Function to clean up the children of a sync object
  111. * @row : Row whose child list to clean
  112. * @list_clean_type : Clean specific object or clean all objects
  113. * @sync_obj : Sync object to be clean if list clean type is
  114. * SYNC_LIST_CLEAN_ONE
  115. *
  116. * @return None
  117. */
  118. void cam_sync_util_cleanup_children_list(struct sync_table_row *row,
  119. uint32_t list_clean_type, uint32_t sync_obj);
  120. /**
  121. * @brief: Function to clean up the parents of a sync object
  122. * @row : Row whose parent list to clean
  123. * @list_clean_type : Clean specific object or clean all objects
  124. * @sync_obj : Sync object to be clean if list clean type is
  125. * SYNC_LIST_CLEAN_ONE
  126. *
  127. * @return None
  128. */
  129. void cam_sync_util_cleanup_parents_list(struct sync_table_row *row,
  130. uint32_t list_clean_type, uint32_t sync_obj);
  131. #endif /* __CAM_SYNC_UTIL_H__ */