ADV7604 Device tree endpoint parsing error

Hello,

We have developed a dual channel video capture card by help of ADV7604 video decoder. According to device driver we have 7 pads: 6 sink pad and 1 source pad. Out of 6 sink pad 4 sink pads for HDMI and 2 sink pads for Analog input(VGA and component). One source pad is for output.

state->source_pad = state->info->num_dv_ports
			  + (state->info->has_afe ? 2 : 0);
	for (i = 0; i < state->source_pad; ++i)
		state->pads[i].flags = MEDIA_PAD_FL_SINK;
	state->pads[state->source_pad].flags = MEDIA_PAD_FL_SOURCE;

	err = media_entity_pads_init(&sd->entity, state->source_pad + 1,
				state->pads);

The driver I am referring from: ADV7604 Linux Device Driver.

Accordingly I have written the device tree for 6 sink pad and 1 source pad. Please see the sample device tree for ADV7604 below:

i2c@3180000 {       //set this to correct i2c bus
        tca9546@70 {
            i2c@2 {
                #address-cells = <1>;
                #size-cells = <0>;
     			adv7604_c@20 { 
					compatible = "adi,adv7604", "adi,adv7611", "adi,adv7612";
		      		reg = <0x20>; 
                    devnode = "video1"; 
					default-input = <4>;
			
                    ports {
                        #address-cells = <1>;
                        #size-cells = <0>;

                        port@0 {
                            reg = <0>;
                            adv7604_in0: endpoint {
								status = "disabled";
                               
                            };
                        };
						port@1 {
                            reg = <1>;
                            adv7604_in1: endpoint {
								status = "disabled";
                               
                            };
                        };
						port@2 {
                            reg = <2>;
                            adv7604_in2: endpoint {
								status = "disabled";
                            
                            };
                        };
						port@3 {
                            reg = <3>;
                            adv7604_in3: endpoint {
								status = "disabled";
                              
                            };
                        };
						port@4 {
                            reg = <4>;
                            adv7604_in4: endpoint {
								status = "disabled";
                          
                            };
                        };
						port@5 {
                            reg = <5>;
                            adv7604_in5: endpoint {
								status = "disabled";
                             
                            };
                        };
						port@6 {
                            reg = <6>;
                            adv7604_out2: endpoint {
								status = "okay";
                                port-index = <0>;
                                bus-width = <4>;
                                remote-endpoint = <&adv7604_csi_in1>;
                            };
                        };
                    };
                };
            };

Our device node is getting created when disable property is disabled(default). But when we are changing it to Okay, device node is not getting created. In the disabled case we are not able to parse the endpoint in the device tree and not able to read device tree property. Snippet is attached below:

	ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), &bus_cfg);
	of_node_put(endpoint);
	if (ret)
		return ret;

	if (!of_property_read_u32(np, "default-input", &v))
		state->pdata.default_input = v;
	else
		state->pdata.default_input = -1;

Please help me to solve this issue as input in our case is UXGA(1600x1200 P60) and output is RGB888 (ADV76XX_OP_MODE_SEL_SDR_444) . I think the way I have written the device tree is incorrect.

Please help me out to resolve this issue.

Thanks and Regards,

