ANDROID: drm/dsi: Fix byte order of DCS set/get brightness
The MIPI DCS specification demands that brightness values are sent in big endian byte order. It also states that one parameter (i.e. one byte) shall be sent/received for 8 bit wide values, and two parameters shall be used for values that are between 9 and 16 bits wide. Bug: 139263611 Bug: 139107810 Change-Id: I24306e21ec6a5ff48ea121d977419a81d5b44152 Signed-off-by: Daniel Mentz <danielmentz@google.com> Signed-off-by: Wilson Sung <wilsonsung@google.com> (cherry picked from commit 3c373bfd83fd686390ea60a032ff876242c71d49) Signed-off-by: Saravana Kannan <saravanak@google.com>
This commit is contained in:
parent
7e7f454531
commit
8a744ca663
4 changed files with 44 additions and 10 deletions
|
@ -1052,17 +1052,33 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_scanline);
|
||||||
* display
|
* display
|
||||||
* @dsi: DSI peripheral device
|
* @dsi: DSI peripheral device
|
||||||
* @brightness: brightness value
|
* @brightness: brightness value
|
||||||
|
* @num_params: 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.
|
||||||
*
|
*
|
||||||
* Return: 0 on success or a negative error code on failure.
|
* Return: 0 on success or a negative error code on failure.
|
||||||
*/
|
*/
|
||||||
int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi,
|
int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi,
|
||||||
u16 brightness)
|
u16 brightness, size_t num_params)
|
||||||
{
|
{
|
||||||
u8 payload[2] = { brightness & 0xff, brightness >> 8 };
|
u8 payload[2];
|
||||||
ssize_t err;
|
ssize_t err;
|
||||||
|
|
||||||
|
switch (num_params) {
|
||||||
|
case 1:
|
||||||
|
payload[0] = brightness & 0xff;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
payload[0] = brightness >> 8;
|
||||||
|
payload[1] = brightness & 0xff;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
|
err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
|
||||||
payload, sizeof(payload));
|
payload, num_params);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -1075,16 +1091,25 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness);
|
||||||
* of the display
|
* of the display
|
||||||
* @dsi: DSI peripheral device
|
* @dsi: DSI peripheral device
|
||||||
* @brightness: brightness value
|
* @brightness: brightness value
|
||||||
|
* @num_params: Number of parameters (i.e. bytes) the brightness value is
|
||||||
|
* encoded in. The MIPI specification states that one parameter
|
||||||
|
* shall be returned from devices that support 8-bit brightness
|
||||||
|
* levels. Devices that support brightness levels wider than
|
||||||
|
* 8-bit return two parameters (i.e. bytes).
|
||||||
*
|
*
|
||||||
* Return: 0 on success or a negative error code on failure.
|
* Return: 0 on success or a negative error code on failure.
|
||||||
*/
|
*/
|
||||||
int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
|
int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
|
||||||
u16 *brightness)
|
u16 *brightness, size_t num_params)
|
||||||
{
|
{
|
||||||
|
u8 payload[2];
|
||||||
ssize_t err;
|
ssize_t err;
|
||||||
|
|
||||||
|
if (!(num_params == 1 || num_params == 2))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS,
|
err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS,
|
||||||
brightness, sizeof(*brightness));
|
payload, num_params);
|
||||||
if (err <= 0) {
|
if (err <= 0) {
|
||||||
if (err == 0)
|
if (err == 0)
|
||||||
err = -ENODATA;
|
err = -ENODATA;
|
||||||
|
@ -1092,6 +1117,15 @@ int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (num_params) {
|
||||||
|
case 1:
|
||||||
|
*brightness = payload[0];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
*brightness = payload[0] << 8 || payload[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness);
|
EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness);
|
||||||
|
|
|
@ -341,7 +341,7 @@ static int dsi_dcs_bl_get_brightness(struct backlight_device *bl)
|
||||||
|
|
||||||
dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
|
dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
|
||||||
|
|
||||||
ret = mipi_dsi_dcs_get_display_brightness(dsi, &brightness);
|
ret = mipi_dsi_dcs_get_display_brightness(dsi, &brightness, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ static int dsi_dcs_bl_update_status(struct backlight_device *bl)
|
||||||
|
|
||||||
dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
|
dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
|
||||||
|
|
||||||
ret = mipi_dsi_dcs_set_display_brightness(dsi, bl->props.brightness);
|
ret = mipi_dsi_dcs_set_display_brightness(dsi, bl->props.brightness, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
@ -365,7 +365,7 @@ static int s6e63j0x03_enable(struct drm_panel *panel)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* set default white brightness */
|
/* set default white brightness */
|
||||||
ret = mipi_dsi_dcs_set_display_brightness(dsi, 0x00ff);
|
ret = mipi_dsi_dcs_set_display_brightness(dsi, 0x00ff, 1);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
@ -283,9 +283,9 @@ int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
|
||||||
int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format);
|
int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format);
|
||||||
int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline);
|
int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline);
|
||||||
int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi,
|
int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi,
|
||||||
u16 brightness);
|
u16 brightness, size_t num_params);
|
||||||
int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
|
int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
|
||||||
u16 *brightness);
|
u16 *brightness, size_t num_params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct mipi_dsi_driver - DSI driver
|
* struct mipi_dsi_driver - DSI driver
|
||||||
|
|
Loading…
Reference in a new issue