Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2602095pxj; Mon, 10 May 2021 06:48:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDXRwg9U27XTfLYwBhUMqG1Lzre3uLSNREHmH6PrPb9/MawMefziswqLIml19kVkZupB0V X-Received: by 2002:a17:906:3385:: with SMTP id v5mr25610645eja.539.1620654514407; Mon, 10 May 2021 06:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620654514; cv=none; d=google.com; s=arc-20160816; b=uYCzSyVtoX6fMHLiBhFF/TDTiRkGNiJuajKWj3p0FMSZA4su+ErPwET54fVaX80rPP znhkCkgA8ANwtydHmU+NdwjS0SM+tUfZXP+MWYagbkqT1F2VH3cZYKCO+uNic/4QTZF4 iyF1wXB4FO1pDcZBwlC8JBXzfOM4IlEDB8Q+FEnMMX6DQwtBWXqAqoLIKi4NnGoqHX4q R8jSpp3/GL7U45P7e66u7SPcf0SKpeghO7PTUxHsjY2falFsR8xHm/zi/mJNXGDMYVRz X6xL/RI0TzA3iiDaxbOI7yzZJudZqfU4droQpz1oVk0rA9rAcHNMI9rZlCHHmSJiCbjK xjxg== 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=JtLh2JsHwR8cBtlAJ8JapdKGa39G1GiW7zwJiTL+bJg=; b=ixqd4EfLlLpS7hV0+SJdC5UknGdnCSka5QIV9PUk/Z1GjI9PuUX9iRfS7gltuGiySN 5iFlkE0fjEi3Yga26zJj4AO71Kpala9i4RYcMGHShSfC0jw+pKpmXvTSGc7n/lKRDE/Y 2mVND3mZsid4tKnB7B0fmgXZTh5Rec9u5wuhSWw+RtT37slFrjItQz1uFnEm9Cy/L19V uRzcGGBkszDkoQdIGL2wNrZKrBsg138y4yTq6eRg4wAGyKeL26Y3NHttE7uMDgDslGtw lZneUQRWq4NQ4UtQnVI9Cia+fINjwnSpUuPb+0tn7GC6lzIpxJpovvTJRO1SfGJCRTdE EMhQ== 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 i22si12695297ejy.656.2021.05.10.06.48.10; Mon, 10 May 2021 06:48:34 -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 S234557AbhEJNr6 (ORCPT + 99 others); Mon, 10 May 2021 09:47:58 -0400 Received: from srv6.fidu.org ([159.69.62.71]:57880 "EHLO srv6.fidu.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241227AbhEJNfJ (ORCPT ); Mon, 10 May 2021 09:35:09 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by srv6.fidu.org (Postfix) with ESMTP id 46F13C800A7; Mon, 10 May 2021 15:33: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 CqKkkfnJub4j; Mon, 10 May 2021 15:33:56 +0200 (CEST) Received: from wsembach-tuxedo.fritz.box (p200300E37F0dA80022824231f945140A.dip0.t-ipconnect.de [IPv6:2003:e3:7f0d:a800:2282:4231:f945:140a]) (Authenticated sender: wse@tuxedocomputers.com) by srv6.fidu.org (Postfix) with ESMTPA id F168BC800A8; Mon, 10 May 2021 15:33:55 +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 v7 2/3] drm/i915/display: Restructure output format computation for better expandability Date: Mon, 10 May 2021 15:33:48 +0200 Message-Id: <20210510133349.14491-3-wse@tuxedocomputers.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210510133349.14491-1-wse@tuxedocomputers.com> References: <20210510133349.14491-1-wse@tuxedocomputers.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Couples the decission between RGB and YCbCr420 mode and the check if the port clock can archive the required frequency. Other checks and configuration steps that where previously done in between can also be done before or after. This allows for are cleaner implementation of retrying different color encodings. A slight change in behaviour occurs with this patch: If YCbCr420 is not allowed but display is YCbCr420 only it no longer fails, but just prints an error and tries to fallback on RGB. Signed-off-by: Werner Sembach --- drivers/gpu/drm/i915/display/intel_hdmi.c | 66 ++++++++++++----------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c index 2f1ca91387e4..c411f1862286 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -2000,29 +2000,6 @@ static bool hdmi_deep_color_possible(const struct intel_crtc_state *crtc_state, INTEL_OUTPUT_FORMAT_YCBCR420); } -static int -intel_hdmi_ycbcr420_config(struct intel_crtc_state *crtc_state, - const struct drm_connector_state *conn_state) -{ - struct drm_connector *connector = conn_state->connector; - struct drm_i915_private *i915 = to_i915(connector->dev); - const struct drm_display_mode *adjusted_mode = - &crtc_state->hw.adjusted_mode; - - if (!drm_mode_is_420_only(&connector->display_info, adjusted_mode)) - return 0; - - if (!connector->ycbcr_420_allowed) { - drm_err(&i915->drm, - "Platform doesn't support YCBCR420 output\n"); - return -EINVAL; - } - - crtc_state->output_format = INTEL_OUTPUT_FORMAT_YCBCR420; - - return intel_pch_panel_fitting(crtc_state, conn_state); -} - static int intel_hdmi_compute_bpc(struct intel_encoder *encoder, struct intel_crtc_state *crtc_state, int clock) @@ -2129,6 +2106,31 @@ static bool intel_hdmi_has_audio(struct intel_encoder *encoder, return intel_conn_state->force_audio == HDMI_AUDIO_ON; } +static int intel_hdmi_compute_output_format(struct intel_encoder *encoder, + struct intel_crtc_state *crtc_state, + const struct drm_connector_state *conn_state) +{ + struct drm_connector *connector = conn_state->connector; + struct drm_i915_private *i915 = to_i915(connector->dev); + const struct drm_display_mode *adjusted_mode = &crtc_state->hw.adjusted_mode; + int ret; + bool ycbcr_420_only; + + ycbcr_420_only = drm_mode_is_420_only(&connector->display_info, adjusted_mode); + if (connector->ycbcr_420_allowed && ycbcr_420_only) { + crtc_state->output_format = INTEL_OUTPUT_FORMAT_YCBCR420; + } else { + if (!connector->ycbcr_420_allowed && ycbcr_420_only) + drm_dbg_kms(&i915->drm, + "YCbCr 4:2:0 mode but YCbCr 4:2:0 output not possible. Falling back to RGB.\n"); + crtc_state->output_format = INTEL_OUTPUT_FORMAT_RGB; + } + + ret = intel_hdmi_compute_clock(encoder, crtc_state); + + return ret; +} + int intel_hdmi_compute_config(struct intel_encoder *encoder, struct intel_crtc_state *pipe_config, struct drm_connector_state *conn_state) @@ -2153,23 +2155,25 @@ int intel_hdmi_compute_config(struct intel_encoder *encoder, if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) pipe_config->pixel_multiplier = 2; - ret = intel_hdmi_ycbcr420_config(pipe_config, conn_state); - if (ret) - return ret; - - pipe_config->limited_color_range = - intel_hdmi_limited_color_range(pipe_config, conn_state); - if (HAS_PCH_SPLIT(dev_priv) && !HAS_DDI(dev_priv)) pipe_config->has_pch_encoder = true; pipe_config->has_audio = intel_hdmi_has_audio(encoder, pipe_config, conn_state); - ret = intel_hdmi_compute_clock(encoder, pipe_config); + ret = intel_hdmi_compute_output_format(encoder, pipe_config, conn_state); if (ret) return ret; + if (pipe_config->output_format == INTEL_OUTPUT_FORMAT_YCBCR420) { + ret = intel_pch_panel_fitting(pipe_config, conn_state); + if (ret) + return ret; + } + + pipe_config->limited_color_range = + intel_hdmi_limited_color_range(pipe_config, conn_state); + if (conn_state->picture_aspect_ratio) adjusted_mode->picture_aspect_ratio = conn_state->picture_aspect_ratio; -- 2.25.1