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

Commit a54fdd7a authored by Rajeev Nandan's avatar Rajeev Nandan
Browse files

disp: msm: dsi: update args for mipi_dsi_dcs_set_display_brightness



The upstream MIPI DSC set/get brightness api has been changed,
and now it requires one extra argument which is number of
parameters (bytes) to encode brightness value in.
The MIPI specification states that one parameter shall be sent for
devices that support 8-bit brightness levels. For devices that
support brightness levels wider than 8-bit, two parameters
shall be sent.

Change-Id: I08aabf70207d5b7ab79966a1f12fe18b83c34721
Signed-off-by: default avatarRajeev Nandan <rajeevny@codeaurora.org>
parent 454ccc1e
Loading
Loading
Loading
Loading
+27 −3
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include <linux/of_gpio.h>
#include <linux/pwm.h>
#include <video/mipi_display.h>
#include <linux/version.h>

#include "dsi_panel.h"
#include "dsi_ctrl_hw.h"
@@ -638,7 +639,9 @@ static int dsi_panel_update_backlight(struct dsi_panel *panel,
{
	int rc = 0;
	struct mipi_dsi_device *dsi;

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 117))
	size_t num_params = 1;
#endif
	if (!panel || (bl_lvl > 0xffff)) {
		DSI_ERR("invalid params\n");
		return -EINVAL;
@@ -646,10 +649,31 @@ static int dsi_panel_update_backlight(struct dsi_panel *panel,

	dsi = &panel->mipi_device;

	if (panel->bl_config.bl_inverted_dbv)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 117))
	/* The MIPI DCS specification demands that brightness values are sent in
	 * big endian byte order i.e. first parameter is high byte and second
	 * is low byte. But some panels require it in little endian byte order.
	 * The `bl_inverted_dbv` bool was introduced for the panels
	 * supporting big endian order, at the time when the driver was sending
	 * commands in little endian order. We should fix the flag name which
	 * sounds misleading. But, we can not change it at this moment of time,
	 * due to some backward compatibility issue in device tree.
	 */
	if (panel->bl_config.bl_max_level > 0xff) {
		num_params = 2;
		if (!panel->bl_config.bl_inverted_dbv) {
			/* panel requires bl_lvl in little endian */
			bl_lvl = (((bl_lvl & 0xff) << 8) | (bl_lvl >> 8));

		}
	}
	rc = mipi_dsi_dcs_set_display_brightness(dsi, bl_lvl, num_params);
#else
	if (panel->bl_config.bl_inverted_dbv) {
		/* panel requires bl_lvl in big endian */
		bl_lvl = (((bl_lvl & 0xff) << 8) | (bl_lvl >> 8));
	}
	rc = mipi_dsi_dcs_set_display_brightness(dsi, bl_lvl);
#endif
	if (rc < 0)
		DSI_ERR("failed to update dcs backlight:%d\n", bl_lvl);