Linux LCD screen driver parameter adjustment practice

Linux LCD screen driver parameter adjustment practice

As mentioned in the article on LCD driver under Linux , the eLCDIF interface driver of IMX6ULL has been written by the semiconductor manufacturer NXP, and the eLCDIF interface driver codes of LCD screens with different resolutions are the same, so the LCD driver part does not need to be modified. You only need to adjust the device tree parameters according to the LCD used. This article uses the IMX6ULL development board of punctual atom, and the interface IO of its LCD is as shown below:

insert image description here
As can be seen from the figure above, the LCD uses the following three types of IO connections:

– 24 RGB LCD data lines
– 4 control lines, PCLK, DE, VSYNC and HSYNC
– 1 LCD backlight PWM pin line

1. Device tree modification

The modification of the device tree involves the following three aspects:

– IO configuration used by the LCD
– Modify the LCD screen node, modify the corresponding attribute value, and replace it with the LCD screen parameters we use
– Modify the LCD backlight node information, modify the corresponding device node information according to the actual backlight IO used

1.1 LCD screen IO configuration

Configure the IO used by the LCD in the device tree. Usually, the semiconductor manufacturer has written it and does not need to be modified. In the imx6ull-andyxi-emmc.dts file, the following configuration content can be found in the iomuxc node:

pinctrl_lcdif_dat: lcdifdatgrp {
    
     
	fsl,pins = < 
		MX6UL_PAD_LCD_DATA00__LCDIF_DATA00 0x79 
		MX6UL_PAD_LCD_DATA01__LCDIF_DATA01 0x79 
		MX6UL_PAD_LCD_DATA02__LCDIF_DATA02 0x79 
		MX6UL_PAD_LCD_DATA03__LCDIF_DATA03 0x79 
		MX6UL_PAD_LCD_DATA04__LCDIF_DATA04 0x79 
		MX6UL_PAD_LCD_DATA05__LCDIF_DATA05 0x79 
		MX6UL_PAD_LCD_DATA06__LCDIF_DATA06 0x79 
		MX6UL_PAD_LCD_DATA07__LCDIF_DATA07 0x79 
		MX6UL_PAD_LCD_DATA08__LCDIF_DATA08 0x79 
		MX6UL_PAD_LCD_DATA09__LCDIF_DATA09 0x79 
		MX6UL_PAD_LCD_DATA10__LCDIF_DATA10 0x79 
		MX6UL_PAD_LCD_DATA11__LCDIF_DATA11 0x79 
		MX6UL_PAD_LCD_DATA12__LCDIF_DATA12 0x79 
		MX6UL_PAD_LCD_DATA13__LCDIF_DATA13 0x79 
		MX6UL_PAD_LCD_DATA14__LCDIF_DATA14 0x79 
		MX6UL_PAD_LCD_DATA15__LCDIF_DATA15 0x79 
		MX6UL_PAD_LCD_DATA16__LCDIF_DATA16 0x79 
		MX6UL_PAD_LCD_DATA17__LCDIF_DATA17 0x79 
		MX6UL_PAD_LCD_DATA18__LCDIF_DATA18 0x79 
		MX6UL_PAD_LCD_DATA19__LCDIF_DATA19 0x79 
		MX6UL_PAD_LCD_DATA20__LCDIF_DATA20 0x79 
		MX6UL_PAD_LCD_DATA21__LCDIF_DATA21 0x79 
		MX6UL_PAD_LCD_DATA22__LCDIF_DATA22 0x79 
		MX6UL_PAD_LCD_DATA23__LCDIF_DATA23 0x79 
	>; 
};

pinctrl_lcdif_ctrl: lcdifctrlgrp {
    
     
	fsl,pins = < 
		MX6UL_PAD_LCD_CLK__LCDIF_CLK 0x79 
		MX6UL_PAD_LCD_ENABLE__LCDIF_ENABLE 0x79 
		MX6UL_PAD_LCD_HSYNC__LCDIF_HSYNC 0x79 
		MX6UL_PAD_LCD_VSYNC__LCDIF_VSYNC 0x79 
	>; 
};
	
pinctrl_pwm1: pwm1grp {
    
     
	fsl,pins = < 
		MX6UL_PAD_GPIO1_IO08__PWM1_OUT 0x110b0 
	>; 
};

The IO used by the LCD is divided into the following three categories:

– The subnode pinctrl_lcdif_dat is the configuration item for the 24 data lines of RGB LCD.
– Subnode pinctrl_lcdif_ctrl RGB LCD 4 control line configuration items, including CLK, ENABLE, VSYNC and HSYNC.
– Subnode pinctrl_pwm1 LCD backlight PWM pin configuration item. This pin should be set according to the actual situation. Here we suggest that in the future study or work, the LCD backlight IO should be as consistent as possible with the official development board of the semiconductor manufacturer.

1.2 LCD screen parameter node information modification

Find the lcdif node in the imx6ull-andyxi-emmc.dts file, taking the ATK7016 (7-inch 1024*600) screen of punctual atom as an example, the content of the node is as follows:

