for (i = 0; i < DP_MAX_SUPPORTED_RATES; i++)
link->rates[i] = 0;
link->num_rates = 0;
}
/** * drm_dp_link_add_rate() - add a rate to the list of supported rates * @link: the link to add the rate to * @rate: the rate to add * * Add a link rate to the list of supported link rates. * * Returns: * 0 on success or one of the following negative error codes on failure: * - ENOSPC if the maximum number of supported rates has been reached * - EEXISTS if the link already supports this rate * * See also: * drm_dp_link_remove_rate()
*/ int drm_dp_link_add_rate(struct drm_dp_link *link, unsignedlong rate)
{ unsignedint i, pivot;
if (link->num_rates == DP_MAX_SUPPORTED_RATES) return -ENOSPC;
for (pivot = 0; pivot < link->num_rates; pivot++) if (rate <= link->rates[pivot]) break;
if (pivot != link->num_rates && rate == link->rates[pivot]) return -EEXIST;
for (i = link->num_rates; i > pivot; i--)
link->rates[i] = link->rates[i - 1];
link->rates[pivot] = rate;
link->num_rates++;
return 0;
}
/** * drm_dp_link_remove_rate() - remove a rate from the list of supported rates * @link: the link from which to remove the rate * @rate: the rate to remove * * Removes a link rate from the list of supported link rates. * * Returns: * 0 on success or one of the following negative error codes on failure: * - EINVAL if the specified rate is not among the supported rates * * See also: * drm_dp_link_add_rate()
*/ int drm_dp_link_remove_rate(struct drm_dp_link *link, unsignedlong rate)
{ unsignedint i;
for (i = 0; i < link->num_rates; i++) if (rate == link->rates[i]) break;
if (i == link->num_rates) return -EINVAL;
link->num_rates--;
while (i < link->num_rates) {
link->rates[i] = link->rates[i + 1];
i++;
}
return 0;
}
/** * drm_dp_link_update_rates() - normalize the supported link rates array * @link: the link for which to normalize the supported link rates * * Users should call this function after they've manually modified the array * of supported link rates. This function removes any stale entries, compacts * the array and updates the supported link rate count. Note that calling the * drm_dp_link_remove_rate() function already does this janitorial work. * * See also: * drm_dp_link_add_rate(), drm_dp_link_remove_rate()
*/ void drm_dp_link_update_rates(struct drm_dp_link *link)
{ unsignedint i, count = 0;
for (i = 0; i < link->num_rates; i++) { if (link->rates[i] != 0)
link->rates[count++] = link->rates[i];
}
for (i = count; i < link->num_rates; i++)
link->rates[i] = 0;
link->num_rates = count;
}
/** * drm_dp_link_probe() - probe a DisplayPort link for capabilities * @aux: DisplayPort AUX channel * @link: pointer to structure in which to return link capabilities * * The structure filled in by this function can usually be passed directly * into drm_dp_link_power_up() and drm_dp_link_configure() to power up and * configure the link based on the link's capabilities. * * Returns 0 on success or a negative error code on failure.
*/ int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link)
{
u8 dpcd[DP_RECEIVER_CAP_SIZE], value; unsignedint rd_interval; int err;
/* * The DPCD stores the AUX read interval in units of 4 ms. There are * two special cases: * * 1) if the TRAINING_AUX_RD_INTERVAL field is 0, the clock recovery * and channel equalization should use 100 us or 400 us AUX read * intervals, respectively * * 2) for DP v1.4 and above, clock recovery should always use 100 us * AUX read intervals
*/
rd_interval = dpcd[DP_TRAINING_AUX_RD_INTERVAL] &
DP_TRAINING_AUX_RD_MASK;
if (rd_interval > 4) {
DRM_DEBUG_KMS("AUX interval %u out of range (max. 4)\n",
rd_interval);
rd_interval = 4;
}
for (i = 0; i < DP_MAX_SUPPORTED_RATES; i++) {
rate = supported_rates[i * 2 + 1] << 8 |
supported_rates[i * 2 + 0];
drm_dp_link_add_rate(link, rate * 200);
}
}
return 0;
}
/** * drm_dp_link_configure() - configure a DisplayPort link * @aux: DisplayPort AUX channel * @link: pointer to a structure containing the link configuration * * Returns 0 on success or a negative error code on failure.
*/ int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link)
{
u8 values[2], value; int err;
if (link->ops && link->ops->configure) {
err = link->ops->configure(link); if (err < 0) {
DRM_ERROR("failed to configure DP link: %d\n", err); return err;
}
}
if (link->caps.alternate_scrambler_reset) {
err = drm_dp_dpcd_writeb(aux, DP_EDP_CONFIGURATION_SET,
DP_ALTERNATE_SCRAMBLER_RESET_ENABLE); if (err < 0) return err;
}
return 0;
}
/** * drm_dp_link_choose() - choose the lowest possible configuration for a mode * @link: DRM DP link object * @mode: DRM display mode * @info: DRM display information * * According to the eDP specification, a source should select a configuration * with the lowest number of lanes and the lowest possible link rate that can * match the bitrate requirements of a video mode. However it must ensure not * to exceed the capabilities of the sink. * * Returns: 0 on success or a negative error code on failure.
*/ int drm_dp_link_choose(struct drm_dp_link *link, conststruct drm_display_mode *mode, conststruct drm_display_info *info)
{ /* available link symbol clock rates */ staticconstunsignedint rates[3] = { 162000, 270000, 540000 }; /* available number of lanes */ staticconstunsignedint lanes[3] = { 1, 2, 4 }; unsignedlong requirement, capacity; unsignedint rate = link->max_rate; unsignedint i, j;
for (i = 0; i < ARRAY_SIZE(lanes) && lanes[i] <= link->max_lanes; i++) { for (j = 0; j < ARRAY_SIZE(rates) && rates[j] <= rate; j++) { /* * Capacity for this combination of lanes and rate, * factoring in the ANSI 8B/10B encoding. * * Link rates in the DRM DP helpers are really link * symbol frequencies, so a tenth of the actual rate * of the link.
*/
capacity = lanes[i] * (rates[j] * 10) * 8 / 10;
err = link->ops->apply_training(link); if (err < 0) {
DRM_ERROR("failed to apply link training: %d\n", err); return err;
}
vs = request->voltage_swing;
pe = request->pre_emphasis;
pc = request->post_cursor;
/* write currently selected voltage-swing and pre-emphasis levels */ for (i = 0; i < lanes; i++)
values[i] = DP_TRAIN_VOLTAGE_SWING_LEVEL(vs[i]) |
DP_TRAIN_PRE_EMPHASIS_LEVEL(pe[i]);
err = drm_dp_dpcd_write(aux, DP_TRAINING_LANE0_SET, values, lanes); if (err < 0) {
DRM_ERROR("failed to set training parameters: %d\n", err); return err;
}
err = drm_dp_link_configure(link->aux, link); if (err < 0) {
DRM_ERROR("failed to configure DP link: %d\n", err); return err;
}
/* transmit training pattern 1 for 500 microseconds */
link->train.pattern = DP_TRAINING_PATTERN_1;
err = drm_dp_link_apply_training(link); if (err < 0) goto out;
usleep_range(500, 1000);
/* transmit training pattern 2 or 3 for 500 microseconds */ if (link->caps.tps3_supported)
link->train.pattern = DP_TRAINING_PATTERN_3; else
link->train.pattern = DP_TRAINING_PATTERN_2;
err = drm_dp_link_apply_training(link); if (err < 0) goto out;
usleep_range(500, 1000);
err = drm_dp_dpcd_read_link_status(link->aux, status); if (err < 0) {
DRM_ERROR("failed to read link status: %d\n", err); goto out;
}
/** * drm_dp_link_train() - perform DisplayPort link training * @link: a DP link object * * Uses the context stored in the DP link object to perform link training. It * is expected that drivers will call drm_dp_link_probe() to obtain the link * capabilities before performing link training. * * If the sink supports fast link training (no AUX CH handshake) and valid * training settings are available, this function will try to perform fast * link training and fall back to full link training on failure. * * Returns: 0 on success or a negative error code on failure.
*/ int drm_dp_link_train(struct drm_dp_link *link)
{ int err;
drm_dp_link_train_init(&link->train);
if (link->caps.fast_training) { if (drm_dp_link_train_valid(&link->train)) {
err = drm_dp_link_train_fast(link); if (err < 0)
DRM_ERROR("fast link training failed: %d\n",
err); else return 0;
} else {
DRM_DEBUG_KMS("training parameters not available\n");
}
} else {
DRM_DEBUG_KMS("fast link training not supported\n");
}
err = drm_dp_link_train_full(link); if (err < 0)
DRM_ERROR("full link training failed: %d\n", err);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.