diff mbox series

[V2,1/3] drm/debug: Expose connector's max supported bpc via debugfs

Message ID 20220411095129.1652096-2-bhanuprakash.modem@intel.com (mailing list archive)
State New, archived
Headers show
Series Expose max and current bpc via debugfs | expand

Commit Message

Modem, Bhanuprakash April 11, 2022, 9:51 a.m. UTC
It's useful to know the connector's max supported bpc for IGT
testing. Expose it via a debugfs file on the connector "output_bpc".

Example: cat /sys/kernel/debug/dri/0/DP-1/output_bpc

V2:
* Fix typo in comments (Harry)

Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
---
 drivers/gpu/drm/drm_debugfs.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Murthy, Arun R April 12, 2022, 3:07 a.m. UTC | #1
> +static int output_bpc_show(struct seq_file *m, void *data) {

Would it be better to have this function name as drm_output_bpc_show()

Thanks and Regards,
Arun R Murthy
--------------------
Modem, Bhanuprakash April 12, 2022, 4:03 a.m. UTC | #2
On Tue-12-04-2022 08:37 am, Murthy, Arun R wrote:
>> +static int output_bpc_show(struct seq_file *m, void *data) {
> 
> Would it be better to have this function name as drm_output_bpc_show()

As we are using DEFINE_SHOW_ATTRIBUTE() to define file_operations, this 
function name must be <debugfs name>_show(). Otherwise, either we need 
to define new file_operations to use the suggested name or rename the 
debugfs name to "drm_output_bpc"

Also, to align/maintain uniform with other debugfs, I think it's ok to 
use output_bpc_show().

- Bhanu

> 
> Thanks and Regards,
> Arun R Murthy
> --------------------
Murthy, Arun R April 29, 2022, 2:27 p.m. UTC | #3
> +static int output_bpc_show(struct seq_file *m, void *data) {

Can we have a meaningful name instead of 'm' ?
Upon changing this parameter name, you can have my
Reviewed-By: Arun R Murthy <arun.r.murthy@intel.com>

Thanks and Regards,
Arun R Murthy
--------------------
Jani Nikula May 2, 2022, 11:49 a.m. UTC | #4
On Fri, 29 Apr 2022, "Murthy, Arun R" <arun.r.murthy@intel.com> wrote:
>> +static int output_bpc_show(struct seq_file *m, void *data) {
>
> Can we have a meaningful name instead of 'm' ?
> Upon changing this parameter name, you can have my
> Reviewed-By: Arun R Murthy <arun.r.murthy@intel.com>

Please keep 'm'. It's by far the most common name for struct seq_file *
in the kernel:

$ git grep -o "struct seq_file \*[a-zA-Z0-9_]\+" | sed 's/^.*:struct seq_file \*//' | sort | uniq -c | sort -rn | head -5
   2212 m
   1219 seq
   1126 s
    135 sf
    121 file


BR,
Jani.
Harry Wentland May 2, 2022, 6:51 p.m. UTC | #5
On 2022-04-11 05:51, Bhanuprakash Modem wrote:
> It's useful to know the connector's max supported bpc for IGT
> testing. Expose it via a debugfs file on the connector "output_bpc".
> 
> Example: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
> 
> V2:
> * Fix typo in comments (Harry)
> 
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Harry Wentland <harry.wentland@amd.com>
> Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>

Reviewed-by: Harry Wentland <harry.wentland@amd.com>

Harry

> ---
>  drivers/gpu/drm/drm_debugfs.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index 7f1b82dbaebb..fb04b7a984de 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -395,6 +395,23 @@ static int vrr_range_show(struct seq_file *m, void *data)
>  }
>  DEFINE_SHOW_ATTRIBUTE(vrr_range);
>  
> +/*
> + * Returns Connector's max supported bpc through debugfs file.
> + * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
> + */
> +static int output_bpc_show(struct seq_file *m, void *data)
> +{
> +	struct drm_connector *connector = m->private;
> +
> +	if (connector->status != connector_status_connected)
> +		return -ENODEV;
> +
> +	seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);
> +
> +	return 0;
> +}
> +DEFINE_SHOW_ATTRIBUTE(output_bpc);
> +
>  static const struct file_operations drm_edid_fops = {
>  	.owner = THIS_MODULE,
>  	.open = edid_open,
> @@ -437,6 +454,10 @@ void drm_debugfs_connector_add(struct drm_connector *connector)
>  	debugfs_create_file("vrr_range", S_IRUGO, root, connector,
>  			    &vrr_range_fops);
>  
> +	/* max bpc */
> +	debugfs_create_file("output_bpc", 0444, root, connector,
> +			    &output_bpc_fops);
> +
>  	if (connector->funcs->debugfs_init)
>  		connector->funcs->debugfs_init(connector, root);
>  }
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index 7f1b82dbaebb..fb04b7a984de 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -395,6 +395,23 @@  static int vrr_range_show(struct seq_file *m, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(vrr_range);
 
+/*
+ * Returns Connector's max supported bpc through debugfs file.
+ * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
+ */
+static int output_bpc_show(struct seq_file *m, void *data)
+{
+	struct drm_connector *connector = m->private;
+
+	if (connector->status != connector_status_connected)
+		return -ENODEV;
+
+	seq_printf(m, "Maximum: %u\n", connector->display_info.bpc);
+
+	return 0;
+}
+DEFINE_SHOW_ATTRIBUTE(output_bpc);
+
 static const struct file_operations drm_edid_fops = {
 	.owner = THIS_MODULE,
 	.open = edid_open,
@@ -437,6 +454,10 @@  void drm_debugfs_connector_add(struct drm_connector *connector)
 	debugfs_create_file("vrr_range", S_IRUGO, root, connector,
 			    &vrr_range_fops);
 
+	/* max bpc */
+	debugfs_create_file("output_bpc", 0444, root, connector,
+			    &output_bpc_fops);
+
 	if (connector->funcs->debugfs_init)
 		connector->funcs->debugfs_init(connector, root);
 }