diff options
Diffstat (limited to 'drivers/gpu/drm/nouveau/nv04_crtc.c')
-rw-r--r-- | drivers/gpu/drm/nouveau/nv04_crtc.c | 142 |
1 files changed, 74 insertions, 68 deletions
diff --git a/drivers/gpu/drm/nouveau/nv04_crtc.c b/drivers/gpu/drm/nouveau/nv04_crtc.c index 37d5b5bf7587..82a0d9c6cda3 100644 --- a/drivers/gpu/drm/nouveau/nv04_crtc.c +++ b/drivers/gpu/drm/nouveau/nv04_crtc.c | |||
@@ -26,14 +26,20 @@ | |||
26 | #include <drm/drmP.h> | 26 | #include <drm/drmP.h> |
27 | #include <drm/drm_crtc_helper.h> | 27 | #include <drm/drm_crtc_helper.h> |
28 | 28 | ||
29 | #include "nouveau_drv.h" | 29 | #include "nouveau_drm.h" |
30 | #include "nouveau_reg.h" | ||
31 | #include "nouveau_bo.h" | ||
32 | #include "nouveau_gem.h" | ||
30 | #include "nouveau_encoder.h" | 33 | #include "nouveau_encoder.h" |
31 | #include "nouveau_connector.h" | 34 | #include "nouveau_connector.h" |
32 | #include "nouveau_crtc.h" | 35 | #include "nouveau_crtc.h" |
33 | #include "nouveau_fb.h" | ||
34 | #include "nouveau_hw.h" | 36 | #include "nouveau_hw.h" |
35 | #include "nvreg.h" | 37 | #include "nvreg.h" |
36 | #include "nouveau_fbcon.h" | 38 | #include "nouveau_fbcon.h" |
39 | #include "nv04_display.h" | ||
40 | |||
41 | #include <subdev/bios/pll.h> | ||
42 | #include <subdev/clock.h> | ||
37 | 43 | ||
38 | static int | 44 | static int |
39 | nv04_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, | 45 | nv04_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, |
@@ -49,8 +55,8 @@ crtc_wr_cio_state(struct drm_crtc *crtc, struct nv04_crtc_reg *crtcstate, int in | |||
49 | static void nv_crtc_set_digital_vibrance(struct drm_crtc *crtc, int level) | 55 | static void nv_crtc_set_digital_vibrance(struct drm_crtc *crtc, int level) |
50 | { | 56 | { |
51 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 57 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
52 | struct drm_nouveau_private *dev_priv = crtc->dev->dev_private; | 58 | struct drm_device *dev = crtc->dev; |
53 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 59 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
54 | 60 | ||
55 | regp->CRTC[NV_CIO_CRE_CSB] = nv_crtc->saturation = level; | 61 | regp->CRTC[NV_CIO_CRE_CSB] = nv_crtc->saturation = level; |
56 | if (nv_crtc->saturation && nv_gf4_disp_arch(crtc->dev)) { | 62 | if (nv_crtc->saturation && nv_gf4_disp_arch(crtc->dev)) { |
@@ -64,8 +70,8 @@ static void nv_crtc_set_digital_vibrance(struct drm_crtc *crtc, int level) | |||
64 | static void nv_crtc_set_image_sharpening(struct drm_crtc *crtc, int level) | 70 | static void nv_crtc_set_image_sharpening(struct drm_crtc *crtc, int level) |
65 | { | 71 | { |
66 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 72 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
67 | struct drm_nouveau_private *dev_priv = crtc->dev->dev_private; | 73 | struct drm_device *dev = crtc->dev; |
68 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 74 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
69 | 75 | ||
70 | nv_crtc->sharpness = level; | 76 | nv_crtc->sharpness = level; |
71 | if (level < 0) /* blur is in hw range 0x3f -> 0x20 */ | 77 | if (level < 0) /* blur is in hw range 0x3f -> 0x20 */ |
@@ -103,14 +109,17 @@ static void nv_crtc_set_image_sharpening(struct drm_crtc *crtc, int level) | |||
103 | static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mode * mode, int dot_clock) | 109 | static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mode * mode, int dot_clock) |
104 | { | 110 | { |
105 | struct drm_device *dev = crtc->dev; | 111 | struct drm_device *dev = crtc->dev; |
106 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 112 | struct nouveau_drm *drm = nouveau_drm(dev); |
113 | struct nouveau_bios *bios = nouveau_bios(drm->device); | ||
114 | struct nouveau_clock *clk = nouveau_clock(drm->device); | ||
107 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 115 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
108 | struct nv04_mode_state *state = &dev_priv->mode_reg; | 116 | struct nv04_mode_state *state = &nv04_display(dev)->mode_reg; |
109 | struct nv04_crtc_reg *regp = &state->crtc_reg[nv_crtc->index]; | 117 | struct nv04_crtc_reg *regp = &state->crtc_reg[nv_crtc->index]; |
110 | struct nouveau_pll_vals *pv = ®p->pllvals; | 118 | struct nouveau_pll_vals *pv = ®p->pllvals; |
111 | struct pll_lims pll_lim; | 119 | struct nvbios_pll pll_lim; |
112 | 120 | ||
113 | if (get_pll_limits(dev, nv_crtc->index ? PLL_VPLL1 : PLL_VPLL0, &pll_lim)) | 121 | if (nvbios_pll_parse(bios, nv_crtc->index ? PLL_VPLL1 : PLL_VPLL0, |
122 | &pll_lim)) | ||
114 | return; | 123 | return; |
115 | 124 | ||
116 | /* NM2 == 0 is used to determine single stage mode on two stage plls */ | 125 | /* NM2 == 0 is used to determine single stage mode on two stage plls */ |
@@ -126,28 +135,29 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod | |||
126 | * has yet been observed in allowing the use a single stage pll on all | 135 | * has yet been observed in allowing the use a single stage pll on all |
127 | * nv43 however. the behaviour of single stage use is untested on nv40 | 136 | * nv43 however. the behaviour of single stage use is untested on nv40 |
128 | */ | 137 | */ |
129 | if (dev_priv->chipset > 0x40 && dot_clock <= (pll_lim.vco1.maxfreq / 2)) | 138 | if (nv_device(drm->device)->chipset > 0x40 && dot_clock <= (pll_lim.vco1.max_freq / 2)) |
130 | memset(&pll_lim.vco2, 0, sizeof(pll_lim.vco2)); | 139 | memset(&pll_lim.vco2, 0, sizeof(pll_lim.vco2)); |
131 | 140 | ||
132 | if (!nouveau_calc_pll_mnp(dev, &pll_lim, dot_clock, pv)) | 141 | |
142 | if (!clk->pll_calc(clk, &pll_lim, dot_clock, pv)) | ||
133 | return; | 143 | return; |
134 | 144 | ||
135 | state->pllsel &= PLLSEL_VPLL1_MASK | PLLSEL_VPLL2_MASK | PLLSEL_TV_MASK; | 145 | state->pllsel &= PLLSEL_VPLL1_MASK | PLLSEL_VPLL2_MASK | PLLSEL_TV_MASK; |
136 | 146 | ||
137 | /* The blob uses this always, so let's do the same */ | 147 | /* The blob uses this always, so let's do the same */ |
138 | if (dev_priv->card_type == NV_40) | 148 | if (nv_device(drm->device)->card_type == NV_40) |
139 | state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_USE_VPLL2_TRUE; | 149 | state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_USE_VPLL2_TRUE; |
140 | /* again nv40 and some nv43 act more like nv3x as described above */ | 150 | /* again nv40 and some nv43 act more like nv3x as described above */ |
141 | if (dev_priv->chipset < 0x41) | 151 | if (nv_device(drm->device)->chipset < 0x41) |
142 | state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_MPLL | | 152 | state->pllsel |= NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_MPLL | |
143 | NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_NVPLL; | 153 | NV_PRAMDAC_PLL_COEFF_SELECT_SOURCE_PROG_NVPLL; |
144 | state->pllsel |= nv_crtc->index ? PLLSEL_VPLL2_MASK : PLLSEL_VPLL1_MASK; | 154 | state->pllsel |= nv_crtc->index ? PLLSEL_VPLL2_MASK : PLLSEL_VPLL1_MASK; |
145 | 155 | ||
146 | if (pv->NM2) | 156 | if (pv->NM2) |
147 | NV_DEBUG_KMS(dev, "vpll: n1 %d n2 %d m1 %d m2 %d log2p %d\n", | 157 | NV_DEBUG(drm, "vpll: n1 %d n2 %d m1 %d m2 %d log2p %d\n", |
148 | pv->N1, pv->N2, pv->M1, pv->M2, pv->log2P); | 158 | pv->N1, pv->N2, pv->M1, pv->M2, pv->log2P); |
149 | else | 159 | else |
150 | NV_DEBUG_KMS(dev, "vpll: n %d m %d log2p %d\n", | 160 | NV_DEBUG(drm, "vpll: n %d m %d log2p %d\n", |
151 | pv->N1, pv->M1, pv->log2P); | 161 | pv->N1, pv->M1, pv->log2P); |
152 | 162 | ||
153 | nv_crtc->cursor.set_offset(nv_crtc, nv_crtc->cursor.offset); | 163 | nv_crtc->cursor.set_offset(nv_crtc, nv_crtc->cursor.offset); |
@@ -158,10 +168,11 @@ nv_crtc_dpms(struct drm_crtc *crtc, int mode) | |||
158 | { | 168 | { |
159 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 169 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
160 | struct drm_device *dev = crtc->dev; | 170 | struct drm_device *dev = crtc->dev; |
171 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
161 | unsigned char seq1 = 0, crtc17 = 0; | 172 | unsigned char seq1 = 0, crtc17 = 0; |
162 | unsigned char crtc1A; | 173 | unsigned char crtc1A; |
163 | 174 | ||
164 | NV_DEBUG_KMS(dev, "Setting dpms mode %d on CRTC %d\n", mode, | 175 | NV_DEBUG(drm, "Setting dpms mode %d on CRTC %d\n", mode, |
165 | nv_crtc->index); | 176 | nv_crtc->index); |
166 | 177 | ||
167 | if (nv_crtc->last_dpms == mode) /* Don't do unnecessary mode changes. */ | 178 | if (nv_crtc->last_dpms == mode) /* Don't do unnecessary mode changes. */ |
@@ -225,9 +236,8 @@ static void | |||
225 | nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode) | 236 | nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode) |
226 | { | 237 | { |
227 | struct drm_device *dev = crtc->dev; | 238 | struct drm_device *dev = crtc->dev; |
228 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
229 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 239 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
230 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 240 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
231 | struct drm_framebuffer *fb = crtc->fb; | 241 | struct drm_framebuffer *fb = crtc->fb; |
232 | 242 | ||
233 | /* Calculate our timings */ | 243 | /* Calculate our timings */ |
@@ -251,8 +261,8 @@ nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode) | |||
251 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 261 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
252 | 262 | ||
253 | if (encoder->crtc == crtc && | 263 | if (encoder->crtc == crtc && |
254 | (nv_encoder->dcb->type == OUTPUT_LVDS || | 264 | (nv_encoder->dcb->type == DCB_OUTPUT_LVDS || |
255 | nv_encoder->dcb->type == OUTPUT_TMDS)) | 265 | nv_encoder->dcb->type == DCB_OUTPUT_TMDS)) |
256 | fp_output = true; | 266 | fp_output = true; |
257 | } | 267 | } |
258 | 268 | ||
@@ -264,7 +274,7 @@ nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode) | |||
264 | horizEnd = horizTotal - 2; | 274 | horizEnd = horizTotal - 2; |
265 | horizBlankEnd = horizTotal + 4; | 275 | horizBlankEnd = horizTotal + 4; |
266 | #if 0 | 276 | #if 0 |
267 | if (dev->overlayAdaptor && dev_priv->card_type >= NV_10) | 277 | if (dev->overlayAdaptor && nv_device(drm->device)->card_type >= NV_10) |
268 | /* This reportedly works around some video overlay bandwidth problems */ | 278 | /* This reportedly works around some video overlay bandwidth problems */ |
269 | horizTotal += 2; | 279 | horizTotal += 2; |
270 | #endif | 280 | #endif |
@@ -452,10 +462,10 @@ static void | |||
452 | nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) | 462 | nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) |
453 | { | 463 | { |
454 | struct drm_device *dev = crtc->dev; | 464 | struct drm_device *dev = crtc->dev; |
455 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 465 | struct nouveau_drm *drm = nouveau_drm(dev); |
456 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 466 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
457 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 467 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
458 | struct nv04_crtc_reg *savep = &dev_priv->saved_reg.crtc_reg[nv_crtc->index]; | 468 | struct nv04_crtc_reg *savep = &nv04_display(dev)->saved_reg.crtc_reg[nv_crtc->index]; |
459 | struct drm_encoder *encoder; | 469 | struct drm_encoder *encoder; |
460 | bool lvds_output = false, tmds_output = false, tv_output = false, | 470 | bool lvds_output = false, tmds_output = false, tv_output = false, |
461 | off_chip_digital = false; | 471 | off_chip_digital = false; |
@@ -467,11 +477,11 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) | |||
467 | if (encoder->crtc != crtc) | 477 | if (encoder->crtc != crtc) |
468 | continue; | 478 | continue; |
469 | 479 | ||
470 | if (nv_encoder->dcb->type == OUTPUT_LVDS) | 480 | if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS) |
471 | digital = lvds_output = true; | 481 | digital = lvds_output = true; |
472 | if (nv_encoder->dcb->type == OUTPUT_TV) | 482 | if (nv_encoder->dcb->type == DCB_OUTPUT_TV) |
473 | tv_output = true; | 483 | tv_output = true; |
474 | if (nv_encoder->dcb->type == OUTPUT_TMDS) | 484 | if (nv_encoder->dcb->type == DCB_OUTPUT_TMDS) |
475 | digital = tmds_output = true; | 485 | digital = tmds_output = true; |
476 | if (nv_encoder->dcb->location != DCB_LOC_ON_CHIP && digital) | 486 | if (nv_encoder->dcb->location != DCB_LOC_ON_CHIP && digital) |
477 | off_chip_digital = true; | 487 | off_chip_digital = true; |
@@ -500,7 +510,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) | |||
500 | regp->cursor_cfg = NV_PCRTC_CURSOR_CONFIG_CUR_LINES_64 | | 510 | regp->cursor_cfg = NV_PCRTC_CURSOR_CONFIG_CUR_LINES_64 | |
501 | NV_PCRTC_CURSOR_CONFIG_CUR_PIXELS_64 | | 511 | NV_PCRTC_CURSOR_CONFIG_CUR_PIXELS_64 | |
502 | NV_PCRTC_CURSOR_CONFIG_ADDRESS_SPACE_PNVM; | 512 | NV_PCRTC_CURSOR_CONFIG_ADDRESS_SPACE_PNVM; |
503 | if (dev_priv->chipset >= 0x11) | 513 | if (nv_device(drm->device)->chipset >= 0x11) |
504 | regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_CUR_BPP_32; | 514 | regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_CUR_BPP_32; |
505 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) | 515 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
506 | regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_DOUBLE_SCAN_ENABLE; | 516 | regp->cursor_cfg |= NV_PCRTC_CURSOR_CONFIG_DOUBLE_SCAN_ENABLE; |
@@ -533,7 +543,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) | |||
533 | 543 | ||
534 | /* The blob seems to take the current value from crtc 0, add 4 to that | 544 | /* The blob seems to take the current value from crtc 0, add 4 to that |
535 | * and reuse the old value for crtc 1 */ | 545 | * and reuse the old value for crtc 1 */ |
536 | regp->CRTC[NV_CIO_CRE_TVOUT_LATENCY] = dev_priv->saved_reg.crtc_reg[0].CRTC[NV_CIO_CRE_TVOUT_LATENCY]; | 546 | regp->CRTC[NV_CIO_CRE_TVOUT_LATENCY] = nv04_display(dev)->saved_reg.crtc_reg[0].CRTC[NV_CIO_CRE_TVOUT_LATENCY]; |
537 | if (!nv_crtc->index) | 547 | if (!nv_crtc->index) |
538 | regp->CRTC[NV_CIO_CRE_TVOUT_LATENCY] += 4; | 548 | regp->CRTC[NV_CIO_CRE_TVOUT_LATENCY] += 4; |
539 | 549 | ||
@@ -541,26 +551,26 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) | |||
541 | * 1 << 30 on 0x60.830), for no apparent reason */ | 551 | * 1 << 30 on 0x60.830), for no apparent reason */ |
542 | regp->CRTC[NV_CIO_CRE_59] = off_chip_digital; | 552 | regp->CRTC[NV_CIO_CRE_59] = off_chip_digital; |
543 | 553 | ||
544 | if (dev_priv->card_type >= NV_30) | 554 | if (nv_device(drm->device)->card_type >= NV_30) |
545 | regp->CRTC[0x9f] = off_chip_digital ? 0x11 : 0x1; | 555 | regp->CRTC[0x9f] = off_chip_digital ? 0x11 : 0x1; |
546 | 556 | ||
547 | regp->crtc_830 = mode->crtc_vdisplay - 3; | 557 | regp->crtc_830 = mode->crtc_vdisplay - 3; |
548 | regp->crtc_834 = mode->crtc_vdisplay - 1; | 558 | regp->crtc_834 = mode->crtc_vdisplay - 1; |
549 | 559 | ||
550 | if (dev_priv->card_type == NV_40) | 560 | if (nv_device(drm->device)->card_type == NV_40) |
551 | /* This is what the blob does */ | 561 | /* This is what the blob does */ |
552 | regp->crtc_850 = NVReadCRTC(dev, 0, NV_PCRTC_850); | 562 | regp->crtc_850 = NVReadCRTC(dev, 0, NV_PCRTC_850); |
553 | 563 | ||
554 | if (dev_priv->card_type >= NV_30) | 564 | if (nv_device(drm->device)->card_type >= NV_30) |
555 | regp->gpio_ext = NVReadCRTC(dev, 0, NV_PCRTC_GPIO_EXT); | 565 | regp->gpio_ext = NVReadCRTC(dev, 0, NV_PCRTC_GPIO_EXT); |
556 | 566 | ||
557 | if (dev_priv->card_type >= NV_10) | 567 | if (nv_device(drm->device)->card_type >= NV_10) |
558 | regp->crtc_cfg = NV10_PCRTC_CONFIG_START_ADDRESS_HSYNC; | 568 | regp->crtc_cfg = NV10_PCRTC_CONFIG_START_ADDRESS_HSYNC; |
559 | else | 569 | else |
560 | regp->crtc_cfg = NV04_PCRTC_CONFIG_START_ADDRESS_HSYNC; | 570 | regp->crtc_cfg = NV04_PCRTC_CONFIG_START_ADDRESS_HSYNC; |
561 | 571 | ||
562 | /* Some misc regs */ | 572 | /* Some misc regs */ |
563 | if (dev_priv->card_type == NV_40) { | 573 | if (nv_device(drm->device)->card_type == NV_40) { |
564 | regp->CRTC[NV_CIO_CRE_85] = 0xFF; | 574 | regp->CRTC[NV_CIO_CRE_85] = 0xFF; |
565 | regp->CRTC[NV_CIO_CRE_86] = 0x1; | 575 | regp->CRTC[NV_CIO_CRE_86] = 0x1; |
566 | } | 576 | } |
@@ -572,7 +582,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) | |||
572 | 582 | ||
573 | /* Generic PRAMDAC regs */ | 583 | /* Generic PRAMDAC regs */ |
574 | 584 | ||
575 | if (dev_priv->card_type >= NV_10) | 585 | if (nv_device(drm->device)->card_type >= NV_10) |
576 | /* Only bit that bios and blob set. */ | 586 | /* Only bit that bios and blob set. */ |
577 | regp->nv10_cursync = (1 << 25); | 587 | regp->nv10_cursync = (1 << 25); |
578 | 588 | ||
@@ -581,7 +591,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) | |||
581 | NV_PRAMDAC_GENERAL_CONTROL_PIXMIX_ON; | 591 | NV_PRAMDAC_GENERAL_CONTROL_PIXMIX_ON; |
582 | if (crtc->fb->depth == 16) | 592 | if (crtc->fb->depth == 16) |
583 | regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL; | 593 | regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_ALT_MODE_SEL; |
584 | if (dev_priv->chipset >= 0x11) | 594 | if (nv_device(drm->device)->chipset >= 0x11) |
585 | regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_PIPE_LONG; | 595 | regp->ramdac_gen_ctrl |= NV_PRAMDAC_GENERAL_CONTROL_PIPE_LONG; |
586 | 596 | ||
587 | regp->ramdac_630 = 0; /* turn off green mode (tv test pattern?) */ | 597 | regp->ramdac_630 = 0; /* turn off green mode (tv test pattern?) */ |
@@ -611,9 +621,9 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, | |||
611 | { | 621 | { |
612 | struct drm_device *dev = crtc->dev; | 622 | struct drm_device *dev = crtc->dev; |
613 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 623 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
614 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 624 | struct nouveau_drm *drm = nouveau_drm(dev); |
615 | 625 | ||
616 | NV_DEBUG_KMS(dev, "CTRC mode on CRTC %d:\n", nv_crtc->index); | 626 | NV_DEBUG(drm, "CTRC mode on CRTC %d:\n", nv_crtc->index); |
617 | drm_mode_debug_printmodeline(adjusted_mode); | 627 | drm_mode_debug_printmodeline(adjusted_mode); |
618 | 628 | ||
619 | /* unlock must come after turning off FP_TG_CONTROL in output_prepare */ | 629 | /* unlock must come after turning off FP_TG_CONTROL in output_prepare */ |
@@ -621,8 +631,8 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, | |||
621 | 631 | ||
622 | nv_crtc_mode_set_vga(crtc, adjusted_mode); | 632 | nv_crtc_mode_set_vga(crtc, adjusted_mode); |
623 | /* calculated in nv04_dfp_prepare, nv40 needs it written before calculating PLLs */ | 633 | /* calculated in nv04_dfp_prepare, nv40 needs it written before calculating PLLs */ |
624 | if (dev_priv->card_type == NV_40) | 634 | if (nv_device(drm->device)->card_type == NV_40) |
625 | NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, dev_priv->mode_reg.sel_clk); | 635 | NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, nv04_display(dev)->mode_reg.sel_clk); |
626 | nv_crtc_mode_set_regs(crtc, adjusted_mode); | 636 | nv_crtc_mode_set_regs(crtc, adjusted_mode); |
627 | nv_crtc_calc_state_ext(crtc, mode, adjusted_mode->clock); | 637 | nv_crtc_calc_state_ext(crtc, mode, adjusted_mode->clock); |
628 | return 0; | 638 | return 0; |
@@ -631,10 +641,10 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, | |||
631 | static void nv_crtc_save(struct drm_crtc *crtc) | 641 | static void nv_crtc_save(struct drm_crtc *crtc) |
632 | { | 642 | { |
633 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 643 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
634 | struct drm_nouveau_private *dev_priv = crtc->dev->dev_private; | 644 | struct drm_device *dev = crtc->dev; |
635 | struct nv04_mode_state *state = &dev_priv->mode_reg; | 645 | struct nv04_mode_state *state = &nv04_display(dev)->mode_reg; |
636 | struct nv04_crtc_reg *crtc_state = &state->crtc_reg[nv_crtc->index]; | 646 | struct nv04_crtc_reg *crtc_state = &state->crtc_reg[nv_crtc->index]; |
637 | struct nv04_mode_state *saved = &dev_priv->saved_reg; | 647 | struct nv04_mode_state *saved = &nv04_display(dev)->saved_reg; |
638 | struct nv04_crtc_reg *crtc_saved = &saved->crtc_reg[nv_crtc->index]; | 648 | struct nv04_crtc_reg *crtc_saved = &saved->crtc_reg[nv_crtc->index]; |
639 | 649 | ||
640 | if (nv_two_heads(crtc->dev)) | 650 | if (nv_two_heads(crtc->dev)) |
@@ -652,14 +662,14 @@ static void nv_crtc_save(struct drm_crtc *crtc) | |||
652 | static void nv_crtc_restore(struct drm_crtc *crtc) | 662 | static void nv_crtc_restore(struct drm_crtc *crtc) |
653 | { | 663 | { |
654 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 664 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
655 | struct drm_nouveau_private *dev_priv = crtc->dev->dev_private; | 665 | struct drm_device *dev = crtc->dev; |
656 | int head = nv_crtc->index; | 666 | int head = nv_crtc->index; |
657 | uint8_t saved_cr21 = dev_priv->saved_reg.crtc_reg[head].CRTC[NV_CIO_CRE_21]; | 667 | uint8_t saved_cr21 = nv04_display(dev)->saved_reg.crtc_reg[head].CRTC[NV_CIO_CRE_21]; |
658 | 668 | ||
659 | if (nv_two_heads(crtc->dev)) | 669 | if (nv_two_heads(crtc->dev)) |
660 | NVSetOwner(crtc->dev, head); | 670 | NVSetOwner(crtc->dev, head); |
661 | 671 | ||
662 | nouveau_hw_load_state(crtc->dev, head, &dev_priv->saved_reg); | 672 | nouveau_hw_load_state(crtc->dev, head, &nv04_display(dev)->saved_reg); |
663 | nv_lock_vga_crtc_shadow(crtc->dev, head, saved_cr21); | 673 | nv_lock_vga_crtc_shadow(crtc->dev, head, saved_cr21); |
664 | 674 | ||
665 | nv_crtc->last_dpms = NV_DPMS_CLEARED; | 675 | nv_crtc->last_dpms = NV_DPMS_CLEARED; |
@@ -668,7 +678,7 @@ static void nv_crtc_restore(struct drm_crtc *crtc) | |||
668 | static void nv_crtc_prepare(struct drm_crtc *crtc) | 678 | static void nv_crtc_prepare(struct drm_crtc *crtc) |
669 | { | 679 | { |
670 | struct drm_device *dev = crtc->dev; | 680 | struct drm_device *dev = crtc->dev; |
671 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 681 | struct nouveau_drm *drm = nouveau_drm(dev); |
672 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 682 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
673 | struct drm_crtc_helper_funcs *funcs = crtc->helper_private; | 683 | struct drm_crtc_helper_funcs *funcs = crtc->helper_private; |
674 | 684 | ||
@@ -682,7 +692,7 @@ static void nv_crtc_prepare(struct drm_crtc *crtc) | |||
682 | 692 | ||
683 | /* Some more preparation. */ | 693 | /* Some more preparation. */ |
684 | NVWriteCRTC(dev, nv_crtc->index, NV_PCRTC_CONFIG, NV_PCRTC_CONFIG_START_ADDRESS_NON_VGA); | 694 | NVWriteCRTC(dev, nv_crtc->index, NV_PCRTC_CONFIG, NV_PCRTC_CONFIG_START_ADDRESS_NON_VGA); |
685 | if (dev_priv->card_type == NV_40) { | 695 | if (nv_device(drm->device)->card_type == NV_40) { |
686 | uint32_t reg900 = NVReadRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900); | 696 | uint32_t reg900 = NVReadRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900); |
687 | NVWriteRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900, reg900 & ~0x10000); | 697 | NVWriteRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900, reg900 & ~0x10000); |
688 | } | 698 | } |
@@ -692,10 +702,9 @@ static void nv_crtc_commit(struct drm_crtc *crtc) | |||
692 | { | 702 | { |
693 | struct drm_device *dev = crtc->dev; | 703 | struct drm_device *dev = crtc->dev; |
694 | struct drm_crtc_helper_funcs *funcs = crtc->helper_private; | 704 | struct drm_crtc_helper_funcs *funcs = crtc->helper_private; |
695 | struct drm_nouveau_private *dev_priv = crtc->dev->dev_private; | ||
696 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 705 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
697 | 706 | ||
698 | nouveau_hw_load_state(dev, nv_crtc->index, &dev_priv->mode_reg); | 707 | nouveau_hw_load_state(dev, nv_crtc->index, &nv04_display(dev)->mode_reg); |
699 | nv04_crtc_mode_set_base(crtc, crtc->x, crtc->y, NULL); | 708 | nv04_crtc_mode_set_base(crtc, crtc->x, crtc->y, NULL); |
700 | 709 | ||
701 | #ifdef __BIG_ENDIAN | 710 | #ifdef __BIG_ENDIAN |
@@ -715,8 +724,6 @@ static void nv_crtc_destroy(struct drm_crtc *crtc) | |||
715 | { | 724 | { |
716 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 725 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
717 | 726 | ||
718 | NV_DEBUG_KMS(crtc->dev, "\n"); | ||
719 | |||
720 | if (!nv_crtc) | 727 | if (!nv_crtc) |
721 | return; | 728 | return; |
722 | 729 | ||
@@ -732,18 +739,17 @@ nv_crtc_gamma_load(struct drm_crtc *crtc) | |||
732 | { | 739 | { |
733 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 740 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
734 | struct drm_device *dev = nv_crtc->base.dev; | 741 | struct drm_device *dev = nv_crtc->base.dev; |
735 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
736 | struct rgb { uint8_t r, g, b; } __attribute__((packed)) *rgbs; | 742 | struct rgb { uint8_t r, g, b; } __attribute__((packed)) *rgbs; |
737 | int i; | 743 | int i; |
738 | 744 | ||
739 | rgbs = (struct rgb *)dev_priv->mode_reg.crtc_reg[nv_crtc->index].DAC; | 745 | rgbs = (struct rgb *)nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index].DAC; |
740 | for (i = 0; i < 256; i++) { | 746 | for (i = 0; i < 256; i++) { |
741 | rgbs[i].r = nv_crtc->lut.r[i] >> 8; | 747 | rgbs[i].r = nv_crtc->lut.r[i] >> 8; |
742 | rgbs[i].g = nv_crtc->lut.g[i] >> 8; | 748 | rgbs[i].g = nv_crtc->lut.g[i] >> 8; |
743 | rgbs[i].b = nv_crtc->lut.b[i] >> 8; | 749 | rgbs[i].b = nv_crtc->lut.b[i] >> 8; |
744 | } | 750 | } |
745 | 751 | ||
746 | nouveau_hw_load_state_palette(dev, nv_crtc->index, &dev_priv->mode_reg); | 752 | nouveau_hw_load_state_palette(dev, nv_crtc->index, &nv04_display(dev)->mode_reg); |
747 | } | 753 | } |
748 | 754 | ||
749 | static void | 755 | static void |
@@ -779,18 +785,18 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc, | |||
779 | { | 785 | { |
780 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 786 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
781 | struct drm_device *dev = crtc->dev; | 787 | struct drm_device *dev = crtc->dev; |
782 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 788 | struct nouveau_drm *drm = nouveau_drm(dev); |
783 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 789 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
784 | struct drm_framebuffer *drm_fb; | 790 | struct drm_framebuffer *drm_fb; |
785 | struct nouveau_framebuffer *fb; | 791 | struct nouveau_framebuffer *fb; |
786 | int arb_burst, arb_lwm; | 792 | int arb_burst, arb_lwm; |
787 | int ret; | 793 | int ret; |
788 | 794 | ||
789 | NV_DEBUG_KMS(dev, "index %d\n", nv_crtc->index); | 795 | NV_DEBUG(drm, "index %d\n", nv_crtc->index); |
790 | 796 | ||
791 | /* no fb bound */ | 797 | /* no fb bound */ |
792 | if (!atomic && !crtc->fb) { | 798 | if (!atomic && !crtc->fb) { |
793 | NV_DEBUG_KMS(dev, "No FB bound\n"); | 799 | NV_DEBUG(drm, "No FB bound\n"); |
794 | return 0; | 800 | return 0; |
795 | } | 801 | } |
796 | 802 | ||
@@ -858,7 +864,7 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc, | |||
858 | crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FF_INDEX); | 864 | crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FF_INDEX); |
859 | crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FFLWM__INDEX); | 865 | crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_FFLWM__INDEX); |
860 | 866 | ||
861 | if (dev_priv->card_type >= NV_20) { | 867 | if (nv_device(drm->device)->card_type >= NV_20) { |
862 | regp->CRTC[NV_CIO_CRE_47] = arb_lwm >> 8; | 868 | regp->CRTC[NV_CIO_CRE_47] = arb_lwm >> 8; |
863 | crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_47); | 869 | crtc_wr_cio_state(crtc, regp, NV_CIO_CRE_47); |
864 | } | 870 | } |
@@ -878,8 +884,8 @@ nv04_crtc_mode_set_base_atomic(struct drm_crtc *crtc, | |||
878 | struct drm_framebuffer *fb, | 884 | struct drm_framebuffer *fb, |
879 | int x, int y, enum mode_set_atomic state) | 885 | int x, int y, enum mode_set_atomic state) |
880 | { | 886 | { |
881 | struct drm_nouveau_private *dev_priv = crtc->dev->dev_private; | 887 | struct nouveau_drm *drm = nouveau_drm(crtc->dev); |
882 | struct drm_device *dev = dev_priv->dev; | 888 | struct drm_device *dev = drm->dev; |
883 | 889 | ||
884 | if (state == ENTER_ATOMIC_MODE_SET) | 890 | if (state == ENTER_ATOMIC_MODE_SET) |
885 | nouveau_fbcon_save_disable_accel(dev); | 891 | nouveau_fbcon_save_disable_accel(dev); |
@@ -934,9 +940,9 @@ static void nv11_cursor_upload(struct drm_device *dev, struct nouveau_bo *src, | |||
934 | 940 | ||
935 | #ifdef __BIG_ENDIAN | 941 | #ifdef __BIG_ENDIAN |
936 | { | 942 | { |
937 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 943 | struct nouveau_drm *drm = nouveau_drm(dev); |
938 | 944 | ||
939 | if (dev_priv->chipset == 0x11) { | 945 | if (nv_device(drm->device)->chipset == 0x11) { |
940 | pixel = ((pixel & 0x000000ff) << 24) | | 946 | pixel = ((pixel & 0x000000ff) << 24) | |
941 | ((pixel & 0x0000ff00) << 8) | | 947 | ((pixel & 0x0000ff00) << 8) | |
942 | ((pixel & 0x00ff0000) >> 8) | | 948 | ((pixel & 0x00ff0000) >> 8) | |
@@ -953,8 +959,8 @@ static int | |||
953 | nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, | 959 | nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, |
954 | uint32_t buffer_handle, uint32_t width, uint32_t height) | 960 | uint32_t buffer_handle, uint32_t width, uint32_t height) |
955 | { | 961 | { |
956 | struct drm_nouveau_private *dev_priv = crtc->dev->dev_private; | 962 | struct nouveau_drm *drm = nouveau_drm(crtc->dev); |
957 | struct drm_device *dev = dev_priv->dev; | 963 | struct drm_device *dev = drm->dev; |
958 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 964 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
959 | struct nouveau_bo *cursor = NULL; | 965 | struct nouveau_bo *cursor = NULL; |
960 | struct drm_gem_object *gem; | 966 | struct drm_gem_object *gem; |
@@ -977,7 +983,7 @@ nv04_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, | |||
977 | if (ret) | 983 | if (ret) |
978 | goto out; | 984 | goto out; |
979 | 985 | ||
980 | if (dev_priv->chipset >= 0x11) | 986 | if (nv_device(drm->device)->chipset >= 0x11) |
981 | nv11_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo); | 987 | nv11_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo); |
982 | else | 988 | else |
983 | nv04_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo); | 989 | nv04_cursor_upload(dev, cursor, nv_crtc->cursor.nvbo); |