Add additional YUV420 bus format check for dw-meson's bridge enable
Subsystems (5)
v3 cover Add additional YUV420 bus format check for dw-meson's bridge enable
This is a belated follow-up on
https://lore.kernel.org/dri-devel/[email protected]
Commit e67f6037ae1be34b2b68 ("drm/meson: split out encoder from meson_dw_hdmi") broke 4K display modes for me, and I discovered it was because the right pixel clock wasn't being chosen in dw_hdmi_phy_init. I misinterpreted the reason as a problem in figuring out whether we want to enforce YUV420 mode, but it turned out to be a mismatch between what dw-meson code is doing and the way the bus format is being picked by the dw-hdmi bus output format drm helper.
I fixed it by bringing back dw-hdmi bus format check in dw-meson.
The second patch makes sure YUV420 bus format is the only one being returned by dw-hdmi's output format bridge function when that's the only drm mode allowed.
Changelog:
v3:
- Change commit message for all three commits to accurately reflect the modified files' subsystem.
- Add v1's Acked-by tags from subsystem maintainer
v2:
- Add commit message to patch number 3 in the series
Adrián Larumbe (3):
drm/bridge: dw-hdmi: change YUV420 selection logic at clock setup drm/bridge: dw-hdmi: truly enforce 420-only formats when drm mode
demands it
drm/bridge: dw-hdmi: remove dead code and fix indentation
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 35 +++++++++-------------- drivers/gpu/drm/meson/meson_dw_hdmi.c | 4 +-- include/drm/bridge/dw_hdmi.h | 2 ++ 3 files changed, 18 insertions(+), 23 deletions(-)
Signature · 1 line
2.40.0
PATCH v3 1/3 drm/bridge: dw-hdmi: change YUV420 selection logic at clock setup
Right now clocking value selection code is prioritising RGB, YUV444 modes over YUV420 for HDMI2 sinks. However, because of the bus format selection procedure in dw-hdmi, for HDMI2 sinks YUV420 is the format that will always be picked during the drm bridge chain check stage.
Later on dw_hdmi_setup will configure a colour space based on the bus format that doesn't match the pixel value we had calculated as described above.
Fix it by bringing back dw-hdmi bus format check when picking the right pixel clock.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 6 ++++++ drivers/gpu/drm/meson/meson_dw_hdmi.c | 4 ++-- include/drm/bridge/dw_hdmi.h | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +6 -0
@@ -3346,6 +3346,12 @@ static int dw_hdmi_parse_dt(struct dw_hdmi *hdmi)return 0 ; } +bool dw_hdmi_bus_fmt_is_420 (struct dw_hdmi *hdmi) +{ +return hdmi_bus_fmt_is_yuv420 (hdmi->hdmi_data.enc_out_bus_format); +} +EXPORT_SYMBOL_GPL (dw_hdmi_bus_fmt_is_420); +struct dw_hdmi *dw_hdmi_probe (struct platform_device *pdev,const struct dw_hdmi_plat_data *plat_data) {
drivers/gpu/drm/meson/meson_dw_hdmi.c +2 -2
@@ -379,8 +379,8 @@ static int dw_hdmi_phy_init(struct dw_hdmi *hdmi, void *data, mode->clock > 340000 ? 40 : 10);if (drm_mode_is_420_only (display, mode) || - (!is_hdmi2_sink && -drm_mode_is_420_also (display, mode))) + (!is_hdmi2_sink &&drm_mode_is_420_also (display, mode)) || +dw_hdmi_bus_fmt_is_420 (hdmi)) mode_is_420 = true;/* Enable clocks */
include/drm/bridge/dw_hdmi.h +2 -0
@@ -206,4 +206,6 @@ void dw_hdmi_phy_update_hpd(struct dw_hdmi *hdmi, void *data, bool force, bool disabled, bool rxsense);void dw_hdmi_phy_setup_hpd (struct dw_hdmi *hdmi,void *data); +bool dw_hdmi_bus_fmt_is_420 (struct dw_hdmi *hdmi); +#endif /* __IMX_HDMI_H__ */
Signature · 1 line
2.40.0
PATCH v3 2/3 drm/bridge: dw-hdmi: truly enforce 420-only formats when drm mode demands it
In reply to Adrián LarumbeThe current output bus format selection logic is enforcing YUV420 even when the drm mode allows for other bus formats as well.
Fix it by adding check for 420-only drm modes.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4 -3
@@ -2710,9 +2710,10 @@ static u32 *dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,/* Default 8bit fallback */ output_fmts[i++] =MEDIA_BUS_FMT_UYYVYY8_0_5X24 ; - *num_output_fmts = i; - -return output_fmts; +if (drm_mode_is_420_only (info, mode)) { + *num_output_fmts = i; +return output_fmts; + } }/*
Signature · 1 line
2.40.0
PATCH v3 3/3 drm/bridge: dw-hdmi: remove dead code and fix indentation
In reply to Adrián LarumbeThe hdmi_datamap enum is no longer in use. Also reindent enable_audio's call params.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4 -18
@@ -49,20 +49,6 @@#define HDMI14_MAX_TMDSCLK 340000000 -enum hdmi_datamap { -RGB444_8B =0x01 , -RGB444_10B =0x03 , -RGB444_12B =0x05 , -RGB444_16B =0x07 , - YCbCr444_8B =0x09 , - YCbCr444_10B =0x0B , - YCbCr444_12B =0x0D , - YCbCr444_16B =0x0F , - YCbCr422_8B =0x16 , - YCbCr422_10B =0x14 , - YCbCr422_12B =0x12 , -}; -static const u16 csc_coeff_default[3 ][4 ] = { {0x2000 ,0x0000 ,0x0000 ,0x0000 }, {0x0000 ,0x2000 ,0x0000 ,0x0000 },
@@ -856,10 +842,10 @@ static void dw_hdmi_gp_audio_enable(struct dw_hdmi *hdmi)if (pdata->enable_audio) pdata->enable_audio (hdmi, - hdmi->channels, - hdmi->sample_width, - hdmi->sample_rate, - hdmi->sample_non_pcm); + hdmi->channels, + hdmi->sample_width, + hdmi->sample_rate, + hdmi->sample_non_pcm); }static void dw_hdmi_gp_audio_disable (struct dw_hdmi *hdmi)
Signature · 1 line
2.40.0
Hi,
Quoted 11 lines · Adrián Larumbe
This is a belated follow-up on
https://lore.kernel.org/dri-devel/[email protected]Commit
e67f6037ae1be34b2b68("drm/meson: split out encoder frommeson_dw_hdmi") broke 4K display modes for me, and I discovered it was because the right pixel clock wasn't being chosen indw_hdmi_phy_init. I misinterpreted the reason as a problem in figuring out whether we want to enforce YUV420 mode, but it turned out to be a mismatch between what dw-meson code is doing and the way the bus format is being picked by the dw-hdmi bus output format drm helper.
Quoted 1 line
[...]
Thanks, Applied to https://anongit.freedesktop.org/git/drm/drm-misc.git (drm-misc-next)
[1/3] drm/bridge: dw-hdmi: change YUV420 selection logic at clock setup
https://cgit.freedesktop.org/drm/drm-misc/commit/?id=7ed40ff1d134bf3a4aef706eed478b926f35b404 [2/3] drm/bridge: dw-hdmi: truly enforce 420-only formats when drm mode demands it https://cgit.freedesktop.org/drm/drm-misc/commit/?id=f3710b424a96078f416e1be9cf52b87eadabae78 [3/3] drm/bridge: dw-hdmi: remove dead code and fix indentation https://cgit.freedesktop.org/drm/drm-misc/commit/?id=2299a8d12c1cbcdc7086027615d9936a970e7d68
Signature · 1 line
Neil