From 708e8b2b2a2159f36d72eb1111ee1116bdd61473 Mon Sep 17 00:00:00 2001 From: forain Date: Wed, 17 Jul 2024 19:57:05 +0800 Subject: [PATCH] DPU: fix bugs of DPU and resolve compilation warnings 1. fix the bug of zero pointer crash during the switch DSI 2. fix the bug of not being able to play sound through HDMI 3. resolve warnings of DPU during compilation Signed-off-by: forain --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 50 ++--------------------- drivers/gpu/drm/verisilicon/dw_mipi_dsi.c | 9 ++-- drivers/gpu/drm/verisilicon/vs_drv.c | 4 +- drivers/phy/synopsys/phy-dw-mipi-dphy.c | 2 + 4 files changed, 11 insertions(+), 54 deletions(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 423923ad4e902..8c0ee1ea830cf 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -682,10 +682,12 @@ static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi, cts = 0; } + hdmi->audio_enable = true; spin_lock_irq(&hdmi->audio_lock); hdmi->audio_n = n; hdmi->audio_cts = cts; hdmi_set_cts_n(hdmi, cts, hdmi->audio_enable ? n : 0); + hdmi_writeb(hdmi, 0x4, HDMI_AUD_INPUTCLKFS); spin_unlock_irq(&hdmi->audio_lock); } @@ -1073,18 +1075,6 @@ static void hdmi_video_sample(struct dw_hdmi *hdmi) hdmi_writeb(hdmi, 0x0, HDMI_TX_BCBDATA1); } -static int is_color_space_conversion(struct dw_hdmi *hdmi) -{ - struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data; - bool is_input_rgb, is_output_rgb; - - is_input_rgb = hdmi_bus_fmt_is_rgb(hdmi_data->enc_in_bus_format); - is_output_rgb = hdmi_bus_fmt_is_rgb(hdmi_data->enc_out_bus_format); - - return (is_input_rgb != is_output_rgb) || - (is_input_rgb && is_output_rgb && hdmi_data->rgb_limited_range); -} - static int is_color_space_decimation(struct dw_hdmi *hdmi) { if (!hdmi_bus_fmt_is_yuv422(hdmi->hdmi_data.enc_out_bus_format)) @@ -1109,13 +1099,6 @@ static int is_color_space_interpolation(struct dw_hdmi *hdmi) return 0; } -static bool is_csc_needed(struct dw_hdmi *hdmi) -{ - return is_color_space_conversion(hdmi) || - is_color_space_decimation(hdmi) || - is_color_space_interpolation(hdmi); -} - static void dw_hdmi_update_csc_coeffs(struct dw_hdmi *hdmi) { const u16 (*csc_coeff)[3][4] = &csc_coeff_default; @@ -2175,33 +2158,6 @@ static void dw_hdmi_enable_video_path(struct dw_hdmi *hdmi) hdmi_writeb(hdmi, 0x0B, HDMI_FC_CH0PREAM); hdmi_writeb(hdmi, 0x16, HDMI_FC_CH1PREAM); hdmi_writeb(hdmi, 0x21, HDMI_FC_CH2PREAM); - - /* Enable pixel clock and tmds data path */ - hdmi->mc_clkdis |= HDMI_MC_CLKDIS_HDCPCLK_DISABLE | - HDMI_MC_CLKDIS_CSCCLK_DISABLE | - HDMI_MC_CLKDIS_AUDCLK_DISABLE | - HDMI_MC_CLKDIS_PREPCLK_DISABLE | - HDMI_MC_CLKDIS_TMDSCLK_DISABLE; - hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_PIXELCLK_DISABLE; - hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); - - hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_TMDSCLK_DISABLE; - hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); - - /* Enable csc path */ - if (is_csc_needed(hdmi)) { - hdmi->mc_clkdis &= ~HDMI_MC_CLKDIS_CSCCLK_DISABLE; - hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); - - hdmi_writeb(hdmi, HDMI_MC_FLOWCTRL_FEED_THROUGH_OFF_CSC_IN_PATH, - HDMI_MC_FLOWCTRL); - } else { - hdmi->mc_clkdis |= HDMI_MC_CLKDIS_CSCCLK_DISABLE; - hdmi_writeb(hdmi, hdmi->mc_clkdis, HDMI_MC_CLKDIS); - - hdmi_writeb(hdmi, HDMI_MC_FLOWCTRL_FEED_THROUGH_OFF_CSC_BYPASS, - HDMI_MC_FLOWCTRL); - } } /* Workaround to clear the overflow condition */ @@ -3396,7 +3352,7 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, hdmi->disabled = true; hdmi->rxsense = true; hdmi->phy_mask = (u8)~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE); - hdmi->mc_clkdis = 0x7f; + hdmi->mc_clkdis = 0x0; hdmi->last_connector_result = connector_status_disconnected; mutex_init(&hdmi->mutex); diff --git a/drivers/gpu/drm/verisilicon/dw_mipi_dsi.c b/drivers/gpu/drm/verisilicon/dw_mipi_dsi.c index 6c3ed4234c2af..029d4705fdd79 100644 --- a/drivers/gpu/drm/verisilicon/dw_mipi_dsi.c +++ b/drivers/gpu/drm/verisilicon/dw_mipi_dsi.c @@ -439,9 +439,9 @@ static int dw_mipi_dsi_read(struct dw_mipi_dsi *dsi, return ret; } - ret = dsi_read(dsi, DSI_GEN_PLD_DATA, &val); - if (unlikely(ret)) - return ret; + ret = dsi_read(dsi, DSI_GEN_PLD_DATA, &val); + if (unlikely(ret)) + return ret; for (j = 0; j < 4 && j + i < len; j++) buf[i + j] = val >> (8 * j); @@ -833,7 +833,8 @@ static void bridge_post_disable(struct drm_bridge *bridge) * This needs to be fixed in the drm_bridge framework and the API * needs to be updated to manage our own call chains... */ - primary->panel_bridge->funcs->post_disable(primary->panel_bridge); + if (primary->panel_bridge->funcs->post_disable) + primary->panel_bridge->funcs->post_disable(primary->panel_bridge); if (primary->secondary_dsi) dw_mipi_dsi_disable(primary->secondary_dsi); diff --git a/drivers/gpu/drm/verisilicon/vs_drv.c b/drivers/gpu/drm/verisilicon/vs_drv.c index 704e6e64cae7a..945dd9a3b7bf7 100644 --- a/drivers/gpu/drm/verisilicon/vs_drv.c +++ b/drivers/gpu/drm/verisilicon/vs_drv.c @@ -165,7 +165,7 @@ static ssize_t log_show(struct kobject *kobj, struct kobj_attribute *attr, char is_current_master ? 'y' : 'n', priv->authenticated ? 'y' : 'n', // from_kuid_munged(seq_user_ns(m), uid) - uid, + __kuid_val(uid), priv->magic); rcu_read_unlock(); } @@ -195,7 +195,6 @@ static ssize_t log_show(struct kobject *kobj, struct kobj_attribute *attr, char list_for_each_entry(drm_crtc, &drm_dev->mode_config.crtc_list, head) { // struct vs_crtc *crtc = to_vs_crtc(drm_crtc); struct drm_crtc *crtc = drm_crtc->state->crtc; - struct vs_crtc_state *crtc_state = to_vs_crtc_state(drm_crtc->state); len += scnprintf(buf + len, PAGE_SIZE - len, "crtc[%u]: %s\n" @@ -215,7 +214,6 @@ static ssize_t log_show(struct kobject *kobj, struct kobj_attribute *attr, char list_for_each_entry(plane, &drm_dev->mode_config.plane_list, head) { struct drm_plane_state *state = plane->state; - struct vs_plane_state *plane_state = to_vs_plane_state(state); struct drm_rect src = drm_plane_state_src(state); struct drm_rect dest = drm_plane_state_dest(state); diff --git a/drivers/phy/synopsys/phy-dw-mipi-dphy.c b/drivers/phy/synopsys/phy-dw-mipi-dphy.c index 022afdfabfba7..931c9d9124e99 100644 --- a/drivers/phy/synopsys/phy-dw-mipi-dphy.c +++ b/drivers/phy/synopsys/phy-dw-mipi-dphy.c @@ -750,6 +750,7 @@ static int dw_dphy_runtime_resume(struct device *dev) return 0; } +#ifdef CONFIG_PM_SLEEP static int dw_dphy_resume(struct device *dev) { int ret; @@ -793,6 +794,7 @@ static int dw_dphy_suspend(struct device *dev) return 0; } +#endif static const struct dev_pm_ops dw_dphy_pm_ops = { SET_LATE_SYSTEM_SLEEP_PM_OPS(dw_dphy_suspend,