提交 6f206e9d 编写于 作者: T Tomi Valkeinen 提交者: Jyri Sarha

drm/tilcdc: verify fb pitch

LCDC hardware does not support fb pitch that is different (i.e. larger)
than the screen size. The driver currently does no checks for this, and
the results of too big pitch are are flickering and lower fps.

This issue easily happens when using libdrm's modetest tool with non-32
bpp modes. As modetest always allocated 4 bytes per pixel, it implies a
bigger pitch for 16 or 24 bpp modes.

This patch adds a check to reject pitches the hardware cannot support.
Signed-off-by: NTomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: NDarren Etheridge <detheridge@ti.com>
Signed-off-by: NJyri Sarha <jsarha@ti.com>
上级 3d19306a
...@@ -151,6 +151,22 @@ static void tilcdc_crtc_destroy(struct drm_crtc *crtc) ...@@ -151,6 +151,22 @@ static void tilcdc_crtc_destroy(struct drm_crtc *crtc)
kfree(tilcdc_crtc); kfree(tilcdc_crtc);
} }
static int tilcdc_verify_fb(struct drm_crtc *crtc, struct drm_framebuffer *fb)
{
struct drm_device *dev = crtc->dev;
unsigned int depth, bpp;
drm_fb_get_bpp_depth(fb->pixel_format, &depth, &bpp);
if (fb->pitches[0] != crtc->mode.hdisplay * bpp / 8) {
dev_err(dev->dev,
"Invalid pitch: fb and crtc widths must be the same");
return -EINVAL;
}
return 0;
}
static int tilcdc_crtc_page_flip(struct drm_crtc *crtc, static int tilcdc_crtc_page_flip(struct drm_crtc *crtc,
struct drm_framebuffer *fb, struct drm_framebuffer *fb,
struct drm_pending_vblank_event *event, struct drm_pending_vblank_event *event,
...@@ -158,6 +174,11 @@ static int tilcdc_crtc_page_flip(struct drm_crtc *crtc, ...@@ -158,6 +174,11 @@ static int tilcdc_crtc_page_flip(struct drm_crtc *crtc,
{ {
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
int r;
r = tilcdc_verify_fb(crtc, fb);
if (r)
return r;
if (tilcdc_crtc->event) { if (tilcdc_crtc->event) {
dev_err(dev->dev, "already pending page flip!\n"); dev_err(dev->dev, "already pending page flip!\n");
...@@ -272,6 +293,10 @@ static int tilcdc_crtc_mode_set(struct drm_crtc *crtc, ...@@ -272,6 +293,10 @@ static int tilcdc_crtc_mode_set(struct drm_crtc *crtc,
if (WARN_ON(!info)) if (WARN_ON(!info))
return -EINVAL; return -EINVAL;
ret = tilcdc_verify_fb(crtc, crtc->primary->fb);
if (ret)
return ret;
pm_runtime_get_sync(dev->dev); pm_runtime_get_sync(dev->dev);
/* Configure the Burst Size and fifo threshold of DMA: */ /* Configure the Burst Size and fifo threshold of DMA: */
...@@ -431,6 +456,12 @@ static int tilcdc_crtc_mode_set(struct drm_crtc *crtc, ...@@ -431,6 +456,12 @@ static int tilcdc_crtc_mode_set(struct drm_crtc *crtc,
static int tilcdc_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, static int tilcdc_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
struct drm_framebuffer *old_fb) struct drm_framebuffer *old_fb)
{ {
int r;
r = tilcdc_verify_fb(crtc, crtc->primary->fb);
if (r)
return r;
update_scanout(crtc); update_scanout(crtc);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册