Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRM fixes on 6.6 #5824

Merged
merged 2 commits into from
Jan 4, 2024
Merged

DRM fixes on 6.6 #5824

merged 2 commits into from
Jan 4, 2024

Conversation

6by9
Copy link
Contributor

@6by9 6by9 commented Jan 4, 2024

The debugfs fix could be split into 3 patches to fix the 3 commits that added each function, but that hardly seems worth it. It will obviously get fixed when looking to merge into mainline.

Other patch hopefully resolves #5674.

6by9 added 2 commits January 4, 2024 12:24
The frame count values moved within registers DISPSTAT1 and
DISPSTAT2 with GEN5, so update the accessor function to
accommodate that.

Fixes: b51cd7a ("drm/vc4: hvs: Fix frame count register readout")
Signed-off-by: Dave Stevenson <[email protected]>
@pelwell pelwell merged commit 7da1db2 into raspberrypi:rpi-6.6.y Jan 4, 2024
11 of 12 checks passed
@JinShil
Copy link
Contributor

JinShil commented Feb 2, 2024

This PR introduced a regression.

I have a Pi5 driving a 7" 800x480 panel through a TFP401 on one of the HDMI ports. Prior to this PR the display works fine. After this PR, the display works fine until reaching the GUI, and then it goes blank. I do not see anything unusual in the logs.

Through a process of bisecting the commits in this repository, I identified this PR as the culprit.

@popcornmix
Copy link
Collaborator

popcornmix commented Feb 2, 2024

Can you confirm which of the commits is responsible (neither looks obviously suspicious).

@JinShil
Copy link
Contributor

JinShil commented Feb 2, 2024

I'm sorry, but I'm not sure how to do that conveniently. I'm using rpi-update pulls/xxx. Is there a way to target a specific commit?

@6by9
Copy link
Contributor Author

6by9 commented Feb 2, 2024

Using rpi-update pulls/xxx isn't bisecting the tree.

Note that this commit is against 6.6, whereas most PRs until recently will be 6.1.
If it's an issue on 6.6 in particular, then working through the commit hashes on https://github.com/raspberrypi/rpi-firmware/commits/next/ will get you the builds of the test kernels on 6.6.

Can you provide the EDID for your display please?

@JinShil
Copy link
Contributor

JinShil commented Feb 5, 2024

Here's the EDID:
edid.zip

I'm sorry, but I don't quite follow what you're suggesting. After running rpi-update pulls/5824 the kernel version is 6.6.9-v8-16K+. I tried rpi-update next 4e6dd7f322de6fd396c9850118be2b4d27b8355f to target a specific commit, but it failed with...

Downloading bootloader tools
 !!! Failed to download rpi-eeprom-update

@6by9
Copy link
Contributor Author

6by9 commented Feb 5, 2024

rpi-update takes either a git hash or a branch name, not both.

As covered in https://github.com/raspberrypi/rpi-update?tab=readme-ov-file#options
rpi-update 4e6dd7f322de6fd396c9850118be2b4d27b8355f would get you commit hash 4e6dd7f from the rpi-firmware repo (that hash appears not to exist).
rpi-update next or rpi-update BRANCH=next would get you the build from the next branch of rpi-update
rpi-update rpi-6.6.y would get you the latest build from the rpi-6.6.y source branch.

If you're not wanting to update the bootloader, prefix the command with SKIP_BOOTLOADER=1

The EDID looks a little odd. According to edid-decode, [email protected] with timing parameters of

                 Hfront  210 Hsync  20 Hback -184 Hpol N
                 Vfront   22 Vsync  10 Vback   -9 Vpol N

Negative timing properties sounds like an error to me.

Pulling the DTD apart using https://en.wikipedia.org/wiki/Extended_display_identification_data#Detailed_Timing_Descriptor

02 0d 20 2e 30 e0 17 10 d2 14 6a 04 20 0d 42 00 00 18

0-1 pixel clock 02 0d
2 hact lsb 20
3 hblank pixels 2e 
4 h msbs 30
5 vact e0 
6 vblank 17 
7 vact/vblank 10
8 hfront d2 
9 hsync 14
10 vfp/vsync 6a 
11 msbs 04 
12 20
13 0d 
14 42
15 00 
16 00 
17 18

(Signal = offsets in the DTD  = values of those registers = value)
HACT = 4 + 2 = 0x300 + 0x20 = 800
HBLANK = 4 + 3 = 0 + 0x2e = 46
HFP = 8 = 0xd2 = 210
HSYNC = 9 = 0x14 = 20
HBP = HBLANK - HFP - HSYNC = 46 - 210 - 20 = -184

VACT = 7 + 5 = 0x100 + 0xe0 = 480
VBLANK = 7 + 6 = 0 + 0xe0 = 23
VFP = 11 + 10 = 0x10 + 0x6 = 22
VSYNC = 11 + 10 = 0x00 + 0x0a = 10
VBP = 23 - 22 - 10 = -9

So it is defining negative back porches.

DRM analyses the mode as

[    9.115375] [drm:drm_mode_debug_printmodeline [drm]] Modeline "800x480": 63 33300 800 1010 1030 1031 480 502 512 513 0x48 0xa
[    9.115615] [drm:drm_mode_prune_invalid [drm]] Not using 800x480 mode: H_ILLEGAL

And is therefore discarding it.
This parsing has not changed with this PR.

@JinShil
Copy link
Contributor

JinShil commented Feb 6, 2024

Here's the timing from the LCD's datasheet:
image

That is transferred to the EDID as:
image

It appears the EDID parsing algorithm does not consider the "Horizontal/Vertical Line" field. Is that right, or am I missing something?

[ 9.115615] [drm:drm_mode_prune_invalid [drm]] Not using 800x480 mode: H_ILLEGAL
And is therefore discarding it.
This parsing has not changed with this PR.

I added drm.debug=0x14 in cmdline.txt. I don't see the prune_invalid line in the logs prior to this PR. However, since I have been using rpi-update pulls/5824, I'm assuming I've inadvertently pulled in some other commit that changed the EDID parsing algorithm with this PR. I'll go fishing for that commit in the rpi-firmware repo. Maybe that's what you've been trying to explain to me, but I don't yet understand how these tools and repos are organized.

@JinShil
Copy link
Contributor

JinShil commented Feb 6, 2024

I see now that front_porch + blanking + active_area equals one horizontal/vertical line. It also appears the Image Size and Border fields are not used in the computation.

So working backwards from the EDID parsing algorithm you posted, I modified the EDID as...
image
... to ensure the back porches were not negative.

edid-decode now shows:

Detailed Timing Descriptors:
    DTD 1:   800x480    78.253881 Hz   5:3     39.362 kHz     33.300000 MHz (150 mm x 100 mm)
                 Hfront   45 Hsync   1 Hback    0 Hpol N
                 Vfront   22 Vsync   1 Vback    0 Vpol N

Logs show:

journalctl -r | grep "kernel: \[drm:drm"
Feb 06 00:22:25 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:41:HDMI-A-2] disconnected
Feb 06 00:22:25 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:41:HDMI-A-2]
Feb 06 00:22:25 raspberrypi kernel: [drm:drm_mode_debug_printmodeline [drm]] Modeline "800x480": 78 33300 800 845 846 846 480 502 503 503 0x48 0xa
Feb 06 00:22:25 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:32:HDMI-A-1] probed modes :
Feb 06 00:22:25 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:32:HDMI-A-1]
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] desired mode 800x480 set on crtc 86 (0,0)
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] picking CRTCs for 800x480 config
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] found mode 800x480
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] looking for preferred mode on connector 32 0
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] looking for cmdline mode on connector 32
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] Not using firmware configuration
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] connector 41 enabled? no
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] connector 32 enabled? yes
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:41:HDMI-A-2] disconnected
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:41:HDMI-A-2]
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_mode_debug_printmodeline [drm]] Modeline "800x480": 78 33300 800 845 846 846 480 502 503 503 0x48 0xa
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:32:HDMI-A-1] probed modes :
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:32:HDMI-A-1]
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]]
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] desired mode 800x480 set on crtc 86 (0,0)
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] picking CRTCs for 800x480 config
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] found mode 800x480
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] looking for preferred mode on connector 32 0
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] looking for cmdline mode on connector 32
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] Not using firmware configuration
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] connector 41 enabled? no
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] connector 32 enabled? yes
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:41:HDMI-A-2] disconnected
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:41:HDMI-A-2]
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_mode_debug_printmodeline [drm]] Modeline "800x480": 78 33300 800 845 846 846 480 502 503 503 0x48 0xa
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:32:HDMI-A-1] probed modes :
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:32:HDMI-A-1]
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]]
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] desired mode 800x480 set on crtc 86 (0,0)
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] picking CRTCs for 8192x8192 config
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] found mode 800x480
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] looking for preferred mode on connector 32 0
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] looking for cmdline mode on connector 32
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] Not using firmware configuration
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] connector 41 enabled? no
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]] connector 32 enabled? yes
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:41:HDMI-A-2] disconnected
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:41:HDMI-A-2] status updated from unknown to disconnected
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:41:HDMI-A-2]
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_mode_debug_printmodeline [drm]] Modeline "800x480": 78 33300 800 845 846 846 480 502 503 503 0x48 0xa
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:32:HDMI-A-1] probed modes :
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:32:HDMI-A-1] status updated from unknown to connected
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_helper_probe_single_connector_modes [drm_kms_helper]] [CONNECTOR:32:HDMI-A-1]
Feb 06 00:22:19 raspberrypi kernel: [drm:drm_client_modeset_probe [drm]]

