blob: b02b02452c854c5fdab9ddd985dc12ce0f12e7af [file] [log] [blame]
Ben Skeggs94580292012-07-06 12:14:00 +10001#ifndef __NOUVEAU_DRMCLI_H__
2#define __NOUVEAU_DRMCLI_H__
3
Ben Skeggs77145f12012-07-31 16:16:21 +10004#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
Ben Skeggs27111a22014-08-10 04:10:31 +100012#define DRIVER_MINOR 2
13#define DRIVER_PATCHLEVEL 0
Christoph Bumiller142c21b2013-03-27 22:25:52 +010014
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).
Mario Kleiner7820e5e2014-08-06 06:09:44 +020024 * 1.1.2:
25 * - fixes multiple bugs in flip completion events and timestamping
Ben Skeggs27111a22014-08-10 04:10:31 +100026 * 1.2.0:
27 * - object api exposed to userspace
28 * - fermi,kepler,maxwell zbc
Christoph Bumiller142c21b2013-03-27 22:25:52 +010029 */
Ben Skeggs77145f12012-07-31 16:16:21 +100030
Ben Skeggs0ad72862014-08-10 04:10:22 +100031#include <nvif/client.h>
32#include <nvif/device.h>
33
Ben Skeggs94580292012-07-06 12:14:00 +100034#include <drmP.h>
Ben Skeggs94580292012-07-06 12:14:00 +100035
Linus Torvalds612a9aa2012-10-03 23:29:23 -070036#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>
Ben Skeggsebb945a2012-07-20 08:17:34 +100042
Ben Skeggsa4e610b2014-08-10 04:10:23 +100043#include "uapi/drm/nouveau_drm.h"
44
Ben Skeggsebb945a2012-07-20 08:17:34 +100045struct nouveau_channel;
Alexandre Courbot8ba9ff12014-06-26 14:33:32 +090046struct platform_device;
Ben Skeggsebb945a2012-07-20 08:17:34 +100047
48#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
49
Ben Skeggsebb945a2012-07-20 08:17:34 +100050#include "nouveau_fence.h"
Ben Skeggs77145f12012-07-31 16:16:21 +100051#include "nouveau_bios.h"
Ben Skeggsebb945a2012-07-20 08:17:34 +100052
53struct nouveau_drm_tile {
54 struct nouveau_fence *fence;
55 bool used;
56};
57
Ben Skeggs0ad72862014-08-10 04:10:22 +100058enum 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
Ben Skeggs94580292012-07-06 12:14:00 +100069enum nouveau_drm_handle {
Ben Skeggs26fdd782013-10-15 11:52:56 +100070 NVDRM_CLIENT = 0xffffffff,
71 NVDRM_DEVICE = 0xdddddddd,
72 NVDRM_CONTROL = 0xdddddddc,
Ben Skeggs2332b312014-01-22 12:58:12 +100073 NVDRM_DISPLAY = 0xd1500000,
Ben Skeggs26fdd782013-10-15 11:52:56 +100074 NVDRM_PUSH = 0xbbbb0000, /* |= client chid */
75 NVDRM_CHAN = 0xcccc0000, /* |= client chid */
Ben Skeggs69a61462013-11-13 10:58:51 +100076 NVDRM_NVSW = 0x55550000,
Ben Skeggs94580292012-07-06 12:14:00 +100077};
78
79struct nouveau_cli {
Ben Skeggs0ad72862014-08-10 04:10:22 +100080 struct nvif_client base;
Ben Skeggs3ee6f5b2014-08-10 04:10:20 +100081 struct nouveau_vm *vm; /*XXX*/
Ben Skeggs94580292012-07-06 12:14:00 +100082 struct list_head head;
83 struct mutex mutex;
Ben Skeggsebb945a2012-07-20 08:17:34 +100084 void *abi16;
Ben Skeggs27111a22014-08-10 04:10:31 +100085 struct list_head objects;
86 struct list_head notifys;
Ben Skeggs94580292012-07-06 12:14:00 +100087};
88
Ben Skeggsebb945a2012-07-20 08:17:34 +100089static inline struct nouveau_cli *
90nouveau_cli(struct drm_file *fpriv)
91{
92 return fpriv ? fpriv->driver_priv : NULL;
93}
94
Ben Skeggs967e7bd2014-08-10 04:10:22 +100095#include <nvif/object.h>
Ben Skeggs967e7bd2014-08-10 04:10:22 +100096#include <nvif/device.h>
Ben Skeggsdb2bec12014-08-10 04:10:22 +100097
Dave Airlie5addcf02012-09-10 14:20:51 +100098extern int nouveau_runtime_pm;
99
Ben Skeggs94580292012-07-06 12:14:00 +1000100struct nouveau_drm {
101 struct nouveau_cli client;
102 struct drm_device *dev;
103
Ben Skeggs967e7bd2014-08-10 04:10:22 +1000104 struct nvif_device device;
Ben Skeggs94580292012-07-06 12:14:00 +1000105 struct list_head clients;
Ben Skeggscb75d972012-07-11 10:44:20 +1000106
107 struct {
108 enum {
109 UNKNOWN = 0,
110 DISABLE = 1,
111 ENABLED = 2
112 } stat;
113 u32 base;
114 u32 size;
115 } agp;
Ben Skeggsebb945a2012-07-20 08:17:34 +1000116
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 *);
Ben Skeggs1bb3f6a2013-07-08 10:40:35 +1000126 struct nouveau_channel *chan;
Ben Skeggs0ad72862014-08-10 04:10:22 +1000127 struct nvif_object copy;
Ben Skeggsebb945a2012-07-20 08:17:34 +1000128 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 */
Ben Skeggs49981042012-08-06 19:38:25 +1000141 struct nouveau_channel *cechan;
Ben Skeggsebb945a2012-07-20 08:17:34 +1000142 struct nouveau_channel *channel;
143 struct nouveau_gpuobj *notify;
144 struct nouveau_fbdev *fbcon;
Ben Skeggs0ad72862014-08-10 04:10:22 +1000145 struct nvif_object nvsw;
146 struct nvif_object ntfy;
Ben Skeggsebb945a2012-07-20 08:17:34 +1000147
148 /* nv10-nv40 tiling regions */
149 struct {
150 struct nouveau_drm_tile reg[15];
151 spinlock_t lock;
152 } tile;
Ben Skeggs51a3d342012-07-26 09:12:47 +1000153
Ben Skeggs77145f12012-07-31 16:16:21 +1000154 /* modesetting */
155 struct nvbios vbios;
156 struct nouveau_display *display;
Ben Skeggs51a3d342012-07-26 09:12:47 +1000157 struct backlight_device *backlight;
Ben Skeggs77145f12012-07-31 16:16:21 +1000158
159 /* power management */
Ben Skeggsb9ed9192013-10-15 09:44:02 +1000160 struct nouveau_hwmon *hwmon;
Ben Skeggs26fdd782013-10-15 11:52:56 +1000161 struct nouveau_sysfs *sysfs;
Dave Airlie5addcf02012-09-10 14:20:51 +1000162
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;
Ben Skeggs94580292012-07-06 12:14:00 +1000168};
169
Ben Skeggsebb945a2012-07-20 08:17:34 +1000170static inline struct nouveau_drm *
171nouveau_drm(struct drm_device *dev)
172{
Ben Skeggs77145f12012-07-31 16:16:21 +1000173 return dev->dev_private;
174}
175
Dave Airlie2d8b9cc2012-11-02 11:04:28 +1000176int nouveau_pmops_suspend(struct device *);
177int nouveau_pmops_resume(struct device *);
Ben Skeggs94580292012-07-06 12:14:00 +1000178
Alexandre Courbot8ba9ff12014-06-26 14:33:32 +0900179#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
Ben Skeggsfa2bade2014-08-10 04:10:22 +1000186#define NV_PRINTK(l,c,f,a...) do { \
187 struct nouveau_cli *_cli = (c); \
Ben Skeggs0ad72862014-08-10 04:10:22 +1000188 nv_##l(_cli->base.base.priv, f, ##a); \
Ben Skeggsfa2bade2014-08-10 04:10:22 +1000189} 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)
Ben Skeggs94580292012-07-06 12:14:00 +1000195
Ben Skeggs94307382012-10-31 12:11:15 +1000196extern int nouveau_modeset;
197
Ben Skeggs94580292012-07-06 12:14:00 +1000198#endif