Commit d8bb92e7 authored by Imre Deak's avatar Imre Deak

drm/dp: Factor out a function to probe a DPCD address

Factor out from drm_dp_dpcd_read() a function to probe a DPCD address
with a 1-byte read access. This will be needed by the next patch doing a
read from an LTTPR address, which must happen without the preceding
wake-up read in drm_dp_dpcd_read().

While at it add tracing for the 1 byte read even if the read was
successful.

v2: Add a probe function instead of exporting drm_dp_dpcd_access(). (Jani)
v3: Add tracing for the 1-byte read even if the read was successful. (Khaled)

Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Khaled Almahallawy <khaled.almahallawy@intel.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220411132539.984647-1-imre.deak@intel.com
parent f1e4c916
...@@ -527,6 +527,31 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request, ...@@ -527,6 +527,31 @@ static int drm_dp_dpcd_access(struct drm_dp_aux *aux, u8 request,
return ret; return ret;
} }
/**
* drm_dp_dpcd_probe() - probe a given DPCD address with a 1-byte read access
* @aux: DisplayPort AUX channel (SST)
* @offset: address of the register to probe
*
* Probe the provided DPCD address by reading 1 byte from it. The function can
* be used to trigger some side-effect the read access has, like waking up the
* sink, without the need for the read-out value.
*
* Returns 0 if the read access suceeded, or a negative error code on failure.
*/
int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset)
{
u8 buffer;
int ret;
ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, 1);
WARN_ON(ret == 0);
drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, &buffer, ret);
return ret < 0 ? ret : 0;
}
EXPORT_SYMBOL(drm_dp_dpcd_probe);
/** /**
* drm_dp_dpcd_read() - read a series of bytes from the DPCD * drm_dp_dpcd_read() - read a series of bytes from the DPCD
* @aux: DisplayPort AUX channel (SST or MST) * @aux: DisplayPort AUX channel (SST or MST)
...@@ -559,10 +584,9 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, ...@@ -559,10 +584,9 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
* monitor doesn't power down exactly after the throw away read. * monitor doesn't power down exactly after the throw away read.
*/ */
if (!aux->is_remote) { if (!aux->is_remote) {
ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, DP_DPCD_REV, ret = drm_dp_dpcd_probe(aux, DP_DPCD_REV);
buffer, 1); if (ret < 0)
if (ret != 1) return ret;
goto out;
} }
if (aux->is_remote) if (aux->is_remote)
...@@ -571,7 +595,6 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, ...@@ -571,7 +595,6 @@ ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset, ret = drm_dp_dpcd_access(aux, DP_AUX_NATIVE_READ, offset,
buffer, size); buffer, size);
out:
drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret); drm_dp_dump_access(aux, DP_AUX_NATIVE_READ, offset, buffer, ret);
return ret; return ret;
} }
......
...@@ -2053,6 +2053,7 @@ struct drm_dp_aux { ...@@ -2053,6 +2053,7 @@ struct drm_dp_aux {
bool is_remote; bool is_remote;
}; };
int drm_dp_dpcd_probe(struct drm_dp_aux *aux, unsigned int offset);
ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset, ssize_t drm_dp_dpcd_read(struct drm_dp_aux *aux, unsigned int offset,
void *buffer, size_t size); void *buffer, size_t size);
ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset, ssize_t drm_dp_dpcd_write(struct drm_dp_aux *aux, unsigned int offset,
......
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