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 for cropping P030/SAND128 on Pi5 #6741

Merged
merged 2 commits into from
Apr 2, 2025

Conversation

6by9
Copy link
Contributor

@6by9 6by9 commented Mar 25, 2025

Addresses 2 of the glitches seen with zooming 10bit HEVC under Kodi.

Diagonal corruption when overlaying GUI with 10bit HEVC, or flickering for 8bit HEVC is still being investigated.

@6by9 6by9 force-pushed the rpi-6.12.y-drm2 branch from 1e3b7b5 to f66f47b Compare March 31, 2025 16:25
@6by9
Copy link
Contributor Author

6by9 commented Mar 31, 2025

Diagonal corruption is something else, and not apparently related to background fill (tested by permanently enabling it). Suspect it is system load, but it is weird that it is only when updating the GUI layer that it causes problems.
Solving that one will have to wait.

@HiassofT
Copy link
Contributor

In the initial version of this PR the Interstellar trailer worked fine on all zoom levels, on a 1920x1080p60 display, with the recent however the "blank screen" issue at zoom level 1.11 is back (as before the change).

Here's kmsprint output with zoom level 1.11 and display blanking out:

rpi5:~ # kmsprint 
Connector 0 (33) HDMI-A-1 (connected)
  Encoder 0 (32) TMDS
    Crtc 2 (92) 1920x1080@60.00 148.500 1920/88/44/148/+ 1080/4/5/36/+ 60 (60.00) D 
      Plane 2 (81) fb-id: 684 (crtcs: 2) 0,0 3840x1608 -> -106,94 2132x894 (XR24 AR24 AB24 XB24 RG16 BG16 AR15 XR15 RG24 BG24 YU16 YV16 YU24 YV24 YU12 YV12 NV12 NV21 NV16 NV61 P030 XR30 AR30 AB30 XB30 RGB8 BGR8 XR12 AR12 XB12 AB12 BX12 BA12 RX12 RA12)
        FB 684 0x0 (�j�
      Plane 4 (105) fb-id: 681 (crtcs: 1 2 3) 0,0 1920x1080 -> 0,0 1920x1080 (XR24 AR24 AB24 XB24 RG16 BG16 AR15 XR15 RG24 BG24 YU16 YV16 YU24 YV24 YU12 YV12 NV12 NV21 NV16 NV61 P030 XR30 AR30 AB30 XB30 RGB8 BGR8 XR12 AR12 XB12 AB12 BX12 BA12 RX12 RA12)
        FB 681 1920x1080 AR24
Connector 1 (42) HDMI-A-2 (disconnected)
  Encoder 1 (41) TMDS

@6by9
Copy link
Contributor Author

6by9 commented Mar 31, 2025

Which version of the Interstellar trailer is it? 4k 10bit HEVC being downscaled to 1080p60?

@HiassofT
Copy link
Contributor

The trailer is 4k HEVC 8bit. I'm using a 1920x1200 monitor here on my test setup, kodi GUI resolution set to 1920x1080p60 which is also used while playing this sample (the monitor doesn't support 24p)

$ ls -l Interstellar-divx-hevc-uhd-51ch-4K.mkv 
-rwxrw-r-- 2 hias hias 403766800 Jun 18  2019 Interstellar-divx-hevc-uhd-51ch-4K.mkv
$ md5sum Interstellar-divx-hevc-uhd-51ch-4K.mkv 
ad611d6067ff79b5b45bd3c571859c23  Interstellar-divx-hevc-uhd-51ch-4K.mkv
$ mediainfo Interstellar-divx-hevc-uhd-51ch-4K.mkv 
General
Unique ID                                : 86748321257335288719775507338167402396 (0x41431E73BC456F9EC4B2746B21093F9C)
Complete name                            : Interstellar-divx-hevc-uhd-51ch-4K.mkv
Format                                   : Matroska
Format version                           : Version 1
File size                                : 385 MiB
Duration                                 : 2 min 24 s
Overall bit rate                         : 22.3 Mb/s
Frame rate                               : 24.000 FPS
Writing application                      : DivXMKVMux 9.9.12.5441
Writing library                          : libDivXMediaFormat 4.0.0.0578

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main@L5.1@Main
Codec ID                                 : V_MPEGH/ISO/HEVC
Duration                                 : 2 min 24 s
Bit rate                                 : 21.2 Mb/s
Width                                    : 3 840 pixels
Height                                   : 1 608 pixels
Display aspect ratio                     : 2.40:1
Frame rate mode                          : Constant
Frame rate                               : 24.000 FPS
Standard                                 : Component
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Bits/(Pixel*Frame)                       : 0.143
Stream size                              : 366 MiB (95%)
Language                                 : English
Default                                  : Yes
Forced                                   : No
Color range                              : Full

