From: Andreas Baierl <[email protected]>

If DISP_CMD_VIDEO_START is called and layer.para.src_win.width = 0,
a division by zero is happening.
This patch is ported from Allwinner's display driver code.
It catches the division by zero by disabling vpp operations if src_win.width < 
1280 and
if src width matches scn width.

Signed-off-by: Andreas Baierl <[email protected]>
---
 drivers/video/sunxi/disp/disp_video.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/video/sunxi/disp/disp_video.c 
b/drivers/video/sunxi/disp/disp_video.c
index aa07364..4d4ac0b 100644
--- a/drivers/video/sunxi/disp/disp_video.c
+++ b/drivers/video/sunxi/disp/disp_video.c
@@ -71,11 +71,13 @@ static __s32 video_enhancement_start(__u32 sel, __u32 id)
        /* !!! assume open HDMI before video start */
        if (gdisp.screen[sel].output_type == DISP_OUTPUT_TYPE_HDMI) {
                scaler_index = gdisp.screen[sel].layer_manage[id].scaler_index;
-               scaleuprate =
-                       gdisp.screen[sel].layer_manage[id].para.scn_win.width *
-                       2 /
-                       gdisp.screen[sel].layer_manage[id].para.src_win.width;
-
+               if ((gdisp.screen[sel].layer_manage[id].para.scn_win.width == 
gdisp.screen[sel].layer_manage[id].para.src_win.width) || 
(gdisp.screen[sel].layer_manage[id].para.src_win.width < 1280)) {
+                       scaleuprate = 0;
+               }
+               else
+               {
+                       scaleuprate = 
gdisp.screen[sel].layer_manage[id].para.scn_win.width * 2 / 
gdisp.screen[sel].layer_manage[id].para.src_win.width;
+               }
                switch (scaleuprate) {
                case 0: /* scale down, do noting */
                        DE_SCAL_Vpp_Enable(scaler_index, 0);
-- 
2.1.1

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to