pvr_ccb.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0-only OR MIT */
  2. /* Copyright (c) 2023 Imagination Technologies Ltd. */
  3. #ifndef PVR_CCB_H
  4. #define PVR_CCB_H
  5. #include "pvr_rogue_fwif.h"
  6. #include <linux/mutex.h>
  7. #include <linux/types.h>
  8. /* Forward declaration from pvr_device.h. */
  9. struct pvr_device;
  10. /* Forward declaration from pvr_gem.h. */
  11. struct pvr_fw_object;
  12. struct pvr_ccb {
  13. /** @ctrl_obj: FW object representing CCB control structure. */
  14. struct pvr_fw_object *ctrl_obj;
  15. /** @ccb_obj: FW object representing CCB. */
  16. struct pvr_fw_object *ccb_obj;
  17. /** @ctrl_fw_addr: FW virtual address of CCB control structure. */
  18. u32 ctrl_fw_addr;
  19. /** @ccb_fw_addr: FW virtual address of CCB. */
  20. u32 ccb_fw_addr;
  21. /** @num_cmds: Number of commands in this CCB. */
  22. u32 num_cmds;
  23. /** @cmd_size: Size of each command in this CCB, in bytes. */
  24. u32 cmd_size;
  25. /** @lock: Mutex protecting @ctrl and @ccb. */
  26. struct mutex lock;
  27. /**
  28. * @ctrl: Kernel mapping of CCB control structure. @lock must be held
  29. * when accessing.
  30. */
  31. struct rogue_fwif_ccb_ctl *ctrl;
  32. /** @ccb: Kernel mapping of CCB. @lock must be held when accessing. */
  33. void *ccb;
  34. };
  35. int pvr_kccb_init(struct pvr_device *pvr_dev);
  36. void pvr_kccb_fini(struct pvr_device *pvr_dev);
  37. int pvr_fwccb_init(struct pvr_device *pvr_dev);
  38. void pvr_ccb_fini(struct pvr_ccb *ccb);
  39. void pvr_fwccb_process(struct pvr_device *pvr_dev);
  40. struct dma_fence *pvr_kccb_fence_alloc(void);
  41. void pvr_kccb_fence_put(struct dma_fence *fence);
  42. struct dma_fence *
  43. pvr_kccb_reserve_slot(struct pvr_device *pvr_dev, struct dma_fence *f);
  44. void pvr_kccb_release_slot(struct pvr_device *pvr_dev);
  45. int pvr_kccb_send_cmd(struct pvr_device *pvr_dev,
  46. struct rogue_fwif_kccb_cmd *cmd, u32 *kccb_slot);
  47. int pvr_kccb_send_cmd_powered(struct pvr_device *pvr_dev,
  48. struct rogue_fwif_kccb_cmd *cmd,
  49. u32 *kccb_slot);
  50. void pvr_kccb_send_cmd_reserved_powered(struct pvr_device *pvr_dev,
  51. struct rogue_fwif_kccb_cmd *cmd,
  52. u32 *kccb_slot);
  53. int pvr_kccb_wait_for_completion(struct pvr_device *pvr_dev, u32 slot_nr, u32 timeout,
  54. u32 *rtn_out);
  55. bool pvr_kccb_is_idle(struct pvr_device *pvr_dev);
  56. void pvr_kccb_wake_up_waiters(struct pvr_device *pvr_dev);
  57. #endif /* PVR_CCB_H */