00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <xf86drm.h>
00033 #include <stdlib.h>
00034 #include <errno.h>
00035 #include "pipe/p_debug.h"
00036 #include "pipe/p_thread.h"
00037 #include "ws_dri_bufpool.h"
00038 #include "ws_dri_bufmgr.h"
00039
00040 static void *
00041 pool_create(struct _DriBufferPool *pool,
00042 unsigned long size, uint64_t flags, unsigned hint,
00043 unsigned alignment)
00044 {
00045 unsigned long *private = malloc(size + 2*sizeof(unsigned long));
00046 if ((flags & DRM_BO_MASK_MEM) != DRM_BO_FLAG_MEM_LOCAL)
00047 abort();
00048
00049 *private = size;
00050 return (void *)private;
00051 }
00052
00053
00054 static int
00055 pool_destroy(struct _DriBufferPool *pool, void *private)
00056 {
00057 free(private);
00058 return 0;
00059 }
00060
00061 static int
00062 pool_waitIdle(struct _DriBufferPool *pool, void *private,
00063 pipe_mutex *mutex, int lazy)
00064 {
00065 return 0;
00066 }
00067
00068 static int
00069 pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
00070 int hint, pipe_mutex *mutex, void **virtual)
00071 {
00072 *virtual = (void *)((unsigned long *)private + 2);
00073 return 0;
00074 }
00075
00076 static int
00077 pool_unmap(struct _DriBufferPool *pool, void *private)
00078 {
00079 return 0;
00080 }
00081
00082 static unsigned long
00083 pool_offset(struct _DriBufferPool *pool, void *private)
00084 {
00085
00086
00087
00088 abort();
00089 return 0UL;
00090 }
00091
00092 static unsigned long
00093 pool_poolOffset(struct _DriBufferPool *pool, void *private)
00094 {
00095
00096
00097
00098 abort();
00099 }
00100
00101 static uint64_t
00102 pool_flags(struct _DriBufferPool *pool, void *private)
00103 {
00104 return DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
00105 }
00106
00107 static unsigned long
00108 pool_size(struct _DriBufferPool *pool, void *private)
00109 {
00110 return *(unsigned long *) private;
00111 }
00112
00113
00114 static int
00115 pool_fence(struct _DriBufferPool *pool, void *private,
00116 struct _DriFenceObject *fence)
00117 {
00118 abort();
00119 return 0UL;
00120 }
00121
00122 static drmBO *
00123 pool_kernel(struct _DriBufferPool *pool, void *private)
00124 {
00125 abort();
00126 return NULL;
00127 }
00128
00129 static void
00130 pool_takedown(struct _DriBufferPool *pool)
00131 {
00132 free(pool);
00133 }
00134
00135
00136 struct _DriBufferPool *
00137 driMallocPoolInit(void)
00138 {
00139 struct _DriBufferPool *pool;
00140
00141 pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
00142 if (!pool)
00143 return NULL;
00144
00145 pool->data = NULL;
00146 pool->fd = -1;
00147 pool->map = &pool_map;
00148 pool->unmap = &pool_unmap;
00149 pool->destroy = &pool_destroy;
00150 pool->offset = &pool_offset;
00151 pool->poolOffset = &pool_poolOffset;
00152 pool->flags = &pool_flags;
00153 pool->size = &pool_size;
00154 pool->create = &pool_create;
00155 pool->fence = &pool_fence;
00156 pool->kernel = &pool_kernel;
00157 pool->validate = NULL;
00158 pool->waitIdle = &pool_waitIdle;
00159 pool->takeDown = &pool_takedown;
00160 return pool;
00161 }