Commit 69039177 authored by Jani Nikula's avatar Jani Nikula

drm/i915/dp: refactor aux_ch_name()

Convert aux_ch_name() to a helper that prints a string to a caller
provided buffer, and use it to get more consistent aux channel
debugs. Now that all users of aux_ch_name() are in intel_dp_aux.c, we
can make it static too.
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Reviewed-by: default avatarGustavo Sousa <gustavo.sousa@intel.com>
Reviewed-by: default avatarAndrzej Hajda <andrzej.hajda@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230922105645.3991066-1-jani.nikula@intel.com
parent 156adfa5
...@@ -190,8 +190,6 @@ enum aux_ch { ...@@ -190,8 +190,6 @@ enum aux_ch {
AUX_CH_E_XELPD, AUX_CH_E_XELPD,
}; };
#define aux_ch_name(a) ((a) + 'A')
enum phy { enum phy {
PHY_NONE = -1, PHY_NONE = -1,
......
...@@ -14,6 +14,21 @@ ...@@ -14,6 +14,21 @@
#include "intel_pps.h" #include "intel_pps.h"
#include "intel_tc.h" #include "intel_tc.h"
#define AUX_CH_NAME_BUFSIZE 6
static const char *aux_ch_name(struct drm_i915_private *i915,
char *buf, int size, enum aux_ch aux_ch)
{
if (DISPLAY_VER(i915) >= 13 && aux_ch >= AUX_CH_D_XELPD)
snprintf(buf, size, "%c", 'A' + aux_ch - AUX_CH_D_XELPD + AUX_CH_D);
else if (DISPLAY_VER(i915) >= 12 && aux_ch >= AUX_CH_USBC1)
snprintf(buf, size, "USBC%c", '1' + aux_ch - AUX_CH_USBC1);
else
snprintf(buf, size, "%c", 'A' + aux_ch);
return buf;
}
u32 intel_dp_aux_pack(const u8 *src, int src_bytes) u32 intel_dp_aux_pack(const u8 *src, int src_bytes)
{ {
int i; int i;
...@@ -728,6 +743,7 @@ void intel_dp_aux_init(struct intel_dp *intel_dp) ...@@ -728,6 +743,7 @@ void intel_dp_aux_init(struct intel_dp *intel_dp)
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
struct intel_encoder *encoder = &dig_port->base; struct intel_encoder *encoder = &dig_port->base;
enum aux_ch aux_ch = dig_port->aux_ch; enum aux_ch aux_ch = dig_port->aux_ch;
char buf[AUX_CH_NAME_BUFSIZE];
if (DISPLAY_VER(dev_priv) >= 14) { if (DISPLAY_VER(dev_priv) >= 14) {
intel_dp->aux_ch_ctl_reg = xelpdp_aux_ctl_reg; intel_dp->aux_ch_ctl_reg = xelpdp_aux_ctl_reg;
...@@ -764,17 +780,8 @@ void intel_dp_aux_init(struct intel_dp *intel_dp) ...@@ -764,17 +780,8 @@ void intel_dp_aux_init(struct intel_dp *intel_dp)
drm_dp_aux_init(&intel_dp->aux); drm_dp_aux_init(&intel_dp->aux);
/* Failure to allocate our preferred name is not critical */ /* Failure to allocate our preferred name is not critical */
if (DISPLAY_VER(dev_priv) >= 13 && aux_ch >= AUX_CH_D_XELPD) intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX %s/%s",
intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX %c/%s", aux_ch_name(dev_priv, buf, sizeof(buf), aux_ch),
aux_ch_name(aux_ch - AUX_CH_D_XELPD + AUX_CH_D),
encoder->base.name);
else if (DISPLAY_VER(dev_priv) >= 12 && aux_ch >= AUX_CH_USBC1)
intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX USBC%c/%s",
aux_ch - AUX_CH_USBC1 + '1',
encoder->base.name);
else
intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX %c/%s",
aux_ch_name(aux_ch),
encoder->base.name); encoder->base.name);
intel_dp->aux.transfer = intel_dp_aux_transfer; intel_dp->aux.transfer = intel_dp_aux_transfer;
...@@ -819,6 +826,7 @@ enum aux_ch intel_dp_aux_ch(struct intel_encoder *encoder) ...@@ -819,6 +826,7 @@ enum aux_ch intel_dp_aux_ch(struct intel_encoder *encoder)
struct intel_encoder *other; struct intel_encoder *other;
const char *source; const char *source;
enum aux_ch aux_ch; enum aux_ch aux_ch;
char buf[AUX_CH_NAME_BUFSIZE];
aux_ch = intel_bios_dp_aux_ch(encoder->devdata); aux_ch = intel_bios_dp_aux_ch(encoder->devdata);
source = "VBT"; source = "VBT";
...@@ -836,16 +844,17 @@ enum aux_ch intel_dp_aux_ch(struct intel_encoder *encoder) ...@@ -836,16 +844,17 @@ enum aux_ch intel_dp_aux_ch(struct intel_encoder *encoder)
other = get_encoder_by_aux_ch(encoder, aux_ch); other = get_encoder_by_aux_ch(encoder, aux_ch);
if (other) { if (other) {
drm_dbg_kms(&i915->drm, drm_dbg_kms(&i915->drm,
"[ENCODER:%d:%s] AUX CH %c already claimed by [ENCODER:%d:%s]\n", "[ENCODER:%d:%s] AUX CH %s already claimed by [ENCODER:%d:%s]\n",
encoder->base.base.id, encoder->base.name, aux_ch_name(aux_ch), encoder->base.base.id, encoder->base.name,
aux_ch_name(i915, buf, sizeof(buf), aux_ch),
other->base.base.id, other->base.name); other->base.base.id, other->base.name);
return AUX_CH_NONE; return AUX_CH_NONE;
} }
drm_dbg_kms(&i915->drm, drm_dbg_kms(&i915->drm,
"[ENCODER:%d:%s] Using AUX CH %c (%s)\n", "[ENCODER:%d:%s] Using AUX CH %s (%s)\n",
encoder->base.base.id, encoder->base.name, encoder->base.base.id, encoder->base.name,
aux_ch_name(aux_ch), source); aux_ch_name(i915, buf, sizeof(buf), aux_ch), source);
return aux_ch; return aux_ch;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment