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