пт, 27 лист. 2026 р. о 07:24 Mikko Perttunen <[email protected]> пише: > > On Sunday, November 22, 2026 5:18 PM Svyatoslav Ryhel wrote: > > Switch to using the atomic versions of the enable() and disable() > > operations. > > > > This is required for acquiring the next bridge state without causing > > crashes, in order to properly set up the encoder. > > This is a bit vague. I'd make an explicit reference to RGB needing > access to the bridge state, which is not possible with the non-atomic > functions, and then explaining that DSI / HDMI / SOR are converted for > consistency. >
Noted > > > > Signed-off-by: Svyatoslav Ryhel <[email protected]> > > --- > > drivers/gpu/drm/tegra/dsi.c | 20 +++++++++++++++----- > > drivers/gpu/drm/tegra/hdmi.c | 20 +++++++++++++++----- > > drivers/gpu/drm/tegra/rgb.c | 23 +++++++++++++++++------ > > drivers/gpu/drm/tegra/sor.c | 18 +++++++++++++----- > > 4 files changed, 60 insertions(+), 21 deletions(-) > > > > diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c > > index 6d6adc485e51e..cd61070072beb 100644 > > --- a/drivers/gpu/drm/tegra/dsi.c > > +++ b/drivers/gpu/drm/tegra/dsi.c > > @@ -855,7 +855,8 @@ static void tegra_dsi_unprepare(struct tegra_dsi *dsi) > > dev_err(dsi->dev, "failed to suspend: %d\n", err); > > } > > > > -static void tegra_dsi_encoder_disable(struct drm_encoder *encoder) > > +static void tegra_dsi_encoder_disable(struct drm_encoder *encoder, > > + struct drm_atomic_commit *comm_state) > > { > > struct tegra_output *output = encoder_to_output(encoder); > > struct tegra_dc *dc = to_tegra_dc(encoder->crtc); > > @@ -919,16 +920,25 @@ static int tegra_dsi_prepare(struct tegra_dsi *dsi) > > return 0; > > } > > > > -static void tegra_dsi_encoder_enable(struct drm_encoder *encoder) > > +static void tegra_dsi_encoder_enable(struct drm_encoder *encoder, > > + struct drm_atomic_commit *comm_state) > > { > > - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; > > struct tegra_output *output = encoder_to_output(encoder); > > struct tegra_dc *dc = to_tegra_dc(encoder->crtc); > > + struct drm_connector_state *conn_state; > > struct tegra_dsi *dsi = to_dsi(output); > > + struct drm_crtc_state *crtc_state; > > + struct drm_connector *connector; > > struct tegra_dsi_state *state; > > + struct drm_display_mode *mode; > > u32 value; > > int err; > > > > + connector = drm_atomic_get_new_connector_for_encoder(comm_state, > > encoder); > > + conn_state = drm_atomic_get_new_connector_state(comm_state, > > connector); > > + crtc_state = drm_atomic_get_new_crtc_state(comm_state, > > conn_state->crtc); > > + mode = &crtc_state->adjusted_mode; > > + > > err = tegra_dsi_prepare(dsi); > > if (err < 0) { > > dev_err(dsi->dev, "failed to prepare: %d\n", err); > > The function also uses encoder->crtc and tegra_dsi_get_state. Should > these be changed to conn_state->crtc and to_dsi_state(conn_state)? > > Similarly for HDMI / SOR. > I must have missed that. Good catch > > @@ -1059,8 +1069,8 @@ static const struct drm_encoder_funcs > > tegra_dsi_encoder_funcs = { > > }; > > > > static const struct drm_encoder_helper_funcs > > tegra_dsi_encoder_helper_funcs = { > > - .disable = tegra_dsi_encoder_disable, > > - .enable = tegra_dsi_encoder_enable, > > + .atomic_disable = tegra_dsi_encoder_disable, > > + .atomic_enable = tegra_dsi_encoder_enable, > > .atomic_check = tegra_dsi_encoder_atomic_check, > > }; > > > > diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c > > index e8c4347f09e69..a78279810dd82 100644 > > --- a/drivers/gpu/drm/tegra/hdmi.c > > +++ b/drivers/gpu/drm/tegra/hdmi.c > > @@ -1166,7 +1166,8 @@ tegra_hdmi_connector_helper_funcs = { > > .mode_valid = tegra_hdmi_connector_mode_valid, > > }; > > > > -static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder) > > +static void tegra_hdmi_encoder_disable(struct drm_encoder *encoder, > > + struct drm_atomic_commit *comm_state) > > { > > struct tegra_output *output = encoder_to_output(encoder); > > struct tegra_dc *dc = to_tegra_dc(encoder->crtc); > > @@ -1209,18 +1210,27 @@ static void tegra_hdmi_encoder_disable(struct > > drm_encoder *encoder) > > dev_err(hdmi->dev, "failed to suspend: %d\n", err); > > } > > > > -static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder) > > +static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder, > > + struct drm_atomic_commit *comm_state) > > { > > - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; > > unsigned int h_sync_width, h_front_porch, h_back_porch, i, rekey; > > struct tegra_output *output = encoder_to_output(encoder); > > struct tegra_dc *dc = to_tegra_dc(encoder->crtc); > > struct tegra_hdmi *hdmi = to_hdmi(output); > > + struct drm_connector_state *conn_state; > > + struct drm_crtc_state *crtc_state; > > unsigned int pulse_start, div82; > > + struct drm_connector *connector; > > + struct drm_display_mode *mode; > > int retries = 1000; > > u32 value; > > int err; > > > > + connector = drm_atomic_get_new_connector_for_encoder(comm_state, > > encoder); > > + conn_state = drm_atomic_get_new_connector_state(comm_state, > > connector); > > + crtc_state = drm_atomic_get_new_crtc_state(comm_state, > > conn_state->crtc); > > + mode = &crtc_state->adjusted_mode; > > + > > err = host1x_client_resume(&hdmi->client); > > if (err < 0) { > > dev_err(hdmi->dev, "failed to resume: %d\n", err); > > @@ -1460,8 +1470,8 @@ tegra_hdmi_encoder_atomic_check(struct drm_encoder > > *encoder, > > } > > > > static const struct drm_encoder_helper_funcs > > tegra_hdmi_encoder_helper_funcs = { > > - .disable = tegra_hdmi_encoder_disable, > > - .enable = tegra_hdmi_encoder_enable, > > + .atomic_disable = tegra_hdmi_encoder_disable, > > + .atomic_enable = tegra_hdmi_encoder_enable, > > .atomic_check = tegra_hdmi_encoder_atomic_check, > > }; > > > > diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c > > index 227a178f761bd..d48d498068ac8 100644 > > --- a/drivers/gpu/drm/tegra/rgb.c > > +++ b/drivers/gpu/drm/tegra/rgb.c > > @@ -90,7 +90,8 @@ static void tegra_dc_write_regs(struct tegra_dc *dc, > > tegra_dc_writel(dc, table[i].value, table[i].offset); > > } > > > > -static void tegra_rgb_encoder_disable(struct drm_encoder *encoder) > > +static void tegra_rgb_encoder_disable(struct drm_encoder *encoder, > > + struct drm_atomic_commit *state) > > { > > struct tegra_output *output = encoder_to_output(encoder); > > struct tegra_rgb *rgb = to_rgb(output); > > @@ -99,12 +100,22 @@ static void tegra_rgb_encoder_disable(struct > > drm_encoder *encoder) > > tegra_dc_commit(rgb->dc); > > } > > > > -static void tegra_rgb_encoder_enable(struct drm_encoder *encoder) > > +static void tegra_rgb_encoder_enable(struct drm_encoder *encoder, > > + struct drm_atomic_commit *state) > > { > > - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; > > struct tegra_output *output = encoder_to_output(encoder); > > struct tegra_rgb *rgb = to_rgb(output); > > - u32 value; > > + struct drm_connector_state *conn_state; > > + struct drm_crtc_state *crtc_state; > > + struct drm_connector *connector; > > + struct drm_display_mode *mode; > > + u32 bus_flags, value; > > + > > + /* Get mode flags */ > > + connector = drm_atomic_get_new_connector_for_encoder(state, encoder); > > + conn_state = drm_atomic_get_new_connector_state(state, connector); > > + crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc); > > + mode = &crtc_state->adjusted_mode; > > > > tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable)); > > > > @@ -201,8 +212,8 @@ static const struct drm_encoder_funcs > > tegra_rgb_encoder_funcs = { > > }; > > > > static const struct drm_encoder_helper_funcs > > tegra_rgb_encoder_helper_funcs = { > > - .disable = tegra_rgb_encoder_disable, > > - .enable = tegra_rgb_encoder_enable, > > + .atomic_disable = tegra_rgb_encoder_disable, > > + .atomic_enable = tegra_rgb_encoder_enable, > > .atomic_check = tegra_rgb_encoder_atomic_check, > > }; > > > > diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c > > index ebac9068b670f..45a9ea94c4355 100644 > > --- a/drivers/gpu/drm/tegra/sor.c > > +++ b/drivers/gpu/drm/tegra/sor.c > > @@ -2203,7 +2203,8 @@ static void tegra_sor_hdmi_scdc_start(struct > > tegra_sor *sor) > > } > > } > > > > -static void tegra_sor_hdmi_disable(struct drm_encoder *encoder) > > +static void tegra_sor_hdmi_disable(struct drm_encoder *encoder, > > + struct drm_atomic_commit *comm_state) > > { > > struct tegra_output *output = encoder_to_output(encoder); > > struct tegra_dc *dc = to_tegra_dc(encoder->crtc); > > @@ -2244,13 +2245,17 @@ static void tegra_sor_hdmi_disable(struct > > drm_encoder *encoder) > > host1x_client_suspend(&sor->client); > > } > > > > -static void tegra_sor_hdmi_enable(struct drm_encoder *encoder) > > +static void tegra_sor_hdmi_enable(struct drm_encoder *encoder, > > + struct drm_atomic_commit *comm_state) > > { > > struct tegra_output *output = encoder_to_output(encoder); > > unsigned int h_ref_to_sync = 1, pulse_start, max_ac; > > struct tegra_dc *dc = to_tegra_dc(encoder->crtc); > > struct tegra_sor_hdmi_settings *settings; > > + struct drm_connector_state *conn_state; > > struct tegra_sor *sor = to_sor(output); > > + struct drm_crtc_state *crtc_state; > > + struct drm_connector *connector; > > struct tegra_sor_state *state; > > struct drm_display_mode *mode; > > unsigned long rate, pclk; > > @@ -2259,7 +2264,10 @@ static void tegra_sor_hdmi_enable(struct drm_encoder > > *encoder) > > int err; > > > > state = to_sor_state(output->connector.state); > > - mode = &encoder->crtc->state->adjusted_mode; > > + connector = drm_atomic_get_new_connector_for_encoder(comm_state, > > encoder); > > + conn_state = drm_atomic_get_new_connector_state(comm_state, > > connector); > > + crtc_state = drm_atomic_get_new_crtc_state(comm_state, > > conn_state->crtc); > > + mode = &crtc_state->adjusted_mode; > > pclk = mode->clock * 1000; > > > > err = host1x_client_resume(&sor->client); > > @@ -2657,8 +2665,8 @@ static void tegra_sor_hdmi_enable(struct drm_encoder > > *encoder) > > } > > > > static const struct drm_encoder_helper_funcs tegra_sor_hdmi_helpers = { > > - .disable = tegra_sor_hdmi_disable, > > - .enable = tegra_sor_hdmi_enable, > > + .atomic_disable = tegra_sor_hdmi_disable, > > + .atomic_enable = tegra_sor_hdmi_enable, > > .atomic_check = tegra_sor_encoder_atomic_check, > > }; > > > > -- > > 2.53.0 > > > > > > > >
