概述
目录
OV8858主要信息
设备树修改
添加编译设置
修改上电时序
修改摄像头配置文件
开发流程概述
添加I2c设备树 --> 修改驱动中的上电时序 --> 读取到摄像头ID --> 修改摄像头配置文件
OV8858主要信息
1.供电
key specifications (typical)
active array size: 3264 x 2448
power supply:
analog: 2.6 to 3.0V (2.8V nominal)
core: 1.14 to 1.26V (1.2V nominal)
I/O: 1.7 to 3.0V (1.8V or 2.8V nominal)
2.如何判断驱动中摄像头配置是 RAW 还是 SOC 类型?
如果驱动中 xxxx_enum_mbus_code 配置为 MEDIA_BUS_FMT_UYVY/YUYV/VYUY 等,则为SOC 摄像头;如果需要调试效果,找对应 Sensor 原厂。
如果驱动中 xxxx_enum_mbus_code 配置为 MEDIA_BUS_FMT_SBGGR/SRGGB/SGBRG 等,则为 RAW 摄像头,
设备树修改
1.添加对应的i2c设备
&i2c1{
status = "okay";
clock-frequency = <400000>;
ov8858: ov8858@36 {
compatible = "ovti,ov8858";
reg = <0x36>;
clocks = <&cru SCLK_CIF_OUT>;
clock-names = "xvclk";
/* avdd-supply = <>; */ /*硬件pwm供电,软件不需要配置*/
/* dvdd-supply = <>; */
/* dovdd-supply = <>; */
/* flash-leds = <>; */
pinctrl-names = "rockchip,camera_default";
pinctrl-0 = <&cif_clkout>;
//power-gpio = <&gpio2 RK_PB4 cc>;/*硬件pwm供电,软件不需要配置*/
reset-gpios = <&gpio2 RK_PD3 GPIO_ACTIVE_LOW>; /*重启设备*/
pwdn-gpios = <&gpio2 RK_PB4 GPIO_ACTIVE_LOW>; /*复位设备寄存器*/
rockchip,camera-module-index = <0>;
rockchip,camera-module-mclk-name = "clk_cif_out";
rockchip,camera-module-facing = "front";
rockchip,camera-module-name = "CameraKing";
rockchip,camera-module-lens-name = "Largan-9569A2";
//power-domains = <&power RK3399_PD_VIO>;
port {
ov8858_out: endpoint {
remote-endpoint = <&mipi_in_ucam0>;
data-lanes = <1 2 3 4>;
};
};
};
};&mipi_dphy_rx0{
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 = <&ov8858_out>;
data-lanes = <1 2 3 4>;
};
};port@1 {
reg = <1>;
#address-cells = <1>;
#size-cells = <0>;dphy_tx1rx1_out: endpoint@0 {
reg = <0>;
remote-endpoint = <&isp0_mipi_in>;
};
};
};
};&rkisp1_0{
status = "okay";
port {
#address-cells = <1>;
#size-cells = <0>;isp0_mipi_in: endpoint@0 {
reg = <0>;
remote-endpoint = <&dphy_tx1rx1_out>;
};
};
};&isp0_mmu{ /* rkisp1_0中指定了iommus = <&isp0_mmu> */
status = "okay";
};
其他的一些修改
&pinctrl {
isp {
cif_clkout: cif-clkout {
rockchip,pins =
/*cif_clkout*/
<2 11 RK_FUNC_3 &pcfg_pull_none>;
};
- bat_detect_gpio: bat-detect-gpio {
+ /*bat_detect_gpio: bat-detect-gpio { /*去除一些重复的引脚,以免出问题*/
rockchip,pins = <2 RK_PB4 RK_FUNC_GPIO &pcfg_pull_none>;
};
+ */
&io_domains {
status = "okay";
- bt656-supply = <&vcc_3v0>;
+ bt656-supply = <&vcc1v8_dvp>;
audio-supply = <&vcca1v8_codec>;
sdmmc-supply = <&vccio_sd>;
gpio1830-supply = <&vcc_3v0>;
添加编译设置
路径:arch/arm64/configs/tab23_rk99_fr_gen2_defconfig
-# CONFIG_VIDEO_OV8858 is not set
+CONFIG_VIDEO_OV8858=y路径:drivers/media/i2c/Kconfig
config VIDEO_OV8858
tristate "OmniVision OV8858 sensor support"
depends on I2C && VIDEO_V4L2
depends on MEDIA_CAMERA_SUPPORT
+ default y
修改上电时序
static int __ov8858_power_on(struct ov8858 *ov8858)
}
if (!IS_ERR(ov8858->reset_gpio))
- gpiod_set_value_cansleep(ov8858->reset_gpio, 0);
-
+ gpiod_set_value_cansleep(ov8858->reset_gpio, 1);
+ if (!IS_ERR(ov8858->pwdn_gpio))
+ gpiod_set_value_cansleep(ov8858->pwdn_gpio, 1);
ret = regulator_bulk_enable(OV8858_NUM_SUPPLIES, ov8858->supplies);
if (ret < 0) {
dev_err(dev, "Failed to enable regulatorsn");
goto disable_clk;
}
-
+ usleep_range(2500, 3000);
if (!IS_ERR(ov8858->reset_gpio))
- gpiod_set_value_cansleep(ov8858->reset_gpio, 1);
+ gpiod_set_value_cansleep(ov8858->reset_gpio, 0);
+
- usleep_range(1000, 2000);
if (!IS_ERR(ov8858->pwdn_gpio))
- gpiod_set_value_cansleep(ov8858->pwdn_gpio, 1);
+ gpiod_set_value_cansleep(ov8858->pwdn_gpio, 0);
修改摄像头配置文件
/FR/hardware/rockchip/camera/etc/camera/camera3_profiles_rk3399.xml
从其他的使用8858的项目里把8858的配置都抄过来
<Profiles cameraId="0" name="ov8858" moduleId="m00"> 只有1个摄像头moduleId为0
<sensor.orientation value="90"/> 摄像头旋转的角度
<sensorType value="SENSOR_TYPE_RAW"/> 摄像头的类型,另一个为SENSOR_TYPE_SOC,如果设置为SOC,这里面的配置都不在生效,摄像的画面会很幽暗。
关于摄像头的效果
/FR/hardware/rockchip/camera/etc/camera/rkisp1/ov8858_CameraKing_Largan-9569A2.xml
源文件:FR/device/rockchip/rk3399/media_profiles_default.xml(拷其他项目的)
这个文件会拷贝为机器的 /vendor/etcmedia_profiles_V1_0.xml 控制摄像头拍照和录像的分辨率,如果这个文件不对会导致录像功能崩溃
问题1:mclk时钟如果没有输出,很有可能是电源阈没有配置正确。
由上图可见mclk的引脚是GPIO2-B3.由原理图可知GPIO2用的电源域对应APIO2,
APIO2_VDD ---> VCC1V8_DVP
查看kernel文档Documentation/devicetree/bindings/power/rockchip-io-domain.txt
Possible supplies for rk3399:
- bt656-supply: The supply connected to APIO2_VDD.
RK3399 GPIO配置问题/电源域配置
问题2:上层未识别到摄像头,使用 APK 打不开摄像头
使用命令: dumpsy media.camera
Number of camera devices: 0,说明 framework 层没有识别到摄像头;
问题3:拍照功能正常,点击录像就会崩溃
logcat报错信息:
10-10 14:27:43.464 1511 2025 E CAM_Storage: getOtherAvailableSpace DIRECTORY:/DCIM/Camera UNAVAILABLE
10-10 14:27:43.468 1511 1511 I CAM_VideoModule: initializeRecorder: Thread[main,5,main]
10-10 14:27:43.469 1511 1511 D CAM_VideoModule: camera isReleased:false
10-10 14:27:43.482 417 1718 W StagefrightRecorder: Max file duration is not positive: 0 us. Disabling duration limit.
10-10 14:27:43.482 417 1718 W StagefrightRecorder: Target duration (0 us) too short to be respected
10-10 14:27:43.483 1511 1511 D CAM_LcyLocProvider: No location received yet.
10-10 14:27:43.484 1511 1511 D CAM_LcyLocProvider: No location received yet.
10-10 14:27:43.484 1511 1511 V CAM_VideoModule: New video filename: /storage/emulated/0/DCIM/Camera/VID_20221010_142743.mp4.tmp
10-10 14:27:43.490 417 592 E CameraSource: Video dimension (1920x1080) is unsupported
10-10 14:27:43.490 1511 1511 E MediaRecorder: start failed: -19
10-10 14:27:43.491 1511 1511 E CAM_VideoModule: Could not start media recorder.
修改device/rockchip/rk3399/media_profiles_default.xml文件,
修改前前置摄像头视频为 HD1080P HD720P CIF
修改后前置摄像头视频为 HD720 SD480P QVGA
问题4: 关于数据链路的确定
如何使用 v4l2 获取底层数据流?
4.8.1 首先配置链路 First configure the link
目前 RK 的 Camera 驱动使用的 media-ctl 框架,有以下四种常见链路:
1、 MIPI-RAW-Sensor -> MIPI 接口->ISP
2、 MIPI-YUV-Sensor -> MIPI 接口->ISP
3、 Parallel-Sensor ->ISP
4、 Parallel-Sensor ->CIF其中MIPI-RAW-Sensor -> MIPI interface->ISP对应的链路图为
配置链路命令如下:(设备树都配置过了,一般不用手动配置)
media-ctl -l '"ov5648 2-0036":0->"rockchip-mipi-dphy-rx":0[1]' //设备树只有 mipi-dphy-rx0
media-ctl -l '"rockchip-mipi-dphy-rx":1->"rkisp1-isp-subdev":0[1]' //设备树有 rkisp1_0 和 rkisp1_1 ,都试试看看那个可用
配置好后,使用 media-ctl -p 命令查看如下:会显示 ENABLED(下同),说明链路配置连接成功。
打开log开关后,可见如下的绑定关系
10-09 10:38:45.761 290 455 I RkCamera: <HAL> MediaController: @configureLink: disable "m00_f_ov8858 1-0036" [0] --> "rockchip-mipi-dphy-rx" [0]
10-09 10:38:45.761 290 455 I RkCamera: <HAL> MediaController: @setupLink
10-09 10:38:45.761 290 455 I RkCamera: <HAL> MediaController: @enumLinks
10-09 10:38:45.762 290 455 I RkCamera: <HAL> MediaEntity: @updateLinks
10-09 10:38:45.762 290 455 I RkCamera: <HAL> MediaEntity: link 0: pad 0 --> sink entity 7:0 (disabled)
10-09 10:38:45.762 290 455 D RkCamera: <HAL> MediaCtlHelper: @resetLinks
10-09 10:38:45.762 290 455 I RkCamera: <HAL> MediaController: @configureLink: disable "rockchip-mipi-dphy-rx" [1] --> "rkisp1-isp-subdev" [0]
tab23_rk99_fr:/ # media-ctl -p
........
........
- entity 7: rockchip-mipi-dphy-rx (2 pads, 2 links)
type V4L2 subdev subtype Unknown
device node name /dev/v4l-subdev1
pad0: Sink
[fmt:SBGGR10/3264x2448]
<- "m00_f_ov8858 1-0036":0 [ENABLED]
pad1: Source
[fmt:SBGGR10/3264x2448]
-> "rkisp1-isp-subdev":0 [ENABLED]
- entity 8: m00_f_ov8858 1-0036 (1 pad, 1 link)
type V4L2 subdev subtype Sensor
device node name /dev/v4l-subdev2
pad0: Source
[fmt:SBGGR10/3264x2448]
-> "rockchip-mipi-dphy-rx":0 [ENABLED]
camera hal3 的 LOG 抓取
打开 camerahal 的 debug 命令;
setprop persist.vendor.camera.hal.debug 5
关闭命令
setprop persist.vendor.camera.hal.debug 0
参考资料:rk3566 ov8858摄像头调试
最后
以上就是追寻招牌为你收集整理的RK3399适配OV8858摄像头OV8858主要信息设备树修改 添加编译设置修改上电时序修改摄像头配置文件的全部内容,希望文章能够帮你解决RK3399适配OV8858摄像头OV8858主要信息设备树修改 添加编译设置修改上电时序修改摄像头配置文件所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复