mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-07 14:08:29 -04:00
brightness/ddc: avoid re-probing already identified devices
related #2049
This commit is contained in:
@@ -68,6 +68,12 @@ func (b *DDCBackend) scanI2CDevicesInternal(force bool) error {
|
|||||||
activeBuses[i] = true
|
activeBuses[i] = true
|
||||||
id := fmt.Sprintf("ddc:i2c-%d", i)
|
id := fmt.Sprintf("ddc:i2c-%d", i)
|
||||||
|
|
||||||
|
// Don't re-probe identified monitors: DDC traffic during a wake
|
||||||
|
// sequence can disturb some monitors' own brightness handling.
|
||||||
|
if _, ok := b.devices.Load(id); ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
dev, err := b.probeDDCDevice(i)
|
dev, err := b.probeDDCDevice(i)
|
||||||
if err != nil || dev == nil {
|
if err != nil || dev == nil {
|
||||||
continue
|
continue
|
||||||
@@ -107,7 +113,8 @@ func (b *DDCBackend) probeDDCDevice(bus int) (*ddcDevice, error) {
|
|||||||
dummy := make([]byte, 32)
|
dummy := make([]byte, 32)
|
||||||
syscall.Read(fd, dummy) //nolint:errcheck
|
syscall.Read(fd, dummy) //nolint:errcheck
|
||||||
|
|
||||||
writebuf := []byte{0x00}
|
writebuf := []byte{DDC_SOURCE_ADDR, 0x80}
|
||||||
|
writebuf = append(writebuf, ddcciChecksum(writebuf))
|
||||||
n, err := syscall.Write(fd, writebuf)
|
n, err := syscall.Write(fd, writebuf)
|
||||||
if err == nil && n == len(writebuf) {
|
if err == nil && n == len(writebuf) {
|
||||||
name := b.getDDCName(bus)
|
name := b.getDDCName(bus)
|
||||||
|
|||||||
Reference in New Issue
Block a user