cam_sync_util.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2017-2018, 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. *
  77. * @return None
  78. */
  79. void cam_sync_util_dispatch_signaled_cb(int32_t sync_obj,
  80. uint32_t status);
  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. *
  89. * @return None
  90. */
  91. void cam_sync_util_send_v4l2_event(uint32_t id,
  92. uint32_t sync_obj,
  93. int status,
  94. void *payload,
  95. int len);
  96. /**
  97. * @brief: Function which gets the next state of the sync object based on the
  98. * current state and the new state
  99. *
  100. * @param current_state : Current state of the sync object
  101. * @param new_state : New state of the sync object
  102. *
  103. * @return Next state of the sync object
  104. */
  105. int cam_sync_util_update_parent_state(struct sync_table_row *parent_row,
  106. int new_state);
  107. /**
  108. * @brief: Function to clean up the children of a sync object
  109. * @row : Row whose child list to clean
  110. * @list_clean_type : Clean specific object or clean all objects
  111. * @sync_obj : Sync object to be clean if list clean type is
  112. * SYNC_LIST_CLEAN_ONE
  113. *
  114. * @return None
  115. */
  116. void cam_sync_util_cleanup_children_list(struct sync_table_row *row,
  117. uint32_t list_clean_type, uint32_t sync_obj);
  118. /**
  119. * @brief: Function to clean up the parents of a sync object
  120. * @row : Row whose parent list to clean
  121. * @list_clean_type : Clean specific object or clean all objects
  122. * @sync_obj : Sync object to be clean if list clean type is
  123. * SYNC_LIST_CLEAN_ONE
  124. *
  125. * @return None
  126. */
  127. void cam_sync_util_cleanup_parents_list(struct sync_table_row *row,
  128. uint32_t list_clean_type, uint32_t sync_obj);
  129. #endif /* __CAM_SYNC_UTIL_H__ */