ADV7280M with Rock Pi 4B - problems

Hi,
I have to connect ADV7280M (contained in the EVAL-ADV7280MEBZ board) to Rock Pi 4B.
I have recompiled the kernel with added adv7180.c driver. The procedure for recompilation of the kernel I have taken from: https://wiki.radxa.com/Rockpi4/dev/kernel-4.4
After that I had to add ADV7280M to the device tree.
First I have found, that the driver does not control the powerdown pin (GPIO1 B5), therefore I have added an overlay that sets this pin to “1”:
/dts-v1/;
/plugin/;

/ {
	model = "ROCK PI 4B";
	compatible = "rockchip,rockpi","rockchip,rk3399";

	fragment@0 {
		target-path = "/";
		__overlay__ {
			wzgpios {
				compatible = "gpio-leds";
				wzcam_on {
					label = "WZcam On";
					gpios = <&gpio1 13 0>;
					default-state = "on";
				};
			};
		};
	};
};

After that I have connected the ADV7280M itself:
/dts-v1/;
/plugin/;

/ {
        model = "ROCK PI 4B";
        compatible = "rockchip,rockpi","rockchip,rk3399";

	fragment@0 {
		target = <&i2c4>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			status = "okay";
			adv7280@21 {
				compatible = "adi,adv7280-m";
				reg = <0x21>;
				status = "okay";
				pinctrl-names = "rockchip,camera_default";
				port {
					adv7280_out: endpoint {
						remote-endpoint = <&mipi_in_ucam0>;
						data-lanes = <1>;
					};
				};
			};
		};
	};

	fragment@1 {
		target = <&mipi_dphy_rx0>;
		__overlay__ {
			status = "okay";
		};
	};

	fragment@2 {
		target = <&mipi_in_ucam0>;
		__overlay__ {
			remote-endpoint = <&adv7280_out>;
			data-lanes = <1>; 
		};
	};
};

With that DT, i have obtained correct output of “media-ctl -p” command, but when I try to start the streaming of data with:

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=NV12,width=1920,height=1080, framerate=30/1 ! videoconvert !  x264enc tune=zerolatency bitrate=500 speed-preset=superfast ! rtph264pay ! udpsink host=172.19.1.1 port=5000

I get the following error and system crashes:

[ 246.739221] adv7180 4-0021: No active sensor
[ 246.739613] rkisp1: open cif pipeline failed -32

I have found, that the problem is caused by the fact that adv7180.c driver does not set the sd->entity.type to MEDIA_ENT_T_V4L2_SUBDEV_SENSOR, and the
drivers/media/platform/rockchip/isp1/dev.c file checks it in lines 153-164:

	/* find the subdev of active sensor */
	sd = p->subdevs[0];
	for (i = 0; i < p->num_subdevs; i++) {
		sd = p->subdevs[i];
		if (sd->entity.type == MEDIA_ENT_T_V4L2_SUBDEV_SENSOR)
			break;
	}

	if (i == p->num_subdevs) {
		v4l2_warn(sd, "No active sensor\n");
		return -EPIPE;
	}

The question is, if the adv7180.c should set this type. If not, then I should define another pipeline element, corresponding to the analog video input. However, I couldn’t find any info how to do that.
Therefore, I have modified the adv7180.c to set the required type.
Unfortunately, it does not help, as my device fails the next check (lines 165-169 in dev.c):

	ctrl = v4l2_ctrl_find(sd->ctrl_handler, V4L2_CID_PIXEL_RATE);
	if (!ctrl) {
		v4l2_warn(sd, "No pixel rate control in subdev\n");
		return -EPIPE;
	}

After an attempt to start streaming, I get

adv7180 4-0021: No pixel rate control in subdev

and the system crashes again. (BTW, why video_rkisp1 crashes the system when starting the pipelione fails?)

Of course, I can add a fake PIXEL_RATE control to adv7180.c, but it does not seem to be the right solution. Probably indeed, it is necessary to define a
“composite video input” element in the pipeline, that would have the entity type set to MEDIA_ENT_T_V4L2_SUBDEV_SENSOR and would provide the V4L2_CID_PIXEL_RATE control.
I’ll appreciate any suggestions how to do it in the right way.

TIA & Regards,
Wojtek

I have found the following device tree binding:


However, the associated driver https://github.com/radxa/kernel/blob/release-4.4-rockpi4/drivers/video/fbdev/omap2/displays-new/connector-analog-tv.c does not seem to be related to V4L…