2 * Copyright © 2008 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Eric Anholt <eric@anholt.net>
29 * @file intel_bufmgr.h
31 * Public definitions of Intel-specific bufmgr functions.
34 #ifndef INTEL_BUFMGR_H
35 #define INTEL_BUFMGR_H
39 typedef struct _dri_bufmgr dri_bufmgr;
40 typedef struct _dri_bo dri_bo;
44 * Size in bytes of the buffer object.
46 * The size may be larger than the size originally requested for the
47 * allocation, such as being aligned to page size.
51 * Card virtual address (offset from the beginning of the aperture) for the
52 * object. Only valid while validated.
56 * Virtual address for accessing the buffer data. Only valid while mapped.
60 /** Buffer manager context associated with this buffer object */
64 dri_bo *dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
65 unsigned int alignment);
66 void dri_bo_reference(dri_bo *bo);
67 void dri_bo_unreference(dri_bo *bo);
68 int dri_bo_map(dri_bo *buf, int write_enable);
69 int dri_bo_unmap(dri_bo *buf);
71 int dri_bo_subdata(dri_bo *bo, unsigned long offset,
72 unsigned long size, const void *data);
73 int dri_bo_get_subdata(dri_bo *bo, unsigned long offset,
74 unsigned long size, void *data);
75 void dri_bo_wait_rendering(dri_bo *bo);
77 void dri_bufmgr_set_debug(dri_bufmgr *bufmgr, int enable_debug);
78 void dri_bufmgr_destroy(dri_bufmgr *bufmgr);
79 int dri_bo_exec(dri_bo *bo, int used,
80 drm_clip_rect_t *cliprects, int num_cliprects,
82 int dri_bufmgr_check_aperture_space(dri_bo **bo_array, int count);
84 int dri_bo_emit_reloc(dri_bo *reloc_buf,
85 uint32_t read_domains, uint32_t write_domain,
86 uint32_t delta, uint32_t offset, dri_bo *target_buf);
87 int dri_bo_pin(dri_bo *buf, uint32_t alignment);
88 int dri_bo_unpin(dri_bo *buf);
89 int dri_bo_set_tiling(dri_bo *buf, uint32_t *tiling_mode);
90 int dri_bo_get_tiling(dri_bo *buf, uint32_t *tiling_mode,
91 uint32_t *swizzle_mode);
92 int dri_bo_flink(dri_bo *buf, uint32_t *name);
94 /* intel_bufmgr_gem.c */
95 dri_bufmgr *intel_bufmgr_gem_init(int fd, int batch_size);
96 dri_bo *intel_bo_gem_create_from_name(dri_bufmgr *bufmgr, const char *name,
98 void intel_bufmgr_gem_enable_reuse(dri_bufmgr *bufmgr);
100 /* intel_bufmgr_fake.c */
101 dri_bufmgr *intel_bufmgr_fake_init(int fd,
102 unsigned long low_offset, void *low_virtual,
104 volatile unsigned int *last_dispatch);
105 void intel_bufmgr_fake_set_last_dispatch(dri_bufmgr *bufmgr,
106 volatile unsigned int *last_dispatch);
107 void intel_bufmgr_fake_set_exec_callback(dri_bufmgr *bufmgr,
108 int (*exec)(dri_bo *bo,
112 void intel_bufmgr_fake_set_fence_callback(dri_bufmgr *bufmgr,
113 unsigned int (*emit)(void *priv),
114 void (*wait)(unsigned int fence,
117 dri_bo *intel_bo_fake_alloc_static(dri_bufmgr *bufmgr, const char *name,
118 unsigned long offset, unsigned long size,
120 void intel_bo_fake_disable_backing_store(dri_bo *bo,
121 void (*invalidate_cb)(dri_bo *bo,
125 void intel_bufmgr_fake_contended_lock_take(dri_bufmgr *bufmgr);
126 void intel_bufmgr_fake_evict_all(dri_bufmgr *bufmgr);
128 #endif /* INTEL_BUFMGR_H */