Linux Samsung SOC development
 help / color / mirror / Atom feed
From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
To: Marek Szyprowski <m.szyprowski@samsung.com>,
	dri-devel@lists.freedesktop.org,
	linux-samsung-soc@vger.kernel.org
Cc: Javier Martinez Canillas <javier@osg.samsung.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	Andrzej Hajda <a.hajda@samsung.com>
Subject: Re: [PATCH 06/25] drm/exynos: fix to calculate offset of each plane for ipp fimc
Date: Thu, 12 Nov 2015 16:20:50 +0100	[thread overview]
Message-ID: <5644AE52.6070303@math.uni-bielefeld.de> (raw)
In-Reply-To: <1447161821-1877-7-git-send-email-m.szyprowski@samsung.com>

Hello,



Marek Szyprowski wrote:
> From: Seung-Woo Kim <sw0312.kim@samsung.com>
> 
> NV12 and YUV420 formats are need to calculate offset of each plane
> for ipp fimc in a gem buffer. Without proper offset, only Y plane
> can be processed, so result shows green frame.
> This patch fixes to calculate offset for cbcr planes for NV12 and
> YUV420 formats.
> 
> Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_fimc.c | 106 +++++++++++++++++++++++++++++++
>  drivers/gpu/drm/exynos/exynos_drm_ipp.c  |  15 ++++-
>  drivers/gpu/drm/exynos/exynos_drm_ipp.h  |   2 +
>  3 files changed, 121 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
> index c747824f3c98..72a7ca188be5 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
> @@ -403,6 +403,97 @@ static void fimc_handle_lastend(struct fimc_context *ctx, bool enable)
>  	fimc_write(ctx, cfg, EXYNOS_CIOCTRL);
>  }
>  
> +static int fimc_set_planar_addr(struct drm_exynos_ipp_buf_info *buf_info,
> +				u32 fmt, struct drm_exynos_sz *sz)
> +{
> +	dma_addr_t *base[EXYNOS_DRM_PLANAR_MAX];
I think I've seen this at several other places already, but I never
fully understood it.

Why are we using dma_addr_t* here, instead of just dma_addr_t? I mean in
the following code the pointer is just in the dereferenced form anyway,
so why this added indirection?


With best wishes,
Tobias



> +	uint64_t size[EXYNOS_DRM_PLANAR_MAX];
> +	uint64_t ofs[EXYNOS_DRM_PLANAR_MAX];
> +	bool bypass = false;
> +	uint64_t tsize = 0;
> +	int i;
> +
> +	for_each_ipp_planar(i) {
> +		base[i] = &buf_info->base[i];
> +		size[i] = buf_info->size[i];
> +		ofs[i] = 0;
> +		tsize += size[i];
> +	}
> +
> +	if (!tsize) {
> +		DRM_INFO("%s:failed to get buffer size.\n", __func__);
> +		return 0;
> +	}
> +
> +	switch (fmt) {
> +	case DRM_FORMAT_NV12:
> +	case DRM_FORMAT_NV21:
> +	case DRM_FORMAT_NV16:
> +	case DRM_FORMAT_NV61:
> +		ofs[0] = sz->hsize * sz->vsize;
> +		ofs[1] = ofs[0] >> 1;
> +		if (*base[0] && *base[1]) {
> +			if (size[0] + size[1] < ofs[0] + ofs[1])
> +				goto err_info;
> +			bypass = true;
> +		}
> +		break;
> +	case DRM_FORMAT_YUV410:
> +	case DRM_FORMAT_YVU410:
> +	case DRM_FORMAT_YUV411:
> +	case DRM_FORMAT_YVU411:
> +	case DRM_FORMAT_YUV420:
> +	case DRM_FORMAT_YVU420:
> +	case DRM_FORMAT_YUV422:
> +	case DRM_FORMAT_YVU422:
> +	case DRM_FORMAT_YUV444:
> +	case DRM_FORMAT_YVU444:
> +		ofs[0] = sz->hsize * sz->vsize;
> +		ofs[1] = ofs[2] = ofs[0] >> 2;
> +		if (*base[0] && *base[1] && *base[2]) {
> +			if (size[0]+size[1]+size[2] < ofs[0]+ofs[1]+ofs[2])
> +				goto err_info;
> +			bypass = true;
> +		}
> +		break;
> +	case DRM_FORMAT_XRGB8888:
> +	case DRM_FORMAT_ARGB8888:
> +		ofs[0] = sz->hsize * sz->vsize << 2;
> +		if (*base[0]) {
> +			if (size[0] < ofs[0])
> +				goto err_info;
> +		}
> +		bypass = true;
> +		break;
> +	default:
> +		bypass = true;
> +		break;
> +	}
> +
> +	if (!bypass) {
> +		*base[1] = *base[0] + ofs[0];
> +		if (ofs[1] && ofs[2])
> +			*base[2] = *base[1] + ofs[1];
> +	}
> +
> +	DRM_DEBUG_KMS("%s:y[0x%x],cb[0x%x],cr[0x%x]\n", __func__,
> +		*base[0], *base[1], *base[2]);
> +
> +	return 0;
> +
> +err_info:
> +	DRM_ERROR("invalid size for fmt[0x%x]\n", fmt);
> +
> +	for_each_ipp_planar(i) {
> +		base[i] = &buf_info->base[i];
> +		size[i] = buf_info->size[i];
> +
> +		DRM_ERROR("buf[%d] - base[0x%x] sz[%llu] ofs[%llu]\n",
> +			i, *base[i], size[i], ofs[i]);
> +	}
> +
> +	return -EINVAL;
> +}
>  
>  static int fimc_src_set_fmt_order(struct fimc_context *ctx, u32 fmt)
>  {
> @@ -689,6 +780,7 @@ static int fimc_src_set_addr(struct device *dev,
>  	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->c_node;
>  	struct drm_exynos_ipp_property *property;
>  	struct drm_exynos_ipp_config *config;
> +	int ret;
>  
>  	if (!c_node) {
>  		DRM_ERROR("failed to get c_node.\n");
> @@ -709,6 +801,12 @@ static int fimc_src_set_addr(struct device *dev,
>  	switch (buf_type) {
>  	case IPP_BUF_ENQUEUE:
>  		config = &property->config[EXYNOS_DRM_OPS_SRC];
> +		ret = fimc_set_planar_addr(buf_info, config->fmt, &config->sz);
> +		if (ret) {
> +			dev_err(dev, "failed to set plane src addr.\n");
> +			return ret;
> +		}
> +
>  		fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_Y],
>  			EXYNOS_CIIYSA0);
>  
> @@ -1148,6 +1246,7 @@ static int fimc_dst_set_addr(struct device *dev,
>  	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->c_node;
>  	struct drm_exynos_ipp_property *property;
>  	struct drm_exynos_ipp_config *config;
> +	int ret;
>  
>  	if (!c_node) {
>  		DRM_ERROR("failed to get c_node.\n");
> @@ -1168,6 +1267,11 @@ static int fimc_dst_set_addr(struct device *dev,
>  	switch (buf_type) {
>  	case IPP_BUF_ENQUEUE:
>  		config = &property->config[EXYNOS_DRM_OPS_DST];
> +		ret = fimc_set_planar_addr(buf_info, config->fmt, &config->sz);
> +		if (ret) {
> +			dev_err(dev, "failed to set plane dst addr.\n");
> +			return ret;
> +		}
>  
>  		fimc_write(ctx, buf_info->base[EXYNOS_DRM_PLANAR_Y],
>  			EXYNOS_CIOYSA(buf_id));
> @@ -1562,6 +1666,8 @@ static void fimc_ippdrv_stop(struct device *dev, enum drm_exynos_ipp_cmd cmd)
>  	/* reset sequence */
>  	fimc_write(ctx, 0x0, EXYNOS_CIFCNTSEQ);
>  
> +	fimc_clear_addr(ctx);
> +
>  	/* Scaler disable */
>  	fimc_clear_bits(ctx, EXYNOS_CISCCTRL, EXYNOS_CISCCTRL_SCALERSTART);
>  
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> index 67d24236e745..408a14a9a180 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> @@ -571,6 +571,7 @@ static struct drm_exynos_ipp_mem_node
>  		/* get dma address by handle */
>  		if (qbuf->handle[i]) {
>  			dma_addr_t *addr;
> +			unsigned long size;
>  
>  			addr = exynos_drm_gem_get_dma_addr(drm_dev,
>  					qbuf->handle[i], c_node->filp);
> @@ -580,10 +581,20 @@ static struct drm_exynos_ipp_mem_node
>  				return ERR_PTR(-EFAULT);
>  			}
>  
> +			size = exynos_drm_gem_get_size(drm_dev,
> +					qbuf->handle[i], c_node->filp);
> +			if (!size) {
> +				DRM_ERROR("failed to get size.\n");
> +				ipp_put_mem_node(drm_dev, c_node, m_node);
> +				return ERR_PTR(-EFAULT);
> +			}
> +
>  			buf_info->handles[i] = qbuf->handle[i];
>  			buf_info->base[i] = *addr;
> -			DRM_DEBUG_KMS("i[%d]base[0x%x]hd[0x%lx]\n", i,
> -				      buf_info->base[i], buf_info->handles[i]);
> +			buf_info->size[i] = (uint64_t)size;
> +			DRM_DEBUG_KMS("i[%d]base[%pad]hd[0x%lx]sz[%llx]\n", i,
> +				      &buf_info->base[i], buf_info->handles[i],
> +				      buf_info->size[i]);
>  		}
>  	}
>  
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.h b/drivers/gpu/drm/exynos/exynos_drm_ipp.h
> index 2a61547a39d0..d4f0b588220b 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_ipp.h
> +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.h
> @@ -85,10 +85,12 @@ struct drm_exynos_ipp_cmd_node {
>   *
>   * @handles: Y, Cb, Cr each gem object handle.
>   * @base: Y, Cb, Cr each planar address.
> + * @size: Y, Cb, Cr each planar size.
>   */
>  struct drm_exynos_ipp_buf_info {
>  	unsigned long	handles[EXYNOS_DRM_PLANAR_MAX];
>  	dma_addr_t	base[EXYNOS_DRM_PLANAR_MAX];
> +	uint64_t	size[EXYNOS_DRM_PLANAR_MAX];
>  };
>  
>  /*
> 

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2015-11-12 15:20 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-10 13:23 [PATCH 00/25] Exynos DRM: new life of IPP (Image Post Processing) subsystem Marek Szyprowski
2015-11-10 13:23 ` [PATCH 01/25] ARM: dts: exynos4: add rotator nodes Marek Szyprowski
2015-11-13  2:23   ` Krzysztof Kozlowski
2015-11-13  8:31     ` Marek Szyprowski
2015-11-13  8:35       ` Krzysztof Kozlowski
2015-11-13 13:29         ` [PATCH v2 1/4] " Marek Szyprowski
2015-11-13 13:29           ` [PATCH v2 2/4] ARM: dts: exynos4: fix power domain for sysmmu-rotator device Marek Szyprowski
2015-11-14 11:37             ` Krzysztof Kozlowski
2015-11-13 13:29           ` [PATCH v2 3/4] ARM: dts: exynos5250: add rotator node Marek Szyprowski
2015-11-14 11:37             ` Krzysztof Kozlowski
2015-11-13 13:29           ` [PATCH v2 4/4] ARM: dts: exynos542x: " Marek Szyprowski
2015-11-14 11:37             ` Krzysztof Kozlowski
2015-11-14 11:37           ` [PATCH v2 1/4] ARM: dts: exynos4: add rotator nodes Krzysztof Kozlowski
2015-11-13  2:29   ` [PATCH 01/25] " Krzysztof Kozlowski
2015-11-13  8:32     ` Marek Szyprowski
2015-11-13  8:36       ` Krzysztof Kozlowski
2015-11-10 13:23 ` [PATCH 02/25] ARM: dts: exynos542x: add rotator node Marek Szyprowski
2015-11-13  2:28   ` Krzysztof Kozlowski
2015-11-10 13:23 ` [PATCH 03/25] drm/exynos: gsc: prepare and unprepare gsc clock Marek Szyprowski
2015-11-12 15:11   ` Gustavo Padovan
2015-11-10 13:23 ` [PATCH 04/25] drm/exynos: gsc: fix wrong pm_runtime state Marek Szyprowski
2015-11-12 15:12   ` Gustavo Padovan
2015-11-10 13:23 ` [PATCH 05/25] drm/exynos: gsc: add device tree support and remove usage of static mappings Marek Szyprowski
2015-11-10 13:23 ` [PATCH 06/25] drm/exynos: fix to calculate offset of each plane for ipp fimc Marek Szyprowski
2015-11-12 15:20   ` Tobias Jakobi [this message]
2015-11-13  9:19     ` Marek Szyprowski
2015-11-10 13:23 ` [PATCH 07/25] drm/exynos: fix to calculate offset of each plane for ipp gsc Marek Szyprowski
2015-11-10 13:23 ` [PATCH 08/25] drm/exynos: rotator: convert to common clock framework Marek Szyprowski
2015-11-12 18:13   ` Gustavo Padovan
2015-11-10 13:23 ` [PATCH 09/25] drm/exynos: exynos7-decon: remove excessive check Marek Szyprowski
2015-11-12 18:15   ` Gustavo Padovan
2015-11-10 13:23 ` [PATCH 10/25] drm/exynos: move dma_addr attribute from exynos plane to exynos fb Marek Szyprowski
2015-11-12 18:25   ` Gustavo Padovan
2015-11-10 13:23 ` [PATCH 11/25] drm/exynos: introduce exynos_drm_plane_state structure Marek Szyprowski
2015-11-13 11:46   ` Gustavo Padovan
2015-11-10 13:23 ` [PATCH 12/25] drm/exynos: mixer: use crtc->state->adjusted_mode instead of crtc->mode Marek Szyprowski
2015-11-13 11:47   ` Gustavo Padovan
2015-11-10 13:23 ` [PATCH 13/25] drm/exynos: mixer: enable video overlay plane only when VP is available Marek Szyprowski
2015-11-13 11:49   ` Gustavo Padovan
2015-11-10 13:23 ` [PATCH 14/25] drm/exynos: introduce exynos_drm_plane_config structure Marek Szyprowski
2015-11-13 12:08   ` Gustavo Padovan
2015-11-17 18:00   ` Tobias Jakobi
2015-11-18 10:25     ` Marek Szyprowski
2015-11-18 15:40       ` Tobias Jakobi
2015-11-19 10:34         ` Marek Szyprowski
2015-11-10 13:23 ` [PATCH 15/25] drm/exynos: add generic check for plane state Marek Szyprowski
2015-11-13 12:30   ` Gustavo Padovan
2015-11-10 13:23 ` [PATCH 16/25] drm/exynos: mixer: use ratio precalculated in exynos_state Marek Szyprowski
2015-11-13 12:35   ` Gustavo Padovan
2015-11-10 13:23 ` [PATCH 17/25] drm/exynos: fix clipping when scalling is enabled Marek Szyprowski
2015-11-17 18:17   ` Tobias Jakobi
2015-11-10 13:23 ` [PATCH 18/25] drm/exynos: fimd: fix dma burst size setting for small plane size Marek Szyprowski
2015-11-12 15:17   ` Tobias Jakobi
2015-11-12 15:23     ` Daniel Stone
2015-11-10 13:23 ` [PATCH 19/25] drm/exynos: add fb pointer to exynos_drm_plane_state Marek Szyprowski
2015-11-10 13:23 ` [PATCH 20/25] drm/exynos: gem: set default alignment for dumb GEM buffers Marek Szyprowski
2015-11-10 13:23 ` [PATCH 21/25] drm/exynos: gem: remove old unused prototypes Marek Szyprowski
2015-11-10 13:23 ` [PATCH 22/25] drm/exynos: gem: simplify access to exynos gem object Marek Szyprowski
2015-11-10 13:23 ` [PATCH 23/25] drm/exynos: ipp: make framework context global Marek Szyprowski
2015-11-10 13:23 ` [PATCH 24/25] drm/exynos: add generic plane rotation property support Marek Szyprowski
2015-11-10 13:23 ` [PATCH 25/25] drm/exynos: add support for plane scaling Marek Szyprowski
2015-11-10 16:23 ` [PATCH 00/25] Exynos DRM: new life of IPP (Image Post Processing) subsystem Tobias Jakobi
2015-11-11 22:30 ` Emil Velikov
2015-11-12 11:14 ` Daniel Stone
2015-11-12 12:44   ` Tobias Jakobi
2015-11-12 14:46     ` Daniel Stone
2015-11-12 15:10       ` Tobias Jakobi
2015-11-16 11:35       ` Marek Szyprowski
2015-11-16 11:52         ` Daniel Stone
2015-11-17 18:13           ` Tobias Jakobi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5644AE52.6070303@math.uni-bielefeld.de \
    --to=tjakobi@math.uni-bielefeld.de \
    --cc=a.hajda@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javier@osg.samsung.com \
    --cc=k.kozlowski@samsung.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=sw0312.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox