build/patch/kernel/sun4i-default/0002-arm-sunxi-g2d-Fix-handle-noop-blits.patch

87 lines
3.4 KiB
Diff

From 3526df71cb2d2f9416a1a007da66ce88d3c70af9 Mon Sep 17 00:00:00 2001
From: Andreas Baierl <ichgeh@imkreisrum.de>
Date: Tue, 26 May 2015 09:20:10 -0400
Subject: [PATCH 2/9] arm:sunxi:g2d: Fix: handle noop blits
Zero area blits are technically valid noops and are requested by
libvdpau. Return 0 when blit area is zero without performing bogus
calculations.
---
drivers/char/sunxi_g2d/g2d.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/char/sunxi_g2d/g2d.c b/drivers/char/sunxi_g2d/g2d.c
index 539c726..02bc83c 100644
--- a/drivers/char/sunxi_g2d/g2d.c
+++ b/drivers/char/sunxi_g2d/g2d.c
@@ -142,8 +142,7 @@ int g2d_blit(g2d_blt * para)
__s32 err = 0;
/* check the parameter valid */
- if(para->src_rect.w == 0 || para->src_rect.h == 0 ||
- ((para->src_rect.x < 0)&&((-para->src_rect.x) > para->src_rect.w)) ||
+ if(((para->src_rect.x < 0)&&((-para->src_rect.x) > para->src_rect.w)) ||
((para->src_rect.y < 0)&&((-para->src_rect.y) > para->src_rect.h)) ||
((para->dst_x < 0)&&((-para->dst_x) > para->src_rect.w)) ||
((para->dst_y < 0)&&((-para->dst_y) > para->src_rect.h)) ||
@@ -157,6 +156,11 @@ int g2d_blit(g2d_blt * para)
}
else
{
+ if((para->src_rect.w == 0) || (para->src_rect.h == 0))
+ {
+ printk(KERN_DEBUG "User requested g2d blit on zero region\n");
+ return err;
+ }
if(((para->src_rect.x < 0)&&((-para->src_rect.x) < para->src_rect.w)))
{
para->src_rect.w = para->src_rect.w + para->src_rect.x;
@@ -209,8 +213,7 @@ int g2d_fill(g2d_fillrect * para)
__s32 err = 0;
/* check the parameter valid */
- if(para->dst_rect.w == 0 || para->dst_rect.h == 0 ||
- ((para->dst_rect.x < 0)&&((-para->dst_rect.x)>para->dst_rect.w)) ||
+ if(((para->dst_rect.x < 0)&&((-para->dst_rect.x)>para->dst_rect.w)) ||
((para->dst_rect.y < 0)&&((-para->dst_rect.y)>para->dst_rect.h)) ||
((para->dst_rect.x > 0)&&(para->dst_rect.x > para->dst_image.w - 1)) ||
((para->dst_rect.y > 0)&&(para->dst_rect.y > para->dst_image.h - 1)))
@@ -220,6 +223,11 @@ int g2d_fill(g2d_fillrect * para)
}
else
{
+ if((para->dst_rect.w == 0) || (para->dst_rect.h == 0))
+ {
+ printk(KERN_DEBUG "User requested g2d fill on zero region\n");
+ return err;
+ }
if(((para->dst_rect.x < 0)&&((-para->dst_rect.x) < para->dst_rect.w)))
{
para->dst_rect.w = para->dst_rect.w + para->dst_rect.x;
@@ -251,9 +259,7 @@ int g2d_stretchblit(g2d_stretchblt * para)
__s32 err = 0;
/* check the parameter valid */
- if(para->src_rect.w == 0 || para->src_rect.h == 0 ||
- para->dst_rect.w == 0 || para->dst_rect.h == 0 ||
- ((para->src_rect.x < 0)&&((-para->src_rect.x) > para->src_rect.w)) ||
+ if(((para->src_rect.x < 0)&&((-para->src_rect.x) > para->src_rect.w)) ||
((para->src_rect.y < 0)&&((-para->src_rect.y) > para->src_rect.h)) ||
((para->dst_rect.x < 0)&&((-para->dst_rect.x) > para->dst_rect.w)) ||
((para->dst_rect.y < 0)&&((-para->dst_rect.y) > para->dst_rect.h)) ||
@@ -267,6 +273,12 @@ int g2d_stretchblit(g2d_stretchblt * para)
}
else
{
+ if((para->dst_rect.w == 0) || (para->dst_rect.h == 0) ||
+ (para->src_rect.w == 0) || (para->src_rect.h == 0))
+ {
+ printk(KERN_DEBUG "User requested g2d stretchblit on zero region\n");
+ return err;
+ }
if(((para->src_rect.x < 0)&&((-para->src_rect.x) < para->src_rect.w)))
{
para->src_rect.w = para->src_rect.w + para->src_rect.x;
--
2.7.0