Skip to content

Commit eb3394f

Browse files
Todd Previtedanvet
authored andcommitted
drm/i915: Add debugfs test control files for Displayport compliance testing
This patch adds 3 debugfs files for handling Displayport compliance testing and supercedes the previous patches that implemented debugfs support for compliance testing. Those patches were: - [PATCH 04/17] drm/i915: Add debugfs functions for Displayport compliance testing - [PATCH 08/17] drm/i915: Add new debugfs file for Displayport compliance test control - [PATCH 09/17] drm/i915: Add debugfs write and test param parsing functions for DP test control This new patch simplifies the debugfs implementation by places a single test control value into an individual file. Each file is readable by the usersapce application and the test_active file is writable to indicate to the kernel when userspace has completed its portion of the test sequence. Replacing the previous files simplifies operation and speeds response time for the user app, as it is required to poll on the test_active file in order to determine when it needs to begin its operations. V2: - Updated the test active variable name to match the change in the initial patch of the series V3: - Added a fix in the test_active_write function to prevent a NULL pointer dereference if the encoder on the connector is invalid Signed-off-by: Todd Previte <tprevite@gmail.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent 559be30 commit eb3394f

File tree

1 file changed

+209
-0
lines changed

1 file changed

+209
-0
lines changed

drivers/gpu/drm/i915/i915_debugfs.c

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3951,6 +3951,212 @@ static const struct file_operations i915_display_crc_ctl_fops = {
39513951
.write = display_crc_ctl_write
39523952
};
39533953

