1 #ifndef __NOUVEAU_LIBDRM_PRIVATE_H__
2 #define __NOUVEAU_LIBDRM_PRIVATE_H__
5 #include <xf86atomic.h>
7 #include "nouveau_drm.h"
12 uint32_t nouveau_debug;
13 #define dbg_on(lvl) (nouveau_debug & (1 << lvl))
14 #define dbg(lvl, fmt, args...) do { \
16 fprintf(stderr, "nouveau: "fmt, ##args); \
19 #define dbg_on(lvl) (0)
20 #define dbg(lvl, fmt, args...)
22 #define err(fmt, args...) fprintf(stderr, "nouveau: "fmt, ##args)
24 struct nouveau_client_kref {
25 struct drm_nouveau_gem_pushbuf_bo *kref;
26 struct nouveau_pushbuf *push;
29 struct nouveau_client_priv {
30 struct nouveau_client base;
31 struct nouveau_client_kref *kref;
35 static inline struct nouveau_client_priv *
36 nouveau_client(struct nouveau_client *client)
38 return (struct nouveau_client_priv *)client;
41 static inline struct drm_nouveau_gem_pushbuf_bo *
42 cli_kref_get(struct nouveau_client *client, struct nouveau_bo *bo)
44 struct nouveau_client_priv *pcli = nouveau_client(client);
45 struct drm_nouveau_gem_pushbuf_bo *kref = NULL;
46 if (pcli->kref_nr > bo->handle)
47 kref = pcli->kref[bo->handle].kref;
51 static inline struct nouveau_pushbuf *
52 cli_push_get(struct nouveau_client *client, struct nouveau_bo *bo)
54 struct nouveau_client_priv *pcli = nouveau_client(client);
55 struct nouveau_pushbuf *push = NULL;
56 if (pcli->kref_nr > bo->handle)
57 push = pcli->kref[bo->handle].push;
62 cli_kref_set(struct nouveau_client *client, struct nouveau_bo *bo,
63 struct drm_nouveau_gem_pushbuf_bo *kref,
64 struct nouveau_pushbuf *push)
66 struct nouveau_client_priv *pcli = nouveau_client(client);
67 if (pcli->kref_nr <= bo->handle) {
68 pcli->kref = realloc(pcli->kref,
69 sizeof(*pcli->kref) * bo->handle * 2);
70 while (pcli->kref_nr < bo->handle * 2) {
71 pcli->kref[pcli->kref_nr].kref = NULL;
72 pcli->kref[pcli->kref_nr].push = NULL;
76 pcli->kref[bo->handle].kref = kref;
77 pcli->kref[bo->handle].push = push;
80 struct nouveau_bo_priv {
81 struct nouveau_bo base;
82 struct nouveau_list head;
89 static inline struct nouveau_bo_priv *
90 nouveau_bo(struct nouveau_bo *bo)
92 return (struct nouveau_bo_priv *)bo;
95 struct nouveau_device_priv {
96 struct nouveau_device base;
99 struct nouveau_list bo_list;
103 int gart_limit_percent, vram_limit_percent;
106 static inline struct nouveau_device_priv *
107 nouveau_device(struct nouveau_device *dev)
109 return (struct nouveau_device_priv *)dev;
113 nouveau_device_open_existing(struct nouveau_device **, int, int, drm_context_t);
116 int abi16_chan_nv04(struct nouveau_object *);
117 int abi16_chan_nvc0(struct nouveau_object *);
118 int abi16_chan_nve0(struct nouveau_object *);
119 int abi16_engobj(struct nouveau_object *);
120 int abi16_ntfy(struct nouveau_object *);
121 void abi16_bo_info(struct nouveau_bo *, struct drm_nouveau_gem_info *);
122 int abi16_bo_init(struct nouveau_bo *, uint32_t alignment,
123 union nouveau_bo_config *);