Commit 3c10473b authored by Hyungwon Hwang's avatar Hyungwon Hwang Committed by Inki Dae

drm/exynos: ipp: validate a GEM handle with multiple planes

FIMC & GSC driver can calculate the offset of planes. So there are
use cases which IPP receives just one GEM handle of an image with
multiple plane. This patch extends ipp_validate_mem_node() to validate
this case.
Signed-off-by: default avatarHyungwon Hwang <human.hwang@samsung.com>
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
parent b224fa9f
...@@ -455,8 +455,8 @@ static int ipp_validate_mem_node(struct drm_device *drm_dev, ...@@ -455,8 +455,8 @@ static int ipp_validate_mem_node(struct drm_device *drm_dev,
{ {
struct drm_exynos_ipp_config *ipp_cfg; struct drm_exynos_ipp_config *ipp_cfg;
unsigned int num_plane; unsigned int num_plane;
unsigned long min_size, size; unsigned long size, buf_size = 0, plane_size, img_size = 0;
unsigned int bpp; unsigned int bpp, width, height;
int i; int i;
ipp_cfg = &c_node->property.config[m_node->ops_id]; ipp_cfg = &c_node->property.config[m_node->ops_id];
...@@ -470,20 +470,45 @@ static int ipp_validate_mem_node(struct drm_device *drm_dev, ...@@ -470,20 +470,45 @@ static int ipp_validate_mem_node(struct drm_device *drm_dev,
* but it seems more than enough * but it seems more than enough
*/ */
for (i = 0; i < num_plane; ++i) { for (i = 0; i < num_plane; ++i) {
if (!m_node->buf_info.handles[i]) { width = ipp_cfg->sz.hsize;
DRM_ERROR("invalid handle for plane %d\n", i); height = ipp_cfg->sz.vsize;
return -EINVAL;
}
bpp = drm_format_plane_cpp(ipp_cfg->fmt, i); bpp = drm_format_plane_cpp(ipp_cfg->fmt, i);
min_size = (ipp_cfg->sz.hsize * ipp_cfg->sz.vsize * bpp) >> 3;
size = exynos_drm_gem_get_size(drm_dev, /*
m_node->buf_info.handles[i], * The result of drm_format_plane_cpp() for chroma planes must
c_node->filp); * be used with drm_format_xxxx_chroma_subsampling() for
if (min_size > size) { * correct result.
DRM_ERROR("invalid size for plane %d\n", i); */
return -EINVAL; if (i > 0) {
width /= drm_format_horz_chroma_subsampling(
ipp_cfg->fmt);
height /= drm_format_vert_chroma_subsampling(
ipp_cfg->fmt);
} }
plane_size = width * height * bpp;
img_size += plane_size;
if (m_node->buf_info.handles[i]) {
size = exynos_drm_gem_get_size(drm_dev,
m_node->buf_info.handles[i],
c_node->filp);
if (plane_size > size) {
DRM_ERROR(
"buffer %d is smaller than required\n",
i);
return -EINVAL;
}
buf_size += size;
}
}
if (buf_size < img_size) {
DRM_ERROR("size of buffers(%lu) is smaller than image(%lu)\n",
buf_size, img_size);
return -EINVAL;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment