Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 3de47e1309c2 ("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

authored by

Devarsh Thakkar and committed by
Neil Armstrong
d6732ef4 cead55e2

+8 -12
+8 -12
drivers/gpu/drm/bridge/sii902x.c
··· 179 179 struct drm_connector connector; 180 180 struct gpio_desc *reset_gpio; 181 181 struct i2c_mux_core *i2cmux; 182 - bool sink_is_hdmi; 183 182 u32 bus_width; 184 183 185 184 /* ··· 314 315 drm_edid_free(drm_edid); 315 316 } 316 317 317 - sii902x->sink_is_hdmi = connector->display_info.is_hdmi; 318 - 319 318 return num; 320 319 } 321 320 ··· 339 342 struct drm_atomic_state *state) 340 343 { 341 344 struct sii902x *sii902x = bridge_to_sii902x(bridge); 345 + struct drm_connector *connector; 346 + u8 output_mode = SII902X_SYS_CTRL_OUTPUT_DVI; 347 + 348 + connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder); 349 + if (connector && connector->display_info.is_hdmi) 350 + output_mode = SII902X_SYS_CTRL_OUTPUT_HDMI; 342 351 343 352 mutex_lock(&sii902x->mutex); 344 353 354 + regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA, 355 + SII902X_SYS_CTRL_OUTPUT_MODE, output_mode); 345 356 regmap_update_bits(sii902x->regmap, SII902X_PWR_STATE_CTRL, 346 357 SII902X_AVI_POWER_STATE_MSK, 347 358 SII902X_AVI_POWER_STATE_D(0)); ··· 364 359 const struct drm_display_mode *adj) 365 360 { 366 361 struct sii902x *sii902x = bridge_to_sii902x(bridge); 367 - u8 output_mode = SII902X_SYS_CTRL_OUTPUT_DVI; 368 362 struct regmap *regmap = sii902x->regmap; 369 363 u8 buf[HDMI_INFOFRAME_SIZE(AVI)]; 370 364 struct hdmi_avi_infoframe frame; 371 365 u16 pixel_clock_10kHz = adj->clock / 10; 372 366 int ret; 373 - 374 - if (sii902x->sink_is_hdmi) 375 - output_mode = SII902X_SYS_CTRL_OUTPUT_HDMI; 376 367 377 368 buf[0] = pixel_clock_10kHz & 0xff; 378 369 buf[1] = pixel_clock_10kHz >> 8; ··· 384 383 SII902X_TPI_AVI_INPUT_COLORSPACE_RGB; 385 384 386 385 mutex_lock(&sii902x->mutex); 387 - 388 - ret = regmap_update_bits(sii902x->regmap, SII902X_SYS_CTRL_DATA, 389 - SII902X_SYS_CTRL_OUTPUT_MODE, output_mode); 390 - if (ret) 391 - goto out; 392 386 393 387 ret = regmap_bulk_write(regmap, SII902X_TPI_VIDEO_DATA, buf, 10); 394 388 if (ret)