# 【Doc】Camera Porting - OS08A20 ###### tags: `Camera`,`i.MX8MP` --- #### Platform [i.MX 8M Plus](https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i-mx-applications-processors/i-mx-8-applications-processors/i-mx-8m-plus-arm-cortex-a53-machine-learning-vision-multimedia-and-industrial-iot:IMX8MPLUS) ![](https://i.imgur.com/aPUks4s.png) --- #### Porting Method * Change Device Tree at boot model ``` $ fatls mmc 1:1 $ env set fdtfile imx8mp-evk-os08a20.dtb $ env save $ boot ``` --- #### Device status * v4l2-ctl --list-devices ``` root@imx8mpevk:~# v4l2-ctl --list-devices (): /dev/v4l-subdev0 /dev/v4l-subdev2 /dev/v4l-subdev3 (csi0): /dev/v4l-subdev1 FSL Capture Media Device (platform:mxc-md): /dev/media0 VIV (platform:viv0): /dev/video2 vsi_v4l2dec (platform:vsi_v4l2dec): /dev/video1 vsi_v4l2enc (platform:vsi_v4l2enc): /dev/video0 viv_media (platform:vvcam-video): /dev/media1 ``` Note : we need to find viv device (32e00000, **/dev/video2**) --- ##### OS08A20 Status * v4l2-ctl --device=/dev/video2 --all ```c root@imx8mpevk:~# v4l2-ctl --device=/dev/video2 --all Driver Info: Driver name : viv_v4l2_device Card type : VIV Bus info : platform:viv0 Driver version : 5.15.71 Capabilities : 0x84201001 Video Capture Video Capture Multiplanar Streaming Extended Pix Format Device Capabilities Device Caps : 0x04200001 Video Capture Streaming Extended Pix Format Media Driver Info: Driver name : vvcam-video Model : viv_media Serial : Bus info : Media version : 5.15.71 Hardware revision: 0x00000000 (0) Driver version : 5.15.71 Interface Info: ID : 0x03000003 Type : V4L Video Entity Info: ID : 0x00000001 (1) Name : viv_v4l20 Function : V4L2 I/O Pad 0x01000002 : 0: Sink, Must Connect Link 0x02000010: from remote pad 0x1000008 of entity 'vvcam-dwe.0' (V4L2 I/O): Data, Enabled Priority: 2 Video input : 0 (camera: ok) Format Video Capture: Width/Height : 3840/2160 Pixel Format : 'YUYV' (YUYV 4:2:2) Field : None Bytes per Line : 7680 Size Image : 16588800 Colorspace : Rec. 709 Transfer Function : Default (maps to Rec. 709) YCbCr/HSV Encoding: Default (maps to Rec. 709) Quantization : Default (maps to Limited Range) Flags : Crop Capability Video Capture: Bounds : Left 0, Top 0, Width 3840, Height 2160 Default : Left 0, Top 0, Width 3840, Height 2160 Pixel Aspect: 1/1 Selection Video Capture: crop, Left 0, Top 0, Width 3840, Height 2160, Flags: Selection Video Capture: crop_default, Left 0, Top 0, Width 3840, Height 2160, Flags: Selection Video Capture: crop_bounds, Left 0, Top 0, Width 3840, Height 2160, Flags: Selection Video Capture: compose, Left 0, Top 0, Width 3840, Height 2160, Flags: Selection Video Capture: compose_default, Left 0, Top 0, Width 3840, Height 2160, Flags: Selection Video Capture: compose_bounds, Left 0, Top 0, Width 3840, Height 2160, Flags: Streaming Parameters Video Capture: Capabilities : timeperframe Frames per second: 30.000 (30/1) Read buffers : 0 ``` ##### OS08A20 Device topology * media-ctl -p ```c root@imx8mpevk:~# media-ctl -p Media controller API version 5.15.71 Media device information ------------------------ driver mxc-md model FSL Capture Media Device serial bus info hw revision 0x0 driver version 5.15.71 Device topology - entity 1: mxc-mipi-csi2.0 (8 pads, 1 link) type Node subtype V4L flags 0 device node name /dev/v4l-subdev0 pad0: Sink <- "os08a20 1-0036":0 [ENABLED,IMMUTABLE] pad1: Sink pad2: Sink pad3: Sink pad4: Source pad5: Source pad6: Source pad7: Source - entity 10: os08a20 1-0036 (1 pad, 1 link) type V4L2 subdev subtype Sensor flags 0 device node name /dev/v4l-subdev1 pad0: Source [fmt:SBGGR12_1X12/3840x2160 field:none] -> "mxc-mipi-csi2.0":0 [ENABLED,IMMUTABLE] ``` ##### OS08A20 Dmesg * dmesg | grep os08a20 ```cpp root@op-kiler-kivy:~# dmesg | grep os08a20 [ 7.236686] os08a20: loading out-of-tree module taints kernel. [ 7.252568] enter os08a20_probe [ 7.256505] os08a20 1-0036: No sensor pwdn pin available [ 7.268777] os08a20 1-0036: No sensor reset pin available [ 7.327265] os08a20 1-0036: supply DOVDD not found, using dummy regulator [ 7.337253] os08a20 1-0036: supply DVDD not found, using dummy regulator [ 7.349458] os08a20 1-0036: supply AVDD not found, using dummy regulator [ 7.390045] os08a20_probe camera mipi os08a20, is found [ 7.448104] mx8-img-md: Registered sensor subdevice: os08a20 1-0036 (1) [ 7.469003] mx8-img-md: created link [os08a20 1-0036] => [mxc-mipi-csi2.0] [ 9.409621] enter os08a20_remove [ 10.613002] enter os08a20_probe [ 10.616195] os08a20 1-0036: No sensor pwdn pin available [ 10.621582] os08a20 1-0036: No sensor reset pin available [ 10.621630] os08a20 1-0036: supply DOVDD not found, using dummy regulator [ 10.622366] os08a20 1-0036: supply DVDD not found, using dummy regulator [ 10.640892] os08a20 1-0036: supply AVDD not found, using dummy regulator [ 10.650426] os08a20_probe camera mipi os08a20, is found [ 10.704667] mx8-img-md: Registered sensor subdevice: os08a20 1-0036 (1) [ 10.711321] mx8-img-md: created link [os08a20 1-0036] => [mxc-mipi-csi2.0] ``` --- * sub-device ```c++ root@op-kiler-kivy:~# v4l2-ctl --log-status -d /dev/v4l-subdev0 [ 5579.325750] os08a20 1-0036: ================= START STATUS ================= [ 5579.333013] os08a20 1-0036: ================== END STATUS ================== VIDIOC_LOG_STATUS: failed: Inappropriate ioctl for device ``` ```c++ root@op-kiler-kivy:~# v4l2-ctl --log-status -d /dev/v4l-subdev2 [ 5399.971187] vvcam-isp.0: ================= START STATUS ================= [ 5399.978177] vvcam-isp.0: ================== END STATUS ================== [ 5399.985278] unsupported command -1070836166 [ 5399.985293] unsupported command -1070836166 [ 5399.989551] enter isp_mi_stop VIDIOC_LOG_STATUS: failed: Inappropriate ioctl for device ``` ```c++ root@op-kiler-kivy:~# v4l2-ctl --log-status -d /dev/v4l-subdev3 [ 5495.432463] vvcam-dwe.0: ================= START STATUS ================= [ 5495.439466] vvcam-dwe.0: ================== END STATUS ================== VIDIOC_LOG_STATUS: failed: Inappr[ 5495.446532] unsupported dwe command -1070836166 ``` --- #### Camera format * OS08A20 format : ```c root@imx8mpevk:~# v4l2-ctl -d /dev/video2 --list-formats-ext ioctl: VIDIOC_ENUM_FMT Type: Video Capture [0]: 'YUYV' (YUYV 4:2:2) Size: Stepwise 176x144 - 4096x3072 with step 16/8 [1]: 'NV12' (Y/CbCr 4:2:0) Size: Stepwise 176x144 - 4096x3072 with step 16/8 [2]: 'NV16' (Y/CbCr 4:2:2) Size: Stepwise 176x144 - 4096x3072 with step 16/8 [3]: 'BG12' (12-bit Bayer BGBG/GRGR) Size: Stepwise 176x144 - 4096x3072 with step 16/8 ``` --- #### XML format * OS08A20 format : <font size=1 color=gray> /opt/imx8-isp/bin/OS08a20_8M_10_1080p_hdr.xml </font> ``` <?xml version="1.0" ?> <matfile> <header type="struct" size="[1 1]"> <creation_date index="1" type="char" size="[1 11]">21-Jul-2022</creation <creator index="1" type="char" size="[1 4]">Alan</creator> <sensor_name index="1" type="char" size="[1 7]">OS08a20</sensor_name> <sample_name index="1" type="char" size="[1 33]">8Mlens_OS08a20_8M_11_10 <generator_version index="1" type="char" size="[1 7]">v2.0.19</generator <resolution index="1" type="cell" size="[1 1]"> <cell index="1" type="struct" size="[1 1]"> <name index="1" type="char" size="[1 9]">1920x1080</name> <id index="1" type="char" size="[1 10]">0x00000001</id> <width index="1" type="double" size="[1 1]">[ 1920]</width> <height index="1" type="double" size="[1 1]">[ 1080]</height> <framerate index="1" type="cell" size="[1 3]"> <cell index="1" type="struct" size="[1 1]"> <name index="1" type="char" size="[1 6]">FPS_15</name> <fps index="1" type="double" size="[1 1]">[ 14.9916]</fp </cell> <cell index="2" type="struct" size="[1 1]"> <name index="1" type="char" size="[1 6]">FPS_10</name> <fps index="1" type="double" size="[1 1]">[ 9.9944]</fps </cell> ... --- #### Eable Debug * Info : ``` $ dmesg -n 8 $ echo "8 4 1 7" > /proc/sys/kernel/printk ``` --- #### Uasge Method * Gstreamer * YUV (Default) ```C $ GST_DEBUG=3 gst-launch-1.0 v4l2src device=/dev/video2 ! fpsdisplaysink device=/dev/video2 ! fpsdisplaysink [ 239.836296] enter isp_mi_stop Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Pipeline is PREROLLED ... Setting pipeline to PLAYING ... New clock: GstSystemClock [ 240.263955] enter isp_mi_stop [ 240.378949] enter isp_s_comp [ 240.381869] enter isp_s_comp [ 240.384775] enter isp_s_comp [ 240.403838] enter wdr3_hw_init [ 240.406906] wdr3 res: 3840 2160 [ 240.444164] enter isp_set_stream 1 [ 240.467031] enter isp_mi_start ``` * YUV (modify resolution) ``` $ gst-launch-1.0 v4l2src device=/dev/video2 ! "video/x-raw,format=YUY2,width=1280,height=720,framerate=30/1" ! fpsdisplaysink ``` * YUV (DMA test) ``` $ gst-launch-1.0 v4l2src device=/dev/video2 num-buffers=500 io-mode=dmabuf ! "video/x-raw,format=RGB3,width=1280,height=720,framerate=(fraction)30/1" ! fpsdisplaysink ``` * RGB (DMA test) ``` $ gst-launch-1.0 v4l2src device=/dev/video2 num-buffers=500 io-mode=dmabuf ! "video/x-raw,format=YUY2,width=1280,height=720,framerate=(fraction)30/1" ! fpsdisplaysink ``` * **Gstreamer (ISP)** **How to setting fps speed** * modify Sensor0_Entry.cfg ``` name = "os08a20" drv = "os08a20.drv" mode = 2 [mode.0] xml = "OS08a20_8M_10_1080p_linear.xml" dwe = "dewarp_config/sensor_dwe_os08a20_1080P_config.json" [mode.1] xml = "OS08a20_8M_10_1080p_hdr.xml" dwe = "dewarp_config/sensor_dwe_os08a20_1080P_config.json" [mode.2] xml = "OS08a20_8M_10_4k_linear.xml" dwe = "dewarp_config/sensor_dwe_os08a20_4K_config.json" [mode.3] xml = "OS08a20_8M_10_4k_hdr.xml" dwe = "dewarp_config/sensor_dwe_os08a20_4K_config.json" ``` * modify xml ```c <cell index="4" type="struct" size="[1 1]"> <name index="1" type="char" size="[1 6]">FPS_06</name> fps index="1" type="double" size="[1 1]">[ 59.9972]</fps> </cell> ``` * running ``` $ gst-launch-1.0 v4l2src device=/dev/video2 ! "video/x-raw,format=YUY2,width=1280,height=720,framerate=60/1" ! fpsdisplaysink ``` ![](https://i.imgur.com/2CtBK39.png)