diff options
author | Jon Mayo <jmayo@nvidia.com> | 2011-04-28 20:25:13 -0700 |
---|---|---|
committer | Varun Colbert <vcolbert@nvidia.com> | 2011-05-10 16:09:01 -0700 |
commit | c8bde2d8332d313b04856377cb95ccd555051a0e (patch) | |
tree | 0073a66338c37ad49075d9f9950cc5e4fce4304c /drivers | |
parent | a14aa5572e32649156c4b755219a07e68b7af5e2 (diff) |
ARM: tegra: dc: clip invalid windows to screen res
clip invalid windows to fix screen size, failure to do so causes display
errors that result in corrupted display and invalid video modes.
prints a warning only once, if this warning is present in the logs then
there is a misbehaving application.
Bug 821094
(cherry picked from commit e08f18eba00bd5d86cb7770f709417a1bd0ca14f)
Change-Id: Ie5cec5c805bfe2bd4c5f1e5b7e22d5f255ca2680
Reviewed-on: http://git-master/r/30587
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/video/tegra/dc/overlay.c | 31 | ||||
-rw-r--r-- | drivers/video/tegra/fb.c | 31 |
2 files changed, 44 insertions, 18 deletions
diff --git a/drivers/video/tegra/dc/overlay.c b/drivers/video/tegra/dc/overlay.c index 0a7bd4de124e..863666d96e51 100644 --- a/drivers/video/tegra/dc/overlay.c +++ b/drivers/video/tegra/dc/overlay.c @@ -161,15 +161,28 @@ static int tegra_overlay_set_windowattr(struct tegra_overlay_info *overlay, win->out_w = flip_win->attr.out_w; win->out_h = flip_win->attr.out_h; - if ((((win->out_x + win->out_w) > xres) && (win->out_x < xres)) || - (((win->out_y + win->out_h) > yres) && (win->out_y < yres))) { - pr_warning("outside of FB: " - "FB=(%d,%d,%d,%d) " - "src=(%d,%d,%d,%d) ", - "dst=(%d,%d,%d,%d)", - 0, 0, xres, yres, - win->x, win->y, win->w, win->h, - win->out_x, win->out_y, win->out_w, win->out_h); + WARN_ONCE(win->out_x >= xres, + "%s:application window x offset exceeds display width(%d)\n", + dev_name(&win->dc->ndev->dev), win->out_x, xres); + WARN_ONCE(win->out_y >= yres, + "%s:application window y offset exceeds display height(%d)\n", + dev_name(&win->dc->ndev->dev), win->out_y, yres); + WARN_ONCE(win->out_x + win->out_w > xres && win->out_x < xres, + "%s:application window width(%d) exceeds display width(%d)\n", + dev_name(&win->dc->ndev->dev), win->out_x + win->out_w, xres); + WARN_ONCE(win->out_y + win->out_h > yres && win->out_y < yres, + "%s:application window height(%d) exceeds display height(%d)\n", + dev_name(&win->dc->ndev->dev), win->out_y + win->out_h, yres); + + if (((win->out_x + win->out_w) > xres) && (win->out_x < xres)) { + long new_w = xres - win->out_x; + win->w = win->w * new_w / win->out_w; + win->out_w = new_w; + } + if (((win->out_y + win->out_h) > yres) && (win->out_y < yres)) { + long new_h = yres - win->out_y; + win->h = win->h * new_h / win->out_h; + win->out_h = new_h; } win->z = flip_win->attr.z; diff --git a/drivers/video/tegra/fb.c b/drivers/video/tegra/fb.c index 3d22f8fc8c98..2ec247633b16 100644 --- a/drivers/video/tegra/fb.c +++ b/drivers/video/tegra/fb.c @@ -417,15 +417,28 @@ static int tegra_fb_set_windowattr(struct tegra_fb_info *tegra_fb, win->out_w = flip_win->attr.out_w; win->out_h = flip_win->attr.out_h; - if ((((win->out_x + win->out_w) > xres) && (win->out_x < xres)) || - (((win->out_y + win->out_h) > yres) && (win->out_y < yres))) { - pr_warning("outside of FB: " - "FB=(%d,%d,%d,%d) " - "src=(%d,%d,%d,%d) ", - "dst=(%d,%d,%d,%d)", - 0, 0, xres, yres, - win->x, win->y, win->w, win->h, - win->out_x, win->out_y, win->out_w, win->out_h); + WARN_ONCE(win->out_x >= xres, + "%s:application window x offset exceeds display width(%d)\n", + dev_name(&win->dc->ndev->dev), win->out_x, xres); + WARN_ONCE(win->out_y >= yres, + "%s:application window y offset exceeds display height(%d)\n", + dev_name(&win->dc->ndev->dev), win->out_y, yres); + WARN_ONCE(win->out_x + win->out_w > xres && win->out_x < xres, + "%s:application window width(%d) exceeds display width(%d)\n", + dev_name(&win->dc->ndev->dev), win->out_x + win->out_w, xres); + WARN_ONCE(win->out_y + win->out_h > yres && win->out_y < yres, + "%s:application window height(%d) exceeds display height(%d)\n", + dev_name(&win->dc->ndev->dev), win->out_y + win->out_h, yres); + + if (((win->out_x + win->out_w) > xres) && (win->out_x < xres)) { + long new_w = xres - win->out_x; + win->w = win->w * new_w / win->out_w; + win->out_w = new_w; + } + if (((win->out_y + win->out_h) > yres) && (win->out_y < yres)) { + long new_h = yres - win->out_y; + win->h = win->h * new_h / win->out_h; + win->out_h = new_h; } win->z = flip_win->attr.z; |