Skip to content

Commit faf94a0

Browse files
joabreudanvet
authored andcommitted
drm: Use mode_valid() in atomic modeset
This patches makes use of the new mode_valid() callbacks introduced previously to validate the full video pipeline when modesetting. This calls the connector->mode_valid(), encoder->mode_valid(), bridge->mode_valid() and crtc->mode_valid() so that we can make sure that the mode will be accepted in every components. Signed-off-by: Jose Abreu <joabreu@synopsys.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Andrzej Hajda <a.hajda@samsung.com> Cc: Carlos Palminha <palminha@synopsys.com> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Dave Airlie <airlied@linux.ie> Cc: Andrzej Hajda <a.hajda@samsung.com> Cc: Archit Taneja <architt@codeaurora.org> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Changes v1->v2: - Removed call to connector->mode_valid (Ville, Daniel) - Changed function name (Ville) - Use for_each_new_connector_in_state (Ville) - Do not validate if connector and mode didn't change (Ville) - Use new helpers to call mode_valid Signed-off-by: Jose Abreu <joabreu@synopsys.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/a457d6a69ad07b3936304653c919068c430c0857.1495720737.git.joabreu@synopsys.com
1 parent 97f973d commit faf94a0

1 file changed

Lines changed: 73 additions & 3 deletions

File tree

‎drivers/gpu/drm/drm_atomic_helper.c‎

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <drm/drm_atomic_helper.h>
3333
#include <linux/dma-fence.h>
3434

35+
#include "drm_crtc_helper_internal.h"
3536
#include "drm_crtc_internal.h"
3637

3738
/**
@@ -452,6 +453,69 @@ mode_fixup(struct drm_atomic_state *state)
452453
return 0;
453454
}
454455

456+
static enum drm_mode_status mode_valid_path(struct drm_connector *connector,
457+
struct drm_encoder *encoder,
458+
struct drm_crtc *crtc,
459+
struct drm_display_mode *mode)
460+
{
461+
enum drm_mode_status ret;
462+
463+
ret = drm_encoder_mode_valid(encoder, mode);
464+
if (ret != MODE_OK) {
465+
DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] mode_valid() failed\n",
466+
encoder->base.id, encoder->name);
467+
return ret;
468+
}
469+
470+
ret = drm_bridge_mode_valid(encoder->bridge, mode);
471+
if (ret != MODE_OK) {
472+
DRM_DEBUG_ATOMIC("[BRIDGE] mode_valid() failed\n");
473+
return ret;
474+
}
475+
476+
ret = drm_crtc_mode_valid(crtc, mode);
477+
if (ret != MODE_OK) {
478+
DRM_DEBUG_ATOMIC("[CRTC:%d:%s] mode_valid() failed\n",
479+
crtc->base.id, crtc->name);
480+
return ret;
481+
}
482+
483+
return ret;
484+
}
485+
486+
static int
487+
mode_valid(struct drm_atomic_state *state)
488+
{
489+
struct drm_connector_state *conn_state;
490+
struct drm_connector *connector;
491+
int i;
492+
493+
for_each_new_connector_in_state(state, connector, conn_state, i) {
494+
struct drm_encoder *encoder = conn_state->best_encoder;
495+
struct drm_crtc *crtc = conn_state->crtc;
496+
struct drm_crtc_state *crtc_state;
497+
enum drm_mode_status mode_status;
498+
struct drm_display_mode *mode;
499+
500+
if (!crtc || !encoder)
501+
continue;
502+
503+
crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
504+
if (!crtc_state)
505+
continue;
506+
if (!crtc_state->mode_changed && !crtc_state->connectors_changed)
507+
continue;
508+
509+
mode = &crtc_state->mode;
510+
511+
mode_status = mode_valid_path(connector, encoder, crtc, mode);
512+
if (mode_status != MODE_OK)
513+
return -EINVAL;
514+
}
515+
516+
return 0;
517+
}
518+
455519
/**
456520
* drm_atomic_helper_check_modeset - validate state object for modeset changes
457521
* @dev: DRM device
@@ -466,13 +530,15 @@ mode_fixup(struct drm_atomic_state *state)
466530
* 2. &drm_connector_helper_funcs.atomic_check to validate the connector state.
467531
* 3. If it's determined a modeset is needed then all connectors on the affected crtc
468532
* crtc are added and &drm_connector_helper_funcs.atomic_check is run on them.
469-
* 4. &drm_bridge_funcs.mode_fixup is called on all encoder bridges.
470-
* 5. &drm_encoder_helper_funcs.atomic_check is called to validate any encoder state.
533+
* 4. &drm_encoder_helper_funcs.mode_valid, &drm_bridge_funcs.mode_valid and
534+
* &drm_crtc_helper_funcs.mode_valid are called on the affected components.
535+
* 5. &drm_bridge_funcs.mode_fixup is called on all encoder bridges.
536+
* 6. &drm_encoder_helper_funcs.atomic_check is called to validate any encoder state.
471537
* This function is only called when the encoder will be part of a configured crtc,
472538
* it must not be used for implementing connector property validation.
473539
* If this function is NULL, &drm_atomic_encoder_helper_funcs.mode_fixup is called
474540
* instead.
475-
* 6. &drm_crtc_helper_funcs.mode_fixup is called last, to fix up the mode with crtc constraints.
541+
* 7. &drm_crtc_helper_funcs.mode_fixup is called last, to fix up the mode with crtc constraints.
476542
*
477543
* &drm_crtc_state.mode_changed is set when the input mode is changed.
478544
* &drm_crtc_state.connectors_changed is set when a connector is added or
@@ -617,6 +683,10 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
617683
return ret;
618684
}
619685

686+
ret = mode_valid(state);
687+
if (ret)
688+
return ret;
689+
620690
return mode_fixup(state);
621691
}
622692
EXPORT_SYMBOL(drm_atomic_helper_check_modeset);

0 commit comments

Comments
 (0)