Linux上使用DDC/CI协议控制显示器

Written by: algebnaly

Date: 2025-11-27T03:08:32.000Z

DDC(Display Data Channel)是电脑和显示器通信的基础标准, CI(Command Interface)是DDC的扩展,用于向显示器发送控制指令。 Linux上提供了ddcutil来操作DDC/CI。 VCP(Virtual Control Panel)是DDC/CI定义的一系列控制代码。

为了控制显示器,我们得先看看显示器是否支持DDC/CI, 以及具体支持哪些VCP代码。

获取VCP信息

Linux上可以使用如下命令查看显示器的VCP版本信息

ddcutil detect

其输出类似如下

Display 1
   I2C bus:  /dev/i2c-5
   DRM_connector:           card1-HDMI-A-1
   EDID synopsis:
      Mfg id:               XXX
      Model:                XXX
      Product code:         XXX
      Serial number:        XXX
      Binary serial number: XXX
      Manufacture year:     2020,  Week: 10
   VCP version:         2.1

Display 2
   I2C bus:  /dev/i2c-6
   DRM_connector:           card1-DP-1
   EDID synopsis:
      Mfg id:               XXX
      Model:                XXX
      Product code:         XXX
      Serial number:        XXX
      Binary serial number: 1 (0x00000001)
      Manufacture year:     2023,  Week: 1
   VCP version:         2.2

接着,我们可以看看某个显示器的VCP的功能:

ddcutil --bus=6 capabilities
Model: XXX
MCCS version: 2.2
Commands:
   Op Code: 01 (VCP Request)
   Op Code: 02 (VCP Response)
   Op Code: 03 (VCP Set)
   Op Code: 07 (Timing Request)
   Op Code: 0C (Save Settings)
   Op Code: E3 (Capabilities Reply)
   Op Code: F3 (Capabilities Request)
VCP Features:
   Feature: 02 (New control value)
   Feature: 04 (Restore factory defaults)
   Feature: 05 (Restore factory brightness/contrast defaults)
   Feature: 06 (Restore factory geometry defaults)
   Feature: 08 (Restore color defaults)
   Feature: 0B (Color temperature increment)
   Feature: 0C (Color temperature request)
   Feature: 10 (Brightness)
   Feature: 12 (Contrast)
   Feature: 14 (Select color preset)
      Values:
         01: sRGB
         02: Display Native
         04: 5000 K
         05: 6500 K
         06: 7500 K
         08: 9300 K
         0b: User 1
   Feature: 16 (Video gain: Red)
   Feature: 18 (Video gain: Green)
   Feature: 1A (Video gain: Blue)
   Feature: 52 (Active control)
   Feature: 60 (Input Source)
      Values:
         01: VGA-1
         03: DVI-1
         0f: DisplayPort-1
         11: HDMI-1
   Feature: 87 (Sharpness)
   Feature: AC (Horizontal frequency)
   Feature: AE (Vertical frequency)
   Feature: B2 (Flat panel sub-pixel layout)
   Feature: B6 (Display technology type)
   Feature: C6 (Application enable key)
   Feature: C8 (Display controller type)
   Feature: CA (OSD/Button Control)
   Feature: CC (OSD Language)
      Values:
         01: Chinese (traditional, Hantai)
         02: English
         03: French
         04: German
         06: Japanese
         0a: Spanish
         0d: Chinese (simplified / Kantai)
   Feature: D6 (Power mode)
      Values:
         01: DPM: On,  DPMS: Off
         04: DPM: Off, DPMS: Off
         05: Write only value to turn off display
   Feature: DF (VCP Version)
   Feature: FD (Manufacturer specific feature)
   Feature: FF (Manufacturer specific feature)

我们可以看到这台显示器支持很多的VCP,以控制亮度为例,我们可以看到,VCP Feature 10是Brightness,也就是亮度,于是我们可以使用如下命令来获取亮度,

ddcutil --bus=6 getvcp 10
VCP code 0x10 (Brightness                    ): current value =    20, max value =   100

可以看到我的显示器当前的亮度为20, 最大值为100。 我们可以使用如下命令来设置亮度

ddcutil --bus=6 setvcp 10 30

其它的VCP设置也是类似的方法调整。