Merge tag 'lsk-v3.10-15.10-android'
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue / include / services.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          Services API Header
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Exported services API details
6 @License        Dual MIT/GPLv2
7
8 The contents of this file are subject to the MIT license as set out below.
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
23
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
43
44 #ifndef __SERVICES_H__
45 #define __SERVICES_H__
46
47 #if defined (__cplusplus)
48 extern "C" {
49 #endif
50
51 #include "img_defs.h"
52 #include "servicesext.h"
53 #include "sync_external.h"
54 #include "pdumpdefs.h"
55 #include "lock_types.h"
56 #include "pvr_debug.h"
57
58 /* 
59 */
60
61 #if defined(LDDM)
62 /* LDDM build needs to include this for the allocation structure */
63 #include "umallocation.h"
64 #endif
65
66 #include "pvrsrv_device_types.h"
67
68 /* The comment below is the front page for code-generated doxygen documentation */
69 /*!
70  ******************************************************************************
71  @mainpage
72  This document details the APIs and implementation of the Consumer Services.
73  It is intended to be used in conjunction with the Consumer Services
74  Software Architectural Specification and the Consumer Services Software
75  Functional Specification.
76  *****************************************************************************/
77
78 /******************************************************************************
79  *      #defines
80  *****************************************************************************/
81
82 /*! 4k page size definition */
83 #define PVRSRV_4K_PAGE_SIZE                                     4096UL      /*!< Size of a 4K Page */
84 #define PVRSRV_4K_PAGE_SIZE_ALIGNSHIFT          12          /*!< Amount to shift an address by so that
85                                                           it is always page-aligned */
86 /*! 16k page size definition */
87 #define PVRSRV_16K_PAGE_SIZE                                    16384UL      /*!< Size of a 16K Page */
88 #define PVRSRV_16K_PAGE_SIZE_ALIGNSHIFT         14          /*!< Amount to shift an address by so that
89                                                           it is always page-aligned */
90 /*! 64k page size definition */
91 #define PVRSRV_64K_PAGE_SIZE                                    65536UL      /*!< Size of a 64K Page */
92 #define PVRSRV_64K_PAGE_SIZE_ALIGNSHIFT         16          /*!< Amount to shift an address by so that
93                                                           it is always page-aligned */
94 /*! 256k page size definition */
95 #define PVRSRV_256K_PAGE_SIZE                                   262144UL      /*!< Size of a 256K Page */
96 #define PVRSRV_256K_PAGE_SIZE_ALIGNSHIFT                18          /*!< Amount to shift an address by so that
97                                                           it is always page-aligned */
98 /*! 1MB page size definition */
99 #define PVRSRV_1M_PAGE_SIZE                                     1048576UL      /*!< Size of a 1M Page */
100 #define PVRSRV_1M_PAGE_SIZE_ALIGNSHIFT          20          /*!< Amount to shift an address by so that
101                                                           it is always page-aligned */
102 /*! 2MB page size definition */
103 #define PVRSRV_2M_PAGE_SIZE                                     2097152UL      /*!< Size of a 2M Page */
104 #define PVRSRV_2M_PAGE_SIZE_ALIGNSHIFT          21          /*!< Amount to shift an address by so that
105                                                           it is always page-aligned */
106
107
108 #define EVENTOBJNAME_MAXLENGTH (50) /*!< Max length of an event object name */
109
110
111 /*!
112         Flags for Services connection.
113         Allows to define per-client policy for Services
114 */
115 #define SRV_FLAGS_PERSIST               (1U << 0)  /*!< Persist client flag */
116 #define SRV_FLAGS_INIT_PROCESS  (1U << 1)  /*!< Allows connect to succeed if SrvInit
117                                             * has not yet run (used by SrvInit itself) */
118 #define SRV_FLAGS_PDUMPCTRL     (1U << 31) /*!< PDump Ctrl client flag */
119
120 /*
121         Pdump flags which are accessible to Services clients
122 */
123 /* 
124 */
125 #define PVRSRV_PDUMP_FLAGS_CONTINUOUS           0x40000000UL /*!< pdump continuous */
126
127 #define PVRSRV_UNDEFINED_HEAP_ID                        (~0LU)
128
129 /*!
130  ******************************************************************************
131  * User Module type
132  *****************************************************************************/
133 typedef enum
134 {
135         IMG_EGL                         = 0x00000001,       /*!< EGL Module */
136         IMG_OPENGLES1           = 0x00000002,       /*!< OGLES1 Module */
137         IMG_OPENGLES3           = 0x00000003,       /*!< OGLES3 Module */
138         IMG_D3DM                        = 0x00000004,       /*!< D3DM Module */
139         IMG_SRV_UM                      = 0x00000005,       /*!< Services User-Mode */
140         IMG_SRV_INIT            = 0x00000006,           /*!< Services initialisation */
141         IMG_SRVCLIENT           = 0x00000007,       /*!< Services Client */
142         IMG_WDDMKMD                     = 0x00000008,       /*!< WDDM KMD */
143         IMG_WDDM3DNODE          = 0x00000009,       /*!< WDDM 3D Node */
144         IMG_WDDMMVIDEONODE      = 0x0000000A,       /*!< WDDM MVideo Node */
145         IMG_WDDMVPBNODE         = 0x0000000B,       /*!< WDDM VPB Node */
146         IMG_OPENGL                      = 0x0000000C,       /*!< OpenGL */
147         IMG_D3D                         = 0x0000000D,       /*!< D3D */
148         IMG_OPENCL                      = 0x0000000E,       /*!< OpenCL */
149         IMG_ANDROID_HAL         = 0x0000000F,       /*!< Graphics HAL */
150         IMG_WEC_GPE                     = 0x00000010,           /*!< WinEC-specific GPE */
151         IMG_PVRGPE                      = 0x00000011,           /*!< WinEC/WinCE GPE */
152         IMG_RSCOMPUTE       = 0x00000012,       /*!< RenderScript Compute */
153         IMG_OPENRL          = 0x00000013,       /*!< OpenRL Module */
154         IMG_PDUMPCTRL           = 0x00000014,       /*!< PDump control client */
155
156 } IMG_MODULE_ID;
157
158 /*! Max length of an App-Hint string */
159 #define APPHINT_MAX_STRING_SIZE 256
160
161 /*!
162  ******************************************************************************
163  * IMG data types
164  *****************************************************************************/
165 typedef enum
166 {
167         IMG_STRING_TYPE         = 1,                    /*!< String type */
168         IMG_FLOAT_TYPE          ,                       /*!< Float type */
169         IMG_UINT_TYPE           ,                       /*!< Unsigned Int type */
170         IMG_INT_TYPE            ,                       /*!< (Signed) Int type */
171         IMG_FLAG_TYPE                               /*!< Flag Type */
172 }IMG_DATA_TYPE;
173
174
175 /******************************************************************************
176  * Structure definitions.
177  *****************************************************************************/
178
179 /*!
180  * Forward declaration
181  */
182 typedef struct _PVRSRV_DEV_DATA_ *PPVRSRV_DEV_DATA;
183 /*!
184  * Forward declaration (look on connection.h)
185  */
186 typedef struct _PVRSRV_CONNECTION_ PVRSRV_CONNECTION;
187
188
189 /*************************************************************************/ /*!
190  * Client dev info
191  */ /*************************************************************************/
192 typedef struct _PVRSRV_CLIENT_DEV_DATA_
193 {
194         IMG_UINT32              ui32NumDevices;                                                         /*!< Number of services-managed devices connected */
195         PVRSRV_DEVICE_IDENTIFIER asDevID[PVRSRV_MAX_DEVICES];                           /*!< Device identifiers */
196         PVRSRV_ERROR    (*apfnDevConnect[PVRSRV_MAX_DEVICES])(PPVRSRV_DEV_DATA);        /*!< device-specific connection callback */
197         PVRSRV_ERROR    (*apfnDumpTrace[PVRSRV_MAX_DEVICES])(PPVRSRV_DEV_DATA);         /*!< device-specific debug trace callback */
198
199 } PVRSRV_CLIENT_DEV_DATA;
200
201 /*!
202  ******************************************************************************
203  * This structure allows the user mode glue code to have an OS independent
204  * set of prototypes.
205  *****************************************************************************/
206 typedef struct _PVRSRV_DEV_DATA_
207 {
208         PVRSRV_CONNECTION        *psConnection; /*!< Services connection info */
209         IMG_HANDLE                      hDevCookie;                             /*!< Dev cookie */
210
211 } PVRSRV_DEV_DATA;
212
213 /*************************************************************************/ /*! 
214     PVR Client Event handling in Services
215 */ /**************************************************************************/
216 typedef enum _PVRSRV_CLIENT_EVENT_
217 {
218         PVRSRV_CLIENT_EVENT_HWTIMEOUT = 0,              /*!< hw timeout event */
219 } PVRSRV_CLIENT_EVENT;
220
221 /**************************************************************************/ /*!
222 @Function       PVRSRVClientEvent
223 @Description    Handles timeouts occurring in client drivers
224 @Input          eEvent          event type
225 @Input          psDevData       pointer to the PVRSRV_DEV_DATA context
226 @Input          pvData          client-specific data
227 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_ 
228                                 error code
229  */ /**************************************************************************/
230 IMG_IMPORT
231 PVRSRV_ERROR IMG_CALLCONV PVRSRVClientEvent(const PVRSRV_CLIENT_EVENT eEvent,
232                                                                                         PVRSRV_DEV_DATA *psDevData,
233                                                                                         IMG_PVOID pvData);
234
235 /******************************************************************************
236  * PVR Services API prototypes.
237  *****************************************************************************/
238
239 /**************************************************************************/ /*!
240 @Function       PVRSRVConnect
241 @Description    Creates a connection from an application to the services 
242                 module and initialises device-specific call-back functions.
243 @Output         ppsConnection   on Success, *ppsConnection is set to the new 
244                                 PVRSRV_CONNECTION instance.
245 @Input          ui32SrvFlags    a bit-wise OR of the following:
246                                 SRV_FLAGS_PERSIST
247 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_ 
248                                 error code
249  */ /**************************************************************************/
250 IMG_IMPORT
251 PVRSRV_ERROR IMG_CALLCONV PVRSRVConnect(PVRSRV_CONNECTION **ppsConnection, IMG_UINT32 ui32SrvFlags);
252
253 /**************************************************************************/ /*!
254 @Function       PVRSRVDisconnect 
255 @Description    Disconnects from the services module
256 @Input          psConnection    the connection to be disconnected
257 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_
258                                 error code
259  */ /**************************************************************************/
260 IMG_IMPORT
261 PVRSRV_ERROR IMG_CALLCONV PVRSRVDisconnect(PVRSRV_CONNECTION *psConnection);
262
263 /**************************************************************************/ /*!
264 @Function       PVRSRVEnumerateDevices
265 @Description    Enumerate all services managed devices in the 
266                 system.
267
268                 The function returns a list of the device IDs stored either
269                 in the services (or constructed in the user mode glue 
270                 component in certain environments). The number of devices 
271                 in the list is also returned.
272
273                 The user is required to provide a buffer large enough to 
274                 receive an array of MAX_NUM_DEVICE_IDS *
275                 PVRSRV_DEVICE_IDENTIFIER structures.
276
277                 In a binary layered component which does not support dynamic
278                 runtime selection, the glue code should compile to return 
279                 the supported devices statically, e.g. multiple instances of
280                 the same device if multiple devices are supported
281
282                 In the case of an environment (for instance) where one 
283                 services managed device may connect to two display devices
284                 this code would enumerate all three devices and even
285                 non-dynamic device selection code should retain the facility
286                 to parse the list to find the index of a given device.}
287
288 @Input          psConnection    Services connection
289 @Output         puiNumDevices   Number of devices present in the system
290 @Output         puiDevIDs       Pointer to called supplied array of
291                                 PVRSRV_DEVICE_IDENTIFIER structures. The
292                                 array is assumed to be at least
293                                 PVRSRV_MAX_DEVICES long.
294 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_
295                                 error code
296  */ /**************************************************************************/
297 IMG_IMPORT
298 PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumerateDevices(const PVRSRV_CONNECTION        *psConnection,
299                                                                                                         IMG_UINT32                                      *puiNumDevices,
300                                                                                                         PVRSRV_DEVICE_IDENTIFIER        *puiDevIDs);
301
302 /**************************************************************************/ /*!
303 @Function       PVRSRVAcquireDeviceData
304 @Description    Returns device info structure pointer for the requested device.
305                 This populates a PVRSRV_DEV_DATA structure with appropriate 
306                 pointers to the DevInfo structure for the device requested.
307
308                 In a non-plug-and-play the first call to GetDeviceInfo for a
309                 device causes device initialisation
310
311                 Calls to GetDeviceInfo are reference counted
312 @Input          psConnection    Services connection
313 @Input          uiDevIndex      Index to the required device obtained from the 
314                                 PVRSRVEnumerateDevice function 
315 @Output         psDevData       The returned Device Data
316 @Input          eDeviceType     Required device type. If type is unknown use 
317                                 uiDevIndex to locate device data
318 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_
319                                 error code
320  */ /**************************************************************************/
321 IMG_IMPORT
322 PVRSRV_ERROR IMG_CALLCONV PVRSRVAcquireDeviceData(PVRSRV_CONNECTION     *psConnection,
323                                                                                                         IMG_UINT32                      uiDevIndex,
324                                                                                                         PVRSRV_DEV_DATA         *psDevData,
325                                                                                                         PVRSRV_DEVICE_TYPE      eDeviceType);
326
327 /**************************************************************************/ /*!
328 @Function       PVRSRVPollForValue
329 @Description    Polls for a value to match a masked read of System Memory.
330                 The function returns when either (1) the value read back
331                 matches ui32Value, or (2) the maximum number of tries has
332                 been reached.
333 @Input          psConnection        Services connection
334 @Input          hOSEvent            Handle to OS event object to wait for
335 @Input          pui32LinMemAddr     the address of the memory to poll
336 @Input          ui32Value           the required value
337 @Input          ui32Mask            the mask to use
338 @Input          ui32Waitus          interval between tries (us)
339 @Input          ui32Tries           number of tries to make before giving up
340 @Return                             PVRSRV_OK on success. Otherwise, a 
341                                     PVRSRV_ error code
342  */ /**************************************************************************/
343 IMG_IMPORT
344 PVRSRV_ERROR PVRSRVPollForValue(const PVRSRV_CONNECTION *psConnection,
345                                                                 IMG_HANDLE                              hOSEvent,
346                                                                 volatile IMG_UINT32             *pui32LinMemAddr,
347                                                                 IMG_UINT32                              ui32Value,
348                                                                 IMG_UINT32                              ui32Mask,
349                                                                 IMG_UINT32                              ui32Waitus,
350                                                                 IMG_UINT32                              ui32Tries);
351
352 /* this function is almost the same as PVRSRVPollForValue. The only difference
353  * is that it now handles the interval between tries itself. Therefore it can
354  * correctly handles the differences between the different platforms.
355  */
356 IMG_IMPORT
357 PVRSRV_ERROR PVRSRVWaitForValue(const PVRSRV_CONNECTION *psConnection,
358                                 IMG_HANDLE                              hOSEvent,
359                                 volatile IMG_UINT32             *pui32LinMemAddr,
360                                 IMG_UINT32                              ui32Value,
361                                 IMG_UINT32                              ui32Mask);
362
363
364 /**************************************************************************/ /*!
365  @Function      PVRSRVConditionCheckCallback
366  @Description   Function prototype for use with the PVRSRVWaitForCondition()
367                 API. Clients implement this callback to test if the condition
368                 waited for has been met and become true.
369
370  @Input         pvUserData      Pointer to client user data needed for
371                                  the check
372  @Output        pbCondMet       Updated on exit with condition state
373
374  @Return        PVRSRV_OK  when condition tested without error
375                 PVRSRV_*   other system error that will lead to the
376                            abnormal termination of the wait API.
377  */
378 /******************************************************************************/
379 typedef
380 PVRSRV_ERROR (*PVRSRVConditionCheckCallback)(
381         IMG_PVOID  pvUserData,
382         IMG_BOOL*  pbCondMet);
383
384
385 /**************************************************************************/ /*!
386 @Function       PVRSRVWaitForCondition
387 @Description    Wait using PVRSRVEventObjectWait() for a
388                 condition (pfnCallback) to become true. It periodically
389                 checks the condition state by employing a loop and
390                 waiting on either the event supplied or sleeping for a brief
391                 time (if hEvent is null) each time the condition is
392                 checked and found not to be met. When the condition is true
393                 the function returns. It will also return when the time
394                 period has been exceeded or an error has occurred.
395
396 @Input          psConnection    Services connection
397 @Input          hEvent          Event to wait on or NULL not to use event
398                                  objects but OS wait for a short time.
399 @Input          pfnCallback     Client condition check callback
400 @Input          pvUserData      Client user data supplied to callback
401
402 @Return         PVRSRV_OK                 When condition met
403                 PVRSRV_ERROR_TIMEOUT  When condition not met and time is up
404                 PVRSRV_*              Otherwise, some other error code
405  */ /**************************************************************************/
406 IMG_IMPORT
407 PVRSRV_ERROR IMG_CALLCONV PVRSRVWaitForCondition(
408         const PVRSRV_CONNECTION*     psConnection,
409         IMG_HANDLE                   hEvent,
410         PVRSRVConditionCheckCallback pfnCallback,
411         IMG_PVOID                    pvUserData);
412
413
414 /**************************************************************************/ /*!
415 @Function       PVRSRVWaitUntilSyncPrimOpReady
416 @Description    Wait using PVRSRVWaitForCondition for a sync operation to
417                 become ready.
418
419 @Input          psConnection    Services connection
420 @Input          hEvent          Event to wait on or NULL not to use event
421                                  objects but OS wait for a short time.
422 @Input          psOpCookie      Sync operation cookie to test
423
424 @Return         PVRSRV_OK                 When condition met
425                 PVRSRV_ERROR_TIMEOUT  When condition not met and time is up
426                 PVRSRV_*              Otherwise, some other error code
427  */ /**************************************************************************/
428 IMG_IMPORT
429 PVRSRV_ERROR IMG_CALLCONV PVRSRVWaitUntilSyncPrimOpReady(
430         const PVRSRV_CONNECTION* psConnection,
431         IMG_HANDLE               hEvent,
432         PSYNC_OP_COOKIE          psOpCookie);
433
434
435 /******************************************************************************
436  * PDUMP Function prototypes...
437  *****************************************************************************/
438 #if defined(PDUMP)
439 /**************************************************************************/ /*!
440 @Function       PVRSRVPDumpInit
441 @Description    Pdump initialisation
442 @Input          psConnection    Services connection
443 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_
444                                 error code
445  */ /**************************************************************************/
446 IMG_IMPORT
447 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpInit(const PVRSRV_CONNECTION *psConnection);
448
449 /**************************************************************************/ /*!
450 @Function       PVRSRVPDumpStartInitPhase
451 @Description    Resume the pdump init phase state   
452 @Input          psConnection    Services connection
453 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_
454                                 error code
455  */ /**************************************************************************/
456 IMG_IMPORT
457 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpStartInitPhase(const PVRSRV_CONNECTION *psConnection);
458
459 /**************************************************************************/ /*!
460 @Function       PVRSRVPDumpStopInitPhase
461 @Description    Stop the pdump init phase state
462 @Input          psConnection    Services connection
463 @Input          eModuleID       Which module is requesting to stop the init phase
464 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_
465                                 error code
466  */ /**************************************************************************/
467 IMG_IMPORT
468 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpStopInitPhase(const PVRSRV_CONNECTION *psConnection,
469                                                                                                 IMG_MODULE_ID eModuleID);
470
471 /**************************************************************************/ /*!
472 @Function       PVRSRVPDumpSetFrame
473 @Description    Sets the pdump frame
474 @Input          psConnection    Services connection
475 @Input          ui32Frame       frame id
476 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_
477                                 error code
478 */ /**************************************************************************/
479 IMG_IMPORT
480 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpSetFrame(const PVRSRV_CONNECTION *psConnection,
481                                                                                           IMG_UINT32 ui32Frame);
482
483 /**************************************************************************/ /*!
484 @Function       PVRSRVPDumpGetFrame
485 @Description    Gets the current pdump frame
486 @Input          psConnection    Services connection
487 @Output         pui32Frame       frame id
488 @Return         PVRSRV_OK on success. Otherwise, a PVRSRV_error code
489 */ /**************************************************************************/
490 IMG_IMPORT
491 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpGetFrame(const PVRSRV_CONNECTION *psConnection,
492                                                                                           IMG_UINT32 *pui32Frame);
493
494 /**************************************************************************/ /*!
495 @Function       PVRSRVPDumpIsLastCaptureFrame
496 @Description    Returns whether this is the last frame of the capture range
497 @Input          psConnection    Services connection
498 @Return                         IMG_TRUE if last frame,
499                                 IMG_FALSE otherwise
500 */ /**************************************************************************/
501 IMG_IMPORT
502 IMG_BOOL IMG_CALLCONV PVRSRVPDumpIsLastCaptureFrame(const PVRSRV_CONNECTION *psConnection);
503
504 /**************************************************************************/ /*!
505 @Function       PVRSRVPDumpAfterRender
506 @Description    Executes TraceBuffer and SignatureBuffer commands
507 @Input          psDevData       Device data
508 */ /**************************************************************************/
509 IMG_IMPORT
510 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpAfterRender(PVRSRV_DEV_DATA *psDevData);
511
512 /**************************************************************************/ /*!
513 @Function       PVRSRVPDumpComment
514 @Description    PDumps a comment
515 @Input          psConnection        Services connection
516 @Input          pszComment          Comment to be inserted
517 @Input          bContinuous         pdump contiunous boolean
518 @Return                             PVRSRV_OK on success. Otherwise, a PVRSRV_
519                                     error code
520  */ /**************************************************************************/
521 IMG_IMPORT
522 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpComment(const PVRSRV_CONNECTION *psConnection,
523                                                                                          const IMG_CHAR *pszComment,
524                                                                                          IMG_BOOL bContinuous);
525
526 /**************************************************************************/ /*!
527 @Function       PVRSRVPDumpCommentf
528 @Description    PDumps a formatted comment
529 @Input          psConnection        Services connection
530 @Input          bContinuous         pdump continuous boolean
531 @Input          pszFormat           Format string
532 @Input          ...                 vararg list
533 @Return                             PVRSRV_OK on success. Otherwise, a PVRSRV_
534                                     error code
535  */ /**************************************************************************/
536 IMG_IMPORT
537 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpCommentf(const PVRSRV_CONNECTION *psConnection,
538                                                                                           IMG_BOOL bContinuous,
539                                                                                           const IMG_CHAR *pszFormat, ...)
540                                                                                           IMG_FORMAT_PRINTF(3, 4);
541
542 /**************************************************************************/ /*!
543 @Function       PVRSRVPDumpCommentWithFlagsf
544 @Description    PDumps a formatted comment, passing in flags
545 @Input          psConnection        Services connection
546 @Input          ui32Flags           Flags
547 @Input          pszFormat           Format string
548 @Input          ...                 vararg list
549 @Return                             PVRSRV_OK on success. Otherwise, a PVRSRV_
550                                     error code
551  */ /**************************************************************************/
552 IMG_IMPORT
553 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpCommentWithFlagsf(const PVRSRV_CONNECTION *psConnection,
554                                                                                                            IMG_UINT32 ui32Flags,
555                                                                                                            const IMG_CHAR *pszFormat, ...)
556                                                                                                            IMG_FORMAT_PRINTF(3, 4);
557
558
559 /**************************************************************************/ /*!
560 @Function       PVRSRVPDumpIsCapturing
561 @Description    Reports whether PDump is currently capturing or not
562 @Input          psConnection        Services connection
563 @Output         pbIsCapturing       Indicates whether PDump is currently
564                                     capturing
565 @Return                             PVRSRV_OK on success. Otherwise, a PVRSRV_
566                                     error code
567  */ /**************************************************************************/
568 IMG_IMPORT
569 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpIsCapturing(const PVRSRV_CONNECTION *psConnection,
570                                                                                                 IMG_BOOL *pbIsCapturing);
571
572
573 /**************************************************************************/ /*!
574 @Function       PVRSRVPDumpIsCapturingTest
575 @Description    checks whether pdump is currently in frame capture range
576 @Input          psConnection        Services connection
577 @Return         IMG_BOOL
578  */ /**************************************************************************/
579 IMG_IMPORT
580 IMG_BOOL IMG_CALLCONV PVRSRVPDumpIsCapturingTest(const PVRSRV_CONNECTION *psConnection);
581
582 IMG_IMPORT
583 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpSetDefaultCaptureParams(const PVRSRV_CONNECTION *psConnection,
584                                                              IMG_UINT32 ui32Mode,
585                                                              IMG_UINT32 ui32Start,
586                                                              IMG_UINT32 ui32End,
587                                                              IMG_UINT32 ui32Interval,
588                                                              IMG_UINT32 ui32MaxParamFileSize);
589
590 #else   /* PDUMP */
591
592 #ifdef INLINE_IS_PRAGMA
593 #pragma inline(PVRSRVPDumpInit)
594 #endif
595 static INLINE PVRSRV_ERROR 
596 PVRSRVPDumpInit(const PVRSRV_CONNECTION *psConnection)
597 {
598         PVR_UNREFERENCED_PARAMETER(psConnection);
599         return PVRSRV_OK;
600 }
601
602 #ifdef INLINE_IS_PRAGMA
603 #pragma inline(PVRSRVPDumpStartInitPhase)
604 #endif
605 static INLINE PVRSRV_ERROR 
606 PVRSRVPDumpStartInitPhase(const PVRSRV_CONNECTION *psConnection)
607 {
608         PVR_UNREFERENCED_PARAMETER(psConnection);
609         return PVRSRV_OK;
610 }
611
612 #ifdef INLINE_IS_PRAGMA
613 #pragma inline(PVRSRVPDumpStopInitPhase)
614 #endif
615 static INLINE PVRSRV_ERROR
616 PVRSRVPDumpStopInitPhase(const PVRSRV_CONNECTION *psConnection)
617 {
618         PVR_UNREFERENCED_PARAMETER(psConnection);
619         return PVRSRV_OK;
620 }
621
622 #ifdef INLINE_IS_PRAGMA
623 #pragma inline(PVRSRVPDumpSetFrame)
624 #endif
625 static INLINE PVRSRV_ERROR
626 PVRSRVPDumpSetFrame(const PVRSRV_CONNECTION *psConnection,
627                                         IMG_UINT32 ui32Frame)
628 {
629         PVR_UNREFERENCED_PARAMETER(psConnection);
630         PVR_UNREFERENCED_PARAMETER(ui32Frame);
631         return PVRSRV_OK;
632 }
633
634 #ifdef INLINE_IS_PRAGMA
635 #pragma inline(PVRSRVPDumpGetFrame)
636 #endif
637 static INLINE PVRSRV_ERROR
638 PVRSRVPDumpGetFrame(const PVRSRV_CONNECTION *psConnection,
639                                         IMG_UINT32 *pui32Frame)
640 {
641         PVR_UNREFERENCED_PARAMETER(psConnection);
642         PVR_UNREFERENCED_PARAMETER(pui32Frame);
643         return PVRSRV_OK;
644 }
645
646
647 #ifdef INLINE_IS_PRAGMA
648 #pragma inline(PVRSRVPDumpIsLastCaptureFrame)
649 #endif
650 static INLINE IMG_BOOL
651 PVRSRVPDumpIsLastCaptureFrame(const PVRSRV_CONNECTION *psConnection)
652 {
653         PVR_UNREFERENCED_PARAMETER(psConnection);
654         return IMG_FALSE;
655 }
656
657 #ifdef INLINE_IS_PRAGMA
658 #pragma inline(PVRSRVPDumpAfterRender)
659 #endif
660 static INLINE PVRSRV_ERROR
661 PVRSRVPDumpAfterRender(PVRSRV_DEV_DATA *psDevData)
662 {
663         PVR_UNREFERENCED_PARAMETER(psDevData);
664         return PVRSRV_OK;
665 }
666
667 #ifdef INLINE_IS_PRAGMA
668 #pragma inline(PVRSRVPDumpComment)
669 #endif
670 static INLINE PVRSRV_ERROR
671 PVRSRVPDumpComment(const PVRSRV_CONNECTION *psConnection,
672                                    const IMG_CHAR *pszComment,
673                                    IMG_BOOL bContinuous)
674 {
675         PVR_UNREFERENCED_PARAMETER(psConnection);
676         PVR_UNREFERENCED_PARAMETER(pszComment);
677         PVR_UNREFERENCED_PARAMETER(bContinuous);
678         return PVRSRV_OK;
679 }
680
681 #ifdef INLINE_IS_PRAGMA
682 #pragma inline(PVRSRVPDumpCommentf)
683 #endif
684 static INLINE PVRSRV_ERROR
685 PVRSRVPDumpCommentf(const PVRSRV_CONNECTION *psConnection,
686                                         IMG_BOOL bContinuous,
687                                         const IMG_CHAR *pszFormat, ...)
688 {
689         PVR_UNREFERENCED_PARAMETER(psConnection);
690         PVR_UNREFERENCED_PARAMETER(bContinuous);
691         PVR_UNREFERENCED_PARAMETER(pszFormat);
692         return PVRSRV_OK;
693 }
694
695 #ifdef INLINE_IS_PRAGMA
696 #pragma inline(PVRSRVPDumpCommentWithFlagsf)
697 #endif
698 static INLINE PVRSRV_ERROR
699 PVRSRVPDumpCommentWithFlagsf(const PVRSRV_CONNECTION *psConnection,
700                                                          IMG_UINT32 ui32Flags,
701                                                          const IMG_CHAR *pszFormat, ...)
702 {
703         PVR_UNREFERENCED_PARAMETER(psConnection);
704         PVR_UNREFERENCED_PARAMETER(ui32Flags);
705         PVR_UNREFERENCED_PARAMETER(pszFormat);
706         return PVRSRV_OK;
707 }
708
709
710 #ifdef INLINE_IS_PRAGMA
711 #pragma inline(PVRSRVPDumpIsCapturing)
712 #endif
713 static INLINE PVRSRV_ERROR
714 PVRSRVPDumpIsCapturing(const PVRSRV_CONNECTION *psConnection,
715                                            IMG_BOOL *pbIsCapturing)
716 {
717         PVR_UNREFERENCED_PARAMETER(psConnection);
718         *pbIsCapturing = IMG_FALSE;
719         return PVRSRV_OK;
720 }                                                                                               
721
722 #ifdef INLINE_IS_PRAGMA
723 #pragma inline(PVRSRVPDumpIsCapturingTest)
724 #endif
725 static INLINE IMG_BOOL
726 PVRSRVPDumpIsCapturingTest(const PVRSRV_CONNECTION *psConnection)
727 {
728         PVR_UNREFERENCED_PARAMETER(psConnection);
729         return IMG_FALSE;
730 }
731
732 #ifdef INLINE_IS_PRAGMA
733 #pragma inline(PDumpSetPidCapRange)
734 #endif
735 static INLINE PVRSRV_ERROR
736 PVRSRVPDumpSetDefaultCaptureParams(const PVRSRV_CONNECTION *psConnection,
737                                    IMG_UINT32 ui32Mode,
738                                    IMG_UINT32 ui32Start,
739                                    IMG_UINT32 ui32End,
740                                    IMG_UINT32 ui32Interval,
741                                    IMG_UINT32 ui32MaxParamFileSize)
742 {
743         PVR_UNREFERENCED_PARAMETER(psConnection);
744         PVR_UNREFERENCED_PARAMETER(ui32Mode);
745         PVR_UNREFERENCED_PARAMETER(ui32Start);
746         PVR_UNREFERENCED_PARAMETER(ui32End);
747         PVR_UNREFERENCED_PARAMETER(ui32Interval);
748         PVR_UNREFERENCED_PARAMETER(ui32MaxParamFileSize);
749
750         return PVRSRV_OK;
751 }
752
753
754 #endif  /* PDUMP */
755
756 /**************************************************************************/ /*!
757 @Function       PVRSRVLoadLibrary
758 @Description    Load the named Dynamic-Link (Shared) Library. This will perform
759                                 reference counting in association with PVRSRVUnloadLibrary,
760                                 so for example if the same library is loaded twice and unloaded once,
761                                 a reference to the library will remain.
762 @Input          pszLibraryName      the name of the library to load
763 @Return                             On success, the handle of the newly-loaded
764                                     library. Otherwise, zero.
765  */ /**************************************************************************/
766 IMG_IMPORT IMG_HANDLE   PVRSRVLoadLibrary(const IMG_CHAR *pszLibraryName);
767
768 /**************************************************************************/ /*!
769 @Function       PVRSRVUnloadLibrary
770 @Description    Unload the Dynamic-Link (Shared) Library which had previously been
771                                 loaded using PVRSRVLoadLibrary(). See PVRSRVLoadLibrary() for
772                                 information regarding reference counting.
773 @Input          hExtDrv             handle of the Dynamic-Link / Shared library
774                                     to unload, as returned by PVRSRVLoadLibrary().
775 @Return                             PVRSRV_OK if successful. Otherwise,
776                                     PVRSRV_ERROR_UNLOAD_LIBRARY_FAILED.
777  */ /**************************************************************************/
778 IMG_IMPORT PVRSRV_ERROR PVRSRVUnloadLibrary(IMG_HANDLE hExtDrv);
779
780 /**************************************************************************/ /*!
781 @Function       PVRSRVGetLibFuncAddr
782 @Description    Returns the address of a function in a Dynamic-Link / Shared
783                 Library.
784 @Input          hExtDrv             handle of the Dynamic-Link / Shared Library
785                                     in which the function resides
786 @Input          pszFunctionName     the name of the function
787 @Output         ppvFuncAddr         on success, the address of the function
788                                     requested. Otherwise, NULL.
789 @Return                             PVRSRV_OK if successful. Otherwise,
790                                     PVRSRV_ERROR_UNABLE_TO_GET_FUNC_ADDR.
791  */ /**************************************************************************/
792 IMG_IMPORT PVRSRV_ERROR PVRSRVGetLibFuncAddr(IMG_HANDLE hExtDrv, 
793                                             const IMG_CHAR *pszFunctionName, 
794                                             IMG_VOID **ppvFuncAddr);
795
796 /**************************************************************************/ /*!
797 @Function       PVRSRVClockus
798 @Description    Returns the current system clock time, in microseconds.  Note 
799                 that this does not necessarily guarantee microsecond accuracy.
800 @Return                             the curent system clock time, in 
801                                     microseconds
802  */ /**************************************************************************/
803 IMG_IMPORT IMG_UINT32 PVRSRVClockus (void);
804
805 /**************************************************************************/ /*!
806 @Function       PVRSRVWaitus
807 @Description    Waits for the specified number of microseconds
808 @Input          ui32Timeus          the time to wait for, in microseconds 
809 @Return         None
810  */ /**************************************************************************/
811 IMG_IMPORT IMG_VOID PVRSRVWaitus (IMG_UINT32 ui32Timeus);
812
813 /**************************************************************************/ /*!
814 @Function       PVRSRVReleaseThreadQuanta
815 @Description    Releases thread quanta
816 @Return         None
817  */ /**************************************************************************/
818 IMG_IMPORT IMG_VOID PVRSRVReleaseThreadQuanta (void);
819
820 /**************************************************************************/ /*!
821 @Function       PVRSRVGetCurrentProcessID
822 @Description    Returns handle for current process
823 @Return         ID of current process
824  */ /**************************************************************************/
825 IMG_IMPORT IMG_PID  IMG_CALLCONV PVRSRVGetCurrentProcessID(void);
826
827 /**************************************************************************/ /*!
828 @Function       PVRSRVSetLocale
829 @Description    Thin wrapper on posix setlocale
830 @Input          pszLocale
831 @Return         IMG_NULL (currently)
832  */ /**************************************************************************/
833 IMG_IMPORT IMG_CHAR * IMG_CALLCONV PVRSRVSetLocale(const IMG_CHAR *pszLocale);
834
835
836 /**************************************************************************/ /*!
837 @Function       PVRSRVCreateAppHintState
838 @Description    Create app hint state
839 @Input          eModuleID       module id
840 @Input          pszAppName      app name
841 @Output         ppvState        state
842 @Return         None
843  */ /**************************************************************************/
844 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVCreateAppHintState(IMG_MODULE_ID eModuleID,
845                                                                                                                 const IMG_CHAR *pszAppName,
846                                                                                                                 IMG_VOID **ppvState);
847 /**************************************************************************/ /*!
848 @Function       PVRSRVFreeAppHintState
849 @Description    Free the app hint state, if it was created
850 @Input          eModuleID       module id
851 @Input          pvHintState     app hint state
852 @Return         None
853  */ /**************************************************************************/
854 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVFreeAppHintState(IMG_MODULE_ID eModuleID,
855                                                                                  IMG_VOID *pvHintState);
856
857 /**************************************************************************/ /*!
858 @Function       PVRSRVGetAppHint
859 @Description    Return the value of this hint from state or use default
860 @Input          pvHintState     hint state
861 @Input          pszHintName     hint name
862 @Input          eDataType       data type
863 @Input          pvDefault       default value
864 @Output         pvReturn        hint value
865 @Return                         True if hint read, False if used default
866  */ /**************************************************************************/
867 IMG_IMPORT IMG_BOOL IMG_CALLCONV PVRSRVGetAppHint(IMG_VOID                      *pvHintState,
868                                                                                                   const IMG_CHAR        *pszHintName,
869                                                                                                   IMG_DATA_TYPE         eDataType,
870                                                                                                   const IMG_VOID        *pvDefault,
871                                                                                                   IMG_VOID                      *pvReturn);
872
873 /******************************************************************************
874  * Memory API(s)
875  *****************************************************************************/
876
877 /* Exported APIs */
878 /**************************************************************************/ /*!
879 @Function       PVRSRVAllocUserModeMem
880 @Description    Allocate a block of user-mode memory
881 @Input          ui32Size    the amount of memory to allocate
882 @Return                     On success, a pointer to the memory allocated.
883                             Otherwise, NULL.
884  */ /**************************************************************************/
885 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVAllocUserModeMem (IMG_SIZE_T ui32Size);
886
887 /**************************************************************************/ /*!
888 @Function       PVRSRVCallocUserModeMem
889 @Description    Allocate a block of user-mode memory
890 @Input          ui32Size    the amount of memory to allocate
891 @Return                     On success, a pointer to the memory allocated.
892                             Otherwise, NULL.
893  */ /**************************************************************************/
894 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVCallocUserModeMem (IMG_SIZE_T ui32Size);
895
896 /**************************************************************************/ /*!
897 @Function       PVRSRVReallocUserModeMem
898 @Description    Re-allocate a block of memory
899 @Input          pvBase      the address of the existing memory, previously
900                             allocated with PVRSRVAllocUserModeMem
901 @Input          uNewSize    the newly-desired size of the memory chunk
902 @Return                     On success, a pointer to the memory block. If the
903                             size of the block could not be changed, the
904                             return value is NULL.
905  */ /**************************************************************************/
906 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVReallocUserModeMem (IMG_PVOID pvBase, IMG_SIZE_T uNewSize);
907 /**************************************************************************/ /*!
908 @Function       PVRSRVFreeUserModeMem
909 @Description    Free a block of memory previously allocated with
910                 PVRSRVAllocUserModeMem
911 @Input          pvMem       pointer to the block of memory to be freed
912 @Return         None
913  */ /**************************************************************************/
914 IMG_IMPORT IMG_VOID  IMG_CALLCONV PVRSRVFreeUserModeMem (IMG_PVOID pvMem);
915
916 /**************************************************************************/ /*!
917 @Function       PVRSRVMemCopy
918 @Description    Copy a block of memory
919                 Safe implementation of memset for use with device memory.
920 @Input          pvDst       Pointer to the destination
921 @Input          pvSrc       Pointer to the source location
922 @Input          uiSize      The amount of memory to copy in bytes
923 @Return         None
924  */ /**************************************************************************/
925 IMG_IMPORT IMG_VOID PVRSRVMemCopy(IMG_VOID *pvDst, const IMG_VOID *pvSrc, IMG_SIZE_T uiSize);
926
927 /**************************************************************************/ /*!
928 @Function       PVRSRVMemSet
929 @Description    Set all bytes in a region of memory to the specified value.
930                 Safe implementation of memset for use with device memory.
931 @Input          pvDest      Pointer to the start of the memory region
932 @Input          ui8Value    The value to be written
933 @Input          uiSize      The number of bytes to be set to ui8Value
934 @Return         None
935  */ /**************************************************************************/
936 IMG_IMPORT IMG_VOID PVRSRVMemSet(IMG_VOID *pvDest, IMG_UINT8 ui8Value, IMG_SIZE_T uiSize);
937
938 /**************************************************************************/ /*!
939 @Function       PVRSRVLockProcessGlobalMutex
940 @Description    Locking function for non-recursive coarse-grained mutex shared
941                 between all threads in a proccess.
942 @Return         None
943  */ /**************************************************************************/
944 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVLockProcessGlobalMutex(void);
945
946 /**************************************************************************/ /*!
947 @Function       PVRSRVUnlockProcessGlobalMutex
948 @Description    Unlocking function for non-recursive coarse-grained mutex shared
949                 between all threads in a proccess.
950 @Return         None
951  */ /**************************************************************************/
952 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVUnlockProcessGlobalMutex(void);
953
954
955 typedef struct _OS_MUTEX_ *PVRSRV_MUTEX_HANDLE;
956
957 /**************************************************************************/ /*!
958 @Function       PVRSRVCreateMutex
959 @Description    creates a mutex
960 @Output         phMutex             ptr to mutex handle
961 @Return                             PVRSRV_OK on success. Otherwise, a PVRSRV_
962                                     error code
963  */ /**************************************************************************/
964 #if !defined(PVR_DEBUG_MUTEXES)
965 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateMutex(PVRSRV_MUTEX_HANDLE *phMutex);
966 #else
967 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateMutex(PVRSRV_MUTEX_HANDLE *phMutex,
968                                                                                                            IMG_CHAR pszMutexName[],
969                                                                                                            IMG_CHAR pszFilename[],
970                                                                                                            IMG_INT iLine);
971 #define PVRSRVCreateMutex(phMutex) \
972         PVRSRVCreateMutex(phMutex, #phMutex, __FILE__, __LINE__)
973 #endif
974
975 /**************************************************************************/ /*!
976 @Function       PVRSRVDestroyMutex
977 @Description    Create a mutex.
978 @Input          hMutex              On success, filled with the new Mutex
979 @Return                             PVRSRV_OK on success. Otherwise, a PVRSRV_
980                                     error code
981  */ /**********************************************************************/
982 #if !defined(PVR_DEBUG_MUTEXES)
983 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyMutex(PVRSRV_MUTEX_HANDLE hMutex);
984 #else
985 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyMutex(PVRSRV_MUTEX_HANDLE hMutex,
986                                                                                                                 IMG_CHAR pszMutexName[],
987                                                                                                                 IMG_CHAR pszFilename[],
988                                                                                                                 IMG_INT iLine);
989 #define PVRSRVDestroyMutex(hMutex) \
990         PVRSRVDestroyMutex(hMutex, #hMutex, __FILE__, __LINE__)
991 #endif
992
993 /**************************************************************************/ /*!
994 @Function       PVRSRVLockMutex
995 @Description    Lock the mutex passed
996 @Input          hMutex              handle of the mutex to be locked
997 @Return         None
998  */ /**********************************************************************/
999 #if !defined(PVR_DEBUG_MUTEXES)
1000 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVLockMutex(PVRSRV_MUTEX_HANDLE hMutex);
1001 #else
1002 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVLockMutex(PVRSRV_MUTEX_HANDLE hMutex,
1003                                                                                                  IMG_CHAR pszMutexName[],
1004                                                                                                  IMG_CHAR pszFilename[],
1005                                                                                                  IMG_INT iLine);
1006 #define PVRSRVLockMutex(hMutex) \
1007         PVRSRVLockMutex(hMutex, #hMutex, __FILE__, __LINE__)
1008 #endif
1009
1010 /**************************************************************************/ /*!
1011 @Function       PVRSRVUnlockMutex
1012 @Description    Unlock the mutex passed
1013 @Input          hMutex              handle of the mutex to be unlocked
1014 @Return         None
1015  */ /**********************************************************************/
1016 #if !defined(PVR_DEBUG_MUTEXES)
1017 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVUnlockMutex(PVRSRV_MUTEX_HANDLE hMutex);
1018 #else
1019 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVUnlockMutex(PVRSRV_MUTEX_HANDLE hMutex,
1020                                                                                                    IMG_CHAR pszMutexName[],
1021                                                                                                    IMG_CHAR pszFilename[],
1022                                                                                                    IMG_INT iLine);
1023 #define PVRSRVUnlockMutex(hMutex) \
1024         PVRSRVUnlockMutex(hMutex, #hMutex, __FILE__, __LINE__)
1025 #endif
1026
1027 struct _PVRSRV_SEMAPHORE_OPAQUE_STRUCT_;
1028 typedef struct  _PVRSRV_SEMAPHORE_OPAQUE_STRUCT_ *PVRSRV_SEMAPHORE_HANDLE; /*!< Convenience typedef */
1029
1030
1031 #if defined(_MSC_VER)
1032     /*! 
1033       Used when waiting for a semaphore to become unlocked. Indicates that 
1034       the caller is willing to wait forever.
1035      */
1036     #define IMG_SEMAPHORE_WAIT_INFINITE       ((IMG_UINT64)0xFFFFFFFFFFFFFFFF)
1037 #else
1038     /*! 
1039       Used when waiting for a semaphore to become unlocked. Indicates that 
1040       the caller is willing to wait forever.
1041      */
1042         #define IMG_SEMAPHORE_WAIT_INFINITE       ((IMG_UINT64)0xFFFFFFFFFFFFFFFFull)
1043 #endif
1044
1045 #ifdef INLINE_IS_PRAGMA
1046 #pragma inline(PVRSRVCreateSemaphore)
1047 #endif
1048 /**************************************************************************/ /*!
1049 @Function       PVRSRVCreateSemaphore
1050 @Description    Create a semaphore with an initial count
1051 @Output         phSemaphore         on success, ptr to the handle of the new 
1052                                     semaphore. Otherwise, zero.
1053 @Input          iInitialCount       initial count
1054 @Return                             PVRSRV_OK on success. Otherwise, a PVRSRV_
1055                                     error code
1056  */ /**************************************************************************/
1057 static INLINE PVRSRV_ERROR PVRSRVCreateSemaphore(PVRSRV_SEMAPHORE_HANDLE *phSemaphore, 
1058                                                 IMG_INT iInitialCount)
1059 {
1060         PVR_UNREFERENCED_PARAMETER(iInitialCount);
1061         *phSemaphore = 0;
1062         return PVRSRV_OK;
1063 }
1064
1065 #ifdef INLINE_IS_PRAGMA
1066 #pragma inline(PVRSRVDestroySemaphore)
1067 #endif
1068 /**************************************************************************/ /*!
1069 @Function       PVRSRVDestroySemaphore
1070 @Description    destroy the semaphore passed
1071 @Input          hSemaphore          the semaphore to be destroyed
1072 @Return                             PVRSRV_OK on success. Otherwise, a PVRSRV_
1073                                     error code
1074  */ /**************************************************************************/
1075 static INLINE PVRSRV_ERROR PVRSRVDestroySemaphore(PVRSRV_SEMAPHORE_HANDLE hSemaphore)
1076 {
1077         PVR_UNREFERENCED_PARAMETER(hSemaphore);
1078         return PVRSRV_OK;
1079 }
1080
1081 #ifdef INLINE_IS_PRAGMA
1082 #pragma inline(PVRSRVWaitSemaphore)
1083 #endif
1084 /**************************************************************************/ /*!
1085 @Function       PVRSRVWaitSemaphore
1086 @Description    wait on the specified semaphore
1087 @Input          hSemaphore          the semephore on which to wait
1088 @Input          ui64TimeoutMicroSeconds the time to wait for the semaphore to
1089                                     become unlocked, if locked when the function
1090                                     is called.
1091 @Return                             PVRSRV_OK on success. Otherwise, a PVRSRV_
1092                                     error code
1093  */ /**************************************************************************/
1094 static INLINE PVRSRV_ERROR PVRSRVWaitSemaphore(PVRSRV_SEMAPHORE_HANDLE hSemaphore, 
1095                                             IMG_UINT64 ui64TimeoutMicroSeconds)
1096 {
1097         PVR_UNREFERENCED_PARAMETER(hSemaphore);
1098         PVR_UNREFERENCED_PARAMETER(ui64TimeoutMicroSeconds);
1099         return PVRSRV_ERROR_INVALID_PARAMS;
1100 }
1101
1102 #ifdef INLINE_IS_PRAGMA
1103 #pragma inline(PVRSRVPostSemaphore)
1104 #endif
1105 /**************************************************************************/ /*!
1106 @Function       PVRSRVPostSemaphore
1107 @Description    post semphore
1108 @Input          hSemaphore      handle to semaphore
1109 @Input          iPostCount      post count
1110 @Return         None
1111  */ /**************************************************************************/
1112 static INLINE IMG_VOID PVRSRVPostSemaphore(PVRSRV_SEMAPHORE_HANDLE hSemaphore, IMG_INT iPostCount)
1113 {
1114         PVR_UNREFERENCED_PARAMETER(hSemaphore);
1115         PVR_UNREFERENCED_PARAMETER(iPostCount);
1116 }
1117
1118 /* Non-exported APIs */
1119 #if defined(DEBUG) && (defined(__linux__) || defined(_WIN32) || defined(__QNXNTO__))
1120 /**************************************************************************/ /*!
1121 @Function       PVRSRVAllocUserModeMemTracking
1122 @Description    Wrapper function for malloc, used for memory-leak detection
1123 @Input          ui32Size            number of bytes to be allocated
1124 @Input          pszFileName         filename of the calling code
1125 @Input          ui32LineNumber      line number of the calling code
1126 @Return                             On success, a ptr to the newly-allocated
1127                                     memory. Otherwise, NULL.
1128  */ /**************************************************************************/
1129 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVAllocUserModeMemTracking(IMG_SIZE_T ui32Size, 
1130                                                                  IMG_CHAR *pszFileName, 
1131                                                                  IMG_UINT32 ui32LineNumber);
1132
1133 /**************************************************************************/ /*!
1134 @Function       PVRSRVCallocUserModeMemTracking
1135 @Description    Wrapper function for calloc, used for memory-leak detection
1136 @Input          ui32Size            number of bytes to be allocated
1137 @Input          pszFileName         filename of the calling code
1138 @Input          ui32LineNumber      line number of the calling code
1139 @Return                             On success, a ptr to the newly-allocated
1140                                     memory. Otherwise, NULL.
1141  */ /**************************************************************************/
1142 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVCallocUserModeMemTracking(IMG_SIZE_T ui32Size, 
1143                                                                   IMG_CHAR *pszFileName, 
1144                                                                   IMG_UINT32 ui32LineNumber);
1145
1146 /**************************************************************************/ /*!
1147 @Function       PVRSRVFreeUserModeMemTracking
1148 @Description    Wrapper for free - see PVRSRVAllocUserModeMemTracking
1149 @Input          pvMem               pointer to the memory to be freed
1150 @Return         None
1151  */ /**************************************************************************/
1152 IMG_IMPORT IMG_VOID  IMG_CALLCONV PVRSRVFreeUserModeMemTracking(IMG_VOID *pvMem);
1153
1154 /**************************************************************************/ /*!
1155 @Function       PVRSRVReallocUserModeMemTracking
1156 @Description    Wrapper for realloc, used in memory-leak detection
1157 @Input          pvMem           pointer to the existing memory block
1158 @Input          ui32NewSize     the desired new size of the block
1159 @Input          pszFileName     the filename of the calling code
1160 @Input          ui32LineNumber  the line number of the calling code
1161 @Return                         on success, a pointer to the memory block.
1162                                 This may not necessarily be the same
1163                                 location as the block was at before the
1164                                 call. On failure, NULL is returned.
1165  */ /**************************************************************************/
1166 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVReallocUserModeMemTracking(IMG_VOID *pvMem, 
1167                                                                 IMG_SIZE_T ui32NewSize, 
1168                                                                                                                     IMG_CHAR *pszFileName, 
1169                                                                 IMG_UINT32 ui32LineNumber);
1170 #endif /* defined(DEBUG) && (defined(__linux__) || defined(_WIN32)) */
1171
1172 /**************************************************************************/ /*!
1173 @Function       PVRSRVDumpDebugInfo
1174 @Description    Dump debug information to kernel log
1175 @Input          psConnection    Services connection
1176 @Return         IMG_VOID
1177  */ /**************************************************************************/
1178 IMG_IMPORT IMG_VOID
1179 PVRSRVDumpDebugInfo(const PVRSRV_CONNECTION *psConnection, IMG_UINT32 ui32VerbLevel);
1180
1181 /**************************************************************************/ /*!
1182 @Function       PVRSRVGetDevClockSpeed
1183 @Description    Gets the RGX clock speed
1184 @Input          psConnection            Services connection
1185 @Input          psDevData                       Pointer to the PVRSRV_DEV_DATA context
1186 @Output         pui32RGXClockSpeed  Variable for storing clock speed
1187 @Return         IMG_BOOL                        True if the operation was successful
1188  */ /**************************************************************************/
1189 IMG_IMPORT IMG_BOOL IMG_CALLCONV PVRSRVGetDevClockSpeed(const PVRSRV_CONNECTION *psConnection,
1190                                                                                                                 PVRSRV_DEV_DATA  *psDevData,
1191                                                                                                                 IMG_PUINT32 pui32RGXClockSpeed);
1192
1193 /**************************************************************************/ /*!
1194 @Function       PVRSRVResetHWRLogs
1195 @Description    Resets the HWR Logs buffer (the hardware recovery count is not reset)
1196 @Input          psConnection            Services connection
1197 @Input          psDevData                       Pointer to the PVRSRV_DEV_DATA context
1198 @Return         PVRSRV_ERROR            PVRSRV_OK on success. Otherwise, a PVRSRV_
1199                                         error code
1200  */ /**************************************************************************/
1201 IMG_IMPORT PVRSRV_ERROR
1202 PVRSRVResetHWRLogs(const PVRSRV_CONNECTION *psConnection, PVRSRV_DEV_DATA  *psDevData);
1203
1204 /******************************************************************************
1205  * PVR Event Object API(s)
1206  *****************************************************************************/
1207
1208 /*****************************************************************************
1209 @Function       PVRSRVAcquireGlobalEventObject
1210 @Description    Gets a handle to an event
1211  Outputs            : phOSEvent    Global eventobject event
1212  Returns            : 
1213 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_
1214                                 error code
1215                       
1216 ******************************************************************************/
1217 IMG_IMPORT PVRSRV_ERROR
1218 PVRSRVAcquireGlobalEventObject(const PVRSRV_CONNECTION *psConnection,
1219                                                                                         IMG_HANDLE *phOSEvent);
1220
1221 /*****************************************************************************
1222  Function Name      : PVRSRVReleaseGlobalEventObject
1223  Inputs             : phOSEvent    Global eventobject event
1224  Outputs            : 
1225 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_
1226                                 error code
1227                       
1228 ******************************************************************************/
1229 IMG_IMPORT PVRSRV_ERROR
1230 PVRSRVReleaseGlobalEventObject(const PVRSRV_CONNECTION *psConnection,
1231                                                                                         IMG_HANDLE hOSEvent);
1232
1233 /**************************************************************************/ /*!
1234 @Function       PVRSRVEventObjectWait
1235 @Description    Wait (block) on the OS-specific event object passed
1236 @Input          psConnection    Services connection
1237 @Input          hOSEvent        the event object to wait on
1238 @Return                         PVRSRV_OK on success. Otherwise, a PVRSRV_
1239                                 error code
1240  */ /**************************************************************************/
1241 IMG_IMPORT PVRSRV_ERROR
1242 PVRSRVEventObjectWait(const PVRSRV_CONNECTION *psConnection,
1243                                                                         IMG_HANDLE hOSEvent);
1244
1245
1246 IMG_IMPORT PVRSRV_ERROR
1247 PVRSRVKickDevices(const PVRSRV_CONNECTION *psConnection);
1248
1249
1250 /**************************************************************************/ /*!
1251 @Function       RGXSoftReset
1252 @Description    Resets some modules of the RGX device
1253 @Input          psConnection    Services connection
1254 @Input          psDevData                       Pointer to the PVRSRV_DEV_DATA context
1255 @Output         ui64ResetValue  a mask for which each bit set correspond
1256                                 to a module to reset.
1257 @Return         PVRSRV_ERROR
1258 */ /***************************************************************************/
1259 IMG_IMPORT PVRSRV_ERROR
1260 PVRSRVSoftReset(const PVRSRV_CONNECTION *psConnection,
1261                                 PVRSRV_DEV_DATA  *psDevData,
1262                                 IMG_UINT64 ui64ResetValue);
1263
1264 /*!
1265  Time wrapping macro
1266 */
1267 #define TIME_NOT_PASSED_UINT32(a,b,c)           (((a) - (b)) < (c))
1268
1269
1270 #if defined (__cplusplus)
1271 }
1272 #endif
1273 #endif /* __SERVICES_H__ */
1274
1275 /******************************************************************************
1276  End of file (services.h)
1277 ******************************************************************************/
1278