Hi everyone,
After implementing a similar change in the VC4 driver [1], as suggested by Laurent in the ToDo list [2], I noticed that a similar pattern is used in the Exynos, Rockchip, STI and sun4i drivers.
This patchset replaces drm_detect_hdmi_monitor() with is_hdmi in the mentioned drivers.
Best wishes, José Expósito
[1] https://lore.kernel.org/dri-devel/20220420114500.187664-1-jose.exposito89@gm... [2] https://docs.kernel.org/gpu/todo.html#replace-drm-detect-hdmi-monitor-with-d...
José Expósito (5): drm/exynos: hdmi: Replace drm_detect_hdmi_monitor() with is_hdmi drm/rockchip: inno_hdmi: Replace drm_detect_hdmi_monitor() with is_hdmi drm/rockchip: rk3066_hdmi: Replace drm_detect_hdmi_monitor() with is_hdmi drm/sti/sti_hdmi: Replace drm_detect_hdmi_monitor() with is_hdmi drm/sun4i: hdmi: Replace drm_detect_hdmi_monitor() with is_hdmi
drivers/gpu/drm/exynos/exynos_hdmi.c | 15 +++++++++------ drivers/gpu/drm/rockchip/inno_hdmi.c | 8 ++++---- drivers/gpu/drm/rockchip/rk3066_hdmi.c | 6 +++--- drivers/gpu/drm/sti/sti_hdmi.c | 7 ++++--- drivers/gpu/drm/sti/sti_hdmi.h | 2 -- drivers/gpu/drm/sun4i/sun4i_hdmi.h | 1 - drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 6 +++--- 7 files changed, 23 insertions(+), 22 deletions(-)
Once EDID is parsed, the monitor HDMI support information is available through drm_display_info.is_hdmi.
This driver calls drm_detect_hdmi_monitor() to receive the same information and stores its own cached value, which is less efficient.
Avoid calling drm_detect_hdmi_monitor() and use drm_display_info.is_hdmi instead and also remove hdmi_context.dvi_mode as it is no longer necessary.
Signed-off-by: José Expósito jose.exposito89@gmail.com --- drivers/gpu/drm/exynos/exynos_hdmi.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 7655142a4651..a6743ae87728 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -119,7 +119,6 @@ struct hdmi_context { struct device *dev; struct drm_device *drm_dev; struct drm_connector connector; - bool dvi_mode; struct delayed_work hotplug_work; struct cec_notifier *notifier; const struct hdmi_driver_data *drv_data; @@ -811,11 +810,12 @@ static int hdmi_audio_infoframe_apply(struct hdmi_context *hdata) static void hdmi_reg_infoframes(struct hdmi_context *hdata) { struct drm_display_mode *m = &hdata->encoder.crtc->state->mode; + struct drm_display_info *display = &hdata->connector.display_info; union hdmi_infoframe frm; u8 buf[25]; int ret;
- if (hdata->dvi_mode) { + if (!display->is_hdmi) { hdmi_reg_writeb(hdata, HDMI_AVI_CON, HDMI_AVI_CON_DO_NOT_TRANSMIT); hdmi_reg_writeb(hdata, HDMI_VSI_CON, @@ -893,9 +893,9 @@ static int hdmi_get_modes(struct drm_connector *connector) if (!edid) return -ENODEV;
- hdata->dvi_mode = !drm_detect_hdmi_monitor(edid); DRM_DEV_DEBUG_KMS(hdata->dev, "%s : width[%d] x height[%d]\n", - (hdata->dvi_mode ? "dvi monitor" : "hdmi monitor"), + (connector->display_info.is_hdmi ? "hdmi monitor" : + "dvi monitor"), edid->width_cm, edid->height_cm);
drm_connector_update_edid_property(connector, edid); @@ -1118,9 +1118,10 @@ static void hdmi_audio_config(struct hdmi_context *hdata)
static void hdmi_audio_control(struct hdmi_context *hdata) { + struct drm_display_info *display = &hdata->connector.display_info; bool enable = !hdata->audio.mute;
- if (hdata->dvi_mode) + if (!display->is_hdmi) return;
hdmi_reg_writeb(hdata, HDMI_AUI_CON, enable ? @@ -1143,6 +1144,8 @@ static void hdmi_start(struct hdmi_context *hdata, bool start)
static void hdmi_conf_init(struct hdmi_context *hdata) { + struct drm_display_info *display = &hdata->connector.display_info; + /* disable HPD interrupts from HDMI IP block, use GPIO instead */ hdmi_reg_writemask(hdata, HDMI_INTC_CON, 0, HDMI_INTC_EN_GLOBAL | HDMI_INTC_EN_HPD_PLUG | HDMI_INTC_EN_HPD_UNPLUG); @@ -1155,7 +1158,7 @@ static void hdmi_conf_init(struct hdmi_context *hdata) /* disable bluescreen */ hdmi_reg_writemask(hdata, HDMI_CON_0, 0, HDMI_BLUE_SCR_EN);
- if (hdata->dvi_mode) { + if (!display->is_hdmi) { hdmi_reg_writemask(hdata, HDMI_MODE_SEL, HDMI_MODE_DVI_EN, HDMI_MODE_MASK); hdmi_reg_writeb(hdata, HDMI_CON_2,
Once EDID is parsed, the monitor HDMI support information is available through drm_display_info.is_hdmi.
This driver calls drm_detect_hdmi_monitor() to receive the same information and stores its own cached value, which is less efficient.
Avoid calling drm_detect_hdmi_monitor() and use drm_display_info.is_hdmi instead and also remove hdmi_data_info.sink_is_hdmi as it is no longer necessary.
Signed-off-by: José Expósito jose.exposito89@gmail.com --- drivers/gpu/drm/rockchip/inno_hdmi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/inno_hdmi.c b/drivers/gpu/drm/rockchip/inno_hdmi.c index 046e8ec2a71c..aa8b704d44a2 100644 --- a/drivers/gpu/drm/rockchip/inno_hdmi.c +++ b/drivers/gpu/drm/rockchip/inno_hdmi.c @@ -30,7 +30,6 @@
struct hdmi_data_info { int vic; - bool sink_is_hdmi; bool sink_has_audio; unsigned int enc_in_format; unsigned int enc_out_format; @@ -433,6 +432,8 @@ static int inno_hdmi_config_video_timing(struct inno_hdmi *hdmi, static int inno_hdmi_setup(struct inno_hdmi *hdmi, struct drm_display_mode *mode) { + struct drm_display_info *display = &hdmi->connector.display_info; + hdmi->hdmi_data.vic = drm_match_cea_mode(mode);
hdmi->hdmi_data.enc_in_format = HDMI_COLORSPACE_RGB; @@ -452,13 +453,13 @@ static int inno_hdmi_setup(struct inno_hdmi *hdmi,
/* Set HDMI Mode */ hdmi_writeb(hdmi, HDMI_HDCP_CTRL, - v_HDMI_DVI(hdmi->hdmi_data.sink_is_hdmi)); + v_HDMI_DVI(display->is_hdmi));
inno_hdmi_config_video_timing(hdmi, mode);
inno_hdmi_config_video_csc(hdmi);
- if (hdmi->hdmi_data.sink_is_hdmi) { + if (display->is_hdmi) { inno_hdmi_config_video_avi(hdmi, mode); inno_hdmi_config_video_vsi(hdmi, mode); } @@ -553,7 +554,6 @@ static int inno_hdmi_connector_get_modes(struct drm_connector *connector)
edid = drm_get_edid(connector, hdmi->ddc); if (edid) { - hdmi->hdmi_data.sink_is_hdmi = drm_detect_hdmi_monitor(edid); hdmi->hdmi_data.sink_has_audio = drm_detect_monitor_audio(edid); drm_connector_update_edid_property(connector, edid); ret = drm_add_edid_modes(connector, edid);
Once EDID is parsed, the monitor HDMI support information is available through drm_display_info.is_hdmi.
This driver calls drm_detect_hdmi_monitor() to receive the same information and stores its own cached value, which is less efficient.
Avoid calling drm_detect_hdmi_monitor() and use drm_display_info.is_hdmi instead and also remove hdmi_data_info.sink_is_hdmi as it is no longer necessary.
Signed-off-by: José Expósito jose.exposito89@gmail.com --- drivers/gpu/drm/rockchip/rk3066_hdmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/rk3066_hdmi.c b/drivers/gpu/drm/rockchip/rk3066_hdmi.c index 1c546c3a8998..a09dbb7d446a 100644 --- a/drivers/gpu/drm/rockchip/rk3066_hdmi.c +++ b/drivers/gpu/drm/rockchip/rk3066_hdmi.c @@ -22,7 +22,6 @@
struct hdmi_data_info { int vic; /* The CEA Video ID (VIC) of the current drm display mode. */ - bool sink_is_hdmi; unsigned int enc_out_format; unsigned int colorimetry; }; @@ -317,6 +316,8 @@ static void rk3066_hdmi_config_phy(struct rk3066_hdmi *hdmi) static int rk3066_hdmi_setup(struct rk3066_hdmi *hdmi, struct drm_display_mode *mode) { + struct drm_display_info *display = &hdmi->connector.display_info; + hdmi->hdmi_data.vic = drm_match_cea_mode(mode); hdmi->hdmi_data.enc_out_format = HDMI_COLORSPACE_RGB;
@@ -349,7 +350,7 @@ static int rk3066_hdmi_setup(struct rk3066_hdmi *hdmi,
rk3066_hdmi_config_video_timing(hdmi, mode);
- if (hdmi->hdmi_data.sink_is_hdmi) { + if (display->is_hdmi) { hdmi_modb(hdmi, HDMI_HDCP_CTRL, HDMI_VIDEO_MODE_MASK, HDMI_VIDEO_MODE_HDMI); rk3066_hdmi_config_avi(hdmi, mode); @@ -472,7 +473,6 @@ static int rk3066_hdmi_connector_get_modes(struct drm_connector *connector)
edid = drm_get_edid(connector, hdmi->ddc); if (edid) { - hdmi->hdmi_data.sink_is_hdmi = drm_detect_hdmi_monitor(edid); drm_connector_update_edid_property(connector, edid); ret = drm_add_edid_modes(connector, edid); kfree(edid);
Once EDID is parsed, the monitor HDMI support information is available through drm_display_info.is_hdmi.
This driver calls drm_detect_hdmi_monitor() to receive the same information and stores its own cached value, which is less efficient.
Avoid calling drm_detect_hdmi_monitor() and use drm_display_info.is_hdmi instead and also remove sti_hdmi.hdmi_monitor as it is no longer necessary.
Signed-off-by: José Expósito jose.exposito89@gmail.com --- drivers/gpu/drm/sti/sti_hdmi.c | 7 ++++--- drivers/gpu/drm/sti/sti_hdmi.h | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/sti/sti_hdmi.c b/drivers/gpu/drm/sti/sti_hdmi.c index f3ace11209dd..93841ba907a8 100644 --- a/drivers/gpu/drm/sti/sti_hdmi.c +++ b/drivers/gpu/drm/sti/sti_hdmi.c @@ -266,6 +266,7 @@ static void hdmi_active_area(struct sti_hdmi *hdmi) static void hdmi_config(struct sti_hdmi *hdmi) { u32 conf; + struct drm_display_info *display = &hdmi->drm_connector->display_info;
DRM_DEBUG_DRIVER("\n");
@@ -274,7 +275,7 @@ static void hdmi_config(struct sti_hdmi *hdmi)
/* Select encryption type and the framing mode */ conf |= HDMI_CFG_ESS_NOT_OESS; - if (hdmi->hdmi_monitor) + if (display->is_hdmi) conf |= HDMI_CFG_HDMI_NOT_DVI;
/* Set Hsync polarity */ @@ -984,9 +985,9 @@ static int sti_hdmi_connector_get_modes(struct drm_connector *connector) if (!edid) goto fail;
- hdmi->hdmi_monitor = drm_detect_hdmi_monitor(edid); DRM_DEBUG_KMS("%s : %dx%d cm\n", - (hdmi->hdmi_monitor ? "hdmi monitor" : "dvi monitor"), + (connector->display_info.is_hdmi ? "hdmi monitor" : + "dvi monitor"), edid->width_cm, edid->height_cm); cec_notifier_set_phys_addr_from_edid(hdmi->notifier, edid);
diff --git a/drivers/gpu/drm/sti/sti_hdmi.h b/drivers/gpu/drm/sti/sti_hdmi.h index 05b2f3d0d48d..6d4c3f57bc46 100644 --- a/drivers/gpu/drm/sti/sti_hdmi.h +++ b/drivers/gpu/drm/sti/sti_hdmi.h @@ -57,7 +57,6 @@ struct hdmi_audio_params { * @reset: reset control of the hdmi phy * @ddc_adapt: i2c ddc adapter * @colorspace: current colorspace selected - * @hdmi_monitor: true if HDMI monitor detected else DVI monitor assumed * @audio_pdev: ASoC hdmi-codec platform device * @audio: hdmi audio parameters. * @drm_connector: hdmi connector @@ -83,7 +82,6 @@ struct sti_hdmi { struct reset_control *reset; struct i2c_adapter *ddc_adapt; enum hdmi_colorspace colorspace; - bool hdmi_monitor; struct platform_device *audio_pdev; struct hdmi_audio_params audio; struct drm_connector *drm_connector;
Once EDID is parsed, the monitor HDMI support information is available through drm_display_info.is_hdmi.
This driver calls drm_detect_hdmi_monitor() to receive the same information and stores its own cached value, which is less efficient.
Avoid calling drm_detect_hdmi_monitor() and use drm_display_info.is_hdmi instead and also remove sun4i_hdmi.hdmi_monitor as it is no longer necessary.
Signed-off-by: José Expósito jose.exposito89@gmail.com --- drivers/gpu/drm/sun4i/sun4i_hdmi.h | 1 - drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi.h b/drivers/gpu/drm/sun4i/sun4i_hdmi.h index 00ca35f07ba5..65c801cd6f35 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi.h +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi.h @@ -285,7 +285,6 @@ struct sun4i_hdmi {
struct sun4i_drv *drv;
- bool hdmi_monitor; struct cec_adapter *cec_adap;
const struct sun4i_hdmi_variant *variant; diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c index 3799a745b7dd..d8b71710e8f6 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c @@ -99,6 +99,7 @@ static void sun4i_hdmi_enable(struct drm_encoder *encoder) { struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; struct sun4i_hdmi *hdmi = drm_encoder_to_sun4i_hdmi(encoder); + struct drm_display_info *display = &hdmi->connector.display_info; u32 val = 0;
DRM_DEBUG_DRIVER("Enabling the HDMI Output\n"); @@ -111,7 +112,7 @@ static void sun4i_hdmi_enable(struct drm_encoder *encoder) writel(val, hdmi->base + SUN4I_HDMI_PKT_CTRL_REG(0));
val = SUN4I_HDMI_VID_CTRL_ENABLE; - if (hdmi->hdmi_monitor) + if (display->is_hdmi) val |= SUN4I_HDMI_VID_CTRL_HDMI_MODE;
writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG); @@ -215,9 +216,8 @@ static int sun4i_hdmi_get_modes(struct drm_connector *connector) if (!edid) return 0;
- hdmi->hdmi_monitor = drm_detect_hdmi_monitor(edid); DRM_DEBUG_DRIVER("Monitor is %s monitor\n", - hdmi->hdmi_monitor ? "an HDMI" : "a DVI"); + connector->display_info.is_hdmi ? "an HDMI" : "a DVI");
drm_connector_update_edid_property(connector, edid); cec_s_phys_addr_from_edid(hdmi->cec_adap, edid);
On Thu, 21 Apr 2022 19:07:25 +0200, José Expósito wrote:
Once EDID is parsed, the monitor HDMI support information is available through drm_display_info.is_hdmi.
This driver calls drm_detect_hdmi_monitor() to receive the same information and stores its own cached value, which is less efficient.
Avoid calling drm_detect_hdmi_monitor() and use drm_display_info.is_hdmi instead and also remove sun4i_hdmi.hdmi_monitor as it is no longer necessary.
[...]
Applied to drm/drm-misc (drm-misc-next).
Thanks! Maxime
On Thu, 21 Apr 2022 19:07:20 +0200, José Expósito wrote:
After implementing a similar change in the VC4 driver [1], as suggested by Laurent in the ToDo list [2], I noticed that a similar pattern is used in the Exynos, Rockchip, STI and sun4i drivers.
This patchset replaces drm_detect_hdmi_monitor() with is_hdmi in the mentioned drivers.
[...]
Applied, thanks!
[2/5] drm/rockchip: inno_hdmi: Replace drm_detect_hdmi_monitor() with is_hdmi commit: d449222dd533ca83a3a2f88aafe06fdd8d589280 [3/5] drm/rockchip: rk3066_hdmi: Replace drm_detect_hdmi_monitor() with is_hdmi commit: d2eabdb64474c2101953859601794f1ea08ec1d9
Best regards,
dri-devel@lists.freedesktop.org