Merge from Tizen 2.2 release
[platform/core/uifw/libtbm.git] / src / tbm_bufmgr_int.h
1 /**************************************************************************\r
2 \r
3 libtbm\r
4 \r
5 Copyright 2012 Samsung Electronics co., Ltd. All Rights Reserved.\r
6 \r
7 Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>\r
8 \r
9 Permission is hereby granted, free of charge, to any person obtaining a\r
10 copy of this software and associated documentation files (the\r
11 "Software"), to deal in the Software without restriction, including\r
12 without limitation the rights to use, copy, modify, merge, publish,\r
13 distribute, sub license, and/or sell copies of the Software, and to\r
14 permit persons to whom the Software is furnished to do so, subject to\r
15 the following conditions:\r
16 \r
17 The above copyright notice and this permission notice (including the\r
18 next paragraph) shall be included in all copies or substantial portions\r
19 of the Software.\r
20 \r
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
22 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.\r
24 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR\r
25 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\r
26 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r
27 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
28 \r
29 **************************************************************************/\r
30 \r
31 #ifndef _TBM_BUFMGR_INT_H_\r
32 #define _TBM_BUFMGR_INT_H_\r
33 \r
34 #include <tbm_bufmgr.h>\r
35 #include <pthread.h>\r
36 #include "tbm_bufmgr_backend.h"\r
37 \r
38 #define TBM_LOG(...)  fprintf (stderr, __VA_ARGS__)\r
39 \r
40 typedef union _tbm_bo_cache_state tbm_bo_cache_state;\r
41 \r
42 struct list_head\r
43 {\r
44     struct list_head *prev;\r
45     struct list_head *next;\r
46 };\r
47 \r
48 union _tbm_bo_cache_state\r
49 {\r
50     unsigned int val;\r
51     struct {\r
52         unsigned int cntFlush:16;    /*Flush all index for sync*/\r
53         unsigned int isCacheable:1;\r
54         unsigned int isCached:1;\r
55         unsigned int isDirtied:2;\r
56     } data;\r
57 };\r
58 \r
59 /**\r
60  * @brief tbm buffer object\r
61  *  buffer object of Tizen Buffer Manager\r
62  */\r
63 struct _tbm_bo\r
64 {\r
65     tbm_bufmgr bufmgr; /**< tbm buffer manager */\r
66 \r
67     int ref_cnt;       /**< ref count of bo */\r
68 \r
69     int flags;         /**< TBM_BO_FLAGS :bo memory type */\r
70 \r
71     unsigned int tgl_key; /**< global key for tizen global lock */\r
72 \r
73     /* for cache control */\r
74     unsigned int map_cnt; /**< device map count */\r
75     tbm_bo_cache_state cache_state; /**< cache state */\r
76 \r
77     int lock_cnt; /**< lock count of bo */\r
78 \r
79     struct list_head user_data_list; /**< list of the user_date in bo */\r
80 \r
81     void *priv; /**< bo private */\r
82 \r
83     struct list_head item_link; /**< link of bo */\r
84 };\r
85 \r
86 /**\r
87  * @brief tbm_bufmgr : structure for tizen buffer manager\r
88  *\r
89  */\r
90 struct _tbm_bufmgr\r
91 {\r
92     int ref_count; /**< ref count of bufmgr */\r
93 \r
94     pthread_mutex_t lock; /**< mutex lock */\r
95 \r
96     int fd;  /**< bufmgr fd */\r
97 \r
98     int lock_fd; /**< fd of tizen global lock */\r
99 \r
100     int lock_type; /**< lock_type of bufmgr */\r
101 \r
102     int use_map_cache; /**< flag to use the map_cahce */\r
103 \r
104     struct list_head bo_list; /**< list of bos belonging to bufmgr */\r
105 \r
106     void *module_data;\r
107 \r
108     tbm_bufmgr_backend backend; /**< bufmgr backend */\r
109 \r
110     struct list_head link; /**< link of bufmgr */\r
111 };\r
112 \r
113 #endif  /* _TBM_BUFMGR_INT_H_ */\r