drm/dp: add helper for reading DP sink/branch device desc from DPCD
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/acba54da7d80eafea9e59a893e27e3c31028c0ba.1495105635.git.jani.nikula@intel.com
This commit is contained in:
Родитель
5ed02dbb49
Коммит
118b90f3f1
|
@ -1208,3 +1208,38 @@ int drm_dp_stop_crc(struct drm_dp_aux *aux)
|
|||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(drm_dp_stop_crc);
|
||||
|
||||
/**
|
||||
* drm_dp_read_desc - read sink/branch descriptor from DPCD
|
||||
* @aux: DisplayPort AUX channel
|
||||
* @desc: Device decriptor to fill from DPCD
|
||||
* @is_branch: true for branch devices, false for sink devices
|
||||
*
|
||||
* Read DPCD 0x400 (sink) or 0x500 (branch) into @desc. Also debug log the
|
||||
* identification.
|
||||
*
|
||||
* Returns 0 on success or a negative error code on failure.
|
||||
*/
|
||||
int drm_dp_read_desc(struct drm_dp_aux *aux, struct drm_dp_desc *desc,
|
||||
bool is_branch)
|
||||
{
|
||||
struct drm_dp_dpcd_ident *ident = &desc->ident;
|
||||
unsigned int offset = is_branch ? DP_BRANCH_OUI : DP_SINK_OUI;
|
||||
int ret, dev_id_len;
|
||||
|
||||
ret = drm_dp_dpcd_read(aux, offset, ident, sizeof(*ident));
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
dev_id_len = strnlen(ident->device_id, sizeof(ident->device_id));
|
||||
|
||||
DRM_DEBUG_KMS("DP %s: OUI %*phD dev-ID %*pE HW-rev %d.%d SW-rev %d.%d\n",
|
||||
is_branch ? "branch" : "sink",
|
||||
(int)sizeof(ident->oui), ident->oui,
|
||||
dev_id_len, ident->device_id,
|
||||
ident->hw_rev >> 4, ident->hw_rev & 0xf,
|
||||
ident->sw_major_rev, ident->sw_minor_rev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(drm_dp_read_desc);
|
||||
|
|
|
@ -913,4 +913,23 @@ void drm_dp_aux_unregister(struct drm_dp_aux *aux);
|
|||
int drm_dp_start_crc(struct drm_dp_aux *aux, struct drm_crtc *crtc);
|
||||
int drm_dp_stop_crc(struct drm_dp_aux *aux);
|
||||
|
||||
struct drm_dp_dpcd_ident {
|
||||
u8 oui[3];
|
||||
u8 device_id[6];
|
||||
u8 hw_rev;
|
||||
u8 sw_major_rev;
|
||||
u8 sw_minor_rev;
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* struct drm_dp_desc - DP branch/sink device descriptor
|
||||
* @ident: DP device identification from DPCD 0x400 (sink) or 0x500 (branch).
|
||||
*/
|
||||
struct drm_dp_desc {
|
||||
struct drm_dp_dpcd_ident ident;
|
||||
};
|
||||
|
||||
int drm_dp_read_desc(struct drm_dp_aux *aux, struct drm_dp_desc *desc,
|
||||
bool is_branch);
|
||||
|
||||
#endif /* _DRM_DP_HELPER_H_ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче