Merge branch 'drop-time' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek...
[cascardo/linux.git] / drivers / gpu / drm / nouveau / nouveau_drm.h
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            1
13 #define DRIVER_PATCHLEVEL       1
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  */
25
26 #include <core/client.h>
27 #include <core/event.h>
28
29 #include <subdev/vm.h>
30
31 #include <drmP.h>
32 #include <drm/nouveau_drm.h>
33
34 #include <drm/ttm/ttm_bo_api.h>
35 #include <drm/ttm/ttm_bo_driver.h>
36 #include <drm/ttm/ttm_placement.h>
37 #include <drm/ttm/ttm_memory.h>
38 #include <drm/ttm/ttm_module.h>
39 #include <drm/ttm/ttm_page_alloc.h>
40
41 struct nouveau_channel;
42
43 #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
44
45 #include "nouveau_fence.h"
46 #include "nouveau_bios.h"
47
48 struct nouveau_drm_tile {
49         struct nouveau_fence *fence;
50         bool used;
51 };
52
53 enum nouveau_drm_handle {
54         NVDRM_CLIENT  = 0xffffffff,
55         NVDRM_DEVICE  = 0xdddddddd,
56         NVDRM_CONTROL = 0xdddddddc,
57         NVDRM_DISPLAY = 0xd1500000,
58         NVDRM_PUSH    = 0xbbbb0000, /* |= client chid */
59         NVDRM_CHAN    = 0xcccc0000, /* |= client chid */
60         NVDRM_NVSW    = 0x55550000,
61 };
62
63 struct nouveau_cli {
64         struct nouveau_client base;
65         struct list_head head;
66         struct mutex mutex;
67         void *abi16;
68 };
69
70 static inline struct nouveau_cli *
71 nouveau_cli(struct drm_file *fpriv)
72 {
73         return fpriv ? fpriv->driver_priv : NULL;
74 }
75
76 extern int nouveau_runtime_pm;
77
78 struct nouveau_drm {
79         struct nouveau_cli client;
80         struct drm_device *dev;
81
82         struct nouveau_object *device;
83         struct list_head clients;
84
85         struct {
86                 enum {
87                         UNKNOWN = 0,
88                         DISABLE = 1,
89                         ENABLED = 2
90                 } stat;
91                 u32 base;
92                 u32 size;
93         } agp;
94
95         /* TTM interface support */
96         struct {
97                 struct drm_global_reference mem_global_ref;
98                 struct ttm_bo_global_ref bo_global_ref;
99                 struct ttm_bo_device bdev;
100                 atomic_t validate_sequence;
101                 int (*move)(struct nouveau_channel *,
102                             struct ttm_buffer_object *,
103                             struct ttm_mem_reg *, struct ttm_mem_reg *);
104                 struct nouveau_channel *chan;
105                 int mtrr;
106         } ttm;
107
108         /* GEM interface support */
109         struct {
110                 u64 vram_available;
111                 u64 gart_available;
112         } gem;
113
114         /* synchronisation */
115         void *fence;
116
117         /* context for accelerated drm-internal operations */
118         struct nouveau_channel *cechan;
119         struct nouveau_channel *channel;
120         struct nouveau_gpuobj *notify;
121         struct nouveau_fbdev *fbcon;
122
123         /* nv10-nv40 tiling regions */
124         struct {
125                 struct nouveau_drm_tile reg[15];
126                 spinlock_t lock;
127         } tile;
128
129         /* modesetting */
130         struct nvbios vbios;
131         struct nouveau_display *display;
132         struct backlight_device *backlight;
133
134         /* power management */
135         struct nouveau_hwmon *hwmon;
136         struct nouveau_sysfs *sysfs;
137
138         /* display power reference */
139         bool have_disp_power_ref;
140
141         struct dev_pm_domain vga_pm_domain;
142         struct pci_dev *hdmi_device;
143 };
144
145 static inline struct nouveau_drm *
146 nouveau_drm(struct drm_device *dev)
147 {
148         return dev->dev_private;
149 }
150
151 static inline struct nouveau_device *
152 nouveau_dev(struct drm_device *dev)
153 {
154         return nv_device(nouveau_drm(dev)->device);
155 }
156
157 int nouveau_pmops_suspend(struct device *);
158 int nouveau_pmops_resume(struct device *);
159
160 #define NV_FATAL(cli, fmt, args...) nv_fatal((cli), fmt, ##args)
161 #define NV_ERROR(cli, fmt, args...) nv_error((cli), fmt, ##args)
162 #define NV_WARN(cli, fmt, args...) nv_warn((cli), fmt, ##args)
163 #define NV_INFO(cli, fmt, args...) nv_info((cli), fmt, ##args)
164 #define NV_DEBUG(cli, fmt, args...) do {                                       \
165         if (drm_debug & DRM_UT_DRIVER)                                         \
166                 nv_info((cli), fmt, ##args);                                   \
167 } while (0)
168
169 extern int nouveau_modeset;
170
171 #endif