From: Dominik Kowalski <[email protected]>

[Why & How]
Add allocation, deallocation and initialization of DPMS-v2 tx structs.
When enable_dpms_v2 is set, link_factory creates a v2 tx; otherwise it
creates a v1 tx, so every link gets a tx. The tx is stored in a new
tx_inst field of dc_link and passed to the dpms_ctx. Link construction
fails if the tx cannot be created.

Cc: Wenjing Liu <[email protected]>
Signed-off-by: Dominik Kowalski <[email protected]>
Signed-off-by: Chenyu Chen <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/dc.h           |  1 +
 drivers/gpu/drm/amd/display/dc/link/Makefile  | 11 +++
 .../drm/amd/display/dc/link/link_factory.c    | 39 ++++++++-
 .../drm/amd/display/dc/link/tx/link_tx_v1.c   | 55 ++++++++++++
 .../drm/amd/display/dc/link/tx/link_tx_v1.h   | 34 ++++++++
 .../drm/amd/display/dc/link/tx/link_tx_v2.c   | 83 +++++++++++++++++++
 .../drm/amd/display/dc/link/tx/link_tx_v2.h   | 38 +++++++++
 7 files changed, 259 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v1.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v1.h
 create mode 100644 drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v2.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v2.h

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 75d1ede366c7..69d6eed1df41 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -1935,6 +1935,7 @@ struct dc_scratch_space {
 
        struct ddc_service *ddc;
        struct link_dpms_ctx *dpms_ctx;
+       struct link_tx *tx_inst;
 
        enum dp_panel_mode panel_mode;
        bool panel_mode_initialized;
diff --git a/drivers/gpu/drm/amd/display/dc/link/Makefile 
b/drivers/gpu/drm/amd/display/dc/link/Makefile
index ea08f1b1e60e..2d9bbf33ed97 100644
--- a/drivers/gpu/drm/amd/display/dc/link/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/link/Makefile
@@ -70,3 +70,14 @@ AMD_DAL_LINK_PROTOCOLS = $(addprefix 
$(AMDDALPATH)/dc/link/protocols/, \
 $(LINK_PROTOCOLS))
 
 AMD_DISPLAY_FILES += $(AMD_DAL_LINK_PROTOCOLS)
+
+###############################################################################
+# tx
+###############################################################################
+LINK_TX = link_tx_v1.o
+LINK_TX += link_tx_v2.o
+
+AMD_DAL_LINK_TX = $(addprefix $(AMDDALPATH)/dc/link/tx/, \
+$(LINK_TX))
+
+AMD_DISPLAY_FILES += $(AMD_DAL_LINK_TX)
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_factory.c 
b/drivers/gpu/drm/amd/display/dc/link/link_factory.c
index 1e32f96348b7..e5a5bc70e7d3 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_factory.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_factory.c
@@ -47,6 +47,9 @@
 #include "protocols/link_hpd.h"
 #include "gpio_service_interface.h"
 #include "atomfirmware.h"
+#include "dc/inc/link_tx.h"
+#include "dc/link/tx/link_tx_v1.h"
+#include "dc/link/tx/link_tx_v2.h"
 
 #define DC_LOGGER \
        dc_ctx->logger
@@ -434,11 +437,18 @@ static struct link_dpms_ctx *link_create_dpms_ctx(struct 
dc_link *link)
 
        *ctx = (struct link_dpms_ctx){
                .link = link,
+               .tx = link->tx_inst,
        };
 
        return ctx;
 }
 
+static void link_destroy_tx(struct link_tx *tx)
+{
+       if (tx && tx->funcs && tx->funcs->destroy)
+               tx->funcs->destroy(tx);
+}
+
 static void link_destruct(struct dc_link *link)
 {
        unsigned int i;
@@ -471,6 +481,9 @@ static void link_destruct(struct dc_link *link)
 
        if (link->dpms_ctx)
                link_destroy_dpms_ctx(link->dpms_ctx);
+
+       if (link->tx_inst)
+               link_destroy_tx(link->tx_inst);
 }
 
 static enum channel_id get_ddc_line(struct dc_link *link)
@@ -922,7 +935,11 @@ static bool construct_phy(struct dc_link *link,
                }
        }
 
