debian 尝试使用ov13850摄像头

首先修改dts文件 rk3399-firefly-linux.dts

&cif_isp0 {
	rockchip,camera-modules-attached = <&camera0>;
	rockchip,gpios-cifpower = <&gpio1 22 GPIO_ACTIVE_HIGH>;

	status = "okay";
};
camera0: camera-module@20 {
		status = "okay";
		compatible = "omnivision,ov13850-v4l2-i2c-subdev";
		reg = < 0x20 >;
		device_type = "v4l2-i2c-subdev";

		clocks = <&cru SCLK_CIF_OUT>;
		clock-names = "clk_cif_out";

		pinctrl-names = "rockchip,camera_default", "rockchip,camera_sleep";
		pinctrl-0 = <&cam0_default_pins>;
		pinctrl-1 = <&cam0_sleep_pins>;

		/*GPIO2  B4 = 12 B6 = 14 MIPI0 D4 = 28 C7 = 23 */
		rockchip,pwr-gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>;	/*Power			GPIO1_C7 */
		rockchip,pd-gpio  = <&gpio2 12 GPIO_ACTIVE_LOW>;	/*Power Down	GPIO2_B4 */
		rockchip,rst-gpio = <&gpio0 8 GPIO_ACTIVE_LOW>;		/*Reset			GPIO0_B0 */

		rockchip,camera-module-mclk-name = "clk_cif_out";
		rockchip,camera-module-facing = "back";
		rockchip,camera-module-name = "cmk-cb0695-fv1";
		rockchip,camera-module-len-name = "lg9569a2";
		rockchip,camera-module-fov-h = "66.0";
		rockchip,camera-module-fov-v = "50.1";
		rockchip,camera-module-orientation = <0>;
		rockchip,camera-module-iq-flip = <0>;
		rockchip,camera-module-iq-mirror = <0>;
		rockchip,camera-module-flip = <0>;
		rockchip,camera-module-mirror = <0>;

		rockchip,camera-module-defrect0 = <1920 1080 0 0 1920 1080>;
		rockchip,camera-module-defrect1 = <2112 1568 0 0 2112 1568>;
		rockchip,camera-module-defrect2 = <4224 3136 0 0 4224 3136>;
		rockchip,camera-module-defrect3 = <3264 2448 0 0 3264 2448>;

		rockchip,camera-module-flash-support = <0>;			/*闪光灯控制开关*/
		rockchip,camera-module-mipi-dphy-index = <0>;		/*MIPI 接口索引*/
	};

修改 cif_isp10_pltfrm.c 文件 加入 cifpower 设定.

void init_cif_power(struct device *dev)
{
	enum of_gpio_flags flags;
	int cifpower_io;
	int io_ret;

    cifpower_io = of_get_named_gpio_flags(dev->of_node, "rockchip,gpios-cifpower", 0, &flags);
    cif_isp10_pltfrm_pr_info(dev,"1-gpios-cifpower: gpio=%d", cifpower_io);
    if(gpio_is_valid(cifpower_io)) {
        cifpower_io = of_get_named_gpio_flags(dev->of_node, "rockchip,gpios-cifpower", 0, &flags);
        cif_isp10_pltfrm_pr_info(dev,"gpios-cifpower: gpio_request");
        io_ret = gpio_request(cifpower_io,"cifpower");
        cif_isp10_pltfrm_pr_info(dev,"1-gpios-cifpower: gpio_request=%d", io_ret);
        if(io_ret < 0){
            cif_isp10_pltfrm_pr_err(dev,"Request %s(%d) failed","cifpower", cifpower_io);
        } else {
            gpio_direction_output(cifpower_io, 1);
            gpio_set_value(cifpower_io, 1);
            cif_isp10_pltfrm_pr_info(dev,"gpios-cifpower: %d high", cifpower_io);
        }
    }
	return;
}

在 cif_isp10_pltfrm_dev_init 函数中调用上面的函数.
然后重新编译并替换内核.
启动后查看启动信息如下:

