BalajiNarasimhan
Posts: 24
Joined: Sun Sep 01, 2019 7:20 am

RPI4 DPI displays not working on ANDROID

Wed Apr 21, 2021 12:41 pm

Hi, i tried running my lcd display on RPI 4 using DPI running android 18.1 build from konstakang.
When mentioned custom timings in config.txt , the display doesnt seem to work. only the pi rainbow flash is displayed.
To cross check i connected to hdmi tv and getting a static rainbow screen , meaning the DPI is activated as gpio alt mode.

when asked konstakang he mentioned is as android is using HAL while pi os use fake KMS / kernel method to configure the DPI.

DIsplay im using is 15.6 , 18.5 inch 1366x768 display. works fine with raspbian, ubuntu.
the below config text gives me the rainbow splash screen, which is the firmware stuff.
The config.txt im using is

Code: Select all

# Kernel
kernel=zImage

# Ramdisk
initramfs ramdisk.img followkernel


# Audio
#[HDMI:0]
#[HDMI:1]
#dtparam=audio=on
#hdmi_force_edid_audio=1
#[all]

# Boot device
dtoverlay=android-sdcard


# Display
#[HDMI:0]
#[HDMI:1]
#hdmi_force_hotplug=1
#hdmi_drive=2
#hdmi_group=2
#hdmi_mode=86
#disable_overscan=1
#[all]

# Graphics acceleration
dtoverlay=vc4-kms-v3d,noaudio
dtoverlay=cma,cma-384

#PHERIPHERALS
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on


# Overclock
over_voltage=0
arm_freq=1500


# Sensors
#dtoverlay=android-i2c-sensor,mpu6050

# Serial console
#enable_uart=1

# Touchscreen
dtoverlay=rpi-backlight

# USB-C
dtoverlay=dwc2,dr_mode=peripheral

#Enable the lcd, enable custom display sizes with CVT, set as the default output.
gpio=0-27=a2,np
dtoverlay=dpi24
enable_dpi_lcd=1
dpi_group=2
dpi_mode=87
display_default_lcd=1

dpi_output_format=458775
hdmi_timings=1368 1 48 112 248 768 1 1 3 38 0 0 0 50 2 52531200 1

As konstakang said , pi foundation engineers can throw me some light regarding this.
Or dpi guru abugsworstnightmare can help me with this.
Thanks in advance

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11055
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: RPI4 DPI displays not working on ANDROID

Wed Apr 21, 2021 1:15 pm

vc4-kms-v3d doesn't use the firmware, so no all configuration options for your DPI display need to through DRM/KMS and device tree.

You need to find an equivalent panel timing for your panel in panel-simple, and then create a dtoverlay along similar lines to Adafruit's Kippah one. (Note that that overlay is only RGB666, so you need to find one that is RGB888 if that is how your display is wired, and amend the GPIO config accordingly)
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

BalajiNarasimhan
Posts: 24
Joined: Sun Sep 01, 2019 7:20 am

Re: RPI4 DPI displays not working on ANDROID

Thu Apr 22, 2021 1:49 am

6by9 wrote:
Wed Apr 21, 2021 1:15 pm
vc4-kms-v3d doesn't use the firmware, so no all configuration options for your DPI display need to through DRM/KMS and device tree.

You need to find an equivalent panel timing for your panel in panel-simple, and then create a dtoverlay along similar lines to Adafruit's Kippah one. (Note that that overlay is only RGB666, so you need to find one that is RGB888 if that is how your display is wired, and amend the GPIO config accordingly)
Thanks for the reply. I see the adafruit kippah uses a dtoverlay to enable RGB18 mode and have the timings mentioned in the overlay itself.
why should a DToverlay with RGB24 mode+timings for my display will work

but
the usual route of using dtoverlay=dpi24 + mentioning RGBmode+hdmi timings directly in the config.txt is not working?

does having a dtoverlay for the dpi display have any sort of priority over the config.txt route?
im sorry im new to this. im trying to understand. sorry for my noobish questions.

thanks in advance

aBUGSworstnightmare
Posts: 2810
Joined: Tue Jun 30, 2015 1:35 pm

Re: RPI4 DPI displays not working on ANDROID

Thu Apr 22, 2021 5:52 am

First of all, if you're using DPI you should also specify a timing for it. in your config the detailed timing is related to HDMI. It seems to work but it should read like below

Code: Select all

dpi_output_format=458775
dpi_timings=1368 1 48 112 248 768 1 1 3 38 0 0 0 50 2 52531200 1
Under FKMS the firmware does all the job for you in regards of decoding your timing (from dpi_output and dpi_timings). Under KMS you need to have a driver + overlay to do this as there is no more GPU firmware handling this stuff.
IMG_2199.jpeg
IMG_2199.jpeg (80.97 KiB) Viewed 406 times
Here is an example how to do this for the NewHaven NHD-3.5-320240MF-ATXL (data sheet at https://eu.mouser.com/ProductDetail/New ... wDmwTHRw==) shown above:

as 6by9 informed you already you need to either find or add the timing to 'panel-simple'. For the 3.5in NewHaven below was added:

Code: Select all

static const struct display_timing newhaven_nhd35-320240mfatxl_timing = {
	.pixelclock = { 6000000, 6000000, 6000000},
	.hactive = { 320, 320, 320 },
	.hfront_porch = { 8, 8, 8 },
	.hback_porch = { 43, 43, 43 },
	.hsync_len = { 4, 4, 4},
	.vactive = { 240, 240, 240 },
	.vfront_porch = { 8, 8, 8},
	.vback_porch = { 12, 12, 12 },
	.vsync_len = { 4, 4, 4 },
	.flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC,
};

static const struct panel_desc newhaven_nhd35-320240mfatxl = {
	.timings = &newhaven_nhd35-320240mfatxl_timing,
	.num_timings = 1,
	.bpc = 8,
	.size = {
		.width = 70,
		.height = 53,
	},	
	.delay = {
		.prepare = 50,
		.enable = 200,
		.disable = 110,
		.unprepare = 200,
	},
	.bus_format = MEDIA_BUS_FMT_RGB888_1X24,
	.bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE,
	.connector_type = DRM_MODE_CONNECTOR_DPI,
};
and further down in the driver source

Code: Select all

static const struct of_device_id platform_of_match[] = {
...{
		.compatible = "newhaven,nhd35320240mfatxl",
		.data = &newhaven_nhd35-320240mfatxl,
	},
	....	
As you can see it's the timing details, as well as information which output format and which connector is to be used. The time for prepare/enable/etc are optional, but to avoid irregular display you should consider to keep them (modified for your panel).

Next thing you need is a 24-bit overlay which makes use of this panel things. This has to be added to your config.txt later.
The overlay source for the 3.5in (can be used as template!!!!) is shown below.

Code: Select all

/*
 * vc4-kms-nhd35-320240mfatxl-overlay.dts
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/pinctrl/bcm2835.h>

/ {
	compatible = "brcm,bcm2835";

	fragment@0 {
		target-path = "/";
		__overlay__ {
			panel: panel {
				compatible = "newhaven,nhd35320240mfatxl", "simple-panel";

				port {
					panel_in: endpoint {
						remote-endpoint = <&dpi_out>;
					};
				};
			};
		};
	};

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

			pinctrl-names = "default";
			pinctrl-0 = <&dpi_gpio0>;

			port {
				dpi_out: endpoint@0 {
					remote-endpoint = <&panel_in>;
				};
			};
		};
	};
};
The overlay configures your GPIO to ALT2=DPI.

your added/changed files needs to be build against the kernel (https://www.raspberrypi.org/documentati ... uilding.md) and then you're ready to go.

BalajiNarasimhan
Posts: 24
Joined: Sun Sep 01, 2019 7:20 am

Re: RPI4 DPI displays not working on ANDROID

Thu Apr 22, 2021 6:28 am

aBUGSworstnightmare wrote:
Thu Apr 22, 2021 5:52 am
First of all, if you're using DPI you should also specify a timing for it. in your config the detailed timing is related to HDMI. It seems to work but it should read like below

Code: Select all

dpi_output_format=458775
dpi_timings=1368 1 48 112 248 768 1 1 3 38 0 0 0 50 2 52531200 1
Under FKMS the firmware does all the job for you in regards of decoding your timing (from dpi_output and dpi_timings). Under KMS you need to have a driver + overlay to do this as there is no more GPU firmware handling this stuff.
IMG_2199.jpeg
Here is an example how to do this for the NewHaven NHD-3.5-320240MF-ATXL (data sheet at https://eu.mouser.com/ProductDetail/New ... wDmwTHRw==) shown above:

as 6by9 informed you already you need to either find or add the timing to 'panel-simple'. For the 3.5in NewHaven below was added:


your added/changed files needs to be build against the kernel (https://www.raspberrypi.org/documentati ... uilding.md) and then you're ready to go.
Thank you very much for the detailed walkthrough. I went through the panel-simple.c and found "AUO G156XTN01" which has the same specifications as the panel im using. since the settings is already there for AUO G156XTN01 . Im planning to directly move to making the DTOVERLAY step.

Code: Select all

/*
 * vc4-kms-AUO G156XTN01.dts
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/pinctrl/bcm2835.h>

/ {
	compatible = "brcm,bcm2835";

	fragment@0 {
		target-path = "/";
		__overlay__ {
			panel: panel {
				compatible = "auo,g156xtn01", "simple-panel";

				port {
					panel_in: endpoint {
						remote-endpoint = <&dpi_out>;
					};
				};
			};
		};
	};

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

			pinctrl-names = "default";
			pinctrl-0 = <&dpi_gpio0>;

			port {
				dpi_out: endpoint@0 {
					remote-endpoint = <&panel_in>;
				};
			};
		};
	};
};
I think this should work.

yet not sure what is the work of these lines

Code: Select all

pinctrl-names = "default";
pinctrl-0 = <&dpi_gpio0>;
Now to the final step, "build against the kernel" which sounds " PRO LEVEL" for me now. ill look into the steps and keep you posted on the progress

once i mention the dtoverlay in config.txt, should i have to still mention the usual dpi mode, timings in config.txt?

Thanks again very much for the detailed instruction and the " TEMPLATE" :D

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11055
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: RPI4 DPI displays not working on ANDROID

Thu Apr 22, 2021 8:30 am

BalajiNarasimhan wrote:
Thu Apr 22, 2021 6:28 am
yet not sure what is the work of these lines

Code: Select all

pinctrl-names = "default";
pinctrl-0 = <&dpi_gpio0>;
Compare against the dpi18 overlay and you'll get the idea.
BalajiNarasimhan wrote:Now to the final step, "build against the kernel" which sounds " PRO LEVEL" for me now. ill look into the steps and keep you posted on the progress

once i mention the dtoverlay in config.txt, should i have to still mention the usual dpi mode, timings in config.txt?

Thanks again very much for the detailed instruction and the " TEMPLATE" :D
panel-simple is already built in standard Pi kernels, so you only need to build your overlay.
As per the docs

Code: Select all

dtc -@ -Hepapr -I dts -O dtb -o 1st.dtbo 1st-overlay.dts
should do it for you without having to build the whole kernel.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

BalajiNarasimhan
Posts: 24
Joined: Sun Sep 01, 2019 7:20 am

Re: RPI4 DPI displays not working on ANDROID

Fri Apr 23, 2021 5:04 am

Thanks 6by9 for the help, i did make the overlay but got some problems compiling the dtoverlay to .dtbo
Compare against the dpi18 overlay and you'll get the idea.
from comparing dpi18 overlay and adafruit kippah overlay i changed the pincontrol -0 to

Code: Select all

pinctrl-names = "default";
pinctrl-0 = <&dpi_24bit_gpio0>;
i guess this should work

Heres my dtoverlay for auo,g156xtn01

Code: Select all


/*
 * g156xtn01-overlay.dts
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/pinctrl/bcm2835.h>

/ {
        compatible = "brcm,bcm2835";

        fragment@0 {
                target-path = "/";
                __overlay__ {
                        panel: panel {
                                compatible = "auo,g156xtn01", "simple-panel";

                                port {
                                        panel_in: endpoint {
                                                remote-endpoint = <&dpi_out>;
                                        };
                                };
                        };
                };
        };

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

                        pinctrl-names = "default";
                        pinctrl-0 = <&dpi_24bit_gpio0>;

                        port {
                                dpi_out: endpoint@0 {
                                        remote-endpoint = <&panel_in>;
                                };
                        };
                };
        };
};


As per the docs

Code: Select all

dtc -@ -Hepapr -I dts -O dtb -o 1st.dtbo 1st-overlay.dts
should do it for you without having to build the whole kernel.
And when i try to compile the dtoverlay to /boot/overlays/ i get a syntax error.

Code: Select all

root@raspberrypi:/home/pi/testoverlay# dtc -@ -Hepapr -I dts -O dtb -o /boot/overlays/g156xtn01.dtbo  /home/pi/testoverlay/g156xtn01.dts 
Error: /home/pi/testoverlay/g156xtn01.dts:8.1-9 syntax error
FATAL ERROR: Unable to parse input tree
i have been scratching my head to find what 8.1-9 syntax error if it is something with the command or something inside the dts file.
Thanks in advance

aBUGSworstnightmare
Posts: 2810
Joined: Tue Jun 30, 2015 1:35 pm

Re: RPI4 DPI displays not working on ANDROID

Fri Apr 23, 2021 5:16 am

The one I've posted is correct, your's not!

You should only catch the point that one configures DPI in 18bit, and mine is 24bit.

BalajiNarasimhan
Posts: 24
Joined: Sun Sep 01, 2019 7:20 am

Re: RPI4 DPI displays not working on ANDROID

Fri Apr 23, 2021 5:52 am

aBUGSworstnightmare wrote:
Fri Apr 23, 2021 5:16 am
The one I've posted is correct, your's not!

You should only catch the point that one configures DPI in 18bit, and mine is 24bit.
thanks for the headsup, i just thought dpi_24bit will activate 24bit mode just like that in adafruit kippah overlay for 18bit.

using your dtoverlay for 24bit, i guess the only thing i will have to change is the " compatible" panel parameters.
Heres my updated dtoverlay

Code: Select all


/*
 * g156xtn01.dts
 */

/dts-v1/;
/plugin/;

#include <dt-bindings/pinctrl/bcm2835.h>

/ {
	compatible = "brcm,bcm2835";

	fragment@0 {
		target-path = "/";
		__overlay__ {
			panel: panel {
				compatible = "auo,g156xtn01", "simple-panel";

				port {
					panel_in: endpoint {
						remote-endpoint = <&dpi_out>;
					};
				};
			};
		};
	};

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

			pinctrl-names = "default";
			pinctrl-0 = <&dpi_gpio0>;

			port {
				dpi_out: endpoint@0 {
					remote-endpoint = <&panel_in>;
				};
			};
		};
	};
};
hope this one is correct

