[Intel-gfx] [PATCH 7/7] drm/i915: enable DP/eDP for Sandybridge/Cougarpoint

Adam Jackson ajax at redhat.com
Wed Apr 7 16:15:43 CEST 2010


On Wed, 2010-04-07 at 16:15 +0800, Zhenyu Wang wrote:
>  
> +static int gen6_edp_levels[] = {
> +	EDP_LINK_TRAIN_400MV_0DB_SNB_B,
> +	EDP_LINK_TRAIN_400MV_6DB_SNB_B,
> +	EDP_LINK_TRAIN_600MV_3_5DB_SNB_B,
> +	EDP_LINK_TRAIN_800MV_0DB_SNB_B,
> +};
> +
> +/* Gen6's DP voltage swing and pre-emphasis control */
> +static uint32_t
> +intel_gen6_edp_signal_levels(uint8_t train_set)
> +{
> +	int v, p;
> +
> +	switch (train_set & DP_TRAIN_VOLTAGE_SWING_MASK) {
> +	case DP_TRAIN_VOLTAGE_SWING_400:
> +	default:
> +		v = 0;
> +		break;
> +	case DP_TRAIN_VOLTAGE_SWING_600:
> +		v = 0;
> +		break;
> +	case DP_TRAIN_VOLTAGE_SWING_800:
> +		v = 3;
> +		break;
> +	case DP_TRAIN_VOLTAGE_SWING_1200:
> +		v = 0;
> +		DRM_DEBUG_KMS("Unsupported voltage swing 1200mV!\n");
> +		break;
> +	}
> +	switch (train_set & DP_TRAIN_PRE_EMPHASIS_MASK) {
> +	case DP_TRAIN_PRE_EMPHASIS_0:
> +	default:
> +		p = 0;
> +		break;
> +	case DP_TRAIN_PRE_EMPHASIS_3_5:
> +		p = 2;
> +		break;
> +	case DP_TRAIN_PRE_EMPHASIS_6:
> +		p = 1;
> +		break;
> +	case DP_TRAIN_PRE_EMPHASIS_9_5:
> +		p = 0;
> +		DRM_DEBUG_KMS("Unsupported pre-emphasis 9.5dB\n");
> +		break;
> +	}
> +	if (v + p > 3) {
> +		DRM_DEBUG_KMS("Unsupported voltage swing/pre-emphasis level\n");
> +		return gen6_edp_levels[0];
> +	} else
> +		return gen6_edp_levels[v + p];
> +}

This is a curiously verbose way to write this.  I stared at the array
indexing for about twenty seconds before I got it.  Seems a lot more
straightforward to just do:

	switch (train_set & (DP_TRAIN_VOLTAGE_SWING_MASK|DP_TRAIN_PRE_EMPHASIS_MASK)) {
	case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PREEMPHASIS_0:
		return EDP_LINK_TRAIN_400MV_0DB_SNB_B;
	case DP_TRAIN_VOLTAGE_SWING_400 | DP_TRAIN_PREEMPHASIS_6:
		return EDP_LINK_TRAIN_400MV_6DB_SNB_B;
	case DP_TRAIN_VOLTAGE_SWING_600 | DP_TRAIN_PREEMPHASIS_3_5:
		return EDP_LINK_TRAIN_600MV_3_5DB_SNB_B;
	case DP_TRAIN_VOLTAGE_SWING_800 | DP_TRAIN_PREEMPHASIS_0:
		return EDP_LINK_TRAIN_800MV_0DB_SNB_B;
	default:
		DRM_DEBUG_KMS("Unsupported voltage swing/pre-emphasis-level\n");
		return EDP_LINK_TRAIN_400MV_0DB_SNB_B;
	}

- ajax
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/intel-gfx/attachments/20100407/e1e56706/attachment.sig>


More information about the Intel-gfx mailing list