|
26 | 26 | */ |
27 | 27 |
|
28 | 28 | #include <linux/iopoll.h> |
| 29 | +#include <linux/seq_buf.h> |
29 | 30 | #include <linux/string_helpers.h> |
30 | 31 |
|
31 | 32 | #include <drm/display/drm_dp_helper.h> |
@@ -5067,11 +5068,45 @@ static bool port_in_use(struct intel_display *display, enum port port) |
5067 | 5068 | return false; |
5068 | 5069 | } |
5069 | 5070 |
|
| 5071 | +static const char *intel_ddi_encoder_name(struct intel_display *display, |
| 5072 | + enum port port, enum phy phy, |
| 5073 | + struct seq_buf *s) |
| 5074 | +{ |
| 5075 | + if (DISPLAY_VER(display) >= 13 && port >= PORT_D_XELPD) { |
| 5076 | + seq_buf_printf(s, "DDI %c/PHY %c", |
| 5077 | + port_name(port - PORT_D_XELPD + PORT_D), |
| 5078 | + phy_name(phy)); |
| 5079 | + } else if (DISPLAY_VER(display) >= 12) { |
| 5080 | + enum tc_port tc_port = intel_port_to_tc(display, port); |
| 5081 | + |
| 5082 | + seq_buf_printf(s, "DDI %s%c/PHY %s%c", |
| 5083 | + port >= PORT_TC1 ? "TC" : "", |
| 5084 | + port >= PORT_TC1 ? port_tc_name(port) : port_name(port), |
| 5085 | + tc_port != TC_PORT_NONE ? "TC" : "", |
| 5086 | + tc_port != TC_PORT_NONE ? tc_port_name(tc_port) : phy_name(phy)); |
| 5087 | + } else if (DISPLAY_VER(display) >= 11) { |
| 5088 | + enum tc_port tc_port = intel_port_to_tc(display, port); |
| 5089 | + |
| 5090 | + seq_buf_printf(s, "DDI %c%s/PHY %s%c", |
| 5091 | + port_name(port), |
| 5092 | + port >= PORT_C ? " (TC)" : "", |
| 5093 | + tc_port != TC_PORT_NONE ? "TC" : "", |
| 5094 | + tc_port != TC_PORT_NONE ? tc_port_name(tc_port) : phy_name(phy)); |
| 5095 | + } else { |
| 5096 | + seq_buf_printf(s, "DDI %c/PHY %c", port_name(port), phy_name(phy)); |
| 5097 | + } |
| 5098 | + |
| 5099 | + drm_WARN_ON(display->drm, seq_buf_has_overflowed(s)); |
| 5100 | + |
| 5101 | + return seq_buf_str(s); |
| 5102 | +} |
| 5103 | + |
5070 | 5104 | void intel_ddi_init(struct intel_display *display, |
5071 | 5105 | const struct intel_bios_encoder_data *devdata) |
5072 | 5106 | { |
5073 | 5107 | struct intel_digital_port *dig_port; |
5074 | 5108 | struct intel_encoder *encoder; |
| 5109 | + DECLARE_SEQ_BUF(encoder_name, 20); |
5075 | 5110 | bool init_hdmi, init_dp; |
5076 | 5111 | enum port port; |
5077 | 5112 | enum phy phy; |
@@ -5156,37 +5191,9 @@ void intel_ddi_init(struct intel_display *display, |
5156 | 5191 | encoder = &dig_port->base; |
5157 | 5192 | encoder->devdata = devdata; |
5158 | 5193 |
|
5159 | | - if (DISPLAY_VER(display) >= 13 && port >= PORT_D_XELPD) { |
5160 | | - drm_encoder_init(display->drm, &encoder->base, &intel_ddi_funcs, |
5161 | | - DRM_MODE_ENCODER_TMDS, |
5162 | | - "DDI %c/PHY %c", |
5163 | | - port_name(port - PORT_D_XELPD + PORT_D), |
5164 | | - phy_name(phy)); |
5165 | | - } else if (DISPLAY_VER(display) >= 12) { |
5166 | | - enum tc_port tc_port = intel_port_to_tc(display, port); |
5167 | | - |
5168 | | - drm_encoder_init(display->drm, &encoder->base, &intel_ddi_funcs, |
5169 | | - DRM_MODE_ENCODER_TMDS, |
5170 | | - "DDI %s%c/PHY %s%c", |
5171 | | - port >= PORT_TC1 ? "TC" : "", |
5172 | | - port >= PORT_TC1 ? port_tc_name(port) : port_name(port), |
5173 | | - tc_port != TC_PORT_NONE ? "TC" : "", |
5174 | | - tc_port != TC_PORT_NONE ? tc_port_name(tc_port) : phy_name(phy)); |
5175 | | - } else if (DISPLAY_VER(display) >= 11) { |
5176 | | - enum tc_port tc_port = intel_port_to_tc(display, port); |
5177 | | - |
5178 | | - drm_encoder_init(display->drm, &encoder->base, &intel_ddi_funcs, |
5179 | | - DRM_MODE_ENCODER_TMDS, |
5180 | | - "DDI %c%s/PHY %s%c", |
5181 | | - port_name(port), |
5182 | | - port >= PORT_C ? " (TC)" : "", |
5183 | | - tc_port != TC_PORT_NONE ? "TC" : "", |
5184 | | - tc_port != TC_PORT_NONE ? tc_port_name(tc_port) : phy_name(phy)); |
5185 | | - } else { |
5186 | | - drm_encoder_init(display->drm, &encoder->base, &intel_ddi_funcs, |
5187 | | - DRM_MODE_ENCODER_TMDS, |
5188 | | - "DDI %c/PHY %c", port_name(port), phy_name(phy)); |
5189 | | - } |
| 5194 | + drm_encoder_init(display->drm, &encoder->base, &intel_ddi_funcs, |
| 5195 | + DRM_MODE_ENCODER_TMDS, "%s", |
| 5196 | + intel_ddi_encoder_name(display, port, phy, &encoder_name)); |
5190 | 5197 |
|
5191 | 5198 | intel_encoder_link_check_init(encoder, intel_ddi_link_check); |
5192 | 5199 |
|
|
0 commit comments