All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Simplify hdmi_automation debugfs with debugfs_create_bool
@ 2026-07-30 18:41 Fangzhi Zuo
  2026-07-31 20:14 ` Harry Wentland
  0 siblings, 1 reply; 2+ messages in thread
From: Fangzhi Zuo @ 2026-07-30 18:41 UTC (permalink / raw)
  To: amd-gfx, nicolas.frattaroli, krzk; +Cc: Fangzhi Zuo

Follow-up fix for commit 442b2e9dc9e9 ("drm/amd/display: Add Support for
HDMI Compliance Automation"), whose hdmi_automation debugfs entry
hand-rolled the boolean parsing (scratch buffer,
parse_write_buffer_into_params(), a switch and kfree) that the debugfs
core already provides.

hdmi_comp_auto is a plain bool, so bind it directly with
debugfs_create_bool() and drop the custom write handler, its
file_operations and the hdmi_debugfs_entries[] row.

Fixes: 442b2e9dc9e9 ("drm/amd/display: Add Support for HDMI Compliance Automation")
Signed-off-by: Fangzhi Zuo <jerry.zuo@amd.com>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 69 +------------------
 1 file changed, 3 insertions(+), 66 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index 830cf8da06b4..45249bebe9fb 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -2981,64 +2981,6 @@ static ssize_t hdmi_cec_state_write(struct file *f, const char __user *buf,
 	return size;
 }
 
-/**
- * hdmi_automation_enable - Enable/Disable HDMI automation feature
- * @f: file structure.
- * @buf: userspace buffer. set to '1' to enable; '0' to disable automation feature.
- * @size: size of buffer from userpsace.
- * @pos: unused.
- *
- * Return size on success, error code on failure
- */
-static ssize_t hdmi_automation_enable(struct file *f, const char __user *buf,
-	size_t size, loff_t *pos)
-{
-	struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
-	char *wr_buf = NULL;
-	const uint32_t wr_buf_size = 40;
-	int max_param_num = 1;
-	uint8_t param_nums = 0;
-	long param[2];
-	bool hdmi_comp_auto;
-
-	if (size == 0)
-		return -EINVAL;
-
-	wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
-	if (!wr_buf)
-		return -ENOSPC;
-
-	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
-					   (long *)param, buf,
-					   max_param_num,
-					   &param_nums)) {
-		kfree(wr_buf);
-		return -EINVAL;
-	}
-
-	if (param_nums <= 0) {
-		kfree(wr_buf);
-		DRM_DEBUG_DRIVER("user data not be read\n");
-		return -EINVAL;
-	}
-
-	switch (param[0]) {
-	case 0:
-		hdmi_comp_auto = false;
-		break;
-	case 1:
-	default:
-		hdmi_comp_auto = true;
-		break;
-	}
-
-	/* Persist setting across sink re-detection/hotplug. */
-	aconnector->hdmi_comp_auto = hdmi_comp_auto;
-
-	kfree(wr_buf);
-	return size;
-}
-
 DEFINE_SHOW_ATTRIBUTE(dp_dsc_fec_support);
 DEFINE_SHOW_ATTRIBUTE(dmub_fw_state);
 DEFINE_SHOW_ATTRIBUTE(dmub_tracebuffer);
@@ -3156,12 +3098,6 @@ static const struct file_operations dp_mst_link_settings_debugfs_fops = {
 	.llseek = default_llseek
 };
 
-static const struct file_operations hdmi_automation_debugfs_fops = {
-	.owner = THIS_MODULE,
-	.write = hdmi_automation_enable,
-	.llseek = default_llseek
-};
-
 static const struct {
 	char *name;
 	const struct file_operations *fops;
@@ -3194,8 +3130,7 @@ static const struct {
 	const struct file_operations *fops;
 } hdmi_debugfs_entries[] = {
 		{"hdcp_sink_capability", &hdcp_sink_capability_fops},
-		{"hdmi_cec_state", &hdmi_cec_state_fops},
-		{"hdmi_automation", &hdmi_automation_debugfs_fops}
+		{"hdmi_cec_state", &hdmi_cec_state_fops}
 };
 
 /*
@@ -3908,6 +3843,8 @@ void connector_debugfs_init(struct amdgpu_dm_connector *connector)
 					    0644, dir, connector,
 					    hdmi_debugfs_entries[i].fops);
 		}
+
+		debugfs_create_bool("hdmi_automation", 0644, dir, &connector->hdmi_comp_auto);
 	}
 }
 
-- 
2.53.0


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

* Re: [PATCH] drm/amd/display: Simplify hdmi_automation debugfs with debugfs_create_bool
  2026-07-30 18:41 [PATCH] drm/amd/display: Simplify hdmi_automation debugfs with debugfs_create_bool Fangzhi Zuo
@ 2026-07-31 20:14 ` Harry Wentland
  0 siblings, 0 replies; 2+ messages in thread
