Linux Media Controller development
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: LMML <linux-media@vger.kernel.org>
Cc: s.nawrocki@samsung.com
Subject: [PATCH 3/5] s5p-fimc: Roundup imagesize to row size for tiled formats
Date: Wed, 26 Mar 2014 18:48:39 -0400	[thread overview]
Message-ID: <1395874119.32312.28.camel@nicolas-tpx230> (raw)
In-Reply-To: <1395873527.32312.27.camel@nicolas-tpx230>

[-- Attachment #1: Type: text/plain, Size: 1763 bytes --]

For tiled format, we need to allocated a multiple of the row size. A
good example is for 1280x720, wich get adjusted to 1280x736. In tiles,
this mean Y plane is 20x23 and UV plane 20x12. Because of the rounding,
the previous code would only have enough space to fit half of the last
row.

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
 drivers/media/platform/exynos4-is/fimc-core.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-core.c b/drivers/media/platform/exynos4-is/fimc-core.c
index 2e70fab..7ea15ef 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -736,6 +736,7 @@ void fimc_adjust_mplane_format(struct fimc_fmt *fmt, u32 width, u32 height,
 	for (i = 0; i < pix->num_planes; ++i) {
 		struct v4l2_plane_pix_format *plane_fmt = &pix->plane_fmt[i];
 		u32 bpl = plane_fmt->bytesperline;
+		u32 sizeimage;
 
 		if (fmt->colplanes > 1 && (bpl == 0 || bpl < pix->width))
 			bpl = pix->width; /* Planar */
@@ -755,8 +756,16 @@ void fimc_adjust_mplane_format(struct fimc_fmt *fmt, u32 width, u32 height,
 			bytesperline /= 2;
 
 		plane_fmt->bytesperline = bytesperline;
-		plane_fmt->sizeimage = max((pix->width * pix->height *
-				   fmt->depth[i]) / 8, plane_fmt->sizeimage);
+		sizeimage = pix->width * pix->height * fmt->depth[i] / 8;
+
+		/* Ensure full last row for tiled formats */
+		if (tiled_fmt(fmt)) {
+			/* 64 * 32 * plane_fmt->bytesperline / 64 */
+			u32 row_size = plane_fmt->bytesperline * 32;
+			sizeimage = roundup(sizeimage, row_size);
+		}
+
+		plane_fmt->sizeimage = max(sizeimage, plane_fmt->sizeimage);
 	}
 }
 
-- 
1.8.5.3

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2014-03-26 22:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-25 20:45 [PATCH 0/5] s5p-fimc: Misc fixes Nicolas Dufresne
2014-03-25 20:50 ` [PATCH 2/5] s5p-fimc: Fix YUV422P depth Nicolas Dufresne
2014-03-25 20:51 ` [PATCH 3/5] s5p-fimc: Align imagesize to row size for tiled formats Nicolas Dufresne
2014-03-26 22:38   ` Nicolas Dufresne
2014-03-26 22:48     ` Nicolas Dufresne [this message]
2014-03-25 20:52 ` [PATCH 4/5] s5p-fimc: Iterate for each memory plane Nicolas Dufresne
2014-03-25 20:53 ` [PATCH 5/5] s5p-fimc: Reuse calculated sizes Nicolas Dufresne
2014-03-25 20:55 ` [PATCH 1/5] s5p-fimc: Changed RGB32 to BGR32 Nicolas Dufresne
2014-04-01 14:34   ` Sylwester Nawrocki
2014-04-01 15:16     ` Nicolas Dufresne
2014-03-25 20:56 ` [PATCH 2/5] s5p-fimc: Fix YUV422P depth Nicolas Dufresne
2014-04-01 14:13 ` [PATCH 0/5] s5p-fimc: Misc fixes Nicolas Dufresne
2014-04-01 14:28   ` Sylwester Nawrocki

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=1395874119.32312.28.camel@nicolas-tpx230 \
    --to=nicolas.dufresne@collabora.com \
    --cc=linux-media@vger.kernel.org \
    --cc=s.nawrocki@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