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