Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1566735pxy; Thu, 6 May 2021 10:25:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc0A7jj5L91zprJpU6DkjCRAgmZqYF87UVV3XI4M05I83hRZb7NfnaarEoWFl+n7VUbY3w X-Received: by 2002:a05:6402:10cd:: with SMTP id p13mr6672401edu.382.1620321948296; Thu, 06 May 2021 10:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620321948; cv=none; d=google.com; s=arc-20160816; b=rmUE3VpsY/0fLF2+SuyfduskAhx3V+3fyhwASlO8yjN9/ZiJr1NCXqpUgRUuci8Tdk A0sb+cXrr4as0gNiq0gVgZq1rBy/omHswbMn1dIybySwwSFTErqOFPnNLqLQXsxug7w4 RUL87K93uP9j25bqHIIEUWBe0jsQvXC4s3ECLmDdYsSp2acdxr1tG3E66RE+rg1uUZjH MLHUadFiRbEobm9oo8mtDSO6ETOyY5Rl79P/9paGVybCQ/PnJmB+/eV8A0jfRu+TCj3V KISz0LMT2xxaWA14nXK5Ych4ENQHAMvLXqZErSbay6CH99ValMIufbSgcjHwxAvSlWr3 hDcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=XXXgXFJhMhiSrwu5jA2yAdPmiZ3e7MLmr8ck6R5QT9U=; b=pVcHIZIeSBZc/lB37ZCFeCjl/mGLTuYfktSvytuikHXf3Ga8SguxAKcot03HlJrtbW xHmD3i5IG81tstlDCFlp0qdIYyHMFTsuw/Z2fDo4T6ciS5AzGIq601vEceWM3YNXKMru yU+m9HnaEJWaOpZC+GJjrl05QwQTCRJg5Me5CsdG6xJwXRK6p+L0Ge1KLWT+FcmHjbNZ c+IX4+OpTcriO4rcFWlH8l0wUB3A/jgaUzqCBhLlMIE2Bj9KDsxfxqhM+HLUKGhVSYxj hepsqTu1CvvwQntnRMOwGiTNxtK5//gO9feqKKKYiU7Y/ixaqY31kpvEOBJ68g0nxJ6s tQRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w10si2810402edd.545.2021.05.06.10.25.22; Thu, 06 May 2021 10:25:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236270AbhEFRYt (ORCPT + 99 others); Thu, 6 May 2021 13:24:49 -0400 Received: from srv6.fidu.org ([159.69.62.71]:57744 "EHLO srv6.fidu.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236248AbhEFRYr (ORCPT ); Thu, 6 May 2021 13:24:47 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by srv6.fidu.org (Postfix) with ESMTP id 424ADC800AE; Thu, 6 May 2021 19:23:46 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at srv6.fidu.org Received: from srv6.fidu.org ([127.0.0.1]) by localhost (srv6.fidu.org [127.0.0.1]) (amavisd-new, port 10026) with LMTP id WB3n034q-CHi; Thu, 6 May 2021 19:23:46 +0200 (CEST) Received: from wsembach-tuxedo.fritz.box (p200300e37F12f2008bdED9a70B37E3f5.dip0.t-ipconnect.de [IPv6:2003:e3:7f12:f200:8bde:d9a7:b37:e3f5]) (Authenticated sender: wse@tuxedocomputers.com) by srv6.fidu.org (Postfix) with ESMTPA id E59FEC800AB; Thu, 6 May 2021 19:23:45 +0200 (CEST) From: Werner Sembach To: ville.syrjala@linux.intel.com, airlied@linux.ie, daniel@ffwll.ch, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Werner Sembach Subject: [PATCH 1/3] drm/i915/display: New function to avoid duplicate code in upcomming commits Date: Thu, 6 May 2021 19:23:23 +0200 Message-Id: <20210506172325.1995964-2-wse@tuxedocomputers.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210506172325.1995964-1-wse@tuxedocomputers.com> References: <20210506172325.1995964-1-wse@tuxedocomputers.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Moves some checks that later will be performed 2 times to an own fuction. This avoids duplicate code later on. Signed-off-by: Werner Sembach --- 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, + 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, + 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