From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> Most of the code for preparing the 'struct intel_flip' instances was identical betwen the CRTC and plane codepaths. Refactor the common parts into a single function. Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx> --- drivers/gpu/drm/i915/intel_atomic.c | 122 +++++++++++++++-------------------- 1 files changed, 52 insertions(+), 70 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c index 36446d1..3717e89 100644 --- a/drivers/gpu/drm/i915/intel_atomic.c +++ b/drivers/gpu/drm/i915/intel_atomic.c @@ -2258,6 +2258,50 @@ void intel_atomic_wedged(struct drm_device *dev) spin_unlock_irqrestore(&dev_priv->flip.lock, flags); } +static void intel_atomic_flip_init(struct intel_flip *intel_flip, + struct drm_device *dev, + u32 flip_seq, + struct drm_i915_file_private *file_priv, + struct drm_pending_atomic_event *event, + struct drm_framebuffer *fb, + bool unpin_old_fb, struct drm_framebuffer *old_fb) +{ + intel_flip->flip_seq = flip_seq; + + if (event) { + intel_flip->event = event; + + /* need to keep track of it in case process exits */ + spin_lock_irq(&dev->event_lock); + list_add_tail(&intel_flip->pending_head, &file_priv->pending_flips); + spin_unlock_irq(&dev->event_lock); + } + + if (fb) { + struct drm_i915_gem_object *obj = to_intel_framebuffer(fb)->obj; + + mutex_lock(&dev->struct_mutex); +#ifdef USE_WRITE_SEQNO + intel_flip->seqno = obj->last_write_seqno; +#else + intel_flip->seqno = obj->last_read_seqno; +#endif + intel_flip->ring = obj->ring; + mutex_unlock(&dev->struct_mutex); + } + + if (old_fb) + intel_flip->old_fb_id = old_fb->base.id; + + if (unpin_old_fb && old_fb) { + intel_flip->old_bo = to_intel_framebuffer(old_fb)->obj; + + mutex_lock(&dev->struct_mutex); + drm_gem_object_reference(&intel_flip->old_bo->base); + mutex_unlock(&dev->struct_mutex); + } +} + static void atomic_pipe_commit(struct drm_device *dev, struct intel_atomic_state *state, int pipe) @@ -2290,33 +2334,13 @@ static void atomic_pipe_commit(struct drm_device *dev, drm_flip_init(&intel_flip->base, &intel_crtc->flip_helper); - intel_flip->flip_seq = flip_seq; - - if (st->event) { - intel_flip->event = st->event; - st->event = NULL; - /* need to keep track of it in case process exits */ - spin_lock_irq(&dev->event_lock); - list_add_tail(&intel_flip->pending_head, - &file_priv->pending_flips); - spin_unlock_irq(&dev->event_lock); - } + intel_atomic_flip_init(intel_flip, dev, flip_seq, + file_priv, st->event, crtc->fb, + st->fb_dirty, st->old.fb); + st->event = NULL; intel_flip->crtc = crtc; - if (crtc->fb) { - struct drm_i915_gem_object *obj = to_intel_framebuffer(crtc->fb)->obj; - - mutex_lock(&dev->struct_mutex); -#ifdef USE_WRITE_SEQNO - intel_flip->seqno = obj->last_write_seqno; -#else - intel_flip->seqno = obj->last_read_seqno; -#endif - intel_flip->ring = obj->ring; - mutex_unlock(&dev->struct_mutex); - } - /* update primary_disabled befoer calc_plane() */ intel_crtc->primary_disabled = st->primary_disabled; @@ -2330,17 +2354,6 @@ static void atomic_pipe_commit(struct drm_device *dev, intel_flip->old_cursor_bo = st->old.cursor_bo; } - if (st->old.fb) - intel_flip->old_fb_id = st->old.fb->base.id; - - if (st->fb_dirty && st->old.fb) { - intel_flip->old_bo = to_intel_framebuffer(st->old.fb)->obj; - - mutex_lock(&dev->struct_mutex); - drm_gem_object_reference(&intel_flip->old_bo->base); - mutex_unlock(&dev->struct_mutex); - } - list_add_tail(&intel_flip->base.list, &flips); } @@ -2361,48 +2374,17 @@ static void atomic_pipe_commit(struct drm_device *dev, drm_flip_init(&intel_flip->base, &intel_plane->flip_helper); - intel_flip->flip_seq = flip_seq; - - if (st->event) { - intel_flip->event = st->event; - st->event = NULL; - /* need to keep track of it in case process exits */ - spin_lock_irq(&dev->event_lock); - list_add_tail(&intel_flip->pending_head, - &file_priv->pending_flips); - spin_unlock_irq(&dev->event_lock); - } + intel_atomic_flip_init(intel_flip, dev, flip_seq, + file_priv, st->event, plane->fb, + st->dirty, st->old.fb); + st->event = NULL; intel_flip->crtc = intel_get_crtc_for_pipe(dev, pipe); intel_flip->plane = plane; - if (plane->fb) { - struct drm_i915_gem_object *obj = to_intel_framebuffer(plane->fb)->obj; - - mutex_lock(&dev->struct_mutex); -#ifdef USE_WRITE_SEQNO - intel_flip->seqno = obj->last_write_seqno; -#else - intel_flip->seqno = obj->last_read_seqno; -#endif - intel_flip->ring = obj->ring; - mutex_unlock(&dev->struct_mutex); - } - intel_plane->calc(plane, plane->fb, &st->coords); intel_flip->regs = intel_plane->regs; - if (st->old.fb) - intel_flip->old_fb_id = st->old.fb->base.id; - - if (st->dirty && st->old.fb) { - intel_flip->old_bo = to_intel_framebuffer(st->old.fb)->obj; - - mutex_lock(&dev->struct_mutex); - drm_gem_object_reference(&intel_flip->old_bo->base); - mutex_unlock(&dev->struct_mutex); - } - list_add_tail(&intel_flip->base.list, &flips); } -- 1.7.8.6 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel