Back to index

libdrm  2.4.37
intel_bufmgr.h
Go to the documentation of this file.
00001 /*
00002  * Copyright © 2008-2012 Intel Corporation
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a
00005  * copy of this software and associated documentation files (the "Software"),
00006  * to deal in the Software without restriction, including without limitation
00007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008  * and/or sell copies of the Software, and to permit persons to whom the
00009  * Software is furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice (including the next
00012  * paragraph) shall be included in all copies or substantial portions of the
00013  * Software.
00014  *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00018  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00020  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
00021  * IN THE SOFTWARE.
00022  *
00023  * Authors:
00024  *    Eric Anholt <eric@anholt.net>
00025  *
00026  */
00027 
00034 #ifndef INTEL_BUFMGR_H
00035 #define INTEL_BUFMGR_H
00036 
00037 #include <stdio.h>
00038 #include <stdint.h>
00039 #include <stdio.h>
00040 
00041 struct drm_clip_rect;
00042 
00043 typedef struct _drm_intel_bufmgr drm_intel_bufmgr;
00044 typedef struct _drm_intel_context drm_intel_context;
00045 typedef struct _drm_intel_bo drm_intel_bo;
00046 
00047 struct _drm_intel_bo {
00054        unsigned long size;
00055 
00061        unsigned long align;
00062 
00068        unsigned long offset;
00069 
00074 #ifdef __cplusplus
00075        void *virt;
00076 #else
00077        void *virtual;
00078 #endif
00079 
00081        drm_intel_bufmgr *bufmgr;
00082 
00086        int handle;
00087 };
00088 
00089 enum aub_dump_bmp_format {
00090        AUB_DUMP_BMP_FORMAT_8BIT = 1,
00091        AUB_DUMP_BMP_FORMAT_ARGB_4444 = 4,
00092        AUB_DUMP_BMP_FORMAT_ARGB_0888 = 6,
00093        AUB_DUMP_BMP_FORMAT_ARGB_8888 = 7,
00094 };
00095 
00096 typedef struct _drm_intel_aub_annotation {
00097        uint32_t type;
00098        uint32_t subtype;
00099        uint32_t ending_offset;
00100 } drm_intel_aub_annotation;
00101 
00102 #define BO_ALLOC_FOR_RENDER (1<<0)
00103 
00104 drm_intel_bo *drm_intel_bo_alloc(drm_intel_bufmgr *bufmgr, const char *name,
00105                              unsigned long size, unsigned int alignment);
00106 drm_intel_bo *drm_intel_bo_alloc_for_render(drm_intel_bufmgr *bufmgr,
00107                                        const char *name,
00108                                        unsigned long size,
00109                                        unsigned int alignment);
00110 drm_intel_bo *drm_intel_bo_alloc_tiled(drm_intel_bufmgr *bufmgr,
00111                                    const char *name,
00112                                    int x, int y, int cpp,
00113                                    uint32_t *tiling_mode,
00114                                    unsigned long *pitch,
00115                                    unsigned long flags);
00116 void drm_intel_bo_reference(drm_intel_bo *bo);
00117 void drm_intel_bo_unreference(drm_intel_bo *bo);
00118 int drm_intel_bo_map(drm_intel_bo *bo, int write_enable);
00119 int drm_intel_bo_unmap(drm_intel_bo *bo);
00120 
00121 int drm_intel_bo_subdata(drm_intel_bo *bo, unsigned long offset,
00122                       unsigned long size, const void *data);
00123 int drm_intel_bo_get_subdata(drm_intel_bo *bo, unsigned long offset,
00124                           unsigned long size, void *data);
00125 void drm_intel_bo_wait_rendering(drm_intel_bo *bo);
00126 
00127 void drm_intel_bufmgr_set_debug(drm_intel_bufmgr *bufmgr, int enable_debug);
00128 void drm_intel_bufmgr_destroy(drm_intel_bufmgr *bufmgr);
00129 int drm_intel_bo_exec(drm_intel_bo *bo, int used,
00130                     struct drm_clip_rect *cliprects, int num_cliprects, int DR4);
00131 int drm_intel_bo_mrb_exec(drm_intel_bo *bo, int used,
00132                      struct drm_clip_rect *cliprects, int num_cliprects, int DR4,
00133                      unsigned int flags);
00134 int drm_intel_bufmgr_check_aperture_space(drm_intel_bo ** bo_array, int count);
00135 
00136 int drm_intel_bo_emit_reloc(drm_intel_bo *bo, uint32_t offset,
00137                          drm_intel_bo *target_bo, uint32_t target_offset,
00138                          uint32_t read_domains, uint32_t write_domain);
00139 int drm_intel_bo_emit_reloc_fence(drm_intel_bo *bo, uint32_t offset,
00140                               drm_intel_bo *target_bo,
00141                               uint32_t target_offset,
00142                               uint32_t read_domains, uint32_t write_domain);
00143 int drm_intel_bo_pin(drm_intel_bo *bo, uint32_t alignment);
00144 int drm_intel_bo_unpin(drm_intel_bo *bo);
00145 int drm_intel_bo_set_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,
00146                          uint32_t stride);
00147 int drm_intel_bo_get_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,
00148                          uint32_t * swizzle_mode);
00149 int drm_intel_bo_flink(drm_intel_bo *bo, uint32_t * name);
00150 int drm_intel_bo_busy(drm_intel_bo *bo);
00151 int drm_intel_bo_madvise(drm_intel_bo *bo, int madv);
00152 
00153 int drm_intel_bo_disable_reuse(drm_intel_bo *bo);
00154 int drm_intel_bo_is_reusable(drm_intel_bo *bo);
00155 int drm_intel_bo_references(drm_intel_bo *bo, drm_intel_bo *target_bo);
00156 
00157 /* drm_intel_bufmgr_gem.c */
00158 drm_intel_bufmgr *drm_intel_bufmgr_gem_init(int fd, int batch_size);
00159 drm_intel_bo *drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
00160                                           const char *name,
00161                                           unsigned int handle);
00162 void drm_intel_bufmgr_gem_enable_reuse(drm_intel_bufmgr *bufmgr);
00163 void drm_intel_bufmgr_gem_enable_fenced_relocs(drm_intel_bufmgr *bufmgr);
00164 void drm_intel_bufmgr_gem_set_vma_cache_size(drm_intel_bufmgr *bufmgr,
00165                                         int limit);
00166 int drm_intel_gem_bo_map_unsynchronized(drm_intel_bo *bo);
00167 int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo);
00168 int drm_intel_gem_bo_unmap_gtt(drm_intel_bo *bo);
00169 
00170 int drm_intel_gem_bo_get_reloc_count(drm_intel_bo *bo);
00171 void drm_intel_gem_bo_clear_relocs(drm_intel_bo *bo, int start);
00172 void drm_intel_gem_bo_start_gtt_access(drm_intel_bo *bo, int write_enable);
00173 
00174 void drm_intel_bufmgr_gem_set_aub_dump(drm_intel_bufmgr *bufmgr, int enable);
00175 void drm_intel_gem_bo_aub_dump_bmp(drm_intel_bo *bo,
00176                                int x1, int y1, int width, int height,
00177                                enum aub_dump_bmp_format format,
00178                                int pitch, int offset);
00179 void
00180 drm_intel_bufmgr_gem_set_aub_annotations(drm_intel_bo *bo,
00181                                     drm_intel_aub_annotation *annotations,
00182                                     unsigned count);
00183 
00184 int drm_intel_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, int crtc_id);
00185 
00186 int drm_intel_get_aperture_sizes(int fd, size_t *mappable, size_t *total);
00187 int drm_intel_bufmgr_gem_get_devid(drm_intel_bufmgr *bufmgr);
00188 int drm_intel_gem_bo_wait(drm_intel_bo *bo, int64_t timeout_ns);
00189 
00190 drm_intel_context *drm_intel_gem_context_create(drm_intel_bufmgr *bufmgr);
00191 void drm_intel_gem_context_destroy(drm_intel_context *ctx);
00192 int drm_intel_gem_bo_context_exec(drm_intel_bo *bo, drm_intel_context *ctx,
00193                               int used, unsigned int flags);
00194 
00195 /* drm_intel_bufmgr_fake.c */
00196 drm_intel_bufmgr *drm_intel_bufmgr_fake_init(int fd,
00197                                         unsigned long low_offset,
00198                                         void *low_virtual,
00199                                         unsigned long size,
00200                                         volatile unsigned int
00201                                         *last_dispatch);
00202 void drm_intel_bufmgr_fake_set_last_dispatch(drm_intel_bufmgr *bufmgr,
00203                                         volatile unsigned int
00204                                         *last_dispatch);
00205 void drm_intel_bufmgr_fake_set_exec_callback(drm_intel_bufmgr *bufmgr,
00206                                         int (*exec) (drm_intel_bo *bo,
00207                                                    unsigned int used,
00208                                                    void *priv),
00209                                         void *priv);
00210 void drm_intel_bufmgr_fake_set_fence_callback(drm_intel_bufmgr *bufmgr,
00211                                          unsigned int (*emit) (void *priv),
00212                                          void (*wait) (unsigned int fence,
00213                                                      void *priv),
00214                                          void *priv);
00215 drm_intel_bo *drm_intel_bo_fake_alloc_static(drm_intel_bufmgr *bufmgr,
00216                                         const char *name,
00217                                         unsigned long offset,
00218                                         unsigned long size, void *virt);
00219 void drm_intel_bo_fake_disable_backing_store(drm_intel_bo *bo,
00220                                         void (*invalidate_cb) (drm_intel_bo
00221                                                             * bo,
00222                                                             void *ptr),
00223                                         void *ptr);
00224 
00225 void drm_intel_bufmgr_fake_contended_lock_take(drm_intel_bufmgr *bufmgr);
00226 void drm_intel_bufmgr_fake_evict_all(drm_intel_bufmgr *bufmgr);
00227 
00228 struct drm_intel_decode *drm_intel_decode_context_alloc(uint32_t devid);
00229 void drm_intel_decode_context_free(struct drm_intel_decode *ctx);
00230 void drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
00231                                    void *data, uint32_t hw_offset,
00232                                    int count);
00233 void drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
00234                                    int dump_past_end);
00235 void drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
00236                                 uint32_t head, uint32_t tail);
00237 void drm_intel_decode_set_output_file(struct drm_intel_decode *ctx, FILE *out);
00238 void drm_intel_decode(struct drm_intel_decode *ctx);
00239 
00240 
00244 #define dri_bo drm_intel_bo
00245 #define dri_bufmgr drm_intel_bufmgr
00246 #define dri_bo_alloc drm_intel_bo_alloc
00247 #define dri_bo_reference drm_intel_bo_reference
00248 #define dri_bo_unreference drm_intel_bo_unreference
00249 #define dri_bo_map drm_intel_bo_map
00250 #define dri_bo_unmap drm_intel_bo_unmap
00251 #define dri_bo_subdata drm_intel_bo_subdata
00252 #define dri_bo_get_subdata drm_intel_bo_get_subdata
00253 #define dri_bo_wait_rendering drm_intel_bo_wait_rendering
00254 #define dri_bufmgr_set_debug drm_intel_bufmgr_set_debug
00255 #define dri_bufmgr_destroy drm_intel_bufmgr_destroy
00256 #define dri_bo_exec drm_intel_bo_exec
00257 #define dri_bufmgr_check_aperture_space drm_intel_bufmgr_check_aperture_space
00258 #define dri_bo_emit_reloc(reloc_bo, read, write, target_offset,              \
00259                        reloc_offset, target_bo)                \
00260        drm_intel_bo_emit_reloc(reloc_bo, reloc_offset,                \
00261                             target_bo, target_offset,          \
00262                             read, write);
00263 #define dri_bo_pin drm_intel_bo_pin
00264 #define dri_bo_unpin drm_intel_bo_unpin
00265 #define dri_bo_get_tiling drm_intel_bo_get_tiling
00266 #define dri_bo_set_tiling(bo, mode) drm_intel_bo_set_tiling(bo, mode, 0)
00267 #define dri_bo_flink drm_intel_bo_flink
00268 #define intel_bufmgr_gem_init drm_intel_bufmgr_gem_init
00269 #define intel_bo_gem_create_from_name drm_intel_bo_gem_create_from_name
00270 #define intel_bufmgr_gem_enable_reuse drm_intel_bufmgr_gem_enable_reuse
00271 #define intel_bufmgr_fake_init drm_intel_bufmgr_fake_init
00272 #define intel_bufmgr_fake_set_last_dispatch drm_intel_bufmgr_fake_set_last_dispatch
00273 #define intel_bufmgr_fake_set_exec_callback drm_intel_bufmgr_fake_set_exec_callback
00274 #define intel_bufmgr_fake_set_fence_callback drm_intel_bufmgr_fake_set_fence_callback
00275 #define intel_bo_fake_alloc_static drm_intel_bo_fake_alloc_static
00276 #define intel_bo_fake_disable_backing_store drm_intel_bo_fake_disable_backing_store
00277 #define intel_bufmgr_fake_contended_lock_take drm_intel_bufmgr_fake_contended_lock_take
00278 #define intel_bufmgr_fake_evict_all drm_intel_bufmgr_fake_evict_all
00279 
00282 #endif /* INTEL_BUFMGR_H */