Home | History | Annotate | Download | only in nouveau
      1 /*
      2  * Copyright 2007 Nouveau Project
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the "Software"),
      6  * to deal in the Software without restriction, including without limitation
      7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8  * and/or sell copies of the Software, and to permit persons to whom the
      9  * Software is furnished to do so, subject to the following conditions:
     10  *
     11  * The above copyright notice and this permission notice shall be included in
     12  * all copies or substantial portions of the Software.
     13  *
     14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     17  * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
     18  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
     19  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     20  * SOFTWARE.
     21  */
     22 
     23 #ifndef __NOUVEAU_PRIVATE_H__
     24 #define __NOUVEAU_PRIVATE_H__
     25 
     26 #include <stdint.h>
     27 #include <xf86drm.h>
     28 #include <nouveau_drm.h>
     29 
     30 #include "nouveau_drmif.h"
     31 #include "nouveau_device.h"
     32 #include "nouveau_channel.h"
     33 #include "nouveau_grobj.h"
     34 #include "nouveau_notifier.h"
     35 #include "nouveau_bo.h"
     36 #include "nouveau_resource.h"
     37 #include "nouveau_pushbuf.h"
     38 
     39 #define CALPB_BUFFERS 4
     40 #define CALPB_BUFSZ   16384
     41 struct nouveau_pushbuf_priv {
     42 	struct nouveau_pushbuf base;
     43 
     44 	int use_cal;
     45 	uint32_t cal_suffix0;
     46 	uint32_t cal_suffix1;
     47 	struct nouveau_bo *buffer[CALPB_BUFFERS];
     48 	int current;
     49 	int current_offset;
     50 
     51 	unsigned *pushbuf;
     52 	unsigned  size;
     53 
     54 	struct drm_nouveau_gem_pushbuf_bo *buffers;
     55 	unsigned nr_buffers;
     56 	struct drm_nouveau_gem_pushbuf_reloc *relocs;
     57 	unsigned nr_relocs;
     58 };
     59 #define nouveau_pushbuf(n) ((struct nouveau_pushbuf_priv *)(n))
     60 
     61 int
     62 nouveau_pushbuf_init(struct nouveau_channel *);
     63 
     64 struct nouveau_channel_priv {
     65 	struct nouveau_channel base;
     66 
     67 	struct drm_nouveau_channel_alloc drm;
     68 
     69 	struct nouveau_bo *notifier_bo;
     70 
     71 	struct nouveau_pushbuf_priv pb;
     72 };
     73 #define nouveau_channel(n) ((struct nouveau_channel_priv *)(n))
     74 
     75 struct nouveau_grobj_priv {
     76 	struct nouveau_grobj base;
     77 };
     78 #define nouveau_grobj(n) ((struct nouveau_grobj_priv *)(n))
     79 
     80 struct nouveau_notifier_priv {
     81 	struct nouveau_notifier base;
     82 
     83 	struct drm_nouveau_notifierobj_alloc drm;
     84 	volatile void *map;
     85 };
     86 #define nouveau_notifier(n) ((struct nouveau_notifier_priv *)(n))
     87 
     88 struct nouveau_bo_priv {
     89 	struct nouveau_bo base;
     90 	int refcount;
     91 
     92 	/* Buffer configuration + usage hints */
     93 	unsigned flags;
     94 	unsigned size;
     95 	unsigned align;
     96 	int user;
     97 
     98 	/* Tracking */
     99 	struct drm_nouveau_gem_pushbuf_bo *pending;
    100 	struct nouveau_channel *pending_channel;
    101 	int write_marker;
    102 
    103 	/* Userspace object */
    104 	void *sysmem;
    105 
    106 	/* Kernel object */
    107 	uint32_t global_handle;
    108 	drm_handle_t handle;
    109 	uint64_t map_handle;
    110 	void *map;
    111 
    112 	/* Last known information from kernel on buffer status */
    113 	int pinned;
    114 	uint64_t offset;
    115 	uint32_t domain;
    116 };
    117 #define nouveau_bo(n) ((struct nouveau_bo_priv *)(n))
    118 
    119 int
    120 nouveau_bo_init(struct nouveau_device *);
    121 
    122 void
    123 nouveau_bo_takedown(struct nouveau_device *);
    124 
    125 struct drm_nouveau_gem_pushbuf_bo *
    126 nouveau_bo_emit_buffer(struct nouveau_channel *, struct nouveau_bo *);
    127 
    128 #endif
    129