| 1 | /* |
| 2 | Copyright (c) 2016, Raspberry Pi (Trading) Ltd |
| 3 | All rights reserved. |
| 4 | |
| 5 | Redistribution and use in source and binary forms, with or without |
| 6 | modification, are permitted provided that the following conditions are met: |
| 7 | * Redistributions of source code must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above copyright |
| 10 | notice, this list of conditions and the following disclaimer in the |
| 11 | documentation and/or other materials provided with the distribution. |
| 12 | * Neither the name of the copyright holder nor the |
| 13 | names of its contributors may be used to endorse or promote products |
| 14 | derived from this software without specific prior written permission. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
| 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef VC_VCHI_GPUSERV_H |
| 29 | #define VC_VCHI_GPUSERV_H |
| 30 | #include "interface/vchiq_arm/vchiq.h" |
| 31 | |
| 32 | // these go in command word of gpu_job_s |
| 33 | // EXECUTE_VPU and EXECUTE_QPU are valid from host |
| 34 | enum { EXECUTE_NONE, EXECUTE_VPU, EXECUTE_QPU, EXECUTE_SYNC }; |
| 35 | |
| 36 | struct vpu_job_s { |
| 37 | // these are function address and parameters for vpu job |
| 38 | uint32_t q[7]; |
| 39 | uint32_t dummy[21]; |
| 40 | }; |
| 41 | |
| 42 | struct qpu_job_s { |
| 43 | // parameters for qpu job |
| 44 | uint32_t jobs; |
| 45 | uint32_t noflush; |
| 46 | uint32_t timeout; |
| 47 | uint32_t dummy; |
| 48 | uint32_t control[12][2]; |
| 49 | }; |
| 50 | |
| 51 | struct sync_job_s { |
| 52 | // parameters for syncjob |
| 53 | // bit 0 set means wait for preceding vpu jobs to complete |
| 54 | // bit 1 set means wait for preceding qpu jobs to complete |
| 55 | uint32_t mask; |
| 56 | uint32_t dummy[27]; |
| 57 | }; |
| 58 | |
| 59 | struct gpu_callback_s { |
| 60 | // callback to call when complete (can be NULL) |
| 61 | void (*func)(); |
| 62 | void *cookie; |
| 63 | }; |
| 64 | |
| 65 | struct gpu_internal_s { |
| 66 | void *message; |
| 67 | int refcount; |
| 68 | }; |
| 69 | |
| 70 | struct gpu_job_s { |
| 71 | // from enum above |
| 72 | uint32_t command; |
| 73 | // qpu or vpu jobs |
| 74 | union { |
| 75 | struct vpu_job_s v; |
| 76 | struct qpu_job_s q; |
| 77 | struct sync_job_s s; |
| 78 | } u; |
| 79 | // callback function to call when complete |
| 80 | struct gpu_callback_s callback; |
| 81 | // for internal use - leave as zero |
| 82 | struct gpu_internal_s internal; |
| 83 | }; |
| 84 | |
| 85 | /* Initialise gpu service. Returns its interface number. This initialises |
| 86 | the host side of the interface, it does not send anything to VideoCore. */ |
| 87 | |
| 88 | VCHPRE_ int32_t VCHPOST_ vc_gpuserv_init(void); |
| 89 | |
| 90 | VCHPRE_ void VCHPOST_ vc_gpuserv_deinit(void); |
| 91 | |
| 92 | VCHPRE_ int32_t VCHPOST_ vc_gpuserv_execute_code(int num_jobs, struct gpu_job_s jobs[]); |
| 93 | |
| 94 | #endif |
| 95 | |