From: Harry Wentland @ 2026-07-31 20:14 UTC (permalink / raw)
  To: Fangzhi Zuo, amd-gfx, nicolas.frattaroli, krzk



On 2026-07-30 14:41, Fangzhi Zuo wrote:
> Follow-up fix for commit 442b2e9dc9e9 ("drm/amd/display: Add Support for
> HDMI Compliance Automation"), whose hdmi_automation debugfs entry
> hand-rolled the boolean parsing (scratch buffer,
> parse_write_buffer_into_params(), a switch and kfree) that the debugfs
> core already provides.
> 
> hdmi_comp_auto is a plain bool, so bind it directly with
> debugfs_create_bool() and drop the custom write handler, its
> file_operations and the hdmi_debugfs_entries[] row.
> 
> Fixes: 442b2e9dc9e9 ("drm/amd/display: Add Support for HDMI Compliance Automation")
> Signed-off-by: Fangzhi Zuo <jerry.zuo@amd.com>

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

Harry

> ---
>  .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 69 +------------------
>  1 file changed, 3 insertions(+), 66 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> index 830cf8da06b4..45249bebe9fb 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> @@ -2981,64 +2981,6 @@ static ssize_t hdmi_cec_state_write(struct file *f, const char __user *buf,
>  	return size;
>  }
>  
> -/**
> - * hdmi_automation_enable - Enable/Disable HDMI automation feature
> - * @f: file structure.
> - * @buf: userspace buffer. set to '1' to enable; '0' to disable automation feature.
> - * @size: size of buffer from userpsace.
> - * @pos: unused.
> - *
> - * Return size on success, error code on failure
> - */
> -static ssize_t hdmi_automation_enable(struct file *f, const char __user *buf,
> -	size_t size, loff_t *pos)
> -{
> -	struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
> -	char *wr_buf = NULL;
> -	const uint32_t wr_buf_size = 40;
> -	int max_param_num = 1;
> -	uint8_t param_nums = 0;
> -	long param[2];
> -	bool hdmi_comp_auto;
> -
> -	if (size == 0)
> -		return -EINVAL;
> -
> -	wr_buf = kcalloc(wr_buf_size, sizeof(char), GFP_KERNEL);
> -	if (!wr_buf)
> -		return -ENOSPC;
> -
> -	if (parse_write_buffer_into_params(wr_buf, wr_buf_size,
> -					   (long *)param, buf,
> -					   max_param_num,
> -					   &param_nums)) {
> -		kfree(wr_buf);
> -		return -EINVAL;
> -	}
> -
> -	if (param_nums <= 0) {
> -		kfree(wr_buf);
> -		DRM_DEBUG_DRIVER("user data not be read\n");
> -		return -EINVAL;
> -	}
> -
> -	switch (param[0]) {
> -	case 0:
> -		hdmi_comp_auto = false;
> -		break;
> -	case 1:
> -	default:
> -		hdmi_comp_auto = true;
> -		break;
> -	}
> -
> -	/* Persist setting across sink re-detection/hotplug. */
> -	aconnector->hdmi_comp_auto = hdmi_comp_auto;
> -
> -	kfree(wr_buf);
> -	return size;
> -}
> -
>  DEFINE_SHOW_ATTRIBUTE(dp_dsc_fec_support);
>  DEFINE_SHOW_ATTRIBUTE(dmub_fw_state);
>  DEFINE_SHOW_ATTRIBUTE(dmub_tracebuffer);
> @@ -3156,12 +3098,6 @@ static const struct file_operations dp_mst_link_settings_debugfs_fops = {
>  	.llseek = default_llseek
>  };
>  
> -static const struct file_operations hdmi_automation_debugfs_fops = {
> -	.owner = THIS_MODULE,
> -	.write = hdmi_automation_enable,
> -	.llseek = default_llseek
> -};
> -
>  static const struct {
>  	char *name;
>  	const struct file_operations *fops;
> @@ -3194,8 +3130,7 @@ static const struct {
>  	const struct file_operations *fops;
>  } hdmi_debugfs_entries[] = {
>  		{"hdcp_sink_capability", &hdcp_sink_capability_fops},
> -		{"hdmi_cec_state", &hdmi_cec_state_fops},
> -		{"hdmi_automation", &hdmi_automation_debugfs_fops}
> +		{"hdmi_cec_state", &hdmi_cec_state_fops}
>  };
>  
>  /*
> @@ -3908,6 +3843,8 @@ void connector_debugfs_init(struct amdgpu_dm_connector *connector)
>  					    0644, dir, connector,
>  					    hdmi_debugfs_entries[i].fops);
>  		}
> +
> +		debugfs_create_bool("hdmi_automation", 0644, dir, &connector->hdmi_comp_auto);
>  	}
>  }
>  


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

end of thread, other threads:[~2026-07-31 20:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-30 18:41 [PATCH] drm/amd/display: Simplify hdmi_automation debugfs with debugfs_create_bool Fangzhi Zuo
2026-07-31 20:14 ` Harry Wentland

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.