From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 4/4] drm/i915: Split map_aux_ch() into per-platform arrays
Date: Fri, 17 Feb 2023 08:40:15 +0200 [thread overview]
Message-ID: <Y+8hT3rFr42SXYO2@intel.com> (raw)
In-Reply-To: <20230216231312.32664-4-ville.syrjala@linux.intel.com>
On Fri, Feb 17, 2023 at 01:13:12AM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> The big switch+if statement mess in map_aux_ch() is
> illegible. Split up into cleaner per-platform arrays
> like we already have for the gmbus pins.
>
> To save space in the arrays we shift away the lower nibble
> of the VBT AUX CH byte since it's always zero anyway.
>
> Extra care must be taken to not leave any holes in the
> arrays because zero initialization would cause them to
> be interpreted as AUX_CH_A. While technically we could
> leave AUX_CH_NONE entries from the end of the array
> (as the whole array would then be smaller) I decided to
> fully pad out the arrays to set a good example. Another
> complication with that would be that the VBT AUX CH
> values are not in a sensible order (eg. DP_AUX_A==0x40).
It occurs to me that one way to avoid these problems would
be to reverse the roles of the index and value. The lookup
would then have to search through the array, but that
doesn't seem too terrible.
>
> TODO: Didn't bother with the platform variants beyond the
> ones that really need remapping, which means if the
> VBT is bogus we end up with a nonexistent aux ch.
> Might be nice to check this a bit better.
> Yet another bitmask in device info?
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_bios.c | 157 ++++++++++++----------
> 1 file changed, 86 insertions(+), 71 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
> index f35ef3675d39..6d9957690a0a 100644
> --- a/drivers/gpu/drm/i915/display/intel_bios.c
> +++ b/drivers/gpu/drm/i915/display/intel_bios.c
> @@ -3572,84 +3572,99 @@ bool intel_bios_get_dsc_params(struct intel_encoder *encoder,
> return false;
> }
>
> +/*
> + * Warning: the aux_ch map arrays must not be populated
> + * sparsely because AUX_CH_A==0. Pad any holes with AUX_CH_NONE.
> + */
> +static const enum aux_ch xelpd_aux_ch_map[] = {
> + [DP_AUX_A >> 4] = AUX_CH_A,
> + [DP_AUX_B >> 4] = AUX_CH_B,
> + [DP_AUX_C >> 4] = AUX_CH_C,
> + [DP_AUX_D >> 4] = AUX_CH_D_XELPD,
> + [DP_AUX_E >> 4] = AUX_CH_E_XELPD,
> + [DP_AUX_F >> 4] = AUX_CH_USBC1,
> + [DP_AUX_G >> 4] = AUX_CH_USBC2,
> + [DP_AUX_H >> 4] = AUX_CH_USBC3,
> + [DP_AUX_I >> 4] = AUX_CH_USBC4,
> +};
> +
> +/*
> + * ADL-S VBT uses PHY based mapping. Combo PHYs A,B,C,D,E
> + * map to DDI A,TC1,TC2,TC3,TC4 respectively.
> + */
> +static const enum aux_ch adls_aux_ch_map[] = {
> + [DP_AUX_A >> 4] = AUX_CH_A,
> + [DP_AUX_B >> 4] = AUX_CH_USBC1,
> + [DP_AUX_C >> 4] = AUX_CH_USBC2,
> + [DP_AUX_D >> 4] = AUX_CH_USBC3,
> + [DP_AUX_E >> 4] = AUX_CH_USBC4,
> + [DP_AUX_F >> 4] = AUX_CH_NONE,
> + [DP_AUX_G >> 4] = AUX_CH_NONE,
> + [DP_AUX_H >> 4] = AUX_CH_NONE,
> + [DP_AUX_I >> 4] = AUX_CH_NONE,
> +};
> +
> +/*
> + * RKL/DG1 VBT uses PHY based mapping. Combo PHYs A,B,C,D
> + * map to DDI A,B,TC1,TC2 respectively.
> + */
> +static const enum aux_ch rkl_aux_ch_map[] = {
> + [DP_AUX_A >> 4] = AUX_CH_A,
> + [DP_AUX_B >> 4] = AUX_CH_B,
> + [DP_AUX_C >> 4] = AUX_CH_USBC1,
> + [DP_AUX_D >> 4] = AUX_CH_USBC2,
> + [DP_AUX_E >> 4] = AUX_CH_NONE,
> + [DP_AUX_F >> 4] = AUX_CH_NONE,
> + [DP_AUX_G >> 4] = AUX_CH_NONE,
> + [DP_AUX_H >> 4] = AUX_CH_NONE,
> + [DP_AUX_I >> 4] = AUX_CH_NONE,
> +};
> +
> +static const enum aux_ch direct_aux_ch_map[] = {
> + [DP_AUX_A >> 4] = AUX_CH_A,
> + [DP_AUX_B >> 4] = AUX_CH_B,
> + [DP_AUX_C >> 4] = AUX_CH_C,
> + [DP_AUX_D >> 4] = AUX_CH_D, /* aka AUX_CH_USBC1 */
> + [DP_AUX_E >> 4] = AUX_CH_E, /* aka AUX_CH_USBC2 */
> + [DP_AUX_F >> 4] = AUX_CH_F, /* aka AUX_CH_USBC3 */
> + [DP_AUX_G >> 4] = AUX_CH_G, /* aka AUX_CH_USBC4 */
> + [DP_AUX_H >> 4] = AUX_CH_H, /* aka AUX_CH_USBC5 */
> + [DP_AUX_I >> 4] = AUX_CH_I, /* aka AUX_CH_USBC6 */
> +};
> +
> static enum aux_ch map_aux_ch(struct drm_i915_private *i915, u8 aux_channel)
> {
> - enum aux_ch aux_ch;
> + const enum aux_ch *aux_ch_map;
> + int index, n_entries;
>
> /*
> - * RKL/DG1 VBT uses PHY based mapping. Combo PHYs A,B,C,D
> - * map to DDI A,B,TC1,TC2 respectively.
> - *
> - * ADL-S VBT uses PHY based mapping. Combo PHYs A,B,C,D,E
> - * map to DDI A,TC1,TC2,TC3,TC4 respectively.
> + * The lower nibble is always 0 and we
> + * don't include it in the array index.
> */
> - switch (aux_channel) {
> - case DP_AUX_A:
> - aux_ch = AUX_CH_A;
> - break;
> - case DP_AUX_B:
> - if (IS_ALDERLAKE_S(i915))
> - aux_ch = AUX_CH_USBC1;
> - else
> - aux_ch = AUX_CH_B;
> - break;
> - case DP_AUX_C:
> - if (IS_ALDERLAKE_S(i915))
> - aux_ch = AUX_CH_USBC2;
> - else if (IS_DG1(i915) || IS_ROCKETLAKE(i915))
> - aux_ch = AUX_CH_USBC1;
> - else
> - aux_ch = AUX_CH_C;
> - break;
> - case DP_AUX_D:
> - if (DISPLAY_VER(i915) >= 13)
> - aux_ch = AUX_CH_D_XELPD;
> - else if (IS_ALDERLAKE_S(i915))
> - aux_ch = AUX_CH_USBC3;
> - else if (IS_DG1(i915) || IS_ROCKETLAKE(i915))
> - aux_ch = AUX_CH_USBC2;
> - else
> - aux_ch = AUX_CH_D;
> - break;
> - case DP_AUX_E:
> - if (DISPLAY_VER(i915) >= 13)
> - aux_ch = AUX_CH_E_XELPD;
> - else if (IS_ALDERLAKE_S(i915))
> - aux_ch = AUX_CH_USBC4;
> - else
> - aux_ch = AUX_CH_E;
> - break;
> - case DP_AUX_F:
> - if (DISPLAY_VER(i915) >= 13)
> - aux_ch = AUX_CH_USBC1;
> - else
> - aux_ch = AUX_CH_F;
> - break;
> - case DP_AUX_G:
> - if (DISPLAY_VER(i915) >= 13)
> - aux_ch = AUX_CH_USBC2;
> - else
> - aux_ch = AUX_CH_G;
> - break;
> - case DP_AUX_H:
> - if (DISPLAY_VER(i915) >= 13)
> - aux_ch = AUX_CH_USBC3;
> - else
> - aux_ch = AUX_CH_H;
> - break;
> - case DP_AUX_I:
> - if (DISPLAY_VER(i915) >= 13)
> - aux_ch = AUX_CH_USBC4;
> - else
> - aux_ch = AUX_CH_I;
> - break;
> - default:
> - MISSING_CASE(aux_channel);
> - aux_ch = AUX_CH_A;
> - break;
> + index = aux_channel >> 4;
> +
> + if (DISPLAY_VER(i915) >= 13) {
> + aux_ch_map = xelpd_aux_ch_map;
> + n_entries = ARRAY_SIZE(xelpd_aux_ch_map);
> + } else if (IS_ALDERLAKE_S(i915)) {
> + aux_ch_map = adls_aux_ch_map;
> + n_entries = ARRAY_SIZE(adls_aux_ch_map);
> + } else if (IS_DG1(i915) || IS_ROCKETLAKE(i915)) {
> + aux_ch_map = rkl_aux_ch_map;
> + n_entries = ARRAY_SIZE(rkl_aux_ch_map);
> + } else {
> + aux_ch_map = direct_aux_ch_map;
> + n_entries = ARRAY_SIZE(direct_aux_ch_map);
> }
>
> - return aux_ch;
> + if (index < n_entries && aux_ch_map[index] != AUX_CH_NONE)
> + return aux_ch_map[index];
> +
> + drm_dbg_kms(&i915->drm,
> + "Ignoring alternate AUX CH: VBT claims AUX 0x%x, which is not valid for this platform\n",
> + aux_channel);
> +
> + return AUX_CH_NONE;
> }
>
> enum aux_ch intel_bios_dp_aux_ch(const struct intel_bios_encoder_data *devdata)
> --
> 2.39.2
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2023-02-17 6:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 23:13 [Intel-gfx] [PATCH 1/4] drm/i915: Restructure intel_bios_port_aux_ch() Ville Syrjala
2023-02-16 23:13 ` [Intel-gfx] [PATCH 2/4] drm/i915: Pimp encoder ddc_pin/aux_ch debug messages Ville Syrjala
2023-02-17 7:03 ` Nautiyal, Ankit K
2023-02-16 23:13 ` [Intel-gfx] [PATCH 3/4] drm/i915: Fix platform default aux ch for skl Ville Syrjala
2023-02-17 9:45 ` Nautiyal, Ankit K
2023-02-17 12:02 ` Ville Syrjälä
2023-02-17 13:05 ` Nautiyal, Ankit K
2023-02-17 13:12 ` Ville Syrjälä
2023-02-17 13:53 ` Nautiyal, Ankit K
2023-02-16 23:13 ` [Intel-gfx] [PATCH 4/4] drm/i915: Split map_aux_ch() into per-platform arrays Ville Syrjala
2023-02-17 6:40 ` Ville Syrjälä [this message]
2023-02-17 0:01 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for series starting with [1/4] drm/i915: Restructure intel_bios_port_aux_ch() Patchwork
2023-02-17 0:25 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-02-17 6:38 ` [Intel-gfx] [PATCH 1/4] " Nautiyal, Ankit K
2023-02-17 12:45 ` Jani Nikula
2023-02-17 13:05 ` Ville Syrjälä
2023-02-17 14:28 ` [Intel-gfx] ✗ Fi.CI.IGT: failure for series starting with [1/4] " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y+8hT3rFr42SXYO2@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.