Message ID | 1465219753-3737-3-git-send-email-mika.kahola@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Jun 06, 2016 at 04:29:04PM +0300, Mika Kahola wrote: > Read DisplayPort downstream port capabilities. Depending on > the DP port the capabilities are defined in length of 1 byte > or 4 bytes depending if the detailed capability information is > available. > > Signed-off-by: Mika Kahola <mika.kahola@intel.com> > --- > drivers/gpu/drm/drm_dp_helper.c | 27 +++++++++++++++++++++++++++ > include/drm/drm_dp_helper.h | 3 +++ > 2 files changed, 30 insertions(+) > > diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c > index eeaf5a7..c4149fd 100644 > --- a/drivers/gpu/drm/drm_dp_helper.c > +++ b/drivers/gpu/drm/drm_dp_helper.c > @@ -438,6 +438,33 @@ int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link) > } > EXPORT_SYMBOL(drm_dp_link_configure); > > +/** > + * drm_dp_downstream_port_cap() - read downstream port capabilities > + * @dpcd: DisplayPort configuration data > + * @port_cap: port capabilities > + * > + * returns size of the port capabilites > + */ > +int drm_dp_downstream_port_cap(struct drm_dp_aux *aux, > + const u8 dpcd[DP_RECEIVER_CAP_SIZE], > + u8 port_cap[4]) > +{ > + int size; > + bool detailed_cap_info = dpcd[DP_DOWNSTREAMPORT_PRESENT] & > + DP_DETAILED_CAP_INFO_AVAILABLE; > + > + if (detailed_cap_info) { > + size = 4; > + drm_dp_dpcd_read(aux, DP_DOWNSTREAM_PORT_0, port_cap, size); > + } else { > + size = 1; > + drm_dp_dpcd_read(aux, DP_DOWNSTREAM_PORT_0, &port_cap[0], size); > + } Could avoid a bit of duplicatetion. Eg.: if (dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DETAILED_CAP_INFO_AVAILABLE) size = 4; else size = 1; return drm_dp_dpcd_read(...); Though perhaps we should just read out the entire 4/16 bytes to get the caps for all the ports? > + > + return size; > +} > +EXPORT_SYMBOL(drm_dp_downstream_port_cap); > + > /* > * I2C-over-AUX implementation > */ > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h > index e384c7f..db8d3d47 100644 > --- a/include/drm/drm_dp_helper.h > +++ b/include/drm/drm_dp_helper.h > @@ -806,6 +806,9 @@ int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link); > int drm_dp_link_power_up(struct drm_dp_aux *aux, struct drm_dp_link *link); > int drm_dp_link_power_down(struct drm_dp_aux *aux, struct drm_dp_link *link); > int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link); > +int drm_dp_downstream_port_cap(struct drm_dp_aux *aux, > + const u8 dpcd[DP_RECEIVER_CAP_SIZE], > + u8 port_cap[4]); > > int drm_dp_aux_register(struct drm_dp_aux *aux); > void drm_dp_aux_unregister(struct drm_dp_aux *aux); > -- > 1.9.1
diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index eeaf5a7..c4149fd 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -438,6 +438,33 @@ int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link) } EXPORT_SYMBOL(drm_dp_link_configure); +/** + * drm_dp_downstream_port_cap() - read downstream port capabilities + * @dpcd: DisplayPort configuration data + * @port_cap: port capabilities + * + * returns size of the port capabilites + */ +int drm_dp_downstream_port_cap(struct drm_dp_aux *aux, + const u8 dpcd[DP_RECEIVER_CAP_SIZE], + u8 port_cap[4]) +{ + int size; + bool detailed_cap_info = dpcd[DP_DOWNSTREAMPORT_PRESENT] & + DP_DETAILED_CAP_INFO_AVAILABLE; + + if (detailed_cap_info) { + size = 4; + drm_dp_dpcd_read(aux, DP_DOWNSTREAM_PORT_0, port_cap, size); + } else { + size = 1; + drm_dp_dpcd_read(aux, DP_DOWNSTREAM_PORT_0, &port_cap[0], size); + } + + return size; +} +EXPORT_SYMBOL(drm_dp_downstream_port_cap); + /* * I2C-over-AUX implementation */ diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h index e384c7f..db8d3d47 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h @@ -806,6 +806,9 @@ int drm_dp_link_probe(struct drm_dp_aux *aux, struct drm_dp_link *link); int drm_dp_link_power_up(struct drm_dp_aux *aux, struct drm_dp_link *link); int drm_dp_link_power_down(struct drm_dp_aux *aux, struct drm_dp_link *link); int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link); +int drm_dp_downstream_port_cap(struct drm_dp_aux *aux, + const u8 dpcd[DP_RECEIVER_CAP_SIZE], + u8 port_cap[4]); int drm_dp_aux_register(struct drm_dp_aux *aux); void drm_dp_aux_unregister(struct drm_dp_aux *aux);
Read DisplayPort downstream port capabilities. Depending on the DP port the capabilities are defined in length of 1 byte or 4 bytes depending if the detailed capability information is available. Signed-off-by: Mika Kahola <mika.kahola@intel.com> --- drivers/gpu/drm/drm_dp_helper.c | 27 +++++++++++++++++++++++++++ include/drm/drm_dp_helper.h | 3 +++ 2 files changed, 30 insertions(+)