-       if (init_params->dc->config.enable_dpms_v2) {
+       if (!init_params->dc->config.enable_dpms_v2) {
+               link->tx_inst = link_tx_create_v1(link);
+       } else {
+               link->tx_inst = link_tx_create_v2(link);
+
                link->dpms_ctx = link_create_dpms_ctx(link);
                if (!link->dpms_ctx) {
                        DC_ERROR("Failed to create dpms_ctx!\n");
@@ -930,6 +947,11 @@ static bool construct_phy(struct dc_link *link,
                }
        }
 
+       if (!link->tx_inst) {
+               DC_ERROR("Failed to create tx!\n");
+               goto fail;
+       }
+
        link->psr_settings.psr_vtotal_control_support = false;
        link->psr_settings.psr_version = DC_PSR_VERSION_UNSUPPORTED;
        link->replay_settings.config.replay_version = 
DC_REPLAY_VERSION_UNSUPPORTED;
@@ -952,6 +974,8 @@ static bool construct_phy(struct dc_link *link,
                link->link_enc->funcs->destroy(&link->link_enc);
        if (link->dpms_ctx)
                link_destroy_dpms_ctx(link->dpms_ctx);
+       if (link->tx_inst)
+               link_destroy_tx(link->tx_inst);
 
        DC_LOG_DC("BIOS object table - %s failed.\n", __func__);
        return false;
@@ -1006,7 +1030,11 @@ static bool construct_dpia(struct dc_link *link,
                goto fail;
        }
 
-       if (init_params->dc->config.enable_dpms_v2) {
+       if (!init_params->dc->config.enable_dpms_v2) {
+               link->tx_inst = link_tx_create_v1(link);
+       } else {
+               link->tx_inst = link_tx_create_v2(link);
+
                link->dpms_ctx = link_create_dpms_ctx(link);
                if (!link->dpms_ctx) {
                        DC_ERROR("Failed to create dpms_ctx!\n");
@@ -1014,6 +1042,11 @@ static bool construct_dpia(struct dc_link *link,
                }
        }
 
+       if (!link->tx_inst) {
+               DC_ERROR("Failed to create tx!\n");
+               goto fail;
+       }
+
        /* Set dpia port index : 0 to number of dpia ports */
        link->ddc_hw_inst = (uint8_t)init_params->connector_index;
 
@@ -1033,6 +1066,8 @@ static bool construct_dpia(struct dc_link *link,
                link_destroy_ddc_service(&link->ddc);
        if (link->dpms_ctx)
                link_destroy_dpms_ctx(link->dpms_ctx);
+       if (link->tx_inst)
+               link_destroy_tx(link->tx_inst);
 
        return false;
 }
diff --git a/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v1.c 
b/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v1.c
new file mode 100644
index 000000000000..68312ab50711
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v1.c
@@ -0,0 +1,55 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#include "dc/link/tx/link_tx_v1.h"
+
+static void link_tx_destroy_v1(struct link_tx *tx)
+{
+       if (!tx)
+               return;
+
+       kfree(tx);
+}
+
+static const struct link_tx_funcs link_tx_funcs_v1 = {
+       .destroy = link_tx_destroy_v1,
+};
+
+struct link_tx *link_tx_create_v1(struct dc_link *link)
+{
+       struct link_tx *tx = kzalloc_obj(*tx);
+
+       if (!tx)
+               return NULL;
+
+       *tx = (struct link_tx){
+               .funcs = &link_tx_funcs_v1,
+               .link = link,
+               .ctx = NULL,
+       };
+
+       return tx;
+}
diff --git a/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v1.h 
b/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v1.h
new file mode 100644
index 000000000000..11211f3955cf
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v1.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#ifndef LINK_TX_V1_H
+#define LINK_TX_V1_H
+
+#include "dc/inc/link_tx.h"
+
+struct link_tx *link_tx_create_v1(struct dc_link *link);
+
+#endif
diff --git a/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v2.c 
b/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v2.c
new file mode 100644
index 000000000000..b42704453f89
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v2.c
@@ -0,0 +1,83 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#include "dc/link/tx/link_tx_v2.h"
+
+static void link_tx_v2_ctx_destroy(struct link_tx_v2_ctx *ctx)
+{
+       if (!ctx)
+               return;
+
+       kfree(ctx);
+}
+
+static struct link_tx_v2_ctx *link_tx_v2_ctx_create(void)
+{
+       struct link_tx_v2_ctx *ctx = kzalloc_obj(*ctx);
+
+       if (!ctx)
+               return NULL;
+
+       *ctx = (struct link_tx_v2_ctx){
+               .dummy = 0,
+       };
+
+       return ctx;
+}
+
+static void link_tx_destroy_v2(struct link_tx *tx)
+{
+       if (!tx)
+               return;
+
+       link_tx_v2_ctx_destroy(tx->ctx);
+       kfree(tx);
+}
+
+static const struct link_tx_funcs link_tx_funcs_v2 = {
+       .destroy = link_tx_destroy_v2,
+};
+
+struct link_tx *link_tx_create_v2(struct dc_link *link)
+{
+       struct link_tx *tx = kzalloc_obj(*tx);
+
+       if (!tx)
+               return NULL;
+
+       *tx = (struct link_tx){
+               .funcs = &link_tx_funcs_v2,
+               .link = link,
+               .ctx = link_tx_v2_ctx_create(),
+       };
+
+       if (!tx->ctx) {
+               link_tx_destroy_v2(tx);
+               return NULL;
+       }
+
+       return tx;
+}
diff --git a/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v2.h 
b/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v2.h
new file mode 100644
index 000000000000..151a6173b2a7
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/link/tx/link_tx_v2.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Copyright 2026 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#ifndef LINK_TX_V2_H
+#define LINK_TX_V2_H
+
+#include "dc/inc/link_tx.h"
+
+struct link_tx_v2_ctx {
+       int dummy;
+};
+
+struct link_tx *link_tx_create_v2(struct dc_link *link);
+
+#endif
-- 
2.43.0

Reply via email to