nouveau_drm.h revision 27111a23d01c1dba3180c998629004ab4c9ac985
1#ifndef __NOUVEAU_DRMCLI_H__
2#define __NOUVEAU_DRMCLI_H__
3
4#define DRIVER_AUTHOR		"Nouveau Project"
5#define DRIVER_EMAIL		"nouveau@lists.freedesktop.org"
6
7#define DRIVER_NAME		"nouveau"
8#define DRIVER_DESC		"nVidia Riva/TNT/GeForce/Quadro/Tesla"
9#define DRIVER_DATE		"20120801"
10
11#define DRIVER_MAJOR		1
12#define DRIVER_MINOR		2
13#define DRIVER_PATCHLEVEL	0
14
15/*
16 * 1.1.1:
17 * 	- added support for tiled system memory buffer objects
18 *      - added support for NOUVEAU_GETPARAM_GRAPH_UNITS on [nvc0,nve0].
19 *      - added support for compressed memory storage types on [nvc0,nve0].
20 *      - added support for software methods 0x600,0x644,0x6ac on nvc0
21 *        to control registers on the MPs to enable performance counters,
22 *        and to control the warp error enable mask (OpenGL requires out of
23 *        bounds access to local memory to be silently ignored / return 0).
24 * 1.1.2:
25 *      - fixes multiple bugs in flip completion events and timestamping
26 * 1.2.0:
27 * 	- object api exposed to userspace
28 * 	- fermi,kepler,maxwell zbc
29 */
30
31#include <nvif/client.h>
32#include <nvif/device.h>
33
34#include <drmP.h>
35
36#include <drm/ttm/ttm_bo_api.h>
37#include <drm/ttm/ttm_bo_driver.h>
38#include <drm/ttm/ttm_placement.h>
39#include <drm/ttm/ttm_memory.h>
40#include <drm/ttm/ttm_module.h>
41#include <drm/ttm/ttm_page_alloc.h>
42
43#include "uapi/drm/nouveau_drm.h"
44
45struct nouveau_channel;
46struct platform_device;
47
48#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
49
50#include "nouveau_fence.h"
51#include "nouveau_bios.h"
52
53struct nouveau_drm_tile {
54	struct nouveau_fence *fence;
55	bool used;
56};
57
58enum nouveau_drm_object_route {
59	NVDRM_OBJECT_NVIF = 0,
60	NVDRM_OBJECT_USIF,
61	NVDRM_OBJECT_ABI16,
62};
63
64enum nouveau_drm_notify_route {
65	NVDRM_NOTIFY_NVIF = 0,
66	NVDRM_NOTIFY_USIF
67};
68
69enum nouveau_drm_handle {
70	NVDRM_CLIENT  = 0xffffffff,
71	NVDRM_DEVICE  = 0xdddddddd,
72	NVDRM_CONTROL = 0xdddddddc,
73	NVDRM_DISPLAY = 0xd1500000,
74	NVDRM_PUSH    = 0xbbbb0000, /* |= client chid */
75	NVDRM_CHAN    = 0xcccc0000, /* |= client chid */
76	NVDRM_NVSW    = 0x55550000,
77};
78
79struct nouveau_cli {
80	struct nvif_client base;
81	struct nouveau_vm *vm; /*XXX*/
82	struct list_head head;
83	struct mutex mutex;
84	void *abi16;
85	struct list_head objects;
86	struct list_head notifys;
87};
88
89static inline struct nouveau_cli *
90nouveau_cli(struct drm_file *fpriv)
91{
92	return fpriv ? fpriv->driver_priv : NULL;
93}
94
95#include <nvif/object.h>
96#include <nvif/device.h>
97
98extern int nouveau_runtime_pm;
99
100struct nouveau_drm {
101	struct nouveau_cli client;
102	struct drm_device *dev;
103
104	struct nvif_device device;
105	struct list_head clients;
106
107	struct {
108		enum {
109			UNKNOWN = 0,
110			DISABLE = 1,
111			ENABLED = 2
112		} stat;
113		u32 base;
114		u32 size;
115	} agp;
116
117	/* TTM interface support */
118	struct {
119		struct drm_global_reference mem_global_ref;
120		struct ttm_bo_global_ref bo_global_ref;
121		struct ttm_bo_device bdev;
122		atomic_t validate_sequence;
123		int (*move)(struct nouveau_channel *,
124			    struct ttm_buffer_object *,
125			    struct ttm_mem_reg *, struct ttm_mem_reg *);
126		struct nouveau_channel *chan;
127		struct nvif_object copy;
128		int mtrr;
129	} ttm;
130
131	/* GEM interface support */
132	struct {
133		u64 vram_available;
134		u64 gart_available;
135	} gem;
136
137	/* synchronisation */
138	void *fence;
139
140	/* context for accelerated drm-internal operations */
141	struct nouveau_channel *cechan;
142	struct nouveau_channel *channel;
143	struct nouveau_gpuobj *notify;
144	struct nouveau_fbdev *fbcon;
145	struct nvif_object nvsw;
146	struct nvif_object ntfy;
147
148	/* nv10-nv40 tiling regions */
149	struct {
150		struct nouveau_drm_tile reg[15];
151		spinlock_t lock;
152	} tile;
153
154	/* modesetting */
155	struct nvbios vbios;
156	struct nouveau_display *display;
157	struct backlight_device *backlight;
158
159	/* power management */
160	struct nouveau_hwmon *hwmon;
161	struct nouveau_sysfs *sysfs;
162
163	/* display power reference */
164	bool have_disp_power_ref;
165
166	struct dev_pm_domain vga_pm_domain;
167	struct pci_dev *hdmi_device;
168};
169
170static inline struct nouveau_drm *
171nouveau_drm(struct drm_device *dev)
172{
173	return dev->dev_private;
174}
175
176int nouveau_pmops_suspend(struct device *);
177int nouveau_pmops_resume(struct device *);
178
179#define nouveau_platform_device_create(p, u)                                   \
180	nouveau_platform_device_create_(p, sizeof(**u), (void **)u)
181struct drm_device *
182nouveau_platform_device_create_(struct platform_device *pdev,
183				int size, void **pobject);
184void nouveau_drm_device_remove(struct drm_device *dev);
185
186#define NV_PRINTK(l,c,f,a...) do {                                             \
187	struct nouveau_cli *_cli = (c);                                        \
188	nv_##l(_cli->base.base.priv, f, ##a);                                  \
189} while(0)
190#define NV_FATAL(drm,f,a...) NV_PRINTK(fatal, &(drm)->client, f, ##a)
191#define NV_ERROR(drm,f,a...) NV_PRINTK(error, &(drm)->client, f, ##a)
192#define NV_WARN(drm,f,a...) NV_PRINTK(warn, &(drm)->client, f, ##a)
193#define NV_INFO(drm,f,a...) NV_PRINTK(info, &(drm)->client, f, ##a)
194#define NV_DEBUG(drm,f,a...) NV_PRINTK(debug, &(drm)->client, f, ##a)
195
196extern int nouveau_modeset;
197
198#endif
199