All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] drm/dsi: Implement dcs set/get display brightness
@ 2016-06-20  5:53 ` Vinay Simha BN
  0 siblings, 0 replies; 15+ messages in thread
From: Vinay Simha BN @ 2016-06-20  5:53 UTC (permalink / raw)
  Cc: Vinay Simha BN, John Stultz, Sumit Semwal, Archit Taneja,
	Rob Clark, Jani Nikula, Thierry Reding, David Airlie,
	open list:DRM DRIVERS, open list

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

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>
Signed-off-by: Vinay Simha BN <simhavcs@gmail.com>
---
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
---
 drivers/gpu/drm/drm_mipi_dsi.c | 49 ++++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_mipi_dsi.h     |  4 ++++
 2 files changed, 53 insertions(+)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 49311fc..2c03784 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -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);
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 72f5b15..4d77bb0 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-07-11 14:12 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-20  5:53 [PATCH v2 1/2] drm/dsi: Implement dcs set/get display brightness Vinay Simha BN
2016-06-20  5:53 ` Vinay Simha BN
2016-06-20  5:53 ` [PATCH v7 2/2] drm/panel: Add JDI LT070ME05000 WUXGA DSI Panel Vinay Simha BN
2016-06-20  5:53   ` Vinay Simha BN
2016-06-28 15:59   ` Vinay Simha
2016-07-03 22:52     ` Emil Velikov
2016-07-03 22:52       ` Emil Velikov
2016-07-04  6:27       ` Vinay Simha
2016-07-06 17:16         ` Emil Velikov
2016-07-06 17:16           ` Emil Velikov
2016-07-11 12:20       ` Thierry Reding
2016-07-11 12:20         ` Thierry Reding
2016-07-11 12:31         ` Vinay Simha
2016-07-11 14:12           ` Emil Velikov
2016-06-28 15:59 ` [PATCH v2 1/2] drm/dsi: Implement dcs set/get display brightness Vinay Simha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.