Commit f468400664e3ae79e6e001bb2820c79bebe6aa41

Authored by Dave Airlie

Merge branch 'drm-nouveau-next' of git://anongit.freedesktop.org/git/nouveau/linux-2.6 into drm-next

Add GK110 modesetting suport.

* 'drm-nouveau-next' of git://anongit.freedesktop.org/git/nouveau/linux-2.6:
  drm/nve0: recognise nvf0 as a kepler board (GK110)
  drm/nouveau: force noaccel when no PFIFO support present
  drm/nvf0/disp: expose display class 2.2

Showing 9 changed files Inline Diff

drivers/gpu/drm/nouveau/Makefile
1 # 1 #
2 # Makefile for the drm device driver. This driver provides support for the 2 # Makefile for the drm device driver. This driver provides support for the
3 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. 3 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
4 4
5 ccflags-y := -Iinclude/drm 5 ccflags-y := -Iinclude/drm
6 ccflags-y += -I$(src)/core/include 6 ccflags-y += -I$(src)/core/include
7 ccflags-y += -I$(src)/core 7 ccflags-y += -I$(src)/core
8 ccflags-y += -I$(src) 8 ccflags-y += -I$(src)
9 9
10 nouveau-y := core/core/client.o 10 nouveau-y := core/core/client.o
11 nouveau-y += core/core/engctx.o 11 nouveau-y += core/core/engctx.o
12 nouveau-y += core/core/engine.o 12 nouveau-y += core/core/engine.o
13 nouveau-y += core/core/enum.o 13 nouveau-y += core/core/enum.o
14 nouveau-y += core/core/event.o 14 nouveau-y += core/core/event.o
15 nouveau-y += core/core/falcon.o 15 nouveau-y += core/core/falcon.o
16 nouveau-y += core/core/gpuobj.o 16 nouveau-y += core/core/gpuobj.o
17 nouveau-y += core/core/handle.o 17 nouveau-y += core/core/handle.o
18 nouveau-y += core/core/mm.o 18 nouveau-y += core/core/mm.o
19 nouveau-y += core/core/namedb.o 19 nouveau-y += core/core/namedb.o
20 nouveau-y += core/core/object.o 20 nouveau-y += core/core/object.o
21 nouveau-y += core/core/option.o 21 nouveau-y += core/core/option.o
22 nouveau-y += core/core/parent.o 22 nouveau-y += core/core/parent.o
23 nouveau-y += core/core/printk.o 23 nouveau-y += core/core/printk.o
24 nouveau-y += core/core/ramht.o 24 nouveau-y += core/core/ramht.o
25 nouveau-y += core/core/subdev.o 25 nouveau-y += core/core/subdev.o
26 26
27 nouveau-y += core/subdev/bar/base.o 27 nouveau-y += core/subdev/bar/base.o
28 nouveau-y += core/subdev/bar/nv50.o 28 nouveau-y += core/subdev/bar/nv50.o
29 nouveau-y += core/subdev/bar/nvc0.o 29 nouveau-y += core/subdev/bar/nvc0.o
30 nouveau-y += core/subdev/bios/base.o 30 nouveau-y += core/subdev/bios/base.o
31 nouveau-y += core/subdev/bios/bit.o 31 nouveau-y += core/subdev/bios/bit.o
32 nouveau-y += core/subdev/bios/conn.o 32 nouveau-y += core/subdev/bios/conn.o
33 nouveau-y += core/subdev/bios/dcb.o 33 nouveau-y += core/subdev/bios/dcb.o
34 nouveau-y += core/subdev/bios/disp.o 34 nouveau-y += core/subdev/bios/disp.o
35 nouveau-y += core/subdev/bios/dp.o 35 nouveau-y += core/subdev/bios/dp.o
36 nouveau-y += core/subdev/bios/extdev.o 36 nouveau-y += core/subdev/bios/extdev.o
37 nouveau-y += core/subdev/bios/gpio.o 37 nouveau-y += core/subdev/bios/gpio.o
38 nouveau-y += core/subdev/bios/i2c.o 38 nouveau-y += core/subdev/bios/i2c.o
39 nouveau-y += core/subdev/bios/init.o 39 nouveau-y += core/subdev/bios/init.o
40 nouveau-y += core/subdev/bios/mxm.o 40 nouveau-y += core/subdev/bios/mxm.o
41 nouveau-y += core/subdev/bios/perf.o 41 nouveau-y += core/subdev/bios/perf.o
42 nouveau-y += core/subdev/bios/pll.o 42 nouveau-y += core/subdev/bios/pll.o
43 nouveau-y += core/subdev/bios/therm.o 43 nouveau-y += core/subdev/bios/therm.o
44 nouveau-y += core/subdev/bios/xpio.o 44 nouveau-y += core/subdev/bios/xpio.o
45 nouveau-y += core/subdev/bus/nv04.o 45 nouveau-y += core/subdev/bus/nv04.o
46 nouveau-y += core/subdev/bus/nv31.o 46 nouveau-y += core/subdev/bus/nv31.o
47 nouveau-y += core/subdev/bus/nv50.o 47 nouveau-y += core/subdev/bus/nv50.o
48 nouveau-y += core/subdev/bus/nvc0.o 48 nouveau-y += core/subdev/bus/nvc0.o
49 nouveau-y += core/subdev/clock/nv04.o 49 nouveau-y += core/subdev/clock/nv04.o
50 nouveau-y += core/subdev/clock/nv40.o 50 nouveau-y += core/subdev/clock/nv40.o
51 nouveau-y += core/subdev/clock/nv50.o 51 nouveau-y += core/subdev/clock/nv50.o
52 nouveau-y += core/subdev/clock/nva3.o 52 nouveau-y += core/subdev/clock/nva3.o
53 nouveau-y += core/subdev/clock/nvc0.o 53 nouveau-y += core/subdev/clock/nvc0.o
54 nouveau-y += core/subdev/clock/pllnv04.o 54 nouveau-y += core/subdev/clock/pllnv04.o
55 nouveau-y += core/subdev/clock/pllnva3.o 55 nouveau-y += core/subdev/clock/pllnva3.o
56 nouveau-y += core/subdev/devinit/base.o 56 nouveau-y += core/subdev/devinit/base.o
57 nouveau-y += core/subdev/devinit/nv04.o 57 nouveau-y += core/subdev/devinit/nv04.o
58 nouveau-y += core/subdev/devinit/nv05.o 58 nouveau-y += core/subdev/devinit/nv05.o
59 nouveau-y += core/subdev/devinit/nv10.o 59 nouveau-y += core/subdev/devinit/nv10.o
60 nouveau-y += core/subdev/devinit/nv1a.o 60 nouveau-y += core/subdev/devinit/nv1a.o
61 nouveau-y += core/subdev/devinit/nv20.o 61 nouveau-y += core/subdev/devinit/nv20.o
62 nouveau-y += core/subdev/devinit/nv50.o 62 nouveau-y += core/subdev/devinit/nv50.o
63 nouveau-y += core/subdev/fb/base.o 63 nouveau-y += core/subdev/fb/base.o
64 nouveau-y += core/subdev/fb/nv04.o 64 nouveau-y += core/subdev/fb/nv04.o
65 nouveau-y += core/subdev/fb/nv10.o 65 nouveau-y += core/subdev/fb/nv10.o
66 nouveau-y += core/subdev/fb/nv1a.o 66 nouveau-y += core/subdev/fb/nv1a.o
67 nouveau-y += core/subdev/fb/nv20.o 67 nouveau-y += core/subdev/fb/nv20.o
68 nouveau-y += core/subdev/fb/nv25.o 68 nouveau-y += core/subdev/fb/nv25.o
69 nouveau-y += core/subdev/fb/nv30.o 69 nouveau-y += core/subdev/fb/nv30.o
70 nouveau-y += core/subdev/fb/nv35.o 70 nouveau-y += core/subdev/fb/nv35.o
71 nouveau-y += core/subdev/fb/nv36.o 71 nouveau-y += core/subdev/fb/nv36.o
72 nouveau-y += core/subdev/fb/nv40.o 72 nouveau-y += core/subdev/fb/nv40.o
73 nouveau-y += core/subdev/fb/nv41.o 73 nouveau-y += core/subdev/fb/nv41.o
74 nouveau-y += core/subdev/fb/nv44.o 74 nouveau-y += core/subdev/fb/nv44.o
75 nouveau-y += core/subdev/fb/nv46.o 75 nouveau-y += core/subdev/fb/nv46.o
76 nouveau-y += core/subdev/fb/nv47.o 76 nouveau-y += core/subdev/fb/nv47.o
77 nouveau-y += core/subdev/fb/nv49.o 77 nouveau-y += core/subdev/fb/nv49.o
78 nouveau-y += core/subdev/fb/nv4e.o 78 nouveau-y += core/subdev/fb/nv4e.o
79 nouveau-y += core/subdev/fb/nv50.o 79 nouveau-y += core/subdev/fb/nv50.o
80 nouveau-y += core/subdev/fb/nvc0.o 80 nouveau-y += core/subdev/fb/nvc0.o
81 nouveau-y += core/subdev/gpio/base.o 81 nouveau-y += core/subdev/gpio/base.o
82 nouveau-y += core/subdev/gpio/nv10.o 82 nouveau-y += core/subdev/gpio/nv10.o
83 nouveau-y += core/subdev/gpio/nv50.o 83 nouveau-y += core/subdev/gpio/nv50.o
84 nouveau-y += core/subdev/gpio/nvd0.o 84 nouveau-y += core/subdev/gpio/nvd0.o
85 nouveau-y += core/subdev/gpio/nve0.o 85 nouveau-y += core/subdev/gpio/nve0.o
86 nouveau-y += core/subdev/i2c/base.o 86 nouveau-y += core/subdev/i2c/base.o
87 nouveau-y += core/subdev/i2c/anx9805.o 87 nouveau-y += core/subdev/i2c/anx9805.o
88 nouveau-y += core/subdev/i2c/aux.o 88 nouveau-y += core/subdev/i2c/aux.o
89 nouveau-y += core/subdev/i2c/bit.o 89 nouveau-y += core/subdev/i2c/bit.o
90 nouveau-y += core/subdev/i2c/nv04.o 90 nouveau-y += core/subdev/i2c/nv04.o
91 nouveau-y += core/subdev/i2c/nv4e.o 91 nouveau-y += core/subdev/i2c/nv4e.o
92 nouveau-y += core/subdev/i2c/nv50.o 92 nouveau-y += core/subdev/i2c/nv50.o
93 nouveau-y += core/subdev/i2c/nv94.o 93 nouveau-y += core/subdev/i2c/nv94.o
94 nouveau-y += core/subdev/i2c/nvd0.o 94 nouveau-y += core/subdev/i2c/nvd0.o
95 nouveau-y += core/subdev/ibus/nvc0.o 95 nouveau-y += core/subdev/ibus/nvc0.o
96 nouveau-y += core/subdev/ibus/nve0.o 96 nouveau-y += core/subdev/ibus/nve0.o
97 nouveau-y += core/subdev/instmem/base.o 97 nouveau-y += core/subdev/instmem/base.o
98 nouveau-y += core/subdev/instmem/nv04.o 98 nouveau-y += core/subdev/instmem/nv04.o
99 nouveau-y += core/subdev/instmem/nv40.o 99 nouveau-y += core/subdev/instmem/nv40.o
100 nouveau-y += core/subdev/instmem/nv50.o 100 nouveau-y += core/subdev/instmem/nv50.o
101 nouveau-y += core/subdev/ltcg/nvc0.o 101 nouveau-y += core/subdev/ltcg/nvc0.o
102 nouveau-y += core/subdev/mc/base.o 102 nouveau-y += core/subdev/mc/base.o
103 nouveau-y += core/subdev/mc/nv04.o 103 nouveau-y += core/subdev/mc/nv04.o
104 nouveau-y += core/subdev/mc/nv44.o 104 nouveau-y += core/subdev/mc/nv44.o
105 nouveau-y += core/subdev/mc/nv50.o 105 nouveau-y += core/subdev/mc/nv50.o
106 nouveau-y += core/subdev/mc/nv98.o 106 nouveau-y += core/subdev/mc/nv98.o
107 nouveau-y += core/subdev/mc/nvc0.o 107 nouveau-y += core/subdev/mc/nvc0.o
108 nouveau-y += core/subdev/mxm/base.o 108 nouveau-y += core/subdev/mxm/base.o
109 nouveau-y += core/subdev/mxm/mxms.o 109 nouveau-y += core/subdev/mxm/mxms.o
110 nouveau-y += core/subdev/mxm/nv50.o 110 nouveau-y += core/subdev/mxm/nv50.o
111 nouveau-y += core/subdev/therm/base.o 111 nouveau-y += core/subdev/therm/base.o
112 nouveau-y += core/subdev/therm/fan.o 112 nouveau-y += core/subdev/therm/fan.o
113 nouveau-y += core/subdev/therm/fannil.o 113 nouveau-y += core/subdev/therm/fannil.o
114 nouveau-y += core/subdev/therm/fanpwm.o 114 nouveau-y += core/subdev/therm/fanpwm.o
115 nouveau-y += core/subdev/therm/fantog.o 115 nouveau-y += core/subdev/therm/fantog.o
116 nouveau-y += core/subdev/therm/ic.o 116 nouveau-y += core/subdev/therm/ic.o
117 nouveau-y += core/subdev/therm/temp.o 117 nouveau-y += core/subdev/therm/temp.o
118 nouveau-y += core/subdev/therm/nv40.o 118 nouveau-y += core/subdev/therm/nv40.o
119 nouveau-y += core/subdev/therm/nv50.o 119 nouveau-y += core/subdev/therm/nv50.o
120 nouveau-y += core/subdev/therm/nv84.o 120 nouveau-y += core/subdev/therm/nv84.o
121 nouveau-y += core/subdev/therm/nva3.o 121 nouveau-y += core/subdev/therm/nva3.o
122 nouveau-y += core/subdev/therm/nvd0.o 122 nouveau-y += core/subdev/therm/nvd0.o
123 nouveau-y += core/subdev/timer/base.o 123 nouveau-y += core/subdev/timer/base.o
124 nouveau-y += core/subdev/timer/nv04.o 124 nouveau-y += core/subdev/timer/nv04.o
125 nouveau-y += core/subdev/vm/base.o 125 nouveau-y += core/subdev/vm/base.o
126 nouveau-y += core/subdev/vm/nv04.o 126 nouveau-y += core/subdev/vm/nv04.o
127 nouveau-y += core/subdev/vm/nv41.o 127 nouveau-y += core/subdev/vm/nv41.o
128 nouveau-y += core/subdev/vm/nv44.o 128 nouveau-y += core/subdev/vm/nv44.o
129 nouveau-y += core/subdev/vm/nv50.o 129 nouveau-y += core/subdev/vm/nv50.o
130 nouveau-y += core/subdev/vm/nvc0.o 130 nouveau-y += core/subdev/vm/nvc0.o
131 131
132 nouveau-y += core/engine/dmaobj/base.o 132 nouveau-y += core/engine/dmaobj/base.o
133 nouveau-y += core/engine/dmaobj/nv04.o 133 nouveau-y += core/engine/dmaobj/nv04.o
134 nouveau-y += core/engine/dmaobj/nv50.o 134 nouveau-y += core/engine/dmaobj/nv50.o
135 nouveau-y += core/engine/dmaobj/nvc0.o 135 nouveau-y += core/engine/dmaobj/nvc0.o
136 nouveau-y += core/engine/dmaobj/nvd0.o 136 nouveau-y += core/engine/dmaobj/nvd0.o
137 nouveau-y += core/engine/bsp/nv84.o 137 nouveau-y += core/engine/bsp/nv84.o
138 nouveau-y += core/engine/bsp/nvc0.o 138 nouveau-y += core/engine/bsp/nvc0.o
139 nouveau-y += core/engine/bsp/nve0.o 139 nouveau-y += core/engine/bsp/nve0.o
140 nouveau-y += core/engine/copy/nva3.o 140 nouveau-y += core/engine/copy/nva3.o
141 nouveau-y += core/engine/copy/nvc0.o 141 nouveau-y += core/engine/copy/nvc0.o
142 nouveau-y += core/engine/copy/nve0.o 142 nouveau-y += core/engine/copy/nve0.o
143 nouveau-y += core/engine/crypt/nv84.o 143 nouveau-y += core/engine/crypt/nv84.o
144 nouveau-y += core/engine/crypt/nv98.o 144 nouveau-y += core/engine/crypt/nv98.o
145 nouveau-y += core/engine/device/base.o 145 nouveau-y += core/engine/device/base.o
146 nouveau-y += core/engine/device/nv04.o 146 nouveau-y += core/engine/device/nv04.o
147 nouveau-y += core/engine/device/nv10.o 147 nouveau-y += core/engine/device/nv10.o
148 nouveau-y += core/engine/device/nv20.o 148 nouveau-y += core/engine/device/nv20.o
149 nouveau-y += core/engine/device/nv30.o 149 nouveau-y += core/engine/device/nv30.o
150 nouveau-y += core/engine/device/nv40.o 150 nouveau-y += core/engine/device/nv40.o
151 nouveau-y += core/engine/device/nv50.o 151 nouveau-y += core/engine/device/nv50.o
152 nouveau-y += core/engine/device/nvc0.o 152 nouveau-y += core/engine/device/nvc0.o
153 nouveau-y += core/engine/device/nve0.o 153 nouveau-y += core/engine/device/nve0.o
154 nouveau-y += core/engine/disp/base.o 154 nouveau-y += core/engine/disp/base.o
155 nouveau-y += core/engine/disp/nv04.o 155 nouveau-y += core/engine/disp/nv04.o
156 nouveau-y += core/engine/disp/nv50.o 156 nouveau-y += core/engine/disp/nv50.o
157 nouveau-y += core/engine/disp/nv84.o 157 nouveau-y += core/engine/disp/nv84.o
158 nouveau-y += core/engine/disp/nv94.o 158 nouveau-y += core/engine/disp/nv94.o
159 nouveau-y += core/engine/disp/nva0.o 159 nouveau-y += core/engine/disp/nva0.o
160 nouveau-y += core/engine/disp/nva3.o 160 nouveau-y += core/engine/disp/nva3.o
161 nouveau-y += core/engine/disp/nvd0.o 161 nouveau-y += core/engine/disp/nvd0.o
162 nouveau-y += core/engine/disp/nve0.o 162 nouveau-y += core/engine/disp/nve0.o
163 nouveau-y += core/engine/disp/nvf0.o
163 nouveau-y += core/engine/disp/dacnv50.o 164 nouveau-y += core/engine/disp/dacnv50.o
164 nouveau-y += core/engine/disp/dport.o 165 nouveau-y += core/engine/disp/dport.o
165 nouveau-y += core/engine/disp/hdanva3.o 166 nouveau-y += core/engine/disp/hdanva3.o
166 nouveau-y += core/engine/disp/hdanvd0.o 167 nouveau-y += core/engine/disp/hdanvd0.o
167 nouveau-y += core/engine/disp/hdminv84.o 168 nouveau-y += core/engine/disp/hdminv84.o
168 nouveau-y += core/engine/disp/hdminva3.o 169 nouveau-y += core/engine/disp/hdminva3.o
169 nouveau-y += core/engine/disp/hdminvd0.o 170 nouveau-y += core/engine/disp/hdminvd0.o
170 nouveau-y += core/engine/disp/piornv50.o 171 nouveau-y += core/engine/disp/piornv50.o
171 nouveau-y += core/engine/disp/sornv50.o 172 nouveau-y += core/engine/disp/sornv50.o
172 nouveau-y += core/engine/disp/sornv94.o 173 nouveau-y += core/engine/disp/sornv94.o
173 nouveau-y += core/engine/disp/sornvd0.o 174 nouveau-y += core/engine/disp/sornvd0.o
174 nouveau-y += core/engine/disp/vga.o 175 nouveau-y += core/engine/disp/vga.o
175 nouveau-y += core/engine/fifo/base.o 176 nouveau-y += core/engine/fifo/base.o
176 nouveau-y += core/engine/fifo/nv04.o 177 nouveau-y += core/engine/fifo/nv04.o
177 nouveau-y += core/engine/fifo/nv10.o 178 nouveau-y += core/engine/fifo/nv10.o
178 nouveau-y += core/engine/fifo/nv17.o 179 nouveau-y += core/engine/fifo/nv17.o
179 nouveau-y += core/engine/fifo/nv40.o 180 nouveau-y += core/engine/fifo/nv40.o
180 nouveau-y += core/engine/fifo/nv50.o 181 nouveau-y += core/engine/fifo/nv50.o
181 nouveau-y += core/engine/fifo/nv84.o 182 nouveau-y += core/engine/fifo/nv84.o
182 nouveau-y += core/engine/fifo/nvc0.o 183 nouveau-y += core/engine/fifo/nvc0.o
183 nouveau-y += core/engine/fifo/nve0.o 184 nouveau-y += core/engine/fifo/nve0.o
184 nouveau-y += core/engine/graph/ctxnv40.o 185 nouveau-y += core/engine/graph/ctxnv40.o
185 nouveau-y += core/engine/graph/ctxnv50.o 186 nouveau-y += core/engine/graph/ctxnv50.o
186 nouveau-y += core/engine/graph/ctxnvc0.o 187 nouveau-y += core/engine/graph/ctxnvc0.o
187 nouveau-y += core/engine/graph/ctxnve0.o 188 nouveau-y += core/engine/graph/ctxnve0.o
188 nouveau-y += core/engine/graph/nv04.o 189 nouveau-y += core/engine/graph/nv04.o
189 nouveau-y += core/engine/graph/nv10.o 190 nouveau-y += core/engine/graph/nv10.o
190 nouveau-y += core/engine/graph/nv20.o 191 nouveau-y += core/engine/graph/nv20.o
191 nouveau-y += core/engine/graph/nv25.o 192 nouveau-y += core/engine/graph/nv25.o
192 nouveau-y += core/engine/graph/nv2a.o 193 nouveau-y += core/engine/graph/nv2a.o
193 nouveau-y += core/engine/graph/nv30.o 194 nouveau-y += core/engine/graph/nv30.o
194 nouveau-y += core/engine/graph/nv34.o 195 nouveau-y += core/engine/graph/nv34.o
195 nouveau-y += core/engine/graph/nv35.o 196 nouveau-y += core/engine/graph/nv35.o
196 nouveau-y += core/engine/graph/nv40.o 197 nouveau-y += core/engine/graph/nv40.o
197 nouveau-y += core/engine/graph/nv50.o 198 nouveau-y += core/engine/graph/nv50.o
198 nouveau-y += core/engine/graph/nvc0.o 199 nouveau-y += core/engine/graph/nvc0.o
199 nouveau-y += core/engine/graph/nve0.o 200 nouveau-y += core/engine/graph/nve0.o
200 nouveau-y += core/engine/mpeg/nv31.o 201 nouveau-y += core/engine/mpeg/nv31.o
201 nouveau-y += core/engine/mpeg/nv40.o 202 nouveau-y += core/engine/mpeg/nv40.o
202 nouveau-y += core/engine/mpeg/nv50.o 203 nouveau-y += core/engine/mpeg/nv50.o
203 nouveau-y += core/engine/mpeg/nv84.o 204 nouveau-y += core/engine/mpeg/nv84.o
204 nouveau-y += core/engine/ppp/nv98.o 205 nouveau-y += core/engine/ppp/nv98.o
205 nouveau-y += core/engine/ppp/nvc0.o 206 nouveau-y += core/engine/ppp/nvc0.o
206 nouveau-y += core/engine/software/nv04.o 207 nouveau-y += core/engine/software/nv04.o
207 nouveau-y += core/engine/software/nv10.o 208 nouveau-y += core/engine/software/nv10.o
208 nouveau-y += core/engine/software/nv50.o 209 nouveau-y += core/engine/software/nv50.o
209 nouveau-y += core/engine/software/nvc0.o 210 nouveau-y += core/engine/software/nvc0.o
210 nouveau-y += core/engine/vp/nv84.o 211 nouveau-y += core/engine/vp/nv84.o
211 nouveau-y += core/engine/vp/nvc0.o 212 nouveau-y += core/engine/vp/nvc0.o
212 nouveau-y += core/engine/vp/nve0.o 213 nouveau-y += core/engine/vp/nve0.o
213 214
214 # drm/core 215 # drm/core
215 nouveau-y += nouveau_drm.o nouveau_chan.o nouveau_dma.o nouveau_fence.o 216 nouveau-y += nouveau_drm.o nouveau_chan.o nouveau_dma.o nouveau_fence.o
216 nouveau-y += nouveau_vga.o nouveau_agp.o 217 nouveau-y += nouveau_vga.o nouveau_agp.o
217 nouveau-y += nouveau_ttm.o nouveau_sgdma.o nouveau_bo.o nouveau_gem.o 218 nouveau-y += nouveau_ttm.o nouveau_sgdma.o nouveau_bo.o nouveau_gem.o
218 nouveau-y += nouveau_prime.o nouveau_abi16.o 219 nouveau-y += nouveau_prime.o nouveau_abi16.o
219 nouveau-y += nv04_fence.o nv10_fence.o nv17_fence.o 220 nouveau-y += nv04_fence.o nv10_fence.o nv17_fence.o
220 nouveau-y += nv50_fence.o nv84_fence.o nvc0_fence.o 221 nouveau-y += nv50_fence.o nv84_fence.o nvc0_fence.o
221 222
222 # drm/kms 223 # drm/kms
223 nouveau-y += nouveau_bios.o nouveau_fbcon.o nouveau_display.o 224 nouveau-y += nouveau_bios.o nouveau_fbcon.o nouveau_display.o
224 nouveau-y += nouveau_connector.o nouveau_dp.o 225 nouveau-y += nouveau_connector.o nouveau_dp.o
225 nouveau-y += nv04_fbcon.o nv50_fbcon.o nvc0_fbcon.o 226 nouveau-y += nv04_fbcon.o nv50_fbcon.o nvc0_fbcon.o
226 227
227 # drm/kms/nv04:nv50 228 # drm/kms/nv04:nv50
228 include $(src)/dispnv04/Makefile 229 include $(src)/dispnv04/Makefile
229 230
230 # drm/kms/nv50- 231 # drm/kms/nv50-
231 nouveau-y += nv50_display.o 232 nouveau-y += nv50_display.o
232 233
233 # drm/pm 234 # drm/pm
234 nouveau-y += nouveau_pm.o nouveau_volt.o nouveau_perf.o 235 nouveau-y += nouveau_pm.o nouveau_volt.o nouveau_perf.o
235 nouveau-y += nv04_pm.o nv40_pm.o nv50_pm.o nva3_pm.o nvc0_pm.o 236 nouveau-y += nv04_pm.o nv40_pm.o nv50_pm.o nva3_pm.o nvc0_pm.o
236 nouveau-y += nouveau_mem.o 237 nouveau-y += nouveau_mem.o
237 238
238 # other random bits 239 # other random bits
239 nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o 240 nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
240 ifdef CONFIG_X86 241 ifdef CONFIG_X86
241 nouveau-$(CONFIG_ACPI) += nouveau_acpi.o 242 nouveau-$(CONFIG_ACPI) += nouveau_acpi.o
242 endif 243 endif
243 nouveau-$(CONFIG_DRM_NOUVEAU_BACKLIGHT) += nouveau_backlight.o 244 nouveau-$(CONFIG_DRM_NOUVEAU_BACKLIGHT) += nouveau_backlight.o
244 nouveau-$(CONFIG_DEBUG_FS) += nouveau_debugfs.o 245 nouveau-$(CONFIG_DEBUG_FS) += nouveau_debugfs.o
245 246
246 obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o 247 obj-$(CONFIG_DRM_NOUVEAU)+= nouveau.o
247 248
drivers/gpu/drm/nouveau/core/engine/device/base.c
1 /* 1 /*
2 * Copyright 2012 Red Hat Inc. 2 * Copyright 2012 Red Hat Inc.
3 * 3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a 4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"), 5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation 6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the 8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions: 9 * Software is furnished to do so, subject to the following conditions:
10 * 10 *
11 * The above copyright notice and this permission notice shall be included in 11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software. 12 * all copies or substantial portions of the Software.
13 * 13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE. 20 * OTHER DEALINGS IN THE SOFTWARE.
21 * 21 *
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24 24
25 #include <core/object.h> 25 #include <core/object.h>
26 #include <core/device.h> 26 #include <core/device.h>
27 #include <core/client.h> 27 #include <core/client.h>
28 #include <core/option.h> 28 #include <core/option.h>
29 29
30 #include <core/class.h> 30 #include <core/class.h>
31 31
32 #include <engine/device.h> 32 #include <engine/device.h>
33 33
34 static DEFINE_MUTEX(nv_devices_mutex); 34 static DEFINE_MUTEX(nv_devices_mutex);
35 static LIST_HEAD(nv_devices); 35 static LIST_HEAD(nv_devices);
36 36
37 struct nouveau_device * 37 struct nouveau_device *
38 nouveau_device_find(u64 name) 38 nouveau_device_find(u64 name)
39 { 39 {
40 struct nouveau_device *device, *match = NULL; 40 struct nouveau_device *device, *match = NULL;
41 mutex_lock(&nv_devices_mutex); 41 mutex_lock(&nv_devices_mutex);
42 list_for_each_entry(device, &nv_devices, head) { 42 list_for_each_entry(device, &nv_devices, head) {
43 if (device->handle == name) { 43 if (device->handle == name) {
44 match = device; 44 match = device;
45 break; 45 break;
46 } 46 }
47 } 47 }
48 mutex_unlock(&nv_devices_mutex); 48 mutex_unlock(&nv_devices_mutex);
49 return match; 49 return match;
50 } 50 }
51 51
52 /****************************************************************************** 52 /******************************************************************************
53 * nouveau_devobj (0x0080): class implementation 53 * nouveau_devobj (0x0080): class implementation
54 *****************************************************************************/ 54 *****************************************************************************/
55 struct nouveau_devobj { 55 struct nouveau_devobj {
56 struct nouveau_parent base; 56 struct nouveau_parent base;
57 struct nouveau_object *subdev[NVDEV_SUBDEV_NR]; 57 struct nouveau_object *subdev[NVDEV_SUBDEV_NR];
58 }; 58 };
59 59
60 static const u64 disable_map[] = { 60 static const u64 disable_map[] = {
61 [NVDEV_SUBDEV_VBIOS] = NV_DEVICE_DISABLE_VBIOS, 61 [NVDEV_SUBDEV_VBIOS] = NV_DEVICE_DISABLE_VBIOS,
62 [NVDEV_SUBDEV_DEVINIT] = NV_DEVICE_DISABLE_CORE, 62 [NVDEV_SUBDEV_DEVINIT] = NV_DEVICE_DISABLE_CORE,
63 [NVDEV_SUBDEV_GPIO] = NV_DEVICE_DISABLE_CORE, 63 [NVDEV_SUBDEV_GPIO] = NV_DEVICE_DISABLE_CORE,
64 [NVDEV_SUBDEV_I2C] = NV_DEVICE_DISABLE_CORE, 64 [NVDEV_SUBDEV_I2C] = NV_DEVICE_DISABLE_CORE,
65 [NVDEV_SUBDEV_CLOCK] = NV_DEVICE_DISABLE_CORE, 65 [NVDEV_SUBDEV_CLOCK] = NV_DEVICE_DISABLE_CORE,
66 [NVDEV_SUBDEV_MXM] = NV_DEVICE_DISABLE_CORE, 66 [NVDEV_SUBDEV_MXM] = NV_DEVICE_DISABLE_CORE,
67 [NVDEV_SUBDEV_MC] = NV_DEVICE_DISABLE_CORE, 67 [NVDEV_SUBDEV_MC] = NV_DEVICE_DISABLE_CORE,
68 [NVDEV_SUBDEV_BUS] = NV_DEVICE_DISABLE_CORE, 68 [NVDEV_SUBDEV_BUS] = NV_DEVICE_DISABLE_CORE,
69 [NVDEV_SUBDEV_TIMER] = NV_DEVICE_DISABLE_CORE, 69 [NVDEV_SUBDEV_TIMER] = NV_DEVICE_DISABLE_CORE,
70 [NVDEV_SUBDEV_FB] = NV_DEVICE_DISABLE_CORE, 70 [NVDEV_SUBDEV_FB] = NV_DEVICE_DISABLE_CORE,
71 [NVDEV_SUBDEV_LTCG] = NV_DEVICE_DISABLE_CORE, 71 [NVDEV_SUBDEV_LTCG] = NV_DEVICE_DISABLE_CORE,
72 [NVDEV_SUBDEV_IBUS] = NV_DEVICE_DISABLE_CORE, 72 [NVDEV_SUBDEV_IBUS] = NV_DEVICE_DISABLE_CORE,
73 [NVDEV_SUBDEV_INSTMEM] = NV_DEVICE_DISABLE_CORE, 73 [NVDEV_SUBDEV_INSTMEM] = NV_DEVICE_DISABLE_CORE,
74 [NVDEV_SUBDEV_VM] = NV_DEVICE_DISABLE_CORE, 74 [NVDEV_SUBDEV_VM] = NV_DEVICE_DISABLE_CORE,
75 [NVDEV_SUBDEV_BAR] = NV_DEVICE_DISABLE_CORE, 75 [NVDEV_SUBDEV_BAR] = NV_DEVICE_DISABLE_CORE,
76 [NVDEV_SUBDEV_VOLT] = NV_DEVICE_DISABLE_CORE, 76 [NVDEV_SUBDEV_VOLT] = NV_DEVICE_DISABLE_CORE,
77 [NVDEV_SUBDEV_THERM] = NV_DEVICE_DISABLE_CORE, 77 [NVDEV_SUBDEV_THERM] = NV_DEVICE_DISABLE_CORE,
78 [NVDEV_ENGINE_DMAOBJ] = NV_DEVICE_DISABLE_CORE, 78 [NVDEV_ENGINE_DMAOBJ] = NV_DEVICE_DISABLE_CORE,
79 [NVDEV_ENGINE_FIFO] = NV_DEVICE_DISABLE_FIFO, 79 [NVDEV_ENGINE_FIFO] = NV_DEVICE_DISABLE_FIFO,
80 [NVDEV_ENGINE_SW] = NV_DEVICE_DISABLE_FIFO, 80 [NVDEV_ENGINE_SW] = NV_DEVICE_DISABLE_FIFO,
81 [NVDEV_ENGINE_GR] = NV_DEVICE_DISABLE_GRAPH, 81 [NVDEV_ENGINE_GR] = NV_DEVICE_DISABLE_GRAPH,
82 [NVDEV_ENGINE_MPEG] = NV_DEVICE_DISABLE_MPEG, 82 [NVDEV_ENGINE_MPEG] = NV_DEVICE_DISABLE_MPEG,
83 [NVDEV_ENGINE_ME] = NV_DEVICE_DISABLE_ME, 83 [NVDEV_ENGINE_ME] = NV_DEVICE_DISABLE_ME,
84 [NVDEV_ENGINE_VP] = NV_DEVICE_DISABLE_VP, 84 [NVDEV_ENGINE_VP] = NV_DEVICE_DISABLE_VP,
85 [NVDEV_ENGINE_CRYPT] = NV_DEVICE_DISABLE_CRYPT, 85 [NVDEV_ENGINE_CRYPT] = NV_DEVICE_DISABLE_CRYPT,
86 [NVDEV_ENGINE_BSP] = NV_DEVICE_DISABLE_BSP, 86 [NVDEV_ENGINE_BSP] = NV_DEVICE_DISABLE_BSP,
87 [NVDEV_ENGINE_PPP] = NV_DEVICE_DISABLE_PPP, 87 [NVDEV_ENGINE_PPP] = NV_DEVICE_DISABLE_PPP,
88 [NVDEV_ENGINE_COPY0] = NV_DEVICE_DISABLE_COPY0, 88 [NVDEV_ENGINE_COPY0] = NV_DEVICE_DISABLE_COPY0,
89 [NVDEV_ENGINE_COPY1] = NV_DEVICE_DISABLE_COPY1, 89 [NVDEV_ENGINE_COPY1] = NV_DEVICE_DISABLE_COPY1,
90 [NVDEV_ENGINE_UNK1C1] = NV_DEVICE_DISABLE_UNK1C1, 90 [NVDEV_ENGINE_UNK1C1] = NV_DEVICE_DISABLE_UNK1C1,
91 [NVDEV_ENGINE_VENC] = NV_DEVICE_DISABLE_VENC, 91 [NVDEV_ENGINE_VENC] = NV_DEVICE_DISABLE_VENC,
92 [NVDEV_ENGINE_DISP] = NV_DEVICE_DISABLE_DISP, 92 [NVDEV_ENGINE_DISP] = NV_DEVICE_DISABLE_DISP,
93 [NVDEV_SUBDEV_NR] = 0, 93 [NVDEV_SUBDEV_NR] = 0,
94 }; 94 };
95 95
96 static int 96 static int
97 nouveau_devobj_ctor(struct nouveau_object *parent, 97 nouveau_devobj_ctor(struct nouveau_object *parent,
98 struct nouveau_object *engine, 98 struct nouveau_object *engine,
99 struct nouveau_oclass *oclass, void *data, u32 size, 99 struct nouveau_oclass *oclass, void *data, u32 size,
100 struct nouveau_object **pobject) 100 struct nouveau_object **pobject)
101 { 101 {
102 struct nouveau_client *client = nv_client(parent); 102 struct nouveau_client *client = nv_client(parent);
103 struct nouveau_device *device; 103 struct nouveau_device *device;
104 struct nouveau_devobj *devobj; 104 struct nouveau_devobj *devobj;
105 struct nv_device_class *args = data; 105 struct nv_device_class *args = data;
106 u32 boot0, strap; 106 u32 boot0, strap;
107 u64 disable, mmio_base, mmio_size; 107 u64 disable, mmio_base, mmio_size;
108 void __iomem *map; 108 void __iomem *map;
109 int ret, i, c; 109 int ret, i, c;
110 110
111 if (size < sizeof(struct nv_device_class)) 111 if (size < sizeof(struct nv_device_class))
112 return -EINVAL; 112 return -EINVAL;
113 113
114 /* find the device subdev that matches what the client requested */ 114 /* find the device subdev that matches what the client requested */
115 device = nv_device(client->device); 115 device = nv_device(client->device);
116 if (args->device != ~0) { 116 if (args->device != ~0) {
117 device = nouveau_device_find(args->device); 117 device = nouveau_device_find(args->device);
118 if (!device) 118 if (!device)
119 return -ENODEV; 119 return -ENODEV;
120 } 120 }
121 121
122 ret = nouveau_parent_create(parent, nv_object(device), oclass, 0, NULL, 122 ret = nouveau_parent_create(parent, nv_object(device), oclass, 0, NULL,
123 (1ULL << NVDEV_ENGINE_DMAOBJ) | 123 (1ULL << NVDEV_ENGINE_DMAOBJ) |
124 (1ULL << NVDEV_ENGINE_FIFO) | 124 (1ULL << NVDEV_ENGINE_FIFO) |
125 (1ULL << NVDEV_ENGINE_DISP), &devobj); 125 (1ULL << NVDEV_ENGINE_DISP), &devobj);
126 *pobject = nv_object(devobj); 126 *pobject = nv_object(devobj);
127 if (ret) 127 if (ret)
128 return ret; 128 return ret;
129 129
130 mmio_base = pci_resource_start(device->pdev, 0); 130 mmio_base = pci_resource_start(device->pdev, 0);
131 mmio_size = pci_resource_len(device->pdev, 0); 131 mmio_size = pci_resource_len(device->pdev, 0);
132 132
133 /* translate api disable mask into internal mapping */ 133 /* translate api disable mask into internal mapping */
134 disable = args->debug0; 134 disable = args->debug0;
135 for (i = 0; i < NVDEV_SUBDEV_NR; i++) { 135 for (i = 0; i < NVDEV_SUBDEV_NR; i++) {
136 if (args->disable & disable_map[i]) 136 if (args->disable & disable_map[i])
137 disable |= (1ULL << i); 137 disable |= (1ULL << i);
138 } 138 }
139 139
140 /* identify the chipset, and determine classes of subdev/engines */ 140 /* identify the chipset, and determine classes of subdev/engines */
141 if (!(args->disable & NV_DEVICE_DISABLE_IDENTIFY) && 141 if (!(args->disable & NV_DEVICE_DISABLE_IDENTIFY) &&
142 !device->card_type) { 142 !device->card_type) {
143 map = ioremap(mmio_base, 0x102000); 143 map = ioremap(mmio_base, 0x102000);
144 if (map == NULL) 144 if (map == NULL)
145 return -ENOMEM; 145 return -ENOMEM;
146 146
147 /* switch mmio to cpu's native endianness */ 147 /* switch mmio to cpu's native endianness */
148 #ifndef __BIG_ENDIAN 148 #ifndef __BIG_ENDIAN
149 if (ioread32_native(map + 0x000004) != 0x00000000) 149 if (ioread32_native(map + 0x000004) != 0x00000000)
150 #else 150 #else
151 if (ioread32_native(map + 0x000004) == 0x00000000) 151 if (ioread32_native(map + 0x000004) == 0x00000000)
152 #endif 152 #endif
153 iowrite32_native(0x01000001, map + 0x000004); 153 iowrite32_native(0x01000001, map + 0x000004);
154 154
155 /* read boot0 and strapping information */ 155 /* read boot0 and strapping information */
156 boot0 = ioread32_native(map + 0x000000); 156 boot0 = ioread32_native(map + 0x000000);
157 strap = ioread32_native(map + 0x101000); 157 strap = ioread32_native(map + 0x101000);
158 iounmap(map); 158 iounmap(map);
159 159
160 /* determine chipset and derive architecture from it */ 160 /* determine chipset and derive architecture from it */
161 if ((boot0 & 0x0f000000) > 0) { 161 if ((boot0 & 0x0f000000) > 0) {
162 device->chipset = (boot0 & 0xff00000) >> 20; 162 device->chipset = (boot0 & 0xff00000) >> 20;
163 switch (device->chipset & 0xf0) { 163 switch (device->chipset & 0xf0) {
164 case 0x10: device->card_type = NV_10; break; 164 case 0x10: device->card_type = NV_10; break;
165 case 0x20: device->card_type = NV_20; break; 165 case 0x20: device->card_type = NV_20; break;
166 case 0x30: device->card_type = NV_30; break; 166 case 0x30: device->card_type = NV_30; break;
167 case 0x40: 167 case 0x40:
168 case 0x60: device->card_type = NV_40; break; 168 case 0x60: device->card_type = NV_40; break;
169 case 0x50: 169 case 0x50:
170 case 0x80: 170 case 0x80:
171 case 0x90: 171 case 0x90:
172 case 0xa0: device->card_type = NV_50; break; 172 case 0xa0: device->card_type = NV_50; break;
173 case 0xc0: device->card_type = NV_C0; break; 173 case 0xc0: device->card_type = NV_C0; break;
174 case 0xd0: device->card_type = NV_D0; break; 174 case 0xd0: device->card_type = NV_D0; break;
175 case 0xe0: device->card_type = NV_E0; break; 175 case 0xe0:
176 case 0xf0: device->card_type = NV_E0; break;
176 default: 177 default:
177 break; 178 break;
178 } 179 }
179 } else 180 } else
180 if ((boot0 & 0xff00fff0) == 0x20004000) { 181 if ((boot0 & 0xff00fff0) == 0x20004000) {
181 if (boot0 & 0x00f00000) 182 if (boot0 & 0x00f00000)
182 device->chipset = 0x05; 183 device->chipset = 0x05;
183 else 184 else
184 device->chipset = 0x04; 185 device->chipset = 0x04;
185 device->card_type = NV_04; 186 device->card_type = NV_04;
186 } 187 }
187 188
188 switch (device->card_type) { 189 switch (device->card_type) {
189 case NV_04: ret = nv04_identify(device); break; 190 case NV_04: ret = nv04_identify(device); break;
190 case NV_10: ret = nv10_identify(device); break; 191 case NV_10: ret = nv10_identify(device); break;
191 case NV_20: ret = nv20_identify(device); break; 192 case NV_20: ret = nv20_identify(device); break;
192 case NV_30: ret = nv30_identify(device); break; 193 case NV_30: ret = nv30_identify(device); break;
193 case NV_40: ret = nv40_identify(device); break; 194 case NV_40: ret = nv40_identify(device); break;
194 case NV_50: ret = nv50_identify(device); break; 195 case NV_50: ret = nv50_identify(device); break;
195 case NV_C0: 196 case NV_C0:
196 case NV_D0: ret = nvc0_identify(device); break; 197 case NV_D0: ret = nvc0_identify(device); break;
197 case NV_E0: ret = nve0_identify(device); break; 198 case NV_E0: ret = nve0_identify(device); break;
198 default: 199 default:
199 ret = -EINVAL; 200 ret = -EINVAL;
200 break; 201 break;
201 } 202 }
202 203
203 if (ret) { 204 if (ret) {
204 nv_error(device, "unknown chipset, 0x%08x\n", boot0); 205 nv_error(device, "unknown chipset, 0x%08x\n", boot0);
205 return ret; 206 return ret;
206 } 207 }
207 208
208 nv_info(device, "BOOT0 : 0x%08x\n", boot0); 209 nv_info(device, "BOOT0 : 0x%08x\n", boot0);
209 nv_info(device, "Chipset: %s (NV%02X)\n", 210 nv_info(device, "Chipset: %s (NV%02X)\n",
210 device->cname, device->chipset); 211 device->cname, device->chipset);
211 nv_info(device, "Family : NV%02X\n", device->card_type); 212 nv_info(device, "Family : NV%02X\n", device->card_type);
212 213
213 /* determine frequency of timing crystal */ 214 /* determine frequency of timing crystal */
214 if ( device->chipset < 0x17 || 215 if ( device->chipset < 0x17 ||
215 (device->chipset >= 0x20 && device->chipset < 0x25)) 216 (device->chipset >= 0x20 && device->chipset < 0x25))
216 strap &= 0x00000040; 217 strap &= 0x00000040;
217 else 218 else
218 strap &= 0x00400040; 219 strap &= 0x00400040;
219 220
220 switch (strap) { 221 switch (strap) {
221 case 0x00000000: device->crystal = 13500; break; 222 case 0x00000000: device->crystal = 13500; break;
222 case 0x00000040: device->crystal = 14318; break; 223 case 0x00000040: device->crystal = 14318; break;
223 case 0x00400000: device->crystal = 27000; break; 224 case 0x00400000: device->crystal = 27000; break;
224 case 0x00400040: device->crystal = 25000; break; 225 case 0x00400040: device->crystal = 25000; break;
225 } 226 }
226 227
227 nv_debug(device, "crystal freq: %dKHz\n", device->crystal); 228 nv_debug(device, "crystal freq: %dKHz\n", device->crystal);
228 } 229 }
229 230
230 if (!(args->disable & NV_DEVICE_DISABLE_MMIO) && 231 if (!(args->disable & NV_DEVICE_DISABLE_MMIO) &&
231 !nv_subdev(device)->mmio) { 232 !nv_subdev(device)->mmio) {
232 nv_subdev(device)->mmio = ioremap(mmio_base, mmio_size); 233 nv_subdev(device)->mmio = ioremap(mmio_base, mmio_size);
233 if (!nv_subdev(device)->mmio) { 234 if (!nv_subdev(device)->mmio) {
234 nv_error(device, "unable to map device registers\n"); 235 nv_error(device, "unable to map device registers\n");
235 return -ENOMEM; 236 return -ENOMEM;
236 } 237 }
237 } 238 }
238 239
239 /* ensure requested subsystems are available for use */ 240 /* ensure requested subsystems are available for use */
240 for (i = 1, c = 1; i < NVDEV_SUBDEV_NR; i++) { 241 for (i = 1, c = 1; i < NVDEV_SUBDEV_NR; i++) {
241 if (!(oclass = device->oclass[i]) || (disable & (1ULL << i))) 242 if (!(oclass = device->oclass[i]) || (disable & (1ULL << i)))
242 continue; 243 continue;
243 244
244 if (device->subdev[i]) { 245 if (device->subdev[i]) {
245 nouveau_object_ref(device->subdev[i], 246 nouveau_object_ref(device->subdev[i],
246 &devobj->subdev[i]); 247 &devobj->subdev[i]);
247 continue; 248 continue;
248 } 249 }
249 250
250 ret = nouveau_object_ctor(nv_object(device), NULL, 251 ret = nouveau_object_ctor(nv_object(device), NULL,
251 oclass, NULL, i, 252 oclass, NULL, i,
252 &devobj->subdev[i]); 253 &devobj->subdev[i]);
253 if (ret == -ENODEV) 254 if (ret == -ENODEV)
254 continue; 255 continue;
255 if (ret) 256 if (ret)
256 return ret; 257 return ret;
257 258
258 /* note: can't init *any* subdevs until devinit has been run 259 /* note: can't init *any* subdevs until devinit has been run
259 * due to not knowing exactly what the vbios init tables will 260 * due to not knowing exactly what the vbios init tables will
260 * mess with. devinit also can't be run until all of its 261 * mess with. devinit also can't be run until all of its
261 * dependencies have been created. 262 * dependencies have been created.
262 * 263 *
263 * this code delays init of any subdev until all of devinit's 264 * this code delays init of any subdev until all of devinit's
264 * dependencies have been created, and then initialises each 265 * dependencies have been created, and then initialises each
265 * subdev in turn as they're created. 266 * subdev in turn as they're created.
266 */ 267 */
267 while (i >= NVDEV_SUBDEV_DEVINIT_LAST && c <= i) { 268 while (i >= NVDEV_SUBDEV_DEVINIT_LAST && c <= i) {
268 struct nouveau_object *subdev = devobj->subdev[c++]; 269 struct nouveau_object *subdev = devobj->subdev[c++];
269 if (subdev && !nv_iclass(subdev, NV_ENGINE_CLASS)) { 270 if (subdev && !nv_iclass(subdev, NV_ENGINE_CLASS)) {
270 ret = nouveau_object_inc(subdev); 271 ret = nouveau_object_inc(subdev);
271 if (ret) 272 if (ret)
272 return ret; 273 return ret;
273 atomic_dec(&nv_object(device)->usecount); 274 atomic_dec(&nv_object(device)->usecount);
274 } else 275 } else
275 if (subdev) { 276 if (subdev) {
276 nouveau_subdev_reset(subdev); 277 nouveau_subdev_reset(subdev);
277 } 278 }
278 } 279 }
279 } 280 }
280 281
281 return 0; 282 return 0;
282 } 283 }
283 284
284 static void 285 static void
285 nouveau_devobj_dtor(struct nouveau_object *object) 286 nouveau_devobj_dtor(struct nouveau_object *object)
286 { 287 {
287 struct nouveau_devobj *devobj = (void *)object; 288 struct nouveau_devobj *devobj = (void *)object;
288 int i; 289 int i;
289 290
290 for (i = NVDEV_SUBDEV_NR - 1; i >= 0; i--) 291 for (i = NVDEV_SUBDEV_NR - 1; i >= 0; i--)
291 nouveau_object_ref(NULL, &devobj->subdev[i]); 292 nouveau_object_ref(NULL, &devobj->subdev[i]);
292 293
293 nouveau_parent_destroy(&devobj->base); 294 nouveau_parent_destroy(&devobj->base);
294 } 295 }
295 296
296 static u8 297 static u8
297 nouveau_devobj_rd08(struct nouveau_object *object, u64 addr) 298 nouveau_devobj_rd08(struct nouveau_object *object, u64 addr)
298 { 299 {
299 return nv_rd08(object->engine, addr); 300 return nv_rd08(object->engine, addr);
300 } 301 }
301 302
302 static u16 303 static u16
303 nouveau_devobj_rd16(struct nouveau_object *object, u64 addr) 304 nouveau_devobj_rd16(struct nouveau_object *object, u64 addr)
304 { 305 {
305 return nv_rd16(object->engine, addr); 306 return nv_rd16(object->engine, addr);
306 } 307 }
307 308
308 static u32 309 static u32
309 nouveau_devobj_rd32(struct nouveau_object *object, u64 addr) 310 nouveau_devobj_rd32(struct nouveau_object *object, u64 addr)
310 { 311 {
311 return nv_rd32(object->engine, addr); 312 return nv_rd32(object->engine, addr);
312 } 313 }
313 314
314 static void 315 static void
315 nouveau_devobj_wr08(struct nouveau_object *object, u64 addr, u8 data) 316 nouveau_devobj_wr08(struct nouveau_object *object, u64 addr, u8 data)
316 { 317 {
317 nv_wr08(object->engine, addr, data); 318 nv_wr08(object->engine, addr, data);
318 } 319 }
319 320
320 static void 321 static void
321 nouveau_devobj_wr16(struct nouveau_object *object, u64 addr, u16 data) 322 nouveau_devobj_wr16(struct nouveau_object *object, u64 addr, u16 data)
322 { 323 {
323 nv_wr16(object->engine, addr, data); 324 nv_wr16(object->engine, addr, data);
324 } 325 }
325 326
326 static void 327 static void
327 nouveau_devobj_wr32(struct nouveau_object *object, u64 addr, u32 data) 328 nouveau_devobj_wr32(struct nouveau_object *object, u64 addr, u32 data)
328 { 329 {
329 nv_wr32(object->engine, addr, data); 330 nv_wr32(object->engine, addr, data);
330 } 331 }
331 332
332 static struct nouveau_ofuncs 333 static struct nouveau_ofuncs
333 nouveau_devobj_ofuncs = { 334 nouveau_devobj_ofuncs = {
334 .ctor = nouveau_devobj_ctor, 335 .ctor = nouveau_devobj_ctor,
335 .dtor = nouveau_devobj_dtor, 336 .dtor = nouveau_devobj_dtor,
336 .init = _nouveau_parent_init, 337 .init = _nouveau_parent_init,
337 .fini = _nouveau_parent_fini, 338 .fini = _nouveau_parent_fini,
338 .rd08 = nouveau_devobj_rd08, 339 .rd08 = nouveau_devobj_rd08,
339 .rd16 = nouveau_devobj_rd16, 340 .rd16 = nouveau_devobj_rd16,
340 .rd32 = nouveau_devobj_rd32, 341 .rd32 = nouveau_devobj_rd32,
341 .wr08 = nouveau_devobj_wr08, 342 .wr08 = nouveau_devobj_wr08,
342 .wr16 = nouveau_devobj_wr16, 343 .wr16 = nouveau_devobj_wr16,
343 .wr32 = nouveau_devobj_wr32, 344 .wr32 = nouveau_devobj_wr32,
344 }; 345 };
345 346
346 /****************************************************************************** 347 /******************************************************************************
347 * nouveau_device: engine functions 348 * nouveau_device: engine functions
348 *****************************************************************************/ 349 *****************************************************************************/
349 static struct nouveau_oclass 350 static struct nouveau_oclass
350 nouveau_device_sclass[] = { 351 nouveau_device_sclass[] = {
351 { 0x0080, &nouveau_devobj_ofuncs }, 352 { 0x0080, &nouveau_devobj_ofuncs },
352 {} 353 {}
353 }; 354 };
354 355
355 static int 356 static int
356 nouveau_device_fini(struct nouveau_object *object, bool suspend) 357 nouveau_device_fini(struct nouveau_object *object, bool suspend)
357 { 358 {
358 struct nouveau_device *device = (void *)object; 359 struct nouveau_device *device = (void *)object;
359 struct nouveau_object *subdev; 360 struct nouveau_object *subdev;
360 int ret, i; 361 int ret, i;
361 362
362 for (i = NVDEV_SUBDEV_NR - 1; i >= 0; i--) { 363 for (i = NVDEV_SUBDEV_NR - 1; i >= 0; i--) {
363 if ((subdev = device->subdev[i])) { 364 if ((subdev = device->subdev[i])) {
364 if (!nv_iclass(subdev, NV_ENGINE_CLASS)) { 365 if (!nv_iclass(subdev, NV_ENGINE_CLASS)) {
365 ret = nouveau_object_dec(subdev, suspend); 366 ret = nouveau_object_dec(subdev, suspend);
366 if (ret && suspend) 367 if (ret && suspend)
367 goto fail; 368 goto fail;
368 } 369 }
369 } 370 }
370 } 371 }
371 372
372 ret = 0; 373 ret = 0;
373 fail: 374 fail:
374 for (; ret && i < NVDEV_SUBDEV_NR; i++) { 375 for (; ret && i < NVDEV_SUBDEV_NR; i++) {
375 if ((subdev = device->subdev[i])) { 376 if ((subdev = device->subdev[i])) {
376 if (!nv_iclass(subdev, NV_ENGINE_CLASS)) { 377 if (!nv_iclass(subdev, NV_ENGINE_CLASS)) {
377 ret = nouveau_object_inc(subdev); 378 ret = nouveau_object_inc(subdev);
378 if (ret) { 379 if (ret) {
379 /* XXX */ 380 /* XXX */
380 } 381 }
381 } 382 }
382 } 383 }
383 } 384 }
384 385
385 return ret; 386 return ret;
386 } 387 }
387 388
388 static int 389 static int
389 nouveau_device_init(struct nouveau_object *object) 390 nouveau_device_init(struct nouveau_object *object)
390 { 391 {
391 struct nouveau_device *device = (void *)object; 392 struct nouveau_device *device = (void *)object;
392 struct nouveau_object *subdev; 393 struct nouveau_object *subdev;
393 int ret, i; 394 int ret, i;
394 395
395 for (i = 0; i < NVDEV_SUBDEV_NR; i++) { 396 for (i = 0; i < NVDEV_SUBDEV_NR; i++) {
396 if ((subdev = device->subdev[i])) { 397 if ((subdev = device->subdev[i])) {
397 if (!nv_iclass(subdev, NV_ENGINE_CLASS)) { 398 if (!nv_iclass(subdev, NV_ENGINE_CLASS)) {
398 ret = nouveau_object_inc(subdev); 399 ret = nouveau_object_inc(subdev);
399 if (ret) 400 if (ret)
400 goto fail; 401 goto fail;
401 } else { 402 } else {
402 nouveau_subdev_reset(subdev); 403 nouveau_subdev_reset(subdev);
403 } 404 }
404 } 405 }
405 } 406 }
406 407
407 ret = 0; 408 ret = 0;
408 fail: 409 fail:
409 for (--i; ret && i >= 0; i--) { 410 for (--i; ret && i >= 0; i--) {
410 if ((subdev = device->subdev[i])) { 411 if ((subdev = device->subdev[i])) {
411 if (!nv_iclass(subdev, NV_ENGINE_CLASS)) 412 if (!nv_iclass(subdev, NV_ENGINE_CLASS))
412 nouveau_object_dec(subdev, false); 413 nouveau_object_dec(subdev, false);
413 } 414 }
414 } 415 }
415 416
416 return ret; 417 return ret;
417 } 418 }
418 419
419 static void 420 static void
420 nouveau_device_dtor(struct nouveau_object *object) 421 nouveau_device_dtor(struct nouveau_object *object)
421 { 422 {
422 struct nouveau_device *device = (void *)object; 423 struct nouveau_device *device = (void *)object;
423 424
424 mutex_lock(&nv_devices_mutex); 425 mutex_lock(&nv_devices_mutex);
425 list_del(&device->head); 426 list_del(&device->head);
426 mutex_unlock(&nv_devices_mutex); 427 mutex_unlock(&nv_devices_mutex);
427 428
428 if (nv_subdev(device)->mmio) 429 if (nv_subdev(device)->mmio)
429 iounmap(nv_subdev(device)->mmio); 430 iounmap(nv_subdev(device)->mmio);
430 431
431 nouveau_engine_destroy(&device->base); 432 nouveau_engine_destroy(&device->base);
432 } 433 }
433 434
434 static struct nouveau_oclass 435 static struct nouveau_oclass
435 nouveau_device_oclass = { 436 nouveau_device_oclass = {
436 .handle = NV_ENGINE(DEVICE, 0x00), 437 .handle = NV_ENGINE(DEVICE, 0x00),
437 .ofuncs = &(struct nouveau_ofuncs) { 438 .ofuncs = &(struct nouveau_ofuncs) {
438 .dtor = nouveau_device_dtor, 439 .dtor = nouveau_device_dtor,
439 .init = nouveau_device_init, 440 .init = nouveau_device_init,
440 .fini = nouveau_device_fini, 441 .fini = nouveau_device_fini,
441 }, 442 },
442 }; 443 };
443 444
444 int 445 int
445 nouveau_device_create_(struct pci_dev *pdev, u64 name, const char *sname, 446 nouveau_device_create_(struct pci_dev *pdev, u64 name, const char *sname,
446 const char *cfg, const char *dbg, 447 const char *cfg, const char *dbg,
447 int length, void **pobject) 448 int length, void **pobject)
448 { 449 {
449 struct nouveau_device *device; 450 struct nouveau_device *device;
450 int ret = -EEXIST; 451 int ret = -EEXIST;
451 452
452 mutex_lock(&nv_devices_mutex); 453 mutex_lock(&nv_devices_mutex);
453 list_for_each_entry(device, &nv_devices, head) { 454 list_for_each_entry(device, &nv_devices, head) {
454 if (device->handle == name) 455 if (device->handle == name)
455 goto done; 456 goto done;
456 } 457 }
457 458
458 ret = nouveau_engine_create_(NULL, NULL, &nouveau_device_oclass, true, 459 ret = nouveau_engine_create_(NULL, NULL, &nouveau_device_oclass, true,
459 "DEVICE", "device", length, pobject); 460 "DEVICE", "device", length, pobject);
460 device = *pobject; 461 device = *pobject;
461 if (ret) 462 if (ret)
462 goto done; 463 goto done;
463 464
464 device->pdev = pdev; 465 device->pdev = pdev;
465 device->handle = name; 466 device->handle = name;
466 device->cfgopt = cfg; 467 device->cfgopt = cfg;
467 device->dbgopt = dbg; 468 device->dbgopt = dbg;
468 device->name = sname; 469 device->name = sname;
469 470
470 nv_subdev(device)->debug = nouveau_dbgopt(device->dbgopt, "DEVICE"); 471 nv_subdev(device)->debug = nouveau_dbgopt(device->dbgopt, "DEVICE");
471 nv_engine(device)->sclass = nouveau_device_sclass; 472 nv_engine(device)->sclass = nouveau_device_sclass;
472 list_add(&device->head, &nv_devices); 473 list_add(&device->head, &nv_devices);
473 done: 474 done:
474 mutex_unlock(&nv_devices_mutex); 475 mutex_unlock(&nv_devices_mutex);
475 return ret; 476 return ret;
476 } 477 }
477 478
drivers/gpu/drm/nouveau/core/engine/device/nve0.c
1 /* 1 /*
2 * Copyright 2012 Red Hat Inc. 2 * Copyright 2012 Red Hat Inc.
3 * 3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a 4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"), 5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation 6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the 8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions: 9 * Software is furnished to do so, subject to the following conditions:
10 * 10 *
11 * The above copyright notice and this permission notice shall be included in 11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software. 12 * all copies or substantial portions of the Software.
13 * 13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE. 20 * OTHER DEALINGS IN THE SOFTWARE.
21 * 21 *
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24 24
25 #include <subdev/bios.h> 25 #include <subdev/bios.h>
26 #include <subdev/bus.h> 26 #include <subdev/bus.h>
27 #include <subdev/gpio.h> 27 #include <subdev/gpio.h>
28 #include <subdev/i2c.h> 28 #include <subdev/i2c.h>
29 #include <subdev/clock.h> 29 #include <subdev/clock.h>
30 #include <subdev/therm.h> 30 #include <subdev/therm.h>
31 #include <subdev/mxm.h> 31 #include <subdev/mxm.h>
32 #include <subdev/devinit.h> 32 #include <subdev/devinit.h>
33 #include <subdev/mc.h> 33 #include <subdev/mc.h>
34 #include <subdev/timer.h> 34 #include <subdev/timer.h>
35 #include <subdev/fb.h> 35 #include <subdev/fb.h>
36 #include <subdev/ltcg.h> 36 #include <subdev/ltcg.h>
37 #include <subdev/ibus.h> 37 #include <subdev/ibus.h>
38 #include <subdev/instmem.h> 38 #include <subdev/instmem.h>
39 #include <subdev/vm.h> 39 #include <subdev/vm.h>
40 #include <subdev/bar.h> 40 #include <subdev/bar.h>
41 41
42 #include <engine/device.h> 42 #include <engine/device.h>
43 #include <engine/dmaobj.h> 43 #include <engine/dmaobj.h>
44 #include <engine/fifo.h> 44 #include <engine/fifo.h>
45 #include <engine/software.h> 45 #include <engine/software.h>
46 #include <engine/graph.h> 46 #include <engine/graph.h>
47 #include <engine/disp.h> 47 #include <engine/disp.h>
48 #include <engine/copy.h> 48 #include <engine/copy.h>
49 #include <engine/bsp.h> 49 #include <engine/bsp.h>
50 #include <engine/vp.h> 50 #include <engine/vp.h>
51 #include <engine/ppp.h> 51 #include <engine/ppp.h>
52 52
53 int 53 int
54 nve0_identify(struct nouveau_device *device) 54 nve0_identify(struct nouveau_device *device)
55 { 55 {
56 switch (device->chipset) { 56 switch (device->chipset) {
57 case 0xe4: 57 case 0xe4:
58 device->cname = "GK104"; 58 device->cname = "GK104";
59 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; 59 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
60 device->oclass[NVDEV_SUBDEV_GPIO ] = &nve0_gpio_oclass; 60 device->oclass[NVDEV_SUBDEV_GPIO ] = &nve0_gpio_oclass;
61 device->oclass[NVDEV_SUBDEV_I2C ] = &nvd0_i2c_oclass; 61 device->oclass[NVDEV_SUBDEV_I2C ] = &nvd0_i2c_oclass;
62 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass; 62 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass;
63 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass; 63 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass;
64 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; 64 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass;
65 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass; 65 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass;
66 device->oclass[NVDEV_SUBDEV_MC ] = &nvc0_mc_oclass; 66 device->oclass[NVDEV_SUBDEV_MC ] = &nvc0_mc_oclass;
67 device->oclass[NVDEV_SUBDEV_BUS ] = &nvc0_bus_oclass; 67 device->oclass[NVDEV_SUBDEV_BUS ] = &nvc0_bus_oclass;
68 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; 68 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass;
69 device->oclass[NVDEV_SUBDEV_FB ] = &nvc0_fb_oclass; 69 device->oclass[NVDEV_SUBDEV_FB ] = &nvc0_fb_oclass;
70 device->oclass[NVDEV_SUBDEV_LTCG ] = &nvc0_ltcg_oclass; 70 device->oclass[NVDEV_SUBDEV_LTCG ] = &nvc0_ltcg_oclass;
71 device->oclass[NVDEV_SUBDEV_IBUS ] = &nve0_ibus_oclass; 71 device->oclass[NVDEV_SUBDEV_IBUS ] = &nve0_ibus_oclass;
72 device->oclass[NVDEV_SUBDEV_INSTMEM] = &nv50_instmem_oclass; 72 device->oclass[NVDEV_SUBDEV_INSTMEM] = &nv50_instmem_oclass;
73 device->oclass[NVDEV_SUBDEV_VM ] = &nvc0_vmmgr_oclass; 73 device->oclass[NVDEV_SUBDEV_VM ] = &nvc0_vmmgr_oclass;
74 device->oclass[NVDEV_SUBDEV_BAR ] = &nvc0_bar_oclass; 74 device->oclass[NVDEV_SUBDEV_BAR ] = &nvc0_bar_oclass;
75 device->oclass[NVDEV_ENGINE_DMAOBJ ] = &nvd0_dmaeng_oclass; 75 device->oclass[NVDEV_ENGINE_DMAOBJ ] = &nvd0_dmaeng_oclass;
76 device->oclass[NVDEV_ENGINE_FIFO ] = &nve0_fifo_oclass; 76 device->oclass[NVDEV_ENGINE_FIFO ] = &nve0_fifo_oclass;
77 device->oclass[NVDEV_ENGINE_SW ] = &nvc0_software_oclass; 77 device->oclass[NVDEV_ENGINE_SW ] = &nvc0_software_oclass;
78 device->oclass[NVDEV_ENGINE_GR ] = &nve0_graph_oclass; 78 device->oclass[NVDEV_ENGINE_GR ] = &nve0_graph_oclass;
79 device->oclass[NVDEV_ENGINE_DISP ] = &nve0_disp_oclass; 79 device->oclass[NVDEV_ENGINE_DISP ] = &nve0_disp_oclass;
80 device->oclass[NVDEV_ENGINE_COPY0 ] = &nve0_copy0_oclass; 80 device->oclass[NVDEV_ENGINE_COPY0 ] = &nve0_copy0_oclass;
81 device->oclass[NVDEV_ENGINE_COPY1 ] = &nve0_copy1_oclass; 81 device->oclass[NVDEV_ENGINE_COPY1 ] = &nve0_copy1_oclass;
82 device->oclass[NVDEV_ENGINE_BSP ] = &nve0_bsp_oclass; 82 device->oclass[NVDEV_ENGINE_BSP ] = &nve0_bsp_oclass;
83 device->oclass[NVDEV_ENGINE_VP ] = &nve0_vp_oclass; 83 device->oclass[NVDEV_ENGINE_VP ] = &nve0_vp_oclass;
84 device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass; 84 device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass;
85 break; 85 break;
86 case 0xe7: 86 case 0xe7:
87 device->cname = "GK107"; 87 device->cname = "GK107";
88 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; 88 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
89 device->oclass[NVDEV_SUBDEV_GPIO ] = &nve0_gpio_oclass; 89 device->oclass[NVDEV_SUBDEV_GPIO ] = &nve0_gpio_oclass;
90 device->oclass[NVDEV_SUBDEV_I2C ] = &nvd0_i2c_oclass; 90 device->oclass[NVDEV_SUBDEV_I2C ] = &nvd0_i2c_oclass;
91 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass; 91 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass;
92 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass; 92 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass;
93 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; 93 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass;
94 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass; 94 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass;
95 device->oclass[NVDEV_SUBDEV_MC ] = &nvc0_mc_oclass; 95 device->oclass[NVDEV_SUBDEV_MC ] = &nvc0_mc_oclass;
96 device->oclass[NVDEV_SUBDEV_BUS ] = &nvc0_bus_oclass; 96 device->oclass[NVDEV_SUBDEV_BUS ] = &nvc0_bus_oclass;
97 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; 97 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass;
98 device->oclass[NVDEV_SUBDEV_FB ] = &nvc0_fb_oclass; 98 device->oclass[NVDEV_SUBDEV_FB ] = &nvc0_fb_oclass;
99 device->oclass[NVDEV_SUBDEV_LTCG ] = &nvc0_ltcg_oclass; 99 device->oclass[NVDEV_SUBDEV_LTCG ] = &nvc0_ltcg_oclass;
100 device->oclass[NVDEV_SUBDEV_IBUS ] = &nve0_ibus_oclass; 100 device->oclass[NVDEV_SUBDEV_IBUS ] = &nve0_ibus_oclass;
101 device->oclass[NVDEV_SUBDEV_INSTMEM] = &nv50_instmem_oclass; 101 device->oclass[NVDEV_SUBDEV_INSTMEM] = &nv50_instmem_oclass;
102 device->oclass[NVDEV_SUBDEV_VM ] = &nvc0_vmmgr_oclass; 102 device->oclass[NVDEV_SUBDEV_VM ] = &nvc0_vmmgr_oclass;
103 device->oclass[NVDEV_SUBDEV_BAR ] = &nvc0_bar_oclass; 103 device->oclass[NVDEV_SUBDEV_BAR ] = &nvc0_bar_oclass;
104 device->oclass[NVDEV_ENGINE_DMAOBJ ] = &nvd0_dmaeng_oclass; 104 device->oclass[NVDEV_ENGINE_DMAOBJ ] = &nvd0_dmaeng_oclass;
105 device->oclass[NVDEV_ENGINE_FIFO ] = &nve0_fifo_oclass; 105 device->oclass[NVDEV_ENGINE_FIFO ] = &nve0_fifo_oclass;
106 device->oclass[NVDEV_ENGINE_SW ] = &nvc0_software_oclass; 106 device->oclass[NVDEV_ENGINE_SW ] = &nvc0_software_oclass;
107 device->oclass[NVDEV_ENGINE_GR ] = &nve0_graph_oclass; 107 device->oclass[NVDEV_ENGINE_GR ] = &nve0_graph_oclass;
108 device->oclass[NVDEV_ENGINE_DISP ] = &nve0_disp_oclass; 108 device->oclass[NVDEV_ENGINE_DISP ] = &nve0_disp_oclass;
109 device->oclass[NVDEV_ENGINE_COPY0 ] = &nve0_copy0_oclass; 109 device->oclass[NVDEV_ENGINE_COPY0 ] = &nve0_copy0_oclass;
110 device->oclass[NVDEV_ENGINE_COPY1 ] = &nve0_copy1_oclass; 110 device->oclass[NVDEV_ENGINE_COPY1 ] = &nve0_copy1_oclass;
111 device->oclass[NVDEV_ENGINE_BSP ] = &nve0_bsp_oclass; 111 device->oclass[NVDEV_ENGINE_BSP ] = &nve0_bsp_oclass;
112 device->oclass[NVDEV_ENGINE_VP ] = &nve0_vp_oclass; 112 device->oclass[NVDEV_ENGINE_VP ] = &nve0_vp_oclass;
113 device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass; 113 device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass;
114 break; 114 break;
115 case 0xe6: 115 case 0xe6:
116 device->cname = "GK106"; 116 device->cname = "GK106";
117 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; 117 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
118 device->oclass[NVDEV_SUBDEV_GPIO ] = &nve0_gpio_oclass; 118 device->oclass[NVDEV_SUBDEV_GPIO ] = &nve0_gpio_oclass;
119 device->oclass[NVDEV_SUBDEV_I2C ] = &nvd0_i2c_oclass; 119 device->oclass[NVDEV_SUBDEV_I2C ] = &nvd0_i2c_oclass;
120 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass; 120 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass;
121 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass; 121 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass;
122 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; 122 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass;
123 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass; 123 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass;
124 device->oclass[NVDEV_SUBDEV_MC ] = &nvc0_mc_oclass; 124 device->oclass[NVDEV_SUBDEV_MC ] = &nvc0_mc_oclass;
125 device->oclass[NVDEV_SUBDEV_BUS ] = &nvc0_bus_oclass; 125 device->oclass[NVDEV_SUBDEV_BUS ] = &nvc0_bus_oclass;
126 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass; 126 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass;
127 device->oclass[NVDEV_SUBDEV_FB ] = &nvc0_fb_oclass; 127 device->oclass[NVDEV_SUBDEV_FB ] = &nvc0_fb_oclass;
128 device->oclass[NVDEV_SUBDEV_LTCG ] = &nvc0_ltcg_oclass; 128 device->oclass[NVDEV_SUBDEV_LTCG ] = &nvc0_ltcg_oclass;
129 device->oclass[NVDEV_SUBDEV_IBUS ] = &nve0_ibus_oclass; 129 device->oclass[NVDEV_SUBDEV_IBUS ] = &nve0_ibus_oclass;
130 device->oclass[NVDEV_SUBDEV_INSTMEM] = &nv50_instmem_oclass; 130 device->oclass[NVDEV_SUBDEV_INSTMEM] = &nv50_instmem_oclass;
131 device->oclass[NVDEV_SUBDEV_VM ] = &nvc0_vmmgr_oclass; 131 device->oclass[NVDEV_SUBDEV_VM ] = &nvc0_vmmgr_oclass;
132 device->oclass[NVDEV_SUBDEV_BAR ] = &nvc0_bar_oclass; 132 device->oclass[NVDEV_SUBDEV_BAR ] = &nvc0_bar_oclass;
133 device->oclass[NVDEV_ENGINE_DMAOBJ ] = &nvd0_dmaeng_oclass; 133 device->oclass[NVDEV_ENGINE_DMAOBJ ] = &nvd0_dmaeng_oclass;
134 device->oclass[NVDEV_ENGINE_FIFO ] = &nve0_fifo_oclass; 134 device->oclass[NVDEV_ENGINE_FIFO ] = &nve0_fifo_oclass;
135 device->oclass[NVDEV_ENGINE_SW ] = &nvc0_software_oclass; 135 device->oclass[NVDEV_ENGINE_SW ] = &nvc0_software_oclass;
136 device->oclass[NVDEV_ENGINE_GR ] = &nve0_graph_oclass; 136 device->oclass[NVDEV_ENGINE_GR ] = &nve0_graph_oclass;
137 device->oclass[NVDEV_ENGINE_DISP ] = &nve0_disp_oclass; 137 device->oclass[NVDEV_ENGINE_DISP ] = &nve0_disp_oclass;
138 device->oclass[NVDEV_ENGINE_COPY0 ] = &nve0_copy0_oclass; 138 device->oclass[NVDEV_ENGINE_COPY0 ] = &nve0_copy0_oclass;
139 device->oclass[NVDEV_ENGINE_COPY1 ] = &nve0_copy1_oclass; 139 device->oclass[NVDEV_ENGINE_COPY1 ] = &nve0_copy1_oclass;
140 device->oclass[NVDEV_ENGINE_BSP ] = &nve0_bsp_oclass; 140 device->oclass[NVDEV_ENGINE_BSP ] = &nve0_bsp_oclass;
141 device->oclass[NVDEV_ENGINE_VP ] = &nve0_vp_oclass; 141 device->oclass[NVDEV_ENGINE_VP ] = &nve0_vp_oclass;
142 device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass; 142 device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass;
143 break; 143 break;
144 case 0xf0:
145 device->cname = "GK110";
146 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
147 device->oclass[NVDEV_SUBDEV_GPIO ] = &nve0_gpio_oclass;
148 device->oclass[NVDEV_SUBDEV_I2C ] = &nvd0_i2c_oclass;
149 device->oclass[NVDEV_SUBDEV_CLOCK ] = &nvc0_clock_oclass;
150 device->oclass[NVDEV_SUBDEV_THERM ] = &nvd0_therm_oclass;
151 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass;
152 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nvc0_devinit_oclass;
153 device->oclass[NVDEV_SUBDEV_MC ] = &nvc0_mc_oclass;
154 device->oclass[NVDEV_SUBDEV_BUS ] = &nvc0_bus_oclass;
155 device->oclass[NVDEV_SUBDEV_TIMER ] = &nv04_timer_oclass;
156 device->oclass[NVDEV_SUBDEV_FB ] = &nvc0_fb_oclass;
157 device->oclass[NVDEV_SUBDEV_LTCG ] = &nvc0_ltcg_oclass;
158 device->oclass[NVDEV_SUBDEV_IBUS ] = &nve0_ibus_oclass;
159 device->oclass[NVDEV_SUBDEV_INSTMEM] = &nv50_instmem_oclass;
160 device->oclass[NVDEV_SUBDEV_VM ] = &nvc0_vmmgr_oclass;
161 device->oclass[NVDEV_SUBDEV_BAR ] = &nvc0_bar_oclass;
162 device->oclass[NVDEV_ENGINE_DMAOBJ ] = &nvd0_dmaeng_oclass;
163 #if 0
164 device->oclass[NVDEV_ENGINE_FIFO ] = &nve0_fifo_oclass;
165 device->oclass[NVDEV_ENGINE_SW ] = &nvc0_software_oclass;
166 device->oclass[NVDEV_ENGINE_GR ] = &nve0_graph_oclass;
167 #endif
168 device->oclass[NVDEV_ENGINE_DISP ] = &nvf0_disp_oclass;
169 #if 0
170 device->oclass[NVDEV_ENGINE_COPY0 ] = &nve0_copy0_oclass;
171 device->oclass[NVDEV_ENGINE_COPY1 ] = &nve0_copy1_oclass;
172 device->oclass[NVDEV_ENGINE_COPY2 ] = &nve0_copy2_oclass;
173 device->oclass[NVDEV_ENGINE_BSP ] = &nve0_bsp_oclass;
174 device->oclass[NVDEV_ENGINE_VP ] = &nve0_vp_oclass;
175 device->oclass[NVDEV_ENGINE_PPP ] = &nvc0_ppp_oclass;
176 #endif
177 break;
144 default: 178 default:
145 nv_fatal(device, "unknown Kepler chipset\n"); 179 nv_fatal(device, "unknown Kepler chipset\n");
146 return -EINVAL; 180 return -EINVAL;
147 } 181 }
148 182
149 return 0; 183 return 0;
150 } 184 }
151 185
drivers/gpu/drm/nouveau/core/engine/disp/nvf0.c
File was created 1 /*
2 * Copyright 2012 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24
25 #include <engine/software.h>
26 #include <engine/disp.h>
27
28 #include <core/class.h>
29
30 #include "nv50.h"
31
32 static struct nouveau_oclass
33 nvf0_disp_sclass[] = {
34 { NVF0_DISP_MAST_CLASS, &nvd0_disp_mast_ofuncs },
35 { NVF0_DISP_SYNC_CLASS, &nvd0_disp_sync_ofuncs },
36 { NVF0_DISP_OVLY_CLASS, &nvd0_disp_ovly_ofuncs },
37 { NVF0_DISP_OIMM_CLASS, &nvd0_disp_oimm_ofuncs },
38 { NVF0_DISP_CURS_CLASS, &nvd0_disp_curs_ofuncs },
39 {}
40 };
41
42 static struct nouveau_oclass
43 nvf0_disp_base_oclass[] = {
44 { NVF0_DISP_CLASS, &nvd0_disp_base_ofuncs, nva3_disp_base_omthds },
45 {}
46 };
47
48 static int
49 nvf0_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
50 struct nouveau_oclass *oclass, void *data, u32 size,
51 struct nouveau_object **pobject)
52 {
53 struct nv50_disp_priv *priv;
54 int heads = nv_rd32(parent, 0x022448);
55 int ret;
56
57 ret = nouveau_disp_create(parent, engine, oclass, heads,
58 "PDISP", "display", &priv);
59 *pobject = nv_object(priv);
60 if (ret)
61 return ret;
62
63 nv_engine(priv)->sclass = nvf0_disp_base_oclass;
64 nv_engine(priv)->cclass = &nv50_disp_cclass;
65 nv_subdev(priv)->intr = nvd0_disp_intr;
66 INIT_WORK(&priv->supervisor, nvd0_disp_intr_supervisor);
67 priv->sclass = nvf0_disp_sclass;
68 priv->head.nr = heads;
69 priv->dac.nr = 3;
70 priv->sor.nr = 4;
71 priv->dac.power = nv50_dac_power;
72 priv->dac.sense = nv50_dac_sense;
73 priv->sor.power = nv50_sor_power;
74 priv->sor.hda_eld = nvd0_hda_eld;
75 priv->sor.hdmi = nvd0_hdmi_ctrl;
76 priv->sor.dp = &nvd0_sor_dp_func;
77 return 0;
78 }
79
80 struct nouveau_oclass
81 nvf0_disp_oclass = {
82 .handle = NV_ENGINE(DISP, 0x92),
83 .ofuncs = &(struct nouveau_ofuncs) {
84 .ctor = nvf0_disp_ctor,
85 .dtor = _nouveau_disp_dtor,
86 .init = _nouveau_disp_init,
87 .fini = _nouveau_disp_fini,
88 },
89 };
90
drivers/gpu/drm/nouveau/core/engine/dmaobj/nvd0.c
1 /* 1 /*
2 * Copyright 2012 Red Hat Inc. 2 * Copyright 2012 Red Hat Inc.
3 * 3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a 4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"), 5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation 6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the 8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions: 9 * Software is furnished to do so, subject to the following conditions:
10 * 10 *
11 * The above copyright notice and this permission notice shall be included in 11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software. 12 * all copies or substantial portions of the Software.
13 * 13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE. 20 * OTHER DEALINGS IN THE SOFTWARE.
21 * 21 *
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24 24
25 #include <core/device.h> 25 #include <core/device.h>
26 #include <core/gpuobj.h> 26 #include <core/gpuobj.h>
27 #include <core/class.h> 27 #include <core/class.h>
28 28
29 #include <subdev/fb.h> 29 #include <subdev/fb.h>
30 #include <engine/dmaobj.h> 30 #include <engine/dmaobj.h>
31 31
32 struct nvd0_dmaeng_priv { 32 struct nvd0_dmaeng_priv {
33 struct nouveau_dmaeng base; 33 struct nouveau_dmaeng base;
34 }; 34 };
35 35
36 static int 36 static int
37 nvd0_dmaobj_bind(struct nouveau_dmaeng *dmaeng, 37 nvd0_dmaobj_bind(struct nouveau_dmaeng *dmaeng,
38 struct nouveau_object *parent, 38 struct nouveau_object *parent,
39 struct nouveau_dmaobj *dmaobj, 39 struct nouveau_dmaobj *dmaobj,
40 struct nouveau_gpuobj **pgpuobj) 40 struct nouveau_gpuobj **pgpuobj)
41 { 41 {
42 u32 flags0 = 0x00000000; 42 u32 flags0 = 0x00000000;
43 int ret; 43 int ret;
44 44
45 if (!nv_iclass(parent, NV_ENGCTX_CLASS)) { 45 if (!nv_iclass(parent, NV_ENGCTX_CLASS)) {
46 switch (nv_mclass(parent->parent)) { 46 switch (nv_mclass(parent->parent)) {
47 case NVD0_DISP_MAST_CLASS: 47 case NVD0_DISP_MAST_CLASS:
48 case NVD0_DISP_SYNC_CLASS: 48 case NVD0_DISP_SYNC_CLASS:
49 case NVD0_DISP_OVLY_CLASS: 49 case NVD0_DISP_OVLY_CLASS:
50 case NVE0_DISP_MAST_CLASS: 50 case NVE0_DISP_MAST_CLASS:
51 case NVE0_DISP_SYNC_CLASS: 51 case NVE0_DISP_SYNC_CLASS:
52 case NVE0_DISP_OVLY_CLASS: 52 case NVE0_DISP_OVLY_CLASS:
53 case NVF0_DISP_MAST_CLASS:
54 case NVF0_DISP_SYNC_CLASS:
55 case NVF0_DISP_OVLY_CLASS:
53 break; 56 break;
54 default: 57 default:
55 return -EINVAL; 58 return -EINVAL;
56 } 59 }
57 } else 60 } else
58 return 0; 61 return 0;
59 62
60 if (!(dmaobj->conf0 & NVD0_DMA_CONF0_ENABLE)) { 63 if (!(dmaobj->conf0 & NVD0_DMA_CONF0_ENABLE)) {
61 if (dmaobj->target == NV_MEM_TARGET_VM) { 64 if (dmaobj->target == NV_MEM_TARGET_VM) {
62 dmaobj->conf0 |= NVD0_DMA_CONF0_TYPE_VM; 65 dmaobj->conf0 |= NVD0_DMA_CONF0_TYPE_VM;
63 dmaobj->conf0 |= NVD0_DMA_CONF0_PAGE_LP; 66 dmaobj->conf0 |= NVD0_DMA_CONF0_PAGE_LP;
64 } else { 67 } else {
65 dmaobj->conf0 |= NVD0_DMA_CONF0_TYPE_LINEAR; 68 dmaobj->conf0 |= NVD0_DMA_CONF0_TYPE_LINEAR;
66 dmaobj->conf0 |= NVD0_DMA_CONF0_PAGE_SP; 69 dmaobj->conf0 |= NVD0_DMA_CONF0_PAGE_SP;
67 } 70 }
68 } 71 }
69 72
70 flags0 |= (dmaobj->conf0 & NVD0_DMA_CONF0_TYPE) << 20; 73 flags0 |= (dmaobj->conf0 & NVD0_DMA_CONF0_TYPE) << 20;
71 flags0 |= (dmaobj->conf0 & NVD0_DMA_CONF0_PAGE) >> 4; 74 flags0 |= (dmaobj->conf0 & NVD0_DMA_CONF0_PAGE) >> 4;
72 75
73 switch (dmaobj->target) { 76 switch (dmaobj->target) {
74 case NV_MEM_TARGET_VRAM: 77 case NV_MEM_TARGET_VRAM:
75 flags0 |= 0x00000009; 78 flags0 |= 0x00000009;
76 break; 79 break;
77 default: 80 default:
78 return -EINVAL; 81 return -EINVAL;
79 break; 82 break;
80 } 83 }
81 84
82 ret = nouveau_gpuobj_new(parent, parent, 24, 32, 0, pgpuobj); 85 ret = nouveau_gpuobj_new(parent, parent, 24, 32, 0, pgpuobj);
83 if (ret == 0) { 86 if (ret == 0) {
84 nv_wo32(*pgpuobj, 0x00, flags0); 87 nv_wo32(*pgpuobj, 0x00, flags0);
85 nv_wo32(*pgpuobj, 0x04, dmaobj->start >> 8); 88 nv_wo32(*pgpuobj, 0x04, dmaobj->start >> 8);
86 nv_wo32(*pgpuobj, 0x08, dmaobj->limit >> 8); 89 nv_wo32(*pgpuobj, 0x08, dmaobj->limit >> 8);
87 nv_wo32(*pgpuobj, 0x0c, 0x00000000); 90 nv_wo32(*pgpuobj, 0x0c, 0x00000000);
88 nv_wo32(*pgpuobj, 0x10, 0x00000000); 91 nv_wo32(*pgpuobj, 0x10, 0x00000000);
89 nv_wo32(*pgpuobj, 0x14, 0x00000000); 92 nv_wo32(*pgpuobj, 0x14, 0x00000000);
90 } 93 }
91 94
92 return ret; 95 return ret;
93 } 96 }
94 97
95 static int 98 static int
96 nvd0_dmaeng_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 99 nvd0_dmaeng_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
97 struct nouveau_oclass *oclass, void *data, u32 size, 100 struct nouveau_oclass *oclass, void *data, u32 size,
98 struct nouveau_object **pobject) 101 struct nouveau_object **pobject)
99 { 102 {
100 struct nvd0_dmaeng_priv *priv; 103 struct nvd0_dmaeng_priv *priv;
101 int ret; 104 int ret;
102 105
103 ret = nouveau_dmaeng_create(parent, engine, oclass, &priv); 106 ret = nouveau_dmaeng_create(parent, engine, oclass, &priv);
104 *pobject = nv_object(priv); 107 *pobject = nv_object(priv);
105 if (ret) 108 if (ret)
106 return ret; 109 return ret;
107 110
108 nv_engine(priv)->sclass = nouveau_dmaobj_sclass; 111 nv_engine(priv)->sclass = nouveau_dmaobj_sclass;
109 priv->base.bind = nvd0_dmaobj_bind; 112 priv->base.bind = nvd0_dmaobj_bind;
110 return 0; 113 return 0;
111 } 114 }
112 115
113 struct nouveau_oclass 116 struct nouveau_oclass
114 nvd0_dmaeng_oclass = { 117 nvd0_dmaeng_oclass = {
115 .handle = NV_ENGINE(DMAOBJ, 0xd0), 118 .handle = NV_ENGINE(DMAOBJ, 0xd0),
116 .ofuncs = &(struct nouveau_ofuncs) { 119 .ofuncs = &(struct nouveau_ofuncs) {
117 .ctor = nvd0_dmaeng_ctor, 120 .ctor = nvd0_dmaeng_ctor,
118 .dtor = _nouveau_dmaeng_dtor, 121 .dtor = _nouveau_dmaeng_dtor,
119 .init = _nouveau_dmaeng_init, 122 .init = _nouveau_dmaeng_init,
120 .fini = _nouveau_dmaeng_fini, 123 .fini = _nouveau_dmaeng_fini,
121 }, 124 },
122 }; 125 };
123 126
drivers/gpu/drm/nouveau/core/include/core/class.h
1 #ifndef __NOUVEAU_CLASS_H__ 1 #ifndef __NOUVEAU_CLASS_H__
2 #define __NOUVEAU_CLASS_H__ 2 #define __NOUVEAU_CLASS_H__
3 3
4 /* Device class 4 /* Device class
5 * 5 *
6 * 0080: NV_DEVICE 6 * 0080: NV_DEVICE
7 */ 7 */
8 #define NV_DEVICE_CLASS 0x00000080 8 #define NV_DEVICE_CLASS 0x00000080
9 9
10 #define NV_DEVICE_DISABLE_IDENTIFY 0x0000000000000001ULL 10 #define NV_DEVICE_DISABLE_IDENTIFY 0x0000000000000001ULL
11 #define NV_DEVICE_DISABLE_MMIO 0x0000000000000002ULL 11 #define NV_DEVICE_DISABLE_MMIO 0x0000000000000002ULL
12 #define NV_DEVICE_DISABLE_VBIOS 0x0000000000000004ULL 12 #define NV_DEVICE_DISABLE_VBIOS 0x0000000000000004ULL
13 #define NV_DEVICE_DISABLE_CORE 0x0000000000000008ULL 13 #define NV_DEVICE_DISABLE_CORE 0x0000000000000008ULL
14 #define NV_DEVICE_DISABLE_DISP 0x0000000000010000ULL 14 #define NV_DEVICE_DISABLE_DISP 0x0000000000010000ULL
15 #define NV_DEVICE_DISABLE_FIFO 0x0000000000020000ULL 15 #define NV_DEVICE_DISABLE_FIFO 0x0000000000020000ULL
16 #define NV_DEVICE_DISABLE_GRAPH 0x0000000100000000ULL 16 #define NV_DEVICE_DISABLE_GRAPH 0x0000000100000000ULL
17 #define NV_DEVICE_DISABLE_MPEG 0x0000000200000000ULL 17 #define NV_DEVICE_DISABLE_MPEG 0x0000000200000000ULL
18 #define NV_DEVICE_DISABLE_ME 0x0000000400000000ULL 18 #define NV_DEVICE_DISABLE_ME 0x0000000400000000ULL
19 #define NV_DEVICE_DISABLE_VP 0x0000000800000000ULL 19 #define NV_DEVICE_DISABLE_VP 0x0000000800000000ULL
20 #define NV_DEVICE_DISABLE_CRYPT 0x0000001000000000ULL 20 #define NV_DEVICE_DISABLE_CRYPT 0x0000001000000000ULL
21 #define NV_DEVICE_DISABLE_BSP 0x0000002000000000ULL 21 #define NV_DEVICE_DISABLE_BSP 0x0000002000000000ULL
22 #define NV_DEVICE_DISABLE_PPP 0x0000004000000000ULL 22 #define NV_DEVICE_DISABLE_PPP 0x0000004000000000ULL
23 #define NV_DEVICE_DISABLE_COPY0 0x0000008000000000ULL 23 #define NV_DEVICE_DISABLE_COPY0 0x0000008000000000ULL
24 #define NV_DEVICE_DISABLE_COPY1 0x0000010000000000ULL 24 #define NV_DEVICE_DISABLE_COPY1 0x0000010000000000ULL
25 #define NV_DEVICE_DISABLE_UNK1C1 0x0000020000000000ULL 25 #define NV_DEVICE_DISABLE_UNK1C1 0x0000020000000000ULL
26 #define NV_DEVICE_DISABLE_VENC 0x0000040000000000ULL 26 #define NV_DEVICE_DISABLE_VENC 0x0000040000000000ULL
27 27
28 struct nv_device_class { 28 struct nv_device_class {
29 u64 device; /* device identifier, ~0 for client default */ 29 u64 device; /* device identifier, ~0 for client default */
30 u64 disable; /* disable particular subsystems */ 30 u64 disable; /* disable particular subsystems */
31 u64 debug0; /* as above, but *internal* ids, and *NOT* ABI */ 31 u64 debug0; /* as above, but *internal* ids, and *NOT* ABI */
32 }; 32 };
33 33
34 /* DMA object classes 34 /* DMA object classes
35 * 35 *
36 * 0002: NV_DMA_FROM_MEMORY 36 * 0002: NV_DMA_FROM_MEMORY
37 * 0003: NV_DMA_TO_MEMORY 37 * 0003: NV_DMA_TO_MEMORY
38 * 003d: NV_DMA_IN_MEMORY 38 * 003d: NV_DMA_IN_MEMORY
39 */ 39 */
40 #define NV_DMA_FROM_MEMORY_CLASS 0x00000002 40 #define NV_DMA_FROM_MEMORY_CLASS 0x00000002
41 #define NV_DMA_TO_MEMORY_CLASS 0x00000003 41 #define NV_DMA_TO_MEMORY_CLASS 0x00000003
42 #define NV_DMA_IN_MEMORY_CLASS 0x0000003d 42 #define NV_DMA_IN_MEMORY_CLASS 0x0000003d
43 43
44 #define NV_DMA_TARGET_MASK 0x000000ff 44 #define NV_DMA_TARGET_MASK 0x000000ff
45 #define NV_DMA_TARGET_VM 0x00000000 45 #define NV_DMA_TARGET_VM 0x00000000
46 #define NV_DMA_TARGET_VRAM 0x00000001 46 #define NV_DMA_TARGET_VRAM 0x00000001
47 #define NV_DMA_TARGET_PCI 0x00000002 47 #define NV_DMA_TARGET_PCI 0x00000002
48 #define NV_DMA_TARGET_PCI_US 0x00000003 48 #define NV_DMA_TARGET_PCI_US 0x00000003
49 #define NV_DMA_TARGET_AGP 0x00000004 49 #define NV_DMA_TARGET_AGP 0x00000004
50 #define NV_DMA_ACCESS_MASK 0x00000f00 50 #define NV_DMA_ACCESS_MASK 0x00000f00
51 #define NV_DMA_ACCESS_VM 0x00000000 51 #define NV_DMA_ACCESS_VM 0x00000000
52 #define NV_DMA_ACCESS_RD 0x00000100 52 #define NV_DMA_ACCESS_RD 0x00000100
53 #define NV_DMA_ACCESS_WR 0x00000200 53 #define NV_DMA_ACCESS_WR 0x00000200
54 #define NV_DMA_ACCESS_RDWR 0x00000300 54 #define NV_DMA_ACCESS_RDWR 0x00000300
55 55
56 /* NV50:NVC0 */ 56 /* NV50:NVC0 */
57 #define NV50_DMA_CONF0_ENABLE 0x80000000 57 #define NV50_DMA_CONF0_ENABLE 0x80000000
58 #define NV50_DMA_CONF0_PRIV 0x00300000 58 #define NV50_DMA_CONF0_PRIV 0x00300000
59 #define NV50_DMA_CONF0_PRIV_VM 0x00000000 59 #define NV50_DMA_CONF0_PRIV_VM 0x00000000
60 #define NV50_DMA_CONF0_PRIV_US 0x00100000 60 #define NV50_DMA_CONF0_PRIV_US 0x00100000
61 #define NV50_DMA_CONF0_PRIV__S 0x00200000 61 #define NV50_DMA_CONF0_PRIV__S 0x00200000
62 #define NV50_DMA_CONF0_PART 0x00030000 62 #define NV50_DMA_CONF0_PART 0x00030000
63 #define NV50_DMA_CONF0_PART_VM 0x00000000 63 #define NV50_DMA_CONF0_PART_VM 0x00000000
64 #define NV50_DMA_CONF0_PART_256 0x00010000 64 #define NV50_DMA_CONF0_PART_256 0x00010000
65 #define NV50_DMA_CONF0_PART_1KB 0x00020000 65 #define NV50_DMA_CONF0_PART_1KB 0x00020000
66 #define NV50_DMA_CONF0_COMP 0x00000180 66 #define NV50_DMA_CONF0_COMP 0x00000180
67 #define NV50_DMA_CONF0_COMP_NONE 0x00000000 67 #define NV50_DMA_CONF0_COMP_NONE 0x00000000
68 #define NV50_DMA_CONF0_COMP_VM 0x00000180 68 #define NV50_DMA_CONF0_COMP_VM 0x00000180
69 #define NV50_DMA_CONF0_TYPE 0x0000007f 69 #define NV50_DMA_CONF0_TYPE 0x0000007f
70 #define NV50_DMA_CONF0_TYPE_LINEAR 0x00000000 70 #define NV50_DMA_CONF0_TYPE_LINEAR 0x00000000
71 #define NV50_DMA_CONF0_TYPE_VM 0x0000007f 71 #define NV50_DMA_CONF0_TYPE_VM 0x0000007f
72 72
73 /* NVC0:NVD9 */ 73 /* NVC0:NVD9 */
74 #define NVC0_DMA_CONF0_ENABLE 0x80000000 74 #define NVC0_DMA_CONF0_ENABLE 0x80000000
75 #define NVC0_DMA_CONF0_PRIV 0x00300000 75 #define NVC0_DMA_CONF0_PRIV 0x00300000
76 #define NVC0_DMA_CONF0_PRIV_VM 0x00000000 76 #define NVC0_DMA_CONF0_PRIV_VM 0x00000000
77 #define NVC0_DMA_CONF0_PRIV_US 0x00100000 77 #define NVC0_DMA_CONF0_PRIV_US 0x00100000
78 #define NVC0_DMA_CONF0_PRIV__S 0x00200000 78 #define NVC0_DMA_CONF0_PRIV__S 0x00200000
79 #define NVC0_DMA_CONF0_UNKN /* PART? */ 0x00030000 79 #define NVC0_DMA_CONF0_UNKN /* PART? */ 0x00030000
80 #define NVC0_DMA_CONF0_TYPE 0x000000ff 80 #define NVC0_DMA_CONF0_TYPE 0x000000ff
81 #define NVC0_DMA_CONF0_TYPE_LINEAR 0x00000000 81 #define NVC0_DMA_CONF0_TYPE_LINEAR 0x00000000
82 #define NVC0_DMA_CONF0_TYPE_VM 0x000000ff 82 #define NVC0_DMA_CONF0_TYPE_VM 0x000000ff
83 83
84 /* NVD9- */ 84 /* NVD9- */
85 #define NVD0_DMA_CONF0_ENABLE 0x80000000 85 #define NVD0_DMA_CONF0_ENABLE 0x80000000
86 #define NVD0_DMA_CONF0_PAGE 0x00000400 86 #define NVD0_DMA_CONF0_PAGE 0x00000400
87 #define NVD0_DMA_CONF0_PAGE_LP 0x00000000 87 #define NVD0_DMA_CONF0_PAGE_LP 0x00000000
88 #define NVD0_DMA_CONF0_PAGE_SP 0x00000400 88 #define NVD0_DMA_CONF0_PAGE_SP 0x00000400
89 #define NVD0_DMA_CONF0_TYPE 0x000000ff 89 #define NVD0_DMA_CONF0_TYPE 0x000000ff
90 #define NVD0_DMA_CONF0_TYPE_LINEAR 0x00000000 90 #define NVD0_DMA_CONF0_TYPE_LINEAR 0x00000000
91 #define NVD0_DMA_CONF0_TYPE_VM 0x000000ff 91 #define NVD0_DMA_CONF0_TYPE_VM 0x000000ff
92 92
93 struct nv_dma_class { 93 struct nv_dma_class {
94 u32 flags; 94 u32 flags;
95 u32 pad0; 95 u32 pad0;
96 u64 start; 96 u64 start;
97 u64 limit; 97 u64 limit;
98 u32 conf0; 98 u32 conf0;
99 }; 99 };
100 100
101 /* DMA FIFO channel classes 101 /* DMA FIFO channel classes
102 * 102 *
103 * 006b: NV03_CHANNEL_DMA 103 * 006b: NV03_CHANNEL_DMA
104 * 006e: NV10_CHANNEL_DMA 104 * 006e: NV10_CHANNEL_DMA
105 * 176e: NV17_CHANNEL_DMA 105 * 176e: NV17_CHANNEL_DMA
106 * 406e: NV40_CHANNEL_DMA 106 * 406e: NV40_CHANNEL_DMA
107 * 506e: NV50_CHANNEL_DMA 107 * 506e: NV50_CHANNEL_DMA
108 * 826e: NV84_CHANNEL_DMA 108 * 826e: NV84_CHANNEL_DMA
109 */ 109 */
110 #define NV03_CHANNEL_DMA_CLASS 0x0000006b 110 #define NV03_CHANNEL_DMA_CLASS 0x0000006b
111 #define NV10_CHANNEL_DMA_CLASS 0x0000006e 111 #define NV10_CHANNEL_DMA_CLASS 0x0000006e
112 #define NV17_CHANNEL_DMA_CLASS 0x0000176e 112 #define NV17_CHANNEL_DMA_CLASS 0x0000176e
113 #define NV40_CHANNEL_DMA_CLASS 0x0000406e 113 #define NV40_CHANNEL_DMA_CLASS 0x0000406e
114 #define NV50_CHANNEL_DMA_CLASS 0x0000506e 114 #define NV50_CHANNEL_DMA_CLASS 0x0000506e
115 #define NV84_CHANNEL_DMA_CLASS 0x0000826e 115 #define NV84_CHANNEL_DMA_CLASS 0x0000826e
116 116
117 struct nv03_channel_dma_class { 117 struct nv03_channel_dma_class {
118 u32 pushbuf; 118 u32 pushbuf;
119 u32 pad0; 119 u32 pad0;
120 u64 offset; 120 u64 offset;
121 }; 121 };
122 122
123 /* Indirect FIFO channel classes 123 /* Indirect FIFO channel classes
124 * 124 *
125 * 506f: NV50_CHANNEL_IND 125 * 506f: NV50_CHANNEL_IND
126 * 826f: NV84_CHANNEL_IND 126 * 826f: NV84_CHANNEL_IND
127 * 906f: NVC0_CHANNEL_IND 127 * 906f: NVC0_CHANNEL_IND
128 * a06f: NVE0_CHANNEL_IND 128 * a06f: NVE0_CHANNEL_IND
129 */ 129 */
130 130
131 #define NV50_CHANNEL_IND_CLASS 0x0000506f 131 #define NV50_CHANNEL_IND_CLASS 0x0000506f
132 #define NV84_CHANNEL_IND_CLASS 0x0000826f 132 #define NV84_CHANNEL_IND_CLASS 0x0000826f
133 #define NVC0_CHANNEL_IND_CLASS 0x0000906f 133 #define NVC0_CHANNEL_IND_CLASS 0x0000906f
134 #define NVE0_CHANNEL_IND_CLASS 0x0000a06f 134 #define NVE0_CHANNEL_IND_CLASS 0x0000a06f
135 135
136 struct nv50_channel_ind_class { 136 struct nv50_channel_ind_class {
137 u32 pushbuf; 137 u32 pushbuf;
138 u32 ilength; 138 u32 ilength;
139 u64 ioffset; 139 u64 ioffset;
140 }; 140 };
141 141
142 #define NVE0_CHANNEL_IND_ENGINE_GR 0x00000001 142 #define NVE0_CHANNEL_IND_ENGINE_GR 0x00000001
143 #define NVE0_CHANNEL_IND_ENGINE_VP 0x00000002 143 #define NVE0_CHANNEL_IND_ENGINE_VP 0x00000002
144 #define NVE0_CHANNEL_IND_ENGINE_PPP 0x00000004 144 #define NVE0_CHANNEL_IND_ENGINE_PPP 0x00000004
145 #define NVE0_CHANNEL_IND_ENGINE_BSP 0x00000008 145 #define NVE0_CHANNEL_IND_ENGINE_BSP 0x00000008
146 #define NVE0_CHANNEL_IND_ENGINE_CE0 0x00000010 146 #define NVE0_CHANNEL_IND_ENGINE_CE0 0x00000010
147 #define NVE0_CHANNEL_IND_ENGINE_CE1 0x00000020 147 #define NVE0_CHANNEL_IND_ENGINE_CE1 0x00000020
148 #define NVE0_CHANNEL_IND_ENGINE_ENC 0x00000040 148 #define NVE0_CHANNEL_IND_ENGINE_ENC 0x00000040
149 149
150 struct nve0_channel_ind_class { 150 struct nve0_channel_ind_class {
151 u32 pushbuf; 151 u32 pushbuf;
152 u32 ilength; 152 u32 ilength;
153 u64 ioffset; 153 u64 ioffset;
154 u32 engine; 154 u32 engine;
155 }; 155 };
156 156
157 /* 0046: NV04_DISP 157 /* 0046: NV04_DISP
158 */ 158 */
159 159
160 #define NV04_DISP_CLASS 0x00000046 160 #define NV04_DISP_CLASS 0x00000046
161 161
162 struct nv04_display_class { 162 struct nv04_display_class {
163 }; 163 };
164 164
165 /* 5070: NV50_DISP 165 /* 5070: NV50_DISP
166 * 8270: NV84_DISP 166 * 8270: NV84_DISP
167 * 8370: NVA0_DISP 167 * 8370: NVA0_DISP
168 * 8870: NV94_DISP 168 * 8870: NV94_DISP
169 * 8570: NVA3_DISP 169 * 8570: NVA3_DISP
170 * 9070: NVD0_DISP 170 * 9070: NVD0_DISP
171 * 9170: NVE0_DISP 171 * 9170: NVE0_DISP
172 * 9270: NVF0_DISP
172 */ 173 */
173 174
174 #define NV50_DISP_CLASS 0x00005070 175 #define NV50_DISP_CLASS 0x00005070
175 #define NV84_DISP_CLASS 0x00008270 176 #define NV84_DISP_CLASS 0x00008270
176 #define NVA0_DISP_CLASS 0x00008370 177 #define NVA0_DISP_CLASS 0x00008370
177 #define NV94_DISP_CLASS 0x00008870 178 #define NV94_DISP_CLASS 0x00008870
178 #define NVA3_DISP_CLASS 0x00008570 179 #define NVA3_DISP_CLASS 0x00008570
179 #define NVD0_DISP_CLASS 0x00009070 180 #define NVD0_DISP_CLASS 0x00009070
180 #define NVE0_DISP_CLASS 0x00009170 181 #define NVE0_DISP_CLASS 0x00009170
182 #define NVF0_DISP_CLASS 0x00009270
181 183
182 #define NV50_DISP_SOR_MTHD 0x00010000 184 #define NV50_DISP_SOR_MTHD 0x00010000
183 #define NV50_DISP_SOR_MTHD_TYPE 0x0000f000 185 #define NV50_DISP_SOR_MTHD_TYPE 0x0000f000
184 #define NV50_DISP_SOR_MTHD_HEAD 0x00000018 186 #define NV50_DISP_SOR_MTHD_HEAD 0x00000018
185 #define NV50_DISP_SOR_MTHD_LINK 0x00000004 187 #define NV50_DISP_SOR_MTHD_LINK 0x00000004
186 #define NV50_DISP_SOR_MTHD_OR 0x00000003 188 #define NV50_DISP_SOR_MTHD_OR 0x00000003
187 189
188 #define NV50_DISP_SOR_PWR 0x00010000 190 #define NV50_DISP_SOR_PWR 0x00010000
189 #define NV50_DISP_SOR_PWR_STATE 0x00000001 191 #define NV50_DISP_SOR_PWR_STATE 0x00000001
190 #define NV50_DISP_SOR_PWR_STATE_ON 0x00000001 192 #define NV50_DISP_SOR_PWR_STATE_ON 0x00000001
191 #define NV50_DISP_SOR_PWR_STATE_OFF 0x00000000 193 #define NV50_DISP_SOR_PWR_STATE_OFF 0x00000000
192 #define NVA3_DISP_SOR_HDA_ELD 0x00010100 194 #define NVA3_DISP_SOR_HDA_ELD 0x00010100
193 #define NV84_DISP_SOR_HDMI_PWR 0x00012000 195 #define NV84_DISP_SOR_HDMI_PWR 0x00012000
194 #define NV84_DISP_SOR_HDMI_PWR_STATE 0x40000000 196 #define NV84_DISP_SOR_HDMI_PWR_STATE 0x40000000
195 #define NV84_DISP_SOR_HDMI_PWR_STATE_OFF 0x00000000 197 #define NV84_DISP_SOR_HDMI_PWR_STATE_OFF 0x00000000
196 #define NV84_DISP_SOR_HDMI_PWR_STATE_ON 0x40000000 198 #define NV84_DISP_SOR_HDMI_PWR_STATE_ON 0x40000000
197 #define NV84_DISP_SOR_HDMI_PWR_MAX_AC_PACKET 0x001f0000 199 #define NV84_DISP_SOR_HDMI_PWR_MAX_AC_PACKET 0x001f0000
198 #define NV84_DISP_SOR_HDMI_PWR_REKEY 0x0000007f 200 #define NV84_DISP_SOR_HDMI_PWR_REKEY 0x0000007f
199 #define NV50_DISP_SOR_LVDS_SCRIPT 0x00013000 201 #define NV50_DISP_SOR_LVDS_SCRIPT 0x00013000
200 #define NV50_DISP_SOR_LVDS_SCRIPT_ID 0x0000ffff 202 #define NV50_DISP_SOR_LVDS_SCRIPT_ID 0x0000ffff
201 203
202 #define NV50_DISP_DAC_MTHD 0x00020000 204 #define NV50_DISP_DAC_MTHD 0x00020000
203 #define NV50_DISP_DAC_MTHD_TYPE 0x0000f000 205 #define NV50_DISP_DAC_MTHD_TYPE 0x0000f000
204 #define NV50_DISP_DAC_MTHD_OR 0x00000003 206 #define NV50_DISP_DAC_MTHD_OR 0x00000003
205 207
206 #define NV50_DISP_DAC_PWR 0x00020000 208 #define NV50_DISP_DAC_PWR 0x00020000
207 #define NV50_DISP_DAC_PWR_HSYNC 0x00000001 209 #define NV50_DISP_DAC_PWR_HSYNC 0x00000001
208 #define NV50_DISP_DAC_PWR_HSYNC_ON 0x00000000 210 #define NV50_DISP_DAC_PWR_HSYNC_ON 0x00000000
209 #define NV50_DISP_DAC_PWR_HSYNC_LO 0x00000001 211 #define NV50_DISP_DAC_PWR_HSYNC_LO 0x00000001
210 #define NV50_DISP_DAC_PWR_VSYNC 0x00000004 212 #define NV50_DISP_DAC_PWR_VSYNC 0x00000004
211 #define NV50_DISP_DAC_PWR_VSYNC_ON 0x00000000 213 #define NV50_DISP_DAC_PWR_VSYNC_ON 0x00000000
212 #define NV50_DISP_DAC_PWR_VSYNC_LO 0x00000004 214 #define NV50_DISP_DAC_PWR_VSYNC_LO 0x00000004
213 #define NV50_DISP_DAC_PWR_DATA 0x00000010 215 #define NV50_DISP_DAC_PWR_DATA 0x00000010
214 #define NV50_DISP_DAC_PWR_DATA_ON 0x00000000 216 #define NV50_DISP_DAC_PWR_DATA_ON 0x00000000
215 #define NV50_DISP_DAC_PWR_DATA_LO 0x00000010 217 #define NV50_DISP_DAC_PWR_DATA_LO 0x00000010
216 #define NV50_DISP_DAC_PWR_STATE 0x00000040 218 #define NV50_DISP_DAC_PWR_STATE 0x00000040
217 #define NV50_DISP_DAC_PWR_STATE_ON 0x00000000 219 #define NV50_DISP_DAC_PWR_STATE_ON 0x00000000
218 #define NV50_DISP_DAC_PWR_STATE_OFF 0x00000040 220 #define NV50_DISP_DAC_PWR_STATE_OFF 0x00000040
219 #define NV50_DISP_DAC_LOAD 0x0002000c 221 #define NV50_DISP_DAC_LOAD 0x0002000c
220 #define NV50_DISP_DAC_LOAD_VALUE 0x00000007 222 #define NV50_DISP_DAC_LOAD_VALUE 0x00000007
221 223
222 #define NV50_DISP_PIOR_MTHD 0x00030000 224 #define NV50_DISP_PIOR_MTHD 0x00030000
223 #define NV50_DISP_PIOR_MTHD_TYPE 0x0000f000 225 #define NV50_DISP_PIOR_MTHD_TYPE 0x0000f000
224 #define NV50_DISP_PIOR_MTHD_OR 0x00000003 226 #define NV50_DISP_PIOR_MTHD_OR 0x00000003
225 227
226 #define NV50_DISP_PIOR_PWR 0x00030000 228 #define NV50_DISP_PIOR_PWR 0x00030000
227 #define NV50_DISP_PIOR_PWR_STATE 0x00000001 229 #define NV50_DISP_PIOR_PWR_STATE 0x00000001
228 #define NV50_DISP_PIOR_PWR_STATE_ON 0x00000001 230 #define NV50_DISP_PIOR_PWR_STATE_ON 0x00000001
229 #define NV50_DISP_PIOR_PWR_STATE_OFF 0x00000000 231 #define NV50_DISP_PIOR_PWR_STATE_OFF 0x00000000
230 #define NV50_DISP_PIOR_TMDS_PWR 0x00032000 232 #define NV50_DISP_PIOR_TMDS_PWR 0x00032000
231 #define NV50_DISP_PIOR_TMDS_PWR_STATE 0x00000001 233 #define NV50_DISP_PIOR_TMDS_PWR_STATE 0x00000001
232 #define NV50_DISP_PIOR_TMDS_PWR_STATE_ON 0x00000001 234 #define NV50_DISP_PIOR_TMDS_PWR_STATE_ON 0x00000001
233 #define NV50_DISP_PIOR_TMDS_PWR_STATE_OFF 0x00000000 235 #define NV50_DISP_PIOR_TMDS_PWR_STATE_OFF 0x00000000
234 #define NV50_DISP_PIOR_DP_PWR 0x00036000 236 #define NV50_DISP_PIOR_DP_PWR 0x00036000
235 #define NV50_DISP_PIOR_DP_PWR_STATE 0x00000001 237 #define NV50_DISP_PIOR_DP_PWR_STATE 0x00000001
236 #define NV50_DISP_PIOR_DP_PWR_STATE_ON 0x00000001 238 #define NV50_DISP_PIOR_DP_PWR_STATE_ON 0x00000001
237 #define NV50_DISP_PIOR_DP_PWR_STATE_OFF 0x00000000 239 #define NV50_DISP_PIOR_DP_PWR_STATE_OFF 0x00000000
238 240
239 struct nv50_display_class { 241 struct nv50_display_class {
240 }; 242 };
241 243
242 /* 507a: NV50_DISP_CURS 244 /* 507a: NV50_DISP_CURS
243 * 827a: NV84_DISP_CURS 245 * 827a: NV84_DISP_CURS
244 * 837a: NVA0_DISP_CURS 246 * 837a: NVA0_DISP_CURS
245 * 887a: NV94_DISP_CURS 247 * 887a: NV94_DISP_CURS
246 * 857a: NVA3_DISP_CURS 248 * 857a: NVA3_DISP_CURS
247 * 907a: NVD0_DISP_CURS 249 * 907a: NVD0_DISP_CURS
248 * 917a: NVE0_DISP_CURS 250 * 917a: NVE0_DISP_CURS
251 * 927a: NVF0_DISP_CURS
249 */ 252 */
250 253
251 #define NV50_DISP_CURS_CLASS 0x0000507a 254 #define NV50_DISP_CURS_CLASS 0x0000507a
252 #define NV84_DISP_CURS_CLASS 0x0000827a 255 #define NV84_DISP_CURS_CLASS 0x0000827a
253 #define NVA0_DISP_CURS_CLASS 0x0000837a 256 #define NVA0_DISP_CURS_CLASS 0x0000837a
254 #define NV94_DISP_CURS_CLASS 0x0000887a 257 #define NV94_DISP_CURS_CLASS 0x0000887a
255 #define NVA3_DISP_CURS_CLASS 0x0000857a 258 #define NVA3_DISP_CURS_CLASS 0x0000857a
256 #define NVD0_DISP_CURS_CLASS 0x0000907a 259 #define NVD0_DISP_CURS_CLASS 0x0000907a
257 #define NVE0_DISP_CURS_CLASS 0x0000917a 260 #define NVE0_DISP_CURS_CLASS 0x0000917a
261 #define NVF0_DISP_CURS_CLASS 0x0000927a
258 262
259 struct nv50_display_curs_class { 263 struct nv50_display_curs_class {
260 u32 head; 264 u32 head;
261 }; 265 };
262 266
263 /* 507b: NV50_DISP_OIMM 267 /* 507b: NV50_DISP_OIMM
264 * 827b: NV84_DISP_OIMM 268 * 827b: NV84_DISP_OIMM
265 * 837b: NVA0_DISP_OIMM 269 * 837b: NVA0_DISP_OIMM
266 * 887b: NV94_DISP_OIMM 270 * 887b: NV94_DISP_OIMM
267 * 857b: NVA3_DISP_OIMM 271 * 857b: NVA3_DISP_OIMM
268 * 907b: NVD0_DISP_OIMM 272 * 907b: NVD0_DISP_OIMM
269 * 917b: NVE0_DISP_OIMM 273 * 917b: NVE0_DISP_OIMM
274 * 927b: NVE0_DISP_OIMM
270 */ 275 */
271 276
272 #define NV50_DISP_OIMM_CLASS 0x0000507b 277 #define NV50_DISP_OIMM_CLASS 0x0000507b
273 #define NV84_DISP_OIMM_CLASS 0x0000827b 278 #define NV84_DISP_OIMM_CLASS 0x0000827b
274 #define NVA0_DISP_OIMM_CLASS 0x0000837b 279 #define NVA0_DISP_OIMM_CLASS 0x0000837b
275 #define NV94_DISP_OIMM_CLASS 0x0000887b 280 #define NV94_DISP_OIMM_CLASS 0x0000887b
276 #define NVA3_DISP_OIMM_CLASS 0x0000857b 281 #define NVA3_DISP_OIMM_CLASS 0x0000857b
277 #define NVD0_DISP_OIMM_CLASS 0x0000907b 282 #define NVD0_DISP_OIMM_CLASS 0x0000907b
278 #define NVE0_DISP_OIMM_CLASS 0x0000917b 283 #define NVE0_DISP_OIMM_CLASS 0x0000917b
284 #define NVF0_DISP_OIMM_CLASS 0x0000927b
279 285
280 struct nv50_display_oimm_class { 286 struct nv50_display_oimm_class {
281 u32 head; 287 u32 head;
282 }; 288 };
283 289
284 /* 507c: NV50_DISP_SYNC 290 /* 507c: NV50_DISP_SYNC
285 * 827c: NV84_DISP_SYNC 291 * 827c: NV84_DISP_SYNC
286 * 837c: NVA0_DISP_SYNC 292 * 837c: NVA0_DISP_SYNC
287 * 887c: NV94_DISP_SYNC 293 * 887c: NV94_DISP_SYNC
288 * 857c: NVA3_DISP_SYNC 294 * 857c: NVA3_DISP_SYNC
289 * 907c: NVD0_DISP_SYNC 295 * 907c: NVD0_DISP_SYNC
290 * 917c: NVE0_DISP_SYNC 296 * 917c: NVE0_DISP_SYNC
297 * 927c: NVF0_DISP_SYNC
291 */ 298 */
292 299
293 #define NV50_DISP_SYNC_CLASS 0x0000507c 300 #define NV50_DISP_SYNC_CLASS 0x0000507c
294 #define NV84_DISP_SYNC_CLASS 0x0000827c 301 #define NV84_DISP_SYNC_CLASS 0x0000827c
295 #define NVA0_DISP_SYNC_CLASS 0x0000837c 302 #define NVA0_DISP_SYNC_CLASS 0x0000837c
296 #define NV94_DISP_SYNC_CLASS 0x0000887c 303 #define NV94_DISP_SYNC_CLASS 0x0000887c
297 #define NVA3_DISP_SYNC_CLASS 0x0000857c 304 #define NVA3_DISP_SYNC_CLASS 0x0000857c
298 #define NVD0_DISP_SYNC_CLASS 0x0000907c 305 #define NVD0_DISP_SYNC_CLASS 0x0000907c
299 #define NVE0_DISP_SYNC_CLASS 0x0000917c 306 #define NVE0_DISP_SYNC_CLASS 0x0000917c
307 #define NVF0_DISP_SYNC_CLASS 0x0000927c
300 308
301 struct nv50_display_sync_class { 309 struct nv50_display_sync_class {
302 u32 pushbuf; 310 u32 pushbuf;
303 u32 head; 311 u32 head;
304 }; 312 };
305 313
306 /* 507d: NV50_DISP_MAST 314 /* 507d: NV50_DISP_MAST
307 * 827d: NV84_DISP_MAST 315 * 827d: NV84_DISP_MAST
308 * 837d: NVA0_DISP_MAST 316 * 837d: NVA0_DISP_MAST
309 * 887d: NV94_DISP_MAST 317 * 887d: NV94_DISP_MAST
310 * 857d: NVA3_DISP_MAST 318 * 857d: NVA3_DISP_MAST
311 * 907d: NVD0_DISP_MAST 319 * 907d: NVD0_DISP_MAST
312 * 917d: NVE0_DISP_MAST 320 * 917d: NVE0_DISP_MAST
321 * 927d: NVF0_DISP_MAST
313 */ 322 */
314 323
315 #define NV50_DISP_MAST_CLASS 0x0000507d 324 #define NV50_DISP_MAST_CLASS 0x0000507d
316 #define NV84_DISP_MAST_CLASS 0x0000827d 325 #define NV84_DISP_MAST_CLASS 0x0000827d
317 #define NVA0_DISP_MAST_CLASS 0x0000837d 326 #define NVA0_DISP_MAST_CLASS 0x0000837d
318 #define NV94_DISP_MAST_CLASS 0x0000887d 327 #define NV94_DISP_MAST_CLASS 0x0000887d
319 #define NVA3_DISP_MAST_CLASS 0x0000857d 328 #define NVA3_DISP_MAST_CLASS 0x0000857d
320 #define NVD0_DISP_MAST_CLASS 0x0000907d 329 #define NVD0_DISP_MAST_CLASS 0x0000907d
321 #define NVE0_DISP_MAST_CLASS 0x0000917d 330 #define NVE0_DISP_MAST_CLASS 0x0000917d
331 #define NVF0_DISP_MAST_CLASS 0x0000927d
322 332
323 struct nv50_display_mast_class { 333 struct nv50_display_mast_class {
324 u32 pushbuf; 334 u32 pushbuf;
325 }; 335 };
326 336
327 /* 507e: NV50_DISP_OVLY 337 /* 507e: NV50_DISP_OVLY
328 * 827e: NV84_DISP_OVLY 338 * 827e: NV84_DISP_OVLY
329 * 837e: NVA0_DISP_OVLY 339 * 837e: NVA0_DISP_OVLY
330 * 887e: NV94_DISP_OVLY 340 * 887e: NV94_DISP_OVLY
331 * 857e: NVA3_DISP_OVLY 341 * 857e: NVA3_DISP_OVLY
332 * 907e: NVD0_DISP_OVLY 342 * 907e: NVD0_DISP_OVLY
333 * 917e: NVE0_DISP_OVLY 343 * 917e: NVE0_DISP_OVLY
344 * 927e: NVF0_DISP_OVLY
334 */ 345 */
335 346
336 #define NV50_DISP_OVLY_CLASS 0x0000507e 347 #define NV50_DISP_OVLY_CLASS 0x0000507e
337 #define NV84_DISP_OVLY_CLASS 0x0000827e 348 #define NV84_DISP_OVLY_CLASS 0x0000827e
338 #define NVA0_DISP_OVLY_CLASS 0x0000837e 349 #define NVA0_DISP_OVLY_CLASS 0x0000837e
339 #define NV94_DISP_OVLY_CLASS 0x0000887e 350 #define NV94_DISP_OVLY_CLASS 0x0000887e
340 #define NVA3_DISP_OVLY_CLASS 0x0000857e 351 #define NVA3_DISP_OVLY_CLASS 0x0000857e
341 #define NVD0_DISP_OVLY_CLASS 0x0000907e 352 #define NVD0_DISP_OVLY_CLASS 0x0000907e
342 #define NVE0_DISP_OVLY_CLASS 0x0000917e 353 #define NVE0_DISP_OVLY_CLASS 0x0000917e
354 #define NVF0_DISP_OVLY_CLASS 0x0000927e
343 355
344 struct nv50_display_ovly_class { 356 struct nv50_display_ovly_class {
345 u32 pushbuf; 357 u32 pushbuf;
346 u32 head; 358 u32 head;
347 }; 359 };
348 360
349 #endif 361 #endif
350 362
drivers/gpu/drm/nouveau/core/include/engine/disp.h
1 #ifndef __NOUVEAU_DISP_H__ 1 #ifndef __NOUVEAU_DISP_H__
2 #define __NOUVEAU_DISP_H__ 2 #define __NOUVEAU_DISP_H__
3 3
4 #include <core/object.h> 4 #include <core/object.h>
5 #include <core/engine.h> 5 #include <core/engine.h>
6 #include <core/device.h> 6 #include <core/device.h>
7 #include <core/event.h> 7 #include <core/event.h>
8 8
9 struct nouveau_disp { 9 struct nouveau_disp {
10 struct nouveau_engine base; 10 struct nouveau_engine base;
11 struct nouveau_event *vblank; 11 struct nouveau_event *vblank;
12 }; 12 };
13 13
14 static inline struct nouveau_disp * 14 static inline struct nouveau_disp *
15 nouveau_disp(void *obj) 15 nouveau_disp(void *obj)
16 { 16 {
17 return (void *)nv_device(obj)->subdev[NVDEV_ENGINE_DISP]; 17 return (void *)nv_device(obj)->subdev[NVDEV_ENGINE_DISP];
18 } 18 }
19 19
20 #define nouveau_disp_create(p,e,c,h,i,x,d) \ 20 #define nouveau_disp_create(p,e,c,h,i,x,d) \
21 nouveau_disp_create_((p), (e), (c), (h), (i), (x), \ 21 nouveau_disp_create_((p), (e), (c), (h), (i), (x), \
22 sizeof(**d), (void **)d) 22 sizeof(**d), (void **)d)
23 #define nouveau_disp_destroy(d) ({ \ 23 #define nouveau_disp_destroy(d) ({ \
24 struct nouveau_disp *disp = (d); \ 24 struct nouveau_disp *disp = (d); \
25 _nouveau_disp_dtor(nv_object(disp)); \ 25 _nouveau_disp_dtor(nv_object(disp)); \
26 }) 26 })
27 #define nouveau_disp_init(d) \ 27 #define nouveau_disp_init(d) \
28 nouveau_engine_init(&(d)->base) 28 nouveau_engine_init(&(d)->base)
29 #define nouveau_disp_fini(d,s) \ 29 #define nouveau_disp_fini(d,s) \
30 nouveau_engine_fini(&(d)->base, (s)) 30 nouveau_engine_fini(&(d)->base, (s))
31 31
32 int nouveau_disp_create_(struct nouveau_object *, struct nouveau_object *, 32 int nouveau_disp_create_(struct nouveau_object *, struct nouveau_object *,
33 struct nouveau_oclass *, int heads, 33 struct nouveau_oclass *, int heads,
34 const char *, const char *, int, void **); 34 const char *, const char *, int, void **);
35 void _nouveau_disp_dtor(struct nouveau_object *); 35 void _nouveau_disp_dtor(struct nouveau_object *);
36 #define _nouveau_disp_init _nouveau_engine_init 36 #define _nouveau_disp_init _nouveau_engine_init
37 #define _nouveau_disp_fini _nouveau_engine_fini 37 #define _nouveau_disp_fini _nouveau_engine_fini
38 38
39 extern struct nouveau_oclass nv04_disp_oclass; 39 extern struct nouveau_oclass nv04_disp_oclass;
40 extern struct nouveau_oclass nv50_disp_oclass; 40 extern struct nouveau_oclass nv50_disp_oclass;
41 extern struct nouveau_oclass nv84_disp_oclass; 41 extern struct nouveau_oclass nv84_disp_oclass;
42 extern struct nouveau_oclass nva0_disp_oclass; 42 extern struct nouveau_oclass nva0_disp_oclass;
43 extern struct nouveau_oclass nv94_disp_oclass; 43 extern struct nouveau_oclass nv94_disp_oclass;
44 extern struct nouveau_oclass nva3_disp_oclass; 44 extern struct nouveau_oclass nva3_disp_oclass;
45 extern struct nouveau_oclass nvd0_disp_oclass; 45 extern struct nouveau_oclass nvd0_disp_oclass;
46 extern struct nouveau_oclass nve0_disp_oclass; 46 extern struct nouveau_oclass nve0_disp_oclass;
47 extern struct nouveau_oclass nvf0_disp_oclass;
47 48
48 #endif 49 #endif
49 50
drivers/gpu/drm/nouveau/nouveau_drm.c
1 /* 1 /*
2 * Copyright 2012 Red Hat Inc. 2 * Copyright 2012 Red Hat Inc.
3 * 3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a 4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"), 5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation 6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the 8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions: 9 * Software is furnished to do so, subject to the following conditions:
10 * 10 *
11 * The above copyright notice and this permission notice shall be included in 11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software. 12 * all copies or substantial portions of the Software.
13 * 13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE. 20 * OTHER DEALINGS IN THE SOFTWARE.
21 * 21 *
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24 24
25 #include <linux/console.h> 25 #include <linux/console.h>
26 #include <linux/module.h> 26 #include <linux/module.h>
27 #include <linux/pci.h> 27 #include <linux/pci.h>
28 28
29 #include <core/device.h> 29 #include <core/device.h>
30 #include <core/client.h> 30 #include <core/client.h>
31 #include <core/gpuobj.h> 31 #include <core/gpuobj.h>
32 #include <core/class.h> 32 #include <core/class.h>
33 33
34 #include <engine/device.h> 34 #include <engine/device.h>
35 #include <engine/disp.h> 35 #include <engine/disp.h>
36 #include <engine/fifo.h>
36 37
37 #include <subdev/vm.h> 38 #include <subdev/vm.h>
38 39
39 #include "nouveau_drm.h" 40 #include "nouveau_drm.h"
40 #include "nouveau_dma.h" 41 #include "nouveau_dma.h"
41 #include "nouveau_ttm.h" 42 #include "nouveau_ttm.h"
42 #include "nouveau_gem.h" 43 #include "nouveau_gem.h"
43 #include "nouveau_agp.h" 44 #include "nouveau_agp.h"
44 #include "nouveau_vga.h" 45 #include "nouveau_vga.h"
45 #include "nouveau_pm.h" 46 #include "nouveau_pm.h"
46 #include "nouveau_acpi.h" 47 #include "nouveau_acpi.h"
47 #include "nouveau_bios.h" 48 #include "nouveau_bios.h"
48 #include "nouveau_ioctl.h" 49 #include "nouveau_ioctl.h"
49 #include "nouveau_abi16.h" 50 #include "nouveau_abi16.h"
50 #include "nouveau_fbcon.h" 51 #include "nouveau_fbcon.h"
51 #include "nouveau_fence.h" 52 #include "nouveau_fence.h"
52 #include "nouveau_debugfs.h" 53 #include "nouveau_debugfs.h"
53 54
54 MODULE_PARM_DESC(config, "option string to pass to driver core"); 55 MODULE_PARM_DESC(config, "option string to pass to driver core");
55 static char *nouveau_config; 56 static char *nouveau_config;
56 module_param_named(config, nouveau_config, charp, 0400); 57 module_param_named(config, nouveau_config, charp, 0400);
57 58
58 MODULE_PARM_DESC(debug, "debug string to pass to driver core"); 59 MODULE_PARM_DESC(debug, "debug string to pass to driver core");
59 static char *nouveau_debug; 60 static char *nouveau_debug;
60 module_param_named(debug, nouveau_debug, charp, 0400); 61 module_param_named(debug, nouveau_debug, charp, 0400);
61 62
62 MODULE_PARM_DESC(noaccel, "disable kernel/abi16 acceleration"); 63 MODULE_PARM_DESC(noaccel, "disable kernel/abi16 acceleration");
63 static int nouveau_noaccel = 0; 64 static int nouveau_noaccel = 0;
64 module_param_named(noaccel, nouveau_noaccel, int, 0400); 65 module_param_named(noaccel, nouveau_noaccel, int, 0400);
65 66
66 MODULE_PARM_DESC(modeset, "enable driver (default: auto, " 67 MODULE_PARM_DESC(modeset, "enable driver (default: auto, "
67 "0 = disabled, 1 = enabled, 2 = headless)"); 68 "0 = disabled, 1 = enabled, 2 = headless)");
68 int nouveau_modeset = -1; 69 int nouveau_modeset = -1;
69 module_param_named(modeset, nouveau_modeset, int, 0400); 70 module_param_named(modeset, nouveau_modeset, int, 0400);
70 71
71 static struct drm_driver driver; 72 static struct drm_driver driver;
72 73
73 static int 74 static int
74 nouveau_drm_vblank_handler(struct nouveau_eventh *event, int head) 75 nouveau_drm_vblank_handler(struct nouveau_eventh *event, int head)
75 { 76 {
76 struct nouveau_drm *drm = 77 struct nouveau_drm *drm =
77 container_of(event, struct nouveau_drm, vblank[head]); 78 container_of(event, struct nouveau_drm, vblank[head]);
78 drm_handle_vblank(drm->dev, head); 79 drm_handle_vblank(drm->dev, head);
79 return NVKM_EVENT_KEEP; 80 return NVKM_EVENT_KEEP;
80 } 81 }
81 82
82 static int 83 static int
83 nouveau_drm_vblank_enable(struct drm_device *dev, int head) 84 nouveau_drm_vblank_enable(struct drm_device *dev, int head)
84 { 85 {
85 struct nouveau_drm *drm = nouveau_drm(dev); 86 struct nouveau_drm *drm = nouveau_drm(dev);
86 struct nouveau_disp *pdisp = nouveau_disp(drm->device); 87 struct nouveau_disp *pdisp = nouveau_disp(drm->device);
87 88
88 if (WARN_ON_ONCE(head > ARRAY_SIZE(drm->vblank))) 89 if (WARN_ON_ONCE(head > ARRAY_SIZE(drm->vblank)))
89 return -EIO; 90 return -EIO;
90 WARN_ON_ONCE(drm->vblank[head].func); 91 WARN_ON_ONCE(drm->vblank[head].func);
91 drm->vblank[head].func = nouveau_drm_vblank_handler; 92 drm->vblank[head].func = nouveau_drm_vblank_handler;
92 nouveau_event_get(pdisp->vblank, head, &drm->vblank[head]); 93 nouveau_event_get(pdisp->vblank, head, &drm->vblank[head]);
93 return 0; 94 return 0;
94 } 95 }
95 96
96 static void 97 static void
97 nouveau_drm_vblank_disable(struct drm_device *dev, int head) 98 nouveau_drm_vblank_disable(struct drm_device *dev, int head)
98 { 99 {
99 struct nouveau_drm *drm = nouveau_drm(dev); 100 struct nouveau_drm *drm = nouveau_drm(dev);
100 struct nouveau_disp *pdisp = nouveau_disp(drm->device); 101 struct nouveau_disp *pdisp = nouveau_disp(drm->device);
101 if (drm->vblank[head].func) 102 if (drm->vblank[head].func)
102 nouveau_event_put(pdisp->vblank, head, &drm->vblank[head]); 103 nouveau_event_put(pdisp->vblank, head, &drm->vblank[head]);
103 else 104 else
104 WARN_ON_ONCE(1); 105 WARN_ON_ONCE(1);
105 drm->vblank[head].func = NULL; 106 drm->vblank[head].func = NULL;
106 } 107 }
107 108
108 static u64 109 static u64
109 nouveau_name(struct pci_dev *pdev) 110 nouveau_name(struct pci_dev *pdev)
110 { 111 {
111 u64 name = (u64)pci_domain_nr(pdev->bus) << 32; 112 u64 name = (u64)pci_domain_nr(pdev->bus) << 32;
112 name |= pdev->bus->number << 16; 113 name |= pdev->bus->number << 16;
113 name |= PCI_SLOT(pdev->devfn) << 8; 114 name |= PCI_SLOT(pdev->devfn) << 8;
114 return name | PCI_FUNC(pdev->devfn); 115 return name | PCI_FUNC(pdev->devfn);
115 } 116 }
116 117
117 static int 118 static int
118 nouveau_cli_create(struct pci_dev *pdev, const char *name, 119 nouveau_cli_create(struct pci_dev *pdev, const char *name,
119 int size, void **pcli) 120 int size, void **pcli)
120 { 121 {
121 struct nouveau_cli *cli; 122 struct nouveau_cli *cli;
122 int ret; 123 int ret;
123 124
124 *pcli = NULL; 125 *pcli = NULL;
125 ret = nouveau_client_create_(name, nouveau_name(pdev), nouveau_config, 126 ret = nouveau_client_create_(name, nouveau_name(pdev), nouveau_config,
126 nouveau_debug, size, pcli); 127 nouveau_debug, size, pcli);
127 cli = *pcli; 128 cli = *pcli;
128 if (ret) { 129 if (ret) {
129 if (cli) 130 if (cli)
130 nouveau_client_destroy(&cli->base); 131 nouveau_client_destroy(&cli->base);
131 *pcli = NULL; 132 *pcli = NULL;
132 return ret; 133 return ret;
133 } 134 }
134 135
135 mutex_init(&cli->mutex); 136 mutex_init(&cli->mutex);
136 return 0; 137 return 0;
137 } 138 }
138 139
139 static void 140 static void
140 nouveau_cli_destroy(struct nouveau_cli *cli) 141 nouveau_cli_destroy(struct nouveau_cli *cli)
141 { 142 {
142 struct nouveau_object *client = nv_object(cli); 143 struct nouveau_object *client = nv_object(cli);
143 nouveau_vm_ref(NULL, &cli->base.vm, NULL); 144 nouveau_vm_ref(NULL, &cli->base.vm, NULL);
144 nouveau_client_fini(&cli->base, false); 145 nouveau_client_fini(&cli->base, false);
145 atomic_set(&client->refcount, 1); 146 atomic_set(&client->refcount, 1);
146 nouveau_object_ref(NULL, &client); 147 nouveau_object_ref(NULL, &client);
147 } 148 }
148 149
149 static void 150 static void
150 nouveau_accel_fini(struct nouveau_drm *drm) 151 nouveau_accel_fini(struct nouveau_drm *drm)
151 { 152 {
152 nouveau_gpuobj_ref(NULL, &drm->notify); 153 nouveau_gpuobj_ref(NULL, &drm->notify);
153 nouveau_channel_del(&drm->channel); 154 nouveau_channel_del(&drm->channel);
154 nouveau_channel_del(&drm->cechan); 155 nouveau_channel_del(&drm->cechan);
155 if (drm->fence) 156 if (drm->fence)
156 nouveau_fence(drm)->dtor(drm); 157 nouveau_fence(drm)->dtor(drm);
157 } 158 }
158 159
159 static void 160 static void
160 nouveau_accel_init(struct nouveau_drm *drm) 161 nouveau_accel_init(struct nouveau_drm *drm)
161 { 162 {
162 struct nouveau_device *device = nv_device(drm->device); 163 struct nouveau_device *device = nv_device(drm->device);
163 struct nouveau_object *object; 164 struct nouveau_object *object;
164 u32 arg0, arg1; 165 u32 arg0, arg1;
165 int ret; 166 int ret;
166 167
167 if (nouveau_noaccel) 168 if (nouveau_noaccel || !nouveau_fifo(device) /*XXX*/)
168 return; 169 return;
169 170
170 /* initialise synchronisation routines */ 171 /* initialise synchronisation routines */
171 if (device->card_type < NV_10) ret = nv04_fence_create(drm); 172 if (device->card_type < NV_10) ret = nv04_fence_create(drm);
172 else if (device->chipset < 0x17) ret = nv10_fence_create(drm); 173 else if (device->chipset < 0x17) ret = nv10_fence_create(drm);
173 else if (device->card_type < NV_50) ret = nv17_fence_create(drm); 174 else if (device->card_type < NV_50) ret = nv17_fence_create(drm);
174 else if (device->chipset < 0x84) ret = nv50_fence_create(drm); 175 else if (device->chipset < 0x84) ret = nv50_fence_create(drm);
175 else if (device->card_type < NV_C0) ret = nv84_fence_create(drm); 176 else if (device->card_type < NV_C0) ret = nv84_fence_create(drm);
176 else ret = nvc0_fence_create(drm); 177 else ret = nvc0_fence_create(drm);
177 if (ret) { 178 if (ret) {
178 NV_ERROR(drm, "failed to initialise sync subsystem, %d\n", ret); 179 NV_ERROR(drm, "failed to initialise sync subsystem, %d\n", ret);
179 nouveau_accel_fini(drm); 180 nouveau_accel_fini(drm);
180 return; 181 return;
181 } 182 }
182 183
183 if (device->card_type >= NV_E0) { 184 if (device->card_type >= NV_E0) {
184 ret = nouveau_channel_new(drm, &drm->client, NVDRM_DEVICE, 185 ret = nouveau_channel_new(drm, &drm->client, NVDRM_DEVICE,
185 NVDRM_CHAN + 1, 186 NVDRM_CHAN + 1,
186 NVE0_CHANNEL_IND_ENGINE_CE0 | 187 NVE0_CHANNEL_IND_ENGINE_CE0 |
187 NVE0_CHANNEL_IND_ENGINE_CE1, 0, 188 NVE0_CHANNEL_IND_ENGINE_CE1, 0,
188 &drm->cechan); 189 &drm->cechan);
189 if (ret) 190 if (ret)
190 NV_ERROR(drm, "failed to create ce channel, %d\n", ret); 191 NV_ERROR(drm, "failed to create ce channel, %d\n", ret);
191 192
192 arg0 = NVE0_CHANNEL_IND_ENGINE_GR; 193 arg0 = NVE0_CHANNEL_IND_ENGINE_GR;
193 arg1 = 1; 194 arg1 = 1;
194 } else { 195 } else {
195 arg0 = NvDmaFB; 196 arg0 = NvDmaFB;
196 arg1 = NvDmaTT; 197 arg1 = NvDmaTT;
197 } 198 }
198 199
199 ret = nouveau_channel_new(drm, &drm->client, NVDRM_DEVICE, NVDRM_CHAN, 200 ret = nouveau_channel_new(drm, &drm->client, NVDRM_DEVICE, NVDRM_CHAN,
200 arg0, arg1, &drm->channel); 201 arg0, arg1, &drm->channel);
201 if (ret) { 202 if (ret) {
202 NV_ERROR(drm, "failed to create kernel channel, %d\n", ret); 203 NV_ERROR(drm, "failed to create kernel channel, %d\n", ret);
203 nouveau_accel_fini(drm); 204 nouveau_accel_fini(drm);
204 return; 205 return;
205 } 206 }
206 207
207 if (device->card_type < NV_C0) { 208 if (device->card_type < NV_C0) {
208 ret = nouveau_gpuobj_new(drm->device, NULL, 32, 0, 0, 209 ret = nouveau_gpuobj_new(drm->device, NULL, 32, 0, 0,
209 &drm->notify); 210 &drm->notify);
210 if (ret) { 211 if (ret) {
211 NV_ERROR(drm, "failed to allocate notifier, %d\n", ret); 212 NV_ERROR(drm, "failed to allocate notifier, %d\n", ret);
212 nouveau_accel_fini(drm); 213 nouveau_accel_fini(drm);
213 return; 214 return;
214 } 215 }
215 216
216 ret = nouveau_object_new(nv_object(drm), 217 ret = nouveau_object_new(nv_object(drm),
217 drm->channel->handle, NvNotify0, 218 drm->channel->handle, NvNotify0,
218 0x003d, &(struct nv_dma_class) { 219 0x003d, &(struct nv_dma_class) {
219 .flags = NV_DMA_TARGET_VRAM | 220 .flags = NV_DMA_TARGET_VRAM |
220 NV_DMA_ACCESS_RDWR, 221 NV_DMA_ACCESS_RDWR,
221 .start = drm->notify->addr, 222 .start = drm->notify->addr,
222 .limit = drm->notify->addr + 31 223 .limit = drm->notify->addr + 31
223 }, sizeof(struct nv_dma_class), 224 }, sizeof(struct nv_dma_class),
224 &object); 225 &object);
225 if (ret) { 226 if (ret) {
226 nouveau_accel_fini(drm); 227 nouveau_accel_fini(drm);
227 return; 228 return;
228 } 229 }
229 } 230 }
230 231
231 232
232 nouveau_bo_move_init(drm); 233 nouveau_bo_move_init(drm);
233 } 234 }
234 235
235 static int nouveau_drm_probe(struct pci_dev *pdev, 236 static int nouveau_drm_probe(struct pci_dev *pdev,
236 const struct pci_device_id *pent) 237 const struct pci_device_id *pent)
237 { 238 {
238 struct nouveau_device *device; 239 struct nouveau_device *device;
239 struct apertures_struct *aper; 240 struct apertures_struct *aper;
240 bool boot = false; 241 bool boot = false;
241 int ret; 242 int ret;
242 243
243 /* remove conflicting drivers (vesafb, efifb etc) */ 244 /* remove conflicting drivers (vesafb, efifb etc) */
244 aper = alloc_apertures(3); 245 aper = alloc_apertures(3);
245 if (!aper) 246 if (!aper)
246 return -ENOMEM; 247 return -ENOMEM;
247 248
248 aper->ranges[0].base = pci_resource_start(pdev, 1); 249 aper->ranges[0].base = pci_resource_start(pdev, 1);
249 aper->ranges[0].size = pci_resource_len(pdev, 1); 250 aper->ranges[0].size = pci_resource_len(pdev, 1);
250 aper->count = 1; 251 aper->count = 1;
251 252
252 if (pci_resource_len(pdev, 2)) { 253 if (pci_resource_len(pdev, 2)) {
253 aper->ranges[aper->count].base = pci_resource_start(pdev, 2); 254 aper->ranges[aper->count].base = pci_resource_start(pdev, 2);
254 aper->ranges[aper->count].size = pci_resource_len(pdev, 2); 255 aper->ranges[aper->count].size = pci_resource_len(pdev, 2);
255 aper->count++; 256 aper->count++;
256 } 257 }
257 258
258 if (pci_resource_len(pdev, 3)) { 259 if (pci_resource_len(pdev, 3)) {
259 aper->ranges[aper->count].base = pci_resource_start(pdev, 3); 260 aper->ranges[aper->count].base = pci_resource_start(pdev, 3);
260 aper->ranges[aper->count].size = pci_resource_len(pdev, 3); 261 aper->ranges[aper->count].size = pci_resource_len(pdev, 3);
261 aper->count++; 262 aper->count++;
262 } 263 }
263 264
264 #ifdef CONFIG_X86 265 #ifdef CONFIG_X86
265 boot = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; 266 boot = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW;
266 #endif 267 #endif
267 remove_conflicting_framebuffers(aper, "nouveaufb", boot); 268 remove_conflicting_framebuffers(aper, "nouveaufb", boot);
268 kfree(aper); 269 kfree(aper);
269 270
270 ret = nouveau_device_create(pdev, nouveau_name(pdev), pci_name(pdev), 271 ret = nouveau_device_create(pdev, nouveau_name(pdev), pci_name(pdev),
271 nouveau_config, nouveau_debug, &device); 272 nouveau_config, nouveau_debug, &device);
272 if (ret) 273 if (ret)
273 return ret; 274 return ret;
274 275
275 pci_set_master(pdev); 276 pci_set_master(pdev);
276 277
277 ret = drm_get_pci_dev(pdev, pent, &driver); 278 ret = drm_get_pci_dev(pdev, pent, &driver);
278 if (ret) { 279 if (ret) {
279 nouveau_object_ref(NULL, (struct nouveau_object **)&device); 280 nouveau_object_ref(NULL, (struct nouveau_object **)&device);
280 return ret; 281 return ret;
281 } 282 }
282 283
283 return 0; 284 return 0;
284 } 285 }
285 286
286 static struct lock_class_key drm_client_lock_class_key; 287 static struct lock_class_key drm_client_lock_class_key;
287 288
288 static int 289 static int
289 nouveau_drm_load(struct drm_device *dev, unsigned long flags) 290 nouveau_drm_load(struct drm_device *dev, unsigned long flags)
290 { 291 {
291 struct pci_dev *pdev = dev->pdev; 292 struct pci_dev *pdev = dev->pdev;
292 struct nouveau_device *device; 293 struct nouveau_device *device;
293 struct nouveau_drm *drm; 294 struct nouveau_drm *drm;
294 int ret; 295 int ret;
295 296
296 ret = nouveau_cli_create(pdev, "DRM", sizeof(*drm), (void**)&drm); 297 ret = nouveau_cli_create(pdev, "DRM", sizeof(*drm), (void**)&drm);
297 if (ret) 298 if (ret)
298 return ret; 299 return ret;
299 lockdep_set_class(&drm->client.mutex, &drm_client_lock_class_key); 300 lockdep_set_class(&drm->client.mutex, &drm_client_lock_class_key);
300 301
301 dev->dev_private = drm; 302 dev->dev_private = drm;
302 drm->dev = dev; 303 drm->dev = dev;
303 304
304 INIT_LIST_HEAD(&drm->clients); 305 INIT_LIST_HEAD(&drm->clients);
305 spin_lock_init(&drm->tile.lock); 306 spin_lock_init(&drm->tile.lock);
306 307
307 /* make sure AGP controller is in a consistent state before we 308 /* make sure AGP controller is in a consistent state before we
308 * (possibly) execute vbios init tables (see nouveau_agp.h) 309 * (possibly) execute vbios init tables (see nouveau_agp.h)
309 */ 310 */
310 if (drm_pci_device_is_agp(dev) && dev->agp) { 311 if (drm_pci_device_is_agp(dev) && dev->agp) {
311 /* dummy device object, doesn't init anything, but allows 312 /* dummy device object, doesn't init anything, but allows
312 * agp code access to registers 313 * agp code access to registers
313 */ 314 */
314 ret = nouveau_object_new(nv_object(drm), NVDRM_CLIENT, 315 ret = nouveau_object_new(nv_object(drm), NVDRM_CLIENT,
315 NVDRM_DEVICE, 0x0080, 316 NVDRM_DEVICE, 0x0080,
316 &(struct nv_device_class) { 317 &(struct nv_device_class) {
317 .device = ~0, 318 .device = ~0,
318 .disable = 319 .disable =
319 ~(NV_DEVICE_DISABLE_MMIO | 320 ~(NV_DEVICE_DISABLE_MMIO |
320 NV_DEVICE_DISABLE_IDENTIFY), 321 NV_DEVICE_DISABLE_IDENTIFY),
321 .debug0 = ~0, 322 .debug0 = ~0,
322 }, sizeof(struct nv_device_class), 323 }, sizeof(struct nv_device_class),
323 &drm->device); 324 &drm->device);
324 if (ret) 325 if (ret)
325 goto fail_device; 326 goto fail_device;
326 327
327 nouveau_agp_reset(drm); 328 nouveau_agp_reset(drm);
328 nouveau_object_del(nv_object(drm), NVDRM_CLIENT, NVDRM_DEVICE); 329 nouveau_object_del(nv_object(drm), NVDRM_CLIENT, NVDRM_DEVICE);
329 } 330 }
330 331
331 ret = nouveau_object_new(nv_object(drm), NVDRM_CLIENT, NVDRM_DEVICE, 332 ret = nouveau_object_new(nv_object(drm), NVDRM_CLIENT, NVDRM_DEVICE,
332 0x0080, &(struct nv_device_class) { 333 0x0080, &(struct nv_device_class) {
333 .device = ~0, 334 .device = ~0,
334 .disable = 0, 335 .disable = 0,
335 .debug0 = 0, 336 .debug0 = 0,
336 }, sizeof(struct nv_device_class), 337 }, sizeof(struct nv_device_class),
337 &drm->device); 338 &drm->device);
338 if (ret) 339 if (ret)
339 goto fail_device; 340 goto fail_device;
340 341
341 /* workaround an odd issue on nvc1 by disabling the device's 342 /* workaround an odd issue on nvc1 by disabling the device's
342 * nosnoop capability. hopefully won't cause issues until a 343 * nosnoop capability. hopefully won't cause issues until a
343 * better fix is found - assuming there is one... 344 * better fix is found - assuming there is one...
344 */ 345 */
345 device = nv_device(drm->device); 346 device = nv_device(drm->device);
346 if (nv_device(drm->device)->chipset == 0xc1) 347 if (nv_device(drm->device)->chipset == 0xc1)
347 nv_mask(device, 0x00088080, 0x00000800, 0x00000000); 348 nv_mask(device, 0x00088080, 0x00000800, 0x00000000);
348 349
349 nouveau_vga_init(drm); 350 nouveau_vga_init(drm);
350 nouveau_agp_init(drm); 351 nouveau_agp_init(drm);
351 352
352 if (device->card_type >= NV_50) { 353 if (device->card_type >= NV_50) {
353 ret = nouveau_vm_new(nv_device(drm->device), 0, (1ULL << 40), 354 ret = nouveau_vm_new(nv_device(drm->device), 0, (1ULL << 40),
354 0x1000, &drm->client.base.vm); 355 0x1000, &drm->client.base.vm);
355 if (ret) 356 if (ret)
356 goto fail_device; 357 goto fail_device;
357 } 358 }
358 359
359 ret = nouveau_ttm_init(drm); 360 ret = nouveau_ttm_init(drm);
360 if (ret) 361 if (ret)
361 goto fail_ttm; 362 goto fail_ttm;
362 363
363 ret = nouveau_bios_init(dev); 364 ret = nouveau_bios_init(dev);
364 if (ret) 365 if (ret)
365 goto fail_bios; 366 goto fail_bios;
366 367
367 ret = nouveau_display_create(dev); 368 ret = nouveau_display_create(dev);
368 if (ret) 369 if (ret)
369 goto fail_dispctor; 370 goto fail_dispctor;
370 371
371 if (dev->mode_config.num_crtc) { 372 if (dev->mode_config.num_crtc) {
372 ret = nouveau_display_init(dev); 373 ret = nouveau_display_init(dev);
373 if (ret) 374 if (ret)
374 goto fail_dispinit; 375 goto fail_dispinit;
375 } 376 }
376 377
377 nouveau_pm_init(dev); 378 nouveau_pm_init(dev);
378 379
379 nouveau_accel_init(drm); 380 nouveau_accel_init(drm);
380 nouveau_fbcon_init(dev); 381 nouveau_fbcon_init(dev);
381 return 0; 382 return 0;
382 383
383 fail_dispinit: 384 fail_dispinit:
384 nouveau_display_destroy(dev); 385 nouveau_display_destroy(dev);
385 fail_dispctor: 386 fail_dispctor:
386 nouveau_bios_takedown(dev); 387 nouveau_bios_takedown(dev);
387 fail_bios: 388 fail_bios:
388 nouveau_ttm_fini(drm); 389 nouveau_ttm_fini(drm);
389 fail_ttm: 390 fail_ttm:
390 nouveau_agp_fini(drm); 391 nouveau_agp_fini(drm);
391 nouveau_vga_fini(drm); 392 nouveau_vga_fini(drm);
392 fail_device: 393 fail_device:
393 nouveau_cli_destroy(&drm->client); 394 nouveau_cli_destroy(&drm->client);
394 return ret; 395 return ret;
395 } 396 }
396 397
397 static int 398 static int
398 nouveau_drm_unload(struct drm_device *dev) 399 nouveau_drm_unload(struct drm_device *dev)
399 { 400 {
400 struct nouveau_drm *drm = nouveau_drm(dev); 401 struct nouveau_drm *drm = nouveau_drm(dev);
401 402
402 nouveau_fbcon_fini(dev); 403 nouveau_fbcon_fini(dev);
403 nouveau_accel_fini(drm); 404 nouveau_accel_fini(drm);
404 405
405 nouveau_pm_fini(dev); 406 nouveau_pm_fini(dev);
406 407
407 if (dev->mode_config.num_crtc) 408 if (dev->mode_config.num_crtc)
408 nouveau_display_fini(dev); 409 nouveau_display_fini(dev);
409 nouveau_display_destroy(dev); 410 nouveau_display_destroy(dev);
410 411
411 nouveau_bios_takedown(dev); 412 nouveau_bios_takedown(dev);
412 413
413 nouveau_ttm_fini(drm); 414 nouveau_ttm_fini(drm);
414 nouveau_agp_fini(drm); 415 nouveau_agp_fini(drm);
415 nouveau_vga_fini(drm); 416 nouveau_vga_fini(drm);
416 417
417 nouveau_cli_destroy(&drm->client); 418 nouveau_cli_destroy(&drm->client);
418 return 0; 419 return 0;
419 } 420 }
420 421
421 static void 422 static void
422 nouveau_drm_remove(struct pci_dev *pdev) 423 nouveau_drm_remove(struct pci_dev *pdev)
423 { 424 {
424 struct drm_device *dev = pci_get_drvdata(pdev); 425 struct drm_device *dev = pci_get_drvdata(pdev);
425 struct nouveau_drm *drm = nouveau_drm(dev); 426 struct nouveau_drm *drm = nouveau_drm(dev);
426 struct nouveau_object *device; 427 struct nouveau_object *device;
427 428
428 device = drm->client.base.device; 429 device = drm->client.base.device;
429 drm_put_dev(dev); 430 drm_put_dev(dev);
430 431
431 nouveau_object_ref(NULL, &device); 432 nouveau_object_ref(NULL, &device);
432 nouveau_object_debug(); 433 nouveau_object_debug();
433 } 434 }
434 435
435 static int 436 static int
436 nouveau_do_suspend(struct drm_device *dev) 437 nouveau_do_suspend(struct drm_device *dev)
437 { 438 {
438 struct nouveau_drm *drm = nouveau_drm(dev); 439 struct nouveau_drm *drm = nouveau_drm(dev);
439 struct nouveau_cli *cli; 440 struct nouveau_cli *cli;
440 int ret; 441 int ret;
441 442
442 if (dev->mode_config.num_crtc) { 443 if (dev->mode_config.num_crtc) {
443 NV_INFO(drm, "suspending fbcon...\n"); 444 NV_INFO(drm, "suspending fbcon...\n");
444 nouveau_fbcon_set_suspend(dev, 1); 445 nouveau_fbcon_set_suspend(dev, 1);
445 446
446 NV_INFO(drm, "suspending display...\n"); 447 NV_INFO(drm, "suspending display...\n");
447 ret = nouveau_display_suspend(dev); 448 ret = nouveau_display_suspend(dev);
448 if (ret) 449 if (ret)
449 return ret; 450 return ret;
450 } 451 }
451 452
452 NV_INFO(drm, "evicting buffers...\n"); 453 NV_INFO(drm, "evicting buffers...\n");
453 ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM); 454 ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM);
454 455
455 if (drm->fence && nouveau_fence(drm)->suspend) { 456 if (drm->fence && nouveau_fence(drm)->suspend) {
456 if (!nouveau_fence(drm)->suspend(drm)) 457 if (!nouveau_fence(drm)->suspend(drm))
457 return -ENOMEM; 458 return -ENOMEM;
458 } 459 }
459 460
460 NV_INFO(drm, "suspending client object trees...\n"); 461 NV_INFO(drm, "suspending client object trees...\n");
461 list_for_each_entry(cli, &drm->clients, head) { 462 list_for_each_entry(cli, &drm->clients, head) {
462 ret = nouveau_client_fini(&cli->base, true); 463 ret = nouveau_client_fini(&cli->base, true);
463 if (ret) 464 if (ret)
464 goto fail_client; 465 goto fail_client;
465 } 466 }
466 467
467 ret = nouveau_client_fini(&drm->client.base, true); 468 ret = nouveau_client_fini(&drm->client.base, true);
468 if (ret) 469 if (ret)
469 goto fail_client; 470 goto fail_client;
470 471
471 nouveau_agp_fini(drm); 472 nouveau_agp_fini(drm);
472 return 0; 473 return 0;
473 474
474 fail_client: 475 fail_client:
475 list_for_each_entry_continue_reverse(cli, &drm->clients, head) { 476 list_for_each_entry_continue_reverse(cli, &drm->clients, head) {
476 nouveau_client_init(&cli->base); 477 nouveau_client_init(&cli->base);
477 } 478 }
478 479
479 if (dev->mode_config.num_crtc) { 480 if (dev->mode_config.num_crtc) {
480 NV_INFO(drm, "resuming display...\n"); 481 NV_INFO(drm, "resuming display...\n");
481 nouveau_display_resume(dev); 482 nouveau_display_resume(dev);
482 } 483 }
483 return ret; 484 return ret;
484 } 485 }
485 486
486 int nouveau_pmops_suspend(struct device *dev) 487 int nouveau_pmops_suspend(struct device *dev)
487 { 488 {
488 struct pci_dev *pdev = to_pci_dev(dev); 489 struct pci_dev *pdev = to_pci_dev(dev);
489 struct drm_device *drm_dev = pci_get_drvdata(pdev); 490 struct drm_device *drm_dev = pci_get_drvdata(pdev);
490 int ret; 491 int ret;
491 492
492 if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) 493 if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF)
493 return 0; 494 return 0;
494 495
495 ret = nouveau_do_suspend(drm_dev); 496 ret = nouveau_do_suspend(drm_dev);
496 if (ret) 497 if (ret)
497 return ret; 498 return ret;
498 499
499 pci_save_state(pdev); 500 pci_save_state(pdev);
500 pci_disable_device(pdev); 501 pci_disable_device(pdev);
501 pci_set_power_state(pdev, PCI_D3hot); 502 pci_set_power_state(pdev, PCI_D3hot);
502 503
503 return 0; 504 return 0;
504 } 505 }
505 506
506 static int 507 static int
507 nouveau_do_resume(struct drm_device *dev) 508 nouveau_do_resume(struct drm_device *dev)
508 { 509 {
509 struct nouveau_drm *drm = nouveau_drm(dev); 510 struct nouveau_drm *drm = nouveau_drm(dev);
510 struct nouveau_cli *cli; 511 struct nouveau_cli *cli;
511 512
512 NV_INFO(drm, "re-enabling device...\n"); 513 NV_INFO(drm, "re-enabling device...\n");
513 514
514 nouveau_agp_reset(drm); 515 nouveau_agp_reset(drm);
515 516
516 NV_INFO(drm, "resuming client object trees...\n"); 517 NV_INFO(drm, "resuming client object trees...\n");
517 nouveau_client_init(&drm->client.base); 518 nouveau_client_init(&drm->client.base);
518 nouveau_agp_init(drm); 519 nouveau_agp_init(drm);
519 520
520 list_for_each_entry(cli, &drm->clients, head) { 521 list_for_each_entry(cli, &drm->clients, head) {
521 nouveau_client_init(&cli->base); 522 nouveau_client_init(&cli->base);
522 } 523 }
523 524
524 if (drm->fence && nouveau_fence(drm)->resume) 525 if (drm->fence && nouveau_fence(drm)->resume)
525 nouveau_fence(drm)->resume(drm); 526 nouveau_fence(drm)->resume(drm);
526 527
527 nouveau_run_vbios_init(dev); 528 nouveau_run_vbios_init(dev);
528 nouveau_pm_resume(dev); 529 nouveau_pm_resume(dev);
529 530
530 if (dev->mode_config.num_crtc) { 531 if (dev->mode_config.num_crtc) {
531 NV_INFO(drm, "resuming display...\n"); 532 NV_INFO(drm, "resuming display...\n");
532 nouveau_display_resume(dev); 533 nouveau_display_resume(dev);
533 } 534 }
534 return 0; 535 return 0;
535 } 536 }
536 537
537 int nouveau_pmops_resume(struct device *dev) 538 int nouveau_pmops_resume(struct device *dev)
538 { 539 {
539 struct pci_dev *pdev = to_pci_dev(dev); 540 struct pci_dev *pdev = to_pci_dev(dev);
540 struct drm_device *drm_dev = pci_get_drvdata(pdev); 541 struct drm_device *drm_dev = pci_get_drvdata(pdev);
541 int ret; 542 int ret;
542 543
543 if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF) 544 if (drm_dev->switch_power_state == DRM_SWITCH_POWER_OFF)
544 return 0; 545 return 0;
545 546
546 pci_set_power_state(pdev, PCI_D0); 547 pci_set_power_state(pdev, PCI_D0);
547 pci_restore_state(pdev); 548 pci_restore_state(pdev);
548 ret = pci_enable_device(pdev); 549 ret = pci_enable_device(pdev);
549 if (ret) 550 if (ret)
550 return ret; 551 return ret;
551 pci_set_master(pdev); 552 pci_set_master(pdev);
552 553
553 return nouveau_do_resume(drm_dev); 554 return nouveau_do_resume(drm_dev);
554 } 555 }
555 556
556 static int nouveau_pmops_freeze(struct device *dev) 557 static int nouveau_pmops_freeze(struct device *dev)
557 { 558 {
558 struct pci_dev *pdev = to_pci_dev(dev); 559 struct pci_dev *pdev = to_pci_dev(dev);
559 struct drm_device *drm_dev = pci_get_drvdata(pdev); 560 struct drm_device *drm_dev = pci_get_drvdata(pdev);
560 561
561 return nouveau_do_suspend(drm_dev); 562 return nouveau_do_suspend(drm_dev);
562 } 563 }
563 564
564 static int nouveau_pmops_thaw(struct device *dev) 565 static int nouveau_pmops_thaw(struct device *dev)
565 { 566 {
566 struct pci_dev *pdev = to_pci_dev(dev); 567 struct pci_dev *pdev = to_pci_dev(dev);
567 struct drm_device *drm_dev = pci_get_drvdata(pdev); 568 struct drm_device *drm_dev = pci_get_drvdata(pdev);
568 569
569 return nouveau_do_resume(drm_dev); 570 return nouveau_do_resume(drm_dev);
570 } 571 }
571 572
572 573
573 static int 574 static int
574 nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) 575 nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
575 { 576 {
576 struct pci_dev *pdev = dev->pdev; 577 struct pci_dev *pdev = dev->pdev;
577 struct nouveau_drm *drm = nouveau_drm(dev); 578 struct nouveau_drm *drm = nouveau_drm(dev);
578 struct nouveau_cli *cli; 579 struct nouveau_cli *cli;
579 char name[32], tmpname[TASK_COMM_LEN]; 580 char name[32], tmpname[TASK_COMM_LEN];
580 int ret; 581 int ret;
581 582
582 get_task_comm(tmpname, current); 583 get_task_comm(tmpname, current);
583 snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid)); 584 snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid));
584 585
585 ret = nouveau_cli_create(pdev, name, sizeof(*cli), (void **)&cli); 586 ret = nouveau_cli_create(pdev, name, sizeof(*cli), (void **)&cli);
586 if (ret) 587 if (ret)
587 return ret; 588 return ret;
588 589
589 if (nv_device(drm->device)->card_type >= NV_50) { 590 if (nv_device(drm->device)->card_type >= NV_50) {
590 ret = nouveau_vm_new(nv_device(drm->device), 0, (1ULL << 40), 591 ret = nouveau_vm_new(nv_device(drm->device), 0, (1ULL << 40),
591 0x1000, &cli->base.vm); 592 0x1000, &cli->base.vm);
592 if (ret) { 593 if (ret) {
593 nouveau_cli_destroy(cli); 594 nouveau_cli_destroy(cli);
594 return ret; 595 return ret;
595 } 596 }
596 } 597 }
597 598
598 fpriv->driver_priv = cli; 599 fpriv->driver_priv = cli;
599 600
600 mutex_lock(&drm->client.mutex); 601 mutex_lock(&drm->client.mutex);
601 list_add(&cli->head, &drm->clients); 602 list_add(&cli->head, &drm->clients);
602 mutex_unlock(&drm->client.mutex); 603 mutex_unlock(&drm->client.mutex);
603 return 0; 604 return 0;
604 } 605 }
605 606
606 static void 607 static void
607 nouveau_drm_preclose(struct drm_device *dev, struct drm_file *fpriv) 608 nouveau_drm_preclose(struct drm_device *dev, struct drm_file *fpriv)
608 { 609 {
609 struct nouveau_cli *cli = nouveau_cli(fpriv); 610 struct nouveau_cli *cli = nouveau_cli(fpriv);
610 struct nouveau_drm *drm = nouveau_drm(dev); 611 struct nouveau_drm *drm = nouveau_drm(dev);
611 612
612 if (cli->abi16) 613 if (cli->abi16)
613 nouveau_abi16_fini(cli->abi16); 614 nouveau_abi16_fini(cli->abi16);
614 615
615 mutex_lock(&drm->client.mutex); 616 mutex_lock(&drm->client.mutex);
616 list_del(&cli->head); 617 list_del(&cli->head);
617 mutex_unlock(&drm->client.mutex); 618 mutex_unlock(&drm->client.mutex);
618 } 619 }
619 620
620 static void 621 static void
621 nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv) 622 nouveau_drm_postclose(struct drm_device *dev, struct drm_file *fpriv)
622 { 623 {
623 struct nouveau_cli *cli = nouveau_cli(fpriv); 624 struct nouveau_cli *cli = nouveau_cli(fpriv);
624 nouveau_cli_destroy(cli); 625 nouveau_cli_destroy(cli);
625 } 626 }
626 627
627 static struct drm_ioctl_desc 628 static struct drm_ioctl_desc
628 nouveau_ioctls[] = { 629 nouveau_ioctls[] = {
629 DRM_IOCTL_DEF_DRV(NOUVEAU_GETPARAM, nouveau_abi16_ioctl_getparam, DRM_UNLOCKED|DRM_AUTH), 630 DRM_IOCTL_DEF_DRV(NOUVEAU_GETPARAM, nouveau_abi16_ioctl_getparam, DRM_UNLOCKED|DRM_AUTH),
630 DRM_IOCTL_DEF_DRV(NOUVEAU_SETPARAM, nouveau_abi16_ioctl_setparam, DRM_UNLOCKED|DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), 631 DRM_IOCTL_DEF_DRV(NOUVEAU_SETPARAM, nouveau_abi16_ioctl_setparam, DRM_UNLOCKED|DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
631 DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_ALLOC, nouveau_abi16_ioctl_channel_alloc, DRM_UNLOCKED|DRM_AUTH), 632 DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_ALLOC, nouveau_abi16_ioctl_channel_alloc, DRM_UNLOCKED|DRM_AUTH),
632 DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_FREE, nouveau_abi16_ioctl_channel_free, DRM_UNLOCKED|DRM_AUTH), 633 DRM_IOCTL_DEF_DRV(NOUVEAU_CHANNEL_FREE, nouveau_abi16_ioctl_channel_free, DRM_UNLOCKED|DRM_AUTH),
633 DRM_IOCTL_DEF_DRV(NOUVEAU_GROBJ_ALLOC, nouveau_abi16_ioctl_grobj_alloc, DRM_UNLOCKED|DRM_AUTH), 634 DRM_IOCTL_DEF_DRV(NOUVEAU_GROBJ_ALLOC, nouveau_abi16_ioctl_grobj_alloc, DRM_UNLOCKED|DRM_AUTH),
634 DRM_IOCTL_DEF_DRV(NOUVEAU_NOTIFIEROBJ_ALLOC, nouveau_abi16_ioctl_notifierobj_alloc, DRM_UNLOCKED|DRM_AUTH), 635 DRM_IOCTL_DEF_DRV(NOUVEAU_NOTIFIEROBJ_ALLOC, nouveau_abi16_ioctl_notifierobj_alloc, DRM_UNLOCKED|DRM_AUTH),
635 DRM_IOCTL_DEF_DRV(NOUVEAU_GPUOBJ_FREE, nouveau_abi16_ioctl_gpuobj_free, DRM_UNLOCKED|DRM_AUTH), 636 DRM_IOCTL_DEF_DRV(NOUVEAU_GPUOBJ_FREE, nouveau_abi16_ioctl_gpuobj_free, DRM_UNLOCKED|DRM_AUTH),
636 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_NEW, nouveau_gem_ioctl_new, DRM_UNLOCKED|DRM_AUTH), 637 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_NEW, nouveau_gem_ioctl_new, DRM_UNLOCKED|DRM_AUTH),
637 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_PUSHBUF, nouveau_gem_ioctl_pushbuf, DRM_UNLOCKED|DRM_AUTH), 638 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_PUSHBUF, nouveau_gem_ioctl_pushbuf, DRM_UNLOCKED|DRM_AUTH),
638 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_PREP, nouveau_gem_ioctl_cpu_prep, DRM_UNLOCKED|DRM_AUTH), 639 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_PREP, nouveau_gem_ioctl_cpu_prep, DRM_UNLOCKED|DRM_AUTH),
639 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_FINI, nouveau_gem_ioctl_cpu_fini, DRM_UNLOCKED|DRM_AUTH), 640 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_CPU_FINI, nouveau_gem_ioctl_cpu_fini, DRM_UNLOCKED|DRM_AUTH),
640 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_INFO, nouveau_gem_ioctl_info, DRM_UNLOCKED|DRM_AUTH), 641 DRM_IOCTL_DEF_DRV(NOUVEAU_GEM_INFO, nouveau_gem_ioctl_info, DRM_UNLOCKED|DRM_AUTH),
641 }; 642 };
642 643
643 static const struct file_operations 644 static const struct file_operations
644 nouveau_driver_fops = { 645 nouveau_driver_fops = {
645 .owner = THIS_MODULE, 646 .owner = THIS_MODULE,
646 .open = drm_open, 647 .open = drm_open,
647 .release = drm_release, 648 .release = drm_release,
648 .unlocked_ioctl = drm_ioctl, 649 .unlocked_ioctl = drm_ioctl,
649 .mmap = nouveau_ttm_mmap, 650 .mmap = nouveau_ttm_mmap,
650 .poll = drm_poll, 651 .poll = drm_poll,
651 .fasync = drm_fasync, 652 .fasync = drm_fasync,
652 .read = drm_read, 653 .read = drm_read,
653 #if defined(CONFIG_COMPAT) 654 #if defined(CONFIG_COMPAT)
654 .compat_ioctl = nouveau_compat_ioctl, 655 .compat_ioctl = nouveau_compat_ioctl,
655 #endif 656 #endif
656 .llseek = noop_llseek, 657 .llseek = noop_llseek,
657 }; 658 };
658 659
659 static struct drm_driver 660 static struct drm_driver
660 driver = { 661 driver = {
661 .driver_features = 662 .driver_features =
662 DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG | 663 DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
663 DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME, 664 DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME,
664 665
665 .load = nouveau_drm_load, 666 .load = nouveau_drm_load,
666 .unload = nouveau_drm_unload, 667 .unload = nouveau_drm_unload,
667 .open = nouveau_drm_open, 668 .open = nouveau_drm_open,
668 .preclose = nouveau_drm_preclose, 669 .preclose = nouveau_drm_preclose,
669 .postclose = nouveau_drm_postclose, 670 .postclose = nouveau_drm_postclose,
670 .lastclose = nouveau_vga_lastclose, 671 .lastclose = nouveau_vga_lastclose,
671 672
672 #if defined(CONFIG_DEBUG_FS) 673 #if defined(CONFIG_DEBUG_FS)
673 .debugfs_init = nouveau_debugfs_init, 674 .debugfs_init = nouveau_debugfs_init,
674 .debugfs_cleanup = nouveau_debugfs_takedown, 675 .debugfs_cleanup = nouveau_debugfs_takedown,
675 #endif 676 #endif
676 677
677 .get_vblank_counter = drm_vblank_count, 678 .get_vblank_counter = drm_vblank_count,
678 .enable_vblank = nouveau_drm_vblank_enable, 679 .enable_vblank = nouveau_drm_vblank_enable,
679 .disable_vblank = nouveau_drm_vblank_disable, 680 .disable_vblank = nouveau_drm_vblank_disable,
680 681
681 .ioctls = nouveau_ioctls, 682 .ioctls = nouveau_ioctls,
682 .fops = &nouveau_driver_fops, 683 .fops = &nouveau_driver_fops,
683 684
684 .prime_handle_to_fd = drm_gem_prime_handle_to_fd, 685 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
685 .prime_fd_to_handle = drm_gem_prime_fd_to_handle, 686 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
686 .gem_prime_export = drm_gem_prime_export, 687 .gem_prime_export = drm_gem_prime_export,
687 .gem_prime_import = drm_gem_prime_import, 688 .gem_prime_import = drm_gem_prime_import,
688 .gem_prime_pin = nouveau_gem_prime_pin, 689 .gem_prime_pin = nouveau_gem_prime_pin,
689 .gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table, 690 .gem_prime_get_sg_table = nouveau_gem_prime_get_sg_table,
690 .gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table, 691 .gem_prime_import_sg_table = nouveau_gem_prime_import_sg_table,
691 .gem_prime_vmap = nouveau_gem_prime_vmap, 692 .gem_prime_vmap = nouveau_gem_prime_vmap,
692 .gem_prime_vunmap = nouveau_gem_prime_vunmap, 693 .gem_prime_vunmap = nouveau_gem_prime_vunmap,
693 694
694 .gem_init_object = nouveau_gem_object_new, 695 .gem_init_object = nouveau_gem_object_new,
695 .gem_free_object = nouveau_gem_object_del, 696 .gem_free_object = nouveau_gem_object_del,
696 .gem_open_object = nouveau_gem_object_open, 697 .gem_open_object = nouveau_gem_object_open,
697 .gem_close_object = nouveau_gem_object_close, 698 .gem_close_object = nouveau_gem_object_close,
698 699
699 .dumb_create = nouveau_display_dumb_create, 700 .dumb_create = nouveau_display_dumb_create,
700 .dumb_map_offset = nouveau_display_dumb_map_offset, 701 .dumb_map_offset = nouveau_display_dumb_map_offset,
701 .dumb_destroy = nouveau_display_dumb_destroy, 702 .dumb_destroy = nouveau_display_dumb_destroy,
702 703
703 .name = DRIVER_NAME, 704 .name = DRIVER_NAME,
704 .desc = DRIVER_DESC, 705 .desc = DRIVER_DESC,
705 #ifdef GIT_REVISION 706 #ifdef GIT_REVISION
706 .date = GIT_REVISION, 707 .date = GIT_REVISION,
707 #else 708 #else
708 .date = DRIVER_DATE, 709 .date = DRIVER_DATE,
709 #endif 710 #endif
710 .major = DRIVER_MAJOR, 711 .major = DRIVER_MAJOR,
711 .minor = DRIVER_MINOR, 712 .minor = DRIVER_MINOR,
712 .patchlevel = DRIVER_PATCHLEVEL, 713 .patchlevel = DRIVER_PATCHLEVEL,
713 }; 714 };
714 715
715 static struct pci_device_id 716 static struct pci_device_id
716 nouveau_drm_pci_table[] = { 717 nouveau_drm_pci_table[] = {
717 { 718 {
718 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID), 719 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID),
719 .class = PCI_BASE_CLASS_DISPLAY << 16, 720 .class = PCI_BASE_CLASS_DISPLAY << 16,
720 .class_mask = 0xff << 16, 721 .class_mask = 0xff << 16,
721 }, 722 },
722 { 723 {
723 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA_SGS, PCI_ANY_ID), 724 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA_SGS, PCI_ANY_ID),
724 .class = PCI_BASE_CLASS_DISPLAY << 16, 725 .class = PCI_BASE_CLASS_DISPLAY << 16,
725 .class_mask = 0xff << 16, 726 .class_mask = 0xff << 16,
726 }, 727 },
727 {} 728 {}
728 }; 729 };
729 730
730 static const struct dev_pm_ops nouveau_pm_ops = { 731 static const struct dev_pm_ops nouveau_pm_ops = {
731 .suspend = nouveau_pmops_suspend, 732 .suspend = nouveau_pmops_suspend,
732 .resume = nouveau_pmops_resume, 733 .resume = nouveau_pmops_resume,
733 .freeze = nouveau_pmops_freeze, 734 .freeze = nouveau_pmops_freeze,
734 .thaw = nouveau_pmops_thaw, 735 .thaw = nouveau_pmops_thaw,
735 .poweroff = nouveau_pmops_freeze, 736 .poweroff = nouveau_pmops_freeze,
736 .restore = nouveau_pmops_resume, 737 .restore = nouveau_pmops_resume,
737 }; 738 };
738 739
739 static struct pci_driver 740 static struct pci_driver
740 nouveau_drm_pci_driver = { 741 nouveau_drm_pci_driver = {
741 .name = "nouveau", 742 .name = "nouveau",
742 .id_table = nouveau_drm_pci_table, 743 .id_table = nouveau_drm_pci_table,
743 .probe = nouveau_drm_probe, 744 .probe = nouveau_drm_probe,
744 .remove = nouveau_drm_remove, 745 .remove = nouveau_drm_remove,
745 .driver.pm = &nouveau_pm_ops, 746 .driver.pm = &nouveau_pm_ops,
746 }; 747 };
747 748
748 static int __init 749 static int __init
749 nouveau_drm_init(void) 750 nouveau_drm_init(void)
750 { 751 {
751 driver.num_ioctls = ARRAY_SIZE(nouveau_ioctls); 752 driver.num_ioctls = ARRAY_SIZE(nouveau_ioctls);
752 753
753 if (nouveau_modeset == -1) { 754 if (nouveau_modeset == -1) {
754 #ifdef CONFIG_VGA_CONSOLE 755 #ifdef CONFIG_VGA_CONSOLE
755 if (vgacon_text_force()) 756 if (vgacon_text_force())
756 nouveau_modeset = 0; 757 nouveau_modeset = 0;
757 #endif 758 #endif
758 } 759 }
759 760
760 if (!nouveau_modeset) 761 if (!nouveau_modeset)
761 return 0; 762 return 0;
762 763
763 nouveau_register_dsm_handler(); 764 nouveau_register_dsm_handler();
764 return drm_pci_init(&driver, &nouveau_drm_pci_driver); 765 return drm_pci_init(&driver, &nouveau_drm_pci_driver);
765 } 766 }
766 767
767 static void __exit 768 static void __exit
768 nouveau_drm_exit(void) 769 nouveau_drm_exit(void)
769 { 770 {
770 if (!nouveau_modeset) 771 if (!nouveau_modeset)
771 return; 772 return;
772 773
773 drm_pci_exit(&driver, &nouveau_drm_pci_driver); 774 drm_pci_exit(&driver, &nouveau_drm_pci_driver);
774 nouveau_unregister_dsm_handler(); 775 nouveau_unregister_dsm_handler();
775 } 776 }
776 777
777 module_init(nouveau_drm_init); 778 module_init(nouveau_drm_init);
778 module_exit(nouveau_drm_exit); 779 module_exit(nouveau_drm_exit);
779 780
780 MODULE_DEVICE_TABLE(pci, nouveau_drm_pci_table); 781 MODULE_DEVICE_TABLE(pci, nouveau_drm_pci_table);
781 MODULE_AUTHOR(DRIVER_AUTHOR); 782 MODULE_AUTHOR(DRIVER_AUTHOR);
782 MODULE_DESCRIPTION(DRIVER_DESC); 783 MODULE_DESCRIPTION(DRIVER_DESC);
783 MODULE_LICENSE("GPL and additional rights"); 784 MODULE_LICENSE("GPL and additional rights");
784 785
drivers/gpu/drm/nouveau/nv50_display.c
1 /* 1 /*
2 * Copyright 2011 Red Hat Inc. 2 * Copyright 2011 Red Hat Inc.
3 * 3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a 4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"), 5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation 6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the 8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions: 9 * Software is furnished to do so, subject to the following conditions:
10 * 10 *
11 * The above copyright notice and this permission notice shall be included in 11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software. 12 * all copies or substantial portions of the Software.
13 * 13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE. 20 * OTHER DEALINGS IN THE SOFTWARE.
21 * 21 *
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24 24
25 #include <linux/dma-mapping.h> 25 #include <linux/dma-mapping.h>
26 26
27 #include <drm/drmP.h> 27 #include <drm/drmP.h>
28 #include <drm/drm_crtc_helper.h> 28 #include <drm/drm_crtc_helper.h>
29 29
30 #include "nouveau_drm.h" 30 #include "nouveau_drm.h"
31 #include "nouveau_dma.h" 31 #include "nouveau_dma.h"
32 #include "nouveau_gem.h" 32 #include "nouveau_gem.h"
33 #include "nouveau_connector.h" 33 #include "nouveau_connector.h"
34 #include "nouveau_encoder.h" 34 #include "nouveau_encoder.h"
35 #include "nouveau_crtc.h" 35 #include "nouveau_crtc.h"
36 #include "nouveau_fence.h" 36 #include "nouveau_fence.h"
37 #include "nv50_display.h" 37 #include "nv50_display.h"
38 38
39 #include <core/client.h> 39 #include <core/client.h>
40 #include <core/gpuobj.h> 40 #include <core/gpuobj.h>
41 #include <core/class.h> 41 #include <core/class.h>
42 42
43 #include <subdev/timer.h> 43 #include <subdev/timer.h>
44 #include <subdev/bar.h> 44 #include <subdev/bar.h>
45 #include <subdev/fb.h> 45 #include <subdev/fb.h>
46 #include <subdev/i2c.h> 46 #include <subdev/i2c.h>
47 47
48 #define EVO_DMA_NR 9 48 #define EVO_DMA_NR 9
49 49
50 #define EVO_MASTER (0x00) 50 #define EVO_MASTER (0x00)
51 #define EVO_FLIP(c) (0x01 + (c)) 51 #define EVO_FLIP(c) (0x01 + (c))
52 #define EVO_OVLY(c) (0x05 + (c)) 52 #define EVO_OVLY(c) (0x05 + (c))
53 #define EVO_OIMM(c) (0x09 + (c)) 53 #define EVO_OIMM(c) (0x09 + (c))
54 #define EVO_CURS(c) (0x0d + (c)) 54 #define EVO_CURS(c) (0x0d + (c))
55 55
56 /* offsets in shared sync bo of various structures */ 56 /* offsets in shared sync bo of various structures */
57 #define EVO_SYNC(c, o) ((c) * 0x0100 + (o)) 57 #define EVO_SYNC(c, o) ((c) * 0x0100 + (o))
58 #define EVO_MAST_NTFY EVO_SYNC( 0, 0x00) 58 #define EVO_MAST_NTFY EVO_SYNC( 0, 0x00)
59 #define EVO_FLIP_SEM0(c) EVO_SYNC((c) + 1, 0x00) 59 #define EVO_FLIP_SEM0(c) EVO_SYNC((c) + 1, 0x00)
60 #define EVO_FLIP_SEM1(c) EVO_SYNC((c) + 1, 0x10) 60 #define EVO_FLIP_SEM1(c) EVO_SYNC((c) + 1, 0x10)
61 61
62 #define EVO_CORE_HANDLE (0xd1500000) 62 #define EVO_CORE_HANDLE (0xd1500000)
63 #define EVO_CHAN_HANDLE(t,i) (0xd15c0000 | (((t) & 0x00ff) << 8) | (i)) 63 #define EVO_CHAN_HANDLE(t,i) (0xd15c0000 | (((t) & 0x00ff) << 8) | (i))
64 #define EVO_CHAN_OCLASS(t,c) ((nv_hclass(c) & 0xff00) | ((t) & 0x00ff)) 64 #define EVO_CHAN_OCLASS(t,c) ((nv_hclass(c) & 0xff00) | ((t) & 0x00ff))
65 #define EVO_PUSH_HANDLE(t,i) (0xd15b0000 | (i) | \ 65 #define EVO_PUSH_HANDLE(t,i) (0xd15b0000 | (i) | \
66 (((NV50_DISP_##t##_CLASS) & 0x00ff) << 8)) 66 (((NV50_DISP_##t##_CLASS) & 0x00ff) << 8))
67 67
68 /****************************************************************************** 68 /******************************************************************************
69 * EVO channel 69 * EVO channel
70 *****************************************************************************/ 70 *****************************************************************************/
71 71
72 struct nv50_chan { 72 struct nv50_chan {
73 struct nouveau_object *user; 73 struct nouveau_object *user;
74 u32 handle; 74 u32 handle;
75 }; 75 };
76 76
77 static int 77 static int
78 nv50_chan_create(struct nouveau_object *core, u32 bclass, u8 head, 78 nv50_chan_create(struct nouveau_object *core, u32 bclass, u8 head,
79 void *data, u32 size, struct nv50_chan *chan) 79 void *data, u32 size, struct nv50_chan *chan)
80 { 80 {
81 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS); 81 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS);
82 const u32 oclass = EVO_CHAN_OCLASS(bclass, core); 82 const u32 oclass = EVO_CHAN_OCLASS(bclass, core);
83 const u32 handle = EVO_CHAN_HANDLE(bclass, head); 83 const u32 handle = EVO_CHAN_HANDLE(bclass, head);
84 int ret; 84 int ret;
85 85
86 ret = nouveau_object_new(client, EVO_CORE_HANDLE, handle, 86 ret = nouveau_object_new(client, EVO_CORE_HANDLE, handle,
87 oclass, data, size, &chan->user); 87 oclass, data, size, &chan->user);
88 if (ret) 88 if (ret)
89 return ret; 89 return ret;
90 90
91 chan->handle = handle; 91 chan->handle = handle;
92 return 0; 92 return 0;
93 } 93 }
94 94
95 static void 95 static void
96 nv50_chan_destroy(struct nouveau_object *core, struct nv50_chan *chan) 96 nv50_chan_destroy(struct nouveau_object *core, struct nv50_chan *chan)
97 { 97 {
98 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS); 98 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS);
99 if (chan->handle) 99 if (chan->handle)
100 nouveau_object_del(client, EVO_CORE_HANDLE, chan->handle); 100 nouveau_object_del(client, EVO_CORE_HANDLE, chan->handle);
101 } 101 }
102 102
103 /****************************************************************************** 103 /******************************************************************************
104 * PIO EVO channel 104 * PIO EVO channel
105 *****************************************************************************/ 105 *****************************************************************************/
106 106
107 struct nv50_pioc { 107 struct nv50_pioc {
108 struct nv50_chan base; 108 struct nv50_chan base;
109 }; 109 };
110 110
111 static void 111 static void
112 nv50_pioc_destroy(struct nouveau_object *core, struct nv50_pioc *pioc) 112 nv50_pioc_destroy(struct nouveau_object *core, struct nv50_pioc *pioc)
113 { 113 {
114 nv50_chan_destroy(core, &pioc->base); 114 nv50_chan_destroy(core, &pioc->base);
115 } 115 }
116 116
117 static int 117 static int
118 nv50_pioc_create(struct nouveau_object *core, u32 bclass, u8 head, 118 nv50_pioc_create(struct nouveau_object *core, u32 bclass, u8 head,
119 void *data, u32 size, struct nv50_pioc *pioc) 119 void *data, u32 size, struct nv50_pioc *pioc)
120 { 120 {
121 return nv50_chan_create(core, bclass, head, data, size, &pioc->base); 121 return nv50_chan_create(core, bclass, head, data, size, &pioc->base);
122 } 122 }
123 123
124 /****************************************************************************** 124 /******************************************************************************
125 * DMA EVO channel 125 * DMA EVO channel
126 *****************************************************************************/ 126 *****************************************************************************/
127 127
128 struct nv50_dmac { 128 struct nv50_dmac {
129 struct nv50_chan base; 129 struct nv50_chan base;
130 dma_addr_t handle; 130 dma_addr_t handle;
131 u32 *ptr; 131 u32 *ptr;
132 132
133 /* Protects against concurrent pushbuf access to this channel, lock is 133 /* Protects against concurrent pushbuf access to this channel, lock is
134 * grabbed by evo_wait (if the pushbuf reservation is successful) and 134 * grabbed by evo_wait (if the pushbuf reservation is successful) and
135 * dropped again by evo_kick. */ 135 * dropped again by evo_kick. */
136 struct mutex lock; 136 struct mutex lock;
137 }; 137 };
138 138
139 static void 139 static void
140 nv50_dmac_destroy(struct nouveau_object *core, struct nv50_dmac *dmac) 140 nv50_dmac_destroy(struct nouveau_object *core, struct nv50_dmac *dmac)
141 { 141 {
142 if (dmac->ptr) { 142 if (dmac->ptr) {
143 struct pci_dev *pdev = nv_device(core)->pdev; 143 struct pci_dev *pdev = nv_device(core)->pdev;
144 pci_free_consistent(pdev, PAGE_SIZE, dmac->ptr, dmac->handle); 144 pci_free_consistent(pdev, PAGE_SIZE, dmac->ptr, dmac->handle);
145 } 145 }
146 146
147 nv50_chan_destroy(core, &dmac->base); 147 nv50_chan_destroy(core, &dmac->base);
148 } 148 }
149 149
150 static int 150 static int
151 nv50_dmac_create_fbdma(struct nouveau_object *core, u32 parent) 151 nv50_dmac_create_fbdma(struct nouveau_object *core, u32 parent)
152 { 152 {
153 struct nouveau_fb *pfb = nouveau_fb(core); 153 struct nouveau_fb *pfb = nouveau_fb(core);
154 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS); 154 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS);
155 struct nouveau_object *object; 155 struct nouveau_object *object;
156 int ret = nouveau_object_new(client, parent, NvEvoVRAM_LP, 156 int ret = nouveau_object_new(client, parent, NvEvoVRAM_LP,
157 NV_DMA_IN_MEMORY_CLASS, 157 NV_DMA_IN_MEMORY_CLASS,
158 &(struct nv_dma_class) { 158 &(struct nv_dma_class) {
159 .flags = NV_DMA_TARGET_VRAM | 159 .flags = NV_DMA_TARGET_VRAM |
160 NV_DMA_ACCESS_RDWR, 160 NV_DMA_ACCESS_RDWR,
161 .start = 0, 161 .start = 0,
162 .limit = pfb->ram.size - 1, 162 .limit = pfb->ram.size - 1,
163 .conf0 = NV50_DMA_CONF0_ENABLE | 163 .conf0 = NV50_DMA_CONF0_ENABLE |
164 NV50_DMA_CONF0_PART_256, 164 NV50_DMA_CONF0_PART_256,
165 }, sizeof(struct nv_dma_class), &object); 165 }, sizeof(struct nv_dma_class), &object);
166 if (ret) 166 if (ret)
167 return ret; 167 return ret;
168 168
169 ret = nouveau_object_new(client, parent, NvEvoFB16, 169 ret = nouveau_object_new(client, parent, NvEvoFB16,
170 NV_DMA_IN_MEMORY_CLASS, 170 NV_DMA_IN_MEMORY_CLASS,
171 &(struct nv_dma_class) { 171 &(struct nv_dma_class) {
172 .flags = NV_DMA_TARGET_VRAM | 172 .flags = NV_DMA_TARGET_VRAM |
173 NV_DMA_ACCESS_RDWR, 173 NV_DMA_ACCESS_RDWR,
174 .start = 0, 174 .start = 0,
175 .limit = pfb->ram.size - 1, 175 .limit = pfb->ram.size - 1,
176 .conf0 = NV50_DMA_CONF0_ENABLE | 0x70 | 176 .conf0 = NV50_DMA_CONF0_ENABLE | 0x70 |
177 NV50_DMA_CONF0_PART_256, 177 NV50_DMA_CONF0_PART_256,
178 }, sizeof(struct nv_dma_class), &object); 178 }, sizeof(struct nv_dma_class), &object);
179 if (ret) 179 if (ret)
180 return ret; 180 return ret;
181 181
182 ret = nouveau_object_new(client, parent, NvEvoFB32, 182 ret = nouveau_object_new(client, parent, NvEvoFB32,
183 NV_DMA_IN_MEMORY_CLASS, 183 NV_DMA_IN_MEMORY_CLASS,
184 &(struct nv_dma_class) { 184 &(struct nv_dma_class) {
185 .flags = NV_DMA_TARGET_VRAM | 185 .flags = NV_DMA_TARGET_VRAM |
186 NV_DMA_ACCESS_RDWR, 186 NV_DMA_ACCESS_RDWR,
187 .start = 0, 187 .start = 0,
188 .limit = pfb->ram.size - 1, 188 .limit = pfb->ram.size - 1,
189 .conf0 = NV50_DMA_CONF0_ENABLE | 0x7a | 189 .conf0 = NV50_DMA_CONF0_ENABLE | 0x7a |
190 NV50_DMA_CONF0_PART_256, 190 NV50_DMA_CONF0_PART_256,
191 }, sizeof(struct nv_dma_class), &object); 191 }, sizeof(struct nv_dma_class), &object);
192 return ret; 192 return ret;
193 } 193 }
194 194
195 static int 195 static int
196 nvc0_dmac_create_fbdma(struct nouveau_object *core, u32 parent) 196 nvc0_dmac_create_fbdma(struct nouveau_object *core, u32 parent)
197 { 197 {
198 struct nouveau_fb *pfb = nouveau_fb(core); 198 struct nouveau_fb *pfb = nouveau_fb(core);
199 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS); 199 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS);
200 struct nouveau_object *object; 200 struct nouveau_object *object;
201 int ret = nouveau_object_new(client, parent, NvEvoVRAM_LP, 201 int ret = nouveau_object_new(client, parent, NvEvoVRAM_LP,
202 NV_DMA_IN_MEMORY_CLASS, 202 NV_DMA_IN_MEMORY_CLASS,
203 &(struct nv_dma_class) { 203 &(struct nv_dma_class) {
204 .flags = NV_DMA_TARGET_VRAM | 204 .flags = NV_DMA_TARGET_VRAM |
205 NV_DMA_ACCESS_RDWR, 205 NV_DMA_ACCESS_RDWR,
206 .start = 0, 206 .start = 0,
207 .limit = pfb->ram.size - 1, 207 .limit = pfb->ram.size - 1,
208 .conf0 = NVC0_DMA_CONF0_ENABLE, 208 .conf0 = NVC0_DMA_CONF0_ENABLE,
209 }, sizeof(struct nv_dma_class), &object); 209 }, sizeof(struct nv_dma_class), &object);
210 if (ret) 210 if (ret)
211 return ret; 211 return ret;
212 212
213 ret = nouveau_object_new(client, parent, NvEvoFB16, 213 ret = nouveau_object_new(client, parent, NvEvoFB16,
214 NV_DMA_IN_MEMORY_CLASS, 214 NV_DMA_IN_MEMORY_CLASS,
215 &(struct nv_dma_class) { 215 &(struct nv_dma_class) {
216 .flags = NV_DMA_TARGET_VRAM | 216 .flags = NV_DMA_TARGET_VRAM |
217 NV_DMA_ACCESS_RDWR, 217 NV_DMA_ACCESS_RDWR,
218 .start = 0, 218 .start = 0,
219 .limit = pfb->ram.size - 1, 219 .limit = pfb->ram.size - 1,
220 .conf0 = NVC0_DMA_CONF0_ENABLE | 0xfe, 220 .conf0 = NVC0_DMA_CONF0_ENABLE | 0xfe,
221 }, sizeof(struct nv_dma_class), &object); 221 }, sizeof(struct nv_dma_class), &object);
222 if (ret) 222 if (ret)
223 return ret; 223 return ret;
224 224
225 ret = nouveau_object_new(client, parent, NvEvoFB32, 225 ret = nouveau_object_new(client, parent, NvEvoFB32,
226 NV_DMA_IN_MEMORY_CLASS, 226 NV_DMA_IN_MEMORY_CLASS,
227 &(struct nv_dma_class) { 227 &(struct nv_dma_class) {
228 .flags = NV_DMA_TARGET_VRAM | 228 .flags = NV_DMA_TARGET_VRAM |
229 NV_DMA_ACCESS_RDWR, 229 NV_DMA_ACCESS_RDWR,
230 .start = 0, 230 .start = 0,
231 .limit = pfb->ram.size - 1, 231 .limit = pfb->ram.size - 1,
232 .conf0 = NVC0_DMA_CONF0_ENABLE | 0xfe, 232 .conf0 = NVC0_DMA_CONF0_ENABLE | 0xfe,
233 }, sizeof(struct nv_dma_class), &object); 233 }, sizeof(struct nv_dma_class), &object);
234 return ret; 234 return ret;
235 } 235 }
236 236
237 static int 237 static int
238 nvd0_dmac_create_fbdma(struct nouveau_object *core, u32 parent) 238 nvd0_dmac_create_fbdma(struct nouveau_object *core, u32 parent)
239 { 239 {
240 struct nouveau_fb *pfb = nouveau_fb(core); 240 struct nouveau_fb *pfb = nouveau_fb(core);
241 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS); 241 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS);
242 struct nouveau_object *object; 242 struct nouveau_object *object;
243 int ret = nouveau_object_new(client, parent, NvEvoVRAM_LP, 243 int ret = nouveau_object_new(client, parent, NvEvoVRAM_LP,
244 NV_DMA_IN_MEMORY_CLASS, 244 NV_DMA_IN_MEMORY_CLASS,
245 &(struct nv_dma_class) { 245 &(struct nv_dma_class) {
246 .flags = NV_DMA_TARGET_VRAM | 246 .flags = NV_DMA_TARGET_VRAM |
247 NV_DMA_ACCESS_RDWR, 247 NV_DMA_ACCESS_RDWR,
248 .start = 0, 248 .start = 0,
249 .limit = pfb->ram.size - 1, 249 .limit = pfb->ram.size - 1,
250 .conf0 = NVD0_DMA_CONF0_ENABLE | 250 .conf0 = NVD0_DMA_CONF0_ENABLE |
251 NVD0_DMA_CONF0_PAGE_LP, 251 NVD0_DMA_CONF0_PAGE_LP,
252 }, sizeof(struct nv_dma_class), &object); 252 }, sizeof(struct nv_dma_class), &object);
253 if (ret) 253 if (ret)
254 return ret; 254 return ret;
255 255
256 ret = nouveau_object_new(client, parent, NvEvoFB32, 256 ret = nouveau_object_new(client, parent, NvEvoFB32,
257 NV_DMA_IN_MEMORY_CLASS, 257 NV_DMA_IN_MEMORY_CLASS,
258 &(struct nv_dma_class) { 258 &(struct nv_dma_class) {
259 .flags = NV_DMA_TARGET_VRAM | 259 .flags = NV_DMA_TARGET_VRAM |
260 NV_DMA_ACCESS_RDWR, 260 NV_DMA_ACCESS_RDWR,
261 .start = 0, 261 .start = 0,
262 .limit = pfb->ram.size - 1, 262 .limit = pfb->ram.size - 1,
263 .conf0 = NVD0_DMA_CONF0_ENABLE | 0xfe | 263 .conf0 = NVD0_DMA_CONF0_ENABLE | 0xfe |
264 NVD0_DMA_CONF0_PAGE_LP, 264 NVD0_DMA_CONF0_PAGE_LP,
265 }, sizeof(struct nv_dma_class), &object); 265 }, sizeof(struct nv_dma_class), &object);
266 return ret; 266 return ret;
267 } 267 }
268 268
269 static int 269 static int
270 nv50_dmac_create(struct nouveau_object *core, u32 bclass, u8 head, 270 nv50_dmac_create(struct nouveau_object *core, u32 bclass, u8 head,
271 void *data, u32 size, u64 syncbuf, 271 void *data, u32 size, u64 syncbuf,
272 struct nv50_dmac *dmac) 272 struct nv50_dmac *dmac)
273 { 273 {
274 struct nouveau_fb *pfb = nouveau_fb(core); 274 struct nouveau_fb *pfb = nouveau_fb(core);
275 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS); 275 struct nouveau_object *client = nv_pclass(core, NV_CLIENT_CLASS);
276 struct nouveau_object *object; 276 struct nouveau_object *object;
277 u32 pushbuf = *(u32 *)data; 277 u32 pushbuf = *(u32 *)data;
278 int ret; 278 int ret;
279 279
280 mutex_init(&dmac->lock); 280 mutex_init(&dmac->lock);
281 281
282 dmac->ptr = pci_alloc_consistent(nv_device(core)->pdev, PAGE_SIZE, 282 dmac->ptr = pci_alloc_consistent(nv_device(core)->pdev, PAGE_SIZE,
283 &dmac->handle); 283 &dmac->handle);
284 if (!dmac->ptr) 284 if (!dmac->ptr)
285 return -ENOMEM; 285 return -ENOMEM;
286 286
287 ret = nouveau_object_new(client, NVDRM_DEVICE, pushbuf, 287 ret = nouveau_object_new(client, NVDRM_DEVICE, pushbuf,
288 NV_DMA_FROM_MEMORY_CLASS, 288 NV_DMA_FROM_MEMORY_CLASS,
289 &(struct nv_dma_class) { 289 &(struct nv_dma_class) {
290 .flags = NV_DMA_TARGET_PCI_US | 290 .flags = NV_DMA_TARGET_PCI_US |
291 NV_DMA_ACCESS_RD, 291 NV_DMA_ACCESS_RD,
292 .start = dmac->handle + 0x0000, 292 .start = dmac->handle + 0x0000,
293 .limit = dmac->handle + 0x0fff, 293 .limit = dmac->handle + 0x0fff,
294 }, sizeof(struct nv_dma_class), &object); 294 }, sizeof(struct nv_dma_class), &object);
295 if (ret) 295 if (ret)
296 return ret; 296 return ret;
297 297
298 ret = nv50_chan_create(core, bclass, head, data, size, &dmac->base); 298 ret = nv50_chan_create(core, bclass, head, data, size, &dmac->base);
299 if (ret) 299 if (ret)
300 return ret; 300 return ret;
301 301
302 ret = nouveau_object_new(client, dmac->base.handle, NvEvoSync, 302 ret = nouveau_object_new(client, dmac->base.handle, NvEvoSync,
303 NV_DMA_IN_MEMORY_CLASS, 303 NV_DMA_IN_MEMORY_CLASS,
304 &(struct nv_dma_class) { 304 &(struct nv_dma_class) {
305 .flags = NV_DMA_TARGET_VRAM | 305 .flags = NV_DMA_TARGET_VRAM |
306 NV_DMA_ACCESS_RDWR, 306 NV_DMA_ACCESS_RDWR,
307 .start = syncbuf + 0x0000, 307 .start = syncbuf + 0x0000,
308 .limit = syncbuf + 0x0fff, 308 .limit = syncbuf + 0x0fff,
309 }, sizeof(struct nv_dma_class), &object); 309 }, sizeof(struct nv_dma_class), &object);
310 if (ret) 310 if (ret)
311 return ret; 311 return ret;
312 312
313 ret = nouveau_object_new(client, dmac->base.handle, NvEvoVRAM, 313 ret = nouveau_object_new(client, dmac->base.handle, NvEvoVRAM,
314 NV_DMA_IN_MEMORY_CLASS, 314 NV_DMA_IN_MEMORY_CLASS,
315 &(struct nv_dma_class) { 315 &(struct nv_dma_class) {
316 .flags = NV_DMA_TARGET_VRAM | 316 .flags = NV_DMA_TARGET_VRAM |
317 NV_DMA_ACCESS_RDWR, 317 NV_DMA_ACCESS_RDWR,
318 .start = 0, 318 .start = 0,
319 .limit = pfb->ram.size - 1, 319 .limit = pfb->ram.size - 1,
320 }, sizeof(struct nv_dma_class), &object); 320 }, sizeof(struct nv_dma_class), &object);
321 if (ret) 321 if (ret)
322 return ret; 322 return ret;
323 323
324 if (nv_device(core)->card_type < NV_C0) 324 if (nv_device(core)->card_type < NV_C0)
325 ret = nv50_dmac_create_fbdma(core, dmac->base.handle); 325 ret = nv50_dmac_create_fbdma(core, dmac->base.handle);
326 else 326 else
327 if (nv_device(core)->card_type < NV_D0) 327 if (nv_device(core)->card_type < NV_D0)
328 ret = nvc0_dmac_create_fbdma(core, dmac->base.handle); 328 ret = nvc0_dmac_create_fbdma(core, dmac->base.handle);
329 else 329 else
330 ret = nvd0_dmac_create_fbdma(core, dmac->base.handle); 330 ret = nvd0_dmac_create_fbdma(core, dmac->base.handle);
331 return ret; 331 return ret;
332 } 332 }
333 333
334 struct nv50_mast { 334 struct nv50_mast {
335 struct nv50_dmac base; 335 struct nv50_dmac base;
336 }; 336 };
337 337
338 struct nv50_curs { 338 struct nv50_curs {
339 struct nv50_pioc base; 339 struct nv50_pioc base;
340 }; 340 };
341 341
342 struct nv50_sync { 342 struct nv50_sync {
343 struct nv50_dmac base; 343 struct nv50_dmac base;
344 u32 addr; 344 u32 addr;
345 u32 data; 345 u32 data;
346 }; 346 };
347 347
348 struct nv50_ovly { 348 struct nv50_ovly {
349 struct nv50_dmac base; 349 struct nv50_dmac base;
350 }; 350 };
351 351
352 struct nv50_oimm { 352 struct nv50_oimm {
353 struct nv50_pioc base; 353 struct nv50_pioc base;
354 }; 354 };
355 355
356 struct nv50_head { 356 struct nv50_head {
357 struct nouveau_crtc base; 357 struct nouveau_crtc base;
358 struct nv50_curs curs; 358 struct nv50_curs curs;
359 struct nv50_sync sync; 359 struct nv50_sync sync;
360 struct nv50_ovly ovly; 360 struct nv50_ovly ovly;
361 struct nv50_oimm oimm; 361 struct nv50_oimm oimm;
362 }; 362 };
363 363
364 #define nv50_head(c) ((struct nv50_head *)nouveau_crtc(c)) 364 #define nv50_head(c) ((struct nv50_head *)nouveau_crtc(c))
365 #define nv50_curs(c) (&nv50_head(c)->curs) 365 #define nv50_curs(c) (&nv50_head(c)->curs)
366 #define nv50_sync(c) (&nv50_head(c)->sync) 366 #define nv50_sync(c) (&nv50_head(c)->sync)
367 #define nv50_ovly(c) (&nv50_head(c)->ovly) 367 #define nv50_ovly(c) (&nv50_head(c)->ovly)
368 #define nv50_oimm(c) (&nv50_head(c)->oimm) 368 #define nv50_oimm(c) (&nv50_head(c)->oimm)
369 #define nv50_chan(c) (&(c)->base.base) 369 #define nv50_chan(c) (&(c)->base.base)
370 #define nv50_vers(c) nv_mclass(nv50_chan(c)->user) 370 #define nv50_vers(c) nv_mclass(nv50_chan(c)->user)
371 371
372 struct nv50_disp { 372 struct nv50_disp {
373 struct nouveau_object *core; 373 struct nouveau_object *core;
374 struct nv50_mast mast; 374 struct nv50_mast mast;
375 375
376 u32 modeset; 376 u32 modeset;
377 377
378 struct nouveau_bo *sync; 378 struct nouveau_bo *sync;
379 }; 379 };
380 380
381 static struct nv50_disp * 381 static struct nv50_disp *
382 nv50_disp(struct drm_device *dev) 382 nv50_disp(struct drm_device *dev)
383 { 383 {
384 return nouveau_display(dev)->priv; 384 return nouveau_display(dev)->priv;
385 } 385 }
386 386
387 #define nv50_mast(d) (&nv50_disp(d)->mast) 387 #define nv50_mast(d) (&nv50_disp(d)->mast)
388 388
389 static struct drm_crtc * 389 static struct drm_crtc *
390 nv50_display_crtc_get(struct drm_encoder *encoder) 390 nv50_display_crtc_get(struct drm_encoder *encoder)
391 { 391 {
392 return nouveau_encoder(encoder)->crtc; 392 return nouveau_encoder(encoder)->crtc;
393 } 393 }
394 394
395 /****************************************************************************** 395 /******************************************************************************
396 * EVO channel helpers 396 * EVO channel helpers
397 *****************************************************************************/ 397 *****************************************************************************/
398 static u32 * 398 static u32 *
399 evo_wait(void *evoc, int nr) 399 evo_wait(void *evoc, int nr)
400 { 400 {
401 struct nv50_dmac *dmac = evoc; 401 struct nv50_dmac *dmac = evoc;
402 u32 put = nv_ro32(dmac->base.user, 0x0000) / 4; 402 u32 put = nv_ro32(dmac->base.user, 0x0000) / 4;
403 403
404 mutex_lock(&dmac->lock); 404 mutex_lock(&dmac->lock);
405 if (put + nr >= (PAGE_SIZE / 4) - 8) { 405 if (put + nr >= (PAGE_SIZE / 4) - 8) {
406 dmac->ptr[put] = 0x20000000; 406 dmac->ptr[put] = 0x20000000;
407 407
408 nv_wo32(dmac->base.user, 0x0000, 0x00000000); 408 nv_wo32(dmac->base.user, 0x0000, 0x00000000);
409 if (!nv_wait(dmac->base.user, 0x0004, ~0, 0x00000000)) { 409 if (!nv_wait(dmac->base.user, 0x0004, ~0, 0x00000000)) {
410 mutex_unlock(&dmac->lock); 410 mutex_unlock(&dmac->lock);
411 NV_ERROR(dmac->base.user, "channel stalled\n"); 411 NV_ERROR(dmac->base.user, "channel stalled\n");
412 return NULL; 412 return NULL;
413 } 413 }
414 414
415 put = 0; 415 put = 0;
416 } 416 }
417 417
418 return dmac->ptr + put; 418 return dmac->ptr + put;
419 } 419 }
420 420
421 static void 421 static void
422 evo_kick(u32 *push, void *evoc) 422 evo_kick(u32 *push, void *evoc)
423 { 423 {
424 struct nv50_dmac *dmac = evoc; 424 struct nv50_dmac *dmac = evoc;
425 nv_wo32(dmac->base.user, 0x0000, (push - dmac->ptr) << 2); 425 nv_wo32(dmac->base.user, 0x0000, (push - dmac->ptr) << 2);
426 mutex_unlock(&dmac->lock); 426 mutex_unlock(&dmac->lock);
427 } 427 }
428 428
429 #define evo_mthd(p,m,s) *((p)++) = (((s) << 18) | (m)) 429 #define evo_mthd(p,m,s) *((p)++) = (((s) << 18) | (m))
430 #define evo_data(p,d) *((p)++) = (d) 430 #define evo_data(p,d) *((p)++) = (d)
431 431
432 static bool 432 static bool
433 evo_sync_wait(void *data) 433 evo_sync_wait(void *data)
434 { 434 {
435 if (nouveau_bo_rd32(data, EVO_MAST_NTFY) != 0x00000000) 435 if (nouveau_bo_rd32(data, EVO_MAST_NTFY) != 0x00000000)
436 return true; 436 return true;
437 usleep_range(1, 2); 437 usleep_range(1, 2);
438 return false; 438 return false;
439 } 439 }
440 440
441 static int 441 static int
442 evo_sync(struct drm_device *dev) 442 evo_sync(struct drm_device *dev)
443 { 443 {
444 struct nouveau_device *device = nouveau_dev(dev); 444 struct nouveau_device *device = nouveau_dev(dev);
445 struct nv50_disp *disp = nv50_disp(dev); 445 struct nv50_disp *disp = nv50_disp(dev);
446 struct nv50_mast *mast = nv50_mast(dev); 446 struct nv50_mast *mast = nv50_mast(dev);
447 u32 *push = evo_wait(mast, 8); 447 u32 *push = evo_wait(mast, 8);
448 if (push) { 448 if (push) {
449 nouveau_bo_wr32(disp->sync, EVO_MAST_NTFY, 0x00000000); 449 nouveau_bo_wr32(disp->sync, EVO_MAST_NTFY, 0x00000000);
450 evo_mthd(push, 0x0084, 1); 450 evo_mthd(push, 0x0084, 1);
451 evo_data(push, 0x80000000 | EVO_MAST_NTFY); 451 evo_data(push, 0x80000000 | EVO_MAST_NTFY);
452 evo_mthd(push, 0x0080, 2); 452 evo_mthd(push, 0x0080, 2);
453 evo_data(push, 0x00000000); 453 evo_data(push, 0x00000000);
454 evo_data(push, 0x00000000); 454 evo_data(push, 0x00000000);
455 evo_kick(push, mast); 455 evo_kick(push, mast);
456 if (nv_wait_cb(device, evo_sync_wait, disp->sync)) 456 if (nv_wait_cb(device, evo_sync_wait, disp->sync))
457 return 0; 457 return 0;
458 } 458 }
459 459
460 return -EBUSY; 460 return -EBUSY;
461 } 461 }
462 462
463 /****************************************************************************** 463 /******************************************************************************
464 * Page flipping channel 464 * Page flipping channel
465 *****************************************************************************/ 465 *****************************************************************************/
466 struct nouveau_bo * 466 struct nouveau_bo *
467 nv50_display_crtc_sema(struct drm_device *dev, int crtc) 467 nv50_display_crtc_sema(struct drm_device *dev, int crtc)
468 { 468 {
469 return nv50_disp(dev)->sync; 469 return nv50_disp(dev)->sync;
470 } 470 }
471 471
472 struct nv50_display_flip { 472 struct nv50_display_flip {
473 struct nv50_disp *disp; 473 struct nv50_disp *disp;
474 struct nv50_sync *chan; 474 struct nv50_sync *chan;
475 }; 475 };
476 476
477 static bool 477 static bool
478 nv50_display_flip_wait(void *data) 478 nv50_display_flip_wait(void *data)
479 { 479 {
480 struct nv50_display_flip *flip = data; 480 struct nv50_display_flip *flip = data;
481 if (nouveau_bo_rd32(flip->disp->sync, flip->chan->addr / 4) == 481 if (nouveau_bo_rd32(flip->disp->sync, flip->chan->addr / 4) ==
482 flip->chan->data); 482 flip->chan->data);
483 return true; 483 return true;
484 usleep_range(1, 2); 484 usleep_range(1, 2);
485 return false; 485 return false;
486 } 486 }
487 487
488 void 488 void
489 nv50_display_flip_stop(struct drm_crtc *crtc) 489 nv50_display_flip_stop(struct drm_crtc *crtc)
490 { 490 {
491 struct nouveau_device *device = nouveau_dev(crtc->dev); 491 struct nouveau_device *device = nouveau_dev(crtc->dev);
492 struct nv50_display_flip flip = { 492 struct nv50_display_flip flip = {
493 .disp = nv50_disp(crtc->dev), 493 .disp = nv50_disp(crtc->dev),
494 .chan = nv50_sync(crtc), 494 .chan = nv50_sync(crtc),
495 }; 495 };
496 u32 *push; 496 u32 *push;
497 497
498 push = evo_wait(flip.chan, 8); 498 push = evo_wait(flip.chan, 8);
499 if (push) { 499 if (push) {
500 evo_mthd(push, 0x0084, 1); 500 evo_mthd(push, 0x0084, 1);
501 evo_data(push, 0x00000000); 501 evo_data(push, 0x00000000);
502 evo_mthd(push, 0x0094, 1); 502 evo_mthd(push, 0x0094, 1);
503 evo_data(push, 0x00000000); 503 evo_data(push, 0x00000000);
504 evo_mthd(push, 0x00c0, 1); 504 evo_mthd(push, 0x00c0, 1);
505 evo_data(push, 0x00000000); 505 evo_data(push, 0x00000000);
506 evo_mthd(push, 0x0080, 1); 506 evo_mthd(push, 0x0080, 1);
507 evo_data(push, 0x00000000); 507 evo_data(push, 0x00000000);
508 evo_kick(push, flip.chan); 508 evo_kick(push, flip.chan);
509 } 509 }
510 510
511 nv_wait_cb(device, nv50_display_flip_wait, &flip); 511 nv_wait_cb(device, nv50_display_flip_wait, &flip);
512 } 512 }
513 513
514 int 514 int
515 nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb, 515 nv50_display_flip_next(struct drm_crtc *crtc, struct drm_framebuffer *fb,
516 struct nouveau_channel *chan, u32 swap_interval) 516 struct nouveau_channel *chan, u32 swap_interval)
517 { 517 {
518 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb); 518 struct nouveau_framebuffer *nv_fb = nouveau_framebuffer(fb);
519 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 519 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
520 struct nv50_sync *sync = nv50_sync(crtc); 520 struct nv50_sync *sync = nv50_sync(crtc);
521 int head = nv_crtc->index, ret; 521 int head = nv_crtc->index, ret;
522 u32 *push; 522 u32 *push;
523 523
524 swap_interval <<= 4; 524 swap_interval <<= 4;
525 if (swap_interval == 0) 525 if (swap_interval == 0)
526 swap_interval |= 0x100; 526 swap_interval |= 0x100;
527 if (chan == NULL) 527 if (chan == NULL)
528 evo_sync(crtc->dev); 528 evo_sync(crtc->dev);
529 529
530 push = evo_wait(sync, 128); 530 push = evo_wait(sync, 128);
531 if (unlikely(push == NULL)) 531 if (unlikely(push == NULL))
532 return -EBUSY; 532 return -EBUSY;
533 533
534 if (chan && nv_mclass(chan->object) < NV84_CHANNEL_IND_CLASS) { 534 if (chan && nv_mclass(chan->object) < NV84_CHANNEL_IND_CLASS) {
535 ret = RING_SPACE(chan, 8); 535 ret = RING_SPACE(chan, 8);
536 if (ret) 536 if (ret)
537 return ret; 537 return ret;
538 538
539 BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 2); 539 BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 2);
540 OUT_RING (chan, NvEvoSema0 + head); 540 OUT_RING (chan, NvEvoSema0 + head);
541 OUT_RING (chan, sync->addr ^ 0x10); 541 OUT_RING (chan, sync->addr ^ 0x10);
542 BEGIN_NV04(chan, 0, NV11_SUBCHAN_SEMAPHORE_RELEASE, 1); 542 BEGIN_NV04(chan, 0, NV11_SUBCHAN_SEMAPHORE_RELEASE, 1);
543 OUT_RING (chan, sync->data + 1); 543 OUT_RING (chan, sync->data + 1);
544 BEGIN_NV04(chan, 0, NV11_SUBCHAN_SEMAPHORE_OFFSET, 2); 544 BEGIN_NV04(chan, 0, NV11_SUBCHAN_SEMAPHORE_OFFSET, 2);
545 OUT_RING (chan, sync->addr); 545 OUT_RING (chan, sync->addr);
546 OUT_RING (chan, sync->data); 546 OUT_RING (chan, sync->data);
547 } else 547 } else
548 if (chan && nv_mclass(chan->object) < NVC0_CHANNEL_IND_CLASS) { 548 if (chan && nv_mclass(chan->object) < NVC0_CHANNEL_IND_CLASS) {
549 u64 addr = nv84_fence_crtc(chan, head) + sync->addr; 549 u64 addr = nv84_fence_crtc(chan, head) + sync->addr;
550 ret = RING_SPACE(chan, 12); 550 ret = RING_SPACE(chan, 12);
551 if (ret) 551 if (ret)
552 return ret; 552 return ret;
553 553
554 BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 1); 554 BEGIN_NV04(chan, 0, NV11_SUBCHAN_DMA_SEMAPHORE, 1);
555 OUT_RING (chan, chan->vram); 555 OUT_RING (chan, chan->vram);
556 BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); 556 BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4);
557 OUT_RING (chan, upper_32_bits(addr ^ 0x10)); 557 OUT_RING (chan, upper_32_bits(addr ^ 0x10));
558 OUT_RING (chan, lower_32_bits(addr ^ 0x10)); 558 OUT_RING (chan, lower_32_bits(addr ^ 0x10));
559 OUT_RING (chan, sync->data + 1); 559 OUT_RING (chan, sync->data + 1);
560 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG); 560 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG);
561 BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); 561 BEGIN_NV04(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4);
562 OUT_RING (chan, upper_32_bits(addr)); 562 OUT_RING (chan, upper_32_bits(addr));
563 OUT_RING (chan, lower_32_bits(addr)); 563 OUT_RING (chan, lower_32_bits(addr));
564 OUT_RING (chan, sync->data); 564 OUT_RING (chan, sync->data);
565 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL); 565 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL);
566 } else 566 } else
567 if (chan) { 567 if (chan) {
568 u64 addr = nv84_fence_crtc(chan, head) + sync->addr; 568 u64 addr = nv84_fence_crtc(chan, head) + sync->addr;
569 ret = RING_SPACE(chan, 10); 569 ret = RING_SPACE(chan, 10);
570 if (ret) 570 if (ret)
571 return ret; 571 return ret;
572 572
573 BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); 573 BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4);
574 OUT_RING (chan, upper_32_bits(addr ^ 0x10)); 574 OUT_RING (chan, upper_32_bits(addr ^ 0x10));
575 OUT_RING (chan, lower_32_bits(addr ^ 0x10)); 575 OUT_RING (chan, lower_32_bits(addr ^ 0x10));
576 OUT_RING (chan, sync->data + 1); 576 OUT_RING (chan, sync->data + 1);
577 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG | 577 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_WRITE_LONG |
578 NVC0_SUBCHAN_SEMAPHORE_TRIGGER_YIELD); 578 NVC0_SUBCHAN_SEMAPHORE_TRIGGER_YIELD);
579 BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4); 579 BEGIN_NVC0(chan, 0, NV84_SUBCHAN_SEMAPHORE_ADDRESS_HIGH, 4);
580 OUT_RING (chan, upper_32_bits(addr)); 580 OUT_RING (chan, upper_32_bits(addr));
581 OUT_RING (chan, lower_32_bits(addr)); 581 OUT_RING (chan, lower_32_bits(addr));
582 OUT_RING (chan, sync->data); 582 OUT_RING (chan, sync->data);
583 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL | 583 OUT_RING (chan, NV84_SUBCHAN_SEMAPHORE_TRIGGER_ACQUIRE_EQUAL |
584 NVC0_SUBCHAN_SEMAPHORE_TRIGGER_YIELD); 584 NVC0_SUBCHAN_SEMAPHORE_TRIGGER_YIELD);
585 } 585 }
586 586
587 if (chan) { 587 if (chan) {
588 sync->addr ^= 0x10; 588 sync->addr ^= 0x10;
589 sync->data++; 589 sync->data++;
590 FIRE_RING (chan); 590 FIRE_RING (chan);
591 } 591 }
592 592
593 /* queue the flip */ 593 /* queue the flip */
594 evo_mthd(push, 0x0100, 1); 594 evo_mthd(push, 0x0100, 1);
595 evo_data(push, 0xfffe0000); 595 evo_data(push, 0xfffe0000);
596 evo_mthd(push, 0x0084, 1); 596 evo_mthd(push, 0x0084, 1);
597 evo_data(push, swap_interval); 597 evo_data(push, swap_interval);
598 if (!(swap_interval & 0x00000100)) { 598 if (!(swap_interval & 0x00000100)) {
599 evo_mthd(push, 0x00e0, 1); 599 evo_mthd(push, 0x00e0, 1);
600 evo_data(push, 0x40000000); 600 evo_data(push, 0x40000000);
601 } 601 }
602 evo_mthd(push, 0x0088, 4); 602 evo_mthd(push, 0x0088, 4);
603 evo_data(push, sync->addr); 603 evo_data(push, sync->addr);
604 evo_data(push, sync->data++); 604 evo_data(push, sync->data++);
605 evo_data(push, sync->data); 605 evo_data(push, sync->data);
606 evo_data(push, NvEvoSync); 606 evo_data(push, NvEvoSync);
607 evo_mthd(push, 0x00a0, 2); 607 evo_mthd(push, 0x00a0, 2);
608 evo_data(push, 0x00000000); 608 evo_data(push, 0x00000000);
609 evo_data(push, 0x00000000); 609 evo_data(push, 0x00000000);
610 evo_mthd(push, 0x00c0, 1); 610 evo_mthd(push, 0x00c0, 1);
611 evo_data(push, nv_fb->r_dma); 611 evo_data(push, nv_fb->r_dma);
612 evo_mthd(push, 0x0110, 2); 612 evo_mthd(push, 0x0110, 2);
613 evo_data(push, 0x00000000); 613 evo_data(push, 0x00000000);
614 evo_data(push, 0x00000000); 614 evo_data(push, 0x00000000);
615 if (nv50_vers(sync) < NVD0_DISP_SYNC_CLASS) { 615 if (nv50_vers(sync) < NVD0_DISP_SYNC_CLASS) {
616 evo_mthd(push, 0x0800, 5); 616 evo_mthd(push, 0x0800, 5);
617 evo_data(push, nv_fb->nvbo->bo.offset >> 8); 617 evo_data(push, nv_fb->nvbo->bo.offset >> 8);
618 evo_data(push, 0); 618 evo_data(push, 0);
619 evo_data(push, (fb->height << 16) | fb->width); 619 evo_data(push, (fb->height << 16) | fb->width);
620 evo_data(push, nv_fb->r_pitch); 620 evo_data(push, nv_fb->r_pitch);
621 evo_data(push, nv_fb->r_format); 621 evo_data(push, nv_fb->r_format);
622 } else { 622 } else {
623 evo_mthd(push, 0x0400, 5); 623 evo_mthd(push, 0x0400, 5);
624 evo_data(push, nv_fb->nvbo->bo.offset >> 8); 624 evo_data(push, nv_fb->nvbo->bo.offset >> 8);
625 evo_data(push, 0); 625 evo_data(push, 0);
626 evo_data(push, (fb->height << 16) | fb->width); 626 evo_data(push, (fb->height << 16) | fb->width);
627 evo_data(push, nv_fb->r_pitch); 627 evo_data(push, nv_fb->r_pitch);
628 evo_data(push, nv_fb->r_format); 628 evo_data(push, nv_fb->r_format);
629 } 629 }
630 evo_mthd(push, 0x0080, 1); 630 evo_mthd(push, 0x0080, 1);
631 evo_data(push, 0x00000000); 631 evo_data(push, 0x00000000);
632 evo_kick(push, sync); 632 evo_kick(push, sync);
633 return 0; 633 return 0;
634 } 634 }
635 635
636 /****************************************************************************** 636 /******************************************************************************
637 * CRTC 637 * CRTC
638 *****************************************************************************/ 638 *****************************************************************************/
639 static int 639 static int
640 nv50_crtc_set_dither(struct nouveau_crtc *nv_crtc, bool update) 640 nv50_crtc_set_dither(struct nouveau_crtc *nv_crtc, bool update)
641 { 641 {
642 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev); 642 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev);
643 struct nouveau_connector *nv_connector; 643 struct nouveau_connector *nv_connector;
644 struct drm_connector *connector; 644 struct drm_connector *connector;
645 u32 *push, mode = 0x00; 645 u32 *push, mode = 0x00;
646 646
647 nv_connector = nouveau_crtc_connector_get(nv_crtc); 647 nv_connector = nouveau_crtc_connector_get(nv_crtc);
648 connector = &nv_connector->base; 648 connector = &nv_connector->base;
649 if (nv_connector->dithering_mode == DITHERING_MODE_AUTO) { 649 if (nv_connector->dithering_mode == DITHERING_MODE_AUTO) {
650 if (nv_crtc->base.fb->depth > connector->display_info.bpc * 3) 650 if (nv_crtc->base.fb->depth > connector->display_info.bpc * 3)
651 mode = DITHERING_MODE_DYNAMIC2X2; 651 mode = DITHERING_MODE_DYNAMIC2X2;
652 } else { 652 } else {
653 mode = nv_connector->dithering_mode; 653 mode = nv_connector->dithering_mode;
654 } 654 }
655 655
656 if (nv_connector->dithering_depth == DITHERING_DEPTH_AUTO) { 656 if (nv_connector->dithering_depth == DITHERING_DEPTH_AUTO) {
657 if (connector->display_info.bpc >= 8) 657 if (connector->display_info.bpc >= 8)
658 mode |= DITHERING_DEPTH_8BPC; 658 mode |= DITHERING_DEPTH_8BPC;
659 } else { 659 } else {
660 mode |= nv_connector->dithering_depth; 660 mode |= nv_connector->dithering_depth;
661 } 661 }
662 662
663 push = evo_wait(mast, 4); 663 push = evo_wait(mast, 4);
664 if (push) { 664 if (push) {
665 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 665 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
666 evo_mthd(push, 0x08a0 + (nv_crtc->index * 0x0400), 1); 666 evo_mthd(push, 0x08a0 + (nv_crtc->index * 0x0400), 1);
667 evo_data(push, mode); 667 evo_data(push, mode);
668 } else 668 } else
669 if (nv50_vers(mast) < NVE0_DISP_MAST_CLASS) { 669 if (nv50_vers(mast) < NVE0_DISP_MAST_CLASS) {
670 evo_mthd(push, 0x0490 + (nv_crtc->index * 0x0300), 1); 670 evo_mthd(push, 0x0490 + (nv_crtc->index * 0x0300), 1);
671 evo_data(push, mode); 671 evo_data(push, mode);
672 } else { 672 } else {
673 evo_mthd(push, 0x04a0 + (nv_crtc->index * 0x0300), 1); 673 evo_mthd(push, 0x04a0 + (nv_crtc->index * 0x0300), 1);
674 evo_data(push, mode); 674 evo_data(push, mode);
675 } 675 }
676 676
677 if (update) { 677 if (update) {
678 evo_mthd(push, 0x0080, 1); 678 evo_mthd(push, 0x0080, 1);
679 evo_data(push, 0x00000000); 679 evo_data(push, 0x00000000);
680 } 680 }
681 evo_kick(push, mast); 681 evo_kick(push, mast);
682 } 682 }
683 683
684 return 0; 684 return 0;
685 } 685 }
686 686
687 static int 687 static int
688 nv50_crtc_set_scale(struct nouveau_crtc *nv_crtc, bool update) 688 nv50_crtc_set_scale(struct nouveau_crtc *nv_crtc, bool update)
689 { 689 {
690 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev); 690 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev);
691 struct drm_display_mode *omode, *umode = &nv_crtc->base.mode; 691 struct drm_display_mode *omode, *umode = &nv_crtc->base.mode;
692 struct drm_crtc *crtc = &nv_crtc->base; 692 struct drm_crtc *crtc = &nv_crtc->base;
693 struct nouveau_connector *nv_connector; 693 struct nouveau_connector *nv_connector;
694 int mode = DRM_MODE_SCALE_NONE; 694 int mode = DRM_MODE_SCALE_NONE;
695 u32 oX, oY, *push; 695 u32 oX, oY, *push;
696 696
697 /* start off at the resolution we programmed the crtc for, this 697 /* start off at the resolution we programmed the crtc for, this
698 * effectively handles NONE/FULL scaling 698 * effectively handles NONE/FULL scaling
699 */ 699 */
700 nv_connector = nouveau_crtc_connector_get(nv_crtc); 700 nv_connector = nouveau_crtc_connector_get(nv_crtc);
701 if (nv_connector && nv_connector->native_mode) 701 if (nv_connector && nv_connector->native_mode)
702 mode = nv_connector->scaling_mode; 702 mode = nv_connector->scaling_mode;
703 703
704 if (mode != DRM_MODE_SCALE_NONE) 704 if (mode != DRM_MODE_SCALE_NONE)
705 omode = nv_connector->native_mode; 705 omode = nv_connector->native_mode;
706 else 706 else
707 omode = umode; 707 omode = umode;
708 708
709 oX = omode->hdisplay; 709 oX = omode->hdisplay;
710 oY = omode->vdisplay; 710 oY = omode->vdisplay;
711 if (omode->flags & DRM_MODE_FLAG_DBLSCAN) 711 if (omode->flags & DRM_MODE_FLAG_DBLSCAN)
712 oY *= 2; 712 oY *= 2;
713 713
714 /* add overscan compensation if necessary, will keep the aspect 714 /* add overscan compensation if necessary, will keep the aspect
715 * ratio the same as the backend mode unless overridden by the 715 * ratio the same as the backend mode unless overridden by the
716 * user setting both hborder and vborder properties. 716 * user setting both hborder and vborder properties.
717 */ 717 */
718 if (nv_connector && ( nv_connector->underscan == UNDERSCAN_ON || 718 if (nv_connector && ( nv_connector->underscan == UNDERSCAN_ON ||
719 (nv_connector->underscan == UNDERSCAN_AUTO && 719 (nv_connector->underscan == UNDERSCAN_AUTO &&
720 nv_connector->edid && 720 nv_connector->edid &&
721 drm_detect_hdmi_monitor(nv_connector->edid)))) { 721 drm_detect_hdmi_monitor(nv_connector->edid)))) {
722 u32 bX = nv_connector->underscan_hborder; 722 u32 bX = nv_connector->underscan_hborder;
723 u32 bY = nv_connector->underscan_vborder; 723 u32 bY = nv_connector->underscan_vborder;
724 u32 aspect = (oY << 19) / oX; 724 u32 aspect = (oY << 19) / oX;
725 725
726 if (bX) { 726 if (bX) {
727 oX -= (bX * 2); 727 oX -= (bX * 2);
728 if (bY) oY -= (bY * 2); 728 if (bY) oY -= (bY * 2);
729 else oY = ((oX * aspect) + (aspect / 2)) >> 19; 729 else oY = ((oX * aspect) + (aspect / 2)) >> 19;
730 } else { 730 } else {
731 oX -= (oX >> 4) + 32; 731 oX -= (oX >> 4) + 32;
732 if (bY) oY -= (bY * 2); 732 if (bY) oY -= (bY * 2);
733 else oY = ((oX * aspect) + (aspect / 2)) >> 19; 733 else oY = ((oX * aspect) + (aspect / 2)) >> 19;
734 } 734 }
735 } 735 }
736 736
737 /* handle CENTER/ASPECT scaling, taking into account the areas 737 /* handle CENTER/ASPECT scaling, taking into account the areas
738 * removed already for overscan compensation 738 * removed already for overscan compensation
739 */ 739 */
740 switch (mode) { 740 switch (mode) {
741 case DRM_MODE_SCALE_CENTER: 741 case DRM_MODE_SCALE_CENTER:
742 oX = min((u32)umode->hdisplay, oX); 742 oX = min((u32)umode->hdisplay, oX);
743 oY = min((u32)umode->vdisplay, oY); 743 oY = min((u32)umode->vdisplay, oY);
744 /* fall-through */ 744 /* fall-through */
745 case DRM_MODE_SCALE_ASPECT: 745 case DRM_MODE_SCALE_ASPECT:
746 if (oY < oX) { 746 if (oY < oX) {
747 u32 aspect = (umode->hdisplay << 19) / umode->vdisplay; 747 u32 aspect = (umode->hdisplay << 19) / umode->vdisplay;
748 oX = ((oY * aspect) + (aspect / 2)) >> 19; 748 oX = ((oY * aspect) + (aspect / 2)) >> 19;
749 } else { 749 } else {
750 u32 aspect = (umode->vdisplay << 19) / umode->hdisplay; 750 u32 aspect = (umode->vdisplay << 19) / umode->hdisplay;
751 oY = ((oX * aspect) + (aspect / 2)) >> 19; 751 oY = ((oX * aspect) + (aspect / 2)) >> 19;
752 } 752 }
753 break; 753 break;
754 default: 754 default:
755 break; 755 break;
756 } 756 }
757 757
758 push = evo_wait(mast, 8); 758 push = evo_wait(mast, 8);
759 if (push) { 759 if (push) {
760 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 760 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
761 /*XXX: SCALE_CTRL_ACTIVE??? */ 761 /*XXX: SCALE_CTRL_ACTIVE??? */
762 evo_mthd(push, 0x08d8 + (nv_crtc->index * 0x400), 2); 762 evo_mthd(push, 0x08d8 + (nv_crtc->index * 0x400), 2);
763 evo_data(push, (oY << 16) | oX); 763 evo_data(push, (oY << 16) | oX);
764 evo_data(push, (oY << 16) | oX); 764 evo_data(push, (oY << 16) | oX);
765 evo_mthd(push, 0x08a4 + (nv_crtc->index * 0x400), 1); 765 evo_mthd(push, 0x08a4 + (nv_crtc->index * 0x400), 1);
766 evo_data(push, 0x00000000); 766 evo_data(push, 0x00000000);
767 evo_mthd(push, 0x08c8 + (nv_crtc->index * 0x400), 1); 767 evo_mthd(push, 0x08c8 + (nv_crtc->index * 0x400), 1);
768 evo_data(push, umode->vdisplay << 16 | umode->hdisplay); 768 evo_data(push, umode->vdisplay << 16 | umode->hdisplay);
769 } else { 769 } else {
770 evo_mthd(push, 0x04c0 + (nv_crtc->index * 0x300), 3); 770 evo_mthd(push, 0x04c0 + (nv_crtc->index * 0x300), 3);
771 evo_data(push, (oY << 16) | oX); 771 evo_data(push, (oY << 16) | oX);
772 evo_data(push, (oY << 16) | oX); 772 evo_data(push, (oY << 16) | oX);
773 evo_data(push, (oY << 16) | oX); 773 evo_data(push, (oY << 16) | oX);
774 evo_mthd(push, 0x0494 + (nv_crtc->index * 0x300), 1); 774 evo_mthd(push, 0x0494 + (nv_crtc->index * 0x300), 1);
775 evo_data(push, 0x00000000); 775 evo_data(push, 0x00000000);
776 evo_mthd(push, 0x04b8 + (nv_crtc->index * 0x300), 1); 776 evo_mthd(push, 0x04b8 + (nv_crtc->index * 0x300), 1);
777 evo_data(push, umode->vdisplay << 16 | umode->hdisplay); 777 evo_data(push, umode->vdisplay << 16 | umode->hdisplay);
778 } 778 }
779 779
780 evo_kick(push, mast); 780 evo_kick(push, mast);
781 781
782 if (update) { 782 if (update) {
783 nv50_display_flip_stop(crtc); 783 nv50_display_flip_stop(crtc);
784 nv50_display_flip_next(crtc, crtc->fb, NULL, 1); 784 nv50_display_flip_next(crtc, crtc->fb, NULL, 1);
785 } 785 }
786 } 786 }
787 787
788 return 0; 788 return 0;
789 } 789 }
790 790
791 static int 791 static int
792 nv50_crtc_set_color_vibrance(struct nouveau_crtc *nv_crtc, bool update) 792 nv50_crtc_set_color_vibrance(struct nouveau_crtc *nv_crtc, bool update)
793 { 793 {
794 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev); 794 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev);
795 u32 *push, hue, vib; 795 u32 *push, hue, vib;
796 int adj; 796 int adj;
797 797
798 adj = (nv_crtc->color_vibrance > 0) ? 50 : 0; 798 adj = (nv_crtc->color_vibrance > 0) ? 50 : 0;
799 vib = ((nv_crtc->color_vibrance * 2047 + adj) / 100) & 0xfff; 799 vib = ((nv_crtc->color_vibrance * 2047 + adj) / 100) & 0xfff;
800 hue = ((nv_crtc->vibrant_hue * 2047) / 100) & 0xfff; 800 hue = ((nv_crtc->vibrant_hue * 2047) / 100) & 0xfff;
801 801
802 push = evo_wait(mast, 16); 802 push = evo_wait(mast, 16);
803 if (push) { 803 if (push) {
804 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 804 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
805 evo_mthd(push, 0x08a8 + (nv_crtc->index * 0x400), 1); 805 evo_mthd(push, 0x08a8 + (nv_crtc->index * 0x400), 1);
806 evo_data(push, (hue << 20) | (vib << 8)); 806 evo_data(push, (hue << 20) | (vib << 8));
807 } else { 807 } else {
808 evo_mthd(push, 0x0498 + (nv_crtc->index * 0x300), 1); 808 evo_mthd(push, 0x0498 + (nv_crtc->index * 0x300), 1);
809 evo_data(push, (hue << 20) | (vib << 8)); 809 evo_data(push, (hue << 20) | (vib << 8));
810 } 810 }
811 811
812 if (update) { 812 if (update) {
813 evo_mthd(push, 0x0080, 1); 813 evo_mthd(push, 0x0080, 1);
814 evo_data(push, 0x00000000); 814 evo_data(push, 0x00000000);
815 } 815 }
816 evo_kick(push, mast); 816 evo_kick(push, mast);
817 } 817 }
818 818
819 return 0; 819 return 0;
820 } 820 }
821 821
822 static int 822 static int
823 nv50_crtc_set_image(struct nouveau_crtc *nv_crtc, struct drm_framebuffer *fb, 823 nv50_crtc_set_image(struct nouveau_crtc *nv_crtc, struct drm_framebuffer *fb,
824 int x, int y, bool update) 824 int x, int y, bool update)
825 { 825 {
826 struct nouveau_framebuffer *nvfb = nouveau_framebuffer(fb); 826 struct nouveau_framebuffer *nvfb = nouveau_framebuffer(fb);
827 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev); 827 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev);
828 u32 *push; 828 u32 *push;
829 829
830 push = evo_wait(mast, 16); 830 push = evo_wait(mast, 16);
831 if (push) { 831 if (push) {
832 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 832 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
833 evo_mthd(push, 0x0860 + (nv_crtc->index * 0x400), 1); 833 evo_mthd(push, 0x0860 + (nv_crtc->index * 0x400), 1);
834 evo_data(push, nvfb->nvbo->bo.offset >> 8); 834 evo_data(push, nvfb->nvbo->bo.offset >> 8);
835 evo_mthd(push, 0x0868 + (nv_crtc->index * 0x400), 3); 835 evo_mthd(push, 0x0868 + (nv_crtc->index * 0x400), 3);
836 evo_data(push, (fb->height << 16) | fb->width); 836 evo_data(push, (fb->height << 16) | fb->width);
837 evo_data(push, nvfb->r_pitch); 837 evo_data(push, nvfb->r_pitch);
838 evo_data(push, nvfb->r_format); 838 evo_data(push, nvfb->r_format);
839 evo_mthd(push, 0x08c0 + (nv_crtc->index * 0x400), 1); 839 evo_mthd(push, 0x08c0 + (nv_crtc->index * 0x400), 1);
840 evo_data(push, (y << 16) | x); 840 evo_data(push, (y << 16) | x);
841 if (nv50_vers(mast) > NV50_DISP_MAST_CLASS) { 841 if (nv50_vers(mast) > NV50_DISP_MAST_CLASS) {
842 evo_mthd(push, 0x0874 + (nv_crtc->index * 0x400), 1); 842 evo_mthd(push, 0x0874 + (nv_crtc->index * 0x400), 1);
843 evo_data(push, nvfb->r_dma); 843 evo_data(push, nvfb->r_dma);
844 } 844 }
845 } else { 845 } else {
846 evo_mthd(push, 0x0460 + (nv_crtc->index * 0x300), 1); 846 evo_mthd(push, 0x0460 + (nv_crtc->index * 0x300), 1);
847 evo_data(push, nvfb->nvbo->bo.offset >> 8); 847 evo_data(push, nvfb->nvbo->bo.offset >> 8);
848 evo_mthd(push, 0x0468 + (nv_crtc->index * 0x300), 4); 848 evo_mthd(push, 0x0468 + (nv_crtc->index * 0x300), 4);
849 evo_data(push, (fb->height << 16) | fb->width); 849 evo_data(push, (fb->height << 16) | fb->width);
850 evo_data(push, nvfb->r_pitch); 850 evo_data(push, nvfb->r_pitch);
851 evo_data(push, nvfb->r_format); 851 evo_data(push, nvfb->r_format);
852 evo_data(push, nvfb->r_dma); 852 evo_data(push, nvfb->r_dma);
853 evo_mthd(push, 0x04b0 + (nv_crtc->index * 0x300), 1); 853 evo_mthd(push, 0x04b0 + (nv_crtc->index * 0x300), 1);
854 evo_data(push, (y << 16) | x); 854 evo_data(push, (y << 16) | x);
855 } 855 }
856 856
857 if (update) { 857 if (update) {
858 evo_mthd(push, 0x0080, 1); 858 evo_mthd(push, 0x0080, 1);
859 evo_data(push, 0x00000000); 859 evo_data(push, 0x00000000);
860 } 860 }
861 evo_kick(push, mast); 861 evo_kick(push, mast);
862 } 862 }
863 863
864 nv_crtc->fb.tile_flags = nvfb->r_dma; 864 nv_crtc->fb.tile_flags = nvfb->r_dma;
865 return 0; 865 return 0;
866 } 866 }
867 867
868 static void 868 static void
869 nv50_crtc_cursor_show(struct nouveau_crtc *nv_crtc) 869 nv50_crtc_cursor_show(struct nouveau_crtc *nv_crtc)
870 { 870 {
871 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev); 871 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev);
872 u32 *push = evo_wait(mast, 16); 872 u32 *push = evo_wait(mast, 16);
873 if (push) { 873 if (push) {
874 if (nv50_vers(mast) < NV84_DISP_MAST_CLASS) { 874 if (nv50_vers(mast) < NV84_DISP_MAST_CLASS) {
875 evo_mthd(push, 0x0880 + (nv_crtc->index * 0x400), 2); 875 evo_mthd(push, 0x0880 + (nv_crtc->index * 0x400), 2);
876 evo_data(push, 0x85000000); 876 evo_data(push, 0x85000000);
877 evo_data(push, nv_crtc->cursor.nvbo->bo.offset >> 8); 877 evo_data(push, nv_crtc->cursor.nvbo->bo.offset >> 8);
878 } else 878 } else
879 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 879 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
880 evo_mthd(push, 0x0880 + (nv_crtc->index * 0x400), 2); 880 evo_mthd(push, 0x0880 + (nv_crtc->index * 0x400), 2);
881 evo_data(push, 0x85000000); 881 evo_data(push, 0x85000000);
882 evo_data(push, nv_crtc->cursor.nvbo->bo.offset >> 8); 882 evo_data(push, nv_crtc->cursor.nvbo->bo.offset >> 8);
883 evo_mthd(push, 0x089c + (nv_crtc->index * 0x400), 1); 883 evo_mthd(push, 0x089c + (nv_crtc->index * 0x400), 1);
884 evo_data(push, NvEvoVRAM); 884 evo_data(push, NvEvoVRAM);
885 } else { 885 } else {
886 evo_mthd(push, 0x0480 + (nv_crtc->index * 0x300), 2); 886 evo_mthd(push, 0x0480 + (nv_crtc->index * 0x300), 2);
887 evo_data(push, 0x85000000); 887 evo_data(push, 0x85000000);
888 evo_data(push, nv_crtc->cursor.nvbo->bo.offset >> 8); 888 evo_data(push, nv_crtc->cursor.nvbo->bo.offset >> 8);
889 evo_mthd(push, 0x048c + (nv_crtc->index * 0x300), 1); 889 evo_mthd(push, 0x048c + (nv_crtc->index * 0x300), 1);
890 evo_data(push, NvEvoVRAM); 890 evo_data(push, NvEvoVRAM);
891 } 891 }
892 evo_kick(push, mast); 892 evo_kick(push, mast);
893 } 893 }
894 } 894 }
895 895
896 static void 896 static void
897 nv50_crtc_cursor_hide(struct nouveau_crtc *nv_crtc) 897 nv50_crtc_cursor_hide(struct nouveau_crtc *nv_crtc)
898 { 898 {
899 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev); 899 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev);
900 u32 *push = evo_wait(mast, 16); 900 u32 *push = evo_wait(mast, 16);
901 if (push) { 901 if (push) {
902 if (nv50_vers(mast) < NV84_DISP_MAST_CLASS) { 902 if (nv50_vers(mast) < NV84_DISP_MAST_CLASS) {
903 evo_mthd(push, 0x0880 + (nv_crtc->index * 0x400), 1); 903 evo_mthd(push, 0x0880 + (nv_crtc->index * 0x400), 1);
904 evo_data(push, 0x05000000); 904 evo_data(push, 0x05000000);
905 } else 905 } else
906 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 906 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
907 evo_mthd(push, 0x0880 + (nv_crtc->index * 0x400), 1); 907 evo_mthd(push, 0x0880 + (nv_crtc->index * 0x400), 1);
908 evo_data(push, 0x05000000); 908 evo_data(push, 0x05000000);
909 evo_mthd(push, 0x089c + (nv_crtc->index * 0x400), 1); 909 evo_mthd(push, 0x089c + (nv_crtc->index * 0x400), 1);
910 evo_data(push, 0x00000000); 910 evo_data(push, 0x00000000);
911 } else { 911 } else {
912 evo_mthd(push, 0x0480 + (nv_crtc->index * 0x300), 1); 912 evo_mthd(push, 0x0480 + (nv_crtc->index * 0x300), 1);
913 evo_data(push, 0x05000000); 913 evo_data(push, 0x05000000);
914 evo_mthd(push, 0x048c + (nv_crtc->index * 0x300), 1); 914 evo_mthd(push, 0x048c + (nv_crtc->index * 0x300), 1);
915 evo_data(push, 0x00000000); 915 evo_data(push, 0x00000000);
916 } 916 }
917 evo_kick(push, mast); 917 evo_kick(push, mast);
918 } 918 }
919 } 919 }
920 920
921 static void 921 static void
922 nv50_crtc_cursor_show_hide(struct nouveau_crtc *nv_crtc, bool show, bool update) 922 nv50_crtc_cursor_show_hide(struct nouveau_crtc *nv_crtc, bool show, bool update)
923 { 923 {
924 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev); 924 struct nv50_mast *mast = nv50_mast(nv_crtc->base.dev);
925 925
926 if (show) 926 if (show)
927 nv50_crtc_cursor_show(nv_crtc); 927 nv50_crtc_cursor_show(nv_crtc);
928 else 928 else
929 nv50_crtc_cursor_hide(nv_crtc); 929 nv50_crtc_cursor_hide(nv_crtc);
930 930
931 if (update) { 931 if (update) {
932 u32 *push = evo_wait(mast, 2); 932 u32 *push = evo_wait(mast, 2);
933 if (push) { 933 if (push) {
934 evo_mthd(push, 0x0080, 1); 934 evo_mthd(push, 0x0080, 1);
935 evo_data(push, 0x00000000); 935 evo_data(push, 0x00000000);
936 evo_kick(push, mast); 936 evo_kick(push, mast);
937 } 937 }
938 } 938 }
939 } 939 }
940 940
941 static void 941 static void
942 nv50_crtc_dpms(struct drm_crtc *crtc, int mode) 942 nv50_crtc_dpms(struct drm_crtc *crtc, int mode)
943 { 943 {
944 } 944 }
945 945
946 static void 946 static void
947 nv50_crtc_prepare(struct drm_crtc *crtc) 947 nv50_crtc_prepare(struct drm_crtc *crtc)
948 { 948 {
949 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 949 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
950 struct nv50_mast *mast = nv50_mast(crtc->dev); 950 struct nv50_mast *mast = nv50_mast(crtc->dev);
951 u32 *push; 951 u32 *push;
952 952
953 nv50_display_flip_stop(crtc); 953 nv50_display_flip_stop(crtc);
954 954
955 push = evo_wait(mast, 2); 955 push = evo_wait(mast, 2);
956 if (push) { 956 if (push) {
957 if (nv50_vers(mast) < NV84_DISP_MAST_CLASS) { 957 if (nv50_vers(mast) < NV84_DISP_MAST_CLASS) {
958 evo_mthd(push, 0x0874 + (nv_crtc->index * 0x400), 1); 958 evo_mthd(push, 0x0874 + (nv_crtc->index * 0x400), 1);
959 evo_data(push, 0x00000000); 959 evo_data(push, 0x00000000);
960 evo_mthd(push, 0x0840 + (nv_crtc->index * 0x400), 1); 960 evo_mthd(push, 0x0840 + (nv_crtc->index * 0x400), 1);
961 evo_data(push, 0x40000000); 961 evo_data(push, 0x40000000);
962 } else 962 } else
963 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 963 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
964 evo_mthd(push, 0x0874 + (nv_crtc->index * 0x400), 1); 964 evo_mthd(push, 0x0874 + (nv_crtc->index * 0x400), 1);
965 evo_data(push, 0x00000000); 965 evo_data(push, 0x00000000);
966 evo_mthd(push, 0x0840 + (nv_crtc->index * 0x400), 1); 966 evo_mthd(push, 0x0840 + (nv_crtc->index * 0x400), 1);
967 evo_data(push, 0x40000000); 967 evo_data(push, 0x40000000);
968 evo_mthd(push, 0x085c + (nv_crtc->index * 0x400), 1); 968 evo_mthd(push, 0x085c + (nv_crtc->index * 0x400), 1);
969 evo_data(push, 0x00000000); 969 evo_data(push, 0x00000000);
970 } else { 970 } else {
971 evo_mthd(push, 0x0474 + (nv_crtc->index * 0x300), 1); 971 evo_mthd(push, 0x0474 + (nv_crtc->index * 0x300), 1);
972 evo_data(push, 0x00000000); 972 evo_data(push, 0x00000000);
973 evo_mthd(push, 0x0440 + (nv_crtc->index * 0x300), 1); 973 evo_mthd(push, 0x0440 + (nv_crtc->index * 0x300), 1);
974 evo_data(push, 0x03000000); 974 evo_data(push, 0x03000000);
975 evo_mthd(push, 0x045c + (nv_crtc->index * 0x300), 1); 975 evo_mthd(push, 0x045c + (nv_crtc->index * 0x300), 1);
976 evo_data(push, 0x00000000); 976 evo_data(push, 0x00000000);
977 } 977 }
978 978
979 evo_kick(push, mast); 979 evo_kick(push, mast);
980 } 980 }
981 981
982 nv50_crtc_cursor_show_hide(nv_crtc, false, false); 982 nv50_crtc_cursor_show_hide(nv_crtc, false, false);
983 } 983 }
984 984
985 static void 985 static void
986 nv50_crtc_commit(struct drm_crtc *crtc) 986 nv50_crtc_commit(struct drm_crtc *crtc)
987 { 987 {
988 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 988 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
989 struct nv50_mast *mast = nv50_mast(crtc->dev); 989 struct nv50_mast *mast = nv50_mast(crtc->dev);
990 u32 *push; 990 u32 *push;
991 991
992 push = evo_wait(mast, 32); 992 push = evo_wait(mast, 32);
993 if (push) { 993 if (push) {
994 if (nv50_vers(mast) < NV84_DISP_MAST_CLASS) { 994 if (nv50_vers(mast) < NV84_DISP_MAST_CLASS) {
995 evo_mthd(push, 0x0874 + (nv_crtc->index * 0x400), 1); 995 evo_mthd(push, 0x0874 + (nv_crtc->index * 0x400), 1);
996 evo_data(push, NvEvoVRAM_LP); 996 evo_data(push, NvEvoVRAM_LP);
997 evo_mthd(push, 0x0840 + (nv_crtc->index * 0x400), 2); 997 evo_mthd(push, 0x0840 + (nv_crtc->index * 0x400), 2);
998 evo_data(push, 0xc0000000); 998 evo_data(push, 0xc0000000);
999 evo_data(push, nv_crtc->lut.nvbo->bo.offset >> 8); 999 evo_data(push, nv_crtc->lut.nvbo->bo.offset >> 8);
1000 } else 1000 } else
1001 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 1001 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
1002 evo_mthd(push, 0x0874 + (nv_crtc->index * 0x400), 1); 1002 evo_mthd(push, 0x0874 + (nv_crtc->index * 0x400), 1);
1003 evo_data(push, nv_crtc->fb.tile_flags); 1003 evo_data(push, nv_crtc->fb.tile_flags);
1004 evo_mthd(push, 0x0840 + (nv_crtc->index * 0x400), 2); 1004 evo_mthd(push, 0x0840 + (nv_crtc->index * 0x400), 2);
1005 evo_data(push, 0xc0000000); 1005 evo_data(push, 0xc0000000);
1006 evo_data(push, nv_crtc->lut.nvbo->bo.offset >> 8); 1006 evo_data(push, nv_crtc->lut.nvbo->bo.offset >> 8);
1007 evo_mthd(push, 0x085c + (nv_crtc->index * 0x400), 1); 1007 evo_mthd(push, 0x085c + (nv_crtc->index * 0x400), 1);
1008 evo_data(push, NvEvoVRAM); 1008 evo_data(push, NvEvoVRAM);
1009 } else { 1009 } else {
1010 evo_mthd(push, 0x0474 + (nv_crtc->index * 0x300), 1); 1010 evo_mthd(push, 0x0474 + (nv_crtc->index * 0x300), 1);
1011 evo_data(push, nv_crtc->fb.tile_flags); 1011 evo_data(push, nv_crtc->fb.tile_flags);
1012 evo_mthd(push, 0x0440 + (nv_crtc->index * 0x300), 4); 1012 evo_mthd(push, 0x0440 + (nv_crtc->index * 0x300), 4);
1013 evo_data(push, 0x83000000); 1013 evo_data(push, 0x83000000);
1014 evo_data(push, nv_crtc->lut.nvbo->bo.offset >> 8); 1014 evo_data(push, nv_crtc->lut.nvbo->bo.offset >> 8);
1015 evo_data(push, 0x00000000); 1015 evo_data(push, 0x00000000);
1016 evo_data(push, 0x00000000); 1016 evo_data(push, 0x00000000);
1017 evo_mthd(push, 0x045c + (nv_crtc->index * 0x300), 1); 1017 evo_mthd(push, 0x045c + (nv_crtc->index * 0x300), 1);
1018 evo_data(push, NvEvoVRAM); 1018 evo_data(push, NvEvoVRAM);
1019 evo_mthd(push, 0x0430 + (nv_crtc->index * 0x300), 1); 1019 evo_mthd(push, 0x0430 + (nv_crtc->index * 0x300), 1);
1020 evo_data(push, 0xffffff00); 1020 evo_data(push, 0xffffff00);
1021 } 1021 }
1022 1022
1023 evo_kick(push, mast); 1023 evo_kick(push, mast);
1024 } 1024 }
1025 1025
1026 nv50_crtc_cursor_show_hide(nv_crtc, nv_crtc->cursor.visible, true); 1026 nv50_crtc_cursor_show_hide(nv_crtc, nv_crtc->cursor.visible, true);
1027 nv50_display_flip_next(crtc, crtc->fb, NULL, 1); 1027 nv50_display_flip_next(crtc, crtc->fb, NULL, 1);
1028 } 1028 }
1029 1029
1030 static bool 1030 static bool
1031 nv50_crtc_mode_fixup(struct drm_crtc *crtc, const struct drm_display_mode *mode, 1031 nv50_crtc_mode_fixup(struct drm_crtc *crtc, const struct drm_display_mode *mode,
1032 struct drm_display_mode *adjusted_mode) 1032 struct drm_display_mode *adjusted_mode)
1033 { 1033 {
1034 return true; 1034 return true;
1035 } 1035 }
1036 1036
1037 static int 1037 static int
1038 nv50_crtc_swap_fbs(struct drm_crtc *crtc, struct drm_framebuffer *old_fb) 1038 nv50_crtc_swap_fbs(struct drm_crtc *crtc, struct drm_framebuffer *old_fb)
1039 { 1039 {
1040 struct nouveau_framebuffer *nvfb = nouveau_framebuffer(crtc->fb); 1040 struct nouveau_framebuffer *nvfb = nouveau_framebuffer(crtc->fb);
1041 int ret; 1041 int ret;
1042 1042
1043 ret = nouveau_bo_pin(nvfb->nvbo, TTM_PL_FLAG_VRAM); 1043 ret = nouveau_bo_pin(nvfb->nvbo, TTM_PL_FLAG_VRAM);
1044 if (ret) 1044 if (ret)
1045 return ret; 1045 return ret;
1046 1046
1047 if (old_fb) { 1047 if (old_fb) {
1048 nvfb = nouveau_framebuffer(old_fb); 1048 nvfb = nouveau_framebuffer(old_fb);
1049 nouveau_bo_unpin(nvfb->nvbo); 1049 nouveau_bo_unpin(nvfb->nvbo);
1050 } 1050 }
1051 1051
1052 return 0; 1052 return 0;
1053 } 1053 }
1054 1054
1055 static int 1055 static int
1056 nv50_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *umode, 1056 nv50_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *umode,
1057 struct drm_display_mode *mode, int x, int y, 1057 struct drm_display_mode *mode, int x, int y,
1058 struct drm_framebuffer *old_fb) 1058 struct drm_framebuffer *old_fb)
1059 { 1059 {
1060 struct nv50_mast *mast = nv50_mast(crtc->dev); 1060 struct nv50_mast *mast = nv50_mast(crtc->dev);
1061 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 1061 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
1062 struct nouveau_connector *nv_connector; 1062 struct nouveau_connector *nv_connector;
1063 u32 ilace = (mode->flags & DRM_MODE_FLAG_INTERLACE) ? 2 : 1; 1063 u32 ilace = (mode->flags & DRM_MODE_FLAG_INTERLACE) ? 2 : 1;
1064 u32 vscan = (mode->flags & DRM_MODE_FLAG_DBLSCAN) ? 2 : 1; 1064 u32 vscan = (mode->flags & DRM_MODE_FLAG_DBLSCAN) ? 2 : 1;
1065 u32 hactive, hsynce, hbackp, hfrontp, hblanke, hblanks; 1065 u32 hactive, hsynce, hbackp, hfrontp, hblanke, hblanks;
1066 u32 vactive, vsynce, vbackp, vfrontp, vblanke, vblanks; 1066 u32 vactive, vsynce, vbackp, vfrontp, vblanke, vblanks;
1067 u32 vblan2e = 0, vblan2s = 1; 1067 u32 vblan2e = 0, vblan2s = 1;
1068 u32 *push; 1068 u32 *push;
1069 int ret; 1069 int ret;
1070 1070
1071 hactive = mode->htotal; 1071 hactive = mode->htotal;
1072 hsynce = mode->hsync_end - mode->hsync_start - 1; 1072 hsynce = mode->hsync_end - mode->hsync_start - 1;
1073 hbackp = mode->htotal - mode->hsync_end; 1073 hbackp = mode->htotal - mode->hsync_end;
1074 hblanke = hsynce + hbackp; 1074 hblanke = hsynce + hbackp;
1075 hfrontp = mode->hsync_start - mode->hdisplay; 1075 hfrontp = mode->hsync_start - mode->hdisplay;
1076 hblanks = mode->htotal - hfrontp - 1; 1076 hblanks = mode->htotal - hfrontp - 1;
1077 1077
1078 vactive = mode->vtotal * vscan / ilace; 1078 vactive = mode->vtotal * vscan / ilace;
1079 vsynce = ((mode->vsync_end - mode->vsync_start) * vscan / ilace) - 1; 1079 vsynce = ((mode->vsync_end - mode->vsync_start) * vscan / ilace) - 1;
1080 vbackp = (mode->vtotal - mode->vsync_end) * vscan / ilace; 1080 vbackp = (mode->vtotal - mode->vsync_end) * vscan / ilace;
1081 vblanke = vsynce + vbackp; 1081 vblanke = vsynce + vbackp;
1082 vfrontp = (mode->vsync_start - mode->vdisplay) * vscan / ilace; 1082 vfrontp = (mode->vsync_start - mode->vdisplay) * vscan / ilace;
1083 vblanks = vactive - vfrontp - 1; 1083 vblanks = vactive - vfrontp - 1;
1084 if (mode->flags & DRM_MODE_FLAG_INTERLACE) { 1084 if (mode->flags & DRM_MODE_FLAG_INTERLACE) {
1085 vblan2e = vactive + vsynce + vbackp; 1085 vblan2e = vactive + vsynce + vbackp;
1086 vblan2s = vblan2e + (mode->vdisplay * vscan / ilace); 1086 vblan2s = vblan2e + (mode->vdisplay * vscan / ilace);
1087 vactive = (vactive * 2) + 1; 1087 vactive = (vactive * 2) + 1;
1088 } 1088 }
1089 1089
1090 ret = nv50_crtc_swap_fbs(crtc, old_fb); 1090 ret = nv50_crtc_swap_fbs(crtc, old_fb);
1091 if (ret) 1091 if (ret)
1092 return ret; 1092 return ret;
1093 1093
1094 push = evo_wait(mast, 64); 1094 push = evo_wait(mast, 64);
1095 if (push) { 1095 if (push) {
1096 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 1096 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
1097 evo_mthd(push, 0x0804 + (nv_crtc->index * 0x400), 2); 1097 evo_mthd(push, 0x0804 + (nv_crtc->index * 0x400), 2);
1098 evo_data(push, 0x00800000 | mode->clock); 1098 evo_data(push, 0x00800000 | mode->clock);
1099 evo_data(push, (ilace == 2) ? 2 : 0); 1099 evo_data(push, (ilace == 2) ? 2 : 0);
1100 evo_mthd(push, 0x0810 + (nv_crtc->index * 0x400), 6); 1100 evo_mthd(push, 0x0810 + (nv_crtc->index * 0x400), 6);
1101 evo_data(push, 0x00000000); 1101 evo_data(push, 0x00000000);
1102 evo_data(push, (vactive << 16) | hactive); 1102 evo_data(push, (vactive << 16) | hactive);
1103 evo_data(push, ( vsynce << 16) | hsynce); 1103 evo_data(push, ( vsynce << 16) | hsynce);
1104 evo_data(push, (vblanke << 16) | hblanke); 1104 evo_data(push, (vblanke << 16) | hblanke);
1105 evo_data(push, (vblanks << 16) | hblanks); 1105 evo_data(push, (vblanks << 16) | hblanks);
1106 evo_data(push, (vblan2e << 16) | vblan2s); 1106 evo_data(push, (vblan2e << 16) | vblan2s);
1107 evo_mthd(push, 0x082c + (nv_crtc->index * 0x400), 1); 1107 evo_mthd(push, 0x082c + (nv_crtc->index * 0x400), 1);
1108 evo_data(push, 0x00000000); 1108 evo_data(push, 0x00000000);
1109 evo_mthd(push, 0x0900 + (nv_crtc->index * 0x400), 2); 1109 evo_mthd(push, 0x0900 + (nv_crtc->index * 0x400), 2);
1110 evo_data(push, 0x00000311); 1110 evo_data(push, 0x00000311);
1111 evo_data(push, 0x00000100); 1111 evo_data(push, 0x00000100);
1112 } else { 1112 } else {
1113 evo_mthd(push, 0x0410 + (nv_crtc->index * 0x300), 6); 1113 evo_mthd(push, 0x0410 + (nv_crtc->index * 0x300), 6);
1114 evo_data(push, 0x00000000); 1114 evo_data(push, 0x00000000);
1115 evo_data(push, (vactive << 16) | hactive); 1115 evo_data(push, (vactive << 16) | hactive);
1116 evo_data(push, ( vsynce << 16) | hsynce); 1116 evo_data(push, ( vsynce << 16) | hsynce);
1117 evo_data(push, (vblanke << 16) | hblanke); 1117 evo_data(push, (vblanke << 16) | hblanke);
1118 evo_data(push, (vblanks << 16) | hblanks); 1118 evo_data(push, (vblanks << 16) | hblanks);
1119 evo_data(push, (vblan2e << 16) | vblan2s); 1119 evo_data(push, (vblan2e << 16) | vblan2s);
1120 evo_mthd(push, 0x042c + (nv_crtc->index * 0x300), 1); 1120 evo_mthd(push, 0x042c + (nv_crtc->index * 0x300), 1);
1121 evo_data(push, 0x00000000); /* ??? */ 1121 evo_data(push, 0x00000000); /* ??? */
1122 evo_mthd(push, 0x0450 + (nv_crtc->index * 0x300), 3); 1122 evo_mthd(push, 0x0450 + (nv_crtc->index * 0x300), 3);
1123 evo_data(push, mode->clock * 1000); 1123 evo_data(push, mode->clock * 1000);
1124 evo_data(push, 0x00200000); /* ??? */ 1124 evo_data(push, 0x00200000); /* ??? */
1125 evo_data(push, mode->clock * 1000); 1125 evo_data(push, mode->clock * 1000);
1126 evo_mthd(push, 0x04d0 + (nv_crtc->index * 0x300), 2); 1126 evo_mthd(push, 0x04d0 + (nv_crtc->index * 0x300), 2);
1127 evo_data(push, 0x00000311); 1127 evo_data(push, 0x00000311);
1128 evo_data(push, 0x00000100); 1128 evo_data(push, 0x00000100);
1129 } 1129 }
1130 1130
1131 evo_kick(push, mast); 1131 evo_kick(push, mast);
1132 } 1132 }
1133 1133
1134 nv_connector = nouveau_crtc_connector_get(nv_crtc); 1134 nv_connector = nouveau_crtc_connector_get(nv_crtc);
1135 nv50_crtc_set_dither(nv_crtc, false); 1135 nv50_crtc_set_dither(nv_crtc, false);
1136 nv50_crtc_set_scale(nv_crtc, false); 1136 nv50_crtc_set_scale(nv_crtc, false);
1137 nv50_crtc_set_color_vibrance(nv_crtc, false); 1137 nv50_crtc_set_color_vibrance(nv_crtc, false);
1138 nv50_crtc_set_image(nv_crtc, crtc->fb, x, y, false); 1138 nv50_crtc_set_image(nv_crtc, crtc->fb, x, y, false);
1139 return 0; 1139 return 0;
1140 } 1140 }
1141 1141
1142 static int 1142 static int
1143 nv50_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, 1143 nv50_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
1144 struct drm_framebuffer *old_fb) 1144 struct drm_framebuffer *old_fb)
1145 { 1145 {
1146 struct nouveau_drm *drm = nouveau_drm(crtc->dev); 1146 struct nouveau_drm *drm = nouveau_drm(crtc->dev);
1147 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 1147 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
1148 int ret; 1148 int ret;
1149 1149
1150 if (!crtc->fb) { 1150 if (!crtc->fb) {
1151 NV_DEBUG(drm, "No FB bound\n"); 1151 NV_DEBUG(drm, "No FB bound\n");
1152 return 0; 1152 return 0;
1153 } 1153 }
1154 1154
1155 ret = nv50_crtc_swap_fbs(crtc, old_fb); 1155 ret = nv50_crtc_swap_fbs(crtc, old_fb);
1156 if (ret) 1156 if (ret)
1157 return ret; 1157 return ret;
1158 1158
1159 nv50_display_flip_stop(crtc); 1159 nv50_display_flip_stop(crtc);
1160 nv50_crtc_set_image(nv_crtc, crtc->fb, x, y, true); 1160 nv50_crtc_set_image(nv_crtc, crtc->fb, x, y, true);
1161 nv50_display_flip_next(crtc, crtc->fb, NULL, 1); 1161 nv50_display_flip_next(crtc, crtc->fb, NULL, 1);
1162 return 0; 1162 return 0;
1163 } 1163 }
1164 1164
1165 static int 1165 static int
1166 nv50_crtc_mode_set_base_atomic(struct drm_crtc *crtc, 1166 nv50_crtc_mode_set_base_atomic(struct drm_crtc *crtc,
1167 struct drm_framebuffer *fb, int x, int y, 1167 struct drm_framebuffer *fb, int x, int y,
1168 enum mode_set_atomic state) 1168 enum mode_set_atomic state)
1169 { 1169 {
1170 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 1170 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
1171 nv50_display_flip_stop(crtc); 1171 nv50_display_flip_stop(crtc);
1172 nv50_crtc_set_image(nv_crtc, fb, x, y, true); 1172 nv50_crtc_set_image(nv_crtc, fb, x, y, true);
1173 return 0; 1173 return 0;
1174 } 1174 }
1175 1175
1176 static void 1176 static void
1177 nv50_crtc_lut_load(struct drm_crtc *crtc) 1177 nv50_crtc_lut_load(struct drm_crtc *crtc)
1178 { 1178 {
1179 struct nv50_disp *disp = nv50_disp(crtc->dev); 1179 struct nv50_disp *disp = nv50_disp(crtc->dev);
1180 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 1180 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
1181 void __iomem *lut = nvbo_kmap_obj_iovirtual(nv_crtc->lut.nvbo); 1181 void __iomem *lut = nvbo_kmap_obj_iovirtual(nv_crtc->lut.nvbo);
1182 int i; 1182 int i;
1183 1183
1184 for (i = 0; i < 256; i++) { 1184 for (i = 0; i < 256; i++) {
1185 u16 r = nv_crtc->lut.r[i] >> 2; 1185 u16 r = nv_crtc->lut.r[i] >> 2;
1186 u16 g = nv_crtc->lut.g[i] >> 2; 1186 u16 g = nv_crtc->lut.g[i] >> 2;
1187 u16 b = nv_crtc->lut.b[i] >> 2; 1187 u16 b = nv_crtc->lut.b[i] >> 2;
1188 1188
1189 if (nv_mclass(disp->core) < NVD0_DISP_CLASS) { 1189 if (nv_mclass(disp->core) < NVD0_DISP_CLASS) {
1190 writew(r + 0x0000, lut + (i * 0x08) + 0); 1190 writew(r + 0x0000, lut + (i * 0x08) + 0);
1191 writew(g + 0x0000, lut + (i * 0x08) + 2); 1191 writew(g + 0x0000, lut + (i * 0x08) + 2);
1192 writew(b + 0x0000, lut + (i * 0x08) + 4); 1192 writew(b + 0x0000, lut + (i * 0x08) + 4);
1193 } else { 1193 } else {
1194 writew(r + 0x6000, lut + (i * 0x20) + 0); 1194 writew(r + 0x6000, lut + (i * 0x20) + 0);
1195 writew(g + 0x6000, lut + (i * 0x20) + 2); 1195 writew(g + 0x6000, lut + (i * 0x20) + 2);
1196 writew(b + 0x6000, lut + (i * 0x20) + 4); 1196 writew(b + 0x6000, lut + (i * 0x20) + 4);
1197 } 1197 }
1198 } 1198 }
1199 } 1199 }
1200 1200
1201 static int 1201 static int
1202 nv50_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, 1202 nv50_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
1203 uint32_t handle, uint32_t width, uint32_t height) 1203 uint32_t handle, uint32_t width, uint32_t height)
1204 { 1204 {
1205 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 1205 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
1206 struct drm_device *dev = crtc->dev; 1206 struct drm_device *dev = crtc->dev;
1207 struct drm_gem_object *gem; 1207 struct drm_gem_object *gem;
1208 struct nouveau_bo *nvbo; 1208 struct nouveau_bo *nvbo;
1209 bool visible = (handle != 0); 1209 bool visible = (handle != 0);
1210 int i, ret = 0; 1210 int i, ret = 0;
1211 1211
1212 if (visible) { 1212 if (visible) {
1213 if (width != 64 || height != 64) 1213 if (width != 64 || height != 64)
1214 return -EINVAL; 1214 return -EINVAL;
1215 1215
1216 gem = drm_gem_object_lookup(dev, file_priv, handle); 1216 gem = drm_gem_object_lookup(dev, file_priv, handle);
1217 if (unlikely(!gem)) 1217 if (unlikely(!gem))
1218 return -ENOENT; 1218 return -ENOENT;
1219 nvbo = nouveau_gem_object(gem); 1219 nvbo = nouveau_gem_object(gem);
1220 1220
1221 ret = nouveau_bo_map(nvbo); 1221 ret = nouveau_bo_map(nvbo);
1222 if (ret == 0) { 1222 if (ret == 0) {
1223 for (i = 0; i < 64 * 64; i++) { 1223 for (i = 0; i < 64 * 64; i++) {
1224 u32 v = nouveau_bo_rd32(nvbo, i); 1224 u32 v = nouveau_bo_rd32(nvbo, i);
1225 nouveau_bo_wr32(nv_crtc->cursor.nvbo, i, v); 1225 nouveau_bo_wr32(nv_crtc->cursor.nvbo, i, v);
1226 } 1226 }
1227 nouveau_bo_unmap(nvbo); 1227 nouveau_bo_unmap(nvbo);
1228 } 1228 }
1229 1229
1230 drm_gem_object_unreference_unlocked(gem); 1230 drm_gem_object_unreference_unlocked(gem);
1231 } 1231 }
1232 1232
1233 if (visible != nv_crtc->cursor.visible) { 1233 if (visible != nv_crtc->cursor.visible) {
1234 nv50_crtc_cursor_show_hide(nv_crtc, visible, true); 1234 nv50_crtc_cursor_show_hide(nv_crtc, visible, true);
1235 nv_crtc->cursor.visible = visible; 1235 nv_crtc->cursor.visible = visible;
1236 } 1236 }
1237 1237
1238 return ret; 1238 return ret;
1239 } 1239 }
1240 1240
1241 static int 1241 static int
1242 nv50_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) 1242 nv50_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
1243 { 1243 {
1244 struct nv50_curs *curs = nv50_curs(crtc); 1244 struct nv50_curs *curs = nv50_curs(crtc);
1245 struct nv50_chan *chan = nv50_chan(curs); 1245 struct nv50_chan *chan = nv50_chan(curs);
1246 nv_wo32(chan->user, 0x0084, (y << 16) | (x & 0xffff)); 1246 nv_wo32(chan->user, 0x0084, (y << 16) | (x & 0xffff));
1247 nv_wo32(chan->user, 0x0080, 0x00000000); 1247 nv_wo32(chan->user, 0x0080, 0x00000000);
1248 return 0; 1248 return 0;
1249 } 1249 }
1250 1250
1251 static void 1251 static void
1252 nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, 1252 nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
1253 uint32_t start, uint32_t size) 1253 uint32_t start, uint32_t size)
1254 { 1254 {
1255 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 1255 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
1256 u32 end = max(start + size, (u32)256); 1256 u32 end = max(start + size, (u32)256);
1257 u32 i; 1257 u32 i;
1258 1258
1259 for (i = start; i < end; i++) { 1259 for (i = start; i < end; i++) {
1260 nv_crtc->lut.r[i] = r[i]; 1260 nv_crtc->lut.r[i] = r[i];
1261 nv_crtc->lut.g[i] = g[i]; 1261 nv_crtc->lut.g[i] = g[i];
1262 nv_crtc->lut.b[i] = b[i]; 1262 nv_crtc->lut.b[i] = b[i];
1263 } 1263 }
1264 1264
1265 nv50_crtc_lut_load(crtc); 1265 nv50_crtc_lut_load(crtc);
1266 } 1266 }
1267 1267
1268 static void 1268 static void
1269 nv50_crtc_destroy(struct drm_crtc *crtc) 1269 nv50_crtc_destroy(struct drm_crtc *crtc)
1270 { 1270 {
1271 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 1271 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
1272 struct nv50_disp *disp = nv50_disp(crtc->dev); 1272 struct nv50_disp *disp = nv50_disp(crtc->dev);
1273 struct nv50_head *head = nv50_head(crtc); 1273 struct nv50_head *head = nv50_head(crtc);
1274 nv50_dmac_destroy(disp->core, &head->ovly.base); 1274 nv50_dmac_destroy(disp->core, &head->ovly.base);
1275 nv50_pioc_destroy(disp->core, &head->oimm.base); 1275 nv50_pioc_destroy(disp->core, &head->oimm.base);
1276 nv50_dmac_destroy(disp->core, &head->sync.base); 1276 nv50_dmac_destroy(disp->core, &head->sync.base);
1277 nv50_pioc_destroy(disp->core, &head->curs.base); 1277 nv50_pioc_destroy(disp->core, &head->curs.base);
1278 nouveau_bo_unmap(nv_crtc->cursor.nvbo); 1278 nouveau_bo_unmap(nv_crtc->cursor.nvbo);
1279 if (nv_crtc->cursor.nvbo) 1279 if (nv_crtc->cursor.nvbo)
1280 nouveau_bo_unpin(nv_crtc->cursor.nvbo); 1280 nouveau_bo_unpin(nv_crtc->cursor.nvbo);
1281 nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); 1281 nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
1282 nouveau_bo_unmap(nv_crtc->lut.nvbo); 1282 nouveau_bo_unmap(nv_crtc->lut.nvbo);
1283 if (nv_crtc->lut.nvbo) 1283 if (nv_crtc->lut.nvbo)
1284 nouveau_bo_unpin(nv_crtc->lut.nvbo); 1284 nouveau_bo_unpin(nv_crtc->lut.nvbo);
1285 nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo); 1285 nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo);
1286 drm_crtc_cleanup(crtc); 1286 drm_crtc_cleanup(crtc);
1287 kfree(crtc); 1287 kfree(crtc);
1288 } 1288 }
1289 1289
1290 static const struct drm_crtc_helper_funcs nv50_crtc_hfunc = { 1290 static const struct drm_crtc_helper_funcs nv50_crtc_hfunc = {
1291 .dpms = nv50_crtc_dpms, 1291 .dpms = nv50_crtc_dpms,
1292 .prepare = nv50_crtc_prepare, 1292 .prepare = nv50_crtc_prepare,
1293 .commit = nv50_crtc_commit, 1293 .commit = nv50_crtc_commit,
1294 .mode_fixup = nv50_crtc_mode_fixup, 1294 .mode_fixup = nv50_crtc_mode_fixup,
1295 .mode_set = nv50_crtc_mode_set, 1295 .mode_set = nv50_crtc_mode_set,
1296 .mode_set_base = nv50_crtc_mode_set_base, 1296 .mode_set_base = nv50_crtc_mode_set_base,
1297 .mode_set_base_atomic = nv50_crtc_mode_set_base_atomic, 1297 .mode_set_base_atomic = nv50_crtc_mode_set_base_atomic,
1298 .load_lut = nv50_crtc_lut_load, 1298 .load_lut = nv50_crtc_lut_load,
1299 }; 1299 };
1300 1300
1301 static const struct drm_crtc_funcs nv50_crtc_func = { 1301 static const struct drm_crtc_funcs nv50_crtc_func = {
1302 .cursor_set = nv50_crtc_cursor_set, 1302 .cursor_set = nv50_crtc_cursor_set,
1303 .cursor_move = nv50_crtc_cursor_move, 1303 .cursor_move = nv50_crtc_cursor_move,
1304 .gamma_set = nv50_crtc_gamma_set, 1304 .gamma_set = nv50_crtc_gamma_set,
1305 .set_config = drm_crtc_helper_set_config, 1305 .set_config = drm_crtc_helper_set_config,
1306 .destroy = nv50_crtc_destroy, 1306 .destroy = nv50_crtc_destroy,
1307 .page_flip = nouveau_crtc_page_flip, 1307 .page_flip = nouveau_crtc_page_flip,
1308 }; 1308 };
1309 1309
1310 static void 1310 static void
1311 nv50_cursor_set_pos(struct nouveau_crtc *nv_crtc, int x, int y) 1311 nv50_cursor_set_pos(struct nouveau_crtc *nv_crtc, int x, int y)
1312 { 1312 {
1313 } 1313 }
1314 1314
1315 static void 1315 static void
1316 nv50_cursor_set_offset(struct nouveau_crtc *nv_crtc, uint32_t offset) 1316 nv50_cursor_set_offset(struct nouveau_crtc *nv_crtc, uint32_t offset)
1317 { 1317 {
1318 } 1318 }
1319 1319
1320 static int 1320 static int
1321 nv50_crtc_create(struct drm_device *dev, struct nouveau_object *core, int index) 1321 nv50_crtc_create(struct drm_device *dev, struct nouveau_object *core, int index)
1322 { 1322 {
1323 struct nv50_disp *disp = nv50_disp(dev); 1323 struct nv50_disp *disp = nv50_disp(dev);
1324 struct nv50_head *head; 1324 struct nv50_head *head;
1325 struct drm_crtc *crtc; 1325 struct drm_crtc *crtc;
1326 int ret, i; 1326 int ret, i;
1327 1327
1328 head = kzalloc(sizeof(*head), GFP_KERNEL); 1328 head = kzalloc(sizeof(*head), GFP_KERNEL);
1329 if (!head) 1329 if (!head)
1330 return -ENOMEM; 1330 return -ENOMEM;
1331 1331
1332 head->base.index = index; 1332 head->base.index = index;
1333 head->base.set_dither = nv50_crtc_set_dither; 1333 head->base.set_dither = nv50_crtc_set_dither;
1334 head->base.set_scale = nv50_crtc_set_scale; 1334 head->base.set_scale = nv50_crtc_set_scale;
1335 head->base.set_color_vibrance = nv50_crtc_set_color_vibrance; 1335 head->base.set_color_vibrance = nv50_crtc_set_color_vibrance;
1336 head->base.color_vibrance = 50; 1336 head->base.color_vibrance = 50;
1337 head->base.vibrant_hue = 0; 1337 head->base.vibrant_hue = 0;
1338 head->base.cursor.set_offset = nv50_cursor_set_offset; 1338 head->base.cursor.set_offset = nv50_cursor_set_offset;
1339 head->base.cursor.set_pos = nv50_cursor_set_pos; 1339 head->base.cursor.set_pos = nv50_cursor_set_pos;
1340 for (i = 0; i < 256; i++) { 1340 for (i = 0; i < 256; i++) {
1341 head->base.lut.r[i] = i << 8; 1341 head->base.lut.r[i] = i << 8;
1342 head->base.lut.g[i] = i << 8; 1342 head->base.lut.g[i] = i << 8;
1343 head->base.lut.b[i] = i << 8; 1343 head->base.lut.b[i] = i << 8;
1344 } 1344 }
1345 1345
1346 crtc = &head->base.base; 1346 crtc = &head->base.base;
1347 drm_crtc_init(dev, crtc, &nv50_crtc_func); 1347 drm_crtc_init(dev, crtc, &nv50_crtc_func);
1348 drm_crtc_helper_add(crtc, &nv50_crtc_hfunc); 1348 drm_crtc_helper_add(crtc, &nv50_crtc_hfunc);
1349 drm_mode_crtc_set_gamma_size(crtc, 256); 1349 drm_mode_crtc_set_gamma_size(crtc, 256);
1350 1350
1351 ret = nouveau_bo_new(dev, 8192, 0x100, TTM_PL_FLAG_VRAM, 1351 ret = nouveau_bo_new(dev, 8192, 0x100, TTM_PL_FLAG_VRAM,
1352 0, 0x0000, NULL, &head->base.lut.nvbo); 1352 0, 0x0000, NULL, &head->base.lut.nvbo);
1353 if (!ret) { 1353 if (!ret) {
1354 ret = nouveau_bo_pin(head->base.lut.nvbo, TTM_PL_FLAG_VRAM); 1354 ret = nouveau_bo_pin(head->base.lut.nvbo, TTM_PL_FLAG_VRAM);
1355 if (!ret) { 1355 if (!ret) {
1356 ret = nouveau_bo_map(head->base.lut.nvbo); 1356 ret = nouveau_bo_map(head->base.lut.nvbo);
1357 if (ret) 1357 if (ret)
1358 nouveau_bo_unpin(head->base.lut.nvbo); 1358 nouveau_bo_unpin(head->base.lut.nvbo);
1359 } 1359 }
1360 if (ret) 1360 if (ret)
1361 nouveau_bo_ref(NULL, &head->base.lut.nvbo); 1361 nouveau_bo_ref(NULL, &head->base.lut.nvbo);
1362 } 1362 }
1363 1363
1364 if (ret) 1364 if (ret)
1365 goto out; 1365 goto out;
1366 1366
1367 nv50_crtc_lut_load(crtc); 1367 nv50_crtc_lut_load(crtc);
1368 1368
1369 /* allocate cursor resources */ 1369 /* allocate cursor resources */
1370 ret = nv50_pioc_create(disp->core, NV50_DISP_CURS_CLASS, index, 1370 ret = nv50_pioc_create(disp->core, NV50_DISP_CURS_CLASS, index,
1371 &(struct nv50_display_curs_class) { 1371 &(struct nv50_display_curs_class) {
1372 .head = index, 1372 .head = index,
1373 }, sizeof(struct nv50_display_curs_class), 1373 }, sizeof(struct nv50_display_curs_class),
1374 &head->curs.base); 1374 &head->curs.base);
1375 if (ret) 1375 if (ret)
1376 goto out; 1376 goto out;
1377 1377
1378 ret = nouveau_bo_new(dev, 64 * 64 * 4, 0x100, TTM_PL_FLAG_VRAM, 1378 ret = nouveau_bo_new(dev, 64 * 64 * 4, 0x100, TTM_PL_FLAG_VRAM,
1379 0, 0x0000, NULL, &head->base.cursor.nvbo); 1379 0, 0x0000, NULL, &head->base.cursor.nvbo);
1380 if (!ret) { 1380 if (!ret) {
1381 ret = nouveau_bo_pin(head->base.cursor.nvbo, TTM_PL_FLAG_VRAM); 1381 ret = nouveau_bo_pin(head->base.cursor.nvbo, TTM_PL_FLAG_VRAM);
1382 if (!ret) { 1382 if (!ret) {
1383 ret = nouveau_bo_map(head->base.cursor.nvbo); 1383 ret = nouveau_bo_map(head->base.cursor.nvbo);
1384 if (ret) 1384 if (ret)
1385 nouveau_bo_unpin(head->base.lut.nvbo); 1385 nouveau_bo_unpin(head->base.lut.nvbo);
1386 } 1386 }
1387 if (ret) 1387 if (ret)
1388 nouveau_bo_ref(NULL, &head->base.cursor.nvbo); 1388 nouveau_bo_ref(NULL, &head->base.cursor.nvbo);
1389 } 1389 }
1390 1390
1391 if (ret) 1391 if (ret)
1392 goto out; 1392 goto out;
1393 1393
1394 /* allocate page flip / sync resources */ 1394 /* allocate page flip / sync resources */
1395 ret = nv50_dmac_create(disp->core, NV50_DISP_SYNC_CLASS, index, 1395 ret = nv50_dmac_create(disp->core, NV50_DISP_SYNC_CLASS, index,
1396 &(struct nv50_display_sync_class) { 1396 &(struct nv50_display_sync_class) {
1397 .pushbuf = EVO_PUSH_HANDLE(SYNC, index), 1397 .pushbuf = EVO_PUSH_HANDLE(SYNC, index),
1398 .head = index, 1398 .head = index,
1399 }, sizeof(struct nv50_display_sync_class), 1399 }, sizeof(struct nv50_display_sync_class),
1400 disp->sync->bo.offset, &head->sync.base); 1400 disp->sync->bo.offset, &head->sync.base);
1401 if (ret) 1401 if (ret)
1402 goto out; 1402 goto out;
1403 1403
1404 head->sync.addr = EVO_FLIP_SEM0(index); 1404 head->sync.addr = EVO_FLIP_SEM0(index);
1405 head->sync.data = 0x00000000; 1405 head->sync.data = 0x00000000;
1406 1406
1407 /* allocate overlay resources */ 1407 /* allocate overlay resources */
1408 ret = nv50_pioc_create(disp->core, NV50_DISP_OIMM_CLASS, index, 1408 ret = nv50_pioc_create(disp->core, NV50_DISP_OIMM_CLASS, index,
1409 &(struct nv50_display_oimm_class) { 1409 &(struct nv50_display_oimm_class) {
1410 .head = index, 1410 .head = index,
1411 }, sizeof(struct nv50_display_oimm_class), 1411 }, sizeof(struct nv50_display_oimm_class),
1412 &head->oimm.base); 1412 &head->oimm.base);
1413 if (ret) 1413 if (ret)
1414 goto out; 1414 goto out;
1415 1415
1416 ret = nv50_dmac_create(disp->core, NV50_DISP_OVLY_CLASS, index, 1416 ret = nv50_dmac_create(disp->core, NV50_DISP_OVLY_CLASS, index,
1417 &(struct nv50_display_ovly_class) { 1417 &(struct nv50_display_ovly_class) {
1418 .pushbuf = EVO_PUSH_HANDLE(OVLY, index), 1418 .pushbuf = EVO_PUSH_HANDLE(OVLY, index),
1419 .head = index, 1419 .head = index,
1420 }, sizeof(struct nv50_display_ovly_class), 1420 }, sizeof(struct nv50_display_ovly_class),
1421 disp->sync->bo.offset, &head->ovly.base); 1421 disp->sync->bo.offset, &head->ovly.base);
1422 if (ret) 1422 if (ret)
1423 goto out; 1423 goto out;
1424 1424
1425 out: 1425 out:
1426 if (ret) 1426 if (ret)
1427 nv50_crtc_destroy(crtc); 1427 nv50_crtc_destroy(crtc);
1428 return ret; 1428 return ret;
1429 } 1429 }
1430 1430
1431 /****************************************************************************** 1431 /******************************************************************************
1432 * DAC 1432 * DAC
1433 *****************************************************************************/ 1433 *****************************************************************************/
1434 static void 1434 static void
1435 nv50_dac_dpms(struct drm_encoder *encoder, int mode) 1435 nv50_dac_dpms(struct drm_encoder *encoder, int mode)
1436 { 1436 {
1437 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1437 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1438 struct nv50_disp *disp = nv50_disp(encoder->dev); 1438 struct nv50_disp *disp = nv50_disp(encoder->dev);
1439 int or = nv_encoder->or; 1439 int or = nv_encoder->or;
1440 u32 dpms_ctrl; 1440 u32 dpms_ctrl;
1441 1441
1442 dpms_ctrl = 0x00000000; 1442 dpms_ctrl = 0x00000000;
1443 if (mode == DRM_MODE_DPMS_STANDBY || mode == DRM_MODE_DPMS_OFF) 1443 if (mode == DRM_MODE_DPMS_STANDBY || mode == DRM_MODE_DPMS_OFF)
1444 dpms_ctrl |= 0x00000001; 1444 dpms_ctrl |= 0x00000001;
1445 if (mode == DRM_MODE_DPMS_SUSPEND || mode == DRM_MODE_DPMS_OFF) 1445 if (mode == DRM_MODE_DPMS_SUSPEND || mode == DRM_MODE_DPMS_OFF)
1446 dpms_ctrl |= 0x00000004; 1446 dpms_ctrl |= 0x00000004;
1447 1447
1448 nv_call(disp->core, NV50_DISP_DAC_PWR + or, dpms_ctrl); 1448 nv_call(disp->core, NV50_DISP_DAC_PWR + or, dpms_ctrl);
1449 } 1449 }
1450 1450
1451 static bool 1451 static bool
1452 nv50_dac_mode_fixup(struct drm_encoder *encoder, 1452 nv50_dac_mode_fixup(struct drm_encoder *encoder,
1453 const struct drm_display_mode *mode, 1453 const struct drm_display_mode *mode,
1454 struct drm_display_mode *adjusted_mode) 1454 struct drm_display_mode *adjusted_mode)
1455 { 1455 {
1456 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1456 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1457 struct nouveau_connector *nv_connector; 1457 struct nouveau_connector *nv_connector;
1458 1458
1459 nv_connector = nouveau_encoder_connector_get(nv_encoder); 1459 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1460 if (nv_connector && nv_connector->native_mode) { 1460 if (nv_connector && nv_connector->native_mode) {
1461 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) { 1461 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) {
1462 int id = adjusted_mode->base.id; 1462 int id = adjusted_mode->base.id;
1463 *adjusted_mode = *nv_connector->native_mode; 1463 *adjusted_mode = *nv_connector->native_mode;
1464 adjusted_mode->base.id = id; 1464 adjusted_mode->base.id = id;
1465 } 1465 }
1466 } 1466 }
1467 1467
1468 return true; 1468 return true;
1469 } 1469 }
1470 1470
1471 static void 1471 static void
1472 nv50_dac_commit(struct drm_encoder *encoder) 1472 nv50_dac_commit(struct drm_encoder *encoder)
1473 { 1473 {
1474 } 1474 }
1475 1475
1476 static void 1476 static void
1477 nv50_dac_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, 1477 nv50_dac_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
1478 struct drm_display_mode *adjusted_mode) 1478 struct drm_display_mode *adjusted_mode)
1479 { 1479 {
1480 struct nv50_mast *mast = nv50_mast(encoder->dev); 1480 struct nv50_mast *mast = nv50_mast(encoder->dev);
1481 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1481 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1482 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); 1482 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
1483 u32 *push; 1483 u32 *push;
1484 1484
1485 nv50_dac_dpms(encoder, DRM_MODE_DPMS_ON); 1485 nv50_dac_dpms(encoder, DRM_MODE_DPMS_ON);
1486 1486
1487 push = evo_wait(mast, 8); 1487 push = evo_wait(mast, 8);
1488 if (push) { 1488 if (push) {
1489 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 1489 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
1490 u32 syncs = 0x00000000; 1490 u32 syncs = 0x00000000;
1491 1491
1492 if (mode->flags & DRM_MODE_FLAG_NHSYNC) 1492 if (mode->flags & DRM_MODE_FLAG_NHSYNC)
1493 syncs |= 0x00000001; 1493 syncs |= 0x00000001;
1494 if (mode->flags & DRM_MODE_FLAG_NVSYNC) 1494 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
1495 syncs |= 0x00000002; 1495 syncs |= 0x00000002;
1496 1496
1497 evo_mthd(push, 0x0400 + (nv_encoder->or * 0x080), 2); 1497 evo_mthd(push, 0x0400 + (nv_encoder->or * 0x080), 2);
1498 evo_data(push, 1 << nv_crtc->index); 1498 evo_data(push, 1 << nv_crtc->index);
1499 evo_data(push, syncs); 1499 evo_data(push, syncs);
1500 } else { 1500 } else {
1501 u32 magic = 0x31ec6000 | (nv_crtc->index << 25); 1501 u32 magic = 0x31ec6000 | (nv_crtc->index << 25);
1502 u32 syncs = 0x00000001; 1502 u32 syncs = 0x00000001;
1503 1503
1504 if (mode->flags & DRM_MODE_FLAG_NHSYNC) 1504 if (mode->flags & DRM_MODE_FLAG_NHSYNC)
1505 syncs |= 0x00000008; 1505 syncs |= 0x00000008;
1506 if (mode->flags & DRM_MODE_FLAG_NVSYNC) 1506 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
1507 syncs |= 0x00000010; 1507 syncs |= 0x00000010;
1508 1508
1509 if (mode->flags & DRM_MODE_FLAG_INTERLACE) 1509 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
1510 magic |= 0x00000001; 1510 magic |= 0x00000001;
1511 1511
1512 evo_mthd(push, 0x0404 + (nv_crtc->index * 0x300), 2); 1512 evo_mthd(push, 0x0404 + (nv_crtc->index * 0x300), 2);
1513 evo_data(push, syncs); 1513 evo_data(push, syncs);
1514 evo_data(push, magic); 1514 evo_data(push, magic);
1515 evo_mthd(push, 0x0180 + (nv_encoder->or * 0x020), 1); 1515 evo_mthd(push, 0x0180 + (nv_encoder->or * 0x020), 1);
1516 evo_data(push, 1 << nv_crtc->index); 1516 evo_data(push, 1 << nv_crtc->index);
1517 } 1517 }
1518 1518
1519 evo_kick(push, mast); 1519 evo_kick(push, mast);
1520 } 1520 }
1521 1521
1522 nv_encoder->crtc = encoder->crtc; 1522 nv_encoder->crtc = encoder->crtc;
1523 } 1523 }
1524 1524
1525 static void 1525 static void
1526 nv50_dac_disconnect(struct drm_encoder *encoder) 1526 nv50_dac_disconnect(struct drm_encoder *encoder)
1527 { 1527 {
1528 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1528 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1529 struct nv50_mast *mast = nv50_mast(encoder->dev); 1529 struct nv50_mast *mast = nv50_mast(encoder->dev);
1530 const int or = nv_encoder->or; 1530 const int or = nv_encoder->or;
1531 u32 *push; 1531 u32 *push;
1532 1532
1533 if (nv_encoder->crtc) { 1533 if (nv_encoder->crtc) {
1534 nv50_crtc_prepare(nv_encoder->crtc); 1534 nv50_crtc_prepare(nv_encoder->crtc);
1535 1535
1536 push = evo_wait(mast, 4); 1536 push = evo_wait(mast, 4);
1537 if (push) { 1537 if (push) {
1538 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 1538 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
1539 evo_mthd(push, 0x0400 + (or * 0x080), 1); 1539 evo_mthd(push, 0x0400 + (or * 0x080), 1);
1540 evo_data(push, 0x00000000); 1540 evo_data(push, 0x00000000);
1541 } else { 1541 } else {
1542 evo_mthd(push, 0x0180 + (or * 0x020), 1); 1542 evo_mthd(push, 0x0180 + (or * 0x020), 1);
1543 evo_data(push, 0x00000000); 1543 evo_data(push, 0x00000000);
1544 } 1544 }
1545 evo_kick(push, mast); 1545 evo_kick(push, mast);
1546 } 1546 }
1547 } 1547 }
1548 1548
1549 nv_encoder->crtc = NULL; 1549 nv_encoder->crtc = NULL;
1550 } 1550 }
1551 1551
1552 static enum drm_connector_status 1552 static enum drm_connector_status
1553 nv50_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector) 1553 nv50_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector)
1554 { 1554 {
1555 struct nv50_disp *disp = nv50_disp(encoder->dev); 1555 struct nv50_disp *disp = nv50_disp(encoder->dev);
1556 int ret, or = nouveau_encoder(encoder)->or; 1556 int ret, or = nouveau_encoder(encoder)->or;
1557 u32 load = 0; 1557 u32 load = 0;
1558 1558
1559 ret = nv_exec(disp->core, NV50_DISP_DAC_LOAD + or, &load, sizeof(load)); 1559 ret = nv_exec(disp->core, NV50_DISP_DAC_LOAD + or, &load, sizeof(load));
1560 if (ret || load != 7) 1560 if (ret || load != 7)
1561 return connector_status_disconnected; 1561 return connector_status_disconnected;
1562 1562
1563 return connector_status_connected; 1563 return connector_status_connected;
1564 } 1564 }
1565 1565
1566 static void 1566 static void
1567 nv50_dac_destroy(struct drm_encoder *encoder) 1567 nv50_dac_destroy(struct drm_encoder *encoder)
1568 { 1568 {
1569 drm_encoder_cleanup(encoder); 1569 drm_encoder_cleanup(encoder);
1570 kfree(encoder); 1570 kfree(encoder);
1571 } 1571 }
1572 1572
1573 static const struct drm_encoder_helper_funcs nv50_dac_hfunc = { 1573 static const struct drm_encoder_helper_funcs nv50_dac_hfunc = {
1574 .dpms = nv50_dac_dpms, 1574 .dpms = nv50_dac_dpms,
1575 .mode_fixup = nv50_dac_mode_fixup, 1575 .mode_fixup = nv50_dac_mode_fixup,
1576 .prepare = nv50_dac_disconnect, 1576 .prepare = nv50_dac_disconnect,
1577 .commit = nv50_dac_commit, 1577 .commit = nv50_dac_commit,
1578 .mode_set = nv50_dac_mode_set, 1578 .mode_set = nv50_dac_mode_set,
1579 .disable = nv50_dac_disconnect, 1579 .disable = nv50_dac_disconnect,
1580 .get_crtc = nv50_display_crtc_get, 1580 .get_crtc = nv50_display_crtc_get,
1581 .detect = nv50_dac_detect 1581 .detect = nv50_dac_detect
1582 }; 1582 };
1583 1583
1584 static const struct drm_encoder_funcs nv50_dac_func = { 1584 static const struct drm_encoder_funcs nv50_dac_func = {
1585 .destroy = nv50_dac_destroy, 1585 .destroy = nv50_dac_destroy,
1586 }; 1586 };
1587 1587
1588 static int 1588 static int
1589 nv50_dac_create(struct drm_connector *connector, struct dcb_output *dcbe) 1589 nv50_dac_create(struct drm_connector *connector, struct dcb_output *dcbe)
1590 { 1590 {
1591 struct nouveau_drm *drm = nouveau_drm(connector->dev); 1591 struct nouveau_drm *drm = nouveau_drm(connector->dev);
1592 struct nouveau_i2c *i2c = nouveau_i2c(drm->device); 1592 struct nouveau_i2c *i2c = nouveau_i2c(drm->device);
1593 struct nouveau_encoder *nv_encoder; 1593 struct nouveau_encoder *nv_encoder;
1594 struct drm_encoder *encoder; 1594 struct drm_encoder *encoder;
1595 int type = DRM_MODE_ENCODER_DAC; 1595 int type = DRM_MODE_ENCODER_DAC;
1596 1596
1597 nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL); 1597 nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL);
1598 if (!nv_encoder) 1598 if (!nv_encoder)
1599 return -ENOMEM; 1599 return -ENOMEM;
1600 nv_encoder->dcb = dcbe; 1600 nv_encoder->dcb = dcbe;
1601 nv_encoder->or = ffs(dcbe->or) - 1; 1601 nv_encoder->or = ffs(dcbe->or) - 1;
1602 nv_encoder->i2c = i2c->find(i2c, dcbe->i2c_index); 1602 nv_encoder->i2c = i2c->find(i2c, dcbe->i2c_index);
1603 1603
1604 encoder = to_drm_encoder(nv_encoder); 1604 encoder = to_drm_encoder(nv_encoder);
1605 encoder->possible_crtcs = dcbe->heads; 1605 encoder->possible_crtcs = dcbe->heads;
1606 encoder->possible_clones = 0; 1606 encoder->possible_clones = 0;
1607 drm_encoder_init(connector->dev, encoder, &nv50_dac_func, type); 1607 drm_encoder_init(connector->dev, encoder, &nv50_dac_func, type);
1608 drm_encoder_helper_add(encoder, &nv50_dac_hfunc); 1608 drm_encoder_helper_add(encoder, &nv50_dac_hfunc);
1609 1609
1610 drm_mode_connector_attach_encoder(connector, encoder); 1610 drm_mode_connector_attach_encoder(connector, encoder);
1611 return 0; 1611 return 0;
1612 } 1612 }
1613 1613
1614 /****************************************************************************** 1614 /******************************************************************************
1615 * Audio 1615 * Audio
1616 *****************************************************************************/ 1616 *****************************************************************************/
1617 static void 1617 static void
1618 nv50_audio_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode) 1618 nv50_audio_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode)
1619 { 1619 {
1620 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1620 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1621 struct nouveau_connector *nv_connector; 1621 struct nouveau_connector *nv_connector;
1622 struct nv50_disp *disp = nv50_disp(encoder->dev); 1622 struct nv50_disp *disp = nv50_disp(encoder->dev);
1623 1623
1624 nv_connector = nouveau_encoder_connector_get(nv_encoder); 1624 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1625 if (!drm_detect_monitor_audio(nv_connector->edid)) 1625 if (!drm_detect_monitor_audio(nv_connector->edid))
1626 return; 1626 return;
1627 1627
1628 drm_edid_to_eld(&nv_connector->base, nv_connector->edid); 1628 drm_edid_to_eld(&nv_connector->base, nv_connector->edid);
1629 1629
1630 nv_exec(disp->core, NVA3_DISP_SOR_HDA_ELD + nv_encoder->or, 1630 nv_exec(disp->core, NVA3_DISP_SOR_HDA_ELD + nv_encoder->or,
1631 nv_connector->base.eld, 1631 nv_connector->base.eld,
1632 nv_connector->base.eld[2] * 4); 1632 nv_connector->base.eld[2] * 4);
1633 } 1633 }
1634 1634
1635 static void 1635 static void
1636 nv50_audio_disconnect(struct drm_encoder *encoder) 1636 nv50_audio_disconnect(struct drm_encoder *encoder)
1637 { 1637 {
1638 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1638 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1639 struct nv50_disp *disp = nv50_disp(encoder->dev); 1639 struct nv50_disp *disp = nv50_disp(encoder->dev);
1640 1640
1641 nv_exec(disp->core, NVA3_DISP_SOR_HDA_ELD + nv_encoder->or, NULL, 0); 1641 nv_exec(disp->core, NVA3_DISP_SOR_HDA_ELD + nv_encoder->or, NULL, 0);
1642 } 1642 }
1643 1643
1644 /****************************************************************************** 1644 /******************************************************************************
1645 * HDMI 1645 * HDMI
1646 *****************************************************************************/ 1646 *****************************************************************************/
1647 static void 1647 static void
1648 nv50_hdmi_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode) 1648 nv50_hdmi_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode)
1649 { 1649 {
1650 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1650 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1651 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); 1651 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
1652 struct nouveau_connector *nv_connector; 1652 struct nouveau_connector *nv_connector;
1653 struct nv50_disp *disp = nv50_disp(encoder->dev); 1653 struct nv50_disp *disp = nv50_disp(encoder->dev);
1654 const u32 moff = (nv_crtc->index << 3) | nv_encoder->or; 1654 const u32 moff = (nv_crtc->index << 3) | nv_encoder->or;
1655 u32 rekey = 56; /* binary driver, and tegra constant */ 1655 u32 rekey = 56; /* binary driver, and tegra constant */
1656 u32 max_ac_packet; 1656 u32 max_ac_packet;
1657 1657
1658 nv_connector = nouveau_encoder_connector_get(nv_encoder); 1658 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1659 if (!drm_detect_hdmi_monitor(nv_connector->edid)) 1659 if (!drm_detect_hdmi_monitor(nv_connector->edid))
1660 return; 1660 return;
1661 1661
1662 max_ac_packet = mode->htotal - mode->hdisplay; 1662 max_ac_packet = mode->htotal - mode->hdisplay;
1663 max_ac_packet -= rekey; 1663 max_ac_packet -= rekey;
1664 max_ac_packet -= 18; /* constant from tegra */ 1664 max_ac_packet -= 18; /* constant from tegra */
1665 max_ac_packet /= 32; 1665 max_ac_packet /= 32;
1666 1666
1667 nv_call(disp->core, NV84_DISP_SOR_HDMI_PWR + moff, 1667 nv_call(disp->core, NV84_DISP_SOR_HDMI_PWR + moff,
1668 NV84_DISP_SOR_HDMI_PWR_STATE_ON | 1668 NV84_DISP_SOR_HDMI_PWR_STATE_ON |
1669 (max_ac_packet << 16) | rekey); 1669 (max_ac_packet << 16) | rekey);
1670 1670
1671 nv50_audio_mode_set(encoder, mode); 1671 nv50_audio_mode_set(encoder, mode);
1672 } 1672 }
1673 1673
1674 static void 1674 static void
1675 nv50_hdmi_disconnect(struct drm_encoder *encoder) 1675 nv50_hdmi_disconnect(struct drm_encoder *encoder)
1676 { 1676 {
1677 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1677 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1678 struct nouveau_crtc *nv_crtc = nouveau_crtc(nv_encoder->crtc); 1678 struct nouveau_crtc *nv_crtc = nouveau_crtc(nv_encoder->crtc);
1679 struct nv50_disp *disp = nv50_disp(encoder->dev); 1679 struct nv50_disp *disp = nv50_disp(encoder->dev);
1680 const u32 moff = (nv_crtc->index << 3) | nv_encoder->or; 1680 const u32 moff = (nv_crtc->index << 3) | nv_encoder->or;
1681 1681
1682 nv50_audio_disconnect(encoder); 1682 nv50_audio_disconnect(encoder);
1683 1683
1684 nv_call(disp->core, NV84_DISP_SOR_HDMI_PWR + moff, 0x00000000); 1684 nv_call(disp->core, NV84_DISP_SOR_HDMI_PWR + moff, 0x00000000);
1685 } 1685 }
1686 1686
1687 /****************************************************************************** 1687 /******************************************************************************
1688 * SOR 1688 * SOR
1689 *****************************************************************************/ 1689 *****************************************************************************/
1690 static void 1690 static void
1691 nv50_sor_dpms(struct drm_encoder *encoder, int mode) 1691 nv50_sor_dpms(struct drm_encoder *encoder, int mode)
1692 { 1692 {
1693 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1693 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1694 struct drm_device *dev = encoder->dev; 1694 struct drm_device *dev = encoder->dev;
1695 struct nv50_disp *disp = nv50_disp(dev); 1695 struct nv50_disp *disp = nv50_disp(dev);
1696 struct drm_encoder *partner; 1696 struct drm_encoder *partner;
1697 int or = nv_encoder->or; 1697 int or = nv_encoder->or;
1698 1698
1699 nv_encoder->last_dpms = mode; 1699 nv_encoder->last_dpms = mode;
1700 1700
1701 list_for_each_entry(partner, &dev->mode_config.encoder_list, head) { 1701 list_for_each_entry(partner, &dev->mode_config.encoder_list, head) {
1702 struct nouveau_encoder *nv_partner = nouveau_encoder(partner); 1702 struct nouveau_encoder *nv_partner = nouveau_encoder(partner);
1703 1703
1704 if (partner->encoder_type != DRM_MODE_ENCODER_TMDS) 1704 if (partner->encoder_type != DRM_MODE_ENCODER_TMDS)
1705 continue; 1705 continue;
1706 1706
1707 if (nv_partner != nv_encoder && 1707 if (nv_partner != nv_encoder &&
1708 nv_partner->dcb->or == nv_encoder->dcb->or) { 1708 nv_partner->dcb->or == nv_encoder->dcb->or) {
1709 if (nv_partner->last_dpms == DRM_MODE_DPMS_ON) 1709 if (nv_partner->last_dpms == DRM_MODE_DPMS_ON)
1710 return; 1710 return;
1711 break; 1711 break;
1712 } 1712 }
1713 } 1713 }
1714 1714
1715 nv_call(disp->core, NV50_DISP_SOR_PWR + or, (mode == DRM_MODE_DPMS_ON)); 1715 nv_call(disp->core, NV50_DISP_SOR_PWR + or, (mode == DRM_MODE_DPMS_ON));
1716 } 1716 }
1717 1717
1718 static bool 1718 static bool
1719 nv50_sor_mode_fixup(struct drm_encoder *encoder, 1719 nv50_sor_mode_fixup(struct drm_encoder *encoder,
1720 const struct drm_display_mode *mode, 1720 const struct drm_display_mode *mode,
1721 struct drm_display_mode *adjusted_mode) 1721 struct drm_display_mode *adjusted_mode)
1722 { 1722 {
1723 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1723 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1724 struct nouveau_connector *nv_connector; 1724 struct nouveau_connector *nv_connector;
1725 1725
1726 nv_connector = nouveau_encoder_connector_get(nv_encoder); 1726 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1727 if (nv_connector && nv_connector->native_mode) { 1727 if (nv_connector && nv_connector->native_mode) {
1728 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) { 1728 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) {
1729 int id = adjusted_mode->base.id; 1729 int id = adjusted_mode->base.id;
1730 *adjusted_mode = *nv_connector->native_mode; 1730 *adjusted_mode = *nv_connector->native_mode;
1731 adjusted_mode->base.id = id; 1731 adjusted_mode->base.id = id;
1732 } 1732 }
1733 } 1733 }
1734 1734
1735 return true; 1735 return true;
1736 } 1736 }
1737 1737
1738 static void 1738 static void
1739 nv50_sor_disconnect(struct drm_encoder *encoder) 1739 nv50_sor_disconnect(struct drm_encoder *encoder)
1740 { 1740 {
1741 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1741 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1742 struct nv50_mast *mast = nv50_mast(encoder->dev); 1742 struct nv50_mast *mast = nv50_mast(encoder->dev);
1743 const int or = nv_encoder->or; 1743 const int or = nv_encoder->or;
1744 u32 *push; 1744 u32 *push;
1745 1745
1746 if (nv_encoder->crtc) { 1746 if (nv_encoder->crtc) {
1747 nv50_crtc_prepare(nv_encoder->crtc); 1747 nv50_crtc_prepare(nv_encoder->crtc);
1748 1748
1749 push = evo_wait(mast, 4); 1749 push = evo_wait(mast, 4);
1750 if (push) { 1750 if (push) {
1751 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 1751 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
1752 evo_mthd(push, 0x0600 + (or * 0x40), 1); 1752 evo_mthd(push, 0x0600 + (or * 0x40), 1);
1753 evo_data(push, 0x00000000); 1753 evo_data(push, 0x00000000);
1754 } else { 1754 } else {
1755 evo_mthd(push, 0x0200 + (or * 0x20), 1); 1755 evo_mthd(push, 0x0200 + (or * 0x20), 1);
1756 evo_data(push, 0x00000000); 1756 evo_data(push, 0x00000000);
1757 } 1757 }
1758 evo_kick(push, mast); 1758 evo_kick(push, mast);
1759 } 1759 }
1760 1760
1761 nv50_hdmi_disconnect(encoder); 1761 nv50_hdmi_disconnect(encoder);
1762 } 1762 }
1763 1763
1764 nv_encoder->last_dpms = DRM_MODE_DPMS_OFF; 1764 nv_encoder->last_dpms = DRM_MODE_DPMS_OFF;
1765 nv_encoder->crtc = NULL; 1765 nv_encoder->crtc = NULL;
1766 } 1766 }
1767 1767
1768 static void 1768 static void
1769 nv50_sor_commit(struct drm_encoder *encoder) 1769 nv50_sor_commit(struct drm_encoder *encoder)
1770 { 1770 {
1771 } 1771 }
1772 1772
1773 static void 1773 static void
1774 nv50_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *umode, 1774 nv50_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *umode,
1775 struct drm_display_mode *mode) 1775 struct drm_display_mode *mode)
1776 { 1776 {
1777 struct nv50_disp *disp = nv50_disp(encoder->dev); 1777 struct nv50_disp *disp = nv50_disp(encoder->dev);
1778 struct nv50_mast *mast = nv50_mast(encoder->dev); 1778 struct nv50_mast *mast = nv50_mast(encoder->dev);
1779 struct drm_device *dev = encoder->dev; 1779 struct drm_device *dev = encoder->dev;
1780 struct nouveau_drm *drm = nouveau_drm(dev); 1780 struct nouveau_drm *drm = nouveau_drm(dev);
1781 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1781 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1782 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); 1782 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
1783 struct nouveau_connector *nv_connector; 1783 struct nouveau_connector *nv_connector;
1784 struct nvbios *bios = &drm->vbios; 1784 struct nvbios *bios = &drm->vbios;
1785 u32 *push, lvds = 0; 1785 u32 *push, lvds = 0;
1786 u8 owner = 1 << nv_crtc->index; 1786 u8 owner = 1 << nv_crtc->index;
1787 u8 proto = 0xf; 1787 u8 proto = 0xf;
1788 u8 depth = 0x0; 1788 u8 depth = 0x0;
1789 1789
1790 nv_connector = nouveau_encoder_connector_get(nv_encoder); 1790 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1791 switch (nv_encoder->dcb->type) { 1791 switch (nv_encoder->dcb->type) {
1792 case DCB_OUTPUT_TMDS: 1792 case DCB_OUTPUT_TMDS:
1793 if (nv_encoder->dcb->sorconf.link & 1) { 1793 if (nv_encoder->dcb->sorconf.link & 1) {
1794 if (mode->clock < 165000) 1794 if (mode->clock < 165000)
1795 proto = 0x1; 1795 proto = 0x1;
1796 else 1796 else
1797 proto = 0x5; 1797 proto = 0x5;
1798 } else { 1798 } else {
1799 proto = 0x2; 1799 proto = 0x2;
1800 } 1800 }
1801 1801
1802 nv50_hdmi_mode_set(encoder, mode); 1802 nv50_hdmi_mode_set(encoder, mode);
1803 break; 1803 break;
1804 case DCB_OUTPUT_LVDS: 1804 case DCB_OUTPUT_LVDS:
1805 proto = 0x0; 1805 proto = 0x0;
1806 1806
1807 if (bios->fp_no_ddc) { 1807 if (bios->fp_no_ddc) {
1808 if (bios->fp.dual_link) 1808 if (bios->fp.dual_link)
1809 lvds |= 0x0100; 1809 lvds |= 0x0100;
1810 if (bios->fp.if_is_24bit) 1810 if (bios->fp.if_is_24bit)
1811 lvds |= 0x0200; 1811 lvds |= 0x0200;
1812 } else { 1812 } else {
1813 if (nv_connector->type == DCB_CONNECTOR_LVDS_SPWG) { 1813 if (nv_connector->type == DCB_CONNECTOR_LVDS_SPWG) {
1814 if (((u8 *)nv_connector->edid)[121] == 2) 1814 if (((u8 *)nv_connector->edid)[121] == 2)
1815 lvds |= 0x0100; 1815 lvds |= 0x0100;
1816 } else 1816 } else
1817 if (mode->clock >= bios->fp.duallink_transition_clk) { 1817 if (mode->clock >= bios->fp.duallink_transition_clk) {
1818 lvds |= 0x0100; 1818 lvds |= 0x0100;
1819 } 1819 }
1820 1820
1821 if (lvds & 0x0100) { 1821 if (lvds & 0x0100) {
1822 if (bios->fp.strapless_is_24bit & 2) 1822 if (bios->fp.strapless_is_24bit & 2)
1823 lvds |= 0x0200; 1823 lvds |= 0x0200;
1824 } else { 1824 } else {
1825 if (bios->fp.strapless_is_24bit & 1) 1825 if (bios->fp.strapless_is_24bit & 1)
1826 lvds |= 0x0200; 1826 lvds |= 0x0200;
1827 } 1827 }
1828 1828
1829 if (nv_connector->base.display_info.bpc == 8) 1829 if (nv_connector->base.display_info.bpc == 8)
1830 lvds |= 0x0200; 1830 lvds |= 0x0200;
1831 } 1831 }
1832 1832
1833 nv_call(disp->core, NV50_DISP_SOR_LVDS_SCRIPT + nv_encoder->or, lvds); 1833 nv_call(disp->core, NV50_DISP_SOR_LVDS_SCRIPT + nv_encoder->or, lvds);
1834 break; 1834 break;
1835 case DCB_OUTPUT_DP: 1835 case DCB_OUTPUT_DP:
1836 if (nv_connector->base.display_info.bpc == 6) { 1836 if (nv_connector->base.display_info.bpc == 6) {
1837 nv_encoder->dp.datarate = mode->clock * 18 / 8; 1837 nv_encoder->dp.datarate = mode->clock * 18 / 8;
1838 depth = 0x2; 1838 depth = 0x2;
1839 } else 1839 } else
1840 if (nv_connector->base.display_info.bpc == 8) { 1840 if (nv_connector->base.display_info.bpc == 8) {
1841 nv_encoder->dp.datarate = mode->clock * 24 / 8; 1841 nv_encoder->dp.datarate = mode->clock * 24 / 8;
1842 depth = 0x5; 1842 depth = 0x5;
1843 } else { 1843 } else {
1844 nv_encoder->dp.datarate = mode->clock * 30 / 8; 1844 nv_encoder->dp.datarate = mode->clock * 30 / 8;
1845 depth = 0x6; 1845 depth = 0x6;
1846 } 1846 }
1847 1847
1848 if (nv_encoder->dcb->sorconf.link & 1) 1848 if (nv_encoder->dcb->sorconf.link & 1)
1849 proto = 0x8; 1849 proto = 0x8;
1850 else 1850 else
1851 proto = 0x9; 1851 proto = 0x9;
1852 break; 1852 break;
1853 default: 1853 default:
1854 BUG_ON(1); 1854 BUG_ON(1);
1855 break; 1855 break;
1856 } 1856 }
1857 1857
1858 nv50_sor_dpms(encoder, DRM_MODE_DPMS_ON); 1858 nv50_sor_dpms(encoder, DRM_MODE_DPMS_ON);
1859 1859
1860 push = evo_wait(nv50_mast(dev), 8); 1860 push = evo_wait(nv50_mast(dev), 8);
1861 if (push) { 1861 if (push) {
1862 if (nv50_vers(mast) < NVD0_DISP_CLASS) { 1862 if (nv50_vers(mast) < NVD0_DISP_CLASS) {
1863 u32 ctrl = (depth << 16) | (proto << 8) | owner; 1863 u32 ctrl = (depth << 16) | (proto << 8) | owner;
1864 if (mode->flags & DRM_MODE_FLAG_NHSYNC) 1864 if (mode->flags & DRM_MODE_FLAG_NHSYNC)
1865 ctrl |= 0x00001000; 1865 ctrl |= 0x00001000;
1866 if (mode->flags & DRM_MODE_FLAG_NVSYNC) 1866 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
1867 ctrl |= 0x00002000; 1867 ctrl |= 0x00002000;
1868 evo_mthd(push, 0x0600 + (nv_encoder->or * 0x040), 1); 1868 evo_mthd(push, 0x0600 + (nv_encoder->or * 0x040), 1);
1869 evo_data(push, ctrl); 1869 evo_data(push, ctrl);
1870 } else { 1870 } else {
1871 u32 magic = 0x31ec6000 | (nv_crtc->index << 25); 1871 u32 magic = 0x31ec6000 | (nv_crtc->index << 25);
1872 u32 syncs = 0x00000001; 1872 u32 syncs = 0x00000001;
1873 1873
1874 if (mode->flags & DRM_MODE_FLAG_NHSYNC) 1874 if (mode->flags & DRM_MODE_FLAG_NHSYNC)
1875 syncs |= 0x00000008; 1875 syncs |= 0x00000008;
1876 if (mode->flags & DRM_MODE_FLAG_NVSYNC) 1876 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
1877 syncs |= 0x00000010; 1877 syncs |= 0x00000010;
1878 1878
1879 if (mode->flags & DRM_MODE_FLAG_INTERLACE) 1879 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
1880 magic |= 0x00000001; 1880 magic |= 0x00000001;
1881 1881
1882 evo_mthd(push, 0x0404 + (nv_crtc->index * 0x300), 2); 1882 evo_mthd(push, 0x0404 + (nv_crtc->index * 0x300), 2);
1883 evo_data(push, syncs | (depth << 6)); 1883 evo_data(push, syncs | (depth << 6));
1884 evo_data(push, magic); 1884 evo_data(push, magic);
1885 evo_mthd(push, 0x0200 + (nv_encoder->or * 0x020), 1); 1885 evo_mthd(push, 0x0200 + (nv_encoder->or * 0x020), 1);
1886 evo_data(push, owner | (proto << 8)); 1886 evo_data(push, owner | (proto << 8));
1887 } 1887 }
1888 1888
1889 evo_kick(push, mast); 1889 evo_kick(push, mast);
1890 } 1890 }
1891 1891
1892 nv_encoder->crtc = encoder->crtc; 1892 nv_encoder->crtc = encoder->crtc;
1893 } 1893 }
1894 1894
1895 static void 1895 static void
1896 nv50_sor_destroy(struct drm_encoder *encoder) 1896 nv50_sor_destroy(struct drm_encoder *encoder)
1897 { 1897 {
1898 drm_encoder_cleanup(encoder); 1898 drm_encoder_cleanup(encoder);
1899 kfree(encoder); 1899 kfree(encoder);
1900 } 1900 }
1901 1901
1902 static const struct drm_encoder_helper_funcs nv50_sor_hfunc = { 1902 static const struct drm_encoder_helper_funcs nv50_sor_hfunc = {
1903 .dpms = nv50_sor_dpms, 1903 .dpms = nv50_sor_dpms,
1904 .mode_fixup = nv50_sor_mode_fixup, 1904 .mode_fixup = nv50_sor_mode_fixup,
1905 .prepare = nv50_sor_disconnect, 1905 .prepare = nv50_sor_disconnect,
1906 .commit = nv50_sor_commit, 1906 .commit = nv50_sor_commit,
1907 .mode_set = nv50_sor_mode_set, 1907 .mode_set = nv50_sor_mode_set,
1908 .disable = nv50_sor_disconnect, 1908 .disable = nv50_sor_disconnect,
1909 .get_crtc = nv50_display_crtc_get, 1909 .get_crtc = nv50_display_crtc_get,
1910 }; 1910 };
1911 1911
1912 static const struct drm_encoder_funcs nv50_sor_func = { 1912 static const struct drm_encoder_funcs nv50_sor_func = {
1913 .destroy = nv50_sor_destroy, 1913 .destroy = nv50_sor_destroy,
1914 }; 1914 };
1915 1915
1916 static int 1916 static int
1917 nv50_sor_create(struct drm_connector *connector, struct dcb_output *dcbe) 1917 nv50_sor_create(struct drm_connector *connector, struct dcb_output *dcbe)
1918 { 1918 {
1919 struct nouveau_drm *drm = nouveau_drm(connector->dev); 1919 struct nouveau_drm *drm = nouveau_drm(connector->dev);
1920 struct nouveau_i2c *i2c = nouveau_i2c(drm->device); 1920 struct nouveau_i2c *i2c = nouveau_i2c(drm->device);
1921 struct nouveau_encoder *nv_encoder; 1921 struct nouveau_encoder *nv_encoder;
1922 struct drm_encoder *encoder; 1922 struct drm_encoder *encoder;
1923 int type; 1923 int type;
1924 1924
1925 switch (dcbe->type) { 1925 switch (dcbe->type) {
1926 case DCB_OUTPUT_LVDS: type = DRM_MODE_ENCODER_LVDS; break; 1926 case DCB_OUTPUT_LVDS: type = DRM_MODE_ENCODER_LVDS; break;
1927 case DCB_OUTPUT_TMDS: 1927 case DCB_OUTPUT_TMDS:
1928 case DCB_OUTPUT_DP: 1928 case DCB_OUTPUT_DP:
1929 default: 1929 default:
1930 type = DRM_MODE_ENCODER_TMDS; 1930 type = DRM_MODE_ENCODER_TMDS;
1931 break; 1931 break;
1932 } 1932 }
1933 1933
1934 nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL); 1934 nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL);
1935 if (!nv_encoder) 1935 if (!nv_encoder)
1936 return -ENOMEM; 1936 return -ENOMEM;
1937 nv_encoder->dcb = dcbe; 1937 nv_encoder->dcb = dcbe;
1938 nv_encoder->or = ffs(dcbe->or) - 1; 1938 nv_encoder->or = ffs(dcbe->or) - 1;
1939 nv_encoder->i2c = i2c->find(i2c, dcbe->i2c_index); 1939 nv_encoder->i2c = i2c->find(i2c, dcbe->i2c_index);
1940 nv_encoder->last_dpms = DRM_MODE_DPMS_OFF; 1940 nv_encoder->last_dpms = DRM_MODE_DPMS_OFF;
1941 1941
1942 encoder = to_drm_encoder(nv_encoder); 1942 encoder = to_drm_encoder(nv_encoder);
1943 encoder->possible_crtcs = dcbe->heads; 1943 encoder->possible_crtcs = dcbe->heads;
1944 encoder->possible_clones = 0; 1944 encoder->possible_clones = 0;
1945 drm_encoder_init(connector->dev, encoder, &nv50_sor_func, type); 1945 drm_encoder_init(connector->dev, encoder, &nv50_sor_func, type);
1946 drm_encoder_helper_add(encoder, &nv50_sor_hfunc); 1946 drm_encoder_helper_add(encoder, &nv50_sor_hfunc);
1947 1947
1948 drm_mode_connector_attach_encoder(connector, encoder); 1948 drm_mode_connector_attach_encoder(connector, encoder);
1949 return 0; 1949 return 0;
1950 } 1950 }
1951 1951
1952 /****************************************************************************** 1952 /******************************************************************************
1953 * PIOR 1953 * PIOR
1954 *****************************************************************************/ 1954 *****************************************************************************/
1955 1955
1956 static void 1956 static void
1957 nv50_pior_dpms(struct drm_encoder *encoder, int mode) 1957 nv50_pior_dpms(struct drm_encoder *encoder, int mode)
1958 { 1958 {
1959 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1959 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1960 struct nv50_disp *disp = nv50_disp(encoder->dev); 1960 struct nv50_disp *disp = nv50_disp(encoder->dev);
1961 u32 mthd = (nv_encoder->dcb->type << 12) | nv_encoder->or; 1961 u32 mthd = (nv_encoder->dcb->type << 12) | nv_encoder->or;
1962 u32 ctrl = (mode == DRM_MODE_DPMS_ON); 1962 u32 ctrl = (mode == DRM_MODE_DPMS_ON);
1963 nv_call(disp->core, NV50_DISP_PIOR_PWR + mthd, ctrl); 1963 nv_call(disp->core, NV50_DISP_PIOR_PWR + mthd, ctrl);
1964 } 1964 }
1965 1965
1966 static bool 1966 static bool
1967 nv50_pior_mode_fixup(struct drm_encoder *encoder, 1967 nv50_pior_mode_fixup(struct drm_encoder *encoder,
1968 const struct drm_display_mode *mode, 1968 const struct drm_display_mode *mode,
1969 struct drm_display_mode *adjusted_mode) 1969 struct drm_display_mode *adjusted_mode)
1970 { 1970 {
1971 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1971 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1972 struct nouveau_connector *nv_connector; 1972 struct nouveau_connector *nv_connector;
1973 1973
1974 nv_connector = nouveau_encoder_connector_get(nv_encoder); 1974 nv_connector = nouveau_encoder_connector_get(nv_encoder);
1975 if (nv_connector && nv_connector->native_mode) { 1975 if (nv_connector && nv_connector->native_mode) {
1976 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) { 1976 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) {
1977 int id = adjusted_mode->base.id; 1977 int id = adjusted_mode->base.id;
1978 *adjusted_mode = *nv_connector->native_mode; 1978 *adjusted_mode = *nv_connector->native_mode;
1979 adjusted_mode->base.id = id; 1979 adjusted_mode->base.id = id;
1980 } 1980 }
1981 } 1981 }
1982 1982
1983 adjusted_mode->clock *= 2; 1983 adjusted_mode->clock *= 2;
1984 return true; 1984 return true;
1985 } 1985 }
1986 1986
1987 static void 1987 static void
1988 nv50_pior_commit(struct drm_encoder *encoder) 1988 nv50_pior_commit(struct drm_encoder *encoder)
1989 { 1989 {
1990 } 1990 }
1991 1991
1992 static void 1992 static void
1993 nv50_pior_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode, 1993 nv50_pior_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
1994 struct drm_display_mode *adjusted_mode) 1994 struct drm_display_mode *adjusted_mode)
1995 { 1995 {
1996 struct nv50_mast *mast = nv50_mast(encoder->dev); 1996 struct nv50_mast *mast = nv50_mast(encoder->dev);
1997 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 1997 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
1998 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); 1998 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
1999 struct nouveau_connector *nv_connector; 1999 struct nouveau_connector *nv_connector;
2000 u8 owner = 1 << nv_crtc->index; 2000 u8 owner = 1 << nv_crtc->index;
2001 u8 proto, depth; 2001 u8 proto, depth;
2002 u32 *push; 2002 u32 *push;
2003 2003
2004 nv_connector = nouveau_encoder_connector_get(nv_encoder); 2004 nv_connector = nouveau_encoder_connector_get(nv_encoder);
2005 switch (nv_connector->base.display_info.bpc) { 2005 switch (nv_connector->base.display_info.bpc) {
2006 case 10: depth = 0x6; break; 2006 case 10: depth = 0x6; break;
2007 case 8: depth = 0x5; break; 2007 case 8: depth = 0x5; break;
2008 case 6: depth = 0x2; break; 2008 case 6: depth = 0x2; break;
2009 default: depth = 0x0; break; 2009 default: depth = 0x0; break;
2010 } 2010 }
2011 2011
2012 switch (nv_encoder->dcb->type) { 2012 switch (nv_encoder->dcb->type) {
2013 case DCB_OUTPUT_TMDS: 2013 case DCB_OUTPUT_TMDS:
2014 case DCB_OUTPUT_DP: 2014 case DCB_OUTPUT_DP:
2015 proto = 0x0; 2015 proto = 0x0;
2016 break; 2016 break;
2017 default: 2017 default:
2018 BUG_ON(1); 2018 BUG_ON(1);
2019 break; 2019 break;
2020 } 2020 }
2021 2021
2022 nv50_pior_dpms(encoder, DRM_MODE_DPMS_ON); 2022 nv50_pior_dpms(encoder, DRM_MODE_DPMS_ON);
2023 2023
2024 push = evo_wait(mast, 8); 2024 push = evo_wait(mast, 8);
2025 if (push) { 2025 if (push) {
2026 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 2026 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
2027 u32 ctrl = (depth << 16) | (proto << 8) | owner; 2027 u32 ctrl = (depth << 16) | (proto << 8) | owner;
2028 if (mode->flags & DRM_MODE_FLAG_NHSYNC) 2028 if (mode->flags & DRM_MODE_FLAG_NHSYNC)
2029 ctrl |= 0x00001000; 2029 ctrl |= 0x00001000;
2030 if (mode->flags & DRM_MODE_FLAG_NVSYNC) 2030 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
2031 ctrl |= 0x00002000; 2031 ctrl |= 0x00002000;
2032 evo_mthd(push, 0x0700 + (nv_encoder->or * 0x040), 1); 2032 evo_mthd(push, 0x0700 + (nv_encoder->or * 0x040), 1);
2033 evo_data(push, ctrl); 2033 evo_data(push, ctrl);
2034 } 2034 }
2035 2035
2036 evo_kick(push, mast); 2036 evo_kick(push, mast);
2037 } 2037 }
2038 2038
2039 nv_encoder->crtc = encoder->crtc; 2039 nv_encoder->crtc = encoder->crtc;
2040 } 2040 }
2041 2041
2042 static void 2042 static void
2043 nv50_pior_disconnect(struct drm_encoder *encoder) 2043 nv50_pior_disconnect(struct drm_encoder *encoder)
2044 { 2044 {
2045 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); 2045 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
2046 struct nv50_mast *mast = nv50_mast(encoder->dev); 2046 struct nv50_mast *mast = nv50_mast(encoder->dev);
2047 const int or = nv_encoder->or; 2047 const int or = nv_encoder->or;
2048 u32 *push; 2048 u32 *push;
2049 2049
2050 if (nv_encoder->crtc) { 2050 if (nv_encoder->crtc) {
2051 nv50_crtc_prepare(nv_encoder->crtc); 2051 nv50_crtc_prepare(nv_encoder->crtc);
2052 2052
2053 push = evo_wait(mast, 4); 2053 push = evo_wait(mast, 4);
2054 if (push) { 2054 if (push) {
2055 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) { 2055 if (nv50_vers(mast) < NVD0_DISP_MAST_CLASS) {
2056 evo_mthd(push, 0x0700 + (or * 0x040), 1); 2056 evo_mthd(push, 0x0700 + (or * 0x040), 1);
2057 evo_data(push, 0x00000000); 2057 evo_data(push, 0x00000000);
2058 } 2058 }
2059 evo_kick(push, mast); 2059 evo_kick(push, mast);
2060 } 2060 }
2061 } 2061 }
2062 2062
2063 nv_encoder->crtc = NULL; 2063 nv_encoder->crtc = NULL;
2064 } 2064 }
2065 2065
2066 static void 2066 static void
2067 nv50_pior_destroy(struct drm_encoder *encoder) 2067 nv50_pior_destroy(struct drm_encoder *encoder)
2068 { 2068 {
2069 drm_encoder_cleanup(encoder); 2069 drm_encoder_cleanup(encoder);
2070 kfree(encoder); 2070 kfree(encoder);
2071 } 2071 }
2072 2072
2073 static const struct drm_encoder_helper_funcs nv50_pior_hfunc = { 2073 static const struct drm_encoder_helper_funcs nv50_pior_hfunc = {
2074 .dpms = nv50_pior_dpms, 2074 .dpms = nv50_pior_dpms,
2075 .mode_fixup = nv50_pior_mode_fixup, 2075 .mode_fixup = nv50_pior_mode_fixup,
2076 .prepare = nv50_pior_disconnect, 2076 .prepare = nv50_pior_disconnect,
2077 .commit = nv50_pior_commit, 2077 .commit = nv50_pior_commit,
2078 .mode_set = nv50_pior_mode_set, 2078 .mode_set = nv50_pior_mode_set,
2079 .disable = nv50_pior_disconnect, 2079 .disable = nv50_pior_disconnect,
2080 .get_crtc = nv50_display_crtc_get, 2080 .get_crtc = nv50_display_crtc_get,
2081 }; 2081 };
2082 2082
2083 static const struct drm_encoder_funcs nv50_pior_func = { 2083 static const struct drm_encoder_funcs nv50_pior_func = {
2084 .destroy = nv50_pior_destroy, 2084 .destroy = nv50_pior_destroy,
2085 }; 2085 };
2086 2086
2087 static int 2087 static int
2088 nv50_pior_create(struct drm_connector *connector, struct dcb_output *dcbe) 2088 nv50_pior_create(struct drm_connector *connector, struct dcb_output *dcbe)
2089 { 2089 {
2090 struct nouveau_drm *drm = nouveau_drm(connector->dev); 2090 struct nouveau_drm *drm = nouveau_drm(connector->dev);
2091 struct nouveau_i2c *i2c = nouveau_i2c(drm->device); 2091 struct nouveau_i2c *i2c = nouveau_i2c(drm->device);
2092 struct nouveau_i2c_port *ddc = NULL; 2092 struct nouveau_i2c_port *ddc = NULL;
2093 struct nouveau_encoder *nv_encoder; 2093 struct nouveau_encoder *nv_encoder;
2094 struct drm_encoder *encoder; 2094 struct drm_encoder *encoder;
2095 int type; 2095 int type;
2096 2096
2097 switch (dcbe->type) { 2097 switch (dcbe->type) {
2098 case DCB_OUTPUT_TMDS: 2098 case DCB_OUTPUT_TMDS:
2099 ddc = i2c->find_type(i2c, NV_I2C_TYPE_EXTDDC(dcbe->extdev)); 2099 ddc = i2c->find_type(i2c, NV_I2C_TYPE_EXTDDC(dcbe->extdev));
2100 type = DRM_MODE_ENCODER_TMDS; 2100 type = DRM_MODE_ENCODER_TMDS;
2101 break; 2101 break;
2102 case DCB_OUTPUT_DP: 2102 case DCB_OUTPUT_DP:
2103 ddc = i2c->find_type(i2c, NV_I2C_TYPE_EXTAUX(dcbe->extdev)); 2103 ddc = i2c->find_type(i2c, NV_I2C_TYPE_EXTAUX(dcbe->extdev));
2104 type = DRM_MODE_ENCODER_TMDS; 2104 type = DRM_MODE_ENCODER_TMDS;
2105 break; 2105 break;
2106 default: 2106 default:
2107 return -ENODEV; 2107 return -ENODEV;
2108 } 2108 }
2109 2109
2110 nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL); 2110 nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL);
2111 if (!nv_encoder) 2111 if (!nv_encoder)
2112 return -ENOMEM; 2112 return -ENOMEM;
2113 nv_encoder->dcb = dcbe; 2113 nv_encoder->dcb = dcbe;
2114 nv_encoder->or = ffs(dcbe->or) - 1; 2114 nv_encoder->or = ffs(dcbe->or) - 1;
2115 nv_encoder->i2c = ddc; 2115 nv_encoder->i2c = ddc;
2116 2116
2117 encoder = to_drm_encoder(nv_encoder); 2117 encoder = to_drm_encoder(nv_encoder);
2118 encoder->possible_crtcs = dcbe->heads; 2118 encoder->possible_crtcs = dcbe->heads;
2119 encoder->possible_clones = 0; 2119 encoder->possible_clones = 0;
2120 drm_encoder_init(connector->dev, encoder, &nv50_pior_func, type); 2120 drm_encoder_init(connector->dev, encoder, &nv50_pior_func, type);
2121 drm_encoder_helper_add(encoder, &nv50_pior_hfunc); 2121 drm_encoder_helper_add(encoder, &nv50_pior_hfunc);
2122 2122
2123 drm_mode_connector_attach_encoder(connector, encoder); 2123 drm_mode_connector_attach_encoder(connector, encoder);
2124 return 0; 2124 return 0;
2125 } 2125 }
2126 2126
2127 /****************************************************************************** 2127 /******************************************************************************
2128 * Init 2128 * Init
2129 *****************************************************************************/ 2129 *****************************************************************************/
2130 void 2130 void
2131 nv50_display_fini(struct drm_device *dev) 2131 nv50_display_fini(struct drm_device *dev)
2132 { 2132 {
2133 } 2133 }
2134 2134
2135 int 2135 int
2136 nv50_display_init(struct drm_device *dev) 2136 nv50_display_init(struct drm_device *dev)
2137 { 2137 {
2138 struct nv50_disp *disp = nv50_disp(dev); 2138 struct nv50_disp *disp = nv50_disp(dev);
2139 struct drm_crtc *crtc; 2139 struct drm_crtc *crtc;
2140 u32 *push; 2140 u32 *push;
2141 2141
2142 push = evo_wait(nv50_mast(dev), 32); 2142 push = evo_wait(nv50_mast(dev), 32);
2143 if (!push) 2143 if (!push)
2144 return -EBUSY; 2144 return -EBUSY;
2145 2145
2146 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 2146 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
2147 struct nv50_sync *sync = nv50_sync(crtc); 2147 struct nv50_sync *sync = nv50_sync(crtc);
2148 nouveau_bo_wr32(disp->sync, sync->addr / 4, sync->data); 2148 nouveau_bo_wr32(disp->sync, sync->addr / 4, sync->data);
2149 } 2149 }
2150 2150
2151 evo_mthd(push, 0x0088, 1); 2151 evo_mthd(push, 0x0088, 1);
2152 evo_data(push, NvEvoSync); 2152 evo_data(push, NvEvoSync);
2153 evo_kick(push, nv50_mast(dev)); 2153 evo_kick(push, nv50_mast(dev));
2154 return 0; 2154 return 0;
2155 } 2155 }
2156 2156
2157 void 2157 void
2158 nv50_display_destroy(struct drm_device *dev) 2158 nv50_display_destroy(struct drm_device *dev)
2159 { 2159 {
2160 struct nv50_disp *disp = nv50_disp(dev); 2160 struct nv50_disp *disp = nv50_disp(dev);
2161 2161
2162 nv50_dmac_destroy(disp->core, &disp->mast.base); 2162 nv50_dmac_destroy(disp->core, &disp->mast.base);
2163 2163
2164 nouveau_bo_unmap(disp->sync); 2164 nouveau_bo_unmap(disp->sync);
2165 if (disp->sync) 2165 if (disp->sync)
2166 nouveau_bo_unpin(disp->sync); 2166 nouveau_bo_unpin(disp->sync);
2167 nouveau_bo_ref(NULL, &disp->sync); 2167 nouveau_bo_ref(NULL, &disp->sync);
2168 2168
2169 nouveau_display(dev)->priv = NULL; 2169 nouveau_display(dev)->priv = NULL;
2170 kfree(disp); 2170 kfree(disp);
2171 } 2171 }
2172 2172
2173 int 2173 int
2174 nv50_display_create(struct drm_device *dev) 2174 nv50_display_create(struct drm_device *dev)
2175 { 2175 {
2176 static const u16 oclass[] = { 2176 static const u16 oclass[] = {
2177 NVF0_DISP_CLASS,
2177 NVE0_DISP_CLASS, 2178 NVE0_DISP_CLASS,
2178 NVD0_DISP_CLASS, 2179 NVD0_DISP_CLASS,
2179 NVA3_DISP_CLASS, 2180 NVA3_DISP_CLASS,
2180 NV94_DISP_CLASS, 2181 NV94_DISP_CLASS,
2181 NVA0_DISP_CLASS, 2182 NVA0_DISP_CLASS,
2182 NV84_DISP_CLASS, 2183 NV84_DISP_CLASS,
2183 NV50_DISP_CLASS, 2184 NV50_DISP_CLASS,
2184 }; 2185 };
2185 struct nouveau_device *device = nouveau_dev(dev); 2186 struct nouveau_device *device = nouveau_dev(dev);
2186 struct nouveau_drm *drm = nouveau_drm(dev); 2187 struct nouveau_drm *drm = nouveau_drm(dev);
2187 struct dcb_table *dcb = &drm->vbios.dcb; 2188 struct dcb_table *dcb = &drm->vbios.dcb;
2188 struct drm_connector *connector, *tmp; 2189 struct drm_connector *connector, *tmp;
2189 struct nv50_disp *disp; 2190 struct nv50_disp *disp;
2190 struct dcb_output *dcbe; 2191 struct dcb_output *dcbe;
2191 int crtcs, ret, i; 2192 int crtcs, ret, i;
2192 2193
2193 disp = kzalloc(sizeof(*disp), GFP_KERNEL); 2194 disp = kzalloc(sizeof(*disp), GFP_KERNEL);
2194 if (!disp) 2195 if (!disp)
2195 return -ENOMEM; 2196 return -ENOMEM;
2196 2197
2197 nouveau_display(dev)->priv = disp; 2198 nouveau_display(dev)->priv = disp;
2198 nouveau_display(dev)->dtor = nv50_display_destroy; 2199 nouveau_display(dev)->dtor = nv50_display_destroy;
2199 nouveau_display(dev)->init = nv50_display_init; 2200 nouveau_display(dev)->init = nv50_display_init;
2200 nouveau_display(dev)->fini = nv50_display_fini; 2201 nouveau_display(dev)->fini = nv50_display_fini;
2201 2202
2202 /* small shared memory area we use for notifiers and semaphores */ 2203 /* small shared memory area we use for notifiers and semaphores */
2203 ret = nouveau_bo_new(dev, 4096, 0x1000, TTM_PL_FLAG_VRAM, 2204 ret = nouveau_bo_new(dev, 4096, 0x1000, TTM_PL_FLAG_VRAM,
2204 0, 0x0000, NULL, &disp->sync); 2205 0, 0x0000, NULL, &disp->sync);
2205 if (!ret) { 2206 if (!ret) {
2206 ret = nouveau_bo_pin(disp->sync, TTM_PL_FLAG_VRAM); 2207 ret = nouveau_bo_pin(disp->sync, TTM_PL_FLAG_VRAM);
2207 if (!ret) { 2208 if (!ret) {
2208 ret = nouveau_bo_map(disp->sync); 2209 ret = nouveau_bo_map(disp->sync);
2209 if (ret) 2210 if (ret)
2210 nouveau_bo_unpin(disp->sync); 2211 nouveau_bo_unpin(disp->sync);
2211 } 2212 }
2212 if (ret) 2213 if (ret)
2213 nouveau_bo_ref(NULL, &disp->sync); 2214 nouveau_bo_ref(NULL, &disp->sync);
2214 } 2215 }
2215 2216
2216 if (ret) 2217 if (ret)
2217 goto out; 2218 goto out;
2218 2219
2219 /* attempt to allocate a supported evo display class */ 2220 /* attempt to allocate a supported evo display class */
2220 ret = -ENODEV; 2221 ret = -ENODEV;
2221 for (i = 0; ret && i < ARRAY_SIZE(oclass); i++) { 2222 for (i = 0; ret && i < ARRAY_SIZE(oclass); i++) {
2222 ret = nouveau_object_new(nv_object(drm), NVDRM_DEVICE, 2223 ret = nouveau_object_new(nv_object(drm), NVDRM_DEVICE,
2223 0xd1500000, oclass[i], NULL, 0, 2224 0xd1500000, oclass[i], NULL, 0,
2224 &disp->core); 2225 &disp->core);
2225 } 2226 }
2226 2227
2227 if (ret) 2228 if (ret)
2228 goto out; 2229 goto out;
2229 2230
2230 /* allocate master evo channel */ 2231 /* allocate master evo channel */
2231 ret = nv50_dmac_create(disp->core, NV50_DISP_MAST_CLASS, 0, 2232 ret = nv50_dmac_create(disp->core, NV50_DISP_MAST_CLASS, 0,
2232 &(struct nv50_display_mast_class) { 2233 &(struct nv50_display_mast_class) {
2233 .pushbuf = EVO_PUSH_HANDLE(MAST, 0), 2234 .pushbuf = EVO_PUSH_HANDLE(MAST, 0),
2234 }, sizeof(struct nv50_display_mast_class), 2235 }, sizeof(struct nv50_display_mast_class),
2235 disp->sync->bo.offset, &disp->mast.base); 2236 disp->sync->bo.offset, &disp->mast.base);
2236 if (ret) 2237 if (ret)
2237 goto out; 2238 goto out;
2238 2239
2239 /* create crtc objects to represent the hw heads */ 2240 /* create crtc objects to represent the hw heads */
2240 if (nv_mclass(disp->core) >= NVD0_DISP_CLASS) 2241 if (nv_mclass(disp->core) >= NVD0_DISP_CLASS)
2241 crtcs = nv_rd32(device, 0x022448); 2242 crtcs = nv_rd32(device, 0x022448);
2242 else 2243 else
2243 crtcs = 2; 2244 crtcs = 2;
2244 2245
2245 for (i = 0; i < crtcs; i++) { 2246 for (i = 0; i < crtcs; i++) {
2246 ret = nv50_crtc_create(dev, disp->core, i); 2247 ret = nv50_crtc_create(dev, disp->core, i);
2247 if (ret) 2248 if (ret)
2248 goto out; 2249 goto out;
2249 } 2250 }
2250 2251
2251 /* create encoder/connector objects based on VBIOS DCB table */ 2252 /* create encoder/connector objects based on VBIOS DCB table */
2252 for (i = 0, dcbe = &dcb->entry[0]; i < dcb->entries; i++, dcbe++) { 2253 for (i = 0, dcbe = &dcb->entry[0]; i < dcb->entries; i++, dcbe++) {
2253 connector = nouveau_connector_create(dev, dcbe->connector); 2254 connector = nouveau_connector_create(dev, dcbe->connector);
2254 if (IS_ERR(connector)) 2255 if (IS_ERR(connector))
2255 continue; 2256 continue;
2256 2257
2257 if (dcbe->location == DCB_LOC_ON_CHIP) { 2258 if (dcbe->location == DCB_LOC_ON_CHIP) {
2258 switch (dcbe->type) { 2259 switch (dcbe->type) {
2259 case DCB_OUTPUT_TMDS: 2260 case DCB_OUTPUT_TMDS:
2260 case DCB_OUTPUT_LVDS: 2261 case DCB_OUTPUT_LVDS:
2261 case DCB_OUTPUT_DP: 2262 case DCB_OUTPUT_DP:
2262 ret = nv50_sor_create(connector, dcbe); 2263 ret = nv50_sor_create(connector, dcbe);
2263 break; 2264 break;
2264 case DCB_OUTPUT_ANALOG: 2265 case DCB_OUTPUT_ANALOG:
2265 ret = nv50_dac_create(connector, dcbe); 2266 ret = nv50_dac_create(connector, dcbe);
2266 break; 2267 break;
2267 default: 2268 default:
2268 ret = -ENODEV; 2269 ret = -ENODEV;
2269 break; 2270 break;
2270 } 2271 }
2271 } else { 2272 } else {
2272 ret = nv50_pior_create(connector, dcbe); 2273 ret = nv50_pior_create(connector, dcbe);
2273 } 2274 }
2274 2275
2275 if (ret) { 2276 if (ret) {
2276 NV_WARN(drm, "failed to create encoder %d/%d/%d: %d\n", 2277 NV_WARN(drm, "failed to create encoder %d/%d/%d: %d\n",
2277 dcbe->location, dcbe->type, 2278 dcbe->location, dcbe->type,
2278 ffs(dcbe->or) - 1, ret); 2279 ffs(dcbe->or) - 1, ret);
2279 ret = 0; 2280 ret = 0;
2280 } 2281 }
2281 } 2282 }
2282 2283
2283 /* cull any connectors we created that don't have an encoder */ 2284 /* cull any connectors we created that don't have an encoder */
2284 list_for_each_entry_safe(connector, tmp, &dev->mode_config.connector_list, head) { 2285 list_for_each_entry_safe(connector, tmp, &dev->mode_config.connector_list, head) {
2285 if (connector->encoder_ids[0]) 2286 if (connector->encoder_ids[0])
2286 continue; 2287 continue;
2287 2288
2288 NV_WARN(drm, "%s has no encoders, removing\n", 2289 NV_WARN(drm, "%s has no encoders, removing\n",
2289 drm_get_connector_name(connector)); 2290 drm_get_connector_name(connector));
2290 connector->funcs->destroy(connector); 2291 connector->funcs->destroy(connector);
2291 } 2292 }
2292 2293
2293 out: 2294 out:
2294 if (ret) 2295 if (ret)
2295 nv50_display_destroy(dev); 2296 nv50_display_destroy(dev);
2296 return ret; 2297 return ret;
2297 } 2298 }
2298 2299