Commit 26b4750d authored by Wenjing Liu's avatar Wenjing Liu Committed by Alex Deucher

drm/amd/display: allow query ddc data over aux to be read only operation

[why]
Two issues:
1. Add read only operation support for query ddc data over aux.
2. Fix a bug where if read size is multiple of 16,
mot of the last read transaction will not be set to 0.
Signed-off-by: default avatarWenjing Liu <wenjing.liu@amd.com>
Reviewed-by: default avatarJun Lei <Jun.Lei@amd.com>
Acked-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 8582aea2
...@@ -503,7 +503,7 @@ bool dal_ddc_service_query_ddc_data( ...@@ -503,7 +503,7 @@ bool dal_ddc_service_query_ddc_data(
uint8_t *read_buf, uint8_t *read_buf,
uint32_t read_size) uint32_t read_size)
{ {
bool ret = false; bool success = true;
uint32_t payload_size = uint32_t payload_size =
dal_ddc_service_is_in_aux_transaction_mode(ddc) ? dal_ddc_service_is_in_aux_transaction_mode(ddc) ?
DEFAULT_AUX_MAX_DATA_SIZE : EDID_SEGMENT_SIZE; DEFAULT_AUX_MAX_DATA_SIZE : EDID_SEGMENT_SIZE;
...@@ -527,7 +527,6 @@ bool dal_ddc_service_query_ddc_data( ...@@ -527,7 +527,6 @@ bool dal_ddc_service_query_ddc_data(
* but we want to read 256 over i2c!!!!*/ * but we want to read 256 over i2c!!!!*/
if (dal_ddc_service_is_in_aux_transaction_mode(ddc)) { if (dal_ddc_service_is_in_aux_transaction_mode(ddc)) {
struct aux_payload payload; struct aux_payload payload;
bool read_available = true;
payload.i2c_over_aux = true; payload.i2c_over_aux = true;
payload.address = address; payload.address = address;
...@@ -536,21 +535,26 @@ bool dal_ddc_service_query_ddc_data( ...@@ -536,21 +535,26 @@ bool dal_ddc_service_query_ddc_data(
if (write_size != 0) { if (write_size != 0) {
payload.write = true; payload.write = true;
payload.mot = false; /* should not set mot (middle of transaction) to 0
* if there are pending read payloads
*/
payload.mot = read_size == 0 ? false : true;
payload.length = write_size; payload.length = write_size;
payload.data = write_buf; payload.data = write_buf;
ret = dal_ddc_submit_aux_command(ddc, &payload); success = dal_ddc_submit_aux_command(ddc, &payload);
read_available = ret;
} }
if (read_size != 0 && read_available) { if (read_size != 0 && success) {
payload.write = false; payload.write = false;
/* should set mot (middle of transaction) to 0
* since it is the last payload to send
*/
payload.mot = false; payload.mot = false;
payload.length = read_size; payload.length = read_size;
payload.data = read_buf; payload.data = read_buf;
ret = dal_ddc_submit_aux_command(ddc, &payload); success = dal_ddc_submit_aux_command(ddc, &payload);
} }
} else { } else {
struct i2c_command command = {0}; struct i2c_command command = {0};
...@@ -573,7 +577,7 @@ bool dal_ddc_service_query_ddc_data( ...@@ -573,7 +577,7 @@ bool dal_ddc_service_query_ddc_data(
command.number_of_payloads = command.number_of_payloads =
dal_ddc_i2c_payloads_get_count(&payloads); dal_ddc_i2c_payloads_get_count(&payloads);
ret = dm_helpers_submit_i2c( success = dm_helpers_submit_i2c(
ddc->ctx, ddc->ctx,
ddc->link, ddc->link,
&command); &command);
...@@ -581,7 +585,7 @@ bool dal_ddc_service_query_ddc_data( ...@@ -581,7 +585,7 @@ bool dal_ddc_service_query_ddc_data(
dal_ddc_i2c_payloads_destroy(&payloads); dal_ddc_i2c_payloads_destroy(&payloads);
} }
return ret; return success;
} }
bool dal_ddc_submit_aux_command(struct ddc_service *ddc, bool dal_ddc_submit_aux_command(struct ddc_service *ddc,
...@@ -598,7 +602,7 @@ bool dal_ddc_submit_aux_command(struct ddc_service *ddc, ...@@ -598,7 +602,7 @@ bool dal_ddc_submit_aux_command(struct ddc_service *ddc,
do { do {
struct aux_payload current_payload; struct aux_payload current_payload;
bool is_end_of_payload = (retrieved + DEFAULT_AUX_MAX_DATA_SIZE) > bool is_end_of_payload = (retrieved + DEFAULT_AUX_MAX_DATA_SIZE) >=
payload->length; payload->length;
current_payload.address = payload->address; current_payload.address = payload->address;
...@@ -607,7 +611,10 @@ bool dal_ddc_submit_aux_command(struct ddc_service *ddc, ...@@ -607,7 +611,10 @@ bool dal_ddc_submit_aux_command(struct ddc_service *ddc,
current_payload.i2c_over_aux = payload->i2c_over_aux; current_payload.i2c_over_aux = payload->i2c_over_aux;
current_payload.length = is_end_of_payload ? current_payload.length = is_end_of_payload ?
payload->length - retrieved : DEFAULT_AUX_MAX_DATA_SIZE; payload->length - retrieved : DEFAULT_AUX_MAX_DATA_SIZE;
current_payload.mot = !is_end_of_payload; /* set mot (middle of transaction) to false
* if it is the last payload
*/
current_payload.mot = is_end_of_payload ? payload->mot:true;
current_payload.reply = payload->reply; current_payload.reply = payload->reply;
current_payload.write = payload->write; current_payload.write = payload->write;
......
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