From: Harry Wentland <harry.wentland@xxxxxxx> [WHY] We need to track the dc_link and it would get confusing if re-using the amdgpu_dm_connector. [HOW] Creating new amdgpu_dm_wb_connector. Reviewed-by: Alex Hung <alex.hung@xxxxxxx> Signed-off-by: Harry Wentland <harry.wentland@xxxxxxx> Signed-off-by: Alex Hung <alex.hung@xxxxxxx> --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 8 ++++++++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c | 16 +++++++++++----- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.h | 3 ++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index eb9f9d77127a..6df23fa9c3ae 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -4478,14 +4478,14 @@ static int amdgpu_dm_initialize_drm_device(struct amdgpu_device *adev) link = dc_get_link_at_index(dm->dc, i); if (link->connector_signal == SIGNAL_TYPE_VIRTUAL) { - struct drm_writeback_connector *wbcon = kzalloc(sizeof(*wbcon), GFP_KERNEL); + struct amdgpu_dm_wb_connector *wbcon = kzalloc(sizeof(*wbcon), GFP_KERNEL); if (!wbcon) { DRM_ERROR("KMS: Failed to allocate writeback connector\n"); continue; } - if (amdgpu_dm_wb_connector_init(dm, wbcon)) { + if (amdgpu_dm_wb_connector_init(dm, wbcon, i)) { DRM_ERROR("KMS: Failed to initialize writeback connector\n"); kfree(wbcon); continue; @@ -7589,6 +7589,7 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm, struct dc_link *link = dc_get_link_at_index(dc, link_index); struct amdgpu_i2c_adapter *i2c; + /* Not needed for writeback connector */ link->priv = aconnector; diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h index 3710f4d0f2cb..0a9974017eba 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h @@ -32,6 +32,7 @@ #include <drm/drm_crtc.h> #include <drm/drm_plane.h> #include "link_service_types.h" +#include <drm/drm_writeback.h> /* * This file contains the definition for amdgpu_display_manager @@ -714,6 +715,13 @@ static inline void amdgpu_dm_set_mst_status(uint8_t *status, #define to_amdgpu_dm_connector(x) container_of(x, struct amdgpu_dm_connector, base) +struct amdgpu_dm_wb_connector { + struct drm_writeback_connector base; + struct dc_link *link; +}; + +#define to_amdgpu_dm_wb_connector(x) container_of(x, struct amdgpu_dm_wb_connector, base) + extern const struct amdgpu_ip_block_version dm_ip_block; struct dm_plane_state { diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c index 74e656696d8e..b3e634b0f712 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.c @@ -30,6 +30,7 @@ #include "amdgpu_dm.h" #include "amdgpu_dm_wb.h" #include "amdgpu_display.h" +#include "dc.h" #include <drm/drm_atomic_state_helper.h> #include <drm/drm_modeset_helper_vtables.h> @@ -183,13 +184,18 @@ static const struct drm_connector_helper_funcs amdgpu_dm_wb_conn_helper_funcs = }; int amdgpu_dm_wb_connector_init(struct amdgpu_display_manager *dm, - struct drm_writeback_connector *wbcon) + struct amdgpu_dm_wb_connector *wbcon, + uint32_t link_index) { + struct dc *dc = dm->dc; + struct dc_link *link = dc_get_link_at_index(dc, link_index); int res = 0; - drm_connector_helper_add(&wbcon->base, &amdgpu_dm_wb_conn_helper_funcs); + wbcon->link = link; - res = drm_writeback_connector_init(&dm->adev->ddev, wbcon, + drm_connector_helper_add(&wbcon->base.base, &amdgpu_dm_wb_conn_helper_funcs); + + res = drm_writeback_connector_init(&dm->adev->ddev, &wbcon->base, &amdgpu_dm_wb_connector_funcs, &amdgpu_dm_wb_encoder_helper_funcs, amdgpu_dm_wb_formats, @@ -202,8 +208,8 @@ int amdgpu_dm_wb_connector_init(struct amdgpu_display_manager *dm, * Some of the properties below require access to state, like bpc. * Allocate some default initial connector state with our reset helper. */ - if (wbcon->base.funcs->reset) - wbcon->base.funcs->reset(&wbcon->base); + if (wbcon->base.base.funcs->reset) + wbcon->base.base.funcs->reset(&wbcon->base.base); return 0; } diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.h index 0bc9df7e7ee1..13d31c857dee 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_wb.h @@ -30,6 +30,7 @@ #include <drm/drm_writeback.h> int amdgpu_dm_wb_connector_init(struct amdgpu_display_manager *dm, - struct drm_writeback_connector *wbcon); + struct amdgpu_dm_wb_connector *dm_wbcon, + uint32_t link_index); #endif -- 2.42.0