Skip to content

Commit

Permalink
DPU: fix bugs of DPU and resolve compilation warnings
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
forain authored and Tianyu-Fu committed Jul 18, 2024
1 parent 25eedaf commit b67f134
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 54 deletions.
50 changes: 3 additions & 47 deletions drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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))
Expand All @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions drivers/gpu/drm/verisilicon/dw_mipi_dsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions drivers/gpu/drm/verisilicon/vs_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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"
Expand All @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions drivers/phy/synopsys/phy-dw-mipi-dphy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b67f134

Please sign in to comment.