From patchwork Fri Feb 3 14:41:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 9554251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AD4BC602B7 for ; Fri, 3 Feb 2017 14:41:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E0C228401 for ; Fri, 3 Feb 2017 14:41:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92D44284F4; Fri, 3 Feb 2017 14:41:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 09FA328401 for ; Fri, 3 Feb 2017 14:41:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F5FC6EB9D; Fri, 3 Feb 2017 14:41:31 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by gabe.freedesktop.org (Postfix) with ESMTPS id 33EB26EB9D for ; Fri, 3 Feb 2017 14:41:30 +0000 (UTC) Received: from e110455-lin.cambridge.arm.com (e110455-lin.cambridge.arm.com [10.2.131.175]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id v13EfSOh005193; Fri, 3 Feb 2017 14:41:28 GMT From: Liviu Dudau To: Emil Velikov Subject: [PATCH libdrm] tests: Fix pattern filler routines for 10-bit RGB colours Date: Fri, 3 Feb 2017 14:41:27 +0000 Message-Id: <20170203144127.15960-1-Liviu.Dudau@arm.com> X-Mailer: git-send-email 2.11.0 Cc: DRI-devel X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The routines that fill the framebuffer with colour data don't work properly for data formats that use 10 bits for RGB colours. Add sibling routines for those formats and use them where appropriate. Signed-off-by: Liviu Dudau --- tests/util/pattern.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 100 insertions(+), 2 deletions(-) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index 00b08a8c..4eed9771 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -70,6 +70,12 @@ struct color_yuv { (((b) >> (8 - (rgb)->blue.length)) << (rgb)->blue.offset) | \ (((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset)) +#define MAKE_RGBA30(rgb, r, g, b, a) \ + ((((r) >> (10 - (rgb)->red.length)) << (rgb)->red.offset) | \ + (((g) >> (10 - (rgb)->green.length)) << (rgb)->green.offset) | \ + (((b) >> (10 - (rgb)->blue.length)) << (rgb)->blue.offset) | \ + (((a) >> (8 - (rgb)->alpha.length)) << (rgb)->alpha.offset)) + #define MAKE_RGB24(rgb, r, g, b) \ { .value = MAKE_RGBA(rgb, r, g, b, 0) } @@ -461,6 +467,67 @@ static void fill_smpte_rgb32(const struct util_rgb_info *rgb, void *mem, } } +static void fill_smpte_rgb30(const struct util_rgb_info *rgb, void *mem, + unsigned int width, unsigned int height, + unsigned int stride) +{ + const uint32_t colors_top[] = { + MAKE_RGBA30(rgb, 768, 768, 768, 255), /* grey */ + MAKE_RGBA30(rgb, 768, 768, 0, 255), /* yellow */ + MAKE_RGBA30(rgb, 0, 768, 768, 255), /* cyan */ + MAKE_RGBA30(rgb, 0, 768, 0, 255), /* green */ + MAKE_RGBA30(rgb, 768, 0, 768, 255), /* magenta */ + MAKE_RGBA30(rgb, 768, 0, 0, 255), /* red */ + MAKE_RGBA30(rgb, 0, 0, 768, 255), /* blue */ + }; + const uint32_t colors_middle[] = { + MAKE_RGBA30(rgb, 0, 0, 768, 127), /* blue */ + MAKE_RGBA30(rgb, 76, 76, 76, 127), /* black */ + MAKE_RGBA30(rgb, 768, 0, 768, 127), /* magenta */ + MAKE_RGBA30(rgb, 76, 76, 76, 127), /* black */ + MAKE_RGBA30(rgb, 0, 768, 768, 127), /* cyan */ + MAKE_RGBA30(rgb, 76, 76, 76, 127), /* black */ + MAKE_RGBA30(rgb, 768, 768, 768, 127), /* grey */ + }; + const uint32_t colors_bottom[] = { + MAKE_RGBA30(rgb, 0, 132, 304, 255), /* in-phase */ + MAKE_RGBA30(rgb, 1020, 1020, 1020, 255),/* super white */ + MAKE_RGBA30(rgb, 200, 0, 424, 255), /* quadrature */ + MAKE_RGBA30(rgb, 76, 76, 76, 255), /* black */ + MAKE_RGBA30(rgb, 36, 36, 36, 255), /* 3.5% */ + MAKE_RGBA30(rgb, 76, 76, 76, 255), /* 7.5% */ + MAKE_RGBA30(rgb, 116, 116, 116, 255), /* 11.5% */ + MAKE_RGBA30(rgb, 76, 76, 76, 255), /* black */ + }; + unsigned int x; + unsigned int y; + + for (y = 0; y < height * 6 / 9; ++y) { + for (x = 0; x < width; ++x) + ((uint32_t *)mem)[x] = colors_top[x * 7 / width]; + mem += stride; + } + + for (; y < height * 7 / 9; ++y) { + for (x = 0; x < width; ++x) + ((uint32_t *)mem)[x] = colors_middle[x * 7 / width]; + mem += stride; + } + + for (; y < height; ++y) { + for (x = 0; x < width * 5 / 7; ++x) + ((uint32_t *)mem)[x] = + colors_bottom[x * 4 / (width * 5 / 7)]; + for (; x < width * 6 / 7; ++x) + ((uint32_t *)mem)[x] = + colors_bottom[(x - width * 5 / 7) * 3 + / (width / 7) + 4]; + for (; x < width; ++x) + ((uint32_t *)mem)[x] = colors_bottom[7]; + mem += stride; + } +} + static void fill_smpte(const struct util_format_info *info, void *planes[3], unsigned int width, unsigned int height, unsigned int stride) @@ -525,6 +592,8 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_RGBX8888: case DRM_FORMAT_BGRA8888: case DRM_FORMAT_BGRX8888: + return fill_smpte_rgb32(&info->rgb, planes[0], + width, height, stride); case DRM_FORMAT_ARGB2101010: case DRM_FORMAT_XRGB2101010: case DRM_FORMAT_ABGR2101010: @@ -533,7 +602,7 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_RGBX1010102: case DRM_FORMAT_BGRA1010102: case DRM_FORMAT_BGRX1010102: - return fill_smpte_rgb32(&info->rgb, planes[0], + return fill_smpte_rgb30(&info->rgb, planes[0], width, height, stride); } } @@ -747,6 +816,33 @@ static void fill_tiles_rgb32(const struct util_format_info *info, void *mem, make_pwetty(mem_base, width, height, stride, info->format); } +static void fill_tiles_rgb30(const struct util_format_info *info, void *mem, + unsigned int width, unsigned int height, + unsigned int stride) +{ + const struct util_rgb_info *rgb = &info->rgb; + void *mem_base = mem; + unsigned int x, y; + + for (y = 0; y < height; ++y) { + for (x = 0; x < width; ++x) { + div_t d = div(x+y, width); + uint32_t rgb32 = 0x004c1408 * (d.quot >> 6) + + 0x00284480 * (d.rem >> 6); + uint32_t alpha = ((y < height/2) && (x < width/2)) ? 127 : 255; + uint32_t color = + MAKE_RGBA30(rgb, (rgb32 >> 16) & 0x3ff, + (rgb32 >> 8) & 0x3ff, rgb32 & 0x3ff, + alpha); + + ((uint32_t *)mem)[x] = color; + } + mem += stride; + } + + make_pwetty(mem_base, width, height, stride, info->format); +} + static void fill_tiles(const struct util_format_info *info, void *planes[3], unsigned int width, unsigned int height, unsigned int stride) @@ -811,6 +907,8 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_RGBX8888: case DRM_FORMAT_BGRA8888: case DRM_FORMAT_BGRX8888: + return fill_tiles_rgb32(info, planes[0], + width, height, stride); case DRM_FORMAT_ARGB2101010: case DRM_FORMAT_XRGB2101010: case DRM_FORMAT_ABGR2101010: @@ -819,7 +917,7 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_RGBX1010102: case DRM_FORMAT_BGRA1010102: case DRM_FORMAT_BGRX1010102: - return fill_tiles_rgb32(info, planes[0], + return fill_tiles_rgb30(info, planes[0], width, height, stride); } }