techpack: display: Add dynamic_fps node
Change-Id: I3caa088d98511e472f6264ed69fd3df2ad35f433
This commit is contained in:
parent
62546d50c0
commit
4f09bc86cc
@ -5663,6 +5663,81 @@ static int dsi_display_pre_acquire(void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dsi_display_get_fps(struct dsi_display *display, u32 *fps)
|
||||
{
|
||||
struct dsi_display_mode *cur_mode = NULL;
|
||||
int ret = 0;
|
||||
|
||||
if (!display || !display->panel) {
|
||||
DSI_ERR("Invalid display/panel ptr\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&display->display_lock);
|
||||
cur_mode = display->panel->cur_mode;
|
||||
if (cur_mode) {
|
||||
*fps = cur_mode->timing.refresh_rate;
|
||||
} else {
|
||||
ret = -EINVAL;
|
||||
}
|
||||
mutex_unlock(&display->display_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t dynamic_fps_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct dsi_display *display;
|
||||
u32 fps = 0;
|
||||
int rc = 0;
|
||||
|
||||
struct platform_device *pdev = to_platform_device(dev);
|
||||
display = platform_get_drvdata(pdev);
|
||||
|
||||
if (!display) {
|
||||
DSI_ERR("Invalid display\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = dsi_display_get_fps(display, &fps);
|
||||
if (rc) {
|
||||
DSI_ERR("%s: failed to get fps. rc=%d\n", __func__, rc);
|
||||
return snprintf(buf, PAGE_SIZE, "%s\n", "null");
|
||||
}
|
||||
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", fps);
|
||||
}
|
||||
static DEVICE_ATTR_RO(dynamic_fps);
|
||||
|
||||
static struct attribute *mi_display_attrs[] = {
|
||||
&dev_attr_dynamic_fps.attr,
|
||||
NULL,
|
||||
};
|
||||
ATTRIBUTE_GROUPS(mi_display);
|
||||
|
||||
void dsi_mi_display_init(struct dsi_display *display) {
|
||||
int disp_id = mi_get_disp_id(display);
|
||||
|
||||
if (IS_ERR_OR_NULL(display->class)) {
|
||||
display->class = class_create(THIS_MODULE, "mi_display");
|
||||
if (IS_ERR(display->class))
|
||||
DSI_ERR("class_create failed, rc: %d\n", PTR_ERR(display->class));
|
||||
}
|
||||
|
||||
if (IS_ERR_OR_NULL(display->dev)) {
|
||||
display->dev = device_create_with_groups(display->class, &display->pdev->dev,
|
||||
0, display, mi_display_groups, "disp-DSI-%d", disp_id);
|
||||
if (IS_ERR(display->dev))
|
||||
DSI_ERR("device_create_with_groups failed for disp-DSI-%d, ret: %d\n", disp_id, PTR_ERR(display->dev));
|
||||
}
|
||||
}
|
||||
|
||||
void dsi_mi_display_deinit(struct dsi_display *display) {
|
||||
device_unregister(display->dev);
|
||||
class_destroy(display->class);
|
||||
}
|
||||
|
||||
/**
|
||||
* dsi_display_bind - bind dsi device with controlling device
|
||||
* @dev: Pointer to base of platform device
|
||||
@ -5872,6 +5947,8 @@ static int dsi_display_bind(struct device *dev,
|
||||
|
||||
msm_register_vm_event(master, dev, &vm_event_ops, (void *)display);
|
||||
|
||||
dsi_mi_display_init(display);
|
||||
|
||||
goto error;
|
||||
|
||||
error_host_deinit:
|
||||
@ -5945,6 +6022,8 @@ static void dsi_display_unbind(struct device *dev,
|
||||
atomic_set(&display->clkrate_change_pending, 0);
|
||||
(void)dsi_display_debugfs_deinit(display);
|
||||
|
||||
dsi_mi_display_deinit(display);
|
||||
|
||||
mutex_unlock(&display->display_lock);
|
||||
}
|
||||
|
||||
@ -7548,6 +7627,10 @@ int dsi_display_set_mode(struct dsi_display *display,
|
||||
SDE_EVT32(adj_mode.priv_info->mdp_transfer_time_us,
|
||||
timing.h_active, timing.v_active, timing.refresh_rate);
|
||||
|
||||
if (display->panel->cur_mode->timing.refresh_rate != timing.refresh_rate) {
|
||||
sysfs_notify(&display->dev->kobj, NULL, "dynamic_fps");
|
||||
}
|
||||
|
||||
memcpy(display->panel->cur_mode, &adj_mode, sizeof(adj_mode));
|
||||
error:
|
||||
mutex_unlock(&display->display_lock);
|
||||
|
@ -204,6 +204,8 @@ struct dsi_display {
|
||||
struct drm_device *drm_dev;
|
||||
struct drm_connector *drm_conn;
|
||||
struct drm_connector *ext_conn;
|
||||
struct class *class;
|
||||
struct device *dev;
|
||||
|
||||
const char *name;
|
||||
const char *display_type;
|
||||
|
Loading…
Reference in New Issue
Block a user