drm/atomic: Pass the full state to CRTC atomic_check
authorMaxime Ripard <maxime@cerno.tech>
Wed, 28 Oct 2020 12:32:21 +0000 (13:32 +0100)
committerMaxime Ripard <maxime@cerno.tech>
Mon, 2 Nov 2020 11:34:49 +0000 (12:34 +0100)
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.

The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.

Let's start convert all the remaining helpers to provide a consistent
interface, starting with the CRTC's atomic_check.

The conversion was done using the coccinelle script below,
built tested on all the drivers and actually tested on vc4.

virtual report

@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier ret, f;
@@

 f(struct drm_device *dev, struct drm_atomic_state *state)
 {
<...
- ret = FUNCS->atomic_check(crtc, crtc_state);
+ ret = FUNCS->atomic_check(crtc, state);
...>
 }

@@
identifier crtc, new_state;
@@

 struct drm_crtc_helper_funcs {
  ...
- int (*atomic_check)(struct drm_crtc *crtc, struct drm_crtc_state *new_state);
+ int (*atomic_check)(struct drm_crtc *crtc, struct drm_atomic_state *state);
  ...
}

@ crtc_atomic_func @
identifier helpers;
identifier func;
@@

static struct drm_crtc_helper_funcs helpers = {
...,
.atomic_check = func,
...,
};

@ ignores_new_state @
identifier crtc_atomic_func.func;
identifier crtc, new_state;
@@

 int func(struct drm_crtc *crtc,
struct drm_crtc_state *new_state)
 {
... when != new_state
 }

@ adds_new_state depends on crtc_atomic_func && !ignores_new_state @
identifier crtc_atomic_func.func;
identifier crtc, new_state;
@@

 int func(struct drm_crtc *crtc, struct drm_crtc_state *new_state)
 {
+ struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
  ...
 }

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@

 int func(...)
 {
...
- T state = E;
+ T crtc_state = E;
  <+...
- state
+ crtc_state
  ...+>
 }

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@

 int func(...)
 {
  ...
- T state;
+ T crtc_state;
  <+...
- state
+ crtc_state
  ...+>
 }

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier new_state;
identifier crtc;
@@

 int func(struct drm_crtc *crtc,
-        struct drm_crtc_state *new_state
+        struct drm_atomic_state *state
       )
 { ... }

@@
identifier new_state;
identifier crtc;
@@

 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
-                             struct drm_crtc_state *new_state
+                             struct drm_atomic_state *state
               )
 {
+       struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state, crtc);
...
 }

@@
identifier new_state;
identifier crtc;
@@

 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
-                             struct drm_crtc_state *new_state
+                             struct drm_atomic_state *state
               );

@ include depends on adds_new_state @
@@

 #include <drm/drm_atomic.h>

@ no_include depends on !include && adds_new_state @
@@

+ #include <drm/drm_atomic.h>
  #include <drm/...>

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-1-maxime@cerno.tech
30 files changed:
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
drivers/gpu/drm/arm/malidp_crtc.c
drivers/gpu/drm/armada/armada_crtc.c
drivers/gpu/drm/ast/ast_mode.c
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/drm_simple_kms_helper.c
drivers/gpu/drm/exynos/exynos_drm_crtc.c
drivers/gpu/drm/imx/ipuv3-crtc.c
drivers/gpu/drm/ingenic/ingenic-drm-drv.c
drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
drivers/gpu/drm/mxsfb/mxsfb_kms.c
drivers/gpu/drm/nouveau/dispnv50/head.c
drivers/gpu/drm/omapdrm/omap_crtc.c
drivers/gpu/drm/rcar-du/rcar_du_crtc.c
drivers/gpu/drm/rockchip/rockchip_drm_vop.c
drivers/gpu/drm/sun4i/sun4i_crtc.c
drivers/gpu/drm/tidss/tidss_crtc.c
drivers/gpu/drm/tilcdc/tilcdc_crtc.c
drivers/gpu/drm/vc4/vc4_crtc.c
drivers/gpu/drm/vc4/vc4_txp.c
drivers/gpu/drm/virtio/virtgpu_display.c
drivers/gpu/drm/vkms/vkms_crtc.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
drivers/gpu/drm/xlnx/zynqmp_disp.c
include/drm/drm_modeset_helper_vtables.h

index e2b23486ba4c9dac4f8f30570c07bc5e12327249..86fd4420f128f31ad639d54d0163869de2ac91af 100644 (file)
@@ -5514,17 +5514,19 @@ static void dm_update_crtc_active_planes(struct drm_crtc *crtc,
 }
 
 static int dm_crtc_helper_atomic_check(struct drm_crtc *crtc,
-                                      struct drm_crtc_state *state)
+                                      struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct amdgpu_device *adev = drm_to_adev(crtc->dev);
        struct dc *dc = adev->dm.dc;
