/* * With Single pipe configuration, HW is capable of supporting maximum of: * 2 slices per line for ICL, BMG * 4 slices per line for other platforms. * For now consider a max of 2 slices per line, which works for all platforms. * With this we can have max of 4 DSC Slices per pipe. * * For higher resolutions where 12 slice support is required with * ultrajoiner, only then each pipe can support 3 slices. * * #TODO Split this better to use 4 slices/dsc engine where supported.
*/ staticconst u8 valid_dsc_slicecount[] = {1, 2, 3, 4};
/** * intel_dp_is_edp - is the given port attached to an eDP panel (either CPU or PCH) * @intel_dp: DP struct * * If a CPU or PCH DP output is attached to an eDP panel, this function * will return true, and false otherwise. * * This function is not safe to use prior to encoder type being set.
*/ bool intel_dp_is_edp(struct intel_dp *intel_dp)
{ struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
/* Is link rate UHBR and thus 128b/132b? */ bool intel_dp_is_uhbr(conststruct intel_crtc_state *crtc_state)
{ return drm_dp_is_uhbr_rate(crtc_state->port_clock);
}
/** * intel_dp_link_symbol_size - get the link symbol size for a given link rate * @rate: link rate in 10kbit/s units * * Returns the link symbol size in bits/symbol units depending on the link * rate -> channel coding.
*/ int intel_dp_link_symbol_size(int rate)
{ return drm_dp_is_uhbr_rate(rate) ? 32 : 10;
}
/** * intel_dp_link_symbol_clock - convert link rate to link symbol clock * @rate: link rate in 10kbit/s units * * Returns the link symbol clock frequency in kHz units depending on the * link rate and channel coding.
*/ int intel_dp_link_symbol_clock(int rate)
{ return DIV_ROUND_CLOSEST(rate * 10, intel_dp_link_symbol_size(rate));
}
if (intel_dp_tunnel_bw_alloc_is_enabled(intel_dp))
max_rate = drm_dp_tunnel_max_dprx_rate(intel_dp->tunnel); else
max_rate = drm_dp_bw_code_to_link_rate(intel_dp->dpcd[DP_MAX_LINK_RATE]);
/* * Some broken eDP sinks illegally declare support for * HBR3 without TPS4, and are unable to produce a stable * output. Reject HBR3 when TPS4 is not available.
*/ if (max_rate >= 810000 && !drm_dp_tps4_supported(intel_dp->dpcd)) {
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] Rejecting HBR3 due to missing TPS4 support\n",
encoder->base.base.id, encoder->base.name);
max_rate = 540000;
}
return max_rate;
}
staticint max_dprx_lane_count(struct intel_dp *intel_dp)
{ if (intel_dp_tunnel_bw_alloc_is_enabled(intel_dp)) return drm_dp_tunnel_max_dprx_lane_count(intel_dp->tunnel);
/* * Sink rates for 8b/10b.
*/
max_rate = max_dprx_rate(intel_dp);
max_lttpr_rate = drm_dp_lttpr_max_link_rate(intel_dp->lttpr_common_caps); if (max_lttpr_rate)
max_rate = min(max_rate, max_lttpr_rate);
for (i = 0; i < ARRAY_SIZE(dp_rates); i++) { if (dp_rates[i] > max_rate) break;
intel_dp->sink_rates[i] = dp_rates[i];
}
/* * Sink rates for 128b/132b. If set, sink should support all 8b/10b * rates and 10 Gbps.
*/ if (drm_dp_128b132b_supported(intel_dp->dpcd)) {
u8 uhbr_rates = 0;
drm_err(display->drm, "[CONNECTOR:%d:%s][ENCODER:%d:%s] Invalid DPCD with no link rates, using defaults\n",
connector->base.base.id, connector->base.name,
encoder->base.base.id, encoder->base.name);
switch (intel_dp->max_sink_lane_count) { case 1: case 2: case 4: return;
}
drm_err(display->drm, "[CONNECTOR:%d:%s][ENCODER:%d:%s] Invalid DPCD max lane count (%d), using default\n",
connector->base.base.id, connector->base.name,
encoder->base.base.id, encoder->base.name,
intel_dp->max_sink_lane_count);
/* Get length of rates array potentially limited by max_rate. */ staticint intel_dp_rate_limit_len(constint *rates, int len, int max_rate)
{ int i;
/* Limit results by potentially reduced max rate */ for (i = 0; i < len; i++) { if (rates[len - i - 1] <= max_rate) return len - i;
}
return 0;
}
/* Get length of common rates array potentially limited by max_rate. */ staticint intel_dp_common_len_rate_limit(conststruct intel_dp *intel_dp, int max_rate)
{ return intel_dp_rate_limit_len(intel_dp->common_rates,
intel_dp->num_common_rates, max_rate);
}
int intel_dp_common_rate(struct intel_dp *intel_dp, int index)
{ struct intel_display *display = to_intel_display(intel_dp);
if (drm_WARN_ON(display->drm,
index < 0 || index >= intel_dp->num_common_rates)) return 162000;
return intel_dp->common_rates[index];
}
/* Theoretical max between source and sink */ int intel_dp_max_common_rate(struct intel_dp *intel_dp)
{ return intel_dp_common_rate(intel_dp, intel_dp->num_common_rates - 1);
}
int intel_dp_max_source_lane_count(struct intel_digital_port *dig_port)
{ int vbt_max_lanes = intel_bios_dp_max_lane_count(dig_port->base.devdata); int max_lanes = dig_port->max_lanes;
if (vbt_max_lanes)
max_lanes = min(max_lanes, vbt_max_lanes);
return max_lanes;
}
/* Theoretical max between source and sink */ int intel_dp_max_common_lane_count(struct intel_dp *intel_dp)
{ struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); int source_max = intel_dp_max_source_lane_count(dig_port); int sink_max = intel_dp->max_sink_lane_count; int lane_max = intel_tc_port_max_lane_count(dig_port); int lttpr_max = drm_dp_lttpr_max_lane_count(intel_dp->lttpr_common_caps);
if (lttpr_max)
sink_max = min(sink_max, lttpr_max);
int intel_dp_max_lane_count(struct intel_dp *intel_dp)
{ int lane_count;
if (intel_dp->link.force_lane_count)
lane_count = forced_lane_count(intel_dp); else
lane_count = intel_dp->link.max_lane_count;
switch (lane_count) { case 1: case 2: case 4: return lane_count; default:
MISSING_CASE(lane_count); return 1;
}
}
staticint intel_dp_min_lane_count(struct intel_dp *intel_dp)
{ if (intel_dp->link.force_lane_count) return forced_lane_count(intel_dp);
return 1;
}
/* * The required data bandwidth for a mode with given pixel clock and bpp. This * is the required net bandwidth independent of the data bandwidth efficiency. * * TODO: check if callers of this functions should use * intel_dp_effective_data_rate() instead.
*/ int
intel_dp_link_required(int pixel_clock, int bpp)
{ /* pixel_clock is in kHz, divide bpp by 8 for bit to Byte conversion */ return DIV_ROUND_UP(pixel_clock * bpp, 8);
}
/** * intel_dp_effective_data_rate - Return the pixel data rate accounting for BW allocation overhead * @pixel_clock: pixel clock in kHz * @bpp_x16: bits per pixel .4 fixed point format * @bw_overhead: BW allocation overhead in 1ppm units * * Return the effective pixel data rate in kB/sec units taking into account * the provided SSC, FEC, DSC BW allocation overhead.
*/ int intel_dp_effective_data_rate(int pixel_clock, int bpp_x16, int bw_overhead)
{ return DIV_ROUND_UP_ULL(mul_u32_u32(pixel_clock * bpp_x16, bw_overhead),
1000000 * 16 * 8);
}
/** * intel_dp_max_link_data_rate: Calculate the maximum rate for the given link params * @intel_dp: Intel DP object * @max_dprx_rate: Maximum data rate of the DPRX * @max_dprx_lanes: Maximum lane count of the DPRX * * Calculate the maximum data rate for the provided link parameters taking into * account any BW limitations by a DP tunnel attached to @intel_dp. * * Returns the maximum data rate in kBps units.
*/ int intel_dp_max_link_data_rate(struct intel_dp *intel_dp, int max_dprx_rate, int max_dprx_lanes)
{ int max_rate = drm_dp_max_dprx_data_rate(max_dprx_rate, max_dprx_lanes);
if (intel_dp_tunnel_bw_alloc_is_enabled(intel_dp))
max_rate = min(max_rate,
drm_dp_tunnel_available_bw(intel_dp->tunnel));
int intel_dp_link_config_index(struct intel_dp *intel_dp, int link_rate, int lane_count)
{ int link_rate_idx = intel_dp_rate_index(intel_dp->common_rates, intel_dp->num_common_rates,
link_rate); int lane_count_exp = ilog2(lane_count); int i;
for (i = 0; i < intel_dp->link.num_configs; i++) { conststruct intel_dp_link_config *lc = &intel_dp->link.configs[i];
/* Paranoia, there should always be something in common. */ if (drm_WARN_ON(display->drm, intel_dp->num_common_rates == 0)) {
intel_dp->common_rates[0] = 162000;
intel_dp->num_common_rates = 1;
}
intel_dp_link_config_init(intel_dp);
}
bool intel_dp_link_params_valid(struct intel_dp *intel_dp, int link_rate,
u8 lane_count)
{ /* * FIXME: we need to synchronize the current link parameters with * hardware readout. Currently fast link training doesn't work on * boot-up.
*/ if (link_rate == 0 ||
link_rate > intel_dp->link.max_rate) returnfalse;
if (lane_count == 0 ||
lane_count > intel_dp_max_lane_count(intel_dp)) returnfalse;
int intel_dp_bw_fec_overhead(bool fec_enabled)
{ /* * TODO: Calculate the actual overhead for a given mode. * The hard-coded 1/0.972261=2.853% overhead factor * corresponds (for instance) to the 8b/10b DP FEC 2.4% + * 0.453% DSC overhead. This is enough for a 3840 width mode, * which has a DSC overhead of up to ~0.2%, but may not be * enough for a 1024 width mode where this is ~0.8% (on a 4 * lane DP link, with 2 DSC slices and 8 bpp color depth).
*/ return fec_enabled ? DP_DSC_FEC_OVERHEAD_FACTOR : 1000000;
}
/* Error out if the max bpp is less than smallest allowed valid bpp */ if (bits_per_pixel < valid_dsc_bpp[0]) {
drm_dbg_kms(display->drm, "Unsupported BPP %u, min %u\n",
bits_per_pixel, valid_dsc_bpp[0]); return 0;
}
/* From XE_LPD onwards we support from bpc upto uncompressed bpp-1 BPPs */ if (DISPLAY_VER(display) >= 13) {
bits_per_pixel = min(bits_per_pixel, pipe_bpp - 1);
/* * According to BSpec, 27 is the max DSC output bpp, * 8 is the min DSC output bpp. * While we can still clamp higher bpp values to 27, saving bandwidth, * if it is required to oompress up to bpp < 8, means we can't do * that and probably means we can't fit the required mode, even with * DSC enabled.
*/ if (bits_per_pixel < 8) {
drm_dbg_kms(display->drm, "Unsupported BPP %u, min 8\n",
bits_per_pixel); return 0;
}
bits_per_pixel = min_t(u32, bits_per_pixel, 27);
} else { /* Find the nearest match in the array of known BPPs from VESA */ for (i = 0; i < ARRAY_SIZE(valid_dsc_bpp) - 1; i++) { if (bits_per_pixel < valid_dsc_bpp[i + 1]) break;
}
drm_dbg_kms(display->drm, "Set dsc bpp from %d to VESA %d\n",
bits_per_pixel, valid_dsc_bpp[i]);
static u32 bigjoiner_bw_max_bpp(struct intel_display *display, u32 mode_clock, int num_joined_pipes)
{
u32 max_bpp; /* With bigjoiner multiple dsc engines are used in parallel so PPC is 2 */ int ppc = 2; int num_big_joiners = num_joined_pipes / 2;
/* * Available Link Bandwidth(Kbits/sec) = (NumberOfLanes)* * (LinkSymbolClock)* 8 * (TimeSlots / 64) * for SST -> TimeSlots is 64(i.e all TimeSlots that are available) * for MST -> TimeSlots has to be calculated, based on mode requirements * * Due to FEC overhead, the available bw is reduced to 97.2261%. * To support the given mode: * Bandwidth required should be <= Available link Bandwidth * FEC Overhead * =>ModeClock * bits_per_pixel <= Available Link Bandwidth * FEC Overhead * =>bits_per_pixel <= Available link Bandwidth * FEC Overhead / ModeClock * =>bits_per_pixel <= (NumberOfLanes * LinkSymbolClock) * 8 (TimeSlots / 64) / * (ModeClock / FEC Overhead) * =>bits_per_pixel <= (NumberOfLanes * LinkSymbolClock * TimeSlots) / * (ModeClock / FEC Overhead * 8)
*/
bits_per_pixel = ((link_clock * lane_count) * timeslots) /
(intel_dp_mode_to_fec_clock(mode_clock) * 8);
/* Bandwidth required for 420 is half, that of 444 format */ if (output_format == INTEL_OUTPUT_FORMAT_YCBCR420)
bits_per_pixel *= 2;
/* * According to DSC 1.2a Section 4.1.1 Table 4.1 the maximum * supported PPS value can be 63.9375 and with the further * mention that for 420, 422 formats, bpp should be programmed double * the target bpp restricting our target bpp to be 31.9375 at max.
*/ if (output_format == INTEL_OUTPUT_FORMAT_YCBCR420)
bits_per_pixel = min_t(u32, bits_per_pixel, 31);
drm_dbg_kms(display->drm, "Max link bpp is %u for %u timeslots " "total bw %u pixel clock %u\n",
bits_per_pixel, timeslots,
(link_clock * lane_count * 8),
intel_dp_mode_to_fec_clock(mode_clock));
/* * Due to some DSC engine BW limitations, we need to enable second * slice and VDSC engine, whenever we approach close enough to max CDCLK
*/ if (mode_clock >= ((display->cdclk.max_cdclk_freq * 85) / 100))
min_slice_count = max_t(u8, min_slice_count, 2);
max_slice_width = drm_dp_dsc_sink_max_slice_width(connector->dp.dsc_dpcd); if (max_slice_width < DP_DSC_MIN_SLICE_WIDTH_VALUE) {
drm_dbg_kms(display->drm, "Unsupported slice width %d by DP DSC Sink device\n",
max_slice_width); return 0;
} /* Also take into account max slice width */
min_slice_count = max_t(u8, min_slice_count,
DIV_ROUND_UP(mode_hdisplay,
max_slice_width));
/* Find the closest match to the valid slice count values */ for (i = 0; i < ARRAY_SIZE(valid_dsc_slicecount); i++) {
u8 test_slice_count = valid_dsc_slicecount[i] * num_joined_pipes;
/* * 3 DSC Slices per pipe need 3 DSC engines, which is supported only * with Ultrajoiner only for some platforms.
*/ if (valid_dsc_slicecount[i] == 3 &&
(!HAS_DSC_3ENGINES(display) || num_joined_pipes != 4)) continue;
if (test_slice_count >
drm_dp_dsc_sink_max_slice_count(connector->dp.dsc_dpcd, false)) break;
/* * Bigjoiner needs small joiner to be enabled. * So there should be at least 2 dsc slices per pipe, * whenever bigjoiner is enabled.
*/ if (num_joined_pipes > 1 && valid_dsc_slicecount[i] < 2) continue;
if (mode_hdisplay % test_slice_count) continue;
if (min_slice_count <= test_slice_count) return test_slice_count;
}
switch (format) { case INTEL_OUTPUT_FORMAT_RGB: returntrue;
case INTEL_OUTPUT_FORMAT_YCBCR444: /* * No YCbCr output support on gmch platforms. * Also, ILK doesn't seem capable of DP YCbCr output. * The displayed image is severely corrupted. SNB+ is fine.
*/ return !HAS_GMCH(display) && !display->platform.ironlake;
case INTEL_OUTPUT_FORMAT_YCBCR420: /* Platform < Gen 11 cannot output YCbCr420 format */ return DISPLAY_VER(display) >= 11;
int intel_dp_min_bpp(enum intel_output_format output_format)
{ if (output_format == INTEL_OUTPUT_FORMAT_RGB) return intel_display_min_pipe_bpp(); else return 8 * 3;
}
int intel_dp_output_bpp(enum intel_output_format output_format, int bpp)
{ /* * bpp value was assumed to RGB format. And YCbCr 4:2:0 output * format of the number of bytes per pixel will be half the number * of bytes of RGB pixel.
*/ if (output_format == INTEL_OUTPUT_FORMAT_YCBCR420)
bpp /= 2;
staticbool intel_dp_hdisplay_bad(struct intel_display *display, int hdisplay)
{ /* * Older platforms don't like hdisplay==4096 with DP. * * On ILK/SNB/IVB the pipe seems to be somewhat running (scanline * and frame counter increment), but we don't get vblank interrupts, * and the pipe underruns immediately. The link also doesn't seem * to get trained properly. * * On CHV the vblank interrupts don't seem to disappear but * otherwise the symptoms are similar. * * TODO: confirm the behaviour on HSW+
*/ return hdisplay == 4096 && !HAS_DDI(display);
}
/* Only consider the sink's max TMDS clock if we know this is a HDMI DFP */ if (max_tmds_clock && info->max_tmds_clock)
max_tmds_clock = min(max_tmds_clock, info->max_tmds_clock);
return max_tmds_clock;
}
staticenum drm_mode_status
intel_dp_tmds_clock_valid(struct intel_dp *intel_dp, int clock, int bpc, enum intel_output_format sink_format, bool respect_downstream_limits)
{ int tmds_clock, min_tmds_clock, max_tmds_clock;
/* If PCON supports FRL MODE, check FRL bandwidth constraints */ if (intel_dp->dfp.pcon_max_frl_bw) { int target_bw; int max_frl_bw; int bpp = intel_dp_mode_min_output_bpp(connector, mode);
target_bw = bpp * target_clock;
max_frl_bw = intel_dp->dfp.pcon_max_frl_bw;
/* converting bw from Gbps to Kbps*/
max_frl_bw = max_frl_bw * 1000000;
if (target_bw > max_frl_bw) return MODE_CLOCK_HIGH;
return MODE_OK;
}
if (intel_dp->dfp.max_dotclock &&
target_clock > intel_dp->dfp.max_dotclock) return MODE_CLOCK_HIGH;
if (intel_dp_has_dsc(connector)) { enum intel_output_format sink_format, output_format; int pipe_bpp;
sink_format = intel_dp_sink_format(connector, mode);
output_format = intel_dp_output_format(connector, sink_format); /* * TBD pass the connector BPC, * for now U8_MAX so that max BPC on that platform would be picked
*/
pipe_bpp = intel_dp_dsc_compute_max_bpp(connector, U8_MAX);
/* * Output bpp is stored in 6.4 format so right shift by 4 to get the * integer value since we support only integer values of bpp.
*/ if (intel_dp_is_edp(intel_dp)) {
dsc_max_compressed_bpp =
drm_edp_dsc_sink_output_bpp(connector->dp.dsc_dpcd) >> 4;
dsc_slice_count =
drm_dp_dsc_sink_max_slice_count(connector->dp.dsc_dpcd, true);
} elseif (drm_dp_sink_supports_fec(connector->dp.fec_capability)) {
dsc_max_compressed_bpp =
intel_dp_dsc_get_max_compressed_bpp(display,
max_link_clock,
max_lanes,
target_clock,
mode->hdisplay,
num_joined_pipes,
output_format,
pipe_bpp, 64);
dsc_slice_count =
intel_dp_dsc_get_slice_count(connector,
target_clock,
mode->hdisplay,
num_joined_pipes);
}
staticint forced_link_rate(struct intel_dp *intel_dp)
{ int len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->link.force_rate);
if (len == 0) return intel_dp_common_rate(intel_dp, 0);
return intel_dp_common_rate(intel_dp, len - 1);
}
int
intel_dp_max_link_rate(struct intel_dp *intel_dp)
{ int len;
if (intel_dp->link.force_rate) return forced_link_rate(intel_dp);
len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->link.max_rate);
return intel_dp_common_rate(intel_dp, len - 1);
}
staticint
intel_dp_min_link_rate(struct intel_dp *intel_dp)
{ if (intel_dp->link.force_rate) return forced_link_rate(intel_dp);
return intel_dp_common_rate(intel_dp, 0);
}
int intel_dp_rate_select(struct intel_dp *intel_dp, int rate)
{ struct intel_display *display = to_intel_display(intel_dp); int i = intel_dp_rate_index(intel_dp->sink_rates,
intel_dp->num_sink_rates, rate);
if (intel_crtc_has_type(crtc_state, INTEL_OUTPUT_DP) &&
!intel_dp_supports_fec(intel_dp, connector, crtc_state)) returnfalse;
return intel_dsc_source_support(crtc_state);
}
staticint intel_dp_hdmi_compute_bpc(struct intel_dp *intel_dp, conststruct intel_crtc_state *crtc_state, int bpc, bool respect_downstream_limits)
{ int clock = crtc_state->hw.adjusted_mode.crtc_clock;
/* * Current bpc could already be below 8bpc due to * FDI bandwidth constraints or other limits. * HDMI minimum is 8bpc however.
*/
bpc = max(bpc, 8);
/* * We will never exceed downstream TMDS clock limits while * attempting deep color. If the user insists on forcing an * out of spec mode they will have to be satisfied with 8bpc.
*/ if (!respect_downstream_limits)
bpc = 8;
bpp = bpc * 3; if (intel_dp_is_edp(intel_dp)) { /* Get bpp from vbt only for panels that dont have bpp in edid */ if (connector->base.display_info.bpc == 0 &&
connector->panel.vbt.edp.bpp &&
connector->panel.vbt.edp.bpp < bpp) {
drm_dbg_kms(display->drm, "clamping bpp for eDP panel to BIOS-provided %i\n",
connector->panel.vbt.edp.bpp);
bpp = connector->panel.vbt.edp.bpp;
}
}
/* FIXME a bit of a mess wrt clock vs. crtc_clock */ if (has_seamless_m_n(connector)) return intel_panel_highest_mode(connector, adjusted_mode)->clock; else return adjusted_mode->crtc_clock;
}
/* Optimize link config in order: max bpp, min clock, min lanes */ staticint
intel_dp_compute_link_config_wide(struct intel_dp *intel_dp, struct intel_crtc_state *pipe_config, conststruct drm_connector_state *conn_state, conststruct link_config_limits *limits)
{ int bpp, i, lane_count, clock = intel_dp_mode_clock(pipe_config, conn_state); int mode_rate, link_rate, link_avail;
for (bpp = fxp_q4_to_int(limits->link.max_bpp_x16);
bpp >= fxp_q4_to_int(limits->link.min_bpp_x16);
bpp -= 2 * 3) { int link_bpp = intel_dp_output_bpp(pipe_config->output_format, bpp);
int intel_dp_dsc_max_src_input_bpc(struct intel_display *display)
{ /* Max DSC Input BPC for ICL is 10 and for TGL+ is 12 */ if (DISPLAY_VER(display) >= 12) return 12; if (DISPLAY_VER(display) == 11) return 10;
return intel_dp_dsc_min_src_input_bpc();
}
int intel_dp_dsc_compute_max_bpp(conststruct intel_connector *connector,
u8 max_req_bpc)
{ struct intel_display *display = to_intel_display(connector); int i, num_bpc;
u8 dsc_bpc[3] = {}; int dsc_max_bpc;
staticint intel_dp_get_slice_height(int vactive)
{ int slice_height;
/* * VDSC 1.2a spec in Section 3.8 Options for Slices implies that 108 * lines is an optimal slice height, but any size can be used as long as * vertical active integer multiple and maximum vertical slice count * requirements are met.
*/ for (slice_height = 108; slice_height <= vactive; slice_height += 2) if (vactive % slice_height == 0) return slice_height;
/* * Highly unlikely we reach here as most of the resolutions will end up * finding appropriate slice_height in above loop but returning * slice_height as 2 here as it should work with all resolutions.
*/ return 2;
}
/* * RC_MODEL_SIZE is currently a constant across all configurations. * * FIXME: Look into using sink defined DPCD DP_DSC_RC_BUF_BLK_SIZE and * DP_DSC_RC_BUF_SIZE for this.
*/
vdsc_cfg->rc_model_size = DSC_RC_MODEL_SIZE_CONST;
vdsc_cfg->pic_height = crtc_state->hw.adjusted_mode.crtc_vdisplay;
/* * FIXME: intel_dp_mtp_tu_compute_config() requires * ->lane_count and ->port_clock set before we know * they'll work. If we end up failing altogether, * they'll remain in crtc state. This shouldn't matter, * as we'd then bail out from compute config, but it's * just ugly.
*/
pipe_config->lane_count = lane_count;
pipe_config->port_clock = link_rate;
if (drm_dp_is_uhbr_rate(link_rate)) { int ret;
ret = intel_dp_mtp_tu_compute_config(intel_dp,
pipe_config,
conn_state,
dsc_bpp_x16,
dsc_bpp_x16,
0, true); if (ret) continue;
} else { if (!is_bw_sufficient_for_dsc_config(dsc_bpp_x16, link_rate,
lane_count, adjusted_mode->clock,
pipe_config->output_format,
timeslots)) continue;
}
if (max_bppx16) return max_bppx16; /* * If support not given in DPCD 67h, 68h use the Maximum Allowed bit rate * values as given in spec Table 2-157 DP v2.0
*/ switch (pipe_config->output_format) { case INTEL_OUTPUT_FORMAT_RGB: case INTEL_OUTPUT_FORMAT_YCBCR444: return (3 * bpc) << 4; case INTEL_OUTPUT_FORMAT_YCBCR420: return (3 * (bpc / 2)) << 4; default:
MISSING_CASE(pipe_config->output_format); break;
}
return 0;
}
int intel_dp_dsc_sink_min_compressed_bpp(conststruct intel_crtc_state *pipe_config)
{ /* From Mandatory bit rate range Support Table 2-157 (DP v2.0) */ switch (pipe_config->output_format) { case INTEL_OUTPUT_FORMAT_RGB: case INTEL_OUTPUT_FORMAT_YCBCR444: return 8; case INTEL_OUTPUT_FORMAT_YCBCR420: return 6; default:
MISSING_CASE(pipe_config->output_format); break;
}
return 0;
}
int intel_dp_dsc_sink_max_compressed_bpp(conststruct intel_connector *connector, conststruct intel_crtc_state *pipe_config, int bpc)
{ return intel_dp_dsc_max_sink_compressed_bppx16(connector,
pipe_config, bpc) >> 4;
}
int intel_dp_dsc_min_src_compressed_bpp(void)
{ /* Min Compressed bpp supported by source is 8 */ return 8;
}
/* * Forcing DSC and using the platform's max compressed bpp is seen to cause * underruns. Since DSC isn't needed in these cases, limit the * max compressed bpp to 18, which is a safe value across platforms with different * pipe bpps.
*/ if (intel_dp->force_dsc_en) return 18;
/* * Max Compressed bpp for Gen 13+ is 27bpp. * For earlier platform is 23bpp. (Bspec:49259).
*/ if (DISPLAY_VER(display) < 13) return 23; else return 27;
}
/* * Note: for pre-13 display you still need to check the validity of each step.
*/ int intel_dp_dsc_bpp_step_x16(conststruct intel_connector *connector)
{ struct intel_display *display = to_intel_display(connector);
u8 incr = drm_dp_dsc_sink_bpp_incr(connector->dp.dsc_dpcd);
if (DISPLAY_VER(display) < 14 || !incr) return fxp_q4_from_int(1);
if (connector->mst.dp &&
!connector->link.force_bpp_x16 && !connector->mst.dp->force_dsc_fractional_bpp_en) return fxp_q4_from_int(1);
/* fxp q4 */ return fxp_q4_from_int(1) / incr;
}
/* * Note: for bpp_x16 to be valid it must be also within the source/sink's * min..max bpp capability range.
*/ bool intel_dp_dsc_valid_compressed_bpp(struct intel_dp *intel_dp, int bpp_x16)
{ struct intel_display *display = to_intel_display(intel_dp); int i;
if (DISPLAY_VER(display) >= 13) { if (intel_dp->force_dsc_fractional_bpp_en && !fxp_q4_to_frac(bpp_x16)) returnfalse;
returntrue;
}
if (fxp_q4_to_frac(bpp_x16)) returnfalse;
for (i = 0; i < ARRAY_SIZE(valid_dsc_bpp); i++) { if (fxp_q4_to_int(bpp_x16) == valid_dsc_bpp[i]) returntrue;
}
returnfalse;
}
/* * Find the max compressed BPP we can find a link configuration for. The BPPs to * try depend on the source (platform) and sink.
*/ staticint dsc_compute_compressed_bpp(struct intel_dp *intel_dp, struct intel_crtc_state *pipe_config, struct drm_connector_state *conn_state, conststruct link_config_limits *limits, int pipe_bpp, int timeslots)
{ struct intel_display *display = to_intel_display(intel_dp); conststruct intel_connector *connector = to_intel_connector(conn_state->connector); conststruct drm_display_mode *adjusted_mode = &pipe_config->hw.adjusted_mode; int output_bpp; int min_bpp_x16, max_bpp_x16, bpp_step_x16; int dsc_joiner_max_bpp; int num_joined_pipes = intel_crtc_num_joined_pipes(pipe_config); int bpp_x16; int ret;
/* Compressed BPP should be less than the Input DSC bpp */
output_bpp = intel_dp_output_bpp(pipe_config->output_format, pipe_bpp);
max_bpp_x16 = min(max_bpp_x16, fxp_q4_from_int(output_bpp) - bpp_step_x16);
if (forced_bpp) {
ret = dsc_compute_compressed_bpp(intel_dp, pipe_config, conn_state,
limits, forced_bpp, timeslots); if (ret == 0) {
pipe_config->pipe_bpp = forced_bpp; return 0;
}
}
/* * Get the maximum DSC bpc that will be supported by any valid * link configuration and compressed bpp.
*/
num_bpc = drm_dp_dsc_sink_supported_input_bpcs(connector->dp.dsc_dpcd, dsc_bpc); for (i = 0; i < num_bpc; i++) {
pipe_bpp = dsc_bpc[i] * 3; if (pipe_bpp < limits->pipe.min_bpp || pipe_bpp > limits->pipe.max_bpp) continue;
ret = dsc_compute_compressed_bpp(intel_dp, pipe_config, conn_state,
limits, pipe_bpp, timeslots); if (ret == 0) {
pipe_config->pipe_bpp = pipe_bpp; return 0;
}
}
if (forced_bpp) {
pipe_bpp = forced_bpp;
} else { int max_bpc = limits->pipe.max_bpp / 3;
/* For eDP use max bpp that can be supported with DSC. */
pipe_bpp = intel_dp_dsc_compute_max_bpp(connector, max_bpc); if (!is_dsc_pipe_bpp_sufficient(limits, pipe_bpp)) {
drm_dbg_kms(display->drm, "Computed BPC is not in DSC BPC limits\n"); return -EINVAL;
}
}
pipe_config->port_clock = limits->max_rate;
pipe_config->lane_count = limits->max_lane_count;
/* * Though eDP v1.5 supports FEC with DSC, unlike DP, it is optional. * Since, FEC is a bandwidth overhead, continue to not enable it for * eDP. Until, there is a good reason to do so.
*/ if (intel_dp_is_edp(intel_dp)) return;
if (!intel_dp_dsc_supports_format(connector, pipe_config->output_format)) return -EINVAL;
/* * Link parameters, pipe bpp and compressed bpp have already been * figured out for DP MST DSC.
*/ if (!is_mst) { if (intel_dp_is_edp(intel_dp))
ret = intel_edp_dsc_compute_pipe_bpp(intel_dp, pipe_config,
conn_state, limits); else
ret = intel_dp_dsc_compute_pipe_bpp(intel_dp, pipe_config,
conn_state, limits, timeslots); if (ret) {
drm_dbg_kms(display->drm, "No Valid pipe bpp for given mode ret = %d\n", ret); return ret;
}
}
dsc_dp_slice_count =
intel_dp_dsc_get_slice_count(connector,
adjusted_mode->crtc_clock,
adjusted_mode->crtc_hdisplay,
num_joined_pipes); if (!dsc_dp_slice_count) {
drm_dbg_kms(display->drm, "Compressed Slice Count not supported\n"); return -EINVAL;
}
pipe_config->dsc.slice_count = dsc_dp_slice_count;
} /* * VDSC engine operates at 1 Pixel per clock, so if peak pixel rate * is greater than the maximum Cdclock and if slice count is even * then we need to use 2 VDSC instances. * In case of Ultrajoiner along with 12 slices we need to use 3 * VDSC instances.
*/ if (pipe_config->joiner_pipes && num_joined_pipes == 4 &&
pipe_config->dsc.slice_count == 12)
pipe_config->dsc.num_streams = 3; elseif (pipe_config->joiner_pipes || pipe_config->dsc.slice_count > 1)
pipe_config->dsc.num_streams = 2; else
pipe_config->dsc.num_streams = 1;
limits->pipe.min_bpp = intel_dp_min_bpp(crtc_state->output_format); if (is_mst) { /* * FIXME: If all the streams can't fit into the link with their * current pipe_bpp we should reduce pipe_bpp across the board * until things start to fit. Until then we limit to <= 8bpc * since that's what was hardcoded for all MST streams * previously. This hack should be removed once we have the * proper retry logic in place.
*/
limits->pipe.max_bpp = min(crtc_state->pipe_bpp, 24);
} else {
limits->pipe.max_bpp = intel_dp_max_bpp(intel_dp, crtc_state,
respect_downstream_limits);
}
if (dsc)
intel_dp_dsc_compute_pipe_bpp_limits(intel_dp, limits);
if (is_mst || intel_dp->use_max_params) { /* * For MST we always configure max link bw - the spec doesn't * seem to suggest we should do otherwise. * * Use the maximum clock and number of lanes the eDP panel * advertizes being capable of in case the initial fast * optimal params failed us. The panels are generally * designed to support only a single clock and lane * configuration, and typically on older panels these * values correspond to the native resolution of the panel.
*/
limits->min_lane_count = limits->max_lane_count;
limits->min_rate = limits->max_rate;
}
if (!dsc_needed) { /* * Optimize for slow and wide for everything, because there are some * eDP 1.3 and 1.4 panels don't work well with fast and narrow.
*/
ret = intel_dp_compute_link_config_wide(intel_dp, pipe_config,
conn_state, &limits); if (!ret && intel_dp_is_uhbr(pipe_config))
ret = intel_dp_mtp_tu_compute_config(intel_dp,
pipe_config,
conn_state,
fxp_q4_from_int(pipe_config->pipe_bpp),
fxp_q4_from_int(pipe_config->pipe_bpp),
0, false); if (ret)
dsc_needed = true;
}
if (dsc_needed && !intel_dp_supports_dsc(intel_dp, connector, pipe_config)) {
drm_dbg_kms(display->drm, "DSC required but not available\n"); return -EINVAL;
}
/* * Our YCbCr output is always limited range. * crtc_state->limited_color_range only applies to RGB, * and it must never be set for YCbCr or we risk setting * some conflicting bits in TRANSCONF which will mess up * the colors on the monitor.
*/ if (crtc_state->output_format != INTEL_OUTPUT_FORMAT_RGB) returnfalse;
staticbool intel_dp_port_has_audio(struct intel_display *display, enum port port)
{ if (display->platform.g4x) returnfalse; if (DISPLAY_VER(display) < 12 && port == PORT_A) returnfalse;
if (crtc_state->has_panel_replay) { /* * Prepare VSC Header for SU as per DP 2.0 spec, Table 2-223 * VSC SDP supporting 3D stereo, Panel Replay, and Pixel * Encoding/Colorimetry Format indication.
*/
vsc->revision = 0x7;
} else { /* * Prepare VSC Header for SU as per DP 1.4 spec, Table 2-118 * VSC SDP supporting 3D stereo, PSR2, and Pixel Encoding/ * Colorimetry Format indication.
*/
vsc->revision = 0x5;
}
vsc->length = 0x13;
/* DP 1.4a spec, Table 2-120 */ switch (crtc_state->output_format) { case INTEL_OUTPUT_FORMAT_YCBCR444:
vsc->pixelformat = DP_PIXELFORMAT_YUV444; break; case INTEL_OUTPUT_FORMAT_YCBCR420:
vsc->pixelformat = DP_PIXELFORMAT_YUV420; break; case INTEL_OUTPUT_FORMAT_RGB: default:
vsc->pixelformat = DP_PIXELFORMAT_RGB;
}
switch (conn_state->colorspace) { case DRM_MODE_COLORIMETRY_BT709_YCC:
vsc->colorimetry = DP_COLORIMETRY_BT709_YCC; break; case DRM_MODE_COLORIMETRY_XVYCC_601:
vsc->colorimetry = DP_COLORIMETRY_XVYCC_601; break; case DRM_MODE_COLORIMETRY_XVYCC_709:
vsc->colorimetry = DP_COLORIMETRY_XVYCC_709; break; case DRM_MODE_COLORIMETRY_SYCC_601:
vsc->colorimetry = DP_COLORIMETRY_SYCC_601; break; case DRM_MODE_COLORIMETRY_OPYCC_601:
vsc->colorimetry = DP_COLORIMETRY_OPYCC_601; break; case DRM_MODE_COLORIMETRY_BT2020_CYCC:
vsc->colorimetry = DP_COLORIMETRY_BT2020_CYCC; break; case DRM_MODE_COLORIMETRY_BT2020_RGB:
vsc->colorimetry = DP_COLORIMETRY_BT2020_RGB; break; case DRM_MODE_COLORIMETRY_BT2020_YCC:
vsc->colorimetry = DP_COLORIMETRY_BT2020_YCC; break; case DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65: case DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER:
vsc->colorimetry = DP_COLORIMETRY_DCI_P3_RGB; break; default: /* * RGB->YCBCR color conversion uses the BT.709 * color space.
*/ if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420)
vsc->colorimetry = DP_COLORIMETRY_BT709_YCC; else
vsc->colorimetry = DP_COLORIMETRY_DEFAULT; break;
}
/* * DRRS and PSR can't be enable together, so giving preference to PSR * as it allows more power-savings by complete shutting down display, * so to guarantee this, intel_drrs_compute_config() must be called * after intel_psr_compute_config().
*/ if (pipe_config->has_psr) returnfalse;
/* FIXME missing FDI M2/N2 etc. */ if (pipe_config->has_pch_encoder) returnfalse;
if (!intel_cpu_transcoder_has_drrs(display, pipe_config->cpu_transcoder)) returnfalse;
/* * FIXME all joined pipes share the same transcoder. * Need to account for that when updating M/N live.
*/ if (has_seamless_m_n(connector) && !pipe_config->joiner_pipes)
pipe_config->update_m_n = true;
if (!can_enable_drrs(connector, pipe_config, downclock_mode)) { if (intel_cpu_transcoder_has_m2_n2(display, pipe_config->cpu_transcoder))
intel_zero_m_n(&pipe_config->dp_m2_n2); return;
}
if (display->platform.ironlake || display->platform.sandybridge ||
display->platform.ivybridge)
pipe_config->msa_timing_delay = connector->panel.vbt.edp.drrs_msa_timing_delay;
pipe_config->has_drrs = true;
pixel_clock = downclock_mode->clock; if (pipe_config->splitter.enable)
pixel_clock /= pipe_config->splitter.link_count;
fixed_mode = intel_panel_fixed_mode(connector, adjusted_mode); if (intel_dp_is_edp(intel_dp) && fixed_mode) {
ret = intel_panel_compute_config(connector, adjusted_mode); if (ret) return ret;
}
if (adjusted_mode->flags & DRM_MODE_FLAG_DBLSCAN) return -EINVAL;
if (!connector->base.interlace_allowed &&
adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) return -EINVAL;
if (adjusted_mode->flags & DRM_MODE_FLAG_DBLCLK) return -EINVAL;
if (intel_dp_hdisplay_bad(display, adjusted_mode->crtc_hdisplay)) return -EINVAL;
/* * Try to respect downstream TMDS clock limits first, if * that fails assume the user might know something we don't.
*/
ret = intel_dp_compute_output_format(encoder, pipe_config, conn_state, true); if (ret)
ret = intel_dp_compute_output_format(encoder, pipe_config, conn_state, false); if (ret) return ret;
if ((intel_dp_is_edp(intel_dp) && fixed_mode) ||
pipe_config->output_format == INTEL_OUTPUT_FORMAT_YCBCR420) {
ret = intel_pfit_compute_config(pipe_config, conn_state); if (ret) return ret;
}
staticbool downstream_hpd_needs_d0(struct intel_dp *intel_dp)
{ /* * DPCD 1.2+ should support BRANCH_DEVICE_CTRL, and thus * be capable of signalling downstream hpd with a long pulse. * Whether or not that means D3 is safe to use is not clear, * but let's assume so until proven otherwise. * * FIXME should really check all downstream ports...
*/ return intel_dp->dpcd[DP_DPCD_REV] == 0x11 &&
drm_dp_is_branch(intel_dp->dpcd) &&
intel_dp->downstream_ports[0] & DP_DS_PORT_HPD;
}
/* * On SST the decompression AUX device won't be shared, each connector * uses for this its own AUX targeting the sink device.
*/ if (!connector->mst.dp) return connector->dp.dsc_decompression_enabled ? 1 : 0;
/** * intel_dp_sink_enable_decompression - Enable DSC decompression in sink/last branch device * @state: atomic state * @connector: connector to enable the decompression for * @new_crtc_state: new state for the CRTC driving @connector * * Enable the DSC decompression if required in the %DP_DSC_ENABLE DPCD * register of the appropriate sink/branch device. On SST this is always the * sink device, whereas on MST based on each device's DSC capabilities it's * either the last branch device (enabling decompression in it) or both the * last branch device (enabling passthrough in it) and the sink device * (enabling decompression in it).
*/ void intel_dp_sink_enable_decompression(struct intel_atomic_state *state, struct intel_connector *connector, conststruct intel_crtc_state *new_crtc_state)
{ struct intel_display *display = to_intel_display(state);
if (!new_crtc_state->dsc.compression_enable) return;
if (drm_WARN_ON(display->drm,
!connector->dp.dsc_decompression_aux ||
connector->dp.dsc_decompression_enabled)) return;
if (!intel_dp_dsc_aux_get_ref(state, connector)) return;
/** * intel_dp_sink_disable_decompression - Disable DSC decompression in sink/last branch device * @state: atomic state * @connector: connector to disable the decompression for * @old_crtc_state: old state for the CRTC driving @connector * * Disable the DSC decompression if required in the %DP_DSC_ENABLE DPCD * register of the appropriate sink/branch device, corresponding to the * sequence in intel_dp_sink_enable_decompression().
*/ void intel_dp_sink_disable_decompression(struct intel_atomic_state *state, struct intel_connector *connector, conststruct intel_crtc_state *old_crtc_state)
{ struct intel_display *display = to_intel_display(state);
if (!old_crtc_state->dsc.compression_enable) return;
if (drm_WARN_ON(display->drm,
!connector->dp.dsc_decompression_aux ||
!connector->dp.dsc_decompression_enabled)) return;
if (!intel_dp_dsc_aux_put_ref(state, connector)) return;
/* * During driver init, we want to be careful and avoid changing the source OUI if it's * already set to what we want, so as to avoid clearing any state by accident
*/ if (drm_dp_dpcd_read(&intel_dp->aux, DP_SOURCE_OUI, buf, sizeof(buf)) < 0)
drm_dbg_kms(display->drm, "Failed to read source OUI\n");
if (memcmp(oui, buf, sizeof(oui)) == 0) { /* Assume the OUI was written now. */
intel_dp->last_oui_write = jiffies; return;
}
if (drm_dp_dpcd_write(&intel_dp->aux, DP_SOURCE_OUI, oui, sizeof(oui)) < 0) {
drm_dbg_kms(display->drm, "Failed to write source OUI\n");
WRITE_ONCE(intel_dp->oui_valid, false);
}
/* If the device supports it, try to set the power state appropriately */ void intel_dp_set_power(struct intel_dp *intel_dp, u8 mode)
{ struct intel_display *display = to_intel_display(intel_dp); struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base; int ret, i;
/* Should have a valid DPCD by this point */ if (intel_dp->dpcd[DP_DPCD_REV] < 0x11) return;
if (mode != DP_SET_POWER_D0) { if (downstream_hpd_needs_d0(intel_dp)) return;
/* Write the source OUI as early as possible */
intel_dp_init_source_oui(intel_dp);
/* * When turning on, we need to retry for 1ms to give the sink * time to wake up.
*/ for (i = 0; i < 3; i++) {
ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER, mode); if (ret == 1) break;
msleep(1);
}
if (ret == 1 && intel_lspcon_active(dig_port))
intel_lspcon_wait_pcon_mode(dig_port);
}
if (ret != 1)
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] Set power to %s failed\n",
encoder->base.base.id, encoder->base.name,
mode == DP_SET_POWER_D0 ? "D0" : "D3");
}
/** * intel_dp_sync_state - sync the encoder state during init/resume * @encoder: intel encoder to sync * @crtc_state: state for the CRTC connected to the encoder * * Sync any state stored in the encoder wrt. HW state during driver init * and system resume.
*/ void intel_dp_sync_state(struct intel_encoder *encoder, conststruct intel_crtc_state *crtc_state)
{ struct intel_dp *intel_dp = enc_to_intel_dp(encoder); bool dpcd_updated = false;
/* * Don't clobber DPCD if it's been already read out during output * setup (eDP) or detect.
*/ if (crtc_state && intel_dp->dpcd[DP_DPCD_REV] == 0) {
intel_dp_get_dpcd(intel_dp);
dpcd_updated = true;
}
/* * If BIOS has set an unsupported or non-standard link rate for some * reason force an encoder recompute and full modeset.
*/ if (intel_dp_rate_index(intel_dp->source_rates, intel_dp->num_source_rates,
crtc_state->port_clock) < 0) {
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] Forcing full modeset due to unsupported link rate\n",
encoder->base.base.id, encoder->base.name);
crtc_state->uapi.connectors_changed = true;
fastset = false;
}
/* * FIXME hack to force full modeset when DSC is being used. * * As long as we do not have full state readout and config comparison * of crtc_state->dsc, we have no way to ensure reliable fastset. * Remove once we have readout for DSC.
*/ if (crtc_state->dsc.compression_enable) {
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] Forcing full modeset due to DSC being enabled\n",
encoder->base.base.id, encoder->base.name);
crtc_state->uapi.mode_changed = true;
fastset = false;
}
if (CAN_PANEL_REPLAY(intel_dp)) {
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] Forcing full modeset to compute panel replay state\n",
encoder->base.base.id, encoder->base.name);
crtc_state->uapi.mode_changed = true;
fastset = false;
}
if (intel_dp_pcon_is_frl_trained(intel_dp, max_frl_bw_mask, &frl_trained_mask)) goto frl_trained;
ret = drm_dp_pcon_frl_prepare(&intel_dp->aux, false); if (ret < 0) return ret; /* Wait for PCON to be FRL Ready */
wait_for(is_active = drm_dp_pcon_is_frl_ready(&intel_dp->aux) == true, TIMEOUT_FRL_READY_MS);
if (!is_active) return -ETIMEDOUT;
ret = drm_dp_pcon_frl_configure_1(&intel_dp->aux, max_frl_bw,
DP_PCON_ENABLE_SEQUENTIAL_LINK); if (ret < 0) return ret;
ret = drm_dp_pcon_frl_configure_2(&intel_dp->aux, max_frl_bw_mask,
DP_PCON_FRL_LINK_TRAIN_NORMAL); if (ret < 0) return ret;
ret = drm_dp_pcon_frl_enable(&intel_dp->aux); if (ret < 0) return ret; /* * Wait for FRL to be completed * Check if the HDMI Link is up and active.
*/
wait_for(is_active =
intel_dp_pcon_is_frl_trained(intel_dp, max_frl_bw_mask, &frl_trained_mask),
TIMEOUT_HDMI_LINK_ACTIVE_MS);
static int intel_dp_pcon_set_tmds_mode(struct intel_dp *intel_dp)
{ int ret;
u8 buf = 0;
/* Set PCON source control mode */
buf |= DP_PCON_ENABLE_SOURCE_CTL_MODE;
ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_PCON_HDMI_LINK_CONFIG_1, buf); if (ret < 0) return ret;
/* Set HDMI LINK ENABLE */
buf |= DP_PCON_ENABLE_HDMI_LINK;
ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_PCON_HDMI_LINK_CONFIG_1, buf); if (ret < 0) return ret;
/* * Clear the cached register set to avoid using stale values * for the sinks that do not support DSC.
*/
memset(connector->dp.dsc_dpcd, 0, sizeof(connector->dp.dsc_dpcd));
/* Clear fec_capable to avoid using stale values */
connector->dp.fec_capability = 0;
if (connector->panel.vbt.edp.bpp && pipe_bpp > connector->panel.vbt.edp.bpp) { /* * This is a big fat ugly hack. * * Some machines in UEFI boot mode provide us a VBT that has 18 * bpp and 1.62 GHz link bandwidth for eDP, which for reasons * unknown we fail to light up. Yet the same BIOS boots up with * 24 bpp and 2.7 GHz link. Use the same bpp as the BIOS uses as * max, not what it tells us to use. * * Note: This will still be broken if the eDP panel is not lit * up by the BIOS, and thus we can't get the mode at module * load.
*/
drm_dbg_kms(display->drm, "pipe has %d bpp for eDP panel, overriding BIOS-provided max %d bpp\n",
pipe_bpp, connector->panel.vbt.edp.bpp);
connector->panel.vbt.edp.bpp = pipe_bpp;
}
}
for (i = 0; i < ARRAY_SIZE(sink_rates); i++) { int rate;
/* Value read multiplied by 200kHz gives the per-lane * link rate in kHz. The source rates are, however, * stored in terms of LS_Clk kHz. The full conversion * back to symbols is * (val * 200kHz)*(8/10 ch. encoding)*(1/8 bit to Byte)
*/
rate = le16_to_cpu(sink_rates[i]) * 200 / 10;
if (rate == 0) break;
/* * Some broken eDP sinks illegally declare support for * HBR3 without TPS4, and are unable to produce a stable * output. Reject HBR3 when TPS4 is not available.
*/ if (rate >= 810000 && !drm_dp_tps4_supported(intel_dp->dpcd)) {
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] Rejecting HBR3 due to missing TPS4 support\n",
encoder->base.base.id, encoder->base.name); break;
}
/* * Use DP_LINK_RATE_SET if DP_SUPPORTED_LINK_RATES are available, * default to DP_MAX_LINK_RATE and DP_LINK_BW_SET otherwise.
*/ if (intel_dp->num_sink_rates)
intel_dp->use_rate_select = true; else
intel_dp_set_sink_rates(intel_dp);
}
/* * Read the eDP display control registers. * * Do this independent of DP_DPCD_DISPLAY_CONTROL_CAPABLE bit in * DP_EDP_CONFIGURATION_CAP, because some buggy displays do not have it * set, but require eDP 1.4+ detection (e.g. for supported link rates * method). The display control registers should read zero if they're * not supported anyway.
*/ if (drm_dp_dpcd_read(&intel_dp->aux, DP_EDP_DPCD_REV,
intel_dp->edp_dpcd, sizeof(intel_dp->edp_dpcd)) == sizeof(intel_dp->edp_dpcd)) {
drm_dbg_kms(display->drm, "eDP DPCD: %*ph\n",
(int)sizeof(intel_dp->edp_dpcd),
intel_dp->edp_dpcd);
/* * If needed, program our source OUI so we can make various Intel-specific AUX services * available (such as HDR backlight controls)
*/
intel_dp_init_source_oui(intel_dp);
/* * This has to be called after intel_dp->edp_dpcd is filled, PSR checks * for SET_POWER_CAPABLE bit in intel_dp->edp_dpcd[1]
*/
intel_psr_init_dpcd(intel_dp);
staticbool
intel_dp_get_dpcd(struct intel_dp *intel_dp)
{ int ret;
if (intel_dp_init_lttpr_and_dprx_caps(intel_dp) < 0) returnfalse;
/* * Don't clobber cached eDP rates. Also skip re-reading * the OUI/ID since we know it won't change.
*/ if (!intel_dp_is_edp(intel_dp)) {
drm_dp_read_desc(&intel_dp->aux, &intel_dp->desc,
drm_dp_is_branch(intel_dp->dpcd));
if (intel_dp_has_sink_count(intel_dp)) {
ret = drm_dp_read_sink_count(&intel_dp->aux); if (ret < 0) returnfalse;
/* * Sink count can change between short pulse hpd hence * a member variable in intel_dp will track any changes * between short pulse interrupts.
*/
intel_dp->sink_count = ret;
/* * SINK_COUNT == 0 and DOWNSTREAM_PORT_PRESENT == 1 implies that * a dongle is present but no display. Unless we require to know * if a dongle is present or not, we don't need to update * downstream port information. So, an early return here saves * time from performing other operations which are not required.
*/ if (!intel_dp->sink_count) returnfalse;
}
/* * Display WA for HSD #13013007775: mtl/arl/lnl * Read the sink count and link service IRQ registers in separate * transactions to prevent disconnecting the sink on a TBT link * inadvertently.
*/ if (IS_DISPLAY_VER(display, 14, 20) && !display->platform.battlemage) { if (drm_dp_dpcd_read(&intel_dp->aux, DP_SINK_COUNT_ESI, esi, 3) != 3) returnfalse;
staticbool intel_dp_ack_sink_irq_esi(struct intel_dp *intel_dp, u8 esi[4])
{ int retry;
for (retry = 0; retry < 3; retry++) { if (drm_dp_dpcd_write(&intel_dp->aux, DP_SINK_COUNT_ESI + 1,
&esi[1], 3) == 3) returntrue;
}
returnfalse;
}
bool
intel_dp_needs_vsc_sdp(conststruct intel_crtc_state *crtc_state, conststruct drm_connector_state *conn_state)
{ /* * As per DP 1.4a spec section 2.2.4.3 [MSA Field for Indication * of Color Encoding Format and Content Color Gamut], in order to * sending YCBCR 420 or HDR BT.2020 signals we should use DP VSC SDP.
*/ if (crtc_state->output_format == INTEL_OUTPUT_FORMAT_YCBCR420) returntrue;
switch (conn_state->colorspace) { case DRM_MODE_COLORIMETRY_SYCC_601: case DRM_MODE_COLORIMETRY_OPYCC_601: case DRM_MODE_COLORIMETRY_BT2020_YCC: case DRM_MODE_COLORIMETRY_BT2020_RGB: case DRM_MODE_COLORIMETRY_BT2020_CYCC: returntrue; default: break;
}
/* * Set up the infoframe sdp packet for HDR static metadata. * Prepare VSC Header for SU as per DP 1.4a spec, * Table 2-100 and Table 2-101
*/
/* Secondary-Data Packet ID, 00h for non-Audio INFOFRAME */
sdp->sdp_header.HB0 = 0; /* * Packet Type 80h + Non-audio INFOFRAME Type value * HDMI_INFOFRAME_TYPE_DRM: 0x87 * - 80h + Non-audio INFOFRAME Type value * - InfoFrame Type: 0x07 * [CTA-861-G Table-42 Dynamic Range and Mastering InfoFrame]
*/
sdp->sdp_header.HB1 = drm_infoframe->type; /* * Least Significant Eight Bits of (Data Byte Count – 1) * infoframe_size - 1
*/
sdp->sdp_header.HB2 = 0x1D; /* INFOFRAME SDP Version Number */
sdp->sdp_header.HB3 = (0x13 << 2); /* CTA Header Byte 2 (INFOFRAME Version Number) */
sdp->db[0] = drm_infoframe->version; /* CTA Header Byte 3 (Length of INFOFRAME): HDMI_DRM_INFOFRAME_SIZE */
sdp->db[1] = drm_infoframe->length; /* * Copy HDMI_DRM_INFOFRAME_SIZE size from a buffer after * HDMI_INFOFRAME_HEADER_SIZE
*/
BUILD_BUG_ON(sizeof(sdp->db) < HDMI_DRM_INFOFRAME_SIZE + 2);
memcpy(&sdp->db[2], &buf[HDMI_INFOFRAME_HEADER_SIZE],
HDMI_DRM_INFOFRAME_SIZE);
/* * Size of DP infoframe sdp packet for HDR static metadata consists of * - DP SDP Header(struct dp_sdp_header): 4 bytes * - Two Data Blocks: 2 bytes * CTA Header Byte2 (INFOFRAME Version Number) * CTA Header Byte3 (Length of INFOFRAME) * - HDMI_DRM_INFOFRAME_SIZE: 26 bytes * * Prior to GEN11's GMP register size is identical to DP HDR static metadata * infoframe size. But GEN11+ has larger than that size, write_infoframe * will pad rest of the size.
*/ returnsizeof(struct dp_sdp_header) + 2 + HDMI_DRM_INFOFRAME_SIZE;
}
if (HAS_AS_SDP(display))
dip_enable |= VIDEO_DIP_ENABLE_AS_ADL;
u32 val = intel_de_read(display, reg) & ~dip_enable;
/* TODO: Sanitize DSC enabling wrt. intel_dsc_dp_pps_write(). */ if (!enable && HAS_DSC(display))
val &= ~VDIP_ENABLE_PPS;
/* * This routine disables VSC DIP if the function is called * to disable SDP or if it does not have PSR
*/ if (!enable || !crtc_state->has_psr)
val &= ~VIDEO_DIP_ENABLE_VSC_HSW;
if (uhbr)
ok = drm_dp_128b132b_lane_channel_eq_done(link_status,
intel_dp->lane_count); else
ok = drm_dp_channel_eq_ok(link_status, intel_dp->lane_count);
if (ok) returntrue;
intel_dp_dump_link_status(intel_dp, DP_PHY_DPRX, link_status);
drm_dbg_kms(display->drm, "[ENCODER:%d:%s] %s link not ok, retraining\n",
encoder->base.base.id, encoder->base.name,
uhbr ? "128b/132b" : "8b/10b");
if (drm_dp_dpcd_read(&intel_dp->aux, DP_LANE0_1_STATUS_ESI, link_status,
esi_link_status_size) != esi_link_status_size) {
drm_err(display->drm, "[ENCODER:%d:%s] Failed to read link status\n",
encoder->base.base.id, encoder->base.name); returnfalse;
}
return intel_dp_link_ok(intel_dp, link_status);
}
/** * intel_dp_check_mst_status - service any pending MST interrupts, check link status * @intel_dp: Intel DP struct * * Read any pending MST interrupts, call MST core to handle these and ack the * interrupts. Check if the main and AUX link state is ok. * * Returns: * - %true if pending interrupts were serviced (or no interrupts were * pending) w/o detecting an error condition. * - %false if an error condition - like AUX failure or a loss of link - is * detected, or another condition - like a DP tunnel BW state change - needs * servicing from the hotplug work.
*/ staticbool
intel_dp_check_mst_status(struct intel_dp *intel_dp)
{ struct intel_display *display = to_intel_display(intel_dp); struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); struct intel_encoder *encoder = &dig_port->base; bool link_ok = true; bool reprobe_needed = false;
for (;;) {
u8 esi[4] = {};
u8 ack[4] = {};
if (!intel_dp_get_sink_irq_esi(intel_dp, esi)) {
drm_dbg_kms(display->drm, "failed to get ESI - device may have failed\n");
link_ok = false;
/* * While PSR source HW is enabled, it will control main-link sending * frames, enabling and disabling it so trying to do a retrain will fail * as the link would or not be on or it could mix training patterns * and frame data at the same time causing retrain to fail. * Also when exiting PSR, HW will retrain the link anyways fixing * any link status error.
*/ if (intel_psr_enabled(intel_dp)) returnfalse;
if (intel_dp->link.force_retrain) returntrue;
if (drm_dp_dpcd_read_phy_link_status(&intel_dp->aux, DP_PHY_DPRX,
link_status) < 0) returnfalse;
/* * Validate the cached values of intel_dp->link_rate and * intel_dp->lane_count before attempting to retrain. * * FIXME would be nice to user the crtc state here, but since * we need to call this from the short HPD handler that seems * a bit hard.
*/ if (!intel_dp_link_params_valid(intel_dp, intel_dp->link_rate,
intel_dp->lane_count)) returnfalse;
if (intel_dp->link.retrain_disabled) returnfalse;
if (intel_dp->link.seq_train_failures) returntrue;
/* Retrain if link not ok */ return !intel_dp_link_ok(intel_dp, link_status) &&
!intel_psr_link_ok(intel_dp);
}
if (intel_dp->dpcd[DP_DPCD_REV] < 0x11) returnfalse;
if (drm_dp_dpcd_readb(&intel_dp->aux,
DP_LINK_SERVICE_IRQ_VECTOR_ESI0, &val) != 1 || !val) returnfalse;
if ((val & DP_TUNNELING_IRQ) &&
drm_dp_tunnel_handle_irq(display->dp_tunnel_mgr,
&intel_dp->aux))
reprobe_needed = true;
if (drm_dp_dpcd_writeb(&intel_dp->aux,
DP_LINK_SERVICE_IRQ_VECTOR_ESI0, val) != 1) return reprobe_needed;
if (val & HDMI_LINK_STATUS_CHANGED)
intel_dp_handle_hdmi_link_status_change(intel_dp);
return reprobe_needed;
}
/* * According to DP spec * 5.1.2: * 1. Read DPCD * 2. Configure link according to Receiver Capabilities * 3. Use Link Training from 2.5.3.3 and 3.5.1.3 * 4. Check link status on receipt of hot-plug interrupt * * intel_dp_short_pulse - handles short pulse interrupts * when full detection is not required. * Returns %true if short pulse is handled and full detection * is NOT required and %false otherwise.
*/ staticbool
intel_dp_short_pulse(struct intel_dp *intel_dp)
{
u8 old_sink_count = intel_dp->sink_count; bool reprobe_needed = false; bool ret;
intel_dp_test_reset(intel_dp);
/* * Now read the DPCD to see if it's actually running * If the current value of sink count doesn't match with * the value that was stored earlier or dpcd read failed * we need to do full detection
*/
ret = intel_dp_get_dpcd(intel_dp);
if ((old_sink_count != intel_dp->sink_count) || !ret) { /* No need to proceed if we are going to do full detect */ returnfalse;
}
if (intel_dp->mst_detect == DRM_DP_MST) return connector_status_connected;
/* If no HPD, poke DDC gently */ if (drm_probe_ddc(&intel_dp->aux.ddc)) return connector_status_connected;
/* Well we tried, say unknown for unreliable port types */ if (intel_dp->dpcd[DP_DPCD_REV] >= 0x11) {
type = intel_dp->downstream_ports[0] & DP_DS_PORT_TYPE_MASK; if (type == DP_DS_PORT_TYPE_VGA ||
type == DP_DS_PORT_TYPE_NON_EDID) return connector_status_unknown;
} else {
type = intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] &
DP_DWN_STRM_PORT_TYPE_MASK; if (type == DP_DWN_STRM_PORT_TYPE_ANALOG ||
type == DP_DWN_STRM_PORT_TYPE_OTHER) return connector_status_unknown;
}
/* Anything else is out of spec, warn and ignore */
drm_dbg_kms(display->drm, "Broken DP branch device, ignoring\n"); return connector_status_disconnected;
}
if (dig_port->unlock)
dig_port->unlock(dig_port);
}
/* * intel_digital_port_connected_locked - is the specified port connected? * @encoder: intel_encoder * * In cases where there's a connector physically connected but it can't be used * by our hardware we also return false, since the rest of the driver should * pretty much treat the port as disconnected. This is relevant for type-C * (starting on ICL) where there's ownership involved. * * The caller must hold the lock acquired by calling intel_digital_port_lock() * when calling this function. * * Return %true if port is connected, %false otherwise.
*/ bool intel_digital_port_connected_locked(struct intel_encoder *encoder)
{ struct intel_display *display = to_intel_display(encoder); struct intel_digital_port *dig_port = enc_to_dig_port(encoder); bool is_glitch_free = intel_tc_port_handles_hpd_glitches(dig_port); bool is_connected = false;
intel_wakeref_t wakeref;
if (!intel_display_device_enabled(display)) return connector_status_disconnected;
if (!intel_display_driver_check_access(display)) return connector->base.status;
intel_dp_flush_connector_commits(connector);
intel_pps_vdd_on(intel_dp);
/* Can't disconnect eDP */ if (intel_dp_is_edp(intel_dp))
status = edp_detect(intel_dp); elseif (intel_digital_port_connected(encoder))
status = intel_dp_detect_dpcd(intel_dp); else
status = connector_status_disconnected;
if (status != connector_status_disconnected &&
!intel_dp_mst_verify_dpcd_state(intel_dp)) /* * This requires retrying detection for instance to re-enable * the MST mode that got reset via a long HPD pulse. The retry * will happen either via the hotplug handler's retry logic, * ensured by setting the connector here to SST/disconnected, * or via a userspace connector probing in response to the * hotplug uevent sent when removing the MST connectors.
*/
status = connector_status_disconnected;
ret = intel_dp_tunnel_detect(intel_dp, ctx); if (ret == -EDEADLK) {
status = ret;
goto out_vdd_off;
}
if (ret == 1)
connector->base.epoch_counter++;
if (!intel_dp_is_edp(intel_dp))
intel_psr_init_dpcd(intel_dp);
intel_dp_detect_dsc_caps(intel_dp, connector);
intel_dp_detect_sdp_caps(intel_dp);
if (intel_dp->reset_link_params) {
intel_dp_reset_link_params(intel_dp);
intel_dp->reset_link_params = false;
}
intel_dp_mst_configure(intel_dp);
intel_dp_print_rates(intel_dp);
if (intel_dp->is_mst) { /* * If we are in MST mode then this connector * won't appear connected or have anything * with EDID on it
*/
status = connector_status_disconnected; goto out_unset_edid;
}
/* * Some external monitors do not signal loss of link synchronization * with an IRQ_HPD, so force a link status check. * * TODO: this probably became redundant, so remove it: the link state * is rechecked/recovered now after modesets, where the loss of * synchronization tends to occur.
*/ if (!intel_dp_is_edp(intel_dp))
intel_dp_check_link_state(intel_dp);
/* * Clearing NACK and defer counts to get their exact values * while reading EDID which are required by Compliance tests * 4.2.2.4 and 4.2.2.5
*/
intel_dp->aux.i2c_nack_count = 0;
intel_dp->aux.i2c_defer_count = 0;
intel_dp_set_edid(intel_dp); if (intel_dp_is_edp(intel_dp) || connector->detect_edid)
status = connector_status_connected;
intel_dp_check_device_service_irq(intel_dp);
out_unset_edid: if (status != connector_status_connected && !intel_dp->is_mst)
intel_dp_unset_edid(intel_dp);
intel_dp_dpcd_set_probe(intel_dp, false);
if (!intel_dp_is_edp(intel_dp))
drm_dp_set_subconnector_property(&connector->base,
status,
intel_dp->dpcd,
intel_dp->downstream_ports);
out_vdd_off:
intel_pps_vdd_off(intel_dp);
ret = intel_connector_register(&connector->base); if (ret) return ret;
drm_dbg_kms(display->drm, "registering %s bus for %s\n",
intel_dp->aux.name, connector->base.kdev->kobj.name);
intel_dp->aux.dev = connector->base.kdev;
ret = drm_dp_aux_register(&intel_dp->aux); if (!ret)
drm_dp_cec_register_connector(&intel_dp->aux, &connector->base);
if (!intel_bios_encoder_is_lspcon(dig_port->base.devdata)) return ret;
/* * ToDo: Clean this up to handle lspcon init and resume more * efficiently and streamlined.
*/ if (intel_lspcon_init(dig_port)) { if (intel_lspcon_detect_hdr_capability(dig_port))
drm_connector_attach_hdr_output_metadata_property(&connector->base);
}
/* * Ensure power off delay is respected on module remove, so that we can * reduce delays at driver probe. See pps_init_timestamps().
*/
intel_pps_wait_power_cycle(intel_dp);
ret = intel_digital_connector_atomic_check(&connector->base, &state->base); if (ret) return ret;
if (intel_dp_mst_source_support(intel_dp)) {
ret = drm_dp_mst_root_conn_atomic_check(conn_state, &intel_dp->mst.mgr); if (ret) return ret;
}
if (!intel_connector_needs_modeset(state, &connector->base)) return 0;
ret = intel_dp_tunnel_atomic_check_state(state,
intel_dp,
connector); if (ret) return ret;
/* * We don't enable port sync on BDW due to missing w/as and * due to not having adjusted the modeset sequence appropriately.
*/ if (DISPLAY_VER(display) < 9) return 0;
if (connector->base.has_tile) {
ret = intel_modeset_tile_group(state, connector->base.tile_group->id); if (ret) return ret;
}
if (dig_port->base.type == INTEL_OUTPUT_EDP &&
(long_hpd ||
intel_display_rpm_suspended(display) ||
!intel_pps_have_panel_power_or_vdd(intel_dp))) { /* * vdd off can generate a long/short pulse on eDP which * would require vdd on to handle it, and thus we * would end up in an endless cycle of * "vdd off -> long/short hpd -> vdd on -> detect -> vdd off -> ..."
*/
drm_dbg_kms(display->drm, "ignoring %s hpd on eDP [ENCODER:%d:%s]\n",
long_hpd ? "long" : "short",
dig_port->base.base.base.id,
dig_port->base.base.name); return IRQ_HANDLED;
}
/* * TBT DP tunnels require the GFX driver to read out the DPRX caps in * response to long HPD pulses. The DP hotplug handler does that, * however the hotplug handler may be blocked by another * connector's/encoder's hotplug handler. Since the TBT CM may not * complete the DP tunnel BW request for the latter connector/encoder * waiting for this encoder's DPRX read, perform a dummy read here.
*/ if (long_hpd) {
intel_dp_dpcd_set_probe(intel_dp, true);
if (intel_dp->is_mst) { if (!intel_dp_check_mst_status(intel_dp)) return IRQ_NONE;
} elseif (!intel_dp_short_pulse(intel_dp)) { return IRQ_NONE;
}
return IRQ_HANDLED;
}
staticbool _intel_dp_is_port_edp(struct intel_display *display, conststruct intel_bios_encoder_data *devdata, enum port port)
{ /* * eDP not supported on g4x. so bail out early just * for a bit extra safety in case the VBT is bonkers.
*/ if (DISPLAY_VER(display) < 5) returnfalse;
if (DISPLAY_VER(display) < 9 && port == PORT_A) returntrue;
/* Register HDMI colorspace for case of lspcon */ if (intel_bios_encoder_is_lspcon(dp_to_dig_port(intel_dp)->base.devdata)) {
drm_connector_attach_content_type_property(&connector->base);
intel_attach_hdmi_colorspace_property(&connector->base);
} else {
intel_attach_dp_colorspace_property(&connector->base);
}
if (intel_dp_has_gamut_metadata_dip(&dp_to_dig_port(intel_dp)->base))
drm_connector_attach_hdr_output_metadata_property(&connector->base);
if (HAS_VRR(display))
drm_connector_attach_vrr_capable_property(&connector->base);
}
/* * On IBX/CPT we may get here with LVDS already registered. Since the * driver uses the only internal power sequencer available for both * eDP and LVDS bail out early in this case to prevent interfering * with an already powered-on LVDS power sequencer.
*/ if (intel_get_lvds_encoder(display)) {
drm_WARN_ON(display->drm,
!(HAS_PCH_IBX(display) || HAS_PCH_CPT(display)));
drm_info(display->drm, "LVDS was detected, not registering eDP\n");
if (!intel_pps_init(intel_dp)) {
drm_info(display->drm, "[ENCODER:%d:%s] unusable PPS, disabling eDP\n",
encoder->base.base.id, encoder->base.name); /* * The BIOS may have still enabled VDD on the PPS even * though it's unusable. Make sure we turn it back off * and to release the power domain references/etc.
*/ goto out_vdd_off;
}
/* * Enable HPD sense for live status check. * intel_hpd_irq_setup() will turn it off again * if it's no longer needed later. * * The DPCD probe below will make sure VDD is on.
*/
intel_hpd_enable_detection(encoder);
intel_alpm_init(intel_dp);
/* Cache DPCD and EDID for edp. */
has_dpcd = intel_edp_init_dpcd(intel_dp, connector);
if (!has_dpcd) { /* if this fails, presume the device is a ghost */
drm_info(display->drm, "[ENCODER:%d:%s] failed to retrieve link info, disabling eDP\n",
encoder->base.base.id, encoder->base.name); goto out_vdd_off;
}
/* * VBT and straps are liars. Also check HPD as that seems * to be the most reliable piece of information available. * * ... expect on devices that forgot to hook HPD up for eDP * (eg. Acer Chromebook C710), so we'll check it only if multiple * ports are attempting to use the same AUX CH, according to VBT.
*/ if (intel_bios_dp_has_shared_aux_ch(encoder->devdata)) { /* * If this fails, presume the DPCD answer came * from some other port using the same AUX CH. * * FIXME maybe cleaner to check this before the * DPCD read? Would need sort out the VDD handling...
*/ if (!intel_digital_port_connected(encoder)) {
drm_info(display->drm, "[ENCODER:%d:%s] HPD is down, disabling eDP\n",
encoder->base.base.id, encoder->base.name); goto out_vdd_off;
}
/* * Unfortunately even the HPD based detection fails on * eg. Asus B360M-A (CFL+CNP), so as a last resort fall * back to checking for a VGA branch device. Only do this * on known affected platforms to minimize false positives.
*/ if (DISPLAY_VER(display) == 9 && drm_dp_is_branch(intel_dp->dpcd) &&
(intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_TYPE_MASK) ==
DP_DWN_STRM_PORT_TYPE_ANALOG) {
drm_info(display->drm, "[ENCODER:%d:%s] VGA converter detected, disabling eDP\n",
encoder->base.base.id, encoder->base.name); goto out_vdd_off;
}
}
mutex_lock(&display->drm->mode_config.mutex);
drm_edid = drm_edid_read_ddc(&connector->base, connector->base.ddc); if (!drm_edid) { /* Fallback to EDID from ACPI OpRegion, if any */
drm_edid = intel_opregion_get_edid(connector); if (drm_edid)
drm_dbg_kms(display->drm, "[CONNECTOR:%d:%s] Using OpRegion EDID\n",
connector->base.base.id, connector->base.name);
} if (drm_edid) { if (drm_edid_connector_update(&connector->base, drm_edid) ||
!drm_edid_connector_add_modes(&connector->base)) {
drm_edid_connector_update(&connector->base, NULL);
drm_edid_free(drm_edid);
drm_edid = ERR_PTR(-EINVAL);
}
} else {
drm_edid = ERR_PTR(-ENOENT);
}
/* MSO requires information from the EDID */
intel_edp_mso_init(intel_dp);
/* multiply the mode clock and horizontal timings for MSO */
list_for_each_entry(fixed_mode, &connector->panel.fixed_modes, head)
intel_edp_mso_mode_fixup(connector, fixed_mode);
/* fallback to VBT if available for eDP */ if (!intel_panel_preferred_fixed_mode(connector))
intel_panel_add_vbt_lfp_fixed_mode(connector);
mutex_unlock(&display->drm->mode_config.mutex);
if (!intel_panel_preferred_fixed_mode(connector)) {
drm_info(display->drm, "[ENCODER:%d:%s] failed to find fixed mode for the panel, disabling eDP\n",
encoder->base.base.id, encoder->base.name); goto out_vdd_off;
}
if (drm_WARN(dev, dig_port->max_lanes < 1, "Not enough lanes (%d) for DP on [ENCODER:%d:%s]\n",
dig_port->max_lanes, encoder->base.base.id,
encoder->base.name)) returnfalse;
intel_dp->reset_link_params = true;
/* Preserve the current hw state. */
intel_dp->DP = intel_de_read(display, intel_dp->output_reg);
intel_dp->attached_connector = connector;
if (_intel_dp_is_port_edp(display, encoder->devdata, port)) { /* * Currently we don't support eDP on TypeC ports for DISPLAY_VER < 30, * although in theory it could work on TypeC legacy ports.
*/
drm_WARN_ON(dev, intel_encoder_is_tc(encoder) &&
DISPLAY_VER(display) < 30);
type = DRM_MODE_CONNECTOR_eDP;
encoder->type = INTEL_OUTPUT_EDP;
/* eDP only on port B and/or C on vlv/chv */ if (drm_WARN_ON(dev, (display->platform.valleyview ||
display->platform.cherryview) &&
port != PORT_B && port != PORT_C)) returnfalse;
} else {
type = DRM_MODE_CONNECTOR_DisplayPort;
}
if (is_hdcp_supported(display, port) && !intel_dp_is_edp(intel_dp)) { int ret = intel_dp_hdcp_init(dig_port, connector); if (ret)
drm_dbg_kms(display->drm, "HDCP init failed, skipping.\n");
}
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.