drm/radeon: split page flip and pending callback
authorChristian König <christian.koenig@amd.com>
Tue, 27 May 2014 14:49:20 +0000 (16:49 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 2 Jun 2014 14:25:11 +0000 (10:25 -0400)
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/evergreen.c
drivers/gpu/drm/radeon/r100.c
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_asic.c
drivers/gpu/drm/radeon/radeon_asic.h
drivers/gpu/drm/radeon/radeon_display.c
drivers/gpu/drm/radeon/rs600.c
drivers/gpu/drm/radeon/rv770.c

index ec31a82208367c74c0fcdf9c8df394283cda1af7..336f0a56edce42b489f318648f783e669d407b0e 100644 (file)
@@ -1313,7 +1313,7 @@ void dce4_wait_for_vblank(struct radeon_device *rdev, int crtc)
  * double buffered update to take place.
  * Returns the current update pending status.
  */
-u32 evergreen_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
+void evergreen_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
 {
        struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id];
        u32 tmp = RREG32(EVERGREEN_GRPH_UPDATE + radeon_crtc->crtc_offset);
@@ -1345,9 +1345,23 @@ u32 evergreen_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
        /* Unlock the lock, so double-buffering can take place inside vblank */
        tmp &= ~EVERGREEN_GRPH_UPDATE_LOCK;
        WREG32(EVERGREEN_GRPH_UPDATE + radeon_crtc->crtc_offset, tmp);
+}
+
+/**
+ * evergreen_page_flip_pending - check if page flip is still pending
+ *
+ * @rdev: radeon_device pointer
+ * @crtc_id: crtc to check
+ *
+ * Returns the current update pending status.
+ */
+bool evergreen_page_flip_pending(struct radeon_device *rdev, int crtc_id)
+{
+       struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id];
 
        /* Return current update_pending status: */
-       return RREG32(EVERGREEN_GRPH_UPDATE + radeon_crtc->crtc_offset) & EVERGREEN_GRPH_SURFACE_UPDATE_PENDING;
+       return !!(RREG32(EVERGREEN_GRPH_UPDATE + radeon_crtc->crtc_offset) &
+               EVERGREEN_GRPH_SURFACE_UPDATE_PENDING);
 }
 
 /* get temperature in millidegrees */
index 840651f3361016ac5ee491d7b5f4b4bfb58830e4..52548f7bbb5ac622854f10974ed08467f8a7c14b 100644 (file)
@@ -152,9 +152,8 @@ void r100_wait_for_vblank(struct radeon_device *rdev, int crtc)
  * During vblank we take the crtc lock and wait for the update_pending
  * bit to go high, when it does, we release the lock, and allow the
  * double buffered update to take place.
- * Returns the current update pending status.
  */
-u32 r100_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
+void r100_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
 {
        struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id];
        u32 tmp = ((u32)crtc_base) | RADEON_CRTC_OFFSET__OFFSET_LOCK;
@@ -176,8 +175,24 @@ u32 r100_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
        tmp &= ~RADEON_CRTC_OFFSET__OFFSET_LOCK;
        WREG32(RADEON_CRTC_OFFSET + radeon_crtc->crtc_offset, tmp);
 
+}
+
+/**
+ * r100_page_flip_pending - check if page flip is still pending
+ *
+ * @rdev: radeon_device pointer
+ * @crtc_id: crtc to check
+ *
+ * Check if the last pagefilp is still pending (r1xx-r4xx).
+ * Returns the current update pending status.
+ */
+bool r100_page_flip_pending(struct radeon_device *rdev, int crtc_id)
+{
+       struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id];
+
        /* Return current update_pending status: */
-       return RREG32(RADEON_CRTC_OFFSET + radeon_crtc->crtc_offset) & RADEON_CRTC_OFFSET__GUI_TRIG_OFFSET;
+       return !!(RREG32(RADEON_CRTC_OFFSET + radeon_crtc->crtc_offset) &
+               RADEON_CRTC_OFFSET__GUI_TRIG_OFFSET);
 }
 
 /**
index 2b919afd7d4cb8e22ffba9409991bbd4b9c8688c..4ae304d7e9321e8e4fa2f8d30a3d1e0ba32b76b8 100644 (file)
@@ -1881,7 +1881,8 @@ struct radeon_asic {
        } dpm;
        /* pageflipping */
        struct {
-               u32 (*page_flip)(struct radeon_device *rdev, int crtc, u64 crtc_base);
+               void (*page_flip)(struct radeon_device *rdev, int crtc, u64 crtc_base);
+               bool (*page_flip_pending)(struct radeon_device *rdev, int crtc);
        } pflip;
 };
 
@@ -2741,6 +2742,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
 #define radeon_pm_init_profile(rdev) (rdev)->asic->pm.init_profile((rdev))
 #define radeon_pm_get_dynpm_state(rdev) (rdev)->asic->pm.get_dynpm_state((rdev))
 #define radeon_page_flip(rdev, crtc, base) (rdev)->asic->pflip.page_flip((rdev), (crtc), (base))
+#define radeon_page_flip_pending(rdev, crtc) (rdev)->asic->pflip.page_flip_pending((rdev), (crtc))
 #define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc))
 #define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev))
 #define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev))
index cb7a0eafadfc62199b4af4ba40bd68730dbc8f91..d8e1587d89cf1c2fb7f5257a315ce7b47e8d1769 100644 (file)
@@ -249,6 +249,7 @@ static struct radeon_asic r100_asic = {
        },
        .pflip = {
                .page_flip = &r100_page_flip,
+               .page_flip_pending = &r100_page_flip_pending,
        },
 };
 
@@ -314,6 +315,7 @@ static struct radeon_asic r200_asic = {
        },
        .pflip = {
                .page_flip = &r100_page_flip,
+               .page_flip_pending = &r100_page_flip_pending,
        },
 };
 
@@ -393,6 +395,7 @@ static struct radeon_asic r300_asic = {
        },
        .pflip = {
                .page_flip = &r100_page_flip,
+               .page_flip_pending = &r100_page_flip_pending,
        },
 };
 
@@ -458,6 +461,7 @@ static struct radeon_asic r300_asic_pcie = {
        },
        .pflip = {
                .page_flip = &r100_page_flip,
+               .page_flip_pending = &r100_page_flip_pending,
        },
 };
 
@@ -523,6 +527,7 @@ static struct radeon_asic r420_asic = {
        },
        .pflip = {
                .page_flip = &r100_page_flip,
+               .page_flip_pending = &r100_page_flip_pending,
        },
 };
 
@@ -588,6 +593,7 @@ static struct radeon_asic rs400_asic = {
        },
        .pflip = {
                .page_flip = &r100_page_flip,
+               .page_flip_pending = &r100_page_flip_pending,
        },
 };
 
@@ -655,6 +661,7 @@ static struct radeon_asic rs600_asic = {
        },
        .pflip = {
                .page_flip = &rs600_page_flip,
+               .page_flip_pending = &rs600_page_flip_pending,
        },
 };
 
@@ -722,6 +729,7 @@ static struct radeon_asic rs690_asic = {
        },
        .pflip = {
                .page_flip = &rs600_page_flip,
+               .page_flip_pending = &rs600_page_flip_pending,
        },
 };
 
@@ -787,6 +795,7 @@ static struct radeon_asic rv515_asic = {
        },
        .pflip = {
                .page_flip = &rs600_page_flip,
+               .page_flip_pending = &rs600_page_flip_pending,
        },
 };
 
@@ -852,6 +861,7 @@ static struct radeon_asic r520_asic = {
        },
        .pflip = {
                .page_flip = &rs600_page_flip,
+               .page_flip_pending = &rs600_page_flip_pending,
        },
 };
 
@@ -949,6 +959,7 @@ static struct radeon_asic r600_asic = {
        },
        .pflip = {
                .page_flip = &rs600_page_flip,
+               .page_flip_pending = &rs600_page_flip_pending,
        },
 };
 
@@ -1038,6 +1049,7 @@ static struct radeon_asic rv6xx_asic = {
        },
        .pflip = {
                .page_flip = &rs600_page_flip,
+               .page_flip_pending = &rs600_page_flip_pending,
        },
 };
 
@@ -1127,6 +1139,7 @@ static struct radeon_asic rs780_asic = {
        },
        .pflip = {
                .page_flip = &rs600_page_flip,
+               .page_flip_pending = &rs600_page_flip_pending,
        },
 };
 
