天天看點

高通DragonBoard 410c MIPI-DIS顯示功能及驅動移植

為了滿足部分IOT應用對顯示的需求,高通DragonBoard 410c IOT平台提供了一個具有四路MIPI-DSI接口的高速擴充口用于提供顯示支援,在DragonBoard 410c開發闆設計中,通過一個DSI選擇器與DSI-HDMI橋進行連接配接,該選擇器搭載在410c上,如圖1所示。

高通DragonBoard 410c MIPI-DIS顯示功能及驅動移植
高通DragonBoard 410c MIPI-DIS顯示功能及驅動移植

圖1 MIPI DSI 0口連接配接示意圖 在實際的工作過程中410c隻能驅動 HDMI和MIPI-DSI接口中的一個用于顯示,在具體的實作中,該控制信号是通過一個DSI_SW_SEL_APQ信号來進行控制的,如果該信号設定為0的時候,系統将使能410c的MIPI-DSI接口,同時将DSI選擇器接入到DSI-HDMI橋上,進行HDMI轉換輸出,否則,MIPI-DSI接口将被連接配接到高速擴充口上,在410c引硬體設計中為了友善使用者選擇通過一個撥碼開關來對該功能進行控制,如圖2所示,隻要将S6中的開關對應的标有HDMI SET字樣的資訊的位撥到“ON”端就能夠實作對軟體控制的覆寫,強迫410c的DSI選擇器選擇DSI-HDMI上,實作HDMI輸出,而撥到OFF端,起可以解除強制覆寫,可以接受軟體控制實作DSI選擇器連接配接選擇,這種設計方式給開發者非常靈活的選擇來定制自己的顯示功能需求。

高通DragonBoard 410c MIPI-DIS顯示功能及驅動移植
高通DragonBoard 410c MIPI-DIS顯示功能及驅動移植

