完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
1.实验原理
前文介绍过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输出端口: 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 = < }; }; };
参考文档: Documentation/devicetree/bindings/pwm/pwm-stm32.txt 内核中ST对STM32MP15x系列芯片的设备树资源了做了定义,可参见: arch/arm/boot/dts/stm32mp151.dtsi stm32mp151中timers2定义如下: timers2: timer@40000000 { #address-cells = <1>; #size-cells = <0>; compatible = "st,stm32-timers"; reg = <0x40000000 0x400>; clocks = <&rcc TIM2_K>; clock-names = "int"; dmas = <&dmamux1 18 0x400 0x80000001>, <&dmamux1 19 0x400 0x80000001>, <&dmamux1 20 0x400 0x80000001>, <&dmamux1 21 0x400 0x80000001>, <&dmamux1 22 0x400 0x80000001>; dma-names = "ch1", "ch2", "ch3", "ch4", "up"; status = "disabled"; pwm { compatible = "st,stm32-pwm"; #pwm-cells = <3>; status = "disabled"; }; timer@1 { compatible = "st,stm32h7-timer-trigger"; reg = <1>; status = "disabled"; }; counter { compatible = "st,stm32-timer-counter"; status = "disabled"; }; }; 上述代码只对timers5做了基本的初始化,并没有针对不同的硬件设计做适配,所以需结合硬件补全设备树节点信息。 参考文档或stm32mp15xx-dkx.dtsi对于i2c设备节点的描述,增加timers内容如下: &timers2 { /* spare dmas for other usage */ /delete-property/dmas; /delete-property/dma-names; status = "okay"; pwm2: pwm { pinctrl-0 = <&pwm2_pins_b>; pinctrl-1 = <&pwm2_sleep_pins_b>; pinctrl-names = "default", "sleep"; #pwm-cells = <2>; status = "okay"; }; timer@2 { status = "disabled"; }; }; stm32mp15-pinctrl.dtsi对于pwm2的描述与FS-MP1A所使用管脚不一致,所以无法直接使用,需参考其增加如下内容: pwm2_pins_b: pwm2-0 { pins { pinmux = bias-pull-down; drive-push-pull; slew-rate = <0>; }; }; pwm2_sleep_pins_b: pwm1-sleep-0 { pins { pinmux = }; };
参考文档: Documentation/devicetree/bindings/leds/backlight/pwm-backlight.txt Documentation/devicetree/bindings/leds/backlight/gpio-backlight.txt FS-MP1A背光可以通过GPIO驱动也可通过PWM2的通道1驱动,可以对比参考文档或内核中其他设备树关于背光的定义。 GPIO驱动背光节点内容如下: panel_backlight: panel-backlight { compatible = "gpio-backlight"; gpios = <&gpiod 13 GPIO_ACTIVE_LOW>; default-on; status = "okay"; }; PWM驱动背光节点内容如下: panel_backlight: panel-backlight { compatible = "pwm-backlight"; pwms = <&pwm2 0 5000000>; brightness-levels = <0 4 8 16 32 64 128 255>; default-brightness-level = <6>; status = "okay"; }; 2.实验目的 熟悉基于Linux操作系统下的摄像头设备驱动移植配置过程。 3.实验平台 华清远见开发环境,FS-MP1A平台; 4.实验步骤
linux@ubuntu:$ source /opt/st/stm32mp1/3.1-openstlinux-5.4-dunfell-mp1-20-06-24/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi
由于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"; }; 由于增加了新的设备树文件需修改arch/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
修改stm32mp15xx-fsmp1x.dtsi,在stm32mp15xx-fsmp1x.dtsi文件末尾添加如下内容: &timers2 { /* spare dmas for other usage */ /delete-property/dmas; /delete-property/dma-names; status = "okay"; pwm2: pwm { pinctrl-0 = <&pwm2_pins_b>; pinctrl-1 = <&pwm2_sleep_pins_b>; pinctrl-names = "default", "sleep"; #pwm-cells = <2>; status = "okay"; }; timer@2 { status = "disabled"; }; }; &pinctrl { pwm2_pins_b: pwm2-0 { pins { pinmux = bias-pull-down; drive-push-pull; slew-rate = <0>; }; }; pwm2_sleep_pins_b: pwm1-sleep-0 { pins { pinmux = }; }; };
修改stm32mp15xx-fsmp1x.dtsi,在根节点中添加如下内容: panel_backlight: panel-backlight { compatible = "pwm-backlight"; pwms = <&pwm2 0 5000000>; brightness-levels = <0 4 8 16 32 64 128 255>; default-brightness-level = <6>; status = "okay"; };
修改文件arm/arm/boot/dts/stm32mp157a-fsmp1a-rgb070.dts,在文件末尾添加如下内容: 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 = < }; }; };
修改文件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
在虚拟机/tftpboot /tftpboot/pxelinux.cfg/01-00-80-e1-42-60-17末尾添加 LABEL stm32mp157a-fsmp1a-mipi KERNEL /uImage FDT /stm32mp157a-fsmp1a-rgb070.dtb APPEND root=/dev/mmcblk1p4 rootwait rw console=ttySTM0,115200
linux@ubuntu:$ make -j4 uImage dtbs LOADADDR=0xC2000040
安装上7寸LCD面板,将编译好的设备树和内核镜像拷贝到/tftpboot目录下,通过tftp引导内核,启动后可正常显示,如果屏幕显示不正可适当调节面板参数。 |
|
|
|
只有小组成员才能发言,加入小组>>
3263 浏览 9 评论
2944 浏览 16 评论
3443 浏览 1 评论
8955 浏览 16 评论
4036 浏览 18 评论
1079浏览 3评论
559浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
552浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2287浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1848浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-10 16:28 , Processed in 1.243246 second(s), Total 79, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号