diff --git a/techpack/display/msm/dsi/dsi_display.c b/techpack/display/msm/dsi/dsi_display.c index a95850ca0ef2..4677a89cc968 100644 --- a/techpack/display/msm/dsi/dsi_display.c +++ b/techpack/display/msm/dsi/dsi_display.c @@ -6742,6 +6742,10 @@ int dsi_display_dev_probe(struct platform_device *pdev) panel_class_create(pdev); + if (index == DSI_PRIMARY) { + sde_sysfs_mot_kms_prop_util_init(display); + } + return 0; end: if (display) @@ -6782,6 +6786,10 @@ int dsi_display_dev_remove(struct platform_device *pdev) } } + if (display->panel_idx == 0) { + sde_sysfs_mot_kms_prop_util_deinit(display); + } + (void)_dsi_display_dev_deinit(display); platform_set_drvdata(pdev, NULL); diff --git a/techpack/display/msm/dsi/dsi_panel.c b/techpack/display/msm/dsi/dsi_panel.c index 3feade367617..78b49a0c4648 100644 --- a/techpack/display/msm/dsi/dsi_panel.c +++ b/techpack/display/msm/dsi/dsi_panel.c @@ -899,7 +899,7 @@ error: return rc; } -static bool dsi_panel_param_is_supported(u32 param_idx) +bool dsi_panel_param_is_supported(u32 param_idx) { struct panel_param *param = NULL; diff --git a/techpack/display/msm/dsi/dsi_panel.h b/techpack/display/msm/dsi/dsi_panel.h index 802cf867df4c..dee68caa5e07 100644 --- a/techpack/display/msm/dsi/dsi_panel.h +++ b/techpack/display/msm/dsi/dsi_panel.h @@ -561,6 +561,8 @@ void dsi_panel_destroy_cmd_packets(struct dsi_panel_cmd_set *set); void dsi_panel_dealloc_cmd_packets(struct dsi_panel_cmd_set *set); +bool dsi_panel_param_is_supported(u32 param_idx); + int dsi_panel_set_param(struct dsi_panel *panel, struct msm_param_info *param_info); diff --git a/techpack/display/msm/sde/sde_motUtil.c b/techpack/display/msm/sde/sde_motUtil.c index 0f3a08ae6d34..b6d1a68b9117 100644 --- a/techpack/display/msm/sde/sde_motUtil.c +++ b/techpack/display/msm/sde/sde_motUtil.c @@ -417,3 +417,112 @@ int sde_debugfs_mot_util_init(struct sde_kms *sde_kms, mutex_init(&motUtil_data.lock); return 0; } + +static int _sde_sysfs_motUtil_kms_prop_test(struct device *dev, size_t count, + char *buf) +{ + struct dsi_display *display; + struct sde_kms *sde_kms; + + display = dev_get_drvdata(dev); + if (!display) { + SDE_ERROR("Invalid display\n"); + return -ENODEV; + } + + sde_kms = to_sde_kms( + ((struct msm_drm_private *)display->drm_dev->dev_private)->kms); + + return _sde_debugfs_motUtil_kms_prop_test(sde_kms, count, buf); +} + +struct mot_kmsprop_attribute { + struct device_attribute attr; + u32 param_idx; + enum sde_motUtil_kmsPropTest_ConnPropType conn_type; +}; + +static ssize_t dsi_display_mot_kmsprop_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct mot_kmsprop_attribute *kmsprop_attr = + container_of(attr, struct mot_kmsprop_attribute, attr); + char input[] = { MOTUTIL_KMS_PROP_TEST, MOTUTIL_MAIN_DISP, + KMSPROPTEST_GETPROP, kmsprop_attr->conn_type }; + int rc, val; + + mutex_lock(&motUtil_data.lock); + rc = _sde_sysfs_motUtil_kms_prop_test(dev, ARRAY_SIZE(input), input); + val = motUtil_data.val; + mutex_unlock(&motUtil_data.lock); + + if (rc < 0) + return rc; + + return snprintf(buf, PAGE_SIZE, "%d\n", val); +} + +static ssize_t dsi_display_mot_kmsprop_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct mot_kmsprop_attribute *kmsprop_attr = + container_of(attr, struct mot_kmsprop_attribute, attr); + char input[] = { MOTUTIL_KMS_PROP_TEST, MOTUTIL_MAIN_DISP, + KMSPROPTEST_SETPROP, kmsprop_attr->conn_type, 0 }; + int rc, val; + + rc = kstrtoint(buf, 10, &val); + if (rc < 0) + return -EINVAL; + input[KMSPROPTEST_NEW_VAL] = val; + + mutex_lock(&motUtil_data.lock); + rc = _sde_sysfs_motUtil_kms_prop_test(dev, ARRAY_SIZE(input), input); + mutex_unlock(&motUtil_data.lock); + + if (rc < 0) + return rc; + + return count; +} + +#define KMS_PROP_ATTR(_name, _param_idx, _conn_type) \ + { \ + __ATTR(_name, 0660, dsi_display_mot_kmsprop_show, \ + dsi_display_mot_kmsprop_store), \ + _param_idx, _conn_type \ + } + +static struct mot_kmsprop_attribute kmsprop_attrs[] = { + KMS_PROP_ATTR(hbm, PARAM_HBM_ID, KMSPROPTEST_TYPE_HBM), + KMS_PROP_ATTR(acl, PARAM_ACL_ID, KMSPROPTEST_TYPE_ACL), + KMS_PROP_ATTR(cabc, PARAM_CABC_ID, KMSPROPTEST_TYPE_CABC), + KMS_PROP_ATTR(dc, PARAM_DC_ID, KMSPROPTEST_TYPE_DC), +}; + +void sde_sysfs_mot_kms_prop_util_init(struct dsi_display *display) +{ + struct device *dev = &display->pdev->dev; + int rc, i; + + for (i = 0; i < ARRAY_SIZE(kmsprop_attrs); ++i) { + if (!dsi_panel_param_is_supported(kmsprop_attrs[i].param_idx)) + continue; + rc = sysfs_create_file(&dev->kobj, &kmsprop_attrs[i].attr.attr); + if (rc) + DRM_ERROR("Failed to create sysfs for param id=%d\n", + kmsprop_attrs[i].param_idx); + } +} + +void sde_sysfs_mot_kms_prop_util_deinit(struct dsi_display *display) +{ + struct device *dev = &display->pdev->dev; + int i; + + for (i = 0; i < ARRAY_SIZE(kmsprop_attrs); ++i) { + sysfs_remove_file(&dev->kobj, &kmsprop_attrs[i].attr.attr); + } +} diff --git a/techpack/display/msm/sde/sde_motUtil.h b/techpack/display/msm/sde/sde_motUtil.h index 0248418d1270..b3653e7cc4a1 100644 --- a/techpack/display/msm/sde/sde_motUtil.h +++ b/techpack/display/msm/sde/sde_motUtil.h @@ -148,4 +148,8 @@ struct motUtil { int sde_debugfs_mot_util_init(struct sde_kms *sde_kms, struct dentry *parent); +struct dsi_display; +void sde_sysfs_mot_kms_prop_util_init(struct dsi_display *display); +void sde_sysfs_mot_kms_prop_util_deinit(struct dsi_display *display); + #endif /* __MOTUTIL_H__ */