cam_sync_util.h 4.6 KB

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