-       struct dm_crtc_state *dm_crtc_state = to_dm_crtc_state(state);
+       struct dm_crtc_state *dm_crtc_state = to_dm_crtc_state(crtc_state);
        int ret = -EINVAL;
 
-       dm_update_crtc_active_planes(crtc, state);
+       dm_update_crtc_active_planes(crtc, crtc_state);
 
        if (unlikely(!dm_crtc_state->stream &&
-                    modeset_required(state, NULL, dm_crtc_state->stream))) {
+                    modeset_required(crtc_state, NULL, dm_crtc_state->stream))) {
                WARN_ON(1);
                return ret;
        }
@@ -5535,8 +5537,8 @@ static int dm_crtc_helper_atomic_check(struct drm_crtc *crtc,
         * planes are disabled, which is not supported by the hardware. And there is legacy
         * userspace which stops using the HW cursor altogether in response to the resulting EINVAL.
         */
-       if (state->enable &&
-           !(state->plane_mask & drm_plane_mask(crtc->primary)))
+       if (crtc_state->enable &&
+           !(crtc_state->plane_mask & drm_plane_mask(crtc->primary)))
                return -EINVAL;
 
        /* In some use cases, like reset, no stream is attached */
index a4bbf56a7fc120f299c6005724f347f06ee52e64..cc65623b54552e993fa51775b27b1f3c8adea852 100644 (file)
@@ -74,16 +74,18 @@ static void komeda_crtc_update_clock_ratio(struct komeda_crtc_state *kcrtc_st)
  */
 static int
 komeda_crtc_atomic_check(struct drm_crtc *crtc,
-                        struct drm_crtc_state *state)
+                        struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct komeda_crtc *kcrtc = to_kcrtc(crtc);
-       struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(state);
+       struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(crtc_state);
        int err;
 
-       if (drm_atomic_crtc_needs_modeset(state))
+       if (drm_atomic_crtc_needs_modeset(crtc_state))
                komeda_crtc_update_clock_ratio(kcrtc_st);
 
-       if (state->active) {
+       if (crtc_state->active) {
                err = komeda_build_display_data_flow(kcrtc, kcrtc_st);
                if (err)
                        return err;
index 49766eb7a554cb3955100b58baa71c8093337617..108e7a31bd26bed69a4349b3a8c534befb7ce38d 100644 (file)
@@ -337,8 +337,10 @@ mclk_calc:
 }
 
 static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
-                                   struct drm_crtc_state *state)
+                                   struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct malidp_drm *malidp = crtc_to_malidp_device(crtc);
        struct malidp_hw_device *hwdev = malidp->dev;
        struct drm_plane *plane;
@@ -373,7 +375,7 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
         */
 
        /* first count the number of rotated planes */
-       drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
+       drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
                struct drm_framebuffer *fb = pstate->fb;
 
                if ((pstate->rotation & MALIDP_ROTATED_MASK) || fb->modifier)
@@ -389,7 +391,7 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
                rot_mem_free += hwdev->rotation_memory[1];
 
        /* now validate the rotation memory requirements */
-       drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
+       drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
                struct malidp_plane *mp = to_malidp_plane(plane);
                struct malidp_plane_state *ms = to_malidp_plane_state(pstate);
                struct drm_framebuffer *fb = pstate->fb;
@@ -417,18 +419,18 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
        }
 
        /* If only the writeback routing has changed, we don't need a modeset */
-       if (state->connectors_changed) {
+       if (crtc_state->connectors_changed) {
                u32 old_mask = crtc->state->connector_mask;
-               u32 new_mask = state->connector_mask;
+               u32 new_mask = crtc_state->connector_mask;
 
                if ((old_mask ^ new_mask) ==
                    (1 << drm_connector_index(&malidp->mw_connector.base)))
-                       state->connectors_changed = false;
+                       crtc_state->connectors_changed = false;
        }
 
-       ret = malidp_crtc_atomic_check_gamma(crtc, state);
-       ret = ret ? ret : malidp_crtc_atomic_check_ctm(crtc, state);
-       ret = ret ? ret : malidp_crtc_atomic_check_scaling(crtc, state);
+       ret = malidp_crtc_atomic_check_gamma(crtc, crtc_state);
+       ret = ret ? ret : malidp_crtc_atomic_check_ctm(crtc, crtc_state);
+       ret = ret ? ret : malidp_crtc_atomic_check_scaling(crtc, crtc_state);
 
        return ret;
 }
index e0fbfc9ce386cabee9eb588a3667d60a3836ae56..d22ca1496c4358b74667af993580f5465efeefac 100644 (file)
@@ -413,15 +413,17 @@ static void armada_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
 }
 
 static int armada_drm_crtc_atomic_check(struct drm_crtc *crtc,
-                                       struct drm_crtc_state *state)
+                                       struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        DRM_DEBUG_KMS("[CRTC:%d:%s]\n", crtc->base.id, crtc->name);
 
