Skip to content

Commit 8ef4cf6

Browse files
ideakgregkh
authored andcommitted
drm/dp/mst: Export drm_dp_get_vc_payload_bw()
commit 83404d5 upstream. This function will be needed by the next patch where the driver calculates the BW based on driver specific parameters, so export it. At the same time sanitize the function params, passing the more natural link rate instead of the encoding of the same rate. v2: - Fix function documentation. (Lyude) Cc: Lyude Paul <lyude@redhat.com> Cc: Ville Syrjala <ville.syrjala@intel.com> Cc: <stable@vger.kernel.org> Cc: dri-devel@lists.freedesktop.org Signed-off-by: Imre Deak <imre.deak@intel.com> Reviewed-by: Lyude Paul <lyude@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210125173636.1733812-1-imre.deak@intel.com (cherry picked from commit a321fc2) Signed-off-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4f627ec commit 8ef4cf6

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

‎drivers/gpu/drm/drm_dp_mst_topology.c‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3629,14 +3629,26 @@ static int drm_dp_send_up_ack_reply(struct drm_dp_mst_topology_mgr *mgr,
36293629
return 0;
36303630
}
36313631

3632-
static int drm_dp_get_vc_payload_bw(u8 dp_link_bw, u8 dp_link_count)
3632+
/**
3633+
* drm_dp_get_vc_payload_bw - get the VC payload BW for an MST link
3634+
* @link_rate: link rate in 10kbits/s units
3635+
* @link_lane_count: lane count
3636+
*
3637+
* Calculate the total bandwidth of a MultiStream Transport link. The returned
3638+
* value is in units of PBNs/(timeslots/1 MTP). This value can be used to
3639+
* convert the number of PBNs required for a given stream to the number of
3640+
* timeslots this stream requires in each MTP.
3641+
*/
3642+
int drm_dp_get_vc_payload_bw(int link_rate, int link_lane_count)
36333643
{
3634-
if (dp_link_bw == 0 || dp_link_count == 0)
3635-
DRM_DEBUG_KMS("invalid link bandwidth in DPCD: %x (link count: %d)\n",
3636-
dp_link_bw, dp_link_count);
3644+
if (link_rate == 0 || link_lane_count == 0)
3645+
DRM_DEBUG_KMS("invalid link rate/lane count: (%d / %d)\n",
3646+
link_rate, link_lane_count);
36373647

3638-
return dp_link_bw * dp_link_count / 2;
3648+
/* See DP v2.0 2.6.4.2, VCPayload_Bandwidth_for_OneTimeSlotPer_MTP_Allocation */
3649+
return link_rate * link_lane_count / 54000;
36393650
}
3651+
EXPORT_SYMBOL(drm_dp_get_vc_payload_bw);
36403652

36413653
/**
36423654
* drm_dp_read_mst_cap() - check whether or not a sink supports MST
@@ -3692,7 +3704,7 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms
36923704
goto out_unlock;
36933705
}
36943706

3695-
mgr->pbn_div = drm_dp_get_vc_payload_bw(mgr->dpcd[1],
3707+
mgr->pbn_div = drm_dp_get_vc_payload_bw(drm_dp_bw_code_to_link_rate(mgr->dpcd[1]),
36963708
mgr->dpcd[2] & DP_MAX_LANE_COUNT_MASK);
36973709
if (mgr->pbn_div == 0) {
36983710
ret = -EINVAL;

‎include/drm/drm_dp_mst_helper.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ drm_dp_mst_detect_port(struct drm_connector *connector,
783783

784784
struct edid *drm_dp_mst_get_edid(struct drm_connector *connector, struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port);
785785

786+
int drm_dp_get_vc_payload_bw(int link_rate, int link_lane_count);
786787

787788
int drm_dp_calc_pbn_mode(int clock, int bpp, bool dsc);
788789

0 commit comments

Comments
 (0)