All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm/i915: Refactor translate_signal_level()
Date: Thu, 23 Feb 2017 19:47:18 +0200	[thread overview]
Message-ID: <20170223174718.GW31595@intel.com> (raw)
In-Reply-To: <20170223174352.sot73s52pqt5u3hh@boom>

On Thu, Feb 23, 2017 at 07:43:52PM +0200, David Weinehall wrote:
> On Thu, Feb 23, 2017 at 07:35:06PM +0200, ville.syrjala@linux.intel.com wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Convert the big switch statement in translate_signal_level() into a neat
> > table. The table also serves as documentation for the translation
> > tables. We'll also have other uses for this table later on.
> > 
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Reviewed-by: David Weinehall <david.weinehall@linux.intel.com>
> 
> > ---
> >  drivers/gpu/drm/i915/intel_ddi.c | 60 ++++++++++++++--------------------------
> >  1 file changed, 21 insertions(+), 39 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> > index 5e4b0172810d..6f8e57f127e5 100644
> > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > @@ -34,6 +34,19 @@ struct ddi_buf_trans {
> >  	u8 i_boost;	/* SKL: I_boost; valid: 0x0, 0x1, 0x3, 0x7 */
> >  };
> >  
> > +static const u8 index_to_dp_signal_levels[] = {
> > +	[0] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_0,
> > +	[1] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_1,
> > +	[2] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_2,
> > +	[3] = DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_3,
> > +	[4] = DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_0,
> > +	[5] = DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_1,
> > +	[6] = DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_2,
> > +	[7] = DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_0,
> > +	[8] = DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_1,
> > +	[9] = DP_TRAIN_VOLTAGE_SWING_LEVEL_3 | DP_TRAIN_PRE_EMPH_LEVEL_0,
> > +};
> > +
> >  /* HDMI/DVI modes ignore everything but the last 2 items. So we share
> >   * them for both DP and FDI transports, allowing those ports to
> >   * automatically adapt to HDMI connections as well
> > @@ -1604,48 +1617,17 @@ static void bxt_ddi_vswing_sequence(struct drm_i915_private *dev_priv,
> >  
> >  static uint32_t translate_signal_level(int signal_levels)
> >  {
> > -	uint32_t level;
> > -
> > -	switch (signal_levels) {
> > -	default:
> > -		DRM_DEBUG_KMS("Unsupported voltage swing/pre-emphasis level: 0x%x\n",
> > -			      signal_levels);
> > -	case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_0:
> > -		level = 0;
> > -		break;
> > -	case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_1:
> > -		level = 1;
> > -		break;
> > -	case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_2:
> > -		level = 2;
> > -		break;
> > -	case DP_TRAIN_VOLTAGE_SWING_LEVEL_0 | DP_TRAIN_PRE_EMPH_LEVEL_3:
> > -		level = 3;
> > -		break;
> > -
> > -	case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_0:
> > -		level = 4;
> > -		break;
> > -	case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_1:
> > -		level = 5;
> > -		break;
> > -	case DP_TRAIN_VOLTAGE_SWING_LEVEL_1 | DP_TRAIN_PRE_EMPH_LEVEL_2:
> > -		level = 6;
> > -		break;
> > -
> > -	case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_0:
> > -		level = 7;
> > -		break;
> > -	case DP_TRAIN_VOLTAGE_SWING_LEVEL_2 | DP_TRAIN_PRE_EMPH_LEVEL_1:
> > -		level = 8;
> > -		break;
> > +	int i;
> >  
> > -	case DP_TRAIN_VOLTAGE_SWING_LEVEL_3 | DP_TRAIN_PRE_EMPH_LEVEL_0:
> > -		level = 9;
> > -		break;
> > +	for (i = 0; i <  ARRAY_SIZE(index_to_dp_signal_levels); i++) {
> 
> Superfluous space between < and ARRAY_SIZE.

Ack.

> 
> > +		if (index_to_dp_signal_levels[i] == signal_levels)
> > +			return i;
> >  	}
> >  
> > -	return level;
> > +	WARN(1, "Unsupported voltage swing/pre-emphasis level: 0x%x\n",
> > +	     signal_levels);
> > +
> > +	return 0;
> >  }
> >  
> >  uint32_t ddi_signal_levels(struct intel_dp *intel_dp)
> > -- 
> > 2.10.2
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-02-23 17:47 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-23 17:35 [PATCH 1/3] drm/i915: Refactor code to select the DDI buf translation table ville.syrjala
2017-02-23 17:35 ` [PATCH 2/3] drm/i915: Refactor translate_signal_level() ville.syrjala
2017-02-23 17:43   ` David Weinehall
2017-02-23 17:47     ` Ville Syrjälä [this message]
2017-02-23 17:35 ` [PATCH 3/3] drm/i915: Introduce intel_ddi_dp_voltage_max() ville.syrjala
2017-02-23 17:44   ` David Weinehall
2017-02-23 17:47     ` Ville Syrjälä
2017-02-23 17:49   ` [PATCH v2 " ville.syrjala
2017-02-23 17:49 ` [PATCH 1/3] drm/i915: Refactor code to select the DDI buf translation table David Weinehall
2017-02-24 12:49   ` Ville Syrjälä
2017-02-23 19:52 ` ✓ Fi.CI.BAT: success for series starting with [1/3] drm/i915: Refactor code to select the DDI buf translation table (rev2) 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=20170223174718.GW31595@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.