[    0.252170] iommu: Adding device ff910000.cif_isp to group 4
[    0.252723] platform ff910000.cif_isp: iommu /iommu@ff914000 not found
[    0.253310] iommu: Removing device ff910000.cif_isp from group 4
[    1.975010] cif_isp10_v4l2_drv_probe: probing...
[    1.975541] cif_isp10_pltfrm_dev_init(1249) ERR: could not get default pinstate
[    1.976623] cif_isp10_pltfrm_dev_init WARN: could not get pins_sleep pinstate
[    1.977252] cif_isp10_pltfrm_dev_init WARN: could not get pins_inactive pinstate
[    1.977941] of_get_named_gpiod_flags: parsed 'rockchip,gpios-cifpower' property of node '/cif_isp@ff910000[0]' - status (0)
[    1.977947] init_cif_power: 1-gpios-cifpower: gpio=54
[    1.978425] of_get_named_gpiod_flags: parsed 'rockchip,gpios-cifpower' property of node '/cif_isp@ff910000[0]' - status (0)
[    1.978454] init_cif_power: gpios-cifpower: gpio_request
[    1.978939] init_cif_power: 1-gpios-cifpower: gpio_request=0
[    1.979484] init_cif_power: gpios-cifpower: 54 high
[    1.980060] iommu: Adding device ff910000.cif_isp to group 4
[    1.980603] rkisp10 ff910000.cif_isp: Possibly a virtual device
[    2.008084] cif_isp10_img_src_v4l2_i2c_subdev_to_img_src(59) ERR: failed with error -6
[    2.008087] cif_isp10_img_src_to_img_src(70) ERR: to_img_src failed!
[    2.008090] cif_isp10_img_src_to_img_src(78) ERR: failed with error -14
[    2.008096] cif_isp10_img_srcs_init(1099) ERR: failed with error -14
[    2.008099] cif_isp10_create(5772) ERR: cif_isp10_img_srcs_init failed
[    2.008101] cif_isp10_create(5808) ERR: failed with error -14
linaro@linaro-alip:~$ dmesg | grep camera
[    1.981743] of_get_named_gpiod_flags: parsed 'rockchip,pd-gpio' property of node '/i2c@ff110000/camera-module@20[0]' - status (0)
[    1.981767] of_get_named_gpiod_flags: parsed 'rockchip,pwr-gpio' property of node '/i2c@ff110000/camera-module@20[0]' - status (0)
[    1.981777] of_get_named_gpiod_flags: can't parse 'rockchip,flash-gpio' property of node '/i2c@ff110000/camera-module@20[0]'
[    1.981787] of_get_named_gpiod_flags: can't parse 'rockchip,torch-gpio' property of node '/i2c@ff110000/camera-module@20[0]'
[    1.981808] of_get_named_gpiod_flags: parsed 'rockchip,rst-gpio' property of node '/i2c@ff110000/camera-module@20[0]' - status (0)
[    2.007420] ov13850.ov_camera_module_write_config(182) ERR: no active sensor configuration
[    2.007421] ov13850.ov_camera_module_write_config(233) ERR: failed with error -14
[    2.007725] ov13850.pltfrm_camera_module_read_reg(996) ERR: i2c read from offset 0x0000300a failed with error -6
[    2.007888] ov13850.pltfrm_camera_module_read_reg(996) ERR: i2c read from offset 0x0000300b failed with error -6
[    2.007893] ov13850.ov13850_check_camera_id(1820) ERR: register read failed, camera module powered off?
[    2.007898] ov13850.ov13850_check_camera_id(1838) ERR: failed with error (-6)
[    2.007945] ov13850.ov_camera_module_attach(256) ERR: failed with error -6

i2c 通信并没有起来,希望大神能提供帮助.

阅读了一次原理图dts 修改后如下:

// MIPI-CIF 位于主板正面外侧, (引脚参考原理图 J22)
	camera0: camera-module@20 {
		status = "okay";
		compatible = "omnivision,ov13850-v4l2-i2c-subdev";
		reg = < 0x20 >;
		device_type = "v4l2-i2c-subdev";

		clocks = <&cru SCLK_CIF_OUT>;
		clock-names = "clk_cif_out";
		rockchip,camera-module-mclk-name = "clk_cif_out";
		rockchip,camera-module-dovdd = "1.8v";

		pinctrl-names = "rockchip,camera_default", "rockchip,camera_sleep";
		pinctrl-0 = <&cam0_default_pins>;
		pinctrl-1 = <&cam0_sleep_pins>;

		/*GPIO2  B4 = 12 B6 = 14 MIPI0 D4 = 27 C7 = 23 */
		rockchip,pwr-gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>;	/*Power			GPIO1_C7 */
		rockchip,pd-gpio  = <&gpio2 12 GPIO_ACTIVE_LOW>;	/*Power Down	GPIO2_B4  OR GPIO2_D4 */

		// rst 硬件上拉 无需配置
		//rockchip,rst-gpio = <&gpio0 8 GPIO_ACTIVE_LOW>;		/*Reset			GPIO0_B0 */

		rockchip,camera-module-facing = "back";
		rockchip,camera-module-name = "cmk-cb0695-fv1";
		rockchip,camera-module-len-name = "lg9569a2";
		rockchip,camera-module-fov-h = "66.0";
		rockchip,camera-module-fov-v = "50.1";
		rockchip,camera-module-orientation = <0>;
		rockchip,camera-module-iq-flip = <0>;
		rockchip,camera-module-iq-mirror = <0>;
		rockchip,camera-module-flip = <0>;
		rockchip,camera-module-mirror = <0>;

		rockchip,camera-module-defrect0 = <3264 2448 0 0 3264 2448>;

		rockchip,camera-module-flash-support = <0>;			/*闪光灯控制开关*/
		rockchip,camera-module-mipi-dphy-index = <0>;		/*MIPI 接口索引*/
	};
&cif_isp0 {
	rockchip,camera-modules-attached = <&camera0>;
	rockchip,gpios-cifpower = <&gpio1 22 GPIO_ACTIVE_HIGH>;

	status = "okay";
};

&isp0_mmu {
    status = "okay";
};

但还是不行,请大神们指点下.

I2C SLAVE 地址修改位 0x10 工作良好

楼主很厉害,不知道有没有尝试过两路MIPI同时使用摄像头

暂时没有尝试过.

按照楼主20180601的配置,I2C SLAVE 地址修改位 0x10,mipi摄像头接到 J22就可以工作了么

RICHYDUAN 发表于 2018-6-21 10:11
按照楼主20180601的配置,I2C SLAVE 地址修改位 0x10,mipi摄像头接到 J22就可以工作了么

修改了一下,内核无限重启了。。。

楼主,参照你的配置,J22这个摄像头i2c可以通信了,但现在的问题是,如果要把摄像头接到J24,I2C SLAVE 地址改成0x6C不能通信,另一路摄像头I2C SLAVE地址应该改成多少呢

RICHYDUAN 发表于 2018-6-22 13:34
楼主,参照你的配置,J22这个摄像头i2c可以通信了,但现在的问题是,如果要把摄像头接到J24,I2C SLAVE 地 …

我也没试过。

楼主,想确认一下,J24的rockchip pd-gpio,也就是 GPIO2 D4 应该配置成27还是28?

bywayboy 发表于 2018-6-4 08:14
I2C SLAVE 地址修改位 0x10 工作良好

楼主,ubuntu下怎么测试写好的驱动mipi摄像头的?有写好的demo应用程序吗

请教楼主,谢谢!

  1. 下述错误如何解决?
    [ 3.293800] ov13850.ov_camera_module_write_config(182) ERR: no active sensor configuration
    [ 3.293800] ov13850.ov_camera_module_write_config(233) ERR: failed with error -14
  2. 用什么应用程序测试摄像头?VLC吗?

本渣参考楼主的修改,然额并没有成功,请帮忙分析一下原因:
[ 13.151931] sensor_register_slave:mpu6880_gyro,id=50
[ 13.153400] cif_isp10_v4l2_drv_probe: probing…
[ 13.153853] init_cif_power: 1-gpios-cifpower锛? gpio=-2
[ 13.154416] cif_isp10_pltfrm_dev_init(1248) ERR: could not get default pinstate
[ 13.155099] cif_isp10_pltfrm_dev_init WARN: could not get pins_sleep pinstate
[ 13.155733] cif_isp10_pltfrm_dev_init WARN: could not get pins_inactive pinstate
[ 13.158413] mmc1: new HS400 Enhanced strobe MMC card at address 0001
[ 13.159824] mmcblk1: mmc1:0001 AJTD4R 14.6 GiB
[ 13.160963] mmcblk1boot0: mmc1:0001 AJTD4R partition 1 4.00 MiB
[ 13.162180] mmcblk1boot1: mmc1:0001 AJTD4R partition 2 4.00 MiB
[ 13.163398] mmcblk1rpmb: mmc1:0001 AJTD4R partition 3 4.00 MiB
[ 13.164529] uboot: 0x000400000 – 0x000800000 (4 MB)
[ 13.165024] trust: 0x000800000 – 0x000c00000 (4 MB)
[ 13.165514] resource: 0x000c00000 – 0x001c00000 (16 MB)
[ 13.166014] kernel: 0x001c00000 – 0x003000000 (20 MB)
[ 13.166508] backup: 0x003000000 – 0x003400000 (4 MB)
[ 13.166997] boot: 0x003400000 – 0x3a3a00000 (14854 MB)
[ 13.167548] mmcblk1: p1 p2 p3 p4 p5 p6
[ 13.175761] usb 1-1: new high-speed USB device number 2 using ehci-platform
[ 13.183145] ov13850.ov_camera_module_write_config(182) ERR: no active sensor configuration
[ 13.183867] ov13850.ov_camera_module_write_config(233) ERR: failed with error -14
[ 13.184785] ov13850.pltfrm_camera_module_read_reg(1007) ERR: i2c read from offset 0x0000300a failed with error -6
[ 13.185883] ov13850.pltfrm_camera_module_read_reg(1007) ERR: i2c read from offset 0x0000300b failed with error -6
[ 13.186803] ov13850.ov13850_check_camera_id(1820) ERR: register read failed, camera module powered off?
[ 13.187628] ov13850.ov13850_check_camera_id(1838) ERR: failed with error (-6)
[ 13.188298] ov13850.ov_camera_module_attach(256) ERR: failed with error -6
[ 13.188942] cif_isp10_img_src_v4l2_i2c_subdev_to_img_src(59) ERR: failed with error -6
[ 13.189633] cif_isp10_img_src_to_img_src(70) ERR: to_img_src failed!
[ 13.190203] cif_isp10_img_src_to_img_src(78) ERR: failed with error -14
[ 13.190797] cif_isp10_img_srcs_init(1099) ERR: failed with error -14
[ 13.191360] cif_isp10_create(5772) ERR: cif_isp10_img_srcs_init failed
[ 13.191943] cif_isp10_create(5808) ERR: failed with error -14

楼主厉害,想问下摄像头接口调通了,应该怎么做测试呢?

ccn422 发表于 2018-9-8 16:34
请教楼主,谢谢!

  1. 下述错误如何解决?
    [ 3.293800] ov13850.ov_camera_module_write_config(182) …

想问下摄像头该怎么测试呢

Pokemon 发表于 2018-10-17 08:28
楼主厉害,想问下摄像头接口调通了,应该怎么做测试呢?

官方都已经出了支持OV13850的固件了{:4_94:}

leung先森 发表于 2018-10-17 09:56
官方都已经出了支持OV13850的固件了

想用在Ubuntu系统下,内核改好了,想做个测试

Pokemon 发表于 2018-10-17 10:40
想用在Ubuntu系统下,内核改好了,想做个测试

ubuntu下应该是不行的,没有64位的ISP库

leung先森 发表于 2018-10-18 15:31
ubuntu下应该是不行的,没有64位的ISP库

debian下 能用opencv的videocapture调用摄像头吗?

Pokemon 发表于 2018-10-17 10:40
想用在Ubuntu系统下,内核改好了,想做个测试

请问你的内核是怎么改的