1 /**************************************************************************
3 * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * 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, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
27 **************************************************************************/
29 * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
32 #ifndef _PSB_BUFPOOL_H_
33 #define _PSB_BUFPOOL_H_
36 #include "pipe/p_thread.h"
37 struct _DriFenceObject
;
39 typedef struct _DriBufferPool
42 int (*map
) (struct _DriBufferPool
* pool
, void *private,
43 unsigned flags
, int hint
, pipe_mutex
*mutex
,
45 int (*unmap
) (struct _DriBufferPool
* pool
, void *private);
46 int (*destroy
) (struct _DriBufferPool
* pool
, void *private);
47 unsigned long (*offset
) (struct _DriBufferPool
* pool
, void *private);
48 unsigned long (*poolOffset
) (struct _DriBufferPool
* pool
, void *private);
49 uint64_t (*flags
) (struct _DriBufferPool
* pool
, void *private);
50 unsigned long (*size
) (struct _DriBufferPool
* pool
, void *private);
51 void *(*create
) (struct _DriBufferPool
* pool
, unsigned long size
,
52 uint64_t flags
, unsigned hint
, unsigned alignment
);
53 void *(*reference
) (struct _DriBufferPool
* pool
, unsigned handle
);
54 int (*unreference
) (struct _DriBufferPool
* pool
, void *private);
55 int (*fence
) (struct _DriBufferPool
* pool
, void *private,
56 struct _DriFenceObject
* fence
);
57 drmBO
*(*kernel
) (struct _DriBufferPool
* pool
, void *private);
58 int (*validate
) (struct _DriBufferPool
* pool
, void *private, pipe_mutex
*mutex
);
59 int (*waitIdle
) (struct _DriBufferPool
*pool
, void *private, pipe_mutex
*mutex
,
61 int (*setStatus
) (struct _DriBufferPool
*pool
, void *private,
62 uint64_t flag_diff
, uint64_t old_flags
);
63 void (*takeDown
) (struct _DriBufferPool
* pool
);
67 extern void bmError(int val
, const char *file
, const char *function
,
69 #define BM_CKFATAL(val) \
73 bmError(tstVal, __FILE__, __FUNCTION__, __LINE__); \
82 * Kernel buffer objects. Size in multiples of page size. Page size aligned.
85 extern struct _DriBufferPool
*driDRMPoolInit(int fd
);
86 extern struct _DriBufferPool
*driMallocPoolInit(void);
88 struct _DriFreeSlabManager
;
89 extern struct _DriBufferPool
* driSlabPoolInit(int fd
, uint64_t flags
,
91 uint32_t smallestSize
,
93 uint32_t desiredNumBuffers
,
95 uint32_t pageAlignment
,
96 struct _DriFreeSlabManager
*fMan
);
97 extern void driFinishFreeSlabManager(struct _DriFreeSlabManager
*fMan
);
98 extern struct _DriFreeSlabManager
*
99 driInitFreeSlabManager(uint32_t checkIntervalMsec
, uint32_t slabTimeoutMsec
);