2 * Copyright 2012-16 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 #include "core_types.h"
28 #include "include/logger_interface.h"
29 #include "dm_helpers.h"
31 #define NUM_ELEMENTS(a) (sizeof(a) / sizeof((a)[0]))
33 struct dc_signal_type_info {
34 enum signal_type type;
35 char name[MAX_NAME_LEN];
38 static const struct dc_signal_type_info signal_type_info_tbl[] = {
39 {SIGNAL_TYPE_NONE, "NC"},
40 {SIGNAL_TYPE_DVI_SINGLE_LINK, "DVI"},
41 {SIGNAL_TYPE_DVI_DUAL_LINK, "DDVI"},
42 {SIGNAL_TYPE_HDMI_TYPE_A, "HDMIA"},
43 {SIGNAL_TYPE_LVDS, "LVDS"},
44 {SIGNAL_TYPE_RGB, "VGA"},
45 {SIGNAL_TYPE_DISPLAY_PORT, "DP"},
46 {SIGNAL_TYPE_DISPLAY_PORT_MST, "MST"},
47 {SIGNAL_TYPE_EDP, "eDP"},
48 {SIGNAL_TYPE_VIRTUAL, "Virtual"}
51 void dc_conn_log(struct dc_context *ctx,
52 const struct dc_link *link,
55 enum dc_log_type event,
61 struct log_entry entry = { 0 };
62 enum signal_type signal;
65 signal = link->local_sink->sink_signal;
67 signal = link->connector_signal;
69 if (link->type == dc_connection_mst_branch)
70 signal = SIGNAL_TYPE_DISPLAY_PORT_MST;
72 dm_logger_open(ctx->logger, &entry, event);
74 for (i = 0; i < NUM_ELEMENTS(signal_type_info_tbl); i++)
75 if (signal == signal_type_info_tbl[i].type)
78 if (i == NUM_ELEMENTS(signal_type_info_tbl))
81 dm_logger_append(&entry, "[%s][ConnIdx:%d] ",
82 signal_type_info_tbl[i].name,
86 entry.buf_offset += dm_log_to_buffer(
87 &entry.buf[entry.buf_offset],
88 LOG_MAX_LINE_SIZE - entry.buf_offset,
91 if (entry.buf[strlen(entry.buf) - 1] == '\n') {
92 entry.buf[strlen(entry.buf) - 1] = '\0';
97 for (i = 0; i < hex_data_count; i++)
98 dm_logger_append(&entry, "%2.2X ", hex_data[i]);
100 dm_logger_append(&entry, "^\n");
101 dm_helpers_dc_conn_log(ctx, &entry, event);
104 dm_logger_close(&entry);