Back to index

libdrm  2.4.37
Classes | Defines | Functions
nouveau.h File Reference
#include <stdint.h>
#include <stdbool.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  nouveau_list
struct  nouveau_object
struct  nouveau_fifo
struct  nv04_fifo
struct  nvc0_fifo
struct  nv04_notify
struct  nouveau_device
struct  nouveau_client
union  nouveau_bo_config
struct  nouveau_bo
struct  nouveau_bufref
struct  nouveau_bufctx
struct  nouveau_pushbuf
struct  nouveau_pushbuf_refn
struct  nouveau_bo_config.nv04
struct  nouveau_bo_config.nv50
struct  nouveau_bo_config.nvc0

Defines

#define NOUVEAU_DEVICE_CLASS   0x80000000
#define NOUVEAU_FIFO_CHANNEL_CLASS   0x80000001
#define NOUVEAU_NOTIFIER_CLASS   0x80000002
#define NOUVEAU_PARENT_CLASS   0xffffffff
#define NV04_BO_16BPP   0x00000001
#define NV04_BO_32BPP   0x00000002
#define NV04_BO_ZETA   0x00000004
#define NOUVEAU_BO_VRAM   0x00000001
#define NOUVEAU_BO_GART   0x00000002
#define NOUVEAU_BO_APER   (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)
#define NOUVEAU_BO_RD   0x00000100
#define NOUVEAU_BO_WR   0x00000200
#define NOUVEAU_BO_RDWR   (NOUVEAU_BO_RD | NOUVEAU_BO_WR)
#define NOUVEAU_BO_NOBLOCK   0x00000400
#define NOUVEAU_BO_LOW   0x00001000
#define NOUVEAU_BO_HIGH   0x00002000
#define NOUVEAU_BO_OR   0x00004000
#define NOUVEAU_BO_MAP   0x80000000
#define NOUVEAU_BO_CONTIG   0x40000000
#define NOUVEAU_BO_NOSNOOP   0x20000000

Functions

int nouveau_object_new (struct nouveau_object *parent, uint64_t handle, uint32_t oclass, void *data, uint32_t length, struct nouveau_object **)
void nouveau_object_del (struct nouveau_object **)
void * nouveau_object_find (struct nouveau_object *, uint32_t parent_class)
int nouveau_device_wrap (int fd, int close, struct nouveau_device **)
int nouveau_device_open (const char *busid, struct nouveau_device **)
void nouveau_device_del (struct nouveau_device **)
int nouveau_getparam (struct nouveau_device *, uint64_t param, uint64_t *value)
int nouveau_setparam (struct nouveau_device *, uint64_t param, uint64_t value)
int nouveau_client_new (struct nouveau_device *, struct nouveau_client **)
void nouveau_client_del (struct nouveau_client **)
int nouveau_bo_new (struct nouveau_device *, uint32_t flags, uint32_t align, uint64_t size, union nouveau_bo_config *, struct nouveau_bo **)
int nouveau_bo_wrap (struct nouveau_device *, uint32_t handle, struct nouveau_bo **)
int nouveau_bo_name_ref (struct nouveau_device *dev, uint32_t name, struct nouveau_bo **)
int nouveau_bo_name_get (struct nouveau_bo *, uint32_t *name)
void nouveau_bo_ref (struct nouveau_bo *, struct nouveau_bo **)
int nouveau_bo_map (struct nouveau_bo *, uint32_t access, struct nouveau_client *)
int nouveau_bo_wait (struct nouveau_bo *, uint32_t access, struct nouveau_client *)
int nouveau_bufctx_new (struct nouveau_client *, int bins, struct nouveau_bufctx **)
void nouveau_bufctx_del (struct nouveau_bufctx **)
struct nouveau_bufrefnouveau_bufctx_refn (struct nouveau_bufctx *, int bin, struct nouveau_bo *, uint32_t flags)
struct nouveau_bufrefnouveau_bufctx_mthd (struct nouveau_bufctx *, int bin, uint32_t packet, struct nouveau_bo *, uint64_t data, uint32_t flags, uint32_t vor, uint32_t tor)
void nouveau_bufctx_reset (struct nouveau_bufctx *, int bin)
int nouveau_pushbuf_new (struct nouveau_client *, struct nouveau_object *channel, int nr, uint32_t size, bool immediate, struct nouveau_pushbuf **)
void nouveau_pushbuf_del (struct nouveau_pushbuf **)
int nouveau_pushbuf_space (struct nouveau_pushbuf *, uint32_t dwords, uint32_t relocs, uint32_t pushes)
void nouveau_pushbuf_data (struct nouveau_pushbuf *, struct nouveau_bo *, uint64_t offset, uint64_t length)
int nouveau_pushbuf_refn (struct nouveau_pushbuf *, struct nouveau_pushbuf_refn *, int nr)
void nouveau_pushbuf_reloc (struct nouveau_pushbuf *, struct nouveau_bo *, uint32_t data, uint32_t flags, uint32_t vor, uint32_t tor)
int nouveau_pushbuf_validate (struct nouveau_pushbuf *)
uint32_t nouveau_pushbuf_refd (struct nouveau_pushbuf *, struct nouveau_bo *)
int nouveau_pushbuf_kick (struct nouveau_pushbuf *, struct nouveau_object *channel)
struct nouveau_bufctxnouveau_pushbuf_bufctx (struct nouveau_pushbuf *, struct nouveau_bufctx *)

