Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp496279pxy; Wed, 5 May 2021 07:14:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6Ox2wSYURD/8N6D0BdgEmRYj34FqWPVt+Mmt7fzb5Nsi1irbHA24o4OcrL4PI8xagfbPv X-Received: by 2002:a05:6a00:1409:b029:27f:fb6a:24b5 with SMTP id l9-20020a056a001409b029027ffb6a24b5mr29055586pfu.18.1620224090638; Wed, 05 May 2021 07:14:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620224090; cv=none; d=google.com; s=arc-20160816; b=J2qhVfmM0h5mlgOaeNAy5gBddqvojdeLlnRQ46WzHASutZtQvDrUiC5p3H76+Wg7uR MLvVqa5bRjsYNvrNPlDeGN7AVDYNCeE0wwnx4qxLQBHeeoUpijeoYPQmb5iisUbuiUmW GsntEZZAZgP5PK9rnJ1XYlb7AmcFfJspM1krJSd53tHHf96buXo/TqHIsQsMytsdrkT8 WhvGqf8iLzany4vsWQcfJnQJDzpNfcwZoNv+WOJjCRhF+KJ5EvpiNsLHNsbcVklk93pQ E9IuxcMvlTUkn3ErgUy7ZweCZPI2n7Ct6foXQuswN4SiHcen795VEyQa6TJOg2BQgmXb XCgQ== 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=cGaX8h7UkN4efGw/bdj+Yg2dPiGtx8EdLPHvkgPcAEs=; b=NFD2jvDqn4K5heTk78jMQ7t9F0jyB9F+Zi+McT2wJwM7Tn2t0rNq8MMiLPQ1FbJnOB xW8HotRvgO0nh2aEs00979q/fmvXlZQwU0CpdIyDdZeNWX7F+5+8kmhbEcAi6S12R1TE xQD6y2+WjY318FWL5tGnbqF5rHpSo4LncgcDvhW/RWbMbnYSp9Fn4Rs5LovEqnQGq7kN 4WFSNfw203l/7uyNa95r34+9slq5bHpVT5Zh9g528zxVuO2slW6IxEpxXVdKb+xAkEAj d3FveKfnPU0bMNI5pHEeUw2VJI7gSbrgaz8RAUq5kTejQgBXzUIknjPKQ4GF18JZZCB+ 6wTg== 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 p5si8003550pjg.17.2021.05.05.07.14.36; Wed, 05 May 2021 07:14:50 -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 S233704AbhEEOL6 (ORCPT + 99 others); Wed, 5 May 2021 10:11:58 -0400 Received: from srv6.fidu.org ([159.69.62.71]:60344 "EHLO srv6.fidu.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233580AbhEEOLy (ORCPT ); Wed, 5 May 2021 10:11:54 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by srv6.fidu.org (Postfix) with ESMTP id 3229BC800B8; Wed, 5 May 2021 16:10:56 +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 Y2H4JWpKOGFz; Wed, 5 May 2021 16:10:56 +0200 (CEST) Received: from wsembach-tuxedo.fritz.box (p200300E37F39860005a4018A54F094b9.dip0.t-ipconnect.de [IPv6:2003:e3:7f39:8600:5a4:18a:54f0:94b9]) (Authenticated sender: wse@tuxedocomputers.com) by srv6.fidu.org (Postfix) with ESMTPA id D64EFC800B5; Wed, 5 May 2021 16:10:55 +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/3] New function to avoid duplicate code in upcomming commits Date: Wed, 5 May 2021 16:10:50 +0200 Message-Id: <20210505141052.3467-2-wse@tuxedocomputers.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210505141052.3467-1-wse@tuxedocomputers.com> References: <20210505141052.3467-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 --- PS.: I have no idea why git send-email is messing up this timestamp in "From" below. From 42a4a3a7d9ea9948b4071f406e7fcae23bfa0bdf Mon Sep 17 00:00:00 2001 From: Werner Sembach Date: Mon, 3 May 2021 14:35:39 +0200 Subject: [PATCH 1/3] 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