diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2012-07-17 20:00:50 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2012-10-02 23:12:53 -0400 |
commit | 017e6e2955a8b290653aa71bd321609d0d4b1486 (patch) | |
tree | c891b865843f0d11437a7acb17063ea028239179 /drivers/gpu | |
parent | 3863c9bc887e9638a9d905d55f6038641ece78d6 (diff) |
drm/nv04/disp: kick all private state out to own header
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_drv.h | 109 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_encoder.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_hw.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_hw.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_state.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv04_crtc.c | 43 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv04_cursor.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv04_dac.c | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv04_dfp.c | 34 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv04_display.c | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv04_display.h | 121 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv04_tv.c | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv17_tv.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv17_tv_modes.c | 3 |
14 files changed, 182 insertions, 171 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_drv.h b/drivers/gpu/drm/nouveau/nouveau_drv.h index f62732dd30ad..760af9286819 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drv.h +++ b/drivers/gpu/drm/nouveau/nouveau_drv.h | |||
@@ -468,76 +468,6 @@ struct nouveau_engine { | |||
468 | struct nouveau_pm_engine pm; | 468 | struct nouveau_pm_engine pm; |
469 | }; | 469 | }; |
470 | 470 | ||
471 | enum nv04_fp_display_regs { | ||
472 | FP_DISPLAY_END, | ||
473 | FP_TOTAL, | ||
474 | FP_CRTC, | ||
475 | FP_SYNC_START, | ||
476 | FP_SYNC_END, | ||
477 | FP_VALID_START, | ||
478 | FP_VALID_END | ||
479 | }; | ||
480 | |||
481 | struct nv04_crtc_reg { | ||
482 | unsigned char MiscOutReg; | ||
483 | uint8_t CRTC[0xa0]; | ||
484 | uint8_t CR58[0x10]; | ||
485 | uint8_t Sequencer[5]; | ||
486 | uint8_t Graphics[9]; | ||
487 | uint8_t Attribute[21]; | ||
488 | unsigned char DAC[768]; | ||
489 | |||
490 | /* PCRTC regs */ | ||
491 | uint32_t fb_start; | ||
492 | uint32_t crtc_cfg; | ||
493 | uint32_t cursor_cfg; | ||
494 | uint32_t gpio_ext; | ||
495 | uint32_t crtc_830; | ||
496 | uint32_t crtc_834; | ||
497 | uint32_t crtc_850; | ||
498 | uint32_t crtc_eng_ctrl; | ||
499 | |||
500 | /* PRAMDAC regs */ | ||
501 | uint32_t nv10_cursync; | ||
502 | struct nouveau_pll_vals pllvals; | ||
503 | uint32_t ramdac_gen_ctrl; | ||
504 | uint32_t ramdac_630; | ||
505 | uint32_t ramdac_634; | ||
506 | uint32_t tv_setup; | ||
507 | uint32_t tv_vtotal; | ||
508 | uint32_t tv_vskew; | ||
509 | uint32_t tv_vsync_delay; | ||
510 | uint32_t tv_htotal; | ||
511 | uint32_t tv_hskew; | ||
512 | uint32_t tv_hsync_delay; | ||
513 | uint32_t tv_hsync_delay2; | ||
514 | uint32_t fp_horiz_regs[7]; | ||
515 | uint32_t fp_vert_regs[7]; | ||
516 | uint32_t dither; | ||
517 | uint32_t fp_control; | ||
518 | uint32_t dither_regs[6]; | ||
519 | uint32_t fp_debug_0; | ||
520 | uint32_t fp_debug_1; | ||
521 | uint32_t fp_debug_2; | ||
522 | uint32_t fp_margin_color; | ||
523 | uint32_t ramdac_8c0; | ||
524 | uint32_t ramdac_a20; | ||
525 | uint32_t ramdac_a24; | ||
526 | uint32_t ramdac_a34; | ||
527 | uint32_t ctv_regs[38]; | ||
528 | }; | ||
529 | |||
530 | struct nv04_output_reg { | ||
531 | uint32_t output; | ||
532 | int head; | ||
533 | }; | ||
534 | |||
535 | struct nv04_mode_state { | ||
536 | struct nv04_crtc_reg crtc_reg[2]; | ||
537 | uint32_t pllsel; | ||
538 | uint32_t sel_clk; | ||
539 | }; | ||
540 | |||
541 | enum nouveau_card_type { | 471 | enum nouveau_card_type { |
542 | NV_04 = 0x04, | 472 | NV_04 = 0x04, |
543 | NV_10 = 0x10, | 473 | NV_10 = 0x10, |
@@ -639,12 +569,6 @@ struct drm_nouveau_private { | |||
639 | u8 *mxms; | 569 | u8 *mxms; |
640 | struct list_head i2c_ports; | 570 | struct list_head i2c_ports; |
641 | 571 | ||
642 | struct nv04_mode_state mode_reg; | ||
643 | struct nv04_mode_state saved_reg; | ||
644 | uint32_t saved_vga_font[4][16384]; | ||
645 | uint32_t crtc_owner; | ||
646 | uint32_t dac_users[4]; | ||
647 | |||
648 | struct backlight_device *backlight; | 572 | struct backlight_device *backlight; |
649 | 573 | ||
650 | struct { | 574 | struct { |
@@ -997,36 +921,6 @@ extern int nv98_ppp_create(struct drm_device *dev); | |||
997 | extern long nouveau_compat_ioctl(struct file *file, unsigned int cmd, | 921 | extern long nouveau_compat_ioctl(struct file *file, unsigned int cmd, |
998 | unsigned long arg); | 922 | unsigned long arg); |
999 | 923 | ||
1000 | /* nv04_dac.c */ | ||
1001 | extern int nv04_dac_create(struct drm_connector *, struct dcb_output *); | ||
1002 | extern uint32_t nv17_dac_sample_load(struct drm_encoder *encoder); | ||
1003 | extern int nv04_dac_output_offset(struct drm_encoder *encoder); | ||
1004 | extern void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable); | ||
1005 | extern bool nv04_dac_in_use(struct drm_encoder *encoder); | ||
1006 | |||
1007 | /* nv04_dfp.c */ | ||
1008 | extern int nv04_dfp_create(struct drm_connector *, struct dcb_output *); | ||
1009 | extern int nv04_dfp_get_bound_head(struct drm_device *dev, struct dcb_output *dcbent); | ||
1010 | extern void nv04_dfp_bind_head(struct drm_device *dev, struct dcb_output *dcbent, | ||
1011 | int head, bool dl); | ||
1012 | extern void nv04_dfp_disable(struct drm_device *dev, int head); | ||
1013 | extern void nv04_dfp_update_fp_control(struct drm_encoder *encoder, int mode); | ||
1014 | |||
1015 | /* nv04_tv.c */ | ||
1016 | extern int nv04_tv_identify(struct drm_device *dev, int i2c_index); | ||
1017 | extern int nv04_tv_create(struct drm_connector *, struct dcb_output *); | ||
1018 | |||
1019 | /* nv17_tv.c */ | ||
1020 | extern int nv17_tv_create(struct drm_connector *, struct dcb_output *); | ||
1021 | |||
1022 | /* nv04_display.c */ | ||
1023 | extern int nv04_display_early_init(struct drm_device *); | ||
1024 | extern void nv04_display_late_takedown(struct drm_device *); | ||
1025 | extern int nv04_display_create(struct drm_device *); | ||
1026 | extern void nv04_display_destroy(struct drm_device *); | ||
1027 | extern int nv04_display_init(struct drm_device *); | ||
1028 | extern void nv04_display_fini(struct drm_device *); | ||
1029 | |||
1030 | /* nvd0_display.c */ | 924 | /* nvd0_display.c */ |
1031 | extern int nvd0_display_create(struct drm_device *); | 925 | extern int nvd0_display_create(struct drm_device *); |
1032 | extern void nvd0_display_destroy(struct drm_device *); | 926 | extern void nvd0_display_destroy(struct drm_device *); |
@@ -1037,9 +931,6 @@ void nvd0_display_flip_stop(struct drm_crtc *); | |||
1037 | int nvd0_display_flip_next(struct drm_crtc *, struct drm_framebuffer *, | 931 | int nvd0_display_flip_next(struct drm_crtc *, struct drm_framebuffer *, |
1038 | struct nouveau_channel *, u32 swap_interval); | 932 | struct nouveau_channel *, u32 swap_interval); |
1039 | 933 | ||
1040 | /* nv04_crtc.c */ | ||
1041 | extern int nv04_crtc_create(struct drm_device *, int index); | ||
1042 | |||
1043 | /* nouveau_bo.c */ | 934 | /* nouveau_bo.c */ |
1044 | extern struct ttm_bo_driver nouveau_bo_driver; | 935 | extern struct ttm_bo_driver nouveau_bo_driver; |
1045 | extern void nouveau_bo_move_init(struct nouveau_channel *); | 936 | extern void nouveau_bo_move_init(struct nouveau_channel *); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_encoder.h b/drivers/gpu/drm/nouveau/nouveau_encoder.h index 789221d86c4a..07cda5840166 100644 --- a/drivers/gpu/drm/nouveau/nouveau_encoder.h +++ b/drivers/gpu/drm/nouveau/nouveau_encoder.h | |||
@@ -29,6 +29,7 @@ | |||
29 | 29 | ||
30 | #include "drm_encoder_slave.h" | 30 | #include "drm_encoder_slave.h" |
31 | #include "nouveau_drv.h" | 31 | #include "nouveau_drv.h" |
32 | #include "nv04_display.h" | ||
32 | 33 | ||
33 | #define NV_DPMS_CLEARED 0x80 | 34 | #define NV_DPMS_CLEARED 0x80 |
34 | 35 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_hw.c b/drivers/gpu/drm/nouveau/nouveau_hw.c index fdd667b70528..9cae3eb508c4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_hw.c +++ b/drivers/gpu/drm/nouveau/nouveau_hw.c | |||
@@ -285,17 +285,16 @@ static void nouveau_vga_font_io(struct drm_device *dev, | |||
285 | void __iomem *iovram, | 285 | void __iomem *iovram, |
286 | bool save, unsigned plane) | 286 | bool save, unsigned plane) |
287 | { | 287 | { |
288 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
289 | unsigned i; | 288 | unsigned i; |
290 | 289 | ||
291 | NVWriteVgaSeq(dev, 0, NV_VIO_SR_PLANE_MASK_INDEX, 1 << plane); | 290 | NVWriteVgaSeq(dev, 0, NV_VIO_SR_PLANE_MASK_INDEX, 1 << plane); |
292 | NVWriteVgaGr(dev, 0, NV_VIO_GX_READ_MAP_INDEX, plane); | 291 | NVWriteVgaGr(dev, 0, NV_VIO_GX_READ_MAP_INDEX, plane); |
293 | for (i = 0; i < 16384; i++) { | 292 | for (i = 0; i < 16384; i++) { |
294 | if (save) { | 293 | if (save) { |
295 | dev_priv->saved_vga_font[plane][i] = | 294 | nv04_display(dev)->saved_vga_font[plane][i] = |
296 | ioread32_native(iovram + i * 4); | 295 | ioread32_native(iovram + i * 4); |
297 | } else { | 296 | } else { |
298 | iowrite32_native(dev_priv->saved_vga_font[plane][i], | 297 | iowrite32_native(nv04_display(dev)->saved_vga_font[plane][i], |
299 | iovram + i * 4); | 298 | iovram + i * 4); |
300 | } | 299 | } |
301 | } | 300 | } |
diff --git a/drivers/gpu/drm/nouveau/nouveau_hw.h b/drivers/gpu/drm/nouveau/nouveau_hw.h index 24c459213613..feb2a2f7bd42 100644 --- a/drivers/gpu/drm/nouveau/nouveau_hw.h +++ b/drivers/gpu/drm/nouveau/nouveau_hw.h | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include "drmP.h" | 26 | #include "drmP.h" |
27 | #include "nouveau_drv.h" | 27 | #include "nouveau_drv.h" |
28 | #include "nv04_display.h" | ||
28 | 29 | ||
29 | #include <subdev/bios/pll.h> | 30 | #include <subdev/bios/pll.h> |
30 | 31 | ||
@@ -437,7 +438,7 @@ nv_show_cursor(struct drm_device *dev, int head, bool show) | |||
437 | { | 438 | { |
438 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 439 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
439 | uint8_t *curctl1 = | 440 | uint8_t *curctl1 = |
440 | &dev_priv->mode_reg.crtc_reg[head].CRTC[NV_CIO_CRE_HCUR_ADDR1_INDEX]; | 441 | &nv04_display(dev)->mode_reg.crtc_reg[head].CRTC[NV_CIO_CRE_HCUR_ADDR1_INDEX]; |
441 | 442 | ||
442 | if (show) | 443 | if (show) |
443 | *curctl1 |= MASK(NV_CIO_CRE_HCUR_ADDR1_ENABLE); | 444 | *curctl1 |= MASK(NV_CIO_CRE_HCUR_ADDR1_ENABLE); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c index f53c6a748200..1cdabdc79083 100644 --- a/drivers/gpu/drm/nouveau/nouveau_state.c +++ b/drivers/gpu/drm/nouveau/nouveau_state.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include "nouveau_fbcon.h" | 37 | #include "nouveau_fbcon.h" |
38 | #include <core/ramht.h> | 38 | #include <core/ramht.h> |
39 | #include "nouveau_pm.h" | 39 | #include "nouveau_pm.h" |
40 | #include "nv04_display.h" | ||
40 | #include "nv50_display.h" | 41 | #include "nv50_display.h" |
41 | #include <engine/fifo.h> | 42 | #include <engine/fifo.h> |
42 | #include "nouveau_fence.h" | 43 | #include "nouveau_fence.h" |
diff --git a/drivers/gpu/drm/nouveau/nv04_crtc.c b/drivers/gpu/drm/nouveau/nv04_crtc.c index 1d38968abcf1..f5d17bf954ff 100644 --- a/drivers/gpu/drm/nouveau/nv04_crtc.c +++ b/drivers/gpu/drm/nouveau/nv04_crtc.c | |||
@@ -49,8 +49,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) | 49 | static void nv_crtc_set_digital_vibrance(struct drm_crtc *crtc, int level) |
50 | { | 50 | { |
51 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 51 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
52 | struct drm_nouveau_private *dev_priv = crtc->dev->dev_private; | 52 | struct drm_device *dev = crtc->dev; |
53 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 53 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
54 | 54 | ||
55 | regp->CRTC[NV_CIO_CRE_CSB] = nv_crtc->saturation = level; | 55 | regp->CRTC[NV_CIO_CRE_CSB] = nv_crtc->saturation = level; |
56 | if (nv_crtc->saturation && nv_gf4_disp_arch(crtc->dev)) { | 56 | if (nv_crtc->saturation && nv_gf4_disp_arch(crtc->dev)) { |
@@ -64,8 +64,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) | 64 | static void nv_crtc_set_image_sharpening(struct drm_crtc *crtc, int level) |
65 | { | 65 | { |
66 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 66 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
67 | struct drm_nouveau_private *dev_priv = crtc->dev->dev_private; | 67 | struct drm_device *dev = crtc->dev; |
68 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 68 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
69 | 69 | ||
70 | nv_crtc->sharpness = level; | 70 | nv_crtc->sharpness = level; |
71 | if (level < 0) /* blur is in hw range 0x3f -> 0x20 */ | 71 | if (level < 0) /* blur is in hw range 0x3f -> 0x20 */ |
@@ -105,7 +105,7 @@ static void nv_crtc_calc_state_ext(struct drm_crtc *crtc, struct drm_display_mod | |||
105 | struct drm_device *dev = crtc->dev; | 105 | struct drm_device *dev = crtc->dev; |
106 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 106 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
107 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 107 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
108 | struct nv04_mode_state *state = &dev_priv->mode_reg; | 108 | struct nv04_mode_state *state = &nv04_display(dev)->mode_reg; |
109 | struct nv04_crtc_reg *regp = &state->crtc_reg[nv_crtc->index]; | 109 | struct nv04_crtc_reg *regp = &state->crtc_reg[nv_crtc->index]; |
110 | struct nouveau_pll_vals *pv = ®p->pllvals; | 110 | struct nouveau_pll_vals *pv = ®p->pllvals; |
111 | struct nvbios_pll pll_lim; | 111 | struct nvbios_pll pll_lim; |
@@ -225,9 +225,8 @@ static void | |||
225 | nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode) | 225 | nv_crtc_mode_set_vga(struct drm_crtc *crtc, struct drm_display_mode *mode) |
226 | { | 226 | { |
227 | struct drm_device *dev = crtc->dev; | 227 | 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); | 228 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
230 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 229 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
231 | struct drm_framebuffer *fb = crtc->fb; | 230 | struct drm_framebuffer *fb = crtc->fb; |
232 | 231 | ||
233 | /* Calculate our timings */ | 232 | /* Calculate our timings */ |
@@ -454,8 +453,8 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) | |||
454 | struct drm_device *dev = crtc->dev; | 453 | struct drm_device *dev = crtc->dev; |
455 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 454 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
456 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 455 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
457 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 456 | 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]; | 457 | struct nv04_crtc_reg *savep = &nv04_display(dev)->saved_reg.crtc_reg[nv_crtc->index]; |
459 | struct drm_encoder *encoder; | 458 | struct drm_encoder *encoder; |
460 | bool lvds_output = false, tmds_output = false, tv_output = false, | 459 | bool lvds_output = false, tmds_output = false, tv_output = false, |
461 | off_chip_digital = false; | 460 | off_chip_digital = false; |
@@ -533,7 +532,7 @@ nv_crtc_mode_set_regs(struct drm_crtc *crtc, struct drm_display_mode * mode) | |||
533 | 532 | ||
534 | /* The blob seems to take the current value from crtc 0, add 4 to that | 533 | /* The blob seems to take the current value from crtc 0, add 4 to that |
535 | * and reuse the old value for crtc 1 */ | 534 | * 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]; | 535 | 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) | 536 | if (!nv_crtc->index) |
538 | regp->CRTC[NV_CIO_CRE_TVOUT_LATENCY] += 4; | 537 | regp->CRTC[NV_CIO_CRE_TVOUT_LATENCY] += 4; |
539 | 538 | ||
@@ -622,7 +621,7 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, | |||
622 | nv_crtc_mode_set_vga(crtc, adjusted_mode); | 621 | nv_crtc_mode_set_vga(crtc, adjusted_mode); |
623 | /* calculated in nv04_dfp_prepare, nv40 needs it written before calculating PLLs */ | 622 | /* calculated in nv04_dfp_prepare, nv40 needs it written before calculating PLLs */ |
624 | if (dev_priv->card_type == NV_40) | 623 | if (dev_priv->card_type == NV_40) |
625 | NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, dev_priv->mode_reg.sel_clk); | 624 | NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, nv04_display(dev)->mode_reg.sel_clk); |
626 | nv_crtc_mode_set_regs(crtc, adjusted_mode); | 625 | nv_crtc_mode_set_regs(crtc, adjusted_mode); |
627 | nv_crtc_calc_state_ext(crtc, mode, adjusted_mode->clock); | 626 | nv_crtc_calc_state_ext(crtc, mode, adjusted_mode->clock); |
628 | return 0; | 627 | return 0; |
@@ -631,10 +630,10 @@ nv_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, | |||
631 | static void nv_crtc_save(struct drm_crtc *crtc) | 630 | static void nv_crtc_save(struct drm_crtc *crtc) |
632 | { | 631 | { |
633 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 632 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
634 | struct drm_nouveau_private *dev_priv = crtc->dev->dev_private; | 633 | struct drm_device *dev = crtc->dev; |
635 | struct nv04_mode_state *state = &dev_priv->mode_reg; | 634 | struct nv04_mode_state *state = &nv04_display(dev)->mode_reg; |
636 | struct nv04_crtc_reg *crtc_state = &state->crtc_reg[nv_crtc->index]; | 635 | struct nv04_crtc_reg *crtc_state = &state->crtc_reg[nv_crtc->index]; |
637 | struct nv04_mode_state *saved = &dev_priv->saved_reg; | 636 | struct nv04_mode_state *saved = &nv04_display(dev)->saved_reg; |
638 | struct nv04_crtc_reg *crtc_saved = &saved->crtc_reg[nv_crtc->index]; | 637 | struct nv04_crtc_reg *crtc_saved = &saved->crtc_reg[nv_crtc->index]; |
639 | 638 | ||
640 | if (nv_two_heads(crtc->dev)) | 639 | if (nv_two_heads(crtc->dev)) |
@@ -652,14 +651,14 @@ static void nv_crtc_save(struct drm_crtc *crtc) | |||
652 | static void nv_crtc_restore(struct drm_crtc *crtc) | 651 | static void nv_crtc_restore(struct drm_crtc *crtc) |
653 | { | 652 | { |
654 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 653 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
655 | struct drm_nouveau_private *dev_priv = crtc->dev->dev_private; | 654 | struct drm_device *dev = crtc->dev; |
656 | int head = nv_crtc->index; | 655 | int head = nv_crtc->index; |
657 | uint8_t saved_cr21 = dev_priv->saved_reg.crtc_reg[head].CRTC[NV_CIO_CRE_21]; | 656 | uint8_t saved_cr21 = nv04_display(dev)->saved_reg.crtc_reg[head].CRTC[NV_CIO_CRE_21]; |
658 | 657 | ||
659 | if (nv_two_heads(crtc->dev)) | 658 | if (nv_two_heads(crtc->dev)) |
660 | NVSetOwner(crtc->dev, head); | 659 | NVSetOwner(crtc->dev, head); |
661 | 660 | ||
662 | nouveau_hw_load_state(crtc->dev, head, &dev_priv->saved_reg); | 661 | nouveau_hw_load_state(crtc->dev, head, &nv04_display(dev)->saved_reg); |
663 | nv_lock_vga_crtc_shadow(crtc->dev, head, saved_cr21); | 662 | nv_lock_vga_crtc_shadow(crtc->dev, head, saved_cr21); |
664 | 663 | ||
665 | nv_crtc->last_dpms = NV_DPMS_CLEARED; | 664 | nv_crtc->last_dpms = NV_DPMS_CLEARED; |
@@ -692,10 +691,9 @@ static void nv_crtc_commit(struct drm_crtc *crtc) | |||
692 | { | 691 | { |
693 | struct drm_device *dev = crtc->dev; | 692 | struct drm_device *dev = crtc->dev; |
694 | struct drm_crtc_helper_funcs *funcs = crtc->helper_private; | 693 | 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); | 694 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
697 | 695 | ||
698 | nouveau_hw_load_state(dev, nv_crtc->index, &dev_priv->mode_reg); | 696 | 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); | 697 | nv04_crtc_mode_set_base(crtc, crtc->x, crtc->y, NULL); |
700 | 698 | ||
701 | #ifdef __BIG_ENDIAN | 699 | #ifdef __BIG_ENDIAN |
@@ -732,18 +730,17 @@ nv_crtc_gamma_load(struct drm_crtc *crtc) | |||
732 | { | 730 | { |
733 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 731 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
734 | struct drm_device *dev = nv_crtc->base.dev; | 732 | 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; | 733 | struct rgb { uint8_t r, g, b; } __attribute__((packed)) *rgbs; |
737 | int i; | 734 | int i; |
738 | 735 | ||
739 | rgbs = (struct rgb *)dev_priv->mode_reg.crtc_reg[nv_crtc->index].DAC; | 736 | rgbs = (struct rgb *)nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index].DAC; |
740 | for (i = 0; i < 256; i++) { | 737 | for (i = 0; i < 256; i++) { |
741 | rgbs[i].r = nv_crtc->lut.r[i] >> 8; | 738 | rgbs[i].r = nv_crtc->lut.r[i] >> 8; |
742 | rgbs[i].g = nv_crtc->lut.g[i] >> 8; | 739 | rgbs[i].g = nv_crtc->lut.g[i] >> 8; |
743 | rgbs[i].b = nv_crtc->lut.b[i] >> 8; | 740 | rgbs[i].b = nv_crtc->lut.b[i] >> 8; |
744 | } | 741 | } |
745 | 742 | ||
746 | nouveau_hw_load_state_palette(dev, nv_crtc->index, &dev_priv->mode_reg); | 743 | nouveau_hw_load_state_palette(dev, nv_crtc->index, &nv04_display(dev)->mode_reg); |
747 | } | 744 | } |
748 | 745 | ||
749 | static void | 746 | static void |
@@ -780,7 +777,7 @@ nv04_crtc_do_mode_set_base(struct drm_crtc *crtc, | |||
780 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); | 777 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
781 | struct drm_device *dev = crtc->dev; | 778 | struct drm_device *dev = crtc->dev; |
782 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 779 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
783 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 780 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
784 | struct drm_framebuffer *drm_fb; | 781 | struct drm_framebuffer *drm_fb; |
785 | struct nouveau_framebuffer *fb; | 782 | struct nouveau_framebuffer *fb; |
786 | int arb_burst, arb_lwm; | 783 | int arb_burst, arb_lwm; |
diff --git a/drivers/gpu/drm/nouveau/nv04_cursor.c b/drivers/gpu/drm/nouveau/nv04_cursor.c index aaf3de3bc816..62294b8712db 100644 --- a/drivers/gpu/drm/nouveau/nv04_cursor.c +++ b/drivers/gpu/drm/nouveau/nv04_cursor.c | |||
@@ -39,7 +39,7 @@ nv04_cursor_set_offset(struct nouveau_crtc *nv_crtc, uint32_t offset) | |||
39 | { | 39 | { |
40 | struct drm_device *dev = nv_crtc->base.dev; | 40 | struct drm_device *dev = nv_crtc->base.dev; |
41 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 41 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
42 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 42 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
43 | struct drm_crtc *crtc = &nv_crtc->base; | 43 | struct drm_crtc *crtc = &nv_crtc->base; |
44 | 44 | ||
45 | regp->CRTC[NV_CIO_CRE_HCUR_ADDR0_INDEX] = | 45 | regp->CRTC[NV_CIO_CRE_HCUR_ADDR0_INDEX] = |
diff --git a/drivers/gpu/drm/nouveau/nv04_dac.c b/drivers/gpu/drm/nouveau/nv04_dac.c index a1a2c2f33d53..32f516ffca75 100644 --- a/drivers/gpu/drm/nouveau/nv04_dac.c +++ b/drivers/gpu/drm/nouveau/nv04_dac.c | |||
@@ -407,11 +407,10 @@ static void nv04_dac_commit(struct drm_encoder *encoder) | |||
407 | void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable) | 407 | void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable) |
408 | { | 408 | { |
409 | struct drm_device *dev = encoder->dev; | 409 | struct drm_device *dev = encoder->dev; |
410 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
411 | struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; | 410 | struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; |
412 | 411 | ||
413 | if (nv_gf4_disp_arch(dev)) { | 412 | if (nv_gf4_disp_arch(dev)) { |
414 | uint32_t *dac_users = &dev_priv->dac_users[ffs(dcb->or) - 1]; | 413 | uint32_t *dac_users = &nv04_display(dev)->dac_users[ffs(dcb->or) - 1]; |
415 | int dacclk_off = NV_PRAMDAC_DACCLK + nv04_dac_output_offset(encoder); | 414 | int dacclk_off = NV_PRAMDAC_DACCLK + nv04_dac_output_offset(encoder); |
416 | uint32_t dacclk = NVReadRAMDAC(dev, 0, dacclk_off); | 415 | uint32_t dacclk = NVReadRAMDAC(dev, 0, dacclk_off); |
417 | 416 | ||
@@ -432,11 +431,11 @@ void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable) | |||
432 | * someone else. */ | 431 | * someone else. */ |
433 | bool nv04_dac_in_use(struct drm_encoder *encoder) | 432 | bool nv04_dac_in_use(struct drm_encoder *encoder) |
434 | { | 433 | { |
435 | struct drm_nouveau_private *dev_priv = encoder->dev->dev_private; | 434 | struct drm_device *dev = encoder->dev; |
436 | struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; | 435 | struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; |
437 | 436 | ||
438 | return nv_gf4_disp_arch(encoder->dev) && | 437 | return nv_gf4_disp_arch(encoder->dev) && |
439 | (dev_priv->dac_users[ffs(dcb->or) - 1] & ~(1 << dcb->index)); | 438 | (nv04_display(dev)->dac_users[ffs(dcb->or) - 1] & ~(1 << dcb->index)); |
440 | } | 439 | } |
441 | 440 | ||
442 | static void nv04_dac_dpms(struct drm_encoder *encoder, int mode) | 441 | static void nv04_dac_dpms(struct drm_encoder *encoder, int mode) |
diff --git a/drivers/gpu/drm/nouveau/nv04_dfp.c b/drivers/gpu/drm/nouveau/nv04_dfp.c index 823a1c5c0755..6d3a12fb8453 100644 --- a/drivers/gpu/drm/nouveau/nv04_dfp.c +++ b/drivers/gpu/drm/nouveau/nv04_dfp.c | |||
@@ -89,8 +89,7 @@ void nv04_dfp_bind_head(struct drm_device *dev, struct dcb_output *dcbent, | |||
89 | 89 | ||
90 | void nv04_dfp_disable(struct drm_device *dev, int head) | 90 | void nv04_dfp_disable(struct drm_device *dev, int head) |
91 | { | 91 | { |
92 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 92 | struct nv04_crtc_reg *crtcstate = nv04_display(dev)->mode_reg.crtc_reg; |
93 | struct nv04_crtc_reg *crtcstate = dev_priv->mode_reg.crtc_reg; | ||
94 | 93 | ||
95 | if (NVReadRAMDAC(dev, head, NV_PRAMDAC_FP_TG_CONTROL) & | 94 | if (NVReadRAMDAC(dev, head, NV_PRAMDAC_FP_TG_CONTROL) & |
96 | FP_TG_CONTROL_ON) { | 95 | FP_TG_CONTROL_ON) { |
@@ -111,14 +110,13 @@ void nv04_dfp_disable(struct drm_device *dev, int head) | |||
111 | void nv04_dfp_update_fp_control(struct drm_encoder *encoder, int mode) | 110 | void nv04_dfp_update_fp_control(struct drm_encoder *encoder, int mode) |
112 | { | 111 | { |
113 | struct drm_device *dev = encoder->dev; | 112 | struct drm_device *dev = encoder->dev; |
114 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
115 | struct drm_crtc *crtc; | 113 | struct drm_crtc *crtc; |
116 | struct nouveau_crtc *nv_crtc; | 114 | struct nouveau_crtc *nv_crtc; |
117 | uint32_t *fpc; | 115 | uint32_t *fpc; |
118 | 116 | ||
119 | if (mode == DRM_MODE_DPMS_ON) { | 117 | if (mode == DRM_MODE_DPMS_ON) { |
120 | nv_crtc = nouveau_crtc(encoder->crtc); | 118 | nv_crtc = nouveau_crtc(encoder->crtc); |
121 | fpc = &dev_priv->mode_reg.crtc_reg[nv_crtc->index].fp_control; | 119 | fpc = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index].fp_control; |
122 | 120 | ||
123 | if (is_fpc_off(*fpc)) { | 121 | if (is_fpc_off(*fpc)) { |
124 | /* using saved value is ok, as (is_digital && dpms_on && | 122 | /* using saved value is ok, as (is_digital && dpms_on && |
@@ -133,7 +131,7 @@ void nv04_dfp_update_fp_control(struct drm_encoder *encoder, int mode) | |||
133 | } else { | 131 | } else { |
134 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | 132 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
135 | nv_crtc = nouveau_crtc(crtc); | 133 | nv_crtc = nouveau_crtc(crtc); |
136 | fpc = &dev_priv->mode_reg.crtc_reg[nv_crtc->index].fp_control; | 134 | fpc = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index].fp_control; |
137 | 135 | ||
138 | nv_crtc->fp_users &= ~(1 << nouveau_encoder(encoder)->dcb->index); | 136 | nv_crtc->fp_users &= ~(1 << nouveau_encoder(encoder)->dcb->index); |
139 | if (!is_fpc_off(*fpc) && !nv_crtc->fp_users) { | 137 | if (!is_fpc_off(*fpc) && !nv_crtc->fp_users) { |
@@ -202,8 +200,7 @@ static bool nv04_dfp_mode_fixup(struct drm_encoder *encoder, | |||
202 | static void nv04_dfp_prepare_sel_clk(struct drm_device *dev, | 200 | static void nv04_dfp_prepare_sel_clk(struct drm_device *dev, |
203 | struct nouveau_encoder *nv_encoder, int head) | 201 | struct nouveau_encoder *nv_encoder, int head) |
204 | { | 202 | { |
205 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 203 | struct nv04_mode_state *state = &nv04_display(dev)->mode_reg; |
206 | struct nv04_mode_state *state = &dev_priv->mode_reg; | ||
207 | uint32_t bits1618 = nv_encoder->dcb->or & DCB_OUTPUT_A ? 0x10000 : 0x40000; | 204 | uint32_t bits1618 = nv_encoder->dcb->or & DCB_OUTPUT_A ? 0x10000 : 0x40000; |
208 | 205 | ||
209 | if (nv_encoder->dcb->location != DCB_LOC_ON_CHIP) | 206 | if (nv_encoder->dcb->location != DCB_LOC_ON_CHIP) |
@@ -233,8 +230,8 @@ static void nv04_dfp_prepare_sel_clk(struct drm_device *dev, | |||
233 | * and which bit-pair to use, is unclear on nv40 (for earlier cards, the fp table | 230 | * and which bit-pair to use, is unclear on nv40 (for earlier cards, the fp table |
234 | * entry has the necessary info) | 231 | * entry has the necessary info) |
235 | */ | 232 | */ |
236 | if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS && dev_priv->saved_reg.sel_clk & 0xf0) { | 233 | if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS && nv04_display(dev)->saved_reg.sel_clk & 0xf0) { |
237 | int shift = (dev_priv->saved_reg.sel_clk & 0x50) ? 0 : 1; | 234 | int shift = (nv04_display(dev)->saved_reg.sel_clk & 0x50) ? 0 : 1; |
238 | 235 | ||
239 | state->sel_clk &= ~0xf0; | 236 | state->sel_clk &= ~0xf0; |
240 | state->sel_clk |= (head ? 0x40 : 0x10) << shift; | 237 | state->sel_clk |= (head ? 0x40 : 0x10) << shift; |
@@ -246,9 +243,8 @@ static void nv04_dfp_prepare(struct drm_encoder *encoder) | |||
246 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 243 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
247 | struct drm_encoder_helper_funcs *helper = encoder->helper_private; | 244 | struct drm_encoder_helper_funcs *helper = encoder->helper_private; |
248 | struct drm_device *dev = encoder->dev; | 245 | struct drm_device *dev = encoder->dev; |
249 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
250 | int head = nouveau_crtc(encoder->crtc)->index; | 246 | int head = nouveau_crtc(encoder->crtc)->index; |
251 | struct nv04_crtc_reg *crtcstate = dev_priv->mode_reg.crtc_reg; | 247 | struct nv04_crtc_reg *crtcstate = nv04_display(dev)->mode_reg.crtc_reg; |
252 | uint8_t *cr_lcd = &crtcstate[head].CRTC[NV_CIO_CRE_LCD__INDEX]; | 248 | uint8_t *cr_lcd = &crtcstate[head].CRTC[NV_CIO_CRE_LCD__INDEX]; |
253 | uint8_t *cr_lcd_oth = &crtcstate[head ^ 1].CRTC[NV_CIO_CRE_LCD__INDEX]; | 249 | uint8_t *cr_lcd_oth = &crtcstate[head ^ 1].CRTC[NV_CIO_CRE_LCD__INDEX]; |
254 | 250 | ||
@@ -284,8 +280,8 @@ static void nv04_dfp_mode_set(struct drm_encoder *encoder, | |||
284 | struct drm_device *dev = encoder->dev; | 280 | struct drm_device *dev = encoder->dev; |
285 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 281 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
286 | struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); | 282 | struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); |
287 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 283 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
288 | struct nv04_crtc_reg *savep = &dev_priv->saved_reg.crtc_reg[nv_crtc->index]; | 284 | struct nv04_crtc_reg *savep = &nv04_display(dev)->saved_reg.crtc_reg[nv_crtc->index]; |
289 | struct nouveau_connector *nv_connector = nouveau_crtc_connector_get(nv_crtc); | 285 | struct nouveau_connector *nv_connector = nouveau_crtc_connector_get(nv_crtc); |
290 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 286 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
291 | struct drm_display_mode *output_mode = &nv_encoder->mode; | 287 | struct drm_display_mode *output_mode = &nv_encoder->mode; |
@@ -459,7 +455,7 @@ static void nv04_dfp_commit(struct drm_encoder *encoder) | |||
459 | 455 | ||
460 | /* update fp_control state for any changes made by scripts, | 456 | /* update fp_control state for any changes made by scripts, |
461 | * so correct value is written at DPMS on */ | 457 | * so correct value is written at DPMS on */ |
462 | dev_priv->mode_reg.crtc_reg[head].fp_control = | 458 | nv04_display(dev)->mode_reg.crtc_reg[head].fp_control = |
463 | NVReadRAMDAC(dev, head, NV_PRAMDAC_FP_TG_CONTROL); | 459 | NVReadRAMDAC(dev, head, NV_PRAMDAC_FP_TG_CONTROL); |
464 | 460 | ||
465 | /* This could use refinement for flatpanels, but it should work this way */ | 461 | /* This could use refinement for flatpanels, but it should work this way */ |
@@ -511,7 +507,6 @@ static void nv04_lvds_dpms(struct drm_encoder *encoder, int mode) | |||
511 | { | 507 | { |
512 | struct drm_device *dev = encoder->dev; | 508 | struct drm_device *dev = encoder->dev; |
513 | struct drm_crtc *crtc = encoder->crtc; | 509 | struct drm_crtc *crtc = encoder->crtc; |
514 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
515 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 510 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
516 | bool was_powersaving = is_powersaving_dpms(nv_encoder->last_dpms); | 511 | bool was_powersaving = is_powersaving_dpms(nv_encoder->last_dpms); |
517 | 512 | ||
@@ -549,10 +544,10 @@ static void nv04_lvds_dpms(struct drm_encoder *encoder, int mode) | |||
549 | if (mode == DRM_MODE_DPMS_ON) | 544 | if (mode == DRM_MODE_DPMS_ON) |
550 | nv04_dfp_prepare_sel_clk(dev, nv_encoder, nouveau_crtc(crtc)->index); | 545 | nv04_dfp_prepare_sel_clk(dev, nv_encoder, nouveau_crtc(crtc)->index); |
551 | else { | 546 | else { |
552 | dev_priv->mode_reg.sel_clk = NVReadRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK); | 547 | nv04_display(dev)->mode_reg.sel_clk = NVReadRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK); |
553 | dev_priv->mode_reg.sel_clk &= ~0xf0; | 548 | nv04_display(dev)->mode_reg.sel_clk &= ~0xf0; |
554 | } | 549 | } |
555 | NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, dev_priv->mode_reg.sel_clk); | 550 | NVWriteRAMDAC(dev, 0, NV_PRAMDAC_SEL_CLK, nv04_display(dev)->mode_reg.sel_clk); |
556 | } | 551 | } |
557 | 552 | ||
558 | static void nv04_tmds_dpms(struct drm_encoder *encoder, int mode) | 553 | static void nv04_tmds_dpms(struct drm_encoder *encoder, int mode) |
@@ -585,7 +580,6 @@ static void nv04_dfp_restore(struct drm_encoder *encoder) | |||
585 | { | 580 | { |
586 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 581 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
587 | struct drm_device *dev = encoder->dev; | 582 | struct drm_device *dev = encoder->dev; |
588 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
589 | int head = nv_encoder->restore.head; | 583 | int head = nv_encoder->restore.head; |
590 | 584 | ||
591 | if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS) { | 585 | if (nv_encoder->dcb->type == DCB_OUTPUT_LVDS) { |
@@ -599,7 +593,7 @@ static void nv04_dfp_restore(struct drm_encoder *encoder) | |||
599 | 593 | ||
600 | } else if (nv_encoder->dcb->type == DCB_OUTPUT_TMDS) { | 594 | } else if (nv_encoder->dcb->type == DCB_OUTPUT_TMDS) { |
601 | int clock = nouveau_hw_pllvals_to_clk | 595 | int clock = nouveau_hw_pllvals_to_clk |
602 | (&dev_priv->saved_reg.crtc_reg[head].pllvals); | 596 | (&nv04_display(dev)->saved_reg.crtc_reg[head].pllvals); |
603 | 597 | ||
604 | run_tmds_table(dev, nv_encoder->dcb, head, clock); | 598 | run_tmds_table(dev, nv_encoder->dcb, head, clock); |
605 | } | 599 | } |
diff --git a/drivers/gpu/drm/nouveau/nv04_display.c b/drivers/gpu/drm/nouveau/nv04_display.c index 2b7d23e8f27f..81947ea0f82d 100644 --- a/drivers/gpu/drm/nouveau/nv04_display.c +++ b/drivers/gpu/drm/nouveau/nv04_display.c | |||
@@ -61,10 +61,16 @@ nv04_display_create(struct drm_device *dev) | |||
61 | struct drm_connector *connector, *ct; | 61 | struct drm_connector *connector, *ct; |
62 | struct drm_encoder *encoder; | 62 | struct drm_encoder *encoder; |
63 | struct drm_crtc *crtc; | 63 | struct drm_crtc *crtc; |
64 | struct nv04_display *disp; | ||
64 | int i, ret; | 65 | int i, ret; |
65 | 66 | ||
66 | NV_DEBUG_KMS(dev, "\n"); | 67 | NV_DEBUG_KMS(dev, "\n"); |
67 | 68 | ||
69 | disp = kzalloc(sizeof(*disp), GFP_KERNEL); | ||
70 | dev_priv->engine.display.priv = disp; | ||
71 | if (!disp) | ||
72 | return -ENOMEM; | ||
73 | |||
68 | nouveau_hw_save_vga_fonts(dev, 1); | 74 | nouveau_hw_save_vga_fonts(dev, 1); |
69 | 75 | ||
70 | nv04_crtc_create(dev, 0); | 76 | nv04_crtc_create(dev, 0); |
@@ -128,6 +134,8 @@ nv04_display_create(struct drm_device *dev) | |||
128 | void | 134 | void |
129 | nv04_display_destroy(struct drm_device *dev) | 135 | nv04_display_destroy(struct drm_device *dev) |
130 | { | 136 | { |
137 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
138 | struct nv04_display *disp = nv04_display(dev); | ||
131 | struct drm_encoder *encoder; | 139 | struct drm_encoder *encoder; |
132 | struct drm_crtc *crtc; | 140 | struct drm_crtc *crtc; |
133 | 141 | ||
@@ -156,6 +164,9 @@ nv04_display_destroy(struct drm_device *dev) | |||
156 | crtc->funcs->restore(crtc); | 164 | crtc->funcs->restore(crtc); |
157 | 165 | ||
158 | nouveau_hw_save_vga_fonts(dev, 0); | 166 | nouveau_hw_save_vga_fonts(dev, 0); |
167 | |||
168 | dev_priv->engine.display.priv = NULL; | ||
169 | kfree(disp); | ||
159 | } | 170 | } |
160 | 171 | ||
161 | int | 172 | int |
diff --git a/drivers/gpu/drm/nouveau/nv04_display.h b/drivers/gpu/drm/nouveau/nv04_display.h new file mode 100644 index 000000000000..29dc4f727f7e --- /dev/null +++ b/drivers/gpu/drm/nouveau/nv04_display.h | |||
@@ -0,0 +1,121 @@ | |||
1 | #ifndef __NV04_DISPLAY_H__ | ||
2 | #define __NV04_DISPLAY_H__ | ||
3 | |||
4 | enum nv04_fp_display_regs { | ||
5 | FP_DISPLAY_END, | ||
6 | FP_TOTAL, | ||
7 | FP_CRTC, | ||
8 | FP_SYNC_START, | ||
9 | FP_SYNC_END, | ||
10 | FP_VALID_START, | ||
11 | FP_VALID_END | ||
12 | }; | ||
13 | |||
14 | struct nv04_crtc_reg { | ||
15 | unsigned char MiscOutReg; | ||
16 | uint8_t CRTC[0xa0]; | ||
17 | uint8_t CR58[0x10]; | ||
18 | uint8_t Sequencer[5]; | ||
19 | uint8_t Graphics[9]; | ||
20 | uint8_t Attribute[21]; | ||
21 | unsigned char DAC[768]; | ||
22 | |||
23 | /* PCRTC regs */ | ||
24 | uint32_t fb_start; | ||
25 | uint32_t crtc_cfg; | ||
26 | uint32_t cursor_cfg; | ||
27 | uint32_t gpio_ext; | ||
28 | uint32_t crtc_830; | ||
29 | uint32_t crtc_834; | ||
30 | uint32_t crtc_850; | ||
31 | uint32_t crtc_eng_ctrl; | ||
32 | |||
33 | /* PRAMDAC regs */ | ||
34 | uint32_t nv10_cursync; | ||
35 | struct nouveau_pll_vals pllvals; | ||
36 | uint32_t ramdac_gen_ctrl; | ||
37 | uint32_t ramdac_630; | ||
38 | uint32_t ramdac_634; | ||
39 | uint32_t tv_setup; | ||
40 | uint32_t tv_vtotal; | ||
41 | uint32_t tv_vskew; | ||
42 | uint32_t tv_vsync_delay; | ||
43 | uint32_t tv_htotal; | ||
44 | uint32_t tv_hskew; | ||
45 | uint32_t tv_hsync_delay; | ||
46 | uint32_t tv_hsync_delay2; | ||
47 | uint32_t fp_horiz_regs[7]; | ||
48 | uint32_t fp_vert_regs[7]; | ||
49 | uint32_t dither; | ||
50 | uint32_t fp_control; | ||
51 | uint32_t dither_regs[6]; | ||
52 | uint32_t fp_debug_0; | ||
53 | uint32_t fp_debug_1; | ||
54 | uint32_t fp_debug_2; | ||
55 | uint32_t fp_margin_color; | ||
56 | uint32_t ramdac_8c0; | ||
57 | uint32_t ramdac_a20; | ||
58 | uint32_t ramdac_a24; | ||
59 | uint32_t ramdac_a34; | ||
60 | uint32_t ctv_regs[38]; | ||
61 | }; | ||
62 | |||
63 | struct nv04_output_reg { | ||
64 | uint32_t output; | ||
65 | int head; | ||
66 | }; | ||
67 | |||
68 | struct nv04_mode_state { | ||
69 | struct nv04_crtc_reg crtc_reg[2]; | ||
70 | uint32_t pllsel; | ||
71 | uint32_t sel_clk; | ||
72 | }; | ||
73 | |||
74 | struct nv04_display { | ||
75 | struct nv04_mode_state mode_reg; | ||
76 | struct nv04_mode_state saved_reg; | ||
77 | uint32_t saved_vga_font[4][16384]; | ||
78 | uint32_t dac_users[4]; | ||
79 | }; | ||
80 | |||
81 | static inline struct nv04_display * | ||
82 | nv04_display(struct drm_device *dev) | ||
83 | { | ||
84 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
85 | return dev_priv->engine.display.priv; | ||
86 | } | ||
87 | |||
88 | /* nv04_display.c */ | ||
89 | int nv04_display_early_init(struct drm_device *); | ||
90 | void nv04_display_late_takedown(struct drm_device *); | ||
91 | int nv04_display_create(struct drm_device *); | ||
92 | void nv04_display_destroy(struct drm_device *); | ||
93 | int nv04_display_init(struct drm_device *); | ||
94 | void nv04_display_fini(struct drm_device *); | ||
95 | |||
96 | /* nv04_crtc.c */ | ||
97 | int nv04_crtc_create(struct drm_device *, int index); | ||
98 | |||
99 | /* nv04_dac.c */ | ||
100 | int nv04_dac_create(struct drm_connector *, struct dcb_output *); | ||
101 | uint32_t nv17_dac_sample_load(struct drm_encoder *encoder); | ||
102 | int nv04_dac_output_offset(struct drm_encoder *encoder); | ||
103 | void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable); | ||
104 | bool nv04_dac_in_use(struct drm_encoder *encoder); | ||
105 | |||
106 | /* nv04_dfp.c */ | ||
107 | int nv04_dfp_create(struct drm_connector *, struct dcb_output *); | ||
108 | int nv04_dfp_get_bound_head(struct drm_device *dev, struct dcb_output *dcbent); | ||
109 | void nv04_dfp_bind_head(struct drm_device *dev, struct dcb_output *dcbent, | ||
110 | int head, bool dl); | ||
111 | void nv04_dfp_disable(struct drm_device *dev, int head); | ||
112 | void nv04_dfp_update_fp_control(struct drm_encoder *encoder, int mode); | ||
113 | |||
114 | /* nv04_tv.c */ | ||
115 | int nv04_tv_identify(struct drm_device *dev, int i2c_index); | ||
116 | int nv04_tv_create(struct drm_connector *, struct dcb_output *); | ||
117 | |||
118 | /* nv17_tv.c */ | ||
119 | int nv17_tv_create(struct drm_connector *, struct dcb_output *); | ||
120 | |||
121 | #endif | ||
diff --git a/drivers/gpu/drm/nouveau/nv04_tv.c b/drivers/gpu/drm/nouveau/nv04_tv.c index 5927391373e9..5f5c25d77343 100644 --- a/drivers/gpu/drm/nouveau/nv04_tv.c +++ b/drivers/gpu/drm/nouveau/nv04_tv.c | |||
@@ -65,8 +65,7 @@ static void nv04_tv_dpms(struct drm_encoder *encoder, int mode) | |||
65 | { | 65 | { |
66 | struct drm_device *dev = encoder->dev; | 66 | struct drm_device *dev = encoder->dev; |
67 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); | 67 | struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder); |
68 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 68 | struct nv04_mode_state *state = &nv04_display(dev)->mode_reg; |
69 | struct nv04_mode_state *state = &dev_priv->mode_reg; | ||
70 | uint8_t crtc1A; | 69 | uint8_t crtc1A; |
71 | 70 | ||
72 | NV_INFO(dev, "Setting dpms mode %d on TV encoder (output %d)\n", | 71 | NV_INFO(dev, "Setting dpms mode %d on TV encoder (output %d)\n", |
@@ -94,8 +93,7 @@ static void nv04_tv_dpms(struct drm_encoder *encoder, int mode) | |||
94 | 93 | ||
95 | static void nv04_tv_bind(struct drm_device *dev, int head, bool bind) | 94 | static void nv04_tv_bind(struct drm_device *dev, int head, bool bind) |
96 | { | 95 | { |
97 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 96 | struct nv04_crtc_reg *state = &nv04_display(dev)->mode_reg.crtc_reg[head]; |
98 | struct nv04_crtc_reg *state = &dev_priv->mode_reg.crtc_reg[head]; | ||
99 | 97 | ||
100 | state->tv_setup = 0; | 98 | state->tv_setup = 0; |
101 | 99 | ||
@@ -133,9 +131,8 @@ static void nv04_tv_mode_set(struct drm_encoder *encoder, | |||
133 | struct drm_display_mode *adjusted_mode) | 131 | struct drm_display_mode *adjusted_mode) |
134 | { | 132 | { |
135 | struct drm_device *dev = encoder->dev; | 133 | struct drm_device *dev = encoder->dev; |
136 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
137 | struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); | 134 | struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc); |
138 | struct nv04_crtc_reg *regp = &dev_priv->mode_reg.crtc_reg[nv_crtc->index]; | 135 | struct nv04_crtc_reg *regp = &nv04_display(dev)->mode_reg.crtc_reg[nv_crtc->index]; |
139 | 136 | ||
140 | regp->tv_htotal = adjusted_mode->htotal; | 137 | regp->tv_htotal = adjusted_mode->htotal; |
141 | regp->tv_vtotal = adjusted_mode->vtotal; | 138 | regp->tv_vtotal = adjusted_mode->vtotal; |
diff --git a/drivers/gpu/drm/nouveau/nv17_tv.c b/drivers/gpu/drm/nouveau/nv17_tv.c index 54ff394e005b..5d1f6f6de257 100644 --- a/drivers/gpu/drm/nouveau/nv17_tv.c +++ b/drivers/gpu/drm/nouveau/nv17_tv.c | |||
@@ -395,7 +395,7 @@ static void nv17_tv_prepare(struct drm_encoder *encoder) | |||
395 | struct drm_encoder_helper_funcs *helper = encoder->helper_private; | 395 | struct drm_encoder_helper_funcs *helper = encoder->helper_private; |
396 | struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder); | 396 | struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder); |
397 | int head = nouveau_crtc(encoder->crtc)->index; | 397 | int head = nouveau_crtc(encoder->crtc)->index; |
398 | uint8_t *cr_lcd = &dev_priv->mode_reg.crtc_reg[head].CRTC[ | 398 | uint8_t *cr_lcd = &nv04_display(dev)->mode_reg.crtc_reg[head].CRTC[ |
399 | NV_CIO_CRE_LCD__INDEX]; | 399 | NV_CIO_CRE_LCD__INDEX]; |
400 | uint32_t dacclk_off = NV_PRAMDAC_DACCLK + | 400 | uint32_t dacclk_off = NV_PRAMDAC_DACCLK + |
401 | nv04_dac_output_offset(encoder); | 401 | nv04_dac_output_offset(encoder); |
@@ -456,7 +456,7 @@ static void nv17_tv_mode_set(struct drm_encoder *encoder, | |||
456 | struct drm_device *dev = encoder->dev; | 456 | struct drm_device *dev = encoder->dev; |
457 | struct drm_nouveau_private *dev_priv = dev->dev_private; | 457 | struct drm_nouveau_private *dev_priv = dev->dev_private; |
458 | int head = nouveau_crtc(encoder->crtc)->index; | 458 | int head = nouveau_crtc(encoder->crtc)->index; |
459 | struct nv04_crtc_reg *regs = &dev_priv->mode_reg.crtc_reg[head]; | 459 | struct nv04_crtc_reg *regs = &nv04_display(dev)->mode_reg.crtc_reg[head]; |
460 | struct nv17_tv_state *tv_regs = &to_tv_enc(encoder)->state; | 460 | struct nv17_tv_state *tv_regs = &to_tv_enc(encoder)->state; |
461 | struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder); | 461 | struct nv17_tv_norm_params *tv_norm = get_tv_norm(encoder); |
462 | int i; | 462 | int i; |
diff --git a/drivers/gpu/drm/nouveau/nv17_tv_modes.c b/drivers/gpu/drm/nouveau/nv17_tv_modes.c index 4d1d29f60307..381d388def3a 100644 --- a/drivers/gpu/drm/nouveau/nv17_tv_modes.c +++ b/drivers/gpu/drm/nouveau/nv17_tv_modes.c | |||
@@ -543,10 +543,9 @@ void nv17_tv_update_rescaler(struct drm_encoder *encoder) | |||
543 | void nv17_ctv_update_rescaler(struct drm_encoder *encoder) | 543 | void nv17_ctv_update_rescaler(struct drm_encoder *encoder) |
544 | { | 544 | { |
545 | struct drm_device *dev = encoder->dev; | 545 | struct drm_device *dev = encoder->dev; |
546 | struct drm_nouveau_private *dev_priv = dev->dev_private; | ||
547 | struct nv17_tv_encoder *tv_enc = to_tv_enc(encoder); | 546 | struct nv17_tv_encoder *tv_enc = to_tv_enc(encoder); |
548 | int head = nouveau_crtc(encoder->crtc)->index; | 547 | int head = nouveau_crtc(encoder->crtc)->index; |
549 | struct nv04_crtc_reg *regs = &dev_priv->mode_reg.crtc_reg[head]; | 548 | struct nv04_crtc_reg *regs = &nv04_display(dev)->mode_reg.crtc_reg[head]; |
550 | struct drm_display_mode *crtc_mode = &encoder->crtc->mode; | 549 | struct drm_display_mode *crtc_mode = &encoder->crtc->mode; |
551 | struct drm_display_mode *output_mode = | 550 | struct drm_display_mode *output_mode = |
552 | &get_tv_norm(encoder)->ctv_enc_mode.mode; | 551 | &get_tv_norm(encoder)->ctv_enc_mode.mode; |