Skip to content

Commit d6732ef

Browse files
Devarsh Thakkarsuperna9999
authored andcommitted
drm/bridge: sii902x: Fix HDMI detection with DRM_BRIDGE_ATTACH_NO_CONNECTOR
The sii902x driver was caching HDMI detection state in a sink_is_hdmi field and checking it in mode_set() to determine whether to set HDMI or DVI output mode. This approach had two problems: 1. With DRM_BRIDGE_ATTACH_NO_CONNECTOR (used by modern display drivers like TIDSS), the bridge's get_modes() is never called. Instead, the drm_bridge_connector helper calls the bridge's edid_read() and updates the connector itself. This meant sink_is_hdmi was never populated, causing the driver to default to DVI mode and breaking HDMI audio. 2. The mode_set() callback doesn't receive atomic state or connector pointer, making it impossible to check connector->display_info.is_hdmi directly at that point. Fix this by moving the HDMI vs DVI decision from mode_set() to atomic_enable(), where we can access the connector via drm_atomic_get_new_connector_for_encoder(). This works for both connector models: - With DRM_BRIDGE_ATTACH_NO_CONNECTOR: Returns the drm_bridge_connector created by the display driver, which has already been updated by the helper's call to drm_edid_connector_update() - Without DRM_BRIDGE_ATTACH_NO_CONNECTOR (legacy): Returns the connector embedded in sii902x struct, which gets updated by the bridge's own get_modes() Fixes: 3de47e1 ("drm/bridge: sii902x: use display info is_hdmi") Signed-off-by: Devarsh Thakkar <devarsht@ti.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Link: https://patch.msgid.link/20251030151635.3019864-1-devarsht@ti.com
1 parent cead55e commit d6732ef

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

drivers/gpu/drm/bridge/sii902x.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ struct sii902x {
179179
struct drm_connector connector;
180180
struct gpio_desc *reset_gpio;
181181
struct i2c_mux_core *i2cmux;
182-
bool sink_is_hdmi;
183182
u32 bus_width;
184183

185184
/*
@@ -315,8 +314,6 @@ static int sii902x_get_modes(struct drm_connector *connector)
315314
drm_edid_free(drm_edid);
316315
}
317316

318-
sii902x->sink_is_hdmi = connector->display_info.is_hdmi;
319-
320317
return num;
321318
}
322319

@@ -342,9 +339,17 @@ static void sii902x_bridge_atomic_enable(struct drm_bridge *bridge,
342339
struct drm_atomic_state *state)
343340
{
344341
struct sii902x *sii902x = bridge_to_sii902x(bridge);
342+
struct drm_connector *connector;
343+
u8 output_mode = SII902X_SYS_CTRL_OUTPUT_DVI;
344+
345+
connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
346+
if (connector && connector->display_info.is_hdmi)
347+
output_mode = SII902X_SYS_CTRL_OUTPUT_HDMI;
345348

346349
mutex_lock(&sii902x->mutex);
347350

351+
regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA,
352+
SII902X_SYS_CTRL_OUTPUT_MODE, output_mode);
348353
regmap_update_bits(sii902x->regmap, SII902X_PWR_STATE_CTRL,
349354
SII902X_AVI_POWER_STATE_MSK,
350355
SII902X_AVI_POWER_STATE_D(0));
@@ -359,16 +364,12 @@ static void sii902x_bridge_mode_set(struct drm_bridge *bridge,
359364
const struct drm_display_mode *adj)
360365
{
361366
struct sii902x *sii902x = bridge_to_sii902x(bridge);
362-
u8 output_mode = SII902X_SYS_CTRL_OUTPUT_DVI;
363367
struct regmap *regmap = sii902x->regmap;
364368
u8 buf[HDMI_INFOFRAME_SIZE(AVI)];
365369
struct hdmi_avi_infoframe frame;
366370
u16 pixel_clock_10kHz = adj->clock / 10;
367371
int ret;
368372

369-
if (sii902x->sink_is_hdmi)
370-
output_mode = SII902X_SYS_CTRL_OUTPUT_HDMI;
371-
372373
buf[0] = pixel_clock_10kHz & 0xff;
373374
buf[1] = pixel_clock_10kHz >> 8;
374375
buf[2] = drm_mode_vrefresh(adj);
@@ -384,11 +385,6 @@ static void sii902x_bridge_mode_set(struct drm_bridge *bridge,
384385

385386
mutex_lock(&sii902x->mutex);
386387

387-
ret = regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA,
388-
SII902X_SYS_CTRL_OUTPUT_MODE, output_mode);
389-
if (ret)
390-
goto out;
391-
392388
ret = regmap_bulk_write(regmap, SII902X_TPI_VIDEO_DATA, buf, 10);
393389
if (ret)
394390
goto out;

0 commit comments

Comments
 (0)