Skip to content

Commit 55c771b

Browse files
committed
drm/i915/ddi: abstract figuring out encoder name
The encoder name deduction has become a bit cumbersome within intel_ddi_init(). Split it out to a separate function to declutter intel_ddi_init(), even if that means having to use a temp seq buffer for the name. Cc: Ankit Nautiyal <ankit.k.nautiyal@intel.com> Reviewed-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com> Link: https://lore.kernel.org/r/20250903101050.3671305-1-jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
1 parent 7ea3baa commit 55c771b

1 file changed

Lines changed: 38 additions & 31 deletions

File tree

drivers/gpu/drm/i915/display/intel_ddi.c

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
*/
2727

2828
#include <linux/iopoll.h>
29+
#include <linux/seq_buf.h>
2930
#include <linux/string_helpers.h>
3031

3132
#include <drm/display/drm_dp_helper.h>
@@ -5067,11 +5068,45 @@ static bool port_in_use(struct intel_display *display, enum port port)
50675068
return false;
50685069
}
50695070

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+
50705104
void intel_ddi_init(struct intel_display *display,
50715105
const struct intel_bios_encoder_data *devdata)
50725106
{
50735107
struct intel_digital_port *dig_port;
50745108
struct intel_encoder *encoder;
5109+
DECLARE_SEQ_BUF(encoder_name, 20);
50755110
bool init_hdmi, init_dp;
50765111
enum port port;
50775112
enum phy phy;
@@ -5156,37 +5191,9 @@ void intel_ddi_init(struct intel_display *display,
51565191
encoder = &dig_port->base;
51575192
encoder->devdata = devdata;
51585193

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));
51905197

51915198
intel_encoder_link_check_init(encoder, intel_ddi_link_check);
51925199

0 commit comments

Comments
 (0)