Commit ded3491b authored by Melissa Wen's avatar Melissa Wen Committed by Alex Deucher

drm/amd/display: code cleanup on dc_link from is_same_edid to get_ddc_line

Removes codestyle issues on the file dc_link between is_same_edid and
get_ddc_line as suggested by checkpatch.pl.

Types covered:

CHECK: Blank lines aren't necessary after an open brace '{'
CHECK: Blank lines aren't necessary before a close brace '}'
WARNING: braces {} are not necessary for single statement blocks
CHECK: Comparison to NULL could be written
CHECK: Lines should not end with a '('
CHECK: Alignment should match open parenthesis
CHECK: Using comparison to false is error prone
CHECK: Using comparison to true is error prone
WARNING: Avoid multiple line dereference - prefer 'link->dpcd_caps.sink_count.bits.SINK_COUNT'
CHECK: Unnecessary parentheses around
WARNING: Missing a blank line after declarations
Signed-off-by: default avatarMelissa Wen <melissa.srw@gmail.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 621514aa
...@@ -677,12 +677,12 @@ static bool is_same_edid(struct dc_edid *old_edid, struct dc_edid *new_edid) ...@@ -677,12 +677,12 @@ static bool is_same_edid(struct dc_edid *old_edid, struct dc_edid *new_edid)
if (new_edid->length == 0) if (new_edid->length == 0)
return false; return false;
return (memcmp(old_edid->raw_edid, new_edid->raw_edid, new_edid->length) == 0); return (memcmp(old_edid->raw_edid,
new_edid->raw_edid, new_edid->length) == 0);
} }
static bool wait_for_alt_mode(struct dc_link *link) static bool wait_for_alt_mode(struct dc_link *link)
{ {
/** /**
* something is terribly wrong if time out is > 200ms. (5Hz) * something is terribly wrong if time out is > 200ms. (5Hz)
* 500 microseconds * 400 tries us 200 ms * 500 microseconds * 400 tries us 200 ms
...@@ -697,7 +697,7 @@ static bool wait_for_alt_mode(struct dc_link *link) ...@@ -697,7 +697,7 @@ static bool wait_for_alt_mode(struct dc_link *link)
DC_LOGGER_INIT(link->ctx->logger); DC_LOGGER_INIT(link->ctx->logger);
if (link->link_enc->funcs->is_in_alt_mode == NULL) if (!link->link_enc->funcs->is_in_alt_mode)
return true; return true;
is_in_alt_mode = link->link_enc->funcs->is_in_alt_mode(link->link_enc); is_in_alt_mode = link->link_enc->funcs->is_in_alt_mode(link->link_enc);
...@@ -712,15 +712,15 @@ static bool wait_for_alt_mode(struct dc_link *link) ...@@ -712,15 +712,15 @@ static bool wait_for_alt_mode(struct dc_link *link)
udelay(sleep_time_in_microseconds); udelay(sleep_time_in_microseconds);
/* ask the link if alt mode is enabled, if so return ok */ /* ask the link if alt mode is enabled, if so return ok */
if (link->link_enc->funcs->is_in_alt_mode(link->link_enc)) { if (link->link_enc->funcs->is_in_alt_mode(link->link_enc)) {
finish_timestamp = dm_get_timestamp(link->ctx); finish_timestamp = dm_get_timestamp(link->ctx);
time_taken_in_ns = dm_get_elapse_time_in_ns( time_taken_in_ns =
link->ctx, finish_timestamp, enter_timestamp); dm_get_elapse_time_in_ns(link->ctx,
finish_timestamp,
enter_timestamp);
DC_LOG_WARNING("Alt mode entered finished after %llu ms\n", DC_LOG_WARNING("Alt mode entered finished after %llu ms\n",
div_u64(time_taken_in_ns, 1000000)); div_u64(time_taken_in_ns, 1000000));
return true; return true;
} }
} }
finish_timestamp = dm_get_timestamp(link->ctx); finish_timestamp = dm_get_timestamp(link->ctx);
time_taken_in_ns = dm_get_elapse_time_in_ns(link->ctx, finish_timestamp, time_taken_in_ns = dm_get_elapse_time_in_ns(link->ctx, finish_timestamp,
...@@ -764,28 +764,28 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -764,28 +764,28 @@ static bool dc_link_detect_helper(struct dc_link *link,
if ((link->connector_signal == SIGNAL_TYPE_LVDS || if ((link->connector_signal == SIGNAL_TYPE_LVDS ||
link->connector_signal == SIGNAL_TYPE_EDP) && link->connector_signal == SIGNAL_TYPE_EDP) &&
link->local_sink) { link->local_sink) {
// need to re-write OUI and brightness in resume case // need to re-write OUI and brightness in resume case
if (link->connector_signal == SIGNAL_TYPE_EDP) { if (link->connector_signal == SIGNAL_TYPE_EDP) {
dpcd_set_source_specific_data(link); dpcd_set_source_specific_data(link);
dc_link_set_default_brightness_aux(link); //TODO: use cached dc_link_set_default_brightness_aux(link);
//TODO: use cached
} }
return true; return true;
} }
if (false == dc_link_detect_sink(link, &new_connection_type)) { if (!dc_link_detect_sink(link, &new_connection_type)) {
BREAK_TO_DEBUGGER(); BREAK_TO_DEBUGGER();
return false; return false;
} }
prev_sink = link->local_sink; prev_sink = link->local_sink;
if (prev_sink != NULL) { if (prev_sink) {
dc_sink_retain(prev_sink); dc_sink_retain(prev_sink);
memcpy(&prev_dpcd_caps, &link->dpcd_caps, sizeof(struct dpcd_caps)); memcpy(&prev_dpcd_caps, &link->dpcd_caps, sizeof(struct dpcd_caps));
} }
link_disconnect_sink(link);
link_disconnect_sink(link);
if (new_connection_type != dc_connection_none) { if (new_connection_type != dc_connection_none) {
link->type = new_connection_type; link->type = new_connection_type;
link->link_state_valid = false; link->link_state_valid = false;
...@@ -832,35 +832,31 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -832,35 +832,31 @@ static bool dc_link_detect_helper(struct dc_link *link,
} }
case SIGNAL_TYPE_DISPLAY_PORT: { case SIGNAL_TYPE_DISPLAY_PORT: {
/* wa HPD high coming too early*/ /* wa HPD high coming too early*/
if (link->link_enc->features.flags.bits.DP_IS_USB_C == 1) { if (link->link_enc->features.flags.bits.DP_IS_USB_C == 1) {
/* if alt mode times out, return false */ /* if alt mode times out, return false */
if (wait_for_alt_mode(link) == false) { if (!wait_for_alt_mode(link))
return false; return false;
} }
}
if (!detect_dp( if (!detect_dp(link, &sink_caps,
link,
&sink_caps,
&converter_disable_audio, &converter_disable_audio,
aud_support, reason)) { aud_support, reason)) {
if (prev_sink != NULL) if (prev_sink)
dc_sink_release(prev_sink); dc_sink_release(prev_sink);
return false; return false;
} }
// Check if dpcp block is the same // Check if dpcp block is the same
if (prev_sink != NULL) { if (prev_sink) {
if (memcmp(&link->dpcd_caps, &prev_dpcd_caps, sizeof(struct dpcd_caps))) if (memcmp(&link->dpcd_caps, &prev_dpcd_caps,
sizeof(struct dpcd_caps)))
same_dpcd = false; same_dpcd = false;
} }
/* Active dongle downstream unplug*/ /* Active dongle downstream unplug*/
if (link->type == dc_connection_active_dongle && if (link->type == dc_connection_active_dongle &&
link->dpcd_caps.sink_count.bits.SINK_COUNT == 0) { link->dpcd_caps.sink_count.bits.SINK_COUNT == 0) {
if (prev_sink != NULL) if (prev_sink)
/* Downstream unplug */ /* Downstream unplug */
dc_sink_release(prev_sink); dc_sink_release(prev_sink);
return true; return true;
...@@ -876,15 +872,15 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -876,15 +872,15 @@ static bool dc_link_detect_helper(struct dc_link *link,
*/ */
dp_verify_mst_link_cap(link); dp_verify_mst_link_cap(link);
if (prev_sink != NULL) if (prev_sink)
dc_sink_release(prev_sink); dc_sink_release(prev_sink);
return false; return false;
} }
// For seamless boot, to skip verify link cap, we read UEFI settings and set them as verified. // For seamless boot, to skip verify link cap, we read UEFI settings and set them as verified.
if (reason == DETECT_REASON_BOOT && if (reason == DETECT_REASON_BOOT &&
dc_ctx->dc->config.power_down_display_on_boot == false && !dc_ctx->dc->config.power_down_display_on_boot &&
link->link_status.link_active == true) link->link_status.link_active)
perform_dp_seamless_boot = true; perform_dp_seamless_boot = true;
if (perform_dp_seamless_boot) { if (perform_dp_seamless_boot) {
...@@ -898,23 +894,22 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -898,23 +894,22 @@ static bool dc_link_detect_helper(struct dc_link *link,
default: default:
DC_ERROR("Invalid connector type! signal:%d\n", DC_ERROR("Invalid connector type! signal:%d\n",
link->connector_signal); link->connector_signal);
if (prev_sink != NULL) if (prev_sink)
dc_sink_release(prev_sink); dc_sink_release(prev_sink);
return false; return false;
} /* switch() */ } /* switch() */
if (link->dpcd_caps.sink_count.bits.SINK_COUNT) if (link->dpcd_caps.sink_count.bits.SINK_COUNT)
link->dpcd_sink_count = link->dpcd_caps.sink_count. link->dpcd_sink_count =
bits.SINK_COUNT; link->dpcd_caps.sink_count.bits.SINK_COUNT;
else else
link->dpcd_sink_count = 1; link->dpcd_sink_count = 1;
dal_ddc_service_set_transaction_type( dal_ddc_service_set_transaction_type(link->ddc,
link->ddc,
sink_caps.transaction_type); sink_caps.transaction_type);
link->aux_mode = dal_ddc_service_is_in_aux_transaction_mode( link->aux_mode =
link->ddc); dal_ddc_service_is_in_aux_transaction_mode(link->ddc);
sink_init_data.link = link; sink_init_data.link = link;
sink_init_data.sink_signal = sink_caps.signal; sink_init_data.sink_signal = sink_caps.signal;
...@@ -922,7 +917,7 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -922,7 +917,7 @@ static bool dc_link_detect_helper(struct dc_link *link,
sink = dc_sink_create(&sink_init_data); sink = dc_sink_create(&sink_init_data);
if (!sink) { if (!sink) {
DC_ERROR("Failed to create sink!\n"); DC_ERROR("Failed to create sink!\n");
if (prev_sink != NULL) if (prev_sink)
dc_sink_release(prev_sink); dc_sink_release(prev_sink);
return false; return false;
} }
...@@ -933,10 +928,8 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -933,10 +928,8 @@ static bool dc_link_detect_helper(struct dc_link *link,
/* dc_sink_create returns a new reference */ /* dc_sink_create returns a new reference */
link->local_sink = sink; link->local_sink = sink;
edid_status = dm_helpers_read_local_edid( edid_status = dm_helpers_read_local_edid(link->ctx,
link->ctx, link, sink);
link,
sink);
switch (edid_status) { switch (edid_status) {
case EDID_BAD_CHECKSUM: case EDID_BAD_CHECKSUM:
...@@ -944,7 +937,6 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -944,7 +937,6 @@ static bool dc_link_detect_helper(struct dc_link *link,
break; break;
case EDID_NO_RESPONSE: case EDID_NO_RESPONSE:
DC_LOG_ERROR("No EDID read.\n"); DC_LOG_ERROR("No EDID read.\n");
/* /*
* Abort detection for non-DP connectors if we have * Abort detection for non-DP connectors if we have
* no EDID * no EDID
...@@ -955,7 +947,7 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -955,7 +947,7 @@ static bool dc_link_detect_helper(struct dc_link *link,
*/ */
if (dc_is_hdmi_signal(link->connector_signal) || if (dc_is_hdmi_signal(link->connector_signal) ||
dc_is_dvi_signal(link->connector_signal)) { dc_is_dvi_signal(link->connector_signal)) {
if (prev_sink != NULL) if (prev_sink)
dc_sink_release(prev_sink); dc_sink_release(prev_sink);
return false; return false;
...@@ -968,14 +960,17 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -968,14 +960,17 @@ static bool dc_link_detect_helper(struct dc_link *link,
link->ctx->dc->debug.disable_fec = true; link->ctx->dc->debug.disable_fec = true;
// Check if edid is the same // Check if edid is the same
if ((prev_sink != NULL) && ((edid_status == EDID_THE_SAME) || (edid_status == EDID_OK))) if ((prev_sink) &&
same_edid = is_same_edid(&prev_sink->dc_edid, &sink->dc_edid); (edid_status == EDID_THE_SAME || edid_status == EDID_OK))
same_edid = is_same_edid(&prev_sink->dc_edid,
&sink->dc_edid);
if (sink->edid_caps.panel_patch.skip_scdc_overwrite) if (sink->edid_caps.panel_patch.skip_scdc_overwrite)
link->ctx->dc->debug.hdmi20_disable = true; link->ctx->dc->debug.hdmi20_disable = true;
if (link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT && if (link->connector_signal == SIGNAL_TYPE_DISPLAY_PORT &&
sink_caps.transaction_type == DDC_TRANSACTION_TYPE_I2C_OVER_AUX) { sink_caps.transaction_type ==
DDC_TRANSACTION_TYPE_I2C_OVER_AUX) {
/* /*
* TODO debug why Dell 2413 doesn't like * TODO debug why Dell 2413 doesn't like
* two link trainings * two link trainings
...@@ -992,7 +987,6 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -992,7 +987,6 @@ static bool dc_link_detect_helper(struct dc_link *link,
link_disconnect_remap(prev_sink, link); link_disconnect_remap(prev_sink, link);
sink = prev_sink; sink = prev_sink;
prev_sink = NULL; prev_sink = NULL;
} }
} }
...@@ -1041,7 +1035,6 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -1041,7 +1035,6 @@ static bool dc_link_detect_helper(struct dc_link *link,
sink->edid_caps.audio_modes[i].sample_rate, sink->edid_caps.audio_modes[i].sample_rate,
sink->edid_caps.audio_modes[i].sample_size); sink->edid_caps.audio_modes[i].sample_size);
} }
} else { } else {
/* From Connected-to-Disconnected. */ /* From Connected-to-Disconnected. */
if (link->type == dc_connection_mst_branch) { if (link->type == dc_connection_mst_branch) {
...@@ -1051,7 +1044,9 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -1051,7 +1044,9 @@ static bool dc_link_detect_helper(struct dc_link *link,
dm_helpers_dp_mst_stop_top_mgr(link->ctx, link); dm_helpers_dp_mst_stop_top_mgr(link->ctx, link);
link->mst_stream_alloc_table.stream_count = 0; link->mst_stream_alloc_table.stream_count = 0;
memset(link->mst_stream_alloc_table.stream_allocations, 0, sizeof(link->mst_stream_alloc_table.stream_allocations)); memset(link->mst_stream_alloc_table.stream_allocations,
0,
sizeof(link->mst_stream_alloc_table.stream_allocations));
} }
link->type = dc_connection_none; link->type = dc_connection_none;
...@@ -1066,15 +1061,14 @@ static bool dc_link_detect_helper(struct dc_link *link, ...@@ -1066,15 +1061,14 @@ static bool dc_link_detect_helper(struct dc_link *link,
LINK_INFO("link=%d, dc_sink_in=%p is now %s prev_sink=%p dpcd same=%d edid same=%d\n", LINK_INFO("link=%d, dc_sink_in=%p is now %s prev_sink=%p dpcd same=%d edid same=%d\n",
link->link_index, sink, link->link_index, sink,
(sink_caps.signal == SIGNAL_TYPE_NONE ? (sink_caps.signal ==
"Disconnected":"Connected"), prev_sink, SIGNAL_TYPE_NONE ? "Disconnected" : "Connected"),
same_dpcd, same_edid); prev_sink, same_dpcd, same_edid);
if (prev_sink != NULL) if (prev_sink)
dc_sink_release(prev_sink); dc_sink_release(prev_sink);
return true; return true;
} }
bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason) bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment