drm/stm: ltdc: add user update info in plane print state
authorPhilippe CORNU <philippe.cornu@st.com>
Sat, 7 Apr 2018 21:35:03 +0000 (23:35 +0200)
committerPhilippe Cornu <philippe.cornu@st.com>
Thu, 19 Apr 2018 10:15:38 +0000 (12:15 +0200)
This patch adds the user update information in
frames-per-second into the drm debugfs plane state.

Signed-off-by: Philippe Cornu <philippe.cornu@st.com>
Reviewed-by: Vincent Abriou <vincent.abriou@st.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180407213503.30932-1-philippe.cornu@st.com
drivers/gpu/drm/stm/ltdc.c
drivers/gpu/drm/stm/ltdc.h

index 2b745cfc9000e8917ef7a6676ab21dfa1ba49b26..061d2b6e51571370fec6b1857645be7d567c95df 100644 (file)
@@ -729,6 +729,8 @@ static void ltdc_plane_atomic_update(struct drm_plane *plane,
        reg_update_bits(ldev->regs, LTDC_L1CR + lofs,
                        LXCR_LEN | LXCR_CLUTEN, val);
 
+       ldev->plane_fpsi[plane->index].counter++;
+
        mutex_lock(&ldev->err_lock);
        if (ldev->error_status & ISR_FUIF) {
                DRM_DEBUG_DRIVER("Fifo underrun\n");
@@ -754,6 +756,25 @@ static void ltdc_plane_atomic_disable(struct drm_plane *plane,
                         oldstate->crtc->base.id, plane->base.id);
 }
 
+static void ltdc_plane_atomic_print_state(struct drm_printer *p,
+                                         const struct drm_plane_state *state)
+{
+       struct drm_plane *plane = state->plane;
+       struct ltdc_device *ldev = plane_to_ltdc(plane);
+       struct fps_info *fpsi = &ldev->plane_fpsi[plane->index];
+       int ms_since_last;
+       ktime_t now;
+
+       now = ktime_get();
+       ms_since_last = ktime_to_ms(ktime_sub(now, fpsi->last_timestamp));
+
+       drm_printf(p, "\tuser_updates=%dfps\n",
+                  DIV_ROUND_CLOSEST(fpsi->counter * 1000, ms_since_last));
+
+       fpsi->last_timestamp = now;
+       fpsi->counter = 0;
+}
+
 static const struct drm_plane_funcs ltdc_plane_funcs = {
        .update_plane = drm_atomic_helper_update_plane,
        .disable_plane = drm_atomic_helper_disable_plane,
@@ -761,6 +782,7 @@ static const struct drm_plane_funcs ltdc_plane_funcs = {
        .reset = drm_atomic_helper_plane_reset,
        .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
        .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
+       .atomic_print_state = ltdc_plane_atomic_print_state,
 };
 
 static const struct drm_plane_helper_funcs ltdc_plane_helper_funcs = {
index 61a80d00bc3b1de92820046ad56392c1e0039315..1e16d6afb0d2f6357f279fa3f5d05c650e6fc37e 100644 (file)
@@ -20,6 +20,13 @@ struct ltdc_caps {
        bool non_alpha_only_l1; /* non-native no-alpha formats on layer 1 */
 };
 
+#define LTDC_MAX_LAYER 4
+
+struct fps_info {
+       unsigned int counter;
+       ktime_t last_timestamp;
+};
+
 struct ltdc_device {
        void __iomem *regs;
        struct clk *pixel_clk;  /* lcd pixel clock */
@@ -27,6 +34,7 @@ struct ltdc_device {
        struct ltdc_caps caps;
        u32 error_status;
        u32 irq_status;
+       struct fps_info plane_fpsi[LTDC_MAX_LAYER];
 };
 
 int ltdc_load(struct drm_device *ddev);