From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3555C41B379; Fri, 27 Feb 2026 19:22:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772220179; cv=pass; b=QBaP0sWjc+HogLef9s4xRUj3867fkT/8FSfJwVelQ/dnr3e25YeV4gQ96cMuP6l+RtJLZls1ZmuNdTDsMC1PjnOO4mjDZuMXWtUpj1sYMHx1lBNxEsXMOZlnVj/fPmxnewc0uWQFwkDG5bKa+8RfZqDT3YM/ADOo2W5aYn6i/WI= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772220179; c=relaxed/simple; bh=97pAhfLduGmajlq5XCjV1KSFkPcZORlIqmavVJvYZVE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qOu+Ulk4z7obrRt2kz6lY16LUlT9xlQUNci4xBhrcdl8NNg35amuyOV2Ba+4s+dWLgpVi1n9Z/cQcKd+mH+CtQui22niE2qS+BOSecwqbVq/iloTqOorATmlL5SgGbxomZhYuDA4qTGCCIsl7cL4FRI+zH+5h50X8Tu9HDRZTxI= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b=WOS2jtS9; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b="WOS2jtS9" ARC-Seal: i=1; a=rsa-sha256; t=1772220127; cv=none; d=zohomail.com; s=zohoarc; b=gmELs3Nl/vS1UrpyYAF2cyf1WSvQbOzQBUye0NbDy5BsujxiWibWCTm3V7ilHip8F30hCudB6DhAm1vLwsf/T8a6ExpV7+mC4ybOUuZ6a8wrNm0zD4cISwDtqoIV17/kMM4MXYsudveWZ3hRcqfATS1PMViC+LHGK3JMkCxysOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772220127; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=/k5/BqEah/aoOJSil87LueDqk+SxhPr5/f7eVZQF6Ak=; b=dZvQnJDQeuvipgnF2pQJ+a5/1DxsOQ4ONtUws0ECjw1mmMgrqHOFxbfABhYYDe2YNwAbt92NIm3TrUtsCUYbyjqBcEdv+Ll/v0BjMRjNngiWocjdqaaiL2dPQ5jjj2FJBJZZHDnb9BqiZe7CWUND6OqF8yl6S6Vk2fuQRFg76Jk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1772220127; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=/k5/BqEah/aoOJSil87LueDqk+SxhPr5/f7eVZQF6Ak=; b=WOS2jtS92hr5dcpbdmXKLe2XTEk4g7filaYDOnN7N+dK5HK/pfrNmdLQFZlFv1DB h2lchROahOTivvDujSgHkJzL6ejcUUnuH1s2sZmZ1/iEyK06km6cHDBR+1rLbwo7nYt hzrIIsQFoXe3RNNJ/DQ8WBghMInBqXZNCCIjeLUE= Received: by mx.zohomail.com with SMTPS id 1772220125698172.56653551643058; Fri, 27 Feb 2026 11:22:05 -0800 (PST) From: Nicolas Frattaroli Date: Fri, 27 Feb 2026 20:20:17 +0100 Subject: [PATCH v9 12/19] drm/bridge: dw-hdmi-qp: Implement atomic_get_output_bus_fmts Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260227-color-format-v9-12-658c3b9db7ef@collabora.com> References: <20260227-color-format-v9-0-658c3b9db7ef@collabora.com> In-Reply-To: <20260227-color-format-v9-0-658c3b9db7ef@collabora.com> To: Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Andy Yan , Jani Nikula , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , Dmitry Baryshkov , Sascha Hauer , Rob Herring , Jonathan Corbet , Shuah Khan Cc: kernel@collabora.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, linux-doc@vger.kernel.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 The atomic_get_output_bus_fmts callback is used by the DRM bridge layer to recursively select a suitable output format in a bridge chain. As a bridge that outputs to HDMI, dw-hdmi-qp will have its output formats determined by which formats the platform-specific integration of the hardware supports, and the chosen HDMI output bit depth. Implement this callback. The returned u32* buffer is supposed to be freed by the caller of this callback, as specified by the callback's documentation. Signed-off-by: Nicolas Frattaroli --- drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c | 64 ++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c index d649a1cf07f5..4556494f9bb1 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -749,6 +750,68 @@ static struct i2c_adapter *dw_hdmi_qp_i2c_adapter(struct dw_hdmi_qp *hdmi) return adap; } +static u32* +dw_hdmi_qp_bridge_get_output_bus_fmts(struct drm_bridge *bridge, + struct drm_bridge_state *bridge_state, + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state, + unsigned int *num_output_fmts) +{ + unsigned int num_fmts = 0; + u32 *out_fmts; + + /* + * bridge->supported_formats is a bit field of the HDMI_COLORSPACE_* enums. + * These enums are defined by the HDMI standard, and currently top out at + * 7. Consequently, BIT(7) is the highest bit that will be set here, unless + * the standard runs out of reserved pixel formats. Therefore, hweight8() + * will give an accurate count of how many bus formats we'll output. + */ + out_fmts = kmalloc_array(hweight8(bridge->supported_formats), sizeof(u32), + GFP_KERNEL); + if (!out_fmts) { + *num_output_fmts = 0; + return NULL; + } + + switch (conn_state->hdmi.output_bpc) { + case 12: + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_RGB121212_1X36; + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR444)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_YUV12_1X36; + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR422)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_UYVY12_1X24; + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR420)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_UYYVYY12_0_5X36; + break; + case 10: + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_RGB101010_1X30; + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR444)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_YUV10_1X30; + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR422)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_UYVY10_1X20; + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR420)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_UYYVYY10_0_5X30; + break; + default: + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_RGB888_1X24; + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR444)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_YUV8_1X24; + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR422)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_UYVY8_1X16; + if (bridge->supported_formats & BIT(DRM_OUTPUT_COLOR_FORMAT_YCBCR420)) + out_fmts[num_fmts++] = MEDIA_BUS_FMT_UYYVYY8_0_5X24; + break; + } + + *num_output_fmts = num_fmts; + + return out_fmts; +} + static void dw_hdmi_qp_bridge_atomic_enable(struct drm_bridge *bridge, struct drm_atomic_state *state) { @@ -1192,6 +1255,7 @@ static int dw_hdmi_qp_cec_transmit(struct drm_bridge *bridge, u8 attempts, #endif /* CONFIG_DRM_DW_HDMI_QP_CEC */ static const struct drm_bridge_funcs dw_hdmi_qp_bridge_funcs = { + .atomic_get_output_bus_fmts = dw_hdmi_qp_bridge_get_output_bus_fmts, .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, .atomic_reset = drm_atomic_helper_bridge_reset, -- 2.53.0