| From 28c1048187fdc6cfc2d0d6f06415e01b1768e9f3 Mon Sep 17 00:00:00 2001 |
| From: Geert Uytterhoeven <geert+renesas@glider.be> |
| Date: Mon, 30 Dec 2019 14:06:04 +0100 |
| Subject: [PATCH] drm/mipi_dbi: Fix off-by-one bugs in mipi_dbi_blank() |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| commit 2ce18249af5a28031b3f909cfafccc88ea966c9d upstream. |
| |
| When configuring the frame memory window, the last column and row |
| numbers are written to the column resp. page address registers. These |
| numbers are thus one less than the actual window width resp. height. |
| |
| While this is handled correctly in mipi_dbi_fb_dirty() since commit |
| 03ceb1c8dfd1e293 ("drm/tinydrm: Fix setting of the column/page end |
| addresses."), it is not in mipi_dbi_blank(). The latter still forgets |
| to subtract one when calculating the most significant bytes of the |
| column and row numbers, thus programming wrong values when the display |
| width or height is a multiple of 256. |
| |
| Fixes: 02dd95fe31693626 ("drm/tinydrm: Add MIPI DBI support") |
| Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> |
| Signed-off-by: Noralf TrΓΈnnes <noralf@tronnes.org> |
| Link: https://patchwork.freedesktop.org/patch/msgid/20191230130604.31006-1-geert+renesas@glider.be |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c |
| index e33b309ba016..eea15c07c554 100644 |
| --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c |
| +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c |
| @@ -362,9 +362,9 @@ static void mipi_dbi_blank(struct mipi_dbi *mipi) |
| memset(mipi->tx_buf, 0, len); |
| |
| mipi_dbi_command(mipi, MIPI_DCS_SET_COLUMN_ADDRESS, 0, 0, |
| - (width >> 8) & 0xFF, (width - 1) & 0xFF); |
| + ((width - 1) >> 8) & 0xFF, (width - 1) & 0xFF); |
| mipi_dbi_command(mipi, MIPI_DCS_SET_PAGE_ADDRESS, 0, 0, |
| - (height >> 8) & 0xFF, (height - 1) & 0xFF); |
| + ((height - 1) >> 8) & 0xFF, (height - 1) & 0xFF); |
| mipi_dbi_command_buf(mipi, MIPI_DCS_WRITE_MEMORY_START, |
| (u8 *)mipi->tx_buf, len); |
| |
| -- |
| 2.7.4 |
| |