lineage-rpi / android_device_brcm_rpi4

38 stars 14 forks source link

RPI not boot fine, when used DVI monitor #4

Closed lubagov closed 3 years ago

lubagov commented 3 years ago

Hello! Almost it same like this issue https://github.com/lineage-rpi/android_device_brcm_rpi4/issues/2 I am attach dmesg and logcat output in archive. When i use HDMI tv with sound support it fine boot.

I don't use MIPI DSI display now. Just write flash and try to boot. But i use DVI display without audio support (Samsung SyncMaster 971P). Also strange, why DSI display not support KMS? I use Eglfs-KMS and VC4 driver, with Qt application, it normal working with DSI official 7" display. RPI 4 B Rev 1.2 (UK), lineage-18.1-20210104-UNOFFICIAL-KonstaKANG-rpi4.img logs.tar.gz

Thank you!

KonstaT commented 3 years ago

You need to use a HDMI display that reports resolutions it supports via EDID. Raspberry Pi doesn't have DVI output so I assume you're using some kind of HDMI-DVI adapter for this. There's been reports that at least some HDMI-VGA adapters work (because they report EDID).

Android builds use the standard Linux KMS driver to configure the display. Raspberry Pi OS (and many other Linux distributions for the Pi) use FKMS (fake/firmware KMS) that rely on the firmware to configure the display.

Pi KMS driver hasn't supported the official 7" DSI display for quite a few kernel versions. Raspberry Pi Foundation just recently added the support in Linux 5.10 (https://github.com/raspberrypi/linux/pull/3954). I actually already have the official display working with hw accelerated graphics but there's still other reasons not to switch to 5.10 just yet.

lubagov commented 3 years ago

But Raspbian works fine with DVI displays, because RPI normally supports both CEA and DMT modes... And my display normal report EDID.... I don't understand your answer, it's not correct...

KonstaT commented 3 years ago

Raspberry Pi OS uses FKMS which is not the same as KMS used with Android. Something working in Raspberry Pi OS doesn't imply in any way that it also works with Android.

FAQ has a section about display issues and EDID you might want to start with first.

lubagov commented 3 years ago

A passive HDMI-DVI cable is used where the DDC (I2C) bus wires are normally connected. And HotPlug Detect works well. EDID is transmitted normally (and this monitor transmits it even when turned off, which is a rarity).

The only difference is that the monitor does not have sound support and only supports DMT modes, and in principle the HDMI and DVI protocols are somewhat different. However, the official Raspbian works well with DVI, both when using KMS and via BCM drivers ....

for example, display can working hdmi_group=2 mode hdmi_mode=82 but preferred mode is 35, however can't work with hdmi_group=1 and hdmi_mode=82. But in any case it is should not have affect on boot process because device not but and i can see error messages with permissions in logs, depending with audio...

KonstaT commented 3 years ago

Like said, FKMS != KMS.

hdmi_* options in /boot/config.txt have no effect whatsoever when KMS is being used. That is to do with how the Raspberry firmware configures the display (FKMS).

lubagov commented 3 years ago

@KonstaT don't know, it start working after i change this params in config.txt:

15c15
< dtparam=audio=on
---
> dtparam=audio=off
34,36c34,36
< hdmi_drive=2
< hdmi_group=1
< hdmi_mode=4
---
> hdmi_drive=1
> hdmi_group=2
> hdmi_mode=82

but don't know what concrete take effect... and yes, it is start in 1280x1024 resolution, unlike i set... and resolution.txt i leave 1920x1080

lubagov commented 3 years ago

i think options hdmi_drive and/or hdmi_group may take effect.... But mode not. It is logical that it does not give an effect.

em.... hmm... not it was empyt resolution.txt, becouse was error on SD card...

KonstaT commented 3 years ago

No, hdmi_* options in /boot/config.txt have no effect whatsoever when KMS is being used.

If you've booted to Android you can go to 'Settings -> System -> Advanced settings -> Display resolution' to see what your display reports as supported (or 'cat /sys/devices/platform/gpu/drm/card0/card0-HDMI-A-1/modes' in shell).

lubagov commented 3 years ago

@KonstaT I realized that it solves the problem. The problem is solved by clearing the resolution.txt file i.e. when it is empty it boot fine. If the resolution is specified there not from the EDID data of the monitor (although the monitor works with 1920x1080, this is not the aspect ratio, and it is not in the list), nothing is boot.

KonstaT commented 3 years ago

Like it says in the FAQ, "Removing /boot/resolution.txt will try to use the preferred resolution for your display.".

You need a display that reports resolutions using EDID for this to work properly.

One thing you can try is adding 'drm_kms_helper.edid_firmware=edid/1920x1080.bin' to the end of the line in /boot/cmdline.txt. This will force EDID from a file included in the kernel. There's some drawbacks like HDMI audio is not working when you use this. I guess your display doesn't support audio anyway so this is not a problem for you.

lubagov commented 3 years ago

Yes thank you. I'll just ask. And what was the problem with setting correct file permissions and removing "permissive mode" in SELinux?

And what about the hardware decoder? In fact, I do not see V4L2 devices for decoder and encoder. What about OpenMax and MMAL? In general, there are none at all?

KonstaT commented 3 years ago

This is off topic for this issue.

Crafting sepolicy is not about setting file permissions. The "problem" is that I just much rather spend my spare time on doing something else than dealing with SELinux issues. I also like to keep the system easily modifiable/hackable for development and users as well. SELinux usually gets away e.g. when testing a new piece hardware.

V4L2 codecs are not enabled on kernel side but you can easily do so. It doesn't get you anywhere as it's not hooked to Android media framework in any way. This has been discussed e.g. https://forum.xda-developers.com/t/dev-rom-unofficial-lineageos-17-1-android-10-for-raspberry-pi-4-b.4139059/page-2#post-83348979

xa0c commented 2 years ago

One thing you can try is adding 'drm_kms_helper.edid_firmware=edid/1920x1080.bin' to the end of the line in /boot/cmdline.txt.

@KonstaT Thanks, that helped me, but in my case I had to specify another file. The list of prebuilt EDIDs from the kernel:

    "edid/800x600.bin",
    "edid/1024x768.bin",
    "edid/1280x1024.bin",
    "edid/1600x1200.bin",
    "edid/1680x1050.bin",
    "edid/1920x1080.bin",