Commit f41a8a69 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Sam Ravnborg

drm/mipi_dbi: Add support for display offsets

If the resolution of the TFT display is smaller than the maximum
resolution supported by the display controller, the display may be
connected to the driver output arrays with a horizontal and/or vertical
offset, leading to a shifted image.

Add support for specifying these offsets.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Acked-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200115124548.3951-4-geert+renesas@glider.be
parent 3a1a6be4
...@@ -238,6 +238,23 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, ...@@ -238,6 +238,23 @@ int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb,
} }
EXPORT_SYMBOL(mipi_dbi_buf_copy); EXPORT_SYMBOL(mipi_dbi_buf_copy);
static void mipi_dbi_set_window_address(struct mipi_dbi_dev *dbidev,
unsigned int xs, unsigned int xe,
unsigned int ys, unsigned int ye)
{
struct mipi_dbi *dbi = &dbidev->dbi;
xs += dbidev->left_offset;
xe += dbidev->left_offset;
ys += dbidev->top_offset;
ye += dbidev->top_offset;
mipi_dbi_command(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, (xs >> 8) & 0xff,
xs & 0xff, (xe >> 8) & 0xff, xe & 0xff);
mipi_dbi_command(dbi, MIPI_DCS_SET_PAGE_ADDRESS, (ys >> 8) & 0xff,
ys & 0xff, (ye >> 8) & 0xff, ye & 0xff);
}
static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
{ {
struct drm_gem_object *gem = drm_gem_fb_get_obj(fb, 0); struct drm_gem_object *gem = drm_gem_fb_get_obj(fb, 0);
...@@ -271,12 +288,8 @@ static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect) ...@@ -271,12 +288,8 @@ static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
tr = cma_obj->vaddr; tr = cma_obj->vaddr;
} }
mipi_dbi_command(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, mipi_dbi_set_window_address(dbidev, rect->x1, rect->x2 - 1, rect->y1,
(rect->x1 >> 8) & 0xff, rect->x1 & 0xff, rect->y2 - 1);
((rect->x2 - 1) >> 8) & 0xff, (rect->x2 - 1) & 0xff);
mipi_dbi_command(dbi, MIPI_DCS_SET_PAGE_ADDRESS,
(rect->y1 >> 8) & 0xff, rect->y1 & 0xff,
((rect->y2 - 1) >> 8) & 0xff, (rect->y2 - 1) & 0xff);
ret = mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START, tr, ret = mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START, tr,
width * height * 2); width * height * 2);
...@@ -366,10 +379,7 @@ static void mipi_dbi_blank(struct mipi_dbi_dev *dbidev) ...@@ -366,10 +379,7 @@ static void mipi_dbi_blank(struct mipi_dbi_dev *dbidev)
memset(dbidev->tx_buf, 0, len); memset(dbidev->tx_buf, 0, len);
mipi_dbi_command(dbi, MIPI_DCS_SET_COLUMN_ADDRESS, 0, 0, mipi_dbi_set_window_address(dbidev, 0, width - 1, 0, height - 1);
((width - 1) >> 8) & 0xFF, (width - 1) & 0xFF);
mipi_dbi_command(dbi, MIPI_DCS_SET_PAGE_ADDRESS, 0, 0,
((height - 1) >> 8) & 0xFF, (height - 1) & 0xFF);
mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START, mipi_dbi_command_buf(dbi, MIPI_DCS_WRITE_MEMORY_START,
(u8 *)dbidev->tx_buf, len); (u8 *)dbidev->tx_buf, len);
......
...@@ -109,6 +109,18 @@ struct mipi_dbi_dev { ...@@ -109,6 +109,18 @@ struct mipi_dbi_dev {
*/ */
unsigned int rotation; unsigned int rotation;
/**
* @left_offset: Horizontal offset of the display relative to the
* controller's driver array
*/
unsigned int left_offset;
/**
* @top_offset: Vertical offset of the display relative to the
* controller's driver array
*/
unsigned int top_offset;
/** /**
* @backlight: backlight device (optional) * @backlight: backlight device (optional)
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment