1. Camera

  • Hardware interface

_images/usage_camera_mipicsi.jpg

1.1. MIPI CSI

RK3576 platform has one DCPHY and two DPHY. DPHY can work in two modes: full mode and split mode; DCPHY only has full mode.

In short, if we use single-camera, we can set dphy to full mode, if we use dual-camera, we can set dphy to split mode.

1.2. Full Mode Configuration

AIO-3576JD4 has 3 mipi-dsi interfaces, their link paths:

MIPI-CSI0: csi2_dphy0 --> mipi1_csi2 --> rkcif_mipi_lvds1
MIPI-CSI1: csi2_dphy3 --> mipi3_csi2 --> rkcif_mipi_lvds3
MIPI-CSI2: csi2_dcphy0 --> mipi0_csi2 --> rkcif_mipi_lvds

Refer to these dts for details:

rk3576-firefly-aio-3576jd4-cam0-8ms1m.dtsi
rk3576-firefly-aio-3576jd4-cam1-8ms1m.dtsi
rk3576-firefly-aio-3576jd4-cam2-8ms1m.dtsi

CAM0 and CAM1 can not be used at same time, there’s a switch in rk3576-firefly-aio-3576jd4.dts can change between CAM0/1

#define CAM1_OR_CAM0 0 /* 1 = CAM1, 0 = CAM0 */

1.3. Camera Debug

Use v4l2-ctl to capture camera frame data

v4l2-ctl --verbose -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='NV12' --stream-mmap=4 --set-selection=target=crop,flags=0,top=0,left=0,width=1920,height=1080 --stream-to=/data/out.yuv

Copy file out.yuv to ubuntu to play

ffplay -f rawvideo -video_size 1920x1080 -pix_fmt nv12 out.yuv

1.4. Android Use Camera App

In addition to the official default supported cameras, To open camera with camera app in Android needs configuring in camera3_profiles*.xml. For details please refer to files in Android SDK under hardware/rockchip/camera/etc/camera.

1.5. Linux Preview Camera

Ubuntu firmware can use this script to view camera stream:

#!/bin/bash

export DISPLAY=:0.0
export XDG_RUNTIME_DIR=/run/user/1000
echo "Start MIPI CSI Camera Preview!"

gst-launch-1.0 v4l2src device=/dev/video0 ! queue ! video/x-raw,width=800,height=600 ! videoconvert ! xvimagesink