OSDN Git Service

android: set LOCAL_MODULE_TAGS to optional
[android-x86/external-libdrm.git] / nouveau / nouveau_private.h
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 #include "nouveau_reloc.h"
39
40 #define CALPB_BUFFERS 3
41
42 struct nouveau_pushbuf_priv {
43         uint32_t cal_suffix0;
44         uint32_t cal_suffix1;
45         struct nouveau_bo *buffer[CALPB_BUFFERS];
46         int current;
47         int current_offset;
48
49         unsigned *pushbuf;
50         unsigned size;
51
52         uint32_t *marker;
53         unsigned marker_offset;
54         unsigned marker_relocs;
55         unsigned marker_push;
56
57         struct drm_nouveau_gem_pushbuf_bo *buffers;
58         unsigned nr_buffers;
59         struct drm_nouveau_gem_pushbuf_reloc *relocs;
60         unsigned nr_relocs;
61         struct drm_nouveau_gem_pushbuf_push push[NOUVEAU_GEM_MAX_PUSH];
62         unsigned nr_push;
63 };
64 #define nouveau_pushbuf(n) ((struct nouveau_pushbuf_priv *)(n))
65
66 int
67 nouveau_pushbuf_init(struct nouveau_channel *, int buf_size);
68 void
69 nouveau_pushbuf_fini(struct nouveau_channel *);
70
71 struct nouveau_channel_priv {
72         struct nouveau_channel base;
73
74         struct drm_nouveau_channel_alloc drm;
75
76         struct nouveau_bo *notifier_bo;
77
78         struct nouveau_pushbuf_priv pb;
79 };
80 #define nouveau_channel(n) ((struct nouveau_channel_priv *)(n))
81
82 struct nouveau_grobj_priv {
83         struct nouveau_grobj base;
84 };
85 #define nouveau_grobj(n) ((struct nouveau_grobj_priv *)(n))
86
87 struct nouveau_notifier_priv {
88         struct nouveau_notifier base;
89
90         struct drm_nouveau_notifierobj_alloc drm;
91         volatile void *map;
92 };
93 #define nouveau_notifier(n) ((struct nouveau_notifier_priv *)(n))
94
95 struct nouveau_bo_priv {
96         struct nouveau_bo base;
97         int refcount;
98
99         /* Buffer configuration + usage hints */
100         unsigned flags;
101         unsigned size;
102         unsigned align;
103         int user;
104
105         /* Tracking */
106         struct drm_nouveau_gem_pushbuf_bo *pending;
107         struct nouveau_channel *pending_channel;
108         int pending_refcnt;
109         int write_marker;
110
111         /* Userspace object */
112         void *sysmem;
113
114         /* Kernel object */
115         uint32_t global_handle;
116         drm_handle_t handle;
117         uint64_t map_handle;
118         int map_refcnt;
119         void *map;
120
121         /* Last known information from kernel on buffer status */
122         uint64_t offset;
123         uint32_t domain;
124 };
125 #define nouveau_bo(n) ((struct nouveau_bo_priv *)(n))
126
127 int
128 nouveau_bo_init(struct nouveau_device *);
129
130 void
131 nouveau_bo_takedown(struct nouveau_device *);
132
133 struct drm_nouveau_gem_pushbuf_bo *
134 nouveau_bo_emit_buffer(struct nouveau_channel *, struct nouveau_bo *);
135
136 #endif