All of lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH v2 8/8] lib/igt_fb: Make sure tiled YUV framebuffers are fully cleared
Date: Tue, 11 Feb 2020 04:31:08 +0200	[thread overview]
Message-ID: <20200211023108.25369-8-imre.deak@intel.com> (raw)
In-Reply-To: <20200211023108.25369-1-imre.deak@intel.com>

For tiled FBs that are mapped in an other way than a GTT map we need to
clear all tile-rows. Clearing only the first stride*height bytes may
leave tiles at the end of the FB uncleared.

v2:
- Don't calculate the plane size for unused planes. (Matt)

Cc: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
---
 lib/igt_fb.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index af3291a2..8bdb0a09 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -841,10 +841,21 @@ static void memset64(uint64_t *s, uint64_t c, size_t n)
 static void clear_yuv_buffer(struct igt_fb *fb)
 {
 	bool full_range = fb->color_range == IGT_COLOR_YCBCR_FULL_RANGE;
+	size_t plane_size[2];
 	void *ptr;
 
 	igt_assert(igt_format_is_yuv(fb->drm_format));
 
+	for (int i = 0; i < lookup_drm_format(fb->drm_format)->num_planes; i++) {
+		unsigned int tile_width, tile_height;
+
+		igt_assert_lt(i, ARRAY_SIZE(plane_size));
+		igt_get_fb_tile_size(fb->fd, fb->modifier, fb->plane_bpp[i],
+				     &tile_width, &tile_height);
+		plane_size[i] = fb->strides[i] *
+			ALIGN(fb->plane_height[i], tile_height);
+	}
+
 	/* Ensure the framebuffer is preallocated */
 	ptr = igt_fb_map_buffer(fb->fd, fb);
 	igt_assert(*(uint32_t *)ptr == 0);
@@ -853,48 +864,48 @@ static void clear_yuv_buffer(struct igt_fb *fb)
 	case DRM_FORMAT_NV12:
 		memset(ptr + fb->offsets[0],
 		       full_range ? 0x00 : 0x10,
-		       fb->strides[0] * fb->plane_height[0]);
+		       plane_size[0]);
 		memset(ptr + fb->offsets[1],
 		       0x80,
-		       fb->strides[1] * fb->plane_height[1]);
+		       plane_size[1]);
 		break;
 	case DRM_FORMAT_XYUV8888:
 		wmemset(ptr + fb->offsets[0], full_range ? 0x00008080 : 0x00108080,
-			fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
+			plane_size[0] / sizeof(wchar_t));
 		break;
 	case DRM_FORMAT_YUYV:
 	case DRM_FORMAT_YVYU:
 		wmemset(ptr + fb->offsets[0],
 			full_range ? 0x80008000 : 0x80108010,
-			fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
+			plane_size[0] / sizeof(wchar_t));
 		break;
 	case DRM_FORMAT_UYVY:
 	case DRM_FORMAT_VYUY:
 		wmemset(ptr + fb->offsets[0],
 			full_range ? 0x00800080 : 0x10801080,
-			fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
+			plane_size[0] / sizeof(wchar_t));
 		break;
 	case DRM_FORMAT_P010:
 	case DRM_FORMAT_P012:
 	case DRM_FORMAT_P016:
 		wmemset(ptr, full_range ? 0 : 0x10001000,
-			fb->offsets[1] / sizeof(wchar_t));
+			plane_size[0] / sizeof(wchar_t));
 		wmemset(ptr + fb->offsets[1], 0x80008000,
-			fb->strides[1] * fb->plane_height[1] / sizeof(wchar_t));
+			plane_size[1] / sizeof(wchar_t));
 		break;
 	case DRM_FORMAT_Y210:
 	case DRM_FORMAT_Y212:
 	case DRM_FORMAT_Y216:
 		wmemset(ptr + fb->offsets[0],
 			full_range ? 0x80000000 : 0x80001000,
-			fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
+			plane_size[0] / sizeof(wchar_t));
 		break;
 
 	case DRM_FORMAT_XVYU2101010:
 	case DRM_FORMAT_Y410:
 		wmemset(ptr + fb->offsets[0],
 			full_range ? 0x20000200 : 0x20010200,
-		fb->strides[0] * fb->plane_height[0] / sizeof(wchar_t));
+			plane_size[0] / sizeof(wchar_t));
 		break;
 
 	case DRM_FORMAT_XVYU12_16161616:
