drm/dsi-mipi: Fix byte order of DCS set/get brightness
Subsystems (6)
RFC PATCH 1/1 drm/dsi-mipi: Fix byte order of DCS set/get brightness
From: Daniel Mentz <[email protected]>
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.
--- drivers/gpu/drm/drm_mipi_dsi.c | 44 ++++++++++++++++--- .../drm/panel/panel-asus-z00t-tm5p5-n35596.c | 4 +- .../gpu/drm/panel/panel-boe-bf060y8m-aj0.c | 4 +- drivers/gpu/drm/panel/panel-ebbg-ft8719.c | 2 +- drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c | 2 +- .../gpu/drm/panel/panel-jdi-lt070me05000.c | 4 +- drivers/gpu/drm/panel/panel-raydium-rm67191.c | 4 +- .../gpu/drm/panel/panel-samsung-s6e63j0x03.c | 2 +- drivers/gpu/drm/panel/panel-samsung-sofef00.c | 4 +- .../panel/panel-sony-tulip-truly-nt35521.c | 4 +- include/drm/drm_mipi_dsi.h | 4 +- 11 files changed, 55 insertions(+), 23 deletions(-)
drivers/gpu/drm/drm_mipi_dsi.c +39 -5
@@ -1180,17 +1180,33 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_scanline);* display * @dsi: DSI peripheral device * @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. */ 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; +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 , - payload,sizeof (payload)); + payload, num_params);if (err <0 )return err;
@@ -1203,16 +1219,25 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness);* of the display * @dsi: DSI peripheral device * @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. */ 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; +if (!(num_params ==1 || num_params ==2 )) +return -EINVAL ; + err =mipi_dsi_dcs_read (dsi,MIPI_DCS_GET_DISPLAY_BRIGHTNESS , - brightness,sizeof (*brightness)); + payload, num_params);if (err <=0 ) {if (err ==0 ) err = -ENODATA ;
@@ -1220,6 +1245,15 @@ int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,return err; } +switch (num_params) { +case 1 : + *brightness = payload[0 ]; +break ; +case 2 : + *brightness = (payload[0 ] <<8 ) | payload[1 ]; +break ; + } +return 0 ; }EXPORT_SYMBOL (mipi_dsi_dcs_get_display_brightness);
drivers/gpu/drm/panel/panel-asus-z00t-tm5p5-n35596.c +2 -2
@@ -220,7 +220,7 @@ static int tm5p5_nt35596_bl_update_status(struct backlight_device *bl) dsi->mode_flags &= ~MIPI_DSI_MODE_LPM ; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;
@@ -237,7 +237,7 @@ static int tm5p5_nt35596_bl_get_brightness(struct backlight_device *bl) 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 )return ret;
drivers/gpu/drm/panel/panel-boe-bf060y8m-aj0.c +2 -2
@@ -253,7 +253,7 @@ static int boe_bf060y8m_aj0_bl_update_status(struct backlight_device *bl)u16 brightness =backlight_get_brightness (bl);int ret; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;
@@ -266,7 +266,7 @@ static int boe_bf060y8m_aj0_bl_get_brightness(struct backlight_device *bl)u16 brightness;int ret; - ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness); + ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness,1 );if (ret <0 )return ret;
drivers/gpu/drm/panel/panel-ebbg-ft8719.c +1 -1
@@ -62,7 +62,7 @@ static int ebbg_ft8719_on(struct ebbg_ft8719 *ctx) dsi->mode_flags |=MIPI_DSI_MODE_LPM ; - ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ); + ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ,1 );if (ret <0 ) {dev_err (dev,"Failed to set display brightness: %d\n" , ret);return ret;
drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c +1 -1
@@ -102,7 +102,7 @@ static int jdi_fhd_r63452_on(struct jdi_fhd_r63452 *ctx)return ret; } - ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ); + ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ,1 );if (ret <0 ) {dev_err (dev,"Failed to set display brightness: %d\n" , ret);return ret;
drivers/gpu/drm/panel/panel-jdi-lt070me05000.c +2 -2
@@ -332,7 +332,7 @@ static int dsi_dcs_bl_get_brightness(struct backlight_device *bl) 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 )return ret;
@@ -348,7 +348,7 @@ static int dsi_dcs_bl_update_status(struct backlight_device *bl) 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 )return ret;
drivers/gpu/drm/panel/panel-raydium-rm67191.c +2 -2
@@ -473,7 +473,7 @@ static int rad_bl_get_brightness(struct backlight_device *bl) 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 )return ret;
@@ -493,7 +493,7 @@ static int rad_bl_update_status(struct backlight_device *bl) 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 )return ret;
drivers/gpu/drm/panel/panel-samsung-s6e63j0x03.c +1 -1
@@ -365,7 +365,7 @@ static int s6e63j0x03_enable(struct drm_panel *panel)return ret;/* 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 )return ret;
drivers/gpu/drm/panel/panel-samsung-sofef00.c +1 -3
@@ -224,10 +224,8 @@ static int sofef00_panel_bl_update_status(struct backlight_device *bl)u16 brightness; brightness = (u16 )backlight_get_brightness (bl); -// This panel needs the high and low bytes swapped for the brightness value - brightness =__swab16 (brightness); - err =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + err =mipi_dsi_dcs_set_display_brightness (dsi, brightness,2 );if (err <0 )return err;
drivers/gpu/drm/panel/panel-sony-tulip-truly-nt35521.c +2 -2
@@ -420,7 +420,7 @@ static int truly_nt35521_bl_update_status(struct backlight_device *bl)u16 brightness =backlight_get_brightness (bl);int ret; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;
@@ -433,7 +433,7 @@ static int truly_nt35521_bl_get_brightness(struct backlight_device *bl)u16 brightness;int ret; - ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness); + ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness,1 );if (ret <0 )return ret;
include/drm/drm_mipi_dsi.h +2 -2
@@ -293,9 +293,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_tear_scanline (struct mipi_dsi_device *dsi,u16 scanline);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, -u16 *brightness); +u16 *brightness,size_t num_params);/** * mipi_dsi_generic_write_seq - transmit data using a generic write packet
Signature · 1 line
2.39.0
Quoted 32 lines · Richard Acayan
From: Daniel Mentz <[email protected]>
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.
Fixes 1a9d759331b8 ("drm/dsi: Implement DCS set/get display brightness")Signed-off-by Daniel Mentz <[email protected]>Change-Id I24306e21ec6a5ff48ea121d977419a81d5b44152[richard: fix 16-bit brightness_get; change brightness call by all panels on the -next tree]Signed-off-by Richard Acayan <[email protected]>--- drivers/gpu/drm/drm_mipi_dsi.c | 44 ++++++++++++++++--- .../drm/panel/panel-asus-z00t-tm5p5-n35596.c | 4 +- .../gpu/drm/panel/panel-boe-bf060y8m-aj0.c | 4 +- drivers/gpu/drm/panel/panel-ebbg-ft8719.c | 2 +- drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c | 2 +- .../gpu/drm/panel/panel-jdi-lt070me05000.c | 4 +- drivers/gpu/drm/panel/panel-raydium-rm67191.c | 4 +- .../gpu/drm/panel/panel-samsung-s6e63j0x03.c | 2 +- drivers/gpu/drm/panel/panel-samsung-sofef00.c | 4 +- .../panel/panel-sony-tulip-truly-nt35521.c | 4 +- include/drm/drm_mipi_dsi.h | 4 +- 11 files changed, 55 insertions(+), 23 deletions(-)drivers/gpu/drm/drm_mipi_dsi.c +0
-0
drivers/gpu/drm/drm_mipi_dsi.c EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_scanline); · line 1187
Quoted 8 lines
drivers/gpu/drm/drm_mipi_dsi.c +5
-0@@ -1180,17 +1180,33 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_scanline);* display * @dsi: DSI peripheral device * @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.
Only one brightness parameter is always sent, no matter how large it is. This isn't the number of parameters, but the number of bytes ("num_bytes").
If there are always one or two bytes, would it be better to have this as a "large" boolean?
Quoted 256 lines
drivers/gpu/drm/drm_mipi_dsi.c +34
-5* * Return: 0 on success or a negative error code on failure. */ 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; +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 , - payload,sizeof (payload)); + payload, num_params);if (err <0 )return err;@@ -1203,16 +1219,25 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness);* of the display * @dsi: DSI peripheral device * @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. */ 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; +if (!(num_params ==1 || num_params ==2 )) +return -EINVAL ; + err =mipi_dsi_dcs_read (dsi,MIPI_DCS_GET_DISPLAY_BRIGHTNESS , - brightness,sizeof (*brightness)); + payload, num_params);if (err <=0 ) {if (err ==0 ) err = -ENODATA ;@@ -1220,6 +1245,15 @@ int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,return err; } +switch (num_params) { +case 1 : + *brightness = payload[0 ]; +break ; +case 2 : + *brightness = (payload[0 ] <<8 ) | payload[1 ]; +break ; + } +return 0 ; }EXPORT_SYMBOL (mipi_dsi_dcs_get_display_brightness);drivers/gpu/drm/panel/panel-asus-z00t-tm5p5-n35596.c +2
-2@@ -220,7 +220,7 @@ static int tm5p5_nt35596_bl_update_status(struct backlight_device *bl) dsi->mode_flags &= ~MIPI_DSI_MODE_LPM ; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;@@ -237,7 +237,7 @@ static int tm5p5_nt35596_bl_get_brightness(struct backlight_device *bl) 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 )return ret;drivers/gpu/drm/panel/panel-boe-bf060y8m-aj0.c +2
-2@@ -253,7 +253,7 @@ static int boe_bf060y8m_aj0_bl_update_status(struct backlight_device *bl)u16 brightness =backlight_get_brightness (bl);int ret; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;@@ -266,7 +266,7 @@ static int boe_bf060y8m_aj0_bl_get_brightness(struct backlight_device *bl)u16 brightness;int ret; - ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness); + ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness,1 );if (ret <0 )return ret;drivers/gpu/drm/panel/panel-ebbg-ft8719.c +1
-1@@ -62,7 +62,7 @@ static int ebbg_ft8719_on(struct ebbg_ft8719 *ctx) dsi->mode_flags |=MIPI_DSI_MODE_LPM ; - ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ); + ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ,1 );if (ret <0 ) {dev_err (dev,"Failed to set display brightness: %d\n" , ret);return ret;drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c +1
-1@@ -102,7 +102,7 @@ static int jdi_fhd_r63452_on(struct jdi_fhd_r63452 *ctx)return ret; } - ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ); + ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ,1 );if (ret <0 ) {dev_err (dev,"Failed to set display brightness: %d\n" , ret);return ret;drivers/gpu/drm/panel/panel-jdi-lt070me05000.c +2
-2@@ -332,7 +332,7 @@ static int dsi_dcs_bl_get_brightness(struct backlight_device *bl) 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 )return ret;@@ -348,7 +348,7 @@ static int dsi_dcs_bl_update_status(struct backlight_device *bl) 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 )return ret;drivers/gpu/drm/panel/panel-raydium-rm67191.c +2
-2@@ -473,7 +473,7 @@ static int rad_bl_get_brightness(struct backlight_device *bl) 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 )return ret;@@ -493,7 +493,7 @@ static int rad_bl_update_status(struct backlight_device *bl) 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 )return ret;drivers/gpu/drm/panel/panel-samsung-s6e63j0x03.c +1
-1@@ -365,7 +365,7 @@ static int s6e63j0x03_enable(struct drm_panel *panel)return ret;/* 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 )return ret;drivers/gpu/drm/panel/panel-samsung-sofef00.c +1
-3@@ -224,10 +224,8 @@ static int sofef00_panel_bl_update_status(struct backlight_device *bl)u16 brightness; brightness = (u16 )backlight_get_brightness (bl); -// This panel needs the high and low bytes swapped for the brightness value - brightness =__swab16 (brightness); - err =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + err =mipi_dsi_dcs_set_display_brightness (dsi, brightness,2 );if (err <0 )return err;drivers/gpu/drm/panel/panel-sony-tulip-truly-nt35521.c +2
-2@@ -420,7 +420,7 @@ static int truly_nt35521_bl_update_status(struct backlight_device *bl)u16 brightness =backlight_get_brightness (bl);int ret; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;@@ -433,7 +433,7 @@ static int truly_nt35521_bl_get_brightness(struct backlight_device *bl)u16 brightness;int ret; - ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness); + ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness,1 );if (ret <0 )return ret;include/drm/drm_mipi_dsi.h +2
-2@@ -293,9 +293,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_tear_scanline (struct mipi_dsi_device *dsi,u16 scanline);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, -u16 *brightness); +u16 *brightness,size_t num_params);/** * mipi_dsi_generic_write_seq - transmit data using a generic write packet Signature · 1 line
2.39.0
Hi Richard/Daniel.
Quoted 6 lines · Richard Acayan
From: Daniel Mentz <[email protected]>
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.
It is only a few week ago someone write they needed a byteswap to use the kernel provided mipi_dsi_dcs_set_display_brightness(). I did not realize then that this is because it is buggy.
Some comments on the patch:
- It would be nice to split it up so first patch fixes that the parameters are in big-endian. This would go for both set and get.
- Second patch could then introduce the possibility to a driver to use a variant that matches the display.
I would suggest to go for two functions:
mipi_dsi_dcs_set_display_brightness() mipi_dsi_dcs_set_display_brightness_two()
So it is obvious when you go for the two byte version without adding a bool parameter.
If the implementation is done using a helper or two independent functions are up to you.
The patch split would be nice, but at least we should have two functions and not a bool parameter.
Both patches should have the same Fixes tag.
Sam
Quoted 289 lines
Fixes 1a9d759331b8 ("drm/dsi: Implement DCS set/get display brightness")Signed-off-by Daniel Mentz <[email protected]>Change-Id I24306e21ec6a5ff48ea121d977419a81d5b44152[richard: fix 16-bit brightness_get; change brightness call by all panels on the -next tree]Signed-off-by Richard Acayan <[email protected]>--- drivers/gpu/drm/drm_mipi_dsi.c | 44 ++++++++++++++++--- .../drm/panel/panel-asus-z00t-tm5p5-n35596.c | 4 +- .../gpu/drm/panel/panel-boe-bf060y8m-aj0.c | 4 +- drivers/gpu/drm/panel/panel-ebbg-ft8719.c | 2 +- drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c | 2 +- .../gpu/drm/panel/panel-jdi-lt070me05000.c | 4 +- drivers/gpu/drm/panel/panel-raydium-rm67191.c | 4 +- .../gpu/drm/panel/panel-samsung-s6e63j0x03.c | 2 +- drivers/gpu/drm/panel/panel-samsung-sofef00.c | 4 +- .../panel/panel-sony-tulip-truly-nt35521.c | 4 +- include/drm/drm_mipi_dsi.h | 4 +- 11 files changed, 55 insertions(+), 23 deletions(-)drivers/gpu/drm/drm_mipi_dsi.c +39
-5@@ -1180,17 +1180,33 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_scanline);* display * @dsi: DSI peripheral device * @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. */ 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; +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 , - payload,sizeof (payload)); + payload, num_params);if (err <0 )return err;@@ -1203,16 +1219,25 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness);* of the display * @dsi: DSI peripheral device * @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. */ 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; +if (!(num_params ==1 || num_params ==2 )) +return -EINVAL ; + err =mipi_dsi_dcs_read (dsi,MIPI_DCS_GET_DISPLAY_BRIGHTNESS , - brightness,sizeof (*brightness)); + payload, num_params);if (err <=0 ) {if (err ==0 ) err = -ENODATA ;@@ -1220,6 +1245,15 @@ int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,return err; } +switch (num_params) { +case 1 : + *brightness = payload[0 ]; +break ; +case 2 : + *brightness = (payload[0 ] <<8 ) | payload[1 ]; +break ; + } +return 0 ; }EXPORT_SYMBOL (mipi_dsi_dcs_get_display_brightness);drivers/gpu/drm/panel/panel-asus-z00t-tm5p5-n35596.c +2
-2@@ -220,7 +220,7 @@ static int tm5p5_nt35596_bl_update_status(struct backlight_device *bl) dsi->mode_flags &= ~MIPI_DSI_MODE_LPM ; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;@@ -237,7 +237,7 @@ static int tm5p5_nt35596_bl_get_brightness(struct backlight_device *bl) 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 )return ret;drivers/gpu/drm/panel/panel-boe-bf060y8m-aj0.c +2
-2@@ -253,7 +253,7 @@ static int boe_bf060y8m_aj0_bl_update_status(struct backlight_device *bl)u16 brightness =backlight_get_brightness (bl);int ret; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;@@ -266,7 +266,7 @@ static int boe_bf060y8m_aj0_bl_get_brightness(struct backlight_device *bl)u16 brightness;int ret; - ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness); + ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness,1 );if (ret <0 )return ret;drivers/gpu/drm/panel/panel-ebbg-ft8719.c +1
-1@@ -62,7 +62,7 @@ static int ebbg_ft8719_on(struct ebbg_ft8719 *ctx) dsi->mode_flags |=MIPI_DSI_MODE_LPM ; - ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ); + ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ,1 );if (ret <0 ) {dev_err (dev,"Failed to set display brightness: %d\n" , ret);return ret;drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c +1
-1@@ -102,7 +102,7 @@ static int jdi_fhd_r63452_on(struct jdi_fhd_r63452 *ctx)return ret; } - ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ); + ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ,1 );if (ret <0 ) {dev_err (dev,"Failed to set display brightness: %d\n" , ret);return ret;drivers/gpu/drm/panel/panel-jdi-lt070me05000.c +2
-2@@ -332,7 +332,7 @@ static int dsi_dcs_bl_get_brightness(struct backlight_device *bl) 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 )return ret;@@ -348,7 +348,7 @@ static int dsi_dcs_bl_update_status(struct backlight_device *bl) 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 )return ret;drivers/gpu/drm/panel/panel-raydium-rm67191.c +2
-2@@ -473,7 +473,7 @@ static int rad_bl_get_brightness(struct backlight_device *bl) 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 )return ret;@@ -493,7 +493,7 @@ static int rad_bl_update_status(struct backlight_device *bl) 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 )return ret;drivers/gpu/drm/panel/panel-samsung-s6e63j0x03.c +1
-1@@ -365,7 +365,7 @@ static int s6e63j0x03_enable(struct drm_panel *panel)return ret;/* 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 )return ret;drivers/gpu/drm/panel/panel-samsung-sofef00.c +1
-3@@ -224,10 +224,8 @@ static int sofef00_panel_bl_update_status(struct backlight_device *bl)u16 brightness; brightness = (u16 )backlight_get_brightness (bl); -// This panel needs the high and low bytes swapped for the brightness value - brightness =__swab16 (brightness); - err =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + err =mipi_dsi_dcs_set_display_brightness (dsi, brightness,2 );if (err <0 )return err;drivers/gpu/drm/panel/panel-sony-tulip-truly-nt35521.c +2
-2@@ -420,7 +420,7 @@ static int truly_nt35521_bl_update_status(struct backlight_device *bl)u16 brightness =backlight_get_brightness (bl);int ret; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;@@ -433,7 +433,7 @@ static int truly_nt35521_bl_get_brightness(struct backlight_device *bl)u16 brightness;int ret; - ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness); + ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness,1 );if (ret <0 )return ret;include/drm/drm_mipi_dsi.h +2
-2@@ -293,9 +293,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_tear_scanline (struct mipi_dsi_device *dsi,u16 scanline);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, -u16 *brightness); +u16 *brightness,size_t num_params);/** * mipi_dsi_generic_write_seq - transmit data using a generic write packet Signature · 1 line
2.39.0
Quoted 1 line · Sam Ravnborg
Hi Richard/Daniel.
Not sure if you saw the original commit that I linked.
This patch was written in 2017 for the Pixel 3 and Pixel 3 XL smartphones. I didn't contact the original author before sending this, since the kernel that this patch originated from is EOL.
This greeting is still fine because it would be great if the original author took responsibility for getting this patch applied.
Quoted 11 lines · Richard Acayan
Quoted 6 lines
From: Daniel Mentz <[email protected]>
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.
It is only a few week ago someone write they needed a byteswap to use the kernel provided
mipi_dsi_dcs_set_display_brightness(). I did not realize then that this is because it is buggy.
I didn't even consider sending this patch when I initially saw it. I would have performed the byte swap in a new S6E3FA7 panel driver just like in SOFEF00.
Quoted 4 lines
Some comments on the patch:
- It would be nice to split it up so first patch fixes that the parameters are in big-endian. This would go for both set and get.
The brightness is only big endian if it's 16-bit.
Most MIPI panel drivers in the kernel tree only send an 8-bit brightness, or none at all. For these panels, the brightness can be sent as a 16-bit integer in little endian, as it has the same effect as an 8-bit integer, with a zero byte appended. The original MIPI brightness functions work properly with no changes for 8-bit brightness panels only.
If we want separate 8-bit (original) and 16-bit functions, the 8-bit functions shouldn't pass the brightness in big endian. That doesn't mean we shouldn't change them at all.
Quoted 6 lines
- Second patch could then introduce the possibility to a driver to use a variant that matches the display.
I would suggest to go for two functions:
mipi_dsi_dcs_set_display_brightness()mipi_dsi_dcs_set_display_brightness_two()
I'm thinking of a "_large" or "_wide" suffix instead. This would make a 32-bit suffix tricky though, if it is ever needed.
Quoted 4 lines
So it is obvious when you go for the two byte version without adding a bool parameter.
If the implementation is done using a helper or two independent functions are up to you.
These get_display_brightness and set_display_brightness functions are already helpers. I'll have them duplicated.
Quoted 3 lines
The patch split would be nice, but at least we should have two functions and not a bool parameter.
Yes, that was a bad idea on my part. With separate functions for 16-bit brightness, there is no API change, less panel driver touching, and panel driver changes can happen in separate patches. Thank you for the suggestion.
Quoted 294 lines
Both patches should have the same Fixes tag.
Sam
Quoted 289 lines
Fixes 1a9d759331b8 ("drm/dsi: Implement DCS set/get display brightness")Signed-off-by Daniel Mentz <[email protected]>Change-Id I24306e21ec6a5ff48ea121d977419a81d5b44152[richard: fix 16-bit brightness_get; change brightness call by all panels on the -next tree]Signed-off-by Richard Acayan <[email protected]>--- drivers/gpu/drm/drm_mipi_dsi.c | 44 ++++++++++++++++--- .../drm/panel/panel-asus-z00t-tm5p5-n35596.c | 4 +- .../gpu/drm/panel/panel-boe-bf060y8m-aj0.c | 4 +- drivers/gpu/drm/panel/panel-ebbg-ft8719.c | 2 +- drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c | 2 +- .../gpu/drm/panel/panel-jdi-lt070me05000.c | 4 +- drivers/gpu/drm/panel/panel-raydium-rm67191.c | 4 +- .../gpu/drm/panel/panel-samsung-s6e63j0x03.c | 2 +- drivers/gpu/drm/panel/panel-samsung-sofef00.c | 4 +- .../panel/panel-sony-tulip-truly-nt35521.c | 4 +- include/drm/drm_mipi_dsi.h | 4 +- 11 files changed, 55 insertions(+), 23 deletions(-)drivers/gpu/drm/drm_mipi_dsi.c +39
-5@@ -1180,17 +1180,33 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_scanline);* display * @dsi: DSI peripheral device * @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. */ 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; +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 , - payload,sizeof (payload)); + payload, num_params);if (err <0 )return err;@@ -1203,16 +1219,25 @@ EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness);* of the display * @dsi: DSI peripheral device * @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. */ 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; +if (!(num_params ==1 || num_params ==2 )) +return -EINVAL ; + err =mipi_dsi_dcs_read (dsi,MIPI_DCS_GET_DISPLAY_BRIGHTNESS , - brightness,sizeof (*brightness)); + payload, num_params);if (err <=0 ) {if (err ==0 ) err = -ENODATA ;@@ -1220,6 +1245,15 @@ int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,return err; } +switch (num_params) { +case 1 : + *brightness = payload[0 ]; +break ; +case 2 : + *brightness = (payload[0 ] <<8 ) | payload[1 ]; +break ; + } +return 0 ; }EXPORT_SYMBOL (mipi_dsi_dcs_get_display_brightness);drivers/gpu/drm/panel/panel-asus-z00t-tm5p5-n35596.c +2
-2@@ -220,7 +220,7 @@ static int tm5p5_nt35596_bl_update_status(struct backlight_device *bl) dsi->mode_flags &= ~MIPI_DSI_MODE_LPM ; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;@@ -237,7 +237,7 @@ static int tm5p5_nt35596_bl_get_brightness(struct backlight_device *bl) 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 )return ret;drivers/gpu/drm/panel/panel-boe-bf060y8m-aj0.c +2
-2@@ -253,7 +253,7 @@ static int boe_bf060y8m_aj0_bl_update_status(struct backlight_device *bl)u16 brightness =backlight_get_brightness (bl);int ret; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;@@ -266,7 +266,7 @@ static int boe_bf060y8m_aj0_bl_get_brightness(struct backlight_device *bl)u16 brightness;int ret; - ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness); + ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness,1 );if (ret <0 )return ret;drivers/gpu/drm/panel/panel-ebbg-ft8719.c +1
-1@@ -62,7 +62,7 @@ static int ebbg_ft8719_on(struct ebbg_ft8719 *ctx) dsi->mode_flags |=MIPI_DSI_MODE_LPM ; - ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ); + ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ,1 );if (ret <0 ) {dev_err (dev,"Failed to set display brightness: %d\n" , ret);return ret;drivers/gpu/drm/panel/panel-jdi-fhd-r63452.c +1
-1@@ -102,7 +102,7 @@ static int jdi_fhd_r63452_on(struct jdi_fhd_r63452 *ctx)return ret; } - ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ); + ret =mipi_dsi_dcs_set_display_brightness (dsi,0x00ff ,1 );if (ret <0 ) {dev_err (dev,"Failed to set display brightness: %d\n" , ret);return ret;drivers/gpu/drm/panel/panel-jdi-lt070me05000.c +2
-2@@ -332,7 +332,7 @@ static int dsi_dcs_bl_get_brightness(struct backlight_device *bl) 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 )return ret;@@ -348,7 +348,7 @@ static int dsi_dcs_bl_update_status(struct backlight_device *bl) 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 )return ret;drivers/gpu/drm/panel/panel-raydium-rm67191.c +2
-2@@ -473,7 +473,7 @@ static int rad_bl_get_brightness(struct backlight_device *bl) 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 )return ret;@@ -493,7 +493,7 @@ static int rad_bl_update_status(struct backlight_device *bl) 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 )return ret;drivers/gpu/drm/panel/panel-samsung-s6e63j0x03.c +1
-1@@ -365,7 +365,7 @@ static int s6e63j0x03_enable(struct drm_panel *panel)return ret;/* 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 )return ret;drivers/gpu/drm/panel/panel-samsung-sofef00.c +1
-3@@ -224,10 +224,8 @@ static int sofef00_panel_bl_update_status(struct backlight_device *bl)u16 brightness; brightness = (u16 )backlight_get_brightness (bl); -// This panel needs the high and low bytes swapped for the brightness value - brightness =__swab16 (brightness); - err =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + err =mipi_dsi_dcs_set_display_brightness (dsi, brightness,2 );if (err <0 )return err;drivers/gpu/drm/panel/panel-sony-tulip-truly-nt35521.c +2
-2@@ -420,7 +420,7 @@ static int truly_nt35521_bl_update_status(struct backlight_device *bl)u16 brightness =backlight_get_brightness (bl);int ret; - ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness); + ret =mipi_dsi_dcs_set_display_brightness (dsi, brightness,1 );if (ret <0 )return ret;@@ -433,7 +433,7 @@ static int truly_nt35521_bl_get_brightness(struct backlight_device *bl)u16 brightness;int ret; - ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness); + ret =mipi_dsi_dcs_get_display_brightness (dsi, &brightness,1 );if (ret <0 )return ret;include/drm/drm_mipi_dsi.h +2
-2@@ -293,9 +293,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_tear_scanline (struct mipi_dsi_device *dsi,u16 scanline);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, -u16 *brightness); +u16 *brightness,size_t num_params);/** * mipi_dsi_generic_write_seq - transmit data using a generic write packet Signature · 1 line
2.39.0
Hi Richard,
Quoted 39 lines · Richard Acayan
Quoted 1 line · Sam Ravnborg
Hi Richard/Daniel.
Not sure if you saw the original commit that I linked.
This patch was written in 2017 for the Pixel 3 and Pixel 3 XL smartphones. I didn't contact the original author before sending this, since the kernel that this patch originated from is EOL.
This greeting is still fine because it would be great if the original author took responsibility for getting this patch applied.
Quoted 11 lines · Richard Acayan
Quoted 6 lines
From: Daniel Mentz <[email protected]>
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.
It is only a few week ago someone write they needed a byteswap to use the kernel provided
mipi_dsi_dcs_set_display_brightness(). I did not realize then that this is because it is buggy.I didn't even consider sending this patch when I initially saw it. I would have performed the byte swap in a new S6E3FA7 panel driver just like in SOFEF00.
Quoted 4 lines
Some comments on the patch:
- It would be nice to split it up so first patch fixes that the parameters are in big-endian. This would go for both set and get.The brightness is only big endian if it's 16-bit.
Most MIPI panel drivers in the kernel tree only send an 8-bit brightness, or none at all. For these panels, the brightness can be sent as a 16-bit integer in little endian, as it has the same effect as an 8-bit integer, with a zero byte appended. The original MIPI brightness functions work properly with no changes for 8-bit brightness panels only.
Quoted 3 lines
If we want separate 8-bit (original) and 16-bit functions, the 8-bit functions shouldn't pass the brightness in big endian. That doesn't mean we shouldn't change them at all.
Agree, the brightness is passed exactly as returned by backlight_get_brightness(), and the helper take care of the correct byte ordering.
Quoted 9 lines
Quoted 7 lines
- Second patch could then introduce the possibility to a driver to use a variant that matches the display.
I would suggest to go for two functions:
mipi_dsi_dcs_set_display_brightness()mipi_dsi_dcs_set_display_brightness_two()I'm thinking of a "
_large" or "_wide" suffix instead. This would make a 32-bit suffix tricky though, if it is ever needed.
_large is way better than _two, and would be my choice.
Quoted 9 lines
Quoted 5 lines
So it is obvious when you go for the two byte version without adding a bool parameter.
If the implementation is done using a helper or two independent functions are up to you.These
get_display_brightnessandset_display_brightnessfunctions are already helpers. I'll have them duplicated.Quoted 1 line
Quoted 6 lines
Quoted 2 lines
The patch split would be nice, but at least we should have two functions and not a bool parameter.
Yes, that was a bad idea on my part. With separate functions for 16-bit brightness, there is no API change, less panel driver touching, and panel driver changes can happen in separate patches. Thank you for the suggestion.
Great, looks forward for the patches.
Sam