All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/i915: Add debugfs to read/write any DPCD register
@ 2015-04-20 11:38 Durgadoss R
  2015-04-20 13:03 ` Sivakumar Thulasimani
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Durgadoss R @ 2015-04-20 11:38 UTC (permalink / raw)
  To: intel-gfx; +Cc: ville.syrjala, paulo.r.zanoni

This patch creates a connector specific debugfs
interface to read any particular DPCD register.
The DPCD register address (hex format) is written
to 'i915_dpcd_addr' interface and the corresponding
value can be read from 'i915_dpcd_val' interface.

To write into a DPCD register, echo a value into
'i915_dpcd_val' interface. This will return -EIO
for invalid writes.

Example usage:
echo 0x2 > i915_dpcd_addr
cat i915_dpcd_val
0x84

To write 0x1 to DPCD 0x170:
echo 0x170 > i915_dpcd_addr
echo 0x1 > i915_dpcd_val
cat i915_dpcd_val
0x1

v2: Address Jani's comments.

v3: Added capability to write DPCD also (Ville)

Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 120 +++++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/i915/intel_drv.h    |   1 +
 2 files changed, 120 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 9c2b9e4..79c876e 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -4968,6 +4968,119 @@ static const struct file_operations i915_dpcd_fops = {
 	.release = single_release,
 };
 
+static ssize_t i915_dpcd_addr_write(struct file *file, const char __user *ubuf,
+				     size_t len, loff_t *offp)
+{
+	struct seq_file *m = file->private_data;
+	struct drm_connector *connector = m->private;
+	struct intel_dp *intel_dp =
+		enc_to_intel_dp(&intel_attached_encoder(connector)->base);
+	unsigned int reg_addr;
+	char tmp[16];
+
+	if (len >= sizeof(tmp))
+		return -EINVAL;
+
+	if (copy_from_user(tmp, ubuf, len))
+		return -EFAULT;
+
+	tmp[len] = '\0';
+
+	if (kstrtouint(tmp, 16, &reg_addr))
+		return -EINVAL;
+
+	intel_dp->debugfs_dpcd_addr = reg_addr;
+
+	return len;
+}
+
+static int i915_dpcd_addr_show(struct seq_file *m, void *data)
+{
+	struct drm_connector *connector = m->private;
+	struct intel_dp *intel_dp =
+		enc_to_intel_dp(&intel_attached_encoder(connector)->base);
+
+	seq_printf(m, "0x%x\n", intel_dp->debugfs_dpcd_addr);
+
+	return 0;
+}
+
+static int i915_dpcd_addr_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, i915_dpcd_addr_show, inode->i_private);
+}
+
+static const struct file_operations i915_dpcd_addr_fops = {
+	.owner = THIS_MODULE,
+	.open = i915_dpcd_addr_open,
+	.read = seq_read,
+	.write = i915_dpcd_addr_write,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
+static ssize_t i915_dpcd_val_write(struct file *file, const char __user *ubuf,
+				     size_t len, loff_t *offp)
+{
+	struct seq_file *m = file->private_data;
+	struct drm_connector *connector = m->private;
+	struct intel_dp *intel_dp =
+		enc_to_intel_dp(&intel_attached_encoder(connector)->base);
+	unsigned int addr = intel_dp->debugfs_dpcd_addr;
+	unsigned int val;
+	char tmp[16];
+	int ret;
+
+	if (len >= sizeof(tmp))
+		return -EINVAL;
+
+	if (copy_from_user(tmp, ubuf, len))
+		return -EFAULT;
+
+	tmp[len] = '\0';
+
+	if (kstrtouint(tmp, 16, &val))
+		return -EINVAL;
+
+	ret = drm_dp_dpcd_writeb(&intel_dp->aux, addr, val);
+	if (ret < 0)
+		return ret;
+
+	return len;
+}
+
+static int i915_dpcd_val_show(struct seq_file *m, void *data)
+{
+	struct drm_connector *connector = m->private;
+	struct intel_dp *intel_dp =
+		enc_to_intel_dp(&intel_attached_encoder(connector)->base);
+	unsigned int addr;
+	u8 val;
+	int ret;
+
+	addr = intel_dp->debugfs_dpcd_addr;
+	ret = drm_dp_dpcd_readb(&intel_dp->aux, addr, &val);
+	if (ret < 0)
+		return ret;
+
+	seq_printf(m, "0x%x\n", val);
+	return 0;
+}
+
+static int i915_dpcd_val_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, i915_dpcd_val_show, inode->i_private);
+}
+
+static const struct file_operations i915_dpcd_val_fops = {
+	.owner = THIS_MODULE,
+	.open = i915_dpcd_val_open,
+	.read = seq_read,
+	.write = i915_dpcd_val_write,
+	.llseek = seq_lseek,
+	.release = single_release,
+};
+
 /**
  * i915_debugfs_connector_add - add i915 specific connector debugfs files
  * @connector: pointer to a registered drm_connector
@@ -4986,9 +5099,14 @@ int i915_debugfs_connector_add(struct drm_connector *connector)
 		return -ENODEV;
 
 	if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
-	    connector->connector_type == DRM_MODE_CONNECTOR_eDP)
+	    connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
 		debugfs_create_file("i915_dpcd", S_IRUGO, root, connector,
 				    &i915_dpcd_fops);
+		debugfs_create_file("i915_dpcd_addr", S_IRUGO | S_IWUSR,
+				root, connector, &i915_dpcd_addr_fops);
+		debugfs_create_file("i915_dpcd_val", S_IRUGO | S_IWUSR,
+				root, connector, &i915_dpcd_val_fops);
+	}
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 23a42a4..4477d14 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -709,6 +709,7 @@ struct intel_dp {
 	unsigned long last_power_cycle;
 	unsigned long last_power_on;
 	unsigned long last_backlight_off;
+	unsigned int debugfs_dpcd_addr;
 
 	struct notifier_block edp_notifier;
 
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] drm/i915: Add debugfs to read/write any DPCD register
  2015-04-20 11:38 [PATCH v3] drm/i915: Add debugfs to read/write any DPCD register Durgadoss R
@ 2015-04-20 13:03 ` Sivakumar Thulasimani
  2015-04-20 14:36 ` shuang.he
  2015-04-20 16:19 ` Daniel Vetter
  2 siblings, 0 replies; 4+ messages in thread
