/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (c) 2020 MediaTek Inc. */ #ifndef __VPU_CMD_H__ #define __VPU_CMD_H__ #include #include #include #include "vpu_algo.h" struct vpu_device; int vpu_cmd_init(struct vpu_device *vd); void vpu_cmd_exit(struct vpu_device *vd); void vpu_cmd_exit_rv(struct vpu_device *vd); void vpu_cmd_clear(struct vpu_device *vd); void vpu_cmd_lock(struct vpu_device *vd, int prio); void vpu_cmd_unlock(struct vpu_device *vd, int prio); void vpu_cmd_lock_all(struct vpu_device *vd); void vpu_cmd_unlock_all(struct vpu_device *vd); /* boost value handling */ int vpu_cmd_boost_set(struct vpu_device *vd, int prio, int boost); int vpu_cmd_boost_put(struct vpu_device *vd, int prio); int vpu_cmd_boost(struct vpu_device *vd, int prio); /* command algorithm */ void vpu_cmd_alg_set(struct vpu_device *vd, int prio, struct __vpu_algo *alg); struct __vpu_algo *vpu_cmd_alg(struct vpu_device *vd, int prio); const char *vpu_cmd_alg_name(struct vpu_device *vd, int prio); static inline void vpu_cmd_alg_clr(struct vpu_device *vd, int prio) { vpu_cmd_alg_set(vd, prio, NULL); } /* command flow control */ void vpu_cmd_run(struct vpu_device *vd, int prio, uint32_t cmd); void vpu_cmd_done(struct vpu_device *vd, int prio, uint32_t result, uint32_t alg_ret); int vpu_cmd_result(struct vpu_device *vd, int prio); uint32_t vpu_cmd_alg_ret(struct vpu_device *vd, int prio); wait_queue_head_t *vpu_cmd_waitq(struct vpu_device *vd, int prio); void vpu_cmd_wake_all(struct vpu_device *vd); /* d2d command buffer */ uint32_t vpu_cmd_buf_iova(struct vpu_device *vd, int prio); int vpu_cmd_buf_set(struct vpu_device *vd, int prio, void *buf, size_t size); /* command control data */ struct vpu_cmd_ctl { uint32_t cmd; uint64_t start_t; /* command start time */ uint64_t end_t; /* command end time */ int boost; /* boost value from vpu_reqest */ struct mutex lock; wait_queue_head_t wait; struct __vpu_algo *alg; /* current active algorithm */ bool done; uint32_t result; /* result from boot code */ uint32_t alg_ret; /* algorithm's return value */ struct vpu_iova vi; /* command buffer */ uint64_t exe_cnt; /* debug: execution count */ }; extern struct vpu_cmd_ops vpu_cmd_ops_ap; extern struct vpu_cmd_ops vpu_cmd_ops_rv; #endif