“Linux内核-RGB LCD驱动移植”的版本间的差异
(→实验步骤) |
(→实验步骤) |
||
第128行: | 第128行: | ||
:: stm32mp157d-dk1.dtb \ | :: stm32mp157d-dk1.dtb \ | ||
</div> | </div> | ||
+ | *添加ltdc端口<br> | ||
+ | |||
+ | 修改文件arm/arm/boot/dts/stm32mp157a-fsmp1a-rgb070.dts,在文件末尾添加如下内容: | ||
+ | <pre><nowiki> | ||
+ | <dc { | ||
+ | status = "okay"; | ||
+ | |||
+ | port { | ||
+ | #address-cells = <1>; | ||
+ | #size-cells = <0>; | ||
+ | ltdc_ep1_out: endpoint@1 { | ||
+ | reg = <1>; | ||
+ | remote-endpoint = <&panel_in_rgb>; | ||
+ | }; | ||
+ | }; | ||
+ | }; | ||
+ | </nowiki></pre> | ||
+ | *添加面板信息<br> | ||
+ | |||
+ | 修改文件arm/arm/boot/dts/stm32mp157a-fsmp1a-rgb070.dts,在根节点中添加如下内容: | ||
+ | <pre><nowiki> | ||
+ | panel: panel-rgb { | ||
+ | compatible = "innolux,zj070na-01p"; | ||
+ | pinctrl-names = "default", "sleep"; | ||
+ | backlight = <&panel_backlight>; | ||
+ | status = "okay"; | ||
+ | port { | ||
+ | panel_in_rgb: endpoint { | ||
+ | remote-endpoint = <<dc_ep1_out>; | ||
+ | }; | ||
+ | }; | ||
+ | }; | ||
+ | </nowiki></pre> | ||
+ | *修改面板驱动,修改面板时序参数<br> | ||
+ | |||
+ | 修改文件drivers/gpu/drm/panel/panel-simple.c,修改zj070na-01p面板信息,对照面板芯片手册修改原有内容,红色字体部分为修改内容: | ||
+ | <pre><nowiki> | ||
+ | static const struct drm_display_mode innolux_zj070na_01p_mode = { | ||
+ | .clock = 51501, | ||
+ | .hdisplay = 1024, | ||
+ | .hsync_start = 1024 + 160, | ||
+ | .hsync_end = 1024 + 160 + 20, | ||
+ | .htotal = 1024 + 160 + 20 + 140, | ||
+ | .vdisplay = 600, | ||
+ | .vsync_start = 600 + 12, | ||
+ | .vsync_end = 600 + 12 + 3, | ||
+ | .vtotal = 600 + 12 + 3 + 12, | ||
+ | .vrefresh = 60, | ||
+ | }; | ||
+ | </nowiki></pre> | ||
+ | *配置内核<br> | ||
+ | |||
+ | 由于内核默认支持通用面板驱动,本节列出主要选项,如下 | ||
+ | <pre><nowiki> | ||
+ | linux@ubuntu:$ make menuconfig | ||
+ | Device Drivers ---> | ||
+ | Graphics support ---> | ||
+ | <*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) ---> | ||
+ | <*> DRM Support for STMicroelectronics SoC Series | ||
+ | Display Panels ---> | ||
+ | <*> support for simple panels | ||
+ | Backlight & LCD device support ---> | ||
+ | <*> Generic PWM based Backlight Driver | ||
+ | </nowiki></pre> | ||
+ | *编译内核及设备树 | ||
+ | linux@ubuntu:$ make -j4 uImage dtbs LOADADDR=0xC2000040 | ||
+ | *重启测试<br> | ||
+ | |||
+ | 安装上7寸LCD面板,将编译好的设备树和内核镜像拷贝到/tftpboot目录下,通过tftp引导内核,启动后可正常显示,如果屏幕显示不正可适当调节面板参数。 | ||
+ | |||
+ | [[Image:55-1-4-1.png]] <br> |
2020年7月28日 (二) 11:42的版本
实验原理
前文介绍过LTDC的内容,本节只需为LTDC添加一个面板即可。内核中包含一个通用的面板驱动,驱动之包含大量各种各样的面板。
- 驱动修改
驱动路径为:drivers/gpu/drm/panel/panel-simple.c
移植时可以在驱动中支持新的面板的内容,也可以找到一个与自己面板相仿的内容进行修改,本节即使用在原有面板修改的方法。如本节参考面板名称为zj070na-01p,对于一个面板最关键的内容在驱动通过drm_display_mode的结构体描述,zj070na-01p的描述如下:
static const struct drm_display_mode innolux_zj070na_01p_mode = { .clock = 51501, .hdisplay = 1024, .hsync_start = 1024 + 128, .hsync_end = 1024 + 128 + 64, .htotal = 1024 + 128 + 64 + 128, .vdisplay = 600, .vsync_start = 600 + 16, .vsync_end = 600 + 16 + 4, .vtotal = 600 + 16 + 4 + 16, .vrefresh = 60, };
这个结构体主要用来描述面板的时序相关信息,时序框图如下:
hdisplay:有效显示区水平像素数量,对应Active Width
hsync_start:水平同步开始,对应hdispay + HFP
hsync_end:水平同步结束,对应hdisplay + HFP + HSYNC width(HPW)
htotal:水平总像素,对应hdisplay + HFP + HSYNC width + HBP
vdisplay:垂直显示像素,对应Active Height
vsync_start:垂直同步开始,对应vdispay + VFP
vsync_end:垂直像素结束,对应vdisplay + VFP + VSYNC width(VPW)
vtotal:垂直总像素,对应vdisplay + VFP + VSYNC width + VBP
vrefresh:刷新率
面板芯片手册中关于时序的描述如下:
表中可以确认HBP=140、HPW=20、HFP=160、VBP=20、VPW=3、VFP=12,修改面板信息如下:
static const struct drm_display_mode innolux_zj070na_01p_mode = { .clock = 51501, .hdisplay = 1024, .hsync_start = 1024 + 160, .hsync_end = 1024 + 160 + 20, .htotal = 1024 + 160 + 20 + 140, .vdisplay = 600, .vsync_start = 600 + 12, .vsync_end = 600 + 12 + 3, .vtotal = 600 + 12 + 3 + 12, .vrefresh = 60, };
- 设备树修改
增加ltdc输出端口:
<dc { status = "okay"; port { #address-cells = <1>; #size-cells = <0>; ltdc_ep1_out: endpoint@1 { reg = <1>; remote-endpoint = <&panel_in_rgb>; }; }; };
增加面板节点:
panel: panel-rgb { compatible = "innolux,zj070na-01p"; pinctrl-names = "default", "sleep"; backlight = <&panel_backlight>; status = "okay"; port { panel_in_rgb: endpoint { remote-endpoint = <<dc_ep1_out>; }; }; };
实验目的
熟悉基于Linux操作系统下的摄像头设备驱动移植配置过程。
实验平台
华清远见开发环境,FS-MP1A平台;
实验步骤
- 增加设备树文件
由于RGB LCD并非FS-MP1A必须配置,本节增加一个设备树文件,对应增加了屏幕的设备。
在内核的arch/arm/boot/dts目录下新建文件stm32mp157a-fsmp1a-rgb070.dts文件并添加如下内容:
#include "stm32mp157a-fsmp1a.dts" / { model = "HQYJ STM32MP157 FSMP1A RGB Discovery Board"; compatible = "st,stm32mp157a-dk1", "st,stm32mp157"; };
由于增加了新的设备树文件需修改arm/arm/boot/dts/Makefile,在文件中增加新的条目,红色字体部分为增加内容
- dtb-$(CONFIG_ARCH_STM32) += \
- …
- stm32mp157a-dk1.dtb \
- stm32mp157a-fsmp1a.dtb \
- stm32mp157a-fsmp1a-mipi050.dtb \
- stm32mp157a-fsmp1a-rgb070.dtb \
- stm32mp157d-dk1.dtb \
- 添加ltdc端口
修改文件arm/arm/boot/dts/stm32mp157a-fsmp1a-rgb070.dts,在文件末尾添加如下内容:
<dc { status = "okay"; port { #address-cells = <1>; #size-cells = <0>; ltdc_ep1_out: endpoint@1 { reg = <1>; remote-endpoint = <&panel_in_rgb>; }; }; };
- 添加面板信息
修改文件arm/arm/boot/dts/stm32mp157a-fsmp1a-rgb070.dts,在根节点中添加如下内容:
panel: panel-rgb { compatible = "innolux,zj070na-01p"; pinctrl-names = "default", "sleep"; backlight = <&panel_backlight>; status = "okay"; port { panel_in_rgb: endpoint { remote-endpoint = <<dc_ep1_out>; }; }; };
- 修改面板驱动,修改面板时序参数
修改文件drivers/gpu/drm/panel/panel-simple.c,修改zj070na-01p面板信息,对照面板芯片手册修改原有内容,红色字体部分为修改内容:
static const struct drm_display_mode innolux_zj070na_01p_mode = { .clock = 51501, .hdisplay = 1024, .hsync_start = 1024 + 160, .hsync_end = 1024 + 160 + 20, .htotal = 1024 + 160 + 20 + 140, .vdisplay = 600, .vsync_start = 600 + 12, .vsync_end = 600 + 12 + 3, .vtotal = 600 + 12 + 3 + 12, .vrefresh = 60, };
- 配置内核
由于内核默认支持通用面板驱动,本节列出主要选项,如下
linux@ubuntu:$ make menuconfig Device Drivers ---> Graphics support ---> <*> Direct Rendering Manager (XFree86 4.1.0 and higher DRI support) ---> <*> DRM Support for STMicroelectronics SoC Series Display Panels ---> <*> support for simple panels Backlight & LCD device support ---> <*> Generic PWM based Backlight Driver
- 编译内核及设备树
linux@ubuntu:$ make -j4 uImage dtbs LOADADDR=0xC2000040
- 重启测试
安装上7寸LCD面板,将编译好的设备树和内核镜像拷贝到/tftpboot目录下,通过tftp引导内核,启动后可正常显示,如果屏幕显示不正可适当调节面板参数。