From patchwork Sat Jun 1 13:12:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 13682379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CFE9AC25B76 for ; Sat, 1 Jun 2024 13:13:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IwfDk9UJ9pkVWCRYIu93z4yMixQTtSAkO8nTVnMnORA=; b=tWCyeHokQVSbU4 7WOh8N5fVkWzWV9zPmGhxVYFN/Z2Citeayx1PEznPAtJrryxK68O7c5sm0ZHwtW0cbA7gK4nLK/EC 0rs7BiFdR0y6uGMnsvtAUy1ZDnVw48+He3OJXqDxC1ANC9Uft2gGgKKhFjDCaFh4q3mLb5VGF4nFH tanRrqfK5k2/XCtTFcqknPzJpw0gNaYG6ioEO/38q3/+Xw/5BIjG+az8gDDnEKVN0RS70nY5l243+ IZVAjE+rvjqXWG5m1L+8xhJlSu7ITjBuXqk3OMDOKrxdj7pZW1dPhL00KNEmQ3LWTaQgQ9JpAzNpC tNFFAS/alcH4yNg+b8Ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDOXn-0000000CeCv-3Md8; Sat, 01 Jun 2024 13:13:11 +0000 Received: from madrid.collaboradmins.com ([46.235.227.194]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDOXg-0000000Ce7m-2TLI; Sat, 01 Jun 2024 13:13:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1717247583; bh=8uRhqLiAdkGIlh3VTlM1cQofy1gF9s+TKt0ENoIYejs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=vxS8ToKOD9x3MfJOagpxmnjgKb8QkJVEMjq8Yp1mb9bT9G4vI3KqyMYSI+RgexhR0 8hcEbfOui1Vw7mVe2TyqPTmaNYv/IIqpz2xojZi43z0JFPqDps+UkVzI1mXyXSSiJH mL02UnET/FOs/KM4964Go8HIaFMApo6OHaleu3WZUDS0JGYHdmUwxs91i3rLmmXg7p RGyy9gCMJ3n8CeQaaeyiqi1sbSa8DSl4RFcNgb9xxzNx9XxHNuydG4zIFyCwSDcSRY Acu1l0Pn839x+gELe/eqLGbnmKRVyxw92PlnfJpT7PluyB+nRO/hGsCjrrhRwOX0DM uj2zZB4GVzJIw== Received: from localhost (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 3039437821EB; Sat, 1 Jun 2024 13:13:03 +0000 (UTC) From: Cristian Ciocaltea Date: Sat, 01 Jun 2024 16:12:26 +0300 Subject: [PATCH 04/14] drm/bridge: dw-hdmi: Factor out AVI infoframe setup MIME-Version: 1.0 Message-Id: <20240601-b4-rk3588-bridge-upstream-v1-4-f6203753232b@collabora.com> References: <20240601-b4-rk3588-bridge-upstream-v1-0-f6203753232b@collabora.com> In-Reply-To: <20240601-b4-rk3588-bridge-upstream-v1-0-f6203753232b@collabora.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Andy Yan , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Mark Yao Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, kernel@collabora.com, Alexandre ARNOUD , Luis de Arquer X-Mailer: b4 0.14-dev-f7c49 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240601_061304_862973_73419E5B X-CRM114-Status: GOOD ( 13.02 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org In preparation to add support for the HDMI 2.1 Quad-Pixel TX Controller and minimize code duplication, factor out the AVI infoframe setup from hdmi_config_AVI() into a common dw_hdmi_prep_avi_infoframe() helper. Signed-off-by: Cristian Ciocaltea --- drivers/gpu/drm/bridge/synopsys/dw-hdmi-common.h | 4 ++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 57 ++++++++++++++---------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-common.h b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-common.h index ffd2ee16466c..0569196bbe3b 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-common.h +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-common.h @@ -150,6 +150,10 @@ struct i2c_adapter *dw_hdmi_i2c_adapter(struct dw_hdmi *hdmi, const struct i2c_algorithm *algo); bool dw_hdmi_support_scdc(struct dw_hdmi *hdmi, const struct drm_display_info *display); +void dw_hdmi_prep_avi_infoframe(struct hdmi_avi_infoframe *frame, + struct dw_hdmi *hdmi, + const struct drm_connector *connector, + const struct drm_display_mode *mode); enum drm_connector_status dw_hdmi_connector_detect(struct drm_connector *connector, bool force); diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 5dd0e2bc080d..81d73fbcb2e6 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -1638,66 +1638,75 @@ static void hdmi_tx_hdcp_config(struct dw_hdmi *hdmi) HDMI_A_HDCPCFG1_ENCRYPTIONDISABLE_MASK, HDMI_A_HDCPCFG1); } -static void hdmi_config_AVI(struct dw_hdmi *hdmi, - const struct drm_connector *connector, - const struct drm_display_mode *mode) +void dw_hdmi_prep_avi_infoframe(struct hdmi_avi_infoframe *frame, + struct dw_hdmi *hdmi, + const struct drm_connector *connector, + const struct drm_display_mode *mode) { - struct hdmi_avi_infoframe frame; - u8 val; - /* Initialise info frame from DRM mode */ - drm_hdmi_avi_infoframe_from_display_mode(&frame, connector, mode); + drm_hdmi_avi_infoframe_from_display_mode(frame, connector, mode); if (hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format)) { - drm_hdmi_avi_infoframe_quant_range(&frame, connector, mode, + drm_hdmi_avi_infoframe_quant_range(frame, connector, mode, hdmi->hdmi_data.rgb_limited_range ? HDMI_QUANTIZATION_RANGE_LIMITED : HDMI_QUANTIZATION_RANGE_FULL); } else { - frame.quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; - frame.ycc_quantization_range = + frame->quantization_range = HDMI_QUANTIZATION_RANGE_DEFAULT; + frame->ycc_quantization_range = HDMI_YCC_QUANTIZATION_RANGE_LIMITED; } if (hdmi_bus_fmt_is_yuv444(hdmi->hdmi_data.enc_out_bus_format)) - frame.colorspace = HDMI_COLORSPACE_YUV444; + frame->colorspace = HDMI_COLORSPACE_YUV444; else if (hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) - frame.colorspace = HDMI_COLORSPACE_YUV422; + frame->colorspace = HDMI_COLORSPACE_YUV422; else if (hdmi_bus_fmt_is_yuv420(hdmi->hdmi_data.enc_out_bus_format)) - frame.colorspace = HDMI_COLORSPACE_YUV420; + frame->colorspace = HDMI_COLORSPACE_YUV420; else - frame.colorspace = HDMI_COLORSPACE_RGB; + frame->colorspace = HDMI_COLORSPACE_RGB; /* Set up colorimetry */ if (!hdmi_bus_fmt_is_rgb(hdmi->hdmi_data.enc_out_bus_format)) { switch (hdmi->hdmi_data.enc_out_encoding) { case V4L2_YCBCR_ENC_601: if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV601) - frame.colorimetry = HDMI_COLORIMETRY_EXTENDED; + frame->colorimetry = HDMI_COLORIMETRY_EXTENDED; else - frame.colorimetry = HDMI_COLORIMETRY_ITU_601; - frame.extended_colorimetry = + frame->colorimetry = HDMI_COLORIMETRY_ITU_601; + frame->extended_colorimetry = HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; break; case V4L2_YCBCR_ENC_709: if (hdmi->hdmi_data.enc_in_encoding == V4L2_YCBCR_ENC_XV709) - frame.colorimetry = HDMI_COLORIMETRY_EXTENDED; + frame->colorimetry = HDMI_COLORIMETRY_EXTENDED; else - frame.colorimetry = HDMI_COLORIMETRY_ITU_709; - frame.extended_colorimetry = + frame->colorimetry = HDMI_COLORIMETRY_ITU_709; + frame->extended_colorimetry = HDMI_EXTENDED_COLORIMETRY_XV_YCC_709; break; default: /* Carries no data */ - frame.colorimetry = HDMI_COLORIMETRY_ITU_601; - frame.extended_colorimetry = + frame->colorimetry = HDMI_COLORIMETRY_ITU_601; + frame->extended_colorimetry = HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; break; } } else { - frame.colorimetry = HDMI_COLORIMETRY_NONE; - frame.extended_colorimetry = + frame->colorimetry = HDMI_COLORIMETRY_NONE; + frame->extended_colorimetry = HDMI_EXTENDED_COLORIMETRY_XV_YCC_601; } +} +EXPORT_SYMBOL_GPL(dw_hdmi_prep_avi_infoframe); + +static void hdmi_config_AVI(struct dw_hdmi *hdmi, + const struct drm_connector *connector, + const struct drm_display_mode *mode) +{ + struct hdmi_avi_infoframe frame; + u8 val; + + dw_hdmi_prep_avi_infoframe(&frame, hdmi, connector, mode); /* * The Designware IP uses a different byte format from standard