Class Documentation

struct nouveau_list

Definition at line 12 of file nouveau.h.

Collaboration diagram for nouveau_list:
Class Members
struct nouveau_list * next
struct nouveau_list * prev
struct nouveau_object

Definition at line 17 of file nouveau.h.

Collaboration diagram for nouveau_object:
Class Members
void * data
uint64_t handle
uint32_t length
uint32_t oclass
struct nouveau_object * parent
struct nouveau_fifo

Definition at line 25 of file nouveau.h.

Collaboration diagram for nouveau_fifo:
Class Members
uint32_t channel
struct nouveau_object * object
uint32_t pushbuf
uint64_t unused1
struct nv04_fifo

Definition at line 32 of file nouveau.h.

Class Members
uint32_t gart
uint32_t notify
uint32_t vram
struct nvc0_fifo

Definition at line 39 of file nouveau.h.

Class Members
uint32_t notify
struct nv04_notify

Definition at line 44 of file nouveau.h.

Collaboration diagram for nv04_notify:
Class Members
uint32_t length
struct nouveau_object * object
uint32_t offset
struct nouveau_device

Definition at line 56 of file nouveau.h.

Class Members
uint32_t chipset
uint32_t drm_version
int fd
uint64_t gart_limit
uint64_t gart_size
uint32_t lib_version
uint64_t vram_limit
uint64_t vram_size
struct nouveau_client

Definition at line 74 of file nouveau.h.

Collaboration diagram for nouveau_client:
Class Members
struct nouveau_device * device
int id
union nouveau_bo_config

Definition at line 82 of file nouveau.h.

Class Members
uint32_t data
struct nouveau_bo_config nv04
struct nouveau_bo_config nv50
struct nouveau_bo_config nvc0
struct nouveau_bo

Definition at line 44 of file nouveau.c.

Collaboration diagram for nouveau_bo:
Class Members
struct nouveau_device * device
uint32_t flags
uint32_t handle
void * map
unsigned map_count
uint64_t map_handle
uint64_t offset
uint64_t size
struct nouveau_bufref

Definition at line 139 of file nouveau.h.

Collaboration diagram for nouveau_bufref:
Class Members
struct nouveau_bo * bo
uint32_t data
uint32_t flags
uint32_t packet
void * priv
uint32_t priv_data
uint32_t tor
uint32_t vor
struct nouveau_bufctx

Definition at line 151 of file nouveau.h.

Collaboration diagram for nouveau_bufctx:
Class Members
struct nouveau_client * client
int relocs
struct nouveau_pushbuf_refn

Definition at line 184 of file nouveau.h.

Collaboration diagram for nouveau_pushbuf_refn:
Class Members
struct nouveau_bo * bo
uint32_t flags
struct nouveau_bo_config.nv04

Definition at line 83 of file nouveau.h.

Class Members
uint32_t surf_flags
uint32_t surf_pitch
struct nouveau_bo_config.nv50

Definition at line 90 of file nouveau.h.

Class Members
uint32_t memtype
uint32_t tile_mode
struct nouveau_bo_config.nvc0

Definition at line 94 of file nouveau.h.

Class Members
uint32_t memtype
uint32_t tile_mode

Define Documentation

Definition at line 103 of file nouveau.h.

#define NOUVEAU_BO_CONTIG   0x40000000

Definition at line 112 of file nouveau.h.

#define NOUVEAU_BO_GART   0x00000002

Definition at line 102 of file nouveau.h.

#define NOUVEAU_BO_HIGH   0x00002000

Definition at line 109 of file nouveau.h.

#define NOUVEAU_BO_LOW   0x00001000

Definition at line 108 of file nouveau.h.

#define NOUVEAU_BO_MAP   0x80000000

Definition at line 111 of file nouveau.h.

#define NOUVEAU_BO_NOBLOCK   0x00000400

Definition at line 107 of file nouveau.h.

#define NOUVEAU_BO_NOSNOOP   0x20000000

Definition at line 113 of file nouveau.h.