Vikas Dwivedi

  • 0
    •  Analog Employees 
    on Oct 26, 2020 10:59 AM 1 month ago

    Hi Vikas,

    First is not clear for me if the devicetree is not compiled or it is compiled but the driver is not probed.

    If the devicetree is not compiling usually it raises an error and indicates which line has failed.

    If the driver is not probing you can grep the DMESG for the line where it failed and it will indicate an error code returned by probe function.

    Please in first step change your compatible string to just 'compatible = "adi,adv7604";'

    Second please take as reference the devicetree created here for adv7604.

    It is not clear to me also the port you want to connect the output of ADV7604. It should be a parallel port with minimum 12 bits. You specify bus-width = <4>. So please describe your system in more detail to have a better understanding of it.

    You can also use for reference the devicetree bindings documentation

  • Hello Btororean,

    We are able to compile the device tree and driver is also getting probed successfully and we can see the binding by command:

    media-ctl -p -d /dev/media0

    Log for ADV7604 is as below:

    entity 4: adv7604 30-0020 (7 pads, 1 link)
               type V4L2 subdev subtype Unknown flags 0
               device node name /dev/v4l-subdev1
        pad0: Sink
             [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000
    stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
        pad1: Sink
             [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000
    stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
        pad2: Sink
             [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000
    stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
        pad3: Sink
             [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000
    stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
        pad4: Sink
             [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000
    stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
        pad5: Sink
             [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000
    stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
        pad6: Source
             [fmt:RGB888_1X24/1024x768 field:none colorspace:srgb
              crop.bounds:(0,0)/1024x768
              crop:(0,0)/1024x768]
             [dv.caps:BT.656/1120 min:0x0@25000000 max:1920x1200@225000000
    stds:CEA-861,DMT,CVT,GTF caps:progressive,reduced-blanking,custom]
             [dv.query:no-link]
             [dv.current:BT.656/1120 1024x768p60 (1344x806) stds:DMT
    flags:]
             -> "150c0000.nvcsi--2":0 [ENABLED]

    I made the changes in the device tree as you suggested:

    i2c@2 {
                    #address-cells = <1>;
                    #size-cells = <0>;
         			adv7604_c@20 { 
    					compatible = "adi,adv7604";
    		      		reg = <0x20>; 
                        devnode = "video1"; 
    					default-input = <0>;
    			
                        ports {
                            #address-cells = <1>;
                            #size-cells = <0>;
    
                            port@0 {
                                reg = <0>;
    
                            };
    						port@1 {
                                reg = <1>;
    
                            };
    						port@2 {
                                reg = <2>;
    
                            };
    						port@3 {
                                reg = <3>;
    
                            };
    						port@4 {
    
                            };
    						port@5 {
                                reg = <5>;
    
                            };
    						port@6 {
                                reg = <6>;
                                adv7604_out2: endpoint@6 {
                                    bus-width = <4>; // VD: CSI bus width is 4 lane
                                    remote-endpoint = <&adv7604_csi_in1>;
                                };
                            };
                        };
                    };
                };

    I tried to debug in more detail and come to know that that default-input property does not exists. In our case sink pad is ADV7604_PAD_VGA_RGB = 4, and source pad is ADV7604_PAD_SOURCE = 6, So why we are getting this error message of property does not exists.

    Main problem is that device is not able to auto detect the format. As we connected different different source (SVGA, XGA and VGA) but getting the same value of STDI registers of ADV7604. Auto detection functionality is already implemented in the driver.

    So I guessed because of device tree is written properly that's why auto detection functionality is not working.

    What I am missing? Can you look at the driver and device tree and suggests the changes, we have to do in our input output case?

    Thanks and Regards,

    Vikas Dwivedi

  • +1
    •  Analog Employees 
    on Oct 28, 2020 10:11 AM 1 month ago in reply to vikas.dwivedi

    Hi Vikas,

    Your devicetree looks fine now and the "default-input" property is correctly stated. It should work.

    Related to STDI problem, please enable v4l2_dbg prints from driver. Maybe you'll see some problem reported there.

    Especially those prints from read_stdi and stdi2dv_timings functions.

    Regards,

    Bogdan

  • Hi Bogdan,

    I have taken device-tree reference provided by you .

    In  this device tree you have two decoders - ADV7611 and ADV7604.

    ADV7611 output is connected to FPGA in and then the FPGA output is connected to CSI0 input.

    But in case of ADV7604,  you have connected ADV output directly to CSI1 input as below:

    port@6 {
    				reg = <6>;
    				hdmi1_out: endpoint@6 {
    					//remote-endpoint = <&hdmi1_fpga_in>;
    					remote-endpoint = <&csi1>;
    					bus-width = <16>;
    				};
    		}

    We have following queries wrt above code:

    1) In the above code, CSI is shown as bus width 16 whereas CSI is maximum
    4 lanes. Is it correct ? Or our understanding is incorrect ?

    2) As per my understanding ADV7604 gives parallel output ONLY. How is it connected to CSI which is a different bus interface. So, is there any  non-programmable device at output of ADV7604 which converts it to CSI ?

    3) Is this a working code or just for reference ?

    In our Architecture, ADV7604 output(24-bit parallel) is given to FPGA. Then FPGA converts it to 4-lane CSI format which goes as an input to our processor. Also our FPGA is non-programmable. So there is no driver for FPGA. 

    Which approach should we follow for our architecture ?

    What changes shall we make in driver as well as device- tree ?

    Regards,

    Vikas

  • 0
    •  Analog Employees 
    on Nov 11, 2020 7:43 AM 20 days ago in reply to vikas.dwivedi

    Hi Vikas,

    For NXP I.Mx platforms the capture interface is just called CSI. It can be a name confusion with MIPI CSI which is differential and serial interface but it is configured in the referenced devicetree as a paralel interface. You can see the pin muxing suggesting a paralel bus. That bus-width parameter specify the interface width. I think you should adapt it to 24 if your bus is 24 bit.

    The referenced devicetree is not supported by us and tested so take it just as a reference.

    You said that you have problems with format auto detection so please try to follow the debug messages from read_stdi and stdi2dv_timings functions