Forums

Problem with connecting ADV7280-M to V4L in Rock Pi 4B SoC

Started by Unknown January 10, 2020
I have to connect ADV7280-M (contained in the EVAL-ADV7280MEBZ board) board to Rock Pi 4B SoC.
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 ADV7280-M to the device tree.

    /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 &ldquo;media-ctl -p&rdquo; 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&rsquo;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.

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&rsquo;ll appreciate any suggestions how to do it in the right way.

TIA & Regards,
Wojtek