Re: [PATCH 13/14] drm/bridge: synopsys: Add DW HDMI QP TX controller driver

Sam Ravnborg
2024-06-01T14:32:52Z

Hi Cristian,

a few drive-by comments below.

Sam

> +
> +static const struct drm_connector_funcs dw_hdmi_qp_connector_funcs = {
> + .fill_modes = drm_helper_probe_single_connector_modes,
> + .detect = dw_hdmi_connector_detect,
> + .destroy = drm_connector_cleanup,
> + .force = dw_hdmi_qp_connector_force,
> + .reset = drm_atomic_helper_connector_reset,
> + .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
> + .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> +};
> +
> +static int dw_hdmi_qp_bridge_attach(struct drm_bridge *bridge,
> + enum drm_bridge_attach_flags flags)
> +{
> + struct dw_hdmi *hdmi = bridge->driver_private;
> +
> + if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
> + return drm_bridge_attach(bridge->encoder, hdmi->next_bridge,
> + bridge, flags);
> +
> + return dw_hdmi_connector_create(hdmi, &dw_hdmi_qp_connector_funcs);
> +}

Are there any users left that requires the display driver to create the
connector?
In other words - could this driver fail if DRM_BRIDGE_ATTACH_NO_CONNECTOR
is not passed and drop dw_hdmi_connector_create()?

I did not try to verify this - just a naive question.

> +
> +static enum drm_mode_status
> +dw_hdmi_qp_bridge_mode_valid(struct drm_bridge *bridge,
> + const struct drm_display_info *info,
> + const struct drm_display_mode *mode)
> +{
> + struct dw_hdmi *hdmi = bridge->driver_private;
> + const struct dw_hdmi_plat_data *pdata = hdmi->plat_data;
> + enum drm_mode_status mode_status = MODE_OK;
> +
> + if (pdata->mode_valid)
> + mode_status = pdata->mode_valid(hdmi, pdata->priv_data, info,
> + mode);
> +
> + return mode_status;
> +}
> +
> +static void dw_hdmi_qp_bridge_atomic_disable(struct drm_bridge *bridge,
> + struct drm_bridge_state *old_state)
> +{
> + struct dw_hdmi *hdmi = bridge->driver_private;
> +
> + mutex_lock(&hdmi->mutex);
> + hdmi->disabled = true;
> + hdmi->curr_conn = NULL;
> + dw_hdmi_qp_update_power(hdmi);
> + dw_handle_plugged_change(hdmi, false);
> + mutex_unlock(&hdmi->mutex);
> +}
> +
> +static void dw_hdmi_qp_bridge_atomic_enable(struct drm_bridge *bridge,
> + struct drm_bridge_state *old_state)
> +{
> + struct dw_hdmi *hdmi = bridge->driver_private;
> + struct drm_atomic_state *state = old_state->base.state;
> + struct drm_connector *connector;
> +
> + connector = drm_atomic_get_new_connector_for_encoder(state,
> + bridge->encoder);
> +
> + mutex_lock(&hdmi->mutex);
> + hdmi->disabled = false;
> + hdmi->curr_conn = connector;
> + dw_hdmi_qp_update_power(hdmi);
> + dw_handle_plugged_change(hdmi, true);
> + mutex_unlock(&hdmi->mutex);
> +}
> +
> +static const struct drm_bridge_funcs dw_hdmi_qp_bridge_funcs = {
> + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
> + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
> + .atomic_reset = drm_atomic_helper_bridge_reset,
> + .attach = dw_hdmi_qp_bridge_attach,
> + .detach = dw_hdmi_bridge_detach,
> + .atomic_check = dw_hdmi_bridge_atomic_check,
> + .atomic_enable = dw_hdmi_qp_bridge_atomic_enable,
> + .atomic_disable = dw_hdmi_qp_bridge_atomic_disable,
> + .mode_set = dw_hdmi_bridge_mode_set,

The use of mode_set is deprecated - see drm_bridge.h