@@ -1231,6 +1244,7 @@ static struct radeon_asic rv770_asic = {
        },
        .pflip = {
                .page_flip = &rv770_page_flip,
+               .page_flip_pending = &rv770_page_flip_pending,
        },
 };
 
@@ -1348,6 +1362,7 @@ static struct radeon_asic evergreen_asic = {
        },
        .pflip = {
                .page_flip = &evergreen_page_flip,
+               .page_flip_pending = &evergreen_page_flip_pending,
        },
 };
 
@@ -1438,6 +1453,7 @@ static struct radeon_asic sumo_asic = {
        },
        .pflip = {
                .page_flip = &evergreen_page_flip,
+               .page_flip_pending = &evergreen_page_flip_pending,
        },
 };
 
@@ -1529,6 +1545,7 @@ static struct radeon_asic btc_asic = {
        },
        .pflip = {
                .page_flip = &evergreen_page_flip,
+               .page_flip_pending = &evergreen_page_flip_pending,
        },
 };
 
@@ -1671,6 +1688,7 @@ static struct radeon_asic cayman_asic = {
        },
        .pflip = {
                .page_flip = &evergreen_page_flip,
+               .page_flip_pending = &evergreen_page_flip_pending,
        },
 };
 
@@ -1770,6 +1788,7 @@ static struct radeon_asic trinity_asic = {
        },
        .pflip = {
                .page_flip = &evergreen_page_flip,
+               .page_flip_pending = &evergreen_page_flip_pending,
        },
 };
 
@@ -1899,6 +1918,7 @@ static struct radeon_asic si_asic = {
        },
        .pflip = {
                .page_flip = &evergreen_page_flip,
+               .page_flip_pending = &evergreen_page_flip_pending,
        },
 };
 
@@ -2060,6 +2080,7 @@ static struct radeon_asic ci_asic = {
        },
        .pflip = {
                .page_flip = &evergreen_page_flip,
+               .page_flip_pending = &evergreen_page_flip_pending,
        },
 };
 
@@ -2163,6 +2184,7 @@ static struct radeon_asic kv_asic = {
        },
        .pflip = {
                .page_flip = &evergreen_page_flip,
+               .page_flip_pending = &evergreen_page_flip_pending,
        },
 };
 
index 953607d69eb1733ebd53892693ef87ded5926f12..0eab015b2cfb89e472ec1377b5dc1a4ad363003a 100644 (file)
@@ -135,7 +135,9 @@ extern void r100_pm_prepare(struct radeon_device *rdev);
 extern void r100_pm_finish(struct radeon_device *rdev);
 extern void r100_pm_init_profile(struct radeon_device *rdev);
 extern void r100_pm_get_dynpm_state(struct radeon_device *rdev);
-extern u32 r100_page_flip(struct radeon_device *rdev, int crtc, u64 crtc_base);
+extern void r100_page_flip(struct radeon_device *rdev, int crtc,
+                          u64 crtc_base);
+extern bool r100_page_flip_pending(struct radeon_device *rdev, int crtc);
 extern void r100_wait_for_vblank(struct radeon_device *rdev, int crtc);
 extern int r100_mc_wait_for_idle(struct radeon_device *rdev);
 
@@ -239,7 +241,9 @@ void rs600_hpd_set_polarity(struct radeon_device *rdev,
 extern void rs600_pm_misc(struct radeon_device *rdev);
 extern void rs600_pm_prepare(struct radeon_device *rdev);
 extern void rs600_pm_finish(struct radeon_device *rdev);
-extern u32 rs600_page_flip(struct radeon_device *rdev, int crtc, u64 crtc_base);
+extern void rs600_page_flip(struct radeon_device *rdev, int crtc,
+                           u64 crtc_base);
+extern bool rs600_page_flip_pending(struct radeon_device *rdev, int crtc);
 void rs600_set_safe_registers(struct radeon_device *rdev);
 extern void avivo_wait_for_vblank(struct radeon_device *rdev, int crtc);
 extern int rs600_mc_wait_for_idle(struct radeon_device *rdev);
@@ -448,7 +452,8 @@ void rv770_fini(struct radeon_device *rdev);
 int rv770_suspend(struct radeon_device *rdev);
 int rv770_resume(struct radeon_device *rdev);
 void rv770_pm_misc(struct radeon_device *rdev);
-u32 rv770_page_flip(struct radeon_device *rdev, int crtc, u64 crtc_base);
+void rv770_page_flip(struct radeon_device *rdev, int crtc, u64 crtc_base);
+bool rv770_page_flip_pending(struct radeon_device *rdev, int crtc);
 void r700_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc);
 void r700_cp_stop(struct radeon_device *rdev);
 void r700_cp_fini(struct radeon_device *rdev);
