From: Dominik Kowalski <[email protected]>

[Why]
Split into smallest possible increment to allow for parallel
review of different aspects of DPMS-v2 design.

[How]
* Add DPMS-v2 files with empty DPMS-on/off functions
* Add flag to dc_config to choose between v1 and v2
* Use flag in link_create_link_service to update vtable

Signed-off-by: Dominik Kowalski <[email protected]>
Signed-off-by: James Lin <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/core/dc.c      |  6 ++-
 drivers/gpu/drm/amd/display/dc/dc.h           |  1 +
 .../gpu/drm/amd/display/dc/inc/link_service.h |  6 ++-
 drivers/gpu/drm/amd/display/dc/link/Makefile  |  9 +++-
 .../drm/amd/display/dc/link/link_dpms_v2.c    | 44 +++++++++++++++++++
 .../drm/amd/display/dc/link/link_dpms_v2.h    | 38 ++++++++++++++++
 .../drm/amd/display/dc/link/link_factory.c    | 21 ++++++---
 7 files changed, 114 insertions(+), 11 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.h

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 463a3fc2d8c2..3ca650461cb6 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1070,7 +1070,11 @@ static bool dc_construct_ctx(struct dc *dc,
 
        dc->ctx = dc_ctx;
 
-       dc->link_srv = link_create_link_service();
+       const struct link_service_options link_service_options = {
+               .enable_dpms_v2 = dc->config.enable_dpms_v2,
+       };
+
+       dc->link_srv = link_create_link_service(link_service_options);
        if (!dc->link_srv)
                return false;
 
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index b71a9a5cd424..01f549010d07 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -645,6 +645,7 @@ struct dc_config {
        // Set by the DM around a commit that runs where allocation is not
        // permitted; requires preallocate_scratch_state.
        bool use_preallocated_state;
+       bool enable_dpms_v2;
 };
 
 enum visual_confirm {
diff --git a/drivers/gpu/drm/amd/display/dc/inc/link_service.h 
b/drivers/gpu/drm/amd/display/dc/inc/link_service.h
index b2f86c51d470..d9a9d5f9f61c 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/link_service.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/link_service.h
@@ -77,7 +77,11 @@
  */
 #include "core_types.h"
 
-struct link_service *link_create_link_service(void);
+struct link_service_options {
+       bool enable_dpms_v2;
+};
+
+struct link_service *link_create_link_service(struct link_service_options 
options);
 void link_destroy_link_service(struct link_service **link_srv);
 
 struct link_init_data {
diff --git a/drivers/gpu/drm/amd/display/dc/link/Makefile 
b/drivers/gpu/drm/amd/display/dc/link/Makefile
index 0eb433b5d822..ea08f1b1e60e 100644
--- a/drivers/gpu/drm/amd/display/dc/link/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/link/Makefile
@@ -23,8 +23,13 @@
 # It abstracts the control and status of back end pipe such as DIO, HPO, DPIA,
 # PHY, HPD, DDC and etc).
 
-LINK = link_detection.o link_dpms_v1.o link_factory.o link_resource.o \
-link_validation.o
+LINK = \
+       link_detection.o \
+       link_dpms_v1.o \
+       link_dpms_v2.o \
+       link_factory.o \
+       link_resource.o \
+       link_validation.o
 
 AMD_DAL_LINK = $(addprefix $(AMDDALPATH)/dc/link/, \
 $(LINK))
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.c 
b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.c
new file mode 100644
index 000000000000..43c3f7dfa343
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.c
@@ -0,0 +1,44 @@
+/*
+ * 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/link_dpms_v2.h"
+
+enum dc_status link_set_dpms_off_v2(struct pipe_ctx *pipe_ctx)
+{
+       // TODO: Implement
+       (void)pipe_ctx;
+       ASSERT(false);
+       return DC_ERROR_UNEXPECTED;
+}
+
+enum dc_status link_set_dpms_on_v2(struct dc_state *state,
+                                  struct pipe_ctx *pipe_ctx)
+{
+       // TODO: Implement
+       (void)state;
+       (void)pipe_ctx;
+       ASSERT(false);
+       return DC_ERROR_UNEXPECTED;
+}
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.h 
b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.h
new file mode 100644
index 000000000000..c6728932691a
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/link/link_dpms_v2.h
@@ -0,0 +1,38 @@
+/*
+ * 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_DPMS_V2_H
+#define LINK_DPMS_V2_H
+
+#include "dc/inc/core_status.h"
+
+struct dc_state;
+struct pipe_ctx;
+
+// TODO: Add RESOURCED state
+enum dc_status link_set_dpms_off_v2(struct pipe_ctx *pipe_ctx);
+enum dc_status link_set_dpms_on_v2(struct dc_state *state,
+                                  struct pipe_ctx *pipe_ctx);
+
+#endif
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 7bf1364659ea..919f67b76f91 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_factory.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_factory.c
@@ -31,6 +31,7 @@
 #include "link_resource.h"
 #include "link_validation.h"
 #include "link_dpms_v1.h"
+#include "link_dpms_v2.h"
 #include "accessories/link_dp_cts.h"
 #include "accessories/link_dp_trace.h"
 #include "protocols/link_ddc.h"
@@ -111,10 +112,16 @@ static void construct_link_service_validation(struct 
link_service *link_srv)
  * with the link and link's enable/disable sequences as result of the stream's
  * dpms state change.
  */
-static void construct_link_service_dpms(struct link_service *link_srv)
+static void construct_link_service_dpms(struct link_service *link_srv, struct 
link_service_options options)
 {
-       link_srv->set_dpms_on = link_set_dpms_on_v1;
-       link_srv->set_dpms_off = link_set_dpms_off_v1;
+       if (options.enable_dpms_v2) {
+               link_srv->set_dpms_on = link_set_dpms_on_v2;
+               link_srv->set_dpms_off = link_set_dpms_off_v2;
+       } else {
+               link_srv->set_dpms_on = link_set_dpms_on_v1;
+               link_srv->set_dpms_off = link_set_dpms_off_v1;
+       }
+
        link_srv->resume = link_resume;
        link_srv->blank_all_dp_displays = link_blank_all_dp_displays;
        link_srv->blank_all_edp_displays = link_blank_all_edp_displays;
@@ -305,7 +312,7 @@ static void construct_link_service_dp_trace(struct 
link_service *link_srv)
        link_srv->dp_trace_source_sequence = dp_trace_source_sequence;
 }
 
-static void construct_link_service(struct link_service *link_srv)
+static void construct_link_service(struct link_service *link_srv, struct 
link_service_options options)
 {
        /* All link service functions should fall under some sub categories.
         * If a new function doesn't perfectly fall under an existing sub
@@ -318,7 +325,7 @@ static void construct_link_service(struct link_service 
*link_srv)
        construct_link_service_detection(link_srv);
        construct_link_service_resource(link_srv);
        construct_link_service_validation(link_srv);
-       construct_link_service_dpms(link_srv);
+       construct_link_service_dpms(link_srv, options);
        construct_link_service_ddc(link_srv);
        construct_link_service_dp_capability(link_srv);
        construct_link_service_dp_phy_or_dpia(link_srv);
@@ -330,14 +337,14 @@ static void construct_link_service(struct link_service 
*link_srv)
        construct_link_service_dp_trace(link_srv);
 }
 
-struct link_service *link_create_link_service(void)
+struct link_service *link_create_link_service(struct link_service_options 
options)
 {
        struct link_service *link_srv = kzalloc_obj(*link_srv);
 
        if (link_srv == NULL)
                goto fail;
 
-       construct_link_service(link_srv);
+       construct_link_service(link_srv, options);
 
        return link_srv;
 fail:
-- 
2.43.0

Reply via email to