#define NOUVEAU_BO_OR   0x00004000

Definition at line 110 of file nouveau.h.

#define NOUVEAU_BO_RD   0x00000100

Definition at line 104 of file nouveau.h.

Definition at line 106 of file nouveau.h.

#define NOUVEAU_BO_VRAM   0x00000001

Definition at line 101 of file nouveau.h.

#define NOUVEAU_BO_WR   0x00000200

Definition at line 105 of file nouveau.h.

#define NOUVEAU_DEVICE_CLASS   0x80000000

Definition at line 7 of file nouveau.h.

#define NOUVEAU_FIFO_CHANNEL_CLASS   0x80000001

Definition at line 8 of file nouveau.h.

#define NOUVEAU_NOTIFIER_CLASS   0x80000002

Definition at line 9 of file nouveau.h.

#define NOUVEAU_PARENT_CLASS   0xffffffff

Definition at line 10 of file nouveau.h.

#define NV04_BO_16BPP   0x00000001

Definition at line 84 of file nouveau.h.

#define NV04_BO_32BPP   0x00000002

Definition at line 85 of file nouveau.h.

#define NV04_BO_ZETA   0x00000004

Definition at line 86 of file nouveau.h.


Function Documentation

int nouveau_bo_map ( struct nouveau_bo ,
uint32_t  access,
struct nouveau_client  
)

Definition at line 479 of file nouveau.c.

{
       struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
       if (bo->map == NULL) {
              bo->map = mmap(0, bo->size, PROT_READ | PROT_WRITE,
                            MAP_SHARED, bo->device->fd, nvbo->map_handle);
              if (bo->map == MAP_FAILED) {
                     bo->map = NULL;
                     return -errno;
              }
       }
       return nouveau_bo_wait(bo, access, client);
}

Here is the call graph for this function:

int nouveau_bo_name_get ( struct nouveau_bo ,
uint32_t *  name 
)

Definition at line 416 of file nouveau.c.

{
       struct drm_gem_flink req = { .handle = bo->handle };
       struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
       if (!nvbo->name) {
              int ret = drmIoctl(bo->device->fd, DRM_IOCTL_GEM_FLINK, &req);
              if (ret)
                     return ret;
              nvbo->name = req.name;
       }
       *name = nvbo->name;
       return 0;
}

Here is the call graph for this function:

int nouveau_bo_name_ref ( struct nouveau_device dev,
uint32_t  name,
struct nouveau_bo **   
)

Definition at line 390 of file nouveau.c.

{
       struct nouveau_device_priv *nvdev = nouveau_device(dev);
       struct nouveau_bo_priv *nvbo;
       struct drm_gem_open req = { .name = name };
       int ret;

       DRMLISTFOREACHENTRY(nvbo, &nvdev->bo_list, head) {
              if (nvbo->name == name) {
                     *pbo = NULL;
                     nouveau_bo_ref(&nvbo->base, pbo);
                     return 0;
              }
       }

       ret = drmIoctl(dev->fd, DRM_IOCTL_GEM_OPEN, &req);
       if (ret == 0) {
              ret = nouveau_bo_wrap(dev, req.handle, pbo);
              nouveau_bo((*pbo))->name = name;
       }

       return ret;
}

Here is the call graph for this function:

int nouveau_bo_new ( struct nouveau_device ,
uint32_t  flags,
uint32_t  align,
uint64_t  size,
union nouveau_bo_config ,
struct nouveau_bo **   
)

Definition at line 326 of file nouveau.c.

