2 * Copyright © 2008 Dave Airlie
3 * Copyright © 2008 Jérôme Glisse
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:
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.
23 * The above copyright notice and this permission notice (including the
24 * next paragraph) shall be included in all copies or substantial portions
30 * Jérôme Glisse <glisse@freedesktop.org>
32 #include <radeon_bo.h>
33 #include <radeon_bo_int.h>
35 void radeon_bo_debug(struct radeon_bo *bo, const char *op)
37 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
39 fprintf(stderr, "%s %p 0x%08X 0x%08X 0x%08X\n",
40 op, bo, bo->handle, boi->size, boi->cref);
43 struct radeon_bo *radeon_bo_open(struct radeon_bo_manager *bom,
51 bo = bom->funcs->bo_open(bom, handle, size, alignment, domains, flags);
55 void radeon_bo_ref(struct radeon_bo *bo)
57 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
59 boi->bom->funcs->bo_ref(boi);
62 struct radeon_bo *radeon_bo_unref(struct radeon_bo *bo)
64 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
69 return boi->bom->funcs->bo_unref(boi);
72 int radeon_bo_map(struct radeon_bo *bo, int write)
74 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
75 return boi->bom->funcs->bo_map(boi, write);
78 int radeon_bo_unmap(struct radeon_bo *bo)
80 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
81 return boi->bom->funcs->bo_unmap(boi);
84 int radeon_bo_wait(struct radeon_bo *bo)
86 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
87 if (!boi->bom->funcs->bo_wait)
89 return boi->bom->funcs->bo_wait(boi);
92 int radeon_bo_is_busy(struct radeon_bo *bo, uint32_t *domain)
94 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
95 return boi->bom->funcs->bo_is_busy(boi, domain);
98 int radeon_bo_set_tiling(struct radeon_bo *bo,
99 uint32_t tiling_flags, uint32_t pitch)
101 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
102 return boi->bom->funcs->bo_set_tiling(boi, tiling_flags, pitch);
105 int radeon_bo_get_tiling(struct radeon_bo *bo,
106 uint32_t *tiling_flags, uint32_t *pitch)
108 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
109 return boi->bom->funcs->bo_get_tiling(boi, tiling_flags, pitch);
112 int radeon_bo_is_static(struct radeon_bo *bo)
114 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
115 if (boi->bom->funcs->bo_is_static)
116 return boi->bom->funcs->bo_is_static(boi);
120 int radeon_bo_is_referenced_by_cs(struct radeon_bo *bo, struct radeon_cs *cs)
122 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
123 return boi->cref > 1;
126 uint32_t radeon_bo_get_handle(struct radeon_bo *bo)
131 uint32_t radeon_bo_get_src_domain(struct radeon_bo *bo)
133 struct radeon_bo_int *boi = (struct radeon_bo_int *)bo;
136 src_domain = boi->space_accounted & 0xffff;
138 src_domain = boi->space_accounted >> 16;