Use the negociated bus formats from the atomic check function if
the input and output formats are non NULL, otherwise fallback to
the plat_data->input_bus_format or the default MEDIA_BUS_FMT_RGB888_1X24
bus format.

Signed-off-by: Neil Armstrong <narmstr...@baylibre.com>
---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c 
b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index 121c2167ee20..316823abdd00 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -1968,11 +1968,10 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct 
drm_display_mode *mode)
        hdmi->hdmi_data.video_mode.mpixelrepetitionoutput = 0;
        hdmi->hdmi_data.video_mode.mpixelrepetitioninput = 0;
 
-       /* TOFIX: Get input format from plat data or fallback to RGB888 */
        if (hdmi->plat_data->input_bus_format)
                hdmi->hdmi_data.enc_in_bus_format =
                        hdmi->plat_data->input_bus_format;
-       else
+       else if (!hdmi->hdmi_data.enc_in_bus_format)
                hdmi->hdmi_data.enc_in_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
 
        /* TOFIX: Get input encoding from plat data or fallback to none */
@@ -1982,8 +1981,8 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct 
drm_display_mode *mode)
        else
                hdmi->hdmi_data.enc_in_encoding = V4L2_YCBCR_ENC_DEFAULT;
 
-       /* TOFIX: Default to RGB888 output format */
-       hdmi->hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
+       if (!hdmi->hdmi_data.enc_out_bus_format)
+               hdmi->hdmi_data.enc_out_bus_format = MEDIA_BUS_FMT_RGB888_1X24;
 
        hdmi->hdmi_data.pix_repet_factor = 0;
        hdmi->hdmi_data.hdcp_enable = 0;
@@ -2224,6 +2223,8 @@ static int dw_hdmi_bridge_atomic_check(struct drm_bridge 
*bridge,
        dev_dbg(hdmi->dev, "selected output format %x\n",
                        bridge_state->output_bus_cfg.fmt);
 
+       hdmi->hdmi_data.enc_out_bus_format = bridge_state->output_bus_cfg.fmt;
+
        ret = drm_atomic_bridge_choose_input_bus_cfg(bridge_state, crtc_state,
                                                      conn_state);
        if (ret)
@@ -2232,6 +2233,8 @@ static int dw_hdmi_bridge_atomic_check(struct drm_bridge 
*bridge,
        dev_dbg(hdmi->dev, "selected input format %x\n",
                        bridge_state->input_bus_cfg.fmt);
 
+       hdmi->hdmi_data.enc_in_bus_format = bridge_state->input_bus_cfg.fmt;
+
        return 0;
 }
 
-- 
2.22.0

Reply via email to