fixes for bc_cat
[sgx.git] / pvr / bridged_support.c
1 /**********************************************************************
2  *
3  * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful but, except
10  * as otherwise stated in writing, without any warranty; without even the
11  * implied warranty of merchantability or fitness for a particular purpose.
12  * See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * The full GNU General Public License is included in this distribution in
19  * the file called "COPYING".
20  *
21  * Contact Information:
22  * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23  * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
24  *
25  ******************************************************************************/
26
27 #include "img_defs.h"
28 #include "servicesint.h"
29 #include "bridged_support.h"
30
31 enum PVRSRV_ERROR
32 PVRSRVLookupOSMemHandle(struct PVRSRV_HANDLE_BASE *psHandleBase,
33                         void **phOSMemHandle, void *hMHandle)
34 {
35         void *hMHandleInt;
36         enum PVRSRV_HANDLE_TYPE eHandleType;
37         enum PVRSRV_ERROR eError;
38
39         eError = PVRSRVLookupHandleAnyType(psHandleBase, &hMHandleInt,
40                                            &eHandleType, hMHandle);
41         if (eError != PVRSRV_OK)
42                 return eError;
43
44         switch (eHandleType) {
45         case PVRSRV_HANDLE_TYPE_MEM_INFO:
46         case PVRSRV_HANDLE_TYPE_MEM_INFO_REF:
47         case PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO:
48                 {
49                         struct PVRSRV_KERNEL_MEM_INFO *psMemInfo =
50                             (struct PVRSRV_KERNEL_MEM_INFO *)hMHandleInt;
51
52                         *phOSMemHandle = psMemInfo->sMemBlk.hOSMemHandle;
53
54                         break;
55                 }
56         case PVRSRV_HANDLE_TYPE_SYNC_INFO:
57                 {
58                         struct PVRSRV_KERNEL_SYNC_INFO *psSyncInfo =
59                             (struct PVRSRV_KERNEL_SYNC_INFO *)hMHandleInt;
60                         struct PVRSRV_KERNEL_MEM_INFO *psMemInfo =
61                             psSyncInfo->psSyncDataMemInfoKM;
62
63                         *phOSMemHandle = psMemInfo->sMemBlk.hOSMemHandle;
64
65                         break;
66                 }
67         case PVRSRV_HANDLE_TYPE_SOC_TIMER:
68                 {
69                         *phOSMemHandle = (void *)hMHandleInt;
70                         break;
71                 }
72         default:
73                 return PVRSRV_ERROR_BAD_MAPPING;
74         }
75
76         return PVRSRV_OK;;
77 }