圖2 硬體選擇HDIM顯示輸出設定示意圖 以上就是410c開發闆MIPI-DSI顯示的基本原理,在實際的開發和創作過程中,通常最為關鍵的是如何進行顯示驅動的移隻,讓自己設計的産品能夠正常穩定的顯示。接着本文将向大家介紹在410c開發闆上進行MIPI-DSI顯示驅動的移植工作通用方法及流程,包括如何下載下傳驅動、利用DTSI和面闆檔案确定XML參數以及移植驅動程式的整個流程。 一、相關準備工作 本文在移植的過程中使用的參考顯示面闆驅動更新檔及相關資訊庫可以通過以下連結進行下載下傳: https://www.codeaurora.org/cgit/external/thundersoft/ihvjointlab/gcdb-kernel/tree/display/ ——核心空間支援 同時還可以在下面的連結下載下傳相關的核心驅動代碼patch和資料檔案: https://www.codeaurora.org/cgit/external/thundersoft/ihvjointlab/gcdb-user-space/tree/display/——使用者空間支援 完成下載下傳後執行以下指令通過打patch方式将驅動資訊加入到對應的驅動代碼中: cd $ANDROID_BUILD_TOP/kernel patch -p1 < 0001-ARM-dts-msm-support-truly-hx8379_a-devicetree.patch cd $ANDROID_BUILD_TOP/ bootable/bootloader/lk patch -p1 < 0001-bootloader-lk-add-lcd-truly-hx8379_a.patch 上面的這兩種方式是參考的方式,具體執行可能應為代碼環境問題,可能會出現patch沖突,這時候使用者可以手動patch或者強制patch然後手動解決相關的沖突。 完成上述工作後還需要擷取參考面闆一些關鍵資訊如下: a)顯示規格參數 b)GPIO引腳信号持續時間資訊如RESET/LOVDD等; c)DSI的指令序列和持續的時間資訊; d)目标幀相關資訊; 二、制作核心LK和DTSI檔案 1)添加面闆的核心LK a)複制參考面闆驅動DTSI檔案到kernel/arch/arm64/boot/dts/qcom目錄下; b)複制面闆驅動頭檔案到bootable/bootloader/lk/dev/gcdb/display/include/目錄下; c)在android核心中添加面闆; d)禁用LK display和continuous splash display 首先通過在bootable/bootloader/lk/target/msm8916/rules.mk檔案中設定DISPLAY_SPLASH_SCREEN為0,禁用continuous splash display,然後繼續添加LK,參考如下方式在bootable/bootloader/lk/target/msm8916/init.c中修改和更新target_cont_splash_screen函數: static uint8_t splash_override; int target_cont_splash_screen() { uint8_t splash_screen = 0; if(!splash_override) { switch(board_hardware_id()) { case HW_PLATFORM_MTP: case HW_PLATFORM_QRD: dprintf(SPEW, "Target_cont_splash=1\n"); splash_screen = 1; // Change to “0” to disable continous splash screen break; default: dprintf(SPEW, "Target_cont_splash=0\n"); splash_screen = 0; } } return splash_screen; } 最後通過在msm8xxx-cdp.dts檔案中設定禁用continuous splash screen,具體如下: &dsi_<vendor>_720p_video{ // qcom,cont-splash-enabled; // Disable continous splash screen }003B }; 2)在xml檔案中輸入LCD顯示面闆的參數 在LCD面闆廠商的xml檔案中更新相關的參數,具體需要更新的相關參數如下(紅色标注的部分): <!-- Panel configuration --> <PanelType> 0</PanelType> // 0 stands for video mode panel, 1 stands for command mode panel <PanelFrameRate> 60</PanelFrameRate> <!-- Panel Resolution --> <PanelWidth> 720</PanelWidth> <PanelHeight> 1280</PanelHeight> <HFrontPorch> 140</HFrontPorch> <HBackPorch> 164</HBackPorch> <HPulseWidth> 8</HPulseWidth> <HSyncSkew> 0</HSyncSkew> <VBackPorch> 4</VBackPorch> <VFrontPorch> 8</VFrontPorch> <VPulseWidth> 4</VPulseWidth> <!-- Panel Color Information --> <ColorFormat> 24</ColorFormat> // 24bpp <!-- Panel Command information --> <OnCommand>" 0x29, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFF, 0xEE,0x29, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFB, 0x01,....... 0x29, 0x01, 0x00, 0x00, 0x78, 0x00, 0x02, 0x29, 0x00" </OnCommand> // add your panel on commands from LCD vendor <OffCommand>" 0x05, 0x01, 0x00, 0x00, 0x32, 0x00, 0x02, 0x28, 0x00, … … … 0x05, 0x01, 0x00, 0x00, 0x78, 0x00, 0x02, 0x10, 0x00" </OffCommand> // add your panel off commands from LCD vendor <OnCommandState> 0</OnCommandState> // 0 stands for lp mode <OffCommandState> 1</OffCommandState> // 1 stands for hs mode

<!-- Video mode panel information --> <HSyncPulse> 1</HSyncPulse> <BLLPEOFPowerMode> 1</BLLPEOFPowerMode> <BLLPPowerMode>1</BLLPPowerMode> <TrafficMode>2</TrafficMode> <!-- Panel Reset Sequence --> <ResetSequence> <PinState1> 1</PinState1> <PulseWidth1> 20</PulseWidth1> <PinState2> 0</PinState2> <PulseWidth2> 2</PulseWidth2> <PinState3> 1</PinState3> <PulseWidth3> 20</PulseWidth3> </ResetSequence> 3)計算DSI PHY定時寄存器 在這裡可以利用高通提供的D-PHY自動計算表來完成計算,具體的計算表格到DragonBoard 410c高通官網資料庫中下載下傳dsi相關資料包DSI_Timing_Parameters.xls檔案中,打開該檔案,在DSI and MDP registers工作表中輸入面闆分辨率、FPS、色彩深度等參數資訊,如下圖3所示。

高通DragonBoard 410c MIPI-DIS顯示功能及驅動移植
高通DragonBoard 410c MIPI-DIS顯示功能及驅動移植

