drm/tegra: dc: Simplify atomic plane helper functions
authorThierry Reding <treding@nvidia.com>
Wed, 30 Aug 2017 15:34:10 +0000 (17:34 +0200)
committerThierry Reding <treding@nvidia.com>
Fri, 20 Oct 2017 12:19:54 +0000 (14:19 +0200)
Remove the tegra_dc_disable_window() function whose only purpose was to
allow tegra_plane_atomic_update() to also call it. Fix that by shuffling
tegra_plano_atomic_disable() to before tegra_plane_atomic_update().

While at it, also remove the overlay plane helper functions because they
are exactly the same as the primary plane helper functions.

Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/drm/tegra/dc.c

index fd31974e2218b48f9d7b3a2fc850010e63484a96..6a43dff70822a4a9a6932e4c71af971d8f8c9626 100644 (file)
@@ -550,14 +550,21 @@ static int tegra_plane_atomic_check(struct drm_plane *plane,
        return 0;
 }
 
-static void tegra_dc_disable_window(struct tegra_dc *dc, int index)
+static void tegra_plane_atomic_disable(struct drm_plane *plane,
+                                      struct drm_plane_state *old_state)
 {
+       struct tegra_dc *dc = to_tegra_dc(old_state->crtc);
+       struct tegra_plane *p = to_tegra_plane(plane);
        unsigned long flags;
        u32 value;
 
+       /* rien ne va plus */
+       if (!old_state || !old_state->crtc)
+               return;
+
        spin_lock_irqsave(&dc->lock, flags);
 
-       value = WINDOW_A_SELECT << index;
+       value = WINDOW_A_SELECT << p->index;
        tegra_dc_writel(dc, value, DC_CMD_DISPLAY_WINDOW_HEADER);
 
        value = tegra_dc_readl(dc, DC_WIN_WIN_OPTIONS);
@@ -582,7 +589,7 @@ static void tegra_plane_atomic_update(struct drm_plane *plane,
                return;
 
        if (!plane->state->visible)
-               return tegra_dc_disable_window(dc, p->index);
+               return tegra_plane_atomic_disable(plane, old_state);
 
        memset(&window, 0, sizeof(window));
        window.src.x = plane->state->src.x1 >> 16;
@@ -618,25 +625,10 @@ static void tegra_plane_atomic_update(struct drm_plane *plane,
        tegra_dc_setup_window(dc, p->index, &window);
 }
 
-static void tegra_plane_atomic_disable(struct drm_plane *plane,
-                                      struct drm_plane_state *old_state)
-{
-       struct tegra_plane *p = to_tegra_plane(plane);
-       struct tegra_dc *dc;
-
-       /* rien ne va plus */
-       if (!old_state || !old_state->crtc)
-               return;
-
-       dc = to_tegra_dc(old_state->crtc);
-
-       tegra_dc_disable_window(dc, p->index);
-}
-
-static const struct drm_plane_helper_funcs tegra_primary_plane_helper_funcs = {
+static const struct drm_plane_helper_funcs tegra_plane_helper_funcs = {
        .atomic_check = tegra_plane_atomic_check,
-       .atomic_update = tegra_plane_atomic_update,
        .atomic_disable = tegra_plane_atomic_disable,
+       .atomic_update = tegra_plane_atomic_update,
 };
 
 static struct drm_plane *tegra_dc_primary_plane_create(struct drm_device *drm,
@@ -676,7 +668,7 @@ static struct drm_plane *tegra_dc_primary_plane_create(struct drm_device *drm,
                return ERR_PTR(err);
        }
 
-       drm_plane_helper_add(&plane->base, &tegra_primary_plane_helper_funcs);
+       drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
 
        return &plane->base;
 }
@@ -871,12 +863,6 @@ static const uint32_t tegra_overlay_plane_formats[] = {
        DRM_FORMAT_YUV422,
 };
 
-static const struct drm_plane_helper_funcs tegra_overlay_plane_helper_funcs = {
-       .atomic_check = tegra_plane_atomic_check,
-       .atomic_update = tegra_plane_atomic_update,
-       .atomic_disable = tegra_plane_atomic_disable,
-};
-
 static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
                                                       struct tegra_dc *dc,
                                                       unsigned int index)
@@ -904,7 +890,7 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
                return ERR_PTR(err);
        }
 
-       drm_plane_helper_add(&plane->base, &tegra_overlay_plane_helper_funcs);
+       drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
 
        return &plane->base;
 }