Skip to content

Commit 3b00b53

Browse files
committed
drm/dp: extract drm_dp_dpcd_write_payload()
SST with 128b/132b channel coding needs this too. Extract to a separate helper, independent of MST. v2: Clean up kernel-doc a bit Cc: Lyude Paul <[email protected]> Reviewed-by: Imre Deak <[email protected]> Reviewed-by: Lyude Paul <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/f626715ba4e348546770750aa3e10fac73a5cbd7.1733238941.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <[email protected]>
1 parent f2663f7 commit 3b00b53

File tree

3 files changed

+62
-49
lines changed

3 files changed

+62
-49
lines changed

drivers/gpu/drm/display/drm_dp_helper.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,63 @@ static int read_payload_update_status(struct drm_dp_aux *aux)
792792
return status;
793793
}
794794

795+
/**
796+
* drm_dp_dpcd_write_payload() - Write Virtual Channel information to payload table
797+
* @aux: DisplayPort AUX channel
798+
* @vcpid: Virtual Channel Payload ID
799+
* @start_time_slot: Starting time slot
800+
* @time_slot_count: Time slot count
801+
*
802+
* Write the Virtual Channel payload allocation table, checking the payload
803+
* update status and retrying as necessary.
804+
*
805+
* Returns:
806+
* 0 on success, negative error otherwise
807+
*/
808+
int drm_dp_dpcd_write_payload(struct drm_dp_aux *aux,
809+
int vcpid, u8 start_time_slot, u8 time_slot_count)
810+
{
811+
u8 payload_alloc[3], status;
812+
int ret;
813+
int retries = 0;
814+
815+
drm_dp_dpcd_writeb(aux, DP_PAYLOAD_TABLE_UPDATE_STATUS,
816+
DP_PAYLOAD_TABLE_UPDATED);
817+
818+
payload_alloc[0] = vcpid;
819+
payload_alloc[1] = start_time_slot;
820+
payload_alloc[2] = time_slot_count;
821+
822+
ret = drm_dp_dpcd_write(aux, DP_PAYLOAD_ALLOCATE_SET, payload_alloc, 3);
823+
if (ret != 3) {
824+
drm_dbg_kms(aux->drm_dev, "failed to write payload allocation %d\n", ret);
825+
goto fail;
826+
}
827+
828+
retry:
829+
ret = drm_dp_dpcd_readb(aux, DP_PAYLOAD_TABLE_UPDATE_STATUS, &status);
830+
if (ret < 0) {
831+
drm_dbg_kms(aux->drm_dev, "failed to read payload table status %d\n", ret);
832+
goto fail;
833+
}
834+
835+
if (!(status & DP_PAYLOAD_TABLE_UPDATED)) {
836+
retries++;
837+
if (retries < 20) {
838+
usleep_range(10000, 20000);
839+
goto retry;
840+
}
841+
drm_dbg_kms(aux->drm_dev, "status not set after read payload table status %d\n",
842+
status);
843+
ret = -EINVAL;
844+
goto fail;
845+
}
846+
ret = 0;
847+
fail:
848+
return ret;
849+
}
850+
EXPORT_SYMBOL(drm_dp_dpcd_write_payload);
851+
795852
/**
796853
* drm_dp_dpcd_poll_act_handled() - Poll for ACT handled status
797854
* @aux: DisplayPort AUX channel

drivers/gpu/drm/display/drm_dp_mst_topology.c

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ static bool dump_dp_payload_table(struct drm_dp_mst_topology_mgr *mgr,
6767

6868
static void drm_dp_mst_topology_put_port(struct drm_dp_mst_port *port);
6969

70-
static int drm_dp_dpcd_write_payload(struct drm_dp_mst_topology_mgr *mgr,
71-
int id, u8 start_slot, u8 num_slots);
72-
7370
static int drm_dp_send_dpcd_read(struct drm_dp_mst_topology_mgr *mgr,
7471
struct drm_dp_mst_port *port,
7572
int offset, int size, u8 *bytes);
@@ -3263,7 +3260,7 @@ EXPORT_SYMBOL(drm_dp_send_query_stream_enc_status);
32633260
static int drm_dp_create_payload_at_dfp(struct drm_dp_mst_topology_mgr *mgr,
32643261
struct drm_dp_mst_atomic_payload *payload)
32653262
{
3266-
return drm_dp_dpcd_write_payload(mgr, payload->vcpi, payload->vc_start_slot,
3263+
return drm_dp_dpcd_write_payload(mgr->aux, payload->vcpi, payload->vc_start_slot,
32673264
payload->time_slots);
32683265
}
32693266

@@ -3294,7 +3291,7 @@ static void drm_dp_destroy_payload_at_remote_and_dfp(struct drm_dp_mst_topology_
32943291
}
32953292

32963293
if (payload->payload_allocation_status == DRM_DP_MST_PAYLOAD_ALLOCATION_DFP)
3297-
drm_dp_dpcd_write_payload(mgr, payload->vcpi, payload->vc_start_slot, 0);
3294+
drm_dp_dpcd_write_payload(mgr->aux, payload->vcpi, payload->vc_start_slot, 0);
32983295
}
32993296

33003297
/**
@@ -3682,7 +3679,7 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms
36823679
goto out_unlock;
36833680

36843681
/* Write reset payload */
3685-
drm_dp_dpcd_write_payload(mgr, 0, 0, 0x3f);
3682+
drm_dp_dpcd_write_payload(mgr->aux, 0, 0, 0x3f);
36863683

