Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/dsi: Implement DCS set/get display brightness

Provide a small convenience wrapper that set/get the display brightness.

Cc: John Stultz <john.stultz@linaro.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Archit Taneja <archit.taneja@gmail.com>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Vinay Simha BN <simhavcs@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>

authored by

Vinay Simha BN and committed by
Thierry Reding
1a9d7593 bbdcf516

+53
+49
drivers/gpu/drm/drm_mipi_dsi.c
··· 1041 1041 } 1042 1042 EXPORT_SYMBOL(mipi_dsi_dcs_set_tear_scanline); 1043 1043 1044 + /** 1045 + * mipi_dsi_dcs_set_display_brightness() - sets the brightness value of the 1046 + * display 1047 + * @dsi: DSI peripheral device 1048 + * @brightness: brightness value 1049 + * 1050 + * Return: 0 on success or a negative error code on failure. 1051 + */ 1052 + int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi, 1053 + u16 brightness) 1054 + { 1055 + u8 payload[2] = { brightness & 0xff, brightness >> 8 }; 1056 + ssize_t err; 1057 + 1058 + err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS, 1059 + payload, sizeof(payload)); 1060 + if (err < 0) 1061 + return err; 1062 + 1063 + return 0; 1064 + } 1065 + EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness); 1066 + 1067 + /** 1068 + * mipi_dsi_dcs_get_display_brightness() - gets the current brightness value 1069 + * of the display 1070 + * @dsi: DSI peripheral device 1071 + * @brightness: brightness value 1072 + * 1073 + * Return: 0 on success or a negative error code on failure. 1074 + */ 1075 + int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, 1076 + u16 *brightness) 1077 + { 1078 + ssize_t err; 1079 + 1080 + err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS, 1081 + brightness, sizeof(*brightness)); 1082 + if (err <= 0) { 1083 + if (err == 0) 1084 + err = -ENODATA; 1085 + 1086 + return err; 1087 + } 1088 + 1089 + return 0; 1090 + } 1091 + EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness); 1092 + 1044 1093 static int mipi_dsi_drv_probe(struct device *dev) 1045 1094 { 1046 1095 struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
+4
include/drm/drm_mipi_dsi.h
··· 270 270 enum mipi_dsi_dcs_tear_mode mode); 271 271 int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format); 272 272 int mipi_dsi_dcs_set_tear_scanline(struct mipi_dsi_device *dsi, u16 scanline); 273 + int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi, 274 + u16 brightness); 275 + int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi, 276 + u16 *brightness); 273 277 274 278 /** 275 279 * struct mipi_dsi_driver - DSI driver