drivers/gpu/drm/tegra/dp.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/tegra/dp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/tegra/dp.c- Extension
.c- Size
- 20157 bytes
- Lines
- 821
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/string_choices.hdrm/display/drm_dp_helper.hdrm/drm_crtc.hdrm/drm_print.hdp.h
Detected Declarations
function drm_dp_link_caps_resetfunction drm_dp_link_caps_copyfunction drm_dp_link_resetfunction drm_dp_link_add_ratefunction drm_dp_link_remove_ratefunction drm_dp_link_update_ratesfunction drm_dp_link_probefunction drm_dp_link_configurefunction drm_dp_link_choosefunction drm_dp_link_train_initfunction drm_dp_link_train_validfunction drm_dp_link_apply_trainingfunction drm_dp_link_train_waitfunction drm_dp_link_get_adjustmentsfunction drm_dp_link_train_adjustfunction drm_dp_link_recover_clockfunction drm_dp_link_clock_recoveryfunction drm_dp_link_equalize_channelfunction drm_dp_link_channel_equalizationfunction drm_dp_link_downgradefunction drm_dp_link_train_disablefunction drm_dp_link_train_fullfunction drm_dp_link_train_fastfunction drm_dp_link_train
Annotated Snippet
if (err < 0) {
DRM_ERROR("failed to configure DP link: %d\n", err);
return err;
}
}
values[0] = drm_dp_link_rate_to_bw_code(link->rate);
values[1] = link->lanes;
if (link->caps.enhanced_framing)
values[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
err = drm_dp_dpcd_write(aux, DP_LINK_BW_SET, values, sizeof(values));
if (err < 0)
return err;
if (link->caps.channel_coding)
value = DP_SET_ANSI_8B10B;
else
value = 0;
err = drm_dp_dpcd_writeb(aux, DP_MAIN_LINK_CHANNEL_CODING_SET, value);
if (err < 0)
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,
const struct drm_display_mode *mode,
const struct drm_display_info *info)
{
/* available link symbol clock rates */
static const unsigned int rates[3] = { 162000, 270000, 540000 };
/* available number of lanes */
static const unsigned int lanes[3] = { 1, 2, 4 };
unsigned long requirement, capacity;
unsigned int rate = link->max_rate;
unsigned int i, j;
/* bandwidth requirement */
requirement = mode->clock * info->bpc * 3;
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;
if (capacity >= requirement) {
DRM_DEBUG_KMS("using %u lanes at %u kHz (%lu/%lu kbps)\n",
lanes[i], rates[j], requirement,
capacity);
link->lanes = lanes[i];
link->rate = rates[j];
return 0;
}
}
}
return -ERANGE;
}
/**
Annotation
- Immediate include surface: `linux/string_choices.h`, `drm/display/drm_dp_helper.h`, `drm/drm_crtc.h`, `drm/drm_print.h`, `dp.h`.
- Detected declarations: `function drm_dp_link_caps_reset`, `function drm_dp_link_caps_copy`, `function drm_dp_link_reset`, `function drm_dp_link_add_rate`, `function drm_dp_link_remove_rate`, `function drm_dp_link_update_rates`, `function drm_dp_link_probe`, `function drm_dp_link_configure`, `function drm_dp_link_choose`, `function drm_dp_link_train_init`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.