haimgel / display-switch

Turn a $30 USB switch into a full-featured multi-monitor KVM switch
https://haim.dev/posts/2020-07-28-dual-monitor-kvm/
MIT License
2.85k stars 112 forks source link

Not switching to different input (same works) due to I2C bus error when using an active DisplayPort-to-HDMI adapter #19

Closed Krischan closed 3 years ago

Krischan commented 3 years ago

Reporting to document and for completeness sake as this appears to be an issue with the DP-HDMI adapter.

The programmatic display input switch works when the input is still the same. However, after a manual switch to another input switching back no longer works. The I2C signal no longer gets through causing an I2C error which gets logged.

Case 1 - toggling the USB switch while input is already set to HDMI (0x11) (PC), i.e. setting to active input.

16:44:55 [DEBUG] (1) display_switch::app: Detected device change. Added device: "05e3:0612"
16:44:55 [INFO] Detected device we're looking for "05e3:0612"
16:44:55 [DEBUG] (1) display_switch::platform::display_control_ddc_hi: Setting display ''Generic PnP Monitor' #0' to 0x11
16:44:55 [INFO] Display 'Generic PnP Monitor' #0 set to 0x11
16:44:55 [DEBUG] (1) display_switch::platform::display_control_ddc_hi: Setting display ''GM107GL-A/2147881095:Lvds' #1' to 0x11
16:44:55 [INFO] Display 'GM107GL-A/2147881095:Lvds' #1 set to 0x11
16:44:56 [DEBUG] (1) display_switch::app: Detected device change. Added device: "05e3:0610"
16:46:11 [DEBUG] (1) display_switch::app: Detected device change. Added device: "0000:0000"

Case 2 - toggling USB switch when input is set to DisplayPort (Mac)

16:51:08 [DEBUG] (1) display_switch::app: Detected device change. Added device: "05e3:0612"
16:51:08 [INFO] Detected device we're looking for "05e3:0612"
16:51:08 [DEBUG] (1) display_switch::platform::display_control_ddc_hi: Setting display ''Generic PnP Monitor' #0' to 0x11
16:51:08 [ERROR] Failed to set display 'Generic PnP Monitor' #0 to 0x11 (Os { code: -1071241854, kind: Other, message: "An error occurred while transmitting data to the device on the I2C bus." })
16:51:08 [DEBUG] (1) display_switch::platform::display_control_ddc_hi: Setting display ''GM107GL-A/2147881095:Lvds' #1' to 0x11
16:51:08 [ERROR] Failed to set display 'GM107GL-A/2147881095:Lvds' #1 to 0x11 (I2c(Error))
16:51:08 [DEBUG] (1) display_switch::app: Detected device change. Added device: "05e3:0610"
Krischan commented 3 years ago

This issue seems to be specific to this LG monitor (or LG in general). It may have to do with aggressive energy saving mode switching.

mariusmarais commented 3 years ago

Seems like LG is particularly problematic with switching: https://github.com/rockowitz/ddcutil/issues/100