-       if (state->gamma_lut && drm_color_lut_size(state->gamma_lut) != 256)
+       if (crtc_state->gamma_lut && drm_color_lut_size(crtc_state->gamma_lut) != 256)
                return -EINVAL;
 
-       if (state->color_mgmt_changed)
-               state->planes_changed = true;
+       if (crtc_state->color_mgmt_changed)
+               crtc_state->planes_changed = true;
 
        return 0;
 }
index bd03a8a67e3ab489937b63d819ada883d59e20f6..346dce2d654fe6ef3d64698c9867c831a81a413d 100644 (file)
@@ -751,24 +751,26 @@ static void ast_crtc_dpms(struct drm_crtc *crtc, int mode)
 }
 
 static int ast_crtc_helper_atomic_check(struct drm_crtc *crtc,
-                                       struct drm_crtc_state *state)
+                                       struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct drm_device *dev = crtc->dev;
        struct ast_crtc_state *ast_state;
        const struct drm_format_info *format;
        bool succ;
 
-       if (!state->enable)
+       if (!crtc_state->enable)
                return 0; /* no mode checks if CRTC is being disabled */
 
-       ast_state = to_ast_crtc_state(state);
+       ast_state = to_ast_crtc_state(crtc_state);
 
        format = ast_state->format;
        if (drm_WARN_ON_ONCE(dev, !format))
                return -EINVAL; /* BUG: We didn't set format in primary check(). */
 
-       succ = ast_get_vbios_mode_info(format, &state->mode,
-                                      &state->adjusted_mode,
+       succ = ast_get_vbios_mode_info(format, &crtc_state->mode,
+                                      &crtc_state->adjusted_mode,
                                       &ast_state->vbios_mode_info);
        if (!succ)
                return -EINVAL;
index 2b3888df22f8970900a24c52f85716acafc69c2b..0e533ded2a965d48f9776f16873b3386f84ee519 100644 (file)
@@ -325,8 +325,9 @@ static int atmel_hlcdc_crtc_select_output_mode(struct drm_crtc_state *state)
 }
 
 static int atmel_hlcdc_crtc_atomic_check(struct drm_crtc *c,
-                                        struct drm_crtc_state *s)
+                                        struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *s = drm_atomic_get_new_crtc_state(state, c);
        int ret;
 
        ret = atmel_hlcdc_crtc_select_output_mode(s);
index a7bcb4b4586cb74a3dcdfdb2a135ffe2f5e5c79c..12d8095318d0bf06c7612496f2882eb0e671147f 100644 (file)
@@ -918,7 +918,7 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
                if (!funcs || !funcs->atomic_check)
                        continue;
 
-               ret = funcs->atomic_check(crtc, new_crtc_state);
+               ret = funcs->atomic_check(crtc, state);
                if (ret) {
                        DRM_DEBUG_ATOMIC("[CRTC:%d:%s] atomic driver check failed\n",
                                         crtc->base.id, crtc->name);
index fa87b63e152a8f76cbd8173f5adba939e010d26f..4b46689634dde777b9ee4f66489d5c8f7dfd2151 100644 (file)
@@ -86,16 +86,18 @@ drm_simple_kms_crtc_mode_valid(struct drm_crtc *crtc,
 }
 
 static int drm_simple_kms_crtc_check(struct drm_crtc *crtc,
-                                    struct drm_crtc_state *state)
+                                    struct drm_atomic_state *state)
 {
-       bool has_primary = state->plane_mask &
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
+       bool has_primary = crtc_state->plane_mask &
                           drm_plane_mask(crtc->primary);
 
        /* We always want to have an active plane with an active CRTC */
-       if (has_primary != state->enable)
+       if (has_primary != crtc_state->enable)
                return -EINVAL;
 
-       return drm_atomic_add_affected_planes(state->state, crtc);
+       return drm_atomic_add_affected_planes(crtc_state->state, crtc);
 }
 
 static void drm_simple_kms_crtc_enable(struct drm_crtc *crtc,
index 35f1d1dbb1262e584bb657bcb2c000b68a26b2be..928f764efce82d09d5b9cb29ba96edd02ff94f35 100644 (file)
@@ -49,15 +49,17 @@ static void exynos_drm_crtc_atomic_disable(struct drm_crtc *crtc,
 }
 
 static int exynos_crtc_atomic_check(struct drm_crtc *crtc,
-                                    struct drm_crtc_state *state)
+                                    struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
 
-       if (!state->enable)
+       if (!crtc_state->enable)
                return 0;
 
        if (exynos_crtc->ops->atomic_check)
-               return exynos_crtc->ops->atomic_check(exynos_crtc, state);
+               return exynos_crtc->ops->atomic_check(exynos_crtc, crtc_state);
 
        return 0;
 }
