packaging: update the changelog
[profile/ivi/intel-emgd-kmod.git] / drivers / pvr / services4 / srvkm / bridged / bridged_support.c
1 /**********************************************************************
2  Copyright (c) Imagination Technologies Ltd.
3
4  Permission is hereby granted, free of charge, to any person obtaining a copy
5  of this software and associated documentation files (the "Software"), to deal
6  in the Software without restriction, including without limitation the rights
7  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  copies of the Software, and to permit persons to whom the Software is
9  furnished to do so, subject to the following conditions:
10
11  The above copyright notice and this permission notice shall be included in
12  all copies or substantial portions of the Software.
13
14  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  THE SOFTWARE.
21  ******************************************************************************/
22
23 #include "img_defs.h"
24 #include "servicesint.h"
25 #include "bridged_support.h"
26
27
28 PVRSRV_ERROR
29 PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psHandleBase, IMG_HANDLE *phOSMemHandle, IMG_HANDLE hMHandle)
30 {
31         IMG_HANDLE hMHandleInt;
32         PVRSRV_HANDLE_TYPE eHandleType;
33         PVRSRV_ERROR eError;
34
35
36         eError = PVRSRVLookupHandleAnyType(psHandleBase, &hMHandleInt,
37                                                           &eHandleType,
38                                                           hMHandle);
39         if(eError != PVRSRV_OK)
40         {
41                 return eError;
42         }
43
44         switch(eHandleType)
45         {
46 #if defined(PVR_SECURE_HANDLES)
47                 case PVRSRV_HANDLE_TYPE_MEM_INFO:
48                 case PVRSRV_HANDLE_TYPE_MEM_INFO_REF:
49                 case PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO:
50                 {
51                         PVRSRV_KERNEL_MEM_INFO *psMemInfo = (PVRSRV_KERNEL_MEM_INFO *)hMHandleInt;
52
53                         *phOSMemHandle = psMemInfo->sMemBlk.hOSMemHandle;
54
55                         break;
56                 }
57                 case PVRSRV_HANDLE_TYPE_SYNC_INFO:
58                 {
59                         PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)hMHandleInt;
60                         PVRSRV_KERNEL_MEM_INFO *psMemInfo = psSyncInfo->psSyncDataMemInfoKM;
61
62                         *phOSMemHandle = psMemInfo->sMemBlk.hOSMemHandle;
63
64                         break;
65                 }
66                 case  PVRSRV_HANDLE_TYPE_SOC_TIMER:
67                 {
68                         *phOSMemHandle = (IMG_VOID *)hMHandleInt;
69                         break;
70                 }
71 #else
72                 case  PVRSRV_HANDLE_TYPE_NONE:
73                         *phOSMemHandle = (IMG_VOID *)hMHandleInt;
74                         break;
75 #endif
76                 default:
77                         return PVRSRV_ERROR_BAD_MAPPING;
78         }
79
80         return PVRSRV_OK;
81 }