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 |
| 12 | #define DRIVER_MINOR 1 |
| 13 | #define DRIVER_PATCHLEVEL 0 |
| 14 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 15 | #include <core/client.h> |
| 16 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 17 | #include <subdev/vm.h> |
| 18 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 19 | #include <drmP.h> |
| 20 | #include <drm/nouveau_drm.h> |
| 21 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 22 | #include "ttm/ttm_bo_api.h" |
| 23 | #include "ttm/ttm_bo_driver.h" |
| 24 | #include "ttm/ttm_placement.h" |
| 25 | #include "ttm/ttm_memory.h" |
| 26 | #include "ttm/ttm_module.h" |
| 27 | #include "ttm/ttm_page_alloc.h" |
| 28 | |
| 29 | struct nouveau_channel; |
| 30 | |
| 31 | #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) |
| 32 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 33 | #include "nouveau_fence.h" |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 34 | #include "nouveau_bios.h" |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 35 | |
| 36 | struct nouveau_drm_tile { |
| 37 | struct nouveau_fence *fence; |
| 38 | bool used; |
| 39 | }; |
| 40 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 41 | enum nouveau_drm_handle { |
| 42 | NVDRM_CLIENT = 0xffffffff, |
| 43 | NVDRM_DEVICE = 0xdddddddd, |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 44 | NVDRM_PUSH = 0xbbbb0000, /* |= client chid */ |
| 45 | NVDRM_CHAN = 0xcccc0000, /* |= client chid */ |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | struct nouveau_cli { |
| 49 | struct nouveau_client base; |
| 50 | struct list_head head; |
| 51 | struct mutex mutex; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 52 | void *abi16; |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 53 | }; |
| 54 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 55 | static inline struct nouveau_cli * |
| 56 | nouveau_cli(struct drm_file *fpriv) |
| 57 | { |
| 58 | return fpriv ? fpriv->driver_priv : NULL; |
| 59 | } |
| 60 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 61 | struct nouveau_drm { |
| 62 | struct nouveau_cli client; |
| 63 | struct drm_device *dev; |
| 64 | |
| 65 | struct nouveau_object *device; |
| 66 | struct list_head clients; |
Ben Skeggs | cb75d97 | 2012-07-11 10:44:20 +1000 | [diff] [blame] | 67 | |
| 68 | struct { |
| 69 | enum { |
| 70 | UNKNOWN = 0, |
| 71 | DISABLE = 1, |
| 72 | ENABLED = 2 |
| 73 | } stat; |
| 74 | u32 base; |
| 75 | u32 size; |
| 76 | } agp; |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 77 | |
| 78 | /* TTM interface support */ |
| 79 | struct { |
| 80 | struct drm_global_reference mem_global_ref; |
| 81 | struct ttm_bo_global_ref bo_global_ref; |
| 82 | struct ttm_bo_device bdev; |
| 83 | atomic_t validate_sequence; |
| 84 | int (*move)(struct nouveau_channel *, |
| 85 | struct ttm_buffer_object *, |
| 86 | struct ttm_mem_reg *, struct ttm_mem_reg *); |
| 87 | int mtrr; |
| 88 | } ttm; |
| 89 | |
| 90 | /* GEM interface support */ |
| 91 | struct { |
| 92 | u64 vram_available; |
| 93 | u64 gart_available; |
| 94 | } gem; |
| 95 | |
| 96 | /* synchronisation */ |
| 97 | void *fence; |
| 98 | |
| 99 | /* context for accelerated drm-internal operations */ |
| 100 | struct nouveau_channel *channel; |
| 101 | struct nouveau_gpuobj *notify; |
| 102 | struct nouveau_fbdev *fbcon; |
| 103 | |
| 104 | /* nv10-nv40 tiling regions */ |
| 105 | struct { |
| 106 | struct nouveau_drm_tile reg[15]; |
| 107 | spinlock_t lock; |
| 108 | } tile; |
Ben Skeggs | 51a3d34 | 2012-07-26 09:12:47 +1000 | [diff] [blame] | 109 | |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 110 | /* modesetting */ |
| 111 | struct nvbios vbios; |
| 112 | struct nouveau_display *display; |
Ben Skeggs | 51a3d34 | 2012-07-26 09:12:47 +1000 | [diff] [blame] | 113 | struct backlight_device *backlight; |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 114 | |
| 115 | /* power management */ |
| 116 | struct nouveau_pm *pm; |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 117 | }; |
| 118 | |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 119 | static inline struct nouveau_drm * |
| 120 | nouveau_drm(struct drm_device *dev) |
| 121 | { |
Ben Skeggs | 77145f1 | 2012-07-31 16:16:21 +1000 | [diff] [blame] | 122 | return dev->dev_private; |
| 123 | } |
| 124 | |
| 125 | static inline struct nouveau_device * |
| 126 | nouveau_dev(struct drm_device *dev) |
| 127 | { |
| 128 | return nv_device(nouveau_drm(dev)->device); |
Ben Skeggs | ebb945a | 2012-07-20 08:17:34 +1000 | [diff] [blame] | 129 | } |
| 130 | |
Ben Skeggs | 9458029 | 2012-07-06 12:14:00 +1000 | [diff] [blame] | 131 | int nouveau_drm_suspend(struct pci_dev *, pm_message_t); |
| 132 | int nouveau_drm_resume(struct pci_dev *); |
| 133 | |
| 134 | #define NV_PRINTK(level, code, drm, fmt, args...) \ |
| 135 | printk(level "nouveau " code "[ DRM][%s] " fmt, \ |
| 136 | pci_name((drm)->dev->pdev), ##args) |
| 137 | #define NV_FATAL(drm, fmt, args...) \ |
| 138 | NV_PRINTK(KERN_CRIT, "!", (drm), fmt, ##args) |
| 139 | #define NV_ERROR(drm, fmt, args...) \ |
| 140 | NV_PRINTK(KERN_ERR, "E", (drm), fmt, ##args) |
| 141 | #define NV_WARN(drm, fmt, args...) \ |
| 142 | NV_PRINTK(KERN_WARNING, "W", (drm), fmt, ##args) |
| 143 | #define NV_INFO(drm, fmt, args...) \ |
| 144 | NV_PRINTK(KERN_INFO, " ", (drm), fmt, ##args) |
| 145 | #define NV_DEBUG(drm, fmt, args...) do { \ |
| 146 | if (drm_debug & DRM_UT_DRIVER) \ |
| 147 | NV_PRINTK(KERN_DEBUG, "D", drm, fmt, ##args); \ |
| 148 | } while (0) |
| 149 | |
| 150 | #endif |