index 7ecc27c41a6a8bf9facd05e95e774936556c91b8..b6d864d7a0dfcb92f3478d10f9a0faf07fb53af7 100644 (file)
@@ -227,11 +227,13 @@ static bool ipu_crtc_mode_fixup(struct drm_crtc *crtc,
 }
 
 static int ipu_crtc_atomic_check(struct drm_crtc *crtc,
-                                struct drm_crtc_state *state)
+                                struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        u32 primary_plane_mask = drm_plane_mask(crtc->primary);
 
-       if (state->active && (primary_plane_mask & state->plane_mask) == 0)
+       if (crtc_state->active && (primary_plane_mask & crtc_state->plane_mask) == 0)
                return -EINVAL;
 
        return 0;
index 2329754af1169e2fd8f35fcad6cfd24334976911..aaa324bd557218694c719898dfeb2b7eb6a78155 100644 (file)
@@ -239,28 +239,33 @@ static void ingenic_drm_crtc_update_timings(struct ingenic_drm *priv,
 }
 
 static int ingenic_drm_crtc_atomic_check(struct drm_crtc *crtc,
-                                        struct drm_crtc_state *state)
+                                        struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct ingenic_drm *priv = drm_crtc_get_priv(crtc);
        struct drm_plane_state *f1_state, *f0_state, *ipu_state = NULL;
 
