drm/tinydrm/mipi-dbi: Add mipi_dbi_enable_flush()
authorNoralf Trønnes <noralf@tronnes.org>
Wed, 10 Jan 2018 18:59:36 +0000 (19:59 +0100)
committerNoralf Trønnes <noralf@tronnes.org>
Mon, 15 Jan 2018 14:10:28 +0000 (15:10 +0100)
Add and use a function for enabling, flushing and turning on backlight.

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Reviewed-by: David Lechner <david@lechnology.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180110185940.53841-4-noralf@tronnes.org
drivers/gpu/drm/tinydrm/ili9225.c
drivers/gpu/drm/tinydrm/mipi-dbi.c
drivers/gpu/drm/tinydrm/st7586.c
drivers/gpu/drm/tinydrm/st7735r.c
include/drm/tinydrm/mipi-dbi.h

index c0cf498493023d10f71f6b05970a0ddc1aa5e03f..a0759502b81ac35e8a0a0c4bb44fadda5a4a5543 100644 (file)
@@ -180,7 +180,6 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
 {
        struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
        struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
-       struct drm_framebuffer *fb = pipe->plane.fb;
        struct device *dev = tdev->drm->dev;
        int ret;
        u8 am_id;
@@ -269,10 +268,7 @@ static void ili9225_pipe_enable(struct drm_simple_display_pipe *pipe,
 
        ili9225_command(mipi, ILI9225_DISPLAY_CONTROL_1, 0x1017);
 
-       mipi->enabled = true;
-
-       if (fb)
-               fb->funcs->dirty(fb, NULL, 0, 0, NULL, 0);
+       mipi_dbi_enable_flush(mipi);
 }
 
 static void ili9225_pipe_disable(struct drm_simple_display_pipe *pipe)
index aa6b6ce568912601a1318868f782816d9d74c6da..1c8ef0c4d6d43fef9ea9b2e910e7064e8d962a61 100644 (file)
@@ -270,6 +270,26 @@ static const struct drm_framebuffer_funcs mipi_dbi_fb_funcs = {
        .dirty          = mipi_dbi_fb_dirty,
 };
 
+/**
+ * mipi_dbi_enable_flush - MIPI DBI enable helper
+ * @mipi: MIPI DBI structure
+ *
+ * This function sets &mipi_dbi->enabled, flushes the whole framebuffer and
+ * enables the backlight. Drivers can use this in their
+ * &drm_simple_display_pipe_funcs->enable callback.
+ */
+void mipi_dbi_enable_flush(struct mipi_dbi *mipi)
+{
+       struct drm_framebuffer *fb = mipi->tinydrm.pipe.plane.fb;
+
+       mipi->enabled = true;
+       if (fb)
+               fb->funcs->dirty(fb, NULL, 0, 0, NULL, 0);
+
+       tinydrm_enable_backlight(mipi->backlight);
+}
+EXPORT_SYMBOL(mipi_dbi_enable_flush);
+
 /**
  * mipi_dbi_pipe_enable - MIPI DBI pipe enable helper
  * @pipe: Display pipe
index 5aebfceb740e66a2dcc628948edc4082409cde7a..9fd4423c8e7047a2498a08bcc154c1249ec7003f 100644 (file)
@@ -179,7 +179,6 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,
 {
        struct tinydrm_device *tdev = pipe_to_tinydrm(pipe);
        struct mipi_dbi *mipi = mipi_dbi_from_tinydrm(tdev);
-       struct drm_framebuffer *fb = pipe->plane.fb;
        struct device *dev = tdev->drm->dev;
        int ret;
        u8 addr_mode;
@@ -241,10 +240,7 @@ static void st7586_pipe_enable(struct drm_simple_display_pipe *pipe,
 
        mipi_dbi_command(mipi, MIPI_DCS_SET_DISPLAY_ON);
 
-       mipi->enabled = true;
-
-       if (fb)
-               fb->funcs->dirty(fb, NULL, 0, 0, NULL, 0);
+       mipi_dbi_enable_flush(mipi);
 }
 
 static void st7586_pipe_disable(struct drm_simple_display_pipe *pipe)
index 98ff447f40b4f6439a7df45276629bddc5240f60..1f38e15da67684762e8df2216174c871036cd062 100644 (file)
@@ -102,7 +102,7 @@ static void jd_t18003_t01_pipe_enable(struct drm_simple_display_pipe *pipe,
 
        msleep(20);
 
-       mipi_dbi_pipe_enable(pipe, crtc_state);
+       mipi_dbi_enable_flush(mipi);
 }
 
 static const struct drm_simple_display_pipe_funcs jd_t18003_t01_pipe_funcs = {
index 5d0e82b36eaf1cf8aa39b4ab76f40f5783b740e8..6441d9a9161a7b340b493730d63d7b4686a47812 100644 (file)
@@ -67,6 +67,7 @@ int mipi_dbi_init(struct device *dev, struct mipi_dbi *mipi,
                  const struct drm_simple_display_pipe_funcs *pipe_funcs,
                  struct drm_driver *driver,
                  const struct drm_display_mode *mode, unsigned int rotation);
+void mipi_dbi_enable_flush(struct mipi_dbi *mipi);
 void mipi_dbi_pipe_enable(struct drm_simple_display_pipe *pipe,
                          struct drm_crtc_state *crtc_state);
 void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe);