1 #ifndef __NOUVEAU_LIBDRM_PRIVATE_H__
2 #define __NOUVEAU_LIBDRM_PRIVATE_H__
5 #include <xf86atomic.h>
6 #include "nouveau_drm.h"
11 uint32_t nouveau_debug;
12 #define dbg_on(lvl) (nouveau_debug & (1 << lvl))
13 #define dbg(lvl, fmt, args...) do { \
15 fprintf(stderr, "nouveau: "fmt, ##args); \
18 #define dbg_on(lvl) (0)
19 #define dbg(lvl, fmt, args...)
21 #define err(fmt, args...) fprintf(stderr, "nouveau: "fmt, ##args)
23 struct nouveau_client_kref {
24 struct drm_nouveau_gem_pushbuf_bo *kref;
25 struct nouveau_pushbuf *push;
28 struct nouveau_client_priv {
29 struct nouveau_client base;
30 struct nouveau_client_kref *kref;
34 static inline struct nouveau_client_priv *
35 nouveau_client(struct nouveau_client *client)
37 return (struct nouveau_client_priv *)client;
40 static inline struct drm_nouveau_gem_pushbuf_bo *
41 cli_kref_get(struct nouveau_client *client, struct nouveau_bo *bo)
43 struct nouveau_client_priv *pcli = nouveau_client(client);
44 struct drm_nouveau_gem_pushbuf_bo *kref = NULL;
45 if (pcli->kref_nr > bo->handle)
46 kref = pcli->kref[bo->handle].kref;
50 static inline struct nouveau_pushbuf *
51 cli_push_get(struct nouveau_client *client, struct nouveau_bo *bo)
53 struct nouveau_client_priv *pcli = nouveau_client(client);
54 struct nouveau_pushbuf *push = NULL;
55 if (pcli->kref_nr > bo->handle)
56 push = pcli->kref[bo->handle].push;
61 cli_kref_set(struct nouveau_client *client, struct nouveau_bo *bo,
62 struct drm_nouveau_gem_pushbuf_bo *kref,
63 struct nouveau_pushbuf *push)
65 struct nouveau_client_priv *pcli = nouveau_client(client);
66 if (pcli->kref_nr <= bo->handle) {
67 pcli->kref = realloc(pcli->kref,
68 sizeof(*pcli->kref) * bo->handle * 2);
69 while (pcli->kref_nr < bo->handle * 2) {
70 pcli->kref[pcli->kref_nr].kref = NULL;
71 pcli->kref[pcli->kref_nr].push = NULL;
75 pcli->kref[bo->handle].kref = kref;
76 pcli->kref[bo->handle].push = push;
79 struct nouveau_bo_priv {
80 struct nouveau_bo base;
81 struct nouveau_list head;
88 static inline struct nouveau_bo_priv *
89 nouveau_bo(struct nouveau_bo *bo)
91 return (struct nouveau_bo_priv *)bo;
94 struct nouveau_device_priv {
95 struct nouveau_device base;
98 struct nouveau_list bo_list;
102 int gart_limit_percent, vram_limit_percent;
105 static inline struct nouveau_device_priv *
106 nouveau_device(struct nouveau_device *dev)
108 return (struct nouveau_device_priv *)dev;
112 nouveau_device_open_existing(struct nouveau_device **, int, int, drm_context_t);
115 int abi16_chan_nv04(struct nouveau_object *);
116 int abi16_chan_nvc0(struct nouveau_object *);
117 int abi16_chan_nve0(struct nouveau_object *);
118 int abi16_engobj(struct nouveau_object *);
119 int abi16_ntfy(struct nouveau_object *);
120 void abi16_bo_info(struct nouveau_bo *, struct drm_nouveau_gem_info *);
121 int abi16_bo_init(struct nouveau_bo *, uint32_t alignment,
122 union nouveau_bo_config *);