drm_writeback_connector_init() hides the encoder inside struct drm_writeback_connector, which is the only reason that structure carries an encoder at all. Every other writeback user already owns its encoder.
Embed the encoder in the driver's own structure and register the connector with drm_writeback_connector_init_with_encoder(), so that the encoder can be dropped from drm_writeback_connector. Assisted-by: LLM Signed-off-by: Dmitry Baryshkov <[email protected]> --- drivers/gpu/drm/arm/malidp_drv.h | 1 + drivers/gpu/drm/arm/malidp_mw.c | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/arm/malidp_drv.h b/drivers/gpu/drm/arm/malidp_drv.h index bc0387876dea..64610f2d23e2 100644 --- a/drivers/gpu/drm/arm/malidp_drv.h +++ b/drivers/gpu/drm/arm/malidp_drv.h @@ -33,6 +33,7 @@ struct malidp_drm { struct malidp_hw_device *dev; struct drm_crtc crtc; struct drm_writeback_connector mw_connector; + struct drm_encoder mw_encoder; wait_queue_head_t wq; struct drm_pending_vblank_event *event; atomic_t config_valid; diff --git a/drivers/gpu/drm/arm/malidp_mw.c b/drivers/gpu/drm/arm/malidp_mw.c index f8be65119e3b..7f5e25adf999 100644 --- a/drivers/gpu/drm/arm/malidp_mw.c +++ b/drivers/gpu/drm/arm/malidp_mw.c @@ -110,6 +110,10 @@ malidp_mw_connector_duplicate_state(struct drm_connector *connector) return &mw_state->base; } +static const struct drm_encoder_funcs malidp_mw_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; + static const struct drm_connector_funcs malidp_mw_connector_funcs = { .reset = malidp_mw_connector_reset, .detect = malidp_mw_connector_detect, @@ -224,14 +228,27 @@ int malidp_mw_connector_init(struct drm_device *drm) if (!formats) return -ENOMEM; - ret = drm_writeback_connector_init(drm, &malidp->mw_connector, - &malidp_mw_connector_funcs, - &malidp_mw_encoder_helper_funcs, - formats, n_formats, - 1 << drm_crtc_index(&malidp->crtc)); + drm_encoder_helper_add(&malidp->mw_encoder, + &malidp_mw_encoder_helper_funcs); + malidp->mw_encoder.possible_crtcs = drm_crtc_mask(&malidp->crtc); + + ret = drm_encoder_init(drm, &malidp->mw_encoder, + &malidp_mw_encoder_funcs, + DRM_MODE_ENCODER_VIRTUAL, NULL); + if (ret) { + kfree(formats); + return ret; + } + + ret = drm_writeback_connector_init_with_encoder(drm, &malidp->mw_connector, + &malidp->mw_encoder, + &malidp_mw_connector_funcs, + formats, n_formats); kfree(formats); - if (ret) + if (ret) { + drm_encoder_cleanup(&malidp->mw_encoder); return ret; + } return 0; } -- 2.47.3
