From 3f0f770ccc8d724fa3b1f5b4bde5addfc4b843b8 Mon Sep 17 00:00:00 2001 From: Nicolas Frattaroli Date: Tue, 9 Jun 2026 14:43:54 +0200 Subject: drm/atomic-helper: Add HDMI bridge output bus formats helper The drm_bridge_funcs atomic_get_output_bus_fmts operation should be the same for likely every HDMI connector bridge, unless such an HDMI connector bridge has some special hardware restrictions that I cannot envision yet. To avoid code duplication and standardize on a set of media bus formats that the HDMI output color formats translate to, add a common helper function that implements this operation to the drm bridge helpers. The function returns a list of output bus formats based on the HDMI bridge's current output bits-per-component, and its bitmask of supported color formats. To guard against future expansion of DRM_OUTPUT_COLOR_FORMAT outgrowing the hweight8 call, add a BUILD_BUG_ON statement where it's used that checks for DRM_OUTPUT_COLOR_FORMAT_COUNT. The justification for not using hweight32 in all cases is that not all ISAs have a popcount instruction, and will benefit from a smaller/faster software implementation that doesn't have to operate across all bits. The justification for not defining an hweight_color depending on the value of DRM_OUTPUT_COLOR_FORMAT_COUNT is that this count enum value is only known at compile time, not at preprocessor time. Reviewed-by: Dmitry Baryshkov Reviewed-by: Daniel Stone Signed-off-by: Nicolas Frattaroli Link: https://patch.msgid.link/20260609-color-format-v17-7-35739b5782cc@collabora.com Signed-off-by: Daniel Stone --- include/drm/drm_atomic_helper.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h index b84152810abb..4cfeec70d648 100644 --- a/include/drm/drm_atomic_helper.h +++ b/include/drm/drm_atomic_helper.h @@ -295,4 +295,11 @@ drm_atomic_helper_bridge_propagate_bus_fmt(struct drm_bridge *bridge, u32 output_fmt, unsigned int *num_input_fmts); +u32 * +drm_atomic_helper_bridge_get_hdmi_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); + #endif /* DRM_ATOMIC_HELPER_H_ */ -- cgit v1.2.3