RK3568平台仅有一个标准物理mipi csi2 dphy,可以工作在full mode 和split mode两个模式, 拆分为csi2_dphy0/csi2_dphy1/csi2_dphy2三个逻辑dphy
Full Mode:
仅使用csi2_dphy0,csi2_dphy0与csi2_dphy1/csi2_dphy2互斥,不可同时使用;
data lane最大4 lanes;
最大速率2.5Gbps/lane;
Split Mode:
仅使用csi2_dphy1和csi2_dphy2, 与csi2_dphy0互斥,不可同时使用;
csi2_dphy1和csi2_dphy2可同时使用;
csi2_dphy1和csi2_dphy2各自的data lane最大是2 lanes;
csi2_dphy1对应物理dphy的lane0/lane1;
csi2_dphy2对应物理dphy的lane2/lane3;
最大速率2.5Gbps/lane
双目摄像头链路连接:
gc2385->csi2_dphy1->isp_vir0
gc2053->csi_dphy2->csi2->cif->isp_vir1
双摄像头的时候,需要用到2个phy,因此需要只能用Split Mode。
一 .Full Mode单摄像头dts配置如下:
gc2385/gc2053->csi2_dphy0->isp_vir0
&csi2_dphy0 {
status = "okay";
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
mipi_in_ucam0: endpoint@0 {
reg = <0>;
remote-endpoint = <&gc2053_out>;
data-lanes = <1 2>;
};
mipi_in_ucam1: endpoint@1 {
reg = <1>;
remote-endpoint = <&gc2385_out>;
data-lanes = <1>;
};
};
port@1 {
reg = <1>;
#address-cells = <1>;
#size-cells = <0>;
csidphy_out: endpoint@0 {
reg = <0>;
remote-endpoint = <&isp0_in>;
};
};
};
};
&csi2_dphy_hw {
status = "okay";
};
&csi2_dphy1 {
status = "disabled";
};
&csi2_dphy2 {
status = "disabled";
};
/*******isp*****/
&rkisp {
status = "okay";
};
&rkisp_mmu {
status = "okay";
};
&rkisp_vir0 {
status = "okay";
port {
#address-cells = <1>;
#size-cells = <0>;
isp0_in: endpoint@0 {
reg = <0>;
remote-endpoint = <&csidphy_out>;
};
};
};
&i2c2 {
status = "okay";
pinctrl-0 = <&i2c2m1_xfer>;
gc2385: gc2385@37 {
status = "okay";
compatible = "galaxycore,gc2385";
reg = <0x37>;
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_PD4 GPIO_ACTIVE_LOW>;
pwdn-gpios = <&gpio3 RK_PD5 GPIO_ACTIVE_HIGH>;
rockchip,camera-module-index = <1>;
rockchip,camera-module-facing = "front";
rockchip,camera-module-name = "HS5885-BNSM1018-V01";
rockchip,camera-module-lens-name = "default";
port {
gc2385_out: endpoint {
remote-endpoint = <&mipi_in_ucam1>;
data-lanes = <1>;
};
};
};
};
&i2c3 {
status = "okay";
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_PD2 GPIO_ACTIVE_LOW>;
pwdn-gpios = <&gpio3 RK_PD3 GPIO_ACTIVE_LOW>;
rockchip,camera-module-index = <0>;
rockchip,camera-module-facing = "back";
rockchip,camera-module-name = "default";
rockchip,camera-module-lens-name = "JX8006";
port {
gc2053_out: endpoint {
remote-endpoint = <&mipi_in_ucam0>;
data-lanes = <1 2>;
};
};
};
};
二. Split Mode双摄像头dts配置:
/*
* 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";
};
&csi2_dphy_hw {
status = "okay";
};
&csi2_dphy2 {
status = "okay";
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
mipi_in_ucam0: 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@0 {
reg = <0>;
remote-endpoint = <&mipi_csi2_input>;
};
};
};
};
&csi2_dphy1 {
status = "okay";
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
#address-cells = <1>;
#size-cells = <0>;
mipi_in_ucam1: endpoint@1 {
reg = <1>;
remote-endpoint = <&gc2385_out>;
data-lanes = <1>;
};
};
port@1 {
reg = <1>;
#address-cells = <1>;
#size-cells = <0>;
dphy1_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 = <&dphy2_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>;
};
};
};
};
&rkcif {
status = "okay";
};
&rkcif_dvp {
status = "disabled";
};
&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 = <&isp1_in>;
data-lanes = <1 2>;
};
};
};
/********isp***********/
&rkisp {
status = "okay";
//max-input = <1920 1080 30>;
};
&rkcif_mmu {
status = "okay";
};
&rkisp_mmu {
status = "okay";
};
&rkisp_vir0 {
status = "okay";
port {
#address-cells = <1>;
#size-cells = <0>;
isp_in1: endpoint@0 {
reg = <0>;
remote-endpoint = <&dphy1_out>;
};
};
};
&rkisp_vir1 {
status = "okay";
port {
#address-cells = <1>;
#size-cells = <0>;
isp1_in: endpoint@0 {
reg = <0>;
remote-endpoint = <&mipi_lvds_sditf>;
};
};
};
&i2c2 {
status = "okay";
pinctrl-0 = <&i2c2m1_xfer>;
gc2385: gc2385@37 {
status = "okay";
compatible = "galaxycore,gc2385";
reg = <0x37>;
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_PD4 GPIO_ACTIVE_LOW>;
pwdn-gpios = <&gpio3 RK_PD5 GPIO_ACTIVE_HIGH>;
rockchip,camera-module-index = <1>;
rockchip,camera-module-facing = "front";
rockchip,camera-module-name = "HS5885-BNSM1018-V01";
rockchip,camera-module-lens-name = "default";
port {
gc2385_out: endpoint {
remote-endpoint = <&mipi_in_ucam1>;
data-lanes = <1>;
};
};
};
};
&i2c3 {
status = "okay";
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_PD2 GPIO_ACTIVE_LOW>;
pwdn-gpios = <&gpio3 RK_PD3 GPIO_ACTIVE_LOW>;
rockchip,camera-module-index = <0>;
rockchip,camera-module-facing = "back";
rockchip,camera-module-name = "default";
rockchip,camera-module-lens-name = "JX8006";
port {
gc2053_out: endpoint {
remote-endpoint = <&mipi_in_ucam0>;
data-lanes = <1 2>;
};
};
};
};
三. 调试流程:
驱动在kernel/drivers/media/i2c下,目前调的2385和2053sdk里面已经存在,直接用该驱动即可。
调试中的一些经验总结:
3.1:首先要确保AVDD(2.8)、DVDD(1.2)、DOVDD(1.8)三路电压正常出来。
3.2:reset、pwdn这两个引脚是否正常配置到起作用,用示波器量信号
3.3:查看原理图,确认硬件连接上的对应关系:2385:MIPI_RX_D0-1(csi2_dphy1) 2053:MIPI_RX_D2-3(csi_dphy2),这个地方要对应上,不可调换过来
gc2385->csi2_dphy1->isp_vir0
gc2053->csi_dphy2->csi2->cif->isp_vir1
3.4:mclk配置查看原理图是否对应正确,RK356x有四个输出时钟,可作为给CIS模组的MCLK:
1、REFCLK_OUT(GPIO0_A0)
示例dts:arch/arm64/boot/dts/rockchip/rk3566-evb2-lp4x-v10.dtsi中的gc5025时钟配置
gc5025: gc5025@37 {
.…..
clocks = <&pmucru CLK_WIFI>;
clock-names = "xvclk";
pinctrl-names = "default";
pinctrl-0 = <&refclk_pins>;
};
2、CAM_CLKOUT0(GPIO4_A7)
示例dts:arch/arm64/boot/dts/rockchip/rk3566-rk817-tablet.dts中的ov8858时钟配置
ov8858: ov8858@36 {
.…..
clocks = <&cru CLK_CAM0_OUT>;
clock-names = "xvclk";
pinctrl-names = "default";
pinctrl-0 = <&cam_clkout0 >;
};
3、 CAM_CLKOUT1(GPIO4_A8)
示例dts:arch/arm64/boot/dts/rockchip/rk3566-evb1-ddr4-v10.dtsi中的ov02k10时钟配置
ov02k10: ov02k10@36 {
.…..
clocks = <&cru CLK_CAM1_OUT>;
clock-names = "xvclk";
pinctrl-names = "default";
pinctrl-0 = <& cam_clkout1>;
};
4、 CLK_CIF_OUT (GPIO4_C0)
示例dts:arch/arm64/boot/dts/rockchip/rk3566-rk817-tablet.dts中的gc2385时钟配置
gc2385: gc2385@37 {
.…..
clocks = <&cru CLK_CIF_OUT >;
clock-names = "xvclk";
pinctrl-names = "default";
pinctrl-0 = <& cif_clk >;
};
这里我用到的两组是:
2053:REFCLK_OUT(GPIO0_A0) 2385:CLK_CIF_OUT (GPIO4_C0)
3.5:确保i2c地址正确,如果以上4点都正常,这时候应该就可以正常识别到sensor id了。可以进行正常的mipi信号传输,可用v4l2 命令获取数据流:
v4l2-ctl --verbose -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat=BG10 --stream-mmap=3 --stream-skip=100 --stream-to=/tmp/GB10.raw --stream-count=1 --stream-poll
v4l2-ctl --verbose -d /dev/video5 --set-fmt-video=width=1600,height=1200,pixelformat=BG10 --stream-mmap=3 --stream-skip=100 --stream-to=/tmp/GB10.raw --stream-count=1 --stream-poll
3.6:此时打开apk,如果还打不开,使用命令:dumpsys media.camera
Number of camera devices: 0,说明 framework 层没有识别到摄像头,这个一般是camera3_profiles.xml中对应摄像头没有配置或者配置不对导致异常
开机过程会有以下log:
rockchip-csi2-dphy csi2-dphy1: dphy1 matches m01_f_gc2385 2-0037:bus type 4
rockchip-csi2-dphy csi2-dphy2: dphy2 matches m00_b_gc2053 3-0037:bus type 4
cat /sys/class/video4linux/*/name或者:
m0x这个对应的是dts中的配置:
rockchip,camera-module-index = <x>; x:0/1
我调试的时候,识别不到设备,就是camera3_profiles.xml中2385的moduleId与驱动 DTS 中配置不一致导致的。
这时再dumpsys media.camera:
Service global info:
Number of camera devices: 1
Number of normal camera devices: 1
Number of public camera devices visible to API1: 1
说明识别到设备了
3.7:第6点正常后,但是使用 APK 还是打不开,这种情况一般是tuning效果文件导致,这种情况只有raw摄像头sensor需要iq文件。
raw摄像头支持的iq文件路径external/camera_engine_rkaiq/iqfiles/isp21, 与以前不一样的地方是iq文件不再采用.xml的方式,而是采用.json的方式。
rkisp : [XCORE]:XCAM ERROR RkAiqCalibDbV2.cpp:322: access /vendor/etc/camera/rkisp2/gc2053_RS-D22WS14P-1_default.json failed!
需要注意的是,这个json文件命名也是跟dts一致的,不然匹配不上:
gc2053_default_JX8006.json
rockchip,camera-module-name = "default";
rockchip,camera-module-lens-name = "JX8006";
3.8:经过以上的艰辛路程,两个摄像头终于可以打开了。经过跟厂家确认,gc2053的是RGB的彩色镜头,gc2385是IR的红外镜头,但发现gc2053的出图是灰白色的,经过跟rk工程师的沟通,需要再iq文件里面修改一下颜色的反色:
diff --git a/iqfiles/isp21/gc2053_default_JX8006.json b/iqfiles/isp21/gc2053_default_JX8006.json
old mode 100644
new mode 100755
index 1b9e81c..d26cfe2
--- a/iqfiles/isp21/gc2053_default_JX8006.json
+++ b/iqfiles/isp21/gc2053_default_JX8006.json
@@ -1763,7 +1763,7 @@
},
"colorAsGrey": {
"param": {
- "enable": 1
+ "enable": 0
}
},
"lumaDetect": {
3.9:默认打开前置、后置摄像头:
packages/apps/Camera2/res/value/strings.xml里设置pref_camera_id_default为1即默认打开后摄,为0即默认打开前置文章来源:https://www.toymoban.com/news/detail-577384.html
3.10:到此,摄像头就正常了。文章来源地址https://www.toymoban.com/news/detail-577384.html
到了这里,关于rk3568mipi摄像头调试(gc2385 + gc2053)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!