圖3 面闆參數設定 通過DSI PHY可以設定和計算相關的時鐘速率,如下圖4所示。

高通DragonBoard 410c MIPI-DIS顯示功能及驅動移植
高通DragonBoard 410c MIPI-DIS顯示功能及驅動移植

圖4 時鐘相關參數設定和計算 最後可以計算得到DSI PHY registers的值,如下圖5所示。

高通DragonBoard 410c MIPI-DIS顯示功能及驅動移植
高通DragonBoard 410c MIPI-DIS顯示功能及驅動移植

圖5 DSI PHY registers 計算結果 完成計算後,将這些參數值輸入到.xml檔案中,如下: <!-- Panel Timing --> <PanelTimings>" 0xDA, 0x34, 0x24, 0x00, 0x64, 0x68, 0x28, 0x38, 0x2A, 0x03, 0x04, 0x00"</PanelTimings> <TClkPost> 0x03</TClkPost> <TClkPre> 0x41</TClkPre> 三、輸入背光控制參數 在驅動中有三個參數可以用于控制LCD背光,具體如下: “bl_ctrl_pwm” = Backlight controlled by PWM GPIO “bl_ctrl_wled” = Backlight controlled by WLED “bl_ctrl_dcs” = Backlight control by DCS commands 其中采用WLED方式來控制背光源,那麼在xml檔案中輸入一下參數: <!-- Backlight --> <BLInterfaceType> 1</BLInterfaceType> <BLMinLevel> 1</BLMinLevel> <BLMaxLevel> 4095</BLMaxLevel> <BLStep> 100</BLStep> <BLPMICModel>" PMIC_8xxx"</BLPMICModel> <BLPMICControlType> 1</BLPMICControlType> // 1 stands for Backlight controlled by WLED. 其他兩種方式與具體的硬體配置和電路相關,為了簡化移植過程在本文不做讨論。 四、設定DSI顯示面闆相關的GPIO引腳 首先在device/qcom/common/display/tools/platform-8xxx.xml檔案中輸入相關的GPIO參數,如下: <PlatformId>" msm8xxx"</PlatformId> <!-- GPIO configuration --> < ResetGPIO> <PinSource>"msmgpio"</PinSource> <PinId> 25</PinId> <PinStrength> 3</PinStrength> <PinDirection> 1</PinDirection> <PinPull> 0</PinPull> <PinState> 1</PinState> </ResetGPIO> < EnableGPIO> <PinSource>"msmgpio"</PinSource> <PinId> 32</PinId> <PinStrength> 3</PinStrength> <PinDirection> 1</PinDirection> <PinPull> 0</PinPull> <PinState> 1</PinState> .... </EnableGPIO> 五、在DTS檔案中添加面闆裝置樹 在arch/arm/boot/dts/qcom/下修改msm8xxx-qrd.dts檔案增加顯示面闆驅動樹,具體可以參考以下例子: /include/ "dsi-panel-<vendor>-720p-video.dtsi" &mdss_mdp { qcom,mdss-pref-prim-intf = "dsi"; }; &mdss_pinmux { qcom,num-grp-pins = < 3>; qcom,pins = <&gp 32>, <&gp 25>, <&gp 97>; }; &mdss_dsi0 { qcom,dsi-pref-prim-pan = <& dsi_<vendor>_720p_video>; pinctrl-names = "default", "sleep"; pinctrl-0 = <&mdss_dsi_active>; pinctrl-1 = <&mdss_dsi_suspend>; 六、增加顯示面闆驅動頭檔案和在LK中檢測顯示面闆ID 在bootable/bootloader/lk/target/msm8xxx/oem_panel.c中增加顯示面闆頭檔案,如下: #include "include/panel_toshiba_720p_video.h" #include "include/panel_nt35590_720p_video.h" #include "include/panel_nt35590_720p_cmd.h" #include "include/panel_hx8394a_720p_video.h" +#include "include/panel_nt35521_720p_video.h" 在enum中增加<vendor>_<resolution>_VIDEO_PANEL 參數,如下: enum { TOSHIBA_720P_VIDEO_PANEL, NT35590_720P_CMD_PANEL, NT35590_720P_VIDEO_PANEL, HX8394A_720P_VIDEO_PANEL, +NT35521_720P_VIDEO_PANEL, UNKNOWN_PANEL }; 在panel_list_supp_panels結構體中增加<vendor>_<resolution>_VIDEO_PANEL參數: static struct panel_list supp_panels[] = { {"toshiba_720p_video", TOSHIBA_720P_VIDEO_PANEL}, {"nt35590_720p_cmd", NT35590_720P_CMD_PANEL}, {"nt35590_720p_video", NT35590_720P_VIDEO_PANEL}, {"hx8394a_720p_video", HX8394A_720P_VIDEO_PANEL}, +{"nt35521_720p_video", NT35521_720P_VIDEO_PANEL}, }; 在init_panel_data函數中增加<vendor>_<resolution>_VIDEO_PANEL參數: static void init_panel_data(struct panel_struct *panelstruct, struct msm_panel_info *pinfo, struct mdss_dsi_phy_ctrl *phy_db) { switch (panel_id) { +case NT35521_720P_VIDEO_PANEL: + panelstruct->paneldata = &nt35521_720p_video_panel_data; + panelstruct->panelres = &nt35521_720p_video_panel_res; + panelstruct->color = &nt35521_720p_video_color; + panelstruct->videopanel = &nt35521_720p_video_video_panel; + panelstruct->commandpanel = &nt35521_720p_video_command_panel; + panelstruct->state = &nt35521_720p_video_state; + panelstruct->laneconfig = &nt35521_720p_video_lane_config; + panelstruct->paneltiminginfo = &nt35521_720p_video_timing_info; + panelstruct->panelresetseq = &nt35521_720p_video_panel_reset_seq; + panelstruct->backlightinfo = &nt35521_720p_video_backlight; + pinfo->mipi.panel_cmds = nt35521_720p_video_on_command; + pinfo->mipi.num_of_panel_cmds = NT35521_720P_VIDEO_ON_COMMAND; + memcpy(phy_db->timing, nt35521_720p_video_timings, TIMING_SIZE); break; 在oem_panel_select函數中選擇面闆ID: enum target_subtype { HW_PLATFORM_SUBTYPE_SKUAA = 0, HW_PLATFORM_SUBTYPE_SKUF = 1, HW_PLATFORM_SUBTYPE_SKUAB = 2, HW_PLATFORM_SUBTYPE_SKUG = 3, +HW_PLATFORM_SUBTYPE_720P = 5, }; switch (hw_id) { case HW_PLATFORM_MTP: case HW_PLATFORM_QRD: if (hw_subtype == HW_PLATFORM_SUBTYPE_720P) + panel_id = NT35521_720P_VIDEO_PANEL; else panel_id = nt35590_panel_id; break; default: dprintf(CRITICAL, "Display not enabled for %d HW type\n" , hw_id); return false;

七、編譯下載下傳images,并通過adb調試 a) 重新整理410c裝置emmc_appsboot.mbn和boot.img檔案,具體重新整理方法可以參考連結: b) 重新開機410c,确認面闆是否點亮,如果沒有,依次檢查初始化指令、複位序列,同僚測量DSI時鐘通道和資料通道的序号進行調試。 c)如果沒有DSI時鐘輸出,那麼通過如下adb指令檢視其相關的時鐘信号,進一步确定問題所在。 》adb root 》adb remount 》 adb shell 》#mount –t debugfs none /sys/kernel/debug 》 #cd /sys/kernel/debug/clk/dsi1_byte_clk 》 #cat measure 以上就是410c平台MIPI-DIS顯示驅動的整個移植過程,按照上述流程,大家可以友善的完成各種面闆驅動的移植,完成基于410c平台顯示面闆的定制。