summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoram Park <boram1288.park@samsung.com>2017-03-07 11:33:31 +0900
committerBoram Park <boram1288.park@samsung.com>2017-03-07 11:40:24 +0900
commit5ff4768603d94e7886a4f355902866d66361eb73 (patch)
tree283b2f013dc8460be6f24ea3e4271d442f34f060
parentc192d78edba8e6223476628a59ee95398891b317 (diff)
downloadlibtdm-drm-5ff4768603d94e7886a4f355902866d66361eb73.tar.gz
libtdm-drm-5ff4768603d94e7886a4f355902866d66361eb73.tar.bz2
libtdm-drm-5ff4768603d94e7886a4f355902866d66361eb73.zip
pp: don't convert if bo size is smaller than the expected size
Change-Id: I24bc03747b0638d44baeb6be3d6cb66acf62e7a8
-rw-r--r--src/tdm_drm_pp.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/tdm_drm_pp.c b/src/tdm_drm_pp.c
index 9180f58..97ee9de 100644
--- a/src/tdm_drm_pp.c
+++ b/src/tdm_drm_pp.c
@@ -166,12 +166,26 @@ _tdm_drm_pp_convert(tdm_drm_pp_buffer *buffer, tdm_info_pp *info)
pixman_format_code_t src_format, dst_format;
int sbw, dbw;
int rotate = 0, hflip = 0;
+ tbm_bo bo = NULL;
+ int bo_cnt = 0;
+ int bo_size = 0;
RETURN_VAL_IF_FAIL(buffer != NULL, TDM_ERROR_INVALID_PARAMETER);
RETURN_VAL_IF_FAIL(buffer->src != NULL, TDM_ERROR_INVALID_PARAMETER);
RETURN_VAL_IF_FAIL(buffer->dst != NULL, TDM_ERROR_INVALID_PARAMETER);
RETURN_VAL_IF_FAIL(info != NULL, TDM_ERROR_INVALID_PARAMETER);
+ bo_cnt = tbm_surface_internal_get_num_bos(buffer->src);
+ RETURN_VAL_IF_FAIL(bo_cnt == 1, TDM_ERROR_INVALID_PARAMETER);
+
+ bo_cnt = tbm_surface_internal_get_num_bos(buffer->dst);
+ RETURN_VAL_IF_FAIL(bo_cnt == 1, TDM_ERROR_INVALID_PARAMETER);
+
+ bo = tbm_surface_internal_get_bo(buffer->src, 0);
+ RETURN_VAL_IF_FAIL(bo != NULL, TDM_ERROR_INVALID_PARAMETER);
+
+ bo_size = tbm_bo_size(bo);
+
/* not handle buffers which have 2 more gem handles */
memset(&src_info, 0, sizeof(tbm_surface_info_s));
@@ -214,6 +228,12 @@ _tdm_drm_pp_convert(tdm_drm_pp_buffer *buffer, tdm_info_pp *info)
if (info->transform >= TDM_TRANSFORM_FLIPPED)
hflip = 1;
+ if (bo_size < src_info.planes[0].stride * src_info.height) {
+ TDM_WRN("bo size(%d) is smaller than the expected size(%d)",
+ bo_size, src_info.planes[0].stride * src_info.height);
+ goto fail_convert;
+ }
+
_tdm_drm_pp_pixman_convert(PIXMAN_OP_SRC,
src_info.planes[0].ptr, dst_info.planes[0].ptr,
src_format, dst_format,