Audio
ID                                       : 2
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Commercial name                          : Dolby Digital
Codec ID                                 : A_AC3
Duration                                 : 2 min 24 s
Bit rate mode                            : Constant
Bit rate                                 : 640 kb/s
Channel(s)                               : 6 channels
Channel layout                           : L R C LFE Ls Rs
Sampling rate                            : 48.0 kHz
Frame rate                               : 31.250 FPS (1536 SPF)
Bit depth                                : 16 bits
Compression mode                         : Lossy
Stream size                              : 11.0 MiB (3%)
Language                                 : English
Service kind                             : Complete Main
Default                                  : Yes
Forced                                   : No

@6by9
Copy link
Contributor Author

6by9 commented Apr 1, 2025

Thanks. I hadn't seen a failure at all with 8bit content, but that does seem to provoke one.

Increasing fetch_count by one for 8bit (x_offset & 31) == 30 covers some situations, but there's another case that is still failing at x1.58, which because it is 4k being scaled to 1080p is a greater crop/scale than all my 4k on 4k tests.

@6by9
Copy link
Contributor Author

6by9 commented Apr 2, 2025

I've found the actual cause.

https://github.com/raspberrypi/linux/blob/rpi-6.12.y/drivers/gpu/drm/vc4/vc4_plane.c#L2016-L2032 increases the source size if fractionally cropping a pixel at the edge. There are conditions for SAND where that will require an extra word to be fetched, however fetch_count had already been computed. Fetching insufficient words results in a total stall.

BCM2712/vc6 uses 256bit words when reading in P030/SAND128,
increased from 128bit on BCM2711/vc5.

Update the code for cropping the read area to handle the correct
word length.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
@6by9 6by9 force-pushed the rpi-6.12.y-drm2 branch from f66f47b to d65bae9 Compare April 2, 2025 16:21
@popcornmix
Copy link
Collaborator

Nice this feels more satisfactory that previous version.

The number of words to fetch for SAND formats on vc6 needs to account
for all pixels requested by width.

If cropping fractional pixels, then the width was being increased, but
fetch_count had already been computed. That led to insufficient words
being fetched, and the HVS locked up solid.

Apply the fixup for fractional pixel source cropping before computing
fetch_count.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
@6by9 6by9 force-pushed the rpi-6.12.y-drm2 branch from d65bae9 to 90359ef Compare April 2, 2025 16:27
@HiassofT
Copy link
Contributor

HiassofT commented Apr 2, 2025

Thanks a lot, testing with your latest update looks good here 👍

@pelwell pelwell merged commit 350deb5 into raspberrypi:rpi-6.12.y Apr 2, 2025
13 checks passed
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Apr 2, 2025
…se HATs

See: raspberrypi/linux#6758

kernel: ads7846 touch overlay fixups
See: raspberrypi/linux#6760

kernel: staging: bcm2835-camera: Initialise dev in v4l2_dev
See: raspberrypi/linux#6754

kernel: media: i2c: imx415: Correct hmax_min values for 891Mbps/lane
See: raspberrypi/linux#6750

kernel: PCI: pcie-brcmstb: fake MSIx support on internal MSI target
See: raspberrypi/linux#6761

kernel: DRM fixes for cropping P030/SAND128 on Pi5
See: raspberrypi/linux#6741

kernel: Show process name in set_mempolicy() ignored message
See: raspberrypi/linux#6762
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Apr 2, 2025
…se HATs

See: raspberrypi/linux#6758

kernel: ads7846 touch overlay fixups
See: raspberrypi/linux#6760

kernel: staging: bcm2835-camera: Initialise dev in v4l2_dev
See: raspberrypi/linux#6754

kernel: media: i2c: imx415: Correct hmax_min values for 891Mbps/lane
See: raspberrypi/linux#6750

kernel: PCI: pcie-brcmstb: fake MSIx support on internal MSI target
See: raspberrypi/linux#6761

kernel: DRM fixes for cropping P030/SAND128 on Pi5
See: raspberrypi/linux#6741

kernel: Show process name in set_mempolicy() ignored message
See: raspberrypi/linux#6762
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