Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2943159pxy; Mon, 3 May 2021 11:22:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw19sROlz1js+IgtSXZzNHu1wSSBWuefU8XQWPBZfI556H6omAdE4h61stAubi2exCNlc2K X-Received: by 2002:a17:902:7081:b029:ec:c083:878a with SMTP id z1-20020a1709027081b02900ecc083878amr21590357plk.76.1620066175829; Mon, 03 May 2021 11:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620066175; cv=none; d=google.com; s=arc-20160816; b=rCxhXoNdEoCvC5aaAo8mEWmu/4DcTNJHLeYOBlcLCLKKZIBcJAUuvZXAKTUDo4UGu4 s4nD0YDFa6dWReZJoibml80PkIpDMiouaUc52ASGJVvynkIeMdK6ZtUuKrpElKXxBB66 exMtKAqaw8Nzb4qgoZ4i7JKRPn7fCa1RHIe9Uyog8L6nwLoWl8RaOXSnsec/6aVLwXRu lSmY3/t76Z1/KpbtU5G3YgUoYy4QeOsqGEchYOgHJjW/aOkbrLHjM75NM3/KbLJ4CViu 2wVEjo3ynmgvdHph0UPsa1a5smK1ESZweBENT25MwUVe7nQGfNe36nDLa9iptBDdcaQ0 bX7A== 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:to:from; bh=iujyPpcbpRsZYLl5yqCta6qHJ4N1Czslq0XyS0xaoX8=; b=UjHAOMiDWEzaCVIKG12eW+7IbgG/g0MMw4U73fP8+ejdFedFTBsFgRvSco2DFOxP60 f6XtnuTe1QenQNBOhVjVXfApWzS3lzRPKvSi7I1WCxtNuIKzvshOdUp4UniP9KRdPwEb Op5yByvobbkZTO0+ZNQfo1PRGMAkSR1fvV7ZPjfUxUcybe1gEiI3U80CgcOLjJksmF7D szMigq8KLq+hNxWjW4rogar5BZl9X2on2yjH4lhEbYMyjlrLQMCUOLHLH3EjWi4WTWzE WXZpsn6ImkUF2DyqjX4vAxnneGvnlbltmWG0kY4RFqJQldDWHxLB9qmuqSBqRuOvytIF glow== 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 s1si449976plq.245.2021.05.03.11.22.42; Mon, 03 May 2021 11:22:55 -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 S229739AbhECSW5 (ORCPT + 99 others); Mon, 3 May 2021 14:22:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbhECSW4 (ORCPT ); Mon, 3 May 2021 14:22:56 -0400 Received: from srv6.fidu.org (srv6.fidu.org [IPv6:2a01:4f8:231:de0::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F017BC06174A for ; Mon, 3 May 2021 11:21:56 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by srv6.fidu.org (Postfix) with ESMTP id CEFAFC800D4; Mon, 3 May 2021 20:21:53 +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 uZQGOFwRhbT2; Mon, 3 May 2021 20:21:53 +0200 (CEST) Received: from wsembach-tuxedo.fritz.box (p200300E37f3986001A8B79e0b24CB29D.dip0.t-ipconnect.de [IPv6:2003:e3:7f39:8600:1a8b:79e0:b24c:b29d]) (Authenticated sender: wse@tuxedocomputers.com) by srv6.fidu.org (Postfix) with ESMTPA id 8079AC800D0; Mon, 3 May 2021 20:21:53 +0200 (CEST) From: Werner Sembach To: wse@tuxedocomputers.com, 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 Subject: [PATCH 1/4] New function to avoid duplicate code in upcomming commits Date: Mon, 3 May 2021 20:21:45 +0200 Message-Id: <20210503182148.851790-2-wse@tuxedocomputers.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210503182148.851790-1-wse@tuxedocomputers.com> References: <20210503182148.851790-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 --- From 1c529783eb2ec02099d1ed2ab9257b008cb6f040 Mon Sep 17 00:00:00 2001 From: Werner Sembach Date: Mon, 3 May 2021 14:35:39 +0200 Subject: [PATCH 1/4] New function to avoid duplicate code in upcomming commits --- 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