Commit cc195141 authored by Shirish S's avatar Shirish S Committed by Alex Deucher

drm/amd/display: make dm_dp_aux_transfer return payload bytes instead of size

The drm layer expects aux->transfer() to return the payload bytes read.
Currently dm_dp_aux_transfer() returns the payload size which does not
gets updated during the read, hence not giving the right data for the
drm layer to pars edid. This leads to the drm layer to conclude as the
edid is BAD and hence some monitors/devices dont get detected properly.

This patch changes the return type of dm_dp_aux_transfer() to actual
bytes read during DP_AUX_NATIVE_READ & DP_AUX_I2C_READ.
Signed-off-by: default avatarShirish S <shirish.s@amd.com>
Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 9f0178fb
...@@ -83,17 +83,18 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, ...@@ -83,17 +83,18 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
enum i2c_mot_mode mot = (msg->request & DP_AUX_I2C_MOT) ? enum i2c_mot_mode mot = (msg->request & DP_AUX_I2C_MOT) ?
I2C_MOT_TRUE : I2C_MOT_FALSE; I2C_MOT_TRUE : I2C_MOT_FALSE;
enum ddc_result res; enum ddc_result res;
ssize_t read_bytes;
switch (msg->request & ~DP_AUX_I2C_MOT) { switch (msg->request & ~DP_AUX_I2C_MOT) {
case DP_AUX_NATIVE_READ: case DP_AUX_NATIVE_READ:
res = dal_ddc_service_read_dpcd_data( read_bytes = dal_ddc_service_read_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
false, false,
I2C_MOT_UNDEF, I2C_MOT_UNDEF,
msg->address, msg->address,
msg->buffer, msg->buffer,
msg->size); msg->size);
break; return read_bytes;
case DP_AUX_NATIVE_WRITE: case DP_AUX_NATIVE_WRITE:
res = dal_ddc_service_write_dpcd_data( res = dal_ddc_service_write_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
...@@ -104,14 +105,14 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, ...@@ -104,14 +105,14 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
msg->size); msg->size);
break; break;
case DP_AUX_I2C_READ: case DP_AUX_I2C_READ:
res = dal_ddc_service_read_dpcd_data( read_bytes = dal_ddc_service_read_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
true, true,
mot, mot,
msg->address, msg->address,
msg->buffer, msg->buffer,
msg->size); msg->size);
break; return read_bytes;
case DP_AUX_I2C_WRITE: case DP_AUX_I2C_WRITE:
res = dal_ddc_service_write_dpcd_data( res = dal_ddc_service_write_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
......
...@@ -629,7 +629,7 @@ bool dal_ddc_service_query_ddc_data( ...@@ -629,7 +629,7 @@ bool dal_ddc_service_query_ddc_data(
return ret; return ret;
} }
enum ddc_result dal_ddc_service_read_dpcd_data( ssize_t dal_ddc_service_read_dpcd_data(
struct ddc_service *ddc, struct ddc_service *ddc,
bool i2c, bool i2c,
enum i2c_mot_mode mot, enum i2c_mot_mode mot,
...@@ -660,8 +660,9 @@ enum ddc_result dal_ddc_service_read_dpcd_data( ...@@ -660,8 +660,9 @@ enum ddc_result dal_ddc_service_read_dpcd_data(
if (dal_i2caux_submit_aux_command( if (dal_i2caux_submit_aux_command(
ddc->ctx->i2caux, ddc->ctx->i2caux,
ddc->ddc_pin, ddc->ddc_pin,
&command)) &command)) {
return DDC_RESULT_SUCESSFULL; return (ssize_t)command.payloads->length;
}
return DDC_RESULT_FAILED_OPERATION; return DDC_RESULT_FAILED_OPERATION;
} }
......
...@@ -126,20 +126,8 @@ static void process_read_reply( ...@@ -126,20 +126,8 @@ static void process_read_reply(
ctx->status = ctx->status =
I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR; I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR;
ctx->operation_succeeded = false; ctx->operation_succeeded = false;
} else if (ctx->returned_byte < ctx->current_read_length) {
ctx->current_read_length -= ctx->returned_byte;
ctx->offset += ctx->returned_byte;
++ctx->invalid_reply_retry_aux_on_ack;
if (ctx->invalid_reply_retry_aux_on_ack >
AUX_INVALID_REPLY_RETRY_COUNTER) {
ctx->status =
I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR;
ctx->operation_succeeded = false;
}
} else { } else {
ctx->current_read_length = ctx->returned_byte;
ctx->status = I2CAUX_TRANSACTION_STATUS_SUCCEEDED; ctx->status = I2CAUX_TRANSACTION_STATUS_SUCCEEDED;
ctx->transaction_complete = true; ctx->transaction_complete = true;
ctx->operation_succeeded = true; ctx->operation_succeeded = true;
...@@ -292,6 +280,7 @@ static bool read_command( ...@@ -292,6 +280,7 @@ static bool read_command(
ctx.operation_succeeded); ctx.operation_succeeded);
} }
request->payload.length = ctx.reply.length;
return ctx.operation_succeeded; return ctx.operation_succeeded;
} }
......
...@@ -253,6 +253,7 @@ bool dal_i2caux_submit_aux_command( ...@@ -253,6 +253,7 @@ bool dal_i2caux_submit_aux_command(
break; break;
} }
cmd->payloads->length = request.payload.length;
++index_of_payload; ++index_of_payload;
} }
......
...@@ -102,7 +102,7 @@ bool dal_ddc_service_query_ddc_data( ...@@ -102,7 +102,7 @@ bool dal_ddc_service_query_ddc_data(
uint8_t *read_buf, uint8_t *read_buf,
uint32_t read_size); uint32_t read_size);
enum ddc_result dal_ddc_service_read_dpcd_data( ssize_t dal_ddc_service_read_dpcd_data(
struct ddc_service *ddc, struct ddc_service *ddc,
bool i2c, bool i2c,
enum i2c_mot_mode mot, enum i2c_mot_mode mot,
......
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