Re: [PATCH v6 1/3] drm/i915/display: New function to avoid duplicate code in upcomming commits
From: Werner Sembach
Date: Fri May 07 2021 - 16:33:11 EST
Am 07.05.21 um 19:47 schrieb Ville Syrjälä:
> On Fri, May 07, 2021 at 10:49:01AM +0200, Werner Sembach wrote:
>> Moves some checks that later will be performed 2 times to an own function.
>> This avoids duplicate code later on.
>>
>> Signed-off-by: Werner Sembach <wse@xxxxxxxxxxxxxxxxxxx>
>> ---
>> drivers/gpu/drm/i915/display/intel_hdmi.c | 41 ++++++++++++++---------
>> 1 file changed, 26 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
>> index 46de56af33db..576d3d910d06 100644
>> --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
>> +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
>> @@ -1861,6 +1861,31 @@ static int intel_hdmi_port_clock(int clock, int bpc)
>> return clock * bpc / 8;
>> }
>>
>> +static enum drm_mode_status
>> +intel_hdmi_mode_clock_valid(struct intel_hdmi *hdmi, int clock, bool has_hdmi_sink)
>> +{
>> + struct drm_device *dev = intel_hdmi_to_dev(hdmi);
>> + struct drm_i915_private *dev_priv = to_i915(dev);
>> + enum drm_mode_status status;
>> +
>> + /* check if we can do 8bpc */
>> + status = hdmi_port_clock_valid(hdmi, clock, true, has_hdmi_sink);
>> +
>> + if (has_hdmi_sink) {
>> + /* if we can't do 8bpc we may still be able to do 12bpc */
>> + if (status != MODE_OK && !HAS_GMCH(dev_priv))
>> + status = hdmi_port_clock_valid(hdmi, clock * 3 / 2,
> Seems we've lost intel_hdmi_port_clock() here somehow.
Yes, I think it happened when I rebased from torvalds/master to drm-tip/drm-tip.
Thanks for pointing it out. Fixed.
>
>> + true, has_hdmi_sink);
>> +
>> + /* if we can't do 8,12bpc we may still be able to do 10bpc */
>> + if (status != MODE_OK && INTEL_GEN(dev_priv) >= 11)
>> + status = hdmi_port_clock_valid(hdmi, clock * 5 / 4,
> Also here.
>
>> + true, has_hdmi_sink);
>> + }
>> +
>> + return status;
>> +}
>> +
>> static enum drm_mode_status
>> intel_hdmi_mode_valid(struct drm_connector *connector,
>> struct drm_display_mode *mode)
>> @@ -1891,21 +1916,7 @@ intel_hdmi_mode_valid(struct drm_connector *connector,
>> if (drm_mode_is_420_only(&connector->display_info, mode))
>> clock /= 2;
>>
>> - /* check if we can do 8bpc */
>> - status = hdmi_port_clock_valid(hdmi, intel_hdmi_port_clock(clock, 8),
>> - true, has_hdmi_sink);
>> -
>> - if (has_hdmi_sink) {
>> - /* if we can't do 8bpc we may still be able to do 12bpc */
>> - if (status != MODE_OK && !HAS_GMCH(dev_priv))
>> - status = hdmi_port_clock_valid(hdmi, intel_hdmi_port_clock(clock, 12),
>> - true, has_hdmi_sink);
>> -
>> - /* if we can't do 8,12bpc we may still be able to do 10bpc */
>> - if (status != MODE_OK && DISPLAY_VER(dev_priv) >= 11)
>> - status = hdmi_port_clock_valid(hdmi, intel_hdmi_port_clock(clock, 10),
>> - true, has_hdmi_sink);
>> - }
>> + status = intel_hdmi_mode_clock_valid(hdmi, clock, has_hdmi_sink);
>> if (status != MODE_OK)
>> return status;
>>
>> --
>> 2.25.1