Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / gallium / winsys / radeon / drm / radeon_drm_bo.h
1 /*
2  * Copyright © 2008 Jérôme Glisse
3  * Copyright © 2011 Marek Olšák <maraeo@gmail.com>
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17  * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
18  * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21  * USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  * The above copyright notice and this permission notice (including the
24  * next paragraph) shall be included in all copies or substantial portions
25  * of the Software.
26  */
27 /*
28  * Authors:
29  *      Jérôme Glisse <glisse@freedesktop.org>
30  *      Marek Olšák <maraeo@gmail.com>
31  */
32 #ifndef RADEON_DRM_BO_H
33 #define RADEON_DRM_BO_H
34
35 #include "radeon_drm_winsys.h"
36 #include "pipebuffer/pb_bufmgr.h"
37 #include "os/os_thread.h"
38
39 #define RADEON_PB_USAGE_DOMAIN_GTT  (1 << 29)
40 #define RADEON_PB_USAGE_DOMAIN_VRAM (1 << 30)
41
42 struct radeon_bomgr;
43
44 struct radeon_bo {
45     struct pb_buffer base;
46     struct radeon_bomgr *mgr;
47     struct radeon_drm_winsys *rws;
48
49     void *ptr;
50     pipe_mutex map_mutex;
51
52     uint32_t size;
53     uint32_t handle;
54     uint32_t name;
55
56     /* how many command streams is this bo referenced in? */
57     int num_cs_references;
58
59     /* how many command streams, which are being emitted in a separate
60      * thread, is this bo referenced in? */
61     int num_active_ioctls;
62
63     /* Whether the buffer has been relocated for write and is busy since then.
64      * This field is updated in:
65      * - radeon_drm_cs_flush (to TRUE if it's relocated for write)
66      * - radeon_bo_is_busy (to FALSE if it's not busy)
67      * - radeon_bo_wait (to FALSE) */
68     boolean busy_for_write;
69
70     boolean flinked;
71     uint32_t flink;
72 };
73
74 struct pb_manager *radeon_bomgr_create(struct radeon_drm_winsys *rws);
75 void radeon_bomgr_init_functions(struct radeon_drm_winsys *ws);
76
77 static INLINE
78 void radeon_bo_reference(struct radeon_bo **dst, struct radeon_bo *src)
79 {
80     pb_reference((struct pb_buffer**)dst, (struct pb_buffer*)src);
81 }
82
83 static INLINE struct pb_buffer *
84 pb_buffer(struct pb_buffer *buffer)
85 {
86     return (struct pb_buffer *)buffer;
87 }
88
89 #endif