Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53654b53 authored by Ram Chandrasekar's avatar Ram Chandrasekar Committed by Gerrit - the friendly Code Review server
Browse files

disp: msm: sde: Register display brightness cooling device



Register for getting a blocking notified call when the display cooling
device mitigates. Update the current brightness to the thermally allowed
level.

Change-Id: I20945a20751646e6d9bbf8bb7e7039c6ce43c306
Signed-off-by: default avatarRam Chandrasekar <rkumbako@codeaurora.org>
parent 132fd394
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include "sde_kms.h"
#include "sde_connector.h"
#include "sde_encoder.h"
#include "msm_cooling_device.h"
#include <linux/backlight.h>
#include <linux/string.h>
#include "dsi_drm.h"
@@ -90,6 +91,8 @@ static int sde_backlight_device_update_status(struct backlight_device *bd)
	display = (struct dsi_display *) c_conn->display;
	if (brightness > display->panel->bl_config.bl_max_level)
		brightness = display->panel->bl_config.bl_max_level;
	if (brightness > c_conn->thermal_max_brightness)
		brightness = c_conn->thermal_max_brightness;

	/* map UI brightness into driver backlight level with rounding */
	bl_lvl = mult_frac(brightness, display->panel->bl_config.bl_max_level,
@@ -129,6 +132,20 @@ static const struct backlight_ops sde_backlight_device_ops = {
	.get_brightness = sde_backlight_device_get_brightness,
};

static int sde_backlight_cooling_cb(struct notifier_block *nb,
					unsigned long val, void *data)
{
	struct sde_connector *c_conn;
	struct backlight_device *bd = (struct backlight_device *)data;

	c_conn = bl_get_data(bd);
	SDE_DEBUG("bl: thermal max brightness cap:%lu\n", val);
	c_conn->thermal_max_brightness = val;

	sde_backlight_device_update_status(bd);
	return 0;
}

static int sde_backlight_setup(struct sde_connector *c_conn,
					struct drm_device *dev)
{
@@ -163,6 +180,17 @@ static int sde_backlight_setup(struct sde_connector *c_conn,
		c_conn->bl_device = NULL;
		return -ENODEV;
	}
	c_conn->thermal_max_brightness = bl_config->brightness_max_level;
	c_conn->n.notifier_call = sde_backlight_cooling_cb;
	c_conn->cdev = backlight_cdev_register(dev->dev, c_conn->bl_device,
							&c_conn->n);
	if (IS_ERR_OR_NULL(c_conn->cdev)) {
		SDE_ERROR("Failed to register backlight cdev: %ld\n",
				    PTR_ERR(c_conn->cdev));
		backlight_device_unregister(c_conn->bl_device);
		c_conn->bl_device = NULL;
		return -ENODEV;
	}
	display_count++;

	return 0;
@@ -945,6 +973,8 @@ void sde_connector_destroy(struct drm_connector *connector)
	if (c_conn->blob_ext_hdr)
		drm_property_blob_put(c_conn->blob_ext_hdr);

	if (c_conn->cdev)
		backlight_cdev_unregister(c_conn->cdev);
	if (c_conn->bl_device)
		backlight_device_unregister(c_conn->bl_device);
	drm_connector_unregister(connector);
+6 −0
Original line number Diff line number Diff line
@@ -412,6 +412,9 @@ struct sde_connector_dyn_hdr_metadata {
 * @event_table: Array of registered events
 * @event_lock: Lock object for event_table
 * @bl_device: backlight device node
 * @cdev: backlight cooling device interface
 * @n: backlight cooling device notifier
 * @thermal_max_brightness: thermal max brightness cap
 * @status_work: work object to perform status checks
 * @esd_status_interval: variable to change ESD check interval in millisec
 * @panel_dead: Flag to indicate if panel has gone bad
@@ -470,6 +473,9 @@ struct sde_connector {
	spinlock_t event_lock;

	struct backlight_device *bl_device;
	struct sde_cdev *cdev;
	struct notifier_block n;
	unsigned long thermal_max_brightness;
	struct delayed_work status_work;
	u32 esd_status_interval;
	bool panel_dead;