36873684
drm_dp_mst_queue_probe_work(mgr);
36883685

@@ -4679,49 +4676,6 @@ void drm_dp_mst_update_slots(struct drm_dp_mst_topology_state *mst_state, uint8_
46794676
}
46804677
EXPORT_SYMBOL(drm_dp_mst_update_slots);
46814678

4682-
static int drm_dp_dpcd_write_payload(struct drm_dp_mst_topology_mgr *mgr,
4683-
int id, u8 start_slot, u8 num_slots)
4684-
{
4685-
u8 payload_alloc[3], status;
4686-
int ret;
4687-
int retries = 0;
4688-
4689-
drm_dp_dpcd_writeb(mgr->aux, DP_PAYLOAD_TABLE_UPDATE_STATUS,
4690-
DP_PAYLOAD_TABLE_UPDATED);
4691-
4692-
payload_alloc[0] = id;
4693-
payload_alloc[1] = start_slot;
4694-
payload_alloc[2] = num_slots;
4695-
4696-
ret = drm_dp_dpcd_write(mgr->aux, DP_PAYLOAD_ALLOCATE_SET, payload_alloc, 3);
4697-
if (ret != 3) {
4698-
drm_dbg_kms(mgr->dev, "failed to write payload allocation %d\n", ret);
4699-
goto fail;
4700-
}
4701-
4702-
retry:
4703-
ret = drm_dp_dpcd_readb(mgr->aux, DP_PAYLOAD_TABLE_UPDATE_STATUS, &status);
4704-
if (ret < 0) {
4705-
drm_dbg_kms(mgr->dev, "failed to read payload table status %d\n", ret);
4706-
goto fail;
4707-
}
4708-
4709-
if (!(status & DP_PAYLOAD_TABLE_UPDATED)) {
4710-
retries++;
4711-
if (retries < 20) {
4712-
usleep_range(10000, 20000);
4713-
goto retry;
4714-
}
4715-
drm_dbg_kms(mgr->dev, "status not set after read payload table status %d\n",
4716-
status);
4717-
ret = -EINVAL;
4718-
goto fail;
4719-
}
4720-
ret = 0;
4721-
fail:
4722-
return ret;
4723-
}
4724-
47254679
/**
47264680
* drm_dp_check_act_status() - Polls for ACT handled status.
47274681
* @mgr: manager to use

include/drm/display/drm_dp_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,8 @@ int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux,
567567
enum drm_dp_phy dp_phy,
568568
u8 link_status[DP_LINK_STATUS_SIZE]);
569569

570+
int drm_dp_dpcd_write_payload(struct drm_dp_aux *aux,
571+
int vcpid, u8 start_time_slot, u8 time_slot_count);
570572
int drm_dp_dpcd_poll_act_handled(struct drm_dp_aux *aux, int timeout_ms);
571573

572574
bool drm_dp_send_real_edid_checksum(struct drm_dp_aux *aux,

0 commit comments

Comments
 (0)