diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2012-07-31 02:16:21 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2012-10-02 23:12:59 -0400 |
commit | 77145f1cbdf8d28b46ff8070ca749bad821e0774 (patch) | |
tree | b496d5d69ce4f5753028b07b09d8cf12025310f2 /drivers/gpu/drm/nouveau/nouveau_hw.h | |
parent | 2094dd82eddc468b53ee99d92c38b23a65efac03 (diff) |
drm/nouveau: port remainder of drm code, and rip out compat layer
v2: Ben Skeggs <bskeggs@redhat.com>
- fill in nouveau_pm.dev to prevent oops
- fix ppc issues (build + OF shadow)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nouveau_hw.h')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_hw.h | 88 |
1 files changed, 50 insertions, 38 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_hw.h b/drivers/gpu/drm/nouveau/nouveau_hw.h index b1c22b788be8..ba8fc0f9e0db 100644 --- a/drivers/gpu/drm/nouveau/nouveau_hw.h +++ b/drivers/gpu/drm/nouveau/nouveau_hw.h | |||
@@ -24,7 +24,6 @@ | |||
24 | #define __NOUVEAU_HW_H__ | 24 | #define __NOUVEAU_HW_H__ |
25 | 25 | ||
26 | #include "drmP.h" | 26 | #include "drmP.h" |
27 | #include "nouveau_drv.h" | ||
28 | #include "nv04_display.h" | 27 | #include "nv04_display.h" |
29 | 28 | ||
30 | #include <subdev/bios/pll.h> | 29 | #include <subdev/bios/pll.h> |
@@ -60,37 +59,41 @@ extern void nouveau_calc_arb(struct drm_device *, int vclk, int bpp, | |||
60 | static inline uint32_t NVReadCRTC(struct drm_device *dev, | 59 | static inline uint32_t NVReadCRTC(struct drm_device *dev, |
61 | int head, uint32_t reg) | 60 | int head, uint32_t reg) |
62 | { | 61 | { |
62 | struct nouveau_device *device = nouveau_dev(dev); | ||
63 | uint32_t val; | 63 | uint32_t val; |
64 | if (head) | 64 | if (head) |
65 | reg += NV_PCRTC0_SIZE; | 65 | reg += NV_PCRTC0_SIZE; |
66 | val = nv_rd32(dev, reg); | 66 | val = nv_rd32(device, reg); |
67 | return val; | 67 | return val; |
68 | } | 68 | } |
69 | 69 | ||
70 | static inline void NVWriteCRTC(struct drm_device *dev, | 70 | static inline void NVWriteCRTC(struct drm_device *dev, |
71 | int head, uint32_t reg, uint32_t val) | 71 | int head, uint32_t reg, uint32_t val) |
72 | { | 72 | { |
73 | struct nouveau_device *device = nouveau_dev(dev); | ||
73 | if (head) | 74 | if (head) |
74 | reg += NV_PCRTC0_SIZE; | 75 | reg += NV_PCRTC0_SIZE; |
75 | nv_wr32(dev, reg, val); | 76 | nv_wr32(device, reg, val); |
76 | } | 77 | } |
77 | 78 | ||
78 | static inline uint32_t NVReadRAMDAC(struct drm_device *dev, | 79 | static inline uint32_t NVReadRAMDAC(struct drm_device *dev, |
79 | int head, uint32_t reg) | 80 | int head, uint32_t reg) |
80 | { | 81 | { |
82 | struct nouveau_device *device = nouveau_dev(dev); | ||
81 | uint32_t val; | 83 | uint32_t val; |
82 | if (head) | 84 | if (head) |
83 | reg += NV_PRAMDAC0_SIZE; | 85 | reg += NV_PRAMDAC0_SIZE; |
84 | val = nv_rd32(dev, reg); | 86 | val = nv_rd32(device, reg); |
85 | return val; | 87 | return val; |
86 | } | 88 | } |
87 | 89 | ||
88 | static inline void NVWriteRAMDAC(struct drm_device *dev, | 90 | static inline void NVWriteRAMDAC(struct drm_device *dev, |
89 | int head, uint32_t reg, uint32_t val) | 91 | int head, uint32_t reg, uint32_t val) |
90 | { | 92 | { |
93 | struct nouveau_device *device = nouveau_dev(dev); | ||
91 | if (head) | 94 | if (head) |
92 | reg += NV_PRAMDAC0_SIZE; | 95 | reg += NV_PRAMDAC0_SIZE; |
93 | nv_wr32(dev, reg, val); | 96 | nv_wr32(device, reg, val); |
94 | } | 97 | } |
95 | 98 | ||
96 | static inline uint8_t nv_read_tmds(struct drm_device *dev, | 99 | static inline uint8_t nv_read_tmds(struct drm_device *dev, |
@@ -116,16 +119,18 @@ static inline void nv_write_tmds(struct drm_device *dev, | |||
116 | static inline void NVWriteVgaCrtc(struct drm_device *dev, | 119 | static inline void NVWriteVgaCrtc(struct drm_device *dev, |
117 | int head, uint8_t index, uint8_t value) | 120 | int head, uint8_t index, uint8_t value) |
118 | { | 121 | { |
119 | nv_wr08(dev, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); | 122 | struct nouveau_device *device = nouveau_dev(dev); |
120 | nv_wr08(dev, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE, value); | 123 | nv_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); |
124 | nv_wr08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE, value); | ||
121 | } | 125 | } |
122 | 126 | ||
123 | static inline uint8_t NVReadVgaCrtc(struct drm_device *dev, | 127 | static inline uint8_t NVReadVgaCrtc(struct drm_device *dev, |
124 | int head, uint8_t index) | 128 | int head, uint8_t index) |
125 | { | 129 | { |
130 | struct nouveau_device *device = nouveau_dev(dev); | ||
126 | uint8_t val; | 131 | uint8_t val; |
127 | nv_wr08(dev, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); | 132 | nv_wr08(device, NV_PRMCIO_CRX__COLOR + head * NV_PRMCIO_SIZE, index); |
128 | val = nv_rd08(dev, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE); | 133 | val = nv_rd08(device, NV_PRMCIO_CR__COLOR + head * NV_PRMCIO_SIZE); |
129 | return val; | 134 | return val; |
130 | } | 135 | } |
131 | 136 | ||
@@ -159,68 +164,74 @@ static inline uint8_t NVReadVgaCrtc5758(struct drm_device *dev, int head, uint8_ | |||
159 | static inline uint8_t NVReadPRMVIO(struct drm_device *dev, | 164 | static inline uint8_t NVReadPRMVIO(struct drm_device *dev, |
160 | int head, uint32_t reg) | 165 | int head, uint32_t reg) |
161 | { | 166 | { |
162 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 167 | struct nouveau_device *device = nouveau_dev(dev); |
168 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
163 | uint8_t val; | 169 | uint8_t val; |
164 | 170 | ||
165 | /* Only NV4x have two pvio ranges; other twoHeads cards MUST call | 171 | /* Only NV4x have two pvio ranges; other twoHeads cards MUST call |
166 | * NVSetOwner for the relevant head to be programmed */ | 172 | * NVSetOwner for the relevant head to be programmed */ |
167 | if (head && dev_priv->card_type == NV_40) | 173 | if (head && nv_device(drm->device)->card_type == NV_40) |
168 | reg += NV_PRMVIO_SIZE; | 174 | reg += NV_PRMVIO_SIZE; |
169 | 175 | ||
170 | val = nv_rd08(dev, reg); | 176 | val = nv_rd08(device, reg); |
171 | return val; | 177 | return val; |
172 | } | 178 | } |
173 | 179 | ||
174 | static inline void NVWritePRMVIO(struct drm_device *dev, | 180 | static inline void NVWritePRMVIO(struct drm_device *dev, |
175 | int head, uint32_t reg, uint8_t value) | 181 | int head, uint32_t reg, uint8_t value) |
176 | { | 182 | { |
177 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 183 | struct nouveau_device *device = nouveau_dev(dev); |
184 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
178 | 185 | ||
179 | /* Only NV4x have two pvio ranges; other twoHeads cards MUST call | 186 | /* Only NV4x have two pvio ranges; other twoHeads cards MUST call |
180 | * NVSetOwner for the relevant head to be programmed */ | 187 | * NVSetOwner for the relevant head to be programmed */ |
181 | if (head && dev_priv->card_type == NV_40) | 188 | if (head && nv_device(drm->device)->card_type == NV_40) |
182 | reg += NV_PRMVIO_SIZE; | 189 | reg += NV_PRMVIO_SIZE; |
183 | 190 | ||
184 | nv_wr08(dev, reg, value); | 191 | nv_wr08(device, reg, value); |
185 | } | 192 | } |
186 | 193 | ||
187 | static inline void NVSetEnablePalette(struct drm_device *dev, int head, bool enable) | 194 | static inline void NVSetEnablePalette(struct drm_device *dev, int head, bool enable) |
188 | { | 195 | { |
189 | nv_rd08(dev, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); | 196 | struct nouveau_device *device = nouveau_dev(dev); |
190 | nv_wr08(dev, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, enable ? 0 : 0x20); | 197 | nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); |
198 | nv_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, enable ? 0 : 0x20); | ||
191 | } | 199 | } |
192 | 200 | ||
193 | static inline bool NVGetEnablePalette(struct drm_device *dev, int head) | 201 | static inline bool NVGetEnablePalette(struct drm_device *dev, int head) |
194 | { | 202 | { |
195 | nv_rd08(dev, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); | 203 | struct nouveau_device *device = nouveau_dev(dev); |
196 | return !(nv_rd08(dev, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE) & 0x20); | 204 | nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); |
205 | return !(nv_rd08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE) & 0x20); | ||
197 | } | 206 | } |
198 | 207 | ||
199 | static inline void NVWriteVgaAttr(struct drm_device *dev, | 208 | static inline void NVWriteVgaAttr(struct drm_device *dev, |
200 | int head, uint8_t index, uint8_t value) | 209 | int head, uint8_t index, uint8_t value) |
201 | { | 210 | { |
211 | struct nouveau_device *device = nouveau_dev(dev); | ||
202 | if (NVGetEnablePalette(dev, head)) | 212 | if (NVGetEnablePalette(dev, head)) |
203 | index &= ~0x20; | 213 | index &= ~0x20; |
204 | else | 214 | else |
205 | index |= 0x20; | 215 | index |= 0x20; |
206 | 216 | ||
207 | nv_rd08(dev, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); | 217 | nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); |
208 | nv_wr08(dev, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index); | 218 | nv_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index); |
209 | nv_wr08(dev, NV_PRMCIO_AR__WRITE + head * NV_PRMCIO_SIZE, value); | 219 | nv_wr08(device, NV_PRMCIO_AR__WRITE + head * NV_PRMCIO_SIZE, value); |
210 | } | 220 | } |
211 | 221 | ||
212 | static inline uint8_t NVReadVgaAttr(struct drm_device *dev, | 222 | static inline uint8_t NVReadVgaAttr(struct drm_device *dev, |
213 | int head, uint8_t index) | 223 | int head, uint8_t index) |
214 | { | 224 | { |
225 | struct nouveau_device *device = nouveau_dev(dev); | ||
215 | uint8_t val; | 226 | uint8_t val; |
216 | if (NVGetEnablePalette(dev, head)) | 227 | if (NVGetEnablePalette(dev, head)) |
217 | index &= ~0x20; | 228 | index &= ~0x20; |
218 | else | 229 | else |
219 | index |= 0x20; | 230 | index |= 0x20; |
220 | 231 | ||
221 | nv_rd08(dev, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); | 232 | nv_rd08(device, NV_PRMCIO_INP0__COLOR + head * NV_PRMCIO_SIZE); |
222 | nv_wr08(dev, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index); | 233 | nv_wr08(device, NV_PRMCIO_ARX + head * NV_PRMCIO_SIZE, index); |
223 | val = nv_rd08(dev, NV_PRMCIO_AR__READ + head * NV_PRMCIO_SIZE); | 234 | val = nv_rd08(device, NV_PRMCIO_AR__READ + head * NV_PRMCIO_SIZE); |
224 | return val; | 235 | return val; |
225 | } | 236 | } |
226 | 237 | ||
@@ -247,10 +258,11 @@ static inline void NVVgaProtect(struct drm_device *dev, int head, bool protect) | |||
247 | static inline bool | 258 | static inline bool |
248 | nv_heads_tied(struct drm_device *dev) | 259 | nv_heads_tied(struct drm_device *dev) |
249 | { | 260 | { |
250 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 261 | struct nouveau_device *device = nouveau_dev(dev); |
262 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
251 | 263 | ||
252 | if (dev_priv->chipset == 0x11) | 264 | if (nv_device(drm->device)->chipset == 0x11) |
253 | return !!(nv_rd32(dev, NV_PBUS_DEBUG_1) & (1 << 28)); | 265 | return !!(nv_rd32(device, NV_PBUS_DEBUG_1) & (1 << 28)); |
254 | 266 | ||
255 | return NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44) & 0x4; | 267 | return NVReadVgaCrtc(dev, 0, NV_CIO_CRE_44) & 0x4; |
256 | } | 268 | } |
@@ -299,13 +311,13 @@ nv_lock_vga_crtc_shadow(struct drm_device *dev, int head, int lock) | |||
299 | static inline bool | 311 | static inline bool |
300 | NVLockVgaCrtcs(struct drm_device *dev, bool lock) | 312 | NVLockVgaCrtcs(struct drm_device *dev, bool lock) |
301 | { | 313 | { |
302 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 314 | struct nouveau_drm *drm = nouveau_drm(dev); |
303 | bool waslocked = !NVReadVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX); | 315 | bool waslocked = !NVReadVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX); |
304 | 316 | ||
305 | NVWriteVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX, | 317 | NVWriteVgaCrtc(dev, 0, NV_CIO_SR_LOCK_INDEX, |
306 | lock ? NV_CIO_SR_LOCK_VALUE : NV_CIO_SR_UNLOCK_RW_VALUE); | 318 | lock ? NV_CIO_SR_LOCK_VALUE : NV_CIO_SR_UNLOCK_RW_VALUE); |
307 | /* NV11 has independently lockable extended crtcs, except when tied */ | 319 | /* NV11 has independently lockable extended crtcs, except when tied */ |
308 | if (dev_priv->chipset == 0x11 && !nv_heads_tied(dev)) | 320 | if (nv_device(drm->device)->chipset == 0x11 && !nv_heads_tied(dev)) |
309 | NVWriteVgaCrtc(dev, 1, NV_CIO_SR_LOCK_INDEX, | 321 | NVWriteVgaCrtc(dev, 1, NV_CIO_SR_LOCK_INDEX, |
310 | lock ? NV_CIO_SR_LOCK_VALUE : | 322 | lock ? NV_CIO_SR_LOCK_VALUE : |
311 | NV_CIO_SR_UNLOCK_RW_VALUE); | 323 | NV_CIO_SR_UNLOCK_RW_VALUE); |
@@ -320,9 +332,9 @@ NVLockVgaCrtcs(struct drm_device *dev, bool lock) | |||
320 | 332 | ||
321 | static inline int nv_cursor_width(struct drm_device *dev) | 333 | static inline int nv_cursor_width(struct drm_device *dev) |
322 | { | 334 | { |
323 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 335 | struct nouveau_drm *drm = nouveau_drm(dev); |
324 | 336 | ||
325 | return dev_priv->card_type >= NV_10 ? NV10_CURSOR_SIZE : NV04_CURSOR_SIZE; | 337 | return nv_device(drm->device)->card_type >= NV_10 ? NV10_CURSOR_SIZE : NV04_CURSOR_SIZE; |
326 | } | 338 | } |
327 | 339 | ||
328 | static inline void | 340 | static inline void |
@@ -340,11 +352,11 @@ nv_fix_nv40_hw_cursor(struct drm_device *dev, int head) | |||
340 | static inline void | 352 | static inline void |
341 | nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset) | 353 | nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset) |
342 | { | 354 | { |
343 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 355 | struct nouveau_drm *drm = nouveau_drm(dev); |
344 | 356 | ||
345 | NVWriteCRTC(dev, head, NV_PCRTC_START, offset); | 357 | NVWriteCRTC(dev, head, NV_PCRTC_START, offset); |
346 | 358 | ||
347 | if (dev_priv->card_type == NV_04) { | 359 | if (nv_device(drm->device)->card_type == NV_04) { |
348 | /* | 360 | /* |
349 | * Hilarious, the 24th bit doesn't want to stick to | 361 | * Hilarious, the 24th bit doesn't want to stick to |
350 | * PCRTC_START... | 362 | * PCRTC_START... |
@@ -359,7 +371,7 @@ nv_set_crtc_base(struct drm_device *dev, int head, uint32_t offset) | |||
359 | static inline void | 371 | static inline void |
360 | nv_show_cursor(struct drm_device *dev, int head, bool show) | 372 | nv_show_cursor(struct drm_device *dev, int head, bool show) |
361 | { | 373 | { |
362 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 374 | struct nouveau_drm *drm = nouveau_drm(dev); |
363 | uint8_t *curctl1 = | 375 | uint8_t *curctl1 = |
364 | &nv04_display(dev)->mode_reg.crtc_reg[head].CRTC[NV_CIO_CRE_HCUR_ADDR1_INDEX]; | 376 | &nv04_display(dev)->mode_reg.crtc_reg[head].CRTC[NV_CIO_CRE_HCUR_ADDR1_INDEX]; |
365 | 377 | ||
@@ -369,14 +381,14 @@ nv_show_cursor(struct drm_device *dev, int head, bool show) | |||
369 | *curctl1 &= ~MASK(NV_CIO_CRE_HCUR_ADDR1_ENABLE); | 381 | *curctl1 &= ~MASK(NV_CIO_CRE_HCUR_ADDR1_ENABLE); |
370 | NVWriteVgaCrtc(dev, head, NV_CIO_CRE_HCUR_ADDR1_INDEX, *curctl1); | 382 | NVWriteVgaCrtc(dev, head, NV_CIO_CRE_HCUR_ADDR1_INDEX, *curctl1); |
371 | 383 | ||
372 | if (dev_priv->card_type == NV_40) | 384 | if (nv_device(drm->device)->card_type == NV_40) |
373 | nv_fix_nv40_hw_cursor(dev, head); | 385 | nv_fix_nv40_hw_cursor(dev, head); |
374 | } | 386 | } |
375 | 387 | ||
376 | static inline uint32_t | 388 | static inline uint32_t |
377 | nv_pitch_align(struct drm_device *dev, uint32_t width, int bpp) | 389 | nv_pitch_align(struct drm_device *dev, uint32_t width, int bpp) |
378 | { | 390 | { |
379 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 391 | struct nouveau_drm *drm = nouveau_drm(dev); |
380 | int mask; | 392 | int mask; |
381 | 393 | ||
382 | if (bpp == 15) | 394 | if (bpp == 15) |
@@ -385,7 +397,7 @@ nv_pitch_align(struct drm_device *dev, uint32_t width, int bpp) | |||
385 | bpp = 8; | 397 | bpp = 8; |
386 | 398 | ||
387 | /* Alignment requirements taken from the Haiku driver */ | 399 | /* Alignment requirements taken from the Haiku driver */ |
388 | if (dev_priv->card_type == NV_04) | 400 | if (nv_device(drm->device)->card_type == NV_04) |
389 | mask = 128 / bpp - 1; | 401 | mask = 128 / bpp - 1; |
390 | else | 402 | else |
391 | mask = 512 / bpp - 1; | 403 | mask = 512 / bpp - 1; |