/boot/hw_intfc.conf
intfc:spi1=on
# Add imx219 camera module support. Need disabled ov5647 camera module.
intfc:dtoverlay=imx219
dmesg | grep imx
[ 2.599576] imx219 4-0010: GPIO lookup for consumer pwdn
[ 2.599587] imx219 4-0010: using device tree for GPIO lookup
[ 2.649799] imx219 4-0010: Model ID 0x0219, Lot ID 0x1c8b77, Chip ID 0x087c
cat test_camera-rkisp1.sh
#!/bin/sh
export DISPLAY=:0.0
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/aarch64-linux-gnu/gstreamer-1.0
export GST_DEBUG=ispsrc:5
export GST_DEBUG_FILE=/tmp/2.txt
echo "Start RKISP Camera Preview!"
su linaro -c " \
gst-launch-1.0 rkv4l2src device=/dev/video0 ! video/x-raw,format=NV12,width=1920,height=1080, framerate=30/1 ! videoconvert ! autovideosink"
kernel module (built-in, lsmod shows):
https://github.com/54shady/qop_kernel/blob/master/drivers/media/i2c/imx219.c
gst-launch:
https://gstreamer.freedesktop.org/documentation/tools/gst-launch.html?gi-language=c
v4l2src
https://people.freedesktop.org/~tsaunier/documentation/video4linux2-1.0/v4l2src.html?gi-language=c
opencv (deps hell)
https://www.geeksforgeeks.org/how-to-capture-a-image-from-webcam-in-python/
Result dark green sh!t, from official rockchip documentation:
gst-launch-1.0 rkv4l2src device=/dev/video0 io-mode=4 isp-mode=2A ! videoconvert ! video/x-raw,format=NV12,width=1920,height=1080 ! jpegenc ! multifilesink location=%d.jpg
Official rockchip documentation:
https://usermanual.wiki/Document/RockchipC2A0Linux20CameraC2A0Developer20Guide20V11.324153775/html
sudo echo 1 > /sys/module/video_rkisp1/parameters/debug
Driver Info (not using libv4l2):
Driver name : rkisp1
Card type : rkisp1_mainpath
Bus info : platform:ff910000.rkisp1
Driver version: 4.4.154
Capabilities : 0x84201000
Video Capture Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04201000
Video Capture Multiplanar
Streaming
Extended Pix Format
root@linaro-alip:/home/linaro# media-ctl --known-mbus-fmts
RGB444_1X12 0x1016
RGB444_2X8_PADHI_BE 0x1001
RGB444_2X8_PADHI_LE 0x1002
RGB555_2X8_PADHI_BE 0x1003
RGB555_2X8_PADHI_LE 0x1004
RGB565_1X16 0x1017
BGR565_2X8_BE 0x1005
BGR565_2X8_LE 0x1006
RGB565_2X8_BE 0x1007
RGB565_2X8_LE 0x1008
RGB666_1X18 0x1009
RBG888_1X24 0x100e
RGB666_1X24_CPADHI 0x1015
RGB666_1X7X3_SPWG 0x1010
BGR888_1X24 0x1013
GBR888_1X24 0x1014
RGB888_1X24 0x100a
RGB888_2X12_BE 0x100b
RGB888_2X12_LE 0x100c
RGB888_1X7X4_SPWG 0x1011
RGB888_1X7X4_JEIDA 0x1012
ARGB8888_1X32 0x100d
RGB888_1X32_PADHI 0x100f
Y8_1X8 0x2001
UV8_1X8 0x2015
UYVY8_1_5X8 0x2002
VYUY8_1_5X8 0x2003
YUYV8_1_5X8 0x2004
YVYU8_1_5X8 0x2005
UYVY8_2X8 0x2006
VYUY8_2X8 0x2007
YUYV8_2X8 0x2008
YVYU8_2X8 0x2009
Y10_1X10 0x200a
UYVY10_2X10 0x2018
VYUY10_2X10 0x2019
YUYV10_2X10 0x200b
YVYU10_2X10 0x200c
Y12_1X12 0x2013
UYVY12_2X12 0x201c
VYUY12_2X12 0x201d
YUYV12_2X12 0x201e
YVYU12_2X12 0x201f
UYVY8_1X16 0x200f
VYUY8_1X16 0x2010
YUYV8_1X16 0x2011
YVYU8_1X16 0x2012
YDYUYDYV8_1X16 0x2014
UYVY10_1X20 0x201a
VYUY10_1X20 0x201b
YUYV10_1X20 0x200d
YVYU10_1X20 0x200e
VUY8_1X24 0x2024
YUV8_1X24 0x2025
UYVY12_1X24 0x2020
VYUY12_1X24 0x2021
YUYV12_1X24 0x2022
YVYU12_1X24 0x2023
YUV10_1X30 0x2016
AYUV8_1X32 0x2017
SBGGR8_1X8 0x3001
SGBRG8_1X8 0x3013
SGRBG8_1X8 0x3002
SRGGB8_1X8 0x3014
SBGGR10_ALAW8_1X8 0x3015
SGBRG10_ALAW8_1X8 0x3016
SGRBG10_ALAW8_1X8 0x3017
SRGGB10_ALAW8_1X8 0x3018
SBGGR10_DPCM8_1X8 0x300b
SGBRG10_DPCM8_1X8 0x300c
SGRBG10_DPCM8_1X8 0x3009
SRGGB10_DPCM8_1X8 0x300d
SBGGR10_2X8_PADHI_BE 0x3003
SBGGR10_2X8_PADHI_LE 0x3004
SBGGR10_2X8_PADLO_BE 0x3005
SBGGR10_2X8_PADLO_LE 0x3006
SBGGR10_1X10 0x3007
SGBRG10_1X10 0x300e
SGRBG10_1X10 0x300a
SRGGB10_1X10 0x300f
SBGGR12_1X12 0x3008
SGBRG12_1X12 0x3010
SGRBG12_1X12 0x3011
SRGGB12_1X12 0x3012
SBGGR14_1X14 0x3019
SGBRG14_1X14 0x301a
SGRBG14_1X14 0x301b
SRGGB14_1X14 0x301c
SBGGR16_1X16 0x301d
SGBRG16_1X16 0x301e
SGRBG16_1X16 0x301f
SRGGB16_1X16 0x3020
JPEG_1X8 0x4001
S5C_UYVY_JPEG_1X8 0x5001
AHSV8888_1X32 0x6001
root@linaro-alip:/home/linaro# media-ctl -d /dev/media0 -p
Media controller API version 0.1.0
Media device information
------------------------
driver rkisp1
model rkisp1
serial
bus info
hw revision 0x0
driver version 0.0.0
Device topology
- entity 1: rkisp1-isp-subdev (4 pads, 5 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev0
pad0: Sink
[fmt:SBGGR10_1X10/800x600 field:none
crop.bounds:(0,0)/800x600
crop:(0,0)/800x600]
<- "rockchip-sy-mipi-dphy":1 [ENABLED]
pad1: Sink
<- "rkisp1-input-params":0 [ENABLED]
pad2: Source
[fmt:YUYV8_2X8/800x600 field:none
crop.bounds:(0,0)/800x600
crop:(0,0)/800x600]
-> "rkisp1_selfpath":0 [ENABLED]
-> "rkisp1_mainpath":0 [ENABLED]
pad3: Source
-> "rkisp1-statistics":0 [ENABLED]
- entity 2: rkisp1_mainpath (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video0
pad0: Sink
<- "rkisp1-isp-subdev":2 [ENABLED]
- entity 3: rkisp1_selfpath (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video1
pad0: Sink
<- "rkisp1-isp-subdev":2 [ENABLED]
- entity 4: rkisp1-statistics (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video2
pad0: Sink
<- "rkisp1-isp-subdev":3 [ENABLED]
- entity 5: rkisp1-input-params (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video3
pad0: Source
-> "rkisp1-isp-subdev":1 [ENABLED]
- entity 6: rockchip-sy-mipi-dphy (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev1
pad0: Sink
[fmt:SRGGB10_1X10/1920x1080 field:none]
<- "imx219 4-0010":0 [ENABLED]
pad1: Source
[fmt:SRGGB10_1X10/1920x1080 field:none]
-> "rkisp1-isp-subdev":0 [ENABLED]
- entity 7: imx219 4-0010 (1 pad, 1 link)
type V4L2 subdev subtype Sensor flags 0
device node name /dev/v4l-subdev2
pad0: Source
[fmt:SRGGB10_1X10/1920x1080 field:none]
-> "rockchip-sy-mipi-dphy":0 [ENABLED]
linaro@linaro-alip:~$ gst-inspect-1.0 rkv4l2src
Factory Details:
Rank primary (256)
Long-name Rockchip Video (video4linux2) Source
Klass Source/Video
Description Reads frames from a Rockchip Video4Linux2 device
Author Leo Wen <leo.wen@rock-chips.com>
Plugin Details:
Name rkv4l2
Description Rockchip elements for Video 4 Linux
Filename /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstrkv4l2.so
Version 1.10.4
License LGPL
Source module gst-plugins-good
Source release date 2017-02-23
Binary package GStreamer Good Plug-ins source release
Origin URL Unknown package origin
GObject
+----GInitiallyUnowned
+----GstObject
+----GstElement
+----GstBaseSrc
+----GstPushSrc
+----GstRKV4l2Src
Implemented Interfaces:
GstURIHandler
Pad Templates:
SRC template: 'src'
Availability: Always
Capabilities:
image/jpeg
video/mpeg
mpegversion: 4
systemstream: false
video/mpeg
mpegversion: 2
video/mpegts
systemstream: true
video/x-bayer
format: { bggr, gbrg, grbg, rggb }
width: [ 1, 32768 ]
height: [ 1, 32768 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-dv
systemstream: true
video/x-h263
variant: itu
video/x-h264
stream-format: { byte-stream, avc }
alignment: au
video/x-pwc1
width: [ 1, 32768 ]
height: [ 1, 32768 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-pwc2
width: [ 1, 32768 ]
height: [ 1, 32768 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-raw
format: { RGB16, BGR, RGB, GRAY8, GRAY16_LE, GRAY16_BE, YVU9, YV12, YUY2, YVYU, UYVY, Y42B, Y41B, YUV9, NV12_64Z32, NV24, NV61, NV16, NV21, NV12, I420, BGRA, BGRx, ARGB, xRGB, BGR15, RGB15 }
width: [ 1, 32768 ]
height: [ 1, 32768 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-sonix
width: [ 1, 32768 ]
height: [ 1, 32768 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-vp8
video/x-vp9
video/x-wmv
wmvversion: 3
format: WVC1
Element Flags:
no flags set
Element Implementation:
Has change_state() function: 0x7f8cf4d980
Element has no clocking capabilities.
URI handling capabilities:
Element can act as source.
Supported URI protocols:
v4l2
Pads:
SRC: 'src'
Pad Template: 'src'
Element Properties:
name : The name of the object
flags: readable, writable
String. Default: "rkv4l2src0"
parent : The parent of the object
flags: readable, writable
Object of type "GstObject"
blocksize : Size in bytes to read per buffer (-1 = default)
flags: readable, writable
Unsigned Integer. Range: 0 - 4294967295 Default: 4096
num-buffers : Number of buffers to output before sending EOS (-1 = unlimited)
flags: readable, writable
Integer. Range: -1 - 2147483647 Default: -1
typefind : Run typefind before negotiating
flags: readable, writable
Boolean. Default: false
do-timestamp : Apply current stream time to buffers
flags: readable, writable
Boolean. Default: false
device : Device location
flags: readable, writable
String. Default: "/dev/video0"
device-name : Name of the device
flags: readable
String. Default: null
device-fd : File descriptor of the device
flags: readable
Integer. Range: -1 - 2147483647 Default: -1
flags : Device type flags
flags: readable
Flags "GstRKV4l2DeviceTypeFlags" Default: 0x00000000, "(none)"
(0x00000001): capture - Device supports video capture
(0x00000002): output - Device supports video playback
(0x00000004): overlay - Device supports video overlay
(0x00000010): vbi-capture - Device supports the VBI capture
(0x00000020): vbi-output - Device supports the VBI output
(0x00020000): audio - Device has audio inputs or outputs
brightness : Picture brightness, or more precisely, the black level
flags: readable, writable, controllable
Integer. Range: -2147483648 - 2147483647 Default: 0
contrast : Picture contrast or luma gain
flags: readable, writable, controllable
Integer. Range: -2147483648 - 2147483647 Default: 0
saturation : Picture color saturation or chroma gain
flags: readable, writable, controllable
Integer. Range: -2147483648 - 2147483647 Default: 0
hue : Hue or color balance
flags: readable, writable, controllable
Integer. Range: -2147483648 - 2147483647 Default: 0
io-mode : I/O mode
flags: readable, writable
Enum "GstRKV4l2IOMode" Default: 0, "auto"
(0): auto - GST_V4L2_IO_AUTO
(1): rw - GST_V4L2_IO_RW
(2): mmap - GST_V4L2_IO_MMAP
(3): userptr - GST_V4L2_IO_USERPTR
(4): dmabuf - GST_V4L2_IO_DMABUF
(5): dmabuf-import - GST_V4L2_IO_DMABUF_IMPORT
extra-controls : Extra v4l2 controls (CIDs) for the device
flags: readable, writable
Boxed pointer of type "GstStructure"
pixel-aspect-ratio : Overwrite the pixel aspect ratio of the device
flags: readable, writable
String. Default: null
force-aspect-ratio : When enabled, the pixel aspect ratio will be enforced
flags: readable, writable
Boolean. Default: true
isp-mode :
flags: readable, writable
Enum "GstRk3AMode" Default: 0, "0A"
(0): 0A - RK_3A_DISABLE
(1): 2A - RK_3A_AEAWB
(2): 3A - RK_3A_AEAWBAF
xml-path :
flags: readable, writable
String. Default: "/etc/cam_iq.xml"
Element Signals:
"prepare-format" : void user_function (GstElement* object,
gint arg0,
GstCaps* arg1,
gpointer user_data);
v4l2-ctl -d /dev/video0 -l
User Controls
exposure (int) : min=0 max=4095 step=1 default=1575 value=1575
gain (int) : min=256 max=43663 step=1 default=256 value=256
horizontal_flip (bool) : default=0 value=0
vertical_flip (bool) : default=0 value=0
Image Source Controls
vertical_blanking (int) : min=686 max=686 step=1 default=686 value=686
horizontal_blanking (int) : min=1524 max=1524 step=1 default=1524 value=1524
analogue_gain (int) : min=256 max=2816 step=1 default=512 value=512
Image Processing Controls
link_frequency (intmenu): min=0 max=0 default=0 value=0
pixel_rate (int64) : min=0 max=182463120 step=1 default=182463120 value=182463120 flags=read-only
test_pattern (menu) : min=0 max=13 default=0 value=0
v4l2-ctl --list-formats-ext --device /dev/video0
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture Multiplanar
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Index : 1
Type : Video Capture Multiplanar
Pixel Format: 'YVYU'
Name : YVYU 4:2:2
Index : 2
Type : Video Capture Multiplanar
Pixel Format: 'VYUY'
Name : VYUY 4:2:2
Index : 3
Type : Video Capture Multiplanar
Pixel Format: '422P'
Name : Planar YVU 4:2:2
Index : 4
Type : Video Capture Multiplanar
Pixel Format: 'NV16'
Name : Y/CbCr 4:2:2
Index : 5
Type : Video Capture Multiplanar
Pixel Format: 'NV61'
Name : Y/CrCb 4:2:2
Index : 6
Type : Video Capture Multiplanar
Pixel Format: 'YM61'
Name : Planar YVU 4:2:2 (N-C)
Index : 7
Type : Video Capture Multiplanar
Pixel Format: 'NV21'
Name : Y/CrCb 4:2:0
Index : 8
Type : Video Capture Multiplanar
Pixel Format: 'NV12'
Name : Y/CbCr 4:2:0
Index : 9
Type : Video Capture Multiplanar
Pixel Format: 'NM21'
Name : Y/CrCb 4:2:0 (N-C)
Index : 10
Type : Video Capture Multiplanar
Pixel Format: 'NM12'
Name : Y/CbCr 4:2:0 (N-C)
Index : 11
Type : Video Capture Multiplanar
Pixel Format: 'YU12'
Name : Planar YUV 4:2:0
Index : 12
Type : Video Capture Multiplanar
Pixel Format: 'YV12'
Name : Planar YVU 4:2:0
Index : 13
Type : Video Capture Multiplanar
Pixel Format: 'YM24'
Name : Planar YUV 4:4:4 (N-C)
Index : 14
Type : Video Capture Multiplanar
Pixel Format: 'GREY'
Name : 8-bit Greyscale
Index : 15
Type : Video Capture Multiplanar
Pixel Format: 'RGGB'
Name : 8-bit Bayer RGRG/GBGB
Index : 16
Type : Video Capture Multiplanar
Pixel Format: 'GRBG'
Name : 8-bit Bayer GRGR/BGBG
Index : 17
Type : Video Capture Multiplanar
Pixel Format: 'GBRG'
Name : 8-bit Bayer GBGB/RGRG
Index : 18
Type : Video Capture Multiplanar
Pixel Format: 'BA81'
Name : 8-bit Bayer BGBG/GRGR
Index : 19
Type : Video Capture Multiplanar
Pixel Format: 'RGGB'
Name : 8-bit Bayer RGRG/GBGB
Index : 20
Type : Video Capture Multiplanar
Pixel Format: 'BA10'
Name : 10-bit Bayer GRGR/BGBG
Index : 21
Type : Video Capture Multiplanar
Pixel Format: 'GB10'
Name : 10-bit Bayer GBGB/RGRG
Index : 22
Type : Video Capture Multiplanar
Pixel Format: 'BG10'
Name : 10-bit Bayer BGBG/GRGR
Index : 23
Type : Video Capture Multiplanar
Pixel Format: 'RG12'
Name : 12-bit Bayer RGRG/GBGB
Index : 24
Type : Video Capture Multiplanar
Pixel Format: 'BA12'
Name : 12-bit Bayer GRGR/BGBG
Index : 25
Type : Video Capture Multiplanar
Pixel Format: 'GB12'
Name : 12-bit Bayer GBGB/RGRG
Index : 26
Type : Video Capture Multiplanar
Pixel Format: 'BG12'
Name : 12-bit Bayer BGBG/GRGR
linaro@linaro-alip:~$ v4l2-compliance
v4l2-compliance SHA : not available
Driver Info:
Driver name : rkisp1
Card type : rkisp1_mainpath
Bus info : platform:ff910000.rkisp1
Driver version: 4.4.154
Capabilities : 0x84201000
Video Capture Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04201000
Video Capture Multiplanar
Streaming
Extended Pix Format
Compliance test for device /dev/video0 (not using libv4l2):
Required ioctls:
test VIDIOC_QUERYCAP: OK
Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
fail: v4l2-test-input-output.cpp(420): G_INPUT not supported for a capture device
test VIDIOC_G/S/ENUMINPUT: FAIL
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
fail: v4l2-test-controls.cpp(723): could not get all controls
test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
fail: v4l2-test-controls.cpp(782): subscribe event for control 'User Controls' failed
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: FAIL
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 13 Private Controls: 0
Format ioctls:
fail: v4l2-test-formats.cpp(272): duplicate format 42474752 (RGGB)
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: FAIL
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
fail: v4l2-test-formats.cpp(328): !colorspace
fail: v4l2-test-formats.cpp(451): testColorspace(pix_mp.pixelformat, pix_mp.colorspace, pix_mp.ycbcr_enc, pix_mp.quantization)
test VIDIOC_G_FMT: FAIL
test VIDIOC_TRY_FMT: OK (Not Supported)
test VIDIOC_S_FMT: OK (Not Supported)
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
fail: v4l2-test-formats.cpp(1273): doioctl(node, VIDIOC_G_SELECTION, &sel) != EINVAL
test Cropping: FAIL
test Composing: OK (Not Supported)
test Scaling: OK
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
fail: v4l2-test-buffers.cpp(571): q.has_expbuf(node)
test VIDIOC_EXPBUF: FAIL
Test input 0:
Total: 43, Succeeded: 36, Failed: 7, Warnings: 0
imx219
Chroma = Color, RGB
Data Format = Raw Bayer 10bit
https://www.arducam.com/downloads/modules/RaspberryPi_camera/IMX219DS.PDF
Full raspberry camera documentations https://www.raspberrypi.com/documentation/accessories/camera.html