1 #ifndef __NOUVEAU_LIBDRM_PRIVATE_H__
2 #define __NOUVEAU_LIBDRM_PRIVATE_H__
6 #include <libdrm_macros.h>
8 #include <xf86atomic.h>
10 #include "nouveau_drm.h"
15 * 0x00000001 dump all pushbuffers
16 * 0x00000002 submit pushbuffers synchronously
17 * 0x80000000 if compiled with SIMULATE return -EINVAL for all pb submissions
19 drm_private
extern uint32_t nouveau_debug
;
20 drm_private
extern FILE *nouveau_out
;
21 #define dbg_on(lvl) (nouveau_debug & (1 << lvl))
22 #define dbg(lvl, fmt, args...) do { \
24 fprintf(nouveau_out, "nouveau: "fmt, ##args); \
26 #define err(fmt, args...) fprintf(nouveau_out, "nouveau: "fmt, ##args)
28 struct nouveau_client_kref
{
29 struct drm_nouveau_gem_pushbuf_bo
*kref
;
30 struct nouveau_pushbuf
*push
;
33 struct nouveau_client_priv
{
34 struct nouveau_client base
;
35 struct nouveau_client_kref
*kref
;
39 static inline struct nouveau_client_priv
*
40 nouveau_client(struct nouveau_client
*client
)
42 return (struct nouveau_client_priv
*)client
;
45 static inline struct drm_nouveau_gem_pushbuf_bo
*
46 cli_kref_get(struct nouveau_client
*client
, struct nouveau_bo
*bo
)
48 struct nouveau_client_priv
*pcli
= nouveau_client(client
);
49 struct drm_nouveau_gem_pushbuf_bo
*kref
= NULL
;
50 if (pcli
->kref_nr
> bo
->handle
)
51 kref
= pcli
->kref
[bo
->handle
].kref
;
55 static inline struct nouveau_pushbuf
*
56 cli_push_get(struct nouveau_client
*client
, struct nouveau_bo
*bo
)
58 struct nouveau_client_priv
*pcli
= nouveau_client(client
);
59 struct nouveau_pushbuf
*push
= NULL
;
60 if (pcli
->kref_nr
> bo
->handle
)
61 push
= pcli
->kref
[bo
->handle
].push
;
66 cli_kref_set(struct nouveau_client
*client
, struct nouveau_bo
*bo
,
67 struct drm_nouveau_gem_pushbuf_bo
*kref
,
68 struct nouveau_pushbuf
*push
)
70 struct nouveau_client_priv
*pcli
= nouveau_client(client
);
71 if (pcli
->kref_nr
<= bo
->handle
) {
72 pcli
->kref
= realloc(pcli
->kref
,
73 sizeof(*pcli
->kref
) * bo
->handle
* 2);
74 while (pcli
->kref_nr
< bo
->handle
* 2) {
75 pcli
->kref
[pcli
->kref_nr
].kref
= NULL
;
76 pcli
->kref
[pcli
->kref_nr
].push
= NULL
;
80 pcli
->kref
[bo
->handle
].kref
= kref
;
81 pcli
->kref
[bo
->handle
].push
= push
;
84 struct nouveau_bo_priv
{
85 struct nouveau_bo base
;
86 struct nouveau_list head
;
93 static inline struct nouveau_bo_priv
*
94 nouveau_bo(struct nouveau_bo
*bo
)
96 return (struct nouveau_bo_priv
*)bo
;
99 struct nouveau_device_priv
{
100 struct nouveau_device base
;
102 pthread_mutex_t lock
;
103 struct nouveau_list bo_list
;
107 int gart_limit_percent
, vram_limit_percent
;
110 static inline struct nouveau_device_priv
*
111 nouveau_device(struct nouveau_device
*dev
)
113 return (struct nouveau_device_priv
*)dev
;
117 nouveau_device_open_existing(struct nouveau_device
**, int, int, drm_context_t
);
120 drm_private
bool abi16_object(struct nouveau_object
*, int (**)(struct nouveau_object
*));
121 drm_private
void abi16_delete(struct nouveau_object
*);
122 drm_private
int abi16_sclass(struct nouveau_object
*, struct nouveau_sclass
**);
123 drm_private
void abi16_bo_info(struct nouveau_bo
*, struct drm_nouveau_gem_info
*);
124 drm_private
int abi16_bo_init(struct nouveau_bo
*, uint32_t alignment
,
125 union nouveau_bo_config
*);