.. include:: /keyword.rst .. _feature-g700-cam-v4l2-raw-sensor: ======================== RAW Sensor (V4L2 Sensor) ======================== .. important:: All the bash commands shown here are based on |G510-G700-EVK|. For |G510-EVK|, users can follow the same step to do the whole setup by changing the naming term from `700` to `510`. .. contents:: Sections :local: :depth: 2 .. note:: All command operations presented in this chapter are based on the IoT Yocto v24.1, |G700-EVK-REF-BOARD| 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 |G510-G700-EVK|. There are 8x camera DMA engines in Genio 510/700. .. 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 |G510-G700-EVK| is ``CAM DTB-D2``. It contains a SONY IMX214 CMOS Image Sensor. .. figure:: /_asset/sw_yocto_app-dev_camera_cam-dtb-d2.jpeg :align: center :scale: 30% Camera DTB D2 - SONY IMX214 Sensor Connect The Camera to the EVK ----------------------------- There are 2 MIPI-CSI slots on |G510-G700-EVK|, which are ``CSI0`` and ``CSI1``. In the following figure, the camera DTB is connected to the ``CSI0`` slot. .. figure:: /_asset/sw_yocto_app-dev_camera_g700_connect-d2.png :align: center :scale: 30% Connect Camera DTB D2 to |G510-G700-EVK| (Schematic) .. figure:: /_asset/sw_yocto_app-dev_camera_g700-p1v3_connect-cam.jpeg :align: center :scale: 30% Connect Camera DTB D2 to |G510-G700-EVK| (Entity) .. note:: All three CSI slots are available. The user can connect the camera sensor to any slot. .. _feature-g700-cam-imx214-raw: 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. .. csv-filter:: Raw Camera DTBO for |G510-G700-EVK| :header-rows: 1 :file: ../../../../_asset/tables/camera-platform-sensor-dtbo.csv :include: {0: 'Genio 510\/700-EVK'} :exclude: {5: '[^0.*]', 6: '[^1.*]'} :included_cols: 0,1,2,4,7 .. prompt:: bash > auto > genio-flash --list-dtbo List of available DTBO: - camera-imx214-csi0-std.dtbo - camera-imx214-csi1-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: #. 4096x2304 #. 1920x1080 Supported formats: #. 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. .. prompt:: bash # auto # 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 |G510-G700-EVK|, they are called ``mtk-cam camsv-* main-stream``. The ``media-ctl`` is a useful tool to list video devices. .. prompt:: bash # auto # declare -a VIDEO_DEV=(`for i in {0..7}; 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 /dev/video59 /dev/video60 .. 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 RAW camera pipeline is quite straightforward. It fundamentally incorporates only three components: the sensor, SENINF, and CAMSV. .. prompt:: bash # auto # media-ctl -d ${MEDIA_DEV} -l "'seninf-0':1 -> 'mtk-cam camsv-0':0 [5]" # media-ctl -d ${MEDIA_DEV} -l "'imx214 5-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. .. prompt:: bash # auto # media-ctl -d ${MEDIA_DEV} -V "'imx214 5-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`_. .. prompt:: bash # auto # declare -a VIDEO_DEV=(`for i in {0..7}; 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 /dev/video59 /dev/video60 .. 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`` .. prompt:: bash # auto # v4l2-ctl -d ${VIDEO_DEV[0]} --set-fmt-video=width=1920,height=1080,pixelformat=MBRA --stream-mmap --stream-count=10 --stream-to=/tmp/imx214.raw --verbose - Use ``gst-launch-1.0`` .. prompt:: bash # auto # 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.