Skip to content

Commit 97f973d

Browse files
joabreudanvet
authored andcommitted
drm: Use new mode_valid() helpers in connector probe helper
This changes the connector probe helper function to use the new encoder->mode_valid(), bridge->mode_valid() and crtc->mode_valid() helper callbacks to validate the modes. The new callbacks are optional so the behaviour remains the same if they are not implemented. If they are, then the code loops through all the connector's encodersXbridgesXcrtcs and calls the callback. If at least a valid encoderXbridgeXcrtc combination is found which accepts the mode then the function returns MODE_OK. Signed-off-by: Jose Abreu <joabreu@synopsys.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Carlos Palminha <palminha@synopsys.com> Cc: Dave Airlie <airlied@linux.ie> Cc: Andrzej Hajda <a.hajda@samsung.com> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Changes v3->v4: - Change function name (Laurent) Changes v2->v3: - Call also bridge->mode_valid (Daniel) Changes v1->v2: - Use new helpers suggested by Ville - Change documentation (Daniel) Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/d4e3ba87d822fa92f1b8773e441b9a02af3bde71.1495720737.git.joabreu@synopsys.com
1 parent b1240f8 commit 97f973d

1 file changed

Lines changed: 63 additions & 4 deletions

File tree

‎drivers/gpu/drm/drm_probe_helper.c‎

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,61 @@ drm_mode_validate_flag(const struct drm_display_mode *mode,
8383
return MODE_OK;
8484
}
8585

86+
static enum drm_mode_status
87+
drm_mode_validate_pipeline(struct drm_display_mode *mode,
88+
struct drm_connector *connector)
89+
{
90+
struct drm_device *dev = connector->dev;
91+
uint32_t *ids = connector->encoder_ids;
92+
enum drm_mode_status ret = MODE_OK;
93+
unsigned int i;
94+
95+
/* Step 1: Validate against connector */
96+
ret = drm_connector_mode_valid(connector, mode);
97+
if (ret != MODE_OK)
98+
return ret;
99+
100+
/* Step 2: Validate against encoders and crtcs */
101+
for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
102+
struct drm_encoder *encoder = drm_encoder_find(dev, ids[i]);
103+
struct drm_crtc *crtc;
104+
105+
if (!encoder)
106+
continue;
107+
108+
ret = drm_encoder_mode_valid(encoder, mode);
109+
if (ret != MODE_OK) {
110+
/* No point in continuing for crtc check as this encoder
111+
* will not accept the mode anyway. If all encoders
112+
* reject the mode then, at exit, ret will not be
113+
* MODE_OK. */
114+
continue;
115+
}
116+
117+
ret = drm_bridge_mode_valid(encoder->bridge, mode);
118+
if (ret != MODE_OK) {
119+
/* There is also no point in continuing for crtc check
120+
* here. */
121+
continue;
122+
}
123+
124+
drm_for_each_crtc(crtc, dev) {
125+
if (!drm_encoder_crtc_ok(encoder, crtc))
126+
continue;
127+
128+
ret = drm_crtc_mode_valid(crtc, mode);
129+
if (ret == MODE_OK) {
130+
/* If we get to this point there is at least
131+
* one combination of encoder+crtc that works
132+
* for this mode. Lets return now. */
133+
return ret;
134+
}
135+
}
136+
}
137+
138+
return ret;
139+
}
140+
86141
static int drm_helper_probe_add_cmdline_mode(struct drm_connector *connector)
87142
{
88143
struct drm_cmdline_mode *cmdline_mode;
@@ -322,7 +377,11 @@ EXPORT_SYMBOL(drm_helper_probe_detect);
322377
* - drm_mode_validate_flag() checks the modes against basic connector
323378
* capabilities (interlace_allowed,doublescan_allowed,stereo_allowed)
324379
* - the optional &drm_connector_helper_funcs.mode_valid helper can perform
325-
* driver and/or hardware specific checks
380+
* driver and/or sink specific checks
381+
* - the optional &drm_crtc_helper_funcs.mode_valid,
382+
* &drm_bridge_funcs.mode_valid and &drm_encoder_helper_funcs.mode_valid
383+
* helpers can perform driver and/or source specific checks which are also
384+
* enforced by the modeset/atomic helpers
326385
*
327386
* 5. Any mode whose status is not OK is pruned from the connector's modes list,
328387
* accompanied by a debug message indicating the reason for the mode's
@@ -466,9 +525,9 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
466525
if (mode->status == MODE_OK)
467526
mode->status = drm_mode_validate_flag(mode, mode_flags);
468527

469-
if (mode->status == MODE_OK && connector_funcs->mode_valid)
470-
mode->status = connector_funcs->mode_valid(connector,
471-
mode);
528+
if (mode->status == MODE_OK)
529+
mode->status = drm_mode_validate_pipeline(mode,
530+
connector);
472531
}
473532

474533
prune:

0 commit comments

Comments
 (0)