The OV5640 has been updated to work on BPI-M64

The OV5640 has been updated to work on M64 ( https://github.com/avafinger/ov5640/tree/A64 ) and will be included on next Armbian release (M2P). Another thing to point to is that the guy Paulo Assis should not use mainline kernel (Armbian), he should get Armbian Legacy kernel that has good support for the Wifi and it really is working good on that. (Ubuntu 14.04). We will update the ov5640 instructions on Armbian as soon as it get stable, and will be really soon.

from Alex of camera developer., thank Alex do this cool work.

Is there support for the OV5640 with the current mainline armbian kernel (5.7.15-sunxi64)?

You have to add the camera node to the DT or add it with overlay. Some kernel config is needed but i think is already set.

/ {
	model = "BananaPi-M64";
	compatible = "m64", "allwinner,sun50i-a64";

	i2c-csi {
		compatible = "i2c-gpio";
		sda-gpios = <&pio 4 13 GPIO_ACTIVE_HIGH>; /* CSI0-SDA: PE13 */
		scl-gpios = <&pio 4 12 GPIO_ACTIVE_HIGH>; /* CSI0-SCK: PE12 */
		i2c-gpio,delay-us = <5>;
		#address-cells = <1>;
		#size-cells = <0>;

		ov5640: camera@3c {
			compatible = "ovti,ov5640";
			reg = <0x3c>;
			pinctrl-names = "default";
			pinctrl-0 = <&csi_mclk_pin>;
			clocks = <&ccu CLK_CSI_MCLK>;
			clock-names = "xclk";

			AVDD-supply = <&reg_dldo3>;
			DOVDD-supply = <&reg_aldo1>;
			DVDD-supply = <&reg_eldo3>;
			reset-gpios = <&pio 4 16 GPIO_ACTIVE_LOW>; /* CSI0-RST: PE16 */
			powerdown-gpios = <&pio 4 17 GPIO_ACTIVE_HIGH>; /* CSI0-PWDN: PE17 */

			port {
				ov5640_ep: endpoint {
					remote-endpoint = <&csi_ep>;
					bus-width = <8>;
					hsync-active = <1>; /* Active high */
					vsync-active = <0>; /* Active low */
					data-active = <1>;  /* Active high */
					pclk-sample = <1>;  /* Rising */
				};
			};
		};
	};
};

&csi {
	status = "okay";

	port {
		#address-cells = <1>;
		#size-cells = <0>;

		csi_ep: endpoint {
			remote-endpoint = <&ov5640_ep>;
			bus-width = <8>;
			hsync-active = <1>; /* Active high */
			vsync-active = <0>; /* Active low */
			data-active = <1>;  /* Active high */
			pclk-sample = <1>;  /* Rising */
		};
	};
};

Use v4l2-commands to configure the sensor (640x480 is default) and grab images with:

How do I compile the DTS. Dtc is complaining:

dtc camera.dts
Error: camera.dts:1.1-2 syntax error
FATAL ERROR: Unable to parse input tree

Start from here: https://docs.armbian.com/User-Guide_Allwinner_overlays/

The DTS above is just the camera node, you can add this node or create an overlay.

OK, I got the dtc file to compile and installed under /boot/overlay-user/. The machine comes up and the video devices show up under /dev:

gollumm64% v4l2-ctl --list-devices

cedrus (platform:cedrus):
	/dev/video1
	/dev/media1

sun6i-csi (platform:csi):
	/dev/video0

Allwinner Video Capture Device (platform:sun6i-csi):
	/dev/media0

gollumm64%  v4l2-ctl -d 0 --list-formats --list-ctrls

ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'BA81' (8-bit Bayer BGBG/GRGR)
	[1]: 'GBRG' (8-bit Bayer GBGB/RGRG)
	[2]: 'GRBG' (8-bit Bayer GRGR/BGBG)
	[3]: 'RGGB' (8-bit Bayer RGRG/GBGB)
	[4]: 'BG10' (10-bit Bayer BGBG/GRGR)
	[5]: 'GB10' (10-bit Bayer GBGB/RGRG)
	[6]: 'BA10' (10-bit Bayer GRGR/BGBG)
	[7]: 'RG10' (10-bit Bayer RGRG/GBGB)
	[8]: 'BG12' (12-bit Bayer BGBG/GRGR)
	[9]: 'GB12' (12-bit Bayer GBGB/RGRG)
	[10]: 'BA12' (12-bit Bayer GRGR/BGBG)
	[11]: 'RG12' (12-bit Bayer RGRG/GBGB)
	[12]: 'YUYV' (YUYV 4:2:2)
	[13]: 'YVYU' (YVYU 4:2:2)
	[14]: 'UYVY' (UYVY 4:2:2)
	[15]: 'VYUY' (VYUY 4:2:2)
	[16]: 'RGBP' (16-bit RGB 5-6-5)
	[17]: 'RGBO' (16-bit A/XRGB 1-5-5-5)
	[18]: 'HM12' (YUV 4:2:0 (16x16 Macroblocks))
	[19]: 'NV12' (Y/CbCr 4:2:0)
	[20]: 'NV21' (Y/CrCb 4:2:0)
	[21]: 'YU12' (Planar YUV 4:2:0)
	[22]: 'YV12' (Planar YVU 4:2:0)
	[23]: 'NV16' (Y/CbCr 4:2:2)
	[24]: 'NV61' (Y/CrCb 4:2:2)
	[25]: '422P' (Planar YUV 4:2:2)
	[26]: 'RGBP' (16-bit RGB 5-6-5)
	[27]: 'RGBR' (16-bit RGB 5-6-5 BE)
	[28]: 'JPEG' (JFIF JPEG, compressed)
gollumm64% v4l2-ctl -d 1 --list-formats --list-ctrls


Codec Controls

        mpeg_2_slice_parameters 0x009909fa (unknown): type=103 flags=has-payload
   mpeg_2_quantization_matrices 0x009909fb (unknown): type=104 flags=has-payload
    h264_sequence_parameter_set 0x00990ce8 (unknown): type=110 flags=has-payload
     h264_picture_parameter_set 0x00990ce9 (unknown): type=111 flags=has-payload
            h264_scaling_matrix 0x00990cea (unknown): type=112 flags=has-payload
          h264_slice_parameters 0x00990ceb (unknown): type=113 flags=has-payload
         h264_decode_parameters 0x00990cec (unknown): type=114 flags=has-payload
               h264_decode_mode 0x00990ced (menu)   : min=0 max=0 default=0 value=0
                h264_start_code 0x00990cee (menu)   : min=0 max=0 default=0 value=0
    hevc_sequence_parameter_set 0x00990cf0 (unknown): type=120 flags=has-payload
     hevc_picture_parameter_set 0x00990cf1 (unknown): type=121 flags=has-payload
          hevc_slice_parameters 0x00990cf2 (unknown): type=122 flags=has-payload
               hevc_decode_mode 0x00990cf7 (menu)   : min=0 max=0 default=0 value=0
                hevc_start_code 0x00990cf8 (menu)   : min=0 max=0 default=0 value=0
ioctl: VIDIOC_ENUM_FMT
	Type: Video Capture

	[0]: 'ST12' (Sunxi Tiled NV12 Format, compressed)
	[1]: 'NV12' (Y/CbCr 4:2:0)
gollumm64% media-ctl --device /dev/media0 -p

Media controller API version 5.7.15

Media device information
------------------------
driver          sun6i-csi
model           Allwinner Video Capture Device
serial          
bus info        
hw revision     0x0
driver version  5.7.15

Device topology
- entity 1: sun6i-csi (1 pad, 0 link)
            type Node subtype V4L flags 0
            device node name /dev/video0
	pad0: Sink

gollumm64% media-ctl --device /dev/media1 -p

Media controller API version 5.7.15

Media device information
------------------------
driver          cedrus
model           cedrus
serial          
bus info        platform:cedrus
hw revision     0x0
driver version  5.7.15

Device topology
- entity 1: cedrus-source (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video1
	pad0: Source
		-> "cedrus-proc":0 [ENABLED,IMMUTABLE]

- entity 3: cedrus-proc (2 pads, 2 links)
            type Node subtype Unknown flags 0
	pad0: Sink
		<- "cedrus-source":0 [ENABLED,IMMUTABLE]
	pad1: Source
		-> "cedrus-sink":0 [ENABLED,IMMUTABLE]

- entity 6: cedrus-sink (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video1
	pad0: Sink
		<- "cedrus-proc":1 [ENABLED,IMMUTABLE]

But I am not able to capture any video and neigher cheese or chromium see the camera. What am I missing?

What are the commands to capture a frame? and what is the error?

dmesg|tail

gollumm64% fswebcam -d /dev/video1 --exposure 4 -r 640x480 -p YUV420P - > cam640x480_2.jpg
--- Opening /dev/video1...
Trying source module v4l2...
/dev/video1 opened.
No input was specified, using the first.
Unable to query input 0.
VIDIOC_ENUMINPUT: Inappropriate ioctl for device
gollumm64% fswebcam -d /dev/video0 --exposure 4 -r 640x480 -p YUV420P - > cam640x480_2.jpg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
rc: -1 - get value: 0
rc: -1 - set src->exposure: 4
Error starting stream.
VIDIOC_STREAMON: Invalid argument
Unable to use mmap. Using read instead.
Unable to use read.
gollumm64% dmesg | tail -70
[  710.375116] alloc_contig_range: [bcc00, be65e) PFNs busy
[  710.376834] alloc_contig_range: [bcc00, be75e) PFNs busy
[  710.378444] alloc_contig_range: [bcc00, be85e) PFNs busy
[  710.380173] alloc_contig_range: [bcc00, be95e) PFNs busy
[  711.247069] cma: cma_alloc: alloc failed, req-size: 6750 pages, ret: -16
[  711.253862] ------------[ cut here ]------------
[  711.253882] WARNING: CPU: 3 PID: 3953 at mm/page_alloc.c:4789 __alloc_pages_nodemask+0x22c/0x270
[  711.253885] Modules linked in: fuse overlay bnep zstd zram dm_mod dax uas hci_uart snd_soc_hdmi_codec btqca btrtl btbcm btintel snd_soc_simple_card brcmfmac bluetooth snd_soc_simple_card_utils brcmutil cfg80211 ecdh_generic axp20x_adc rfkill sunxi_cedrus(C) ecc axp20x_battery sun6i_csi sun50i_codec_analog axp20x_ac_power sun8i_codec sun4i_i2s sun8i_adda_pr_regmap snd_soc_core v4l2_mem2mem dw_hdmi_i2s_audio v4l2_fwnode dw_hdmi_cec snd_pcm_dmaengine snd_pcm videobuf2_dma_contig videobuf2_memops snd_timer videobuf2_v4l2 snd videobuf2_common sun4i_gpadc_iio soundcore videodev sun8i_ce mc crypto_engine display_connector cpufreq_dt usb_f_acm u_serial g_serial libcomposite axp20x_usb_power industrialio pinctrl_axp209 realtek dwmac_sun8i mdio_mux i2c_mv64xxx
[  711.253998] CPU: 3 PID: 3953 Comm: v4l2src1:src Tainted: G        WC        5.7.15-sunxi64 #20.08
[  711.254000] Hardware name: BananaPi-M64 (DT)
[  711.254005] pstate: 20000005 (nzCv daif -PAN -UAO)
[  711.254010] pc : __alloc_pages_nodemask+0x22c/0x270
[  711.254019] lr : __dma_direct_alloc_pages+0x1a0/0x288
[  711.254021] sp : ffff80001399b8c0
[  711.254024] x29: ffff80001399b8c0 x28: ffff80001399bba8 
[  711.254029] x27: 000000000000000d x26: ffff8000111802a0 
[  711.254034] x25: 00000000ffffffff x24: 0000000001a5dfff 
[  711.254038] x23: 000000013fffffff x22: 0000000001a5e000 
[  711.254043] x21: 000000000000000d x20: ffff000009910d40 
[  711.254048] x19: 0000000000000cc0 x18: 0000000000000010 
[  711.254052] x17: 0000000000000000 x16: 0000000000000000 
[  711.254057] x15: ffff000009911168 x14: ffffffffffffffff 
[  711.254062] x13: ffff80009399b627 x12: ffff80001399b62f 
[  711.254067] x11: ffff8000111b0000 x10: 0000000000000000 
[  711.254071] x9 : ffff800011274000 x8 : 00000000000003d9 
[  711.254076] x7 : 0000000000000015 x6 : 0000000000000001 
[  711.254080] x5 : 0000000000000000 x4 : ffff000077bb0818 
[  711.254085] x3 : 0000000000000000 x2 : 0000000000000000 
[  711.254089] x1 : 0000000000000000 x0 : 0000000000000cc0 
[  711.254094] Call trace:
[  711.254101]  __alloc_pages_nodemask+0x22c/0x270
[  711.254106]  __dma_direct_alloc_pages+0x1a0/0x288
[  711.254111]  dma_direct_alloc_pages+0x58/0x210
[  711.254116]  dma_direct_alloc+0x10/0x20
[  711.254122]  dma_alloc_attrs+0x80/0xf0
[  711.254133]  vb2_dc_alloc+0x6c/0x130 [videobuf2_dma_contig]
[  711.254141]  __vb2_queue_alloc+0x170/0x420 [videobuf2_common]
[  711.254147]  vb2_core_reqbufs+0x280/0x468 [videobuf2_common]
[  711.254155]  vb2_ioctl_reqbufs+0x84/0xc0 [videobuf2_v4l2]
[  711.254177]  v4l_reqbufs+0x4c/0x60 [videodev]
[  711.254190]  __video_do_ioctl+0x184/0x3e8 [videodev]
[  711.254202]  video_usercopy+0x190/0x500 [videodev]
[  711.254215]  video_ioctl2+0x18/0x60 [videodev]
[  711.254227]  v4l2_ioctl+0x40/0x60 [videodev]
[  711.254234]  ksys_ioctl+0xa8/0xe8
[  711.254238]  __arm64_sys_ioctl+0x20/0x30
[  711.254247]  el0_svc_common.constprop.0+0x6c/0x168
[  711.254252]  do_el0_svc+0x24/0x90
[  711.254258]  el0_sync_handler+0x114/0x180
[  711.254263]  el0_sync+0x158/0x180
[  711.254266] ---[ end trace 2ac908bc2925169e ]---
[  711.254281] sun6i-csi 1cb0000.csi: dma_alloc_coherent of size 27648000 failed
[  894.103300] cma: cma_alloc: alloc failed, req-size: 6750 pages, ret: -12
[  894.110069] sun6i-csi 1cb0000.csi: dma_alloc_coherent of size 27648000 failed
[  951.121828] cma: cma_alloc: alloc failed, req-size: 6750 pages, ret: -12
[  951.128595] sun6i-csi 1cb0000.csi: dma_alloc_coherent of size 27648000 failed
[ 1981.157550] alloc_contig_range: 24 callbacks suppressed
[ 1981.157559] alloc_contig_range: [bbf00, bd95e) PFNs busy
[ 1981.158740] alloc_contig_range: [bc000, bda5e) PFNs busy
[ 1981.159740] alloc_contig_range: [bc000, bdb5e) PFNs busy
[ 1981.160826] alloc_contig_range: [bc000, bdc5e) PFNs busy
[ 1981.162150] alloc_contig_range: [bc000, bdd5e) PFNs busy
[ 1981.163372] alloc_contig_range: [bc400, bde5e) PFNs busy
[ 1981.692939] alloc_contig_range: [be000, bfa5e) PFNs busy
[ 1981.694822] alloc_contig_range: [be000, bfb5e) PFNs busy
[ 1981.696478] alloc_contig_range: [be000, bfc5e) PFNs busy
[ 1981.698230] alloc_contig_range: [be000, bfd5e) PFNs busy
[ 1981.701569] cma: cma_alloc: alloc failed, req-size: 6750 pages, ret: -16
[ 1981.712942] sun6i-csi 1cb0000.csi: dma_alloc_coherent of size 27648000 failed
[31897.006556] md: md0: recovery done.

Looks like you need to increase CMA.

  • Find the current cma size:

    dmesg|grep "cma:"

  • Increase cma, use a boot like command or the Armbian way

    CMA=256

Still does not work… Same errors, but now nothing shows up in dmesg, so I guess the CMA errors are cured.

Do you get any output from:

dmesg|grep ov

Just:

gollumm64% dmesg|grep ov
[   40.439531] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.sinovoip,bananapi-m64.txt failed with error -2
[  443.332657] md: recovery of RAID array md0
[31764.468591] md: md0: recovery done.

You could try a few things, assuming you did not set any window size yet:

fswebcam -v --displayfps 1 -S 30 -d /dev/video0 -r 640x480 -p YUV420P - > 640p.jpg

and just to get some dmesg info:

v4l2-ctl -d0 --stream-mmap --stream-count=1 --stream-to=file.raw

You can also capture a raw frame to test if v4l2 kernel implementation is not broken:

v4l2-ctl --device /dev/video0 --set-fmt-video=width=640,height=480,pixelformat=YU12 --stream-mmap  --stream-to=frame_640x480.raw --stream-count=1

You should get a yu12 raw file with 460800 in size, you can convert it to jpeg just to see how it looks.

You can use Imagemagick to convert to png:

convert -size 640x480 -sampling-factor 4:2:0 -depth 8 yuv:frame_640x480.raw -colorspace RGB png:frame_640x480.png

Better result with jpeg:

convert -size 640x480 -sampling-factor 4:2:0 -depth 8 yuv:frame_640x480.raw -colorspace RGB jpg:frame_640x480.jpg

Nothing seems to work…

Both v4l2-ctl just hang (I need to ^C out). Nothing shows up in dmesg.

And the fswebcam command yields this (I tried both /dev/video0 and /dev/video1):

gollumm64% fswebcam -v --displayfps 1 -S 30 -d /dev/video0 -r 640x480 -p YUV420P  - > 640p.jpg

--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
src_v4l2_get_capability,87: /dev/video0 information:
src_v4l2_get_capability,88: cap.driver: "cedrus"
src_v4l2_get_capability,89: cap.card: "cedrus"
src_v4l2_get_capability,90: cap.bus_info: "platform:cedrus"
src_v4l2_get_capability,91: cap.capabilities=0x84208000
src_v4l2_get_capability,103: - STREAMING
No input was specified, using the first.
Unable to query input 0.
VIDIOC_ENUMINPUT: Inappropriate ioctl for device
gollumm64% fswebcam -v --displayfps 1 -S 30 -d /dev/video1 -r 640x480 -p YUV420P  - > 640p.jpg

--- Opening /dev/video1...
Trying source module v4l2...
/dev/video1 opened.
src_v4l2_get_capability,87: /dev/video1 information:
src_v4l2_get_capability,88: cap.driver: "sun6i-video"
src_v4l2_get_capability,89: cap.card: "sun6i-csi"
src_v4l2_get_capability,90: cap.bus_info: "platform:csi"
src_v4l2_get_capability,91: cap.capabilities=0x84200001
src_v4l2_get_capability,92: - VIDEO_CAPTURE
src_v4l2_get_capability,103: - STREAMING
No input was specified, using the first.
src_v4l2_set_input,181: /dev/video1: Input 0 information:
src_v4l2_set_input,182: name = "camera"
src_v4l2_set_input,183: type = 00000002
src_v4l2_set_input,185: - CAMERA
src_v4l2_set_input,186: audioset = 00000000
src_v4l2_set_input,187: tuner = 00000000
src_v4l2_set_input,188: status = 00000000
src_v4l2_set_pix_format,551: Device offers the following V4L2 pixel formats:
src_v4l2_set_pix_format,560: 0: [0x31384142] 'A81ä' (e)
src_v4l2_set_pix_format,560: 1: [0x47524247] 'BRGä' (e)
src_v4l2_set_pix_format,560: 2: [0x47425247] 'RBGä' (e)
src_v4l2_set_pix_format,560: 3: [0x42474752] 'GGBä' (e)
src_v4l2_set_pix_format,560: 4: [0x30314742] 'G10ä' (e)
src_v4l2_set_pix_format,560: 5: [0x30314247] 'B10ä' (e)
src_v4l2_set_pix_format,560: 6: [0x30314142] 'A10ä' (e)
src_v4l2_set_pix_format,560: 7: [0x30314752] 'G10ä' (e)
src_v4l2_set_pix_format,560: 8: [0x32314742] 'G12ä' (e)
src_v4l2_set_pix_format,560: 9: [0x32314247] 'B12ä' (e)
src_v4l2_set_pix_format,560: 10: [0x32314142] 'A12ä' (e)
src_v4l2_set_pix_format,560: 11: [0x32314752] 'G12ä' (e)
src_v4l2_set_pix_format,560: 12: [0x56595559] 'UYVä' (e)
src_v4l2_set_pix_format,560: 13: [0x55595659] 'VYUä' (e)
src_v4l2_set_pix_format,560: 14: [0x59565955] 'YVYä' (e)
src_v4l2_set_pix_format,560: 15: [0x59555956] 'YUYä' (e)
src_v4l2_set_pix_format,560: 16: [0x50424752] 'GBPä' (e)
src_v4l2_set_pix_format,560: 17: [0x4F424752] 'GBOä' (e)
src_v4l2_set_pix_format,560: 18: [0x32314D48] 'M12ä' (e)
src_v4l2_set_pix_format,560: 19: [0x3231564E] 'V12ä' (e)
src_v4l2_set_pix_format,560: 20: [0x3132564E] 'V21ä' (e)
src_v4l2_set_pix_format,560: 21: [0x32315559] 'U12ä' (e)
src_v4l2_set_pix_format,560: 22: [0x32315659] 'V12ä' (e)
src_v4l2_set_pix_format,560: 23: [0x3631564E] 'V16ä' (e)
src_v4l2_set_pix_format,560: 24: [0x3136564E] 'V61ä' (e)
src_v4l2_set_pix_format,560: 25: [0x50323234] '22Pä' (e)
src_v4l2_set_pix_format,560: 26: [0x50424752] 'GBPä' (e)
src_v4l2_set_pix_format,560: 27: [0x52424752] 'GBRä' (e)
src_v4l2_set_pix_format,560: 28: [0x4745504A] 'PEGä' (e)
Using palette YUV420P
9: 'YU12'
src_v4l2_set_mmap,708: mmap information:
src_v4l2_set_mmap,709: frames=4
src_v4l2_set_mmap,758: 0 length=460800
src_v4l2_set_mmap,758: 1 length=460800
src_v4l2_set_mmap,758: 2 length=460800
src_v4l2_set_mmap,758: 3 length=460800
Error starting stream.
VIDIOC_STREAMON: Invalid argument
Unable to use mmap. Using read instead.
Unable to use read.
gollumm64% exit

In your case:

  • /dev/video0 is the CEDRUS (hw decoding)
  • /dev/video1 is the camera

Can you check your board revision version?

We should get at least some dmesg error. The output of the command:

media-ctl --device /dev/media0 -p

should give something like this (i have /dev/video0 as a camera):

Media controller API version 5.9.0

Media device information
------------------------
driver          sun6i-csi
model           Allwinner Video Capture Device
serial          
bus info        platform:1cb0000.csi
hw revision     0x0
driver version  5.9.0

Device topology
- entity 1: sun6i-csi (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video0
	pad0: Sink
		<- "ov5640 2-003c":0 [ENABLED,IMMUTABLE]

- entity 5: ov5640 2-003c (1 pad, 1 link)
            type V4L2 subdev subtype Sensor flags 0
            device node name /dev/v4l-subdev0
	pad0: Source
		[fmt:UYVY8_2X8/640x480@1/30 field:none colorspace:srgb xfer:srgb ycbcr:601 quantization:full-range]
		-> "sun6i-csi":0 [ENABLED,IMMUTABLE]

You have some options that comes to my mind:

  1. disclose your camera overlay so others can test or review
  2. move on to a 5.8 dev kernel with this overlay and see what you get
  3. play with v4l2-ctl and media-ctl and try to find the sink

The media-ctl comand results:

gollumm64% media-ctl --device /dev/media0 -p

Media controller API version 5.7.15

Media device information
------------------------
driver          cedrus
model           cedrus
serial          
bus info        platform:cedrus
hw revision     0x0
driver version  5.7.15

Device topology
- entity 1: cedrus-source (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video0
	pad0: Source
		-> "cedrus-proc":0 [ENABLED,IMMUTABLE]

- entity 3: cedrus-proc (2 pads, 2 links)
            type Node subtype Unknown flags 0
	pad0: Sink
		<- "cedrus-source":0 [ENABLED,IMMUTABLE]
	pad1: Source
		-> "cedrus-sink":0 [ENABLED,IMMUTABLE]

- entity 6: cedrus-sink (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video0
	pad0: Sink
		<- "cedrus-proc":1 [ENABLED,IMMUTABLE]

gollumm64% media-ctl --device /dev/media1 -p

Media controller API version 5.7.15

Media device information
------------------------
driver          sun6i-csi
model           Allwinner Video Capture Device
serial          
bus info        
hw revision     0x0
driver version  5.7.15

Device topology
- entity 1: sun6i-csi (1 pad, 0 link)
            type Node subtype V4L flags 0
            device node name /dev/video1
	pad0: Sink

gollumm64% exit

Camera.dts is:

/dts-v1/;
/plugin/;

/ {
	model = "BananaPi-M64";
	compatible = "m64", "allwinner,sun50i-a64";

	i2c-csi {
		compatible = "i2c-gpio";
		sda-gpios = <&pio 4 13 0>; /* CSI0-SDA: PE13 */
		scl-gpios = <&pio 4 12 0>; /* CSI0-SCK: PE12 */
		i2c-gpio,delay-us = <5>;
		#address-cells = <1>;
		#size-cells = <0>;

		ov5640: camera@3c {
			compatible = "ovti,ov5640";
			reg = <0x3c>;
			pinctrl-names = "default";
			pinctrl-0 = <&csi_mclk_pin>;
			clocks = <&ccu 105>;
			clock-names = "xclk";

			AVDD-supply = <&reg_dldo3>;
			DOVDD-supply = <&reg_aldo1>;
			DVDD-supply = <&reg_eldo3>;
			reset-gpios = <&pio 4 16 1>; /* CSI0-RST: PE16 */
			powerdown-gpios = <&pio 4 17 0>; /* CSI0-PWDN: PE17 */

			port {
				ov5640_ep: endpoint {
					remote-endpoint = <&csi_ep>;
					bus-width = <8>;
					hsync-active = <1>; /* Active high */
					vsync-active = <0>; /* Active low */
					data-active = <1>;  /* Active high */
					pclk-sample = <1>;  /* Rising */
				};
			};
		};
	};
};

&csi {
	status = "okay";

	port {
		#address-cells = <1>;
		#size-cells = <0>;

		csi_ep: endpoint {
			remote-endpoint = <&ov5640_ep>;
			bus-width = <8>;
			hsync-active = <1>; /* Active high */
			vsync-active = <0>; /* Active low */
			data-active = <1>;  /* Active high */
			pclk-sample = <1>;  /* Rising */
		};
	};
};

This is pretty much copy and pasted from what you posted, except I prefixed it with the first two lines and replaced the defined constants with the actual values from the include files. I needed to do that to get armbian-add-overlay to not complain.

Board rev is BPI-M64 V1.2.

Your media is media1 (not media0), this depends on the order they are created at boot time, in my case it is in reverse order than yours. But it does not matter.

media-ctl --device /dev/media1 -p

Can you check if this got applied? (i think this is the endpoint and is missing foe some reason):

&csi {
	status = "okay";

	port {
		#address-cells = <1>;
		#size-cells = <0>;

		csi_ep: endpoint {
			remote-endpoint = <&ov5640_ep>;
			bus-width = <8>;
			hsync-active = <1>; /* Active high */
			vsync-active = <0>; /* Active low */
			data-active = <1>;  /* Active high */
			pclk-sample = <1>;  /* Rising */
		};
	};
};

Maybe Igor can give some input about this overlay.