Dual display on Apalix iMX6: HDMI is not properly initialized if cable was not connected during bootup

Hello, I’m trying to get working iMX6 Apalis module with 2 different displays (LVDS as main display and HDMI as optional display) in dual mode (not mirroring!) with Qt5 and EGLFS.

I’ve configured kernel and device tree, everything is working very well but only if HDMI cable is connected at bootup.
Here is the initialization string:

vidargs=video=mxcfb0:dev=ldb,1024x600@60,if=RGB18,bpp=18 video2=mxcfb1:hdmi,1024x768M@60,if=RGB24 video=mxcfb2:off video=mxcfb3:off ldb=dul1 fbmem=32M

And device tree for LVDS/HDMI:

mxcfb1: fb@0 {
		compatible = "fsl,mxc_sdc_fb";
		disp_dev = "ldb";
		interface_pix_fmt = "RGB24";
		default_bpp = <32>;
		int_clk = <0>;
		late_init = <0>;
		status = "disabled";
};

mxcfb2: fb@1 {
		compatible = "fsl,mxc_sdc_fb";
		disp_dev = "hdmi";
		interface_pix_fmt = "RGB24";
		mode_str ="1920x1080M@60";
		default_bpp = <16>;
		int_clk = <0>;
		late_init = <0>;
		status = "disabled";
};

	
&ldb {
	status = "okay";
	ipu_id = <0>;
	disp_id = <1>;

	lvds-channel@0 {
		reg = <0>;
		fsl,data-mapping = "spwg";
		fsl,data-width = <24>;
		crtc = "ipu2-di1";
		primary;
		status = "okay";

		display-timings {
			native-mode = <&timing_lvds>;
			timing_lvds: 1024x600 {
				clock-frequency = <51200000>;
				hactive = <1024>;
				vactive = <600>;
				hback-porch = <110>;
				hfront-porch = <110>;
				vback-porch = <15>;
				vfront-porch = <15>;
				hsync-len = <100>;
				vsync-len = <5>;
				de-active = <1>;
				pixelclk-active = <0>;
			};
		};
	};
};

If the HDMI cable was not connected and is connected afterwards the image on the display is corrupted. It looks like the frequency of the signal was not properly initialized.

But kernel log shows that the same settings were applied for both modes:

With cable:

mxc_sdc_fb fb@1: 1280x1024 h_sync,r,l: 112,48,248  v_sync,l,u: 3,1,38 pixclock=108003000 Hz

Without cable:

mxc_sdc_fb fb@1: 1920x1080 h_sync,r,l: 44,88,148  v_sync,l,u: 5,4,36 pixclock=148500000 Hz
... Cable is connected here ...
mxc_hdmi 20e0000.hdmi_video: Read EDID again
mxc_sdc_fb fb@1: 640x480 h_sync,r,l: 96,16,48  v_sync,l,u: 2,10,33 pixclock=25175000 Hz
mxc_sdc_fb fb@1: 640x480 h_sync,r,l: 96,16,48  v_sync,l,u: 2,10,33 pixclock=25175000 Hz
mxc_sdc_fb fb@1: 1280x1024 h_sync,r,l: 112,48,248  v_sync,l,u: 3,1,38 pixclock=108003000 Hz

What am I doing wrong? I have tried to reinitialize the HDMI display writing 1 to blank property in the fb2 section but it doesn’t really help.

I’m confused - what is your HDMI display native resolution? You set to 1024x768M@60 at vidargs, however you Device Tree setting is 1920x1080M@60. And when cable connected resolution set to 1280x1024. Looks like the latest one is native. Could you try to use 1280x1024 at vidarg and if doesn’t work - update a Device Tree accordingly?