From: Sivakumar Thulasimani @ 2015-04-20 13:03 UTC (permalink / raw)
  To: Durgadoss R; +Cc: intel-gfx, ville.syrjala, paulo.r.zanoni


[-- Attachment #1.1: Type: text/plain, Size: 5546 bytes --]

Reviewed-by: Sivakumar Thulasimani <sivakumar.thulasimani@intel.com>


On 4/20/2015 5:08 PM, Durgadoss R wrote:
> This patch creates a connector specific debugfs
> interface to read any particular DPCD register.
> The DPCD register address (hex format) is written
> to 'i915_dpcd_addr' interface and the corresponding
> value can be read from 'i915_dpcd_val' interface.
>
> To write into a DPCD register, echo a value into
> 'i915_dpcd_val' interface. This will return -EIO
> for invalid writes.
>
> Example usage:
> echo 0x2 > i915_dpcd_addr
> cat i915_dpcd_val
> 0x84
>
> To write 0x1 to DPCD 0x170:
> echo 0x170 > i915_dpcd_addr
> echo 0x1 > i915_dpcd_val
> cat i915_dpcd_val
> 0x1
>
> v2: Address Jani's comments.
>
> v3: Added capability to write DPCD also (Ville)
>
> Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_debugfs.c | 120 +++++++++++++++++++++++++++++++++++-
>   drivers/gpu/drm/i915/intel_drv.h    |   1 +
>   2 files changed, 120 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 9c2b9e4..79c876e 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -4968,6 +4968,119 @@ static const struct file_operations i915_dpcd_fops = {
>   	.release = single_release,
>   };
>   
> +static ssize_t i915_dpcd_addr_write(struct file *file, const char __user *ubuf,
> +				     size_t len, loff_t *offp)
> +{
> +	struct seq_file *m = file->private_data;
> +	struct drm_connector *connector = m->private;
> +	struct intel_dp *intel_dp =
> +		enc_to_intel_dp(&intel_attached_encoder(connector)->base);
> +	unsigned int reg_addr;
> +	char tmp[16];
> +
> +	if (len >= sizeof(tmp))
> +		return -EINVAL;
> +
> +	if (copy_from_user(tmp, ubuf, len))
> +		return -EFAULT;
> +
> +	tmp[len] = '\0';
> +
> +	if (kstrtouint(tmp, 16, &reg_addr))
> +		return -EINVAL;
> +
> +	intel_dp->debugfs_dpcd_addr = reg_addr;
> +
> +	return len;
> +}
> +
> +static int i915_dpcd_addr_show(struct seq_file *m, void *data)
> +{
> +	struct drm_connector *connector = m->private;
> +	struct intel_dp *intel_dp =
> +		enc_to_intel_dp(&intel_attached_encoder(connector)->base);
> +
> +	seq_printf(m, "0x%x\n", intel_dp->debugfs_dpcd_addr);
> +
> +	return 0;
> +}
> +
> +static int i915_dpcd_addr_open(struct inode *inode, struct file *file)
> +{
> +	return single_open(file, i915_dpcd_addr_show, inode->i_private);
> +}
> +
> +static const struct file_operations i915_dpcd_addr_fops = {
> +	.owner = THIS_MODULE,
> +	.open = i915_dpcd_addr_open,
> +	.read = seq_read,
> +	.write = i915_dpcd_addr_write,
> +	.llseek = seq_lseek,
> +	.release = single_release,
> +};
> +
> +static ssize_t i915_dpcd_val_write(struct file *file, const char __user *ubuf,
> +				     size_t len, loff_t *offp)
> +{
> +	struct seq_file *m = file->private_data;
> +	struct drm_connector *connector = m->private;
> +	struct intel_dp *intel_dp =
> +		enc_to_intel_dp(&intel_attached_encoder(connector)->base);
> +	unsigned int addr = intel_dp->debugfs_dpcd_addr;
> +	unsigned int val;
> +	char tmp[16];
> +	int ret;
> +
> +	if (len >= sizeof(tmp))
> +		return -EINVAL;
> +
> +	if (copy_from_user(tmp, ubuf, len))
> +		return -EFAULT;
> +
> +	tmp[len] = '\0';
> +
> +	if (kstrtouint(tmp, 16, &val))
> +		return -EINVAL;
> +
> +	ret = drm_dp_dpcd_writeb(&intel_dp->aux, addr, val);
> +	if (ret < 0)
> +		return ret;
> +
> +	return len;
> +}
> +
> +static int i915_dpcd_val_show(struct seq_file *m, void *data)
> +{
> +	struct drm_connector *connector = m->private;
> +	struct intel_dp *intel_dp =
> +		enc_to_intel_dp(&intel_attached_encoder(connector)->base);
> +	unsigned int addr;
> +	u8 val;
> +	int ret;
> +
> +	addr = intel_dp->debugfs_dpcd_addr;
> +	ret = drm_dp_dpcd_readb(&intel_dp->aux, addr, &val);
> +	if (ret < 0)
> +		return ret;
> +
> +	seq_printf(m, "0x%x\n", val);
> +	return 0;
> +}
> +
> +static int i915_dpcd_val_open(struct inode *inode, struct file *file)
> +{
> +	return single_open(file, i915_dpcd_val_show, inode->i_private);
> +}
> +
> +static const struct file_operations i915_dpcd_val_fops = {
> +	.owner = THIS_MODULE,
> +	.open = i915_dpcd_val_open,
> +	.read = seq_read,
> +	.write = i915_dpcd_val_write,
> +	.llseek = seq_lseek,
> +	.release = single_release,
> +};
> +
>   /**
>    * i915_debugfs_connector_add - add i915 specific connector debugfs files
>    * @connector: pointer to a registered drm_connector
> @@ -4986,9 +5099,14 @@ int i915_debugfs_connector_add(struct drm_connector *connector)
>   		return -ENODEV;
>   
>   	if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
> -	    connector->connector_type == DRM_MODE_CONNECTOR_eDP)
> +	    connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
>   		debugfs_create_file("i915_dpcd", S_IRUGO, root, connector,
>   				    &i915_dpcd_fops);
> +		debugfs_create_file("i915_dpcd_addr", S_IRUGO | S_IWUSR,
> +				root, connector, &i915_dpcd_addr_fops);
> +		debugfs_create_file("i915_dpcd_val", S_IRUGO | S_IWUSR,
> +				root, connector, &i915_dpcd_val_fops);
> +	}
>   
>   	return 0;
>   }
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 23a42a4..4477d14 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -709,6 +709,7 @@ struct intel_dp {
>   	unsigned long last_power_cycle;
>   	unsigned long last_power_on;
>   	unsigned long last_backlight_off;
> +	unsigned int debugfs_dpcd_addr;
>   
>   	struct notifier_block edp_notifier;
>   


[-- Attachment #1.2: Type: text/html, Size: 5954 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] drm/i915: Add debugfs to read/write any DPCD register
  2015-04-20 11:38 [PATCH v3] drm/i915: Add debugfs to read/write any DPCD register Durgadoss R
  2015-04-20 13:03 ` Sivakumar Thulasimani
@ 2015-04-20 14:36 ` shuang.he
  2015-04-20 16:19 ` Daniel Vetter
  2 siblings, 0 replies; 4+ messages in thread
From: shuang.he @ 2015-04-20 14:36 UTC (permalink / raw)
  To: shuang.he, ethan.gao, intel-gfx, durgadoss.r

Tested-By: Intel Graphics QA PRTS (Patch Regression Test System Contact: shuang.he@intel.com)
Task id: 6234
-------------------------------------Summary-------------------------------------
Platform          Delta          drm-intel-nightly          Series Applied
PNV                                  276/276              276/276
ILK                                  302/302              302/302
SNB                                  318/318              318/318
IVB                                  341/341              341/341
BYT                                  287/287              287/287
BDW                                  318/318              318/318
-------------------------------------Detailed-------------------------------------
Platform  Test                                drm-intel-nightly          Series Applied
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v3] drm/i915: Add debugfs to read/write any DPCD register
  2015-04-20 11:38 [PATCH v3] drm/i915: Add debugfs to read/write any DPCD register Durgadoss R
  2015-04-20 13:03 ` Sivakumar Thulasimani
  2015-04-20 14:36 ` shuang.he
@ 2015-04-20 16:19 ` Daniel Vetter
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Vetter @ 2015-04-20 16:19 UTC (permalink / raw)
  To: Durgadoss R; +Cc: intel-gfx, ville.syrjala, paulo.r.zanoni

On Mon, Apr 20, 2015 at 05:08:14PM +0530, Durgadoss R wrote:
> This patch creates a connector specific debugfs
> interface to read any particular DPCD register.
> The DPCD register address (hex format) is written
> to 'i915_dpcd_addr' interface and the corresponding
> value can be read from 'i915_dpcd_val' interface.
> 
> To write into a DPCD register, echo a value into
> 'i915_dpcd_val' interface. This will return -EIO
> for invalid writes.
> 
> Example usage:
> echo 0x2 > i915_dpcd_addr
> cat i915_dpcd_val
> 0x84
> 
> To write 0x1 to DPCD 0x170:
> echo 0x170 > i915_dpcd_addr
> echo 0x1 > i915_dpcd_val
> cat i915_dpcd_val
> 0x1
> 
> v2: Address Jani's comments.
> 
> v3: Added capability to write DPCD also (Ville)
> 
> Signed-off-by: Durgadoss R <durgadoss.r@intel.com>

As mentioned in another thread I think the right approach here is to
expose the dp aux interface through some ioctls in debugfs or dev
somewhere, and then add simple tools on top of that. Similar to what we
have with i2c. That would allow us to implement additional things on top
like mst inspection or using the i2c-over-dp-aux sidechannel.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-04-20 16:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-20 11:38 [PATCH v3] drm/i915: Add debugfs to read/write any DPCD register Durgadoss R
2015-04-20 13:03 ` Sivakumar Thulasimani
2015-04-20 14:36 ` shuang.he
2015-04-20 16:19 ` Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.