0.前言
? 由于之前我們已經(jīng)適配過RGB屏,如果我們?nèi)ミm配了4寸MIPI屏,那么RGB屏就不能使用了。對于4寸屏購買鏈接為:
LCD_調(diào)試指南:https://tina.100ask.net/SdkModule/Linux_LCD_DevelopmentGuide-01/
Display_開發(fā)指南:https://tina.100ask.net/SdkModule/Linux_Display_DevelopmentGuide-01/
4寸屏適配資源包:https://forums.100ask.net/uploads/short-url/g7BQ0FPSSnKHSptR2QMjIPwnwno.zip。該資源包里面包含了適配修改后的所有文件(包括驅(qū)動程序、設(shè)備樹和配置文件等)
1.添加新驅(qū)動
將驅(qū)動程序添加到
內(nèi)核的lcd驅(qū)動目錄下:
tina-v853-open/kernel/linux-4.9/drivers/video/fbdev/sunxi/disp2/disp/lcd
uboot的lcd驅(qū)動目錄下:
tina-v853-open/brandy/brandy-2.0/u-boot-2018/drivers/video/sunxi/disp2/disp/lcd/
由于uboot和內(nèi)核中的屏驅(qū)動會存在一些差別,下面分別展示出uboot和內(nèi)核中不同的屏驅(qū)動。具體源文件可以在4寸屏適配資源包中查看。
1.1 uboot驅(qū)動程序
驅(qū)動程序頭文件tft08006.h
#ifndef _TFT08006_H
#define _TFT08006_H
#include "panels.h"
extern __lcd_panel_t tft08006_panel;
extern s32 bsp_disp_get_panel_info(u32 screen_id, disp_panel_para *info);
#endif /*End of file*/
驅(qū)動程序的C文件tft08006.c
這里只展示與內(nèi)核不同的部分
__lcd_panel_t tft08006_panel = {
/* panel driver name, must mach the name of
* lcd_drv_name in sys_config.fex
*/
.name = "tft08006",
.func = {
.cfg_panel_info = lcd_cfg_panel_info,
.cfg_open_flow = lcd_open_flow,
.cfg_close_flow = lcd_close_flow,
.lcd_user_defined_func = lcd_user_defined_func,
},
};
1.2 內(nèi)核驅(qū)動程序
驅(qū)動程序頭文件tft08006.h
#ifndef _TFT08006_H
#define _TFT08006_H
#include "panels.h"
extern struct __lcd_panel tft08006_panel;
extern s32 bsp_disp_get_panel_info(u32 screen_id, struct disp_panel_para *info);
#endif /*End of file*/
驅(qū)動程序的C文件"tft08006.c,這里只展示與uboot不同的部分。
struct __lcd_panel tft08006_panel = {
/* panel driver name, must mach the name of
* lcd_drv_name in sys_config.fex
*/
.name = "tft08006",
.func = {
.cfg_panel_info = lcd_cfg_panel_info,
.cfg_open_flow = lcd_open_flow,
.cfg_close_flow = lcd_close_flow,
.lcd_user_defined_func = lcd_user_defined_func,
},
};
2.修改內(nèi)核中panels.h和panels.c
由于內(nèi)核中沒有對tft08006屏驅(qū)動有相關(guān)的配置,所以我們還需要在panels全志顯示驅(qū)動中增加定義。
2.1 修改內(nèi)核中panels.h
在屏驅(qū)動目錄下修改panels.h
book@100ask:~/workspaces/tina-v853-open/kernel/linux-4.9/drivers/video/fbdev/sunxi/disp2/disp/lcd$ vi panels.h
在icn6202屏驅(qū)動定義的后面增加tft08006屏驅(qū)動定義
#ifdef CONFIG_LCD_SUPPORT_ICN6202
extern struct __lcd_panel icn6202_panel;
#endif
#ifdef CONFIG_LCD_SUPPORT_ICN6202
extern struct __lcd_panel icn6202_panel;
#endif
#ifdef CONFIG_LCD_SUPPORT_NT35510_MIPI
extern struct __lcd_panel nt35510_panel;
#endif
按下ESC,輸入:wq
,保存剛才的修改并退出
2.2 修改內(nèi)核中panels.c
在屏驅(qū)動目錄下修改panels.c
book@100ask:~/workspaces/tina-v853-open/kernel/linux-4.9/drivers/video/fbdev/sunxi/disp2/disp/lcd$ vi panels.c
在icn6202屏驅(qū)動定義的后面增加tft08006屏驅(qū)動定義
#ifdef CONFIG_LCD_SUPPORT_ICN6202
&icn6202_panel,
#endif
#ifdef CONFIG_LCD_SUPPORT_TFT08006
&tft08006_panel,
#endif
#ifdef CONFIG_LCD_SUPPORT_NT35510_MIPI
&nt35510_panel,
#endif
按下ESC,輸入:wq
,保存剛才的修改并退出
3.修改內(nèi)核中Kconfig和Makefile
3.1 修改內(nèi)核中的Kconfig
修改屏驅(qū)動目錄下的Kconfig,使內(nèi)核配置中增加tft08006屏驅(qū)動的,以便后續(xù)選擇編譯該屏驅(qū)動
在屏驅(qū)動目錄下輸入vi Kconfig
tina-v853-open/kernel/linux-4.9/drivers/video/fbdev/sunxi/disp2/disp/lcd$ vi Kconfig
在icn6202屏驅(qū)動配置的后面增加tft08006屏驅(qū)動配置
config LCD_SUPPORT_ICN6202
bool "LCD support icn6202 panel"
default n
---help---
If you want to support icn6202 panel for display driver, select it.
config LCD_SUPPORT_TFT08006
bool "LCD support tft08006 panel"
default n
---help---
If you want to support tft08006 panel for display driver, select it.
config LCD_SUPPORT_NT35510_MIPI
bool "LCD support nt35510_mipi panel"
default n
help
If you want to support nt35510_mipi panel for display driver, select it.
按下ESC,輸入:wq
,保存剛才的修改并退出
3.2 修改內(nèi)核中的Makefile
返回屏驅(qū)動的上一級目錄,修改Makefile文件
book@100ask:~/workspaces/tina-v853-open/kernel/linux-4.9/drivers/video/fbdev/sunxi/disp2/disp$ vi Makefile
在icn6202屏驅(qū)動編譯規(guī)則的后面增加tft08006屏驅(qū)動編譯規(guī)則
disp-$(CONFIG_LCD_SUPPORT_ICN6202) += lcd/icn6202.o
disp-$(CONFIG_LCD_SUPPORT_TFT08006) += lcd/tft08006.o
disp-$(CONFIG_LCD_SUPPORT_NT35510_MIPI) += lcd/nt35510.o
按下ESC,輸入:wq
,保存剛才的修改并退出
4.修改內(nèi)核配置
在Tina的根目錄下輸入make kernel_menuconfig
,進(jìn)入內(nèi)核配置界面。
book@100ask:~/workspaces/tina-v853-open$ make kernel_menuconfig
在選中屏驅(qū)動前,要確保DISP Driver Support(sunxi-disp2)
,我們的提供的SDK默認(rèn)已經(jīng)打開了,如果您之前關(guān)閉了,需要在內(nèi)核配置界面中,進(jìn)入Video support for sunxi
目錄下輸入Y選中sunxi-disp2
打開lcd節(jié)點(diǎn)配置。
→ Device Drivers
→ Graphics support
→ Frame buffer Devices
→ Video support for sunxi
<*> DISP Driver Support(sunxi-disp2)
進(jìn)入屏驅(qū)動目錄,輸入Y選中tft08006
→ Device Drivers
→ Graphics support
→ Frame buffer Devices
→ Video support for sunxi
→ LCD panels select
[*] LCD support tft08006 panel
如下圖所示,選中tft08006屏驅(qū)動,編譯到內(nèi)核中。
保存并推車內(nèi)核配置界面。
5.修改uboot配置
進(jìn)入uboot的根目錄下,執(zhí)行make menuconfig
,打開uboot配置界面。
book@100ask:~/workspaces/tina-v853-open/brandy/brandy-2.0/u-boot-2018$ make menuconfig
在選中屏驅(qū)動前,要確保DISP Driver Support(sunxi-disp2)
,我們的提供的SDK默認(rèn)已經(jīng)打開了,如果您之前關(guān)閉了,需要在內(nèi)核配置界面中,進(jìn)入Graphics support
目錄下輸入Y選中sunxi-disp2
打開lcd節(jié)點(diǎn)配置。
→ Device Drivers
→ Graphics support
[*] DISP Driver Support(sunxi-disp2) --->
進(jìn)入屏驅(qū)動目錄下,輸入Y選中TFT08006屏驅(qū)動。
→ Device Drivers
→ Graphics support
→ LCD panels select
[*] LCD support TFT08006 panel
如下圖所示,選中tft08006屏驅(qū)動。
保存并退出uboot配置界面
6.修改設(shè)備樹
設(shè)備樹位置:tina-v853-open/device/config/chips/v853/configs/100ask/
book@100ask:~/workspaces/tina-v853-open/device/config/chips/v853/configs/100ask$ ls
BoardConfig.mk board.dts buildroot env.cfg linux-4.9 sys_config.fex uboot-board.dts
其中board.dts為內(nèi)核設(shè)備樹,uboot-board.dts為uboot設(shè)備樹。
6.1 修改uboot設(shè)備樹
在設(shè)備樹的目錄下輸入vi uboot-board.dts
,編譯uboot設(shè)備樹。
book@100ask:~/workspaces/tina-v853-open/device/config/chips/v853/configs/100ask$ vi uboot-board.dts
注釋掉原來的lcd0節(jié)點(diǎn),修改tft08006屏lcd0節(jié)點(diǎn)
&lcd0 {
base_config_start = <1>;
lcd_used = <1>;
lcd_driver_name = "tft08006";
lcd_backlight = <500>;
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 = <9>;
lcd_pwm_freq = <50000>;
lcd_pwm_pol = <1>;
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_dsi_format = <0>;
lcd_dsi_te = <0>;
lcd_dsi_eotp = <0>;
lcd_frm = <0>;
lcd_io_phase = <0x0000>;
lcd_hv_clk_phase = <0>;
lcd_hv_sync_polarity= <0>;
lcd_gamma_en = <0>;
lcd_bright_curve_en = <0>;
lcd_cmap_en = <0>;
lcdgamma4iep = <22>;
lcd_gpio_0 = <&pio PH 0 1 0 3 1>;
pinctrl-0 = <&dsi4lane_pins_a>;
pinctrl-1 = <&dsi4lane_pins_b>;
base_config_end = <1>;
};
在&pio節(jié)點(diǎn)后增加復(fù)用引腳
dsi4lane_pins_a: dsi4lane@0 {
allwinner,pins = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD9", "PD10", "PD11";
allwinner,pname = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD9", "PD10", "PD11";
allwinner,function = "dsi";
allwinner,muxsel = <5>;
allwinner,drive = <3>;
allwinner,pull = <0>;
};
dsi4lane_pins_b: dsi4lane@1 {
allwinner,pins = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD9", "PD10", "PD11";
allwinner,pname = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD9", "PD10", "DP11";
allwinner,function = "io_disabled";
allwinner,muxsel = <0xf>;
allwinner,drive = <1>;
allwinner,pull = <0>;
};
6.2 修改內(nèi)核設(shè)備樹
在設(shè)備樹的目錄下輸入vi board.dts
,編譯內(nèi)核設(shè)備樹。
book@100ask:~/workspaces/tina-v853-open/device/config/chips/v853/configs/100ask$ vi board.dts
注釋掉原來的lcd0節(jié)點(diǎn),修改tft08006屏lcd0節(jié)點(diǎn)
&lcd0 {
base_config_start = <1>;
lcd_used = <1>;
lcd_driver_name = "tft08006";
lcd_backlight = <500>;
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 = <9>;
lcd_pwm_freq = <50000>;
lcd_pwm_pol = <1>;
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_dsi_format = <0>;
lcd_dsi_te = <0>;
lcd_dsi_eotp = <0>;
lcd_frm = <0>;
lcd_io_phase = <0x0000>;
lcd_hv_clk_phase = <0>;
lcd_hv_sync_polarity= <0>;
lcd_gamma_en = <0>;
lcd_bright_curve_en = <0>;
lcd_cmap_en = <0>;
lcdgamma4iep = <22>;
lcd_gpio_0 = <&pio PH 0 1 0 3 1>;
pinctrl-0 = <&dsi4lane_pins_a>;
pinctrl-1 = <&dsi4lane_pins_b>;
base_config_end = <1>;
};
在&pio節(jié)點(diǎn)后增加復(fù)用引腳
dsi4lane_pins_a: dsi4lane@0 {
allwinner,pins = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD9", "PD10", "PD11";
allwinner,pname = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD9", "PD10", "PD11";
allwinner,function = "dsi";
allwinner,muxsel = <5>;
allwinner,drive = <3>;
allwinner,pull = <0>;
};
dsi4lane_pins_b: dsi4lane@1 {
allwinner,pins = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD9", "PD10", "PD11";
allwinner,pname = "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD9", "PD10", "DP11";
allwinner,function = "io_disabled";
allwinner,muxsel = <0xf>;
allwinner,drive = <1>;
allwinner,pull = <0>;
};
7.增加I2C觸摸
通過拿到的屏幕資料包,我們可以知道該MIPI屏的觸摸芯片為FT5336,下面我們使用全志已經(jīng)內(nèi)置好的FT6336觸摸驅(qū)動。
7.1 修改設(shè)備樹
修改twi2節(jié)點(diǎn),使用ft6336驅(qū)動,修改觸摸的范圍。寬X為480,高y為800。其中初始化引腳需要查看V853底板原理圖,其中初始化引腳為PH7,喚醒引腳為PH8。
&twi2 {
ctp@38 {
status = "okay";
ctp_used = <1>;
ctp_name = "ft6336";
ctp_twi_id = <0x2>;
ctp_twi_addr = <0x38>;
ctp_screen_max_x = <0x480>;
ctp_screen_max_y = <0x800>;
ctp_revert_x_flag = <0x0>;
ctp_revert_y_flag = <0x1>;
ctp_exchange_x_y_flag = <0x0>;
ctp_int_port = <&pio PH 7 6 1 3 0xffffffff>;
ctp_wakeup = <&pio PH 8 1 1 3 0xffffffff>;
};
};
對于設(shè)備樹的參數(shù)意義,可以訪問百問網(wǎng)的Tina站點(diǎn):https://tina.100ask.net/SdkModule/Linux_Deploy_DevelopmentGuide-02/#39
7.2 修改內(nèi)核配置
? 由于我們之前適配過了RGB屏觸摸驅(qū)動,所以需要進(jìn)入內(nèi)核中修改為我們使用的新驅(qū)動,進(jìn)入如下目錄中,按下空格鍵取消勾選之前的觸摸驅(qū)動gt9xxnew touchscreen driver,輸入Y選中我們使用的ft6336 touchscreen driver新驅(qū)動,并保存退出。
→ Device Drivers
→ Input device support
→ Touchscreens
<*> ft6336 touchscreen driver
7.3 修改驅(qū)動程序
修改ft6336.c觸摸驅(qū)動程序,這里只展示修改的部分,源文件可見4寸屏適配資源包中查看。
input_report_abs(ts->input_dev,
ABS_MT_POSITION_X, -(event->au16_x[i]-480));
input_report_abs(ts->input_dev,
ABS_MT_POSITION_Y, -(event->au16_y[i]-800));
7.4 LVGL綁定新觸摸節(jié)點(diǎn)
由于Tina使用的默認(rèn)綁定的觸摸節(jié)點(diǎn)為/dev/input/event0,我們需要修改lvgl驅(qū)動頭文件中綁定的節(jié)點(diǎn)為我們觸摸驅(qū)動上報數(shù)據(jù)的節(jié)點(diǎn),我們觸摸驅(qū)動上報的節(jié)點(diǎn)為event2,所以需要進(jìn)入
tina-v853-open/platform/thirdparty/gui/lvgl-8/lv_examples/src
目錄下修改lv_drv_conf.h頭文件,如下所示
book@100ask:~/workspaces/tina-v853-open$ cd platform/thirdparty/gui/lvgl-8/lv_examples/src/
book@100ask:~/workspaces/tina-v853-open/platform/thirdparty/gui/lvgl-8/lv_examples/src$ vi lv_drv_conf.h
找到觸摸節(jié)點(diǎn)中的LIBINPUT_NAME
,將原來的/dev/input/event0
修改/dev/input/event2
,如下圖紅框內(nèi)所示。
注意:我們這里修改的是頭文件,可能之前編譯生成過了之后再重新編譯時可能不會再編譯頭文件,導(dǎo)致修改的節(jié)點(diǎn)不會生效,可以手動刪除out目錄中的lv_examples
示例程序或者直接刪除out目錄重新編譯即可。具體原因可以觀看韋東山老師的《ARM架構(gòu)與編程》課程中的gcc編譯過程詳解。訪問鏈接為:ARM架構(gòu)與編程
8.編譯系統(tǒng)并打包生成鏡像
返回Tina根目錄下,輸入make
,編譯系統(tǒng)
book@100ask:~/workspaces/tina-v853-open$ make -j4
...
sun8iw21p1 compile Kernel successful
INFO: ----------------------------------------
INFO: build Tina OK.
INFO: ----------------------------------------
打包生成鏡像,輸入pack
book@100ask:~/workspaces/tina-v853-open$ pack
...
Dragon execute image.cfg SUCCESS !
----------image is at----------
33M /home/book/workspaces/tina-v853-open/out/v853/100ask/openwrt/v853_linux_100ask_uart0.img
pack finish
9.燒錄并測試
? 打包完成后,將新生成的鏡像拷貝到Windows主機(jī)電腦上,使用全志PhoenixSuit燒寫工具,燒寫到開發(fā)板上。具體可以參考:https://forums.100ask.net/t/topic/2882。燒寫完成后需要斷電,才能連接MIPI屏的排線到MIPI屏接口,注意排線的線序是否一致。
? 接完排線后,重新接入電源,和2條Type-C數(shù)據(jù)線,再將開關(guān)撥向電源接口處上電啟動,啟動時會出現(xiàn)Tina Linux小企鵝logo,進(jìn)入系統(tǒng)后,可以查看觸摸節(jié)點(diǎn)
root@TinaLinux:/# ls /dev/input/
event0 event1 event2
? 我們使用的event2,如果你不確定您的觸摸驅(qū)動程序使用的是哪個,可以通過cat /dev/input/event*
,其中*
表示要查看的是哪一個觸摸節(jié)點(diǎn),例如我使用的是event2,則需要輸入cat /dev/input/event2
,此時觸摸屏幕會有上報信息。
? 使用LVGL DEMO示例,輸入lv_examples 0
啟動lvgl示例,可以通過點(diǎn)擊屏幕上的UI交互按鈕測試觸摸是否生效。
root@TinaLinux:/# lv_examples 0
wh=480x800, vwh=480x1600, bpp=32, rotated=0
Turn on double buffering.
Turn on 2d hardware acceleration.
Turn on 2d hardware acceleration rotate.
-
嵌入式
+關(guān)注
關(guān)注
5060文章
18978瀏覽量
302225 -
Linux
+關(guān)注
關(guān)注
87文章
11213瀏覽量
208736 -
開發(fā)板
+關(guān)注
關(guān)注
25文章
4909瀏覽量
97080 -
MIPI
+關(guān)注
關(guān)注
11文章
304瀏覽量
48526 -
RGB屏
+關(guān)注
關(guān)注
0文章
9瀏覽量
1156
發(fā)布評論請先 登錄
相關(guān)推薦
評論