Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

ddccontrol for monitors

The story

I use an Nvidia graphics card on my Devuan Ceres desktop. I also use two monitors, and a kvm switch for one of the monitors. On the other monitor I have a 3-input HDMI input switcher. Some article I read on the Internet suggested that one can use software to interact with the monitors, using the ddc protocol. I think DDC is how my old computers could recognize what was plugged in to my VGA port (and nowadays, VGA, displayport, and unfortunately some HDMI) by name.

On GNU/Linux, that software is ddccontrol. To enable Nvidia to pass through ddc protocol, I had to enable a module parameter. I set value in new file /etc/modprobe.d/nvidia-registry.conf which turns on the i2c capabilities of my 01:00.0 VGA compatible controller: NVIDIA Corporation GP107 [GeForce GTX 1050 Ti] (rev a1).

options nvidia NVreg_RegistryDwords="RMUseSwI2c=1"

I re-ran update-initramfs to ensure even the initram has this new setting.

sudo update-initramfs -u -k $( uname -r )

After a reboot (just to be sure), in userspace, I can now query the monitor. To learn the input field:

$ ddccontrol dev:/dev/i2c-4 -d | grep -i input
 Control 0x60: +/5/3 C [Input Source Select (Main)]

My two identical Samsung monitors ended up needing slightly different ddccontrol commands. I suspect this is due to one is connected via HDMI and one via DP.

My monitor-left-hdmi.sh command:

ddccontrol dev:/dev/i2c-4 -r 0x60 -w '5'

monitor-left-dp.sh:

ddccontrol dev:/dev/i2c-4 -r 0x60 -w '3'

monitor-right-vga.sh:

ddccontrol dev:/dev/i2c-2 -r 0x60 -w '1'
ddccontrol dev:/dev/i2c-2 -r 0xdb -w '4'
ddccontrol dev:/dev/i2c-2 -r 0xdc -w '6'
ddccontrol dev:/dev/i2c-2 -r 0xeb -w '253'

monitor-right-hdmi.sh:

ddccontrol dev:/dev/i2c-2 -r 0xdb -w '253'
ddccontrol dev:/dev/i2c-2 -r 0xdc -w '260'
ddccontrol dev:/dev/i2c-2 -r 0xeb -w '9'
ddccontrol dev:/dev/i2c-2 -r 0x60 -w '5'

I learned all those by evaluating the output of ddccontrol dev:/dev/i2c-4 -d after manually choosing the inputs I cared about.

These monitors didn't have prebuilt profiles in the ddccontrol-db.

Comments