drm/dsi: Implement dcs set/get display brightness
Subsystems (3)
PATCH v3 1/2 drm/dsi: Implement dcs set/get display brightness
Provide a small convenience wrapper that set/get the display brightness value
---
v1:
*tested in nexus7 2nd gen.
v2:
* implemented jani review comments
-functions name mapped accordingly
-bl value increased from 0xff to 0xffff -backlight interface will be handled in panel driver,
so it is moved from the mipi_dsi helper function
v3:
* emil review comments
(err < 0) supposed to be (err <= 0)
--- drivers/gpu/drm/drm_mipi_dsi.c | 49 ++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 4 ++++ 2 files changed, 53 insertions(+)
drivers/gpu/drm/drm_mipi_dsi.c +49 -0
@@ -1041,6 +1041,55 @@ int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) }EXPORT_SYMBOL (mipi_dsi_dcs_set_pixel_format); +/** +* mipi_dsi_dcs_get_display_brightness() - gets the current brightness value +* of the display +* @dsi: DSI peripheral device +* @brightness: brightness value +* +* 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) +{ +ssize_t err; + + err =mipi_dsi_dcs_read (dsi,MIPI_DCS_GET_DISPLAY_BRIGHTNESS , + brightness,sizeof (*brightness)); +if (err <=0 ) { +if (err ==0 ) + err = -ENODATA ; + +return err; + } + +return 0 ; +} +EXPORT_SYMBOL (mipi_dsi_dcs_get_display_brightness); + +/** +* mipi_dsi_dcs_set_display_brightness() - sets the brightness value of +* the display +* @dsi: DSI peripheral device +* @brightness: brightness value +* +* 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) +{ +ssize_t err; +u8 bl_value[2 ] = { brightness &0xff , brightness >>8 }; + + err =mipi_dsi_dcs_write (dsi,MIPI_DCS_SET_DISPLAY_BRIGHTNESS , + bl_value,sizeof (bl_value)); +if (err <0 ) +return err; + +return 0 ; +} +EXPORT_SYMBOL (mipi_dsi_dcs_set_display_brightness); +static int mipi_dsi_drv_probe (struct device *dev) {struct mipi_dsi_driver *drv =to_mipi_dsi_driver (dev->driver);
include/drm/drm_mipi_dsi.h +4 -0
@@ -270,6 +270,10 @@ int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);int mipi_dsi_dcs_set_tear_on (struct mipi_dsi_device *dsi,enum mipi_dsi_dcs_tear_mode mode);int mipi_dsi_dcs_set_pixel_format (struct mipi_dsi_device *dsi,u8 format); +int mipi_dsi_dcs_get_display_brightness (struct mipi_dsi_device *dsi, +u16 *brightness); +int mipi_dsi_dcs_set_display_brightness (struct mipi_dsi_device *dsi, +u16 brightness);/** * struct mipi_dsi_driver - DSI driver
Signature · 1 line
2.1.2
PATCH v8 2/2 drm/panel: Add JDI LT070ME05000 WUXGA DSI Panel
Add support for the JDI LT070ME05000 WUXGA DSI panel used in Nexus 7 2013 devices.
Programming sequence for the panel is was originally found in the android-msm-flo-3.4-lollipop-release branch from:
https://android.googlesource.com/kernel/msm.git
And video mode setting is from dsi-panel-jdi-dualmipi1-video.dtsi file in:
git://codeaurora.org/kernel/msm-3.10.git LNX.LA.3.6_rb1.27
---
v1:
* sumit ported to drm/panel framework, john cherry-picked to mainline, folded down other fixes from Vinay and Archit, vinay removed interface setting cmd mode, video mode panel selected
v2:
* incorporated code reviews from theiry, archit
code style, alphabetical soring in Makefile, Kconfig, regulator_bulk, arrays of u8, generic helper function, documentation bindings,
v3:
* dcs backlight support added
* tested this panel driver in nexus7 2013 device
v4:
* backlight interface added in the panel driver
* incorporated width_mm and height_mm suggested by rob herring
v5:
* theirry review comments incorporated
panel model naming consistent, alphabetical soring in Kconfig Makefile, MAX_BRIGHTNESS dropped, regulator_names, parameterize panel width and height, descprition for control display, cabc and interface setting, temporary variable removed, consistent error reporting and commit message
* removed tear on/off, scanline, since these are required only for command mode panels
v6:
* emil review comments incorporated PANEL_NUM_REGULATORS dropped, return ret added at necessary places, if checks dropped for backlight and gpios
v7:
* emil review comments incorporated
added ARRAY_SIZE in struct, regulator_bulk_disable in poweroff, gpios checks dropped.
some returns cannot be dropped, since drm panel framework return type required.
v8:
* emil review commnets incorporated for jdi_panel_unprepare, dropped the returns (ref: panel-sharp-lq101r1sx01.c) and for jdi_panel_prepare(panel_on) it does not return prematurely and goes to poweroff if not success
* few dev_err's for panel_init
--- drivers/gpu/drm/panel/Kconfig | 11 + drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-jdi-lt070me05000.c | 518 +++++++++++++++++++++++++ 3 files changed, 530 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-jdi-lt070me05000.c
drivers/gpu/drm/panel/Kconfig +11 -0
@@ -18,6 +18,17 @@ config DRM_PANEL_SIMPLE that it can be automatically turned off when the panel goes into a low power state. +config DRM_PANEL_JDI_LT070ME05000 + tristate "JDI LT070ME05000 WUXGA DSI panel" + depends on OF + depends on DRM_MIPI_DSI + depends on BACKLIGHT_CLASS_DEVICE + help + Say Y here if you want to enable support for JDI DSI video mode + panel as found in Google Nexus 7 (2013) devices. + The panel has a 1200(RGB)×1920 (WUXGA) resolution and uses + 24 bit per pixel. + config DRM_PANEL_SAMSUNG_LD9040 tristate "Samsung LD9040 RGB/SPI panel" depends on OF && SPI
drivers/gpu/drm/panel/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o +obj-$(CONFIG_DRM_PANEL_JDI_LT070ME05000) += panel-jdi-lt070me05000.o obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += panel-panasonic-vvx10f034n00.o obj-$(CONFIG_DRM_PANEL_SAMSUNG_LD9040) += panel-samsung-ld9040.o
drivers/gpu/drm/panel/panel-jdi-lt070me05000.c new file +518 -0
518 lines not on this page · raw message
Signature · 1 line
2.1.2
Quoted 48 lines · Vinay Simha BN
Provide a small convenience wrapper that set/get the display brightness value
Cc John Stultz <[email protected]>Cc Sumit Semwal <[email protected]>Cc Archit Taneja <[email protected]>Cc Rob Clark <[email protected]>Cc Jani Nikula <[email protected]>Cc Thierry Reding <[email protected]>Cc Emil Velikov <[email protected]>Signed-off-by Vinay Simha BN <[email protected]>---
v1:
*tested in nexus7 2nd gen.v2:
* implemented jani review comments
-functions name mapped accordingly
-bl value increased from0xffto0xffff-backlight interface will be handled in panel driver,
so it is moved from themipi_dsihelper functionv3:
* emil review comments
(err < 0) supposed to be (err <= 0)--- drivers/gpu/drm/drm_mipi_dsi.c | 49 ++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 4 ++++ 2 files changed, 53 insertions(+)drivers/gpu/drm/drm_mipi_dsi.c +9
-0@@ -1041,6 +1041,55 @@ int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) }EXPORT_SYMBOL (mipi_dsi_dcs_set_pixel_format); +/** +* mipi_dsi_dcs_get_display_brightness() - gets the current brightness value +* of the display +* @dsi: DSI peripheral device +* @brightness: brightness value +* +* Return: 0 on success or a negative error code on failure. +*/ +int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
drivers/gpu/drm/drm_mipi_dsi.c int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) · line 1062
Quoted 10 lines
drivers/gpu/drm/drm_mipi_dsi.c +10
-0+ u16 *brightness) +{ +ssize_t err; + + err =mipi_dsi_dcs_read (dsi,MIPI_DCS_GET_DISPLAY_BRIGHTNESS , + brightness,sizeof (*brightness)); +if (err <=0 ) { +if (err ==0 ) + err = -ENODATA ; +
Looks better now. Thank you.
drivers/gpu/drm/drm_mipi_dsi.c int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) · line 1063
Quoted 1 line
drivers/gpu/drm/drm_mipi_dsi.c +1
-0+return err;
Side note:
When sizeof(ssize_t) != sizeof(int) this might lead to some very annoying bugs. In practise I doubt anyone uses error codes in the SSIZE_MIN to INT_MIN range so we should be safe.
Regards,
Emil
Quoted 52 lines · Vinay Simha BN
Provide a small convenience wrapper that set/get the display brightness value
Cc John Stultz <[email protected]>Cc Sumit Semwal <[email protected]>Cc Archit Taneja <[email protected]>Cc Rob Clark <[email protected]>Cc Jani Nikula <[email protected]>Cc Thierry Reding <[email protected]>Cc Emil Velikov <[email protected]>Signed-off-by Vinay Simha BN <[email protected]>---
v1:
*tested in nexus7 2nd gen.v2:
* implemented jani review comments
-functions name mapped accordingly
-bl value increased from0xffto0xffff-backlight interface will be handled in panel driver,
so it is moved from themipi_dsihelper functionv3:
* emil review comments
(err < 0) supposed to be (err <= 0)--- drivers/gpu/drm/drm_mipi_dsi.c | 49 ++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 4 ++++ 2 files changed, 53 insertions(+)drivers/gpu/drm/drm_mipi_dsi.c +13
-0@@ -1041,6 +1041,55 @@ int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) }EXPORT_SYMBOL (mipi_dsi_dcs_set_pixel_format); +/** +* mipi_dsi_dcs_get_display_brightness() - gets the current brightness value +* of the display +* @dsi: DSI peripheral device +* @brightness: brightness value +* +* 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) +{ +ssize_t err; +
drivers/gpu/drm/drm_mipi_dsi.c int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) · line 1066
Quoted 10 lines
drivers/gpu/drm/drm_mipi_dsi.c +10
-0+ err =mipi_dsi_dcs_read (dsi,MIPI_DCS_GET_DISPLAY_BRIGHTNESS , + brightness,sizeof (*brightness)); +if (err <=0 ) { +if (err ==0 ) + err = -ENODATA ; + +return err; + } + +return 0 ;
IMO, this is still pretty awkward. I think the following is a bit more conventional:
err = mipi_dsi_dcs_...
if (err == 0)
return -ENODATA;
else if (err < 0)
return err;return 0;
Quoted 47 lines
drivers/gpu/drm/drm_mipi_dsi.c +26
-0+} +EXPORT_SYMBOL (mipi_dsi_dcs_get_display_brightness); + +/** +* mipi_dsi_dcs_set_display_brightness() - sets the brightness value of +* the display +* @dsi: DSI peripheral device +* @brightness: brightness value +* +* 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) +{ +ssize_t err; +u8 bl_value[2 ] = { brightness &0xff , brightness >>8 }; + + err =mipi_dsi_dcs_write (dsi,MIPI_DCS_SET_DISPLAY_BRIGHTNESS , + bl_value,sizeof (bl_value)); +if (err <0 ) +return err; + +return 0 ; +} +EXPORT_SYMBOL (mipi_dsi_dcs_set_display_brightness); +static int mipi_dsi_drv_probe (struct device *dev) {struct mipi_dsi_driver *drv =to_mipi_dsi_driver (dev->driver);include/drm/drm_mipi_dsi.h +4
-1@@ -270,6 +270,10 @@ int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);int mipi_dsi_dcs_set_tear_on (struct mipi_dsi_device *dsi,enum mipi_dsi_dcs_tear_mode mode);int mipi_dsi_dcs_set_pixel_format (struct mipi_dsi_device *dsi,u8 format); +int mipi_dsi_dcs_get_display_brightness (struct mipi_dsi_device *dsi, +u16 *brightness); +int mipi_dsi_dcs_set_display_brightness (struct mipi_dsi_device *dsi, +u16 brightness);/** * struct mipi_dsi_driver - DSI driver -- 2.1.2
just to be inline with the existing code (funcs:mipi_dsi_dcs_get_power_mode, mipi_dsi_dcs_get_pixel_format) in drivers/gpu/drm/drm_mipi_dsi.c followed the same for mipi_dsi_dcs_get_display_brightness
We may need to change as you suggested for other two functions also. please suggest.
Quoted 122 lines · Sean Paul
Quoted 52 lines · Vinay Simha BN
Provide a small convenience wrapper that set/get the display brightness value
Cc John Stultz <[email protected]>Cc Sumit Semwal <[email protected]>Cc Archit Taneja <[email protected]>Cc Rob Clark <[email protected]>Cc Jani Nikula <[email protected]>Cc Thierry Reding <[email protected]>Cc Emil Velikov <[email protected]>Signed-off-by Vinay Simha BN <[email protected]>---
v1:
*tested in nexus7 2nd gen.v2:
* implemented jani review comments
-functions name mapped accordingly
-bl value increased from0xffto0xffff-backlight interface will be handled in panel driver,
so it is moved from themipi_dsihelper functionv3:
* emil review comments
(err < 0) supposed to be (err <= 0)--- drivers/gpu/drm/drm_mipi_dsi.c | 49 ++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 4 ++++ 2 files changed, 53 insertions(+)drivers/gpu/drm/drm_mipi_dsi.c +13
-0@@ -1041,6 +1041,55 @@ int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) }EXPORT_SYMBOL (mipi_dsi_dcs_set_pixel_format); +/** +* mipi_dsi_dcs_get_display_brightness() - gets the current brightness value +* of the display +* @dsi: DSI peripheral device +* @brightness: brightness value +* +* 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) +{ +ssize_t err; +drivers/gpu/drm/drm_mipi_dsi.c int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) · line 1066
Quoted 10 lines
drivers/gpu/drm/drm_mipi_dsi.c +10
-0+ err =mipi_dsi_dcs_read (dsi,MIPI_DCS_GET_DISPLAY_BRIGHTNESS , + brightness,sizeof (*brightness)); +if (err <=0 ) { +if (err ==0 ) + err = -ENODATA ; + +return err; + } + +return 0 ;IMO, this is still pretty awkward. I think the following is a bit more conventional:
err =
mipi_dsi_dcs_...
if (err == 0)return -ENODATA; else if (err < 0) return err;return 0;
Quoted 47 lines
drivers/gpu/drm/drm_mipi_dsi.c +26
-0+} +EXPORT_SYMBOL (mipi_dsi_dcs_get_display_brightness); + +/** +* mipi_dsi_dcs_set_display_brightness() - sets the brightness value of +* the display +* @dsi: DSI peripheral device +* @brightness: brightness value +* +* 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) +{ +ssize_t err; +u8 bl_value[2 ] = { brightness &0xff , brightness >>8 }; + + err =mipi_dsi_dcs_write (dsi,MIPI_DCS_SET_DISPLAY_BRIGHTNESS , + bl_value,sizeof (bl_value)); +if (err <0 ) +return err; + +return 0 ; +} +EXPORT_SYMBOL (mipi_dsi_dcs_set_display_brightness); +static int mipi_dsi_drv_probe (struct device *dev) {struct mipi_dsi_driver *drv =to_mipi_dsi_driver (dev->driver);include/drm/drm_mipi_dsi.h +4
-1@@ -270,6 +270,10 @@ int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);int mipi_dsi_dcs_set_tear_on (struct mipi_dsi_device *dsi,enum mipi_dsi_dcs_tear_mode mode);int mipi_dsi_dcs_set_pixel_format (struct mipi_dsi_device *dsi,u8 format); +int mipi_dsi_dcs_get_display_brightness (struct mipi_dsi_device *dsi, +u16 *brightness); +int mipi_dsi_dcs_set_display_brightness (struct mipi_dsi_device *dsi, +u16 brightness);/** * struct mipi_dsi_driver - DSI driver -- 2.1.2
Signature · 3 lines
Regards, Vinay Simha.B.N.
Quoted 8 lines · Vinay Simha
just to be inline with the existing code (funcs:
mipi_dsi_dcs_get_power_mode,mipi_dsi_dcs_get_pixel_format) indrivers/gpu/drm/drm_mipi_dsi.cfollowed the same formipi_dsi_dcs_get_display_brightnessWe may need to change as you suggested for other two functions also. please suggest.
Ah, didn't see that. I don't really care either way, tbh, just something that struck me as odd. Feel free to ignore.
Sean
Quoted 133 lines · Sean Paul
Quoted 117 lines · Vinay Simha BN
Quoted 52 lines
Provide a small convenience wrapper that set/get the display brightness value
Cc John Stultz <[email protected]>Cc Sumit Semwal <[email protected]>Cc Archit Taneja <[email protected]>Cc Rob Clark <[email protected]>Cc Jani Nikula <[email protected]>Cc Thierry Reding <[email protected]>Cc Emil Velikov <[email protected]>Signed-off-by Vinay Simha BN <[email protected]>---
v1:
*tested in nexus7 2nd gen.v2:
* implemented jani review comments
-functions name mapped accordingly
-bl value increased from0xffto0xffff-backlight interface will be handled in panel driver,
so it is moved from themipi_dsihelper functionv3:
* emil review comments
(err < 0) supposed to be (err <= 0)--- drivers/gpu/drm/drm_mipi_dsi.c | 49 ++++++++++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 4 ++++ 2 files changed, 53 insertions(+)drivers/gpu/drm/drm_mipi_dsi.c +13
-0@@ -1041,6 +1041,55 @@ int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) }EXPORT_SYMBOL (mipi_dsi_dcs_set_pixel_format); +/** +* mipi_dsi_dcs_get_display_brightness() - gets the current brightness value +* of the display +* @dsi: DSI peripheral device +* @brightness: brightness value +* +* 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) +{ +ssize_t err; +drivers/gpu/drm/drm_mipi_dsi.c int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format) · line 1066
Quoted 10 lines
drivers/gpu/drm/drm_mipi_dsi.c +10
-0+ err =mipi_dsi_dcs_read (dsi,MIPI_DCS_GET_DISPLAY_BRIGHTNESS , + brightness,sizeof (*brightness)); +if (err <=0 ) { +if (err ==0 ) + err = -ENODATA ; + +return err; + } + +return 0 ;IMO, this is still pretty awkward. I think the following is a bit more conventional:
err =
mipi_dsi_dcs_...
if (err == 0)return -ENODATA; else if (err < 0) return err;return 0;
Quoted 42 lines
drivers/gpu/drm/drm_mipi_dsi.c +26
-0+} +EXPORT_SYMBOL (mipi_dsi_dcs_get_display_brightness); + +/** +* mipi_dsi_dcs_set_display_brightness() - sets the brightness value of +* the display +* @dsi: DSI peripheral device +* @brightness: brightness value +* +* 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) +{ +ssize_t err; +u8 bl_value[2 ] = { brightness &0xff , brightness >>8 }; + + err =mipi_dsi_dcs_write (dsi,MIPI_DCS_SET_DISPLAY_BRIGHTNESS , + bl_value,sizeof (bl_value)); +if (err <0 ) +return err; + +return 0 ; +} +EXPORT_SYMBOL (mipi_dsi_dcs_set_display_brightness); +static int mipi_dsi_drv_probe (struct device *dev) {struct mipi_dsi_driver *drv =to_mipi_dsi_driver (dev->driver);include/drm/drm_mipi_dsi.h +4
-0@@ -270,6 +270,10 @@ int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);int mipi_dsi_dcs_set_tear_on (struct mipi_dsi_device *dsi,enum mipi_dsi_dcs_tear_mode mode);int mipi_dsi_dcs_set_pixel_format (struct mipi_dsi_device *dsi,u8 format); +int mipi_dsi_dcs_get_display_brightness (struct mipi_dsi_device *dsi, +u16 *brightness); +int mipi_dsi_dcs_set_display_brightness (struct mipi_dsi_device *dsi, +u16 brightness);Quoted 5 lines
Quoted 5 lines
include/drm/drm_mipi_dsi.h +0
-1/** * struct mipi_dsi_driver - DSI driver -- 2.1.2
--
Regards,Vinay Simha.B.N.