-       if (state->gamma_lut &&
-           drm_color_lut_size(state->gamma_lut) != ARRAY_SIZE(priv->dma_hwdescs->palette)) {
+       if (crtc_state->gamma_lut &&
+           drm_color_lut_size(crtc_state->gamma_lut) != ARRAY_SIZE(priv->dma_hwdescs->palette)) {
                dev_dbg(priv->dev, "Invalid palette size\n");
                return -EINVAL;
        }
 
-       if (drm_atomic_crtc_needs_modeset(state) && priv->soc_info->has_osd) {
-               f1_state = drm_atomic_get_plane_state(state->state, &priv->f1);
+       if (drm_atomic_crtc_needs_modeset(crtc_state) && priv->soc_info->has_osd) {
+               f1_state = drm_atomic_get_plane_state(crtc_state->state,
+                                                     &priv->f1);
                if (IS_ERR(f1_state))
                        return PTR_ERR(f1_state);
 
-               f0_state = drm_atomic_get_plane_state(state->state, &priv->f0);
+               f0_state = drm_atomic_get_plane_state(crtc_state->state,
+                                                     &priv->f0);
                if (IS_ERR(f0_state))
                        return PTR_ERR(f0_state);
 
                if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU) && priv->ipu_plane) {
-                       ipu_state = drm_atomic_get_plane_state(state->state, priv->ipu_plane);
+                       ipu_state = drm_atomic_get_plane_state(crtc_state->state,
+                                                              priv->ipu_plane);
                        if (IS_ERR(ipu_state))
                                return PTR_ERR(ipu_state);
 
index 6a24ce245a373606c9ab5b78b220c43924e6f3f1..169df7ca85fd0cdfda8fbc35cfd61724b6377fe3 100644 (file)
@@ -815,10 +815,12 @@ struct plane_state {
 };
 
 static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
-               struct drm_crtc_state *state)
+               struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
-       struct dpu_crtc_state *cstate = to_dpu_crtc_state(state);
+       struct dpu_crtc_state *cstate = to_dpu_crtc_state(crtc_state);
        struct plane_state *pstates;
 
        const struct drm_plane_state *pstate;
@@ -835,32 +837,33 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
 
        pstates = kzalloc(sizeof(*pstates) * DPU_STAGE_MAX * 4, GFP_KERNEL);
 
-       if (!state->enable || !state->active) {
+       if (!crtc_state->enable || !crtc_state->active) {
                DPU_DEBUG("crtc%d -> enable %d, active %d, skip atomic_check\n",
-                               crtc->base.id, state->enable, state->active);
+                               crtc->base.id, crtc_state->enable,
+                               crtc_state->active);
                goto end;
        }
 
-       mode = &state->adjusted_mode;
+       mode = &crtc_state->adjusted_mode;
        DPU_DEBUG("%s: check", dpu_crtc->name);
 
        /* force a full mode set if active state changed */
-       if (state->active_changed)
-               state->mode_changed = true;
+       if (crtc_state->active_changed)
+               crtc_state->mode_changed = true;
 
        memset(pipe_staged, 0, sizeof(pipe_staged));
 
        if (cstate->num_mixers) {
                mixer_width = mode->hdisplay / cstate->num_mixers;
 
-               _dpu_crtc_setup_lm_bounds(crtc, state);
+               _dpu_crtc_setup_lm_bounds(crtc, crtc_state);
        }
 
        crtc_rect.x2 = mode->hdisplay;
        crtc_rect.y2 = mode->vdisplay;
 
         /* get plane state for all drm planes associated with crtc state */
-       drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
+       drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
                struct drm_rect dst, clip = crtc_rect;
 
                if (IS_ERR_OR_NULL(pstate)) {
@@ -966,7 +969,7 @@ static int dpu_crtc_atomic_check(struct drm_crtc *crtc,
 
        atomic_inc(&_dpu_crtc_get_kms(crtc)->bandwidth_ref);
 
-       rc = dpu_core_perf_crtc_check(crtc, state);
+       rc = dpu_core_perf_crtc_check(crtc, crtc_state);
        if (rc) {
                DPU_ERROR("crtc%d failed performance check %d\n",
                                crtc->base.id, rc);
index 6b03ceeb5ba173e43abd4965a24cd261342a33ef..af80f3baf05beac3df8da65485dba0e6ad6d67c7 100644 (file)
@@ -307,7 +307,7 @@ static void mdp4_crtc_atomic_enable(struct drm_crtc *crtc,
 }
 
 static int mdp4_crtc_atomic_check(struct drm_crtc *crtc,
-               struct drm_crtc_state *state)
+               struct drm_atomic_state *state)
 {
        struct mdp4_crtc *mdp4_crtc = to_mdp4_crtc(crtc);
        DBG("%s: check", mdp4_crtc->name);
index 747dd8a7aa6e4dd6330a5d7fc3c9252f50b752e2..500f885c0eae2f361cf5a1190379b85a69bf1982 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <linux/sort.h>
 
+#include <drm/drm_atomic.h>
 #include <drm/drm_mode.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_flip_work.h>
@@ -682,15 +683,17 @@ static enum mdp_mixer_stage_id get_start_stage(struct drm_crtc *crtc,
 }
 
 static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
-               struct drm_crtc_state *state)
+               struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct mdp5_kms *mdp5_kms = get_kms(crtc);
        struct drm_plane *plane;
        struct drm_device *dev = crtc->dev;
        struct plane_state pstates[STAGE_MAX + 1];
        const struct mdp5_cfg_hw *hw_cfg;
        const struct drm_plane_state *pstate;
-       const struct drm_display_mode *mode = &state->adjusted_mode;
+       const struct drm_display_mode *mode = &crtc_state->adjusted_mode;
        bool cursor_plane = false;
        bool need_right_mixer = false;
        int cnt = 0, i;
@@ -699,7 +702,7 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
 
        DBG("%s: check", crtc->name);
 
-       drm_atomic_crtc_state_for_each_plane_state(plane, pstate, state) {
+       drm_atomic_crtc_state_for_each_plane_state(plane, pstate, crtc_state) {
                if (!pstate->visible)
                        continue;
 
@@ -731,7 +734,7 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
        if (mode->hdisplay > hw_cfg->lm.max_width)
                need_right_mixer = true;
 
-       ret = mdp5_crtc_setup_pipeline(crtc, state, need_right_mixer);
+       ret = mdp5_crtc_setup_pipeline(crtc, crtc_state, need_right_mixer);
        if (ret) {
                DRM_DEV_ERROR(dev->dev, "couldn't assign mixers %d\n", ret);
                return ret;
@@ -744,7 +747,7 @@ static int mdp5_crtc_atomic_check(struct drm_crtc *crtc,
        WARN_ON(cursor_plane &&
                (pstates[cnt - 1].plane->type != DRM_PLANE_TYPE_CURSOR));
 
-       start = get_start_stage(crtc, state, &pstates[0].state->base);
+       start = get_start_stage(crtc, crtc_state, &pstates[0].state->base);
 
        /* verify that there are not too many planes attached to crtc
         * and that we don't have conflicting mixer stages:
index 956f631997f2b60c42d75f698db861929c834175..b0757f84a979d0f5845551971ba26778d0f77d64 100644 (file)
@@ -269,17 +269,19 @@ static void mxsfb_crtc_mode_set_nofb(struct mxsfb_drm_private *mxsfb)
 }
 
 static int mxsfb_crtc_atomic_check(struct drm_crtc *crtc,
-                                  struct drm_crtc_state *state)
+                                  struct drm_atomic_state *state)
 {
-       bool has_primary = state->plane_mask &
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
+       bool has_primary = crtc_state->plane_mask &
                           drm_plane_mask(crtc->primary);
 
        /* The primary plane has to be enabled when the CRTC is active. */
-       if (state->active && !has_primary)
+       if (crtc_state->active && !has_primary)
                return -EINVAL;
 
        /* TODO: Is this needed ? */
-       return drm_atomic_add_affected_planes(state->state, crtc);
+       return drm_atomic_add_affected_planes(crtc_state->state, crtc);
 }
 
 static void mxsfb_crtc_atomic_flush(struct drm_crtc *crtc,
index 841edfaf5b9d44eee0e0a7ee20c0b87376370836..0542ca22b33ab93636e45af0346f79f11b4e7e8d 100644 (file)
@@ -30,6 +30,7 @@
 #include <nvif/event.h>
 #include <nvif/cl0046.h>
 
+#include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_vblank.h>
@@ -310,12 +311,14 @@ nv50_head_atomic_check_mode(struct nv50_head *head, struct nv50_head_atom *asyh)
 }
 
 static int
-nv50_head_atomic_check(struct drm_crtc *crtc, struct drm_crtc_state *state)
+nv50_head_atomic_check(struct drm_crtc *crtc, struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct nouveau_drm *drm = nouveau_drm(crtc->dev);
        struct nv50_head *head = nv50_head(crtc);
        struct nv50_head_atom *armh = nv50_head_atom(crtc->state);
-       struct nv50_head_atom *asyh = nv50_head_atom(state);
+       struct nv50_head_atom *asyh = nv50_head_atom(crtc_state);
        struct nouveau_conn_atom *asyc = NULL;
        struct drm_connector_state *conns;
        struct drm_connector *conn;
index fef3b0032fd834c4e88642f899ddf92b4e4742a5..69a0770ba38e76b644291210bf3c9dd980f74161 100644 (file)
@@ -569,22 +569,25 @@ static bool omap_crtc_is_manually_updated(struct drm_crtc *crtc)
 }
 
 static int omap_crtc_atomic_check(struct drm_crtc *crtc,
-                               struct drm_crtc_state *state)
+                               struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct drm_plane_state *pri_state;
 
-       if (state->color_mgmt_changed && state->gamma_lut) {
-               unsigned int length = state->gamma_lut->length /
+       if (crtc_state->color_mgmt_changed && crtc_state->gamma_lut) {
+               unsigned int length = crtc_state->gamma_lut->length /
                        sizeof(struct drm_color_lut);
 
                if (length < 2)
                        return -EINVAL;
        }
 
-       pri_state = drm_atomic_get_new_plane_state(state->state, crtc->primary);
+       pri_state = drm_atomic_get_new_plane_state(crtc_state->state,
+                                                  crtc->primary);
        if (pri_state) {
                struct omap_crtc_state *omap_crtc_state =
-                       to_omap_crtc_state(state);
+                       to_omap_crtc_state(crtc_state);
 
                /* Mirror new values for zpos and rotation in omap_crtc_state */
                omap_crtc_state->zpos = pri_state->zpos;
index 4c360a255849d93af1951c1677b75c6a00090b6f..460fb07b786f72c11f4711806b361c511dc6d536 100644 (file)
@@ -682,20 +682,23 @@ static void rcar_du_crtc_stop(struct rcar_du_crtc *rcrtc)
  */
 
 static int rcar_du_crtc_atomic_check(struct drm_crtc *crtc,
-                                    struct drm_crtc_state *state)
+                                    struct drm_atomic_state *state)
 {
-       struct rcar_du_crtc_state *rstate = to_rcar_crtc_state(state);
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
+       struct rcar_du_crtc_state *rstate = to_rcar_crtc_state(crtc_state);
        struct drm_encoder *encoder;
        int ret;
 
-       ret = rcar_du_cmm_check(crtc, state);
+       ret = rcar_du_cmm_check(crtc, crtc_state);
        if (ret)
                return ret;
 
        /* Store the routes from the CRTC output to the DU outputs. */
        rstate->outputs = 0;
 
-       drm_for_each_encoder_mask(encoder, crtc->dev, state->encoder_mask) {
+       drm_for_each_encoder_mask(encoder, crtc->dev,
+                                 crtc_state->encoder_mask) {
                struct rcar_du_encoder *renc;
 
                /* Skip the writeback encoder. */
index 47835715b44b04a61b30c2b57dfb0dbc0c8f087c..fcbd758e653173cfb6ee7cbb28ba52d9ad18248f 100644 (file)
@@ -1415,8 +1415,10 @@ static void vop_wait_for_irq_handler(struct vop *vop)
 }
 
 static int vop_crtc_atomic_check(struct drm_crtc *crtc,
-                                struct drm_crtc_state *crtc_state)
+                                struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct vop *vop = to_vop(crtc);
        struct drm_plane *plane;
        struct drm_plane_state *plane_state;
index 999deb64bd709ef70d053f6b090b3737641582b9..8f91391832dbbcdccafe889434b1f32bf13d3671 100644 (file)
@@ -15,6 +15,7 @@
 
 #include <video/videomode.h>
 
+#include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_modes.h>
@@ -45,14 +46,16 @@ static struct drm_encoder *sun4i_crtc_get_encoder(struct drm_crtc *crtc)
 }
 
 static int sun4i_crtc_atomic_check(struct drm_crtc *crtc,
-                                   struct drm_crtc_state *state)
+                                   struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct sun4i_crtc *scrtc = drm_crtc_to_sun4i_crtc(crtc);
        struct sunxi_engine *engine = scrtc->engine;
        int ret = 0;
 
        if (engine && engine->ops && engine->ops->atomic_check)
-               ret = engine->ops->atomic_check(engine, state);
+               ret = engine->ops->atomic_check(engine, crtc_state);
 
        return ret;
 }
index 848b9c7b553d9d8ff671e3b9e72dcf88c7d3c6f1..6739f489dfdfe6e739e5ccad6b9b5510053ba804 100644 (file)
@@ -85,8 +85,10 @@ void tidss_crtc_error_irq(struct drm_crtc *crtc, u64 irqstatus)
 /* drm_crtc_helper_funcs */
 
 static int tidss_crtc_atomic_check(struct drm_crtc *crtc,
-                                  struct drm_crtc_state *state)
+                                  struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        struct drm_device *ddev = crtc->dev;
        struct tidss_device *tidss = to_tidss(ddev);
        struct dispc_device *dispc = tidss->dispc;
@@ -97,10 +99,10 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,
 
        dev_dbg(ddev->dev, "%s\n", __func__);
 
-       if (!state->enable)
+       if (!crtc_state->enable)
                return 0;
 
-       mode = &state->adjusted_mode;
+       mode = &crtc_state->adjusted_mode;
 
        ok = dispc_vp_mode_valid(dispc, hw_videoport, mode);
        if (ok != MODE_OK) {
@@ -109,7 +111,7 @@ static int tidss_crtc_atomic_check(struct drm_crtc *crtc,
                return -EINVAL;
        }
 
-       return dispc_vp_bus_check(dispc, hw_videoport, state);
+       return dispc_vp_bus_check(dispc, hw_videoport, crtc_state);
 }
 
 /*
index da2ab2aa35777d52faf2cba66855632ae2dbe290..d87a9fd4a20391c1d02481c52eef308adedd7a9b 100644 (file)
@@ -657,15 +657,17 @@ static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc,
 }
 
 static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
-                                   struct drm_crtc_state *state)
+                                   struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
        /* If we are not active we don't care */
-       if (!state->active)
+       if (!crtc_state->active)
                return 0;
 
-       if (state->state->planes[0].ptr != crtc->primary ||
-           state->state->planes[0].state == NULL ||
-           state->state->planes[0].state->crtc != crtc) {
+       if (crtc_state->state->planes[0].ptr != crtc->primary ||
+           crtc_state->state->planes[0].state == NULL ||
+           crtc_state->state->planes[0].state->crtc != crtc) {
                dev_dbg(crtc->dev->dev, "CRTC primary plane must be present");
                return -EINVAL;
        }
index f04f5cc8c839d652b95752c8045f45f5af56e19a..06088854c6478592ec856d6bff1cb114a319f0a1 100644 (file)
@@ -584,18 +584,21 @@ void vc4_crtc_get_margins(struct drm_crtc_state *state,
 }
 
 static int vc4_crtc_atomic_check(struct drm_crtc *crtc,
-                                struct drm_crtc_state *state)
+                                struct drm_atomic_state *state)
 {
-       struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(state);
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
+       struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc_state);
        struct drm_connector *conn;
        struct drm_connector_state *conn_state;
        int ret, i;
 
-       ret = vc4_hvs_atomic_check(crtc, state);
+       ret = vc4_hvs_atomic_check(crtc, crtc_state);
        if (ret)
                return ret;
 
-       for_each_new_connector_in_state(state->state, conn, conn_state, i) {
+       for_each_new_connector_in_state(crtc_state->state, conn, conn_state,
+                                       i) {
                if (conn_state->crtc != crtc)
                        continue;
 
index e0e0b72ea65cad517337624f3b36915b6473450b..34612edcabbd39c530c5d2c7b6d55e5c4add448e 100644 (file)
@@ -386,16 +386,18 @@ static const struct drm_crtc_funcs vc4_txp_crtc_funcs = {
 };
 
 static int vc4_txp_atomic_check(struct drm_crtc *crtc,
-                               struct drm_crtc_state *state)
+                               struct drm_atomic_state *state)
 {
-       struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(state);
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
+       struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc_state);
        int ret;
 
-       ret = vc4_hvs_atomic_check(crtc, state);
+       ret = vc4_hvs_atomic_check(crtc, crtc_state);
        if (ret)
                return ret;
 
-       state->no_vblank = true;
+       crtc_state->no_vblank = true;
        vc4_state->feed_txp = true;
 
        return 0;
index 48b3194ee0514802acdaff69b6d36684a9776781..e81183ab87e0567da03ff5e1ed9cd7edcc24f068 100644 (file)
@@ -111,7 +111,7 @@ static void virtio_gpu_crtc_atomic_disable(struct drm_crtc *crtc,
 }
 
 static int virtio_gpu_crtc_atomic_check(struct drm_crtc *crtc,
-                                       struct drm_crtc_state *state)
+                                       struct drm_atomic_state *state)
 {
        return 0;
 }
index e43e4e1b268a331f4f190a3290ce9e34a29d2942..6a49e70bdf18451de6bbf1251f0cd96112bb60c5 100644 (file)
@@ -168,9 +168,11 @@ static const struct drm_crtc_funcs vkms_crtc_funcs = {
 };
 
 static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
-                                 struct drm_crtc_state *state)
+                                 struct drm_atomic_state *state)
 {
-       struct vkms_crtc_state *vkms_state = to_vkms_crtc_state(state);
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
+       struct vkms_crtc_state *vkms_state = to_vkms_crtc_state(crtc_state);
        struct drm_plane *plane;
        struct drm_plane_state *plane_state;
        int i = 0, ret;
@@ -178,12 +180,12 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
        if (vkms_state->active_planes)
                return 0;
 
-       ret = drm_atomic_add_affected_planes(state->state, crtc);
+       ret = drm_atomic_add_affected_planes(crtc_state->state, crtc);
        if (ret < 0)
                return ret;
 
-       drm_for_each_plane_mask(plane, crtc->dev, state->plane_mask) {
-               plane_state = drm_atomic_get_existing_plane_state(state->state,
+       drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) {
+               plane_state = drm_atomic_get_existing_plane_state(crtc_state->state,
                                                                  plane);
                WARN_ON(!plane_state);
 
@@ -199,8 +201,8 @@ static int vkms_crtc_atomic_check(struct drm_crtc *crtc,
        vkms_state->num_active_planes = i;
 
        i = 0;
-       drm_for_each_plane_mask(plane, crtc->dev, state->plane_mask) {
-               plane_state = drm_atomic_get_existing_plane_state(state->state,
+       drm_for_each_plane_mask(plane, crtc->dev, crtc_state->plane_mask) {
+               plane_state = drm_atomic_get_existing_plane_state(crtc_state->state,
                                                                  plane);
 
                if (!plane_state->visible)
index 312ed0881a99b63c106abe60ab5bf2daa43a8aa8..a74c9454ade2e582a220478e1dee58cf607fa594 100644 (file)
@@ -522,8 +522,10 @@ int vmw_du_cursor_plane_atomic_check(struct drm_plane *plane,
 
 
 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
-                            struct drm_crtc_state *new_state)
+                            struct drm_atomic_state *state)
 {
+       struct drm_crtc_state *new_state = drm_atomic_get_new_crtc_state(state,
+                                                                        crtc);
        struct vmw_display_unit *du = vmw_crtc_to_du(new_state->crtc);
        int connector_mask = drm_connector_mask(&du->connector);
        bool has_primary = new_state->plane_mask &
index 3ee03227607c60b70d5febc697ab499fc615293e..b3d4e7b4c8c573ab1e8543c6f1ce8d41118a1b0e 100644 (file)
@@ -473,7 +473,7 @@ void vmw_du_plane_unpin_surf(struct vmw_plane_state *vps,
                             bool unreference);
 
 int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
-                            struct drm_crtc_state *state);
+                            struct drm_atomic_state *state);
 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
                              struct drm_crtc_state *old_crtc_state);
 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
index 5802752860dd2c7c21ada318617070429233da3f..058fbcebe6ce7dba535734e3c60d05aca974ffc8 100644 (file)
@@ -1504,9 +1504,11 @@ zynqmp_disp_crtc_atomic_disable(struct drm_crtc *crtc,
 }
 
 static int zynqmp_disp_crtc_atomic_check(struct drm_crtc *crtc,
-                                        struct drm_crtc_state *state)
+                                        struct drm_atomic_state *state)
 {
-       return drm_atomic_add_affected_planes(state->state, crtc);
+       struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state,
+                                                                         crtc);
+       return drm_atomic_add_affected_planes(crtc_state->state, crtc);
 }
 
 static void
index bde42988c4b5b7323a1e7089086c9be27412fcd6..b97441deaf93e2f70a257c369cd277451699e4a0 100644 (file)
@@ -336,8 +336,7 @@ struct drm_crtc_helper_funcs {
         *
         * This function is called in the check phase of an atomic update. The
         * driver is not allowed to change anything outside of the free-standing
-        * state objects passed-in or assembled in the overall &drm_atomic_state
-        * update tracking structure.
+        * state object passed-in.
         *
         * Also beware that userspace can request its own custom modes, neither
         * core nor helpers filter modes to the list of probe modes reported by
@@ -353,7 +352,7 @@ struct drm_crtc_helper_funcs {
         * deadlock.
         */
        int (*atomic_check)(struct drm_crtc *crtc,
-                           struct drm_crtc_state *state);
+                           struct drm_atomic_state *state);
 
        /**
         * @atomic_begin: