Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/meson: fix colour distortion from HDR set during vendor u-boot

Add support for the OSD1 HDR registers so meson DRM can handle the HDR
properties set by Amlogic u-boot on G12A and newer devices which result
in blue/green/pink colour distortion to display output.

This takes the original patch submissions from Mathias [0] and [1] with
corrections for formatting and the missing description and attribution
needed for merge.

[0] https://lore.kernel.org/linux-amlogic/59dfd7e6-fc91-3d61-04c4-94e078a3188c@baylibre.com/T/
[1] https://lore.kernel.org/linux-amlogic/CAOKfEHBx_fboUqkENEMd-OC-NSrf46nto+vDLgvgttzPe99kXg@mail.gmail.com/T/#u

Fixes: 728883948b0d ("drm/meson: Add G12A Support for VIU setup")
Suggested-by: Mathias Steiger <mathias.steiger@googlemail.com>
Signed-off-by: Christian Hewitt <christianshewitt@gmail.com>
Tested-by: Neil Armstrong <narmstrong@baylibre.com>
Tested-by: Philip Milev <milev.philip@gmail.com>
[narmsrong: adding missing space on second tested-by tag]
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210806094005.7136-1-christianshewitt@gmail.com

authored by

Christian Hewitt and committed by
Neil Armstrong
bf33677a e89afb51

+11 -1
+5
drivers/gpu/drm/meson/meson_registers.h
··· 634 634 #define VPP_WRAP_OSD3_MATRIX_PRE_OFFSET2 0x3dbc 635 635 #define VPP_WRAP_OSD3_MATRIX_EN_CTRL 0x3dbd 636 636 637 + /* osd1 HDR */ 638 + #define OSD1_HDR2_CTRL 0x38a0 639 + #define OSD1_HDR2_CTRL_VDIN0_HDR2_TOP_EN BIT(13) 640 + #define OSD1_HDR2_CTRL_REG_ONLY_MAT BIT(16) 641 + 637 642 /* osd2 scaler */ 638 643 #define OSD2_VSC_PHASE_STEP 0x3d00 639 644 #define OSD2_VSC_INI_PHASE 0x3d01
+6 -1
drivers/gpu/drm/meson/meson_viu.c
··· 425 425 if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXM) || 426 426 meson_vpu_is_compatible(priv, VPU_COMPATIBLE_GXL)) 427 427 meson_viu_load_matrix(priv); 428 - else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) 428 + else if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) { 429 429 meson_viu_set_g12a_osd1_matrix(priv, RGB709_to_YUV709l_coeff, 430 430 true); 431 + /* fix green/pink color distortion from vendor u-boot */ 432 + writel_bits_relaxed(OSD1_HDR2_CTRL_REG_ONLY_MAT | 433 + OSD1_HDR2_CTRL_VDIN0_HDR2_TOP_EN, 0, 434 + priv->io_base + _REG(OSD1_HDR2_CTRL)); 435 + } 431 436 432 437 /* Initialize OSD1 fifo control register */ 433 438 reg = VIU_OSD_DDR_PRIORITY_URGENT |