Method and device for automatically generating LCD drive program and device tree configuration file and storage medium
By automating the generation of LCD drivers and device tree configuration files using Python scripts, the problems of large development workload and error susceptibility in existing technologies are solved, enabling efficient and flexible code generation and maintenance, and shortening the development cycle.
Patent Information
- Application Number
- CN202511079410.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-03
- Publication Date
- 2025-11-21
AI Technical Summary
In the existing technology, the development of LCD panel drivers and device tree configuration files is labor-intensive, cumbersome, and error-prone, lacking automation and flexibility, resulting in long development cycles and difficult code maintenance.
The system uses Python scripts to automatically generate LCD drivers and device tree configuration files. By preparing a CSV file, it reads and parses the LCD configuration information to automatically generate the corresponding driver code and device tree configuration, including parameters such as LCD model, resolution, interface type, and GPIO configuration, ensuring correctness and consistency.
It achieves automated generation of LCD driver and device tree configuration files, reducing human error, improving work efficiency, shortening development cycle, and enhancing code reusability and maintainability.
Smart Images

Figure CN120994258A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to a method for setting an LCD driver program, in particular, a method, device and storage medium for automatically generating an LCD driver program and a device tree configuration file. BACKGROUND
[0002] In motorcycle instruments and car control devices, LCD display panels are important components. Different devices have different requirements for LCD panels, such as resolution, interface standards, timing parameters, etc. In the production process, developing a driver program and a device tree configuration file for each type of LCD panel often requires a lot of manual work, which has the following significant shortcomings: Heavy and tedious workload: for each new LCD panel, the developer needs to manually write the driver code, device tree configuration file, and needs to adjust it according to the specific parameters of each LCD panel. This process is not only tedious but also prone to errors.
[0003] Lack of automation and flexibility: Although there are certain templates for developers to refer to, each new LCD model still requires a lot of manual modification, resulting in poor generality of the templates and inability to meet large-scale production needs.
[0004] Prone to errors: due to manual modification and input, there are often spelling errors, inaccurate parameter configurations, and missing key configurations in the configuration file, which may cause hardware initialization failure or system failure.
[0005] Long development cycle: each new LCD panel requires re-modification and debugging of the driver code, device tree file, etc., greatly prolonging the product development cycle.
[0006] Code maintenance difficulties: with the increase of product models, manually writing and maintaining a large number of LCD driver programs and device tree configuration files will lead to code redundancy and confusion, making it difficult to effectively manage and update. SUMMARY
[0007] To solve the above problems, the present application provides a method for automatically generating an LCD driver program and a device tree configuration file, the specific technical solution is as follows: A method for automatically generating an LCD driver program and a device tree configuration file, comprising the following steps: Prepare a CSV file: prepare a CSV file containing LCD configuration information, each row of the CSV file represents the configuration of an LCD model; Run Python script: execute Python script, read each row of data in the CSV file, and automatically generate corresponding driver code and device tree configuration; Generate code files: The script generates a.c file for each LCD configuration, which includes the LCD driver header file, and saves the generated file in the specified directory. Update device tree files: The script automatically updates the device tree file based on the GPIO and configuration parameters of each LCD, adding a device tree fragment for new LCD models. Verify and debug: Testing on the LCD screen ensures that the driver is correct and the device tree configuration is accurate.
[0008] Preferably, the configuration includes the model, resolution, interface type, synchronization mode, GPIO pin configuration, PLL clock, color order, and pixel format of the LCD.
[0009] Preferably, the LCD driver header file includes: initialization, suspension, and recovery of the LCD; parameter setting functions generated using the timing and resolution information of the LCD.
[0010] Further, the generated driver code file is saved under the lcm / directory.
[0011] Preferably, when updating the device tree file, a device tree fragment is generated based on the LCD information, which includes the compatible field identifying the LCD type. Configure the GPIO interface of the LCD, including the reset pin and power pin.
[0012] The device tree fragment is appended to the specified device tree file.
[0013] Preferably, when running the Python script, read the CSV file and parse each row of data, then call the generate_lcd_driver and generate_device_tree functions to generate the driver source code and device tree configuration respectively.
[0014] Preferably, when the Python script is executed, it reads the configuration information from the lcd_info.csv file and processes it to generate the relevant driver files and device tree configuration.
[0015] An apparatus for automatically generating LCD driver programs and device tree configuration files, the apparatus comprising: a processor, a memory, and a program; the program is stored in the memory, and the processor calls the program stored in the memory to execute the steps of the method.
[0016] A computer-readable storage medium configured to store a program configured to perform the steps of the method of automatically generating an LCD driver and device tree configuration file.
[0017] Compared with the prior art, the present application has the following beneficial effects: The method of automatically generating an LCD driver and device tree configuration file provided by the present application can automatically generate an LCD driver and a device tree configuration file, reduce the work burden of developers, improve work efficiency, reduce human errors, speed up the development cycle of products, and improve code reusability and maintainability. BRIEF DESCRIPTION OF DRAWINGS
[0018] Figure 1 is the flowchart of the present application. DETAILED DESCRIPTION
[0019] The present application will be further described in conjunction with the accompanying drawings.
[0020] As shown in the accompanying drawings, a method of automatically generating an LCD driver and device tree configuration file includes the following steps: Figure 1 Preparation of a CSV file: First, prepare a CSV file containing LCD configuration information. Each row represents the configuration of an LCD model, including the resolution, timing, GPIO configuration, etc. of the LCD. Running a Python script: Execute a Python script that reads each line of data in the CSV file and automatically generates the corresponding driver code (.c file) and device tree configuration (.dts file).
[0021] Generation of code files: The script generates a.c file for each LCD configuration, including initialization, timing settings, and related operations. The generated files are saved in a designated directory.
[0022] Update the device tree file: The script automatically updates the device tree file based on the GPIO and configuration parameters of each LCD, adding device tree fragments for new LCD models.
[0023] Verification and debugging: The generated code can be directly compiled and run for testing on the LCD screen to ensure that the driver is correct and the device tree configuration is error-free.
[0024] The configuration includes the model, resolution, interface type, synchronization mode, GPIO pin configuration, PLL clock, color order, and pixel format of the LCD.
[0025]
[0026] The header file of the LCD driver includes parameter setting functions for generating drivers using the initialization, suspension, and recovery of the LCD, as well as the timing and resolution information of the LCD.
[0027] The generated driver code file is saved under the lcm / directory.
[0028] When updating the device tree file, a device tree fragment is generated according to the LCD information, which includes a compatible field identifying the LCD type. Configure the GPIO interface of the LCD, including the reset pin and power pin.
[0029] The device tree fragment is appended to the specified device tree file.
[0030] When running the Python script, read the CSV file and parse each row of data, then call the generate_lcd_driver and generate_device_tree functions to generate the driver source code and device tree configuration respectively.
[0031] When the Python script is executed, it reads the configuration information from the lcd_info.csv file and processes it to generate the relevant driver files and device tree configurations.
[0032] Input configuration file: Use a CSV file to store detailed parameter information for each LCD panel, including resolution, interface type, synchronization mode, GPIO pin configuration, PLL clock, etc.
[0033] An example of the configuration file structure is as follows: LCD model: indicates the name or identification of the LCD panel; Resolution width: horizontal resolution of the LCD; Resolution height: vertical resolution of the LCD; Synchronization mode: display mode, such as synchronous mode, DPI mode, DSI mode, etc. GPIO reset pin: GPIO pin number corresponding to the LCD reset signal; GPIO power pin: GPIO pin number for LCD power control; Other hardware parameters: such as PLL clock, color order, pixel format, etc.
[0034] Automatic code generation script: Write a Python script to automatically generate C language code based on the specific parameters of each LCD model by reading the input configuration file. The generated code includes the initialization function of the LCD driver, hardware timing parameters, GPIO control logic, and other contents.
[0035] Automatically generate device tree node code that describes the hardware characteristics of the LCD panel, such as display mode, resolution, timing, and other configurations, and save it as a device tree file.
[0036] Script execution and code output: Users simply need to run the script, which will automatically generate the corresponding driver source code file (.c file) and device tree file (.dts) for each LCD model based on the contents of the configuration file.
[0037] The generated code includes: LCD driver file: containing functions for initialization, timing configuration, GPIO control, etc.
[0038] Device tree node file: describes the hardware interfaces and configuration information of the LCD panel.
[0039] Code integration and debugging: The automatically generated code is integrated with the existing hardware platform and verified through compilation and debugging. Fine-tuning of the generated code is performed as needed.
[0040] After the code is generated, developers can fine-tune specific hardware configurations according to actual needs to ensure that the hardware can work properly.
[0041] Define the input table: First, define a CSV file (lcd_info.csv) to record information for each LCD. The content can include the following fields: LCD model name; Resolution (e.g., 1920x1080); Timing parameters (e.g., VFP, VSA, HFP, HSA, etc.); GPIO configuration information (e.g., reset-gpios, lcd_vdd_en-gpios, etc.); Clock frequency, number of data channels, etc.; Other LCD features.
[0042] Python script implementation: Automatically generate LCD driver code. First, prepare a CSV file containing LCD configuration information. The script reads this CSV file and generates the corresponding source code based on each row of configuration.
[0043] Explanation of script execution steps: 1. Generate LCD driver code (generate_lcd_driver).
[0044] After reading the configuration information for each LCD from the CSV file, this function will generate a .c file for each LCD model.
[0045] The file contains: header files for the LCD driver.
[0046] The structure for setting up the LCD driver includes operations such as LCD initialization, suspension, and resumption.
[0047] The parameter setting function for the driver is generated using information such as the LCD's timing and resolution.
[0048] The generated driver code file will eventually be saved in the lcm / directory.
[0049] 2. Generate the device tree file (generate_device_tree).
[0050] A device tree fragment is generated based on the LCD information, including the compatible field which identifies the LCD type.
[0051] Configure the LCD's GPIO interfaces, including the reset pin (reset-gpios) and power pins (lcd_vdd_en-gpios, lcd_avdd_en-gpios).
[0052] The device tree fragment will be appended to the specified device tree file (e.g., tb8781p1_64.dts).
[0053] 3. Process CSV files (process_lcd_info).
[0054] This function reads a CSV file, parses each row (the configuration for each LCD), and then calls the generate_lcd_driver and generate_device_tree functions to generate the driver source code and device tree configuration, respectively.
[0055] Each line contains configuration information for an LCD, which will be passed to the function that generates the code.
[0056] 4. Main program entry point.
[0057] When the script is executed, it reads and processes the configuration information from the lcd_info.csv file to generate the relevant driver files and device tree configuration.
[0058] Input file (lcd_info.csv) example: This CSV file contains basic configuration information for each LCD. An example is shown below:
[0059]
[0060] Note: The above two tables are the same row Compared with the prior art, the present application has the following several significant advantages and innovations: Automatic code generation: The present application generates driving code and device tree configuration files automatically based on the input LCD panel parameters (such as resolution, interface type, timing configuration, etc.) through the design of an automatic script, reducing the need for manual operation and code manual input, greatly improving work efficiency.
[0061] Flexible and efficient: By using a parameter configuration file in CSV format, users can easily adjust the configuration of each LCD panel without the need to manually modify the code, and can generate drivers and configuration files for multiple LCD models at once. This method is not only suitable for small-scale development, but also can meet the needs of large-scale production.
[0062] Reduce human error: The automatically generated code follows a uniform format and standard, avoiding human errors such as spelling errors, parameter errors, etc., ensuring the correctness and consistency of the code, thereby improving the stability and reliability of the system.
[0063] Accelerate development cycle: By automatically generating code, developers no longer need to repeatedly modify the code manually, thereby greatly shortening the development cycle and shortening the time to market.
[0064] Convenient for later maintenance and update: The automatically generated code structure is clear, easy to manage and maintain. When a new model of LCD panel needs to be added, only the configuration file needs to be updated and the automatic script needs to be run again, greatly simplifying the code maintenance process.
[0065] Improve code reusability: Through template design and parameterized configuration, developers can quickly generate drivers for multiple LCD panels, ensuring code reusability and reducing repetitive development work.
[0066] An apparatus for automatically generating an LCD driver program and a device tree configuration file, the apparatus comprising: a processor, a memory, and a program; the program is stored in the memory, and the processor calls the program stored in the memory to execute the steps of the method for automatically generating an LCD driver program and a device tree configuration file.
[0067] The memory and the processor are electrically connected directly or indirectly to realize the transmission or interaction of data. For example, these elements can be electrically connected through one or more communication buses or signal lines, such as through a bus connection. The memory stores computer execution instructions for realizing the data access control method, including at least one software function module stored in the memory in the form of software or firmware. The processor executes various function applications and data processing by running the software program and the module stored in the memory.
[0068] The memory can be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. Among them, the memory is used to store programs, and the processor executes the programs after receiving execution instructions.
[0069] The processor can be an integrated circuit chip with signal processing capability. The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc. It can realize or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0070] The embodiments of the present application are described with reference to the flowcharts according to the method, terminal device (system), and computer program product of the embodiments of the present application. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device produce a device for realizing the functions specified in the flowcharts and / or.
[0071] A computer readable storage medium is configured to store a program, and the program is configured to execute the steps of the method for automatically generating an LCD driver and a device tree configuration file.
[0072] Computer readable storage media as used herein includes random access memory (RAM), internal memory, read only memory (ROM), erasable programmable ROM, electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disks, CD-ROMs, and any other form of storage medium known in the art.
[0073] The technical principles of the present application are described above in connection with specific embodiments. These descriptions are only for explaining the principles of the present application and cannot be interpreted as limiting the scope of protection of the present application in any way. Based on the explanations herein, other specific embodiments of the present application can be conceived by those skilled in the art without any creative effort, and these embodiments will all fall within the scope of protection of the claims of the present application.
Claims
1. A method for automatically generating LCD driver programs and device tree configuration files, characterized in that, The method comprises the following steps: Preparing a CSV file containing LCD configuration information, each line of which represents the configuration of an LCD model; Running a Python script to read each line of data in the CSV file and automatically generating the corresponding driver code and device tree configuration; Generating code files: the script generates a.c file for each LCD configuration, which includes the header file of the LCD driver, and saves the generated file in the specified directory; Updating the device tree file: the script automatically updates the device tree file based on the GPIO and configuration parameters of each LCD, adding a device tree fragment for the new LCD model; Verification and debugging: test on the LCD screen to ensure that the driver is correct and the device tree configuration is correct.
2. The method of claim 1, wherein, The configuration includes the model, resolution, interface type, synchronization mode, GPIO pin configuration, PLL clock, color order, and pixel format of the LCD.
3. The method of claim 1, wherein, The header file of the LCD driver includes the initialization, suspension, and recovery of the LCD, as well as the parameter setting function generated using the timing and resolution information of the LCD.
4. The method of claim 3, wherein, The generated driver code file is saved under the lcm / directory.
5. The method of claim 1, wherein, When updating the device tree file, a device tree fragment is generated based on the LCD information, which includes the compatible field identifying the LCD type. Configure the GPIO interface of the LCD, including the reset pin and power pin.
6. The device tree fragment is appended to the specified device tree file.
7. The method of claim 1, wherein, When running the Python script, read the CSV file and parse each line of data, then call the generate_lcd_driver and generate_device_tree functions to generate the driver source code and device tree configuration respectively.
8. The method of claim 1, wherein, When the Python script is executed, the configuration information is read from the lcd_info.csv file and processed to generate the relevant driver files and device tree configuration.
9. An apparatus for automatically generating an LCD driver program and device tree configuration file, the apparatus comprising: a processor, a memory, and a program; the program is stored in the memory, and the processor calls the program stored in the memory to execute the steps of the method of claim 1.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium is configured to store a program, and the program is configured to execute the steps of the method of claim 1.