RAW Sensor (V4L2 Sensor)

Note

All command operations presented in this chapter are based on the IoT Yocto v24.1, Genio 1200-EVK and Sony IMX214 sensor. You might get different operation results depending on the platform you use.

This chapter shows how to receive RAW (bayer) sensor data and directly dump it to the DRAM under V4L2 Sensor architecture on Genio 1200-EVK. There are 6x camera DMA engines in Genio 1200.

Note

The purpose of capturing bayer frames is to verify the hardware pathway before getting started with imgsensor integration for a given sensor.

Camera Package and Specification

The RAW camera DTB for Genio 1200-EVK is CAM DTB-D2. It contains a SONY IMX214 CMOS Image Sensor.

../../../../_images/sw_yocto_app-dev_camera_cam-dtb-d2.jpeg

Camera DTB D2 - SONY IMX214 Sensor

Connect The Camera to the EVK

There are 3 MIPI-CSI slots on Genio 1200-EVK, which are CSI0, CSI1, and CSI2. In the following figure, the camera DTB is connected to the CSI0 slot.

../../../../_images/sw_yocto_app-dev_camera_g1200_connect-d2.png

Connect Camera DTB D2 to Genio 1200-EVK (Schematic)

../../../../_images/sw_yocto_app-dev_camera_g1200-p1v2_connect-cam.jpeg

Connect Camera DTB D2 to Genio 1200-EVK (Entity)

Note

All three CSI slots are available. The user can connect the camera sensor to any slot.

Select Camera Device Tree Blob Overlay

The camera device is inactive by default, so the kernel has to load a specific device tree blob overlay to enable it. Please refer to bl33u-boot for more details.

Raw Camera DTBO for Genio 1200-EVK

Platform

CSI0

CSI1

CSI2

DTBO

Usage

Genio 1200-EVK

IMX214

x

x

camera-imx214-csi0-std.dtbo

Enable 4-lane CAM-DTB-D2 w/ Sony IMX214 on CSI0 using standard V4L2 driver

Genio 1200-EVK

x

IMX214

x

camera-imx214-csi1-std.dtbo

Enable 4-lane CAM-DTB-D2 w/ Sony IMX214 on CSI1 using standard V4L2 driver

Genio 1200-EVK

x

x

IMX214

camera-imx214-csi2-std.dtbo

Enable 4-lane CAM-DTB-D2 w/ Sony IMX214 on CSI2 using standard V4L2 driver

genio-flash --list-dtbo
List of available DTBO:
        - camera-imx214-csi0-std.dtbo
        - camera-imx214-csi1-std.dtbo
        - camera-imx214-csi2-std.dtbo
        - ...
genio-flash --load-dtbo camera-imx214-csi0-std.dtbo --load-dtbo gpu-mali.dtbo --load-dtbo apusys.dtbo --load-dtbo video.dtbo

Warning

Please select the DTBO according to the CSI slot to which the camera sensor is connected. For example, if the camera is connected to the CSI0 slot, please load the dtbo camera-imx214-csi0-std.dtbo. Otherwise, the camera initialization will fail.

Supported Formats and Sizes

The array of supported formats and sizes depends on the IMX214 driver in the linux kernel.

Supported sizes:

  1. 4096x2304

  2. 1920x1080

Supported formats:

  1. SRGGB10

Media Device

The media device represents the internal topology of a media system like ISP. The topology setting including links, pads, and entities can be set through the media device. Therefore, the first step is to find the target media device node.

export MEDIA_DEV=$(v4l2-ctl -z platform:$(basename `find /sys/bus/platform/devices/ -name "*camisp"`) --list-devices | grep media)
echo ${MEDIA_DEV}
/dev/media3

Warning

The assigned node number for the media device may vary depending on the sequence of the probing process during the boot-up phase. As such, it is crucial to ensure the accuracy of the media device node before using the camera.

Video Device

The video device is the interface for users to obtain the images. On Genio 1200-EVK, they are called mtk-cam camsv-* main-stream. The media-ctl is a useful tool to list video devices.

declare -a VIDEO_DEV=(`for i in {0..5}; do media-ctl -d ${MEDIA_DEV} --entity "mtk-cam camsv-$i main-stream"; done | tr "\n" " "`)
echo ${VIDEO_DEV[*]}
/dev/video53 /dev/video54 /dev/video55 /dev/video56 /dev/video57 /dev/video58

Warning

The assigned node number for the video device may vary depending on the sequence of the probing process during the boot-up phase. As such, it is crucial to ensure the accuracy of the video device node before using the camera.

Launch Camera

The initial step is to link all the necessary components within the media device. The structure of the YUV camera pipeline is quite straightforward. It fundamentally incorporates only three components: the sensor, SENINF, and CAMSV.

media-ctl -d ${MEDIA_DEV} -l "'seninf-0':1 -> 'mtk-cam camsv-0':0 [5]"
media-ctl -d ${MEDIA_DEV} -l "'imx214 0-001a':0 -> 'seninf-0':0 [1]"

The second step is to assign the correct format and size to each component incorporated in the camera pipeline.

media-ctl -d ${MEDIA_DEV} -V "'imx214 0-001a':0 [fmt:SRGGB10_1X10/1920x1080 field:none]"
media-ctl -d ${MEDIA_DEV} -V "'seninf-0':1 [fmt:SRGGB10_1X10/1920x1080 field:none]"
media-ctl -d ${MEDIA_DEV} -V "'mtk-cam camsv-0':1 [fmt:SRGGB10_1X10/1920x1080 field:none]"

For the third step, it’s necessary to identify the correct video device node. For further information on this, please refer to Video Device.

declare -a VIDEO_DEV=(`for i in {0..5}; do media-ctl -d ${MEDIA_DEV} --entity "mtk-cam camsv-$i main-stream"; done | tr "\n" " "`)
echo ${VIDEO_DEV[*]}
/dev/video53 /dev/video54 /dev/video55 /dev/video56 /dev/video57 /dev/video58

Important

You have to select the video node that corresponds to the CAMSV instance linked in the second step. In this given example, mtk-cam camsv-0 is the linked instance, hence the video device node should be ${VIDEO_DEV[0]} or /dev/video53.

Lastly, to activate the camera, the user can use v4l2-ctl, gst-launch-1.0, or other V4L2 applications.

  • Use v4l2-ctl

    v4l2-ctl -d ${VIDEO_DEV[0]} --set-fmt-video=width=1920,height=1080,pixelformat=MBRA --stream-mmap --stream-count=10 --stream-to=/tmp/ap1302.yuv --verbose
    
  • Use gst-launch-1.0

    gst-launch-1.0 v4l2src device=${VIDEO_DEV[0]} ! video/x-bayer,width=1920,height=1080,format=rggb ! bayer2rgb ! waylandsink sync=false
    

Note

The output captured or displayed through the raw sensor pipeline may appear discolored or dark because it lacks ISP processing.