1 #ifndef __NOUVEAU_LIBDRM_PRIVATE_H__
2 #define __NOUVEAU_LIBDRM_PRIVATE_H__
6 #include <xf86atomic.h>
8 #include "nouveau_drm.h"
13 uint32_t nouveau_debug;
14 #define dbg_on(lvl) (nouveau_debug & (1 << lvl))
15 #define dbg(lvl, fmt, args...) do { \
17 fprintf(stderr, "nouveau: "fmt, ##args); \
20 #define dbg_on(lvl) (0)
21 #define dbg(lvl, fmt, args...)
23 #define err(fmt, args...) fprintf(stderr, "nouveau: "fmt, ##args)
25 struct nouveau_client_kref {
26 struct drm_nouveau_gem_pushbuf_bo *kref;
27 struct nouveau_pushbuf *push;
30 struct nouveau_client_priv {
31 struct nouveau_client base;
32 struct nouveau_client_kref *kref;
36 static inline struct nouveau_client_priv *
37 nouveau_client(struct nouveau_client *client)
39 return (struct nouveau_client_priv *)client;
42 static inline struct drm_nouveau_gem_pushbuf_bo *
43 cli_kref_get(struct nouveau_client *client, struct nouveau_bo *bo)
45 struct nouveau_client_priv *pcli = nouveau_client(client);
46 struct drm_nouveau_gem_pushbuf_bo *kref = NULL;
47 if (pcli->kref_nr > bo->handle)
48 kref = pcli->kref[bo->handle].kref;
52 static inline struct nouveau_pushbuf *
53 cli_push_get(struct nouveau_client *client, struct nouveau_bo *bo)
55 struct nouveau_client_priv *pcli = nouveau_client(client);
56 struct nouveau_pushbuf *push = NULL;
57 if (pcli->kref_nr > bo->handle)
58 push = pcli->kref[bo->handle].push;
63 cli_kref_set(struct nouveau_client *client, struct nouveau_bo *bo,
64 struct drm_nouveau_gem_pushbuf_bo *kref,
65 struct nouveau_pushbuf *push)
67 struct nouveau_client_priv *pcli = nouveau_client(client);
68 if (pcli->kref_nr <= bo->handle) {
69 pcli->kref = realloc(pcli->kref,
70 sizeof(*pcli->kref) * bo->handle * 2);
71 while (pcli->kref_nr < bo->handle * 2) {
72 pcli->kref[pcli->kref_nr].kref = NULL;
73 pcli->kref[pcli->kref_nr].push = NULL;
77 pcli->kref[bo->handle].kref = kref;
78 pcli->kref[bo->handle].push = push;
81 struct nouveau_bo_priv {
82 struct nouveau_bo base;
83 struct nouveau_list head;
90 static inline struct nouveau_bo_priv *
91 nouveau_bo(struct nouveau_bo *bo)
93 return (struct nouveau_bo_priv *)bo;
96 struct nouveau_device_priv {
97 struct nouveau_device base;
100 struct nouveau_list bo_list;
104 int gart_limit_percent, vram_limit_percent;
107 static inline struct nouveau_device_priv *
108 nouveau_device(struct nouveau_device *dev)
110 return (struct nouveau_device_priv *)dev;
114 nouveau_device_open_existing(struct nouveau_device **, int, int, drm_context_t);
117 int abi16_chan_nv04(struct nouveau_object *);
118 int abi16_chan_nvc0(struct nouveau_object *);
119 int abi16_chan_nve0(struct nouveau_object *);
120 int abi16_engobj(struct nouveau_object *);
121 int abi16_ntfy(struct nouveau_object *);
122 void abi16_bo_info(struct nouveau_bo *, struct drm_nouveau_gem_info *);
123 int abi16_bo_init(struct nouveau_bo *, uint32_t alignment,
124 union nouveau_bo_config *);