MIPI屏适配 [size=15.008px]100ASK-D1-H_DualDisplay-DevKit V11 1. 显示适配1.1 修改设备树1.1.1 修改内核设备树[size=15.008px]进入目录: [color=var(--hljs-builtin-name)]cd /home/ubuntu/tina-d1-h/device/config/chips/d1-h/configs/nezha/linux-5.4[size=15.008px]修改board.dts: &lcd0 { lcd_used = <1>; lcd_driver_name = [color=var(--hljs-string)]"tft08006"; lcd_backlight = <100>; lcd_if = <4>; lcd_x = <480>; lcd_y = <800>; lcd_width = <52>; lcd_height = <52>; lcd_dclk_freq = <25>; lcd_pwm_used = <1>; lcd_pwm_ch = <0>; lcd_pwm_freq = <1000>; lcd_pwm_pol = <0>; lcd_pwm_max_limit = <255>; lcd_hbp = <10>; lcd_ht = <515>; lcd_hspw = <5>; lcd_vbp = <20>; lcd_vt = <830>; lcd_vspw = <5>; lcd_dsi_if = <0>; lcd_dsi_lane = <2>; lcd_lvds_if = <0>; lcd_lvds_colordepth = <0>; lcd_lvds_mode = <0>; lcd_frm = <0>; lcd_hv_clk_phase = <0>; lcd_hv_sync_polarity= <0>; lcd_gamma_en = <0>; lcd_bright_curve_en = <0>; lcd_cmap_en = <0>; lcd_fsync_en = <0>; lcd_fsync_act_time = <1000>; lcd_fsync_dis_time = <1000>; lcd_fsync_pol = <0>; deu_mode = <0>; lcdgamma4iep = <22>; smart_color = <90>; lcd_gpio_0 = <&pio PG 13 GPIO_ACTIVE_HIGH>; pinctrl-0 = <&dsi4lane_pins_a>; pinctrl-1 = <&dsi4lane_pins_b>;};[size=15.008px]根据原理图:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-1[color=var(--secondary-high)]1178×985 197 KB
[size=15.008px]可以查看到,mipi屏的pwm通道引脚是PB5,设备树中搜索PB5,发现有I2C设备树节点占用,需要把status位设置为disabled:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-2[color=var(--secondary-high)]634×535 64.8 KB
[size=15.008px]lcd0设备树节点中的pwm通道是pwm0,即把pwm0设备树节点的引脚改为相应的PB5引脚: [size=15.008px] 1.1.2 修改uboot设备树[size=15.008px]进入目录: /home/ubuntu/tina-d1-h/device/config/chips/d1-h/configs/nezha[size=15.008px]修改uboot-board.dts: &lcd0 { lcd_used = <1>; lcd_driver_name = [color=var(--hljs-string)]"tft08006"; lcd_backlight = <100>; lcd_if = <4>; lcd_x = <480>; lcd_y = <800>; lcd_width = <52>; lcd_height = <52>; lcd_dclk_freq = <25>; lcd_pwm_used = <1>; lcd_pwm_ch = <0>; lcd_pwm_freq = <1000>; lcd_pwm_pol = <0>; lcd_pwm_max_limit = <255>; lcd_hbp = <10>; lcd_ht = <515>; lcd_hspw = <5>; lcd_vbp = <20>; lcd_vt = <830>; lcd_vspw = <5>; lcd_dsi_if = <0>; lcd_dsi_lane = <2>; lcd_lvds_if = <0>; lcd_lvds_colordepth = <0>; lcd_lvds_mode = <0>; lcd_frm = <0>; lcd_hv_clk_phase = <0>; lcd_hv_sync_polarity= <0>; lcd_io_phase = <0x0000>; lcd_dsi_te = <0>; lcd_gamma_en = <0>; lcd_bright_curve_en = <0>; lcd_cmap_en = <0>; lcd_fsync_en = <0>; lcd_fsync_act_time = <1000>; lcd_fsync_dis_time = <1000>; lcd_fsync_pol = <0>; deu_mode = <0>; lcdgamma4iep = <22>; smart_color = <90>; lcd_gpio_0 = <&pio PG 13 GPIO_ACTIVE_HIGH>; pinctrl-0 = <&dsi4lane_pins_a>; pinctrl-1 = <&dsi4lane_pins_b>;};1.2 内核配置[size=15.008px]修改内核驱动: [size=15.008px]进入目录: ~/tina-d1-h/lichee/linux-5.4/drivers/video/fbdev/sunxi/disp2/disp/lcd[size=15.008px]在这里[color=var(--tertiary)]100ASK_T113-PRO开发板适配4寸MIPI屏-Tina SDK - Allwinner / T113s3-PRO - 嵌入式开发问答社区可以下载到相应的驱动,替换到TinaSDK里面的tft08006.c和tft08006.h。 [size=15.008px]并修改如下:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-9[color=var(--secondary-high)]1029×452 17.4 KB
[size=15.008px]执行ckernel,进入内核配置界面: m kernel_menuconfig[size=15.008px]选上屏幕显示驱动TFT08006:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-4[color=var(--secondary-high)]2230×1064 221 KB
[size=15.008px]选上支持显示框架驱动:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-5[color=var(--secondary-high)]2222×1083 182 KB
[size=15.008px]"DISP Driver Support"关乎显示驱动框架的整体启用,而"LCD panels select"则专注于在这个框架下选择和配置具体的LCD面板硬件。前者是基础支持层,后者是具体应用层。 1.3 uboot配置[size=15.008px]修改uboot下的驱动: [size=15.008px]进入目录: ~/tina-d1-h/lichee/brandy-2.0/u-boot-2018/drivers/video/sunxi/disp2/disp/lcd[size=15.008px]在这里[color=var(--tertiary)]100ASK_T113-PRO开发板适配4寸MIPI屏-Tina SDK - Allwinner / T113s3-PRO - 嵌入式开发问答社区可以下载到相应的驱动,替换到TinaSDK里面的tft08006.c和tft08006.h。 [size=15.008px]并修改如下:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-10[color=var(--secondary-high)]1093×471 17.4 KB
[size=15.008px]执行cboot,进入uboot配置界面: make menuconfig[size=15.008px]选上屏幕显示驱动:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-6[color=var(--secondary-high)]2224×1072 215 KB
[size=15.008px]选上支持显示框架驱动:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-7[color=var(--secondary-high)]2228×1064 184 KB
[size=15.008px]mipi屏幕显示需要先在uboot阶段初始化。 1.4 显示测试[size=15.008px]为了方便测试屏幕显示,可以选上TinaSDK自带的lvgl例程。 [size=15.008px]执行croot,进入配置界面: make menuconfig[size=15.008px]选上lvgl例程:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-8[color=var(--secondary-high)]2223×1062 82.3 KB
[size=15.008px]编译make,打包pack。 [size=15.008px]烧录到板子后,执行lv_examples 1:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-11[color=var(--secondary-high)]891×516 55.9 KB
2. 触摸适配2.1 修改内核设备树[size=15.008px]根据原理图:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-12[color=var(--secondary-high)]1213×820 226 KB
[size=15.008px]可以查看: [size=15.008px]TP_INT→PB6;TP_RESET→PB4;DSI_SCL→PB0;DSI_SDA→PB1; [size=15.008px]进入: vi /home/ubuntu/tina-d1-h/device/config/chips/d1-h/configs/nezha/linux-5.4/board.dts[size=15.008px] [size=15.008px]看到PB0、PB1引脚对应的是twi2设备树节点。所以需要在twi2设备树节点中添加触摸屏设备树节点。 &twi2 { clock-frequency = <400000>; pinctrl-0 = <&twi2_pins_a>; pinctrl-1 = <&twi2_pins_b>; pinctrl-names = [color=var(--hljs-string)]"default", [color=var(--hljs-string)]"sleep"; dmas = <&dma 45>, <&dma 45>; dma-names = [color=var(--hljs-string)]"tx", [color=var(--hljs-string)]"rx"; status = [color=var(--hljs-string)]"okay"; ctp@38 { compatible = [color=var(--hljs-string)]"focaltech,fts"; reg = <0x38>; status = [color=var(--hljs-string)]"okay"; interrupt-parent = <&pio>; interrupts = <PB 6 IRQ_TYPE_LEVEL_LOW>; focaltech,reset-gpio = <&pio PB 4 GPIO_ACTIVE_HIGH>; focaltech,irq-gpio = <&pio PB 6 IRQ_TYPE_LEVEL_LOW>; focaltech,max-touch-number = <5>; focaltech,display-coords = <0 0 480 800>; focaltech,reg_vdd = <0x0000001f>; focaltech,reg_avdd = <0x0000001f>; };};[size=15.008px]如果原来有同样地址为0x38的I2C设备和触摸设备的节点时,可以注释或者删除。 2.2 添加触摸驱动Tina_SDK自带相应的触摸驱动,只需修改内核配置,把驱动编译进系统。
[size=15.008px]执行ckernel进入内核目录。 [size=15.008px]执行m kernel_menuconfig,进入内核配置界面,选上Focaltech Touchscreen :
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-14[color=var(--secondary-high)]2227×1061 217 KB
[size=15.008px]执行croot,进入SDK根目录,执行make menuconfig进入配置界面,把触摸驱动模块添加进文件系统中:
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-15[color=var(--secondary-high)]2226×1060 157 KB
2.3 修改触摸驱动在测试过程中,发现触摸点(x,y)不对,需要修改驱动程序。
[size=15.008px]进入目录: tina-d1-h/lichee/linux-5.4/drivers/input/touchscreen/focaltech_touch[size=15.008px]修改: vim focaltech_core.c[size=15.008px]两处修改: - 在fts_input_dev_report_a函数中修改,找到相应的位置:
[color=var(--hljs-comment)]#原来的input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->au16_x);input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->au16_y);[color=var(--hljs-comment)]#修改的input_report_abs(data->input_dev, ABS_MT_POSITION_X, -(event->au16_x - 480));input_report_abs(data->input_dev, ABS_MT_POSITION_Y, -(event->au16_y - 800));- 在fts_input_dev_report_b函数中修改,找到相应的位置:
[color=var(--hljs-comment)]#原来的input_report_abs(data->input_dev, ABS_MT_POSITION_X, event->au16_x);input_report_abs(data->input_dev, ABS_MT_POSITION_Y, event->au16_y);[color=var(--hljs-comment)]#修改的input_report_abs(data->input_dev, ABS_MT_POSITION_X, -(event->au16_x - 480));input_report_abs(data->input_dev, ABS_MT_POSITION_Y, -(event->au16_y - 800));2.4 修改lvgl驱动配置文件[size=15.008px]如果在lvgl的例程上测试触摸功能,需要进入目录: [color=var(--hljs-builtin-name)]cd /home/ubuntu/tina-d1-h/package/gui/littlevgl-8/lv_examples/src[size=15.008px]修改: vim lv_drv_conf.h
[size=15.008px][color=var(--tertiary)][color=var(--secondary)]image-16[color=var(--secondary-high)]1977×742 119 KB
[size=15.008px]如果之前配置过lvgl例程,需要进入目录: [color=var(--hljs-builtin-name)]cd /home/ubuntu/tina-d1-h/out/d1-h-nezha/compile_dir/target[size=15.008px]删除lv_examples,再进行编译打包烧录。 [size=15.008px]开发板上执行lv_examples 0,测试:
[size=15.008px][color=var(--tertiary)]
|