專欄總目錄
【資料圖】
本文介紹RK3588平臺(tái)的Camera:MIPI-CSI調(diào)試之通路解析
MIPI聯(lián)盟,即移動(dòng)產(chǎn)業(yè)處理器接口(Mobile Industry Processor Interface 簡(jiǎn)稱MIPI)聯(lián)盟。MIPI(移動(dòng)產(chǎn)業(yè)處理器接口)是MIPI聯(lián)盟發(fā)起的為移動(dòng)應(yīng)用處理器制定的開放標(biāo)準(zhǔn)和一個(gè)規(guī)范。
目的是把手機(jī)內(nèi)部的接口如攝像頭、顯示屏接口、射頻/基帶接口等標(biāo)準(zhǔn)化,從而減少手機(jī)設(shè)計(jì)的復(fù)雜程度和增加設(shè)計(jì)靈活性。
CSI & DSI
? CSI ( Camera Serial Interface ):攝像頭接口
? DSI ( Display Serial Interface ):顯示接口
下圖是RK3588 camera連接鏈路示意圖,可以支持7路camera。
圖中:mipi camera2---> csi2_dphy1 ---> mipi2_csi2 ---> rkcif_mipi_lvds2--->rkcif_mipi_lvds2_sditf --->rkisp0_vir2
對(duì)應(yīng)節(jié)點(diǎn):imx415 ---> csi2_dphy0 ---> mipi2_csi2 ---> rkcif_mipi_lvds2--->rkcif_mipi_lvds2_sditf --->rkisp0_vir2
鏈接關(guān)系:sensor---> csi2 dphy---->mipi csi host--->vicap
實(shí)線鏈路解析: Camera sensor ---> dphy ---> 通過(guò)mipi_csi2模塊解析mipi協(xié)議---> vicap ( rkcif節(jié)點(diǎn)代表vicap )
虛線鏈路解析:vicap ---> rkcif_mipi_lvds2_sditf ---> isp
每個(gè)vicap節(jié)點(diǎn)與isp的鏈接關(guān)系,通過(guò)對(duì)應(yīng)虛擬出的XXX_sditf來(lái)指明鏈接關(guān)系。
當(dāng)使用dphy0_hw:
full mode:節(jié)點(diǎn)名稱使用csi2_dphy0,最多支持4 lane。當(dāng)dphy0_hw使用full mode時(shí),鏈路需要按照csi2_dphy1這條鏈路來(lái)配置,但是節(jié)點(diǎn)名稱csi2_dphy1需要修改為csi2_dphy0,軟件上是通過(guò)phy的序號(hào)來(lái)區(qū)分phy使用的模式。split mode:拆分成2個(gè)phy使用,分別為csi2_dphy1(使用0/1 lane)、csi2_dphy2(使用2/3 lane),每個(gè)phy最多支持2 lane。當(dāng)使用dphy1_hw:
full mode:節(jié)點(diǎn)名稱使用csi2_dphy3,最多支持4 lane。當(dāng)dphy1_hw使用full mode時(shí),鏈路需要按照csi2_dphy4這條鏈路來(lái)配置,但是節(jié)點(diǎn)名稱csi2_dphy4需要修改為csi2_dphy3,軟件上是通過(guò)phy的序號(hào)來(lái)區(qū)分phy使用的模式。split mode:拆分成2個(gè)phy使用,分別為csi2_dphy4(使用0/1 lane)、csi2_dphy5(使用2/3 lane),每個(gè)phy最多支持2 lane。dcphy:rk3588支持兩個(gè)dcphy,節(jié)點(diǎn)名稱分別為csi2_dcphy0/csi2_dcphy1。每個(gè)dcphy硬件支持RX/TX同時(shí)使用,對(duì)于camera輸入使用的是RX。支持DPHY/CPHY協(xié)議復(fù)用;需要注意的是同一個(gè)dcphy的TX/RX只能同時(shí)使用DPHY或同時(shí)使用CPHY。其他dcphy參數(shù)請(qǐng)查閱rk3588數(shù)據(jù)手冊(cè)。
使用上述mipi phy節(jié)點(diǎn),需要把對(duì)應(yīng)的物理節(jié)點(diǎn)配置上。(csi2_dcphy0_hw/csi2_dcphy1_hw/csi2_dphy0_hw/csi2_dphy1_hw)
每個(gè)mipi phy都需要一個(gè)csi2模塊來(lái)解析mipi協(xié)議,節(jié)點(diǎn)名稱分別為mipi0_csi2~mipi5_csi2。
rk3588所有camera數(shù)據(jù)都需要通過(guò)vicap,再鏈接到isp。rk3588僅支持一個(gè)vicap硬件,這個(gè)vicap支持同時(shí)輸入6路mipi phy,及一路dvp數(shù)據(jù),所以我們將vicap分化成rkcif_mipi_lvds~rkcif_mipi_lvds5、rkcif_dvp等7個(gè)節(jié)點(diǎn),各個(gè)節(jié)點(diǎn)的綁定關(guān)系需要嚴(yán)格按照框圖的節(jié)點(diǎn)序號(hào)配置。
每個(gè)vicap節(jié)點(diǎn)與isp的鏈接關(guān)系,通過(guò)對(duì)應(yīng)虛擬出的XXX_sditf來(lái)指明鏈接關(guān)系。
rk3588支持2個(gè)isp硬件,每個(gè)isp設(shè)備可虛擬出多個(gè)虛擬節(jié)點(diǎn),軟件上通過(guò)回讀的方式,依次從ddr讀取每一路的圖像數(shù)據(jù)進(jìn)isp處理。對(duì)于多攝方案,建議將數(shù)據(jù)流平均分配到兩個(gè)isp上。
直通與回讀模式:?直通:指數(shù)據(jù)經(jīng)過(guò)vicap采集,直接發(fā)送給isp處理,不存儲(chǔ)到ddr。需要注意的是hdr直通時(shí),只有短幀是真正的直通,長(zhǎng)幀需要存在ddr,isp再?gòu)膁dr讀取。
?回讀:指數(shù)據(jù)經(jīng)過(guò)vicap采集到ddr,應(yīng)用獲取到數(shù)據(jù)后,將buffer地址推送給isp,isp再?gòu)膁dr獲取圖像數(shù)據(jù)。
?在dts配置時(shí),一個(gè)isp硬件,如果只配置一個(gè)虛擬節(jié)點(diǎn),默認(rèn)使用直通模式,如果配置了多個(gè)虛擬節(jié)點(diǎn)默認(rèn)使用回讀模式。
&i2c3 {status = "okay";imx415: imx415@1a {status = "okay";compatible = "sony,imx415";reg = < 0x1a >;clocks = < &cru CLK_MIPI_CAMARAOUT_M3 >;clock-names = "xvclk";pinctrl-names = "default";pinctrl-0 = < &mipim0_camera3_clk >;power-domains = < &power RK3588_PD_VI >;pwdn-gpios = < &gpio1 RK_PB0 GPIO_ACTIVE_HIGH >;reset-gpios = < &gpio4 RK_PA0 GPIO_ACTIVE_LOW >;rockchip,camera-module-index = < 0 >;rockchip,camera-module-facing = "back";rockchip,camera-module-name = "CMK-OT2022-PX1";rockchip,camera-module-lens-name = "IR0147-50IRC-8M-F20";port {imx415_out0: endpoint {remote-endpoint = < &mipidphy0_in_ucam0 >;data-lanes = < 1 2 3 4 >;};};};camera_imx219: camera-imx219@10 {status = "disabled";compatible = "sony,imx219";reg = < 0x10 >;clocks = < &clk_cam_24m >;clock-names = "xvclk";rockchip,camera-module-index = < 0 >;rockchip,camera-module-facing = "back";rockchip,camera-module-name = "rpi-camera-v2";rockchip,camera-module-lens-name = "default";port {imx219_out0: endpoint {remote-endpoint = < &mipidphy0_in_ucam1 >;data-lanes = < 1 2 >;};};};};&csi2_dphy0_hw {status = "okay";};&csi2_dphy0 {status = "okay";ports {#address-cells = < 1 >;#size-cells = < 0 >;port@0 {reg = < 0 >;#address-cells = < 1 >;#size-cells = < 0 >;mipidphy0_in_ucam0: endpoint@1 {reg = < 1 >;remote-endpoint = < &imx415_out0 >;data-lanes = < 1 2 3 4 >;};mipidphy0_in_ucam1: endpoint@2 {reg = < 2 >;remote-endpoint = < &imx219_out0 >;data-lanes = < 1 2 >;};};port@1 {reg = < 1 >;#address-cells = < 1 >;#size-cells = < 0 >;csidphy0_out: endpoint@0 {reg = < 0 >;remote-endpoint = < &mipi2_csi2_input >;};};};};&mipi2_csi2 {status = "okay";ports {#address-cells = < 1 >;#size-cells = < 0 >;port@0 {reg = < 0 >;#address-cells = < 1 >;#size-cells = < 0 >;mipi2_csi2_input: endpoint@1 {reg = < 1 >;remote-endpoint = < &csidphy0_out >;};};port@1 {reg = < 1 >;#address-cells = < 1 >;#size-cells = < 0 >;mipi2_csi2_output: endpoint@0 {reg = < 0 >;remote-endpoint = < &cif_mipi2_in0 >;};};};};&rkcif {status = "okay";};&rkcif_mipi_lvds2 {status = "okay";port {cif_mipi2_in0: endpoint {remote-endpoint = < &mipi2_csi2_output >;};};};&rkcif_mipi_lvds2_sditf {status = "okay";port {mipi_lvds2_sditf: endpoint {remote-endpoint = < &isp0_vir0 >;};};};&rkcif_mmu {status = "okay";};&rkisp0 {status = "okay";};&isp0_mmu {status = "okay";};&rkisp0_vir0 {status = "okay";port {#address-cells = < 1 >;#size-cells = < 0 >;isp0_vir0: endpoint@0 {reg = < 0 >;remote-endpoint = < &mipi_lvds2_sditf >;};};};&pinctrl {camera {cam_pwdn_gpio: cam-pwdn-gpio {rockchip,pins = < 1 RK_PB0 RK_FUNC_GPIO &pcfg_pull_up >;};};};
i2cdetect -y 3
gst-launch-1.0 v4l2src device=/dev/video11 ! video/x-raw,format=NV12,width=3840,height=2160, framerate=30/1 ! xvimagesink
Android系統(tǒng):
Android系統(tǒng)自帶相機(jī)APP。點(diǎn)擊APP,看攝像畫面是否正常顯示。
dmesg | grep imx415
media-ctl -d /dev/media0 -p
審核編輯:湯梓紅
標(biāo)簽: