RK3568/RK3566 mipi双摄调试(gc2093+gc2053)

这篇文章给大家介绍一下RK3568双摄的调试,RK3568有一个4lane的mipi dphy,最高支持2.5G/bps每lane,ISP自带csi host,最高处理8M的图像,rk3568这个mipi dphy还有一个处理方法,就是拆分成2个2lane的使用,其中一个连接到单独的csi host,另一个连接到isp内部自带的csi host,这样就可以支持双摄同时的应用场景,下面介绍一下双摄的调试。

目录

(1)RK3568 camera资源介绍

①RK3568 MIPI CSI

②VICAP

③ISP

(2)RK3568双摄调试

①双摄硬件连接

②dts配置

③抓数据流确认

④HAL层适配

⑤接vicap的sensor的MIPI信号异常导致画面异常复位机制

(3)总结


(1)RK3568 camera资源介绍

①RK3568 MIPI CSI

RK356x有一个DPHY,其中有两个clk lane,可做4lane使用,也可以做2x2lane使用。

type Max bandwidth NUM Mode
DPHY DPHY v1.2 2.5Gbps x 4 lanes 1 4lane or 2lane+2lane

②VICAP

VICAP控制器可以接CSI HOST的输入,输入分辨率一般没有限制,主要是ddr带宽的限制。

接口 数量 输入 输出
VICAP 1

BT601 YCbCr 422 8bit, RAW 8/10/12

BT656 YCbCr 422 8bit 逐行/隔行

BT1120 YCbCr 422 16bit 逐行/隔行,单/双边沿采样

2/4 通道交错BT656/BT1120 YCbCr 422 8/16bit 逐行/隔行

MIPI CSI 4路IDs虚拟通道

MIPI CSI RAW8/10/12/14, YUV422

NV16/NV12/YUV400/YUYV

紧凑/非紧凑 RAW

③ISP

RK3568ISP属于RKISP V2.1的版本

吞吐率 最大分辨率 输入格式
单ISP 单CIS 8M@30 4096x2304 raw8/raw10/raw12/YUV422

(2)RK3568双摄调试

RK3568双摄同时打开的话,需要满足吞吐率符合要求,因为DPHY总计只有4lane,因此双摄都必须是2lane或者小于2lane的sensor。

①双摄硬件连接

需要使用到MIPI的 CLK0 和 CLK1:
MIPI_RX_CLK0 和 MIPI_RX_D0-1 一组,使用CLK0
MIPI_RX_CLK1 和 MIPI_RX_D2-3 一组,使用CLK1

②dts配置

链接关系 1: sensor1->csi2_dphy1->isp_vir0
链接关系 2: sensor2->csi2_dphy2->mipi_csi2->vicap ......->isp_vir1

实例使用gc2093+gc2053,参考配置如下:

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2022 Rockchip Electronics Co., Ltd.
 *
 */

&csi2_dphy_hw {
	status = "okay";
};

/*
 * csi2_dphy1 & csi2_dphy2 used for split mode,
 * csi2_dphy0 used for full mode,
 * full mode and split mode are mutually exclusive
 */
&csi2_dphy0 {
	status = "disabled";
	/delete-node/ ports;
};

&csi2_dphy1 {
	status = "okay";
	/*
	 * dphy1 only used for split mode,
	 * can be used  concurrently  with dphy2
	 * full mode and split mode are mutually exclusive
	 */
	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;

			mipi_in_gc2093_rgb: endpoint@2 {
				reg = <2>;
				remote-endpoint = <&gc2093_out>;
				data-lanes = <1 2>;
			};
		};

		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;

			dphy1_out: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&mipi_csi2_input>;
			};
		};
	};
};

&csi2_dphy2 {
	status = "okay";
	/*
	 * dphy2 only used for split mode,
	 * can be used  concurrently  with dphy1
	 * full mode and split mode are mutually exclusive
	 */
	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;

			mipi_in_gc2053_ir: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&gc2053_out>;
				data-lanes = <1 2>;
			};
		};

		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;

			dphy2_out: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&isp_in1>;
			};
		};
	};
};

&mipi_csi2 {
	status = "okay";

	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;

			mipi_csi2_input: endpoint@1 {
				reg = <1>;
				remote-endpoint = <&dphy1_out>;
				data-lanes = <1 2>;
			};
		};

		port@1 {
			reg = <1>;
			#address-cells = <1>;
			#size-cells = <0>;

			mipi_csi2_output: endpoint@0 {
				reg = <0>;
				remote-endpoint = <&cif_mipi_in>;
				data-lanes = <1 2>;
			};
		};
	};
};

&i2c4 {
	status = "okay";

	/delete-node/ gc8034@37;
	/delete-node/ os04a10@36;
	/delete-node/ ov5695@36;

	gc2053: gc2053@37 {
		status = "okay";
		compatible = "galaxycore,gc2053";
		reg = <0x37>;
		clocks = <&pmucru CLK_WIFI>;
		clock-names = "xvclk";
		power-domains = <&power RK3568_PD_VI>;
		pinctrl-names = "default";
		pinctrl-0 = <&refclk_pins>;
		reset-gpios = <&gpio3 RK_PB5 GPIO_ACTIVE_LOW>;
		pwdn-gpios = <&gpio4 RK_PB5 GPIO_ACTIVE_LOW>;
		rockchip,camera-module-index = <1>;
		rockchip,camera-module-facing = "front";
		rockchip,camera-module-name = "DW-RV2093-V1.0";
		rockchip,camera-module-lens-name = "JZ-7070AS-A3";
		port {
			gc2053_out: endpoint {
				remote-endpoint = <&mipi_in_gc2053_ir>;
				data-lanes = <1 2>;
			};
		};
	};

	gc2093: gc2093@7e {
		status = "okay";
		compatible = "galaxycore,gc2093";
		reg = <0x7e>;
		clocks = <&cru CLK_CIF_OUT>;
		clock-names = "xvclk";
		power-domains = <&power RK3568_PD_VI>;
		pinctrl-names = "default";
		pinctrl-0 = <&cif_clk>;
		reset-gpios = <&gpio3 RK_PB6 GPIO_ACTIVE_LOW>;
		pwdn-gpios = <&gpio4 RK_PB4 GPIO_ACTIVE_HIGH>;
		rockchip,camera-module-index = <0>;
		rockchip,camera-module-facing = "front";
		rockchip,camera-module-name = "DW-RV2093-V1.0";
		rockchip,camera-module-lens-name = "JZ-7070AS-A1";
		port {
			gc2093_out: endpoint {
				remote-endpoint = <&mipi_in_gc2093_rgb>;
				data-lanes = <1 2>;
			};
		};
	};
};

&rkcif {
	status = "okay";
};

&rkcif_mipi_lvds {
	status = "okay";

	port {
		cif_mipi_in: endpoint {
			remote-endpoint = <&mipi_csi2_output>;
			data-lanes = <1 2>;
		};
	};
};

&rkcif_mipi_lvds_sditf {
	status = "okay";

	port {
		mipi_lvds_sditf: endpoint {
			remote-endpoint = <&isp_in2>;
			data-lanes = <1 2>;
		 };
	};
};

&rkcif_mmu {
	status = "okay";
};


&rkisp {
	status = "okay";
	max-input = <3840 2160 30>;
};

&rkisp_mmu {
	status = "okay";
};

&rkisp_vir0 {
	status = "okay";
	/* gc2053-ir->dphy2->isp_vir0 */
	port {
		#address-cells = <1>;
		#size-cells = <0>;

		isp_in1: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&dphy2_out>;
		};
	};
};

&rkisp_vir1 {
	status = "okay";
	/* gc2093-rgb->dphy1->csi2->vicap */
	/* vicap sditf->isp_vir1 */
	port {
		#address-cells = <1>;
		#size-cells = <0>;

		isp_in2: endpoint@0 {
			reg = <0>;
			remote-endpoint = <&mipi_lvds_sditf>;
		};
	};
};

③抓数据流确认

需要注意一个点是,RK3568双摄的使用场景时,第二路必须使用回读模式,也就是必须将AIQ跑起来才可以同时从两路的ISP输出抓到数据流。

第一路直通ISP的sensor可以直接从对应的ISP节点抓数据流,第二路链路可以先保证从vicap的节点抓到数据流,之后再跑aiq的回读模式确认回读到ISP的数据。

使用如下命令可以查看对应的节点:

rk3568_t:/ # grep -H '' /sys/class/video4linux/video*/name 
/sys/class/video4linux/video0/name:stream_cif_mipi_id0     
/sys/class/video4linux/video1/name:stream_cif_mipi_id1     
/sys/class/video4linux/video10/name:rkisp_rawrd0_m         
/sys/class/video4linux/video11/name:rkisp_rawrd2_s         
/sys/class/video4linux/video12/name:rkisp-statistics       
/sys/class/video4linux/video13/name:rkisp-input-params     
/sys/class/video4linux/video14/name:rkisp_mainpath         
/sys/class/video4linux/video15/name:rkisp_selfpath         
/sys/class/video4linux/video16/name:rkisp_rawwr0           
/sys/class/video4linux/video17/name:rkisp_rawwr2           
/sys/class/video4linux/video18/name:rkisp_rawwr3           
/sys/class/video4linux/video19/name:rkisp_rawrd0_m         
/sys/class/video4linux/video2/name:stream_cif_mipi_id2     
/sys/class/video4linux/video20/name:rkisp_rawrd2_s         
/sys/class/video4linux/video21/name:rkisp-statistics       
/sys/class/video4linux/video22/name:rkisp-input-params     
/sys/class/video4linux/video3/name:stream_cif_mipi_id3     
/sys/class/video4linux/video4/name:rkcif-mipi-luma         
/sys/class/video4linux/video5/name:rkisp_mainpath          
/sys/class/video4linux/video6/name:rkisp_selfpath          
/sys/class/video4linux/video7/name:rkisp_rawwr0            
/sys/class/video4linux/video8/name:rkisp_rawwr2            
/sys/class/video4linux/video9/name:rkisp_rawwr3            

一般是video0和video5两个同时抓数据流确认,如果正常,则说明底层通路是正常的。

④HAL层适配

HAL层主要需要适配pipeline,双摄对应场景的pipeline,HAL层可能没有完全支持,可以在如下位置进行自行按需求增加修改:

hardware/rockchip/camera/psl/rkisp2/RKISP2GraphConfig.cpp:

    if(mIsMipiInterface){
        if ((mipName.find("dphy2") != std::string::npos) && (mipName2.find("mipi") != std::string::npos)) {
            //for dual camera
            if(PlatformData::supportDualVideo()) {
                addLinkParams(mipName, mipSrcPad, mipName2, csiSinkPad, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
                addLinkParams(mipName2, 1, "stream_cif_mipi_id0", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
                addLinkParams(mipName2, 2, "stream_cif_mipi_id1", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
                addLinkParams(mipName2, 3, "stream_cif_mipi_id2", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
                addLinkParams(mipName2, 4, "stream_cif_mipi_id3", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);

                addLinkParams("rkisp-csi-subdev", 2, "rkisp_rawwr0", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
                addLinkParams("rkisp-csi-subdev", 4, "rkisp_rawwr2", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
                addLinkParams("rkisp-csi-subdev", 5, "rkisp_rawwr3", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);

                addLinkParams("rkisp-isp-subdev", 2, "rkisp_mainpath", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
                addLinkParams("rkisp-isp-subdev", 2, "rkisp_selfpath", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
            }
	    } else if(mipName2.find("mipi") != std::string::npos) {
            addLinkParams(mipName, mipSrcPad, mipName2, csiSinkPad, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
            addLinkParams(mipName2, 1, "stream_cif_mipi_id0", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
            addLinkParams(mipName2, 2, "stream_cif_mipi_id1", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
            addLinkParams(mipName2, 3, "stream_cif_mipi_id2", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
            addLinkParams(mipName2, 4, "stream_cif_mipi_id3", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
            mSensorLinkedToCIF = true;
	    } else {
            addLinkParams(mipName, mipSrcPad, csiName, csiSinkPad, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
            addLinkParams(csiName, csiSrcPad, IspName, ispSinkPad, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
            addLinkParams(csiName, 2, "rkisp_rawwr0", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
            addLinkParams(csiName, 4, "rkisp_rawwr2", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
            addLinkParams(csiName, 5, "rkisp_rawwr3", 0, 1, MEDIA_LNK_FL_ENABLED, mediaCtlConfig);
	    }
    }

HAL 还需要配置双摄的属性,通知AIQ走回读模式:

diff --git a/common/platformdata/PlatformData.cpp b/common/platformdata/PlatformData.cpp
index 4d9257f..91cf277 100755
--- a/common/platformdata/PlatformData.cpp
+++ b/common/platformdata/PlatformData.cpp
@@ -1047,7 +1047,7 @@ CameraHWInfo::CameraHWInfo() :
 	mProductName = "";
	mManufacturerName = "";
 	mCameraDeviceAPIVersion = CAMERA_DEVICE_API_VERSION_3_3;
- 	mSupportDualVideo = false;
+ 	mSupportDualVideo = true;
 	mSupportExtendedMakernote = false;
 	mSupportFullColorRange = true;
 	mSupportIPUAcceleration = false;

如果是比较新的SDK,通过XML配置属性即可:

 
  

⑤接vicap的sensor的MIPI信号异常导致画面异常复位机制

mipi 信号出错,导致 vicap(356x 的 mipi接收端)从某帧开始丢了几行,少的几行由下一帧的前面几行补上;所以造成画面断层(仔细观察预览画面,画面底部会有断层),如果刚好丢的行数是奇数行,那由于bayer rgb顺序变掉,isp出来的效果就是偏紫的这种是处理信号低概率出错情况,概率如果高,一直reset也不是办法,且reset会丢帧卡顿,也有可能会闪红一两帧的如果高概率出现mipi报错,还是要硬件信号确认下。

&rkcif_mipi_lvds {
        status = "okay";
	/* parameters for do cif reset detecting:
	 * index0: monitor mode,
		   0 for idle,
		   1 for continue,
		   2 for trigger,
		   3 for hotplug (for nextchip)
	 * index1: the frame id to start timer,
		   min is 2
	 * index2: frame num of monitoring cycle
	 * index3: err time for keep monitoring
		   after finding out err (ms)
	 * index4: csi2 err reference val for resetting
	 */
	rockchip,cif-monitor = <3 2 3 1000 5>;
        port {
                cif_mipi_in: endpoint {
                        remote-endpoint = <&mipi_csi2_output>;
                        data-lanes = <1 2>;
                };
        };
};

(3)总结

这篇文章主要介绍了RK3568/rk3566的camera资源以及双摄的配置调试,很多人会发现rk3568除了两路mipi camera的支持,还能支持一路dvp接口的camera,是否可以同时支持3路camera的场景?当然是可以的,下次再给大家分享一下3摄的配置调试。

你可能感兴趣的:(camera调试,RK356X,驱动开发,linux,android)