1 /**************************************************************************
3 * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved.
5 * Contact: Konstantin Drabeniuk <k.drabeniuk@samsung.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
29 #ifndef TBM_BUFMGR_STUBS_H
30 #define TBM_BUFMGR_STUBS_H
32 #include <tbm_bufmgr.h>
34 /* HELPER FUNCTIONS */
36 static int bo_size = 100;
37 static int bo2_size = 100;
38 static void *ret_bo = (void *)"bo_alloc";
39 static int UT_TBM_ERROR = 0;
40 static int TBM_BO_ALLOC_ERROR = 0;
41 static int TBM_BO_IMPORT_ERROR = 0;
42 static int bo_ret_flags = TBM_BO_SCANOUT;
43 static int ut_tbm_bufmgr_init_error;
44 static int ut_tbm_data_free_called = 0;
46 static int ut_bo_size(tbm_bo __attribute__ ((unused)) bo)
51 static int ut_bo2_size(tbm_bo __attribute__ ((unused)) bo)
56 static void *ut_bo_alloc(tbm_bo __attribute__ ((unused)) bo,
57 int __attribute__ ((unused)) size,
58 int __attribute__ ((unused)) flags)
60 if (TBM_BO_ALLOC_ERROR)
66 static void *ut_bo_import(tbm_bo __attribute__ ((unused)) bo,
67 unsigned int __attribute__ ((unused)) key)
69 if (TBM_BO_IMPORT_ERROR)
75 static int ut_bo_get_flags(tbm_bo __attribute__ ((unused)) bo)
80 static void *ut_bo_import_fd(tbm_bo __attribute__ ((unused)) bo,
81 tbm_fd __attribute__ ((unused)) fd)
83 if (TBM_BO_IMPORT_ERROR)
89 static unsigned int ut_bo_export(tbm_bo __attribute__ ((unused)) bo)
97 static tbm_fd ut_bo_export_fd(tbm_bo __attribute__ ((unused)) bo)
105 static tbm_bo_handle ut_bo_get_handle(tbm_bo __attribute__ ((unused)) bo,
106 int __attribute__ ((unused)) device)
113 ret.ptr = (void *)12;
118 static tbm_bo_handle ut_bo_map(tbm_bo __attribute__ ((unused)) bo,
119 int __attribute__ ((unused)) device,
120 int __attribute__ ((unused)) opt)
127 ret.ptr = (void *)12;
132 static int ut_bo_unmap(tbm_bo __attribute__ ((unused)) bo)
140 static void ut_tbm_data_free(void __attribute__ ((unused)) *user_data)
142 ut_tbm_data_free_called = 1;
145 static int ut_bufmgr_bind_native_display(tbm_bufmgr __attribute__ ((unused)) bufmgr,
146 void __attribute__ ((unused)) *NativeDisplay)
154 static struct _tbm_bufmgr ut_ret_bufmgr;
155 static tbm_bufmgr ut_tbm_bufmgr_init(int fd)
157 if (ut_tbm_bufmgr_init_error)
160 return &ut_ret_bufmgr;
163 #endif /* TBM_BUFMGR_STUBS_H */