drm/msm: Convert to struct drm_crtc_helper_funcs.get_scanout_position()
authorThomas Zimmermann <tzimmermann@suse.de>
Thu, 23 Jan 2020 13:59:33 +0000 (14:59 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Thu, 13 Feb 2020 12:08:14 +0000 (13:08 +0100)
The callback struct drm_driver.get_scanout_position() is deprecated in
favor of struct drm_crtc_helper_funcs.get_scanout_position(). Convert
msm over.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Rob Clark <robdclark@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200123135943.24140-13-tzimmermann@suse.de
drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c

index 05cc04f729d638963325b03a288ad502cccae822..4decf19847a898b8a8183d094ddf1a5272c0a657 100644 (file)
@@ -405,6 +405,72 @@ static void mdp5_crtc_mode_set_nofb(struct drm_crtc *crtc)
        spin_unlock_irqrestore(&mdp5_crtc->lm_lock, flags);
 }
 
+static struct drm_encoder *get_encoder_from_crtc(struct drm_crtc *crtc)
+{
+       struct drm_device *dev = crtc->dev;
+       struct drm_encoder *encoder;
+
+       drm_for_each_encoder(encoder, dev)
+               if (encoder->crtc == crtc)
+                       return encoder;
+
+       return NULL;
+}
+
+static bool mdp5_crtc_get_scanout_position(struct drm_crtc *crtc,
+                                          bool in_vblank_irq,
+                                          int *vpos, int *hpos,
+                                          ktime_t *stime, ktime_t *etime,
+                                          const struct drm_display_mode *mode)
+{
+       unsigned int pipe = crtc->index;
+       struct drm_encoder *encoder;
+       int line, vsw, vbp, vactive_start, vactive_end, vfp_end;
+
+
+       encoder = get_encoder_from_crtc(crtc);
+       if (!encoder) {
+               DRM_ERROR("no encoder found for crtc %d\n", pipe);
+               return false;
+       }
+
+       vsw = mode->crtc_vsync_end - mode->crtc_vsync_start;
+       vbp = mode->crtc_vtotal - mode->crtc_vsync_end;
+
+       /*
+        * the line counter is 1 at the start of the VSYNC pulse and VTOTAL at
+        * the end of VFP. Translate the porch values relative to the line
+        * counter positions.
+        */
+
+       vactive_start = vsw + vbp + 1;
+
+       vactive_end = vactive_start + mode->crtc_vdisplay;
+
+       /* last scan line before VSYNC */
+       vfp_end = mode->crtc_vtotal;
+
+       if (stime)
+               *stime = ktime_get();
+
+       line = mdp5_encoder_get_linecount(encoder);
+
+       if (line < vactive_start)
+               line -= vactive_start;
+       else if (line > vactive_end)
+               line = line - vfp_end - vactive_start;
+       else
+               line -= vactive_start;
+
+       *vpos = line;
+       *hpos = 0;
+
+       if (etime)
+               *etime = ktime_get();
+
+       return true;
+}
+
 static void mdp5_crtc_atomic_disable(struct drm_crtc *crtc,
                                     struct drm_crtc_state *old_state)
 {
@@ -1063,6 +1129,7 @@ static const struct drm_crtc_helper_funcs mdp5_crtc_helper_funcs = {
        .atomic_flush = mdp5_crtc_atomic_flush,
        .atomic_enable = mdp5_crtc_atomic_enable,
        .atomic_disable = mdp5_crtc_atomic_disable,
+       .get_scanout_position = mdp5_crtc_get_scanout_position,
 };
 
 static void mdp5_crtc_vblank_irq(struct mdp_irq *irq, uint32_t irqstatus)
index e43ecd4be10a3e1b441c0824263042496a1869eb..8b72ac44ce55b4f41e7061588b5022d2c274dd19 100644 (file)
@@ -595,66 +595,6 @@ static struct drm_encoder *get_encoder_from_crtc(struct drm_crtc *crtc)
        return NULL;
 }
 
-static bool mdp5_get_scanoutpos(struct drm_device *dev, unsigned int pipe,
-                               bool in_vblank_irq, int *vpos, int *hpos,
-                               ktime_t *stime, ktime_t *etime,
-                               const struct drm_display_mode *mode)
-{
-       struct msm_drm_private *priv = dev->dev_private;
-       struct drm_crtc *crtc;
-       struct drm_encoder *encoder;
-       int line, vsw, vbp, vactive_start, vactive_end, vfp_end;
-
-       crtc = priv->crtcs[pipe];
-       if (!crtc) {
-               DRM_ERROR("Invalid crtc %d\n", pipe);
-               return false;
-       }
-
-       encoder = get_encoder_from_crtc(crtc);
-       if (!encoder) {
-               DRM_ERROR("no encoder found for crtc %d\n", pipe);
-               return false;
-       }
-
-       vsw = mode->crtc_vsync_end - mode->crtc_vsync_start;
-       vbp = mode->crtc_vtotal - mode->crtc_vsync_end;
-
-       /*
-        * the line counter is 1 at the start of the VSYNC pulse and VTOTAL at
-        * the end of VFP. Translate the porch values relative to the line
-        * counter positions.
-        */
-
-       vactive_start = vsw + vbp + 1;
-
-       vactive_end = vactive_start + mode->crtc_vdisplay;
-
-       /* last scan line before VSYNC */
-       vfp_end = mode->crtc_vtotal;
-
-       if (stime)
-               *stime = ktime_get();
-
-       line = mdp5_encoder_get_linecount(encoder);
-
-       if (line < vactive_start) {
-               line -= vactive_start;
-       } else if (line > vactive_end) {
-               line = line - vfp_end - vactive_start;
-       } else {
-               line -= vactive_start;
-       }
-
-       *vpos = line;
-       *hpos = 0;
-
-       if (etime)
-               *etime = ktime_get();
-
-       return true;
-}
-
 static u32 mdp5_get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
        struct msm_drm_private *priv = dev->dev_private;
@@ -763,7 +703,6 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev)
        dev->mode_config.max_height = 0xffff;
 
        dev->driver->get_vblank_timestamp = drm_calc_vbltimestamp_from_scanoutpos;
-       dev->driver->get_scanout_position = mdp5_get_scanoutpos;
        dev->driver->get_vblank_counter = mdp5_get_vblank_counter;
        dev->max_vblank_count = 0; /* max_vblank_count is set on each CRTC */
        dev->vblank_disable_immediate = true;