Back to index

libdrm  2.4.37
private.h
Go to the documentation of this file.
00001 #ifndef __NOUVEAU_LIBDRM_PRIVATE_H__
00002 #define __NOUVEAU_LIBDRM_PRIVATE_H__
00003 
00004 #include <xf86drm.h>
00005 #include <xf86atomic.h>
00006 #include "nouveau_drm.h"
00007 
00008 #include "nouveau.h"
00009 
00010 #ifdef DEBUG
00011 uint32_t nouveau_debug;
00012 #define dbg_on(lvl) (nouveau_debug & (1 << lvl))
00013 #define dbg(lvl, fmt, args...) do {                                            \
00014        if (dbg_on((lvl)))                                                     \
00015               fprintf(stderr, "nouveau: "fmt, ##args);                       \
00016 } while(0)
00017 #else
00018 #define dbg_on(lvl) (0)
00019 #define dbg(lvl, fmt, args...)
00020 #endif
00021 #define err(fmt, args...) fprintf(stderr, "nouveau: "fmt, ##args)
00022 
00023 struct nouveau_client_kref {
00024        struct drm_nouveau_gem_pushbuf_bo *kref;
00025        struct nouveau_pushbuf *push;
00026 };
00027 
00028 struct nouveau_client_priv {
00029        struct nouveau_client base;
00030        struct nouveau_client_kref *kref;
00031        unsigned kref_nr;
00032 };
00033 
00034 static inline struct nouveau_client_priv *
00035 nouveau_client(struct nouveau_client *client)
00036 {
00037        return (struct nouveau_client_priv *)client;
00038 }
00039 
00040 static inline struct drm_nouveau_gem_pushbuf_bo *
00041 cli_kref_get(struct nouveau_client *client, struct nouveau_bo *bo)
00042 {
00043        struct nouveau_client_priv *pcli = nouveau_client(client);
00044        struct drm_nouveau_gem_pushbuf_bo *kref = NULL;
00045        if (pcli->kref_nr > bo->handle)
00046               kref = pcli->kref[bo->handle].kref;
00047        return kref;
00048 }
00049 
00050 static inline struct nouveau_pushbuf *
00051 cli_push_get(struct nouveau_client *client, struct nouveau_bo *bo)
00052 {
00053        struct nouveau_client_priv *pcli = nouveau_client(client);
00054        struct nouveau_pushbuf *push = NULL;
00055        if (pcli->kref_nr > bo->handle)
00056               push = pcli->kref[bo->handle].push;
00057        return push;
00058 }
00059 
00060 static inline void
00061 cli_kref_set(struct nouveau_client *client, struct nouveau_bo *bo,
00062             struct drm_nouveau_gem_pushbuf_bo *kref,
00063             struct nouveau_pushbuf *push)
00064 {
00065        struct nouveau_client_priv *pcli = nouveau_client(client);
00066        if (pcli->kref_nr <= bo->handle) {
00067               pcli->kref = realloc(pcli->kref,
00068                                  sizeof(*pcli->kref) * bo->handle * 2);
00069               while (pcli->kref_nr < bo->handle * 2) {
00070                      pcli->kref[pcli->kref_nr].kref = NULL;
00071                      pcli->kref[pcli->kref_nr].push = NULL;
00072                      pcli->kref_nr++;
00073               }
00074        }
00075        pcli->kref[bo->handle].kref = kref;
00076        pcli->kref[bo->handle].push = push;
00077 }
00078 
00079 struct nouveau_bo_priv {
00080        struct nouveau_bo base;
00081        struct nouveau_list head;
00082        atomic_t refcnt;
00083        uint64_t map_handle;
00084        uint32_t name;
00085        uint32_t access;
00086 };
00087 
00088 static inline struct nouveau_bo_priv *
00089 nouveau_bo(struct nouveau_bo *bo)
00090 {
00091        return (struct nouveau_bo_priv *)bo;
00092 }
00093 
00094 struct nouveau_device_priv {
00095        struct nouveau_device base;
00096        int close;
00097        atomic_t lock;
00098        struct nouveau_list bo_list;
00099        uint32_t *client;
00100        int nr_client;
00101        bool have_bo_usage;
00102 };
00103 
00104 static inline struct nouveau_device_priv *
00105 nouveau_device(struct nouveau_device *dev)
00106 {
00107        return (struct nouveau_device_priv *)dev;
00108 }
00109 
00110 int
00111 nouveau_device_open_existing(struct nouveau_device **, int, int, drm_context_t);
00112 
00113 /* abi16.c */
00114 int  abi16_chan_nv04(struct nouveau_object *);
00115 int  abi16_chan_nvc0(struct nouveau_object *);
00116 int  abi16_engobj(struct nouveau_object *);
00117 int  abi16_ntfy(struct nouveau_object *);
00118 void abi16_bo_info(struct nouveau_bo *, struct drm_nouveau_gem_info *);
00119 int  abi16_bo_init(struct nouveau_bo *, uint32_t alignment,
00120                  union nouveau_bo_config *);
00121 
00122 #endif