Commit 084b3765 authored by Harry Wentland's avatar Harry Wentland Committed by Alex Deucher

drm/amd/display: Return aux replies directly to DRM

Currently we still go through DC code that does error checking, retries,
etc. There's no need for that since DRM already does that for us. This
simplifies the code a bit and makes it easier to debug.

This also ensures we correctly tell DRM how many bytes have actually
been read, as we should. This allows DRM to correctly read the EDID on
the Chamelium DP port.
Signed-off-by: default avatarHarry Wentland <harry.wentland@amd.com>
Reviewed-by: default avatarTony Cheng <Tony.Cheng@amd.com>
Acked-by: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 899e2aad
...@@ -80,52 +80,72 @@ static void log_dpcd(uint8_t type, ...@@ -80,52 +80,72 @@ static void log_dpcd(uint8_t type,
static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
struct drm_dp_aux_msg *msg) struct drm_dp_aux_msg *msg)
{ {
enum i2c_mot_mode mot = (msg->request & DP_AUX_I2C_MOT) ? ssize_t result = 0;
I2C_MOT_TRUE : I2C_MOT_FALSE; enum i2caux_transaction_action action;
enum ddc_result res; enum aux_transaction_type type;
if (WARN_ON(msg->size > 16)) if (WARN_ON(msg->size > 16))
return -E2BIG; return -E2BIG;
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( type = AUX_TRANSACTION_TYPE_DP;
TO_DM_AUX(aux)->ddc_service, action = I2CAUX_TRANSACTION_ACTION_DP_READ;
false,
I2C_MOT_UNDEF, result = dc_link_aux_transfer(TO_DM_AUX(aux)->ddc_service,
msg->address, msg->address,
msg->buffer, &msg->reply,
msg->size); msg->buffer,
msg->size,
type,
action);
break; break;
case DP_AUX_NATIVE_WRITE: case DP_AUX_NATIVE_WRITE:
res = dal_ddc_service_write_dpcd_data( type = AUX_TRANSACTION_TYPE_DP;
TO_DM_AUX(aux)->ddc_service, action = I2CAUX_TRANSACTION_ACTION_DP_WRITE;
false,
I2C_MOT_UNDEF, dc_link_aux_transfer(TO_DM_AUX(aux)->ddc_service,
msg->address, msg->address,
msg->buffer, &msg->reply,
msg->size); msg->buffer,
msg->size,
type,
action);
result = msg->size;
break; break;
case DP_AUX_I2C_READ: case DP_AUX_I2C_READ:
res = dal_ddc_service_read_dpcd_data( type = AUX_TRANSACTION_TYPE_I2C;
TO_DM_AUX(aux)->ddc_service, if (msg->request & DP_AUX_I2C_MOT)
true, action = I2CAUX_TRANSACTION_ACTION_I2C_READ_MOT;
mot, else
msg->address, action = I2CAUX_TRANSACTION_ACTION_I2C_READ;
msg->buffer,
msg->size); result = dc_link_aux_transfer(TO_DM_AUX(aux)->ddc_service,
msg->address,
&msg->reply,
msg->buffer,
msg->size,
type,
action);
break; break;
case DP_AUX_I2C_WRITE: case DP_AUX_I2C_WRITE:
res = dal_ddc_service_write_dpcd_data( type = AUX_TRANSACTION_TYPE_I2C;
TO_DM_AUX(aux)->ddc_service, if (msg->request & DP_AUX_I2C_MOT)
true, action = I2CAUX_TRANSACTION_ACTION_I2C_WRITE_MOT;
mot, else
msg->address, action = I2CAUX_TRANSACTION_ACTION_I2C_WRITE;
msg->buffer,
msg->size); dc_link_aux_transfer(TO_DM_AUX(aux)->ddc_service,
msg->address,
&msg->reply,
msg->buffer,
msg->size,
type,
action);
result = msg->size;
break; break;
default: default:
return 0; return -EINVAL;
} }
#ifdef TRACE_DPCD #ifdef TRACE_DPCD
...@@ -136,7 +156,10 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, ...@@ -136,7 +156,10 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
r == DDC_RESULT_SUCESSFULL); r == DDC_RESULT_SUCESSFULL);
#endif #endif
return msg->size; if (result < 0) /* DC doesn't know about kernel error codes */
result = -EIO;
return result;
} }
static enum drm_connector_status static enum drm_connector_status
......
...@@ -33,6 +33,10 @@ ...@@ -33,6 +33,10 @@
#include "include/vector.h" #include "include/vector.h"
#include "core_types.h" #include "core_types.h"
#include "dc_link_ddc.h" #include "dc_link_ddc.h"
#include "i2caux/engine.h"
#include "i2caux/i2c_engine.h"
#include "i2caux/aux_engine.h"
#include "i2caux/i2caux.h"
#define AUX_POWER_UP_WA_DELAY 500 #define AUX_POWER_UP_WA_DELAY 500
#define I2C_OVER_AUX_DEFER_WA_DELAY 70 #define I2C_OVER_AUX_DEFER_WA_DELAY 70
...@@ -629,78 +633,62 @@ bool dal_ddc_service_query_ddc_data( ...@@ -629,78 +633,62 @@ bool dal_ddc_service_query_ddc_data(
return ret; return ret;
} }
enum ddc_result dal_ddc_service_read_dpcd_data( int dc_link_aux_transfer(struct ddc_service *ddc,
struct ddc_service *ddc, unsigned int address,
bool i2c, uint8_t *reply,
enum i2c_mot_mode mot, void *buffer,
uint32_t address, unsigned int size,
uint8_t *data, enum aux_transaction_type type,
uint32_t len) enum i2caux_transaction_action action)
{ {
struct aux_payload read_payload = { struct i2caux *i2caux = ddc->ctx->i2caux;
.i2c_over_aux = i2c, struct ddc *ddc_pin = ddc->ddc_pin;
.write = false, struct aux_engine *engine;
.address = address, enum aux_channel_operation_result operation_result;
.length = len, struct aux_request_transaction_data aux_req;
.data = data, struct aux_reply_transaction_data aux_rep;
}; uint8_t returned_bytes = 0;
struct aux_command command = { int res = -1;
.payloads = &read_payload, uint32_t status;
.number_of_payloads = 1,
.defer_delay = 0,
.max_defer_write_retry = 0,
.mot = mot
};
if (len > DEFAULT_AUX_MAX_DATA_SIZE) {
BREAK_TO_DEBUGGER();
return DDC_RESULT_FAILED_INVALID_OPERATION;
}
if (dal_i2caux_submit_aux_command( memset(&aux_req, 0, sizeof(aux_req));
ddc->ctx->i2caux, memset(&aux_rep, 0, sizeof(aux_rep));
ddc->ddc_pin,
&command))
return DDC_RESULT_SUCESSFULL;
return DDC_RESULT_FAILED_OPERATION; engine = i2caux->funcs->acquire_aux_engine(i2caux, ddc_pin);
}
enum ddc_result dal_ddc_service_write_dpcd_data( aux_req.type = type;
struct ddc_service *ddc, aux_req.action = action;
bool i2c,
enum i2c_mot_mode mot, aux_req.address = address;
uint32_t address, aux_req.delay = 0;
const uint8_t *data, aux_req.length = size;
uint32_t len) aux_req.data = buffer;
{
struct aux_payload write_payload = { engine->funcs->submit_channel_request(engine, &aux_req);
.i2c_over_aux = i2c, operation_result = engine->funcs->get_channel_status(engine, &returned_bytes);
.write = true,
.address = address,
.length = len,
.data = (uint8_t *)data,
};
struct aux_command command = {
.payloads = &write_payload,
.number_of_payloads = 1,
.defer_delay = 0,
.max_defer_write_retry = 0,
.mot = mot
};
if (len > DEFAULT_AUX_MAX_DATA_SIZE) {
BREAK_TO_DEBUGGER();
return DDC_RESULT_FAILED_INVALID_OPERATION;
}
if (dal_i2caux_submit_aux_command( switch (operation_result) {
ddc->ctx->i2caux, case AUX_CHANNEL_OPERATION_SUCCEEDED:
ddc->ddc_pin, res = returned_bytes;
&command))
return DDC_RESULT_SUCESSFULL; if (res <= size && res > 0)
res = engine->funcs->read_channel_reply(engine, size,
buffer, reply,
&status);
break;
case AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON:
res = 0;
break;
case AUX_CHANNEL_OPERATION_FAILED_REASON_UNKNOWN:
case AUX_CHANNEL_OPERATION_FAILED_INVALID_REPLY:
case AUX_CHANNEL_OPERATION_FAILED_TIMEOUT:
res = -1;
break;
}
return DDC_RESULT_FAILED_OPERATION; i2caux->funcs->release_engine(i2caux, &engine->base);
return res;
} }
/*test only function*/ /*test only function*/
......
...@@ -102,21 +102,13 @@ bool dal_ddc_service_query_ddc_data( ...@@ -102,21 +102,13 @@ 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( int dc_link_aux_transfer(struct ddc_service *ddc,
struct ddc_service *ddc, unsigned int address,
bool i2c, uint8_t *reply,
enum i2c_mot_mode mot, void *buffer,
uint32_t address, unsigned int size,
uint8_t *data, enum aux_transaction_type type,
uint32_t len); enum i2caux_transaction_action action);
enum ddc_result dal_ddc_service_write_dpcd_data(
struct ddc_service *ddc,
bool i2c,
enum i2c_mot_mode mot,
uint32_t address,
const uint8_t *data,
uint32_t len);
void dal_ddc_service_write_scdc_data( void dal_ddc_service_write_scdc_data(
struct ddc_service *ddc_service, struct ddc_service *ddc_service,
......
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