[Intel-gfx] [PATCH 03/38] drm/msm: Use for_each_*_in_state
Maarten Lankhorst
maarten.lankhorst at linux.intel.com
Thu Jun 2 13:13:03 UTC 2016
Op 02-06-16 om 00:06 schreef Daniel Vetter:
> We want to hide drm_atomic_state internals
>
> Cc: Rob Clark <robdclark at gmail.com>
> Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
> ---
> drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c | 20 +++++++----------
> drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c | 12 +++-------
> drivers/gpu/drm/msm/msm_atomic.c | 35 ++++++++++--------------------
> drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 1 +
> 4 files changed, 23 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
> index 67442d50a6c2..f145d256e332 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp4/mdp4_kms.c
> @@ -106,31 +106,27 @@ out:
> static void mdp4_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *state)
> {
> struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
> - int i, ncrtcs = state->dev->mode_config.num_crtc;
> + int i;
> + struct drm_crtc *crtc;
> + struct drm_crtc_state *crtc_state;
>
> mdp4_enable(mdp4_kms);
>
> /* see 119ecb7fd */
> - for (i = 0; i < ncrtcs; i++) {
> - struct drm_crtc *crtc = state->crtcs[i];
> - if (!crtc)
> - continue;
> + for_each_crtc_in_state(state, crtc, crtc_state, i)
> drm_crtc_vblank_get(crtc);
> - }
> }
>
> static void mdp4_complete_commit(struct msm_kms *kms, struct drm_atomic_state *state)
> {
> struct mdp4_kms *mdp4_kms = to_mdp4_kms(to_mdp_kms(kms));
> - int i, ncrtcs = state->dev->mode_config.num_crtc;
> + int i;
> + struct drm_crtc *crtc;
> + struct drm_crtc_state *crtc_state;
>
> /* see 119ecb7fd */
> - for (i = 0; i < ncrtcs; i++) {
> - struct drm_crtc *crtc = state->crtcs[i];
> - if (!crtc)
> - continue;
> + for_each_crtc_in_state(state, crtc, crtc_state, i)
> drm_crtc_vblank_put(crtc);
> - }
>
> mdp4_disable(mdp4_kms);
> }
> diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
> index 484b4d15e71d..f0c285b1c027 100644
> --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
> +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.c
> @@ -78,17 +78,11 @@ static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *s
> {
> int i;
> struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
> - int nplanes = mdp5_kms->dev->mode_config.num_total_plane;
> -
> - for (i = 0; i < nplanes; i++) {
> - struct drm_plane *plane = state->planes[i];
> - struct drm_plane_state *plane_state = state->plane_states[i];
> -
> - if (!plane)
> - continue;
> + struct drm_plane *plane;
> + struct drm_plane_state *plane_state;
>
> + for_each_plane_in_state(state, plane, plane_state, i)
> mdp5_plane_complete_commit(plane, plane_state);
> - }
>
> mdp5_disable(mdp5_kms);
> }
> diff --git a/drivers/gpu/drm/msm/msm_atomic.c b/drivers/gpu/drm/msm/msm_atomic.c
> index e3892c263f27..9c0e4261dbba 100644
> --- a/drivers/gpu/drm/msm/msm_atomic.c
> +++ b/drivers/gpu/drm/msm/msm_atomic.c
> @@ -84,17 +84,12 @@ static void msm_atomic_wait_for_commit_done(struct drm_device *dev,
> struct drm_atomic_state *old_state)
> {
> struct drm_crtc *crtc;
> + struct drm_crtc_state *crtc_state;
> struct msm_drm_private *priv = old_state->dev->dev_private;
> struct msm_kms *kms = priv->kms;
> - int ncrtcs = old_state->dev->mode_config.num_crtc;
> int i;
>
> - for (i = 0; i < ncrtcs; i++) {
> - crtc = old_state->crtcs[i];
> -
> - if (!crtc)
> - continue;
> -
> + for_each_crtc_in_state(old_state, crtc, crtc_state, i) {
> if (!crtc->state->enable)
> continue;
>
> @@ -192,9 +187,11 @@ int msm_atomic_commit(struct drm_device *dev,
> struct drm_atomic_state *state, bool nonblock)
> {
> struct msm_drm_private *priv = dev->dev_private;
> - int nplanes = dev->mode_config.num_total_plane;
> - int ncrtcs = dev->mode_config.num_crtc;
> struct msm_commit *c;
> + struct drm_crtc *crtc;
> + struct drm_crtc_state *crtc_state;
> + struct drm_plane *plane;
> + struct drm_plane_state *plane_state;
> int i, ret;
>
> ret = drm_atomic_helper_prepare_planes(dev, state);
> @@ -210,28 +207,18 @@ int msm_atomic_commit(struct drm_device *dev,
> /*
> * Figure out what crtcs we have:
> */
> - for (i = 0; i < ncrtcs; i++) {
> - struct drm_crtc *crtc = state->crtcs[i];
> - if (!crtc)
> - continue;
> + for_each_crtc_in_state(state, crtc, crtc_state, i)
> c->crtc_mask |= (1 << drm_crtc_index(crtc));
Maybe also change this to use drm_crtc_mask(crtc); ?
> - }
>
> /*
> * Figure out what fence to wait for:
> */
> - for (i = 0; i < nplanes; i++) {
> - struct drm_plane *plane = state->planes[i];
> - struct drm_plane_state *new_state = state->plane_states[i];
> -
> - if (!plane)
> - continue;
> -
> - if ((plane->state->fb != new_state->fb) && new_state->fb) {
> - struct drm_gem_object *obj = msm_framebuffer_bo(new_state->fb, 0);
> + for_each_plane_in_state(state, plane, plane_state, i) {
> + if ((plane->state->fb != plane_state->fb) && plane_state->fb) {
> + struct drm_gem_object *obj = msm_framebuffer_bo(plane_state->fb, 0);
> struct msm_gem_object *msm_obj = to_msm_bo(obj);
>
> - new_state->fence = reservation_object_get_excl_rcu(msm_obj->resv);
> + plane_state->fence = reservation_object_get_excl_rcu(msm_obj->resv);
> }
> }
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> index 755cfdba61cd..03913b483506 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c
> @@ -197,6 +197,7 @@ rockchip_atomic_wait_for_complete(struct drm_device *dev, struct drm_atomic_stat
> struct drm_crtc *crtc;
> int i, ret;
>
> +
> for_each_crtc_in_state(old_state, crtc, old_crtc_state, i) {
> /* No one cares about the old state, so abuse it for tracking
> * and store whether we hold a vblank reference (and should do a
What's this doing here?
With whitespace change removed.
Reviewed-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
More information about the Intel-gfx
mailing list