cam_custom_context.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* SPDX-License-Identifier: GPL-2.0-only
  2. *
  3. * Copyright (c) 2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _CAM_CUSTOM_CONTEXT_H_
  6. #define _CAM_CUSTOM_CONTEXT_H_
  7. #include <linux/spinlock.h>
  8. #include <media/cam_custom.h>
  9. #include <media/cam_defs.h>
  10. #include "cam_context.h"
  11. #include "cam_custom_hw_mgr_intf.h"
  12. /*
  13. * Maximum hw resource - This number is based on the maximum
  14. * output port resource. The current maximum resource number
  15. * is 2.
  16. */
  17. #define CAM_CUSTOM_DEV_CTX_RES_MAX 2
  18. #define CAM_CUSTOM_CTX_CFG_MAX 8
  19. /* forward declaration */
  20. struct cam_custom_context;
  21. /**
  22. * struct cam_custom_dev_ctx_req - Custom context request object
  23. *
  24. * @base: Common request object pointer
  25. * @cfg: Custom hardware configuration array
  26. * @num_cfg: Number of custom hardware configuration entries
  27. * @fence_map_out: Output fence mapping array
  28. * @num_fence_map_out: Number of the output fence map
  29. * @fence_map_in: Input fence mapping array
  30. * @num_fence_map_in: Number of input fence map
  31. * @num_acked: Count to track acked entried for output.
  32. * If count equals the number of fence out, it means
  33. * the request has been completed.
  34. * @hw_update_data: HW update data for this request
  35. *
  36. */
  37. struct cam_custom_dev_ctx_req {
  38. struct cam_ctx_request *base;
  39. struct cam_hw_update_entry cfg
  40. [CAM_CUSTOM_CTX_CFG_MAX];
  41. uint32_t num_cfg;
  42. struct cam_hw_fence_map_entry fence_map_out
  43. [CAM_CUSTOM_DEV_CTX_RES_MAX];
  44. uint32_t num_fence_map_out;
  45. struct cam_hw_fence_map_entry fence_map_in
  46. [CAM_CUSTOM_DEV_CTX_RES_MAX];
  47. uint32_t num_fence_map_in;
  48. uint32_t num_acked;
  49. struct cam_custom_prepare_hw_update_data hw_update_data;
  50. };
  51. /**
  52. * struct cam_custom_context - Custom device context
  53. * @base: custom device context object
  54. * @state_machine: state machine for Custom device context
  55. * @state: Common context state
  56. * @hw_ctx: HW object returned by the acquire device command
  57. * @init_received: Indicate whether init config packet is received
  58. * @subscribe_event: The irq event mask that CRM subscribes to,
  59. * custom HW will invoke CRM cb at those event.
  60. * @active_req_cnt: Counter for the active request
  61. * @frame_id: Frame id tracking for the custom context
  62. * @hw_acquired: Flag to indicate if HW is acquired for this context
  63. * @req_base: common request structure
  64. * @req_custom: custom request structure
  65. *
  66. */
  67. struct cam_custom_context {
  68. struct cam_context *base;
  69. struct cam_ctx_ops *state_machine;
  70. uint32_t state;
  71. void *hw_ctx;
  72. bool init_received;
  73. uint32_t subscribe_event;
  74. uint32_t active_req_cnt;
  75. int64_t frame_id;
  76. bool hw_acquired;
  77. struct cam_ctx_request req_base[CAM_CTX_REQ_MAX];
  78. struct cam_custom_dev_ctx_req req_custom[CAM_CTX_REQ_MAX];
  79. };
  80. /**
  81. * cam_custom_dev_context_init()
  82. *
  83. * @brief: Initialization function for the custom context
  84. *
  85. * @ctx: Custom context obj to be initialized
  86. * @bridge_ops: Bridge call back funciton
  87. * @hw_intf: Cust hw manager interface
  88. * @ctx_id: ID for this context
  89. *
  90. */
  91. int cam_custom_dev_context_init(struct cam_custom_context *ctx,
  92. struct cam_context *ctx_base,
  93. struct cam_req_mgr_kmd_ops *bridge_ops,
  94. struct cam_hw_mgr_intf *hw_intf,
  95. uint32_t ctx_id);
  96. /**
  97. * cam_custom_dev_context_deinit()
  98. *
  99. * @brief: Deinitialize function for the Custom context
  100. *
  101. * @ctx: Custom context obj to be deinitialized
  102. *
  103. */
  104. int cam_custom_dev_context_deinit(struct cam_custom_context *ctx);
  105. #endif /* _CAM_CUSTOM_CONTEXT_H_ */