]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/gpu/drm/vc4/vc4_crtc.c
mtd: nand: atmel: Relax tADL_min constraint
[mirror_ubuntu-artful-kernel.git] / drivers / gpu / drm / vc4 / vc4_crtc.c
index d86c8cce318270a0e34b09c3a1713d48e1a4ff0b..403bbd5f99a9fa97c025f60be11e31a6e043027e 100644 (file)
  * ones that set the clock.
  */
 
-#include "drm_atomic.h"
-#include "drm_atomic_helper.h"
-#include "drm_crtc_helper.h"
-#include "linux/clk.h"
-#include "drm_fb_cma_helper.h"
-#include "linux/component.h"
-#include "linux/of_device.h"
+#include <drm/drm_atomic.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <linux/clk.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <linux/component.h>
+#include <linux/of_device.h>
 #include "vc4_drv.h"
 #include "vc4_regs.h"
 
@@ -151,10 +151,10 @@ int vc4_crtc_debugfs_regs(struct seq_file *m, void *unused)
 }
 #endif
 
-int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
-                           unsigned int flags, int *vpos, int *hpos,
-                           ktime_t *stime, ktime_t *etime,
-                           const struct drm_display_mode *mode)
+bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
+                            bool in_vblank_irq, int *vpos, int *hpos,
+                            ktime_t *stime, ktime_t *etime,
+                            const struct drm_display_mode *mode)
 {
        struct vc4_dev *vc4 = to_vc4_dev(dev);
        struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
@@ -162,7 +162,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
        u32 val;
        int fifo_lines;
        int vblank_lines;
-       int ret = 0;
+       bool ret = false;
 
        /* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */
 
@@ -198,7 +198,7 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
        fifo_lines = vc4_crtc->cob_size / mode->crtc_hdisplay;
 
        if (fifo_lines > 0)
-               ret |= DRM_SCANOUTPOS_VALID;
+               ret = true;
 
        /* HVS more than fifo_lines into frame for compositing? */
        if (*vpos > fifo_lines) {
@@ -216,7 +216,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
                 */
                *vpos -= fifo_lines + 1;
 
-               ret |= DRM_SCANOUTPOS_ACCURATE;
                return ret;
        }
 
@@ -229,10 +228,9 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
         * We can't get meaningful readings wrt. scanline position of the PV
         * and need to make things up in a approximative but consistent way.
         */
-       ret |= DRM_SCANOUTPOS_IN_VBLANK;
        vblank_lines = mode->vtotal - mode->vdisplay;
 
-       if (flags & DRM_CALLED_FROM_VBLIRQ) {
+       if (in_vblank_irq) {
                /*
                 * Assume the irq handler got called close to first
                 * line of vblank, so PV has about a full vblank
@@ -254,9 +252,10 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
                 * we are at the very beginning of vblank, as the hvs just
                 * started refilling, and the stime and etime timestamps
                 * truly correspond to start of vblank.
+                *
+                * Unfortunately there's no way to report this to upper levels
+                * and make it more useful.
                 */
-               if ((val & SCALER_DISPSTATX_FULL) != SCALER_DISPSTATX_FULL)
-                       ret |= DRM_SCANOUTPOS_ACCURATE;
        } else {
                /*
                 * No clue where we are inside vblank. Return a vpos of zero,
@@ -270,19 +269,6 @@ int vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
        return ret;
 }
 
-int vc4_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int crtc_id,
-                                 int *max_error, struct timeval *vblank_time,
-                                 unsigned flags)
-{
-       struct drm_crtc *crtc = drm_crtc_from_index(dev, crtc_id);
-       struct drm_crtc_state *state = crtc->state;
-
-       /* Helper routine in DRM core does all the work: */
-       return drm_calc_vbltimestamp_from_scanoutpos(dev, crtc_id, max_error,
-                                                    vblank_time, flags,
-                                                    &state->adjusted_mode);
-}
-
 static void vc4_crtc_destroy(struct drm_crtc *crtc)
 {
        drm_crtc_cleanup(crtc);
@@ -359,12 +345,16 @@ static u32 vc4_get_fifo_full_level(u32 format)
 static struct drm_encoder *vc4_get_crtc_encoder(struct drm_crtc *crtc)
 {
        struct drm_connector *connector;
+       struct drm_connector_list_iter conn_iter;
 
-       drm_for_each_connector(connector, crtc->dev) {
+       drm_connector_list_iter_begin(crtc->dev, &conn_iter);
+       drm_for_each_connector_iter(connector, &conn_iter) {
                if (connector->state->crtc == crtc) {
+                       drm_connector_list_iter_end(&conn_iter);
                        return connector->encoder;
                }
        }
+       drm_connector_list_iter_end(&conn_iter);
 
        return NULL;
 }