3954+
static ssize_t i915_displayport_test_active_write(struct file *file,
3955+
const char __user *ubuf,
3956+
size_t len, loff_t *offp)
3957+
{
3958+
char *input_buffer;
3959+
int status = 0;
3960+
struct seq_file *m;
3961+
struct drm_device *dev;
3962+
struct drm_connector *connector;
3963+
struct list_head *connector_list;
3964+
struct intel_dp *intel_dp;
3965+
int val = 0;
3966+
3967+
m = file->private_data;
3968+
if (!m) {
3969+
status = -ENODEV;
3970+
return status;
3971+
}
3972+
dev = m->private;
3973+
3974+
if (!dev) {
3975+
status = -ENODEV;
3976+
return status;
3977+
}
3978+
connector_list = &dev->mode_config.connector_list;
3979+
3980+
if (len == 0)
3981+
return 0;
3982+
3983+
input_buffer = kmalloc(len + 1, GFP_KERNEL);
3984+
if (!input_buffer)
3985+
return -ENOMEM;
3986+
3987+
if (copy_from_user(input_buffer, ubuf, len)) {
3988+
status = -EFAULT;
3989+
goto out;
3990+
}
3991+
3992+
input_buffer[len] = '\0';
3993+
DRM_DEBUG_DRIVER("Copied %d bytes from user\n", (unsigned int)len);
3994+
3995+
list_for_each_entry(connector, connector_list, head) {
3996+
3997+
if (connector->connector_type !=
3998+
DRM_MODE_CONNECTOR_DisplayPort)
3999+
continue;
4000+
4001+
if (connector->connector_type ==
4002+
DRM_MODE_CONNECTOR_DisplayPort &&
4003+
connector->status == connector_status_connected &&
4004+
connector->encoder != NULL) {
4005+
intel_dp = enc_to_intel_dp(connector->encoder);
4006+
status = kstrtoint(input_buffer, 10, &val);
4007+
if (status < 0)
4008+
goto out;
4009+
DRM_DEBUG_DRIVER("Got %d for test active\n", val);
4010+
/* To prevent erroneous activation of the compliance
4011+
* testing code, only accept an actual value of 1 here
4012+
*/
4013+
if (val == 1)
4014+
intel_dp->compliance_test_active = 1;
4015+
else
4016+
intel_dp->compliance_test_active = 0;
4017+
}
4018+
}
4019+
out:
4020+
kfree(input_buffer);
4021+
if (status < 0)
4022+
return status;
4023+
4024+
*offp += len;
4025+
return len;
4026+
}
4027+
4028+
static int i915_displayport_test_active_show(struct seq_file *m, void *data)
4029+
{
4030+
struct drm_device *dev = m->private;
4031+
struct drm_connector *connector;
4032+
struct list_head *connector_list = &dev->mode_config.connector_list;
4033+
struct intel_dp *intel_dp;
4034+
4035+
if (!dev)
4036+
return -ENODEV;
4037+
4038+
list_for_each_entry(connector, connector_list, head) {
4039+
4040+
if (connector->connector_type !=
4041+
DRM_MODE_CONNECTOR_DisplayPort)
4042+
continue;
4043+
4044+
if (connector->status == connector_status_connected &&
4045+
connector->encoder != NULL) {
4046+
intel_dp = enc_to_intel_dp(connector->encoder);
4047+
if (intel_dp->compliance_test_active)
4048+
seq_puts(m, "1");
4049+
else
4050+
seq_puts(m, "0");
4051+
} else
4052+
seq_puts(m, "0");
4053+
}
4054+
4055+
return 0;
4056+
}
4057+
4058+
static int i915_displayport_test_active_open(struct inode *inode,
4059+
struct file *file)
4060+
{
4061+
struct drm_device *dev = inode->i_private;
4062+
4063+
return single_open(file, i915_displayport_test_active_show, dev);
4064+
}
4065+
4066+
static const struct file_operations i915_displayport_test_active_fops = {
4067+
.owner = THIS_MODULE,
4068+
.open = i915_displayport_test_active_open,
4069+
.read = seq_read,
4070+
.llseek = seq_lseek,
4071+
.release = single_release,
4072+
.write = i915_displayport_test_active_write
4073+
};
4074+
4075+
static int i915_displayport_test_data_show(struct seq_file *m, void *data)
4076+
{
4077+
struct drm_device *dev = m->private;
4078+
struct drm_connector *connector;
4079+
struct list_head *connector_list = &dev->mode_config.connector_list;
4080+
struct intel_dp *intel_dp;
4081+
4082+
if (!dev)
4083+
return -ENODEV;
4084+
4085+
list_for_each_entry(connector, connector_list, head) {
4086+
4087+
if (connector->connector_type !=
4088+
DRM_MODE_CONNECTOR_DisplayPort)
4089+
continue;
4090+
4091+
if (connector->status == connector_status_connected &&
4092+
connector->encoder != NULL) {
4093+
intel_dp = enc_to_intel_dp(connector->encoder);
4094+
seq_printf(m, "%lx", intel_dp->compliance_test_data);
4095+
} else
4096+
seq_puts(m, "0");
4097+
}
4098+
4099+
return 0;
4100+
}
4101+
static int i915_displayport_test_data_open(struct inode *inode,
4102+
struct file *file)
4103+
{
4104+
struct drm_device *dev = inode->i_private;
4105+
4106+
return single_open(file, i915_displayport_test_data_show, dev);
4107+
}
4108+
4109+
static const struct file_operations i915_displayport_test_data_fops = {
4110+
.owner = THIS_MODULE,
4111+
.open = i915_displayport_test_data_open,
4112+
.read = seq_read,
4113+
.llseek = seq_lseek,
4114+
.release = single_release
4115+
};
4116+
4117+
static int i915_displayport_test_type_show(struct seq_file *m, void *data)
4118+
{
4119+
struct drm_device *dev = m->private;
4120+
struct drm_connector *connector;
4121+
struct list_head *connector_list = &dev->mode_config.connector_list;
4122+
struct intel_dp *intel_dp;
4123+
4124+
if (!dev)
4125+
return -ENODEV;
4126+
4127+
list_for_each_entry(connector, connector_list, head) {
4128+
4129+
if (connector->connector_type !=
4130+
DRM_MODE_CONNECTOR_DisplayPort)
4131+
continue;
4132+
4133+
if (connector->status == connector_status_connected &&
4134+
connector->encoder != NULL) {
4135+
intel_dp = enc_to_intel_dp(connector->encoder);
4136+
seq_printf(m, "%02lx", intel_dp->compliance_test_type);
4137+
} else
4138+
seq_puts(m, "0");
4139+
}
4140+
4141+
return 0;
4142+
}
4143+
4144+
static int i915_displayport_test_type_open(struct inode *inode,
4145+
struct file *file)
4146+
{
4147+
struct drm_device *dev = inode->i_private;
4148+
4149+
return single_open(file, i915_displayport_test_type_show, dev);
4150+
}
4151+
4152+
static const struct file_operations i915_displayport_test_type_fops = {
4153+
.owner = THIS_MODULE,
4154+
.open = i915_displayport_test_type_open,
4155+
.read = seq_read,
4156+
.llseek = seq_lseek,
4157+
.release = single_release
4158+
};
4159+
39544160
static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
39554161
{
39564162
struct drm_device *dev = m->private;
@@ -4846,6 +5052,9 @@ static const struct i915_debugfs_files {
48465052
{"i915_spr_wm_latency", &i915_spr_wm_latency_fops},
48475053
{"i915_cur_wm_latency", &i915_cur_wm_latency_fops},
48485054
{"i915_fbc_false_color", &i915_fbc_fc_fops},
5055+
{"i915_dp_test_data", &i915_displayport_test_data_fops},
5056+
{"i915_dp_test_type", &i915_displayport_test_type_fops},
5057+
{"i915_dp_test_active", &i915_displayport_test_active_fops}
48495058
};
48505059

48515060
void intel_display_crc_init(struct drm_device *dev)

0 commit comments

Comments
 (0)