From patchwork Fri Jul 14 18:06:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Eduardo Gallo Filho X-Patchwork-Id: 13314134 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 105FFC001B0 for ; Fri, 14 Jul 2023 18:08:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 13F5310E8CC; Fri, 14 Jul 2023 18:08:35 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5E41410E8CC for ; Fri, 14 Jul 2023 18:08:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 2026540BFF; Fri, 14 Jul 2023 20:08:32 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Sqflcgn8Xh3X; Fri, 14 Jul 2023 20:08:31 +0200 (CEST) From: Carlos Eduardo Gallo Filho DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1689358111; bh=3APKavHLl3ZkMGA6TxzMMhaHSrKm6w2x6zwKuukLtHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LWeTv64r5lEAHYelWNGXWQOQ9Sqq0e0+nng3MKoLyE+Mi/n+cl1AcMris53ELZ9YC V0+qrTpZrdPswnXILPXL5fNvZS6pz8HlVyFITDe3TAGJ5+Ma+4/VgyMfzi8BiJCrf+ C0nY/Gn9KlZEnae5Hlnlk2ITz+wIqfWuajSJCRDgkJsew7SMghra6yPzVUE3Wznp6l 0R65DXom9MqcBU4GL2knzRNxx1r0O/p04qYgn6azmOk4R3+5134dQnlSsIzr+8w/lr AcIlRaRhRJTCatm1ADV8fHN3Ol7waWYqaeJWnOI0FFn2TV2s/X9pVIABn4fEX8R973 ZmfAYv2OaV1mA== To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/4] drm: Add kernel-doc for drm_framebuffer_check_src_coords() Date: Fri, 14 Jul 2023 15:06:16 -0300 Message-ID: <20230714180619.15850-2-gcarlos@disroot.org> In-Reply-To: <20230714180619.15850-1-gcarlos@disroot.org> References: <20230714180619.15850-1-gcarlos@disroot.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrealmeid@igalia.com, tzimmermann@suse.de, tales.aparecida@gmail.com, mripard@kernel.org, mairacanal@riseup.net, Carlos Eduardo Gallo Filho , davidgow@google.com, michal.winiarski@intel.com, arthurgrillo@riseup.net Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Signed-off-by: Carlos Eduardo Gallo Filho --- drivers/gpu/drm/drm_framebuffer.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index aff3746dedfb..49df3ca3b3ee 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -73,6 +73,21 @@ * drm_framebuffer. */ +/** + * drm_framebuffer_check_src_coords - check if the source with given + * coordinates and sizes is inside the framebuffer + * @src_x: source x coordinate + * @src_y: source y coordinate + * @src_w: source width + * @src_h: source height + * @fb: pointer to the framebuffer to check + * + * This function checks if an object with the given set of coordinates and + * sizes fits inside the framebuffer by looking at its size. + * + * Returns: + * Zero on success, negative errno on failure. + */ int drm_framebuffer_check_src_coords(uint32_t src_x, uint32_t src_y, uint32_t src_w, uint32_t src_h, const struct drm_framebuffer *fb) @@ -82,7 +97,6 @@ int drm_framebuffer_check_src_coords(uint32_t src_x, uint32_t src_y, fb_width = fb->width << 16; fb_height = fb->height << 16; - /* Make sure source coordinates are inside the fb. */ if (src_w > fb_width || src_x > fb_width - src_w || src_h > fb_height || From patchwork Fri Jul 14 18:06:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Eduardo Gallo Filho X-Patchwork-Id: 13314135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC916C001B0 for ; Fri, 14 Jul 2023 18:08:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B606F10E8CD; Fri, 14 Jul 2023 18:08:42 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1D29210E8CD for ; Fri, 14 Jul 2023 18:08:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id C2CFF417DF; Fri, 14 Jul 2023 20:08:38 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x634WJrbEqXS; Fri, 14 Jul 2023 20:08:37 +0200 (CEST) From: Carlos Eduardo Gallo Filho DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1689358117; bh=BUdWzGGUIraxiwSGjTBXbs/5tBXQvtbqo8XCpVksx8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Lp+57JqlATj+nHs2KwNdFMzV6BY7KdwItr1z5YKYGlWKWkGXFUUPzHHsWrSCUl2Hz RYQYgR92eSoCythPHgB0UIvr8dJtO5aPhL9/GzqgH3QeaZ4ySOKXF7uVGzzytR3M5l kd5U5vD6xo5p0eoUeoBg0mpLSAnEc55V/9a20ShhIIzlW2ryLingzNTepjRoTeyRDX C0imO2jpss6ahVIm1u4Iy89cIbZpwbvOOocpKAqIgPTcrlR0hCaEkYkJ+zGzVcGfeo X4iQD1WWpYUzC9MkCmkD+itR1YryxU0Zb/m7AAvvN5G+j1AwXEb+LK4LdhsynbasZh LSJa55rSnn5zQ== To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/4] drm/tests: Add test for drm_framebuffer_check_src_coords() Date: Fri, 14 Jul 2023 15:06:17 -0300 Message-ID: <20230714180619.15850-3-gcarlos@disroot.org> In-Reply-To: <20230714180619.15850-1-gcarlos@disroot.org> References: <20230714180619.15850-1-gcarlos@disroot.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrealmeid@igalia.com, tzimmermann@suse.de, tales.aparecida@gmail.com, mripard@kernel.org, mairacanal@riseup.net, Carlos Eduardo Gallo Filho , davidgow@google.com, michal.winiarski@intel.com, arthurgrillo@riseup.net Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a parametrized test for the drm_framebuffer_check_src_coords function. Signed-off-by: Carlos Eduardo Gallo Filho --- drivers/gpu/drm/tests/drm_framebuffer_test.c | 107 +++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_framebuffer_test.c b/drivers/gpu/drm/tests/drm_framebuffer_test.c index f759d9f3b76e..175146f7ac9e 100644 --- a/drivers/gpu/drm/tests/drm_framebuffer_test.c +++ b/drivers/gpu/drm/tests/drm_framebuffer_test.c @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -366,8 +367,114 @@ static void drm_framebuffer_test_to_desc(const struct drm_framebuffer_test *t, c KUNIT_ARRAY_PARAM(drm_framebuffer_create, drm_framebuffer_create_cases, drm_framebuffer_test_to_desc); +struct check_src_coords_case { + const int expect; + const uint32_t src_x; + const uint32_t src_y; + const uint32_t src_w; + const uint32_t src_h; + const struct drm_framebuffer fb; + const char *name; +}; + +static const struct check_src_coords_case check_src_coords_cases[] = { + { .name = "source inside framebuffer", + .expect = 0, + .src_x = 500 << 16, .src_y = 700 << 16, + .src_w = 100 << 16, .src_h = 100 << 16, + .fb = { .width = 600, .height = 800 } + }, + { .name = "out of bound with normal sizes and coordinates", + .expect = -ENOSPC, + .src_x = (500 << 16) + 1, .src_y = (700 << 16) + 1, + .src_w = 100 << 16, .src_h = 100 << 16, + .fb = { .width = 600, .height = 800 } + }, + { .name = "source width higher than framebuffer width", + .expect = -ENOSPC, + .src_x = 0, .src_y = 700 << 16, + .src_w = (600 << 16) + 1, .src_h = 100 << 16, + .fb = { .width = 600, .height = 800 } + }, + { .name = "source width equal framebuffer width with x coordinates 0", + .expect = 0, + .src_x = 0, .src_y = 700 << 16, + .src_w = 600 << 16, .src_h = 100 << 16, + .fb = { .width = 600, .height = 800 } + }, + { .name = "source width equal framebuffer width with non-zero x coordinate", + .expect = -ENOSPC, + .src_x = 1, .src_y = 700 << 16, + .src_w = 600 << 16, .src_h = 100 << 16, + .fb = { .width = 600, .height = 800 } + }, + { .name = "out of bound with normal width and x", + .expect = -ENOSPC, + .src_x = (500 << 16) + 1, .src_y = 700 << 16, + .src_w = 100 << 16, .src_h = 100 << 16, + .fb = { .width = 600, .height = 800 } + }, + { .name = "x coordinate higher than framebuffer width", + .expect = -ENOSPC, + .src_x = (600 << 16) + 1, .src_y = 700 << 16, + .src_w = 0, .src_h = 100 << 16, + .fb = { .width = 600, .height = 800 } + }, + { .name = "source height higher than framebuffer height", + .expect = -ENOSPC, + .src_x = 700 << 16, .src_y = 0, + .src_w = 100 << 16, .src_h = (600 << 16) + 1, + .fb = { .width = 800, .height = 600 } + }, + { .name = "source height equal framebuffer height with y coordinates 0", + .expect = 0, + .src_x = 700 << 16, .src_y = 0, + .src_w = 100 << 16, .src_h = 600 << 16, + .fb = { .width = 800, .height = 600 } + }, + { .name = "source height equal framebuffer height with non-zero y coordinate", + .expect = -ENOSPC, + .src_x = 700 << 16, .src_y = 1, + .src_w = 100 << 16, .src_h = 600 << 16, + .fb = { .width = 800, .height = 600 } + }, + { .name = "out of bound with normal height and y", + .expect = -ENOSPC, + .src_x = 700 << 16, .src_y = (500 << 16) + 1, + .src_w = 100 << 16, .src_h = 100 << 16, + .fb = { .width = 800, .height = 600 } + }, + { .name = "y coordinate higher than framebuffer height", + .expect = -ENOSPC, + .src_x = 700 << 16, .src_y = (600 << 16) + 1, + .src_w = 100 << 16, .src_h = 0, + .fb = { .width = 800, .height = 600 } + }, +}; + +static void drm_test_framebuffer_check_src_coords(struct kunit *test) +{ + const struct check_src_coords_case *params = test->param_value; + int r; + + r = drm_framebuffer_check_src_coords(params->src_x, params->src_y, + params->src_w, params->src_h, + ¶ms->fb); + KUNIT_EXPECT_EQ(test, r, params->expect); +} + +static void check_src_coords_test_to_desc(const struct check_src_coords_case *t, + char *desc) +{ + strcpy(desc, t->name); +} + +KUNIT_ARRAY_PARAM(check_src_coords, check_src_coords_cases, + check_src_coords_test_to_desc); + static struct kunit_case drm_framebuffer_tests[] = { KUNIT_CASE_PARAM(drm_test_framebuffer_create, drm_framebuffer_create_gen_params), + KUNIT_CASE_PARAM(drm_test_framebuffer_check_src_coords, check_src_coords_gen_params), { } }; From patchwork Fri Jul 14 18:06:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Eduardo Gallo Filho X-Patchwork-Id: 13314136 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2FA94EB64DC for ; Fri, 14 Jul 2023 18:08:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 420DA10E8D0; Fri, 14 Jul 2023 18:08:48 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id AAA1410E8CF for ; Fri, 14 Jul 2023 18:08:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 6BCAB41619; Fri, 14 Jul 2023 20:08:43 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id W4usPE5h62UI; Fri, 14 Jul 2023 20:08:42 +0200 (CEST) From: Carlos Eduardo Gallo Filho DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1689358122; bh=eNsFTZyfa6jXYsfPIjmOFdv9yK0UIKUp42WQf0szOjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CeWWvy+qKOSIZm0d1blt7ekEh1dNKxAhifeobOHgR2J6MI+ZWq+bxnh0WmT7faTbF qgvXwlIRm3VLo98NJpvOFTHLoOc22o/YiDgfhefTlluRMmR4ur48y8qrqsLXmq7O2y Zic1eaAzSOSN1DJOxok2S5DtTY2GMYq7qOSdH5aHuoJB3mj31RlnRHX3/IErVygzKn xuCDlet+bVK62QMoPaxKN5FJ/C6AEh4rwzysTiSEhy6PfTW6Nh4jZRF6SfuVNdqRj8 QFrihufTRGiiBbLBbhtp/VE5gnK+Xln0W23fRPifZjANu5qE6HsX6cTwRSMxXpigu9 qT7OsR/RtLajQ== To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/4] drm/tests: Add parameters to the drm_test_framebuffer_create test Date: Fri, 14 Jul 2023 15:06:18 -0300 Message-ID: <20230714180619.15850-4-gcarlos@disroot.org> In-Reply-To: <20230714180619.15850-1-gcarlos@disroot.org> References: <20230714180619.15850-1-gcarlos@disroot.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrealmeid@igalia.com, tzimmermann@suse.de, tales.aparecida@gmail.com, mripard@kernel.org, mairacanal@riseup.net, Carlos Eduardo Gallo Filho , davidgow@google.com, michal.winiarski@intel.com, arthurgrillo@riseup.net Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Extend the existing test case to cover: 1. Invalid flag atribute in the struct drm_mode_fb_cmd2. 2. Pixel format which requires non-linear modifier with DRM_FORMAT_MOD_LINEAR set. 3. Non-zero buffer offset for an unused plane Signed-off-by: Carlos Eduardo Gallo Filho --- drivers/gpu/drm/tests/drm_framebuffer_test.c | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_framebuffer_test.c b/drivers/gpu/drm/tests/drm_framebuffer_test.c index 175146f7ac9e..1fbb534b2e22 100644 --- a/drivers/gpu/drm/tests/drm_framebuffer_test.c +++ b/drivers/gpu/drm/tests/drm_framebuffer_test.c @@ -20,6 +20,8 @@ #define MIN_HEIGHT 4 #define MAX_HEIGHT 4096 +#define DRM_MODE_FB_INVALID BIT(2) + struct drm_framebuffer_test { int buffer_created; struct drm_mode_fb_cmd2 cmd; @@ -84,6 +86,18 @@ static const struct drm_framebuffer_test drm_framebuffer_create_cases[] = { .pitches = { 4 * MAX_WIDTH, 0, 0 }, } }, +{ .buffer_created = 0, .name = "ABGR8888 Non-zero buffer offset for unused plane", + .cmd = { .width = MAX_WIDTH, .height = MAX_HEIGHT, .pixel_format = DRM_FORMAT_ABGR8888, + .handles = { 1, 0, 0 }, .offsets = { UINT_MAX / 2, UINT_MAX / 2, 0 }, + .pitches = { 4 * MAX_WIDTH, 0, 0 }, .flags = DRM_MODE_FB_MODIFIERS, + } +}, +{ .buffer_created = 0, .name = "ABGR8888 Invalid flag", + .cmd = { .width = MAX_WIDTH, .height = MAX_HEIGHT, .pixel_format = DRM_FORMAT_ABGR8888, + .handles = { 1, 0, 0 }, .offsets = { UINT_MAX / 2, 0, 0 }, + .pitches = { 4 * MAX_WIDTH, 0, 0 }, .flags = DRM_MODE_FB_INVALID, + } +}, { .buffer_created = 1, .name = "ABGR8888 Set DRM_MODE_FB_MODIFIERS without modifiers", .cmd = { .width = MAX_WIDTH, .height = MAX_HEIGHT, .pixel_format = DRM_FORMAT_ABGR8888, .handles = { 1, 0, 0 }, .offsets = { UINT_MAX / 2, 0, 0 }, @@ -263,6 +277,13 @@ static const struct drm_framebuffer_test drm_framebuffer_create_cases[] = { .pitches = { MAX_WIDTH, DIV_ROUND_UP(MAX_WIDTH, 2), DIV_ROUND_UP(MAX_WIDTH, 2) }, } }, +{ .buffer_created = 0, .name = "YUV420_10BIT Invalid modifier(DRM_FORMAT_MOD_LINEAR)", + .cmd = { .width = MAX_WIDTH, .height = MAX_HEIGHT, .pixel_format = DRM_FORMAT_YUV420_10BIT, + .handles = { 1, 0, 0 }, .flags = DRM_MODE_FB_MODIFIERS, + .modifier = { DRM_FORMAT_MOD_LINEAR, 0, 0 }, + .pitches = { MAX_WIDTH, 0, 0 }, + } +}, { .buffer_created = 1, .name = "X0L2 Normal sizes", .cmd = { .width = 600, .height = 600, .pixel_format = DRM_FORMAT_X0L2, .handles = { 1, 0, 0 }, .pitches = { 1200, 0, 0 } From patchwork Fri Jul 14 18:06:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Eduardo Gallo Filho X-Patchwork-Id: 13314137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7331AC001B0 for ; Fri, 14 Jul 2023 18:08:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B7FC10E8D3; Fri, 14 Jul 2023 18:08:53 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A65D10E8D2 for ; Fri, 14 Jul 2023 18:08:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 01A5940B42; Fri, 14 Jul 2023 20:08:48 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nFB0oipgnOCk; Fri, 14 Jul 2023 20:08:46 +0200 (CEST) From: Carlos Eduardo Gallo Filho DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1689358126; bh=kpryaEClraU066T2dbISwNctGwV1TRNDGalAYs3XCFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=g9s3K3glvTNWEmqmlvbQYY4wulTg9mLRXm324OcxNchEWt2rcvIbF9zRc83Wl8mDi Vi/WUVimrQd3No9i/9WAafsNELvE0rk+u9v5qUdEfJefiwQqiHKlRT1+UDiWV3jucm ZRkSEyWUs8UidsiRDSbv56O/ecMoCJtF1WZjz8Qxz+k6n4lck+bQQl/7P0ZEmmcean 0r/34KiOg0MtKZTxYUIakA2maVhuODx7zcGDwp/iuJ+wrCYi/wl5/vYUbbBU93pdYj hPzwbumPZgVlBiVurWbE+TUhQyiRWw4Gv+qCcWJyDeDJYJM/oQOlhjWOv1q1KsuFH0 vjoZyOxc8id6g== To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] drm/tests: Add test case for drm_internal_framebuffer_create() Date: Fri, 14 Jul 2023 15:06:19 -0300 Message-ID: <20230714180619.15850-5-gcarlos@disroot.org> In-Reply-To: <20230714180619.15850-1-gcarlos@disroot.org> References: <20230714180619.15850-1-gcarlos@disroot.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrealmeid@igalia.com, tzimmermann@suse.de, tales.aparecida@gmail.com, mripard@kernel.org, mairacanal@riseup.net, Carlos Eduardo Gallo Filho , davidgow@google.com, michal.winiarski@intel.com, arthurgrillo@riseup.net Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Introduce a test to cover the creation of a framebuffer with a setted modifier and a driver that don't support modifiers. Signed-off-by: Carlos Eduardo Gallo Filho --- drivers/gpu/drm/tests/drm_framebuffer_test.c | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_framebuffer_test.c b/drivers/gpu/drm/tests/drm_framebuffer_test.c index 1fbb534b2e22..7ee595321462 100644 --- a/drivers/gpu/drm/tests/drm_framebuffer_test.c +++ b/drivers/gpu/drm/tests/drm_framebuffer_test.c @@ -388,6 +388,26 @@ static void drm_framebuffer_test_to_desc(const struct drm_framebuffer_test *t, c KUNIT_ARRAY_PARAM(drm_framebuffer_create, drm_framebuffer_create_cases, drm_framebuffer_test_to_desc); +static void drm_test_framebuffer_modifiers_not_supported(struct kunit *test) +{ + struct drm_mode_fb_cmd2 cmd = { + .width = MAX_WIDTH, .height = MAX_HEIGHT, + .pixel_format = DRM_FORMAT_ABGR8888, .handles = { 1, 0, 0 }, + .offsets = { UINT_MAX / 2, 0, 0 }, .pitches = { 4 * MAX_WIDTH, 0, 0 }, + .flags = DRM_MODE_FB_MODIFIERS, + }; + struct drm_device *mock = test->priv; + int buffer_created = 0; + + mock->dev_private = &buffer_created; + mock->mode_config.fb_modifiers_not_supported = 1; + + drm_internal_framebuffer_create(mock, &cmd, NULL); + KUNIT_EXPECT_EQ(test, 0, buffer_created); + + mock->mode_config.fb_modifiers_not_supported = 0; +} + struct check_src_coords_case { const int expect; const uint32_t src_x; @@ -494,6 +514,7 @@ KUNIT_ARRAY_PARAM(check_src_coords, check_src_coords_cases, check_src_coords_test_to_desc); static struct kunit_case drm_framebuffer_tests[] = { + KUNIT_CASE(drm_test_framebuffer_modifiers_not_supported), KUNIT_CASE_PARAM(drm_test_framebuffer_create, drm_framebuffer_create_gen_params), KUNIT_CASE_PARAM(drm_test_framebuffer_check_src_coords, check_src_coords_gen_params), { }