{
       struct nouveau_device_priv *nvdev = nouveau_device(dev);
       struct nouveau_bo_priv *nvbo = calloc(1, sizeof(*nvbo));
       struct nouveau_bo *bo = &nvbo->base;
       int ret;

       if (!nvbo)
              return -ENOMEM;
       atomic_set(&nvbo->refcnt, 1);
       bo->device = dev;
       bo->flags = flags;
       bo->size = size;

       ret = abi16_bo_init(bo, align, config);
       if (ret) {
              free(nvbo);
              return ret;
       }

       DRMLISTADD(&nvbo->head, &nvdev->bo_list);

       *pbo = bo;
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nouveau_bo_ref ( struct nouveau_bo ,
struct nouveau_bo **   
)

Definition at line 431 of file nouveau.c.

{
       struct nouveau_bo *ref = *pref;
       if (bo) {
              atomic_inc(&nouveau_bo(bo)->refcnt);
       }
       if (ref) {
              if (atomic_dec_and_test(&nouveau_bo(ref)->refcnt))
                     nouveau_bo_del(ref);
       }
       *pref = bo;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nouveau_bo_wait ( struct nouveau_bo ,
uint32_t  access,
struct nouveau_client  
)

Definition at line 445 of file nouveau.c.

{
       struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
       struct drm_nouveau_gem_cpu_prep req;
       struct nouveau_pushbuf *push;
       int ret = 0;

       if (!(access & NOUVEAU_BO_RDWR))
              return 0;

       push = cli_push_get(client, bo);
       if (push && push->channel)
              nouveau_pushbuf_kick(push, push->channel);

       if (!nvbo->name && !(nvbo->access & NOUVEAU_BO_WR) &&
                        !(      access & NOUVEAU_BO_WR))
              return 0;

       req.handle = bo->handle;
       req.flags = 0;
       if (access & NOUVEAU_BO_WR)
              req.flags |= NOUVEAU_GEM_CPU_PREP_WRITE;
       if (access & NOUVEAU_BO_NOBLOCK)
              req.flags |= NOUVEAU_GEM_CPU_PREP_NOWAIT;

       ret = drmCommandWrite(bo->device->fd, DRM_NOUVEAU_GEM_CPU_PREP,
                           &req, sizeof(req));
       if (ret == 0)
              nvbo->access = 0;
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nouveau_bo_wrap ( struct nouveau_device ,
uint32_t  handle,
struct nouveau_bo **   
)

Definition at line 355 of file nouveau.c.

{
       struct nouveau_device_priv *nvdev = nouveau_device(dev);
       struct drm_nouveau_gem_info req = { .handle = handle };
       struct nouveau_bo_priv *nvbo;
       int ret;

       DRMLISTFOREACHENTRY(nvbo, &nvdev->bo_list, head) {
              if (nvbo->base.handle == handle) {
                     *pbo = NULL;
                     nouveau_bo_ref(&nvbo->base, pbo);
                     return 0;
              }
       }

       ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_GEM_INFO,
                              &req, sizeof(req));
       if (ret)
              return ret;

       nvbo = calloc(1, sizeof(*nvbo));
       if (nvbo) {
              atomic_set(&nvbo->refcnt, 1);
              nvbo->base.device = dev;
              abi16_bo_info(&nvbo->base, &req);
              DRMLISTADD(&nvbo->head, &nvdev->bo_list);
              *pbo = &nvbo->base;
              return 0;
       }

       return -ENOMEM;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nouveau_bufctx_del ( struct nouveau_bufctx **  )

Definition at line 92 of file bufctx.c.

{
       struct nouveau_bufctx_priv *pctx = nouveau_bufctx(*pbctx);
       struct nouveau_bufref_priv *pref;
       if (pctx) {
              while (pctx->nr_bins--)
                     nouveau_bufctx_reset(&pctx->base, pctx->nr_bins);
              while ((pref = pctx->free)) {
                     pctx->free = pref->next;
                     free(pref);
              }
              free(pctx);
              *pbctx = NULL;
       }
}

Here is the call graph for this function:

struct nouveau_bufref* nouveau_bufctx_mthd ( struct nouveau_bufctx ,
int  bin,
uint32_t  packet,
struct nouveau_bo ,
uint64_t  data,
uint32_t  flags,
uint32_t  vor,
uint32_t  tor 
) [read]

Definition at line 154 of file bufctx.c.

{
       struct nouveau_bufctx_priv *pctx = nouveau_bufctx(bctx);
       struct nouveau_bufbin_priv *pbin = &pctx->bins[bin];
       struct nouveau_bufref *bref = nouveau_bufctx_refn(bctx, bin, bo, flags);
       if (bref) {
              bref->packet = packet;
              bref->data = data;
              bref->vor = vor;
              bref->tor = tor;
              pbin->relocs++;
              bctx->relocs++;
       }
       return bref;
}

Here is the call graph for this function:

int nouveau_bufctx_new ( struct nouveau_client ,
int  bins,
struct nouveau_bufctx **   
)

Definition at line 72 of file bufctx.c.

{
       struct nouveau_bufctx_priv *priv;

       priv = calloc(1, sizeof(*priv) + sizeof(priv->bins[0]) * bins);
       if (priv) {
              DRMINITLISTHEAD(&priv->base.head);
              DRMINITLISTHEAD(&priv->base.pending);
              DRMINITLISTHEAD(&priv->base.current);
              priv->base.client = client;
              priv->nr_bins = bins;
              *pbctx = &priv->base;
              return 0;
       }

       return -ENOMEM;
}
struct nouveau_bufref* nouveau_bufctx_refn ( struct nouveau_bufctx ,
int  bin,
struct nouveau_bo ,
uint32_t  flags 
) [read]

Definition at line 127 of file bufctx.c.

{
       struct nouveau_bufctx_priv *pctx = nouveau_bufctx(bctx);
       struct nouveau_bufbin_priv *pbin = &pctx->bins[bin];
       struct nouveau_bufref_priv *pref = pctx->free;

       if (!pref)
              pref = malloc(sizeof(*pref));
       else
              pctx->free = pref->next;

       if (pref) {
              pref->base.bo = bo;
              pref->base.flags = flags;
              pref->base.packet = 0;

              DRMLISTADDTAIL(&pref->base.thead, &bctx->pending);
              pref->bufctx = bctx;
              pref->next = pbin->list;
              pbin->list = pref;
       }

       return &pref->base;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nouveau_bufctx_reset ( struct nouveau_bufctx ,
int  bin 
)

Definition at line 109 of file bufctx.c.

{
       struct nouveau_bufctx_priv *pctx = nouveau_bufctx(bctx);
       struct nouveau_bufbin_priv *pbin = &pctx->bins[bin];
       struct nouveau_bufref_priv *pref;

       while ((pref = pbin->list)) {
              DRMLISTDELINIT(&pref->base.thead);
              pbin->list = pref->next;
              pref->next = pctx->free;
              pctx->free = pref;
       }

       bctx->relocs -= pbin->relocs;
       pbin->relocs  = 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nouveau_client_del ( struct nouveau_client **  )

Definition at line 206 of file nouveau.c.

{
       struct nouveau_client_priv *pcli = nouveau_client(*pclient);
       struct nouveau_device_priv *nvdev;
       if (pcli) {
              int id = pcli->base.id;
              nvdev = nouveau_device(pcli->base.device);
              nvdev->client[id / 32] &= ~(1 << (id % 32));
              free(pcli->kref);
              free(pcli);
       }
}

Here is the call graph for this function:

int nouveau_client_new ( struct nouveau_device ,
struct nouveau_client **   
)

Definition at line 172 of file nouveau.c.

{
       struct nouveau_device_priv *nvdev = nouveau_device(dev);
       struct nouveau_client_priv *pcli;
       int id = 0, i, ret = -ENOMEM;
       uint32_t *clients;

       for (i = 0; i < nvdev->nr_client; i++) {
              id = ffs(nvdev->client[i]) - 1;
              if (id >= 0)
                     goto out;
       }

       clients = realloc(nvdev->client, sizeof(uint32_t) * (i + 1));
       if (!clients)
              return ret;
       nvdev->client = clients;
       nvdev->client[i] = 0;
       nvdev->nr_client++;

out:
       pcli = calloc(1, sizeof(*pcli));
       if (pcli) {
              nvdev->client[i] |= (1 << id);
              pcli->base.device = dev;
              pcli->base.id = (i * 32) + id;
              ret = 0;
       }

       *pclient = &pcli->base;
       return ret;
}

Here is the call graph for this function:

void nouveau_device_del ( struct nouveau_device **  )

Definition at line 142 of file nouveau.c.

{
       struct nouveau_device_priv *nvdev = nouveau_device(*pdev);
       if (nvdev) {
              if (nvdev->close)
                     drmClose(nvdev->base.fd);
              free(nvdev->client);
              free(nvdev);
              *pdev = NULL;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nouveau_device_open ( const char *  busid,
struct nouveau_device **   
)

Definition at line 130 of file nouveau.c.

{
       int ret = -ENODEV, fd = drmOpen("nouveau", busid);
       if (fd >= 0) {
              ret = nouveau_device_wrap(fd, 1, pdev);
              if (ret)
                     drmClose(fd);
       }
       return ret;
}

Here is the call graph for this function:

int nouveau_device_wrap ( int  fd,
int  close,
struct nouveau_device **   
)

Definition at line 72 of file nouveau.c.

{
       struct nouveau_device_priv *nvdev = calloc(1, sizeof(*nvdev));
       struct nouveau_device *dev = &nvdev->base;
       uint64_t chipset, vram, gart, bousage;
       drmVersionPtr ver;
       int ret;

#ifdef DEBUG
       debug_init(getenv("NOUVEAU_LIBDRM_DEBUG"));
#endif

       if (!nvdev)
              return -ENOMEM;
       nvdev->base.fd = fd;

       ver = drmGetVersion(fd);
       if (ver) dev->drm_version = (ver->version_major << 24) |
                                (ver->version_minor << 8) |
                                 ver->version_patchlevel;
       drmFreeVersion(ver);

       if ( dev->drm_version != 0x00000010 &&
           (dev->drm_version <  0x01000000 ||
            dev->drm_version >= 0x02000000)) {
              nouveau_device_del(&dev);
              return -EINVAL;
       }

       ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_CHIPSET_ID, &chipset);
       if (ret == 0)
       ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_FB_SIZE, &vram);
       if (ret == 0)
       ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_AGP_SIZE, &gart);
       if (ret) {
              nouveau_device_del(&dev);
              return ret;
       }

       ret = nouveau_getparam(dev, NOUVEAU_GETPARAM_HAS_BO_USAGE, &bousage);
       if (ret == 0)
              nvdev->have_bo_usage = (bousage != 0);

       nvdev->close = close;
       DRMINITLISTHEAD(&nvdev->bo_list);
       nvdev->base.object.oclass = NOUVEAU_DEVICE_CLASS;
       nvdev->base.lib_version = 0x01000000;
       nvdev->base.chipset = chipset;
       nvdev->base.vram_size = vram;
       nvdev->base.gart_size = gart;
       nvdev->base.vram_limit = (nvdev->base.vram_size * 80) / 100;
       nvdev->base.gart_limit = (nvdev->base.gart_size * 80) / 100;

       *pdev = &nvdev->base;
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nouveau_getparam ( struct nouveau_device ,
uint64_t  param,
uint64_t *  value 
)

Definition at line 155 of file nouveau.c.

{
       struct drm_nouveau_getparam r = { param, 0 };
       int fd = dev->fd, ret =
              drmCommandWriteRead(fd, DRM_NOUVEAU_GETPARAM, &r, sizeof(r));
       *value = r.value;
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nouveau_object_del ( struct nouveau_object **  )

Definition at line 279 of file nouveau.c.

{
       struct nouveau_object *obj = *pobj;
       struct nouveau_device *dev;
       if (obj) {
              dev = nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
              if (obj->oclass == NOUVEAU_FIFO_CHANNEL_CLASS) {
                     struct drm_nouveau_channel_free req;
                     req.channel = obj->handle;
                     drmCommandWrite(dev->fd, DRM_NOUVEAU_CHANNEL_FREE,
                                   &req, sizeof(req));
              } else {
                     struct drm_nouveau_gpuobj_free req;
                     req.channel = obj->parent->handle;
                     req.handle  = obj->handle;
                     drmCommandWrite(dev->fd, DRM_NOUVEAU_GPUOBJ_FREE,
                                   &req, sizeof(req));
              }
       }
       free(obj);
       *pobj = NULL;
}

Here is the call graph for this function:

void* nouveau_object_find ( struct nouveau_object ,
uint32_t  parent_class 
)

Definition at line 303 of file nouveau.c.

{
       while (obj && obj->oclass != pclass) {
              obj = obj->parent;
              if (pclass == NOUVEAU_PARENT_CLASS)
                     break;
       }
       return obj;
}

Here is the caller graph for this function:

int nouveau_object_new ( struct nouveau_object parent,
uint64_t  handle,
uint32_t  oclass,
void *  data,
uint32_t  length,
struct nouveau_object **   
)

Definition at line 220 of file nouveau.c.

{
       struct nouveau_device *dev;
       struct nouveau_object *obj;
       int ret = -EINVAL;

       if (length == 0)
              length = sizeof(struct nouveau_object *);
       obj = malloc(sizeof(*obj) + length);
       obj->parent = parent;
       obj->handle = handle;
       obj->oclass = oclass;
       obj->length = length;
       obj->data = obj + 1;
       if (data)
              memcpy(obj->data, data, length);
       *(struct nouveau_object **)obj->data = obj;

       dev = nouveau_object_find(obj, NOUVEAU_DEVICE_CLASS);
       switch (parent->oclass) {
       case NOUVEAU_DEVICE_CLASS:
              switch (obj->oclass) {
              case NOUVEAU_FIFO_CHANNEL_CLASS:
              {
                     if (dev->chipset < 0xc0)
                            ret = abi16_chan_nv04(obj);
                     else
                            ret = abi16_chan_nvc0(obj);
              }
                     break;
              default:
                     break;
              }
              break;
       case NOUVEAU_FIFO_CHANNEL_CLASS:
              switch (obj->oclass) {
              case NOUVEAU_NOTIFIER_CLASS:
                     ret = abi16_ntfy(obj);
                     break;
              default:
                     ret = abi16_engobj(obj);
                     break;
              }
       default:
              break;
       }

       if (ret) {
              free(obj);
              return ret;
       }

       *pobj = obj;
       return 0;
}

Here is the call graph for this function:

struct nouveau_bufctx* nouveau_pushbuf_bufctx ( struct nouveau_pushbuf ,
struct nouveau_bufctx  
) [read]

Definition at line 628 of file pushbuf.c.

{
       struct nouveau_bufctx *prev = push->bufctx;
       push->bufctx = ctx;
       return prev;
}
void nouveau_pushbuf_data ( struct nouveau_pushbuf ,
struct nouveau_bo ,
uint64_t  offset,
uint64_t  length 
)

Definition at line 700 of file pushbuf.c.

{
       struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(push);
       struct nouveau_pushbuf_krec *krec = nvpb->krec;
       struct drm_nouveau_gem_pushbuf_push *kpsh;
       struct drm_nouveau_gem_pushbuf_bo *kref;

       if (bo != nvpb->bo && nvpb->bgn != push->cur) {
              if (nvpb->suffix0 || nvpb->suffix1) {
                     *push->cur++ = nvpb->suffix0;
                     *push->cur++ = nvpb->suffix1;
              }

              nouveau_pushbuf_data(push, nvpb->bo,
                                 (nvpb->bgn - nvpb->ptr) * 4,
                                 (push->cur - nvpb->bgn) * 4);
              nvpb->bgn = push->cur;
       }

       if (bo) {
              kref = cli_kref_get(push->client, bo);
              kpsh = &krec->push[krec->nr_push++];
              kpsh->bo_index = kref - krec->buffer;
              kpsh->offset   = offset;
              kpsh->length   = length;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nouveau_pushbuf_del ( struct nouveau_pushbuf **  )

Definition at line 602 of file pushbuf.c.

{
       struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(*ppush);
       if (nvpb) {
              struct drm_nouveau_gem_pushbuf_bo *kref;
              struct nouveau_pushbuf_krec *krec;
              while ((krec = nvpb->list)) {
                     kref = krec->buffer;
                     while (krec->nr_buffer--) {
                            unsigned long priv = kref++->user_priv;
                            struct nouveau_bo *bo = (void *)priv;
                            cli_kref_set(nvpb->base.client, bo, NULL, NULL);
                            nouveau_bo_ref(NULL, &bo);
                     }
                     nvpb->list = krec->next;
                     free(krec);
              }
              while (nvpb->bo_nr--)
                     nouveau_bo_ref(NULL, &nvpb->bos[nvpb->bo_nr]);
              nouveau_bo_ref(NULL, &nvpb->bo);
              free(nvpb);
       }
       *ppush = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nouveau_pushbuf_kick ( struct nouveau_pushbuf ,
struct nouveau_object channel 
)

Definition at line 767 of file pushbuf.c.

{
       if (!push->channel)
              return pushbuf_submit(push, chan);
       pushbuf_flush(push);
       return pushbuf_validate(push, false);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int nouveau_pushbuf_new ( struct nouveau_client ,
struct nouveau_object channel,
int  nr,
uint32_t  size,
bool  immediate,
struct nouveau_pushbuf **   
)

Definition at line 531 of file pushbuf.c.

{
       struct nouveau_device *dev = client->device;
       struct nouveau_fifo *fifo = chan->data;
       struct nouveau_pushbuf_priv *nvpb;
       struct nouveau_pushbuf *push;
       struct drm_nouveau_gem_pushbuf req = {};
       int ret;

       if (chan->oclass != NOUVEAU_FIFO_CHANNEL_CLASS)
              return -EINVAL;

       /* nop pushbuf call, to get the current "return to main" sequence
        * we need to append to the pushbuf on early chipsets
        */
       req.channel = fifo->channel;
       req.nr_push = 0;
       ret = drmCommandWriteRead(dev->fd, DRM_NOUVEAU_GEM_PUSHBUF,
                              &req, sizeof(req));
       if (ret)
              return ret;

       nvpb = calloc(1, sizeof(*nvpb) + nr * sizeof(*nvpb->bos));
       if (!nvpb)
              return -ENOMEM;

#ifndef SIMULATE
       nvpb->suffix0 = req.suffix0;
       nvpb->suffix1 = req.suffix1;
#else
       nvpb->suffix0 = 0xffffffff;
       nvpb->suffix1 = 0xffffffff;
#endif
       nvpb->krec = calloc(1, sizeof(*nvpb->krec));
       nvpb->list = nvpb->krec;
       if (!nvpb->krec) {
              free(nvpb);
              return -ENOMEM;
       }

       push = &nvpb->base;
       push->client = client;
       push->channel = immediate ? chan : NULL;
       push->flags = NOUVEAU_BO_RD;
       if (fifo->pushbuf & NOUVEAU_GEM_DOMAIN_VRAM) {
              push->flags |= NOUVEAU_BO_VRAM;
              nvpb->type   = NOUVEAU_BO_VRAM;
       }
       if (fifo->pushbuf & NOUVEAU_GEM_DOMAIN_GART) {
              push->flags |= NOUVEAU_BO_GART;
              nvpb->type   = NOUVEAU_BO_GART;
       }
       nvpb->type |= NOUVEAU_BO_MAP;

       for (nvpb->bo_nr = 0; nvpb->bo_nr < nr; nvpb->bo_nr++) {
              ret = nouveau_bo_new(client->device, nvpb->type, 0, size,
                                 NULL, &nvpb->bos[nvpb->bo_nr]);
              if (ret) {
                     nouveau_pushbuf_del(&push);
                     return ret;
              }
       }

       DRMINITLISTHEAD(&nvpb->bctx_list);
       *ppush = push;
       return 0;
}

Here is the call graph for this function:

uint32_t nouveau_pushbuf_refd ( struct nouveau_pushbuf ,
struct nouveau_bo  
)

Definition at line 750 of file pushbuf.c.

{
       struct drm_nouveau_gem_pushbuf_bo *kref;
       uint32_t flags = 0;

       if (cli_push_get(push->client, bo) == push) {
              kref = cli_kref_get(push->client, bo);
              if (kref->read_domains)
                     flags |= NOUVEAU_BO_RD;
              if (kref->write_domains)
                     flags |= NOUVEAU_BO_WR;
       }

       return flags;
}

Here is the call graph for this function:

int nouveau_pushbuf_refn ( struct nouveau_pushbuf ,
struct nouveau_pushbuf_refn ,
int  nr 
)

Definition at line 730 of file pushbuf.c.

{
       return pushbuf_refn(push, true, refs, nr);
}

Here is the call graph for this function:

void nouveau_pushbuf_reloc ( struct nouveau_pushbuf ,
struct nouveau_bo ,
uint32_t  data,
uint32_t  flags,
uint32_t  vor,
uint32_t  tor 
)

Definition at line 737 of file pushbuf.c.

{
       *push->cur++ = pushbuf_krel(push, bo, data, flags, vor, tor);
}

Here is the call graph for this function:

int nouveau_pushbuf_space ( struct nouveau_pushbuf ,
uint32_t  dwords,
uint32_t  relocs,
uint32_t  pushes 
)

Definition at line 636 of file pushbuf.c.

{
       struct nouveau_pushbuf_priv *nvpb = nouveau_pushbuf(push);
       struct nouveau_pushbuf_krec *krec = nvpb->krec;
       struct nouveau_client *client = push->client;
       struct nouveau_bo *bo = NULL;
       bool flushed = false;
       int ret = 0;

       /* switch to next buffer if insufficient space in the current one */
       if (push->cur + dwords >= push->end) {
              if (nvpb->bo_next < nvpb->bo_nr) {
                     nouveau_bo_ref(nvpb->bos[nvpb->bo_next++], &bo);
                     if (nvpb->bo_next == nvpb->bo_nr && push->channel)
                            nvpb->bo_next = 0;
              } else {
                     ret = nouveau_bo_new(client->device, nvpb->type, 0,
                                        nvpb->bos[0]->size, NULL, &bo);
                     if (ret)
                            return ret;
              }
       }

       /* make sure there's always enough space to queue up the pending
        * data in the pushbuf proper
        */
       pushes++;

       /* need to flush if we've run out of space on an immediate pushbuf,
        * if the new buffer won't fit, or if the kernel push/reloc limits
        * have been hit
        */
       if ((bo && ( push->channel ||
                  !pushbuf_kref(push, bo, push->flags))) ||
           krec->nr_reloc + relocs >= NOUVEAU_GEM_MAX_RELOCS ||
           krec->nr_push + pushes >= NOUVEAU_GEM_MAX_PUSH) {
              if (nvpb->bo && krec->nr_buffer)
                     pushbuf_flush(push);
              flushed = true;
       }

       /* if necessary, switch to new buffer */
       if (bo) {
              ret = nouveau_bo_map(bo, NOUVEAU_BO_WR, push->client);
              if (ret)
                     return ret;

              nouveau_pushbuf_data(push, NULL, 0, 0);
              nouveau_bo_ref(bo, &nvpb->bo);
              nouveau_bo_ref(NULL, &bo);

              nvpb->bgn = nvpb->bo->map;
              nvpb->ptr = nvpb->bgn;
              push->cur = nvpb->bgn;
              push->end = push->cur + (nvpb->bo->size / 4);
              push->end -= 2 + push->rsvd_kick; /* space for suffix */
       }

       pushbuf_kref(push, nvpb->bo, push->flags);
       return flushed ? pushbuf_validate(push, false) : 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 744 of file pushbuf.c.

{
       return pushbuf_validate(push, true);
}

Here is the call graph for this function:

int nouveau_setparam ( struct nouveau_device ,
uint64_t  param,
uint64_t  value 
)

Definition at line 165 of file nouveau.c.

{
       struct drm_nouveau_setparam r = { param, value };
       return drmCommandWrite(dev->fd, DRM_NOUVEAU_SETPARAM, &r, sizeof(r));
}

Here is the call graph for this function: