aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/gma500/gma_display.c
diff options
context:
space:
mode:
authorPatrik Jakobsson <patrik.r.jakobsson@gmail.com>2013-07-12 09:30:56 -0400
committerPatrik Jakobsson <patrik.r.jakobsson@gmail.com>2013-07-23 19:47:30 -0400
commit2e775700a297982a3ffbfe72935982b6fb51e015 (patch)
tree0b6cb2a504966997db9f95c715beab4a9e184676 /drivers/gpu/drm/gma500/gma_display.c
parentc9d4959000c0b11c4265af820434b868c4066e0e (diff)
drm/gma500: Add generic crtc save/restore funcs
Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/gma500/gma_display.c')
-rw-r--r--drivers/gpu/drm/gma500/gma_display.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index 67d86d8fcd4d..cca40c0b64e4 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -519,6 +519,111 @@ void gma_crtc_destroy(struct drm_crtc *crtc)
519 kfree(psb_intel_crtc); 519 kfree(psb_intel_crtc);
520} 520}
521 521
522/**
523 * Save HW states of given crtc
524 */
525void gma_crtc_save(struct drm_crtc *crtc)
526{
527 struct drm_device *dev = crtc->dev;
528 struct drm_psb_private *dev_priv = dev->dev_private;
529 struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
530 struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state;
531 const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe];
532 uint32_t palette_reg;
533 int i;
534
535 if (!crtc_state) {
536 dev_err(dev->dev, "No CRTC state found\n");
537 return;
538 }
539
540 crtc_state->saveDSPCNTR = REG_READ(map->cntr);
541 crtc_state->savePIPECONF = REG_READ(map->conf);
542 crtc_state->savePIPESRC = REG_READ(map->src);
543 crtc_state->saveFP0 = REG_READ(map->fp0);
544 crtc_state->saveFP1 = REG_READ(map->fp1);
545 crtc_state->saveDPLL = REG_READ(map->dpll);
546 crtc_state->saveHTOTAL = REG_READ(map->htotal);
547 crtc_state->saveHBLANK = REG_READ(map->hblank);
548 crtc_state->saveHSYNC = REG_READ(map->hsync);
549 crtc_state->saveVTOTAL = REG_READ(map->vtotal);
550 crtc_state->saveVBLANK = REG_READ(map->vblank);
551 crtc_state->saveVSYNC = REG_READ(map->vsync);
552 crtc_state->saveDSPSTRIDE = REG_READ(map->stride);
553
554 /* NOTE: DSPSIZE DSPPOS only for psb */
555 crtc_state->saveDSPSIZE = REG_READ(map->size);
556 crtc_state->saveDSPPOS = REG_READ(map->pos);
557
558 crtc_state->saveDSPBASE = REG_READ(map->base);
559
560 palette_reg = map->palette;
561 for (i = 0; i < 256; ++i)
562 crtc_state->savePalette[i] = REG_READ(palette_reg + (i << 2));
563}
564
565/**
566 * Restore HW states of given crtc
567 */
568void gma_crtc_restore(struct drm_crtc *crtc)
569{
570 struct drm_device *dev = crtc->dev;
571 struct drm_psb_private *dev_priv = dev->dev_private;
572 struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
573 struct psb_intel_crtc_state *crtc_state = psb_intel_crtc->crtc_state;
574 const struct psb_offset *map = &dev_priv->regmap[psb_intel_crtc->pipe];
575 uint32_t palette_reg;
576 int i;
577
578 if (!crtc_state) {
579 dev_err(dev->dev, "No crtc state\n");
580 return;
581 }
582
583 if (crtc_state->saveDPLL & DPLL_VCO_ENABLE) {
584 REG_WRITE(map->dpll,
585 crtc_state->saveDPLL & ~DPLL_VCO_ENABLE);
586 REG_READ(map->dpll);
587 udelay(150);
588 }
589
590 REG_WRITE(map->fp0, crtc_state->saveFP0);
591 REG_READ(map->fp0);
592
593 REG_WRITE(map->fp1, crtc_state->saveFP1);
594 REG_READ(map->fp1);
595
596 REG_WRITE(map->dpll, crtc_state->saveDPLL);
597 REG_READ(map->dpll);
598 udelay(150);
599
600 REG_WRITE(map->htotal, crtc_state->saveHTOTAL);
601 REG_WRITE(map->hblank, crtc_state->saveHBLANK);
602 REG_WRITE(map->hsync, crtc_state->saveHSYNC);
603 REG_WRITE(map->vtotal, crtc_state->saveVTOTAL);
604 REG_WRITE(map->vblank, crtc_state->saveVBLANK);
605 REG_WRITE(map->vsync, crtc_state->saveVSYNC);
606 REG_WRITE(map->stride, crtc_state->saveDSPSTRIDE);
607
608 REG_WRITE(map->size, crtc_state->saveDSPSIZE);
609 REG_WRITE(map->pos, crtc_state->saveDSPPOS);
610
611 REG_WRITE(map->src, crtc_state->savePIPESRC);
612 REG_WRITE(map->base, crtc_state->saveDSPBASE);
613 REG_WRITE(map->conf, crtc_state->savePIPECONF);
614
615 gma_wait_for_vblank(dev);
616
617 REG_WRITE(map->cntr, crtc_state->saveDSPCNTR);
618 REG_WRITE(map->base, crtc_state->saveDSPBASE);
619
620 gma_wait_for_vblank(dev);
621
622 palette_reg = map->palette;
623 for (i = 0; i < 256; ++i)
624 REG_WRITE(palette_reg + (i << 2), crtc_state->savePalette[i]);
625}
626
522void gma_encoder_prepare(struct drm_encoder *encoder) 627void gma_encoder_prepare(struct drm_encoder *encoder)
523{ 628{
524 struct drm_encoder_helper_funcs *encoder_funcs = 629 struct drm_encoder_helper_funcs *encoder_funcs =