&lcdif {
    
     
	pinctrl-names = "default"; 
	pinctrl-0 = <&pinctrl_lcdif_dat /* 使用到的IO */ 
				 &pinctrl_lcdif_ctrl
				 &pinctrl_lcdif_reset>; 			 
	display = <&display0>; 
	status = "okay"; 

	display0: display {
    
     /* LCD属性信息 */
		bits-per-pixel = <24>; /* 一个像素占用24bit */ 
		bus-width = <24>; /* 总线宽度 */ 
 
		display-timings {
    
     
			native-mode = <&timing0>; /* 时序信息 */ 
			timing0: timing0 {
    
     
				clock-frequency = <51200000>; /* LCD像素时钟,单位Hz */ 
				hactive = <1024>; /* LCD X轴像素个数 */ 
				vactive = <600>; /* LCD Y轴像素个数 */ 
				hfront-porch = <160>; /* LCD hfp参数 */ 
				hback-porch = <140>; /* LCD hbp参数 */ 
				hsync-len = <20>; /* LCD hspw参数 */ 
				vback-porch = <20>; /* LCD vbp参数 */ 
				vfront-porch = <12>; /* LCD vfp参数 */ 
				vsync-len = <3>; /* LCD vspw参数 */ 

				hsync-active = <0>; /* hsync数据线极性 */ 
				vsync-active = <0>; /* vsync数据线极性 */ 
				de-active = <1>; /* de数据线极性 */ 
				pixelclk-active = <0>; /* clk数据线先极性 */ 
			}; 
		}; 
	}; 
};

1.3 LCD screen backlight node information

The backlight control IO is connected to the GPIO1_IO08 pin of I.MX6U, which is multiplexed as PWM1_OUT, and the brightness of the LCD screen backlight is controlled through the PWM signal.

The configuration information of the backlight node can be found in imx6ull-andyxi-emmc.dts:

pinctrl_pwm1: pwm1grp {
    
     
	fsl,pins = < 
		MX6UL_PAD_GPIO1_IO08__PWM1_OUT 0x110b0 
	>; 
};
&pwm1 {
    
     
	pinctrl-names = "default"; 
	pinctrl-0 = <&pinctrl_pwm1>; 
	status = "okay"; 
};
backlight {
    
     
	compatible = "pwm-backlight"; 
	pwms = <&pwm1 0 5000000>; 
	brightness-levels = <0 4 8 16 32 64 128 255>; 
	default-brightness-level = <6>; 
	status = "okay"; 
};

2. Compile and test

2.1 LCD basic test

After configuring the device tree, use make dtbsthe command to compile the device tree and use the new device tree to start the Linux kernel. In order to observe whether the LCD driver is working normally, you can enable the little penguin logo display function of Linux. In the root directory of the Linux kernel source code, use make menuconfigthe command to open the graphical configuration interface, and press the following path to enable the logo display function

-> Device Drivers 
	-> Graphics support 
		-> Bootup logo (LOGO [=y]) 
			-> Standard black and white Linux logo 
			-> Standard 16-color Linux logo 
			-> Standard 224-color Linux logo 如图

insert image description here
Recompile the Linux kernel and use the new zImage image to start the system. If the LCD driver is normal, a colorful little penguin logo will appear in the upper left corner of the screen, and the background color of the screen is black, as shown below
insert image description here

2.2 LCD as a terminal console

In Linux development, the serial port software on the computer is usually used as the terminal of the Linux development board, and the development board communicates with the serial port software through the serial port. After the LCD is driven, you can set it as a terminal, that is, the development board uses its own display device as its own terminal. After connecting the keyboard, you can directly type commands on the development board. The method of setting the LCD as a terminal console is as follows :

  • Set the bootargs in uboot: restart the development board, enter the uboot command line, and reset the bootargs parametersconsolecontent
setenv bootargs 'console=tty1 console=ttymxc0,115200 root=/dev/nfs rw nfsroot=192.168.1.100: /home/andyxi/linux/nfs/rootfs ip=192.168.1.200:192.168.1.100:192.168.1.1:255.255.255.0::eth0:off'

Note: The console is set twice to the console,tty1is to set the LCD screen as the console,ttymxc0,115200It is to set the serial port as a console, which is equivalent to opening two consoles

  • Revise/etc/inittabFile: Open the /etc/inittab file in the root file system of the development board, and add the following code
tty1::askfirst:-/bin/sh

insert image description here

After the above modification, restart the development board, the LCD screen can be used as a terminal console, and you can connect the keyboard to type commands directly on the development board

2.3 LCD backlight adjustment

The backlight device tree node sets 8 levels of backlight adjustment, which can be set from 0 to 7. We can adjust the brightness of the LCD backlight by setting the backlight level, and enter the following directory:

/sys/devices/platform/backlight/backlight/backlight

insert image description here

Brightness in the figure above indicates the current brightness level, max_bgigntness indicates the maximum brightness level, and you can use catthe command to view the content
insert image description here

To modify the screen brightness, you only need to write the screen brightness level that needs to be set to brightness

echo 7 > brightness

2.4 LCD automatically turns off

The default setting in the Linux kernel is to turn off the LCD screen if it is not operated for 10 minutes to save power. There are several ways to solve this problem

  • Key or keyboard wakes up the LCD
  • Modify the Linux kernel settings: After modifying the blankinterval variable in the drivers/tty/vt/vt.c file in the Linux source code, recompile the kernel
static int vesa_blank_mode; 
static int vesa_off_interval; 
static int blankinterval = 10*60; //10*60秒,改为0后即可关闭熄屏功能
  • Use the APP to turn off the screen: write an APP with the LCD always on, and start the APP in the startup script
/***** lcd_always_on.c *****/
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h> 
 
int main(int argc, char *argv[]) {
    
     
	int fd; 
	fd = open("/dev/tty1", O_RDWR); 
	write(fd, "\033[9;0]", 8); 
	close(fd); 
	return 0; 
}

After compiling and generating an executable file, copy it to the ==/usr/bin== directory of the root file system of the development board, give it executable permission, set it to boot automatically, and open/etc/init.d/rcS, add the following at the end of this file:

insert image description here

cd /usr/bin 
./lcd_always_on 
cd ..

Guess you like

Origin blog.csdn.net/Chuangke_Andy/article/details/126288634