First off, thanks to everyone who has figured this all out. Much of this is over my head
I think I've nearly got my camera working with Armbian 22.08.6 Jammy on Linux 5.15.69-sunxi which is running on an Orange Pi PC.
I've gotten /dev/media1 and /dev/video1 nodes after using the following device tree overlay. It is just a combination of @rreignier's overlay with @gsumner's regulator nodes but I haven't seen anyone post a combined overlay yet so I hope this makes it clear for anyone trying to get this to work on the same platform.
/dts-v1/;
/plugin/;
/ {
compatible = "allwinner,sun8i-h3";
};
&ccu {
assigned-clocks = <&ccu 107>;
assigned-clock-parents = <&osc24M>;
assigned-clock-rates = <24000000>;
};
&pio {
csi_mclk_pin: csi-mclk-pin {
pins = "PE1";
function = "csi";
};
};
&i2c2_pins {
bias-pull-up;
};
&i2c2 {
status = "okay";
ov5640: camera@3c {
compatible = "ovti,ov5640";
reg = <0x3c>;
pinctrl-names = "default";
pinctrl-0 = <&csi_mclk_pin>;
clocks = <&ccu 107>;
clock-names = "xclk";
AVDD-supply = <®_vcc_af_csi>;
DOVDD-supply = <®_vdd_1v5_csi>;
DVDD-supply = <®_vcc_csi>;
reset-gpios = <&pio 4 14 1>; /* CSI-RST-R: PE14 */
powerdown-gpios = <&pio 4 15 0>; /* CSI-STBY-R: PE15 */
port {
ov5640_ep: endpoint {
remote-endpoint = <&csi_ep>;
bus-width = <8>;
data-shift = <2>; /* lines 9:2 are used */
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 */
};
};
};
&{/} {
reg_vdd_1v5_csi: vdd-1v5-csi {
compatible = "regulator-fixed";
regulator-name = "vdd1v5-csi";
regulator-min-microvolt = <1500000>;
regulator-max-microvolt = <1500000>;
gpio = <&pio 6 13 0>; /* PG13 */
enable-active-high;
regulator-boot-on;
regulator-always-on;
};
reg_vcc_csi: vcc-csi {
compatible = "regulator-fixed";
regulator-name = "vcc-csi";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
gpio = <&pio 6 11 0>; /* PG11 */
enable-active-high;
regulator-boot-on;
regulator-always-on;
};
reg_vcc_af_csi: vcc-af-csi {
compatible = "regulator-fixed";
regulator-name = "vcc-af-csi";
regulator-min-microvolt = <2800000>;
regulator-max-microvolt = <2800000>;
gpio = <&pio 0 17 0>; /* PA17 */
enable-active-high;
regulator-boot-on;
regulator-always-on;
};
};
After applying the overlay and rebooting, I can use lsmod to see the camera driver:
lsmod | grep "ov5640"
ov5640 28672 1
v4l2_fwnode 24576 2 ov5640,sun6i_csi
v4l2_async 20480 3 ov5640,v4l2_fwnode,sun6i_csi
And I can use the media-ctl command to check the topology:
media-ctl --device /dev/media1 --print-topology
Media controller API version 5.15.69
Media device information
------------------------
driver sun6i-csi
model Allwinner Video Capture Device
serial
bus info platform:1cb0000.camera
hw revision 0x0
driver version 5.15.69
Device topology
- entity 1: sun6i-csi (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video1
pad0: Sink
<- "ov5640 0-003c":0 [ENABLED]
- entity 5: ov5640 0-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]
However, when I try to use the command to set 1920x1080, it fails:
media-ctl --device /dev/media1 --set-v4l2 '"ov5640 1-003c":0[fmt:UYVY8/1920x1080]'
Unable to setup formats: Invalid argument (22)
I've been staring at the help output for media-ctl but I'm in over my head with this one.
I also tried poking around with v4l2-ctl but nothing there seems to be working. Here is the result of a v4l2-ctl --info command:
Driver Info:
Driver name : cedrus
Card type : cedrus
Bus info : platform:cedrus
Driver version : 5.15.74
Capabilities : 0x84208000
Video Memory-to-Memory
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04208000
Video Memory-to-Memory
Streaming
Extended Pix Format
Media Driver Info:
Driver name : cedrus
Model : cedrus
Serial :
Bus info : platform:cedrus
Media version : 5.15.74
Hardware revision: 0x00000000 (0)
Driver version : 5.15.74
Interface Info:
ID : 0x0300000c
Type : V4L Video
Entity Info:
ID : 0x00000001 (1)
Name : cedrus-source
Function : V4L2 I/O
Pad 0x01000002 : 0: Source
Link 0x02000008: to remote pad 0x1000004 of entity 'cedrus-proc' (Video Decoder): Data, Enabled, Immutable
What am I still missing?