@@ -516,7 +521,9 @@ extern void sumo_pm_init_profile(struct radeon_device *rdev);
 extern void btc_pm_init_profile(struct radeon_device *rdev);
 int sumo_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk);
 int evergreen_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk);
-extern u32 evergreen_page_flip(struct radeon_device *rdev, int crtc, u64 crtc_base);
+extern void evergreen_page_flip(struct radeon_device *rdev, int crtc,
+                               u64 crtc_base);
+extern bool evergreen_page_flip_pending(struct radeon_device *rdev, int crtc);
 extern void dce4_wait_for_vblank(struct radeon_device *rdev, int crtc);
 void evergreen_disable_interrupt_state(struct radeon_device *rdev);
 int evergreen_mc_wait_for_idle(struct radeon_device *rdev);
index d597d08bdaaaacee48059ce8cf38771ff25ec9cf..c52c18246ed73b842649fe3eadc002fcda4f41c8 100644 (file)
@@ -294,7 +294,8 @@ void radeon_crtc_handle_flip(struct radeon_device *rdev, int crtc_id)
        /* New pageflip, or just completion of a previous one? */
        if (!radeon_crtc->deferred_flip_completion) {
                /* do the flip (mmio) */
-               update_pending = radeon_page_flip(rdev, crtc_id, work->new_crtc_base);
+               radeon_page_flip(rdev, crtc_id, work->new_crtc_base);
+               update_pending = radeon_page_flip_pending(rdev, crtc_id);
        } else {
                /* This is just a completion of a flip queued in crtc
                 * at last invocation. Make sure we go directly to
index e005bd74a8079658d8e0c047f2b64ce7c11678b1..9922ee5bd497514e444eb5bdf5438728945f4282 100644 (file)
@@ -109,7 +109,7 @@ void avivo_wait_for_vblank(struct radeon_device *rdev, int crtc)
        }
 }
 
-u32 rs600_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
+void rs600_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
 {
        struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id];
        u32 tmp = RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset);
@@ -136,9 +136,15 @@ u32 rs600_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
        /* Unlock the lock, so double-buffering can take place inside vblank */
        tmp &= ~AVIVO_D1GRPH_UPDATE_LOCK;
        WREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset, tmp);
+}
+
+bool rs600_page_flip_pending(struct radeon_device *rdev, int crtc_id)
+{
+       struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id];
 
        /* Return current update_pending status: */
-       return RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) & AVIVO_D1GRPH_SURFACE_UPDATE_PENDING;
+       return !!(RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) &
+               AVIVO_D1GRPH_SURFACE_UPDATE_PENDING);
 }
 
 void avivo_program_fmt(struct drm_encoder *encoder)
index fef310773aadc71260888372b896df0afcced749..97b776666b75134064af5786ca98667fc5180897 100644 (file)
@@ -801,7 +801,7 @@ u32 rv770_get_xclk(struct radeon_device *rdev)
        return reference_clock;
 }
 
-u32 rv770_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
+void rv770_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
 {
        struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id];
        u32 tmp = RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset);
@@ -835,9 +835,15 @@ u32 rv770_page_flip(struct radeon_device *rdev, int crtc_id, u64 crtc_base)
        /* Unlock the lock, so double-buffering can take place inside vblank */
        tmp &= ~AVIVO_D1GRPH_UPDATE_LOCK;
        WREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset, tmp);
+}
+
+bool rv770_page_flip_pending(struct radeon_device *rdev, int crtc_id)
+{
+       struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[crtc_id];
 
        /* Return current update_pending status: */
-       return RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) & AVIVO_D1GRPH_SURFACE_UPDATE_PENDING;
+       return !!(RREG32(AVIVO_D1GRPH_UPDATE + radeon_crtc->crtc_offset) &
+               AVIVO_D1GRPH_SURFACE_UPDATE_PENDING);
 }
 
 /* get temperature in millidegrees */