Commit 6f77b2ac authored by Eryk Brol's avatar Eryk Brol Committed by Alex Deucher

drm/amd/display: Add connector HPD trigger debugfs entry

[why]
Need a tool to retrigger a virtual hotplug for testing purposes with
force redetection in both DC and DM.

[how]
Emulate handle_hpd_irq for connector as if usermode would trigger
a hotplug. Perform DC link discovery, DM connector update, and
DM force atomic commit.

In order to trigger HPD on the connector user needs to echo 1 into
"trigger_hotplug" debugfs entry on its respective connector.
Signed-off-by: default avatarEryk Brol <eryk.brol@amd.com>
Signed-off-by: default avatarMikita Lipski <mikita.lipski@amd.com>
Reviewed-by: default avatarMikita Lipski <Mikita.Lipski@amd.com>
Acked-by: default avatarEryk Brol <eryk.brol@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 237070fd
...@@ -1049,6 +1049,81 @@ static int dp_dsc_fec_support_show(struct seq_file *m, void *data) ...@@ -1049,6 +1049,81 @@ static int dp_dsc_fec_support_show(struct seq_file *m, void *data)
return ret; return ret;
} }
/* function: Trigger virtual HPD redetection on connector
*
* This function will perform link rediscovery, link disable
* and enable, and dm connector state update.
*
* Retrigger HPD on an existing connector by echoing 1 into
* its respectful "trigger_hotplug" debugfs entry:
*
* echo 1 > /sys/kernel/debug/dri/0/DP-X/trigger_hotplug
*
*/
static ssize_t dp_trigger_hotplug(struct file *f, const char __user *buf,
size_t size, loff_t *pos)
{
struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
struct drm_connector *connector = &aconnector->base;
struct drm_device *dev = connector->dev;
enum dc_connection_type new_connection_type = dc_connection_none;
char *wr_buf = NULL;
uint32_t wr_buf_size = 42;
int max_param_num = 1;
long param[1] = {0};
uint8_t param_nums = 0;
if (!aconnector || !aconnector->dc_link)
return -EINVAL;
if (size == 0)
return -EINVAL;
wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
if (!wr_buf) {
DRM_DEBUG_DRIVER("no memory to allocate write buffer\n");
return -ENOSPC;
}
if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
(long *)param, buf,
max_param_num,
&param_nums))
return -EINVAL;
if (param_nums <= 0) {
DRM_DEBUG_DRIVER("user data not be read\n");
kfree(wr_buf);
return -EINVAL;
}
if (param[0] == 1) {
mutex_lock(&aconnector->hpd_lock);
if (!dc_link_detect_sink(aconnector->dc_link, &new_connection_type) &&
new_connection_type != dc_connection_none)
goto unlock;
if (!dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD))
goto unlock;
amdgpu_dm_update_connector_after_detect(aconnector);
drm_modeset_lock_all(dev);
dm_restore_drm_connector_state(dev, connector);
drm_modeset_unlock_all(dev);
drm_kms_helper_hotplug_event(dev);
unlock:
mutex_unlock(&aconnector->hpd_lock);
}
kfree(wr_buf);
return size;
}
/* function: read DSC status on the connector /* function: read DSC status on the connector
* *
* The read function: dp_dsc_clock_en_read * The read function: dp_dsc_clock_en_read
...@@ -1967,6 +2042,12 @@ static const struct file_operations dp_dsc_slice_bpg_offset_debugfs_fops = { ...@@ -1967,6 +2042,12 @@ static const struct file_operations dp_dsc_slice_bpg_offset_debugfs_fops = {
.llseek = default_llseek .llseek = default_llseek
}; };
static const struct file_operations dp_trigger_hotplug_debugfs_fops = {
.owner = THIS_MODULE,
.write = dp_trigger_hotplug,
.llseek = default_llseek
};
static const struct file_operations dp_link_settings_debugfs_fops = { static const struct file_operations dp_link_settings_debugfs_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.read = dp_link_settings_read, .read = dp_link_settings_read,
......
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