fix(HDMI-Tool): 启动拓扑改智能判定 — 仅转接板(XLS)未激活时强制扩展, 家里仅第二屏零打扰
This commit is contained in:
@@ -342,15 +342,43 @@ def apply_mode(device, dm):
|
||||
|
||||
|
||||
def ensure_display_extend():
|
||||
"""把 Windows 显示拓扑强制为"扩展"。
|
||||
"""仅当转接板显示器"已接入但未进入桌面"时, 才强制扩展拓扑。
|
||||
|
||||
LT8619C 转接板热插拔后, 若 Windows 停留在"仅电脑屏幕"拓扑(会记住上次
|
||||
场景: 板卡热插拔后, 若 Windows 停留在"仅电脑屏幕"拓扑(会记住上次
|
||||
Win+P 的选择), 板卡的 EDID 虽已安装、GPU 也在按首选时序输出, 但桌面
|
||||
并未扩展过去, get_displays() 就枚举不到这块"显示器"。
|
||||
并未扩展过去, get_displays() 就枚举不到这块"显示器" —— 此时才需要
|
||||
强制扩展把它拉回桌面。
|
||||
|
||||
返回 SetDisplayConfig 的返回码(0=成功); 任何异常静默, 不影响工具启动。
|
||||
用户主动选择的拓扑(家里的"仅第二屏幕"、手动关闭的显示器等)一律不动:
|
||||
枚举"接入但不在桌面"的显示器, 只有其 EDID 厂商是转接板签名 "XLS"
|
||||
(字节 0x61 0x93, 上游 lt8619c_edid.c) 时才扩展; 笔记本内屏等其它
|
||||
厂商视为用户有意关闭, 不干预。
|
||||
|
||||
返回 SetDisplayConfig 的返回码(0=成功, -1=未触发, 其它=异常); 静默容错。
|
||||
"""
|
||||
try:
|
||||
board_stuck = False
|
||||
i = 0
|
||||
while True:
|
||||
dd = DISPLAY_DEVICEW()
|
||||
dd.cb = ctypes.sizeof(dd)
|
||||
if not user32.EnumDisplayDevicesW(None, i, ctypes.byref(dd), 0):
|
||||
break
|
||||
i += 1
|
||||
j = 0
|
||||
while True:
|
||||
m = DISPLAY_DEVICEW()
|
||||
m.cb = ctypes.sizeof(m)
|
||||
if not user32.EnumDisplayDevicesW(dd.DeviceName, j, ctypes.byref(m), 0):
|
||||
break
|
||||
j += 1
|
||||
if m.StateFlags & 0x1: # ATTACHED_TO_DESKTOP: 已在桌面
|
||||
continue
|
||||
raw = read_edid_from_registry(m.DeviceID)
|
||||
if len(raw or ()) >= 10 and raw[8:10] == b'\x61\x93':
|
||||
board_stuck = True # 转接板没进桌面 -> 需要拉回
|
||||
if not board_stuck:
|
||||
return -1
|
||||
SDC_TOPOLOGY_EXTEND = 0x00000004
|
||||
SDC_APPLY = 0x00000080
|
||||
return ctypes.windll.user32.SetDisplayConfig(
|
||||
@@ -1648,8 +1676,8 @@ def main():
|
||||
help='RS485 发送光机命令(可多次), 如 --dlpc-cmd M730S0 --dlpc-cmd M999')
|
||||
args = ap.parse_args()
|
||||
|
||||
# LT8619C 板卡热插拔后可能停留在"仅电脑屏幕"拓扑, 先强制扩展,
|
||||
# 否则 get_displays() 枚举不到板卡的"显示器"(失败静默)
|
||||
# LT8619C 板卡热插拔后可能停留在"仅电脑屏幕"拓扑: 仅当检测到转接板
|
||||
# (EDID 厂商 XLS)接入但未进桌面时才强制扩展, 其余拓扑不动(失败静默)
|
||||
ensure_display_extend()
|
||||
|
||||
if args.dump or args.edid_fields:
|
||||
|
||||
Reference in New Issue
Block a user