Skip to content

Commit 6903917

Browse files
committed
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: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com> Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230922105645.3991066-1-jani.nikula@intel.com
1 parent 156adfa commit 6903917

2 files changed

Lines changed: 25 additions & 18 deletions

File tree

drivers/gpu/drm/i915/display/intel_display.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ enum aux_ch {
190190
AUX_CH_E_XELPD,
191191
};
192192

193-
#define aux_ch_name(a) ((a) + 'A')
194-
195193
enum phy {
196194
PHY_NONE = -1,
197195

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

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414
#include "intel_pps.h"
1515
#include "intel_tc.h"
1616

17+
#define AUX_CH_NAME_BUFSIZE 6
18+
19+
static const char *aux_ch_name(struct drm_i915_private *i915,
20+
char *buf, int size, enum aux_ch aux_ch)
21+
{
22+
if (DISPLAY_VER(i915) >= 13 && aux_ch >= AUX_CH_D_XELPD)
23+
snprintf(buf, size, "%c", 'A' + aux_ch - AUX_CH_D_XELPD + AUX_CH_D);
24+
else if (DISPLAY_VER(i915) >= 12 && aux_ch >= AUX_CH_USBC1)
25+
snprintf(buf, size, "USBC%c", '1' + aux_ch - AUX_CH_USBC1);
26+
else
27+
snprintf(buf, size, "%c", 'A' + aux_ch);
28+
29+
return buf;
30+
}
31+
1732
u32 intel_dp_aux_pack(const u8 *src, int src_bytes)
1833
{
1934
int i;
@@ -728,6 +743,7 @@ void intel_dp_aux_init(struct intel_dp *intel_dp)
728743
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
729744
struct intel_encoder *encoder = &dig_port->base;
730745
enum aux_ch aux_ch = dig_port->aux_ch;
746+
char buf[AUX_CH_NAME_BUFSIZE];
731747

732748
if (DISPLAY_VER(dev_priv) >= 14) {
733749
intel_dp->aux_ch_ctl_reg = xelpdp_aux_ctl_reg;
@@ -764,18 +780,9 @@ void intel_dp_aux_init(struct intel_dp *intel_dp)
764780
drm_dp_aux_init(&intel_dp->aux);
765781

766782
/* Failure to allocate our preferred name is not critical */
767-
if (DISPLAY_VER(dev_priv) >= 13 && aux_ch >= AUX_CH_D_XELPD)
768-
intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX %c/%s",
769-
aux_ch_name(aux_ch - AUX_CH_D_XELPD + AUX_CH_D),
770-
encoder->base.name);
771-
else if (DISPLAY_VER(dev_priv) >= 12 && aux_ch >= AUX_CH_USBC1)
772-
intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX USBC%c/%s",
773-
aux_ch - AUX_CH_USBC1 + '1',
774-
encoder->base.name);
775-
else
776-
intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX %c/%s",
777-
aux_ch_name(aux_ch),
778-
encoder->base.name);
783+
intel_dp->aux.name = kasprintf(GFP_KERNEL, "AUX %s/%s",
784+
aux_ch_name(dev_priv, buf, sizeof(buf), aux_ch),
785+
encoder->base.name);
779786

780787
intel_dp->aux.transfer = intel_dp_aux_transfer;
781788
cpu_latency_qos_add_request(&intel_dp->pm_qos, PM_QOS_DEFAULT_VALUE);
@@ -819,6 +826,7 @@ enum aux_ch intel_dp_aux_ch(struct intel_encoder *encoder)
819826
struct intel_encoder *other;
820827
const char *source;
821828
enum aux_ch aux_ch;
829+
char buf[AUX_CH_NAME_BUFSIZE];
822830

823831
aux_ch = intel_bios_dp_aux_ch(encoder->devdata);
824832
source = "VBT";
@@ -836,16 +844,17 @@ enum aux_ch intel_dp_aux_ch(struct intel_encoder *encoder)
836844
other = get_encoder_by_aux_ch(encoder, aux_ch);
837845
if (other) {
838846
drm_dbg_kms(&i915->drm,
839-
"[ENCODER:%d:%s] AUX CH %c already claimed by [ENCODER:%d:%s]\n",
840-
encoder->base.base.id, encoder->base.name, aux_ch_name(aux_ch),
847+
"[ENCODER:%d:%s] AUX CH %s already claimed by [ENCODER:%d:%s]\n",
848+
encoder->base.base.id, encoder->base.name,
849+
aux_ch_name(i915, buf, sizeof(buf), aux_ch),
841850
other->base.base.id, other->base.name);
842851
return AUX_CH_NONE;
843852
}
844853

845854
drm_dbg_kms(&i915->drm,
846-
"[ENCODER:%d:%s] Using AUX CH %c (%s)\n",
855+
"[ENCODER:%d:%s] Using AUX CH %s (%s)\n",
847856
encoder->base.base.id, encoder->base.name,
848-
aux_ch_name(aux_ch), source);
857+
aux_ch_name(i915, buf, sizeof(buf), aux_ch), source);
849858

850859
return aux_ch;
851860
}

0 commit comments

Comments
 (0)