aBUGSworstnightmare
Posts: 2810
Joined: Tue Jun 30, 2015 1:35 pm

Re: RPI4 DPI displays not working on ANDROID

Fri Apr 23, 2021 6:04 am

BalajiNarasimhan wrote:
Fri Apr 23, 2021 5:52 am
aBUGSworstnightmare wrote:
Fri Apr 23, 2021 5:16 am
The one I've posted is correct, your's not!

You should only catch the point that one configures DPI in 18bit, and mine is 24bit.
thanks for the headsup, i just thought dpi_24bit will activate 24bit mode just like that in adafruit kippah overlay for 18bit.

using your dtoverlay for 24bit, i guess the only thing i will have to change is the " compatible" panel parameters.
Heres my updated dtoverlay
no and yes. Compile it and see if it works for you.

BalajiNarasimhan
Posts: 24
Joined: Sun Sep 01, 2019 7:20 am

Re: RPI4 DPI displays not working on ANDROID

Fri Apr 30, 2021 6:31 am

no and yes. Compile it and see if it works for you.
Hi bugs and 6by9, I compiled my overlay and placed it in boot/overlays folder.

mentioned dtoverlay=g156xtn01 in config.txt and unfortunately it didnt work.

Heres the overlay dts file i made.

Code: Select all

/dts-v1/;
/plugin/;


/ {
        compatible = "brcm,bcm2835";

        fragment@0 {
                target-path = "/";
                __overlay__ {
                        panel: panel {
                                compatible = "auo,g156xtn01", "simple-panel";

                                port {
                                        panel_in: endpoint {
                                                remote-endpoint = <&dpi_out>;
                                        };
                                };
                        };
                };
        };

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

                        pinctrl-names = "default";
                        pinctrl-0 = <&dpi_gpio0>;

                        port {
                                dpi_out: endpoint {
                                        remote-endpoint = <&panel_in>;
                                                                        };
                        };
                };
        };
};


Removed

Code: Select all

#include <dt-bindings/pinctrl/bcm2835.h>
as they were throwing errors and warnings

overlay compiled fine and was added to config.txt
but the panel wasnt initialised.

maybe is it because the #include bcm2385.h wasnt included?

i also decompiled vc4-kms-kippach.dtbo and it is different than the one from github.

Code: Select all

/dts-v1/;

/ {
        compatible = "brcm,bcm2835";

        fragment@0 {
                target-path = [ 2f 00 ];

                __overlay__ {

                        panel {
                                compatible = "ontat,yx700wv03\0simple-panel";
                                phandle = < 0x03 >;

                                port {

                                        endpoint {
                                                remote-endpoint = < 0x01 >;
                                                phandle = < 0x02 >;
                                        };
                                };
                        };
                };
        };

        fragment@1 {
                target = < 0xffffffff >;

                __overlay__ {
                        status = "okay";
                        pinctrl-names = "default";
                        pinctrl-0 = < 0xffffffff >;

 port {

                                endpoint@0 {
                                        remote-endpoint = < 0x02 >;
                                        phandle = < 0x01 >;
                                };
                        };
                };
        };

        __symbols__ {
                panel = "/fragment@0/__overlay__/panel";
                panel_in = "/fragment@0/__overlay__/panel/port/endpoint";
                dpi_out = "/fragment@1/__overlay__/port/endpoint@0";
        };

        __fixups__ {
dpi = "/fragment@1:target:0";
                dpi_18bit_gpio0 = "/fragment@1/__overlay__:pinctrl-0:0";
        };

        __local_fixups__ {

                fragment@0 {

                        __overlay__ {

                                panel {

                                        port {

                                                endpoint {
                                                        remote-endpoint = < 0x00 >;
                                                };
                                        };
                                };
                        };
                };

                fragment@1 {

                        __overlay__ {

                                port {

                                        endpoint@0 {
                                                remote-endpoint = < 0x00 >;
                                        };
                                };
                        };
                };
        };
};

Any pointers will be helpful.
Thanks in advance.

BalajiNarasimhan
Posts: 24
Joined: Sun Sep 01, 2019 7:20 am

Re: RPI4 DPI displays not working on ANDROID

Sat May 01, 2021 2:39 am

hi, guys i found the problem with my approach. i forgot to see the exisiting g156xtt0.1 parameters in panel-simple.c. i checked the examples and found the connection mentioned for it is default is lvds. and my case needs dpi.

For now i have to enter custom parameters for my panel in panel-simple.c

i see only panel-simple.ko available in /drivers/gpu/panel/

how can i proceed at this point?

create a file panel-simple.c , copy paste the contents and add my parameters like timings, connectors, compatible etc and compile it to .ko ?

i got some idea from this thread viewtopic.php?t=259119

Any pointers will be helpful. thanks

Return to “Android”