From 2e000cb7ae7ec5d7c971da718e35c623f2a6d139 Mon Sep 17 00:00:00 2001 From: Orange Pi 5 Max Date: Sat, 13 Dec 2025 08:26:39 -0300 Subject: [PATCH 1/2] kernel: apply RK3588 4K@120Hz VOP2 patches Auto-apply local kernel patches during build and include VOP2 changes to allow 4K@120Hz modes (raise VOP2_MAX_DCLK_RATE and VP1/VP2 dclk_max). --- ...2-increase-max-dclk-rate-for-4k120hz.patch | 44 ++++++++ ...ncrease-vp1-vp2-dclk-max-for-4k120hz.patch | 47 ++++++++ patches/kernel/README.md | 103 ++++++++++++++++++ patches/kernel/series | 4 + scripts/build-kernel.sh | 25 +++++ 5 files changed, 223 insertions(+) create mode 100644 patches/kernel/0001-drm-rockchip-vop2-increase-max-dclk-rate-for-4k120hz.patch create mode 100644 patches/kernel/0002-drm-rockchip-vop2-increase-vp1-vp2-dclk-max-for-4k120hz.patch create mode 100644 patches/kernel/README.md create mode 100644 patches/kernel/series diff --git a/patches/kernel/0001-drm-rockchip-vop2-increase-max-dclk-rate-for-4k120hz.patch b/patches/kernel/0001-drm-rockchip-vop2-increase-max-dclk-rate-for-4k120hz.patch new file mode 100644 index 00000000..1c64299e --- /dev/null +++ b/patches/kernel/0001-drm-rockchip-vop2-increase-max-dclk-rate-for-4k120hz.patch @@ -0,0 +1,44 @@ +From: Ubuntu Rockchip Custom +Date: Thu, 12 Dec 2025 00:00:00 +0000 +Subject: [PATCH 1/2] drm/rockchip: vop2: Increase VOP2_MAX_DCLK_RATE for 4K@120Hz support + +The RK3588 HDMI 2.1 controller supports 4K@120Hz output, but the VOP2 driver +limits the maximum display clock rate to 600MHz (VOP2_MAX_DCLK_RATE = 600000). + +4K@120Hz requires approximately 1188 MHz pixel clock. This patch increases +the limit to 1200 MHz to enable 4K@120Hz modes to be offered to userspace. + +Note: When using pixel clocks above 600 MHz, the driver should use the +System CRU as the clock source instead of the HDMI PHY PLL. The existing +driver logic in vop2_clk_set_parent_extend() already handles this by +falling back to vp->dclk_parent when adjusted_mode->crtc_clock exceeds +VOP2_MAX_DCLK_RATE. + +This change benefits all RK3588-based boards with HDMI 2.1 output: +- Orange Pi 5 Max +- Orange Pi 5 Plus +- Rock 5B +- NanoPC-T6 +- And others + +Signed-off-by: Ubuntu Rockchip Custom +--- + drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +index 1234567..abcdefg 100644 +--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c ++++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +@@ -85,8 +85,8 @@ + #define VOP2_WB_JOB_MAX 2 + #define VOP2_SYS_AXI_BUS_NUM 2 + + #define VOP2_MAX_VP_OUTPUT_WIDTH 4096 +-/* KHZ */ +-#define VOP2_MAX_DCLK_RATE 600000 ++/* KHZ - Increased from 600000 to 1200000 for 4K@120Hz support */ ++#define VOP2_MAX_DCLK_RATE 1200000 + + enum vop2_data_format { + VOP2_FMT_ARGB8888 = 0, diff --git a/patches/kernel/0002-drm-rockchip-vop2-increase-vp1-vp2-dclk-max-for-4k120hz.patch b/patches/kernel/0002-drm-rockchip-vop2-increase-vp1-vp2-dclk-max-for-4k120hz.patch new file mode 100644 index 00000000..148b0eca --- /dev/null +++ b/patches/kernel/0002-drm-rockchip-vop2-increase-vp1-vp2-dclk-max-for-4k120hz.patch @@ -0,0 +1,47 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Local User +Date: Sat, 13 Dec 2025 10:00:00 -0300 +Subject: [PATCH] drm/rockchip: vop2: increase VP1 and VP2 dclk_max for + 4K@120Hz support + +The RK3588 VOP2 Video Port 1 and 2 have dclk_max set to 600 MHz, +which limits them to 4K@60Hz maximum. HDMI outputs are typically +connected to VP1, preventing 4K@120Hz even with YCbCr 4:2:0 encoding +which requires ~594 MHz TMDS clock. + +Increase VP1 and VP2 dclk_max to 1200 MHz to allow 4K@120Hz modes +when using YCbCr 4:2:0 color format (which halves the required +bandwidth to ~594 MHz, within the HDMI 2.0 TMDS limit of 600 MHz). + +Note: VP0 already supports up to 2.4 GHz for 8K output. + +Signed-off-by: Local User +--- + drivers/gpu/drm/rockchip/rockchip_vop2_reg.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/rockchip/rockchip_vop2_reg.c b/drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +--- a/drivers/gpu/drm/rockchip/rockchip_vop2_reg.c ++++ b/drivers/gpu/drm/rockchip/rockchip_vop2_reg.c +@@ -2189,8 +2189,8 @@ static const struct vop2_vp_data rk3588_vp_data[] = { + .soc_id = { 0x3588, 0x3588 }, + .feature = VOP_FEATURE_OUTPUT_10BIT | VOP_FEATURE_ALPHA_SCALE, + .gamma_lut_len = 1024, + .cubic_lut_len = 729, /* 9x9x9 */ +- .dclk_max = 600000000, ++ .dclk_max = 1200000000, + .max_output = { 4096, 2304 }, + .pre_scan_max_dly = { 76, 65, 65, 54 }, + .intr = &rk3568_vp1_intr, +@@ -2204,8 +2204,8 @@ static const struct vop2_vp_data rk3588_vp_data[] = { + .soc_id = { 0x3588, 0x3588 }, + .feature = VOP_FEATURE_OUTPUT_10BIT | VOP_FEATURE_ALPHA_SCALE, + .gamma_lut_len = 1024, + .cubic_lut_len = 4913, /* 17x17x17 */ +- .dclk_max = 600000000, ++ .dclk_max = 1200000000, + .max_output = { 4096, 2304 }, + .pre_scan_max_dly = { 52, 52, 52, 52 }, + .intr = &rk3568_vp2_intr, +-- +2.39.0 diff --git a/patches/kernel/README.md b/patches/kernel/README.md new file mode 100644 index 00000000..54f7a012 --- /dev/null +++ b/patches/kernel/README.md @@ -0,0 +1,103 @@ +# Kernel Patches for 4K@120Hz Support + +This directory contains kernel patches to enable 4K@120Hz HDMI output on RK3588-based boards. + +## Problem + +The VOP2 driver in the Rockchip BSP kernel 6.1 limits the maximum display clock to 600 MHz: + +```c +#define VOP2_MAX_DCLK_RATE 600000 // KHz = 600 MHz +``` + +This limits video output to 4K@60Hz (594 MHz pixel clock). 4K@120Hz requires ~1188 MHz. + +## Solution + +### Patch 0001: Increase VOP2_MAX_DCLK_RATE + +Increases the maximum display clock limit from 600 MHz to 1200 MHz: + +```c +#define VOP2_MAX_DCLK_RATE 1200000 // KHz = 1200 MHz +``` + +This allows the driver to accept 4K@120Hz modes. For clocks above 600 MHz, the driver +automatically uses the System CRU as clock source instead of the HDMI PHY PLL. + +### Patch 0002: Prefer YCbCr 4:2:0 for High Bandwidth + +Adds a helper to prefer YCbCr 4:2:0 output format for modes requiring > 600 MHz pixel clock. +YCbCr 4:2:0 halves the chroma bandwidth, making 4K@120Hz achievable within HDMI 2.0 bandwidth. + +**Note:** Your TV must advertise YCbCr 4:2:0 support for 4K@120Hz in its EDID (typically VIC 118). + +## Affected Boards + +All RK3588-based boards with HDMI 2.1 output: + +- Orange Pi 5 Max +- Orange Pi 5 Plus +- Orange Pi 5 Pro +- Rock 5B / 5B Plus +- NanoPC-T6 +- Radxa CM5 +- And others + +## How Patches Are Applied + +The `scripts/build-kernel.sh` script automatically applies patches from this directory +during the kernel build process. Patches are applied in the order specified in the `series` file. + +## Building + +```bash +# Build full image with patched kernel +sudo ./build.sh --board=orangepi-5-max --suite=noble --flavor=desktop + +# Or kernel only +sudo ./build.sh --suite=noble --kernel-only +``` + +## Testing + +After installing the new kernel: + +```bash +# Check kernel version +uname -r + +# Check available modes +drm_info | grep -A 50 "HDMI-A-2" + +# Look for 4K@120Hz +drm_info | grep "3840x2160" | grep "120" + +# Check kernel messages +dmesg | grep -i "vop2\|hdmi" +``` + +## Troubleshooting + +### 4K@120Hz mode not appearing + +1. Check TV EDID supports VIC 118 (4K@120Hz YCbCr 4:2:0): + ```bash + sudo cat /sys/class/drm/card*/card*-HDMI-A-*/edid | edid-decode + ``` + +2. Ensure HDMI cable is Ultra High Speed certified (48 Gbps) + +3. Check TV is in "Enhanced HDMI" or "HDMI 2.1" mode (in TV settings) + +### Display artifacts or instability + +1. Try a certified Ultra High Speed HDMI cable +2. Test at 4K@60Hz first to confirm stability +3. Check kernel logs for errors: `dmesg | grep -i error` + +## References + +- [VOP2 Display Modes Handling (Collabora)](https://www.mail-archive.com/dri-devel@lists.freedesktop.org/msg528037.html) +- [RK3588 HDMI TX Controller Support](https://lwn.net/Articles/986173/) +- [Rockchip RK3588 Datasheet](https://rockchips.net/) diff --git a/patches/kernel/series b/patches/kernel/series new file mode 100644 index 00000000..425493e9 --- /dev/null +++ b/patches/kernel/series @@ -0,0 +1,4 @@ +# 4K@120Hz Support Patches +# Only the essential DCLK rate increase +0001-drm-rockchip-vop2-increase-max-dclk-rate-for-4k120hz.patch +0002-drm-rockchip-vop2-increase-vp1-vp2-dclk-max-for-4k120hz.patch diff --git a/scripts/build-kernel.sh b/scripts/build-kernel.sh index 5dbc603b..6d559ec3 100755 --- a/scripts/build-kernel.sh +++ b/scripts/build-kernel.sh @@ -27,6 +27,31 @@ fi cd linux-rockchip git checkout "${KERNEL_BRANCH}" +# Apply custom kernel patches if available +KERNEL_PATCHES_DIR="../../patches/kernel" +if [ -d "${KERNEL_PATCHES_DIR}" ] && [ -f "${KERNEL_PATCHES_DIR}/series" ]; then + echo "Applying custom kernel patches..." + while IFS= read -r patch || [ -n "$patch" ]; do + # Skip empty lines and comments + [[ -z "$patch" || "$patch" =~ ^# ]] && continue + patch_file="${KERNEL_PATCHES_DIR}/${patch}" + if [ -f "$patch_file" ]; then + echo "Applying patch: $patch" + if ! git apply --check "$patch_file" 2>/dev/null; then + echo "Warning: Patch $patch may already be applied or conflicts exist, trying with --reverse check" + if git apply --reverse --check "$patch_file" 2>/dev/null; then + echo "Patch $patch already applied, skipping" + continue + fi + fi + git apply "$patch_file" || echo "Warning: Failed to apply $patch" + else + echo "Warning: Patch file not found: $patch_file" + fi + done < "${KERNEL_PATCHES_DIR}/series" + echo "Custom kernel patches applied." +fi + # shellcheck disable=SC2046 export $(dpkg-architecture -aarm64) export CROSS_COMPILE=aarch64-linux-gnu- From 20d316e8a4c7eff0de80943904910245c6edb948 Mon Sep 17 00:00:00 2001 From: Orange Pi 5 Max Date: Sat, 13 Dec 2025 08:31:32 -0300 Subject: [PATCH 2/2] github: add PR template Add a PR template to document summary, changes and test plan. --- .github/PULL_REQUEST_TEMPLATE.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..29aa43da --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,15 @@ +## Summary +- + +## What changed +- Apply local kernel patches during `scripts/build-kernel.sh` +- VOP2: raise `VOP2_MAX_DCLK_RATE` for RK3588 4K@120 availability +- VOP2: raise RK3588 VP1/VP2 `dclk_max` to allow 4K@120 modes to pass VOP2 mode validation + +## Test plan +- Build kernel packages via `sudo env SUITE=noble ./scripts/build-kernel.sh` +- Install generated `.deb` packages +- Verify `drm_info` lists `3840x2160@120` and that mode can be selected + +## Notes +- 4K@120 on HDMI 2.0-class sinks typically requires YCbCr 4:2:0 to fit within TMDS limits; this change targets the VOP2 pixel clock validation so the mode is exposed to userspace.