Method and device for adjusting brightness of external display in real time based on DDC protocol
By obtaining the I2C device number of the monitor and building a data packet that complies with the I2C protocol format, it directly writes it to the I2C device register of the monitor, solving the problems of complex brightness adjustment and long response time of external displays in the prior art, real-time adjustment of brightness and rapid response of brightness are achieved, and the user experience is improved.
Patent Information
- Application Number
- CN202411602777.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-02-28
AI Technical Summary
The adjustment method of external display brightness in the existing Linux environment is complex and not intuitive, and it is inconvenient to adjust brightness in multi-display environments, and the response time is long, which affects the user experience.
By acquiring and storing the I2C device number of the display, a target data structure containing brightness control information is constructed according to the data format of the DDC protocol, a complete data packet that conforms to the I2C protocol format is formed, and directly written to the I2C device register of the display to achieve brightness adjustment.
It effectively reduces the time-consuming response time for display brightness changes, and the brightness can be synchronized with user operations in a timely manner, improving the user experience.
Smart Images

Figure CN119537268A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of digital display control, and in particular to a method and device for adjusting the brightness of an external display in real time based on a DDC protocol. Background Art
[0002] In the current Linux operating system environment, there are mature solutions for adjusting the brightness of built-in laptop screens. Users can usually make intuitive and convenient adjustments through the operating system's control center graphical interface. This adjustment method utilizes the specific interface design in the laptop hardware to achieve fast response and precise control of the built-in screen brightness. However, when facing the application scenario of an external display, especially when the desktop is connected to an external display or the laptop is connected to an external second screen, the existing Linux desktop environment often fails to provide the same convenient brightness adjustment function in the control center.
[0003] DDC (Digital Display Channel) is a data transmission channel between the host and the display, mainly used to transmit EDID (Extended Display Identification Data) information, that is, the physical characteristic parameters of the display. On this basis, the DDC / CI (Display Data Channel Command Interface) protocol further allows users to directly adjust various settings (including brightness adjustment) of the external display in real time through mouse operation and a friendly software interface, without relying on the traditional OSD (On-Screen Display) menu for cumbersome physical button operations. This mechanism provides a theoretical basis for convenient control of the brightness of the external display in the Linux environment.
[0004] However, the current Linux distribution has the following limitations when implementing the external monitor brightness adjustment function:
[0005] 1. In the prior art, the brightness of the external display is mainly adjusted in the form of command lines. For ordinary users, this operation method is relatively complicated and not intuitive enough, which reduces the convenience of use and user experience.
[0006] 2. Use the physical buttons on the monitor's built-in OSD menu to make manual adjustments. Although this method is intuitive, it requires the user to leave the current work interface and interrupt the operation process. In addition, in a multi-monitor environment, it is particularly inconvenient to adjust the brightness of each monitor one by one.
[0007] 3. Challenges of integration into the control center: Although in theory command line tools such as DDCutil can be integrated into the control center graphical interface to achieve graphical adjustment of the brightness of external displays, there are significant technical difficulties in actual application. When DDCutil performs brightness adjustment tasks, each command execution needs to traverse the I2C devices in the system to determine the specific device to which the display is connected, and perform multiple communications and data exchanges during each adjustment process. This process results in a significant increase in response time, usually taking about 1 to 2 seconds. When such commands are integrated into the control center and quickly dragged and adjusted, the display brightness cannot change synchronously with the user's operation in a timely manner. It often happens that after the user stops dragging, the screen brightness is still lagging behind in adjustment, which seriously affects the real-time performance and user experience. Summary of the invention
[0008] The technical problem to be solved by the present invention is: in view of the technical problems existing in the prior art, the present invention provides a method and device for adjusting the brightness of an external display in real time based on a DDC protocol with a simple structure and a fast response speed.
[0009] In order to solve the above technical problems, the technical solution proposed by the present invention is:
[0010] A method for adjusting the brightness of an external display in real time based on a DDC protocol, comprising:
[0011] Step S1: Obtain and store the I2C device number of the display;
[0012] Step S2: According to the data format of the DDC protocol, a target data structure containing brightness control information is constructed. When the display brightness needs to be adjusted, the target brightness value is embedded in the target data structure to obtain a complete data packet that conforms to the I2C protocol format, and the complete data packet is input into the device corresponding to the I2C device number, thereby achieving brightness adjustment.
[0013] As a further improvement of the method of the present invention: the step S1 is to pre-acquire the I2C device number of the display during the system startup phase, and save the I2C device number into the system configuration.
[0014] As a further improvement of the method of the present invention: in the step S2, the complete data packet is input into the register corresponding to the I2C device number using an I2C communication tool, thereby adjusting the brightness of the display.
[0015] A device for adjusting the brightness of an external display in real time based on a DDC protocol, comprising:
[0016] A data storage module, used to obtain and store the I2C device number of the display;
[0017] A data construction module, used for constructing a target data structure containing brightness control information according to a data format of a DDC protocol;
[0018] The brightness adjustment module embeds the target brightness value into the target data structure to obtain a complete data packet conforming to the I2C protocol format when the display brightness needs to be adjusted, and inputs the complete data packet into the device corresponding to the I2C device number, thereby realizing brightness adjustment.
[0019] A computer device comprises a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to perform the above method.
[0020] A computer-readable storage medium storing a computer program, wherein the computer program executes the above method.
[0021] Compared with the prior art, the advantages of the present invention are:
[0022] The present invention analyzes and optimizes the communication process of DDC brightness adjustment, recombines DDC protocol data and brightness value into I2C protocol data, and uses an I2C communication tool to send a complete data packet that complies with the I2C protocol format to the I2C device register connected to the display to adjust the brightness. The present invention can effectively reduce the time-consuming response time of the display brightness change, and the display brightness can change synchronously with the user's operation in a timely manner, effectively improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 The present invention is a flowchart of a method for adjusting the brightness of an external display in real time based on the DDC protocol according to an embodiment of the present invention.
[0024] Figure 2 This is a flow chart of a method for adjusting the brightness of an external display in real time according to a specific application embodiment of the present invention. DETAILED DESCRIPTION
[0025] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0026] like Figure 1 As shown, this embodiment provides a method for adjusting the brightness of an external display in real time based on the DDC protocol, comprising the following steps:
[0027] Step S1: Obtain and store the I2C device number of the display.
[0028] In this embodiment, the I2C device number of the display is pre-acquired during the system startup phase, and the I2C device number is saved in the system configuration.
[0029] When the monitor is connected to the Linux system, the i2c device number mapped to the system remains unchanged. Before the system boots up and enters the desktop, the obtained I2C device number of the monitor connection is saved to a specified location, such as in the gsettings setting tool.
[0030] Step S2: According to the data format of the DDC protocol, a target data structure containing brightness control information is constructed. When the display brightness needs to be adjusted, the target brightness value is embedded in the target data structure to obtain a complete data packet that conforms to the I2C protocol format, and the complete data packet is input into the device corresponding to the I2C device number, thereby achieving brightness adjustment.
[0031] In a specific embodiment, the key DDC protocol data for brightness adjustment is obtained by analyzing the DDC protocol. Based on the obtained information, a template for the DDC protocol data packet is created, which should contain fixed parts such as the correct start byte, command identifier, register address, and possible control flags. When the user drags the brightness bar in the graphical interface control center to adjust the brightness, the brightness value generated by the drag is obtained in real time, the brightness value that the user wants to adjust is converted into the format specified by the DDC protocol, and the integrated brightness value is embedded in the target data structure to ensure that the data packet structure is complete and complies with the protocol regulations.
[0032] In this embodiment, an I2C communication tool is used to input a complete data packet into a register corresponding to the I2C device number, thereby adjusting the brightness of the display.
[0033] Specifically, the i2ctransfer command is used to directly write the I2C data packet containing the adjusted brightness value into the register corresponding to the display according to the obtained display I2C device number.
[0034] The present invention is further described below by taking the above method for real-time adjustment of an external display in a specific application embodiment as an example. Figure 2 As shown, the detailed steps are:
[0035] Step 1: Analyze the DDC protocol and obtain the communication protocol data (hexadecimal). Through in-depth research on the Display Data Channel (DDC) protocol, especially the part related to brightness control, understand the data format and communication mechanism in the DDC protocol, and analyze the ddcutil tool source code or runtime behavior to extract the hexadecimal protocol data related to brightness control and clarify how to encode and decode brightness values.
[0036] Step 2: Install the i2c-tools package.
[0037] Step 3: After the system starts, obtain the I2C device number to which the monitor is connected. During the system startup phase or when the monitor is connected for the first time, detect and record the device address on the I2C bus to which the monitor is connected through the API or tools provided by the system (such as udev rules, kernel logs, etc.).
[0038] Step 4: Open the brightness adjustment module in the control center and drag the brightness bar.
[0039] Step 5: Get the current value of the brightness bar (0-100).
[0040] Step 6: Reassemble the data according to the data format of the i2c protocol (ddc protocol data + brightness value)
[0041] Step 7: The control center executes the i2ctransfer command to write the I2C data into the register of the display. Specifically, the i2ctransfer command is used to directly write the I2C data packet containing the adjusted brightness value into the register corresponding to the display according to the display I2C device number obtained in step 3.
[0042] This embodiment optimizes the communication process of ddcutil to adjust the brightness, re-sorts the DDC protocol format data, and recombines the DDC protocol data and the brightness value into the communication data in the I2C protocol format that the display can recognize, and directly writes the new data into the register of the display device (I2C) through i2ctransfer to adjust the brightness. When the brightness needs to be adjusted, the I2C communication tool i2ctransfer is used to send the new data to the I2C device connected to the display. This process can reduce the time-consuming process of ddcutil traversing the I2C device and unnecessary protocol data transmission, and reduces the time delay of the prior art 1s-2s to a time delay of less than 40ms, greatly shortening the response time of brightness adjustment, and realizing the speed of real-time response of the display brightness to dragging.
[0043] This embodiment also provides a device for adjusting the brightness of an external display in real time based on a DDC protocol, including:
[0044] A data storage module, used to obtain and store the I2C device number of the display;
[0045] A data construction module, used for constructing a target data structure containing brightness control information according to a data format of a DDC protocol;
[0046] The brightness adjustment module, when the display brightness needs to be adjusted, embeds the target brightness value into the target data structure to obtain a complete data packet that conforms to the I2C protocol format, and inputs the complete data packet into the device corresponding to the I2C device number, thereby achieving brightness adjustment.
[0047] In this embodiment, the device for adjusting the brightness of an external display in real time based on the DDC protocol and the method for adjusting the brightness of an external display in real time based on the DDC protocol correspond one to one, and are not described one by one here.
[0048] This embodiment further provides a computer device, including a processor and a memory, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to perform the above method.
[0049] It is understandable that the above method of this embodiment can be executed by a single device, such as a computer or server, etc., and can also be applied to a distributed scenario and completed by multiple devices in cooperation with each other. In the case of a distributed scenario, one of the multiple devices can only execute one or more steps in the above method of this embodiment, and multiple devices interact to complete the above method. The processor can be implemented in the form of a general-purpose CPU, a microprocessor, an application-specific integrated circuit, or one or more integrated circuits, etc., for executing related programs to implement the above method of this embodiment. The memory can be implemented in the form of a read-only memory ROM, a random access memory RAM, a static storage device, and a dynamic storage device. The memory can store an operating system and other applications. When the above method of this embodiment is implemented by software or firmware, the relevant program code is stored in the memory and called and executed by the processor.
[0050] This embodiment further provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the above method is implemented.
[0051] Those skilled in the art will appreciate that the above-mentioned embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, may be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the functions in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The above are only preferred embodiments of the present invention and are not intended to limit the present invention in any form. Although the present invention has been disclosed as above with preferred embodiments, it is not intended to limit the present invention. Therefore, any simple modification, equivalent change and modification made to the above embodiments according to the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the scope of protection of the technical solution of the present invention.
[0052] The above is only a preferred embodiment of the present invention, and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment, it is not intended to limit the present invention. Therefore, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the content of the technical solution of the present invention shall fall within the scope of protection of the technical solution of the present invention.
Claims
1. A method for adjusting the brightness of an external display in real time based on a DDC protocol, characterized in that: include: Step S1: Obtain and store the I2C device number of the display; Step S2: According to the data format of the DDC protocol, a target data structure containing brightness control information is constructed. When the display brightness needs to be adjusted, the target brightness value is embedded in the target data structure to obtain a complete data packet that conforms to the I2C protocol format, and the complete data packet is input into the device corresponding to the I2C device number, thereby achieving brightness adjustment.
2. The method for adjusting the brightness of an external display in real time based on the DDC protocol according to claim 1, characterized in that: In the step S1, the I2C device number of the display is pre-acquired during the system startup phase, and the I2C device number is saved in the system configuration.
3. The method for adjusting the brightness of an external display in real time based on the DDC protocol according to claim 1, characterized in that: In the step S2, the complete data packet is input into the register corresponding to the I2C device number using an I2C communication tool, thereby adjusting the brightness of the display.
4. A device for adjusting the brightness of an external display in real time based on a DDC protocol, characterized in that: include: A data storage module, used to obtain and store the I2C device number of the display; A data construction module, used for constructing a target data structure containing brightness control information according to a data format of a DDC protocol; The brightness adjustment module embeds the target brightness value into the target data structure to obtain a complete data packet conforming to the I2C protocol format when the display brightness needs to be adjusted, and inputs the complete data packet into the device corresponding to the I2C device number, thereby realizing brightness adjustment.
5. A computer device comprising a processor and a memory, wherein the memory is used to store a computer program, wherein: The processor is configured to execute the computer program to perform the method according to any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed, the method according to any one of claims 1 to 3 is implemented.