Re: [PATCH v13 27/28] drm/rockchip: inno_hdmi: Switch to HDMI connector

Maxime Ripard
2024-05-16T09:36:44Z

[-- Attachment #1.1: Type: text/plain, Size: 5184 bytes --]

Hi Andy,

On Sun, May 12, 2024 at 04:29:47PM +0800, Andy Yan wrote:
> At 2024-05-07 21:17:45, "Maxime Ripard" <mripard@kernel.org> wrote:
> >The new HDMI connector infrastructure allows to remove some boilerplate,
> >especially to generate infoframes. Let's switch to it.
> >
> >Reviewed-by: Heiko Stuebner <heiko@sntech.de>
> >Acked-by: Heiko Stuebner <heiko@sntech.de>
> >Signed-off-by: Maxime Ripard <mripard@kernel.org>
> >---
> > drivers/gpu/drm/rockchip/Kconfig | 3 +
> > drivers/gpu/drm/rockchip/inno_hdmi.c | 153 ++++++++++++---------------------
> > drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 3 +
> > 3 files changed, 61 insertions(+), 98 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
> >index 1bf3e2829cd0..7df875e38517 100644
> >--- a/drivers/gpu/drm/rockchip/Kconfig
> >+++ b/drivers/gpu/drm/rockchip/Kconfig
> >@@ -72,10 +72,13 @@ config ROCKCHIP_DW_MIPI_DSI
> > enable MIPI DSI on RK3288 or RK3399 based SoC, you should
> > select this option.
> >
> > config ROCKCHIP_INNO_HDMI
> > bool "Rockchip specific extensions for Innosilicon HDMI"
> >+ select DRM_DISPLAY_HDMI_HELPER
> >+ select DRM_DISPLAY_HDMI_STATE_HELPER
> >+ select DRM_DISPLAY_HELPER
> > help
> > This selects support for Rockchip SoC specific extensions
> > for the Innosilicon HDMI driver. If you want to enable
> > HDMI on RK3036 based SoC, you should select this option.
> >
> >diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c
> >index 3df2cfcf9998..5069403c3b80 100644
> >--- a/drivers/gpu/drm/rockchip/inno_hdmi.c
> >+++ b/drivers/gpu/drm/rockchip/inno_hdmi.c
> >@@ -20,10 +20,13 @@
> > #include <drm/drm_edid.h>
> > #include <drm/drm_of.h>
> > #include <drm/drm_probe_helper.h>
> > #include <drm/drm_simple_kms_helper.h>
> >
> >+#include <drm/display/drm_hdmi_helper.h>
> >+#include <drm/display/drm_hdmi_state_helper.h>
> >+
> ......
> >
> > static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi)
> > {
> > struct drm_connector *connector = &hdmi->connector;
> > struct drm_connector_state *conn_state = connector->state;
> >@@ -359,12 +323,12 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi)
> > value = v_VIDEO_INPUT_BITS(VIDEO_INPUT_8BITS) |
> > v_VIDEO_OUTPUT_COLOR(0) |
> > v_VIDEO_INPUT_CSP(0);
> > hdmi_writeb(hdmi, HDMI_VIDEO_CONTRL2, value);
> >
> >- if (inno_conn_state->enc_out_format == HDMI_COLORSPACE_RGB) {
> >- if (inno_conn_state->rgb_limited_range) {
> >+ if (conn_state->hdmi.output_format == HDMI_COLORSPACE_RGB) {
> >+ if (conn_state->hdmi.is_limited_range) {
> > csc_mode = CSC_RGB_0_255_TO_RGB_16_235_8BIT;
> > auto_csc = AUTO_CSC_DISABLE;
> > c0_c2_change = C0_C2_CHANGE_DISABLE;
> > csc_enable = v_CSC_ENABLE;
> >
> >@@ -378,18 +342,18 @@ static int inno_hdmi_config_video_csc(struct inno_hdmi *hdmi)
> > v_VIDEO_C0_C2_SWAP(C0_C2_CHANGE_DISABLE));
> > return 0;
> > }
> > } else {
> > if (inno_conn_state->colorimetry == HDMI_COLORIMETRY_ITU_601) {
> >- if (inno_conn_state->enc_out_format == HDMI_COLORSPACE_YUV444) {
> >+ if (conn_state->hdmi.output_format == HDMI_COLORSPACE_YUV444) {
> > csc_mode = CSC_RGB_0_255_TO_ITU601_16_235_8BIT;
> > auto_csc = AUTO_CSC_DISABLE;
> > c0_c2_change = C0_C2_CHANGE_DISABLE;
> > csc_enable = v_CSC_ENABLE;
> > }
> > } else {
> >- if (inno_conn_state->enc_out_format == HDMI_COLORSPACE_YUV444) {
> >+ if (conn_state->hdmi.output_format == HDMI_COLORSPACE_YUV444) {
> > csc_mode = CSC_RGB_0_255_TO_ITU709_16_235_8BIT;
> > auto_csc = AUTO_CSC_DISABLE;
> > c0_c2_change = C0_C2_CHANGE_DISABLE;
> > csc_enable = v_CSC_ENABLE;
> > }
> >@@ -460,14 +424,16 @@ static int inno_hdmi_config_video_timing(struct inno_hdmi *hdmi,
> >
> > return 0;
> > }
> >
> > static int inno_hdmi_setup(struct inno_hdmi *hdmi,
> >- struct drm_display_mode *mode)
> >+ struct drm_crtc_state *new_crtc_state,
> >+ struct drm_connector_state *new_conn_state)
> > {
> >- struct drm_display_info *display = &hdmi->connector.display_info;
> >- unsigned long mpixelclock = mode->clock * 1000;
> >+ struct drm_connector *connector = &hdmi->connector;
> >+ struct drm_display_info *display = &connector->display_info;
> >+ struct drm_display_mode *mode = &new_crtc_state->adjusted_mode;
> >
> > /* Mute video and audio output */
> > hdmi_modb(hdmi, HDMI_AV_MUTE, m_AUDIO_MUTE | m_VIDEO_BLACK,
> > v_AUDIO_MUTE(1) | v_VIDEO_MUTE(1));
> >
> >@@ -477,26 +443,26 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi,
> >
> > inno_hdmi_config_video_timing(hdmi, mode);
> >
> > inno_hdmi_config_video_csc(hdmi);
> >
> >- if (display->is_hdmi)
> >- inno_hdmi_config_video_avi(hdmi, mode);
> >+ drm_atomic_helper_connector_hdmi_update_infoframes(connector,
> >+ new_conn_state->state);
> >
>
> new_conn_state->state will be set NULL in drm_atomic_helper_swap_state,
> so this will cause a NULL pointer reference panic here.

That's a good catch, I'll fix it, thanks!
Maxime

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]