From cb972f701dde6afea594f8177c85629f457076b9 Mon Sep 17 00:00:00 2001 From: hjc Date: Mon, 9 Mar 2015 12:10:48 +0800 Subject: [PATCH] rk fb: add memsize check Signed-off-by: hjc --- drivers/video/rockchip/rk_fb.c | 39 ++++++++++++++++++++++++++++++++++ include/linux/rk_fb.h | 1 + 2 files changed, 40 insertions(+) diff --git a/drivers/video/rockchip/rk_fb.c b/drivers/video/rockchip/rk_fb.c index f5d9cd08c731..c9ceab40b325 100755 --- a/drivers/video/rockchip/rk_fb.c +++ b/drivers/video/rockchip/rk_fb.c @@ -1820,6 +1820,7 @@ static int rk_fb_set_win_buffer(struct fb_info *info, u8 ppixel_a = 0, global_a = 0; ion_phys_addr_t phy_addr; int ret = 0; + int buff_len; reg_win_data->reg_area_data[0].smem_start = -1; reg_win_data->area_num = 0; @@ -1861,6 +1862,7 @@ static int rk_fb_set_win_buffer(struct fb_info *info, reg_win_data->reg_area_data[i].smem_start = phy_addr; reg_win_data->area_buf_num++; reg_win_data->reg_area_data[i].index_buf = 1; + reg_win_data->reg_area_data[i].buff_len = len; } } } else { @@ -1962,6 +1964,26 @@ static int rk_fb_set_win_buffer(struct fb_info *info, xoffset * pixel_width / 8; } } + if ((fb_data_fmt != YUV420) && + (fb_data_fmt != YUV420_NV21) && + (fb_data_fmt != YUV422) && + (fb_data_fmt != YUV444)) { + buff_len = reg_win_data->reg_area_data[i].y_offset + + reg_win_data->reg_area_data[i].xvir * + reg_win_data->reg_area_data[i].yact * + pixel_width / 8 - + reg_win_data->reg_area_data[i].xoff* + pixel_width / 8; + if (buff_len > reg_win_data->reg_area_data[i].buff_len) + pr_err("\n!!!!!!error: fmt=%d,xvir[%d]*" + "yact[%d]*bpp[%d]" + "=buff_len[0x%x]>>mmu len=0x%x\n", + fb_data_fmt, + reg_win_data->reg_area_data[i].xvir, + reg_win_data->reg_area_data[i].yact, + pixel_width, buff_len, + reg_win_data->reg_area_data[i].buff_len); + } } global_a = (win_par->g_alpha_val == 0) ? 0 : 1; @@ -2031,6 +2053,23 @@ static int rk_fb_set_win_buffer(struct fb_info *info, uv_x_off * pixel_width / 8; } } + buff_len = reg_win_data->reg_area_data[0].cbr_start + + reg_win_data->reg_area_data[0].c_offset + + reg_win_data->reg_area_data[0].xvir * + reg_win_data->reg_area_data[0].yact * + pixel_width / 16 - + reg_win_data->reg_area_data[0].smem_start - + reg_win_data->reg_area_data[0].xoff* + pixel_width / 16 ; + if (buff_len > reg_win_data->reg_area_data[0].buff_len) + pr_err("\n!!!!!!error: fmt=%d,xvir[%d]*" + "yact[%d]*bpp[%d]" + "=buff_len[0x%x]>>mmu len=0x%x\n", + fb_data_fmt, + reg_win_data->reg_area_data[0].xvir, + reg_win_data->reg_area_data[0].yact, + pixel_width, buff_len, + reg_win_data->reg_area_data[0].buff_len); } /* record buffer information for rk_fb_disp_scale to prevent fence timeout diff --git a/include/linux/rk_fb.h b/include/linux/rk_fb.h index 18a55f57b79f..51608d8f03f1 100755 --- a/include/linux/rk_fb.h +++ b/include/linux/rk_fb.h @@ -517,6 +517,7 @@ struct rk_fb_reg_area_data { u32 c_offset; /*cb cr offset--->LCDC_WINx_CBR_MSTx*/ u32 y_vir_stride; u32 uv_vir_stride; + u32 buff_len; u16 xpos; /*start point in panel --->LCDC_WINx_DSP_ST*/ u16 ypos; u16 xsize; /* display window width/height -->LCDC_WINx_DSP_INFO*/ -- 2.34.1