.. which appears to not show any errors, but the screen still remains blank after trying to display the desktop.

wlr-randr shows...

Physical size: 150x100 mm
  Enabled: yes
  Modes:
    800x480 px, 78.253998 Hz (preferred, current)
  Position: 0,0
  Transform: normal
  Scale: 1.000000

... but nothing is displayed on the screen.

@JinShil
Copy link
Contributor

JinShil commented Feb 6, 2024

I also tried this EDID in an attempt to satisfy the datasheet and the EDID parsing algorithm...
image
.. but the symptom is the same.

@JinShil
Copy link
Contributor

JinShil commented Feb 6, 2024

The latest commit at https://github.com/raspberrypi/rpi-firmware/commits/master, "kernel: Bump to 6.1.74" works fine.

I'm now working through the commits at https://github.com/raspberrypi/rpi-firmware/commits/next, but I hit the GitHub rate limit. I'll continue tomorrow.

@6by9
Copy link
Contributor Author

6by9 commented Feb 6, 2024

Pi4 all along has had a restriction on odd values in the horizontal timings due to running at 2pixels/clock, but that should be enforce on 6.1 as well as 6.6
https://www.raspberrypi.com/documentation/computers/config_txt.html#hdmi-pipeline-for-raspberry-pi-4

Also double check your display datasheet - many quote a blank period that is sync + back porch, whereas DRM wants them independently. I think this is the case in your datasheet where thb is sync + back porch and must be 46 clocks, but the sync pulse (thpw) must be 1 to 40 of those clock cycles. Are you feeding your EDID editor with data in the right format?

@JinShil
Copy link
Contributor

JinShil commented Feb 6, 2024

The specific commit in the "Next" branch that introduced this symptom is raspberrypi/rpi-firmware@7fa525a, "Bump to kernel 6.6.5", apparently the first v6.6 commit.

@JinShil
Copy link
Contributor

JinShil commented Feb 8, 2024

Also double check your display datasheet - many quote a blank period that is sync + back porch

Thanks, that is indeed how the data is presented in this LCD's datasheet. From that, and the algorithm you posted earlier, I was able to create a working EDID by using a high Blank, and adjusting Sync to make the Back Porch match the Blank field in the datasheet.

This is what ultimately worked.
image

edid-decode shows ...

DTD 1:   800x480    59.780374 Hz   5:3     31.504 kHz     33.300000 MHz (150 mm x 100 mm)
                 Hfront  210 Hsync   1 Hback   46 Hpol N
                 Vfront   22 Vsync   2 Vback   23 Vpol N

... which matches the datasheet pretty well.

Still, what changed? Now I wonder if I need a different EDID for v6.1 and v6.6. I think I'll just avoid 6.1 and hope things remain stable going forward.

@6by9
Copy link
Contributor Author

6by9 commented Feb 8, 2024

(Sorry, I had missed you'd said PI5, so my comment on odd timings is irrelevant).

Your old EDID was invalid, so I suspect the core EDID parsing code has just been updated and now rejects it. d78c4ef looks like a likely candidate.

A valid EDID should work fine under 6.1 or 6.6.

@6by9
Copy link
Contributor Author

6by9 commented Feb 8, 2024

Note that your timings still don't match your display's datasheet.
I would expect something like

Hfront  210 Hsync   2 Hback   44 Hpol N
Vfront   22 Vsync   1 Vback   22 Vpol N

Hsync + Hback should add up to thb (46) in the datasheet, and likewise Vsync + Vback add up to tvb (23).

It's often difficult to tell, but potentially you'd have a 1 pixel shift, as the start of the image data would be read as 46 clocks from the start of the sync signal, and you've put the active data at 47 clocks later. It all depends on exactly how the TFP401 translates the HDMI timing into the signals for the panel. Use of kmstest (in package kms++-utils) is the easiest tool I use for this, as the test pattern it uses has a single pixel line around the hollow boxes in 3 of the 4 corners.

Using even horizontal timings will make the mode work on the Pi4 too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants