brightness: retry initial ddc read (#3287)

port 1.6

(cherry picked from commit ec22e9e594)
This commit is contained in:
usoaraway0
2026-09-04 13:51:54 +00:00
committed by dms-ci[bot]
parent 6ed79d06df
commit f2114c1a01
+12 -7
View File
@@ -160,15 +160,20 @@ func (b *DDCBackend) getDDCName(bus int) string {
}
func (b *DDCBackend) readInitialBrightness(fd int, dev *ddcDevice) {
cap, err := b.getVCPFeature(fd, VCP_BRIGHTNESS)
if err != nil {
for attempt := 0; attempt < 3; attempt++ {
cap, err := b.getVCPFeature(fd, VCP_BRIGHTNESS)
if err == nil {
dev.max = cap.max
dev.lastBrightness = cap.current
log.Debugf("initialized %s with brightness %d/%d", dev.name, cap.current, cap.max)
return
}
if attempt < 2 {
time.Sleep(100 * time.Millisecond)
continue
}
log.Debugf("failed to read initial brightness for %s: %v", dev.name, err)
return
}
dev.max = cap.max
dev.lastBrightness = cap.current
log.Debugf("initialized %s with brightness %d/%d", dev.name, cap.current, cap.max)
}
func (b *DDCBackend) GetDevices() ([]Device, error) {