@@ -903,7 +914,7 @@ static void clear_yuv_buffer(struct igt_fb *fb)
 	case DRM_FORMAT_Y416:
 		memset64(ptr + fb->offsets[0],
 			 full_range ? 0x800000008000ULL : 0x800010008000ULL,
-			 fb->strides[0] * fb->plane_height[0] / sizeof(uint64_t));
+			 plane_size[0] / sizeof(uint64_t));
 		break;
 	}
 
-- 
2.23.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2020-02-11  2:31 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11  2:31 [igt-dev] [PATCH v2 1/8] lib/igt_draw: Refactor get_tiling calls Imre Deak
2020-02-11  2:31 ` [igt-dev] [PATCH v2 2/8] tests/kms_frontbuffer_tracking: Skip set tiling calls if not supported Imre Deak
2020-02-11  2:31 ` [igt-dev] [PATCH v2 3/8] tests/kms_available_modes_crc: Don't set tiling for framebuffer Imre Deak
2020-02-11 20:15   ` Dixit, Ashutosh
2020-02-11 20:42     ` Imre Deak
2020-02-11 22:35       ` Dixit, Ashutosh
2020-02-11  2:31 ` [igt-dev] [PATCH v2 4/8] tests/kms_draw_crc: Skip GTT subtests on platforms w/o aperture Imre Deak
2020-02-12  0:17   ` Dixit, Ashutosh
2020-02-12  2:41     ` Dixit, Ashutosh
2020-02-12  2:49       ` Dixit, Ashutosh
2020-02-11  2:31 ` [igt-dev] [PATCH v2 5/8] tests/kms_draw_crc: Fix generating reference CRCs " Imre Deak
2020-02-11 15:34   ` Matt Roper
2020-02-12  0:29   ` Dixit, Ashutosh
2020-02-12 10:23     ` Imre Deak
2020-02-12 16:57       ` Imre Deak
2020-02-12 21:50   ` [igt-dev] [PATCH v3 " Imre Deak
2020-02-13  4:20     ` Dixit, Ashutosh
2020-02-13  8:09       ` Imre Deak
2020-02-11  2:31 ` [igt-dev] [PATCH v2 6/8] tests/kms_frontbuffer_tracking: Skip GTT subtests " Imre Deak
2020-02-11 15:45   ` Matt Roper
2020-02-11 15:53     ` Imre Deak
2020-02-12  5:45   ` Dixit, Ashutosh
2020-02-12 17:01     ` Imre Deak
2020-02-12 21:50   ` [igt-dev] [PATCH v3 " Imre Deak
2020-02-13  4:34     ` Dixit, Ashutosh
2020-02-11  2:31 ` [igt-dev] [PATCH v2 7/8] lib/igt_draw: Fix igt_draw_fill_fb() " Imre Deak
2020-02-12  3:48   ` Dixit, Ashutosh
2020-02-12 21:50   ` [igt-dev] [PATCH v3 " Imre Deak
2020-02-13  4:22     ` Dixit, Ashutosh
2020-02-11  2:31 ` Imre Deak [this message]
2020-02-11  3:21 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [v2,1/8] lib/igt_draw: Refactor get_tiling calls Patchwork
2020-02-11 15:33 ` [igt-dev] [PATCH v2 1/8] " Matt Roper
2020-02-12 16:46 ` [igt-dev] ✓ Fi.CI.IGT: success for series starting with [v2,1/8] " Patchwork
2020-02-13  8:26   ` Imre Deak
2020-02-12 22:36 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [v2,1/8] lib/igt_draw: Refactor get_tiling calls (rev4) Patchwork
2020-02-15 17:55 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

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=20200211023108.25369-8-imre.deak@intel.com \
    --to=imre.deak@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.