drm/GPU: Add support Imagination PowerVR GPU driver v1.17
[platform/kernel/linux-starfive.git] / drivers / gpu / drm / img / img-rogue / generated / rogue / pvrtl_bridge / client_pvrtl_direct_bridge.c
1 /*******************************************************************************
2 @File
3 @Title          Direct client bridge for pvrtl
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Implements the client side of the bridge for pvrtl
6                 which is used in calls from Server context.
7 @License        Dual MIT/GPLv2
8
9 The contents of this file are subject to the MIT license as set out below.
10
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
21 Alternatively, the contents of this file may be used under the terms of
22 the GNU General Public License Version 2 ("GPL") in which case the provisions
23 of GPL are applicable instead of those above.
24
25 If you wish to allow use of your version of this file only under the terms of
26 GPL, and not to allow others to use your version of this file under the terms
27 of the MIT license, indicate your decision by deleting the provisions above
28 and replace them with the notice and other provisions required by GPL as set
29 out in the file called "GPL-COPYING" included in this distribution. If you do
30 not delete the provisions above, a recipient may use your version of this file
31 under the terms of either the MIT license or GPL.
32
33 This License is also included in this distribution in the file called
34 "MIT-COPYING".
35
36 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
37 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
40 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
41 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 *******************************************************************************/
44
45 #include "client_pvrtl_bridge.h"
46 #include "img_defs.h"
47 #include "pvr_debug.h"
48
49 /* Module specific includes */
50 #include "devicemem_typedefs.h"
51 #include "pvrsrv_tlcommon.h"
52
53 #include "tlserver.h"
54
55 IMG_INTERNAL PVRSRV_ERROR BridgeTLOpenStream(IMG_HANDLE hBridge,
56                                              const IMG_CHAR * puiName,
57                                              IMG_UINT32 ui32Mode,
58                                              IMG_HANDLE * phSD, IMG_HANDLE * phTLPMR)
59 {
60         PVRSRV_ERROR eError;
61         TL_STREAM_DESC *psSDInt = NULL;
62         PMR *psTLPMRInt = NULL;
63         PVR_UNREFERENCED_PARAMETER(hBridge);
64
65         eError = TLServerOpenStreamKM(puiName, ui32Mode, &psSDInt, &psTLPMRInt);
66
67         *phSD = psSDInt;
68         *phTLPMR = psTLPMRInt;
69         return eError;
70 }
71
72 IMG_INTERNAL PVRSRV_ERROR BridgeTLCloseStream(IMG_HANDLE hBridge, IMG_HANDLE hSD)
73 {
74         PVRSRV_ERROR eError;
75         TL_STREAM_DESC *psSDInt;
76         PVR_UNREFERENCED_PARAMETER(hBridge);
77
78         psSDInt = (TL_STREAM_DESC *) hSD;
79
80         eError = TLServerCloseStreamKM(psSDInt);
81
82         return eError;
83 }
84
85 IMG_INTERNAL PVRSRV_ERROR BridgeTLAcquireData(IMG_HANDLE hBridge,
86                                               IMG_HANDLE hSD,
87                                               IMG_UINT32 * pui32ReadOffset,
88                                               IMG_UINT32 * pui32ReadLen)
89 {
90         PVRSRV_ERROR eError;
91         TL_STREAM_DESC *psSDInt;
92         PVR_UNREFERENCED_PARAMETER(hBridge);
93
94         psSDInt = (TL_STREAM_DESC *) hSD;
95
96         eError = TLServerAcquireDataKM(psSDInt, pui32ReadOffset, pui32ReadLen);
97
98         return eError;
99 }
100
101 IMG_INTERNAL PVRSRV_ERROR BridgeTLReleaseData(IMG_HANDLE hBridge,
102                                               IMG_HANDLE hSD,
103                                               IMG_UINT32 ui32ReadOffset, IMG_UINT32 ui32ReadLen)
104 {
105         PVRSRV_ERROR eError;
106         TL_STREAM_DESC *psSDInt;
107         PVR_UNREFERENCED_PARAMETER(hBridge);
108
109         psSDInt = (TL_STREAM_DESC *) hSD;
110
111         eError = TLServerReleaseDataKM(psSDInt, ui32ReadOffset, ui32ReadLen);
112
113         return eError;
114 }
115
116 IMG_INTERNAL PVRSRV_ERROR BridgeTLDiscoverStreams(IMG_HANDLE hBridge,
117                                                   const IMG_CHAR * puiNamePattern,
118                                                   IMG_UINT32 ui32Size,
119                                                   IMG_CHAR * puiStreams, IMG_UINT32 * pui32NumFound)
120 {
121         PVRSRV_ERROR eError;
122         PVR_UNREFERENCED_PARAMETER(hBridge);
123
124         eError = TLServerDiscoverStreamsKM(puiNamePattern, ui32Size, puiStreams, pui32NumFound);
125
126         return eError;
127 }
128
129 IMG_INTERNAL PVRSRV_ERROR BridgeTLReserveStream(IMG_HANDLE hBridge,
130                                                 IMG_HANDLE hSD,
131                                                 IMG_UINT32 * pui32BufferOffset,
132                                                 IMG_UINT32 ui32Size,
133                                                 IMG_UINT32 ui32SizeMin, IMG_UINT32 * pui32Available)
134 {
135         PVRSRV_ERROR eError;
136         TL_STREAM_DESC *psSDInt;
137         PVR_UNREFERENCED_PARAMETER(hBridge);
138
139         psSDInt = (TL_STREAM_DESC *) hSD;
140
141         eError =
142             TLServerReserveStreamKM(psSDInt,
143                                     pui32BufferOffset, ui32Size, ui32SizeMin, pui32Available);
144
145         return eError;
146 }
147
148 IMG_INTERNAL PVRSRV_ERROR BridgeTLCommitStream(IMG_HANDLE hBridge,
149                                                IMG_HANDLE hSD, IMG_UINT32 ui32ReqSize)
150 {
151         PVRSRV_ERROR eError;
152         TL_STREAM_DESC *psSDInt;
153         PVR_UNREFERENCED_PARAMETER(hBridge);
154
155         psSDInt = (TL_STREAM_DESC *) hSD;
156
157         eError = TLServerCommitStreamKM(psSDInt, ui32ReqSize);
158
159         return eError;
160 }
161
162 IMG_INTERNAL PVRSRV_ERROR BridgeTLWriteData(IMG_HANDLE hBridge,
163                                             IMG_HANDLE hSD,
164                                             IMG_UINT32 ui32Size, IMG_BYTE * pui8Data)
165 {
166         PVRSRV_ERROR eError;
167         TL_STREAM_DESC *psSDInt;
168         PVR_UNREFERENCED_PARAMETER(hBridge);
169
170         psSDInt = (TL_STREAM_DESC *) hSD;
171
172         eError = TLServerWriteDataKM(psSDInt, ui32Size, pui8Data);
173
174         return eError;
175 }