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

drm/mipi_dbi: Fix off-by-one bugs in mipi_dbi_blank()

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

authored by

Geert Uytterhoeven and committed by
Noralf Trønnes
2ce18249 1ce0d516

+2 -2
+2 -2
drivers/gpu/drm/drm_mipi_dbi.c
··· 367 367 memset(dbidev->tx_buf, 0, len); 368 368 369 369 mipi_dbi_command(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, 0, 0, 370 - (width >> 8) & 0xFF, (width - 1) & 0xFF); 370 + ((width - 1) >> 8) & 0xFF, (width - 1) & 0xFF); 371 371 mipi_dbi_command(dbi, MIPI_DCS_SET_PAGE_ADDRESS, 0, 0, 372 - (height >> 8) & 0xFF, (height - 1) & 0xFF); 372 + ((height - 1) >> 8) & 0xFF, (height - 1) & 0xFF); 373 373 mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START, 374 374 (u8 *)dbidev->tx_buf, len); 375 375