return 0;
}
+static void hdmi_frl_status_polling_work(struct work_struct *work)
+{
+ struct amdgpu_display_manager *dm =
+ container_of(to_delayed_work(work), struct amdgpu_display_manager,
+ hdmi_frl_status_polling_work);
+ struct dc *dc = dm->dc;
+ struct dc_link *dc_link;
+ bool link_update = false;
+
+ for (int i = 0; i < MAX_LINKS; i++) {
+ dc_link = dc->links[i];
+
+ if (!dc_link || !dc_link->local_sink)
+ continue;
+
+ if (!dc_is_hdmi_signal(dc_link->connector_signal))
+ continue;
+
+ if (dc_link->connector_signal != SIGNAL_TYPE_HDMI_FRL)
+ continue;
+
+ link_update = dc_link_frl_poll_status_flag(dc_link);
+ if (link_update) {
+ mutex_lock(&dm->dc_lock);
+ dc_link_detect(dc_link, DETECT_REASON_RETRAIN);
+ mutex_unlock(&dm->dc_lock);
+ }
+ }
+
+ queue_delayed_work(dm->hdmi_frl_status_polling_wq,
+ &dm->hdmi_frl_status_polling_work,
+ msecs_to_jiffies(dm->hdmi_frl_status_polling_delay_ms));
+}
+
static int amdgpu_dm_init(struct amdgpu_device *adev)
{
struct dc_init_data init_data;
dc_init_callbacks(adev->dm.dc, &init_params);
}
+ if (adev->dm.dc->caps.max_links > 0) {
+ adev->dm.hdmi_frl_status_polling_wq =
+ create_singlethread_workqueue("hdmi_frl_status_polling_workqueue");
+ if (!adev->dm.hdmi_frl_status_polling_wq)
+ drm_err(adev_to_drm(adev), "failed to initialize hdmi_frl_status_polling_workqueue\n");
+ adev->dm.hdmi_frl_status_polling_delay_ms = 200;
+ INIT_DELAYED_WORK(&adev->dm.hdmi_frl_status_polling_work, hdmi_frl_status_polling_work);
+ }
if (dc_is_dmub_outbox_supported(adev->dm.dc)) {
init_completion(&adev->dm.dmub_aux_transfer_done);
adev->dm.dmub_notify = kzalloc_obj(struct dmub_notification);
timing_out->flags.VSYNC_POSITIVE_POLARITY = 1;
}
- if (stream->signal == SIGNAL_TYPE_HDMI_TYPE_A) {
+ if (stream->signal == SIGNAL_TYPE_HDMI_TYPE_A ||
+ stream->signal == SIGNAL_TYPE_HDMI_FRL) {
err = drm_hdmi_avi_infoframe_from_display_mode(&avi_frame,
(struct drm_connector *)connector,
mode_in);
update_stream_signal(stream, sink);
- if (stream->signal == SIGNAL_TYPE_HDMI_TYPE_A)
+ if (stream->signal == SIGNAL_TYPE_HDMI_TYPE_A ||
+ stream->signal == SIGNAL_TYPE_HDMI_FRL)
mod_build_hf_vsif_infopacket(stream, &stream->vsp_infopacket, false, false);
if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT ||
if (aconnector &&
(aconnector->dc_link->connector_signal == SIGNAL_TYPE_HDMI_TYPE_A ||
+ aconnector->dc_link->connector_signal == SIGNAL_TYPE_HDMI_FRL ||
aconnector->dc_link->dpcd_caps.dongle_type == DISPLAY_DONGLE_DP_HDMI_CONVERTER))
bpc_limit = 8;
dc_exit_ips_for_hw_access(dm->dc);
WARN_ON(!dc_commit_streams(dm->dc, ¶ms));
+ bool frl_stream_found = false;
+
+ for (i = 0; i < params.stream_count; i++) {
+ struct dc_stream_state *stream = params.streams[i];
+
+ if (stream->signal == SIGNAL_TYPE_HDMI_FRL) {
+ frl_stream_found = true;
+ break;
+ }
+ }
+ if (frl_stream_found) {
+ if (queue_delayed_work(dm->hdmi_frl_status_polling_wq,
+ &dm->hdmi_frl_status_polling_work,
+ msecs_to_jiffies(dm->hdmi_frl_status_polling_delay_ms)))
+ drm_dbg_kms(dev, "200ms frl status polling starts ...\n");
+ } else {
+ if (cancel_delayed_work_sync(&dm->hdmi_frl_status_polling_work))
+ drm_dbg_kms(dev, "200ms frl status polling stops ...\n");
+ }
/* Allow idle optimization when vblank count is 0 for display off */
if ((dm->active_vblank_irq_count == 0) && amdgpu_dm_is_headless(dm->adev))
dc_allow_idle_optimizations(dm->dc, true);
struct completion replied;
char reply_data[0x40]; // Cannot include dmub_cmd here
} fused_io[8];
+ /**
+ * @hdmi_frl_status_polling_work:
+ *
+ * workqueue for 200ms frl status polling
+ */
+ struct workqueue_struct *hdmi_frl_status_polling_wq;
+ struct delayed_work hdmi_frl_status_polling_work;
+ unsigned int hdmi_frl_status_polling_delay_ms;
/**
* @dm_boot_time_crc_info:
bool disallow_edp_enter_psr;
bool disallow_edp_enter_replay;
+ union dwnstream_portxcaps mst_downstream_port_caps;
+
/* Record progress status of mst*/
uint8_t mst_status;
link->dp.mst_enabled = config->mst_enabled;
link->dp.dp2_enabled = config->dp2_enabled;
link->dp.usb4_enabled = config->usb4_enabled;
+ if (aconnector->dc_sink->sink_signal == SIGNAL_TYPE_HDMI_FRL)
+ link->hdmi.frl_enabled = config->frl_enabled;
display->adjust.disable = MOD_HDCP_DISPLAY_DISABLE_AUTHENTICATION;
link->adjust.auth_delay = 2;
link->adjust.retry_limit = MAX_NUM_OF_ATTEMPTS;
return edid;
}
+static uint8_t get_max_frl_rate(uint8_t max_lanes, uint8_t max_rate_per_lane)
+{
+ uint8_t max_frl_rate;
+
+ if ((max_lanes == 3) && (max_rate_per_lane == 3))
+ max_frl_rate = 1;
+ else if ((max_lanes == 3) && (max_rate_per_lane == 6))
+ max_frl_rate = 2;
+ else if ((max_lanes == 4) && (max_rate_per_lane == 6))
+ max_frl_rate = 3;
+ else if ((max_lanes == 4) && (max_rate_per_lane == 8))
+ max_frl_rate = 4;
+ else if ((max_lanes == 4) && (max_rate_per_lane == 10))
+ max_frl_rate = 5;
+ else if ((max_lanes == 4) && (max_rate_per_lane == 12))
+ max_frl_rate = 6;
+ else
+ max_frl_rate = 0;
+
+ return max_frl_rate;
+}
+
void populate_hdmi_info_from_connector(struct drm_hdmi_info *hdmi, struct dc_edid_caps *edid_caps)
{
edid_caps->scdc_present = hdmi->scdc.supported;
+ edid_caps->max_frl_rate = get_max_frl_rate(hdmi->max_lanes, hdmi->max_frl_rate_per_lane);
}
enum dc_edid_status dm_helpers_read_local_edid(
return 0;
}
+static bool get_conv_frl_bw(struct amdgpu_dm_connector *aconnector,
+ uint32_t *bw_in_kbps, uint32_t *dsc_bw_in_kbps)
+{
+ unsigned int max_conv_bw_in_kbps = 0;
+ unsigned int max_sink_bw_in_kbps = 0;
+ unsigned int dsc_max_sink_bw_in_kbps = 0;
+
+ if (aconnector->dc_link->dc->caps.dp_hdmi21_pcon_support &&
+ aconnector->mst_downstream_port_caps.bytes.byte0.bits.DWN_STRM_PORTX_TYPE == DOWN_STREAM_DETAILED_HDMI) {
+ max_conv_bw_in_kbps = dc_link_bw_kbps_from_raw_frl_link_rate_data(
+ aconnector->dc_link->dc,
+ aconnector->mst_downstream_port_caps.bytes.byte2.bits.MAX_ENCODED_LINK_BW_SUPPORT);
+ if (aconnector->dc_sink->edid_caps.max_frl_rate && max_conv_bw_in_kbps) {
+ max_sink_bw_in_kbps = dc_link_bw_kbps_from_raw_frl_link_rate_data(
+ aconnector->dc_link->dc,
+ aconnector->dc_sink->edid_caps.max_frl_rate);
+ dsc_max_sink_bw_in_kbps = dc_link_bw_kbps_from_raw_frl_link_rate_data(
+ aconnector->dc_link->dc,
+ aconnector->dc_sink->edid_caps.frl_dsc_max_frl_rate);
+
+ *bw_in_kbps = min(max_conv_bw_in_kbps, max_sink_bw_in_kbps);
+ *dsc_bw_in_kbps = min(*bw_in_kbps, dsc_max_sink_bw_in_kbps);
+ }
+ }
+
+ return *bw_in_kbps > 0; // Frl endpoint is detected
+}
+
+static void build_frl_mst_dsc_params(struct amdgpu_dm_connector *aconnector,
+ struct dc_stream_state *stream,
+ struct dc_dsc_policy *dsc_policy,
+ struct dsc_mst_fairness_params *params,
+ uint32_t frl_conv_dsc_bw_in_kbps)
+{
+ uint32_t min_bpp_x16, max_bpp_x16;
+ struct dc_dsc_config_options dsc_options = {0};
+
+ min_bpp_x16 = dsc_policy->min_target_bpp * 16;
+ max_bpp_x16 = dsc_policy->max_target_bpp * 16;
+
+ dc_dsc_get_default_config_option(stream->sink->ctx->dc, &dsc_options);
+ dsc_options.max_target_bpp_limit_override_x16 =
+ stream->sink->edid_caps.panel_patch.max_dsc_target_bpp_limit * 16;
+
+ if (dc_dsc_compute_config(
+ stream->sink->ctx->dc->res_pool->dscs[0],
+ &stream->sink->dsc_caps.dsc_dec_caps,
+ &dsc_options,
+ frl_conv_dsc_bw_in_kbps,
+ &stream->timing,
+ dc_link_get_highest_encoding_format(aconnector->dc_link),
+ &stream->timing.dsc_cfg)) {
+ // The timing can enable dsc
+ if (stream->sink->dsc_caps.dsc_dec_caps.is_vic_all_bpp && min_bpp_x16 <= stream->timing.dsc_cfg.bits_per_pixel) {
+ // with all supported bpp within the range limit
+ params->bw_range.max_target_bpp_x16 = min(stream->timing.dsc_cfg.bits_per_pixel, dsc_policy->max_target_bpp * 16);
+ params->bw_range.min_target_bpp_x16 = min_bpp_x16;
+ params->bw_range.max_kbps = (params->bw_range.max_target_bpp_x16 * stream->timing.pix_clk_100hz + 159) / 160;
+ params->bw_range.min_kbps = (params->bw_range.min_target_bpp_x16 * stream->timing.pix_clk_100hz + 159) / 160;
+ } else if (!stream->sink->dsc_caps.dsc_dec_caps.is_vic_all_bpp &&
+ min_bpp_x16 <= stream->timing.dsc_cfg.bits_per_pixel &&
+ max_bpp_x16 >= stream->timing.dsc_cfg.bits_per_pixel) {
+ // with selected bpp only within the range limit
+ params->bw_range.max_target_bpp_x16 = stream->timing.dsc_cfg.bits_per_pixel;
+ params->bw_range.max_kbps = (params->bw_range.max_target_bpp_x16 * stream->timing.pix_clk_100hz + 159) / 160;
+ params->bw_range.min_target_bpp_x16 = params->bw_range.max_target_bpp_x16;
+ params->bw_range.min_kbps = params->bw_range.max_kbps;
+ }
+ }
+}
+
static void log_dsc_params(int count, struct dsc_mst_fairness_vars *vars, int k)
{
int i;
bool debugfs_overwrite = false;
uint16_t fec_overhead_multiplier_x1000 = get_fec_overhead_multiplier(dc_link);
struct drm_connector_state *new_conn_state;
+ bool is_frl_endpoint_present;
+ uint32_t frl_conv_bw_in_kbps, frl_conv_dsc_bw_in_kbps;
memset(params, 0, sizeof(params));
params[count].bpp_overwrite = aconnector->dsc_settings.dsc_bits_per_pixel;
params[count].compression_possible = stream->sink->dsc_caps.dsc_dec_caps.is_dsc_supported;
dc_dsc_get_policy_for_timing(params[count].timing, 0, &dsc_policy, dc_link_get_highest_encoding_format(stream->link));
+ is_frl_endpoint_present = get_conv_frl_bw(aconnector, &frl_conv_bw_in_kbps, &frl_conv_dsc_bw_in_kbps);
+ if (stream->sink->dsc_caps.dsc_dec_caps.is_dsc_supported &&
+ is_frl_endpoint_present &&
+ frl_conv_dsc_bw_in_kbps &&
+ stream->sink->dsc_caps.dsc_dec_caps.is_frl)
+ build_frl_mst_dsc_params(aconnector, stream, &dsc_policy, ¶ms[count], frl_conv_dsc_bw_in_kbps);
if (!dc_dsc_compute_bandwidth_range(
stream->sink->ctx->dc->res_pool->dscs[0],
stream->sink->ctx->dc->debug.dsc_min_slice_height_override,