Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 1 | #ifndef __NOUVEAU_DRMCLI_H__ |
| 2 | #define __NOUVEAU_DRMCLI_H__ |
| 3 | |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 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 |
Ben Skeggs | 27111a2 | 2014-08-10 04:10:31 +1000 | [diff] [blame] | 12 | #define DRIVER_MINOR 2 |
| 13 | #define DRIVER_PATCHLEVEL 0 |
Christoph Bumiller | 142c21b | 2013-03-27 22:25:52 +0100 | [diff] [blame] | 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). |
Mario Kleiner | 7820e5e | 2014-08-06 06:09:44 +0200 | [diff] [blame] | 24 | * 1.1.2: |
| 25 | * - fixes multiple bugs in flip completion events and timestamping |
Ben Skeggs | 27111a2 | 2014-08-10 04:10:31 +1000 | [diff] [blame] | 26 | * 1.2.0: |
| 27 | * - object api exposed to userspace |
| 28 | * - fermi,kepler,maxwell zbc |
Christoph Bumiller | 142c21b | 2013-03-27 22:25:52 +0100 | [diff] [blame] | 29 | */ |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 30 | |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 31 | #include <nvif/client.h> |
| 32 | #include <nvif/device.h> |
| 33 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 34 | #include <drmP.h> |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 35 | |
Linus Torvalds | 612a9aa | 2012-10-03 23:29:23 -0700 | [diff] [blame] | 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> |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 42 | |
Ben Skeggs | a4e610b | 2014-08-10 04:10:23 +1000 | [diff] [blame] | 43 | #include "uapi/drm/nouveau_drm.h" |
| 44 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 45 | struct nouveau_channel; |
Alexandre Courbot | 8ba9ff1 | 2014-06-26 14:33:32 +0900 | [diff] [blame] | 46 | struct platform_device; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 47 | |
| 48 | #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) |
| 49 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 50 | #include "nouveau_fence.h" |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 51 | #include "nouveau_bios.h" |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 52 | |
| 53 | struct nouveau_drm_tile { |
| 54 | struct nouveau_fence *fence; |
| 55 | bool used; |
| 56 | }; |
| 57 | |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 58 | enum nouveau_drm_object_route { |
| 59 | NVDRM_OBJECT_NVIF = 0, |
| 60 | NVDRM_OBJECT_USIF, |
| 61 | NVDRM_OBJECT_ABI16, |
| 62 | }; |
| 63 | |
| 64 | enum nouveau_drm_notify_route { |
| 65 | NVDRM_NOTIFY_NVIF = 0, |
| 66 | NVDRM_NOTIFY_USIF |
| 67 | }; |
| 68 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 69 | enum nouveau_drm_handle { |
Ben Skeggs | 26fdd78 | 2013-10-15 11:52:56 +1000 | [diff] [blame] | 70 | NVDRM_CLIENT = 0xffffffff, |
| 71 | NVDRM_DEVICE = 0xdddddddd, |
| 72 | NVDRM_CONTROL = 0xdddddddc, |
Ben Skeggs | 2332b31 | 2014-01-22 12:58:12 +1000 | [diff] [blame] | 73 | NVDRM_DISPLAY = 0xd1500000, |
Ben Skeggs | 26fdd78 | 2013-10-15 11:52:56 +1000 | [diff] [blame] | 74 | NVDRM_PUSH = 0xbbbb0000, /* |= client chid */ |
| 75 | NVDRM_CHAN = 0xcccc0000, /* |= client chid */ |
Ben Skeggs | 69a6146 | 2013-11-13 10:58:51 +1000 | [diff] [blame] | 76 | NVDRM_NVSW = 0x55550000, |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | struct nouveau_cli { |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 80 | struct nvif_client base; |
Ben Skeggs | 3ee6f5b | 2014-08-10 04:10:20 +1000 | [diff] [blame] | 81 | struct nouveau_vm *vm; /*XXX*/ |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 82 | struct list_head head; |
| 83 | struct mutex mutex; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 84 | void *abi16; |
Ben Skeggs | 27111a2 | 2014-08-10 04:10:31 +1000 | [diff] [blame] | 85 | struct list_head objects; |
| 86 | struct list_head notifys; |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 87 | }; |
| 88 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 89 | static inline struct nouveau_cli * |
| 90 | nouveau_cli(struct drm_file *fpriv) |
| 91 | { |
| 92 | return fpriv ? fpriv->driver_priv : NULL; |
| 93 | } |
| 94 | |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 95 | #include <nvif/object.h> |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 96 | #include <nvif/device.h> |
Ben Skeggs | db2bec1 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 97 | |
Dave Airlie | 5addcf0 | 2012-09-10 14:20:51 +1000 | [diff] [blame] | 98 | extern int nouveau_runtime_pm; |
| 99 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 100 | struct nouveau_drm { |
| 101 | struct nouveau_cli client; |
| 102 | struct drm_device *dev; |
| 103 | |
Ben Skeggs | 967e7bd | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 104 | struct nvif_device device; |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 105 | struct list_head clients; |
Ben Skeggs | cb75d97 | 2012-07-11 10:44:20 +1000 | [diff] [blame] | 106 | |
| 107 | struct { |
| 108 | enum { |
| 109 | UNKNOWN = 0, |
| 110 | DISABLE = 1, |
| 111 | ENABLED = 2 |
| 112 | } stat; |
| 113 | u32 base; |
| 114 | u32 size; |
| 115 | } agp; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 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 *); |
Ben Skeggs | 1bb3f6a | 2013-07-08 10:40:35 +1000 | [diff] [blame] | 126 | struct nouveau_channel *chan; |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 127 | struct nvif_object copy; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 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 */ |
Ben Skeggs | 4998104 | 2012-08-06 19:38:25 +1000 | [diff] [blame] | 141 | struct nouveau_channel *cechan; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 142 | struct nouveau_channel *channel; |
| 143 | struct nouveau_gpuobj *notify; |
| 144 | struct nouveau_fbdev *fbcon; |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 145 | struct nvif_object nvsw; |
| 146 | struct nvif_object ntfy; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 147 | |
| 148 | /* nv10-nv40 tiling regions */ |
| 149 | struct { |
| 150 | struct nouveau_drm_tile reg[15]; |
| 151 | spinlock_t lock; |
| 152 | } tile; |
Ben Skeggs | 51a3d34 | 2012-07-26 09:12:47 +1000 | [diff] [blame] | 153 | |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 154 | /* modesetting */ |
| 155 | struct nvbios vbios; |
| 156 | struct nouveau_display *display; |
Ben Skeggs | 51a3d34 | 2012-07-26 09:12:47 +1000 | [diff] [blame] | 157 | struct backlight_device *backlight; |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 158 | |
| 159 | /* power management */ |
Ben Skeggs | b9ed919 | 2013-10-15 09:44:02 +1000 | [diff] [blame] | 160 | struct nouveau_hwmon *hwmon; |
Ben Skeggs | 26fdd78 | 2013-10-15 11:52:56 +1000 | [diff] [blame] | 161 | struct nouveau_sysfs *sysfs; |
Dave Airlie | 5addcf0 | 2012-09-10 14:20:51 +1000 | [diff] [blame] | 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; |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 168 | }; |
| 169 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 170 | static inline struct nouveau_drm * |
| 171 | nouveau_drm(struct drm_device *dev) |
| 172 | { |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 173 | return dev->dev_private; |
| 174 | } |
| 175 | |
Dave Airlie | 2d8b9cc | 2012-11-02 11:04:28 +1000 | [diff] [blame] | 176 | int nouveau_pmops_suspend(struct device *); |
| 177 | int nouveau_pmops_resume(struct device *); |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 178 | |
Alexandre Courbot | 8ba9ff1 | 2014-06-26 14:33:32 +0900 | [diff] [blame] | 179 | #define nouveau_platform_device_create(p, u) \ |
| 180 | nouveau_platform_device_create_(p, sizeof(**u), (void **)u) |
| 181 | struct drm_device * |
| 182 | nouveau_platform_device_create_(struct platform_device *pdev, |
| 183 | int size, void **pobject); |
| 184 | void nouveau_drm_device_remove(struct drm_device *dev); |
| 185 | |
Ben Skeggs | fa2bade | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 186 | #define NV_PRINTK(l,c,f,a...) do { \ |
| 187 | struct nouveau_cli *_cli = (c); \ |
Ben Skeggs | 0ad7286 | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 188 | nv_##l(_cli->base.base.priv, f, ##a); \ |
Ben Skeggs | fa2bade | 2014-08-10 04:10:22 +1000 | [diff] [blame] | 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) |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 195 | |
Ben Skeggs | 9430738 | 2012-10-31 12:11:15 +1000 | [diff] [blame] | 196 | extern int nouveau_modeset; |
| 197 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 198 | #endif |