From b255322a18b097eec8d4f32d74059cf1d24bd7fb Mon Sep 17 00:00:00 2001 From: Bang Nguyen Date: Thu, 22 Aug 2019 08:19:38 -0500 Subject: [PATCH] gpu/drm: Create sysfs to expose panel vendor infor Create sysfs panelId, panelVer, and panelName in /sys/class/drm/card0-DSI-1 and /sys/class/drm/card0-DSI-2 to expose panel_name, panel_id and panel_ver for panel vendor information. Port from: 5df4be294 Change-Id: If6733e1e64ca61c5576e9db0d7aacf62fb5e54a6 Signed-off-by: Bang Nguyen Reviewed-on: https://gerrit.mot.com/1444418 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1509785 Reviewed-by: Xiangpo Zhao --- drivers/gpu/drm/drm_sysfs.c | 48 +++++++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 7 ++++++ include/drm/drm_modes.h | 7 +++++- 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index ecb7b33002bb..f62ce5f07eaa 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -229,16 +229,64 @@ static ssize_t modes_show(struct device *device, return written; } +static ssize_t panelId_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct drm_connector *connector = to_drm_connector(device); + + mutex_lock(&connector->dev->mode_config.mutex); + snprintf(buf, PAGE_SIZE, "0x%016llx\n", + connector->display_info.panel_id); + mutex_unlock(&connector->dev->mode_config.mutex); + + return 20; +} + +static ssize_t panelVer_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct drm_connector *connector = to_drm_connector(device); + + mutex_lock(&connector->dev->mode_config.mutex); + snprintf(buf, PAGE_SIZE, "0x%016llx\n", + connector->display_info.panel_ver); + mutex_unlock(&connector->dev->mode_config.mutex); + + return 20; +} + +static ssize_t panelName_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct drm_connector *connector = to_drm_connector(device); + + mutex_lock(&connector->dev->mode_config.mutex); + snprintf(buf, PAGE_SIZE, "%s\n", connector->display_info.panel_name); + mutex_unlock(&connector->dev->mode_config.mutex); + + return sizeof(connector->display_info.panel_name); +} + static DEVICE_ATTR_RW(status); static DEVICE_ATTR_RO(enabled); static DEVICE_ATTR_RO(dpms); static DEVICE_ATTR_RO(modes); +static DEVICE_ATTR_RO(panelId); +static DEVICE_ATTR_RO(panelVer); +static DEVICE_ATTR_RO(panelName); + static struct attribute *connector_dev_attrs[] = { &dev_attr_status.attr, &dev_attr_enabled.attr, &dev_attr_dpms.attr, &dev_attr_modes.attr, + &dev_attr_panelId.attr, + &dev_attr_panelVer.attr, + &dev_attr_panelName.attr, NULL }; diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index a3c02470cc39..de11814cd783 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -92,6 +92,8 @@ enum subpixel_order { }; +#define DRM_DISPLAY_NAME_LEN 128 + /** * struct drm_scrambling: sink's scrambling support. */ @@ -266,6 +268,11 @@ struct drm_display_info { */ unsigned int height_mm; + u64 panel_id; + u64 panel_ver; + char panel_name[DRM_DISPLAY_NAME_LEN]; + + /** * @pixel_clock: Maximum pixel clock supported by the sink, in units of * 100Hz. This mismatches the clock in &drm_display_mode (which is in diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h index baded6514456..852a708e46a6 100644 --- a/include/drm/drm_modes.h +++ b/include/drm/drm_modes.h @@ -146,6 +146,7 @@ enum drm_mode_status { #define CRTC_STEREO_DOUBLE_ONLY (CRTC_STEREO_DOUBLE | CRTC_NO_DBLSCAN | CRTC_NO_VSCAN) #define DRM_MODE_FLAG_3D_MAX DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF +#define DRM_MODE_DISPLAY_NAME_LEN 128 #define DRM_MODE_MATCH_TIMINGS (1 << 0) #define DRM_MODE_MATCH_CLOCK (1 << 1) @@ -286,6 +287,10 @@ struct drm_display_mode { int vsync_end; int vtotal; int vscan; + + u64 panel_id; + u64 panel_ver; + char panel_name[DRM_MODE_DISPLAY_NAME_LEN]; /** * @flags: * @@ -331,7 +336,7 @@ struct drm_display_mode { int width_mm; /** - * @height_mm: + * @Height_mm: * * Addressable size of the output in mm, projectors should set this to * 0.