diff options
author | Max Krummenacher | 2023-07-18 11:07:34 +0200 |
---|---|---|
committer | Tom Rini | 2023-08-04 13:32:39 -0400 |
commit | a0383427b33e7813999a54f19d77954dadc66ab9 (patch) | |
tree | 79ba487ea4beb6426f2fe0d7f1453551be484083 | |
parent | 39e521f75674e640474f9db2b6db8bf68ae59a5f (diff) |
toradex: tdx-cfg-block: rework display adapter name handling
Rework the rather big array of zero length strings with 4 entries of
actual display adapter names to a array of structs which ties a pid4
to its correspondent human readable string.
Provide an accessor to get the string for a given PID4.
Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs@toradex.com>
-rw-r--r-- | board/toradex/common/tdx-cfg-block.c | 22 | ||||
-rw-r--r-- | board/toradex/common/tdx-cfg-block.h | 2 |
2 files changed, 19 insertions, 5 deletions
diff --git a/board/toradex/common/tdx-cfg-block.c b/board/toradex/common/tdx-cfg-block.c index 98a2d44ed3e..12a558c7bba 100644 --- a/board/toradex/common/tdx-cfg-block.c +++ b/board/toradex/common/tdx-cfg-block.c @@ -155,10 +155,11 @@ const struct pid4list toradex_carrier_boards[] = { {YAVIA, "Yavia"}, }; -const char * const toradex_display_adapters[] = { - [0] = "UNKNOWN DISPLAY ADAPTER", - [157] = "Verdin DSI to HDMI Adapter", - [159] = "Verdin DSI to LVDS Adapter", +const struct pid4list toradex_display_adapters[] = { + /* the code assumes unknown at index 0 */ + {0, "UNKNOWN DISPLAY ADAPTER"}, + {VERDIN_DSI_TO_HDMI_ADAPTER, "Verdin DSI to HDMI Adapter"}, + {VERDIN_DSI_TO_LVDS_ADAPTER, "Verdin DSI to LVDS Adapter"}, }; const u32 toradex_ouis[] = { @@ -179,6 +180,19 @@ const char * const get_toradex_carrier_boards(int pid4) return toradex_carrier_boards[index].name; } +const char * const get_toradex_display_adapters(int pid4) +{ + int i, index = 0; + + for (i = 1; i < ARRAY_SIZE(toradex_display_adapters); i++) { + if (pid4 == toradex_display_adapters[i].pid4) { + index = i; + break; + } + } + return toradex_display_adapters[index].name; +} + static u32 get_serial_from_mac(struct toradex_eth_addr *eth_addr) { int i; diff --git a/board/toradex/common/tdx-cfg-block.h b/board/toradex/common/tdx-cfg-block.h index 7486ffbb541..5dc9053ec0a 100644 --- a/board/toradex/common/tdx-cfg-block.h +++ b/board/toradex/common/tdx-cfg-block.h @@ -120,7 +120,7 @@ extern u32 tdx_car_serial; int read_tdx_cfg_block(void); int read_tdx_cfg_block_carrier(void); const char * const get_toradex_carrier_boards(int pid4); - +const char * const get_toradex_display_adapters(int pid4); int try_migrate_tdx_cfg_block_carrier(void); void get_mac_from_serial(u32 tdx_serial, struct toradex_eth_addr *eth_addr); |