<div dir="ltr"><div dir="ltr">On Thu, Jan 9, 2020 at 4:27 PM Ville Syrjälä <<a href="mailto:ville.syrjala@linux.intel.com">ville.syrjala@linux.intel.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Jan 09, 2020 at 04:07:52PM +0100, Mario Kleiner wrote:<br>
> If the current eDP link rate, as read from hw, provides a<br>
> higher bandwidth than the standard link rates, then add the<br>
> current link rate to the link_rates array for consideration<br>
> in future mode-sets.<br>
> <br>
> These initial current eDP link settings have been set up by<br>
> firmware during boot, so they should work on the eDP panel.<br>
> Therefore use them if the firmware thinks they are good and<br>
> they provide higher link bandwidth, e.g., to enable higher<br>
> resolutions / color depths.<br>
> <br>
> This fixes a problem found on the MacBookPro 2017 Retina panel:<br>
> <br>
> The panel reports 10 bpc color depth in its EDID, and the UEFI<br>
> firmware chooses link settings at boot which support enough<br>
> bandwidth for 10 bpc (324000 kbit/sec to be precise), but the<br>
> DP_MAX_LINK_RATE dpcd register only reports 2.7 Gbps as possible,<br>
> so intel_dp_set_sink_rates() would cap at that. This restricts<br>
> achievable color depth to 8 bpc, not providing the full color<br>
> depth of the panel. With this commit, we can use firmware setting<br>
> and get the full 10 bpc advertised by the Retina panel.<br>
> <br>
> Signed-off-by: Mario Kleiner <<a href="mailto:mario.kleiner.de@gmail.com" target="_blank">mario.kleiner.de@gmail.com</a>><br>
> Cc: Daniel Vetter <<a href="mailto:daniel.vetter@ffwll.ch" target="_blank">daniel.vetter@ffwll.ch</a>><br>
> ---<br>
> drivers/gpu/drm/i915/display/intel_dp.c | 23 +++++++++++++++++++++++<br>
> 1 file changed, 23 insertions(+)<br>
> <br>
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c<br>
> index 2f31d226c6eb..aa3e0b5108c6 100644<br>
> --- a/drivers/gpu/drm/i915/display/intel_dp.c<br>
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c<br>
> @@ -4368,6 +4368,8 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp)<br>
> {<br>
> struct drm_i915_private *dev_priv =<br>
> to_i915(dp_to_dig_port(intel_dp)-><a href="http://base.base.dev" rel="noreferrer" target="_blank">base.base.dev</a>);<br>
> + int max_rate;<br>
> + u8 link_bw;<br>
> <br>
> /* this function is meant to be called only once */<br>
> WARN_ON(intel_dp->dpcd[DP_DPCD_REV] != 0);<br>
> @@ -4433,6 +4435,27 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp)<br>
> else<br>
> intel_dp_set_sink_rates(intel_dp);<br>
> <br>
> + /*<br>
> + * If the firmware programmed a rate higher than the standard sink rates<br>
> + * during boot, then add that rate as a valid sink rate, as fw knows<br>
> + * this is a good rate and we get extra bandwidth.<br>
> + *<br>
> + * Helps, e.g., on the Apple MacBookPro 2017 Retina panel, which is only<br>
> + * eDP 1.1, but supports the unusual rate of 324000 kHz at bootup, for<br>
> + * 10 bpc / 30 bit color depth.<br>
> + */<br>
> + if (!intel_dp->use_rate_select &&<br>
> + (drm_dp_dpcd_read(&intel_dp->aux, DP_LINK_BW_SET, &link_bw, 1) == 1) &&<br>
> + (link_bw > 0) && (intel_dp->num_sink_rates < DP_MAX_SUPPORTED_RATES)) {<br>
> + max_rate = drm_dp_bw_code_to_link_rate(link_bw);<br>
> + if (max_rate > intel_dp->sink_rates[intel_dp->num_sink_rates - 1]) {<br>
> + intel_dp->sink_rates[intel_dp->num_sink_rates] = max_rate;<br>
> + intel_dp->num_sink_rates++;<br>
> + DRM_DEBUG_KMS("Adding max bandwidth eDP rate %d kHz.\n",<br>
> + max_rate);<br>
> + }<br>
<br>
Hmm. I guess we could do this. But plese put it into a separate<br>
function so we don't end up with that super ugly if condition.<br>
<br></blockquote><div><br></div><div>Ok. Does static void intel_edp_add_bootup_rate() good to you? Or intel_edp_add_fw_rate()?</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The debug message should probably be a bit more explicit. Eg. <br>
something like: <br>
"Firmware using non-standard link rate %d kHz. Including it in sink rates.\n"<br></blockquote><div><br></div><div>Ok.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I'm also wondering if we shouldn't just add the link rate to the sink<br>
rates regradless of whether it's the highest rate or not...<br>
<br></blockquote><div><br></div><div>I tried to be conservative, and simple, but yes, one could add it anyway. Would need to preserve the order in the sink_rates[] array.</div><div>Your choice, your're the expert :)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> + }<br>
> +<br>
> intel_dp_set_common_rates(intel_dp);<br>
> <br>
> /* Read the eDP DSC DPCD registers */<br>
> -- <br>
> 2.24.0<br>
> <br>
> _______________________________________________<br>
> dri-devel mailing list<br>
> <a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
<br>
-- <br>
Ville Syrjälä<br>
Intel<br>
</blockquote></div></div>