Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/atomic: Extract needs_modeset function

We use the same check already in the atomic core, so might as well
make this official. And it's also reused in e.g. i915.

Motivated by Maarten's idea to extract a connector_changed state out
of mode_changed.

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-By: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>

+12 -13
+1 -2
drivers/gpu/drm/drm_atomic.c
··· 1216 1216 1217 1217 if (!state->allow_modeset) { 1218 1218 for_each_crtc_in_state(state, crtc, crtc_state, i) { 1219 - if (crtc_state->mode_changed || 1220 - crtc_state->active_changed) { 1219 + if (drm_atomic_crtc_needs_modeset(crtc_state)) { 1221 1220 DRM_DEBUG_ATOMIC("[CRTC:%d] requires full modeset\n", 1222 1221 crtc->base.id); 1223 1222 return -EINVAL;
+5 -11
drivers/gpu/drm/drm_atomic_helper.c
··· 331 331 return 0; 332 332 } 333 333 334 - static bool 335 - needs_modeset(struct drm_crtc_state *state) 336 - { 337 - return state->mode_changed || state->active_changed; 338 - } 339 - 340 334 /** 341 335 * drm_atomic_helper_check_modeset - validate state object for modeset changes 342 336 * @dev: DRM device ··· 408 414 crtc_state->active_changed = true; 409 415 } 410 416 411 - if (!needs_modeset(crtc_state)) 417 + if (!drm_atomic_crtc_needs_modeset(crtc_state)) 412 418 continue; 413 419 414 420 DRM_DEBUG_ATOMIC("[CRTC:%d] needs all connectors, enable: %c, active: %c\n", ··· 558 564 old_crtc_state = old_state->crtc_states[drm_crtc_index(old_conn_state->crtc)]; 559 565 560 566 if (!old_crtc_state->active || 561 - !needs_modeset(old_conn_state->crtc->state)) 567 + !drm_atomic_crtc_needs_modeset(old_conn_state->crtc->state)) 562 568 continue; 563 569 564 570 encoder = old_conn_state->best_encoder; ··· 595 601 const struct drm_crtc_helper_funcs *funcs; 596 602 597 603 /* Shut down everything that needs a full modeset. */ 598 - if (!needs_modeset(crtc->state)) 604 + if (!drm_atomic_crtc_needs_modeset(crtc->state)) 599 605 continue; 600 606 601 607 if (!old_crtc_state->active) ··· 786 792 const struct drm_crtc_helper_funcs *funcs; 787 793 788 794 /* Need to filter out CRTCs where only planes change. */ 789 - if (!needs_modeset(crtc->state)) 795 + if (!drm_atomic_crtc_needs_modeset(crtc->state)) 790 796 continue; 791 797 792 798 if (!crtc->state->active) ··· 813 819 continue; 814 820 815 821 if (!connector->state->crtc->state->active || 816 - !needs_modeset(connector->state->crtc->state)) 822 + !drm_atomic_crtc_needs_modeset(connector->state->crtc->state)) 817 823 continue; 818 824 819 825 encoder = connector->state->best_encoder;
+6
include/drm/drm_atomic.h
··· 163 163 (plane_state) = (state)->plane_states[__i], 1); \ 164 164 (__i)++) \ 165 165 if (plane_state) 166 + static inline bool 167 + drm_atomic_crtc_needs_modeset(struct drm_crtc_state *state) 168 + { 169 + return state->mode_changed || state->active_changed; 170 + } 171 + 166 172 167 173 #endif /* DRM_ATOMIC_H_ */