Skip to contentSkip to conversation

drm/amd/display/dc: Refactor remove duplications

RFC PATCH Superseded Luan Icaro Pinto Arcanjo 1 participant 1 message Nov 16, 2024

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH v2 1/1 drm/amd/display/dc: Refactor remove duplications

From: Luan Arcanjo <[email protected]>

All dce command_table_helper's shares a copy-pasted collection of copy-pasted functions, which are: phy_id_to_atom, clock_source_id_to_atom_phy_clk_src_id, and engine_bp_to_atom.

This patch removes the multiple copy-pasted by creating a common command table and make the command_table_helper's calls the functions implemented by the common instead.

The changes were not tested on actual hardware. I am only able to verify that the changes keep the code compileable and do my best to to look repeatedly if I am not actually changing any code.

This is the version 2 of the PATCH, fixed comments about licence in the new files and the matches From email to Signed-off-by email.

---
 drivers/gpu/drm/amd/display/dc/bios/Makefile  |   6 +
 .../bios/dce110/command_table_helper_dce110.c | 104 +----------------
 .../dce112/command_table_helper2_dce112.c     | 104 +----------------
 .../bios/dce112/command_table_helper_dce112.c | 104 +----------------
 .../bios/dce60/command_table_helper_dce60.c   | 106 +----------------
 .../bios/dce80/command_table_helper_dce80.c   | 106 +----------------
 .../command_table_helper_dce_common.c         | 110 ++++++++++++++++++
 .../command_table_helper_dce_common.h         |  14 +++
 8 files changed, 137 insertions(+), 517 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/bios/dce_common/command_table_helper_dce_common.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/bios/dce_common/command_table_helper_dce_common.h
drivers/gpu/drm/amd/display/dc/bios/Makefile +6 -0
index ed6b5e9763f6..0d2f7ca1d0c2 100644
@@ -27,6 +27,7 @@ BIOS = bios_parser.o bios_parser_interface.o  bios_parser_helper.o command_table
 
 BIOS += command_table2.o command_table_helper2.o bios_parser2.o
 
+
 AMD_DAL_BIOS = $(addprefix $(AMDDALPATH)/dc/bios/,$(BIOS))
 
 AMD_DISPLAY_FILES += $(AMD_DAL_BIOS)
@@ -55,3 +56,8 @@ AMD_DISPLAY_FILES += $(AMDDALPATH)/dc/bios/dce110/command_table_helper_dce110.o
 AMD_DISPLAY_FILES += $(AMDDALPATH)/dc/bios/dce112/command_table_helper_dce112.o
 
 AMD_DISPLAY_FILES += $(AMDDALPATH)/dc/bios/dce112/command_table_helper2_dce112.o
+
+###############################################################################
+# DCE COMMON
+###############################################################################
+AMD_DISPLAY_FILES += $(AMDDALPATH)/dc/bios/dce_common/command_table_helper_dce_common.o
drivers/gpu/drm/amd/display/dc/bios/dce110/command_table_helper_dce110.c +1 -103

122 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/bios/dce112/command_table_helper2_dce112.c +1 -103

122 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/bios/dce112/command_table_helper_dce112.c +1 -103

122 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/bios/dce60/command_table_helper_dce60.c +2 -104

130 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/bios/dce80/command_table_helper_dce80.c +2 -104

130 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/bios/dce_common/command_table_helper_dce_common.c new file +110 -0

110 lines not on this page · raw message

drivers/gpu/drm/amd/display/dc/bios/dce_common/command_table_helper_dce_common.h new file +14 -0
new file mode 100644
index 000000000000..4e0ceb39b95f
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef __DAL_COMMAND_TABLE_HELPER_DCE_COMMON_H__
+#define __DAL_COMMAND_TABLE_HELPER_DCE_COMMON_H__
+
+
+uint8_t phy_id_to_atom(enum transmitter t);
+
+uint8_t clock_source_id_to_atom_phy_clk_src_id(
+		enum clock_source_id id);
+
+bool engine_bp_to_atom(enum engine_id id, uint32_t *atom_engine_id);
+
+#endif
Signature · 1 line
2.43.0